@@ -6,6 +6,7 @@ import * as prompts from '@voidzero-dev/vite-plus-prompts';
66import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
77
88import {
9+ detectExistingAgentTargetPaths ,
910 detectExistingAgentTargetPath ,
1011 replaceMarkedAgentInstructionsSection ,
1112 resolveAgentTargetPaths ,
@@ -259,6 +260,14 @@ describe('resolveAgentTargetPaths', () => {
259260} ) ;
260261
261262describe ( 'detectExistingAgentTargetPath' , ( ) => {
263+ it ( 'detects all existing regular agent files' , async ( ) => {
264+ const dir = await createProjectDir ( ) ;
265+ await mockFs . writeFile ( path . join ( dir , 'AGENTS.md' ) , '# Agents' ) ;
266+ await mockFs . writeFile ( path . join ( dir , 'CLAUDE.md' ) , '# Claude' ) ;
267+
268+ expect ( detectExistingAgentTargetPaths ( dir ) ) . toEqual ( [ 'AGENTS.md' , 'CLAUDE.md' ] ) ;
269+ } ) ;
270+
262271 it ( 'detects existing regular agent files' , async ( ) => {
263272 const dir = await createProjectDir ( ) ;
264273 await mockFs . writeFile ( path . join ( dir , 'CLAUDE.md' ) , '# Claude' ) ;
@@ -340,4 +349,29 @@ describe('writeAgentInstructions symlink behavior', () => {
340349 expect ( await mockFs . readText ( existingClaude ) ) . toBe ( 'existing claude instructions' ) ;
341350 expect ( mockFs . existsSync ( path . join ( dir , 'AGENTS.md' ) ) ) . toBe ( true ) ;
342351 } ) ;
352+
353+ it ( 'silently updates marker blocks without prompting in interactive mode' , async ( ) => {
354+ const dir = await createProjectDir ( ) ;
355+ const targetPath = path . join ( dir , 'AGENTS.md' ) ;
356+ const existing = [
357+ '# Local' ,
358+ '<!--VITE PLUS START-->' ,
359+ 'old block' ,
360+ '<!--VITE PLUS END-->' ,
361+ ] . join ( '\n' ) ;
362+ await mockFs . writeFile ( targetPath , existing ) ;
363+
364+ const selectSpy = vi . spyOn ( prompts , 'select' ) ;
365+ const successSpy = vi . spyOn ( prompts . log , 'success' ) ;
366+
367+ await writeAgentInstructions ( {
368+ projectRoot : dir ,
369+ targetPaths : [ 'AGENTS.md' ] ,
370+ interactive : true ,
371+ } ) ;
372+
373+ expect ( selectSpy ) . not . toHaveBeenCalled ( ) ;
374+ expect ( await mockFs . readText ( targetPath ) ) . toContain ( 'template block' ) ;
375+ expect ( successSpy ) . not . toHaveBeenCalledWith ( 'Updated agent instructions in AGENTS.md' ) ;
376+ } ) ;
343377} ) ;
0 commit comments