@wrongstack/sdd 0.284.1 → 0.285.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 (55) hide show
  1. package/dist/auto-executor.d.ts +89 -0
  2. package/dist/auto-executor.d.ts.map +1 -0
  3. package/dist/board-types.d.ts +144 -0
  4. package/dist/board-types.d.ts.map +1 -0
  5. package/dist/conflict-resolver.d.ts +45 -0
  6. package/dist/conflict-resolver.d.ts.map +1 -0
  7. package/dist/critical-path.d.ts +36 -0
  8. package/dist/critical-path.d.ts.map +1 -0
  9. package/dist/decompose-task.d.ts +20 -0
  10. package/dist/decompose-task.d.ts.map +1 -0
  11. package/dist/index.d.ts +26 -1864
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +192 -76
  14. package/dist/index.js.map +7 -1
  15. package/dist/sdd-board-projector.d.ts +83 -0
  16. package/dist/sdd-board-projector.d.ts.map +1 -0
  17. package/dist/sdd-board-store.d.ts +59 -0
  18. package/dist/sdd-board-store.d.ts.map +1 -0
  19. package/dist/sdd-interview-driver.d.ts +131 -0
  20. package/dist/sdd-interview-driver.d.ts.map +1 -0
  21. package/dist/sdd-lifecycle.d.ts +146 -0
  22. package/dist/sdd-lifecycle.d.ts.map +1 -0
  23. package/dist/sdd-parallel-run.d.ts +427 -0
  24. package/dist/sdd-parallel-run.d.ts.map +1 -0
  25. package/dist/sdd-run-registry.d.ts +68 -0
  26. package/dist/sdd-run-registry.d.ts.map +1 -0
  27. package/dist/sdd-supervisor.d.ts +52 -0
  28. package/dist/sdd-supervisor.d.ts.map +1 -0
  29. package/dist/sdd-task-decomposer.d.ts +89 -0
  30. package/dist/sdd-task-decomposer.d.ts.map +1 -0
  31. package/dist/spec-builder.d.ts +139 -0
  32. package/dist/spec-builder.d.ts.map +1 -0
  33. package/dist/spec-parser.d.ts +14 -0
  34. package/dist/spec-parser.d.ts.map +1 -0
  35. package/dist/spec-store.d.ts +36 -0
  36. package/dist/spec-store.d.ts.map +1 -0
  37. package/dist/spec-templates.d.ts +22 -0
  38. package/dist/spec-templates.d.ts.map +1 -0
  39. package/dist/spec-versioning.d.ts +49 -0
  40. package/dist/spec-versioning.d.ts.map +1 -0
  41. package/dist/start-sdd-run.d.ts +67 -0
  42. package/dist/start-sdd-run.d.ts.map +1 -0
  43. package/dist/task-flow.d.ts +99 -0
  44. package/dist/task-flow.d.ts.map +1 -0
  45. package/dist/task-generator.d.ts +39 -0
  46. package/dist/task-generator.d.ts.map +1 -0
  47. package/dist/task-graph-store.d.ts +33 -0
  48. package/dist/task-graph-store.d.ts.map +1 -0
  49. package/dist/task-tracker.d.ts +2 -0
  50. package/dist/task-tracker.d.ts.map +1 -0
  51. package/dist/task-visualizer.d.ts +26 -0
  52. package/dist/task-visualizer.d.ts.map +1 -0
  53. package/dist/verify-task.d.ts +23 -0
  54. package/dist/verify-task.d.ts.map +1 -0
  55. package/package.json +4 -5
@@ -0,0 +1,83 @@
1
+ /**
2
+ * SddBoardProjector
3
+ *
4
+ * Composes a live SDD board snapshot from a running graph and streams it to
5
+ * every surface. It subscribes to `TaskTracker` mutations (the source of truth
6
+ * for task state) plus the run's `sdd.*` lifecycle events (status / wave /
7
+ * deadlock), and on each change — throttled — rebuilds a `SddBoardSnapshot`,
8
+ * emits `sdd.board.snapshot` on the EventBus, persists it (JSON) and appends the
9
+ * triggering event to the board's JSONL log.
10
+ *
11
+ * The graph is the single source of truth: task status/assignee/worktree live
12
+ * on the nodes (the run mutates them through the tracker), so the projector
13
+ * mostly re-derives the snapshot and only tracks run-level status/wave/deadlock.
14
+ */
15
+ import type { EventBus } from '@wrongstack/core/kernel';
16
+ import type { TaskGraph } from '@wrongstack/core/types';
17
+ import type { TaskTracker } from '@wrongstack/core/tasking';
18
+ import type { SddBoardStore } from './sdd-board-store.js';
19
+ export interface SddBoardProjectorOptions {
20
+ runId: string;
21
+ graph: TaskGraph;
22
+ tracker: TaskTracker;
23
+ events: EventBus;
24
+ /** Parent session id for emitted `sdd.board.snapshot` events. */
25
+ sessionId?: string | (() => string | undefined) | undefined;
26
+ /** Persist snapshots + JSONL events (optional — omit for in-memory only). */
27
+ store?: SddBoardStore | undefined;
28
+ specId?: string | undefined;
29
+ /** Run-level default worker model/provider/fallbacks (shown in the board header). */
30
+ defaultModel?: string | undefined;
31
+ defaultProvider?: string | undefined;
32
+ fallbackModels?: string[] | undefined;
33
+ /** Base branch the run's squash commits land on (for the board + rollback). */
34
+ baseBranch?: string | undefined;
35
+ /** Snapshot coalescing window in ms (default 250). */
36
+ throttleMs?: number | undefined;
37
+ /** Clock injection for tests; defaults to Date.now. */
38
+ now?: (() => number) | undefined;
39
+ }
40
+ export declare class SddBoardProjector {
41
+ private readonly o;
42
+ private readonly now;
43
+ private readonly throttleMs;
44
+ private readonly shortId;
45
+ private status;
46
+ private wave;
47
+ private startedAt;
48
+ private deadlockChains;
49
+ /** Live activity feed, most recent first (capped). */
50
+ private feed;
51
+ private static readonly FEED_CAP;
52
+ private finished;
53
+ private runDeadlocked;
54
+ private runStopped;
55
+ /** Squash commits the run landed on the base branch (for post-run rollback). */
56
+ private mergedCommits;
57
+ /** Base branch reported by the run at start (overrides the constructor option). */
58
+ private runBaseBranch;
59
+ private dirty;
60
+ private timer;
61
+ private readonly unsubs;
62
+ /** Tail of in-flight persistence, so callers can await a settled state. */
63
+ private lastSave;
64
+ constructor(opts: SddBoardProjectorOptions);
65
+ private pushFeed;
66
+ /** ` (title…)` suffix for a feed line, or '' when the node/title is missing. */
67
+ private titleOf;
68
+ private assigneeOf;
69
+ /** Latest snapshot, built on demand (e.g. for a late-joining client). */
70
+ snapshot(): import("./board-types.js").SddBoardSnapshot;
71
+ /** Resolve once all in-flight snapshot persistence has settled. */
72
+ drain(): Promise<void>;
73
+ /** Stop projecting and release subscriptions. */
74
+ dispose(): void;
75
+ /** Subscribe to a run event scoped to this run id; also append to JSONL. */
76
+ private onRun;
77
+ private resolveStatus;
78
+ private build;
79
+ private markDirty;
80
+ private flush;
81
+ private currentSessionId;
82
+ }
83
+ //# sourceMappingURL=sdd-board-projector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdd-board-projector.d.ts","sourceRoot":"","sources":["../src/sdd-board-projector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAQ5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,QAAQ,CAAC;IACjB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAC5D,6EAA6E;IAC7E,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACtC,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,uDAAuD;IACvD,GAAG,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;CAClC;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAA2B;IAC7C,O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shots + event logs (wpaths.projectSddBoards). */
4
+ baseDir: string;
5
+ }
6
+ export interface SddBoardIndexEntry {
7
+ runId: string;
8
+ specId?: string | undefined;
9
+ title: string;
10
+ status: string;
11
+ total: number;
12
+ completed: number;
13
+ updatedAt: number;
14
+ }
15
+ /** One appended line in a board's JSONL event log. */
16
+ export interface SddBoardEvent {
17
+ ts: number;
18
+ type: string;
19
+ payload?: unknown;
20
+ }
21
+ /**
22
+ * File-backed SDD board storage. Each board (= one parallel run) has:
23
+ * - `<runId>.json` — latest full snapshot (atomic; resume + standalone-webui mirror)
24
+ * - `<runId>.events.jsonl`— append-only event log (audit / replay)
25
+ * - `<runId>.control.jsonl` — append-only command queue (cross-process control, written by readers)
26
+ * plus `_index.json` for fast listing. JSON for state, JSONL for streams.
27
+ */
28
+ export declare class SddBoardStore {
29
+ private readonly baseDir;
30
+ private readonly indexPath;
31
+ constructor(opts: SddBoardStoreOptions);
32
+ snapshotPath(runId: string): string;
33
+ eventsPath(runId: string): string;
34
+ controlPath(runId: string): string;
35
+ saveSnapshot(snapshot: SddBoardSnapshot): Promise<void>;
36
+ load(runId: string): Promise<SddBoardSnapshot | null>;
37
+ list(): Promise<SddBoardIndexEntry[]>;
38
+ loadLatestForSpec(specId: string): Promise<SddBoardSnapshot | null>;
39
+ /** Append one line to the board's JSONL event log (best-effort, never throws). */
40
+ appendEvent(runId: string, event: SddBoardEvent): Promise<void>;
41
+ /** Append a control command (used by readers to steer a CLI-owned run). */
42
+ appendControl(runId: string, command: {
43
+ ts: number;
44
+ type: string;
45
+ payload?: unknown;
46
+ }): Promise<void>;
47
+ /** Read + truncate the control queue (the run drains it). Returns parsed commands. */
48
+ drainControl(runId: string): Promise<Array<{
49
+ ts: number;
50
+ type: string;
51
+ payload?: unknown;
52
+ }>>;
53
+ delete(runId: string): Promise<void>;
54
+ private safe;
55
+ private readIndex;
56
+ private updateIndex;
57
+ private removeFromIndex;
58
+ }
59
+ //# sourceMappingURL=sdd-board-store.d.ts.map
@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gBAAgB,GAAG,IAAI,CAAC,CAGxE;IAED,kFAAkF;IAC5E,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpE;IAED,2EAA2E;IACrE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1G;IAED,sFAAsF;IAChF,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAwBjG;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzC;IAID,OAAO,CAAC,IAAI;YAIE,SAAS;YAWT,WAAW;YAiBX,eAAe;CAK9B"}
@@ -0,0 +1,131 @@
1
+ import type { TaskGraph } from '@wrongstack/core/types';
2
+ import { AISpecBuilder, type AISpecPhase } from './spec-builder.js';
3
+ import type { SpecStore } from './spec-store.js';
4
+ import type { TaskGraphStore } from './task-graph-store.js';
5
+ import { TaskTracker } from '@wrongstack/core/tasking';
6
+ import { type SddBoardTask, type SddBoardColumn } from './board-types.js';
7
+ export interface SddInterviewDriverOptions {
8
+ /** Disk-backed spec store (`wpaths.projectSpecs`). */
9
+ specStore: SpecStore;
10
+ /** Disk-backed task-graph store (`wpaths.projectTaskGraphs`). */
11
+ graphStore: TaskGraphStore;
12
+ /** Persist the interview session here so a reconnect can resume it. */
13
+ sessionPath?: string | undefined;
14
+ /** Project context string injected into the questioning prompt. */
15
+ projectContext?: string | undefined;
16
+ minQuestions?: number | undefined;
17
+ maxQuestions?: number | undefined;
18
+ }
19
+ /** A serialisable view of the interview, streamed to observing surfaces. */
20
+ export interface SddInterviewSnapshot {
21
+ sessionId: string;
22
+ phase: AISpecPhase;
23
+ title: string;
24
+ /** The operator's original goal prompt (verbatim). `title` is a short heading. */
25
+ goal: string;
26
+ questionCount: number;
27
+ minQuestions: number;
28
+ maxQuestions: number;
29
+ answers: Array<{
30
+ question: string;
31
+ answer: string;
32
+ }>;
33
+ spec?: {
34
+ id: string;
35
+ title: string;
36
+ overview: string;
37
+ requirements: Array<{
38
+ priority: string;
39
+ description: string;
40
+ }>;
41
+ } | undefined;
42
+ graphId?: string | undefined;
43
+ taskCount: number;
44
+ /**
45
+ * Topologically-laid-out task graph (once decomposed) — lets the wizard
46
+ * render the same animated DAG as the live board ("decomposition reveal").
47
+ */
48
+ board?: {
49
+ tasks: SddBoardTask[];
50
+ columns: SddBoardColumn[];
51
+ } | undefined;
52
+ /** The current AI prompt for this phase (what to send the agent next). */
53
+ prompt: string;
54
+ }
55
+ /** What `ingestAgentOutput` detected and acted on. */
56
+ export interface SddIngestResult {
57
+ specDetected: boolean;
58
+ implementationDetected: boolean;
59
+ tasksDetected: boolean;
60
+ graphId?: string | undefined;
61
+ }
62
+ export declare class SddInterviewDriver {
63
+ readonly builder: AISpecBuilder;
64
+ private readonly o;
65
+ private readonly minQuestions;
66
+ private readonly maxQuestions;
67
+ private tracker;
68
+ private graph;
69
+ constructor(opts: SddInterviewDriverOptions);
70
+ /** Begin a fresh interview. Returns the first AI prompt (a question kickoff). */
71
+ start(title: string, intent?: string): string;
72
+ /**
73
+ * Resume a previously-persisted interview from disk. Re-hydrates the task
74
+ * graph too when one was already produced. Returns true if a session loaded.
75
+ */
76
+ loadExisting(): Promise<boolean>;
77
+ phase(): AISpecPhase;
78
+ currentPrompt(): string;
79
+ getTracker(): TaskTracker | null;
80
+ getGraph(): TaskGraph | null;
81
+ /** Record a Q/A pair (the agent asked `question`, the user replied `answer`). */
82
+ submitAnswer(question: string, answer: string): void;
83
+ /**
84
+ * Feed the agent's text output back into the interview. Detects, in order:
85
+ * 1. a Specification JSON → setSpec (phase → spec_review) + persist to SpecStore
86
+ * 2. an implementation plan (implementation phase) → setImplementation
87
+ * 3. a task JSON array → build + persist a TaskGraph
88
+ * Each step is independent and best-effort; a malformed payload is ignored
89
+ * rather than thrown, so a chatty agent turn never breaks the interview.
90
+ */
91
+ ingestAgentOutput(text: string): Promise<SddIngestResult>;
92
+ /**
93
+ * Advance to the next phase (mirrors `/sdd approve`). When moving into the
94
+ * executing phase, guarantees a task graph exists — deterministically
95
+ * generating one from the approved spec if the agent never emitted a valid
96
+ * task array. Returns the new phase and its AI prompt.
97
+ */
98
+ approve(): Promise<{
99
+ phase: AISpecPhase;
100
+ prompt: string;
101
+ }>;
102
+ /**
103
+ * Ensure a TaskGraph exists for the approved spec. If the agent already
104
+ * produced one (via `ingestAgentOutput`), returns it; otherwise builds a
105
+ * deterministic graph from the spec's requirements via TaskGenerator. This is
106
+ * the robustness backstop: a run can always start, even if the model never
107
+ * emitted a parseable task array.
108
+ */
109
+ ensureTaskGraph(): Promise<TaskGraph | null>;
110
+ snapshot(): SddInterviewSnapshot;
111
+ private persistSpec;
112
+ private persistGraph;
113
+ /**
114
+ * Port of the CLI `trySaveImplementationPlan` operating on this driver's
115
+ * builder. Captures the prose plan that precedes the task JSON block.
116
+ */
117
+ private trySaveImplementationPlan;
118
+ /**
119
+ * Port of the CLI `trySaveTasksFromAIOutput`: parse a task JSON array from the
120
+ * agent output, build (or extend) the tracker + graph, persist to disk, and
121
+ * link the graphId to the session. Returns the graphId on success.
122
+ */
123
+ private tryBuildTasksFromOutput;
124
+ }
125
+ /**
126
+ * True when the text reads like conversational filler rather than a structured
127
+ * implementation plan. Ported verbatim from the CLI detection so behaviour is
128
+ * identical across surfaces.
129
+ */
130
+ export declare function isExplanatoryText(text: string): boolean;
131
+ //# sourceMappingURL=sdd-interview-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdd-interview-driver.d.ts","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AAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAEnD;IAED;;;;;;;OAOG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAiC9D;IAED;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAM/D;IAED;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAmBjD;IAED,QAAQ,IAAI,oBAAoB,CA4B/B;YAIa,WAAW;YAQX,YAAY;IAQ1B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAsBjC;;;;OAIG;YACW,uBAAuB;CAsDtC;AA0BD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAkBvD"}
@@ -0,0 +1,146 @@
1
+ /** Force-remove every git worktree + branch a previous run left behind. */
2
+ export declare function cleanupSddWorktrees(projectRoot: string): Promise<{
3
+ removed: number;
4
+ }>;
5
+ /**
6
+ * Detect and clean up stale worktrees from a crashed previous run.
7
+ * No-op when the project is clean. Called on SDD/Director boot to
8
+ * prevent orphaned worktrees from conflicting with the next run's
9
+ * `allocate()`.
10
+ *
11
+ * P2 #B6 (sprint2 audit).
12
+ */
13
+ export declare function cleanupStaleWorktrees(projectRoot: string): Promise<{
14
+ removed: number;
15
+ detected: number;
16
+ }>;
17
+ export interface CleanupStaleSddOptions {
18
+ projectRoot: string;
19
+ /** Board snapshot dir (`wpaths.projectSddBoards`) — read for the liveness guard. */
20
+ boardsDir: string;
21
+ /** A `running` board updated within this window is treated as live → skip. Default 120_000 (2 min). */
22
+ runningLiveMs?: number | undefined;
23
+ /** A `paused` board updated within this window is treated as live → skip. Default 1_800_000 (30 min). */
24
+ pausedLiveMs?: number | undefined;
25
+ /** Injectable clock for tests. */
26
+ now?: (() => number) | undefined;
27
+ }
28
+ export interface CleanupStaleSddResult {
29
+ /** True when a sweep ran (orphans were found and removed). */
30
+ swept: boolean;
31
+ removed: number;
32
+ detected: number;
33
+ /** Set when the sweep was skipped because a run appears live. */
34
+ skippedReason?: string | undefined;
35
+ }
36
+ /**
37
+ * Liveness-guarded stale-worktree sweep for boot + run-start. Worktrees live
38
+ * under `<projectRoot>/.wrongstack/worktrees` and a sweep force-removes ALL of
39
+ * them — so it must NEVER run under a genuinely live run (possibly in another
40
+ * process). The guard reads the latest board: a `running` board updated within
41
+ * `runningLiveMs`, or a `paused` one within `pausedLiveMs`, is treated as live
42
+ * and the sweep is skipped. A crashed run leaves its board frozen as `running`
43
+ * → once it ages past the window it is correctly swept. Any other status
44
+ * (completed / failed / stopped / deadlocked / idle) is always sweepable.
45
+ * Never throws — best-effort cleanup.
46
+ */
47
+ export declare function cleanupStaleSddWorktrees(opts: CleanupStaleSddOptions): Promise<CleanupStaleSddResult>;
48
+ export interface RollbackFromDiskOptions {
49
+ projectRoot: string;
50
+ /** Directory holding persisted board snapshots (`wpaths.projectSddBoards`). */
51
+ boardsDir: string;
52
+ /** Specific run to roll back. Omit → the most recently updated board. */
53
+ runId?: string | undefined;
54
+ }
55
+ /**
56
+ * Roll back a finished run's merged commits by reading its persisted board
57
+ * snapshot (base branch + commit SHAs) and reverting each. History-preserving;
58
+ * refuses on a dirty tree or revert conflict (surfaced in `reason`). Returns
59
+ * `ok:false` with a reason when there is no board, no base branch, or nothing to
60
+ * revert.
61
+ */
62
+ export declare function rollbackSddRunFromDisk(opts: RollbackFromDiskOptions): Promise<{
63
+ ok: boolean;
64
+ reverted: number;
65
+ reason?: string;
66
+ }>;
67
+ export interface DestroySddProjectOptions {
68
+ projectRoot: string;
69
+ /** Resolved wstack paths to delete. */
70
+ paths: {
71
+ projectSpecs: string;
72
+ projectTaskGraphs: string;
73
+ projectSddSession: string;
74
+ projectSddBoards: string;
75
+ };
76
+ /**
77
+ * Also revert this run's already-merged squash commits (history-preserving
78
+ * `git revert`) BEFORE deleting the board that records them. Off by default —
79
+ * a plain destroy wipes worktrees + artifacts but leaves merged commits on the
80
+ * base branch (un-merged worktree work is destroyed regardless, since its
81
+ * branch is force-removed). When on and the working tree is dirty, the revert
82
+ * is refused and surfaced in `revertReason` (the destroy still proceeds).
83
+ */
84
+ revertMerged?: boolean | undefined;
85
+ /** Which run's merged commits to revert. Omit → the most recently updated board. */
86
+ runId?: string | undefined;
87
+ }
88
+ export interface DestroySddProjectResult {
89
+ worktreesRemoved: number;
90
+ /** Human labels of the artifacts that were deleted. */
91
+ deleted: string[];
92
+ /** Number of merged commits reverted (only when `revertMerged` was set). */
93
+ reverted: number;
94
+ /** Whether the optional merged-commit revert succeeded (undefined → not requested). */
95
+ revertOk?: boolean | undefined;
96
+ /** Why the revert did not fully apply (dirty tree, conflict, nothing to revert). */
97
+ revertReason?: string | undefined;
98
+ }
99
+ /**
100
+ * Destroy an SDD project: optionally revert its merged commits, then clean every
101
+ * worktree + branch, then delete the on-disk artifacts (specs, task-graphs,
102
+ * session, boards). The revert is opt-in (`revertMerged`) and runs FIRST — it
103
+ * reads the board snapshot that the artifact deletion removes. Best-effort: a
104
+ * missing path is simply skipped. The caller is responsible for stopping any
105
+ * active run first.
106
+ */
107
+ export declare function destroySddProject(opts: DestroySddProjectOptions): Promise<DestroySddProjectResult>;
108
+ /** Lifecycle operation kinds shared by every surface (WebUI / TUI / CLI). */
109
+ export type SddLifecycleOp = 'cleanup_worktrees' | 'rollback' | 'destroy';
110
+ export interface SddLifecycleOptions {
111
+ projectRoot: string;
112
+ /** Resolved wstack paths (required for `destroy`; boards dir is enough for `rollback`). */
113
+ paths: {
114
+ projectSpecs: string;
115
+ projectTaskGraphs: string;
116
+ projectSddSession: string;
117
+ projectSddBoards: string;
118
+ };
119
+ /** Target a specific run (rollback / destroy). Omit → most recently updated board. */
120
+ runId?: string | undefined;
121
+ /** `destroy` only: also revert merged commits before wiping. */
122
+ revertMerged?: boolean | undefined;
123
+ }
124
+ /** Uniform result for any lifecycle op — drives identical UI wording everywhere. */
125
+ export interface SddLifecycleResult {
126
+ op: SddLifecycleOp;
127
+ ok: boolean;
128
+ /** Worktrees removed (cleanup_worktrees / destroy). */
129
+ removed?: number | undefined;
130
+ /** Merged commits reverted (rollback / destroy with revertMerged). */
131
+ reverted?: number | undefined;
132
+ /** Artifact labels deleted (destroy). */
133
+ deleted?: string[] | undefined;
134
+ /** Failure / partial reason, surfaced verbatim in the UI. */
135
+ reason?: string | undefined;
136
+ }
137
+ /**
138
+ * Apply a post-run SDD lifecycle operation from disk and return a uniform result.
139
+ * The single entry point shared by the WebUI board handler, the TUI overlay, and
140
+ * the CLI `/sdd` host so every surface reports the same thing. The caller must
141
+ * ensure no run is active (these operate on git + on-disk state, not the live
142
+ * run) — `cleanup`/`destroy` force-remove worktrees, `rollback` refuses on a
143
+ * dirty tree. Never throws.
144
+ */
145
+ export declare function applySddLifecycle(op: SddLifecycleOp, opts: SddLifecycleOptions): Promise<SddLifecycleResult>;
146
+ //# sourceMappingURL=sdd-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdd-lifecycle.d.ts","sourceRoot":"","sources":["../src/sdd-lifecycle.ts"],"names":[],"mappings":"AAeA,2EAA2E;AAC3E,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAG3F;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAG/G;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC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