@earendil-works/pi-coding-agent 0.81.1 → 0.82.0

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 (100) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +13 -0
  3. package/dist/cli/config-selector.d.ts.map +1 -1
  4. package/dist/cli/config-selector.js +1 -1
  5. package/dist/cli/config-selector.js.map +1 -1
  6. package/dist/cli/startup-ui.d.ts.map +1 -1
  7. package/dist/cli/startup-ui.js +1 -1
  8. package/dist/cli/startup-ui.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +11 -0
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +5 -1
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/compaction/compaction.d.ts.map +1 -1
  14. package/dist/core/compaction/compaction.js +11 -3
  15. package/dist/core/compaction/compaction.js.map +1 -1
  16. package/dist/core/extensions/runner.d.ts.map +1 -1
  17. package/dist/core/extensions/runner.js +4 -0
  18. package/dist/core/extensions/runner.js.map +1 -1
  19. package/dist/core/extensions/types.d.ts +5 -1
  20. package/dist/core/extensions/types.d.ts.map +1 -1
  21. package/dist/core/extensions/types.js.map +1 -1
  22. package/dist/core/model-config.d.ts +30 -0
  23. package/dist/core/model-config.d.ts.map +1 -1
  24. package/dist/core/model-config.js +6 -0
  25. package/dist/core/model-config.js.map +1 -1
  26. package/dist/core/model-registry.d.ts.map +1 -1
  27. package/dist/core/model-registry.js +2 -2
  28. package/dist/core/model-registry.js.map +1 -1
  29. package/dist/core/model-resolver.d.ts.map +1 -1
  30. package/dist/core/model-resolver.js +7 -0
  31. package/dist/core/model-resolver.js.map +1 -1
  32. package/dist/core/model-runtime.d.ts +0 -1
  33. package/dist/core/model-runtime.d.ts.map +1 -1
  34. package/dist/core/model-runtime.js +3 -5
  35. package/dist/core/model-runtime.js.map +1 -1
  36. package/dist/core/remote-catalog-provider.d.ts +1 -1
  37. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  38. package/dist/core/remote-catalog-provider.js +5 -10
  39. package/dist/core/remote-catalog-provider.js.map +1 -1
  40. package/dist/core/settings-manager.d.ts +1 -1
  41. package/dist/core/settings-manager.d.ts.map +1 -1
  42. package/dist/core/settings-manager.js.map +1 -1
  43. package/dist/core/system-prompt.d.ts.map +1 -1
  44. package/dist/core/system-prompt.js +1 -1
  45. package/dist/core/system-prompt.js.map +1 -1
  46. package/dist/core/tools/bash.d.ts +2 -0
  47. package/dist/core/tools/bash.d.ts.map +1 -1
  48. package/dist/core/tools/bash.js +34 -5
  49. package/dist/core/tools/bash.js.map +1 -1
  50. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  51. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  52. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  53. package/dist/extensions/llama/provider.d.ts.map +1 -1
  54. package/dist/extensions/llama/provider.js +1 -2
  55. package/dist/extensions/llama/provider.js.map +1 -1
  56. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  57. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/extension-editor.js +16 -46
  59. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  60. package/dist/modes/interactive/external-editor.d.ts +12 -0
  61. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  62. package/dist/modes/interactive/external-editor.js +37 -0
  63. package/dist/modes/interactive/external-editor.js.map +1 -0
  64. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  65. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  66. package/dist/modes/interactive/interactive-mode.js +24 -42
  67. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  68. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  69. package/dist/modes/rpc/rpc-mode.js +1 -0
  70. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  71. package/dist/utils/clipboard.d.ts.map +1 -1
  72. package/dist/utils/clipboard.js +19 -8
  73. package/dist/utils/clipboard.js.map +1 -1
  74. package/dist/utils/version-check.d.ts.map +1 -1
  75. package/dist/utils/version-check.js +3 -1
  76. package/dist/utils/version-check.js.map +1 -1
  77. package/docs/compaction.md +1 -1
  78. package/docs/custom-provider.md +5 -2
  79. package/docs/environment-variables.md +88 -0
  80. package/docs/extensions.md +11 -3
  81. package/docs/index.md +1 -0
  82. package/docs/models.md +6 -2
  83. package/docs/providers.md +8 -1
  84. package/docs/rpc.md +23 -6
  85. package/docs/settings.md +1 -1
  86. package/docs/usage.md +0 -13
  87. package/examples/extensions/custom-compaction.ts +3 -0
  88. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  89. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  90. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  91. package/examples/extensions/gondolin/package-lock.json +2 -2
  92. package/examples/extensions/gondolin/package.json +1 -1
  93. package/examples/extensions/handoff.ts +9 -1
  94. package/examples/extensions/sandbox/package-lock.json +2 -2
  95. package/examples/extensions/sandbox/package.json +1 -1
  96. package/examples/extensions/summarize.ts +3 -0
  97. package/examples/extensions/with-deps/package-lock.json +2 -2
  98. package/examples/extensions/with-deps/package.json +1 -1
  99. package/npm-shrinkwrap.json +16 -15
  100. package/package.json +5 -4
@@ -64,6 +64,7 @@ import { TreeSelectorComponent } from "./components/tree-selector.js";
64
64
  import { TrustSelectorComponent } from "./components/trust-selector.js";
65
65
  import { UserMessageComponent } from "./components/user-message.js";
66
66
  import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
67
+ import { editInExternalEditor } from "./external-editor.js";
67
68
  import { getModelSearchText } from "./model-search.js";
68
69
  import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, onThemeChange, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
69
70
  import { InteractiveThemeController } from "./theme/theme-controller.js";
@@ -272,7 +273,7 @@ export class InteractiveMode {
272
273
  await this.rebindCurrentSession({ renderBeforeBind: true });
273
274
  });
274
275
  this.version = VERSION;
275
- this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor());
276
+ this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor(), getAgentDir());
276
277
  this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
277
278
  this.headerContainer = new Container();
278
279
  this.loadedResourcesContainer = new Container();
@@ -797,8 +798,15 @@ export class InteractiveMode {
797
798
  * Get a short path relative to the package root for display.
798
799
  */
799
800
  getShortPath(fullPath, sourceInfo) {
801
+ const normalizedFullPath = fullPath.replace(/\\/g, "/");
800
802
  const baseDir = sourceInfo?.baseDir;
801
803
  if (baseDir && this.isPackageSource(sourceInfo)) {
804
+ const normalizedBaseDir = baseDir.replace(/\\/g, "/");
805
+ const npmRootMatch = normalizedBaseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
806
+ // If fullPath is under the same node_modules root as baseDir, preserve that relative topology.
807
+ if (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {
808
+ return path.posix.relative(normalizedBaseDir, normalizedFullPath);
809
+ }
802
810
  const relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));
803
811
  if (relativePath &&
804
812
  relativePath !== "." &&
@@ -809,11 +817,11 @@ export class InteractiveMode {
809
817
  }
810
818
  }
811
819
  const source = sourceInfo?.source ?? "";
812
- const npmMatch = fullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
820
+ const npmMatch = normalizedFullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
813
821
  if (npmMatch && source.startsWith("npm:")) {
814
822
  return npmMatch[2];
815
823
  }
816
- const gitMatch = fullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
824
+ const gitMatch = normalizedFullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
817
825
  if (gitMatch && source.startsWith("git:")) {
818
826
  return gitMatch[1];
819
827
  }
@@ -1353,6 +1361,7 @@ export class InteractiveMode {
1353
1361
  sessionManager: this.sessionManager,
1354
1362
  modelRegistry: extensionRunner.getModelRegistry(),
1355
1363
  model: this.session.model,
1364
+ thinkingLevel: this.session.thinkingLevel,
1356
1365
  isIdle: () => this.session.isIdle,
1357
1366
  isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
1358
1367
  signal: this.session.agent.signal,
@@ -2038,7 +2047,7 @@ export class InteractiveMode {
2038
2047
  this.defaultEditor.onAction("app.model.select", () => this.showModelSelector());
2039
2048
  this.defaultEditor.onAction("app.tools.expand", () => this.toggleToolOutputExpansion());
2040
2049
  this.defaultEditor.onAction("app.thinking.toggle", () => this.toggleThinkingBlockVisibility());
2041
- this.defaultEditor.onAction("app.editor.external", () => this.openExternalEditor());
2050
+ this.defaultEditor.onAction("app.editor.external", () => void this.handleOpenExternalEditor());
2042
2051
  this.defaultEditor.onAction("app.message.copy", () => void this.handleCopyCommand());
2043
2052
  this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
2044
2053
  this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
@@ -2400,6 +2409,9 @@ export class InteractiveMode {
2400
2409
  }
2401
2410
  this.ui.requestRender();
2402
2411
  break;
2412
+ case "bash_execution_update":
2413
+ // The bash execution callback handles TUI output rendering.
2414
+ break;
2403
2415
  case "tool_execution_start": {
2404
2416
  let component = this.pendingTools.get(event.toolCallId);
2405
2417
  if (!component) {
@@ -3122,51 +3134,21 @@ export class InteractiveMode {
3122
3134
  }
3123
3135
  this.showStatus(`Thinking blocks: ${this.hideThinkingBlock ? "hidden" : "visible"}`);
3124
3136
  }
3125
- async openExternalEditor() {
3137
+ async handleOpenExternalEditor() {
3126
3138
  const editorCmd = this.settingsManager.getExternalEditorCommand();
3127
- if (!editorCmd) {
3128
- this.showWarning("No editor configured. Set externalEditor in settings.json or $VISUAL/$EDITOR.");
3129
- return;
3130
- }
3131
- const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();
3132
- const tmpFile = path.join(os.tmpdir(), `pi-editor-${Date.now()}.pi.md`);
3139
+ const content = this.editor.getExpandedText?.() ?? this.editor.getText();
3140
+ this.ui.stop();
3133
3141
  try {
3134
- // Write current content to temp file
3135
- fs.writeFileSync(tmpFile, currentText, "utf-8");
3136
- // Stop TUI to release terminal
3137
- this.ui.stop();
3138
- // Split by space to support editor arguments (e.g., "code --wait")
3139
- const [editor, ...editorArgs] = editorCmd.split(" ");
3140
- process.stdout.write(`Launching external editor: ${editorCmd}\nPi will resume when the editor exits.\n`);
3141
- // Do not use spawnSync here. On Windows, synchronous child_process calls can keep
3142
- // Node/libuv's console input read active after ui.stop() pauses stdin, racing
3143
- // vim/nvim for the console input buffer until Ctrl+C cancels the pending read.
3144
- const status = await new Promise((resolve) => {
3145
- const child = spawn(editor, [...editorArgs, tmpFile], {
3146
- stdio: "inherit",
3147
- shell: process.platform === "win32",
3148
- });
3149
- child.on("error", () => resolve(null));
3150
- child.on("close", (code) => resolve(code));
3142
+ const result = await editInExternalEditor({
3143
+ command: editorCmd,
3144
+ content,
3151
3145
  });
3152
- // On successful exit (status 0), replace editor content
3153
- if (status === 0) {
3154
- const newContent = fs.readFileSync(tmpFile, "utf-8").replace(/\n$/, "");
3155
- this.editor.setText(newContent);
3146
+ if (result.status === "complete") {
3147
+ this.editor.setText(result.content);
3156
3148
  }
3157
- // On non-zero exit, keep original text (no action needed)
3158
3149
  }
3159
3150
  finally {
3160
- // Clean up temp file
3161
- try {
3162
- fs.unlinkSync(tmpFile);
3163
- }
3164
- catch {
3165
- // Ignore cleanup errors
3166
- }
3167
- // Restart TUI
3168
3151
  this.ui.start();
3169
- // Force full re-render since external editor uses alternate screen
3170
3152
  this.ui.requestRender(true);
3171
3153
  }
3172
3154
  }