@codex-infinity/pi-infinity 0.63.2 → 0.63.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.
@@ -39,8 +39,8 @@ You can also trigger manually with `/compact [instructions]`, where optional ins
39
39
  ### How It Works
40
40
 
41
41
  1. **Find cut point**: Walk backwards from newest message, accumulating token estimates until `keepRecentTokens` (default 20k, configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`) is reached
42
- 2. **Extract messages**: Collect messages from previous compaction (or start) up to cut point
43
- 3. **Generate summary**: Call LLM to summarize with structured format
42
+ 2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
43
+ 3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
44
44
  4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
45
45
  5. **Reload**: Session reloads, using summary + messages from `firstKeptEntryId` onwards
46
46
 
@@ -76,6 +76,8 @@ What the LLM sees:
76
76
  prompt from cmp messages from firstKeptEntryId
77
77
  ```
78
78
 
79
+ On repeated compactions, the summarized span starts at the previous compaction's kept boundary (`firstKeptEntryId`), not at the compaction entry itself, falling back to the entry after the previous compaction if that kept entry cannot be found in the path. This preserves messages that survived the earlier compaction by including them in the next summarization pass as well. Pi also recalculates `tokensBefore` from the rebuilt session context before writing the new `CompactionEntry`, so the token count reflects the actual pre-compaction context being replaced.
80
+
79
81
  ### Split Turns
80
82
 
81
83
  A "turn" starts with a user message and includes all assistant responses and tool calls until the next user message. Normally, compaction cuts at turn boundaries.
@@ -629,6 +629,8 @@ Fired after tool execution finishes and before `tool_execution_end` plus the fin
629
629
  - Each handler sees the latest result after previous handler changes
630
630
  - Handlers can return partial patches (`content`, `details`, or `isError`); omitted fields keep their current values
631
631
 
632
+ Use `ctx.signal` for nested async work inside the handler. This lets Esc cancel model calls, `fetch()`, and other abort-aware operations started by the extension.
633
+
632
634
  ```typescript
633
635
  import { isBashToolResult } from "@mariozechner/pi-coding-agent";
634
636
 
@@ -640,6 +642,12 @@ pi.on("tool_result", async (event, ctx) => {
640
642
  // event.details is typed as BashToolDetails
641
643
  }
642
644
 
645
+ const response = await fetch("https://example.com/summarize", {
646
+ method: "POST",
647
+ body: JSON.stringify({ content: event.content }),
648
+ signal: ctx.signal,
649
+ });
650
+
643
651
  // Modify result:
644
652
  return { content: [...], details: {...}, isError: false };
645
653
  });
@@ -759,6 +767,31 @@ ctx.sessionManager.getLeafId() // Current leaf entry ID
759
767
 
760
768
  Access to models and API keys.
761
769
 
770
+ ### ctx.signal
771
+
772
+ The current agent abort signal, or `undefined` when no agent turn is active.
773
+
774
+ Use this for abort-aware nested work started by extension handlers, for example:
775
+ - `fetch(..., { signal: ctx.signal })`
776
+ - model calls that accept `signal`
777
+ - file or process helpers that accept `AbortSignal`
778
+
779
+ `ctx.signal` is typically defined during active turn events such as `tool_call`, `tool_result`, `message_update`, and `turn_end`.
780
+ It is usually `undefined` in idle or non-turn contexts such as session events, extension commands, and shortcuts fired while pi is idle.
781
+
782
+ ```typescript
783
+ pi.on("tool_result", async (event, ctx) => {
784
+ const response = await fetch("https://example.com/api", {
785
+ method: "POST",
786
+ body: JSON.stringify(event),
787
+ signal: ctx.signal,
788
+ });
789
+
790
+ const data = await response.json();
791
+ return { details: data };
792
+ });
793
+ ```
794
+
762
795
  ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
763
796
 
764
797
  Control flow helpers.
@@ -5,6 +5,10 @@
5
5
  * restrictions on bash commands at the OS level (sandbox-exec on macOS,
6
6
  * bubblewrap on Linux).
7
7
  *
8
+ * Note: this example intentionally overrides the built-in `bash` tool to show
9
+ * how built-in tools can be replaced. Alternatively, you could sandbox `bash`
10
+ * via `tool_call` input mutation without replacing the tool.
11
+ *
8
12
  * Config files (merged, project takes precedence):
9
13
  * - ~/.pi/agent/sandbox.json (global)
10
14
  * - <cwd>/.pi/sandbox.json (project-local)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codex-infinity/pi-infinity",
3
- "version": "0.63.2",
3
+ "version": "0.63.3",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -40,9 +40,9 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@mariozechner/jiti": "^2.6.2",
43
- "@mariozechner/pi-agent-core": "^0.63.2",
44
- "@mariozechner/pi-ai": "^0.63.2",
45
- "@mariozechner/pi-tui": "^0.63.2",
43
+ "@mariozechner/pi-agent-core": "^0.63.3",
44
+ "@mariozechner/pi-ai": "^0.63.3",
45
+ "@mariozechner/pi-tui": "^0.63.3",
46
46
  "@silvia-odwyer/photon-node": "^0.3.4",
47
47
  "ajv": "^8.17.1",
48
48
  "chalk": "^5.5.0",