@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,326 @@
1
+ // packages/cdd-engine/src-next/face/host.ts
2
+ // T21 — the harness-contract typed surface: the harness-contract JSON's data-plane
3
+ // home as one typed constant module. The new tree reads zero config files — the
4
+ // host-adaptation contract (host detection · dispatch · refs) lives here and is
5
+ // imported, never parsed:
6
+ //
7
+ // · HOSTS — the per-harness rows (cli / invoke / promptForm / output / ship /
8
+ // detect / install / cache). The host-marker closure is single-sourced HERE: the
9
+ // detect rows are the only copy of the marker env keys (the channel audit derives
10
+ // the env whitelist from them — never a second declaration). The promptForm
11
+ // column (§3.5) is the prompt-position semantics data contract — how the
12
+ // skill-ref enters the child prompt (ref-prefixed | plain).
13
+ // · DISPATCH — the dispatch table: the skill-ref each dispatch face resolves
14
+ // to. M1 supersede (P5): the implement slot names the upstream
15
+ // `mattpocock-skills:implement` skill; the fix face carries no skill ref (its
16
+ // fix discipline lives as the FIX_SHELL typed instructions).
17
+ // · REFS — the per-harness slash reference forms (claude/cursor use the
18
+ // `/namespace:skill` form; pi the flat `/skill:<bare>` form — the pi flat
19
+ // namespace has no namespace-qualification syntax).
20
+ // · HostDetect — the module-level host judgment (the detection's single home):
21
+ // the dispatch face's detectHost delegates here; the work face's Capsule wiring
22
+ // reads the same judgment over process.env.
23
+ //
24
+ // P5 lands here: the forbidden parallel-sub-agents prose is deleted from the review
25
+ // dispatch rows (the task/branch rows carry their ref only) and the review
26
+ // criteria — the URC spec/plan axes + the writing-plans self-check + the
27
+ // verification-evidence duty — land in render/templates.ts (the axes guide's
28
+ // typed home). The `mattpocock-skills:implement` ref key is registered here.
29
+ //
30
+ // Module-level exports are types / the declared constant data — zero behavior-
31
+ // carrying bare functions (the plan's zero-bare-function discipline).
32
+
33
+ /** The harness ids the contract adapts. */
34
+ export type HostId = "claude" | "cursor" | "pi";
35
+
36
+ /** One host-detect row — the marker env key (+ the AI_AGENT match semantics). */
37
+ export interface HostDetectSpec {
38
+ /** The marker env key the host detection reads. */
39
+ env: string;
40
+ /** pi-only: the AI_AGENT exact value the detection matches (`=== "value"`). */
41
+ value?: string;
42
+ /** claude-only: the AI_AGENT prefix the detection matches via startsWith. */
43
+ aiAgentPrefix?: string;
44
+ }
45
+
46
+ /** One host-cache row — the prompt-cache mechanism facts. */
47
+ export interface HostCacheSpec {
48
+ /** The cache mechanism (explicit hints / auto-prefix). */
49
+ mechanism: string;
50
+ /** The minimum token threshold; the `pending` literal is the not-yet-known marker. */
51
+ minTokens: number | "pending";
52
+ /** Explicit-hint face: the read/write budget multipliers + TTL (claude only). */
53
+ readMultiplier?: number;
54
+ /** Explicit-hint face: the write-budget multiplier (claude only). */
55
+ writeMultiplier?: number;
56
+ /** Explicit-hint face: the cache TTL in minutes (claude only). */
57
+ ttlMinutes?: number;
58
+ /** Whether the cache is observable to the engine. */
59
+ observable: boolean;
60
+ }
61
+
62
+ /** The prompt-position semantics of a harness — HOW the skill-ref enters the child
63
+ * prompt (the §3.5 data contract, resolved by #childPrompt — the from-code-assumed
64
+ * prompt assembly becomes a per-host row). `ref-prefixed`: the slash ref prefixes
65
+ * the single prompt positional; `plain`: the child receives the prompt verbatim
66
+ * (no ref to prefix — the URC-prose rows). */
67
+ export type PromptForm = "ref-prefixed" | "plain";
68
+
69
+ /** One harness's capability facts (T25 — the capabilities per-harness declaration):
70
+ * the tested dispatch faces, one data column per row, zero prose. */
71
+ export interface HostCapabilities {
72
+ /** The parallel sub-agent dispatch face — `true` the measured face (claude),
73
+ * `"pending"` the not-yet-exercised marker (cursor/pi — the per-tested stance,
74
+ * the install `"pending"` pattern). */
75
+ parallel: boolean | "pending";
76
+ }
77
+
78
+ /** One per-harness host row — the adaptation facts the engine + guards consume. */
79
+ export interface HostRow {
80
+ /** The host harness CLI binary. */
81
+ cli: string;
82
+ /** The invoke flags prepended to the dispatch prompt. */
83
+ invoke: string;
84
+ /** The prompt-position semantics — how the skill-ref enters the child prompt. */
85
+ promptForm: PromptForm;
86
+ /** The harness output mode. */
87
+ output: string;
88
+ /** The ship status of the harness face. */
89
+ ship: string;
90
+ /** The detect row — the marker env key(+ semantics). */
91
+ detect: HostDetectSpec;
92
+ /** The per-package install banners (kairos self-install + upstream plugins);
93
+ * `"pending"` is the literal not-yet-known command. */
94
+ install: Readonly<Record<string, readonly string[] | "pending">>;
95
+ /** The prompt-cache facts. */
96
+ cache: HostCacheSpec;
97
+ /** The capability facts — the tested dispatch-face columns (T25). */
98
+ capabilities: HostCapabilities;
99
+ }
100
+
101
+ /** A review dispatch row — an object-shaped slot naming its ref key (the note face
102
+ * is deleted with the P5 forbidden prose; the review criteria live in the axes
103
+ * guide, render/templates.ts). */
104
+ export interface ReviewDispatchRow {
105
+ /** The ref key the review phase dispatches to. */
106
+ ref: string;
107
+ }
108
+
109
+ /**
110
+ * The dispatch table — the phase/type → skill-ref (or URC prose) resolution.
111
+ * v1.8 closeout: the spec/plan review criteria migrated to the template plane's
112
+ * REVIEWS (render/templates.ts) — the dispatch review rows are the task/branch ref
113
+ * keys only; a spec/plan review resolves no skill ref (the URC prose rides the
114
+ * review prompt's criteria body).
115
+ */
116
+ export interface DispatchTable {
117
+ /** The implement phase's ref key (M1 supersede: mattpocock-skills:implement). */
118
+ implement: string;
119
+ /** The review phase rows — the task/branch ref keys (the spec/plan rows carry no
120
+ * skill ref — the review criteria live in the template plane). */
121
+ review: Readonly<Record<"wave" | "branch", ReviewDispatchRow>>;
122
+ }
123
+
124
+ /** The per-harness slash reference forms of one ref key. */
125
+ export type HostReferenceForm = Readonly<Record<HostId, string>>;
126
+
127
+ /** The full reference table — every `<pkg>:<skill>` cross-skill reference key. */
128
+ export type HostReferenceTable = Readonly<Record<string, HostReferenceForm>>;
129
+
130
+ /** The extended typed harness contract — hosts + dispatch + refs. */
131
+ export interface HostContract {
132
+ hosts: Readonly<Record<HostId, HostRow>>;
133
+ dispatch: DispatchTable;
134
+ refs: HostReferenceTable;
135
+ }
136
+
137
+ /** The per-harness install banners — the kairos self-install + the upstream plugin
138
+ * install commands (the README upstream dependency table renders from these rows). */
139
+ export const INSTALL_ROWS = {
140
+ kairos: [
141
+ "claude plugin marketplace add oscaner/skills",
142
+ "claude plugin install kairos@oscaner-skills",
143
+ ],
144
+ superpowers: [
145
+ "claude plugin marketplace add obra/superpowers-marketplace",
146
+ "claude plugin install superpowers@superpowers-marketplace",
147
+ ],
148
+ "mattpocock-skills": [
149
+ "claude plugin marketplace add mattpocock/skills",
150
+ "claude plugin install mattpocock-skills@mattpocock",
151
+ ],
152
+ impeccable: [
153
+ "claude plugin marketplace add pbakaus/impeccable",
154
+ "claude plugin install impeccable@impeccable",
155
+ ],
156
+ } as const;
157
+
158
+ /** The per-harness host rows — claude / cursor / pi adaptation facts. */
159
+ export const HOSTS = {
160
+ claude: {
161
+ promptForm: "ref-prefixed",
162
+ cli: "claude",
163
+ invoke: "-p --output-format text --dangerously-skip-permissions",
164
+ output: "text",
165
+ ship: "full",
166
+ detect: { env: "CLAUDE_CODE_SESSION_ID", aiAgentPrefix: "claude-code" },
167
+ install: INSTALL_ROWS,
168
+ cache: {
169
+ mechanism: "explicit",
170
+ minTokens: 512,
171
+ readMultiplier: 0.1,
172
+ writeMultiplier: 1.25,
173
+ ttlMinutes: 5,
174
+ observable: true,
175
+ },
176
+ capabilities: { parallel: true },
177
+ },
178
+ cursor: {
179
+ promptForm: "ref-prefixed",
180
+ cli: "cursor-agent",
181
+ invoke: "--print --output-format text --force",
182
+ output: "text",
183
+ ship: "full",
184
+ detect: { env: "CURSOR_TRACE_ID" },
185
+ install: {
186
+ kairos: "pending",
187
+ superpowers: "pending",
188
+ "mattpocock-skills": "pending",
189
+ impeccable: "pending",
190
+ },
191
+ cache: { mechanism: "auto-prefix", minTokens: "pending", observable: false },
192
+ capabilities: { parallel: "pending" },
193
+ },
194
+ pi: {
195
+ promptForm: "ref-prefixed",
196
+ cli: "pi",
197
+ invoke: "-p --mode text",
198
+ output: "text",
199
+ ship: "full",
200
+ detect: { env: "AI_AGENT", value: "pi" },
201
+ install: {
202
+ kairos: ["pi install npm:@oscaner-skills/kairos"],
203
+ superpowers: ["pi install git:github.com/obra/superpowers"],
204
+ "mattpocock-skills": ["pi install git:github.com/mattpocock/skills"],
205
+ impeccable: ["npx impeccable install --providers=pi --scope=global -y"],
206
+ },
207
+ cache: { mechanism: "auto-prefix", minTokens: "pending", observable: false },
208
+ capabilities: { parallel: "pending" },
209
+ },
210
+ } as const satisfies Readonly<Record<HostId, HostRow>>;
211
+
212
+ /** The dispatch table — the phase/type → skill-ref resolution. The implement slot
213
+ * is the M1 supersede (P5): it names the upstream `mattpocock-skills:implement`
214
+ * skill. The fix face carries no skill ref (its fix discipline rides the FIX_SHELL
215
+ * typed instructions). The REVIEW rows are the task/branch ref keys only (the
216
+ * spec/plan rows' URC review criteria migrated to the template plane's REVIEWS at
217
+ * the v1.8 closeout — their single typed home; the parallel-sub-agents note prose
218
+ * is deleted — P5 forbidden text). */
219
+ export const DISPATCH = {
220
+ implement: "mattpocock-skills:implement",
221
+ review: {
222
+ wave: { ref: "mattpocock-skills:code-review" },
223
+ branch: { ref: "mattpocock-skills:code-review" },
224
+ },
225
+ } as const satisfies DispatchTable;
226
+
227
+ /** The reference table — every `<pkg>:<skill>` cross-skill reference key and its
228
+ * per-harness slash form: claude/cursor use `/namespace:skill`, pi the flat
229
+ * `/skill:<bare>` form. The `mattpocock-skills:implement` key is registered here
230
+ * (P5 — the implement dispatch's first-class refs-domain entry). */
231
+ export const REFS = {
232
+ "superpowers:brainstorming": {
233
+ claude: "/superpowers:brainstorming",
234
+ cursor: "/superpowers:brainstorming",
235
+ pi: "/skill:brainstorming",
236
+ },
237
+ "superpowers:writing-plans": {
238
+ claude: "/superpowers:writing-plans",
239
+ cursor: "/superpowers:writing-plans",
240
+ pi: "/skill:writing-plans",
241
+ },
242
+ "superpowers:finishing-a-development-branch": {
243
+ claude: "/superpowers:finishing-a-development-branch",
244
+ cursor: "/superpowers:finishing-a-development-branch",
245
+ pi: "/skill:finishing-a-development-branch",
246
+ },
247
+ "mattpocock-skills:implement": {
248
+ claude: "/mattpocock-skills:implement",
249
+ cursor: "/mattpocock-skills:implement",
250
+ pi: "/skill:implement",
251
+ },
252
+ "mattpocock-skills:code-review": {
253
+ claude: "/mattpocock-skills:code-review",
254
+ cursor: "/mattpocock-skills:code-review",
255
+ pi: "/skill:code-review",
256
+ },
257
+ "mattpocock-skills:grilling": {
258
+ claude: "/mattpocock-skills:grilling",
259
+ cursor: "/mattpocock-skills:grilling",
260
+ pi: "/skill:grilling",
261
+ },
262
+ "kairos:cdd-design": {
263
+ claude: "/kairos:cdd-design",
264
+ cursor: "/kairos:cdd-design",
265
+ pi: "/skill:cdd-design",
266
+ },
267
+ "kairos:cdd-spec-writer": {
268
+ claude: "/kairos:cdd-spec-writer",
269
+ cursor: "/kairos:cdd-spec-writer",
270
+ pi: "/skill:cdd-spec-writer",
271
+ },
272
+ "kairos:cdd-plan": {
273
+ claude: "/kairos:cdd-plan",
274
+ cursor: "/kairos:cdd-plan",
275
+ pi: "/skill:cdd-plan",
276
+ },
277
+ "kairos:cdd-dev": { claude: "/kairos:cdd-dev", cursor: "/kairos:cdd-dev", pi: "/skill:cdd-dev" },
278
+ "kairos:cdd-close": {
279
+ claude: "/kairos:cdd-close",
280
+ cursor: "/kairos:cdd-close",
281
+ pi: "/skill:cdd-close",
282
+ },
283
+ "kairos:cdd-report": {
284
+ claude: "/kairos:cdd-report",
285
+ cursor: "/kairos:cdd-report",
286
+ pi: "/skill:cdd-report",
287
+ },
288
+ } as const satisfies HostReferenceTable;
289
+
290
+ /** The typed harness contract — one constant: hosts + dispatch + refs (the single
291
+ * harness-adaptation truth; zero `_doc`/`$schema` prose). */
292
+ export const HOST_CONTRACT = {
293
+ hosts: HOSTS,
294
+ dispatch: DISPATCH,
295
+ refs: REFS,
296
+ } as const satisfies HostContract;
297
+
298
+ /** HostDetect — the module-level host judgment (the detection's single home). The
299
+ * input is the inline structural env view — no cross-import (the host plane
300
+ * must stay import-clean toward the dispatch face). */
301
+ // biome-ignore lint/complexity/noStaticOnlyClass: the module-level host-detect surface — the zero-bare-function discipline admits no standalone predicate functions.
302
+ export class HostDetect {
303
+ /** detect(env) — the first host detect row that matches, in the pinned order
304
+ * `claude` → `cursor` → `pi` (specific markers first, the generic AI_AGENT
305
+ * last). One row detects by its primary marker (a session env, presence/enum —
306
+ * a UUID CLAUDE_CODE_SESSION_ID is claude by presence) or by the AI_AGENT
307
+ * prefix (AI_AGENT=claude-code-…); no match returns `""`. */
308
+ static detect(env: Record<string, string | undefined>): HostId | "" {
309
+ for (const id of ["claude", "cursor", "pi"] as const) {
310
+ const detect: HostDetectSpec = HOSTS[id].detect;
311
+ if (detect.env !== undefined && detect.env !== "") {
312
+ const marker = env[detect.env];
313
+ if (marker !== undefined && marker.length > 0) {
314
+ if (detect.value !== undefined && marker !== detect.value) continue;
315
+ return id;
316
+ }
317
+ }
318
+ if (detect.aiAgentPrefix !== undefined && detect.aiAgentPrefix.length > 0) {
319
+ const agent = env.AI_AGENT;
320
+ if (agent !== undefined && agent.length > 0 && agent.startsWith(detect.aiAgentPrefix))
321
+ return id;
322
+ }
323
+ }
324
+ return "";
325
+ }
326
+ }