@oscaner-skills/cdd-engine 1.0.0 → 2.0.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 (99) hide show
  1. package/README.md +9 -8
  2. package/README.zh-CN.md +9 -8
  3. package/package.json +15 -22
  4. package/src-next/__tests__/bin.test.ts +128 -0
  5. package/src-next/__tests__/smoke.integration.test.ts +202 -0
  6. package/src-next/__tests__/zero-dep.test.ts +134 -0
  7. package/src-next/bin.ts +61 -0
  8. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +238 -0
  9. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +153 -0
  10. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +173 -0
  11. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +89 -0
  12. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +225 -0
  13. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +155 -0
  14. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +175 -0
  15. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +85 -0
  16. package/src-next/contract/__tests__/declare.test.ts +242 -0
  17. package/src-next/contract/__tests__/doc.test.ts +358 -0
  18. package/src-next/contract/__tests__/judge.test.ts +873 -0
  19. package/src-next/contract/__tests__/lint.test.ts +314 -0
  20. package/src-next/contract/__tests__/project.test.ts +419 -0
  21. package/src-next/contract/__tests__/translate.test.ts +96 -0
  22. package/src-next/contract/declare.ts +983 -0
  23. package/src-next/contract/doc.ts +753 -0
  24. package/src-next/contract/invariants.ts +1268 -0
  25. package/src-next/contract/judge.ts +142 -0
  26. package/src-next/contract/lint.ts +275 -0
  27. package/src-next/contract/project.ts +596 -0
  28. package/src-next/contract/skill-anatomy.ts +273 -0
  29. package/src-next/contract/translate.ts +113 -0
  30. package/src-next/face/__tests__/board-view.test.ts +948 -0
  31. package/src-next/face/__tests__/capsule.test.ts +276 -0
  32. package/src-next/face/__tests__/channel-closure.guard.test.ts +102 -0
  33. package/src-next/face/__tests__/cli.test.ts +4643 -0
  34. package/src-next/face/__tests__/face.test.ts +289 -0
  35. package/src-next/face/__tests__/graph-view.test.ts +61 -0
  36. package/src-next/face/__tests__/host.test.ts +24 -0
  37. package/src-next/face/__tests__/negation.ts +6 -0
  38. package/src-next/face/__tests__/projection.test.ts +301 -0
  39. package/src-next/face/__tests__/sync-runner.test.ts +70 -0
  40. package/src-next/face/__tests__/words.guard.test.ts +93 -0
  41. package/src-next/face/artifacts.ts +195 -0
  42. package/src-next/face/board-view.ts +662 -0
  43. package/src-next/face/capsule.ts +149 -0
  44. package/src-next/face/cli.ts +819 -0
  45. package/src-next/face/declare.ts +326 -0
  46. package/src-next/face/gate.ts +170 -0
  47. package/src-next/face/graph-view.ts +74 -0
  48. package/src-next/face/host.ts +326 -0
  49. package/src-next/face/lifecycle.ts +700 -0
  50. package/src-next/face/projection.ts +282 -0
  51. package/src-next/face/route-render.ts +160 -0
  52. package/src-next/face/words.ts +296 -0
  53. package/src-next/infra/__tests__/infra.test.ts +287 -0
  54. package/src-next/infra/config.ts +42 -0
  55. package/src-next/infra/git.ts +39 -0
  56. package/src-next/infra/process.ts +34 -0
  57. package/src-next/infra/runtime.ts +185 -0
  58. package/src-next/infra/workspace.ts +232 -0
  59. package/src-next/render/__tests__/render.test.ts +499 -0
  60. package/src-next/render/__tests__/skeleton.test.ts +466 -0
  61. package/src-next/render/brief.ts +121 -0
  62. package/src-next/render/issue-body.ts +159 -0
  63. package/src-next/render/skeleton.ts +437 -0
  64. package/src-next/render/templates.ts +650 -0
  65. package/src-next/session/__tests__/graph.test.ts +270 -0
  66. package/src-next/session/__tests__/handoff-plane.guard.test.ts +48 -0
  67. package/src-next/session/__tests__/handoff-schema.test.ts +310 -0
  68. package/src-next/session/__tests__/ledger.test.ts +744 -0
  69. package/src-next/session/__tests__/next.test.ts +368 -0
  70. package/src-next/session/__tests__/preflight.test.ts +491 -0
  71. package/src-next/session/__tests__/run.test.ts +1014 -0
  72. package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
  73. package/src-next/session/__tests__/wave.test.ts +469 -0
  74. package/src-next/session/faces.ts +110 -0
  75. package/src-next/session/graph.ts +411 -0
  76. package/src-next/session/handoff-schema.ts +373 -0
  77. package/src-next/session/ledger.ts +1004 -0
  78. package/src-next/session/next.ts +192 -0
  79. package/src-next/session/preflight.ts +240 -0
  80. package/src-next/session/run.ts +606 -0
  81. package/src-next/session/state.ts +30 -0
  82. package/src-next/session/wave.ts +139 -0
  83. package/templates/report/issue-body.json +18 -20
  84. package/dist/chunks/branch.mjs +0 -480
  85. package/dist/chunks/docs.mjs +0 -253
  86. package/dist/chunks/task.mjs +0 -913
  87. package/dist/cli.mjs +0 -5457
  88. package/dist/documents/schema/add-phase-protocol.json +0 -126
  89. package/dist/documents/schema/overall.json +0 -361
  90. package/dist/documents/schema/phase-spec.json +0 -145
  91. package/dist/documents/schema/plan.json +0 -191
  92. package/dist/documents/schema/skill-anatomy.json +0 -233
  93. package/dist/resources/harness-registry.json +0 -49
  94. package/dist/shared/cdd-engine.liioziig.mjs +0 -184
  95. package/templates/engine-config.json +0 -302
  96. package/templates/schema/cache-profile-schema.json +0 -23
  97. package/templates/schema/docs-handoff-schema.json +0 -129
  98. package/templates/schema/task-handoff-schema.json +0 -332
  99. package/templates/template-contract.json +0 -231
@@ -0,0 +1,139 @@
1
+ // packages/cdd-engine/src-next/session/wave.ts
2
+ // T24 (v1.21 — the three-verb unified wave gate) — the task-face dispatch
3
+ // pre-flight as ONE gate method. The retired split check (the implement-only
4
+ // strict-wave check + the phase lock) converges into `WaveGate.vet(requested,
5
+ // verb)`: implement / review / fix share the same single wave gate — a
6
+ // half-wave review or a half-wave fix is structurally blocked exactly like a
7
+ // half-wave implement.
8
+ //
9
+ // The gate's only read face is `open = frontier(closedWaves())` — the derived
10
+ // wave over the ledger's C5 closure set (ledger.ts, the same closure predicate as
11
+ // the lifecycle's #markTerminal). The two judgments:
12
+ // 1. requested ≠ open → the split/subset BLOCK (dispatch the full derived wave,
13
+ // with the wave-board hint);
14
+ // 2. the open wave's phase ≠ verb → the wrong-phase BLOCK (run the matching phase).
15
+ // (v1.28 — the heterogeneous-phase row RETIRED: the wave-unitary ledger has ONE row
16
+ // per wave, so mixed per-task phases are structurally impossible — a per-task phase
17
+ // read was the T26 regression {16,22,24} exposed (the row key `16` never matched
18
+ // `{wave:"16,22,24"}`), not a mixed-phase anomaly.)
19
+ // The verdict wording renders the wave-gate vocabulary rows (face/words.ts — the
20
+ // gate's prompt wording rides the word table, never a literal restate). BLOCK
21
+ // messages and the verdict shape are data here; the CLI face renders them.
22
+ //
23
+ // Module-level exports are types / the class — zero behavior-carrying bare
24
+ // functions (the plan's zero-bare-function discipline).
25
+
26
+ import type { Words } from "../face/words.ts";
27
+ import type { DispatchPhase } from "./faces.ts";
28
+ import type { TaskGraph } from "./graph.ts";
29
+ import type { Ledger } from "./ledger.ts";
30
+
31
+ /** The verdict kinds — the named gate rows (the BLOCK reason each carries). */
32
+ export type WaveGateReason = "split" | "wrong-phase";
33
+
34
+ /** One open-wave task's phase row — every member carries the WAVE's single phase
35
+ * (the wave-unitary read: one ledger row per wave; a per-task read would miss the
36
+ * wave row — `16` ≠ `16,22,24` — the T26 migration regression). */
37
+ export interface WavePhaseRow {
38
+ /** The task id. */
39
+ task: number;
40
+ /** The wave's open phase (null = a closed/held wave — no open round on record). */
41
+ phase: DispatchPhase | null;
42
+ }
43
+
44
+ /** The wave-gate verdict — approved or one of the three named BLOCK rows. */
45
+ export interface WaveVerdict {
46
+ /** Whether the gate approves the dispatch (the requested wave = the open wave,
47
+ * the wave's phase = the requested verb). */
48
+ ok: boolean;
49
+ /** The BLOCK reason kind (present when ok is false). */
50
+ reason?: WaveGateReason;
51
+ /** The rendered BLOCK message (the vocabulary row, verbatim-filled). */
52
+ message?: string;
53
+ /** The derived open wave — frontier(closedWaves), ascending (both the split hint
54
+ * and the CLI's progress-marking read this). */
55
+ open: readonly number[];
56
+ /** The open wave's member phases — every task carries the WAVE's single phase
57
+ * (the wave-unitary display: one ledger row per wave, never a per-task read). */
58
+ phases?: readonly WavePhaseRow[];
59
+ }
60
+
61
+ /**
62
+ * WaveGate — the three-verb unified wave gate (implement / review / fix share the
63
+ * single gate). One OOP method: vet(requested, verb) judges the request against
64
+ * the derived open wave + the ledger's per-task phases; the CLI calls it before
65
+ * ANY task-face dispatch, never a variant gate per verb.
66
+ */
67
+ export class WaveGate {
68
+ /** vet(requested, verb, graph, ledger, words) — the three-verb gate: the verdict
69
+ * row the CLI renders (ok → dispatch; a reason + message → the BLOCK face). */
70
+ vet(
71
+ requested: ReadonlySet<number>,
72
+ verb: "implement" | "review" | "fix",
73
+ graph: TaskGraph,
74
+ ledger: Ledger,
75
+ words: Words,
76
+ ): WaveVerdict {
77
+ const closed = ledger.closedWaves();
78
+ const open = [...graph.frontier(closed)].sort((a, b) => a - b);
79
+ const asked = [...requested].sort((a, b) => a - b);
80
+ const requestedKey = asked.join(",");
81
+ const openKey = open.join(",");
82
+ const wordsGate = words.waveGateWords();
83
+ const exact = asked.length === open.length && asked.every((id, index) => id === open[index]);
84
+
85
+ // 1. The split/subset BLOCK — requested ≠ open: a `--tasks` set that splits or
86
+ // mismatches the derived wave is refused for ANY verb (a subset never reorders
87
+ // the wave, never half-approves it). The full-wave hint rides the message.
88
+ if (!exact) {
89
+ return {
90
+ ok: false,
91
+ reason: "split",
92
+ message: this.#fill(wordsGate.split, { requested: requestedKey, open: openKey }),
93
+ open,
94
+ phases: this.#phasesOf(ledger, open),
95
+ };
96
+ }
97
+
98
+ // 2. The open wave's phase — the single phase of the wave's own row (wave-unitary:
99
+ // one ledger row per wave, so every member shares the phase; a per-task read
100
+ // never matches the wave row — the T26 migration regression).
101
+ const phases = this.#phasesOf(ledger, open);
102
+ const phase = phases[0]?.phase ?? null;
103
+ if (phase !== verb) {
104
+ return {
105
+ ok: false,
106
+ reason: "wrong-phase",
107
+ message: this.#fill(wordsGate.wrongPhase, { phase: phase ?? "held" }),
108
+ open,
109
+ phases,
110
+ };
111
+ }
112
+ return { ok: true, open, phases };
113
+ }
114
+
115
+ /** The open wave's per-task phases — every member resolves the WAVE row's single
116
+ * phase (implement → review → fix → re-review → closure; null = no open round). */
117
+ #phasesOf(ledger: Ledger, open: readonly number[]): readonly WavePhaseRow[] {
118
+ const waveKey = open.join(",");
119
+ const phase = this.#phaseOf(ledger, waveKey);
120
+ return open.map((task) => ({ task, phase }));
121
+ }
122
+
123
+ /** The ledger-derived open phase of ONE wave row — the SINGLE source (D26): the
124
+ * wave gate and the lifecycle's frame frontier both read this one method
125
+ * (`Ledger#waveLinePhase`), never a per-consumer copy. The wave-unitary read: the
126
+ * same C5 round-pair derivation over the wave's own row key (the per-task read
127
+ * never matched a `{wave:"16,22,24"}` row — the fix). The D16/T11 revision
128
+ * precheck lives in the ledger method (a drifted BRIEF reopens at review; same +
129
+ * pending fix stays at fix). */
130
+ #phaseOf(ledger: Ledger, waveKey: string): DispatchPhase | null {
131
+ return ledger.waveLinePhase(waveKey);
132
+ }
133
+
134
+ /** The raw fill of one placeholder template — the noun-slot substitution
135
+ * ({requested} / {open} / {phase} / {map}); every slot defined, unknown braces kept. */
136
+ #fill(template: string, slots: Record<string, string>): string {
137
+ return template.replace(/\{(\w+)\}/g, (whole, name: string) => slots[name] ?? whole);
138
+ }
139
+ }
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "components": [
3
- "osuperpowers (general)",
3
+ "kairos (general)",
4
4
  "cdd-engine",
5
- "osuperpowers:brainstorming",
6
- "osuperpowers:writing-single-spec",
7
- "osuperpowers:writing-overall-spec",
8
- "osuperpowers:writing-phase-spec",
9
- "osuperpowers:writing-plans",
10
- "osuperpowers:cli-driven-development",
11
- "osuperpowers:report-issues",
12
- "osuperpowers:finishing"
5
+ "kairos:cdd-design",
6
+ "kairos:cdd-spec-writer",
7
+ "kairos:cdd-plan",
8
+ "kairos:cdd-dev",
9
+ "kairos:cdd-report",
10
+ "kairos:cdd-close"
13
11
  ],
14
12
  "severities": [
15
13
  "blocker",
@@ -54,14 +52,14 @@
54
52
  "bug_report": {
55
53
  "frontmatter": {
56
54
  "name": "Bug report",
57
- "description": "Report a bug found while using osuperpowers skills (dogfood)",
58
- "labels": ["bug", "osuperpowers"]
55
+ "description": "Report a bug found while using kairos skills (dogfood)",
56
+ "labels": ["bug", "kairos"]
59
57
  },
60
58
  "body": [
61
59
  {
62
60
  "type": "markdown",
63
61
  "attributes": {
64
- "value": "Use this template to report bugs found during dogfood use of osuperpowers skills.\n"
62
+ "value": "Use this template to report bugs found during dogfood use of kairos skills.\n"
65
63
  }
66
64
  },
67
65
  {
@@ -78,8 +76,8 @@
78
76
  "id": "context",
79
77
  "attributes": {
80
78
  "label": "Context",
81
- "description": "Dogfood session context: date, harness, which osuperpowers skills were in use",
82
- "placeholder": "Date: YYYY-MM-DD, Harness: claude-code, Skills: cli-driven-development, writing-plans"
79
+ "description": "Dogfood session context: date, harness, which kairos skills were in use",
80
+ "placeholder": "Date: YYYY-MM-DD, Harness: claude-code, Skills: cdd-dev, cdd-plan"
83
81
  },
84
82
  "validations": { "required": true }
85
83
  },
@@ -125,14 +123,14 @@
125
123
  "enhancement": {
126
124
  "frontmatter": {
127
125
  "name": "Enhancement",
128
- "description": "Suggest an improvement to osuperpowers skills or workflow",
129
- "labels": ["enhancement", "osuperpowers"]
126
+ "description": "Suggest an improvement to kairos skills or workflow",
127
+ "labels": ["enhancement", "kairos"]
130
128
  },
131
129
  "body": [
132
130
  {
133
131
  "type": "markdown",
134
132
  "attributes": {
135
- "value": "Use this template to suggest improvements found during dogfood use of osuperpowers skills.\n"
133
+ "value": "Use this template to suggest improvements found during dogfood use of kairos skills.\n"
136
134
  }
137
135
  },
138
136
  {
@@ -149,8 +147,8 @@
149
147
  "id": "context",
150
148
  "attributes": {
151
149
  "label": "Context",
152
- "description": "Dogfood session context: date, harness, which osuperpowers skills were in use",
153
- "placeholder": "Date: YYYY-MM-DD, Harness: claude-code, Skills: cli-driven-development"
150
+ "description": "Dogfood session context: date, harness, which kairos skills were in use",
151
+ "placeholder": "Date: YYYY-MM-DD, Harness: claude-code, Skills: cdd-dev"
154
152
  },
155
153
  "validations": { "required": true }
156
154
  },
@@ -195,7 +193,7 @@
195
193
  }
196
194
  },
197
195
  "reportDef": {
198
- "labels": ["osuperpowers", "cdd-engine"]
196
+ "labels": ["kairos", "cdd-engine"]
199
197
  },
200
198
  "masterDef": {
201
199
  "sessionTitle": "## Session",