@@ -487,4 +487,77 @@ test('extractMcpServerName: mcp__server__tool format extracts server name', () =
487487
488488test ( 'extractMcpServerName: mcp__server__multi__part__tool extracts only first server segment' , ( ) => {
489489 assert . equal ( extractMcpServerName ( 'mcp__my_server__tool__with__parts' ) , 'my_server' ) ;
490- } ) ;
490+ } ) ;
491+ // ── scanWorkspaceCustomizationFiles — category detection ─────────────────
492+
493+ import * as fs from 'node:fs' ;
494+ import * as os from 'node:os' ;
495+ import * as nodePath from 'node:path' ;
496+ import { scanWorkspaceCustomizationFiles } from '../../src/workspaceHelpers' ;
497+
498+ test ( 'scanWorkspaceCustomizationFiles: returns empty array for non-existent dir' , ( ) => {
499+ const result = scanWorkspaceCustomizationFiles ( '/does/not/exist/xyz123' ) ;
500+ assert . deepEqual ( result , [ ] ) ;
501+ } ) ;
502+
503+ test ( 'scanWorkspaceCustomizationFiles: detects copilot-instructions.md as copilot category' , ( ) => {
504+ const tmpDir = fs . mkdtempSync ( nodePath . join ( os . tmpdir ( ) , 'wh-test-' ) ) ;
505+ try {
506+ const githubDir = nodePath . join ( tmpDir , '.github' ) ;
507+ fs . mkdirSync ( githubDir ) ;
508+ fs . writeFileSync ( nodePath . join ( githubDir , 'copilot-instructions.md' ) , '# Instructions' ) ;
509+ const result = scanWorkspaceCustomizationFiles ( tmpDir ) ;
510+ const copilotFile = result . find ( f => f . type !== 'unknown' && f . path . includes ( 'copilot-instructions.md' ) ) ;
511+ assert . ok ( copilotFile , 'should find copilot-instructions.md' ) ;
512+ assert . equal ( copilotFile ?. category , 'copilot' ) ;
513+ } finally {
514+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
515+ }
516+ } ) ;
517+
518+ test ( 'scanWorkspaceCustomizationFiles: detects .cursorrules as non-copilot category' , ( ) => {
519+ const tmpDir = fs . mkdtempSync ( nodePath . join ( os . tmpdir ( ) , 'wh-test-' ) ) ;
520+ try {
521+ fs . writeFileSync ( nodePath . join ( tmpDir , '.cursorrules' ) , '# Cursor rules' ) ;
522+ const result = scanWorkspaceCustomizationFiles ( tmpDir ) ;
523+ const cursorFile = result . find ( f => f . path . includes ( '.cursorrules' ) ) ;
524+ assert . ok ( cursorFile , 'should find .cursorrules' ) ;
525+ assert . equal ( cursorFile ?. category , 'non-copilot' ) ;
526+ } finally {
527+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
528+ }
529+ } ) ;
530+
531+ test ( 'scanWorkspaceCustomizationFiles: detects .claude/settings.json as non-copilot (not CLAUDE.md)' , ( ) => {
532+ const tmpDir = fs . mkdtempSync ( nodePath . join ( os . tmpdir ( ) , 'wh-test-' ) ) ;
533+ try {
534+ // CLAUDE.md should NOT appear as non-copilot (it is Copilot-compatible)
535+ fs . writeFileSync ( nodePath . join ( tmpDir , 'CLAUDE.md' ) , '# Claude instructions' ) ;
536+ const result = scanWorkspaceCustomizationFiles ( tmpDir ) ;
537+ const claudeMd = result . find ( f => f . path . includes ( 'CLAUDE.md' ) && f . category === 'non-copilot' ) ;
538+ assert . equal ( claudeMd , undefined , 'CLAUDE.md should not be flagged as non-copilot' ) ;
539+
540+ // .claude/settings.json SHOULD appear as non-copilot
541+ const claudeDir = nodePath . join ( tmpDir , '.claude' ) ;
542+ fs . mkdirSync ( claudeDir ) ;
543+ fs . writeFileSync ( nodePath . join ( claudeDir , 'settings.json' ) , '{}' ) ;
544+ const result2 = scanWorkspaceCustomizationFiles ( tmpDir ) ;
545+ const claudeSettings = result2 . find ( f => f . path . includes ( 'settings.json' ) && f . category === 'non-copilot' ) ;
546+ assert . ok ( claudeSettings , 'should find .claude/settings.json as non-copilot' ) ;
547+ } finally {
548+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
549+ }
550+ } ) ;
551+
552+ test ( 'scanWorkspaceCustomizationFiles: detects opencode.json as non-copilot' , ( ) => {
553+ const tmpDir = fs . mkdtempSync ( nodePath . join ( os . tmpdir ( ) , 'wh-test-' ) ) ;
554+ try {
555+ fs . writeFileSync ( nodePath . join ( tmpDir , 'opencode.json' ) , '{}' ) ;
556+ const result = scanWorkspaceCustomizationFiles ( tmpDir ) ;
557+ const opencodeFile = result . find ( f => f . path . includes ( 'opencode.json' ) ) ;
558+ assert . ok ( opencodeFile , 'should find opencode.json' ) ;
559+ assert . equal ( opencodeFile ?. category , 'non-copilot' ) ;
560+ } finally {
561+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
562+ }
563+ } ) ;
0 commit comments