Skip to content

Commit cd5edbd

Browse files
docs(hooks): Add on_done_thinking and on_permission_requested docs
1 parent 722ceff commit cd5edbd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ require('opencode').setup({
257257
hooks = {
258258
on_file_edited = nil, -- Called after a file is edited by opencode.
259259
on_session_loaded = nil, -- Called after a session is loaded.
260+
on_done_thinking = nil, -- Called when opencode finishes thinking (all jobs complete).
261+
on_permission_requested = nil, -- Called when a permission request is issued.
260262
},
261263
})
262264
```
@@ -591,12 +593,14 @@ The plugin defines several highlight groups that can be customized to match your
591593

592594
The `prompt_guard` configuration option allows you to control when prompts can be sent to Opencode. This is useful for preventing accidental or unauthorized AI interactions in certain contexts.
593595

594-
## 🪝Custom user hooks
596+
## 🪝 Custom user hooks
595597

596598
You can define custom functions to be called at specific events in Opencode:
597599

598600
- `on_file_edited`: Called after a file is edited by Opencode.
599601
- `on_session_loaded`: Called after a session is loaded.
602+
- `on_done_thinking`: Called when Opencode finishes thinking (all user jobs complete).
603+
- `on_permission_requested`: Called when a permission request is issued.
600604

601605
```lua
602606
require('opencode').setup({
@@ -609,6 +613,14 @@ require('opencode').setup({
609613
-- Custom logic after a session is loaded
610614
print("Session loaded: " .. session_name)
611615
end,
616+
on_done_thinking = function()
617+
-- Custom logic when thinking is done
618+
print("Done thinking!")
619+
end,
620+
on_permission_requested = function()
621+
-- Custom logic when a permission is requested
622+
print("Permission requested!")
623+
end,
612624
},
613625
})
614626
```

0 commit comments

Comments
 (0)