@astralyn/pi 0.84.0 → 0.84.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.
Files changed (176) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/cli/args.js +3 -3
  3. package/dist/cli/args.js.map +1 -1
  4. package/dist/cli/auth-check.d.ts +19 -0
  5. package/dist/cli/auth-check.d.ts.map +1 -0
  6. package/dist/cli/auth-check.js +50 -0
  7. package/dist/cli/auth-check.js.map +1 -0
  8. package/dist/cli/auth-command.d.ts +24 -0
  9. package/dist/cli/auth-command.d.ts.map +1 -0
  10. package/dist/cli/auth-command.js +104 -0
  11. package/dist/cli/auth-command.js.map +1 -0
  12. package/dist/cli/credential-print.d.ts +4 -14
  13. package/dist/cli/credential-print.d.ts.map +1 -1
  14. package/dist/cli/credential-print.js +38 -79
  15. package/dist/cli/credential-print.js.map +1 -1
  16. package/dist/core/auth-storage.d.ts +10 -0
  17. package/dist/core/auth-storage.d.ts.map +1 -1
  18. package/dist/core/auth-storage.js +76 -1
  19. package/dist/core/auth-storage.js.map +1 -1
  20. package/dist/core/extensions/types.d.ts +5 -0
  21. package/dist/core/extensions/types.d.ts.map +1 -1
  22. package/dist/core/extensions/types.js.map +1 -1
  23. package/dist/core/keybindings.d.ts +8 -0
  24. package/dist/core/keybindings.d.ts.map +1 -1
  25. package/dist/core/model-resolver.d.ts.map +1 -1
  26. package/dist/core/model-resolver.js +1 -0
  27. package/dist/core/model-resolver.js.map +1 -1
  28. package/dist/core/model-runtime.d.ts +2 -0
  29. package/dist/core/model-runtime.d.ts.map +1 -1
  30. package/dist/core/model-runtime.js +3 -1
  31. package/dist/core/model-runtime.js.map +1 -1
  32. package/dist/core/tools/bash.d.ts +4 -0
  33. package/dist/core/tools/bash.d.ts.map +1 -1
  34. package/dist/core/tools/bash.js +6 -4
  35. package/dist/core/tools/bash.js.map +1 -1
  36. package/dist/core/tools/edit.d.ts +4 -0
  37. package/dist/core/tools/edit.d.ts.map +1 -1
  38. package/dist/core/tools/edit.js +11 -7
  39. package/dist/core/tools/edit.js.map +1 -1
  40. package/dist/core/tools/find.d.ts +4 -0
  41. package/dist/core/tools/find.d.ts.map +1 -1
  42. package/dist/core/tools/find.js +5 -1
  43. package/dist/core/tools/find.js.map +1 -1
  44. package/dist/core/tools/grep.d.ts +4 -0
  45. package/dist/core/tools/grep.d.ts.map +1 -1
  46. package/dist/core/tools/grep.js +5 -1
  47. package/dist/core/tools/grep.js.map +1 -1
  48. package/dist/core/tools/ls.d.ts +4 -0
  49. package/dist/core/tools/ls.d.ts.map +1 -1
  50. package/dist/core/tools/ls.js +5 -1
  51. package/dist/core/tools/ls.js.map +1 -1
  52. package/dist/core/tools/read.d.ts +4 -0
  53. package/dist/core/tools/read.d.ts.map +1 -1
  54. package/dist/core/tools/read.js +6 -2
  55. package/dist/core/tools/read.js.map +1 -1
  56. package/dist/core/tools/write.d.ts +4 -0
  57. package/dist/core/tools/write.d.ts.map +1 -1
  58. package/dist/core/tools/write.js +6 -2
  59. package/dist/core/tools/write.js.map +1 -1
  60. package/dist/extensions/index.d.ts.map +1 -1
  61. package/dist/extensions/index.js +0 -4
  62. package/dist/extensions/index.js.map +1 -1
  63. package/dist/extensions/todo/schema.d.ts +1 -1
  64. package/dist/extensions/todo/state.js +5 -5
  65. package/dist/extensions/todo/state.js.map +1 -1
  66. package/dist/main.d.ts.map +1 -1
  67. package/dist/main.js +57 -21
  68. package/dist/main.js.map +1 -1
  69. package/dist/modes/interactive/interactive-mode.d.ts +3 -4
  70. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  71. package/dist/modes/interactive/interactive-mode.js +48 -41
  72. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  73. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  74. package/dist/modes/interactive/theme/theme.js +11 -3
  75. package/dist/modes/interactive/theme/theme.js.map +1 -1
  76. package/dist/server/create-harness.d.ts +26 -0
  77. package/dist/server/create-harness.d.ts.map +1 -0
  78. package/dist/server/create-harness.js +104 -0
  79. package/dist/server/create-harness.js.map +1 -0
  80. package/dist/utils/coalescing-terminal.d.ts +19 -4
  81. package/dist/utils/coalescing-terminal.d.ts.map +1 -1
  82. package/dist/utils/coalescing-terminal.js +33 -5
  83. package/dist/utils/coalescing-terminal.js.map +1 -1
  84. package/docs/bundled/README.md +0 -2
  85. package/docs/docs.json +0 -8
  86. package/docs/extensions.md +3 -2
  87. package/docs/keybindings.md +9 -5
  88. package/docs/providers.md +8 -1
  89. package/docs/usage.md +0 -1
  90. package/examples/extensions/README.md +2 -0
  91. package/examples/extensions/custom-provider-anthropic/package-lock.json +5 -5
  92. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  93. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  94. package/examples/extensions/gondolin/package-lock.json +2 -2
  95. package/examples/extensions/gondolin/package.json +1 -1
  96. package/examples/extensions/plan-mode/README.md +66 -0
  97. package/examples/extensions/plan-mode/index.ts +390 -0
  98. package/examples/extensions/plan-mode/utils.ts +168 -0
  99. package/examples/extensions/sandbox/package-lock.json +3 -3
  100. package/examples/extensions/sandbox/package.json +1 -1
  101. package/examples/extensions/subagent/README.md +175 -0
  102. package/examples/extensions/subagent/agents/planner.md +37 -0
  103. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  104. package/examples/extensions/subagent/agents/scout.md +50 -0
  105. package/examples/extensions/subagent/agents/worker.md +24 -0
  106. package/examples/extensions/subagent/agents.ts +126 -0
  107. package/examples/extensions/subagent/index.ts +1009 -0
  108. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  109. package/examples/extensions/subagent/prompts/implement.md +10 -0
  110. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  111. package/examples/extensions/with-deps/package-lock.json +4 -4
  112. package/examples/extensions/with-deps/package.json +1 -1
  113. package/npm-shrinkwrap.json +26 -26
  114. package/package.json +6 -6
  115. package/dist/extensions/biu/index.d.ts +0 -19
  116. package/dist/extensions/biu/index.d.ts.map +0 -1
  117. package/dist/extensions/biu/index.js +0 -350
  118. package/dist/extensions/biu/index.js.map +0 -1
  119. package/dist/extensions/biu/prompts.d.ts +0 -26
  120. package/dist/extensions/biu/prompts.d.ts.map +0 -1
  121. package/dist/extensions/biu/prompts.js +0 -260
  122. package/dist/extensions/biu/prompts.js.map +0 -1
  123. package/dist/extensions/biu/workspace.d.ts +0 -122
  124. package/dist/extensions/biu/workspace.d.ts.map +0 -1
  125. package/dist/extensions/biu/workspace.js +0 -404
  126. package/dist/extensions/biu/workspace.js.map +0 -1
  127. package/dist/extensions/rewind/anchor.d.ts +0 -29
  128. package/dist/extensions/rewind/anchor.d.ts.map +0 -1
  129. package/dist/extensions/rewind/anchor.js +0 -35
  130. package/dist/extensions/rewind/anchor.js.map +0 -1
  131. package/dist/extensions/rewind/config.d.ts +0 -16
  132. package/dist/extensions/rewind/config.d.ts.map +0 -1
  133. package/dist/extensions/rewind/config.js +0 -69
  134. package/dist/extensions/rewind/config.js.map +0 -1
  135. package/dist/extensions/rewind/engine.d.ts +0 -93
  136. package/dist/extensions/rewind/engine.d.ts.map +0 -1
  137. package/dist/extensions/rewind/engine.js +0 -778
  138. package/dist/extensions/rewind/engine.js.map +0 -1
  139. package/dist/extensions/rewind/gc.d.ts +0 -35
  140. package/dist/extensions/rewind/gc.d.ts.map +0 -1
  141. package/dist/extensions/rewind/gc.js +0 -169
  142. package/dist/extensions/rewind/gc.js.map +0 -1
  143. package/dist/extensions/rewind/index.d.ts +0 -3
  144. package/dist/extensions/rewind/index.d.ts.map +0 -1
  145. package/dist/extensions/rewind/index.js +0 -287
  146. package/dist/extensions/rewind/index.js.map +0 -1
  147. package/dist/extensions/rewind/menu.d.ts +0 -13
  148. package/dist/extensions/rewind/menu.d.ts.map +0 -1
  149. package/dist/extensions/rewind/menu.js +0 -123
  150. package/dist/extensions/rewind/menu.js.map +0 -1
  151. package/dist/extensions/rewind/paths.d.ts +0 -4
  152. package/dist/extensions/rewind/paths.d.ts.map +0 -1
  153. package/dist/extensions/rewind/paths.js +0 -15
  154. package/dist/extensions/rewind/paths.js.map +0 -1
  155. package/dist/extensions/rewind/restore.d.ts +0 -54
  156. package/dist/extensions/rewind/restore.d.ts.map +0 -1
  157. package/dist/extensions/rewind/restore.js +0 -94
  158. package/dist/extensions/rewind/restore.js.map +0 -1
  159. package/dist/extensions/rewind/snapshot.d.ts +0 -45
  160. package/dist/extensions/rewind/snapshot.d.ts.map +0 -1
  161. package/dist/extensions/rewind/snapshot.js +0 -21
  162. package/dist/extensions/rewind/snapshot.js.map +0 -1
  163. package/dist/extensions/rewind/storage.d.ts +0 -12
  164. package/dist/extensions/rewind/storage.d.ts.map +0 -1
  165. package/dist/extensions/rewind/storage.js +0 -33
  166. package/dist/extensions/rewind/storage.js.map +0 -1
  167. package/dist/extensions/rewind/text.d.ts +0 -7
  168. package/dist/extensions/rewind/text.d.ts.map +0 -1
  169. package/dist/extensions/rewind/text.js +0 -19
  170. package/dist/extensions/rewind/text.js.map +0 -1
  171. package/dist/extensions/rewind/tool-path.d.ts +0 -3
  172. package/dist/extensions/rewind/tool-path.d.ts.map +0 -1
  173. package/dist/extensions/rewind/tool-path.js +0 -9
  174. package/dist/extensions/rewind/tool-path.js.map +0 -1
  175. package/docs/bundled/extensions/biu.md +0 -63
  176. package/docs/bundled/extensions/rewind.md +0 -86
@@ -1,287 +0,0 @@
1
- /**
2
- * rewind — file-backed checkpoint & rewind for Pi.
3
- *
4
- * Engine: instead of snapshotting the whole work tree into a per-session shadow
5
- * git repo (the old design, which froze the UI in large directories like a
6
- * multi-project parent folder and grew storage without bound), we back up ONLY
7
- * the files Pi's edit/write tools are about to modify — one copyFile before each
8
- * edit (see engine.ts, ported from Claude Code's file-history). Cost is
9
- * proportional to how many files Pi changed, never to project size.
10
- *
11
- * Per turn: before_agent_start opens a snapshot frame (re-recording tracked files
12
- * at their turn-start state); tool_call(edit|write) backs up each newly edited
13
- * file before it lands; agent_settled persists the frame to the session JSONL
14
- * (custom "pi-rewind-snapshot" entry) when it changed. agent_settled is used
15
- * instead of agent_end so auto-retry, overflow compaction-retry, and queued
16
- * follow-ups stay in one logical turn (agent_end can fire mid-continuation).
17
- * The frame anchors to the FIRST user entry the run appended (tracked via
18
- * anchorScanStart + anchor.ts) — the entry whose start the frame recorded;
19
- * steering/follow-up messages append later user entries that must not steal
20
- * the anchor. On session_start the index is rebuilt from those entries;
21
- * resume/fork hard-links the prior session's blobs.
22
- *
23
- * Time-travel is fused into /tree: navigating to a node whose turn changed files
24
- * offers to sync the work tree to that point (session_before_tree/session_tree).
25
- * Snapshot selection mirrors navigateTree's leaf rules (see restore.ts).
26
- * /rewind itself is a settings + storage menu (menu.ts), not a restore picker.
27
- *
28
- * Restore safety: applySnapshot only rewrites files that differ and never throws
29
- * out — a broken backup degrades to "leave the file alone", so it can never abort
30
- * the user's session.
31
- *
32
- * Architecture informed by oh-my-pi (GPL-3.0) and Claude Code's file-history;
33
- * independent implementation. No ANSI: all UI is native (ctx.ui.* + theme).
34
- */
35
- import path from "node:path";
36
- import { firstUserEntryIdAfter } from "./anchor.js";
37
- import { loadRewindConfig, reloadRewindConfig } from "./config.js";
38
- import { beginTurn, capSnapshots, disposeSession, endTurn, getSnapshots, migrateBackupsFromSession, registerSession, restoreStateFromSnapshots, trackEdit, } from "./engine.js";
39
- import { runGc, sessionIdFromFile } from "./gc.js";
40
- import { runRewindMenu } from "./menu.js";
41
- import { rewindBackupsRoot, sessionsDirectory } from "./paths.js";
42
- import { restoreToSnapshot, snapshotChangeDiffStats, snapshotChangedPaths, snapshotForEntry, } from "./restore.js";
43
- import { isSnapshot, SNAPSHOT_ENTRY_TYPE } from "./snapshot.js";
44
- import { configureStorage } from "./storage.js";
45
- import { truncateText } from "./text.js";
46
- import { editWriteTargetPath, resolveToolPath } from "./tool-path.js";
47
- // Bind the engine/gc storage roots to the real on-disk locations (they avoid
48
- // importing paths.ts directly so they stay node-testable). Safe to call at load.
49
- configureStorage({ backupsRoot: rewindBackupsRoot(), sessionsRoot: sessionsDirectory() });
50
- // Global (one config.json). Reloaded from disk at session_start; /rewind menu
51
- // saveRewindConfig updates the in-memory cache so the next turn sees changes
52
- // without re-reading the file every before_agent_start.
53
- let config = loadRewindConfig();
54
- // Per-session transient state held by the integration layer.
55
- const pendingPrompt = new Map(); // turn prompt, captured for the snapshot label
56
- const pendingTreeRestore = new Map(); // /tree sync intent
57
- // Leaf id before the current run started (null = branch root). agent_settled
58
- // scans forward from here for the run's FIRST user entry — the frame's anchor.
59
- const anchorScanStart = new Map();
60
- // ---- helpers --------------------------------------------------------------
61
- /** Record the current leaf as the scan start for the next frame's anchor. */
62
- function markAnchorScanStart(sid, ctx) {
63
- anchorScanStart.set(sid, ctx.sessionManager.getLeafId() ?? null);
64
- }
65
- /** Adapt the session manager to restore.ts's tree view (turn-anchor = navigateTree's "leaf = parent" entries). */
66
- function sessionTreeView(ctx) {
67
- return {
68
- getEntry(id) {
69
- const e = ctx.sessionManager.getEntry(id);
70
- if (!e)
71
- return undefined;
72
- const isTurnAnchor = (e.type === "message" && e.message.role === "user") || e.type === "custom_message";
73
- return { id: e.id, parentId: e.parentId, isTurnAnchor };
74
- },
75
- };
76
- }
77
- /** Rebuild the snapshot list for a session from its persisted custom entries. */
78
- function rebuildSnapshots(ctx) {
79
- const out = [];
80
- for (const entry of ctx.sessionManager.getEntries()) {
81
- if (entry.type === "custom" && entry.customType === SNAPSHOT_ENTRY_TYPE && isSnapshot(entry.data)) {
82
- out.push(entry.data);
83
- }
84
- }
85
- return out;
86
- }
87
- /** Max files listed in the /tree restore confirmation before "+N more". */
88
- const RESTORE_PREVIEW_LIMIT = 8;
89
- /** Max characters per previewed path (leading-truncated: the filename matters most). */
90
- const RESTORE_PREVIEW_PATH_MAX = 64;
91
- /**
92
- * Bounded cwd-relative file list shown under the /tree restore question, so an
93
- * irreversible work-tree rewrite is confirmed against WHICH files, not just a
94
- * count. Multi-line select titles are upstream-sanctioned (ui.confirm joins
95
- * title + message with \n through the same selector).
96
- */
97
- function formatRestorePreview(changedPaths, cwd) {
98
- const lines = changedPaths.slice(0, RESTORE_PREVIEW_LIMIT).map((p) => {
99
- const rel = path.relative(cwd, p);
100
- const display = rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? rel : p;
101
- const bounded = display.length > RESTORE_PREVIEW_PATH_MAX ? `…${display.slice(-(RESTORE_PREVIEW_PATH_MAX - 1))}` : display;
102
- return ` ${bounded}`;
103
- });
104
- if (changedPaths.length > RESTORE_PREVIEW_LIMIT) {
105
- lines.push(` … +${changedPaths.length - RESTORE_PREVIEW_LIMIT} more`);
106
- }
107
- return lines.join("\n");
108
- }
109
- // ---- extension entry ------------------------------------------------------
110
- export default function rewind(pi) {
111
- // session_start: rebuild the index, migrate fork/resume blobs, reclaim storage.
112
- pi.on("session_start", async (event, ctx) => {
113
- config = reloadRewindConfig();
114
- const sid = ctx.sessionManager.getSessionId();
115
- if (!sid)
116
- return;
117
- registerSession(sid, ctx.cwd);
118
- const snapshots = rebuildSnapshots(ctx);
119
- // Migrate BEFORE rebuilding in-memory state: restoreStateFromSnapshots
120
- // prunes over-cap blobs from THIS session's directory (fire-and-forget),
121
- // and linking only the retained frames first keeps the two steps disjoint
122
- // — no race, and dropped frames' blobs are never linked at all.
123
- if ((event.reason === "resume" || event.reason === "fork") && event.previousSessionFile) {
124
- const prevSid = sessionIdFromFile(event.previousSessionFile);
125
- if (prevSid) {
126
- try {
127
- await migrateBackupsFromSession(prevSid, sid, capSnapshots(snapshots, config.maxSnapshots));
128
- }
129
- catch {
130
- // best-effort; a missing blob just means that version can't restore
131
- }
132
- }
133
- }
134
- restoreStateFromSnapshots(sid, ctx.cwd, snapshots, config.maxSnapshots);
135
- markAnchorScanStart(sid, ctx);
136
- try {
137
- runGc(config.retentionDays, sid);
138
- }
139
- catch {
140
- // GC is best-effort; never block startup
141
- }
142
- });
143
- // tool_call: back up the target file BEFORE the edit/write lands. Synchronous
144
- // so the backup is on disk before the hook returns control to the agent loop.
145
- pi.on("tool_call", (event, ctx) => {
146
- if (event.toolName !== "edit" && event.toolName !== "write")
147
- return;
148
- if (!config.enabled)
149
- return;
150
- const sid = ctx.sessionManager.getSessionId();
151
- if (!sid)
152
- return;
153
- const rawPath = editWriteTargetPath(event.input);
154
- if (!rawPath)
155
- return;
156
- const abs = resolveToolPath(rawPath, ctx.cwd);
157
- try {
158
- trackEdit(sid, abs);
159
- }
160
- catch {
161
- // never block the edit on a backup failure
162
- }
163
- });
164
- // before_agent_start: open the turn's snapshot frame.
165
- pi.on("before_agent_start", async (event, ctx) => {
166
- // Memory-cached; session_start reloads disk, /rewind save updates cache.
167
- config = loadRewindConfig();
168
- const sid = ctx.sessionManager.getSessionId();
169
- if (!sid)
170
- return;
171
- // The run's user entry is appended after this hook; the frame's anchor is
172
- // the first user entry that appears past this leaf.
173
- markAnchorScanStart(sid, ctx);
174
- if (!config.enabled)
175
- return;
176
- pendingPrompt.set(sid, event.prompt ?? "");
177
- try {
178
- await beginTurn(sid);
179
- }
180
- catch {
181
- // non-fatal
182
- }
183
- });
184
- // agent_settled: finalize + persist after Pi will not auto-continue (retry /
185
- // compact-retry / follow-up). agent_end alone is too early for that.
186
- pi.on("agent_settled", async (_event, ctx) => {
187
- if (!config.enabled)
188
- return;
189
- const sid = ctx.sessionManager.getSessionId();
190
- if (!sid)
191
- return;
192
- // Anchor = the run's FIRST appended user entry (whose start the frame
193
- // recorded). Steering/follow-up messages consumed in the same run append
194
- // later user entries and must not steal the anchor. Unresolvable (scan
195
- // start missing / off-branch / no user entry appended) -> endTurn discards.
196
- const scanStart = anchorScanStart.get(sid);
197
- const userEntryId = scanStart === undefined ? "" : (firstUserEntryIdAfter(ctx.sessionManager.getBranch(), scanStart) ?? "");
198
- const turnId = ctx.sessionManager.getLeafId() ?? userEntryId;
199
- const prompt = truncateText(pendingPrompt.get(sid) ?? "", 120, { collapseWhitespace: true });
200
- pendingPrompt.delete(sid);
201
- const frame = endTurn(sid, userEntryId, turnId, prompt, new Date().toISOString(), config.maxSnapshots);
202
- if (frame) {
203
- pi.appendEntry(SNAPSHOT_ENTRY_TYPE, frame);
204
- }
205
- // Next run may start without before_agent_start (custom-triggered): scan
206
- // from the settled leaf (past this run's entries + the snapshot entry).
207
- markAnchorScanStart(sid, ctx);
208
- });
209
- // session_before_tree: offer to sync files when navigating to a changed point.
210
- pi.on("session_before_tree", async (event, ctx) => {
211
- const sid = ctx.sessionManager.getSessionId();
212
- if (!sid)
213
- return;
214
- pendingTreeRestore.set(sid, null);
215
- if (!config.enabled)
216
- return;
217
- const target = snapshotForEntry(getSnapshots(sid), sessionTreeView(ctx), event.preparation.targetId);
218
- if (!target)
219
- return;
220
- const changed = await snapshotChangedPaths(sid, target);
221
- if (changed.length === 0)
222
- return; // silent nav, like native /tree
223
- // Lifecycle handler: silent-return without UI. (hasUI is the guard for
224
- // ctx.ui.*; checking ctx.mode here would wrongly proceed when a TUI
225
- // session has no usable UI.)
226
- if (!ctx.hasUI)
227
- return;
228
- const n = changed.length;
229
- let lineStats = "";
230
- try {
231
- const stats = await snapshotChangeDiffStats(sid, target, changed);
232
- if (stats.insertions > 0 || stats.deletions > 0) {
233
- lineStats = ` (+${stats.insertions} / −${stats.deletions})`;
234
- }
235
- }
236
- catch {
237
- // Coarse stats are best-effort; still offer path preview.
238
- }
239
- const choice = await ctx.ui.select(`Restore ${n} file${n === 1 ? "" : "s"} to this point?${lineStats}\n${formatRestorePreview(changed, ctx.cwd)}\n (covers edit/write changes only; files changed via bash are not tracked)`, ["Yes, restore files", "No, conversation only"]);
240
- if (choice?.startsWith("Yes")) {
241
- // Cache paths so session_tree can apply without a second full compare.
242
- pendingTreeRestore.set(sid, { snapshot: target, changedPaths: changed });
243
- }
244
- });
245
- // session_tree: execute any sync intent recorded above.
246
- pi.on("session_tree", async (_event, ctx) => {
247
- const sid = ctx.sessionManager.getSessionId();
248
- if (!sid)
249
- return;
250
- // The leaf moved; the old scan start may now be off-branch. Re-mark so a
251
- // custom-triggered run after navigation still anchors correctly.
252
- markAnchorScanStart(sid, ctx);
253
- const pending = pendingTreeRestore.get(sid);
254
- pendingTreeRestore.set(sid, null);
255
- if (!pending)
256
- return;
257
- try {
258
- const changed = await restoreToSnapshot(sid, pending.snapshot, {
259
- onlyPaths: new Set(pending.changedPaths),
260
- });
261
- if (changed.length > 0) {
262
- ctx.ui.notify(`Restored ${changed.length} file${changed.length === 1 ? "" : "s"} to this checkpoint.`, "info");
263
- }
264
- }
265
- catch (e) {
266
- ctx.ui.notify(`Rewind restore failed: ${String(e)}`, "warning");
267
- }
268
- });
269
- // session_shutdown: drop this session's in-memory state.
270
- pi.on("session_shutdown", async (_event, ctx) => {
271
- const sid = ctx.sessionManager.getSessionId();
272
- if (!sid)
273
- return;
274
- disposeSession(sid);
275
- pendingTreeRestore.delete(sid);
276
- pendingPrompt.delete(sid);
277
- anchorScanStart.delete(sid);
278
- });
279
- // /rewind: settings + storage menu (time-travel itself is via /tree).
280
- pi.registerCommand("rewind", {
281
- description: "Rewind settings and backup storage (restore is via /tree)",
282
- handler: async (_args, ctx) => {
283
- await runRewindMenu(ctx);
284
- },
285
- });
286
- }
287
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/rewind/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAqB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EACN,SAAS,EACT,YAAY,EACZ,cAAc,EACd,OAAO,EACP,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,yBAAyB,EACzB,SAAS,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CA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QAC1B,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,sEAAsE;IACtE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE;QAC5B,WAAW,EAAE,2DAA2D;QACxE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * rewind — file-backed checkpoint & rewind for Pi.\n *\n * Engine: instead of snapshotting the whole work tree into a per-session shadow\n * git repo (the old design, which froze the UI in large directories like a\n * multi-project parent folder and grew storage without bound), we back up ONLY\n * the files Pi's edit/write tools are about to modify — one copyFile before each\n * edit (see engine.ts, ported from Claude Code's file-history). Cost is\n * proportional to how many files Pi changed, never to project size.\n *\n * Per turn: before_agent_start opens a snapshot frame (re-recording tracked files\n * at their turn-start state); tool_call(edit|write) backs up each newly edited\n * file before it lands; agent_settled persists the frame to the session JSONL\n * (custom \"pi-rewind-snapshot\" entry) when it changed. agent_settled is used\n * instead of agent_end so auto-retry, overflow compaction-retry, and queued\n * follow-ups stay in one logical turn (agent_end can fire mid-continuation).\n * The frame anchors to the FIRST user entry the run appended (tracked via\n * anchorScanStart + anchor.ts) — the entry whose start the frame recorded;\n * steering/follow-up messages append later user entries that must not steal\n * the anchor. On session_start the index is rebuilt from those entries;\n * resume/fork hard-links the prior session's blobs.\n *\n * Time-travel is fused into /tree: navigating to a node whose turn changed files\n * offers to sync the work tree to that point (session_before_tree/session_tree).\n * Snapshot selection mirrors navigateTree's leaf rules (see restore.ts).\n * /rewind itself is a settings + storage menu (menu.ts), not a restore picker.\n *\n * Restore safety: applySnapshot only rewrites files that differ and never throws\n * out — a broken backup degrades to \"leave the file alone\", so it can never abort\n * the user's session.\n *\n * Architecture informed by oh-my-pi (GPL-3.0) and Claude Code's file-history;\n * independent implementation. No ANSI: all UI is native (ctx.ui.* + theme).\n */\nimport path from \"node:path\";\n\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../core/extensions/types.ts\";\n\nimport { firstUserEntryIdAfter } from \"./anchor.ts\";\nimport { loadRewindConfig, type RewindConfig, reloadRewindConfig } from \"./config.ts\";\nimport {\n\tbeginTurn,\n\tcapSnapshots,\n\tdisposeSession,\n\tendTurn,\n\tgetSnapshots,\n\tmigrateBackupsFromSession,\n\tregisterSession,\n\trestoreStateFromSnapshots,\n\ttrackEdit,\n} from \"./engine.ts\";\nimport { runGc, sessionIdFromFile } from \"./gc.ts\";\nimport { runRewindMenu } from \"./menu.ts\";\nimport { rewindBackupsRoot, sessionsDirectory } from \"./paths.ts\";\nimport {\n\ttype EntryTreeView,\n\trestoreToSnapshot,\n\tsnapshotChangeDiffStats,\n\tsnapshotChangedPaths,\n\tsnapshotForEntry,\n} from \"./restore.ts\";\nimport { type FileHistorySnapshot, isSnapshot, SNAPSHOT_ENTRY_TYPE } from \"./snapshot.ts\";\nimport { configureStorage } from \"./storage.ts\";\nimport { truncateText } from \"./text.ts\";\nimport { editWriteTargetPath, resolveToolPath } from \"./tool-path.ts\";\n\n// Bind the engine/gc storage roots to the real on-disk locations (they avoid\n// importing paths.ts directly so they stay node-testable). Safe to call at load.\nconfigureStorage({ backupsRoot: rewindBackupsRoot(), sessionsRoot: sessionsDirectory() });\n\n// Global (one config.json). Reloaded from disk at session_start; /rewind menu\n// saveRewindConfig updates the in-memory cache so the next turn sees changes\n// without re-reading the file every before_agent_start.\nlet config: RewindConfig = loadRewindConfig();\n\n/** /tree confirm → apply payload (changedPaths skips a second originChanged pass). */\ninterface PendingTreeRestore {\n\tsnapshot: FileHistorySnapshot;\n\tchangedPaths: string[];\n}\n\n// Per-session transient state held by the integration layer.\nconst pendingPrompt = new Map<string, string>(); // turn prompt, captured for the snapshot label\nconst pendingTreeRestore = new Map<string, PendingTreeRestore | null>(); // /tree sync intent\n// Leaf id before the current run started (null = branch root). agent_settled\n// scans forward from here for the run's FIRST user entry — the frame's anchor.\nconst anchorScanStart = new Map<string, string | null>();\n\n// ---- helpers --------------------------------------------------------------\n\n/** Record the current leaf as the scan start for the next frame's anchor. */\nfunction markAnchorScanStart(sid: string, ctx: ExtensionContext): void {\n\tanchorScanStart.set(sid, ctx.sessionManager.getLeafId() ?? null);\n}\n\n/** Adapt the session manager to restore.ts's tree view (turn-anchor = navigateTree's \"leaf = parent\" entries). */\nfunction sessionTreeView(ctx: ExtensionContext): EntryTreeView {\n\treturn {\n\t\tgetEntry(id) {\n\t\t\tconst e = ctx.sessionManager.getEntry(id);\n\t\t\tif (!e) return undefined;\n\t\t\tconst isTurnAnchor =\n\t\t\t\t(e.type === \"message\" && (e.message as AgentMessage).role === \"user\") || e.type === \"custom_message\";\n\t\t\treturn { id: e.id, parentId: e.parentId, isTurnAnchor };\n\t\t},\n\t};\n}\n\n/** Rebuild the snapshot list for a session from its persisted custom entries. */\nfunction rebuildSnapshots(ctx: ExtensionContext): FileHistorySnapshot[] {\n\tconst out: FileHistorySnapshot[] = [];\n\tfor (const entry of ctx.sessionManager.getEntries()) {\n\t\tif (entry.type === \"custom\" && entry.customType === SNAPSHOT_ENTRY_TYPE && isSnapshot(entry.data)) {\n\t\t\tout.push(entry.data);\n\t\t}\n\t}\n\treturn out;\n}\n\n/** Max files listed in the /tree restore confirmation before \"+N more\". */\nconst RESTORE_PREVIEW_LIMIT = 8;\n/** Max characters per previewed path (leading-truncated: the filename matters most). */\nconst RESTORE_PREVIEW_PATH_MAX = 64;\n\n/**\n * Bounded cwd-relative file list shown under the /tree restore question, so an\n * irreversible work-tree rewrite is confirmed against WHICH files, not just a\n * count. Multi-line select titles are upstream-sanctioned (ui.confirm joins\n * title + message with \\n through the same selector).\n */\nfunction formatRestorePreview(changedPaths: string[], cwd: string): string {\n\tconst lines = changedPaths.slice(0, RESTORE_PREVIEW_LIMIT).map((p) => {\n\t\tconst rel = path.relative(cwd, p);\n\t\tconst display = rel && !rel.startsWith(\"..\") && !path.isAbsolute(rel) ? rel : p;\n\t\tconst bounded =\n\t\t\tdisplay.length > RESTORE_PREVIEW_PATH_MAX ? `…${display.slice(-(RESTORE_PREVIEW_PATH_MAX - 1))}` : display;\n\t\treturn ` ${bounded}`;\n\t});\n\tif (changedPaths.length > RESTORE_PREVIEW_LIMIT) {\n\t\tlines.push(` … +${changedPaths.length - RESTORE_PREVIEW_LIMIT} more`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n// ---- extension entry ------------------------------------------------------\n\nexport default function rewind(pi: ExtensionAPI): void {\n\t// session_start: rebuild the index, migrate fork/resume blobs, reclaim storage.\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tconfig = reloadRewindConfig();\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\tregisterSession(sid, ctx.cwd);\n\n\t\tconst snapshots = rebuildSnapshots(ctx);\n\n\t\t// Migrate BEFORE rebuilding in-memory state: restoreStateFromSnapshots\n\t\t// prunes over-cap blobs from THIS session's directory (fire-and-forget),\n\t\t// and linking only the retained frames first keeps the two steps disjoint\n\t\t// — no race, and dropped frames' blobs are never linked at all.\n\t\tif ((event.reason === \"resume\" || event.reason === \"fork\") && event.previousSessionFile) {\n\t\t\tconst prevSid = sessionIdFromFile(event.previousSessionFile);\n\t\t\tif (prevSid) {\n\t\t\t\ttry {\n\t\t\t\t\tawait migrateBackupsFromSession(prevSid, sid, capSnapshots(snapshots, config.maxSnapshots));\n\t\t\t\t} catch {\n\t\t\t\t\t// best-effort; a missing blob just means that version can't restore\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trestoreStateFromSnapshots(sid, ctx.cwd, snapshots, config.maxSnapshots);\n\t\tmarkAnchorScanStart(sid, ctx);\n\n\t\ttry {\n\t\t\trunGc(config.retentionDays, sid);\n\t\t} catch {\n\t\t\t// GC is best-effort; never block startup\n\t\t}\n\t});\n\n\t// tool_call: back up the target file BEFORE the edit/write lands. Synchronous\n\t// so the backup is on disk before the hook returns control to the agent loop.\n\tpi.on(\"tool_call\", (event, ctx) => {\n\t\tif (event.toolName !== \"edit\" && event.toolName !== \"write\") return;\n\t\tif (!config.enabled) return;\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\tconst rawPath = editWriteTargetPath(event.input);\n\t\tif (!rawPath) return;\n\t\tconst abs = resolveToolPath(rawPath, ctx.cwd);\n\t\ttry {\n\t\t\ttrackEdit(sid, abs);\n\t\t} catch {\n\t\t\t// never block the edit on a backup failure\n\t\t}\n\t});\n\n\t// before_agent_start: open the turn's snapshot frame.\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\t// Memory-cached; session_start reloads disk, /rewind save updates cache.\n\t\tconfig = loadRewindConfig();\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\t// The run's user entry is appended after this hook; the frame's anchor is\n\t\t// the first user entry that appears past this leaf.\n\t\tmarkAnchorScanStart(sid, ctx);\n\t\tif (!config.enabled) return;\n\t\tpendingPrompt.set(sid, event.prompt ?? \"\");\n\t\ttry {\n\t\t\tawait beginTurn(sid);\n\t\t} catch {\n\t\t\t// non-fatal\n\t\t}\n\t});\n\n\t// agent_settled: finalize + persist after Pi will not auto-continue (retry /\n\t// compact-retry / follow-up). agent_end alone is too early for that.\n\tpi.on(\"agent_settled\", async (_event, ctx) => {\n\t\tif (!config.enabled) return;\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\t// Anchor = the run's FIRST appended user entry (whose start the frame\n\t\t// recorded). Steering/follow-up messages consumed in the same run append\n\t\t// later user entries and must not steal the anchor. Unresolvable (scan\n\t\t// start missing / off-branch / no user entry appended) -> endTurn discards.\n\t\tconst scanStart = anchorScanStart.get(sid);\n\t\tconst userEntryId =\n\t\t\tscanStart === undefined ? \"\" : (firstUserEntryIdAfter(ctx.sessionManager.getBranch(), scanStart) ?? \"\");\n\t\tconst turnId = ctx.sessionManager.getLeafId() ?? userEntryId;\n\t\tconst prompt = truncateText(pendingPrompt.get(sid) ?? \"\", 120, { collapseWhitespace: true });\n\t\tpendingPrompt.delete(sid);\n\t\tconst frame = endTurn(sid, userEntryId, turnId, prompt, new Date().toISOString(), config.maxSnapshots);\n\t\tif (frame) {\n\t\t\tpi.appendEntry(SNAPSHOT_ENTRY_TYPE, frame);\n\t\t}\n\t\t// Next run may start without before_agent_start (custom-triggered): scan\n\t\t// from the settled leaf (past this run's entries + the snapshot entry).\n\t\tmarkAnchorScanStart(sid, ctx);\n\t});\n\n\t// session_before_tree: offer to sync files when navigating to a changed point.\n\tpi.on(\"session_before_tree\", async (event, ctx) => {\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\tpendingTreeRestore.set(sid, null);\n\t\tif (!config.enabled) return;\n\n\t\tconst target = snapshotForEntry(getSnapshots(sid), sessionTreeView(ctx), event.preparation.targetId);\n\t\tif (!target) return;\n\t\tconst changed = await snapshotChangedPaths(sid, target);\n\t\tif (changed.length === 0) return; // silent nav, like native /tree\n\t\t// Lifecycle handler: silent-return without UI. (hasUI is the guard for\n\t\t// ctx.ui.*; checking ctx.mode here would wrongly proceed when a TUI\n\t\t// session has no usable UI.)\n\t\tif (!ctx.hasUI) return;\n\n\t\tconst n = changed.length;\n\t\tlet lineStats = \"\";\n\t\ttry {\n\t\t\tconst stats = await snapshotChangeDiffStats(sid, target, changed);\n\t\t\tif (stats.insertions > 0 || stats.deletions > 0) {\n\t\t\t\tlineStats = ` (+${stats.insertions} / −${stats.deletions})`;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Coarse stats are best-effort; still offer path preview.\n\t\t}\n\t\tconst choice = await ctx.ui.select(\n\t\t\t`Restore ${n} file${n === 1 ? \"\" : \"s\"} to this point?${lineStats}\\n${formatRestorePreview(changed, ctx.cwd)}\\n (covers edit/write changes only; files changed via bash are not tracked)`,\n\t\t\t[\"Yes, restore files\", \"No, conversation only\"],\n\t\t);\n\t\tif (choice?.startsWith(\"Yes\")) {\n\t\t\t// Cache paths so session_tree can apply without a second full compare.\n\t\t\tpendingTreeRestore.set(sid, { snapshot: target, changedPaths: changed });\n\t\t}\n\t});\n\n\t// session_tree: execute any sync intent recorded above.\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\t// The leaf moved; the old scan start may now be off-branch. Re-mark so a\n\t\t// custom-triggered run after navigation still anchors correctly.\n\t\tmarkAnchorScanStart(sid, ctx);\n\t\tconst pending = pendingTreeRestore.get(sid);\n\t\tpendingTreeRestore.set(sid, null);\n\t\tif (!pending) return;\n\t\ttry {\n\t\t\tconst changed = await restoreToSnapshot(sid, pending.snapshot, {\n\t\t\t\tonlyPaths: new Set(pending.changedPaths),\n\t\t\t});\n\t\t\tif (changed.length > 0) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Restored ${changed.length} file${changed.length === 1 ? \"\" : \"s\"} to this checkpoint.`,\n\t\t\t\t\t\"info\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tctx.ui.notify(`Rewind restore failed: ${String(e)}`, \"warning\");\n\t\t}\n\t});\n\n\t// session_shutdown: drop this session's in-memory state.\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tconst sid = ctx.sessionManager.getSessionId();\n\t\tif (!sid) return;\n\t\tdisposeSession(sid);\n\t\tpendingTreeRestore.delete(sid);\n\t\tpendingPrompt.delete(sid);\n\t\tanchorScanStart.delete(sid);\n\t});\n\n\t// /rewind: settings + storage menu (time-travel itself is via /tree).\n\tpi.registerCommand(\"rewind\", {\n\t\tdescription: \"Rewind settings and backup storage (restore is via /tree)\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tawait runRewindMenu(ctx);\n\t\t},\n\t});\n}\n"]}
@@ -1,13 +0,0 @@
1
- /**
2
- * menu.ts — the `/rewind` settings menu.
3
- *
4
- * Per the design, /rewind no longer performs the time-travel itself — restoring
5
- * files is fused into /tree navigation (see index.ts session_before_tree/
6
- * session_tree). /rewind is purely a settings + storage console:
7
- * - toggle the master switch
8
- * - set the auto-clean retention window
9
- * - inspect and prune backup storage (aged / orphaned / all-but-current)
10
- */
11
- import type { ExtensionCommandContext } from "../../core/extensions/types.ts";
12
- export declare function runRewindMenu(ctx: ExtensionCommandContext): Promise<void>;
13
- //# sourceMappingURL=menu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/extensions/rewind/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAW9E,wBAAsB,aAAa,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B/E"}
@@ -1,123 +0,0 @@
1
- import { loadRewindConfig, saveRewindConfig } from "./config.js";
2
- import { listSessions, removeSession, runGc } from "./gc.js";
3
- import { formatSize } from "./text.js";
4
- const RETENTION_PRESETS = [7, 14, 30, 60, 90];
5
- /** Backup dirs written to this recently likely belong to a live session in another Pi process. */
6
- const RECENT_ACTIVE_MS = 10 * 60 * 1000;
7
- export async function runRewindMenu(ctx) {
8
- if (!ctx.hasUI) {
9
- ctx.ui.notify("/rewind requires an interactive UI.", "warning");
10
- return;
11
- }
12
- const sid = ctx.sessionManager.getSessionId() ?? undefined;
13
- for (;;) {
14
- const cfg = loadRewindConfig();
15
- const sessions = listSessions(sid);
16
- const total = sessions.reduce((n, s) => n + s.bytes, 0);
17
- const enabledLabel = `Rewind: ${cfg.enabled ? "on" : "off"}`;
18
- const retentionLabel = `Auto-clean backups: ${cfg.retentionDays > 0 ? `after ${cfg.retentionDays} days` : "never (keep forever)"}`;
19
- const storageLabel = `Storage: ${formatSize(total)} across ${sessions.length} session${sessions.length === 1 ? "" : "s"}`;
20
- const pick = await ctx.ui.select("Rewind settings (Esc to close)", [enabledLabel, retentionLabel, storageLabel]);
21
- if (!pick)
22
- return;
23
- if (pick === enabledLabel) {
24
- saveRewindConfig({ ...cfg, enabled: !cfg.enabled });
25
- ctx.ui.notify(`Rewind ${cfg.enabled ? "disabled" : "enabled"}.`, "info");
26
- }
27
- else if (pick === retentionLabel) {
28
- await pickRetention(ctx);
29
- }
30
- else if (pick === storageLabel) {
31
- await storageMenu(ctx, sid);
32
- }
33
- }
34
- }
35
- async function pickRetention(ctx) {
36
- const options = [...RETENTION_PRESETS.map((d) => `${d} days`), "Keep forever", "Custom..."];
37
- const pick = await ctx.ui.select("Auto-clean backups after", options);
38
- if (!pick)
39
- return;
40
- let days;
41
- if (pick === "Keep forever") {
42
- days = 0;
43
- }
44
- else if (pick === "Custom...") {
45
- const value = await ctx.ui.input("Days to keep backups (0 = forever)");
46
- if (value === undefined)
47
- return;
48
- const n = Number.parseInt(value.trim(), 10);
49
- if (!Number.isFinite(n) || n < 0) {
50
- ctx.ui.notify("Invalid number of days.", "warning");
51
- return;
52
- }
53
- days = n;
54
- }
55
- else {
56
- days = Number.parseInt(pick, 10);
57
- }
58
- const cfg = loadRewindConfig();
59
- saveRewindConfig({ ...cfg, retentionDays: days });
60
- ctx.ui.notify(days > 0 ? `Backups now kept for ${days} days.` : "Backups kept forever.", "info");
61
- }
62
- async function storageMenu(ctx, sid) {
63
- for (;;) {
64
- const sessions = listSessions(sid);
65
- const total = sessions.reduce((n, s) => n + s.bytes, 0);
66
- const orphans = sessions.filter((s) => s.orphan);
67
- // Skip recently-written dirs: they may belong to another running Pi
68
- // process whose in-memory index still references those blobs.
69
- const now = Date.now();
70
- const others = sessions.filter((s) => s.sessionId !== sid && now - s.mtimeMs > RECENT_ACTIVE_MS);
71
- const cleanLabel = "Clean now (aged + orphaned)";
72
- const orphanLabel = `Remove orphaned (${orphans.length})`;
73
- const allLabel = `Remove all except current (${others.length})`;
74
- const pick = await ctx.ui.select(`Rewind storage — ${formatSize(total)}, ${sessions.length} session${sessions.length === 1 ? "" : "s"} (Esc to close)`, [cleanLabel, orphanLabel, allLabel]);
75
- if (!pick)
76
- return;
77
- if (pick === cleanLabel) {
78
- const r = runGc(loadRewindConfig().retentionDays, sid);
79
- ctx.ui.notify(r.removed > 0
80
- ? `Removed ${r.removed} session(s), reclaimed ${formatSize(r.reclaimedBytes)}.`
81
- : "Nothing to clean.", "info");
82
- }
83
- else if (pick === orphanLabel) {
84
- if (orphans.length === 0) {
85
- ctx.ui.notify("No orphaned backups.", "info");
86
- continue;
87
- }
88
- const ok = await ctx.ui.confirm("Remove orphaned backups?", `Deletes backups for ${orphans.length} session(s) with no session file.`);
89
- if (!ok)
90
- continue;
91
- let bytes = 0;
92
- let removed = 0;
93
- for (const s of orphans) {
94
- const b = removeSession(s.sessionId);
95
- if (b !== null) {
96
- bytes += b;
97
- removed++;
98
- }
99
- }
100
- ctx.ui.notify(`Removed ${removed} orphaned session(s), reclaimed ${formatSize(bytes)}.`, "info");
101
- }
102
- else if (pick === allLabel) {
103
- if (others.length === 0) {
104
- ctx.ui.notify("No other sessions' backups.", "info");
105
- continue;
106
- }
107
- const ok = await ctx.ui.confirm("Remove all other backups?", `Deletes backups for ${others.length} session(s). Keeps the current session and any written to in the last 10 minutes (possibly running elsewhere).`);
108
- if (!ok)
109
- continue;
110
- let bytes = 0;
111
- let removed = 0;
112
- for (const s of others) {
113
- const b = removeSession(s.sessionId);
114
- if (b !== null) {
115
- bytes += b;
116
- removed++;
117
- }
118
- }
119
- ctx.ui.notify(`Removed ${removed} session(s), reclaimed ${formatSize(bytes)}.`, "info");
120
- }
121
- }
122
- }
123
- //# sourceMappingURL=menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../../src/extensions/rewind/menu.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAA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gBACX,CAAC;YACF,CAAC;YACD,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,OAAO,0BAA0B,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/**\n * menu.ts — the `/rewind` settings menu.\n *\n * Per the design, /rewind no longer performs the time-travel itself — restoring\n * files is fused into /tree navigation (see index.ts session_before_tree/\n * session_tree). /rewind is purely a settings + storage console:\n * - toggle the master switch\n * - set the auto-clean retention window\n * - inspect and prune backup storage (aged / orphaned / all-but-current)\n */\nimport type { ExtensionCommandContext } from \"../../core/extensions/types.ts\";\n\nimport { loadRewindConfig, saveRewindConfig } from \"./config.ts\";\nimport { listSessions, removeSession, runGc } from \"./gc.ts\";\nimport { formatSize } from \"./text.ts\";\n\nconst RETENTION_PRESETS = [7, 14, 30, 60, 90];\n\n/** Backup dirs written to this recently likely belong to a live session in another Pi process. */\nconst RECENT_ACTIVE_MS = 10 * 60 * 1000;\n\nexport async function runRewindMenu(ctx: ExtensionCommandContext): Promise<void> {\n\tif (!ctx.hasUI) {\n\t\tctx.ui.notify(\"/rewind requires an interactive UI.\", \"warning\");\n\t\treturn;\n\t}\n\tconst sid = ctx.sessionManager.getSessionId() ?? undefined;\n\n\tfor (;;) {\n\t\tconst cfg = loadRewindConfig();\n\t\tconst sessions = listSessions(sid);\n\t\tconst total = sessions.reduce((n, s) => n + s.bytes, 0);\n\n\t\tconst enabledLabel = `Rewind: ${cfg.enabled ? \"on\" : \"off\"}`;\n\t\tconst retentionLabel = `Auto-clean backups: ${cfg.retentionDays > 0 ? `after ${cfg.retentionDays} days` : \"never (keep forever)\"}`;\n\t\tconst storageLabel = `Storage: ${formatSize(total)} across ${sessions.length} session${sessions.length === 1 ? \"\" : \"s\"}`;\n\n\t\tconst pick = await ctx.ui.select(\"Rewind settings (Esc to close)\", [enabledLabel, retentionLabel, storageLabel]);\n\t\tif (!pick) return;\n\n\t\tif (pick === enabledLabel) {\n\t\t\tsaveRewindConfig({ ...cfg, enabled: !cfg.enabled });\n\t\t\tctx.ui.notify(`Rewind ${cfg.enabled ? \"disabled\" : \"enabled\"}.`, \"info\");\n\t\t} else if (pick === retentionLabel) {\n\t\t\tawait pickRetention(ctx);\n\t\t} else if (pick === storageLabel) {\n\t\t\tawait storageMenu(ctx, sid);\n\t\t}\n\t}\n}\n\nasync function pickRetention(ctx: ExtensionCommandContext): Promise<void> {\n\tconst options = [...RETENTION_PRESETS.map((d) => `${d} days`), \"Keep forever\", \"Custom...\"];\n\tconst pick = await ctx.ui.select(\"Auto-clean backups after\", options);\n\tif (!pick) return;\n\n\tlet days: number;\n\tif (pick === \"Keep forever\") {\n\t\tdays = 0;\n\t} else if (pick === \"Custom...\") {\n\t\tconst value = await ctx.ui.input(\"Days to keep backups (0 = forever)\");\n\t\tif (value === undefined) return;\n\t\tconst n = Number.parseInt(value.trim(), 10);\n\t\tif (!Number.isFinite(n) || n < 0) {\n\t\t\tctx.ui.notify(\"Invalid number of days.\", \"warning\");\n\t\t\treturn;\n\t\t}\n\t\tdays = n;\n\t} else {\n\t\tdays = Number.parseInt(pick, 10);\n\t}\n\n\tconst cfg = loadRewindConfig();\n\tsaveRewindConfig({ ...cfg, retentionDays: days });\n\tctx.ui.notify(days > 0 ? `Backups now kept for ${days} days.` : \"Backups kept forever.\", \"info\");\n}\n\nasync function storageMenu(ctx: ExtensionCommandContext, sid: string | undefined): Promise<void> {\n\tfor (;;) {\n\t\tconst sessions = listSessions(sid);\n\t\tconst total = sessions.reduce((n, s) => n + s.bytes, 0);\n\t\tconst orphans = sessions.filter((s) => s.orphan);\n\t\t// Skip recently-written dirs: they may belong to another running Pi\n\t\t// process whose in-memory index still references those blobs.\n\t\tconst now = Date.now();\n\t\tconst others = sessions.filter((s) => s.sessionId !== sid && now - s.mtimeMs > RECENT_ACTIVE_MS);\n\n\t\tconst cleanLabel = \"Clean now (aged + orphaned)\";\n\t\tconst orphanLabel = `Remove orphaned (${orphans.length})`;\n\t\tconst allLabel = `Remove all except current (${others.length})`;\n\n\t\tconst pick = await ctx.ui.select(\n\t\t\t`Rewind storage — ${formatSize(total)}, ${sessions.length} session${sessions.length === 1 ? \"\" : \"s\"} (Esc to close)`,\n\t\t\t[cleanLabel, orphanLabel, allLabel],\n\t\t);\n\t\tif (!pick) return;\n\n\t\tif (pick === cleanLabel) {\n\t\t\tconst r = runGc(loadRewindConfig().retentionDays, sid);\n\t\t\tctx.ui.notify(\n\t\t\t\tr.removed > 0\n\t\t\t\t\t? `Removed ${r.removed} session(s), reclaimed ${formatSize(r.reclaimedBytes)}.`\n\t\t\t\t\t: \"Nothing to clean.\",\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t} else if (pick === orphanLabel) {\n\t\t\tif (orphans.length === 0) {\n\t\t\t\tctx.ui.notify(\"No orphaned backups.\", \"info\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst ok = await ctx.ui.confirm(\n\t\t\t\t\"Remove orphaned backups?\",\n\t\t\t\t`Deletes backups for ${orphans.length} session(s) with no session file.`,\n\t\t\t);\n\t\t\tif (!ok) continue;\n\t\t\tlet bytes = 0;\n\t\t\tlet removed = 0;\n\t\t\tfor (const s of orphans) {\n\t\t\t\tconst b = removeSession(s.sessionId);\n\t\t\t\tif (b !== null) {\n\t\t\t\t\tbytes += b;\n\t\t\t\t\tremoved++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.ui.notify(`Removed ${removed} orphaned session(s), reclaimed ${formatSize(bytes)}.`, \"info\");\n\t\t} else if (pick === allLabel) {\n\t\t\tif (others.length === 0) {\n\t\t\t\tctx.ui.notify(\"No other sessions' backups.\", \"info\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst ok = await ctx.ui.confirm(\n\t\t\t\t\"Remove all other backups?\",\n\t\t\t\t`Deletes backups for ${others.length} session(s). Keeps the current session and any written to in the last 10 minutes (possibly running elsewhere).`,\n\t\t\t);\n\t\t\tif (!ok) continue;\n\t\t\tlet bytes = 0;\n\t\t\tlet removed = 0;\n\t\t\tfor (const s of others) {\n\t\t\t\tconst b = removeSession(s.sessionId);\n\t\t\t\tif (b !== null) {\n\t\t\t\t\tbytes += b;\n\t\t\t\t\tremoved++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.ui.notify(`Removed ${removed} session(s), reclaimed ${formatSize(bytes)}.`, \"info\");\n\t\t}\n\t}\n}\n"]}
@@ -1,4 +0,0 @@
1
- export declare function rewindConfigPath(): string;
2
- export declare function rewindBackupsRoot(): string;
3
- export declare function sessionsDirectory(): string;
4
- //# sourceMappingURL=paths.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/extensions/rewind/paths.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
@@ -1,15 +0,0 @@
1
- import { join } from "node:path";
2
- import { getAgentDir } from "../../config.js";
3
- function rewindDirectory() {
4
- return join(getAgentDir(), "rewind");
5
- }
6
- export function rewindConfigPath() {
7
- return join(rewindDirectory(), "config.json");
8
- }
9
- export function rewindBackupsRoot() {
10
- return join(rewindDirectory(), "backups");
11
- }
12
- export function sessionsDirectory() {
13
- return join(getAgentDir(), "sessions");
14
- }
15
- //# sourceMappingURL=paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/extensions/rewind/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,SAAS,eAAe;IACvB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC/B,OAAO,IAAI,CAAC,eAAe,EAAE,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,iBAAiB;IAChC,OAAO,IAAI,CAAC,eAAe,EAAE,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,iBAAiB;IAChC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { join } from \"node:path\";\n\nimport { getAgentDir } from \"../../config.ts\";\n\nfunction rewindDirectory(): string {\n\treturn join(getAgentDir(), \"rewind\");\n}\n\nexport function rewindConfigPath(): string {\n\treturn join(rewindDirectory(), \"config.json\");\n}\n\nexport function rewindBackupsRoot(): string {\n\treturn join(rewindDirectory(), \"backups\");\n}\n\nexport function sessionsDirectory(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n"]}
@@ -1,54 +0,0 @@
1
- /**
2
- * restore.ts — map a /tree navigation target to the snapshot that should be
3
- * restored and apply it via the engine.
4
- *
5
- * Snapshot semantics: a frame anchored at user entry U records the work tree
6
- * at the moment U's run STARTED (see engine.ts beginTurn). The selection here
7
- * must mirror AgentSession.navigateTree's leaf rules:
8
- *
9
- * - user / custom_message target: navigateTree removes the target's turn
10
- * from the branch (leaf = parent, text returns to the editor) → restore
11
- * to the state BEFORE that turn = the snapshot anchored at the target.
12
- * - any other target: the target's turn STAYS in the conversation
13
- * (leaf = target) → restore to the state AFTER that turn = the first
14
- * chronological snapshot anchored at a descendant turn (it recorded the
15
- * work tree when the next run began). No such snapshot → nothing was
16
- * recorded after the target, so offer no restore at all — falling back to
17
- * an ancestor frame would roll back the target turn's own edits and leave
18
- * the work tree older than the conversation.
19
- */
20
- import { type ApplySnapshotOptions, type CoarseDiffStats } from "./engine.ts";
21
- import type { FileHistorySnapshot } from "./snapshot.ts";
22
- /** Minimal per-entry view needed to walk the tree and classify targets. */
23
- export interface EntryView {
24
- id: string;
25
- parentId: string | null;
26
- /** True for entries navigateTree treats as turn starts (user / custom_message → leaf = parent). */
27
- isTurnAnchor: boolean;
28
- }
29
- /** Minimal session view we need to walk the entry tree. */
30
- export interface EntryTreeView {
31
- getEntry(id: string): EntryView | undefined;
32
- }
33
- /**
34
- * The snapshot that matches navigating to `targetId`, per the rules in the
35
- * module header. Undefined when no recorded state corresponds to the target
36
- * (then the work tree should be left alone).
37
- */
38
- export declare function snapshotForEntry(snapshots: FileHistorySnapshot[], view: EntryTreeView, targetId: string): FileHistorySnapshot | undefined;
39
- /**
40
- * Absolute file paths restoring to this snapshot would change on disk (empty =
41
- * none). Callers use the length for the count and the paths for the preview.
42
- */
43
- export declare function snapshotChangedPaths(sessionId: string, snapshot: FileHistorySnapshot): Promise<string[]>;
44
- /**
45
- * Coarse +N/−M line stats for the confirm dialog (paths must already be known
46
- * changed — typically from snapshotChangedPaths).
47
- */
48
- export declare function snapshotChangeDiffStats(sessionId: string, snapshot: FileHistorySnapshot, changedPaths: readonly string[]): Promise<CoarseDiffStats>;
49
- /**
50
- * Restore the work tree to `snapshot` and return changed absolute paths.
51
- * Pass `onlyPaths` from a prior snapshotChangedPaths call to skip re-compare.
52
- */
53
- export declare function restoreToSnapshot(sessionId: string, snapshot: FileHistorySnapshot, opts?: ApplySnapshotOptions): Promise<string[]>;
54
- //# sourceMappingURL=restore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/extensions/rewind/restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACN,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EAGpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mGAAmG;IACnG,YAAY,EAAE,OAAO,CAAC;CACtB;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CAC5C;AAiCD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,mBAAmB,EAAE,EAChC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,MAAM,GACd,mBAAmB,GAAG,SAAS,CAkBjC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAExG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,mBAAmB,EAC7B,YAAY,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAAC,eAAe,CAAC,CAE1B;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,CAAC,EAAE,oBAAoB,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB"}