@codex-infinity/pi-infinity 0.62.3 → 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.
Files changed (94) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +2 -2
  3. package/dist/core/agent-session.d.ts +8 -6
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +98 -54
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/auth-storage.d.ts +3 -1
  8. package/dist/core/auth-storage.d.ts.map +1 -1
  9. package/dist/core/auth-storage.js +5 -2
  10. package/dist/core/auth-storage.js.map +1 -1
  11. package/dist/core/compaction/branch-summarization.d.ts +2 -0
  12. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  13. package/dist/core/compaction/branch-summarization.js +2 -2
  14. package/dist/core/compaction/branch-summarization.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts +3 -3
  16. package/dist/core/compaction/compaction.d.ts.map +1 -1
  17. package/dist/core/compaction/compaction.js +27 -26
  18. package/dist/core/compaction/compaction.js.map +1 -1
  19. package/dist/core/extensions/runner.d.ts +1 -0
  20. package/dist/core/extensions/runner.d.ts.map +1 -1
  21. package/dist/core/extensions/runner.js +3 -0
  22. package/dist/core/extensions/runner.js.map +1 -1
  23. package/dist/core/extensions/types.d.ts +10 -1
  24. package/dist/core/extensions/types.d.ts.map +1 -1
  25. package/dist/core/extensions/types.js.map +1 -1
  26. package/dist/core/model-registry.d.ts +18 -2
  27. package/dist/core/model-registry.d.ts.map +1 -1
  28. package/dist/core/model-registry.js +83 -69
  29. package/dist/core/model-registry.js.map +1 -1
  30. package/dist/core/model-resolver.d.ts.map +1 -1
  31. package/dist/core/model-resolver.js +4 -4
  32. package/dist/core/model-resolver.js.map +1 -1
  33. package/dist/core/package-manager.d.ts.map +1 -1
  34. package/dist/core/package-manager.js +34 -18
  35. package/dist/core/package-manager.js.map +1 -1
  36. package/dist/core/resolve-config-value.d.ts +6 -0
  37. package/dist/core/resolve-config-value.d.ts.map +1 -1
  38. package/dist/core/resolve-config-value.js +37 -5
  39. package/dist/core/resolve-config-value.js.map +1 -1
  40. package/dist/core/sdk.d.ts +1 -1
  41. package/dist/core/sdk.d.ts.map +1 -1
  42. package/dist/core/sdk.js +13 -22
  43. package/dist/core/sdk.js.map +1 -1
  44. package/dist/core/settings-manager.d.ts +2 -0
  45. package/dist/core/settings-manager.d.ts.map +1 -1
  46. package/dist/core/settings-manager.js +3 -0
  47. package/dist/core/settings-manager.js.map +1 -1
  48. package/dist/core/timings.d.ts +1 -0
  49. package/dist/core/timings.d.ts.map +1 -1
  50. package/dist/core/timings.js +6 -0
  51. package/dist/core/timings.js.map +1 -1
  52. package/dist/core/tools/edit-diff.d.ts +23 -1
  53. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  54. package/dist/core/tools/edit-diff.js +150 -57
  55. package/dist/core/tools/edit-diff.js.map +1 -1
  56. package/dist/core/tools/edit.d.ts +13 -11
  57. package/dist/core/tools/edit.d.ts.map +1 -1
  58. package/dist/core/tools/edit.js +44 -77
  59. package/dist/core/tools/edit.js.map +1 -1
  60. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  61. package/dist/core/tools/file-mutation-queue.js +4 -4
  62. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  63. package/dist/core/tools/index.d.ts +9 -6
  64. package/dist/core/tools/index.d.ts.map +1 -1
  65. package/dist/main.d.ts.map +1 -1
  66. package/dist/main.js +24 -9
  67. package/dist/main.js.map +1 -1
  68. package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
  69. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/tool-execution.js +2 -7
  71. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  72. package/dist/modes/interactive/interactive-mode.d.ts +0 -1
  73. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  74. package/dist/modes/interactive/interactive-mode.js +29 -65
  75. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  76. package/docs/compaction.md +4 -2
  77. package/docs/development.md +3 -1
  78. package/docs/extensions.md +46 -2
  79. package/docs/models.md +6 -0
  80. package/docs/settings.md +12 -0
  81. package/docs/skills.md +3 -2
  82. package/examples/extensions/custom-compaction.ts +17 -4
  83. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  84. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  85. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  86. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  87. package/examples/extensions/handoff.ts +5 -2
  88. package/examples/extensions/qna.ts +5 -2
  89. package/examples/extensions/sandbox/index.ts +4 -0
  90. package/examples/extensions/summarize.ts +15 -4
  91. package/examples/extensions/trigger-compact.ts +11 -1
  92. package/examples/extensions/with-deps/package-lock.json +2 -2
  93. package/examples/extensions/with-deps/package.json +1 -1
  94. package/package.json +5 -4
@@ -292,7 +292,8 @@ export class InteractiveMode {
292
292
  hint("app.clipboard.pasteImage", "to paste image"),
293
293
  rawKeyHint("drop files", "to attach"),
294
294
  ].join("\n");
295
- this.builtInHeader = new Text(`${logo}\n${instructions}`, 1, 0);
295
+ const onboarding = theme.fg("dim", `Pi can explain its own features and look up its docs. Ask it how to use or extend Pi.`);
296
+ this.builtInHeader = new Text(`${logo}\n${instructions}\n\n${onboarding}`, 1, 0);
296
297
  // Setup UI layout
297
298
  this.headerContainer.addChild(new Spacer(1));
298
299
  this.headerContainer.addChild(this.builtInHeader);
@@ -970,6 +971,7 @@ export class InteractiveMode {
970
971
  modelRegistry: this.session.modelRegistry,
971
972
  model: this.session.model,
972
973
  isIdle: () => !this.session.isStreaming,
974
+ signal: this.session.agent.signal,
973
975
  abort: () => this.session.abort(),
974
976
  hasPendingMessages: () => this.session.pendingMessageCount > 0,
975
977
  shutdown: () => {
@@ -979,10 +981,8 @@ export class InteractiveMode {
979
981
  compact: (options) => {
980
982
  void (async () => {
981
983
  try {
982
- const result = await this.executeCompaction(options?.customInstructions, false);
983
- if (result) {
984
- options?.onComplete?.(result);
985
- }
984
+ const result = await this.session.compact(options?.customInstructions);
985
+ options?.onComplete?.(result);
986
986
  }
987
987
  catch (error) {
988
988
  const err = error instanceof Error ? error : new Error(String(error));
@@ -1945,54 +1945,54 @@ export class InteractiveMode {
1945
1945
  await this.checkShutdownRequested();
1946
1946
  this.ui.requestRender();
1947
1947
  break;
1948
- case "auto_compaction_start": {
1948
+ case "compaction_start": {
1949
1949
  // Keep editor active; submissions are queued during compaction.
1950
- // Set up escape to abort auto-compaction
1951
1950
  this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
1952
1951
  this.defaultEditor.onEscape = () => {
1953
1952
  this.session.abortCompaction();
1954
1953
  };
1955
- // Show compacting indicator with reason
1956
1954
  this.statusContainer.clear();
1957
- const reasonText = event.reason === "overflow" ? "Context overflow detected, " : "";
1958
- this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), `${reasonText}Auto-compacting... (${keyText("app.interrupt")} to cancel)`);
1955
+ const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
1956
+ const label = event.reason === "manual"
1957
+ ? `Compacting context... ${cancelHint}`
1958
+ : `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
1959
+ this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
1959
1960
  this.statusContainer.addChild(this.autoCompactionLoader);
1960
1961
  this.ui.requestRender();
1961
1962
  break;
1962
1963
  }
1963
- case "auto_compaction_end": {
1964
- // Restore escape handler
1964
+ case "compaction_end": {
1965
1965
  if (this.autoCompactionEscapeHandler) {
1966
1966
  this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
1967
1967
  this.autoCompactionEscapeHandler = undefined;
1968
1968
  }
1969
- // Stop loader
1970
1969
  if (this.autoCompactionLoader) {
1971
1970
  this.autoCompactionLoader.stop();
1972
1971
  this.autoCompactionLoader = undefined;
1973
1972
  this.statusContainer.clear();
1974
1973
  }
1975
- // Handle result
1976
1974
  if (event.aborted) {
1977
- this.showStatus("Auto-compaction cancelled");
1975
+ if (event.reason === "manual") {
1976
+ this.showError("Compaction cancelled");
1977
+ }
1978
+ else {
1979
+ this.showStatus("Auto-compaction cancelled");
1980
+ }
1978
1981
  }
1979
1982
  else if (event.result) {
1980
- // Rebuild chat to show compacted state
1981
1983
  this.chatContainer.clear();
1982
1984
  this.rebuildChatFromMessages();
1983
- // Add compaction component at bottom so user sees it without scrolling
1984
- this.addMessageToChat({
1985
- role: "compactionSummary",
1986
- tokensBefore: event.result.tokensBefore,
1987
- summary: event.result.summary,
1988
- timestamp: Date.now(),
1989
- });
1985
+ this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
1990
1986
  this.footer.invalidate();
1991
1987
  }
1992
1988
  else if (event.errorMessage) {
1993
- // Compaction failed (e.g., quota exceeded, API error)
1994
- this.chatContainer.addChild(new Spacer(1));
1995
- this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
1989
+ if (event.reason === "manual") {
1990
+ this.showError(event.errorMessage);
1991
+ }
1992
+ else {
1993
+ this.chatContainer.addChild(new Spacer(1));
1994
+ this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
1995
+ }
1996
1996
  }
1997
1997
  void this.flushCompactionQueue({ willRetry: event.willRetry });
1998
1998
  this.ui.requestRender();
@@ -3827,53 +3827,17 @@ export class InteractiveMode {
3827
3827
  this.showWarning("Nothing to compact (no messages yet)");
3828
3828
  return;
3829
3829
  }
3830
- await this.executeCompaction(customInstructions, false);
3831
- }
3832
- async executeCompaction(customInstructions, isAuto = false) {
3833
- // Stop loading animation
3834
3830
  if (this.loadingAnimation) {
3835
3831
  this.loadingAnimation.stop();
3836
3832
  this.loadingAnimation = undefined;
3837
3833
  }
3838
3834
  this.statusContainer.clear();
3839
- // Set up escape handler during compaction
3840
- const originalOnEscape = this.defaultEditor.onEscape;
3841
- this.defaultEditor.onEscape = () => {
3842
- this.session.abortCompaction();
3843
- };
3844
- // Show compacting status
3845
- this.chatContainer.addChild(new Spacer(1));
3846
- const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
3847
- const label = isAuto ? `Auto-compacting context... ${cancelHint}` : `Compacting context... ${cancelHint}`;
3848
- const compactingLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
3849
- this.statusContainer.addChild(compactingLoader);
3850
- this.ui.requestRender();
3851
- let result;
3852
3835
  try {
3853
- result = await this.session.compact(customInstructions);
3854
- // Rebuild UI
3855
- this.rebuildChatFromMessages();
3856
- // Add compaction component at bottom so user sees it without scrolling
3857
- const msg = createCompactionSummaryMessage(result.summary, result.tokensBefore, new Date().toISOString());
3858
- this.addMessageToChat(msg);
3859
- this.footer.invalidate();
3860
- }
3861
- catch (error) {
3862
- const message = error instanceof Error ? error.message : String(error);
3863
- if (message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError")) {
3864
- this.showError("Compaction cancelled");
3865
- }
3866
- else {
3867
- this.showError(`Compaction failed: ${message}`);
3868
- }
3836
+ await this.session.compact(customInstructions);
3869
3837
  }
3870
- finally {
3871
- compactingLoader.stop();
3872
- this.statusContainer.clear();
3873
- this.defaultEditor.onEscape = originalOnEscape;
3838
+ catch {
3839
+ // Ignore, will be emitted as an event
3874
3840
  }
3875
- void this.flushCompactionQueue({ willRetry: false });
3876
- return result;
3877
3841
  }
3878
3842
  stop() {
3879
3843
  if (this.loadingAnimation) {