@oscaner-skills/cdd-engine 3.0.0 → 3.0.1
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/{src-next/bin.ts → dist/bin.js} +18 -21
- package/dist/contract/declare.js +998 -0
- package/dist/contract/doc.js +565 -0
- package/dist/contract/frontmatter.js +209 -0
- package/dist/contract/home-extractors.js +379 -0
- package/dist/contract/invariants.js +1030 -0
- package/dist/contract/judge.js +109 -0
- package/dist/contract/lint.js +206 -0
- package/dist/contract/project.js +371 -0
- package/dist/contract/skill-anatomy.js +156 -0
- package/dist/contract/translate.js +85 -0
- package/dist/face/artifacts.js +189 -0
- package/dist/face/board-view.js +522 -0
- package/dist/face/capsule.js +141 -0
- package/dist/face/cli.js +891 -0
- package/dist/face/declare.js +241 -0
- package/dist/face/gate.js +158 -0
- package/dist/face/graph-view.js +66 -0
- package/dist/face/host.js +211 -0
- package/dist/face/lifecycle.js +603 -0
- package/dist/face/preview.js +136 -0
- package/dist/face/projection.js +259 -0
- package/dist/face/route-render.js +162 -0
- package/dist/face/termination.js +482 -0
- package/dist/face/words.js +220 -0
- package/{src-next/infra/config.ts → dist/infra/config.js} +19 -24
- package/{src-next/infra/doc-roots.ts → dist/infra/doc-roots.js} +3 -13
- package/dist/infra/git.js +37 -0
- package/dist/infra/process.js +22 -0
- package/{src-next/infra/root.ts → dist/infra/root.js} +25 -36
- package/dist/infra/runtime.js +85 -0
- package/dist/infra/workspace.js +276 -0
- package/dist/render/brief.js +82 -0
- package/dist/render/issue-body.js +129 -0
- package/dist/render/skeleton.js +434 -0
- package/dist/render/templates.js +520 -0
- package/dist/session/faces.js +38 -0
- package/dist/session/graph.js +309 -0
- package/dist/session/handoff-schema.js +295 -0
- package/dist/session/ledger.js +762 -0
- package/dist/session/next.js +211 -0
- package/dist/session/preflight.js +194 -0
- package/dist/session/round-naming.js +73 -0
- package/dist/session/run.js +441 -0
- package/dist/session/state.js +8 -0
- package/dist/session/wave.js +92 -0
- package/package.json +5 -5
- package/src-next/__tests__/bin.test.ts +0 -128
- package/src-next/__tests__/dead-decl.guard.test.ts +0 -39
- package/src-next/__tests__/floor.guard.test.ts +0 -69
- package/src-next/__tests__/issue-body.guard.test.ts +0 -66
- package/src-next/__tests__/phase-suffix.guard.test.ts +0 -72
- package/src-next/__tests__/smoke.integration.test.ts +0 -185
- package/src-next/__tests__/support/strip-comments.ts +0 -99
- package/src-next/__tests__/zero-dep.test.ts +0 -94
- package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +0 -256
- package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +0 -165
- package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +0 -190
- package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +0 -106
- package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +0 -240
- package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +0 -165
- package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +0 -190
- package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +0 -100
- package/src-next/contract/__tests__/declare.test.ts +0 -481
- package/src-next/contract/__tests__/doc.test.ts +0 -527
- package/src-next/contract/__tests__/dockey.guard.test.ts +0 -58
- package/src-next/contract/__tests__/edge-conditions.guard.test.ts +0 -81
- package/src-next/contract/__tests__/frontmatter.test.ts +0 -164
- package/src-next/contract/__tests__/judge.test.ts +0 -1111
- package/src-next/contract/__tests__/lint.test.ts +0 -324
- package/src-next/contract/__tests__/project.test.ts +0 -460
- package/src-next/contract/__tests__/structure-pin.test.ts +0 -186
- package/src-next/contract/__tests__/translate.test.ts +0 -96
- package/src-next/contract/declare.ts +0 -1071
- package/src-next/contract/doc.ts +0 -816
- package/src-next/contract/frontmatter.ts +0 -233
- package/src-next/contract/home-extractors.ts +0 -397
- package/src-next/contract/invariants.ts +0 -1413
- package/src-next/contract/judge.ts +0 -151
- package/src-next/contract/lint.ts +0 -239
- package/src-next/contract/project.ts +0 -656
- package/src-next/contract/skill-anatomy.ts +0 -301
- package/src-next/contract/translate.ts +0 -113
- package/src-next/face/__tests__/board-view.test.ts +0 -1151
- package/src-next/face/__tests__/capsule.test.ts +0 -300
- package/src-next/face/__tests__/channel-closure.guard.test.ts +0 -129
- package/src-next/face/__tests__/cli.test.ts +0 -4897
- package/src-next/face/__tests__/face.test.ts +0 -289
- package/src-next/face/__tests__/graph-view.test.ts +0 -61
- package/src-next/face/__tests__/host.test.ts +0 -24
- package/src-next/face/__tests__/install-rows.guard.test.ts +0 -58
- package/src-next/face/__tests__/negation.ts +0 -6
- package/src-next/face/__tests__/preview.test.ts +0 -374
- package/src-next/face/__tests__/projection.test.ts +0 -303
- package/src-next/face/__tests__/repo-root.guard.test.ts +0 -120
- package/src-next/face/__tests__/termination.test.ts +0 -650
- package/src-next/face/__tests__/words.guard.test.ts +0 -93
- package/src-next/face/artifacts.ts +0 -248
- package/src-next/face/board-view.ts +0 -652
- package/src-next/face/capsule.ts +0 -163
- package/src-next/face/cli.ts +0 -1028
- package/src-next/face/declare.ts +0 -323
- package/src-next/face/gate.ts +0 -171
- package/src-next/face/graph-view.ts +0 -74
- package/src-next/face/host.ts +0 -302
- package/src-next/face/lifecycle.ts +0 -725
- package/src-next/face/preview.ts +0 -151
- package/src-next/face/projection.ts +0 -285
- package/src-next/face/route-render.ts +0 -185
- package/src-next/face/termination.ts +0 -573
- package/src-next/face/words.ts +0 -314
- package/src-next/infra/__tests__/infra.test.ts +0 -333
- package/src-next/infra/__tests__/root.test.ts +0 -56
- package/src-next/infra/git.ts +0 -39
- package/src-next/infra/process.ts +0 -34
- package/src-next/infra/runtime.ts +0 -132
- package/src-next/infra/workspace.ts +0 -322
- package/src-next/render/__tests__/render.test.ts +0 -550
- package/src-next/render/__tests__/skeleton.test.ts +0 -684
- package/src-next/render/brief.ts +0 -121
- package/src-next/render/issue-body.ts +0 -162
- package/src-next/render/skeleton.ts +0 -502
- package/src-next/render/templates.ts +0 -645
- package/src-next/session/__tests__/graph.test.ts +0 -277
- package/src-next/session/__tests__/handoff-plane.guard.test.ts +0 -48
- package/src-next/session/__tests__/handoff-schema.test.ts +0 -310
- package/src-next/session/__tests__/ledger.test.ts +0 -745
- package/src-next/session/__tests__/next.test.ts +0 -460
- package/src-next/session/__tests__/preflight.test.ts +0 -545
- package/src-next/session/__tests__/round-naming.test.ts +0 -142
- package/src-next/session/__tests__/run.test.ts +0 -1026
- package/src-next/session/__tests__/wave-line-phase.guard.test.ts +0 -49
- package/src-next/session/__tests__/wave.test.ts +0 -476
- package/src-next/session/faces.ts +0 -110
- package/src-next/session/graph.ts +0 -411
- package/src-next/session/handoff-schema.ts +0 -373
- package/src-next/session/ledger.ts +0 -1076
- package/src-next/session/next.ts +0 -293
- package/src-next/session/preflight.ts +0 -271
- package/src-next/session/round-naming.ts +0 -84
- package/src-next/session/run.ts +0 -610
- package/src-next/session/state.ts +0 -30
- package/src-next/session/wave.ts +0 -139
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
// packages/cdd-engine/src-next/contract/skill-anatomy.ts
|
|
2
|
-
// T14 — the skill-anatomy contract typed export: skill-anatomy.json's content
|
|
3
|
-
// relocates into this typed constant module (the engine contract plane). The old
|
|
4
|
-
// JSON home is retired — the guard (scripts) consumes THIS export, never a JSON path.
|
|
5
|
-
//
|
|
6
|
-
// The contract: the node-anchored skill (SKILL.md) document structure — the
|
|
7
|
-
// section-heading registry (a STRICT allowlist), the `## Flow Digraph` mermaid
|
|
8
|
-
// section (mermaid-only), the `### `node`` node-definition grammar, the per-node
|
|
9
|
-
// four-element contract, the `## Invariants` / `## Failure Modes` tables, the
|
|
10
|
-
// BLOCKED terminal convention, the growth boundary (15 nodes / 17 edges — a
|
|
11
|
-
// crossing's rationale registers in this contract's registry), and the
|
|
12
|
-
// consumer-surface purity rule (SKILL.md carries zero growth/refactor narrative
|
|
13
|
-
// headings). Every fact the guard asserts is data here — the guard never restates
|
|
14
|
-
// a heading, pattern or limit.
|
|
15
|
-
//
|
|
16
|
-
// Module-level exports are type definitions + the declared contract constant —
|
|
17
|
-
// zero behavior-carrying bare functions (the plan's zero-bare-function discipline).
|
|
18
|
-
|
|
19
|
-
/** The section-registry keys — the strict `## ` allowlist (public + conditional). */
|
|
20
|
-
export interface AnatomySectionRegistry {
|
|
21
|
-
public: readonly string[];
|
|
22
|
-
conditional: readonly string[];
|
|
23
|
-
sections: Readonly<Record<string, AnatomySectionRow>>;
|
|
24
|
-
headingKinds: { nodeName: { pattern: string } };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** One section registry row — the canonical heading (+ the conditional carriers). */
|
|
28
|
-
export interface AnatomySectionRow {
|
|
29
|
-
heading: string;
|
|
30
|
-
requiredCarriers?: readonly string[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** The `## Flow Digraph` content rule — mermaid-only, zero trailing prose. */
|
|
34
|
-
export interface AnatomyDigraph {
|
|
35
|
-
sectionHeading: string;
|
|
36
|
-
mermaidOnly: boolean;
|
|
37
|
-
mermaidFence: string;
|
|
38
|
-
nodeTypes: Readonly<Record<string, { pattern: string }>>;
|
|
39
|
-
terminalStates: Readonly<Record<string, string>>;
|
|
40
|
-
/** The unified-skeleton hub name — the shared NEXT-LOOP hub the loop-family
|
|
41
|
-
* shapes assert (every loop-family skill is a pipeline scope: the hub carries
|
|
42
|
-
* the two-edge shape and no handoff-* terminal — the closure routes through the
|
|
43
|
-
* engine's next face, the dissolved handoff, D33). */
|
|
44
|
-
loopHubNode: {
|
|
45
|
-
name: string;
|
|
46
|
-
};
|
|
47
|
-
/** The loop-condition phrases the loop-family NEXT-LOOP hub's out-edges may
|
|
48
|
-
* carry (the `until next is terminal` self-loop · the `no next` failure face).
|
|
49
|
-
* This slot IS the authoritative home for the family (P9 branch-review-1 F9):
|
|
50
|
-
* the phrases are the SKILL-digraph EDGE-LABEL vocabulary — a consumer-surface
|
|
51
|
-
* prose face the runtime `next:` never emits — so there is no engine runtime
|
|
52
|
-
* constant to derive them from (unlike the status family ← the word table and
|
|
53
|
-
* the route family ← `ROUTE_DECISION_WORDS`, both engine-grounded). The
|
|
54
|
-
* edge-conditions guard pins the two runtime-derived families against their
|
|
55
|
-
* engine sources and consumes THIS slot verbatim for the loop family. */
|
|
56
|
-
nextLoopConditions: readonly string[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** The per-node four-element contract — the `### `node`` definitions' bullet fields. */
|
|
60
|
-
export interface AnatomyNodeElements {
|
|
61
|
-
[field: string]: { pattern: string };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** The node-definition grammar — the `### `node`` heading kind + the extension rule. */
|
|
65
|
-
export interface AnatomyNodeDefinitions {
|
|
66
|
-
sectionHeading: string;
|
|
67
|
-
headingKind: { pattern: string };
|
|
68
|
-
extensionRule: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** The growth boundary — limits + the registered-crossings rationale registry. */
|
|
72
|
-
export interface AnatomyGrowthBoundary {
|
|
73
|
-
nodeLimit: number;
|
|
74
|
-
edgeLimit: number;
|
|
75
|
-
registry: { crossings: Record<string, unknown> };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** The consumer-surface purity rule — the forbidden narrative-heading regression pins. */
|
|
79
|
-
export interface AnatomyConsumerPurity {
|
|
80
|
-
forbiddenNarrativeHeads: readonly string[];
|
|
81
|
-
zeroTraceRule: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** The frontmatter-validity rule (spec §4 · D42) — every shipped SKILL.md's YAML
|
|
85
|
-
* frontmatter block must parse under a REAL YAML parser. A bare ASCII `: ` inside
|
|
86
|
-
* an unquoted scalar (e.g. `the engine's next: line`) makes the block unparseable,
|
|
87
|
-
* and the harness then silently drops the skill — an ungated declaration. */
|
|
88
|
-
export interface AnatomyFrontmatter {
|
|
89
|
-
/** The frontmatter fence delimiter (the block between two `---` lines). */
|
|
90
|
-
fence: string;
|
|
91
|
-
/** The rule wording the check quotes when a frontmatter block fails to parse. */
|
|
92
|
-
rule: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** The author-entry bootstrap surface (§10 · the D29-regression pin) — the flow's
|
|
96
|
-
* content-authoring entry nodes and the skeleton bootstrap literal each one's Do
|
|
97
|
-
* must carry. D29's stripping rule keys on the ENTRY ROLE, not the surface shape:
|
|
98
|
-
* a node that authors a document (`author-spec` / `author-plan`) emits its target's
|
|
99
|
-
* `schema get … --output skeleton` bootstrap command (D29's own "entry-node bootstrap
|
|
100
|
-
* exception"), while the internal structure mirror (slot names / `:::fill`
|
|
101
|
-
* restatements) stays stripped. This fact pins the entry literals so a future
|
|
102
|
-
* shape-keyed strip cannot silently remove them again. */
|
|
103
|
-
export interface AnatomyAuthorBootstrap {
|
|
104
|
-
/** The author-entry nodes — one (skill, node) pair per content-authoring entry. */
|
|
105
|
-
entries: readonly { skill: string; node: string }[];
|
|
106
|
-
/** The skeleton bootstrap command pattern each entry node's block must satisfy
|
|
107
|
-
* (the `schema get <type> --output skeleton <target>` render literal). */
|
|
108
|
-
skeletonCommandPattern: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** The six-skill roster row — one shipped kairos skill (the P4 closed set's data). */
|
|
112
|
-
export interface SkillRosterRow {
|
|
113
|
-
/** The skill's role in the workflow normalization (§4.1). */
|
|
114
|
-
role: "orchestrator" | "spec-writer" | "executor" | "utility";
|
|
115
|
-
/** The flow family — the digraph-shape family the guard asserts:
|
|
116
|
-
* `loop` = the five-chain unified skeleton (NEXT-LOOP hub + self-loop + terminals);
|
|
117
|
-
* `close` = ends at the finish gate + terminal (no self-loop);
|
|
118
|
-
* `onepass` = one-pass · no self-loop (a one-shot toolchain or a forked-routing
|
|
119
|
-
* flow — covers both the linear cdd-report toolchain and the forked cdd-design
|
|
120
|
-
* routing; no self-loop either way). */
|
|
121
|
-
family: "loop" | "close" | "onepass";
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** The full skill-anatomy contract — the typed structure facts the guard consumes. */
|
|
125
|
-
export interface SkillAnatomyContract {
|
|
126
|
-
sectionRegistry: AnatomySectionRegistry;
|
|
127
|
-
digraph: AnatomyDigraph;
|
|
128
|
-
nodeDefinitions: AnatomyNodeDefinitions;
|
|
129
|
-
nodeElements: AnatomyNodeElements;
|
|
130
|
-
invariants: { table: { rowPattern: string } };
|
|
131
|
-
failureModes: { table: { rowPattern: string } };
|
|
132
|
-
blockedTerminal: { stateToken: string; requires: readonly string[] };
|
|
133
|
-
growthBoundary: AnatomyGrowthBoundary;
|
|
134
|
-
consumerPurity: AnatomyConsumerPurity;
|
|
135
|
-
authorBootstrap: AnatomyAuthorBootstrap;
|
|
136
|
-
/** The frontmatter-validity rule (spec §4 · D42) — the real-YAML-parse gate. */
|
|
137
|
-
frontmatter: AnatomyFrontmatter;
|
|
138
|
-
skills: { registry: Readonly<Record<string, SkillRosterRow>> };
|
|
139
|
-
wording: Readonly<Record<string, string>>;
|
|
140
|
-
/** The engine-lexicon pinned condition words (the v1.20 word-table pin) — the phrase set the
|
|
141
|
-
* digraph's loop/closure decision edges may carry (the NEXT-LOOP phrases + the
|
|
142
|
-
* decision status words + the Route-kind words). The static digraph truth and the
|
|
143
|
-
* runtime `next:` instance share this one list — the guard asserts every NEXT-LOOP
|
|
144
|
-
* out-edge label ∈ this set, and the wording test pins the set's derivation from
|
|
145
|
-
* the engine word table/Route lexicon (mechanical anti-drift, never a re-type). */
|
|
146
|
-
edgeConditionWords: readonly string[];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** The section-heading registry — the strict `## `/`### ` allowlist (public +
|
|
150
|
-
* conditional sections + the node-name heading grammar). */
|
|
151
|
-
const SECTION_REGISTRY = {
|
|
152
|
-
public: ["flowDigraph", "nodeDefinitions", "invariants", "failureModes"],
|
|
153
|
-
conditional: [],
|
|
154
|
-
sections: {
|
|
155
|
-
flowDigraph: { heading: "## Flow Digraph" },
|
|
156
|
-
nodeDefinitions: { heading: "## Node Definitions" },
|
|
157
|
-
invariants: { heading: "## Invariants" },
|
|
158
|
-
failureModes: { heading: "## Failure Modes" },
|
|
159
|
-
},
|
|
160
|
-
headingKinds: { nodeName: { pattern: "^### `[^`]+`$" } },
|
|
161
|
-
} as const;
|
|
162
|
-
|
|
163
|
-
/** The six-skill roster — the P4 closed set: exactly these members ship, the 9th
|
|
164
|
-
* seat is vacant (a directory scan may carry zero more, zero missing); the family
|
|
165
|
-
* facts drive the digraph-shape assertions (consistency over the five chains). */
|
|
166
|
-
const SKILL_ROSTER: Readonly<Record<string, SkillRosterRow>> = {
|
|
167
|
-
"cdd-design": { role: "orchestrator", family: "onepass" },
|
|
168
|
-
"cdd-spec-writer": { role: "spec-writer", family: "loop" },
|
|
169
|
-
"cdd-plan": { role: "orchestrator", family: "loop" },
|
|
170
|
-
"cdd-dev": { role: "executor", family: "loop" },
|
|
171
|
-
"cdd-close": { role: "orchestrator", family: "close" },
|
|
172
|
-
"cdd-report": { role: "utility", family: "onepass" },
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/** The skill-anatomy contract — one typed constant: the structure facts + the
|
|
176
|
-
* diagnostic wording the checks quote (single source, never a guard literal). */
|
|
177
|
-
export const SKILL_ANATOMY = {
|
|
178
|
-
sectionRegistry: SECTION_REGISTRY,
|
|
179
|
-
digraph: {
|
|
180
|
-
sectionHeading: "## Flow Digraph",
|
|
181
|
-
mermaidOnly: true,
|
|
182
|
-
mermaidFence: "```mermaid",
|
|
183
|
-
nodeTypes: {
|
|
184
|
-
operator: { pattern: "^\\w+\\[.*\\]$" },
|
|
185
|
-
decision: { pattern: "^\\w+\\{.*\\}$" },
|
|
186
|
-
terminal: { pattern: "^\\w+\\(\\(.*\\)\\)$" },
|
|
187
|
-
},
|
|
188
|
-
terminalStates: { blocked: "BLOCKED", approved: "APPROVED" },
|
|
189
|
-
// The five-chain unified skeleton — one shared hub across the loop family; the
|
|
190
|
-
// hub carries the two-edge pipeline shape (the closure routes through the engine's
|
|
191
|
-
// next face, D33 — no closure exit, no handoff-* terminal). The close/onepass
|
|
192
|
-
// families are the explicit no-self-loop exceptions.
|
|
193
|
-
loopHubNode: { name: "NEXT-LOOP" },
|
|
194
|
-
// The v1.20 restored loop conditions — the pinned word face of the NEXT-LOOP hub's
|
|
195
|
-
// two out-edges (the digraph's static branch truth, one table with the runtime
|
|
196
|
-
// `next:` instance: `until next is terminal` self-loop · the `no next` failure
|
|
197
|
-
// face. Each label must be one of these — the guard asserts it).
|
|
198
|
-
nextLoopConditions: ["until next is terminal", "no next"],
|
|
199
|
-
},
|
|
200
|
-
nodeDefinitions: {
|
|
201
|
-
sectionHeading: "## Node Definitions",
|
|
202
|
-
headingKind: { pattern: "^### `[^`]+`$" },
|
|
203
|
-
extensionRule: "prose sections map one-to-one to graph nodes",
|
|
204
|
-
},
|
|
205
|
-
nodeElements: {
|
|
206
|
-
do: { pattern: "^- \\*\\*Do\\*\\*:" },
|
|
207
|
-
read: { pattern: "^- \\*\\*Read\\*\\*:" },
|
|
208
|
-
exit: { pattern: "^- \\*\\*Exit\\*\\*:" },
|
|
209
|
-
fail: { pattern: "^- \\*\\*Fail\\*\\*:" },
|
|
210
|
-
},
|
|
211
|
-
invariants: { table: { rowPattern: "^\\|\\s*[A-Z]+\\d+\\s*\\|" } },
|
|
212
|
-
failureModes: { table: { rowPattern: "^\\|[^\\n]+\\|$" } },
|
|
213
|
-
blockedTerminal: {
|
|
214
|
-
stateToken: "BLOCKED",
|
|
215
|
-
requires: ["blocking reason", "recovery action", "no silent fallback"],
|
|
216
|
-
},
|
|
217
|
-
growthBoundary: {
|
|
218
|
-
nodeLimit: 15,
|
|
219
|
-
edgeLimit: 17,
|
|
220
|
-
// The registered-growth rationale registry — a digraph crossing the boundary is
|
|
221
|
-
// admitted here (never narrated inside the consumer SKILL.md). No crossing is
|
|
222
|
-
// registered: every live digraph stays inside the node/edge limits.
|
|
223
|
-
registry: {
|
|
224
|
-
crossings: {} as Record<string, string>,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
consumerPurity: {
|
|
228
|
-
forbiddenNarrativeHeads: ["## Flow size note", "## Full Flow Refactor Rationale"],
|
|
229
|
-
zeroTraceRule: "zero trace in the consumer skill",
|
|
230
|
-
},
|
|
231
|
-
// The author-entry bootstrap surface (§10 · the D29-regression pin) — the
|
|
232
|
-
// content-authoring entry nodes' skeleton bootstrap literals. D29 strips the
|
|
233
|
-
// INTERNAL structure mirror (slot names / `:::fill` restatements), never the
|
|
234
|
-
// entry node's bootstrap command (its own exception); this pins the literals so
|
|
235
|
-
// a shape-keyed strip cannot silently remove them again.
|
|
236
|
-
authorBootstrap: {
|
|
237
|
-
entries: [
|
|
238
|
-
{ skill: "cdd-spec-writer", node: "author-spec" },
|
|
239
|
-
{ skill: "cdd-plan", node: "author-plan" },
|
|
240
|
-
],
|
|
241
|
-
skeletonCommandPattern: "schema get \\S+ --output skeleton",
|
|
242
|
-
},
|
|
243
|
-
// The frontmatter-validity rule (spec §4 · D42) — every shipped SKILL.md's YAML
|
|
244
|
-
// frontmatter block must parse under a REAL parser; a bare `: ` in an unquoted
|
|
245
|
-
// scalar breaks the block and the harness silently drops the skill.
|
|
246
|
-
frontmatter: {
|
|
247
|
-
fence: "---",
|
|
248
|
-
rule: "every SKILL.md frontmatter block must parse under a real YAML parser — an unquoted `: ` in a scalar makes the block unparseable and the harness silently drops the skill (D42)",
|
|
249
|
-
},
|
|
250
|
-
skills: { registry: SKILL_ROSTER },
|
|
251
|
-
// The check-facing diagnostic wording — the prose the anatomy assertions quote
|
|
252
|
-
// when a structure rule fires (the contract's self-describing face).
|
|
253
|
-
wording: {
|
|
254
|
-
registryRule:
|
|
255
|
-
"the section-heading registry is a STRICT allowlist — a registry-external heading is a BLOCK because an undefined section is uncertainty on the consumer's real entry surface",
|
|
256
|
-
headingKindRule:
|
|
257
|
-
"every live `### ` heading is a backticked node-name heading (a node-definitions entry) — any other `### ` form is registry-external → BLOCK",
|
|
258
|
-
digraphContentRule:
|
|
259
|
-
"the Flow Digraph section carries EXACTLY ONE mermaid block and ZERO trailing prose — a flow intro line below the mermaid is redundant narration, forbidden on the consumer surface",
|
|
260
|
-
nodeElementRule:
|
|
261
|
-
"the per-node four-element contract — every node definition's prose carries Do / Read / Exit / Fail; a node missing any of the four elements is structurally incomplete",
|
|
262
|
-
nodeDefinitionRule:
|
|
263
|
-
"every digraph operator node has a definition heading and every definition heading names a digraph operator node (bidirectional completeness) — orphans and dangling nodes fail",
|
|
264
|
-
growthRule:
|
|
265
|
-
"crossing the growth boundary requires a rationale registered in this contract's growth registry — NEVER inside the consumer-shipped SKILL.md (consumer-surface purity)",
|
|
266
|
-
purityRule:
|
|
267
|
-
"SKILL.md is an instruction document — growth/refactor narrative headings are forbidden in ANY form; the rationale surface lives here, the consumer skill carries zero trace",
|
|
268
|
-
closedSetRule:
|
|
269
|
-
"the kairos skills are a CLOSED six-set registered in this contract's roster — the directory scan must carry exactly these members (9th seat vacant): an extra member is a new skill entering without registration, a missing member is a retired skill leaving without a plan entry",
|
|
270
|
-
loopShapeRule:
|
|
271
|
-
"the five-chain unified skeleton — every loop-family skill digraph carries the shared NEXT-LOOP hub; the hub carries TWO out-edges (the `until next is terminal` self-loop · the `no next` BLOCKED face) and NO handoff-* terminal — its closure routes through the engine's next face (the dissolved handoff, D33) (digraph↔Node Definitions↔text-reference consistency, shared node names must never drift)",
|
|
272
|
-
enderShapeRule:
|
|
273
|
-
"the explicit no-self-loop exceptions — cdd-close ends at the finish semantic gate + terminal, cdd-report is a one-shot toolchain, cdd-design is a forked-routing one-pass flow; a NEXT-LOOP self-loop in any of them is a shape violation",
|
|
274
|
-
edgeConditionRule:
|
|
275
|
-
"decision edges carry explicit condition labels — the NEXT-LOOP hub's out-edges ARE the pinned loop conditions (`until next is terminal` → self-loop · `no next` → BLOCKED) and every edge out of a decision node is condition-labeled; an unlabeled decision edge, a bare NEXT-LOOP self-loop, or a NEXT-LOOP out-edge count/condition that deviates from the pinned shape is a shape violation (the edge-zero-state-label rule retired v1.20)",
|
|
276
|
-
routeFactRule:
|
|
277
|
-
"next: is consumed as a dispatch-ready literal (the literal IS the dispatch, no kind→command mapping layer); a full cdd command string never follows the next: token on a line; BLOCKED/TIMEOUT carry no next line and are not consumed as next steps",
|
|
278
|
-
},
|
|
279
|
-
// The engine-lexicon pinned condition words (the v1.20 word-table pin) — the phrase
|
|
280
|
-
// set the digraph's loop/closure decision edges may carry: the NEXT-LOOP phrases +
|
|
281
|
-
// the decision status words (the word table's status vocabulary minus the failure
|
|
282
|
-
// statuses) + the Route decision words (the `next:` lexical domain). This declared
|
|
283
|
-
// value is PINNED by the engine-suite derivation gate
|
|
284
|
-
// (contract/__tests__/edge-conditions.guard.test.ts) — it must equal the derivation
|
|
285
|
-
// from the engine word table / Route lexicon (`CAPSULE_WORDS.status` minus
|
|
286
|
-
// `FAILED_STATUS`, `ROUTE_DECISION_WORDS`, `nextLoopConditions`); a drifted engine
|
|
287
|
-
// word fails that gate, never a silent second list. The kairos-suite edge assertion
|
|
288
|
-
// consumes this set as its label allowlist.
|
|
289
|
-
edgeConditionWords: [
|
|
290
|
-
"until next is terminal",
|
|
291
|
-
"no next",
|
|
292
|
-
"APPROVED",
|
|
293
|
-
"CHANGES_REQUESTED",
|
|
294
|
-
"REVIEW_FIX",
|
|
295
|
-
"done",
|
|
296
|
-
"next-wave",
|
|
297
|
-
"review",
|
|
298
|
-
"fix",
|
|
299
|
-
"soft-cap",
|
|
300
|
-
],
|
|
301
|
-
} as const satisfies SkillAnatomyContract;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// packages/cdd-engine/src-next/contract/translate.ts
|
|
2
|
-
// T19 — the single bidirectional translation layer (the P7 translation system core):
|
|
3
|
-
// the words' locale face (each row `{ en: canonical, zh?: Chinese alias }`) is served
|
|
4
|
-
// by the word table (face/words.ts — the word table's locale family), and ONE
|
|
5
|
-
// translator class speaks for the whole plane:
|
|
6
|
-
//
|
|
7
|
-
// canonicalize(line) — the recognition face: every registered Chinese alias span in
|
|
8
|
-
// the line maps to its canonical English row (the longest registered alias wins
|
|
9
|
-
// at each position — non-overlapping spans; unregistered text passes through
|
|
10
|
-
// unchanged). The doc-parse / judge recognition channel the legacy Chinese
|
|
11
|
-
// markers used to need — recognition rides this layer, never a second
|
|
12
|
-
// hand-written map. The single recognition face: the retired single-token
|
|
13
|
-
// normalize folds in — a single-token judgement is canonicalize over that
|
|
14
|
-
// token's line.
|
|
15
|
-
// localize(token, locale) — the rendering face: the canonical token → the requested
|
|
16
|
-
// locale's output word (the en locale renders the canonical itself — identity),
|
|
17
|
-
// the human-readable rendering faces' locale-normalized output.
|
|
18
|
-
//
|
|
19
|
-
// The layer is word-table driven with ZERO switch (a new word is declared as data,
|
|
20
|
-
// never as a code branch — the lookups are maps over the injected row data). The
|
|
21
|
-
// capsule machine face (status · next: · CDD_BLOCKED:) is deliberately NOT in the
|
|
22
|
-
// locale rows — the machine surface is English-constant and never localizable.
|
|
23
|
-
// Module-level exports are types / the class — zero behavior-carrying bare functions.
|
|
24
|
-
|
|
25
|
-
/** One locale word — a word's locale face: `{ en: canonical, zh?: Chinese alias }`
|
|
26
|
-
* (the word table's locale-column shape; the en face is always present, the zh alias
|
|
27
|
-
* is a row's non-en locale output). Rows are keyed by locale — the en column is
|
|
28
|
-
* required, every further locale column is an optional alias. */
|
|
29
|
-
export interface LocalizedWord {
|
|
30
|
-
/** The canonical English form — the token's stable face (the canonicalize target). */
|
|
31
|
-
en: string;
|
|
32
|
-
/** The Chinese alias — the zh locale's output word of this row. */
|
|
33
|
-
zh?: string;
|
|
34
|
-
/** The locale columns — a row's output word per key; the canonical always renders
|
|
35
|
-
* under `en`, further locales under their key (an absent column = no output). */
|
|
36
|
-
[locale: string]: string | undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** The word table's locale face — the single locale source the translator and the
|
|
40
|
-
* locale consumers read (the langs derivation + the label rows). Every method on the
|
|
41
|
-
* face is data-backed — a second hand-written locale table is excluded by construction. */
|
|
42
|
-
export interface WordLocaleFace {
|
|
43
|
-
/** The locale key set — the word table's declared language keys (the `langs`
|
|
44
|
-
* projection source: locale-consuming faces derive from this, never hardcode). */
|
|
45
|
-
localeKeys(): readonly string[];
|
|
46
|
-
/** Every locale row of the word table, flat (the translator's row index source). */
|
|
47
|
-
localeRows(): readonly LocalizedWord[];
|
|
48
|
-
/** One locale row by its word id; null for an unknown id. */
|
|
49
|
-
localeRow(id: string): LocalizedWord | null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Translator — the single bidirectional translation layer. canonicalize() recognizes
|
|
54
|
-
* an input line — every registered Chinese alias span maps to its canonical English
|
|
55
|
-
* form, unregistered text passes through (identity); localize() renders a canonical
|
|
56
|
-
* token at a requested locale. Both ride the injected word-table locale face — zero
|
|
57
|
-
* switch: a new word is a new data row, never a new code branch (the word table is
|
|
58
|
-
* the single-source translation data).
|
|
59
|
-
*/
|
|
60
|
-
export class Translator {
|
|
61
|
-
/** The bilingual row index — canonical token → its row (the localize/identity path). */
|
|
62
|
-
readonly #byToken: ReadonlyMap<string, LocalizedWord>;
|
|
63
|
-
/** The alias index — non-en alias → its canonical token (the canonicalize path). */
|
|
64
|
-
readonly #byAlias: ReadonlyMap<string, string>;
|
|
65
|
-
/** The alias keys, longest first — the canonicalize scan order (the longest
|
|
66
|
-
* registered alias binds at each position; a same-length tie keeps insertion
|
|
67
|
-
* order). Built once — the scan never re-sorts. */
|
|
68
|
-
readonly #aliasesByLength: readonly string[];
|
|
69
|
-
|
|
70
|
-
constructor(face: WordLocaleFace) {
|
|
71
|
-
const byToken = new Map<string, LocalizedWord>();
|
|
72
|
-
const byAlias = new Map<string, string>();
|
|
73
|
-
for (const row of face.localeRows()) {
|
|
74
|
-
byToken.set(row.en, row);
|
|
75
|
-
if (row.zh !== undefined) byAlias.set(row.zh, row.en);
|
|
76
|
-
}
|
|
77
|
-
this.#byToken = byToken;
|
|
78
|
-
this.#byAlias = byAlias;
|
|
79
|
-
this.#aliasesByLength = [...byAlias.keys()].sort((a, b) => b.length - a.length);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** canonicalize(line) — the bidirectional recognition face: every registered
|
|
83
|
-
* Chinese alias span in the line maps to its canonical English row (the longest
|
|
84
|
-
* registered alias wins at each position — non-overlapping spans; unregistered
|
|
85
|
-
* text, an already-canonical line, and an empty line pass through unchanged). The
|
|
86
|
-
* single recognition face — a single-token judgement is canonicalize over that
|
|
87
|
-
* token's line (the retired single-token normalize). Pure: the caller owns any
|
|
88
|
-
* write-back — this method never rewrites the source document. */
|
|
89
|
-
canonicalize(line: string): string {
|
|
90
|
-
let out = "";
|
|
91
|
-
let i = 0;
|
|
92
|
-
while (i < line.length) {
|
|
93
|
-
const alias = this.#aliasesByLength.find((candidate) => line.startsWith(candidate, i));
|
|
94
|
-
if (alias === undefined) {
|
|
95
|
-
out += line[i];
|
|
96
|
-
i += 1;
|
|
97
|
-
} else {
|
|
98
|
-
out += this.#byAlias.get(alias);
|
|
99
|
-
i += alias.length;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return out;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** localize(token, locale) — the rendering face: the canonical token → the requested
|
|
106
|
-
* locale's output word (en renders the canonical itself — identity); an unknown
|
|
107
|
-
* token, an unknown locale, or a row without the locale's column is null. */
|
|
108
|
-
localize(token: string, locale: string): string | null {
|
|
109
|
-
const row = this.#byToken.get(token);
|
|
110
|
-
if (row === undefined) return null;
|
|
111
|
-
return row[locale] ?? null;
|
|
112
|
-
}
|
|
113
|
-
}
|