@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
package/dist/src/prose.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prose —
|
|
3
|
-
* member declares: `file()` for a document that keeps its medium,
|
|
4
|
-
* for short
|
|
5
|
-
* composed body that interleaves verbatim prose spans with embedded-member values in
|
|
2
|
+
* Prose — three constructors, one field type. A member's words are data the
|
|
3
|
+
* member declares: `file()` for a document that keeps its medium, an inline
|
|
4
|
+
* {@link Text} for short prose — spelled `` text`…` `` or `span()` — and `blocks()`
|
|
5
|
+
* for a composed body that interleaves verbatim prose spans with embedded-member values in
|
|
6
6
|
* authored order. Whatever the constructor, the words land byte-identical to their
|
|
7
|
-
* authored text. The two inline
|
|
7
|
+
* authored text. The two inline spellings build the same {@link Text} and differ
|
|
8
8
|
* only in where the words come from: reach for `` text`…` `` when they are literal, for
|
|
9
9
|
* `span()` when they are a string the program derived — the tag's interpolations are
|
|
10
10
|
* references, never words, so a computed string has no slot to ride in.
|
|
@@ -20,14 +20,40 @@ export interface Mentionable {
|
|
|
20
20
|
readonly address: string;
|
|
21
21
|
/** The display text the one corpus-wide rule renders in place. */
|
|
22
22
|
readonly display: string;
|
|
23
|
+
/**
|
|
24
|
+
* The mention's rendered form, when not {@link display}: `"path"` renders the target's
|
|
25
|
+
* projection path relative to the host's own, derived at emit off both members'
|
|
26
|
+
* placements — so a link to a supporting doc is the one bound spelling of where the
|
|
27
|
+
* doc lands, never a hand-written restatement of it. Absent, the display renders.
|
|
28
|
+
*/
|
|
29
|
+
readonly form?: MentionForm;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* How a mention renders in its host's words: `"name"` (the default) as the target's
|
|
33
|
+
* {@link Mentionable.display}, `"path"` as the target's projection path relative to the
|
|
34
|
+
* host's — a target that projects no file has no path, and emit refuses it by name.
|
|
35
|
+
*/
|
|
36
|
+
export type MentionForm = "name" | "path";
|
|
37
|
+
/** The rendering choice {@link mentionOf} takes. */
|
|
38
|
+
export interface MentionOptions {
|
|
39
|
+
/** The form the mention renders as; `"name"` when omitted. */
|
|
40
|
+
readonly as?: MentionForm;
|
|
23
41
|
}
|
|
24
42
|
/**
|
|
25
43
|
* Spell a member as the {@link Mentionable} a mention carries: its own
|
|
26
44
|
* {@link memberAddress}, its bare name the display text — the convention every corpus
|
|
27
45
|
* repeats to cite a member from prose. A nested file child spells the host-qualified
|
|
28
46
|
* address it resolves at, exactly as its declaration rows key by it.
|
|
47
|
+
*
|
|
48
|
+
* A user-invoked member placed under a subdirectory's own locus displays the invocation
|
|
49
|
+
* spelling its placement gives instead ({@link nestedInvocation}): the address stays the
|
|
50
|
+
* identity, the display is what the user types.
|
|
51
|
+
*
|
|
52
|
+
* `{ as: "path" }` renders the mention as the target's projection path relative to the
|
|
53
|
+
* host's instead ({@link MentionForm}) — `text\`See [the reference](${mentionOf(doc, { as:
|
|
54
|
+
* "path" })}).\`` in a skill body emits `reference.md`, wherever the two land.
|
|
29
55
|
*/
|
|
30
|
-
export declare function mentionOf(member: Member): Mentionable;
|
|
56
|
+
export declare function mentionOf(member: Member, options?: MentionOptions): Mentionable;
|
|
31
57
|
/** One authored interpolation: position in the template plus its target. */
|
|
32
58
|
export interface Mention {
|
|
33
59
|
readonly index: number;
|
|
@@ -126,8 +152,17 @@ export interface Blocks {
|
|
|
126
152
|
readonly kind: "blocks";
|
|
127
153
|
readonly values: readonly (Text | EmbeddedMemberValue)[];
|
|
128
154
|
}
|
|
129
|
-
/** A member's prose — one of the
|
|
155
|
+
/** A member's prose — one of the three constructors' values, one field type. */
|
|
130
156
|
export type Prose = File | Text | Blocks;
|
|
157
|
+
/**
|
|
158
|
+
* A member init's `prose`, checked to be one of the three constructors' values. The
|
|
159
|
+
* type already refuses a bare string; an untyped program reaching here with one would
|
|
160
|
+
* otherwise crash emit far from the member that authored it.
|
|
161
|
+
*
|
|
162
|
+
* # Throws
|
|
163
|
+
* If `prose` is present and is not a `text`, `file()` or `blocks()` value.
|
|
164
|
+
*/
|
|
165
|
+
export declare function memberProse(prose: unknown, member: string, kind: string): Prose | undefined;
|
|
131
166
|
/**
|
|
132
167
|
* Declare a document whose medium is preserved — read in whole at emit.
|
|
133
168
|
* `moduleUrl` is the declaring module's own `import.meta.url`,
|
|
@@ -149,9 +184,8 @@ export declare function text(strings: TemplateStringsArray, ...targets: Referenc
|
|
|
149
184
|
/**
|
|
150
185
|
* The computed-prose constructor: the same inline prose as `` text`…` ``, from a string
|
|
151
186
|
* the program built rather than a template the author typed — a rolled-up participants
|
|
152
|
-
* line, a table derived from the members.
|
|
153
|
-
*
|
|
154
|
-
* cannot, because the tag's interpolations *are* the references. So a span is prose with
|
|
187
|
+
* line, a table derived from the members. Only the tag can carry a {@link Reference}
|
|
188
|
+
* — its interpolations *are* the references — so a computed string cannot. So a span is prose with
|
|
155
189
|
* zero references by construction, dedented by the same rule, and composes wherever a
|
|
156
190
|
* `` text`…` `` span does — a member's whole body or a {@link blocks} child.
|
|
157
191
|
*
|
|
@@ -187,9 +221,14 @@ export declare function isTextSpan(value: Text | EmbeddedMemberValue): value is
|
|
|
187
221
|
* Render an inline body to its final text — the display rule applied: each
|
|
188
222
|
* mention slot becomes its target's display form, the surrounding words
|
|
189
223
|
* untouched. The chunk count is `mentions.length + 1` by {@link text}'s
|
|
190
|
-
* construction, so the walk consumes every slot.
|
|
224
|
+
* construction, so the walk consumes every slot. `render` is the per-mention rule; emit
|
|
225
|
+
* passes one that also derives a path-form mention's relative path, and the default
|
|
226
|
+
* ({@link displayOf}) refuses one, having no host placement to derive it from.
|
|
227
|
+
*
|
|
228
|
+
* # Throws
|
|
229
|
+
* If the default rule meets a path-form mention ({@link displayOf}).
|
|
191
230
|
*/
|
|
192
|
-
export declare function renderText(prose: Text): string;
|
|
231
|
+
export declare function renderText(prose: Text, render?: (target: Mentionable) => string): string;
|
|
193
232
|
/**
|
|
194
233
|
* Resolve a leaf's authored value to its stored/rendered string: a bare string
|
|
195
234
|
* is unchanged; a `Text` leaf is mention-resolution-checked against `scope`
|
|
@@ -237,3 +276,21 @@ export interface ResolvedEmbeddedLeaves {
|
|
|
237
276
|
* leaf carries an include ({@link resolveLeaf}).
|
|
238
277
|
*/
|
|
239
278
|
export declare function resolveEmbeddedLeaves(value: EmbeddedMemberValue, scope: MentionScope): ResolvedEmbeddedLeaves;
|
|
279
|
+
/**
|
|
280
|
+
* Rendered prose still carrying its links: literal chunks with one mention between each
|
|
281
|
+
* pair, so a link to a topic is a typed edge to its doc — never a hand-typed path the
|
|
282
|
+
* gate cannot see — while the rendered bytes stay the path the doc lands at.
|
|
283
|
+
*/
|
|
284
|
+
export interface Linked {
|
|
285
|
+
readonly chunks: readonly string[];
|
|
286
|
+
readonly targets: readonly Mentionable[];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A {@link Linked} from a template — `` linked`read [x.md](${link("x")})` ``: a string
|
|
290
|
+
* interpolation is literal text, a {@link Mentionable} one a link.
|
|
291
|
+
*/
|
|
292
|
+
export declare function linked(strings: TemplateStringsArray, ...values: (string | Mentionable)[]): Linked;
|
|
293
|
+
/** Join pieces with `separator`, as `Array.join` would, keeping every piece's links. */
|
|
294
|
+
export declare function joined(pieces: readonly (string | Linked)[], separator?: string): Linked;
|
|
295
|
+
/** The prose a {@link Linked} composes to: the same bytes, each link a mention. */
|
|
296
|
+
export declare function linkedText(value: Linked): Text;
|
package/dist/src/prose.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prose —
|
|
3
|
-
* member declares: `file()` for a document that keeps its medium,
|
|
4
|
-
* for short
|
|
5
|
-
* composed body that interleaves verbatim prose spans with embedded-member values in
|
|
2
|
+
* Prose — three constructors, one field type. A member's words are data the
|
|
3
|
+
* member declares: `file()` for a document that keeps its medium, an inline
|
|
4
|
+
* {@link Text} for short prose — spelled `` text`…` `` or `span()` — and `blocks()`
|
|
5
|
+
* for a composed body that interleaves verbatim prose spans with embedded-member values in
|
|
6
6
|
* authored order. Whatever the constructor, the words land byte-identical to their
|
|
7
|
-
* authored text. The two inline
|
|
7
|
+
* authored text. The two inline spellings build the same {@link Text} and differ
|
|
8
8
|
* only in where the words come from: reach for `` text`…` `` when they are literal, for
|
|
9
9
|
* `span()` when they are a string the program derived — the tag's interpolations are
|
|
10
10
|
* references, never words, so a computed string has no slot to ride in.
|
|
@@ -13,15 +13,47 @@
|
|
|
13
13
|
* **include** (an {@link Include}) pulls the target file's bytes into the host's emitted
|
|
14
14
|
* projection. Both are authored per word and resolution-checked at emit, never mined.
|
|
15
15
|
*/
|
|
16
|
+
import { registrationOf, templatesOf } from "./kind.js";
|
|
16
17
|
import { memberAddress, parseHostAddress } from "./member-address.js";
|
|
17
18
|
/**
|
|
18
19
|
* Spell a member as the {@link Mentionable} a mention carries: its own
|
|
19
20
|
* {@link memberAddress}, its bare name the display text — the convention every corpus
|
|
20
21
|
* repeats to cite a member from prose. A nested file child spells the host-qualified
|
|
21
22
|
* address it resolves at, exactly as its declaration rows key by it.
|
|
23
|
+
*
|
|
24
|
+
* A user-invoked member placed under a subdirectory's own locus displays the invocation
|
|
25
|
+
* spelling its placement gives instead ({@link nestedInvocation}): the address stays the
|
|
26
|
+
* identity, the display is what the user types.
|
|
27
|
+
*
|
|
28
|
+
* `{ as: "path" }` renders the mention as the target's projection path relative to the
|
|
29
|
+
* host's instead ({@link MentionForm}) — `text\`See [the reference](${mentionOf(doc, { as:
|
|
30
|
+
* "path" })}).\`` in a skill body emits `reference.md`, wherever the two land.
|
|
31
|
+
*/
|
|
32
|
+
export function mentionOf(member, options = {}) {
|
|
33
|
+
const mention = { address: memberAddress(member), display: nestedInvocation(member) ?? member.name };
|
|
34
|
+
return options.as === "path" ? { ...mention, form: "path" } : mention;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The invocation a member nested under a subdirectory is typed by, rendered from its
|
|
38
|
+
* placement, never its identity — or `undefined` for every other member. It applies to a
|
|
39
|
+
* user-invoked directory unit claimed at any depth (`**\/…`), whose identity prefixes the
|
|
40
|
+
* subdirectory's segments with `:` (`apps:web:deploy`): those segments are a path, so
|
|
41
|
+
* they render `/`-joined ahead of the `:`-joined leaf — `/apps/web:deploy`
|
|
42
|
+
* (code.claude.com/docs/en/skills, "Load skills in monorepos and subdirectories",
|
|
43
|
+
* retrieved 2026-11-25). A root member's identity is its whole name and keeps it.
|
|
22
44
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
function nestedInvocation(member) {
|
|
46
|
+
const facts = member.facts;
|
|
47
|
+
if (facts.locus.kind !== "at" || facts.unitShape !== "directory")
|
|
48
|
+
return undefined;
|
|
49
|
+
if (!templatesOf(facts.locus).some((glob) => glob.startsWith("**/")))
|
|
50
|
+
return undefined;
|
|
51
|
+
if (!registrationOf(facts).some((channel) => channel.via === "user-invoked"))
|
|
52
|
+
return undefined;
|
|
53
|
+
const colon = member.name.lastIndexOf(":");
|
|
54
|
+
if (colon < 0)
|
|
55
|
+
return undefined;
|
|
56
|
+
return `/${member.name.slice(0, colon).replaceAll(":", "/")}:${member.name.slice(colon + 1)}`;
|
|
25
57
|
}
|
|
26
58
|
/**
|
|
27
59
|
* Whether an unresolved address **defers to the gate** rather than refusing at emit: a
|
|
@@ -75,6 +107,25 @@ const MENTION_SLOT = "\u0000";
|
|
|
75
107
|
* carries one, so the split is unambiguous.
|
|
76
108
|
*/
|
|
77
109
|
const INCLUDE_SLOT = "\u0001";
|
|
110
|
+
/**
|
|
111
|
+
* A member init's `prose`, checked to be one of the three constructors' values. The
|
|
112
|
+
* type already refuses a bare string; an untyped program reaching here with one would
|
|
113
|
+
* otherwise crash emit far from the member that authored it.
|
|
114
|
+
*
|
|
115
|
+
* # Throws
|
|
116
|
+
* If `prose` is present and is not a `text`, `file()` or `blocks()` value.
|
|
117
|
+
*/
|
|
118
|
+
export function memberProse(prose, member, kind) {
|
|
119
|
+
if (prose === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
const tag = prose?.kind;
|
|
122
|
+
if (typeof prose === "object" && (tag === "text" || tag === "file" || tag === "blocks")) {
|
|
123
|
+
return prose;
|
|
124
|
+
}
|
|
125
|
+
const shape = typeof prose === "string" ? "a plain string" : `a ${prose === null ? "null" : typeof prose}`;
|
|
126
|
+
throw new Error(`member \`${member}\` of kind \`${kind}\`: field \`prose\` is ${shape} — a member's prose is ` +
|
|
127
|
+
`a \`text\` span, a \`file()\` or a \`blocks()\` body; tag the template literal with \`text\`.`);
|
|
128
|
+
}
|
|
78
129
|
/**
|
|
79
130
|
* Refuse authored words carrying {@link MENTION_SLOT} or {@link INCLUDE_SLOT} — the
|
|
80
131
|
* markers are the tool's alone. A stray one would split into a chunk no reference
|
|
@@ -144,9 +195,8 @@ export function text(strings, ...targets) {
|
|
|
144
195
|
/**
|
|
145
196
|
* The computed-prose constructor: the same inline prose as `` text`…` ``, from a string
|
|
146
197
|
* the program built rather than a template the author typed — a rolled-up participants
|
|
147
|
-
* line, a table derived from the members.
|
|
148
|
-
*
|
|
149
|
-
* cannot, because the tag's interpolations *are* the references. So a span is prose with
|
|
198
|
+
* line, a table derived from the members. Only the tag can carry a {@link Reference}
|
|
199
|
+
* — its interpolations *are* the references — so a computed string cannot. So a span is prose with
|
|
150
200
|
* zero references by construction, dedented by the same rule, and composes wherever a
|
|
151
201
|
* `` text`…` `` span does — a member's whole body or a {@link blocks} child.
|
|
152
202
|
*
|
|
@@ -208,16 +258,37 @@ export function isTextSpan(value) {
|
|
|
208
258
|
* Render an inline body to its final text — the display rule applied: each
|
|
209
259
|
* mention slot becomes its target's display form, the surrounding words
|
|
210
260
|
* untouched. The chunk count is `mentions.length + 1` by {@link text}'s
|
|
211
|
-
* construction, so the walk consumes every slot.
|
|
261
|
+
* construction, so the walk consumes every slot. `render` is the per-mention rule; emit
|
|
262
|
+
* passes one that also derives a path-form mention's relative path, and the default
|
|
263
|
+
* ({@link displayOf}) refuses one, having no host placement to derive it from.
|
|
264
|
+
*
|
|
265
|
+
* # Throws
|
|
266
|
+
* If the default rule meets a path-form mention ({@link displayOf}).
|
|
212
267
|
*/
|
|
213
|
-
export function renderText(prose) {
|
|
268
|
+
export function renderText(prose, render = displayOf) {
|
|
214
269
|
const chunks = prose.template.split(MENTION_SLOT);
|
|
215
270
|
let out = chunks[0];
|
|
216
271
|
prose.mentions.forEach((mention, i) => {
|
|
217
|
-
out += mention.target
|
|
272
|
+
out += render(mention.target) + chunks[i + 1];
|
|
218
273
|
});
|
|
219
274
|
return out;
|
|
220
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* The display rule alone: a mention renders as its {@link Mentionable.display}. A
|
|
278
|
+
* path-form mention ({@link MentionForm}) is refused — its path is derived off the host's
|
|
279
|
+
* placement, which only emit knows, so rendering it here would spell the name where the
|
|
280
|
+
* author bound a path.
|
|
281
|
+
*
|
|
282
|
+
* # Throws
|
|
283
|
+
* If the target is a path-form mention.
|
|
284
|
+
*/
|
|
285
|
+
function displayOf(target) {
|
|
286
|
+
if (target.form === "path") {
|
|
287
|
+
throw new Error(`mention of \`${target.address}\` renders as a path, which is derived off its host's ` +
|
|
288
|
+
`projection at emit — render the host through \`emit\` (specs/model/authoring.md, "The SDK").`);
|
|
289
|
+
}
|
|
290
|
+
return target.display;
|
|
291
|
+
}
|
|
221
292
|
/**
|
|
222
293
|
* Resolve a leaf's authored value to its stored/rendered string: a bare string
|
|
223
294
|
* is unchanged; a `Text` leaf is mention-resolution-checked against `scope`
|
|
@@ -237,6 +308,12 @@ export function resolveLeaf(value, scope, context) {
|
|
|
237
308
|
`member-body intent, not a fenced-value one (specs/model/authoring.md, "The SDK").`);
|
|
238
309
|
}
|
|
239
310
|
checkMentions(value.mentions, scope, context);
|
|
311
|
+
const path = value.mentions.find((mention) => mention.target.form === "path");
|
|
312
|
+
if (path !== undefined) {
|
|
313
|
+
throw new Error(`${context}: mention of \`${path.target.address}\` renders as a path, but an embedded-member ` +
|
|
314
|
+
`leaf is a fenced value, not a document a relative path is read from — mention it by ` +
|
|
315
|
+
`name here (specs/model/authoring.md, "The SDK").`);
|
|
316
|
+
}
|
|
240
317
|
return renderText(value);
|
|
241
318
|
}
|
|
242
319
|
/**
|
|
@@ -274,3 +351,38 @@ export function resolveEmbeddedLeaves(value, scope) {
|
|
|
274
351
|
}
|
|
275
352
|
return { leaves, collections };
|
|
276
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* A {@link Linked} from a template — `` linked`read [x.md](${link("x")})` ``: a string
|
|
356
|
+
* interpolation is literal text, a {@link Mentionable} one a link.
|
|
357
|
+
*/
|
|
358
|
+
export function linked(strings, ...values) {
|
|
359
|
+
const chunks = [strings[0]];
|
|
360
|
+
const targets = [];
|
|
361
|
+
values.forEach((value, i) => {
|
|
362
|
+
if (typeof value === "string") {
|
|
363
|
+
chunks[chunks.length - 1] += value + strings[i + 1];
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
targets.push(value);
|
|
367
|
+
chunks.push(strings[i + 1]);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return { chunks, targets };
|
|
371
|
+
}
|
|
372
|
+
/** Join pieces with `separator`, as `Array.join` would, keeping every piece's links. */
|
|
373
|
+
export function joined(pieces, separator = "\n\n") {
|
|
374
|
+
const chunks = [""];
|
|
375
|
+
const targets = [];
|
|
376
|
+
pieces.forEach((piece, i) => {
|
|
377
|
+
const part = typeof piece === "string" ? { chunks: [piece], targets: [] } : piece;
|
|
378
|
+
chunks[chunks.length - 1] += (i === 0 ? "" : separator) + part.chunks[0];
|
|
379
|
+
chunks.push(...part.chunks.slice(1));
|
|
380
|
+
targets.push(...part.targets);
|
|
381
|
+
});
|
|
382
|
+
return { chunks, targets };
|
|
383
|
+
}
|
|
384
|
+
/** The prose a {@link Linked} composes to: the same bytes, each link a mention. */
|
|
385
|
+
export function linkedText(value) {
|
|
386
|
+
const strings = Object.assign([...value.chunks], { raw: [...value.chunks] });
|
|
387
|
+
return text(strings, ...value.targets);
|
|
388
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The harness reference — temper's operate skill as a value a harness declares. Listed in
|
|
3
|
+
* `harness({ members })` it is an ordinary `skill` member named `temper`; at emit its
|
|
4
|
+
* description and body render from the program's own declarations: the product's
|
|
5
|
+
* mechanics, then one index line per kind in play and per contracted requirement, and a
|
|
6
|
+
* description naming those requirements so every session starts knowing which are taken.
|
|
7
|
+
* Each kind and requirement the index names gets its topic flat beside `SKILL.md`, a
|
|
8
|
+
* `supporting-doc`: `kind-<k>.md` carries the kind's counsel, locus, fields, edges in and
|
|
9
|
+
* out with their intent, the clauses bound over it and its requirements; `requirement-<r>.md` the
|
|
10
|
+
* requirement's prose, what holds it, and its owners. A kind topic names no member but
|
|
11
|
+
* the `tool` topic's commands, so it grows with declarations, never with documents.
|
|
12
|
+
*
|
|
13
|
+
* It renders only committed declarations: a kind at a `local` locus (the dial among
|
|
14
|
+
* them) and every member of one stay out of the index, since a committed projection
|
|
15
|
+
* cannot carry what one machine alone declared.
|
|
16
|
+
*/
|
|
17
|
+
import type { Harness } from "./assembly.js";
|
|
18
|
+
import type { Member } from "./kind.js";
|
|
19
|
+
import type { Mentionable, Text } from "./prose.js";
|
|
20
|
+
/** The reference's skill name — its member lands at `.claude/skills/temper/SKILL.md`. */
|
|
21
|
+
export declare const REFERENCE_NAME = "temper";
|
|
22
|
+
/**
|
|
23
|
+
* What the reference may declare of its own: the trigger its description opens with, and
|
|
24
|
+
* the requirements it fills. Its body and topics are never authored — they derive from the
|
|
25
|
+
* harness listing it.
|
|
26
|
+
*/
|
|
27
|
+
export interface ReferenceInit {
|
|
28
|
+
/**
|
|
29
|
+
* The trigger the skill's description opens with — when a session should load it.
|
|
30
|
+
* Absent, temper's own trigger. Either way the rendered description closes by naming
|
|
31
|
+
* the harness's contracted requirements, which derive from what is declared.
|
|
32
|
+
*/
|
|
33
|
+
readonly description?: string;
|
|
34
|
+
/** The requirements this member fills — every member's `satisfies` edge. */
|
|
35
|
+
readonly satisfies?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Declare the harness reference: a `skill` member named {@link REFERENCE_NAME} whose
|
|
39
|
+
* description and body `emit` renders from the harness listing it. `description`
|
|
40
|
+
* hydrates the description's trigger; `satisfies` lets it fill a requirement — and so list
|
|
41
|
+
* itself as that requirement's owner.
|
|
42
|
+
*
|
|
43
|
+
* # Throws
|
|
44
|
+
* If `description` is blank — a skill's description is how a session finds it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function reference(init?: ReferenceInit): Member;
|
|
47
|
+
/** A topic the reference carries beside `SKILL.md`: its doc name and its body. */
|
|
48
|
+
interface Topic {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly body: Text;
|
|
51
|
+
}
|
|
52
|
+
/** The mention a link to the named topic renders: its doc's path from the linking file. */
|
|
53
|
+
type TopicLink = (topic: string) => Mentionable;
|
|
54
|
+
/**
|
|
55
|
+
* The rendered reference over `harness`: its description — `trigger`, then the contracted
|
|
56
|
+
* requirements — its body, and its topics, one per kind in play, then one per contracted requirement.
|
|
57
|
+
*/
|
|
58
|
+
export declare function renderReference(harness: Harness, link: TopicLink, trigger?: string): {
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly body: Text;
|
|
61
|
+
readonly topics: readonly Topic[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* `harness` with every declared reference rendered from it — the one view emit compiles,
|
|
65
|
+
* so the projection and the declaration rows agree. Each rendered reference brings its
|
|
66
|
+
* kind and requirement topics as `supporting-doc` members hosted by it. A harness carrying none comes
|
|
67
|
+
* back as is.
|
|
68
|
+
*/
|
|
69
|
+
export declare function withReference(harness: Harness): Harness;
|
|
70
|
+
export {};
|