@@ -34,14 +34,15 @@ describe('subagent input plugin', () => {
3434
3535 const srcFile = path . join ( srcDir , 'demo.src.mdx' )
3636 const distFile = path . join ( distDir , 'demo.mdx' )
37- fs . writeFileSync ( srcFile , '---\nname: demo\ ndescription: src\n---\nSubAgent source' , 'utf8' )
38- fs . writeFileSync ( distFile , '---\nname: demo\ ndescription: dist\n---\nexport const x = 1\n\nSubAgent dist' , 'utf8' )
37+ fs . writeFileSync ( srcFile , '---\ndescription: src\n---\nSubAgent source' , 'utf8' )
38+ fs . writeFileSync ( distFile , '---\ndescription: dist\n---\nexport const x = 1\n\nSubAgent dist' , 'utf8' )
3939
4040 const plugin = new SubAgentInputCapability ( )
4141 const result = await plugin . collect ( createContext ( tempWorkspace ) )
4242
4343 expect ( result . subAgents ?. length ?? 0 ) . toBe ( 1 )
4444 expect ( result . subAgents ?. [ 0 ] ?. agentName ) . toBe ( 'demo' )
45+ expect ( result . subAgents ?. [ 0 ] ?. canonicalName ) . toBe ( 'demo' )
4546 expect ( result . subAgents ?. [ 0 ] ?. content ) . toContain ( 'SubAgent dist' )
4647 expect ( result . subAgents ?. [ 0 ] ?. content ) . not . toContain ( 'SubAgent source' )
4748 expect ( result . subAgents ?. [ 0 ] ?. content ) . not . toContain ( 'export const x = 1' )
@@ -64,8 +65,8 @@ describe('subagent input plugin', () => {
6465
6566 const srcFile = path . join ( srcDir , 'boot.src.mdx' )
6667 const distFile = path . join ( distDir , 'boot.mdx' )
67- fs . writeFileSync ( srcFile , '---\nname: boot\ ndescription: qa boot src\n---\nSubAgent source' , 'utf8' )
68- fs . writeFileSync ( distFile , '---\nname: boot\ ndescription: qa boot dist\n---\nSubAgent dist' , 'utf8' )
68+ fs . writeFileSync ( srcFile , '---\ndescription: qa boot src\n---\nSubAgent source' , 'utf8' )
69+ fs . writeFileSync ( distFile , '---\ndescription: qa boot dist\n---\nSubAgent dist' , 'utf8' )
6970
7071 const plugin = new SubAgentInputCapability ( )
7172 const result = await plugin . collect ( createContext ( tempWorkspace ) )
@@ -74,6 +75,7 @@ describe('subagent input plugin', () => {
7475 expect ( result . subAgents ?. length ?? 0 ) . toBe ( 1 )
7576 expect ( subAgent ?. agentPrefix ) . toBe ( 'qa' )
7677 expect ( subAgent ?. agentName ) . toBe ( 'boot' )
78+ expect ( subAgent ?. canonicalName ) . toBe ( 'qa-boot' )
7779 expect ( subAgent ?. content ) . toContain ( 'SubAgent dist' )
7880 expect ( subAgent ?. content ) . not . toContain ( 'SubAgent source' )
7981 }
@@ -94,8 +96,8 @@ describe('subagent input plugin', () => {
9496
9597 const srcFile = path . join ( srcDir , 'demo.src.mdx' )
9698 const distFile = path . join ( distDir , 'demo.mdx' )
97- fs . writeFileSync ( srcFile , '---\nname: demo\ ndescription: src\n---\nSubAgent source' , 'utf8' )
98- fs . writeFileSync ( distFile , '---\nname: demo\ ndescription: dist\n---\nexport const x = 1\n\nSubAgent dist' , 'utf8' )
99+ fs . writeFileSync ( srcFile , '---\ndescription: src\n---\nSubAgent source' , 'utf8' )
100+ fs . writeFileSync ( distFile , '---\ndescription: dist\n---\nexport const x = 1\n\nSubAgent dist' , 'utf8' )
99101
100102 const plugin = new SubAgentInputCapability ( )
101103 const result = await plugin . collect ( createContext ( tempWorkspace ) )
@@ -118,7 +120,7 @@ describe('subagent input plugin', () => {
118120 fs . mkdirSync ( distDir , { recursive : true } )
119121 fs . writeFileSync (
120122 path . join ( distDir , 'demo.mdx' ) ,
121- '---\nname: demo\ ndescription: dist only\n---\nDist only subagent' ,
123+ '---\ndescription: dist only\n---\nDist only subagent' ,
122124 'utf8'
123125 )
124126
@@ -127,6 +129,7 @@ describe('subagent input plugin', () => {
127129
128130 expect ( result . subAgents ?. length ?? 0 ) . toBe ( 1 )
129131 expect ( result . subAgents ?. [ 0 ] ?. agentName ) . toBe ( 'demo' )
132+ expect ( result . subAgents ?. [ 0 ] ?. canonicalName ) . toBe ( 'demo' )
130133 expect ( result . subAgents ?. [ 0 ] ?. content ) . toContain ( 'Dist only subagent' )
131134 expect ( result . subAgents ?. [ 0 ] ?. yamlFrontMatter ?. description ) . toBe ( 'dist only' )
132135 }
@@ -143,7 +146,7 @@ describe('subagent input plugin', () => {
143146 fs . mkdirSync ( srcDir , { recursive : true } )
144147 fs . writeFileSync (
145148 path . join ( srcDir , 'demo.src.mdx' ) ,
146- '---\nname: demo\ ndescription: source only\n---\nSource only subagent' ,
149+ '---\ndescription: source only\n---\nSource only subagent' ,
147150 'utf8'
148151 )
149152
@@ -163,7 +166,7 @@ describe('subagent input plugin', () => {
163166 fs . mkdirSync ( distDir , { recursive : true } )
164167 fs . writeFileSync (
165168 path . join ( distDir , 'demo.mdx' ) ,
166- '---\nname: demo\ ndescription: dist only\nscope: workspace\n---\nDist only subagent' ,
169+ '---\ndescription: dist only\nscope: workspace\n---\nDist only subagent' ,
167170 'utf8'
168171 )
169172
@@ -174,4 +177,48 @@ describe('subagent input plugin', () => {
174177 fs . rmSync ( tempWorkspace , { recursive : true , force : true } )
175178 }
176179 } )
180+
181+ it ( 'warns and ignores authored subagent names' , async ( ) => {
182+ const tempWorkspace = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'tnmsc-subagent-name-warning-test-' ) )
183+ const warnings : string [ ] = [ ]
184+ const aindexDir = path . join ( tempWorkspace , 'aindex' )
185+ const srcDir = path . join ( aindexDir , 'subagents' , 'qa' )
186+ const distDir = path . join ( aindexDir , 'dist' , 'subagents' , 'qa' )
187+
188+ try {
189+ fs . mkdirSync ( srcDir , { recursive : true } )
190+ fs . mkdirSync ( distDir , { recursive : true } )
191+
192+ fs . writeFileSync ( path . join ( srcDir , 'boot.src.mdx' ) , '---\nname: review-helper\ndescription: src\n---\nSubAgent source' , 'utf8' )
193+ fs . writeFileSync ( path . join ( distDir , 'boot.mdx' ) , '---\nname: review-helper\ndescription: dist\n---\nSubAgent dist' , 'utf8' )
194+
195+ const logger = {
196+ trace : ( ) => { } ,
197+ debug : ( ) => { } ,
198+ info : ( ) => { } ,
199+ warn : diagnostic => warnings . push ( diagnostic . code ) ,
200+ error : ( ) => { } ,
201+ fatal : ( ) => { }
202+ }
203+
204+ const options = mergeConfig ( { workspaceDir : tempWorkspace } )
205+ const plugin = new SubAgentInputCapability ( )
206+ const result = await plugin . collect ( {
207+ logger,
208+ fs,
209+ path,
210+ glob,
211+ userConfigOptions : options ,
212+ dependencyContext : { }
213+ } as InputCapabilityContext )
214+
215+ const [ subAgent ] = result . subAgents ?? [ ]
216+ expect ( subAgent ?. canonicalName ) . toBe ( 'qa-boot' )
217+ expect ( 'name' in ( subAgent ?. yamlFrontMatter ?? { } ) ) . toBe ( false )
218+ expect ( warnings ) . toContain ( 'SUBAGENT_NAME_IGNORED' )
219+ }
220+ finally {
221+ fs . rmSync ( tempWorkspace , { recursive : true , force : true } )
222+ }
223+ } )
177224} )
0 commit comments