feat: add nested-glob target type for monorepo/multi-module AGENTS.md discovery - #234
Merged
Merged
Conversation
Adds a new `nested-glob` sync type that recursively discovers files
matching a glob pattern under a search root directory, then creates
a symlink for each discovered file at a path produced by expanding
a destination template.
Key changes:
- New `SyncType::NestedGlob` variant (TOML: `type = "nested-glob"`)
- New `exclude: Vec<String>` field on `TargetConfig` for exclusion patterns
- `process_nested_glob()` in linker.rs using walkdir for traversal
- `expand_destination_template()` with {relative_path}, {file_name},
{stem}, {ext} placeholders; {relative_path} is "." for root-level files
- `matches_path_glob()` / `path_glob_match()` supporting ** multi-segment
glob matching
- `clean()` extended to re-discover and remove nested-glob symlinks
- `all_gitignore_entries()` skips NestedGlob destinations (they're templates)
- Comprehensive unit tests (13 new tests)
- README documentation
Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dallay/agentsync/sessions/971330c2-c7c7-4439-9f72-cd0588402b5e
Copilot
AI
changed the title
[WIP] Add support for nested AGENTS.md files
feat: add Mar 21, 2026
nested-glob target type for monorepo/multi-module AGENTS.md discovery
yacosta738
marked this pull request as ready for review
March 21, 2026 23:25
…tion - Use find() instead of any() for exclusion patterns to enable early-exit and show which pattern matched in verbose output - Add comprehensive doc comments to process_nested_glob() - Minor formatting improvements
- Set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true in ci.yml and contributor-report.yml - Update contributor-report.yml to use v1.1.0 of dallay/common-actions Node.js 20 actions are deprecated and will be forced to Node.js 24 by default starting June 2nd, 2026.
Upgrades reqwest from 0.13.1 to 0.13.2 which pulls in updated transitive dependencies that fix the following RUSTSEC advisories: - RUSTSEC-2026-0045: Timing Side-Channel in AES-CCM Tag Verification - RUSTSEC-2026-0044: AWS-LC X.509 Name Constraints Bypass - RUSTSEC-2026-0048: CRL Distribution Point Scope Check Logic Error - RUSTSEC-2026-0047: PKCS7_verify Signature Validation Bypass - RUSTSEC-2026-0046: PKCS7_verify Certificate Chain Validation Bypass - RUSTSEC-2026-0049: CRLs not considered authoritative by Distribution Point
…nested-agents-md-files
yacosta738
approved these changes
Mar 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentSync only supported a single flat
AGENTS.mdsource per agent config, making it unusable for monorepos and multi-module projects where subdirectories carry domain-specific agent instructions.New
nested-globtarget typeRecursively discovers files matching a glob pattern under a search root and creates a symlink for each match using a destination template.
Given
clients/agent-runtime/AGENTS.mdandmodules/core-kmp/AGENTS.md, this produces:clients/agent-runtime/CLAUDE.md→ symlinkmodules/core-kmp/CLAUDE.md→ symlinkDestination template placeholders
{relative_path}clients/agent-runtimesource;.at search root{file_name}AGENTS.md{stem}AGENTS{ext}mdImplementation details
config.rs: newSyncType::NestedGlobvariant; newexclude: Vec<String>field onTargetConfig;all_gitignore_entries()skipsNestedGlobdestinations (they are templates, not literal paths)linker.rs:process_nested_glob()walks withwalkdir(follow_links = false);matches_path_glob()/path_glob_match()implement**multi-segment glob matching on top of the existing single-segmentmatches_pattern();expand_destination_template()handles placeholder substitution;clean()extended to re-discover and remove nested-glob symlinksOriginal prompt
This section details on the original issue you should resolve
<issue_title>Support for Nested AGENTS.md Files</issue_title>
<issue_description># Feature Request: Support for Nested AGENTS.md Files
Problem Statement
Currently, AgentSync only supports a single
AGENTS.mdsource file in.agents/.There is no mechanism to discover or sync AGENTS.md files that exist in
subdirectories of a project.
This limits AgentSync's usefulness in monorepos and multi-module projects
where different directories may need domain-specific agent instructions.
Use Cases
1. Monorepo with Domain-Specific Instructions
Each submodule has specialized instructions (Rust patterns, Vue conventions,
Kotlin patterns) that differ from the root. Currently, these nested
AGENTS.mdfiles must be maintained manually or through external scripts.2. Gradle Multi-Module Projects
3. Selective Inheritance
Many AI coding tools (Claude Code, OpenCode, etc.) already support reading
AGENTS.md from subdirectories with inheritance/cascading behavior —
the closest AGENTS.md to the current working directory takes precedence.
AgentSync should complement this by:
Proposed Solutions
Option A: Glob-Based Discovery (Recommended)
Add support for glob patterns in
agentsync.toml:This would:
AGENTS.mdfiles matching the patternclients/agent-runtime/AGENTS.md→clients/agent-runtime/AGENTS.md(symlink)Option B: Explicit Nested Targets
Keep the current flat structure but allow explicit per-directory targets:
Downside: Requires manual configuration for each nested file.
Option C: Contextual Inheritance (Most Complex)
Implement a discovery mechanism that:
**/AGENTS.mdfilesDownside: Significant complexity; may conflict with agent-specific inheritance behavior.
Technical Considerations
1. Circular Reference Prevention
Ensure glob patterns don't accidentally include the root
.agents/AGENTS.mdcreating loops.2. Exclusion Patterns
Some directories should be excluded:
node_modules/target/(Rust)build/(Gradle).git/dist/,coverage/3. Incremental Sync
On subsequent runs, only sync changed/new/deleted files, not the entire glob result every time.
4. Conflict Resolution
If a nested AGENTS.md has the same content as the root, should it still create a symlink?
(Probably yes, for explicit submodule ownership.)
5. Performance
For large monorepos, glob patterns could match hundreds of files. Consider:
Example Configuration (Option A)