@jigs.design/prompt 0.3.4 → 0.3.6
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/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/system-prompt.d.ts +33 -3
- package/dist/system-prompt.js +15 -3
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { askOf, documentOf, withDocument } from "./document.js";
|
|
2
2
|
import { editRepairText, fullDocumentText, needsRepair, repairText } from "./repair.js";
|
|
3
|
-
import { PromptMode, PromptOptions, SystemPromptParts, systemPrompt, systemPromptParts } from "./system-prompt.js";
|
|
3
|
+
import { PromptMode, PromptOptions, PromptTag, SystemPromptParts, savedTagsSection, systemPrompt, systemPromptParts } from "./system-prompt.js";
|
|
4
4
|
import { TOOL_RESULTS, toolResultsSlot } from "./tool-results.js";
|
|
5
5
|
import { typeText } from "./types.js";
|
|
6
|
-
export { type PromptMode, type PromptOptions, type SystemPromptParts, TOOL_RESULTS, askOf, documentOf, editRepairText, fullDocumentText, needsRepair, repairText, systemPrompt, systemPromptParts, toolResultsSlot, typeText, withDocument };
|
|
6
|
+
export { type PromptMode, type PromptOptions, type PromptTag, type SystemPromptParts, TOOL_RESULTS, askOf, documentOf, editRepairText, fullDocumentText, needsRepair, repairText, savedTagsSection, systemPrompt, systemPromptParts, toolResultsSlot, typeText, withDocument };
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,5 @@ import { askOf, documentOf, withDocument } from "./document.js";
|
|
|
2
2
|
import { editRepairText, fullDocumentText, needsRepair, repairText } from "./repair.js";
|
|
3
3
|
import { typeText } from "./types.js";
|
|
4
4
|
import { TOOL_RESULTS, toolResultsSlot } from "./tool-results.js";
|
|
5
|
-
import { systemPrompt, systemPromptParts } from "./system-prompt.js";
|
|
6
|
-
export { TOOL_RESULTS, askOf, documentOf, editRepairText, fullDocumentText, needsRepair, repairText, systemPrompt, systemPromptParts, toolResultsSlot, typeText, withDocument };
|
|
5
|
+
import { savedTagsSection, systemPrompt, systemPromptParts } from "./system-prompt.js";
|
|
6
|
+
export { TOOL_RESULTS, askOf, documentOf, editRepairText, fullDocumentText, needsRepair, repairText, savedTagsSection, systemPrompt, systemPromptParts, toolResultsSlot, typeText, withDocument };
|
package/dist/system-prompt.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export interface PromptOptions {
|
|
|
11
11
|
instructions?: string;
|
|
12
12
|
/** Default "document". */
|
|
13
13
|
mode?: PromptMode;
|
|
14
|
+
/**
|
|
15
|
+
* Tags one user saved, rendered as `## Saved tags`, the third part
|
|
16
|
+
* (`tail`), after everything the host renders. None by default, and
|
|
17
|
+
* then the prompt is the host's alone.
|
|
18
|
+
*/
|
|
19
|
+
savedTags?: ReadonlyArray<PromptTag>;
|
|
14
20
|
/**
|
|
15
21
|
* The host carries the `toolResults` slot (`toolResultsSlot`): add the
|
|
16
22
|
* rules on reading a tool's results instead of copying them. The slot
|
|
@@ -18,6 +24,21 @@ export interface PromptOptions {
|
|
|
18
24
|
*/
|
|
19
25
|
toolResults?: boolean;
|
|
20
26
|
}
|
|
27
|
+
/** A tag as the prompt lists it: its signature from `source`, then what it is for. */
|
|
28
|
+
export interface PromptTag {
|
|
29
|
+
description: string;
|
|
30
|
+
/** A one-line use. */
|
|
31
|
+
example?: string;
|
|
32
|
+
name: string;
|
|
33
|
+
/** One `<define>`, with or without a pragma line. */
|
|
34
|
+
source: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The `## Saved tags` section for one user's tags, each as a `### <signature>`
|
|
38
|
+
* block like the app's tags; empty for none. `systemPromptParts` renders it
|
|
39
|
+
* as `tail`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function savedTagsSection(tags: ReadonlyArray<PromptTag>): string;
|
|
21
42
|
/**
|
|
22
43
|
* The system prompt for writing Jigs against `host`. In document mode
|
|
23
44
|
* (the default) every reply is one UI, as a session expects; in chat mode a
|
|
@@ -34,17 +55,26 @@ export interface PromptOptions {
|
|
|
34
55
|
* changes the prefix.
|
|
35
56
|
*/
|
|
36
57
|
export declare function systemPrompt(host: Host, options?: PromptOptions): string;
|
|
37
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* The system prompt in parts: what stays the same from turn to turn, the
|
|
60
|
+
* rest of what the host renders, and one user's saved tags.
|
|
61
|
+
*/
|
|
38
62
|
export interface SystemPromptParts {
|
|
39
63
|
/** The output rules, the language and the catalog: the part a provider can cache. */
|
|
40
64
|
stable: string;
|
|
65
|
+
/**
|
|
66
|
+
* The `## Saved tags` section for `PromptOptions.savedTags`, after
|
|
67
|
+
* `variable`; empty without any. It differs per user, so it comes last.
|
|
68
|
+
*/
|
|
69
|
+
tail: string;
|
|
41
70
|
/** The app's instructions, the procedures and the images. */
|
|
42
71
|
variable: string;
|
|
43
72
|
}
|
|
44
73
|
/**
|
|
45
74
|
* `systemPrompt` split where what a turn may change begins, so a model call
|
|
46
|
-
* can mark the first part for a provider's prompt cache
|
|
47
|
-
* the
|
|
75
|
+
* can mark the first part for a provider's prompt cache, and where one
|
|
76
|
+
* user's saved tags begin, so the host's parts stay the same for every user.
|
|
77
|
+
* `systemPrompt` is the first two joined by a blank line.
|
|
48
78
|
*/
|
|
49
79
|
export declare function systemPromptParts(host: Host, options?: PromptOptions): SystemPromptParts;
|
|
50
80
|
//#endregion
|
package/dist/system-prompt.js
CHANGED
|
@@ -228,6 +228,8 @@ function insertAfter(text, after, line) {
|
|
|
228
228
|
}
|
|
229
229
|
const TAGS_INTRO = `## App tags
|
|
230
230
|
Tags this app wrote in Jigs. Use them like any tag, with the props shown; a bare prop is required. They are already defined: never write their <define>. Prefer one over building the same thing from components. When one of them alone answers the ask, the UI is that one tag and nothing else.`;
|
|
231
|
+
const SAVED_TAGS_INTRO = `## Saved tags
|
|
232
|
+
Tags this user saved, written in Jigs. Use them like the app's tags: with the props shown, a bare prop required, never writing their \`<define>\`. Prefer one over building the same thing from components. When one of them alone answers the ask, the UI is that one tag and nothing else.`;
|
|
231
233
|
function tagSection(entry) {
|
|
232
234
|
const lines = [`### ${jigSignature({
|
|
233
235
|
name: entry.name,
|
|
@@ -236,6 +238,14 @@ function tagSection(entry) {
|
|
|
236
238
|
if (entry.example !== void 0) lines.push(`Example: \`${entry.example}\``);
|
|
237
239
|
return lines.join("\n");
|
|
238
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* The `## Saved tags` section for one user's tags, each as a `### <signature>`
|
|
243
|
+
* block like the app's tags; empty for none. `systemPromptParts` renders it
|
|
244
|
+
* as `tail`.
|
|
245
|
+
*/
|
|
246
|
+
function savedTagsSection(tags) {
|
|
247
|
+
return tags.length === 0 ? "" : [SAVED_TAGS_INTRO, ...tags.map((entry) => tagSection(entry))].join("\n\n");
|
|
248
|
+
}
|
|
239
249
|
const SITUATIONS_INTRO = `## Situations
|
|
240
250
|
Find the situation whose When matches what the reader will do with this UI. Follow its guidance where it differs from Design. Ignore the others. If none matches, follow Design alone.`;
|
|
241
251
|
/**
|
|
@@ -325,8 +335,9 @@ function systemPrompt(host, options) {
|
|
|
325
335
|
}
|
|
326
336
|
/**
|
|
327
337
|
* `systemPrompt` split where what a turn may change begins, so a model call
|
|
328
|
-
* can mark the first part for a provider's prompt cache
|
|
329
|
-
* the
|
|
338
|
+
* can mark the first part for a provider's prompt cache, and where one
|
|
339
|
+
* user's saved tags begin, so the host's parts stay the same for every user.
|
|
340
|
+
* `systemPrompt` is the first two joined by a blank line.
|
|
330
341
|
*/
|
|
331
342
|
function systemPromptParts(host, options) {
|
|
332
343
|
const entries = Object.entries(host.procedures);
|
|
@@ -365,8 +376,9 @@ function systemPromptParts(host, options) {
|
|
|
365
376
|
variable.push(host.imageHosts.length === 0 ? "## Images\n- No image hosts are allowed. Do not use images." : `## Images\n- Images may only load from: ${host.imageHosts.join(", ")}. Any other URL is dropped.`);
|
|
366
377
|
return {
|
|
367
378
|
stable: sections.join("\n\n"),
|
|
379
|
+
tail: savedTagsSection(options?.savedTags ?? []),
|
|
368
380
|
variable: variable.join("\n\n")
|
|
369
381
|
};
|
|
370
382
|
}
|
|
371
383
|
//#endregion
|
|
372
|
-
export { systemPrompt, systemPromptParts };
|
|
384
|
+
export { savedTagsSection, systemPrompt, systemPromptParts };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/prompt",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "The system prompt and the repair text, rendered from a host and from diagnostics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@jigs.design/compiler": "0.3.
|
|
29
|
-
"@jigs.design/host": "0.3.
|
|
30
|
-
"@jigs.design/protocol": "0.3.
|
|
28
|
+
"@jigs.design/compiler": "0.3.6",
|
|
29
|
+
"@jigs.design/host": "0.3.6",
|
|
30
|
+
"@jigs.design/protocol": "0.3.6"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"zod": "^4.0.0"
|