@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,163 @@
1
+ // packages/cdd-engine/src-next/face/capsule.ts
2
+ // T10 — the single capsule face (design spec §3.2: the `status · blocker · handoff
3
+ // · next:` word-face steady state). Capsule#emit renders the ALL-OP single stdout
4
+ // face — the capsule the orchestrator greps / routes on without opening the handoff:
5
+ //
6
+ // status: <status> · blocker: <blocker> · handoff: <handoff>
7
+ // next: <suggestion> (optional — the C5 route / a caller-rendered text)
8
+ //
9
+ // The byte face is v1-pinned: the key words (status · blocker · handoff) are
10
+ // pin-enforced by the CapsuleKey type and the emit signature — a data-only change
11
+ // cannot reshape them. What rides the injected Words table (the single word-table
12
+ // instance) is the `·` separator, the `next:` station anchor and the route/status
13
+ // vocabulary — a second table is excluded by construction. The `next:` value is
14
+ // either a caller-rendered string or the C5 Route rendered through the route-word
15
+ // table as a COMPLETE EXECUTABLE command (P4.1 T4 — the v1.39 semantic-literal
16
+ // reversal): `implement --plan <path> --tasks 17` · `review --type spec --spec
17
+ // <path>` · `fix --type spec --spec <path> --reviews <handoff> (read file back to
18
+ // confirm)` · `done` (the bare terminal word) · the soft-cap message verbatim.
19
+ // The argv is composed from the frame facts (the RouteTarget's type + id + plan)
20
+ // through the argv-channel flag spellings (the same channel the CLI parse reads —
21
+ // the render source is the declared channel, never a second hard-coded format
22
+ // string); the type flag renders ONLY where the verb's type discriminates
23
+ // (review/fix multi-type — implement is the single-type wave verb, so its literal
24
+ // never carries `--type` — the declaration's `parsed.args.type ?? "wave"` default
25
+ // semantics unchanged). The route-borne prose — the readback suffix · the soft-cap
26
+ // message — rides declared constants from session/next.ts, rendered by reference,
27
+ // never restated.
28
+ //
29
+ // D40 — the render delegates to the shared `RouteRenderer` (the ONE route →
30
+ // `next:` literal face, also consumed by the board); the capsule adds only the
31
+ // `done` face's doc-class discrimination (a spec doc's declared class decides the
32
+ // pipeline entry — or the BLOCKED face when the declaration is absent, spec §12).
33
+ //
34
+ // The class satisfies the session/run.ts CapsuleFace seam (T8's interaction point) —
35
+ // the capsule plugs into the lifecycle's attachCapsule contact, byte-identically.
36
+ // Module-level exports are the class — zero behavior-carrying bare functions.
37
+
38
+ import { type RepoPath, RepoRoot } from "../infra/root.ts";
39
+ import type { RouteTarget } from "../session/faces.ts";
40
+ import { NextStepRouter, type PipelineKey, type Route } from "../session/next.ts";
41
+ import { BoardView } from "./board-view.ts";
42
+ import { type RouteChannelRow, RouteRenderer } from "./route-render.ts";
43
+ import type { CapsuleKey, Words } from "./words.ts";
44
+
45
+ /** The argv-channel flag row the capsule's render reads — re-exported from the
46
+ * shared renderer's row type (the capsule renders through the ONE RouteRenderer). */
47
+ export type CapsuleChannelRow = RouteChannelRow;
48
+
49
+ /**
50
+ * Capsule — the single capsule output face. emit(status, blocker, handoff, next)
51
+ * renders one round's facts into the byte-pinned `status · blocker · handoff` line
52
+ * plus the optional `next:` line. The key words are the CapsuleKey literals the
53
+ * kind loop renders (pin-enforced by the emit signature); the separator, station
54
+ * and route/status words ride the injected Words instance. The complete executable
55
+ * `next:` literal composes its full argv from the route + the additive optional
56
+ * RouteTarget (the frame's own facts) through the argv-channel flag spellings
57
+ * (P4.1 T4; same channel source parse reads — the 4-param signature stays
58
+ * byte-pinned, the target is an optional 5th, the channel an optional 2nd).
59
+ */
60
+ export class Capsule {
61
+ /** The single word table — the capsule's whole vocabulary source. */
62
+ readonly #words: Words;
63
+ /** The ONE route → `next:` literal renderer (D40 — shared with the board). */
64
+ readonly #route: RouteRenderer;
65
+ /** The repo-basis value object the doc-target ids + the `handoff:` cell resolve
66
+ * through (T1 `RepoRoot` · D47 — the ONE conversion exit; `null` keeps a relative
67
+ * id relative · the hermetic-test default). */
68
+ readonly #root: RepoRoot | null;
69
+
70
+ constructor(
71
+ words: Words,
72
+ channels: Readonly<Record<string, CapsuleChannelRow>> = {},
73
+ host = "",
74
+ root: RepoRoot | null = null,
75
+ ) {
76
+ this.#words = words;
77
+ this.#root = root;
78
+ this.#route = new RouteRenderer(words, channels, host, root);
79
+ }
80
+
81
+ /** emit(status, blocker, handoff, next, target) → the capsule stdout lines: the
82
+ * pinned `status · blocker · handoff` capsule line, then the optional `next:`
83
+ * line (a caller-rendered text, a C5 Route rendered as the complete executable
84
+ * command, or null/absent → no line). The additive optional RouteTarget supplies
85
+ * the frame's own type + id + plan for the executable literal (P4.1 T4); without
86
+ * it the route renders its bare classifier fallbacks (the 4-param signature stays
87
+ * byte-pinned). */
88
+ emit(
89
+ status: string,
90
+ blocker: string,
91
+ handoff: string,
92
+ next?: Route | string | null,
93
+ target?: RouteTarget | null,
94
+ ): string[] {
95
+ const words = this.#words;
96
+ // The `handoff:` cell is a path value — normalized to the repoRoot-relative
97
+ // shape through the ONE value object (D47 · the ONE basis; `handoffPath` sources
98
+ // it absolute).
99
+ const cells: Record<CapsuleKey, string> = {
100
+ status,
101
+ blocker,
102
+ handoff: this.#rel(handoff),
103
+ };
104
+ const capsuleLine = words
105
+ .capsuleKeys()
106
+ .map((kind) => `${kind}: ${cells[kind]}`)
107
+ .join(words.capsuleSeparator());
108
+ const lines = [capsuleLine];
109
+ if (next !== undefined && next !== null) {
110
+ const text = typeof next === "string" ? next : this.#routeText(next, target);
111
+ lines.push(`${words.station("next")} ${text}`);
112
+ }
113
+ return lines;
114
+ }
115
+
116
+ /** The route → `next:` text render — the shared RouteRenderer (D40) unless the
117
+ * `done` face's doc-class discrimination fires (a spec doc's declared class decides
118
+ * the pipeline entry — or the BLOCKED face when the declaration is absent, spec
119
+ * §12 · D34). The capsule resolves the doc-class, then hands the resulting Route
120
+ * (a `handoff` carrying the entry, or the bare `done`) to the same renderer. */
121
+ #routeText(route: Route, target?: RouteTarget | null): string {
122
+ if (route.kind === "done" && target != null) {
123
+ const verdict = this.#docClassOf(target);
124
+ if (verdict === "blocked") {
125
+ return `${this.#words.station("blocked")} ${this.#words.routeWord("docType")}`;
126
+ }
127
+ // The declared doc-class (or a bare terminal) picks the pipeline entry — the
128
+ // same resolver + renderer the board consumes.
129
+ const key = verdict === "terminal" ? null : verdict;
130
+ return this.#route.render(NextStepRouter.resolve({ kind: "done" }, key), target);
131
+ }
132
+ return this.#route.render(route, target);
133
+ }
134
+
135
+ /** The target → doc-class verdict of the unified next face — the doc-class
136
+ * discrimination face (D33): the spec doc's class reads its DECLARED type (the
137
+ * front-matter `doc-type:` key, spec §12 · D34 — BoardView.readDocType,
138
+ * the one declaration reading face), never the filename suffix; the task-face
139
+ * targets key by type. `blocked` — the key is missing (the caller
140
+ * renders the BLOCKED face); `terminal` — no pipeline seam carries the declared
141
+ * class (`single-spec`, the table's five keys exclude it — the bare word). */
142
+ #docClassOf(target: RouteTarget): "blocked" | "terminal" | PipelineKey {
143
+ if (target.type === "spec") {
144
+ // The read face takes the value object + the repoRoot-relative id (T4 §2.2);
145
+ // a `null` root (the hermetic default) keeps the value as its own basis. The
146
+ // `#rel` branded return needs no cast here (F3).
147
+ const declared = BoardView.readDocType(this.#root ?? new RepoRoot(""), this.#rel(target.id));
148
+ return declared === null ? "blocked" : declared === "single-spec" ? "terminal" : declared;
149
+ }
150
+ if (target.type === "plan") return "plan";
151
+ if (target.type === "wave") return "wave";
152
+ return "branch";
153
+ }
154
+
155
+ /** One path value normalized to the branded repoRoot-relative `RepoPath` through
156
+ * the ONE value object (D47); a `null` root (the hermetic default) passes the
157
+ * value through as its own basis. The branded return type carries the §2.2 brand
158
+ * to the read face (`BoardView.readDocType`) with NO call-site cast (branch-
159
+ * review-1 F3). */
160
+ #rel(value: string): RepoPath {
161
+ return this.#root === null ? (value as RepoPath) : this.#root.relativize(value);
162
+ }
163
+ }