@@ -303,6 +303,8 @@ export function getClaudeCliToolsInfo(projectDir: string): {
303303
304304/**
305305 * Update Code Index MCP provider and switch CLAUDE.md reference
306+ * Strategy: Only modify global user-level CLAUDE.md (~/.claude/CLAUDE.md)
307+ * This is consistent with Chinese response and Windows platform settings
306308 */
307309export function updateCodeIndexMcp (
308310 projectDir : string ,
@@ -314,36 +316,30 @@ export function updateCodeIndexMcp(
314316 config . settings . codeIndexMcp = provider ;
315317 saveClaudeCliTools ( projectDir , config ) ;
316318
317- // Update CLAUDE.md reference
318- const claudeMdPath = path . join ( projectDir , '.claude' , 'CLAUDE.md' ) ;
319- if ( fs . existsSync ( claudeMdPath ) ) {
320- let content = fs . readFileSync ( claudeMdPath , 'utf-8' ) ;
319+ // Only update global CLAUDE.md (consistent with Chinese response / Windows platform)
320+ const globalClaudeMdPath = path . join ( os . homedir ( ) , '.claude' , 'CLAUDE.md' ) ;
321321
322- // Define the file patterns
323- const codexlensPattern = / @ ~ \/ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s \. m d / g;
324- const acePattern = / @ ~ \/ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s - a c e \. m d / g;
322+ if ( ! fs . existsSync ( globalClaudeMdPath ) ) {
323+ // If global CLAUDE.md doesn't exist, check project-level
324+ const projectClaudeMdPath = path . join ( projectDir , '.claude' , 'CLAUDE.md' ) ;
325+ if ( fs . existsSync ( projectClaudeMdPath ) ) {
326+ let content = fs . readFileSync ( projectClaudeMdPath , 'utf-8' ) ;
325327
326- // Also handle project-level references
327- const codexlensPatternProject = / @ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s \. m d / g;
328- const acePatternProject = / @ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s - a c e \. m d / g;
328+ // Define patterns for both formats
329+ const codexlensPattern = / @ ~ \/ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s \. m d / g;
330+ const acePattern = / @ ~ \/ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s - a c e \. m d / g;
329331
330- if ( provider === 'ace' ) {
331- // Switch to ACE
332- content = content . replace ( codexlensPattern , '@~/.claude/workflows/context-tools-ace.md' ) ;
333- content = content . replace ( codexlensPatternProject , '@.claude/workflows/context-tools-ace.md' ) ;
334- } else {
335- // Switch to CodexLens
336- content = content . replace ( acePattern , '@~/.claude/workflows/context-tools.md' ) ;
337- content = content . replace ( acePatternProject , '@.claude/workflows/context-tools.md' ) ;
338- }
339-
340- fs . writeFileSync ( claudeMdPath , content , 'utf-8' ) ;
341- console . log ( `[claude-cli-tools] Updated CLAUDE.md to use ${ provider } ` ) ;
342- }
332+ if ( provider === 'ace' ) {
333+ content = content . replace ( codexlensPattern , '@~/.claude/workflows/context-tools-ace.md' ) ;
334+ } else {
335+ content = content . replace ( acePattern , '@~/.claude/workflows/context-tools.md' ) ;
336+ }
343337
344- // Also update global CLAUDE.md if it exists
345- const globalClaudeMdPath = path . join ( os . homedir ( ) , '.claude' , 'CLAUDE.md' ) ;
346- if ( fs . existsSync ( globalClaudeMdPath ) ) {
338+ fs . writeFileSync ( projectClaudeMdPath , content , 'utf-8' ) ;
339+ console . log ( `[claude-cli-tools] Updated project CLAUDE.md to use ${ provider } (no global CLAUDE.md found)` ) ;
340+ }
341+ } else {
342+ // Update global CLAUDE.md (primary target)
347343 let content = fs . readFileSync ( globalClaudeMdPath , 'utf-8' ) ;
348344
349345 const codexlensPattern = / @ ~ \/ \. c l a u d e \/ w o r k f l o w s \/ c o n t e x t - t o o l s \. m d / g;
0 commit comments