Skip to content

Commit 522f7ab

Browse files
committed
Document runtime output injection hooks
1 parent f5ff4a2 commit 522f7ab

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/command-handbook.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ Use these directly in OpenCode:
128128

129129
`/notify inbox` reads the repo-local gateway event audit feed from `.opencode/gateway-events.jsonl` (or `MY_OPENCODE_GATEWAY_EVENT_AUDIT_PATH` when set). Enable gateway event auditing with `MY_OPENCODE_GATEWAY_EVENT_AUDIT=1` to populate inbox entries, but after a wrapped session use `/gateway continuation report` for the fastest `todo-continuation-enforcer` audit check.
130130

131+
For runtime AI-output injection work, treat the gateway event audit as the fastest way to identify the real render path instead of guessing from nearby lifecycle names. The practical mapping from the timestamp fix is:
132+
- `experimental.chat.messages.transform`: mutate message history or synthetic context before the model call
133+
- `experimental.chat.system.transform`: mutate the system prompt before the model call
134+
- `experimental.text.complete`: mutate the final rendered assistant text that `opencode run` prints to the terminal
135+
- `message.updated` / `message.part.updated` / `message.part.delta`: useful for debugging streaming and message lifecycle state, but not reliable as the final `opencode run` print surface
136+
- `session.idle`: end-of-turn lifecycle signal; too late for terminal text injection in the reproduced timestamp case
137+
138+
Recommended runtime-injection debug loop:
139+
- run `python3 scripts/gateway_command.py status --json` and confirm `runtime_mode` is `plugin_gateway`
140+
- enable audit with `MY_OPENCODE_GATEWAY_EVENT_AUDIT=1`
141+
- smoke test with `opencode run "Tell me one short random fact."`
142+
- inspect `.opencode/gateway-events.jsonl` for the event type that actually fires on the rendered path you care about
143+
- if `opencode run` output is the target, start with `experimental.text.complete` before trying lower-level lifecycle events
144+
145+
The terminal timestamp work landed on `experimental.text.complete` in `plugin/gateway-core/src/index.ts` and `plugin/gateway-core/src/hooks/assistant-message-timestamp/index.ts`. Use that pair as the reference example for future runtime output decoration.
146+
131147
## Session digest inside OpenCode 🧾
132148

133149
Use these directly in OpenCode:

0 commit comments

Comments
 (0)