refactor(lite-plan): enhance execution call tracking and user interaction clarity

This commit is contained in:
catlog22
2025-11-16 21:52:09 +08:00
parent fa6257ecae
commit 81362c14de

View File

@@ -23,8 +23,8 @@ Intelligent lightweight planning and execution command with dynamic workflow ada
- Complex tasks: Delegates to cli-planning-agent for detailed breakdown - Complex tasks: Delegates to cli-planning-agent for detailed breakdown
- **Three-Dimensional Confirmation**: Multi-select interaction for task approval + execution method selection + code review tool selection - **Three-Dimensional Confirmation**: Multi-select interaction for task approval + execution method selection + code review tool selection
- **Direct Execution**: Immediate dispatch to selected execution method (agent/codex/auto) - **Direct Execution**: Immediate dispatch to selected execution method (agent/codex/auto)
- **Live Progress Tracking**: Real-time TodoWrite updates during execution - **Live Progress Tracking**: Real-time TodoWrite updates at execution call level ([Agent-1], [Codex-1], etc.) during execution
- **Optional Code Review**: Post-execution quality analysis with claude/gemini/qwen/codex (user selectable) - **Optional Code Review**: Post-execution quality analysis with gemini/agent or custom tools via "Other" option (e.g., qwen, codex)
## Usage ## Usage
@@ -73,19 +73,19 @@ User Input ("/workflow:lite-plan \"task\"")
v v
[Phase 4] Task Confirmation & Execution Selection (User interaction) [Phase 4] Task Confirmation & Execution Selection (User interaction)
-> Display task breakdown and approach -> Display task breakdown and approach
-> AskUserQuestion: Three dimensions (all multi-select) -> AskUserQuestion: Three dimensions
1. Confirm task: Allow/Modify/Cancel (can supplement via Other) 1. Confirm task: Allow/Modify/Cancel (multi-select, can supplement via Other)
2. Execution method: Agent/Codex/Auto (auto: simple→agent, complex→codex) 2. Execution method: Agent/Codex/Auto (single-select, auto: simple→agent, complex→codex)
3. Code review: No/Claude/Gemini/Qwen/Codex 3. Code review: Skip/Gemini/Agent/Other (single-select, can specify custom tool via Other)
-> Process selections and proceed to Phase 5 -> Process selections and proceed to Phase 5
-> If cancel: Exit -> If cancel: Exit
| |
v v
[Phase 5] Execution & Progress Tracking [Phase 5] Execution & Progress Tracking
-> Create TodoWrite task list from breakdown -> Create TodoWrite execution call list (grouped tasks)
-> Launch selected execution (agent or CLI) -> Launch selected execution (agent or CLI)
-> Track progress with TodoWrite updates -> Track execution call progress with TodoWrite updates
-> Real-time status displayed to user -> Real-time call status displayed to user (e.g., "[Agent-1] (Task A + Task B)")
-> If code review enabled: Run selected CLI analysis -> If code review enabled: Run selected CLI analysis
| |
v v
@@ -94,9 +94,10 @@ Execution Complete
### Task Management Pattern ### Task Management Pattern
- TodoWrite creates task list before execution starts (Phase 5) - TodoWrite creates execution call list before execution starts (Phase 5)
- Tasks marked as in_progress/completed during execution - Execution calls ([Agent-1], [Codex-1], etc.) marked as in_progress/completed during execution
- Real-time progress updates visible to user - Each execution call handles multiple related tasks
- Real-time progress updates visible at call level (not individual task level)
- No intermediate file artifacts generated - No intermediate file artifacts generated
## Detailed Phase Execution ## Detailed Phase Execution
@@ -335,19 +336,22 @@ planObject = {
**Operations**: **Operations**:
- Display plan summary with full task breakdown - Display plan summary with full task breakdown
- Collect three multi-select inputs: - Collect three inputs:
1. Task confirmation (Allow/Modify/Cancel + optional supplements) 1. Task confirmation (multi-select: Allow/Modify/Cancel + optional supplements via "Other")
2. Execution method (Agent/Codex/Auto) 2. Execution method (single-select: Agent/Codex/Auto)
- Agent: Execute with @code-developer - Agent: Execute with @code-developer
- Codex: Execute with codex CLI tool - Codex: Execute with codex CLI tool
- Auto: Simple tasks (Low complexity) → Agent, Complex tasks (Medium/High) → Codex - Auto: Simple tasks (Low complexity) → Agent, Complex tasks (Medium/High) → Codex
3. Code review tool (No/Claude/Gemini/Qwen/Codex) 3. Code review tool (single-select: Skip/Gemini/Agent + custom tools via "Other")
- Support plan supplements and modifications via "Other" input - Gemini Review: Use gemini CLI for code analysis
- Agent Review: Use @code-reviewer agent
- Other: Specify custom tool (e.g., "qwen", "codex") via text input
- Support plan supplements and custom tool specification via "Other" input
**Combined Three Questions in Single Call**: **Combined Three Questions in Single Call**:
- Question 1: Display full plan + task confirmation (multi-select: Allow/Modify/Cancel) - Question 1: Display full plan + task confirmation (multi-select: Allow/Modify/Cancel)
- Question 2: Execution method selection (single-select: Agent/Codex/Auto) - Question 2: Execution method selection (single-select: Agent/Codex/Auto)
- Question 3: Code review tool selection (single-select: Gemini/Qwen/Agent/Skip) - Question 3: Code review tool selection (single-select: Skip/Gemini/Agent, custom via "Other")
**Combined AskUserQuestion (Single Call)**: **Combined AskUserQuestion (Single Call)**:
```javascript ```javascript
@@ -392,12 +396,13 @@ Confirm this plan? (Multi-select enabled - you can select multiple options and a
] ]
}, },
{ {
question: `Enable code review after execution?`, question: `Enable code review after execution?
(You can specify other tools like "qwen" or "codex" via "Other" option)`,
header: "Code Review", header: "Code Review",
multiSelect: false, multiSelect: false,
options: [ options: [
{ label: "Gemini Review", description: "Review with Gemini CLI tool (gemini-2.5-pro)" }, { label: "Gemini Review", description: "Review with Gemini CLI tool (gemini-2.5-pro)" },
{ label: "Qwen Review", description: "Review with Qwen CLI tool (coder-model)" },
{ label: "Agent Review", description: "Review with @code-reviewer agent" }, { label: "Agent Review", description: "Review with @code-reviewer agent" },
{ label: "Skip", description: "No review needed" } { label: "Skip", description: "No review needed" }
] ]
@@ -421,11 +426,10 @@ Execution Method Selection (Single-select):
└─ If complexity = Medium/High → Execute with codex CLI tool └─ If complexity = Medium/High → Execute with codex CLI tool
Code Review Selection (after execution): Code Review Selection (after execution):
├─ No → Skip review, workflow complete ├─ Skip → Skip review, workflow complete
├─ Claude (default) → Current Claude agent review ├─ Gemini Review → Run gemini code analysis (gemini-2.5-pro)
├─ Gemini → Run gemini code analysis ├─ Agent Review → Current Claude agent review
Qwen → Run qwen code analysis Other → Specify custom tool (e.g., "qwen", "codex") via text input
└─ Codex → Run codex code analysis
``` ```
**Progress Tracking**: **Progress Tracking**:
@@ -439,33 +443,40 @@ Code Review Selection (after execution):
### Phase 5: Execution & Progress Tracking ### Phase 5: Execution & Progress Tracking
**Operations**: **Operations**:
- Create TodoWrite task list from plan breakdown - Create TodoWrite execution call list (grouped tasks by dependencies)
- Launch selected execution method (agent or CLI) - Launch selected execution method (agent or CLI)
- Track execution progress with real-time TodoWrite updates - Track execution call progress with real-time TodoWrite updates (not individual tasks)
- Display status to user - Display execution status to user
**Step 5.1: Create TodoWrite Task List** **Step 5.1: Create TodoWrite Execution List**
**Before execution starts**, create task list: **Before execution starts**, create execution call list (not individual tasks):
```javascript ```javascript
// Group tasks based on dependencies and execution strategy
// Each execution call handles multiple related tasks
executionCalls = groupTasksByExecution(planObject.tasks, planObject.dependencies)
TodoWrite({ TodoWrite({
todos: planObject.tasks.map((task, index) => ({ todos: executionCalls.map((call, index) => ({
content: task, content: `[${call.method}-${index+1}] (${call.taskSummary})`,
status: "pending", status: "pending",
activeForm: task.replace(/^(.*?):/, "$1ing:") // "Implement X" -> "Implementing X" activeForm: `Executing [${call.method}-${index+1}] (${call.taskSummary})`
})) }))
}) })
``` ```
**Example Task List**: **Example Execution List**:
``` ```
[ ] Implement authentication service in src/auth/service.ts [ ] [Agent-1] (Implement auth service + Create JWT utilities)
[ ] Create JWT token utilities in src/auth/jwt.ts [ ] [Agent-2] (Add middleware + Update routes)
[ ] Add authentication middleware to src/middleware/auth.ts [ ] [Codex-1] (Add integration tests for auth flow)
[ ] Update API routes to use authentication
[ ] Add integration tests for auth flow
``` ```
**Task Grouping Logic**:
- Parallel tasks → Single execution call
- Sequential tasks → Separate execution calls
- Complex tasks → May split into multiple calls based on file scope
**Step 5.2: Launch Execution** **Step 5.2: Launch Execution**
**IMPORTANT**: CLI execution MUST run in foreground (no background execution) **IMPORTANT**: CLI execution MUST run in foreground (no background execution)
@@ -510,18 +521,19 @@ Based on user selection in Phase 4, execute appropriate method:
IMPORTANT Instructions: IMPORTANT Instructions:
- **Parallel Execution**: Identify independent tasks from dependencies field and execute them in parallel using multiple tool calls in a single message - **Parallel Execution**: Identify independent tasks from dependencies field and execute them in parallel using multiple tool calls in a single message
- **Dependency Respect**: Sequential tasks must wait for dependent tasks to complete before starting - **Dependency Respect**: Sequential tasks must wait for dependent tasks to complete before starting
- **TodoWrite Updates**: Mark tasks as in_progress when starting, completed when finished
- **Intelligent Grouping**: Analyze task dependencies to determine parallel groups - tasks with no file conflicts or logical dependencies can run simultaneously - **Intelligent Grouping**: Analyze task dependencies to determine parallel groups - tasks with no file conflicts or logical dependencies can run simultaneously
- Test functionality as you go - Test functionality as you go
- Handle risks proactively - Handle risks proactively
Note: This agent call handles multiple tasks. TodoWrite tracking is managed at call level by orchestrator.
` `
) )
``` ```
**Agent Responsibilities**: **Agent Responsibilities**:
- Mark tasks as in_progress when starting - Each agent call handles multiple tasks (grouped by dependencies)
- Mark tasks as completed when finished - Agent updates TodoWrite at **call level** (not individual task level)
- Update TodoWrite in real-time for user visibility - Mark execution call as in_progress when starting, completed when all assigned tasks finished
#### Option B: CLI Execution (Codex) #### Option B: CLI Execution (Codex)
@@ -570,75 +582,76 @@ Complexity: ${planObject.complexity}
**Execution with Progress Tracking**: **Execution with Progress Tracking**:
```javascript ```javascript
// Launch CLI in foreground (NOT background - avoid ) // Launch CLI in foreground (NOT background)
bash_result = Bash( bash_result = Bash(
command=cli_command, command=cli_command,
timeout=600000 // 10 minutes timeout=600000 // 10 minutes
) )
// Monitor output and update TodoWrite // Update TodoWrite when CLI execution call completes
// Parse CLI output for task completion indicators // Mark execution call (e.g., "[Codex-1]") as completed when CLI finishes
// Update TodoWrite when tasks complete // One CLI call may handle multiple tasks - track at call level, not task level
// Example: When CLI outputs "✓ Task 1 complete" -> Mark task 1 as completed
``` ```
**CLI Progress Monitoring**: **CLI Progress Monitoring**:
- Parse CLI output for completion keywords ("done", "complete", "✓", etc.) - Monitor CLI execution at **call level** (not individual task level)
- Update corresponding TodoWrite tasks based on progress - Update TodoWrite when CLI execution call completes (all assigned tasks done)
- Provide real-time visibility to user - Provide real-time visibility of execution call progress to user
**Step 5.3: Track Execution Progress** **Step 5.3: Track Execution Progress**
Track **agent/CLI call level** (not individual tasks):
**Real-time TodoWrite Updates**: **Real-time TodoWrite Updates**:
```javascript ```javascript
// As execution progresses, update task status: // When execution call starts
// Task started
TodoWrite({ TodoWrite({
todos: [ todos: [
{ content: "Implement auth service", status: "in_progress", activeForm: "Implementing auth service" }, { content: "[Agent-1] (Implement auth service + Create JWT utilities)", status: "in_progress", activeForm: "Executing [Agent-1] (Implement auth service + Create JWT utilities)" },
{ content: "Create JWT utilities", status: "pending", activeForm: "Creating JWT utilities" }, { content: "[Agent-2] (Add middleware + Update routes)", status: "pending", activeForm: "Executing [Agent-2] (Add middleware + Update routes)" },
// ... { content: "[Codex-1] (Add integration tests)", status: "pending", activeForm: "Executing [Codex-1] (Add integration tests)" }
] ]
}) })
// Task completed // When execution call completes
TodoWrite({ TodoWrite({
todos: [ todos: [
{ content: "Implement auth service", status: "completed", activeForm: "Implementing auth service" }, { content: "[Agent-1] (Implement auth service + Create JWT utilities)", status: "completed", activeForm: "Executing [Agent-1] (Implement auth service + Create JWT utilities)" },
{ content: "Create JWT utilities", status: "in_progress", activeForm: "Creating JWT utilities" }, { content: "[Agent-2] (Add middleware + Update routes)", status: "in_progress", activeForm: "Executing [Agent-2] (Add middleware + Update routes)" },
// ... { content: "[Codex-1] (Add integration tests)", status: "pending", activeForm: "Executing [Codex-1] (Add integration tests)" }
] ]
}) })
``` ```
**User Visibility**: **User Visibility**:
- User sees real-time task progress - User sees **execution call progress** (not individual task progress)
- Current task highlighted as "in_progress" - Current execution highlighted as "in_progress" (e.g., "[Agent-1] (Task A + Task B)")
- Completed tasks marked with checkmark - Completed executions marked with checkmark
- Pending tasks remain unchecked - Pending executions remain unchecked
- Each execution shows **task summary** for context
**Progress Tracking**: **Progress Tracking**:
- Mark Phase 5 as in_progress throughout execution - Track agent/CLI call completion (not task completion)
- Mark Phase 5 as completed when all tasks done - One execution call may handle multiple tasks simultaneously
- Final status summary displayed to user - Mark Phase 5 as completed when all execution calls done
**Step 5.4: Code Review (Optional)** **Step 5.4: Code Review (Optional)**
**Skip Condition**: Only run if user selected review tool in Phase 4 (not "No") **Skip Condition**: Only run if user selected review tool in Phase 4 (not "Skip")
**Operations**: **Operations**:
- If Claude: Current agent performs direct code review analysis - If "Agent Review": Current agent performs direct code review analysis
- If CLI tool (gemini/qwen/codex): Execute CLI with code review analysis prompt - If "Gemini Review": Execute gemini CLI with code review analysis prompt
- If "Other" (custom tool specified): Execute specified CLI tool (e.g., qwen, codex)
- Review all modified files from execution - Review all modified files from execution
- Generate quality assessment and improvement recommendations - Generate quality assessment and improvement recommendations
**Command Format**: **Command Format**:
```bash ```bash
# Claude (default): Direct agent review (no CLI command needed) # Agent Review: Direct agent review (no CLI command needed)
# Uses analysis prompt and TodoWrite tools directly # Uses analysis prompt and TodoWrite tools directly
# CLI Tools (gemini/qwen/codex): Execute analysis command # Gemini Review / Custom Tool (qwen, codex, etc.): Execute analysis command
{selected_tool} -p " {selected_tool} -p "
PURPOSE: Code review for implemented changes PURPOSE: Code review for implemented changes
TASK: • Analyze code quality • Identify potential issues • Suggest improvements TASK: • Analyze code quality • Identify potential issues • Suggest improvements
@@ -685,20 +698,22 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/02-review-code-q
- Balances speed and thoroughness appropriately - Balances speed and thoroughness appropriately
4. **Three-Dimensional Confirmation**: Comprehensive task approval and execution control 4. **Three-Dimensional Confirmation**: Comprehensive task approval and execution control
- First dimension: Confirm/Modify/Cancel plan - First dimension: Confirm/Modify/Cancel plan (multi-select with supplement via "Other")
- Second dimension: Execution method selection (Agent/Codex/Auto) - Second dimension: Execution method selection (Agent/Codex/Auto)
- Third dimension: Code review tool selection (No/Claude/Gemini/Qwen/Codex) - Third dimension: Code review tool selection (Skip/Gemini/Agent, custom via "Other")
- Allows plan refinement without re-selecting execution method - Allows plan refinement without re-selecting execution method
- Supports iterative planning with user feedback - Supports iterative planning with user feedback
- Auto mode intelligently selects execution method based on complexity - Auto mode intelligently selects execution method based on complexity
- Custom code review tools (qwen, codex, etc.) can be specified via "Other" option
### Task Management ### Task Management
1. **Live Progress Tracking**: TodoWrite provides real-time execution visibility 1. **Live Progress Tracking**: TodoWrite provides real-time execution call visibility
- Tasks created before execution starts - Execution calls ([Agent-1], [Codex-1], etc.) created before execution starts
- Updated in real-time as work progresses - Updated in real-time as execution calls progress
- User sees current task being worked on - User sees current execution call being worked on (e.g., "[Agent-1] (Task A + Task B)")
- Clear completion status throughout execution - Each execution call shows task summary for context
- Clear completion status at call level (not individual task level)
2. **Phase-Based Organization**: 5 distinct phases with clear transitions 2. **Phase-Based Organization**: 5 distinct phases with clear transitions
- Phase 1: Task Analysis & Exploration (automatic) - Phase 1: Task Analysis & Exploration (automatic)