feat: Add Codex CLI support as alternative analysis method in workflow system

## Major Changes
- Add --AM flag to /workflow:plan command for analysis method selection
- Support both Gemini CLI (pattern-based) and Codex CLI (autonomous) analysis
- Implement dual marker system: [GEMINI_CLI_REQUIRED] and [CODEX_CLI_REQUIRED]
- Update all 4 agents to handle both analysis markers
- Create analysis method templates for standardized CLI usage

## Files Modified
- workflow-architecture.md: Add Analysis Method Integration section
- plan.md: Add --AM flag and bilingual rule standardization
- execute.md: Update marker mapping logic and standardize to English
- 4 agent files: Add dual CLI support with usage guidelines
- New: analysis-methods/ templates for Gemini and Codex CLI

## Backward Compatibility
- Gemini CLI remains default analysis method
- Existing workflows continue to work unchanged
- Progressive enhancement for autonomous development scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-09-12 23:40:12 +08:00
parent 2038d83398
commit 685c0f7f79
7 changed files with 215 additions and 56 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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