feat: 添加选项以标记任务为失败

This commit is contained in:
catlog22
2025-12-28 20:45:05 +08:00
parent c24ad501b5
commit 847abcefce
2 changed files with 104 additions and 61 deletions

View File

@@ -1,47 +1,51 @@
---
description: Execute solution from issue queue with git commit after each task
argument-hint: "<solution-id> [--dry-run]"
description: Execute all solutions from issue queue with git commit after each task
argument-hint: ""
---
# Issue Execute (Codex Version)
## Core Principle
**Solution-Aware Execution**: Receive a complete solution with all its tasks, execute tasks sequentially within the solution (implement → test → commit per task), then report solution completion. This aligns with the Queue's Solution-Level design.
**Serial Execution**: Execute solutions ONE BY ONE from the issue queue via `ccw issue next`. For each solution, complete all tasks sequentially (implement → test → commit per task). Continue autonomously until queue is empty.
## Execution Flow
```
INIT: Receive solution ID (S-N) from orchestrator
INIT: Fetch first solution via ccw issue next
FOR solution:
1. Fetch full solution via: ccw issue detail <solution-id>
2. Iterate through solution.tasks sequentially:
FOR each task in solution.tasks:
WHILE solution exists:
1. Receive solution JSON from ccw issue next
2. Execute all tasks in solution.tasks sequentially:
FOR each task:
- IMPLEMENT: Follow task.implementation steps
- TEST: Run task.test commands
- VERIFY: Check task.acceptance criteria
- COMMIT: Stage files, commit with task.commit.message_template
3. Report solution completion: ccw issue done <solution-id>
3. Report completion via ccw issue done <item_id>
4. Fetch next solution via ccw issue next
OUTPUT: Final summary with all commits
WHEN queue empty:
Output final summary
```
## Step 1: Fetch Solution
## Step 1: Fetch First Solution
Run this command to get the full solution:
Run this command to get your first solution:
```bash
ccw issue detail <solution-id>
ccw issue next
```
This returns JSON with the complete solution definition:
This returns JSON with the full solution definition:
- `item_id`: Solution identifier in queue (e.g., "S-1")
- `issue_id`: Parent issue ID (e.g., "ISS-20251227-001")
- `solution_id`: Solution ID (e.g., "SOL-20251227-001")
- `solution`: Full solution with all tasks
- `execution_hints`: Timing and executor hints
If response contains `{ "status": "empty" }`, all solutions are complete - skip to final summary.
## Step 2: Parse Solution Response
Expected solution structure:
@@ -54,13 +58,13 @@ Expected solution structure:
"status": "pending",
"solution": {
"id": "SOL-20251227-001",
"approach": "Description of solution approach",
"description": "Description of solution approach",
"tasks": [
{
"id": "T1",
"title": "Task title",
"scope": "src/module/",
"action": "Create|Modify|Fix|Refactor",
"action": "Create|Modify|Fix|Refactor|Add",
"description": "What to do",
"modification_points": [
{ "file": "path/to/file.ts", "target": "function name", "change": "description" }
@@ -71,22 +75,35 @@ Expected solution structure:
],
"test": {
"commands": ["npm test -- --filter=xxx"],
"unit": "Unit test requirements",
"integration": "Integration test requirements (optional)"
"unit": ["Unit test requirement 1", "Unit test requirement 2"]
},
"regression": ["Verify existing tests still pass"],
"acceptance": {
"criteria": ["Criterion 1: Must pass", "Criterion 2: Must verify"],
"verification": ["Run test command", "Manual verification step"]
},
"acceptance": [
"Criterion 1: Must pass",
"Criterion 2: Must verify"
],
"commit": {
"type": "feat|fix|test|refactor",
"scope": "module",
"message_template": "feat(scope): description"
}
},
"depends_on": [],
"estimated_minutes": 30,
"priority": 1
}
],
"exploration_context": {
"relevant_files": ["path/to/reference.ts"],
"patterns": "Follow existing pattern in xxx"
}
"patterns": "Follow existing pattern in xxx",
"integration_points": "Used by other modules"
},
"analysis": {
"risk": "low|medium|high",
"impact": "low|medium|high",
"complexity": "low|medium|high"
},
"score": 0.95,
"is_bound": true
},
"execution_hints": {
"executor": "codex",
@@ -101,10 +118,11 @@ Iterate through `solution.tasks` array and execute each task:
### Phase A: IMPLEMENT
1. Read all `exploration_context.relevant_files` to understand existing patterns
1. Read all `solution.exploration_context.relevant_files` to understand existing patterns
2. Follow `task.implementation` steps in order
3. Apply changes to `task.modification_points` files
4. Follow `exploration_context.patterns` for code style consistency
4. Follow `solution.exploration_context.patterns` for code style consistency
5. Run `task.regression` checks if specified to ensure no breakage
**Output format:**
```
@@ -142,7 +160,7 @@ Iterate through `solution.tasks` array and execute each task:
### Phase C: VERIFY
Check all `task.acceptance` criteria are met:
Check all `task.acceptance.criteria` are met using `task.acceptance.verification` steps:
```
## Verifying: [task.title]
@@ -152,6 +170,10 @@ Check all `task.acceptance` criteria are met:
- [x] Criterion 2: Verified
...
**Verification Steps**:
- [x] Run test command
- [x] Manual verification step
All criteria met: YES
```
@@ -189,87 +211,107 @@ EOF
Continue to next task in `solution.tasks` array until all tasks are complete.
## Step 4: Report Solution Completion
## Step 4: Report Completion
After ALL tasks in the solution are complete, report to queue system:
```bash
ccw issue done <solution-id> --result '{
"summary": "[What was accomplished]",
"files_modified": ["path1", "path2", ...],
"tasks_completed": N,
ccw issue done <item_id> --result '{
"files_modified": ["path1", "path2"],
"tests_passed": true,
"acceptance_passed": true,
"committed": true,
"commits": [
{ "task_id": "T1", "hash": "abc123" },
{ "task_id": "T2", "hash": "def456" }
]
],
"summary": "[What was accomplished]"
}'
```
**If any task failed and cannot be fixed:**
**If solution failed and cannot be fixed:**
```bash
ccw issue done <solution-id> --fail --reason "Task [task.id] failed: [details]"
ccw issue done <item_id> --fail --reason "Task [task.id] failed: [details]"
```
## Step 5: Continue to Next Solution
Immediately fetch the next solution:
```bash
ccw issue next
```
**Output progress:**
```
✓ [N/M] Completed: [item_id] - [solution.approach]
→ Fetching next solution...
```
**DO NOT STOP.** Return to Step 2 and continue until queue is empty.
## Final Summary
When all tasks in solution are complete:
When `ccw issue next` returns `{ "status": "empty" }`:
```markdown
## Solution Execution Complete
## Issue Queue Execution Complete
**Solution**: [solution_id]
**Issue**: [issue_id]
**Tasks Executed**: N/N
**Total Solutions Executed**: N
**Total Tasks Executed**: M
**All Commits**:
| # | Task ID | Task Title | Commit |
|---|---------|------------|--------|
| 1 | T1 | Task title | abc123 |
| 2 | T2 | Task title | def456 |
| # | Solution | Task | Commit |
|---|----------|------|--------|
| 1 | S-1 | T1 | abc123 |
| 2 | S-1 | T2 | def456 |
| 3 | S-2 | T1 | ghi789 |
**Files Modified**:
- path/to/file1.ts
- path/to/file2.ts
**Summary**:
[Overall what was accomplished for this solution]
[Overall what was accomplished]
```
## Execution Rules
1. **Solution-aware** - Receive complete solution, iterate tasks internally
2. **Sequential within solution** - Complete each task (including commit) before moving to next
3. **Tests MUST pass** - Do not proceed to commit if tests fail
4. **Commit after each task** - Each task gets its own commit
5. **Self-verify** - All acceptance criteria must pass before commit
6. **Report accurately** - Use `ccw issue done` after all tasks complete
7. **Handle failures gracefully** - If a task fails, report via `ccw issue done --fail`
1. **Never stop mid-queue** - Continue until queue is empty
2. **One solution at a time** - Fully complete (all tasks + report) before moving on
3. **Sequential within solution** - Complete each task (including commit) before next
4. **Tests MUST pass** - Do not proceed to commit if tests fail
5. **Commit after each task** - Each task gets its own commit
6. **Self-verify** - All acceptance criteria must pass before commit
7. **Report accurately** - Use `ccw issue done` after each solution
8. **Handle failures gracefully** - If a solution fails, report via `ccw issue done --fail` and continue to next
## Error Handling
| Situation | Action |
|-----------|--------|
| Solution not found | Report error, abort |
| `ccw issue next` returns empty | All done - output final summary |
| Tests fail | Fix code, re-run tests |
| Verification fails | Go back to implement phase |
| Git commit fails | Check staging, retry commit |
| Unrecoverable error | Call `ccw issue done --fail`, report details |
| `ccw issue done` fails | Log error, continue to next solution |
| Unrecoverable error | Call `ccw issue done --fail`, continue to next |
## CLI Command Reference
| Command | Purpose |
|---------|---------|
| `ccw issue detail <id>` | Fetch full solution (READ-ONLY) |
| `ccw issue done <id>` | Mark solution complete |
| `ccw issue done <id> --fail` | Mark solution failed |
| `ccw issue next` | Fetch next solution from queue |
| `ccw issue done <id>` | Mark solution complete with result |
| `ccw issue done <id> --fail` | Mark solution failed with reason |
## Start Execution
When invoked by orchestrator with solution ID:
Begin by running:
```bash
ccw issue detail <solution-id>
ccw issue next
```
Then follow the task lifecycle for each task in `solution.tasks` until all complete.
Then follow the solution lifecycle for each solution until queue is empty.

View File

@@ -284,6 +284,7 @@ export function run(argv: string[]): void {
.option('--solution-id <id>', 'Solution ID')
.option('--result <json>', 'Execution result JSON')
.option('--reason <text>', 'Failure reason')
.option('--fail', 'Mark task as failed')
.action((subcommand, args, options) => issueCommand(subcommand, args, options));
program.parse(argv);