library: agents in a running WSL distro take skills, MCP servers and instructions (#331) — the Library knew only this machine's agent ids, so codex@wsl:Ubuntu and the like were never offered, and the id's colon was refused as an agent's name and can't be in a Windows file name. Claude Code, Codex, Pi and OmO in a distro now get them at their default places under the distro's $HOME through \\wsl.localhost, only while it runs (opening a stopped one's files starts it; its state is kept and asking for it says to start it). Skills go in as copies, made beside and renamed into place and made again when the library's changes, since a Linux agent can't follow a link to a Windows folder (project skills share the same copy code); an MCP server that runs a Windows program (C:\…, *.exe/.cmd/.bat/.ps1) is refused for them with a message; Pi there gets no MCP servers, where its version decides the file. The id's colon is a dot in file and folder names, and setup export/import turns it back. TestWSLTargets, TestWSLSkillsCopied, TestWSLServers and TestWSLInstructions (a fake distro) fail without the change. go vet (and GOOS=windows for agent, library), go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. Not run against a real distro.

This commit is contained in:
yetone
2026-09-30 22:17:23 +08:00
parent 007a84964a
commit b03967bb79
13 changed files with 386 additions and 26 deletions
+5
View File
@@ -87,6 +87,11 @@ type Agent struct {
// WSL is the distro an agent inside WSL lives in, "" for this
// machine's own (see wsl.go).
WSL string
// Home is a WSL agent's $HOME in its distro as magpie opens it
// (\\wsl.localhost\<distro>\home\me), where its other files are; ""
// for this machine's, and while the distro is stopped: opening it
// would start it.
Home string
// Import, for an app that takes magpie only through an import link of
// its own, which the user confirms there (Cindy), is that link; the app
// has no fields magpie sets. Added says whether it has magpie already.
+7 -1
View File
@@ -247,6 +247,9 @@ func wslAgent(k wslKind, d distro) *Agent {
id := k.id + "@wsl:" + d.Name
a := k.in(d.place(id))
a.ID, a.Name, a.Aliases, a.Bin, a.UA, a.WSL = id, k.name+" · WSL "+d.Name, nil, "", nil, d.Name
if d.Running {
a.Home = d.local(d.Home)
}
a.detect = func() bool { return k.found(d) }
// its requests carry the agent's User-Agent and are counted as its
// Windows twin's, so a prompt with none of "its" own seen isn't a bypass
@@ -341,7 +344,7 @@ func asleep(live *Agent, k wslKind, d distro) *Agent {
// wslAgents are the agents in this machine's WSL distros; none off Windows.
func wslAgents() []*Agent {
if runtime.GOOS != "windows" {
if !wslOn {
return nil
}
return wslAgentsOf(wslDistros())
@@ -382,6 +385,9 @@ const (
wslRetryAge = 10 * time.Minute
)
// wslOn is whether there is WSL to look in: on Windows, or in tests.
var wslOn = runtime.GOOS == "windows"
// wslRun runs wsl.exe; a var for tests.
var wslRun = func(timeout time.Duration, args ...string) ([]byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
+46
View File
@@ -0,0 +1,46 @@
package agent
import (
"errors"
"strings"
"time"
)
// FakeWSL, for other packages' tests, stands in for wsl.exe on any
// system: each distro named in probes is installed and running, answers
// the probe with what probes has for it (wslProbeScript's output: "home:/
// home/me\ndir:.codex\n…") and is opened at roots' folder for it. What
// magpie remembers of WSL is forgotten, before and after; the returned
// func puts everything back.
func FakeWSL(probes, roots map[string]string) func() {
on, run, root := wslOn, wslRun, wslRoot
reset := func() {
wsl.Lock()
wsl.seen, wsl.at, wsl.names, wsl.running, wsl.probed, wsl.failed, wsl.dirty = nil, time.Time{}, nil, nil, nil, nil, false
wsl.Unlock()
}
reset()
var names []string
for n := range probes {
names = append(names, n)
}
list := []byte(strings.Join(names, "\n"))
wslOn = true
wslRun = func(_ time.Duration, args ...string) ([]byte, error) {
switch strings.Join(args, " ") {
case "-l -q", "-l --running -q":
return list, nil
}
if len(args) > 2 && args[0] == "-d" {
if p, ok := probes[args[1]]; ok {
return []byte(p), nil
}
}
return nil, errors.New("unexpected wsl.exe " + strings.Join(args, " "))
}
wslRoot = func(name string) string { return roots[name] }
return func() {
wslOn, wslRun, wslRoot = on, run, root
reset()
}
}
+2 -2
View File
@@ -45,11 +45,11 @@ func (b *backups) keep(agent, path string) error {
if b.dir == "" {
b.dir = filepath.Join(BackupDir(), time.Now().Format("2006-01-02_15-04-05.000"))
}
dst := filepath.Join(b.dir, agent, filepath.Base(path))
dst := filepath.Join(b.dir, fileName(agent), filepath.Base(path))
if _, err := os.Stat(dst); err == nil {
// another file by that name (each dsh profile's cordis.patch.yml):
// kept under its folder's name
dst = filepath.Join(b.dir, agent, filepath.Base(filepath.Dir(path)), filepath.Base(path))
dst = filepath.Join(b.dir, fileName(agent), filepath.Base(filepath.Dir(path)), filepath.Base(path))
}
if err := os.MkdirAll(filepath.Dir(dst), 0o700); err != nil {
return err
+1 -1
View File
@@ -154,7 +154,7 @@ func (b *Bundle) check() error {
}
}
for id := range b.Extra {
if err := checkName("agent", id); err != nil {
if err := checkAgent(id); err != nil {
return err
}
}
+2 -2
View File
@@ -68,7 +68,7 @@ func (l *Library) active() string {
func (l *Library) sharedPath() string { return setPath(l.active()) }
func extraPath(agent string) string {
return filepath.Join(Dir(), "instructions", agent+".md")
return filepath.Join(Dir(), "instructions", fileName(agent)+".md")
}
func readText(path string) string {
@@ -298,7 +298,7 @@ func SaveInstructions(c InstructionsChange) (*Result, error) {
if x == nil {
continue
}
if err := checkName("agent", id); err != nil {
if err := checkAgent(id); err != nil {
return err
}
if err := writeText(extraPath(id), *x); err != nil {
+19
View File
@@ -12,6 +12,7 @@ import (
"regexp"
"slices"
"sort"
"strings"
"sync"
"github.com/yetone/magpie/internal/edit"
@@ -138,6 +139,24 @@ func checkName(kind, name string) error {
return nil
}
// agentRe is an agent's id: a name, or one in a WSL distro's
// (codex@wsl:Ubuntu-24.04).
var agentRe = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_-]{0,63}(@wsl:[A-Za-z0-9][A-Za-z0-9._-]{0,63})?$`)
func checkAgent(id string) error {
if !agentRe.MatchString(id) {
return fmt.Errorf("agent %q: not an agent's id", id)
}
return nil
}
// fileName is an agent's id as the name of a file or folder of its:
// Windows has no colon in one, so a WSL agent's is codex@wsl.Ubuntu.
func fileName(id string) string { return strings.Replace(id, "@wsl:", "@wsl.", 1) }
// agentOfFile is the agent's id a fileName is of.
func agentOfFile(name string) string { return strings.Replace(name, "@wsl.", "@wsl:", 1) }
// set turns id on or off in a list of agent ids, which stays sorted.
func set(list []string, id string, on bool) []string {
i := slices.Index(list, id)
+11
View File
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"maps"
"regexp"
"slices"
"sort"
"strings"
@@ -148,6 +149,9 @@ type mcpFile struct {
// library, but not written: Pi's mcp.json that pi-mcp-adapter no longer
// reads, with what couldn't be moved from it.
Extra []string
// WSL: the agent runs in a WSL distro, where a Windows program isn't
// one it can start
WSL bool
}
// files are every file the servers are written into.
@@ -179,9 +183,16 @@ func (f *mcpFile) supports(s *Server) error {
if f.Format == fmtDsh && s.Name != "" && !dshServerName.MatchString(s.Name) {
return errDshName
}
if f.WSL && !s.Remote() && windowsPath.MatchString(s.Command) {
return fmt.Errorf("it runs a Windows program (%s), which an agent in WSL can't start: give it a command WSL has", s.Command)
}
return nil
}
// windowsPath is a program named as Windows names one: C:/…, a path with a
// backslash in it, or …/npx.cmd.
var windowsPath = regexp.MustCompile(`^[A-Za-z]:[\\/]|\\|(?i)\.(?:exe|cmd|bat|ps1)$`)
// errNoRemote is what the page says of an app that reaches only a server
// it runs itself (Claude Desktop, whose remote ones are its Connectors).
var errNoRemote = errors.New("no-remote")
+1 -16
View File
@@ -170,22 +170,7 @@ func (p *Project) place(e, name string) error {
}
return link(abs, name)
}
// the new copy is made beside and put in the old one's place
next := filepath.Join(filepath.Dir(abs), "."+name+".magpie-next")
os.RemoveAll(next)
if err := copyDir(realDir(lib), next); err != nil {
os.RemoveAll(next)
return err
}
if err := os.WriteFile(filepath.Join(next, marker), []byte("copied from "+lib+" by magpie, and copied again when it changes\n"), 0o644); err != nil {
os.RemoveAll(next)
return err
}
if err := unlink(abs); err != nil {
os.RemoveAll(next)
return err
}
return os.Rename(next, abs)
return copyIn(abs, name)
}
// mkdirs makes dir and the folders above it the project hasn't, noting
+3 -2
View File
@@ -101,7 +101,8 @@ func extras() map[string]string {
es, _ := os.ReadDir(filepath.Dir(extraPath("x")))
for _, e := range es {
id, ok := strings.CutSuffix(e.Name(), ".md")
if !ok || e.IsDir() || checkName("agent", id) != nil {
id = agentOfFile(id)
if !ok || e.IsDir() || checkAgent(id) != nil {
continue
}
if text := readText(extraPath(id)); text != "" {
@@ -162,7 +163,7 @@ func Restore(s *Setup) (*Result, error) {
texts[extraPath(id)] = ""
}
for id, text := range s.Instructions.Extra {
if err := checkName("agent", id); err != nil {
if err := checkAgent(id); err != nil {
return err
}
texts[extraPath(id)] = text
+42 -2
View File
@@ -155,6 +155,34 @@ func link(p, name string) error {
return os.WriteFile(filepath.Join(p, marker), []byte("copied from "+skillDir(name)+"\n"), 0o644)
}
// copyIn puts a copy of the library's skill at p, marked as magpie's, in
// place of a link: made beside it and put in the place of what is there,
// so the agent never finds half of one.
func copyIn(p, name string) error {
lib := skillDir(name)
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
return err
}
next := filepath.Join(filepath.Dir(p), "."+name+".magpie-next")
os.RemoveAll(next)
if err := copyDir(realDir(lib), next); err != nil {
os.RemoveAll(next)
return err
}
if err := os.WriteFile(filepath.Join(next, marker), []byte("copied from "+lib+" by magpie, and copied again when it changes\n"), 0o644); err != nil {
os.RemoveAll(next)
return err
}
if err := unlink(p); err != nil {
os.RemoveAll(next)
return err
}
return os.Rename(next, p)
}
// fresh is whether the copy at p holds what the library's skill does.
func fresh(p, name string) bool { return hashDir(p) == hashDir(realDir(skillDir(name))) }
func unlink(p string) error {
fi, err := os.Lstat(p)
if err != nil {
@@ -304,6 +332,14 @@ func (l *Library) syncSkills(t *Target, res *Result, all []*Target) {
// the folder the library's skill links to is there already: one
// brought in from ~/.agents/skills, which stays where it is
if ours(p, s.Name) || realDir(p) == realDir(skillDir(s.Name)) {
// a copy is made again once the library's skill has changed
if t.Copy && ours(p, s.Name) && (linked(p) || !fresh(p, s.Name)) {
if err := copyIn(p, s.Name); err != nil {
res.fail(id, "skill:"+s.Name, err)
} else {
res.changed(id)
}
}
mine = append(mine, s.Name)
continue
}
@@ -323,7 +359,11 @@ func (l *Library) syncSkills(t *Target, res *Result, all []*Target) {
continue
}
}
if err := link(p, s.Name); err != nil {
put := link
if t.Copy {
put = copyIn
}
if err := put(p, s.Name); err != nil {
res.fail(id, "skill:"+s.Name, err)
continue
}
@@ -1223,7 +1263,7 @@ func (e *leftBehind) Unwrap() error { return e.err }
// setAside moves an agent's own skill (a folder, or a link) out of its
// way, into a backup of its own: nothing of the user's is just deleted.
func setAside(agent, p string) (string, error) {
dst := filepath.Join(BackupDir(), time.Now().Format("2006-01-02_15-04-05.000"), agent, "skills", filepath.Base(p))
dst := filepath.Join(BackupDir(), time.Now().Format("2006-01-02_15-04-05.000"), fileName(agent), "skills", filepath.Base(p))
for i := 2; ; i++ {
if _, err := os.Lstat(dst); errors.Is(err, fs.ErrNotExist) {
break
+52
View File
@@ -28,6 +28,10 @@ type Target struct {
MCPVia string
// Note is what the page says of the agent's instructions file.
Note string
// Copy is an agent that gets a copy of each skill, made again when
// the library's changes, rather than a link: one in a WSL distro,
// which can't follow a link to a Windows folder.
Copy bool
}
func home() string { h, _ := os.UserHomeDir(); return h }
@@ -58,6 +62,9 @@ func codexDir() string {
// targetOf is where a known agent keeps them, or nil for one magpie can't
// give any of them to.
func targetOf(a *agent.Agent) *Target {
if a.WSL != "" {
return wslTargetOf(a)
}
h := home()
t := &Target{Agent: a}
switch a.ID {
@@ -261,6 +268,48 @@ func targetOf(a *agent.Agent) *Target {
return t
}
// wslTargetOf is where an agent in a WSL distro keeps them: its files at
// their defaults under the distro's $HOME (the distro's variables that
// move them aren't read), opened through \\wsl.localhost; nil while the
// distro is stopped, which opening them would start. What is written is
// the same as for this machine's agent: nothing in it names a place on
// Windows, and each skill is a copy.
func wslTargetOf(a *agent.Agent) *Target {
h := a.Home
if h == "" {
return nil
}
t := &Target{Agent: a, Copy: true}
id, _, _ := strings.Cut(a.ID, "@")
switch id {
case "claude":
d := filepath.Join(h, ".claude")
t.Instructions = filepath.Join(d, "CLAUDE.md")
t.MCP = &mcpFile{Path: filepath.Join(h, ".claude.json"), Format: fmtClaude, WSL: true}
t.Skills = filepath.Join(d, "skills")
case "codex":
d := filepath.Join(h, ".codex")
t.Instructions = filepath.Join(d, "AGENTS.md")
t.Override = filepath.Join(d, "AGENTS.override.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "config.toml"), Format: fmtCodex, WSL: true}
t.Skills = filepath.Join(d, "skills")
case "pi":
// its MCP servers go where the Pi installed there reads them,
// which its version decides (piMCP), and that isn't known here
d := filepath.Join(h, ".pi", "agent")
t.Instructions = filepath.Join(d, "AGENTS.md")
t.Skills = filepath.Join(d, "skills")
case "omo":
d := filepath.Join(h, ".omo", "agent")
t.Instructions = filepath.Join(d, "AGENTS.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "mcp.json"), Format: fmtPiNative, WSL: true}
t.Skills = filepath.Join(d, "skills")
default:
return nil
}
return t
}
// apps are what the library can give MCP servers to that aren't agents
// magpie sets up: known by the folder they keep their settings in.
func apps() []*agent.Agent {
@@ -384,6 +433,9 @@ func Takes(q, kind string) (string, error) {
t := targetOf(a)
var has bool
what := map[string]string{"instructions": "instructions", "mcp": "MCP servers", "skills": "skills"}[kind]
if t == nil && a.WSL != "" && a.Home == "" {
return "", fmt.Errorf("WSL %s isn't running: start it, and %s can be given %s", a.WSL, a.Name, what)
}
if t != nil {
switch kind {
case "instructions":
+195
View File
@@ -0,0 +1,195 @@
package library
import (
"os"
"path/filepath"
"slices"
"strings"
"testing"
"github.com/yetone/magpie/internal/agent"
)
// wslSandbox is sandbox with a running WSL distro, Ubuntu-24.04, whose /
// is a temp folder and whose user /home/me has Codex, Claude Code, Pi and
// OmO; it gives back that user's home as magpie opens it.
func wslSandbox(t *testing.T) string {
t.Helper()
sandbox(t)
root := t.TempDir()
home := filepath.Join(root, "home", "me")
write(t, filepath.Join(home, ".codex", "config.toml"), "model = \"gpt-5.5\"\n")
write(t, filepath.Join(home, ".claude", "settings.json"), "{}\n")
write(t, filepath.Join(home, ".pi", "agent", "settings.json"), "{}\n")
write(t, filepath.Join(home, ".omo", "agent", "settings.json"), "{}\n")
t.Cleanup(agent.FakeWSL(map[string]string{
"Ubuntu-24.04": "home:/home/me\ndir:.codex\ndir:.claude\ndir:.pi\ndir:.omo\n",
}, map[string]string{"Ubuntu-24.04": root}))
return home
}
const (
wslCodex = "codex@wsl:Ubuntu-24.04"
wslClaude = "claude@wsl:Ubuntu-24.04"
wslPi = "pi@wsl:Ubuntu-24.04"
wslOmO = "omo@wsl:Ubuntu-24.04"
)
// The agents magpie found in a WSL distro are the library's to give to
// (#331), each at its own files in the distro's home, not Windows'.
func TestWSLTargets(t *testing.T) {
h := wslSandbox(t)
want := map[string][3]string{ // instructions, MCP, skills
wslCodex: {".codex/AGENTS.md", ".codex/config.toml", ".codex/skills"},
wslClaude: {".claude/CLAUDE.md", ".claude.json", ".claude/skills"},
wslPi: {".pi/agent/AGENTS.md", "", ".pi/agent/skills"},
wslOmO: {".omo/agent/AGENTS.md", ".omo/agent/mcp.json", ".omo/agent/skills"},
}
for id, w := range want {
tg := targetByID(id)
if tg == nil {
t.Fatalf("%s isn't a target: %v", id, ids(Targets()))
}
mcp := ""
if tg.MCP != nil {
mcp = tg.MCP.Path
}
at := func(rel string) string {
if rel == "" {
return ""
}
return filepath.Join(h, rel)
}
if tg.Instructions != at(w[0]) || mcp != at(w[1]) || tg.Skills != at(w[2]) || !tg.Copy {
t.Errorf("%s: %+v (mcp %s)", id, tg, mcp)
}
}
for _, kind := range []string{"instructions", "mcp", "skills"} {
if id, err := Takes("Codex · WSL Ubuntu-24.04", kind); err != nil || id != wslCodex {
t.Errorf("Takes %s: %s %v", kind, id, err)
}
}
// a stopped distro's is none: opening its files would start it
if tg := targetOf(&agent.Agent{ID: "codex@wsl:Stopped", WSL: "Stopped"}); tg != nil {
t.Errorf("stopped distro: %+v", tg)
}
}
// A skill reaches an agent in WSL as a copy — a link to a Windows folder
// is nothing it can follow — which is copied again when the library's
// changes, and taken away with the rest.
func TestWSLSkillsCopied(t *testing.T) {
h := wslSandbox(t)
src := filepath.Join(home(), "src", "skills")
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
ok(t)(InstallSkills(src, []string{"pdf"}, []string{"claude", wslCodex, wslClaude, wslPi}))
for _, d := range []string{".codex/skills/pdf", ".claude/skills/pdf", ".pi/agent/skills/pdf"} {
p := filepath.Join(h, d)
fi, err := os.Lstat(p)
if err != nil || !fi.IsDir() {
t.Fatalf("%s: not a folder: %v", d, err)
}
if !strings.Contains(read(t, filepath.Join(p, "SKILL.md")), "Read PDFs") || read(t, filepath.Join(p, "scripts/run.sh")) != "echo hi\n" || !ours(p, "pdf") {
t.Errorf("%s isn't the library's skill", d)
}
}
if !linked(filepath.Join(home(), ".claude/skills/pdf")) {
t.Error("this machine's Claude Code got a copy, not a link")
}
// the skill is its folder: an edit there reaches the copies at the next sync
write(t, filepath.Join(src, "pdf/SKILL.md"), "---\nname: pdf\ndescription: Changed\n---\n")
res := ok(t)(Sync())
if !slices.Contains(res.Changed, wslCodex) {
t.Errorf("changed: %v", res.Changed)
}
if !strings.Contains(read(t, filepath.Join(h, ".codex/skills/pdf/SKILL.md")), "Changed") {
t.Error("the copy wasn't made again")
}
if res := ok(t)(Sync()); len(res.Changed) != 0 {
t.Errorf("a sync with nothing new wrote %v", res.Changed)
}
ok(t)(SkillAgents("pdf", []string{"claude", wslClaude}))
if _, err := os.Lstat(filepath.Join(h, ".codex/skills/pdf")); !os.IsNotExist(err) {
t.Errorf("codex@wsl still has it: %v", err)
}
if !ours(filepath.Join(h, ".claude/skills/pdf"), "pdf") {
t.Error("claude@wsl lost it")
}
}
// MCP servers are written into the distro's files in each agent's own
// format; one that runs a Windows program isn't given to them.
func TestWSLServers(t *testing.T) {
h := wslSandbox(t)
ok(t)(SaveServer("", Server{Name: "fetch", Transport: "stdio", Command: "uvx", Args: []string{"mcp-server-fetch"},
Agents: []string{"codex", wslCodex, wslClaude, wslOmO}}))
if s := read(t, filepath.Join(h, ".codex/config.toml")); !strings.Contains(s, "[mcp_servers.fetch]") || !strings.Contains(s, `command = "uvx"`) || !strings.Contains(s, `model = "gpt-5.5"`) {
t.Errorf("codex@wsl config.toml:\n%s", s)
}
if s := read(t, filepath.Join(h, ".claude.json")); !strings.Contains(s, `"fetch"`) || !strings.Contains(s, `"uvx"`) {
t.Errorf("claude@wsl .claude.json:\n%s", s)
}
if s := read(t, filepath.Join(h, ".omo/agent/mcp.json")); !strings.Contains(s, `"fetch"`) {
t.Errorf("omo@wsl mcp.json:\n%s", s)
}
if s := read(t, filepath.Join(home(), ".codex/config.toml")); !strings.Contains(s, "[mcp_servers.fetch]") {
t.Errorf("this machine's codex:\n%s", s)
}
res, err := SaveServer("", Server{Name: "win", Transport: "stdio", Command: `C:\Program Files\nodejs\npx.cmd`, Args: []string{"x"},
Agents: []string{"codex", wslCodex}})
if err != nil {
t.Fatal(err)
}
if len(res.Problems) != 1 || res.Problems[0].Agent != wslCodex || res.Problems[0].What != "mcp:win" {
t.Errorf("problems: %+v", res.Problems)
}
if strings.Contains(read(t, filepath.Join(h, ".codex/config.toml")), "mcp_servers.win") {
t.Error("the Windows program was given to codex@wsl")
}
if !strings.Contains(read(t, filepath.Join(home(), ".codex/config.toml")), "mcp_servers.win") {
t.Error("this machine's codex didn't get it")
}
}
// The shared instructions, and what one WSL agent gets besides, go into
// its file in the distro; the files magpie keeps of it are named without
// the colon Windows can't have in a name.
func TestWSLInstructions(t *testing.T) {
h := wslSandbox(t)
write(t, filepath.Join(h, ".codex/AGENTS.md"), "Mine.\n")
shared, extra := "Be brief.", "Use apt."
res := ok(t)(SaveInstructions(InstructionsChange{Shared: &shared, Agents: []string{wslCodex, wslClaude},
Extra: map[string]*string{wslCodex: &extra}}))
s := read(t, filepath.Join(h, ".codex/AGENTS.md"))
if !strings.HasPrefix(s, "Mine.\n") || !strings.Contains(s, "Be brief.\n\nUse apt.") {
t.Errorf("codex@wsl AGENTS.md:\n%s", s)
}
if s := read(t, filepath.Join(h, ".claude/CLAUDE.md")); !strings.Contains(s, "Be brief.") || strings.Contains(s, "apt") {
t.Errorf("claude@wsl CLAUDE.md:\n%s", s)
}
// what it gets besides, and its file kept before the change
for _, dir := range []string{filepath.Dir(extraPath(wslCodex)), res.Backup} {
es, _ := os.ReadDir(dir)
var names []string
for _, e := range es {
names = append(names, e.Name())
}
if !slices.ContainsFunc(names, func(n string) bool { return strings.HasPrefix(n, "codex@wsl") && !strings.Contains(n, ":") }) ||
slices.ContainsFunc(names, func(n string) bool { return strings.Contains(n, ":") }) {
t.Errorf("%s: %v", dir, names)
}
}
// a setup carried elsewhere keeps what it gets besides
if x := extras(); x[wslCodex] != extra {
t.Errorf("extras: %v", x)
}
iv, err := ReadInstructions()
if err != nil {
t.Fatal(err)
}
i := slices.IndexFunc(iv.Agents, func(a AgentInstructions) bool { return a.Agent == wslCodex })
if i < 0 || !iv.Agents[i].On || iv.Agents[i].Extra != extra || iv.Agents[i].Own != 1 {
t.Errorf("instructions page: %+v", iv.Agents)
}
}