diff --git a/.claude/workflows/intelligent-tools-strategy.md b/.claude/workflows/intelligent-tools-strategy.md index f4c1d0b5..a3b6d7bc 100644 --- a/.claude/workflows/intelligent-tools-strategy.md +++ b/.claude/workflows/intelligent-tools-strategy.md @@ -41,19 +41,21 @@ type: strategic-guideline ### Standard Format (REQUIRED) ```bash -# Gemini Analysis +# Gemini Analysis (全权限) cd [directory] && ~/.claude/scripts/gemini-wrapper -p " PURPOSE: [clear analysis goal] TASK: [specific analysis task] +MODE: [analysis|write] CONTEXT: [file references and memory context] EXPECTED: [expected output] RULES: [template reference and constraints] " -# Qwen Architecture & Code Generation +# Qwen Architecture Analysis (仅分析) cd [directory] && ~/.claude/scripts/qwen-wrapper -p " -PURPOSE: [clear architecture/code goal] -TASK: [specific architecture/code task] +PURPOSE: [clear architecture goal] +TASK: [specific analysis task] +MODE: analysis CONTEXT: [file references and memory context] EXPECTED: [expected deliverables] RULES: [template reference and constraints] @@ -63,6 +65,7 @@ RULES: [template reference and constraints] codex -C [directory] --full-auto exec " PURPOSE: [clear development goal] TASK: [specific development task] +MODE: [auto|write] CONTEXT: [file references and memory context] EXPECTED: [expected deliverables] RULES: [template reference and constraints] @@ -72,10 +75,26 @@ RULES: [template reference and constraints] ### Template Structure - [ ] **PURPOSE** - Clear goal and intent - [ ] **TASK** - Specific execution task +- [ ] **MODE** - Execution mode and permission level - [ ] **CONTEXT** - File references and memory context from previous sessions - [ ] **EXPECTED** - Clear expected results - [ ] **RULES** - Template reference and constraints +### MODE Field Definition + +The MODE field controls execution behavior and file permissions: + +**For Gemini** (全权限,可读写): +- `analysis` (default) - 分析 + 可生成文档 +- `write` - 创建/修改文件(自动启用 --approval-mode yolo) + +**For Qwen** (仅分析): +- `analysis` (default) - 仅架构分析,不生成代码 + +**For Codex**: +- `auto` (default) - 自主开发,全文件操作 +- `write` - 测试生成和文件修改 + ### Directory Context Tools execute in current working directory: - **Gemini**: `cd path/to/project && ~/.claude/scripts/gemini-wrapper -p "prompt"` @@ -150,80 +169,92 @@ When planning any coding task, **ALWAYS** integrate CLI tools: ### Common Scenarios ```bash -# Project Analysis (in current directory) +# Gemini - Code Analysis ~/.claude/scripts/gemini-wrapper -p " PURPOSE: Understand codebase architecture TASK: Analyze project structure and identify patterns +MODE: analysis CONTEXT: @{src/**/*.ts,CLAUDE.md} Previous analysis of auth system EXPECTED: Architecture overview and integration points -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt") | Focus on integration points +RULES: $(cat '~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt') | Focus on integration points " -# Project Analysis (in different directory) -cd ../other-project && ~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Compare authentication patterns -TASK: Analyze auth implementation in related project -CONTEXT: @{src/auth/**/*} Current project context from session memory -EXPECTED: Pattern comparison and recommendations -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt") | Focus on architectural differences +# Gemini - Generate Documentation +~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Generate API documentation +TASK: Create comprehensive API reference from code +MODE: write +CONTEXT: @{src/api/**/*} +EXPECTED: API.md with all endpoints documented +RULES: Follow project documentation standards " -# Architecture Design (with Qwen) +# Qwen - Architecture Analysis cd src/auth && ~/.claude/scripts/qwen-wrapper -p " -PURPOSE: Design authentication system architecture -TASK: Create modular JWT-based auth system design +PURPOSE: Analyze authentication system architecture +TASK: Review JWT-based auth system design +MODE: analysis CONTEXT: @{src/auth/**/*} Existing patterns and requirements -EXPECTED: Complete architecture with code scaffolding -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt") | Focus on modularity and security +EXPECTED: Architecture analysis report with recommendations +RULES: $(cat '~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt') | Focus on security " -# Feature Development (in target directory) +# Codex - Feature Development codex -C path/to/project --full-auto exec " PURPOSE: Implement user authentication TASK: Create JWT-based authentication system +MODE: auto CONTEXT: @{src/auth/**/*} Database schema from session memory EXPECTED: Complete auth module with tests -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/development/feature.txt") | Follow security best practices +RULES: $(cat '~/.claude/workflows/cli-templates/prompts/development/feature.txt') | Follow security best practices " --skip-git-repo-check -s danger-full-access -# Code Review Preparation -~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Prepare comprehensive code review -TASK: Analyze code changes and identify potential issues -CONTEXT: @{**/*.modified} Recent changes discussed in last session -EXPECTED: Review checklist and improvement suggestions -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/analysis/quality.txt") | Focus on maintainability -" +# Codex - Test Generation +codex -C src/auth --full-auto exec " +PURPOSE: Increase test coverage +TASK: Generate comprehensive tests for auth module +MODE: write +CONTEXT: @{**/*.ts} Exclude existing tests +EXPECTED: Complete test suite with 80%+ coverage +RULES: Use Jest, follow existing patterns +" --skip-git-repo-check -s danger-full-access ``` ## 📋 Planning Checklist For every development task: - [ ] **Purpose defined** - Clear goal and intent +- [ ] **Mode selected** - Execution mode and permission level determined - [ ] **Context gathered** - File references and session memory documented - [ ] **Gemini analysis** completed for understanding - [ ] **Template selected** - Appropriate template chosen - [ ] **Constraints specified** - File patterns, scope, requirements - [ ] **Implementation approach** - Tool selection and workflow - [ ] **Quality measures** - Testing and validation plan +- [ ] **Tool configuration** - Review `.gemini/CLAUDE.md` or `.codex/Agent.md` if needed ## 🎯 Key Features -### Gemini +### Gemini (全权限) - **Command**: `~/.claude/scripts/gemini-wrapper` - **Strengths**: Large context window, pattern recognition -- **Best For**: Analysis, architecture review, code exploration +- **Best For**: Analysis, documentation generation, code exploration +- **Permissions**: 可读写,MODE=write 时自动启用 --approval-mode yolo +- **Default MODE**: `analysis` -### Qwen +### Qwen (仅分析) - **Command**: `~/.claude/scripts/qwen-wrapper` -- **Strengths**: Architecture analysis, code generation, implementation patterns -- **Best For**: System design, code scaffolding, architectural planning +- **Strengths**: Architecture analysis, pattern recognition +- **Best For**: System design analysis, architectural review +- **Permissions**: 仅分析,不生成代码 +- **Default MODE**: `analysis` ### Codex - **Command**: `codex --full-auto exec` - **Strengths**: Autonomous development, mathematical reasoning - **Best For**: Implementation, testing, automation - **Required**: `-s danger-full-access` and `--skip-git-repo-check` for development +- **Default MODE**: `auto` ### File Patterns - All files: `@{**/*}` @@ -250,15 +281,33 @@ For every development task: **Example**: ```bash -# Focused analysis (preferred) -cd src/auth && ~/.claude/scripts/gemini-wrapper -p "analyze auth patterns" +# Gemini - Focused analysis +cd src/auth && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Understand authentication patterns +TASK: Analyze auth implementation +MODE: analysis +CONTEXT: @{**/*.ts} +EXPECTED: Pattern documentation +RULES: Focus on security best practices +" -# Focused architecture (Qwen) -cd src/auth && ~/.claude/scripts/qwen-wrapper -p "design auth architecture" +# Qwen - Architecture analysis +cd src/auth && ~/.claude/scripts/qwen-wrapper -p " +PURPOSE: Analyze auth architecture +TASK: Review auth system design and patterns +MODE: analysis +CONTEXT: @{**/*} +EXPECTED: Architecture analysis report +RULES: Focus on modularity and security +" -# Focused implementation (Codex) -codex -C src/auth --full-auto exec "analyze auth implementation" --skip-git-repo-check - -# Multi-scope (stay in root) -~/.claude/scripts/gemini-wrapper -p "CONTEXT: @{src/auth/**/*,src/api/**/*}" +# Codex - Implementation +codex -C src/auth --full-auto exec " +PURPOSE: Improve auth implementation +TASK: Review and enhance auth code +MODE: auto +CONTEXT: @{**/*.ts} +EXPECTED: Code improvements and fixes +RULES: Maintain backward compatibility +" --skip-git-repo-check -s danger-full-access ``` \ No newline at end of file diff --git a/.codex/AGENTS.md b/.codex/AGENTS.md new file mode 100644 index 00000000..0b50b3f6 --- /dev/null +++ b/.codex/AGENTS.md @@ -0,0 +1,215 @@ +# Codex Agent Execution Protocol + +## Overview + +**Role**: Codex - autonomous development, implementation, and testing + +## Prompt Structure + +**Receive prompts in this format**: + +``` +PURPOSE: [development goal] +TASK: [specific implementation task] +MODE: [auto|write] +CONTEXT: [file patterns] +EXPECTED: [deliverables] +RULES: [constraints and templates] +``` + +## Execution Requirements + +### ALWAYS + +- **Parse all six fields** - Understand PURPOSE, TASK, MODE, CONTEXT, EXPECTED, RULES +- **Follow MODE strictly** - Respect execution boundaries +- **Study CONTEXT files** - Find 3+ similar patterns before implementing +- **Apply RULES** - Follow templates and constraints exactly +- **Test continuously** - Run tests after every change +- **Commit incrementally** - Small, working commits +- **Match project style** - Follow existing patterns exactly +- **Validate EXPECTED** - Ensure all deliverables are met + +### NEVER + +- **Make assumptions** - Verify with existing code +- **Ignore existing patterns** - Study before implementing +- **Skip tests** - Tests are mandatory +- **Use clever tricks** - Choose boring, obvious solutions +- **Over-engineer** - Simple solutions over complex architectures +- **Break existing code** - Ensure backward compatibility +- **Exceed 3 attempts** - Stop and reassess if blocked 3 times + +## MODE Behavior + +### MODE: auto (default) + +**Permissions**: +- Full file operations (create/modify/delete) +- Run tests and builds +- Commit code incrementally + +**Execute**: +1. Parse PURPOSE and TASK +2. Analyze CONTEXT files - find 3+ similar patterns +3. Plan implementation approach +4. Generate code following RULES and project patterns +5. Write tests alongside code +6. Run tests continuously +7. Commit working code incrementally +8. Validate all EXPECTED deliverables +9. Report results + +**Use For**: Feature implementation, bug fixes, refactoring + +### MODE: write + +**Permissions**: +- Focused file operations +- Create/modify specific files +- Run tests for validation + +**Execute**: +1. Analyze CONTEXT files +2. Make targeted changes +3. Validate tests pass +4. Report file changes + +**Use For**: Test generation, documentation updates, targeted fixes + +## RULES Processing + +- **Parse the RULES field** to identify template content and additional constraints +- **Recognize `|` as separator** between template and additional constraints +- **ALWAYS apply all template guidelines** provided in the prompt +- **ALWAYS apply all additional constraints** specified after `|` +- **Treat all rules as mandatory** - both template and constraints must be followed +- **Failure to follow any rule** constitutes task failure + +## Error Handling + +### Three-Attempt Rule + +**On 3rd failed attempt**: +1. **Stop execution** +2. **Report status**: What was attempted, what failed, root cause +3. **Request guidance**: Ask for clarification, suggest alternatives + +### Recovery Strategies + +**Syntax/Type Errors**: +1. Review and fix errors +2. Re-run tests +3. Validate build succeeds + +**Runtime Errors**: +1. Analyze stack trace +2. Add error handling +3. Add tests for error cases + +**Test Failures**: +1. Debug in isolation +2. Review test setup +3. Fix implementation or test + +**Build Failures**: +1. Check error messages +2. Fix incrementally +3. Validate each fix + +## Progress Reporting + +### During Execution + +``` +[1/5] Analyzing existing code patterns... +[2/5] Planning implementation approach... +[3/5] Generating code... +[4/5] Writing tests... +[5/5] Running validation... +``` + +### On Success + +``` +✅ Task completed + +Changes: +- Created: [files with line counts] +- Modified: [files with changes] + +Validation: +✅ Tests: [count] passing +✅ Coverage: [percentage] +✅ Build: Success + +Next Steps: [recommendations] +``` + +### On Partial Completion + +``` +⚠️ Task partially completed + +Completed: [what worked] +Blocked: [what failed and why] +Required: [what's needed] +Recommendation: [next steps] +``` + +## Quality Standards + +### Code Quality +- Follow project's existing patterns +- Match import style and naming conventions +- Single responsibility per function/class +- DRY (Don't Repeat Yourself) +- YAGNI (You Aren't Gonna Need It) + +### Testing +- Test all public functions +- Test edge cases and error conditions +- Mock external dependencies +- Target 80%+ coverage + +### Error Handling +- Proper try-catch blocks +- Clear error messages +- Graceful degradation +- Don't expose sensitive info + +## Philosophy + +- **Incremental progress over big bangs** - Small, testable changes +- **Learning from existing code** - Study 3+ patterns before implementing +- **Pragmatic over dogmatic** - Adapt to project reality +- **Clear intent over clever code** - Boring, obvious solutions +- **Simple over complex** - Avoid over-engineering +- **Follow existing style** - Match project patterns exactly + +## Execution Checklist + +### Before Implementation +- [ ] Understand PURPOSE and TASK clearly +- [ ] Review all CONTEXT files +- [ ] Find 3+ similar patterns in codebase +- [ ] Check RULES templates and constraints +- [ ] Plan implementation approach + +### During Implementation +- [ ] Follow existing patterns exactly +- [ ] Write tests alongside code +- [ ] Run tests after every change +- [ ] Commit working code incrementally +- [ ] Handle errors properly + +### After Implementation +- [ ] Run full test suite - all pass +- [ ] Check coverage - meets target +- [ ] Run build - succeeds +- [ ] Review EXPECTED - all deliverables met + +--- + +**Version**: 2.0.0 +**Last Updated**: 2025-10-02 diff --git a/.gemini/GEMINI.md b/.gemini/GEMINI.md new file mode 100644 index 00000000..d6c8fda9 --- /dev/null +++ b/.gemini/GEMINI.md @@ -0,0 +1,143 @@ +# Gemini Execution Protocol + +## Overview + +**Role**: Gemini - code analysis and documentation generation + +## Prompt Structure + +**Receive prompts in this format**: + +``` +PURPOSE: [goal statement] +TASK: [specific task] +MODE: [analysis|write] +CONTEXT: [file patterns] +EXPECTED: [deliverables] +RULES: [constraints and templates] +``` + +## Execution Requirements + +### ALWAYS + +- **Parse all six fields** - Understand PURPOSE, TASK, MODE, CONTEXT, EXPECTED, RULES +- **Follow MODE strictly** - Respect permission boundaries +- **Analyze CONTEXT files** - Read all matching patterns thoroughly +- **Apply RULES** - Follow templates and constraints exactly +- **Provide evidence** - Quote code with file:line references +- **Match EXPECTED** - Deliver exactly what's requested + +### NEVER + +- **Assume behavior** - Verify with actual code +- **Ignore CONTEXT** - Stay within specified file patterns +- **Skip RULES** - Templates are mandatory when provided +- **Make unsubstantiated claims** - Always back with code references +- **Deviate from MODE** - Respect read/write boundaries + +## MODE Behavior + +### MODE: analysis (default) + +**Permissions**: +- Read all CONTEXT files +- Create/modify documentation files + +**Execute**: +1. Read and analyze CONTEXT files +2. Identify patterns and issues +3. Generate insights and recommendations +4. Create documentation if needed +5. Output structured analysis + +**Constraint**: Do NOT modify source code files + +### MODE: write + +**Permissions**: +- Full file operations +- Create/modify any files + +**Execute**: +1. Read CONTEXT files +2. Perform requested file operations +3. Create/modify files as specified +4. Validate changes +5. Report file changes + +## Output Format + +### Standard Analysis Structure + +```markdown +# Analysis: [TASK Title] + +## Summary +[2-3 sentence overview] + +## Key Findings +1. [Finding] - path/to/file:123 +2. [Finding] - path/to/file:456 + +## Detailed Analysis +[Evidence-based analysis with code quotes] + +## Recommendations +1. [Actionable recommendation] +2. [Actionable recommendation] +``` + +### Code References + +Always use format: `path/to/file:line_number` + +Example: "Authentication logic at `src/auth/jwt.ts:45` uses deprecated algorithm" + +## RULES Processing + +- **Parse the RULES field** to identify template content and additional constraints +- **Recognize `|` as separator** between template and additional constraints +- **ALWAYS apply all template guidelines** provided in the prompt +- **ALWAYS apply all additional constraints** specified after `|` +- **Treat all rules as mandatory** - both template and constraints must be followed +- **Failure to follow any rule** constitutes task failure + +## Error Handling + +**File Not Found**: +- Report missing files +- Continue with available files +- Note in output + +**Invalid CONTEXT Pattern**: +- Report invalid pattern +- Request correction +- Do not guess + +## Quality Standards + +### Thoroughness +- Analyze ALL files in CONTEXT +- Check cross-file patterns +- Identify edge cases +- Quantify when possible + +### Evidence-Based +- Quote relevant code +- Provide file:line references +- Link related patterns + +### Actionable +- Clear recommendations +- Prioritized by impact +- Specific, not vague + +## Philosophy + +- **Incremental over big bangs** - Suggest small, testable changes +- **Learn from existing code** - Reference project patterns +- **Pragmatic over dogmatic** - Adapt to project reality +- **Clear over clever** - Prefer obvious solutions +- **Simple over complex** - Avoid over-engineering + diff --git a/Install-Claude.ps1 b/Install-Claude.ps1 index 29f1b307..7d33e2bb 100644 --- a/Install-Claude.ps1 +++ b/Install-Claude.ps1 @@ -156,22 +156,34 @@ function Test-Prerequisites { Write-ColorOutput "Current version: $($PSVersionTable.PSVersion)" $ColorError return $false } - + # Test source files exist $sourceDir = $PSScriptRoot $claudeDir = Join-Path $sourceDir ".claude" $claudeMd = Join-Path $sourceDir "CLAUDE.md" - + $codexDir = Join-Path $sourceDir ".codex" + $geminiDir = Join-Path $sourceDir ".gemini" + if (-not (Test-Path $claudeDir)) { Write-ColorOutput "ERROR: .claude directory not found in $sourceDir" $ColorError return $false } - + if (-not (Test-Path $claudeMd)) { Write-ColorOutput "ERROR: CLAUDE.md file not found in $sourceDir" $ColorError return $false } - + + if (-not (Test-Path $codexDir)) { + Write-ColorOutput "ERROR: .codex directory not found in $sourceDir" $ColorError + return $false + } + + if (-not (Test-Path $geminiDir)) { + Write-ColorOutput "ERROR: .gemini directory not found in $sourceDir" $ColorError + return $false + } + Write-ColorOutput "Prerequisites check passed" $ColorSuccess return $true } @@ -617,6 +629,8 @@ function Install-Global { $userProfile = [Environment]::GetFolderPath("UserProfile") $globalClaudeDir = Join-Path $userProfile ".claude" $globalClaudeMd = Join-Path $globalClaudeDir "CLAUDE.md" + $globalCodexDir = Join-Path $userProfile ".codex" + $globalGeminiDir = Join-Path $userProfile ".gemini" Write-ColorOutput "Global installation path: $userProfile" $ColorInfo @@ -624,12 +638,23 @@ function Install-Global { $sourceDir = $PSScriptRoot $sourceClaudeDir = Join-Path $sourceDir ".claude" $sourceClaudeMd = Join-Path $sourceDir "CLAUDE.md" + $sourceCodexDir = Join-Path $sourceDir ".codex" + $sourceGeminiDir = Join-Path $sourceDir ".gemini" # Create backup folder if needed (default behavior unless NoBackup is specified) $backupFolder = $null if (-not $NoBackup) { - if (Test-Path $globalClaudeDir) { - $existingFiles = Get-ChildItem $globalClaudeDir -Recurse -File -ErrorAction SilentlyContinue + if ((Test-Path $globalClaudeDir) -or (Test-Path $globalCodexDir) -or (Test-Path $globalGeminiDir)) { + $existingFiles = @() + if (Test-Path $globalClaudeDir) { + $existingFiles += Get-ChildItem $globalClaudeDir -Recurse -File -ErrorAction SilentlyContinue + } + if (Test-Path $globalCodexDir) { + $existingFiles += Get-ChildItem $globalCodexDir -Recurse -File -ErrorAction SilentlyContinue + } + if (Test-Path $globalGeminiDir) { + $existingFiles += Get-ChildItem $globalGeminiDir -Recurse -File -ErrorAction SilentlyContinue + } if (($existingFiles -and ($existingFiles | Measure-Object).Count -gt 0)) { $backupFolder = Get-BackupDirectory -TargetDirectory $userProfile Write-ColorOutput "Backup folder created: $backupFolder" $ColorInfo @@ -649,6 +674,14 @@ function Install-Global { Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo $claudeMdInstalled = Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder + # Merge .codex directory contents + Write-ColorOutput "Merging .codex directory contents..." $ColorInfo + $codexMerged = Merge-DirectoryContents -Source $sourceCodexDir -Destination $globalCodexDir -Description ".codex directory contents" -BackupFolder $backupFolder + + # Merge .gemini directory contents + Write-ColorOutput "Merging .gemini directory contents..." $ColorInfo + $geminiMerged = Merge-DirectoryContents -Source $sourceGeminiDir -Destination $globalGeminiDir -Description ".gemini directory contents" -BackupFolder $backupFolder + if ($backupFolder -and (Test-Path $backupFolder)) { $backupFiles = Get-ChildItem $backupFolder -Recurse -File -ErrorAction SilentlyContinue if (-not $backupFiles -or ($backupFiles | Measure-Object).Count -eq 0) { @@ -679,14 +712,18 @@ function Install-Path { $sourceDir = $PSScriptRoot $sourceClaudeDir = Join-Path $sourceDir ".claude" $sourceClaudeMd = Join-Path $sourceDir "CLAUDE.md" + $sourceCodexDir = Join-Path $sourceDir ".codex" + $sourceGeminiDir = Join-Path $sourceDir ".gemini" - # Local paths - only for agents, commands, output-styles + # Local paths - for agents, commands, output-styles, .codex, .gemini $localClaudeDir = Join-Path $TargetDirectory ".claude" + $localCodexDir = Join-Path $TargetDirectory ".codex" + $localGeminiDir = Join-Path $TargetDirectory ".gemini" # Create backup folder if needed $backupFolder = $null if (-not $NoBackup) { - if ((Test-Path $localClaudeDir) -or (Test-Path $globalClaudeDir)) { + if ((Test-Path $localClaudeDir) -or (Test-Path $localCodexDir) -or (Test-Path $localGeminiDir) -or (Test-Path $globalClaudeDir)) { $backupFolder = Get-BackupDirectory -TargetDirectory $TargetDirectory Write-ColorOutput "Backup folder created: $backupFolder" $ColorInfo } @@ -774,6 +811,14 @@ function Install-Path { Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder + # Merge .codex directory contents to local location + Write-ColorOutput "Merging .codex directory contents to local location..." $ColorInfo + $codexMerged = Merge-DirectoryContents -Source $sourceCodexDir -Destination $localCodexDir -Description ".codex directory contents" -BackupFolder $backupFolder + + # Merge .gemini directory contents to local location + Write-ColorOutput "Merging .gemini directory contents to local location..." $ColorInfo + $geminiMerged = Merge-DirectoryContents -Source $sourceGeminiDir -Destination $localGeminiDir -Description ".gemini directory contents" -BackupFolder $backupFolder + if ($backupFolder -and (Test-Path $backupFolder)) { $backupFiles = Get-ChildItem $backupFolder -Recurse -File -ErrorAction SilentlyContinue if (-not $backupFiles -or ($backupFiles | Measure-Object).Count -eq 0) { @@ -879,10 +924,11 @@ function Show-Summary { if ($Mode -eq "Path") { Write-Host " Local Path: $Path" Write-Host " Global Path: $([Environment]::GetFolderPath('UserProfile'))" - Write-Host " Local Components: agents, commands, output-styles" + Write-Host " Local Components: agents, commands, output-styles, .codex, .gemini" Write-Host " Global Components: workflows, scripts, python_script, etc." } else { Write-Host " Path: $Path" + Write-Host " Global Components: .claude, .codex, .gemini" } if ($NoBackup) { @@ -896,10 +942,12 @@ function Show-Summary { Write-Host "" Write-ColorOutput "Next steps:" $ColorInfo Write-Host "1. Review CLAUDE.md - Customize guidelines for your project" - Write-Host "2. Configure settings - Edit .claude/settings.local.json as needed" - Write-Host "3. Start using Claude Code with Agent workflow coordination!" - Write-Host "4. Use /workflow commands for task execution" - Write-Host "5. Use /update-memory commands for memory system management" + Write-Host "2. Review .codex/Agent.md - Codex agent execution protocol" + Write-Host "3. Review .gemini/CLAUDE.md - Gemini agent execution protocol" + Write-Host "4. Configure settings - Edit .claude/settings.local.json as needed" + Write-Host "5. Start using Claude Code with Agent workflow coordination!" + Write-Host "6. Use /workflow commands for task execution" + Write-Host "7. Use /update-memory commands for memory system management" Write-Host "" Write-ColorOutput "Documentation: https://github.com/catlog22/Claude-CCW" $ColorInfo diff --git a/Install-Claude.sh b/Install-Claude.sh index 717a7baa..8c3fd84b 100644 --- a/Install-Claude.sh +++ b/Install-Claude.sh @@ -97,6 +97,8 @@ function test_prerequisites() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" local claude_dir="$script_dir/.claude" local claude_md="$script_dir/CLAUDE.md" + local codex_dir="$script_dir/.codex" + local gemini_dir="$script_dir/.gemini" if [ ! -d "$claude_dir" ]; then write_color "ERROR: .claude directory not found in $script_dir" "$COLOR_ERROR" @@ -108,6 +110,16 @@ function test_prerequisites() { return 1 fi + if [ ! -d "$codex_dir" ]; then + write_color "ERROR: .codex directory not found in $script_dir" "$COLOR_ERROR" + return 1 + fi + + if [ ! -d "$gemini_dir" ]; then + write_color "ERROR: .gemini directory not found in $script_dir" "$COLOR_ERROR" + return 1 + fi + write_color "✓ Prerequisites check passed" "$COLOR_SUCCESS" return 0 } @@ -389,6 +401,8 @@ function install_global() { local user_home="$HOME" local global_claude_dir="${user_home}/.claude" local global_claude_md="${global_claude_dir}/CLAUDE.md" + local global_codex_dir="${user_home}/.codex" + local global_gemini_dir="${user_home}/.gemini" write_color "Global installation path: $user_home" "$COLOR_INFO" @@ -396,14 +410,25 @@ function install_global() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" local source_claude_dir="${script_dir}/.claude" local source_claude_md="${script_dir}/CLAUDE.md" + local source_codex_dir="${script_dir}/.codex" + local source_gemini_dir="${script_dir}/.gemini" # Create backup folder if needed local backup_folder="" if [ "$NO_BACKUP" = false ]; then + local has_existing_files=false + if [ -d "$global_claude_dir" ] && [ "$(ls -A "$global_claude_dir" 2>/dev/null)" ]; then - backup_folder=$(get_backup_directory "$user_home") - write_color "Backup folder created: $backup_folder" "$COLOR_INFO" + has_existing_files=true + elif [ -d "$global_codex_dir" ] && [ "$(ls -A "$global_codex_dir" 2>/dev/null)" ]; then + has_existing_files=true + elif [ -d "$global_gemini_dir" ] && [ "$(ls -A "$global_gemini_dir" 2>/dev/null)" ]; then + has_existing_files=true elif [ -f "$global_claude_md" ]; then + has_existing_files=true + fi + + if [ "$has_existing_files" = true ]; then backup_folder=$(get_backup_directory "$user_home") write_color "Backup folder created: $backup_folder" "$COLOR_INFO" fi @@ -417,6 +442,14 @@ function install_global() { write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO" copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder" + # Merge .codex directory contents + write_color "Merging .codex directory contents..." "$COLOR_INFO" + merge_directory_contents "$source_codex_dir" "$global_codex_dir" ".codex directory contents" "$backup_folder" + + # Merge .gemini directory contents + write_color "Merging .gemini directory contents..." "$COLOR_INFO" + merge_directory_contents "$source_gemini_dir" "$global_gemini_dir" ".gemini directory contents" "$backup_folder" + # Remove empty backup folder if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then if [ -z "$(ls -A "$backup_folder" 2>/dev/null)" ]; then @@ -442,14 +475,18 @@ function install_path() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" local source_claude_dir="${script_dir}/.claude" local source_claude_md="${script_dir}/CLAUDE.md" + local source_codex_dir="${script_dir}/.codex" + local source_gemini_dir="${script_dir}/.gemini" # Local paths local local_claude_dir="${target_dir}/.claude" + local local_codex_dir="${target_dir}/.codex" + local local_gemini_dir="${target_dir}/.gemini" # Create backup folder if needed local backup_folder="" if [ "$NO_BACKUP" = false ]; then - if [ -d "$local_claude_dir" ] || [ -d "$global_claude_dir" ]; then + if [ -d "$local_claude_dir" ] || [ -d "$local_codex_dir" ] || [ -d "$local_gemini_dir" ] || [ -d "$global_claude_dir" ]; then backup_folder=$(get_backup_directory "$target_dir") write_color "Backup folder created: $backup_folder" "$COLOR_INFO" fi @@ -530,6 +567,14 @@ function install_path() { write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO" copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder" + # Merge .codex directory contents to local location + write_color "Merging .codex directory contents to local location..." "$COLOR_INFO" + merge_directory_contents "$source_codex_dir" "$local_codex_dir" ".codex directory contents" "$backup_folder" + + # Merge .gemini directory contents to local location + write_color "Merging .gemini directory contents to local location..." "$COLOR_INFO" + merge_directory_contents "$source_gemini_dir" "$local_gemini_dir" ".gemini directory contents" "$backup_folder" + # Remove empty backup folder if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then if [ -z "$(ls -A "$backup_folder" 2>/dev/null)" ]; then @@ -631,10 +676,11 @@ function show_summary() { if [ "$mode" = "Path" ]; then echo " Local Path: $path" echo " Global Path: $HOME" - echo " Local Components: agents, commands, output-styles" + echo " Local Components: agents, commands, output-styles, .codex, .gemini" echo " Global Components: workflows, scripts, python_script, etc." else echo " Path: $path" + echo " Global Components: .claude, .codex, .gemini" fi if [ "$NO_BACKUP" = true ]; then @@ -648,10 +694,12 @@ function show_summary() { echo "" write_color "Next steps:" "$COLOR_INFO" echo "1. Review CLAUDE.md - Customize guidelines for your project" - echo "2. Configure settings - Edit .claude/settings.local.json as needed" - echo "3. Start using Claude Code with Agent workflow coordination!" - echo "4. Use /workflow commands for task execution" - echo "5. Use /update-memory commands for memory system management" + echo "2. Review .codex/Agent.md - Codex agent execution protocol" + echo "3. Review .gemini/CLAUDE.md - Gemini agent execution protocol" + echo "4. Configure settings - Edit .claude/settings.local.json as needed" + echo "5. Start using Claude Code with Agent workflow coordination!" + echo "6. Use /workflow commands for task execution" + echo "7. Use /update-memory commands for memory system management" echo "" write_color "Documentation: https://github.com/catlog22/Claude-Code-Workflow" "$COLOR_INFO" diff --git a/README.md b/README.md index 04bf632b..dce51c0f 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,12 @@ After installation, run the following command to ensure CCW is working: /workflow:session:list ``` +> **📝 Important Notes:** +> - The installer will automatically install/update `.codex/` and `.gemini/` directories +> - **Global mode**: Installs to `~/.codex` and `~/.gemini` +> - **Path mode**: Installs to your specified directory (e.g., `project/.codex`, `project/.gemini`) +> - Existing files will be backed up automatically before installation + --- ## 🚀 Getting Started @@ -162,6 +168,22 @@ After installation, run the following command to ensure CCW is working: /workflow:execute ``` +> **💡 When to Use Which Approach?** +> +> **Use `/workflow:plan` + `/workflow:execute` for:** +> - Complex features requiring multiple modules (>3 modules) +> - Tasks with multiple subtasks (>5 subtasks) +> - Cross-cutting changes affecting architecture +> - Features requiring coordination between components +> - When you need structured planning and progress tracking +> +> **Use Claude Code directly for:** +> - Simple, focused changes (single file or module) +> - Quick bug fixes with clear solutions +> - Documentation updates +> - Code refactoring within one component +> - Straightforward feature additions + **Code Analysis:** ```bash # Deep codebase analysis diff --git a/README_CN.md b/README_CN.md index 82c2976c..ceab865d 100644 --- a/README_CN.md +++ b/README_CN.md @@ -100,6 +100,12 @@ bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflo /workflow:session:list ``` +> **📝 重要说明:** +> - 安装程序将自动安装/更新 `.codex/` 和 `.gemini/` 目录 +> - **全局模式**:安装到 `~/.codex` 和 `~/.gemini` +> - **路径模式**:安装到指定目录(例如 `project/.codex`、`project/.gemini`) +> - 安装前会自动备份现有文件 + --- ## 🚀 快速入门 @@ -165,6 +171,22 @@ bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflo /workflow:execute ``` +> **💡 何时使用哪种方式?** +> +> **使用 `/workflow:plan` + `/workflow:execute` 适用于:** +> - 需要多个模块的复杂功能(>3 个模块) +> - 包含多个子任务的任务(>5 个子任务) +> - 影响架构的横切变更 +> - 需要组件间协调的功能 +> - 需要结构化规划和进度跟踪时 +> +> **直接使用 Claude Code 适用于:** +> - 简单、聚焦的变更(单个文件或模块) +> - 解决方案明确的快速 bug 修复 +> - 文档更新 +> - 单个组件内的代码重构 +> - 简单直接的功能添加 + **代码分析:** ```bash # 深度代码库分析