@dtmd/temper 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/assembly.d.ts +20 -5
- package/dist/src/assembly.js +17 -7
- package/dist/src/builtins.d.ts +241 -52
- package/dist/src/builtins.js +248 -42
- package/dist/src/claude-code.d.ts +3 -2
- package/dist/src/claude-code.js +8 -1
- package/dist/src/contract.d.ts +20 -1
- package/dist/src/contract.js +20 -1
- package/dist/src/declarations.d.ts +26 -38
- package/dist/src/declarations.js +169 -92
- package/dist/src/emit.d.ts +9 -5
- package/dist/src/emit.js +265 -122
- package/dist/src/generated/AssemblyFactRow.d.ts +7 -5
- package/dist/src/generated/Declarations.d.ts +2 -2
- package/dist/src/generated/PayloadMember.d.ts +9 -3
- package/dist/src/generated/gate-commands.d.ts +2 -0
- package/dist/src/generated/gate-commands.js +3 -0
- package/dist/src/generated/index.d.ts +1 -0
- package/dist/src/generated/index.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/kind.d.ts +11 -4
- package/dist/src/kind.js +29 -0
- package/dist/src/member-address.d.ts +133 -25
- package/dist/src/member-address.js +144 -31
- package/dist/src/prose.d.ts +54 -13
- package/dist/src/prose.js +52 -11
- package/package.json +3 -3
package/dist/src/builtins.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* — never from the root.
|
|
11
11
|
*/
|
|
12
12
|
import { kind } from "./kind.js";
|
|
13
|
+
import { isNameQualifier } from "./member-address.js";
|
|
13
14
|
import { allowedChars, clause, closedKeys, degree, deny, enumOf, extent, forbiddenKeys, globValid, maxLen, mentionReachable, minLen, nameMatchesDir, optional, required, shape, type, uniqueName, when, } from "./contract.js";
|
|
14
15
|
/**
|
|
15
16
|
* `supporting-doc` — a skill's bundled reference document, at the nested-file locus:
|
|
@@ -109,6 +110,24 @@ export const memory = kind({
|
|
|
109
110
|
registration: [{ via: "always" }],
|
|
110
111
|
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.",
|
|
111
112
|
});
|
|
113
|
+
/**
|
|
114
|
+
* `handler` — one entry in a hook's `hooks` array, at the **embedded** locus: it owns no
|
|
115
|
+
* file and no glob, living inside its host matcher group and keyed by its position there
|
|
116
|
+
* (`…/handler/0`). Fields-only (no body slot) and channel-less: a handler reaches the
|
|
117
|
+
* world only through the hook whose event fires it. Matching handlers run in parallel, so
|
|
118
|
+
* the position is an address and carries no runtime meaning.
|
|
119
|
+
*
|
|
120
|
+
* The kind's own format fact — that a matcher group carries its handlers in a `hooks`
|
|
121
|
+
* array, keyed by position — is cited here, the point of claim.
|
|
122
|
+
*/
|
|
123
|
+
export const handler = kind({
|
|
124
|
+
name: "handler",
|
|
125
|
+
locus: { kind: "embedded" },
|
|
126
|
+
unitShape: "file",
|
|
127
|
+
registration: [],
|
|
128
|
+
shape: "fields",
|
|
129
|
+
cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-09-29)",
|
|
130
|
+
});
|
|
112
131
|
/**
|
|
113
132
|
* The manifest Claude Code's harness-level settings reside in — the file the assembly's
|
|
114
133
|
* residual settings keys fold into as opaque residue, the same manifest the `hook` kind's
|
|
@@ -118,35 +137,111 @@ export const SETTINGS_MANIFEST = "settings.json";
|
|
|
118
137
|
/** The `hooks.<Event>` collection address's key-path — the `hook` kind's own address, and
|
|
119
138
|
* the tap hook registration's, since a tap hook is an ordinary `hook` entry. */
|
|
120
139
|
const HOOK_KEY_PATH = "hooks.<Event>";
|
|
140
|
+
/**
|
|
141
|
+
* The key a matcher group carries its handler array under — {@link Hook}'s `hooks` field,
|
|
142
|
+
* the `member_key` of the kind's group-array entry shape, and the field name the join in
|
|
143
|
+
* `declarations.ts` reads to merge a synthesized tap hook into an authored group. One
|
|
144
|
+
* home, so the authored surface, the declared entry shape and the join cannot drift
|
|
145
|
+
* (code.claude.com/docs/en/hooks, "Matcher patterns", retrieved 2026-09-29).
|
|
146
|
+
*/
|
|
147
|
+
export const HOOK_HANDLER_KEY = "hooks";
|
|
148
|
+
/** The one group-level field a matcher group lifts beside its handlers — {@link Hook}'s
|
|
149
|
+
* `matcher`, and the other half of the group's identity the join keys on (same source). */
|
|
150
|
+
export const HOOK_MATCHER_KEY = "matcher";
|
|
151
|
+
/**
|
|
152
|
+
* A hook member's **name** — its lifecycle `event`, then `:` and the matcher's authored
|
|
153
|
+
* bytes; the bare event where the group binds no matcher
|
|
154
|
+
* (`hook:PostToolUse:Edit|Write`, `hook:SessionStart`).
|
|
155
|
+
*
|
|
156
|
+
* Name and collection key part company because the **group** is the member and the event
|
|
157
|
+
* keys them all: Claude Code nests several matcher groups under one event, and two
|
|
158
|
+
* members at one address is a malformed lock. The matcher is joined verbatim, never
|
|
159
|
+
* normalized — `Edit|Write` and `Edit, Write` are two groups on the wire and two members
|
|
160
|
+
* here — which is also why an authored empty matcher joins as the empty bytes it is.
|
|
161
|
+
*/
|
|
162
|
+
export function hookMemberName(event, matcher) {
|
|
163
|
+
return matcher === undefined ? event : `${event}:${matcher}`;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The `hooks.<Event>` collection key a hook member's name was joined onto — its text
|
|
167
|
+
* before its own first `:`. The inverse of {@link hookMemberName} for the one reader that
|
|
168
|
+
* needs the key back: a registration row keys where the group writes, and the group still
|
|
169
|
+
* writes under `hooks.<Event>` (`declarations.ts`). No documented lifecycle event carries
|
|
170
|
+
* a colon, so the first one is the join's.
|
|
171
|
+
*/
|
|
172
|
+
export function hookCollectionKey(name) {
|
|
173
|
+
const colon = name.indexOf(":");
|
|
174
|
+
return colon < 0 ? name : name.slice(0, colon);
|
|
175
|
+
}
|
|
121
176
|
/**
|
|
122
177
|
* `hook` — a `settings.json` `hooks.<Event>` registration member: a fields-only kind (no
|
|
123
178
|
* body slot), its members discovered off the `.claude/settings.json` manifest at the
|
|
124
179
|
* `hooks.<Event>` collection address, keyed by lifecycle event; registers on the `event`
|
|
125
180
|
* channel (code.claude.com/docs/en/hooks, retrieved 2026-07-15). The first manifest kind
|
|
126
181
|
* temper ships — the read side of 0021's manifest-authoring surface.
|
|
182
|
+
*
|
|
183
|
+
* Its one template layer names {@link handler}, the embedded kind of each entry in the
|
|
184
|
+
* group's `hooks` array. An embedded layer, so it carries no `path` — a handler owns no
|
|
185
|
+
* unit of its own, unlike `skill`'s file-child twin.
|
|
127
186
|
*/
|
|
128
|
-
|
|
187
|
+
const hookGroup = kind({
|
|
129
188
|
name: "hook",
|
|
130
189
|
locus: { kind: "at", root: ".claude", glob: SETTINGS_MANIFEST },
|
|
131
190
|
unitShape: "file",
|
|
132
191
|
registration: [{ via: "event", field: "event" }],
|
|
133
192
|
shape: "fields",
|
|
134
|
-
collectionAddress: {
|
|
193
|
+
collectionAddress: {
|
|
194
|
+
manifest: SETTINGS_MANIFEST,
|
|
195
|
+
keyPath: HOOK_KEY_PATH,
|
|
196
|
+
entryShape: `group-array(${HOOK_HANDLER_KEY};${HOOK_MATCHER_KEY})`,
|
|
197
|
+
},
|
|
198
|
+
templates: [{ kind: handler }],
|
|
135
199
|
guidance: "keep a handler's `type` among `command`/`http`/`mcp_tool`/`prompt`/`agent`; a `command` handler needs a `command`, an `http` handler a `url`; the `matcher` filters tool-scoped events and is inert on events that carry no tool (`UserPromptSubmit`, `Stop`, and their siblings).",
|
|
136
200
|
});
|
|
137
201
|
/**
|
|
138
|
-
* The
|
|
202
|
+
* The one kind whose member name is not the `name` the author wrote: the author names the
|
|
203
|
+
* lifecycle **event**, and the member's identity is that event joined with its matcher
|
|
204
|
+
* ({@link hookMemberName}), because the event keys every group under it and two members
|
|
205
|
+
* at one address is a malformed lock. The authored property keeps the event, so the
|
|
206
|
+
* module the lift scaffolds and the row the emit writes both spell the key the wire uses;
|
|
207
|
+
* the composition happens here, once, rather than at every reader of a hook's address.
|
|
208
|
+
*
|
|
209
|
+
* # Throws
|
|
210
|
+
* If the matcher carries a `/` — the separator the member-address grammar cuts an
|
|
211
|
+
* address at, which in a name truncates the member and re-seats every handler beneath it
|
|
212
|
+
* ({@link isNameQualifier}).
|
|
213
|
+
*/
|
|
214
|
+
function hookMember(init) {
|
|
215
|
+
if (init.matcher !== undefined && !isNameQualifier(init.matcher)) {
|
|
216
|
+
throw new Error(`hook \`${init.name}\`: matcher \`${init.matcher}\` carries a \`/\`, and a hook's name ` +
|
|
217
|
+
`joins its matcher after a \`:\` (\`hook:${init.name}:${init.matcher}\`) — the \`/\` is ` +
|
|
218
|
+
`the separator an address is cut at, so the member and its handlers would answer to ` +
|
|
219
|
+
`an address naming something else (specs/model/representation.md, "member").`);
|
|
220
|
+
}
|
|
221
|
+
return hookGroup({ ...init, name: hookMemberName(init.name, init.matcher) });
|
|
222
|
+
}
|
|
223
|
+
/** The authored `hook` constructor — {@link hookGroup}'s facts over {@link hookMember}'s
|
|
224
|
+
* name composition. */
|
|
225
|
+
export const hook = Object.assign(hookMember, {
|
|
226
|
+
facts: hookGroup.facts,
|
|
227
|
+
key: hookGroup.key,
|
|
228
|
+
render: hookGroup.render,
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
|
|
139
232
|
* provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
|
|
140
|
-
*
|
|
141
|
-
*
|
|
233
|
+
* One matcher group like any authored one: the per-event `matcher`
|
|
234
|
+
* {@link TELEMETRY_EVENT_HOOKS} names lifted beside a single `command` handler carrying
|
|
235
|
+
* the tap's own command, so a synthesized row and an authored one are the same shape and
|
|
236
|
+
* the join in `declarations.ts` can merge one into the other.
|
|
142
237
|
*/
|
|
143
238
|
export function tapHookRegistration(command, matcher) {
|
|
239
|
+
const handler = { type: "command", command };
|
|
144
240
|
return {
|
|
145
241
|
keyPath: HOOK_KEY_PATH,
|
|
146
242
|
fields: [
|
|
147
|
-
[
|
|
148
|
-
[
|
|
149
|
-
["matcher", matcher],
|
|
243
|
+
[HOOK_MATCHER_KEY, matcher],
|
|
244
|
+
[HOOK_HANDLER_KEY, [handler]],
|
|
150
245
|
],
|
|
151
246
|
};
|
|
152
247
|
}
|
|
@@ -503,12 +598,9 @@ const RESERVED_MARKETPLACE_NAMES = [
|
|
|
503
598
|
* catalog published under a name that later becomes reserved stops loading for every user
|
|
504
599
|
* who already added it. That is the one clause here worth more than a lint.
|
|
505
600
|
*
|
|
506
|
-
* The `source` union's per-form required fields
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
* before these comments were last touched. The per-source-form requirements now hold via guarded
|
|
510
|
-
* clauses at `plugins[*].source`: the string form needs `leading-dot-slash` shape; each object
|
|
511
|
-
* form (`github`, `url`, `git-subdir`, `npm`) needs its required fields.
|
|
601
|
+
* The `source` union's per-form required fields gate as `when` clauses at
|
|
602
|
+
* `plugins[*].source`: the string form needs `leading-dot-slash` shape, and each object
|
|
603
|
+
* form (`github`, `url`, `git-subdir`, `npm`) needs its own required fields.
|
|
512
604
|
*
|
|
513
605
|
* Deliberately absent as undecidable, and never a clause (`specs/intent.md`, invariant 2):
|
|
514
606
|
* the docs *also* block names that "impersonate official marketplaces" (`official-claude-plugins`,
|
|
@@ -723,6 +815,42 @@ export const settingsDefaultContract = [
|
|
|
723
815
|
cite: "https://code.claude.com/docs/en/settings-reference#attribution (retrieved 2026-09-22)",
|
|
724
816
|
}),
|
|
725
817
|
];
|
|
818
|
+
/**
|
|
819
|
+
* `mcp` — `.mcp.json`, a whole-file JSON document at the **committed** commitment class:
|
|
820
|
+
* the program authors every key, `emit` renders the file whole, and the member's byte
|
|
821
|
+
* fingerprint makes a hand edit to any part of it drift under the root `fresh` clause
|
|
822
|
+
* (decision 0050). Identity is the fixed singleton stem `.mcp` (the `file` unit shape — a
|
|
823
|
+
* project's committed MCP manifest is the one file at the repository root, so no declared
|
|
824
|
+
* key names it). Channel-less: configuration the harness reads, never surfaced to the
|
|
825
|
+
* model — the connections it carries reach the world as {@link mcpServer} members.
|
|
826
|
+
*
|
|
827
|
+
* It is the **container** of one registration collection address, `mcpServers`, which keeps
|
|
828
|
+
* its own kind ({@link mcpServer}). That segment and this member's opaque residue are one
|
|
829
|
+
* file: emit renders the declared segment first, then the residue — which the member itself
|
|
830
|
+
* authors through {@link Mcp.residue}, flat and key-sorted
|
|
831
|
+
* (code.claude.com/docs/en/mcp, retrieved 2026-09-29).
|
|
832
|
+
*/
|
|
833
|
+
export const mcp = kind({
|
|
834
|
+
name: "mcp",
|
|
835
|
+
locus: { kind: "at", root: ".", glob: ".mcp.json" },
|
|
836
|
+
format: "json-document",
|
|
837
|
+
unitShape: "file",
|
|
838
|
+
registration: [],
|
|
839
|
+
});
|
|
840
|
+
/**
|
|
841
|
+
* The default contract for `mcp` — **deliberately empty**, and empty *by construction*
|
|
842
|
+
* rather than by omission. `.mcp.json` documents exactly one top-level key, `mcpServers`
|
|
843
|
+
* (code.claude.com/docs/en/mcp, retrieved 2026-09-29), and that key is
|
|
844
|
+
* {@link mcpServer}'s collection address: its shape is that kind's contract to hold,
|
|
845
|
+
* server by server, so gating it here would contract the same segment twice. Nothing else
|
|
846
|
+
* is left to range over — a format that documents almost no contract earns an almost-empty
|
|
847
|
+
* default contract, the honest encoding rather than a gap.
|
|
848
|
+
*
|
|
849
|
+
* No `closedKeys()` either: the remainder rides {@link Mcp.residue} opaque and named, so a
|
|
850
|
+
* key upstream adds is unmodeled rather than indicted, and a valid committed manifest is
|
|
851
|
+
* never stranded by temper's release cadence.
|
|
852
|
+
*/
|
|
853
|
+
export const mcpDefaultContract = [];
|
|
726
854
|
/**
|
|
727
855
|
* The default contract for `skill` — Anthropic's documented skill contract: the Agent
|
|
728
856
|
* Skills open standard (agentskills.io), Anthropic's platform upload
|
|
@@ -814,13 +942,13 @@ export const skillDefaultContract = [
|
|
|
814
942
|
}),
|
|
815
943
|
clause(globValid("paths"), {
|
|
816
944
|
severity: "required",
|
|
817
|
-
guidance: "The optional `paths` scope gates every invocation channel until
|
|
945
|
+
guidance: "The optional `paths` scope gates every invocation channel until a file tool (read, edit, write) touches a path its globs match; each entry is a glob (brace expansion supported). An unparseable pattern — an unclosed `[`, say — is invalid under globset and silently matches nothing, so the gate never opens and the skill never registers, with no error surfaced. Fix the pattern or drop the field.",
|
|
818
946
|
cite: "https://code.claude.com/docs/en/memory#path-specific-rules (retrieved 2026-07-15)",
|
|
819
947
|
}),
|
|
820
948
|
clause(mentionReachable("paths", "paths"), {
|
|
821
949
|
severity: "advisory",
|
|
822
|
-
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
|
|
823
|
-
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211)",
|
|
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)",
|
|
824
952
|
}),
|
|
825
953
|
];
|
|
826
954
|
/**
|
|
@@ -899,9 +1027,11 @@ export const agentDefaultContract = [
|
|
|
899
1027
|
* v2.0.64). All sources retrieved 2026-07-15.
|
|
900
1028
|
*
|
|
901
1029
|
* `paths` is the one documented frontmatter key for rules: glob patterns
|
|
902
|
-
* (brace expansion supported) that scope the rule to matching
|
|
1030
|
+
* (brace expansion supported) that scope the rule to matching paths. Rules
|
|
903
1031
|
* without it load at launch with the same priority as CLAUDE.md; path-scoped
|
|
904
|
-
* rules load when
|
|
1032
|
+
* rules load when a file tool (read, edit, write) touches a matching path — a
|
|
1033
|
+
* shell or search read of that path opens nothing (probed on Claude Code
|
|
1034
|
+
* 2.1.281, 2026-09-24; decision 0061). Note skills now take a
|
|
905
1035
|
* `paths` key too — the two schemas are separate. (Guidance only: an
|
|
906
1036
|
* optional field asserts nothing decidable, so it carries no clause of its
|
|
907
1037
|
* own: `required` is the one
|
|
@@ -916,7 +1046,7 @@ export const ruleDefaultContract = [
|
|
|
916
1046
|
}),
|
|
917
1047
|
clause(globValid("paths"), {
|
|
918
1048
|
severity: "required",
|
|
919
|
-
guidance: "`paths` is the one documented rules key: globs (brace expansion supported) that
|
|
1049
|
+
guidance: "`paths` is the one documented rules key: globs (brace expansion supported) that load the rule when a file tool (read, edit, write) touches a matching path. An unparseable pattern — an unclosed `[`, say — is invalid under globset and silently matches nothing, so the rule never loads where you meant it to, with no error surfaced. Fix the pattern or drop it.",
|
|
920
1050
|
cite: "https://code.claude.com/docs/en/memory#path-specific-rules (retrieved 2026-07-15)",
|
|
921
1051
|
}),
|
|
922
1052
|
clause(extent("lines", 200), {
|
|
@@ -926,8 +1056,8 @@ export const ruleDefaultContract = [
|
|
|
926
1056
|
}),
|
|
927
1057
|
clause(mentionReachable("paths", "paths"), {
|
|
928
1058
|
severity: "advisory",
|
|
929
|
-
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
|
|
930
|
-
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211)",
|
|
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)",
|
|
931
1061
|
}),
|
|
932
1062
|
];
|
|
933
1063
|
/**
|
|
@@ -950,7 +1080,7 @@ export const memoryAnthropicDefaultContract = [
|
|
|
950
1080
|
];
|
|
951
1081
|
/**
|
|
952
1082
|
* Every documented Claude Code hook lifecycle event — the closed set a `hooks.<Event>`
|
|
953
|
-
* key is drawn from (code.claude.com/docs/en/hooks, "Hook events", retrieved 2026-
|
|
1083
|
+
* key is drawn from (code.claude.com/docs/en/hooks, "Hook events", retrieved 2026-09-25).
|
|
954
1084
|
* The allowlist the `hook` default contract's one decidable clause ranges over; the
|
|
955
1085
|
* update ritual when the docs add an event is to re-fetch and extend this set, never to
|
|
956
1086
|
* re-derive from memory.
|
|
@@ -978,37 +1108,115 @@ const DOCUMENTED_HOOK_EVENTS = [
|
|
|
978
1108
|
"InstructionsLoaded",
|
|
979
1109
|
"ConfigChange",
|
|
980
1110
|
"CwdChanged",
|
|
1111
|
+
"DirectoryAdded",
|
|
981
1112
|
"FileChanged",
|
|
982
1113
|
"WorktreeCreate",
|
|
983
1114
|
"WorktreeRemove",
|
|
984
1115
|
"PreCompact",
|
|
985
1116
|
"PostCompact",
|
|
1117
|
+
"PreModelSwitch",
|
|
1118
|
+
"PostModelSwitch",
|
|
986
1119
|
"Elicitation",
|
|
987
1120
|
"ElicitationResult",
|
|
988
1121
|
"SessionEnd",
|
|
989
1122
|
];
|
|
1123
|
+
/**
|
|
1124
|
+
* Every documented Claude Code hook handler kind — the closed set a handler's `type` is
|
|
1125
|
+
* drawn from (code.claude.com/docs/en/hooks, "Hook handler fields", retrieved 2026-09-25).
|
|
1126
|
+
* The allowlist {@link handlerDefaultContract}'s enum ranges over, and the guard values
|
|
1127
|
+
* its per-kind `when` clauses partition; the update ritual when the docs add a handler
|
|
1128
|
+
* kind is to re-fetch, extend this set, widen {@link Handler}'s `type` — its one home,
|
|
1129
|
+
* since a group authors its handlers rather than one handler's keys — and give the new
|
|
1130
|
+
* kind its own guarded clause, never to re-derive from memory.
|
|
1131
|
+
*/
|
|
1132
|
+
const DOCUMENTED_HOOK_HANDLER_TYPES = ["command", "http", "mcp_tool", "prompt", "agent"];
|
|
1133
|
+
/**
|
|
1134
|
+
* The default contract for `handler` — the handler-level half of Anthropic's documented
|
|
1135
|
+
* hooks contract (code.claude.com/docs/en/hooks, retrieved 2026-09-25), and the only home
|
|
1136
|
+
* and the only binding those six clauses have.
|
|
1137
|
+
*
|
|
1138
|
+
* The clauses address by bare name because a handler is a member: the group-array read
|
|
1139
|
+
* gives each entry of a group's `hooks` array its own member at
|
|
1140
|
+
* `<hook-address>/handler/<position>`, carrying that entry's own keys
|
|
1141
|
+
* (`hook_group_members`, `src/json_manifest.rs`), so `type`, `command`, `url`, `server`,
|
|
1142
|
+
* `tool` and `prompt` are its fields — no path into the handler array is ever spelled, and
|
|
1143
|
+
* none needs to be. The documented per-kind requirements therefore gate as `when` clauses
|
|
1144
|
+
* in the shape {@link mcpServerDefaultContract} already holds: a guard over `type`, a body
|
|
1145
|
+
* carrying that kind's required fields. `prompt` and `agent` share one guard because the
|
|
1146
|
+
* docs give them one table and one required field.
|
|
1147
|
+
*
|
|
1148
|
+
* The enum settles which values are legal, never that a value is present, and an absent
|
|
1149
|
+
* `type` enters no guard — so presence is its own clause beside the enum. The docs'
|
|
1150
|
+
* common-fields table marks `type` required and gives it no default, so a handler naming
|
|
1151
|
+
* none is dead configuration rather than a defaulted one.
|
|
1152
|
+
*/
|
|
1153
|
+
export const handlerDefaultContract = [
|
|
1154
|
+
clause(required("type"), {
|
|
1155
|
+
severity: "required",
|
|
1156
|
+
guidance: "A handler names how it fires, and the documented common-fields table gives `type` no default — so a handler carrying none is dead configuration: nothing to run, and no per-kind requirement for temper to hold it to either. Name one of the documented five (`command`, `http`, `mcp_tool`, `prompt`, `agent`).",
|
|
1157
|
+
cite: "https://code.claude.com/docs/en/hooks#common-fields (retrieved 2026-09-25)",
|
|
1158
|
+
}),
|
|
1159
|
+
clause(enumOf("type", DOCUMENTED_HOOK_HANDLER_TYPES), {
|
|
1160
|
+
severity: "required",
|
|
1161
|
+
guidance: "A handler's `type` names how the hook fires; a value outside the documented five (`command`, `http`, `mcp_tool`, `prompt`, `agent`) is a handler Claude Code cannot run. If this is a newly-documented handler kind, re-fetch code.claude.com/docs/en/hooks and extend temper's cited set rather than working around the finding.",
|
|
1162
|
+
cite: "https://code.claude.com/docs/en/hooks#common-fields (retrieved 2026-09-25)",
|
|
1163
|
+
}),
|
|
1164
|
+
when(enumOf("type", ["command"]), [
|
|
1165
|
+
clause(required("command"), {
|
|
1166
|
+
severity: "required",
|
|
1167
|
+
guidance: "A `command` handler runs a shell command, so it must carry one — the command line to execute, or, beside `args`, the executable to spawn directly. Without it the handler registers and does nothing.",
|
|
1168
|
+
cite: "https://code.claude.com/docs/en/hooks#command-hook-fields (retrieved 2026-09-25)",
|
|
1169
|
+
}),
|
|
1170
|
+
], { cite: "https://code.claude.com/docs/en/hooks#command-hook-fields (retrieved 2026-09-25)" }),
|
|
1171
|
+
when(enumOf("type", ["http"]), [
|
|
1172
|
+
clause(required("url"), {
|
|
1173
|
+
severity: "required",
|
|
1174
|
+
guidance: "An `http` handler POSTs the event's JSON input to a URL, so it must carry one. Without it there is no endpoint to call.",
|
|
1175
|
+
cite: "https://code.claude.com/docs/en/hooks#http-hook-fields (retrieved 2026-09-25)",
|
|
1176
|
+
}),
|
|
1177
|
+
], { cite: "https://code.claude.com/docs/en/hooks#http-hook-fields (retrieved 2026-09-25)" }),
|
|
1178
|
+
when(enumOf("type", ["mcp_tool"]), [
|
|
1179
|
+
clause(required("server"), {
|
|
1180
|
+
severity: "required",
|
|
1181
|
+
guidance: "An `mcp_tool` handler names the already-connected MCP server it calls. For a plugin-bundled server that is the scoped `plugin:<plugin-name>:<server-name>` name, not the bare server key.",
|
|
1182
|
+
cite: "https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields (retrieved 2026-09-25)",
|
|
1183
|
+
}),
|
|
1184
|
+
clause(required("tool"), {
|
|
1185
|
+
severity: "required",
|
|
1186
|
+
guidance: "An `mcp_tool` handler names the tool it calls on its server; the server alone does not say what to invoke.",
|
|
1187
|
+
cite: "https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields (retrieved 2026-09-25)",
|
|
1188
|
+
}),
|
|
1189
|
+
], { cite: "https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields (retrieved 2026-09-25)" }),
|
|
1190
|
+
when(enumOf("type", ["prompt", "agent"]), [
|
|
1191
|
+
clause(required("prompt"), {
|
|
1192
|
+
severity: "required",
|
|
1193
|
+
guidance: "A `prompt` or `agent` handler sends prompt text to a model, so it must carry one; `$ARGUMENTS` stands for the hook input JSON. The two kinds share this requirement — the docs give them one field table.",
|
|
1194
|
+
cite: "https://code.claude.com/docs/en/hooks#prompt-and-agent-hook-fields (retrieved 2026-09-25)",
|
|
1195
|
+
}),
|
|
1196
|
+
], { cite: "https://code.claude.com/docs/en/hooks#prompt-and-agent-hook-fields (retrieved 2026-09-25)" }),
|
|
1197
|
+
];
|
|
990
1198
|
/**
|
|
991
1199
|
* The default contract for `hook` — Anthropic's documented hooks contract
|
|
992
|
-
* (code.claude.com/docs/en/hooks, retrieved 2026-
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
1200
|
+
* (code.claude.com/docs/en/hooks, retrieved 2026-09-25).
|
|
1201
|
+
*
|
|
1202
|
+
* A hook surfaces at `hooks.<Event>`, so the lifecycle event is a member field, its name
|
|
1203
|
+
* carried off the collection key. That event is the first decidable, cited property: a key
|
|
1204
|
+
* outside the documented set is dead configuration — Claude Code silently never fires a
|
|
1205
|
+
* hook under an unrecognized event, so the strictest documented profile is that the event
|
|
1206
|
+
* is one temper's cited docs name.
|
|
998
1207
|
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1005
|
-
* the read never surfaces, so it is no clause at all — the addressing-reach gap remains.
|
|
1208
|
+
* The event clause is the whole of it. The handler-level clauses are
|
|
1209
|
+
* {@link handlerDefaultContract}'s and bind under `handler` alone: a hook member is its
|
|
1210
|
+
* whole matcher group, and each entry of the group's `hooks` array is a `handler` member
|
|
1211
|
+
* keyed by its position there — so `type`, `command` and `url` are fields of a member this
|
|
1212
|
+
* contract does not range over. The transitional double binding is retired with this: the
|
|
1213
|
+
* six clauses have one binding, under the kind whose members carry the fields they judge.
|
|
1006
1214
|
*/
|
|
1007
1215
|
export const hookDefaultContract = [
|
|
1008
1216
|
clause(enumOf("event", DOCUMENTED_HOOK_EVENTS), {
|
|
1009
1217
|
severity: "required",
|
|
1010
1218
|
guidance: "A hook keys under its lifecycle event; an event outside the documented set is dead configuration — Claude Code silently never fires a hook under an unrecognized event. If this is a newly-documented event, re-fetch code.claude.com/docs/en/hooks and extend temper's cited set rather than working around the finding.",
|
|
1011
|
-
cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-
|
|
1219
|
+
cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-09-25)",
|
|
1012
1220
|
}),
|
|
1013
1221
|
];
|
|
1014
1222
|
/**
|
|
@@ -1053,11 +1261,9 @@ const DOCUMENTED_MCP_TRANSPORTS = ["stdio", "http", "streamable-http", "sse", "w
|
|
|
1053
1261
|
* profile is that a present `type` names one temper's cited docs carry. An absent `type`
|
|
1054
1262
|
* passes — Claude Code reads it as `stdio`, the documented default.
|
|
1055
1263
|
*
|
|
1056
|
-
* The per-transport requirements
|
|
1057
|
-
*
|
|
1058
|
-
* `
|
|
1059
|
-
* src/contract.rs and the SDK's `when()` export has been available since 884a704 — both
|
|
1060
|
-
* well before these comments were last written.
|
|
1264
|
+
* The per-transport requirements gate as `when` clauses: a `stdio` server needs a
|
|
1265
|
+
* `command`, and a remote server (`http`, `streamable-http`, `sse`, or `ws`) needs a
|
|
1266
|
+
* `url`.
|
|
1061
1267
|
*/
|
|
1062
1268
|
export const mcpServerDefaultContract = [
|
|
1063
1269
|
clause(enumOf("type", DOCUMENTED_MCP_TRANSPORTS), {
|
|
@@ -7,7 +7,8 @@
|
|
|
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, Hook, InstalledPlugin, KnownMarketplace, Marketplace, MarketplacePlugin, MarketplaceSource, McpServer, Memory, PluginManifest, Rule, Settings, SettingsLocal, Skill, SupportingDoc, } from "./builtins.js";
|
|
11
|
-
export { agent, agentDefaultContract, command, commandDefaultContract, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
|
|
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";
|
|
12
13
|
export type { Blocks, File, Prose, Text } from "./prose.js";
|
|
13
14
|
export { blocks, file, text } from "./prose.js";
|
package/dist/src/claude-code.js
CHANGED
|
@@ -7,5 +7,12 @@
|
|
|
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, hook, hookDefaultContract, installedPlugin, installedPluginDefaultContract, knownMarketplace, knownMarketplaceDefaultContract, marketplace, marketplaceDefaultContract, mcpServer, mcpServerDefaultContract, memory, memoryAnthropicDefaultContract, pluginManifest, pluginManifestDefaultContract, rule, ruleDefaultContract, settings, settingsDefaultContract, settingsLocal, settingsLocalDefaultContract, skill, skillDefaultContract, supportingDoc, supportingDocDefaultContract, } from "./builtins.js";
|
|
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";
|
|
11
18
|
export { blocks, file, text } from "./prose.js";
|
package/dist/src/contract.d.ts
CHANGED
|
@@ -182,7 +182,8 @@ export declare const globValid: (field: string) => Predicate;
|
|
|
182
182
|
/**
|
|
183
183
|
* Every mention a selected member authors can fire where its target can be invoked. A
|
|
184
184
|
* target whose `gateField` carries globs is gated — removed from every invocation
|
|
185
|
-
* channel until
|
|
185
|
+
* channel until a file tool (read, edit, write) touches a matching path, a shell or
|
|
186
|
+
* search read of that path opening none — so a mention of it is actionable only
|
|
186
187
|
* inside that gate. Fires on a scoped source whose `scopeField` globs are not contained
|
|
187
188
|
* in the target's gate, and on an unscoped source mentioning a gated target.
|
|
188
189
|
*
|
|
@@ -244,6 +245,24 @@ export declare const fresh: () => Predicate;
|
|
|
244
245
|
* binding would have no member to hang off.
|
|
245
246
|
*/
|
|
246
247
|
export declare const locusDeclared: () => Predicate;
|
|
248
|
+
/**
|
|
249
|
+
* The engine that wrote the committed lock is the engine running the gate. The lock
|
|
250
|
+
* names the version that laid it down (`specs/model/pipeline.md`, "The lock"), and a
|
|
251
|
+
* run by a different one says so: the rows it is reading were compiled by a compiler it
|
|
252
|
+
* is not, so a normalized older spelling and a genuine behaviour change read alike from
|
|
253
|
+
* the inside. The remedy is one `emit`, which rewrites the lock whole in the running
|
|
254
|
+
* engine's canonical form.
|
|
255
|
+
*
|
|
256
|
+
* Names **no field**, like {@link locusDeclared}: the comparison is the lock's own
|
|
257
|
+
* stamp against the running binary's version, never any member's fields. So it composes
|
|
258
|
+
* into a root `contract` — the stamp is one fact about the whole harness, and there is
|
|
259
|
+
* no per-kind population for it to range over.
|
|
260
|
+
*
|
|
261
|
+
* Lock-only and offline, like {@link fresh}: a lock recording no stamp reads *unknown*
|
|
262
|
+
* rather than mismatched, and a harness with no committed lock has nothing to compare,
|
|
263
|
+
* so both are silent.
|
|
264
|
+
*/
|
|
265
|
+
export declare const engineMatches: () => Predicate;
|
|
247
266
|
/**
|
|
248
267
|
* Every edge the member's kind declares is placed by the format that renders the member
|
|
249
268
|
* — a format that omits one renders a contract the prose does not represent. Names no
|
package/dist/src/contract.js
CHANGED
|
@@ -114,7 +114,8 @@ export const globValid = (field) => ({ key: "glob-valid", field });
|
|
|
114
114
|
/**
|
|
115
115
|
* Every mention a selected member authors can fire where its target can be invoked. A
|
|
116
116
|
* target whose `gateField` carries globs is gated — removed from every invocation
|
|
117
|
-
* channel until
|
|
117
|
+
* channel until a file tool (read, edit, write) touches a matching path, a shell or
|
|
118
|
+
* search read of that path opening none — so a mention of it is actionable only
|
|
118
119
|
* inside that gate. Fires on a scoped source whose `scopeField` globs are not contained
|
|
119
120
|
* in the target's gate, and on an unscoped source mentioning a gated target.
|
|
120
121
|
*
|
|
@@ -180,6 +181,24 @@ export const fresh = () => ({ key: "fresh" });
|
|
|
180
181
|
* binding would have no member to hang off.
|
|
181
182
|
*/
|
|
182
183
|
export const locusDeclared = () => ({ key: "locus-declared" });
|
|
184
|
+
/**
|
|
185
|
+
* The engine that wrote the committed lock is the engine running the gate. The lock
|
|
186
|
+
* names the version that laid it down (`specs/model/pipeline.md`, "The lock"), and a
|
|
187
|
+
* run by a different one says so: the rows it is reading were compiled by a compiler it
|
|
188
|
+
* is not, so a normalized older spelling and a genuine behaviour change read alike from
|
|
189
|
+
* the inside. The remedy is one `emit`, which rewrites the lock whole in the running
|
|
190
|
+
* engine's canonical form.
|
|
191
|
+
*
|
|
192
|
+
* Names **no field**, like {@link locusDeclared}: the comparison is the lock's own
|
|
193
|
+
* stamp against the running binary's version, never any member's fields. So it composes
|
|
194
|
+
* into a root `contract` — the stamp is one fact about the whole harness, and there is
|
|
195
|
+
* no per-kind population for it to range over.
|
|
196
|
+
*
|
|
197
|
+
* Lock-only and offline, like {@link fresh}: a lock recording no stamp reads *unknown*
|
|
198
|
+
* rather than mismatched, and a harness with no committed lock has nothing to compare,
|
|
199
|
+
* so both are silent.
|
|
200
|
+
*/
|
|
201
|
+
export const engineMatches = () => ({ key: "engine-matches" });
|
|
183
202
|
/**
|
|
184
203
|
* Every edge the member's kind declares is placed by the format that renders the member
|
|
185
204
|
* — a format that omits one renders a contract the prose does not represent. Names no
|