Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Liberate: add /migrate allias for /liberate
  • Loading branch information
nightnei committed Jul 7, 2026
commit a35671bf6e4e021fcb2fe18a3a94c7687110e683
10 changes: 9 additions & 1 deletion packages/common/ai/slash-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { __ } from '@wordpress/i18n';
export interface SkillSlashCommand {
name: string;
description: string;
/** Skill invoked by this command when it differs from `name` (alias commands). */
skill?: string;
}

export const AI_SKILL_COMMANDS: SkillSlashCommand[] = [
Expand All @@ -14,8 +16,14 @@ export const AI_SKILL_COMMANDS: SkillSlashCommand[] = [
name: 'liberate',
description: __( 'Import & rebuild a site from a closed platform' ),
},
{
name: 'migrate',
skill: 'liberate',
description: __( 'Import & rebuild a site from a closed platform (alias of /liberate)' ),
},
];

export function buildSkillInvocationPrompt( name: string ): string {
return `Run the /${ name } skill using the Skill tool.`;
const skill = AI_SKILL_COMMANDS.find( ( cmd ) => cmd.name === name )?.skill ?? name;
return `Run the /${ skill } skill using the Skill tool.`;
}
31 changes: 31 additions & 0 deletions packages/common/ai/tests/slash-commands.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { describe, expect, it } from 'vitest';
import { AI_SKILL_COMMANDS, buildSkillInvocationPrompt } from '../slash-commands';

describe( 'buildSkillInvocationPrompt', () => {
it( 'invokes the skill matching the command name', () => {
expect( buildSkillInvocationPrompt( 'liberate' ) ).toBe(
'Run the /liberate skill using the Skill tool.'
);
} );

it( 'resolves alias commands to their target skill', () => {
expect( buildSkillInvocationPrompt( 'migrate' ) ).toBe(
'Run the /liberate skill using the Skill tool.'
);
} );

it( 'falls back to the given name for unknown commands', () => {
expect( buildSkillInvocationPrompt( 'unknown-skill' ) ).toBe(
'Run the /unknown-skill skill using the Skill tool.'
);
} );

it( 'aliases point at a skill provided by another command', () => {
const names = new Set( AI_SKILL_COMMANDS.map( ( cmd ) => cmd.name ) );
for ( const cmd of AI_SKILL_COMMANDS ) {
if ( cmd.skill ) {
expect( names ).toContain( cmd.skill );
}
}
} );
} );
Loading