@elizaos/prompts 2.0.0-alpha.97 → 2.0.0-beta.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/README.md CHANGED
@@ -1,61 +1,51 @@
1
1
  # @elizaos/prompts
2
2
 
3
- Shared prompt templates for elizaOS across TypeScript, Python, and Rust runtimes.
3
+ Shared prompt templates and action specs for elizaOS.
4
4
 
5
5
  ## Overview
6
6
 
7
- This package provides a single source of truth for all prompt templates used by elizaOS agents. Prompts are stored as `.txt` files and generated into native formats for each language.
7
+ This package is the single source of truth for prompt templates used by the runtime. Prompts are authored directly as TypeScript modules under `src/` and re-exported from `src/index.ts`.
8
8
 
9
9
  ## Structure
10
10
 
11
11
  ```
12
12
  packages/prompts/
13
- ├── prompts/ # Source prompt templates (.txt files)
14
- │ ├── reply.txt
15
- │ ├── choose_option.txt
16
- │ ├── image_generation.txt
13
+ ├── src/ # TypeScript prompt template modules (source of truth)
14
+ │ ├── reply.ts
15
+ │ ├── choose_option.ts
16
+ │ ├── image_generation.ts
17
17
  │ └── ...
18
- ├── scripts/ # Build scripts
19
- └── generate.js # Generates native code from prompts
20
- ├── dist/ # Generated output
21
- ├── typescript/ # TypeScript exports
22
- ├── python/ # Python module
23
- └── rust/ # Rust source
24
- └── package.json
18
+ ├── specs/ # Canonical merged action/provider specs (JSON) + generated plugins.generated.json
19
+ └── scripts/ # Spec + docs generators
20
+ ├── generate-action-docs.js
21
+ ├── generate-plugin-action-spec.js
22
+ ├── prompt-compression.js
23
+ └── check-secrets.js
25
24
  ```
26
25
 
27
26
  ## Template Syntax
28
27
 
29
- All prompts use **Handlebars-style** template variables:
28
+ Prompts use Handlebars-style variables:
30
29
 
31
- - `{{variableName}}` - Simple variable substitution
32
- - `{{#each items}}...{{/each}}` - Iteration over arrays
33
- - `{{#if condition}}...{{/if}}` - Conditional blocks
30
+ - `{{variableName}}` - simple variable substitution
31
+ - `{{#each items}}...{{/each}}` - iteration
32
+ - `{{#if condition}}...{{/if}}` - conditional
34
33
 
35
- ### Variable Naming Convention
34
+ Use camelCase for variables (`{{agentName}}`, `{{providers}}`, `{{recentMessages}}`).
36
35
 
37
- Use camelCase for all template variables to ensure consistency across languages:
36
+ ## Plugin-local `prompts/*.json` (under `plugins/**`)
38
37
 
39
- - `{{agentName}}` - The agent's name
40
- - `{{providers}}` - Provider context
41
- - `{{recentMessages}}` - Recent conversation messages
38
+ Some plugins keep **hand-edited** `actions.json` / `evaluators.json` / `providers.json` next to their source. Those files feed **per-plugin codegen** (for example `generated/specs/spec-helpers.ts` via each plugin’s own workflow). They are **not** inputs to `scripts/generate-plugin-action-spec.js`, which instead scans `plugins/**/*.ts` for `export const …: Action` blocks and writes `specs/actions/plugins.generated.json`.
42
39
 
43
40
  ## Building
44
41
 
45
42
  ```bash
46
- # Build all targets
47
- npm run build
48
-
49
- # Build specific target
50
- npm run build:typescript
51
- npm run build:python
52
- npm run build:rust
43
+ # Generate plugin action spec + action docs
44
+ bun run build
53
45
  ```
54
46
 
55
47
  ## Usage
56
48
 
57
- ### TypeScript
58
-
59
49
  ```typescript
60
50
  import { REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE } from "@elizaos/prompts";
61
51
 
@@ -65,78 +55,29 @@ const prompt = composePrompt({
65
55
  });
66
56
  ```
67
57
 
68
- ### Python
69
-
70
- ```python
71
- from elizaos.prompts import REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE
72
-
73
- prompt = compose_prompt(state={'agentName': 'Alice'}, template=REPLY_TEMPLATE)
74
- ```
75
-
76
- ### Rust
77
-
78
- ```rust
79
- use elizaos_prompts::{REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE};
80
-
81
- let prompt = compose_prompt(&state, REPLY_TEMPLATE);
82
- ```
83
-
84
58
  ## Adding New Prompts
85
59
 
86
- 1. Create a new `.txt` file in `prompts/` directory
87
- 2. Name the file using snake_case (e.g., `my_new_action.txt`)
88
- 3. Run `npm run build` to generate native code
89
- 4. The prompt will be exported as `MY_NEW_ACTION_TEMPLATE` in all languages
90
-
91
- ## Plugin Prompts
92
-
93
- Plugins can use the same prompt system! See [README-PLUGIN-PROMPTS.md](./README-PLUGIN-PROMPTS.md) for details on how to set up prompts in your plugin.
94
-
95
- The `scripts/generate-plugin-prompts.js` utility can be used by any plugin to generate TypeScript, Python, and Rust exports from `.txt` prompt templates.
60
+ 1. Create a new `.ts` file in `src/` exporting a `*_TEMPLATE` constant.
61
+ 2. Re-export it from `src/index.ts`.
96
62
 
97
63
  ## Template Guidelines
98
64
 
99
- 1. **Start with a task description** - Begin prompts with `# Task:` to clearly state the objective
100
- 2. **Include providers placeholder** - Use `{{providers}}` where provider context should be injected
101
- 3. **Use XML output format** - Standardize on XML response format for consistent parsing
102
- 4. **Add clear instructions** - Include explicit instructions for the LLM
103
- 5. **End with output format** - Always specify the expected output format
104
-
105
- Example:
106
-
107
- ```txt
108
- # Task: Generate dialog for the character {{agentName}}.
65
+ 1. **Start with a task description** begin prompts with `# Task:` to state the objective.
66
+ 2. **Include providers placeholder** use `{{providers}}` where provider context should be injected.
67
+ 3. **Use JSON output format** standardize on JSON response format for consistent parsing.
68
+ 4. **Add clear instructions** explicit instructions for the LLM.
69
+ 5. **End with output format** always specify the expected output format.
109
70
 
110
- {{providers}}
71
+ ## Security & Privacy
111
72
 
112
- # Instructions: Write the next message for {{agentName}}.
113
-
114
- Respond using XML format like this:
115
- <response>
116
- <thought>Your thought here</thought>
117
- <text>Your message here</text>
118
- </response>
119
-
120
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above.
121
- ```
122
-
123
- ## Security & Privacy Guidance (SOC2-aligned)
124
-
125
- - **Do not embed real secrets** in prompt templates. Prompts are source-controlled and often distributed.
73
+ - **Do not embed real secrets** in prompt templates. Prompts are source-controlled.
126
74
  - **Avoid including PII** (emails, phone numbers, addresses, IDs) in templates or examples.
127
- - Prefer placeholders (e.g., `{{apiKey}}`, `{{userEmail}}`) and ensure the runtime injects only the minimum needed.
75
+ - Prefer placeholders (e.g., `{{apiKey}}`, `{{userEmail}}`) and inject only the minimum needed at runtime.
128
76
 
129
77
  ### Secret scan
130
78
 
131
- This package includes a conservative scanner that flags prompt templates containing strings that strongly resemble real credentials (or private key material).
132
-
133
- Run:
134
-
135
79
  ```bash
136
80
  npm run check:secrets
137
81
  ```
138
82
 
139
- It scans:
140
-
141
- - `packages/prompts/prompts/**/*.txt`
142
- - `plugins/**/prompts/**/*.txt`
83
+ Scans `packages/prompts/src/**/*.ts`, plugin prompt TS modules (paths matching `prompts/**/*.ts`, `workflow-prompts/**/*.ts`, etc.), and a few explicit files — see `scripts/check-secrets.js`.