Skip to content

Commit ae62f39

Browse files
authored
docs(pi-session-recall): improve search query guidance (#170)
1 parent eb34a60 commit ae62f39

5 files changed

Lines changed: 8 additions & 28 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/pi-session-recall/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pi install npm:@henryqw/pi-session-recall
2727

2828
**Browse** — recent sessions: path, name, cwd, started date, preview.
2929

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.
3131

3232
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.
3333

packages/pi-session-recall/extensions/session-recall.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,30 +85,12 @@ interface ToolParams {
8585
detail?: "adaptive" | "full";
8686
}
8787

88-
const DESCRIPTION = `Search past Pi sessions stored on disk (FTS5-backed over a local SQLite index), or inspect one session in detail. No LLM calls — every shape returns actual messages.
88+
const DESCRIPTION = `Search past Pi sessions locally with FTS5; returns stored messages.
8989
90-
FOUR CALLING SHAPES
91-
92-
1) DISCOVERY — pass \`query\`:
93-
session_search(query="auth refactor", limit=3)
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.`;
11294

11395
export default function (pi: ExtensionAPI): void {
11496
// Best-effort sync at startup, deferred so the synchronous walk + SQLite

packages/pi-session-recall/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@henryqw/pi-session-recall",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "FTS5 search over past Pi sessions: single tool, four arg-inferred modes (discovery/scroll/read/browse), zero LLM calls.",
55
"keywords": [
66
"pi-package",

packages/pi-session-recall/test/entry.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ describe("session_search entry point", () => {
7272

7373
const tool = (pi as any).tool as CapturedTool;
7474
assert.equal(tool.name, "session_search");
75-
assert.match(tool.description, /FOUR CALLING SHAPES/);
76-
assert.match(tool.description, /user\/assistant/);
7775
assert.equal(tool.promptSnippet, "Search past Pi sessions for prior decisions and context");
7876

7977
// Fixture sessions with proper parentId chain.

0 commit comments

Comments
 (0)