mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
refactor: remove MCP code-index dependency, replace with ripgrep/find
Replace all mcp__code-index__ calls with native ripgrep and find commands across workflow and command files for better performance and portability. Changes: - Remove 41 mcp__code-index__ function calls from 12 files - Replace with ripgrep (rg) for content search - Replace with find for file discovery - Remove index refresh dependencies (no longer needed) Modified files: - workflow/tools: context-gather, test-context-gather, task-generate-agent, task-generate, test-task-generate (core workflow tools) - workflow: review (security scanning) - memory: load, update-related, docs (memory management) - cli/mode: plan, bug-index, code-analysis (CLI modes) Documentation updates: - Simplify mcp-tool-strategy.md to only Exa usage (5 lines) - Streamline context-search-strategy.md to 69 lines - Standardize codebase-retrieval syntax per intelligent-tools-strategy.md Benefits: - Faster search with ripgrep (no index overhead) - Better cross-platform compatibility - Simpler configuration (fewer MCP dependencies) - -232 lines of code removed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -92,10 +92,10 @@ After bash validation, the model takes control to:
|
||||
2. **Perform Specialized Review**: Based on `review_type`
|
||||
|
||||
**Security Review** (`--type=security`):
|
||||
- Use MCP code search for security patterns:
|
||||
- Use ripgrep for security patterns:
|
||||
```bash
|
||||
mcp__code-index__search_code_advanced(pattern="password|token|secret|auth", file_pattern="*.{ts,js,py}")
|
||||
mcp__code-index__search_code_advanced(pattern="eval|exec|innerHTML|dangerouslySetInnerHTML", file_pattern="*.{ts,js,tsx}")
|
||||
rg "password|token|secret|auth" -g "*.{ts,js,py}"
|
||||
rg "eval|exec|innerHTML|dangerouslySetInnerHTML" -g "*.{ts,js,tsx}"
|
||||
```
|
||||
- Use Gemini for security analysis:
|
||||
```bash
|
||||
|
||||
@@ -17,7 +17,7 @@ Agent-driven intelligent context collector that gathers relevant information fro
|
||||
- **Agent-Driven**: Delegate execution to universal-executor agent for autonomous operation
|
||||
- **Two-Phase Flow**: Discovery (context loading) → Execution (context gathering and packaging)
|
||||
- **Memory-First**: Reuse loaded documents from conversation memory
|
||||
- **MCP-Enhanced**: Use MCP tools for advanced code analysis and file discovery
|
||||
- **Ripgrep-Enhanced**: Use ripgrep and native tools for code analysis and file discovery
|
||||
- **Intelligent Collection**: Auto-identify relevant resources based on keyword analysis
|
||||
- **Comprehensive Coverage**: Collect code, documentation, configurations, and dependencies
|
||||
- **Standardized Output**: Generate unified format context-package.json
|
||||
@@ -36,9 +36,10 @@ Agent-driven intelligent context collector that gathers relevant information fro
|
||||
// If in memory: use cached content
|
||||
// Else: Load from .workflow/{session-id}/workflow-session.json
|
||||
},
|
||||
"mcp_capabilities": {
|
||||
// Agent will use these tools to discover project context
|
||||
"code_index": true,
|
||||
"search_tools": {
|
||||
// Agent will use these native tools to discover project context
|
||||
"ripgrep": true,
|
||||
"find": true,
|
||||
"exa_code": true,
|
||||
"exa_web": true
|
||||
}
|
||||
@@ -76,8 +77,9 @@ Task(
|
||||
### Session Metadata
|
||||
{session_metadata_content}
|
||||
|
||||
### MCP Capabilities
|
||||
- code-index: Available for file discovery and code search
|
||||
### Search Tools
|
||||
- ripgrep: Available for content search and pattern matching
|
||||
- find: Available for file discovery
|
||||
- exa-code: Available for external research
|
||||
- exa-web: Available for web search
|
||||
|
||||
@@ -87,7 +89,7 @@ Task(
|
||||
1. **Project Structure Analysis**: Execute get_modules_by_depth.sh for architecture overview
|
||||
2. **Documentation Loading**: Load CLAUDE.md, README.md and relevant documentation
|
||||
3. **Keyword Extraction**: Extract core keywords from task description
|
||||
4. **Smart File Discovery**: Use MCP code-index tools to locate relevant files
|
||||
4. **Smart File Discovery**: Use ripgrep and find to locate relevant files
|
||||
5. **Code Structure Analysis**: Analyze project structure to identify relevant modules
|
||||
6. **Dependency Discovery**: Identify tech stack and dependency relationships
|
||||
7. **Context Packaging**: Generate standardized JSON context package
|
||||
@@ -120,22 +122,18 @@ Task(
|
||||
- Identify potentially involved modules and components
|
||||
- Set file type filters
|
||||
|
||||
#### Step 2: MCP-Enhanced File Discovery
|
||||
#### Step 2: File Discovery with Native Tools
|
||||
1. **Code File Location**
|
||||
Use MCP code-index tools:
|
||||
\`\`\`javascript
|
||||
// Find files by pattern
|
||||
mcp__code-index__find_files(pattern="*{keyword}*")
|
||||
Use ripgrep and find commands:
|
||||
\`\`\`bash
|
||||
# Find files by pattern
|
||||
find . -name "*{keyword}*" -type f
|
||||
|
||||
// Search code content
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="{keyword_patterns}",
|
||||
file_pattern="*.{ts,js,py,go,md}",
|
||||
context_lines=3
|
||||
)
|
||||
# Search code content with ripgrep
|
||||
rg "{keyword_patterns}" --type-add 'custom:*.{ts,js,py,go,md}' -t custom -C 3
|
||||
|
||||
// Get file summaries
|
||||
mcp__code-index__get_file_summary(file_path="relevant/file.ts")
|
||||
# Get file summaries (find function/class definitions)
|
||||
rg "^(class|function|export|def|interface)" relevant/file.ts
|
||||
\`\`\`
|
||||
|
||||
2. **Configuration Files Discovery**
|
||||
@@ -321,34 +319,27 @@ Before completion, verify:
|
||||
- File count limit: Maximum 50 files per type
|
||||
- Size filtering: Skip oversized files (>10MB)
|
||||
- Depth limit: Maximum search depth of 3 levels
|
||||
- Use MCP tools for efficient discovery
|
||||
- Use ripgrep for efficient discovery
|
||||
|
||||
**MCP Tools Integration**:
|
||||
Agent should use MCP code-index tools when available:
|
||||
\`\`\`javascript
|
||||
// Set project path
|
||||
mcp__code-index__set_project_path(path="{current_project_path}")
|
||||
**Native Tools Integration**:
|
||||
Agent should use ripgrep and find commands:
|
||||
\`\`\`bash
|
||||
# Find files by pattern
|
||||
find . -name "*{keyword}*" -type f
|
||||
|
||||
// Refresh index
|
||||
mcp__code-index__refresh_index()
|
||||
# Search code content with ripgrep
|
||||
rg "{keyword_patterns}" --type ts --type js --type py --type go --type md -C 3
|
||||
|
||||
// Find files by pattern
|
||||
mcp__code-index__find_files(pattern="*{keyword}*")
|
||||
# Alternative: use glob patterns
|
||||
rg "{keyword_patterns}" -g "*.{ts,js,py,go,md}" -C 3
|
||||
|
||||
// Search code content
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="{keyword_patterns}",
|
||||
file_pattern="*.{ts,js,py,go,md}",
|
||||
context_lines=3
|
||||
)
|
||||
# Count matches
|
||||
rg "{keyword_patterns}" -c
|
||||
|
||||
# List files with matches
|
||||
rg "{keyword_patterns}" --files-with-matches
|
||||
\`\`\`
|
||||
|
||||
**Fallback Strategy**:
|
||||
When MCP tools unavailable, agent should use traditional commands:
|
||||
- \`find\` for file discovery
|
||||
- \`rg\` or \`grep\` for content search
|
||||
- Bash commands from project structure analysis
|
||||
|
||||
## Output
|
||||
|
||||
Generate context-package.json and report completion:
|
||||
@@ -391,9 +382,10 @@ const agentContext = {
|
||||
? memory.get("workflow-session.json")
|
||||
: Read(.workflow/WFS-[id]/workflow-session.json),
|
||||
|
||||
// MCP capabilities - agent will use these tools
|
||||
mcp_capabilities: {
|
||||
code_index: true,
|
||||
// Search tools - agent will use these native tools
|
||||
search_tools: {
|
||||
ripgrep: true,
|
||||
find: true,
|
||||
exa_code: true,
|
||||
exa_web: true
|
||||
}
|
||||
|
||||
@@ -93,14 +93,11 @@ Autonomous task JSON and IMPL_PLAN.md generation using action-planning-agent wit
|
||||
}
|
||||
```
|
||||
|
||||
5. **MCP Code Analysis** (optional - enhance understanding)
|
||||
```javascript
|
||||
// Find relevant files for task context
|
||||
mcp__code-index__find_files(pattern="*auth*")
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="authentication|oauth",
|
||||
file_pattern="*.ts"
|
||||
)
|
||||
5. **Code Analysis with Native Tools** (optional - enhance understanding)
|
||||
```bash
|
||||
# Find relevant files for task context
|
||||
find . -name "*auth*" -type f
|
||||
rg "authentication|oauth" -g "*.ts"
|
||||
```
|
||||
|
||||
6. **MCP External Research** (optional - gather best practices)
|
||||
@@ -274,18 +271,13 @@ $(cat ~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)
|
||||
**Code Index Usage**:
|
||||
\`\`\`javascript
|
||||
// Discover authentication-related files
|
||||
mcp__code-index__find_files(pattern="*auth*")
|
||||
bash(find . -name "*auth*" -type f)
|
||||
|
||||
// Search for OAuth patterns
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="oauth|jwt|authentication",
|
||||
file_pattern="*.{ts,js}"
|
||||
)
|
||||
bash(rg "oauth|jwt|authentication" -g "*.{ts,js}")
|
||||
|
||||
// Get file summary for key components
|
||||
mcp__code-index__get_file_summary(
|
||||
file_path="src/auth/index.ts"
|
||||
)
|
||||
bash(rg "^(class|function|export|interface)" src/auth/index.ts)
|
||||
\`\`\`
|
||||
|
||||
**Exa Research Usage**:
|
||||
|
||||
@@ -249,9 +249,9 @@ This enhanced 5-field schema embeds all necessary context, artifacts, and execut
|
||||
}
|
||||
},
|
||||
{
|
||||
"step": "mcp_codebase_exploration",
|
||||
"action": "Explore codebase using MCP tools",
|
||||
"command": "mcp__code-index__find_files(pattern=\"[patterns]\") && mcp__code-index__search_code_advanced(pattern=\"[patterns]\")",
|
||||
"step": "codebase_exploration",
|
||||
"action": "Explore codebase using native tools",
|
||||
"command": "bash(find . -name \"[patterns]\" -type f && rg \"[patterns]\")",
|
||||
"output_to": "codebase_structure"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,11 +17,11 @@ Specialized context collector for test generation workflows that analyzes test c
|
||||
- **Gap Identification**: Locate implementation files without corresponding tests
|
||||
- **Source Context Loading**: Import implementation summaries from source session
|
||||
- **Framework Detection**: Auto-detect test framework and patterns
|
||||
- **MCP-Powered**: Leverage code-index tools for precise analysis
|
||||
- **Ripgrep-Powered**: Leverage ripgrep and native tools for precise analysis
|
||||
|
||||
## Core Responsibilities
|
||||
- Load source session implementation context
|
||||
- Analyze current test coverage using MCP tools
|
||||
- Analyze current test coverage using ripgrep
|
||||
- Identify files requiring test generation
|
||||
- Detect test framework and conventions
|
||||
- Package test context for analysis phase
|
||||
@@ -41,21 +41,17 @@ Specialized context collector for test generation workflows that analyzes test c
|
||||
- Extract changed files and implementation scope
|
||||
- Identify implementation patterns and tech stack
|
||||
|
||||
### Phase 2: Test Coverage Analysis (MCP Tools)
|
||||
### Phase 2: Test Coverage Analysis (Ripgrep)
|
||||
|
||||
1. **Existing Test Discovery**
|
||||
```bash
|
||||
# Find all test files
|
||||
mcp__code-index__find_files(pattern="*.test.*")
|
||||
mcp__code-index__find_files(pattern="*.spec.*")
|
||||
mcp__code-index__find_files(pattern="*test_*.py")
|
||||
find . -name "*.test.*" -type f
|
||||
find . -name "*.spec.*" -type f
|
||||
find . -name "*test_*.py" -type f
|
||||
|
||||
# Search for test patterns
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="describe|it|test|@Test",
|
||||
file_pattern="*.test.*",
|
||||
context_lines=0
|
||||
)
|
||||
rg "describe|it|test|@Test" -g "*.test.*"
|
||||
```
|
||||
|
||||
2. **Coverage Gap Analysis**
|
||||
@@ -80,18 +76,10 @@ Specialized context collector for test generation workflows that analyzes test c
|
||||
1. **Framework Identification**
|
||||
```bash
|
||||
# Check package.json or requirements.txt
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="jest|mocha|jasmine|pytest|unittest|rspec",
|
||||
file_pattern="package.json|requirements.txt|Gemfile",
|
||||
context_lines=2
|
||||
)
|
||||
rg "jest|mocha|jasmine|pytest|unittest|rspec" -g "package.json" -g "requirements.txt" -g "Gemfile" -C 2
|
||||
|
||||
# Analyze existing test patterns
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="describe\\(|it\\(|test\\(|def test_",
|
||||
file_pattern="*.test.*",
|
||||
context_lines=3
|
||||
)
|
||||
rg "describe\(|it\(|test\(|def test_" -g "*.test.*" -C 3
|
||||
```
|
||||
|
||||
2. **Convention Analysis**
|
||||
@@ -207,33 +195,26 @@ Generate `test-context-package.json`:
|
||||
.workflow/{test_session_id}/.process/test-context-package.json
|
||||
```
|
||||
|
||||
## MCP Tools Usage
|
||||
## Native Tools Usage
|
||||
|
||||
### File Discovery
|
||||
```bash
|
||||
# Test files
|
||||
mcp__code-index__find_files(pattern="*.test.*")
|
||||
mcp__code-index__find_files(pattern="*.spec.*")
|
||||
find . -name "*.test.*" -type f
|
||||
find . -name "*.spec.*" -type f
|
||||
|
||||
# Implementation files
|
||||
mcp__code-index__find_files(pattern="*.ts")
|
||||
mcp__code-index__find_files(pattern="*.js")
|
||||
find . -name "*.ts" -type f
|
||||
find . -name "*.js" -type f
|
||||
```
|
||||
|
||||
### Content Search
|
||||
```bash
|
||||
# Test framework detection
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="jest|mocha|pytest",
|
||||
file_pattern="package.json|requirements.txt"
|
||||
)
|
||||
rg "jest|mocha|pytest" -g "package.json" -g "requirements.txt"
|
||||
|
||||
# Test pattern analysis
|
||||
mcp__code-index__search_code_advanced(
|
||||
pattern="describe|it|test",
|
||||
file_pattern="*.test.*",
|
||||
context_lines=2
|
||||
)
|
||||
rg "describe|it|test" -g "*.test.*" -C 2
|
||||
```
|
||||
|
||||
### Coverage Analysis
|
||||
@@ -249,7 +230,7 @@ test_file_patterns=(
|
||||
|
||||
# Search for test file
|
||||
for pattern in "${test_file_patterns[@]}"; do
|
||||
if mcp__code-index__find_files(pattern="$pattern") | grep -q .; then
|
||||
if [ -f "$pattern" ]; then
|
||||
echo "✅ Test exists: $pattern"
|
||||
break
|
||||
fi
|
||||
@@ -262,10 +243,9 @@ done
|
||||
|-------|-------|------------|
|
||||
| Source session not found | Invalid source_session reference | Verify test session metadata |
|
||||
| No implementation summaries | Source session incomplete | Complete source session first |
|
||||
| MCP tools unavailable | MCP not configured | Fallback to bash find/grep |
|
||||
| No test framework detected | Missing test dependencies | Request user to specify framework |
|
||||
|
||||
## Fallback Strategy (No MCP)
|
||||
## Native Tools Implementation
|
||||
|
||||
```bash
|
||||
# File discovery
|
||||
@@ -287,8 +267,8 @@ done
|
||||
- `/workflow:test-gen` (Phase 3: Context Gathering)
|
||||
|
||||
### Calls
|
||||
- MCP code-index tools for analysis
|
||||
- Bash file operations for fallback
|
||||
- Ripgrep and find for file analysis
|
||||
- Bash file operations for coverage analysis
|
||||
|
||||
### Followed By
|
||||
- `/workflow:tools:test-concept-enhanced` - Analyzes context and plans test generation
|
||||
@@ -296,7 +276,7 @@ done
|
||||
## Success Criteria
|
||||
|
||||
- ✅ Source session context loaded successfully
|
||||
- ✅ Test coverage gaps identified with MCP tools
|
||||
- ✅ Test coverage gaps identified with ripgrep
|
||||
- ✅ Test framework detected and documented
|
||||
- ✅ Valid test-context-package.json generated
|
||||
- ✅ All missing tests catalogued with priority
|
||||
|
||||
@@ -146,9 +146,9 @@ Generate **TWO task JSON files**:
|
||||
"step": "load_existing_test_patterns",
|
||||
"action": "Study existing tests for pattern reference",
|
||||
"commands": [
|
||||
"mcp__code-index__find_files(pattern=\"*.test.*\")",
|
||||
"bash(find . -name \"*.test.*\" -type f)",
|
||||
"bash(# Read first 2 existing test files as examples)",
|
||||
"bash(test_files=$(mcp__code-index__find_files(pattern=\"*.test.*\") | head -2))",
|
||||
"bash(test_files=$(find . -name \"*.test.*\" -type f | head -2))",
|
||||
"bash(for f in $test_files; do echo \"=== $f ===\"&& cat \"$f\"; done)"
|
||||
],
|
||||
"output_to": "existing_test_patterns",
|
||||
@@ -282,11 +282,11 @@ Generate **TWO task JSON files**:
|
||||
"step": "analyze_test_coverage",
|
||||
"action": "Analyze test coverage and identify missing tests",
|
||||
"commands": [
|
||||
"mcp__code-index__find_files(pattern=\"*.test.*\")",
|
||||
"mcp__code-index__search_code_advanced(pattern=\"test|describe|it|def test_\", file_pattern=\"*.test.*\")",
|
||||
"bash(find . -name \"*.test.*\" -type f)",
|
||||
"bash(rg \"test|describe|it|def test_\" -g \"*.test.*\")",
|
||||
"bash(# Count implementation files vs test files)",
|
||||
"bash(impl_count=$(find [changed_files_dirs] -type f \\( -name '*.ts' -o -name '*.js' -o -name '*.py' \\) ! -name '*.test.*' 2>/dev/null | wc -l))",
|
||||
"bash(test_count=$(mcp__code-index__find_files(pattern=\"*.test.*\") | wc -l))",
|
||||
"bash(test_count=$(find . -name \"*.test.*\" -type f | wc -l))",
|
||||
"bash(echo \"Implementation files: $impl_count, Test files: $test_count\")"
|
||||
],
|
||||
"output_to": "test_coverage_analysis",
|
||||
|
||||
Reference in New Issue
Block a user