@oscaner-skills/cdd-engine 3.0.0 → 3.0.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.
Files changed (143) hide show
  1. package/{src-next/bin.ts → dist/bin.js} +18 -21
  2. package/dist/contract/declare.js +998 -0
  3. package/dist/contract/doc.js +565 -0
  4. package/dist/contract/frontmatter.js +209 -0
  5. package/dist/contract/home-extractors.js +379 -0
  6. package/dist/contract/invariants.js +1030 -0
  7. package/dist/contract/judge.js +109 -0
  8. package/dist/contract/lint.js +206 -0
  9. package/dist/contract/project.js +371 -0
  10. package/dist/contract/skill-anatomy.js +156 -0
  11. package/dist/contract/translate.js +85 -0
  12. package/dist/face/artifacts.js +189 -0
  13. package/dist/face/board-view.js +522 -0
  14. package/dist/face/capsule.js +141 -0
  15. package/dist/face/cli.js +891 -0
  16. package/dist/face/declare.js +241 -0
  17. package/dist/face/gate.js +158 -0
  18. package/dist/face/graph-view.js +66 -0
  19. package/dist/face/host.js +211 -0
  20. package/dist/face/lifecycle.js +603 -0
  21. package/dist/face/preview.js +136 -0
  22. package/dist/face/projection.js +259 -0
  23. package/dist/face/route-render.js +162 -0
  24. package/dist/face/termination.js +482 -0
  25. package/dist/face/words.js +220 -0
  26. package/{src-next/infra/config.ts → dist/infra/config.js} +19 -24
  27. package/{src-next/infra/doc-roots.ts → dist/infra/doc-roots.js} +3 -13
  28. package/dist/infra/git.js +37 -0
  29. package/dist/infra/process.js +22 -0
  30. package/{src-next/infra/root.ts → dist/infra/root.js} +25 -36
  31. package/dist/infra/runtime.js +85 -0
  32. package/dist/infra/workspace.js +276 -0
  33. package/dist/render/brief.js +82 -0
  34. package/dist/render/issue-body.js +129 -0
  35. package/dist/render/skeleton.js +434 -0
  36. package/dist/render/templates.js +520 -0
  37. package/dist/session/faces.js +38 -0
  38. package/dist/session/graph.js +309 -0
  39. package/dist/session/handoff-schema.js +295 -0
  40. package/dist/session/ledger.js +762 -0
  41. package/dist/session/next.js +211 -0
  42. package/dist/session/preflight.js +194 -0
  43. package/dist/session/round-naming.js +73 -0
  44. package/dist/session/run.js +441 -0
  45. package/dist/session/state.js +8 -0
  46. package/dist/session/wave.js +92 -0
  47. package/package.json +5 -5
  48. package/src-next/__tests__/bin.test.ts +0 -128
  49. package/src-next/__tests__/dead-decl.guard.test.ts +0 -39
  50. package/src-next/__tests__/floor.guard.test.ts +0 -69
  51. package/src-next/__tests__/issue-body.guard.test.ts +0 -66
  52. package/src-next/__tests__/phase-suffix.guard.test.ts +0 -72
  53. package/src-next/__tests__/smoke.integration.test.ts +0 -185
  54. package/src-next/__tests__/support/strip-comments.ts +0 -99
  55. package/src-next/__tests__/zero-dep.test.ts +0 -94
  56. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +0 -256
  57. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +0 -165
  58. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +0 -190
  59. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +0 -106
  60. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +0 -240
  61. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +0 -165
  62. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +0 -190
  63. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +0 -100
  64. package/src-next/contract/__tests__/declare.test.ts +0 -481
  65. package/src-next/contract/__tests__/doc.test.ts +0 -527
  66. package/src-next/contract/__tests__/dockey.guard.test.ts +0 -58
  67. package/src-next/contract/__tests__/edge-conditions.guard.test.ts +0 -81
  68. package/src-next/contract/__tests__/frontmatter.test.ts +0 -164
  69. package/src-next/contract/__tests__/judge.test.ts +0 -1111
  70. package/src-next/contract/__tests__/lint.test.ts +0 -324
  71. package/src-next/contract/__tests__/project.test.ts +0 -460
  72. package/src-next/contract/__tests__/structure-pin.test.ts +0 -186
  73. package/src-next/contract/__tests__/translate.test.ts +0 -96
  74. package/src-next/contract/declare.ts +0 -1071
  75. package/src-next/contract/doc.ts +0 -816
  76. package/src-next/contract/frontmatter.ts +0 -233
  77. package/src-next/contract/home-extractors.ts +0 -397
  78. package/src-next/contract/invariants.ts +0 -1413
  79. package/src-next/contract/judge.ts +0 -151
  80. package/src-next/contract/lint.ts +0 -239
  81. package/src-next/contract/project.ts +0 -656
  82. package/src-next/contract/skill-anatomy.ts +0 -301
  83. package/src-next/contract/translate.ts +0 -113
  84. package/src-next/face/__tests__/board-view.test.ts +0 -1151
  85. package/src-next/face/__tests__/capsule.test.ts +0 -300
  86. package/src-next/face/__tests__/channel-closure.guard.test.ts +0 -129
  87. package/src-next/face/__tests__/cli.test.ts +0 -4897
  88. package/src-next/face/__tests__/face.test.ts +0 -289
  89. package/src-next/face/__tests__/graph-view.test.ts +0 -61
  90. package/src-next/face/__tests__/host.test.ts +0 -24
  91. package/src-next/face/__tests__/install-rows.guard.test.ts +0 -58
  92. package/src-next/face/__tests__/negation.ts +0 -6
  93. package/src-next/face/__tests__/preview.test.ts +0 -374
  94. package/src-next/face/__tests__/projection.test.ts +0 -303
  95. package/src-next/face/__tests__/repo-root.guard.test.ts +0 -120
  96. package/src-next/face/__tests__/termination.test.ts +0 -650
  97. package/src-next/face/__tests__/words.guard.test.ts +0 -93
  98. package/src-next/face/artifacts.ts +0 -248
  99. package/src-next/face/board-view.ts +0 -652
  100. package/src-next/face/capsule.ts +0 -163
  101. package/src-next/face/cli.ts +0 -1028
  102. package/src-next/face/declare.ts +0 -323
  103. package/src-next/face/gate.ts +0 -171
  104. package/src-next/face/graph-view.ts +0 -74
  105. package/src-next/face/host.ts +0 -302
  106. package/src-next/face/lifecycle.ts +0 -725
  107. package/src-next/face/preview.ts +0 -151
  108. package/src-next/face/projection.ts +0 -285
  109. package/src-next/face/route-render.ts +0 -185
  110. package/src-next/face/termination.ts +0 -573
  111. package/src-next/face/words.ts +0 -314
  112. package/src-next/infra/__tests__/infra.test.ts +0 -333
  113. package/src-next/infra/__tests__/root.test.ts +0 -56
  114. package/src-next/infra/git.ts +0 -39
  115. package/src-next/infra/process.ts +0 -34
  116. package/src-next/infra/runtime.ts +0 -132
  117. package/src-next/infra/workspace.ts +0 -322
  118. package/src-next/render/__tests__/render.test.ts +0 -550
  119. package/src-next/render/__tests__/skeleton.test.ts +0 -684
  120. package/src-next/render/brief.ts +0 -121
  121. package/src-next/render/issue-body.ts +0 -162
  122. package/src-next/render/skeleton.ts +0 -502
  123. package/src-next/render/templates.ts +0 -645
  124. package/src-next/session/__tests__/graph.test.ts +0 -277
  125. package/src-next/session/__tests__/handoff-plane.guard.test.ts +0 -48
  126. package/src-next/session/__tests__/handoff-schema.test.ts +0 -310
  127. package/src-next/session/__tests__/ledger.test.ts +0 -745
  128. package/src-next/session/__tests__/next.test.ts +0 -460
  129. package/src-next/session/__tests__/preflight.test.ts +0 -545
  130. package/src-next/session/__tests__/round-naming.test.ts +0 -142
  131. package/src-next/session/__tests__/run.test.ts +0 -1026
  132. package/src-next/session/__tests__/wave-line-phase.guard.test.ts +0 -49
  133. package/src-next/session/__tests__/wave.test.ts +0 -476
  134. package/src-next/session/faces.ts +0 -110
  135. package/src-next/session/graph.ts +0 -411
  136. package/src-next/session/handoff-schema.ts +0 -373
  137. package/src-next/session/ledger.ts +0 -1076
  138. package/src-next/session/next.ts +0 -293
  139. package/src-next/session/preflight.ts +0 -271
  140. package/src-next/session/round-naming.ts +0 -84
  141. package/src-next/session/run.ts +0 -610
  142. package/src-next/session/state.ts +0 -30
  143. package/src-next/session/wave.ts +0 -139
@@ -1,324 +0,0 @@
1
- // packages/cdd-engine/src-next/contract/__tests__/lint.test.ts
2
- // T5 reference-lint suite — the WARN pass acceptance surface (design spec §2.3):
3
- // · the missing-edge suspect scan — a backward `Task N` / `T<N>` prose reference
4
- // with no matching `- **DependsOn**:` declaration WARNs once per block, while
5
- // forward / self / unregistered / spec-item / code-span / declared-edge refs
6
- // stay silent (the positive surface);
7
- // · the retired cross-doc drift observation (T6) — the Class-B link-text drift
8
- // WARN retires with the ChainLink label face: parent references carry zero
9
- // WARNs whatever their shape (the chain facts ride the front-matter head);
10
- // · the WARN-only gate — the same defective document produces ZERO Contract
11
- // findings (the lint never feeds the judgment face) and every warning carries
12
- // the reference-lint shape, never a Finding.
13
- // Fixtures are known-good plan literals parsed through the shared PlanDocType
14
- // instance (the parse-once-reuse discipline — the lint consumes the same parse
15
- // record the dispatch and the graph read). Since T6 the fixtures carry the
16
- // front-matter head (the §2.2 delivery seam's canonical document form).
17
-
18
- import { describe, expect, it } from "vitest";
19
- import type { ParsedDoc } from "../doc.ts";
20
- import { docTypeParsers } from "../doc.ts";
21
- import type { DocFs } from "../invariants.ts";
22
- import { Contract } from "../judge.ts";
23
- import { LintPass } from "../lint.ts";
24
-
25
- const PLAN_PATH = "docs/kairos/plans/x-p3.md";
26
- const SPEC_PATH = "docs/kairos/specs/x-p3-design.md";
27
-
28
- /** The sibling-doc fs a conforming chain resolves into (judge comparisons). */
29
- const GOOD_FS: DocFs = {
30
- exists: () => true,
31
- read: () => null,
32
- list: (dir) =>
33
- dir.endsWith("/specs") || dir.endsWith("specs")
34
- ? ["x-overall.md", "x-design.md", "x-p3-design.md"]
35
- : ["x-p3.md"],
36
- };
37
-
38
- /** One rendered `### Task N:` block with all required fields. */
39
- const planTask = (
40
- id: number,
41
- objective: string,
42
- dependsOn: string,
43
- acceptance: readonly string[] = ["done"],
44
- ): string[] => {
45
- return [
46
- `### Task ${id}: task ${id}`,
47
- `- **Objective**: ${objective}`,
48
- "- **Files**: file",
49
- "- **Consumes**: consumes",
50
- "- **Produces**: produces",
51
- "- **Steps**:",
52
- " - step one",
53
- "- **Acceptance**:",
54
- ...acceptance.map((entry) => ` - ${entry}`),
55
- `- **DependsOn**: ${dependsOn}`,
56
- ];
57
- };
58
-
59
- /** A full canonical plan document over the task blocks — the shared parse fixture
60
- * (the front-matter head carries the chain scalars; the lint's scan surfaces are
61
- * the task blocks only). */
62
- const planDoc = (blocks: readonly string[]): string => {
63
- return [
64
- "---",
65
- "title: Test Plan",
66
- "doc-type: plan",
67
- "version: v1.0",
68
- "date: 2026-10-09",
69
- "spec: docs/kairos/specs/x-design.md",
70
- "parent-program: docs/kairos/specs/x-overall.md",
71
- "parent-version: v1.21",
72
- "---",
73
- "",
74
- "## Constraints",
75
- "",
76
- "- delta",
77
- "",
78
- ...blocks,
79
- ].join("\n");
80
- };
81
-
82
- const lintPass = new LintPass();
83
-
84
- const lintPlan = (content: string): ReturnType<LintPass["run"]> => {
85
- return lintPass.run({
86
- path: PLAN_PATH,
87
- parsed: parseDoc("plan", content.split("\n")),
88
- });
89
- };
90
-
91
- const lintParsed = (
92
- docKey: "overall-spec" | "plan" | "phase-spec",
93
- lines: readonly string[],
94
- ): ReturnType<LintPass["run"]> => {
95
- // docKey selects the parser only — the lint input carries no re-typed doc key.
96
- return lintPass.run({ path: PLAN_PATH, parsed: parseDoc(docKey, lines) });
97
- };
98
-
99
- /** The shared parse — the composition root consumers reuse (parse-once discipline). */
100
- const parseDoc = (
101
- docKey: "overall-spec" | "plan" | "phase-spec",
102
- lines: readonly string[],
103
- ): ParsedDoc => docTypeParsers[docKey].parse(lines);
104
-
105
- describe("the missing-edge suspect scan (the prose reference surface)", () => {
106
- it("a backward Task N citation with no matching edge → exactly one WARN per block", () => {
107
- const warns = lintPlan(
108
- planDoc([
109
- ...planTask(1, "task one", "none"),
110
- ...planTask(2, "task two", "none"),
111
- ...planTask(3, "extends Task 1", "none"),
112
- ]),
113
- );
114
- expect(warns).toHaveLength(1);
115
- expect(warns[0]!.field).toBe("Task 3");
116
- expect(warns[0]!.kind).toBe("reference-lint");
117
- });
118
-
119
- it("the short T<N> form triggers the same observation", () => {
120
- const warns = lintPlan(
121
- planDoc([
122
- ...planTask(1, "task one", "none"),
123
- ...planTask(2, "task two", "none"),
124
- ...planTask(3, "reuses T1", "none"),
125
- ]),
126
- );
127
- expect(warns).toHaveLength(1);
128
- });
129
-
130
- it("aggregation — multiple suspect references in one block collapse into a single WARN", () => {
131
- const warns = lintPlan(
132
- planDoc([
133
- ...planTask(1, "task one", "none"),
134
- ...planTask(2, "task two", "none"),
135
- ...planTask(3, "spans Task 1 and Task 2", "none"),
136
- ]),
137
- );
138
- expect(warns).toHaveLength(1);
139
- });
140
-
141
- it("per-block granularity — two suspect blocks emit two WARNs", () => {
142
- const warns = lintPlan(
143
- planDoc([
144
- ...planTask(1, "task one", "none"),
145
- ...planTask(2, "reuses Task 1", "none"),
146
- ...planTask(3, "reuses Task 1", "none"),
147
- ]),
148
- );
149
- expect(warns).toHaveLength(2);
150
- });
151
- });
152
-
153
- describe("the silent surfaces (positive reference scanning)", () => {
154
- it("a forward reference and a self reference are never a missing-edge suspicion", () => {
155
- const warns = lintPlan(
156
- planDoc([
157
- ...planTask(1, "continues Task 3", "none"),
158
- ...planTask(2, "task two", "none"),
159
- ...planTask(3, "about Task 3 itself", "none"),
160
- ]),
161
- );
162
- expect(warns).toEqual([]);
163
- });
164
-
165
- it("an unregistered reference (the graph's missing-id class) is never a missing-edge suspicion", () => {
166
- const warns = lintPlan(
167
- planDoc([...planTask(1, "task one", "none"), ...planTask(3, "mirrors Task 2", "none")]),
168
- );
169
- expect(warns).toEqual([]);
170
- });
171
-
172
- it("the spec-item word form (T3.1) is excluded — a design-item reference is never a task reference", () => {
173
- const warns = lintPlan(
174
- planDoc([
175
- ...planTask(1, "task one", "none"),
176
- ...planTask(2, "task two", "none"),
177
- ...planTask(3, "task three", "none"),
178
- ...planTask(4, "per T3.1", "none"),
179
- ]),
180
- );
181
- expect(warns).toEqual([]);
182
- });
183
-
184
- it("a reference inside a code span cites a symbol, never prose intent — `T3` / `Task 1` stay silent", () => {
185
- const warns = lintPlan(
186
- planDoc([
187
- ...planTask(1, "task one", "none"),
188
- ...planTask(2, "task two", "none"),
189
- ...planTask(3, "reads `T3` and `Task 1`", "none"),
190
- ]),
191
- );
192
- expect(warns).toEqual([]);
193
- });
194
-
195
- it("the scan surface is prospective prose — a reference inside Files / Consumes / Steps is never prose intent", () => {
196
- const content = [
197
- "---",
198
- "title: Test Plan",
199
- "doc-type: plan",
200
- "version: v1.0",
201
- "date: 2026-10-09",
202
- "spec: docs/kairos/specs/x-design.md",
203
- "parent-program: docs/kairos/specs/x-overall.md",
204
- "parent-version: v1.21",
205
- "---",
206
- "",
207
- "### Task 3: task 3",
208
- "- **Objective**: task three",
209
- "- **Files**:",
210
- " - src/Task 1 seam",
211
- "- **Consumes**: T1 骨架 · T2 登记表",
212
- "- **Produces**: produces",
213
- "- **Steps**:",
214
- " - 1. wire the T1 seam — checkable: done",
215
- "- **Acceptance**:",
216
- " - done",
217
- "- **DependsOn**: none",
218
- ].join("\n");
219
- expect(lintPlan(content)).toEqual([]);
220
- });
221
-
222
- it("a reference the block itself declares as an edge is never a suspicion", () => {
223
- const warns = lintPlan(
224
- planDoc([...planTask(1, "task one", "none"), ...planTask(2, "spans Task 1", "1")]),
225
- );
226
- expect(warns).toEqual([]);
227
- });
228
-
229
- it("a conformant plan with zero references observes zero — the lint adds no noise to a clean record", () => {
230
- const warns = lintPlan(
231
- planDoc([...planTask(1, "task one", "none"), ...planTask(2, "task two", "1")]),
232
- );
233
- expect(warns).toEqual([]);
234
- });
235
- });
236
-
237
- describe("the retired cross-doc drift observation (T6 — zero WARNs)", () => {
238
- it("the canonical parent reference stays silent (zero WARNs)", () => {
239
- const warns = lintPlan(planDoc([...planTask(1, "task one", "none")]));
240
- expect(warns).toEqual([]);
241
- });
242
-
243
- it("a parent reference whose shape would have drifted WARNs no more — the link-text face is retired", () => {
244
- // The Class-B link-text drift judgment retired with the ChainLink label face:
245
- // the parent reference is a front-matter HEAD SCALAR (the `parent-program:`
246
- // key) — there is no link text to compare, so no drift WARN can fire.
247
- const warns = lintPlan(planDoc([...planTask(1, "task one", "none")]));
248
- expect(warns).toEqual([]);
249
- });
250
-
251
- it("the same retired surface applies to a phase-spec's parent reference — zero WARNs", () => {
252
- const lines = [
253
- "---",
254
- "title: Test Spec",
255
- "doc-type: phase-spec",
256
- "version: v1.0",
257
- "date: 2026-10-09",
258
- "status: Draft",
259
- "author: x",
260
- "parent-program: docs/kairos/specs/x-overall.md",
261
- "parent-version: v1.0",
262
- "depends-on: P1",
263
- "---",
264
- "",
265
- "## Design",
266
- "",
267
- "### 1. group",
268
- "#### 1.1 item",
269
- "- text",
270
- "",
271
- "### Acceptance criteria",
272
- "",
273
- "- `c`",
274
- ];
275
- const warns = lintPass.run({
276
- path: SPEC_PATH,
277
- parsed: parseDoc("phase-spec", lines),
278
- });
279
- expect(warns).toEqual([]);
280
- });
281
-
282
- it("the overall carries no reference-lint surface — the class is a silent no-op over an overall", () => {
283
- const warns = lintParsed("overall-spec", ["# Test Overall", "## Document scope", "scope"]);
284
- expect(warns).toEqual([]);
285
- });
286
- });
287
-
288
- describe("the WARN-only gate", () => {
289
- it("the lint-defective plan stays judgment-clean on the reference surfaces — WARNs never become Findings", () => {
290
- const content = planDoc([
291
- ...planTask(1, "task one", "none"),
292
- ...planTask(2, "task two", "none"),
293
- ...planTask(3, "extends Task 1", "none"),
294
- ]);
295
- expect(lintPlan(content)).toHaveLength(1);
296
- // The lint's observation surfaces — prose references, DependsOn edges, the
297
- // cross-doc chain — judge ZERO findings even though the lint WARNs the doc.
298
- const findings = new Contract().validate({
299
- docKey: "plan",
300
- path: PLAN_PATH,
301
- content,
302
- root: ".",
303
- fs: GOOD_FS,
304
- });
305
- const referenceSurfaces = findings.filter((finding) =>
306
- ["crosslink", "cross-doc-chain", "file-existence", "sibling-scan"].includes(finding.kind),
307
- );
308
- expect(referenceSurfaces).toEqual([]);
309
- });
310
-
311
- it("every warning carries the reference-lint shape, never a judge Finding kind", () => {
312
- const warns = lintPlan(
313
- planDoc([...planTask(1, "task one", "none"), ...planTask(3, "extends Task 1", "none")]),
314
- );
315
- expect(warns.length).toBeGreaterThan(0);
316
- for (const warn of warns) {
317
- expect(warn.kind).toBe("reference-lint");
318
- expect(typeof warn.path).toBe("string");
319
- expect(typeof warn.field).toBe("string");
320
- expect(typeof warn.message).toBe("string");
321
- expect(typeof warn.fix).toBe("string");
322
- }
323
- });
324
- });