Repository navigation
feat: add CodeBuddy hook integration - #2359
SeeYangZhi wants to merge 1 commit into
Conversation
Add first-class CodeBuddy (Tencent Cloud AI code editor) support to rtk. CodeBuddy uses a hook protocol compatible with Claude Code's specification with three differences in the output JSON: 1. Requires top-level "continue": true 2. Requires "permissionDecision": "allow" for rewrites to apply 3. Reads "modifiedInput" (Claude Code reads "updatedInput") The hook emits BOTH updatedInput and modifiedInput so the same output works with Claude Code and CodeBuddy. Changes: - constants.rs: Add CODEBUDDY_DIR, CODEBUDDY_HOOK_COMMAND, CODEBUDDY_MATCHER - hook_cmd.rs: Add run_codebuddy() with dual-format output, process_codebuddy_payload() - init.rs: Add run_codebuddy_mode(), uninstall_codebuddy(), settings.json patcher - main.rs: Add Codebuddy to AgentTarget and HookCommands enums, wire dispatch - Tests: 12 new unit tests covering rewrite, passthrough, IDE tool names, edge cases Init: rtk init --agent codebuddy Hook: rtk hook codebuddy Matcher: Bash|execute_command (CLI + IDE modes) Closes rtk-ai#1966 Related: rtk-ai#1967, rtk-ai#2071, rtk-ai#2111
|
Looking forward to integrating as soon as possible |
|
This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet. |
|
Closing as a duplicate of #1967, which adds the same CodeBuddy hook integration and also ships the awareness file and the README and supported agents documentation that a new agent needs, and has already been through a review round. The dual format output here (continue, permissionDecision and modifiedInput) is the one thing #1967 does not do, so please raise it on that PR if CodeBuddy needs it, or reply here if your scope was different. Review and comments are very welcome on #1967. |
Summary
Adds first-class CodeBuddy (Tencent Cloud AI code editor) support to rtk.
Closes #1966
Related: #1967, #2071, #2111
Background
CodeBuddy is Tencent Cloud's AI code editor with a hooks system fully compatible with the Claude Code Hooks specification. The only differences are in the output JSON format:
"continue": true"permissionDecision": "allow"for rewrites to apply"modifiedInput"(Claude Code reads"updatedInput")The hook emits both
updatedInputandmodifiedInputso the same output works with both agents.Changes
src/hooks/constants.rsCODEBUDDY_DIR(.codebuddy),CODEBUDDY_HOOK_COMMAND,CODEBUDDY_MATCHER(Bash|execute_command)src/hooks/hook_cmd.rsrun_codebuddy()— the hook command entry pointprocess_codebuddy_payload()— handles dual-format outputrun_codebuddy_inner()— test helpersrc/hooks/init.rsrun_codebuddy_mode()— patches~/.codebuddy/settings.jsonuninstall_codebuddy()— removes RTK hook from settingssrc/main.rsCodebuddyvariant toAgentTargetandHookCommandsenumsUsage
Tool Name Mapping
CodeBuddy uses IDE-style tool names. The matcher
Bash|execute_commandcatches both CLI and IDE modes:Bashexecute_commandSettings Written
{ "hooks": { "PreToolUse": [ { "matcher": "Bash|execute_command", "hooks": [ { "type": "command", "command": "rtk hook codebuddy" } ] } ] } }Testing
hook_cmd.rscargo testlocally (no Rust toolchain on this machine) — CI will validateChecklist
developbranch (notmaster)updatedInput+modifiedInput)continue: trueandpermissionDecision: "allow"cargo fmt --all --check(pending CI)cargo clippy --all-targets(pending CI)cargo test(pending CI)