[PR #9657] feat: Subdirectory rule loading when accessing files #13174

Closed
opened 2026-02-16 18:18:02 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9657

State: closed
Merged: No


What does this PR do?

First pass draft implementation at loading of rules from subdirectories.

Closes #6316

Working

  • Loading of subdirectory rules in response to tool calls that introduce files which should result in a rule load
  • Path filtering via YAML frontmatter, meaning that rule application can be restricted further to only apply when files matching the globs are in context.
  • Configuration under subdirectoryRules option
    • Disabled by default
    • Glob patterns can be set via patterns, default is **/AGENTS.md
    • Searches up by default, can be configured to just load rule files that are in the same directory as the loaded file by setting the exact option to true
  • When tool calls that introduced rules into the session are pruned, the rules are also pruned. Tool calls that would match a rule are all tracked, so any live tool calls that reference a rule will keep the rule loaded into the session
  • TUI shows rule loads in the message interface, all currently loaded rules are listed in the sidebar

Not working

  • Web UI + Desktop UI (Rule loading triggers, just having trouble getting the UI aspect working)

How did you verify your code works?

  • Running the TUI, adding additional AGENTS.md files, sending chat messages that should trigger loading of rules
  • Simple unit tests
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9657 **State:** closed **Merged:** No --- ### What does this PR do? First pass draft implementation at loading of rules from subdirectories. Closes #6316 #### Working * Loading of subdirectory rules in response to tool calls that introduce files which should result in a rule load * Path filtering via YAML frontmatter, meaning that rule application can be restricted further to only apply when files matching the globs are in context. * Configuration under `subdirectoryRules` option * Disabled by default * Glob patterns can be set via `patterns`, default is `**/AGENTS.md` * Searches up by default, can be configured to just load rule files that are in the same directory as the loaded file by setting the `exact` option to `true` * When tool calls that introduced rules into the session are pruned, the rules are also pruned. Tool calls that would match a rule are all tracked, so any live tool calls that reference a rule will keep the rule loaded into the session * TUI shows rule loads in the message interface, all currently loaded rules are listed in the sidebar #### Not working * Web UI + Desktop UI (Rule loading triggers, just having trouble getting the UI aspect working) ### How did you verify your code works? * Running the TUI, adding additional AGENTS.md files, sending chat messages that should trigger loading of rules * Simple unit tests
yindo added the pull-request label 2026-02-16 18:18:02 -05:00
yindo closed this issue 2026-02-16 18:18:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13174