@astralyn/pi 0.81.1-2 → 0.82.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.
- package/CHANGELOG.md +53 -0
- package/README.md +14 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +22 -4
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -3
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +4 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +9 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-config.d.ts +30 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +6 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +7 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +0 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -5
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +5 -10
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +49 -48
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -0
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +13 -3
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -6
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +5 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +1 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/subagent/activity.d.ts +16 -0
- package/dist/extensions/subagent/activity.d.ts.map +1 -0
- package/dist/extensions/subagent/activity.js +150 -0
- package/dist/extensions/subagent/activity.js.map +1 -0
- package/dist/extensions/subagent/agents.d.ts +7 -0
- package/dist/extensions/subagent/agents.d.ts.map +1 -0
- package/dist/extensions/subagent/agents.js +218 -0
- package/dist/extensions/subagent/agents.js.map +1 -0
- package/dist/extensions/subagent/constants.d.ts +22 -0
- package/dist/extensions/subagent/constants.d.ts.map +1 -0
- package/dist/extensions/subagent/constants.js +32 -0
- package/dist/extensions/subagent/constants.js.map +1 -0
- package/dist/extensions/subagent/index.d.ts +3 -0
- package/dist/extensions/subagent/index.d.ts.map +1 -0
- package/dist/extensions/subagent/index.js +249 -0
- package/dist/extensions/subagent/index.js.map +1 -0
- package/dist/extensions/subagent/picker.d.ts +31 -0
- package/dist/extensions/subagent/picker.d.ts.map +1 -0
- package/dist/extensions/subagent/picker.js +116 -0
- package/dist/extensions/subagent/picker.js.map +1 -0
- package/dist/extensions/subagent/render.d.ts +8 -0
- package/dist/extensions/subagent/render.d.ts.map +1 -0
- package/dist/extensions/subagent/render.js +322 -0
- package/dist/extensions/subagent/render.js.map +1 -0
- package/dist/extensions/subagent/resolve.d.ts +16 -0
- package/dist/extensions/subagent/resolve.d.ts.map +1 -0
- package/dist/extensions/subagent/resolve.js +103 -0
- package/dist/extensions/subagent/resolve.js.map +1 -0
- package/dist/extensions/subagent/runner.d.ts +30 -0
- package/dist/extensions/subagent/runner.d.ts.map +1 -0
- package/dist/extensions/subagent/runner.js +355 -0
- package/dist/extensions/subagent/runner.js.map +1 -0
- package/dist/extensions/subagent/schema.d.ts +28 -0
- package/dist/extensions/subagent/schema.d.ts.map +1 -0
- package/dist/extensions/subagent/schema.js +33 -0
- package/dist/extensions/subagent/schema.js.map +1 -0
- package/dist/extensions/subagent/sdk-runner.d.ts +14 -0
- package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -0
- package/dist/extensions/subagent/sdk-runner.js +210 -0
- package/dist/extensions/subagent/sdk-runner.js.map +1 -0
- package/dist/extensions/subagent/settings.d.ts +9 -0
- package/dist/extensions/subagent/settings.d.ts.map +1 -0
- package/dist/extensions/subagent/settings.js +131 -0
- package/dist/extensions/subagent/settings.js.map +1 -0
- package/dist/extensions/subagent/types.d.ts +99 -0
- package/dist/extensions/subagent/types.d.ts.map +1 -0
- package/dist/extensions/subagent/types.js +2 -0
- package/dist/extensions/subagent/types.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +25 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts +16 -0
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-group.js +64 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -0
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +3 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +61 -62
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +19 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/output-decoder.d.ts +52 -0
- package/dist/utils/output-decoder.d.ts.map +1 -0
- package/dist/utils/output-decoder.js +134 -0
- package/dist/utils/output-decoder.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +1 -1
- package/docs/custom-provider.md +5 -2
- package/docs/environment-variables.md +88 -0
- package/docs/extensions.md +11 -3
- package/docs/index.md +4 -1
- package/docs/models.md +6 -2
- package/docs/providers.md +8 -1
- package/docs/rpc.md +23 -6
- package/docs/settings.md +1 -1
- package/docs/usage.md +0 -13
- package/examples/extensions/custom-compaction.ts +3 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +9 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +3 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +16 -15
- package/package.json +5 -4
- package/dist/core/tools/bash-command-summary.d.ts +0 -7
- package/dist/core/tools/bash-command-summary.d.ts.map +0 -1
- package/dist/core/tools/bash-command-summary.js +0 -261
- package/dist/core/tools/bash-command-summary.js.map +0 -1
|
@@ -58,10 +58,12 @@ import { SettingsSelectorComponent } from "./components/settings-selector.js";
|
|
|
58
58
|
import { SkillInvocationMessageComponent } from "./components/skill-invocation-message.js";
|
|
59
59
|
import { BranchSummaryStatusIndicator, CompactionStatusIndicator, IdleStatus, RetryStatusIndicator, WorkingStatusIndicator, } from "./components/status-indicator.js";
|
|
60
60
|
import { ToolExecutionComponent } from "./components/tool-execution.js";
|
|
61
|
+
import { ToolGroupComponent } from "./components/tool-group.js";
|
|
61
62
|
import { TreeSelectorComponent } from "./components/tree-selector.js";
|
|
62
63
|
import { TrustSelectorComponent } from "./components/trust-selector.js";
|
|
63
64
|
import { UserMessageComponent } from "./components/user-message.js";
|
|
64
65
|
import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
|
|
66
|
+
import { editInExternalEditor } from "./external-editor.js";
|
|
65
67
|
import { getModelSearchText } from "./model-search.js";
|
|
66
68
|
import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, onThemeChange, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
|
|
67
69
|
import { InteractiveThemeController } from "./theme/theme-controller.js";
|
|
@@ -270,7 +272,7 @@ export class InteractiveMode {
|
|
|
270
272
|
await this.rebindCurrentSession({ renderBeforeBind: true });
|
|
271
273
|
});
|
|
272
274
|
this.version = VERSION;
|
|
273
|
-
this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor());
|
|
275
|
+
this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor(), getAgentDir());
|
|
274
276
|
this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
|
|
275
277
|
this.headerContainer = new Container();
|
|
276
278
|
this.loadedResourcesContainer = new Container();
|
|
@@ -777,8 +779,15 @@ export class InteractiveMode {
|
|
|
777
779
|
* Get a short path relative to the package root for display.
|
|
778
780
|
*/
|
|
779
781
|
getShortPath(fullPath, sourceInfo) {
|
|
782
|
+
const normalizedFullPath = fullPath.replace(/\\/g, "/");
|
|
780
783
|
const baseDir = sourceInfo?.baseDir;
|
|
781
784
|
if (baseDir && this.isPackageSource(sourceInfo)) {
|
|
785
|
+
const normalizedBaseDir = baseDir.replace(/\\/g, "/");
|
|
786
|
+
const npmRootMatch = normalizedBaseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
|
|
787
|
+
// If fullPath is under the same node_modules root as baseDir, preserve that relative topology.
|
|
788
|
+
if (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {
|
|
789
|
+
return path.posix.relative(normalizedBaseDir, normalizedFullPath);
|
|
790
|
+
}
|
|
782
791
|
const relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));
|
|
783
792
|
if (relativePath &&
|
|
784
793
|
relativePath !== "." &&
|
|
@@ -789,11 +798,11 @@ export class InteractiveMode {
|
|
|
789
798
|
}
|
|
790
799
|
}
|
|
791
800
|
const source = sourceInfo?.source ?? "";
|
|
792
|
-
const npmMatch =
|
|
801
|
+
const npmMatch = normalizedFullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
|
|
793
802
|
if (npmMatch && source.startsWith("npm:")) {
|
|
794
803
|
return npmMatch[2];
|
|
795
804
|
}
|
|
796
|
-
const gitMatch =
|
|
805
|
+
const gitMatch = normalizedFullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
|
|
797
806
|
if (gitMatch && source.startsWith("git:")) {
|
|
798
807
|
return gitMatch[1];
|
|
799
808
|
}
|
|
@@ -1317,6 +1326,34 @@ export class InteractiveMode {
|
|
|
1317
1326
|
getRegisteredToolDefinition(toolName) {
|
|
1318
1327
|
return this.session.getToolDefinition(toolName);
|
|
1319
1328
|
}
|
|
1329
|
+
createToolExecutionComponent(toolName, toolCallId, args) {
|
|
1330
|
+
const component = new ToolExecutionComponent(toolName, toolCallId, args, {
|
|
1331
|
+
showImages: this.settingsManager.getShowImages(),
|
|
1332
|
+
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
1333
|
+
}, this.getRegisteredToolDefinition(toolName), this.ui, this.sessionManager.getCwd());
|
|
1334
|
+
component.setExpanded(this.toolOutputExpanded);
|
|
1335
|
+
return component;
|
|
1336
|
+
}
|
|
1337
|
+
appendToolExecutionComponent(component) {
|
|
1338
|
+
const toolGroup = component.toolGroup?.trim();
|
|
1339
|
+
if (!toolGroup) {
|
|
1340
|
+
this.chatContainer.addChild(component);
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
const children = this.chatContainer.children;
|
|
1344
|
+
const lastChild = children[children.length - 1];
|
|
1345
|
+
if (lastChild instanceof ToolGroupComponent && lastChild.toolGroup === toolGroup) {
|
|
1346
|
+
lastChild.addTool(component);
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
if (lastChild instanceof ToolExecutionComponent && lastChild.toolGroup?.trim() === toolGroup) {
|
|
1350
|
+
const group = new ToolGroupComponent(toolGroup, [lastChild, component]);
|
|
1351
|
+
group.setExpanded(this.toolOutputExpanded);
|
|
1352
|
+
children[children.length - 1] = group;
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
this.chatContainer.addChild(component);
|
|
1356
|
+
}
|
|
1320
1357
|
/**
|
|
1321
1358
|
* Set up keyboard shortcuts registered by extensions.
|
|
1322
1359
|
*/
|
|
@@ -1333,6 +1370,7 @@ export class InteractiveMode {
|
|
|
1333
1370
|
sessionManager: this.sessionManager,
|
|
1334
1371
|
modelRegistry: extensionRunner.getModelRegistry(),
|
|
1335
1372
|
model: this.session.model,
|
|
1373
|
+
thinkingLevel: this.session.thinkingLevel,
|
|
1336
1374
|
isIdle: () => this.session.isIdle,
|
|
1337
1375
|
isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
|
|
1338
1376
|
signal: this.session.agent.signal,
|
|
@@ -2018,7 +2056,7 @@ export class InteractiveMode {
|
|
|
2018
2056
|
this.defaultEditor.onAction("app.model.select", () => this.showModelSelector());
|
|
2019
2057
|
this.defaultEditor.onAction("app.tools.expand", () => this.toggleToolOutputExpansion());
|
|
2020
2058
|
this.defaultEditor.onAction("app.thinking.toggle", () => this.toggleThinkingBlockVisibility());
|
|
2021
|
-
this.defaultEditor.onAction("app.editor.external", () => this.
|
|
2059
|
+
this.defaultEditor.onAction("app.editor.external", () => void this.handleOpenExternalEditor());
|
|
2022
2060
|
this.defaultEditor.onAction("app.message.copy", () => void this.handleCopyCommand());
|
|
2023
2061
|
this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
|
|
2024
2062
|
this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
|
|
@@ -2321,12 +2359,8 @@ export class InteractiveMode {
|
|
|
2321
2359
|
for (const content of this.streamingMessage.content) {
|
|
2322
2360
|
if (content.type === "toolCall") {
|
|
2323
2361
|
if (!this.pendingTools.has(content.id)) {
|
|
2324
|
-
const component =
|
|
2325
|
-
|
|
2326
|
-
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
2327
|
-
}, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
|
|
2328
|
-
component.setExpanded(this.toolOutputExpanded);
|
|
2329
|
-
this.chatContainer.addChild(component);
|
|
2362
|
+
const component = this.createToolExecutionComponent(content.name, content.id, content.arguments);
|
|
2363
|
+
this.appendToolExecutionComponent(component);
|
|
2330
2364
|
this.pendingTools.set(content.id, component);
|
|
2331
2365
|
}
|
|
2332
2366
|
else {
|
|
@@ -2380,15 +2414,14 @@ export class InteractiveMode {
|
|
|
2380
2414
|
}
|
|
2381
2415
|
this.ui.requestRender();
|
|
2382
2416
|
break;
|
|
2417
|
+
case "bash_execution_update":
|
|
2418
|
+
// The bash execution callback handles TUI output rendering.
|
|
2419
|
+
break;
|
|
2383
2420
|
case "tool_execution_start": {
|
|
2384
2421
|
let component = this.pendingTools.get(event.toolCallId);
|
|
2385
2422
|
if (!component) {
|
|
2386
|
-
component =
|
|
2387
|
-
|
|
2388
|
-
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
2389
|
-
}, this.getRegisteredToolDefinition(event.toolName), this.ui, this.sessionManager.getCwd());
|
|
2390
|
-
component.setExpanded(this.toolOutputExpanded);
|
|
2391
|
-
this.chatContainer.addChild(component);
|
|
2423
|
+
component = this.createToolExecutionComponent(event.toolName, event.toolCallId, event.args);
|
|
2424
|
+
this.appendToolExecutionComponent(component);
|
|
2392
2425
|
this.pendingTools.set(event.toolCallId, component);
|
|
2393
2426
|
}
|
|
2394
2427
|
component.markExecutionStarted();
|
|
@@ -2677,12 +2710,8 @@ export class InteractiveMode {
|
|
|
2677
2710
|
// Render tool call components
|
|
2678
2711
|
for (const content of message.content) {
|
|
2679
2712
|
if (content.type === "toolCall") {
|
|
2680
|
-
const component =
|
|
2681
|
-
|
|
2682
|
-
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
2683
|
-
}, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
|
|
2684
|
-
component.setExpanded(this.toolOutputExpanded);
|
|
2685
|
-
this.chatContainer.addChild(component);
|
|
2713
|
+
const component = this.createToolExecutionComponent(content.name, content.id, content.arguments);
|
|
2714
|
+
this.appendToolExecutionComponent(component);
|
|
2686
2715
|
if (message.stopReason === "aborted" || message.stopReason === "error") {
|
|
2687
2716
|
let errorMessage;
|
|
2688
2717
|
if (message.stopReason === "aborted") {
|
|
@@ -3102,51 +3131,21 @@ export class InteractiveMode {
|
|
|
3102
3131
|
}
|
|
3103
3132
|
this.showStatus(`Thinking blocks: ${this.hideThinkingBlock ? "hidden" : "visible"}`);
|
|
3104
3133
|
}
|
|
3105
|
-
async
|
|
3134
|
+
async handleOpenExternalEditor() {
|
|
3106
3135
|
const editorCmd = this.settingsManager.getExternalEditorCommand();
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
return;
|
|
3110
|
-
}
|
|
3111
|
-
const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();
|
|
3112
|
-
const tmpFile = path.join(os.tmpdir(), `pi-editor-${Date.now()}.pi.md`);
|
|
3136
|
+
const content = this.editor.getExpandedText?.() ?? this.editor.getText();
|
|
3137
|
+
this.ui.stop();
|
|
3113
3138
|
try {
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
this.ui.stop();
|
|
3118
|
-
// Split by space to support editor arguments (e.g., "code --wait")
|
|
3119
|
-
const [editor, ...editorArgs] = editorCmd.split(" ");
|
|
3120
|
-
process.stdout.write(`Launching external editor: ${editorCmd}\nPi will resume when the editor exits.\n`);
|
|
3121
|
-
// Do not use spawnSync here. On Windows, synchronous child_process calls can keep
|
|
3122
|
-
// Node/libuv's console input read active after ui.stop() pauses stdin, racing
|
|
3123
|
-
// vim/nvim for the console input buffer until Ctrl+C cancels the pending read.
|
|
3124
|
-
const status = await new Promise((resolve) => {
|
|
3125
|
-
const child = spawn(editor, [...editorArgs, tmpFile], {
|
|
3126
|
-
stdio: "inherit",
|
|
3127
|
-
shell: process.platform === "win32",
|
|
3128
|
-
});
|
|
3129
|
-
child.on("error", () => resolve(null));
|
|
3130
|
-
child.on("close", (code) => resolve(code));
|
|
3139
|
+
const result = await editInExternalEditor({
|
|
3140
|
+
command: editorCmd,
|
|
3141
|
+
content,
|
|
3131
3142
|
});
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
const newContent = fs.readFileSync(tmpFile, "utf-8").replace(/\n$/, "");
|
|
3135
|
-
this.editor.setText(newContent);
|
|
3143
|
+
if (result.status === "complete") {
|
|
3144
|
+
this.editor.setText(result.content);
|
|
3136
3145
|
}
|
|
3137
|
-
// On non-zero exit, keep original text (no action needed)
|
|
3138
3146
|
}
|
|
3139
3147
|
finally {
|
|
3140
|
-
// Clean up temp file
|
|
3141
|
-
try {
|
|
3142
|
-
fs.unlinkSync(tmpFile);
|
|
3143
|
-
}
|
|
3144
|
-
catch {
|
|
3145
|
-
// Ignore cleanup errors
|
|
3146
|
-
}
|
|
3147
|
-
// Restart TUI
|
|
3148
3148
|
this.ui.start();
|
|
3149
|
-
// Force full re-render since external editor uses alternate screen
|
|
3150
3149
|
this.ui.requestRender(true);
|
|
3151
3150
|
}
|
|
3152
3151
|
}
|
|
@@ -3422,7 +3421,7 @@ export class InteractiveMode {
|
|
|
3422
3421
|
onShowImagesChange: (enabled) => {
|
|
3423
3422
|
this.settingsManager.setShowImages(enabled);
|
|
3424
3423
|
for (const child of this.chatContainer.children) {
|
|
3425
|
-
if (child instanceof ToolExecutionComponent) {
|
|
3424
|
+
if (child instanceof ToolExecutionComponent || child instanceof ToolGroupComponent) {
|
|
3426
3425
|
child.setShowImages(enabled);
|
|
3427
3426
|
}
|
|
3428
3427
|
}
|
|
@@ -3430,7 +3429,7 @@ export class InteractiveMode {
|
|
|
3430
3429
|
onImageWidthCellsChange: (width) => {
|
|
3431
3430
|
this.settingsManager.setImageWidthCells(width);
|
|
3432
3431
|
for (const child of this.chatContainer.children) {
|
|
3433
|
-
if (child instanceof ToolExecutionComponent) {
|
|
3432
|
+
if (child instanceof ToolExecutionComponent || child instanceof ToolGroupComponent) {
|
|
3434
3433
|
child.setImageWidthCells(width);
|
|
3435
3434
|
}
|
|
3436
3435
|
}
|