@brunosps00/dev-workflow 2.2.0 → 2.3.0

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.
Files changed (119) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +12 -4
  4. package/lib/constants.js +24 -24
  5. package/lib/init.js +8 -0
  6. package/lib/instruction-health.js +38 -0
  7. package/lib/post-update.js +2 -1
  8. package/lib/validate.js +3 -1
  9. package/package.json +1 -1
  10. package/scaffold/config/routing.json +61 -23
  11. package/scaffold/en/agent-instructions.md +31 -137
  12. package/scaffold/en/commands/dw-analyze-project.md +2 -0
  13. package/scaffold/en/commands/dw-autopilot.md +22 -245
  14. package/scaffold/en/commands/dw-bugfix.md +9 -35
  15. package/scaffold/en/commands/dw-claude-run.md +29 -45
  16. package/scaffold/en/commands/dw-codex-run.md +30 -45
  17. package/scaffold/en/commands/dw-context-budget.md +6 -14
  18. package/scaffold/en/commands/dw-copilot-run.md +29 -41
  19. package/scaffold/en/commands/dw-generate-pr.md +2 -2
  20. package/scaffold/en/commands/dw-goal.md +11 -5
  21. package/scaffold/en/commands/dw-help.md +2 -2
  22. package/scaffold/en/commands/dw-plan.md +14 -7
  23. package/scaffold/en/commands/dw-qa.md +2 -0
  24. package/scaffold/en/commands/dw-resume.md +5 -11
  25. package/scaffold/en/commands/dw-review.md +4 -3
  26. package/scaffold/en/commands/dw-run.md +19 -166
  27. package/scaffold/en/commands/dw-skill-health.md +7 -0
  28. package/scaffold/en/commands/dw-update.md +18 -4
  29. package/scaffold/en/references/command-routing.md +53 -0
  30. package/scaffold/en/references/execution-contract.md +55 -0
  31. package/scaffold/en/templates/frontend-quality-template.md +43 -0
  32. package/scaffold/en/templates/task-template.md +20 -40
  33. package/scaffold/en/templates/tasks-template.md +9 -6
  34. package/scaffold/en/templates/techspec-template.md +4 -0
  35. package/scaffold/pt-br/agent-instructions.md +31 -137
  36. package/scaffold/pt-br/commands/dw-analyze-project.md +2 -0
  37. package/scaffold/pt-br/commands/dw-autopilot.md +22 -245
  38. package/scaffold/pt-br/commands/dw-bugfix.md +9 -35
  39. package/scaffold/pt-br/commands/dw-claude-run.md +29 -46
  40. package/scaffold/pt-br/commands/dw-codex-run.md +30 -45
  41. package/scaffold/pt-br/commands/dw-context-budget.md +6 -14
  42. package/scaffold/pt-br/commands/dw-copilot-run.md +29 -43
  43. package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
  44. package/scaffold/pt-br/commands/dw-goal.md +11 -5
  45. package/scaffold/pt-br/commands/dw-help.md +2 -2
  46. package/scaffold/pt-br/commands/dw-plan.md +14 -7
  47. package/scaffold/pt-br/commands/dw-qa.md +2 -0
  48. package/scaffold/pt-br/commands/dw-resume.md +7 -11
  49. package/scaffold/pt-br/commands/dw-review.md +4 -3
  50. package/scaffold/pt-br/commands/dw-run.md +19 -166
  51. package/scaffold/pt-br/commands/dw-skill-health.md +7 -0
  52. package/scaffold/pt-br/commands/dw-update.md +18 -4
  53. package/scaffold/pt-br/references/command-routing.md +53 -0
  54. package/scaffold/pt-br/references/execution-contract.md +55 -0
  55. package/scaffold/pt-br/templates/frontend-quality-template.md +43 -0
  56. package/scaffold/pt-br/templates/task-template.md +20 -40
  57. package/scaffold/pt-br/templates/tasks-template.md +9 -6
  58. package/scaffold/pt-br/templates/techspec-template.md +4 -0
  59. package/scaffold/scripts/lib/workflow-contract.mjs +101 -0
  60. package/scaffold/skill-registry.json +23 -23
  61. package/scaffold/skills/dw-cli-run/SKILL.md +33 -217
  62. package/scaffold/skills/dw-cli-run/references/dispatch-tuning.md +14 -72
  63. package/scaffold/skills/dw-codebase-intel/SKILL.md +5 -39
  64. package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +1 -1
  65. package/scaffold/skills/dw-codebase-intel/references/agents-detail.md +7 -0
  66. package/scaffold/skills/dw-codebase-intel/references/files-in-dw-intel-detail.md +16 -0
  67. package/scaffold/skills/dw-codebase-intel/references/how-dw-intel-reads-this-detail.md +12 -0
  68. package/scaffold/skills/dw-codebase-intel/references/how-to-compose-the-typical-flow-detail.md +11 -0
  69. package/scaffold/skills/dw-council/SKILL.md +2 -17
  70. package/scaffold/skills/dw-council/references/integration-with-other-dw-commands-detail.md +7 -0
  71. package/scaffold/skills/dw-council/references/phase-2-tensions-and-rebuttals-detail.md +15 -0
  72. package/scaffold/skills/dw-domain-modeling/SKILL.md +1 -1
  73. package/scaffold/skills/dw-execute-phase/SKILL.md +12 -32
  74. package/scaffold/skills/dw-execute-phase/agents/executor.md +15 -252
  75. package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +4 -207
  76. package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +8 -18
  77. package/scaffold/skills/dw-execute-phase/references/de-sloppify-pass-optional-cleanup-task-detail.md +12 -0
  78. package/scaffold/skills/dw-execute-phase/references/deviation-rules-during-execution-detail.md +8 -0
  79. package/scaffold/skills/dw-execute-phase/references/how-the-two-agents-compose-detail.md +7 -0
  80. package/scaffold/skills/dw-execute-phase/references/plan-verification.md +9 -155
  81. package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +6 -97
  82. package/scaffold/skills/dw-git-discipline/SKILL.md +2 -2
  83. package/scaffold/skills/dw-grilling/SKILL.md +1 -1
  84. package/scaffold/skills/dw-incident-response/SKILL.md +1 -64
  85. package/scaffold/skills/dw-incident-response/references/the-five-phases-detail.md +66 -0
  86. package/scaffold/skills/dw-llm-eval/SKILL.md +5 -53
  87. package/scaffold/skills/dw-llm-eval/references/agent-tool-use-evaluation-detail.md +23 -0
  88. package/scaffold/skills/dw-llm-eval/references/anti-patterns-will-block-in-dw-review-code-only-detail.md +9 -0
  89. package/scaffold/skills/dw-llm-eval/references/consistency-run-to-run-stability-detail.md +10 -0
  90. package/scaffold/skills/dw-llm-eval/references/integration-with-dev-workflow-commands-detail.md +6 -0
  91. package/scaffold/skills/dw-llm-eval/references/the-oracle-ladder-detail.md +15 -0
  92. package/scaffold/skills/dw-memory/SKILL.md +4 -50
  93. package/scaffold/skills/dw-memory/references/context-budget.md +8 -56
  94. package/scaffold/skills/dw-memory/references/promotion-decision-test-detail.md +30 -0
  95. package/scaffold/skills/dw-minimalism/SKILL.md +4 -5
  96. package/scaffold/skills/dw-review-rigor/SKILL.md +1 -54
  97. package/scaffold/skills/dw-review-rigor/references/the-five-rules-detail.md +56 -0
  98. package/scaffold/skills/dw-simplification/SKILL.md +2 -55
  99. package/scaffold/skills/dw-simplification/references/pattern-recognition-detail.md +11 -0
  100. package/scaffold/skills/dw-simplification/references/the-five-rules-detail.md +48 -0
  101. package/scaffold/skills/dw-source-grounding/SKILL.md +1 -56
  102. package/scaffold/skills/dw-source-grounding/references/the-protocol-detect-fetch-implement-cite-detail.md +58 -0
  103. package/scaffold/skills/dw-testing-discipline/SKILL.md +25 -177
  104. package/scaffold/skills/dw-testing-discipline/references/agent-guardrails.md +9 -167
  105. package/scaffold/skills/dw-testing-discipline/references/core-rules.md +3 -3
  106. package/scaffold/skills/dw-testing-discipline/references/mutation-testing.md +19 -0
  107. package/scaffold/skills/dw-testing-discipline/references/patterns.md +3 -12
  108. package/scaffold/skills/dw-ui-discipline/SKILL.md +2 -59
  109. package/scaffold/skills/dw-ui-discipline/references/frontend-engineering.md +46 -0
  110. package/scaffold/skills/dw-ui-discipline/references/the-four-grounding-questions-detail.md +61 -0
  111. package/scaffold/skills/dw-verify/SKILL.md +26 -148
  112. package/scaffold/skills/dw-verify/references/verification-discovery-and-attribution.md +2 -2
  113. package/scaffold/skills/humanizer/SKILL.md +2 -1
  114. package/scaffold/skills/security-review/SKILL.md +3 -183
  115. package/scaffold/skills/security-review/references/do-not-flag-detail.md +49 -0
  116. package/scaffold/skills/security-review/references/quick-patterns-reference-detail.md +56 -0
  117. package/scaffold/skills/security-review/references/review-process-detail.md +84 -0
  118. package/scaffold/skills/vercel-react-best-practices/SKILL.md +1 -90
  119. package/scaffold/skills/vercel-react-best-practices/references/quick-reference-detail.md +92 -0
@@ -0,0 +1,101 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { resolve } from 'node:path';
4
+
5
+ const tools = new Set(['local', 'codex', 'claude', 'copilot']);
6
+ const tiers = new Set(['light', 'standard', 'heavy']);
7
+
8
+ // A small executable contract for the agent-authored execution-plan.json.
9
+ // This validates assignments, not account access or authorization on its own.
10
+ export function validatePlan(plan) {
11
+ const issues = [];
12
+ if (!plan || !['1.0', '1.1'].includes(plan.schema_version)) return ['Unsupported execution plan schema'];
13
+ if (!Array.isArray(plan.tasks) || !plan.tasks.length) return ['tasks must be a nonempty array'];
14
+ if (typeof plan.approved !== 'boolean') issues.push('approved must be a boolean');
15
+ const ids = new Set();
16
+ for (const task of plan.tasks) {
17
+ if (!task || typeof task.id !== 'string' || !task.id.trim()) {
18
+ issues.push('Every task needs a nonempty string id');
19
+ continue;
20
+ }
21
+ if (ids.has(task.id)) issues.push(`Duplicate task ${task.id}`);
22
+ ids.add(task.id);
23
+ if (!Array.isArray(task.depends_on) || task.depends_on.some(id => typeof id !== 'string')) issues.push(`${task.id}: depends_on must be a string array`);
24
+ if (plan.schema_version === '1.1' && !task.execution) issues.push(`${task.id}: missing execution assignment`);
25
+ if (task.execution) {
26
+ const e = task.execution;
27
+ if (typeof e !== 'object' || Array.isArray(e)) { issues.push(`${task.id}: execution must be an object`); continue; }
28
+ if (!tiers.has(e.complexity)) issues.push(`${task.id}: invalid complexity`);
29
+ if (typeof e.rationale !== 'string' || !e.rationale.trim()) issues.push(`${task.id}: missing rationale`);
30
+ if (!Array.isArray(e.agents) || e.agents.some(a => typeof a !== 'string')) issues.push(`${task.id}: agents must be a string array`);
31
+ for (const assignment of [e, ...(Array.isArray(e.fallbacks) ? e.fallbacks : [])]) {
32
+ if (!assignment || typeof assignment !== 'object' || Array.isArray(assignment)) { issues.push(`${task.id}: invalid fallback assignment`); continue; }
33
+ if (!tools.has(assignment.tool)) issues.push(`${task.id}: invalid tool`);
34
+ if (typeof assignment.model !== 'string' || !assignment.model.trim()) issues.push(`${task.id}: missing model`);
35
+ if (typeof assignment.effort !== 'string' || !assignment.effort.trim()) issues.push(`${task.id}: missing effort`);
36
+ if (assignment.tool !== 'local' && [assignment.model, assignment.effort].includes('inherit')) issues.push(`${task.id}: external assignments must resolve model and effort`);
37
+ }
38
+ if (e.fallbacks !== undefined && !Array.isArray(e.fallbacks)) issues.push(`${task.id}: fallbacks must be an array`);
39
+ }
40
+ }
41
+ const tasks = new Map(plan.tasks.filter(t => t?.id).map(t => [t.id, t]));
42
+ const visiting = new Set(), visited = new Set();
43
+ function visit(id) {
44
+ if (visiting.has(id)) { issues.push(`Dependency cycle at ${id}`); return; }
45
+ if (visited.has(id)) return;
46
+ visiting.add(id);
47
+ for (const dep of tasks.get(id)?.depends_on || []) {
48
+ if (!ids.has(dep)) issues.push(`${id}: unknown dependency ${dep}`);
49
+ else visit(dep);
50
+ }
51
+ visiting.delete(id); visited.add(id);
52
+ }
53
+ if (!issues.length) for (const id of ids) visit(id);
54
+ return issues;
55
+ }
56
+
57
+ export function resolveAssignment(plan, taskId, availableTools) {
58
+ const issues = validatePlan(plan);
59
+ if (issues.length) throw new Error(issues.join('; '));
60
+ if (plan.approved !== true) throw new Error('Execution plan is not approved');
61
+ const task = plan.tasks.find(t => t.id === taskId);
62
+ if (!task) throw new Error(`Unknown task ${taskId}`);
63
+ // Legacy plans never imply permission to start another CLI.
64
+ const assignment = task.execution || { tool: 'local', model: 'inherit', effort: 'inherit', agents: [] };
65
+ const candidates = [assignment, ...(assignment.fallbacks || [])];
66
+ const chosen = candidates.find(c => availableTools.includes(c.tool));
67
+ if (!chosen) throw new Error(`No approved executor available for ${taskId}`);
68
+ return { ...chosen, agents: assignment.agents || [], fallback: chosen !== assignment };
69
+ }
70
+
71
+ export function readyTasks(plan, completedIds) {
72
+ const issues = validatePlan(plan);
73
+ if (issues.length) throw new Error(issues.join('; '));
74
+ const done = new Set(completedIds);
75
+ return plan.tasks.filter(t => !done.has(t.id) && t.depends_on.every(id => done.has(id))).map(t => t.id);
76
+ }
77
+
78
+ // Callers fingerprint actual inputs (including relevant untracked files) and
79
+ // environment. Unknown values fail closed. Time/message boundaries are irrelevant.
80
+ export function reusableEvidence(evidence, current) {
81
+ if (!evidence || evidence.exit_code !== 0 || !current) return false;
82
+ for (const key of ['command', 'input_fingerprint', 'environment_fingerprint']) {
83
+ if (typeof current[key] !== 'string' || !current[key] || evidence[key] !== current[key]) return false;
84
+ }
85
+ return Array.isArray(current.scope) && current.scope.length > 0 && Array.isArray(evidence.scope)
86
+ && current.scope.every(item => evidence.scope.includes(item));
87
+ }
88
+
89
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
90
+ try {
91
+ const [mode, file, taskId, available = 'local'] = process.argv.slice(2);
92
+ if (!['validate', 'resolve', 'ready'].includes(mode) || !file) throw new Error('Usage: workflow-contract.mjs validate|resolve|ready <plan.json> [task-id|completed-csv] [available-tools-csv]');
93
+ const plan = JSON.parse(readFileSync(file, 'utf8'));
94
+ if (mode === 'validate') {
95
+ const issues = validatePlan(plan);
96
+ console.log(JSON.stringify({ status: issues.length ? 'BLOCKED' : 'PASS', issues }));
97
+ if (issues.length) process.exitCode = 1;
98
+ } else if (mode === 'resolve') console.log(JSON.stringify(resolveAssignment(plan, taskId, available.split(','))));
99
+ else console.log(JSON.stringify(readyTasks(plan, taskId ? taskId.split(',') : [])));
100
+ } catch (error) { console.error(error.message); process.exitCode = 1; }
101
+ }
@@ -9,7 +9,7 @@
9
9
  "trigger": "API QA, endpoint testing, HTTP recipe generation",
10
10
  "expected_output": "A selected API testing recipe and evidence path for the active stack.",
11
11
  "load_policy": "lazy-references",
12
- "context_limit": 12000,
12
+ "context_limit": 8000,
13
13
  "invocation": "explicit",
14
14
  "exportable": true,
15
15
  "bundled": true
@@ -22,7 +22,7 @@
22
22
  "trigger": "Docker Compose service selection or local infrastructure setup",
23
23
  "expected_output": "A selected service recipe and composition guidance.",
24
24
  "load_policy": "lazy-references",
25
- "context_limit": 12000,
25
+ "context_limit": 8000,
26
26
  "invocation": "explicit",
27
27
  "exportable": true,
28
28
  "bundled": true
@@ -32,10 +32,10 @@
32
32
  "kind": "protocol",
33
33
  "tier": "core",
34
34
  "owner": "dw-codex-run,dw-claude-run,dw-copilot-run",
35
- "trigger": "Fire an AI CLI (Codex/Claude/Copilot) in a dedicated git worktree to implement a prepared prompt; resumable per-task session; STOP for the gate",
36
- "expected_output": "Audit-logged run with a 0-10 dual evaluation, a resumable session-id sidecar, and a STOP-for-gate Structured Return.",
35
+ "trigger": "Execute an approved task through a supported external CLI adapter",
36
+ "expected_output": "Reviewed task handoff with durable session, acceptance evidence and next task or blocker.",
37
37
  "load_policy": "lazy-references",
38
- "context_limit": 20500,
38
+ "context_limit": 8000,
39
39
  "bundled": true
40
40
  },
41
41
  {
@@ -46,7 +46,7 @@
46
46
  "trigger": "Codebase indexing or codebase intelligence query",
47
47
  "expected_output": ".dw/intel index files or a cited answer from the index.",
48
48
  "load_policy": "lazy-references",
49
- "context_limit": 12000,
49
+ "context_limit": 8000,
50
50
  "bundled": true
51
51
  },
52
52
  {
@@ -57,7 +57,7 @@
57
57
  "trigger": "Council mode or high-impact architectural debate",
58
58
  "expected_output": "Advisor positions, tension synthesis, and decision recommendation.",
59
59
  "load_policy": "lazy-references",
60
- "context_limit": 12000,
60
+ "context_limit": 8000,
61
61
  "bundled": true
62
62
  },
63
63
  {
@@ -68,7 +68,7 @@
68
68
  "trigger": "Native Grill domain vocabulary: challenge fuzzy/overloaded terms, cross-check against code, persist a canonical glossary to .dw/domain",
69
69
  "expected_output": "Canonical terms with discouraged synonyms persisted lazily to .dw/domain (single or multi-context), or fuzzy-term findings.",
70
70
  "load_policy": "lazy-references",
71
- "context_limit": 12000,
71
+ "context_limit": 8000,
72
72
  "exportable": false,
73
73
  "bundled": true
74
74
  },
@@ -80,7 +80,7 @@
80
80
  "trigger": "Native Grill decision-tree interview: sharpen a plan/PRD to shared understanding, exactly one decision per turn with a recommended answer",
81
81
  "expected_output": "A dependency-ordered decision tree, resolved decisions with recommendations, and an explicit shared-understanding gate.",
82
82
  "load_policy": "lazy-references",
83
- "context_limit": 12000,
83
+ "context_limit": 8000,
84
84
  "exportable": false,
85
85
  "bundled": true
86
86
  },
@@ -92,7 +92,7 @@
92
92
  "trigger": "Bugfix, QA fix loop, or non-reproducible failure",
93
93
  "expected_output": "Six-step triage, root cause, guard, and verification path.",
94
94
  "load_policy": "lazy-references",
95
- "context_limit": 12000,
95
+ "context_limit": 8000,
96
96
  "bundled": true
97
97
  },
98
98
  {
@@ -103,7 +103,7 @@
103
103
  "trigger": "Task execution, plan-checking, waves, checkpoint recovery",
104
104
  "expected_output": "Plan-check verdict, wave execution report, or checkpoint summary.",
105
105
  "load_policy": "lazy-references",
106
- "context_limit": 12000,
106
+ "context_limit": 8000,
107
107
  "bundled": true
108
108
  },
109
109
  {
@@ -114,7 +114,7 @@
114
114
  "trigger": "Commit creation, branch hygiene, PR generation",
115
115
  "expected_output": "Atomic commit plan and git hygiene checks.",
116
116
  "load_policy": "lazy-references",
117
- "context_limit": 12000,
117
+ "context_limit": 8000,
118
118
  "bundled": true
119
119
  },
120
120
  {
@@ -125,7 +125,7 @@
125
125
  "trigger": "Production critical bug, outage, incident, SEV workflow",
126
126
  "expected_output": "Incident triage, communication, resolution, and postmortem artifacts.",
127
127
  "load_policy": "lazy-references",
128
- "context_limit": 12000,
128
+ "context_limit": 8000,
129
129
  "bundled": true
130
130
  },
131
131
  {
@@ -136,7 +136,7 @@
136
136
  "trigger": "AI, LLM, RAG, classifier, agent, or tool-use feature",
137
137
  "expected_output": "Eval strategy, oracle choice, dataset requirements, and result checks.",
138
138
  "load_policy": "lazy-references",
139
- "context_limit": 12000,
139
+ "context_limit": 8000,
140
140
  "bundled": true
141
141
  },
142
142
  {
@@ -147,7 +147,7 @@
147
147
  "trigger": "Task execution memory, checkpointing, compaction",
148
148
  "expected_output": "Updated workflow memory and task-local memory guidance.",
149
149
  "load_policy": "lazy-references",
150
- "context_limit": 12000,
150
+ "context_limit": 8000,
151
151
  "bundled": true
152
152
  },
153
153
  {
@@ -171,7 +171,7 @@
171
171
  "trigger": "Code review, implementation review, or review consolidation",
172
172
  "expected_output": "Deduplicated findings ordered by defensible severity.",
173
173
  "load_policy": "always-small",
174
- "context_limit": 12000,
174
+ "context_limit": 8000,
175
175
  "bundled": true
176
176
  },
177
177
  {
@@ -205,7 +205,7 @@
205
205
  "trigger": "Refactor analysis, code smells, complexity, or behavior-preserving simplification",
206
206
  "expected_output": "Simplification target, risk, behavior-preserving checks, and recommendation.",
207
207
  "load_policy": "lazy-references",
208
- "context_limit": 12000,
208
+ "context_limit": 8000,
209
209
  "exportable": true,
210
210
  "bundled": true
211
211
  },
@@ -217,7 +217,7 @@
217
217
  "trigger": "Library/framework/API decision, technical research, dependency audit",
218
218
  "expected_output": "Cited source-grounded decision with version and retrieval date.",
219
219
  "load_policy": "lazy-references",
220
- "context_limit": 12000,
220
+ "context_limit": 8000,
221
221
  "bundled": true
222
222
  },
223
223
  {
@@ -228,7 +228,7 @@
228
228
  "trigger": "Writing, reviewing, or debugging tests",
229
229
  "expected_output": "Test placement, invariant, anti-pattern checks, and verification guidance.",
230
230
  "load_policy": "lazy-references",
231
- "context_limit": 12000,
231
+ "context_limit": 8000,
232
232
  "bundled": true
233
233
  },
234
234
  {
@@ -239,7 +239,7 @@
239
239
  "trigger": "UI design, redesign, visual QA, accessibility, or frontend polish",
240
240
  "expected_output": "Grounding answers, state matrix, accessibility checks, and visual risks.",
241
241
  "load_policy": "lazy-references",
242
- "context_limit": 12000,
242
+ "context_limit": 8000,
243
243
  "bundled": true
244
244
  },
245
245
  {
@@ -250,7 +250,7 @@
250
250
  "trigger": "Completion claim, commit, PR generation, or fixed bug status",
251
251
  "expected_output": "Fresh verification report with cited command evidence.",
252
252
  "load_policy": "always-small",
253
- "context_limit": 12000,
253
+ "context_limit": 8000,
254
254
  "exportable": true,
255
255
  "bundled": true
256
256
  },
@@ -288,7 +288,7 @@
288
288
  "trigger": "Security review, sensitive code, OWASP checks, auth/payment/input surfaces",
289
289
  "expected_output": "High-confidence security findings or explicit pass.",
290
290
  "load_policy": "lazy-references",
291
- "context_limit": 14000,
291
+ "context_limit": 8000,
292
292
  "exportable": true,
293
293
  "bundled": true
294
294
  },
@@ -300,7 +300,7 @@
300
300
  "trigger": "React/Next.js performance, hydration, data fetching, bundle or render issues",
301
301
  "expected_output": "Selected performance rule references and metric-driven recommendations.",
302
302
  "load_policy": "lazy-references",
303
- "context_limit": 12000,
303
+ "context_limit": 8000,
304
304
  "invocation": "explicit",
305
305
  "exportable": true,
306
306
  "bundled": true
@@ -1,234 +1,50 @@
1
1
  ---
2
2
  name: dw-cli-run
3
- description: "Shared runner protocol for the dw-*-run commands (dw-codex-run / dw-claude-run / dw-copilot-run). Fires an autonomous AI CLI (Codex / Claude / Copilot) INSIDE a dedicated git worktree to implement a prepared prompt/spec, with streaming captured to a durable audit log, a resumable per-task session, a 0–10 dual evaluation, graded escalation, and a STOP for the human gate. Loaded by those commands — substitute the CLI-specific adapter table they supply. NEVER runs in the main checkout; NEVER auto-merges (the owner decides after the gate)."
3
+ description: Execute an approved task through a Codex, Claude or Copilot CLI adapter, with isolated Git work, durable sessions and a reviewed handoff.
4
4
  allowed-tools:
5
- - Bash
6
5
  - Read
7
- - AskUserQuestion
6
+ - Write
7
+ - Bash
8
+ - Grep
9
+ - Glob
8
10
  ---
9
11
 
10
- # dw-cli-run — fire an AI CLI in the right worktree, audit it, keep the session, stop for the gate
11
-
12
- CLI-**agnostic** core protocol for the delegation step of `dw-codex-run` / `dw-claude-run` / `dw-copilot-run`: a
13
- **git worktree** holds a **prompt/spec** already prepared → this protocol fires the autonomous CLI there
14
- (streaming, non-blocking) → **captures the whole run to a durable audit log** → **keeps a resumable per-task
15
- session** → **evaluates the delivery 0–10** → escalates on failure → **STOPS for the gate** (merge is the owner's
16
- call). It exists because running these CLIs by hand is repetitive and risky: wrong worktree, hangs without a TTY,
17
- lost audit trail, and forgetting to measure quality before merge.
18
-
19
- > **Dual-use:** these CLIs perform **autonomous edits with auto-approve**. Confirm the **right worktree** and the
20
- > **scope** before firing. The isolated worktree is the mitigation that justifies the auto-approve flag.
21
-
22
- ## The adapter table (supplied by the invoking command)
23
- The command that loaded you (`dw-codex-run` / `dw-claude-run` / `dw-copilot-run`) provides a **CLI adapter table**
24
- with these slots. Substitute them into the steps below — everything else is identical across CLIs:
25
-
26
- | Slot | Meaning |
27
- |---|---|
28
- | `DISPATCH` | first-run command (background, streaming → audit log, `</dev/null`) |
29
- | `STREAM` | flag(s) that make it emit parseable streaming events (JSON/JSONL) |
30
- | `MODEL` | flag that selects the model tier for this dispatch |
31
- | `EFFORT` | flag that selects the reasoning budget for this dispatch |
32
- | `AUTO` | auto-approve / non-interactive flag for a **WRITE** dispatch (justified by the isolated worktree) |
33
- | `AUTO_READONLY` | plan/sandbox flag for a **READ-ONLY** dispatch (makes edits impossible; no worktree needed) |
34
- | `NO_MCP` | flag that starts the CLI with no MCP servers (cold-start trim) |
35
- | `RESUME <id>` | re-run command that **continues the SAME session/context** by id |
36
- | `RESUME_LAST` | "resume the last session of this cwd" fallback |
37
- | `SESSION_ID` | how to obtain/fix the session-id (from the stream, a sidecar, or a flag) |
38
- | `DONE_SIGNAL` | the stream event that means the turn finished |
39
- | `USAGE` | where token usage appears in the stream |
40
-
41
- If the command did not supply an adapter table, return `BLOCKED` — this skill is not invoked standalone.
42
-
43
- ## Dispatch modes — WRITE and READ-ONLY
44
-
45
- Every dispatch declares its mode up front; it decides isolation, permission flags, and gate. **WRITE** edits and
46
- commits → worktree mandatory, `AUTO`, one per worktree, full 0–10 gate. **READ-ONLY** reads/reviews/reports → no
47
- worktree, `AUTO_READONLY`, freely parallel, score the report without a re-run gate. Per-mode detail:
48
- `references/dispatch-tuning.md`.
49
-
50
- <critical>RULE (hard) — a WRITE dispatch runs **only** inside a **dedicated git worktree** (off main). **NEVER** fire a WRITE dispatch in the repo's **main checkout** (the root tree on the primary branch, e.g. `~/code/<project>` on `main`) — the CLI edits autonomously and that would corrupt the owner's active tree. If the target is the main checkout, **ABORT** (`BLOCKED`) and instruct: create/use a worktree first (`git worktree add ../<project>-<slug> -b <branch> main`). Mandatory check before running: `git worktree list` → the target is a secondary worktree (not the one flagged as main) **AND** the CLI's `cwd` is that worktree.</critical>
51
-
52
- <critical>A READ-ONLY dispatch MAY run in the main checkout, because the read-only flags make autonomous edits impossible — that is the entire reason the worktree rule exists. This is NOT a relaxation of the WRITE rule: if the dispatch can write, it is a WRITE dispatch and the worktree is mandatory. When in doubt, treat it as WRITE. Never pass an auto-approve flag on a dispatch declared READ-ONLY.</critical>
53
-
54
- ## Pre-flight (fail early > run in the wrong place)
55
- 1. `<cli> --version` answers (CLI + credentials present). Missing → `BLOCKED`.
56
- 2. **Declare the mode** (WRITE or READ-ONLY) and pick the matching `AUTO`/`AUTO_READONLY` slot.
57
- 3. WRITE only: `git worktree list` — confirm the target worktree and that it is **not** the main checkout. Missing →
58
- create it with `/dw-worktree create <slug>` (naming convention + install/build prep), never a bare `git worktree add`.
59
- 4. A **prompt/spec** exists (what the CLI receives). Common conventions: `.dw/spec/<slug>/codex-prompt.md`
60
- (dev-workflow), `PROMPT.md`, `TASK.md`, or a path the owner names. **Read it** — it is the scope/fence/gate.
61
-
62
- ## Cold-start cost
63
- A spawned CLI does not share the parent session's prompt cache and boots every configured MCP server first — on a
64
- small task that startup can outweigh the task. **Default: pass the adapter's `NO_MCP` slot on every dispatch whose
65
- prompt does not name an MCP capability.** Tool restriction, config trimming, and how to bind
66
- `.dw/config/routing.json` are in `references/dispatch-tuning.md` — read it when a dispatch feels overpriced.
67
-
68
- ## Where to run — pick the VEHICLE (the main thread NEVER runs inline)
69
- The main thread **orchestrates**; execution goes to one of these:
70
- - **Workflow (PREFERRED)** — when there is a pipeline (CLI implements → evaluate 0–10 → **gate fan-out**). One
71
- workflow agent runs the CLI (network OK). Shows in `/workflows` + parallelizes. Structure as separate
72
- **phases/agents**: `[agent that runs the CLI]` → `[gate agents]`.
73
- - **Single Agent (subagent)** — one-off dispatch of ONE run, no gate fan-out. Lighter; background; returns the
74
- report. Does not show in `/workflows`.
75
- - **Background Bash** — fallback only (no workflow/agent harness). Needs network → run un-sandboxed so the CLI can
76
- reach its API.
77
-
78
- > **Nesting:** the agent running the CLI **must not spawn further subagents** (nesting limit; Workflow nests only
79
- > 1 level). The gate is **another phase/agent** of the workflow — never a sub-spawn from inside the runner agent.
80
-
81
- ## Progress loop (auto-arm)
82
- WRITE runs invoke `/dw-report` before dispatch (idempotent while `.dw/reports/.active.json` is live; skipped when
83
- `DW_REPORT_AUTO=off`; `armed_by: dw-cli-run`). Ticks read the stream for measurable progress (`grep -c
84
- '"type":"item.completed"'`, last `command_execution`); the gate verdict is `finished` → final report + auto-disarm.
12
+ # CLI task execution
85
13
 
86
- ## Protocol
87
- 1. **Resolve target.** Worktree + prompt path (from the user or inferred). Derive a `<slug>` (the spec slug or
88
- worktree tag) — it keys the durable audit log and the session sidecar.
89
- 2. **Model + effort — routing table first, size only what it misses.** `.dw/config/routing.json` is the default
90
- source: commit type → tier (`by_commit_type`), raised if the fence matches `escalate_on_surface`, then tier →
91
- `MODEL`/`EFFORT` for the brand. Costs no reasoning, reproducible. Absent, or no declared type? Size it: propose
92
- with a one-line rationale (signals: task count, fence breadth, sensitive surface, architectural vs mechanical,
93
- E2E/secure-audit in the gate); the owner confirms or overrides. Either way start **one notch below the
94
- ceiling**. A tier that keeps escalating is a routing bug — name the entry that mis-sized it.
95
- 3. **Set up the durable audit dir (OUTSIDE the worktree).** `<AUDIT>=<main-repo-or-home>/.dw/cli-run/` — it MUST
96
- survive `git worktree remove` (the worktree's `QA/` is wiped on merge). Files: `<AUDIT>/<slug>.log` (stream),
97
- `<AUDIT>/<slug>.session` (session-id sidecar), optionally `<AUDIT>/<slug>.last.md` (final message).
98
- 4. **Dispatch (first run) in BACKGROUND with streaming → durable audit log.** Use the adapter's `DISPATCH`:
99
- ```bash
100
- cd <WORKTREE> && <DISPATCH ... STREAM AUTO ... "$(cat <PROMPT_PATH>)"> </dev/null \
101
- > <AUDIT>/<slug>.log 2>&1 # durable streaming audit trail
102
- ```
103
- - `</dev/null` ALWAYS (no TTY → hang). `STREAM` = parseable events; **don't** swallow everything with
104
- `2>/dev/null`.
105
- - **The stream log IS the audit trail (always capture).** It records, live and progressively, EVERYTHING the
106
- CLI does: each shell `command`, item started/completed, the CLI's `agent_message` (reasoning + answers),
107
- tool-calls, and the final `DONE_SIGNAL` (with `USAGE`/tokens). A "last message" capture (`-o` and friends)
108
- holds only the **final** message; the stream holds the **whole path**.
109
- - **Durability (critical for "audit later"):** write the stream log to a dir **outside** the worktree (step 3).
110
- If it lived in the worktree's `QA/`, post-merge cleanup would delete it and the audit would vanish. Audit
111
- later: shell commands `grep -oE '"command":"[^"]*"' <log>`; CLI reasoning/answers `grep '"agent_message"'
112
- <log>`; tokens via the adapter's `USAGE` field; a readable transcript = `agent_message` + `command` in file
113
- order.
114
- 5. **SESSION PER TASK (the heart) — capture on first run, resume by id.**
115
- - **First run:** obtain the **session-id** per the adapter's `SESSION_ID` (from the stream, a sidecar, or a
116
- fixed flag) and write it to the durable sidecar `<AUDIT>/<slug>.session` (one line: the id). This sidecar
117
- lives outside the worktree → it survives `git worktree remove`.
118
- - **Resume the SAME context:** read `<AUDIT>/<slug>.session` and re-run the adapter's `RESUME <id>` with the
119
- follow-up prompt → the CLI continues the **same session/context** (its reasoning, the files it already
120
- touched, the gate state). This is how "come back to the C6 run with full context" works: re-run with the id.
121
- - **Fallback:** if the sidecar is missing, the adapter's `RESUME_LAST` resumes the last session of this cwd
122
- (worktree = the session's cwd), so context is recoverable as long as you run from the same worktree.
123
- - Always record the session-id + sidecar path in the Structured Return (Artifacts) so a later turn can resume.
124
- 6. **Detect "DONE" — by the stream, NEVER by `pgrep` of the worktree path.** The done signal is the adapter's
125
- `DONE_SIGNAL` in the stream log **+** the worktree showing a commit/report (`git -C <worktree> log`, last
126
- message filled). A `pgrep -f "<worktree-path>"` (or `-f "<...>/last-message"`) **self-matches your own grep
127
- command** (the path is in the grep's argv) → false "running" that can hold a **READY** delivery for hours (and
128
- a `until ! pgrep ...` waiter with that pattern **never terminates**, since it sees itself alive). In background
129
- (`run_in_background`/Workflow), the **completion notification** is the signal. If you truly need pgrep,
130
- restrict to `pgrep -af "<cli> "` and filter `/proc/<pid>/cmdline` — never pgrep the raw path.
131
- 7. **Gate needs network?** Auto-approve modes that keep a sandbox **block network** for the CLI's shell commands →
132
- `install`/build/test/E2E fail with `EAI_AGAIN`. If the prompt tells the CLI to run the gate, the adapter's
133
- `AUTO` flag must be the **network-allowed** variant (full access) so the CLI runs the gate and self-validates.
134
- Justified because the **hard RULE** guarantees an isolated worktree. Without network in the gate, the CLI only
135
- implements and reports `blockers` (the gate then sits with the parent).
136
- 8. **Read-only / analysis mode:** when only reviewing (no edits), use the adapter's read-only variant and drop the
137
- auto-edit flag.
14
+ Use with `dw-codex-run`, `dw-claude-run`, or `dw-copilot-run`. The command supplies the adapter table; without it return `BLOCKED`. Read `.dw/references/execution-contract.md` for task assignments, dependency branches and resume state in an installed workflow. For standalone explicit runner requests, the user's prompt/spec supplies the assignment and authorized scope; do not require an unrelated PRD.
138
15
 
139
- ## Mandatory evaluation — 0–10 score (ALWAYS)
140
- When the run finishes, the parent **evaluates the delivery and gives a 0–10 score** (10 = full conformance +
141
- complete delivery). Do not skip it — it is the signal that decides gate vs escalation. Score against the prompt:
142
- - **Scope/fence conformance** (did the ask; stayed inside the allowlist).
143
- - **Technical gate** (lint/test/build/E2E per the prompt — green?).
144
- - **Completeness** (every task/item delivered).
145
- - **Hygiene** (committed, no junk, nothing outside the fence, no forbidden deps).
146
- - **Quality / no regression.**
147
- **Acceptance bar: score ≥9** (owner's decision). Bands: **≥9** = acceptable (ready for the human gate); **6–8** =
148
- `FINDINGS` → **escalate** to reach ≥9; **<6** = failure → **escalate**. `BLOCKED` if the ladder is exhausted
149
- without reaching 9. Always show the score + a short per-criterion rationale — and for any criterion below its
150
- ceiling, **cite the specific gap** (the failing test, the file left out of fence), not just a label. Same
151
- evidence discipline as the five-axis rubric in `dw-review-rigor/references/self-eval-rubric.md`.
16
+ ## Adapter slots
152
17
 
153
- ## Dual evaluation: the worker auto-gates → the parent re-gates
154
- A worker **can't grade its own exam alone** — hence two layers. (1) The worker loops at max effort until its own
155
- score is ≥9 with a green gate. (2) The parent independently re-runs the SAME gate and scores it, without trusting
156
- the self-score — **a worker never signs off on its own exam, even when that worker is Claude**. (3) The parent's
157
- score is what counts; a large gap means the worker overestimated → hand the gaps back via session resume and
158
- repeat. Record both scores and the gap. Prefer a **different brand** for the re-gate when one is installed; with
159
- only one, re-gate in a separate dispatch at a different tier — never reuse the executing session. Full protocol:
160
- `references/dispatch-tuning.md`.
18
+ `DISPATCH`, `STREAM`, `MODEL`, `EFFORT`, `AUTO`, `AUTO_READONLY`, `NO_MCP`, `RESUME <id>`, `SESSION_ID`, `DONE_SIGNAL`, `USAGE` describe the provider interface. `AUTO` means the approved non-interactive permission configuration, not blanket permission bypass. Check the installed CLI's help before substituting flags. A CLI version does not prove credentials or model access.
161
19
 
162
- ## Graded escalation on failure
163
- If the score is low / the gate failed / the CLI didn't finish, **re-run the SAME task one notch up** — gradual, no
164
- giving up on the first stumble, no jumping to the top. **Ladder:** effort first (`low`→`max`), then bump the model
165
- one tier and reset effort. **Stop** at score ≥9, or `BLOCKED` with evidence when the ceiling is exhausted.
166
- Announce each notch. Full ladder, continue-vs-restart rules, and how to read escalation as a routing-table signal:
167
- `references/dispatch-tuning.md`.
20
+ ## Isolation and permissions
168
21
 
169
- ## Detailed output → direct the next step
170
- The delivery must be **detailed enough for the parent to decide the next step** — not an opaque "done". When it
171
- finishes: **read the final message in full** + scan the stream; complement with `git -C <worktree> status` and
172
- `git diff --stat` to see what truly changed (don't trust only what the CLI said). Then **produce a HANDOFF**: what
173
- the **gate** should focus on, what to **adjust/redo**, whether to **escalate**, what's **outside the fence /
174
- uncommitted**, and the **blockers** — record it in the Structured Return (Evidence/Artifacts/Next Step). If the
175
- report is shallow, treat as `FINDINGS` and ask for detail (resume) or reconstruct it from the diff first.
22
+ - a WRITE dispatch runs **only** inside a **dedicated git worktree**. Create through `/dw-worktree create <slug>` when missing. Check the target is a secondary worktree and the CLI cwd matches it.
23
+ - A READ-ONLY dispatch MAY run in the main checkout when effective tool permissions prevent writes. When in doubt, treat it as WRITE. Never pass an auto-approve flag on a dispatch declared READ-ONLY.
24
+ - Worktrees isolate Git state, not the filesystem, network, credentials or other processes. Preserve platform permissions. Permission bypass is not a default and cannot be justified by a worktree alone.
25
+ - One writer per worktree. Dependent tasks use the same execution branch sequentially; independent branches require a planned integration path.
26
+ - Workers do not merge or push. The parent prepares the reviewed delivery and acts on separate integration/publication authorization.
176
27
 
177
- ## Telemetry (tokens + time) — always report
178
- The stream ends with the adapter's `USAGE` block (token counts). Extract it from the log.
179
- - **Effective billable ≈ `(input − cached_input) + output`** — input is often ~95%+ cache; reporting only the raw
180
- number misleads. Show both (raw + effective).
181
- - **Wall-clock:** the done event usually carries no duration → measure it yourself: wrap the dispatch with
182
- `/usr/bin/time` or `date +%s` before/after. Report in minutes.
183
- - **Command count:** `grep -c '"command"' <log>` (effort proxy).
184
- - Record all of it under Structured Return → Telemetry. Useful for cost, escalation, and comparing fan-out phases.
28
+ ## Execute and continue
185
29
 
186
- ## Discipline (when finishing)
187
- - **STOP — not merged.** The CLI implemented in the worktree; **run the gate** (tests/lint/build + review; if the
188
- project uses dev-workflow: `/dw-review` + `/dw-qa` + `/dw-secure-audit`) **before** any merge.
189
- - **Merge = the owner's explicit decision.** Never automatic here.
190
- - **End of life = the same turn as the merge (hard).** When the owner merges: `/dw-worktree merge <slug>` (ff-only from the
191
- main checkout → remove → branch delete → prune) or, if merged by other means, `/dw-worktree clean --apply` in that
192
- same turn. Never `git worktree remove --force`; KEEP verdicts (dirty/unmerged/in-use) are reported, not forced.
193
- - Flag **uncommitted** work or edits **outside the fence**.
194
- - **Stop/abort a running CLI:** use **`TaskStop <task_id>`** (if `run_in_background`/Workflow) OR
195
- **`git worktree remove --force <worktree>`** (pulls the rug — the CLI has nowhere to write and dies). Fallback:
196
- `kill -9` **only** the PIDs from `pgrep -af "<cli> "` whose `/proc/<pid>/cmdline` matches the worktree tag.
197
- **NEVER walk UP the process tree (ppid → ppid…) to kill "the supervisor":** the background CLI is a **child of
198
- the Claude session itself** (`<cli> ← claude ← bash ← init`) → killing the ancestors **takes down the session**.
199
- Apparent "respawns" are just the node workers of ONE run.
30
+ 1. Resolve the assignment from the approved task matrix; `.dw/config/routing.json` only supplies candidates for missing choices. Use current explicit instructions before saved assignments. Do not re-ask approved model/effort choices. An unavailable model uses only an approved fallback, otherwise report the exact blocker.
31
+ 2. Read the task prompt, relevant source and constraints. Check dependencies exist on the execution branch. Give the worker acceptance criteria, file scope, verification commands, permission boundaries, and a stopping condition: implemented and verified, or a concrete blocker. No recursive dispatch to another implementation CLI.
32
+ 3. Persist assignment, task identity, attempt, worktree/base, prompt and audit paths in `execution-state.json`. Store logs and session sidecars outside disposable worktrees. Capture the stream and final report; never discard error output. Do not claim the stream exposes private reasoning or every internal event.
33
+ 4. Run in a background process or bounded agent supported by the host. No mandatory extra agent layer. Read `references/dispatch-tuning.md` only for permission/MCP tuning, diagnostics or escalation.
34
+ 5. Persist the exact provider session ID. On resume, verify task/provider/worktree identity from state and audit. Missing sidecar: recover that task's session from its log; if unrecoverable, start a fresh session in the same worktree with the task, diff and checkpoint. Never blindly resume the latest session. Never reset/clean partial work to retry.
35
+ 6. Completion requires the terminal event, process outcome, and inspected files/report. A completed turn is not proof of task success. Poll the process handle or task notification; searching for the worktree path with `pgrep` can match the observer itself.
36
+ 7. Parent re-gate (independent): the parent re-gates by inspecting diff, acceptance criteria and blocking findings, and validating worker evidence with `dw-verify`. Reuse equivalent evidence rather than mechanically repeating the same suite. Send in-scope corrections to the same worker and continue approved dependent tasks.
37
+ 8. Keep model/effort on normal corrections. Escalate only on demonstrated capability limits to a supported, approved alternative. A numeric score is optional diagnostic information, never an acceptance gate. At an impasse preserve work, report the blocker, and continue independent authorized tasks.
200
38
 
201
- ## Anti-patterns
202
- - Running in the main checkout / without confirming the worktree — corrupts the active tree. *(pre-flight 2)*
203
- - Merging/pushing inside the skill — merge lives outside, after the gate.
204
- - Skipping the 0–10 score — loses the quality/escalation signal.
205
- - Suppressing all output (or not capturing the stream to a log) — loses the audit of what the CLI did.
206
- - **Detecting "done" by `pgrep` of the worktree path** — self-matches your own command → false "running" that
207
- holds ready deliveries. Use `DONE_SIGNAL` + worktree. *(step 6)*
208
- - **Killing the CLI by walking up the PID tree** — takes down the Claude session. Use `TaskStop`/`worktree
209
- remove`. *(Discipline)*
210
- - Losing the session-id — without the sidecar you can't resume the SAME context; capture it on the first run.
39
+ WRITE runs arm `/dw-report` once (`armed_by: dw-cli-run`) (idempotent, skipped when `DW_REPORT_AUTO=off`). On cancellation stop only the recorded task handle/PID, preserve files and logs, and disarm reporting. Never remove a worktree to kill its worker or walk up the process tree. The parent uses `/dw-worktree merge <slug>` for authorized merge and cleanup in the same turn (end-of-life); KEEP worktrees remain intact.
211
40
 
212
41
  ## Structured Return
213
- - **Status:** `PASS` · `FINDINGS` · `BLOCKED` · `NOT_APPLICABLE` — `PASS` = ran, score ≥9, stopped clean in the
214
- right worktree, ready for the gate; `FINDINGS` = ran, score 6–8 or caveats (uncommitted/out-of-fence/partial);
215
- `BLOCKED` = missing CLI/credential/worktree/prompt/adapter table, or escalation exhausted without reaching 9;
216
- `NOT_APPLICABLE` = no worktree+prompt → still planning.
217
- - **Score:** **the parent's score** (0–10 — counts for acceptance, bar ≥9) + the **CLI self-score** + the **gap**;
218
- per-criterion rationale (conformance/gate/completeness/hygiene/quality). Large gap = inflated self-score.
219
- - **Scope:** worktree + branch + prompt used; CLI + model + effort + sandbox/auto mode; escalation notches taken.
220
- - **Evidence:** path of the durable audit log + final-message file; stream JSONL excerpt; `git status`/diff of the
221
- worktree post-run.
222
- - **Artifacts:** files created/changed (diff summary); **the session-id + sidecar path** (`<AUDIT>/<slug>.session`)
223
- so a later turn can resume; the durable audit log path.
224
- - **Decisions:** model/effort and why; implementation vs read-only; continue (resume) vs reset on retry.
225
- - **Risks:** out of fence, uncommitted, gate not run, dual-use (autonomous edits).
226
- - **Telemetry:** tokens from the done event (input/cached/output/reasoning + **effective billable**) + **wall-clock**
227
- + command count.
228
- - **Next Step:** "run the gate in the worktree; merge is the owner's decision" — and the exact resume command
229
- (`RESUME <id>`) to continue this session.
230
42
 
231
- ## Notes
232
- The CLI-specific flag names, model list, resume form, and session-id capture live in the **adapter table** of the
233
- invoking command (`dw-codex-run` / `dw-claude-run` / `dw-copilot-run`). This skill holds the CLI-agnostic protocol
234
- only; substitute the adapter slots and everything above applies unchanged.
43
+ - **Status:** `PASS` task acceptance and required checks satisfied; `FINDINGS` corrections remain; `BLOCKED` unavailable executor, permissions or unresolved decision; `NOT_APPLICABLE` no CLI execution in scope.
44
+ - **Scope:** task, worktree/branch/base, provider, model, effort, agents and permission mode.
45
+ - **Evidence:** inspected diff, acceptance checks, verification records, process outcome and durable audit path.
46
+ - **Artifacts:** changed files, commits, exact provider session ID and sidecar, execution state, report.
47
+ - **Decisions:** approved assignment/fallback used, corrections, session recovery or new-session reason.
48
+ - **Risks:** outstanding findings, partial work, missing checks or lost conversational context.
49
+ - **Telemetry:** observed tokens, elapsed time and command counts when available; label unavailable fields, never estimate billing from undocumented fields.
50
+ - **Next Step:** parent review/correction/next task, or concrete blocker; merge/push only under applicable authorization.