@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.
Files changed (99) hide show
  1. package/README.md +9 -8
  2. package/README.zh-CN.md +9 -8
  3. package/package.json +15 -22
  4. package/src-next/__tests__/bin.test.ts +128 -0
  5. package/src-next/__tests__/smoke.integration.test.ts +202 -0
  6. package/src-next/__tests__/zero-dep.test.ts +134 -0
  7. package/src-next/bin.ts +61 -0
  8. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +238 -0
  9. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +153 -0
  10. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +173 -0
  11. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +89 -0
  12. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +225 -0
  13. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +155 -0
  14. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +175 -0
  15. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +85 -0
  16. package/src-next/contract/__tests__/declare.test.ts +242 -0
  17. package/src-next/contract/__tests__/doc.test.ts +358 -0
  18. package/src-next/contract/__tests__/judge.test.ts +873 -0
  19. package/src-next/contract/__tests__/lint.test.ts +314 -0
  20. package/src-next/contract/__tests__/project.test.ts +419 -0
  21. package/src-next/contract/__tests__/translate.test.ts +96 -0
  22. package/src-next/contract/declare.ts +983 -0
  23. package/src-next/contract/doc.ts +753 -0
  24. package/src-next/contract/invariants.ts +1268 -0
  25. package/src-next/contract/judge.ts +142 -0
  26. package/src-next/contract/lint.ts +275 -0
  27. package/src-next/contract/project.ts +596 -0
  28. package/src-next/contract/skill-anatomy.ts +273 -0
  29. package/src-next/contract/translate.ts +113 -0
  30. package/src-next/face/__tests__/board-view.test.ts +948 -0
  31. package/src-next/face/__tests__/capsule.test.ts +276 -0
  32. package/src-next/face/__tests__/channel-closure.guard.test.ts +102 -0
  33. package/src-next/face/__tests__/cli.test.ts +4643 -0
  34. package/src-next/face/__tests__/face.test.ts +289 -0
  35. package/src-next/face/__tests__/graph-view.test.ts +61 -0
  36. package/src-next/face/__tests__/host.test.ts +24 -0
  37. package/src-next/face/__tests__/negation.ts +6 -0
  38. package/src-next/face/__tests__/projection.test.ts +301 -0
  39. package/src-next/face/__tests__/sync-runner.test.ts +70 -0
  40. package/src-next/face/__tests__/words.guard.test.ts +93 -0
  41. package/src-next/face/artifacts.ts +195 -0
  42. package/src-next/face/board-view.ts +662 -0
  43. package/src-next/face/capsule.ts +149 -0
  44. package/src-next/face/cli.ts +819 -0
  45. package/src-next/face/declare.ts +326 -0
  46. package/src-next/face/gate.ts +170 -0
  47. package/src-next/face/graph-view.ts +74 -0
  48. package/src-next/face/host.ts +326 -0
  49. package/src-next/face/lifecycle.ts +700 -0
  50. package/src-next/face/projection.ts +282 -0
  51. package/src-next/face/route-render.ts +160 -0
  52. package/src-next/face/words.ts +296 -0
  53. package/src-next/infra/__tests__/infra.test.ts +287 -0
  54. package/src-next/infra/config.ts +42 -0
  55. package/src-next/infra/git.ts +39 -0
  56. package/src-next/infra/process.ts +34 -0
  57. package/src-next/infra/runtime.ts +185 -0
  58. package/src-next/infra/workspace.ts +232 -0
  59. package/src-next/render/__tests__/render.test.ts +499 -0
  60. package/src-next/render/__tests__/skeleton.test.ts +466 -0
  61. package/src-next/render/brief.ts +121 -0
  62. package/src-next/render/issue-body.ts +159 -0
  63. package/src-next/render/skeleton.ts +437 -0
  64. package/src-next/render/templates.ts +650 -0
  65. package/src-next/session/__tests__/graph.test.ts +270 -0
  66. package/src-next/session/__tests__/handoff-plane.guard.test.ts +48 -0
  67. package/src-next/session/__tests__/handoff-schema.test.ts +310 -0
  68. package/src-next/session/__tests__/ledger.test.ts +744 -0
  69. package/src-next/session/__tests__/next.test.ts +368 -0
  70. package/src-next/session/__tests__/preflight.test.ts +491 -0
  71. package/src-next/session/__tests__/run.test.ts +1014 -0
  72. package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
  73. package/src-next/session/__tests__/wave.test.ts +469 -0
  74. package/src-next/session/faces.ts +110 -0
  75. package/src-next/session/graph.ts +411 -0
  76. package/src-next/session/handoff-schema.ts +373 -0
  77. package/src-next/session/ledger.ts +1004 -0
  78. package/src-next/session/next.ts +192 -0
  79. package/src-next/session/preflight.ts +240 -0
  80. package/src-next/session/run.ts +606 -0
  81. package/src-next/session/state.ts +30 -0
  82. package/src-next/session/wave.ts +139 -0
  83. package/templates/report/issue-body.json +18 -20
  84. package/dist/chunks/branch.mjs +0 -480
  85. package/dist/chunks/docs.mjs +0 -253
  86. package/dist/chunks/task.mjs +0 -913
  87. package/dist/cli.mjs +0 -5457
  88. package/dist/documents/schema/add-phase-protocol.json +0 -126
  89. package/dist/documents/schema/overall.json +0 -361
  90. package/dist/documents/schema/phase-spec.json +0 -145
  91. package/dist/documents/schema/plan.json +0 -191
  92. package/dist/documents/schema/skill-anatomy.json +0 -233
  93. package/dist/resources/harness-registry.json +0 -49
  94. package/dist/shared/cdd-engine.liioziig.mjs +0 -184
  95. package/templates/engine-config.json +0 -302
  96. package/templates/schema/cache-profile-schema.json +0 -23
  97. package/templates/schema/docs-handoff-schema.json +0 -129
  98. package/templates/schema/task-handoff-schema.json +0 -332
  99. package/templates/template-contract.json +0 -231
@@ -0,0 +1,149 @@
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> --findings <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 path from "node:path";
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 root the doc-target ids resolve against (the declaration read's
66
+ * path base; `""` keeps a relative id relative — the hermetic-test default). */
67
+ readonly #repoRoot: string;
68
+
69
+ constructor(
70
+ words: Words,
71
+ channels: Readonly<Record<string, CapsuleChannelRow>> = {},
72
+ host = "",
73
+ repoRoot = "",
74
+ ) {
75
+ this.#words = words;
76
+ this.#repoRoot = repoRoot;
77
+ this.#route = new RouteRenderer(words, channels, host);
78
+ }
79
+
80
+ /** emit(status, blocker, handoff, next, target) → the capsule stdout lines: the
81
+ * pinned `status · blocker · handoff` capsule line, then the optional `next:`
82
+ * line (a caller-rendered text, a C5 Route rendered as the complete executable
83
+ * command, or null/absent → no line). The additive optional RouteTarget supplies
84
+ * the frame's own type + id + plan for the executable literal (P4.1 T4); without
85
+ * it the route renders its bare classifier fallbacks (the 4-param signature stays
86
+ * byte-pinned). */
87
+ emit(
88
+ status: string,
89
+ blocker: string,
90
+ handoff: string,
91
+ next?: Route | string | null,
92
+ target?: RouteTarget | null,
93
+ ): string[] {
94
+ const words = this.#words;
95
+ const cells: Record<CapsuleKey, string> = { status, blocker, handoff };
96
+ const capsuleLine = words
97
+ .capsuleKeys()
98
+ .map((kind) => `${kind}: ${cells[kind]}`)
99
+ .join(words.capsuleSeparator());
100
+ const lines = [capsuleLine];
101
+ if (next !== undefined && next !== null) {
102
+ const text = typeof next === "string" ? next : this.#routeText(next, target);
103
+ lines.push(`${words.station("next")} ${text}`);
104
+ }
105
+ return lines;
106
+ }
107
+
108
+ /** The route → `next:` text render — the shared RouteRenderer (D40) unless the
109
+ * `done` face's doc-class discrimination fires (a spec doc's declared class decides
110
+ * the pipeline entry — or the BLOCKED face when the declaration is absent, spec
111
+ * §12 · D34). The capsule resolves the doc-class, then hands the resulting Route
112
+ * (a `handoff` carrying the entry, or the bare `done`) to the same renderer. */
113
+ #routeText(route: Route, target?: RouteTarget | null): string {
114
+ if (route.kind === "done" && target != null) {
115
+ const verdict = this.#docClassOf(target);
116
+ if (verdict === "blocked") {
117
+ return `${this.#words.station("blocked")} ${this.#words.routeWord("docType")}`;
118
+ }
119
+ // The declared doc-class (or a bare terminal) picks the pipeline entry — the
120
+ // same resolver + renderer the board consumes.
121
+ const key = verdict === "terminal" ? null : verdict;
122
+ return this.#route.render(NextStepRouter.resolve({ kind: "done" }, key), target);
123
+ }
124
+ return this.#route.render(route, target);
125
+ }
126
+
127
+ /** The target → doc-class verdict of the unified next face — the doc-class
128
+ * discrimination face (D33): the spec doc's class reads its DECLARED type (the
129
+ * `- **Doc type**:` header declaration, spec §12 · D34 — BoardView.readDocType,
130
+ * the one declaration reading face), never the filename suffix; the task-face
131
+ * targets key by type. `blocked` — the declaration is missing (the caller
132
+ * renders the BLOCKED face); `terminal` — no pipeline seam carries the declared
133
+ * class (`single-spec`, the table's five keys exclude it — the bare word). */
134
+ #docClassOf(target: RouteTarget): "blocked" | "terminal" | PipelineKey {
135
+ if (target.type === "spec") {
136
+ const declared = BoardView.readDocType(this.#docPathOf(target.id));
137
+ return declared === null ? "blocked" : declared === "single-spec" ? "terminal" : declared;
138
+ }
139
+ if (target.type === "plan") return "plan";
140
+ if (target.type === "wave") return "wave";
141
+ return "branch";
142
+ }
143
+
144
+ /** The doc-target id's file path — the id resolved against the capsule's repo
145
+ * root (an absolute id passes through; a relative one joins the root). */
146
+ #docPathOf(id: string): string {
147
+ return path.isAbsolute(id) ? id : this.#repoRoot === "" ? id : path.join(this.#repoRoot, id);
148
+ }
149
+ }