Skip to content

Commit 6894c7e

Browse files
author
catlog22
committed
feat: 更新 Code Index MCP 提供者支持,修改 CLAUDE.md 和相关样式
1 parent 2031004 commit 6894c7e

File tree

7 files changed

+88
-34
lines changed

7 files changed

+88
-34
lines changed

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
44
- **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
5-
- **Context Requirements**: @~/.claude/workflows/context-tools.md
5+
- **Context Requirements**: @~/.claude/workflows/context-tools-ace.md
66
- **File Modification**: @~/.claude/workflows/file-modification.md
77
- **CLI Endpoints Config**: @.claude/cli-tools.json
88

.claude/cli-tools.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$schema": "./cli-tools.schema.json",
32
"version": "1.0.0",
43
"tools": {
54
"gemini": {
@@ -41,6 +40,8 @@
4140
"injectionMode": "auto",
4241
"defaultPrefix": "",
4342
"defaultSuffix": ""
44-
}
45-
}
46-
}
43+
},
44+
"codeIndexMcp": "ace"
45+
},
46+
"$schema": "./cli-tools.schema.json"
47+
}

ccw/src/templates/dashboard-css/18-cli-settings.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,37 @@
158158
pointer-events: none;
159159
}
160160

161+
/* Code Index MCP Toggle Buttons */
162+
.code-mcp-btn {
163+
padding: 0.375rem 0.75rem;
164+
font-size: 0.75rem;
165+
font-weight: 500;
166+
border-radius: 0.375rem;
167+
border: none;
168+
cursor: pointer;
169+
transition: all 0.15s ease;
170+
background: transparent;
171+
color: hsl(var(--muted-foreground));
172+
}
173+
174+
.code-mcp-btn:hover {
175+
color: hsl(var(--foreground));
176+
background: hsl(var(--muted) / 0.5);
177+
}
178+
179+
.code-mcp-btn.active,
180+
.code-mcp-btn[class*="bg-primary"] {
181+
background: hsl(var(--primary));
182+
color: hsl(var(--primary-foreground));
183+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
184+
}
185+
186+
.code-mcp-toggle {
187+
display: flex;
188+
align-items: center;
189+
gap: 0.25rem;
190+
background: hsl(var(--muted));
191+
border-radius: 0.5rem;
192+
padding: 0.125rem;
193+
}
194+

ccw/src/templates/dashboard-js/components/cli-status.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ async function setCodeIndexMcpProvider(provider) {
776776
window.claudeCliToolsConfig.settings.codeIndexMcp = provider;
777777
}
778778
showRefreshToast(`Code Index MCP switched to ${provider === 'ace' ? 'ACE (Augment)' : 'CodexLens'}`, 'success');
779-
renderCliStatus();
779+
// Re-render both CLI status and settings section
780+
if (typeof renderCliStatus === 'function') renderCliStatus();
781+
if (typeof renderCliSettingsSection === 'function') renderCliSettingsSection();
780782
} else {
781783
const data = await response.json();
782784
showRefreshToast(`Failed to switch Code Index MCP: ${data.error}`, 'error');

ccw/src/templates/dashboard-js/i18n.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,9 @@ const i18n = {
546546
'cli.recursiveQueryDesc': 'Aggregate CLI history and memory data from parent and child projects',
547547
'cli.maxContextFiles': 'Max Context Files',
548548
'cli.maxContextFilesDesc': 'Maximum files to include in smart context',
549-
549+
'cli.codeIndexMcp': 'Code Index MCP',
550+
'cli.codeIndexMcpDesc': 'Code search provider (updates CLAUDE.md context-tools reference)',
551+
550552
// CCW Install
551553
'ccw.install': 'CCW Install',
552554
'ccw.installations': 'installation',
@@ -2254,7 +2256,9 @@ const i18n = {
22542256
'cli.recursiveQueryDesc': '聚合显示父项目和子项目的 CLI 历史与内存数据',
22552257
'cli.maxContextFiles': '最大上下文文件数',
22562258
'cli.maxContextFilesDesc': '智能上下文包含的最大文件数',
2257-
2259+
'cli.codeIndexMcp': '代码索引 MCP',
2260+
'cli.codeIndexMcpDesc': '代码搜索提供者 (更新 CLAUDE.md 的 context-tools 引用)',
2261+
22582262
// CCW Install
22592263
'ccw.install': 'CCW 安装',
22602264
'ccw.installations': '个安装',

ccw/src/templates/dashboard-js/views/cli-manager.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,23 @@ function renderCliSettingsSection() {
987987
'</div>' +
988988
'<p class="cli-setting-desc">' + t('cli.maxContextFilesDesc') + '</p>' +
989989
'</div>' +
990+
'<div class="cli-setting-item">' +
991+
'<label class="cli-setting-label">' +
992+
'<i data-lucide="search" class="w-3 h-3"></i>' +
993+
t('cli.codeIndexMcp') +
994+
'</label>' +
995+
'<div class="cli-setting-control">' +
996+
'<div class="flex items-center bg-muted rounded-lg p-0.5">' +
997+
'<button class="code-mcp-btn px-3 py-1.5 text-xs font-medium rounded-md transition-all ' + (codeIndexMcpProvider === 'codexlens' ? 'bg-primary text-primary-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground') + '" onclick="setCodeIndexMcpProvider(\'codexlens\')">' +
998+
'CodexLens' +
999+
'</button>' +
1000+
'<button class="code-mcp-btn px-3 py-1.5 text-xs font-medium rounded-md transition-all ' + (codeIndexMcpProvider === 'ace' ? 'bg-primary text-primary-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground') + '" onclick="setCodeIndexMcpProvider(\'ace\')">' +
1001+
'ACE' +
1002+
'</button>' +
1003+
'</div>' +
1004+
'</div>' +
1005+
'<p class="cli-setting-desc">' + t('cli.codeIndexMcpDesc') + '</p>' +
1006+
'</div>' +
9901007
'</div>';
9911008

9921009
container.innerHTML = settingsHtml;

ccw/src/tools/claude-cli-tools.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
307309
export 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 = /@~\/\.claude\/workflows\/context-tools\.md/g;
324-
const acePattern = /@~\/\.claude\/workflows\/context-tools-ace\.md/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 = /@\.claude\/workflows\/context-tools\.md/g;
328-
const acePatternProject = /@\.claude\/workflows\/context-tools-ace\.md/g;
328+
// Define patterns for both formats
329+
const codexlensPattern = /@~\/\.claude\/workflows\/context-tools\.md/g;
330+
const acePattern = /@~\/\.claude\/workflows\/context-tools-ace\.md/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 = /@~\/\.claude\/workflows\/context-tools\.md/g;

0 commit comments

Comments
 (0)