@tekmidian/pai 0.65.0 → 0.65.2
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/README.md +60 -1065
- package/dist/{async-CNn36gm4.mjs → async-C2Bm_Lal.mjs} +2 -2
- package/dist/{async-CNn36gm4.mjs.map → async-C2Bm_Lal.mjs.map} +1 -1
- package/dist/{auto-route-sLMU-NnM.mjs → auto-route-o0BOsXn7.mjs} +2 -2
- package/dist/{auto-route-sLMU-NnM.mjs.map → auto-route-o0BOsXn7.mjs.map} +1 -1
- package/dist/{chain-C8QO8gwj.mjs → chain-CT3SI-3z.mjs} +2 -2
- package/dist/{chain-C8QO8gwj.mjs.map → chain-CT3SI-3z.mjs.map} +1 -1
- package/dist/cli/index.mjs +12 -10
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/program.mjs +10 -10
- package/dist/{clusters-PgIUYT_v.mjs → clusters-BCtD3fbe.mjs} +1 -1
- package/dist/{clusters-PgIUYT_v.mjs.map → clusters-BCtD3fbe.mjs.map} +1 -1
- package/dist/config-BbLFD7Uf.mjs.map +1 -1
- package/dist/{context-handover-cache-mGxq2-8f.mjs → context-handover-cache-CRSFdkNi.mjs} +2 -2
- package/dist/{context-handover-cache-mGxq2-8f.mjs.map → context-handover-cache-CRSFdkNi.mjs.map} +1 -1
- package/dist/daemon/index.mjs +12 -10
- package/dist/daemon/index.mjs.map +1 -1
- package/dist/daemon-DoTVK9z6.mjs +19 -0
- package/dist/{daemon-D2r1AQqE.mjs → daemon-SaPnmoyg.mjs} +23 -23
- package/dist/{daemon-D2r1AQqE.mjs.map → daemon-SaPnmoyg.mjs.map} +1 -1
- package/dist/daemon-mcp/index.mjs +7 -5
- package/dist/daemon-mcp/index.mjs.map +1 -1
- package/dist/detector-BEPFsINR.mjs +3 -0
- package/dist/{detector-CIHEXKsV.mjs → detector-BRTtAWrM.mjs} +1 -1
- package/dist/{detector-CIHEXKsV.mjs.map → detector-BRTtAWrM.mjs.map} +1 -1
- package/dist/{embeddings-BbNVXa_0.mjs → embeddings-Bx3q0QOY.mjs} +1 -1
- package/dist/{embeddings-BbNVXa_0.mjs.map → embeddings-Bx3q0QOY.mjs.map} +1 -1
- package/dist/{embeddings-CDfM63uC.mjs → embeddings-CcscYWwk.mjs} +1 -1
- package/dist/env-JNEIrQWg.mjs +14 -0
- package/dist/env-JNEIrQWg.mjs.map +1 -0
- package/dist/{factory-y36qGegI.mjs → factory-CNpPQQ-5.mjs} +7 -7
- package/dist/{factory-y36qGegI.mjs.map → factory-CNpPQQ-5.mjs.map} +1 -1
- package/dist/{factory-CaswxuJ0.mjs → factory-DY7x73mE.mjs} +1 -1
- package/dist/{fallback-CWDQYmJi.mjs → fallback-vHjFZP0Y.mjs} +2 -2
- package/dist/{fallback-CWDQYmJi.mjs.map → fallback-vHjFZP0Y.mjs.map} +1 -1
- package/dist/hooks/block-sleep-poll.mjs.map +1 -1
- package/dist/hooks/context-compression-hook.mjs.map +1 -1
- package/dist/hooks/load-project-context.mjs.map +2 -2
- package/dist/hooks/post-compact-inject.mjs.map +1 -1
- package/dist/hooks/route-agents-to-worker.mjs.map +1 -1
- package/dist/hooks/security-validator.mjs +2 -2
- package/dist/hooks/security-validator.mjs.map +1 -1
- package/dist/hooks/whisper-rules.mjs.map +1 -1
- package/dist/hooks/worker-guard.mjs.map +1 -1
- package/dist/hooks/worker-proxy.mjs.map +1 -1
- package/dist/hooks/worker-status-line.mjs.map +2 -2
- package/dist/hooks/worker-supervision.mjs.map +1 -1
- package/dist/{indexer-backend-Cnc7Tf5C.mjs → indexer-backend-DFF2FrYx.mjs} +1 -1
- package/dist/{kg-entity-COTUj1ZC.mjs → kg-entity-DCOcsVFD.mjs} +1 -1
- package/dist/{kg-entity-COTUj1ZC.mjs.map → kg-entity-DCOcsVFD.mjs.map} +1 -1
- package/dist/{latent-ideas-ByvMjVcb.mjs → latent-ideas-wwAXquGe.mjs} +3 -3
- package/dist/{latent-ideas-ByvMjVcb.mjs.map → latent-ideas-wwAXquGe.mjs.map} +1 -1
- package/dist/{link-boost-UiE-uooT.mjs → link-boost-CnI7UVMJ.mjs} +1 -1
- package/dist/{link-boost-UiE-uooT.mjs.map → link-boost-CnI7UVMJ.mjs.map} +1 -1
- package/dist/{main-resolver-CDe7DCso.mjs → main-resolver-CKNGux1B.mjs} +8 -8
- package/dist/{main-resolver-CDe7DCso.mjs.map → main-resolver-CKNGux1B.mjs.map} +1 -1
- package/dist/{main-resolver-DI-A7lSO.mjs → main-resolver-VSM5ytnA.mjs} +1 -1
- package/dist/{neighborhood-CvRHlqdR.mjs → neighborhood-2FsmzoxG.mjs} +2 -2
- package/dist/{neighborhood-CvRHlqdR.mjs.map → neighborhood-2FsmzoxG.mjs.map} +1 -1
- package/dist/{note-context-BrbfUIoP.mjs → note-context-De63k8na.mjs} +1 -1
- package/dist/{note-context-BrbfUIoP.mjs.map → note-context-De63k8na.mjs.map} +1 -1
- package/dist/{planner-8-shIa8t.mjs → planner-Dzs9-8AS.mjs} +4 -4
- package/dist/{planner-8-shIa8t.mjs.map → planner-Dzs9-8AS.mjs.map} +1 -1
- package/dist/{postgres-DYtZg7J7.mjs → postgres-Ceqsa64C.mjs} +3 -3
- package/dist/{postgres-DYtZg7J7.mjs.map → postgres-Ceqsa64C.mjs.map} +1 -1
- package/dist/{program-DiktbiWa.mjs → program-DK0mRRlf.mjs} +81 -59
- package/dist/program-DK0mRRlf.mjs.map +1 -0
- package/dist/{registry-postgres-DSrkxqfF.mjs → registry-postgres-nOfyBSIW.mjs} +1 -1
- package/dist/{registry-postgres-DSrkxqfF.mjs.map → registry-postgres-nOfyBSIW.mjs.map} +1 -1
- package/dist/{registry-sqlite-B2436JgX.mjs → registry-sqlite-DrCW1aRK.mjs} +1 -1
- package/dist/{registry-sqlite-B2436JgX.mjs.map → registry-sqlite-DrCW1aRK.mjs.map} +1 -1
- package/dist/router-CXUGsv85.mjs +3 -0
- package/dist/{router-aqLMvNMg.mjs → router-a5G7q8_3.mjs} +1 -1
- package/dist/{router-aqLMvNMg.mjs.map → router-a5G7q8_3.mjs.map} +1 -1
- package/dist/{run-DUZRSnIT.mjs → run-DMaCpvMW.mjs} +23 -5
- package/dist/run-DMaCpvMW.mjs.map +1 -0
- package/dist/{session-keepalive-CZUwp5IQ.mjs → session-keepalive-DVZ9-7qg.mjs} +2 -2
- package/dist/{session-keepalive-CZUwp5IQ.mjs.map → session-keepalive-DVZ9-7qg.mjs.map} +1 -1
- package/dist/skills/Tasks/SKILL.md +1 -1
- package/dist/{sources-DX4ElmrE.mjs → sources-CijVso3n.mjs} +1 -1
- package/dist/{sources-DX4ElmrE.mjs.map → sources-CijVso3n.mjs.map} +1 -1
- package/dist/{sqlite-BrEu3avy.mjs → sqlite-CqsTy6xo.mjs} +3 -3
- package/dist/{sqlite-BrEu3avy.mjs.map → sqlite-CqsTy6xo.mjs.map} +1 -1
- package/dist/{themes-BgqahYVM.mjs → themes-CTaOj3e1.mjs} +2 -2
- package/dist/{themes-BgqahYVM.mjs.map → themes-CTaOj3e1.mjs.map} +1 -1
- package/dist/{tools-gMGDIpJ9.mjs → tools-BcOKPBtg.mjs} +16 -16
- package/dist/{tools-gMGDIpJ9.mjs.map → tools-BcOKPBtg.mjs.map} +1 -1
- package/dist/{tools-BbqQIHPe.mjs → tools-C-_l0o8Z.mjs} +4 -4
- package/dist/{trace-CmAB7iJZ.mjs → trace-CtV0RO6n.mjs} +1 -1
- package/dist/{trace-CmAB7iJZ.mjs.map → trace-CtV0RO6n.mjs.map} +1 -1
- package/dist/{vault-indexer-Ddq51X20.mjs → vault-indexer-BG1sEVyM.mjs} +1 -1
- package/dist/{vault-indexer-Ddq51X20.mjs.map → vault-indexer-BG1sEVyM.mjs.map} +1 -1
- package/dist/{wakeup-CZw88uXf.mjs → wakeup-D8n33hYV.mjs} +2 -2
- package/dist/{wakeup-CZw88uXf.mjs.map → wakeup-D8n33hYV.mjs.map} +1 -1
- package/dist/{work-queue-worker-Taba_vcA.mjs → work-queue-worker-D7GHuj2I.mjs} +3 -3
- package/dist/{work-queue-worker-DCzfH0d1.mjs → work-queue-worker-DZiEMvBQ.mjs} +3 -3
- package/dist/{work-queue-worker-DCzfH0d1.mjs.map → work-queue-worker-DZiEMvBQ.mjs.map} +1 -1
- package/dist/{zettelkasten-Dwj67e4p.mjs → zettelkasten-CtGHQWPU.mjs} +3 -3
- package/dist/{zettelkasten-Dwj67e4p.mjs.map → zettelkasten-CtGHQWPU.mjs.map} +1 -1
- package/docs/auto-compact.md +31 -0
- package/docs/budget-advisor.md +48 -0
- package/docs/command-reference.md +25 -0
- package/docs/companion-projects.md +9 -0
- package/docs/context-preservation.md +43 -0
- package/docs/how-it-works.md +25 -0
- package/docs/install-linux.md +32 -0
- package/docs/install.md +56 -0
- package/docs/memory.md +96 -0
- package/docs/observations.md +58 -0
- package/docs/release-history.md +42 -0
- package/docs/rules-and-privacy.md +37 -0
- package/docs/search.md +169 -0
- package/docs/session-management.md +153 -0
- package/docs/session-notes.md +64 -0
- package/docs/skills.md +45 -0
- package/docs/task-bus.md +1 -2
- package/docs/use-cases.md +194 -0
- package/docs/what-you-can-ask.md +78 -0
- package/docs/worker-providers.md +58 -0
- package/docs/zettelkasten.md +37 -0
- package/package.json +1 -1
- package/plugins/productivity/skills/Tasks/SKILL.md +1 -1
- package/src/hooks/ts/pre-tool-use/security-validator.test.ts +23 -0
- package/src/hooks/ts/pre-tool-use/security-validator.ts +1 -1
- package/src/hooks/ts/session-start/load-project-context.ts +1 -1
- package/statusline-command.sh +1 -1
- package/dist/daemon-CX9JomIJ.mjs +0 -19
- package/dist/detector-C3Q7mxQU.mjs +0 -3
- package/dist/program-DiktbiWa.mjs.map +0 -1
- package/dist/router-S6C5BxzZ.mjs +0 -3
- package/dist/run-DUZRSnIT.mjs.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Linux, from zero (Ubuntu)
|
|
2
|
+
|
|
3
|
+
Both paths below were run end to end on a fresh Ubuntu 26.04 (arm64) install: setup, daemon, statusline in Claude Code, and a real `pai worker run`.
|
|
4
|
+
|
|
5
|
+
Prerequisite: Claude Code installed.
|
|
6
|
+
|
|
7
|
+
Common start:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
sudo apt install -y nodejs npm tmux
|
|
11
|
+
npm config set prefix ~/.npm-global && export PATH="$HOME/.npm-global/bin:$PATH" # global npm installs without sudo
|
|
12
|
+
npm i -g @tekmidian/pai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Keyword search only (SQLite, no Docker):**
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pai setup --yes --storage sqlite
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Keyword and semantic search (PostgreSQL + pgvector in Docker):**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
sudo apt install -y docker.io docker-compose-v2
|
|
25
|
+
sudo usermod -aG docker "$USER" # then log out and in, or prefix the next command with: sg docker -c "…"
|
|
26
|
+
export PAI_PG_SHARED_BUFFERS=256MB # only on small machines; the default 1GB must fit in RAM
|
|
27
|
+
pai setup --yes --storage postgres
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Setup starts the `pai-pgvector` container itself (`pgvector/pgvector:pg17`, bound to 127.0.0.1:5432, data in `~/.pai/pgdata`). The daemon waits for the database, so the first start of the container can take its time.
|
|
31
|
+
|
|
32
|
+
Either way, setup skips macOS-only steps, installs the daemon as a systemd user unit, and turns workers on with the built-in `anthropic` provider. Inside tmux, `pai worker run` opens its follow pane as a tmux split; elsewhere use `pai worker follow <id>`. Setup also enables systemd linger itself so the daemon survives logout, and prints the `sudo loginctl enable-linger` command if the system does not allow it. Where systemd is absent (containers), run the daemon with `pai daemon serve`.
|
package/docs/install.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Install
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
Tell Claude Code:
|
|
6
|
+
|
|
7
|
+
> Clone https://github.com/mnott/PAI and set it up for me
|
|
8
|
+
|
|
9
|
+
Or install with a single command:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @tekmidian/pai install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or manually:
|
|
16
|
+
|
|
17
|
+
### 1. Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/mnott/PAI
|
|
21
|
+
cd PAI
|
|
22
|
+
bun install
|
|
23
|
+
bun run build
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 2. Run the setup wizard
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pai setup # interactive
|
|
30
|
+
pai setup --yes # unattended: every prompt takes its default
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The wizard walks you through: storage mode (SQLite or PostgreSQL), project directories, Obsidian vault path, MCP server registration, CLAUDE.md template, and daemon configuration. It's idempotent — safe to re-run anytime.
|
|
34
|
+
|
|
35
|
+
On Linux, follow [Linux, from zero (Ubuntu)](install-linux.md): it covers the native Claude installer, both storage paths (SQLite, PostgreSQL + pgvector in Docker) and the systemd daemon.
|
|
36
|
+
|
|
37
|
+
### 3. The daemon
|
|
38
|
+
|
|
39
|
+
Setup installs and starts it. To manage it:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pai daemon status # running? which storage?
|
|
43
|
+
pai daemon restart
|
|
44
|
+
pai daemon install # re-create the launchd (macOS) or systemd (Linux) service
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The daemon runs in the background via launchd (macOS) or a systemd user unit (Linux), indexing your sessions and serving the MCP tools. It starts automatically on login.
|
|
48
|
+
|
|
49
|
+
### 4. Verify
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pai daemon status # should show "running"
|
|
53
|
+
pai memory search "test" # should return results after indexing
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That's it. Claude Code now has persistent memory across all sessions.
|
package/docs/memory.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Memory
|
|
2
|
+
|
|
3
|
+
## Progressive Memory Loading
|
|
4
|
+
|
|
5
|
+
PAI loads context in layers at session start rather than all at once. This keeps early-session latency low while giving Claude everything it needs to be useful immediately.
|
|
6
|
+
|
|
7
|
+
### The Four Layers
|
|
8
|
+
|
|
9
|
+
| Layer | What it loads | When |
|
|
10
|
+
|-------|---------------|------|
|
|
11
|
+
| **L0 — Identity** | Your identity file (`~/.pai/identity.txt`) — who you are, your working style, key preferences | Always, at every session start |
|
|
12
|
+
| **L1 — Essential story** | Summaries from the most recent session notes — what you were doing, what decisions were made, where things stand | Always, at session start |
|
|
13
|
+
| **L2 — Topic queries** | On-demand retrieval for the current topic — fetched when a specific question or task is identified | On demand, during the session |
|
|
14
|
+
| **L3 — Deep search** | Full `memory_search` across all indexed content — for when L2 is not enough | On demand, when explicitly needed |
|
|
15
|
+
|
|
16
|
+
L0 and L1 fire automatically via the `memory_wakeup` MCP tool, which is called by the `SessionStart` hook. L2 and L3 are invoked as needed — the model decides when to go deeper based on the question at hand.
|
|
17
|
+
|
|
18
|
+
### Configuring Your Identity File
|
|
19
|
+
|
|
20
|
+
Create `~/.pai/identity.txt` with a short description of yourself and your working style. Claude will see this at every session start. Example:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Principal engineer. Work across TypeScript, Dart, and shell scripting.
|
|
24
|
+
Projects: PAI (AI infrastructure), RingsADay (Flutter app), Scribe (MCP server).
|
|
25
|
+
Prefer concise explanations, hate unnecessary hedging.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Advanced Memory Tools
|
|
29
|
+
|
|
30
|
+
### Temporal Knowledge Graph
|
|
31
|
+
|
|
32
|
+
Facts change over time. The `kg_triples` table stores knowledge as subject-predicate-object triples with `valid_from` and `valid_to` timestamps, so facts can expire and contradict each other rather than accumulating in an undated blob.
|
|
33
|
+
|
|
34
|
+
Four MCP tools cover the full lifecycle:
|
|
35
|
+
|
|
36
|
+
- `kg_add` — Add a fact with a start date (and optional end date)
|
|
37
|
+
- `kg_query` — Query the graph, filtered to facts valid at a given point in time
|
|
38
|
+
- `kg_invalidate` — Mark a fact as no longer true (sets `valid_to`)
|
|
39
|
+
- `kg_contradictions` — Surface facts that directly contradict each other, using predicate inversion rules
|
|
40
|
+
|
|
41
|
+
Example: "the user prefers PostgreSQL" added in March; "the user prefers SQLite" added in April with the March fact invalidated. `kg_query` in April sees only the current fact; `kg_query` for March sees the historical one.
|
|
42
|
+
|
|
43
|
+
### Memory Taxonomy
|
|
44
|
+
|
|
45
|
+
`memory_taxonomy` gives a shape-of-memory overview: projects, session counts, chunk counts, embedding coverage, and recent activity. Think of it as a dashboard for your knowledge base — useful both for the model (to understand what it knows) and for you (to audit what is indexed).
|
|
46
|
+
|
|
47
|
+
### Cross-Project Tunnels
|
|
48
|
+
|
|
49
|
+
`memory_tunnels` detects concepts that appear across multiple projects. It works by comparing FTS vocabulary in SQLite mode or `ts_stat` output in PostgreSQL mode. When a concept — a library name, a design pattern, a person's name — shows up in three separate projects, PAI surfaces that connection as a tunnel.
|
|
50
|
+
|
|
51
|
+
This reveals unexpected intellectual bridges: the same concurrency pattern used in PAI's daemon showing up in your Flutter app's state management, or a vendor name appearing in both your notes and your job applications.
|
|
52
|
+
|
|
53
|
+
## Memory Architecture
|
|
54
|
+
|
|
55
|
+
PAI's memory system uses a three-tier hybrid store inspired by Cognee's approach to knowledge graphs and retrieval. Each tier has a distinct role, and they work together to answer queries that no single store could handle alone.
|
|
56
|
+
|
|
57
|
+
### Three-Tier Hybrid Store
|
|
58
|
+
|
|
59
|
+
| Tier | Backend | What it stores |
|
|
60
|
+
|------|---------|----------------|
|
|
61
|
+
| **Chunks + entities** | SQLite (simple mode) or PostgreSQL (full mode) | Text chunks with embeddings; named entity records with content-address hashes |
|
|
62
|
+
| **Knowledge graph** | PostgreSQL (`kg_triples`) | Subject-predicate-object triples with `valid_from`/`valid_to` timestamps |
|
|
63
|
+
| **Vector embeddings** | pgvector (full mode) | 768-dimensional Snowflake Arctic embeddings on chunks and vault notes |
|
|
64
|
+
|
|
65
|
+
### Entity Deduplication via Content-Address Hashing
|
|
66
|
+
|
|
67
|
+
Named entities (people, projects, libraries, concepts) extracted during indexing are stored in a `kg_entities` table and deduplicated using a content-address hash derived from the entity's canonical name. Two mentions of "PostgreSQL" in different session notes resolve to a single entity row — the hash acts as a stable identity, so the graph stays normalized even as new content is indexed.
|
|
68
|
+
|
|
69
|
+
### Graph-Completion Search Pipeline
|
|
70
|
+
|
|
71
|
+
Standard vector search finds semantically similar chunks. Graph-completion search goes further:
|
|
72
|
+
|
|
73
|
+
1. **Vector seeds** — a semantic search returns the top-K most relevant chunks.
|
|
74
|
+
2. **Graph traversal** — the entities mentioned in those chunks are looked up in `kg_triples`; their immediate neighbors are fetched (one hop).
|
|
75
|
+
3. **Candidate expansion** — the neighbor entities' associated chunks are added to the result set.
|
|
76
|
+
4. **Re-rank** — the expanded candidate set is re-scored by the cross-encoder, which reads each (query, result) pair together. Results are sorted by this final relevance score.
|
|
77
|
+
|
|
78
|
+
This means a query about "the PAI daemon" can surface a session note that mentions the daemon only indirectly — because a connected entity (the Unix socket, the launchd service) appears in both the graph and the note.
|
|
79
|
+
|
|
80
|
+
### Feedback Loop with Relevance Scoring
|
|
81
|
+
|
|
82
|
+
Every search result that is subsequently retrieved via `memory_get` (i.e., actually read by the model) generates a positive feedback signal. These signals are stored and used to adjust future search weights using an exponential moving average (EMA):
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
new_weight = alpha * signal + (1 - alpha) * old_weight
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The default alpha is 0.1, so recent positive signals gradually raise a chunk's effective score without overriding the semantic baseline. This creates a personalization loop: content you actually use rises in future rankings; content you skip does not.
|
|
89
|
+
|
|
90
|
+
### Access Timestamp Tracking
|
|
91
|
+
|
|
92
|
+
Every chunk row carries a `last_accessed_at` timestamp updated on each `memory_get` call. This supports recency boost (content accessed recently scores higher) and enables future eviction policies for very large knowledge bases.
|
|
93
|
+
|
|
94
|
+
### Multi-Tenant Support
|
|
95
|
+
|
|
96
|
+
PAI isolates memory by project. Every chunk, entity, and observation row carries a `project_id` foreign key. Searches default to the current project; the `all_projects: true` flag (or `--all` CLI option) lifts the filter. Knowledge-graph triples carry a `project_id` as well, so cross-project tunnels (`memory_tunnels`) are detected explicitly rather than accidentally.
|
|
@@ -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.
|