@dtmd/temper 0.0.22 → 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
  /**
@@ -407,18 +431,6 @@ export declare const HOOK_HANDLER_KEY = "hooks";
407
431
  /** The one group-level field a matcher group lifts beside its handlers — {@link Hook}'s
408
432
  * `matcher`, and the other half of the group's identity the join keys on (same source). */
409
433
  export declare const HOOK_MATCHER_KEY = "matcher";
410
- /**
411
- * A hook member's **name** — its lifecycle `event`, then `:` and the matcher's authored
412
- * bytes; the bare event where the group binds no matcher
413
- * (`hook:PostToolUse:Edit|Write`, `hook:SessionStart`).
414
- *
415
- * Name and collection key part company because the **group** is the member and the event
416
- * keys them all: Claude Code nests several matcher groups under one event, and two
417
- * members at one address is a malformed lock. The matcher is joined verbatim, never
418
- * normalized — `Edit|Write` and `Edit, Write` are two groups on the wire and two members
419
- * here — which is also why an authored empty matcher joins as the empty bytes it is.
420
- */
421
- export declare function hookMemberName(event: string, matcher: string | undefined): string;
422
434
  /**
423
435
  * The `hooks.<Event>` collection key a hook member's name was joined onto — its text
424
436
  * before its own first `:`. The inverse of {@link hookMemberName} for the one reader that
@@ -430,6 +442,52 @@ export declare function hookCollectionKey(name: string): string;
430
442
  /** The authored `hook` constructor — {@link hookGroup}'s facts over {@link hookMember}'s
431
443
  * name composition. */
432
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;
433
491
  /**
434
492
  * The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
435
493
  * provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
@@ -674,7 +732,9 @@ export interface PluginManifest {
674
732
  * It owns its file, so it carries no collection address, and it is channel-less: a
675
733
  * manifest carries distribution metadata rather than session content, so it reaches the
676
734
  * model on no channel of its own — what it reaches is the installer
677
- * (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).
678
738
  */
679
739
  export declare const pluginManifest: KindDefinition<PluginManifest>;
680
740
  /**
@@ -817,7 +877,10 @@ export interface Marketplace {
817
877
  * stem is `marketplace` for every catalog ever written. Like its `plugin-manifest`
818
878
  * sibling it owns its file (no collection address) and is channel-less: a catalog is read
819
879
  * by the installer, never surfaced to the model
820
- * (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).
821
884
  */
822
885
  export declare const marketplace: KindDefinition<Marketplace>;
823
886
  /**
@@ -900,7 +963,9 @@ export interface SettingsLocal {
900
963
  * key names it). The keys it does not type ride {@link SettingsLocal.residue}, the opaque
901
964
  * channel 0036's partial governance names. Channel-less: machine configuration read by the
902
965
  * harness, never surfaced to the model (code.claude.com/docs/en/settings, retrieved
903
- * 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).
904
969
  */
905
970
  export declare const settingsLocal: KindDefinition<SettingsLocal>;
906
971
  /**
@@ -992,6 +1057,10 @@ export interface Settings {
992
1057
  * address order, then the residue — which the member itself authors through
993
1058
  * {@link Settings.residue}, flat and key-sorted behind its typed fields
994
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).
995
1064
  */
996
1065
  export declare const settings: KindDefinition<Settings>;
997
1066
  /**
@@ -1050,7 +1119,9 @@ export interface Mcp {
1050
1119
  * its own kind ({@link mcpServer}). That segment and this member's opaque residue are one
1051
1120
  * file: emit renders the declared segment first, then the residue — which the member itself
1052
1121
  * authors through {@link Mcp.residue}, flat and key-sorted
1053
- * (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).
1054
1125
  */
1055
1126
  export declare const mcp: KindDefinition<Mcp>;
1056
1127
  /**
@@ -1203,18 +1274,19 @@ export declare const hookDefaultContract: readonly Clause[];
1203
1274
  * projects its tap hook at. The event-name is the author-facing token a telemetry
1204
1275
  * verifier names (`contract.ts`'s `telemetry`, the `roster.rs` admissibility set); the
1205
1276
  * `event` is the `hooks.<Event>` key the tap registers under, and the `matcher` scopes
1206
- * the fire to the telemetry-relevant subset — each an external fact
1207
- * (code.claude.com/docs/en/hooks, retrieved 2026-08-26):
1277
+ * the fire to the telemetry-relevant subset — a load reason, a command name, a tool name,
1278
+ * each an external fact (code.claude.com/docs/en/hooks, retrieved 2026-08-26).
1279
+ *
1280
+ * The pairing's one home is the engine's own `TAP_HOOK_BINDINGS` table
1281
+ * (`src/builtin_kind.rs`), which states and cites each event's own matcher and resolves the
1282
+ * table through an exhaustive match over the `TapEvent` it already classifies hook payloads
1283
+ * into — and which `check` reads for the admissibility set too, so the names a telemetry
1284
+ * verifier may declare and the names a tap hook is synthesized for are one enumeration. The
1285
+ * binding read here is machine-written across the `generated/` seam from that table and held
1286
+ * byte-equal by the seam gate (`tests/it/seam_bindings_current.rs`).
1208
1287
  *
1209
- * - `InstructionsLoaded` fires on a rule/memory load; its matcher filters the load
1210
- * reason across all documented reasons (session_start, nested_traversal, path_glob_match,
1211
- * include, compact), so always-on members that load at session start are recorded.
1212
- * - `SkillInvoked` is a skill invocation, surfaced under `PostToolUse` with the tool-name
1213
- * matcher `Skill` — the tap's own read of a skill call.
1214
- * - `UserPromptExpansion` fires on a command expansion; its matcher filters the command
1215
- * name, `.*` capturing every one.
1216
- * - `ToolUse` fires after any tool call; its matcher filters the tool name, `.*`
1217
- * capturing every one.
1288
+ * The widened annotation stays: `tapHookRows` looks up an author-supplied event name, which
1289
+ * the generated literal's own narrow key type would refuse.
1218
1290
  */
1219
1291
  export declare const TELEMETRY_EVENT_HOOKS: Readonly<Record<string, {
1220
1292
  readonly event: string;
@@ -9,6 +9,7 @@
9
9
  * `@dtmd/temper/claude-code` subpath
10
10
  * — never from the root.
11
11
  */
12
+ import { TAP_EVENT_HOOKS } from "./generated/index.js";
12
13
  import { kind } from "./kind.js";
13
14
  import { isNameQualifier } from "./member-address.js";
14
15
  import { allowedChars, clause, closedKeys, degree, deny, enumOf, extent, forbiddenKeys, globValid, maxLen, mentionReachable, minLen, nameMatchesDir, optional, required, shape, type, uniqueName, when, } from "./contract.js";
@@ -19,12 +20,14 @@ import { allowedChars, clause, closedKeys, degree, deny, enumOf, extent, forbidd
19
20
  * file is body), identity from the filename, and channel-less: a supporting file reaches
20
21
  * the world only through the skill whose body references it, never on a channel of its
21
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).
22
26
  */
23
27
  export const supportingDoc = kind({
24
28
  name: "supporting-doc",
25
29
  locus: { kind: "nested-file" },
26
30
  unitShape: "file",
27
- registration: [],
28
31
  });
29
32
  /**
30
33
  * `skill` — `.claude/skills/<name>/SKILL.md`, a directory unit, YAML frontmatter
@@ -40,6 +43,10 @@ export const supportingDoc = kind({
40
43
  * files"). The pattern claims the markdown subset the prose-only child kind can hold —
41
44
  * a supporting file of another type (the docs' own `scripts/helper.py`) matches nothing
42
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).
43
50
  */
44
51
  export const skill = kind({
45
52
  name: "skill",
@@ -57,6 +64,10 @@ export const skill = kind({
57
64
  * retrieved 2026-07-15): a lone file (identity from the stem, so no
58
65
  * `identityField` — like `rule`), the skill's field schema by import, registering
59
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).
60
71
  */
61
72
  export const command = kind({
62
73
  name: "command",
@@ -71,7 +82,10 @@ export const command = kind({
71
82
  * `name` then `description`; identity is the `name` field (never the filename),
72
83
  * the named-field mode; registers on the description-trigger channel only — no
73
84
  * user-invoked slash command (code.claude.com/docs/en/sub-agents, retrieved
74
- * 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).
75
89
  */
76
90
  export const agent = kind({
77
91
  name: "agent",
@@ -82,13 +96,15 @@ export const agent = kind({
82
96
  identityField: "name",
83
97
  });
84
98
  /**
85
- * `rule` — `.claude/rules/<name>.md`, a lone file (identity from the stem), YAML
86
- * frontmatter; registers a path scope (code.claude.com/docs/en/memory, retrieved
87
- * 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).
88
104
  */
89
105
  export const rule = kind({
90
106
  name: "rule",
91
- locus: { kind: "at", root: ".claude/rules", glob: "*.md" },
107
+ locus: { kind: "at", root: ".claude/rules", glob: "**/*.md" },
92
108
  format: "yaml-frontmatter",
93
109
  unitShape: "file",
94
110
  registration: [{ via: "paths-match", field: "paths" }],
@@ -101,11 +117,24 @@ export const rule = kind({
101
117
  * `format`. A project `CLAUDE.md` may sit at either `./CLAUDE.md` or
102
118
  * `./.claude/CLAUDE.md` — equal documented locations (same source) — and the
103
119
  * any-depth locus (a `CLAUDE.md` at any directory) covers both; a
104
- * 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).
105
129
  */
106
130
  export const memory = kind({
107
131
  name: "memory",
108
- 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
+ },
109
138
  unitShape: "file",
110
139
  registration: [{ via: "always" }],
111
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.",
@@ -124,7 +153,6 @@ export const handler = kind({
124
153
  name: "handler",
125
154
  locus: { kind: "embedded" },
126
155
  unitShape: "file",
127
- registration: [],
128
156
  shape: "fields",
129
157
  cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-09-29)",
130
158
  });
@@ -159,7 +187,7 @@ export const HOOK_MATCHER_KEY = "matcher";
159
187
  * normalized — `Edit|Write` and `Edit, Write` are two groups on the wire and two members
160
188
  * here — which is also why an authored empty matcher joins as the empty bytes it is.
161
189
  */
162
- export function hookMemberName(event, matcher) {
190
+ function hookMemberName(event, matcher) {
163
191
  return matcher === undefined ? event : `${event}:${matcher}`;
164
192
  }
165
193
  /**
@@ -191,7 +219,6 @@ const hookGroup = kind({
191
219
  registration: [{ via: "event", field: "event" }],
192
220
  shape: "fields",
193
221
  collectionAddress: {
194
- manifest: SETTINGS_MANIFEST,
195
222
  keyPath: HOOK_KEY_PATH,
196
223
  entryShape: `group-array(${HOOK_HANDLER_KEY};${HOOK_MATCHER_KEY})`,
197
224
  },
@@ -227,6 +254,48 @@ export const hook = Object.assign(hookMember, {
227
254
  key: hookGroup.key,
228
255
  render: hookGroup.render,
229
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
+ }
230
299
  /**
231
300
  * The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
232
301
  * provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
@@ -259,7 +328,7 @@ export const mcpServer = kind({
259
328
  unitShape: "file",
260
329
  registration: [{ via: "connection" }],
261
330
  shape: "fields",
262
- collectionAddress: { manifest: ".mcp.json", keyPath: "mcpServers.*", entryShape: "object" },
331
+ collectionAddress: { keyPath: "mcpServers.*", entryShape: "object" },
263
332
  });
264
333
  /**
265
334
  * `installedPlugin` — a `settings.json` `enabledPlugins` registration member: a
@@ -275,7 +344,7 @@ export const installedPlugin = kind({
275
344
  unitShape: "file",
276
345
  registration: [{ via: "enablement", field: "enabled" }],
277
346
  shape: "fields",
278
- collectionAddress: { manifest: SETTINGS_MANIFEST, keyPath: "enabledPlugins.*", entryShape: "scalar(enabled)" },
347
+ collectionAddress: { keyPath: "enabledPlugins.*", entryShape: "scalar(enabled)" },
279
348
  // The marketplace half of the `<plugin>@<marketplace>` key is a declared edge to the
280
349
  // `known-marketplace` member it names (decision 0039). The half is not an authored field
281
350
  // — the engine splits it off the composite key at read (`src/kind.rs`, the read-time fold
@@ -318,7 +387,7 @@ export const knownMarketplace = kind({
318
387
  unitShape: "file",
319
388
  registration: [{ via: "registry" }],
320
389
  shape: "fields",
321
- collectionAddress: { manifest: SETTINGS_MANIFEST, keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
390
+ collectionAddress: { keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
322
391
  });
323
392
  /**
324
393
  * The default contract for `known-marketplace` — **deliberately empty**. The format
@@ -337,7 +406,9 @@ export const knownMarketplaceDefaultContract = [];
337
406
  * It owns its file, so it carries no collection address, and it is channel-less: a
338
407
  * manifest carries distribution metadata rather than session content, so it reaches the
339
408
  * model on no channel of its own — what it reaches is the installer
340
- * (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).
341
412
  */
342
413
  export const pluginManifest = kind({
343
414
  name: "plugin-manifest",
@@ -552,7 +623,10 @@ export const pluginManifestDefaultContract = [
552
623
  * stem is `marketplace` for every catalog ever written. Like its `plugin-manifest`
553
624
  * sibling it owns its file (no collection address) and is channel-less: a catalog is read
554
625
  * by the installer, never surfaced to the model
555
- * (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).
556
630
  */
557
631
  export const marketplace = kind({
558
632
  name: "marketplace",
@@ -715,7 +789,9 @@ export const marketplaceDefaultContract = [
715
789
  * key names it). The keys it does not type ride {@link SettingsLocal.residue}, the opaque
716
790
  * channel 0036's partial governance names. Channel-less: machine configuration read by the
717
791
  * harness, never surfaced to the model (code.claude.com/docs/en/settings, retrieved
718
- * 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).
719
795
  */
720
796
  export const settingsLocal = kind({
721
797
  name: "settings-local",
@@ -771,6 +847,10 @@ export const settingsLocalDefaultContract = [
771
847
  * address order, then the residue — which the member itself authors through
772
848
  * {@link Settings.residue}, flat and key-sorted behind its typed fields
773
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).
774
854
  */
775
855
  export const settings = kind({
776
856
  name: "settings",
@@ -828,7 +908,9 @@ export const settingsDefaultContract = [
828
908
  * its own kind ({@link mcpServer}). That segment and this member's opaque residue are one
829
909
  * file: emit renders the declared segment first, then the residue — which the member itself
830
910
  * authors through {@link Mcp.residue}, flat and key-sorted
831
- * (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).
832
914
  */
833
915
  export const mcp = kind({
834
916
  name: "mcp",
@@ -851,6 +933,25 @@ export const mcp = kind({
851
933
  * never stranded by temper's release cadence.
852
934
  */
853
935
  export const mcpDefaultContract = [];
936
+ /**
937
+ * The cite behind {@link pathsGateGuidance} — one doc page and three dated probes: the
938
+ * gating hard-error, and the two negative findings that a shell read and a search read
939
+ * open no path gate. Dated facts go stale together, so they live in one place: a re-probe
940
+ * re-dates this const and every clause reading it moves with it.
941
+ */
942
+ const PATHS_GATE_CITE = "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211; shell and search reads open no path gate, probed on Claude Code 2.1.281, 2026-09-24)";
943
+ /**
944
+ * The `mentionReachable("paths", "paths")` clause's guidance, for a member kind that
945
+ * carries a `paths` gate and can mention another that does. The reachability argument is
946
+ * a property of the gate mechanic, not of either kind, so the two default contracts that
947
+ * bind this clause — `skill` and `rule` — differ in exactly one word: the noun naming the
948
+ * mentioning member.
949
+ */
950
+ function pathsGateGuidance(member) {
951
+ return ("A mention of a gated member is actionable only where that member can be invoked. A `paths` gate removes its member from every invocation channel until a file tool (read, edit, write) touches a matching path, and invoking a gated member from outside its gate hard-errors (`Unknown skill`) — the harness then tells the user it doesn't exist. " +
952
+ `So a ${member} that loads where its target cannot be invoked hands Claude an obligation it cannot act on. Two remedies: scope this ${member}'s \`paths\` to the target's gate, or ungate the target. ` +
953
+ "Advisory because the containment test is literal — every glob here must appear verbatim in the gate — so a semantically narrower glob (`src/**/*.ts` inside `src/**`) false-fires; retune or drop this clause in your own contract when it does. The judgment is over the gates, not over how they open: only a file tool (read, edit, write) opens a path gate — a shell read of a matching path, or a search tool's, opens none — so a session that works inside the gate through the shell alone loads neither member, and nothing static can see that.");
954
+ }
854
955
  /**
855
956
  * The default contract for `skill` — Anthropic's documented skill contract: the Agent
856
957
  * Skills open standard (agentskills.io), Anthropic's platform upload
@@ -947,8 +1048,8 @@ export const skillDefaultContract = [
947
1048
  }),
948
1049
  clause(mentionReachable("paths", "paths"), {
949
1050
  severity: "advisory",
950
- guidance: "A mention of a gated member is actionable only where that member can be invoked. A `paths` gate removes its member from every invocation channel until a file tool (read, edit, write) touches a matching path, and invoking a gated member from outside its gate hard-errors (`Unknown skill`) — the harness then tells the user it doesn't exist. So a skill that loads where its target cannot be invoked hands Claude an obligation it cannot act on. Two remedies: scope this skill's `paths` to the target's gate, or ungate the target. Advisory because the containment test is literal — every glob here must appear verbatim in the gate — so a semantically narrower glob (`src/**/*.ts` inside `src/**`) false-fires; retune or drop this clause in your own contract when it does. The judgment is over the gates, not over how they open: only a file tool (read, edit, write) opens a path gate — a shell read of a matching path, or a search tool's, opens none — so a session that works inside the gate through the shell alone loads neither member, and nothing static can see that.",
951
- cite: "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211; shell and search reads open no path gate, probed on Claude Code 2.1.281, 2026-09-24)",
1051
+ guidance: pathsGateGuidance("skill"),
1052
+ cite: PATHS_GATE_CITE,
952
1053
  }),
953
1054
  ];
954
1055
  /**
@@ -1056,8 +1157,8 @@ export const ruleDefaultContract = [
1056
1157
  }),
1057
1158
  clause(mentionReachable("paths", "paths"), {
1058
1159
  severity: "advisory",
1059
- guidance: "A mention of a gated member is actionable only where that member can be invoked. A `paths` gate removes its member from every invocation channel until a file tool (read, edit, write) touches a matching path, and invoking a gated member from outside its gate hard-errors (`Unknown skill`) — the harness then tells the user it doesn't exist. So a rule that loads where its target cannot be invoked hands Claude an obligation it cannot act on. Two remedies: scope this rule's `paths` to the target's gate, or ungate the target. Advisory because the containment test is literal — every glob here must appear verbatim in the gate — so a semantically narrower glob (`src/**/*.ts` inside `src/**`) false-fires; retune or drop this clause in your own contract when it does. The judgment is over the gates, not over how they open: only a file tool (read, edit, write) opens a path gate — a shell read of a matching path, or a search tool's, opens none — so a session that works inside the gate through the shell alone loads neither member, and nothing static can see that.",
1060
- cite: "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211; shell and search reads open no path gate, probed on Claude Code 2.1.281, 2026-09-24)",
1160
+ guidance: pathsGateGuidance("rule"),
1161
+ cite: PATHS_GATE_CITE,
1061
1162
  }),
1062
1163
  ];
1063
1164
  /**
@@ -1224,25 +1325,21 @@ export const hookDefaultContract = [
1224
1325
  * projects its tap hook at. The event-name is the author-facing token a telemetry
1225
1326
  * verifier names (`contract.ts`'s `telemetry`, the `roster.rs` admissibility set); the
1226
1327
  * `event` is the `hooks.<Event>` key the tap registers under, and the `matcher` scopes
1227
- * the fire to the telemetry-relevant subset — each an external fact
1228
- * (code.claude.com/docs/en/hooks, retrieved 2026-08-26):
1328
+ * the fire to the telemetry-relevant subset — a load reason, a command name, a tool name,
1329
+ * each an external fact (code.claude.com/docs/en/hooks, retrieved 2026-08-26).
1330
+ *
1331
+ * The pairing's one home is the engine's own `TAP_HOOK_BINDINGS` table
1332
+ * (`src/builtin_kind.rs`), which states and cites each event's own matcher and resolves the
1333
+ * table through an exhaustive match over the `TapEvent` it already classifies hook payloads
1334
+ * into — and which `check` reads for the admissibility set too, so the names a telemetry
1335
+ * verifier may declare and the names a tap hook is synthesized for are one enumeration. The
1336
+ * binding read here is machine-written across the `generated/` seam from that table and held
1337
+ * byte-equal by the seam gate (`tests/it/seam_bindings_current.rs`).
1229
1338
  *
1230
- * - `InstructionsLoaded` fires on a rule/memory load; its matcher filters the load
1231
- * reason across all documented reasons (session_start, nested_traversal, path_glob_match,
1232
- * include, compact), so always-on members that load at session start are recorded.
1233
- * - `SkillInvoked` is a skill invocation, surfaced under `PostToolUse` with the tool-name
1234
- * matcher `Skill` — the tap's own read of a skill call.
1235
- * - `UserPromptExpansion` fires on a command expansion; its matcher filters the command
1236
- * name, `.*` capturing every one.
1237
- * - `ToolUse` fires after any tool call; its matcher filters the tool name, `.*`
1238
- * capturing every one.
1339
+ * The widened annotation stays: `tapHookRows` looks up an author-supplied event name, which
1340
+ * the generated literal's own narrow key type would refuse.
1239
1341
  */
1240
- export const TELEMETRY_EVENT_HOOKS = {
1241
- InstructionsLoaded: { event: "InstructionsLoaded", matcher: ".*" },
1242
- SkillInvoked: { event: "PostToolUse", matcher: "Skill" },
1243
- UserPromptExpansion: { event: "UserPromptExpansion", matcher: ".*" },
1244
- ToolUse: { event: "PostToolUse", matcher: ".*" },
1245
- };
1342
+ export const TELEMETRY_EVENT_HOOKS = TAP_EVENT_HOOKS;
1246
1343
  /**
1247
1344
  * Every documented `.mcp.json` server transport — the closed set a server entry's `type`
1248
1345
  * is drawn from (code.claude.com/docs/en/mcp, retrieved 2026-07-15). `stdio` is the
@@ -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";