diff --git a/.claude/agents/action-planning-agent.md b/.claude/agents/action-planning-agent.md index 9c73b347..bcfe64f9 100644 --- a/.claude/agents/action-planning-agent.md +++ b/.claude/agents/action-planning-agent.md @@ -31,7 +31,9 @@ You are a pure execution agent specialized in creating actionable implementation ``` 1. Parse input requirements and extract control flags 2. IF DEEP_ANALYSIS_REQUIRED flag present: - → Execute comprehensive Gemini CLI analysis + → Check for analysis method markers: + - [GEMINI_CLI_REQUIRED] → Execute comprehensive Gemini CLI analysis + - [CODEX_CLI_REQUIRED] → Execute autonomous Codex CLI analysis → Use analysis results for planning context 3. Assess task complexity (simple/medium/complex) 4. Create staged implementation plan @@ -39,11 +41,15 @@ You are a pure execution agent specialized in creating actionable implementation 6. Update workflow structure ``` -**Gemini CLI Usage Standards**: -Follow unified Gemini CLI guidelines: `@~/.claude/workflows/gemini-unified.md` +**Analysis CLI Usage Standards**: +- **Gemini CLI**: Follow unified guidelines: `@~/.claude/workflows/gemini-unified.md` +- **Codex CLI**: Follow unified guidelines: `@~/.claude/workflows/codex-unified.md` ### Deep Analysis Execution **When DEEP_ANALYSIS_REQUIRED flag is present:** + +#### Gemini CLI Analysis (Pattern-Based) +**When [GEMINI_CLI_REQUIRED] marker present:** 1. Execute comprehensive Gemini CLI analysis across 4 dimensions: - Architecture patterns and component relationships - Implementation conventions and coding standards @@ -52,6 +58,16 @@ Follow unified Gemini CLI guidelines: `@~/.claude/workflows/gemini-unified.md` 2. Consolidate analysis results for planning context 3. Use analysis to inform implementation stages and task breakdown +#### Codex CLI Analysis (Autonomous Development) +**When [CODEX_CLI_REQUIRED] marker present:** +1. Execute autonomous Codex CLI analysis: + - Intelligent file discovery and code pattern recognition + - Autonomous implementation strategy development + - System-wide impact assessment and integration planning + - Automated testing and validation approach recommendations +2. Integrate autonomous analysis results into planning framework +3. Use Codex insights to create self-guided implementation stages + ## Core Functions ### 1. Stage Design diff --git a/.claude/agents/code-developer.md b/.claude/agents/code-developer.md index dcc7b49c..3080d67a 100644 --- a/.claude/agents/code-developer.md +++ b/.claude/agents/code-developer.md @@ -37,20 +37,27 @@ You are a code execution specialist focused on implementing high-quality, produc ``` IF context sufficient for implementation: → Proceed with execution -ELIF context insufficient OR task has [GEMINI_CLI_REQUIRED] marker: - → Execute Gemini CLI for codebase analysis (MANDATORY) +ELIF context insufficient OR task has analysis marker: + → Check marker type: + - [GEMINI_CLI_REQUIRED] → Execute Gemini CLI for codebase analysis (MANDATORY) + - [CODEX_CLI_REQUIRED] → Execute Codex CLI for autonomous context gathering (MANDATORY) → Extract patterns and conventions → Proceed with execution ``` -**Gemini CLI Marker System**: -- **[GEMINI_CLI_REQUIRED]**: Mandatory analysis flag - - **Trigger**: Auto-added when task.analysis_source = "gemini" or scope > 3 files +**Analysis CLI Marker System**: +- **[GEMINI_CLI_REQUIRED]**: Mandatory Gemini analysis flag + - **Trigger**: Auto-added when task.analysis_source = "gemini" or scope > 3 files (default) - **Action**: MUST run Gemini CLI first to gather context - - **Purpose**: Ensures code aligns with existing patterns + - **Purpose**: Ensures code aligns with existing patterns through pattern-based analysis +- **[CODEX_CLI_REQUIRED]**: Mandatory Codex analysis flag + - **Trigger**: Auto-added when task.analysis_source = "codex" + - **Action**: MUST run Codex CLI in autonomous mode first to gather context + - **Purpose**: Enables autonomous development with intelligent file discovery and code generation -**Gemini CLI Usage Standards**: -Follow unified Gemini CLI guidelines: @~/.claude/workflows/gemini-unified.md +**Analysis CLI Usage Standards**: +- **Gemini CLI**: Follow unified guidelines: @~/.claude/workflows/gemini-unified.md +- **Codex CLI**: Follow unified guidelines: @~/.claude/workflows/codex-unified.md **Test-Driven Development**: - Write tests first (red → green → refactor) diff --git a/.claude/agents/code-review-test-agent.md b/.claude/agents/code-review-test-agent.md index d52b0e14..f993819e 100644 --- a/.claude/agents/code-review-test-agent.md +++ b/.claude/agents/code-review-test-agent.md @@ -47,27 +47,31 @@ You will review code changes AND handle test implementation by understanding the 9. **Regression Testing**: Create tests that prevent future regressions 10. **Test Strategy**: Recommend appropriate testing strategies (unit, integration, e2e) based on code changes -## Gemini CLI Context Activation Rules +## Analysis CLI Context Activation Rules -**🎯 GEMINI_CLI_REQUIRED Flag Detection** -When task assignment includes `[GEMINI_CLI_REQUIRED]` flag: -1. **MANDATORY**: Execute Gemini CLI context gathering as first step -2. **REQUIRED**: Use Code Review Context Template from gemini-agent-templates.md -3. **PROCEED**: Only after understanding changes and repository standards +**🎯 Analysis Marker Detection** +When task assignment includes analysis markers: +- **[GEMINI_CLI_REQUIRED]**: Execute Gemini CLI context gathering as first step +- **[CODEX_CLI_REQUIRED]**: Execute Codex CLI autonomous analysis as first step **Context Gathering Decision Logic**: ``` IF task contains [GEMINI_CLI_REQUIRED] flag: → Execute Gemini CLI context gathering (MANDATORY) + → Use pattern-based code review analysis +ELIF task contains [CODEX_CLI_REQUIRED] flag: + → Execute Codex CLI autonomous analysis (MANDATORY) + → Use autonomous development context for review ELIF reviewing >3 files OR security changes OR architecture modifications: - → Execute Gemini CLI context gathering (AUTO-TRIGGER) + → Execute Gemini CLI context gathering (AUTO-TRIGGER, default) ELSE: → Proceed with review using standard quality checks ``` ## Context Gathering Phase (Execute When Required) -When GEMINI_CLI_REQUIRED flag is present or complexity triggers apply, gather precise, change-focused context: +### Gemini CLI Context Gathering +When [GEMINI_CLI_REQUIRED] flag is present or complexity triggers apply, gather precise, change-focused context: Use the targeted review context template: @~/.claude/workflows/gemini-unified.md @@ -79,6 +83,19 @@ This executes a change-specific Gemini CLI command that identifies: - **Test coverage validation**: Whether changes are properly tested - **Integration verification**: If necessary integration points are handled +### Codex CLI Context Gathering +When [CODEX_CLI_REQUIRED] flag is present, execute autonomous analysis: + +Use the autonomous development context template: +@~/.claude/workflows/codex-unified.md + +This executes autonomous Codex CLI analysis that provides: +- **Autonomous understanding**: Intelligent discovery of implementation context +- **Code generation insights**: Autonomous development recommendations +- **System-wide impact**: Comprehensive integration analysis +- **Automated testing strategy**: Autonomous test implementation approach +- **Quality assurance**: Self-guided validation and optimization recommendations + **Context Application for Review**: - Review changes against repository-specific standards for similar code - Compare implementation approach with established patterns for this type of feature diff --git a/.claude/agents/conceptual-planning-agent.md b/.claude/agents/conceptual-planning-agent.md index d3593894..e350a69b 100644 --- a/.claude/agents/conceptual-planning-agent.md +++ b/.claude/agents/conceptual-planning-agent.md @@ -34,31 +34,41 @@ You are a conceptual planning specialist focused on single-role strategic thinki 4. **Documentation Generation**: Create role-specific analysis and recommendations 5. **Requirements Analysis**: Generate structured requirements from the assigned role's perspective -## Gemini Analysis Integration +## Analysis Method Integration ### Detection and Activation -When receiving task prompt, check for GEMINI_ANALYSIS_REQUIRED flag: -- **If GEMINI_ANALYSIS_REQUIRED: true** - Execute mandatory Gemini CLI analysis +When receiving task prompt, check for analysis markers: +- **[GEMINI_CLI_REQUIRED]** - Execute mandatory Gemini CLI pattern-based analysis +- **[CODEX_CLI_REQUIRED]** - Execute mandatory Codex CLI autonomous analysis - **ASSIGNED_ROLE** - Extract the specific role for focused analysis - **ANALYSIS_DIMENSIONS** - Load role-specific analysis dimensions ### Execution Logic ```python -def handle_gemini_analysis(prompt): - if "GEMINI_ANALYSIS_REQUIRED: true" in prompt: - role = extract_value("ASSIGNED_ROLE", prompt) - dimensions = extract_value("ANALYSIS_DIMENSIONS", prompt) - +def handle_analysis_markers(prompt): + role = extract_value("ASSIGNED_ROLE", prompt) + dimensions = extract_value("ANALYSIS_DIMENSIONS", prompt) + topic = extract_topic(prompt) + + if "[GEMINI_CLI_REQUIRED]" in prompt: for dimension in dimensions: result = execute_gemini_cli( dimension=dimension, role_context=role, - topic=extract_topic(prompt) + topic=topic ) integrate_to_role_output(result, role) + + elif "[CODEX_CLI_REQUIRED]" in prompt: + result = execute_codex_cli( + autonomous_analysis=True, + role_context=role, + topic=topic + ) + integrate_autonomous_insights(result, role) ``` -### Role-Specific Gemini Dimensions +### Role-Specific Analysis Dimensions | Role | Primary Dimensions | Focus Areas | |------|-------------------|--------------| @@ -73,12 +83,19 @@ def handle_gemini_analysis(prompt): | feature-planner | implementation_complexity, dependency_mapping, risk_assessment | Development planning | ### Output Integration -Gemini analysis results are integrated into the single role's output: -- Enhanced `analysis.md` with codebase insights -- Role-specific technical recommendations -- Pattern-based best practices from actual code + +**Gemini Analysis Integration**: Pattern-based analysis results are integrated into the single role's output: +- Enhanced `analysis.md` with codebase insights and architectural patterns +- Role-specific technical recommendations based on existing conventions +- Pattern-based best practices from actual code examination - Realistic feasibility assessments based on current implementation +**Codex Analysis Integration**: Autonomous analysis results provide comprehensive insights: +- Enhanced `analysis.md` with autonomous development recommendations +- Role-specific strategy based on intelligent system understanding +- Autonomous development approaches and implementation guidance +- Self-guided optimization and integration recommendations + ## Task Reception Protocol ### Task Reception diff --git a/.claude/commands/workflow/execute.md b/.claude/commands/workflow/execute.md index f0980dac..4ffdb85d 100644 --- a/.claude/commands/workflow/execute.md +++ b/.claude/commands/workflow/execute.md @@ -23,15 +23,19 @@ The intelligent execution approach focuses on: - **Dynamic task orchestration** - Coordinate based on discovered task relationships - **Progress tracking** - Update task status after agent completion -**GEMINI_CLI_REQUIRED Marker**: -- **Purpose**: Forces agent to analyze existing codebase before implementation -- **Auto-trigger**: When task.analysis_source = "gemini" OR scope > 3 files -- **Agent Action**: MUST execute Gemini CLI as first step +**Analysis Markers**: +- **[GEMINI_CLI_REQUIRED]**: Forces agent to use Gemini CLI for pattern-based codebase analysis + - **Auto-trigger**: When task.analysis_source = "gemini" OR scope > 3 files (default) + - **Agent Action**: MUST execute Gemini CLI as first step +- **[CODEX_CLI_REQUIRED]**: Forces agent to use Codex CLI for autonomous development analysis + - **Auto-trigger**: When task.analysis_source = "codex" + - **Agent Action**: MUST execute Codex CLI in autonomous mode as first step -**analysis_source 到标记的映射**: -- **"gemini"** → 添加 [GEMINI_CLI_REQUIRED] -- **"auto-detected"** + scope > 3 files → 添加 [GEMINI_CLI_REQUIRED] -- **"manual"** → 不添加标记 +**analysis_source to Marker Mapping**: +- **"gemini"** → Add [GEMINI_CLI_REQUIRED] +- **"codex"** → Add [CODEX_CLI_REQUIRED] +- **"auto-detected"** + scope > 3 files → Add [GEMINI_CLI_REQUIRED] (default) +- **"manual"** → No marker added ## Execution Flow @@ -62,11 +66,13 @@ Workflow Discovery: ## Execution Plan - [ ] **TASK-001**: [Agent: planning-agent] [GEMINI_CLI_REQUIRED] Design auth schema (impl-1.1) -- [ ] **TASK-002**: [Agent: code-developer] [GEMINI_CLI_REQUIRED] Implement auth logic (impl-1.2) +- [ ] **TASK-002**: [Agent: code-developer] [CODEX_CLI_REQUIRED] Implement auth logic (impl-1.2) - [ ] **TASK-003**: [Agent: code-review-agent] Review implementations - [ ] **TASK-004**: Update task statuses and session state -**Marker Legend**: [GEMINI_CLI_REQUIRED] = Agent must analyze codebase context first +**Marker Legend**: +- [GEMINI_CLI_REQUIRED] = Agent must use Gemini CLI for pattern analysis +- [CODEX_CLI_REQUIRED] = Agent must use Codex CLI for autonomous analysis ``` ### 3. Agent Context Assignment diff --git a/.claude/commands/workflow/plan.md b/.claude/commands/workflow/plan.md index 5711748a..85fc4572 100644 --- a/.claude/commands/workflow/plan.md +++ b/.claude/commands/workflow/plan.md @@ -20,7 +20,19 @@ Creates actionable implementation plans with intelligent input source detection. ## Usage ```bash -/workflow/plan +/workflow:plan [--AM gemini|codex] +``` + +### Analysis Method Flag (--AM) +Optional flag to specify which CLI tool to use for context analysis: +- **gemini** (default): Uses Gemini CLI for pattern-based analysis and architectural understanding +- **codex**: Uses Codex CLI for autonomous development context gathering with intelligent file discovery + +**Examples**: +```bash +/workflow:plan --AM codex "Build authentication system" +/workflow:plan --AM gemini requirements.md +/workflow:plan ISS-001 # Uses default (gemini) ``` ## Input Detection Logic @@ -83,30 +95,42 @@ The command automatically detects input type: ### Implementation Field Requirements ⚠️ **CRITICAL**: All generated tasks must include detailed implementation guidance -**analysis_source 赋值规则**: -- **"manual"**: 用户提供完整实现细节(包含具体文件、代码片段) -- **"gemini"**: 信息不足,需要 Gemini 分析(缺少文件路径或代码上下文) -- **"auto-detected"**: 系统自动推断实现细节(基于模式识别) +**analysis_source Assignment Rules**: +- **"manual"**: User provides complete implementation details (including specific files and code snippets) +- **"gemini"**: Insufficient information, requires Gemini analysis (missing file paths or code context) +- **"codex"**: Insufficient information, requires Codex autonomous development analysis (complex refactoring or intelligent file discovery) +- **"auto-detected"**: System automatically infers implementation details (based on pattern recognition) -**判断流程**: -1. **IF** 用户提供文件路径 + 代码片段 → "manual" -2. **ELIF** 系统能推断实现位置 → "auto-detected" -3. **ELSE** → "gemini" (需要深度分析) +**Decision Flow**: +1. **IF** user provides file paths + code snippets → "manual" +2. **ELIF** system can infer implementation location → "auto-detected" +3. **ELIF** --AM codex specified → "codex" (requires autonomous development analysis) +4. **ELSE** → "gemini" (requires deep analysis, default method) **Auto-fill Strategy**: 1. **Sufficient Information**: Auto-fill implementation field based on user input and project context -2. **Insufficient Information**: Mark analysis_source as "gemini" and prompt: +2. **Insufficient Information**: Mark analysis_source appropriately and prompt: + + **For Gemini Analysis (default)**: ``` ⚠️ Implementation details incomplete, recommend using gemini analysis: gemini --all-files -p "@{relevant-file-patterns} @{CLAUDE.md} Analyze task: [task description] Extract: 1) File locations and code snippets 2) Modification logic and data flow 3) Risks and dependencies" ``` + + **For Codex Analysis (when --AM codex specified)**: + ``` + ⚠️ Implementation details incomplete, recommend using codex analysis: + codex --full-auto exec "Analyze and implement: [task description] + Context: Autonomous analysis and implementation guidance needed + Extract: 1) Intelligent file discovery 2) Implementation strategy 3) Autonomous development approach" + ``` **Required Implementation Sub-fields**: - **files**: Must contain at least 1 file with detailed info (path, location, original_code, modifications) - **context_notes**: Dependencies, risks, performance considerations -- **analysis_source**: manual|gemini|auto-detected +- **analysis_source**: manual|gemini|codex|auto-detected **Quality Standards**: - logic_flow must use specified symbols (───►, ◊───, ◄───) diff --git a/.claude/workflows/workflow-architecture.md b/.claude/workflows/workflow-architecture.md index 52fded5f..ec46f671 100644 --- a/.claude/workflows/workflow-architecture.md +++ b/.claude/workflows/workflow-architecture.md @@ -142,7 +142,7 @@ All task files use this 9-field schema: "performance_considerations": "JWT validation will add approximately 5ms latency", "error_handling": "Ensure sensitive information is not leaked in error responses" }, - "analysis_source": "manual|gemini|auto-detected" + "analysis_source": "manual|gemini|codex|auto-detected" } } ``` @@ -172,6 +172,7 @@ The **implementation** field provides detailed code implementation guidance with #### analysis_source - Information Source Identifier - **manual**: Detailed information manually provided by user - **gemini**: Automatically obtained through Gemini CLI analysis +- **codex**: Automatically obtained through Codex CLI analysis - **auto-detected**: Auto-detected based on task type and context ### Hierarchical Task System @@ -388,6 +389,35 @@ Agents receive complete task JSON plus workflow context: } ``` +## Analysis Method Integration + +### Supported Analysis Tools + +The workflow system supports multiple analysis methods for context gathering and code analysis: + +#### Analysis Method Selection +- **Gemini CLI**: Pattern-based codebase analysis and architectural understanding (default) +- **Codex CLI**: Autonomous development context gathering with intelligent file discovery + +#### Selection Criteria +- **Use Gemini when**: + - Need comprehensive pattern analysis and architectural understanding + - Analyzing existing code conventions and relationships + - Understanding complex module dependencies +- **Use Codex when**: + - Need autonomous file discovery and context gathering + - Working with complex refactoring scenarios + - Requiring intelligent code generation and autonomous development + +#### Analysis Method Mapping +```markdown +analysis_source → CLI Tool → Agent Marker +"gemini" → Gemini CLI → [GEMINI_CLI_REQUIRED] +"codex" → Codex CLI → [CODEX_CLI_REQUIRED] +"manual" → N/A → No marker +"auto-detected" → Context-based → [GEMINI_CLI_REQUIRED] (default) +``` + ## Gemini Analysis Integration ### Implementation Field Population Strategy @@ -434,6 +464,48 @@ Target Files: [scope patterns or 'auto-detect'] - **Task Refinement**: `/task:replan` for updating incomplete implementation details - **Manual Trigger**: Direct gemini analysis when implementation details are missing +## Codex Analysis Integration + +### Autonomous Context Gathering Strategy + +When task creation specifies Codex analysis, the system integrates with Codex CLI for autonomous development context gathering: + +#### Trigger Conditions +- **analysis_source**: Marked as "codex" during task creation +- **Complex Refactoring**: Tasks involving system-wide changes or architectural modifications +- **Autonomous Development**: When intelligent file discovery and code generation is preferred + +#### Codex Analysis Command Template +```bash +codex --full-auto exec "$(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) + +## Task-Specific Analysis: +Task: [task title and description] +Context: Autonomous analysis and implementation context gathering + +## Required Extraction: +1. **Intelligent File Discovery**: Auto-discover relevant files and code patterns +2. **Context Gathering**: Understand existing code architecture and dependencies +3. **Implementation Strategy**: Propose autonomous implementation approach +4. **Risk Assessment**: Identify potential issues and mitigation strategies + +## Autonomous Execution: +- Let Codex handle file discovery and pattern analysis +- Generate context-aware implementation guidance +- Provide autonomous development recommendations" +``` + +#### Analysis Result Processing +1. **Parse Codex Output**: Extract autonomous analysis and implementation recommendations +2. **Context Integration**: Incorporate Codex insights into task implementation field +3. **Autonomous Guidance**: Update task JSON with Codex-generated context and strategy +4. **Quality Validation**: Ensure autonomous recommendations meet project standards + +#### Integration Points +- **Task Creation**: `/workflow:plan --AM codex` command +- **Autonomous Development**: Tasks requiring intelligent code generation +- **Complex Refactoring**: System-wide changes with autonomous discovery needs + ### Implementation Field Validation **Required Quality Standards**: @@ -476,7 +548,7 @@ generate_todo_list_from_json .task/ 5. **Status Consistency**: Status values from defined enumeration 6. **Required Fields**: All 9 core fields must be present 7. **Implementation Structure**: implementation.files array must contain valid file paths -8. **Analysis Source**: analysis_source must be one of: manual|gemini|auto-detected +8. **Analysis Source**: analysis_source must be one of: manual|gemini|codex|auto-detected ### Session Consistency Checks ```bash