@dtmd/temper 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/assembly.js +1 -1
- package/dist/src/builtins.d.ts +105 -33
- package/dist/src/builtins.js +136 -39
- package/dist/src/claude-code.d.ts +2 -3
- package/dist/src/claude-code.js +1 -8
- package/dist/src/contract.d.ts +8 -1
- package/dist/src/contract.js +3 -1
- package/dist/src/declarations.d.ts +1 -1
- package/dist/src/declarations.js +38 -12
- package/dist/src/emit.d.ts +10 -0
- package/dist/src/emit.js +43 -2
- package/dist/src/generated/CollectionAddressRow.d.ts +11 -10
- package/dist/src/generated/Declarations.d.ts +8 -0
- package/dist/src/generated/KindFactRow.d.ts +7 -0
- package/dist/src/generated/RequirementRow.d.ts +3 -1
- package/dist/src/generated/index.d.ts +1 -1
- package/dist/src/generated/index.js +1 -1
- package/dist/src/generated/tap-hooks.d.ts +18 -0
- package/dist/src/generated/tap-hooks.js +7 -0
- package/dist/src/kind.d.ts +57 -32
- package/dist/src/kind.js +30 -3
- package/package.json +3 -3
- package/dist/src/generated/gate-commands.d.ts +0 -2
- package/dist/src/generated/gate-commands.js +0 -3
package/dist/src/contract.d.ts
CHANGED
|
@@ -387,7 +387,9 @@ export declare const script: (path: string) => Verifier;
|
|
|
387
387
|
* A telemetry verifier — the named documented harness events the emitted tap records
|
|
388
388
|
* to a local-locus log, judged by reading the field record. Each name must be a
|
|
389
389
|
* documented harness lifecycle event — the gate checks each resolves, never records
|
|
390
|
-
* into it.
|
|
390
|
+
* into it. The vocabulary is the engine's own `TAP_HOOK_BINDINGS` table
|
|
391
|
+
* (`src/builtin_kind.rs`), machine-written across the `generated/` seam and read by
|
|
392
|
+
* `builtins.ts`'s `TELEMETRY_EVENT_HOOKS`.
|
|
391
393
|
*/
|
|
392
394
|
export declare const telemetry: (events: readonly string[]) => Verifier;
|
|
393
395
|
/**
|
|
@@ -405,6 +407,11 @@ export declare const telemetry: (events: readonly string[]) => Verifier;
|
|
|
405
407
|
export interface Requirement {
|
|
406
408
|
readonly prose: string;
|
|
407
409
|
readonly kind?: string | KindDefinition<any>;
|
|
410
|
+
/**
|
|
411
|
+
* Whether the requirement must be filled. Unset inherits the corpus's shipped
|
|
412
|
+
* default — at least one satisfier, at error severity — so an unfilled
|
|
413
|
+
* requirement fails `check`; `false` is the advisory override.
|
|
414
|
+
*/
|
|
408
415
|
readonly required?: boolean;
|
|
409
416
|
readonly clauses?: readonly Clause[];
|
|
410
417
|
readonly verifier?: Verifier;
|
package/dist/src/contract.js
CHANGED
|
@@ -315,7 +315,9 @@ export const script = (path) => ({ species: "script", path });
|
|
|
315
315
|
* A telemetry verifier — the named documented harness events the emitted tap records
|
|
316
316
|
* to a local-locus log, judged by reading the field record. Each name must be a
|
|
317
317
|
* documented harness lifecycle event — the gate checks each resolves, never records
|
|
318
|
-
* into it.
|
|
318
|
+
* into it. The vocabulary is the engine's own `TAP_HOOK_BINDINGS` table
|
|
319
|
+
* (`src/builtin_kind.rs`), machine-written across the `generated/` seam and read by
|
|
320
|
+
* `builtins.ts`'s `TELEMETRY_EVENT_HOOKS`.
|
|
319
321
|
*/
|
|
320
322
|
export const telemetry = (events) => ({ species: "telemetry", events });
|
|
321
323
|
/** An identity helper — types a requirement literal at the keystroke. */
|
|
@@ -111,7 +111,7 @@ export declare function declaredAtLocusKinds(harness: Harness): Set<string>;
|
|
|
111
111
|
* columns — honest (nothing observed a render) but undecidable for a `format-places-edges`
|
|
112
112
|
* or `extent` clause, so a whole compile goes through `emit`, never this alone.
|
|
113
113
|
*/
|
|
114
|
-
export declare function compileDeclarations(harness: Harness, placements?: EdgePlacements, extents?: RenderedExtents): Declarations;
|
|
114
|
+
export declare function compileDeclarations(harness: Harness, placements?: EdgePlacements, extents?: RenderedExtents, modules?: readonly string[]): Declarations;
|
|
115
115
|
/**
|
|
116
116
|
* Serialize the seam payload to the internal versioned JSON pipe — `encodeSeam`
|
|
117
117
|
* stamps `version`, so the caller supplies the rest of the {@link Payload}.
|
package/dist/src/declarations.js
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
|
+
import { manifestOf } from "./kind.js";
|
|
13
14
|
import { isTextSpan, resolveEmbeddedLeaves } from "./prose.js";
|
|
14
|
-
import { HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
|
|
15
|
+
import { GATE_BINARY_KEY, HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, gateHookBinary, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
|
|
15
16
|
import { leafAddress, memberAddress, nestedAddress } from "./member-address.js";
|
|
16
17
|
/**
|
|
17
18
|
* Compile one `Clause` into its lock row: the shared `key`/`field`/`severity`/
|
|
@@ -291,7 +292,6 @@ function collectionAddressRow(facts) {
|
|
|
291
292
|
if (facts.collectionAddress === undefined)
|
|
292
293
|
return undefined;
|
|
293
294
|
return {
|
|
294
|
-
manifest: facts.collectionAddress.manifest,
|
|
295
295
|
key_path: facts.collectionAddress.keyPath,
|
|
296
296
|
entry_shape: facts.collectionAddress.entryShape,
|
|
297
297
|
};
|
|
@@ -310,8 +310,8 @@ function leafSetRow(leaves) {
|
|
|
310
310
|
* One kind's fact row — an `at` locus supplies `governs_root`/`governs_glob` and any
|
|
311
311
|
* other locus neither (a nested-file kind's path composes from its host's unit and the
|
|
312
312
|
* host template's pattern; an embedded kind owns no unit at all — both govern no glob).
|
|
313
|
-
* A file locus's `commitment` class
|
|
314
|
-
* default. `templates` names the embedded kinds the corpus admits over it, and `content`
|
|
313
|
+
* A file locus's `commitment` class and `exclude` paths ride the same spelling, absent for
|
|
314
|
+
* the committed, nothing-excluded default. `templates` names the embedded kinds the corpus admits over it, and `content`
|
|
315
315
|
* lowers a declared layout (absent for a `file`-content kind). A registration kind
|
|
316
316
|
* extends the row with its `shape` marker and `collection_address`. A declared leaf-set
|
|
317
317
|
* witness lowers to `leaves` ([`leafSetRow`]), absent for a kind declaring none. Advisory
|
|
@@ -328,9 +328,12 @@ function kindFactRow(facts, admissions) {
|
|
|
328
328
|
governs_root: governs?.root,
|
|
329
329
|
governs_glob: governs?.glob,
|
|
330
330
|
commitment: governs?.commitment,
|
|
331
|
+
// Spread rather than an `undefined` column: a row excluding nothing carries no key.
|
|
332
|
+
...(governs?.exclude?.length ? { exclude: [...governs.exclude] } : {}),
|
|
331
333
|
format: facts.format,
|
|
332
334
|
unit_shape: unitShapeLabel(facts),
|
|
333
|
-
|
|
335
|
+
// An embedded or nested-file kind declares no set — its locus already states it empty.
|
|
336
|
+
registration: registrationLabels(facts.registration ?? []),
|
|
334
337
|
templates: templatesFor(facts, admissions),
|
|
335
338
|
content: contentRow(facts.content),
|
|
336
339
|
shape: facts.shape,
|
|
@@ -492,7 +495,11 @@ function kindFactKindsInPlay(allKinds) {
|
|
|
492
495
|
facts.cite !== undefined ||
|
|
493
496
|
facts.leaves !== undefined);
|
|
494
497
|
}
|
|
495
|
-
/**
|
|
498
|
+
/**
|
|
499
|
+
* The requirement rows — assembly `require` and every member's `requires`, one namespace.
|
|
500
|
+
* An unset `required` lowers the corpus's shipped default — "this must be filled": at
|
|
501
|
+
* least one satisfier, at error — so only an explicit `required: false` is advisory.
|
|
502
|
+
*/
|
|
496
503
|
function requirementRows(harness) {
|
|
497
504
|
const entries = [];
|
|
498
505
|
for (const [name, requirement] of Object.entries(harness.require)) {
|
|
@@ -509,7 +516,7 @@ function requirementRows(harness) {
|
|
|
509
516
|
.map(([name, requirement]) => ({
|
|
510
517
|
name,
|
|
511
518
|
kind: typeof requirement.kind === "string" ? requirement.kind : requirement.kind?.key,
|
|
512
|
-
required: requirement.required ??
|
|
519
|
+
required: requirement.required ?? true,
|
|
513
520
|
clauses: (requirement.clauses ?? []).map((clause) => clauseRow(clause)),
|
|
514
521
|
verifier: verifierRow(requirement.verifier),
|
|
515
522
|
prose: requirement.prose,
|
|
@@ -707,6 +714,13 @@ function inputRows(harness) {
|
|
|
707
714
|
}
|
|
708
715
|
return rows;
|
|
709
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* The `module` rows — the program's loaded local modules, deduplicated and sorted so the
|
|
719
|
+
* row order is the set's, never the load order a refactor of import statements reshuffles.
|
|
720
|
+
*/
|
|
721
|
+
function moduleRows(modules) {
|
|
722
|
+
return [...new Set(modules)].sort(compareStrings);
|
|
723
|
+
}
|
|
710
724
|
/**
|
|
711
725
|
* One host member's declared embedded-member value as its declaration row
|
|
712
726
|
* ([`NestedMemberRow`]) — its leaves through the shared walk
|
|
@@ -802,8 +816,8 @@ function nestedMemberRows(harness, admissions, scope, placements, extents) {
|
|
|
802
816
|
/**
|
|
803
817
|
* The `registration` rows — every fields-only registration member (a hook, an MCP server)
|
|
804
818
|
* erased for the manifest write face, kind-then-key sorted so double emit is byte-stable.
|
|
805
|
-
* Each carries its **collection key** (`kind`/`key`), its
|
|
806
|
-
* (
|
|
819
|
+
* Each carries its **collection key** (`kind`/`key`), its manifest (the kind's locus,
|
|
820
|
+
* {@link manifestOf}) and key path (the wire's snake_case `key_path`), and its folded typed fields —
|
|
807
821
|
* the entry value the engine's write face places under `key`. The authored half alone:
|
|
808
822
|
* the synthesized tap hooks join these rows in {@link mergedRegistrationRows}, which is
|
|
809
823
|
* what both readers of the family take.
|
|
@@ -829,15 +843,26 @@ function registrationRows(harness) {
|
|
|
829
843
|
return {
|
|
830
844
|
kind: member.kind,
|
|
831
845
|
key: member.kind === hook.key ? hookCollectionKey(member.name) : member.name,
|
|
832
|
-
manifest:
|
|
846
|
+
manifest: manifestOf(member.facts),
|
|
833
847
|
key_path: address.keyPath,
|
|
834
848
|
// The generated row carries a mutable field list; the member's is read-only, so
|
|
835
849
|
// copy each pair into a fresh tuple — the same values, a shape the row accepts.
|
|
836
|
-
fields:
|
|
850
|
+
fields: [
|
|
851
|
+
...member.fields.map(([name, value]) => [name, value]),
|
|
852
|
+
// A gate hook carries its declared binary across the seam beside its fields; the
|
|
853
|
+
// engine renders the handler's command from it and drops the key ({@link gateHook}).
|
|
854
|
+
...gateBinaryField(member),
|
|
855
|
+
],
|
|
837
856
|
};
|
|
838
857
|
})
|
|
839
858
|
.sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.key, b.key));
|
|
840
859
|
}
|
|
860
|
+
/** The gate hook row's binary field — `[GATE_BINARY_KEY, binary]` for a {@link gateHook}
|
|
861
|
+
* member, `null` declaring none, and nothing for every other member. */
|
|
862
|
+
function gateBinaryField(member) {
|
|
863
|
+
const binary = gateHookBinary(member);
|
|
864
|
+
return binary === undefined ? [] : [[GATE_BINARY_KEY, binary]];
|
|
865
|
+
}
|
|
841
866
|
/** The tap invocation the synthesized telemetry hooks run — the sibling verb of the
|
|
842
867
|
* session-start reporter, appending one event record to the per-machine log
|
|
843
868
|
* (`src/tap.rs`). Every synthesized hook's `command` field carries it verbatim. */
|
|
@@ -1036,7 +1061,7 @@ function mentionScope(harness) {
|
|
|
1036
1061
|
* columns — honest (nothing observed a render) but undecidable for a `format-places-edges`
|
|
1037
1062
|
* or `extent` clause, so a whole compile goes through `emit`, never this alone.
|
|
1038
1063
|
*/
|
|
1039
|
-
export function compileDeclarations(harness, placements, extents) {
|
|
1064
|
+
export function compileDeclarations(harness, placements, extents, modules = []) {
|
|
1040
1065
|
const allKinds = kindsInPlay(harness);
|
|
1041
1066
|
const admissions = admissionsByHost(harness);
|
|
1042
1067
|
const clauses = [];
|
|
@@ -1063,6 +1088,7 @@ export function compileDeclarations(harness, placements, extents) {
|
|
|
1063
1088
|
mentions: mentionRows(harness),
|
|
1064
1089
|
includes: includeRows(harness),
|
|
1065
1090
|
inputs: inputRows(harness),
|
|
1091
|
+
modules: moduleRows(modules),
|
|
1066
1092
|
nested_members: nestedMemberRows(harness, admissions, mentionScope(harness), placements, extents),
|
|
1067
1093
|
registrations: mergedRegistrationRows(harness),
|
|
1068
1094
|
settings: settingsRows(harness),
|
package/dist/src/emit.d.ts
CHANGED
|
@@ -126,6 +126,16 @@ export interface EmitResult {
|
|
|
126
126
|
*/
|
|
127
127
|
readonly settings: readonly SettingsResidue[];
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* The real paths of every local module this run loaded, as the engine's preload recorded
|
|
131
|
+
* them — empty when no preload ran (the SDK driven outside `temper emit`). The judge is the
|
|
132
|
+
* real path, not the URL a specifier resolved through: a workspace package reached via a
|
|
133
|
+
* `node_modules` symlink is the author's own source and stays fingerprinted, while an
|
|
134
|
+
* installed package, whose real path sits under `node_modules`, is its lockfile's to pin.
|
|
135
|
+
* The engine then keeps only the modules the repository tracks: a path its ignore rules
|
|
136
|
+
* exclude (a linked package's build output) gets no row.
|
|
137
|
+
*/
|
|
138
|
+
export declare function loadedLocalModules(): string[];
|
|
129
139
|
/**
|
|
130
140
|
* Compile the whole face in one deterministic pass: the declaration rows (its
|
|
131
141
|
* rollup and its seven families) and every projected member's erased payload.
|
package/dist/src/emit.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* run.
|
|
10
10
|
*/
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { readFileSync } from "node:fs";
|
|
12
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
13
|
+
import { sep } from "node:path";
|
|
13
14
|
import { checkMentions, defersToGate, isTextSpan, renderText, resolveEmbeddedLeaves } from "./prose.js";
|
|
14
15
|
import { permissionUnion } from "./needs.js";
|
|
15
16
|
import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, settingsRows, uniqueMap, } from "./declarations.js";
|
|
@@ -802,6 +803,44 @@ function orderedMembers(harness, options) {
|
|
|
802
803
|
};
|
|
803
804
|
});
|
|
804
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* The `globalThis` key the engine's `node --import` preload publishes the run's loaded
|
|
808
|
+
* `file:` URLs under (`src/drift.rs`, `LOADED_MODULES_KEY`). Change both.
|
|
809
|
+
*/
|
|
810
|
+
const LOADED_MODULES_KEY = Symbol.for("@dtmd/temper.loaded-modules");
|
|
811
|
+
/**
|
|
812
|
+
* The real paths of every local module this run loaded, as the engine's preload recorded
|
|
813
|
+
* them — empty when no preload ran (the SDK driven outside `temper emit`). The judge is the
|
|
814
|
+
* real path, not the URL a specifier resolved through: a workspace package reached via a
|
|
815
|
+
* `node_modules` symlink is the author's own source and stays fingerprinted, while an
|
|
816
|
+
* installed package, whose real path sits under `node_modules`, is its lockfile's to pin.
|
|
817
|
+
* The engine then keeps only the modules the repository tracks: a path its ignore rules
|
|
818
|
+
* exclude (a linked package's build output) gets no row.
|
|
819
|
+
*/
|
|
820
|
+
export function loadedLocalModules() {
|
|
821
|
+
const recorded = globalThis[LOADED_MODULES_KEY];
|
|
822
|
+
if (!(recorded instanceof Set)) {
|
|
823
|
+
return [];
|
|
824
|
+
}
|
|
825
|
+
const paths = [];
|
|
826
|
+
for (const url of recorded) {
|
|
827
|
+
if (typeof url !== "string" || !url.startsWith("file:")) {
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
const path = fileURLToPath(url);
|
|
831
|
+
let real;
|
|
832
|
+
try {
|
|
833
|
+
real = realpathSync(path);
|
|
834
|
+
}
|
|
835
|
+
catch {
|
|
836
|
+
real = path;
|
|
837
|
+
}
|
|
838
|
+
if (!real.split(sep).includes("node_modules")) {
|
|
839
|
+
paths.push(real);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return paths;
|
|
843
|
+
}
|
|
805
844
|
/**
|
|
806
845
|
* Compile the whole face in one deterministic pass: the declaration rows (its
|
|
807
846
|
* rollup and its seven families) and every projected member's erased payload.
|
|
@@ -816,9 +855,11 @@ export function emit(harness) {
|
|
|
816
855
|
deferrableKinds: declaredAtLocusKinds(harness),
|
|
817
856
|
members: memberTable(harness),
|
|
818
857
|
};
|
|
858
|
+
// Read once, ahead of both passes: the set is a fact about this run, not the harness.
|
|
859
|
+
const modules = loadedLocalModules();
|
|
819
860
|
const compile = () => {
|
|
820
861
|
const members = orderedMembers(harness, resolve);
|
|
821
|
-
const declarations = compileDeclarations(harness, edgePlacements(harness, resolve), renderedExtents(harness, resolve));
|
|
862
|
+
const declarations = compileDeclarations(harness, edgePlacements(harness, resolve), renderedExtents(harness, resolve), modules);
|
|
822
863
|
return {
|
|
823
864
|
declarations,
|
|
824
865
|
members,
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A kind's declared **collection address** row — the
|
|
3
|
-
*
|
|
4
|
-
* [`KindFactRow::collection_address`] carries.
|
|
5
|
-
*
|
|
2
|
+
* A kind's declared **collection address** row — the key path a registration member
|
|
3
|
+
* keys at and the shape its entry takes: the presence-coupled pair
|
|
4
|
+
* [`KindFactRow::collection_address`] carries. The manifest it keys inside is the row's
|
|
5
|
+
* own starless `governs_glob`, never a second column here. Absent from a [`KindFactRow`]
|
|
6
|
+
* means the kind owns its own file locus.
|
|
6
7
|
*/
|
|
7
8
|
export type CollectionAddressRow = {
|
|
8
|
-
/**
|
|
9
|
-
* The host manifest the registration surfaces in (`settings.json`, `.mcp.json`).
|
|
10
|
-
*/
|
|
11
|
-
manifest: string;
|
|
12
9
|
/**
|
|
13
10
|
* The manifest key path the registration keys at (`hooks.<Event>`, `mcpServers.*`), a
|
|
14
11
|
* closed vocabulary the engine's kind lift rejects an unknown value from.
|
|
15
12
|
*/
|
|
16
13
|
key_path: string;
|
|
17
14
|
/**
|
|
18
|
-
* The entry's declared shape —
|
|
15
|
+
* The entry's declared shape — `object`, `scalar(field)`, or
|
|
16
|
+
* `group-array(member_key;lifted_fields)`, a closed vocabulary the engine's kind lift
|
|
17
|
+
* rejects an unknown value from. Required: the shape is the kind's own declared fact,
|
|
18
|
+
* never derivable from the key path (two kinds keying at `hooks.<Event>` may lift
|
|
19
|
+
* different group fields).
|
|
19
20
|
*/
|
|
20
|
-
entry_shape: string
|
|
21
|
+
entry_shape: string;
|
|
21
22
|
};
|
|
@@ -73,6 +73,14 @@ export type Declarations = {
|
|
|
73
73
|
* this family empty.
|
|
74
74
|
*/
|
|
75
75
|
inputs: Array<InputRow>;
|
|
76
|
+
/**
|
|
77
|
+
* The real, absolute path of every local module the program's own run loaded — any
|
|
78
|
+
* `file:` module whose real path sits under no `node_modules` directory, since an
|
|
79
|
+
* installed package is its package lockfile's to pin. Seam-inbound like `inputs`:
|
|
80
|
+
* `emit` fingerprints each as a `module` source dependency owned by the root member,
|
|
81
|
+
* so a lock round-trip reads this family empty.
|
|
82
|
+
*/
|
|
83
|
+
modules: Array<string>;
|
|
76
84
|
/**
|
|
77
85
|
* The host members' declared embedded-member facts — captured as declaration
|
|
78
86
|
* rows rather than a second copy the engine reads back off the rendered fence
|
|
@@ -39,6 +39,13 @@ export type KindFactRow = {
|
|
|
39
39
|
* derive at read time under it.
|
|
40
40
|
*/
|
|
41
41
|
commitment?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The file locus's declared **excluded** paths — harness-relative, starless, each a
|
|
44
|
+
* path the locus template would otherwise govern, left ungoverned. Empty for a
|
|
45
|
+
* locus excluding nothing, the tolerant round-trip
|
|
46
|
+
* [`registration`](KindFactRow::registration) takes.
|
|
47
|
+
*/
|
|
48
|
+
exclude?: Array<string>;
|
|
42
49
|
/**
|
|
43
50
|
* The declared projection format label, when declared.
|
|
44
51
|
*/
|
|
@@ -20,7 +20,9 @@ export type RequirementRow = {
|
|
|
20
20
|
*/
|
|
21
21
|
kind?: string;
|
|
22
22
|
/**
|
|
23
|
-
* Whether an unfilled requirement blocks the gate.
|
|
23
|
+
* Whether an unfilled requirement blocks the gate. Absent ⇒ `true`: the
|
|
24
|
+
* corpus default (at least one satisfier, at error), the one the SDK lowers —
|
|
25
|
+
* a row read without the column inherits it, never re-decides it.
|
|
24
26
|
*/
|
|
25
27
|
required: boolean;
|
|
26
28
|
/**
|
|
@@ -34,4 +34,4 @@ export type { Shape } from "./Shape.js";
|
|
|
34
34
|
export type { TemplateRow } from "./TemplateRow.js";
|
|
35
35
|
export type { ValueType } from "./ValueType.js";
|
|
36
36
|
export type { Verifier } from "./Verifier.js";
|
|
37
|
-
export {
|
|
37
|
+
export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const TAP_EVENT_HOOKS: {
|
|
2
|
+
readonly InstructionsLoaded: {
|
|
3
|
+
readonly event: "InstructionsLoaded";
|
|
4
|
+
readonly matcher: ".*";
|
|
5
|
+
};
|
|
6
|
+
readonly SkillInvoked: {
|
|
7
|
+
readonly event: "PostToolUse";
|
|
8
|
+
readonly matcher: "Skill";
|
|
9
|
+
};
|
|
10
|
+
readonly UserPromptExpansion: {
|
|
11
|
+
readonly event: "UserPromptExpansion";
|
|
12
|
+
readonly matcher: ".*";
|
|
13
|
+
};
|
|
14
|
+
readonly ToolUse: {
|
|
15
|
+
readonly event: "PostToolUse";
|
|
16
|
+
readonly matcher: ".*";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// This file carries temper's tap-hook registrations, generated from the engine's own table. Do not edit this file manually.
|
|
2
|
+
export const TAP_EVENT_HOOKS = {
|
|
3
|
+
"InstructionsLoaded": { event: "InstructionsLoaded", matcher: ".*" },
|
|
4
|
+
"SkillInvoked": { event: "PostToolUse", matcher: "Skill" },
|
|
5
|
+
"UserPromptExpansion": { event: "UserPromptExpansion", matcher: ".*" },
|
|
6
|
+
"ToolUse": { event: "PostToolUse", matcher: ".*" },
|
|
7
|
+
};
|
package/dist/src/kind.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* `T` and a constructor `kind<T>()` — plus seven facts of runtime residue: label,
|
|
4
4
|
* locus, projection, registration, edge fields, content, and template. A registration kind (a hook,
|
|
5
5
|
* an MCP server) extends the content fact with a fields-only `shape` and a
|
|
6
|
-
* `collectionAddress` naming the
|
|
6
|
+
* `collectionAddress` naming the key path it surfaces at, inside the manifest its starless
|
|
7
|
+
* `at` locus names. `tsc` is the keystroke
|
|
7
8
|
* wall; every type erases at the seam, and what a kind leaves behind rides the lock as
|
|
8
9
|
* rows. Identity travels by import, never by string — a `kind` reference is the imported
|
|
9
10
|
* value.
|
|
@@ -97,8 +98,19 @@ export interface EdgeField {
|
|
|
97
98
|
export type Locus = {
|
|
98
99
|
readonly kind: "at";
|
|
99
100
|
readonly root: string;
|
|
101
|
+
/** A placement template: literal `/`-separated segments with at most one `*`,
|
|
102
|
+
* optionally under a leading `**` + `/` for any depth. Any other pattern syntax
|
|
103
|
+
* (a `?`, a character class, braces, an extglob, a second star) is refused when
|
|
104
|
+
* the engine loads the lock; narrow member names with a clause, never the glob. */
|
|
100
105
|
readonly glob: string;
|
|
101
106
|
readonly commitment?: "local";
|
|
107
|
+
/** Paths the template would govern that the kind leaves ungoverned — each a
|
|
108
|
+
* starless, harness-relative literal the template matches (`domains/README.md`
|
|
109
|
+
* under `domains` + `*.md`), or a bare directory (no trailing `/`) the template
|
|
110
|
+
* reaches beneath, leaving every path under it ungoverned (`domains/legacy` under
|
|
111
|
+
* `domains` + `* /SKILL.md`, read without the space). Anything else is refused when
|
|
112
|
+
* the engine loads the lock. */
|
|
113
|
+
readonly exclude?: readonly string[];
|
|
102
114
|
} | {
|
|
103
115
|
readonly kind: "embedded";
|
|
104
116
|
} | {
|
|
@@ -107,16 +119,18 @@ export type Locus = {
|
|
|
107
119
|
/**
|
|
108
120
|
* One region of a kind's **layout** — one of the three corpus primitives over the
|
|
109
121
|
* body's heading tree. `prose` is a verbatim span, or an `import` reference resolving to
|
|
110
|
-
* a file's contents; `field` is a heading whose span fills a named field `slot
|
|
122
|
+
* a file's contents; `field` is a heading whose span fills a named field `slot` — a key
|
|
123
|
+
* of the kind's own typed surface `T`, so a slot the member does not carry is a compile
|
|
124
|
+
* error rather than a second, free-hand spelling of the field set;
|
|
111
125
|
* `collection` is a heading whose child headings are each one member of `memberKind`,
|
|
112
126
|
* identity the slugged child heading unless an explicit `key` overrides it.
|
|
113
127
|
*/
|
|
114
|
-
export type LayoutRegion = {
|
|
128
|
+
export type LayoutRegion<T extends object = Record<string, unknown>> = {
|
|
115
129
|
readonly region: "prose";
|
|
116
130
|
readonly import?: string;
|
|
117
131
|
} | {
|
|
118
132
|
readonly region: "field";
|
|
119
|
-
readonly slot: string;
|
|
133
|
+
readonly slot: keyof T & string;
|
|
120
134
|
} | {
|
|
121
135
|
readonly region: "collection";
|
|
122
136
|
readonly memberKind: string;
|
|
@@ -127,8 +141,8 @@ export type LayoutRegion = {
|
|
|
127
141
|
* Declaring one on a kind's `content` makes the kind `layout`-content; leaving `content`
|
|
128
142
|
* absent leaves it `file`-content (one verbatim prose body, the default).
|
|
129
143
|
*/
|
|
130
|
-
export interface Layout {
|
|
131
|
-
readonly regions: readonly LayoutRegion[];
|
|
144
|
+
export interface Layout<T extends object = Record<string, unknown>> {
|
|
145
|
+
readonly regions: readonly LayoutRegion<T>[];
|
|
132
146
|
}
|
|
133
147
|
/**
|
|
134
148
|
* A kind's **body shape** marker — `"fields"` for a fields-only kind: no body slot at
|
|
@@ -156,14 +170,14 @@ export type LeafSet<T extends object> = {
|
|
|
156
170
|
readonly [K in keyof T]-?: true;
|
|
157
171
|
};
|
|
158
172
|
/**
|
|
159
|
-
* A registration member's **collection address** — where inside
|
|
160
|
-
* registration surfaces:
|
|
161
|
-
*
|
|
173
|
+
* A registration member's **collection address** — where inside its host manifest its
|
|
174
|
+
* registration surfaces: the `keyPath` it keys at, one of the four addresses the shipped
|
|
175
|
+
* kinds surface at. The manifest itself is the kind's starless `at` locus — one home, so
|
|
176
|
+
* the address and the locus can never name two different files ({@link manifestOf}).
|
|
162
177
|
* Carried by a fields-only registration kind; absent for a kind that owns its own file
|
|
163
178
|
* locus.
|
|
164
179
|
*/
|
|
165
180
|
export interface CollectionAddress {
|
|
166
|
-
readonly manifest: string;
|
|
167
181
|
readonly keyPath: "hooks.<Event>" | "mcpServers.*" | "enabledPlugins.*" | "extraKnownMarketplaces.*";
|
|
168
182
|
readonly entryShape: string;
|
|
169
183
|
}
|
|
@@ -212,12 +226,9 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
212
226
|
/** Fact 2, locus — where members live, and for a file locus whether their documents
|
|
213
227
|
* are committed: a `local` commitment class declares the kind reviewed and its
|
|
214
228
|
* members' documents not. */
|
|
215
|
-
readonly locus: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
readonly glob: string;
|
|
219
|
-
readonly commitment?: "local";
|
|
220
|
-
};
|
|
229
|
+
readonly locus: Extract<Locus, {
|
|
230
|
+
kind: "at";
|
|
231
|
+
}>;
|
|
221
232
|
/** Fact 3a, projection — the artifact format; omitted for a kind that declares none. */
|
|
222
233
|
readonly format?: Format;
|
|
223
234
|
/** Fact 3b, projection — the on-disk unit shape. */
|
|
@@ -240,12 +251,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
240
251
|
readonly edgeFields?: readonly EdgeField[];
|
|
241
252
|
/** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
|
|
242
253
|
* leaves the kind `file`-content (one verbatim prose body, the default). */
|
|
243
|
-
readonly content?: Layout
|
|
254
|
+
readonly content?: Layout<T>;
|
|
244
255
|
/** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
|
|
245
256
|
* leaves the kind body-bearing (`file` or a {@link Layout}). */
|
|
246
257
|
readonly shape?: Shape;
|
|
247
|
-
/** The registration member's {@link CollectionAddress} —
|
|
248
|
-
*
|
|
258
|
+
/** The registration member's {@link CollectionAddress} — the key path its
|
|
259
|
+
* registration surfaces at inside the manifest this kind's starless locus names;
|
|
260
|
+
* absent for a kind that owns its own file locus. */
|
|
249
261
|
readonly collectionAddress?: CollectionAddress;
|
|
250
262
|
/** Fact 7, template — one {@link Template} per inner layer of nested members the kind
|
|
251
263
|
* hosts; absent for a kind that nests nothing. */
|
|
@@ -286,8 +298,10 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
286
298
|
readonly format?: Format;
|
|
287
299
|
/** Fact 3b, projection — the on-disk unit shape. */
|
|
288
300
|
readonly unitShape: UnitShape;
|
|
289
|
-
/** Fact 4, registration —
|
|
290
|
-
|
|
301
|
+
/** Fact 4, registration — derived, never declared: an embedded member registers
|
|
302
|
+
* nothing, so the locus already states the empty set and the lowering supplies it
|
|
303
|
+
* (`declarations.ts`). */
|
|
304
|
+
readonly registration?: never;
|
|
291
305
|
/**
|
|
292
306
|
* The frontmatter key the member's name writes under. For `unitShape:
|
|
293
307
|
* "named-field"` this is the id **source** — the declared field a member's
|
|
@@ -303,13 +317,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
303
317
|
readonly edgeFields?: readonly EdgeField[];
|
|
304
318
|
/** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
|
|
305
319
|
* leaves the kind `file`-content (one verbatim prose body, the default). */
|
|
306
|
-
readonly content?: Layout
|
|
320
|
+
readonly content?: Layout<T>;
|
|
307
321
|
/** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
|
|
308
322
|
* leaves the kind body-bearing (`file` or a {@link Layout}). */
|
|
309
323
|
readonly shape?: Shape;
|
|
310
|
-
/**
|
|
311
|
-
*
|
|
312
|
-
readonly collectionAddress?:
|
|
324
|
+
/** No collection address: a registration kind's manifest is its `at` locus, and
|
|
325
|
+
* this locus names no file. */
|
|
326
|
+
readonly collectionAddress?: never;
|
|
313
327
|
/** Fact 7, template — one {@link Template} per inner layer of nested members the kind
|
|
314
328
|
* hosts; absent for a kind that nests nothing. */
|
|
315
329
|
readonly templates?: readonly Template[];
|
|
@@ -349,8 +363,10 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
349
363
|
readonly format?: Format;
|
|
350
364
|
/** Fact 3b, projection — the on-disk unit shape. */
|
|
351
365
|
readonly unitShape: UnitShape;
|
|
352
|
-
/** Fact 4, registration — nested-file
|
|
353
|
-
|
|
366
|
+
/** Fact 4, registration — derived, never declared: a nested-file member registers
|
|
367
|
+
* nothing, so the locus already states the empty set and the lowering supplies it
|
|
368
|
+
* (`declarations.ts`). */
|
|
369
|
+
readonly registration?: never;
|
|
354
370
|
/**
|
|
355
371
|
* The frontmatter key the member's name writes under. For `unitShape:
|
|
356
372
|
* "named-field"` this is the id **source** — the declared field a member's
|
|
@@ -366,13 +382,13 @@ export type KindFacts<T extends object = Record<string, unknown>> = {
|
|
|
366
382
|
readonly edgeFields?: readonly EdgeField[];
|
|
367
383
|
/** Fact 6, content — a declared {@link Layout} over the body's heading tree; absent
|
|
368
384
|
* leaves the kind `file`-content (one verbatim prose body, the default). */
|
|
369
|
-
readonly content?: Layout
|
|
385
|
+
readonly content?: Layout<T>;
|
|
370
386
|
/** Fact 6b, content — the fields-only body shape (`"fields"`, no body slot); absent
|
|
371
387
|
* leaves the kind body-bearing (`file` or a {@link Layout}). */
|
|
372
388
|
readonly shape?: Shape;
|
|
373
|
-
/**
|
|
374
|
-
*
|
|
375
|
-
readonly collectionAddress?:
|
|
389
|
+
/** No collection address: a registration kind's manifest is its `at` locus, and
|
|
390
|
+
* this locus names no file. */
|
|
391
|
+
readonly collectionAddress?: never;
|
|
376
392
|
/** Fact 7, template — one {@link Template} per inner layer of nested members the kind
|
|
377
393
|
* hosts; absent for a kind that nests nothing. */
|
|
378
394
|
readonly templates?: readonly Template[];
|
|
@@ -510,7 +526,16 @@ export interface KindOptions {
|
|
|
510
526
|
* checked here at the keystroke, and its lowering to the row is the one place it is
|
|
511
527
|
* spelled again (`declarations.ts`).
|
|
512
528
|
*/
|
|
513
|
-
export declare function kind<T extends object>(
|
|
529
|
+
export declare function kind<T extends object>(typed: KindFacts<T>, options?: KindOptions): KindDefinition<T>;
|
|
530
|
+
/**
|
|
531
|
+
* The host manifest a registration kind surfaces in — its `at` locus glob, which must
|
|
532
|
+
* name exactly one file (no `*`): a starred glob governs a family of files, and a
|
|
533
|
+
* collection address keys inside one.
|
|
534
|
+
*
|
|
535
|
+
* # Throws
|
|
536
|
+
* If the kind's locus is not `at`, or its glob carries a `*`.
|
|
537
|
+
*/
|
|
538
|
+
export declare function manifestOf(facts: KindFacts): string;
|
|
514
539
|
/**
|
|
515
540
|
* A **relocation delta** — the facts a relocated built-in kind diverges from its base
|
|
516
541
|
* on. Two faces, either or both:
|
package/dist/src/kind.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* `T` and a constructor `kind<T>()` — plus seven facts of runtime residue: label,
|
|
4
4
|
* locus, projection, registration, edge fields, content, and template. A registration kind (a hook,
|
|
5
5
|
* an MCP server) extends the content fact with a fields-only `shape` and a
|
|
6
|
-
* `collectionAddress` naming the
|
|
6
|
+
* `collectionAddress` naming the key path it surfaces at, inside the manifest its starless
|
|
7
|
+
* `at` locus names. `tsc` is the keystroke
|
|
7
8
|
* wall; every type erases at the seam, and what a kind leaves behind rides the lock as
|
|
8
9
|
* rows. Identity travels by import, never by string — a `kind` reference is the imported
|
|
9
10
|
* value.
|
|
@@ -135,7 +136,14 @@ function hostOf(facts, init) {
|
|
|
135
136
|
* checked here at the keystroke, and its lowering to the row is the one place it is
|
|
136
137
|
* spelled again (`declarations.ts`).
|
|
137
138
|
*/
|
|
138
|
-
export function kind(
|
|
139
|
+
export function kind(typed, options = {}) {
|
|
140
|
+
// The erasure, spelled: `T` binds the witness and the field slots at the keystroke and
|
|
141
|
+
// then leaves. `keyof T` reads contravariantly, so the compiler will not widen a slot
|
|
142
|
+
// set bound to `T` to the erased `string` on its own — every key of `T` is a string
|
|
143
|
+
// the erased surface admits, which is all this assertion claims.
|
|
144
|
+
const facts = typed;
|
|
145
|
+
if (facts.collectionAddress !== undefined)
|
|
146
|
+
manifestOf(facts);
|
|
139
147
|
const construct = (init) => ({
|
|
140
148
|
kind: facts.name,
|
|
141
149
|
facts,
|
|
@@ -150,6 +158,23 @@ export function kind(facts, options = {}) {
|
|
|
150
158
|
});
|
|
151
159
|
return Object.assign(construct, { facts, key: facts.name, render: options.render });
|
|
152
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* The host manifest a registration kind surfaces in — its `at` locus glob, which must
|
|
163
|
+
* name exactly one file (no `*`): a starred glob governs a family of files, and a
|
|
164
|
+
* collection address keys inside one.
|
|
165
|
+
*
|
|
166
|
+
* # Throws
|
|
167
|
+
* If the kind's locus is not `at`, or its glob carries a `*`.
|
|
168
|
+
*/
|
|
169
|
+
export function manifestOf(facts) {
|
|
170
|
+
if (facts.locus.kind !== "at" || facts.locus.glob.includes("*")) {
|
|
171
|
+
const spelled = facts.locus.kind === "at" ? `\`${facts.locus.glob}\`` : `a \`${facts.locus.kind}\` locus`;
|
|
172
|
+
throw new Error(`kind \`${facts.name}\`: a collection address keys inside the one manifest the kind's ` +
|
|
173
|
+
`locus names, and ${spelled} names no single file — declare an \`at\` locus whose ` +
|
|
174
|
+
`glob carries no \`*\` (specs/model/representation.md, "Reach").`);
|
|
175
|
+
}
|
|
176
|
+
return facts.locus.glob;
|
|
177
|
+
}
|
|
153
178
|
/**
|
|
154
179
|
* The locus a `governs` delta moves the base to: the base's `at` root and glob replaced,
|
|
155
180
|
* every other locus fact (its commitment class among them) riding through.
|
|
@@ -225,7 +250,9 @@ export function relocate(base, delta) {
|
|
|
225
250
|
const relocated = { ...base.facts, relocates: base.facts.name, edgeFields };
|
|
226
251
|
// Two spellings, not one with an optional `locus`: `KindFacts` is a union discriminated
|
|
227
252
|
// on the locus, so the moved case must carry the `at` locus as its own literal branch.
|
|
228
|
-
|
|
253
|
+
// A moved locus is only ever an `at` base's (`relocatedLocus` refuses the rest), and an
|
|
254
|
+
// `at` kind declares its registration set — so the base's set rides through as declared.
|
|
255
|
+
const facts = locus === undefined ? relocated : { ...relocated, locus, registration: relocated.registration ?? [] };
|
|
229
256
|
// The base's leaf-set witness rides through as data, and the assertion is that
|
|
230
257
|
// pass-through spelled: a relocation appends *edge fields* over the kind's own surface,
|
|
231
258
|
// never a leaf, so the set the base's own constructor already bound still names what a
|