@oscaner-skills/cdd-engine 3.0.0 → 3.1.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 (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 +149 -0
  15. package/dist/face/cli.js +893 -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 +702 -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 +504 -0
  25. package/dist/face/words.js +258 -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 +453 -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,128 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/bin.test.ts
2
- // T13 — the bin-bootstrap face, black-box: the thin entry's cli-load + exit-code
3
- // plumbing exercised exactly the way the checkable runs it (`node src-next/bin.ts …`).
4
- // Spawns the source entry straight (Node >=22.18 native type stripping — the dev
5
- // face; the test asserts through the steady exit-code table — 0 = OK · 2 = usage —
6
- // not through anything imported in-process: the bin is only ever executed, never
7
- // imported).
8
-
9
- import { spawnSync } from "node:child_process";
10
- import { readFileSync } from "node:fs";
11
- import process from "node:process";
12
- import { fileURLToPath } from "node:url";
13
- import { describe, expect, it } from "vitest";
14
-
15
- const BIN = fileURLToPath(new URL("../bin.ts", import.meta.url));
16
-
17
- /** One spawned bin run — fail-open (a non-zero child rides the code, never a throw;
18
- * the child's streams are piped, never inherited into the reporter). */
19
- const run = (
20
- args: readonly string[],
21
- opts: { cwd?: string; input?: string } = {},
22
- ): { code: number; stdout: string; stderr: string } => {
23
- const result = spawnSync(process.execPath, [BIN, ...args], {
24
- encoding: "utf8",
25
- cwd: opts.cwd ?? process.cwd(),
26
- input: opts.input,
27
- stdio: ["pipe", "pipe", "pipe"],
28
- });
29
- return {
30
- code: result.status ?? (result.error !== undefined ? 1 : 0),
31
- stdout: result.stdout ?? "",
32
- stderr: result.stderr ?? "",
33
- };
34
- };
35
-
36
- describe("the T9 deliberate pin — the NodeEnvGuard + Cli.create entry (the class-face boot)", () => {
37
- it("the entry is the NodeEnvGuard class member + the Cli.create factory — zero module-level functions in bin.ts", () => {
38
- // bin.ts is only ever executed, never imported, so the entry form is pinned
39
- // from its source: the environment pre-flight is a class static judgement and
40
- // the CLI face boots through the Cli.create static factory — a regression to a
41
- // module-level `bootEnvironmentProblem`/`cli` function trips this pin.
42
- const src = readFileSync(BIN, "utf8");
43
- expect(src).not.toMatch(/^(export )?(async )?function /m);
44
- expect(src).toMatch(/class NodeEnvGuard/);
45
- expect(src).toMatch(/NodeEnvGuard\.problem\(\)/);
46
- expect(src).toMatch(/const \{ Cli \} = await import\("\.\/face\/cli\.ts"\)/);
47
- expect(src).toMatch(/Cli\.create\(\)\.runArgv/);
48
- });
49
-
50
- it("the environment guard's message + exit bytes are pinned (the below-floor word face)", () => {
51
- const src = readFileSync(BIN, "utf8");
52
- // The byte message is produced from the NODE_FLOOR row — both the floor and the
53
- // template production are pinned so the below-floor word face cannot drift.
54
- expect(src).toContain("const NODE_FLOOR = { major: 22, minor: 18 } as const;");
55
- expect(src).toMatch(
56
- /cdd requires Node >= \$\{NODE_FLOOR\.major\}\.\$\{NODE_FLOOR\.minor\} \(native type stripping\) — installed: \$\{process\.versions\.node\}/,
57
- );
58
- expect(src).toContain("process.exit(1)");
59
- });
60
- });
61
-
62
- describe("the bin bootstrap — cli load + exit-code plumbing (black-box)", () => {
63
- it("`node src-next/bin.ts schema get plan` prints the derived plan schema + exits 0 (the T13 checkable)", () => {
64
- const result = run(["schema", "get", "plan"]);
65
- expect(result.code).toBe(0);
66
- const parsed = JSON.parse(result.stdout) as {
67
- docType: string;
68
- $schema: string;
69
- properties: Record<string, unknown>;
70
- };
71
- // The derived doc-structure schema — the registration-derived face, never a
72
- // hand-written second schema.
73
- expect(parsed.docType).toBe("plan");
74
- expect(parsed.$schema).toContain("json-schema.org");
75
- expect(parsed.properties).toBeTypeOf("object");
76
- expect(Object.keys(parsed.properties).length).toBeGreaterThan(0);
77
- });
78
-
79
- it("an unknown flag exits 2 with commander's unknown-option byte + the native did-you-mean (the guardArgs semantics ride the bin)", () => {
80
- // the required flags must be satisfied first — commander's missing-required
81
- // check fires before the unknown-option scan, so the typo surfaces only with
82
- // --tasks/--plan present
83
- const result = run(["implement", "--tasks", "2", "--plan", "p.md", "--taks"]);
84
- expect(result.code).toBe(2);
85
- expect(result.stderr).toContain("error: unknown option '--taks'");
86
- expect(result.stderr).toContain("(Did you mean --tasks?)");
87
- });
88
-
89
- it("an unknown command exits 2 with commander's unknown-command byte", () => {
90
- const result = run(["bogus"]);
91
- expect(result.code).toBe(2);
92
- expect(result.stderr).toContain("error: unknown command 'bogus'");
93
- });
94
-
95
- it("a missing required flag exits 2 with the .requiredOption() byte (base get's required --plan)", () => {
96
- const result = run(["base", "get"]);
97
- expect(result.code).toBe(2);
98
- expect(result.stderr).toContain("error: required option '--plan <path>' not specified");
99
- });
100
-
101
- it("`node src-next/bin.ts issue render` renders the aggregate body from stdin + exits 0", () => {
102
- const input = JSON.stringify({
103
- harness: "claude",
104
- findings: [
105
- {
106
- type: "bug",
107
- lang: "en",
108
- context: "c",
109
- problem: "p",
110
- impact: "i",
111
- suggestedFix: "f",
112
- meta: { skill: "tdd", step: "loop" },
113
- },
114
- ],
115
- });
116
- const result = run(["issue", "render"], { input });
117
- expect(result.code).toBe(0);
118
- expect(result.stdout).toContain("# CDD aggregate issue");
119
- expect(result.stdout).toContain("## Context");
120
- expect(result.stdout).toContain("- Skill: tdd");
121
- });
122
-
123
- it("issue render rejects malformed input JSON with exit 1 (the input-value failure surface)", () => {
124
- const result = run(["issue", "render"], { input: "not json" });
125
- expect(result.code).toBe(1);
126
- expect(result.stderr).toContain("invalid input JSON");
127
- });
128
- });
@@ -1,39 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/dead-decl.guard.test.ts
2
- // T14 (spec §3.4 ⑧/⑯/⑱/⑲) — the dead-declaration zero-residue gate. The T1=a
3
- // stance is "a declaration is a fact": a field/constant/helper with zero reader is
4
- // either deleted or given a real consumer, never left as a dead declaration.
5
- // · ⑧ HOSTS[*].cache — deleted (zero reader).
6
- // · ⑯ HandoffFamily.round/phase/fixFamily/fixTemplate/prev — deleted (name +
7
- // schema are the only readers).
8
- // · ⑱ CRASH_TAIL_LINES — the ghost comment referencing the nonexistent symbol.
9
- // · ⑲ setupRepo — the zero-caller helper (kairos tests plane).
10
-
11
- import { readFileSync } from "node:fs";
12
- import { fileURLToPath } from "node:url";
13
- import { describe, expect, it } from "vitest";
14
-
15
- const SRC = fileURLToPath(new URL("../", import.meta.url));
16
- const read = (rel: string): string => readFileSync(`${SRC}/${rel}`, "utf8");
17
-
18
- describe("dead-declaration zero residue (spec §3.4)", () => {
19
- it("⑧ the HOSTS rows carry zero cache field", () => {
20
- const hostSrc = read("face/host.ts");
21
- expect(hostSrc).not.toMatch(/\bcache\b/);
22
- expect(hostSrc).not.toMatch(/HostCacheSpec/);
23
- });
24
-
25
- it("⑯ the HandoffFamily interface + table carry zero dead fields", () => {
26
- const runtimeSrc = read("infra/runtime.ts");
27
- for (const dead of ["fixFamily", "fixTemplate"]) {
28
- expect(runtimeSrc, dead).not.toContain(dead);
29
- }
30
- // the round/phase/prev fields are gone (the table rows carry name + schema only)
31
- expect(runtimeSrc).not.toMatch(/^\s*round:/m);
32
- expect(runtimeSrc).not.toMatch(/^\s*phase:/m);
33
- expect(runtimeSrc).not.toMatch(/^\s*prev:/m);
34
- });
35
-
36
- it("⑱ the CRASH_TAIL_LINES ghost symbol is gone from ledger.ts", () => {
37
- expect(read("session/ledger.ts")).not.toContain("CRASH_TAIL_LINES");
38
- });
39
- });
@@ -1,69 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/floor.guard.test.ts
2
- // T8 (spec §3.1 ②) — the floor single-source gate. ② is TWO distinct facts that
3
- // must NOT be merged into one source:
4
- // · the INSTALL floor — `packages/cdd-engine/package.json#engines` ("node"):
5
- // which Node the published artifact is installed/run on. The README install
6
- // lines (README.md + its zh mirror) must agree with it.
7
- // · the TYPE-STRIPPING floor — `bin.ts` `NODE_FLOOR` (22.18): the dev face's
8
- // `node src-next/bin.ts` native-type-stripping requirement. The README
9
- // development lines must agree with it.
10
- // Deriving NODE_FLOOR from `#engines` (`>=24`) would make the guard OVER-STRICT
11
- // (it would reject Node 22.18–23.x, which the README explicitly documents as
12
- // usable for source-direct runs), so the two facts stay separate and each is
13
- // pinned to its own correct source by this gate.
14
-
15
- import { readFileSync } from "node:fs";
16
- import { fileURLToPath } from "node:url";
17
- import { describe, expect, it } from "vitest";
18
-
19
- const ENGINE_ROOT = fileURLToPath(new URL("../../", import.meta.url));
20
- const read = (rel: string): string => readFileSync(`${ENGINE_ROOT}/${rel}`, "utf8");
21
-
22
- /** The install floor declared by `package.json#engines.node` (e.g. ">=24"). */
23
- const enginesFloor = (): string => {
24
- const pkg = JSON.parse(read("package.json")) as { engines?: { node?: string } };
25
- const node = pkg.engines?.node;
26
- if (node === undefined) throw new Error("package.json#engines.node is missing");
27
- return node.replace(/\s+/g, "");
28
- };
29
-
30
- /** The type-stripping floor declared by `bin.ts`'s NODE_FLOOR (major.minor). */
31
- const typeStrippingFloor = (): string => {
32
- const src = read("src-next/bin.ts");
33
- const match = /const NODE_FLOOR = \{ major: (\d+), minor: (\d+) \}/.exec(src);
34
- if (match === null) throw new Error("bin.ts NODE_FLOOR shape changed");
35
- return `${match[1]}.${match[2]}`;
36
- };
37
-
38
- describe("the two floors hold their correct single source (spec §3.1 ②)", () => {
39
- it("the INSTALL floor — both README install lines agree with package.json#engines", () => {
40
- const floor = enginesFloor(); // ">=24"
41
- const bare = floor.replace(/^>=\s*/, ""); // "24"
42
- for (const rel of ["README.md", "README.zh-CN.md"]) {
43
- const src = read(rel);
44
- // The install-requirement line: "Requires Node.js `>= 24`." / "需要 Node.js `>= 24`。"
45
- const match = /Node\.js `([^`]+)`/.exec(src);
46
- expect(match, `${rel}: no install-floor line`).not.toBeNull();
47
- expect(match?.[1]?.replace(/\s+/g, ""), `${rel}: install floor drifted from #engines`).toBe(
48
- [">=", bare].join(""),
49
- );
50
- }
51
- });
52
-
53
- it("the TYPE-STRIPPING floor — both README development lines agree with bin.ts NODE_FLOOR", () => {
54
- const floor = typeStrippingFloor(); // "22.18"
55
- for (const rel of ["README.md", "README.zh-CN.md"]) {
56
- const src = read(rel);
57
- // The dev line: "… (Node ≥22.18 native type stripping)" / "…(Node ≥22.18 原生类型剥离)"
58
- const match = /Node\s*≥\s*(\d+\.\d+)/.exec(src);
59
- expect(match, `${rel}: no type-stripping-floor line`).not.toBeNull();
60
- expect(match?.[1], `${rel}: dev floor drifted from NODE_FLOOR`).toBe(floor);
61
- }
62
- });
63
-
64
- it("the two facts stay distinct — the install floor is not silently merged into NODE_FLOOR", () => {
65
- // The install floor (>=24) and the type-stripping floor (22.18) are different
66
- // numbers: deriving the latter from the former would over-strict the dev guard.
67
- expect(enginesFloor().replace(/^>=\s*/, "")).not.toBe(typeStrippingFloor().split(".")[0]);
68
- });
69
- });
@@ -1,66 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/issue-body.guard.test.ts
2
- // T10 (spec §3.1 ① · §3.2 ⑤ · §3.4 ⑰) — the issue-body single-source gate.
3
- // · ① the label table lives ONLY on the word table (face/words.ts ISSUE_LABEL_WORDS,
4
- // the renderer's real read); the withdrawn `sectionLabels` copy in
5
- // templates/report/issue-body.json (which had drifted: bug.context zh
6
- // `## 场景` vs `## 背景`, enhancement.problem `## Gap` vs `## Current behavior`)
7
- // is deleted — a re-added divergent copy fails here.
8
- // · ⑤ the components roster in the JSON must derive EXACTLY: six kairos
9
- // components are `"kairos:" + SKILL_ROSTER key` (a prefix transform — the roster
10
- // is the engine's closed six-set, skill-anatomy.ts) plus two fixed headers
11
- // (`kairos (general)` / `cdd-engine`) that carry no roster source.
12
- // · ⑰ the orphan fields (severities / metaFields / reportDef / masterDef — zero
13
- // reader) are deleted.
14
-
15
- import { readFileSync } from "node:fs";
16
- import { fileURLToPath } from "node:url";
17
- import { describe, expect, it } from "vitest";
18
- import { SKILL_ANATOMY } from "../contract/skill-anatomy.ts";
19
-
20
- const ISSUE_BODY_PATH = fileURLToPath(
21
- new URL("../../templates/report/issue-body.json", import.meta.url),
22
- );
23
-
24
- /** The shipped issue-body template — the emit-side form/component source. */
25
- const issueBody = (): { components?: unknown } & Record<string, unknown> =>
26
- JSON.parse(readFileSync(ISSUE_BODY_PATH, "utf8")) as { components?: unknown } & Record<
27
- string,
28
- unknown
29
- >;
30
-
31
- describe("issue-body single-source (spec §3.1 ① · §3.2 ⑤ · §3.4 ⑰)", () => {
32
- it("① the withdrawn sectionLabels copy is gone — the word table is the sole label source", () => {
33
- // The label rows live on face/words.ts (the renderer's real read). A second
34
- // copy here is the drift this gate bans.
35
- expect(issueBody()).not.toHaveProperty("sectionLabels");
36
- });
37
-
38
- it("⑰ the orphan fields carry zero residue (severities / metaFields / reportDef / masterDef)", () => {
39
- const meta = issueBody();
40
- for (const orphan of ["severities", "metaFields", "reportDef", "masterDef"]) {
41
- expect(meta, `${orphan} must be deleted (zero reader)`).not.toHaveProperty(orphan);
42
- }
43
- });
44
-
45
- it("⑤ the components roster derives — six roster-prefixed kairos keys + two fixed headers", () => {
46
- const components = issueBody().components as unknown[];
47
- expect(Array.isArray(components)).toBe(true);
48
-
49
- // The two fixed headers (no roster source) — declared explicitly.
50
- const fixed = ["kairos (general)", "cdd-engine"];
51
- // The six kairos components = `kairos:` + the closed six-set roster key.
52
- const derived = Object.keys(SKILL_ANATOMY.skills.registry).map((key) => `kairos:${key}`);
53
-
54
- const expected = new Set([...fixed, ...derived]);
55
- expect(components).toHaveLength(expected.size);
56
- for (const component of components) {
57
- expect(expected.has(String(component)), `unexpected component: ${String(component)}`).toBe(
58
- true,
59
- );
60
- }
61
- // The roster-derived half is exactly the six kairos keys (the prefix transform).
62
- for (const component of derived) {
63
- expect(components, `${component} missing from the roster`).toContain(component);
64
- }
65
- });
66
- });
@@ -1,72 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/phase-suffix.guard.test.ts
2
- // T12 (spec §3.2 ⑬) — the phase-suffix consistency gate. The slug phase-suffix
3
- // grammar is ONE fact with two consumption surfaces:
4
- // · Workspace.phaseSuffixOf — the trailing `-p<major>(.<minor>)*` parse
5
- // (the `-p…$` form, infra/workspace.ts).
6
- // · BoardView.scanPhases — the suffix-only match over the specs dir
7
- // (the `^p…$` form, face/board-view.ts, via PHASE_SUFFIX_BARE).
8
- // Both MUST compose from the shared `PHASE_SUFFIX_CORE` fragment so the two forms
9
- // cannot drift. (The doc-contract design-unit syntax `P\d+(\.\d+)*-design` is
10
- // ANOTHER fact — uppercase + `-design` tail — never merged here.) This gate pins
11
- // the single source structurally and the two surfaces behaviorally (in-grammar
12
- // agrees, out-of-grammar rejected at both).
13
-
14
- import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
15
- import { tmpdir } from "node:os";
16
- import path from "node:path";
17
- import { fileURLToPath } from "node:url";
18
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
19
- import { BoardView } from "../face/board-view.ts";
20
- import { PHASE_SUFFIX_BARE, PHASE_SUFFIX_CORE, Workspace } from "../infra/workspace.ts";
21
-
22
- const SRC = fileURLToPath(new URL("../", import.meta.url));
23
- const read = (rel: string): string => readFileSync(`${SRC}/${rel}`, "utf8");
24
-
25
- describe("the phase-suffix grammar holds one shared source (spec §3.2 ⑬)", () => {
26
- it("both regex forms are composed from PHASE_SUFFIX_CORE — zero second literal", () => {
27
- // The shared fragment is the ONE grammar: the suffix-only form is built from it
28
- // (`^${PHASE_SUFFIX_CORE}$` — asserted behaviorally below), and the board's scan
29
- // imports that derived form rather than re-spelling the pattern.
30
- expect(PHASE_SUFFIX_BARE.source).toBe(`^${PHASE_SUFFIX_CORE}$`);
31
- const boardSrc = read("face/board-view.ts");
32
- expect(boardSrc).toContain("PHASE_SUFFIX_BARE");
33
- // no raw phase-suffix regex literal re-spelled in the board face
34
- expect(boardSrc).not.toMatch(/p\\d\+/);
35
- });
36
-
37
- it("in-grammar suffixes parse identically at both surfaces", () => {
38
- // the tail parse captures the dash-bearing `-p…` segment; the board's bare
39
- // match takes the dash-less `p…` segment (same grammar, different input form).
40
- for (const suffix of ["p2", "p4.1", "p10"]) {
41
- expect(Workspace.phaseSuffixOf(`prog-${suffix}`), `phaseSuffixOf prog-${suffix}`).toBe(
42
- `-${suffix}`,
43
- );
44
- expect(PHASE_SUFFIX_BARE.test(suffix), `board bare test ${suffix}`).toBe(true);
45
- }
46
- });
47
-
48
- it("out-of-grammar suffixes are rejected at both surfaces (uppercase is another fact)", () => {
49
- for (const suffix of ["P7", "p", "p7x", "pp7"]) {
50
- expect(Workspace.phaseSuffixOf(`prog-${suffix}`), `phaseSuffixOf prog-${suffix}`).toBeNull();
51
- expect(PHASE_SUFFIX_BARE.test(suffix), `board bare test ${suffix}`).toBe(false);
52
- }
53
- });
54
-
55
- describe("behavioral agreement over the on-disk scan", () => {
56
- let repo: string;
57
- beforeEach(() => {
58
- repo = mkdtempSync(path.join(tmpdir(), "phase-suffix-guard-"));
59
- });
60
- afterEach(() => {
61
- rmSync(repo, { recursive: true, force: true });
62
- });
63
-
64
- it("scanPhases admits exactly the suffixes phaseSuffixOf accepts", () => {
65
- mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
66
- // in-grammar → admitted; out-of-grammar (uppercase `P7`) → not a phase
67
- for (const name of ["prog-p7", "prog-p7.1", "prog-P7"])
68
- writeFileSync(path.join(repo, "docs/kairos/specs", `${name}-design.md`), "# S\n");
69
- expect(BoardView.scanPhases("prog", repo)).toEqual(["-p7", "-p7.1"]);
70
- });
71
- });
72
- });
@@ -1,185 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/smoke.integration.test.ts
2
- // The engine smoke integration test — the consumer release gate migrated from
3
- // scripts/smoke-cdd.ts (P5 T7): boots the source bin (`node src-next/bin.ts`) over a
4
- // fresh fixture git repo and asserts the `--help` commander face plus the read-only
5
- // `--dry-run` preview (the five-row next-step forecast at zero repo writes). The engine
6
- // carries no version assertion — `--expect-version` was withdrawn as a no-op (user
7
- // adjudication 2026-10-12); the `smoke` script (`pnpm -C packages/cdd-engine run smoke`)
8
- // is the release.yml gate's shared anchor.
9
- //
10
- // Zero module-level bare functions — the helpers are `const` (the P5
11
- // zero-`function`-declaration discipline).
12
-
13
- import { execFileSync, spawnSync } from "node:child_process";
14
- import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
15
- import { tmpdir } from "node:os";
16
- import path from "node:path";
17
- import { fileURLToPath } from "node:url";
18
- import { describe, it } from "vitest";
19
-
20
- /** The source bin under test — the engine's own entry (spawned, never imported). */
21
- const BIN = fileURLToPath(new URL("../bin.ts", import.meta.url));
22
-
23
- /** The fixture plan text — the canonical data-shaped task record (the front-matter
24
- * head the plan parser reads; the workspace slug derives `fixture` from the
25
- * basename). */
26
- const fixturePlan = (): string =>
27
- [
28
- "---",
29
- "title: Fixture Plan",
30
- "doc-type: plan",
31
- "version: v1.0",
32
- "date: 2026-10-09",
33
- "spec: fixture-design.md",
34
- "parent-program: fixture-overall.md",
35
- "parent-version: v1.0",
36
- "---",
37
- "",
38
- "## Constraints",
39
- "",
40
- "- Smoke fixture constraints materialized into the temp repo.",
41
- "",
42
- "### Task 1: fixture task",
43
- "",
44
- "- **Objective**: exercise the installed cdd engine under the read-only preview",
45
- "- **Files**: fixture-plan.md",
46
- "- **Steps**:",
47
- " 1. run the new-tree engine under `--dry-run` — checkable: the preview block completes",
48
- "- **Acceptance**:",
49
- " - the preview forecasts the next step with zero repo writes",
50
- "- **DependsOn**: none",
51
- "",
52
- ].join("\n");
53
-
54
- /** The fixture design spec — the plan's `spec:` link target (existence only). */
55
- const fixtureSpec = (): string =>
56
- [
57
- "---",
58
- "title: Fixture Design",
59
- "doc-type: phase-spec",
60
- "version: v1.0",
61
- "date: 2026-10-09",
62
- "status: Draft",
63
- "---",
64
- "",
65
- "## Design",
66
- "",
67
- "### Acceptance criteria",
68
- "",
69
- "- the smoke chain audits clean",
70
- "",
71
- ].join("\n");
72
-
73
- /** The fixture overall — the plan's `parent-program:` link target (existence only). */
74
- const fixtureOverall = (): string =>
75
- [
76
- "---",
77
- "title: Fixture Overall",
78
- "doc-type: overall-spec",
79
- "version: v1.0",
80
- "date: 2026-10-09",
81
- "status: Draft",
82
- "---",
83
- "",
84
- "## Phase inventory",
85
- "",
86
- "| # | Phase | Status | []",
87
- "|---|-------|--------|-----|",
88
- "",
89
- "",
90
- ]
91
- .join("\n")
92
- .trimEnd();
93
-
94
- /** The smoke assertion surface — one failed assert = the smoke fails loud. */
95
- const assertOk = (cond: boolean, msg: string): void => {
96
- if (!cond) throw new Error(`smoke: ${msg}`);
97
- };
98
-
99
- /** Run the source bin in a cwd (host env injected — the harness detection sees claude). */
100
- const runNode = (args: string[], cwd: string): { code: number; stdout: string; stderr: string } => {
101
- const res = spawnSync(process.execPath, args, {
102
- cwd,
103
- encoding: "utf8",
104
- env: { ...process.env, CLAUDE_CODE_SESSION_ID: "1" },
105
- timeout: 120_000,
106
- });
107
- return {
108
- code: res.status ?? 1,
109
- stdout: (res.stdout ?? "") as string,
110
- stderr: (res.stderr ?? "") as string,
111
- };
112
- };
113
-
114
- /** Run git in the fixture repo (the temp repo's commit identity is injected inline). */
115
- const git = (repo: string, ...args: string[]): void => {
116
- execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", stdio: "ignore" });
117
- };
118
-
119
- describe("the engine smoke — the source bin over a fixture repo", () => {
120
- it("boots the bin, asserts the `--help` face + the read-only `--dry-run` preview (zero writes)", () => {
121
- const repoRoot = mkdtempSync(path.join(tmpdir(), "cdd-smoke-"));
122
- try {
123
- writeFileSync(path.join(repoRoot, ".gitignore"), ".kairos\n");
124
- writeFileSync(path.join(repoRoot, "fixture-plan.md"), fixturePlan(), "utf8");
125
- writeFileSync(path.join(repoRoot, "fixture-design.md"), fixtureSpec(), "utf8");
126
- writeFileSync(path.join(repoRoot, "fixture-overall.md"), fixtureOverall(), "utf8");
127
- git(repoRoot, "init", "-q");
128
- git(
129
- repoRoot,
130
- "-c",
131
- "user.name=cdd-smoke",
132
- "-c",
133
- "user.email=cdd-smoke@oscaner.dev",
134
- "add",
135
- "-A",
136
- );
137
- git(
138
- repoRoot,
139
- "-c",
140
- "user.name=cdd-smoke",
141
- "-c",
142
- "user.email=cdd-smoke@oscaner.dev",
143
- "commit",
144
- "-qm",
145
- "fixture",
146
- );
147
-
148
- // The help face — the commander-native program face (the T4 stable anchor): the
149
- // native Usage first line + the command-table rows (the new-tree CLI's --help is
150
- // the commander program face — `Usage: cdd [options] [command]` + the
151
- // `implement [options]` / `review [options]` / `fix [options]` rows).
152
- const helpOut = runNode([BIN, "--help"], repoRoot);
153
- assertOk(
154
- helpOut.stdout.includes("Usage: cdd [options] [command]") &&
155
- ["implement", "review", "fix"].every((name) =>
156
- helpOut.stdout.includes(`${name} [options]`),
157
- ),
158
- `--help missing the commander-native face (code ${helpOut.code}) stdout=${JSON.stringify(helpOut.stdout.slice(0, 120))} stderr=${JSON.stringify(helpOut.stderr.slice(0, 120))}`,
159
- );
160
-
161
- // The `--dry-run` read-only preview — the release gate's zero-write face: the
162
- // next dispatch step is forecast in five rows and nothing is written. The
163
- // retired synthetic bookkeeping (a booked round + a fabricated capsule) is
164
- // gone: a preview states the step, never a conclusion.
165
- const preview = runNode(
166
- [BIN, "--dry-run", "implement", "--tasks", "1", "--plan", "fixture-plan.md"],
167
- repoRoot,
168
- );
169
- assertOk(preview.code === 0, `--dry-run implement exited ${preview.code}: ${preview.stderr}`);
170
- assertOk(
171
- preview.stdout.startsWith("cdd implement: preview (no repo changes)\n"),
172
- `preview header missing: ${JSON.stringify(preview.stdout)}`,
173
- );
174
- for (const label of ["step:", "reads:", "would write:", "would record:", "child:"])
175
- assertOk(preview.stdout.includes(` ${label} `), `preview row ${label} missing`);
176
- // a preview fabricates no conclusion and no next hop
177
- assertOk(!preview.stdout.includes("status:"), "preview must not print a status: line");
178
- assertOk(!/^next:/m.test(preview.stdout), "preview must not print a next: line");
179
- // zero repo writes — the engine workspace (and its slug) never appear
180
- assertOk(!existsSync(path.join(repoRoot, ".kairos")), ".kairos/ must stay absent");
181
- } finally {
182
- rmSync(repoRoot, { recursive: true, force: true });
183
- }
184
- });
185
- });
@@ -1,99 +0,0 @@
1
- // packages/cdd-engine/src-next/__tests__/support/strip-comments.ts
2
- // The shared length-preserving comment/string stripper for the src-next source
3
- // guards (P9 branch-review-1 F4 — one stripper, one home). Two guards read the
4
- // engine's own source text and must ignore prose comments while still counting a
5
- // token that lives inside a string literal (a `process.cwd()` quoted in code is a
6
- // real occurrence; the same text in a `//` comment is not) — the structural pin
7
- // (face/__tests__/repo-root.guard.test.ts) and the retired-plane guard
8
- // (__tests__/zero-dep.test.ts) both ride this ONE implementation, so their
9
- // hand-written heuristic boundary can never drift apart.
10
- //
11
- // The stripper preserves length and line count (a stripped comment collapses to
12
- // blank chars, its line terminator survives) so a reported `line:col` hit stays
13
- // true after stripping. It tracks string and template-literal interiors (never
14
- // blanked — a token inside a string is a real occurrence) and regex-literal
15
- // bodies (so a backtick inside `/`+…`/` never desyncs the string tracker).
16
- //
17
- // Documented heuristic boundary: a template literal's `${ … }` nesting is not
18
- // tracked, so a backtick inside an interpolation closes the outer template early.
19
- //
20
- // Zero module-level bare functions — the strip/regex-may-start pair are `const`
21
- // arrows (the plan's zero-`function`-declaration discipline).
22
-
23
- /** Whether a `/` at `previous` (the last non-space code char, "" at file start)
24
- * may open a regex literal rather than being a division operator. */
25
- const regexMayStart = (previous: string): boolean =>
26
- previous === "" || !/[A-Za-z0-9_$)\]]/.test(previous);
27
-
28
- /** Strip line + block comments, preserving length and line count. The scan tracks
29
- * string / template-literal interiors (kept verbatim — a symbol inside a string
30
- * is a real occurrence, not prose) and regex-literal bodies (so a backtick inside
31
- * `/`+…`/` never desyncs the string tracker); a `//` inside a string or template
32
- * therefore never truncates the line. See the module header for the documented
33
- * interpolation-nesting boundary. */
34
- export const stripComments = (source: string): string => {
35
- const out = source.split("");
36
- let index = 0;
37
- let previous = "";
38
- while (index < source.length) {
39
- const char = source[index]!;
40
- const next = source[index + 1];
41
- if (char === "/" && next === "/") {
42
- while (index < source.length && source[index] !== "\n") {
43
- out[index] = "";
44
- index += 1;
45
- }
46
- } else if (char === "/" && next === "*") {
47
- out[index] = "";
48
- out[index + 1] = "";
49
- index += 2;
50
- while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
51
- if (source[index] !== "\n") out[index] = "";
52
- index += 1;
53
- }
54
- if (index < source.length) {
55
- out[index] = "";
56
- out[index + 1] = "";
57
- index += 2;
58
- }
59
- } else if (char === "'" || char === '"' || char === "`") {
60
- const quote = char;
61
- index += 1;
62
- while (index < source.length && source[index] !== quote) {
63
- if (source[index] === "\\") index += 1;
64
- index += 1;
65
- }
66
- index += 1;
67
- } else if (char === "/" && regexMayStart(previous)) {
68
- index += 1;
69
- let inClass = false;
70
- while (index < source.length) {
71
- const inner = source[index]!;
72
- if (inner === "\\") {
73
- index += 2;
74
- continue;
75
- }
76
- if (inner === "[") {
77
- inClass = true;
78
- index += 1;
79
- continue;
80
- }
81
- if (inner === "]") {
82
- inClass = false;
83
- index += 1;
84
- continue;
85
- }
86
- if (inner === "/" && !inClass) {
87
- index += 1;
88
- break;
89
- }
90
- if (inner === "\n") break;
91
- index += 1;
92
- }
93
- } else {
94
- if (char.trim() !== "") previous = char;
95
- index += 1;
96
- }
97
- }
98
- return out.join("");
99
- };