fix(bash): preserve configured shell behavior

This commit is contained in:
jb
2026-09-04 17:11:46 -04:00
parent 3cf354b74b
commit e1c5c55c15
4 changed files with 85 additions and 20 deletions
+19 -3
View File
@@ -3,6 +3,9 @@ import { resolve } from "node:path";
import {
createBashToolDefinition,
getAgentDir,
SettingsManager,
type BashToolOptions,
type ExtensionAPI,
type ExtensionContext,
} from "@earendil-works/pi-coding-agent";
@@ -52,8 +55,18 @@ async function resolveWorkingDirectory(
return cwd;
}
export function createContextualBashTool() {
const baseTool = createBashToolDefinition(process.cwd());
function loadBashOptions(ctx: ExtensionContext): BashToolOptions {
const settings = SettingsManager.create(ctx.cwd, getAgentDir(), {
projectTrusted: ctx.isProjectTrusted(),
});
return {
commandPrefix: settings.getShellCommandPrefix(),
shellPath: settings.getShellPath(),
};
}
export function createContextualBashTool(options?: BashToolOptions) {
const baseTool = createBashToolDefinition(process.cwd(), options);
return {
...baseTool,
@@ -72,7 +85,10 @@ export function createContextualBashTool() {
}
const cwd = await resolveWorkingDirectory(ctx.cwd, params.cwd);
const contextualTool = createBashToolDefinition(cwd);
const contextualTool = createBashToolDefinition(
cwd,
options ?? loadBashOptions(ctx),
);
return contextualTool.execute(
toolCallId,
{ command: params.command, timeout: params.timeout },