cclaw-cli 7.7.1 → 8.1.1
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/README.md +211 -134
- package/dist/artifact-frontmatter.d.ts +51 -0
- package/dist/artifact-frontmatter.js +131 -0
- package/dist/artifact-paths.d.ts +7 -27
- package/dist/artifact-paths.js +20 -249
- package/dist/cancel.d.ts +16 -0
- package/dist/cancel.js +66 -0
- package/dist/cli.d.ts +2 -27
- package/dist/cli.js +107 -511
- package/dist/compound.d.ts +26 -0
- package/dist/compound.js +96 -0
- package/dist/config.d.ts +14 -51
- package/dist/config.js +23 -359
- package/dist/constants.d.ts +11 -18
- package/dist/constants.js +19 -106
- package/dist/content/antipatterns.d.ts +1 -0
- package/dist/content/antipatterns.js +109 -0
- package/dist/content/artifact-templates.d.ts +10 -0
- package/dist/content/artifact-templates.js +550 -0
- package/dist/content/cancel-command.d.ts +2 -2
- package/dist/content/cancel-command.js +25 -17
- package/dist/content/core-agents.d.ts +9 -233
- package/dist/content/core-agents.js +39 -768
- package/dist/content/decision-protocol.d.ts +1 -12
- package/dist/content/decision-protocol.js +27 -20
- package/dist/content/examples.d.ts +8 -42
- package/dist/content/examples.js +293 -425
- package/dist/content/idea-command.d.ts +2 -0
- package/dist/content/idea-command.js +38 -0
- package/dist/content/iron-laws.d.ts +4 -138
- package/dist/content/iron-laws.js +18 -197
- package/dist/content/meta-skill.d.ts +1 -3
- package/dist/content/meta-skill.js +57 -134
- package/dist/content/node-hooks.d.ts +12 -8
- package/dist/content/node-hooks.js +188 -838
- package/dist/content/recovery.d.ts +8 -0
- package/dist/content/recovery.js +179 -0
- package/dist/content/reference-patterns.d.ts +4 -13
- package/dist/content/reference-patterns.js +260 -389
- package/dist/content/research-playbooks.d.ts +8 -8
- package/dist/content/research-playbooks.js +108 -121
- package/dist/content/review-loop.d.ts +6 -192
- package/dist/content/review-loop.js +29 -731
- package/dist/content/skills.d.ts +8 -38
- package/dist/content/skills.js +681 -732
- package/dist/content/specialist-prompts/architect.d.ts +1 -0
- package/dist/content/specialist-prompts/architect.js +225 -0
- package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
- package/dist/content/specialist-prompts/brainstormer.js +168 -0
- package/dist/content/specialist-prompts/index.d.ts +2 -0
- package/dist/content/specialist-prompts/index.js +14 -0
- package/dist/content/specialist-prompts/planner.d.ts +1 -0
- package/dist/content/specialist-prompts/planner.js +182 -0
- package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/reviewer.js +193 -0
- package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/security-reviewer.js +133 -0
- package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
- package/dist/content/specialist-prompts/slice-builder.js +232 -0
- package/dist/content/stage-playbooks.d.ts +8 -0
- package/dist/content/stage-playbooks.js +404 -0
- package/dist/content/start-command.d.ts +2 -12
- package/dist/content/start-command.js +221 -207
- package/dist/flow-state.d.ts +21 -178
- package/dist/flow-state.js +67 -170
- package/dist/fs-utils.d.ts +6 -26
- package/dist/fs-utils.js +29 -162
- package/dist/gitignore.d.ts +2 -1
- package/dist/gitignore.js +51 -34
- package/dist/harness-detect.d.ts +10 -0
- package/dist/harness-detect.js +29 -0
- package/dist/harness-prompt.d.ts +26 -0
- package/dist/harness-prompt.js +142 -0
- package/dist/install.d.ts +35 -15
- package/dist/install.js +238 -1347
- package/dist/knowledge-store.d.ts +19 -163
- package/dist/knowledge-store.js +56 -590
- package/dist/logger.d.ts +8 -3
- package/dist/logger.js +13 -4
- package/dist/orchestrator-routing.d.ts +29 -0
- package/dist/orchestrator-routing.js +156 -0
- package/dist/run-persistence.d.ts +7 -118
- package/dist/run-persistence.js +29 -845
- package/dist/runtime/run-hook.entry.d.ts +1 -3
- package/dist/runtime/run-hook.entry.js +19 -4
- package/dist/runtime/run-hook.mjs +13 -1024
- package/dist/types.d.ts +25 -261
- package/dist/types.js +8 -36
- package/package.json +6 -3
- package/dist/artifact-linter/brainstorm.d.ts +0 -2
- package/dist/artifact-linter/brainstorm.js +0 -353
- package/dist/artifact-linter/design.d.ts +0 -18
- package/dist/artifact-linter/design.js +0 -444
- package/dist/artifact-linter/findings-dedup.d.ts +0 -56
- package/dist/artifact-linter/findings-dedup.js +0 -232
- package/dist/artifact-linter/plan.d.ts +0 -2
- package/dist/artifact-linter/plan.js +0 -826
- package/dist/artifact-linter/review-army.d.ts +0 -49
- package/dist/artifact-linter/review-army.js +0 -520
- package/dist/artifact-linter/review.d.ts +0 -2
- package/dist/artifact-linter/review.js +0 -113
- package/dist/artifact-linter/scope.d.ts +0 -2
- package/dist/artifact-linter/scope.js +0 -158
- package/dist/artifact-linter/shared.d.ts +0 -637
- package/dist/artifact-linter/shared.js +0 -2163
- package/dist/artifact-linter/ship.d.ts +0 -2
- package/dist/artifact-linter/ship.js +0 -250
- package/dist/artifact-linter/spec.d.ts +0 -2
- package/dist/artifact-linter/spec.js +0 -176
- package/dist/artifact-linter/tdd.d.ts +0 -118
- package/dist/artifact-linter/tdd.js +0 -1404
- package/dist/artifact-linter.d.ts +0 -15
- package/dist/artifact-linter.js +0 -517
- package/dist/codex-feature-flag.d.ts +0 -58
- package/dist/codex-feature-flag.js +0 -193
- package/dist/content/closeout-guidance.d.ts +0 -14
- package/dist/content/closeout-guidance.js +0 -44
- package/dist/content/diff-command.d.ts +0 -1
- package/dist/content/diff-command.js +0 -43
- package/dist/content/harness-doc.d.ts +0 -1
- package/dist/content/harness-doc.js +0 -65
- package/dist/content/hook-events.d.ts +0 -9
- package/dist/content/hook-events.js +0 -23
- package/dist/content/hook-manifest.d.ts +0 -81
- package/dist/content/hook-manifest.js +0 -156
- package/dist/content/hooks.d.ts +0 -11
- package/dist/content/hooks.js +0 -1972
- package/dist/content/idea.d.ts +0 -60
- package/dist/content/idea.js +0 -416
- package/dist/content/language-policy.d.ts +0 -2
- package/dist/content/language-policy.js +0 -13
- package/dist/content/learnings.d.ts +0 -6
- package/dist/content/learnings.js +0 -141
- package/dist/content/observe.d.ts +0 -19
- package/dist/content/observe.js +0 -86
- package/dist/content/opencode-plugin.d.ts +0 -1
- package/dist/content/opencode-plugin.js +0 -635
- package/dist/content/review-prompts.d.ts +0 -1
- package/dist/content/review-prompts.js +0 -104
- package/dist/content/runtime-shared-snippets.d.ts +0 -8
- package/dist/content/runtime-shared-snippets.js +0 -80
- package/dist/content/session-hooks.d.ts +0 -7
- package/dist/content/session-hooks.js +0 -107
- package/dist/content/skills-elicitation.d.ts +0 -1
- package/dist/content/skills-elicitation.js +0 -167
- package/dist/content/stage-command.d.ts +0 -2
- package/dist/content/stage-command.js +0 -17
- package/dist/content/stage-schema.d.ts +0 -117
- package/dist/content/stage-schema.js +0 -955
- package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
- package/dist/content/stages/_lint-metadata/index.js +0 -97
- package/dist/content/stages/brainstorm.d.ts +0 -2
- package/dist/content/stages/brainstorm.js +0 -184
- package/dist/content/stages/design.d.ts +0 -2
- package/dist/content/stages/design.js +0 -288
- package/dist/content/stages/index.d.ts +0 -8
- package/dist/content/stages/index.js +0 -11
- package/dist/content/stages/plan.d.ts +0 -2
- package/dist/content/stages/plan.js +0 -191
- package/dist/content/stages/review.d.ts +0 -2
- package/dist/content/stages/review.js +0 -240
- package/dist/content/stages/schema-types.d.ts +0 -203
- package/dist/content/stages/schema-types.js +0 -1
- package/dist/content/stages/scope.d.ts +0 -2
- package/dist/content/stages/scope.js +0 -254
- package/dist/content/stages/ship.d.ts +0 -2
- package/dist/content/stages/ship.js +0 -159
- package/dist/content/stages/spec.d.ts +0 -2
- package/dist/content/stages/spec.js +0 -170
- package/dist/content/stages/tdd.d.ts +0 -4
- package/dist/content/stages/tdd.js +0 -273
- package/dist/content/state-contracts.d.ts +0 -1
- package/dist/content/state-contracts.js +0 -63
- package/dist/content/status-command.d.ts +0 -4
- package/dist/content/status-command.js +0 -109
- package/dist/content/subagent-context-skills.d.ts +0 -4
- package/dist/content/subagent-context-skills.js +0 -279
- package/dist/content/subagents.d.ts +0 -3
- package/dist/content/subagents.js +0 -997
- package/dist/content/templates.d.ts +0 -26
- package/dist/content/templates.js +0 -1692
- package/dist/content/track-render-context.d.ts +0 -18
- package/dist/content/track-render-context.js +0 -53
- package/dist/content/tree-command.d.ts +0 -1
- package/dist/content/tree-command.js +0 -64
- package/dist/content/utility-skills.d.ts +0 -30
- package/dist/content/utility-skills.js +0 -160
- package/dist/content/view-command.d.ts +0 -2
- package/dist/content/view-command.js +0 -92
- package/dist/delegation.d.ts +0 -649
- package/dist/delegation.js +0 -1539
- package/dist/early-loop.d.ts +0 -70
- package/dist/early-loop.js +0 -302
- package/dist/execution-topology.d.ts +0 -44
- package/dist/execution-topology.js +0 -95
- package/dist/gate-evidence.d.ts +0 -85
- package/dist/gate-evidence.js +0 -631
- package/dist/harness-adapters.d.ts +0 -151
- package/dist/harness-adapters.js +0 -756
- package/dist/harness-selection.d.ts +0 -31
- package/dist/harness-selection.js +0 -214
- package/dist/hook-schema.d.ts +0 -6
- package/dist/hook-schema.js +0 -114
- package/dist/hook-schemas/claude-hooks.v1.json +0 -10
- package/dist/hook-schemas/codex-hooks.v1.json +0 -10
- package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
- package/dist/init-detect.d.ts +0 -2
- package/dist/init-detect.js +0 -50
- package/dist/internal/advance-stage/advance.d.ts +0 -89
- package/dist/internal/advance-stage/advance.js +0 -655
- package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
- package/dist/internal/advance-stage/cancel-run.js +0 -19
- package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
- package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
- package/dist/internal/advance-stage/helpers.d.ts +0 -14
- package/dist/internal/advance-stage/helpers.js +0 -145
- package/dist/internal/advance-stage/hook.d.ts +0 -8
- package/dist/internal/advance-stage/hook.js +0 -40
- package/dist/internal/advance-stage/parsers.d.ts +0 -72
- package/dist/internal/advance-stage/parsers.js +0 -357
- package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
- package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
- package/dist/internal/advance-stage/review-loop.d.ts +0 -16
- package/dist/internal/advance-stage/review-loop.js +0 -199
- package/dist/internal/advance-stage/rewind.d.ts +0 -14
- package/dist/internal/advance-stage/rewind.js +0 -108
- package/dist/internal/advance-stage/start-flow.d.ts +0 -13
- package/dist/internal/advance-stage/start-flow.js +0 -241
- package/dist/internal/advance-stage/verify.d.ts +0 -21
- package/dist/internal/advance-stage/verify.js +0 -185
- package/dist/internal/advance-stage.d.ts +0 -7
- package/dist/internal/advance-stage.js +0 -138
- package/dist/internal/cohesion-contract-stub.d.ts +0 -24
- package/dist/internal/cohesion-contract-stub.js +0 -148
- package/dist/internal/compound-readiness.d.ts +0 -23
- package/dist/internal/compound-readiness.js +0 -102
- package/dist/internal/detect-public-api-changes.d.ts +0 -5
- package/dist/internal/detect-public-api-changes.js +0 -45
- package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
- package/dist/internal/detect-supply-chain-changes.js +0 -138
- package/dist/internal/early-loop-status.d.ts +0 -7
- package/dist/internal/early-loop-status.js +0 -93
- package/dist/internal/envelope-validate.d.ts +0 -7
- package/dist/internal/envelope-validate.js +0 -66
- package/dist/internal/flow-state-repair.d.ts +0 -20
- package/dist/internal/flow-state-repair.js +0 -104
- package/dist/internal/plan-split-waves.d.ts +0 -190
- package/dist/internal/plan-split-waves.js +0 -764
- package/dist/internal/runtime-integrity.d.ts +0 -7
- package/dist/internal/runtime-integrity.js +0 -268
- package/dist/internal/slice-commit.d.ts +0 -7
- package/dist/internal/slice-commit.js +0 -619
- package/dist/internal/tdd-loop-status.d.ts +0 -14
- package/dist/internal/tdd-loop-status.js +0 -68
- package/dist/internal/tdd-red-evidence.d.ts +0 -7
- package/dist/internal/tdd-red-evidence.js +0 -153
- package/dist/internal/waiver-grant.d.ts +0 -62
- package/dist/internal/waiver-grant.js +0 -294
- package/dist/internal/wave-status.d.ts +0 -74
- package/dist/internal/wave-status.js +0 -506
- package/dist/managed-resources.d.ts +0 -53
- package/dist/managed-resources.js +0 -313
- package/dist/policy.d.ts +0 -10
- package/dist/policy.js +0 -167
- package/dist/retro-gate.d.ts +0 -9
- package/dist/retro-gate.js +0 -47
- package/dist/run-archive.d.ts +0 -61
- package/dist/run-archive.js +0 -391
- package/dist/runs.d.ts +0 -2
- package/dist/runs.js +0 -2
- package/dist/stack-detection.d.ts +0 -116
- package/dist/stack-detection.js +0 -489
- package/dist/streaming/event-stream.d.ts +0 -31
- package/dist/streaming/event-stream.js +0 -114
- package/dist/tdd-cycle.d.ts +0 -107
- package/dist/tdd-cycle.js +0 -289
- package/dist/tdd-verification-evidence.d.ts +0 -17
- package/dist/tdd-verification-evidence.js +0 -122
- package/dist/track-heuristics.d.ts +0 -27
- package/dist/track-heuristics.js +0 -154
- package/dist/util/slice-id.d.ts +0 -58
- package/dist/util/slice-id.js +0 -89
- package/dist/worktree-manager.d.ts +0 -20
- package/dist/worktree-manager.js +0 -108
|
@@ -1,955 +0,0 @@
|
|
|
1
|
-
import { FLOW_STAGES, FLOW_TRACKS, TRACK_STAGES } from "../types.js";
|
|
2
|
-
import { STAGE_TO_SKILL_FOLDER } from "../constants.js";
|
|
3
|
-
import { BRAINSTORM, SCOPE, DESIGN, SPEC, PLAN, TDD, REVIEW, SHIP } from "./stages/index.js";
|
|
4
|
-
import { stagePolicyNeedlesFromMetadata } from "./stages/_lint-metadata/index.js";
|
|
5
|
-
import { tddStageForTrack } from "./stages/tdd.js";
|
|
6
|
-
import { trackRenderContext } from "./track-render-context.js";
|
|
7
|
-
import { STACK_REVIEW_ROUTE_PROFILES } from "../stack-detection.js";
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// NOTE: The former QUESTION_FORMAT_SPEC / ERROR_BUDGET_SPEC exports were
|
|
10
|
-
// hoisted into `src/content/meta-skill.ts` (Shared Decision + Tool-Use
|
|
11
|
-
// Protocol). They are no longer re-exported from here to avoid duplication
|
|
12
|
-
// and drift. Stage skills cite the meta-skill by path instead.
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Optional artifact appendix (documentation-only — not a tiered gate)
|
|
16
|
-
//
|
|
17
|
-
// `## Amendments` — after a stage is closed, substantive edits SHOULD append dated
|
|
18
|
-
// bullets (ISO timestamp + reason) here instead of silently rewriting history. The
|
|
19
|
-
// linter surfaces advisory `stage_artifact_post_closure_mutation` findings when mtimes
|
|
20
|
-
// move without this trail (`completedStageMeta` must exist).
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
export const SKILL_ENVELOPE_KINDS = [
|
|
23
|
-
"stage-output",
|
|
24
|
-
"gate-result",
|
|
25
|
-
"delegation-record"
|
|
26
|
-
];
|
|
27
|
-
export const NON_FLOW_ENVELOPE_STAGE = "non-flow";
|
|
28
|
-
const FLOW_STAGE_SET = new Set(FLOW_STAGES);
|
|
29
|
-
const SKILL_ENVELOPE_KIND_SET = new Set(SKILL_ENVELOPE_KINDS);
|
|
30
|
-
const COMPLEXITY_TIER_ORDER = {
|
|
31
|
-
lightweight: 0,
|
|
32
|
-
standard: 1,
|
|
33
|
-
deep: 2
|
|
34
|
-
};
|
|
35
|
-
const REVIEW_STACK_AWARE_ROUTES = STACK_REVIEW_ROUTE_PROFILES.map((profile) => ({
|
|
36
|
-
stack: profile.stack,
|
|
37
|
-
agent: "reviewer",
|
|
38
|
-
signals: [...profile.reviewSignals],
|
|
39
|
-
focus: profile.focus
|
|
40
|
-
}));
|
|
41
|
-
function stackAwareRoutesForStage(stage) {
|
|
42
|
-
return stage === "review" ? reviewStackAwareRoutes() : [];
|
|
43
|
-
}
|
|
44
|
-
export function reviewStackAwareRoutes() {
|
|
45
|
-
return REVIEW_STACK_AWARE_ROUTES.map((route) => ({
|
|
46
|
-
...route,
|
|
47
|
-
signals: [...route.signals]
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
export function reviewStackAwareRoutingSummary() {
|
|
51
|
-
const routeList = REVIEW_STACK_AWARE_ROUTES
|
|
52
|
-
.map((route) => `${route.stack} via ${route.signals.join("/")}`)
|
|
53
|
-
.join("; ");
|
|
54
|
-
return `Stack-aware review routing: keep the default reviewer and security-reviewer passes, then proactively route matching reviewer lenses when repo signals or review context match (${routeList}). Do not run every stack lens unconditionally.`;
|
|
55
|
-
}
|
|
56
|
-
function dedupeAgentsInOrder(agents) {
|
|
57
|
-
const out = [];
|
|
58
|
-
const seen = new Set();
|
|
59
|
-
for (const agent of agents) {
|
|
60
|
-
if (seen.has(agent))
|
|
61
|
-
continue;
|
|
62
|
-
seen.add(agent);
|
|
63
|
-
out.push(agent);
|
|
64
|
-
}
|
|
65
|
-
return out;
|
|
66
|
-
}
|
|
67
|
-
function discoveryModeTier(mode) {
|
|
68
|
-
if (mode === "lean")
|
|
69
|
-
return "lightweight";
|
|
70
|
-
if (mode === "deep")
|
|
71
|
-
return "deep";
|
|
72
|
-
return "standard";
|
|
73
|
-
}
|
|
74
|
-
function resolvedStageComplexityTier(params) {
|
|
75
|
-
const base = params.defaultTier ?? "standard";
|
|
76
|
-
const earlyStage = params.stage === "brainstorm" || params.stage === "scope" || params.stage === "design";
|
|
77
|
-
if (!earlyStage || params.discoveryMode === undefined)
|
|
78
|
-
return base;
|
|
79
|
-
return discoveryModeTier(params.discoveryMode);
|
|
80
|
-
}
|
|
81
|
-
function defaultReturnSchemaForAgent(agent) {
|
|
82
|
-
switch (agent) {
|
|
83
|
-
case "researcher":
|
|
84
|
-
return "research-return";
|
|
85
|
-
case "architect":
|
|
86
|
-
return "architecture-return";
|
|
87
|
-
case "spec-validator":
|
|
88
|
-
return "spec-validation-return";
|
|
89
|
-
case "spec-document-reviewer":
|
|
90
|
-
case "coherence-reviewer":
|
|
91
|
-
case "scope-guardian-reviewer":
|
|
92
|
-
case "feasibility-reviewer":
|
|
93
|
-
return "review-return";
|
|
94
|
-
case "slice-builder":
|
|
95
|
-
return "worker-return";
|
|
96
|
-
case "release-reviewer":
|
|
97
|
-
return "release-return";
|
|
98
|
-
case "planner":
|
|
99
|
-
return "planning-return";
|
|
100
|
-
case "product-discovery":
|
|
101
|
-
return "product-return";
|
|
102
|
-
case "divergent-thinker":
|
|
103
|
-
case "critic":
|
|
104
|
-
return "critic-return";
|
|
105
|
-
case "reviewer":
|
|
106
|
-
case "integration-overseer":
|
|
107
|
-
return "review-return";
|
|
108
|
-
case "security-reviewer":
|
|
109
|
-
return "security-return";
|
|
110
|
-
case "doc-updater":
|
|
111
|
-
return "docs-return";
|
|
112
|
-
case "fixer":
|
|
113
|
-
return "fixer-return";
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function dispatchClassForRow(row) {
|
|
117
|
-
if (row.dispatchClass)
|
|
118
|
-
return row.dispatchClass;
|
|
119
|
-
if (row.agent === "fixer" || row.agent === "slice-builder")
|
|
120
|
-
return "worker";
|
|
121
|
-
return row.skill?.includes("review") || row.agent === "reviewer" || row.agent === "security-reviewer" || row.agent.endsWith("-reviewer")
|
|
122
|
-
? "review-lens"
|
|
123
|
-
: "stage-specialist";
|
|
124
|
-
}
|
|
125
|
-
function delegationDispatchRule(row) {
|
|
126
|
-
return {
|
|
127
|
-
agent: row.agent,
|
|
128
|
-
mode: row.mode,
|
|
129
|
-
when: row.when,
|
|
130
|
-
purpose: row.purpose,
|
|
131
|
-
requiresUserGate: row.requiresUserGate,
|
|
132
|
-
requiredAtTier: row.requiredAtTier,
|
|
133
|
-
dispatchClass: dispatchClassForRow(row),
|
|
134
|
-
returnSchema: row.returnSchema ?? defaultReturnSchemaForAgent(row.agent),
|
|
135
|
-
skill: row.skill
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Canonical delegation summary derived from STAGE_AUTO_SUBAGENT_DISPATCH.
|
|
140
|
-
*
|
|
141
|
-
* Keep all generated routing surfaces (skills, AGENTS.md) on this helper so
|
|
142
|
-
* stage->agent defaults are maintained in one place.
|
|
143
|
-
*/
|
|
144
|
-
export function stageDelegationSummary(complexityTier = "standard") {
|
|
145
|
-
const currentTierRank = COMPLEXITY_TIER_ORDER[complexityTier];
|
|
146
|
-
return FLOW_STAGES.map((stage) => {
|
|
147
|
-
const eligibleRows = STAGE_AUTO_SUBAGENT_DISPATCH[stage].filter((row) => {
|
|
148
|
-
const requiredAt = row.requiredAtTier ?? "standard";
|
|
149
|
-
return currentTierRank >= COMPLEXITY_TIER_ORDER[requiredAt];
|
|
150
|
-
});
|
|
151
|
-
const mandatoryAgents = dedupeAgentsInOrder(eligibleRows
|
|
152
|
-
.filter((row) => row.mode === "mandatory")
|
|
153
|
-
.map((row) => row.agent));
|
|
154
|
-
const proactiveAgents = dedupeAgentsInOrder(eligibleRows
|
|
155
|
-
.filter((row) => row.mode === "proactive")
|
|
156
|
-
.map((row) => row.agent));
|
|
157
|
-
const primaryAgents = dedupeAgentsInOrder([...mandatoryAgents, ...proactiveAgents]);
|
|
158
|
-
return {
|
|
159
|
-
stage,
|
|
160
|
-
mandatoryAgents,
|
|
161
|
-
proactiveAgents,
|
|
162
|
-
primaryAgents,
|
|
163
|
-
dispatchRules: eligibleRows.map(delegationDispatchRule),
|
|
164
|
-
stackAwareRoutes: stackAwareRoutesForStage(stage)
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function asRecord(value) {
|
|
169
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
return value;
|
|
173
|
-
}
|
|
174
|
-
export function validateSkillEnvelope(value) {
|
|
175
|
-
const errors = [];
|
|
176
|
-
const record = asRecord(value);
|
|
177
|
-
if (!record) {
|
|
178
|
-
return { ok: false, errors: ["envelope must be a JSON object"] };
|
|
179
|
-
}
|
|
180
|
-
if (record.version !== "1") {
|
|
181
|
-
errors.push('envelope.version must equal "1".');
|
|
182
|
-
}
|
|
183
|
-
if (typeof record.kind !== "string" || !SKILL_ENVELOPE_KIND_SET.has(record.kind)) {
|
|
184
|
-
errors.push(`envelope.kind must be one of: ${SKILL_ENVELOPE_KINDS.join(", ")}.`);
|
|
185
|
-
}
|
|
186
|
-
if (typeof record.stage !== "string" ||
|
|
187
|
-
(record.stage !== NON_FLOW_ENVELOPE_STAGE && !FLOW_STAGE_SET.has(record.stage))) {
|
|
188
|
-
errors.push(`envelope.stage must be one of: ${FLOW_STAGES.join(", ")} or ${NON_FLOW_ENVELOPE_STAGE}.`);
|
|
189
|
-
}
|
|
190
|
-
if (!Object.prototype.hasOwnProperty.call(record, "payload")) {
|
|
191
|
-
errors.push("envelope.payload is required.");
|
|
192
|
-
}
|
|
193
|
-
if (typeof record.emittedAt !== "string" || Number.isNaN(Date.parse(record.emittedAt))) {
|
|
194
|
-
errors.push("envelope.emittedAt must be an ISO-8601 timestamp string.");
|
|
195
|
-
}
|
|
196
|
-
if (record.agent !== undefined && typeof record.agent !== "string") {
|
|
197
|
-
errors.push("envelope.agent must be a string when present.");
|
|
198
|
-
}
|
|
199
|
-
return { ok: errors.length === 0, errors };
|
|
200
|
-
}
|
|
201
|
-
export function parseSkillEnvelope(raw) {
|
|
202
|
-
let parsed;
|
|
203
|
-
try {
|
|
204
|
-
parsed = JSON.parse(raw);
|
|
205
|
-
}
|
|
206
|
-
catch {
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
const validation = validateSkillEnvelope(parsed);
|
|
210
|
-
if (!validation.ok) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
return parsed;
|
|
214
|
-
}
|
|
215
|
-
const ARTIFACT_STAGE_BY_PREFIX = {
|
|
216
|
-
"01": "brainstorm",
|
|
217
|
-
"02": "scope",
|
|
218
|
-
"03": "design",
|
|
219
|
-
"04": "spec",
|
|
220
|
-
"05": "plan",
|
|
221
|
-
"06": "tdd",
|
|
222
|
-
"07": "review",
|
|
223
|
-
"08": "ship"
|
|
224
|
-
};
|
|
225
|
-
const ARTIFACT_STAGE_BY_SPECIAL_FILE = {
|
|
226
|
-
"02a-research.md": "design"
|
|
227
|
-
};
|
|
228
|
-
function stageFromArtifactPath(artifactPath) {
|
|
229
|
-
const normalized = artifactPath.replace(/\\/gu, "/");
|
|
230
|
-
const fileName = normalized.split("/").pop() ?? normalized;
|
|
231
|
-
const special = ARTIFACT_STAGE_BY_SPECIAL_FILE[fileName];
|
|
232
|
-
if (special) {
|
|
233
|
-
return special;
|
|
234
|
-
}
|
|
235
|
-
const match = /^(\d{2})(?:[a-z])?-/u.exec(fileName);
|
|
236
|
-
if (!match) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
return ARTIFACT_STAGE_BY_PREFIX[match[1]] ?? null;
|
|
240
|
-
}
|
|
241
|
-
const REQUIRED_GATE_IDS = {
|
|
242
|
-
brainstorm: [
|
|
243
|
-
"brainstorm_approaches_compared",
|
|
244
|
-
"brainstorm_direction_approved",
|
|
245
|
-
"brainstorm_artifact_reviewed"
|
|
246
|
-
],
|
|
247
|
-
scope: [
|
|
248
|
-
"scope_mode_selected",
|
|
249
|
-
"scope_contract_written",
|
|
250
|
-
"scope_user_approved"
|
|
251
|
-
],
|
|
252
|
-
design: [
|
|
253
|
-
"design_research_complete",
|
|
254
|
-
"design_architecture_locked",
|
|
255
|
-
"design_diagram_freshness",
|
|
256
|
-
"design_data_flow_mapped",
|
|
257
|
-
"design_failure_modes_mapped",
|
|
258
|
-
"design_test_and_perf_defined"
|
|
259
|
-
],
|
|
260
|
-
spec: [
|
|
261
|
-
"spec_ac_ids_present",
|
|
262
|
-
"spec_acceptance_measurable",
|
|
263
|
-
"spec_testability_confirmed",
|
|
264
|
-
"spec_assumptions_surfaced",
|
|
265
|
-
"spec_self_review_complete",
|
|
266
|
-
"spec_user_approved"
|
|
267
|
-
],
|
|
268
|
-
plan: [
|
|
269
|
-
"plan_tasks_sliced_2_5_min",
|
|
270
|
-
"plan_dependency_batches_defined",
|
|
271
|
-
"plan_acceptance_mapped",
|
|
272
|
-
"plan_execution_posture_recorded",
|
|
273
|
-
"plan_parallel_exec_full_coverage",
|
|
274
|
-
"plan_wave_paths_disjoint",
|
|
275
|
-
"plan_module_introducing_slice_wires_root",
|
|
276
|
-
"plan_wait_for_confirm"
|
|
277
|
-
],
|
|
278
|
-
tdd: (track) => [
|
|
279
|
-
"tdd_test_discovery_complete",
|
|
280
|
-
"tdd_impact_check_complete",
|
|
281
|
-
"tdd_red_test_written",
|
|
282
|
-
"tdd_green_full_suite",
|
|
283
|
-
"tdd_refactor_completed",
|
|
284
|
-
"tdd_verified_before_complete",
|
|
285
|
-
"tdd_iron_law_acknowledged",
|
|
286
|
-
"tdd_watched_red_observed",
|
|
287
|
-
"tdd_slice_cycle_complete",
|
|
288
|
-
"tdd_slice_closes_ac",
|
|
289
|
-
"slice_no_orphan_changes",
|
|
290
|
-
"tdd_docs_drift_check",
|
|
291
|
-
...(track === "quick" ? [] : ["tdd_traceable_to_plan"])
|
|
292
|
-
],
|
|
293
|
-
review: (track) => [
|
|
294
|
-
"review_layer1_spec_compliance",
|
|
295
|
-
"review_layer2_security",
|
|
296
|
-
"review_layer_coverage_complete",
|
|
297
|
-
"review_criticals_resolved",
|
|
298
|
-
"review_army_json_valid"
|
|
299
|
-
],
|
|
300
|
-
ship: [
|
|
301
|
-
"ship_review_verdict_valid",
|
|
302
|
-
"ship_preflight_passed",
|
|
303
|
-
"ship_rollback_plan_ready",
|
|
304
|
-
"ship_all_acceptance_criteria_have_commits",
|
|
305
|
-
"ship_finalization_executed"
|
|
306
|
-
]
|
|
307
|
-
};
|
|
308
|
-
const REQUIRED_ARTIFACT_SECTIONS = {
|
|
309
|
-
brainstorm: [
|
|
310
|
-
"Context",
|
|
311
|
-
"Problem Decision Record",
|
|
312
|
-
"Approach Tier",
|
|
313
|
-
"Approaches",
|
|
314
|
-
"Approach Reaction",
|
|
315
|
-
"Selected Direction"
|
|
316
|
-
],
|
|
317
|
-
scope: ["Scope Contract", "Scope Mode", "In Scope / Out of Scope", "Completion Dashboard", "Scope Summary"],
|
|
318
|
-
design: [
|
|
319
|
-
"Research Fleet Synthesis",
|
|
320
|
-
"Engineering Lock",
|
|
321
|
-
"Architecture Boundaries",
|
|
322
|
-
"Architecture Diagram",
|
|
323
|
-
"Failure Mode Table",
|
|
324
|
-
"Security & Threat Model",
|
|
325
|
-
"Observability & Debuggability",
|
|
326
|
-
"Deployment & Rollout",
|
|
327
|
-
"Spec Handoff",
|
|
328
|
-
"Completion Dashboard"
|
|
329
|
-
],
|
|
330
|
-
spec: [
|
|
331
|
-
"Acceptance Criteria",
|
|
332
|
-
"Edge Cases",
|
|
333
|
-
"Assumptions Before Finalization",
|
|
334
|
-
"Acceptance Mapping",
|
|
335
|
-
"Spec Self-Review",
|
|
336
|
-
"Approval"
|
|
337
|
-
],
|
|
338
|
-
plan: ["Task List", "Dependency Batches", "Acceptance Mapping", "Execution Posture", "WAIT_FOR_CONFIRM"],
|
|
339
|
-
tdd: [
|
|
340
|
-
"System-Wide Impact Check",
|
|
341
|
-
"RED Evidence",
|
|
342
|
-
"GREEN Evidence",
|
|
343
|
-
"REFACTOR Notes",
|
|
344
|
-
"Traceability",
|
|
345
|
-
"Iron Law Acknowledgement",
|
|
346
|
-
"Verification Ladder"
|
|
347
|
-
],
|
|
348
|
-
review: ["Review Evidence Scope", "Changed-File Coverage", "Layer 1 Verdict", "Review Findings Contract", "Severity Summary", "Final Verdict"],
|
|
349
|
-
ship: ["Preflight Results", "Release Notes", "Traceability Matrix", "Rollback Plan", "Finalization"]
|
|
350
|
-
};
|
|
351
|
-
function resolveRequiredGateIds(stage, track) {
|
|
352
|
-
const raw = REQUIRED_GATE_IDS[stage];
|
|
353
|
-
return typeof raw === "function" ? raw(track) : raw;
|
|
354
|
-
}
|
|
355
|
-
function tieredStageGates(stage, gates, track) {
|
|
356
|
-
const requiredSet = new Set(resolveRequiredGateIds(stage, track));
|
|
357
|
-
return gates.map((gate) => {
|
|
358
|
-
return {
|
|
359
|
-
...gate,
|
|
360
|
-
tier: requiredSet.has(gate.id) ? "required" : "recommended"
|
|
361
|
-
};
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
function tieredArtifactValidation(stage, rows) {
|
|
365
|
-
const requiredSections = new Set(REQUIRED_ARTIFACT_SECTIONS[stage]);
|
|
366
|
-
return rows.map((row) => {
|
|
367
|
-
const required = requiredSections.has(row.section);
|
|
368
|
-
return {
|
|
369
|
-
...row,
|
|
370
|
-
tier: required ? "required" : "recommended",
|
|
371
|
-
required
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
function readsFromForTrack(readsFrom, track) {
|
|
376
|
-
const stageSet = new Set(TRACK_STAGES[track]);
|
|
377
|
-
return readsFrom.filter((artifactPath) => {
|
|
378
|
-
const stage = stageFromArtifactPath(artifactPath);
|
|
379
|
-
if (!stage) {
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
return stageSet.has(stage);
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
function isStageSchemaV2Input(value) {
|
|
386
|
-
return value.schemaShape === "v2";
|
|
387
|
-
}
|
|
388
|
-
function normalizeStageSchemaInput(value) {
|
|
389
|
-
if (!isStageSchemaV2Input(value)) {
|
|
390
|
-
return value;
|
|
391
|
-
}
|
|
392
|
-
return {
|
|
393
|
-
stage: value.stage,
|
|
394
|
-
skillFolder: value.skillFolder,
|
|
395
|
-
skillName: value.skillName,
|
|
396
|
-
skillDescription: value.skillDescription,
|
|
397
|
-
complexityTier: value.complexityTier,
|
|
398
|
-
hardGate: value.philosophy.hardGate,
|
|
399
|
-
ironLaw: value.philosophy.ironLaw,
|
|
400
|
-
purpose: value.philosophy.purpose,
|
|
401
|
-
whenToUse: value.philosophy.whenToUse,
|
|
402
|
-
whenNotToUse: value.philosophy.whenNotToUse,
|
|
403
|
-
interactionProtocol: value.executionModel.interactionProtocol,
|
|
404
|
-
process: value.executionModel.process,
|
|
405
|
-
processFlow: value.executionModel.processFlow,
|
|
406
|
-
platformNotes: value.executionModel.platformNotes,
|
|
407
|
-
requiredGates: value.executionModel.requiredGates,
|
|
408
|
-
requiredEvidence: value.executionModel.requiredEvidence,
|
|
409
|
-
inputs: value.executionModel.inputs,
|
|
410
|
-
requiredContext: value.executionModel.requiredContext,
|
|
411
|
-
researchPlaybooks: value.executionModel.researchPlaybooks,
|
|
412
|
-
outputs: value.reviewLens.outputs,
|
|
413
|
-
blockers: value.executionModel.blockers,
|
|
414
|
-
exitCriteria: value.executionModel.exitCriteria,
|
|
415
|
-
commonRationalizations: value.philosophy.commonRationalizations,
|
|
416
|
-
artifactFile: value.artifactRules.artifactFile,
|
|
417
|
-
next: value.next,
|
|
418
|
-
checklist: value.executionModel.checklist,
|
|
419
|
-
reviewSections: value.reviewLens.reviewSections,
|
|
420
|
-
reviewLoop: value.reviewLens.reviewLoop,
|
|
421
|
-
completionStatus: value.artifactRules.completionStatus,
|
|
422
|
-
crossStageTrace: value.artifactRules.crossStageTrace,
|
|
423
|
-
artifactValidation: value.artifactRules.artifactValidation,
|
|
424
|
-
batchExecutionAllowed: value.batchExecutionAllowed,
|
|
425
|
-
trivialOverrideSections: value.artifactRules.trivialOverrideSections
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
// ---------------------------------------------------------------------------
|
|
429
|
-
// Stage map and accessors
|
|
430
|
-
// ---------------------------------------------------------------------------
|
|
431
|
-
const STAGE_SCHEMA_MAP = {
|
|
432
|
-
brainstorm: BRAINSTORM,
|
|
433
|
-
scope: SCOPE,
|
|
434
|
-
design: DESIGN,
|
|
435
|
-
spec: SPEC,
|
|
436
|
-
plan: PLAN,
|
|
437
|
-
tdd: TDD,
|
|
438
|
-
review: REVIEW,
|
|
439
|
-
ship: SHIP
|
|
440
|
-
};
|
|
441
|
-
/**
|
|
442
|
-
* Stage-level subagent dispatch matrix.
|
|
443
|
-
*
|
|
444
|
-
* NOTE on `fixer`: the `fixer` agent is intentionally NOT listed in any stage
|
|
445
|
-
* row. It is dispatched on-demand by the SDD `subagent-dev` skill (and by
|
|
446
|
-
* reviewer flows) when a review surfaces a concrete failing criterion that
|
|
447
|
-
* needs a fresh worker. Adding `fixer` to the static matrix would create
|
|
448
|
-
* proactive-waiver theatre because it can only run after a specific review
|
|
449
|
-
* finding exists. See `core-agents.ts` `fixer` definition for the contract.
|
|
450
|
-
*/
|
|
451
|
-
const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
452
|
-
brainstorm: [
|
|
453
|
-
{
|
|
454
|
-
agent: "product-discovery",
|
|
455
|
-
mode: "mandatory",
|
|
456
|
-
requiredAtTier: "standard",
|
|
457
|
-
runPhase: "post-elicitation",
|
|
458
|
-
when: "Always for standard/deep brainstorm to validate value, persona/JTBD, success metric, and why-now framing. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
459
|
-
purpose: "Run product-discovery mode to pressure-test problem/value fit and produce product evidence for the Problem Decision Record.",
|
|
460
|
-
requiresUserGate: false
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
agent: "divergent-thinker",
|
|
464
|
-
mode: "proactive",
|
|
465
|
-
runPhase: "post-elicitation",
|
|
466
|
-
when: "When brainstorm has >1 candidate direction or user signals openness to alternatives. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
467
|
-
purpose: "Expand option-space with alternative framings and approaches before planner/critic convergence.",
|
|
468
|
-
requiresUserGate: false
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
agent: "critic",
|
|
472
|
-
mode: "mandatory",
|
|
473
|
-
requiredAtTier: "standard",
|
|
474
|
-
runPhase: "post-elicitation",
|
|
475
|
-
when: "Always for standard/deep brainstorm to challenge the premise, do-nothing path, and higher-upside alternatives. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
476
|
-
purpose: "Attack assumptions and surface non-goals before direction approval, with pre-commitment predictions validated against evidence.",
|
|
477
|
-
requiresUserGate: false,
|
|
478
|
-
skill: "critic-multi-perspective"
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
agent: "researcher",
|
|
482
|
-
mode: "proactive",
|
|
483
|
-
runPhase: "post-elicitation",
|
|
484
|
-
when: "When repository, market, docs, or prior-art context changes the approach set. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
485
|
-
purpose: "Provide search-before-read summaries and context-readiness evidence before large reads or decisions.",
|
|
486
|
-
requiresUserGate: false,
|
|
487
|
-
essentialAcrossModes: true
|
|
488
|
-
}
|
|
489
|
-
],
|
|
490
|
-
scope: [
|
|
491
|
-
{
|
|
492
|
-
agent: "planner",
|
|
493
|
-
mode: "mandatory",
|
|
494
|
-
requiredAtTier: "standard",
|
|
495
|
-
runPhase: "post-elicitation",
|
|
496
|
-
when: "Always during scope shaping. Runs only after the adaptive elicitation Q&A loop converges and the user has approved the scope contract draft.",
|
|
497
|
-
purpose: "Challenge premise, map alternatives, and produce explicit in/out contract.",
|
|
498
|
-
requiresUserGate: false
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
agent: "divergent-thinker",
|
|
502
|
-
mode: "proactive",
|
|
503
|
-
runPhase: "post-elicitation",
|
|
504
|
-
when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has fewer than 3 alternatives considered. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
505
|
-
purpose: "Generate additional framings and approach variants before scope convergence hardens.",
|
|
506
|
-
requiresUserGate: false
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
agent: "critic",
|
|
510
|
-
mode: "mandatory",
|
|
511
|
-
requiredAtTier: "standard",
|
|
512
|
-
runPhase: "post-elicitation",
|
|
513
|
-
when: "Always during scope shaping for standard/deep work. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
514
|
-
purpose: "Test whether the selected scope mode is too timid, too broad, or hiding a smaller useful slice, using pre-commitment predictions and validation.",
|
|
515
|
-
requiresUserGate: false,
|
|
516
|
-
skill: "critic-multi-perspective"
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
agent: "researcher",
|
|
520
|
-
mode: "proactive",
|
|
521
|
-
runPhase: "post-elicitation",
|
|
522
|
-
when: "When churn, prior attempts, reference patterns, or external constraints may change scope boundaries. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
523
|
-
purpose: "Summarize search/context findings before the scope contract locks accepted/rejected/deferred ideas.",
|
|
524
|
-
requiresUserGate: false,
|
|
525
|
-
essentialAcrossModes: true
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
agent: "product-discovery",
|
|
529
|
-
mode: "proactive",
|
|
530
|
-
runPhase: "post-elicitation",
|
|
531
|
-
when: "When scope choices change user value, success metrics, or product positioning (Mode: discovery). Runs only after the adaptive elicitation Q&A loop converges.",
|
|
532
|
-
purpose: "Keep accepted/deferred reference ideas tied to user value and measurable success under product-discovery mode.",
|
|
533
|
-
requiresUserGate: false
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
agent: "product-discovery",
|
|
537
|
-
mode: "proactive",
|
|
538
|
-
requiredAtTier: "standard",
|
|
539
|
-
runPhase: "post-elicitation",
|
|
540
|
-
when: "When scope mode resolves to SCOPE EXPANSION or SELECTIVE EXPANSION (Mode: strategist). Runs only after the adaptive elicitation Q&A loop converges.",
|
|
541
|
-
purpose: "Drive 10x vision and concrete expansion proposals before locking the scope contract via product-discovery strategist mode.",
|
|
542
|
-
requiresUserGate: false
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
agent: "scope-guardian-reviewer",
|
|
546
|
-
mode: "proactive",
|
|
547
|
-
runPhase: "post-elicitation",
|
|
548
|
-
when: "When scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION, or scope contract has many accepted ideas. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
549
|
-
purpose: "Challenge complexity growth and enforce minimum-change scope discipline before scope lock.",
|
|
550
|
-
requiresUserGate: false,
|
|
551
|
-
skill: "document-scope-guard"
|
|
552
|
-
}
|
|
553
|
-
],
|
|
554
|
-
design: [
|
|
555
|
-
{
|
|
556
|
-
agent: "architect",
|
|
557
|
-
mode: "mandatory",
|
|
558
|
-
requiredAtTier: "standard",
|
|
559
|
-
runPhase: "post-elicitation",
|
|
560
|
-
when: "Always during design lock. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
561
|
-
purpose: "Stress architecture boundaries, dependency graph, critical path, and spec handoff.",
|
|
562
|
-
requiresUserGate: false
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
agent: "critic",
|
|
566
|
-
mode: "proactive",
|
|
567
|
-
runPhase: "post-elicitation",
|
|
568
|
-
when: "When architecture alternatives, coupling, cost, or rollback risk remain debatable, or when security/auth/authz trust boundaries are involved. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
569
|
-
purpose: "Produce a shadow alternative, switch trigger, and cheaper-path challenge for the engineering lock with pre-commitment predictions and validation.",
|
|
570
|
-
requiresUserGate: false,
|
|
571
|
-
skill: "critic-multi-perspective"
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
agent: "researcher",
|
|
575
|
-
mode: "proactive",
|
|
576
|
-
runPhase: "post-elicitation",
|
|
577
|
-
when: "When framework/library docs, repo graph context, or reference contracts may change the design. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
578
|
-
purpose: "Run search-before-read context synthesis before architecture locks.",
|
|
579
|
-
requiresUserGate: false,
|
|
580
|
-
essentialAcrossModes: true
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
agent: "security-reviewer",
|
|
584
|
-
mode: "proactive",
|
|
585
|
-
runPhase: "post-elicitation",
|
|
586
|
-
when: "When trust boundaries, auth, secrets, sensitive data, or external inputs are involved. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
587
|
-
purpose: "Catch design-level security risks before implementation.",
|
|
588
|
-
requiresUserGate: false
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
agent: "coherence-reviewer",
|
|
592
|
-
mode: "proactive",
|
|
593
|
-
runPhase: "post-elicitation",
|
|
594
|
-
when: "When design touches multiple subsystems or includes multiple alternatives sections. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
595
|
-
purpose: "Detect internal contradictions, terminology drift, and broken cross-section references in design docs.",
|
|
596
|
-
requiresUserGate: false,
|
|
597
|
-
skill: "document-coherence-pass"
|
|
598
|
-
},
|
|
599
|
-
{
|
|
600
|
-
agent: "feasibility-reviewer",
|
|
601
|
-
mode: "proactive",
|
|
602
|
-
runPhase: "post-elicitation",
|
|
603
|
-
when: "When design assumes runtime conditions, scaling behavior, or external service availability. Runs only after the adaptive elicitation Q&A loop converges.",
|
|
604
|
-
purpose: "Validate that design assumptions remain feasible in real runtime and rollout constraints.",
|
|
605
|
-
requiresUserGate: false,
|
|
606
|
-
skill: "document-feasibility-pass"
|
|
607
|
-
}
|
|
608
|
-
],
|
|
609
|
-
spec: [
|
|
610
|
-
{
|
|
611
|
-
agent: "spec-validator",
|
|
612
|
-
mode: "mandatory",
|
|
613
|
-
requiredAtTier: "standard",
|
|
614
|
-
when: "Always for standard/deep specs before plan handoff.",
|
|
615
|
-
purpose: "Validate measurability, edge cases, assumptions, and AC-to-testability mapping.",
|
|
616
|
-
requiresUserGate: false
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
agent: "spec-document-reviewer",
|
|
620
|
-
mode: "proactive",
|
|
621
|
-
requiredAtTier: "standard",
|
|
622
|
-
when: "When Spec Self-Review reports gaps (Status: Issues Found) or subsystem boundaries drift beyond one coherent plan slice.",
|
|
623
|
-
purpose: "Run a final document-level quality pass for completeness, consistency, clarity, and scope fit before handoff to plan.",
|
|
624
|
-
requiresUserGate: false
|
|
625
|
-
},
|
|
626
|
-
{
|
|
627
|
-
agent: "coherence-reviewer",
|
|
628
|
-
mode: "proactive",
|
|
629
|
-
when: "When spec has more than five acceptance criteria or multiple assumptions sections.",
|
|
630
|
-
purpose: "Check cross-section coherence, terminology consistency, and internal references before plan handoff.",
|
|
631
|
-
requiresUserGate: false,
|
|
632
|
-
skill: "document-coherence-pass"
|
|
633
|
-
}
|
|
634
|
-
],
|
|
635
|
-
plan: [
|
|
636
|
-
{
|
|
637
|
-
agent: "planner",
|
|
638
|
-
mode: "mandatory",
|
|
639
|
-
requiredAtTier: "standard",
|
|
640
|
-
when: "Always when producing execution slices.",
|
|
641
|
-
purpose: "Create dependency-aware executable packets with expected failing test, passing command, stop condition, and verification evidence.",
|
|
642
|
-
requiresUserGate: false
|
|
643
|
-
},
|
|
644
|
-
{
|
|
645
|
-
agent: "researcher",
|
|
646
|
-
mode: "proactive",
|
|
647
|
-
when: "When plan tasks touch unfamiliar areas or reference-pattern adoption needs source verification.",
|
|
648
|
-
purpose: "Confirm context/search evidence before plan packets rely on discovered patterns.",
|
|
649
|
-
requiresUserGate: false
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
agent: "coherence-reviewer",
|
|
653
|
-
mode: "proactive",
|
|
654
|
-
when: "When plan packets touch more than one subsystem or map more than five dependency edges.",
|
|
655
|
-
purpose: "Verify internal consistency across batches, dependencies, and handoff narratives.",
|
|
656
|
-
requiresUserGate: false,
|
|
657
|
-
skill: "document-coherence-pass"
|
|
658
|
-
},
|
|
659
|
-
{
|
|
660
|
-
agent: "scope-guardian-reviewer",
|
|
661
|
-
mode: "proactive",
|
|
662
|
-
when: "When plan introduces new abstractions or generic utility layers.",
|
|
663
|
-
purpose: "Challenge unnecessary abstraction and enforce minimum viable implementation scope.",
|
|
664
|
-
requiresUserGate: false,
|
|
665
|
-
skill: "document-scope-guard"
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
agent: "feasibility-reviewer",
|
|
669
|
-
mode: "proactive",
|
|
670
|
-
when: "When plan carries runtime, environment, dependency, or resource assumptions.",
|
|
671
|
-
purpose: "Validate execution and rollout feasibility before implementation starts.",
|
|
672
|
-
requiresUserGate: false,
|
|
673
|
-
skill: "document-feasibility-pass"
|
|
674
|
-
}
|
|
675
|
-
],
|
|
676
|
-
tdd: [
|
|
677
|
-
{
|
|
678
|
-
agent: "slice-builder",
|
|
679
|
-
mode: "mandatory",
|
|
680
|
-
requiredAtTier: "lightweight",
|
|
681
|
-
when: "During delegated TDD topologies (`single-builder`, `parallel-builders`, `strict-micro`). Inline topology may skip the dispatch only when the same RED/GREEN/REFACTOR evidence gates are preserved.",
|
|
682
|
-
purpose: "Own one feature-atomic implementation unit/slice end-to-end: RED → GREEN → REFACTOR → per-slice DOC in a single delegated span. Multiple slice-builder spans run in parallel only under `parallel-builders` topology with disjoint `claimedPaths`. Linter rules `tdd_slice_builder_missing` and `tdd_slice_doc_missing` block unauthorized GREEN authors and missing per-slice prose unless inline topology is explicitly recorded.",
|
|
683
|
-
requiresUserGate: false,
|
|
684
|
-
skill: "tdd-cycle-evidence"
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
agent: "integration-overseer",
|
|
688
|
-
mode: "proactive",
|
|
689
|
-
when: "When a wave fans out 2+ parallel slice-builder spans, or when slices touch shared interfaces.",
|
|
690
|
-
purpose: "Verify cohesion-contract integrity across shared types, touchpoints, invariants, and integration test outcomes after fan-in.",
|
|
691
|
-
requiresUserGate: false
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
agent: "reviewer",
|
|
695
|
-
mode: "proactive",
|
|
696
|
-
when: "When per-slice review triggers fire or assertion quality needs an independent read-only overseer.",
|
|
697
|
-
purpose: "Read-only overseer pass for slice spec fit, assertion quality, and simpler alternatives.",
|
|
698
|
-
requiresUserGate: false
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
agent: "doc-updater",
|
|
702
|
-
mode: "proactive",
|
|
703
|
-
when: "Proactive in tdd when public behavior, APIs, or config surfaces change.",
|
|
704
|
-
purpose: "Prevent code/docs drift before review and ship.",
|
|
705
|
-
requiresUserGate: false
|
|
706
|
-
}
|
|
707
|
-
],
|
|
708
|
-
review: [
|
|
709
|
-
{
|
|
710
|
-
agent: "reviewer",
|
|
711
|
-
mode: "mandatory",
|
|
712
|
-
requiredAtTier: "lightweight",
|
|
713
|
-
when: "Always in review stage.",
|
|
714
|
-
purpose: "Layer 1 spec compliance plus integrated Layer 2 review across correctness, architecture, and inline performance/compatibility/observability lens coverage with source-tagged findings. Escalate to optional dedicated lens skills only when diff scope/risk justifies a deeper pass.",
|
|
715
|
-
requiresUserGate: false,
|
|
716
|
-
skill: "review-spec-pass"
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
agent: "security-reviewer",
|
|
720
|
-
mode: "mandatory",
|
|
721
|
-
requiredAtTier: "lightweight",
|
|
722
|
-
when: "Always in review stage. Even when no trust boundaries changed, produce an explicit no-change/no-impact security attestation.",
|
|
723
|
-
purpose: "Guarantee a dedicated security pass on every diff: auth, input validation, secrets, injection, privilege, and blast-radius review are never opt-in.",
|
|
724
|
-
requiresUserGate: false,
|
|
725
|
-
skill: "security-audit"
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
agent: "reviewer",
|
|
729
|
-
mode: "proactive",
|
|
730
|
-
when: "When trust boundaries changed, Critical/Important ambiguity remains, or the diff is both large and high-risk.",
|
|
731
|
-
purpose: "Adversarial second-opinion review for genuinely high-blast-radius changes. Treat the implementation as hostile and try to break it before ship.",
|
|
732
|
-
requiresUserGate: false,
|
|
733
|
-
skill: "adversarial-review"
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
agent: "reviewer",
|
|
737
|
-
mode: "proactive",
|
|
738
|
-
when: "When external reviewer comments, bot findings, or CI annotations are present after the initial review pass.",
|
|
739
|
-
purpose: "Run the receiving-code-review workflow so every incoming feedback item gets an explicit disposition with evidence.",
|
|
740
|
-
requiresUserGate: false,
|
|
741
|
-
skill: "receiving-code-review"
|
|
742
|
-
},
|
|
743
|
-
{
|
|
744
|
-
agent: "reviewer",
|
|
745
|
-
mode: "proactive",
|
|
746
|
-
when: "When repo signals or review context indicate TypeScript/JavaScript, Python, Ruby/Rails, Go, or Rust coverage is relevant.",
|
|
747
|
-
purpose: "Route a matching stack-aware reviewer lens while keeping the default general review pass intact; do not run every stack lens unconditionally.",
|
|
748
|
-
requiresUserGate: false,
|
|
749
|
-
skill: "stack-aware-review"
|
|
750
|
-
}
|
|
751
|
-
],
|
|
752
|
-
ship: [
|
|
753
|
-
{
|
|
754
|
-
agent: "architect",
|
|
755
|
-
mode: "mandatory",
|
|
756
|
-
requiredAtTier: "lightweight",
|
|
757
|
-
when: "Always before final ship — verify cross-stage cohesion across scope/design/spec/plan/code.",
|
|
758
|
-
purpose: "Final cross-stage cohesion gate before release finalization.",
|
|
759
|
-
requiresUserGate: false,
|
|
760
|
-
skill: "architect-cross-stage-verification"
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
agent: "release-reviewer",
|
|
764
|
-
mode: "mandatory",
|
|
765
|
-
requiredAtTier: "lightweight",
|
|
766
|
-
when: "Always in ship stage.",
|
|
767
|
-
purpose: "Run release readiness, finalization mode, rollback, evidence freshness, and victory-detector checks before archive/ship.",
|
|
768
|
-
requiresUserGate: false
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
agent: "doc-updater",
|
|
772
|
-
mode: "proactive",
|
|
773
|
-
when: "When release notes, migrations, public behavior, CLI/config, or docs changed.",
|
|
774
|
-
purpose: "Ensure release notes and docs reflect actual shipped behavior.",
|
|
775
|
-
requiresUserGate: false
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
agent: "security-reviewer",
|
|
779
|
-
mode: "proactive",
|
|
780
|
-
when: "When release involves broad blast radius, trust-boundary movement, or unresolved security concerns.",
|
|
781
|
-
purpose: "Provide final exploitability check before release finalization.",
|
|
782
|
-
requiresUserGate: false
|
|
783
|
-
}
|
|
784
|
-
]
|
|
785
|
-
};
|
|
786
|
-
/** Transition guard: agents with `mode: "mandatory"` in auto-subagent dispatch for this stage. */
|
|
787
|
-
export function mandatoryDelegationsForStage(stage, complexityTier = "standard") {
|
|
788
|
-
const summary = stageDelegationSummary(complexityTier)
|
|
789
|
-
.find((row) => row.stage === stage);
|
|
790
|
-
return summary ? summary.mandatoryAgents : [];
|
|
791
|
-
}
|
|
792
|
-
export function mandatoryAgentsFor(stage, track, taskClass, complexityTier = "standard", discoveryMode) {
|
|
793
|
-
if (track === "quick")
|
|
794
|
-
return [];
|
|
795
|
-
if (taskClass === "software-bugfix")
|
|
796
|
-
return [];
|
|
797
|
-
const effectiveTier = resolvedStageComplexityTier({
|
|
798
|
-
stage,
|
|
799
|
-
defaultTier: complexityTier,
|
|
800
|
-
discoveryMode
|
|
801
|
-
});
|
|
802
|
-
return mandatoryDelegationsForStage(stage, effectiveTier);
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Track-aware artifact validation demotion.
|
|
806
|
-
*
|
|
807
|
-
* Mirrors `mandatoryAgentsFor`'s skip logic for the small-fix lanes.
|
|
808
|
-
* Returns `true` when artifact-level "advanced" validation rules
|
|
809
|
-
* (architecture-diagram async/failure edges, interaction edge-case
|
|
810
|
-
* mandatory rows, stale-diagram drift check, expansion-strategist
|
|
811
|
-
* delegation) should be DEMOTED from required → advisory.
|
|
812
|
-
*
|
|
813
|
-
* - `track === "quick"` — quick-tier runs (single-purpose
|
|
814
|
-
* landing-page edits, doc tweaks, config nudges). The advanced
|
|
815
|
-
* checks fire on architecture surfaces a quick-track artifact
|
|
816
|
-
* usually doesn't have.
|
|
817
|
-
* - `taskClass === "software-bugfix"` — bugfixes carry RED-first
|
|
818
|
-
* repro coverage; tdd/review own the safety surface.
|
|
819
|
-
*
|
|
820
|
-
* When this returns `true`, the linter still runs the rules and prints
|
|
821
|
-
* their findings (so authors see them as advisory info), but does NOT
|
|
822
|
-
* block stage advance. An audit event of type
|
|
823
|
-
* `artifact_validation_demoted_by_track` is appended to
|
|
824
|
-
* `delegation-events.jsonl` once per stage advance for traceability.
|
|
825
|
-
*/
|
|
826
|
-
export function shouldDemoteArtifactValidationByTrack(track, taskClass) {
|
|
827
|
-
if (track === "quick")
|
|
828
|
-
return true;
|
|
829
|
-
if (taskClass === "software-bugfix")
|
|
830
|
-
return true;
|
|
831
|
-
return false;
|
|
832
|
-
}
|
|
833
|
-
export function stageSchema(stage, track = "standard", discoveryMode, taskClass) {
|
|
834
|
-
const rawInput = stage === "tdd" ? tddStageForTrack(track) : STAGE_SCHEMA_MAP[stage];
|
|
835
|
-
const base = normalizeStageSchemaInput(rawInput);
|
|
836
|
-
const tieredGates = tieredStageGates(stage, base.requiredGates, track);
|
|
837
|
-
const tieredValidation = tieredArtifactValidation(stage, base.artifactValidation);
|
|
838
|
-
const crossStageTrace = {
|
|
839
|
-
...base.crossStageTrace,
|
|
840
|
-
readsFrom: readsFromForTrack(base.crossStageTrace.readsFrom, track)
|
|
841
|
-
};
|
|
842
|
-
const complexityTier = resolvedStageComplexityTier({
|
|
843
|
-
stage,
|
|
844
|
-
defaultTier: base.complexityTier ?? "standard",
|
|
845
|
-
discoveryMode
|
|
846
|
-
});
|
|
847
|
-
const mandatoryDelegations = mandatoryDelegationsForStage(stage, complexityTier);
|
|
848
|
-
const philosophy = {
|
|
849
|
-
hardGate: base.hardGate,
|
|
850
|
-
ironLaw: base.ironLaw,
|
|
851
|
-
purpose: base.purpose,
|
|
852
|
-
whenToUse: base.whenToUse,
|
|
853
|
-
whenNotToUse: base.whenNotToUse,
|
|
854
|
-
commonRationalizations: base.commonRationalizations
|
|
855
|
-
};
|
|
856
|
-
const executionModel = {
|
|
857
|
-
interactionProtocol: base.interactionProtocol,
|
|
858
|
-
process: base.process,
|
|
859
|
-
processFlow: base.processFlow,
|
|
860
|
-
platformNotes: base.platformNotes,
|
|
861
|
-
checklist: base.checklist,
|
|
862
|
-
requiredGates: tieredGates,
|
|
863
|
-
requiredEvidence: base.requiredEvidence,
|
|
864
|
-
inputs: base.inputs,
|
|
865
|
-
requiredContext: base.requiredContext,
|
|
866
|
-
researchPlaybooks: base.researchPlaybooks,
|
|
867
|
-
blockers: base.blockers,
|
|
868
|
-
exitCriteria: base.exitCriteria
|
|
869
|
-
};
|
|
870
|
-
const artifactRules = {
|
|
871
|
-
artifactFile: base.artifactFile,
|
|
872
|
-
completionStatus: base.completionStatus,
|
|
873
|
-
crossStageTrace,
|
|
874
|
-
artifactValidation: tieredValidation,
|
|
875
|
-
trivialOverrideSections: base.trivialOverrideSections
|
|
876
|
-
};
|
|
877
|
-
const reviewLens = {
|
|
878
|
-
outputs: base.outputs,
|
|
879
|
-
reviewSections: base.reviewSections,
|
|
880
|
-
mandatoryDelegations,
|
|
881
|
-
reviewLoop: base.reviewLoop
|
|
882
|
-
};
|
|
883
|
-
return {
|
|
884
|
-
...base,
|
|
885
|
-
schemaShape: "v2",
|
|
886
|
-
complexityTier,
|
|
887
|
-
philosophy,
|
|
888
|
-
executionModel,
|
|
889
|
-
artifactRules,
|
|
890
|
-
reviewLens,
|
|
891
|
-
skillFolder: STAGE_TO_SKILL_FOLDER[stage],
|
|
892
|
-
crossStageTrace,
|
|
893
|
-
requiredGates: tieredGates,
|
|
894
|
-
artifactValidation: tieredValidation,
|
|
895
|
-
mandatoryDelegations
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
export function orderedStageSchemas(track = "standard") {
|
|
899
|
-
return FLOW_STAGES.map((stage) => stageSchema(stage, track));
|
|
900
|
-
}
|
|
901
|
-
export function stageGateIds(stage, track = "standard") {
|
|
902
|
-
return stageSchema(stage, track).requiredGates
|
|
903
|
-
.filter((gate) => gate.tier === "required")
|
|
904
|
-
.map((gate) => gate.id);
|
|
905
|
-
}
|
|
906
|
-
export function stageRecommendedGateIds(stage, track = "standard") {
|
|
907
|
-
return stageSchema(stage, track).requiredGates
|
|
908
|
-
.filter((gate) => gate.tier === "recommended")
|
|
909
|
-
.map((gate) => gate.id);
|
|
910
|
-
}
|
|
911
|
-
export function buildTransitionRules() {
|
|
912
|
-
const rules = [];
|
|
913
|
-
const seen = new Set();
|
|
914
|
-
// Derive transitions from every track so medium/quick (which skip stages)
|
|
915
|
-
// get their neighbour edges registered alongside the standard chain.
|
|
916
|
-
for (const track of FLOW_TRACKS) {
|
|
917
|
-
const ordered = TRACK_STAGES[track];
|
|
918
|
-
for (let i = 0; i < ordered.length - 1; i += 1) {
|
|
919
|
-
const from = ordered[i];
|
|
920
|
-
const to = ordered[i + 1];
|
|
921
|
-
const key = `${from}->${to}`;
|
|
922
|
-
if (seen.has(key))
|
|
923
|
-
continue;
|
|
924
|
-
seen.add(key);
|
|
925
|
-
rules.push({
|
|
926
|
-
from,
|
|
927
|
-
to,
|
|
928
|
-
guards: stageGateIds(from, track)
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
// Review can explicitly route back to TDD when the verdict is BLOCKED.
|
|
933
|
-
rules.push({
|
|
934
|
-
from: "review",
|
|
935
|
-
to: "tdd",
|
|
936
|
-
guards: ["review_verdict_blocked"]
|
|
937
|
-
});
|
|
938
|
-
return rules;
|
|
939
|
-
}
|
|
940
|
-
export function stagePolicyNeedles(stage, track = "standard") {
|
|
941
|
-
return stagePolicyNeedlesFromMetadata(stage, track);
|
|
942
|
-
}
|
|
943
|
-
export function stageTrackRenderContext(track = "standard") {
|
|
944
|
-
return trackRenderContext(track);
|
|
945
|
-
}
|
|
946
|
-
export function stageAutoSubagentDispatch(stage) {
|
|
947
|
-
return STAGE_AUTO_SUBAGENT_DISPATCH[stage].map((row) => {
|
|
948
|
-
const normalized = delegationDispatchRule(row);
|
|
949
|
-
return {
|
|
950
|
-
...row,
|
|
951
|
-
dispatchClass: normalized.dispatchClass,
|
|
952
|
-
returnSchema: normalized.returnSchema
|
|
953
|
-
};
|
|
954
|
-
});
|
|
955
|
-
}
|