@@ -995,6 +995,93 @@ describe('InitCommand', () => {
995995 ) ;
996996 expect ( crushChoice . configured ) . toBe ( true ) ;
997997 } ) ;
998+
999+ it ( 'should create CoStrict slash command files with templates' , async ( ) => {
1000+ queueSelections ( 'costrict' , DONE ) ;
1001+
1002+ await initCommand . execute ( testDir ) ;
1003+
1004+ const costrictProposal = path . join (
1005+ testDir ,
1006+ '.cospec/openspec/commands/openspec-proposal.md'
1007+ ) ;
1008+ const costrictApply = path . join (
1009+ testDir ,
1010+ '.cospec/openspec/commands/openspec-apply.md'
1011+ ) ;
1012+ const costrictArchive = path . join (
1013+ testDir ,
1014+ '.cospec/openspec/commands/openspec-archive.md'
1015+ ) ;
1016+
1017+ expect ( await fileExists ( costrictProposal ) ) . toBe ( true ) ;
1018+ expect ( await fileExists ( costrictApply ) ) . toBe ( true ) ;
1019+ expect ( await fileExists ( costrictArchive ) ) . toBe ( true ) ;
1020+
1021+ const proposalContent = await fs . readFile ( costrictProposal , 'utf-8' ) ;
1022+ expect ( proposalContent ) . toContain ( '---' ) ;
1023+ expect ( proposalContent ) . toContain ( 'description: "Scaffold a new OpenSpec change and validate strictly."' ) ;
1024+ expect ( proposalContent ) . toContain ( 'argument-hint: feature description or request' ) ;
1025+ expect ( proposalContent ) . toContain ( '<!-- OPENSPEC:START -->' ) ;
1026+ expect ( proposalContent ) . toContain ( '**Guardrails**' ) ;
1027+
1028+ const applyContent = await fs . readFile ( costrictApply , 'utf-8' ) ;
1029+ expect ( applyContent ) . toContain ( '---' ) ;
1030+ expect ( applyContent ) . toContain ( 'description: "Implement an approved OpenSpec change and keep tasks in sync."' ) ;
1031+ expect ( applyContent ) . toContain ( 'argument-hint: change-id' ) ;
1032+ expect ( applyContent ) . toContain ( 'Work through tasks sequentially' ) ;
1033+
1034+ const archiveContent = await fs . readFile ( costrictArchive , 'utf-8' ) ;
1035+ expect ( archiveContent ) . toContain ( '---' ) ;
1036+ expect ( archiveContent ) . toContain ( 'description: "Archive a deployed OpenSpec change and update specs."' ) ;
1037+ expect ( archiveContent ) . toContain ( 'argument-hint: change-id' ) ;
1038+ expect ( archiveContent ) . toContain ( 'openspec archive <id> --yes' ) ;
1039+ } ) ;
1040+
1041+ it ( 'should mark CoStrict as already configured during extend mode' , async ( ) => {
1042+ queueSelections ( 'costrict' , DONE , 'costrict' , DONE ) ;
1043+ await initCommand . execute ( testDir ) ;
1044+ await initCommand . execute ( testDir ) ;
1045+
1046+ const secondRunArgs = mockPrompt . mock . calls [ 1 ] [ 0 ] ;
1047+ const costrictChoice = secondRunArgs . choices . find (
1048+ ( choice : any ) => choice . value === 'costrict'
1049+ ) ;
1050+ expect ( costrictChoice . configured ) . toBe ( true ) ;
1051+ } ) ;
1052+
1053+ it ( 'should create COSTRICT.md when CoStrict is selected' , async ( ) => {
1054+ queueSelections ( 'costrict' , DONE ) ;
1055+
1056+ await initCommand . execute ( testDir ) ;
1057+
1058+ const costrictPath = path . join ( testDir , 'COSTRICT.md' ) ;
1059+ expect ( await fileExists ( costrictPath ) ) . toBe ( true ) ;
1060+
1061+ const content = await fs . readFile ( costrictPath , 'utf-8' ) ;
1062+ expect ( content ) . toContain ( '<!-- OPENSPEC:START -->' ) ;
1063+ expect ( content ) . toContain ( "@/openspec/AGENTS.md" ) ;
1064+ expect ( content ) . toContain ( 'openspec update' ) ;
1065+ expect ( content ) . toContain ( '<!-- OPENSPEC:END -->' ) ;
1066+ } ) ;
1067+
1068+ it ( 'should update existing COSTRICT.md with markers' , async ( ) => {
1069+ queueSelections ( 'costrict' , DONE ) ;
1070+
1071+ const costrictPath = path . join ( testDir , 'COSTRICT.md' ) ;
1072+ const existingContent =
1073+ '# My CoStrict Instructions\nCustom instructions here' ;
1074+ await fs . writeFile ( costrictPath , existingContent ) ;
1075+
1076+ await initCommand . execute ( testDir ) ;
1077+
1078+ const updatedContent = await fs . readFile ( costrictPath , 'utf-8' ) ;
1079+ expect ( updatedContent ) . toContain ( '<!-- OPENSPEC:START -->' ) ;
1080+ expect ( updatedContent ) . toContain ( "@/openspec/AGENTS.md" ) ;
1081+ expect ( updatedContent ) . toContain ( 'openspec update' ) ;
1082+ expect ( updatedContent ) . toContain ( '<!-- OPENSPEC:END -->' ) ;
1083+ expect ( updatedContent ) . toContain ( 'Custom instructions here' ) ;
1084+ } ) ;
9981085 } ) ;
9991086
10001087 describe ( 'non-interactive mode' , ( ) => {
0 commit comments