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).
114 lines
3.6 KiB
Go
114 lines
3.6 KiB
Go
package library
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
"slices"
|
|
"sort"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// sharedRTKIssues are the agents that cite the same rtk-ai/rtk issues on
|
|
// purpose, each with why. Any other two agents citing the same list is a
|
|
// reason copied from one agent onto another.
|
|
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+)`)
|
|
|
|
func rtkIssues(s string) []string {
|
|
var out []string
|
|
for _, m := range rtkIssueRe.FindAllStringSubmatch(s, -1) {
|
|
out = append(out, m[1]+"#"+m[2])
|
|
}
|
|
sort.Strings(out)
|
|
return slices.Compact(out)
|
|
}
|
|
|
|
// The RTK tab's no-hook tag says each agent's own reason and cites its
|
|
// own issues (新v学员 on Discord: Grok Build's tag said DeepSeek Harness's
|
|
// hooks can't rewrite a command and linked dsh's rtk-ai/rtk#3847, since
|
|
// every agent got dsh's text). The page's reasons (rtkNoHookWhy in
|
|
// plugins/library/client.js) cover every agent in rtkNoHook and cite the
|
|
// same issues as rtk.go's, two agents share an issue list only when
|
|
// sharedRTKIssues says why, and the fallback for an agent with no entry
|
|
// cites nothing.
|
|
func TestRTKNoHookIssuesAreEachAgents(t *testing.T) {
|
|
src, err := os.ReadFile(filepath.Join("..", "gui", "assets", "plugins", "library", "client.js"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := string(src)
|
|
start := strings.Index(s, "function rtkNoHookWhy(")
|
|
if start < 0 {
|
|
t.Fatal("client.js has no rtkNoHookWhy: the no-hook tag isn't per agent")
|
|
}
|
|
end := strings.Index(s[start:], "\n }\n")
|
|
if end < 0 {
|
|
t.Fatal("rtkNoHookWhy has no end")
|
|
}
|
|
body := s[start : start+end]
|
|
page := map[string]string{}
|
|
fallback, hasFallback := "", false
|
|
for _, line := range strings.Split(body, "\n") {
|
|
if m := regexp.MustCompile(`^\s*case "([\w-]+)": return (.*)$`).FindStringSubmatch(line); m != nil {
|
|
page[m[1]] = m[2]
|
|
} else if m := regexp.MustCompile(`^\s*default: return (.*)$`).FindStringSubmatch(line); m != nil {
|
|
fallback, hasFallback = m[1], true
|
|
}
|
|
}
|
|
if !hasFallback {
|
|
t.Error("rtkNoHookWhy has no default reason")
|
|
}
|
|
if got := rtkIssues(fallback); len(got) > 0 {
|
|
t.Errorf("the reason for an agent with no entry cites %v", got)
|
|
}
|
|
|
|
ids := make([]string, 0, len(rtkNoHook))
|
|
for id := range rtkNoHook {
|
|
ids = append(ids, id)
|
|
}
|
|
sort.Strings(ids)
|
|
for _, id := range ids {
|
|
why, ok := page[id]
|
|
if !ok {
|
|
t.Errorf("%s is in rtkNoHook but the page has no reason for it", id)
|
|
continue
|
|
}
|
|
if g, p := rtkIssues(rtkNoHook[id]), rtkIssues(why); !slices.Equal(g, p) {
|
|
t.Errorf("%s cites %v in rtk.go and %v on the page", id, g, p)
|
|
}
|
|
}
|
|
for id := range page {
|
|
if _, ok := rtkNoHook[id]; !ok {
|
|
t.Errorf("the page has a reason for %s, which rtkNoHook doesn't list", id)
|
|
}
|
|
}
|
|
|
|
for _, src := range []map[string]string{rtkNoHook, page} {
|
|
for i, a := range ids {
|
|
for _, b := range ids[i+1:] {
|
|
ia, ib := rtkIssues(src[a]), rtkIssues(src[b])
|
|
if len(ia) == 0 || !slices.Equal(ia, ib) {
|
|
continue
|
|
}
|
|
if _, ok := sharedRTKIssues[[2]string{a, b}]; !ok {
|
|
t.Errorf("%s and %s both cite %v: one's reason was copied onto the other", a, b, ia)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// a deliberate share that no longer holds is dropped from the list
|
|
for pair := range sharedRTKIssues {
|
|
if ia := rtkIssues(rtkNoHook[pair[0]]); len(ia) == 0 || !slices.Equal(ia, rtkIssues(rtkNoHook[pair[1]])) {
|
|
t.Errorf("sharedRTKIssues lists %v, which don't share an issue list", pair)
|
|
}
|
|
}
|
|
}
|