@henryqw/pi-session-recall 0.1.5 → 0.1.7
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 +7 -17
- package/extensions/session-recall.ts +5 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,12 +27,18 @@ pi install npm:@henryqw/pi-session-recall
|
|
|
27
27
|
|
|
28
28
|
**Browse** — recent sessions: path, name, cwd, started date, preview.
|
|
29
29
|
|
|
30
|
-
Query syntax: FTS5 over a trigram index — multi-word = AND by default, `OR` for breadth, quoted phrases for exact match, `NOT` to exclude. Wildcards only help stems ≥3 chars. Only user/assistant text is indexed; thinking blocks and tool output are not searchable. For message text over the 20,000-character indexing budget, only first/last regions are indexed and the middle is omitted; phrases and `NEAR` cannot cross those regions, but ordinary AND terms can. `sessionId` must be a `.jsonl` file under the Pi sessions directory.
|
|
30
|
+
Query syntax: Prefer distinctive identifiers, package names, issue numbers, or uncommon terms; use quoted phrases only when exact wording is known. FTS5 over a trigram index — multi-word = AND by default, `OR` for breadth, quoted phrases for exact match, `NOT` to exclude. Wildcards only help stems ≥3 chars. Only user/assistant text is indexed; thinking blocks and tool output are not searchable. For message text over the 20,000-character indexing budget, only first/last regions are indexed and the middle is omitted; phrases and `NEAR` cannot cross those regions, but ordinary AND terms can. `sessionId` must be a `.jsonl` file under the Pi sessions directory.
|
|
31
31
|
|
|
32
32
|
Hits inside the current session's live context are suppressed; compacted-away or inactive-branch history stays discoverable. Forked sessions collapse into their parent when both match.
|
|
33
33
|
|
|
34
34
|
If the lazy index sync before browse/discovery cannot fully enumerate the session tree, or throws entirely, results are still served from the current index — potentially partially updated and stale: files discovered before the failure may already reflect their new content, while rows for files the walk never reached remain stale — and carry a top-level `syncWarning`: `{kind:"incomplete-walk"}` for a partial walk (indexed-but-unseen paths are never purged in that case), or `{kind:"sync-failed", error}` with the capped failure message. The warning is omitted once a sync completes.
|
|
35
35
|
|
|
36
|
+
## State
|
|
37
|
+
|
|
38
|
+
| Path | Purpose |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `~/.pi/agent/config/pi-session-recall/index.db` | Derived SQLite search index, maintained by the extension. |
|
|
41
|
+
|
|
36
42
|
## Deliberate exclusions
|
|
37
43
|
|
|
38
44
|
Session directories whose encoded path starts with `--tmp-` or `--private-tmp-` (sessions run from `/tmp` or `/private/tmp`) are never indexed. Session files over 32 MiB are excluded from indexing and hydration: discovery cannot newly find them; READ/SCROLL return an explicit size error, while a stale discovery hit retained from before the file grew is returned as metadata with empty messages and that error.
|
|
@@ -40,19 +46,3 @@ Session directories whose encoded path starts with `--tmp-` or `--private-tmp-`
|
|
|
40
46
|
## Storage & privacy
|
|
41
47
|
|
|
42
48
|
The SQLite index lives at `~/.pi/agent/config/pi-session-recall/index.db`. It is derived state: delete it and it rebuilds from your session files. Everything stays local — transcripts are read in place and nothing leaves the machine beyond what tool results already show the model.
|
|
43
|
-
|
|
44
|
-
## Remove
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
pi remove npm:@henryqw/pi-session-recall
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Delete `~/.pi/agent/config/pi-session-recall/` to reclaim index disk space.
|
|
51
|
-
|
|
52
|
-
## Development
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm test --workspace @henryqw/pi-session-recall
|
|
56
|
-
npm run typecheck --workspace @henryqw/pi-session-recall
|
|
57
|
-
npm run pack:check --workspace @henryqw/pi-session-recall
|
|
58
|
-
```
|
|
@@ -85,30 +85,12 @@ interface ToolParams {
|
|
|
85
85
|
detail?: "adaptive" | "full";
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const DESCRIPTION = `Search past Pi sessions
|
|
88
|
+
const DESCRIPTION = `Search past Pi sessions locally with FTS5; returns stored messages.
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Runs FTS5 search and returns the top N sessions with metadata, match snippet, and messages around each match. Adaptive detail (default): the top-ranked result carries a ±5 message window plus first/last bookend messages; lower-ranked results carry only the anchor message. Pass \`detail="full"\` to hydrate every result fully.
|
|
95
|
-
|
|
96
|
-
2) SCROLL — pass \`sessionId\` + \`aroundMessageId\`:
|
|
97
|
-
session_search(sessionId="...", aroundMessageId="e07", window=10)
|
|
98
|
-
Returns ±window messages centered on the anchor (clamped to [1,20]). Use after discovery when you need more context than the default ±5 window. To scroll forward/backward, pass the last/first message entryId of the previous window back as aroundMessageId; messagesBefore/messagesAfter tell you where you are. Across forks, re-anchoring on a shared ancestor can jump branches — pass the previous response's branchTip as the branchTip argument (aroundMessageId only moves the center) to stay on that branch.
|
|
99
|
-
|
|
100
|
-
3) READ — pass \`sessionId\` only:
|
|
101
|
-
session_search(sessionId="...")
|
|
102
|
-
Returns the session's active branch (first 20 + last 10 messages when large).
|
|
103
|
-
|
|
104
|
-
4) BROWSE — no args:
|
|
105
|
-
session_search()
|
|
106
|
-
Returns recent sessions: name, cwd, start time, first-user-message preview. Use when asked "what was I working on" without a topic.
|
|
107
|
-
|
|
108
|
-
Mode is inferred from args; precedence: scroll > read > browse > discovery.
|
|
109
|
-
|
|
110
|
-
FTS5 SYNTAX
|
|
111
|
-
AND is the default — multi-word queries require all terms. Use OR for broader recall (\`alpha OR beta\`), quoted phrases for exact match (\`"docker networking"\`), NOT to exclude (\`python NOT java\`). Wildcards work only as stem expansion of tokens ≥3 chars (trigram tokenizer); very short terms fall back to substring matching. The index covers user/assistant message text only — thinking, tool calls/results are not searchable.`;
|
|
90
|
+
- \`query\`: discover matches. Prefer distinctive identifiers or uncommon terms; multi-word queries are AND. Use \`OR\`/\`NOT\` for Boolean queries and quotes only when exact wording is known.
|
|
91
|
+
- \`sessionId\` + \`aroundMessageId\`: scroll ±\`window\`; retain \`branchTip\` across forks.
|
|
92
|
+
- \`sessionId\` alone: read; no args: browse recent sessions.
|
|
93
|
+
- Discovery is adaptive; use \`detail: "full"\` to hydrate every result.`;
|
|
112
94
|
|
|
113
95
|
export default function (pi: ExtensionAPI): void {
|
|
114
96
|
// Best-effort sync at startup, deferred so the synchronous walk + SQLite
|
package/package.json
CHANGED