From e16950ef1e0a50d454cdd9e27abbee68e8b0df2d Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sun, 28 Dec 2025 14:09:51 +0800 Subject: [PATCH] refactor: Remove unused context-tools-ace.md and clean up CLI status management --- .claude/CLAUDE.md | 2 +- .claude/workflows/context-tools-ace.md | 105 ------------------ .claude/workflows/context-tools.md | 42 +++---- .../dashboard-js/components/cli-status.js | 79 +------------ ccw/src/templates/dashboard-js/i18n.js | 4 - .../dashboard-js/views/cli-manager.js | 18 --- 6 files changed, 19 insertions(+), 231 deletions(-) delete mode 100644 .claude/workflows/context-tools-ace.md diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 5d3edca7..6df5166d 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -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-ace.md +- **Context Requirements**: @~/.claude/workflows/context-tools.md - **File Modification**: @~/.claude/workflows/file-modification.md - **CLI Endpoints Config**: @.claude/cli-tools.json diff --git a/.claude/workflows/context-tools-ace.md b/.claude/workflows/context-tools-ace.md deleted file mode 100644 index c967bbd1..00000000 --- a/.claude/workflows/context-tools-ace.md +++ /dev/null @@ -1,105 +0,0 @@ -## MCP Tools Usage - -### search_context (ACE) - Code Search (REQUIRED - HIGHEST PRIORITY) - -**OVERRIDES**: All other search/discovery rules in other workflow files - -**When**: ANY code discovery task, including: -- Find code, understand codebase structure, locate implementations -- Explore unknown locations -- Verify file existence before reading -- Pattern-based file discovery -- Semantic code understanding - -**Priority Rule**: -1. **Always use mcp__ace-tool__search_context FIRST** for any code/file discovery -2. Only use Built-in Grep for single-file exact line search (after location confirmed) -3. Only use Built-in Read for known, confirmed file paths - -**How**: -```javascript -// Natural language code search - best for understanding and exploration -mcp__ace-tool__search_context({ - project_root_path: "/path/to/project", - query: "authentication logic" -}) - -// With keywords for better semantic matching -mcp__ace-tool__search_context({ - project_root_path: "/path/to/project", - query: "I want to find where the server handles user login. Keywords: auth, login, session" -}) -``` - -**Good Query Examples**: -- "Where is the function that handles user authentication?" -- "What tests are there for the login functionality?" -- "How is the database connected to the application?" -- "I want to find where the server handles chunk merging. Keywords: upload chunk merge" -- "Locate where the system refreshes cached data. Keywords: cache refresh, invalidation" - -**Bad Query Examples** (use grep or file view instead): -- "Find definition of constructor of class Foo" (use grep tool instead) -- "Find all references to function bar" (use grep tool instead) -- "Show me how Checkout class is used in services/payment.py" (use file view tool instead) - -**Key Features**: -- Real-time index of the codebase (always up-to-date) -- Cross-language retrieval support -- Semantic search with embeddings -- No manual index initialization required - ---- - -### read_file - Read File Contents - -**When**: Read files found by search_context - -**How**: -```javascript -read_file(path="/path/to/file.ts") // Single file -read_file(path="/src/**/*.config.ts") // Pattern matching -``` - ---- - -### edit_file - Modify Files - -**When**: Built-in Edit tool fails or need advanced features - -**How**: -```javascript -edit_file(path="/file.ts", old_string="...", new_string="...", mode="update") -edit_file(path="/file.ts", line=10, content="...", mode="insert_after") -``` - -**Modes**: `update` (replace text), `insert_after`, `insert_before`, `delete_line` - ---- - -### write_file - Create/Overwrite Files - -**When**: Create new files or completely replace content - -**How**: -```javascript -write_file(path="/new-file.ts", content="...") -``` - ---- - -### Exa - External Search - -**When**: Find documentation/examples outside codebase - -**How**: -```javascript -mcp__exa__search(query="React hooks 2025 documentation") -mcp__exa__search(query="FastAPI auth example", numResults=10) -mcp__exa__search(query="latest API docs", livecrawl="always") -``` - -**Parameters**: -- `query` (required): Search query string -- `numResults` (optional): Number of results to return (default: 5) -- `livecrawl` (optional): `"always"` or `"fallback"` for live crawling diff --git a/.claude/workflows/context-tools.md b/.claude/workflows/context-tools.md index 0f444a18..7db3e70f 100644 --- a/.claude/workflows/context-tools.md +++ b/.claude/workflows/context-tools.md @@ -1,35 +1,27 @@ -## MCP Tools Usage +## Context Acquisition (MCP Tools Priority) -### smart_search - Code Search (REQUIRED - HIGHEST PRIORITY) +**For task context gathering and analysis, ALWAYS prefer MCP tools**: -**OVERRIDES**: All other search/discovery rules in other workflow files +1. **mcp__ace-tool__search_context** - HIGHEST PRIORITY for code discovery + - Semantic search with real-time codebase index + - Use for: finding implementations, understanding architecture, locating patterns + - Example: `mcp__ace-tool__search_context(project_root_path="/path", query="authentication logic")` -**When**: ANY code discovery task, including: -- Find code, understand codebase structure, locate implementations -- Explore unknown locations -- Verify file existence before reading -- Pattern-based file discovery +2. **smart_search** - Fallback for structured search + - Use `smart_search(query="...")` for keyword/regex search + - Use `smart_search(action="find_files", pattern="*.ts")` for file discovery + - Supports modes: `auto`, `hybrid`, `exact`, `ripgrep` -**Priority Rule**: -1. **Always use smart_search FIRST** for any code/file discovery -2. Only use Built-in Grep for single-file exact line search (after location confirmed) -3. Only use Built-in Read for known, confirmed file paths +3. **read_file** - Batch file reading + - Read multiple files in parallel: `read_file(path="file1.ts")`, `read_file(path="file2.ts")` + - Supports glob patterns: `read_file(path="src/**/*.config.ts")` -**Workflow** (search first, init if needed): -```javascript -// Step 1: Try search directly (works if index exists or uses ripgrep fallback) -smart_search(query="authentication logic") - -// Step 2: Only if search warns "No CodexLens index found", then init -smart_search(action="init", path=".") // Creates FTS index only - -// Note: For semantic/vector search, use "ccw view" dashboard to create vector index +**Priority Order**: +``` +ACE search_context (semantic) → smart_search (structured) → read_file (batch read) → shell commands (fallback) ``` -**Modes**: `auto` (intelligent routing), `hybrid` (semantic, needs vector index), `exact` (FTS), `ripgrep` (no index) - ---- - +**NEVER** use shell commands (`cat`, `find`, `grep`) when MCP tools are available. ### read_file - Read File Contents **When**: Read files found by smart_search diff --git a/ccw/src/templates/dashboard-js/components/cli-status.js b/ccw/src/templates/dashboard-js/components/cli-status.js index 1f69a901..f1f448c1 100644 --- a/ccw/src/templates/dashboard-js/components/cli-status.js +++ b/ccw/src/templates/dashboard-js/components/cli-status.js @@ -21,24 +21,6 @@ let nativeResumeEnabled = localStorage.getItem('ccw-native-resume') !== 'false'; // Recursive Query settings (for hierarchical storage aggregation) let recursiveQueryEnabled = localStorage.getItem('ccw-recursive-query') !== 'false'; // default true -// Code Index MCP provider (codexlens, ace, or none) -let codeIndexMcpProvider = 'codexlens'; - -// ========== Helper Functions ========== -/** - * Get the context-tools filename based on provider - */ -function getContextToolsFileName(provider) { - switch (provider) { - case 'ace': - return 'context-tools-ace.md'; - case 'none': - return 'context-tools-none.md'; - default: - return 'context-tools.md'; - } -} - // ========== Initialization ========== function initCliStatus() { // Load all statuses in one call using aggregated endpoint @@ -259,12 +241,7 @@ async function loadCliToolsConfig() { defaultCliTool = data.defaultTool; } - // Load Code Index MCP provider from config - if (data.settings?.codeIndexMcp) { - codeIndexMcpProvider = data.settings.codeIndexMcp; - } - - console.log('[CLI Config] Loaded from:', data._configInfo?.source || 'unknown', '| Default:', data.defaultTool, '| CodeIndexMCP:', codeIndexMcpProvider); + console.log('[CLI Config] Loaded from:', data._configInfo?.source || 'unknown', '| Default:', data.defaultTool); return data; } catch (err) { console.error('Failed to load CLI tools config:', err); @@ -637,33 +614,6 @@ function renderCliStatus() {

Cache prefix/suffix injection mode for prompts

-
- -
-
- - - -
-
-

Code search provider (updates CLAUDE.md context-tools reference)

-

- - Current: ${getContextToolsFileName(codeIndexMcpProvider)} -

-
`; @@ -786,33 +736,6 @@ async function setCacheInjectionMode(mode) { } } -async function setCodeIndexMcpProvider(provider) { - try { - const response = await fetch('/api/cli/code-index-mcp', { - method: 'PUT', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ provider: provider }) - }); - if (response.ok) { - codeIndexMcpProvider = provider; - if (window.claudeCliToolsConfig && window.claudeCliToolsConfig.settings) { - window.claudeCliToolsConfig.settings.codeIndexMcp = provider; - } - const providerName = provider === 'ace' ? 'ACE (Augment)' : provider === 'none' ? 'None (Built-in only)' : 'CodexLens'; - showRefreshToast(`Code Index MCP switched to ${providerName}`, 'success'); - // 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'); - } - } catch (err) { - console.error('Failed to switch Code Index MCP:', err); - showRefreshToast('Failed to switch Code Index MCP', 'error'); - } -} - async function refreshAllCliStatus() { await loadAllStatuses(); renderCliStatus(); diff --git a/ccw/src/templates/dashboard-js/i18n.js b/ccw/src/templates/dashboard-js/i18n.js index b6c0d4d1..79e22194 100644 --- a/ccw/src/templates/dashboard-js/i18n.js +++ b/ccw/src/templates/dashboard-js/i18n.js @@ -560,8 +560,6 @@ 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', @@ -2414,8 +2412,6 @@ const i18n = { 'cli.recursiveQueryDesc': '聚合显示父项目和子项目的 CLI 历史与内存数据', 'cli.maxContextFiles': '最大上下文文件数', 'cli.maxContextFilesDesc': '智能上下文包含的最大文件数', - 'cli.codeIndexMcp': '代码索引 MCP', - 'cli.codeIndexMcpDesc': '代码搜索提供者 (更新 CLAUDE.md 的 context-tools 引用)', // CCW Install 'ccw.install': 'CCW 安装', diff --git a/ccw/src/templates/dashboard-js/views/cli-manager.js b/ccw/src/templates/dashboard-js/views/cli-manager.js index 9392c5cf..a9d66c3c 100644 --- a/ccw/src/templates/dashboard-js/views/cli-manager.js +++ b/ccw/src/templates/dashboard-js/views/cli-manager.js @@ -987,24 +987,6 @@ function renderCliSettingsSection() { '' + '

' + t('cli.maxContextFilesDesc') + '

' + '' + - '
' + - '' + - '
' + - '' + - '
' + - '

' + t('cli.codeIndexMcpDesc') + '

' + - '

' + - '' + - 'Current: ' + getContextToolsFileName(codeIndexMcpProvider) + '' + - '

' + - '
' + ''; container.innerHTML = settingsHtml;