mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: 添加选项以标记任务为失败
This commit is contained in:
@@ -1,47 +1,51 @@
|
|||||||
---
|
---
|
||||||
description: Execute solution from issue queue with git commit after each task
|
description: Execute all solutions from issue queue with git commit after each task
|
||||||
argument-hint: "<solution-id> [--dry-run]"
|
argument-hint: ""
|
||||||
---
|
---
|
||||||
|
|
||||||
# Issue Execute (Codex Version)
|
# Issue Execute (Codex Version)
|
||||||
|
|
||||||
## Core Principle
|
## 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
|
## Execution Flow
|
||||||
|
|
||||||
```
|
```
|
||||||
INIT: Receive solution ID (S-N) from orchestrator
|
INIT: Fetch first solution via ccw issue next
|
||||||
|
|
||||||
FOR solution:
|
WHILE solution exists:
|
||||||
1. Fetch full solution via: ccw issue detail <solution-id>
|
1. Receive solution JSON from ccw issue next
|
||||||
2. Iterate through solution.tasks sequentially:
|
2. Execute all tasks in solution.tasks sequentially:
|
||||||
FOR each task in solution.tasks:
|
FOR each task:
|
||||||
- IMPLEMENT: Follow task.implementation steps
|
- IMPLEMENT: Follow task.implementation steps
|
||||||
- TEST: Run task.test commands
|
- TEST: Run task.test commands
|
||||||
- VERIFY: Check task.acceptance criteria
|
- VERIFY: Check task.acceptance criteria
|
||||||
- COMMIT: Stage files, commit with task.commit.message_template
|
- 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
|
```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")
|
- `item_id`: Solution identifier in queue (e.g., "S-1")
|
||||||
- `issue_id`: Parent issue ID (e.g., "ISS-20251227-001")
|
- `issue_id`: Parent issue ID (e.g., "ISS-20251227-001")
|
||||||
- `solution_id`: Solution ID (e.g., "SOL-20251227-001")
|
- `solution_id`: Solution ID (e.g., "SOL-20251227-001")
|
||||||
- `solution`: Full solution with all tasks
|
- `solution`: Full solution with all tasks
|
||||||
- `execution_hints`: Timing and executor hints
|
- `execution_hints`: Timing and executor hints
|
||||||
|
|
||||||
|
If response contains `{ "status": "empty" }`, all solutions are complete - skip to final summary.
|
||||||
|
|
||||||
## Step 2: Parse Solution Response
|
## Step 2: Parse Solution Response
|
||||||
|
|
||||||
Expected solution structure:
|
Expected solution structure:
|
||||||
@@ -54,13 +58,13 @@ Expected solution structure:
|
|||||||
"status": "pending",
|
"status": "pending",
|
||||||
"solution": {
|
"solution": {
|
||||||
"id": "SOL-20251227-001",
|
"id": "SOL-20251227-001",
|
||||||
"approach": "Description of solution approach",
|
"description": "Description of solution approach",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"id": "T1",
|
"id": "T1",
|
||||||
"title": "Task title",
|
"title": "Task title",
|
||||||
"scope": "src/module/",
|
"scope": "src/module/",
|
||||||
"action": "Create|Modify|Fix|Refactor",
|
"action": "Create|Modify|Fix|Refactor|Add",
|
||||||
"description": "What to do",
|
"description": "What to do",
|
||||||
"modification_points": [
|
"modification_points": [
|
||||||
{ "file": "path/to/file.ts", "target": "function name", "change": "description" }
|
{ "file": "path/to/file.ts", "target": "function name", "change": "description" }
|
||||||
@@ -71,22 +75,35 @@ Expected solution structure:
|
|||||||
],
|
],
|
||||||
"test": {
|
"test": {
|
||||||
"commands": ["npm test -- --filter=xxx"],
|
"commands": ["npm test -- --filter=xxx"],
|
||||||
"unit": "Unit test requirements",
|
"unit": ["Unit test requirement 1", "Unit test requirement 2"]
|
||||||
"integration": "Integration test requirements (optional)"
|
},
|
||||||
|
"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": {
|
"commit": {
|
||||||
|
"type": "feat|fix|test|refactor",
|
||||||
|
"scope": "module",
|
||||||
"message_template": "feat(scope): description"
|
"message_template": "feat(scope): description"
|
||||||
}
|
},
|
||||||
|
"depends_on": [],
|
||||||
|
"estimated_minutes": 30,
|
||||||
|
"priority": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"exploration_context": {
|
"exploration_context": {
|
||||||
"relevant_files": ["path/to/reference.ts"],
|
"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": {
|
"execution_hints": {
|
||||||
"executor": "codex",
|
"executor": "codex",
|
||||||
@@ -101,10 +118,11 @@ Iterate through `solution.tasks` array and execute each task:
|
|||||||
|
|
||||||
### Phase A: IMPLEMENT
|
### 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
|
2. Follow `task.implementation` steps in order
|
||||||
3. Apply changes to `task.modification_points` files
|
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:**
|
**Output format:**
|
||||||
```
|
```
|
||||||
@@ -142,7 +160,7 @@ Iterate through `solution.tasks` array and execute each task:
|
|||||||
|
|
||||||
### Phase C: VERIFY
|
### 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]
|
## Verifying: [task.title]
|
||||||
@@ -152,6 +170,10 @@ Check all `task.acceptance` criteria are met:
|
|||||||
- [x] Criterion 2: Verified
|
- [x] Criterion 2: Verified
|
||||||
...
|
...
|
||||||
|
|
||||||
|
**Verification Steps**:
|
||||||
|
- [x] Run test command
|
||||||
|
- [x] Manual verification step
|
||||||
|
|
||||||
All criteria met: YES
|
All criteria met: YES
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -189,87 +211,107 @@ EOF
|
|||||||
|
|
||||||
Continue to next task in `solution.tasks` array until all tasks are complete.
|
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:
|
After ALL tasks in the solution are complete, report to queue system:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ccw issue done <solution-id> --result '{
|
ccw issue done <item_id> --result '{
|
||||||
"summary": "[What was accomplished]",
|
"files_modified": ["path1", "path2"],
|
||||||
"files_modified": ["path1", "path2", ...],
|
"tests_passed": true,
|
||||||
"tasks_completed": N,
|
"acceptance_passed": true,
|
||||||
|
"committed": true,
|
||||||
"commits": [
|
"commits": [
|
||||||
{ "task_id": "T1", "hash": "abc123" },
|
{ "task_id": "T1", "hash": "abc123" },
|
||||||
{ "task_id": "T2", "hash": "def456" }
|
{ "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
|
```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
|
## Final Summary
|
||||||
|
|
||||||
When all tasks in solution are complete:
|
When `ccw issue next` returns `{ "status": "empty" }`:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
## Solution Execution Complete
|
## Issue Queue Execution Complete
|
||||||
|
|
||||||
**Solution**: [solution_id]
|
**Total Solutions Executed**: N
|
||||||
**Issue**: [issue_id]
|
**Total Tasks Executed**: M
|
||||||
**Tasks Executed**: N/N
|
|
||||||
|
|
||||||
**All Commits**:
|
**All Commits**:
|
||||||
| # | Task ID | Task Title | Commit |
|
| # | Solution | Task | Commit |
|
||||||
|---|---------|------------|--------|
|
|---|----------|------|--------|
|
||||||
| 1 | T1 | Task title | abc123 |
|
| 1 | S-1 | T1 | abc123 |
|
||||||
| 2 | T2 | Task title | def456 |
|
| 2 | S-1 | T2 | def456 |
|
||||||
|
| 3 | S-2 | T1 | ghi789 |
|
||||||
|
|
||||||
**Files Modified**:
|
**Files Modified**:
|
||||||
- path/to/file1.ts
|
- path/to/file1.ts
|
||||||
- path/to/file2.ts
|
- path/to/file2.ts
|
||||||
|
|
||||||
**Summary**:
|
**Summary**:
|
||||||
[Overall what was accomplished for this solution]
|
[Overall what was accomplished]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Execution Rules
|
## Execution Rules
|
||||||
|
|
||||||
1. **Solution-aware** - Receive complete solution, iterate tasks internally
|
1. **Never stop mid-queue** - Continue until queue is empty
|
||||||
2. **Sequential within solution** - Complete each task (including commit) before moving to next
|
2. **One solution at a time** - Fully complete (all tasks + report) before moving on
|
||||||
3. **Tests MUST pass** - Do not proceed to commit if tests fail
|
3. **Sequential within solution** - Complete each task (including commit) before next
|
||||||
4. **Commit after each task** - Each task gets its own commit
|
4. **Tests MUST pass** - Do not proceed to commit if tests fail
|
||||||
5. **Self-verify** - All acceptance criteria must pass before commit
|
5. **Commit after each task** - Each task gets its own commit
|
||||||
6. **Report accurately** - Use `ccw issue done` after all tasks complete
|
6. **Self-verify** - All acceptance criteria must pass before commit
|
||||||
7. **Handle failures gracefully** - If a task fails, report via `ccw issue done --fail`
|
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
|
## Error Handling
|
||||||
|
|
||||||
| Situation | Action |
|
| 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 |
|
| Tests fail | Fix code, re-run tests |
|
||||||
| Verification fails | Go back to implement phase |
|
| Verification fails | Go back to implement phase |
|
||||||
| Git commit fails | Check staging, retry commit |
|
| 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
|
## CLI Command Reference
|
||||||
|
|
||||||
| Command | Purpose |
|
| Command | Purpose |
|
||||||
|---------|---------|
|
|---------|---------|
|
||||||
| `ccw issue detail <id>` | Fetch full solution (READ-ONLY) |
|
| `ccw issue next` | Fetch next solution from queue |
|
||||||
| `ccw issue done <id>` | Mark solution complete |
|
| `ccw issue done <id>` | Mark solution complete with result |
|
||||||
| `ccw issue done <id> --fail` | Mark solution failed |
|
| `ccw issue done <id> --fail` | Mark solution failed with reason |
|
||||||
|
|
||||||
## Start Execution
|
## Start Execution
|
||||||
|
|
||||||
When invoked by orchestrator with solution ID:
|
Begin by running:
|
||||||
|
|
||||||
```bash
|
```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.
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ export function run(argv: string[]): void {
|
|||||||
.option('--solution-id <id>', 'Solution ID')
|
.option('--solution-id <id>', 'Solution ID')
|
||||||
.option('--result <json>', 'Execution result JSON')
|
.option('--result <json>', 'Execution result JSON')
|
||||||
.option('--reason <text>', 'Failure reason')
|
.option('--reason <text>', 'Failure reason')
|
||||||
|
.option('--fail', 'Mark task as failed')
|
||||||
.action((subcommand, args, options) => issueCommand(subcommand, args, options));
|
.action((subcommand, args, options) => issueCommand(subcommand, args, options));
|
||||||
|
|
||||||
program.parse(argv);
|
program.parse(argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user