@dtmd/temper 0.0.4 → 0.0.7

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 (91) hide show
  1. package/README.md +10 -12
  2. package/bin/temper.js +52 -0
  3. package/dist/src/assembly.d.ts +32 -16
  4. package/dist/src/assembly.js +11 -10
  5. package/dist/src/builtins.d.ts +206 -41
  6. package/dist/src/builtins.js +258 -54
  7. package/dist/src/claude-code.d.ts +7 -9
  8. package/dist/src/claude-code.js +6 -8
  9. package/dist/src/contract.d.ts +47 -24
  10. package/dist/src/contract.js +35 -9
  11. package/dist/src/declarations.d.ts +42 -101
  12. package/dist/src/declarations.js +375 -47
  13. package/dist/src/emit.d.ts +56 -28
  14. package/dist/src/emit.js +177 -54
  15. package/dist/src/generated/AssemblyFactRow.d.ts +29 -0
  16. package/dist/src/generated/AssemblyFactRow.js +2 -0
  17. package/dist/src/generated/BoundRow.d.ts +14 -0
  18. package/dist/src/generated/BoundRow.js +2 -0
  19. package/dist/src/generated/CharsetRow.d.ts +15 -0
  20. package/dist/src/generated/CharsetRow.js +2 -0
  21. package/dist/src/generated/ClauseRow.d.ts +97 -0
  22. package/dist/src/generated/ClauseRow.js +1 -0
  23. package/dist/src/generated/CollectionAddressRow.d.ts +17 -0
  24. package/dist/src/generated/CollectionAddressRow.js +2 -0
  25. package/dist/src/generated/CollectionEntryRow.d.ts +23 -0
  26. package/dist/src/generated/CollectionEntryRow.js +2 -0
  27. package/dist/src/generated/CollectionEntryWire.d.ts +17 -0
  28. package/dist/src/generated/CollectionEntryWire.js +2 -0
  29. package/dist/src/generated/CountBoundRow.d.ts +13 -0
  30. package/dist/src/generated/CountBoundRow.js +2 -0
  31. package/dist/src/generated/Declarations.d.ts +89 -0
  32. package/dist/src/generated/Declarations.js +1 -0
  33. package/dist/src/generated/DegreeBoundRow.d.ts +15 -0
  34. package/dist/src/generated/DegreeBoundRow.js +1 -0
  35. package/dist/src/generated/EdgeBoundRow.d.ts +13 -0
  36. package/dist/src/generated/EdgeBoundRow.js +2 -0
  37. package/dist/src/generated/EmbeddedMember.d.ts +45 -0
  38. package/dist/src/generated/EmbeddedMember.js +1 -0
  39. package/dist/src/generated/EmbeddedMemberCollectionEntry.d.ts +21 -0
  40. package/dist/src/generated/EmbeddedMemberCollectionEntry.js +1 -0
  41. package/dist/src/generated/FeatureValue.d.ts +23 -0
  42. package/dist/src/generated/FeatureValue.js +1 -0
  43. package/dist/src/generated/Features.d.ts +82 -0
  44. package/dist/src/generated/Features.js +1 -0
  45. package/dist/src/generated/FencedBlock.d.ts +24 -0
  46. package/dist/src/generated/FencedBlock.js +2 -0
  47. package/dist/src/generated/IncludeRow.d.ts +18 -0
  48. package/dist/src/generated/IncludeRow.js +2 -0
  49. package/dist/src/generated/KindFactRow.d.ts +65 -0
  50. package/dist/src/generated/KindFactRow.js +1 -0
  51. package/dist/src/generated/LayoutRegionRow.d.ts +29 -0
  52. package/dist/src/generated/LayoutRegionRow.js +2 -0
  53. package/dist/src/generated/LayoutRow.d.ts +12 -0
  54. package/dist/src/generated/LayoutRow.js +1 -0
  55. package/dist/src/generated/MentionRow.d.ts +17 -0
  56. package/dist/src/generated/MentionRow.js +2 -0
  57. package/dist/src/generated/NestedMemberRow.d.ts +39 -0
  58. package/dist/src/generated/NestedMemberRow.js +1 -0
  59. package/dist/src/generated/Payload.d.ts +25 -0
  60. package/dist/src/generated/Payload.js +1 -0
  61. package/dist/src/generated/PayloadMember.d.ts +31 -0
  62. package/dist/src/generated/PayloadMember.js +2 -0
  63. package/dist/src/generated/RangeBoundRow.d.ts +15 -0
  64. package/dist/src/generated/RangeBoundRow.js +2 -0
  65. package/dist/src/generated/RegistrationRow.d.ts +35 -0
  66. package/dist/src/generated/RegistrationRow.js +2 -0
  67. package/dist/src/generated/RequirementRow.d.ts +40 -0
  68. package/dist/src/generated/RequirementRow.js +1 -0
  69. package/dist/src/generated/SatisfiesRow.d.ts +14 -0
  70. package/dist/src/generated/SatisfiesRow.js +2 -0
  71. package/dist/src/generated/Section.d.ts +21 -0
  72. package/dist/src/generated/Section.js +2 -0
  73. package/dist/src/generated/SectionContainsRow.d.ts +14 -0
  74. package/dist/src/generated/SectionContainsRow.js +2 -0
  75. package/dist/src/generated/SettingsRow.d.ts +25 -0
  76. package/dist/src/generated/SettingsRow.js +2 -0
  77. package/dist/src/generated/ValueType.d.ts +9 -0
  78. package/dist/src/generated/ValueType.js +2 -0
  79. package/dist/src/generated/index.d.ts +32 -0
  80. package/dist/src/generated/index.js +1 -0
  81. package/dist/src/index.d.ts +14 -18
  82. package/dist/src/index.js +10 -13
  83. package/dist/src/kind.d.ts +190 -43
  84. package/dist/src/kind.js +34 -30
  85. package/dist/src/needs.d.ts +8 -8
  86. package/dist/src/needs.js +7 -7
  87. package/dist/src/prose.d.ts +75 -28
  88. package/dist/src/prose.js +0 -0
  89. package/package.json +9 -1
  90. package/dist/src/genres.d.ts +0 -38
  91. package/dist/src/genres.js +0 -24
@@ -1,13 +1,12 @@
1
1
  /**
2
- * Contracts — clauses and requirements as typed values (`specs/architecture/10-contracts.md`).
2
+ * Contracts — clauses and requirements as typed values.
3
3
  * A clause is `predicate · severity · guidance · cite`; a requirement is
4
- * `means · kind · required · clauses? · verifiedBy?`. Both erase to compiled data
5
- * at the seam (`20-surface.md`): the author composes typed objects, the engine
4
+ * `prose · kind · required · clauses? · verifiedBy?`. Both erase to compiled data
5
+ * at the seam: the author composes typed objects, the engine
6
6
  * consumes their rows. The predicate vocabulary is the closed algebra — a clause
7
- * outside it is a squiggle, not a runtime rejection (`10-contracts.md`, the two
8
- * walls).
7
+ * outside it is a squiggle, not a runtime rejection.
9
8
  */
10
- // Node-scope predicates (`10-contracts.md`, "The predicate algebra").
9
+ // Node-scope predicates.
11
10
  /** A field or marker is present. */
12
11
  export const required = (field) => ({ key: "required", field });
13
12
  /** The field's parsed scalar type is as declared. */
@@ -36,8 +35,35 @@ export const deny = (field, values) => ({
36
35
  export const requireSections = () => ({ key: "require_sections" });
37
36
  /** The member's name matches its directory. */
38
37
  export const nameMatchesDir = () => ({ key: "name-matches-dir" });
39
- // Node-set/edge-scope predicates (`10-contracts.md`, "Judged at the node-set
40
- // scope" / "Judged at the edge scope") — a requirement's set-scope demands ride
38
+ /** Names are unique within the artifact kind (a scope-wide identity collision). */
39
+ export const uniqueName = () => ({ key: "unique-name" });
40
+ /**
41
+ * The named field may be present — always satisfied, recording the key as part of a
42
+ * declared (closed) schema. `dependency-exists` has no constructor: the engine holds
43
+ * it back absent a decidable reference syntax, so a hand-authored clause would fail
44
+ * admissibility.
45
+ */
46
+ export const optional = (field) => ({ key: "optional", field });
47
+ /** The field's numeric value lies within the inclusive `[min, max]` bound. */
48
+ export const range = (field, min, max) => ({
49
+ key: "range",
50
+ field,
51
+ range: { min, max },
52
+ });
53
+ /** The field's value is one of `values`. Spelled `enumOf` — `enum` is a reserved word. */
54
+ export const enumOf = (field, values) => ({
55
+ key: "enum",
56
+ field,
57
+ values,
58
+ });
59
+ /** The named body marker is defined (e.g. `disable-model-invocation`). */
60
+ export const mustDefine = (marker) => ({ key: "must_define", field: marker });
61
+ /** Every body section whose heading *starts with* `heading` carries `marker` in its body. */
62
+ export const sectionContains = (heading, marker) => ({
63
+ key: "section_contains",
64
+ section: { heading, marker },
65
+ });
66
+ // Node-set/edge-scope predicates — a requirement's set-scope demands ride
41
67
  // these as ordinary clause values, the same four-channel `clause()` shape as
42
68
  // the node-scope predicates above.
43
69
  /** The satisfier set's size lies in the inclusive `[min, max]` bound. */
@@ -74,7 +100,7 @@ export const degree = (bounds) => {
74
100
  export function clause(predicate, opts) {
75
101
  return { predicate, severity: opts.severity, guidance: opts.guidance, cite: opts.cite };
76
102
  }
77
- /** An identity helper — types a requirement literal at the keystroke (`40-composition.md`). */
103
+ /** An identity helper — types a requirement literal at the keystroke. */
78
104
  export function requirement(init) {
79
105
  return init;
80
106
  }
@@ -1,113 +1,54 @@
1
1
  /**
2
- * Declaration rows — the composed program's erased declarations
3
- * (`specs/architecture/20-surface.md`, "The seam — one implementation"; "The lock
4
- * and drift"). Every type erases at the seam: kinds, clauses, requirements, and
5
- * assembly facts compile to plain rows the engine reads. The **row shape** matches
6
- * the Rust lock's `[declaration]` families (`src/drift.rs` `Declarations`) — the
7
- * byte-parity lockstep two writers keep until single-writer lands
8
- * (`SDK-RECUT-CORPUS-FACE`). The same rows ride the internal versioned JSON pipe
9
- * ({@link declarationsToJson}) — not a designed IR, versioned in lockstep.
2
+ * Declaration rows — the composed program's erased declarations.
3
+ * Every type erases at the seam: kinds, clauses, requirements, and
4
+ * assembly facts compile to plain rows the engine reads. The **row shapes are the
5
+ * generated `ts-rs` bindings** (`./generated/`, derived from `src/drift.rs`), so a
6
+ * Rust-side row rename is a compile error here, never a silent shape drift. This
7
+ * module authors the builders that fill them; the same rows ride the internal
8
+ * versioned JSON pipe ({@link encodeSeam}) — not a designed IR, versioned
9
+ * in lockstep.
10
10
  */
11
11
  import type { Harness } from "./assembly.js";
12
- import type { Charset } from "./contract.js";
13
- /** One kind's declaration row — its identity and declared runtime facts. */
14
- export interface KindFactRow {
15
- readonly name: string;
16
- readonly provider?: string;
17
- readonly governs_root: string;
18
- readonly governs_glob: string;
19
- readonly format?: string;
20
- readonly unit_shape?: string;
21
- readonly registration?: string;
22
- }
12
+ import type { Declarations, Payload, RegistrationRow, SettingsRow } from "./generated/index.js";
13
+ export type { AssemblyFactRow, ClauseRow, Declarations, KindFactRow, RequirementRow, SatisfiesRow, } from "./generated/index.js";
14
+ /** The stable-sort ordering every declaration row family shares. */
15
+ export declare function compareStrings(a: string, b: string): number;
23
16
  /**
24
- * One clause of a kind's effective contract, or one of a requirement's own
25
- * set-/edge-scope demands — the same row shape either way (`src/drift.rs`
26
- * `ClauseRow`). `kind` is absent when this row is nested inside a
27
- * `RequirementRow`'s own `clauses`: a requirement's demand names no kind of its
28
- * own (`10-contracts.md`, "Decision: set-scope demands are clauses").
17
+ * The `registration` rows — every fields-only registration member (a hook, an MCP server)
18
+ * erased for the manifest write face, kind-then-key sorted so double emit is byte-stable.
19
+ * Each carries its identity (`kind`/`key`), its collection address (`manifest`/`keyPath`,
20
+ * the wire's snake_case `key_path`), and its folded typed fields — the entry value the
21
+ * engine's write face places under `key`. The one source `emit.ts`'s public
22
+ * {@link RegistrationFact} view also maps from, so the seam and the `EmitResult` sibling
23
+ * cannot disagree on what a manifest carries.
24
+ *
25
+ * # Throws
26
+ * If a fields-only member declares no collection address — it surfaces in no host manifest.
29
27
  */
30
- export interface ClauseRow {
31
- readonly kind?: string;
32
- readonly predicate: string;
33
- readonly field?: string;
34
- readonly severity: string;
35
- /** The just-in-time teaching channel the predicate cannot encode (`10-contracts.md`, "guidance"). */
36
- readonly guidance?: string;
37
- /** The external-fact source backing the clause — a doc URL plus retrieved date (`10-contracts.md`, "cite"). */
38
- readonly cite?: string;
39
- /** The `count` predicate's satisfier-set-size bound. */
40
- readonly count?: {
41
- readonly min: number;
42
- readonly max: number;
43
- };
44
- /** The `membership` predicate's target requirement name. */
45
- readonly target?: string;
46
- /** The `degree` predicate's in/out edge-count bound. */
47
- readonly degree?: {
48
- readonly incoming?: {
49
- readonly min?: number;
50
- readonly max?: number;
51
- };
52
- readonly outgoing?: {
53
- readonly min?: number;
54
- readonly max?: number;
55
- };
56
- };
57
- /** The `min_len`/`max_len`/`max_lines` predicate's scalar bound. */
58
- readonly bound?: {
59
- readonly min?: number;
60
- readonly max?: number;
61
- };
62
- /** The `allowed_chars` predicate's declared character class. */
63
- readonly charset?: Charset;
64
- /** The `forbidden_keys` predicate's forbidden key list. */
65
- readonly keys?: readonly string[];
66
- /** The `deny` predicate's forbidden value list. */
67
- readonly values?: readonly string[];
68
- }
28
+ export declare function registrationRows(harness: Harness): RegistrationRow[];
69
29
  /**
70
- * One named requirement's declaration row — the scalar facets plus its own
71
- * `count`/`unique`/`membership`/`degree` clause rows (`10-contracts.md`,
72
- * "Decision: set-scope demands are clauses"): the requirement's `clauses` array
73
- * is the whole of its set-/edge-scope demand, no facet columns beside it.
30
+ * The `settings` rows — the assembly's harness-level residual settings keys, each folded
31
+ * into the settings.json manifest's opaque residue at emit. Key-sorted so double emit is
32
+ * byte-stable. Seam-inbound: the value lives in the projected manifest, never the lock.
74
33
  */
75
- export interface RequirementRow {
76
- readonly name: string;
77
- readonly kind?: string;
78
- readonly required: boolean;
79
- readonly clauses: readonly ClauseRow[];
80
- readonly verified_by?: string;
81
- }
82
- /** One assembly-scope fact — authority or an edge. */
83
- export interface AssemblyFactRow {
84
- readonly fact: string;
85
- readonly value?: string;
86
- readonly from?: string;
87
- readonly field?: string;
88
- readonly to?: string;
89
- }
90
- /** One member→requirement fill edge — a resolved `satisfies` key. */
91
- export interface SatisfiesRow {
92
- readonly member: string;
93
- readonly requirement: string;
94
- }
95
- /** The five declaration families — the whole erased program the lock and pipe carry. */
96
- export interface Declarations {
97
- readonly kinds: readonly KindFactRow[];
98
- readonly clauses: readonly ClauseRow[];
99
- readonly requirements: readonly RequirementRow[];
100
- readonly assembly: readonly AssemblyFactRow[];
101
- readonly satisfies: readonly SatisfiesRow[];
102
- }
103
- /** Compile a harness into its five declaration families — the erased program. */
34
+ export declare function settingsRows(harness: Harness): SettingsRow[];
35
+ /** Every requirement name a `satisfies` claim may fill — assembly `require` ∪ member `requires`. */
36
+ export declare function declaredRequirements(harness: Harness): Set<string>;
37
+ /**
38
+ * Every address a mention may name — declared requirement names ∪ each member's
39
+ * `kind:name`. Shared by `emit.ts` (a member-level `Text` body's mentions) and
40
+ * this module (an embedded member's `Text` leaves) — the one resolution-check
41
+ * set, so a leaf mention and a member mention are held to the identical bar.
42
+ */
43
+ export declare function declaredAddresses(harness: Harness): Set<string>;
44
+ /** Compile a harness into its seven declaration families — the erased program. */
104
45
  export declare function compileDeclarations(harness: Harness): Declarations;
105
46
  /** The SDK's pinned engine/interchange version — the JSON pipe rides it in lockstep. */
106
47
  export declare const SEAM_VERSION = 2;
107
48
  /**
108
- * Serialize the declaration rows to the internal versioned JSON pipe
109
- * (`20-surface.md`, "The seam"). Not a designed IR — a stable public interchange
110
- * is admitted only when its consumer lands. Deterministic: insertion-ordered keys
111
- * and a trailing newline, so a re-emit is byte-identical (law 5).
49
+ * Serialize the seam payload to the internal versioned JSON pipe — `encodeSeam`
50
+ * stamps `version`, so the caller supplies the rest of the {@link Payload}.
51
+ * Deterministic: insertion-ordered keys and a trailing newline, so a re-emit is
52
+ * byte-identical.
112
53
  */
113
- export declare function declarationsToJson(declarations: Declarations): string;
54
+ export declare function encodeSeam(payload: Omit<Payload, "version">): string;