opencode-command-hooks 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +14 -29
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # 🪝 OpenCode Command Hooks
2
2
 
3
- Use simple configs to easily integrate shell command hooks with tool/subagent invocations. With a single line of configuration, you can inject a hook's output directly into context for your agent to read.
4
-
5
- Example use cases: run tests after a subagent finishes a task, auto-lint after writes, etc. You can also configure the hooks to run only when specified arguments are passed to a given tool.
3
+ Use simple configs to declaratively define shell command hooks on tool/subagent invocations. With a single line of configuration, you can inject a hook's output directly into context for your agent to read.
6
4
 
7
5
  ## Markdown Frontmatter Hooks
8
6
 
@@ -19,6 +17,14 @@ hooks:
19
17
  ---
20
18
  ````
21
19
 
20
+ ## Table of Contents
21
+
22
+ - [Features](#features)
23
+ - [Installation](#installation)
24
+ - [Configuration](#configuration)
25
+ - [Examples](#examples)
26
+ - [Template Placeholders](#template-placeholders)
27
+
22
28
  ### How It Works
23
29
 
24
30
  1. **Runs automatically** on the configured event
@@ -143,14 +149,14 @@ You can set up tool hooks to only trigger on specific arguments via `when.toolAr
143
149
 
144
150
  ## Features
145
151
 
146
- - Tool hooks (`before`/`after`) and session hooks (`start`/`idle`)
152
+ - Tool hooks (`before`/`after`) and session hooks (`start`/`idle`) via simple JSON/YAML frontmatter config
147
153
  - Hooks are **non-blocking**: failures don’t crash the session/tool.
148
154
  - Commands run **sequentially**, even if earlier ones fail.
155
+ - Inject bash output into context with `inject` and notify user with `toast`
149
156
  - `inject`/`toast` interpolate using the **last command’s** output if `run` is an array.
150
- - Match by tool name, calling agent, slash command, and tool arguments
157
+ - Match by tool name and (optionally) arguments
151
158
  - Optional session injection and toast notifications
152
- - Output truncation to keep memory bounded
153
- - Debug logging via `OPENCODE_HOOKS_DEBUG=1`
159
+ - Automatic output truncation (30,000 by default)
154
160
 
155
161
  ---
156
162
 
@@ -221,7 +227,7 @@ hooks:
221
227
 
222
228
  ## Examples
223
229
 
224
- ### Autonomous Quality Gates (After `task`)
230
+ ### Automatically run typecheck, lint, and test (after `task`)
225
231
 
226
232
  Run validation after certain subagents complete, inject results back into the session, and show a small toast.
227
233
 
@@ -304,25 +310,6 @@ Tool-arg matching is exact. This example runs only when the tool arg `path` equa
304
310
  }
305
311
  ```
306
312
 
307
- ### Handle Async Tool Completion (`tool.result`)
308
-
309
- ```jsonc
310
- {
311
- "tool": [
312
- {
313
- "id": "task-result-hook",
314
- "when": {
315
- "phase": "after",
316
- "tool": "task",
317
- "toolArgs": { "subagent_type": "code-writer" },
318
- },
319
- "run": ["npm run validate-changes"],
320
- "toast": { "title": "Code Writer", "message": "exit {exitCode}" },
321
- },
322
- ],
323
- }
324
- ```
325
-
326
313
  ### Session Lifecycle Hooks
327
314
 
328
315
  ```jsonc
@@ -437,5 +424,3 @@ export const MyHooks: Plugin = async ({ $, client }) => {
437
424
  };
438
425
  };
439
426
  ```
440
-
441
- The plugin handles: sequential execution with failure recovery, output truncation, exit code capture, template interpolation, session injection, toast notifications, toolArgs filtering, async tool support, and non-blocking error handling.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-command-hooks",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCode plugin for declaratively attaching shell commands to agent/tool/slash-command lifecycle events",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",