@dtmd/temper 0.0.25 → 0.0.26
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/README.md +14 -12
- package/dist/src/assembly.d.ts +45 -11
- package/dist/src/assembly.js +115 -7
- package/dist/src/builtins.d.ts +433 -103
- package/dist/src/builtins.js +771 -167
- package/dist/src/claude-code.d.ts +6 -3
- package/dist/src/claude-code.js +2 -2
- package/dist/src/contract.d.ts +153 -44
- package/dist/src/contract.js +123 -34
- package/dist/src/counsel.d.ts +11 -0
- package/dist/src/counsel.js +68 -0
- package/dist/src/declarations.d.ts +108 -2
- package/dist/src/declarations.js +606 -100
- package/dist/src/dial.d.ts +3 -3
- package/dist/src/dial.js +21 -5
- package/dist/src/emit.d.ts +12 -14
- package/dist/src/emit.js +123 -47
- package/dist/src/generated/AbsenceGateRow.d.ts +16 -0
- package/dist/src/generated/AbsenceGateRow.js +2 -0
- package/dist/src/generated/AreaMode.d.ts +5 -0
- package/dist/src/generated/AreaMode.js +2 -0
- package/dist/src/generated/AreaRow.d.ts +20 -0
- package/dist/src/generated/AreaRow.js +1 -0
- package/dist/src/generated/AssemblyFactRow.d.ts +17 -4
- package/dist/src/generated/BoundRow.d.ts +9 -4
- package/dist/src/generated/CedeRow.d.ts +14 -0
- package/dist/src/generated/CedeRow.js +2 -0
- package/dist/src/generated/CharsetRow.d.ts +14 -3
- package/dist/src/generated/ClauseRow.d.ts +23 -21
- package/dist/src/generated/CollectionAddressRow.d.ts +1 -1
- package/dist/src/generated/Declarations.d.ts +24 -9
- package/dist/src/generated/FeatureValue.d.ts +3 -3
- package/dist/src/generated/Features.d.ts +3 -3
- package/dist/src/generated/KindFactRow.d.ts +41 -8
- package/dist/src/generated/Payload.d.ts +3 -5
- package/dist/src/generated/PayloadMember.d.ts +7 -0
- package/dist/src/generated/RunsRow.d.ts +17 -0
- package/dist/src/generated/RunsRow.js +2 -0
- package/dist/src/generated/Section.d.ts +2 -2
- package/dist/src/generated/SectionContainsRow.d.ts +1 -1
- package/dist/src/generated/TypecheckRow.d.ts +20 -0
- package/dist/src/generated/TypecheckRow.js +2 -0
- package/dist/src/generated/Verifier.d.ts +8 -2
- package/dist/src/generated/index.d.ts +6 -0
- package/dist/src/index.d.ts +20 -15
- package/dist/src/index.js +10 -9
- package/dist/src/kind.d.ts +382 -52
- package/dist/src/kind.js +461 -49
- package/dist/src/lockfile.d.ts +39 -0
- package/dist/src/lockfile.js +265 -0
- package/dist/src/member-address.d.ts +15 -3
- package/dist/src/member-address.js +23 -6
- package/dist/src/needs.d.ts +25 -15
- package/dist/src/needs.js +10 -11
- package/dist/src/patterns.d.ts +112 -0
- package/dist/src/patterns.js +90 -0
- package/dist/src/pipe.d.ts +16 -0
- package/dist/src/pipe.js +39 -0
- package/dist/src/playbook.d.ts +203 -0
- package/dist/src/playbook.js +239 -0
- package/dist/src/prose.d.ts +69 -12
- package/dist/src/prose.js +125 -13
- package/dist/src/reference.d.ts +70 -0
- package/dist/src/reference.js +368 -0
- package/package.json +13 -4
- package/schemas/agent.json +23 -0
- package/schemas/command.json +5 -0
- package/schemas/output-style.json +4 -0
- package/schemas/rule.json +33 -0
- package/schemas/skill.json +63 -0
package/dist/src/kind.d.ts
CHANGED
|
@@ -11,7 +11,19 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { Prose, Text } from "./prose.js";
|
|
13
13
|
import type { Capability } from "./needs.js";
|
|
14
|
-
import type {
|
|
14
|
+
import type { RequirementValue } from "./contract.js";
|
|
15
|
+
import type { EnforcementMode } from "./assembly.js";
|
|
16
|
+
/** The brand {@link Remedy} keys on — unexported, so no value outside this module can carry it. */
|
|
17
|
+
declare const remedy: unique symbol;
|
|
18
|
+
/**
|
|
19
|
+
* A type no authored value inhabits, whose argument is the fix for writing one. It stands
|
|
20
|
+
* where a known mistake would otherwise meet `never` or a bare missing-name error — a field
|
|
21
|
+
* the locus already derives, a field that moved, a retired export — so the compiler's own
|
|
22
|
+
* error prints the remedy (`Type 'never[]' is not assignable to type 'Remedy<"…">'`).
|
|
23
|
+
*/
|
|
24
|
+
export type Remedy<Message extends string> = {
|
|
25
|
+
readonly [remedy]: Message;
|
|
26
|
+
};
|
|
15
27
|
/**
|
|
16
28
|
* The shape of the on-disk artifact a member projects to (fact 3, projection) — a closed
|
|
17
29
|
* vocabulary the engine implements once per entry, and the fact deciding which adapter
|
|
@@ -21,16 +33,26 @@ import type { Requirement } from "./contract.js";
|
|
|
21
33
|
* member declaring it, so it serves a document temper reads in place and never writes.
|
|
22
34
|
*/
|
|
23
35
|
export type Format = "yaml-frontmatter" | "json-document" | "toml-document";
|
|
36
|
+
/**
|
|
37
|
+
* A source malformation a kind's reader forgives, because the runtime loads the document
|
|
38
|
+
* anyway — a closed vocabulary. `"malformed-yaml"`: a frontmatter block that does not
|
|
39
|
+
* parse as YAML loads with no fields set and draws an advisory, never a load fault.
|
|
40
|
+
*/
|
|
41
|
+
export type Leniency = "malformed-yaml";
|
|
24
42
|
/**
|
|
25
43
|
* Whether a member is a lone file (identity from the stem), a directory with an
|
|
26
44
|
* entry file (identity from the directory name), a lone file whose identity is
|
|
27
45
|
* read from a declared field (`identityField`) instead of derived from the path (an
|
|
28
|
-
* agent's `name`) — on whichever surface the kind's `format` carries its fields — or
|
|
29
|
-
*
|
|
46
|
+
* agent's `name`) — on whichever surface the kind's `format` carries its fields — or
|
|
47
|
+
* read from that field when present and the stem otherwise (`"named-field-or-file"`: an
|
|
48
|
+
* output style's `name`, else its filename), or a lone file keyed by the directory segment its single-`*` segment glob stars
|
|
30
49
|
* (`"starred-segment"`), coexisting inside another kind's directory rather than owning
|
|
31
|
-
* one
|
|
50
|
+
* one — or a lone file named by its whole path under the locus, each `/` a `:` and the
|
|
51
|
+
* extension dropped (`"path"`: a command's `frontend/component.md` is
|
|
52
|
+
* `frontend:component`). The identity source is this spelled fact, never inferred from
|
|
53
|
+
* the glob.
|
|
32
54
|
*/
|
|
33
|
-
export type UnitShape = "file" | "directory" | "named-field" | "starred-segment";
|
|
55
|
+
export type UnitShape = "file" | "directory" | "named-field" | "named-field-or-file" | "starred-segment" | "path";
|
|
34
56
|
/**
|
|
35
57
|
* One **channel** a kind's registration declares — a documented way a member
|
|
36
58
|
* reaches the world (fact 4, `builtins.md`, "The shipped kinds": "user
|
|
@@ -48,6 +70,31 @@ export type Registration = {
|
|
|
48
70
|
} | {
|
|
49
71
|
readonly via: "paths-match";
|
|
50
72
|
readonly field: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The member loads the first time Claude reads a file beneath its **home** — its own
|
|
76
|
+
* directory, a `.claude/` folder folded into the directory holding it. A member homed
|
|
77
|
+
* at the harness root (the working directory) is beneath it already, so it loads at
|
|
78
|
+
* launch; one homed in a subdirectory loads on demand. A subdirectory's `CLAUDE.md`
|
|
79
|
+
* "load[s] only when Claude reads a file there" (code.claude.com/docs/en/memory,
|
|
80
|
+
* "How CLAUDE.md files load", retrieved 2026-11-24). Never provably dead: the member
|
|
81
|
+
* is itself a file beneath its home. Carries no field — placement is the criterion.
|
|
82
|
+
*/
|
|
83
|
+
| {
|
|
84
|
+
readonly via: "on-read-beneath";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The member joins the invocation listing the first time a file tool reads a file
|
|
88
|
+
* the named glob field matches; an absent or blank field lists it from session start.
|
|
89
|
+
* A skill's own `paths` gate its listing, not its body (probed on Claude Code 2.1.332,
|
|
90
|
+
* 2026-11-26, decision 0111; code.claude.com/docs/en/skills, retrieved 2026-07-15).
|
|
91
|
+
* Distinct from `paths-match`, which loads the member's body on the read: here the
|
|
92
|
+
* read opens the listing, and the body still loads only on invocation. A present
|
|
93
|
+
* glob set matching no file is dead, as `paths-match`'s is.
|
|
94
|
+
*/
|
|
95
|
+
| {
|
|
96
|
+
readonly via: "paths-listing";
|
|
97
|
+
readonly field: string;
|
|
51
98
|
} | {
|
|
52
99
|
readonly via: "event";
|
|
53
100
|
readonly field: string;
|
|
@@ -58,6 +105,20 @@ export type Registration = {
|
|
|
58
105
|
readonly field: string;
|
|
59
106
|
} | {
|
|
60
107
|
readonly via: "registry";
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The member is **selected** by another member's edge under the named field, and the
|
|
111
|
+
* runtime loads what is selected at launch: the active output style a settings file's
|
|
112
|
+
* `outputStyle` names rides every request from launch
|
|
113
|
+
* (code.claude.com/docs/en/output-styles, "How output styles work", retrieved
|
|
114
|
+
* 2026-11-27). The field names the *selecting* edge's field, not one of the member's
|
|
115
|
+
* own. A member no committed edge selects has no load moment the tree can show, and the
|
|
116
|
+
* channel is never provably dead: a user-scope setting or the `/config` picker may
|
|
117
|
+
* select it from outside the tree.
|
|
118
|
+
*/
|
|
119
|
+
| {
|
|
120
|
+
readonly via: "selected";
|
|
121
|
+
readonly field: string;
|
|
61
122
|
};
|
|
62
123
|
/** One of a kind's fields that is a reference to another member — a graph edge (fact 5). */
|
|
63
124
|
export interface EdgeField {
|
|
@@ -68,18 +129,30 @@ export interface EdgeField {
|
|
|
68
129
|
* set demands the kind-qualified `kind:name` address always, since resolution
|
|
69
130
|
* reads the written text and never infers from the member population. The
|
|
70
131
|
* non-emptiness is the type's to hold — an edge declaring no target kind can
|
|
71
|
-
* never resolve.
|
|
132
|
+
* never resolve. Each target is a kind value, since a kind's identity travels by
|
|
133
|
+
* import, never by string: a misspelled target is a compile error, not a dangling
|
|
134
|
+
* name. The lock still records each target's name ({@link edgeTargetNames}).
|
|
135
|
+
*/
|
|
136
|
+
readonly to: readonly [KindDefinition<any>, ...KindDefinition<any>[]];
|
|
137
|
+
/**
|
|
138
|
+
* The names the **runtime itself** answers at the far end, with no member behind
|
|
139
|
+
* them — a settings `outputStyle` naming one of Claude Code's built-in styles. A value
|
|
140
|
+
* spelling one exactly resolves to no member and draws no dangling-route finding,
|
|
141
|
+
* because the runtime loads what it names (decision 0101); a member of the same name
|
|
142
|
+
* still takes the resolution. Omitted when the runtime supplies none, the common case.
|
|
72
143
|
*/
|
|
73
|
-
readonly
|
|
144
|
+
readonly provided?: readonly string[];
|
|
74
145
|
}
|
|
146
|
+
/** The kind names an edge's `to` set lists, in declared order — the names the lock records. */
|
|
147
|
+
export declare function edgeTargetNames(edge: Pick<EdgeField, "to">): string[];
|
|
75
148
|
/**
|
|
76
149
|
* A kind's **locus** (fact 2), in three spellings: members live at path globs (`at`),
|
|
77
150
|
* as typed fenced blocks inside host documents (`embedded`), or as `nested-file`
|
|
78
151
|
* children owning a file whose path composes from their host member's unit and the host
|
|
79
152
|
* kind's template pattern. An `at` locus is split root + glob so the kind fact row
|
|
80
|
-
* carries `
|
|
153
|
+
* carries `locus_root`/`locus_glob` directly; a `nested-file` kind declares neither
|
|
81
154
|
* — the pattern is the host {@link Template}'s one home, so a child can never collide
|
|
82
|
-
* with its host's own
|
|
155
|
+
* with its host's own locus glob. An `embedded` locus names no host: which types may
|
|
83
156
|
* compose a kind's body is the adopting corpus's `admit` declaration over the host kind
|
|
84
157
|
* (`assembly.ts`), so one embedded type means the same thing in every body that admits
|
|
85
158
|
* it. A `nested-file` child names its host per member ({@link MemberInit}'s `host`) —
|
|
@@ -98,11 +171,12 @@ export interface EdgeField {
|
|
|
98
171
|
export type Locus = {
|
|
99
172
|
readonly kind: "at";
|
|
100
173
|
readonly root: string;
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
|
|
174
|
+
/** One or more placement templates under `root`, a document at any of them the
|
|
175
|
+
* kind's: each literal `/`-separated segments with at most one `*`, optionally
|
|
176
|
+
* under a leading `**` + `/` for any depth. Any other pattern syntax (a `?`, a
|
|
177
|
+
* character class, braces, an extglob, a second star) is refused when the engine
|
|
178
|
+
* loads the lock. A list is the several-template spelling; a lone string is one. */
|
|
179
|
+
readonly glob: string | Templates;
|
|
106
180
|
readonly commitment?: "local";
|
|
107
181
|
/** Paths the template would govern that the kind leaves ungoverned — each a
|
|
108
182
|
* starless, harness-relative literal the template matches (`domains/README.md`
|
|
@@ -116,6 +190,33 @@ export type Locus = {
|
|
|
116
190
|
} | {
|
|
117
191
|
readonly kind: "nested-file";
|
|
118
192
|
};
|
|
193
|
+
/**
|
|
194
|
+
* One template that carries an **absence gate**: a document at `glob` is the kind's by
|
|
195
|
+
* position, and opens its channels only where none of `absent` — paths relative to a
|
|
196
|
+
* directory — closes it. The document is judged from its home, its own directory with a
|
|
197
|
+
* `.claude/` folder folded into the one holding it, and its position picks one of two
|
|
198
|
+
* gates: homed at the working directory, it loads at launch and any `absent` path there
|
|
199
|
+
* or above shuts it; homed in a subdirectory, it loads on demand and only that
|
|
200
|
+
* subdirectory's own `absent` paths shut it. The gate shuts reach, never membership, and
|
|
201
|
+
* an import still reaches the document.
|
|
202
|
+
*/
|
|
203
|
+
export interface GatedTemplate {
|
|
204
|
+
readonly glob: string;
|
|
205
|
+
readonly absent: readonly [string, ...string[]];
|
|
206
|
+
}
|
|
207
|
+
/** A file locus's several templates — one or more, in declared order. */
|
|
208
|
+
export type Templates = readonly [string | GatedTemplate, ...(string | GatedTemplate)[]];
|
|
209
|
+
/**
|
|
210
|
+
* An `at` locus's templates as a list of globs, in declared order — the one
|
|
211
|
+
* normalization of {@link Locus}'s `glob`, so no reader branches on its spellings.
|
|
212
|
+
*/
|
|
213
|
+
export declare function templatesOf(locus: {
|
|
214
|
+
readonly glob: string | Templates;
|
|
215
|
+
}): readonly string[];
|
|
216
|
+
/** The gated templates of an `at` locus, in declared order; empty for a locus gating none. */
|
|
217
|
+
export declare function absenceGatesOf(locus: {
|
|
218
|
+
readonly glob: string | Templates;
|
|
219
|
+
}): readonly GatedTemplate[];
|
|
119
220
|
/**
|
|
120
221
|
* One region of a kind's **layout** — one of the three corpus primitives over the
|
|
121
222
|
* body's heading tree. `prose` is a verbatim span, or an `import` reference resolving to
|
|
@@ -180,6 +281,8 @@ export type LeafSet<T extends object> = {
|
|
|
180
281
|
export interface CollectionAddress {
|
|
181
282
|
readonly keyPath: "hooks.<Event>" | "mcpServers.*" | "enabledPlugins.*" | "extraKnownMarketplaces.*";
|
|
182
283
|
readonly entryShape: string;
|
|
284
|
+
/** Retired: the manifest is the kind's starless `at` locus glob, stated once there. */
|
|
285
|
+
readonly manifest?: Remedy<"the manifest is the kind's `at` locus glob: delete `manifest`">;
|
|
183
286
|
}
|
|
184
287
|
/**
|
|
185
288
|
* A kind's **template** for one inner layer of nested members it hosts (fact 7): the
|
|
@@ -200,6 +303,18 @@ export interface Template {
|
|
|
200
303
|
/** Where a file child's unit sits, relative to the parent's unit; absent for an embedded layer. */
|
|
201
304
|
readonly path?: string;
|
|
202
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Per-field authoring counsel over a kind's typed surface `T` — one optional counsel per
|
|
308
|
+
* key of `T`, so a field the surface does not carry cannot be counselled. Advisory only:
|
|
309
|
+
* it never gates, and it reaches an author through the kind's path-scoped guidance rule.
|
|
310
|
+
*
|
|
311
|
+
* A surface with no fields resolves to `never`: the mapped object over no keys would be
|
|
312
|
+
* `{}`, which the compiler checks no excess property against, so the empty case is
|
|
313
|
+
* spelled as the refusal it is rather than left open to any key.
|
|
314
|
+
*/
|
|
315
|
+
export type FieldGuidance<T extends object> = [keyof T & string] extends [never] ? never : {
|
|
316
|
+
readonly [K in keyof T & string]?: string;
|
|
317
|
+
};
|
|
203
318
|
/**
|
|
204
319
|
* The seven facts of a kind's runtime residue, plus the derived {@link LeafSet} witness
|
|
205
320
|
* its typed surface hands over. `T` is that surface — the interface the kind's
|
|
@@ -223,6 +338,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
223
338
|
* (`src/compose.rs`'s `row_relocates_builtin`).
|
|
224
339
|
*/
|
|
225
340
|
readonly relocates?: string;
|
|
341
|
+
/** The kind this one is a **subkind** of, by name — set only by {@link extend} under a
|
|
342
|
+
* new name. It reaches the kind-fact row's `base` column. */
|
|
343
|
+
readonly base?: string;
|
|
226
344
|
/** Fact 2, locus — where members live, and for a file locus whether their documents
|
|
227
345
|
* are committed: a `local` commitment class declares the kind reviewed and its
|
|
228
346
|
* members' documents not. */
|
|
@@ -231,6 +349,8 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
231
349
|
}>;
|
|
232
350
|
/** Fact 3a, projection — the artifact format; omitted for a kind that declares none. */
|
|
233
351
|
readonly format?: Format;
|
|
352
|
+
/** The source malformations the kind's reader forgives; absent forgives none. */
|
|
353
|
+
readonly leniency?: readonly Leniency[];
|
|
234
354
|
/** Fact 3b, projection — the on-disk unit shape. */
|
|
235
355
|
readonly unitShape: UnitShape;
|
|
236
356
|
/** Fact 4, registration — the declared channel set naming every documented way
|
|
@@ -239,7 +359,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
239
359
|
/**
|
|
240
360
|
* The frontmatter key the member's name writes under. For `unitShape:
|
|
241
361
|
* "named-field"` this is the id **source** — the declared field a member's
|
|
242
|
-
* identity is read from (an agent's `name`), never the filename or directory
|
|
362
|
+
* identity is read from (an agent's `name`), never the filename or directory;
|
|
363
|
+
* for `"named-field-or-file"` it is read first, the file stem standing in where
|
|
364
|
+
* the field is absent (an output style's `name`).
|
|
243
365
|
* For `"directory"` it is a projection-order detail only (a skill's `name`
|
|
244
366
|
* still writes into frontmatter, but identity is the directory name); absent
|
|
245
367
|
* when identity is the file stem and no field carries it (a rule), or the
|
|
@@ -267,12 +389,20 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
267
389
|
* what a read verb renders where the surface holds no member of the kind yet.
|
|
268
390
|
* Absent for a kind whose constructor declares no witness. */
|
|
269
391
|
readonly leaves?: LeafSet<T>;
|
|
270
|
-
/** Advisory authoring counsel for the kind as a whole
|
|
271
|
-
*
|
|
392
|
+
/** Advisory authoring counsel for the kind as a whole, carrying no predicate or
|
|
393
|
+
* severity; it rides the kind's guidance rule over its locus. */
|
|
272
394
|
readonly guidance?: string;
|
|
273
395
|
/** External-fact source backing the guidance — a doc URL plus retrieved date,
|
|
274
396
|
* carried as data. */
|
|
275
397
|
readonly cite?: string;
|
|
398
|
+
/** The enforcement mode the guard holds this kind's members to, overriding the
|
|
399
|
+
* harness's; a member's own outranks it. Absent defers to the harness. */
|
|
400
|
+
readonly mode?: EnforcementMode;
|
|
401
|
+
/** Advisory counsel per field, keyed by the kind's typed surface `T` — a key naming a
|
|
402
|
+
* field the surface lacks fails `tsc` (decision 0091, bounded as 0078 bounds a leaf
|
|
403
|
+
* set). It carries no predicate and rides the kind's guidance rule beside the kind's
|
|
404
|
+
* own counsel, in the order the author wrote it. */
|
|
405
|
+
readonly fieldGuidance?: FieldGuidance<T>;
|
|
276
406
|
} | {
|
|
277
407
|
/** Fact 1, label — the compiled debug label findings speak; the kind's name. */
|
|
278
408
|
readonly name: string;
|
|
@@ -288,6 +418,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
288
418
|
* (`src/compose.rs`'s `row_relocates_builtin`).
|
|
289
419
|
*/
|
|
290
420
|
readonly relocates?: string;
|
|
421
|
+
/** The kind this one is a **subkind** of, by name — set only by {@link extend} under a
|
|
422
|
+
* new name. It reaches the kind-fact row's `base` column. */
|
|
423
|
+
readonly base?: string;
|
|
291
424
|
/** Fact 2, locus — where members live, and for a file locus whether their documents
|
|
292
425
|
* are committed: a `local` commitment class declares the kind reviewed and its
|
|
293
426
|
* members' documents not. */
|
|
@@ -301,11 +434,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
301
434
|
/** Fact 4, registration — derived, never declared: an embedded member registers
|
|
302
435
|
* nothing, so the locus already states the empty set and the lowering supplies it
|
|
303
436
|
* (`declarations.ts`). */
|
|
304
|
-
readonly registration?:
|
|
437
|
+
readonly registration?: Remedy<"an embedded locus registers nothing: delete `registration`">;
|
|
305
438
|
/**
|
|
306
439
|
* The frontmatter key the member's name writes under. For `unitShape:
|
|
307
440
|
* "named-field"` this is the id **source** — the declared field a member's
|
|
308
|
-
* identity is read from (an agent's `name`), never the filename or directory
|
|
441
|
+
* identity is read from (an agent's `name`), never the filename or directory;
|
|
442
|
+
* for `"named-field-or-file"` it is read first, the file stem standing in where
|
|
443
|
+
* the field is absent (an output style's `name`).
|
|
309
444
|
* For `"directory"` it is a projection-order detail only (a skill's `name`
|
|
310
445
|
* still writes into frontmatter, but identity is the directory name); absent
|
|
311
446
|
* when identity is the file stem and no field carries it (a rule), or the
|
|
@@ -323,7 +458,7 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
323
458
|
readonly shape?: Shape;
|
|
324
459
|
/** No collection address: a registration kind's manifest is its `at` locus, and
|
|
325
460
|
* this locus names no file. */
|
|
326
|
-
readonly collectionAddress?:
|
|
461
|
+
readonly collectionAddress?: Remedy<"a collection address keys inside an `at` locus's manifest: declare that locus or delete `collectionAddress`">;
|
|
327
462
|
/** Fact 7, template — one {@link Template} per inner layer of nested members the kind
|
|
328
463
|
* hosts; absent for a kind that nests nothing. */
|
|
329
464
|
readonly templates?: readonly Template[];
|
|
@@ -332,12 +467,20 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
332
467
|
* what a read verb renders where the surface holds no member of the kind yet.
|
|
333
468
|
* Absent for a kind whose constructor declares no witness. */
|
|
334
469
|
readonly leaves?: LeafSet<T>;
|
|
335
|
-
/** Advisory authoring counsel for the kind as a whole
|
|
336
|
-
*
|
|
470
|
+
/** Advisory authoring counsel for the kind as a whole, carrying no predicate or
|
|
471
|
+
* severity; it rides the kind's guidance rule over its locus. */
|
|
337
472
|
readonly guidance?: string;
|
|
338
473
|
/** External-fact source backing the guidance — a doc URL plus retrieved date,
|
|
339
474
|
* carried as data. */
|
|
340
475
|
readonly cite?: string;
|
|
476
|
+
/** The enforcement mode the guard holds this kind's members to, overriding the
|
|
477
|
+
* harness's; a member's own outranks it. Absent defers to the harness. */
|
|
478
|
+
readonly mode?: EnforcementMode;
|
|
479
|
+
/** Advisory counsel per field, keyed by the kind's typed surface `T` — a key naming a
|
|
480
|
+
* field the surface lacks fails `tsc` (decision 0091, bounded as 0078 bounds a leaf
|
|
481
|
+
* set). It carries no predicate and rides the kind's guidance rule beside the kind's
|
|
482
|
+
* own counsel, in the order the author wrote it. */
|
|
483
|
+
readonly fieldGuidance?: FieldGuidance<T>;
|
|
341
484
|
} | {
|
|
342
485
|
/** Fact 1, label — the compiled debug label findings speak; the kind's name. */
|
|
343
486
|
readonly name: string;
|
|
@@ -353,6 +496,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
353
496
|
* (`src/compose.rs`'s `row_relocates_builtin`).
|
|
354
497
|
*/
|
|
355
498
|
readonly relocates?: string;
|
|
499
|
+
/** The kind this one is a **subkind** of, by name — set only by {@link extend} under a
|
|
500
|
+
* new name. It reaches the kind-fact row's `base` column. */
|
|
501
|
+
readonly base?: string;
|
|
356
502
|
/** Fact 2, locus — where members live, and for a file locus whether their documents
|
|
357
503
|
* are committed: a `local` commitment class declares the kind reviewed and its
|
|
358
504
|
* members' documents not. */
|
|
@@ -361,16 +507,20 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
361
507
|
};
|
|
362
508
|
/** Fact 3a, projection — the artifact format; omitted for a kind that declares none. */
|
|
363
509
|
readonly format?: Format;
|
|
510
|
+
/** The source malformations the kind's reader forgives; absent forgives none. */
|
|
511
|
+
readonly leniency?: readonly Leniency[];
|
|
364
512
|
/** Fact 3b, projection — the on-disk unit shape. */
|
|
365
513
|
readonly unitShape: UnitShape;
|
|
366
514
|
/** Fact 4, registration — derived, never declared: a nested-file member registers
|
|
367
515
|
* nothing, so the locus already states the empty set and the lowering supplies it
|
|
368
516
|
* (`declarations.ts`). */
|
|
369
|
-
readonly registration?:
|
|
517
|
+
readonly registration?: Remedy<"a nested-file locus registers nothing: delete `registration`">;
|
|
370
518
|
/**
|
|
371
519
|
* The frontmatter key the member's name writes under. For `unitShape:
|
|
372
520
|
* "named-field"` this is the id **source** — the declared field a member's
|
|
373
|
-
* identity is read from (an agent's `name`), never the filename or directory
|
|
521
|
+
* identity is read from (an agent's `name`), never the filename or directory;
|
|
522
|
+
* for `"named-field-or-file"` it is read first, the file stem standing in where
|
|
523
|
+
* the field is absent (an output style's `name`).
|
|
374
524
|
* For `"directory"` it is a projection-order detail only (a skill's `name`
|
|
375
525
|
* still writes into frontmatter, but identity is the directory name); absent
|
|
376
526
|
* when identity is the file stem and no field carries it (a rule), or the
|
|
@@ -388,7 +538,7 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
388
538
|
readonly shape?: Shape;
|
|
389
539
|
/** No collection address: a registration kind's manifest is its `at` locus, and
|
|
390
540
|
* this locus names no file. */
|
|
391
|
-
readonly collectionAddress?:
|
|
541
|
+
readonly collectionAddress?: Remedy<"a collection address keys inside an `at` locus's manifest: declare that locus or delete `collectionAddress`">;
|
|
392
542
|
/** Fact 7, template — one {@link Template} per inner layer of nested members the kind
|
|
393
543
|
* hosts; absent for a kind that nests nothing. */
|
|
394
544
|
readonly templates?: readonly Template[];
|
|
@@ -397,12 +547,20 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
397
547
|
* what a read verb renders where the surface holds no member of the kind yet.
|
|
398
548
|
* Absent for a kind whose constructor declares no witness. */
|
|
399
549
|
readonly leaves?: LeafSet<T>;
|
|
400
|
-
/** Advisory authoring counsel for the kind as a whole
|
|
401
|
-
*
|
|
550
|
+
/** Advisory authoring counsel for the kind as a whole, carrying no predicate or
|
|
551
|
+
* severity; it rides the kind's guidance rule over its locus. */
|
|
402
552
|
readonly guidance?: string;
|
|
403
553
|
/** External-fact source backing the guidance — a doc URL plus retrieved date,
|
|
404
554
|
* carried as data. */
|
|
405
555
|
readonly cite?: string;
|
|
556
|
+
/** The enforcement mode the guard holds this kind's members to, overriding the
|
|
557
|
+
* harness's; a member's own outranks it. Absent defers to the harness. */
|
|
558
|
+
readonly mode?: EnforcementMode;
|
|
559
|
+
/** Advisory counsel per field, keyed by the kind's typed surface `T` — a key naming a
|
|
560
|
+
* field the surface lacks fails `tsc` (decision 0091, bounded as 0078 bounds a leaf
|
|
561
|
+
* set). It carries no predicate and rides the kind's guidance rule beside the kind's
|
|
562
|
+
* own counsel, in the order the author wrote it. */
|
|
563
|
+
readonly fieldGuidance?: FieldGuidance<T>;
|
|
406
564
|
};
|
|
407
565
|
/**
|
|
408
566
|
* A **declared input** — a file the member's claims rest on, fingerprinted by the lock
|
|
@@ -444,6 +602,8 @@ export interface Member {
|
|
|
444
602
|
readonly name: string;
|
|
445
603
|
/** The host member a nested-file child's path composes under; absent at every other locus. */
|
|
446
604
|
readonly host?: Member;
|
|
605
|
+
/** Where the member's file sits relative to its locus root, when its name is not placed whole. */
|
|
606
|
+
readonly location?: string;
|
|
447
607
|
/** The member's words. */
|
|
448
608
|
readonly prose?: Prose;
|
|
449
609
|
/** The kind's typed fields, flat and ordered — the projected frontmatter. */
|
|
@@ -451,11 +611,13 @@ export interface Member {
|
|
|
451
611
|
/** String keys naming the requirements this member fills. */
|
|
452
612
|
readonly satisfies: readonly string[];
|
|
453
613
|
/** Requirements the member itself publishes, by name. */
|
|
454
|
-
readonly requires: Readonly<Record<string,
|
|
614
|
+
readonly requires: Readonly<Record<string, RequirementValue>>;
|
|
455
615
|
/** The capabilities the member's behavior uses — the permission union's source. */
|
|
456
616
|
readonly needs: readonly Capability[];
|
|
457
617
|
/** The files this member's claims rest on — fingerprinted, never moved. */
|
|
458
618
|
readonly inputs: readonly Input[];
|
|
619
|
+
/** The member's own enforcement mode, outranking its kind's and the harness's. */
|
|
620
|
+
readonly mode?: EnforcementMode;
|
|
459
621
|
}
|
|
460
622
|
/**
|
|
461
623
|
* The bag a surface `T` declares its {@link RESIDUE_KEY} channel as — the keys `T` does
|
|
@@ -468,7 +630,7 @@ export interface Member {
|
|
|
468
630
|
* the collision again over the keys it actually holds ({@link orderedFields}).
|
|
469
631
|
*/
|
|
470
632
|
export type Residue<T> = Readonly<Record<string, unknown>> & {
|
|
471
|
-
readonly [K in keyof T]?:
|
|
633
|
+
readonly [K in keyof T]?: Remedy<`\`${K & string}\` is a typed field: write it beside \`residue\`, not in it`>;
|
|
472
634
|
};
|
|
473
635
|
/**
|
|
474
636
|
* The init a kind constructor takes — the framework keys plus the kind's typed fields `T`.
|
|
@@ -479,9 +641,16 @@ export type MemberInit<T> = {
|
|
|
479
641
|
readonly name: string;
|
|
480
642
|
/** The host member this member's unit composes under — a nested-file child's, and only its. */
|
|
481
643
|
readonly host?: Member;
|
|
644
|
+
/**
|
|
645
|
+
* Where the member's file sits, relative to its locus root (its kind's `locus` root,
|
|
646
|
+
* or its host's unit). Declared where no template places the name whole — a
|
|
647
|
+
* `:`-prefixed identity such as `apps:web:CLAUDE` sits at `apps/web/CLAUDE.md` — and
|
|
648
|
+
* agreeing with that prefix; never parsed out of the name.
|
|
649
|
+
*/
|
|
650
|
+
readonly location?: string;
|
|
482
651
|
readonly prose?: Prose;
|
|
483
652
|
readonly satisfies?: readonly string[];
|
|
484
|
-
readonly requires?: Readonly<Record<string,
|
|
653
|
+
readonly requires?: Readonly<Record<string, RequirementValue>>;
|
|
485
654
|
readonly needs?: readonly Capability[];
|
|
486
655
|
/**
|
|
487
656
|
* The files this member's claims rest on ({@link input}) — fingerprinted by the lock,
|
|
@@ -489,14 +658,18 @@ export type MemberInit<T> = {
|
|
|
489
658
|
* value takes no `MemberInit`, and its claims are its host's.
|
|
490
659
|
*/
|
|
491
660
|
readonly inputs?: readonly Input[];
|
|
661
|
+
/** The enforcement mode the guard holds this member to, outranking its kind's and the harness's. */
|
|
662
|
+
readonly mode?: EnforcementMode;
|
|
492
663
|
} & T;
|
|
493
664
|
/**
|
|
494
665
|
* A kind — a callable constructor carrying its seven facts. Calling it builds a
|
|
495
666
|
* member; `key` (its name) keys `expect` and a `kind` reference in a requirement.
|
|
496
|
-
* The value *is* the identity — it travels by import, never by string.
|
|
667
|
+
* The value *is* the identity — it travels by import, never by string. `Init` is the
|
|
668
|
+
* constructor's input, {@link MemberInit} over `T` unless a kind widens it with
|
|
669
|
+
* {@link Remedy} slots for fields that moved off its surface.
|
|
497
670
|
*/
|
|
498
|
-
export interface KindDefinition<T
|
|
499
|
-
(init:
|
|
671
|
+
export interface KindDefinition<T, Init = MemberInit<T>> {
|
|
672
|
+
(init: Init): Member;
|
|
500
673
|
readonly facts: KindFacts;
|
|
501
674
|
readonly key: string;
|
|
502
675
|
/**
|
|
@@ -509,7 +682,32 @@ export interface KindDefinition<T> {
|
|
|
509
682
|
* the default `[collection.entry]` TOML view.
|
|
510
683
|
*/
|
|
511
684
|
readonly render?: (value: ResolvedEmbeddedMemberValue) => string;
|
|
685
|
+
/**
|
|
686
|
+
* Where the **plain fields** an {@link extend} delta added live — every one named, so
|
|
687
|
+
* construction never projects it as a frontmatter key, and the delta's body `render`,
|
|
688
|
+
* when declared, which builds a member's body from its values. Set only by `extend`;
|
|
689
|
+
* absent on a kind declaring no added plain field.
|
|
690
|
+
*/
|
|
691
|
+
readonly body?: BodyPlacement;
|
|
512
692
|
}
|
|
693
|
+
/**
|
|
694
|
+
* The plain fields a kind's body holds rather than its frontmatter, and the render that
|
|
695
|
+
* places those a `"render"` placement names ({@link KindExtension.fields}). Erased at the
|
|
696
|
+
* emit seam like {@link KindDefinition.render}: a member reaches emit with the field out
|
|
697
|
+
* of its projected fields and its value already in its prose.
|
|
698
|
+
*/
|
|
699
|
+
export interface BodyPlacement {
|
|
700
|
+
/** Every added plain field, whichever placement holds it. */
|
|
701
|
+
readonly plain: readonly string[];
|
|
702
|
+
/** The member's body built from its values — the base's own render, then the delta's. */
|
|
703
|
+
readonly render?: (values: Readonly<Record<string, unknown>>) => Prose;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* The identity prefix a location spells: the directories the one `**` of the first
|
|
707
|
+
* template it fits spans, `:`-joined — the engine's read-side span over the same path.
|
|
708
|
+
* Empty where no template carries exactly one `**`, or the location fits none.
|
|
709
|
+
*/
|
|
710
|
+
export declare function locationPrefix(templates: readonly string[], location: string): string;
|
|
513
711
|
/** The options `kind()` takes beyond its seven facts — today, only the embedded `render` hook. */
|
|
514
712
|
export interface KindOptions {
|
|
515
713
|
readonly render?: (value: ResolvedEmbeddedMemberValue) => string;
|
|
@@ -525,8 +723,31 @@ export interface KindOptions {
|
|
|
525
723
|
* declared {@link LeafSet} witness to `keyof T`: the leaf set is the kind's own surface,
|
|
526
724
|
* checked here at the keystroke, and its lowering to the row is the one place it is
|
|
527
725
|
* spelled again (`declarations.ts`).
|
|
726
|
+
*
|
|
727
|
+
* One overload per locus: {@link KindFacts} discriminates on the nested `locus.kind`,
|
|
728
|
+
* which the compiler cannot narrow a union by, so a single union parameter reports a
|
|
729
|
+
* wrong field against an arbitrary branch. Per-locus overloads let it judge the branch
|
|
730
|
+
* the author wrote, and that branch's {@link Remedy} slots are what its error prints.
|
|
528
731
|
*/
|
|
529
|
-
export declare function kind<T extends object>(typed: KindFacts<T>,
|
|
732
|
+
export declare function kind<T extends object>(typed: Extract<KindFacts<T>, {
|
|
733
|
+
readonly locus: {
|
|
734
|
+
readonly kind: "at";
|
|
735
|
+
};
|
|
736
|
+
}>, options?: KindOptions): KindDefinition<T>;
|
|
737
|
+
export declare function kind<T extends object>(typed: Extract<KindFacts<T>, {
|
|
738
|
+
readonly locus: {
|
|
739
|
+
readonly kind: "embedded";
|
|
740
|
+
};
|
|
741
|
+
}>, options?: KindOptions): KindDefinition<T>;
|
|
742
|
+
export declare function kind<T extends object>(typed: Extract<KindFacts<T>, {
|
|
743
|
+
readonly locus: {
|
|
744
|
+
readonly kind: "nested-file";
|
|
745
|
+
};
|
|
746
|
+
}>, options?: KindOptions): KindDefinition<T>;
|
|
747
|
+
/** A kind's registration channel set — declared on an `at` locus, empty on every other. */
|
|
748
|
+
export declare function registrationOf(facts: KindFacts): readonly Registration[];
|
|
749
|
+
/** A kind's collection address — only an `at` locus names a manifest to key inside. */
|
|
750
|
+
export declare function collectionAddressOf(facts: KindFacts): CollectionAddress | undefined;
|
|
530
751
|
/**
|
|
531
752
|
* The host manifest a registration kind surfaces in — its `at` locus glob, which must
|
|
532
753
|
* name exactly one file (no `*`): a starred glob governs a family of files, and a
|
|
@@ -538,25 +759,31 @@ export declare function kind<T extends object>(typed: KindFacts<T>, options?: Ki
|
|
|
538
759
|
export declare function manifestOf(facts: KindFacts): string;
|
|
539
760
|
/**
|
|
540
761
|
* A **relocation delta** — the facts a relocated built-in kind diverges from its base
|
|
541
|
-
* on.
|
|
762
|
+
* on. Four faces, any one or more:
|
|
542
763
|
*
|
|
543
764
|
* - `edgeFields`, *added* to whatever the base already declares (never replacing them,
|
|
544
765
|
* which would drop a shipped kind's own edges silently). Each added field names a key
|
|
545
766
|
* of the relocated kind's typed surface `T`, so an edge can never be declared over a
|
|
546
767
|
* field the kind does not carry.
|
|
547
|
-
* - `
|
|
768
|
+
* - `locus`, *replacing* the base's `at` locus root and glob — moving where the kind's
|
|
548
769
|
* members are found, the one fact the engine's own overlay exists to apply
|
|
549
770
|
* (`src/compose.rs`'s `overlay_builtin_kind`).
|
|
771
|
+
* - `exclude`, *appended* to the base exclusions the (possibly moved) locus still
|
|
772
|
+
* reaches — leaving paths the built-in would claim ungoverned (decision 0085).
|
|
773
|
+
* - `guidance`, `fieldGuidance` and `cite`, *replacing* the base's counsel — the
|
|
774
|
+
* relocated kind's guidance rule carries exactly what the relocation declares, and a
|
|
775
|
+
* relocation declaring none carries none: a built-in's own shipped counsel never
|
|
776
|
+
* projects into an adopter's harness (decision 0091).
|
|
550
777
|
*
|
|
551
778
|
* Every other fact — format, unit shape, registration, content, templates, the declared
|
|
552
779
|
* leaf set — rides through unchanged, which is exactly what makes the emitted row still
|
|
553
780
|
* read as a relocation rather than a name collision on the reading side.
|
|
554
781
|
*/
|
|
555
|
-
export interface KindRelocation<T> {
|
|
782
|
+
export interface KindRelocation<T extends object> {
|
|
556
783
|
/** The edge fields this relocation adds, each over a field of the kind's own surface. */
|
|
557
784
|
readonly edgeFields?: readonly {
|
|
558
785
|
readonly field: keyof T & string;
|
|
559
|
-
readonly to:
|
|
786
|
+
readonly to: EdgeField["to"];
|
|
560
787
|
}[];
|
|
561
788
|
/**
|
|
562
789
|
* The locus this relocation moves the kind's members to — root and glob, the two
|
|
@@ -565,28 +792,50 @@ export interface KindRelocation<T> {
|
|
|
565
792
|
* a `commitment` delta would author a fact the reader drops in silence — a built-in's
|
|
566
793
|
* commitment class stays the built-in's.
|
|
567
794
|
*/
|
|
568
|
-
readonly
|
|
795
|
+
readonly locus?: {
|
|
569
796
|
readonly root: string;
|
|
570
|
-
readonly glob: string;
|
|
797
|
+
readonly glob: string | Templates;
|
|
571
798
|
};
|
|
799
|
+
/**
|
|
800
|
+
* Paths the relocated kind leaves ungoverned, *appended* to the base exclusions its
|
|
801
|
+
* template (moved or not) still reaches — the way an author answers a collision with a
|
|
802
|
+
* built-in, or leaves a fixture tree holding harness files ungoverned. Each is spelled
|
|
803
|
+
* as {@link Locus}'s `exclude` is: a starless, harness-relative literal the template
|
|
804
|
+
* matches, or a bare directory it reaches beneath. Only an `at` kind carries a locus
|
|
805
|
+
* to exclude from.
|
|
806
|
+
*/
|
|
807
|
+
readonly exclude?: readonly string[];
|
|
808
|
+
/** Counsel for the relocated kind as a whole, projected as its path-scoped guidance rule. */
|
|
809
|
+
readonly guidance?: string;
|
|
810
|
+
/** Counsel per field of the relocated kind's surface, riding the same rule. */
|
|
811
|
+
readonly fieldGuidance?: FieldGuidance<T>;
|
|
812
|
+
/** External-fact source backing the relocation's guidance. */
|
|
813
|
+
readonly cite?: string;
|
|
814
|
+
/** The enforcement mode the guard holds the kind's members to; absent keeps the base's. */
|
|
815
|
+
readonly mode?: EnforcementMode;
|
|
572
816
|
}
|
|
817
|
+
/** A file locus as one harness-relative template, a root-locus kind's `.` dropped. */
|
|
818
|
+
export declare function locusPattern(root: string, glob: string): string;
|
|
573
819
|
/**
|
|
574
820
|
* **Relocate** a built-in kind: the sanctioned way an adopting corpus moves a kind it
|
|
575
|
-
* does not own to its own root, adds an edge field to it,
|
|
576
|
-
* constructor over the widened typed surface `T` (the
|
|
577
|
-
* fields, spelled by the caller as one interface),
|
|
578
|
-
* `delta`'s edge fields appended, `delta`'s `
|
|
579
|
-
*
|
|
821
|
+
* does not own to its own root, adds an edge field to it, excludes paths from it, or any
|
|
822
|
+
* combination. Returns a fresh constructor over the widened typed surface `T` (the
|
|
823
|
+
* base's fields plus the added edge fields, spelled by the caller as one interface),
|
|
824
|
+
* carrying the base's facts with `delta`'s edge fields appended, `delta`'s `locus` in
|
|
825
|
+
* place of the base's locus root and glob, `delta`'s `exclude` appended to the locus's
|
|
826
|
+
* exclusions, and the base's own {@link KindDefinition.render} hook preserved. Ownership,
|
|
580
827
|
* not privilege — a relocated built-in is an ordinary kind value from here on, and its
|
|
581
828
|
* added edge reaches the lock as an assembly `edge` row keyed by `from`, exactly as any
|
|
582
829
|
* kind's does (`declarations.ts`), never as a column on a kind-fact row.
|
|
583
830
|
*
|
|
584
831
|
* A moved locus, by contrast, *is* a kind-fact row column pair: the emitted row carries
|
|
585
|
-
* the delta's `
|
|
832
|
+
* the delta's `locus_root`/`locus_glob` while `format`, `unit_shape` and
|
|
586
833
|
* `registration` stay the base's — which is precisely the three-fact test the lock
|
|
587
834
|
* reader applies before overlaying the row onto its compiled-in built-in
|
|
588
835
|
* (`src/compose.rs`'s `row_relocates_builtin`), so the engine reads members at the new
|
|
589
|
-
* root rather than treating the row as a colliding kind.
|
|
836
|
+
* root rather than treating the row as a colliding kind. An `exclude` delta rides the
|
|
837
|
+
* same row's `exclude` column — the reached base exclusions, then the authored ones —
|
|
838
|
+
* which the overlay writes back whole.
|
|
590
839
|
*
|
|
591
840
|
* The produced facts carry `relocates`, naming the base — the marker that tells a
|
|
592
841
|
* legitimate relocation from a genuine name collision when two same-named kinds are in
|
|
@@ -596,13 +845,94 @@ export interface KindRelocation<T> {
|
|
|
596
845
|
* # Throws
|
|
597
846
|
* If an added edge field re-declares one the base already carries, or one another
|
|
598
847
|
* entry of the same delta already added — two `edge` rows over one `<from, field>`
|
|
599
|
-
* cross-wire the graph instead of declaring one relationship. If a `
|
|
600
|
-
* names a base whose locus is not `at` ({@link relocatedLocus})
|
|
601
|
-
*
|
|
848
|
+
* cross-wire the graph instead of declaring one relationship. If a `locus` delta
|
|
849
|
+
* names a base whose locus is not `at` ({@link relocatedLocus}), or an `exclude` delta
|
|
850
|
+
* does, or names a path the locus cannot subtract ({@link excludedLocus}). And if the
|
|
851
|
+
* delta declares no face, which would mint a marker-bearing clone of the base — a second
|
|
602
852
|
* same-named kind diverging on nothing, which is a name collision spelled as a
|
|
603
853
|
* relocation.
|
|
604
854
|
*/
|
|
605
855
|
export declare function relocate<T extends object>(base: KindDefinition<any>, delta: KindRelocation<T>): KindDefinition<T>;
|
|
856
|
+
/**
|
|
857
|
+
* The witness that an extension's surface `T` keeps every field of its base's `B` —
|
|
858
|
+
* `unknown` when it does, a {@link Remedy} the delta cannot supply when it drops one.
|
|
859
|
+
* `T extends B` alone admits dropping an *optional* base field (a surface without it is
|
|
860
|
+
* still assignable), so the keys are compared on their own.
|
|
861
|
+
*/
|
|
862
|
+
export type KeepsBaseSurface<B, T> = [Exclude<keyof B, keyof T>] extends [never] ? unknown : {
|
|
863
|
+
readonly droppedBaseFields: Remedy<"a subkind keeps every field of its base's surface — extend the base's interface rather than omit one of its fields">;
|
|
864
|
+
};
|
|
865
|
+
/**
|
|
866
|
+
* An **extension delta** — a {@link KindRelocation} plus an optional `name`. A name other
|
|
867
|
+
* than the base's mints a subkind; none (or the base's own) is a relocation.
|
|
868
|
+
*/
|
|
869
|
+
export interface KindExtension<T extends object> extends KindRelocation<T> {
|
|
870
|
+
/** The subkind's name; omitted, the extension relocates the base under its own. */
|
|
871
|
+
readonly name?: string;
|
|
872
|
+
/**
|
|
873
|
+
* The **plain fields** this extension adds over the widened surface `T`, each with the
|
|
874
|
+
* place the base's format admits it — never a new frontmatter key, which the base's
|
|
875
|
+
* documented format does not carry:
|
|
876
|
+
*
|
|
877
|
+
* - `"region"` — a `field` region of the base's declared {@link Layout} whose slot is
|
|
878
|
+
* the field's name; the member's body holds it under that heading, read as the base
|
|
879
|
+
* reads it.
|
|
880
|
+
* - `"render"` — this delta's body {@link KindExtension.render}, which builds the
|
|
881
|
+
* member's body from its values; admitted where the base's body is one verbatim
|
|
882
|
+
* prose value (`file` content).
|
|
883
|
+
*/
|
|
884
|
+
readonly fields?: {
|
|
885
|
+
readonly [K in keyof T & string]?: "region" | "render";
|
|
886
|
+
};
|
|
887
|
+
/**
|
|
888
|
+
* The extension's body **render** — the template a member's body is built from: its
|
|
889
|
+
* typed values in (the `"render"`-placed fields and its own `prose` among them), its
|
|
890
|
+
* body out. Declared only beside a `"render"`-placed field. Over a base that renders its
|
|
891
|
+
* own body, the base's render builds the `prose` this one receives.
|
|
892
|
+
*/
|
|
893
|
+
readonly render?: (values: T) => Prose;
|
|
894
|
+
/**
|
|
895
|
+
* A **subkind of a nested or embedded kind** this host names as its child: the host's
|
|
896
|
+
* template layer whose child is `template`'s base takes `template` in its place, keeping
|
|
897
|
+
* the layer's path, and so does a layout collection of an embedded base. A nested
|
|
898
|
+
* member's kind is its host's, so this is the one way to place a nested subkind's
|
|
899
|
+
* members — it declares no locus of its own.
|
|
900
|
+
*/
|
|
901
|
+
readonly template?: KindDefinition<any>;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* **Extend** a kind. Under a new `name` the result is a **subkind**: it keeps the base's
|
|
905
|
+
* facts, adds `delta`'s edge fields, plain fields and counsel, governs a locus within the
|
|
906
|
+
* base's (the base's own unless `locus` moves it), and names the base in its `base`
|
|
907
|
+
* fact — the engine then reads a document in that locus as the subkind's one member.
|
|
908
|
+
* Under the base's name it is the relocation {@link relocate} documents, the same
|
|
909
|
+
* operation.
|
|
910
|
+
*
|
|
911
|
+
* A plain field lives where the base's format admits it ({@link KindExtension.fields}):
|
|
912
|
+
* a `field` region of the base's layout, or the body the delta's `render` builds. Either
|
|
913
|
+
* way a member never projects it as a frontmatter key, so the subkind's kind-fact row and
|
|
914
|
+
* its members' headers stay the base's documented format.
|
|
915
|
+
*
|
|
916
|
+
* The surface is typed: `T extends B` and {@link KeepsBaseSurface} make `tsc` refuse a
|
|
917
|
+
* delta whose surface retypes or drops a base field, optional ones included — every
|
|
918
|
+
* selection of the base binds the subkind's documents, so its members must read as the
|
|
919
|
+
* base's. Spell both: `extend<Rule, Standard>(rule, { … })`.
|
|
920
|
+
*
|
|
921
|
+
* # Throws
|
|
922
|
+
* As {@link relocate}; for a subkind, if a nested or embedded base's subkind declares a
|
|
923
|
+
* locus, or an `at` subkind's locus does not lie within its base's; if a `template` names
|
|
924
|
+
* no subkind of a layer or collection the host holds; and if a plain field has no place the base's format
|
|
925
|
+
* admits, or a `render` places none ({@link placedBody}).
|
|
926
|
+
*/
|
|
927
|
+
export declare function extend<B extends object, T extends B>(base: KindDefinition<B, any>, delta: KindExtension<T> & KeepsBaseSurface<B, T>): KindDefinition<T>;
|
|
928
|
+
/** The kind `facts` is a subkind of, by identity, or `undefined` for a kind {@link extend} minted no subkind from. */
|
|
929
|
+
export declare function baseOf(facts: KindFacts): KindFacts | undefined;
|
|
930
|
+
/**
|
|
931
|
+
* Whether `facts` is `ancestor`'s own facts or a subkind's anywhere down its
|
|
932
|
+
* {@link extend} chain. Identity travels by import: a same-named kind defined apart is
|
|
933
|
+
* no descendant.
|
|
934
|
+
*/
|
|
935
|
+
export declare function extendsKind(facts: KindFacts, ancestor: KindFacts): boolean;
|
|
606
936
|
/**
|
|
607
937
|
* One entry in a sibling collection: its own key plus its leaf fields
|
|
608
938
|
* (`rejected."baked-projection"`) — an ordered list element, never a positional
|
|
@@ -696,8 +1026,7 @@ export interface ResolvedEmbeddedMemberValue {
|
|
|
696
1026
|
* The target facts of each edge field this value *fills and resolves*, keyed by the edge
|
|
697
1027
|
* field's own name — the data a `render` hook selects to spell a reference. Two cases
|
|
698
1028
|
* read absent: an unfilled field (no edge at all), and a kind declaring no edge fields —
|
|
699
|
-
* or a value composed off a bare kind name, which carries none. A
|
|
700
|
-
* reference off such a key must therefore handle its absence. A third derives no facts
|
|
1029
|
+
* or a value composed off a bare kind name, which carries none. A third derives no facts
|
|
701
1030
|
* but does not read absent: a filled field whose target defers to `check`, naming a
|
|
702
1031
|
* declared `at`-locus kind's uncomposed member (`pipeline.md`, "Emit", the "Refusing"
|
|
703
1032
|
* bullet) — reading it refuses by name at emit, naming the member, the value, the field
|
|
@@ -727,3 +1056,4 @@ export declare function embeddedMemberValue(init: {
|
|
|
727
1056
|
leaves: Readonly<Record<string, string | Text>>;
|
|
728
1057
|
collections?: EmbeddedMemberValue["collections"];
|
|
729
1058
|
}): EmbeddedMemberValue;
|
|
1059
|
+
export {};
|