shariq-pi-extensions 0.2.34 → 0.2.35

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.
@@ -89,12 +89,25 @@ export function createSmartCompactionExtension(options: SmartCompactionExtension
89
89
 
90
90
  // In-flight context threshold guard:
91
91
  // If consecutive tool calls in a single run exceed 95% of the model's context window,
92
- // immediately trigger compaction before the next step runs away.
92
+ // trigger compaction cleanly and continue the task from the compacted checkpoint.
93
+ let isCompactingInFlight = false;
94
+
93
95
  const checkInFlightUsage = (ctx: ExtensionContext) => {
94
- if (!config.enabled) return;
96
+ if (!config.enabled || isCompactingInFlight) return;
95
97
  const usage = ctx.getContextUsage();
96
98
  if (usage && typeof usage.percent === "number" && usage.percent >= 95) {
97
- ctx.compact();
99
+ isCompactingInFlight = true;
100
+ ctx.compact({
101
+ onComplete: () => {
102
+ isCompactingInFlight = false;
103
+ // After in-flight compaction completes, if the agent was interrupted mid-run,
104
+ // queue a follow-up continuation so the agent automatically picks up where it left off.
105
+ pi.sendUserMessage("Continue.", { deliverAs: "followUp" });
106
+ },
107
+ onError: () => {
108
+ isCompactingInFlight = false;
109
+ },
110
+ });
98
111
  }
99
112
  };
100
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shariq-pi-extensions",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "Cross-platform extension suite for the Pi coding agent.",
5
5
  "license": "MIT",
6
6
  "author": "Shariq Riaz",