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