@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,58 @@
1
+ # Automatic Observation Capture
2
+
3
+ PAI automatically classifies and stores every significant tool call during your sessions. When you edit a file, run a command, or make a decision, PAI captures it as a structured observation — building a searchable timeline of everything you've done across all projects.
4
+
5
+ ## How it works
6
+
7
+ A PostToolUse hook fires after every Claude Code tool call. A rule-based classifier (no AI needed, under 50ms) categorizes each action:
8
+
9
+ | Type | What triggers it | Examples |
10
+ |------|-----------------|----------|
11
+ | **decision** | Git commits, config changes | `git commit`, writing to config files |
12
+ | **bugfix** | Test runs, error investigation | `npm test`, debugging commands |
13
+ | **feature** | New file creation, feature work | Creating components, adding endpoints |
14
+ | **refactor** | Code restructuring | Renaming, moving files, reorganizing |
15
+ | **discovery** | File reads, searches | Reading code, grep searches, glob patterns |
16
+ | **change** | File edits | Editing source files, updating configs |
17
+
18
+ Observations are stored with content-hash deduplication (30-second window) to prevent duplicates from rapid tool calls.
19
+
20
+ ## Progressive context injection
21
+
22
+ At session start, PAI injects recent observations as layered context:
23
+
24
+ 1. **Compact index** (~100 tokens) — observation type counts and active projects
25
+ 2. **Timeline** (~500 tokens) — recent observations with timestamps
26
+ 3. **On-demand** — full details available via MCP tools
27
+
28
+ This means Claude starts every session already knowing what you were working on, without you re-explaining anything.
29
+
30
+ ## Searching observations
31
+
32
+ Ask Claude naturally:
33
+
34
+ ```
35
+ "What changes did I make to the daemon today?"
36
+ "Show me all decisions from the last session"
37
+ "What files did I modify in the PAI project this week?"
38
+ ```
39
+
40
+ Or use the CLI:
41
+
42
+ ```bash
43
+ # List recent observations
44
+ pai observation list
45
+
46
+ # Filter by type
47
+ pai observation list --type decision
48
+
49
+ # Filter by project
50
+ pai observation list --project pai
51
+
52
+ # Show stats
53
+ pai observation stats
54
+ ```
55
+
56
+ ## Session summaries
57
+
58
+ When a session ends, PAI generates a structured summary capturing what was requested, investigated, learned, completed, and what the next steps are. These summaries feed into the progressive context system, giving future sessions a concise picture of past work.
@@ -0,0 +1,42 @@
1
+ # Release History
2
+
3
+ 31 releases shipped from v0.7.2 to v0.10.0 (March 19 – May 21, 2026):
4
+
5
+ | Version | Feature |
6
+ |---------|---------|
7
+ | v0.7.2 | Auto-registration, one-note-per-session, Reconstruct skill |
8
+ | v0.7.3 | Automatic AI-powered session notes via daemon |
9
+ | v0.7.4 | Auto-register on parent match |
10
+ | v0.7.5 | Tiered model selection (opus/sonnet/haiku) |
11
+ | v0.7.6 | Find claude binary in launchd |
12
+ | v0.7.7 | Whisper rules hook |
13
+ | v0.7.8 | Strip API key from daemon (prevent billing) |
14
+ | v0.8.0 | Topic-based note splitting |
15
+ | v0.8.1 | /whisper skill, remove hardcoded defaults |
16
+ | v0.8.2 | Reduce topic split sensitivity |
17
+ | v0.8.3 | /consolidate skill |
18
+ | v0.8.4 | Store TOPIC in HTML comment |
19
+ | v0.8.5 | God-note detection, confidence tagging, Louvain communities, query feedback |
20
+ | v0.9.0 | 4-layer wake-up, temporal KG, taxonomy, tunnels, mid-session auto-save |
21
+ | v0.9.1 | KG backfill CLI, shared kg-extraction module |
22
+ | v0.9.2 | Stop-hook first-run safeguard |
23
+ | v0.9.3 | Silence stop-hook diagnostics |
24
+ | v0.9.4 | Remove exit(2) noise |
25
+ | v0.9.5 | Budget-aware advisor mode |
26
+ | v0.9.6 | Statusline auto-writes budget to advisor |
27
+ | v0.9.7 | Advisor mode label in statusline, natural language mode switching |
28
+ | v0.9.8 | Privacy tags, compact search format, npx install |
29
+ | v0.9.9 | Fix advisor mode to delegate to haiku instead of hoarding in opus |
30
+ | v0.9.10 | Cognee-inspired three-tier memory: entity deduplication, graph-completion search, feedback EMA |
31
+ | v0.9.11 | Session-commands hook for truncation resilience |
32
+ | v0.9.12 | Dispatcher uses openFederation directly for kg_search/feedback |
33
+ | v0.9.13 | Emit chunk IDs in memory_search output |
34
+ | v0.9.14 | AIBroker live-session integration: `pai sessions` shows live iTerm2 panes |
35
+ | v0.9.15 | `pai pause all`: pause every live Claude session at once via AIBroker |
36
+ | v0.9.16 | createHash import fix, registry scan clc fallback map |
37
+ | v0.9.17 | Switch live-session listing to `sessions` IPC (metadata-only, faster); `--all-tabs` flag |
38
+ | v0.9.18 | `pai projects`: moved-project auto-detect, rebind command, active-only default listing |
39
+ | v0.10.0 | Topic-first redesign: `pai <topic>` universal resolver, history search, sticky tab titles |
40
+ | v0.10.1 | `pai sessions clear-names` recovery command |
41
+ | v0.11.0 | Deduped session listing + universal `pai <name>` (switch / resume / fresh) |
42
+ | v0.12.0 | Interactive picker: `pai` opens a modal search-and-act selector over projects + sessions (g go · n new · c cd · f finder · d remove); note-keyword filtering; quoted exit-dir path |
@@ -0,0 +1,37 @@
1
+ # Whisper Rules and Privacy Tags
2
+
3
+ ## Whisper Rules
4
+
5
+ PAI provides a hook that injects user-defined rules into every prompt via `UserPromptSubmit`. Rules survive compaction, `/clear`, and session restarts — they fire on every single turn, making them the most reliable way to enforce behavioral constraints.
6
+
7
+ **PAI ships the mechanism. You provide the rules.** The file `~/.claude/pai/whisper-rules.md` does not exist by default. Use the `/whisper` skill to manage your rules:
8
+
9
+ ```
10
+ /whisper — show current rules
11
+ /whisper add "NEVER send emails" — add a rule
12
+ /whisper remove 3 — remove rule #3
13
+ /whisper list — list with line numbers
14
+ ```
15
+
16
+ Or edit `~/.claude/pai/whisper-rules.md` directly — one rule per line, plain text.
17
+
18
+ **Keep rules focused.** Every rule is injected on every prompt. Too many rules dilute effectiveness and waste tokens. Reserve whisper rules for truly critical constraints that keep getting violated despite being in CLAUDE.md.
19
+
20
+ The pattern is inspired by [Letta's claude-subconscious](https://github.com/letta-ai/claude-subconscious) approach to persistent context injection.
21
+
22
+ ## Privacy Tags
23
+
24
+ Wrap any content in `<private>...</private>` tags to exclude it from PAI's memory index. Private content is stripped before chunking — it's never stored, never searched, never surfaced.
25
+
26
+ ```markdown
27
+ ## API Keys
28
+ <private>
29
+ STRIPE_KEY=sk_live_abc123
30
+ DATABASE_URL=postgres://user:pass@host/db
31
+ </private>
32
+
33
+ ## Architecture Notes
34
+ The payment system uses Stripe webhooks...
35
+ ```
36
+
37
+ The architecture notes get indexed. The API keys don't. Works in session notes, memory files, and any markdown PAI indexes.
package/docs/search.md ADDED
@@ -0,0 +1,169 @@
1
+ # Search
2
+
3
+ ## Token-Efficient Search (3-Layer Pattern)
4
+
5
+ For budget-conscious usage, PAI supports a compact search format that returns ~10x fewer tokens per result. Instead of fetching full snippets upfront, get a compact index first, then drill into interesting results.
6
+
7
+ ### The workflow
8
+
9
+ ```
10
+ 1. Search with format="compact" → IDs + paths + scores (~50 tokens/result)
11
+ 2. Review the index, pick interesting results
12
+ 3. Use memory_get to read full content for those specific files
13
+ ```
14
+
15
+ ### Example
16
+
17
+ ```
18
+ "Search for authentication with compact format"
19
+ → Claude passes format: "compact" to memory_search
20
+ → Gets a tight index: [1] pai — src/auth.ts L10-45 score=0.892
21
+ → Then reads only the files that matter
22
+ ```
23
+
24
+ Via MCP, pass `format: "compact"` to the `memory_search` tool. Default is `"full"` (current behavior with snippets).
25
+
26
+ ### Section-aware retrieval
27
+
28
+ Long notes are chunked at their headings, and every chunk carries its heading path as a first line, for example `[Decisions > Worker routing > Provider choice]`. A search for "routing" therefore finds the paragraph under that sub-section even when the paragraph never uses the word. Headings inside code fences are ignored.
29
+
30
+ For long files, read by section instead of whole:
31
+
32
+ ```
33
+ 1. memory_outline(project, path) → heading tree with line ranges and token estimates
34
+ ## Previous handovers L45-195 ~2361t
35
+ ### Shipped (2026-09-29) L60-66 ~251t
36
+ 2. memory_get(project, path, from=60, lines=7) → just that section
37
+ ```
38
+
39
+ `memory_outline` returns structure only, never text, and takes an optional `max_depth`.
40
+
41
+ When the chunking logic changes, `CHUNKER_VERSION` in `src/memory/chunker.ts` is bumped. It is part of each file's change-detection hash, so the first index pass after an upgrade re-chunks and re-embeds every file once; later passes skip unchanged files as before. On a large index that pass takes hours of local CPU for embeddings, and semantic search misses files until they are re-embedded, so restart the daemon onto a new version at a quiet time.
42
+
43
+ ## Search Intelligence
44
+
45
+ PAI doesn't just store your notes — it understands them. Three search modes work together, with reranking and recency boost on by default. All search settings are configurable.
46
+
47
+ ### Search Modes
48
+
49
+ | Mode | How it works | Best for |
50
+ |------|-------------|----------|
51
+ | **Keyword** | Full-text search (BM25 via SQLite FTS5) | Exact terms, function names, error messages |
52
+ | **Semantic** | Vector similarity (Snowflake Arctic embeddings) | Finding things by meaning, even with different words |
53
+ | **Hybrid** | Keyword + semantic combined, scores normalized and blended | General use — the default |
54
+
55
+ ### Cross-Encoder Reranking
56
+
57
+ Every search automatically runs a second pass: a cross-encoder model reads each (query, result) pair together and re-scores them for relevance. This catches results that keyword or vector search ranked too low.
58
+
59
+ ```bash
60
+ # Search with reranking (default)
61
+ pai memory search "how does session routing work"
62
+
63
+ # Skip reranking for faster results
64
+ pai memory search "how does session routing work" --no-rerank
65
+ ```
66
+
67
+ The reranker uses a small local model (~23 MB) that runs entirely on your machine. First use downloads it automatically. No API keys, no cloud calls.
68
+
69
+ ### Recency Boost
70
+
71
+ Recent content scores higher than older content — on by default with a 90-day half-life. A 3-month-old result retains 50% of its score, a 6-month-old retains 25%, and a year-old retains ~6%.
72
+
73
+ ```bash
74
+ # Search uses recency boost automatically (90-day half-life from config)
75
+ pai memory search "notification system"
76
+
77
+ # Override the half-life for this search
78
+ pai memory search "notification system" --recency 30
79
+
80
+ # Disable recency boost for this search
81
+ pai memory search "notification system" --recency 0
82
+ ```
83
+
84
+ Via MCP, pass `recency_boost: 90` to the `memory_search` tool, or `recency_boost: 0` to disable.
85
+
86
+ Recency boost is applied after cross-encoder reranking, so relevance is scored first, then time-weighted. Scores are normalized before decay so the math works correctly regardless of the underlying score scale.
87
+
88
+ ### Search Settings
89
+
90
+ All search defaults are configurable via `~/.claude/pai/config.json` and can be viewed or changed from the command line.
91
+
92
+ ```bash
93
+ # View all search settings
94
+ pai memory settings
95
+
96
+ # View a single setting
97
+ pai memory settings recencyBoostDays
98
+
99
+ # Change a setting
100
+ pai memory settings recencyBoostDays 60
101
+ pai memory settings mode hybrid
102
+ pai memory settings rerank false
103
+ ```
104
+
105
+ | Setting | Default | Description |
106
+ |---------|---------|-------------|
107
+ | `mode` | `keyword` | Default search mode: `keyword`, `semantic`, or `hybrid` |
108
+ | `rerank` | `true` | Cross-encoder reranking on by default |
109
+ | `recencyBoostDays` | `90` | Recency half-life in days. `0` = off |
110
+ | `defaultLimit` | `10` | Default number of results |
111
+ | `snippetLength` | `200` | Max characters per snippet in MCP results |
112
+
113
+ Settings live in the `search` section of `~/.claude/pai/config.json`. Per-call parameters (CLI flags or MCP tool arguments) always override config defaults.
114
+
115
+ ### Using Search from Within Claude
116
+
117
+ When PAI is configured as an MCP server, Claude uses the `memory_search` tool automatically. You don't need to call it yourself — just ask Claude naturally and it searches your memory behind the scenes.
118
+
119
+ **Example prompts you can give Claude:**
120
+
121
+ ```
122
+ "Search your memory for authentication"
123
+ "What do you know about the database migration?"
124
+ "Find where we discussed the notification system"
125
+ ```
126
+
127
+ Claude calls `memory_search` with the right parameters based on your config defaults. Reranking and recency boost are both active by default — you don't need to configure anything for good results.
128
+
129
+ **Overriding defaults for a specific search:**
130
+
131
+ You can ask Claude to adjust search behavior per-query:
132
+
133
+ ```
134
+ "Search for authentication using semantic mode"
135
+ → Claude passes mode: "semantic"
136
+
137
+ "Search for the old logging discussion without recency boost"
138
+ → Claude passes recency_boost: 0
139
+
140
+ "Search for database schema across all projects with no reranking"
141
+ → Claude passes all_projects: true, rerank: false
142
+ ```
143
+
144
+ **The `memory_search` MCP tool accepts these parameters:**
145
+
146
+ | Parameter | Type | Description |
147
+ |-----------|------|-------------|
148
+ | `query` | string | Free-text search query (required) |
149
+ | `project` | string | Scope to one project by slug |
150
+ | `all_projects` | boolean | Explicitly search all projects |
151
+ | `sources` | array | Restrict to `"memory"` or `"notes"` |
152
+ | `limit` | integer | Max results (1–100, default from config) |
153
+ | `mode` | string | `"keyword"`, `"semantic"`, or `"hybrid"` |
154
+ | `rerank` | boolean | Cross-encoder reranking (default: true from config) |
155
+ | `recency_boost` | integer | Recency half-life in days (0 = off, default from config) |
156
+
157
+ All parameters except `query` are optional. Omitted values fall back to your `~/.claude/pai/config.json` defaults.
158
+
159
+ **Changing defaults permanently:**
160
+
161
+ Tell Claude to change your search settings:
162
+
163
+ ```
164
+ "Set my default search mode to hybrid"
165
+ "Turn off reranking by default"
166
+ "Change the recency boost to 60 days"
167
+ ```
168
+
169
+ Claude runs `pai memory settings <key> <value>` to update `~/.claude/pai/config.json`. Changes take effect on the next search — no restart needed.
@@ -0,0 +1,153 @@
1
+ # Session Management
2
+
3
+ PAI gives you a complete picture of every Claude Code session running on your machine — live tabs in iTerm2, paused snapshots on disk, and everything in between.
4
+
5
+ ## The Core Idea: One Entry Point
6
+
7
+ Two ways in, both forgiving:
8
+
9
+ - **`pai`** (no args) — opens the **interactive picker**: type to search across projects *and* sessions, then act on the highlighted row with a single key.
10
+ - **`pai <name>`** — the universal session command when you already know the name. It does the right thing based on session state:
11
+ - **Live session** — switches the iTerm2 tab to front (no new Claude launched)
12
+ - **Otherwise** — starts a fresh Claude in the project directory, on the configured route. If a resumable transcript exists it asks `Resume it? [y/N]` first (Enter keeps fresh); `--resume` or `pai resume <name>` resume without asking; `-y` skips the question.
13
+ - **No match** — searches `~/.claude/history.jsonl`, shows a candidate picker
14
+
15
+ ```bash
16
+ pai # Interactive picker — search, then go / new / cd / finder / remove
17
+ pai aibroker # Switch to the live AIBroker tab (iTerm comes to front)
18
+ pai youdrill # Fresh youdrill session; offers to resume the last transcript
19
+ pai mdf # Free-text search across your prompt history
20
+ pai 0856d40b # Resume by UUID prefix
21
+ pai --list # Static deduped table (the old no-args behaviour)
22
+ ```
23
+
24
+ ## Daily Commands
25
+
26
+ ```bash
27
+ pai # Interactive picker (projects + sessions; search then act)
28
+ pai --list # Static deduped listing (one row per name)
29
+ pai <name> # Switch / resume / fresh — universal
30
+ pai pause # Save state checkpoint (write ## Continue to TODO.md)
31
+ pai pause all # Pause every live Claude session at once
32
+ pai end # Finalize: save state + mark session note Completed
33
+ ```
34
+
35
+ And inside Claude Code, the two slash commands that matter:
36
+
37
+ ```
38
+ /pause → write checkpoint to TODO.md, print handoff block, then type /exit
39
+ /end → same as /pause, plus marks the session note Completed
40
+ ```
41
+
42
+ ## The Interactive Picker
43
+
44
+ Run `pai` with no arguments to open a self-contained terminal selector (no `fzf` or other dependency) over a **unified, deduped list of both projects and sessions** — tagged so the two stay distinct. It's the one place to answer "where did I work on X, and take me there."
45
+
46
+ ```
47
+ pai — find a project or session
48
+ search > samba
49
+
50
+ live Chenarlier now …/Raspi/Chenarlier samba setup monster reverse proxy
51
+ project Glidr 2d …/apps/glidr claude pai research
52
+
53
+ ────────────────────────────────────────
54
+ Chenarlier ~/…/Raspi/Chenarlier
55
+ recent notes:
56
+ 10 - Samba Setup/01 - Samba Server Setup.md 1mo
57
+ 00 - Monster/00 - Monster.md 3mo
58
+ ────────────────────────────────────────
59
+ g go to tab · n new · c cd · f finder · d remove · s search · ↑↓ move · q quit
60
+ ```
61
+
62
+ **Two modes.** You start in *command mode* (single keys are actions). Press `s` (or `/`) to enter *search mode* (type a topic — it filters by name, path, **and folded-in note file/folder names**, so `samba` finds a project literally named "Chenarlier"); `Enter` or `esc` returns to command mode.
63
+
64
+ **Command keys** act immediately on the highlighted row:
65
+
66
+ | Key | Action |
67
+ |-----|--------|
68
+ | `g` | **Go to** the running iTerm2 tab (for live rows) |
69
+ | `n` | **New** Claude session in that directory (current terminal) |
70
+ | `c` | **cd** into the folder only — no Claude (your shell stays there) |
71
+ | `f` | Open the folder in **Finder** / Explorer / `xdg-open` (keeps the picker open) |
72
+ | `d` | **Remove** from PAI's list — archives the project (reversible, files untouched); asks `y/N` first |
73
+ | `s` `/` | Enter **search** mode |
74
+ | `↑↓` `j` `k` | Move the highlight |
75
+ | `q` `esc` | Quit |
76
+
77
+ `Enter` on a row takes the smart default: a live row → go to its tab, otherwise → new session.
78
+
79
+ The `c` (cd) action needs PAI's shell integration to change your shell's directory — see [Finding the Claude Binary](#finding-the-claude-binary) / `pai shell-init`. On a non-interactive terminal (piped output), `pai` falls back to the static listing automatically.
80
+
81
+ ## Static Listing
82
+
83
+ `pai --list` shows a single deduped table — one row per session name, regardless of how many snapshots exist on disk:
84
+
85
+ ```
86
+ Sessions:
87
+
88
+ # name status age project last prompt
89
+ -- ---------- ---------- -------- ---------------------------- --------------------------
90
+ 1 AIBroker live now — —
91
+ 2 PAI resumable 2m ago /…dev/ai/PAI "refactor session listing…"
92
+ 3 MDF transcript 3d ago /…MDF/Infrastruktur/Webseiten "ok so we recently had…"
93
+ ```
94
+
95
+ Status values: `live` (active iTerm tab), `resumable` (clean snapshot on disk), `transcript` (history available, not resumable), `stub` (empty or minimal).
96
+
97
+ ## Finding Sessions by Topic
98
+
99
+ `pai <topic>` first checks session names, then falls back to searching your prompt history:
100
+
101
+ ```
102
+ Sessions matching "mdf":
103
+
104
+ # id when project last matching prompt
105
+ - -------- ---------------- ----------------------------------- -------------------------
106
+ 1 6269cf64 2026-05-21 08:20 /…MDF/Infrastruktur/20 - Webseiten "ok so we recently had an order…"
107
+ 2 abe2d977 2026-02-23 08:40 /…MDF/Infrastruktur/20 - Webseiten "yes the session notes for Whazaa…"
108
+
109
+ Enter # to launch (1-2), or press Enter to cancel:
110
+ ```
111
+
112
+ Use `pai <topic> --auto` (or `-y`) to auto-pick #1. Use `pai <topic> 2` to pick directly.
113
+
114
+ ## Power User Access
115
+
116
+ The full session management namespace is still available:
117
+
118
+ ```bash
119
+ pai sessions # Live + disk listing (with more columns)
120
+ pai sessions --all # Include unnamed orphan sessions
121
+ pai sessions --all-tabs # Include shell tabs in the live section
122
+ pai sessions goto <name> # Named-session resolver (same as pai <name>)
123
+ pai sessions list # Explicit listing (same as pai sessions)
124
+ ```
125
+
126
+ ## Pausing All Sessions at Once
127
+
128
+ When you're done for the day and have multiple Claude windows open:
129
+
130
+ ```bash
131
+ pai pause all # send "pause session" to every live Claude pane
132
+ pai pause all --dry-run # preview what would be sent
133
+ pai pause all --exit # also send /exit after each session saves state
134
+ ```
135
+
136
+ AIBroker must be running for this to work. Shell tabs (bare zsh, SSH panes) are automatically skipped — only Claude Code panes receive the pause command. The count of skipped tabs is printed to stderr.
137
+
138
+ ## /pause and /end Inside Claude Code
139
+
140
+ Type `/pause` or `/end` from inside an active Claude Code session (not from a shell — these are Claude Code slash commands, not CLI commands):
141
+
142
+ - `/pause` — Claude writes a `## Continue` block to the project's `TODO.md`, prints a handoff summary with the session ID, then tells you to type `/exit`. The next session starts by reading that TODO.md block and picking up exactly where you left off.
143
+ - `/end` — Same as `/pause`, plus Claude marks the session note as Completed and writes a final summary. Use this when you're genuinely done with a topic, not just pausing mid-task.
144
+
145
+ After either command, type `/exit` to exit Claude Code cleanly.
146
+
147
+ ## Why /exit and Not Ctrl+C
148
+
149
+ Ctrl+C or closing the terminal kills the Claude Code process abruptly. The session note generation hook never fires, the checkpoint is not written, and the session cannot be resumed with `claude --resume`.
150
+
151
+ `/exit` sends a clean shutdown signal. Claude Code runs its Stop and Session End hooks, which trigger PAI to write the session note, push the final summary to the daemon, and save a resumable snapshot. The difference in recovery quality between a clean `/exit` and a Ctrl+C is significant for long sessions.
152
+
153
+ If you do accidentally close a terminal, use `pai sessions --all` to find the orphaned transcript. The `/reconstruct` skill can retroactively generate a session note from it.
@@ -0,0 +1,64 @@
1
+ # Automatic Session Notes
2
+
3
+ ## Automatic Session Notes — by Topic
4
+
5
+ PAI's headline feature: **every session is automatically documented.** No manual note-taking, no "pause session" commands, no forgetting to save what you did.
6
+
7
+ When you work, a background daemon watches your session **continuously**. Every time Claude's context compacts — which happens automatically as the conversation grows — the daemon reads the JSONL transcript, combines it with your git history, and spawns a headless Claude process to write a structured session note. Not just at session end. Midway through your work, while you're still coding. The notes build up in real time as you go — what was built, what decisions were made, what problems were hit, what's left to do.
8
+
9
+ **When you change topics mid-session, PAI creates a new note.** If you start the day debugging audio, then pivot to a Flutter rewrite, you get two notes — not one giant file mixing unrelated work:
10
+
11
+ ```
12
+ Notes/2026/03/
13
+ 0001 - 2026-03-23 - Phase 1 Research and Architecture.md
14
+ 0002 - 2026-03-24 - Background Audio and iOS Conflicts.md
15
+ 0003 - 2026-03-24 - Flutter Rewrite with Whisper.md ← auto-split, same day
16
+ ```
17
+
18
+ Topic detection uses Jaccard word similarity between the new summary's topic and the existing note's title. Below 30% overlap = new note.
19
+
20
+ **Model tiering:** Opus for final session summaries (best quality, runs once). Sonnet for mid-session checkpoints (good quality, runs on compaction). All using your Max plan — no API charges.
21
+
22
+ This is not a template or a skeleton. These are real notes with build error chronologies, architectural decisions with rationale, code snippets, and "what was tried and failed" sections. The kind of notes you'd write yourself if you had time.
23
+
24
+ ## Automatic Session Notes
25
+
26
+ PAI automatically writes structured session notes after every session ends — no manual journaling required. The daemon spawns a headless Claude CLI process (using your Max plan, not the API) to summarize the JSONL conversation transcript combined with recent git history.
27
+
28
+ ### What Gets Generated
29
+
30
+ Each session note contains:
31
+
32
+ - **Work Done** — concrete description of what was accomplished
33
+ - **Key Decisions** — choices made and their rationale
34
+ - **Known Issues** — bugs found, blockers, or open questions
35
+ - **Next Steps** — where to pick up in the next session
36
+
37
+ The summarizer uses tiered model selection based on the trigger:
38
+
39
+ | Trigger | Model | Timeout | JSONL Limit |
40
+ |---------|-------|---------|-------------|
41
+ | Session end (Stop hook) | Opus | 5 minutes | 500K bytes |
42
+ | Auto-compaction (PreCompact hook) | Sonnet | 2 minutes | 200K bytes |
43
+
44
+ ### Topic-Based Note Splitting
45
+
46
+ When a session covers multiple distinct topics, PAI creates separate notes rather than one long note for the whole session. The summarizer outputs a `TOPIC:` line describing the subject of the current work. PAI compares this against the existing note title using Jaccard word similarity — when similarity falls below 30%, a new note is created automatically.
47
+
48
+ Notes within the same day are numbered sequentially: `0042 - 2026-03-24 - Session Name.md`, `0043 - 2026-03-24 - Different Topic.md`, and so on.
49
+
50
+ ### One Note Per Session
51
+
52
+ Each compaction within a session updates the existing note rather than creating a new one. The 30-minute cooldown between summaries prevents redundant updates. Stop hook triggers bypass the cooldown with a force flag to ensure the final state is always captured.
53
+
54
+ ### Garbage Title Filter
55
+
56
+ Session note titles are validated before creation. Over 20 patterns are rejected, including: task notification strings, `[object Object]`, hex hashes, bare numbers, and other non-descriptive artifacts that can appear in session transcripts. Titles must describe actual work done and are capped at 60 characters.
57
+
58
+ ### Finding the Claude Binary
59
+
60
+ The daemon runs under launchd with a minimal PATH that does not include `~/.local/bin/`. PAI resolves the Claude CLI binary by checking `~/.local/bin/claude` first, then falling back to PATH lookup, before spawning headless summarization processes.
61
+
62
+ ### Stripping the API Key
63
+
64
+ When spawning headless Claude CLI processes for summarization, the daemon strips `ANTHROPIC_API_KEY` from the subprocess environment. This forces the spawned process to authenticate via your Max plan (free) rather than using the API key (billable). Without this, every automatic session note would incur API charges.
package/docs/skills.md ADDED
@@ -0,0 +1,45 @@
1
+ # Skills
2
+
3
+ PAI ships 22 skills — slash commands that activate specialized workflows. Each responds to natural language triggers as well as the `/command` syntax.
4
+
5
+ ## Productivity
6
+
7
+ | Skill | Trigger | What it does |
8
+ |-------|---------|-------------|
9
+ | `/advisor` | "budget mode", "save budget", "go easy on the budget" | Manage budget-aware model tiering for subagents |
10
+ | `/plan` | "plan my week", "what should I focus on", "priorities" | Plan tomorrow/week/month based on open tasks and calendar |
11
+ | `/review` | "review my week", "what did I do", "recap" | Daily/weekly/monthly review of work accomplished |
12
+ | `/journal` | "journal", "note to self", "capture this thought" | Create, read, or search personal journal entries |
13
+ | `/share` | "share on LinkedIn", "tweet about", "post to Bluesky" | Generate social media posts about completed work |
14
+
15
+ ## Session Management
16
+
17
+ | Skill | Trigger | What it does |
18
+ |-------|---------|-------------|
19
+ | `/sessions` | "list sessions", "where was I working" | Navigate sessions, projects, switch working context |
20
+ | `/route` | "what project is this", "tag this session" | Detect which PAI project the current session belongs to |
21
+ | `/name` | "name this session", "rename session" | Name or rename the current session |
22
+ | `/search-history` | "search history", "find past", "what did we do" | Search past sessions and previous work by keyword |
23
+ | `/consolidate` | "consolidate notes", "clean up notes", "merge duplicates" | Merge duplicate session notes, fix titles, renumber |
24
+ | `/reconstruct` | "reconstruct sessions", "backfill session notes" | Retroactively create notes from JSONL transcripts and git history |
25
+
26
+ ## Obsidian Vault
27
+
28
+ | Skill | Trigger | What it does |
29
+ |-------|---------|-------------|
30
+ | `/vault-context` | "morning briefing", "load vault context" | Load Obsidian vault context for a briefing |
31
+ | `/vault-connect` | "connect X and Y", "how does X relate to Y" | Find connections between two topics in the vault |
32
+ | `/vault-emerge` | "what's emerging", "find patterns", "themes in vault" | Surface emerging themes and clusters |
33
+ | `/vault-orphans` | "find orphans", "unlinked notes" | Find and reconnect orphaned notes with zero inbound links |
34
+ | `/vault-trace` | "trace idea", "how did X evolve", "idea history" | Trace the evolution of an idea across vault notes over time |
35
+
36
+ ## Tools & System
37
+
38
+ | Skill | Trigger | What it does |
39
+ |-------|---------|-------------|
40
+ | `/whisper` | "add whisper rule", "show whisper rules" | Manage persistent behavioral constraints injected on every prompt |
41
+ | `/research` | "do research", "extract wisdom", "analyze content" | Web research, content extraction, and analysis via parallel agents |
42
+ | `/art` | "create diagram", "flowchart", "visualize" | Create visual content, diagrams, flowcharts, and AI-generated images |
43
+ | `/story` | "explain this as a story", "create story explanation" | Create numbered narrative story explanations of any content |
44
+ | `/observability` | "start observability", "monitor agents" | Start, stop, or check the multi-agent observability dashboard |
45
+ | `/createskill` | "create skill", "validate skill" | Create, validate, update, or canonicalize a PAI skill |
package/docs/task-bus.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  File a task from your phone. A session picks it up, does the work, and ticks it off.
4
4
 
5
- This document is the setup guide. For why the design splits the way it does, see
6
- `Notes/docs/task-bus.md`.
5
+ This document is the setup guide.
7
6
 
8
7
  ---
9
8