fix(bash): preserve configured shell behavior
This commit is contained in:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user