@foliox/transparent-compact-pi 0.0.0-stage → 0.8.3

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/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@foliox/transparent-compact-pi",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.3",
4
+ "description": "Deterministic, verbatim-preserving compaction for Pi, with session-backed subagent context recovery.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "compaction",
9
+ "context-recovery"
10
+ ],
11
+ "homepage": "https://github.com/felixwoolford/transparent-compact-pi#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/felixwoolford/transparent-compact-pi/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/felixwoolford/transparent-compact-pi.git"
18
+ },
19
+ "license": "MIT",
20
+ "type": "module",
21
+ "main": "index.js",
22
+ "directories": {
23
+ "doc": "docs"
24
+ },
25
+ "files": [
26
+ "extensions/",
27
+ "skills/context-retrieval/",
28
+ "README.md",
29
+ "CHANGELOG.md",
30
+ "LICENSE",
31
+ "docs/"
32
+ ],
33
+ "scripts": {
34
+ "test": "node scripts/test-all.cjs",
35
+ "test:integration": "node test.cjs",
36
+ "test:cap": "node test.cjs cap",
37
+ "test:caphang": "node test.cjs caphang",
38
+ "test:capspans": "node test.cjs capspans",
39
+ "test:package": "node scripts/test-package.cjs"
40
+ },
41
+ "devDependencies": {
42
+ "@earendil-works/pi-coding-agent": "1.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@earendil-works/pi-ai": "*",
46
+ "@earendil-works/pi-agent-core": "*",
47
+ "@earendil-works/pi-coding-agent": "*",
48
+ "typebox": "*"
49
+ },
50
+ "engines": {
51
+ "node": ">=22.19.0"
52
+ },
53
+ "pi": {
54
+ "extensions": [
55
+ "./extensions/transparent-compact.ts"
56
+ ],
57
+ "skills": [
58
+ "./skills/context-retrieval"
59
+ ]
60
+ }
61
+ }
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: context-retrieval
3
+ description: Recover earlier pi session context through the context_lookup subagent. Use after compaction when exact tool outputs, error text, file contents, thinking, tool-call arguments, or earlier instructions and decisions are needed. Use pi's retained session history for recovery, without creating additional snapshots.
4
+ ---
5
+
6
+ # Session context recovery
7
+
8
+ This skill pairs with `transparent-compact.ts`, which provides:
9
+
10
+ - **Verbatim compaction** — a deterministic checkpoint retains user messages, assistant prose, and compact tool-call signatures. Thinking and tool outputs are removed from the active model context, not from the raw session history. Earlier spans are re-rendered flat, with one re-orientation block and an opaque base when needed.
11
+ - **`context_lookup`** — the preferred first step: a subagent searches the full raw session branch in its **own** context and returns relevant findings. At lookup time, the extension mechanically renders the branch into entry-anchored text with an authoritative entry/section index, in memory. There is no local dump or temporary transcript file to manage.
12
+ - **Bounded fallback tools** — if those findings are incomplete, use `context_list_entries`, `context_grep`, and `context_show_entry` for direct evidence recovery. Their results enter this conversation. These are the permitted fallback, not filesystem access to session files.
13
+
14
+ Pi normally saves sessions under `~/.pi/agent/sessions/`; custom session locations also work. In-memory sessions retain history only while the process lives and cannot be resumed after exit. The extension does not register a snapshot tool or command.
15
+
16
+ If `context_lookup` is not in your tool list, say that subagent recovery is unavailable. Use the bounded fallback tools if available; otherwise report that limitation. Do not assume the extension is absent solely because `dump_context` is unavailable, and do not search session files manually as a fallback.
17
+
18
+ ## When to use
19
+
20
+ - After a compaction, you need an exact error message, a full tool output, previously read file content, full tool-call arguments, an earlier instruction or decision, or reasoning that was dropped → call `context_lookup` with a **specific** question.
21
+ - A checkpoint or your memory contains a claim based on pre-compaction tool output → re-read the current source or ask `context_lookup` for the historical evidence before relying on the claim. If you cannot verify it, explicitly label it unverified.
22
+ - Before a long, tool-heavy task → no extra snapshot is required for recovery. Pi's raw session history already retains finalized entries. Follow the checkpoint's re-orientation instructions after compaction.
23
+
24
+ ## How to ask
25
+
26
+ ```text
27
+ context_lookup({ question: "What exact error did the earlier test run return for the N=7 case? Include the ENTRY id and observed tool output." })
28
+ ```
29
+
30
+ For `context_lookup`, only supply `question`. Lookup covers all earlier compactions on the current branch automatically; there is no dump-selection argument. It does **not** search abandoned branches or unrelated sessions. If the detail is absent, report that limitation instead of claiming it was recovered or widening the search through filesystem tools.
31
+
32
+ A study harness may configure `MECH_COMPACT_LOOKUP_SESSION_FILE` to make the extension search a full session rather than a pruned fork. This is extension configuration, not a tool argument or a file the main agent should read. Do not discover or change the override to broaden a lookup.
33
+
34
+ ## Bounded fallback and pagination
35
+
36
+ If the subagent comes up short, use `context_list_entries` for an overview,
37
+ `context_grep` for specific historical evidence, and `context_show_entry` for
38
+ an identified entry. Do not immediately repeat the subagent query. The three
39
+ fallback tools neither increase nor reset the lookup count: they are part of
40
+ the same recovery episode. Narration and thinking do not reset it either. Only
41
+ a tool result outside the four recovery tools, a user message, or a bash
42
+ execution resets the limit.
43
+
44
+ Search responses are pages, not necessarily complete evidence. Follow pages
45
+ only when omitted content is needed; do not exhaust every match or entry merely
46
+ because a continuation is available. Keep other parameters unchanged and use
47
+ all continuation parameters printed at the end of a limited page:
48
+
49
+ - Listings and entry retrieval: `offset` counts characters (UTF-16 code units)
50
+ in the rendered listing or entry, starting at 0.
51
+ - Grep: `offset` counts matches, starting at 0; `charOffset` continues within
52
+ the context of an oversized match. Grep reports how many matches remain.
53
+ - `maxLines` and `maxMatches` limit a page, not the backing history. Increasing
54
+ them does not remove the character guard. Use the reported cursor instead.
55
+
56
+ Listing/grep cursors also report `throughEntry`: retain this original last-entry
57
+ id on subsequent pages, so newly appended calls/results cannot keep expanding
58
+ the search. The source is rendered afresh, without a snapshot. If you change
59
+ search/context parameters or navigate to another branch, restart at `offset=0`
60
+ (and `charOffset=0` for grep) without `throughEntry`. If grep reports an invalid
61
+ `charOffset`, retry that match at the same `offset` with `charOffset=0` and your
62
+ intended context parameters.
63
+
64
+ ## Rules
65
+
66
+ 1. **Never grep or read session JSONL files or old context dumps through filesystem tools in the main conversation for recovery.** Prefer `context_lookup`; when its findings are incomplete, use the bounded fallback tools above. Raw filesystem recovery would refill the compacted context.
67
+ 2. Ask narrowly scoped questions using exact error strings, file paths, function names, or the command whose output you need. Recover tightly related details together; use separate queries for independent facts. Ask the subagent for evidence, not for a solution to the broader task.
68
+ 3. Findings cite ENTRY ids and the logical transcript name. Retain these citations when relying on recovered facts. The renderer preserves full thinking, text, tool-call arguments, and tool results, although individual search results have output limits.
69
+ 4. Distinguish **user instructions**, **observed tool output**, and **reasoning at the time**. A recovered `[thinking]` block is a historical hypothesis, not verified fact. Earlier assistant prose is not independently observed evidence either.
70
+ 5. Historical tool output proves what was observed then, not what is true now. Re-read any file you are about to modify, review uncommitted work, and re-verify current build/test state as required by the checkpoint.
71
+ 6. Lookups can return incomplete findings or fail. State what remains missing; do not invent details or treat a partial answer as exhaustive.
72
+
73
+ ## Explicit snapshot requests
74
+
75
+ If the user asks to save/dump/snapshot context, explain that this extension uses pi's retained session history for recovery and provides no separate snapshot tool. Do not call `dump_context` or claim a new snapshot was saved. If the user needs an independent export, pi provides `/export`; review exports for sensitive content before sharing.
76
+
77
+ Session history and recovered findings can contain credentials, private code, and conversation details. Do not commit or share them without the user's explicit approval.