@agentkit-js/agent-prompts 0.2.0

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 ADDED
@@ -0,0 +1,186 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as defined by the copyright owner,
48
+ any work of authorship, including the original version of the Work and
49
+ any modifications or additions to that Work or Derivative Works of the
50
+ Work, that is intentionally submitted to the Licensor for inclusion in
51
+ the Work by the copyright owner or by an individual or Legal Entity
52
+ authorized to submit on behalf of the copyright owner. For the purposes
53
+ of this definition, "submitted" means any form of electronic, verbal,
54
+ or written communication sent to the Licensor or its representatives,
55
+ including but not limited to communication on electronic mailing lists,
56
+ source code control systems, and issue tracking systems that are
57
+ managed by, or on behalf of, the Licensor for the purpose of
58
+ discussing and improving the Work, but excluding communication that is
59
+ conspicuously marked or otherwise designated in writing by the copyright
60
+ owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
63
+ whom a Contribution has been received by the Licensor and included
64
+ within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by the combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a cross-claim
83
+ or counterclaim in a lawsuit) alleging that the Work or any
84
+ Contribution embodied within the Work constitutes patent or
85
+ contributory patent infringement, then any patent licenses granted
86
+ to You under this License for that Work shall terminate as of the date
87
+ such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, You must include a readable copy of the
108
+ attribution notices contained within such NOTICE file, in
109
+ at least one of the following places: within a NOTICE text
110
+ file distributed as part of the Derivative Works; within
111
+ the Source form or documentation, if provided along with the
112
+ Derivative Works; or, within a display generated by the
113
+ Derivative Works, if and wherever such third-party notices
114
+ normally appear. The contents of the NOTICE file are for
115
+ informational purposes only and do not modify the License.
116
+ You may add Your own attribution notices within Derivative
117
+ Works that You distribute, alongside or as an addendum to
118
+ the NOTICE text from the Work, provided that such additional
119
+ attribution notices cannot be construed as modifying the License.
120
+
121
+ You may add Your own license statement for Your modifications and
122
+ may provide additional grant of rights to use, copy, modify, merge,
123
+ publish, distribute, sublicense, and/or sell copies of the
124
+ Contribution, either alone or in combination with the Work.
125
+
126
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
127
+ any Contribution intentionally submitted for inclusion in the Work
128
+ by You to the Licensor shall be under the terms and conditions of
129
+ this License, without any additional terms or conditions.
130
+ Notwithstanding the above, nothing herein shall supersede or modify
131
+ the terms of any separate license agreement you may have executed
132
+ with Licensor regarding such Contributions.
133
+
134
+ 6. Trademarks. This License does not grant permission to use the trade
135
+ names, trademarks, service marks, or product names of the Licensor,
136
+ except as required for reasonable and customary use in describing the
137
+ origin of the Work and reproducing the content of the NOTICE file.
138
+
139
+ 7. Disclaimer of Warranty. Unless required by applicable law or
140
+ agreed to in writing, Licensor provides the Work (and each
141
+ Contributor provides its Contributions) on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
143
+ implied, including, without limitation, any conditions of
144
+ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
145
+ PARTICULAR PURPOSE. You are solely responsible for determining the
146
+ appropriateness of using or reproducing the Work and assume any
147
+ risks associated with Your exercise of permissions under this License.
148
+
149
+ 8. Limitation of Liability. In no event and under no legal theory,
150
+ whether in tort (including negligence), contract, or otherwise,
151
+ unless required by applicable law (such as deliberate and grossly
152
+ negligent acts) or agreed to in writing, shall any Contributor be
153
+ liable to You for damages, including any direct, indirect, special,
154
+ incidental, or exemplary damages of any character arising as a
155
+ result of this License or out of the use or inability to use the
156
+ Work (including but not limited to damages for loss of goodwill,
157
+ work stoppage, computer failure or malfunction, or all other
158
+ commercial damages or losses), even if such Contributor has been
159
+ advised of the possibility of such damages.
160
+
161
+ 9. Accepting Warranty or Additional Liability. While redistributing
162
+ the Work or Derivative Works thereof, You may choose to offer,
163
+ and charge a fee for, acceptance of support, warranty, indemnity,
164
+ or other liability obligations and/or rights consistent with this
165
+ License. However, in accepting such obligations, You may act only
166
+ on Your own behalf and on Your sole responsibility, not on behalf
167
+ of any other Contributor, and only if You agree to indemnify,
168
+ defend, and hold each Contributor harmless for any liability
169
+ incurred by, or claims asserted against, such Contributor by reason
170
+ of your accepting any such warranty or additional liability.
171
+
172
+ END OF TERMS AND CONDITIONS
173
+
174
+ Copyright 2026 agentkit-js contributors
175
+
176
+ Licensed under the Apache License, Version 2.0 (the "License");
177
+ you may not use this file except in compliance with the License.
178
+ You may obtain a copy of the License at
179
+
180
+ http://www.apache.org/licenses/LICENSE-2.0
181
+
182
+ Unless required by applicable law or agreed to in writing, software
183
+ distributed under the License is distributed on an "AS IS" BASIS,
184
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
185
+ See the License for the specific language governing permissions and
186
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @agentkit-js/agent-prompts
2
+
3
+ Reusable system prompt templates for agentkit-js — code/tool/framework prompts with D2 + Markdown card conventions.
4
+
5
+ > Part of [agentkit-js](https://github.com/telleroutlook/agentkit-js) — a TypeScript + WASM agent runtime.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @agentkit-js/agent-prompts
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { composePrompt, codeAgentPrompt, cardConventions } from "@agentkit-js/agent-prompts";
17
+
18
+ const system = composePrompt([codeAgentPrompt(), cardConventions()]);
19
+ ```
20
+
21
+ ## License
22
+
23
+ [Apache-2.0](./LICENSE) — © agentkit-js contributors
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Prompt composer — combines fragments into a full system prompt.
3
+ *
4
+ * Use this when you want the agentkit conventions (reasoning-first,
5
+ * output contract, error recovery, card blocks) bundled into one prompt
6
+ * along with your own product-specific instructions (persona, tool
7
+ * surface, file conventions, etc.).
8
+ *
9
+ * @example
10
+ * const prompt = composePrompt({
11
+ * persona: "You are MyAgent, an expert SQL analyst.",
12
+ * fragments: [
13
+ * REASONING_FIRST,
14
+ * SANDBOX_NODE,
15
+ * OUTPUT_CONTRACT_STDOUT,
16
+ * DIAGRAMS_GENERIC,
17
+ * ERROR_RECOVERY,
18
+ * ],
19
+ * trailing: "When in doubt, prefer explicit JOINs over implicit ones.",
20
+ * });
21
+ */
22
+ export interface ComposePromptInput {
23
+ /** Opening line(s). Typically the agent's role / persona declaration. */
24
+ persona?: string;
25
+ /** Ordered list of fragments to include. Each is separated by a blank line. */
26
+ fragments?: string[];
27
+ /** Optional trailing text appended after all fragments. */
28
+ trailing?: string;
29
+ }
30
+ /**
31
+ * Compose a system prompt from a persona, ordered fragments, and an
32
+ * optional trailing block. Joins everything with double newlines.
33
+ *
34
+ * Empty / undefined sections are skipped — call sites can conditionally
35
+ * include fragments without having to filter null values themselves.
36
+ */
37
+ export declare function composePrompt(input: ComposePromptInput): string;
38
+ //# sourceMappingURL=composePrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composePrompt.d.ts","sourceRoot":"","sources":["../src/composePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAQ/D"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Prompt composer — combines fragments into a full system prompt.
3
+ *
4
+ * Use this when you want the agentkit conventions (reasoning-first,
5
+ * output contract, error recovery, card blocks) bundled into one prompt
6
+ * along with your own product-specific instructions (persona, tool
7
+ * surface, file conventions, etc.).
8
+ *
9
+ * @example
10
+ * const prompt = composePrompt({
11
+ * persona: "You are MyAgent, an expert SQL analyst.",
12
+ * fragments: [
13
+ * REASONING_FIRST,
14
+ * SANDBOX_NODE,
15
+ * OUTPUT_CONTRACT_STDOUT,
16
+ * DIAGRAMS_GENERIC,
17
+ * ERROR_RECOVERY,
18
+ * ],
19
+ * trailing: "When in doubt, prefer explicit JOINs over implicit ones.",
20
+ * });
21
+ */
22
+ /**
23
+ * Compose a system prompt from a persona, ordered fragments, and an
24
+ * optional trailing block. Joins everything with double newlines.
25
+ *
26
+ * Empty / undefined sections are skipped — call sites can conditionally
27
+ * include fragments without having to filter null values themselves.
28
+ */
29
+ export function composePrompt(input) {
30
+ const parts = [];
31
+ if (input.persona?.trim())
32
+ parts.push(input.persona.trim());
33
+ for (const f of input.fragments ?? []) {
34
+ if (f?.trim())
35
+ parts.push(f.trim());
36
+ }
37
+ if (input.trailing?.trim())
38
+ parts.push(input.trailing.trim());
39
+ return parts.join("\n\n");
40
+ }
41
+ //# sourceMappingURL=composePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composePrompt.js","sourceRoot":"","sources":["../src/composePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAWH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,EAAE,IAAI,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shared diagram + card-block rules used by every system prompt.
3
+ *
4
+ * The same set of rules is concatenated into code-agent and tool-agent
5
+ * prompts so an agent's final answer can produce structured cards
6
+ * (D2 diagrams, Markdown reports) instead of plain text or HTML.
7
+ *
8
+ * Three variants for different agent contexts:
9
+ * - {@link DIAGRAMS_GENERIC} — used by tool-agent variants
10
+ * - {@link DIAGRAMS_CODE_JS} — used by JS code-agent (no matplotlib mention)
11
+ * - {@link DIAGRAMS_CODE_PYTHON} — used by Python code-agent (mentions matplotlib for data)
12
+ */
13
+ /** Card-block rule block for tool-calling / framework agents. */
14
+ export declare const DIAGRAMS_GENERIC = "## Diagrams & Rich Content \u2014 use card blocks\nStructural diagrams \u2192 `card:d2`. Formatted docs/tables/summaries \u2192 `card:markdown`.\n\n```card:d2 <title>\ndirection: right\nA -> B\n```\n\n```card:markdown\n## Title\n| A | B |\n|---|---|\n```\n\nUse card blocks in your final answer when delivering diagrams or formatted documentation.\nUse plain code files (write_file) only for: charts needing interactivity, animations, app source files.";
15
+ /** Card-block rule block for the JS code-agent prompt. */
16
+ export declare const DIAGRAMS_CODE_JS = "## Diagrams (D2 \u2014 preferred over code)\nFor flowcharts, architecture diagrams, sequence diagrams, ER diagrams, or state machines \u2014 output a D2 card block as the final answer instead of generating HTML/SVG/Canvas code.\n\nThe final-answer string MUST be a fenced ```card:d2 block. Wrap it in a JS template literal so the fences survive:\n\n```javascript\n__finalAnswer__ = [\n \"```card:d2 Deployment Pipeline\",\n \"direction: right\",\n \"A -> B -> C\",\n \"```\"\n].join(\"\\n\");\n```\n\nUse D2 for structural diagrams. Use HTML/Canvas code only for data charts, animations, or interactive visualizations.";
17
+ /** Card-block rule block for the Python code-agent prompt. */
18
+ export declare const DIAGRAMS_CODE_PYTHON = "## Diagrams (D2 \u2014 preferred over code)\nFor flowcharts, architecture diagrams, sequence diagrams, ER diagrams, or state machines \u2014 output a D2 card block as the final answer instead of using matplotlib.\n\nThe final-answer string MUST be a fenced ```card:d2 block:\n\n```python\n__final_answer__ = \"\\n\".join([\n \"```card:d2 Deployment Pipeline\",\n \"direction: right\",\n \"A -> B -> C\",\n \"```\",\n])\n```\n\nUse matplotlib for data charts (bar/line/scatter/heatmap). Use D2 for structural/relational diagrams.";
19
+ //# sourceMappingURL=diagrams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagrams.d.ts","sourceRoot":"","sources":["../src/diagrams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,ycAe2E,CAAC;AAOzG,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,mnBAcyF,CAAC;AAEvH,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,iiBAcqE,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shared diagram + card-block rules used by every system prompt.
3
+ *
4
+ * The same set of rules is concatenated into code-agent and tool-agent
5
+ * prompts so an agent's final answer can produce structured cards
6
+ * (D2 diagrams, Markdown reports) instead of plain text or HTML.
7
+ *
8
+ * Three variants for different agent contexts:
9
+ * - {@link DIAGRAMS_GENERIC} — used by tool-agent variants
10
+ * - {@link DIAGRAMS_CODE_JS} — used by JS code-agent (no matplotlib mention)
11
+ * - {@link DIAGRAMS_CODE_PYTHON} — used by Python code-agent (mentions matplotlib for data)
12
+ */
13
+ /** Card-block rule block for tool-calling / framework agents. */
14
+ export const DIAGRAMS_GENERIC = `## Diagrams & Rich Content — use card blocks
15
+ Structural diagrams → \`card:d2\`. Formatted docs/tables/summaries → \`card:markdown\`.
16
+
17
+ \`\`\`card:d2 <title>
18
+ direction: right
19
+ A -> B
20
+ \`\`\`
21
+
22
+ \`\`\`card:markdown
23
+ ## Title
24
+ | A | B |
25
+ |---|---|
26
+ \`\`\`
27
+
28
+ Use card blocks in your final answer when delivering diagrams or formatted documentation.
29
+ Use plain code files (write_file) only for: charts needing interactivity, animations, app source files.`;
30
+ // Triple-backtick literal — used inside the prompt strings below to
31
+ // describe what the final-answer string must contain. Avoids escaping
32
+ // hell when nesting fenced blocks inside a template literal.
33
+ const FENCE = "```";
34
+ /** Card-block rule block for the JS code-agent prompt. */
35
+ export const DIAGRAMS_CODE_JS = `## Diagrams (D2 — preferred over code)
36
+ For flowcharts, architecture diagrams, sequence diagrams, ER diagrams, or state machines — output a D2 card block as the final answer instead of generating HTML/SVG/Canvas code.
37
+
38
+ The final-answer string MUST be a fenced ${FENCE}card:d2 block. Wrap it in a JS template literal so the fences survive:
39
+
40
+ ${FENCE}javascript
41
+ __finalAnswer__ = [
42
+ "${FENCE}card:d2 Deployment Pipeline",
43
+ "direction: right",
44
+ "A -> B -> C",
45
+ "${FENCE}"
46
+ ].join("\\n");
47
+ ${FENCE}
48
+
49
+ Use D2 for structural diagrams. Use HTML/Canvas code only for data charts, animations, or interactive visualizations.`;
50
+ /** Card-block rule block for the Python code-agent prompt. */
51
+ export const DIAGRAMS_CODE_PYTHON = `## Diagrams (D2 — preferred over code)
52
+ For flowcharts, architecture diagrams, sequence diagrams, ER diagrams, or state machines — output a D2 card block as the final answer instead of using matplotlib.
53
+
54
+ The final-answer string MUST be a fenced ${FENCE}card:d2 block:
55
+
56
+ ${FENCE}python
57
+ __final_answer__ = "\\n".join([
58
+ "${FENCE}card:d2 Deployment Pipeline",
59
+ "direction: right",
60
+ "A -> B -> C",
61
+ "${FENCE}",
62
+ ])
63
+ ${FENCE}
64
+
65
+ Use matplotlib for data charts (bar/line/scatter/heatmap). Use D2 for structural/relational diagrams.`;
66
+ //# sourceMappingURL=diagrams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagrams.js","sourceRoot":"","sources":["../src/diagrams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;wGAewE,CAAC;AAEzG,oEAAoE;AACpE,sEAAsE;AACtE,6DAA6D;AAC7D,MAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;2CAGW,KAAK;;EAE9C,KAAK;;KAEF,KAAK;;;KAGL,KAAK;;EAER,KAAK;;sHAE+G,CAAC;AAEvH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;2CAGO,KAAK;;EAE9C,KAAK;;OAEA,KAAK;;;OAGL,KAAK;;EAEV,KAAK;;sGAE+F,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Reusable prompt fragments — atomic building blocks an agent author can
3
+ * combine via {@link composePrompt} into a full system prompt.
4
+ *
5
+ * Fragments are intentionally product-agnostic. They encode patterns the
6
+ * field has converged on (reasoning-first, output contracts, error
7
+ * recovery) without prescribing a particular agent persona, sandbox
8
+ * convention, or tool surface.
9
+ *
10
+ * To embed product-specific instructions (custom planning tags, framework
11
+ * file conventions, persona declarations), compose these fragments with
12
+ * your own text via {@link composePrompt} in your product code.
13
+ */
14
+ /**
15
+ * "Think before you act" preamble. Reduces wrong-direction runs by
16
+ * forcing the model to state an approach before producing output.
17
+ */
18
+ export declare const REASONING_FIRST = "## Approach (Reasoning-First)\nBefore producing output, briefly state:\n- What the task requires\n- Your approach / algorithm\n- The expected output shape\n\nThen proceed.";
19
+ /**
20
+ * Stronger planning preamble — forces a structured plan with named
21
+ * sections. Useful for code-generation tasks that touch multiple files.
22
+ */
23
+ export declare const STRUCTURED_PLAN = "## Phase 1: Plan\nBefore writing any code, output a plan with these sections:\n- **Goal:** the user's intent restated\n- **Inputs:** what data / files / context you need\n- **Outputs:** what you will produce\n- **Steps:** ordered list of operations\n\n## Phase 2: Execute\nCarry out the plan, deviating only when a step turns out infeasible.";
24
+ /**
25
+ * Output contract for code-executing agents that need to signal a final
26
+ * value to the kernel. Used by CodeAgent + Pyodide / QuickJS kernels.
27
+ */
28
+ export declare const OUTPUT_CONTRACT_FINAL_ANSWER = "## Output Contract\n- Set `__finalAnswer__ = <value>` with the final result\n- For data/computations: `__finalAnswer__` = the computed value (number, array, object, string)\n- For HTML/CSS/JS source: build as a template literal string, set `__finalAnswer__` = htmlString\n- Aliases: `__final_answer__` = ... also works";
29
+ /**
30
+ * Output contract for stdout-capturing kernels (Node, shell). The last
31
+ * non-empty line of stdout is treated as the answer.
32
+ */
33
+ export declare const OUTPUT_CONTRACT_STDOUT = "## Output Contract\n- Print the final result to stdout \u2014 last non-empty line is captured as the answer\n- For structured data: print JSON via `JSON.stringify(result)` (or the language equivalent)\n- For text/explanation: print plain text\n- Use stderr for debug; it is not captured as the answer";
34
+ export declare const CODE_QUALITY_GENERIC = "## Code Quality\n- Clear, descriptive identifiers (no single-letter names except loop indices)\n- Comment non-obvious logic only \u2014 don't restate what the code says\n- Handle the edge cases the input could realistically hit (empty / null / oversized)\n- Fail fast with clear error messages when an invariant is violated";
35
+ export declare const CODE_QUALITY_TYPESCRIPT = "## Code Quality (TypeScript)\n- TypeScript strict mode for all .ts/.tsx files\n- No `any` \u2014 type props with interfaces, narrow unknowns explicitly\n- Each file \u2264 300 lines; split into modules when longer\n- Wrap async operations in try/catch with typed error handling";
36
+ export declare const ERROR_RECOVERY = "## Error Recovery\n- If a previous step failed, analyze the error before retrying\n- Don't repeat the same approach \u2014 change strategy\n- Use logging (console.log / print) to inspect intermediate values when needed";
37
+ export declare const FILE_OPS_ATOMIC = "## File Operation Rules\n- One file per tool call \u2014 never batch multiple files in a single call\n- For new files: use the write tool with complete content\n- For edits to existing files: use the patch tool when only a few lines change\n- Verify after writing: read the file back to confirm correctness when uncertain";
38
+ export declare const SANDBOX_QUICKJS = "## Sandbox Constraints\n- Pure JavaScript runtime in WebAssembly\n- No DOM, no browser APIs, no `require` / `import`, no `fetch`, no filesystem\n- Available globals: Math, JSON, Array, Object, String, Number, Date, RegExp, Map, Set, Promise\n- For multi-step problems: build the result incrementally with intermediate variables";
39
+ export declare const SANDBOX_PYODIDE = "## Sandbox Constraints\n- CPython in WebAssembly \u2014 most stdlib is available (math, json, re, itertools, collections, ...)\n- numpy, scipy, pandas, matplotlib available via `pyodide.loadPackage()` \u2014 load on demand\n- No network access, no filesystem (use in-memory data structures)\n- **No GUI libraries** (tkinter, pygame, wx, Qt, curses) \u2014 they require a desktop OS and will fail\n- For visualization, use matplotlib with the Agg backend and emit a base64 PNG";
40
+ export declare const SANDBOX_NODE = "## Sandbox\n- Full Node.js runtime: filesystem, network, npm packages on demand\n- ESM `import` syntax preferred; CommonJS `require` also works\n- For multi-step problems: build the result incrementally with intermediate variables";
41
+ //# sourceMappingURL=fragments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../src/fragments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;GAGG;AACH,eAAO,MAAM,eAAe,gLAMd,CAAC;AAEf;;;GAGG;AACH,eAAO,MAAM,eAAe,0VAQyC,CAAC;AAItE;;;GAGG;AACH,eAAO,MAAM,4BAA4B,mUAIQ,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iTAIsB,CAAC;AAI1D,eAAO,MAAM,oBAAoB,wUAImC,CAAC;AAErE,eAAO,MAAM,uBAAuB,0RAI2B,CAAC;AAIhE,eAAO,MAAM,cAAc,+NAGoD,CAAC;AAIhF,eAAO,MAAM,eAAe,sUAIqD,CAAC;AAIlF,eAAO,MAAM,eAAe,4UAI0D,CAAC;AAEvF,eAAO,MAAM,eAAe,geAKmD,CAAC;AAEhF,eAAO,MAAM,YAAY,2OAG6D,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Reusable prompt fragments — atomic building blocks an agent author can
3
+ * combine via {@link composePrompt} into a full system prompt.
4
+ *
5
+ * Fragments are intentionally product-agnostic. They encode patterns the
6
+ * field has converged on (reasoning-first, output contracts, error
7
+ * recovery) without prescribing a particular agent persona, sandbox
8
+ * convention, or tool surface.
9
+ *
10
+ * To embed product-specific instructions (custom planning tags, framework
11
+ * file conventions, persona declarations), compose these fragments with
12
+ * your own text via {@link composePrompt} in your product code.
13
+ */
14
+ // ── Reasoning preambles ──────────────────────────────────────────────────────
15
+ /**
16
+ * "Think before you act" preamble. Reduces wrong-direction runs by
17
+ * forcing the model to state an approach before producing output.
18
+ */
19
+ export const REASONING_FIRST = `## Approach (Reasoning-First)
20
+ Before producing output, briefly state:
21
+ - What the task requires
22
+ - Your approach / algorithm
23
+ - The expected output shape
24
+
25
+ Then proceed.`;
26
+ /**
27
+ * Stronger planning preamble — forces a structured plan with named
28
+ * sections. Useful for code-generation tasks that touch multiple files.
29
+ */
30
+ export const STRUCTURED_PLAN = `## Phase 1: Plan
31
+ Before writing any code, output a plan with these sections:
32
+ - **Goal:** the user's intent restated
33
+ - **Inputs:** what data / files / context you need
34
+ - **Outputs:** what you will produce
35
+ - **Steps:** ordered list of operations
36
+
37
+ ## Phase 2: Execute
38
+ Carry out the plan, deviating only when a step turns out infeasible.`;
39
+ // ── Output contracts ─────────────────────────────────────────────────────────
40
+ /**
41
+ * Output contract for code-executing agents that need to signal a final
42
+ * value to the kernel. Used by CodeAgent + Pyodide / QuickJS kernels.
43
+ */
44
+ export const OUTPUT_CONTRACT_FINAL_ANSWER = `## Output Contract
45
+ - Set \`__finalAnswer__ = <value>\` with the final result
46
+ - For data/computations: \`__finalAnswer__\` = the computed value (number, array, object, string)
47
+ - For HTML/CSS/JS source: build as a template literal string, set \`__finalAnswer__\` = htmlString
48
+ - Aliases: \`__final_answer__\` = ... also works`;
49
+ /**
50
+ * Output contract for stdout-capturing kernels (Node, shell). The last
51
+ * non-empty line of stdout is treated as the answer.
52
+ */
53
+ export const OUTPUT_CONTRACT_STDOUT = `## Output Contract
54
+ - Print the final result to stdout — last non-empty line is captured as the answer
55
+ - For structured data: print JSON via \`JSON.stringify(result)\` (or the language equivalent)
56
+ - For text/explanation: print plain text
57
+ - Use stderr for debug; it is not captured as the answer`;
58
+ // ── Code quality ─────────────────────────────────────────────────────────────
59
+ export const CODE_QUALITY_GENERIC = `## Code Quality
60
+ - Clear, descriptive identifiers (no single-letter names except loop indices)
61
+ - Comment non-obvious logic only — don't restate what the code says
62
+ - Handle the edge cases the input could realistically hit (empty / null / oversized)
63
+ - Fail fast with clear error messages when an invariant is violated`;
64
+ export const CODE_QUALITY_TYPESCRIPT = `## Code Quality (TypeScript)
65
+ - TypeScript strict mode for all .ts/.tsx files
66
+ - No \`any\` — type props with interfaces, narrow unknowns explicitly
67
+ - Each file ≤ 300 lines; split into modules when longer
68
+ - Wrap async operations in try/catch with typed error handling`;
69
+ // ── Error recovery ───────────────────────────────────────────────────────────
70
+ export const ERROR_RECOVERY = `## Error Recovery
71
+ - If a previous step failed, analyze the error before retrying
72
+ - Don't repeat the same approach — change strategy
73
+ - Use logging (console.log / print) to inspect intermediate values when needed`;
74
+ // ── File operation rules (for tool-calling agents that write files) ──────────
75
+ export const FILE_OPS_ATOMIC = `## File Operation Rules
76
+ - One file per tool call — never batch multiple files in a single call
77
+ - For new files: use the write tool with complete content
78
+ - For edits to existing files: use the patch tool when only a few lines change
79
+ - Verify after writing: read the file back to confirm correctness when uncertain`;
80
+ // ── Sandbox descriptions ─────────────────────────────────────────────────────
81
+ export const SANDBOX_QUICKJS = `## Sandbox Constraints
82
+ - Pure JavaScript runtime in WebAssembly
83
+ - No DOM, no browser APIs, no \`require\` / \`import\`, no \`fetch\`, no filesystem
84
+ - Available globals: Math, JSON, Array, Object, String, Number, Date, RegExp, Map, Set, Promise
85
+ - For multi-step problems: build the result incrementally with intermediate variables`;
86
+ export const SANDBOX_PYODIDE = `## Sandbox Constraints
87
+ - CPython in WebAssembly — most stdlib is available (math, json, re, itertools, collections, ...)
88
+ - numpy, scipy, pandas, matplotlib available via \`pyodide.loadPackage()\` — load on demand
89
+ - No network access, no filesystem (use in-memory data structures)
90
+ - **No GUI libraries** (tkinter, pygame, wx, Qt, curses) — they require a desktop OS and will fail
91
+ - For visualization, use matplotlib with the Agg backend and emit a base64 PNG`;
92
+ export const SANDBOX_NODE = `## Sandbox
93
+ - Full Node.js runtime: filesystem, network, npm packages on demand
94
+ - ESM \`import\` syntax preferred; CommonJS \`require\` also works
95
+ - For multi-step problems: build the result incrementally with intermediate variables`;
96
+ //# sourceMappingURL=fragments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragments.js","sourceRoot":"","sources":["../src/fragments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;cAMjB,CAAC;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;qEAQsC,CAAC;AAEtE,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;iDAIK,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;yDAImB,CAAC;AAE1D,gFAAgF;AAEhF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;oEAIgC,CAAC;AAErE,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;+DAIwB,CAAC;AAEhE,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG;;;+EAGiD,CAAC;AAEhF,gFAAgF;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;iFAIkD,CAAC;AAElF,gFAAgF;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;sFAIuD,CAAC;AAEvF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;+EAKgD,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAG;;;sFAG0D,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @agentkit-js/agent-prompts — composable system-prompt fragments.
3
+ *
4
+ * agentkit-js is a generic agent runtime. This package provides
5
+ * **building blocks** for system prompts (reasoning preambles, sandbox
6
+ * descriptions, output contracts, error-recovery rules, card-block
7
+ * conventions), plus a {@link composePrompt} composer.
8
+ *
9
+ * It does NOT ship full opinionated prompts for any particular product
10
+ * (e.g. coding-assistant personas, framework-specific file rules). Build
11
+ * those in your own product code by composing these fragments with your
12
+ * own product-specific instructions.
13
+ *
14
+ * @example
15
+ * import {
16
+ * composePrompt,
17
+ * REASONING_FIRST,
18
+ * SANDBOX_QUICKJS,
19
+ * OUTPUT_CONTRACT_FINAL_ANSWER,
20
+ * CODE_QUALITY_GENERIC,
21
+ * DIAGRAMS_CODE_JS,
22
+ * ERROR_RECOVERY,
23
+ * } from "@agentkit-js/agent-prompts";
24
+ *
25
+ * const prompt = composePrompt({
26
+ * persona: "You are an expert JavaScript coding assistant.",
27
+ * fragments: [
28
+ * REASONING_FIRST,
29
+ * SANDBOX_QUICKJS,
30
+ * OUTPUT_CONTRACT_FINAL_ANSWER,
31
+ * CODE_QUALITY_GENERIC,
32
+ * DIAGRAMS_CODE_JS,
33
+ * ERROR_RECOVERY,
34
+ * ],
35
+ * });
36
+ */
37
+ export type { ComposePromptInput } from "./composePrompt.js";
38
+ export { composePrompt } from "./composePrompt.js";
39
+ export { DIAGRAMS_CODE_JS, DIAGRAMS_CODE_PYTHON, DIAGRAMS_GENERIC, } from "./diagrams.js";
40
+ export { CODE_QUALITY_GENERIC, CODE_QUALITY_TYPESCRIPT, ERROR_RECOVERY, FILE_OPS_ATOMIC, OUTPUT_CONTRACT_FINAL_ANSWER, OUTPUT_CONTRACT_STDOUT, REASONING_FIRST, SANDBOX_NODE, SANDBOX_PYODIDE, SANDBOX_QUICKJS, STRUCTURED_PLAN, } from "./fragments.js";
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAOvB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @agentkit-js/agent-prompts — composable system-prompt fragments.
3
+ *
4
+ * agentkit-js is a generic agent runtime. This package provides
5
+ * **building blocks** for system prompts (reasoning preambles, sandbox
6
+ * descriptions, output contracts, error-recovery rules, card-block
7
+ * conventions), plus a {@link composePrompt} composer.
8
+ *
9
+ * It does NOT ship full opinionated prompts for any particular product
10
+ * (e.g. coding-assistant personas, framework-specific file rules). Build
11
+ * those in your own product code by composing these fragments with your
12
+ * own product-specific instructions.
13
+ *
14
+ * @example
15
+ * import {
16
+ * composePrompt,
17
+ * REASONING_FIRST,
18
+ * SANDBOX_QUICKJS,
19
+ * OUTPUT_CONTRACT_FINAL_ANSWER,
20
+ * CODE_QUALITY_GENERIC,
21
+ * DIAGRAMS_CODE_JS,
22
+ * ERROR_RECOVERY,
23
+ * } from "@agentkit-js/agent-prompts";
24
+ *
25
+ * const prompt = composePrompt({
26
+ * persona: "You are an expert JavaScript coding assistant.",
27
+ * fragments: [
28
+ * REASONING_FIRST,
29
+ * SANDBOX_QUICKJS,
30
+ * OUTPUT_CONTRACT_FINAL_ANSWER,
31
+ * CODE_QUALITY_GENERIC,
32
+ * DIAGRAMS_CODE_JS,
33
+ * ERROR_RECOVERY,
34
+ * ],
35
+ * });
36
+ */
37
+ // Composer
38
+ export { composePrompt } from "./composePrompt.js";
39
+ // Card-block / diagram conventions
40
+ export { DIAGRAMS_CODE_JS, DIAGRAMS_CODE_PYTHON, DIAGRAMS_GENERIC, } from "./diagrams.js";
41
+ // Reasoning preambles
42
+ // Output contracts
43
+ // Code quality rules
44
+ // Error recovery
45
+ // File operation rules
46
+ // Sandbox descriptions
47
+ export { CODE_QUALITY_GENERIC, CODE_QUALITY_TYPESCRIPT, ERROR_RECOVERY, FILE_OPS_ATOMIC, OUTPUT_CONTRACT_FINAL_ANSWER, OUTPUT_CONTRACT_STDOUT, REASONING_FIRST, SANDBOX_NODE, SANDBOX_PYODIDE, SANDBOX_QUICKJS, STRUCTURED_PLAN, } from "./fragments.js";
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,WAAW;AACX,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,mCAAmC;AACnC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,sBAAsB;AACtB,mBAAmB;AACnB,qBAAqB;AACrB,iBAAiB;AACjB,uBAAuB;AACvB,uBAAuB;AACvB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@agentkit-js/agent-prompts",
3
+ "version": "0.2.0",
4
+ "description": "Reusable system prompt templates for agentkit-js — code/tool/framework prompts with D2 + Markdown card conventions",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "test": "vitest run",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "clean": "rm -rf dist .turbo"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^22.0.0",
22
+ "typescript": "^5.7.0",
23
+ "vitest": "^2.1.0"
24
+ },
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ },
28
+ "keywords": [
29
+ "agentkit",
30
+ "prompts",
31
+ "system-prompt",
32
+ "code-agent",
33
+ "framework"
34
+ ],
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/telleroutlook/agentkit-js.git",
39
+ "directory": "packages/agent-prompts"
40
+ },
41
+ "homepage": "https://github.com/telleroutlook/agentkit-js/tree/main/packages/agent-prompts#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/telleroutlook/agentkit-js/issues"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "LICENSE",
51
+ "README.md"
52
+ ],
53
+ "author": "agentkit-js contributors"
54
+ }