library: RTK covers Droid, and lists Qoder, Cline and Kimi Code with why
lml0664 on Discord: Library > RTK offered a fixed few agents, even on the
latest magpie. RTK 1.1.0 (rtk-ai/rtk, Latest, 2026-10-25) has `rtk init`
agents claude, cursor, trae, windsurf, cline, kilocode, antigravity, kimi,
pi, hermes, droid, vibe, omp, plus --codex/--gemini/--opencode/--copilot.
Every one with a global hook that magpie has an agent for was already on
the page except Factory's Droid, which is added now:
- droid: rtk's own `rtk init -g --agent droid`, given Droid's folder as
FACTORY_HOME_OVERRIDE (magpie's droid agent honours it). rtk writes its
Execute group (`rtk hook droid`) into the root hooks.json, or into
settings.json's hooks.PreToolUse when Droid's hooks already live there
(src/hooks/init/droid.rs), so ReadRTK and switching off look at all
three files rtk may use (hooks.json, hooks/hooks.json, settings.json)
and leave the user's own hooks and settings. rtk before 0.44 has no
Droid agent, so it is blocked with "needs RTK 0.44 or newer".
- dropHook no longer slices key[:-1] for a top-level key (hooks.json's
"PreToolUse"); before, it would have panicked.
Listed with the switch off and their own reason (rtkNoHook and the page's
rtkNoHookWhy, in zh, zh-TW, ja and de too):
- Qoder, Qoder CN: rtk 1.1.0 has no Qoder agent (`--agent qoder` is an
invalid value), rtk-ai/rtk#1327 (PR #1721 open).
- Cline: `rtk init --agent cline` only writes a .clinerules in the
current project asking the model to type rtk, no hook (#3841).
- Kimi Code: Kimi's hooks can't rewrite a command; rtk writes only one
project's AGENTS.md and refuses -g ("Kimi AI is project-scoped").
RTK's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent.
Run:
- go test -tags nogui ./internal/library -run TestRTK on mote: ok
(TestRTKDroid home/override, TestRTKDroidSettingsHooks,
TestRTKNoHookQoderClineKimi new, sandbox HOME, fake rtk).
- Red on old code: rtk.go at HEAD^ -> TestRTKDroid, ...SettingsHooks and
...NoHookQoderClineKimi red. Broken by hand: version gate at 0.43, the
settings.json entry dropped -> red; FACTORY_HOME_OVERRIDE not passed ->
TestRTKDroid/home red. client.js at HEAD^ -> library-rtk-nohook red
(Qoder's reason was the generic one).
- Real rtk 1.1.0 (release tarball, sha256 checked against checksums.txt)
on mote in a sandbox HOME through SetRTK/ReadRTK: plain ~/.factory,
settings.json with the user's own Execute hook (kept, rtk's taken out)
and FACTORY_HOME_OVERRIDE: on, seen on, off, seen off. Real rtk also
refuses --agent qoder and -g --agent kimi, and cline writes .clinerules.
- Full suite on mote, go test -count=1 -timeout 45m ./...: 80 packages
ok; internal/gui red only in its 10 real-window AppKit tests (#4125).
- GOOS=linux and GOOS=windows go vet ./internal/library: ok. gofmt clean.
- GUI on the WSL box (mote's browsers crash at launch, #4125):
library-rtk-nohook (chromium+webkit, en+zh) and i18n-keys 10/10; all 45
library-*.test.cjs files 810/824, the 14 reds (library-chip-fan webkit,
library-items webkit, library-mcp-tools chromium ja 420) are the same
at origin/main cf9ea977c and are #4120.
Not tried: a real Droid session running the hook; the whole GUI suite
(only the Library files); Windows (Droid's folder there is the same code
path; no run).
This commit is contained in:
@@ -31,7 +31,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
|
||||
| Hooks | A `Hook` (#1790) is a command, an event, an optional matcher, a timeout and the agents ticked for it. Its optional `Description` (#2011) says what it is for in any language, since its name is letters, digits, - and _: one line of at most `maxHookDescription` (200) characters, shown under the name; only library.json keeps it, and no agent is given it. Its event is portable (`HookEvents`: turn-end, after-tool, before-tool, prompt, session-start, each under the agent's own name) or an agent's own (`"codex:PermissionRequest"`), which only that agent is given. A portable tool event can be narrowed to shell or edit tools, each agent's own tool names for them. `syncHooks` writes each into the agent's own file and shape (`hookSpecOf`): Claude Code `<claude dir>/settings.json`, Codex `hooks.json` beside its config.toml, Gemini CLI `~/.gemini/settings.json` (timeout in ms), Cursor `~/.cursor/hooks.json` (flat entries, `version: 1`), and Grok Build `~/.grok/config.toml` and Grok App `agent-home/config.toml` as `[[hooks.<Event>]]` array tables with a `[[hooks.<Event>.hooks]]` child. Grok Build and Grok App run the one CLI, so a `grok:<Event>` own event goes to both (`sameHookFamily`). Every other agent, and an agent in WSL, is refused with why, and the page greys its chip with that reason. The page also says when an agent has every hook turned off (`hooksOff`: Claude Code's `disableAllHooks`, Gemini's `hooksConfig.enabled`, Codex's `[features] hooks`). | [`hooks.go`](../../internal/library/hooks.go) |
|
||||
| Subagents | A `Subagent` (#2283) is a name (lowercase letters, digits and -), a one-line description, a prompt, and the library's skills and MCP servers it uses, given to the agents ticked for it. `syncSubagents` writes it as a file of its own in each agent's user-level folder, in that agent's format (`subagentSpecOf`): Markdown with YAML front matter in `~/.claude/agents` (with `skills` and `mcpServers`), `~/.factory/droids` (with `mcpServers`), `~/.config/opencode/agents` (`mode: subagent`), `~/.gemini/agents`, `~/.qwen/agents`, `~/.grok/agents`, `~/.cursor/agents` and `~/.copilot/agents` (`<name>.agent.md`); a TOML role (`name`, `description`, `developer_instructions`) in `$CODEX_HOME/agents`. Skills and servers are named only where the agent's file can name them, and only those the library has. The page lists, per agent, whether it binds skills and servers (`SubagentAgentView`) and greys out an agent that takes none. | [`subagents.go`](../../internal/library/subagents.go) |
|
||||
| Backups | Before a change first writes an agent file, `backups` copies it to `BackupDir`, one folder per change. The last `keepBackups` (30) changes are kept. The Backups button at the top of every tab, beside Library folder, opens that folder (`libHead`; Dade on Discord found it at the foot of a long page). | [`backup.go`](../../internal/library/backup.go) |
|
||||
| RTK | `SetRTK` runs rtk's own installer (`rtk init -g …`) for an agent being switched on. For one being switched off, it removes exactly what the installer wrote, using magpie's own code, which works even with rtk gone. `ReadRTK` reads each agent's files to say which have the hook. An agent gone for its CLI (`CLIMissing`, #2254) isn't offered rtk, but one that still has the hook is listed so it can be taken out. `rtkSpec.blocked` stops the installer where it would break an agent. `rtkSpec.env` tells the installer the agent's folder where rtk would pick another: Hermes Agent's is `appdir.HermesHome` (`%LOCALAPPDATA%\hermes` on Windows), which rtk is given as `HERMES_HOME`, since rtk 0.51 knows only `$HERMES_HOME` and `~/.hermes`. Antigravity CLI (`agy`, #2202) gets rtk 0.51's own plugin for Antigravity, `plugins/rtk` in its global customization folder `~/.gemini/config` (`plugin.json`, `hooks.json` with `PreToolUse` → `rtk hook antigravity`, `rules/AGENTS.md`), which `agy plugin list` lists; switching it off takes that one folder out. rtk 0.50 knows Antigravity only per project and fails `rtk init -g --agent antigravity`, so an older rtk is `blocked` (`agyBlocked`) and the row says to update RTK. OpenCode 2 loads only the plugin rtk 0.52 on writes (one default object with `id` and `setup()`, rtk-ai/rtk#4187); an older rtk's plugin is for OpenCode 1 and OpenCode 2 refuses it, so with an OpenCode 2 here an older rtk is `blocked` (`openCodeBlocked`) and the row says to update RTK (#2295). Under OpenCode 2, an old plugin left from before an rtk update counts as off once the rtk here can write the new one (`openCodeHas`), so switching it on writes the new one over it; with an older rtk it counts as on, so it can be switched off. A detected agent RTK has no hook for at all is still listed, from `rtkNoHook`, with the reason and a switch that can't be turned on (dsh: its hooks can allow or deny a command but not rewrite it, and `rtk init` has no `--agent dsh`; Grok Build and Grok App: `rtk init` has no Grok or Grok App agent, so both are listed with the switch off). The page's No RTK hook tag gives each agent's own reason and rtk-ai/rtk issue (`rtkNoHookWhy` in plugins/library/client.js: dsh #3847, Grok Build and Grok App #2136), and an agent with no entry gets no link; `TestRTKNoHookIssuesAreEachAgents` fails when the page and `rtkNoHook` cite different issues, or two agents cite the same ones without a reason in `sharedRTKIssues`. | [`rtk.go`](../../internal/library/rtk.go) |
|
||||
| RTK | `SetRTK` runs rtk's own installer (`rtk init -g …`) for an agent being switched on. For one being switched off, it removes exactly what the installer wrote, using magpie's own code, which works even with rtk gone. `ReadRTK` reads each agent's files to say which have the hook. An agent gone for its CLI (`CLIMissing`, #2254) isn't offered rtk, but one that still has the hook is listed so it can be taken out. `rtkSpec.blocked` stops the installer where it would break an agent. `rtkSpec.env` tells the installer the agent's folder where rtk would pick another: Hermes Agent's is `appdir.HermesHome` (`%LOCALAPPDATA%\hermes` on Windows), which rtk is given as `HERMES_HOME`, since rtk 0.51 knows only `$HERMES_HOME` and `~/.hermes`. Antigravity CLI (`agy`, #2202) gets rtk 0.51's own plugin for Antigravity, `plugins/rtk` in its global customization folder `~/.gemini/config` (`plugin.json`, `hooks.json` with `PreToolUse` → `rtk hook antigravity`, `rules/AGENTS.md`), which `agy plugin list` lists; switching it off takes that one folder out. rtk 0.50 knows Antigravity only per project and fails `rtk init -g --agent antigravity`, so an older rtk is `blocked` (`agyBlocked`) and the row says to update RTK. OpenCode 2 loads only the plugin rtk 0.52 on writes (one default object with `id` and `setup()`, rtk-ai/rtk#4187); an older rtk's plugin is for OpenCode 1 and OpenCode 2 refuses it, so with an OpenCode 2 here an older rtk is `blocked` (`openCodeBlocked`) and the row says to update RTK (#2295). Under OpenCode 2, an old plugin left from before an rtk update counts as off once the rtk here can write the new one (`openCodeHas`), so switching it on writes the new one over it; with an older rtk it counts as on, so it can be switched off. Factory's Droid (lml0664 on Discord) gets rtk's own `rtk init -g --agent droid`, given Droid's folder as `FACTORY_HOME_OVERRIDE`; rtk puts its `Execute` group (`rtk hook droid`) in the root `hooks.json`, or in `settings.json`'s `hooks.PreToolUse` where Droid's hooks already are, so `droidHookFiles` reads and switches off all three places rtk 1.1.0 may use (`hooks.json`, `hooks/hooks.json`, `settings.json`), leaving the user's own hooks. rtk before 0.44 has no Droid agent, so it is `blocked` (`droidBlocked`). A detected agent RTK has no hook for at all is still listed, from `rtkNoHook`, with the reason and a switch that can't be turned on (dsh: its hooks can allow or deny a command but not rewrite it, and `rtk init` has no `--agent dsh`; Grok Build and Grok App: `rtk init` has no Grok or Grok App agent, so both are listed with the switch off; Qoder and Qoder CN: rtk 1.1.0 has no Qoder agent; Cline and Kimi Code: `rtk init --agent cline|kimi` writes only one project's `.clinerules` or `AGENTS.md`, instructions with no hook, and Kimi's refuses `-g`). RTK 1.1.0's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent. The page's No RTK hook tag gives each agent's own reason and rtk-ai/rtk issue (`rtkNoHookWhy` in plugins/library/client.js: dsh #3847, Grok Build and Grok App #2136, Qoder and Qoder CN #1327, Cline #3841), and an agent with no entry gets no link; `TestRTKNoHookIssuesAreEachAgents` fails when the page and `rtkNoHook` cite different issues, or two agents cite the same ones without a reason in `sharedRTKIssues`. | [`rtk.go`](../../internal/library/rtk.go) |
|
||||
| RTK in WSL | An agent in a WSL distro (`claude@wsl:Ubuntu`) is listed by its kind (`rtkKind`), and its hook runs in the distro, where Windows' rtk.exe is no command, so it gets the distro's own rtk (lex on Discord). `rtkDistroOf` asks the distro with `wsl.exe -d <distro> -e sh -lc` where rtk is (a login or interactive shell's PATH; else `~/.local/bin` or `~/.cargo/bin`, `offPath`), kept 15s; `ReadRTK` lists one `RTKDistro` for each distro its agents are in. Install RTK in WSL `<distro>` (`InstallRTKIn`, `POST /api/library/rtk/install` with `distro`, `magpie library rtk install <distro>`) runs RTK's own Linux installer in the distro (`curl -fsSL …/install.sh \| sh`, wget where there's no curl). Switching an agent on runs the distro's rtk there (`rtkInstallWSL`: `rtk init -g …` with its folder on PATH, Claude Code pointed at a folder of its own for the OpenCode and Cursor installers), and reads and edits its files under the distro's home as magpie opens it (`rtkClaudeDir`, `rtkCodexDir`, `rtkHome`). A distro that isn't running is never started (#3896): `rtkWSLLive` and `rtkDistroOf` check `agent.WSLRunning` first, its agents are listed `asleep` with the switch off, and switching or installing says to start it (`TestRTKWSLAsleep`). The page gives each distro a card (`rtkDistroCard` in plugins/library/client.js; library-rtk-wsl.test.cjs). | [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) |
|
||||
|
||||
## Runtime path
|
||||
|
||||
@@ -1016,6 +1016,8 @@ magpie.plugin("library", (ctx) => {
|
||||
if (a.noHook) row.append(tag(t("No RTK hook"), "warn", rtkNoHookWhy(a)));
|
||||
// RTK before 0.51 installs Antigravity's hook only per project
|
||||
else if (a.blocked && kind === "agy") row.append(tag(t("Update RTK"), "warn", t("{agent}'s hook needs RTK 0.51 or newer: older ones install it only per project. Update RTK (brew upgrade rtk, or its installer again), then switch it on.", { agent: a.name })));
|
||||
// RTK before 0.44 has no Droid agent
|
||||
else if (a.blocked && kind === "droid") row.append(tag(t("Update RTK"), "warn", t("{agent}'s hook needs RTK 0.44 or newer: older ones have no hook for it. Update RTK (brew upgrade rtk, or its installer again), then switch it on.", { agent: a.name })));
|
||||
else if (a.blocked && kind !== "opencode") row.append(tag(t("Update RTK"), "warn", t("{agent}'s hook needs RTK 0.50 or newer: older ones only add @RTK.md to AGENTS.md, which rewrites no command. Update RTK (brew upgrade rtk, or its installer again), then switch it on.", { agent: a.name })));
|
||||
// OpenCode 2 loads only the plugin RTK 0.52 on writes (rtk-ai/rtk#4187);
|
||||
// an older one's, already there, can be switched off
|
||||
@@ -1041,6 +1043,10 @@ magpie.plugin("library", (ctx) => {
|
||||
case "dsh": return t("RTK can't be given to {agent} yet: RTK works by rewriting the shell command an agent is about to run, and {agent}'s hooks can only allow or deny a command, not change it. RTK's installer has no option for it either (github.com/rtk-ai/rtk/issues/3847).", { agent });
|
||||
case "grok": return t("RTK can't be given to {agent} yet: RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).", { agent });
|
||||
case "grok-app": return t("RTK can't be given to {agent} yet: {agent} runs Grok Build, and RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).", { agent });
|
||||
case "qoder": return t("RTK can't be given to {agent} yet: RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).", { agent });
|
||||
case "qoder-cn": return t("RTK can't be given to {agent} yet: {agent} is Qoder's China build, and RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).", { agent });
|
||||
case "cline": return t("RTK can't be given to {agent} yet: RTK's installer only writes a .clinerules into one project, asking the model to type rtk itself, and has nothing for every project (github.com/rtk-ai/rtk/issues/3841).", { agent });
|
||||
case "kimi": return t("RTK can't be given to {agent}: {agent}'s hooks can only allow or deny a command, not change it, so RTK's installer only adds instructions to one project's AGENTS.md and has nothing for every project.", { agent });
|
||||
default: return t("RTK can't be given to {agent} yet: RTK has no hook for it.", { agent });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +267,11 @@ magpie.strings({
|
||||
"RTK can't be given to {agent} yet: RTK works by rewriting the shell command an agent is about to run, and {agent}'s hooks can only allow or deny a command, not change it. RTK's installer has no option for it either (github.com/rtk-ai/rtk/issues/3847).": "暂时无法给 {agent} 接入 RTK:RTK 的做法是在 agent 执行 shell 命令前把命令改写掉,而 {agent} 的 hook 只能放行或拦截命令,不能改写;RTK 的安装程序也还没有它的选项(github.com/rtk-ai/rtk/issues/3847)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "暂时无法给 {agent} 接入 RTK:RTK 的安装程序还没有 Grok Build 的选项(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"RTK can't be given to {agent} yet: {agent} runs Grok Build, and RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "暂时无法给 {agent} 接入 RTK:{agent} 运行的是 Grok Build,而 RTK 的安装程序还没有 Grok Build 的选项(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"{agent}'s hook needs RTK 0.44 or newer: older ones have no hook for it. Update RTK (brew upgrade rtk, or its installer again), then switch it on.": "{agent} 的 hook 需要 RTK 0.44 或更高版本:旧版没有它的 hook。请先更新 RTK(brew upgrade rtk,或重新运行其安装脚本)再打开。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "暂时无法给 {agent} 接入 RTK:RTK 的安装程序还没有 Qoder 的选项(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: {agent} is Qoder's China build, and RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "暂时无法给 {agent} 接入 RTK:{agent} 是 Qoder 的国内版,而 RTK 的安装程序还没有 Qoder 的选项(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer only writes a .clinerules into one project, asking the model to type rtk itself, and has nothing for every project (github.com/rtk-ai/rtk/issues/3841).": "暂时无法给 {agent} 接入 RTK:RTK 的安装程序只会在单个项目里写一个 .clinerules,请模型自己输入 rtk,没有对所有项目生效的方式(github.com/rtk-ai/rtk/issues/3841)。",
|
||||
"RTK can't be given to {agent}: {agent}'s hooks can only allow or deny a command, not change it, so RTK's installer only adds instructions to one project's AGENTS.md and has nothing for every project.": "无法给 {agent} 接入 RTK:{agent} 的 hook 只能放行或拦截命令,不能改写,所以 RTK 的安装程序只会在单个项目的 AGENTS.md 里加说明,没有对所有项目生效的方式。",
|
||||
"RTK can't be given to {agent} yet: RTK has no hook for it.": "暂时无法给 {agent} 接入 RTK:RTK 还没有它的 hook。",
|
||||
"Get RTK": "获取 RTK",
|
||||
"restart an agent after switching it": "切换后需重启对应 Agent",
|
||||
@@ -995,6 +1000,11 @@ magpie.strings({
|
||||
"RTK can't be given to {agent} yet: RTK works by rewriting the shell command an agent is about to run, and {agent}'s hooks can only allow or deny a command, not change it. RTK's installer has no option for it either (github.com/rtk-ai/rtk/issues/3847).": "暫時無法給 {agent} 接入 RTK:RTK 的做法是在 agent 執行 shell 命令前把命令改寫掉,而 {agent} 的 hook 只能放行或攔截命令,不能改寫;RTK 的安裝程式也還沒有它的選項(github.com/rtk-ai/rtk/issues/3847)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "暫時無法給 {agent} 接入 RTK:RTK 的安裝程式還沒有 Grok Build 的選項(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"RTK can't be given to {agent} yet: {agent} runs Grok Build, and RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "暫時無法給 {agent} 接入 RTK:{agent} 執行的是 Grok Build,而 RTK 的安裝程式還沒有 Grok Build 的選項(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"{agent}'s hook needs RTK 0.44 or newer: older ones have no hook for it. Update RTK (brew upgrade rtk, or its installer again), then switch it on.": "{agent} 的 hook 需要 RTK 0.44 或更高版本:舊版沒有它的 hook。請先更新 RTK(brew upgrade rtk,或重新執行其安裝指令碼)再開啟。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "暫時無法給 {agent} 接入 RTK:RTK 的安裝程式還沒有 Qoder 的選項(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: {agent} is Qoder's China build, and RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "暫時無法給 {agent} 接入 RTK:{agent} 是 Qoder 的中國版,而 RTK 的安裝程式還沒有 Qoder 的選項(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer only writes a .clinerules into one project, asking the model to type rtk itself, and has nothing for every project (github.com/rtk-ai/rtk/issues/3841).": "暫時無法給 {agent} 接入 RTK:RTK 的安裝程式只會在單一專案裡寫一個 .clinerules,請模型自己輸入 rtk,沒有對所有專案生效的方式(github.com/rtk-ai/rtk/issues/3841)。",
|
||||
"RTK can't be given to {agent}: {agent}'s hooks can only allow or deny a command, not change it, so RTK's installer only adds instructions to one project's AGENTS.md and has nothing for every project.": "無法給 {agent} 接入 RTK:{agent} 的 hook 只能放行或攔截命令,不能改寫,所以 RTK 的安裝程式只會在單一專案的 AGENTS.md 裡加說明,沒有對所有專案生效的方式。",
|
||||
"RTK can't be given to {agent} yet: RTK has no hook for it.": "暫時無法給 {agent} 接入 RTK:RTK 還沒有它的 hook。",
|
||||
"Get RTK": "取得 RTK",
|
||||
"restart an agent after switching it": "切換後需重啟對應 Agent",
|
||||
@@ -1718,6 +1728,11 @@ magpie.strings({
|
||||
"RTK can't be given to {agent} yet: RTK works by rewriting the shell command an agent is about to run, and {agent}'s hooks can only allow or deny a command, not change it. RTK's installer has no option for it either (github.com/rtk-ai/rtk/issues/3847).": "{agent} にはまだ RTK を使えません。RTK はエージェントが実行しようとするシェルコマンドを書き換えて動きますが、{agent} のフックはコマンドを許可・拒否できるだけで書き換えられません。RTK のインストーラーにもそのためのオプションはありません(github.com/rtk-ai/rtk/issues/3847)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "{agent} にはまだ RTK を使えません。RTK のインストーラーに Grok Build のオプションがありません(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"RTK can't be given to {agent} yet: {agent} runs Grok Build, and RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "{agent} にはまだ RTK を使えません。{agent} は Grok Build を実行しますが、RTK のインストーラーに Grok Build のオプションがありません(github.com/rtk-ai/rtk/issues/2136)。",
|
||||
"{agent}'s hook needs RTK 0.44 or newer: older ones have no hook for it. Update RTK (brew upgrade rtk, or its installer again), then switch it on.": "{agent} のフックには RTK 0.44 以降が必要です。古いバージョンにはそのフックがありません。RTK を更新(brew upgrade rtk、またはインストーラを再実行)してからオンにしてください。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "{agent} にはまだ RTK を使えません。RTK のインストーラーに Qoder のオプションがありません(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: {agent} is Qoder's China build, and RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "{agent} にはまだ RTK を使えません。{agent} は Qoder の中国版で、RTK のインストーラーに Qoder のオプションがありません(github.com/rtk-ai/rtk/issues/1327)。",
|
||||
"RTK can't be given to {agent} yet: RTK's installer only writes a .clinerules into one project, asking the model to type rtk itself, and has nothing for every project (github.com/rtk-ai/rtk/issues/3841).": "{agent} にはまだ RTK を使えません。RTK のインストーラーは 1 つのプロジェクトに .clinerules を書いてモデル自身に rtk を付けさせるだけで、すべてのプロジェクト向けの方法がありません(github.com/rtk-ai/rtk/issues/3841)。",
|
||||
"RTK can't be given to {agent}: {agent}'s hooks can only allow or deny a command, not change it, so RTK's installer only adds instructions to one project's AGENTS.md and has nothing for every project.": "{agent} には RTK を使えません。{agent} のフックはコマンドの許可・拒否しかできず書き換えられないため、RTK のインストーラーは 1 つのプロジェクトの AGENTS.md に説明を加えるだけで、すべてのプロジェクト向けの方法がありません。",
|
||||
"RTK can't be given to {agent} yet: RTK has no hook for it.": "{agent} にはまだ RTK を使えません。RTK にはそのフックがありません。",
|
||||
"Get RTK": "RTK を入手",
|
||||
"restart an agent after switching it": "切り替え後はエージェントを再起動してください",
|
||||
@@ -2444,6 +2459,11 @@ magpie.strings({
|
||||
"RTK can't be given to {agent} yet: RTK works by rewriting the shell command an agent is about to run, and {agent}'s hooks can only allow or deny a command, not change it. RTK's installer has no option for it either (github.com/rtk-ai/rtk/issues/3847).": "RTK lässt sich {agent} noch nicht geben: RTK schreibt den Shell-Befehl um, den ein Agent gleich ausführt, und die Hooks von {agent} können einen Befehl nur erlauben oder ablehnen, nicht ändern. Auch der Installer von RTK hat keine Option dafür (github.com/rtk-ai/rtk/issues/3847).",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "RTK lässt sich {agent} noch nicht geben: Der Installer von RTK hat keine Option für Grok Build (github.com/rtk-ai/rtk/issues/2136).",
|
||||
"RTK can't be given to {agent} yet: {agent} runs Grok Build, and RTK's installer has no option for Grok Build (github.com/rtk-ai/rtk/issues/2136).": "RTK lässt sich {agent} noch nicht geben: {agent} führt Grok Build aus, und der Installer von RTK hat keine Option für Grok Build (github.com/rtk-ai/rtk/issues/2136).",
|
||||
"{agent}'s hook needs RTK 0.44 or newer: older ones have no hook for it. Update RTK (brew upgrade rtk, or its installer again), then switch it on.": "Der Hook von {agent} benötigt RTK 0.44 oder neuer: Ältere Versionen haben keinen Hook dafür. Aktualisieren Sie RTK (brew upgrade rtk oder erneut über den Installer) und schalten Sie es dann ein.",
|
||||
"RTK can't be given to {agent} yet: RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "RTK kann {agent} noch nicht gegeben werden: Der Installer von RTK hat keine Option für Qoder (github.com/rtk-ai/rtk/issues/1327).",
|
||||
"RTK can't be given to {agent} yet: {agent} is Qoder's China build, and RTK's installer has no option for Qoder (github.com/rtk-ai/rtk/issues/1327).": "RTK kann {agent} noch nicht gegeben werden: {agent} ist die China-Version von Qoder, und der Installer von RTK hat keine Option für Qoder (github.com/rtk-ai/rtk/issues/1327).",
|
||||
"RTK can't be given to {agent} yet: RTK's installer only writes a .clinerules into one project, asking the model to type rtk itself, and has nothing for every project (github.com/rtk-ai/rtk/issues/3841).": "RTK kann {agent} noch nicht gegeben werden: Der Installer von RTK schreibt nur eine .clinerules in ein einzelnes Projekt, die das Modell bittet, rtk selbst zu tippen, und hat nichts für alle Projekte (github.com/rtk-ai/rtk/issues/3841).",
|
||||
"RTK can't be given to {agent}: {agent}'s hooks can only allow or deny a command, not change it, so RTK's installer only adds instructions to one project's AGENTS.md and has nothing for every project.": "RTK kann {agent} nicht gegeben werden: Die Hooks von {agent} können einen Befehl nur erlauben oder ablehnen, nicht ändern, daher fügt der Installer von RTK nur Anweisungen zur AGENTS.md eines einzelnen Projekts hinzu und hat nichts für alle Projekte.",
|
||||
"RTK can't be given to {agent} yet: RTK has no hook for it.": "RTK lässt sich {agent} noch nicht geben: RTK hat keinen Hook dafür.",
|
||||
"Get RTK": "RTK holen",
|
||||
"restart an agent after switching it": "Agenten nach dem Umschalten neu starten",
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
// linked dsh's rtk-ai/rtk#3847. Each agent's tag says its own reason now:
|
||||
// Grok Build's cites rtk-ai/rtk#2136, the request for Grok Build, and says
|
||||
// nothing about its hooks.
|
||||
// Discord (lml0664): Qoder, Cline and Kimi Code, which RTK has nothing
|
||||
// global for, are listed each with its own reason (Qoder's cites
|
||||
// rtk-ai/rtk#1327), and Droid, which it has a hook for from RTK 0.44,
|
||||
// says that version when this RTK is older, not Codex's 0.50.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -19,7 +23,7 @@ const HOME = "/Users/aimer";
|
||||
const agent = (id, name) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skills`, mcp: `${HOME}/.${id}/mcp.json` });
|
||||
const lib = () => ({
|
||||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||||
agents: [agent("pi", "Pi"), agent("dsh", "DeepSeek Harness"), agent("grok", "Grok Build")],
|
||||
agents: [agent("pi", "Pi"), agent("dsh", "DeepSeek Harness"), agent("grok", "Grok Build"), agent("qoder", "Qoder"), agent("kimi", "Kimi Code"), agent("droid", "Droid")],
|
||||
instructions: { agents: [], sets: [] }, foundServers: [], projects: [], foundSkills: [], skills: [], servers: [],
|
||||
});
|
||||
const rtkView = () => ({
|
||||
@@ -28,6 +32,9 @@ const rtkView = () => ({
|
||||
{ id: "pi", name: "Pi", icon: "", on: false },
|
||||
{ id: "dsh", name: "DeepSeek Harness", icon: "", on: false, noHook: true, blocked: "RTK has no hook for DeepSeek Harness yet" },
|
||||
{ id: "grok", name: "Grok Build", icon: "", on: false, noHook: true, blocked: "RTK has no hook for Grok Build yet" },
|
||||
{ id: "qoder", name: "Qoder", icon: "", on: false, noHook: true, blocked: "RTK has no hook for Qoder yet" },
|
||||
{ id: "kimi", name: "Kimi Code", icon: "", on: false, noHook: true, blocked: "RTK has no hook for Kimi Code" },
|
||||
{ id: "droid", name: "Droid", icon: "", on: false, blocked: "Droid's hook needs RTK 0.44 or newer" },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -54,8 +61,8 @@ function server(lang, calls) {
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { tag: "No RTK hook", why: "DeepSeek Harness's hooks can only allow or deny a command, not change it", grok: "RTK's installer has no option for Grok Build" },
|
||||
zh: { tag: "RTK 暂不支持", why: "DeepSeek Harness 的 hook 只能放行或拦截命令,不能改写", grok: "RTK 的安装程序还没有 Grok Build 的选项" },
|
||||
en: { tag: "No RTK hook", why: "DeepSeek Harness's hooks can only allow or deny a command, not change it", grok: "RTK's installer has no option for Grok Build", qoder: "RTK's installer has no option for Qoder", kimi: "AGENTS.md", update: "Update RTK", droid: "RTK 0.44 or newer" },
|
||||
zh: { tag: "RTK 暂不支持", why: "DeepSeek Harness 的 hook 只能放行或拦截命令,不能改写", grok: "RTK 的安装程序还没有 Grok Build 的选项", qoder: "RTK 的安装程序还没有 Qoder 的选项", kimi: "AGENTS.md", update: "需更新 RTK", droid: "RTK 0.44 或更高版本" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
@@ -93,6 +100,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(gwhy.includes(w.grok) && gwhy.includes("rtk-ai/rtk/issues/2136"), gwhy);
|
||||
assert(!gwhy.includes("3847") && !gwhy.includes("DeepSeek") && !gwhy.includes("hook"), gwhy);
|
||||
assert.equal(await row("Grok Build").locator(".lib-switch").isDisabled(), true);
|
||||
// Qoder's and Kimi Code's are their own too
|
||||
const qwhy = await row("Qoder").locator(".lib-tag").getAttribute("title");
|
||||
assert(qwhy.includes(w.qoder) && qwhy.includes("rtk-ai/rtk/issues/1327") && !qwhy.includes("2136"), qwhy);
|
||||
const kwhy = await row("Kimi Code").locator(".lib-tag").getAttribute("title");
|
||||
assert(kwhy.includes(w.kimi) && !kwhy.includes("issues/"), kwhy);
|
||||
// Droid with an RTK before 0.44: its own version, not Codex's
|
||||
const dtag = row("Droid").locator(".lib-tag");
|
||||
assert.deepEqual(await dtag.allTextContents(), [w.update]);
|
||||
const dwhy = await dtag.getAttribute("title");
|
||||
assert(dwhy.includes(w.droid) && !dwhy.includes("0.50"), dwhy);
|
||||
assert.equal(await row("Droid").locator(".lib-switch").isDisabled(), true);
|
||||
const sw = row("DeepSeek Harness").locator(".lib-switch");
|
||||
assert.equal(await sw.isDisabled(), true);
|
||||
// Pi has a hook: nothing to say, and it can be switched on
|
||||
|
||||
+85
-2
@@ -198,6 +198,41 @@ var rtkSpecs = map[string]rtkSpec{
|
||||
},
|
||||
"pi": extensionSpec("pi"),
|
||||
"omp": extensionSpec("omp"),
|
||||
// Factory's Droid: rtk 0.44 on (src/hooks/init/droid.rs in 1.1.0)
|
||||
// adds a PreToolUse group matching Execute, running rtk hook droid, to
|
||||
// the one file of Droid's whose PreToolUse hooks Droid runs: the root
|
||||
// hooks.json (or the legacy hooks/hooks.json when there's none), else
|
||||
// settings.json's hooks, and takes a stale one out of the others. It
|
||||
// finds Droid's folder as Droid does, $FACTORY_HOME_OVERRIDE/.factory
|
||||
// or ~/.factory, and is told the one magpie found Droid in. It reads
|
||||
// no patch mode, so --auto-patch isn't given.
|
||||
"droid": {
|
||||
flags: []string{"--agent", "droid"}, blocked: droidBlocked,
|
||||
has: func(a *agent.Agent) bool {
|
||||
for _, f := range droidHookFiles(a) {
|
||||
if contains(f.path, droidHook) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
files: func(a *agent.Agent) []string {
|
||||
var out []string
|
||||
for _, f := range droidHookFiles(a) {
|
||||
out = append(out, f.path)
|
||||
}
|
||||
return out
|
||||
},
|
||||
remove: func(a *agent.Agent) error {
|
||||
var errs []error
|
||||
for _, f := range droidHookFiles(a) {
|
||||
errs = append(errs, dropHook(f.path, f.key, droidHook))
|
||||
}
|
||||
return errors.Join(errs...)
|
||||
},
|
||||
dir: func(a *agent.Agent) string { return a.Dir },
|
||||
env: func(a *agent.Agent) []string { return []string{"FACTORY_HOME_OVERRIDE=" + filepath.Dir(a.Dir)} },
|
||||
},
|
||||
// Hermes's folder is the agent's (appdir.HermesHome): $HERMES_HOME,
|
||||
// else %LOCALAPPDATA%\hermes on Windows and ~/.hermes elsewhere. rtk
|
||||
// (0.51, src/hooks/init/hermes.rs) knows only $HERMES_HOME and
|
||||
@@ -231,13 +266,56 @@ var rtkSpecs = map[string]rtkSpec{
|
||||
var rtkNoHook = map[string]string{
|
||||
"dsh": "RTK has no hook for DeepSeek Harness yet: RTK works by rewriting the shell command an agent is about to run, and dsh's hooks can only allow or deny a command, not change it; rtk init has no --agent dsh either (github.com/rtk-ai/rtk/issues/3847)",
|
||||
// rtk init's agents are claude, cursor, codex, copilot, gemini,
|
||||
// opencode and the rest of rtkSpecs (src/hooks/init in rtk 1.0.1).
|
||||
// opencode and the rest of rtkSpecs (src/hooks/init in rtk 1.1.0).
|
||||
// There is no grok or grok-app, so a hook written here would have
|
||||
// nowhere to go, for Grok Build no more than for the App that runs it.
|
||||
// rtk-ai/rtk#2136 asks for Grok Build, and Grok App runs Grok Build,
|
||||
// so the two share it on purpose (sharedRTKIssues in the test).
|
||||
"grok": "RTK has no hook for Grok Build yet: rtk init has no Grok agent, so it cannot rewrite the shell commands Grok Build runs (github.com/rtk-ai/rtk/issues/2136)",
|
||||
"grok-app": "RTK has no hook for Grok App yet: rtk init has no Grok or Grok App agent, so it cannot rewrite the shell commands Grok App runs (github.com/rtk-ai/rtk/issues/2136)",
|
||||
// rtk 1.1.0 has no Qoder agent: rtk-ai/rtk#1327 asks for one, and its
|
||||
// PR (#1721) is still open. Qoder CN is Qoder's China build, so the two
|
||||
// share it on purpose (sharedRTKIssues in the test).
|
||||
"qoder": "RTK has no hook for Qoder yet: rtk init has no Qoder agent (RTK 1.1.0), so it cannot rewrite the shell commands Qoder CLI runs (github.com/rtk-ai/rtk/issues/1327)",
|
||||
"qoder-cn": "RTK has no hook for Qoder CN yet: rtk init has no Qoder agent (RTK 1.1.0), so it cannot rewrite the shell commands Qoder CN's CLI runs (github.com/rtk-ai/rtk/issues/1327)",
|
||||
// rtk init --agent cline writes .clinerules into the folder it is run
|
||||
// in, asking the model to type rtk itself, and has no hook; it is
|
||||
// project-only (instructions_agents.rs in 1.1.0), so there is nothing
|
||||
// to give every project. rtk-ai/rtk#3841 asks for a hook through Cline
|
||||
// CLI's own hooks.
|
||||
"cline": "RTK has no hook for Cline yet: rtk init --agent cline only writes a .clinerules into one project, asking the model to type rtk itself, and nothing for every project (github.com/rtk-ai/rtk/issues/3841)",
|
||||
// rtk init --agent kimi adds instructions to one project's AGENTS.md and
|
||||
// refuses -g: Kimi Code's PreToolUse hooks can allow or deny a command
|
||||
// but not rewrite it (instructions_agents.rs in 1.1.0).
|
||||
"kimi": "RTK has no hook for Kimi Code: Kimi Code's hooks can only allow or deny a command, not rewrite it, so rtk init --agent kimi only adds instructions to one project's AGENTS.md and refuses to install for every project",
|
||||
}
|
||||
|
||||
// droidHook is the command rtk's Droid hook runs.
|
||||
const droidHook = "rtk hook droid"
|
||||
|
||||
// droidHookFile is one of Droid's files with PreToolUse hooks, and where
|
||||
// in it they are.
|
||||
type droidHookFile struct{ path, key string }
|
||||
|
||||
// droidHookFiles are every file Droid reads PreToolUse hooks from, as rtk
|
||||
// 1.1.0's droid_hook_file_candidates: hooks.json and the legacy
|
||||
// hooks/hooks.json hold them at the top, settings.json under hooks.
|
||||
func droidHookFiles(a *agent.Agent) []droidHookFile {
|
||||
return []droidHookFile{
|
||||
{filepath.Join(a.Dir, "hooks.json"), "PreToolUse"},
|
||||
{filepath.Join(a.Dir, "hooks", "hooks.json"), "PreToolUse"},
|
||||
{filepath.Join(a.Dir, "settings.json"), "hooks.PreToolUse"},
|
||||
}
|
||||
}
|
||||
|
||||
// droidBlocked: rtk has a Droid agent from 0.44.0 on; an older one refuses
|
||||
// --agent droid.
|
||||
func droidBlocked(a *agent.Agent) string {
|
||||
v := rtkVersionOf(a)
|
||||
if v == "" || !older(v, 0, 44) {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("Droid's hook needs RTK 0.44 or newer, and this RTK is %s, which has no Droid hook. Update RTK (brew upgrade rtk, or its installer again), then switch it on", v)
|
||||
}
|
||||
|
||||
func opencodePlugin(a *agent.Agent) string {
|
||||
@@ -462,7 +540,12 @@ func dropHook(path, key, mark string) error {
|
||||
if err := edit.DelJSON(path, key); err != nil {
|
||||
return err
|
||||
}
|
||||
parent := key[:strings.LastIndex(key, ".")]
|
||||
i := strings.LastIndex(key, ".")
|
||||
if i < 0 {
|
||||
// the array was at the top (Droid's hooks.json): the file stays
|
||||
return nil
|
||||
}
|
||||
parent := key[:i]
|
||||
if v, ok := edit.GetJSON(path, parent); ok && strings.TrimSpace(v) == "{}" {
|
||||
return edit.DelJSON(path, parent)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/testenv"
|
||||
)
|
||||
|
||||
// fakeRTKDroid acts as rtk 1.1.0's rtk init -g --agent droid does
|
||||
// (src/hooks/init/droid.rs) where Droid has no hooks yet: it writes the
|
||||
// root hooks.json in $FACTORY_HOME_OVERRIDE/.factory, else ~/.factory, with
|
||||
// rtk's Execute group word for word. It notes the FACTORY_HOME_OVERRIDE it
|
||||
// was given. Any other arguments (--auto-patch among them) are refused.
|
||||
const fakeRTKDroid = `#!/bin/sh
|
||||
case "$1" in
|
||||
--version) echo "rtk $RTK_V"; exit 0 ;;
|
||||
gain) exit 1 ;;
|
||||
esac
|
||||
shift 2
|
||||
[ "$*" = "--agent droid" ] || { echo "unknown: $*" >&2; exit 2; }
|
||||
echo "$FACTORY_HOME_OVERRIDE" > "$HOME/given"
|
||||
d="${FACTORY_HOME_OVERRIDE:-$HOME}/.factory"
|
||||
/bin/mkdir -p "$d"
|
||||
/bin/cat > "$d/hooks.json" <<'J'
|
||||
{
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "Execute",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "rtk hook droid"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
J
|
||||
echo "Factory Droid hook registered (global)."
|
||||
`
|
||||
|
||||
func droidRow(t *testing.T, id string) *RTKAgent {
|
||||
t.Helper()
|
||||
for _, a := range ReadRTK().Agents {
|
||||
if a.ID == id {
|
||||
return &a
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// lml0664 on Discord: the RTK page offered a fixed few agents, though rtk
|
||||
// 1.1.0 has a hook for Factory's Droid too. Droid is listed, switched on
|
||||
// with rtk's own installer (told Droid's folder), and switched off by
|
||||
// magpie taking rtk's group out of whichever of Droid's hook files has it,
|
||||
// leaving the user's own hooks and settings; an rtk before 0.44, which has
|
||||
// no Droid agent, isn't run for it.
|
||||
func TestRTKDroid(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("the fake rtk is a shell script")
|
||||
}
|
||||
h := sandbox(t)
|
||||
bin := filepath.Join(h, "bin")
|
||||
testenv.Program(t, filepath.Join(bin, "rtk"), fakeRTKDroid)
|
||||
holdCLI(t, h, "droid")
|
||||
t.Setenv("PATH", bin)
|
||||
for _, c := range []struct{ name, override string }{
|
||||
{"home", ""},
|
||||
// Droid's own FACTORY_HOME_OVERRIDE: its folder isn't ~/.factory
|
||||
{"override", filepath.Join(h, "elsewhere")},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Setenv("FACTORY_HOME_OVERRIDE", c.override)
|
||||
root := h
|
||||
if c.override != "" {
|
||||
root = c.override
|
||||
}
|
||||
dir := filepath.Join(root, ".factory")
|
||||
settings := filepath.Join(dir, "settings.json")
|
||||
mine := `{"sessionDefaultSettings": {"model": "x"}}`
|
||||
write(t, settings, mine)
|
||||
hooks := filepath.Join(dir, "hooks.json")
|
||||
|
||||
t.Setenv("RTK_V", "0.43.0")
|
||||
a := droidRow(t, "droid")
|
||||
if a == nil {
|
||||
t.Fatal("Droid isn't on the RTK page")
|
||||
}
|
||||
if !strings.Contains(a.Blocked, "0.44") || a.On || a.NoHook {
|
||||
t.Fatalf("rtk 0.43: %+v", a)
|
||||
}
|
||||
if _, err := SetRTK("droid", true); err == nil || !strings.Contains(err.Error(), "RTK 0.44 or newer") {
|
||||
t.Fatalf("switched on with rtk 0.43: %v", err)
|
||||
}
|
||||
if exists(hooks) {
|
||||
t.Fatal("rtk 0.43's installer was run for Droid")
|
||||
}
|
||||
|
||||
t.Setenv("RTK_V", "1.1.0")
|
||||
if a := droidRow(t, "droid"); a.Blocked != "" || a.On {
|
||||
t.Fatalf("rtk 1.1 before switching on: %+v", a)
|
||||
}
|
||||
if _, err := SetRTK("droid", true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := strings.TrimSpace(read(t, filepath.Join(h, "given"))); got != root {
|
||||
t.Errorf("rtk was given FACTORY_HOME_OVERRIDE=%q, want %q", got, root)
|
||||
}
|
||||
if !contains(hooks, "rtk hook droid") {
|
||||
t.Fatalf("no hook in %s", hooks)
|
||||
}
|
||||
if a := droidRow(t, "droid"); !a.On {
|
||||
t.Fatal("Droid isn't seen with rtk on")
|
||||
}
|
||||
if id, err := RTKTakes("droid"); err != nil || id != "droid" {
|
||||
t.Fatalf("RTKTakes(droid) = %q, %v", id, err)
|
||||
}
|
||||
if _, err := SetRTK("droid", false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if contains(hooks, "rtk hook droid") {
|
||||
t.Error("rtk's hook is still in hooks.json")
|
||||
}
|
||||
if a := droidRow(t, "droid"); a.On {
|
||||
t.Fatal("Droid still seen with rtk on")
|
||||
}
|
||||
if got := read(t, settings); got != mine {
|
||||
t.Errorf("settings.json = %q", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// rtk puts its group into settings.json's hooks when that is where Droid's
|
||||
// PreToolUse hooks already are; taking it out there leaves the user's own
|
||||
// hook in the same Execute list, and their other settings.
|
||||
func TestRTKDroidSettingsHooks(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
holdCLI(t, h, "droid")
|
||||
t.Setenv("FACTORY_HOME_OVERRIDE", "")
|
||||
settings := filepath.Join(h, ".factory", "settings.json")
|
||||
write(t, settings, `{
|
||||
"sessionDefaultSettings": {"model": "x"},
|
||||
"hooks": {
|
||||
"PreToolUse": [
|
||||
{"matcher": "Execute", "hooks": [
|
||||
{"type": "command", "command": "my-guard"},
|
||||
{"type": "command", "command": "rtk hook droid"}
|
||||
]}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
if a := droidRow(t, "droid"); a == nil || !a.On {
|
||||
t.Fatalf("Droid with rtk's hook in settings.json: %+v", a)
|
||||
}
|
||||
if _, err := SetRTK("droid", false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if contains(settings, "rtk hook droid") || !contains(settings, "my-guard") || !contains(settings, `"model"`) {
|
||||
t.Fatalf("settings.json after switching off: %s", read(t, settings))
|
||||
}
|
||||
}
|
||||
|
||||
// Agents RTK has no global hook for are listed with their own reason, and
|
||||
// never switched on: Qoder and Qoder CN (no Qoder agent in rtk 1.1.0,
|
||||
// rtk-ai/rtk#1327), Cline (one project's .clinerules only, #3841) and Kimi
|
||||
// Code (one project's AGENTS.md only; its hooks can't rewrite).
|
||||
func TestRTKNoHookQoderClineKimi(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
for _, b := range []string{"qodercli", "qoderclicn", "cline", "kimi"} {
|
||||
holdCLI(t, h, b)
|
||||
}
|
||||
for _, c := range []struct{ id, why string }{
|
||||
{"qoder", "no Qoder agent"},
|
||||
{"qoder-cn", "no Qoder agent"},
|
||||
{"cline", ".clinerules"},
|
||||
{"kimi", "AGENTS.md"},
|
||||
} {
|
||||
a := droidRow(t, c.id)
|
||||
if a == nil {
|
||||
t.Errorf("%s isn't listed", c.id)
|
||||
continue
|
||||
}
|
||||
if b, _ := json.Marshal(a); a.On || !a.NoHook || !strings.Contains(a.Blocked, c.why) {
|
||||
t.Errorf("%s listed as %s", c.id, b)
|
||||
}
|
||||
if _, err := SetRTK(c.id, true); err == nil || !strings.Contains(err.Error(), c.why) {
|
||||
t.Errorf("%s switched on: %v", c.id, err)
|
||||
}
|
||||
if _, err := RTKTakes(c.id); err == nil || !strings.Contains(err.Error(), c.why) {
|
||||
t.Errorf("magpie library rtk on %s: %v", c.id, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
var sharedRTKIssues = map[[2]string]string{
|
||||
// Grok App runs Grok Build, and rtk-ai/rtk#2136 asks for Grok Build.
|
||||
{"grok", "grok-app"}: "Grok App runs Grok Build",
|
||||
// Qoder CN is Qoder's China build, and rtk-ai/rtk#1327 asks for Qoder.
|
||||
{"qoder", "qoder-cn"}: "Qoder CN is Qoder's China build",
|
||||
}
|
||||
|
||||
var rtkIssueRe = regexp.MustCompile(`github\.com/([\w.-]+/[\w.-]+)/issues/(\d+)`)
|
||||
|
||||
Reference in New Issue
Block a user