awesome-slash 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +54 -0
- package/.claude-plugin/plugin.json +11 -0
- package/.mcp.json +8 -0
- package/CHANGELOG.md +261 -0
- package/LICENSE +21 -0
- package/README.md +363 -0
- package/SECURITY.md +101 -0
- package/adapters/README.md +256 -0
- package/adapters/codex/README.md +272 -0
- package/adapters/codex/install.sh +179 -0
- package/adapters/opencode/README.md +301 -0
- package/adapters/opencode/install.sh +223 -0
- package/lib/patterns/review-patterns.js +511 -0
- package/lib/patterns/slop-patterns.js +647 -0
- package/lib/platform/detect-platform.js +535 -0
- package/lib/platform/verify-tools.js +235 -0
- package/lib/state/workflow-state.js +635 -0
- package/lib/state/workflow-state.schema.json +282 -0
- package/lib/utils/context-optimizer.js +227 -0
- package/mcp-server/index.js +303 -0
- package/mcp-server/package.json +23 -0
- package/package.json +63 -0
- package/plugins/deslop-around/.claude-plugin/plugin.json +20 -0
- package/plugins/deslop-around/commands/deslop-around.md +220 -0
- package/plugins/deslop-around/lib/patterns/review-patterns.js +511 -0
- package/plugins/deslop-around/lib/patterns/slop-patterns.js +641 -0
- package/plugins/deslop-around/lib/platform/detect-platform.js +514 -0
- package/plugins/deslop-around/lib/platform/verify-tools.js +235 -0
- package/plugins/deslop-around/lib/state/workflow-state.js +635 -0
- package/plugins/deslop-around/lib/state/workflow-state.schema.json +282 -0
- package/plugins/deslop-around/lib/utils/context-optimizer.js +222 -0
- package/plugins/next-task/.claude-plugin/plugin.json +24 -0
- package/plugins/next-task/agents/ci-fixer.md +236 -0
- package/plugins/next-task/agents/ci-monitor.md +291 -0
- package/plugins/next-task/agents/delivery-validator.md +451 -0
- package/plugins/next-task/agents/deslop-work.md +272 -0
- package/plugins/next-task/agents/docs-updater.md +506 -0
- package/plugins/next-task/agents/exploration-agent.md +277 -0
- package/plugins/next-task/agents/implementation-agent.md +427 -0
- package/plugins/next-task/agents/planning-agent.md +236 -0
- package/plugins/next-task/agents/policy-selector.md +248 -0
- package/plugins/next-task/agents/review-orchestrator.md +521 -0
- package/plugins/next-task/agents/simple-fixer.md +136 -0
- package/plugins/next-task/agents/task-discoverer.md +357 -0
- package/plugins/next-task/agents/test-coverage-checker.md +447 -0
- package/plugins/next-task/agents/worktree-manager.md +419 -0
- package/plugins/next-task/commands/delivery-approval.md +331 -0
- package/plugins/next-task/commands/next-task.md +627 -0
- package/plugins/next-task/commands/update-docs-around.md +418 -0
- package/plugins/next-task/hooks/hooks.json +14 -0
- package/plugins/next-task/lib/patterns/review-patterns.js +511 -0
- package/plugins/next-task/lib/patterns/slop-patterns.js +641 -0
- package/plugins/next-task/lib/platform/detect-platform.js +514 -0
- package/plugins/next-task/lib/platform/verify-tools.js +235 -0
- package/plugins/next-task/lib/state/tasks-registry.schema.json +85 -0
- package/plugins/next-task/lib/state/workflow-state.js +635 -0
- package/plugins/next-task/lib/state/workflow-state.schema.json +282 -0
- package/plugins/next-task/lib/state/worktree-status.schema.json +219 -0
- package/plugins/next-task/lib/utils/context-optimizer.js +222 -0
- package/plugins/project-review/.claude-plugin/plugin.json +20 -0
- package/plugins/project-review/commands/project-review-agents.md +286 -0
- package/plugins/project-review/commands/project-review-github.md +142 -0
- package/plugins/project-review/commands/project-review.md +273 -0
- package/plugins/project-review/lib/patterns/review-patterns.js +511 -0
- package/plugins/project-review/lib/patterns/slop-patterns.js +641 -0
- package/plugins/project-review/lib/platform/detect-platform.js +514 -0
- package/plugins/project-review/lib/platform/verify-tools.js +235 -0
- package/plugins/project-review/lib/state/workflow-state.js +635 -0
- package/plugins/project-review/lib/state/workflow-state.schema.json +282 -0
- package/plugins/project-review/lib/utils/context-optimizer.js +222 -0
- package/plugins/reality-check/.claude-plugin/plugin.json +23 -0
- package/plugins/reality-check/README.md +156 -0
- package/plugins/reality-check/agents/code-explorer.md +353 -0
- package/plugins/reality-check/agents/doc-analyzer.md +337 -0
- package/plugins/reality-check/agents/issue-scanner.md +231 -0
- package/plugins/reality-check/agents/plan-synthesizer.md +479 -0
- package/plugins/reality-check/commands/scan.md +242 -0
- package/plugins/reality-check/commands/set.md +203 -0
- package/plugins/reality-check/lib/state/reality-check-state.js +509 -0
- package/plugins/reality-check/skills/reality-analysis/SKILL.md +317 -0
- package/plugins/ship/.claude-plugin/plugin.json +21 -0
- package/plugins/ship/commands/ship-ci-review-loop.md +443 -0
- package/plugins/ship/commands/ship-deployment.md +330 -0
- package/plugins/ship/commands/ship-error-handling.md +254 -0
- package/plugins/ship/commands/ship.md +370 -0
- package/plugins/ship/lib/patterns/review-patterns.js +511 -0
- package/plugins/ship/lib/patterns/slop-patterns.js +641 -0
- package/plugins/ship/lib/platform/detect-platform.js +514 -0
- package/plugins/ship/lib/platform/verify-tools.js +235 -0
- package/plugins/ship/lib/state/workflow-state.js +635 -0
- package/plugins/ship/lib/state/workflow-state.schema.json +282 -0
- package/plugins/ship/lib/utils/context-optimizer.js +222 -0
- package/scripts/install/claude.sh +50 -0
- package/scripts/install/codex.sh +181 -0
- package/scripts/install/opencode.sh +211 -0
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Master workflow orchestrator with autonomous task-to-production automation
|
|
3
|
+
argument-hint: "[filter] [--status] [--resume] [--abort] [--implement]"
|
|
4
|
+
allowed-tools: Bash(git:*), Bash(gh:*), Bash(npm:*), Bash(node:*), Read, Write, Edit, Glob, Grep, Task, AskUserQuestion
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /next-task - Master Workflow Orchestrator
|
|
8
|
+
|
|
9
|
+
Discover what to work on next and execute the complete implementation workflow.
|
|
10
|
+
|
|
11
|
+
## Workflow Overview
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Policy Selection → Task Discovery → Worktree Setup → Exploration → Planning
|
|
15
|
+
↓ ↓
|
|
16
|
+
(User input) (User approval)
|
|
17
|
+
↓
|
|
18
|
+
← ← ← AUTONOMOUS FROM HERE → → →
|
|
19
|
+
↓
|
|
20
|
+
Implementation → Pre-Review Gates → Review Loop → Delivery Validation
|
|
21
|
+
↓
|
|
22
|
+
Docs Update → /ship
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Human interaction points (ONLY THESE):**
|
|
26
|
+
1. Policy selection via checkboxes
|
|
27
|
+
2. Task selection from ranked list
|
|
28
|
+
3. Plan approval (EnterPlanMode/ExitPlanMode)
|
|
29
|
+
|
|
30
|
+
**After plan approval, everything runs autonomously until delivery validation passes.**
|
|
31
|
+
|
|
32
|
+
## ⛔ WORKFLOW ENFORCEMENT - CRITICAL
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
╔══════════════════════════════════════════════════════════════════════════╗
|
|
36
|
+
║ MANDATORY WORKFLOW GATES ║
|
|
37
|
+
╠══════════════════════════════════════════════════════════════════════════╣
|
|
38
|
+
║ ║
|
|
39
|
+
║ Each phase MUST complete and approve before the next can start: ║
|
|
40
|
+
║ ║
|
|
41
|
+
║ 1. implementation-agent completes ║
|
|
42
|
+
║ ↓ MUST trigger ║
|
|
43
|
+
║ 2. deslop-work + test-coverage-checker (parallel) ║
|
|
44
|
+
║ ↓ MUST trigger ║
|
|
45
|
+
║ 3. review-orchestrator (MUST approve - all critical/high resolved) ║
|
|
46
|
+
║ ↓ MUST trigger (only if approved) ║
|
|
47
|
+
║ 4. delivery-validator (MUST approve - tests pass, build passes) ║
|
|
48
|
+
║ ↓ MUST trigger (only if approved) ║
|
|
49
|
+
║ 5. docs-updater ║
|
|
50
|
+
║ ↓ MUST EXPLICITLY invoke /ship (NOT rely on hooks alone) ║
|
|
51
|
+
║ 6. /ship command (creates PR, monitors CI, merges, CLEANS UP) ║
|
|
52
|
+
║ ║
|
|
53
|
+
╠══════════════════════════════════════════════════════════════════════════╣
|
|
54
|
+
║ ║
|
|
55
|
+
║ ⛔ NO AGENT may create a PR - only /ship creates PRs ║
|
|
56
|
+
║ ⛔ NO AGENT may push to remote - only /ship pushes ║
|
|
57
|
+
║ ⛔ NO AGENT may skip the review-orchestrator ║
|
|
58
|
+
║ ⛔ NO AGENT may skip the delivery-validator ║
|
|
59
|
+
║ ⛔ NO AGENT may skip the docs-updater ║
|
|
60
|
+
║ ⛔ NO AGENT may skip workflow-status.json updates after each phase ║
|
|
61
|
+
║ ║
|
|
62
|
+
╚══════════════════════════════════════════════════════════════════════════╝
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## ⚠️ MANDATORY STATE UPDATES - EVERY AGENT
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
╔══════════════════════════════════════════════════════════════════════════╗
|
|
69
|
+
║ EVERY AGENT MUST UPDATE STATE ║
|
|
70
|
+
╠══════════════════════════════════════════════════════════════════════════╣
|
|
71
|
+
║ ║
|
|
72
|
+
║ After EACH phase completion, agents MUST: ║
|
|
73
|
+
║ ║
|
|
74
|
+
║ 1. Update .claude/workflow-status.json in the WORKTREE with: ║
|
|
75
|
+
║ - Current step name and status ║
|
|
76
|
+
║ - Timestamp of completion ║
|
|
77
|
+
║ - Any relevant result data ║
|
|
78
|
+
║ ║
|
|
79
|
+
║ 2. Update .claude/tasks.json in the MAIN REPO with: ║
|
|
80
|
+
║ - lastActivityAt timestamp ║
|
|
81
|
+
║ - Current status ║
|
|
82
|
+
║ ║
|
|
83
|
+
║ FAILURE TO UPDATE STATE = WORKFLOW CANNOT RESUME ║
|
|
84
|
+
║ ║
|
|
85
|
+
╚══════════════════════════════════════════════════════════════════════════╝
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### State Update Code (Use in EVERY agent)
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// MANDATORY: Call this at the END of every agent's work
|
|
92
|
+
function recordStepCompletion(stepName, result = {}) {
|
|
93
|
+
const fs = require('fs');
|
|
94
|
+
const path = require('path');
|
|
95
|
+
|
|
96
|
+
// 1. Update worktree's workflow-status.json
|
|
97
|
+
const worktreeStatusPath = '.claude/workflow-status.json';
|
|
98
|
+
if (fs.existsSync(worktreeStatusPath)) {
|
|
99
|
+
const status = JSON.parse(fs.readFileSync(worktreeStatusPath, 'utf8'));
|
|
100
|
+
|
|
101
|
+
status.steps.push({
|
|
102
|
+
step: stepName,
|
|
103
|
+
status: 'completed',
|
|
104
|
+
startedAt: status.workflow.lastActivityAt,
|
|
105
|
+
completedAt: new Date().toISOString(),
|
|
106
|
+
result: result
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
status.workflow.lastActivityAt = new Date().toISOString();
|
|
110
|
+
status.workflow.currentPhase = stepName;
|
|
111
|
+
status.resume.resumeFromStep = stepName;
|
|
112
|
+
|
|
113
|
+
fs.writeFileSync(worktreeStatusPath, JSON.stringify(status, null, 2));
|
|
114
|
+
console.log(`✓ Updated workflow-status.json: ${stepName}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 2. Update main repo's tasks.json (if accessible)
|
|
118
|
+
const mainRepoTasksPath = status?.git?.mainRepoPath
|
|
119
|
+
? path.join(status.git.mainRepoPath, '.claude', 'tasks.json')
|
|
120
|
+
: null;
|
|
121
|
+
|
|
122
|
+
if (mainRepoTasksPath && fs.existsSync(mainRepoTasksPath)) {
|
|
123
|
+
const registry = JSON.parse(fs.readFileSync(mainRepoTasksPath, 'utf8'));
|
|
124
|
+
const taskIdx = registry.tasks.findIndex(t => t.id === status.task.id);
|
|
125
|
+
|
|
126
|
+
if (taskIdx >= 0) {
|
|
127
|
+
registry.tasks[taskIdx].lastActivityAt = new Date().toISOString();
|
|
128
|
+
registry.tasks[taskIdx].currentStep = stepName;
|
|
129
|
+
fs.writeFileSync(mainRepoTasksPath, JSON.stringify(registry, null, 2));
|
|
130
|
+
console.log(`✓ Updated tasks.json registry: ${stepName}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### SubagentStop Hook Enforcement
|
|
137
|
+
|
|
138
|
+
The `hooks/hooks.json` SubagentStop hook enforces this sequence. When any agent
|
|
139
|
+
completes, the hook determines and triggers the next mandatory phase. Agents
|
|
140
|
+
MUST NOT invoke subsequent phases themselves - they STOP and let the hook handle it.
|
|
141
|
+
|
|
142
|
+
## Arguments
|
|
143
|
+
|
|
144
|
+
Parse from $ARGUMENTS:
|
|
145
|
+
- `--status`: Show current workflow state and exit
|
|
146
|
+
- `--resume [task/branch/worktree]`: Continue from last checkpoint
|
|
147
|
+
- `--abort`: Cancel workflow and cleanup
|
|
148
|
+
- `--implement`: Skip to implementation after task selection
|
|
149
|
+
- `[filter]`: Task filter (bug, feature, security, test)
|
|
150
|
+
|
|
151
|
+
### Resume Syntax
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
/next-task --resume # Resume active worktree (if only one)
|
|
155
|
+
/next-task --resume 123 # Resume by task ID
|
|
156
|
+
/next-task --resume feature/my-task-123 # Resume by branch name
|
|
157
|
+
/next-task --resume ../worktrees/my-task-123 # Resume by worktree path
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### ⚠️ EXISTING SESSION vs STALE SESSION - IMPORTANT
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
╔══════════════════════════════════════════════════════════════════════════╗
|
|
164
|
+
║ UNDERSTANDING "EXISTING SESSION" SEMANTICS ║
|
|
165
|
+
╠══════════════════════════════════════════════════════════════════════════╣
|
|
166
|
+
║ ║
|
|
167
|
+
║ "Existing session" means AN ACTIVE AGENT IS CURRENTLY RUNNING: ║
|
|
168
|
+
║ ║
|
|
169
|
+
║ ✓ An agent is in the middle of processing ║
|
|
170
|
+
║ ✓ The workflow was interrupted (context limit, crash, user cancel) ║
|
|
171
|
+
║ ✓ workflow-status.json shows recent lastActivityAt (< 1 hour) ║
|
|
172
|
+
║ ║
|
|
173
|
+
║ This is DIFFERENT from a "stale session": ║
|
|
174
|
+
║ ║
|
|
175
|
+
║ ✗ Worktree exists but no agent is running ║
|
|
176
|
+
║ ✗ lastActivityAt is old (> 24 hours) ║
|
|
177
|
+
║ ✗ User abandoned the task without cleanup ║
|
|
178
|
+
║ ║
|
|
179
|
+
║ BEHAVIOR: ║
|
|
180
|
+
║ - Existing session: --resume continues from last checkpoint ║
|
|
181
|
+
║ - Stale session: Ask user - resume or abort/cleanup? ║
|
|
182
|
+
║ - No session: Start fresh workflow ║
|
|
183
|
+
║ ║
|
|
184
|
+
║ CHECK BEFORE STARTING NEW WORKFLOW: ║
|
|
185
|
+
║ 1. Read .claude/tasks.json in main repo ║
|
|
186
|
+
║ 2. If tasks exist, check lastActivityAt for each ║
|
|
187
|
+
║ 3. Recent activity (< 1 hour) = active session, DO NOT start new ║
|
|
188
|
+
║ 4. Old activity (> 24 hours) = stale, ask user ║
|
|
189
|
+
║ ║
|
|
190
|
+
╚══════════════════════════════════════════════════════════════════════════╝
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Pre-flight: Handle Arguments
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
const workflowState = require('${CLAUDE_PLUGIN_ROOT}/lib/state/workflow-state.js');
|
|
197
|
+
const args = '$ARGUMENTS'.split(' ').filter(Boolean);
|
|
198
|
+
|
|
199
|
+
// Handle --status
|
|
200
|
+
if (args.includes('--status')) {
|
|
201
|
+
const summary = workflowState.getWorkflowSummary();
|
|
202
|
+
if (!summary) { console.log("No active workflow."); return; }
|
|
203
|
+
console.log(`## Status: ${summary.status} | Phase: ${summary.currentPhase} | Task: ${summary.task?.title || 'None'}`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Handle --abort
|
|
208
|
+
if (args.includes('--abort')) {
|
|
209
|
+
workflowState.abortWorkflow('User requested abort');
|
|
210
|
+
console.log("✓ Workflow aborted.");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Handle --resume
|
|
215
|
+
if (args.includes('--resume')) {
|
|
216
|
+
const resumeArg = args[args.indexOf('--resume') + 1];
|
|
217
|
+
const worktree = await findWorktreeToResume(resumeArg);
|
|
218
|
+
|
|
219
|
+
if (!worktree) {
|
|
220
|
+
console.log("No worktree found to resume. Specify task ID, branch, or worktree path.");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Read workflow-status.json from the worktree
|
|
225
|
+
const statusPath = path.join(worktree.path, '.claude', 'workflow-status.json');
|
|
226
|
+
if (!fs.existsSync(statusPath)) {
|
|
227
|
+
console.log(`No workflow-status.json found in ${worktree.path}`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const status = JSON.parse(fs.readFileSync(statusPath, 'utf8'));
|
|
232
|
+
const lastStep = status.steps[status.steps.length - 1];
|
|
233
|
+
|
|
234
|
+
console.log(`
|
|
235
|
+
## Resuming Workflow
|
|
236
|
+
|
|
237
|
+
**Task**: #${status.task.id} - ${status.task.title}
|
|
238
|
+
**Worktree**: ${worktree.path}
|
|
239
|
+
**Branch**: ${status.git.branch}
|
|
240
|
+
**Last Step**: ${lastStep.step} (${lastStep.status})
|
|
241
|
+
**Last Activity**: ${status.workflow.lastActivityAt}
|
|
242
|
+
`);
|
|
243
|
+
|
|
244
|
+
// Change to worktree
|
|
245
|
+
process.chdir(worktree.path);
|
|
246
|
+
|
|
247
|
+
// Determine resume phase from last completed step
|
|
248
|
+
const resumePhase = mapStepToPhase(lastStep.step);
|
|
249
|
+
console.log(`Resuming from phase: ${resumePhase}`);
|
|
250
|
+
|
|
251
|
+
// Continue workflow from that phase...
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function findWorktreeToResume(arg) {
|
|
255
|
+
const registryPath = '.claude/tasks.json';
|
|
256
|
+
if (!fs.existsSync(registryPath)) return null;
|
|
257
|
+
|
|
258
|
+
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
|
259
|
+
|
|
260
|
+
// No argument - if only one active task, use it
|
|
261
|
+
if (!arg && registry.tasks.length === 1) {
|
|
262
|
+
return { path: registry.tasks[0].worktreePath, task: registry.tasks[0] };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Search by task ID
|
|
266
|
+
const byId = registry.tasks.find(t => t.id === arg);
|
|
267
|
+
if (byId) return { path: byId.worktreePath, task: byId };
|
|
268
|
+
|
|
269
|
+
// Search by branch name
|
|
270
|
+
const byBranch = registry.tasks.find(t => t.branch === arg || t.branch.endsWith(arg));
|
|
271
|
+
if (byBranch) return { path: byBranch.worktreePath, task: byBranch };
|
|
272
|
+
|
|
273
|
+
// Direct path
|
|
274
|
+
if (arg && fs.existsSync(arg)) {
|
|
275
|
+
return { path: arg, task: null };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function mapStepToPhase(step) {
|
|
282
|
+
const stepToPhase = {
|
|
283
|
+
'worktree-created': 'exploration',
|
|
284
|
+
'exploration-completed': 'planning',
|
|
285
|
+
'plan-approved': 'implementation',
|
|
286
|
+
'implementation-completed': 'pre-review-gates',
|
|
287
|
+
'deslop-work-completed': 'review-loop',
|
|
288
|
+
'review-approved': 'delivery-validation',
|
|
289
|
+
'delivery-validation-passed': 'docs-update',
|
|
290
|
+
'docs-updated': 'ship',
|
|
291
|
+
'ready-to-ship': 'ship'
|
|
292
|
+
};
|
|
293
|
+
return stepToPhase[step] || 'exploration';
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Phase 1: Policy Selection
|
|
298
|
+
|
|
299
|
+
→ **Agent**: `next-task:policy-selector` (haiku)
|
|
300
|
+
|
|
301
|
+
```javascript
|
|
302
|
+
workflowState.startPhase('policy-selection');
|
|
303
|
+
|
|
304
|
+
await Task({
|
|
305
|
+
subagent_type: "next-task:policy-selector",
|
|
306
|
+
prompt: `Configure workflow via checkbox selection. Gather: task source, priority filter, stopping point.`
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Policy now in state
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Phase 2: Task Discovery
|
|
313
|
+
|
|
314
|
+
→ **Agent**: `next-task:task-discoverer` (inherit)
|
|
315
|
+
|
|
316
|
+
```javascript
|
|
317
|
+
workflowState.startPhase('task-discovery');
|
|
318
|
+
|
|
319
|
+
await Task({
|
|
320
|
+
subagent_type: "next-task:task-discoverer",
|
|
321
|
+
prompt: `Discover tasks from ${policy.taskSource}, filter by ${policy.priorityFilter}. Present top 5 to user for selection.`
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Selected task now in state.task
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Phase 3: Worktree Setup
|
|
328
|
+
|
|
329
|
+
→ **Agent**: `next-task:worktree-manager` (haiku)
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
workflowState.startPhase('worktree-setup');
|
|
333
|
+
|
|
334
|
+
await Task({
|
|
335
|
+
subagent_type: "next-task:worktree-manager",
|
|
336
|
+
prompt: `Create worktree for task #${state.task.id} - ${state.task.title}. Anchor pwd to worktree.`
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// All subsequent operations happen in worktree
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Phase 4: Exploration
|
|
343
|
+
|
|
344
|
+
→ **Agent**: `next-task:exploration-agent` (opus)
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
workflowState.startPhase('exploration');
|
|
348
|
+
|
|
349
|
+
await Task({
|
|
350
|
+
subagent_type: "next-task:exploration-agent",
|
|
351
|
+
model: "opus",
|
|
352
|
+
prompt: `Deep codebase analysis for task #${state.task.id}. Find key files, patterns, dependencies.`
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Exploration results in state for planning
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Phase 5: Planning
|
|
359
|
+
|
|
360
|
+
→ **Agent**: `next-task:planning-agent` (opus)
|
|
361
|
+
|
|
362
|
+
```javascript
|
|
363
|
+
workflowState.startPhase('planning');
|
|
364
|
+
|
|
365
|
+
await Task({
|
|
366
|
+
subagent_type: "next-task:planning-agent",
|
|
367
|
+
model: "opus",
|
|
368
|
+
prompt: `Design implementation plan for task #${state.task.id}. Enter plan mode for user approval.`
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// Agent uses EnterPlanMode → user approves → ExitPlanMode
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Phase 6: User Approval
|
|
375
|
+
|
|
376
|
+
Planning agent handles this via EnterPlanMode/ExitPlanMode.
|
|
377
|
+
**This is the LAST human interaction point.**
|
|
378
|
+
|
|
379
|
+
## Phase 7: Implementation
|
|
380
|
+
|
|
381
|
+
→ **Agent**: `next-task:implementation-agent` (opus)
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
workflowState.startPhase('implementation');
|
|
385
|
+
|
|
386
|
+
await Task({
|
|
387
|
+
subagent_type: "next-task:implementation-agent",
|
|
388
|
+
model: "opus",
|
|
389
|
+
prompt: `Execute approved plan for task #${state.task.id}. Commit changes incrementally.`
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// → SubagentStop hook triggers pre-review gates
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Phase 8: Pre-Review Gates
|
|
396
|
+
|
|
397
|
+
→ **Agents** (parallel): `next-task:deslop-work` (sonnet) + `next-task:test-coverage-checker` (sonnet)
|
|
398
|
+
|
|
399
|
+
Triggered automatically by SubagentStop hook after implementation.
|
|
400
|
+
|
|
401
|
+
```javascript
|
|
402
|
+
workflowState.startPhase('pre-review-gates');
|
|
403
|
+
|
|
404
|
+
await Promise.all([
|
|
405
|
+
Task({ subagent_type: "next-task:deslop-work", prompt: `Clean AI slop from new work.` }),
|
|
406
|
+
Task({ subagent_type: "next-task:test-coverage-checker", prompt: `Validate test coverage (advisory).` })
|
|
407
|
+
]);
|
|
408
|
+
|
|
409
|
+
// → Proceeds to review loop
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Phase 9: Review Loop
|
|
413
|
+
|
|
414
|
+
→ **Agent**: `next-task:review-orchestrator` (opus)
|
|
415
|
+
|
|
416
|
+
```javascript
|
|
417
|
+
workflowState.startPhase('review-loop');
|
|
418
|
+
|
|
419
|
+
await Task({
|
|
420
|
+
subagent_type: "next-task:review-orchestrator",
|
|
421
|
+
model: "opus",
|
|
422
|
+
prompt: `Orchestrate multi-agent review. Fix critical/high issues. Max ${policy.maxReviewIterations || 3} iterations.`
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Runs deslop-work after each iteration to clean fixes
|
|
426
|
+
// → SubagentStop hook triggers delivery validation when approved
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Phase 10: Delivery Validation
|
|
430
|
+
|
|
431
|
+
→ **Agent**: `next-task:delivery-validator` (sonnet)
|
|
432
|
+
|
|
433
|
+
Triggered automatically by SubagentStop hook after review approval.
|
|
434
|
+
|
|
435
|
+
```javascript
|
|
436
|
+
workflowState.startPhase('delivery-validation');
|
|
437
|
+
|
|
438
|
+
const result = await Task({
|
|
439
|
+
subagent_type: "next-task:delivery-validator",
|
|
440
|
+
prompt: `Validate task completion. Check: tests pass, build passes, requirements met, no regressions.`
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (!result.approved) {
|
|
444
|
+
// Return to implementation with fix instructions - automatic retry
|
|
445
|
+
workflowState.failPhase(result.reason, { fixInstructions: result.fixInstructions });
|
|
446
|
+
return; // Workflow retries from implementation
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
workflowState.completePhase({ deliveryApproved: true });
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Phase 11: Docs Update
|
|
453
|
+
|
|
454
|
+
→ **Agent**: `next-task:docs-updater` (sonnet)
|
|
455
|
+
|
|
456
|
+
Triggered automatically by SubagentStop hook after delivery validation.
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
workflowState.startPhase('docs-update');
|
|
460
|
+
|
|
461
|
+
await Task({
|
|
462
|
+
subagent_type: "next-task:docs-updater",
|
|
463
|
+
prompt: `Update docs for changed files. CHANGELOG, API docs, code examples.`
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
workflowState.completePhase({ docsUpdated: true });
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## ⚠️ EXPLICIT HANDOFF TO /ship - CRITICAL
|
|
470
|
+
|
|
471
|
+
After docs-updater completes, you MUST EXPLICITLY invoke /ship.
|
|
472
|
+
**DO NOT rely on SubagentStop hooks alone** - explicitly call the ship skill.
|
|
473
|
+
|
|
474
|
+
```
|
|
475
|
+
╔══════════════════════════════════════════════════════════════════════════╗
|
|
476
|
+
║ /ship RESPONSIBILITIES ║
|
|
477
|
+
╠══════════════════════════════════════════════════════════════════════════╣
|
|
478
|
+
║ ║
|
|
479
|
+
║ /ship handles ALL of the following (agents must NOT do these): ║
|
|
480
|
+
║ ║
|
|
481
|
+
║ 1. CREATE PR - Push branch, create pull request ║
|
|
482
|
+
║ 2. MONITOR CI - Wait for checks to pass ║
|
|
483
|
+
║ 3. MONITOR COMMENTS - Wait for reviews, address all comments ║
|
|
484
|
+
║ 4. MERGE PR - Squash/merge based on policy ║
|
|
485
|
+
║ 5. CLEANUP WORKTREE - Remove worktree after merge ║
|
|
486
|
+
║ 6. UPDATE tasks.json - Remove task from registry after completion ║
|
|
487
|
+
║ ║
|
|
488
|
+
║ AGENTS MUST NOT: ║
|
|
489
|
+
║ - Create PRs ║
|
|
490
|
+
║ - Push to remote ║
|
|
491
|
+
║ - Clean up worktrees ║
|
|
492
|
+
║ - Remove tasks from registry ║
|
|
493
|
+
║ ║
|
|
494
|
+
╚══════════════════════════════════════════════════════════════════════════╝
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### Required Handoff Code
|
|
498
|
+
|
|
499
|
+
```javascript
|
|
500
|
+
// AFTER docs-updater completes, EXPLICITLY invoke /ship
|
|
501
|
+
console.log(`
|
|
502
|
+
## ✓ Implementation Complete - Ready to Ship
|
|
503
|
+
|
|
504
|
+
Task #${state.task.id} passed all validation checks.
|
|
505
|
+
- ✓ Review approved (all critical/high resolved)
|
|
506
|
+
- ✓ Delivery validated (tests pass, build passes)
|
|
507
|
+
- ✓ Documentation updated
|
|
508
|
+
|
|
509
|
+
→ EXPLICITLY invoking /ship for PR creation and merge workflow.
|
|
510
|
+
`);
|
|
511
|
+
|
|
512
|
+
// Update state BEFORE invoking ship
|
|
513
|
+
recordStepCompletion('ready-to-ship', {
|
|
514
|
+
readyAt: new Date().toISOString(),
|
|
515
|
+
taskId: state.task.id
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// EXPLICIT invocation - DO NOT skip this
|
|
519
|
+
await Skill({ skill: "ship:ship", args: "--state-file .claude/workflow-status.json" });
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### /ship Cleanup Responsibilities
|
|
523
|
+
|
|
524
|
+
When /ship completes successfully, it MUST:
|
|
525
|
+
|
|
526
|
+
```javascript
|
|
527
|
+
// /ship cleanup (happens inside ship command)
|
|
528
|
+
function cleanupAfterShip(state) {
|
|
529
|
+
const fs = require('fs');
|
|
530
|
+
const path = require('path');
|
|
531
|
+
|
|
532
|
+
// 1. Remove task from main repo's tasks.json
|
|
533
|
+
const mainRepoTasksPath = path.join(state.git.mainRepoPath, '.claude', 'tasks.json');
|
|
534
|
+
if (fs.existsSync(mainRepoTasksPath)) {
|
|
535
|
+
const registry = JSON.parse(fs.readFileSync(mainRepoTasksPath, 'utf8'));
|
|
536
|
+
registry.tasks = registry.tasks.filter(t => t.id !== state.task.id);
|
|
537
|
+
fs.writeFileSync(mainRepoTasksPath, JSON.stringify(registry, null, 2));
|
|
538
|
+
console.log(`✓ Removed task #${state.task.id} from tasks.json registry`);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// 2. Return to main repo directory
|
|
542
|
+
process.chdir(state.git.mainRepoPath);
|
|
543
|
+
|
|
544
|
+
// 3. Remove worktree
|
|
545
|
+
exec(`git worktree remove "${state.git.worktreePath}" --force`);
|
|
546
|
+
console.log(`✓ Removed worktree at ${state.git.worktreePath}`);
|
|
547
|
+
|
|
548
|
+
// 4. Prune worktree references
|
|
549
|
+
exec('git worktree prune');
|
|
550
|
+
}
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
## Error Handling
|
|
554
|
+
|
|
555
|
+
```javascript
|
|
556
|
+
try {
|
|
557
|
+
// ... workflow phases ...
|
|
558
|
+
} catch (error) {
|
|
559
|
+
workflowState.failPhase(error.message, { phase: currentPhase });
|
|
560
|
+
console.log(`
|
|
561
|
+
## Workflow Failed at ${currentPhase}
|
|
562
|
+
|
|
563
|
+
Use \`/next-task --resume\` to retry from checkpoint.
|
|
564
|
+
Use \`/next-task --abort\` to cancel.
|
|
565
|
+
`);
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## State Management Architecture
|
|
570
|
+
|
|
571
|
+
Two-file state management to prevent collisions across parallel workflows:
|
|
572
|
+
|
|
573
|
+
### Main Repo: `.claude/tasks.json`
|
|
574
|
+
```
|
|
575
|
+
- Shared registry of claimed tasks
|
|
576
|
+
- task-discoverer reads to exclude claimed tasks
|
|
577
|
+
- worktree-manager adds entry when creating worktree
|
|
578
|
+
- ship removes entry on cleanup
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Worktree: `.claude/workflow-status.json`
|
|
582
|
+
```
|
|
583
|
+
- Local to each worktree
|
|
584
|
+
- Tracks all steps with timestamps
|
|
585
|
+
- Used for --resume to find last step
|
|
586
|
+
- Isolated from other workflows
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Step Recording
|
|
590
|
+
|
|
591
|
+
Each agent MUST record its step in the worktree's workflow-status.json:
|
|
592
|
+
|
|
593
|
+
```javascript
|
|
594
|
+
function recordStep(stepName, status, result = null) {
|
|
595
|
+
const statusPath = '.claude/workflow-status.json';
|
|
596
|
+
const state = JSON.parse(fs.readFileSync(statusPath, 'utf8'));
|
|
597
|
+
|
|
598
|
+
state.steps.push({
|
|
599
|
+
step: stepName,
|
|
600
|
+
status: status,
|
|
601
|
+
startedAt: new Date().toISOString(),
|
|
602
|
+
completedAt: status === 'completed' ? new Date().toISOString() : null,
|
|
603
|
+
result: result
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
state.workflow.lastActivityAt = new Date().toISOString();
|
|
607
|
+
state.workflow.currentPhase = stepName;
|
|
608
|
+
state.resume.resumeFromStep = stepName;
|
|
609
|
+
|
|
610
|
+
fs.writeFileSync(statusPath, JSON.stringify(state, null, 2));
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
## Success Criteria
|
|
615
|
+
|
|
616
|
+
- Policy selection via checkboxes
|
|
617
|
+
- **Two-file state management** (main repo registry + worktree status)
|
|
618
|
+
- **Resume by task ID, branch, or worktree path**
|
|
619
|
+
- Worktree isolation
|
|
620
|
+
- Opus for complex tasks (explore, plan, implement, review)
|
|
621
|
+
- Sonnet for validation tasks (quality gates, delivery)
|
|
622
|
+
- Haiku for simple tasks (policy, worktree)
|
|
623
|
+
- Fully autonomous after plan approval
|
|
624
|
+
- SubagentStop hooks for phase transitions
|
|
625
|
+
- Handoff to /ship for PR workflow
|
|
626
|
+
|
|
627
|
+
Begin workflow now.
|