pi-goosedump 0.12.12 → 0.12.14

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 (3) hide show
  1. package/README.md +2 -3
  2. package/dist/index.ts +15 -36
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -98,9 +98,8 @@ that call tools. The countdown is restored when a session resumes and appears in
98
98
  the footer with a status dot (green when >25% turns remain, yellow when ≤25%, red
99
99
  when ≤12.5%) followed by a hexadecimal countdown. `● GD:0A` means ten turns
100
100
  remain, `● GD:00` is ready to compact, and `● GD:--` is disabled. If zero is
101
- reached during a tool loop, the extension finishes the current tool batch, stops
102
- the continuation, compacts after Pi settles, and resumes automatically. A failed
103
- compaction leaves the task paused and the counter armed at zero.
101
+ reached during a tool loop, the extension waits for the agent run to settle and
102
+ then compacts. A failed compaction leaves the counter armed at zero.
104
103
 
105
104
  `summaryMaxTokens` is an integer from 512 to 65536 (default 4096). The effective
106
105
  summary budget is the lower of this value and 80% of Pi's `compaction.reserveTokens`,
package/dist/index.ts CHANGED
@@ -1287,19 +1287,16 @@ async function runSessionsPanel(ctx, executablePath) {
1287
1287
  ctx.ui.notify(`Only Pi sessions can be resumed (session ${s.id} is ${s.provider})`, "warning");
1288
1288
  return;
1289
1289
  }
1290
- const sessionDir = ctx.sessionManager.getSessionDir();
1291
- const sessionPath = join(sessionDir, s.id.endsWith(".jsonl") ? s.id : `${s.id}.jsonl`);
1290
+ const sessionPath = s.path;
1292
1291
  if (!existsSync(sessionPath)) {
1293
1292
  ctx.ui.notify(`Session transcript file not found: ${sessionPath}`, "error");
1294
1293
  return;
1295
1294
  }
1296
1295
  done(undefined);
1297
- const cmdCtx = ctx;
1298
- if (typeof cmdCtx.switchSession === "function") {
1299
- cmdCtx.switchSession(sessionPath);
1300
- } else {
1301
- ctx.ui.notify(`Session switched to ${sessionPath}`, "info");
1302
- }
1296
+ ctx.switchSession(sessionPath).catch((err) => {
1297
+ const message = err instanceof Error ? err.message : String(err);
1298
+ ctx.ui.notify(`Failed to switch session: ${message}`, "error");
1299
+ });
1303
1300
  return;
1304
1301
  }
1305
1302
  },
@@ -1325,7 +1322,6 @@ function createGoosedumpIntegration(options = {}) {
1325
1322
  let compactionQueued = false;
1326
1323
  let compactionHookActive = false;
1327
1324
  let pendingKeep = null;
1328
- let counterInterruptPending = false;
1329
1325
  const rememberQueue = [];
1330
1326
  let rememberRunning = null;
1331
1327
  function enqueueRemember(target, reportError) {
@@ -1393,17 +1389,13 @@ function createGoosedumpIntegration(options = {}) {
1393
1389
  syncCompactCounters(ctx);
1394
1390
  updateStatus(ctx);
1395
1391
  }
1396
- function interruptActiveRunForCompaction(ctx, hasToolResults) {
1397
- if (!counterTriggered || !hasToolResults || ctx.isIdle())
1398
- return;
1399
- if (counterInterruptPending)
1400
- return;
1401
- if (compactionQueued || compactionHookActive || ctx.hasPendingMessages())
1402
- return;
1403
- if (!hasCompactableHistory(ctx))
1404
- return;
1405
- counterInterruptPending = true;
1406
- ctx.abort();
1392
+ function normalThresholdTriggered(ctx) {
1393
+ if (compactSettings.turnsBeforeCompact <= 0)
1394
+ return false;
1395
+ const usage = ctx.getContextUsage();
1396
+ if (!usage || usage.tokens === null || usage.contextWindow <= 0)
1397
+ return false;
1398
+ return usage.tokens > usage.contextWindow - piReserveTokens(ctx.cwd);
1407
1399
  }
1408
1400
  function checkGoosedump(ctx) {
1409
1401
  try {
@@ -1790,7 +1782,9 @@ ${lines.join(`
1790
1782
  function maybeAutoCompact(ctx) {
1791
1783
  if (!goosedumpAvailable || !shouldOverrideDefaultCompaction)
1792
1784
  return;
1793
- if (!counterTriggered || compactionQueued)
1785
+ if (!counterTriggered && !normalThresholdTriggered(ctx))
1786
+ return;
1787
+ if (compactionQueued)
1794
1788
  return;
1795
1789
  if (ctx.hasPendingMessages())
1796
1790
  return;
@@ -1798,8 +1792,6 @@ ${lines.join(`
1798
1792
  return;
1799
1793
  if (!hasCompactableHistory(ctx))
1800
1794
  return;
1801
- const resumeAfter = counterInterruptPending;
1802
- counterInterruptPending = false;
1803
1795
  syncCompactCounters(ctx, true);
1804
1796
  updateStatus(ctx);
1805
1797
  compactionQueued = true;
@@ -1808,7 +1800,6 @@ ${lines.join(`
1808
1800
  compactionQueued = false;
1809
1801
  syncCompactCounters(ctx, true);
1810
1802
  updateStatus(ctx);
1811
- resumeInterruptedRun(ctx, resumeAfter);
1812
1803
  },
1813
1804
  onError: (error) => {
1814
1805
  compactionQueued = false;
@@ -1820,18 +1811,8 @@ ${lines.join(`
1820
1811
  }
1821
1812
  });
1822
1813
  }
1823
- function resumeInterruptedRun(ctx, resume) {
1824
- if (!resume || !ctx.isIdle() || ctx.hasPendingMessages())
1825
- return;
1826
- pi.sendMessage({
1827
- customType: "goosedump-autocompact-resume",
1828
- content: "The session was compacted to reduce context size. Continue the task you were working on from where you left off.",
1829
- display: false
1830
- }, { triggerTurn: true });
1831
- }
1832
1814
  pi.on("session_start", async (_event, ctx) => {
1833
1815
  goosedumpAvailable = checkGoosedump(ctx);
1834
- counterInterruptPending = false;
1835
1816
  notifyInvalidSettings(ctx);
1836
1817
  syncCompactCounters(ctx, true);
1837
1818
  updateStatus(ctx);
@@ -1839,7 +1820,6 @@ ${lines.join(`
1839
1820
  pi.on("turn_end", async (event, ctx) => {
1840
1821
  if (isCompletedAssistant(event.message))
1841
1822
  noteCompletedTurn(ctx);
1842
- interruptActiveRunForCompaction(ctx, event.toolResults.length > 0);
1843
1823
  });
1844
1824
  pi.on("agent_settled", async (_event, ctx) => {
1845
1825
  maybeAutoCompact(ctx);
@@ -1892,7 +1872,6 @@ ${lines.join(`
1892
1872
  return;
1893
1873
  syncCompactCounters(ctx, true);
1894
1874
  updateStatus(ctx);
1895
- counterInterruptPending = false;
1896
1875
  const compactionEntry = event.compactionEntry;
1897
1876
  if (!event.fromExtension || !compactionEntry || !isRecord(compactionEntry.details) || compactionEntry.details.source !== "goosedump") {
1898
1877
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goosedump",
3
- "version": "0.12.12",
3
+ "version": "0.12.14",
4
4
  "description": "Pi extension for goosedump session search, durable memory, and compaction",
5
5
  "keywords": [
6
6
  "compaction",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@earendil-works/pi-tui": "^0.82.1",
41
- "@jarkkojs/goosedump": "^0.12.12",
41
+ "@jarkkojs/goosedump": "^0.12.14",
42
42
  "@sinclair/typebox": "^0.34.49"
43
43
  },
44
44
  "devDependencies": {