@dtmd/temper 0.0.23 → 0.0.24

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.
@@ -64,7 +64,7 @@ export const rootDefaultContract = [
64
64
  }),
65
65
  clause(fresh(), {
66
66
  severity: "advisory",
67
- guidance: "A lock row this member owns no longer matches disk: either its committed projection was hand-edited, or a fingerprinted source dependency it imports or includes has moved. Nothing reverse-parses a projection back into the program, so the two sides stay apart until you reconcile them: edit the owning source and re-emit, and for a moved dependency re-verify the member's claims against the new bytes first. Advisory because a drifted checkout is usually one `emit` away and blocking every such run would be temper's escalation, not yours; dial this label to `required` — or re-declare the clause — once a drifted projection should fail CI.",
67
+ guidance: "A lock row this member owns no longer matches disk: either its committed projection was hand-edited, or a fingerprinted source dependency has moved: a layout import, a prose include, a declared input, or — on the root member — a module the program itself loaded. Nothing reverse-parses a projection back into the program, so the two sides stay apart until you reconcile them: edit the owning source and re-emit, and for a moved declared input re-verify the member's claims against the new bytes first. Advisory because a drifted checkout is usually one `emit` away and blocking every such run would be temper's escalation, not yours; dial this label to `required` — or re-declare the clause — once a drifted projection should fail CI.",
68
68
  }),
69
69
  clause(locusDeclared(), {
70
70
  severity: "advisory",
@@ -9,7 +9,7 @@
9
9
  * `@dtmd/temper/claude-code` subpath
10
10
  * — never from the root.
11
11
  */
12
- import type { KindDefinition, Residue } from "./kind.js";
12
+ import type { KindDefinition, Member, Residue } from "./kind.js";
13
13
  import type { Prose } from "./prose.js";
14
14
  import type { Clause } from "./contract.js";
15
15
  /** A Claude Code skill — a directory whose entry file is `SKILL.md` with YAML frontmatter. */
@@ -134,6 +134,9 @@ export interface SupportingDoc {
134
134
  * file is body), identity from the filename, and channel-less: a supporting file reaches
135
135
  * the world only through the skill whose body references it, never on a channel of its
136
136
  * own (code.claude.com/docs/en/skills, "Add supporting files", retrieved 2026-07-16).
137
+ * The locus is the host's: "Skills can include multiple files in their directory", the
138
+ * documented layout placing `reference.md` and `examples.md` beside `SKILL.md`
139
+ * (code.claude.com/docs/en/skills, "Add supporting files", retrieved 2026-11-24).
137
140
  */
138
141
  export declare const supportingDoc: KindDefinition<SupportingDoc>;
139
142
  /**
@@ -150,6 +153,10 @@ export declare const supportingDoc: KindDefinition<SupportingDoc>;
150
153
  * files"). The pattern claims the markdown subset the prose-only child kind can hold —
151
154
  * a supporting file of another type (the docs' own `scripts/helper.py`) matches nothing
152
155
  * and stays unmodeled rather than mis-typed.
156
+ *
157
+ * The locus is the project row of the documented load table,
158
+ * `.claude/skills/<skill-name>/SKILL.md` (code.claude.com/docs/en/skills, "Choose where
159
+ * skills load", retrieved 2026-11-24).
153
160
  */
154
161
  export declare const skill: KindDefinition<Skill>;
155
162
  /**
@@ -158,6 +165,10 @@ export declare const skill: KindDefinition<Skill>;
158
165
  * retrieved 2026-07-15): a lone file (identity from the stem, so no
159
166
  * `identityField` — like `rule`), the skill's field schema by import, registering
160
167
  * on the same two documented invocation channels as `skill`.
168
+ *
169
+ * The locus is the documented placement: "a Markdown file in `.claude/commands/` is the
170
+ * older format and still works" (code.claude.com/docs/en/skills, "Choose where skills
171
+ * load", retrieved 2026-11-24).
161
172
  */
162
173
  export declare const command: KindDefinition<Skill>;
163
174
  /** A Claude Code subagent definition. */
@@ -254,7 +265,10 @@ export interface Agent {
254
265
  * `name` then `description`; identity is the `name` field (never the filename),
255
266
  * the named-field mode; registers on the description-trigger channel only — no
256
267
  * user-invoked slash command (code.claude.com/docs/en/sub-agents, retrieved
257
- * 2026-07-15).
268
+ * 2026-07-15). The locus is the project row, `.claude/agents/`, and recurses: "Claude
269
+ * Code scans `.claude/agents/` and `~/.claude/agents/` recursively, so you can organize
270
+ * definitions into subfolders" (code.claude.com/docs/en/sub-agents, "Choose the subagent
271
+ * scope", retrieved 2026-11-24).
258
272
  */
259
273
  export declare const agent: KindDefinition<Agent>;
260
274
  /** A Claude Code rule — a flat markdown file with an optional `paths` scope. */
@@ -267,9 +281,11 @@ export interface Rule {
267
281
  readonly prose?: Prose;
268
282
  }
269
283
  /**
270
- * `rule` — `.claude/rules/<name>.md`, a lone file (identity from the stem), YAML
271
- * frontmatter; registers a path scope (code.claude.com/docs/en/memory, retrieved
272
- * 2026-07-15).
284
+ * `rule` — a `<name>.md` at any depth under `.claude/rules/`, a lone file (identity
285
+ * from the stem), YAML frontmatter; registers a path scope
286
+ * (code.claude.com/docs/en/memory, retrieved 2026-07-15). The locus recurses: "All `.md` files are discovered recursively, so
287
+ * you can organize rules into subdirectories like `frontend/` or `backend/`"
288
+ * (code.claude.com/docs/en/memory, "Organize rules with `.claude/rules/`", retrieved 2026-11-24).
273
289
  */
274
290
  export declare const rule: KindDefinition<Rule>;
275
291
  /** A Claude Code memory file — `CLAUDE.md`, loaded in full at launch, no frontmatter. */
@@ -283,7 +299,15 @@ export interface Memory {
283
299
  * `format`. A project `CLAUDE.md` may sit at either `./CLAUDE.md` or
284
300
  * `./.claude/CLAUDE.md` — equal documented locations (same source) — and the
285
301
  * any-depth locus (a `CLAUDE.md` at any directory) covers both; a
286
- * module-carried memory projects the root file.
302
+ * module-carried memory projects the root file. The locus is the project row,
303
+ * "`./CLAUDE.md` or `./.claude/CLAUDE.md`", at any depth because "Claude also discovers
304
+ * `CLAUDE.md` and `CLAUDE.local.md` files in subdirectories under your current working
305
+ * directory" (code.claude.com/docs/en/memory, "Choose where to put CLAUDE.md files" and
306
+ * "How CLAUDE.md files load", retrieved 2026-11-24). The locus excludes the `.claude/`
307
+ * folders another built-in loader owns — `agents`, `commands`, `rules`, `skills`: the
308
+ * memory docs describe no `CLAUDE.md` inside them loading as memory, and the rules
309
+ * loader discovers every `.md` under `.claude/rules/` recursively
310
+ * (code.claude.com/docs/en/memory, retrieved 2026-11-24; decision 0084).
287
311
  */
288
312
  export declare const memory: KindDefinition<Memory>;
289
313
  /**
@@ -418,6 +442,52 @@ export declare function hookCollectionKey(name: string): string;
418
442
  /** The authored `hook` constructor — {@link hookGroup}'s facts over {@link hookMember}'s
419
443
  * name composition. */
420
444
  export declare const hook: KindDefinition<Hook>;
445
+ /**
446
+ * The lifecycle events temper's own gate rides — the session-start report and the guard's
447
+ * two edges. A gate hook on any other event fires no temper verb, so the type refuses it.
448
+ */
449
+ export type GateHookEvent = "SessionStart" | "PreToolUse" | "PostToolUse";
450
+ /**
451
+ * A gate hook's authored surface: the event and matcher that place its matcher group, and
452
+ * the one fact the member states — the temper `binary` it runs. Absent, the binary is
453
+ * `temper` on the PATH; a workspace install states its path instead
454
+ * (`"./node_modules/.bin/temper"`). The command is never authored: the engine renders it
455
+ * from the binary at emit, so the bytes a gate hook runs have one home
456
+ * (specs/model/adoption.md, "Install"; decision 0082).
457
+ */
458
+ export interface GateHookInit {
459
+ /** The lifecycle event — the member's `name`, as on {@link hook}. */
460
+ readonly name: GateHookEvent;
461
+ /** The tool-name filter the group binds, as on {@link Hook}; absent on `SessionStart`. */
462
+ readonly matcher?: string;
463
+ /** The temper binary the hook runs — a name resolved on the PATH, or a path. */
464
+ readonly binary?: string;
465
+ }
466
+ /**
467
+ * The key a gate hook's registration row carries its declared binary under — the engine's
468
+ * `GATE_BINARY_KEY` (`src/drift.rs`), which consumes it at emit and renders the handler's
469
+ * command in its place. Colon-qualified so no typed {@link Hook} field can spell it.
470
+ * `null` is a gate hook declaring no binary, so the default (`temper`) has one spelling,
471
+ * the engine's.
472
+ */
473
+ export declare const GATE_BINARY_KEY = "temper:gate-binary";
474
+ /**
475
+ * A temper gate hook — a {@link hook} member whose single `command` handler runs the
476
+ * temper verb its event fires, with the binary it states. The member is an ordinary
477
+ * matcher group in every other respect: its name joins its matcher as any hook's does,
478
+ * and a tap hook at the same event and matcher joins it as a further handler.
479
+ *
480
+ * # Throws
481
+ * If `binary` is the empty string — there is nothing to run — or the matcher carries a
482
+ * `/` ({@link hook}).
483
+ */
484
+ export declare function gateHook(init: GateHookInit): Member;
485
+ /**
486
+ * The binary a gate hook member declares — `null` where it declares none (`temper` on the
487
+ * PATH) — or `undefined` where `member` is not a gate hook at all. The one reader is the
488
+ * registration erasure (`declarations.ts`), which carries it under {@link GATE_BINARY_KEY}.
489
+ */
490
+ export declare function gateHookBinary(member: Member): string | null | undefined;
421
491
  /**
422
492
  * The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
423
493
  * provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
@@ -662,7 +732,9 @@ export interface PluginManifest {
662
732
  * It owns its file, so it carries no collection address, and it is channel-less: a
663
733
  * manifest carries distribution metadata rather than session content, so it reaches the
664
734
  * model on no channel of its own — what it reaches is the installer
665
- * (code.claude.com/docs/en/plugins-reference, retrieved 2026-07-16).
735
+ * (code.claude.com/docs/en/plugins-reference, retrieved 2026-07-16). The locus is the
736
+ * documented one: "Save the manifest at `.claude-plugin/plugin.json` under the plugin
737
+ * root" (code.claude.com/docs/en/plugins-reference, "Manifest file", retrieved 2026-11-24).
666
738
  */
667
739
  export declare const pluginManifest: KindDefinition<PluginManifest>;
668
740
  /**
@@ -805,7 +877,10 @@ export interface Marketplace {
805
877
  * stem is `marketplace` for every catalog ever written. Like its `plugin-manifest`
806
878
  * sibling it owns its file (no collection address) and is channel-less: a catalog is read
807
879
  * by the installer, never surfaced to the model
808
- * (code.claude.com/docs/en/plugin-marketplaces, retrieved 2026-07-16).
880
+ * (code.claude.com/docs/en/plugin-marketplaces, retrieved 2026-07-16). The locus is the
881
+ * documented one: a marketplace is "a directory or repository with a
882
+ * `.claude-plugin/marketplace.json` file" (code.claude.com/docs/en/plugin-marketplaces,
883
+ * "Create a marketplace", retrieved 2026-11-24).
809
884
  */
810
885
  export declare const marketplace: KindDefinition<Marketplace>;
811
886
  /**
@@ -888,7 +963,9 @@ export interface SettingsLocal {
888
963
  * key names it). The keys it does not type ride {@link SettingsLocal.residue}, the opaque
889
964
  * channel 0036's partial governance names. Channel-less: machine configuration read by the
890
965
  * harness, never surfaced to the model (code.claude.com/docs/en/settings, retrieved
891
- * 2026-07-16; decisions 0032/0034/0036).
966
+ * 2026-07-16; decisions 0032/0034/0036). The locus is the "Project local" row,
967
+ * `.claude/settings.local.json`, which "Claude Code keeps … out of git"
968
+ * (code.claude.com/docs/en/settings, "Settings files and who they affect", retrieved 2026-11-24).
892
969
  */
893
970
  export declare const settingsLocal: KindDefinition<SettingsLocal>;
894
971
  /**
@@ -980,6 +1057,10 @@ export interface Settings {
980
1057
  * address order, then the residue — which the member itself authors through
981
1058
  * {@link Settings.residue}, flat and key-sorted behind its typed fields
982
1059
  * (code.claude.com/docs/en/settings, retrieved 2026-09-22).
1060
+ *
1061
+ * The locus is the "Shared project" row, `.claude/settings.json` — "In a git repository,
1062
+ * commit it so teammates get it" (code.claude.com/docs/en/settings, "Settings files and
1063
+ * who they affect", retrieved 2026-11-24).
983
1064
  */
984
1065
  export declare const settings: KindDefinition<Settings>;
985
1066
  /**
@@ -1038,7 +1119,9 @@ export interface Mcp {
1038
1119
  * its own kind ({@link mcpServer}). That segment and this member's opaque residue are one
1039
1120
  * file: emit renders the declared segment first, then the residue — which the member itself
1040
1121
  * authors through {@link Mcp.residue}, flat and key-sorted
1041
- * (code.claude.com/docs/en/mcp, retrieved 2026-09-29).
1122
+ * (code.claude.com/docs/en/mcp, retrieved 2026-09-29). The locus is the project root:
1123
+ * "add the entry under `mcpServers` in `.mcp.json` at your project root and commit it"
1124
+ * (code.claude.com/docs/en/mcp, "Add a server from an `mcpServers` JSON block", retrieved 2026-11-24).
1042
1125
  */
1043
1126
  export declare const mcp: KindDefinition<Mcp>;
1044
1127
  /**
@@ -20,12 +20,14 @@ import { allowedChars, clause, closedKeys, degree, deny, enumOf, extent, forbidd
20
20
  * file is body), identity from the filename, and channel-less: a supporting file reaches
21
21
  * the world only through the skill whose body references it, never on a channel of its
22
22
  * own (code.claude.com/docs/en/skills, "Add supporting files", retrieved 2026-07-16).
23
+ * The locus is the host's: "Skills can include multiple files in their directory", the
24
+ * documented layout placing `reference.md` and `examples.md` beside `SKILL.md`
25
+ * (code.claude.com/docs/en/skills, "Add supporting files", retrieved 2026-11-24).
23
26
  */
24
27
  export const supportingDoc = kind({
25
28
  name: "supporting-doc",
26
29
  locus: { kind: "nested-file" },
27
30
  unitShape: "file",
28
- registration: [],
29
31
  });
30
32
  /**
31
33
  * `skill` — `.claude/skills/<name>/SKILL.md`, a directory unit, YAML frontmatter
@@ -41,6 +43,10 @@ export const supportingDoc = kind({
41
43
  * files"). The pattern claims the markdown subset the prose-only child kind can hold —
42
44
  * a supporting file of another type (the docs' own `scripts/helper.py`) matches nothing
43
45
  * and stays unmodeled rather than mis-typed.
46
+ *
47
+ * The locus is the project row of the documented load table,
48
+ * `.claude/skills/<skill-name>/SKILL.md` (code.claude.com/docs/en/skills, "Choose where
49
+ * skills load", retrieved 2026-11-24).
44
50
  */
45
51
  export const skill = kind({
46
52
  name: "skill",
@@ -58,6 +64,10 @@ export const skill = kind({
58
64
  * retrieved 2026-07-15): a lone file (identity from the stem, so no
59
65
  * `identityField` — like `rule`), the skill's field schema by import, registering
60
66
  * on the same two documented invocation channels as `skill`.
67
+ *
68
+ * The locus is the documented placement: "a Markdown file in `.claude/commands/` is the
69
+ * older format and still works" (code.claude.com/docs/en/skills, "Choose where skills
70
+ * load", retrieved 2026-11-24).
61
71
  */
62
72
  export const command = kind({
63
73
  name: "command",
@@ -72,7 +82,10 @@ export const command = kind({
72
82
  * `name` then `description`; identity is the `name` field (never the filename),
73
83
  * the named-field mode; registers on the description-trigger channel only — no
74
84
  * user-invoked slash command (code.claude.com/docs/en/sub-agents, retrieved
75
- * 2026-07-15).
85
+ * 2026-07-15). The locus is the project row, `.claude/agents/`, and recurses: "Claude
86
+ * Code scans `.claude/agents/` and `~/.claude/agents/` recursively, so you can organize
87
+ * definitions into subfolders" (code.claude.com/docs/en/sub-agents, "Choose the subagent
88
+ * scope", retrieved 2026-11-24).
76
89
  */
77
90
  export const agent = kind({
78
91
  name: "agent",
@@ -83,13 +96,15 @@ export const agent = kind({
83
96
  identityField: "name",
84
97
  });
85
98
  /**
86
- * `rule` — `.claude/rules/<name>.md`, a lone file (identity from the stem), YAML
87
- * frontmatter; registers a path scope (code.claude.com/docs/en/memory, retrieved
88
- * 2026-07-15).
99
+ * `rule` — a `<name>.md` at any depth under `.claude/rules/`, a lone file (identity
100
+ * from the stem), YAML frontmatter; registers a path scope
101
+ * (code.claude.com/docs/en/memory, retrieved 2026-07-15). The locus recurses: "All `.md` files are discovered recursively, so
102
+ * you can organize rules into subdirectories like `frontend/` or `backend/`"
103
+ * (code.claude.com/docs/en/memory, "Organize rules with `.claude/rules/`", retrieved 2026-11-24).
89
104
  */
90
105
  export const rule = kind({
91
106
  name: "rule",
92
- locus: { kind: "at", root: ".claude/rules", glob: "*.md" },
107
+ locus: { kind: "at", root: ".claude/rules", glob: "**/*.md" },
93
108
  format: "yaml-frontmatter",
94
109
  unitShape: "file",
95
110
  registration: [{ via: "paths-match", field: "paths" }],
@@ -102,11 +117,24 @@ export const rule = kind({
102
117
  * `format`. A project `CLAUDE.md` may sit at either `./CLAUDE.md` or
103
118
  * `./.claude/CLAUDE.md` — equal documented locations (same source) — and the
104
119
  * any-depth locus (a `CLAUDE.md` at any directory) covers both; a
105
- * module-carried memory projects the root file.
120
+ * module-carried memory projects the root file. The locus is the project row,
121
+ * "`./CLAUDE.md` or `./.claude/CLAUDE.md`", at any depth because "Claude also discovers
122
+ * `CLAUDE.md` and `CLAUDE.local.md` files in subdirectories under your current working
123
+ * directory" (code.claude.com/docs/en/memory, "Choose where to put CLAUDE.md files" and
124
+ * "How CLAUDE.md files load", retrieved 2026-11-24). The locus excludes the `.claude/`
125
+ * folders another built-in loader owns — `agents`, `commands`, `rules`, `skills`: the
126
+ * memory docs describe no `CLAUDE.md` inside them loading as memory, and the rules
127
+ * loader discovers every `.md` under `.claude/rules/` recursively
128
+ * (code.claude.com/docs/en/memory, retrieved 2026-11-24; decision 0084).
106
129
  */
107
130
  export const memory = kind({
108
131
  name: "memory",
109
- locus: { kind: "at", root: ".", glob: "**/CLAUDE.md" },
132
+ locus: {
133
+ kind: "at",
134
+ root: ".",
135
+ glob: "**/CLAUDE.md",
136
+ exclude: [".claude/agents", ".claude/commands", ".claude/rules", ".claude/skills"],
137
+ },
110
138
  unitShape: "file",
111
139
  registration: [{ via: "always" }],
112
140
  guidance: "a `paths:` frontmatter block belongs on a `.claude/rules/*.md` file, not on `CLAUDE.md` — the memory docs document `paths` only for rules, so a rules-style header on `CLAUDE.md` is dead configuration. Split a large file with `@path` imports (resolved relative to the importing file, absolute allowed, recursion capped at four hops; wrap a path in backticks to mention it without importing). If the repo already ships an `AGENTS.md` for other agents, don't duplicate it — create a `CLAUDE.md` that `@AGENTS.md`-imports it (or symlink, except on Windows where the import is the recommended bridge). Mind the loading asymmetry: every ancestor `CLAUDE.md` loads in full at launch, while files in subdirectories load only when Claude reads a file there — so a rule that must always hold belongs above the working directory, not below it. Personal, un-shared notes go in `CLAUDE.local.md` (gitignored), appended after `CLAUDE.md` at its level.",
@@ -125,7 +153,6 @@ export const handler = kind({
125
153
  name: "handler",
126
154
  locus: { kind: "embedded" },
127
155
  unitShape: "file",
128
- registration: [],
129
156
  shape: "fields",
130
157
  cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-09-29)",
131
158
  });
@@ -192,7 +219,6 @@ const hookGroup = kind({
192
219
  registration: [{ via: "event", field: "event" }],
193
220
  shape: "fields",
194
221
  collectionAddress: {
195
- manifest: SETTINGS_MANIFEST,
196
222
  keyPath: HOOK_KEY_PATH,
197
223
  entryShape: `group-array(${HOOK_HANDLER_KEY};${HOOK_MATCHER_KEY})`,
198
224
  },
@@ -228,6 +254,48 @@ export const hook = Object.assign(hookMember, {
228
254
  key: hookGroup.key,
229
255
  render: hookGroup.render,
230
256
  });
257
+ /**
258
+ * The key a gate hook's registration row carries its declared binary under — the engine's
259
+ * `GATE_BINARY_KEY` (`src/drift.rs`), which consumes it at emit and renders the handler's
260
+ * command in its place. Colon-qualified so no typed {@link Hook} field can spell it.
261
+ * `null` is a gate hook declaring no binary, so the default (`temper`) has one spelling,
262
+ * the engine's.
263
+ */
264
+ export const GATE_BINARY_KEY = "temper:gate-binary";
265
+ /** Each gate hook member's declared binary (`null` declaring none) — the fact
266
+ * {@link gateHook} records and {@link gateHookBinary} reads, keyed by the member itself so
267
+ * the member's typed fields stay exactly the manifest entry they project to. */
268
+ const gateHookBinaries = new WeakMap();
269
+ /**
270
+ * A temper gate hook — a {@link hook} member whose single `command` handler runs the
271
+ * temper verb its event fires, with the binary it states. The member is an ordinary
272
+ * matcher group in every other respect: its name joins its matcher as any hook's does,
273
+ * and a tap hook at the same event and matcher joins it as a further handler.
274
+ *
275
+ * # Throws
276
+ * If `binary` is the empty string — there is nothing to run — or the matcher carries a
277
+ * `/` ({@link hook}).
278
+ */
279
+ export function gateHook(init) {
280
+ if (init.binary === "") {
281
+ throw new Error(`gate hook \`${init.name}\`: \`binary\` is empty — state the temper binary the hook ` +
282
+ `runs, or omit it for \`temper\` on the PATH (specs/model/adoption.md, "Install").`);
283
+ }
284
+ const handlers = [{ type: "command" }];
285
+ const member = init.matcher === undefined
286
+ ? hook({ name: init.name, hooks: handlers })
287
+ : hook({ name: init.name, matcher: init.matcher, hooks: handlers });
288
+ gateHookBinaries.set(member, init.binary ?? null);
289
+ return member;
290
+ }
291
+ /**
292
+ * The binary a gate hook member declares — `null` where it declares none (`temper` on the
293
+ * PATH) — or `undefined` where `member` is not a gate hook at all. The one reader is the
294
+ * registration erasure (`declarations.ts`), which carries it under {@link GATE_BINARY_KEY}.
295
+ */
296
+ export function gateHookBinary(member) {
297
+ return gateHookBinaries.get(member);
298
+ }
231
299
  /**
232
300
  * The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
233
301
  * provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
@@ -260,7 +328,7 @@ export const mcpServer = kind({
260
328
  unitShape: "file",
261
329
  registration: [{ via: "connection" }],
262
330
  shape: "fields",
263
- collectionAddress: { manifest: ".mcp.json", keyPath: "mcpServers.*", entryShape: "object" },
331
+ collectionAddress: { keyPath: "mcpServers.*", entryShape: "object" },
264
332
  });
265
333
  /**
266
334
  * `installedPlugin` — a `settings.json` `enabledPlugins` registration member: a
@@ -276,7 +344,7 @@ export const installedPlugin = kind({
276
344
  unitShape: "file",
277
345
  registration: [{ via: "enablement", field: "enabled" }],
278
346
  shape: "fields",
279
- collectionAddress: { manifest: SETTINGS_MANIFEST, keyPath: "enabledPlugins.*", entryShape: "scalar(enabled)" },
347
+ collectionAddress: { keyPath: "enabledPlugins.*", entryShape: "scalar(enabled)" },
280
348
  // The marketplace half of the `<plugin>@<marketplace>` key is a declared edge to the
281
349
  // `known-marketplace` member it names (decision 0039). The half is not an authored field
282
350
  // — the engine splits it off the composite key at read (`src/kind.rs`, the read-time fold
@@ -319,7 +387,7 @@ export const knownMarketplace = kind({
319
387
  unitShape: "file",
320
388
  registration: [{ via: "registry" }],
321
389
  shape: "fields",
322
- collectionAddress: { manifest: SETTINGS_MANIFEST, keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
390
+ collectionAddress: { keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
323
391
  });
324
392
  /**
325
393
  * The default contract for `known-marketplace` — **deliberately empty**. The format
@@ -338,7 +406,9 @@ export const knownMarketplaceDefaultContract = [];
338
406
  * It owns its file, so it carries no collection address, and it is channel-less: a
339
407
  * manifest carries distribution metadata rather than session content, so it reaches the
340
408
  * model on no channel of its own — what it reaches is the installer
341
- * (code.claude.com/docs/en/plugins-reference, retrieved 2026-07-16).
409
+ * (code.claude.com/docs/en/plugins-reference, retrieved 2026-07-16). The locus is the
410
+ * documented one: "Save the manifest at `.claude-plugin/plugin.json` under the plugin
411
+ * root" (code.claude.com/docs/en/plugins-reference, "Manifest file", retrieved 2026-11-24).
342
412
  */
343
413
  export const pluginManifest = kind({
344
414
  name: "plugin-manifest",
@@ -553,7 +623,10 @@ export const pluginManifestDefaultContract = [
553
623
  * stem is `marketplace` for every catalog ever written. Like its `plugin-manifest`
554
624
  * sibling it owns its file (no collection address) and is channel-less: a catalog is read
555
625
  * by the installer, never surfaced to the model
556
- * (code.claude.com/docs/en/plugin-marketplaces, retrieved 2026-07-16).
626
+ * (code.claude.com/docs/en/plugin-marketplaces, retrieved 2026-07-16). The locus is the
627
+ * documented one: a marketplace is "a directory or repository with a
628
+ * `.claude-plugin/marketplace.json` file" (code.claude.com/docs/en/plugin-marketplaces,
629
+ * "Create a marketplace", retrieved 2026-11-24).
557
630
  */
558
631
  export const marketplace = kind({
559
632
  name: "marketplace",
@@ -716,7 +789,9 @@ export const marketplaceDefaultContract = [
716
789
  * key names it). The keys it does not type ride {@link SettingsLocal.residue}, the opaque
717
790
  * channel 0036's partial governance names. Channel-less: machine configuration read by the
718
791
  * harness, never surfaced to the model (code.claude.com/docs/en/settings, retrieved
719
- * 2026-07-16; decisions 0032/0034/0036).
792
+ * 2026-07-16; decisions 0032/0034/0036). The locus is the "Project local" row,
793
+ * `.claude/settings.local.json`, which "Claude Code keeps … out of git"
794
+ * (code.claude.com/docs/en/settings, "Settings files and who they affect", retrieved 2026-11-24).
720
795
  */
721
796
  export const settingsLocal = kind({
722
797
  name: "settings-local",
@@ -772,6 +847,10 @@ export const settingsLocalDefaultContract = [
772
847
  * address order, then the residue — which the member itself authors through
773
848
  * {@link Settings.residue}, flat and key-sorted behind its typed fields
774
849
  * (code.claude.com/docs/en/settings, retrieved 2026-09-22).
850
+ *
851
+ * The locus is the "Shared project" row, `.claude/settings.json` — "In a git repository,
852
+ * commit it so teammates get it" (code.claude.com/docs/en/settings, "Settings files and
853
+ * who they affect", retrieved 2026-11-24).
775
854
  */
776
855
  export const settings = kind({
777
856
  name: "settings",
@@ -829,7 +908,9 @@ export const settingsDefaultContract = [
829
908
  * its own kind ({@link mcpServer}). That segment and this member's opaque residue are one
830
909
  * file: emit renders the declared segment first, then the residue — which the member itself
831
910
  * authors through {@link Mcp.residue}, flat and key-sorted
832
- * (code.claude.com/docs/en/mcp, retrieved 2026-09-29).
911
+ * (code.claude.com/docs/en/mcp, retrieved 2026-09-29). The locus is the project root:
912
+ * "add the entry under `mcpServers` in `.mcp.json` at your project root and commit it"
913
+ * (code.claude.com/docs/en/mcp, "Add a server from an `mcpServers` JSON block", retrieved 2026-11-24).
833
914
  */
834
915
  export const mcp = kind({
835
916
  name: "mcp",
@@ -7,8 +7,7 @@
7
7
  * specifier like any other. The built-in default contracts join the kinds here
8
8
  * too: adoption is `import { skill, skillDefaultContract } from "@dtmd/temper/claude-code"`.
9
9
  */
10
- export type { Agent, Handler, Hook, InstalledPlugin, KnownMarketplace, Marketplace, MarketplacePlugin, MarketplaceSource, Mcp, McpServer, Memory, PluginManifest, Rule, Settings, SettingsLocal, Skill, SupportingDoc, } from "./builtins.js";
11
- export { agent, agentDefaultContract, command, commandDefaultContract, handler, handlerDefaultContract, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcp, mcpDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
12
- export { GUARD_COMMAND, SESSION_START_COMMAND } from "./generated/index.js";
10
+ export type { Agent, GateHookEvent, GateHookInit, Handler, Hook, InstalledPlugin, KnownMarketplace, Marketplace, MarketplacePlugin, MarketplaceSource, Mcp, McpServer, Memory, PluginManifest, Rule, Settings, SettingsLocal, Skill, SupportingDoc, } from "./builtins.js";
11
+ export { agent, agentDefaultContract, command, commandDefaultContract, gateHook, handler, handlerDefaultContract, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcp, mcpDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
13
12
  export type { Blocks, File, Prose, Text } from "./prose.js";
14
13
  export { blocks, file, text } from "./prose.js";
@@ -7,12 +7,5 @@
7
7
  * specifier like any other. The built-in default contracts join the kinds here
8
8
  * too: adoption is `import { skill, skillDefaultContract } from "@dtmd/temper/claude-code"`.
9
9
  */
10
- export { agent, agentDefaultContract, command, commandDefaultContract, handler, handlerDefaultContract, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcp, mcpDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
11
- // temper's own gate commands — the exec-form strings its `SessionStart` and guard hook
12
- // members run. The engine is their one home (`src/install.rs`); these bindings are
13
- // machine-written across the `generated/` seam from those constants and held byte-equal by
14
- // the seam gate (`tests/it/seam_bindings_current.rs`), so a scaffolded gate-hook member
15
- // imports the command it fires rather than spelling a literal that goes stale the day the
16
- // command changes (decision 0073).
17
- export { GUARD_COMMAND, SESSION_START_COMMAND } from "./generated/index.js";
10
+ export { agent, agentDefaultContract, command, commandDefaultContract, gateHook, handler, handlerDefaultContract, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcp, mcpDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
18
11
  export { blocks, file, text } from "./prose.js";
@@ -407,6 +407,11 @@ export declare const telemetry: (events: readonly string[]) => Verifier;
407
407
  export interface Requirement {
408
408
  readonly prose: string;
409
409
  readonly kind?: string | KindDefinition<any>;
410
+ /**
411
+ * Whether the requirement must be filled. Unset inherits the corpus's shipped
412
+ * default — at least one satisfier, at error severity — so an unfilled
413
+ * requirement fails `check`; `false` is the advisory override.
414
+ */
410
415
  readonly required?: boolean;
411
416
  readonly clauses?: readonly Clause[];
412
417
  readonly verifier?: Verifier;
@@ -111,7 +111,7 @@ export declare function declaredAtLocusKinds(harness: Harness): Set<string>;
111
111
  * columns — honest (nothing observed a render) but undecidable for a `format-places-edges`
112
112
  * or `extent` clause, so a whole compile goes through `emit`, never this alone.
113
113
  */
114
- export declare function compileDeclarations(harness: Harness, placements?: EdgePlacements, extents?: RenderedExtents): Declarations;
114
+ export declare function compileDeclarations(harness: Harness, placements?: EdgePlacements, extents?: RenderedExtents, modules?: readonly string[]): Declarations;
115
115
  /**
116
116
  * Serialize the seam payload to the internal versioned JSON pipe — `encodeSeam`
117
117
  * stamps `version`, so the caller supplies the rest of the {@link Payload}.
@@ -10,8 +10,9 @@
10
10
  */
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { isDeepStrictEqual } from "node:util";
13
+ import { manifestOf } from "./kind.js";
13
14
  import { isTextSpan, resolveEmbeddedLeaves } from "./prose.js";
14
- import { HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
15
+ import { GATE_BINARY_KEY, HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, gateHookBinary, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
15
16
  import { leafAddress, memberAddress, nestedAddress } from "./member-address.js";
16
17
  /**
17
18
  * Compile one `Clause` into its lock row: the shared `key`/`field`/`severity`/
@@ -291,7 +292,6 @@ function collectionAddressRow(facts) {
291
292
  if (facts.collectionAddress === undefined)
292
293
  return undefined;
293
294
  return {
294
- manifest: facts.collectionAddress.manifest,
295
295
  key_path: facts.collectionAddress.keyPath,
296
296
  entry_shape: facts.collectionAddress.entryShape,
297
297
  };
@@ -310,8 +310,8 @@ function leafSetRow(leaves) {
310
310
  * One kind's fact row — an `at` locus supplies `governs_root`/`governs_glob` and any
311
311
  * other locus neither (a nested-file kind's path composes from its host's unit and the
312
312
  * host template's pattern; an embedded kind owns no unit at all — both govern no glob).
313
- * A file locus's `commitment` class rides the same spelling, absent for the committed
314
- * default. `templates` names the embedded kinds the corpus admits over it, and `content`
313
+ * A file locus's `commitment` class and `exclude` paths ride the same spelling, absent for
314
+ * the committed, nothing-excluded default. `templates` names the embedded kinds the corpus admits over it, and `content`
315
315
  * lowers a declared layout (absent for a `file`-content kind). A registration kind
316
316
  * extends the row with its `shape` marker and `collection_address`. A declared leaf-set
317
317
  * witness lowers to `leaves` ([`leafSetRow`]), absent for a kind declaring none. Advisory
@@ -328,9 +328,12 @@ function kindFactRow(facts, admissions) {
328
328
  governs_root: governs?.root,
329
329
  governs_glob: governs?.glob,
330
330
  commitment: governs?.commitment,
331
+ // Spread rather than an `undefined` column: a row excluding nothing carries no key.
332
+ ...(governs?.exclude?.length ? { exclude: [...governs.exclude] } : {}),
331
333
  format: facts.format,
332
334
  unit_shape: unitShapeLabel(facts),
333
- registration: registrationLabels(facts.registration),
335
+ // An embedded or nested-file kind declares no set — its locus already states it empty.
336
+ registration: registrationLabels(facts.registration ?? []),
334
337
  templates: templatesFor(facts, admissions),
335
338
  content: contentRow(facts.content),
336
339
  shape: facts.shape,
@@ -492,7 +495,11 @@ function kindFactKindsInPlay(allKinds) {
492
495
  facts.cite !== undefined ||
493
496
  facts.leaves !== undefined);
494
497
  }
495
- /** The requirement rows — assembly `require` and every member's `requires`, one namespace. */
498
+ /**
499
+ * The requirement rows — assembly `require` and every member's `requires`, one namespace.
500
+ * An unset `required` lowers the corpus's shipped default — "this must be filled": at
501
+ * least one satisfier, at error — so only an explicit `required: false` is advisory.
502
+ */
496
503
  function requirementRows(harness) {
497
504
  const entries = [];
498
505
  for (const [name, requirement] of Object.entries(harness.require)) {
@@ -509,7 +516,7 @@ function requirementRows(harness) {
509
516
  .map(([name, requirement]) => ({
510
517
  name,
511
518
  kind: typeof requirement.kind === "string" ? requirement.kind : requirement.kind?.key,
512
- required: requirement.required ?? false,
519
+ required: requirement.required ?? true,
513
520
  clauses: (requirement.clauses ?? []).map((clause) => clauseRow(clause)),
514
521
  verifier: verifierRow(requirement.verifier),
515
522
  prose: requirement.prose,
@@ -707,6 +714,13 @@ function inputRows(harness) {
707
714
  }
708
715
  return rows;
709
716
  }
717
+ /**
718
+ * The `module` rows — the program's loaded local modules, deduplicated and sorted so the
719
+ * row order is the set's, never the load order a refactor of import statements reshuffles.
720
+ */
721
+ function moduleRows(modules) {
722
+ return [...new Set(modules)].sort(compareStrings);
723
+ }
710
724
  /**
711
725
  * One host member's declared embedded-member value as its declaration row
712
726
  * ([`NestedMemberRow`]) — its leaves through the shared walk
@@ -802,8 +816,8 @@ function nestedMemberRows(harness, admissions, scope, placements, extents) {
802
816
  /**
803
817
  * The `registration` rows — every fields-only registration member (a hook, an MCP server)
804
818
  * erased for the manifest write face, kind-then-key sorted so double emit is byte-stable.
805
- * Each carries its **collection key** (`kind`/`key`), its collection address
806
- * (`manifest`/`keyPath`, the wire's snake_case `key_path`), and its folded typed fields —
819
+ * Each carries its **collection key** (`kind`/`key`), its manifest (the kind's locus,
820
+ * {@link manifestOf}) and key path (the wire's snake_case `key_path`), and its folded typed fields —
807
821
  * the entry value the engine's write face places under `key`. The authored half alone:
808
822
  * the synthesized tap hooks join these rows in {@link mergedRegistrationRows}, which is
809
823
  * what both readers of the family take.
@@ -829,15 +843,26 @@ function registrationRows(harness) {
829
843
  return {
830
844
  kind: member.kind,
831
845
  key: member.kind === hook.key ? hookCollectionKey(member.name) : member.name,
832
- manifest: address.manifest,
846
+ manifest: manifestOf(member.facts),
833
847
  key_path: address.keyPath,
834
848
  // The generated row carries a mutable field list; the member's is read-only, so
835
849
  // copy each pair into a fresh tuple — the same values, a shape the row accepts.
836
- fields: member.fields.map(([name, value]) => [name, value]),
850
+ fields: [
851
+ ...member.fields.map(([name, value]) => [name, value]),
852
+ // A gate hook carries its declared binary across the seam beside its fields; the
853
+ // engine renders the handler's command from it and drops the key ({@link gateHook}).
854
+ ...gateBinaryField(member),
855
+ ],
837
856
  };
838
857
  })
839
858
  .sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.key, b.key));
840
859
  }
860
+ /** The gate hook row's binary field — `[GATE_BINARY_KEY, binary]` for a {@link gateHook}
861
+ * member, `null` declaring none, and nothing for every other member. */
862
+ function gateBinaryField(member) {
863
+ const binary = gateHookBinary(member);
864
+ return binary === undefined ? [] : [[GATE_BINARY_KEY, binary]];
865
+ }
841
866
  /** The tap invocation the synthesized telemetry hooks run — the sibling verb of the
842
867
  * session-start reporter, appending one event record to the per-machine log
843
868
  * (`src/tap.rs`). Every synthesized hook's `command` field carries it verbatim. */
@@ -1036,7 +1061,7 @@ function mentionScope(harness) {
1036
1061
  * columns — honest (nothing observed a render) but undecidable for a `format-places-edges`
1037
1062
  * or `extent` clause, so a whole compile goes through `emit`, never this alone.
1038
1063
  */
1039
- export function compileDeclarations(harness, placements, extents) {
1064
+ export function compileDeclarations(harness, placements, extents, modules = []) {
1040
1065
  const allKinds = kindsInPlay(harness);
1041
1066
  const admissions = admissionsByHost(harness);
1042
1067
  const clauses = [];
@@ -1063,6 +1088,7 @@ export function compileDeclarations(harness, placements, extents) {
1063
1088
  mentions: mentionRows(harness),
1064
1089
  includes: includeRows(harness),
1065
1090
  inputs: inputRows(harness),
1091
+ modules: moduleRows(modules),
1066
1092
  nested_members: nestedMemberRows(harness, admissions, mentionScope(harness), placements, extents),
1067
1093
  registrations: mergedRegistrationRows(harness),
1068
1094
  settings: settingsRows(harness),
@@ -126,6 +126,16 @@ export interface EmitResult {
126
126
  */
127
127
  readonly settings: readonly SettingsResidue[];
128
128
  }
129
+ /**
130
+ * The real paths of every local module this run loaded, as the engine's preload recorded
131
+ * them — empty when no preload ran (the SDK driven outside `temper emit`). The judge is the
132
+ * real path, not the URL a specifier resolved through: a workspace package reached via a
133
+ * `node_modules` symlink is the author's own source and stays fingerprinted, while an
134
+ * installed package, whose real path sits under `node_modules`, is its lockfile's to pin.
135
+ * The engine then keeps only the modules the repository tracks: a path its ignore rules
136
+ * exclude (a linked package's build output) gets no row.
137
+ */
138
+ export declare function loadedLocalModules(): string[];
129
139
  /**
130
140
  * Compile the whole face in one deterministic pass: the declaration rows (its
131
141
  * rollup and its seven families) and every projected member's erased payload.
package/dist/src/emit.js CHANGED
@@ -9,7 +9,8 @@
9
9
  * run.
10
10
  */
11
11
  import { fileURLToPath } from "node:url";
12
- import { readFileSync } from "node:fs";
12
+ import { readFileSync, realpathSync } from "node:fs";
13
+ import { sep } from "node:path";
13
14
  import { checkMentions, defersToGate, isTextSpan, renderText, resolveEmbeddedLeaves } from "./prose.js";
14
15
  import { permissionUnion } from "./needs.js";
15
16
  import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, settingsRows, uniqueMap, } from "./declarations.js";
@@ -802,6 +803,44 @@ function orderedMembers(harness, options) {
802
803
  };
803
804
  });
804
805
  }
806
+ /**
807
+ * The `globalThis` key the engine's `node --import` preload publishes the run's loaded
808
+ * `file:` URLs under (`src/drift.rs`, `LOADED_MODULES_KEY`). Change both.
809
+ */
810
+ const LOADED_MODULES_KEY = Symbol.for("@dtmd/temper.loaded-modules");
811
+ /**
812
+ * The real paths of every local module this run loaded, as the engine's preload recorded
813
+ * them — empty when no preload ran (the SDK driven outside `temper emit`). The judge is the
814
+ * real path, not the URL a specifier resolved through: a workspace package reached via a
815
+ * `node_modules` symlink is the author's own source and stays fingerprinted, while an
816
+ * installed package, whose real path sits under `node_modules`, is its lockfile's to pin.
817
+ * The engine then keeps only the modules the repository tracks: a path its ignore rules
818
+ * exclude (a linked package's build output) gets no row.
819
+ */
820
+ export function loadedLocalModules() {
821
+ const recorded = globalThis[LOADED_MODULES_KEY];
822
+ if (!(recorded instanceof Set)) {
823
+ return [];
824
+ }
825
+ const paths = [];
826
+ for (const url of recorded) {
827
+ if (typeof url !== "string" || !url.startsWith("file:")) {
828
+ continue;
829
+ }
830
+ const path = fileURLToPath(url);
831
+ let real;
832
+ try {
833
+ real = realpathSync(path);
834
+ }
835
+ catch {
836
+ real = path;
837
+ }
838
+ if (!real.split(sep).includes("node_modules")) {
839
+ paths.push(real);
840
+ }
841
+ }
842
+ return paths;
843
+ }
805
844
  /**
806
845
  * Compile the whole face in one deterministic pass: the declaration rows (its
807
846
  * rollup and its seven families) and every projected member's erased payload.
@@ -816,9 +855,11 @@ export function emit(harness) {
816
855
  deferrableKinds: declaredAtLocusKinds(harness),
817
856
  members: memberTable(harness),
818
857
  };
858
+ // Read once, ahead of both passes: the set is a fact about this run, not the harness.
859
+ const modules = loadedLocalModules();
819
860
  const compile = () => {
820
861
  const members = orderedMembers(harness, resolve);
821
- const declarations = compileDeclarations(harness, edgePlacements(harness, resolve), renderedExtents(harness, resolve));
862
+ const declarations = compileDeclarations(harness, edgePlacements(harness, resolve), renderedExtents(harness, resolve), modules);
822
863
  return {
823
864
  declarations,
824
865
  members,
@@ -1,14 +1,11 @@
1
1
  /**
2
- * A kind's declared **collection address** row — the manifest a registration member
3
- * surfaces in, the key path it keys at, and the shape its entry takes: the
4
- * presence-coupled triple [`KindFactRow::collection_address`] carries. Absent from a
5
- * [`KindFactRow`] means the kind owns its own file locus.
2
+ * A kind's declared **collection address** row — the key path a registration member
3
+ * keys at and the shape its entry takes: the presence-coupled pair
4
+ * [`KindFactRow::collection_address`] carries. The manifest it keys inside is the row's
5
+ * own starless `governs_glob`, never a second column here. Absent from a [`KindFactRow`]
6
+ * means the kind owns its own file locus.
6
7
  */
7
8
  export type CollectionAddressRow = {
8
- /**
9
- * The host manifest the registration surfaces in (`settings.json`, `.mcp.json`).
10
- */
11
- manifest: string;
12
9
  /**
13
10
  * The manifest key path the registration keys at (`hooks.<Event>`, `mcpServers.*`), a
14
11
  * closed vocabulary the engine's kind lift rejects an unknown value from.
@@ -73,6 +73,14 @@ export type Declarations = {
73
73
  * this family empty.
74
74
  */
75
75
  inputs: Array<InputRow>;
76
+ /**
77
+ * The real, absolute path of every local module the program's own run loaded — any
78
+ * `file:` module whose real path sits under no `node_modules` directory, since an
79
+ * installed package is its package lockfile's to pin. Seam-inbound like `inputs`:
80
+ * `emit` fingerprints each as a `module` source dependency owned by the root member,
81
+ * so a lock round-trip reads this family empty.
82
+ */
83
+ modules: Array<string>;
76
84
  /**
77
85
  * The host members' declared embedded-member facts — captured as declaration
78
86
  * rows rather than a second copy the engine reads back off the rendered fence
@@ -39,6 +39,13 @@ export type KindFactRow = {
39
39
  * derive at read time under it.
40
40
  */
41
41
  commitment?: string;
42
+ /**
43
+ * The file locus's declared **excluded** paths — harness-relative, starless, each a
44
+ * path the locus template would otherwise govern, left ungoverned. Empty for a
45
+ * locus excluding nothing, the tolerant round-trip
46
+ * [`registration`](KindFactRow::registration) takes.
47
+ */
48
+ exclude?: Array<string>;
42
49
  /**
43
50
  * The declared projection format label, when declared.
44
51
  */
@@ -20,7 +20,9 @@ export type RequirementRow = {
20
20
  */
21
21
  kind?: string;
22
22
  /**
23
- * Whether an unfilled requirement blocks the gate.
23
+ * Whether an unfilled requirement blocks the gate. Absent ⇒ `true`: the
24
+ * corpus default (at least one satisfier, at error), the one the SDK lowers —
25
+ * a row read without the column inherits it, never re-decides it.
24
26
  */
25
27
  required: boolean;
26
28
  /**
@@ -34,5 +34,4 @@ export type { Shape } from "./Shape.js";
34
34
  export type { TemplateRow } from "./TemplateRow.js";
35
35
  export type { ValueType } from "./ValueType.js";
36
36
  export type { Verifier } from "./Verifier.js";
37
- export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
38
37
  export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
@@ -1,2 +1 @@
1
- export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
2
1
  export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
@@ -3,7 +3,8 @@
3
3
  * `T` and a constructor `kind<T>()` — plus seven facts of runtime residue: label,
4
4
  * locus, projection, registration, edge fields, content, and template. A registration kind (a hook,
5
5
  * an MCP server) extends the content fact with a fields-only `shape` and a
6
- * `collectionAddress` naming the host manifest it surfaces in. `tsc` is the keystroke
6
+ * `collectionAddress` naming the key path it surfaces at, inside the manifest its starless
7
+ * `at` locus names. `tsc` is the keystroke
7
8
  * wall; every type erases at the seam, and what a kind leaves behind rides the lock as
8
9
  * rows. Identity travels by import, never by string — a `kind` reference is the imported
9
10
  * value.
@@ -97,8 +98,19 @@ export interface EdgeField {
97
98
  export type Locus = {
98
99
  readonly kind: "at";
99
100
  readonly root: string;
101
+ /** A placement template: literal `/`-separated segments with at most one `*`,
102
+ * optionally under a leading `**` + `/` for any depth. Any other pattern syntax
103
+ * (a `?`, a character class, braces, an extglob, a second star) is refused when
104
+ * the engine loads the lock; narrow member names with a clause, never the glob. */
100
105
  readonly glob: string;
101
106
  readonly commitment?: "local";
107
+ /** Paths the template would govern that the kind leaves ungoverned — each a
108
+ * starless, harness-relative literal the template matches (`domains/README.md`
109
+ * under `domains` + `*.md`), or a bare directory (no trailing `/`) the template
110
+ * reaches beneath, leaving every path under it ungoverned (`domains/legacy` under
111
+ * `domains` + `* /SKILL.md`, read without the space). Anything else is refused when
112
+ * the engine loads the lock. */
113
+ readonly exclude?: readonly string[];
102
114
  } | {
103
115
  readonly kind: "embedded";
104
116
  } | {
@@ -107,16 +119,18 @@ export type Locus = {
107
119
  /**
108
120
  * One region of a kind's **layout** — one of the three corpus primitives over the
109
121
  * body's heading tree. `prose` is a verbatim span, or an `import` reference resolving to
110
- * a file's contents; `field` is a heading whose span fills a named field `slot`;
122
+ * a file's contents; `field` is a heading whose span fills a named field `slot` — a key
123
+ * of the kind's own typed surface `T`, so a slot the member does not carry is a compile
124
+ * error rather than a second, free-hand spelling of the field set;
111
125
  * `collection` is a heading whose child headings are each one member of `memberKind`,
112
126
  * identity the slugged child heading unless an explicit `key` overrides it.
113
127
  */
114
- export type LayoutRegion = {
128
+ export type LayoutRegion<T extends object = Record<string, unknown>> = {
115
129
  readonly region: "prose";
116
130
  readonly import?: string;
117
131
  } | {
118
132
  readonly region: "field";
119
- readonly slot: string;
133
+ readonly slot: keyof T & string;
120
134
  } | {
121
135
  readonly region: "collection";
122
136
  readonly memberKind: string;
@@ -127,8 +141,8 @@ export type LayoutRegion = {
127
141
  * Declaring one on a kind's `content` makes the kind `layout`-content; leaving `content`
128
142
  * absent leaves it `file`-content (one verbatim prose body, the default).
129
143
  */
130
- export interface Layout {
131
- readonly regions: readonly LayoutRegion[];
144
+ export interface Layout<T extends object = Record<string, unknown>> {
145
+ readonly regions: readonly LayoutRegion<T>[];
132
146
  }
133
147
  /**
134
148
  * A kind's **body shape** marker — `"fields"` for a fields-only kind: no body slot at
@@ -156,14 +170,14 @@ export type LeafSet<T extends object> = {
156
170
  readonly [K in keyof T]-?: true;
157
171
  };
158
172
  /**
159
- * A registration member's **collection address** — where inside a host manifest its
160
- * registration surfaces: which `manifest` (`settings.json`, `.mcp.json`) and which
161
- * `keyPath` it keys at — one of the four addresses the shipped kinds surface at.
173
+ * A registration member's **collection address** — where inside its host manifest its
174
+ * registration surfaces: the `keyPath` it keys at, one of the four addresses the shipped
175
+ * kinds surface at. The manifest itself is the kind's starless `at` locus — one home, so
176
+ * the address and the locus can never name two different files ({@link manifestOf}).
162
177
  * Carried by a fields-only registration kind; absent for a kind that owns its own file
163
178
  * locus.
164
179
  */
165
180
  export interface CollectionAddress {
166
- readonly manifest: string;
167
181
  readonly keyPath: "hooks.<Event>" | "mcpServers.*" | "enabledPlugins.*" | "extraKnownMarketplaces.*";
168
182
  readonly entryShape: string;
169
183
  }
@@ -212,12 +226,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
212
226
  /** Fact 2, locus — where members live, and for a file locus whether their documents
213
227
  * are committed: a `local` commitment class declares the kind reviewed and its
214
228
  * members' documents not. */
215
- readonly locus: {
216
- readonly kind: "at";
217
- readonly root: string;
218
- readonly glob: string;
219
- readonly commitment?: "local";
220
- };
229
+ readonly locus: Extract<Locus, {
230
+ kind: "at";
231
+ }>;
221
232
  /** Fact 3a, projection — the artifact format; omitted for a kind that declares none. */
222
233
  readonly format?: Format;
223
234
  /** Fact 3b, projection — the on-disk unit shape. */
@@ -240,12 +251,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
240
251
  readonly edgeFields?: readonly EdgeField[];
241
252
  /** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
242
253
  * leaves the kind `file`-content (one verbatim prose body, the default). */
243
- readonly content?: Layout;
254
+ readonly content?: Layout<T>;
244
255
  /** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
245
256
  * leaves the kind body-bearing (`file` or a {@link Layout}). */
246
257
  readonly shape?: Shape;
247
- /** The registration member's {@link CollectionAddress} — which manifest and key path
248
- * its registration surfaces at; absent for a kind that owns its own file locus. */
258
+ /** The registration member's {@link CollectionAddress} — the key path its
259
+ * registration surfaces at inside the manifest this kind's starless locus names;
260
+ * absent for a kind that owns its own file locus. */
249
261
  readonly collectionAddress?: CollectionAddress;
250
262
  /** Fact 7, template — one {@link Template} per inner layer of nested members the kind
251
263
  * hosts; absent for a kind that nests nothing. */
@@ -286,8 +298,10 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
286
298
  readonly format?: Format;
287
299
  /** Fact 3b, projection — the on-disk unit shape. */
288
300
  readonly unitShape: UnitShape;
289
- /** Fact 4, registration — embedded members register nothing. */
290
- readonly registration: readonly [];
301
+ /** Fact 4, registration — derived, never declared: an embedded member registers
302
+ * nothing, so the locus already states the empty set and the lowering supplies it
303
+ * (`declarations.ts`). */
304
+ readonly registration?: never;
291
305
  /**
292
306
  * The frontmatter key the member's name writes under. For `unitShape:
293
307
  * "named-field"` this is the id **source** — the declared field a member's
@@ -303,13 +317,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
303
317
  readonly edgeFields?: readonly EdgeField[];
304
318
  /** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
305
319
  * leaves the kind `file`-content (one verbatim prose body, the default). */
306
- readonly content?: Layout;
320
+ readonly content?: Layout<T>;
307
321
  /** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
308
322
  * leaves the kind body-bearing (`file` or a {@link Layout}). */
309
323
  readonly shape?: Shape;
310
- /** The registration member's {@link CollectionAddress} — which manifest and key path
311
- * its registration surfaces at; absent for a kind that owns its own file locus. */
312
- readonly collectionAddress?: CollectionAddress;
324
+ /** No collection address: a registration kind's manifest is its `at` locus, and
325
+ * this locus names no file. */
326
+ readonly collectionAddress?: never;
313
327
  /** Fact 7, template — one {@link Template} per inner layer of nested members the kind
314
328
  * hosts; absent for a kind that nests nothing. */
315
329
  readonly templates?: readonly Template[];
@@ -349,8 +363,10 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
349
363
  readonly format?: Format;
350
364
  /** Fact 3b, projection — the on-disk unit shape. */
351
365
  readonly unitShape: UnitShape;
352
- /** Fact 4, registration — nested-file members register nothing. */
353
- readonly registration: readonly [];
366
+ /** Fact 4, registration — derived, never declared: a nested-file member registers
367
+ * nothing, so the locus already states the empty set and the lowering supplies it
368
+ * (`declarations.ts`). */
369
+ readonly registration?: never;
354
370
  /**
355
371
  * The frontmatter key the member's name writes under. For `unitShape:
356
372
  * "named-field"` this is the id **source** — the declared field a member's
@@ -366,13 +382,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
366
382
  readonly edgeFields?: readonly EdgeField[];
367
383
  /** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
368
384
  * leaves the kind `file`-content (one verbatim prose body, the default). */
369
- readonly content?: Layout;
385
+ readonly content?: Layout<T>;
370
386
  /** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
371
387
  * leaves the kind body-bearing (`file` or a {@link Layout}). */
372
388
  readonly shape?: Shape;
373
- /** The registration member's {@link CollectionAddress} — which manifest and key path
374
- * its registration surfaces at; absent for a kind that owns its own file locus. */
375
- readonly collectionAddress?: CollectionAddress;
389
+ /** No collection address: a registration kind's manifest is its `at` locus, and
390
+ * this locus names no file. */
391
+ readonly collectionAddress?: never;
376
392
  /** Fact 7, template — one {@link Template} per inner layer of nested members the kind
377
393
  * hosts; absent for a kind that nests nothing. */
378
394
  readonly templates?: readonly Template[];
@@ -510,7 +526,16 @@ export interface KindOptions {
510
526
  * checked here at the keystroke, and its lowering to the row is the one place it is
511
527
  * spelled again (`declarations.ts`).
512
528
  */
513
- export declare function kind<T extends object>(facts: KindFacts<T>, options?: KindOptions): KindDefinition<T>;
529
+ export declare function kind<T extends object>(typed: KindFacts<T>, options?: KindOptions): KindDefinition<T>;
530
+ /**
531
+ * The host manifest a registration kind surfaces in — its `at` locus glob, which must
532
+ * name exactly one file (no `*`): a starred glob governs a family of files, and a
533
+ * collection address keys inside one.
534
+ *
535
+ * # Throws
536
+ * If the kind's locus is not `at`, or its glob carries a `*`.
537
+ */
538
+ export declare function manifestOf(facts: KindFacts): string;
514
539
  /**
515
540
  * A **relocation delta** — the facts a relocated built-in kind diverges from its base
516
541
  * on. Two faces, either or both:
package/dist/src/kind.js CHANGED
@@ -3,7 +3,8 @@
3
3
  * `T` and a constructor `kind<T>()` — plus seven facts of runtime residue: label,
4
4
  * locus, projection, registration, edge fields, content, and template. A registration kind (a hook,
5
5
  * an MCP server) extends the content fact with a fields-only `shape` and a
6
- * `collectionAddress` naming the host manifest it surfaces in. `tsc` is the keystroke
6
+ * `collectionAddress` naming the key path it surfaces at, inside the manifest its starless
7
+ * `at` locus names. `tsc` is the keystroke
7
8
  * wall; every type erases at the seam, and what a kind leaves behind rides the lock as
8
9
  * rows. Identity travels by import, never by string — a `kind` reference is the imported
9
10
  * value.
@@ -135,7 +136,14 @@ function hostOf(facts, init) {
135
136
  * checked here at the keystroke, and its lowering to the row is the one place it is
136
137
  * spelled again (`declarations.ts`).
137
138
  */
138
- export function kind(facts, options = {}) {
139
+ export function kind(typed, options = {}) {
140
+ // The erasure, spelled: `T` binds the witness and the field slots at the keystroke and
141
+ // then leaves. `keyof T` reads contravariantly, so the compiler will not widen a slot
142
+ // set bound to `T` to the erased `string` on its own — every key of `T` is a string
143
+ // the erased surface admits, which is all this assertion claims.
144
+ const facts = typed;
145
+ if (facts.collectionAddress !== undefined)
146
+ manifestOf(facts);
139
147
  const construct = (init) => ({
140
148
  kind: facts.name,
141
149
  facts,
@@ -150,6 +158,23 @@ export function kind(facts, options = {}) {
150
158
  });
151
159
  return Object.assign(construct, { facts, key: facts.name, render: options.render });
152
160
  }
161
+ /**
162
+ * The host manifest a registration kind surfaces in — its `at` locus glob, which must
163
+ * name exactly one file (no `*`): a starred glob governs a family of files, and a
164
+ * collection address keys inside one.
165
+ *
166
+ * # Throws
167
+ * If the kind's locus is not `at`, or its glob carries a `*`.
168
+ */
169
+ export function manifestOf(facts) {
170
+ if (facts.locus.kind !== "at" || facts.locus.glob.includes("*")) {
171
+ const spelled = facts.locus.kind === "at" ? `\`${facts.locus.glob}\`` : `a \`${facts.locus.kind}\` locus`;
172
+ throw new Error(`kind \`${facts.name}\`: a collection address keys inside the one manifest the kind's ` +
173
+ `locus names, and ${spelled} names no single file — declare an \`at\` locus whose ` +
174
+ `glob carries no \`*\` (specs/model/representation.md, "Reach").`);
175
+ }
176
+ return facts.locus.glob;
177
+ }
153
178
  /**
154
179
  * The locus a `governs` delta moves the base to: the base's `at` root and glob replaced,
155
180
  * every other locus fact (its commitment class among them) riding through.
@@ -225,7 +250,9 @@ export function relocate(base, delta) {
225
250
  const relocated = { ...base.facts, relocates: base.facts.name, edgeFields };
226
251
  // Two spellings, not one with an optional `locus`: `KindFacts` is a union discriminated
227
252
  // on the locus, so the moved case must carry the `at` locus as its own literal branch.
228
- const facts = locus === undefined ? relocated : { ...relocated, locus };
253
+ // A moved locus is only ever an `at` base's (`relocatedLocus` refuses the rest), and an
254
+ // `at` kind declares its registration set — so the base's set rides through as declared.
255
+ const facts = locus === undefined ? relocated : { ...relocated, locus, registration: relocated.registration ?? [] };
229
256
  // The base's leaf-set witness rides through as data, and the assertion is that
230
257
  // pass-through spelled: a relocation appends *edge fields* over the kind's own surface,
231
258
  // never a leaf, so the set the base's own constructor already bound still names what a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtmd/temper",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "The temper authoring face — the six-noun model as typed modules: harness(), kind<T>(), clause values, needs, and file()/text/blocks(). Emit compiles to the declaration rows the engine reads, a byte-faithful projection, and the lock.",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "temper": "bin/temper.js"
53
53
  },
54
54
  "optionalDependencies": {
55
- "@dtmd/temper-linux-x64": "0.0.23",
56
- "@dtmd/temper-win32-x64": "0.0.23"
55
+ "@dtmd/temper-linux-x64": "0.0.24",
56
+ "@dtmd/temper-win32-x64": "0.0.24"
57
57
  }
58
58
  }
@@ -1,2 +0,0 @@
1
- export declare const GUARD_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper guard .";
2
- export declare const SESSION_START_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper check . --reporter session-start";
@@ -1,3 +0,0 @@
1
- // This file carries temper's gate commands, generated from the engine's own constants. Do not edit this file manually.
2
- export const GUARD_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper guard .";
3
- export const SESSION_START_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper check . --reporter session-start";