Skip to content

Commit 104fa1b

Browse files
feat(hook): command execute before hook (anomalyco#9267)
1 parent 6ce4a99 commit 104fa1b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/opencode/src/session/prompt.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,16 @@ NOTE: At any point in time through this workflow you should feel free to ask the
17021702
: await lastModel(input.sessionID)
17031703
: taskModel
17041704

1705+
await Plugin.trigger(
1706+
"command.execute.before",
1707+
{
1708+
command: input.command,
1709+
sessionID: input.sessionID,
1710+
arguments: input.arguments,
1711+
},
1712+
{ parts },
1713+
)
1714+
17051715
const result = (await prompt({
17061716
sessionID: input.sessionID,
17071717
messageID: input.messageID,

packages/plugin/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ export interface Hooks {
173173
output: { temperature: number; topP: number; topK: number; options: Record<string, any> },
174174
) => Promise<void>
175175
"permission.ask"?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void>
176+
"command.execute.before"?: (
177+
input: { command: string; sessionID: string; arguments: string },
178+
output: { parts: Part[] },
179+
) => Promise<void>
176180
"tool.execute.before"?: (
177181
input: { tool: string; sessionID: string; callID: string },
178182
output: { args: any },

0 commit comments

Comments
 (0)