@oscaner-skills/cdd-engine 1.0.0 → 3.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 +11 -10
- package/README.zh-CN.md +11 -10
- package/package.json +16 -22
- package/src-next/__tests__/bin.test.ts +128 -0
- package/src-next/__tests__/dead-decl.guard.test.ts +39 -0
- package/src-next/__tests__/floor.guard.test.ts +69 -0
- package/src-next/__tests__/issue-body.guard.test.ts +66 -0
- package/src-next/__tests__/phase-suffix.guard.test.ts +72 -0
- package/src-next/__tests__/smoke.integration.test.ts +185 -0
- package/src-next/__tests__/support/strip-comments.ts +99 -0
- package/src-next/__tests__/zero-dep.test.ts +94 -0
- package/src-next/bin.ts +61 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +256 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +165 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +190 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +106 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +240 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +165 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +190 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +100 -0
- package/src-next/contract/__tests__/declare.test.ts +481 -0
- package/src-next/contract/__tests__/doc.test.ts +527 -0
- package/src-next/contract/__tests__/dockey.guard.test.ts +58 -0
- package/src-next/contract/__tests__/edge-conditions.guard.test.ts +81 -0
- package/src-next/contract/__tests__/frontmatter.test.ts +164 -0
- package/src-next/contract/__tests__/judge.test.ts +1111 -0
- package/src-next/contract/__tests__/lint.test.ts +324 -0
- package/src-next/contract/__tests__/project.test.ts +460 -0
- package/src-next/contract/__tests__/structure-pin.test.ts +186 -0
- package/src-next/contract/__tests__/translate.test.ts +96 -0
- package/src-next/contract/declare.ts +1071 -0
- package/src-next/contract/doc.ts +816 -0
- package/src-next/contract/frontmatter.ts +233 -0
- package/src-next/contract/home-extractors.ts +397 -0
- package/src-next/contract/invariants.ts +1413 -0
- package/src-next/contract/judge.ts +151 -0
- package/src-next/contract/lint.ts +239 -0
- package/src-next/contract/project.ts +656 -0
- package/src-next/contract/skill-anatomy.ts +301 -0
- package/src-next/contract/translate.ts +113 -0
- package/src-next/face/__tests__/board-view.test.ts +1151 -0
- package/src-next/face/__tests__/capsule.test.ts +300 -0
- package/src-next/face/__tests__/channel-closure.guard.test.ts +129 -0
- package/src-next/face/__tests__/cli.test.ts +4897 -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__/install-rows.guard.test.ts +58 -0
- package/src-next/face/__tests__/negation.ts +6 -0
- package/src-next/face/__tests__/preview.test.ts +374 -0
- package/src-next/face/__tests__/projection.test.ts +303 -0
- package/src-next/face/__tests__/repo-root.guard.test.ts +120 -0
- package/src-next/face/__tests__/termination.test.ts +650 -0
- package/src-next/face/__tests__/words.guard.test.ts +93 -0
- package/src-next/face/artifacts.ts +248 -0
- package/src-next/face/board-view.ts +652 -0
- package/src-next/face/capsule.ts +163 -0
- package/src-next/face/cli.ts +1028 -0
- package/src-next/face/declare.ts +323 -0
- package/src-next/face/gate.ts +171 -0
- package/src-next/face/graph-view.ts +74 -0
- package/src-next/face/host.ts +302 -0
- package/src-next/face/lifecycle.ts +725 -0
- package/src-next/face/preview.ts +151 -0
- package/src-next/face/projection.ts +285 -0
- package/src-next/face/route-render.ts +185 -0
- package/src-next/face/termination.ts +573 -0
- package/src-next/face/words.ts +314 -0
- package/src-next/infra/__tests__/infra.test.ts +333 -0
- package/src-next/infra/__tests__/root.test.ts +56 -0
- package/src-next/infra/config.ts +42 -0
- package/src-next/infra/doc-roots.ts +29 -0
- package/src-next/infra/git.ts +39 -0
- package/src-next/infra/process.ts +34 -0
- package/src-next/infra/root.ts +73 -0
- package/src-next/infra/runtime.ts +132 -0
- package/src-next/infra/workspace.ts +322 -0
- package/src-next/render/__tests__/render.test.ts +550 -0
- package/src-next/render/__tests__/skeleton.test.ts +684 -0
- package/src-next/render/brief.ts +121 -0
- package/src-next/render/issue-body.ts +162 -0
- package/src-next/render/skeleton.ts +502 -0
- package/src-next/render/templates.ts +645 -0
- package/src-next/session/__tests__/graph.test.ts +277 -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 +745 -0
- package/src-next/session/__tests__/next.test.ts +460 -0
- package/src-next/session/__tests__/preflight.test.ts +545 -0
- package/src-next/session/__tests__/round-naming.test.ts +142 -0
- package/src-next/session/__tests__/run.test.ts +1026 -0
- package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
- package/src-next/session/__tests__/wave.test.ts +476 -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 +1076 -0
- package/src-next/session/next.ts +293 -0
- package/src-next/session/preflight.ts +271 -0
- package/src-next/session/round-naming.ts +84 -0
- package/src-next/session/run.ts +610 -0
- package/src-next/session/state.ts +30 -0
- package/src-next/session/wave.ts +139 -0
- package/templates/report/issue-body.json +17 -65
- 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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/contract/__tests__/translate.test.ts
|
|
2
|
+
// T19 Translator suite — the P7 bidirectional translation layer (design spec §1.2
|
|
3
|
+
// locale face):
|
|
4
|
+
// · canonicalize — the recognition face: every registered Chinese alias span maps
|
|
5
|
+
// to its canonical English form (a full-line alias is the single-token case), an
|
|
6
|
+
// already-canonical / unregistered line passes through unchanged (identity) — the
|
|
7
|
+
// positive + identity + negative cases, the P7 charter rows, and the
|
|
8
|
+
// compound-word boundary;
|
|
9
|
+
// · localize — the rendering face: the canonical token renders at the requested
|
|
10
|
+
// locale (en = identity · zh = the row's alias), an unknown token / locale / a
|
|
11
|
+
// row without the locale's alias is null;
|
|
12
|
+
// · the bidirectional property — canonicalize(localize(token, zh)) recovers the
|
|
13
|
+
// canonical token, over every row of the word table;
|
|
14
|
+
// · the machine-face immunity — the capsule machine words (status · next: ·
|
|
15
|
+
// CDD_BLOCKED:) are NOT locale rows: canonicalize passes them through unchanged
|
|
16
|
+
// and localize cannot render them (the machine surface is English-constant,
|
|
17
|
+
// never localized).
|
|
18
|
+
// The data all rides the word table (Words — the single source); the translator
|
|
19
|
+
// itself holds zero literal word data.
|
|
20
|
+
|
|
21
|
+
import { describe, expect, it } from "vitest";
|
|
22
|
+
import { Words } from "../../face/words.ts";
|
|
23
|
+
import { Translator } from "../translate.ts";
|
|
24
|
+
|
|
25
|
+
const words = new Words();
|
|
26
|
+
const translator = new Translator(words);
|
|
27
|
+
|
|
28
|
+
describe("Translator — the bidirectional translation layer", () => {
|
|
29
|
+
it("canonicalize — a Chinese alias span maps to the canonical English token (the recognition face)", () => {
|
|
30
|
+
expect(translator.canonicalize("## 场景")).toBe("## Context");
|
|
31
|
+
expect(translator.canonicalize("## 问题")).toBe("## Problem");
|
|
32
|
+
expect(translator.canonicalize("## 差距")).toBe("## Gap");
|
|
33
|
+
expect(translator.canonicalize("## 建议方向")).toBe("## Suggested direction");
|
|
34
|
+
expect(translator.canonicalize("## 建议修复")).toBe("## Suggested fix");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("canonicalize — the charter rows: a registered Chinese marker maps to its canonical form", () => {
|
|
38
|
+
expect(translator.canonicalize("M 组")).toBe("M group");
|
|
39
|
+
expect(translator.canonicalize("#### 上游先例背书")).toBe("#### Upstream Endorsements");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("canonicalize — an already-canonical line passes through (identity)", () => {
|
|
43
|
+
expect(translator.canonicalize("## Context")).toBe("## Context");
|
|
44
|
+
expect(translator.canonicalize("## Suggested fix")).toBe("## Suggested fix");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("canonicalize — unregistered text passes through unchanged (no null face)", () => {
|
|
48
|
+
expect(translator.canonicalize("## 未知")).toBe("## 未知");
|
|
49
|
+
expect(translator.canonicalize("bogus")).toBe("bogus");
|
|
50
|
+
expect(translator.canonicalize("")).toBe("");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("canonicalize — the compound boundary: only the registered span is replaced, neighbors untouched", () => {
|
|
54
|
+
// 件 is unregistered — the single-character 组 alias replaces only its own span
|
|
55
|
+
expect(translator.canonicalize("组件")).toBe("group件");
|
|
56
|
+
// trailing unregistered prose (the parenthetical) passes through verbatim
|
|
57
|
+
expect(translator.canonicalize("M 组(skill-ref 映射,M1–M4 全关)")).toBe(
|
|
58
|
+
"M group(skill-ref 映射,M1–M4 全关)",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("localize — the canonical token renders at the requested locale (en identity · zh alias)", () => {
|
|
63
|
+
expect(translator.localize("## Context", "en")).toBe("## Context");
|
|
64
|
+
expect(translator.localize("## Problem", "zh")).toBe("## 问题");
|
|
65
|
+
expect(translator.localize("## Impact", "zh")).toBe("## 影响");
|
|
66
|
+
expect(translator.localize("## Suggested direction", "zh")).toBe("## 建议方向");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("localize — an unknown token / locale is null (the negative face)", () => {
|
|
70
|
+
expect(translator.localize("bogus", "zh")).toBeNull();
|
|
71
|
+
expect(translator.localize("## Context", "fr")).toBeNull();
|
|
72
|
+
expect(translator.localize("", "zh")).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("the round trip — canonicalize(localize(token, zh)) recovers the canonical token over every row", () => {
|
|
76
|
+
for (const row of words.localeRows()) {
|
|
77
|
+
const localized = translator.localize(row.en, "zh");
|
|
78
|
+
expect(localized).not.toBeNull();
|
|
79
|
+
expect(translator.canonicalize(localized!)).toBe(row.en);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("the machine face is not the translation surface — the capsule words carry zero aliases", () => {
|
|
84
|
+
// status / next: / CDD_BLOCKED: / the status vocabulary are the capsule machine
|
|
85
|
+
// channel words — English-constant, never human-readable rendering words. The
|
|
86
|
+
// Translator over the word table holds no alias for them — canonicalize passes
|
|
87
|
+
// them through unchanged, localize cannot render them.
|
|
88
|
+
expect(translator.canonicalize(words.station("next"))).toBe("next:");
|
|
89
|
+
expect(translator.canonicalize(words.station("blocked"))).toBe("CDD_BLOCKED:");
|
|
90
|
+
expect(translator.canonicalize(words.station("warn"))).toBe("CDD_WARN:");
|
|
91
|
+
expect(translator.localize(words.station("next"), "zh")).toBeNull();
|
|
92
|
+
expect(translator.localize("status", "zh")).toBeNull();
|
|
93
|
+
expect(translator.localize(words.statusVocab()[0], "zh")).toBeNull();
|
|
94
|
+
expect(translator.localize(words.statusVocab()[1], "zh")).toBeNull();
|
|
95
|
+
});
|
|
96
|
+
});
|