Repository navigation
feat(cli): relay pre-tool and prompt hooks on opencode and kilo - #1361
Closed
blafourcade wants to merge 2 commits into
Closed
blafourcade wants to merge 2 commits into
blafourcade wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 task
…oss hosts Kilo's awaited scripts and its Stop reason now go through the shared runCapture like OpenCode's. The skipped-event warning has one owner in shared materialization, and the bridge reports its own unrelayed events from the manifest parser instead of a duplicated event list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Superseded by #1378, which consolidates the five OpenCode and Kilo bridge branches into one shared runtime (V1 and V2) and is merged on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 What & why
Relays the
PreToolUseandUserPromptSubmithooks through the OpenCode and Kilo bridge, which relayed neither event before. APreToolUsescript can refuse a tool call; aUserPromptSubmitscript can add a part to the prompt. Refs #1193.🛠️ How it works
Host facts, probed end to end through the built bridge (
translate --to <host> --as flat, two probe plugins). Payloads captured inscripts/__tests__/fixtures/hook-payloads/(opencode-*.json,kilo-*.json).tool.execute.before(input, output), arguments inoutput.args. A throw refuses the call and the message reaches the model.chat.message(input, output): a part pushed tooutput.partsreaches the model only if it is complete (id,messageID,sessionID,synthetic: true).Wired in
cli/src/contexts/tools/domain/bridges/bridge-relay-source.ts:PreToolUse: a script exiting 2 refuses the call with its stderr as the reason. The first refusing script stops the rest.UserPromptSubmit: each answer becomes a synthetic part, id<first part id>-<plugin>-<hook index>, so two scripts of one plugin do not collide. A follow-up the bridge sent itself (metadatamark) is never read as the user's prompt.translate) for each event a plugin names that the bridge does not relay.Goldens moved, all intended:
cli/tests/fixtures/hooks-routes/{kilo,opencode}/*.txt(generated bridge source) and theopencode/kiloaidd-context-hooks.jshashes incli/tests/golden/snapshots/{framework-build,translate-install}/golden.json.🧪 How to verify
cd cli && pnpm exec vitest run tests/contexts/tools tests/contexts/translate.make validate;pnpm exec lefthook run pre-commit --all-files;cd cli && pnpm exec lefthook run pre-push(9948 passed, 1 expected fail, 15 skipped);cd cli && pnpm build(bundle 884.4 KB, budget 897 KB, +5.2 KB over 879.2 KB).Limits, stated and not coded:
setup(ctx), v2.2.7): not installed, not probed.opencode-events.jsrelays neither event. Open question for the maintainer: does the bridge target 1.x only, or V2 too. Not decided here.UserPromptSubmitcannot refuse a prompt on either host: a throw fromchat.messageis unprobed. Exit 2 only puts stderr in context.hooks-runtime/host-bridge.cjs) still maps SessionStart, PostToolUse and Stop only.plugin installon the flat route reports no skipped event, andSessionEndandSubagentStopare dropped silently there.docs/COMPATIBILITY.md,08-hook-generatereferences, tool-paths) are not edited here, another PR owns them. They must now read: PreToolUse =tool.execute.before(denies by throwing); UserPromptSubmit =chat.message(adds a part, no refusal). Their PR link is not added yet.🔗 Linked issue
Refs #1193
✅ I certify
🤖 Generated with Claude Code