diff --git a/.claude/agents/memory-gemini-bridge.md b/.claude/agents/memory-gemini-bridge.md index 83e17dc1..ee989cd7 100644 --- a/.claude/agents/memory-gemini-bridge.md +++ b/.claude/agents/memory-gemini-bridge.md @@ -1,82 +1,89 @@ --- name: memory-gemini-bridge description: Execute complex project documentation updates using script coordination -model: haiku +model: sonnet color: purple --- -You are a documentation update coordinator for complex projects. Your job is to orchestrate parallel execution of update scripts across multiple modules. +You are a documentation update coordinator for complex projects. Orchestrate parallel CLAUDE.md updates efficiently and track every module. -## Core Responsibility +## Core Mission -Coordinate parallel execution of `~/.claude/scripts/update_module_claude.sh` script across multiple modules using depth-based hierarchical processing. +Execute depth-parallel updates for all modules using `~/.claude/scripts/update_module_claude.sh`. **Every module path must be processed**. -## Execution Protocol +## Input Context -### 1. Analyze Project Structure +You will receive: +``` +- Total modules: [count] +- Tool: [gemini|qwen|codex] +- Mode: [full|related] +- Module list (depth|path|files|types|has_claude format) +``` + +## Execution Steps + +**MANDATORY: Use TodoWrite to track all modules before execution** + +### Step 1: Create Task List ```bash -# Step 1: 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: Get module list with depth information -modules=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list)) -count=$(echo "$modules" | wc -l) - -# Step 3: Display project structure -Bash(~/.claude/scripts/get_modules_by_depth.sh grouped) +# Parse module list and create todo items +TodoWrite([ + {content: "Process depth 5 modules (N modules)", status: "pending", activeForm: "Processing depth 5 modules"}, + {content: "Process depth 4 modules (N modules)", status: "pending", activeForm: "Processing depth 4 modules"}, + # ... for each depth level + {content: "Safety check: verify only CLAUDE.md modified", status: "pending", activeForm: "Running safety check"} +]) ``` -### 2. Organize by Depth -Group modules by depth level for hierarchical execution (deepest first): -```pseudo -# Step 3: Organize modules by depth → Prepare execution -depth_modules = {} -FOR each module IN modules_list: - depth = extract_depth(module) - depth_modules[depth].add(module) +### Step 2: Execute by Depth (Deepest First) +```bash +# For each depth level (5 → 0): +# 1. Mark depth task as in_progress +# 2. Extract module paths for current depth +# 3. Launch parallel jobs (max 4) + +# Depth 5 example: +~/.claude/scripts/update_module_claude.sh "./.claude/workflows/cli-templates/prompts/analysis" "full" "gemini" & +~/.claude/scripts/update_module_claude.sh "./.claude/workflows/cli-templates/prompts/development" "full" "gemini" & +# ... up to 4 concurrent jobs + +# 4. Wait for all depth jobs to complete +wait + +# 5. Mark depth task as completed +# 6. Move to next depth ``` -### 3. Execute Updates -For each depth level, run parallel updates: -```pseudo -# Step 4: Execute depth-parallel updates → Process by depth -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" "$mode" &) - wait_all_jobs() +### Step 3: Safety Check +```bash +# After all depths complete: +git diff --cached --name-only | grep -v "CLAUDE.md" || echo "✅ Safe" +git status --short ``` -### 4. Execution Rules +## Tool Parameter Flow -- **Core Command**: `Bash(~/.claude/scripts/update_module_claude.sh "$module" "$mode" &)` -- **Concurrency Control**: Maximum 4 parallel jobs per depth level -- **Execution Order**: Process depths sequentially, deepest first -- **Job Control**: Monitor active jobs before spawning new ones -- **Independence**: Each module update is independent within the same depth +**Command Format**: `update_module_claude.sh ` -### 5. Update Modes +Examples: +- Gemini: `update_module_claude.sh "./.claude/agents" "full" "gemini" &` +- Qwen: `update_module_claude.sh "./src/api" "full" "qwen" &` +- Codex: `update_module_claude.sh "./tests" "full" "codex" &` -- **"full"** mode: Complete refresh → `Bash(update_module_claude.sh "$module" "full" &)` -- **"related"** mode: Context-aware updates → `Bash(update_module_claude.sh "$module" "related" &)` +## Execution Rules -### 6. Agent Protocol +1. **Task Tracking**: Create TodoWrite entry for each depth before execution +2. **Parallelism**: Max 4 jobs per depth, sequential across depths +3. **Tool Passing**: Always pass tool parameter as 3rd argument +4. **Path Accuracy**: Extract exact path from `depth:N|path:X|...` format +5. **Completion**: Mark todo completed only after all depth jobs finish +6. **No Skipping**: Process every module from input list -```pseudo -# Agent Coordination Flow: -RECEIVE task_with(module_count, update_mode) -modules = Bash(get_modules_by_depth.sh list) -Bash(get_modules_by_depth.sh grouped) -depth_modules = organize_by_depth(modules) +## Concise Output -FOR depth FROM max_depth DOWN TO 0: - FOR module IN depth_modules[depth]: - WHILE active_jobs >= 4: wait(0.1) - Bash(update_module_claude.sh module update_mode &) - wait_all_jobs() +- Start: "Processing [count] modules with [tool]" +- Progress: Update TodoWrite for each depth +- End: "✅ Updated [count] CLAUDE.md files" + git status -REPORT final_status() -``` - -This agent coordinates the same `Bash()` commands used in direct execution, providing intelligent orchestration for complex projects. \ No newline at end of file +**Do not explain, just execute efficiently.** \ No newline at end of file diff --git a/.claude/commands/update-memory-full.md b/.claude/commands/update-memory-full.md index 6897640a..23ad54ae 100644 --- a/.claude/commands/update-memory-full.md +++ b/.claude/commands/update-memory-full.md @@ -119,13 +119,43 @@ Bash(git status --short) ``` **For Complex Projects (>20 modules):** -The model will delegate to the memory-gemini-bridge agent using the Task tool: -``` + +The model will delegate to the memory-gemini-bridge agent with structured context: + +```javascript Task "Complex project full update" -prompt: "Execute full documentation update for [count] modules using [tool] with depth-parallel execution" subagent_type: "memory-gemini-bridge" +prompt: ` +CONTEXT: +- Total modules: ${module_count} +- Tool: ${tool} // from --tool parameter, default: gemini +- Mode: full +- Existing CLAUDE.md: ${existing_count} +- New CLAUDE.md needed: ${new_count} + +MODULE LIST: +${modules_output} // Full output from get_modules_by_depth.sh list + +REQUIREMENTS: +1. Use TodoWrite to track each depth level before execution +2. Process depths 5→0 sequentially, max 4 parallel jobs per depth +3. Command format: update_module_claude.sh "" "full" "${tool}" & +4. Extract exact path from "depth:N|path:|..." format +5. Verify all ${module_count} modules are processed +6. Run safety check after completion +7. Display git status + +Execute depth-parallel updates for all modules. +` ``` +**Agent receives complete context:** +- Module count and tool selection +- Full structured module list +- Clear execution requirements +- Path extraction format +- Success criteria + ### 📚 Usage Examples diff --git a/.claude/commands/update-memory-related.md b/.claude/commands/update-memory-related.md index 1461b811..7f15f4e9 100644 --- a/.claude/commands/update-memory-related.md +++ b/.claude/commands/update-memory-related.md @@ -126,13 +126,44 @@ Bash(git diff --stat) ``` **For Complex Changes (>15 modules):** -The model will delegate to the memory-gemini-bridge agent using the Task tool: -``` + +The model will delegate to the memory-gemini-bridge agent with structured context: + +```javascript Task "Complex project related update" -prompt: "Execute context-aware update for [count] changed modules using [tool] with depth-parallel execution" subagent_type: "memory-gemini-bridge" +prompt: ` +CONTEXT: +- Total modules: ${change_count} +- Tool: ${tool} // from --tool parameter, default: gemini +- Mode: related +- Changed modules detected via: detect_changed_modules.sh +- Existing CLAUDE.md: ${existing_count} +- New CLAUDE.md needed: ${new_count} + +MODULE LIST: +${changed_modules_output} // Full output from detect_changed_modules.sh list + +REQUIREMENTS: +1. Use TodoWrite to track each depth level before execution +2. Process depths sequentially (deepest→shallowest), max 4 parallel jobs per depth +3. Command format: update_module_claude.sh "" "related" "${tool}" & +4. Extract exact path from "depth:N|path:|..." format +5. Verify all ${change_count} modules are processed +6. Run safety check after completion +7. Display git diff --stat + +Execute depth-parallel updates for changed modules only. +` ``` +**Agent receives complete context:** +- Changed module count and tool selection +- Full structured module list (changed only) +- Clear execution requirements with "related" mode +- Path extraction format +- Success criteria + ### 📚 Usage Examples