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
package/dist/flow-state.d.ts
CHANGED
|
@@ -1,179 +1,22 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const
|
|
3
|
-
export
|
|
4
|
-
/** Snapshot from `collectRepoSignals` at last successful `start-flow` (optional on older states). */
|
|
5
|
-
export interface RepoSignals {
|
|
6
|
-
fileCount: number;
|
|
7
|
-
hasReadme: boolean;
|
|
8
|
-
hasPackageManifest: boolean;
|
|
9
|
-
capturedAt: string;
|
|
10
|
-
}
|
|
11
|
-
export interface StageGateState {
|
|
12
|
-
required: string[];
|
|
13
|
-
recommended: string[];
|
|
14
|
-
conditional: string[];
|
|
15
|
-
/** Conditional gates currently considered active for blocking checks. */
|
|
16
|
-
triggered: string[];
|
|
17
|
-
passed: string[];
|
|
18
|
-
blocked: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface RewindRecord {
|
|
21
|
-
id: string;
|
|
22
|
-
fromStage: FlowStage;
|
|
23
|
-
toStage: FlowStage;
|
|
24
|
-
reason: string;
|
|
25
|
-
timestamp: string;
|
|
26
|
-
invalidatedStages: FlowStage[];
|
|
27
|
-
}
|
|
28
|
-
export interface StaleStageMarker {
|
|
29
|
-
rewindId: string;
|
|
30
|
-
reason: string;
|
|
31
|
-
markedAt: string;
|
|
32
|
-
acknowledgedAt?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface RetroState {
|
|
35
|
-
required: boolean;
|
|
36
|
-
completedAt?: string;
|
|
37
|
-
compoundEntries: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Ship closeout substate machine.
|
|
41
|
-
*
|
|
42
|
-
* After ship completes, cclaw auto-chains post-ship review → archive.
|
|
43
|
-
* Each step is interruptible: `/cc` reads `shipSubstate` and resumes
|
|
44
|
-
* from the correct step even across sessions.
|
|
45
|
-
*
|
|
46
|
-
* - `idle` — ship not complete, or closeout not yet started.
|
|
47
|
-
* - `post_ship_review` — unified closeout leg: retro acceptance/edit/no changes
|
|
48
|
-
* plus compound pass execution (or explicit no-additional-changes path).
|
|
49
|
-
* - `ready_to_archive` — retro + compound done; archive is the next
|
|
50
|
-
* automatic step.
|
|
51
|
-
* - `archived` — archive completed in this session (transient — archive
|
|
52
|
-
* resets flow-state so this value does not persist between runs).
|
|
53
|
-
*
|
|
54
|
-
* Layer separation (intentional):
|
|
55
|
-
* - `next: "done"` in stage schema means "the flow stage chain ended".
|
|
56
|
-
* - `shipSubstate: "archived"` is closeout-machine progress after ship.
|
|
57
|
-
* - `shipSubstate: "idle"` is the default closeout value before ship.
|
|
58
|
-
*
|
|
59
|
-
* These are not duplicates: `done` lives in stage transitions; `archived` /
|
|
60
|
-
* `idle` live in closeout lifecycle state.
|
|
61
|
-
*/
|
|
62
|
-
export declare const SHIP_SUBSTATES: readonly ["idle", "post_ship_review", "ready_to_archive", "archived"];
|
|
63
|
-
export type ShipSubstate = (typeof SHIP_SUBSTATES)[number];
|
|
64
|
-
export interface CloseoutState {
|
|
65
|
-
shipSubstate: ShipSubstate;
|
|
66
|
-
retroDraftedAt?: string;
|
|
67
|
-
retroAcceptedAt?: string;
|
|
68
|
-
retroSkipped?: boolean;
|
|
69
|
-
retroSkipReason?: string;
|
|
70
|
-
compoundCompletedAt?: string;
|
|
71
|
-
compoundSkipped?: boolean;
|
|
72
|
-
compoundSkipReason?: string;
|
|
73
|
-
compoundPromoted: number;
|
|
74
|
-
}
|
|
75
|
-
export declare function createInitialCloseoutState(): CloseoutState;
|
|
76
|
-
export interface FlowState {
|
|
77
|
-
/** Schema marker for forward compatibility. */
|
|
1
|
+
import { type AcceptanceCriterionState, type BuildProfile, type DiscoverySpecialistId, type FlowStage } from "./types.js";
|
|
2
|
+
export declare const FLOW_STATE_SCHEMA_VERSION = 2;
|
|
3
|
+
export interface FlowStateV8 {
|
|
78
4
|
schemaVersion: typeof FLOW_STATE_SCHEMA_VERSION;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
* edges, Interaction Edge Case mandatory rows, Stale Diagram Drift,
|
|
98
|
-
* Expansion Strategist) from required → advisory.
|
|
99
|
-
*/
|
|
100
|
-
taskClass?: "software-standard" | "software-trivial" | "software-bugfix" | null;
|
|
101
|
-
/** Stages explicitly skipped for this track (empty for standard; populated for quick). */
|
|
102
|
-
skippedStages: FlowStage[];
|
|
103
|
-
/** Stages invalidated by rewind operations and awaiting explicit acknowledgement. */
|
|
104
|
-
staleStages: Partial<Record<FlowStage, StaleStageMarker>>;
|
|
105
|
-
/** Chronological rewind operations for the active run. */
|
|
106
|
-
rewinds: RewindRecord[];
|
|
107
|
-
/** Optional per-stage interaction hints carried from prior stage transitions. */
|
|
108
|
-
interactionHints?: Partial<Record<FlowStage, StageInteractionHint>>;
|
|
109
|
-
/** Mandatory retrospective gate status before archive. */
|
|
110
|
-
retro: RetroState;
|
|
111
|
-
/** Ship → post_ship_review → archive substate for resumable closeout. */
|
|
112
|
-
closeout: CloseoutState;
|
|
113
|
-
/** Repo shape signals captured at last successful start-flow (omit on legacy files). */
|
|
114
|
-
repoSignals?: RepoSignals;
|
|
115
|
-
/**
|
|
116
|
-
* Best-effort stage completion timestamps (ISO strings) captured as stages
|
|
117
|
-
* enter `completedStages`. Missing keys behave like older flows with no
|
|
118
|
-
* audit clock for post-closure mutation hints.
|
|
119
|
-
*/
|
|
120
|
-
completedStageMeta?: Partial<Record<FlowStage, {
|
|
121
|
-
completedAt: string;
|
|
122
|
-
}>>;
|
|
123
|
-
/**
|
|
124
|
-
* Minimum elapsed milliseconds between `acknowledged` and `completed`
|
|
125
|
-
* for a `slice-builder --phase green` row. The hook helper rejects
|
|
126
|
-
* fast-greens (`completedTs - ackTs < this`) with `green_evidence_too_fresh`
|
|
127
|
-
* unless the dispatch carries `--green-mode=observational`.
|
|
128
|
-
*
|
|
129
|
-
* Default 4000ms when omitted (see `effectiveTddGreenMinElapsedMs`).
|
|
130
|
-
* Operators tuning the floor for very fast suites may set it lower
|
|
131
|
-
* (e.g. `1500`) or `0` to disable the check entirely while keeping the
|
|
132
|
-
* other freshness contracts (RED test name match, passing assertion line)
|
|
133
|
-
* active.
|
|
134
|
-
*/
|
|
135
|
-
tddGreenMinElapsedMs?: number;
|
|
136
|
-
}
|
|
137
|
-
export declare const DEFAULT_TDD_GREEN_MIN_ELAPSED_MS = 4000;
|
|
138
|
-
/**
|
|
139
|
-
* Effective minimum GREEN elapsed window in milliseconds. Returns the
|
|
140
|
-
* per-project override when present and finite; otherwise the documented
|
|
141
|
-
* 4000ms default. Negative values or NaN fall through to the default so a
|
|
142
|
-
* hand-edited `flow-state.json` cannot accidentally disable the check via
|
|
143
|
-
* `-1` or `"oops"`.
|
|
144
|
-
*/
|
|
145
|
-
export declare function effectiveTddGreenMinElapsedMs(state: FlowState): number;
|
|
146
|
-
export interface StageInteractionHint {
|
|
147
|
-
skipQuestions?: boolean;
|
|
148
|
-
sourceStage?: FlowStage;
|
|
149
|
-
recordedAt?: string;
|
|
150
|
-
/**
|
|
151
|
-
* `/cc-ideate` handoff carry-forward. When a brainstorm run is started
|
|
152
|
-
* from a `/cc-ideate` recommendation, `start-flow` records the originating
|
|
153
|
-
* idea artifact so brainstorm can reuse the divergent + critique + rank
|
|
154
|
-
* work instead of re-generating it.
|
|
155
|
-
*
|
|
156
|
-
* `fromIdeaArtifact` is a workspace-relative POSIX path to
|
|
157
|
-
* `.cclaw/ideas/idea-YYYY-MM-DD-<slug>.md` (or wherever `/cc-ideate`
|
|
158
|
-
* wrote its artifact). `fromIdeaCandidateId` is the chosen `I-#` row.
|
|
159
|
-
*/
|
|
160
|
-
fromIdeaArtifact?: string;
|
|
161
|
-
fromIdeaCandidateId?: string;
|
|
162
|
-
}
|
|
163
|
-
export interface InitialFlowStateOptions {
|
|
164
|
-
activeRunId?: string;
|
|
165
|
-
track?: FlowTrack;
|
|
166
|
-
discoveryMode?: DiscoveryMode;
|
|
167
|
-
}
|
|
168
|
-
export declare function isFlowTrack(value: unknown): value is FlowTrack;
|
|
169
|
-
export declare function isDiscoveryMode(value: unknown): value is DiscoveryMode;
|
|
170
|
-
export declare function trackStages(track: FlowTrack): FlowStage[];
|
|
171
|
-
export declare function skippedStagesForTrack(track: FlowTrack): FlowStage[];
|
|
172
|
-
export declare function firstStageForTrack(track: FlowTrack): FlowStage;
|
|
173
|
-
export declare function createRunId(date?: Date): string;
|
|
174
|
-
export declare function createInitialFlowState(activeRunIdOrOptions?: string | InitialFlowStateOptions, maybeTrack?: FlowTrack): FlowState;
|
|
175
|
-
export declare function canTransition(from: FlowStage, to: FlowStage): boolean;
|
|
176
|
-
export declare function getAvailableTransitions(from: FlowStage, track?: FlowTrack): TransitionRule[];
|
|
177
|
-
export declare function getTransitionGuards(from: FlowStage, to: FlowStage, track?: FlowTrack): string[];
|
|
178
|
-
export declare function nextStage(stage: FlowStage, track?: FlowTrack): FlowStage | null;
|
|
179
|
-
export declare function previousStage(stage: FlowStage, track?: FlowTrack): FlowStage | null;
|
|
5
|
+
currentSlug: string | null;
|
|
6
|
+
currentStage: FlowStage | null;
|
|
7
|
+
ac: AcceptanceCriterionState[];
|
|
8
|
+
lastSpecialist: DiscoverySpecialistId | null;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
reviewIterations: number;
|
|
11
|
+
securityFlag: boolean;
|
|
12
|
+
buildProfile?: BuildProfile;
|
|
13
|
+
}
|
|
14
|
+
export type FlowState = FlowStateV8;
|
|
15
|
+
export declare class LegacyFlowStateError extends Error {
|
|
16
|
+
readonly observedSchemaVersion: unknown;
|
|
17
|
+
constructor(message: string, observedSchemaVersion: unknown);
|
|
18
|
+
}
|
|
19
|
+
export declare function isFlowStage(value: unknown): value is FlowStage;
|
|
20
|
+
export declare function isDiscoverySpecialist(value: unknown): value is DiscoverySpecialistId;
|
|
21
|
+
export declare function createInitialFlowStateV8(nowIso?: string): FlowStateV8;
|
|
22
|
+
export declare function assertFlowStateV8(value: unknown): asserts value is FlowStateV8;
|
package/dist/flow-state.js
CHANGED
|
@@ -1,185 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* from the correct step even across sessions.
|
|
11
|
-
*
|
|
12
|
-
* - `idle` — ship not complete, or closeout not yet started.
|
|
13
|
-
* - `post_ship_review` — unified closeout leg: retro acceptance/edit/no changes
|
|
14
|
-
* plus compound pass execution (or explicit no-additional-changes path).
|
|
15
|
-
* - `ready_to_archive` — retro + compound done; archive is the next
|
|
16
|
-
* automatic step.
|
|
17
|
-
* - `archived` — archive completed in this session (transient — archive
|
|
18
|
-
* resets flow-state so this value does not persist between runs).
|
|
19
|
-
*
|
|
20
|
-
* Layer separation (intentional):
|
|
21
|
-
* - `next: "done"` in stage schema means "the flow stage chain ended".
|
|
22
|
-
* - `shipSubstate: "archived"` is closeout-machine progress after ship.
|
|
23
|
-
* - `shipSubstate: "idle"` is the default closeout value before ship.
|
|
24
|
-
*
|
|
25
|
-
* These are not duplicates: `done` lives in stage transitions; `archived` /
|
|
26
|
-
* `idle` live in closeout lifecycle state.
|
|
27
|
-
*/
|
|
28
|
-
export const SHIP_SUBSTATES = [
|
|
29
|
-
"idle",
|
|
30
|
-
"post_ship_review",
|
|
31
|
-
"ready_to_archive",
|
|
32
|
-
"archived"
|
|
33
|
-
];
|
|
34
|
-
export function createInitialCloseoutState() {
|
|
35
|
-
return {
|
|
36
|
-
shipSubstate: "idle",
|
|
37
|
-
retroDraftedAt: undefined,
|
|
38
|
-
retroAcceptedAt: undefined,
|
|
39
|
-
retroSkipped: undefined,
|
|
40
|
-
retroSkipReason: undefined,
|
|
41
|
-
compoundCompletedAt: undefined,
|
|
42
|
-
compoundSkipped: undefined,
|
|
43
|
-
compoundSkipReason: undefined,
|
|
44
|
-
compoundPromoted: 0
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export const DEFAULT_TDD_GREEN_MIN_ELAPSED_MS = 4000;
|
|
48
|
-
/**
|
|
49
|
-
* Effective minimum GREEN elapsed window in milliseconds. Returns the
|
|
50
|
-
* per-project override when present and finite; otherwise the documented
|
|
51
|
-
* 4000ms default. Negative values or NaN fall through to the default so a
|
|
52
|
-
* hand-edited `flow-state.json` cannot accidentally disable the check via
|
|
53
|
-
* `-1` or `"oops"`.
|
|
54
|
-
*/
|
|
55
|
-
export function effectiveTddGreenMinElapsedMs(state) {
|
|
56
|
-
const raw = state.tddGreenMinElapsedMs;
|
|
57
|
-
if (typeof raw !== "number")
|
|
58
|
-
return DEFAULT_TDD_GREEN_MIN_ELAPSED_MS;
|
|
59
|
-
if (!Number.isFinite(raw))
|
|
60
|
-
return DEFAULT_TDD_GREEN_MIN_ELAPSED_MS;
|
|
61
|
-
if (raw < 0)
|
|
62
|
-
return DEFAULT_TDD_GREEN_MIN_ELAPSED_MS;
|
|
63
|
-
return Math.floor(raw);
|
|
64
|
-
}
|
|
65
|
-
export function isFlowTrack(value) {
|
|
66
|
-
return typeof value === "string" && FLOW_TRACKS.includes(value);
|
|
67
|
-
}
|
|
68
|
-
export function isDiscoveryMode(value) {
|
|
69
|
-
return typeof value === "string" && DISCOVERY_MODES.includes(value);
|
|
70
|
-
}
|
|
71
|
-
export function trackStages(track) {
|
|
72
|
-
return [...TRACK_STAGES[track]];
|
|
73
|
-
}
|
|
74
|
-
export function skippedStagesForTrack(track) {
|
|
75
|
-
const inTrack = new Set(TRACK_STAGES[track]);
|
|
76
|
-
return FLOW_STAGES.filter((stage) => !inTrack.has(stage));
|
|
1
|
+
import { FLOW_STAGES } from "./types.js";
|
|
2
|
+
export const FLOW_STATE_SCHEMA_VERSION = 2;
|
|
3
|
+
export class LegacyFlowStateError extends Error {
|
|
4
|
+
observedSchemaVersion;
|
|
5
|
+
constructor(message, observedSchemaVersion) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.observedSchemaVersion = observedSchemaVersion;
|
|
8
|
+
this.name = "LegacyFlowStateError";
|
|
9
|
+
}
|
|
77
10
|
}
|
|
78
|
-
export function
|
|
79
|
-
|
|
80
|
-
return stages[0] ?? "brainstorm";
|
|
11
|
+
export function isFlowStage(value) {
|
|
12
|
+
return typeof value === "string" && FLOW_STAGES.includes(value);
|
|
81
13
|
}
|
|
82
|
-
export function
|
|
83
|
-
return
|
|
14
|
+
export function isDiscoverySpecialist(value) {
|
|
15
|
+
return value === "brainstormer" || value === "architect" || value === "planner";
|
|
84
16
|
}
|
|
85
|
-
export function
|
|
86
|
-
const options = typeof activeRunIdOrOptions === "string"
|
|
87
|
-
? { activeRunId: activeRunIdOrOptions, track: maybeTrack }
|
|
88
|
-
: activeRunIdOrOptions;
|
|
89
|
-
const activeRunId = options.activeRunId ?? createRunId();
|
|
90
|
-
const track = options.track ?? "standard";
|
|
91
|
-
const discoveryMode = options.discoveryMode ?? "guided";
|
|
92
|
-
const skippedStages = skippedStagesForTrack(track);
|
|
93
|
-
const stageGateCatalog = {};
|
|
94
|
-
for (const schema of orderedStageSchemas(track)) {
|
|
95
|
-
stageGateCatalog[schema.stage] = {
|
|
96
|
-
required: stageGateIds(schema.stage, track),
|
|
97
|
-
recommended: stageRecommendedGateIds(schema.stage, track),
|
|
98
|
-
conditional: [],
|
|
99
|
-
triggered: [],
|
|
100
|
-
passed: [],
|
|
101
|
-
blocked: []
|
|
102
|
-
};
|
|
103
|
-
}
|
|
17
|
+
export function createInitialFlowStateV8(nowIso = new Date().toISOString()) {
|
|
104
18
|
return {
|
|
105
19
|
schemaVersion: FLOW_STATE_SCHEMA_VERSION,
|
|
106
|
-
|
|
107
|
-
currentStage:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
skippedStages,
|
|
114
|
-
staleStages: {},
|
|
115
|
-
rewinds: [],
|
|
116
|
-
interactionHints: {},
|
|
117
|
-
retro: {
|
|
118
|
-
required: false,
|
|
119
|
-
completedAt: undefined,
|
|
120
|
-
compoundEntries: 0
|
|
121
|
-
},
|
|
122
|
-
closeout: createInitialCloseoutState()
|
|
20
|
+
currentSlug: null,
|
|
21
|
+
currentStage: null,
|
|
22
|
+
ac: [],
|
|
23
|
+
lastSpecialist: null,
|
|
24
|
+
startedAt: nowIso,
|
|
25
|
+
reviewIterations: 0,
|
|
26
|
+
securityFlag: false
|
|
123
27
|
};
|
|
124
28
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
29
|
+
function assertAcArray(value) {
|
|
30
|
+
if (!Array.isArray(value))
|
|
31
|
+
throw new Error("flow-state.ac must be an array");
|
|
32
|
+
for (const item of value) {
|
|
33
|
+
if (typeof item !== "object" || item === null)
|
|
34
|
+
throw new Error("flow-state.ac entries must be objects");
|
|
35
|
+
const ac = item;
|
|
36
|
+
if (typeof ac.id !== "string" || typeof ac.text !== "string") {
|
|
37
|
+
throw new Error("flow-state.ac entries require string id and text");
|
|
38
|
+
}
|
|
39
|
+
if (ac.status !== "pending" && ac.status !== "committed") {
|
|
40
|
+
throw new Error(`Invalid AC status: ${String(ac.status)}`);
|
|
41
|
+
}
|
|
42
|
+
if (ac.phases !== undefined) {
|
|
43
|
+
if (typeof ac.phases !== "object" || ac.phases === null) {
|
|
44
|
+
throw new Error("flow-state.ac.phases must be an object when present");
|
|
45
|
+
}
|
|
46
|
+
for (const phaseKey of Object.keys(ac.phases)) {
|
|
47
|
+
if (phaseKey !== "red" && phaseKey !== "green" && phaseKey !== "refactor") {
|
|
48
|
+
throw new Error(`Invalid TDD phase key: ${phaseKey}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
133
52
|
}
|
|
134
|
-
return fromRules.sort((a, b) => {
|
|
135
|
-
if (a.to === natural && b.to !== natural)
|
|
136
|
-
return -1;
|
|
137
|
-
if (b.to === natural && a.to !== natural)
|
|
138
|
-
return 1;
|
|
139
|
-
return a.to.localeCompare(b.to);
|
|
140
|
-
});
|
|
141
53
|
}
|
|
142
|
-
export function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// gets lost if quick was registered first).
|
|
149
|
-
const ordered = TRACK_STAGES[track];
|
|
150
|
-
const fromIdx = ordered.indexOf(from);
|
|
151
|
-
if (fromIdx >= 0 && ordered[fromIdx + 1] === to) {
|
|
152
|
-
return stageGateIds(from, track);
|
|
54
|
+
export function assertFlowStateV8(value) {
|
|
55
|
+
if (typeof value !== "object" || value === null)
|
|
56
|
+
throw new Error("flow-state must be an object");
|
|
57
|
+
const state = value;
|
|
58
|
+
if (state.schemaVersion !== FLOW_STATE_SCHEMA_VERSION) {
|
|
59
|
+
throw new LegacyFlowStateError("Unsupported flow-state schema. cclaw v8 cannot resume 7.x runs. Finish or abandon the old run, then delete .cclaw/state/flow-state.json.", state.schemaVersion);
|
|
153
60
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// back to the pre-computed rule table.
|
|
157
|
-
const match = TRANSITION_RULES.find((rule) => rule.from === from && rule.to === to);
|
|
158
|
-
return match ? [...match.guards] : [];
|
|
159
|
-
}
|
|
160
|
-
export function nextStage(stage, track = "standard") {
|
|
161
|
-
const ordered = TRACK_STAGES[track];
|
|
162
|
-
const index = ordered.indexOf(stage);
|
|
163
|
-
if (index < 0) {
|
|
164
|
-
return null;
|
|
61
|
+
if (state.currentSlug !== null && state.currentSlug !== undefined && typeof state.currentSlug !== "string") {
|
|
62
|
+
throw new Error("flow-state.currentSlug must be a string or null");
|
|
165
63
|
}
|
|
166
|
-
if (
|
|
167
|
-
|
|
64
|
+
if (state.currentStage !== null && state.currentStage !== undefined && !isFlowStage(state.currentStage)) {
|
|
65
|
+
throw new Error(`Invalid currentStage: ${String(state.currentStage)}`);
|
|
168
66
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const ordered = TRACK_STAGES[track];
|
|
173
|
-
const index = ordered.indexOf(stage);
|
|
174
|
-
if (index === 0) {
|
|
175
|
-
return null;
|
|
67
|
+
assertAcArray(state.ac);
|
|
68
|
+
if (state.lastSpecialist !== null && state.lastSpecialist !== undefined && !isDiscoverySpecialist(state.lastSpecialist)) {
|
|
69
|
+
throw new Error(`Invalid lastSpecialist: ${String(state.lastSpecialist)}`);
|
|
176
70
|
}
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
71
|
+
if (typeof state.startedAt !== "string")
|
|
72
|
+
throw new Error("flow-state.startedAt must be a string");
|
|
73
|
+
if (typeof state.reviewIterations !== "number" || state.reviewIterations < 0) {
|
|
74
|
+
throw new Error("flow-state.reviewIterations must be a non-negative number");
|
|
75
|
+
}
|
|
76
|
+
if (typeof state.securityFlag !== "boolean") {
|
|
77
|
+
throw new Error("flow-state.securityFlag must be a boolean");
|
|
78
|
+
}
|
|
79
|
+
if (state.buildProfile !== undefined && state.buildProfile !== "default" && state.buildProfile !== "bootstrap") {
|
|
80
|
+
throw new Error(`Invalid buildProfile: ${String(state.buildProfile)}`);
|
|
183
81
|
}
|
|
184
|
-
return ordered[index - 1];
|
|
185
82
|
}
|
package/dist/fs-utils.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
export declare function ensureDir(dirPath: string): Promise<void>;
|
|
2
|
-
/**
|
|
3
|
-
* Strip a leading UTF-8 BOM (U+FEFF) if present. Many editors (VS Code on
|
|
4
|
-
* Windows, Notepad, some CI tools) silently prepend a BOM when saving
|
|
5
|
-
* UTF-8; when the file is then split on `\n` the first line keeps the
|
|
6
|
-
* invisible BOM and `JSON.parse` rejects it, which caused the first
|
|
7
|
-
* knowledge.jsonl entry to be silently dropped on load. Treat BOM as a
|
|
8
|
-
* no-op at read time so the rest of the pipeline sees clean UTF-8.
|
|
9
|
-
*/
|
|
10
|
-
export declare function stripBom(text: string): string;
|
|
11
|
-
export interface DirectoryLockOptions {
|
|
12
|
-
retries?: number;
|
|
13
|
-
retryDelayMs?: number;
|
|
14
|
-
staleAfterMs?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Acquire a lightweight lock by creating a directory.
|
|
18
|
-
* The lock is removed in a finally block.
|
|
19
|
-
*/
|
|
20
|
-
export declare function withDirectoryLock<T>(lockPath: string, fn: () => Promise<T>, options?: DirectoryLockOptions): Promise<T>;
|
|
21
|
-
export interface WriteFileSafeOptions {
|
|
22
|
-
mode?: number;
|
|
23
|
-
}
|
|
24
|
-
export declare function writeFileSafe(filePath: string, content: string, options?: WriteFileSafeOptions): Promise<void>;
|
|
25
1
|
export declare function exists(filePath: string): Promise<boolean>;
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
2
|
+
export declare function ensureDir(dirPath: string): Promise<void>;
|
|
3
|
+
export declare function writeFileSafe(filePath: string, content: string): Promise<void>;
|
|
4
|
+
export declare function readJsonIfExists<T>(filePath: string): Promise<T | null>;
|
|
5
|
+
export declare function removePath(filePath: string): Promise<void>;
|
|
6
|
+
export declare function listMarkdownFiles(dir: string): Promise<string[]>;
|
|
7
|
+
export declare function listSubdirs(dir: string): Promise<string[]>;
|