Skip to content

fix(core): ignore directories named AGENTS.md during instruction discovery - #52576

Merged
neriousy merged 4 commits into
v2from
agents-md-dir
Oct 1, 2026
Merged

neriousy merged 4 commits into
v2from
agents-md-dir

Conversation

@neriousy

@neriousy neriousy commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #52301

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

fs.up matches any existing path, so both AGENTS.md walks also picked up directories with that name (on macOS, any folder called agents.md, e.g. a clone of a repo with that name):

  • Startup instructions (config/plugin/instruction.ts): reading the directory fails with EISDIR, the project source becomes Instructions.unavailable, and every prompt fails with "Instruction initialization blocked by unavailable sources: core/instructions".
  • Nested instructions after a read (tool/plugin/read.ts): the directory makes sessionInstructions.load fail, and since that failure is swallowed, every nested AGENTS.md from that walk is silently dropped, including valid ones.

fs.up gets an opt-in type: "file" | "directory" option. Both AGENTS.md walks pass type: "file", and the global AGENTS.md is skipped unless it is a regular file. Callers that legitimately match either kind (.git, which is a file in worktrees, .hg, project markers, config discovery) keep the default behaviour.

A real AGENTS.md that exists but can't be read still marks instructions unavailable, as before.

How did you verify your code works?

  • Ran the dev TUI (--standalone) in a project inside $HOME with an AGENTS.md directory in its parent, a real AGENTS.md above that, an AGENTS.md directory in sub/, and a real one in sub/deeper/:
    • On v2: every prompt fails with the error above. With only read.ts on v2, reading sub/deeper/notes.txt loads no nested instructions.
    • With this PR: both startup files load, and the read loads sub/deeper/AGENTS.md.
  • Checked fs.up with no type, "file" and "directory" against a real directory tree.
  • bun typecheck in packages/util and packages/core; instruction, config, filesystem, git, project and read-tool tests in packages/core pass.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@neriousy
neriousy merged commit 0f9f0a9 into v2 Oct 1, 2026
10 checks passed
@neriousy
neriousy deleted the agents-md-dir branch October 1, 2026 21:12
Ichinose-Kazuki pushed a commit to Ichinose-Kazuki/opencode that referenced this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant