Skip to content

feat: add CodeBuddy hook integration - #2359

Closed
SeeYangZhi wants to merge 1 commit into
rtk-ai:developfrom
SeeYangZhi:feat/codebuddy-hook
Closed

SeeYangZhi wants to merge 1 commit into
rtk-ai:developfrom
SeeYangZhi:feat/codebuddy-hook

Conversation

@SeeYangZhi

Copy link
Copy Markdown

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:

  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 both agents.

Changes

src/hooks/constants.rs

  • Add CODEBUDDY_DIR (.codebuddy), CODEBUDDY_HOOK_COMMAND, CODEBUDDY_MATCHER (Bash|execute_command)

src/hooks/hook_cmd.rs

  • Add run_codebuddy() — the hook command entry point
  • Add process_codebuddy_payload() — handles dual-format output
  • Add run_codebuddy_inner() — test helper
  • 12 new unit tests covering: rewrite, IDE tool names, passthrough, edge cases

src/hooks/init.rs

  • Add run_codebuddy_mode() — patches ~/.codebuddy/settings.json
  • Add uninstall_codebuddy() — removes RTK hook from settings
  • Add helper functions for JSON patching with idempotency and backup

src/main.rs

  • Add Codebuddy variant to AgentTarget and HookCommands enums
  • Wire init, uninstall, and hook dispatch

Usage

# Initialize
rtk init --agent codebuddy

# Hook (called automatically by CodeBuddy)
rtk hook codebuddy

# Uninstall
rtk init --agent codebuddy --uninstall

Tool Name Mapping

CodeBuddy uses IDE-style tool names. The matcher Bash|execute_command catches both CLI and IDE modes:

CLI style IDE style
Bash execute_command

Settings Written

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash|execute_command",
        "hooks": [
          {
            "type": "command",
            "command": "rtk hook codebuddy"
          }
        ]
      }
    ]
  }
}

Testing

  • 12 new unit tests in hook_cmd.rs
  • Cannot run cargo test locally (no Rust toolchain on this machine) — CI will validate

Checklist

  • Targets develop branch (not master)
  • Dual-format output (updatedInput + modifiedInput)
  • Top-level continue: true and permissionDecision: "allow"
  • Idempotent init (skips if hook already present)
  • Settings backup before modification
  • Uninstall support
  • Unit tests
  • cargo fmt --all --check (pending CI)
  • cargo clippy --all-targets (pending CI)
  • cargo test (pending CI)

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
@CLAassistant

CLAassistant commented Jun 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jagerzhang

Copy link
Copy Markdown

Looking forward to integrating as soon as possible

@rtk-release-bot

Copy link
Copy Markdown
Contributor

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.

@KuSh

KuSh commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

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.

@KuSh KuSh closed this Sep 19, 2026
@KuSh KuSh added the duplicate This issue or pull request already exists label Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add support for CodeBuddy (Tencent Cloud AI Code Editor)

4 participants