@dtmd/temper 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -12
- package/dist/src/assembly.d.ts +45 -11
- package/dist/src/assembly.js +115 -7
- package/dist/src/builtins.d.ts +433 -103
- package/dist/src/builtins.js +771 -167
- package/dist/src/claude-code.d.ts +6 -3
- package/dist/src/claude-code.js +2 -2
- package/dist/src/contract.d.ts +153 -44
- package/dist/src/contract.js +123 -34
- package/dist/src/counsel.d.ts +11 -0
- package/dist/src/counsel.js +68 -0
- package/dist/src/declarations.d.ts +108 -2
- package/dist/src/declarations.js +606 -100
- package/dist/src/dial.d.ts +3 -3
- package/dist/src/dial.js +21 -5
- package/dist/src/emit.d.ts +12 -14
- package/dist/src/emit.js +123 -47
- package/dist/src/generated/AbsenceGateRow.d.ts +16 -0
- package/dist/src/generated/AbsenceGateRow.js +2 -0
- package/dist/src/generated/AreaMode.d.ts +5 -0
- package/dist/src/generated/AreaMode.js +2 -0
- package/dist/src/generated/AreaRow.d.ts +20 -0
- package/dist/src/generated/AreaRow.js +1 -0
- package/dist/src/generated/AssemblyFactRow.d.ts +17 -4
- package/dist/src/generated/BoundRow.d.ts +9 -4
- package/dist/src/generated/CedeRow.d.ts +14 -0
- package/dist/src/generated/CedeRow.js +2 -0
- package/dist/src/generated/CharsetRow.d.ts +14 -3
- package/dist/src/generated/ClauseRow.d.ts +23 -21
- package/dist/src/generated/CollectionAddressRow.d.ts +1 -1
- package/dist/src/generated/Declarations.d.ts +24 -9
- package/dist/src/generated/FeatureValue.d.ts +3 -3
- package/dist/src/generated/Features.d.ts +3 -3
- package/dist/src/generated/KindFactRow.d.ts +41 -8
- package/dist/src/generated/Payload.d.ts +3 -5
- package/dist/src/generated/PayloadMember.d.ts +7 -0
- package/dist/src/generated/RunsRow.d.ts +17 -0
- package/dist/src/generated/RunsRow.js +2 -0
- package/dist/src/generated/Section.d.ts +2 -2
- package/dist/src/generated/SectionContainsRow.d.ts +1 -1
- package/dist/src/generated/TypecheckRow.d.ts +20 -0
- package/dist/src/generated/TypecheckRow.js +2 -0
- package/dist/src/generated/Verifier.d.ts +8 -2
- package/dist/src/generated/index.d.ts +6 -0
- package/dist/src/index.d.ts +20 -15
- package/dist/src/index.js +10 -9
- package/dist/src/kind.d.ts +382 -52
- package/dist/src/kind.js +461 -49
- package/dist/src/lockfile.d.ts +39 -0
- package/dist/src/lockfile.js +265 -0
- package/dist/src/member-address.d.ts +15 -3
- package/dist/src/member-address.js +23 -6
- package/dist/src/needs.d.ts +25 -15
- package/dist/src/needs.js +10 -11
- package/dist/src/patterns.d.ts +112 -0
- package/dist/src/patterns.js +90 -0
- package/dist/src/pipe.d.ts +16 -0
- package/dist/src/pipe.js +39 -0
- package/dist/src/playbook.d.ts +203 -0
- package/dist/src/playbook.js +239 -0
- package/dist/src/prose.d.ts +69 -12
- package/dist/src/prose.js +125 -13
- package/dist/src/reference.d.ts +70 -0
- package/dist/src/reference.js +368 -0
- package/package.json +13 -4
- package/schemas/agent.json +23 -0
- package/schemas/command.json +5 -0
- package/schemas/output-style.json +4 -0
- package/schemas/rule.json +33 -0
- package/schemas/skill.json +63 -0
package/dist/src/builtins.js
CHANGED
|
@@ -10,16 +10,19 @@
|
|
|
10
10
|
* — never from the root.
|
|
11
11
|
*/
|
|
12
12
|
import { TAP_EVENT_HOOKS } from "./generated/index.js";
|
|
13
|
-
import { kind } from "./kind.js";
|
|
14
|
-
import { isNameQualifier } from "./member-address.js";
|
|
15
|
-
import {
|
|
13
|
+
import { extendsKind, kind } from "./kind.js";
|
|
14
|
+
import { ROOT_HOSTED_KINDS, isNameQualifier } from "./member-address.js";
|
|
15
|
+
import { renderText } from "./prose.js";
|
|
16
|
+
import { allowedChars, clause, closedKeys, count, degree, deny, enumOf, extent, forbiddenKeys, globValid, loads, maxLen, mentionReachable, minLen, nameMatchesDir, optional, required, resolves, shape, triggerAgrees, type, uniqueName, unshadowed, when, } from "./contract.js";
|
|
16
17
|
/**
|
|
17
18
|
* `supporting-doc` — a skill's bundled reference document, at the nested-file locus:
|
|
18
19
|
* its path composes from its host skill's unit and the host's template pattern, so it
|
|
19
20
|
* governs no glob of its own. Fields-free and frontmatterless (no `format` — the whole
|
|
20
|
-
* file is body), identity from the filename
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* file is body), identity from the filename. It declares no registration — the
|
|
22
|
+
* nested-file locus derives it — and the engine derives the one documented channel,
|
|
23
|
+
* `on-read`: a supporting file loads on demand when it is read, as the skill body that
|
|
24
|
+
* references it directs (code.claude.com/docs/en/skills, "Add supporting files",
|
|
25
|
+
* retrieved 2026-11-26).
|
|
23
26
|
* The locus is the host's: "Skills can include multiple files in their directory", the
|
|
24
27
|
* documented layout placing `reference.md` and `examples.md` beside `SKILL.md`
|
|
25
28
|
* (code.claude.com/docs/en/skills, "Add supporting files", retrieved 2026-11-24).
|
|
@@ -28,12 +31,15 @@ export const supportingDoc = kind({
|
|
|
28
31
|
name: "supporting-doc",
|
|
29
32
|
locus: { kind: "nested-file" },
|
|
30
33
|
unitShape: "file",
|
|
34
|
+
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-11-25)",
|
|
35
|
+
guidance: "a supporting doc never loads on its own: it reaches context only when its skill's body sends Claude to it, after the skill is invoked — so the body names the file and says when to open it, and a doc the body never mentions is never read. Keep each doc to one concern, so following one pointer loads only what that step needs.",
|
|
31
36
|
});
|
|
32
37
|
/**
|
|
33
|
-
* `skill` —
|
|
38
|
+
* `skill` — `**\/.claude/skills/<name>/SKILL.md`, a directory unit, YAML frontmatter
|
|
34
39
|
* carrying `name` then `description`; registers on both documented invocation
|
|
35
40
|
* channels — user-invoked (`/name`) and description-trigger — modulated per
|
|
36
|
-
* member by the `disable-model-invocation`/`user-invocable` fields
|
|
41
|
+
* member by the `disable-model-invocation`/`user-invocable` fields, and on
|
|
42
|
+
* `paths-listing(paths)`, the read of a match that joins a scoped skill to the listing
|
|
37
43
|
* (code.claude.com/docs/en/skills, agentskills.io/specification, retrieved
|
|
38
44
|
* 2026-07-15).
|
|
39
45
|
*
|
|
@@ -46,35 +52,57 @@ export const supportingDoc = kind({
|
|
|
46
52
|
*
|
|
47
53
|
* The locus is the project row of the documented load table,
|
|
48
54
|
* `.claude/skills/<skill-name>/SKILL.md` (code.claude.com/docs/en/skills, "Choose where
|
|
49
|
-
* skills load", retrieved 2026-11-24)
|
|
55
|
+
* skills load", retrieved 2026-11-24), at any depth: a subdirectory's own
|
|
56
|
+
* `.claude/skills/` loads once Claude works there, its skill named by the subdirectory's
|
|
57
|
+
* segments joined with `:` (`apps/web/.claude/skills/deploy` is `apps:web:deploy`;
|
|
58
|
+
* same source, "Load skills in monorepos and subdirectories", retrieved 2026-11-25).
|
|
59
|
+
*
|
|
60
|
+
* A skill whose frontmatter YAML does not parse still loads, with no fields set (same
|
|
61
|
+
* source, retrieved 2026-11-25), so the kind forgives `malformed-yaml`.
|
|
50
62
|
*/
|
|
51
63
|
export const skill = kind({
|
|
52
64
|
name: "skill",
|
|
53
|
-
locus: { kind: "at", root: ".
|
|
65
|
+
locus: { kind: "at", root: ".", glob: "**/.claude/skills/*/SKILL.md" },
|
|
54
66
|
format: "yaml-frontmatter",
|
|
67
|
+
leniency: ["malformed-yaml"],
|
|
55
68
|
unitShape: "directory",
|
|
56
|
-
registration: [
|
|
69
|
+
registration: [
|
|
70
|
+
{ via: "user-invoked" },
|
|
71
|
+
{ via: "description-trigger", field: "description" },
|
|
72
|
+
{ via: "paths-listing", field: "paths" },
|
|
73
|
+
],
|
|
57
74
|
identityField: "name",
|
|
58
75
|
templates: [{ kind: supportingDoc, path: "*.md" }],
|
|
59
|
-
|
|
76
|
+
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-11-25)",
|
|
77
|
+
guidance: "a skill reaches context in two steps: its `description` is listed from session start, and its body loads only when the skill is invoked — by `/name`, or by Claude matching the description — so the description carries the trigger and the body the procedure. A `paths` list withholds even the listing until Read, Write or Edit touches a matching file, and supporting files load only when the body sends Claude to one. Set `disable-model-invocation: true` for side-effectful workflows you want to time yourself — it drops the description from context too, so only `/name` loads the skill; `user-invocable: false` for background knowledge that is not a command. Prefer gerund or noun-phrase names (`processing-pdfs`, `pdf-processing`) over vague ones (`helper`, `utils`); `metadata` is the sanctioned home for versioning — there is no top-level `version` field.",
|
|
60
78
|
});
|
|
61
79
|
/**
|
|
62
|
-
* `command` — `.claude/commands
|
|
80
|
+
* `command` — `.claude/commands/**\/*.md`, the skill surface's legacy file placement
|
|
63
81
|
* (Claude Code merged commands into skills; code.claude.com/docs/en/skills,
|
|
64
|
-
* retrieved 2026-07-15): a lone file
|
|
65
|
-
* `identityField` — like `rule`), the skill's field
|
|
66
|
-
* on the same two documented invocation channels as
|
|
82
|
+
* retrieved 2026-07-15): a lone file named by its path under `commands/`, each `/` a
|
|
83
|
+
* `:` (`unitShape: "path"`, so no `identityField` — like `rule`), the skill's field
|
|
84
|
+
* schema by import, registering on the same two documented invocation channels as
|
|
85
|
+
* `skill`.
|
|
67
86
|
*
|
|
68
87
|
* The locus is the documented placement: "a Markdown file in `.claude/commands/` is the
|
|
69
88
|
* older format and still works" (code.claude.com/docs/en/skills, "Choose where skills
|
|
70
|
-
* load", retrieved 2026-11-24)
|
|
89
|
+
* load", retrieved 2026-11-24), and a subdirectory names the command —
|
|
90
|
+
* `.claude/commands/frontend/component.md` is `/frontend:component`
|
|
91
|
+
* (code.claude.com/docs/en/skills, retrieved 2026-11-25).
|
|
92
|
+
*
|
|
93
|
+
* It loads as a skill does, so it forgives `malformed-yaml` as `skill` does. `agent`
|
|
94
|
+
* forgives nothing: a subagent whose YAML does not parse is skipped
|
|
95
|
+
* (code.claude.com/docs/en/sub-agents, retrieved 2026-11-25).
|
|
71
96
|
*/
|
|
72
97
|
export const command = kind({
|
|
73
98
|
name: "command",
|
|
74
|
-
locus: { kind: "at", root: ".claude/commands", glob: "
|
|
99
|
+
locus: { kind: "at", root: ".claude/commands", glob: "**/*.md" },
|
|
75
100
|
format: "yaml-frontmatter",
|
|
76
|
-
|
|
101
|
+
leniency: ["malformed-yaml"],
|
|
102
|
+
unitShape: "path",
|
|
77
103
|
registration: [{ via: "user-invoked" }, { via: "description-trigger", field: "description" }],
|
|
104
|
+
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-11-25)",
|
|
105
|
+
guidance: "a command loads as a skill does: its `description` is listed from session start, and its body reaches context only when invoked — by `/` plus its path under `commands/` with each `/` a `:`, or by Claude matching the description. It is one file, so it bundles no supporting files; reach for `.claude/skills/<name>/SKILL.md` when the procedure needs reference material loaded on demand.",
|
|
78
106
|
});
|
|
79
107
|
/**
|
|
80
108
|
* `agent` — every markdown file under `.claude/agents`, discovered recursively (a
|
|
@@ -95,50 +123,182 @@ export const agent = kind({
|
|
|
95
123
|
registration: [{ via: "description-trigger", field: "description" }],
|
|
96
124
|
identityField: "name",
|
|
97
125
|
});
|
|
126
|
+
/**
|
|
127
|
+
* `outputStyle` — a markdown file under `.claude/output-styles/`, optional YAML frontmatter
|
|
128
|
+
* over a body that is the style's instructions. "The file name becomes the style name
|
|
129
|
+
* unless you set `name` in the frontmatter", so identity is the `name` field, else the
|
|
130
|
+
* file stem (`unitShape: "named-field-or-file"`); settings select the style by that exact
|
|
131
|
+
* name (code.claude.com/docs/en/output-styles, retrieved 2026-11-25). "If the YAML doesn't
|
|
132
|
+
* parse, the style still loads under its file name with no fields set" (same source), so
|
|
133
|
+
* the kind forgives `malformed-yaml`. Styles load from every `.claude/output-styles/`
|
|
134
|
+
* folder, a nested one once Claude works there (same source), so the locus reaches every
|
|
135
|
+
* depth; a nested style's identity is its subdirectory's segments then its name, each
|
|
136
|
+
* joined with `:` (`apps:web:terse`), and its frontmatter `name` stays the leaf. The docs
|
|
137
|
+
* say nothing on subdirectories inside `output-styles/`, so each folder's direct `*.md`
|
|
138
|
+
* files are claimed and no deeper. A style is selected by a setting rather than invoked
|
|
139
|
+
* or triggered, so it registers the `selected` channel over the `outputStyle` edge
|
|
140
|
+
* field: the active style's instructions ride every request from launch, where a settings
|
|
141
|
+
* file selects it (code.claude.com/docs/en/output-styles, "How output styles work",
|
|
142
|
+
* retrieved 2026-11-27).
|
|
143
|
+
*/
|
|
144
|
+
export const outputStyle = kind({
|
|
145
|
+
name: "output-style",
|
|
146
|
+
locus: { kind: "at", root: ".", glob: "**/.claude/output-styles/*.md" },
|
|
147
|
+
format: "yaml-frontmatter",
|
|
148
|
+
leniency: ["malformed-yaml"],
|
|
149
|
+
unitShape: "named-field-or-file",
|
|
150
|
+
registration: [{ via: "selected", field: "outputStyle" }],
|
|
151
|
+
identityField: "name",
|
|
152
|
+
cite: "https://code.claude.com/docs/en/output-styles (retrieved 2026-11-25)",
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* The styles Claude Code ships itself, selectable by the same `outputStyle` field as a
|
|
156
|
+
* project style: "write the built-in names as `Proactive`, `Concise`, `Explanatory`, and
|
|
157
|
+
* `Learning`", and "`default` appears in the `/output-style` list with the other styles"
|
|
158
|
+
* (code.claude.com/docs/en/output-styles, retrieved 2026-11-25). Spelled exactly, since
|
|
159
|
+
* "the value is case-sensitive" (same source). The runtime loads them, so naming one is no
|
|
160
|
+
* dangling edge (decision 0101).
|
|
161
|
+
*/
|
|
162
|
+
const BUILTIN_OUTPUT_STYLES = ["default", "Proactive", "Concise", "Explanatory", "Learning"];
|
|
163
|
+
/**
|
|
164
|
+
* The `outputStyle` edge `settings` and `settings-local` both carry: the key selects the
|
|
165
|
+
* {@link outputStyle} member whose name it spells exactly — "A value that doesn't match a
|
|
166
|
+
* style name exactly, such as `explanatory`, gives you the Default style"
|
|
167
|
+
* (code.claude.com/docs/en/output-styles, retrieved 2026-11-25) — so a value naming no
|
|
168
|
+
* project style and no {@link BUILTIN_OUTPUT_STYLES} entry silently selects the default,
|
|
169
|
+
* and dangles. The field stays the documented string the file carries; the edge reads it.
|
|
170
|
+
*/
|
|
171
|
+
const OUTPUT_STYLE_EDGE = {
|
|
172
|
+
field: "outputStyle",
|
|
173
|
+
to: [outputStyle],
|
|
174
|
+
provided: BUILTIN_OUTPUT_STYLES,
|
|
175
|
+
};
|
|
98
176
|
/**
|
|
99
177
|
* `rule` — a `<name>.md` at any depth under `.claude/rules/`, a lone file (identity
|
|
100
178
|
* from the stem), YAML frontmatter; registers a path scope
|
|
101
179
|
* (code.claude.com/docs/en/memory, retrieved 2026-07-15). The locus recurses: "All `.md` files are discovered recursively, so
|
|
102
180
|
* you can organize rules into subdirectories like `frontend/` or `backend/`"
|
|
103
181
|
* (code.claude.com/docs/en/memory, "Organize rules with `.claude/rules/`", retrieved 2026-11-24).
|
|
182
|
+
* It claims a subdirectory's own `.claude/rules/` too, whose rules load on demand once
|
|
183
|
+
* Claude works there (code.claude.com/docs/en/memory, "Claude ignores the end of my
|
|
184
|
+
* subdirectory CLAUDE.md", retrieved 2026-11-26). Identity joins the spans the two `**`
|
|
185
|
+
* cover, never the literal `.claude/rules` folders: `apps/web/.claude/rules/frontend/x.md`
|
|
186
|
+
* is `apps:web:frontend:x`, and a root rule keeps `frontend:x`.
|
|
187
|
+
*
|
|
188
|
+
* It registers `on-read-beneath` beside `paths-match`: a subdirectory's own rules load
|
|
189
|
+
* once Claude reads a file beneath that subdirectory, as its `CLAUDE.md` does
|
|
190
|
+
* (decision 0120), so a nested rule without `paths` loads on demand, and its `paths` is
|
|
191
|
+
* the other on-demand cause.
|
|
104
192
|
*/
|
|
105
193
|
export const rule = kind({
|
|
106
194
|
name: "rule",
|
|
107
|
-
locus: { kind: "at", root: ".
|
|
195
|
+
locus: { kind: "at", root: ".", glob: "**/.claude/rules/**/*.md" },
|
|
108
196
|
format: "yaml-frontmatter",
|
|
109
197
|
unitShape: "file",
|
|
110
|
-
registration: [{ via: "paths-match", field: "paths" }],
|
|
111
|
-
|
|
198
|
+
registration: [{ via: "paths-match", field: "paths" }, { via: "on-read-beneath" }],
|
|
199
|
+
cite: "https://code.claude.com/docs/en/memory (retrieved 2026-11-25); path-rule load timing observed on Claude Code 2.1.332",
|
|
200
|
+
guidance: "a rule reaches context on one of two schedules: with no `paths` frontmatter it loads at launch, beside `CLAUDE.md`; with `paths` it loads the first time Read, Write or Edit touches a matching file, once per session. A subdirectory's own `.claude/rules/` loads with that subdirectory's `CLAUDE.md`, the first time Claude reads a file beneath it. So keep a rule to facts Claude should hold whenever the rule is loaded — concrete enough to verify ('use 2-space indentation', not 'format code properly'). If an entry is a multi-step procedure or only matters occasionally, it belongs in a skill, whose body loads only when invoked, rather than a rule, which loads whole once its scope opens. Prefer path-scoped rules when one convention governs scattered paths; prefer per-directory CLAUDE.md when directory owners maintain their own. Treat rules like code: prune them when behavior drifts, and test a change by watching whether Claude's behavior actually shifts.",
|
|
112
201
|
});
|
|
113
202
|
/**
|
|
114
|
-
* `memory` — a
|
|
115
|
-
*
|
|
203
|
+
* `memory` — a `CLAUDE.md` or `AGENTS.md`, a lone file loaded whole, with **no
|
|
204
|
+
* frontmatter** (code.claude.com/docs/en/memory,
|
|
116
205
|
* retrieved 2026-07-15): the whole file is the body, so the kind declares no
|
|
117
206
|
* `format`. A project `CLAUDE.md` may sit at either `./CLAUDE.md` or
|
|
118
207
|
* `./.claude/CLAUDE.md` — equal documented locations (same source) — and the
|
|
119
|
-
* any-depth locus (a `CLAUDE.md` at any directory) covers both
|
|
120
|
-
*
|
|
208
|
+
* any-depth locus (a `CLAUDE.md` at any directory) covers both. A nested memory is
|
|
209
|
+
* named by its placement, `:`-joined (`apps:web:CLAUDE`), so it projects back where it
|
|
210
|
+
* was found. The locus is the project row,
|
|
121
211
|
* "`./CLAUDE.md` or `./.claude/CLAUDE.md`", at any depth because "Claude also discovers
|
|
122
212
|
* `CLAUDE.md` and `CLAUDE.local.md` files in subdirectories under your current working
|
|
123
213
|
* 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`, `
|
|
126
|
-
* memory docs describe no `CLAUDE.md` inside them loading as memory
|
|
127
|
-
*
|
|
128
|
-
*
|
|
214
|
+
* "How CLAUDE.md files load", retrieved 2026-11-24). The locus excludes the root `.claude/`
|
|
215
|
+
* folders another built-in loader owns — `agents`, `commands`, `output-styles`, `skills`:
|
|
216
|
+
* the memory docs describe no `CLAUDE.md` inside them loading as memory
|
|
217
|
+
* (code.claude.com/docs/en/memory, retrieved 2026-11-24; decision 0084). A `.claude/rules/`
|
|
218
|
+
* at any depth needs no exclusion: the rules loader discovers every `.md` under it
|
|
219
|
+
* recursively, and memory cedes that folder claim to `rule`.
|
|
220
|
+
*
|
|
221
|
+
* The second template claims `AGENTS.md` at any depth — `.claude/AGENTS.md` among them,
|
|
222
|
+
* which loads at launch beside `AGENTS.md` — behind two absence gates
|
|
223
|
+
* (code.claude.com/docs/en/memory, "AGENTS.md", retrieved 2026-11-26). At launch one
|
|
224
|
+
* loads only where there is no "`CLAUDE.md`, `.claude/CLAUDE.md`, or `CLAUDE.local.md` in
|
|
225
|
+
* your working directory or any directory above it"; a subdirectory's loads when Claude
|
|
226
|
+
* reads a file there only where "that subdirectory has none of the three `CLAUDE.md`
|
|
227
|
+
* files of its own", so a `CLAUDE.md` above it never shuts it. Reading it directly
|
|
228
|
+
* "requires Claude Code v2.1.277 or later" (same source). An `AGENTS.md` a `CLAUDE.md`
|
|
229
|
+
* shadows is still a member, and an `@AGENTS.md` import still loads it.
|
|
230
|
+
*
|
|
231
|
+
* It registers `on-read-beneath`: the root's memory loads at launch, and a
|
|
232
|
+
* subdirectory's loads "only when Claude reads a file there" (same source, "How
|
|
233
|
+
* CLAUDE.md files load", retrieved 2026-11-24), so the load moment is read off the
|
|
234
|
+
* member's placement — one fact `explain` and the advisories share (decision 0115).
|
|
129
235
|
*/
|
|
130
236
|
export const memory = kind({
|
|
131
237
|
name: "memory",
|
|
132
238
|
locus: {
|
|
133
239
|
kind: "at",
|
|
134
240
|
root: ".",
|
|
135
|
-
glob:
|
|
136
|
-
|
|
241
|
+
glob: [
|
|
242
|
+
"**/CLAUDE.md",
|
|
243
|
+
{ glob: "**/AGENTS.md", absent: ["CLAUDE.md", ".claude/CLAUDE.md", "CLAUDE.local.md"] },
|
|
244
|
+
],
|
|
245
|
+
exclude: [
|
|
246
|
+
".claude/agents",
|
|
247
|
+
".claude/commands",
|
|
248
|
+
".claude/output-styles",
|
|
249
|
+
".claude/skills",
|
|
250
|
+
],
|
|
137
251
|
},
|
|
138
252
|
unitShape: "file",
|
|
139
|
-
registration: [{ via: "
|
|
253
|
+
registration: [{ via: "on-read-beneath" }],
|
|
140
254
|
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.",
|
|
141
255
|
});
|
|
256
|
+
/**
|
|
257
|
+
* `memory-local` — a `CLAUDE.local.md` at any depth, a lone file loaded whole with no
|
|
258
|
+
* frontmatter, "loaded alongside" the `CLAUDE.md` of its directory and "treated the same
|
|
259
|
+
* way" (code.claude.com/docs/en/memory, "Choose where to put CLAUDE.md files", retrieved
|
|
260
|
+
* 2026-11-27). It is personal and gitignored (same source), so it sits at the **local**
|
|
261
|
+
* commitment class as {@link settingsLocal} does beside {@link settings}: read in place at
|
|
262
|
+
* check and gated, never an `emit` input or target, no row of its members ever landing in
|
|
263
|
+
* the lock. Claude also discovers "`CLAUDE.md` and `CLAUDE.local.md` files in
|
|
264
|
+
* subdirectories" (same source, "How CLAUDE.md files load"), so the locus reaches any
|
|
265
|
+
* depth and the kind registers `on-read-beneath` exactly as {@link memory} does: the root's
|
|
266
|
+
* at launch, a subdirectory's when Claude reads a file there. It leaves the root `.claude/`
|
|
267
|
+
* loader folders memory leaves.
|
|
268
|
+
*/
|
|
269
|
+
export const memoryLocal = kind({
|
|
270
|
+
name: "memory-local",
|
|
271
|
+
locus: {
|
|
272
|
+
kind: "at",
|
|
273
|
+
root: ".",
|
|
274
|
+
glob: "**/CLAUDE.local.md",
|
|
275
|
+
commitment: "local",
|
|
276
|
+
exclude: [
|
|
277
|
+
".claude/agents",
|
|
278
|
+
".claude/commands",
|
|
279
|
+
".claude/output-styles",
|
|
280
|
+
".claude/skills",
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
unitShape: "file",
|
|
284
|
+
registration: [{ via: "on-read-beneath" }],
|
|
285
|
+
});
|
|
286
|
+
/** The edge field a runner names the {@link tool} it runs under — temper's own, never a
|
|
287
|
+
* projected key. The engine's `RUNS_FIELD` (`src/drift.rs`). */
|
|
288
|
+
export const RUNS_FIELD = "runs";
|
|
289
|
+
/** The default tool: the temper package's own bin. */
|
|
290
|
+
const TEMPER_TOOL = { package: "@dtmd/temper", bin: "temper" };
|
|
291
|
+
/**
|
|
292
|
+
* `tool` at the embedded locus, hosted by the root member: it owns no file, projects
|
|
293
|
+
* nothing, and registers nothing. Fields-only.
|
|
294
|
+
*/
|
|
295
|
+
const toolKind = kind({
|
|
296
|
+
name: "tool",
|
|
297
|
+
locus: { kind: "embedded" },
|
|
298
|
+
unitShape: "file",
|
|
299
|
+
shape: "fields",
|
|
300
|
+
leaves: { package: true, bin: true, file: true, system: true },
|
|
301
|
+
});
|
|
142
302
|
/**
|
|
143
303
|
* `handler` — one entry in a hook's `hooks` array, at the **embedded** locus: it owns no
|
|
144
304
|
* file and no glob, living inside its host matcher group and keyed by its position there
|
|
@@ -155,6 +315,156 @@ export const handler = kind({
|
|
|
155
315
|
unitShape: "file",
|
|
156
316
|
shape: "fields",
|
|
157
317
|
cite: "https://code.claude.com/docs/en/hooks (retrieved 2026-09-29)",
|
|
318
|
+
edgeFields: [{ field: RUNS_FIELD, to: [toolKind] }],
|
|
319
|
+
});
|
|
320
|
+
/**
|
|
321
|
+
* A tool member's name, absent an authored one: the bin, the file's last segment, or the
|
|
322
|
+
* system tool's name.
|
|
323
|
+
*/
|
|
324
|
+
function toolName(init) {
|
|
325
|
+
if ("package" in init)
|
|
326
|
+
return init.bin;
|
|
327
|
+
if ("file" in init)
|
|
328
|
+
return init.file.split("/").filter((segment) => segment !== "").pop() ?? init.file;
|
|
329
|
+
return init.system;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Build a tool member. Absent an init, the tool is the temper package's bin.
|
|
333
|
+
*
|
|
334
|
+
* # Throws
|
|
335
|
+
* If a variant's value is blank, or the init carries more than one variant.
|
|
336
|
+
*/
|
|
337
|
+
function toolMember(init = TEMPER_TOOL) {
|
|
338
|
+
const variants = ["package", "file", "system"].filter((key) => key in init);
|
|
339
|
+
if (variants.length !== 1) {
|
|
340
|
+
throw new Error(`tool: state exactly one of \`{ package, bin }\`, \`{ file }\` or \`{ system }\` — ` +
|
|
341
|
+
`got ${variants.length === 0 ? "none" : variants.map((key) => `\`${key}\``).join(", ")}.`);
|
|
342
|
+
}
|
|
343
|
+
const { name, ...variant } = init;
|
|
344
|
+
for (const [key, value] of Object.entries(variant)) {
|
|
345
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
346
|
+
throw new Error(`tool: \`${key}\` is blank — a tool names what it runs.`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const tool = variant;
|
|
350
|
+
return toolKind({ ...tool, name: name ?? toolName(tool) });
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* `requirement` at the embedded locus, hosted by the root member: it owns no file and
|
|
354
|
+
* projects nothing. A member of it, or of a subkind `extend(requirement, …)` mints, is a
|
|
355
|
+
* requirement the harness declares.
|
|
356
|
+
*/
|
|
357
|
+
const requirementKind = kind({
|
|
358
|
+
name: "requirement",
|
|
359
|
+
locus: { kind: "embedded" },
|
|
360
|
+
unitShape: "file",
|
|
361
|
+
shape: "fields",
|
|
362
|
+
leaves: { kind: true, required: true, clauses: true, verifier: true },
|
|
363
|
+
});
|
|
364
|
+
/**
|
|
365
|
+
* Build a requirement member from a literal. The string prose becomes the member's
|
|
366
|
+
* `text` span byte for byte — no dedent, since the lock carries a requirement's prose
|
|
367
|
+
* exactly as authored. Absent a `name`, the requirement map's key supplies one.
|
|
368
|
+
*
|
|
369
|
+
* # Throws
|
|
370
|
+
* If `prose` is not a string, or carries a marker the prose constructors reserve.
|
|
371
|
+
*/
|
|
372
|
+
function requirementMember(init) {
|
|
373
|
+
const { name, prose, ...fields } = init;
|
|
374
|
+
if (typeof prose !== "string") {
|
|
375
|
+
throw new Error(`requirement${name === undefined ? "" : ` \`${name}\``}: \`prose\` is the authored intent, a string.`);
|
|
376
|
+
}
|
|
377
|
+
if (prose.includes("\u0000") || prose.includes("\u0001")) {
|
|
378
|
+
throw new Error(`requirement${name === undefined ? "" : ` \`${name}\``}: \`prose\` carries U+0000 or U+0001, ` +
|
|
379
|
+
`the markers temper's prose constructors reserve for mentions and includes.`);
|
|
380
|
+
}
|
|
381
|
+
const words = { kind: "text", template: prose, mentions: [], includes: [] };
|
|
382
|
+
return requirementKind({ ...fields, name: name ?? "", prose: words });
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The authored `requirement` constructor — {@link requirementKind}'s facts over
|
|
386
|
+
* {@link requirementMember}. As a kind value it is what `extend(requirement, { name, … })`
|
|
387
|
+
* takes, minting a subkind whose members are requirements too.
|
|
388
|
+
*/
|
|
389
|
+
export const requirement = Object.assign(requirementMember, {
|
|
390
|
+
facts: requirementKind.facts,
|
|
391
|
+
key: requirementKind.key,
|
|
392
|
+
});
|
|
393
|
+
/**
|
|
394
|
+
* The default contract for `requirement` — two clauses, each judged over every declared
|
|
395
|
+
* requirement's own opt-in selection rather than over the kind's population. `count` is
|
|
396
|
+
* the fill default, at least one satisfier; a requirement declared `required: false`
|
|
397
|
+
* reads it at advisory rather than not at all. `resolves` holds every `satisfies` link to a
|
|
398
|
+
* declared requirement.
|
|
399
|
+
*/
|
|
400
|
+
export const requirementDefaultContract = [
|
|
401
|
+
clause(count({ min: 1 }), {
|
|
402
|
+
severity: "required",
|
|
403
|
+
guidance: "No member opts in to fill this requirement: nothing in the harness declares a `satisfies` link naming it, so the intent its prose states has no home. Add the requirement's name to the `satisfies` of the member that carries the intent, or author that member. A requirement declared `required: false` reads this clause at advisory, so an aspiration still reports; dial this label to `advisory` while a tree mid-adoption has not filled its requirements yet.",
|
|
404
|
+
cite: "https://github.com/duct-tape-and-markdown/temper/blob/main/specs/model/contract.md#requirement--a-shipped-kind-not-a-primitive (retrieved 2026-11-26)",
|
|
405
|
+
}),
|
|
406
|
+
clause(resolves(), {
|
|
407
|
+
severity: "required",
|
|
408
|
+
guidance: "This member's `satisfies` names a requirement the harness does not declare, so the claim fills nothing — most often a typo, or a requirement renamed or retired under it. Fix the name, declare the requirement in the harness `require` map or a member's `requires`, or drop the link. Dial this label to `advisory` while a renamed requirement's old claims are still being moved.",
|
|
409
|
+
cite: "https://github.com/duct-tape-and-markdown/temper/blob/main/specs/model/contract.md#requirement--a-shipped-kind-not-a-primitive (retrieved 2026-11-26)",
|
|
410
|
+
}),
|
|
411
|
+
];
|
|
412
|
+
/** Whether a member is a requirement: of the `requirement` kind, or a subkind anywhere down its chain. */
|
|
413
|
+
export function isRequirement(member) {
|
|
414
|
+
return extendsKind(member.facts, requirementKind.facts);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The requirement a map entry declares under `name`, as the declaration rows read it. A
|
|
418
|
+
* literal is itself; a requirement member yields its template, its prose rendered from
|
|
419
|
+
* its `text` span.
|
|
420
|
+
*
|
|
421
|
+
* # Throws
|
|
422
|
+
* If the value is a member of no requirement kind, a member named other than `name`, or a
|
|
423
|
+
* member whose prose is absent or not a `text` span.
|
|
424
|
+
*/
|
|
425
|
+
export function requirementOf(name, value) {
|
|
426
|
+
if (!("facts" in value))
|
|
427
|
+
return value;
|
|
428
|
+
const at = `requirement \`${name}\``;
|
|
429
|
+
if (!isRequirement(value)) {
|
|
430
|
+
throw new Error(`${at}: a requirement map holds requirements, and \`${value.name}\` is a member of kind ` +
|
|
431
|
+
`\`${value.kind}\` — pass \`requirement(…)\` or a member of a kind extending it.`);
|
|
432
|
+
}
|
|
433
|
+
if (value.name !== "" && value.name !== name) {
|
|
434
|
+
throw new Error(`${at}: the member is named \`${value.name}\`, and a requirement has one identity — name it once.`);
|
|
435
|
+
}
|
|
436
|
+
if (value.prose?.kind !== "text") {
|
|
437
|
+
throw new Error(`${at}: a requirement's prose is the authored intent, a \`text\` span — ` +
|
|
438
|
+
`${value.prose === undefined ? "it states none" : `got a \`${value.prose.kind}\` body`}.`);
|
|
439
|
+
}
|
|
440
|
+
const field = (key) => value.fields.find(([held]) => held === key)?.[1];
|
|
441
|
+
const read = {
|
|
442
|
+
prose: renderText(value.prose),
|
|
443
|
+
kind: field("kind"),
|
|
444
|
+
required: field("required"),
|
|
445
|
+
clauses: field("clauses"),
|
|
446
|
+
verifier: field("verifier"),
|
|
447
|
+
};
|
|
448
|
+
REQUIREMENT_MEMBERS.set(read, value);
|
|
449
|
+
return read;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* The member each requirement {@link requirementOf} read off a member came from, keyed by
|
|
453
|
+
* the requirement it returned — so the lowering that keys a requirement as the root's
|
|
454
|
+
* nested member reads its kind (a subkind's own name) and its leaves (a subkind's own
|
|
455
|
+
* fields) off the member, while every other reader keeps the erased {@link Requirement}.
|
|
456
|
+
*/
|
|
457
|
+
const REQUIREMENT_MEMBERS = new WeakMap();
|
|
458
|
+
/** The member a requirement was read off ({@link requirementOf}), or `undefined` for a literal. */
|
|
459
|
+
export function requirementSource(requirement) {
|
|
460
|
+
return REQUIREMENT_MEMBERS.get(requirement);
|
|
461
|
+
}
|
|
462
|
+
/** The embedded kinds the root member hosts — the grammar's set, re-exported beside the kinds. */
|
|
463
|
+
export { ROOT_HOSTED_KINDS };
|
|
464
|
+
/** The authored `tool` constructor — {@link toolKind}'s facts over {@link toolMember}. */
|
|
465
|
+
export const tool = Object.assign(toolMember, {
|
|
466
|
+
facts: toolKind.facts,
|
|
467
|
+
key: toolKind.key,
|
|
158
468
|
});
|
|
159
469
|
/**
|
|
160
470
|
* The manifest Claude Code's harness-level settings reside in — the file the assembly's
|
|
@@ -226,26 +536,44 @@ const hookGroup = kind({
|
|
|
226
536
|
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).",
|
|
227
537
|
});
|
|
228
538
|
/**
|
|
229
|
-
* The one kind whose
|
|
230
|
-
*
|
|
231
|
-
* ({@link hookMemberName}), because the event keys every
|
|
232
|
-
* at one address is a malformed lock. The
|
|
233
|
-
*
|
|
234
|
-
*
|
|
539
|
+
* The one kind whose author writes no `name`: the author names the lifecycle **event** —
|
|
540
|
+
* the runtime's word for the fact, keyed `event` — and the member's identity is that
|
|
541
|
+
* event joined with its matcher ({@link hookMemberName}), because the event keys every
|
|
542
|
+
* group under it and two members at one address is a malformed lock. The module the lift
|
|
543
|
+
* scaffolds and the row the emit writes both spell the key the wire uses; the composition
|
|
544
|
+
* happens here, once, rather than at every reader of a hook's address.
|
|
235
545
|
*
|
|
236
546
|
* # Throws
|
|
237
|
-
* If
|
|
547
|
+
* If `name` is handed without `event` ({@link HOOK_NAME_REMEDY}) — the moved spelling an
|
|
548
|
+
* untypechecked program can still pass. If the matcher carries a `/` — the separator the member-address grammar cuts an
|
|
238
549
|
* address at, which in a name truncates the member and re-seats every handler beneath it
|
|
239
550
|
* ({@link isNameQualifier}).
|
|
240
551
|
*/
|
|
241
552
|
function hookMember(init) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
553
|
+
refuseAuthoredName("hook", init, HOOK_NAME_REMEDY);
|
|
554
|
+
const { event, ...group } = init;
|
|
555
|
+
if (group.matcher !== undefined && !isNameQualifier(group.matcher)) {
|
|
556
|
+
throw new Error(`hook \`${event}\`: matcher \`${group.matcher}\` carries a \`/\`, and a hook's name ` +
|
|
557
|
+
`joins its matcher after a \`:\` (\`hook:${event}:${group.matcher}\`) — the \`/\` is ` +
|
|
245
558
|
`the separator an address is cut at, so the member and its handlers would answer to ` +
|
|
246
559
|
`an address naming something else (specs/model/representation.md, "member").`);
|
|
247
560
|
}
|
|
248
|
-
return hookGroup({ ...
|
|
561
|
+
return hookGroup({ ...group, name: hookMemberName(event, group.matcher) });
|
|
562
|
+
}
|
|
563
|
+
/** The words `hook({ name })` fails with — at `tsc` through {@link HookInit}'s
|
|
564
|
+
* {@link Remedy} slot, and at runtime through {@link refuseAuthoredName}: one spelling. */
|
|
565
|
+
const HOOK_NAME_REMEDY = "a hook's lifecycle event is its `event`: write `hook({ event, matcher, hooks })`";
|
|
566
|
+
/** The words `gateHook({ name })` fails with, as {@link HOOK_NAME_REMEDY} is `hook`'s. */
|
|
567
|
+
const GATE_HOOK_NAME_REMEDY = "a gate hook's lifecycle event is its `event`: write `gateHook({ event, matcher })`";
|
|
568
|
+
/**
|
|
569
|
+
* Refuses an init carrying the moved `name` and no `event` — the spelling the
|
|
570
|
+
* {@link Remedy} slot fails at `tsc`, met at runtime by a program nothing typechecked, so
|
|
571
|
+
* it throws the Remedy's own words rather than reading through an absent event.
|
|
572
|
+
*/
|
|
573
|
+
function refuseAuthoredName(constructor, init, remedy) {
|
|
574
|
+
if (init.name !== undefined && init.event === undefined) {
|
|
575
|
+
throw new Error(`${constructor} \`${String(init.name)}\`: ${remedy}.`);
|
|
576
|
+
}
|
|
249
577
|
}
|
|
250
578
|
/** The authored `hook` constructor — {@link hookGroup}'s facts over {@link hookMember}'s
|
|
251
579
|
* name composition. */
|
|
@@ -255,63 +583,94 @@ export const hook = Object.assign(hookMember, {
|
|
|
255
583
|
render: hookGroup.render,
|
|
256
584
|
});
|
|
257
585
|
/**
|
|
258
|
-
* The
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* `null` is a gate hook declaring no binary, so the default (`temper`) has one spelling,
|
|
262
|
-
* the engine's.
|
|
586
|
+
* The tool-name matcher the guard's `PreToolUse` edge binds — Claude Code's own
|
|
587
|
+
* file-writing tools (`code.claude.com/docs/en/hooks`, retrieved 2026-07-24), the matcher
|
|
588
|
+
* `temper install` places (`src/install.rs`'s `GUARD_MATCHER`).
|
|
263
589
|
*/
|
|
264
|
-
export const
|
|
265
|
-
/**
|
|
266
|
-
*
|
|
590
|
+
export const GUARD_MATCHER = "Write|Edit|MultiEdit";
|
|
591
|
+
/**
|
|
592
|
+
* The key a gate hook's registration row carries the address of the tool it runs under —
|
|
593
|
+
* the engine's `GATE_TOOL_KEY` (`src/drift.rs`), which consumes it at emit and renders the
|
|
594
|
+
* handler's command in its place. Colon-qualified so no typed {@link Hook} field can spell
|
|
595
|
+
* it. `null` is a gate hook declaring no tool, so the default has one spelling, the
|
|
596
|
+
* engine's.
|
|
597
|
+
*/
|
|
598
|
+
export const GATE_TOOL_KEY = "temper:gate-tool";
|
|
599
|
+
/** Each gate hook member's declared tool (`null` declaring none) — the fact
|
|
600
|
+
* {@link gateHook} records and {@link gateHookTool} reads, keyed by the member itself so
|
|
267
601
|
* the member's typed fields stay exactly the manifest entry they project to. */
|
|
268
|
-
const
|
|
602
|
+
const gateHookTools = new WeakMap();
|
|
269
603
|
/**
|
|
270
604
|
* A temper gate hook — a {@link hook} member whose single `command` handler runs the
|
|
271
|
-
* temper verb its event fires, with the
|
|
605
|
+
* temper verb its event fires, with the tool it reaches. The handler carries the tool as
|
|
606
|
+
* its `runs` edge, so the lock records which tool the gate runs. The member is an ordinary
|
|
272
607
|
* matcher group in every other respect: its name joins its matcher as any hook's does,
|
|
273
608
|
* and a tap hook at the same event and matcher joins it as a further handler.
|
|
274
609
|
*
|
|
275
610
|
* # Throws
|
|
276
|
-
* If `
|
|
277
|
-
* `/` ({@link hook}).
|
|
611
|
+
* If `name` is handed without `event` ({@link GATE_HOOK_NAME_REMEDY}), `tool` is not a
|
|
612
|
+
* `tool(...)` member, or the matcher carries a `/` ({@link hook}).
|
|
278
613
|
*/
|
|
279
614
|
export function gateHook(init) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
615
|
+
refuseAuthoredName("gateHook", init, GATE_HOOK_NAME_REMEDY);
|
|
616
|
+
if (init.tool !== undefined && init.tool.kind !== toolKind.key) {
|
|
617
|
+
throw new Error(`gate hook \`${init.event}\`: \`tool\` names what the hook runs — pass a \`tool(...)\` ` +
|
|
618
|
+
`member, or omit it for the temper package's bin.`);
|
|
283
619
|
}
|
|
284
|
-
const handlers = [{ type: "command" }];
|
|
620
|
+
const handlers = [init.tool === undefined ? { type: "command" } : { type: "command", runs: init.tool }];
|
|
285
621
|
const satisfies = init.satisfies === undefined ? {} : { satisfies: init.satisfies };
|
|
286
622
|
const member = init.matcher === undefined
|
|
287
|
-
? hook({
|
|
288
|
-
: hook({
|
|
289
|
-
|
|
623
|
+
? hook({ event: init.event, hooks: handlers, ...satisfies })
|
|
624
|
+
: hook({ event: init.event, matcher: init.matcher, hooks: handlers, ...satisfies });
|
|
625
|
+
gateHookTools.set(member, init.tool ?? null);
|
|
290
626
|
return member;
|
|
291
627
|
}
|
|
292
628
|
/**
|
|
293
|
-
* The
|
|
294
|
-
*
|
|
295
|
-
* registration erasure (`declarations.ts`), which carries
|
|
629
|
+
* The tool a gate hook member reaches — `null` where it declares none (the temper
|
|
630
|
+
* package's bin) — or `undefined` where `member` is not a gate hook at all. The one reader
|
|
631
|
+
* is the registration erasure (`declarations.ts`), which carries its address under
|
|
632
|
+
* {@link GATE_TOOL_KEY}.
|
|
296
633
|
*/
|
|
297
|
-
export function
|
|
298
|
-
return
|
|
634
|
+
export function gateHookTool(member) {
|
|
635
|
+
return gateHookTools.get(member);
|
|
299
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* The key a tap handler carries its declaration's tool address under — the engine's
|
|
639
|
+
* `TAP_TOOL_KEY` (`src/drift.rs`), which consumes it at emit and renders the handler's
|
|
640
|
+
* command in its place, anchored at the project. Carried on the **handler**, not the row,
|
|
641
|
+
* because a tap joins an authored group at the same (event, matcher) as a further handler
|
|
642
|
+
* (`declarations.ts`). Colon-qualified so no typed {@link Handler} field can spell it;
|
|
643
|
+
* `null` is a declaration naming no tool, so the default has one spelling, the engine's.
|
|
644
|
+
*/
|
|
645
|
+
export const TAP_TOOL_KEY = "temper:tap-tool";
|
|
646
|
+
/**
|
|
647
|
+
* The key a tap handler carries the name of the telemetry declaration it speaks for — the
|
|
648
|
+
* engine's `TAP_DECLARATION_KEY` (`src/drift.rs`), which names it when two declarations
|
|
649
|
+
* sharing a tap resolve to different commands, then drops it before a byte is projected.
|
|
650
|
+
*/
|
|
651
|
+
export const TAP_DECLARATION_KEY = "temper:tap-declaration";
|
|
300
652
|
/**
|
|
301
653
|
* The tap hook registration's `hooks.<Event>` key-path and {@link Hook} fields — the
|
|
302
654
|
* provider fact {@link tapHookRows} (`declarations.ts`) fills rather than authors inline.
|
|
303
655
|
* One matcher group like any authored one: the per-event `matcher`
|
|
304
|
-
* {@link TELEMETRY_EVENT_HOOKS} names lifted beside
|
|
305
|
-
*
|
|
306
|
-
* the
|
|
656
|
+
* {@link TELEMETRY_EVENT_HOOKS} names lifted beside one `command` handler per distinct
|
|
657
|
+
* declared tool, each carrying that tool's address ({@link TAP_TOOL_KEY}; `null` naming
|
|
658
|
+
* none) and the declaration naming it ({@link TAP_DECLARATION_KEY}) — the engine renders
|
|
659
|
+
* each tool's command, merges the handlers that agree into one tap, and refuses the rest —
|
|
660
|
+
* so a synthesized row and an authored one are the same shape and the join in
|
|
661
|
+
* `declarations.ts` can merge one into the other.
|
|
307
662
|
*/
|
|
308
|
-
export function tapHookRegistration(
|
|
309
|
-
const
|
|
663
|
+
export function tapHookRegistration(declarations, matcher) {
|
|
664
|
+
const handlers = declarations.map(({ tool, named }) => ({
|
|
665
|
+
type: "command",
|
|
666
|
+
[TAP_TOOL_KEY]: tool,
|
|
667
|
+
[TAP_DECLARATION_KEY]: named,
|
|
668
|
+
}));
|
|
310
669
|
return {
|
|
311
670
|
keyPath: HOOK_KEY_PATH,
|
|
312
671
|
fields: [
|
|
313
672
|
[HOOK_MATCHER_KEY, matcher],
|
|
314
|
-
[HOOK_HANDLER_KEY,
|
|
673
|
+
[HOOK_HANDLER_KEY, handlers],
|
|
315
674
|
],
|
|
316
675
|
};
|
|
317
676
|
}
|
|
@@ -331,6 +690,33 @@ export const mcpServer = kind({
|
|
|
331
690
|
shape: "fields",
|
|
332
691
|
collectionAddress: { keyPath: "mcpServers.*", entryShape: "object" },
|
|
333
692
|
});
|
|
693
|
+
/**
|
|
694
|
+
* `knownMarketplace` — a `settings.json` `extraKnownMarketplaces` registration member: a
|
|
695
|
+
* fields-only kind (no body slot), its members discovered off the `.claude/settings.json`
|
|
696
|
+
* manifest at the `extraKnownMarketplaces.*` collection address, keyed by marketplace name;
|
|
697
|
+
* registers on the `registry` channel — the entry's own presence is the registration, and
|
|
698
|
+
* whether the marketplace it names actually resolves is a fetch-time fact temper cannot
|
|
699
|
+
* decide, so the channel is never provably dead (code.claude.com/docs/en/plugin-marketplaces,
|
|
700
|
+
* retrieved 2026-07-17). The fourth registration member temper ships.
|
|
701
|
+
*/
|
|
702
|
+
export const knownMarketplace = kind({
|
|
703
|
+
name: "known-marketplace",
|
|
704
|
+
locus: { kind: "at", root: ".claude", glob: SETTINGS_MANIFEST },
|
|
705
|
+
unitShape: "file",
|
|
706
|
+
registration: [{ via: "registry" }],
|
|
707
|
+
shape: "fields",
|
|
708
|
+
collectionAddress: { keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
|
|
709
|
+
});
|
|
710
|
+
/**
|
|
711
|
+
* The default contract for `known-marketplace` — **deliberately empty**. The format
|
|
712
|
+
* documents no decidable schema beyond the shape the {@link KnownMarketplace} type already
|
|
713
|
+
* holds: `source` is the same union {@link Marketplace} carries and reuses its typing,
|
|
714
|
+
* `autoUpdate` is a bare optional boolean, and the key is the member's identity (a
|
|
715
|
+
* marketplace name) rather than a declared field a clause could range over. Nothing decidable
|
|
716
|
+
* survives that the type does not already enforce, so the honest encoding is the empty
|
|
717
|
+
* contract, not a forged clause — the `installedPluginDefaultContract` precedent.
|
|
718
|
+
*/
|
|
719
|
+
export const knownMarketplaceDefaultContract = [];
|
|
334
720
|
/**
|
|
335
721
|
* `installedPlugin` — a `settings.json` `enabledPlugins` registration member: a
|
|
336
722
|
* fields-only kind (no body slot), its members discovered off the `.claude/settings.json`
|
|
@@ -351,7 +737,7 @@ export const installedPlugin = kind({
|
|
|
351
737
|
// — the engine splits it off the composite key at read (`src/kind.rs`, the read-time fold
|
|
352
738
|
// that surfaces it under `marketplace`) — so the edge resolves on the reference graph like
|
|
353
739
|
// any other, and an enablement naming a marketplace no registration declares dangles.
|
|
354
|
-
edgeFields: [{ field: "marketplace", to: [
|
|
740
|
+
edgeFields: [{ field: "marketplace", to: [knownMarketplace] }],
|
|
355
741
|
});
|
|
356
742
|
/**
|
|
357
743
|
* The default contract for `installed-plugin` — **deliberately empty**. The format
|
|
@@ -373,33 +759,6 @@ export const installedPlugin = kind({
|
|
|
373
759
|
* omits it projects the `true` Claude Code itself writes.
|
|
374
760
|
*/
|
|
375
761
|
export const installedPluginDefaultContract = [];
|
|
376
|
-
/**
|
|
377
|
-
* `knownMarketplace` — a `settings.json` `extraKnownMarketplaces` registration member: a
|
|
378
|
-
* fields-only kind (no body slot), its members discovered off the `.claude/settings.json`
|
|
379
|
-
* manifest at the `extraKnownMarketplaces.*` collection address, keyed by marketplace name;
|
|
380
|
-
* registers on the `registry` channel — the entry's own presence is the registration, and
|
|
381
|
-
* whether the marketplace it names actually resolves is a fetch-time fact temper cannot
|
|
382
|
-
* decide, so the channel is never provably dead (code.claude.com/docs/en/plugin-marketplaces,
|
|
383
|
-
* retrieved 2026-07-17). The fourth registration member temper ships.
|
|
384
|
-
*/
|
|
385
|
-
export const knownMarketplace = kind({
|
|
386
|
-
name: "known-marketplace",
|
|
387
|
-
locus: { kind: "at", root: ".claude", glob: SETTINGS_MANIFEST },
|
|
388
|
-
unitShape: "file",
|
|
389
|
-
registration: [{ via: "registry" }],
|
|
390
|
-
shape: "fields",
|
|
391
|
-
collectionAddress: { keyPath: "extraKnownMarketplaces.*", entryShape: "object" },
|
|
392
|
-
});
|
|
393
|
-
/**
|
|
394
|
-
* The default contract for `known-marketplace` — **deliberately empty**. The format
|
|
395
|
-
* documents no decidable schema beyond the shape the {@link KnownMarketplace} type already
|
|
396
|
-
* holds: `source` is the same union {@link Marketplace} carries and reuses its typing,
|
|
397
|
-
* `autoUpdate` is a bare optional boolean, and the key is the member's identity (a
|
|
398
|
-
* marketplace name) rather than a declared field a clause could range over. Nothing decidable
|
|
399
|
-
* survives that the type does not already enforce, so the honest encoding is the empty
|
|
400
|
-
* contract, not a forged clause — the `installedPluginDefaultContract` precedent.
|
|
401
|
-
*/
|
|
402
|
-
export const knownMarketplaceDefaultContract = [];
|
|
403
762
|
/**
|
|
404
763
|
* `plugin-manifest` — `.claude-plugin/plugin.json`, a whole-file JSON document (never
|
|
405
764
|
* frontmatter) whose top-level keys are its fields; identity is read from `name`, the
|
|
@@ -451,57 +810,72 @@ export const pluginManifestDefaultContract = [
|
|
|
451
810
|
clause(required("name"), {
|
|
452
811
|
severity: "required",
|
|
453
812
|
guidance: "A manifest declares a `name` — the pack's identity and the namespace its components surface under (`plugin-dev:agent-creator`). Omitting the manifest entirely is supported and Claude Code then derives the name from the directory; a manifest that exists and has no `name` is the one case the loader rejects outright: `name: Invalid input: expected string, received undefined`.",
|
|
454
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#
|
|
813
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#name (retrieved 2026-11-26)",
|
|
455
814
|
}),
|
|
456
815
|
clause(minLen("name", 1), {
|
|
457
816
|
severity: "required",
|
|
458
817
|
guidance: "A present-but-empty name cannot namespace a component or key an install. Drop the field to let Claude Code derive the name from the directory, or give it a real one.",
|
|
459
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#
|
|
818
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#name (retrieved 2026-11-26)",
|
|
460
819
|
}),
|
|
461
820
|
clause(allowedChars("name", { ranges: ["a-z", "0-9"], chars: "-" }), {
|
|
462
821
|
severity: "required",
|
|
463
822
|
guidance: "Kebab-case, no spaces — lowercase letters, digits, and hyphens. The name is a namespace prefix and an install key, so a space or a capital makes it unquotable in the places it is typed. Use `displayName` for the human-readable label: it may carry spaces and any casing, and is never used for lookup.",
|
|
464
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#
|
|
823
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#name (retrieved 2026-11-26)",
|
|
465
824
|
}),
|
|
466
825
|
clause(forbiddenKeys(["themes", "monitors"]), {
|
|
467
826
|
severity: "required",
|
|
468
827
|
guidance: "`themes` and `monitors` are experimental components and belong under the `experimental` key. Declaring them at the top level still loads today and `claude plugin validate` only warns — but `--strict` fails it, and a future release will require `experimental.*`, so a top-level spelling is a migration already scheduled against you.",
|
|
469
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#
|
|
828
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
470
829
|
}),
|
|
471
830
|
clause(type("keywords", ["list"]), {
|
|
472
831
|
severity: "required",
|
|
473
|
-
guidance: "`keywords` is an array of discovery tags, and a bare string is not a shorter spelling of a one-tag list: a
|
|
474
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#
|
|
832
|
+
guidance: "`keywords` is an array of discovery tags, and a bare string is not a shorter spelling of a one-tag list: a type mismatch fails `claude plugin validate` outright, not merely under `--strict`, and Claude Code reports the same problem when it loads the plugin. Write `[\"deployment\"]` for a single tag.",
|
|
833
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#validate-the-manifest (retrieved 2026-11-26)",
|
|
475
834
|
}),
|
|
476
835
|
clause(type("skills", ["string", "list"]), {
|
|
477
836
|
severity: "required",
|
|
478
|
-
guidance: "`skills` names custom skill directories — each holding a `<name>/SKILL.md` — as one `\"./custom/skills/\"` path or a list of them. Unlike its neighbours it *adds* to the default `skills/` scan rather than replacing it, so listing `\"./skills/\"` alongside your extra path is redundant, not required.",
|
|
479
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
837
|
+
guidance: "`skills` names custom skill directories — each holding a `<name>/SKILL.md` — as one `\"./custom/skills/\"` path or a list of them; `\".\"` names the plugin root. Unlike its neighbours it *adds* to the default `skills/` scan rather than replacing it, so listing `\"./skills/\"` alongside your extra path is redundant, not required.",
|
|
838
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
480
839
|
}),
|
|
481
840
|
clause(type("commands", ["string", "list", "map"]), {
|
|
482
841
|
severity: "required",
|
|
483
|
-
guidance: "`commands` names flat `.md` skill files or directories, as one path, a list of them, or an object keyed by command name (each entry
|
|
484
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
842
|
+
guidance: "`commands` names flat `.md` skill files or directories, as one path, a list of them, or an object keyed by command name (each entry setting exactly one of `source` or inline `content`). Setting it *replaces* the default `commands/` scan — to keep the default and add to it, list it explicitly: `[\"./commands/\", \"./extras/\"]`.",
|
|
843
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
485
844
|
}),
|
|
486
845
|
clause(type("agents", ["string", "list"]), {
|
|
487
846
|
severity: "required",
|
|
488
|
-
guidance: "`agents` names custom agent files as one path or a list of them
|
|
489
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
847
|
+
guidance: "`agents` names custom agent `.md` files as one path or a list of them — directories are not accepted — and *replaces* the default `agents/` scan — a manifest that sets it and expects `agents/` to still be read ships a plugin missing every agent in that folder. Claude Code v2.1.140 and later warns about the ignored folder in `claude plugin list`.",
|
|
848
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
490
849
|
}),
|
|
491
850
|
clause(type("hooks", ["string", "list", "map"]), {
|
|
492
851
|
severity: "required",
|
|
493
|
-
guidance: "`hooks` is a path to a hook config JSON file,
|
|
494
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
852
|
+
guidance: "`hooks` is a path to a hook config JSON file, the config inline as an object keyed by event name, or a list of either; it loads together with `hooks/hooks.json`. The inline object is the whole `hooks.json` body, not a fragment of it — the same shape `hooks/hooks.json` carries.",
|
|
853
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
495
854
|
}),
|
|
496
855
|
clause(type("mcpServers", ["string", "list", "map"]), {
|
|
497
856
|
severity: "required",
|
|
498
|
-
guidance: "`mcpServers` is a path to an MCP config JSON file
|
|
499
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
857
|
+
guidance: "`mcpServers` is a path to an MCP config JSON file or an `.mcpb`/`.dxt` bundle, the config inline as an object keyed by server name — the same shape `.mcp.json` carries — or a list of either. A `channels` entry's `server` must match a key here, so the inline object is the form to reach for when the two are authored together.",
|
|
858
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
500
859
|
}),
|
|
501
860
|
clause(type("lspServers", ["string", "list", "map"]), {
|
|
502
861
|
severity: "required",
|
|
503
|
-
guidance: "`lspServers` is a path to an LSP config JSON file,
|
|
504
|
-
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-
|
|
862
|
+
guidance: "`lspServers` is a path to an LSP config JSON file, the config inline as an object keyed by server name — the same shape `.lsp.json` carries — or a list of either. These drive code intelligence (go to definition, find references), so a wrong-typed value costs the capability silently rather than loudly.",
|
|
863
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
864
|
+
}),
|
|
865
|
+
clause(type("outputStyles", ["string", "list"]), {
|
|
866
|
+
severity: "required",
|
|
867
|
+
guidance: "`outputStyles` names output-style files or directories as one path or a list of them. Setting it *replaces* the default `output-styles/` scan — to keep the default and add to it, list it explicitly: `[\"./output-styles/\", \"./styles/\"]`.",
|
|
868
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
869
|
+
}),
|
|
870
|
+
clause(type("workflows", ["string", "list"]), {
|
|
871
|
+
severity: "required",
|
|
872
|
+
guidance: "`workflows` names workflow `.js` files or directories as one path or a list of them. Setting it *replaces* the default `workflows/` scan — to keep the default and add to it, list it explicitly: `[\"./workflows/\", \"./extras/\"]`.",
|
|
873
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#component-path-forms (retrieved 2026-11-26)",
|
|
874
|
+
}),
|
|
875
|
+
clause(type("experimental", ["map"]), {
|
|
876
|
+
severity: "required",
|
|
877
|
+
guidance: "`experimental` is an object whose keys are the experimental components — `themes`, `monitors`, `evals` — each carrying its own path form: `{ \"themes\": \"./themes/\" }`, never a bare path or a list.",
|
|
878
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
505
879
|
}),
|
|
506
880
|
// Every documented top-level key the manifest recognizes, `name` (required, above)
|
|
507
881
|
// aside — the allow-list `closedKeys()` reads, declared here once and consumed there
|
|
@@ -510,87 +884,158 @@ export const pluginManifestDefaultContract = [
|
|
|
510
884
|
// absent from this block is one `closedKeys()` indicts.
|
|
511
885
|
clause(optional("$schema"), {
|
|
512
886
|
severity: "required",
|
|
513
|
-
|
|
887
|
+
guidance: "`$schema` is a JSON Schema URL for editor autocomplete; Claude Code ignores it at load time, so it costs nothing at runtime.",
|
|
888
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
514
889
|
}),
|
|
515
890
|
clause(optional("displayName"), {
|
|
516
891
|
severity: "required",
|
|
517
|
-
|
|
892
|
+
guidance: "`displayName` is the name the UI shows in place of `name` — it may carry spaces and any casing and is never used for lookup. A marketplace entry's own `displayName` takes precedence over this one.",
|
|
893
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
518
894
|
}),
|
|
519
895
|
clause(optional("version"), {
|
|
520
896
|
severity: "required",
|
|
521
|
-
|
|
897
|
+
guidance: "`version` is not checked as semver, and setting it pins users to that version until you change it — so bump it with every release, or leave it out.",
|
|
898
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
522
899
|
}),
|
|
523
900
|
clause(optional("description"), {
|
|
524
901
|
severity: "required",
|
|
525
|
-
|
|
902
|
+
guidance: "`description` is a short explanation of what the plugin provides, shown wherever the plugin is listed.",
|
|
903
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
526
904
|
}),
|
|
527
905
|
clause(optional("author"), {
|
|
528
906
|
severity: "required",
|
|
529
|
-
|
|
907
|
+
guidance: "`author` is an object: `name` is required, `email` and `url` optional.",
|
|
908
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
530
909
|
}),
|
|
531
910
|
clause(optional("homepage"), {
|
|
532
911
|
severity: "required",
|
|
533
|
-
|
|
912
|
+
guidance: "`homepage` is the plugin's documentation URL, and it must parse as a URL.",
|
|
913
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
534
914
|
}),
|
|
535
915
|
clause(optional("repository"), {
|
|
536
916
|
severity: "required",
|
|
537
|
-
|
|
917
|
+
guidance: "`repository` is the source repository URL; Claude Code does not validate it.",
|
|
918
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
538
919
|
}),
|
|
539
920
|
clause(optional("license"), {
|
|
540
921
|
severity: "required",
|
|
541
|
-
|
|
922
|
+
guidance: "`license` is an SPDX identifier such as `MIT`.",
|
|
923
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
542
924
|
}),
|
|
543
925
|
clause(optional("keywords"), {
|
|
544
926
|
severity: "required",
|
|
545
|
-
|
|
927
|
+
guidance: "`keywords` is an array of discovery tags.",
|
|
928
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
929
|
+
}),
|
|
930
|
+
clause(optional("metadata"), {
|
|
931
|
+
severity: "required",
|
|
932
|
+
guidance: "`metadata` is a free-form object for your own data, such as catalog or entitlement fields. Claude Code does not read it.",
|
|
933
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
934
|
+
}),
|
|
935
|
+
clause(optional("icon"), {
|
|
936
|
+
severity: "required",
|
|
937
|
+
guidance: "`icon` is the plugin's icon in Anthropic's directory listing. Claude Code does not read it, and `claude plugin validate` before v2.1.281 reports it as unknown, so a `--strict` run on those versions fails.",
|
|
938
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
939
|
+
}),
|
|
940
|
+
clause(optional("documentationUrl"), {
|
|
941
|
+
severity: "required",
|
|
942
|
+
guidance: "`documentationUrl` is the documentation link in Anthropic's directory listing. Claude Code does not read it, and `claude plugin validate` before v2.1.281 reports it as unknown, so a `--strict` run on those versions fails.",
|
|
943
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
944
|
+
}),
|
|
945
|
+
clause(optional("supportUrl"), {
|
|
946
|
+
severity: "required",
|
|
947
|
+
guidance: "`supportUrl` is the support link in Anthropic's directory listing. Claude Code does not read it, and `claude plugin validate` before v2.1.281 reports it as unknown, so a `--strict` run on those versions fails.",
|
|
948
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
949
|
+
}),
|
|
950
|
+
clause(optional("privacyPolicyUrl"), {
|
|
951
|
+
severity: "required",
|
|
952
|
+
guidance: "`privacyPolicyUrl` is the privacy policy link in Anthropic's directory listing. Claude Code does not read it, and `claude plugin validate` before v2.1.281 reports it as unknown, so a `--strict` run on those versions fails.",
|
|
953
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
954
|
+
}),
|
|
955
|
+
clause(optional("termsOfServiceUrl"), {
|
|
956
|
+
severity: "required",
|
|
957
|
+
guidance: "`termsOfServiceUrl` is the terms of service link in Anthropic's directory listing. Claude Code does not read it, and `claude plugin validate` before v2.1.281 reports it as unknown, so a `--strict` run on those versions fails.",
|
|
958
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
959
|
+
}),
|
|
960
|
+
clause(optional("engines"), {
|
|
961
|
+
severity: "required",
|
|
962
|
+
guidance: "`engines` declares the Claude Code versions the plugin works on, as a semver range under `claude-code` (`{ \"claude-code\": \">=2.1.400\" }`); it needs v2.1.323 or later. Versions v2.0.15 through v2.1.75 reject a manifest carrying it with `Unrecognized key`, so omit it to keep those working.",
|
|
963
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
964
|
+
}),
|
|
965
|
+
clause(optional("network"), {
|
|
966
|
+
severity: "required",
|
|
967
|
+
guidance: "`network` lists the hosts the plugin reaches (`{ \"hosts\": [\"api.example.com\"] }`, in `sandbox.network.allowedDomains` syntax) for `claude plugin validate` to report; it allows and blocks nothing. Requires v2.1.328 or later.",
|
|
968
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
969
|
+
}),
|
|
970
|
+
clause(optional("types"), {
|
|
971
|
+
severity: "required",
|
|
972
|
+
guidance: "`types` is a path to a `.d.ts` file declaring a mod's `$.state` values and `$` nouns.",
|
|
973
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
546
974
|
}),
|
|
547
975
|
clause(optional("defaultEnabled"), {
|
|
548
976
|
severity: "required",
|
|
549
|
-
|
|
977
|
+
guidance: "`defaultEnabled` (a boolean, default `true`) sets whether the plugin starts enabled when the user has no `enabledPlugins` entry for it. Once that entry is written, later changes to this field no longer reach that user.",
|
|
978
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
550
979
|
}),
|
|
551
980
|
clause(optional("skills"), {
|
|
552
981
|
severity: "required",
|
|
553
|
-
|
|
982
|
+
guidance: "`skills` names extra directories scanned for `<name>/SKILL.md` skills. It adds to the default `skills/` scan rather than replacing it.",
|
|
983
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
554
984
|
}),
|
|
555
985
|
clause(optional("commands"), {
|
|
556
986
|
severity: "required",
|
|
557
|
-
|
|
987
|
+
guidance: "`commands` names flat `.md` files or directories, or maps command names to entries. Setting it replaces the default `commands/` scan; list `./commands/` explicitly to keep it.",
|
|
988
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
558
989
|
}),
|
|
559
990
|
clause(optional("agents"), {
|
|
560
991
|
severity: "required",
|
|
561
|
-
|
|
992
|
+
guidance: "`agents` names agent `.md` files; directories are not accepted. Setting it replaces the default `agents/` scan; list `./agents/` explicitly to keep it.",
|
|
993
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
562
994
|
}),
|
|
563
995
|
clause(optional("hooks"), {
|
|
564
996
|
severity: "required",
|
|
565
|
-
|
|
997
|
+
guidance: "`hooks` is a hook config `.json` path, an inline hooks object, or a list of either. It merges with `hooks/hooks.json` rather than replacing it.",
|
|
998
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
566
999
|
}),
|
|
567
1000
|
clause(optional("mcpServers"), {
|
|
568
1001
|
severity: "required",
|
|
569
|
-
|
|
1002
|
+
guidance: "`mcpServers` is an MCP config path or `.mcpb`/`.dxt` bundle, an inline server map, or a list of either. It merges with `.mcp.json`, and a server name declared later replaces an earlier one.",
|
|
1003
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
570
1004
|
}),
|
|
571
1005
|
clause(optional("outputStyles"), {
|
|
572
1006
|
severity: "required",
|
|
573
|
-
|
|
1007
|
+
guidance: "`outputStyles` names output-style files or directories. Setting it replaces the default `output-styles/` scan; list `./output-styles/` explicitly to keep it.",
|
|
1008
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
574
1009
|
}),
|
|
575
1010
|
clause(optional("lspServers"), {
|
|
576
1011
|
severity: "required",
|
|
577
|
-
|
|
1012
|
+
guidance: "`lspServers` is an LSP config `.json` path, an inline server map, or a list of either. It merges with `.lsp.json`.",
|
|
1013
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
1014
|
+
}),
|
|
1015
|
+
clause(optional("workflows"), {
|
|
1016
|
+
severity: "required",
|
|
1017
|
+
guidance: "`workflows` names workflow `.js` files or directories. Setting it replaces the default `workflows/` scan; list `./workflows/` explicitly to keep it.",
|
|
1018
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
578
1019
|
}),
|
|
579
1020
|
clause(optional("experimental"), {
|
|
580
1021
|
severity: "required",
|
|
581
|
-
|
|
1022
|
+
guidance: "`experimental` is the container for components whose manifest shape may still change: `themes`, `monitors`, and `evals` (the eval-case directory when it is not the default `evals/`). Declare `themes` and `monitors` under it, not at the top level.",
|
|
1023
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
582
1024
|
}),
|
|
583
1025
|
clause(optional("userConfig"), {
|
|
584
1026
|
severity: "required",
|
|
585
|
-
|
|
1027
|
+
guidance: "`userConfig` declares the values Claude Code prompts for when the plugin is enabled. Each option carries a `type`, `title` and `description`. A `sensitive` option's value goes to the secure credential store rather than to settings.",
|
|
1028
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
586
1029
|
}),
|
|
587
1030
|
clause(optional("channels"), {
|
|
588
1031
|
severity: "required",
|
|
589
|
-
|
|
1032
|
+
guidance: "`channels` lists the message channels the plugin provides. Each entry's `server` must be the key of one of the plugin's `mcpServers`.",
|
|
1033
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
590
1034
|
}),
|
|
591
1035
|
clause(optional("dependencies"), {
|
|
592
1036
|
severity: "required",
|
|
593
|
-
|
|
1037
|
+
guidance: "`dependencies` lists plugins that must be enabled for this one to work, each as `\"name\"`, `\"name@marketplace\"`, or a `{ name, marketplace, version }` object.",
|
|
1038
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
594
1039
|
}),
|
|
595
1040
|
// Recognized at the top level, and separately denied there by the `forbiddenKeys` clause
|
|
596
1041
|
// above: the migration is where they are declared, not whether the key is known. Leaving
|
|
@@ -598,11 +1043,13 @@ export const pluginManifestDefaultContract = [
|
|
|
598
1043
|
// the format, and a second finding for one mistake.
|
|
599
1044
|
clause(optional("themes"), {
|
|
600
1045
|
severity: "required",
|
|
601
|
-
|
|
1046
|
+
guidance: "`themes` is recognized here only so the `forbidden-keys` clause can name the move: theme files belong under `experimental.themes`.",
|
|
1047
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
602
1048
|
}),
|
|
603
1049
|
clause(optional("monitors"), {
|
|
604
1050
|
severity: "required",
|
|
605
|
-
|
|
1051
|
+
guidance: "`monitors` is recognized here only so the `forbidden-keys` clause can name the move: monitors belong under `experimental.monitors`.",
|
|
1052
|
+
cite: "https://code.claude.com/docs/en/plugins-reference#fields (retrieved 2026-11-26)",
|
|
606
1053
|
}),
|
|
607
1054
|
// The published schema's own property, absent from the reference's field tables. The
|
|
608
1055
|
// allow-list spans both sources: this contract already treats the schema as documentation
|
|
@@ -610,6 +1057,7 @@ export const pluginManifestDefaultContract = [
|
|
|
610
1057
|
// false positive.
|
|
611
1058
|
clause(optional("settings"), {
|
|
612
1059
|
severity: "required",
|
|
1060
|
+
guidance: "`settings` is a property of the published manifest schema, though the reference's field tables omit it. It is admitted here so a schema-valid manifest never draws a `closed-keys` finding.",
|
|
613
1061
|
cite: "https://json.schemastore.org/claude-code-plugin-manifest.json (retrieved 2026-07-16)",
|
|
614
1062
|
}),
|
|
615
1063
|
clause(closedKeys(), {
|
|
@@ -737,6 +1185,8 @@ export const marketplaceDefaultContract = [
|
|
|
737
1185
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
738
1186
|
}),
|
|
739
1187
|
], {
|
|
1188
|
+
severity: "required",
|
|
1189
|
+
guidance: "Where a catalog entry's `source` is a string, it is a relative path, resolved from the marketplace root — so the body below holds it to the path form.",
|
|
740
1190
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
741
1191
|
}),
|
|
742
1192
|
when(enumOf("plugins[*].source.source", ["github"]), [
|
|
@@ -746,6 +1196,8 @@ export const marketplaceDefaultContract = [
|
|
|
746
1196
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
747
1197
|
}),
|
|
748
1198
|
], {
|
|
1199
|
+
severity: "required",
|
|
1200
|
+
guidance: "Where a catalog entry's source object is a `github` source, the body below holds the field that source type requires: the `owner/repo` repository.",
|
|
749
1201
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
750
1202
|
}),
|
|
751
1203
|
when(enumOf("plugins[*].source.source", ["url"]), [
|
|
@@ -755,6 +1207,8 @@ export const marketplaceDefaultContract = [
|
|
|
755
1207
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
756
1208
|
}),
|
|
757
1209
|
], {
|
|
1210
|
+
severity: "required",
|
|
1211
|
+
guidance: "Where a catalog entry's source object is a `url` source, the body below holds the field that source type requires: the git URL to clone.",
|
|
758
1212
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
759
1213
|
}),
|
|
760
1214
|
when(enumOf("plugins[*].source.source", ["git-subdir"]), [
|
|
@@ -769,6 +1223,8 @@ export const marketplaceDefaultContract = [
|
|
|
769
1223
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
770
1224
|
}),
|
|
771
1225
|
], {
|
|
1226
|
+
severity: "required",
|
|
1227
|
+
guidance: "Where a catalog entry's source object is a `git-subdir` source, the body below holds the fields that source type requires: the repository URL and the subdirectory holding the plugin.",
|
|
772
1228
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
773
1229
|
}),
|
|
774
1230
|
when(enumOf("plugins[*].source.source", ["npm"]), [
|
|
@@ -778,6 +1234,8 @@ export const marketplaceDefaultContract = [
|
|
|
778
1234
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
779
1235
|
}),
|
|
780
1236
|
], {
|
|
1237
|
+
severity: "required",
|
|
1238
|
+
guidance: "Where a catalog entry's source object is an `npm` source, the body below holds the field that source type requires: the package name.",
|
|
781
1239
|
cite: "https://code.claude.com/docs/en/plugin-marketplaces#plugin-sources (retrieved 2026-07-16)",
|
|
782
1240
|
}),
|
|
783
1241
|
];
|
|
@@ -800,6 +1258,7 @@ export const settingsLocal = kind({
|
|
|
800
1258
|
format: "json-document",
|
|
801
1259
|
unitShape: "file",
|
|
802
1260
|
registration: [],
|
|
1261
|
+
edgeFields: [OUTPUT_STYLE_EDGE],
|
|
803
1262
|
});
|
|
804
1263
|
/**
|
|
805
1264
|
* The default contract for `settings-local` — deliberately near-empty. The settings format
|
|
@@ -859,6 +1318,8 @@ export const settings = kind({
|
|
|
859
1318
|
format: "json-document",
|
|
860
1319
|
unitShape: "file",
|
|
861
1320
|
registration: [],
|
|
1321
|
+
// The tool its `statusLine` command runs: carried on the lock, never in the file.
|
|
1322
|
+
edgeFields: [{ field: RUNS_FIELD, to: [tool] }, OUTPUT_STYLE_EDGE],
|
|
862
1323
|
});
|
|
863
1324
|
/**
|
|
864
1325
|
* The default contract for `settings` — the structural container keys typed, everything
|
|
@@ -951,7 +1412,7 @@ const PATHS_GATE_CITE = "https://code.claude.com/docs/en/skills (retrieved 2026-
|
|
|
951
1412
|
function pathsGateGuidance(member) {
|
|
952
1413
|
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. " +
|
|
953
1414
|
`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. ` +
|
|
954
|
-
"Advisory because
|
|
1415
|
+
"Advisory because containment is judged over sample paths each glob here matches, not decided, so a verdict can be wrong; retune or drop this clause in your own contract when it is. 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.");
|
|
955
1416
|
}
|
|
956
1417
|
/**
|
|
957
1418
|
* The default contract for `skill` — Anthropic's documented skill contract: the Agent
|
|
@@ -1072,7 +1533,7 @@ export const skillDefaultContract = [
|
|
|
1072
1533
|
export const supportingDocDefaultContract = [
|
|
1073
1534
|
clause(degree({ incoming: { min: 1 } }), {
|
|
1074
1535
|
severity: "advisory",
|
|
1075
|
-
guidance: "
|
|
1536
|
+
guidance: "No typed reference reaches this file: no resolved edge from the host skill points at it. A supporting file the skill's body never points at is invisible: Claude has no way to learn what it holds or when to load it, and it ships as dead weight in the bundle. Reference it from `SKILL.md` with `mentionOf(doc)`, or its path mention (`mentionOf`'s `path` form) where the body links the file; a hand-typed link in prose is no edge. What the edge cannot decide is whether the reference tells Claude *when* to follow it, and that sentence is the point of writing one.",
|
|
1076
1537
|
cite: "https://code.claude.com/docs/en/skills (retrieved 2026-07-16)",
|
|
1077
1538
|
}),
|
|
1078
1539
|
];
|
|
@@ -1089,12 +1550,40 @@ export const supportingDocDefaultContract = [
|
|
|
1089
1550
|
* the portable profile for skill directories.
|
|
1090
1551
|
*/
|
|
1091
1552
|
export const commandDefaultContract = [];
|
|
1553
|
+
/**
|
|
1554
|
+
* The default contract for `output-style` — one advisory `unshadowed` clause. Every
|
|
1555
|
+
* output-style field is optional, a misspelled one is ignored without an error, and a style
|
|
1556
|
+
* whose YAML does not parse still loads under its file name, so the format documents no
|
|
1557
|
+
* field requirement to gate. Styles load from every `.claude/output-styles/` folder and the
|
|
1558
|
+
* one nearest the working directory wins a shared name (code.claude.com/docs/en/output-styles,
|
|
1559
|
+
* retrieved 2026-11-25), so a nested style named like a shallower one is legal and loads —
|
|
1560
|
+
* the clause says which sessions it takes over, never refuses it.
|
|
1561
|
+
*/
|
|
1562
|
+
export const outputStyleDefaultContract = [
|
|
1563
|
+
clause(unshadowed(), {
|
|
1564
|
+
severity: "advisory",
|
|
1565
|
+
guidance: "A bare `outputStyle` name resolves to the style nearest the directory a session starts in, so a nested style sharing a shallower style's name replaces it for every session started at or below the nested folder. Rename one of them if both should stay selectable there; keep the shared name if the override is the point.",
|
|
1566
|
+
cite: "https://code.claude.com/docs/en/output-styles (retrieved 2026-11-25)",
|
|
1567
|
+
}),
|
|
1568
|
+
];
|
|
1569
|
+
/**
|
|
1570
|
+
* The default contract for `tool` — one advisory `degree` clause, incoming at least one: a
|
|
1571
|
+
* tool no runner reaches is a command nothing runs.
|
|
1572
|
+
*/
|
|
1573
|
+
export const toolDefaultContract = [
|
|
1574
|
+
clause(degree({ incoming: { min: 1 } }), {
|
|
1575
|
+
severity: "advisory",
|
|
1576
|
+
guidance: "Nothing runs this tool: no gate hook, tap, typecheck or script verifier reaches it by an edge. A tool is the one home of a command the harness runs, so one nothing points at is a declaration that governs nothing — a reader takes it for a live dependency, and its package, file or system claim is checked for no runner. Point the runner that executes this command at the tool, or delete the tool. Advisory because a tool declared ahead of its runner is ordinary work in progress; dial this label to `required` once every declared tool should be run.",
|
|
1577
|
+
cite: "https://github.com/duct-tape-and-markdown/temper/blob/main/specs/builtins.md#tool (retrieved 2026-11-26)",
|
|
1578
|
+
}),
|
|
1579
|
+
];
|
|
1092
1580
|
/**
|
|
1093
1581
|
* The default contract for `agent` — Anthropic's documented subagent contract
|
|
1094
|
-
* (code.claude.com/docs/en/sub-agents, retrieved 2026-
|
|
1095
|
-
* `description` are the only required fields
|
|
1096
|
-
*
|
|
1097
|
-
*
|
|
1582
|
+
* (code.claude.com/docs/en/sub-agents, retrieved 2026-11-25): `name` and
|
|
1583
|
+
* `description` are the only required fields; `name` is a "unique identifier of
|
|
1584
|
+
* at most 256 characters" with no documented charset (`reviewer-v2` is the docs'
|
|
1585
|
+
* own example, and a project agent named `Explore` overrides the built-in); and
|
|
1586
|
+
* "keep `name` values unique across subfolders" — a same-directory collision
|
|
1098
1587
|
* loads only one definition.
|
|
1099
1588
|
*
|
|
1100
1589
|
* Deliberately narrow, like `ruleDefaultContract`: undecidable properties (whether the
|
|
@@ -1105,24 +1594,47 @@ export const agentDefaultContract = [
|
|
|
1105
1594
|
clause(required("name"), {
|
|
1106
1595
|
severity: "required",
|
|
1107
1596
|
guidance: "Every subagent declares a `name` — its unique identifier. Claude Code binds identity to this field alone, never the filename, so a nameless subagent cannot be delegated to.",
|
|
1108
|
-
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-
|
|
1597
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1109
1598
|
}),
|
|
1110
|
-
clause(
|
|
1599
|
+
clause(maxLen("name", 256), {
|
|
1111
1600
|
severity: "required",
|
|
1112
|
-
guidance: "
|
|
1113
|
-
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-
|
|
1601
|
+
guidance: "A name longer than 256 characters is skipped at load — Claude Code writes an error to the debug log and the subagent never exists. Any case and digits are fine (`reviewer-v2`, `Explore` to override the built-in). Hooks receive this value as `agent_type`.",
|
|
1602
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1603
|
+
}),
|
|
1604
|
+
clause(allowedChars("name", { chars: ":", negated: true }), {
|
|
1605
|
+
severity: "required",
|
|
1606
|
+
guidance: "A name containing `:` is skipped at load — the colon is reserved for plugin-scoped ids like `my-plugin:reviewer`, so the subagent never exists. Use a hyphen instead (`my-reviewer`).",
|
|
1607
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1608
|
+
}),
|
|
1609
|
+
clause(allowedChars("name", { chars: "-", negated: true, position: "leading" }), {
|
|
1610
|
+
severity: "required",
|
|
1611
|
+
guidance: "A name starting with `-` is skipped at load, so the subagent never exists. Start with a letter or digit; a hyphen anywhere after the first character is fine (`reviewer-v2`).",
|
|
1612
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1114
1613
|
}),
|
|
1115
1614
|
clause(uniqueName(), {
|
|
1116
1615
|
severity: "required",
|
|
1117
1616
|
guidance: "Keep `name` values unique across the whole tree — when two files in one scope declare the same name, Claude Code loads only one of them, silently shadowing the other.",
|
|
1118
|
-
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-
|
|
1617
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1119
1618
|
}),
|
|
1120
1619
|
clause(required("description"), {
|
|
1121
1620
|
severity: "required",
|
|
1122
1621
|
guidance: "The description is how Claude decides when to delegate to this subagent — write it so the trigger is unambiguous.",
|
|
1123
|
-
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-
|
|
1622
|
+
cite: "https://code.claude.com/docs/en/sub-agents (retrieved 2026-11-25)",
|
|
1124
1623
|
}),
|
|
1125
1624
|
];
|
|
1625
|
+
/**
|
|
1626
|
+
* The per-file character limit an on-demand rules or memory file is truncated past, at the
|
|
1627
|
+
* smallest documented context window: "**200K context window**: 40,000 characters"; "**1M
|
|
1628
|
+
* context window**: 200,000 characters on Claude Opus 4.6 and Claude Sonnet 4.6, and
|
|
1629
|
+
* 150,000 characters on later models" — and "Before v2.1.309, Claude Code didn't apply
|
|
1630
|
+
* this limit to files that load on demand." Judging the smallest window keeps a passing
|
|
1631
|
+
* file whole on every one. The limit covers a subdirectory's `CLAUDE.md` and the rules it
|
|
1632
|
+
* loads on demand, so each clause over it is guarded on the load moment: a launch-loaded
|
|
1633
|
+
* file arrives whole up to 4 MiB.
|
|
1634
|
+
*/
|
|
1635
|
+
const ON_DEMAND_CHARACTER_LIMIT = 40_000;
|
|
1636
|
+
/** The memory docs' section stating the on-demand per-file size limit. */
|
|
1637
|
+
const ON_DEMAND_SIZE_LIMIT_CITE = "https://code.claude.com/docs/en/memory#claude-ignores-the-end-of-my-subdirectory-claude-md (retrieved 2026-11-26)";
|
|
1126
1638
|
/**
|
|
1127
1639
|
* The default contract for `rule` — Anthropic's documented contract for a Claude Code
|
|
1128
1640
|
* rules file, sourced from the memory docs (`.claude/rules/` landed in
|
|
@@ -1153,14 +1665,30 @@ export const ruleDefaultContract = [
|
|
|
1153
1665
|
}),
|
|
1154
1666
|
clause(extent("lines", 200), {
|
|
1155
1667
|
severity: "advisory",
|
|
1156
|
-
guidance: "Unconditional rules are always-on context, paid every session: the docs' size target is under 200 rendered lines per memory file — 'longer files consume more context and reduce adherence.' Measured render-side, off the projected artifact rather than the source body. (Distinct from the hard 200-line/25KB cutoff, which applies only to auto-memory MEMORY.md;
|
|
1668
|
+
guidance: "Unconditional rules are always-on context, paid every session: the docs' size target is under 200 rendered lines per memory file — 'longer files consume more context and reduce adherence.' Measured render-side, off the projected artifact rather than the source body. (Distinct from the hard 200-line/25KB cutoff, which applies only to auto-memory MEMORY.md. A rule that loads at launch arrives whole up to 4 MiB; a path-scoped rule is cut at a per-file character limit, which the clause below judges.) For each line ask: would removing it cause Claude to make mistakes? If not, cut it.",
|
|
1157
1669
|
cite: "https://code.claude.com/docs/en/memory#write-effective-instructions (retrieved 2026-07-15)",
|
|
1158
1670
|
}),
|
|
1671
|
+
when(loads("on-demand"), [
|
|
1672
|
+
clause(extent("characters", ON_DEMAND_CHARACTER_LIMIT), {
|
|
1673
|
+
severity: "advisory",
|
|
1674
|
+
guidance: "A rule with `paths`, or one under a subdirectory's own `.claude/rules/`, loads on demand, and an on-demand rules file past the per-file size limit reaches Claude truncated: only its start, ending in a note to read the rest with the Read tool, and until Claude does, the later instructions are not in its context. The limit scales with the context window — 40,000 characters at 200K, 150,000 to 200,000 at 1M — and this clause judges the smallest documented, so a rule that passes is whole on every window. Measured render-side, as `wc -m` counts the projected file. Trim the rule, or split it into several rules files, each of which counts against the limit on its own. A root rule without `paths` loads at launch and is not cut this way, so this clause binds only where the rule loads on demand.",
|
|
1675
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1676
|
+
}),
|
|
1677
|
+
], {
|
|
1678
|
+
severity: "advisory",
|
|
1679
|
+
guidance: "A rule that carries `paths`, or sits under a subdirectory's own `.claude/rules/`, loads on demand, so it is judged against the per-file limit an on-demand file is truncated past: 40,000 rendered characters, the smallest documented window's. A root rule without `paths` loads at launch, arrives whole, and is not judged by this clause.",
|
|
1680
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1681
|
+
}),
|
|
1159
1682
|
clause(mentionReachable("paths", "paths"), {
|
|
1160
1683
|
severity: "advisory",
|
|
1161
1684
|
guidance: pathsGateGuidance("rule"),
|
|
1162
1685
|
cite: PATHS_GATE_CITE,
|
|
1163
1686
|
}),
|
|
1687
|
+
clause(triggerAgrees("paths", "paths"), {
|
|
1688
|
+
severity: "advisory",
|
|
1689
|
+
guidance: "A path-scoped rule that mentions a path-scoped skill gives one area two triggers: the rule loads when a file tool touches a path its `paths` match, the skill becomes invocable when one touches a path the skill's `paths` match. Where the skill's gate reaches past this rule's scope, the skill can be invoked there without the rule that frames it ever loading, and the two triggers drift apart as either is edited. Keep them one set: widen this rule's `paths` to the skill's gate, or narrow the gate. Advisory because containment is judged over sample paths each glob matches, not decided, so a verdict can be wrong; retune or drop this clause in your own contract when it is.",
|
|
1690
|
+
cite: PATHS_GATE_CITE,
|
|
1691
|
+
}),
|
|
1164
1692
|
];
|
|
1165
1693
|
/**
|
|
1166
1694
|
* The default contract for the qualified `claude-code.memory` kind — Anthropic's
|
|
@@ -1170,16 +1698,69 @@ export const ruleDefaultContract = [
|
|
|
1170
1698
|
* markdown with no documented frontmatter and no required fields
|
|
1171
1699
|
* (code.claude.com/docs/en/memory, retrieved 2026-07-15), so there is no
|
|
1172
1700
|
* schema to gate — manufacturing a required field or a forbidden-key list
|
|
1173
|
-
* would fake a check the format does not carry. The
|
|
1174
|
-
*
|
|
1701
|
+
* would fake a check the format does not carry. The clauses are context-cost budgets —
|
|
1702
|
+
* the size target, and the per-file limit a subdirectory's `CLAUDE.md`, loaded on demand,
|
|
1703
|
+
* is truncated past; everything else the contract could say is guidance.
|
|
1175
1704
|
*/
|
|
1176
|
-
export const
|
|
1705
|
+
export const memoryDefaultContract = [
|
|
1177
1706
|
clause(extent("lines", 200), {
|
|
1178
1707
|
severity: "advisory",
|
|
1179
1708
|
guidance: "CLAUDE.md is always-on context, paid every session. The memory docs' size target is under 200 rendered lines per memory file — 'longer files consume more context and reduce adherence.' Measured render-side, off the projected artifact rather than the source body. For each line ask: would removing it cause Claude to make mistakes? If not, cut it. (Advisory: Claude Code loads the file in full regardless of length; this is a context-cost budget, not a hard cutoff.)",
|
|
1180
1709
|
cite: "https://code.claude.com/docs/en/memory#write-effective-instructions (retrieved 2026-07-15)",
|
|
1181
1710
|
}),
|
|
1711
|
+
when(loads("on-demand"), [
|
|
1712
|
+
clause(extent("characters", ON_DEMAND_CHARACTER_LIMIT), {
|
|
1713
|
+
severity: "advisory",
|
|
1714
|
+
guidance: "A subdirectory's CLAUDE.md loads on demand, the first time Claude reads a file beneath its directory, and an on-demand memory file past the per-file size limit reaches Claude truncated: only its start, ending in a note to read the rest with the Read tool, and until Claude does, the later instructions are not in its context. The limit scales with the context window — 40,000 characters at 200K, 150,000 to 200,000 at 1M — and this clause judges the smallest documented, so a file that passes is whole on every window. Measured render-side, as `wc -m` counts the projected file. Trim it, or move detail into rules under that subdirectory's `.claude/rules/`, each of which counts against the limit on its own. The root CLAUDE.md loads at launch and is not cut this way, so this clause binds only below the root.",
|
|
1715
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1716
|
+
}),
|
|
1717
|
+
], {
|
|
1718
|
+
severity: "advisory",
|
|
1719
|
+
guidance: "A CLAUDE.md below the harness root loads on demand, so it is judged against the per-file limit an on-demand file is truncated past: 40,000 rendered characters, the smallest documented window's. The root's loads at launch, arrives whole, and is not judged by this clause.",
|
|
1720
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1721
|
+
}),
|
|
1182
1722
|
];
|
|
1723
|
+
/**
|
|
1724
|
+
* The default contract for `memory-local` — the memory size target, which the docs state
|
|
1725
|
+
* per memory file, and a `CLAUDE.local.md` is loaded the same way a `CLAUDE.md` is; and
|
|
1726
|
+
* the per-file limit a subdirectory's `CLAUDE.local.md`, loaded on demand beside its
|
|
1727
|
+
* `CLAUDE.md`, is truncated past.
|
|
1728
|
+
*/
|
|
1729
|
+
export const memoryLocalDefaultContract = [
|
|
1730
|
+
clause(extent("lines", 200), {
|
|
1731
|
+
severity: "advisory",
|
|
1732
|
+
guidance: "CLAUDE.local.md loads beside the CLAUDE.md of its directory and is paid the same way, every session that loads it. The memory docs' size target is under 200 lines per memory file — 'longer files consume more context and reduce adherence.' It is personal and uncommitted, so trim it yourself: for each line ask whether removing it would cause Claude to make mistakes. (Advisory: Claude Code loads the file in full regardless of length.)",
|
|
1733
|
+
cite: "https://code.claude.com/docs/en/memory#write-effective-instructions (retrieved 2026-11-27)",
|
|
1734
|
+
}),
|
|
1735
|
+
when(loads("on-demand"), [
|
|
1736
|
+
clause(extent("characters", ON_DEMAND_CHARACTER_LIMIT), {
|
|
1737
|
+
severity: "advisory",
|
|
1738
|
+
guidance: "A subdirectory's CLAUDE.local.md loads on demand with that subdirectory's CLAUDE.md, the first time Claude reads a file beneath its directory, and an on-demand memory file past the per-file size limit reaches Claude truncated: only its start, ending in a note to read the rest with the Read tool, and until Claude does, the later instructions are not in its context. The limit scales with the context window — 40,000 characters at 200K, 150,000 to 200,000 at 1M — and this clause judges the smallest documented, so a file that passes is whole on every window. Measured as `wc -m` counts the file. Trim it, or split detail into files it imports, each of which counts against the limit on its own. The root CLAUDE.local.md loads at launch and is not cut this way, so this clause binds only below the root.",
|
|
1739
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1740
|
+
}),
|
|
1741
|
+
], {
|
|
1742
|
+
severity: "advisory",
|
|
1743
|
+
guidance: "A CLAUDE.local.md below the harness root loads on demand, so it is judged against the per-file limit an on-demand file is truncated past: 40,000 characters, the smallest documented window's. The root's loads at launch, arrives whole, and is not judged by this clause.",
|
|
1744
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1745
|
+
}),
|
|
1746
|
+
];
|
|
1747
|
+
/**
|
|
1748
|
+
* The root's size clause over every import target no kind claims: such a file has no
|
|
1749
|
+
* kind contract to size it, so it is judged at the root, through the reference graph,
|
|
1750
|
+
* against the per-file limit when the memory that imports it loads on demand. A file a
|
|
1751
|
+
* launch-loaded member reaches arrives whole and is not judged.
|
|
1752
|
+
*/
|
|
1753
|
+
export const unclaimedImportSizeClause = when(loads("on-demand"), [
|
|
1754
|
+
clause(extent("characters", ON_DEMAND_CHARACTER_LIMIT), {
|
|
1755
|
+
severity: "advisory",
|
|
1756
|
+
guidance: "This file no kind claims is imported by memory that loads on demand — a subdirectory's CLAUDE.md or CLAUDE.local.md, read the first time Claude reads a file beneath its directory — and an on-demand file past the per-file size limit reaches Claude truncated: only its start, ending in a note to read the rest with the Read tool, and until Claude does, the later instructions are not in its context. The limit scales with the context window — 40,000 characters at 200K, 150,000 to 200,000 at 1M — and this clause judges the smallest documented, so a file that passes is whole on every window. Measured as `wc -m` counts the file. Trim it, or split it into several imported files, each of which counts against the limit on its own. A file a launch-loaded member imports arrives whole and is not judged.",
|
|
1757
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1758
|
+
}),
|
|
1759
|
+
], {
|
|
1760
|
+
severity: "advisory",
|
|
1761
|
+
guidance: "An import target no kind claims has no kind contract of its own, so the root sizes it: where every member importing it loads on demand, it is judged against the per-file limit an on-demand file is truncated past, 40,000 characters, the smallest documented window's.",
|
|
1762
|
+
cite: ON_DEMAND_SIZE_LIMIT_CITE,
|
|
1763
|
+
});
|
|
1183
1764
|
/**
|
|
1184
1765
|
* Every documented Claude Code hook lifecycle event — the closed set a `hooks.<Event>`
|
|
1185
1766
|
* key is drawn from (code.claude.com/docs/en/hooks, "Hook events", retrieved 2026-09-25).
|
|
@@ -1269,14 +1850,22 @@ export const handlerDefaultContract = [
|
|
|
1269
1850
|
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.",
|
|
1270
1851
|
cite: "https://code.claude.com/docs/en/hooks#command-hook-fields (retrieved 2026-09-25)",
|
|
1271
1852
|
}),
|
|
1272
|
-
], {
|
|
1853
|
+
], {
|
|
1854
|
+
severity: "required",
|
|
1855
|
+
guidance: "Where a handler's `type` is `command`, the body below holds the field that type requires: the command to run.",
|
|
1856
|
+
cite: "https://code.claude.com/docs/en/hooks#command-hook-fields (retrieved 2026-09-25)",
|
|
1857
|
+
}),
|
|
1273
1858
|
when(enumOf("type", ["http"]), [
|
|
1274
1859
|
clause(required("url"), {
|
|
1275
1860
|
severity: "required",
|
|
1276
1861
|
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.",
|
|
1277
1862
|
cite: "https://code.claude.com/docs/en/hooks#http-hook-fields (retrieved 2026-09-25)",
|
|
1278
1863
|
}),
|
|
1279
|
-
], {
|
|
1864
|
+
], {
|
|
1865
|
+
severity: "required",
|
|
1866
|
+
guidance: "Where a handler's `type` is `http`, the body below holds the field that type requires: the endpoint the event's JSON input is POSTed to.",
|
|
1867
|
+
cite: "https://code.claude.com/docs/en/hooks#http-hook-fields (retrieved 2026-09-25)",
|
|
1868
|
+
}),
|
|
1280
1869
|
when(enumOf("type", ["mcp_tool"]), [
|
|
1281
1870
|
clause(required("server"), {
|
|
1282
1871
|
severity: "required",
|
|
@@ -1288,14 +1877,22 @@ export const handlerDefaultContract = [
|
|
|
1288
1877
|
guidance: "An `mcp_tool` handler names the tool it calls on its server; the server alone does not say what to invoke.",
|
|
1289
1878
|
cite: "https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields (retrieved 2026-09-25)",
|
|
1290
1879
|
}),
|
|
1291
|
-
], {
|
|
1880
|
+
], {
|
|
1881
|
+
severity: "required",
|
|
1882
|
+
guidance: "Where a handler's `type` is `mcp_tool`, the body below holds the fields that type requires: the connected server and the tool to call on it.",
|
|
1883
|
+
cite: "https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields (retrieved 2026-09-25)",
|
|
1884
|
+
}),
|
|
1292
1885
|
when(enumOf("type", ["prompt", "agent"]), [
|
|
1293
1886
|
clause(required("prompt"), {
|
|
1294
1887
|
severity: "required",
|
|
1295
1888
|
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.",
|
|
1296
1889
|
cite: "https://code.claude.com/docs/en/hooks#prompt-and-agent-hook-fields (retrieved 2026-09-25)",
|
|
1297
1890
|
}),
|
|
1298
|
-
], {
|
|
1891
|
+
], {
|
|
1892
|
+
severity: "required",
|
|
1893
|
+
guidance: "Where a handler's `type` is `prompt` or `agent`, the body below holds the field both types require: the prompt text sent to the model.",
|
|
1894
|
+
cite: "https://code.claude.com/docs/en/hooks#prompt-and-agent-hook-fields (retrieved 2026-09-25)",
|
|
1895
|
+
}),
|
|
1299
1896
|
];
|
|
1300
1897
|
/**
|
|
1301
1898
|
* The default contract for `hook` — Anthropic's documented hooks contract
|
|
@@ -1357,11 +1954,14 @@ const DOCUMENTED_MCP_TRANSPORTS = ["stdio", "http", "streamable-http", "sse", "w
|
|
|
1357
1954
|
* cited property that holds across every transport is `type`: a value outside the
|
|
1358
1955
|
* documented set is a transport Claude Code cannot honor, so the strictest documented
|
|
1359
1956
|
* profile is that a present `type` names one temper's cited docs carry. An absent `type`
|
|
1360
|
-
* passes
|
|
1957
|
+
* passes that clause.
|
|
1361
1958
|
*
|
|
1362
1959
|
* The per-transport requirements gate as `when` clauses: a `stdio` server needs a
|
|
1363
1960
|
* `command`, and a remote server (`http`, `streamable-http`, `sse`, or `ws`) needs a
|
|
1364
|
-
* `url`.
|
|
1961
|
+
* `url`. The guards read `type` as Claude Code does — absent is `stdio`, the documented
|
|
1962
|
+
* default {@link McpServer.type} cites, a built-in fact of the `mcp-server` kind's format
|
|
1963
|
+
* (`src/builtin_kind.rs`) — so an entry with no `type` is judged a stdio server, and one
|
|
1964
|
+
* carrying only a `url` draws the stdio `command` finding rather than passing as remote.
|
|
1365
1965
|
*/
|
|
1366
1966
|
export const mcpServerDefaultContract = [
|
|
1367
1967
|
clause(enumOf("type", DOCUMENTED_MCP_TRANSPORTS), {
|
|
@@ -1372,10 +1972,12 @@ export const mcpServerDefaultContract = [
|
|
|
1372
1972
|
when(enumOf("type", ["stdio"]), [
|
|
1373
1973
|
clause(required("command"), {
|
|
1374
1974
|
severity: "required",
|
|
1375
|
-
guidance: "A stdio server must specify a `command` — the executable path and arguments to run the server process. Without it, Claude Code cannot start the server.
|
|
1975
|
+
guidance: "A stdio server must specify a `command` — the executable path and arguments to run the server process. Without it, Claude Code cannot start the server. An entry with no `type` is a stdio server, as Claude Code reads it, so this fires there too: a server reached at a `url` needs its remote `type` (`http`, `sse`, or `ws`) declared.",
|
|
1376
1976
|
cite: "https://code.claude.com/docs/en/mcp#transport-options (retrieved 2026-07-15)",
|
|
1377
1977
|
}),
|
|
1378
1978
|
], {
|
|
1979
|
+
severity: "required",
|
|
1980
|
+
guidance: "Where a server's transport is `stdio` — the default an entry with no `type` reads as — the body below holds the field a local process requires: the command that starts it.",
|
|
1379
1981
|
cite: "https://code.claude.com/docs/en/mcp#transport-options (retrieved 2026-07-15)",
|
|
1380
1982
|
}),
|
|
1381
1983
|
when(enumOf("type", ["http", "streamable-http", "sse", "ws"]), [
|
|
@@ -1385,6 +1987,8 @@ export const mcpServerDefaultContract = [
|
|
|
1385
1987
|
cite: "https://code.claude.com/docs/en/mcp#transport-options (retrieved 2026-07-15)",
|
|
1386
1988
|
}),
|
|
1387
1989
|
], {
|
|
1990
|
+
severity: "required",
|
|
1991
|
+
guidance: "Where a server's transport is remote (`http`, `streamable-http`, `sse` or `ws`), the body below holds the field every remote transport requires: the endpoint URL.",
|
|
1388
1992
|
cite: "https://code.claude.com/docs/en/mcp#transport-options (retrieved 2026-07-15)",
|
|
1389
1993
|
}),
|
|
1390
1994
|
];
|