[PR #952] [CLOSED] Added recursive AGENTS.md loading from child dirs #9754

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

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/952
Author: @opencode-agent[bot]
Created: 7/13/2025
Status: Closed

Base: devHead: opencode/issue847-20250713_205033


📝 Commits (1)

  • f261046 Added recursive AGENTS.md loading from child dirs

📊 Changes

2 files changed (+28 additions, -2 deletions)

View changed files

📝 packages/opencode/src/session/system.ts (+7 -2)
📝 packages/opencode/src/util/filesystem.ts (+21 -0)

📄 Description

Summary

I've successfully implemented recursive loading of AGENTS.md files from child folders. Here's what I did:

Changes Made:

  1. Added findDown function in /home/runner/work/opencode/opencode/packages/opencode/src/util/filesystem.ts:69-84:

    • Searches for files recursively in child directories using Bun's glob functionality
    • Includes a configurable maxDepth parameter (default: 3) to prevent performance issues
    • Uses the pattern **/${target} to find files at any depth
  2. Updated custom() function in /home/runner/work/opencode/opencode/packages/opencode/src/session/system.ts:53-84:

    • Now searches both upward (existing functionality) and downward (new functionality) for AGENTS.md files
    • Maintains backward compatibility with existing behavior
    • Limits search depth to 3 levels to avoid performance issues in large codebases

Key Features:

  • Backward Compatible: Existing upward search functionality remains unchanged
  • Performance Optimized: Limited to 3 levels of depth by default to prevent scanning entire large codebases
  • Comprehensive Coverage: Now finds AGENTS.md files in:
    • Current directory and parent directories (existing)
    • Child directories up to 3 levels deep (new)
    • Global config directory (existing)
    • Home directory .claude folder (existing)

Testing:

The implementation was tested and verified to correctly find AGENTS.md files at different directory levels, respecting the depth limit parameter.

This should resolve the issue where AGENTS.md files in child folders were being ignored, allowing for more granular project-specific instructions at different directory levels.

Closes #847

view session | view log


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/952 **Author:** [@opencode-agent[bot]](https://github.com/apps/opencode-agent) **Created:** 7/13/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `opencode/issue847-20250713_205033` --- ### 📝 Commits (1) - [`f261046`](https://github.com/anomalyco/opencode/commit/f26104636121d211100a137ec3fc331d00dc13e4) Added recursive AGENTS.md loading from child dirs ### 📊 Changes **2 files changed** (+28 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/session/system.ts` (+7 -2) 📝 `packages/opencode/src/util/filesystem.ts` (+21 -0) </details> ### 📄 Description ## Summary I've successfully implemented recursive loading of AGENTS.md files from child folders. Here's what I did: ### Changes Made: 1. **Added `findDown` function** in `/home/runner/work/opencode/opencode/packages/opencode/src/util/filesystem.ts:69-84`: - Searches for files recursively in child directories using Bun's glob functionality - Includes a configurable `maxDepth` parameter (default: 3) to prevent performance issues - Uses the pattern `**/${target}` to find files at any depth 2. **Updated `custom()` function** in `/home/runner/work/opencode/opencode/packages/opencode/src/session/system.ts:53-84`: - Now searches both upward (existing functionality) and downward (new functionality) for AGENTS.md files - Maintains backward compatibility with existing behavior - Limits search depth to 3 levels to avoid performance issues in large codebases ### Key Features: - **Backward Compatible**: Existing upward search functionality remains unchanged - **Performance Optimized**: Limited to 3 levels of depth by default to prevent scanning entire large codebases - **Comprehensive Coverage**: Now finds AGENTS.md files in: - Current directory and parent directories (existing) - Child directories up to 3 levels deep (new) - Global config directory (existing) - Home directory `.claude` folder (existing) ### Testing: The implementation was tested and verified to correctly find AGENTS.md files at different directory levels, respecting the depth limit parameter. This should resolve the issue where AGENTS.md files in child folders were being ignored, allowing for more granular project-specific instructions at different directory levels. Closes #847 [view session](https://opencode.ai/s/gI1j1e77) | [view log](/sst/opencode/actions/runs/16253302844) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:07 -05:00
yindo closed this issue 2026-02-16 18:14:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9754