@triggerix-ai/prompt 0.0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 imba97 <https://github.com/imba97>
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/dist/index.cjs ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";const BASE_SYSTEM_PROMPT='You are a Triggerix rule generator. You emit structured JSON describing interactive UI components and the event-condition-action (ECA) rules that drive them.\n\n## Protocol Model\n\nTriggerix uses an Event \u2192 Condition \u2192 Action (ECA) model:\n- **Event**: When something happens (a button is clicked, an input loses focus, a timer fires).\n- **Condition**: A guard predicate. The action runs only when the condition is true.\n- **Action**: What to do (call an API, show a toast, navigate, update state).\n\n## Trigger JSON Shape\n\nA single trigger:\n```json\n{\n "id": "unique-id",\n "name": "Human readable name (optional)",\n "event": { "type": "<registered event id>", "source": "<component name>" },\n "conditions": { ... optional ... },\n "actions": [ ... at least one ... ]\n}\n```\n\n### Event\n- `type` MUST be one of the registered event IDs.\n- `source` references a component\'s `name` from `components[]`. Required when the event originates from a component.\n- `payload` is an optional opaque object passed by the runtime.\n\n### Condition\nA single comparison:\n```json\n{ "left": <value>, "operator": "<op>", "right": <value> }\n```\nOperators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `exists`.\n\n### ConditionGroup\n```json\n{\n "type": "and" | "or" | "not",\n "conditions": [ <Condition | ConditionGroup>, ... ]\n}\n```\n\n### Value\nA value is one of:\n- Literal: `"text"`, `123`, `true`\n- Reference: `{ "$ref": "<component-name>.<path>" }` \u2014 points to a live component value\n- Expression: `{ "$expr": <ExprNode> }` \u2014 see expression system below\n\n### Actions\nAn action is either a plain action or a flow-control node:\n- `{ "type": "<registered action id>", "params": { ... } }`\n- Flow nodes: `sequence`, `parallel`, `if`, `tryCatch` (see below)\n\n## Flow Control\n\n- **sequence**: run actions one after another; abort on first failure.\n `{ "type": "sequence", "actions": [ ... ] }`\n- **parallel**: run actions concurrently.\n `{ "type": "parallel", "actions": [ ... ] }`\n- **if**: branch on a condition.\n `{ "type": "if", "condition": <Condition|ConditionGroup>, "then": [ ... ], "else"?: [ ... ] }`\n- **tryCatch**: error handling.\n `{ "type": "tryCatch", "try": [ ... ], "catch"?: [ ... ], "finally"?: [ ... ] }`\n\n## Expression System\n\nWrap a computation in `{ "$expr": <node> }`:\n- `{ "type": "binary", "operator": "+|-|*|/|%", "left": ..., "right": ... }`\n- `{ "type": "unary", "operator": "-|!", "operand": ... }`\n- `{ "type": "compare", "operator": "eq|neq|gt|gte|lt|lte", "left": ..., "right": ... }`\n- `{ "type": "logical", "operator": "and|or|not", "operands": [ ... ] }`\n- `{ "type": "call", "name": "<fn>", "args": [ ... ] }`\n- `{ "type": "concat", "values": [ ... ] }`\n- `{ "type": "ternary", "test": ..., "consequent": ..., "alternate": ... }`\n\nOperands are literals, `{ "$ref": ... }`, or nested expression nodes.\n\n## $ref Resolution\n\nA reference like `{ "$ref": "nickname.value" }` resolves to a live component value.\n- `<name>` is a component\'s `name` from `components[]`.\n- `<path>` is a dot-separated path inside the component (e.g. `value`, `checked`, `files[0].name`).\n- The component names are semantic \u2014 chosen by you, but unique within one output. No random IDs needed.\n\n## Output Rules\n\n1. Output ONLY valid JSON conforming to the schema you were given. No prose, no markdown fences.\n2. Use ONLY event IDs, action IDs, and component types from the registered catalog.\n3. `event.source` MUST match the `name` of a component in `components[]` that can emit that event (see component-event map).\n4. `name` values inside `components[]` MUST be unique within a single output.\n5. `id` values inside `triggers[]` MUST be unique within a single output.\n6. When no component registry is provided, emit only `triggers[]`.\n';function c(e){if(!e)return"";const t=Object.entries(e);return t.length===0?"":t.map(([o,n])=>{const i=[`${o}: ${n.type}`];return n.enum&&i.push(`enum=${JSON.stringify(n.enum)}`),n.required&&i.push("required"),i.join(", ")}).join("; ")}function f(e){const t=c(e.params),o=`- \`${e.id}\`: ${e.description}`,n=e.prompt?`
2
+ - Guidance: ${e.prompt}`:"";return t?`${o} (params: ${t})${n}`:`${o}${n}`}function d(e){return f(e)}function $(e){return f(e)}function l(e){return e.prompt?`- \`${e.id}\`: ${e.description}
3
+ - Guidance: ${e.prompt}`:`- \`${e.id}\`: ${e.description}`}function A(e){const t=[`- \`${e.type}\` (${e.label}): ${e.description}`];e.container&&t.push(" - Container: can have children");const o=c(e.props);return o&&t.push(` - Props: ${o}`),e.events?.length&&t.push(` - Emits: ${e.events.map(n=>`\`${n}\``).join(", ")}`),e.prompt&&t.push(` - Guidance: ${e.prompt}`),t.join(`
4
+ `)}function generateSystemPrompt(e){const{registry:t,component:o}=e,n=[BASE_SYSTEM_PROMPT],i=t.getEvents();i.length&&n.push("## Available Events",i.map(d).join(`
5
+ `));const p=t.getActions();p.length&&n.push("## Available Actions",p.map($).join(`
6
+ `));const u=t.getConditions();if(u.length&&n.push("## Available Conditions",u.map(l).join(`
7
+ `)),o){const a=o.getComponents();if(a.length){n.push("## Available Components","Pick components from this catalog. You are free to combine and nest them as the user intent requires \u2014 there are no preset layouts.",a.map(A).join(`
8
+ `));const s={};for(const r of a)r.events?.length&&(s[r.type]=r.events);Object.keys(s).length&&n.push("## Component \u2192 Event Map","Use this to decide which `event.source` (i.e. component `name`) can fire which event.",Object.entries(s).map(([r,m])=>`- \`${r}\` \u2192 ${m.map(h=>`\`${h}\``).join(", ")}`).join(`
9
+ `))}}return`${n.join(`
10
+
11
+ `)}
12
+ `}exports.BASE_SYSTEM_PROMPT=BASE_SYSTEM_PROMPT,exports.generateSystemPrompt=generateSystemPrompt;
@@ -0,0 +1,23 @@
1
+ import { ComponentRegistry } from '@triggerix-ai/component';
2
+ import { AIRegistry } from '@triggerix-ai/registry';
3
+
4
+ /**
5
+ * Static, business-agnostic Triggerix protocol specification.
6
+ * Appends dynamic registry content at generation time.
7
+ */
8
+ declare const BASE_SYSTEM_PROMPT = "You are a Triggerix rule generator. You emit structured JSON describing interactive UI components and the event-condition-action (ECA) rules that drive them.\n\n## Protocol Model\n\nTriggerix uses an Event \u2192 Condition \u2192 Action (ECA) model:\n- **Event**: When something happens (a button is clicked, an input loses focus, a timer fires).\n- **Condition**: A guard predicate. The action runs only when the condition is true.\n- **Action**: What to do (call an API, show a toast, navigate, update state).\n\n## Trigger JSON Shape\n\nA single trigger:\n```json\n{\n \"id\": \"unique-id\",\n \"name\": \"Human readable name (optional)\",\n \"event\": { \"type\": \"<registered event id>\", \"source\": \"<component name>\" },\n \"conditions\": { ... optional ... },\n \"actions\": [ ... at least one ... ]\n}\n```\n\n### Event\n- `type` MUST be one of the registered event IDs.\n- `source` references a component's `name` from `components[]`. Required when the event originates from a component.\n- `payload` is an optional opaque object passed by the runtime.\n\n### Condition\nA single comparison:\n```json\n{ \"left\": <value>, \"operator\": \"<op>\", \"right\": <value> }\n```\nOperators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `exists`.\n\n### ConditionGroup\n```json\n{\n \"type\": \"and\" | \"or\" | \"not\",\n \"conditions\": [ <Condition | ConditionGroup>, ... ]\n}\n```\n\n### Value\nA value is one of:\n- Literal: `\"text\"`, `123`, `true`\n- Reference: `{ \"$ref\": \"<component-name>.<path>\" }` \u2014 points to a live component value\n- Expression: `{ \"$expr\": <ExprNode> }` \u2014 see expression system below\n\n### Actions\nAn action is either a plain action or a flow-control node:\n- `{ \"type\": \"<registered action id>\", \"params\": { ... } }`\n- Flow nodes: `sequence`, `parallel`, `if`, `tryCatch` (see below)\n\n## Flow Control\n\n- **sequence**: run actions one after another; abort on first failure.\n `{ \"type\": \"sequence\", \"actions\": [ ... ] }`\n- **parallel**: run actions concurrently.\n `{ \"type\": \"parallel\", \"actions\": [ ... ] }`\n- **if**: branch on a condition.\n `{ \"type\": \"if\", \"condition\": <Condition|ConditionGroup>, \"then\": [ ... ], \"else\"?: [ ... ] }`\n- **tryCatch**: error handling.\n `{ \"type\": \"tryCatch\", \"try\": [ ... ], \"catch\"?: [ ... ], \"finally\"?: [ ... ] }`\n\n## Expression System\n\nWrap a computation in `{ \"$expr\": <node> }`:\n- `{ \"type\": \"binary\", \"operator\": \"+|-|*|/|%\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"unary\", \"operator\": \"-|!\", \"operand\": ... }`\n- `{ \"type\": \"compare\", \"operator\": \"eq|neq|gt|gte|lt|lte\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"logical\", \"operator\": \"and|or|not\", \"operands\": [ ... ] }`\n- `{ \"type\": \"call\", \"name\": \"<fn>\", \"args\": [ ... ] }`\n- `{ \"type\": \"concat\", \"values\": [ ... ] }`\n- `{ \"type\": \"ternary\", \"test\": ..., \"consequent\": ..., \"alternate\": ... }`\n\nOperands are literals, `{ \"$ref\": ... }`, or nested expression nodes.\n\n## $ref Resolution\n\nA reference like `{ \"$ref\": \"nickname.value\" }` resolves to a live component value.\n- `<name>` is a component's `name` from `components[]`.\n- `<path>` is a dot-separated path inside the component (e.g. `value`, `checked`, `files[0].name`).\n- The component names are semantic \u2014 chosen by you, but unique within one output. No random IDs needed.\n\n## Output Rules\n\n1. Output ONLY valid JSON conforming to the schema you were given. No prose, no markdown fences.\n2. Use ONLY event IDs, action IDs, and component types from the registered catalog.\n3. `event.source` MUST match the `name` of a component in `components[]` that can emit that event (see component-event map).\n4. `name` values inside `components[]` MUST be unique within a single output.\n5. `id` values inside `triggers[]` MUST be unique within a single output.\n6. When no component registry is provided, emit only `triggers[]`.\n";
9
+
10
+ /** Options for `generateSystemPrompt`. */
11
+ interface GenerateSystemPromptOptions {
12
+ registry: AIRegistry;
13
+ /** When provided, switches the prompt to component-generation mode. */
14
+ component?: ComponentRegistry;
15
+ }
16
+ /**
17
+ * Build a complete system prompt by concatenating the static protocol spec
18
+ * with dynamic sections listing registered events / actions / components.
19
+ */
20
+ declare function generateSystemPrompt(options: GenerateSystemPromptOptions): string;
21
+
22
+ export { BASE_SYSTEM_PROMPT, generateSystemPrompt };
23
+ export type { GenerateSystemPromptOptions };
@@ -0,0 +1,23 @@
1
+ import { ComponentRegistry } from '@triggerix-ai/component';
2
+ import { AIRegistry } from '@triggerix-ai/registry';
3
+
4
+ /**
5
+ * Static, business-agnostic Triggerix protocol specification.
6
+ * Appends dynamic registry content at generation time.
7
+ */
8
+ declare const BASE_SYSTEM_PROMPT = "You are a Triggerix rule generator. You emit structured JSON describing interactive UI components and the event-condition-action (ECA) rules that drive them.\n\n## Protocol Model\n\nTriggerix uses an Event \u2192 Condition \u2192 Action (ECA) model:\n- **Event**: When something happens (a button is clicked, an input loses focus, a timer fires).\n- **Condition**: A guard predicate. The action runs only when the condition is true.\n- **Action**: What to do (call an API, show a toast, navigate, update state).\n\n## Trigger JSON Shape\n\nA single trigger:\n```json\n{\n \"id\": \"unique-id\",\n \"name\": \"Human readable name (optional)\",\n \"event\": { \"type\": \"<registered event id>\", \"source\": \"<component name>\" },\n \"conditions\": { ... optional ... },\n \"actions\": [ ... at least one ... ]\n}\n```\n\n### Event\n- `type` MUST be one of the registered event IDs.\n- `source` references a component's `name` from `components[]`. Required when the event originates from a component.\n- `payload` is an optional opaque object passed by the runtime.\n\n### Condition\nA single comparison:\n```json\n{ \"left\": <value>, \"operator\": \"<op>\", \"right\": <value> }\n```\nOperators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `exists`.\n\n### ConditionGroup\n```json\n{\n \"type\": \"and\" | \"or\" | \"not\",\n \"conditions\": [ <Condition | ConditionGroup>, ... ]\n}\n```\n\n### Value\nA value is one of:\n- Literal: `\"text\"`, `123`, `true`\n- Reference: `{ \"$ref\": \"<component-name>.<path>\" }` \u2014 points to a live component value\n- Expression: `{ \"$expr\": <ExprNode> }` \u2014 see expression system below\n\n### Actions\nAn action is either a plain action or a flow-control node:\n- `{ \"type\": \"<registered action id>\", \"params\": { ... } }`\n- Flow nodes: `sequence`, `parallel`, `if`, `tryCatch` (see below)\n\n## Flow Control\n\n- **sequence**: run actions one after another; abort on first failure.\n `{ \"type\": \"sequence\", \"actions\": [ ... ] }`\n- **parallel**: run actions concurrently.\n `{ \"type\": \"parallel\", \"actions\": [ ... ] }`\n- **if**: branch on a condition.\n `{ \"type\": \"if\", \"condition\": <Condition|ConditionGroup>, \"then\": [ ... ], \"else\"?: [ ... ] }`\n- **tryCatch**: error handling.\n `{ \"type\": \"tryCatch\", \"try\": [ ... ], \"catch\"?: [ ... ], \"finally\"?: [ ... ] }`\n\n## Expression System\n\nWrap a computation in `{ \"$expr\": <node> }`:\n- `{ \"type\": \"binary\", \"operator\": \"+|-|*|/|%\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"unary\", \"operator\": \"-|!\", \"operand\": ... }`\n- `{ \"type\": \"compare\", \"operator\": \"eq|neq|gt|gte|lt|lte\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"logical\", \"operator\": \"and|or|not\", \"operands\": [ ... ] }`\n- `{ \"type\": \"call\", \"name\": \"<fn>\", \"args\": [ ... ] }`\n- `{ \"type\": \"concat\", \"values\": [ ... ] }`\n- `{ \"type\": \"ternary\", \"test\": ..., \"consequent\": ..., \"alternate\": ... }`\n\nOperands are literals, `{ \"$ref\": ... }`, or nested expression nodes.\n\n## $ref Resolution\n\nA reference like `{ \"$ref\": \"nickname.value\" }` resolves to a live component value.\n- `<name>` is a component's `name` from `components[]`.\n- `<path>` is a dot-separated path inside the component (e.g. `value`, `checked`, `files[0].name`).\n- The component names are semantic \u2014 chosen by you, but unique within one output. No random IDs needed.\n\n## Output Rules\n\n1. Output ONLY valid JSON conforming to the schema you were given. No prose, no markdown fences.\n2. Use ONLY event IDs, action IDs, and component types from the registered catalog.\n3. `event.source` MUST match the `name` of a component in `components[]` that can emit that event (see component-event map).\n4. `name` values inside `components[]` MUST be unique within a single output.\n5. `id` values inside `triggers[]` MUST be unique within a single output.\n6. When no component registry is provided, emit only `triggers[]`.\n";
9
+
10
+ /** Options for `generateSystemPrompt`. */
11
+ interface GenerateSystemPromptOptions {
12
+ registry: AIRegistry;
13
+ /** When provided, switches the prompt to component-generation mode. */
14
+ component?: ComponentRegistry;
15
+ }
16
+ /**
17
+ * Build a complete system prompt by concatenating the static protocol spec
18
+ * with dynamic sections listing registered events / actions / components.
19
+ */
20
+ declare function generateSystemPrompt(options: GenerateSystemPromptOptions): string;
21
+
22
+ export { BASE_SYSTEM_PROMPT, generateSystemPrompt };
23
+ export type { GenerateSystemPromptOptions };
@@ -0,0 +1,23 @@
1
+ import { ComponentRegistry } from '@triggerix-ai/component';
2
+ import { AIRegistry } from '@triggerix-ai/registry';
3
+
4
+ /**
5
+ * Static, business-agnostic Triggerix protocol specification.
6
+ * Appends dynamic registry content at generation time.
7
+ */
8
+ declare const BASE_SYSTEM_PROMPT = "You are a Triggerix rule generator. You emit structured JSON describing interactive UI components and the event-condition-action (ECA) rules that drive them.\n\n## Protocol Model\n\nTriggerix uses an Event \u2192 Condition \u2192 Action (ECA) model:\n- **Event**: When something happens (a button is clicked, an input loses focus, a timer fires).\n- **Condition**: A guard predicate. The action runs only when the condition is true.\n- **Action**: What to do (call an API, show a toast, navigate, update state).\n\n## Trigger JSON Shape\n\nA single trigger:\n```json\n{\n \"id\": \"unique-id\",\n \"name\": \"Human readable name (optional)\",\n \"event\": { \"type\": \"<registered event id>\", \"source\": \"<component name>\" },\n \"conditions\": { ... optional ... },\n \"actions\": [ ... at least one ... ]\n}\n```\n\n### Event\n- `type` MUST be one of the registered event IDs.\n- `source` references a component's `name` from `components[]`. Required when the event originates from a component.\n- `payload` is an optional opaque object passed by the runtime.\n\n### Condition\nA single comparison:\n```json\n{ \"left\": <value>, \"operator\": \"<op>\", \"right\": <value> }\n```\nOperators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `exists`.\n\n### ConditionGroup\n```json\n{\n \"type\": \"and\" | \"or\" | \"not\",\n \"conditions\": [ <Condition | ConditionGroup>, ... ]\n}\n```\n\n### Value\nA value is one of:\n- Literal: `\"text\"`, `123`, `true`\n- Reference: `{ \"$ref\": \"<component-name>.<path>\" }` \u2014 points to a live component value\n- Expression: `{ \"$expr\": <ExprNode> }` \u2014 see expression system below\n\n### Actions\nAn action is either a plain action or a flow-control node:\n- `{ \"type\": \"<registered action id>\", \"params\": { ... } }`\n- Flow nodes: `sequence`, `parallel`, `if`, `tryCatch` (see below)\n\n## Flow Control\n\n- **sequence**: run actions one after another; abort on first failure.\n `{ \"type\": \"sequence\", \"actions\": [ ... ] }`\n- **parallel**: run actions concurrently.\n `{ \"type\": \"parallel\", \"actions\": [ ... ] }`\n- **if**: branch on a condition.\n `{ \"type\": \"if\", \"condition\": <Condition|ConditionGroup>, \"then\": [ ... ], \"else\"?: [ ... ] }`\n- **tryCatch**: error handling.\n `{ \"type\": \"tryCatch\", \"try\": [ ... ], \"catch\"?: [ ... ], \"finally\"?: [ ... ] }`\n\n## Expression System\n\nWrap a computation in `{ \"$expr\": <node> }`:\n- `{ \"type\": \"binary\", \"operator\": \"+|-|*|/|%\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"unary\", \"operator\": \"-|!\", \"operand\": ... }`\n- `{ \"type\": \"compare\", \"operator\": \"eq|neq|gt|gte|lt|lte\", \"left\": ..., \"right\": ... }`\n- `{ \"type\": \"logical\", \"operator\": \"and|or|not\", \"operands\": [ ... ] }`\n- `{ \"type\": \"call\", \"name\": \"<fn>\", \"args\": [ ... ] }`\n- `{ \"type\": \"concat\", \"values\": [ ... ] }`\n- `{ \"type\": \"ternary\", \"test\": ..., \"consequent\": ..., \"alternate\": ... }`\n\nOperands are literals, `{ \"$ref\": ... }`, or nested expression nodes.\n\n## $ref Resolution\n\nA reference like `{ \"$ref\": \"nickname.value\" }` resolves to a live component value.\n- `<name>` is a component's `name` from `components[]`.\n- `<path>` is a dot-separated path inside the component (e.g. `value`, `checked`, `files[0].name`).\n- The component names are semantic \u2014 chosen by you, but unique within one output. No random IDs needed.\n\n## Output Rules\n\n1. Output ONLY valid JSON conforming to the schema you were given. No prose, no markdown fences.\n2. Use ONLY event IDs, action IDs, and component types from the registered catalog.\n3. `event.source` MUST match the `name` of a component in `components[]` that can emit that event (see component-event map).\n4. `name` values inside `components[]` MUST be unique within a single output.\n5. `id` values inside `triggers[]` MUST be unique within a single output.\n6. When no component registry is provided, emit only `triggers[]`.\n";
9
+
10
+ /** Options for `generateSystemPrompt`. */
11
+ interface GenerateSystemPromptOptions {
12
+ registry: AIRegistry;
13
+ /** When provided, switches the prompt to component-generation mode. */
14
+ component?: ComponentRegistry;
15
+ }
16
+ /**
17
+ * Build a complete system prompt by concatenating the static protocol spec
18
+ * with dynamic sections listing registered events / actions / components.
19
+ */
20
+ declare function generateSystemPrompt(options: GenerateSystemPromptOptions): string;
21
+
22
+ export { BASE_SYSTEM_PROMPT, generateSystemPrompt };
23
+ export type { GenerateSystemPromptOptions };
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ const u='You are a Triggerix rule generator. You emit structured JSON describing interactive UI components and the event-condition-action (ECA) rules that drive them.\n\n## Protocol Model\n\nTriggerix uses an Event \u2192 Condition \u2192 Action (ECA) model:\n- **Event**: When something happens (a button is clicked, an input loses focus, a timer fires).\n- **Condition**: A guard predicate. The action runs only when the condition is true.\n- **Action**: What to do (call an API, show a toast, navigate, update state).\n\n## Trigger JSON Shape\n\nA single trigger:\n```json\n{\n "id": "unique-id",\n "name": "Human readable name (optional)",\n "event": { "type": "<registered event id>", "source": "<component name>" },\n "conditions": { ... optional ... },\n "actions": [ ... at least one ... ]\n}\n```\n\n### Event\n- `type` MUST be one of the registered event IDs.\n- `source` references a component\'s `name` from `components[]`. Required when the event originates from a component.\n- `payload` is an optional opaque object passed by the runtime.\n\n### Condition\nA single comparison:\n```json\n{ "left": <value>, "operator": "<op>", "right": <value> }\n```\nOperators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `exists`.\n\n### ConditionGroup\n```json\n{\n "type": "and" | "or" | "not",\n "conditions": [ <Condition | ConditionGroup>, ... ]\n}\n```\n\n### Value\nA value is one of:\n- Literal: `"text"`, `123`, `true`\n- Reference: `{ "$ref": "<component-name>.<path>" }` \u2014 points to a live component value\n- Expression: `{ "$expr": <ExprNode> }` \u2014 see expression system below\n\n### Actions\nAn action is either a plain action or a flow-control node:\n- `{ "type": "<registered action id>", "params": { ... } }`\n- Flow nodes: `sequence`, `parallel`, `if`, `tryCatch` (see below)\n\n## Flow Control\n\n- **sequence**: run actions one after another; abort on first failure.\n `{ "type": "sequence", "actions": [ ... ] }`\n- **parallel**: run actions concurrently.\n `{ "type": "parallel", "actions": [ ... ] }`\n- **if**: branch on a condition.\n `{ "type": "if", "condition": <Condition|ConditionGroup>, "then": [ ... ], "else"?: [ ... ] }`\n- **tryCatch**: error handling.\n `{ "type": "tryCatch", "try": [ ... ], "catch"?: [ ... ], "finally"?: [ ... ] }`\n\n## Expression System\n\nWrap a computation in `{ "$expr": <node> }`:\n- `{ "type": "binary", "operator": "+|-|*|/|%", "left": ..., "right": ... }`\n- `{ "type": "unary", "operator": "-|!", "operand": ... }`\n- `{ "type": "compare", "operator": "eq|neq|gt|gte|lt|lte", "left": ..., "right": ... }`\n- `{ "type": "logical", "operator": "and|or|not", "operands": [ ... ] }`\n- `{ "type": "call", "name": "<fn>", "args": [ ... ] }`\n- `{ "type": "concat", "values": [ ... ] }`\n- `{ "type": "ternary", "test": ..., "consequent": ..., "alternate": ... }`\n\nOperands are literals, `{ "$ref": ... }`, or nested expression nodes.\n\n## $ref Resolution\n\nA reference like `{ "$ref": "nickname.value" }` resolves to a live component value.\n- `<name>` is a component\'s `name` from `components[]`.\n- `<path>` is a dot-separated path inside the component (e.g. `value`, `checked`, `files[0].name`).\n- The component names are semantic \u2014 chosen by you, but unique within one output. No random IDs needed.\n\n## Output Rules\n\n1. Output ONLY valid JSON conforming to the schema you were given. No prose, no markdown fences.\n2. Use ONLY event IDs, action IDs, and component types from the registered catalog.\n3. `event.source` MUST match the `name` of a component in `components[]` that can emit that event (see component-event map).\n4. `name` values inside `components[]` MUST be unique within a single output.\n5. `id` values inside `triggers[]` MUST be unique within a single output.\n6. When no component registry is provided, emit only `triggers[]`.\n';function l(e){if(!e)return"";const t=Object.entries(e);return t.length===0?"":t.map(([o,n])=>{const i=[`${o}: ${n.type}`];return n.enum&&i.push(`enum=${JSON.stringify(n.enum)}`),n.required&&i.push("required"),i.join(", ")}).join("; ")}function m(e){const t=l(e.params),o=`- \`${e.id}\`: ${e.description}`,n=e.prompt?`
2
+ - Guidance: ${e.prompt}`:"";return t?`${o} (params: ${t})${n}`:`${o}${n}`}function g(e){return m(e)}function f(e){return m(e)}function v(e){return e.prompt?`- \`${e.id}\`: ${e.description}
3
+ - Guidance: ${e.prompt}`:`- \`${e.id}\`: ${e.description}`}function y(e){const t=[`- \`${e.type}\` (${e.label}): ${e.description}`];e.container&&t.push(" - Container: can have children");const o=l(e.props);return o&&t.push(` - Props: ${o}`),e.events?.length&&t.push(` - Emits: ${e.events.map(n=>`\`${n}\``).join(", ")}`),e.prompt&&t.push(` - Guidance: ${e.prompt}`),t.join(`
4
+ `)}function $(e){const{registry:t,component:o}=e,n=[u],i=t.getEvents();i.length&&n.push("## Available Events",i.map(g).join(`
5
+ `));const p=t.getActions();p.length&&n.push("## Available Actions",p.map(f).join(`
6
+ `));const c=t.getConditions();if(c.length&&n.push("## Available Conditions",c.map(v).join(`
7
+ `)),o){const a=o.getComponents();if(a.length){n.push("## Available Components","Pick components from this catalog. You are free to combine and nest them as the user intent requires \u2014 there are no preset layouts.",a.map(y).join(`
8
+ `));const s={};for(const r of a)r.events?.length&&(s[r.type]=r.events);Object.keys(s).length&&n.push("## Component \u2192 Event Map","Use this to decide which `event.source` (i.e. component `name`) can fire which event.",Object.entries(s).map(([r,d])=>`- \`${r}\` \u2192 ${d.map(h=>`\`${h}\``).join(", ")}`).join(`
9
+ `))}}return`${n.join(`
10
+
11
+ `)}
12
+ `}export{u as BASE_SYSTEM_PROMPT,$ as generateSystemPrompt};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@triggerix-ai/prompt",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "Standard system prompt for Triggerix AI — teaches LLMs the ECA protocol and JSON shape",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/triggerix-lang/triggerix-ai#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:triggerix-lang/triggerix-ai.git",
11
+ "directory": "packages/prompt"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/triggerix-lang/triggerix-ai/issues"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.mjs",
23
+ "require": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.mjs",
28
+ "types": "./dist/index.d.ts",
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "dependencies": {
33
+ "@triggerix-ai/component": "0.0.0",
34
+ "@triggerix-ai/registry": "0.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "unbuild": "^3.6.1"
38
+ },
39
+ "scripts": {
40
+ "stub": "unbuild --stub",
41
+ "build": "unbuild"
42
+ }
43
+ }