@jigs.design/prompt 0.1.1 → 0.1.2
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 +1 -1
- package/dist/repair.d.ts +1 -1
- package/dist/repair.js +7 -7
- package/dist/system-prompt.d.ts +2 -2
- package/dist/system-prompt.js +12 -12
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Renders the text the model reads: the system prompt from a host, and the repair text from diagnostics. `@jigs.design/server` uses it; you import it to read or test the prompt a host produces.
|
|
4
4
|
|
|
5
|
-
The system prompt carries the app's `instructions`, then lists the host's procedures, components and recipes, and ends with the host's design guidance (`## Design`: shared, then the mode's) and situations (`## Situations`: how to choose, then each with its When line, guidance and example). It writes each procedure's input and output out as types, with each field's `.describe()` text and constraints as a comment, and shared enums declared once. It has two modes: `document`, where the whole reply is one UI, and `chat`, where the reply is Markdown with fenced `
|
|
5
|
+
The system prompt carries the app's `instructions`, then lists the host's procedures, components and recipes, and ends with the host's design guidance (`## Design`: shared, then the mode's) and situations (`## Situations`: how to choose, then each with its When line, guidance and example). It writes each procedure's input and output out as types, with each field's `.describe()` text and constraints as a comment, and shared enums declared once. It has two modes: `document`, where the whole reply is one UI, and `chat`, where the reply is Markdown with fenced `jigs` blocks.
|
|
6
6
|
|
|
7
7
|
## Exports
|
|
8
8
|
|
package/dist/repair.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface RepairAdvice {
|
|
|
10
10
|
/**
|
|
11
11
|
* The follow-up turn asking the model to fix the errors in its last answer,
|
|
12
12
|
* and any design advice the app chose to repair. With advice alone, it says
|
|
13
|
-
* the
|
|
13
|
+
* the Jigs works and asks for the design change.
|
|
14
14
|
*/
|
|
15
15
|
export declare function repairText(diagnostics: ReadonlyArray<Diagnostic>, advice?: ReadonlyArray<RepairAdvice>): string;
|
|
16
16
|
/** An edit block that did not apply, as `applyEdits` and the server report it. */
|
package/dist/repair.js
CHANGED
|
@@ -7,7 +7,7 @@ function needsRepair(diagnostics) {
|
|
|
7
7
|
/**
|
|
8
8
|
* The follow-up turn asking the model to fix the errors in its last answer,
|
|
9
9
|
* and any design advice the app chose to repair. With advice alone, it says
|
|
10
|
-
* the
|
|
10
|
+
* the Jigs works and asks for the design change.
|
|
11
11
|
*/
|
|
12
12
|
function repairText(diagnostics, advice = []) {
|
|
13
13
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -20,14 +20,14 @@ function repairText(diagnostics, advice = []) {
|
|
|
20
20
|
});
|
|
21
21
|
const lines = issues.slice(0, MAX_ISSUES).map((issue) => `- Line ${issue.span.line}: ${issue.message}`);
|
|
22
22
|
if (issues.length > MAX_ISSUES) lines.push(`- ...and ${issues.length - MAX_ISSUES} more`);
|
|
23
|
-
if (errors.length === 0) return `Your
|
|
23
|
+
if (errors.length === 0) return `Your jig works, but its design can be better. Line numbers refer to your last answer.
|
|
24
24
|
${lines.join("\n")}
|
|
25
25
|
|
|
26
|
-
Change that and keep everything else as it is. Reply with edit blocks, or with the complete corrected
|
|
27
|
-
return `Your
|
|
26
|
+
Change that and keep everything else as it is. Reply with edit blocks, or with the complete corrected Jigs if the change is large.`;
|
|
27
|
+
return `Your jig has problems. Line numbers refer to your last answer.
|
|
28
28
|
${lines.join("\n")}
|
|
29
29
|
|
|
30
|
-
Fix them and keep everything that already works. Reply with edit blocks, or with the complete corrected
|
|
30
|
+
Fix them and keep everything that already works. Reply with edit blocks, or with the complete corrected Jigs if the fix is large.`;
|
|
31
31
|
}
|
|
32
32
|
/** Letter pairs of a line without its indentation, for a rough similarity. */
|
|
33
33
|
function pairs(line) {
|
|
@@ -126,7 +126,7 @@ const EDIT_ADVICE = {
|
|
|
126
126
|
* the current UI it concerns, so the next edits land where they were meant.
|
|
127
127
|
*/
|
|
128
128
|
function editRepairText(edit, source) {
|
|
129
|
-
return [...failureParts(edit, source), `${EDIT_ADVICE[edit.reason]}, or with the complete updated
|
|
129
|
+
return [...failureParts(edit, source), `${EDIT_ADVICE[edit.reason]}, or with the complete updated Jigs if the change is large.`].join("\n\n");
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Asks for the whole document after an edit did not apply. It repeats what
|
|
@@ -134,7 +134,7 @@ function editRepairText(edit, source) {
|
|
|
134
134
|
* SEARCH text, so the rewrite makes that change and nothing else.
|
|
135
135
|
*/
|
|
136
136
|
function fullDocumentText(edit, source) {
|
|
137
|
-
return [...failureParts(edit, source), "Reply with the complete updated
|
|
137
|
+
return [...failureParts(edit, source), "Reply with the complete updated Jigs instead of edits: the current UI with this change made, and everything else kept as it is."].join("\n\n");
|
|
138
138
|
}
|
|
139
139
|
//#endregion
|
|
140
140
|
export { editRepairText, fullDocumentText, needsRepair, repairText };
|
package/dist/system-prompt.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export interface PromptOptions {
|
|
|
13
13
|
mode?: PromptMode;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The system prompt for writing
|
|
16
|
+
* The system prompt for writing Jigs against `host`. In document mode
|
|
17
17
|
* (the default) every reply is one UI, as a session expects; in chat mode a
|
|
18
|
-
* reply is Markdown with UIs in fenced `
|
|
18
|
+
* reply is Markdown with UIs in fenced `jigs` blocks. Everything but the
|
|
19
19
|
* output section and the mode's design guidance is the same in both.
|
|
20
20
|
*
|
|
21
21
|
* What stays the same from turn to turn comes first, so a provider can
|
package/dist/system-prompt.js
CHANGED
|
@@ -3,7 +3,7 @@ import { sharedObjects, sharedTypes } from "./shared-types.js";
|
|
|
3
3
|
import { recipeSignature } from "@jigs.design/compiler";
|
|
4
4
|
import { dataSchema } from "@jigs.design/host";
|
|
5
5
|
//#region src/system-prompt.ts
|
|
6
|
-
const
|
|
6
|
+
const JIGS = `Jigs is Markdown for prose, JSX-like tags for components from a fixed catalog, and \`{@body ...}\` lines of JavaScript for state and logic.`;
|
|
7
7
|
const EDIT_BLOCK = `<<<<<<< SEARCH
|
|
8
8
|
exact lines from the current UI
|
|
9
9
|
=======
|
|
@@ -11,23 +11,23 @@ the new lines
|
|
|
11
11
|
>>>>>>> REPLACE
|
|
12
12
|
- Copy SEARCH lines exactly, indentation included, with enough lines to be unique. Use one block per place you change, in document order. An empty SEARCH appends to the end.`;
|
|
13
13
|
/** Every reply is one UI: the whole document, or edits to the last one. */
|
|
14
|
-
const DOCUMENT_OUTPUT = `You write interactive user interfaces in
|
|
14
|
+
const DOCUMENT_OUTPUT = `You write interactive user interfaces in Jigs. ${JIGS}
|
|
15
15
|
|
|
16
16
|
## Output
|
|
17
|
-
- Reply with
|
|
17
|
+
- Reply with Jigs only. No code fences, no explanation before or after it.
|
|
18
18
|
|
|
19
19
|
## Changing an existing UI
|
|
20
20
|
When asked to change a UI you wrote earlier:
|
|
21
21
|
- For a focused change, reply with edit blocks only, no other text:
|
|
22
22
|
${EDIT_BLOCK}
|
|
23
|
-
- If the change rewrites most of the UI, reply with the complete updated
|
|
23
|
+
- If the change rewrites most of the UI, reply with the complete updated Jigs instead.`;
|
|
24
24
|
const OUTPUT = {
|
|
25
|
-
chat: `You reply in Markdown, and you can show interactive user interfaces in your replies by writing
|
|
25
|
+
chat: `You reply in Markdown, and you can show interactive user interfaces in your replies by writing Jigs. ${JIGS}
|
|
26
26
|
|
|
27
27
|
## Output
|
|
28
28
|
- Answer in Markdown, as in any chat. Most replies need no UI.
|
|
29
|
-
- When a UI helps more than prose (live data, a form, a comparison, a chart, anything to click), write it in
|
|
30
|
-
\`\`\`
|
|
29
|
+
- When a UI helps more than prose (live data, a form, a comparison, a chart, anything to click), write it in Jigs inside a fenced block that opens with \`\`\`jigs and a short kebab-case id, and closes with \`\`\`:
|
|
30
|
+
\`\`\`jigs monthly-spending
|
|
31
31
|
# Spending this month
|
|
32
32
|
...
|
|
33
33
|
\`\`\`
|
|
@@ -35,13 +35,13 @@ const OUTPUT = {
|
|
|
35
35
|
- You never see what a query returns: the UI reads it when it runs, after your reply. So your prose must not state figures, totals or conclusions about the user's data; say what the UI shows instead.
|
|
36
36
|
- Tags, recipes and \`{@body}\` lines work only inside a block. Outside one, write plain Markdown: no tags, no HTML and no tool-call markup, which would show as text.
|
|
37
37
|
- A reply may hold several blocks, each with its own id. Each block is a separate UI: it cannot see another block's state.
|
|
38
|
-
- Never put
|
|
38
|
+
- Never put Jigs in any other fence, and never put a fence inside a block.
|
|
39
39
|
|
|
40
40
|
## Changing an earlier UI
|
|
41
41
|
- To change a UI from earlier in the conversation, write a block with the same id. It shows the new version in your reply; the old one stays where it was.
|
|
42
42
|
- For a focused change, the block holds only edit blocks against that UI's latest version:
|
|
43
43
|
${EDIT_BLOCK}
|
|
44
|
-
- If the change rewrites most of the UI, put the complete updated
|
|
44
|
+
- If the change rewrites most of the UI, put the complete updated Jigs in the block instead.
|
|
45
45
|
- A new id makes a new UI.`,
|
|
46
46
|
document: DOCUMENT_OUTPUT
|
|
47
47
|
};
|
|
@@ -201,7 +201,7 @@ function actionSection(name, procedure, names) {
|
|
|
201
201
|
].join("\n");
|
|
202
202
|
}
|
|
203
203
|
const RECIPES_INTRO = `## Recipes
|
|
204
|
-
Components written in
|
|
204
|
+
Components written in Jigs for this app. Use them like any tag, with the props shown; a bare prop is required. They are already defined: never write their <define>. Prefer a recipe over building the same thing from components.`;
|
|
205
205
|
function recipeSection(entry) {
|
|
206
206
|
const lines = [`### ${recipeSignature({
|
|
207
207
|
name: entry.name,
|
|
@@ -279,9 +279,9 @@ function typesSection(heading, intro, declarations) {
|
|
|
279
279
|
].join("\n")];
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
|
-
* The system prompt for writing
|
|
282
|
+
* The system prompt for writing Jigs against `host`. In document mode
|
|
283
283
|
* (the default) every reply is one UI, as a session expects; in chat mode a
|
|
284
|
-
* reply is Markdown with UIs in fenced `
|
|
284
|
+
* reply is Markdown with UIs in fenced `jigs` blocks. Everything but the
|
|
285
285
|
* output section and the mode's design guidance is the same in both.
|
|
286
286
|
*
|
|
287
287
|
* What stays the same from turn to turn comes first, so a provider can
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/prompt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The system prompt and the repair text, rendered from a host and from diagnostics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/yoamomonstruos/
|
|
8
|
+
"url": "git+https://github.com/yoamomonstruos/jigs.git",
|
|
9
9
|
"directory": "packages/prompt"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@jigs.design/compiler": "0.1.
|
|
29
|
-
"@jigs.design/host": "0.1.
|
|
30
|
-
"@jigs.design/runtime": "0.1.
|
|
28
|
+
"@jigs.design/compiler": "0.1.2",
|
|
29
|
+
"@jigs.design/host": "0.1.2",
|
|
30
|
+
"@jigs.design/runtime": "0.1.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"zod": "^4.0.0"
|