@tekmidian/pai 0.6.0 → 0.6.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.
package/ARCHITECTURE.md CHANGED
@@ -95,15 +95,22 @@ docker run -d \
95
95
  pai setup
96
96
  ```
97
97
 
98
- The interactive wizard walks through seven steps:
98
+ The interactive wizard walks through 14 steps:
99
99
 
100
- 1. PostgreSQL connection (host, port, credentials)
101
- 2. Embedding model selection (Snowflake Arctic recommended)
102
- 3. Indexing interval (default: 5 minutes)
100
+ 1. Welcome and version check
101
+ 2. Storage backend selection (SQLite or PostgreSQL)
102
+ 3. Embedding model configuration
103
103
  4. CLAUDE.md template installation
104
- 5. Projects root directory
105
- 6. Obsidian vault location (optional)
106
- 7. MCP server registration with Claude Code
104
+ 5. PAI skill installation
105
+ 6. Steering rules installation
106
+ 7. Hook system deployment
107
+ 8. TypeScript hook compilation
108
+ 9. Claude Code settings configuration
109
+ 10. Daemon installation
110
+ 11. MCP server registration
111
+ 12. Directory creation
112
+ 13. Initial indexing
113
+ 14. Verification
107
114
 
108
115
  ### 4. Install the Daemon
109
116
 
@@ -143,7 +150,7 @@ If both commands return healthy output, PAI is running. Open a new Claude Code s
143
150
 
144
151
  ## MCP Server
145
152
 
146
- PAI exposes 7 tools to Claude Code via a daemon-backed MCP shim. The shim speaks stdio (what Claude Code expects) and proxies each request to the background daemon over NDJSON on a Unix socket.
153
+ PAI exposes 9 tools, 18 on-demand prompts (skills), and 11 reference resources to Claude Code via a daemon-backed MCP shim. The shim speaks stdio (what Claude Code expects) and proxies each request to the background daemon over NDJSON on a Unix socket.
147
154
 
148
155
  ```
149
156
  Claude Code (stdio)
@@ -164,14 +171,8 @@ Claude Code (stdio)
164
171
  | `session_list` | List session notes, optionally filtered by project |
165
172
  | `registry_search` | Search project metadata (names, paths, tags) |
166
173
  | `project_detect` | Identify which project a given path belongs to |
167
- | `observation_search` | Search classified observations by project, type, or session |
168
- | `observation_timeline` | Recent observation timeline with progressive context layers |
169
- | `zettel_explore` | BFS traversal of wikilink graph from a seed note |
170
- | `zettel_surprise` | Find semantically distant but graph-close notes |
171
- | `zettel_converse` | Hybrid search with graph expansion and cross-domain connections |
172
- | `zettel_themes` | Cluster vault notes into thematic groups by embedding similarity |
173
- | `zettel_health` | Audit vault for broken links, orphans, and isolated clusters |
174
- | `zettel_suggest` | Suggest link targets weighted by semantics, tags, and graph neighborhood |
174
+ | `project_health` | Audit all registered paths for moved or deleted directories |
175
+ | `project_todo` | Read a project's TODO.md and continuation prompt |
175
176
 
176
177
  ### Tool Reference
177
178
 
@@ -189,21 +190,52 @@ Claude Code (stdio)
189
190
 
190
191
  **`project_detect(path?)`** — Given a filesystem path (defaults to CWD), returns the matching project.
191
192
 
192
- **`observation_search(project?, type?, session_id?, limit?)`** — Search the observation store. Filter by project slug, observation type (`decision`, `bugfix`, `feature`, `refactor`, `discovery`, `change`), or session ID. Returns observations ordered by creation time descending.
193
+ **`project_health(category?)`** — Audits all registered projects to find moved or deleted directories. Categorizes each as `active` (path exists), `stale` (path missing but candidate found nearby), or `dead` (path missing, no candidate). Also reports TODO.md presence and continuation prompts.
193
194
 
194
- **`observation_timeline(project?, limit?)`** — Returns a layered timeline: compact index (~100 tokens with type counts and active projects), recent timeline (~500 tokens with timestamped observations), and on-demand detail access via `observation_search`.
195
+ **`project_todo(project?)`** — Reads a project's TODO.md without needing the exact file path. Searches Notes/TODO.md, .claude/Notes/TODO.md, tasks/todo.md, and project-root TODO.md in order. Surfaces any `## Continue` section at the top for quick context recovery.
195
196
 
196
- **`zettel_explore(note, depth?, direction?)`** — BFS walk from a seed note across `vault_links`. Returns a subgraph of neighboring notes with each edge classified as `sequential` or `associative`. `direction`: `outbound` (default), `inbound`, or `both`.
197
+ ### On-Demand Prompts (Skills)
197
198
 
198
- **`zettel_surprise(note, limit?)`** Returns notes that are semantically dissimilar to `note` but reachable within a short graph distance. Scored as `cosine_similarity × log2(graph_distance + 1)`. Useful for lateral discovery.
199
+ The MCP server registers 18 prompts that Claude can invoke as on-demand skills. Each prompt provides a focused workflow with instructions, examples, and constraints loaded only when needed to conserve context.
199
200
 
200
- **`zettel_converse(query, limit?)`** Runs a hybrid memory search, expands the result set via graph neighborhood, then surfaces cross-domain connections — notes from unrelated clusters that are semantically close to the query.
201
-
202
- **`zettel_themes(min_cluster_size?)`** Clusters all vault embeddings using agglomerative single-linkage clustering. Returns thematic groups with representative note titles and cluster size.
203
-
204
- **`zettel_health()`** — Full structural audit of the vault. Reports broken links (target not in `vault_files`), orphaned notes (no inbound or outbound edges), notes missing embeddings, and isolated clusters detected via union-find.
205
-
206
- **`zettel_suggest(note, limit?)`** Ranks candidate link targets for a given note. Score is a weighted sum: semantic embedding similarity (0.5), shared tags (0.2), graph neighborhood overlap with existing links (0.3).
201
+ | Prompt | Purpose |
202
+ |--------|---------|
203
+ | `art` | Visual art direction and creative guidance |
204
+ | `createskill` | Scaffold new PAI skills |
205
+ | `journal` | Structured journaling workflow |
206
+ | `name` | Session and project naming conventions |
207
+ | `observability` | Observation system usage and querying |
208
+ | `plan` | Forward-looking planning from TODOs and recent activity |
209
+ | `research` | Structured research methodology |
210
+ | `review` | Retrospective review of work over a time period |
211
+ | `route` | Session note routing across projects |
212
+ | `search-history` | Search history analysis and patterns |
213
+ | `sessions` | Session lifecycle management |
214
+ | `share` | Generate social media posts from recent work |
215
+ | `story-explanation` | Narrative explanations of technical concepts |
216
+ | `vault-connect` | Suggest and create vault connections |
217
+ | `vault-context` | Use vault as conversational context |
218
+ | `vault-emerge` | Detect emerging themes in the vault |
219
+ | `vault-orphans` | Find and fix orphaned vault notes |
220
+ | `vault-trace` | Trace idea lineage through vault links |
221
+
222
+ ### Reference Resources
223
+
224
+ 11 resources available via `pai://` URIs. Claude reads these on demand for reference documentation.
225
+
226
+ | URI | Content |
227
+ |-----|---------|
228
+ | `pai://aesthetic` | Visual and output style guidelines |
229
+ | `pai://constitution` | Core philosophy and principles |
230
+ | `pai://history-system` | Search history tracking system |
231
+ | `pai://hook-system` | Hook architecture and development guide |
232
+ | `pai://mcp-dev-guide` | MCP server development patterns |
233
+ | `pai://prompting` | Prompt engineering best practices |
234
+ | `pai://prosody-agent-template` | Voice agent template |
235
+ | `pai://prosody-guide` | Voice and prosody guidelines |
236
+ | `pai://skill-system` | Skill authoring reference |
237
+ | `pai://terminal-tabs` | Terminal tab management |
238
+ | `pai://voice` | Voice configuration reference |
207
239
 
208
240
  ### Installation
209
241
 
@@ -418,7 +450,7 @@ pai observation stats
418
450
  ```bash
419
451
  pai backup # Backup registry, config, and Postgres
420
452
  pai restore <path> # Restore from backup (--no-postgres to skip DB)
421
- pai setup # Interactive 7-step setup wizard
453
+ pai setup # Interactive 14-step setup wizard
422
454
  pai search "query" # Quick full-text search shortcut
423
455
  ```
424
456
 
@@ -819,41 +851,89 @@ bun run lint # tsc --noEmit
819
851
  | Output | Purpose |
820
852
  |--------|---------|
821
853
  | `dist/cli/index.mjs` | `pai` CLI |
822
- | `dist/mcp/index.mjs` | Direct MCP server (legacy) |
823
854
  | `dist/daemon/index.mjs` | Daemon server |
824
855
  | `dist/daemon-mcp/index.mjs` | MCP shim (stdio → daemon socket) |
856
+ | `dist/hooks/*.mjs` | Compiled lifecycle hooks |
825
857
 
826
858
  ### Source Structure
827
859
 
828
860
  ```
829
861
  src/
830
- ├── cli/commands/ # CLI command implementations
831
- └── zettel.ts # `pai zettel` with 6 subcommands
832
- ├── daemon/ # Daemon server and index scheduler
833
- ├── daemon-mcp/ # MCP shim (stdio → daemon socket)
834
- ├── federation/ # Federation schema definitions
835
- ├── hooks/ # Lifecycle hooks (pre-compact, session-stop)
836
- ├── mcp/ # Direct MCP server (legacy)
837
- ├── memory/ # Indexer, chunker, embeddings, search, reranker
838
- │ ├── reranker.ts # Cross-encoder reranking (Xenova/ms-marco-MiniLM-L-6-v2)
839
- └── vault-indexer.ts # Obsidian vault indexing into v3 vault tables
840
- ├── observations/ # Automatic observation capture
841
- │ ├── classifier.ts # Rule-based tool call classifier (decision/bugfix/feature/refactor/discovery/change)
842
- ├── store.ts # PostgreSQL persistence with content-hash deduplication
843
- │ └── schema.sql # Observation + session summary table DDL
844
- ├── obsidian/ # Obsidian vault bridge
845
- │ └── vault-fixer.ts # Repairs broken wikilinks and orphaned entries
846
- ├── registry/ # Registry migrations and queries
847
- ├── session/ # Session slug generator
848
- ├── storage/ # Storage backend interface (SQLite/Postgres)
849
- └── zettelkasten/ # Luhmann-inspired graph + semantic operations
850
- ├── explore.ts # BFS traversal classifying sequential/associative edges
851
- ├── surprise.ts # Serendipitous bridge discovery via cosine × graph distance
852
- ├── converse.ts # Hybrid search → graph expansion → cross-domain connections
853
- ├── themes.ts # Agglomerative embedding clustering for thematic groups
854
- ├── health.ts # SQL-driven vault audit with union-find cluster detection
855
- ├── suggest.ts # Weighted link suggestions (semantic + tags + graph)
856
- └── index.ts # Barrel export for all zettelkasten operations
862
+ ├── cli/
863
+ ├── commands/ # CLI command modules
864
+ │ │ ├── backup.ts
865
+ │ │ ├── daemon.ts
866
+ │ │ ├── memory.ts
867
+ │ │ ├── observation.ts
868
+ │ │ ├── obsidian.ts
869
+ │ │ ├── project.ts
870
+ ├── registry.ts
871
+ │ ├── session.ts
872
+ │ │ ├── setup/ # 14-step interactive wizard
873
+ │ │ ├── steps/ # 01-welcome through 15-verify
874
+ │ │ └── index.ts
875
+ └── zettel.ts
876
+ │ └── index.ts # CLI entry point
877
+ ├── daemon/
878
+ ├── daemon/ # Daemon server internals
879
+ │ │ ├── dispatcher.ts # Tool dispatch (zettel, observation, memory)
880
+ │ │ ├── handler.ts # NDJSON request handler
881
+ │ │ └── server.ts # Socket server
882
+ ├── indexer/ # Background index scheduler
883
+ ├── config.ts # Runtime configuration
884
+ │ └── index.ts # Daemon entry point
885
+ ├── daemon-mcp/
886
+ ├── instructions.ts # MCP server instructions (~1.5KB routing table)
887
+ ├── prompts/ # 18 on-demand skill prompts
888
+ │ ├── resources/ # 11 reference resources (pai:// URIs)
889
+ │ └── index.ts # MCP shim entry point (stdio → socket)
890
+ ├── hooks/
891
+ │ └── ts/ # TypeScript hook sources by event
892
+ │ ├── PreCompact/
893
+ │ ├── PreToolUse/
894
+ │ ├── PostToolUse/
895
+ │ ├── SessionStart/
896
+ │ ├── Stop/
897
+ │ └── UserPromptSubmit/
898
+ ├── mcp/
899
+ │ └── tools/ # Shared tool implementations
900
+ │ ├── memory.ts
901
+ │ ├── observations.ts
902
+ │ ├── projects.ts
903
+ │ ├── registry.ts
904
+ │ ├── sessions.ts
905
+ │ └── zettel.ts
906
+ ├── memory/
907
+ │ ├── chunker/ # Text chunking strategies
908
+ │ ├── embeddings.ts # Snowflake Arctic embedding generation
909
+ │ ├── indexer.ts # File indexer with change detection
910
+ │ ├── reranker.ts # Cross-encoder reranking (ms-marco-MiniLM)
911
+ │ ├── search.ts # Multi-mode search (keyword/semantic/hybrid)
912
+ │ └── vault-indexer.ts # Obsidian vault indexing
913
+ ├── observations/ # Automatic observation capture
914
+ │ ├── classifier.ts # Rule-based tool call classifier
915
+ │ ├── store.ts # PostgreSQL persistence with deduplication
916
+ │ └── schema.sql # DDL for observation tables
917
+ ├── obsidian/ # Obsidian vault bridge
918
+ │ └── vault-fixer.ts # Repairs broken wikilinks and orphans
919
+ ├── registry/ # SQLite registry queries and migrations
920
+ ├── session/ # Session slug generator
921
+ ├── storage/ # Pluggable storage backend
922
+ │ ├── factory.ts # Backend selection (SQLite/PostgreSQL)
923
+ │ ├── interface.ts # StorageInterface contract
924
+ │ ├── postgres.ts # PostgreSQL + pgvector backend
925
+ │ └── sqlite.ts # SQLite backend
926
+ ├── utils/ # Shared utilities
927
+ │ ├── hash.ts # SHA-256 hashing
928
+ │ └── stop-words.ts # Stop word lists for search
929
+ ├── zettelkasten/ # Luhmann-inspired operations
930
+ │ ├── explore.ts # BFS traversal
931
+ │ ├── surprise.ts # Serendipitous bridge discovery
932
+ │ ├── converse.ts # Hybrid search + graph expansion
933
+ │ ├── themes.ts # Embedding clustering
934
+ │ ├── health.ts # Vault structural audit
935
+ │ └── suggest.ts # Weighted link suggestions
936
+ └── index.ts # Package entry point
857
937
  ```
858
938
 
859
939
  ### Important Notes
package/FEATURE.md CHANGED
@@ -28,13 +28,13 @@ different direction: persistent memory, session continuity, and deep Claude Code
28
28
  | **Persistent session memory** | No | Yes — auto-indexed, 449K+ chunks |
29
29
  | **Session registry** | No | Yes — SQLite, tracks 77+ projects |
30
30
  | **Background daemon** | No | Yes — launchd, IPC via Unix socket |
31
- | **MCP server** | No | Yes — 7+ tools exposed to Claude Code |
31
+ | **MCP server** | No | Yes — 9 tools, 18 prompts, 11 resources exposed to Claude Code |
32
32
  | **Keyword search (BM25)** | No | Yes — GIN full-text index, PostgreSQL |
33
33
  | **Semantic search (vector)** | No | Yes — pgvector HNSW, Snowflake Arctic 768-dim |
34
34
  | **Multi-backend storage** | No | Yes — SQLite (simple) or PostgreSQL (full) |
35
35
  | **Obsidian vault bridge** | No | Yes — symlinks + auto-generated topic pages |
36
36
  | **Project lifecycle** | No | Yes — promote, archive, move, detect from cwd |
37
- | **Setup wizard** | No | Yes — idempotent 7-step interactive wizard |
37
+ | **Setup wizard** | No | Yes — idempotent 14-step interactive wizard |
38
38
  | **Hook system** | No | Yes — pre-compact, session-stop, auto-cleanup |
39
39
  | **Backup / restore** | No | Yes — timestamped pg_dump + registry export |
40
40
  | **Multi-session concurrency** | n/a | Yes — daemon multiplexes Claude sessions |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekmidian/pai",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "PAI Knowledge OS — Personal AI Infrastructure with federated memory and project management",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",