mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat(prompt): 重新注册 bash,把"不要用 bash 搜索"写进工具描述
真实会话里模型仍习惯性先调 bash grep,被拒后才改用 grep 工具;系统提示词里已有 4 处 提醒,但模型下调用决定时看的是工具 schema 描述,而 Pi 内置 bash 描述对此只字未提。 - 新增 extensions/bash-override.ts:用 Pi 的 createBashToolDefinition 重新注册 bash, 执行、输出结构与 codemode 说明完全沿用上游;shellPath/commandPrefix 按 ctx.cwd 经 SettingsManager 惰性解析,与内置一致 - tools.jsonc 新增 descriptionAppend 字段,由 prompt-guard 注册时拼接到上游描述后 - bash 增加命令→工具对照规则(grep -n / grep -rl / find -name),并提示 文件清单用 $(git ls-files) 传参、不要接 xargs(会触发权限审核) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
2b21163a18
commit
87940da51a
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
createBashToolDefinition,
|
||||
type ExtensionAPI,
|
||||
getAgentDir,
|
||||
SettingsManager,
|
||||
} from "@earendil-works/pi-coding-agent";
|
||||
import { guardExtensionApi } from "./prompt-guard.ts";
|
||||
|
||||
type BashDefinition = ReturnType<typeof createBashToolDefinition>;
|
||||
|
||||
/** Re-register Pi's bash so tools.jsonc can append to its model-facing description; execution stays upstream. */
|
||||
export default function bashOverrideExtension(pi: ExtensionAPI): void {
|
||||
const sessionDefinitions = new Map<string, BashDefinition>();
|
||||
const sessionDefinition = (cwd: string): BashDefinition => {
|
||||
let definition = sessionDefinitions.get(cwd);
|
||||
if (definition === undefined) {
|
||||
const settings = SettingsManager.create(cwd, getAgentDir());
|
||||
definition = createBashToolDefinition(cwd, {
|
||||
shellPath: settings.getShellPath(),
|
||||
commandPrefix: settings.getShellCommandPrefix(),
|
||||
});
|
||||
sessionDefinitions.set(cwd, definition);
|
||||
}
|
||||
return definition;
|
||||
};
|
||||
|
||||
guardExtensionApi(pi).registerTool({
|
||||
...sessionDefinition(process.cwd()),
|
||||
execute: (toolCallId, params, signal, onUpdate, ctx) =>
|
||||
sessionDefinition(ctx?.cwd ?? process.cwd()).execute(
|
||||
toolCallId,
|
||||
params,
|
||||
signal,
|
||||
onUpdate,
|
||||
ctx,
|
||||
),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user