@tekmidian/pai 0.65.0 → 0.65.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 (66) hide show
  1. package/README.md +60 -1065
  2. package/dist/{chain-C8QO8gwj.mjs → chain-CLb6hbFS.mjs} +2 -2
  3. package/dist/{chain-C8QO8gwj.mjs.map → chain-CLb6hbFS.mjs.map} +1 -1
  4. package/dist/cli/index.mjs +6 -6
  5. package/dist/cli/program.mjs +6 -6
  6. package/dist/config-BbLFD7Uf.mjs.map +1 -1
  7. package/dist/daemon/index.mjs +3 -3
  8. package/dist/{daemon-CX9JomIJ.mjs → daemon-BjaPR39W.mjs} +3 -3
  9. package/dist/{daemon-D2r1AQqE.mjs → daemon-DqCB3fO-.mjs} +3 -3
  10. package/dist/{daemon-D2r1AQqE.mjs.map → daemon-DqCB3fO-.mjs.map} +1 -1
  11. package/dist/daemon-mcp/index.mjs +4 -4
  12. package/dist/daemon-mcp/index.mjs.map +1 -1
  13. package/dist/{fallback-CWDQYmJi.mjs → fallback-CupzGkuJ.mjs} +2 -2
  14. package/dist/{fallback-CWDQYmJi.mjs.map → fallback-CupzGkuJ.mjs.map} +1 -1
  15. package/dist/hooks/block-sleep-poll.mjs.map +1 -1
  16. package/dist/hooks/context-compression-hook.mjs.map +1 -1
  17. package/dist/hooks/load-project-context.mjs.map +2 -2
  18. package/dist/hooks/post-compact-inject.mjs.map +1 -1
  19. package/dist/hooks/route-agents-to-worker.mjs.map +1 -1
  20. package/dist/hooks/security-validator.mjs +2 -2
  21. package/dist/hooks/security-validator.mjs.map +1 -1
  22. package/dist/hooks/whisper-rules.mjs.map +1 -1
  23. package/dist/hooks/worker-guard.mjs.map +1 -1
  24. package/dist/hooks/worker-proxy.mjs.map +1 -1
  25. package/dist/hooks/worker-status-line.mjs.map +2 -2
  26. package/dist/hooks/worker-supervision.mjs.map +1 -1
  27. package/dist/{main-resolver-CDe7DCso.mjs → main-resolver-BeYWNzrt.mjs} +6 -6
  28. package/dist/{main-resolver-CDe7DCso.mjs.map → main-resolver-BeYWNzrt.mjs.map} +1 -1
  29. package/dist/{main-resolver-DI-A7lSO.mjs → main-resolver-kHW6FewU.mjs} +1 -1
  30. package/dist/{planner-8-shIa8t.mjs → planner-DAq4Yx-H.mjs} +3 -3
  31. package/dist/{planner-8-shIa8t.mjs.map → planner-DAq4Yx-H.mjs.map} +1 -1
  32. package/dist/{program-DiktbiWa.mjs → program-CWf9mT7Z.mjs} +45 -23
  33. package/dist/program-CWf9mT7Z.mjs.map +1 -0
  34. package/dist/{run-DUZRSnIT.mjs → run-uAkNItb6.mjs} +22 -4
  35. package/dist/run-uAkNItb6.mjs.map +1 -0
  36. package/dist/{session-keepalive-CZUwp5IQ.mjs → session-keepalive-BWEjcRrh.mjs} +2 -2
  37. package/dist/{session-keepalive-CZUwp5IQ.mjs.map → session-keepalive-BWEjcRrh.mjs.map} +1 -1
  38. package/dist/skills/Tasks/SKILL.md +1 -1
  39. package/docs/auto-compact.md +31 -0
  40. package/docs/budget-advisor.md +48 -0
  41. package/docs/command-reference.md +25 -0
  42. package/docs/companion-projects.md +9 -0
  43. package/docs/context-preservation.md +43 -0
  44. package/docs/how-it-works.md +25 -0
  45. package/docs/install-linux.md +32 -0
  46. package/docs/install.md +56 -0
  47. package/docs/memory.md +96 -0
  48. package/docs/observations.md +58 -0
  49. package/docs/release-history.md +42 -0
  50. package/docs/rules-and-privacy.md +37 -0
  51. package/docs/search.md +169 -0
  52. package/docs/session-management.md +153 -0
  53. package/docs/session-notes.md +64 -0
  54. package/docs/skills.md +45 -0
  55. package/docs/task-bus.md +1 -2
  56. package/docs/use-cases.md +194 -0
  57. package/docs/what-you-can-ask.md +78 -0
  58. package/docs/worker-providers.md +58 -0
  59. package/docs/zettelkasten.md +37 -0
  60. package/package.json +1 -1
  61. package/plugins/productivity/skills/Tasks/SKILL.md +1 -1
  62. package/src/hooks/ts/pre-tool-use/security-validator.test.ts +23 -0
  63. package/src/hooks/ts/pre-tool-use/security-validator.ts +1 -1
  64. package/src/hooks/ts/session-start/load-project-context.ts +1 -1
  65. package/dist/program-DiktbiWa.mjs.map +0 -1
  66. package/dist/run-DUZRSnIT.mjs.map +0 -1
@@ -0,0 +1,194 @@
1
+ # PAI Knowledge OS - Use Cases
2
+
3
+
4
+ ## 1. Solo Developer - Building a SaaS Product
5
+
6
+ ### The Person
7
+
8
+ Alex builds a project management SaaS solo. Alternates between frontend (React), backend (Node.js), infrastructure (AWS), and customer support. Uses Claude Code 8-10 hours a day.
9
+
10
+ ### Before PAI
11
+
12
+ Every morning, Alex spends 20 minutes re-explaining the project to Claude: "We're building a PM tool, here's the stack, here's where we left off on the notification system, the database schema looks like this..." When context compaction hits mid-afternoon, another 15 minutes gone. Multiply by 250 working days: **145 hours per year re-explaining context**.
13
+
14
+ ### After PAI
15
+
16
+ Alex says "Go" and Claude reads the TODO.md continuation prompt. It knows the project, the stack, the current sprint, and what broke yesterday. When compaction hits, PAI's relay preserves state automatically. Alex's weekly review ("review my week") generates a narrative of everything accomplished - useful for investor updates.
17
+
18
+ **Key features used:** Session continuity, context preservation, project registry, plan skill, review skill
19
+
20
+ ---
21
+
22
+ ## 2. Team Lead - Managing Multiple Codebases
23
+
24
+ ### The Person
25
+
26
+ Jordan manages 5 microservices, 3 frontend apps, and a shared library. Switches between projects 10-15 times per day. Has 3 junior developers asking questions about architecture decisions made months ago.
27
+
28
+ ### Before PAI
29
+
30
+ Jordan cannot remember which session had the discussion about the event bus architecture. The junior dev asks "why did we choose RabbitMQ over Kafka?" and Jordan has to dig through Slack, Notion, and git commit messages to reconstruct the reasoning.
31
+
32
+ ### After PAI
33
+
34
+ Jordan searches: "Search your memory for message queue decision." PAI finds the session from 6 weeks ago where the tradeoffs were discussed, including the specific latency requirements that ruled out Kafka. The junior dev gets a complete answer in 30 seconds.
35
+
36
+ **Key features used:** Memory search, cross-project sessions, session history, project registry, observation capture
37
+
38
+ ---
39
+
40
+ ## 3. Researcher - Academic Paper Writing
41
+
42
+ ### The Person
43
+
44
+ Dr. Chen writes papers using Claude Code for LaTeX editing, data analysis scripts, and literature review organization. Works on 3 papers simultaneously with different co-authors.
45
+
46
+ ### Before PAI
47
+
48
+ Each paper requires different context: methodologies, related work, reviewer comments. Switching between papers means a 10-minute context dump each time. Literature connections between papers are tracked manually in a spreadsheet.
49
+
50
+ ### After PAI
51
+
52
+ Each paper is a PAI project. "Which project am I in?" auto-detects from the directory. Dr. Chen's Obsidian vault is indexed by PAI's Zettelkasten system. "Find surprising connections to this note on attention mechanisms" discovers a relevant paper in the NLP project that applies to the computer vision paper - a connection Dr. Chen missed.
53
+
54
+ **Key features used:** Project registry, Zettelkasten (surprise, themes), session management, vault intelligence
55
+
56
+ ---
57
+
58
+ ## 4. Consultant - Client Project Rotation
59
+
60
+ ### The Person
61
+
62
+ Maria is a freelance developer working with 6 clients simultaneously. Each client has different tech stacks, coding standards, deployment processes, and communication preferences.
63
+
64
+ ### Before PAI
65
+
66
+ Monday: Maria works on Client A's Django project. Tuesday: Client B's React app. By Wednesday, she can't remember Client A's specific deployment process. She keeps a folder of client context documents that she manually pastes into Claude sessions.
67
+
68
+ ### After PAI
69
+
70
+ Maria's 6 clients are 6 PAI projects. "What's the deployment process for Client A?" - PAI finds it in session notes from last week. Observations capture every deployment command she ran, so the process is reconstructible even if she never wrote it down. Weekly reviews per client make invoicing easy.
71
+
72
+ **Key features used:** Multi-project management, observation capture, memory search, review skill, session history
73
+
74
+ ---
75
+
76
+ ## 5. Open Source Maintainer - Community Management
77
+
78
+ ### The Person
79
+
80
+ Sam maintains a popular open source library with 5,000 GitHub stars, 200+ issues, and regular pull request reviews.
81
+
82
+ ### Before PAI
83
+
84
+ Contributors ask the same architectural questions repeatedly. "Why is this implemented this way?" Sam re-explains the same reasoning in GitHub issues, Discord, and PR reviews. Design decisions from 8 months ago are lost in conversation history.
85
+
86
+ ### After PAI
87
+
88
+ Sam's design decisions are captured as observations. "Search your memory for the decision about the plugin API" finds the session where the API was designed, including rejected alternatives and the reasoning. Sam uses the Share skill to generate a technical blog post about the architecture for the project's documentation.
89
+
90
+ **Key features used:** Observation capture (decisions), memory search, share skill, review skill
91
+
92
+ ---
93
+
94
+ ## 6. Job Seeker - Application Management
95
+
96
+ ### The Person
97
+
98
+ Lisa is a senior engineer looking for her next role. She's applying to 15 companies, each requiring tailored cover letters and application tracking.
99
+
100
+ ### Before PAI
101
+
102
+ Lisa tracks applications in a spreadsheet. Each cover letter requires manually adapting her experience to the job description. Follow-up timing is tracked with calendar reminders.
103
+
104
+ ### After PAI
105
+
106
+ With SeriousLetter MCP (companion), Lisa's applications are managed through Claude. PAI remembers each company's context: "What did I tell Acme Corp about my distributed systems experience?" The journal skill tracks her reflections after interviews. The review skill generates weekly job search summaries.
107
+
108
+ **Key features used:** SeriousLetter integration, journal skill, review skill, project management, memory search
109
+
110
+ ---
111
+
112
+ ## 7. Content Creator - Technical Writing
113
+
114
+ ### The Person
115
+
116
+ Dev writes a weekly technical newsletter and produces YouTube tutorials. Uses Claude Code to help draft content, write code examples, and edit scripts.
117
+
118
+ ### Before PAI
119
+
120
+ Dev cannot easily find previous content to avoid repetition. "Did I already write about rate limiting?" requires manually searching through 50+ newsletter editions. Code examples are lost in old Claude sessions.
121
+
122
+ ### After PAI
123
+
124
+ "Search your memory for rate limiting" instantly shows what Dev has written. The Share skill generates newsletter drafts and social media posts from recent work. Code examples from any session are retrievable. "Review my month" generates a content roundup.
125
+
126
+ **Key features used:** Memory search, share skill (LinkedIn, X, Bluesky), review skill, session history
127
+
128
+ ---
129
+
130
+ ## 8. Knowledge Worker - Building a Second Brain
131
+
132
+ ### The Person
133
+
134
+ Pat is a product manager who uses Obsidian to track market research, user interviews, competitive analysis, and product strategy. Has 2,000+ notes accumulated over 3 years.
135
+
136
+ ### Before PAI
137
+
138
+ Obsidian search is keyword-only. Pat knows there's a connection between the user interview from March and the competitive analysis from June, but can't find it. Notes accumulate but connections between them are manual.
139
+
140
+ ### After PAI
141
+
142
+ PAI's Zettelkasten module indexes Pat's vault. "What themes are emerging in my vault?" detects clusters of related notes forming around "AI-first workflows." "Suggest connections for this note" proposes 5 links Pat never considered. "How healthy is my vault?" reveals 47 orphaned notes that need integration.
143
+
144
+ **Key features used:** Zettelkasten (all 6 operations), vault indexing, semantic search, themes, health
145
+
146
+ ---
147
+
148
+ ## 9. Security Auditor - Compliance and Penetration Testing
149
+
150
+ ### The Person
151
+
152
+ Robin conducts security audits for enterprise clients. Each engagement produces hundreds of findings, code reviews, and remediation recommendations.
153
+
154
+ ### Before PAI
155
+
156
+ Previous audit findings are buried in PDF reports. When Robin encounters a similar vulnerability pattern at a new client, there's no quick way to reference how it was documented and remediated before.
157
+
158
+ ### After PAI
159
+
160
+ Each audit is a PAI project. "Search your memory for SQL injection remediation" finds findings from previous audits, including specific remediation code. Observations automatically capture every security-relevant command and finding. Session summaries create audit trails. The research skill structures vulnerability analysis.
161
+
162
+ **Key features used:** Project registry, observation capture, memory search, session summaries, research skill
163
+
164
+ ---
165
+
166
+ ## 10. AI-First Company - Engineering Team
167
+
168
+ ### The Person
169
+
170
+ A 12-person startup where every engineer uses Claude Code daily. The CTO wants institutional knowledge to survive employee turnover and ensure architectural decisions are documented.
171
+
172
+ ### Before PAI
173
+
174
+ When Engineer A leaves, their Claude Code sessions (and all the architectural reasoning) vanish. The replacement spends 2 months reconstructing context. Design decisions are scattered across Slack, Notion, and individual engineers' heads.
175
+
176
+ ### After PAI
177
+
178
+ Every engineer runs PAI. Architectural decisions are automatically captured as observations. Memory search works across all projects. When Engineer A leaves, their session history, observations, and decision trail remain searchable. New engineers search "why did we choose GraphQL" and get the complete reasoning. The review skill generates team-wide weekly summaries for the CTO.
179
+
180
+ **Key features used:** Multi-project registry, observation capture (decisions), memory search (cross-project), review skill, session continuity
181
+
182
+ ---
183
+
184
+ ## Common Patterns Across Use Cases
185
+
186
+ | Pattern | PAI Feature | Time Saved |
187
+ |---------|------------|------------|
188
+ | Re-explaining context every session | Session continuity, context preservation | 15-30 min/session |
189
+ | Finding past decisions | Observation capture, memory search | Hours/week |
190
+ | Tracking work across projects | Project registry, cross-project search | Hours/week |
191
+ | Creating content from work | Share, Review skills | 2-4 hours/week |
192
+ | Maintaining knowledge connections | Zettelkasten operations | Manual impossible |
193
+ | Surviving context compaction | Two-stage relay | 15 min/compaction |
194
+ | Onboarding new team members | Searchable institutional memory | Weeks/hire |
@@ -0,0 +1,78 @@
1
+ # What You Can Ask Claude
2
+
3
+ ## Searching Your Memory
4
+
5
+ - "Search your memory for authentication" — finds past sessions about auth, even with different words
6
+ - "What do you know about the Whazaa project?" — retrieves full project context instantly
7
+ - "Find where we discussed the database migration" — semantic search finds it even if you phrase it differently
8
+ - "Search your memory for that Chrome browser issue" — keyword and meaning-based search combined
9
+
10
+ ## Managing Projects
11
+
12
+ - "Show me all my projects" — lists everything PAI tracks with stats
13
+ - "Which project am I in?" — auto-detects from your current directory
14
+ - "What's the status of the PAI project?" — full project details, sessions, last activity
15
+ - "How many sessions does Whazaa have?" — project-level session history
16
+
17
+ ## Navigating Sessions
18
+
19
+ - "List my recent sessions" — shows what you've been working on across all projects
20
+ - "What did we do in session 42?" — retrieves any specific session by number
21
+ - "What were we working on last week?" — Claude knows, without you re-explaining
22
+ - "Clean up my session notes" — auto-names unnamed sessions and organizes by date
23
+
24
+ ## Reviewing Your Work
25
+
26
+ - "Review my week" — synthesizes session notes, git commits, and completed tasks into a themed narrative
27
+ - "What did I do today?" — daily review across all projects
28
+ - "Journal this thought" — capture freeform reflections with timestamps
29
+ - "Plan my week" — forward-looking priorities based on open TODOs and recent activity
30
+ - "What themes are emerging in my work?" — spot patterns across sessions and projects
31
+
32
+ ## Sharing Your Work
33
+
34
+ - "Share on LinkedIn today" — generates a professional post about what you shipped, with real numbers and technical substance
35
+ - "Tweet about the vault migration" — punchy X/Twitter post or thread, with option to post directly
36
+ - "Share on Bluesky this week" — conversational technical post for the Bluesky audience
37
+ - Platform-aware formatting: LinkedIn gets hashtags and narrative, X gets threads and hooks, Bluesky gets conversational tone
38
+
39
+ ## Tracking Your Activity
40
+
41
+ - "What changes did I make to the daemon today?" — automatic observation capture tracks every tool call
42
+ - "Show me all decisions from the last session" — observations are classified: decision, bugfix, feature, refactor, discovery, change
43
+ - "What files did I modify in the PAI project this week?" — searchable timeline of every edit, commit, and search
44
+ - "Show observation stats" — totals, breakdowns by type and project, with visual bar charts
45
+
46
+ ## Continuing Where You Left Off
47
+
48
+ - "Go" — reads your TODO.md continuation prompt and picks up exactly where the last session stopped
49
+ - "What was I working on?" — progressive context injection loads recent observations at session start
50
+ - "Continue the daemon refactor" — session summaries give Claude full context without re-explaining
51
+ - "/reconstruct" — retroactively creates session notes from JSONL transcripts and git history when automatic capture missed a session
52
+
53
+ ## Keeping Things Safe
54
+
55
+ - "Back up everything" — creates a timestamped backup of all your data
56
+ - "How's the system doing?" — checks daemon health, index stats, embedding coverage
57
+
58
+ ## Obsidian Integration
59
+
60
+ - "Sync my Obsidian vault" — updates your linked vault with the latest notes
61
+ - "Open my notes in Obsidian" — launches Obsidian with your full knowledge graph
62
+
63
+ ## Zettelkasten Intelligence
64
+
65
+ - "Explore notes linked to PAI" — follow trains of thought through wikilink chains
66
+ - "Find surprising connections to this note" — discover semantically similar but graph-distant notes
67
+ - "What themes are emerging in my vault?" — detect clusters of related notes forming new ideas
68
+ - "How healthy is my vault?" — structural audit: dead links, orphans, disconnected clusters
69
+ - "Suggest connections for this note" — proactive link suggestions using semantic + graph signals
70
+ - "What does my vault say about knowledge management?" — use the vault as a thinking partner
71
+
72
+ ## Budget Management
73
+
74
+ - "How much budget do I have left?" — shows current weekly usage and advisor mode
75
+ - "Go easy on the budget" — switches to conservative mode (prefer haiku subagents)
76
+ - "Lock it down" — switches to critical mode (minimize all token usage)
77
+ - "Go full power" — switches to normal mode (no constraints)
78
+ - "Back to auto" — resets to auto mode (derives from weekly budget percentage)
@@ -0,0 +1,58 @@
1
+ # Worker Providers — Run the Fleet Anywhere
2
+
3
+ **Read the story: [Provider Independence — how I freed my stack from a single vendor in one day](provider-independence.md).**
4
+
5
+ Only the outer orchestrator session runs on Anthropic. Every worker PAI spawns — research, drafting, implementation, review, spotchecks — runs on a managed provider you choose. The same provider layer carries the daemon's background calls and the session picker, so the whole stack moves together.
6
+
7
+ ## Why
8
+
9
+ - **Vendor independence.** Any provider that speaks the Anthropic Messages protocol is a registry entry: models, key file, price tier. OpenAI-protocol providers work through a built-in translating proxy. Switching is configuration, not surgery.
10
+ - **Cost control.** Parallel work is a commodity; it should not burn your premium seat. Workers bill against their own provider, and cheap classes resolve to the provider's fast model automatically.
11
+ - **No lock-in to one orchestrator vendor.** Sessions run on the active provider too — the picker launches through it, and `pai worker fallback` extends that machine-wide.
12
+ - **Survives orchestrator outages.** Workers carry their own provider credentials, so a quota freeze or outage on the vendor seat does not stop delegated work.
13
+
14
+ ## How
15
+
16
+ - **Managed providers.** `pai worker providers add` registers one, `pai worker providers use <name>` switches the fleet, `pai worker off` disables routing entirely (the Agent tool runs on Anthropic again), `pai worker on` re-enables it. The reserved name `anthropic` needs no `add` step — it's Claude Code's own login; `pai worker providers use anthropic` switches straight to it.
17
+ - **Start the harness itself on any provider.** `pai launch` (numbered picker, or `--provider <name> [--model <model>]`) starts a fresh Claude Code session on any provider/model in `workers.yaml` — a running session can't switch providers (base URL and auth are fixed at start), so this always begins a new one. Claude Code's own `/model` only lists the current endpoint's models; `pai launch --list` (or the `/providers` skill, from inside a session) lists every provider configured here.
18
+ - **Classes route work to the right model.** `--class` picks the provider and model for the job: `draft`, `plan`, `implement`, `review`, `research`, `spotcheck`, `simple`, `complex`, `image`. `pai worker classes` shows and edits the mapping; `--provider` / `--model` override for a single run.
19
+ - **Every worker spawn stands alone.** The orchestrator's API key is stripped and the spawn gets the provider's base URL, token and model ids instead — proven live: a worker answers with the parent's credentials gone. No inherited billing, no fallback to the vendor login.
20
+ - **The route is pinned, not inherited.** Claude Code's user settings outrank the process env, so a machine-wide proxy route (a `caveman` install, a `pai worker fallback`) would otherwise swallow a worker's base URL and send its provider token to the wrong endpoint. Every spawn repeats its route with `--settings`, which outranks user settings; native-Anthropic workers are pinned to `api.anthropic.com`, or launched as `caveman claude` when `workers.caveman: true` is set in `config.yaml`. Details: [docs/worker.md](worker.md), "What a worker is".
21
+ - **One file to configure it.** Providers, per-role model ids and class routing live in one hand-editable `workers.yaml` — adding a provider (Anthropic-compatible, OpenAI-compatible, or local) is a YAML edit, never code. Full reference: [docs/workers-config.md](workers-config.md).
22
+
23
+ ```yaml
24
+ active: anthropic
25
+ providers:
26
+ anthropic:
27
+ builtin: true # Claude Code's own login
28
+ models: { default: claude-sonnet-5, fast: claude-haiku-4-5-20251001 }
29
+ glm:
30
+ url: https://api.z.ai/api/anthropic
31
+ key: "<your-api-key>" # or key_file: <path to a 0600 file>
32
+ tier: 3
33
+ models: { default: glm-5.3[1m], fast: glm-5.3-flash }
34
+ classes:
35
+ implement: anthropic
36
+ spotcheck: anthropic/fast # cheap classes default to the fast model
37
+ ```
38
+
39
+ ## What
40
+
41
+ ```bash
42
+ pai worker run -p '<task>' --class implement # one worker on a provider
43
+ pai worker ps # this session's workers (--all: every one)
44
+ pai worker follow <id> # live transcript of one worker
45
+ pai worker pane # shared follow pane for the session
46
+ pai worker replay <id> # transcript of a finished or running worker
47
+ pai worker say <id> <text> # message a running worker mid-run
48
+ pai worker handoff '<json>' # from inside a worker: report to the parent
49
+ pai worker merge <id> # merge the worker's branch back, drop the worktree
50
+ pai worker wait <id>... # block until workers finish (never sleep-loop)
51
+ pai worker watch # ps refreshed every 2 seconds
52
+ ```
53
+
54
+ The rest of the surface — `discard`, `resume`, `controls`, `proxy`, `mcp`, `model`, `providers`, `classes` — is in `pai help worker` and [docs/commands/worker.md](commands/worker.md).
55
+
56
+ ![Workers in the statusline](images/workers.png)
57
+
58
+ Get started in three copy-paste steps: **[docs/provider-independence.md](provider-independence.md)**. For the depth — provider registry, statusline instrumentation, seam patches, current limits — see **[docs/provider-abstraction.md](provider-abstraction.md)**.
@@ -0,0 +1,37 @@
1
+ # Zettelkasten Intelligence
2
+
3
+ PAI implements Niklas Luhmann's Zettelkasten principles as six computational operations on your Obsidian vault.
4
+
5
+ ## How it works
6
+
7
+ PAI indexes your entire vault — following symlinks, deduplicating by inode, parsing every link — and builds a graph database alongside semantic embeddings. Six tools then operate on this dual representation:
8
+
9
+ | Tool | What it does |
10
+ |------|-------------|
11
+ | `pai zettel explore` | Follow trains of thought through link chains (Folgezettel traversal) |
12
+ | `pai zettel surprise` | Find notes that are semantically close but far apart in the link graph |
13
+ | `pai zettel converse` | Ask questions and let the vault "talk back" with unexpected connections |
14
+ | `pai zettel themes` | Detect emerging clusters of related notes across folders |
15
+ | `pai zettel health` | Structural audit — dead links, orphans, disconnected clusters, health score |
16
+ | `pai zettel suggest` | Proactive connection suggestions combining semantic similarity, tags, and graph proximity |
17
+
18
+ All tools work as CLI commands (`pai zettel <command>`) and MCP tools (`zettel_*`) accessible through the daemon.
19
+
20
+ ## Vault Indexing
21
+
22
+ The vault indexer follows symlinks (critical for vaults built on symlinks), deduplicates files by inode to handle multiple paths to the same file, and builds a complete link graph with Obsidian-compatible shortest-match resolution.
23
+
24
+ All link types are parsed and resolved:
25
+
26
+ | Syntax | Type | Example |
27
+ |--------|------|---------|
28
+ | `[[Note]]` | Wikilink | `[[Daily Note]]`, `[[Note\|alias]]`, `[[Note#heading]]` |
29
+ | `![[file]]` | Embed | `![[diagram.png]]`, `![[template]]` |
30
+ | `[text](path.md)` | Markdown link | `[see here](notes/idea.md)`, `[ref](note.md#section)` |
31
+ | `![alt](file)` | Markdown embed | `![photo](assets/img.jpg)` |
32
+
33
+ External URLs (`https://`, `mailto:`, etc.) are excluded — only relative paths are treated as vault connections. URL-encoded paths (e.g. `my%20note.md`) are decoded automatically.
34
+
35
+ - Full index: ~10 seconds for ~1,000 files
36
+ - Incremental: ~2 seconds (hash-based change detection)
37
+ - Runs automatically via the daemon scheduler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekmidian/pai",
3
- "version": "0.65.0",
3
+ "version": "0.65.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",
@@ -123,4 +123,4 @@ An explicit label that matches nothing does **not** fall through to the containe
123
123
 
124
124
  - `pai task done <id>` closes a task on the tracker. Dispatched tasks tell the receiving session to do this, so work is not dispatched twice.
125
125
  - The bus never reads the tracker back into PAI state. It is one-way: PAI and its sessions write, a routine reads.
126
- - Full architecture and the verified API constraints: `Notes/docs/task-bus.md`.
126
+ - Full architecture and the verified API constraints: `docs/task-bus.md`.
@@ -60,6 +60,29 @@ describe("security-validator", () => {
60
60
  expect(status).toBe(2);
61
61
  });
62
62
 
63
+ it.each([
64
+ "git push --force-with-lease origin main",
65
+ "git push --force-with-lease=main:abc123 origin main",
66
+ "git -C repo.git push --force-with-lease URL main refs/tags/v1",
67
+ "git push --force-with-lease --force-if-includes origin main",
68
+ "git push --follow-tags origin main",
69
+ ])("allows %s", (command) => {
70
+ const { status, stderr } = runHook(command);
71
+ expect(status).toBe(0);
72
+ expect(stderr).toBe("");
73
+ });
74
+
75
+ it.each([
76
+ "git push --force origin main",
77
+ "git push -f origin main",
78
+ "git push --force --force-with-lease origin main",
79
+ "git push --force-with-lease origin main --force",
80
+ "git push origin main -f",
81
+ ])("denies %s", (command) => {
82
+ const { status } = runHook(command);
83
+ expect(status).toBe(2);
84
+ });
85
+
63
86
  it("allows an ordinary command", () => {
64
87
  const { status, stderr } = runHook("ls -la");
65
88
  expect(status).toBe(0);
@@ -65,7 +65,7 @@ const DANGEROUS_FILE_OPS_PATTERNS: RegExp[] = [
65
65
 
66
66
  // OPTIONAL: Operations that require confirmation instead of blocking
67
67
  const DANGEROUS_GIT_PATTERNS: RegExp[] = [
68
- /\bgit\s+push\s+.*(-f\b|--force)/i, // git push --force
68
+ /\bgit\b.*\spush\b.*(\s-f\b|\s--force(\s|$))/i, // git push -f / --force; --force-with-lease and --follow-tags pass
69
69
  /\bgit\s+reset\s+--hard/i, // git reset --hard
70
70
  // Add your own git safety patterns here
71
71
  ];
@@ -266,7 +266,7 @@ async function main() {
266
266
  // in its own archived handovers as `claude --resume <uuid>`, so the instruction
267
267
  // we ship in every checkpoint could not work.
268
268
  //
269
- // It also completes the incident of that morning: `pai Paperfull` failed to
269
+ // It also completes the incident of that morning: `pai Northwind` failed to
270
270
  // resume b3462801 because of a probe bug, started a fresh session instead, and
271
271
  // THIS hook then moved b3462801 — 867 KB of real work — out of reach. The
272
272
  // failed resume destroyed what it had failed to open.