@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.
Files changed (120) hide show
  1. package/README.md +11 -10
  2. package/README.zh-CN.md +11 -10
  3. package/package.json +16 -22
  4. package/src-next/__tests__/bin.test.ts +128 -0
  5. package/src-next/__tests__/dead-decl.guard.test.ts +39 -0
  6. package/src-next/__tests__/floor.guard.test.ts +69 -0
  7. package/src-next/__tests__/issue-body.guard.test.ts +66 -0
  8. package/src-next/__tests__/phase-suffix.guard.test.ts +72 -0
  9. package/src-next/__tests__/smoke.integration.test.ts +185 -0
  10. package/src-next/__tests__/support/strip-comments.ts +99 -0
  11. package/src-next/__tests__/zero-dep.test.ts +94 -0
  12. package/src-next/bin.ts +61 -0
  13. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +256 -0
  14. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +165 -0
  15. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +190 -0
  16. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +106 -0
  17. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +240 -0
  18. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +165 -0
  19. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +190 -0
  20. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +100 -0
  21. package/src-next/contract/__tests__/declare.test.ts +481 -0
  22. package/src-next/contract/__tests__/doc.test.ts +527 -0
  23. package/src-next/contract/__tests__/dockey.guard.test.ts +58 -0
  24. package/src-next/contract/__tests__/edge-conditions.guard.test.ts +81 -0
  25. package/src-next/contract/__tests__/frontmatter.test.ts +164 -0
  26. package/src-next/contract/__tests__/judge.test.ts +1111 -0
  27. package/src-next/contract/__tests__/lint.test.ts +324 -0
  28. package/src-next/contract/__tests__/project.test.ts +460 -0
  29. package/src-next/contract/__tests__/structure-pin.test.ts +186 -0
  30. package/src-next/contract/__tests__/translate.test.ts +96 -0
  31. package/src-next/contract/declare.ts +1071 -0
  32. package/src-next/contract/doc.ts +816 -0
  33. package/src-next/contract/frontmatter.ts +233 -0
  34. package/src-next/contract/home-extractors.ts +397 -0
  35. package/src-next/contract/invariants.ts +1413 -0
  36. package/src-next/contract/judge.ts +151 -0
  37. package/src-next/contract/lint.ts +239 -0
  38. package/src-next/contract/project.ts +656 -0
  39. package/src-next/contract/skill-anatomy.ts +301 -0
  40. package/src-next/contract/translate.ts +113 -0
  41. package/src-next/face/__tests__/board-view.test.ts +1151 -0
  42. package/src-next/face/__tests__/capsule.test.ts +300 -0
  43. package/src-next/face/__tests__/channel-closure.guard.test.ts +129 -0
  44. package/src-next/face/__tests__/cli.test.ts +4897 -0
  45. package/src-next/face/__tests__/face.test.ts +289 -0
  46. package/src-next/face/__tests__/graph-view.test.ts +61 -0
  47. package/src-next/face/__tests__/host.test.ts +24 -0
  48. package/src-next/face/__tests__/install-rows.guard.test.ts +58 -0
  49. package/src-next/face/__tests__/negation.ts +6 -0
  50. package/src-next/face/__tests__/preview.test.ts +374 -0
  51. package/src-next/face/__tests__/projection.test.ts +303 -0
  52. package/src-next/face/__tests__/repo-root.guard.test.ts +120 -0
  53. package/src-next/face/__tests__/termination.test.ts +650 -0
  54. package/src-next/face/__tests__/words.guard.test.ts +93 -0
  55. package/src-next/face/artifacts.ts +248 -0
  56. package/src-next/face/board-view.ts +652 -0
  57. package/src-next/face/capsule.ts +163 -0
  58. package/src-next/face/cli.ts +1028 -0
  59. package/src-next/face/declare.ts +323 -0
  60. package/src-next/face/gate.ts +171 -0
  61. package/src-next/face/graph-view.ts +74 -0
  62. package/src-next/face/host.ts +302 -0
  63. package/src-next/face/lifecycle.ts +725 -0
  64. package/src-next/face/preview.ts +151 -0
  65. package/src-next/face/projection.ts +285 -0
  66. package/src-next/face/route-render.ts +185 -0
  67. package/src-next/face/termination.ts +573 -0
  68. package/src-next/face/words.ts +314 -0
  69. package/src-next/infra/__tests__/infra.test.ts +333 -0
  70. package/src-next/infra/__tests__/root.test.ts +56 -0
  71. package/src-next/infra/config.ts +42 -0
  72. package/src-next/infra/doc-roots.ts +29 -0
  73. package/src-next/infra/git.ts +39 -0
  74. package/src-next/infra/process.ts +34 -0
  75. package/src-next/infra/root.ts +73 -0
  76. package/src-next/infra/runtime.ts +132 -0
  77. package/src-next/infra/workspace.ts +322 -0
  78. package/src-next/render/__tests__/render.test.ts +550 -0
  79. package/src-next/render/__tests__/skeleton.test.ts +684 -0
  80. package/src-next/render/brief.ts +121 -0
  81. package/src-next/render/issue-body.ts +162 -0
  82. package/src-next/render/skeleton.ts +502 -0
  83. package/src-next/render/templates.ts +645 -0
  84. package/src-next/session/__tests__/graph.test.ts +277 -0
  85. package/src-next/session/__tests__/handoff-plane.guard.test.ts +48 -0
  86. package/src-next/session/__tests__/handoff-schema.test.ts +310 -0
  87. package/src-next/session/__tests__/ledger.test.ts +745 -0
  88. package/src-next/session/__tests__/next.test.ts +460 -0
  89. package/src-next/session/__tests__/preflight.test.ts +545 -0
  90. package/src-next/session/__tests__/round-naming.test.ts +142 -0
  91. package/src-next/session/__tests__/run.test.ts +1026 -0
  92. package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
  93. package/src-next/session/__tests__/wave.test.ts +476 -0
  94. package/src-next/session/faces.ts +110 -0
  95. package/src-next/session/graph.ts +411 -0
  96. package/src-next/session/handoff-schema.ts +373 -0
  97. package/src-next/session/ledger.ts +1076 -0
  98. package/src-next/session/next.ts +293 -0
  99. package/src-next/session/preflight.ts +271 -0
  100. package/src-next/session/round-naming.ts +84 -0
  101. package/src-next/session/run.ts +610 -0
  102. package/src-next/session/state.ts +30 -0
  103. package/src-next/session/wave.ts +139 -0
  104. package/templates/report/issue-body.json +17 -65
  105. package/dist/chunks/branch.mjs +0 -480
  106. package/dist/chunks/docs.mjs +0 -253
  107. package/dist/chunks/task.mjs +0 -913
  108. package/dist/cli.mjs +0 -5457
  109. package/dist/documents/schema/add-phase-protocol.json +0 -126
  110. package/dist/documents/schema/overall.json +0 -361
  111. package/dist/documents/schema/phase-spec.json +0 -145
  112. package/dist/documents/schema/plan.json +0 -191
  113. package/dist/documents/schema/skill-anatomy.json +0 -233
  114. package/dist/resources/harness-registry.json +0 -49
  115. package/dist/shared/cdd-engine.liioziig.mjs +0 -184
  116. package/templates/engine-config.json +0 -302
  117. package/templates/schema/cache-profile-schema.json +0 -23
  118. package/templates/schema/docs-handoff-schema.json +0 -129
  119. package/templates/schema/task-handoff-schema.json +0 -332
  120. 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
+ });