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