@tekmidian/pai 0.6.6 → 0.7.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 (35) hide show
  1. package/.claude-plugin/plugin.json +50 -0
  2. package/PLUGIN-ARCHITECTURE.md +365 -0
  3. package/dist/cli/index.mjs +1 -1
  4. package/dist/daemon/index.mjs +1 -1
  5. package/dist/{daemon-D3hYb5_C.mjs → daemon-DJoesjez.mjs} +847 -4
  6. package/dist/daemon-DJoesjez.mjs.map +1 -0
  7. package/dist/hooks/context-compression-hook.mjs.map +2 -2
  8. package/dist/hooks/load-project-context.mjs +4 -23
  9. package/dist/hooks/load-project-context.mjs.map +2 -2
  10. package/dist/hooks/stop-hook.mjs +206 -125
  11. package/dist/hooks/stop-hook.mjs.map +3 -3
  12. package/dist/hooks/sync-todo-to-md.mjs.map +1 -1
  13. package/gemini-extension.json +26 -0
  14. package/package.json +8 -2
  15. package/pai-plugin.json +212 -0
  16. package/plugins/context-preservation/hooks/hooks.json +23 -0
  17. package/plugins/context-preservation/plugin.json +10 -0
  18. package/plugins/core/hooks/hooks.json +37 -0
  19. package/plugins/core/plugin.json +10 -0
  20. package/plugins/creative/plugin.json +10 -0
  21. package/plugins/observability/hooks/hooks.json +75 -0
  22. package/plugins/observability/plugin.json +11 -0
  23. package/plugins/productivity/hooks/hooks.json +17 -0
  24. package/plugins/productivity/plugin.json +11 -0
  25. package/plugins/semantic-search/plugin.json +21 -0
  26. package/plugins/ui/hooks/hooks.json +17 -0
  27. package/plugins/ui/plugin.json +11 -0
  28. package/plugins/zettelkasten/plugin.json +19 -0
  29. package/src/hooks/ts/lib/project-utils/session-notes.ts +24 -5
  30. package/src/hooks/ts/session-start/load-project-context.ts +9 -25
  31. package/src/hooks/ts/stop/stop-hook.ts +259 -199
  32. package/user-extensions/README.md +87 -0
  33. package/user-extensions/hooks/.gitkeep +0 -0
  34. package/user-extensions/skills/.gitkeep +0 -0
  35. package/dist/daemon-D3hYb5_C.mjs.map +0 -1
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@tekmidian/pai",
3
+ "displayName": "PAI Knowledge OS",
4
+ "description": "Personal AI Infrastructure — persistent memory, session continuity, and knowledge graph for Claude Code",
5
+ "version": "0.7.0",
6
+ "author": "Matthias Nott",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/mnott/PAI",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/mnott/PAI"
12
+ },
13
+ "keywords": [
14
+ "memory",
15
+ "knowledge-os",
16
+ "session-continuity",
17
+ "mcp",
18
+ "personal-ai",
19
+ "hooks",
20
+ "skills",
21
+ "zettelkasten"
22
+ ],
23
+ "engines": {
24
+ "claude-code": ">=1.0.0",
25
+ "node": ">=20.0.0"
26
+ },
27
+ "setup": "pai setup",
28
+ "mcp": {
29
+ "server": "dist/daemon-mcp/index.mjs",
30
+ "daemon": "dist/daemon/index.mjs"
31
+ },
32
+ "hooks": "plugins/core/hooks/hooks.json",
33
+ "skills": [
34
+ "plugins/core/skills/",
35
+ "plugins/productivity/skills/",
36
+ "plugins/observability/skills/",
37
+ "plugins/zettelkasten/skills/",
38
+ "plugins/creative/skills/"
39
+ ],
40
+ "templates": [
41
+ "templates/claude-md.template.md",
42
+ "templates/pai-skill.template.md",
43
+ "templates/agent-prefs.example.md"
44
+ ],
45
+ "userExtensions": {
46
+ "hooks": "user-extensions/hooks/",
47
+ "skills": "user-extensions/skills/",
48
+ "prompts": "src/daemon-mcp/prompts/custom/"
49
+ }
50
+ }
@@ -0,0 +1,365 @@
1
+ # PAI Plugin Architecture
2
+
3
+ Technical reference for PAI's modular plugin system, cross-platform support, user extensions, and monetization tiers.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ PAI is structured as a modular plugin system with 8 named modules organized into 3 pricing tiers. The architecture supports Claude Code (full integration), Cursor (MCP only), and Gemini CLI (MCP only).
10
+
11
+ ```
12
+ PAI Knowledge OS
13
+ ├── Core (free, required)
14
+ │ ├── Memory engine (keyword search, SQLite)
15
+ │ ├── Session management
16
+ │ ├── Project registry
17
+ │ ├── 5 essential hooks
18
+ │ └── 3 essential skills
19
+ ├── Free Extensions
20
+ │ ├── Productivity (Plan, Review, Journal, Research, Share)
21
+ │ ├── UI Customization (tab titles, statusline, tab colors)
22
+ │ └── Context Preservation (compression, relay, checkpoint)
23
+ ├── Pro Extensions
24
+ │ ├── Semantic Search (pgvector, reranking, hybrid)
25
+ │ └── Observability (capture, classify, summarize)
26
+ └── Enterprise Extensions
27
+ ├── Zettelkasten Intelligence (6 graph operations)
28
+ └── Creative Studio (art, story, voice/prosody)
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Module System
34
+
35
+ ### Module Manifest
36
+
37
+ Each module has a `plugins/<module>/plugin.json` that declares:
38
+
39
+ ```json
40
+ {
41
+ "name": "pai-core",
42
+ "displayName": "PAI Core",
43
+ "description": "Core memory engine, session management, and project registry",
44
+ "version": "0.7.0",
45
+ "tier": "free",
46
+ "required": true,
47
+ "depends": [],
48
+ "hooks": "hooks/hooks.json",
49
+ "skills": ["Sessions", "Route", "Name"]
50
+ }
51
+ ```
52
+
53
+ ### Module Inventory
54
+
55
+ | Module | Tier | Hooks | Skills | Description |
56
+ |--------|------|-------|--------|-------------|
57
+ | `core` | free | 6 | 3 | Memory engine, sessions, projects, security |
58
+ | `productivity` | free | 2 | 6 | Plan, Review, Journal, Research, Share, Createskill |
59
+ | `ui` | free | 2 | 0 | Tab titles, statusline, tab coloring |
60
+ | `context-preservation` | free | 3 | 0 | Context compression and relay |
61
+ | `semantic-search` | pro | 0 | 0 | pgvector, reranking, hybrid search |
62
+ | `observability` | pro | 13 | 2 | Event capture, classification, summaries |
63
+ | `zettelkasten` | enterprise | 0 | 5 | Graph operations, vault intelligence |
64
+ | `creative` | enterprise | 0 | 2 | Art direction, story, voice/prosody |
65
+
66
+ ### Hook Distribution
67
+
68
+ Total: 26 hook registrations across 6 modules.
69
+
70
+ **Core (6):** load-core-context, load-project-context, initialize-session, security-validator, stop-hook, pai-session-stop.sh
71
+
72
+ **Productivity (2):** sync-todo-to-md, cleanup-session-files
73
+
74
+ **UI (2):** update-tab-titles, update-tab-on-action
75
+
76
+ **Context Preservation (3):** context-compression-hook, pai-pre-compact.sh, post-compact-inject
77
+
78
+ **Observability (13):** capture-all-events (7 events), observe, inject-observations, capture-tool-output, capture-session-summary, subagent-stop-hook
79
+
80
+ ### Skill Distribution
81
+
82
+ Total: 18 skills across 5 modules.
83
+
84
+ **Core (3):** Sessions, Route, Name
85
+
86
+ **Productivity (6):** Plan, Review, Journal, Research, Share, Createskill
87
+
88
+ **Observability (2):** Observability, SearchHistory
89
+
90
+ **Zettelkasten (5):** VaultConnect, VaultContext, VaultEmerge, VaultOrphans, VaultTrace
91
+
92
+ **Creative (2):** Art, StoryExplanation
93
+
94
+ ---
95
+
96
+ ## Directory Structure
97
+
98
+ ```
99
+ PAI/
100
+ ├── .claude-plugin/
101
+ │ └── plugin.json # Claude Code plugin manifest
102
+ ├── .cursor/
103
+ │ └── plugin.json # Cursor plugin manifest
104
+ ├── gemini-extension.json # Gemini CLI extension manifest
105
+ ├── pai-plugin.json # Canonical module manifest (build reads this)
106
+
107
+ ├── plugins/ # Module definitions
108
+ │ ├── core/
109
+ │ │ ├── plugin.json # Module metadata
110
+ │ │ ├── hooks/
111
+ │ │ │ └── hooks.json # Core hook definitions
112
+ │ │ └── skills/ # (populated by build symlinks)
113
+ │ ├── productivity/
114
+ │ │ ├── plugin.json
115
+ │ │ ├── hooks/
116
+ │ │ │ └── hooks.json
117
+ │ │ └── skills/
118
+ │ ├── ui/
119
+ │ │ ├── plugin.json
120
+ │ │ └── hooks/
121
+ │ │ └── hooks.json
122
+ │ ├── context-preservation/
123
+ │ │ ├── plugin.json
124
+ │ │ └── hooks/
125
+ │ │ └── hooks.json
126
+ │ ├── semantic-search/
127
+ │ │ └── plugin.json
128
+ │ ├── observability/
129
+ │ │ ├── plugin.json
130
+ │ │ ├── hooks/
131
+ │ │ │ └── hooks.json
132
+ │ │ └── skills/
133
+ │ ├── zettelkasten/
134
+ │ │ ├── plugin.json
135
+ │ │ └── skills/
136
+ │ └── creative/
137
+ │ ├── plugin.json
138
+ │ └── skills/
139
+
140
+ ├── user-extensions/ # User customization point (gitignored)
141
+ │ ├── README.md
142
+ │ ├── hooks/
143
+ │ │ └── .gitkeep
144
+ │ └── skills/
145
+ │ └── .gitkeep
146
+
147
+ ├── src/ # Source code (unchanged)
148
+ ├── dist/ # Build output (unchanged)
149
+ ├── templates/ # Setup templates (unchanged)
150
+ └── scripts/ # Build scripts
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Cross-Platform Support
156
+
157
+ ### Claude Code (Full Integration)
158
+
159
+ Claude Code gets the complete PAI experience:
160
+
161
+ | Capability | Support |
162
+ |------------|---------|
163
+ | MCP Tools (9) | Full |
164
+ | MCP Resources (11) | Full |
165
+ | MCP Prompts (18) | Full |
166
+ | Hooks (26 registrations) | Full |
167
+ | Skills (18 SKILL.md stubs) | Full |
168
+ | Statusline | Full |
169
+ | Tab management | Full |
170
+
171
+ Manifest: `.claude-plugin/plugin.json`
172
+
173
+ ### Cursor (MCP Only)
174
+
175
+ Cursor supports MCP servers but not Claude Code's hook or skill system:
176
+
177
+ | Capability | Support |
178
+ |------------|---------|
179
+ | MCP Tools (9) | Full |
180
+ | MCP Resources | Not supported |
181
+ | MCP Prompts | Not supported |
182
+ | Hooks | Not supported |
183
+ | Skills | Not supported (use Cursor Rules instead) |
184
+
185
+ Manifest: `.cursor/plugin.json`
186
+
187
+ To use PAI with Cursor, add to `.cursor/mcp.json`:
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "pai": {
192
+ "command": "node",
193
+ "args": ["/path/to/PAI/dist/daemon-mcp/index.mjs"]
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ ### Gemini CLI (MCP Only)
200
+
201
+ Gemini CLI supports MCP servers via extensions:
202
+
203
+ | Capability | Support |
204
+ |------------|---------|
205
+ | MCP Tools (9) | Full |
206
+ | Hooks | Not supported |
207
+ | Skills | Not supported |
208
+
209
+ Manifest: `gemini-extension.json`
210
+
211
+ ### Codex (Future)
212
+
213
+ OpenAI's Codex supports MCP. When available, a `codex-extension.json` can follow the same pattern.
214
+
215
+ ---
216
+
217
+ ## User Extensions
218
+
219
+ PAI provides three extension points that survive git pull and PAI updates.
220
+
221
+ ### Custom Skills
222
+
223
+ Create `user-extensions/skills/MySkill/SKILL.md`:
224
+
225
+ ```markdown
226
+ ---
227
+ name: MySkill
228
+ description: "What the skill does. USE WHEN user says 'trigger phrase'."
229
+ ---
230
+
231
+ ## My Skill Instructions
232
+
233
+ Your skill content here...
234
+ ```
235
+
236
+ Run `bun run build` to deploy. The build script discovers and symlinks custom skills into `~/.claude/skills/`.
237
+
238
+ ### Custom Hooks
239
+
240
+ Create `user-extensions/hooks/my-hook.ts` or `user-extensions/hooks/my-hook.sh`:
241
+
242
+ TypeScript hooks are compiled during build. Shell hooks are symlinked directly. Register in `~/.claude/settings.json` under the appropriate hook event.
243
+
244
+ ### Custom MCP Prompts
245
+
246
+ Create `src/daemon-mcp/prompts/custom/my-prompt.ts`:
247
+
248
+ ```typescript
249
+ export const myPrompt = {
250
+ description: "What the prompt does",
251
+ content: `## My Prompt
252
+ USE WHEN user says 'trigger phrase'...
253
+ Your prompt content here...`,
254
+ };
255
+ ```
256
+
257
+ Run `bun run build` to generate the skill stub.
258
+
259
+ ### Extension Safety
260
+
261
+ | Location | Gitignored | PAI Updates | Discovery |
262
+ |----------|------------|-------------|-----------|
263
+ | `user-extensions/skills/` | Yes | Never touched | Build sync |
264
+ | `user-extensions/hooks/` | Yes | Never touched | Build compile |
265
+ | `src/daemon-mcp/prompts/custom/` | Yes | Never touched | Build generate |
266
+ | `~/.claude/skills/user/` | N/A (outside repo) | Never touched | Claude Code scanner |
267
+
268
+ ---
269
+
270
+ ## Monetization Architecture
271
+
272
+ ### Tier Model
273
+
274
+ | Tier | Price | Modules |
275
+ |------|-------|---------|
276
+ | Free | $0 | core, productivity, ui, context-preservation |
277
+ | Pro | $9/mo or $79/yr | Free + semantic-search, observability |
278
+ | Enterprise | $29/mo or $249/yr | Pro + zettelkasten, creative |
279
+
280
+ ### Gating Strategy (Future)
281
+
282
+ The tier annotations in `pai-plugin.json` are structural markers for future license gating. The planned approach:
283
+
284
+ 1. License key stored in `~/.config/pai/license.json`
285
+ 2. Signed JWT for offline validation (no phone-home)
286
+ 3. Checked at daemon startup and premium MCP tool invocation
287
+ 4. Graceful degradation: premium features return "upgrade required" message
288
+ 5. `pai license activate <key>` CLI command
289
+
290
+ Currently (v0.7.0): all features ship as free. Tier annotations are informational only.
291
+
292
+ ### What Justifies Each Tier
293
+
294
+ **Pro** ($9/mo):
295
+ - Semantic search is a significant infrastructure requirement (PostgreSQL + pgvector)
296
+ - Cross-encoder reranking adds meaningful relevance improvement
297
+ - Observability provides professional-grade session tracking
298
+ - The value: "Your AI remembers better and you can see what it learned"
299
+
300
+ **Enterprise** ($29/mo):
301
+ - Zettelkasten requires Obsidian + significant graph computation
302
+ - 6 specialized operations (explore, surprise, converse, themes, health, suggest)
303
+ - Creative studio for specialized content creation workflows
304
+ - The value: "Your knowledge graph is actively maintained by AI"
305
+
306
+ ---
307
+
308
+ ## Build System Integration
309
+
310
+ The existing build system continues to work unchanged:
311
+
312
+ ```bash
313
+ bun run build
314
+ # = tsdown (compile TS)
315
+ # + node scripts/build-hooks.mjs --sync (compile hooks, symlink to ~/.claude/Hooks/)
316
+ # + node scripts/build-skill-stubs.mjs --sync (generate skills, symlink to ~/.claude/skills/)
317
+ ```
318
+
319
+ The plugin manifests (`pai-plugin.json`, `.claude-plugin/plugin.json`, etc.) are static JSON files maintained alongside the codebase. They declare the module structure but do not participate in the build process.
320
+
321
+ Future enhancement: a `scripts/build-plugin-manifest.mjs` that generates manifests from the module plugin.json files, ensuring version consistency.
322
+
323
+ ---
324
+
325
+ ## Migration Path
326
+
327
+ ### From Pre-Plugin PAI (v0.6.x)
328
+
329
+ No migration needed. The plugin architecture is purely additive:
330
+
331
+ 1. All existing symlinks continue to work
332
+ 2. `~/.claude/settings.json` hook registrations unchanged
333
+ 3. MCP server registration unchanged
334
+ 4. User skills in `~/.claude/skills/user/` unchanged
335
+ 5. Custom prompts in `src/daemon-mcp/prompts/custom/` unchanged
336
+
337
+ ### For New Users
338
+
339
+ `pai setup` handles everything. The setup wizard installs all modules by default. Users can selectively disable modules later.
340
+
341
+ ---
342
+
343
+ ## Future Roadmap
344
+
345
+ ### Phase 1 (v0.7.0 — Current)
346
+ - Module manifest system
347
+ - Cross-platform manifests
348
+ - User extension points
349
+ - Tier annotations (no enforcement)
350
+
351
+ ### Phase 2 (v0.8.0)
352
+ - `pai plugins list` — show installed modules and tiers
353
+ - `pai plugins enable/disable <module>` — selective module activation
354
+ - Build system reads `pai-plugin.json` to generate platform manifests
355
+
356
+ ### Phase 3 (v0.9.0)
357
+ - License validation system
358
+ - `pai license activate <key>` command
359
+ - Graceful tier gating with upgrade prompts
360
+
361
+ ### Phase 4 (v1.0.0)
362
+ - Plugin marketplace integration
363
+ - Third-party plugin support
364
+ - Plugin dependency resolution
365
+ - Community plugin repository
@@ -3793,7 +3793,7 @@ function cmdLogs(opts) {
3793
3793
  }
3794
3794
  function registerDaemonCommands(daemonCmd) {
3795
3795
  daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
3796
- const { serve } = await import("../daemon-D3hYb5_C.mjs").then((n) => n.t);
3796
+ const { serve } = await import("../daemon-DJoesjez.mjs").then((n) => n.t);
3797
3797
  const { loadConfig: lc, ensureConfigDir } = await import("../config-BuhHWyOK.mjs").then((n) => n.r);
3798
3798
  ensureConfigDir();
3799
3799
  await serve(lc());
@@ -8,7 +8,7 @@ import "../indexer-D53l5d1U.mjs";
8
8
  import { t as PaiClient } from "../ipc-client-CoyUHPod.mjs";
9
9
  import { i as ensureConfigDir, o as loadConfig } from "../config-BuhHWyOK.mjs";
10
10
  import "../factory-Ygqe_bVZ.mjs";
11
- import { n as serve } from "../daemon-D3hYb5_C.mjs";
11
+ import { n as serve } from "../daemon-DJoesjez.mjs";
12
12
  import "../state-C6_vqz7w.mjs";
13
13
  import "../tools-DcaJlYDN.mjs";
14
14
  import "../detector-jGBuYQJM.mjs";