cclaw-cli 6.1.0 → 6.2.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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/artifact-linter/brainstorm.js +13 -13
  3. package/dist/artifact-linter/design.js +5 -5
  4. package/dist/artifact-linter/scope.js +3 -3
  5. package/dist/artifact-linter/shared.d.ts +18 -19
  6. package/dist/artifact-linter/shared.js +34 -31
  7. package/dist/artifact-linter.js +4 -0
  8. package/dist/content/hooks.js +2 -2
  9. package/dist/content/skills-elicitation.js +8 -19
  10. package/dist/content/stage-schema.d.ts +3 -3
  11. package/dist/content/stage-schema.js +27 -4
  12. package/dist/content/stages/brainstorm.js +5 -5
  13. package/dist/content/stages/design.js +1 -1
  14. package/dist/content/stages/scope.js +2 -2
  15. package/dist/content/start-command.d.ts +2 -2
  16. package/dist/content/start-command.js +18 -17
  17. package/dist/content/subagents.js +1 -1
  18. package/dist/delegation.d.ts +4 -1
  19. package/dist/delegation.js +11 -3
  20. package/dist/flow-state.d.ts +5 -1
  21. package/dist/flow-state.js +6 -1
  22. package/dist/gate-evidence.js +4 -3
  23. package/dist/internal/advance-stage/advance.js +13 -4
  24. package/dist/internal/advance-stage/parsers.d.ts +2 -1
  25. package/dist/internal/advance-stage/parsers.js +11 -1
  26. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +19 -0
  27. package/dist/internal/advance-stage/proactive-delegation-trace.js +44 -0
  28. package/dist/internal/advance-stage/start-flow.js +17 -2
  29. package/dist/internal/advance-stage/verify.d.ts +0 -8
  30. package/dist/internal/advance-stage/verify.js +2 -30
  31. package/dist/run-persistence.js +35 -2
  32. package/dist/track-heuristics.d.ts +2 -2
  33. package/dist/track-heuristics.js +11 -6
  34. package/dist/types.d.ts +2 -0
  35. package/dist/types.js +1 -0
  36. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- import { type StageAutoSubagentDispatch } from "../../content/stage-schema.js";
2
1
  import { type FlowState, type StageGateState } from "../../flow-state.js";
3
2
  import { type FlowStage, type FlowTrack } from "../../types.js";
4
3
  import type { VerifyCurrentStateArgs, VerifyFlowStateDiffArgs } from "./parsers.js";
@@ -7,9 +6,6 @@ interface InternalIo {
7
6
  stdout: Writable;
8
7
  stderr: Writable;
9
8
  }
10
- interface ProactiveDelegationTraceResult {
11
- missingRules: StageAutoSubagentDispatch[];
12
- }
13
9
  export declare function runVerifyFlowStateDiff(projectRoot: string, args: VerifyFlowStateDiffArgs, io: InternalIo): Promise<number>;
14
10
  export declare function runVerifyCurrentState(projectRoot: string, args: VerifyCurrentStateArgs, io: InternalIo): Promise<number>;
15
11
  export declare function firstIncompleteStageForTrack(track: FlowTrack, completedStages: FlowStage[]): FlowStage;
@@ -18,10 +14,6 @@ export declare function carriedCompletedStageCatalog(current: FlowState, fresh:
18
14
  evidence: Record<string, string>;
19
15
  };
20
16
  export declare function completedStageClosureEvidenceIssues(flowState: FlowState): string[];
21
- export declare function ensureProactiveDelegationTrace(projectRoot: string, stage: FlowStage, options: {
22
- acceptWaiver: boolean;
23
- waiverReason?: string;
24
- }): Promise<ProactiveDelegationTraceResult>;
25
17
  export declare function pathExists(projectRoot: string, relPath: string): Promise<boolean>;
26
18
  export declare function listExistingFiles(projectRoot: string, relPaths: string[]): Promise<string[]>;
27
19
  export declare function listFilesUnder(projectRoot: string, relDir: string, limit?: number): Promise<string[]>;
@@ -1,7 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { RUNTIME_ROOT } from "../../constants.js";
3
- import { stageAutoSubagentDispatch, stageSchema } from "../../content/stage-schema.js";
4
- import { appendDelegation, readDelegationLedger } from "../../delegation.js";
3
+ import { stageSchema } from "../../content/stage-schema.js";
5
4
  import { readFlowState } from "../../runs.js";
6
5
  import { TRACK_STAGES } from "../../types.js";
7
6
  import { coerceCandidateFlowState } from "./flow-state-coercion.js";
@@ -87,7 +86,7 @@ export function carriedCompletedStageCatalog(current, fresh, stage) {
87
86
  export function completedStageClosureEvidenceIssues(flowState) {
88
87
  const issues = [];
89
88
  for (const stage of flowState.completedStages) {
90
- const schema = stageSchema(stage, flowState.track);
89
+ const schema = stageSchema(stage, flowState.track, flowState.discoveryMode, flowState.taskClass ?? null);
91
90
  const catalog = flowState.stageGateCatalog[stage];
92
91
  const required = schema.requiredGates
93
92
  .filter((gate) => gate.tier === "required")
@@ -103,33 +102,6 @@ export function completedStageClosureEvidenceIssues(flowState) {
103
102
  }
104
103
  return issues;
105
104
  }
106
- export async function ensureProactiveDelegationTrace(projectRoot, stage, options) {
107
- const proactiveRules = stageAutoSubagentDispatch(stage).filter((rule) => rule.mode === "proactive");
108
- if (proactiveRules.length === 0)
109
- return { missingRules: [] };
110
- const ledger = await readDelegationLedger(projectRoot);
111
- const currentRunEntries = ledger.entries.filter((entry) => entry.runId === ledger.runId);
112
- const missingRules = proactiveRules.filter((rule) => !currentRunEntries.some((entry) => entry.stage === stage && entry.agent === rule.agent && entry.mode === "proactive"));
113
- if (missingRules.length === 0)
114
- return { missingRules: [] };
115
- if (!options.acceptWaiver)
116
- return { missingRules };
117
- const waiverReason = options.waiverReason?.trim() || "accepted via --accept-proactive-waiver";
118
- for (const rule of missingRules) {
119
- await appendDelegation(projectRoot, {
120
- stage,
121
- agent: rule.agent,
122
- mode: "proactive",
123
- status: "waived",
124
- waiverReason,
125
- acceptedBy: "user-flag",
126
- conditionTrigger: rule.when,
127
- skill: rule.skill,
128
- ts: new Date().toISOString()
129
- });
130
- }
131
- return { missingRules: [] };
132
- }
133
105
  export async function pathExists(projectRoot, relPath) {
134
106
  try {
135
107
  await fs.stat(path.join(projectRoot, relPath));
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { RUNTIME_ROOT } from "./constants.js";
4
- import { nextStage, createInitialCloseoutState, createInitialFlowState, FLOW_STATE_SCHEMA_VERSION, isFlowTrack, skippedStagesForTrack, SHIP_SUBSTATES } from "./flow-state.js";
4
+ import { nextStage, createInitialCloseoutState, createInitialFlowState, FLOW_STATE_SCHEMA_VERSION, isDiscoveryMode, isFlowTrack, skippedStagesForTrack, SHIP_SUBSTATES } from "./flow-state.js";
5
5
  import { ensureDir, exists, withDirectoryLock, writeFileSafe } from "./fs-utils.js";
6
6
  import { FLOW_STAGES } from "./types.js";
7
7
  export class InvalidStageTransitionError extends Error {
@@ -30,6 +30,9 @@ function validateFlowTransition(prev, next) {
30
30
  if (prev.track !== next.track) {
31
31
  throw new InvalidStageTransitionError(prev.currentStage, next.currentStage, `cannot change track from "${prev.track}" to "${next.track}" mid-run (activeRunId="${prev.activeRunId}"). Archive the run and start a new one to switch tracks.`);
32
32
  }
33
+ if (prev.discoveryMode !== next.discoveryMode) {
34
+ throw new InvalidStageTransitionError(prev.currentStage, next.currentStage, `cannot change discoveryMode from "${prev.discoveryMode}" to "${next.discoveryMode}" mid-run (activeRunId="${prev.activeRunId}"). Reclassify through start-flow or start a new run.`);
35
+ }
33
36
  const newRewind = next.rewinds.length === prev.rewinds.length + 1
34
37
  ? next.rewinds[next.rewinds.length - 1]
35
38
  : undefined;
@@ -159,6 +162,32 @@ function sanitizeStageGateCatalog(value, fallback) {
159
162
  function coerceTrack(value) {
160
163
  return isFlowTrack(value) ? value : "standard";
161
164
  }
165
+ function coerceDiscoveryMode(value) {
166
+ return isDiscoveryMode(value) ? value : "guided";
167
+ }
168
+ /**
169
+ * Wave 24 follow-up (v6.1.1) — preserve `flow-state.json#taskClass`
170
+ * across read/write round-trips. Before this audit fix the persistence
171
+ * layer silently dropped the field, which made the Wave 24 bugfix-skip
172
+ * (`mandatoryAgentsFor` short-circuit) and the Wave 25 artifact-validation
173
+ * demotion both dead in practice: the only entry point that classified
174
+ * a run was the unit-test harness passing `options.taskClass` directly
175
+ * to `checkMandatoryDelegations`. The accepted union mirrors
176
+ * `MandatoryDelegationTaskClass` plus `null` so callers can explicitly
177
+ * clear the classification without dropping the property.
178
+ */
179
+ function coerceTaskClass(value) {
180
+ if (value === undefined)
181
+ return undefined;
182
+ if (value === null)
183
+ return null;
184
+ if (value === "software-standard" ||
185
+ value === "software-trivial" ||
186
+ value === "software-bugfix") {
187
+ return value;
188
+ }
189
+ return undefined;
190
+ }
162
191
  function sanitizeSkippedStages(value, track) {
163
192
  const trackDefault = skippedStagesForTrack(track);
164
193
  if (!Array.isArray(value)) {
@@ -349,11 +378,13 @@ function sanitizeCloseoutState(value) {
349
378
  }
350
379
  function coerceFlowState(parsed) {
351
380
  const track = coerceTrack(parsed.track);
352
- const next = createInitialFlowState({ track });
381
+ const discoveryMode = coerceDiscoveryMode(parsed.discoveryMode);
382
+ const next = createInitialFlowState({ track, discoveryMode });
353
383
  const activeRunIdRaw = parsed.activeRunId;
354
384
  const activeRunId = typeof activeRunIdRaw === "string" && activeRunIdRaw.trim().length > 0
355
385
  ? activeRunIdRaw.trim()
356
386
  : next.activeRunId;
387
+ const taskClass = coerceTaskClass(parsed.taskClass);
357
388
  const state = {
358
389
  schemaVersion: FLOW_STATE_SCHEMA_VERSION,
359
390
  activeRunId,
@@ -362,6 +393,8 @@ function coerceFlowState(parsed) {
362
393
  guardEvidence: sanitizeGuardEvidence(parsed.guardEvidence),
363
394
  stageGateCatalog: sanitizeStageGateCatalog(parsed.stageGateCatalog, next.stageGateCatalog),
364
395
  track,
396
+ discoveryMode,
397
+ ...(taskClass !== undefined ? { taskClass } : {}),
365
398
  skippedStages: sanitizeSkippedStages(parsed.skippedStages, track),
366
399
  staleStages: sanitizeStaleStages(parsed.staleStages),
367
400
  rewinds: sanitizeRewinds(parsed.rewinds),
@@ -1,4 +1,4 @@
1
- import type { FlowStage, FlowTrack, TrackHeuristicRule, TrackHeuristicsConfig } from "./types.js";
1
+ import type { DiscoveryMode, FlowStage, FlowTrack, TrackHeuristicRule, TrackHeuristicsConfig } from "./types.js";
2
2
  export interface TrackResolution {
3
3
  track: FlowTrack;
4
4
  reason: string;
@@ -19,7 +19,7 @@ export interface QuestionBudgetHint {
19
19
  * "advisory" language.
20
20
  */
21
21
  export declare function resolveTrackFromPrompt(prompt: string, config: TrackHeuristicsConfig | undefined): TrackResolution;
22
- export declare function questionBudgetHint(track: FlowTrack, stage: FlowStage): QuestionBudgetHint;
22
+ export declare function questionBudgetHint(modeOrTrack: DiscoveryMode | FlowTrack, stage: FlowStage): QuestionBudgetHint;
23
23
  export declare const TRACK_HEURISTICS_DEFAULTS: {
24
24
  readonly fallback: "standard";
25
25
  readonly evaluationOrder: readonly ("quick" | "medium" | "standard")[];
@@ -55,10 +55,10 @@ const DEFAULT_RULES = {
55
55
  const EVALUATION_ORDER = ["standard", "medium", "quick"];
56
56
  const DEFAULT_FALLBACK = "standard";
57
57
  const ADAPTIVE_ELICITATION_STAGES = new Set(["brainstorm", "scope", "design"]);
58
- const QUESTION_BUDGET_HINTS_BY_TRACK = {
59
- quick: { min: 2, recommended: 3, hardCapWarning: 4 },
60
- medium: { min: 5, recommended: 6, hardCapWarning: 8 },
61
- standard: { min: 10, recommended: 12, hardCapWarning: 14 }
58
+ const QUESTION_BUDGET_HINTS_BY_DISCOVERY_MODE = {
59
+ lean: { min: 3, recommended: 4, hardCapWarning: 6 },
60
+ guided: { min: 5, recommended: 7, hardCapWarning: 10 },
61
+ deep: { min: 7, recommended: 10, hardCapWarning: 14 }
62
62
  };
63
63
  function hasToken(promptLower, token) {
64
64
  return promptLower.includes(token.toLowerCase());
@@ -136,11 +136,16 @@ export function resolveTrackFromPrompt(prompt, config) {
136
136
  overrideGuidance: "Confirm or override before state is written; choose quick only for known low-blast-radius work, medium for known architecture with product framing, standard for uncertainty."
137
137
  };
138
138
  }
139
- export function questionBudgetHint(track, stage) {
139
+ export function questionBudgetHint(modeOrTrack, stage) {
140
140
  if (!ADAPTIVE_ELICITATION_STAGES.has(stage)) {
141
141
  return { min: 0, recommended: 0, hardCapWarning: 0 };
142
142
  }
143
- return QUESTION_BUDGET_HINTS_BY_TRACK[track];
143
+ if (modeOrTrack === "lean" || modeOrTrack === "guided" || modeOrTrack === "deep") {
144
+ return QUESTION_BUDGET_HINTS_BY_DISCOVERY_MODE[modeOrTrack];
145
+ }
146
+ if (modeOrTrack === "quick")
147
+ return QUESTION_BUDGET_HINTS_BY_DISCOVERY_MODE.lean;
148
+ return QUESTION_BUDGET_HINTS_BY_DISCOVERY_MODE.guided;
144
149
  }
145
150
  export const TRACK_HEURISTICS_DEFAULTS = {
146
151
  fallback: DEFAULT_FALLBACK,
package/dist/types.d.ts CHANGED
@@ -2,6 +2,8 @@ export declare const FLOW_STAGES: readonly ["brainstorm", "scope", "design", "sp
2
2
  export type FlowStage = (typeof FLOW_STAGES)[number];
3
3
  export declare const FLOW_TRACKS: readonly ["quick", "medium", "standard"];
4
4
  export type FlowTrack = (typeof FLOW_TRACKS)[number];
5
+ export declare const DISCOVERY_MODES: readonly ["lean", "guided", "deep"];
6
+ export type DiscoveryMode = (typeof DISCOVERY_MODES)[number];
5
7
  /**
6
8
  * Ordered stages that make up each flow track.
7
9
  *
package/dist/types.js CHANGED
@@ -9,6 +9,7 @@ export const FLOW_STAGES = [
9
9
  "ship"
10
10
  ];
11
11
  export const FLOW_TRACKS = ["quick", "medium", "standard"];
12
+ export const DISCOVERY_MODES = ["lean", "guided", "deep"];
12
13
  /**
13
14
  * Ordered stages that make up each flow track.
14
15
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {