feat(plugin): add shell.create.before hook (#39547)

This commit is contained in:
Aiden Cline 2026-07-29 14:11:52 -05:00 committed by GitHub
commit c8dca936b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 142 additions and 49 deletions

View file

@ -42,4 +42,25 @@ describe("PluginHooks", () => {
expect(event.messages).toEqual([Message.user("changed")])
}),
)
it.effect("mutates shell creation input", () =>
Effect.gen(function* () {
const hooks = yield* PluginHooks.Service
yield* hooks.register("shell", "create.before", (event) =>
Effect.sync(() => {
event.command = "echo changed"
}),
)
const event = {
command: "echo original",
cwd: "/tmp",
timeout: 0,
shell: "/bin/sh",
env: {},
}
expect(yield* hooks.trigger("shell", "create.before", event)).toBe(event)
expect(event.command).toBe("echo changed")
}),
)
})

View file

@ -86,6 +86,9 @@ export function host(overrides: Overrides = {}): Plugin.Context {
transform: () => Effect.die("unused skill.transform"),
reload: () => Effect.die("unused skill.reload"),
},
shell: overrides.shell ?? {
hook: () => Effect.die("unused shell.hook"),
},
tool: overrides.tool ?? {
transform: () => Effect.die("unused tool.transform"),
hook: () => Effect.die("unused tool.hook"),