@plures/runebook 0.4.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/ANALYSIS_LADDER.md +231 -0
- package/CHANGELOG.md +124 -0
- package/INTEGRATIONS.md +242 -0
- package/LICENSE +21 -0
- package/MEMORY.md +253 -0
- package/NIXOS.md +357 -0
- package/QUICKSTART.md +157 -0
- package/README.md +295 -0
- package/RELEASE.md +190 -0
- package/ValidationChecklist.md +598 -0
- package/docs/demo.md +338 -0
- package/docs/llm-integration.md +300 -0
- package/docs/parallel-execution-plan.md +160 -0
- package/flake.nix +228 -0
- package/integrations/README.md +242 -0
- package/integrations/demo-steps.sh +64 -0
- package/integrations/nvim-runebook.lua +140 -0
- package/integrations/tmux-status.sh +51 -0
- package/integrations/vim-runebook.vim +77 -0
- package/integrations/wezterm-status-simple.lua +48 -0
- package/integrations/wezterm-status.lua +76 -0
- package/nixos-module.nix +156 -0
- package/package.json +76 -0
- package/packages/design-dojo/index.js +4 -0
- package/packages/design-dojo/package.json +20 -0
- package/packages/design-dojo/tokens.css +69 -0
- package/playwright.config.ts +16 -0
- package/scripts/check-versions.cjs +62 -0
- package/scripts/demo.sh +220 -0
- package/shell.nix +31 -0
- package/src/app.html +13 -0
- package/src/cli/index.ts +1050 -0
- package/src/lib/agent/analysis-pipeline.ts +347 -0
- package/src/lib/agent/analysis-service.ts +171 -0
- package/src/lib/agent/analysis.ts +159 -0
- package/src/lib/agent/analyzers/heuristic.ts +289 -0
- package/src/lib/agent/analyzers/index.ts +7 -0
- package/src/lib/agent/analyzers/llm.ts +204 -0
- package/src/lib/agent/analyzers/local-search.ts +215 -0
- package/src/lib/agent/capture.ts +123 -0
- package/src/lib/agent/index.ts +244 -0
- package/src/lib/agent/integration.ts +81 -0
- package/src/lib/agent/llm/providers/base.ts +99 -0
- package/src/lib/agent/llm/providers/index.ts +60 -0
- package/src/lib/agent/llm/providers/mock.ts +67 -0
- package/src/lib/agent/llm/providers/ollama.ts +151 -0
- package/src/lib/agent/llm/providers/openai.ts +153 -0
- package/src/lib/agent/llm/sanitizer.ts +170 -0
- package/src/lib/agent/llm/types.ts +118 -0
- package/src/lib/agent/memory.ts +363 -0
- package/src/lib/agent/node-status.ts +56 -0
- package/src/lib/agent/node-suggestions.ts +64 -0
- package/src/lib/agent/status.ts +80 -0
- package/src/lib/agent/suggestions.ts +169 -0
- package/src/lib/components/Canvas.svelte +124 -0
- package/src/lib/components/ConnectionLine.svelte +46 -0
- package/src/lib/components/DisplayNode.svelte +167 -0
- package/src/lib/components/InputNode.svelte +158 -0
- package/src/lib/components/TerminalNode.svelte +237 -0
- package/src/lib/components/Toolbar.svelte +359 -0
- package/src/lib/components/TransformNode.svelte +327 -0
- package/src/lib/core/index.ts +31 -0
- package/src/lib/core/observer.ts +278 -0
- package/src/lib/core/redaction.ts +158 -0
- package/src/lib/core/shell-adapters/base.ts +325 -0
- package/src/lib/core/shell-adapters/bash.ts +110 -0
- package/src/lib/core/shell-adapters/index.ts +62 -0
- package/src/lib/core/shell-adapters/zsh.ts +105 -0
- package/src/lib/core/storage.ts +360 -0
- package/src/lib/core/types.ts +176 -0
- package/src/lib/design-dojo/Box.svelte +47 -0
- package/src/lib/design-dojo/Button.svelte +75 -0
- package/src/lib/design-dojo/Input.svelte +65 -0
- package/src/lib/design-dojo/List.svelte +38 -0
- package/src/lib/design-dojo/Select.svelte +48 -0
- package/src/lib/design-dojo/SplitPane.svelte +43 -0
- package/src/lib/design-dojo/StatusBar.svelte +61 -0
- package/src/lib/design-dojo/Table.svelte +47 -0
- package/src/lib/design-dojo/Text.svelte +36 -0
- package/src/lib/design-dojo/Toggle.svelte +48 -0
- package/src/lib/design-dojo/index.ts +10 -0
- package/src/lib/stores/canvas-praxis.ts +268 -0
- package/src/lib/stores/canvas.ts +58 -0
- package/src/lib/types/agent.ts +78 -0
- package/src/lib/types/canvas.ts +71 -0
- package/src/lib/utils/storage.ts +326 -0
- package/src/lib/utils/yaml-loader.ts +52 -0
- package/src/routes/+layout.svelte +5 -0
- package/src/routes/+layout.ts +5 -0
- package/src/routes/+page.svelte +32 -0
- package/src-tauri/Cargo.lock +5735 -0
- package/src-tauri/Cargo.toml +38 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/capabilities/default.json +10 -0
- package/src-tauri/icons/128x128.png +0 -0
- package/src-tauri/icons/128x128@2x.png +0 -0
- package/src-tauri/icons/32x32.png +0 -0
- package/src-tauri/icons/Square107x107Logo.png +0 -0
- package/src-tauri/icons/Square142x142Logo.png +0 -0
- package/src-tauri/icons/Square150x150Logo.png +0 -0
- package/src-tauri/icons/Square284x284Logo.png +0 -0
- package/src-tauri/icons/Square30x30Logo.png +0 -0
- package/src-tauri/icons/Square310x310Logo.png +0 -0
- package/src-tauri/icons/Square44x44Logo.png +0 -0
- package/src-tauri/icons/Square71x71Logo.png +0 -0
- package/src-tauri/icons/Square89x89Logo.png +0 -0
- package/src-tauri/icons/StoreLogo.png +0 -0
- package/src-tauri/icons/icon.icns +0 -0
- package/src-tauri/icons/icon.ico +0 -0
- package/src-tauri/icons/icon.png +0 -0
- package/src-tauri/src/agents/agent1.rs +66 -0
- package/src-tauri/src/agents/agent2.rs +80 -0
- package/src-tauri/src/agents/agent3.rs +73 -0
- package/src-tauri/src/agents/agent4.rs +66 -0
- package/src-tauri/src/agents/agent5.rs +68 -0
- package/src-tauri/src/agents/agent6.rs +75 -0
- package/src-tauri/src/agents/base.rs +52 -0
- package/src-tauri/src/agents/mod.rs +17 -0
- package/src-tauri/src/core/coordination.rs +117 -0
- package/src-tauri/src/core/mod.rs +12 -0
- package/src-tauri/src/core/ownership.rs +61 -0
- package/src-tauri/src/core/types.rs +132 -0
- package/src-tauri/src/execution/mod.rs +5 -0
- package/src-tauri/src/execution/runner.rs +143 -0
- package/src-tauri/src/lib.rs +161 -0
- package/src-tauri/src/main.rs +6 -0
- package/src-tauri/src/memory/api.rs +422 -0
- package/src-tauri/src/memory/client.rs +156 -0
- package/src-tauri/src/memory/encryption.rs +79 -0
- package/src-tauri/src/memory/migration.rs +110 -0
- package/src-tauri/src/memory/mod.rs +28 -0
- package/src-tauri/src/memory/schema.rs +275 -0
- package/src-tauri/src/memory/tests.rs +192 -0
- package/src-tauri/src/orchestrator/coordinator.rs +232 -0
- package/src-tauri/src/orchestrator/mod.rs +13 -0
- package/src-tauri/src/orchestrator/planner.rs +304 -0
- package/src-tauri/tauri.conf.json +35 -0
- package/static/examples/date-time-example.yaml +147 -0
- package/static/examples/hello-world.yaml +74 -0
- package/static/examples/transform-example.yaml +157 -0
- package/static/favicon.png +0 -0
- package/static/svelte.svg +1 -0
- package/static/tauri.svg +6 -0
- package/static/vite.svg +1 -0
- package/svelte.config.js +18 -0
- package/tsconfig.json +19 -0
- package/vite.config.js +45 -0
- package/vitest.config.ts +21 -0
package/docs/demo.md
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# RuneBook Ambient Agent Mode - "Zero to Hero" Demo
|
|
2
|
+
|
|
3
|
+
This walkthrough demonstrates RuneBook's Ambient Agent Mode from setup to analysis, showing how it captures terminal commands, analyzes failures, and provides intelligent suggestions.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 20.x or higher
|
|
8
|
+
- RuneBook installed (or development environment)
|
|
9
|
+
- Nix installed (for demo commands that will fail)
|
|
10
|
+
- Terminal access
|
|
11
|
+
|
|
12
|
+
## Demo Overview
|
|
13
|
+
|
|
14
|
+
This demo will:
|
|
15
|
+
1. Enable Ambient Agent Mode
|
|
16
|
+
2. Run a few failing Nix commands
|
|
17
|
+
3. Show RuneBook capturing the events
|
|
18
|
+
4. Display analysis results and suggestions
|
|
19
|
+
5. Show how to inspect and manage stored data
|
|
20
|
+
|
|
21
|
+
## Step 1: Enable Ambient Agent Mode
|
|
22
|
+
|
|
23
|
+
First, enable the agent:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run agent enable
|
|
27
|
+
npm run agent status
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
You should see:
|
|
31
|
+
```
|
|
32
|
+
=== Ambient Agent Status ===
|
|
33
|
+
|
|
34
|
+
Enabled: Yes
|
|
35
|
+
Capture Events: Yes
|
|
36
|
+
Analyze Patterns: Yes
|
|
37
|
+
Suggest Improvements: Yes
|
|
38
|
+
Storage Path: Memory (in-memory)
|
|
39
|
+
...
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Step 2: Run Failing Commands
|
|
43
|
+
|
|
44
|
+
Now let's run some commands that will fail. These are common Nix development errors:
|
|
45
|
+
|
|
46
|
+
### Command 1: Missing Attribute Error
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
nix build .#cursor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This will likely fail with an error like:
|
|
53
|
+
```
|
|
54
|
+
error: attribute 'cursor' missing
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Command 2: Flake-Parts Template Path Error
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
nix flake init -t flake-parts#devShells
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This might fail with:
|
|
64
|
+
```
|
|
65
|
+
error: path '/nix/store/.../devShells' does not exist
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Command 3: Build Environment Font Conflict
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
nix build .#packages.x86_64-linux.default
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This might fail with font-related errors in buildEnv.
|
|
75
|
+
|
|
76
|
+
## Step 3: View Captured Events
|
|
77
|
+
|
|
78
|
+
Check what RuneBook captured:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm run agent events 10
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You should see output like:
|
|
85
|
+
```
|
|
86
|
+
=== Recent Events (3) ===
|
|
87
|
+
|
|
88
|
+
✗ [2024-12-27 10:30:15] nix build .#cursor
|
|
89
|
+
Duration: 2.34s, Exit Code: 1
|
|
90
|
+
CWD: /home/user/projects/myproject
|
|
91
|
+
|
|
92
|
+
✗ [2024-12-27 10:30:20] nix flake init -t flake-parts#devShells
|
|
93
|
+
Duration: 1.89s, Exit Code: 1
|
|
94
|
+
CWD: /home/user/projects/myproject
|
|
95
|
+
|
|
96
|
+
✗ [2024-12-27 10:30:25] nix build .#packages.x86_64-linux.default
|
|
97
|
+
Duration: 15.67s, Exit Code: 1
|
|
98
|
+
CWD: /home/user/projects/myproject
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Step 4: Analyze Last Failure
|
|
102
|
+
|
|
103
|
+
Analyze the most recent failure:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm run analyze last
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
You should see detailed analysis:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
=== Analysis Results ===
|
|
113
|
+
|
|
114
|
+
Command: nix build .#cursor
|
|
115
|
+
Exit Code: 1
|
|
116
|
+
Status: completed
|
|
117
|
+
CWD: /home/user/projects/myproject
|
|
118
|
+
|
|
119
|
+
Stderr:
|
|
120
|
+
error: attribute 'cursor' missing
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
=== Suggestions (2) ===
|
|
124
|
+
|
|
125
|
+
[NixErrorAnalyzer] Missing Attribute "cursor" (confidence: 90%)
|
|
126
|
+
The attribute "cursor" is missing from your flake outputs or packages.
|
|
127
|
+
|
|
128
|
+
Check your flake.nix file and ensure the attribute exists:
|
|
129
|
+
|
|
130
|
+
outputs = { self, nixpkgs, ... }: {
|
|
131
|
+
packages.x86_64-linux.cursor = ...;
|
|
132
|
+
# or
|
|
133
|
+
packages.cursor = ...;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
[LocalSearchAnalyzer] Check flake.nix for available attributes (confidence: 75%)
|
|
137
|
+
Your flake.nix might have similar attributes. Check the file for available options.
|
|
138
|
+
|
|
139
|
+
grep -r "packages\|outputs" flake.nix
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Step 5: View All Suggestions
|
|
143
|
+
|
|
144
|
+
See all current suggestions:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm run agent suggestions
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Output:
|
|
151
|
+
```
|
|
152
|
+
=== Suggestions ===
|
|
153
|
+
|
|
154
|
+
[high] Missing Attribute "cursor"
|
|
155
|
+
The attribute "cursor" is missing from your flake outputs.
|
|
156
|
+
Confidence: 90%
|
|
157
|
+
|
|
158
|
+
[medium] Check flake.nix for available attributes
|
|
159
|
+
Your flake.nix might have similar attributes.
|
|
160
|
+
Confidence: 75%
|
|
161
|
+
|
|
162
|
+
[low] Consider using nix search for available packages
|
|
163
|
+
Use 'nix search' to find available packages.
|
|
164
|
+
Confidence: 60%
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Step 6: Inspect Memory Storage
|
|
168
|
+
|
|
169
|
+
If using PluresDB, inspect the cognitive memory:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm run memory inspect
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Output:
|
|
176
|
+
```
|
|
177
|
+
=== RuneBook Cognitive Memory ===
|
|
178
|
+
|
|
179
|
+
Sessions: 1
|
|
180
|
+
Recent Errors: 3
|
|
181
|
+
Active Suggestions: 3
|
|
182
|
+
|
|
183
|
+
=== Recent Sessions ===
|
|
184
|
+
abc12345... - bash (started: 12/27/2024, 10:30:00 AM)
|
|
185
|
+
|
|
186
|
+
=== Recent Errors ===
|
|
187
|
+
[high] exit_code - error: attribute 'cursor' missing
|
|
188
|
+
[high] exit_code - path '/nix/store/.../devShells' does not exist
|
|
189
|
+
[medium] exit_code - font conflict in buildEnv
|
|
190
|
+
|
|
191
|
+
=== Top Suggestions ===
|
|
192
|
+
[high] Missing Attribute "cursor" - The attribute "cursor" is missing...
|
|
193
|
+
[medium] Check flake.nix for available attributes - Your flake.nix might...
|
|
194
|
+
[low] Consider using nix search - Use 'nix search' to find...
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Step 7: View Agent Statistics
|
|
198
|
+
|
|
199
|
+
Check overall agent statistics:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm run agent status
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Output:
|
|
206
|
+
```
|
|
207
|
+
=== Ambient Agent Status ===
|
|
208
|
+
|
|
209
|
+
Enabled: Yes
|
|
210
|
+
Capture Events: Yes
|
|
211
|
+
Analyze Patterns: Yes
|
|
212
|
+
Suggest Improvements: Yes
|
|
213
|
+
Storage Path: Memory (in-memory)
|
|
214
|
+
Max Events: Unlimited
|
|
215
|
+
Retention Days: 30
|
|
216
|
+
|
|
217
|
+
=== Statistics ===
|
|
218
|
+
Total Events: 3
|
|
219
|
+
Unique Commands: 3
|
|
220
|
+
Average Success Rate: 0.0%
|
|
221
|
+
Total Duration: 20.0s
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Step 8: Observer Mode (Optional)
|
|
225
|
+
|
|
226
|
+
For more detailed event capture, enable the observer:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm run observer enable
|
|
230
|
+
npm run observer status
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Then tail events in real-time:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm run observer events tail
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
In another terminal, run a command:
|
|
240
|
+
```bash
|
|
241
|
+
nix build .#test
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
You'll see events stream in:
|
|
245
|
+
```
|
|
246
|
+
[2024-12-27T10:35:00.000Z] command_start nix build .#test
|
|
247
|
+
CWD: /home/user/projects/myproject
|
|
248
|
+
[2024-12-27T10:35:02.000Z] stdout_chunk [0] building...
|
|
249
|
+
[2024-12-27T10:35:05.000Z] exit_status exitCode: 1, success: false
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Step 9: Clean Up Data
|
|
253
|
+
|
|
254
|
+
Clear old events (optional):
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Clear events older than 7 days
|
|
258
|
+
npm run agent clear 7
|
|
259
|
+
|
|
260
|
+
# Or clear all events older than 30 days (default)
|
|
261
|
+
npm run agent clear
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Troubleshooting
|
|
265
|
+
|
|
266
|
+
### Agent not capturing events
|
|
267
|
+
|
|
268
|
+
1. Check if agent is enabled:
|
|
269
|
+
```bash
|
|
270
|
+
npm run agent status
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
2. Verify configuration:
|
|
274
|
+
```bash
|
|
275
|
+
cat ~/.runebook/agent-config.json
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
3. Ensure `captureEvents: true` in config
|
|
279
|
+
|
|
280
|
+
### No suggestions appearing
|
|
281
|
+
|
|
282
|
+
1. Run some commands first (agent needs data to analyze)
|
|
283
|
+
2. Check for failures:
|
|
284
|
+
```bash
|
|
285
|
+
npm run agent events 20
|
|
286
|
+
```
|
|
287
|
+
3. Run analysis:
|
|
288
|
+
```bash
|
|
289
|
+
npm run analyze last
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### PluresDB not available
|
|
293
|
+
|
|
294
|
+
If you see "PluresDB server not available":
|
|
295
|
+
|
|
296
|
+
1. Check if PluresDB is running:
|
|
297
|
+
```bash
|
|
298
|
+
curl http://localhost:34567/health
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
2. Start PluresDB:
|
|
302
|
+
```bash
|
|
303
|
+
pluresdb --port 34567
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
3. Or use in-memory storage (default):
|
|
307
|
+
- The agent works fine with in-memory storage
|
|
308
|
+
- Data will be lost on restart, but it's fine for testing
|
|
309
|
+
|
|
310
|
+
### Analysis not working
|
|
311
|
+
|
|
312
|
+
1. Ensure observer is enabled:
|
|
313
|
+
```bash
|
|
314
|
+
npm run observer status
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
2. Check that commands are being captured:
|
|
318
|
+
```bash
|
|
319
|
+
npm run observer events 10
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
3. Verify analysis service is initialized (check logs)
|
|
323
|
+
|
|
324
|
+
## Next Steps
|
|
325
|
+
|
|
326
|
+
- **Read the documentation**: See [README.md](../README.md) for full feature list
|
|
327
|
+
- **Explore analysis ladder**: See [ANALYSIS_LADDER.md](../ANALYSIS_LADDER.md) for analysis details
|
|
328
|
+
- **Check architecture**: See [ARCHITECTURE.md](../ARCHITECTURE.md) for technical details
|
|
329
|
+
- **Review memory schema**: See [MEMORY.md](../MEMORY.md) for storage details
|
|
330
|
+
|
|
331
|
+
## Demo Script
|
|
332
|
+
|
|
333
|
+
For an automated version of this demo, run:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
bash scripts/demo.sh
|
|
337
|
+
```
|
|
338
|
+
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# LLM/MCP Integration
|
|
2
|
+
|
|
3
|
+
RuneBook supports optional model-backed reasoning via LLM providers or MCP (Model Context Protocol). This feature is **disabled by default** and must be explicitly enabled in configuration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The LLM integration provides intelligent suggestions for command failures by analyzing:
|
|
8
|
+
- Command context (command, args, working directory)
|
|
9
|
+
- Error output (stderr, stdout)
|
|
10
|
+
- Previous commands
|
|
11
|
+
- Repository metadata
|
|
12
|
+
|
|
13
|
+
All LLM analysis is **suggestion-only** - it never executes commands automatically.
|
|
14
|
+
|
|
15
|
+
## Safety Features
|
|
16
|
+
|
|
17
|
+
### Context Sanitization
|
|
18
|
+
Before sending context to an LLM, RuneBook automatically redacts:
|
|
19
|
+
- API keys and tokens (GitHub tokens, OpenAI keys, AWS keys, etc.)
|
|
20
|
+
- Environment variables containing secrets
|
|
21
|
+
- Private keys
|
|
22
|
+
- JWT tokens
|
|
23
|
+
- Long alphanumeric strings that look like tokens
|
|
24
|
+
|
|
25
|
+
### User Review
|
|
26
|
+
By default, the sanitized context is shown to the user before sending to the LLM. This can be disabled in configuration, but is recommended for privacy.
|
|
27
|
+
|
|
28
|
+
### Caching (Optional)
|
|
29
|
+
Responses can be cached to reduce API calls and costs. Cache TTL is configurable.
|
|
30
|
+
|
|
31
|
+
### Never Auto-Execute
|
|
32
|
+
LLM suggestions are **never executed automatically**. They are only displayed as suggestions that the user can review and apply manually.
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
### Basic Configuration
|
|
37
|
+
|
|
38
|
+
Add LLM configuration to your observer config file (`~/.runebook/observer-config.json`):
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"redactSecrets": true,
|
|
44
|
+
"llm": {
|
|
45
|
+
"type": "ollama",
|
|
46
|
+
"enabled": true,
|
|
47
|
+
"ollama": {
|
|
48
|
+
"model": "llama3.2",
|
|
49
|
+
"baseUrl": "http://localhost:11434"
|
|
50
|
+
},
|
|
51
|
+
"safety": {
|
|
52
|
+
"requireUserReview": true,
|
|
53
|
+
"cacheEnabled": false,
|
|
54
|
+
"cacheTtl": 3600
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Provider Types
|
|
61
|
+
|
|
62
|
+
#### Ollama (Local)
|
|
63
|
+
Runs models locally via Ollama. No API keys required.
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"llm": {
|
|
68
|
+
"type": "ollama",
|
|
69
|
+
"enabled": true,
|
|
70
|
+
"ollama": {
|
|
71
|
+
"model": "llama3.2",
|
|
72
|
+
"baseUrl": "http://localhost:11434"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Requirements:**
|
|
79
|
+
- Ollama installed and running (`ollama serve`)
|
|
80
|
+
- Model pulled (`ollama pull llama3.2`)
|
|
81
|
+
|
|
82
|
+
#### OpenAI
|
|
83
|
+
Uses OpenAI API. Requires API key.
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"llm": {
|
|
88
|
+
"type": "openai",
|
|
89
|
+
"enabled": true,
|
|
90
|
+
"openai": {
|
|
91
|
+
"model": "gpt-4o-mini",
|
|
92
|
+
"apiKey": "${OPENAI_API_KEY}"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Requirements:**
|
|
99
|
+
- `OPENAI_API_KEY` environment variable set
|
|
100
|
+
- Or provide `apiKey` in config (less secure)
|
|
101
|
+
|
|
102
|
+
#### Mock (Testing)
|
|
103
|
+
Returns deterministic responses for testing.
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"llm": {
|
|
108
|
+
"type": "mock",
|
|
109
|
+
"enabled": true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### MCP (Future)
|
|
115
|
+
MCP provider support is planned but not yet implemented.
|
|
116
|
+
|
|
117
|
+
### Safety Configuration
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"safety": {
|
|
122
|
+
"requireUserReview": true, // Show context before sending (default: true)
|
|
123
|
+
"maxContextLength": 8000, // Truncate if too long (default: 8000 tokens)
|
|
124
|
+
"cacheEnabled": false, // Cache responses (default: false)
|
|
125
|
+
"cacheTtl": 3600 // Cache TTL in seconds (default: 3600)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## CLI Commands
|
|
131
|
+
|
|
132
|
+
### Check LLM Status
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
runebook llm status
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Shows:
|
|
139
|
+
- Provider type and availability
|
|
140
|
+
- Configuration settings
|
|
141
|
+
- Safety settings
|
|
142
|
+
- Provider-specific configuration
|
|
143
|
+
|
|
144
|
+
## Privacy Considerations
|
|
145
|
+
|
|
146
|
+
### What Data is Sent
|
|
147
|
+
|
|
148
|
+
When LLM analysis is enabled, the following data may be sent to the LLM provider:
|
|
149
|
+
- Command and arguments (sanitized)
|
|
150
|
+
- Working directory
|
|
151
|
+
- Error output (stderr, sanitized)
|
|
152
|
+
- Standard output (stdout, sanitized)
|
|
153
|
+
- Previous commands (last 3-5)
|
|
154
|
+
- Repository metadata (type, language, relevant files)
|
|
155
|
+
|
|
156
|
+
### What is NOT Sent
|
|
157
|
+
|
|
158
|
+
- Full environment variables (only sanitized summary)
|
|
159
|
+
- Secrets, tokens, API keys (redacted)
|
|
160
|
+
- Full file contents (only metadata)
|
|
161
|
+
- Personal information (if present in commands, may be included)
|
|
162
|
+
|
|
163
|
+
### Data Retention
|
|
164
|
+
|
|
165
|
+
- **Ollama (Local)**: Data never leaves your machine
|
|
166
|
+
- **OpenAI**: Data is sent to OpenAI's API. Check OpenAI's privacy policy for data retention.
|
|
167
|
+
- **Mock**: No external calls, only for testing
|
|
168
|
+
|
|
169
|
+
### Recommendations
|
|
170
|
+
|
|
171
|
+
1. **Use Ollama for maximum privacy** - All processing happens locally
|
|
172
|
+
2. **Enable user review** - Review context before sending
|
|
173
|
+
3. **Review sanitization** - Check what was redacted before sending
|
|
174
|
+
4. **Disable if sensitive** - If working with highly sensitive data, disable LLM analysis
|
|
175
|
+
|
|
176
|
+
## MCP Tool Contract
|
|
177
|
+
|
|
178
|
+
The LLM integration uses a standardized contract for communication:
|
|
179
|
+
|
|
180
|
+
### Input
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
{
|
|
184
|
+
contextWindow: {
|
|
185
|
+
command: string;
|
|
186
|
+
args: string[];
|
|
187
|
+
cwd: string;
|
|
188
|
+
env: Record<string, string>; // Sanitized
|
|
189
|
+
exitCode: number;
|
|
190
|
+
stdout: string; // Sanitized
|
|
191
|
+
stderr: string; // Sanitized
|
|
192
|
+
previousCommands: Array<{...}>;
|
|
193
|
+
};
|
|
194
|
+
errorSummary: {
|
|
195
|
+
command: string;
|
|
196
|
+
args: string[];
|
|
197
|
+
exitCode: number;
|
|
198
|
+
stderr: string;
|
|
199
|
+
stdout: string;
|
|
200
|
+
cwd: string;
|
|
201
|
+
timestamp: number;
|
|
202
|
+
};
|
|
203
|
+
repoMetadata: {
|
|
204
|
+
root?: string;
|
|
205
|
+
type?: 'git' | 'hg' | 'svn' | 'none';
|
|
206
|
+
files?: string[];
|
|
207
|
+
language?: string;
|
|
208
|
+
framework?: string;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Output
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
{
|
|
217
|
+
suggestions: Array<{
|
|
218
|
+
title: string;
|
|
219
|
+
description: string;
|
|
220
|
+
actionableSnippet?: string;
|
|
221
|
+
confidence: number; // 0.0 to 1.0
|
|
222
|
+
type: 'command' | 'optimization' | 'shortcut' | 'warning' | 'tip';
|
|
223
|
+
priority: 'low' | 'medium' | 'high';
|
|
224
|
+
}>;
|
|
225
|
+
provenance: {
|
|
226
|
+
provider: string;
|
|
227
|
+
model?: string;
|
|
228
|
+
timestamp: number;
|
|
229
|
+
tokensUsed?: number;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Troubleshooting
|
|
235
|
+
|
|
236
|
+
### Ollama Not Available
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
Error: Ollama provider is not available
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Solution:**
|
|
243
|
+
1. Make sure Ollama is running: `ollama serve`
|
|
244
|
+
2. Check if the model is installed: `ollama list`
|
|
245
|
+
3. Pull the model if needed: `ollama pull llama3.2`
|
|
246
|
+
4. Verify base URL in config matches Ollama's port
|
|
247
|
+
|
|
248
|
+
### OpenAI API Key Missing
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
Error: OpenAI API key not found
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Solution:**
|
|
255
|
+
1. Set `OPENAI_API_KEY` environment variable: `export OPENAI_API_KEY=sk-...`
|
|
256
|
+
2. Or provide `apiKey` in config (less secure)
|
|
257
|
+
|
|
258
|
+
### Provider Not Responding
|
|
259
|
+
|
|
260
|
+
If the provider times out or fails:
|
|
261
|
+
1. Check network connectivity (for OpenAI)
|
|
262
|
+
2. Check provider logs (for Ollama)
|
|
263
|
+
3. Try disabling and re-enabling LLM analysis
|
|
264
|
+
4. Check `runebook llm status` for detailed error messages
|
|
265
|
+
|
|
266
|
+
## Examples
|
|
267
|
+
|
|
268
|
+
### Example: Nix Build Error
|
|
269
|
+
|
|
270
|
+
When a Nix build fails, the LLM analyzer receives:
|
|
271
|
+
- Command: `nix build`
|
|
272
|
+
- Error: Missing attribute "cursor"
|
|
273
|
+
- Repository: Nix flake with `flake.nix`
|
|
274
|
+
|
|
275
|
+
The LLM might suggest:
|
|
276
|
+
- Check if the attribute exists in the flake
|
|
277
|
+
- Verify the input source
|
|
278
|
+
- Check for typos in attribute names
|
|
279
|
+
|
|
280
|
+
### Example: Git Authentication Error
|
|
281
|
+
|
|
282
|
+
When Git authentication fails:
|
|
283
|
+
- Command: `git push`
|
|
284
|
+
- Error: Authentication failed
|
|
285
|
+
- Repository: Git repository
|
|
286
|
+
|
|
287
|
+
The LLM might suggest:
|
|
288
|
+
- Check if credentials are configured
|
|
289
|
+
- Verify SSH key or token
|
|
290
|
+
- Check GitHub rate limits
|
|
291
|
+
|
|
292
|
+
## Future Enhancements
|
|
293
|
+
|
|
294
|
+
- [ ] MCP protocol support
|
|
295
|
+
- [ ] Additional providers (Anthropic, local models)
|
|
296
|
+
- [ ] Fine-tuned models for specific error types
|
|
297
|
+
- [ ] Context window optimization
|
|
298
|
+
- [ ] Streaming responses
|
|
299
|
+
- [ ] Multi-model ensemble
|
|
300
|
+
|