@continuum-dev/prompts 0.1.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/LICENSE +21 -0
- package/README.md +65 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +2 -0
- package/lib/templates.d.ts +19 -0
- package/lib/templates.d.ts.map +1 -0
- package/lib/templates.js +193 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bryton Cooper
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @continuum-dev/prompts
|
|
2
|
+
|
|
3
|
+
Prompt templates and assembly helpers for Continuum AI view generation.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @continuum-dev/prompts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What this package provides
|
|
12
|
+
|
|
13
|
+
- A production-ready base system prompt
|
|
14
|
+
- Mode prompts for create, evolve, and correction loops
|
|
15
|
+
- Optional addons for attachment extraction and strict continuity
|
|
16
|
+
- Typed helpers to assemble system prompts and build user messages
|
|
17
|
+
|
|
18
|
+
## Quick usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import {
|
|
22
|
+
assembleSystemPrompt,
|
|
23
|
+
buildEvolveUserMessage,
|
|
24
|
+
type PromptMode,
|
|
25
|
+
} from '@continuum-dev/prompts';
|
|
26
|
+
|
|
27
|
+
const mode: PromptMode = 'evolve-view';
|
|
28
|
+
|
|
29
|
+
const systemPrompt = assembleSystemPrompt({
|
|
30
|
+
mode,
|
|
31
|
+
addons: ['strict-continuity'],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const userMessage = buildEvolveUserMessage({
|
|
35
|
+
currentView,
|
|
36
|
+
instruction: 'Add co-borrower employment and preserve semantic keys.',
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Exports
|
|
41
|
+
|
|
42
|
+
- `PROMPT_LIBRARY_VERSION`
|
|
43
|
+
- `PROMPT_LIBRARY`
|
|
44
|
+
- `SYSTEM_CORE`
|
|
45
|
+
- `MODE_CREATE_VIEW`
|
|
46
|
+
- `MODE_EVOLVE_VIEW`
|
|
47
|
+
- `MODE_CORRECTION_LOOP`
|
|
48
|
+
- `ADDON_ATTACHMENTS`
|
|
49
|
+
- `ADDON_STRICT_CONTINUITY`
|
|
50
|
+
- `assembleSystemPrompt`
|
|
51
|
+
- `buildCreateUserMessage`
|
|
52
|
+
- `buildEvolveUserMessage`
|
|
53
|
+
- `buildCorrectionUserMessage`
|
|
54
|
+
- `getModePrompt`
|
|
55
|
+
- `getAddonPrompt`
|
|
56
|
+
|
|
57
|
+
## Recommended request metadata
|
|
58
|
+
|
|
59
|
+
Store this with each model request:
|
|
60
|
+
|
|
61
|
+
- `promptVersion`
|
|
62
|
+
- `mode`
|
|
63
|
+
- enabled addons list
|
|
64
|
+
|
|
65
|
+
This makes prompt behavior auditable and easier to tune.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './lib/types.js';
|
|
2
|
+
export { ADDON_ATTACHMENTS, ADDON_STRICT_CONTINUITY, EXAMPLE_CORRECTION_LOOP_USER_MESSAGE, EXAMPLE_CREATE_VIEW_USER_MESSAGE, EXAMPLE_EVOLVE_VIEW_USER_MESSAGE, MODE_CORRECTION_LOOP, MODE_CREATE_VIEW, MODE_EVOLVE_VIEW, PROMPT_LIBRARY, PROMPT_LIBRARY_VERSION, SYSTEM_CORE, assembleSystemPrompt, buildCorrectionUserMessage, buildCreateUserMessage, buildEvolveUserMessage, getAddonPrompt, getModePrompt, } from './lib/templates.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/prompts/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,oCAAoC,EACpC,gCAAgC,EAChC,gCAAgC,EAChC,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from './lib/types.js';
|
|
2
|
+
export { ADDON_ATTACHMENTS, ADDON_STRICT_CONTINUITY, EXAMPLE_CORRECTION_LOOP_USER_MESSAGE, EXAMPLE_CREATE_VIEW_USER_MESSAGE, EXAMPLE_EVOLVE_VIEW_USER_MESSAGE, MODE_CORRECTION_LOOP, MODE_CREATE_VIEW, MODE_EVOLVE_VIEW, PROMPT_LIBRARY, PROMPT_LIBRARY_VERSION, SYSTEM_CORE, assembleSystemPrompt, buildCorrectionUserMessage, buildCreateUserMessage, buildEvolveUserMessage, getAddonPrompt, getModePrompt, } from './lib/templates.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AssembleSystemPromptArgs, BuildUserMessageArgs, PromptAddon, PromptLibrary, PromptMode } from './types.js';
|
|
2
|
+
export declare const PROMPT_LIBRARY_VERSION = "2026-03-06.1";
|
|
3
|
+
export declare const SYSTEM_CORE = "You generate Continuum ViewDefinition JSON.\n\nOutput requirements:\n- Return JSON only (no markdown, no commentary).\n- Top-level shape:\n {\n \"viewId\": string,\n \"version\": string,\n \"nodes\": ViewNode[]\n }\n\nCore continuity rules:\n- Keep viewId stable for the same logical workflow.\n- Change version when structure changes.\n- Keep node ids unique in the full tree.\n- Keep semantic keys stable across versions when meaning is unchanged.\n- Preserve unchanged semantics whenever possible.\n\nRendering constraints:\n- Only use node types that this app explicitly supports.\n- Include required fields for each node type.\n- For option-based nodes, include options as [{ \"value\": string, \"label\": string }].\n- For collection nodes, include a valid template node.";
|
|
4
|
+
export declare const MODE_CREATE_VIEW = "Mode: Create a brand-new view from user intent.\n\nGuidance:\n- Optimize for clarity and completion of the user task.\n- Choose a layout that fits the task and data complexity.\n- Include labels and sensible defaults when helpful.\n- Prefer semantic keys that remain meaningful in future versions.\n\nFor this app, supported node types are:\n- field (requires dataType: string | number | boolean)\n- textarea\n- date\n- select (requires options)\n- radio-group (requires options)\n- slider (requires min and max)\n- toggle\n- action (requires intentId and label)\n- group (requires children)\n- row (requires children)\n- grid (requires children, optional columns)\n- collection (requires template, optional defaultValues)\n- presentation (requires contentType and content)\n\nIf uncertain:\n- Use simple, explicit structures first.\n- Avoid creating deeply nested trees unless clearly beneficial.";
|
|
5
|
+
export declare const MODE_EVOLVE_VIEW = "Mode: Evolve an existing view.\n\nInput context will include:\n- currentView JSON\n- user instruction describing changes\n\nGuidance:\n- Evolve currentView instead of regenerating from scratch.\n- Preserve semantic continuity when meaning is unchanged.\n- Keep stable keys for unchanged semantics.\n- You may restructure layout containers when useful.\n- If semantics change, update key/type intentionally and clearly.\n\nContinuity preferences:\n- Preserve existing node ids when possible.\n- If id changes, keep key stable when semantics are unchanged.\n- Avoid unnecessary key churn.\n\nOutput:\n- Full next ViewDefinition JSON.";
|
|
6
|
+
export declare const MODE_CORRECTION_LOOP = "Mode: Correct a rejected or problematic view.\n\nInput context will include:\n- currentView JSON\n- original instruction\n- validation errors\n- runtime errors\n- detached node ids (if any)\n\nCorrection goals:\n- Resolve all listed validation and runtime errors.\n- Preserve semantic keys for unchanged fields.\n- Avoid duplicate ids and duplicate scoped keys.\n- Reduce detached outcomes unless semantics truly changed.\n\nOutput requirements:\n- Return a corrected full ViewDefinition.\n- Keep only relevant structural changes needed to resolve errors.";
|
|
7
|
+
export declare const ADDON_ATTACHMENTS = "Attachment extraction addon.\n\nWhen attachments (documents/images) are present:\n- Extract known values and populate defaultValue/defaultValues when confidence is high.\n- Do not invent uncertain values.\n- Use placeholder as hint text only, not as extracted data storage.\n\nField-specific rules:\n- date values should be YYYY-MM-DD.\n- select/radio-group defaultValue should be one of the option values.\n- collection defaultValues should include one entry per extracted line item.";
|
|
8
|
+
export declare const ADDON_STRICT_CONTINUITY = "Strict continuity addon.\n\nApply stronger bias toward continuity:\n- Do not change keys for unchanged semantic meaning.\n- Do not change node type for unchanged semantic meaning.\n- Do not remove existing fields unless the user explicitly requests removal.\n- Do not split or merge collections unless explicitly requested.\n\nAllowed flexibility:\n- Layout container changes are allowed when semantics are preserved.\n- New fields can be added when clearly requested or required.";
|
|
9
|
+
export declare const EXAMPLE_CREATE_VIEW_USER_MESSAGE = "Create a mortgage intake form for first-time home buyers.\n\nRequirements:\n- Capture borrower identity, contact info, employment, income, assets, liabilities.\n- Include a co-borrower section that can stay hidden until user enables it.\n- Include a collection for liabilities with creditor, balance, monthlyPayment.\n- Include one action node for \"submit_prequal\".\n\nKeep the structure understandable for non-technical users.";
|
|
10
|
+
export declare const EXAMPLE_EVOLVE_VIEW_USER_MESSAGE = "Current view is provided.\n\nPlease evolve it with these changes:\n- Add a co-borrower employment subsection.\n- Add a date field for lease_end_date in housing details.\n- Keep all existing semantic keys for unchanged meaning.\n- Keep action intent ids unchanged.\n\nYou may adjust layout containers if needed.";
|
|
11
|
+
export declare const EXAMPLE_CORRECTION_LOOP_USER_MESSAGE = "Current view and diagnostics are provided.\n\nRegenerate a corrected full view that:\n- resolves all validation errors\n- resolves runtime errors\n- avoids duplicate ids and duplicate scoped keys\n- preserves semantic keys and node types for unchanged meaning\n\nDo not make unrelated structural changes.";
|
|
12
|
+
export declare const PROMPT_LIBRARY: PromptLibrary;
|
|
13
|
+
export declare function assembleSystemPrompt(args: AssembleSystemPromptArgs): string;
|
|
14
|
+
export declare function buildCreateUserMessage(instruction: string): string;
|
|
15
|
+
export declare function buildEvolveUserMessage(args: BuildUserMessageArgs): string;
|
|
16
|
+
export declare function buildCorrectionUserMessage(args: BuildUserMessageArgs): string;
|
|
17
|
+
export declare function getModePrompt(mode: PromptMode): string;
|
|
18
|
+
export declare function getAddonPrompt(addon: PromptAddon): string;
|
|
19
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../packages/prompts/src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,eAAO,MAAM,WAAW,yxBAsB+B,CAAC;AAExD,eAAO,MAAM,gBAAgB,s4BAyBmC,CAAC;AAEjE,eAAO,MAAM,gBAAgB,4nBAmBI,CAAC;AAElC,eAAO,MAAM,oBAAoB,gjBAiBiC,CAAC;AAEnE,eAAO,MAAM,iBAAiB,yeAU+C,CAAC;AAE9E,eAAO,MAAM,uBAAuB,qeAU0B,CAAC;AAE/D,eAAO,MAAM,gCAAgC,kbAQc,CAAC;AAE5D,eAAO,MAAM,gCAAgC,2TAQD,CAAC;AAE7C,eAAO,MAAM,oCAAoC,qTAQP,CAAC;AAE3C,eAAO,MAAM,cAAc,EAAE,aAY5B,CAAC;AAMF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,MAAM,CAM3E;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CASzE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAgB7E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEzD"}
|
package/lib/templates.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export const PROMPT_LIBRARY_VERSION = '2026-03-06.1';
|
|
2
|
+
export const SYSTEM_CORE = `You generate Continuum ViewDefinition JSON.
|
|
3
|
+
|
|
4
|
+
Output requirements:
|
|
5
|
+
- Return JSON only (no markdown, no commentary).
|
|
6
|
+
- Top-level shape:
|
|
7
|
+
{
|
|
8
|
+
"viewId": string,
|
|
9
|
+
"version": string,
|
|
10
|
+
"nodes": ViewNode[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Core continuity rules:
|
|
14
|
+
- Keep viewId stable for the same logical workflow.
|
|
15
|
+
- Change version when structure changes.
|
|
16
|
+
- Keep node ids unique in the full tree.
|
|
17
|
+
- Keep semantic keys stable across versions when meaning is unchanged.
|
|
18
|
+
- Preserve unchanged semantics whenever possible.
|
|
19
|
+
|
|
20
|
+
Rendering constraints:
|
|
21
|
+
- Only use node types that this app explicitly supports.
|
|
22
|
+
- Include required fields for each node type.
|
|
23
|
+
- For option-based nodes, include options as [{ "value": string, "label": string }].
|
|
24
|
+
- For collection nodes, include a valid template node.`;
|
|
25
|
+
export const MODE_CREATE_VIEW = `Mode: Create a brand-new view from user intent.
|
|
26
|
+
|
|
27
|
+
Guidance:
|
|
28
|
+
- Optimize for clarity and completion of the user task.
|
|
29
|
+
- Choose a layout that fits the task and data complexity.
|
|
30
|
+
- Include labels and sensible defaults when helpful.
|
|
31
|
+
- Prefer semantic keys that remain meaningful in future versions.
|
|
32
|
+
|
|
33
|
+
For this app, supported node types are:
|
|
34
|
+
- field (requires dataType: string | number | boolean)
|
|
35
|
+
- textarea
|
|
36
|
+
- date
|
|
37
|
+
- select (requires options)
|
|
38
|
+
- radio-group (requires options)
|
|
39
|
+
- slider (requires min and max)
|
|
40
|
+
- toggle
|
|
41
|
+
- action (requires intentId and label)
|
|
42
|
+
- group (requires children)
|
|
43
|
+
- row (requires children)
|
|
44
|
+
- grid (requires children, optional columns)
|
|
45
|
+
- collection (requires template, optional defaultValues)
|
|
46
|
+
- presentation (requires contentType and content)
|
|
47
|
+
|
|
48
|
+
If uncertain:
|
|
49
|
+
- Use simple, explicit structures first.
|
|
50
|
+
- Avoid creating deeply nested trees unless clearly beneficial.`;
|
|
51
|
+
export const MODE_EVOLVE_VIEW = `Mode: Evolve an existing view.
|
|
52
|
+
|
|
53
|
+
Input context will include:
|
|
54
|
+
- currentView JSON
|
|
55
|
+
- user instruction describing changes
|
|
56
|
+
|
|
57
|
+
Guidance:
|
|
58
|
+
- Evolve currentView instead of regenerating from scratch.
|
|
59
|
+
- Preserve semantic continuity when meaning is unchanged.
|
|
60
|
+
- Keep stable keys for unchanged semantics.
|
|
61
|
+
- You may restructure layout containers when useful.
|
|
62
|
+
- If semantics change, update key/type intentionally and clearly.
|
|
63
|
+
|
|
64
|
+
Continuity preferences:
|
|
65
|
+
- Preserve existing node ids when possible.
|
|
66
|
+
- If id changes, keep key stable when semantics are unchanged.
|
|
67
|
+
- Avoid unnecessary key churn.
|
|
68
|
+
|
|
69
|
+
Output:
|
|
70
|
+
- Full next ViewDefinition JSON.`;
|
|
71
|
+
export const MODE_CORRECTION_LOOP = `Mode: Correct a rejected or problematic view.
|
|
72
|
+
|
|
73
|
+
Input context will include:
|
|
74
|
+
- currentView JSON
|
|
75
|
+
- original instruction
|
|
76
|
+
- validation errors
|
|
77
|
+
- runtime errors
|
|
78
|
+
- detached node ids (if any)
|
|
79
|
+
|
|
80
|
+
Correction goals:
|
|
81
|
+
- Resolve all listed validation and runtime errors.
|
|
82
|
+
- Preserve semantic keys for unchanged fields.
|
|
83
|
+
- Avoid duplicate ids and duplicate scoped keys.
|
|
84
|
+
- Reduce detached outcomes unless semantics truly changed.
|
|
85
|
+
|
|
86
|
+
Output requirements:
|
|
87
|
+
- Return a corrected full ViewDefinition.
|
|
88
|
+
- Keep only relevant structural changes needed to resolve errors.`;
|
|
89
|
+
export const ADDON_ATTACHMENTS = `Attachment extraction addon.
|
|
90
|
+
|
|
91
|
+
When attachments (documents/images) are present:
|
|
92
|
+
- Extract known values and populate defaultValue/defaultValues when confidence is high.
|
|
93
|
+
- Do not invent uncertain values.
|
|
94
|
+
- Use placeholder as hint text only, not as extracted data storage.
|
|
95
|
+
|
|
96
|
+
Field-specific rules:
|
|
97
|
+
- date values should be YYYY-MM-DD.
|
|
98
|
+
- select/radio-group defaultValue should be one of the option values.
|
|
99
|
+
- collection defaultValues should include one entry per extracted line item.`;
|
|
100
|
+
export const ADDON_STRICT_CONTINUITY = `Strict continuity addon.
|
|
101
|
+
|
|
102
|
+
Apply stronger bias toward continuity:
|
|
103
|
+
- Do not change keys for unchanged semantic meaning.
|
|
104
|
+
- Do not change node type for unchanged semantic meaning.
|
|
105
|
+
- Do not remove existing fields unless the user explicitly requests removal.
|
|
106
|
+
- Do not split or merge collections unless explicitly requested.
|
|
107
|
+
|
|
108
|
+
Allowed flexibility:
|
|
109
|
+
- Layout container changes are allowed when semantics are preserved.
|
|
110
|
+
- New fields can be added when clearly requested or required.`;
|
|
111
|
+
export const EXAMPLE_CREATE_VIEW_USER_MESSAGE = `Create a mortgage intake form for first-time home buyers.
|
|
112
|
+
|
|
113
|
+
Requirements:
|
|
114
|
+
- Capture borrower identity, contact info, employment, income, assets, liabilities.
|
|
115
|
+
- Include a co-borrower section that can stay hidden until user enables it.
|
|
116
|
+
- Include a collection for liabilities with creditor, balance, monthlyPayment.
|
|
117
|
+
- Include one action node for "submit_prequal".
|
|
118
|
+
|
|
119
|
+
Keep the structure understandable for non-technical users.`;
|
|
120
|
+
export const EXAMPLE_EVOLVE_VIEW_USER_MESSAGE = `Current view is provided.
|
|
121
|
+
|
|
122
|
+
Please evolve it with these changes:
|
|
123
|
+
- Add a co-borrower employment subsection.
|
|
124
|
+
- Add a date field for lease_end_date in housing details.
|
|
125
|
+
- Keep all existing semantic keys for unchanged meaning.
|
|
126
|
+
- Keep action intent ids unchanged.
|
|
127
|
+
|
|
128
|
+
You may adjust layout containers if needed.`;
|
|
129
|
+
export const EXAMPLE_CORRECTION_LOOP_USER_MESSAGE = `Current view and diagnostics are provided.
|
|
130
|
+
|
|
131
|
+
Regenerate a corrected full view that:
|
|
132
|
+
- resolves all validation errors
|
|
133
|
+
- resolves runtime errors
|
|
134
|
+
- avoids duplicate ids and duplicate scoped keys
|
|
135
|
+
- preserves semantic keys and node types for unchanged meaning
|
|
136
|
+
|
|
137
|
+
Do not make unrelated structural changes.`;
|
|
138
|
+
export const PROMPT_LIBRARY = {
|
|
139
|
+
version: PROMPT_LIBRARY_VERSION,
|
|
140
|
+
base: SYSTEM_CORE,
|
|
141
|
+
modes: {
|
|
142
|
+
'create-view': MODE_CREATE_VIEW,
|
|
143
|
+
'evolve-view': MODE_EVOLVE_VIEW,
|
|
144
|
+
'correction-loop': MODE_CORRECTION_LOOP,
|
|
145
|
+
},
|
|
146
|
+
addons: {
|
|
147
|
+
attachments: ADDON_ATTACHMENTS,
|
|
148
|
+
'strict-continuity': ADDON_STRICT_CONTINUITY,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
function uniqueAddons(addons = []) {
|
|
152
|
+
return Array.from(new Set(addons));
|
|
153
|
+
}
|
|
154
|
+
export function assembleSystemPrompt(args) {
|
|
155
|
+
const sections = [PROMPT_LIBRARY.base, PROMPT_LIBRARY.modes[args.mode]];
|
|
156
|
+
for (const addon of uniqueAddons(args.addons)) {
|
|
157
|
+
sections.push(PROMPT_LIBRARY.addons[addon]);
|
|
158
|
+
}
|
|
159
|
+
return sections.join('\n\n');
|
|
160
|
+
}
|
|
161
|
+
export function buildCreateUserMessage(instruction) {
|
|
162
|
+
return instruction.trim();
|
|
163
|
+
}
|
|
164
|
+
export function buildEvolveUserMessage(args) {
|
|
165
|
+
if (typeof args.currentView === 'undefined') {
|
|
166
|
+
throw new Error('buildEvolveUserMessage requires currentView');
|
|
167
|
+
}
|
|
168
|
+
return [
|
|
169
|
+
`Current view:\n${JSON.stringify(args.currentView, null, 2)}`,
|
|
170
|
+
`Instruction:\n${args.instruction.trim()}`,
|
|
171
|
+
].join('\n\n');
|
|
172
|
+
}
|
|
173
|
+
export function buildCorrectionUserMessage(args) {
|
|
174
|
+
if (typeof args.currentView === 'undefined') {
|
|
175
|
+
throw new Error('buildCorrectionUserMessage requires currentView');
|
|
176
|
+
}
|
|
177
|
+
const validationErrors = args.validationErrors ?? [];
|
|
178
|
+
const runtimeErrors = args.runtimeErrors ?? [];
|
|
179
|
+
const detachedNodeIds = args.detachedNodeIds ?? [];
|
|
180
|
+
return [
|
|
181
|
+
`Current view:\n${JSON.stringify(args.currentView, null, 2)}`,
|
|
182
|
+
`Instruction:\n${args.instruction.trim()}`,
|
|
183
|
+
`Validation errors:\n${validationErrors.length > 0 ? validationErrors.join('\n') : 'none'}`,
|
|
184
|
+
`Runtime errors:\n${runtimeErrors.length > 0 ? runtimeErrors.join(', ') : 'none'}`,
|
|
185
|
+
`Detached node ids:\n${detachedNodeIds.length > 0 ? detachedNodeIds.join(', ') : 'none'}`,
|
|
186
|
+
].join('\n\n');
|
|
187
|
+
}
|
|
188
|
+
export function getModePrompt(mode) {
|
|
189
|
+
return PROMPT_LIBRARY.modes[mode];
|
|
190
|
+
}
|
|
191
|
+
export function getAddonPrompt(addon) {
|
|
192
|
+
return PROMPT_LIBRARY.addons[addon];
|
|
193
|
+
}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type PromptMode = 'create-view' | 'evolve-view' | 'correction-loop';
|
|
2
|
+
export type PromptAddon = 'attachments' | 'strict-continuity';
|
|
3
|
+
export interface PromptLibrary {
|
|
4
|
+
version: string;
|
|
5
|
+
base: string;
|
|
6
|
+
modes: Record<PromptMode, string>;
|
|
7
|
+
addons: Record<PromptAddon, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface AssembleSystemPromptArgs {
|
|
10
|
+
mode: PromptMode;
|
|
11
|
+
addons?: PromptAddon[];
|
|
12
|
+
}
|
|
13
|
+
export interface BuildUserMessageArgs {
|
|
14
|
+
currentView?: unknown;
|
|
15
|
+
instruction: string;
|
|
16
|
+
validationErrors?: string[];
|
|
17
|
+
runtimeErrors?: string[];
|
|
18
|
+
detachedNodeIds?: string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/prompts/src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B"}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@continuum-dev/prompts",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Prompt templates and helpers for Continuum AI view generation",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/brytoncooper/cooper-continuum.git",
|
|
12
|
+
"directory": "packages/prompts"
|
|
13
|
+
},
|
|
14
|
+
"author": "Bryton Cooper",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"continuum",
|
|
17
|
+
"ai",
|
|
18
|
+
"prompt",
|
|
19
|
+
"viewdefinition",
|
|
20
|
+
"reconciliation"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "./index.js",
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./index.d.ts",
|
|
29
|
+
"import": "./index.js",
|
|
30
|
+
"default": "./index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"**/*.js",
|
|
35
|
+
"**/*.d.ts",
|
|
36
|
+
"**/*.d.ts.map",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE*"
|
|
39
|
+
]
|
|
40
|
+
}
|