@softspark/ai-toolkit 1.9.0 → 2.0.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +40 -14
  2. package/README.md +18 -18
  3. package/app/ARCHITECTURE.md +3 -3
  4. package/app/hooks/governance-capture.sh +1 -1
  5. package/app/hooks/pre-compact-save.sh +1 -1
  6. package/app/hooks/session-context.sh +1 -1
  7. package/app/hooks/track-usage.sh +2 -2
  8. package/app/hooks.json +20 -20
  9. package/app/plugins/memory-pack/README.md +1 -1
  10. package/app/plugins/memory-pack/hooks/observation-capture.sh +2 -2
  11. package/app/plugins/memory-pack/hooks/session-summary.sh +1 -1
  12. package/app/plugins/memory-pack/scripts/init_db.py +2 -2
  13. package/app/plugins/memory-pack/skills/mem-search/SKILL.md +3 -3
  14. package/app/skills/hook-creator/SKILL.md +2 -2
  15. package/app/skills/mem-search/SKILL.md +3 -3
  16. package/app/skills/repeat/SKILL.md +1 -1
  17. package/bin/ai-toolkit.js +9 -4
  18. package/kb/history/completed/enterprise-config-inheritance-plan-20260412.md +32 -34
  19. package/kb/history/completed/offline-slm-profile-plan-20260411.md +12 -12
  20. package/kb/planning/cloud-security-pack-plan.md +3 -3
  21. package/kb/procedures/maintenance-sop.md +3 -3
  22. package/kb/reference/architecture-overview.md +5 -5
  23. package/kb/reference/benchmark-config.md +1 -1
  24. package/kb/reference/competitive-features-implementation.md +2 -2
  25. package/kb/reference/enterprise-config-guide.md +9 -9
  26. package/kb/reference/extension-api.md +1 -1
  27. package/kb/reference/global-install-model.md +2 -2
  28. package/kb/reference/hooks-catalog.md +30 -30
  29. package/kb/reference/integrations.md +3 -3
  30. package/kb/reference/manifest-install.md +4 -4
  31. package/kb/reference/plugin-pack-conventions.md +5 -5
  32. package/kb/reference/stats.md +3 -3
  33. package/kb/reference/sync.md +3 -3
  34. package/llms-full.txt +118 -899
  35. package/llms.txt +0 -1
  36. package/manifest.json +3 -3
  37. package/package.json +1 -1
  38. package/scripts/add_rule.py +3 -2
  39. package/scripts/benchmark_config.py +3 -1
  40. package/scripts/compile_slm.py +9 -7
  41. package/scripts/config_cli.py +7 -7
  42. package/scripts/config_lock.py +12 -4
  43. package/scripts/config_merger.py +1 -1
  44. package/scripts/config_resolver.py +20 -7
  45. package/scripts/config_scaffold.py +4 -4
  46. package/scripts/config_validator.py +3 -3
  47. package/scripts/dir_rules_shared.py +1 -1
  48. package/scripts/doctor.py +3 -2
  49. package/scripts/install.py +12 -7
  50. package/scripts/install_git_hooks.py +1 -1
  51. package/scripts/install_steps/ai_tools.py +4 -4
  52. package/scripts/install_steps/hooks.py +1 -1
  53. package/scripts/install_steps/install_state.py +8 -6
  54. package/scripts/install_steps/project_registry.py +5 -5
  55. package/scripts/migrate.py +241 -0
  56. package/scripts/paths.py +50 -0
  57. package/scripts/plugin.py +8 -6
  58. package/scripts/remove_rule.py +5 -4
  59. package/scripts/stats.py +3 -2
  60. package/scripts/sync.py +3 -2
  61. package/scripts/update_projects.py +1 -1
  62. package/scripts/version_check.py +5 -2
  63. package/kb/planning/local-dashboard-plan.md +0 -773
@@ -1,773 +0,0 @@
1
- ---
2
- title: "Plan: Local Dashboard — ai-toolkit ui"
3
- category: planning
4
- service: ai-toolkit
5
- tags:
6
- - dashboard
7
- - developer-experience
8
- - web-ui
9
- - tui
10
- - configuration
11
- - visualization
12
- doc_type: plan
13
- status: proposed
14
- created: "2026-04-10"
15
- last_updated: "2026-04-10"
16
- completion: "0%"
17
- description: "Ephemeral local web dashboard for ai-toolkit. Provides visual management of agents, skills, hooks, plugins, stats, credentials, and configuration profiles. Zero external dependencies — stdlib Node.js server with embedded HTML/CSS/JS. Launched via `ai-toolkit ui`."
18
- ---
19
-
20
- # Plan: Local Dashboard — `ai-toolkit ui`
21
-
22
- **Status:** Proposed
23
- **Completion:** 0%
24
- **Created:** 2026-04-10
25
- **Origin:** DX friction — managing 44 agents, 91 skills, 21 hooks, 11 plugin packs, and multiple profiles via CLI only creates a steep learning curve for new adopters. Visual management lowers the adoption barrier.
26
- **Estimated Effort:** 6-7 weeks (1 person)
27
-
28
- ---
29
-
30
- ## 1. Objective
31
-
32
- Create an `ai-toolkit ui` command that launches an ephemeral local HTTP server serving a single-page web dashboard. The dashboard provides visual management of all toolkit components — no more memorizing CLI flags.
33
-
34
- **Key design principles:**
35
- - **Zero external dependencies** — stdlib Node.js `http` module, embedded HTML/CSS/JS (same approach as `visual-server.cjs` in `/write-a-prd`). Server lives in `app/dashboard/` (not `scripts/`) — aligns with `visual-server.cjs` precedent and the "scripts/ = Python stdlib only" convention
36
- - **Ephemeral** — auto-kills after 30 minutes of inactivity (matching existing companion pattern)
37
- - **Read-write** — reads state from `~/.ai-toolkit/state.json`, `~/.claude/settings.json`, `manifest.json`; writes config changes through existing CLI commands (never mutates files directly)
38
- - **Dark theme** — premium aesthetic, responsive, glassmorphism accents
39
- - **Offline** — no CDN dependencies, no external fonts, no analytics
40
- - **Port discovery** — starts on 3141, auto-increments if busy
41
-
42
- ---
43
-
44
- ## 1a. Functional Requirements
45
-
46
- | ID | Requirement | Priority | Success Metric |
47
- |----|-------------|----------|----------------|
48
- | FR1 | HTTP server with auto-kill + port discovery | Must | Starts, auto-kills after 30 min, increments port if busy |
49
- | FR2 | Read API endpoints (status, agents, skills, hooks, plugins, stats, config, mcp) | Must | All 8 endpoints return valid JSON |
50
- | FR3 | Action execution via `POST /api/action` with SSE streaming | Must | Command output streamed, exit code returned |
51
- | FR4 | Overview page with health checks + component counts | Must | Live data, matches `ai-toolkit validate` output |
52
- | FR5 | Agents page with grid view + category filter | Must | All 44 agents parsed, 10 categories filterable |
53
- | FR6 | Skills page with type/effort filter + sortable table | Must | All 91 skills, 3 type badges |
54
- | FR7 | Hooks page with lifecycle diagram + profile toggle | Should | 21 hooks, 3 profiles toggleable |
55
- | FR8 | Plugins page with install/remove action buttons | Should | Action triggers CLI via POST /api/action |
56
- | FR9 | Config page with profile/persona management | Should | Reads + writes profiles via CLI |
57
- | FR10 | Stats page with inline SVG charts | Should | Bar chart + trend line minimum (v1) |
58
- | FR11 | MCP template browser with add/remove | Could | 25 templates browseable |
59
- | FR12 | Dark theme + glassmorphism CSS design system | Must | Zero external CSS/font deps |
60
- | FR13 | Client-side SPA routing (hash-based) | Must | Navigation without page reload |
61
- | FR14 | Responsive design (desktop, tablet, mobile) | Should | 3 breakpoints, usable on mobile |
62
- | FR15 | Command allowlist enforcement on /api/action | Must | Non-allowlisted commands → 403 |
63
-
64
- ---
65
-
66
- ## 2. Architecture Overview
67
-
68
- ```
69
- ai-toolkit ui [--port 3141] [--no-auto-kill]
70
-
71
- ┌──────────────────────────────────────────────────────────┐
72
- │ Local Dashboard │
73
- │ │
74
- │ Server: stdlib Node.js http (0 deps) │
75
- │ Port: 3141 (auto-increment if busy) │
76
- │ Auto-kill: 30 min idle (configurable) │
77
- │ │
78
- │ Pages: │
79
- │ / Overview + health │
80
- │ /agents 44 agents — grid view │
81
- │ /skills 91 skills — filterable table │
82
- │ /hooks 21 hooks — lifecycle diagram │
83
- │ /plugins 11 packs — install/remove │
84
- │ /config Profile / persona / modules │
85
- │ /stats Usage analytics + charts │
86
- │ /mcp MCP templates — add/remove │
87
- │ (credentials page deferred — requires cloud-security-pack CLI) │
88
- │ │
89
- │ API (JSON, internal): │
90
- │ GET /api/status Toolkit state │
91
- │ GET /api/agents Agent catalog │
92
- │ GET /api/skills Skill catalog │
93
- │ GET /api/hooks Hook definitions │
94
- │ GET /api/plugins Plugin packs + install state │
95
- │ GET /api/stats Usage statistics │
96
- │ GET /api/config Current configuration │
97
- │ GET /api/mcp MCP templates + installed │
98
- │ (credentials endpoint deferred — see Future section) │
99
- │ POST /api/action Execute CLI command │
100
- │ │
101
- │ Static assets (inlined in server.js): │
102
- │ HTML template (single page, client-side routing) │
103
- │ CSS (dark theme, glassmorphism, responsive) │
104
- │ JS (vanilla, fetch-based, no framework) │
105
- └──────────────────────────────────────────────────────────┘
106
- ```
107
-
108
- ### Action Execution Model
109
-
110
- All write operations go through `POST /api/action`:
111
-
112
- ```json
113
- {
114
- "command": "plugin",
115
- "args": ["install", "memory-pack"]
116
- }
117
- ```
118
-
119
- The server spawns `ai-toolkit <command> <args>` as a child process, streams stdout/stderr back via SSE (Server-Sent Events), and returns exit code. This ensures:
120
- 1. All existing validation logic in CLI scripts executes
121
- 2. No file mutation logic duplicated in the dashboard
122
- 3. Audit trail identical to CLI usage
123
-
124
- ---
125
-
126
- ## 3. Progress Tracking
127
-
128
- | # | Feature | Priority | Status | Est. Time | Notes |
129
- |---|---------|----------|--------|-----------|-------|
130
- | 1.1 | HTTP server + auto-kill + port discovery | P0 | Proposed | 1d | stdlib Node.js, ephemeral lifecycle |
131
- | 1.2 | API layer — read endpoints (status, agents, skills, hooks, plugins, stats, config, mcp) | P0 | Proposed | 2d | Parse frontmatter, state.json, hooks.json |
132
- | 1.3 | API layer — action execution endpoint | P0 | Proposed | 1d | Spawn CLI + SSE streaming |
133
- | 2.1 | Overview page (health, component counts, version) | P0 | Proposed | 1.5d | Dashboard landing page |
134
- | 2.2 | Agents page (grid + detail view + category filter) | P0 | Proposed | 2d | Parse agent .md frontmatter |
135
- | 2.3 | Skills page (filterable table + type badges + effort) | P0 | Proposed | 2d | Task / hybrid / knowledge taxonomy |
136
- | 2.4 | Hooks page (lifecycle diagram + profile toggle) | P1 | Proposed | 2d | Visual event → script mapping |
137
- | 2.5 | Plugins page (install/remove/status cards) | P1 | Proposed | 2d | Action buttons trigger CLI |
138
- | 2.6 | Config page (profile/persona/modules checkboxes) | P1 | Proposed | 2d | Read/write profiles |
139
- | 2.7 | Stats page (usage charts, skill invocation heatmap) | P1 | Proposed | 3.5d | Hand-drawn SVG charts (bar, heatmap, trend), no chart library |
140
- | 2.8 | MCP page (template browser, add/remove) | P2 | Proposed | 1.5d | 25 MCP templates |
141
- | 2.9 | ~~Credentials page~~ | — | Deferred | — | Requires cloud-security-pack CLI commands (not yet implemented) |
142
- | 3.1 | CSS design system (dark theme, glassmorphism, responsive) | P0 | Proposed | 2d | Premium aesthetic, zero external deps |
143
- | 3.2 | Client-side routing + navigation | P0 | Proposed | 1d | Hash-based SPA routing |
144
- | 4.1 | CLI command registration (`ai-toolkit ui`) | P0 | Proposed | 0.5d | bin/ai-toolkit.js integration |
145
- | 4.2 | Tests (bats + node:test) | P1 | Proposed | 3d | Server lifecycle (bats) + API endpoints + SSE streaming (node:test) |
146
- | 4.3 | Documentation | P1 | Proposed | 2.5d | README, CLAUDE.md, ARCHITECTURE.md, package.json, llms.txt, llms-full.txt, AGENTS.md, skills-catalog.md, architecture-overview.md |
147
-
148
- **Phasing:**
149
- - **Phase 1 (week 1-3):** Foundation — server, API, design system, overview page, agents page, skills page
150
- - **Phase 2 (week 3-5):** Interactive — hooks, plugins, config, action execution, stats
151
- - **Phase 3 (week 6-7):** Polish — MCP, responsive testing, tests, documentation (2.5d docs — all 9 docs per CLAUDE.md rules)
152
-
153
- > **Demand validation gate:** Ship Phase 1 (server + overview + agents + skills) as MVP. Announce, measure adoption (track `ai-toolkit ui` invocations via `stats.json`). Only build Phase 2 interactive pages if usage > 10 sessions/week across early adopters.
154
-
155
- ---
156
-
157
- ## 4. Dependency Graph
158
-
159
- ```
160
- Phase 1: Foundation (week 1-3)
161
- ================================
162
- HTTP server (1.1) ──────┐
163
- ├──► API read layer (1.2) ──► Overview page (2.1)
164
- CSS design system (3.1) ┤ ├──► Agents page (2.2)
165
- Client routing (3.2) ───┘ └──► Skills page (2.3)
166
-
167
- Phase 2: Interactive (week 3-5)
168
- =================================
169
- API action layer (1.3) ─┐
170
- ├──► Hooks page (2.4)
171
- ├──► Plugins page (2.5)
172
- ├──► Config page (2.6)
173
- └──► Stats page (2.7)
174
-
175
- Phase 3: Polish (week 6-7)
176
- ===========================
177
- ├──► MCP page (2.8)
178
- ├──► CLI registration (4.1)
179
- └──► Tests + docs (4.2, 4.3)
180
- ```
181
-
182
- ---
183
-
184
- ## 5. Detailed Implementation
185
-
186
- ### Phase 1: Foundation (week 1-3)
187
-
188
- #### 1.1 HTTP Server + Lifecycle
189
-
190
- **File:** `app/dashboard/server.js`
191
-
192
- ```javascript
193
- // Key design decisions:
194
- // 1. stdlib only — require('http'), require('fs'), require('path')
195
- // 2. Auto-kill timer — 30 min idle, reset on every request
196
- // 3. Port discovery — try 3141, increment until available
197
- // 4. Single-file deployment — HTML/CSS/JS embedded as template literals
198
- // 5. Same pattern as visual-brainstorming companion in /write-a-prd
199
-
200
- const AUTO_KILL_MS = 30 * 60 * 1000; // 30 minutes
201
- const DEFAULT_PORT = 3141;
202
- const MAX_PORT_ATTEMPTS = 10;
203
- ```
204
-
205
- **CLI interface:**
206
- ```bash
207
- ai-toolkit ui # open dashboard on port 3141
208
- ai-toolkit ui --port 4000 # custom port
209
- ai-toolkit ui --no-auto-kill # disable 30 min auto-kill
210
- ai-toolkit ui --open # auto-open browser (default: true)
211
- ```
212
-
213
- **Lifecycle:**
214
- 1. Start HTTP server on available port
215
- 2. Open browser via `open` (macOS) / `xdg-open` (Linux)
216
- 3. Reset idle timer on every request
217
- 4. After 30 min inactivity → `process.exit(0)` with console message
218
- 5. `Ctrl+C` → graceful shutdown
219
-
220
- **Security:**
221
- - Bind to `127.0.0.1` only (never `0.0.0.0`)
222
- - No authentication needed (localhost only, ephemeral)
223
- - POST `/api/action` validates command against allowlist (same commands as CLI)
224
- - No file uploads, no eval, no template injection
225
-
226
- **Files:**
227
-
228
- | File | Action | Description |
229
- |------|--------|-------------|
230
- | `app/dashboard/server.js` | CREATE | HTTP server + API + embedded UI |
231
- | `app/dashboard/api.js` | CREATE | API endpoint handlers |
232
- | `app/dashboard/assets.js` | CREATE | Embedded HTML/CSS/JS templates |
233
-
234
- **Success Criteria:**
235
- - [ ] Server starts on port 3141 (or next available)
236
- - [ ] Auto-kills after 30 min idle
237
- - [ ] Browser auto-opens on launch
238
- - [ ] Binds to 127.0.0.1 only
239
- - [ ] `Ctrl+C` graceful shutdown
240
-
241
- ---
242
-
243
- #### 1.2 API Layer — Read Endpoints
244
-
245
- All endpoints return JSON. Data sources:
246
-
247
- | Endpoint | Source | Description |
248
- |----------|--------|-------------|
249
- | `GET /api/status` | `~/.ai-toolkit/state.json` + `manifest.json` | Version, profile, installed modules |
250
- | `GET /api/agents` | `app/agents/*.md` frontmatter | Name, description, tools, triggers, category |
251
- | `GET /api/skills` | `app/skills/*/SKILL.md` frontmatter | Name, type, effort, agent, description |
252
- | `GET /api/hooks` | `app/hooks.json` | Event, script, description, profile |
253
- | `GET /api/plugins` | `app/plugins/*/plugin.json` + state | Name, domain, status, installed?, components |
254
- | `GET /api/stats` | `~/.ai-toolkit/stats.json` | Skill invocation counts, dates |
255
- | `GET /api/config` | `~/.ai-toolkit/state.json` + settings | Profile, persona, modules, hook profile |
256
- | `GET /api/mcp` | `app/mcp-templates/*.json` + `.mcp.json` | Available templates, installed servers |
257
- | ~~`GET /api/credentials`~~ | — | Deferred — requires cloud-security-pack CLI |
258
-
259
- **Frontmatter parser:** Reuse the YAML-subset parser pattern from existing `scripts/frontmatter.py` — port to JS (simple `---` delimited key-value extraction, covers all toolkit frontmatter which is flat YAML).
260
-
261
- **Response format (example):**
262
- ```json
263
- {
264
- "agents": [
265
- {
266
- "name": "backend-specialist",
267
- "description": "Expert backend architect for Node.js, Python, PHP...",
268
- "tools": ["Read", "Write", "Edit", "Bash", "Grep", "Glob"],
269
- "triggers": ["backend", "server", "api", "endpoint"],
270
- "category": "development",
271
- "file": "app/agents/backend-specialist.md"
272
- }
273
- ],
274
- "meta": { "count": 44, "categories": 10 }
275
- }
276
- ```
277
-
278
- **Success Criteria:**
279
- - [ ] All 8 read endpoints return valid JSON
280
- - [ ] Agent frontmatter parsed for all 44 agents
281
- - [ ] Skill frontmatter parsed for all 91 skills
282
- - [ ] Stats endpoint handles missing stats.json gracefully
283
-
284
- ---
285
-
286
- #### 1.3 API Layer — Action Execution
287
-
288
- **Endpoint:** `POST /api/action`
289
-
290
- ```json
291
- // Request
292
- {
293
- "command": "plugin",
294
- "args": ["install", "memory-pack"]
295
- }
296
-
297
- // Response (SSE stream)
298
- event: stdout
299
- data: Installing memory-pack...
300
-
301
- event: stdout
302
- data: ✓ Hooks installed
303
-
304
- event: done
305
- data: {"exitCode": 0, "duration": 1234}
306
- ```
307
-
308
- **Command allowlist:**
309
- ```javascript
310
- const ALLOWED_COMMANDS = [
311
- 'plugin install', 'plugin remove', 'plugin update', 'plugin clean',
312
- 'mcp add', 'mcp remove',
313
- 'install --profile', 'install --persona',
314
- 'update', 'validate', 'doctor', 'doctor --fix',
315
- 'stats', 'stats --reset',
316
- // 'credentials add/remove/test' — deferred until cloud-security-pack CLI ships
317
- ];
318
- ```
319
-
320
- **Security:** Commands not in allowlist → 403. No shell injection — args passed as array to `execFile`, never interpolated into a string.
321
-
322
- **Success Criteria:**
323
- - [ ] SSE streaming of command output
324
- - [ ] Exit code returned in final event
325
- - [ ] Command allowlist enforced
326
- - [ ] No shell injection possible
327
- - [ ] Concurrent commands rejected (one at a time)
328
-
329
- ---
330
-
331
- ### Phase 2: UI Pages (week 3-5)
332
-
333
- #### 2.1 Overview Page
334
-
335
- The landing page — first thing the user sees.
336
-
337
- **Layout:**
338
- ```
339
- ┌─────────────────────────────────────────────────┐
340
- │ ai-toolkit v1.5.1 [● running] │
341
- ├─────────────────────────────────────────────────┤
342
- │ │
343
- │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
344
- │ │ 44 │ │ 91 │ │ 21 │ │ 11 │ │
345
- │ │agents│ │skills│ │hooks │ │packs │ │
346
- │ └──────┘ └──────┘ └──────┘ └──────┘ │
347
- │ │
348
- │ Profile: standard Persona: (none) │
349
- │ Hook Profile: standard │
350
- │ Node: v22.x Python: 3.12 │
351
- │ │
352
- │ ┌─ Health ──────────────────────────────────┐ │
353
- │ │ ✓ Constitution symlinked │ │
354
- │ │ ✓ Hooks installed (21/21) │ │
355
- │ │ ✓ Agents symlinked (44/44) │ │
356
- │ │ ⚠ 2 plugins not installed │ │
357
- │ │ ✓ MCP servers: 3 configured │ │
358
- │ └───────────────────────────────────────────┘ │
359
- │ │
360
- │ ┌─ Recent Activity ─────────────────────────┐ │
361
- │ │ /review — 12 invocations (last: 2h ago) │ │
362
- │ │ /commit — 8 invocations (last: 5h ago) │ │
363
- │ │ /test — 6 invocations (last: 1d ago) │ │
364
- │ └───────────────────────────────────────────┘ │
365
- └─────────────────────────────────────────────────┘
366
- ```
367
-
368
- **Data sources:** `/api/status` + `/api/stats` + `/api/plugins`
369
-
370
- **Success Criteria:**
371
- - [ ] Component counts rendered from live data
372
- - [ ] Health checks match `ai-toolkit validate` output
373
- - [ ] Recent activity from stats.json
374
- - [ ] Responsive on mobile-width screens
375
-
376
- ---
377
-
378
- #### 2.2 Agents Page
379
-
380
- **Layout:** Grid of agent cards, filterable by category (10 categories).
381
-
382
- **Card design:**
383
- ```
384
- ┌─────────────────────────────────┐
385
- │ 🔧 backend-specialist │
386
- │ │
387
- │ Expert backend architect for │
388
- │ Node.js, Python, PHP... │
389
- │ │
390
- │ Tools: Read, Write, Edit, Bash │
391
- │ Triggers: backend, server, api │
392
- │ │
393
- │ [View Definition] │
394
- └─────────────────────────────────┘
395
- ```
396
-
397
- **Features:**
398
- - Category filter pills (development, security, data, infrastructure, etc.)
399
- - Search by name/description/trigger
400
- - Click card → modal with full agent definition (rendered markdown)
401
- - Agent count per category in filter pills
402
-
403
- ---
404
-
405
- #### 2.3 Skills Page
406
-
407
- **Layout:** Filterable table with type badges.
408
-
409
- | Skill | Type | Effort | Agent | Description |
410
- |-------|------|--------|-------|-------------|
411
- | /commit | task | medium | — | Structured commit with linting |
412
- | /review | hybrid | high | code-reviewer | Code review: quality, security |
413
- | clean-code | knowledge | — | — | Auto-loaded code quality patterns |
414
-
415
- **Features:**
416
- - Filter by type (task / hybrid / knowledge)
417
- - Filter by effort (low / medium / high / max)
418
- - Search by name/description
419
- - Sort by any column
420
- - Badge colors: task=blue, hybrid=purple, knowledge=green
421
-
422
- ---
423
-
424
- #### 2.4 Hooks Page
425
-
426
- **Layout:** Lifecycle diagram with profile toggle (minimal/standard/strict).
427
-
428
- **Visualization:**
429
- ```
430
- Event Timeline (horizontal flow):
431
- PreToolUse ──► ToolUse ──► PostToolUse ──► Notification
432
- │ │ │ │
433
- guard-path.sh (tool exec) quality-check.sh track-usage.sh
434
- guard-destructive.sh session-context.sh
435
- ```
436
-
437
- **Features:**
438
- - Lifecycle event diagram — visual mapping of event → hook script(s)
439
- - Profile toggle — show/hide hooks per profile (minimal hides most, strict shows all)
440
- - Hook detail panel — click hook name to see: script path, description, when it fires, which profile includes it
441
- - Profile diff — highlight which hooks are added/removed between profiles
442
- - Status indicators — green (installed), red (missing script), yellow (overridden by plugin)
443
-
444
- **Data source:** `app/hooks.json` + `~/.ai-toolkit/hooks/` filesystem check
445
-
446
- **Success Criteria:**
447
- - [ ] All 21 hooks rendered with correct lifecycle event
448
- - [ ] Profile toggle filters hooks correctly
449
- - [ ] Missing hook scripts shown with warning indicator
450
- - [ ] Hook detail panel shows script content preview
451
-
452
- ---
453
-
454
- #### 2.5 Plugins Page
455
-
456
- **Layout:** Cards with install/remove buttons.
457
-
458
- ```
459
- ┌─────────────────────────────────┐
460
- │ 🧩 memory-pack ● installed │
461
- │ │
462
- │ SQLite-based persistent memory │
463
- │ with FTS5 search across sessions│
464
- │ │
465
- │ Skills: 1 Hooks: 2 Agents: 0 │
466
- │ DB size: 2.4 MB Obs: 1,234 │
467
- │ │
468
- │ [Update] [Clean] [Remove] │
469
- └─────────────────────────────────┘
470
- ```
471
-
472
- **Actions:** Install, update, remove, clean — all via `POST /api/action` → `ai-toolkit plugin <action> <name>`. SSE output shown in a slide-out console panel.
473
-
474
- ---
475
-
476
- #### 2.6 Config Page
477
-
478
- **Layout:** Form with current configuration, editable.
479
-
480
- **Sections:**
481
- 1. **Profile selector:** minimal / standard / strict (radio buttons)
482
- 2. **Persona selector:** none / backend-lead / frontend-lead / devops-eng / junior-dev
483
- 3. **Hook profile:** minimal / standard / strict
484
- 4. **Installed modules:** checkboxes for each module from manifest.json
485
- 5. **Language rules:** detected languages + override checkboxes
486
- 6. **Editor configs:** which editors are configured (read-only status)
487
-
488
- **Save:** Generates and executes the equivalent `ai-toolkit install --profile X --persona Y --modules A,B,C` command.
489
-
490
- ---
491
-
492
- #### 2.7 Stats Page
493
-
494
- **Layout:** Usage analytics with inline SVG charts.
495
-
496
- **Charts (SVG, hand-drawn — no chart library):**
497
- 1. **Skill invocation bar chart** — top 15 most-used skills
498
- 2. **Invocation heatmap** — 7x24 grid (day of week × hour) showing when skills are used
499
- 3. **Effort distribution** — pie chart of low/medium/high/max invocations
500
- 4. **Trend line** — daily invocations over last 30 days
501
-
502
- **Data source:** `~/.ai-toolkit/stats.json` (written by `track-usage.sh` hook)
503
-
504
- **SVG implementation notes:**
505
- - All charts rendered as inline SVG strings in `assets.js` — no external chart library
506
- - Bar chart: `<rect>` elements with calculated heights, axis labels as `<text>`
507
- - Heatmap: 7x24 grid of `<rect>` with color intensity mapped to invocation count (0=transparent, max=accent-primary)
508
- - Trend line: `<polyline>` with data points as `<circle>`, area fill via `<polygon>`
509
- - Pie chart: `<path>` arcs calculated from percentages (use `Math.cos`/`Math.sin` for arc endpoints)
510
- - All charts use CSS custom properties for colors (respects design system tokens)
511
-
512
- **Fallback:** If hand-drawn SVG proves too complex for 4 chart types in 3.5d budget, reduce to 2 charts (bar + trend) for v1 and defer heatmap + pie to v2.
513
-
514
- **Success Criteria:**
515
- - [ ] All 4 chart types render from live stats.json data
516
- - [ ] Empty state when stats.json missing: "No usage data yet — skills will appear here after first use"
517
- - [ ] Charts responsive (SVG viewBox scales to container width)
518
- - [ ] Tooltip on hover showing exact counts
519
-
520
- ---
521
-
522
- ### Phase 3: Polish (week 6-7)
523
-
524
- #### 3.1 CSS Design System
525
-
526
- **Design tokens:**
527
- ```css
528
- :root {
529
- /* Dark theme palette */
530
- --bg-primary: #0f0f14;
531
- --bg-secondary: #1a1a24;
532
- --bg-card: rgba(255, 255, 255, 0.04);
533
- --bg-glass: rgba(255, 255, 255, 0.06);
534
- --border-glass: rgba(255, 255, 255, 0.08);
535
-
536
- /* Accent colors (derived from SoftSpark brand) */
537
- --accent-primary: #6366f1; /* indigo */
538
- --accent-secondary: #8b5cf6; /* violet */
539
- --accent-success: #10b981; /* emerald */
540
- --accent-warning: #f59e0b; /* amber */
541
- --accent-danger: #ef4444; /* red */
542
-
543
- /* Typography */
544
- --font-sans: system-ui, -apple-system, sans-serif;
545
- --font-mono: 'SF Mono', 'Cascadia Code', monospace;
546
-
547
- /* Spacing scale */
548
- --space-xs: 4px;
549
- --space-sm: 8px;
550
- --space-md: 16px;
551
- --space-lg: 24px;
552
- --space-xl: 32px;
553
-
554
- /* Glassmorphism */
555
- --glass-blur: 12px;
556
- --glass-bg: rgba(255, 255, 255, 0.05);
557
- --glass-border: rgba(255, 255, 255, 0.1);
558
- }
559
- ```
560
-
561
- **Components:**
562
- - Cards with glassmorphism backdrop-filter
563
- - Badge pills (type, effort, status)
564
- - Sidebar navigation with active state
565
- - Console output panel (slide-out, monospace)
566
- - Modal overlays for detail views
567
- - Toast notifications for action results
568
- - Skeleton loading states
569
-
570
- **Responsive breakpoints:**
571
- - Desktop: 1200px+ (sidebar + content)
572
- - Tablet: 768px-1199px (collapsed sidebar)
573
- - Mobile: <768px (hamburger menu, stacked cards)
574
-
575
- ---
576
-
577
- #### 4.1 CLI Command Registration
578
-
579
- **File:** `bin/ai-toolkit.js` — add to `COMMANDS` and `SPECIAL_HANDLERS`:
580
-
581
- ```javascript
582
- // COMMANDS
583
- 'ui': 'Launch local web dashboard for visual toolkit management',
584
-
585
- // SPECIAL_HANDLERS
586
- 'ui': (args) => {
587
- const serverPath = path.join(TOOLKIT_DIR, 'app', 'dashboard', 'server.js');
588
- const child = require('child_process').spawn('node', [serverPath, ...args], {
589
- stdio: 'inherit',
590
- env: { ...process.env, TOOLKIT_DIR }
591
- });
592
- child.on('exit', (code) => process.exit(code || 0));
593
- },
594
- ```
595
-
596
- **Files to modify:**
597
-
598
- | File | Action | Description |
599
- |------|--------|-------------|
600
- | `bin/ai-toolkit.js` | EDIT | Register `ui` command |
601
- | `app/dashboard/server.js` | CREATE | HTTP server (main) |
602
- | `app/dashboard/api.js` | CREATE | API handlers |
603
- | `app/dashboard/assets.js` | CREATE | Embedded HTML/CSS/JS |
604
- | `app/dashboard/frontmatter.js` | CREATE | JS frontmatter parser |
605
- | `tests/test_dashboard.bats` | CREATE | Server lifecycle tests |
606
- | `tests/test_dashboard_api.bats` | CREATE | API endpoint tests |
607
-
608
- ---
609
-
610
- ## 6. File Summary
611
-
612
- | File | Action | LOC (est.) | Description |
613
- |------|--------|------------|-------------|
614
- | `app/dashboard/server.js` | CREATE | ~300 | HTTP server, lifecycle, routing |
615
- | `app/dashboard/api.js` | CREATE | ~400 | All API endpoint handlers |
616
- | `app/dashboard/assets.js` | CREATE | ~2800 | Embedded HTML + CSS + JS. Split internally: `getOverviewHTML()`, `getAgentsHTML()`, etc. — one exported function per page. Single file, multiple functions (not multiple files — preserves single-`require` deployment). If file exceeds 3000 LOC, extract to `assets/` directory with `index.js` barrel |
617
- | `app/dashboard/frontmatter.js` | CREATE | ~80 | Frontmatter parser (JS port) |
618
- | `bin/ai-toolkit.js` | EDIT | +15 | Register `ui` command |
619
- | `tests/test_dashboard.bats` | CREATE | ~100 | Server lifecycle tests |
620
- | `tests/test_dashboard_api.bats` | CREATE | ~150 | API endpoint tests |
621
- | **Total** | | **~3845** | |
622
-
623
- ---
624
-
625
- ## 7. Success Criteria (Overall)
626
-
627
- | Metric | Target |
628
- |--------|--------|
629
- | Pages | 8 (overview, agents, skills, hooks, plugins, config, stats, mcp) |
630
- | API endpoints | 9 (8 read + 1 action) |
631
- | External dependencies | 0 (stdlib Node.js only) |
632
- | Server startup time | < 500ms |
633
- | Auto-kill | 30 min idle (configurable) |
634
- | Responsive breakpoints | 3 (desktop, tablet, mobile) |
635
- | Tests | 25+ |
636
- | Browser support | Chrome, Firefox, Safari (modern, no IE) |
637
-
638
- ---
639
-
640
- ## 7a. Non-Functional Requirements
641
-
642
- | Category | Requirement |
643
- |----------|-------------|
644
- | **Performance** | Server startup < 500ms. Page render < 200ms. API responses < 100ms. |
645
- | **Memory** | Max RSS < 100MB (including embedded assets). No unbounded caching. |
646
- | **Concurrency** | Max 1 concurrent action execution. Queue or reject additional requests with 429. |
647
- | **Security** | Bind `127.0.0.1` only. CSP header: `default-src 'self' 'unsafe-inline'`. No CORS headers (same-origin only). Command allowlist enforced server-side. `execFile` with array args (no shell). |
648
- | **Accessibility** | Keyboard navigation for all interactive elements. Focus management on page transitions. Minimum 4.5:1 contrast ratio (WCAG AA). ARIA labels on icon-only buttons. |
649
- | **Error handling** | Missing/corrupt data files → graceful empty state with message. Server crash → exit code 1 with stderr diagnostic. API errors → JSON `{ "error": "..." }` with HTTP status. |
650
- | **Graceful degradation** | If `stats.json` missing → stats page shows "No data yet". If `state.json` missing → overview shows defaults. If agent/skill .md unreadable → skip with warning in console. |
651
-
652
- ---
653
-
654
- ## 7b. Rollback & Feature Flag
655
-
656
- The dashboard is purely additive — removing it is trivial:
657
- 1. Delete `app/dashboard/` directory
658
- 2. Remove `ui` from `COMMANDS` and `SPECIAL_HANDLERS` in `bin/ai-toolkit.js`
659
- 3. No config files, no state files, no hooks to clean up
660
-
661
- **Disable without removal:** `ai-toolkit ui --disabled` could print "Dashboard disabled" and exit. Alternatively, skip registering the `ui` command in `bin/ai-toolkit.js` behind a `manifest.json` module flag so users can opt out via `--skip dashboard`.
662
-
663
- ---
664
-
665
- ## 7c. Testing Strategy
666
-
667
- | Layer | Framework | Coverage |
668
- |-------|-----------|----------|
669
- | Server lifecycle (start, port discovery, auto-kill, shutdown) | bats | 5+ tests |
670
- | API endpoints (all 8 read + action) | `node:test` (stdlib) | 15+ tests |
671
- | SSE streaming (stdout/stderr/done events) | `node:test` | 3+ tests |
672
- | Command allowlist enforcement | `node:test` | 5+ tests |
673
- | Frontmatter parser edge cases | `node:test` | 5+ tests |
674
- | Integration: full pipeline (start → API → action → stop) | `node:test` | 3+ tests |
675
- | **Total** | | **36+** |
676
-
677
- `node:test` is stdlib (Node 18+), zero dependencies. Bats tests are for CLI-level integration (process start/stop). JS tests cover API correctness.
678
-
679
- ---
680
-
681
- ## 7d. Discoverability
682
-
683
- | Touchpoint | Action |
684
- |------------|--------|
685
- | `ai-toolkit install` output | Print banner: `Run 'ai-toolkit ui' to explore agents, skills, and plugins visually.` |
686
- | `ai-toolkit help` | Include `ui` in command list |
687
- | README.md | Screenshot/GIF of dashboard overview page |
688
- | First-run detection | If `stats.json` is empty, show a "Try the dashboard" suggestion after `ai-toolkit install` |
689
-
690
- ---
691
-
692
- ## 8. Risks and Mitigation
693
-
694
- | Risk | Probability | Impact | Mitigation |
695
- |------|-------------|--------|------------|
696
- | Assets.js file too large (embedded HTML/CSS/JS) | Medium | Low | Split into multiple template modules, lazy-load pages |
697
- | Port conflict on 3141 | Low | Low | Auto-increment port, show clear message |
698
- | SSE not supported in old browsers | Low | Low | Fallback to polling for action results |
699
- | Frontmatter parser edge cases | Low | Medium | Match exact patterns used in existing toolkit metadata |
700
- | Config writes break installation | Low | High | All writes go through existing CLI commands — never direct file mutation |
701
- | Stats.json missing or empty | Medium | Low | Graceful empty state with "No usage data yet" message |
702
-
703
- ---
704
-
705
- ## 9. Pre-Mortem
706
-
707
- 1. **"Too many features per page"** — Dashboard tries to show everything. Users may feel overwhelmed. Mitigation: progressive disclosure — overview page shows summary only, detail pages are opt-in.
708
- 2. **"Asset file becomes unmaintainable"** — ~2800 LOC of embedded HTML/CSS/JS is hard to iterate on. Mitigation: split into `assets/overview.js`, `assets/agents.js`, etc. with a build-free concatenation in server.js.
709
- 3. **"Nobody uses it"** — CLI users may prefer CLI. Mitigation: dashboard is opt-in, never required. Add `ai-toolkit ui` suggestion to `ai-toolkit install` output for new users.
710
- 4. **"Action execution feels disconnected"** — SSE console output may confuse users unfamiliar with CLI. Mitigation: rich UI feedback (progress bars, success/error toasts) layered on top of raw output.
711
- 5. **"Charts look bad without a library"** — Hand-drawn SVG charts may look amateur. Mitigation: keep charts simple (bar + heatmap), use consistent design tokens, test extensively.
712
-
713
- ---
714
-
715
- ## 10. Next Actions
716
-
717
- 1. [ ] Approve plan
718
- 2. [ ] Create `app/dashboard/server.js` with HTTP server + lifecycle (1.1)
719
- 3. [ ] Create API layer — read endpoints (1.2)
720
- 4. [ ] Create CSS design system + client routing (3.1, 3.2)
721
- 5. [ ] Build Overview page (2.1)
722
- 6. [ ] Build Agents page (2.2)
723
- 7. [ ] Build Skills page (2.3)
724
- 8. [ ] Add action execution API (1.3)
725
- 9. [ ] Build Hooks, Plugins, Config pages (2.4, 2.5, 2.6)
726
- 10. [ ] Build Stats page with SVG charts (2.7)
727
- 11. [ ] Build MCP page (2.8)
728
- 12. [ ] Register CLI command (4.1)
729
- 13. [ ] Tests — bats + node:test (4.2)
730
- 14. [ ] Documentation — all 9 docs per CLAUDE.md rules (4.3)
731
-
732
- ---
733
-
734
- ## 11. Future (Deferred)
735
-
736
- | Feature | Reason for deferral | Prerequisite |
737
- |---------|-------------------|--------------|
738
- | Credentials page (2.9) | CLI has no `credentials` commands yet | cloud-security-pack CLI implementation |
739
- | `ai-toolkit ui --static` | Generate a single standalone HTML file (no server) — covers 80% of catalog value at 20% complexity | Post-v1 evaluation of actual usage patterns |
740
- | Guided onboarding flow | Interactive wizard for new users | Post-v1, based on user feedback |
741
- | Light theme toggle | Dark-only for v1 | CSS variable architecture makes this easy later |
742
-
743
- ---
744
-
745
- ## 10. Market Positioning
746
-
747
- **Target users:**
748
- 1. **New adopters** — developers evaluating ai-toolkit who want to understand what's included before committing to a profile
749
- 2. **Team leads** — visual overview of which agents, skills, and plugins are active across team setups
750
- 3. **Plugin explorers** — developers browsing available plugin packs without memorizing CLI commands
751
- 4. **Onboarding** — new team members getting oriented with the toolkit's capabilities
752
-
753
- **Competitive advantage:** No existing AI coding toolkit provides a zero-dependency ephemeral web dashboard for visual management. Backstage is 1000x heavier (requires Kubernetes, PostgreSQL). TUI tools (mise, lazygit) lack visual richness. The ephemeral auto-kill design means zero operational burden.
754
-
755
- **Discovery opportunity:** The dashboard serves as a self-documenting catalog — users discover agents and skills they didn't know existed, increasing toolkit utilization.
756
-
757
- ---
758
-
759
- ## 12. Cross-Plan Dependencies
760
-
761
- This plan shares modification targets with two other proposed plans:
762
-
763
- | Shared File | This Plan | Enterprise Config Plan | Offline SLM Plan |
764
- |-------------|-----------|----------------------|-----------------|
765
- | `bin/ai-toolkit.js` | +15 LOC (ui command) | +40 LOC (config subcommands) | +10 LOC (compile-slm command) |
766
-
767
- **If Enterprise Config ships first:** Dashboard Config page (2.6) should display `.ai-toolkit.json` / `extends` status and `config diff` output. Add an API endpoint `GET /api/config/extends` reading resolved extends state from `state.json`.
768
-
769
- **If Offline SLM ships first:** Dashboard Overview page (2.1) should display `offline-slm` profile status and link to compiled output. Stats page may show limited data (SLM providers don't emit hook-based stats).
770
-
771
- ---
772
-
773
- **Last Updated:** 2026-04-10