@dtmd/temper 0.0.24 → 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 +116 -8
- package/dist/src/builtins.d.ts +436 -103
- package/dist/src/builtins.js +772 -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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The rule carrying {@link SDK_COUNSEL}, scoped over the program directory. */
|
|
2
|
+
export declare const COUNSEL_RULE_NAME = "temper-sdk";
|
|
3
|
+
/** The name prefix every synthesized guidance rule takes — `temper-guidance-<kind>`. */
|
|
4
|
+
export declare const GUIDANCE_RULE_PREFIX = "temper-guidance-";
|
|
5
|
+
/**
|
|
6
|
+
* The SDK's authoring counsel — what an agent writing a harness program is told the
|
|
7
|
+
* first time it touches one. `emit` projects it as a rule scoped to the program
|
|
8
|
+
* directory, so it re-projects on every SDK upgrade instead of going stale as a copy.
|
|
9
|
+
* Advisory: a check holds none of it. Kept within about 1k tokens.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SDK_COUNSEL = "# Authoring the temper program\n\nThis directory is the harness's source: a typed program over `@dtmd/temper`. The\nharness files it describes (`CLAUDE.md`, `.claude/**`, any governed document) are\nprojections of it.\n\n## The loop\n\n- Change the module or the prose file that owns a member, then run `temper emit`.\n Never edit a projection: a file carrying the `temper: managed projection` header is\n written by `emit`, and a direct edit is drift that `check` and `guard` report.\n- Run `temper check` after an emit; read its findings and their guidance before\n deciding a finding is noise. `temper explain <kind>` prints what a kind expects.\n- A refusal from `emit` or a type error from `tsc` names the broken input. Fix the\n source; never route around a refusal by loosening a type.\n\n## Members\n\n- Build members with the kind constructors (`rule`, `skill`, `memory`, `hook`,\n `agent`, ... from `@dtmd/temper/claude-code`, or your own `kind()`), and list every\n one in `harness({ members })`. A member the program does not list is not governed.\n- Keep long prose in a sibling Markdown file and reference it with\n `file(import.meta.url, \"./name.md\")`; use `text` for short inline prose, `span`\n only for a string the program computes. temper copies prose verbatim.\n- Cite another member as `text` with `${mentionOf(member)}` interpolated, not a\n hand-typed name or path: the mention resolves at emit and refuses when its target\n is gone.\n- A temper gate placement is `gateHook({ event, matcher })`, never `hook()` with a\n hand-written `temper` command: the engine renders the command, so it stays correct\n across installs and upgrades.\n\n## Requirements and contracts\n\n- A `require` entry names a role the harness must fill; members fill it through\n `satisfies`. Unset, `required` means at least one satisfier at error severity, so\n an empty slot fails `check`. A slot you declare ahead of its content, or one that\n is aspirational, says `required: false`.\n- Bind clauses to a kind with `expect`; start from the shipped default contract\n (`skillDefaultContract`, ...) and add to it rather than restating it.\n- A check enters only as a decidable clause. Behavior no predicate can decide belongs\n to a wired verifier or to your own review \u2014 never a clause that approximates it. A\n clause that can false-fire (`mentionReachable`'s glob containment) is advisory.\n\n## Kinds\n\n- Declare a custom kind's intent as `guidance` and its fields' as `fieldGuidance`,\n never only in a comment: emit delivers guidance as a rule scoped to the kind's\n documents, where the next author reads it.\n- To move or retune a built-in, `relocate` it; do not redeclare it under a new name.\n- A subkind is `extend<Base, Sub>(base, delta)` with `interface Sub extends Base`:\n `tsc` refuses a surface that drops or retypes a base field. A field interface,\n clause set, or guidance several subkinds share is an ordinary TypeScript value \u2014\n extend the interface, and spread the value into each `extend` delta.\n- Narrow a kind's members with a clause, never a richer locus glob. A `render` hook\n treats every `value.targets` entry as possibly absent.\n- The rule names `temper-sdk` and `temper-guidance-<kind>` are temper's own; an\n authored rule at either refuses.\n";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** The rule carrying {@link SDK_COUNSEL}, scoped over the program directory. */
|
|
2
|
+
export const COUNSEL_RULE_NAME = "temper-sdk";
|
|
3
|
+
/** The name prefix every synthesized guidance rule takes — `temper-guidance-<kind>`. */
|
|
4
|
+
export const GUIDANCE_RULE_PREFIX = "temper-guidance-";
|
|
5
|
+
/**
|
|
6
|
+
* The SDK's authoring counsel — what an agent writing a harness program is told the
|
|
7
|
+
* first time it touches one. `emit` projects it as a rule scoped to the program
|
|
8
|
+
* directory, so it re-projects on every SDK upgrade instead of going stale as a copy.
|
|
9
|
+
* Advisory: a check holds none of it. Kept within about 1k tokens.
|
|
10
|
+
*/
|
|
11
|
+
export const SDK_COUNSEL = `# Authoring the temper program
|
|
12
|
+
|
|
13
|
+
This directory is the harness's source: a typed program over \`@dtmd/temper\`. The
|
|
14
|
+
harness files it describes (\`CLAUDE.md\`, \`.claude/**\`, any governed document) are
|
|
15
|
+
projections of it.
|
|
16
|
+
|
|
17
|
+
## The loop
|
|
18
|
+
|
|
19
|
+
- Change the module or the prose file that owns a member, then run \`temper emit\`.
|
|
20
|
+
Never edit a projection: a file carrying the \`temper: managed projection\` header is
|
|
21
|
+
written by \`emit\`, and a direct edit is drift that \`check\` and \`guard\` report.
|
|
22
|
+
- Run \`temper check\` after an emit; read its findings and their guidance before
|
|
23
|
+
deciding a finding is noise. \`temper explain <kind>\` prints what a kind expects.
|
|
24
|
+
- A refusal from \`emit\` or a type error from \`tsc\` names the broken input. Fix the
|
|
25
|
+
source; never route around a refusal by loosening a type.
|
|
26
|
+
|
|
27
|
+
## Members
|
|
28
|
+
|
|
29
|
+
- Build members with the kind constructors (\`rule\`, \`skill\`, \`memory\`, \`hook\`,
|
|
30
|
+
\`agent\`, ... from \`@dtmd/temper/claude-code\`, or your own \`kind()\`), and list every
|
|
31
|
+
one in \`harness({ members })\`. A member the program does not list is not governed.
|
|
32
|
+
- Keep long prose in a sibling Markdown file and reference it with
|
|
33
|
+
\`file(import.meta.url, "./name.md")\`; use \`text\` for short inline prose, \`span\`
|
|
34
|
+
only for a string the program computes. temper copies prose verbatim.
|
|
35
|
+
- Cite another member as \`text\` with \`\${mentionOf(member)}\` interpolated, not a
|
|
36
|
+
hand-typed name or path: the mention resolves at emit and refuses when its target
|
|
37
|
+
is gone.
|
|
38
|
+
- A temper gate placement is \`gateHook({ event, matcher })\`, never \`hook()\` with a
|
|
39
|
+
hand-written \`temper\` command: the engine renders the command, so it stays correct
|
|
40
|
+
across installs and upgrades.
|
|
41
|
+
|
|
42
|
+
## Requirements and contracts
|
|
43
|
+
|
|
44
|
+
- A \`require\` entry names a role the harness must fill; members fill it through
|
|
45
|
+
\`satisfies\`. Unset, \`required\` means at least one satisfier at error severity, so
|
|
46
|
+
an empty slot fails \`check\`. A slot you declare ahead of its content, or one that
|
|
47
|
+
is aspirational, says \`required: false\`.
|
|
48
|
+
- Bind clauses to a kind with \`expect\`; start from the shipped default contract
|
|
49
|
+
(\`skillDefaultContract\`, ...) and add to it rather than restating it.
|
|
50
|
+
- A check enters only as a decidable clause. Behavior no predicate can decide belongs
|
|
51
|
+
to a wired verifier or to your own review — never a clause that approximates it. A
|
|
52
|
+
clause that can false-fire (\`mentionReachable\`'s glob containment) is advisory.
|
|
53
|
+
|
|
54
|
+
## Kinds
|
|
55
|
+
|
|
56
|
+
- Declare a custom kind's intent as \`guidance\` and its fields' as \`fieldGuidance\`,
|
|
57
|
+
never only in a comment: emit delivers guidance as a rule scoped to the kind's
|
|
58
|
+
documents, where the next author reads it.
|
|
59
|
+
- To move or retune a built-in, \`relocate\` it; do not redeclare it under a new name.
|
|
60
|
+
- A subkind is \`extend<Base, Sub>(base, delta)\` with \`interface Sub extends Base\`:
|
|
61
|
+
\`tsc\` refuses a surface that drops or retypes a base field. A field interface,
|
|
62
|
+
clause set, or guidance several subkinds share is an ordinary TypeScript value —
|
|
63
|
+
extend the interface, and spread the value into each \`extend\` delta.
|
|
64
|
+
- Narrow a kind's members with a clause, never a richer locus glob. A \`render\` hook
|
|
65
|
+
treats every \`value.targets\` entry as possibly absent.
|
|
66
|
+
- The rule names \`${COUNSEL_RULE_NAME}\` and \`${GUIDANCE_RULE_PREFIX}<kind>\` are temper's own; an
|
|
67
|
+
authored rule at either refuses.
|
|
68
|
+
`;
|
|
@@ -9,8 +9,25 @@
|
|
|
9
9
|
* in lockstep.
|
|
10
10
|
*/
|
|
11
11
|
import type { Harness } from "./assembly.js";
|
|
12
|
+
import type { KindFacts, Member } from "./kind.js";
|
|
13
|
+
import type { Predicate, Verifier } from "./contract.js";
|
|
12
14
|
import type { Declarations, Payload, RegistrationRow, SettingsRow } from "./generated/index.js";
|
|
13
15
|
export type { AssemblyFactRow, ClauseRow, Declarations, KindFactRow, RequirementRow, SatisfiesRow, } from "./generated/index.js";
|
|
16
|
+
/**
|
|
17
|
+
* The `field` column for one predicate: the field it names, or — for the four
|
|
18
|
+
* predicates that name a *section*, a field *set*, or a *requirement* rather than a
|
|
19
|
+
* field — an identity synthesized from the arguments the row already carries.
|
|
20
|
+
*
|
|
21
|
+
* `section-contains`, `require-sections`, `degree` and `reached-from` set no `field`,
|
|
22
|
+
* and the column is what emit stamps a clause's label from (`stamp_clause_label`,
|
|
23
|
+
* `src/drift.rs`), so reading `Predicate.field` folds every clause of one of those
|
|
24
|
+
* predicates on one kind into one label — two rows wearing one label, which
|
|
25
|
+
* admissibility refuses as a malformed lock. Synthesizing here keeps the whole fix at
|
|
26
|
+
* the lowering: the Rust reader reconstructs all four predicates from the
|
|
27
|
+
* `section`/`sections`/`fields`/`target` columns and never from this one, so nothing
|
|
28
|
+
* round-trips through the synthesized text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function clauseField(predicate: Predicate): string | undefined;
|
|
14
31
|
/** The stable-sort ordering every declaration row family shares. */
|
|
15
32
|
export declare function compareStrings(a: string, b: string): number;
|
|
16
33
|
/**
|
|
@@ -22,6 +39,87 @@ export declare function compareStrings(a: string, b: string): number;
|
|
|
22
39
|
* colliding key.
|
|
23
40
|
*/
|
|
24
41
|
export declare function uniqueMap<K, V>(entries: Iterable<[K, V]>): Map<K, V>;
|
|
42
|
+
/**
|
|
43
|
+
* Every kind in play, at any locus — member kinds ∪ expect kinds ∪ their embedded
|
|
44
|
+
* children — name-sorted, so every family derived from it inherits one stable order.
|
|
45
|
+
*
|
|
46
|
+
* The embedded children close transitively over both channels a host names one through:
|
|
47
|
+
* `admit` (the adopting corpus's declaration) and a path-less `templates` entry (the
|
|
48
|
+
* embedded layer). An embedded kind reaches the lock through its host's `templates`
|
|
49
|
+
* column rather than a row of its own, so those channels are the only way one is in play
|
|
50
|
+
* at all — and its declared edge fields are still owed their assembly facts.
|
|
51
|
+
*
|
|
52
|
+
* Beside them, a template's **subkind** child is drawn in: an extended host names it in its
|
|
53
|
+
* base's place, so the host's own row is what puts it in play. Any other path-carrying
|
|
54
|
+
* template is the nested-file layer, whose child owns a unit and reaches the lock through
|
|
55
|
+
* `expect` like any other unit kind; pulling one in here would forge it a kind-fact row
|
|
56
|
+
* it never declared.
|
|
57
|
+
*
|
|
58
|
+
* A synthesized tap hook ({@link tapHookRows}) puts the `hook` kind in play as an authored
|
|
59
|
+
* hook member would: its row lands in `registrations` under `hook`, so the kind is owed
|
|
60
|
+
* the fact row the engine resolves that row's kind against.
|
|
61
|
+
*
|
|
62
|
+
* Two facts values arriving under one name are decided by {@link resolveNameCollision},
|
|
63
|
+
* never by arrival order: the deduped facts are what `assemblyFactRows` derives every
|
|
64
|
+
* `edge` row from, so first-wins would drop a relocation's added edge on the floor
|
|
65
|
+
* whenever the base happened to be named first.
|
|
66
|
+
*/
|
|
67
|
+
export declare function kindsInPlay(harness: Harness): KindFacts[];
|
|
68
|
+
/** The kind names an edge field's `to` set lists, for a line that states where it points. */
|
|
69
|
+
export declare function targetList(to: readonly string[]): string;
|
|
70
|
+
/**
|
|
71
|
+
* One declared edge and its intent — the counsel its source kind gives the edge field,
|
|
72
|
+
* absent when the source declares none. `shipped` marks a source kind temper ships, whose
|
|
73
|
+
* counsel a guidance rule never projects.
|
|
74
|
+
*/
|
|
75
|
+
export interface EdgeIntent {
|
|
76
|
+
readonly from: string;
|
|
77
|
+
readonly field: string;
|
|
78
|
+
readonly to: readonly string[];
|
|
79
|
+
readonly intent: string | undefined;
|
|
80
|
+
readonly shipped: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The edges at a kind's two ends, with their intent: `outbound` its own edge fields in
|
|
84
|
+
* declared order, `inbound` every kind-in-play's edge field whose `to` set names it, in
|
|
85
|
+
* `kinds` order. The one assembly of edge intent the guidance rules and the reference's
|
|
86
|
+
* kind topics both state, so a relationship's intent reads the same at every surface.
|
|
87
|
+
*/
|
|
88
|
+
export declare function kindEdges(facts: KindFacts, kinds: readonly KindFacts[]): {
|
|
89
|
+
readonly outbound: readonly EdgeIntent[];
|
|
90
|
+
readonly inbound: readonly EdgeIntent[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The repository-relative file globs a kind's members occupy over `harness` — what a
|
|
94
|
+
* guidance rule's `paths` lists and a kind topic names as its locus.
|
|
95
|
+
*/
|
|
96
|
+
export declare function kindLocusGlobs(facts: KindFacts, harness: Harness): string[];
|
|
97
|
+
/**
|
|
98
|
+
* A requirement as the guidance rules and the reference state it: its kind (when
|
|
99
|
+
* declared), its prose, what holds its behavior (absent when unheld), its satisfiers.
|
|
100
|
+
*/
|
|
101
|
+
export interface ContractedRequirement {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly kind: string | undefined;
|
|
104
|
+
readonly prose: string;
|
|
105
|
+
readonly verifier: Verifier | undefined;
|
|
106
|
+
readonly satisfiers: readonly {
|
|
107
|
+
readonly kind: string;
|
|
108
|
+
readonly address: string;
|
|
109
|
+
}[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Every declared requirement — assembly `require` ∪ each member's `requires`, the
|
|
113
|
+
* namespace {@link requirementRows} lowers — with the members claiming to fill it, name
|
|
114
|
+
* sorted, satisfiers in address order.
|
|
115
|
+
*/
|
|
116
|
+
export declare function contractedRequirements(harness: Harness): ContractedRequirement[];
|
|
117
|
+
/**
|
|
118
|
+
* `harness` with its {@link guidanceRules} joined into the member roster — the one view
|
|
119
|
+
* every compiled face reads, so the declaration rows and the projected members agree on
|
|
120
|
+
* what was synthesized. Idempotent: a harness already carrying them comes back as is.
|
|
121
|
+
*/
|
|
122
|
+
export declare function withGuidanceRules(harness: Harness): Harness;
|
|
25
123
|
/**
|
|
26
124
|
* Each composed embedded value's placed edge fields, by {@link nestedAddress} — the very
|
|
27
125
|
* address the `nested_member` row each entry feeds is identified by — `emit`'s record of
|
|
@@ -46,6 +144,14 @@ export interface RenderedExtent {
|
|
|
46
144
|
* unmeasured member's `extent` stays undecidable, never a zero read as a pass.
|
|
47
145
|
*/
|
|
48
146
|
export type RenderedExtents = ReadonlyMap<string, RenderedExtent>;
|
|
147
|
+
/**
|
|
148
|
+
* A member's field as its artifact carries it: a hook's handlers and a settings member's
|
|
149
|
+
* `statusLine` each lose the {@link RUNS_FIELD} edge, which is temper's and rides the lock
|
|
150
|
+
* as a `runs` row ({@link runsRows}), never a key in `settings.json`. Every other field is
|
|
151
|
+
* as authored. The one projection of a runner's fields, read by the registration rows here
|
|
152
|
+
* and by the payload members `emit.ts` hands the engine.
|
|
153
|
+
*/
|
|
154
|
+
export declare function projectedField(member: Member, name: string, value: unknown): unknown;
|
|
49
155
|
/**
|
|
50
156
|
* Builds a collision-safe dedup key for a tap hook (event, matcher) pair.
|
|
51
157
|
* Two distinct pairs cannot produce the same key (e.g., ("Foo", "BarBaz") ≠ ("FooBar", "Baz")).
|
|
@@ -102,7 +208,7 @@ export declare function declaredAddresses(harness: Harness): Set<string>;
|
|
|
102
208
|
*/
|
|
103
209
|
export declare function declaredAtLocusKinds(harness: Harness): Set<string>;
|
|
104
210
|
/**
|
|
105
|
-
* Compile a harness into its
|
|
211
|
+
* Compile a harness into its declaration families — the erased program.
|
|
106
212
|
*
|
|
107
213
|
* `placements` and `extents` are `emit`'s record of what each embedded value's format
|
|
108
214
|
* rendered (`emit.ts`'s `edgePlacements`) and the span it spanned (`renderedExtents`); this
|
|
@@ -111,7 +217,7 @@ export declare function declaredAtLocusKinds(harness: Harness): Set<string>;
|
|
|
111
217
|
* columns — honest (nothing observed a render) but undecidable for a `format-places-edges`
|
|
112
218
|
* or `extent` clause, so a whole compile goes through `emit`, never this alone.
|
|
113
219
|
*/
|
|
114
|
-
export declare function compileDeclarations(
|
|
220
|
+
export declare function compileDeclarations(program: Harness, placements?: EdgePlacements, extents?: RenderedExtents, modules?: readonly string[]): Declarations;
|
|
115
221
|
/**
|
|
116
222
|
* Serialize the seam payload to the internal versioned JSON pipe — `encodeSeam`
|
|
117
223
|
* stamps `version`, so the caller supplies the rest of the {@link Payload}.
|