mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 10:05:14 +00:00
feat(coding-agent): add bash spawn hook
This commit is contained in:
parent
25fa1fafde
commit
86b43c8eac
6 changed files with 81 additions and 3 deletions
30
packages/coding-agent/examples/extensions/bash-spawn-hook.ts
Normal file
30
packages/coding-agent/examples/extensions/bash-spawn-hook.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Bash Spawn Hook Example
|
||||
*
|
||||
* Adjusts command, cwd, and env before execution.
|
||||
*
|
||||
* Usage:
|
||||
* pi -e ./bash-spawn-hook.ts
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
import { createBashTool } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const cwd = process.cwd();
|
||||
|
||||
const bashTool = createBashTool(cwd, {
|
||||
spawnHook: ({ command, cwd, env }) => ({
|
||||
command: `source ~/.profile\n${command}`,
|
||||
cwd,
|
||||
env: { ...env, PI_SPAWN_HOOK: "1" },
|
||||
}),
|
||||
});
|
||||
|
||||
pi.registerTool({
|
||||
...bashTool,
|
||||
execute: async (id, params, onUpdate, _ctx, signal) => {
|
||||
return bashTool.execute(id, params, signal, onUpdate);
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue