@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.
- package/README.md +9 -8
- package/README.zh-CN.md +9 -8
- package/package.json +15 -22
- package/src-next/__tests__/bin.test.ts +128 -0
- package/src-next/__tests__/smoke.integration.test.ts +202 -0
- package/src-next/__tests__/zero-dep.test.ts +134 -0
- package/src-next/bin.ts +61 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +238 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +153 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +173 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +89 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +225 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +155 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +175 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +85 -0
- package/src-next/contract/__tests__/declare.test.ts +242 -0
- package/src-next/contract/__tests__/doc.test.ts +358 -0
- package/src-next/contract/__tests__/judge.test.ts +873 -0
- package/src-next/contract/__tests__/lint.test.ts +314 -0
- package/src-next/contract/__tests__/project.test.ts +419 -0
- package/src-next/contract/__tests__/translate.test.ts +96 -0
- package/src-next/contract/declare.ts +983 -0
- package/src-next/contract/doc.ts +753 -0
- package/src-next/contract/invariants.ts +1268 -0
- package/src-next/contract/judge.ts +142 -0
- package/src-next/contract/lint.ts +275 -0
- package/src-next/contract/project.ts +596 -0
- package/src-next/contract/skill-anatomy.ts +273 -0
- package/src-next/contract/translate.ts +113 -0
- package/src-next/face/__tests__/board-view.test.ts +948 -0
- package/src-next/face/__tests__/capsule.test.ts +276 -0
- package/src-next/face/__tests__/channel-closure.guard.test.ts +102 -0
- package/src-next/face/__tests__/cli.test.ts +4643 -0
- package/src-next/face/__tests__/face.test.ts +289 -0
- package/src-next/face/__tests__/graph-view.test.ts +61 -0
- package/src-next/face/__tests__/host.test.ts +24 -0
- package/src-next/face/__tests__/negation.ts +6 -0
- package/src-next/face/__tests__/projection.test.ts +301 -0
- package/src-next/face/__tests__/sync-runner.test.ts +70 -0
- package/src-next/face/__tests__/words.guard.test.ts +93 -0
- package/src-next/face/artifacts.ts +195 -0
- package/src-next/face/board-view.ts +662 -0
- package/src-next/face/capsule.ts +149 -0
- package/src-next/face/cli.ts +819 -0
- package/src-next/face/declare.ts +326 -0
- package/src-next/face/gate.ts +170 -0
- package/src-next/face/graph-view.ts +74 -0
- package/src-next/face/host.ts +326 -0
- package/src-next/face/lifecycle.ts +700 -0
- package/src-next/face/projection.ts +282 -0
- package/src-next/face/route-render.ts +160 -0
- package/src-next/face/words.ts +296 -0
- package/src-next/infra/__tests__/infra.test.ts +287 -0
- package/src-next/infra/config.ts +42 -0
- package/src-next/infra/git.ts +39 -0
- package/src-next/infra/process.ts +34 -0
- package/src-next/infra/runtime.ts +185 -0
- package/src-next/infra/workspace.ts +232 -0
- package/src-next/render/__tests__/render.test.ts +499 -0
- package/src-next/render/__tests__/skeleton.test.ts +466 -0
- package/src-next/render/brief.ts +121 -0
- package/src-next/render/issue-body.ts +159 -0
- package/src-next/render/skeleton.ts +437 -0
- package/src-next/render/templates.ts +650 -0
- package/src-next/session/__tests__/graph.test.ts +270 -0
- package/src-next/session/__tests__/handoff-plane.guard.test.ts +48 -0
- package/src-next/session/__tests__/handoff-schema.test.ts +310 -0
- package/src-next/session/__tests__/ledger.test.ts +744 -0
- package/src-next/session/__tests__/next.test.ts +368 -0
- package/src-next/session/__tests__/preflight.test.ts +491 -0
- package/src-next/session/__tests__/run.test.ts +1014 -0
- package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
- package/src-next/session/__tests__/wave.test.ts +469 -0
- package/src-next/session/faces.ts +110 -0
- package/src-next/session/graph.ts +411 -0
- package/src-next/session/handoff-schema.ts +373 -0
- package/src-next/session/ledger.ts +1004 -0
- package/src-next/session/next.ts +192 -0
- package/src-next/session/preflight.ts +240 -0
- package/src-next/session/run.ts +606 -0
- package/src-next/session/state.ts +30 -0
- package/src-next/session/wave.ts +139 -0
- package/templates/report/issue-body.json +18 -20
- package/dist/chunks/branch.mjs +0 -480
- package/dist/chunks/docs.mjs +0 -253
- package/dist/chunks/task.mjs +0 -913
- package/dist/cli.mjs +0 -5457
- package/dist/documents/schema/add-phase-protocol.json +0 -126
- package/dist/documents/schema/overall.json +0 -361
- package/dist/documents/schema/phase-spec.json +0 -145
- package/dist/documents/schema/plan.json +0 -191
- package/dist/documents/schema/skill-anatomy.json +0 -233
- package/dist/resources/harness-registry.json +0 -49
- package/dist/shared/cdd-engine.liioziig.mjs +0 -184
- package/templates/engine-config.json +0 -302
- package/templates/schema/cache-profile-schema.json +0 -23
- package/templates/schema/docs-handoff-schema.json +0 -129
- package/templates/schema/task-handoff-schema.json +0 -332
- package/templates/template-contract.json +0 -231
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | [中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
CDD engine CLI — the task runner, document/branch reviewer, and harness dispatcher behind the
|
|
5
|
+
CDD engine CLI — the task runner, document/branch reviewer, and harness dispatcher behind the kairos `cdd-dev` skill. Published as a standalone package so the engine (`cdd`) can be installed and invoked on its own.
|
|
6
6
|
|
|
7
7
|
## What this package is
|
|
8
8
|
|
|
9
|
-
The engine runs the implement / review / fix phases of the CDD workflow against a plan file, writes the dispatch's handoff artifacts, reads and writes the `base
|
|
9
|
+
The engine runs the implement / review / fix phases of the CDD workflow against a plan file, writes the dispatch's handoff artifacts, reads and writes the `base` artifact, and dispatches each phase to the host harness CLI through its embedded harness registry. It is consumed by the [kairos plugin](https://www.npmjs.com/package/@oscaner-skills/kairos)'s `cdd-dev` skill and is also usable directly from the command line.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -29,23 +29,24 @@ Global option: `--dry-run` — simulate the dispatch without writing handoff art
|
|
|
29
29
|
| `implement` | `cdd implement --tasks=<n> [--plan=<path>]` | Run the task implement phase |
|
|
30
30
|
| `review` | `cdd review --type=<task\|branch\|spec\|plan>` | Run a review — task, branch, spec, or plan |
|
|
31
31
|
| `fix` | `cdd fix --type=<task\|branch\|spec\|plan>` | Fix review findings — task, branch, spec, or plan |
|
|
32
|
-
| `base
|
|
32
|
+
| `base` | `cdd base set\|get` | Read/write the `base.json` artifact (single CDD `--plan` target) |
|
|
33
33
|
| `schema` | `cdd schema get <type>` | Print the canonical doc-structure schema (discovery-only, zero enforcement) |
|
|
34
34
|
| `issue` | `cdd issue render` | Render an aggregate issue body from stdin findings (pure rendering, zero enforcement) |
|
|
35
|
+
| `board` | `cdd board <slug>` | Render the slug progress board (overall/spec/plan/wave/branch; pure read, zero enforcement) |
|
|
35
36
|
|
|
36
|
-
Use `cdd <command> --help` for a command's full option list (for example `cdd review --tasks` / `--
|
|
37
|
+
Use `cdd <command> --help` for a command's full option list (for example `cdd review --tasks` / `--spec` / `--plan` / `--round`).
|
|
37
38
|
|
|
38
39
|
## Development
|
|
39
40
|
|
|
40
|
-
The package lives in the [Oscaner/skills](https://github.com/Oscaner/skills) monorepo at `packages/cdd-engine` (TypeScript,
|
|
41
|
+
The package lives in the [Oscaner/skills](https://github.com/Oscaner/skills) monorepo at `packages/cdd-engine` (TypeScript, emitted with `tsc -p tsconfig.build.json`, tested with vitest; tests are colocated at `src-next/**/__tests__/**/*.test.ts`).
|
|
41
42
|
|
|
42
43
|
```bash
|
|
43
|
-
|
|
44
|
-
node packages/cdd-engine/dist/cli.mjs schema get plan # invoke the engine from the working tree
|
|
44
|
+
node packages/cdd-engine/src-next/bin.ts schema get plan # invoke the engine source-direct from the working tree (Node ≥22.18 native type stripping)
|
|
45
45
|
pnpm --filter @oscaner-skills/cdd-engine test # run the engine test suite
|
|
46
|
+
pnpm --filter @oscaner-skills/cdd-engine build # tsc-emit the published dist/bin.js
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
During repository development the engine is invoked straight
|
|
49
|
+
During repository development the engine is invoked straight on the source entry (`node packages/cdd-engine/src-next/bin.ts`) — never through a global install or link, which can go stale.
|
|
49
50
|
|
|
50
51
|
## License
|
|
51
52
|
|
package/README.zh-CN.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[English](README.md) | [中文](README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
CDD 引擎 CLI——
|
|
7
|
+
CDD 引擎 CLI——kairos `cdd-dev` 技能背后的任务运行器、文档/分支评审器与 harness 派发器。以独立包发布,使引擎(`cdd`)可单独安装与调用。
|
|
8
8
|
|
|
9
9
|
## 包定位
|
|
10
10
|
|
|
11
|
-
引擎针对计划文件运行 CDD 工作流的 implement / review / fix 阶段,写出派发的 handoff 产物,读写 `base
|
|
11
|
+
引擎针对计划文件运行 CDD 工作流的 implement / review / fix 阶段,写出派发的 handoff 产物,读写 `base` 产物,并通过其内嵌的 harness 注册表将每个阶段派发给宿主 harness CLI。它被 [kairos 插件](https://www.npmjs.com/package/@oscaner-skills/kairos)的 `cdd-dev` 技能消费,也可直接从命令行使用。
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
@@ -31,23 +31,24 @@ npm install @oscaner-skills/cdd-engine
|
|
|
31
31
|
| `implement` | `cdd implement --tasks=<n> [--plan=<path>]` | 运行任务 implement 阶段 |
|
|
32
32
|
| `review` | `cdd review --type=<task\|branch\|spec\|plan>` | 运行评审——task、branch、spec 或 plan |
|
|
33
33
|
| `fix` | `cdd fix --type=<task\|branch\|spec\|plan>` | 修复评审发现——task、branch、spec 或 plan |
|
|
34
|
-
| `base
|
|
34
|
+
| `base` | `cdd base set\|get` | 读写 `base.json` 产物(单一 CDD `--plan` 目标) |
|
|
35
35
|
| `schema` | `cdd schema get <type>` | 打印 canonical 文档结构 schema(发现型、零执法) |
|
|
36
36
|
| `issue` | `cdd issue render` | 依据 stdin 发现渲染聚合 issue 正文(纯渲染、零执法) |
|
|
37
|
+
| `board` | `cdd board <slug>` | 渲染 slug 进度板(overall/spec/plan/wave/branch;纯读、零执法) |
|
|
37
38
|
|
|
38
|
-
用 `cdd <command> --help` 查看某命令的完整选项列表(例如 `cdd review --tasks` / `--
|
|
39
|
+
用 `cdd <command> --help` 查看某命令的完整选项列表(例如 `cdd review --tasks` / `--spec` / `--plan` / `--round`)。
|
|
39
40
|
|
|
40
41
|
## 开发说明
|
|
41
42
|
|
|
42
|
-
包位于 [Oscaner/skills](https://github.com/Oscaner/skills) monorepo 的 `packages/cdd-engine`(TypeScript
|
|
43
|
+
包位于 [Oscaner/skills](https://github.com/Oscaner/skills) monorepo 的 `packages/cdd-engine`(TypeScript,`tsc -p tsconfig.build.json` 发布构建,vitest 测试;测试与源码同地放置于 `src-next/**/__tests__/**/*.test.ts`)。
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
|
|
46
|
-
node packages/cdd-engine/dist/cli.mjs schema get plan # 从工作树直接调用引擎
|
|
46
|
+
node packages/cdd-engine/src-next/bin.ts schema get plan # 从工作树源面直接调用引擎(Node ≥22.18 原生类型剥离)
|
|
47
47
|
pnpm --filter @oscaner-skills/cdd-engine test # 运行引擎测试套件
|
|
48
|
+
pnpm --filter @oscaner-skills/cdd-engine build # tsc 构建发布产物 dist/bin.js
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
仓库开发期间引擎须从源面直调(`node packages/cdd-engine/src-next/bin.ts`)——绝不要经全局安装或链接,可能过期。
|
|
51
52
|
|
|
52
53
|
## 许可
|
|
53
54
|
|
package/package.json
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscaner-skills/cdd-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "CDD engine CLIs: task runner, docs reviewer, branch reviewer, harness selector.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=24"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
10
|
+
"src-next/",
|
|
11
11
|
"templates/"
|
|
12
12
|
],
|
|
13
|
-
"main": "./
|
|
13
|
+
"main": "./src-next/bin.ts",
|
|
14
14
|
"exports": {
|
|
15
|
-
".": "./
|
|
15
|
+
".": "./src-next/bin.ts",
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"cdd": "./
|
|
19
|
+
"cdd": "./src-next/bin.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"handlebars": "^4.7.9",
|
|
27
|
-
"hookable": "^6.1.2",
|
|
28
|
-
"semver": "^7.8.5",
|
|
29
|
-
"simple-git": "^3.36.0",
|
|
30
|
-
"tinyglobby": "^0.2.17"
|
|
22
|
+
"commander": "^15.0.0",
|
|
23
|
+
"execa": "^10.1.1",
|
|
24
|
+
"jsonc-parser": "^3.3.1",
|
|
25
|
+
"simple-git": "^4.0.2"
|
|
31
26
|
},
|
|
32
27
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"@typescript/typescript6": "^6.0.2",
|
|
28
|
+
"@types/node": "^24.19.2",
|
|
35
29
|
"typescript": "^7.0.2",
|
|
36
|
-
"
|
|
37
|
-
"vitest": "^5.0.1"
|
|
30
|
+
"vitest": "^5.0.3"
|
|
38
31
|
},
|
|
39
32
|
"repository": {
|
|
40
33
|
"type": "git",
|
|
@@ -43,9 +36,9 @@
|
|
|
43
36
|
},
|
|
44
37
|
"license": "MIT",
|
|
45
38
|
"scripts": {
|
|
46
|
-
"build": "
|
|
47
|
-
"dev:stub": "unbuild --stub",
|
|
39
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
48
40
|
"test": "vitest run",
|
|
49
|
-
"test:watch": "vitest"
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"smoke": "vitest run src-next/__tests__/smoke.integration.test.ts"
|
|
50
43
|
}
|
|
51
44
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
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 status-capsule contract on the dry-run
|
|
5
|
+
// chain (`--dry-run implement` + `--dry-run review`) plus the `--help` commander
|
|
6
|
+
// face. The engine carries no version assertion — `--expect-version` was withdrawn as
|
|
7
|
+
// a no-op (user adjudication 2026-10-12); the `smoke` script (`pnpm -C
|
|
8
|
+
// packages/cdd-engine run smoke`) 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 { 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, expect, 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 markers the
|
|
24
|
+
* plan parser reads; the workspace slug derives `fixture` from the basename). */
|
|
25
|
+
const fixturePlan = (): string =>
|
|
26
|
+
[
|
|
27
|
+
"# Fixture Plan",
|
|
28
|
+
"",
|
|
29
|
+
"**Spec:** [fixture-design.md](fixture-design.md)",
|
|
30
|
+
"",
|
|
31
|
+
"- **Parent program**: [fixture-overall.md v1.0](fixture-overall.md)",
|
|
32
|
+
"",
|
|
33
|
+
"## Constraints",
|
|
34
|
+
"",
|
|
35
|
+
"- Smoke fixture constraints materialized into the temp repo.",
|
|
36
|
+
"",
|
|
37
|
+
"### Task 1: fixture task",
|
|
38
|
+
"",
|
|
39
|
+
"- **Objective**: exercise the installed cdd engine under dry-run",
|
|
40
|
+
"- **Files**: fixture-plan.md",
|
|
41
|
+
"- **Steps**:",
|
|
42
|
+
" 1. run the new-tree engine under dry-run — checkable: the dry-run chain completes",
|
|
43
|
+
"- **Acceptance**:",
|
|
44
|
+
" - the dry-run chain prints the status capsule",
|
|
45
|
+
"- **DependsOn**: none",
|
|
46
|
+
"",
|
|
47
|
+
].join("\n");
|
|
48
|
+
|
|
49
|
+
/** The fixture design spec — the plan's **Spec:** link target (existence only). */
|
|
50
|
+
const fixtureSpec = (): string =>
|
|
51
|
+
[
|
|
52
|
+
"# Fixture Design",
|
|
53
|
+
"",
|
|
54
|
+
"- **Version**: v1.0",
|
|
55
|
+
"",
|
|
56
|
+
"## Design",
|
|
57
|
+
"",
|
|
58
|
+
"### Acceptance criteria",
|
|
59
|
+
"",
|
|
60
|
+
"- the smoke chain audits clean",
|
|
61
|
+
"",
|
|
62
|
+
].join("\n");
|
|
63
|
+
|
|
64
|
+
/** The fixture overall — the plan's **Parent program** link target (existence only). */
|
|
65
|
+
const fixtureOverall = (): string =>
|
|
66
|
+
[
|
|
67
|
+
"# Fixture Overall",
|
|
68
|
+
"",
|
|
69
|
+
"- **Version**: v1.0",
|
|
70
|
+
"",
|
|
71
|
+
"## Phase inventory",
|
|
72
|
+
"",
|
|
73
|
+
"| # | Phase | Status | []",
|
|
74
|
+
"|---|-------|--------|-----|",
|
|
75
|
+
"",
|
|
76
|
+
"",
|
|
77
|
+
]
|
|
78
|
+
.join("\n")
|
|
79
|
+
.trimEnd();
|
|
80
|
+
|
|
81
|
+
/** The smoke assertion surface — one failed assert = the smoke fails loud. */
|
|
82
|
+
const assertOk = (cond: boolean, msg: string): void => {
|
|
83
|
+
if (!cond) throw new Error(`smoke: ${msg}`);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Run the source bin in a cwd (host env injected — the harness detection sees claude). */
|
|
87
|
+
const runNode = (args: string[], cwd: string): { code: number; stdout: string; stderr: string } => {
|
|
88
|
+
const res = spawnSync(process.execPath, args, {
|
|
89
|
+
cwd,
|
|
90
|
+
encoding: "utf8",
|
|
91
|
+
env: { ...process.env, CLAUDE_CODE_SESSION_ID: "1" },
|
|
92
|
+
timeout: 120_000,
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
code: res.status ?? 1,
|
|
96
|
+
stdout: (res.stdout ?? "") as string,
|
|
97
|
+
stderr: (res.stderr ?? "") as string,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** The capsule contract — the last stdout block carries the status capsule + the
|
|
102
|
+
* `next:` suggestion line (the engine's single result surface). The route-face
|
|
103
|
+
* words (v1.25 dispatch-ready literals: `done` terminal · `implement wave {tasks}`
|
|
104
|
+
* · `review <type> <id> (base …)` · `fix <type> <id> --findings …` + the readback
|
|
105
|
+
* suffix · the soft-cap message) — `none` is retired. */
|
|
106
|
+
const assertCapsule = (stdout: string, command: string): void => {
|
|
107
|
+
const lines = stdout.trim().split("\n");
|
|
108
|
+
const capsule = lines.find((l) => l.startsWith("status:") && l.includes("blocker:"));
|
|
109
|
+
assertOk(
|
|
110
|
+
capsule !== undefined,
|
|
111
|
+
`status capsule missing from ${command} stdout: ${JSON.stringify(stdout)}`,
|
|
112
|
+
);
|
|
113
|
+
assertOk(
|
|
114
|
+
/^status: (APPROVED|BLOCKED|REVIEW_FIX|CHANGES_REQUESTED) · blocker: \d+ · handoff: /.test(
|
|
115
|
+
capsule!,
|
|
116
|
+
),
|
|
117
|
+
`status capsule malformed for ${command}: ${JSON.stringify(capsule)}`,
|
|
118
|
+
);
|
|
119
|
+
const next = lines.find((l) => l.startsWith("next:"));
|
|
120
|
+
assertOk(
|
|
121
|
+
next !== undefined && /^next: (done$|implement wave|review |fix($| )|BLOCKED:)/.test(next!),
|
|
122
|
+
`next: line missing or malformed for ${command}: ${JSON.stringify(next)}`,
|
|
123
|
+
);
|
|
124
|
+
// Zero old-shape stdout key lines (the 4-line block is retired).
|
|
125
|
+
assertOk(
|
|
126
|
+
lines.every((l) => !/^(commits|artifacts|counters):/.test(l)),
|
|
127
|
+
`old-shape stdout key line present for ${command}`,
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** Run git in the fixture repo (the temp repo's commit identity is injected inline). */
|
|
132
|
+
const git = (repo: string, ...args: string[]): void => {
|
|
133
|
+
execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", stdio: "ignore" });
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
describe("the engine smoke — the source bin dry-run chain over a fixture repo", () => {
|
|
137
|
+
it("boots the bin, asserts the `--help` face + the capsule contract on the dry-run chain", () => {
|
|
138
|
+
const repoRoot = mkdtempSync(path.join(tmpdir(), "cdd-smoke-"));
|
|
139
|
+
try {
|
|
140
|
+
writeFileSync(path.join(repoRoot, ".gitignore"), ".kairos\n");
|
|
141
|
+
writeFileSync(path.join(repoRoot, "fixture-plan.md"), fixturePlan(), "utf8");
|
|
142
|
+
writeFileSync(path.join(repoRoot, "fixture-design.md"), fixtureSpec(), "utf8");
|
|
143
|
+
writeFileSync(path.join(repoRoot, "fixture-overall.md"), fixtureOverall(), "utf8");
|
|
144
|
+
git(repoRoot, "init", "-q");
|
|
145
|
+
git(
|
|
146
|
+
repoRoot,
|
|
147
|
+
"-c",
|
|
148
|
+
"user.name=cdd-smoke",
|
|
149
|
+
"-c",
|
|
150
|
+
"user.email=cdd-smoke@oscaner.dev",
|
|
151
|
+
"add",
|
|
152
|
+
"-A",
|
|
153
|
+
);
|
|
154
|
+
git(
|
|
155
|
+
repoRoot,
|
|
156
|
+
"-c",
|
|
157
|
+
"user.name=cdd-smoke",
|
|
158
|
+
"-c",
|
|
159
|
+
"user.email=cdd-smoke@oscaner.dev",
|
|
160
|
+
"commit",
|
|
161
|
+
"-qm",
|
|
162
|
+
"fixture",
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// The help face — the commander-native program face (the T4 stable anchor): the
|
|
166
|
+
// native Usage first line + the command-table rows (the new-tree CLI's --help is
|
|
167
|
+
// the commander program face — `Usage: cdd [options] [command]` + the
|
|
168
|
+
// `implement [options]` / `review [options]` / `fix [options]` rows).
|
|
169
|
+
const helpOut = runNode([BIN, "--help"], repoRoot);
|
|
170
|
+
assertOk(
|
|
171
|
+
helpOut.stdout.includes("Usage: cdd [options] [command]") &&
|
|
172
|
+
["implement", "review", "fix"].every((name) =>
|
|
173
|
+
helpOut.stdout.includes(`${name} [options]`),
|
|
174
|
+
),
|
|
175
|
+
`--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))}`,
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// The dry-run work chain — implement then review, each asserting the capsule.
|
|
179
|
+
let stdout = "";
|
|
180
|
+
const chain = [
|
|
181
|
+
["--dry-run", "implement", "--tasks", "1", "--plan", "fixture-plan.md"],
|
|
182
|
+
["--dry-run", "review", "--type", "wave", "--tasks", "1", "--plan", "fixture-plan.md"],
|
|
183
|
+
];
|
|
184
|
+
for (const args of chain) {
|
|
185
|
+
const res = runNode([BIN, ...args], repoRoot);
|
|
186
|
+
assertOk(
|
|
187
|
+
res.code === 0,
|
|
188
|
+
`dry-run ${args.slice(1, 3).join(" ")} exited ${res.code}: ${res.stderr}`,
|
|
189
|
+
);
|
|
190
|
+
assertCapsule(res.stdout, args.join(" "));
|
|
191
|
+
stdout += res.stdout;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// The fixture repo's workspace slug + the status capsule (the smoke.test.ts
|
|
195
|
+
// assertions, migrated in place).
|
|
196
|
+
expect(stdout).toContain("status:");
|
|
197
|
+
expect(stdout).toContain(".kairos/cdd/fixture/");
|
|
198
|
+
} finally {
|
|
199
|
+
rmSync(repoRoot, { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/__tests__/zero-dep.test.ts
|
|
2
|
+
// P3.2 zero-dependency guard (T1 → cutover): during the two-tree coexistence window the
|
|
3
|
+
// old tree (src) and the new tree (src-next) had to stay mutually import-free. The
|
|
4
|
+
// cutover (T15) deleted the old tree — the guard now pins the post-cutover terminal
|
|
5
|
+
// state: the retired planes of this package (the src and config planes) are absent from
|
|
6
|
+
// disk, and no src-next module specifier may address them (a dangling reference into a
|
|
7
|
+
// deleted plane is a hard violation of the plan's zero-residue constraint). The two-way
|
|
8
|
+
// scan becomes one-way: src-next is the only live plane left.
|
|
9
|
+
|
|
10
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
11
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { expect, it } from "vitest";
|
|
14
|
+
|
|
15
|
+
const SRC_NEXT = fileURLToPath(new URL("../", import.meta.url));
|
|
16
|
+
const PKG_ROOT = fileURLToPath(new URL("../../", import.meta.url)); // packages/cdd-engine/
|
|
17
|
+
|
|
18
|
+
// The retired-plane discriminant: which deleted plane a module specifier addresses.
|
|
19
|
+
// The bare dirnames (no trailing slash — a slash-prefixed form would itself trip the
|
|
20
|
+
// cutover's zero-residue grep) are the only retired-plane tokens the guard names.
|
|
21
|
+
type RetiredPlane = "src" | "config";
|
|
22
|
+
const RETIRED_PLANES: readonly RetiredPlane[] = ["src", "config"];
|
|
23
|
+
|
|
24
|
+
/** Which retired plane a first path segment names, or null. */
|
|
25
|
+
const retiredBySegment = (head: string | undefined): RetiredPlane | null =>
|
|
26
|
+
head === "src" || head === "config" ? head : null;
|
|
27
|
+
|
|
28
|
+
/** The retired plane a resolved path falls into (by the package-root-relative first
|
|
29
|
+
* segment), or null when the path lives in a live plane or outside the package. */
|
|
30
|
+
const retiredByResolved = (resolved: string): RetiredPlane | null => {
|
|
31
|
+
return retiredBySegment(relative(PKG_ROOT, resolved).split(sep)[0]);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Module specifier patterns: `from "..."` (static import + re-export), dynamic
|
|
35
|
+
// `import("...")`, and side-effect `import "..."`.
|
|
36
|
+
const SPECIFIER_PATTERN = /(?:from\s+|import\s*\(\s*)(['"])([^'"]+)\1/g;
|
|
37
|
+
const SIDE_EFFECT_PATTERN = /^\s*import\s+(['"])([^'"]+)\1/gm;
|
|
38
|
+
|
|
39
|
+
// Strip comments conservatively (line + block) while keeping string literals, so
|
|
40
|
+
// prose that quotes a `from "../src/x"` idiom never trips the guard.
|
|
41
|
+
// Heuristic boundary: comment elision applies only in code scope — string-literal
|
|
42
|
+
// contents are kept verbatim, and nested template literals are not tracked (a
|
|
43
|
+
// backtick inside `${ }` prematurely closes the outer template).
|
|
44
|
+
const stripComments = (code: string): string => {
|
|
45
|
+
let out = "";
|
|
46
|
+
let i = 0;
|
|
47
|
+
let inLineComment = false;
|
|
48
|
+
let inBlockComment = false;
|
|
49
|
+
let inString: "'" | '"' | "`" | null = null;
|
|
50
|
+
while (i < code.length) {
|
|
51
|
+
const c = code[i];
|
|
52
|
+
const next = code[i + 1];
|
|
53
|
+
if (inLineComment) {
|
|
54
|
+
if (c === "\n") {
|
|
55
|
+
inLineComment = false;
|
|
56
|
+
out += c;
|
|
57
|
+
}
|
|
58
|
+
i++;
|
|
59
|
+
} else if (inBlockComment) {
|
|
60
|
+
if (c === "*" && next === "/") inBlockComment = false;
|
|
61
|
+
i++;
|
|
62
|
+
} else if (inString) {
|
|
63
|
+
if (c === "\\") {
|
|
64
|
+
out += c + (next ?? "");
|
|
65
|
+
i += 2;
|
|
66
|
+
} else {
|
|
67
|
+
out += c;
|
|
68
|
+
if (c === inString) inString = null;
|
|
69
|
+
i++;
|
|
70
|
+
}
|
|
71
|
+
} else if (c === "/" && next === "/") {
|
|
72
|
+
inLineComment = true;
|
|
73
|
+
i += 2;
|
|
74
|
+
} else if (c === "/" && next === "*") {
|
|
75
|
+
inBlockComment = true;
|
|
76
|
+
i += 2;
|
|
77
|
+
} else {
|
|
78
|
+
if (c === "'" || c === '"' || c === "`") inString = c;
|
|
79
|
+
out += c;
|
|
80
|
+
i++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const listTsFiles = (dir: string, files: string[]): string[] => {
|
|
87
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
88
|
+
const full = join(dir, entry.name);
|
|
89
|
+
if (entry.isDirectory()) listTsFiles(full, files);
|
|
90
|
+
else if (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")) files.push(full);
|
|
91
|
+
}
|
|
92
|
+
return files;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const extractSpecifiers = (text: string): string[] => {
|
|
96
|
+
const specifiers = new Set<string>();
|
|
97
|
+
const cleaned = stripComments(text);
|
|
98
|
+
for (const match of cleaned.matchAll(SPECIFIER_PATTERN)) specifiers.add(match[2]);
|
|
99
|
+
for (const match of cleaned.matchAll(SIDE_EFFECT_PATTERN)) specifiers.add(match[2]);
|
|
100
|
+
return [...specifiers];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Result: the retired plane a module specifier addresses, or null when it addresses
|
|
104
|
+
// neither (a live plane, a bare package, a node: builtin, or an external module).
|
|
105
|
+
const addressedRetiredPlane = (specifier: string, importer: string): RetiredPlane | null => {
|
|
106
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/")) {
|
|
107
|
+
return retiredBySegment(specifier.split("/")[0]);
|
|
108
|
+
}
|
|
109
|
+
const resolved = specifier.startsWith("/") ? specifier : resolve(dirname(importer), specifier);
|
|
110
|
+
return retiredByResolved(resolved);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
it("the retired src and config planes are deleted from the package (the cutover terminal pin)", () => {
|
|
114
|
+
const entries = readdirSync(PKG_ROOT);
|
|
115
|
+
for (const name of RETIRED_PLANES) {
|
|
116
|
+
expect(entries, `deleted plane ${name} must be absent from the package root`).not.toContain(
|
|
117
|
+
name,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("src-next carries zero module specifiers addressing the retired src or config planes", () => {
|
|
123
|
+
const files = listTsFiles(SRC_NEXT, []);
|
|
124
|
+
const violations: string[] = [];
|
|
125
|
+
for (const file of files) {
|
|
126
|
+
for (const specifier of extractSpecifiers(readFileSync(file, "utf8"))) {
|
|
127
|
+
const target = addressedRetiredPlane(specifier, file);
|
|
128
|
+
if (target !== null) violations.push(`${file} imports "${specifier}"`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const message =
|
|
132
|
+
violations.length > 0 ? violations.join("\n") : "src-next has no retired-plane references";
|
|
133
|
+
expect(violations, message).toEqual([]);
|
|
134
|
+
});
|