mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: 更新 Code Index MCP 提供者支持,修改 CLAUDE.md 和相关样式
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
|
||||
- **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
|
||||
- **Context Requirements**: @~/.claude/workflows/context-tools.md
|
||||
- **Context Requirements**: @~/.claude/workflows/context-tools-ace.md
|
||||
- **File Modification**: @~/.claude/workflows/file-modification.md
|
||||
- **CLI Endpoints Config**: @.claude/cli-tools.json
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"$schema": "./cli-tools.schema.json",
|
||||
"version": "1.0.0",
|
||||
"tools": {
|
||||
"gemini": {
|
||||
@@ -41,6 +40,8 @@
|
||||
"injectionMode": "auto",
|
||||
"defaultPrefix": "",
|
||||
"defaultSuffix": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"codeIndexMcp": "ace"
|
||||
},
|
||||
"$schema": "./cli-tools.schema.json"
|
||||
}
|
||||
@@ -158,3 +158,37 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Code Index MCP Toggle Buttons */
|
||||
.code-mcp-btn {
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
border-radius: 0.375rem;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
background: transparent;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
|
||||
.code-mcp-btn:hover {
|
||||
color: hsl(var(--foreground));
|
||||
background: hsl(var(--muted) / 0.5);
|
||||
}
|
||||
|
||||
.code-mcp-btn.active,
|
||||
.code-mcp-btn[class*="bg-primary"] {
|
||||
background: hsl(var(--primary));
|
||||
color: hsl(var(--primary-foreground));
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.code-mcp-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
background: hsl(var(--muted));
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.125rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -776,7 +776,9 @@ async function setCodeIndexMcpProvider(provider) {
|
||||
window.claudeCliToolsConfig.settings.codeIndexMcp = provider;
|
||||
}
|
||||
showRefreshToast(`Code Index MCP switched to ${provider === 'ace' ? 'ACE (Augment)' : 'CodexLens'}`, 'success');
|
||||
renderCliStatus();
|
||||
// Re-render both CLI status and settings section
|
||||
if (typeof renderCliStatus === 'function') renderCliStatus();
|
||||
if (typeof renderCliSettingsSection === 'function') renderCliSettingsSection();
|
||||
} else {
|
||||
const data = await response.json();
|
||||
showRefreshToast(`Failed to switch Code Index MCP: ${data.error}`, 'error');
|
||||
|
||||
@@ -546,7 +546,9 @@ const i18n = {
|
||||
'cli.recursiveQueryDesc': 'Aggregate CLI history and memory data from parent and child projects',
|
||||
'cli.maxContextFiles': 'Max Context Files',
|
||||
'cli.maxContextFilesDesc': 'Maximum files to include in smart context',
|
||||
|
||||
'cli.codeIndexMcp': 'Code Index MCP',
|
||||
'cli.codeIndexMcpDesc': 'Code search provider (updates CLAUDE.md context-tools reference)',
|
||||
|
||||
// CCW Install
|
||||
'ccw.install': 'CCW Install',
|
||||
'ccw.installations': 'installation',
|
||||
@@ -2254,7 +2256,9 @@ const i18n = {
|
||||
'cli.recursiveQueryDesc': '聚合显示父项目和子项目的 CLI 历史与内存数据',
|
||||
'cli.maxContextFiles': '最大上下文文件数',
|
||||
'cli.maxContextFilesDesc': '智能上下文包含的最大文件数',
|
||||
|
||||
'cli.codeIndexMcp': '代码索引 MCP',
|
||||
'cli.codeIndexMcpDesc': '代码搜索提供者 (更新 CLAUDE.md 的 context-tools 引用)',
|
||||
|
||||
// CCW Install
|
||||
'ccw.install': 'CCW 安装',
|
||||
'ccw.installations': '个安装',
|
||||
|
||||
@@ -987,6 +987,23 @@ function renderCliSettingsSection() {
|
||||
'</div>' +
|
||||
'<p class="cli-setting-desc">' + t('cli.maxContextFilesDesc') + '</p>' +
|
||||
'</div>' +
|
||||
'<div class="cli-setting-item">' +
|
||||
'<label class="cli-setting-label">' +
|
||||
'<i data-lucide="search" class="w-3 h-3"></i>' +
|
||||
t('cli.codeIndexMcp') +
|
||||
'</label>' +
|
||||
'<div class="cli-setting-control">' +
|
||||
'<div class="flex items-center bg-muted rounded-lg p-0.5">' +
|
||||
'<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\')">' +
|
||||
'CodexLens' +
|
||||
'</button>' +
|
||||
'<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\')">' +
|
||||
'ACE' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<p class="cli-setting-desc">' + t('cli.codeIndexMcpDesc') + '</p>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
container.innerHTML = settingsHtml;
|
||||
|
||||
@@ -303,6 +303,8 @@ export function getClaudeCliToolsInfo(projectDir: string): {
|
||||
|
||||
/**
|
||||
* Update Code Index MCP provider and switch CLAUDE.md reference
|
||||
* Strategy: Only modify global user-level CLAUDE.md (~/.claude/CLAUDE.md)
|
||||
* This is consistent with Chinese response and Windows platform settings
|
||||
*/
|
||||
export function updateCodeIndexMcp(
|
||||
projectDir: string,
|
||||
@@ -314,36 +316,30 @@ export function updateCodeIndexMcp(
|
||||
config.settings.codeIndexMcp = provider;
|
||||
saveClaudeCliTools(projectDir, config);
|
||||
|
||||
// Update CLAUDE.md reference
|
||||
const claudeMdPath = path.join(projectDir, '.claude', 'CLAUDE.md');
|
||||
if (fs.existsSync(claudeMdPath)) {
|
||||
let content = fs.readFileSync(claudeMdPath, 'utf-8');
|
||||
|
||||
// Define the file patterns
|
||||
const codexlensPattern = /@~\/\.claude\/workflows\/context-tools\.md/g;
|
||||
const acePattern = /@~\/\.claude\/workflows\/context-tools-ace\.md/g;
|
||||
|
||||
// Also handle project-level references
|
||||
const codexlensPatternProject = /@\.claude\/workflows\/context-tools\.md/g;
|
||||
const acePatternProject = /@\.claude\/workflows\/context-tools-ace\.md/g;
|
||||
|
||||
if (provider === 'ace') {
|
||||
// Switch to ACE
|
||||
content = content.replace(codexlensPattern, '@~/.claude/workflows/context-tools-ace.md');
|
||||
content = content.replace(codexlensPatternProject, '@.claude/workflows/context-tools-ace.md');
|
||||
} else {
|
||||
// Switch to CodexLens
|
||||
content = content.replace(acePattern, '@~/.claude/workflows/context-tools.md');
|
||||
content = content.replace(acePatternProject, '@.claude/workflows/context-tools.md');
|
||||
}
|
||||
|
||||
fs.writeFileSync(claudeMdPath, content, 'utf-8');
|
||||
console.log(`[claude-cli-tools] Updated CLAUDE.md to use ${provider}`);
|
||||
}
|
||||
|
||||
// Also update global CLAUDE.md if it exists
|
||||
// Only update global CLAUDE.md (consistent with Chinese response / Windows platform)
|
||||
const globalClaudeMdPath = path.join(os.homedir(), '.claude', 'CLAUDE.md');
|
||||
if (fs.existsSync(globalClaudeMdPath)) {
|
||||
|
||||
if (!fs.existsSync(globalClaudeMdPath)) {
|
||||
// If global CLAUDE.md doesn't exist, check project-level
|
||||
const projectClaudeMdPath = path.join(projectDir, '.claude', 'CLAUDE.md');
|
||||
if (fs.existsSync(projectClaudeMdPath)) {
|
||||
let content = fs.readFileSync(projectClaudeMdPath, 'utf-8');
|
||||
|
||||
// Define patterns for both formats
|
||||
const codexlensPattern = /@~\/\.claude\/workflows\/context-tools\.md/g;
|
||||
const acePattern = /@~\/\.claude\/workflows\/context-tools-ace\.md/g;
|
||||
|
||||
if (provider === 'ace') {
|
||||
content = content.replace(codexlensPattern, '@~/.claude/workflows/context-tools-ace.md');
|
||||
} else {
|
||||
content = content.replace(acePattern, '@~/.claude/workflows/context-tools.md');
|
||||
}
|
||||
|
||||
fs.writeFileSync(projectClaudeMdPath, content, 'utf-8');
|
||||
console.log(`[claude-cli-tools] Updated project CLAUDE.md to use ${provider} (no global CLAUDE.md found)`);
|
||||
}
|
||||
} else {
|
||||
// Update global CLAUDE.md (primary target)
|
||||
let content = fs.readFileSync(globalClaudeMdPath, 'utf-8');
|
||||
|
||||
const codexlensPattern = /@~\/\.claude\/workflows\/context-tools\.md/g;
|
||||
|
||||
Reference in New Issue
Block a user