Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/cli/commands/site/start.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { updateManagedInstructionFiles } from '@studio/common/lib/agent-skills';
import { SiteCommandLoggerAction as LoggerAction } from '@studio/common/logger-actions';
import { __ } from '@wordpress/i18n';
import {
Expand All @@ -6,6 +7,7 @@ import {
updateSiteLatestCliPid,
} from 'cli/lib/cli-config/sites';
import { connectToDaemon, disconnectFromDaemon } from 'cli/lib/daemon-client';
import { getAiInstructionsPath } from 'cli/lib/server-files';
import { logSiteDetails, openSiteInBrowser, setupCustomDomain } from 'cli/lib/site-utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { isServerRunning, startWordPressServer } from 'cli/lib/wordpress-server-manager';
Expand Down Expand Up @@ -52,6 +54,15 @@ export async function runCommand(
await keepSqliteIntegrationUpdated( sitePath );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

try {
await updateManagedInstructionFiles( sitePath, getAiInstructionsPath() );
} catch ( error ) {
logger.reportError(
new LoggerError( __( 'Failed to update AI instructions. Proceeding anyway…' ), error ),
false
);
}

logger.reportStart( LoggerAction.START_SITE, __( 'Starting WordPress server…' ) );
try {
const processDesc = await startWordPressServer( site, logger );
Expand Down
8 changes: 0 additions & 8 deletions apps/studio/src/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
installAiInstructionsToSite,
installSkillToSite,
removeSkillFromSite,
updateManagedInstructionFiles,
} from '@studio/common/lib/agent-skills';
import { validateBlueprintData } from '@studio/common/lib/blueprint-validation';
import { parseCliError, errorMessageContains } from '@studio/common/lib/cli-error';
Expand Down Expand Up @@ -598,13 +597,6 @@ export async function startServer( event: IpcMainInvokeEvent, id: string ): Prom
void loadThemeDetails( event, id );
}

// Keep managed instruction files (STUDIO.md, CLAUDE.md) up-to-date
void updateManagedInstructionFiles( server.details.path, getAiInstructionsPath() ).catch(
( error ) => {
console.error( '[ai-instructions] Failed to update managed instruction files:', error );
}
);

console.log( `Server started for '${ server.details.name }'` );
}

Expand Down
2 changes: 1 addition & 1 deletion tools/common/lib/agent-skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isErrnoException } from './is-errno-exception';
* Managed instruction files that are always kept up-to-date on server start.
* These are overwritten with the bundled version whenever they already exist in a site.
*/
const MANAGED_INSTRUCTION_FILES = [ 'STUDIO.md', 'CLAUDE.md' ];
const MANAGED_INSTRUCTION_FILES = [ 'STUDIO.md' ];

/**
* Install all bundled AI instructions and skills from a source directory into a site.
Expand Down
8 changes: 2 additions & 6 deletions tools/common/lib/tests/agent-skills.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe( 'updateManagedInstructionFiles', () => {
vi.mocked( fs.copyFile ).mockResolvedValue( undefined );
} );

it( 'updates STUDIO.md and CLAUDE.md when both exist in the site', async () => {
it( 'updates STUDIO.md when it exists in the site', async () => {
vi.mocked( pathExists ).mockResolvedValue( true );

await updateManagedInstructionFiles( SITE_PATH, BUNDLED_PATH );
Expand All @@ -328,11 +328,7 @@ describe( 'updateManagedInstructionFiles', () => {
path.join( BUNDLED_PATH, 'STUDIO.md' ),
path.join( SITE_PATH, 'STUDIO.md' )
);
expect( fs.copyFile ).toHaveBeenCalledWith(
path.join( BUNDLED_PATH, 'CLAUDE.md' ),
path.join( SITE_PATH, 'CLAUDE.md' )
);
expect( fs.copyFile ).toHaveBeenCalledTimes( 2 );
expect( fs.copyFile ).toHaveBeenCalledTimes( 1 );
} );

it( 'skips files that do not exist in the site', async () => {
Expand Down
Loading