[PR #10043] test(plugin): add tests for tool execution hooks #13313

Open
opened 2026-02-16 18:18:10 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10043

State: open
Merged: No


Adds comprehensive tests for tool.execute.before and tool.execute.after plugin hooks.

Fixes #10042

Tests Added

tool.execute.before (6 tests):

  • Hook receives correct input parameters
  • Hook receives args in output
  • Hook can modify args
  • Hook can throw to block execution
  • Multiple hooks called sequentially
  • No hooks registered returns output unchanged

tool.execute.after (6 tests):

  • Hook receives correct input parameters
  • Hook receives result in output
  • Hook can modify output text
  • Hook can modify title
  • Hook can modify metadata
  • Multiple hooks called sequentially

How verified

bun test test/plugin/tool-hooks.test.ts

All 12 tests pass.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10043 **State:** open **Merged:** No --- Adds comprehensive tests for `tool.execute.before` and `tool.execute.after` plugin hooks. Fixes #10042 ## Tests Added **`tool.execute.before` (6 tests):** - Hook receives correct input parameters - Hook receives args in output - Hook can modify args - Hook can throw to block execution - Multiple hooks called sequentially - No hooks registered returns output unchanged **`tool.execute.after` (6 tests):** - Hook receives correct input parameters - Hook receives result in output - Hook can modify output text - Hook can modify title - Hook can modify metadata - Multiple hooks called sequentially ## How verified ```bash bun test test/plugin/tool-hooks.test.ts ``` All 12 tests pass.
yindo added the pull-request label 2026-02-16 18:18:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13313