@henryqw/pi-session-recall 0.2.0 → 0.2.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 CHANGED
@@ -1,10 +1,12 @@
1
1
  # `@henryqw/pi-session-recall`
2
2
 
3
- FTS5 search over past Pi sessions: a zero-LLM `session_search` tool plus a bundled skill for finding repeated work worth automating.
3
+ Search past Pi sessions with local FTS5. The `session_search` tool has four modes and makes no model calls.
4
+
5
+ The package also includes `pi-session-pattern-miner`. This skill finds repeated work that may be worth automating.
4
6
 
5
7
  ## Why
6
8
 
7
- - **Created for**: Pi users who need to recover decisions and context from prior sessions without keeping every transcript in the active prompt.
9
+ - **Created for**: Recover decisions and context from prior sessions without keeping every transcript in the active prompt.
8
10
  - **Advantage**: Local FTS5 search gives fast, private recall with zero standing context cost and no model calls.
9
11
 
10
12
  ## Install
@@ -17,39 +19,56 @@ pi install npm:@henryqw/pi-session-recall
17
19
 
18
20
  | Surface | Type | Purpose |
19
21
  | --- | --- | --- |
20
- | `session_search` | tool | Search past sessions or inspect one: discovery (`query`), scroll (`sessionId` + `aroundMessageId`), read (`sessionId`), browse (no args) |
21
- | `pi-session-pattern-miner` | skill | Find recurring work across sessions and define the smallest deterministic script, skill, or product change that should own it |
22
+ | `session_search` | tool | Search past sessions or inspect one. |
23
+ | `pi-session-pattern-miner` | skill | Find repeated work and choose the smallest useful automation. |
22
24
 
23
- ### Find work worth automating
25
+ BM25 is a text-ranking method. Hydrated results include messages read from saved session files.
26
+
27
+ | Mode | Call | Result |
28
+ | --- | --- | --- |
29
+ | Discovery | `query` | BM25-ranked top sessions. The top hit is hydrated with a ±5 message window and first/last-3 bookends. Lower hits include the matched anchor message and metadata. `detail:"full"` hydrates all. |
30
+ | Scroll | `sessionId` + `aroundMessageId` | ±`window` messages ([1,20]) around the anchor on its branch. Re-anchor on the last or first message ID to scroll. Across forks, pass the previous response's `branchTip`; `aroundMessageId` only centers the window and must lie on that branch. |
31
+ | Read | `sessionId` | The whole session. Large sessions return head 20 + tail 10. Oversized content is bounded to 50k characters and marked with `contentTruncated`. |
32
+ | Browse | no args | Recent sessions with path, name, cwd, started date, and preview. |
24
33
 
25
- Run `/skill:pi-session-pattern-miner` to find recurring workflows in past sessions. It requires evidence from two independent sessions, checks for existing automation, and prefers deterministic scripts when model judgment is unnecessary.
34
+ In the interactive TUI, the collapsed tool block shows the last five visual lines and the earlier-line count. Press `Ctrl+O` to expand the full bounded response. The model always receives the complete tool result.
26
35
 
27
- **Discovery** — BM25-ranked top sessions; top hit hydrated with a ±5 message window and first/last-3 bookends; lower hits carry the matched anchor message plus metadata (`detail:"full"` hydrates all).
36
+ ### Find work worth automating
28
37
 
29
- **Scroll** — ±`window` messages ([1,20]) around the anchor on its branch; scroll forward/backward by re-anchoring on the last/first message id of the returned window. Across forks, pass the previous response's `branchTip` to select the branch — `aroundMessageId` only centers the window and must lie on that branch.
38
+ Run `/skill:pi-session-pattern-miner` to find repeated workflows in past sessions. It requires evidence from two independent sessions and checks for existing automation. It prefers a fixed script when model judgment is not needed.
30
39
 
31
- **Read** — whole session; head 20 + tail 10 when large, with oversized content bounded to 50k characters and flagged by `contentTruncated`.
40
+ ### Query syntax and indexed text
32
41
 
33
- **Browse** — recent sessions: path, name, cwd, started date, preview.
42
+ - Prefer distinctive identifiers, package names, issue numbers, or uncommon terms. Use quoted phrases only when exact wording is known.
43
+ - The FTS5 trigram index uses AND for multiple words by default. Use `OR` for breadth, quoted phrases for exact matches, and `NOT` to exclude. Wildcards help only stems ≥3 characters.
44
+ - Only user and assistant text is indexed. Thinking blocks and tool output are not searchable.
45
+ - For message text over the 20,000-character indexing budget, only the first and last regions are indexed. The middle is omitted. Phrases and `NEAR` cannot cross those regions, but ordinary AND terms can.
46
+ - `sessionId` must be a `.jsonl` file under the Pi sessions directory.
34
47
 
35
- In the interactive TUI, tool results use Pi's built-in tail-preview behavior: the collapsed block shows the last five visual lines and the earlier-line count; `Ctrl+O` expands the full bounded response. This changes display only—the model still receives the complete tool result.
48
+ ### Context and sync
36
49
 
37
- 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.
50
+ 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.
38
51
 
39
- 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.
52
+ Before browse or discovery, lazy index sync can fail while walking the session tree. Results still come from the current index and can be partly updated or stale. Files found before failure may have new content, while rows for files the walk did not reach stay stale.
40
53
 
41
- 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.
54
+ - A partial walk returns top-level `syncWarning`: `{kind:"incomplete-walk"}`. Indexed-but-unseen paths are never purged in that case.
55
+ - A total sync failure returns top-level `syncWarning`: `{kind:"sync-failed", error}` with the capped failure message.
56
+ - The warning is omitted after a completed sync.
42
57
 
43
58
  ## State
44
59
 
45
- | Path | Purpose |
46
- | --- | --- |
47
- | `~/.pi/agent/config/pi-session-recall/index.db` | Derived SQLite search index, maintained by the extension. |
60
+ The extension maintains the derived SQLite search index at `~/.pi/agent/config/pi-session-recall/index.db`.
48
61
 
49
62
  ## Deliberate exclusions
50
63
 
51
- 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.
64
+ Session directories whose encoded path starts with `--tmp-` or `--private-tmp-` are never indexed. These sessions run from `/tmp` or `/private/tmp`.
65
+
66
+ Session files over 32 MiB are excluded from indexing and hydration. Discovery cannot newly find them.
67
+
68
+ READ and SCROLL return an explicit size error. A stale discovery hit from before a file grew returns metadata with empty messages and that error.
52
69
 
53
70
  ## Storage & privacy
54
71
 
55
- 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.
72
+ This is derived state. Delete it and it rebuilds from your session files.
73
+
74
+ Everything stays local. Transcripts are read in place, and nothing leaves the machine beyond what tool results already show the model.
@@ -4,6 +4,7 @@
4
4
  import { getAgentDir, keyHint, truncateToVisualLines } from "@earendil-works/pi-coding-agent";
5
5
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
6
6
  import { StringEnum } from "@earendil-works/pi-ai";
7
+ import { extensionConfigDir } from "@henryqw/pi-config-store";
7
8
  import { Text, truncateToWidth } from "@earendil-works/pi-tui";
8
9
  import { Type } from "typebox";
9
10
  import { realpathSync } from "node:fs";
@@ -12,7 +13,7 @@ import { MAX_QUERY_CHARS, getSessionRows, searchIndex, syncSessions } from "./se
12
13
  import { getWindow, readSession } from "./hydrate.ts";
13
14
  import type { WindowMessage } from "./types.ts";
14
15
 
15
- const dbPath = () => join(getAgentDir(), "config", "pi-session-recall", "index.db");
16
+ const dbPath = () => join(extensionConfigDir("pi-session-recall"), "index.db");
16
17
  const sessionsDir = () => join(getAgentDir(), "sessions");
17
18
 
18
19
  const OUTPUT_CHAR_BUDGET = 50_000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-session-recall",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Local FTS5 search over past Pi sessions plus a skill for turning recurring work into deterministic automation.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -15,10 +15,10 @@
15
15
  },
16
16
  "license": "MIT",
17
17
  "files": [
18
+ "LICENSE",
18
19
  "extensions",
19
20
  "skills",
20
- "README.md",
21
- "LICENSE"
21
+ "README.md"
22
22
  ],
23
23
  "scripts": {
24
24
  "test": "node --test test/*.test.ts",
@@ -49,5 +49,8 @@
49
49
  "skills": [
50
50
  "./skills"
51
51
  ]
52
+ },
53
+ "dependencies": {
54
+ "@henryqw/pi-config-store": "^0.1.0"
52
55
  }
53
56
  }