@blackbelt-technology/pi-dashboard-extension 0.3.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.
Files changed (57) hide show
  1. package/.pi/skills/pi-dashboard/SKILL.md +134 -0
  2. package/.pi/skills/pi-dashboard/references/api-reference.md +470 -0
  3. package/.pi/skills/pi-dashboard/references/recipes.md +252 -0
  4. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +75 -0
  5. package/package.json +38 -0
  6. package/src/__tests__/ask-user-tool.test.ts +432 -0
  7. package/src/__tests__/command-handler.test.ts +712 -0
  8. package/src/__tests__/connection.test.ts +344 -0
  9. package/src/__tests__/credentials-updated.test.ts +26 -0
  10. package/src/__tests__/dashboard-default-adapter.test.ts +77 -0
  11. package/src/__tests__/dev-build.test.ts +79 -0
  12. package/src/__tests__/enrich-model-metadata.test.ts +201 -0
  13. package/src/__tests__/event-forwarder.test.ts +89 -0
  14. package/src/__tests__/fork-entryid-timing.test.ts +100 -0
  15. package/src/__tests__/git-info.test.ts +124 -0
  16. package/src/__tests__/git-link-builder.test.ts +102 -0
  17. package/src/__tests__/openspec-activity-detector.test.ts +232 -0
  18. package/src/__tests__/openspec-poller.test.ts +124 -0
  19. package/src/__tests__/process-metrics.test.ts +47 -0
  20. package/src/__tests__/process-scanner-kill.test.ts +61 -0
  21. package/src/__tests__/process-scanner.test.ts +202 -0
  22. package/src/__tests__/prompt-bus-wiring.test.ts +791 -0
  23. package/src/__tests__/prompt-bus.test.ts +469 -0
  24. package/src/__tests__/prompt-expander.test.ts +54 -0
  25. package/src/__tests__/provider-register-reload.test.ts +394 -0
  26. package/src/__tests__/server-auto-start.test.ts +258 -0
  27. package/src/__tests__/server-launcher.test.ts +61 -0
  28. package/src/__tests__/server-probe.test.ts +25 -0
  29. package/src/__tests__/session-switch.test.ts +139 -0
  30. package/src/__tests__/session-sync.test.ts +55 -0
  31. package/src/__tests__/source-detector.test.ts +73 -0
  32. package/src/__tests__/stats-extractor.test.ts +92 -0
  33. package/src/__tests__/tui-prompt-adapter.test.ts +207 -0
  34. package/src/__tests__/watchdog.test.ts +161 -0
  35. package/src/ask-user-tool.ts +352 -0
  36. package/src/bridge-context.ts +64 -0
  37. package/src/bridge.ts +1182 -0
  38. package/src/command-handler.ts +533 -0
  39. package/src/connection.ts +204 -0
  40. package/src/dashboard-default-adapter.ts +37 -0
  41. package/src/dev-build.ts +39 -0
  42. package/src/event-forwarder.ts +40 -0
  43. package/src/flow-event-wiring.ts +85 -0
  44. package/src/git-info.ts +55 -0
  45. package/src/git-link-builder.ts +112 -0
  46. package/src/model-tracker.ts +56 -0
  47. package/src/pi-env.d.ts +37 -0
  48. package/src/process-metrics.ts +70 -0
  49. package/src/process-scanner.ts +430 -0
  50. package/src/prompt-bus.ts +240 -0
  51. package/src/prompt-expander.ts +108 -0
  52. package/src/provider-register.ts +564 -0
  53. package/src/server-auto-start.ts +113 -0
  54. package/src/server-launcher.ts +126 -0
  55. package/src/server-probe.ts +33 -0
  56. package/src/session-sync.ts +155 -0
  57. package/src/source-detector.ts +26 -0
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: pi-dashboard
3
+ description: >
4
+ Monitor and control the pi-dashboard server. List sessions, send prompts,
5
+ abort runs, spawn new sessions, manage git branches, control flows, and
6
+ configure the dashboard — all via REST API. Use when you need to interact
7
+ with other pi sessions, check dashboard health, or orchestrate multi-session
8
+ workflows.
9
+ license: MIT
10
+ metadata:
11
+ author: pi-dashboard
12
+ version: "1.0"
13
+ ---
14
+
15
+ # Pi Dashboard Control
16
+
17
+ Interact with the pi-dashboard server from any pi session via its REST API.
18
+
19
+ ## Setup — Discover the Dashboard URL
20
+
21
+ Read the port from config, defaulting to `8000`:
22
+
23
+ ```bash
24
+ PORT=$(cat ~/.pi/dashboard/config.json 2>/dev/null | grep '"port"' | grep -o '[0-9]*' || echo 8000)
25
+ BASE="http://localhost:$PORT"
26
+ ```
27
+
28
+ Verify the server is running:
29
+
30
+ ```bash
31
+ curl -s "$BASE/api/health" | jq .
32
+ # Expected: { "ok": true, "pid": ..., "uptime": ... }
33
+ ```
34
+
35
+ ## Authentication
36
+
37
+ By default, auth is **disabled** and all localhost requests work without tokens.
38
+
39
+ When auth is enabled (remote/tunnel access), include the JWT cookie:
40
+
41
+ ```bash
42
+ # Check auth status
43
+ curl -s "$BASE/auth/status" | jq .
44
+
45
+ # If auth is enabled, include token in requests:
46
+ curl -s -b "pi_dash_token=YOUR_JWT" "$BASE/api/sessions" | jq .
47
+ ```
48
+
49
+ ## Quick Reference
50
+
51
+ ### Monitor
52
+
53
+ | Action | Command |
54
+ |--------|---------|
55
+ | List sessions | `curl -s "$BASE/api/sessions" \| jq .` |
56
+ | Server health | `curl -s "$BASE/api/health" \| jq .` |
57
+ | Session file diff | `curl -s "$BASE/api/session-diff?sessionId=ID" \| jq .` |
58
+ | Read file | `curl -s "$BASE/api/file?cwd=CWD&path=REL" \| jq .` |
59
+ | List pinned dirs | `curl -s "$BASE/api/pinned-dirs" \| jq .` |
60
+
61
+ ### Control Sessions
62
+
63
+ | Action | Command |
64
+ |--------|---------|
65
+ | Send prompt | `curl -s -X POST "$BASE/api/session/ID/prompt" -H 'Content-Type: application/json' -d '{"text":"your message"}'` |
66
+ | Abort | `curl -s -X POST "$BASE/api/session/ID/abort" -H 'Content-Type: application/json' -d '{}'` |
67
+ | Shutdown session | `curl -s -X POST "$BASE/api/session/ID/shutdown" -H 'Content-Type: application/json' -d '{}'` |
68
+ | Rename | `curl -s -X POST "$BASE/api/session/ID/rename" -H 'Content-Type: application/json' -d '{"name":"my-name"}'` |
69
+ | Hide | `curl -s -X POST "$BASE/api/session/ID/hide" -H 'Content-Type: application/json' -d '{}'` |
70
+ | Unhide | `curl -s -X POST "$BASE/api/session/ID/unhide" -H 'Content-Type: application/json' -d '{}'` |
71
+ | Spawn new | `curl -s -X POST "$BASE/api/session/spawn" -H 'Content-Type: application/json' -d '{"cwd":"/path"}'` |
72
+ | Resume/Fork | `curl -s -X POST "$BASE/api/session/ID/resume" -H 'Content-Type: application/json' -d '{"mode":"continue"}'` |
73
+
74
+ ### Flow Control
75
+
76
+ | Action | Command |
77
+ |--------|---------|
78
+ | Abort flow | `curl -s -X POST "$BASE/api/session/ID/flow-control" -H 'Content-Type: application/json' -d '{"action":"abort"}'` |
79
+ | Toggle autonomous | `curl -s -X POST "$BASE/api/session/ID/flow-control" -H 'Content-Type: application/json' -d '{"action":"toggle_autonomous"}'` |
80
+
81
+ ### Model / Thinking
82
+
83
+ | Action | Command |
84
+ |--------|---------|
85
+ | Set model | `curl -s -X POST "$BASE/api/session/ID/model" -H 'Content-Type: application/json' -d '{"provider":"anthropic","modelId":"claude-sonnet-4-20250514"}'` |
86
+ | Set thinking | `curl -s -X POST "$BASE/api/session/ID/thinking-level" -H 'Content-Type: application/json' -d '{"level":"high"}'` |
87
+
88
+ ### Git Operations
89
+
90
+ | Action | Command |
91
+ |--------|---------|
92
+ | List branches | `curl -s "$BASE/api/git/branches?cwd=CWD" \| jq .` |
93
+ | Checkout | `curl -s -X POST "$BASE/api/git/checkout" -H 'Content-Type: application/json' -d '{"cwd":"CWD","branch":"main"}'` |
94
+ | Init repo | `curl -s -X POST "$BASE/api/git/init" -H 'Content-Type: application/json' -d '{"cwd":"CWD"}'` |
95
+ | Stash pop | `curl -s -X POST "$BASE/api/git/stash-pop" -H 'Content-Type: application/json' -d '{"cwd":"CWD"}'` |
96
+
97
+ ### OpenSpec
98
+
99
+ | Action | Command |
100
+ |--------|---------|
101
+ | Attach proposal | `curl -s -X POST "$BASE/api/session/ID/attach-proposal" -H 'Content-Type: application/json' -d '{"changeName":"change-name"}'` |
102
+ | Detach proposal | `curl -s -X POST "$BASE/api/session/ID/detach-proposal" -H 'Content-Type: application/json' -d '{}'` |
103
+ | Archive listing | `curl -s "$BASE/api/openspec-archive?cwd=CWD" \| jq .` |
104
+
105
+ ### Configuration
106
+
107
+ | Action | Command |
108
+ |--------|---------|
109
+ | Read config | `curl -s "$BASE/api/config" \| jq .` |
110
+ | Update config | `curl -s -X PUT "$BASE/api/config" -H 'Content-Type: application/json' -d '{"autoShutdown":false}'` |
111
+
112
+ ### Tunnel
113
+
114
+ | Action | Command |
115
+ |--------|---------|
116
+ | Tunnel status | `curl -s "$BASE/api/tunnel-status" \| jq .` |
117
+ | Connect tunnel | `curl -s -X POST "$BASE/api/tunnel-connect"` |
118
+ | Disconnect tunnel | `curl -s -X POST "$BASE/api/tunnel-disconnect"` |
119
+
120
+ ## Helper Script
121
+
122
+ A convenience wrapper is available at [scripts/dashboard-api.sh](scripts/dashboard-api.sh):
123
+
124
+ ```bash
125
+ # Usage:
126
+ ./scripts/dashboard-api.sh GET /api/sessions
127
+ ./scripts/dashboard-api.sh POST /api/session/ID/prompt '{"text":"hello"}'
128
+ ./scripts/dashboard-api.sh POST /api/session/spawn '{"cwd":"/path/to/project"}'
129
+ ```
130
+
131
+ ## Detailed References
132
+
133
+ - [API Reference](references/api-reference.md) — Complete endpoint documentation with request/response schemas
134
+ - [Recipes](references/recipes.md) — Multi-step orchestration workflows
@@ -0,0 +1,470 @@
1
+ # Pi Dashboard REST API Reference
2
+
3
+ Base URL: `http://localhost:{port}` (default port: `8000`, configurable in `~/.pi/dashboard/config.json`).
4
+
5
+ All responses use JSON. Mutation endpoints require `Content-Type: application/json`.
6
+
7
+ ---
8
+
9
+ ## Health & Status
10
+
11
+ ### `GET /api/health`
12
+ Server liveness check.
13
+
14
+ **Response:**
15
+ ```json
16
+ { "ok": true, "pid": 12345, "uptime": 3600 }
17
+ ```
18
+
19
+ ### `GET /auth/status`
20
+ Check authentication status.
21
+
22
+ **Response (auth disabled):**
23
+ ```json
24
+ { "authenticated": true, "authEnabled": false }
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Sessions
30
+
31
+ ### `GET /api/sessions`
32
+ List all sessions.
33
+
34
+ **Response:**
35
+ ```json
36
+ {
37
+ "success": true,
38
+ "data": [
39
+ {
40
+ "id": "abc123",
41
+ "cwd": "/path/to/project",
42
+ "name": "my-session",
43
+ "source": "tui",
44
+ "status": "active",
45
+ "model": "claude-sonnet-4-20250514",
46
+ "startedAt": 1711900000000,
47
+ "tokensIn": 5000,
48
+ "tokensOut": 1200,
49
+ "cost": 0.05,
50
+ "currentTool": "Edit",
51
+ "gitBranch": "main",
52
+ "hidden": false
53
+ }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ **Session fields:**
59
+ | Field | Type | Description |
60
+ |-------|------|-------------|
61
+ | `id` | string | Unique session identifier |
62
+ | `cwd` | string | Working directory |
63
+ | `name` | string? | User-assigned name |
64
+ | `source` | string | Origin: `tui`, `zed`, `tmux`, `dashboard`, `terminal`, `unknown` |
65
+ | `status` | string | `active`, `idle`, `streaming`, `ended` |
66
+ | `model` | string? | Current model name |
67
+ | `thinkingLevel` | string? | Current thinking level |
68
+ | `startedAt` | number | Unix timestamp (ms) |
69
+ | `endedAt` | number? | Unix timestamp (ms) when ended |
70
+ | `tokensIn` | number? | Total input tokens |
71
+ | `tokensOut` | number? | Total output tokens |
72
+ | `cost` | number? | Total cost in USD |
73
+ | `currentTool` | string? | Currently executing tool name |
74
+ | `gitBranch` | string? | Current git branch |
75
+ | `attachedProposal` | string? | Attached OpenSpec change name |
76
+ | `hidden` | boolean? | Whether session is hidden |
77
+ | `activeFlowName` | string? | Running flow name |
78
+ | `flowStatus` | string? | `running`, `success`, `error`, `aborted` |
79
+ | `sessionFile` | string? | Path to session JSONL file |
80
+
81
+ ---
82
+
83
+ ## Session Control
84
+
85
+ ### `POST /api/session/:id/prompt`
86
+ Send a text prompt to a session.
87
+
88
+ **Body:**
89
+ ```json
90
+ { "text": "your prompt message", "images": [] }
91
+ ```
92
+ - `text` (required): Prompt text
93
+ - `images` (optional): Array of `{ type: "image", data: "base64...", mimeType: "image/png" }`
94
+
95
+ **Responses:**
96
+ - `200`: `{ "success": true }`
97
+ - `400`: Missing `text`
98
+ - `404`: Session not found
99
+ - `502`: No bridge connection (session not connected to dashboard)
100
+
101
+ ### `POST /api/session/:id/abort`
102
+ Abort the current operation in a session.
103
+
104
+ **Body:** `{}`
105
+
106
+ **Responses:**
107
+ - `200`: `{ "success": true }`
108
+ - `404`: Session not found
109
+
110
+ ### `POST /api/session/:id/shutdown`
111
+ Shut down a pi session (terminates the process, not the server).
112
+
113
+ **Body:** `{}`
114
+
115
+ **Responses:**
116
+ - `200`: `{ "success": true }`
117
+ - `404`: Session not found
118
+
119
+ ### `POST /api/session/:id/rename`
120
+ Rename a session.
121
+
122
+ **Body:**
123
+ ```json
124
+ { "name": "new-session-name" }
125
+ ```
126
+
127
+ **Responses:**
128
+ - `200`: `{ "success": true }`
129
+ - `400`: Missing `name`
130
+ - `404`: Session not found
131
+
132
+ ### `POST /api/session/:id/hide`
133
+ Hide a session from the default view.
134
+
135
+ **Body:** `{}`
136
+
137
+ **Responses:**
138
+ - `200`: `{ "success": true }`
139
+ - `404`: Session not found
140
+
141
+ ### `POST /api/session/:id/unhide`
142
+ Unhide a previously hidden session.
143
+
144
+ **Body:** `{}`
145
+
146
+ **Responses:**
147
+ - `200`: `{ "success": true }`
148
+ - `404`: Session not found
149
+
150
+ ### `POST /api/session/spawn`
151
+ Spawn a new pi session in a directory.
152
+
153
+ **Body:**
154
+ ```json
155
+ { "cwd": "/path/to/project" }
156
+ ```
157
+
158
+ **Responses:**
159
+ - `200`: `{ "success": true, "data": { "message": "..." } }`
160
+ - `400`: Missing `cwd`
161
+ - `500`: Spawn failed
162
+
163
+ ### `POST /api/session/:id/resume`
164
+ Resume or fork an ended session.
165
+
166
+ **Body:**
167
+ ```json
168
+ { "mode": "continue" }
169
+ ```
170
+ - `mode`: `"continue"` (resume same session) or `"fork"` (create a new branch from this session)
171
+
172
+ **Responses:**
173
+ - `200`: `{ "success": true, "data": { "message": "..." } }`
174
+ - `400`: Invalid `mode` or missing session file
175
+ - `404`: Session not found
176
+ - `409`: Session is still active or already resuming
177
+ - `500`: Spawn failed
178
+
179
+ ---
180
+
181
+ ## Flow Control
182
+
183
+ ### `POST /api/session/:id/flow-control`
184
+ Control a running flow.
185
+
186
+ **Body:**
187
+ ```json
188
+ { "action": "abort" }
189
+ ```
190
+ - `action`: `"abort"` or `"toggle_autonomous"`
191
+
192
+ **Responses:**
193
+ - `200`: `{ "success": true }`
194
+ - `400`: Invalid `action`
195
+ - `404`: Session not found
196
+
197
+ ---
198
+
199
+ ## Model Configuration
200
+
201
+ ### `POST /api/session/:id/model`
202
+ Set the model for a session.
203
+
204
+ **Body:**
205
+ ```json
206
+ { "provider": "anthropic", "modelId": "claude-sonnet-4-20250514" }
207
+ ```
208
+
209
+ **Responses:**
210
+ - `200`: `{ "success": true }`
211
+ - `400`: Missing `provider` or `modelId`
212
+ - `404`: Session not found
213
+
214
+ ### `POST /api/session/:id/thinking-level`
215
+ Set the thinking level for a session.
216
+
217
+ **Body:**
218
+ ```json
219
+ { "level": "high" }
220
+ ```
221
+
222
+ **Responses:**
223
+ - `200`: `{ "success": true }`
224
+ - `400`: Missing `level`
225
+ - `404`: Session not found
226
+
227
+ ---
228
+
229
+ ## OpenSpec
230
+
231
+ ### `POST /api/session/:id/attach-proposal`
232
+ Attach an OpenSpec change proposal to a session. Auto-names the session if unnamed.
233
+
234
+ **Body:**
235
+ ```json
236
+ { "changeName": "add-new-feature" }
237
+ ```
238
+
239
+ **Responses:**
240
+ - `200`: `{ "success": true }`
241
+ - `400`: Missing `changeName`
242
+ - `404`: Session not found
243
+
244
+ ### `POST /api/session/:id/detach-proposal`
245
+ Detach the currently attached proposal from a session.
246
+
247
+ **Body:** `{}`
248
+
249
+ **Responses:**
250
+ - `200`: `{ "success": true }`
251
+ - `404`: Session not found
252
+
253
+ ### `GET /api/openspec-archive?cwd=CWD`
254
+ List archived OpenSpec changes for a directory.
255
+
256
+ **Response:**
257
+ ```json
258
+ {
259
+ "success": true,
260
+ "data": [
261
+ { "name": "add-feature", "date": "2025-01-15", "path": "openspec/changes/archive/2025-01-15-add-feature" }
262
+ ]
263
+ }
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Git Operations
269
+
270
+ All git endpoints are **localhost-only**.
271
+
272
+ ### `GET /api/git/branches?cwd=CWD`
273
+ List git branches.
274
+
275
+ **Response:**
276
+ ```json
277
+ {
278
+ "success": true,
279
+ "data": {
280
+ "current": "main",
281
+ "detached": false,
282
+ "branches": [
283
+ { "name": "main", "isRemote": false, "isCurrent": true },
284
+ { "name": "origin/main", "isRemote": true, "isCurrent": false }
285
+ ]
286
+ }
287
+ }
288
+ ```
289
+
290
+ ### `POST /api/git/checkout`
291
+ Checkout a branch.
292
+
293
+ **Body:**
294
+ ```json
295
+ { "cwd": "/path", "branch": "feature-branch", "stash": false }
296
+ ```
297
+
298
+ **Responses:**
299
+ - `200`: `{ "success": true, "data": { "stashed": false } }`
300
+ - `409`: Dirty working tree (returns `{ "success": false, "dirty": true, "files": [...] }`)
301
+
302
+ ### `POST /api/git/init`
303
+ Initialize a git repository.
304
+
305
+ **Body:** `{ "cwd": "/path" }`
306
+
307
+ ### `POST /api/git/stash-pop`
308
+ Pop the most recent stash.
309
+
310
+ **Body:** `{ "cwd": "/path" }`
311
+
312
+ **Response:** `{ "success": true, "data": { "conflicts": false } }`
313
+
314
+ ---
315
+
316
+ ## Files & Browse
317
+
318
+ ### `GET /api/file?cwd=CWD&path=RELPATH`
319
+ Read a file or list a directory (localhost-only).
320
+
321
+ **Response (file):**
322
+ ```json
323
+ { "success": true, "data": { "type": "file", "content": "file contents..." } }
324
+ ```
325
+
326
+ **Response (directory):**
327
+ ```json
328
+ { "success": true, "data": { "type": "directory", "entries": ["file1.ts", "dir/"] } }
329
+ ```
330
+
331
+ ### `GET /api/browse?path=PATH`
332
+ Browse directories (localhost-only).
333
+
334
+ **Response:**
335
+ ```json
336
+ {
337
+ "success": true,
338
+ "data": {
339
+ "current": "/Users/me/projects",
340
+ "parent": "/Users/me",
341
+ "entries": [
342
+ { "name": "my-app", "path": "/Users/me/projects/my-app", "isGit": true, "isPi": true }
343
+ ]
344
+ }
345
+ }
346
+ ```
347
+
348
+ ### `GET /api/readme?cwd=CWD`
349
+ Read README.md from a directory (localhost-only).
350
+
351
+ ---
352
+
353
+ ## Events
354
+
355
+ ### `GET /api/events/:sessionId/:seq`
356
+ Fetch a specific event by sequence number.
357
+
358
+ **Response:**
359
+ ```json
360
+ {
361
+ "success": true,
362
+ "data": {
363
+ "eventType": "tool_use",
364
+ "timestamp": 1711900000000,
365
+ "data": { "toolName": "Edit", "input": "..." }
366
+ }
367
+ }
368
+ ```
369
+
370
+ ### `GET /api/session-diff?sessionId=ID`
371
+ Get file changes made during a session (localhost-only).
372
+
373
+ **Response:**
374
+ ```json
375
+ {
376
+ "success": true,
377
+ "data": {
378
+ "isGitRepo": true,
379
+ "files": [
380
+ {
381
+ "path": "src/app.ts",
382
+ "changes": [{ "type": "edit", "timestamp": 1711900000000, "message": "Add feature" }],
383
+ "gitDiff": "--- a/src/app.ts\n+++ b/src/app.ts\n..."
384
+ }
385
+ ]
386
+ }
387
+ }
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Configuration
393
+
394
+ ### `GET /api/config`
395
+ Read server configuration (redacted secrets, localhost-only).
396
+
397
+ ### `PUT /api/config`
398
+ Update server configuration (partial merge, localhost-only).
399
+
400
+ **Body (any subset):**
401
+ ```json
402
+ {
403
+ "port": 8000,
404
+ "autoShutdown": true,
405
+ "shutdownIdleSeconds": 300,
406
+ "spawnStrategy": "headless",
407
+ "tunnel": { "enabled": true }
408
+ }
409
+ ```
410
+
411
+ ---
412
+
413
+ ## Tunnel
414
+
415
+ ### `GET /api/tunnel-status`
416
+ Check tunnel status.
417
+
418
+ **Response:**
419
+ ```json
420
+ { "status": "active", "url": "https://abc.share.zrok.io", "serverOs": "darwin" }
421
+ ```
422
+ Status can be `active`, `inactive`, or `unavailable`.
423
+
424
+ ### `POST /api/tunnel-connect`
425
+ Create a tunnel connection.
426
+
427
+ ### `POST /api/tunnel-disconnect`
428
+ Disconnect the active tunnel.
429
+
430
+ ---
431
+
432
+ ## Server Lifecycle
433
+
434
+ ### `POST /api/shutdown`
435
+ Shut down the dashboard server (localhost-only). Flushes persistence before exit.
436
+
437
+ **Response:** `{ "ok": true }`
438
+
439
+ ---
440
+
441
+ ## Pi Resources
442
+
443
+ ### `GET /api/pi-resources?cwd=CWD`
444
+ List discovered extensions, skills, and prompts (localhost-only).
445
+
446
+ ### `GET /api/pi-resource-file?path=FILEPATH`
447
+ Read a pi resource file (localhost-only, restricted to allowed locations).
448
+
449
+ ### `GET /api/editors?path=CWD`
450
+ Detect available editors (localhost-only).
451
+
452
+ ### `POST /api/open-editor`
453
+ Open a file in an editor (localhost-only).
454
+
455
+ **Body:**
456
+ ```json
457
+ { "path": "/project", "editor": "vscode", "file": "src/app.ts", "line": 42 }
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Pinned Directories
463
+
464
+ ### `GET /api/pinned-dirs`
465
+ List pinned directories.
466
+
467
+ **Response:**
468
+ ```json
469
+ { "success": true, "data": ["/path/to/project1", "/path/to/project2"] }
470
+ ```