@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.
Files changed (70) hide show
  1. package/README.md +14 -12
  2. package/dist/src/assembly.d.ts +45 -11
  3. package/dist/src/assembly.js +115 -7
  4. package/dist/src/builtins.d.ts +433 -103
  5. package/dist/src/builtins.js +771 -167
  6. package/dist/src/claude-code.d.ts +6 -3
  7. package/dist/src/claude-code.js +2 -2
  8. package/dist/src/contract.d.ts +153 -44
  9. package/dist/src/contract.js +123 -34
  10. package/dist/src/counsel.d.ts +11 -0
  11. package/dist/src/counsel.js +68 -0
  12. package/dist/src/declarations.d.ts +108 -2
  13. package/dist/src/declarations.js +606 -100
  14. package/dist/src/dial.d.ts +3 -3
  15. package/dist/src/dial.js +21 -5
  16. package/dist/src/emit.d.ts +12 -14
  17. package/dist/src/emit.js +123 -47
  18. package/dist/src/generated/AbsenceGateRow.d.ts +16 -0
  19. package/dist/src/generated/AbsenceGateRow.js +2 -0
  20. package/dist/src/generated/AreaMode.d.ts +5 -0
  21. package/dist/src/generated/AreaMode.js +2 -0
  22. package/dist/src/generated/AreaRow.d.ts +20 -0
  23. package/dist/src/generated/AreaRow.js +1 -0
  24. package/dist/src/generated/AssemblyFactRow.d.ts +17 -4
  25. package/dist/src/generated/BoundRow.d.ts +9 -4
  26. package/dist/src/generated/CedeRow.d.ts +14 -0
  27. package/dist/src/generated/CedeRow.js +2 -0
  28. package/dist/src/generated/CharsetRow.d.ts +14 -3
  29. package/dist/src/generated/ClauseRow.d.ts +23 -21
  30. package/dist/src/generated/CollectionAddressRow.d.ts +1 -1
  31. package/dist/src/generated/Declarations.d.ts +24 -9
  32. package/dist/src/generated/FeatureValue.d.ts +3 -3
  33. package/dist/src/generated/Features.d.ts +3 -3
  34. package/dist/src/generated/KindFactRow.d.ts +41 -8
  35. package/dist/src/generated/Payload.d.ts +3 -5
  36. package/dist/src/generated/PayloadMember.d.ts +7 -0
  37. package/dist/src/generated/RunsRow.d.ts +17 -0
  38. package/dist/src/generated/RunsRow.js +2 -0
  39. package/dist/src/generated/Section.d.ts +2 -2
  40. package/dist/src/generated/SectionContainsRow.d.ts +1 -1
  41. package/dist/src/generated/TypecheckRow.d.ts +20 -0
  42. package/dist/src/generated/TypecheckRow.js +2 -0
  43. package/dist/src/generated/Verifier.d.ts +8 -2
  44. package/dist/src/generated/index.d.ts +6 -0
  45. package/dist/src/index.d.ts +20 -15
  46. package/dist/src/index.js +10 -9
  47. package/dist/src/kind.d.ts +382 -52
  48. package/dist/src/kind.js +461 -49
  49. package/dist/src/lockfile.d.ts +39 -0
  50. package/dist/src/lockfile.js +265 -0
  51. package/dist/src/member-address.d.ts +15 -3
  52. package/dist/src/member-address.js +23 -6
  53. package/dist/src/needs.d.ts +25 -15
  54. package/dist/src/needs.js +10 -11
  55. package/dist/src/patterns.d.ts +112 -0
  56. package/dist/src/patterns.js +90 -0
  57. package/dist/src/pipe.d.ts +16 -0
  58. package/dist/src/pipe.js +39 -0
  59. package/dist/src/playbook.d.ts +203 -0
  60. package/dist/src/playbook.js +239 -0
  61. package/dist/src/prose.d.ts +69 -12
  62. package/dist/src/prose.js +125 -13
  63. package/dist/src/reference.d.ts +70 -0
  64. package/dist/src/reference.js +368 -0
  65. package/package.json +13 -4
  66. package/schemas/agent.json +23 -0
  67. package/schemas/command.json +5 -0
  68. package/schemas/output-style.json +4 -0
  69. package/schemas/rule.json +33 -0
  70. package/schemas/skill.json +63 -0
@@ -30,11 +30,11 @@ import type { KindDefinition } from "./kind.js";
30
30
  */
31
31
  export interface DialEntry {
32
32
  /**
33
- * The clause's compiled address — the label every finding prints as its `rule` id
33
+ * The clause's id — the compiled address every finding prints as its `rule` id
34
34
  * and `explain` narrates (decision 0032). Spelled straight back out of the finding:
35
- * that round trip is what the label's legibility exists for.
35
+ * that round trip is what the id's legibility exists for.
36
36
  */
37
- readonly label: string;
37
+ readonly id: string;
38
38
  /** The severity this machine reads that clause at. */
39
39
  readonly severity: Severity;
40
40
  }
package/dist/src/dial.js CHANGED
@@ -40,6 +40,8 @@ export const dial = kind({
40
40
  registration: [],
41
41
  identityField: "name",
42
42
  });
43
+ /** The corpus section that rules the dial envelope — a temper-owned format, cited to its own spec. */
44
+ const DIAL_CITE = "https://github.com/duct-tape-and-markdown/temper/blob/main/specs/model/contract.md#clause (retrieved 2026-11-26)";
43
45
  /**
44
46
  * The default contract for `dial` — the envelope, stated as clauses.
45
47
  *
@@ -56,27 +58,41 @@ export const dialDefaultContract = [
56
58
  clause(required("name"), {
57
59
  severity: "required",
58
60
  guidance: "A dial names the machine it speaks for — its identity, and what its findings are reported under. There is no filename fallback: every machine's dial is `dial.toml`.",
61
+ cite: DIAL_CITE,
62
+ }),
63
+ clause(type("name", ["string"]), {
64
+ severity: "required",
65
+ guidance: "The machine's name is a string — the label its findings report under, written `name = \"laptop\"`.",
66
+ cite: DIAL_CITE,
59
67
  }),
60
- clause(type("name", ["string"]), { severity: "required" }),
61
68
  clause(type("clause", ["list"]), {
62
69
  severity: "required",
63
- guidance: "The dialed clauses are an array of tables — `[[clause]]` per entry, each naming one `label` and one `severity`.",
70
+ guidance: "The dialed clauses are an array of tables — `[[clause]]` per entry, each naming one `id` and one `severity`.",
71
+ cite: DIAL_CITE,
72
+ }),
73
+ clause(required("clause[*].id"), {
74
+ severity: "required",
75
+ guidance: "An entry names the clause it dials by the address the finding printed as its `rule` id — spell it back verbatim. An entry naming an id no clause in this harness carries is a finding, never a silent no-op.",
76
+ cite: DIAL_CITE,
64
77
  }),
65
- clause(required("clause[*].label"), {
78
+ clause(type("clause[*].id", ["string"]), {
66
79
  severity: "required",
67
- guidance: "An entry names the clause it dials by the address the finding printed as its `rule` id — spell it back verbatim. An entry naming a label no clause in this harness carries is a finding, never a silent no-op.",
80
+ guidance: "An id is a string — the clause's printed `rule` id, quoted verbatim: `id = \"skill.required.description\"`.",
81
+ cite: DIAL_CITE,
68
82
  }),
69
- clause(type("clause[*].label", ["string"]), { severity: "required" }),
70
83
  clause(required("clause[*].severity"), {
71
84
  severity: "required",
72
85
  guidance: "Severity is an entry's only verb: it is what a dial says, and all a dial says.",
86
+ cite: DIAL_CITE,
73
87
  }),
74
88
  clause(enumOf("clause[*].severity", ["required", "advisory"]), {
75
89
  severity: "required",
76
90
  guidance: "The two severities an authored clause declares under are the two a dial re-declares under — there is no third value that means `off`. Softening a clause to `advisory` still reports it, and is inert in block mode; hardening one to `required` binds in every mode.",
91
+ cite: DIAL_CITE,
77
92
  }),
78
93
  clause(closedKeys(), {
79
94
  severity: "required",
80
95
  guidance: "The dial's key set is exhaustive: `name` and `clause`, nothing else. A key outside it is a verb this schema does not have — most likely an attempt to spell deletion, which it cannot.",
96
+ cite: DIAL_CITE,
81
97
  }),
82
98
  ];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Emit — the compile from the six-noun face to the seam's JSON pipe.
2
+ * Emit — the compile from the authoring face to the seam's JSON pipe.
3
3
  * The SDK implements **no semantics**: emit
4
4
  * produces plain data — the declaration rows the engine reads and, per projected
5
5
  * member, its ordered typed fields and resolved prose body. The engine is the
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import type { Harness } from "./assembly.js";
12
12
  import type { EmbeddedMemberValue, Member } from "./kind.js";
13
+ import type { PermissionLists } from "./needs.js";
13
14
  import type { Declarations } from "./declarations.js";
14
15
  import type { PayloadMember } from "./generated/index.js";
15
16
  export type { PayloadMember } from "./generated/index.js";
@@ -96,7 +97,7 @@ export interface SettingsResidue {
96
97
  * double-verifies it.
97
98
  */
98
99
  export interface EmitResult {
99
- /** The declaration rows — the erased program the lock's seven families carry. */
100
+ /** The declaration rows — the erased program the lock's declaration families carry. */
100
101
  readonly declarations: Declarations;
101
102
  /** The projected members — the engine's sole input for every projection. */
102
103
  readonly members: readonly PayloadMember[];
@@ -106,23 +107,20 @@ export interface EmitResult {
106
107
  */
107
108
  readonly seam: string;
108
109
  /**
109
- * The derived permission list — the union of every member's `needs`, deduped and
110
- * sorted.
111
- * Folds into the settings artifact once hook/MCP members land; carried here as
112
- * data until then.
110
+ * The derived settings `permissions` lists — `allow` and `ask`, each the union of every
111
+ * member's `needs` on that list, deduped and sorted. Off the seam: no projection writes it.
113
112
  */
114
- readonly permissions: readonly string[];
113
+ readonly permissions: PermissionLists;
115
114
  /**
116
115
  * The fields-only registration members erased for the manifest write face — each
117
- * a name, its collection address, and its folded fields. Folds into the manifest
118
- * artifacts once the engine write face lands; carried here as data until then, the
119
- * way `permissions` is.
116
+ * a name, its collection address, and its folded fields — a view of the rows
117
+ * `declarations.registrations` carries to the engine's write face.
120
118
  */
121
119
  readonly registrations: readonly RegistrationFact[];
122
120
  /**
123
121
  * The harness-level settings residue erased for the manifest write face — each an opaque
124
122
  * settings.json key and its value. Folds into the settings.json manifest's residue at
125
- * emit, the way `registrations` builds its collection segments; carried here as data too.
123
+ * emit, the way `registrations` builds its collection segments.
126
124
  */
127
125
  readonly settings: readonly SettingsResidue[];
128
126
  }
@@ -137,10 +135,10 @@ export interface EmitResult {
137
135
  */
138
136
  export declare function loadedLocalModules(): string[];
139
137
  /**
140
- * Compile the whole face in one deterministic pass: the declaration rows (its
141
- * rollup and its seven families) and every projected member's erased payload.
138
+ * Compile the whole face in one deterministic pass: the declaration rows and
139
+ * every projected member's erased payload.
142
140
  * Prose resolves once (`file()` assets read in, mentions resolution-checked
143
141
  * against the harness's declared values). Double-emit verified — nondeterministic
144
142
  * authoring is a loud failure, never a silent churn.
145
143
  */
146
- export declare function emit(harness: Harness): EmitResult;
144
+ export declare function emit(program: Harness): EmitResult;
package/dist/src/emit.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Emit — the compile from the six-noun face to the seam's JSON pipe.
2
+ * Emit — the compile from the authoring face to the seam's JSON pipe.
3
3
  * The SDK implements **no semantics**: emit
4
4
  * produces plain data — the declaration rows the engine reads and, per projected
5
5
  * member, its ordered typed fields and resolved prose body. The engine is the
@@ -11,10 +11,12 @@
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { readFileSync, realpathSync } from "node:fs";
13
13
  import { sep } from "node:path";
14
+ import { edgeTargetNames, templatesOf } from "./kind.js";
14
15
  import { checkMentions, defersToGate, isTextSpan, renderText, resolveEmbeddedLeaves } from "./prose.js";
15
16
  import { permissionUnion } from "./needs.js";
16
- import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, settingsRows, uniqueMap, } from "./declarations.js";
17
- import { bareLookupKey, edgeLookupKey, hostAddress, isOneSegment, memberAddress, nestedAddress, } from "./member-address.js";
17
+ import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, projectedField, settingsRows, uniqueMap, withGuidanceRules, } from "./declarations.js";
18
+ import { withReference } from "./reference.js";
19
+ import { ROOT_HOSTED_KINDS, bareLookupKey, edgeLookupKey, isOneSegment, memberAddress, nestedAddress, } from "./member-address.js";
18
20
  /** The {@link MentionScope} a set of {@link ResolveOptions} names — its two sets, each defaulting to empty. */
19
21
  function scopeOf(options) {
20
22
  return {
@@ -66,8 +68,8 @@ function joinSlash(...parts) {
66
68
  * `name` spliced through `pattern`'s lone `*` — the one name-through-a-glob rule, and the
67
69
  * only one: every flat `at` glob and every host template's path pattern places through it.
68
70
  *
69
- * A leading `**\/` collapses to zero segments, because an any-depth prefix names where the
70
- * glob *matches*, never where a projection *lands*. What remains is placement: literal
71
+ * Each `**` collapses to zero segments, because an any-depth span names where the glob
72
+ * *matches*, never where a projection *lands*. What remains is placement: literal
71
73
  * segments verbatim, the name into the final segment's lone `*` (`**\/CLAUDE.md` → the
72
74
  * fixed `CLAUDE.md`, `**\/sub/*.json` → `sub/<name>.json`), and a `*`-free pattern wholly
73
75
  * fixed. `starredSegment` is the one admission on top: a `*\/<file>` glob whose `*` stars a
@@ -80,7 +82,10 @@ function joinSlash(...parts) {
80
82
  * stray literal `*` behind, or star a directory the member name does not identify.
81
83
  */
82
84
  function spliceName(kindName, pattern, name, starredSegment) {
83
- const placed = pattern.startsWith("**/") ? pattern.slice(3) : pattern;
85
+ const placed = pattern
86
+ .split("/")
87
+ .filter((segment) => segment !== "**")
88
+ .join("/");
84
89
  const stars = placed.split("*").length - 1;
85
90
  const starInLeaf = placed.lastIndexOf("*") > placed.lastIndexOf("/");
86
91
  const leadingSegment = starredSegment && stars === 1 && placed.startsWith("*/");
@@ -93,27 +98,68 @@ function spliceName(kindName, pattern, name, starredSegment) {
93
98
  return placed.replace("*", name);
94
99
  }
95
100
  /**
96
- * The placement a member of `facts` named `name` takes **inside the locus its pattern is
97
- * rooted at** — the half an `at` kind and a nested file child derive identically, since a
98
- * host template's path pattern stands to its host's unit exactly as an `at` kind's glob
99
- * stands to its `governs` root (`specs/model/representation.md`, "locus").
100
- *
101
- * A **directory** unit owns a directory and seats its entry file inside it, so the pattern
102
- * names that entry file and the member's own name is the directory: the leading segment
103
- * drops and `<name>/` takes its place, which is what makes `*\/SKILL.md` and a template's
104
- * `*\/PAGE.md` land the same shape. Every other shape places its name through the one
105
- * splice rule ({@link spliceName}), a starred-segment kind's `*\/<file>` included.
101
+ * The placement a member of `facts` named `name` takes **whole** inside the locus its
102
+ * pattern is rooted at — the engine's `placement_in_unit` (`src/drift.rs`). A directory
103
+ * unit's name is its directory, seated where the pattern stars it; every other shape
104
+ * places its name through the one splice rule ({@link spliceName}). The name is never
105
+ * cut: a placement its identity's `:`-joined prefix spells is its declared location.
106
106
  *
107
107
  * # Throws
108
108
  * Whatever {@link spliceName} throws when the pattern maps the name onto no one path.
109
109
  */
110
110
  function placementInUnit(facts, pattern, name) {
111
111
  if (facts.unitShape === "directory") {
112
+ if (pattern.startsWith("**/"))
113
+ return pattern.slice(3).replace("*", name);
112
114
  const slash = pattern.indexOf("/");
113
115
  return joinSlash(name, slash < 0 ? pattern : pattern.slice(slash + 1));
114
116
  }
115
117
  return spliceName(facts.name, pattern, name, facts.unitShape === "starred-segment");
116
118
  }
119
+ /**
120
+ * Whether `pattern` places `name` whole — the engine's `places_whole`. A `:` in a
121
+ * path-derived identity joins the directories its placement spans, so only a declared
122
+ * location places it; a `named-field` identity is opaque. Of several templates, a
123
+ * starless one places only the name its filename's stem spells; a lone one places any.
124
+ */
125
+ function placesWhole(facts, pattern, name, lone) {
126
+ if (name.includes(":") && facts.unitShape !== "named-field")
127
+ return false;
128
+ const under = pattern.startsWith("**/") ? pattern.slice(3) : pattern;
129
+ if (lone || under.includes("*"))
130
+ return true;
131
+ const file = under.slice(under.lastIndexOf("/") + 1);
132
+ const dot = file.lastIndexOf(".");
133
+ return (dot > 0 ? file.slice(0, dot) : file) === name;
134
+ }
135
+ /**
136
+ * The in-locus placement `member` takes through `patterns`: its declared location, else
137
+ * its name whole through the first pattern that places it ({@link placesWhole}).
138
+ *
139
+ * # Throws
140
+ * If the location is no plain relative path, or no pattern places the name whole and no
141
+ * location is declared.
142
+ */
143
+ function placementThrough(member, patterns) {
144
+ const context = `member \`${member.name}\` of kind \`${member.kind}\``;
145
+ const location = member.location;
146
+ if (location !== undefined) {
147
+ const plain = location.split("/").every((segment) => segment !== "" && segment !== "." && segment !== ".." && !segment.includes("\\"));
148
+ if (!plain) {
149
+ throw new Error(`${context}: location \`${location}\` is no plain relative path — non-empty \`/\`-joined ` +
150
+ `segments, none empty, \`.\` or \`..\`.`);
151
+ }
152
+ return location;
153
+ }
154
+ const lone = patterns.length < 2;
155
+ const pattern = patterns.find((candidate) => placesWhole(member.facts, candidate, member.name, lone));
156
+ if (pattern === undefined) {
157
+ throw new Error(`${context}: declares no location and no template places its name whole (templates ` +
158
+ `\`${patterns.join("`, `")}\`) — a \`:\`-prefixed identity's placement is declared as the ` +
159
+ `member's \`location\`, relative to its locus root (specs/model/representation.md, "member").`);
160
+ }
161
+ return placementInUnit(member.facts, pattern, member.name);
162
+ }
117
163
  /**
118
164
  * The unit `host`'s file children compose their paths under — a directory unit's own
119
165
  * directory, since a template's path pattern is relative to the parent's unit.
@@ -166,11 +212,11 @@ function nestedFilePath(member) {
166
212
  `\`${member.kind}\` — the path pattern is the host kind's declared fact, and there is ` +
167
213
  `none to compose against (specs/model/representation.md, "locus").`);
168
214
  }
169
- return joinSlash(hostUnit(host, context), placementInUnit(member.facts, template.path, member.name));
215
+ return joinSlash(hostUnit(host, context), placementThrough(member, [template.path]));
170
216
  }
171
217
  /**
172
218
  * The harness-relative locus `member` projects onto: a file member places its name inside
173
- * the locus its own `governs` glob is rooted at ({@link placementInUnit}); a nested file
219
+ * the locus its own `locus` glob is rooted at ({@link placementInUnit}); a nested file
174
220
  * child places it inside its host's unit instead, through that same rule and its host
175
221
  * kind's declared template pattern ({@link nestedFilePath}). The engine
176
222
  * derives the same locus from the same facts (`src/drift.rs`'s `member_projection_path`);
@@ -200,8 +246,8 @@ function projectionPath(member) {
200
246
  }
201
247
  if (facts.locus.kind === "nested-file")
202
248
  return nestedFilePath(member);
203
- const { root, glob } = facts.locus;
204
- return joinSlash(root, placementInUnit(facts, glob, member.name));
249
+ const { root } = facts.locus;
250
+ return joinSlash(root, placementThrough(member, templatesOf(facts.locus)));
205
251
  }
206
252
  /**
207
253
  * `to`'s path as read from the document at `from` — the shared leading segments drop
@@ -247,14 +293,14 @@ function edgeTargetFacts(host, value, leaves, options) {
247
293
  const address = leaves[edge.field];
248
294
  if (address === undefined || address === "")
249
295
  continue;
250
- const lookup = edgeLookupKey(address, edge.to);
296
+ const lookup = edgeLookupKey(address, edgeTargetNames(edge));
251
297
  const target = options.members?.get(lookup);
252
298
  const reference = `${context}: edge field \`${edge.field}\` names \`${address}\``;
253
299
  if (target === undefined) {
254
- // Judged on the address the author wrote, never `lookup`: the one-element-`to` lift
255
- // spells a bare name as a host address for the member table alone, and a bare name
256
- // names no discoverable member.
257
- if (defersToGate(address, deferrableKinds)) {
300
+ // Judged on `lookup`: a one-element `to` set makes a bare name and its `kind:name`
301
+ // spelling one address, so both defer alike; a bare name in a wider set stays bare,
302
+ // names no discoverable member, and refuses.
303
+ if (defersToGate(lookup, deferrableKinds)) {
258
304
  deferred.set(edge.field, reference);
259
305
  continue;
260
306
  }
@@ -325,7 +371,7 @@ function resolvedTargetFacts(host, target, reference) {
325
371
  };
326
372
  }
327
373
  if (target.length > 1) {
328
- const hosts = target.map((carrier) => `\`${hostAddress(carrier.host.kind, carrier.host.name)}\``).join(", ");
374
+ const hosts = target.map((carrier) => `\`${memberAddress(carrier.host)}\``).join(", ");
329
375
  throw new Error(`${reference}, a bare key ${target.length} hosts carry (${hosts}) — a nested member's address ` +
330
376
  `composes through its host, so spell the whole \`<host-address>/<kind>/<key>\` ` +
331
377
  `(specs/model/representation.md, "member").`);
@@ -531,14 +577,42 @@ function renderedExtents(harness, options) {
531
577
  * address, a discovery-locus one deferred; `context` naming the host) and the
532
578
  * display rule applied, each include slot left standing for the engine to splice.
533
579
  * Shared by a `text` body and a composed body's prose spans, so a narrative span
534
- * resolves the identical way a member-level `text` body does.
580
+ * resolves the identical way a member-level `text` body does. A path-form mention renders
581
+ * as its target's projection path read from `host`'s ({@link mentionPath}).
535
582
  *
536
583
  * # Throws
537
- * If a mention names no declared value and has no discovery locus.
584
+ * If a mention names no declared value and has no discovery locus, or a path-form
585
+ * mention's target projects no file ({@link mentionPath}).
538
586
  */
539
- function renderTextBody(prose, scope, context) {
540
- checkMentions(prose.mentions, scope, context);
541
- return renderText(prose);
587
+ function renderTextBody(host, prose, options, context) {
588
+ checkMentions(prose.mentions, scopeOf(options), context);
589
+ return renderText(prose, (target) => target.form === "path" ? mentionPath(host, target, options, context) : target.display);
590
+ }
591
+ /**
592
+ * A path-form mention's rendering: the target's projection path relative to the host's,
593
+ * by the same {@link relativeProjection} an edge target's `path` fact is derived by, so
594
+ * a hand-written link and a rendered one are never two spellings of one placement.
595
+ *
596
+ * Only a composed member that owns a file has a path: a deferred target is discovered on
597
+ * disk where emit derives no placement, an embedded value lands inside its host's body,
598
+ * and a registration writes into a shared document — each refuses by name, before any
599
+ * byte is written.
600
+ *
601
+ * # Throws
602
+ * If the target resolves to no composed member, or to one that projects no file.
603
+ */
604
+ function mentionPath(host, target, options, context) {
605
+ const reference = `${context}: path-form mention of \`${target.address}\``;
606
+ const member = options.members?.get(target.address);
607
+ if (member === undefined) {
608
+ throw new Error(`${reference} names no composed member — a path is derived off the target's placement, ` +
609
+ `and emit places only what the program composes (specs/model/authoring.md, "The SDK").`);
610
+ }
611
+ if (isNested(member) || !isProjected(member)) {
612
+ throw new Error(`${reference}, which projects no file — there is no path to render; mention it by name ` +
613
+ `(specs/model/representation.md, "locus").`);
614
+ }
615
+ return relativeProjection(projectionPath(host), projectionPath(member));
542
616
  }
543
617
  /**
544
618
  * Resolve a member's prose to its final body bytes: a `file()` asset is read in
@@ -566,14 +640,15 @@ function resolveBody(member, options) {
566
640
  `(looked at \`${assetPath}\`).`, { cause });
567
641
  }
568
642
  }
569
- const scope = scopeOf(options);
643
+ const context = `member \`${member.name}\``;
570
644
  if (prose.kind === "blocks") {
571
- const context = `member \`${member.name}\``;
572
645
  return (prose.values
573
- .map((value) => isTextSpan(value) ? renderTextBody(value, scope, context) : renderMemberBlock(member, value, options))
646
+ .map((value) => isTextSpan(value)
647
+ ? renderTextBody(member, value, options, context)
648
+ : renderMemberBlock(member, value, options))
574
649
  .join("\n\n") + "\n");
575
650
  }
576
- return renderTextBody(prose, scope, `member \`${member.name}\``);
651
+ return renderTextBody(member, prose, options, context);
577
652
  }
578
653
  /**
579
654
  * The one declare-side refusal emit runs before it produces a byte: a
@@ -677,10 +752,8 @@ function settingsResidue(harness) {
677
752
  * `<kind>:<name>` keying raised for a corpus that is perfectly well-formed. A registration
678
753
  * member's address is its *group key* — a `hook` registers on its event, and Claude Code
679
754
  * admits any number of matcher groups per event — so several legitimately share one address
680
- * and the table keeps the last composed (the pre-0.0.16 reading; an edge targeting that
681
- * shared address resolves ambiguously, the open fork `(hook-member-identity)` in
682
- * `.flume/plan/open-questions.md`). Refusing them broke `emit` on every harness with two
683
- * hooks on one event (0.0.16).
755
+ * and the table keeps the last composed; an edge targeting that shared address resolves
756
+ * ambiguously.
684
757
  */
685
758
  function memberTable(harness) {
686
759
  const table = uniqueMap([
@@ -696,9 +769,10 @@ function memberTable(harness) {
696
769
  return table;
697
770
  }
698
771
  /**
699
- * Every nested **file** child under the bare `<kind>:<name>` short form as well as its own
700
- * host-qualified address — the same second spelling {@link nestedTargets} gives an embedded
701
- * member, so the two nested grains resolve alike.
772
+ * Every nested **file** child and every root-hosted member ({@link ROOT_HOSTED_KINDS})
773
+ * under the bare `<kind>:<name>` short form as well as its own host-qualified address —
774
+ * the same second spelling {@link nestedTargets} gives an embedded member, so every nested
775
+ * grain resolves alike.
702
776
  *
703
777
  * A bare key names a nested member only while a single host carries it, so a name several
704
778
  * hosts spell enters under no bare key at all and an edge citing it refuses as an address
@@ -710,7 +784,7 @@ function memberTable(harness) {
710
784
  function bareFileChildTargets(harness) {
711
785
  const carriers = new Map();
712
786
  for (const member of harness.members) {
713
- if (member.host === undefined || isRegistration(member))
787
+ if ((member.host === undefined && !ROOT_HOSTED_KINDS.has(member.kind)) || isRegistration(member))
714
788
  continue;
715
789
  const key = bareLookupKey(member.kind, member.name);
716
790
  const carried = carriers.get(key);
@@ -795,9 +869,10 @@ function orderedMembers(harness, options) {
795
869
  // this column to find the host's host when it composes a child's path, so a
796
870
  // flattened spelling would strand every layer above the nearest one.
797
871
  host: member.host && memberAddress(member.host),
872
+ location: member.location,
798
873
  // The generated row carries a mutable field list; the member's is read-only,
799
874
  // so copy each pair into a fresh tuple — the same values, a shape the row accepts.
800
- fields: member.fields.map(([name, value]) => [name, value]),
875
+ fields: member.fields.map(([name, value]) => [name, projectedField(member, name, value)]),
801
876
  body: resolveBody(member, options),
802
877
  source_path: fileSourcePath(member),
803
878
  };
@@ -842,13 +917,14 @@ export function loadedLocalModules() {
842
917
  return paths;
843
918
  }
844
919
  /**
845
- * Compile the whole face in one deterministic pass: the declaration rows (its
846
- * rollup and its seven families) and every projected member's erased payload.
920
+ * Compile the whole face in one deterministic pass: the declaration rows and
921
+ * every projected member's erased payload.
847
922
  * Prose resolves once (`file()` assets read in, mentions resolution-checked
848
923
  * against the harness's declared values). Double-emit verified — nondeterministic
849
924
  * authoring is a loud failure, never a silent churn.
850
925
  */
851
- export function emit(harness) {
926
+ export function emit(program) {
927
+ const harness = withGuidanceRules(withReference(program));
852
928
  refuseBrokenSource(harness);
853
929
  const resolve = {
854
930
  mentionable: declaredAddresses(harness),
@@ -0,0 +1,16 @@
1
+ /**
2
+ * One template's **absence gate** on a [`KindFactRow`]: a document at `template` opens
3
+ * its channels only where none of `absent` — paths relative to a directory — sits in
4
+ * its own directory or any directory above it, up to the harness root.
5
+ */
6
+ export type AbsenceGateRow = {
7
+ /**
8
+ * The gated template, spelled exactly as one of the row's `locus_glob` entries.
9
+ */
10
+ template: string;
11
+ /**
12
+ * The documents whose presence at or above closes the gate (`CLAUDE.md`,
13
+ * `.claude/CLAUDE.md`).
14
+ */
15
+ absent: Array<string>;
16
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * What `temper guard` does with an edit on a playbook area: `point` allows it and sends
3
+ * the session to the area's rule, `refuse` denies it naming the rule.
4
+ */
5
+ export type AreaMode = "point" | "refuse";
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { AreaMode } from "./AreaMode.js";
2
+ /**
3
+ * One playbook area a guard attachment binds: the globs naming the area's files, the
4
+ * address of the rule holding its standing facts, and what `temper guard` does with an
5
+ * edit there.
6
+ */
7
+ export type AreaRow = {
8
+ /**
9
+ * The address of the area's rule — `rule:<name>`.
10
+ */
11
+ rule: string;
12
+ /**
13
+ * The area's globs, relative to the harness root.
14
+ */
15
+ paths: Array<string>;
16
+ /**
17
+ * Whether the guard points an edit on the area at its rule or refuses it.
18
+ */
19
+ mode: AreaMode;
20
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -10,13 +10,13 @@ export type AssemblyFactRow = {
10
10
  */
11
11
  fact: string;
12
12
  /**
13
- * The scalar value a `mode` fact carries (the root member's declared
14
- * enforcement mode).
13
+ * The scalar value a `mode` fact carries (the enforcement mode the root, a kind or
14
+ * a member declares).
15
15
  */
16
16
  value?: string;
17
17
  /**
18
- * An `edge` fact's source kind, or the kind a `contract` fact marks a declared
19
- * contract for — absent on a `contract` fact, which makes it the root's, the same
18
+ * An `edge` fact's source kind, or the kind a `contract` or `mode` fact binds —
19
+ * absent on a `contract` or `mode` fact, which makes it the root's, the same
20
20
  * kind-absent-means-root discriminator a top-level clause row uses.
21
21
  */
22
22
  from?: string;
@@ -28,4 +28,17 @@ export type AssemblyFactRow = {
28
28
  * An `edge` fact's target kinds — the non-empty set the field may resolve into.
29
29
  */
30
30
  to?: Array<string>;
31
+ /**
32
+ * An `edge` fact's **runtime-provided** names: the values the runtime itself answers
33
+ * at the far end with no member behind them (a settings `outputStyle` naming one of
34
+ * Claude Code's built-in styles). Such a value resolves to no member and dangles
35
+ * never. Absent when the runtime supplies none, the common case.
36
+ */
37
+ provided?: Array<string>;
38
+ /**
39
+ * The member address a `mode` fact overrides the enforcement mode for. A `mode`
40
+ * fact carrying neither this nor `from` is the root's; one carrying `from` alone is
41
+ * that kind's.
42
+ */
43
+ member?: string;
31
44
  };
@@ -1,14 +1,19 @@
1
1
  /**
2
- * A node-scope clause row's scalar bound — `min_len`'s `min`, `max_len`/`extent`'s
3
- * `max`, each endpoint optional so the row carries only what the predicate declared.
2
+ * A clause row's scalar bound — `min-len`'s `min`, `max-len`/`extent`/`listing`'s
3
+ * `max`, `listing`'s per-entry cap, each optional so the row carries only what the predicate declared.
4
4
  */
5
5
  export type BoundRow = {
6
6
  /**
7
- * The inclusive lower bound, when the predicate declares one (`min_len`).
7
+ * The inclusive lower bound, when the predicate declares one (`min-len`).
8
8
  */
9
9
  min?: number;
10
10
  /**
11
- * The inclusive upper bound, when the predicate declares one (`max_len`/`extent`).
11
+ * The inclusive upper bound, when the predicate declares one
12
+ * (`max-len`/`extent`/`listing`).
12
13
  */
13
14
  max?: number;
15
+ /**
16
+ * The per-entry character cap, when the predicate declares one (`listing`).
17
+ */
18
+ entry?: number;
14
19
  };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * One recorded **claim resolution** on a [`KindFactRow`]: the locus `pattern` the row's
3
+ * kind cedes and the kind it cedes `to`, whose claim holds every document there.
4
+ */
5
+ export type CedeRow = {
6
+ /**
7
+ * The kind holding the ceded documents — a subkind, or a directory-unit host.
8
+ */
9
+ to: string;
10
+ /**
11
+ * The ceded locus pattern ([`crate::kind::locus_pattern`] spelling, harness-relative).
12
+ */
13
+ pattern: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -1,7 +1,8 @@
1
1
  /**
2
- * An `allowed_chars` clause row's declared character class — the wire form of
2
+ * An `allowed-chars` clause row's declared character class — the wire form of
3
3
  * [`crate::contract::Charset`]: inclusive `"<lo>-<hi>"` range specs plus a literal
4
- * string of individually permitted characters.
4
+ * string of individually listed characters, an optional negation, and an optional
5
+ * governed position.
5
6
  */
6
7
  export type CharsetRow = {
7
8
  /**
@@ -9,7 +10,17 @@ export type CharsetRow = {
9
10
  */
10
11
  ranges?: Array<string>;
11
12
  /**
12
- * The individually permitted characters, when any are declared.
13
+ * The individually listed characters, when any are declared.
13
14
  */
14
15
  chars?: string;
16
+ /**
17
+ * Whether the class lists forbidden characters rather than permitted ones;
18
+ * absent is a permitted-characters class.
19
+ */
20
+ negated?: boolean;
21
+ /**
22
+ * The governed position — `leading` for the first character only; absent
23
+ * governs every character.
24
+ */
25
+ position?: string;
15
26
  };