The open source coding agent.
TypeScript
feat(hook): command execute before hook (#9267)
Spoonbfd2f91d5b4b
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.tsindex 0d3d25feb8d..f4793d1a798 100644--- a/packages/opencode/src/session/prompt.ts+++ b/packages/opencode/src/session/prompt.ts@@ -1702,6 +1702,16 @@ NOTE: At any point in time through this workflow you should feel free to ask the: await lastModel(input.sessionID): taskModel+ await Plugin.trigger(+ "command.execute.before",+ {+ command: input.command,+ sessionID: input.sessionID,+ arguments: input.arguments,+ },+ { parts },+ )+const result = (await prompt({sessionID: input.sessionID,messageID: input.messageID,diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.tsindex e57eff579e6..36a4657d74c 100644--- a/packages/plugin/src/index.ts+++ b/packages/plugin/src/index.ts@@ -173,6 +173,10 @@ export interface Hooks {output: { temperature: number; topP: number; topK: number; options: Record<string, any> },) => Promise<void>"permission.ask"?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void>+ "command.execute.before"?: (+ input: { command: string; sessionID: string; arguments: string },+ output: { parts: Part[] },+ ) => Promise<void>"tool.execute.before"?: (input: { tool: string; sessionID: string; callID: string },output: { args: any },