@mariozechner/pi-coding-agent 0.63.0 → 0.63.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 (48) hide show
  1. package/CHANGELOG.md +35 -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 +65 -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/runner.d.ts +1 -0
  12. package/dist/core/extensions/runner.d.ts.map +1 -1
  13. package/dist/core/extensions/runner.js +3 -0
  14. package/dist/core/extensions/runner.js.map +1 -1
  15. package/dist/core/extensions/types.d.ts +10 -1
  16. package/dist/core/extensions/types.d.ts.map +1 -1
  17. package/dist/core/extensions/types.js.map +1 -1
  18. package/dist/core/package-manager.d.ts.map +1 -1
  19. package/dist/core/package-manager.js +34 -18
  20. package/dist/core/package-manager.js.map +1 -1
  21. package/dist/core/tools/edit-diff.d.ts +3 -3
  22. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  23. package/dist/core/tools/edit-diff.js +50 -25
  24. package/dist/core/tools/edit-diff.js.map +1 -1
  25. package/dist/core/tools/edit.d.ts +7 -17
  26. package/dist/core/tools/edit.d.ts.map +1 -1
  27. package/dist/core/tools/edit.js +23 -98
  28. package/dist/core/tools/edit.js.map +1 -1
  29. package/dist/core/tools/index.d.ts +5 -10
  30. package/dist/core/tools/index.d.ts.map +1 -1
  31. package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
  32. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  33. package/dist/modes/interactive/components/tool-execution.js +2 -7
  34. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  35. package/dist/modes/interactive/interactive-mode.d.ts +0 -1
  36. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  37. package/dist/modes/interactive/interactive-mode.js +27 -64
  38. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  39. package/docs/extensions.md +44 -1
  40. package/docs/skills.md +3 -2
  41. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  42. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  43. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  44. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  45. package/examples/extensions/trigger-compact.ts +11 -1
  46. package/examples/extensions/with-deps/package-lock.json +2 -2
  47. package/examples/extensions/with-deps/package.json +1 -1
  48. package/package.json +4 -4
@@ -991,6 +991,7 @@ export class InteractiveMode {
991
991
  modelRegistry: this.session.modelRegistry,
992
992
  model: this.session.model,
993
993
  isIdle: () => !this.session.isStreaming,
994
+ signal: this.session.agent.signal,
994
995
  abort: () => this.session.abort(),
995
996
  hasPendingMessages: () => this.session.pendingMessageCount > 0,
996
997
  shutdown: () => {
@@ -1000,10 +1001,8 @@ export class InteractiveMode {
1000
1001
  compact: (options) => {
1001
1002
  void (async () => {
1002
1003
  try {
1003
- const result = await this.executeCompaction(options?.customInstructions, false);
1004
- if (result) {
1005
- options?.onComplete?.(result);
1006
- }
1004
+ const result = await this.session.compact(options?.customInstructions);
1005
+ options?.onComplete?.(result);
1007
1006
  }
1008
1007
  catch (error) {
1009
1008
  const err = error instanceof Error ? error : new Error(String(error));
@@ -1966,54 +1965,54 @@ export class InteractiveMode {
1966
1965
  await this.checkShutdownRequested();
1967
1966
  this.ui.requestRender();
1968
1967
  break;
1969
- case "auto_compaction_start": {
1968
+ case "compaction_start": {
1970
1969
  // Keep editor active; submissions are queued during compaction.
1971
- // Set up escape to abort auto-compaction
1972
1970
  this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
1973
1971
  this.defaultEditor.onEscape = () => {
1974
1972
  this.session.abortCompaction();
1975
1973
  };
1976
- // Show compacting indicator with reason
1977
1974
  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)`);
1975
+ const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
1976
+ const label = event.reason === "manual"
1977
+ ? `Compacting context... ${cancelHint}`
1978
+ : `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
1979
+ this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
1980
1980
  this.statusContainer.addChild(this.autoCompactionLoader);
1981
1981
  this.ui.requestRender();
1982
1982
  break;
1983
1983
  }
1984
- case "auto_compaction_end": {
1985
- // Restore escape handler
1984
+ case "compaction_end": {
1986
1985
  if (this.autoCompactionEscapeHandler) {
1987
1986
  this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
1988
1987
  this.autoCompactionEscapeHandler = undefined;
1989
1988
  }
1990
- // Stop loader
1991
1989
  if (this.autoCompactionLoader) {
1992
1990
  this.autoCompactionLoader.stop();
1993
1991
  this.autoCompactionLoader = undefined;
1994
1992
  this.statusContainer.clear();
1995
1993
  }
1996
- // Handle result
1997
1994
  if (event.aborted) {
1998
- this.showStatus("Auto-compaction cancelled");
1995
+ if (event.reason === "manual") {
1996
+ this.showError("Compaction cancelled");
1997
+ }
1998
+ else {
1999
+ this.showStatus("Auto-compaction cancelled");
2000
+ }
1999
2001
  }
2000
2002
  else if (event.result) {
2001
- // Rebuild chat to show compacted state
2002
2003
  this.chatContainer.clear();
2003
2004
  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
- });
2005
+ this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
2011
2006
  this.footer.invalidate();
2012
2007
  }
2013
2008
  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));
2009
+ if (event.reason === "manual") {
2010
+ this.showError(event.errorMessage);
2011
+ }
2012
+ else {
2013
+ this.chatContainer.addChild(new Spacer(1));
2014
+ this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2015
+ }
2017
2016
  }
2018
2017
  void this.flushCompactionQueue({ willRetry: event.willRetry });
2019
2018
  this.ui.requestRender();
@@ -3853,53 +3852,17 @@ export class InteractiveMode {
3853
3852
  this.showWarning("Nothing to compact (no messages yet)");
3854
3853
  return;
3855
3854
  }
3856
- await this.executeCompaction(customInstructions, false);
3857
- }
3858
- async executeCompaction(customInstructions, isAuto = false) {
3859
- // Stop loading animation
3860
3855
  if (this.loadingAnimation) {
3861
3856
  this.loadingAnimation.stop();
3862
3857
  this.loadingAnimation = undefined;
3863
3858
  }
3864
3859
  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
3860
  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
- }
3861
+ await this.session.compact(customInstructions);
3895
3862
  }
3896
- finally {
3897
- compactingLoader.stop();
3898
- this.statusContainer.clear();
3899
- this.defaultEditor.onEscape = originalOnEscape;
3863
+ catch {
3864
+ // Ignore, will be emitted as an event
3900
3865
  }
3901
- void this.flushCompactionQueue({ willRetry: false });
3902
- return result;
3903
3866
  }
3904
3867
  stop() {
3905
3868
  if (this.loadingAnimation) {