feat: add hook mode — silently execute bash via rtk wrapper - #2
Open
xelr233 wants to merge 12 commits into
Open
Conversation
verify/show only read the cached probe state, which stays undefined until the first bash call, so an installed rtk was always reported as "not probed yet" (the verify hint even told users to re-run a command that never probes). Force a fresh probe (cache bypass) in both commands and report the resolved path or NOT FOUND. Also fix the npm test script for Node 24 (node --test test/ fails with MODULE_NOT_FOUND) and add command tests covering verify/show probing.
…EADME, fix mode comment F1: bound state.hookPlan / state.hookExecuted to HOOK_PLAN_MAX (64) entries, evicting the oldest beyond the cap, plus defensive hookPlan cleanup in tools/post-execute so a planned-but-never-executed call leaks nothing. F2: propagate readStream spillPath into bash stdout/stderr objects. F3: reconcile README blockquote with the hook-mode exception. F4: update stale DEFAULT_CONFIG.mode comment to include 'hook'.
…rd-party rtk binary
2 tasks
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.
摘要
新增第三种模式
hook:模型调用 bash 时,插件在tools/pre-execute调rtk hook claude获取改写命令,在tools/execute短路替换执行/bin/bash -c <rewritten>,让命令真正以 rtk 包装器形式运行——输出经 rtk 过滤、rtk gain的Total commands计数 +1。默认无感(不附加任何标注),debug=true时输出排查标注。变更
rtkHookRewrite():spawnrtk hook claude,stdin 传 PreToolUse JSON,解析updatedInput.commandstate.hookPlan/state.hookExecuted(有界 Map,cap 64,防泄漏)tools/execute短路:返回符合 bash schema 的{value},跳过 DSH 默认执行;超时返回 timedOut 结果(不重复执行原命令)tools/post-execute:debug 门控的executed as "..."标注/rtk set mode hook、help 更新、README 文档 + sandbox/第三方外发安全警告测试
node --test test/*.test.js→ 41 pass / 0 fail(短路、fallthrough、超时、无感默认、cap、spillPath)rtk hook claude→/bin/bash -c rtk ls→ post-execute 无附注注意