@mariozechner/pi-coding-agent 0.63.0 → 0.63.1

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 (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -2
  3. package/dist/core/agent-session.d.ts +4 -3
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +64 -10
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/compaction/compaction.d.ts +1 -1
  8. package/dist/core/compaction/compaction.d.ts.map +1 -1
  9. package/dist/core/compaction/compaction.js +18 -17
  10. package/dist/core/compaction/compaction.js.map +1 -1
  11. package/dist/core/extensions/types.d.ts +7 -1
  12. package/dist/core/extensions/types.d.ts.map +1 -1
  13. package/dist/core/extensions/types.js.map +1 -1
  14. package/dist/core/package-manager.d.ts.map +1 -1
  15. package/dist/core/package-manager.js +34 -18
  16. package/dist/core/package-manager.js.map +1 -1
  17. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  18. package/dist/core/tools/edit-diff.js +50 -25
  19. package/dist/core/tools/edit-diff.js.map +1 -1
  20. package/dist/core/tools/edit.d.ts.map +1 -1
  21. package/dist/core/tools/edit.js +8 -1
  22. package/dist/core/tools/edit.js.map +1 -1
  23. package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
  24. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  25. package/dist/modes/interactive/components/tool-execution.js +2 -7
  26. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  27. package/dist/modes/interactive/interactive-mode.d.ts +0 -1
  28. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  29. package/dist/modes/interactive/interactive-mode.js +26 -64
  30. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  31. package/docs/extensions.md +11 -1
  32. package/docs/skills.md +3 -2
  33. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  34. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  35. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  36. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  37. package/examples/extensions/trigger-compact.ts +11 -1
  38. package/examples/extensions/with-deps/package-lock.json +2 -2
  39. package/examples/extensions/with-deps/package.json +1 -1
  40. package/package.json +4 -4
@@ -1000,10 +1000,8 @@ export class InteractiveMode {
1000
1000
  compact: (options) => {
1001
1001
  void (async () => {
1002
1002
  try {
1003
- const result = await this.executeCompaction(options?.customInstructions, false);
1004
- if (result) {
1005
- options?.onComplete?.(result);
1006
- }
1003
+ const result = await this.session.compact(options?.customInstructions);
1004
+ options?.onComplete?.(result);
1007
1005
  }
1008
1006
  catch (error) {
1009
1007
  const err = error instanceof Error ? error : new Error(String(error));
@@ -1966,54 +1964,54 @@ export class InteractiveMode {
1966
1964
  await this.checkShutdownRequested();
1967
1965
  this.ui.requestRender();
1968
1966
  break;
1969
- case "auto_compaction_start": {
1967
+ case "compaction_start": {
1970
1968
  // Keep editor active; submissions are queued during compaction.
1971
- // Set up escape to abort auto-compaction
1972
1969
  this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
1973
1970
  this.defaultEditor.onEscape = () => {
1974
1971
  this.session.abortCompaction();
1975
1972
  };
1976
- // Show compacting indicator with reason
1977
1973
  this.statusContainer.clear();
1978
- const reasonText = event.reason === "overflow" ? "Context overflow detected, " : "";
1979
- this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), `${reasonText}Auto-compacting... (${keyText("app.interrupt")} to cancel)`);
1974
+ const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
1975
+ const label = event.reason === "manual"
1976
+ ? `Compacting context... ${cancelHint}`
1977
+ : `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
1978
+ this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
1980
1979
  this.statusContainer.addChild(this.autoCompactionLoader);
1981
1980
  this.ui.requestRender();
1982
1981
  break;
1983
1982
  }
1984
- case "auto_compaction_end": {
1985
- // Restore escape handler
1983
+ case "compaction_end": {
1986
1984
  if (this.autoCompactionEscapeHandler) {
1987
1985
  this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
1988
1986
  this.autoCompactionEscapeHandler = undefined;
1989
1987
  }
1990
- // Stop loader
1991
1988
  if (this.autoCompactionLoader) {
1992
1989
  this.autoCompactionLoader.stop();
1993
1990
  this.autoCompactionLoader = undefined;
1994
1991
  this.statusContainer.clear();
1995
1992
  }
1996
- // Handle result
1997
1993
  if (event.aborted) {
1998
- this.showStatus("Auto-compaction cancelled");
1994
+ if (event.reason === "manual") {
1995
+ this.showError("Compaction cancelled");
1996
+ }
1997
+ else {
1998
+ this.showStatus("Auto-compaction cancelled");
1999
+ }
1999
2000
  }
2000
2001
  else if (event.result) {
2001
- // Rebuild chat to show compacted state
2002
2002
  this.chatContainer.clear();
2003
2003
  this.rebuildChatFromMessages();
2004
- // Add compaction component at bottom so user sees it without scrolling
2005
- this.addMessageToChat({
2006
- role: "compactionSummary",
2007
- tokensBefore: event.result.tokensBefore,
2008
- summary: event.result.summary,
2009
- timestamp: Date.now(),
2010
- });
2004
+ this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
2011
2005
  this.footer.invalidate();
2012
2006
  }
2013
2007
  else if (event.errorMessage) {
2014
- // Compaction failed (e.g., quota exceeded, API error)
2015
- this.chatContainer.addChild(new Spacer(1));
2016
- this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2008
+ if (event.reason === "manual") {
2009
+ this.showError(event.errorMessage);
2010
+ }
2011
+ else {
2012
+ this.chatContainer.addChild(new Spacer(1));
2013
+ this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2014
+ }
2017
2015
  }
2018
2016
  void this.flushCompactionQueue({ willRetry: event.willRetry });
2019
2017
  this.ui.requestRender();
@@ -3853,53 +3851,17 @@ export class InteractiveMode {
3853
3851
  this.showWarning("Nothing to compact (no messages yet)");
3854
3852
  return;
3855
3853
  }
3856
- await this.executeCompaction(customInstructions, false);
3857
- }
3858
- async executeCompaction(customInstructions, isAuto = false) {
3859
- // Stop loading animation
3860
3854
  if (this.loadingAnimation) {
3861
3855
  this.loadingAnimation.stop();
3862
3856
  this.loadingAnimation = undefined;
3863
3857
  }
3864
3858
  this.statusContainer.clear();
3865
- // Set up escape handler during compaction
3866
- const originalOnEscape = this.defaultEditor.onEscape;
3867
- this.defaultEditor.onEscape = () => {
3868
- this.session.abortCompaction();
3869
- };
3870
- // Show compacting status
3871
- this.chatContainer.addChild(new Spacer(1));
3872
- const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
3873
- const label = isAuto ? `Auto-compacting context... ${cancelHint}` : `Compacting context... ${cancelHint}`;
3874
- const compactingLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
3875
- this.statusContainer.addChild(compactingLoader);
3876
- this.ui.requestRender();
3877
- let result;
3878
3859
  try {
3879
- result = await this.session.compact(customInstructions);
3880
- // Rebuild UI
3881
- this.rebuildChatFromMessages();
3882
- // Add compaction component at bottom so user sees it without scrolling
3883
- const msg = createCompactionSummaryMessage(result.summary, result.tokensBefore, new Date().toISOString());
3884
- this.addMessageToChat(msg);
3885
- this.footer.invalidate();
3886
- }
3887
- catch (error) {
3888
- const message = error instanceof Error ? error.message : String(error);
3889
- if (message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError")) {
3890
- this.showError("Compaction cancelled");
3891
- }
3892
- else {
3893
- this.showError(`Compaction failed: ${message}`);
3894
- }
3860
+ await this.session.compact(customInstructions);
3895
3861
  }
3896
- finally {
3897
- compactingLoader.stop();
3898
- this.statusContainer.clear();
3899
- this.defaultEditor.onEscape = originalOnEscape;
3862
+ catch {
3863
+ // Ignore, will be emitted as an event
3900
3864
  }
3901
- void this.flushCompactionQueue({ willRetry: false });
3902
- return result;
3903
3865
  }
3904
3866
  stop() {
3905
3867
  if (this.loadingAnimation) {