@jigs.design/prompt 0.3.0 → 0.3.1
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/system-prompt.d.ts +4 -4
- package/dist/system-prompt.js +19 -6
- package/package.json +4 -4
package/dist/system-prompt.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export interface PromptOptions {
|
|
|
22
22
|
* cache it as a prefix: the output rules, the language, the catalog's
|
|
23
23
|
* types and components, the app's tags, the design guidance and situations.
|
|
24
24
|
* What a turn may change comes last: the app's `instructions`, the
|
|
25
|
-
* procedures' own types, the queries, mutations and actions,
|
|
26
|
-
* procedure enum the catalog already names keeps that name;
|
|
27
|
-
* named among the procedures alone, so changing them never
|
|
28
|
-
* prefix.
|
|
25
|
+
* procedures' own types, the queries, provided data, mutations and actions,
|
|
26
|
+
* and images. A procedure enum the catalog already names keeps that name;
|
|
27
|
+
* the others are named among the procedures alone, so changing them never
|
|
28
|
+
* changes the prefix.
|
|
29
29
|
*/
|
|
30
30
|
export declare function systemPrompt(host: Host, options?: PromptOptions): string;
|
|
31
31
|
/** The system prompt in two parts: what stays the same from turn to turn, and the rest. */
|
package/dist/system-prompt.js
CHANGED
|
@@ -76,7 +76,8 @@ const LANGUAGE = `## Rules
|
|
|
76
76
|
- The body sees only its props, its own \`{@body}\` lines and other components. It does not see the document's state; pass values in as props, with a setter if the component should change them.
|
|
77
77
|
- In a list, give each instance a \`key\` (\`<stat key={item.id}/>\`), on the component inside \`<each>\`, not on \`<each>\`, or repeat items that have an \`id\`, so that state stays put when the list changes.`;
|
|
78
78
|
const NO_PROCEDURES = `## Data and actions
|
|
79
|
-
- This app registered no queries or mutations. Do not call \`useQuery\` or \`useMutation\`; keep everything in state
|
|
79
|
+
- This app registered no queries or mutations. Do not call \`useQuery\` or \`useMutation\`; keep everything in state.
|
|
80
|
+
- Data given in the request itself: write it in \`{@body}\` as literal values and show it. No data given, and the ask is about the user's own records (their accounts, orders, balances): show the UI with placeholders and say what is missing; never invent their numbers, names or records. Content the ask asks you to make, such as a recipe, a quiz, an FAQ or example rows, is yours to write.`;
|
|
80
81
|
const HOOKS = `## Data and actions
|
|
81
82
|
- \`{@body const orders = useQuery("orders", { status: "open" })}\` reads a query listed below while rendering. It returns \`{ status, data, error }\`: status is "pending", "success" or "error"; \`data\` is null until "success"; \`error\` is \`{ code, message }\`. Show each status with \`<if>\`. There is no \`isLoading\` and no \`refetch\`.
|
|
82
83
|
- Calls with the same name and input share one request. Pass submitted values, not live keystrokes: keep a text field in state and copy it into the query's input on Enter or a button.
|
|
@@ -86,7 +87,7 @@ const HOOKS = `## Data and actions
|
|
|
86
87
|
- After a mutation succeeds, the queries listed under "Refreshes" reload by themselves. Write nothing to make that happen.
|
|
87
88
|
- An action listed below is called the same way, with \`useMutation("name")\` and \`mutate(input)\` in a handler. The page handles it instead of the server, for example by sending a message; its handle has the same \`status\`, \`data\` and \`error\`.
|
|
88
89
|
- The first argument is always the name as a string literal. Never write \`useQuery({ queryKey, queryFn })\`.
|
|
89
|
-
-
|
|
90
|
+
- Where a UI's data comes from, in this order. A query or provided slot listed below that covers the ask: read it with \`useQuery\` and show what it returns, and never write its values into the UI yourself, not even as an example. Data given in the request itself that no listed name covers: write it in \`{@body}\` as literal values and show it. Neither, and the ask is about the user's own records (their accounts, orders, balances): show the UI with placeholders and say what is missing; never invent their numbers, names or records. Content the ask asks you to make, such as a recipe, a quiz, an FAQ or example rows, is yours to write.
|
|
90
91
|
- Inputs and data are TypeScript-like types. A \`//\` comment gives a field's meaning and limits; follow them when you build an input.`;
|
|
91
92
|
const COMPONENTS_INTRO = `## Components
|
|
92
93
|
Each prop is \`name: type = default\`, then what it does. Leave a prop out to get its default.
|
|
@@ -203,6 +204,16 @@ function actionSection(name, procedure, names) {
|
|
|
203
204
|
"Handled by the page, not the server. Refreshes nothing."
|
|
204
205
|
].join("\n");
|
|
205
206
|
}
|
|
207
|
+
const PROVIDED_INTRO = `## Provided data
|
|
208
|
+
The app supplies these when it shows the UI. Read one with \`useQuery("name")\`; it takes no input and is never stale on your side.`;
|
|
209
|
+
function slotSection(name, procedure, names) {
|
|
210
|
+
return [
|
|
211
|
+
`### ${name}`,
|
|
212
|
+
procedure.description,
|
|
213
|
+
`Call: useQuery("${name}")`,
|
|
214
|
+
`Data: ${typeText(procedure.output, "output", names)}`
|
|
215
|
+
].join("\n");
|
|
216
|
+
}
|
|
206
217
|
const TAGS_INTRO = `## App tags
|
|
207
218
|
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.`;
|
|
208
219
|
function tagSection(entry) {
|
|
@@ -291,10 +302,10 @@ function typesSection(heading, intro, declarations) {
|
|
|
291
302
|
* cache it as a prefix: the output rules, the language, the catalog's
|
|
292
303
|
* types and components, the app's tags, the design guidance and situations.
|
|
293
304
|
* What a turn may change comes last: the app's `instructions`, the
|
|
294
|
-
* procedures' own types, the queries, mutations and actions,
|
|
295
|
-
* procedure enum the catalog already names keeps that name;
|
|
296
|
-
* named among the procedures alone, so changing them never
|
|
297
|
-
* prefix.
|
|
305
|
+
* procedures' own types, the queries, provided data, mutations and actions,
|
|
306
|
+
* and images. A procedure enum the catalog already names keeps that name;
|
|
307
|
+
* the others are named among the procedures alone, so changing them never
|
|
308
|
+
* changes the prefix.
|
|
298
309
|
*/
|
|
299
310
|
function systemPrompt(host, options) {
|
|
300
311
|
const parts = systemPromptParts(host, options);
|
|
@@ -332,6 +343,8 @@ function systemPromptParts(host, options) {
|
|
|
332
343
|
if (instructions !== "") variable.push(`## App instructions\n${instructions}`);
|
|
333
344
|
variable.push(...typesSection("## Data types", "Named lists of values and objects, used by the queries and mutations below.", [...dataTypes.declarations, ...objectTypes.declarations]));
|
|
334
345
|
if (queries.length > 0) variable.push(["## Queries", ...queries.map(([name, procedure]) => procedureSection(name, procedure, names))].join("\n\n"));
|
|
346
|
+
const slots = entries.flatMap(([name, procedure]) => procedure.kind === "data" ? [slotSection(name, procedure, names)] : []);
|
|
347
|
+
if (slots.length > 0) variable.push([PROVIDED_INTRO, ...slots].join("\n\n"));
|
|
335
348
|
if (mutations.length > 0) variable.push(["## Mutations", ...mutations.map(([name, procedure]) => procedureSection(name, procedure, names))].join("\n\n"));
|
|
336
349
|
const actions = entries.flatMap(([name, procedure]) => procedure.kind === "action" ? [actionSection(name, procedure, names)] : []);
|
|
337
350
|
if (actions.length > 0) variable.push(["## Actions", ...actions].join("\n\n"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/prompt",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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.1",
|
|
29
|
+
"@jigs.design/host": "0.3.1",
|
|
30
|
+
"@jigs.design/protocol": "0.3.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"zod": "^4.0.0"
|