@riotprompt/riotprompt 0.0.11 → 0.0.13
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 +1 -1
- package/README.md +121 -21
- package/dist/builder.js +3 -0
- package/dist/builder.js.map +1 -1
- package/dist/cli.cjs +1519 -0
- package/dist/cli.d.ts +8 -0
- package/dist/config.d.ts +7 -0
- package/dist/conversation-logger.js +6 -1
- package/dist/conversation-logger.js.map +1 -1
- package/dist/execution/anthropic.d.ts +5 -0
- package/dist/execution/anthropic.js +46 -0
- package/dist/execution/anthropic.js.map +1 -0
- package/dist/execution/gemini.d.ts +5 -0
- package/dist/execution/gemini.js +78 -0
- package/dist/execution/gemini.js.map +1 -0
- package/dist/execution/index.d.ts +10 -0
- package/dist/execution/index.js +53 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/openai.d.ts +5 -0
- package/dist/execution/openai.js +44 -0
- package/dist/execution/openai.js.map +1 -0
- package/dist/execution/provider.d.ts +18 -0
- package/dist/loader.js +3 -0
- package/dist/loader.js.map +1 -1
- package/dist/model-config.d.ts +1 -0
- package/dist/model-config.js +19 -18
- package/dist/model-config.js.map +1 -1
- package/dist/override.js +3 -0
- package/dist/override.js.map +1 -1
- package/dist/recipes.js +3 -0
- package/dist/recipes.js.map +1 -1
- package/dist/riotprompt.cjs +612 -77
- package/dist/riotprompt.cjs.map +1 -1
- package/dist/riotprompt.d.ts +3 -0
- package/dist/riotprompt.js +6 -0
- package/dist/riotprompt.js.map +1 -1
- package/dist/serializer.d.ts +5 -0
- package/dist/serializer.js +220 -0
- package/dist/serializer.js.map +1 -0
- package/dist/writer.d.ts +2 -0
- package/dist/writer.js +91 -0
- package/dist/writer.js.map +1 -0
- package/guide/architecture.md +51 -0
- package/guide/configuration.md +51 -0
- package/guide/development.md +62 -0
- package/guide/index.md +55 -0
- package/guide/usage.md +99 -0
- package/package.json +14 -3
- package/vite.config.cli.ts +49 -0
- package/BUG-ANALYSIS.md +0 -523
- package/CODE-REVIEW-SUMMARY.md +0 -330
- package/FIXES-APPLIED.md +0 -437
package/guide/usage.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Usage Patterns
|
|
2
|
+
|
|
3
|
+
**Purpose**: Common patterns for using `riotprompt` via CLI and Library.
|
|
4
|
+
|
|
5
|
+
## CLI Usage
|
|
6
|
+
|
|
7
|
+
The CLI is the primary way to interact with filesystem-based prompts.
|
|
8
|
+
|
|
9
|
+
### Directory Structure
|
|
10
|
+
|
|
11
|
+
RiotPrompt expects a specific directory structure for a prompt "package":
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
my-prompt-project/
|
|
15
|
+
├── persona.md # OR directory persona/ containing .md files
|
|
16
|
+
├── instructions.md # OR directory instructions/ containing .md files
|
|
17
|
+
└── context/ # Directory containing reference files (json, md, txt)
|
|
18
|
+
├── data.json
|
|
19
|
+
└── background.md
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Commands
|
|
23
|
+
|
|
24
|
+
**Create a New Prompt**:
|
|
25
|
+
```bash
|
|
26
|
+
# Create a prompt in the current directory
|
|
27
|
+
riotprompt create my-new-prompt
|
|
28
|
+
|
|
29
|
+
# Create with custom content
|
|
30
|
+
riotprompt create my-new-prompt --persona "You are a data scientist." --instructions "Analyze this dataset."
|
|
31
|
+
|
|
32
|
+
# Create without context directory
|
|
33
|
+
riotprompt create my-new-prompt --no-context
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Process a Prompt**:
|
|
37
|
+
```bash
|
|
38
|
+
# Default text output (formatted for console/copy-paste)
|
|
39
|
+
riotprompt process ./my-prompt-project
|
|
40
|
+
|
|
41
|
+
# Specify a target model (affects formatting, e.g., role names)
|
|
42
|
+
riotprompt process ./my-prompt-project --model gpt-4
|
|
43
|
+
|
|
44
|
+
# Export to JSON (for API integration)
|
|
45
|
+
riotprompt process ./my-prompt-project --format json --output prompt.json
|
|
46
|
+
|
|
47
|
+
# Export to XML
|
|
48
|
+
riotprompt process ./my-prompt-project --format xml --output prompt.xml
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Library Usage
|
|
52
|
+
|
|
53
|
+
You can import `riotprompt` into your own TypeScript applications to build dynamic prompt pipelines.
|
|
54
|
+
|
|
55
|
+
### Dynamic Context Injection
|
|
56
|
+
|
|
57
|
+
A common pattern is to have static instructions but dynamic context (e.g., user data).
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import * as RiotPrompt from '@riotprompt/riotprompt';
|
|
61
|
+
|
|
62
|
+
async function buildPromptForUser(userData: any) {
|
|
63
|
+
// 1. Load static parts from disk
|
|
64
|
+
const loader = RiotPrompt.Loader.create();
|
|
65
|
+
const [baseContext] = await loader.load(['./prompts/base-context']);
|
|
66
|
+
|
|
67
|
+
// 2. Create dynamic sections
|
|
68
|
+
const userContext = RiotPrompt.createSection({ title: 'User Data' });
|
|
69
|
+
userContext.add(JSON.stringify(userData));
|
|
70
|
+
|
|
71
|
+
// 3. Create Instructions
|
|
72
|
+
const instructions = RiotPrompt.createSection({ title: 'Task' })
|
|
73
|
+
.add(RiotPrompt.createInstruction('Analyze this user data.'));
|
|
74
|
+
|
|
75
|
+
// 4. Assemble
|
|
76
|
+
const prompt = RiotPrompt.createPrompt({
|
|
77
|
+
instructions,
|
|
78
|
+
contexts: RiotPrompt.createSection({ title: 'Context' })
|
|
79
|
+
.add(baseContext)
|
|
80
|
+
.add(userContext) // Inject dynamic part
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return prompt;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Custom Formatters
|
|
88
|
+
|
|
89
|
+
If you need to output to a specific non-standard format, you can access the raw `Prompt` object structure.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const prompt = ...;
|
|
93
|
+
|
|
94
|
+
// Iterate over instructions
|
|
95
|
+
prompt.instructions.items.forEach(item => {
|
|
96
|
+
console.log(item.text);
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riotprompt/riotprompt",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"prompt",
|
|
6
6
|
"llm",
|
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
"require": "./dist/riotprompt.cjs"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"riotprompt": "./dist/cli.cjs"
|
|
28
|
+
},
|
|
26
29
|
"scripts": {
|
|
27
|
-
"build": "npm run lint && tsc --noEmit && vite build",
|
|
30
|
+
"build": "npm run lint && tsc --noEmit && vite build && vite build -c vite.config.cli.ts",
|
|
28
31
|
"start": "dist/main.js",
|
|
29
32
|
"dev": "vite",
|
|
30
33
|
"watch": "vite build --watch",
|
|
@@ -43,7 +46,7 @@
|
|
|
43
46
|
"docs:test": "cd docs && npm run test",
|
|
44
47
|
"docs:coverage": "cd docs && npm run coverage"
|
|
45
48
|
},
|
|
46
|
-
"author": "
|
|
49
|
+
"author": "Tim O'Brien <tobrien@discursive.com>",
|
|
47
50
|
"license": "Apache-2.0",
|
|
48
51
|
"devDependencies": {
|
|
49
52
|
"@babel/core": "^7.28.0",
|
|
@@ -70,8 +73,16 @@
|
|
|
70
73
|
"vitest": "^3.2.4"
|
|
71
74
|
},
|
|
72
75
|
"dependencies": {
|
|
76
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
77
|
+
"@google/generative-ai": "^0.24.1",
|
|
78
|
+
"@theunwalked/cardigantime": "^0.0.17",
|
|
79
|
+
"commander": "^14.0.2",
|
|
80
|
+
"dotenv": "^17.2.3",
|
|
81
|
+
"fast-xml-parser": "^5.3.3",
|
|
73
82
|
"glob": "^11.0.3",
|
|
83
|
+
"js-yaml": "^4.1.1",
|
|
74
84
|
"marked": "^16.0.0",
|
|
85
|
+
"openai": "^6.15.0",
|
|
75
86
|
"tiktoken": "^1.0.22",
|
|
76
87
|
"zod": "^4.0.2"
|
|
77
88
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import shebang from 'rollup-plugin-preserve-shebang';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
resolve: {
|
|
7
|
+
alias: {
|
|
8
|
+
'@': path.resolve(__dirname, './src')
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
build: {
|
|
12
|
+
target: 'node18',
|
|
13
|
+
ssr: true, // Enable SSR mode for Node.js build
|
|
14
|
+
outDir: 'dist',
|
|
15
|
+
emptyOutDir: false,
|
|
16
|
+
lib: {
|
|
17
|
+
entry: './src/cli.ts',
|
|
18
|
+
formats: ['cjs'],
|
|
19
|
+
fileName: () => 'cli.cjs',
|
|
20
|
+
},
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
external: [
|
|
23
|
+
'commander',
|
|
24
|
+
'@theunwalked/cardigantime',
|
|
25
|
+
'fs',
|
|
26
|
+
'fs/promises',
|
|
27
|
+
'path',
|
|
28
|
+
'crypto',
|
|
29
|
+
'zod',
|
|
30
|
+
'marked',
|
|
31
|
+
'tiktoken',
|
|
32
|
+
'glob',
|
|
33
|
+
'js-yaml',
|
|
34
|
+
'fast-xml-parser',
|
|
35
|
+
'openai',
|
|
36
|
+
'@anthropic-ai/sdk',
|
|
37
|
+
'@google/generative-ai',
|
|
38
|
+
'dotenv',
|
|
39
|
+
'dotenv/config'
|
|
40
|
+
],
|
|
41
|
+
plugins: [
|
|
42
|
+
shebang({
|
|
43
|
+
shebang: '#!/usr/bin/env node',
|
|
44
|
+
}),
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|