From e656888867afefcf70154ff6a95ff360a097176e Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 21 Oct 2026 16:50:09 +0800 Subject: [PATCH] =?UTF-8?q?library:=20Library=20=E2=86=92=20Instructions?= =?UTF-8?q?=20gives=20Devin=20its=20global=20AGENTS.md=20(#3151,=20eqe365?= =?UTF-8?q?=20on=20Discord)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eqe365 on Discord (#3151): Devin CLI reads AGENTS.md, but Library → Instructions listed Devin as keeping no user-wide instructions file. Devin's target had Skills and MCP and no Instructions. Source: the docs Devin CLI 3000.11.92 ships with it, share/devin/docs/extensibility/rules.mdx ("Rules & AGENTS.md" → Global Rules). It reads global rules from ~/.config/devin/AGENTS.md (%APPDATA%\devin\AGENTS.md on Windows) at the start of every session, and the singular AGENT.md there too. Devin's folder (a.Dir) is already that folder, so Instructions is AGENTS.md there, or AGENT.md when only that one exists (firstThere). The GUI is data-driven and needs no change. Test: TestDevinInstructions (internal/library/agent_skills_test.go) checks: - the target is AGENTS.md before the file exists; - Save writes the shared block after the user's own text; - with only AGENT.md present, that file is the target. With targets.go reverted it fails: "Devin's instructions: "", want .../.config/devin/AGENTS.md before the file is there". Run with this change on origin/main ba319a758 (before the rebase), set -o pipefail, GOMODCACHE pinned: - gofmt -l: clean. - go vet ./..., GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: all clean. darwin, linux nogui and windows builds: ok. - go test -timeout 45m ./...: 66 packages ok. Two timed out at 45m while the machine's load average was 24 to 60 (other sessions' suites): - internal/library (2724s; TestCheckSkills had been running 6s at the deadline). Alone at -timeout 90m it is ok in 2204s. This is #2853. - internal/agent (2714s). It doesn't import internal/library, so it runs the same code as origin/main. This is #2544. - Packages that import library are ok: backup, cli, davsync, gui, profile, tui. - No GUI files touched. Not tried: a real Devin session reading the file; the claim rests on Devin's own shipped docs. --- internal/library/agent_skills_test.go | 33 +++++++++++++++++++++++++++ internal/library/targets.go | 5 ++++ 2 files changed, 38 insertions(+) diff --git a/internal/library/agent_skills_test.go b/internal/library/agent_skills_test.go index 313202cbc..387970090 100644 --- a/internal/library/agent_skills_test.go +++ b/internal/library/agent_skills_test.go @@ -190,6 +190,39 @@ func TestDroidGrokInstructions(t *testing.T) { } } +// Devin CLI reads its global rules from AGENTS.md in its config folder +// (~/.config/devin, %APPDATA%\devin on Windows), else the singular AGENT.md +// there (#3151): the library's instructions reach it, after what the user +// wrote, which stays, and Devin is offered them rather than listed as having +// no user-wide file. +func TestDevinInstructions(t *testing.T) { + h := sandbox(t) + write(t, filepath.Join(h, ".config/devin/config.json"), "{}") + tg := targetByID("devin") + if tg == nil { + t.Fatal("Devin isn't a target") + } + f := filepath.Join(tg.Agent.Dir, "AGENTS.md") + if tg.Instructions != f { + t.Fatalf("Devin's instructions: %q, want %q before the file is there", tg.Instructions, f) + } + write(t, f, "# Mine\n") + shared := "Use tabs." + ok(t)(SaveInstructions(InstructionsChange{Shared: &shared, Agents: []string{"devin"}})) + if s := read(t, f); s != "# Mine\n\n"+blockBegin+"\nUse tabs.\n"+blockEnd+"\n" { + t.Fatalf("Devin's AGENTS.md:\n%s", s) + } + + // a user who keeps theirs as AGENT.md has it written there instead + h = sandbox(t) + write(t, filepath.Join(h, ".config/devin/config.json"), "{}") + dir := targetByID("devin").Agent.Dir + write(t, filepath.Join(dir, "AGENT.md"), "# Mine\n") + if tg := targetByID("devin"); tg.Instructions != filepath.Join(dir, "AGENT.md") { + t.Fatalf("Devin with AGENT.md: %q", tg.Instructions) + } +} + // Qwen Code reads QWEN.md in its folder ($QWEN_HOME, else ~/.qwen) before // every conversation (wongxy on Discord): the library's instructions reach // it there, after what the user wrote, which stays; its settings' diff --git a/internal/library/targets.go b/internal/library/targets.go index 5a13fc7e4..ecfe544fa 100644 --- a/internal/library/targets.go +++ b/internal/library/targets.go @@ -304,6 +304,11 @@ func targetOf(a *agent.Agent) *Target { // beside its config.json (devin mcp add --scope user) t.MCP = &mcpFile{Path: filepath.Join(a.Dir, "mcp_config.json"), Format: fmtDevin} t.Skills = filepath.Join(a.Dir, "skills") + // and its global rules from AGENTS.md there, else the singular + // AGENT.md it also reads, at the start of every session (Rules & + // AGENTS.md → Global Rules in the docs Devin CLI 3000.11.92 ships, + // share/devin/docs/extensibility/rules.mdx, #3151) + t.Instructions = firstThere(a.Dir, "AGENTS.md", "AGENT.md") case "grok": // Grok Build reads [mcp_servers.] from its config.toml, as // `grok mcp add` writes them; its user-wide instructions are