From 437897faff39c94c4c6178dd0bdf660ec4a6eea5 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 4 Oct 2025 20:44:10 +0800 Subject: [PATCH] feat: Add multi-tool support for CLAUDE.md documentation generation (v3.4.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add flexible tool selection (gemini/qwen/codex) for documentation updates, allowing users to choose the best tool for their analysis needs. Changes: - Add --tool parameter to /update-memory-full and /update-memory-related - Enhance update_module_claude.sh with tool routing (gemini|qwen|codex) - Update command documentation with tool selection examples - Add CHANGELOG entry for v3.4.1 Tool features: - Gemini (default): Documentation generation, pattern recognition - Qwen: Architecture analysis, system design (direct command, no wrapper) - Codex: Implementation validation, code quality analysis Backward compatible: Commands default to gemini without --tool parameter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/commands/update-memory-full.md | 39 ++++++++++---- .claude/commands/update-memory-related.md | 41 ++++++++++----- .claude/scripts/update_module_claude.sh | 63 +++++++++++++++-------- CHANGELOG.md | 50 ++++++++++++++++++ 4 files changed, 149 insertions(+), 44 deletions(-) diff --git a/.claude/commands/update-memory-full.md b/.claude/commands/update-memory-full.md index 21a56503..6897640a 100644 --- a/.claude/commands/update-memory-full.md +++ b/.claude/commands/update-memory-full.md @@ -1,33 +1,46 @@ --- name: update-memory-full description: Complete project-wide CLAUDE.md documentation update -usage: /update-memory-full +usage: /update-memory-full [--tool ] +argument-hint: "[--tool gemini|qwen|codex]" examples: - - /update-memory-full # Full project documentation update + - /update-memory-full # Full project documentation update (gemini default) + - /update-memory-full --tool qwen # Use Qwen for architecture analysis + - /update-memory-full --tool codex # Use Codex for implementation validation --- ### 🚀 Command Overview: `/update-memory-full` Complete project-wide documentation update using depth-parallel execution. +**Tool Selection**: +- **Gemini (default)**: Documentation generation, pattern recognition, architecture review +- **Qwen**: Architecture analysis, system design documentation +- **Codex**: Implementation validation, code quality analysis + ### 📝 Execution Template ```bash #!/bin/bash # Complete project-wide CLAUDE.md documentation update -# Step 1: Code Index architecture analysis +# Step 1: Parse tool selection (default: gemini) +tool="gemini" +[[ "$*" == *"--tool qwen"* ]] && tool="qwen" +[[ "$*" == *"--tool codex"* ]] && tool="codex" + +# Step 2: Code Index architecture analysis mcp__code-index__search_code_advanced(pattern="class|function|interface", file_pattern="**/*.{ts,js,py}") mcp__code-index__find_files(pattern="**/*.{md,json,yaml,yml}") -# Step 2: Cache git changes +# Step 3: Cache git changes Bash(git add -A 2>/dev/null || true) -# Step 3: Get and display project structure +# Step 4: Get and display project structure modules=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list)) count=$(echo "$modules" | wc -l) -# Step 3: Analysis handover → Model takes control +# Step 5: Analysis handover → Model takes control # BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS # Pseudocode flow: @@ -35,6 +48,8 @@ count=$(echo "$modules" | wc -l) # → Task "Complex project full update" subagent_type: "memory-gemini-bridge" # ELSE: # → Present plan and WAIT FOR USER APPROVAL before execution +# +# Pass tool parameter to update_module_claude.sh: "$tool" ``` ### 🧠 Model Analysis Phase @@ -43,7 +58,7 @@ After the bash script completes the initial analysis, the model takes control to 1. **Analyze Complexity**: Review module count and project context 2. **Parse CLAUDE.md Status**: Extract which modules have/need CLAUDE.md files -3. **Choose Strategy**: +3. **Choose Strategy**: - Simple projects: Present execution plan with CLAUDE.md paths to user - Complex projects: Delegate to memory-gemini-bridge agent 4. **Present Detailed Plan**: Show user exactly which CLAUDE.md files will be created/updated @@ -56,17 +71,19 @@ After the bash script completes the initial analysis, the model takes control to Model will present detailed plan: ``` 📋 Update Plan: + Tool: [gemini|qwen|codex] (from --tool parameter) + NEW CLAUDE.md files (X): - ./src/components/CLAUDE.md - ./src/services/CLAUDE.md - + UPDATE existing CLAUDE.md files (Y): - ./CLAUDE.md - ./src/CLAUDE.md - ./tests/CLAUDE.md Total: N CLAUDE.md files will be processed - + ⚠️ Confirm execution? (y/n) ``` @@ -84,7 +101,7 @@ depth_modules = organize_by_depth(modules) FOR depth FROM max_depth DOWN TO 0: FOR each module IN depth_modules[depth]: WHILE active_jobs >= 4: wait(0.1) - Bash(~/.claude/scripts/update_module_claude.sh "$module" "full" &) + Bash(~/.claude/scripts/update_module_claude.sh "$module" "full" "$tool" &) wait_all_jobs() # Step 6: Safety check and restore staging state @@ -105,7 +122,7 @@ Bash(git status --short) The model will delegate to the memory-gemini-bridge agent using the Task tool: ``` Task "Complex project full update" -prompt: "Execute full documentation update for [count] modules using depth-parallel execution" +prompt: "Execute full documentation update for [count] modules using [tool] with depth-parallel execution" subagent_type: "memory-gemini-bridge" ``` diff --git a/.claude/commands/update-memory-related.md b/.claude/commands/update-memory-related.md index 2b672d63..1461b811 100644 --- a/.claude/commands/update-memory-related.md +++ b/.claude/commands/update-memory-related.md @@ -1,15 +1,23 @@ --- name: update-memory-related description: Context-aware CLAUDE.md documentation updates based on recent changes -usage: /update-memory-related +usage: /update-memory-related [--tool ] +argument-hint: "[--tool gemini|qwen|codex]" examples: - - /update-memory-related # Update documentation based on recent changes + - /update-memory-related # Update documentation based on recent changes (gemini default) + - /update-memory-related --tool qwen # Use Qwen for architecture analysis + - /update-memory-related --tool codex # Use Codex for implementation validation --- ### 🚀 Command Overview: `/update-memory-related` Context-aware documentation update for modules affected by recent changes. +**Tool Selection**: +- **Gemini (default)**: Documentation generation, pattern recognition, architecture review +- **Qwen**: Architecture analysis, system design documentation +- **Codex**: Implementation validation, code quality analysis + ### 📝 Execution Template @@ -17,23 +25,28 @@ Context-aware documentation update for modules affected by recent changes. #!/bin/bash # Context-aware CLAUDE.md documentation update -# Step 1: Code Index refresh and architecture analysis +# Step 1: Parse tool selection (default: gemini) +tool="gemini" +[[ "$*" == *"--tool qwen"* ]] && tool="qwen" +[[ "$*" == *"--tool codex"* ]] && tool="codex" + +# Step 2: Code Index refresh and architecture analysis mcp__code-index__refresh_index() mcp__code-index__search_code_advanced(pattern="class|function|interface", file_pattern="**/*.{ts,js,py}") -# Step 2: Detect changed modules (before staging) +# Step 3: Detect changed modules (before staging) changed=$(Bash(~/.claude/scripts/detect_changed_modules.sh list)) -# Step 3: Cache git changes (protect current state) +# Step 4: Cache git changes (protect current state) Bash(git add -A 2>/dev/null || true) -# Step 3: Use detected changes or fallback +# Step 5: Use detected changes or fallback if [ -z "$changed" ]; then changed=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list | head -10)) fi count=$(echo "$changed" | wc -l) -# Step 4: Analysis handover → Model takes control +# Step 6: Analysis handover → Model takes control # BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS # Pseudocode flow: @@ -41,6 +54,8 @@ count=$(echo "$changed" | wc -l) # → Task "Complex project related update" subagent_type: "memory-gemini-bridge" # ELSE: # → Present plan and WAIT FOR USER APPROVAL before execution +# +# Pass tool parameter to update_module_claude.sh: "$tool" ``` ### 🧠 Model Analysis Phase @@ -62,18 +77,20 @@ After the bash script completes change detection, the model takes control to: Model will present detailed plan for affected modules: ``` 📋 Related Update Plan: + Tool: [gemini|qwen|codex] (from --tool parameter) + CHANGED modules affecting CLAUDE.md: - + NEW CLAUDE.md files (X): - ./src/api/auth/CLAUDE.md [new module] - ./src/utils/helpers/CLAUDE.md [new module] - + UPDATE existing CLAUDE.md files (Y): - ./src/api/CLAUDE.md [parent of changed auth/] - ./src/CLAUDE.md [root level] Total: N CLAUDE.md files will be processed for recent changes - + ⚠️ Confirm execution? (y/n) ``` @@ -91,7 +108,7 @@ depth_modules = organize_by_depth(changed_modules) FOR depth FROM max_depth DOWN TO 0: FOR each module IN depth_modules[depth]: WHILE active_jobs >= 4: wait(0.1) - Bash(~/.claude/scripts/update_module_claude.sh "$module" "related" &) + Bash(~/.claude/scripts/update_module_claude.sh "$module" "related" "$tool" &) wait_all_jobs() # Step 6: Safety check and restore staging state @@ -112,7 +129,7 @@ Bash(git diff --stat) The model will delegate to the memory-gemini-bridge agent using the Task tool: ``` Task "Complex project related update" -prompt: "Execute context-aware update for [count] changed modules using depth-parallel execution" +prompt: "Execute context-aware update for [count] changed modules using [tool] with depth-parallel execution" subagent_type: "memory-gemini-bridge" ``` diff --git a/.claude/scripts/update_module_claude.sh b/.claude/scripts/update_module_claude.sh index 7dd42421..3ff6afb9 100644 --- a/.claude/scripts/update_module_claude.sh +++ b/.claude/scripts/update_module_claude.sh @@ -1,13 +1,15 @@ #!/bin/bash # Update CLAUDE.md for a specific module with automatic layer detection -# Usage: update_module_claude.sh [update_type] +# Usage: update_module_claude.sh [update_type] [tool] # module_path: Path to the module directory # update_type: full|related (default: full) +# tool: gemini|qwen|codex (default: gemini) # Script automatically detects layer depth and selects appropriate template update_module_claude() { local module_path="$1" local update_type="${2:-full}" + local tool="${3:-gemini}" # Validate parameters if [ -z "$module_path" ]; then @@ -61,9 +63,9 @@ update_module_claude() { # Prepare logging info local module_name=$(basename "$module_path") - + echo "⚡ Updating: $module_path" - echo " Layer: $layer | Type: $update_type | Files: $file_count" + echo " Layer: $layer | Type: $update_type | Tool: $tool | Files: $file_count" echo " Template: $(basename "$template_path") | Strategy: $analysis_strategy" # Generate prompt with template injection @@ -106,31 +108,50 @@ update_module_claude() { # Execute update local start_time=$(date +%s) echo " 🔄 Starting update..." - + if cd "$module_path" 2>/dev/null; then - # Execute gemini command with layer-specific analysis strategy - local gemini_result=0 - if [ "$analysis_strategy" = "--all-files" ]; then - gemini --all-files --yolo -p "$base_prompt + local tool_result=0 + local final_prompt="$base_prompt Module Information: - Name: $module_name - Path: $module_path - Layer: $layer - - Analysis Strategy: $analysis_strategy" 2>&1 - gemini_result=$? - else - gemini --yolo -p "$analysis_strategy $base_prompt + - Tool: $tool + - Analysis Strategy: $analysis_strategy" - Module Information: - - Name: $module_name - - Path: $module_path - - Layer: $layer - - Analysis Strategy: $analysis_strategy" 2>&1 - gemini_result=$? - fi - - if [ $gemini_result -eq 0 ]; then + # Execute with selected tool + case "$tool" in + qwen) + if [ "$analysis_strategy" = "--all-files" ]; then + qwen --all-files --yolo -p "$final_prompt" 2>&1 + tool_result=$? + else + qwen --yolo -p "$analysis_strategy $final_prompt" 2>&1 + tool_result=$? + fi + ;; + codex) + if [ "$analysis_strategy" = "--all-files" ]; then + codex --full-auto exec "$final_prompt" --skip-git-repo-check -s danger-full-access 2>&1 + tool_result=$? + else + codex --full-auto exec "$final_prompt CONTEXT: $analysis_strategy" --skip-git-repo-check -s danger-full-access 2>&1 + tool_result=$? + fi + ;; + gemini|*) + if [ "$analysis_strategy" = "--all-files" ]; then + gemini --all-files --yolo -p "$final_prompt" 2>&1 + tool_result=$? + else + gemini --yolo -p "$analysis_strategy $final_prompt" 2>&1 + tool_result=$? + fi + ;; + esac + + if [ $tool_result -eq 0 ]; then local end_time=$(date +%s) local duration=$((end_time - start_time)) echo " ✅ Completed in ${duration}s" diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a6c49d..0843cf5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,56 @@ All notable changes to Claude Code Workflow (CCW) will be documented in this fil The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.4.1] - 2025-10-04 + +### 🎯 Multi-Tool Support for Documentation Updates + +This release adds flexible tool selection for CLAUDE.md documentation generation, allowing users to choose between Gemini, Qwen, or Codex based on their analysis needs. + +#### Added + +**Multi-Tool Support**: +- **`/update-memory-full --tool `**: Choose tool for full project documentation update +- **`/update-memory-related --tool `**: Choose tool for context-aware documentation update +- **Default**: Gemini (documentation generation, pattern recognition) +- **Qwen**: Architecture analysis, system design documentation +- **Codex**: Implementation validation, code quality analysis + +**Script Enhancement** (`update_module_claude.sh`): +- Added third parameter for tool selection: ` [update_type] [tool]` +- Support for three tools with consistent parameter syntax: + - `gemini --all-files --yolo -p` (default) + - `qwen --all-files --yolo -p` (direct command, no wrapper) + - `codex --full-auto exec` (with danger-full-access) +- Automatic tool routing via case statement +- Improved logging with tool information display + +#### Changed + +**Command Documentation**: +- Updated `/update-memory-full.md` with tool selection usage and examples +- Updated `/update-memory-related.md` with tool selection usage and examples +- Added tool selection strategy and rationale documentation + +#### Technical Details + +**Tool Execution Patterns**: +```bash +# Gemini (default) +gemini --all-files --yolo -p "$prompt" + +# Qwen (architecture analysis) +qwen --all-files --yolo -p "$prompt" + +# Codex (implementation validation) +codex --full-auto exec "$prompt" --skip-git-repo-check -s danger-full-access +``` + +**Backward Compatibility**: +- ✅ Existing commands without `--tool` parameter default to Gemini +- ✅ All three tools support Layer 1-4 template system +- ✅ No breaking changes to existing workflows + ## [3.3.0] - 2025-10-04 ### 🚀 CLI Tool Enhancements & Codex Multi-Step Execution