Repository navigation
Description
Summary
Request native hook support for Trae IDE (ByteDance's agentic IDE), enabling rtk init --agent trae or rtk hook trae. The hook should rewrite Bash-equivalent commands issued via Trae's RunCommand tool before execution, so RTK's compact output reaches the Trae-bound LLM.
Background
RTK already ships hooks for Claude Code, Cursor, Gemini CLI, Copilot, and Factory Droid. Trae IDE (agentic IDE from ByteDance, not the open-source trae-agent) is a growing user base that supports the same PreToolUse/PostToolUse hook protocol, but uses a different command-execution tool name and a slightly different hook config location.
I've verified the gap experimentally:
| Step | Result |
|---|---|
rtk hook claude with tool_name: "Bash" stdin |
✅ Returns {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git status"}}} |
rtk hook claude with tool_name: "RunCommand" stdin (Trae's tool name) |
❌ No rewrite — rtk passes through silently (tool name unrecognized) |
rtk hook cursor with tool_name: "RunCommand" |
❌ Same — no rewrite |
So even though Trae speaks the Claude-Code-compatible stdin protocol, RTK's Bash-only tool-name match means Trae commands are never rewritten.
Trae's Hook Protocol (verified)
Config file
- Path:
~/.trae-cn/hooks.json(user-global; also~/.trae/hooks.jsonon some builds) - Format — same shape as Claude Code's
settings.jsonhooks:
{
"hooks": {
"PreToolUse": [
{
"matcher": "RunCommand",
"hooks": [
{ "type": "command", "command": "rtk hook trae" }
]
}
],
"PostToolUse": [
{
"matcher": "RunCommand",
"hooks": [
{ "type": "command", "command": "rtk hook trae --post" }
]
}
]
}
}stdin payload (PreToolUse)
Same fields as Claude Code, except tool_name is RunCommand instead of Bash:
{
"hook_event_name": "PreToolUse",
"session_id": "...",
"cwd": "D:\\project\\path",
"tool_name": "RunCommand",
"tool_input": {
"command": "git status",
"blocking": true,
"command_type": "short_running_process",
"requires_approval": false
}
}Expected stdout response (PreToolUse)
Trae accepts the same hookSpecificOutput.updatedInput JSON shape as Claude Code:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecisionReason": "RTK auto-rewrite",
"updatedInput": { "command": "rtk git status" }
}
}Exit code semantics appear identical to Claude Code (0 = proceed, 2 = block).
Key differences from Claude Code
| Claude Code | Trae IDE | |
|---|---|---|
| Command tool name | Bash |
RunCommand |
| Config file | ~/.claude/settings.json |
~/.trae-cn/hooks.json |
tool_input fields |
{command} |
{command, blocking, command_type, requires_approval} |
| Init command (proposed) | rtk init -g |
rtk init -g --agent trae |
Proposed Implementation (minimal)
- Add
Traevariant to the hook agent enum insrc/hooks/(alongsideClaude,Cursor,Gemini,Copilot,Droid). - In the PreToolUse processor, match
tool_name == "RunCommand"the same wayBashis matched for Claude. - Read
tool_input.command, run the existing rewrite engine, emitupdatedInput.commandwith the rewritten command (preserve the othertool_inputfields —blocking,command_type,requires_approval— unchanged). - Add
rtk init -g --agent traethat patches~/.trae-cn/hooks.jsonwith aPreToolUse/RunCommandhook entry (mirror the existingrtk init -gpatcher for Claude). - Add
rtk hook traesubcommand (can initially delegate to the same handler asrtk hook claudebut withRunCommandas the accepted tool name).
Why This Fits RTK
- Same protocol: Trae speaks the Claude-Code-compatible stdin/stdout JSON contract. The rewrite engine is reusable as-is.
- Single-line change in spirit: the only behavioral delta is the accepted
tool_name. - High-value user base: Trae is ByteDance's flagship agentic IDE with a large Chinese-market footprint; users currently have zero RTK integration path.
- Follows existing pattern: mirrors exactly how Cursor/Copilot/Droid variants were added.
Verification Plan (for the PR)
I'm happy to test a build on Windows + Trae against:
git status/git log/git diff→ expect compact RTK outputpytest→ expect failures-only outputls/find→ expect compact listings- Exit-code 0 / 2 path both respected by Trae
Environment
- RTK: latest develop (tested
rtk hook claudeandrtk hook cursor) - OS: Windows 11
- Trae IDE: built-in hook system at
~/.trae-cn/hooks.json(verified working with aPostToolUse+RunCommandPython hook locally) - Reference for Trae's hook protocol: Volcengine enterprise hook docs (enterprise variant uses
type: http; the localtype: commandvariant used here follows the Claude-Code-compatible shape)
Activity
pszymkowiak commentedon Jul 27, 2026
🔍 Automated Triage
featuremediumSummary
Add Trae IDE hook support (RunCommand tool_name, ~/.trae-cn/hooks.json) mirroring existing Claude/Cursor/Copilot/Droid hook integrations.
📁 Relevant files
src/hooks/mod.rssrc/hooks/claude.rssrc/hooks/cursor.rssrc/init.rsTriaged automatically by wshm · This is an automated analysis, not a human review.