pi-tuck 1.1.3 → 1.2.0

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/index.d.ts +2 -6
  3. package/dist/index.js +16 -111
  4. package/dist/src/build-id.d.ts +1 -1
  5. package/dist/src/build-id.js +1 -1
  6. package/dist/src/compaction.d.ts +2 -103
  7. package/dist/src/compaction.js +20 -140
  8. package/dist/src/diagnostic-replay.js +2 -2
  9. package/dist/src/diagnostics.d.ts +3 -2
  10. package/dist/src/diagnostics.js +30 -9
  11. package/dist/src/history-tools.js +3 -3
  12. package/dist/src/kept-reads.d.ts +2 -2
  13. package/dist/src/kept-reads.js +144 -8
  14. package/dist/src/ledger.d.ts +1 -1
  15. package/dist/src/ledger.js +5 -3
  16. package/dist/src/legacy-cleanup.d.ts +3 -0
  17. package/dist/src/legacy-cleanup.js +190 -0
  18. package/dist/src/notify.d.ts +3 -0
  19. package/dist/src/notify.js +13 -0
  20. package/dist/src/omissions.d.ts +1 -1
  21. package/dist/src/omissions.js +3 -3
  22. package/dist/src/path-key.d.ts +3 -0
  23. package/dist/src/path-key.js +8 -0
  24. package/dist/src/request-capacity.js +1 -1
  25. package/dist/src/run.d.ts +1 -3
  26. package/dist/src/run.js +3 -5
  27. package/dist/src/source-export.d.ts +1 -1
  28. package/dist/src/source-export.js +1 -1
  29. package/dist/src/status.d.ts +0 -6
  30. package/dist/src/status.js +1 -6
  31. package/dist/src/tuck/core/content.js +6 -9
  32. package/dist/src/tuck/core/keyword-query.d.ts +2 -2
  33. package/dist/src/tuck/core/keyword-query.js +1 -1
  34. package/dist/src/tuck/core/search-entries.js +5 -5
  35. package/dist/src/tuck/core/transcript.js +2 -1
  36. package/dist/src/tuck.js +390 -394
  37. package/dist/src/windows-private-storage.d.ts +9 -0
  38. package/dist/src/windows-private-storage.js +90 -0
  39. package/index.ts +18 -82
  40. package/package.json +5 -8
  41. package/src/build-id.ts +1 -1
  42. package/src/compaction.ts +19 -107
  43. package/src/diagnostic-replay.ts +2 -2
  44. package/src/diagnostics.ts +24 -9
  45. package/src/history-tools.ts +3 -3
  46. package/src/kept-reads.ts +78 -10
  47. package/src/ledger.ts +5 -3
  48. package/src/legacy-cleanup.ts +134 -0
  49. package/src/notify.ts +10 -0
  50. package/src/omissions.ts +3 -3
  51. package/src/path-key.ts +9 -0
  52. package/src/request-capacity.ts +1 -1
  53. package/src/run.ts +4 -6
  54. package/src/source-export.ts +1 -1
  55. package/src/status.ts +1 -10
  56. package/src/tuck/core/content.ts +5 -10
  57. package/src/tuck/core/keyword-query.ts +2 -2
  58. package/src/tuck/core/search-entries.ts +5 -5
  59. package/src/tuck/core/transcript.ts +2 -1
  60. package/src/tuck.ts +329 -335
  61. package/src/windows-private-storage.ts +94 -0
  62. package/dist/src/assets.d.ts +0 -58
  63. package/dist/src/assets.js +0 -80
  64. package/dist/src/eligibility-cache.d.ts +0 -19
  65. package/dist/src/eligibility-cache.js +0 -33
  66. package/dist/src/semantic-recall.d.ts +0 -422
  67. package/dist/src/semantic-recall.js +0 -1386
  68. package/dist/src/setup.d.ts +0 -3
  69. package/dist/src/setup.js +0 -191
  70. package/scripts/eg2-runtime.py +0 -307
  71. package/scripts/provision-eg2.py +0 -139
  72. package/scripts/semantic-worker.py +0 -234
  73. package/src/assets.ts +0 -92
  74. package/src/eligibility-cache.ts +0 -43
  75. package/src/semantic-recall.ts +0 -592
  76. package/src/setup.ts +0 -163
package/CHANGELOG.md CHANGED
@@ -3,6 +3,52 @@
3
3
  All notable changes to pi-tuck. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
4
4
  [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [1.2.0] - 2026-11-15
7
+
8
+ ### Added
9
+
10
+ - **Windows.** pi-tuck now installs and runs on Windows. Paths are compared the same way however Windows spells them (drive letter case,
11
+ backslashes, relative paths), and Windows shell commands that change files (`Set-Content`, `Remove-Item`, `del`, `move` and others)
12
+ count as changes. `/tuck-incident` creates its folder and files with private Windows permissions and refuses folders other users can read.
13
+ Tested on Windows 10 with Node 24 and Pi 1.5.2.
14
+
15
+ ### Fixed
16
+
17
+ - **Kept reads no longer quote a stale or partial file as if it were whole and current.** A cut's summary now keeps only whole reads;
18
+ a read is dropped from it when a later shell command that is not read-only names the file, or when a git command such as `checkout`,
19
+ `stash`, `restore` or `reset` ran, and paths are compared after normalising their spelling.
20
+
21
+ ### Removed
22
+
23
+ - **Semantic search and `tuck_search`.** Semantic-unique hits were 18 of 1,935 events (0.9%), against a 15% bar. The local model,
24
+ setup and downloads, worker, indexes and background indexing are gone. `tuck_recall` still provides exact reads and keyword search.
25
+
26
+ ### Changed
27
+
28
+ - **Old sessions still load, cut and recall.** Historical `tuck_search` and `vcc_search` calls remain readable; old private entries are
29
+ ignored. A leftover `semanticRecall` setting is ignored silently, and `/tuck` no longer reports semantic state.
30
+ - **Old search files are cleaned up once per machine.** Under `~/.pi/agent/pi-tuck/` (from the home directory, independent of Pi's agent-folder
31
+ setting), cleanup removes the real directories `python`, `index`,
32
+ `downloads`, `staging-<digits>` (exactly `staging-` followed by one or more digits), and `.pi-semantic-<six alphanumeric characters>`.
33
+ It removes `runtime` only when a child has a `pins.json` with pi-tuck's old pin fields, then removes the root only if empty.
34
+ Symlinks at the root or candidate paths and foreign files in the root are left in place; links inside removed directories are unlinked without
35
+ following their targets. On macOS and Linux, a directory is left alone if a live process has it open or the bounded `lsof` check fails;
36
+ Windows leaves all candidates alone. A notice names only removed directories, with the path and best-effort space freed, using stderr
37
+ without a UI. An empty `~/.pi/agent/pi-tuck-semantic-removed` marker records a completed attempt, including partial cleanup or nothing
38
+ to clean; an attempt that cannot start is retried. Once marked, a folder recreated later by another program is left alone.
39
+ `/tuck-semantic`, its stub text and the old notice are gone.
40
+
41
+ ### Release gates
42
+
43
+ - **Live gate on NIM Nemotron (10 paired tasks at room 16,384, against 1.1.2):** solved wins minus losses +1 (bar at least -1), turn-cap
44
+ stops 3 against 4, doubt moments 6 against 9, 0 lost tasks. Kept-read records quoting a partial or stale read: 0 against 141. The gate
45
+ found one false refusal after a steering message; it was fixed (1.1.3) and pinned by tests built from that run.
46
+ - **Replay against 1.1.3 (byte-identical to 1.1.2):** 29 recordings, cuts 1,975 → 1,869 and clips 16 → 8 with the smaller tool list and
47
+ the stricter kept reads; 0 lost or dead tasks, 0 faults.
48
+ - **Strict stress:** 322 cells, the resumed-session and stand-down suites and an 85 MB recall test, 0 findings. Lifecycle with 40 seeds.
49
+ Tests and CI on macOS and Ubuntu; the full suite also passed on Windows. The packed tarball loaded in the real installed Pi on macOS and
50
+ Windows.
51
+
6
52
  ## [1.1.3] - 2026-11-15
7
53
 
8
54
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -2,12 +2,8 @@ import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  export type { CompactionOptions } from "./src/compaction.js";
3
3
  export { installCompaction } from "./src/compaction.js";
4
4
  export { inspectIncident, readableIncident } from "./src/diagnostic-replay.js";
5
- export { createSemanticRecall, SemanticRecallController } from "./src/semantic-recall.js";
6
- export type { SemanticRecallConfig, PriorResult, SemanticState, SemanticSetup } from "./src/semantic-recall.js";
7
- export { ensureSemanticRuntime } from "./src/setup.js";
8
- /** pi-tuck as a Pi extension: compaction and history recall always; semantic recall too, unless `pi-tuck.json` in Pi's agent folder
9
- * says `{"semanticRecall": false}`. Its runtime is set up in the background the first time a session starts. The same file's `"cutAt"`
10
- * (a number above 0 and at most 1) is the fraction of the input room a cut is triggered at, 0.6 by default. */
5
+ /** pi-tuck as a Pi extension: compaction and history recall. `"cutAt"` in `pi-tuck.json` in Pi's agent folder (a number above 0 and at most
6
+ * 1) fixes the cut point as a fraction of the input room; without it, the cut point adapts. */
11
7
  /** The oldest Pi with every hook and API pi-tuck uses, and the oldest its tests pass on (Pi 1.2 added the custom message that starts a
12
8
  * run to before_agent_start, which the prompt's cut counts). */
13
9
  export declare const PI_FLOOR = "1.2.0";
package/dist/index.js CHANGED
@@ -1,18 +1,14 @@
1
1
  import { VERSION, getAgentDir } from "@earendil-works/pi-coding-agent";
2
- import { existsSync, readFileSync, realpathSync } from "node:fs";
3
- import { join, sep } from "node:path";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
4
  import { installCompaction } from "./src/compaction.js";
5
5
  import { validCutAt } from "./src/budget.js";
6
- import { createSemanticRecall } from "./src/semantic-recall.js";
7
- import { defaultRoot, runtimeConfigPath } from "./src/assets.js";
8
- import { ensureSemanticRuntime } from "./src/setup.js";
6
+ import { notify } from "./src/notify.js";
7
+ import { cleanupLegacyFiles } from "./src/legacy-cleanup.js";
9
8
  export { installCompaction } from "./src/compaction.js";
10
9
  export { inspectIncident, readableIncident } from "./src/diagnostic-replay.js";
11
- export { createSemanticRecall, SemanticRecallController } from "./src/semantic-recall.js";
12
- export { ensureSemanticRuntime } from "./src/setup.js";
13
- /** pi-tuck as a Pi extension: compaction and history recall always; semantic recall too, unless `pi-tuck.json` in Pi's agent folder
14
- * says `{"semanticRecall": false}`. Its runtime is set up in the background the first time a session starts. The same file's `"cutAt"`
15
- * (a number above 0 and at most 1) is the fraction of the input room a cut is triggered at, 0.6 by default. */
10
+ /** pi-tuck as a Pi extension: compaction and history recall. `"cutAt"` in `pi-tuck.json` in Pi's agent folder (a number above 0 and at most
11
+ * 1) fixes the cut point as a fraction of the input room; without it, the cut point adapts. */
16
12
  /** The oldest Pi with every hook and API pi-tuck uses, and the oldest its tests pass on (Pi 1.2 added the custom message that starts a
17
13
  * run to before_agent_start, which the prompt's cut counts). */
18
14
  export const PI_FLOOR = "1.2.0";
@@ -41,99 +37,16 @@ export default async function (pi) {
41
37
  });
42
38
  return;
43
39
  }
44
- const semanticRecall = createSemanticRecall();
45
- // `/tuck-semantic off` holds for the rest of the session, including over a setup that finishes later.
46
40
  const settings = readSettings(join(getAgentDir(), "pi-tuck.json"));
47
- // Semantic recall runs on Metal, so only on Apple silicon; elsewhere the model is not offered tuck_search at all.
48
- const appleSilicon = process.platform === "darwin" && process.arch === "arm64";
49
- const handle = await installCompaction(pi, { semanticRecall, search: appleSilicon, cutAt: settings.cutAt, onSemanticSetting: async (enabled) => {
50
- if (!enabled)
51
- semanticRecall.setSetup("off-user");
52
- else if (semanticRecall.status().setup === "off-user")
53
- semanticRecall.setSetup("starting", { installed: existsSync(runtimeConfigPath(defaultRoot())) });
54
- } });
55
- if (settings.semanticRecall === false) {
56
- semanticRecall.setSetup("off-settings");
57
- pi.on("session_start", () => { semanticRecall.setSetup("off-settings"); });
58
- return;
59
- }
60
- let session = 0, said = "", announced = false, setup;
61
- // A context outlives its session (a setup can finish after /new); a notice to an ended session is dropped.
62
- // With no UI (pi -p), Pi shows no notices, so a settings error or an off or failing semantic recall would go unsaid: write each to stderr
63
- // instead, once per session. stderr is the operator's; it never enters the model's context.
64
- const stderrSaid = new Set();
65
- const say = (ctx, message, level) => {
66
- if (!ctx.hasUI) {
67
- if (!stderrSaid.has(message)) {
68
- stderrSaid.add(message);
69
- try {
70
- process.stderr.write(message + "\n");
71
- }
72
- catch { /* closed */ }
73
- }
74
- return;
75
- }
76
- try {
77
- ctx.ui.notify(message, level);
78
- }
79
- catch { /* ended */ }
80
- };
81
- const once = (ctx, message, level) => { if (said !== message) {
82
- said = message;
83
- say(ctx, message, level);
84
- } };
85
- const announce = (ctx, state, detail) => {
86
- semanticRecall.setSetup(state, detail);
87
- const notice = semanticRecall.setupNotice();
88
- if (notice)
89
- (state === "off-platform" || state === "off-project" ? once : say)(ctx, notice.message, notice.level);
90
- };
91
- pi.on("session_shutdown", () => { session++; });
92
- pi.on("session_start", (_event, ctx) => {
93
- const current = ++session;
94
- stderrSaid.clear();
41
+ const handle = await installCompaction(pi, { cutAt: settings.cutAt });
42
+ let said = false;
43
+ pi.on("session_start", async (_event, ctx) => {
44
+ await cleanupLegacyFiles(ctx);
95
45
  if (handle.state?.(ctx).kind === "standingDown")
96
46
  return;
97
- if (settings.error)
98
- once(ctx, `pi-tuck: ${settings.error}; using the defaults.`, "warning");
99
- if (!appleSilicon)
100
- return announce(ctx, "off-platform");
101
- // Semantic recall keeps its runtime and indexes outside the project it serves, so not when Pi runs in a folder that holds its
102
- // agent folder, such as the home folder.
103
- if (within(real(getAgentDir()), real(ctx.cwd)))
104
- return announce(ctx, "off-project");
105
- // A run with no UI (pi -p, RPC, JSON) uses a runtime that is already installed: that needs no download. It does not start a first-time
106
- // setup, which would outlast a one-shot run, and it says why, so tuck_search and /tuck name the real state.
107
- const installed = existsSync(runtimeConfigPath(defaultRoot()));
108
- if (!ctx.hasUI && !installed)
109
- return announce(ctx, "not-installed");
110
- // The download's announcement outlives the session that made it: a session that starts while the shared setup is still running
111
- // owes the "set up" notice once, as before the refactor.
112
- semanticRecall.setSetup("starting", { installed, announced });
113
- setup ??= ensureSemanticRuntime(defaultRoot(), message => {
114
- announced = true;
115
- if (current === session && semanticRecall.status().setup !== "off-user")
116
- announce(ctx, "starting", { installed, notice: message, announced: true });
117
- });
118
- setup.then(async () => {
119
- if (current !== session || semanticRecall.status().setup === "off-user")
120
- return;
121
- try {
122
- await handle.setSemanticEnabled(true, ctx);
123
- if (current === session && semanticRecall.status().setup !== "off-user") {
124
- announce(ctx, "ready", { announced });
125
- announced = false;
126
- }
127
- }
128
- catch (error) {
129
- if (current === session && semanticRecall.status().setup !== "off-user")
130
- announce(ctx, "failed", { stage: "start", reason: reason(error) });
131
- }
132
- }, error => {
133
- setup = undefined; // the next session start tries again
134
- if (current === session && semanticRecall.status().setup !== "off-user")
135
- announce(ctx, "failed", { stage: "setup", reason: reason(error) });
136
- });
47
+ if (settings.error && !said) {
48
+ said = notify(ctx, `pi-tuck: ${settings.error}; using the defaults.`, "warning");
49
+ }
137
50
  });
138
51
  }
139
52
  function readSettings(path) {
@@ -146,18 +59,10 @@ function readSettings(path) {
146
59
  }
147
60
  try {
148
61
  const value = JSON.parse(text);
149
- if (value && typeof value === "object" && (value.semanticRecall === undefined || typeof value.semanticRecall === "boolean") &&
62
+ if (value && typeof value === "object" &&
150
63
  (value.cutAt === undefined || validCutAt(value.cutAt)))
151
- return value;
64
+ return { cutAt: value.cutAt };
152
65
  }
153
66
  catch { /* reported below */ }
154
- return { error: `${path} should be a JSON object like {"semanticRecall": false, "cutAt": 0.8}, with cutAt a number above 0 and at most 1` };
155
- }
156
- const reason = (error) => error instanceof Error ? error.message : String(error);
157
- const within = (path, folder) => path === folder || path.startsWith(folder.endsWith(sep) ? folder : folder + sep);
158
- const real = (path) => { try {
159
- return realpathSync(path);
67
+ return { error: `${path} should be a JSON object like {"cutAt": 0.8}, with cutAt a number above 0 and at most 1` };
160
68
  }
161
- catch {
162
- return path;
163
- } };
@@ -1 +1 @@
1
- export declare const BUILD_ID = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
1
+ export declare const BUILD_ID = "f653b17921c5383797b70c8962152e6b4537a7769e05118290fc34d492a06ec1";
@@ -1 +1 @@
1
- export const BUILD_ID = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
1
+ export const BUILD_ID = "f653b17921c5383797b70c8962152e6b4537a7769e05118290fc34d492a06ec1";
@@ -1,5 +1,4 @@
1
- import { type Run } from "./run.js";
2
- import { type SemanticRecallController } from "./semantic-recall.js";
1
+ import { Run } from "./run.js";
3
2
  import { type RecorderOptions } from "./diagnostics.js";
4
3
  import { type AgentMessage } from "./budget.js";
5
4
  import { SettingsManager, type ExtensionAPI, type ExtensionContext, type SessionEntry } from "@earendil-works/pi-coding-agent";
@@ -38,12 +37,6 @@ export declare function compactionState(model: {
38
37
  contextWindow?: number;
39
38
  } | undefined, enabled: boolean): CompactionState;
40
39
  export interface CompactionOptions {
41
- semanticRecall?: SemanticRecallController;
42
- /** Whether `tuck_search` exists: false where semantic recall cannot run (off Apple silicon), so the model is offered word recall only. */
43
- search?: boolean;
44
- /** Optional host-owned transient operator preference; handle operations never call back. */
45
- onSemanticSetting?: (enabled: boolean) => Promise<unknown>;
46
- semanticStatus?: () => unknown;
47
40
  diagnostics?: RecorderOptions;
48
41
  /** Optional read-only observation of actual corrected budget checks; no request content. */
49
42
  observeBudget?: (measurement: {
@@ -86,104 +79,10 @@ export interface CompactionOptions {
86
79
  }
87
80
  export declare function installCompaction(pi: ExtensionAPI, options?: CompactionOptions): Promise<{
88
81
  close: () => Promise<void>;
89
- semanticRecall: SemanticRecallController;
90
- setSemanticEnabled: (enabled: boolean, ctx: ExtensionContext) => Promise<{
91
- setup: import("./semantic-recall.js").SemanticSetup;
92
- setupMessage: string | null;
93
- enabled: boolean;
94
- configured: boolean;
95
- cleanupError: string | null;
96
- state: import("./semantic-recall.js").SemanticState;
97
- snapshotId: string | null;
98
- throughEntryId: string | null;
99
- eligibleSources: number;
100
- totalUnits: number;
101
- coveredUnits: number;
102
- indexingComplete: boolean;
103
- lastError: string | null;
104
- window: {
105
- indexedCharacters: number;
106
- windowCharacters: number;
107
- outOfViewCharacters: number;
108
- eligibleCharacters: number;
109
- oldestCoveredEntryId: string | null;
110
- oldestCoveredTime: string | null;
111
- conversation: {
112
- indexedCharacters: number;
113
- outOfViewCharacters: number;
114
- };
115
- toolResults: {
116
- indexedCharacters: number;
117
- outOfViewCharacters: number;
118
- oldestCoveredTime: string | null;
119
- };
120
- } | null;
121
- recovery: {
122
- attempts: number;
123
- integrity: boolean;
124
- retryAt: string | null;
125
- } | null;
126
- operations: {
127
- preparationEmbeddings: number;
128
- queryEmbeddings: number;
129
- };
130
- limits: {
131
- keyword: number;
132
- broad: number;
133
- };
134
- }>;
135
- semanticStatus: () => {
136
- host?: unknown;
137
- local: {
138
- setup: import("./semantic-recall.js").SemanticSetup;
139
- setupMessage: string | null;
140
- enabled: boolean;
141
- configured: boolean;
142
- cleanupError: string | null;
143
- state: import("./semantic-recall.js").SemanticState;
144
- snapshotId: string | null;
145
- throughEntryId: string | null;
146
- eligibleSources: number;
147
- totalUnits: number;
148
- coveredUnits: number;
149
- indexingComplete: boolean;
150
- lastError: string | null;
151
- window: {
152
- indexedCharacters: number;
153
- windowCharacters: number;
154
- outOfViewCharacters: number;
155
- eligibleCharacters: number;
156
- oldestCoveredEntryId: string | null;
157
- oldestCoveredTime: string | null;
158
- conversation: {
159
- indexedCharacters: number;
160
- outOfViewCharacters: number;
161
- };
162
- toolResults: {
163
- indexedCharacters: number;
164
- outOfViewCharacters: number;
165
- oldestCoveredTime: string | null;
166
- };
167
- } | null;
168
- recovery: {
169
- attempts: number;
170
- integrity: boolean;
171
- retryAt: string | null;
172
- } | null;
173
- operations: {
174
- preparationEmbeddings: number;
175
- queryEmbeddings: number;
176
- };
177
- limits: {
178
- keyword: number;
179
- broad: number;
180
- };
181
- };
182
- };
183
82
  state: (ctx: ExtensionContext) => CompactionState;
184
83
  inspectState: (ctx: ExtensionContext) => {
185
84
  run: Readonly<Run> | undefined;
186
- phase: "starting" | "failed" | "decided" | "claimed" | "expired" | "admitted" | "commit-failed" | undefined;
85
+ phase: "decided" | "claimed" | "expired" | "starting" | "admitted" | "failed" | "commit-failed" | undefined;
187
86
  calibrationIdentity: string;
188
87
  pendingCut: boolean;
189
88
  };