Skip to content

Conversation

@Synesso
Copy link
Contributor

@Synesso Synesso commented Dec 22, 2025

Summary

This PR implements symlink support for the ai-rules generate command, enabling users to share rule files across repositories using symlinks.

Changes

  • CLI Flag: Added --no-follow-symlinks flag to exclude symlinked files (default: symlinks are followed)
  • Core Logic: Modified find_files_by_extension() to use fs::metadata() when following symlinks
  • Parameter Threading: Updated source_reader.rs, generate.rs, and related modules to pass follow_symlinks parameter
  • Tests: Added comprehensive tests for:
    • Symlinks enabled (includes symlinked files)
    • Symlinks disabled (excludes symlinked files)
    • Broken symlinks (handles errors gracefully)

Behavior

  • Default: Symlinks are followed
  • Opt-out: Use --no-follow-symlinks to exclude symlinked markdown files

Testing

All 336 tests pass with no clippy warnings.

Implement --no-follow-symlinks flag to allow users to control whether
symlinked markdown files in the ai-rules/ directory are included during
generation. This enables sharing rule files across repositories.

Changes:
- Add --no-follow-symlinks CLI flag (default: false, symlinks followed)
- Modify find_files_by_extension() to use fs::metadata() when following symlinks
- Thread follow_symlinks parameter through source_reader and generate modules
- Add comprehensive tests for symlink handling (enabled, disabled, broken links)

By default, symlinks are now followed, allowing users to symlink shared
markdown files (e.g., bitcoin-network-engineering-practices.md) between
repositories like btc-network and btc-moongate.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds symlink support to the ai-rules generate command, allowing users to share rule files across repositories using symbolic links. By default, symlinks are followed, with an opt-out --no-follow-symlinks flag available.

Key changes:

  • Added --no-follow-symlinks CLI flag to control symlink behavior during file discovery
  • Modified find_files_by_extension() to use fs::metadata() when following symlinks vs entry.metadata() when not following them
  • Threaded the follow_symlinks parameter through multiple modules including source_reader.rs and generate.rs

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/file_utils.rs Updated find_files_by_extension() to accept follow_symlinks parameter and added three new tests for symlink handling
src/operations/source_reader.rs Added follow_symlinks parameter to find_source_files() and related functions
src/operations/command_reader.rs Updated to pass hardcoded true for symlink following in command file discovery
src/commands/status.rs Updated test fixtures to include follow_symlinks: true
src/commands/mod.rs Updated test fixtures to include follow_symlinks: true
src/commands/init.rs Updated to pass true for following symlinks
src/commands/generate.rs Added follow_symlinks parameter threading throughout generation logic and updated test fixtures
src/commands/clean.rs Updated test fixtures to include follow_symlinks: true
src/cli/tests.rs Updated test fixtures to include no_follow_symlinks: false
src/cli/config_resolution.rs Converts no_follow_symlinks CLI flag to follow_symlinks in resolved args
src/cli/args.rs Added no_follow_symlinks CLI flag and follow_symlinks field to ResolvedGenerateArgs
Cargo.lock Version bump from 1.1.0 to 1.2.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Synesso and others added 3 commits December 31, 2025 10:55
- Add follow_symlinks parameter to find_command_files() and related functions
- Update CommandGeneratorTrait interface to accept follow_symlinks
- Update AgentRuleGenerator interface to thread follow_symlinks through
- Update all agent implementations to accept and pass the parameter
- Add #[cfg(unix)] guards to symlink-related tests in file_utils.rs
- Ensures command file discovery respects --no-follow-symlinks flag

Amp-Thread-ID: https://ampcode.com/threads/T-69bbb9e8-6527-4832-94ad-31eea70f63c3
Co-authored-by: Amp <amp@ampcode.com>
Updated all test functions to pass the follow_symlinks boolean parameter
that was added to generate_commands, check_commands, and
generate_agent_contents methods. All tests now pass true for this
parameter to maintain existing behavior (following symlinks by default).

Changes:
- claude_command_generator.rs: Updated 4 test functions
- cursor_command_generator.rs: Updated 4 test functions
- amp_command_generator.rs: Updated 4 test functions
- amp.rs: Updated 1 test function
- firebender.rs: Updated 9 test functions

All 336 tests now passing with clean build.

Amp-Thread-ID: https://ampcode.com/threads/T-1175d274-930e-41ad-bb9a-8caac30cee56
Co-authored-by: Amp <amp@ampcode.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Synesso and others added 3 commits January 1, 2026 15:48
Added documentation for the new --no-follow-symlinks flag in both the
generate and status command sections. This flag allows users to disable
symlink following when discovering source files and command files in
ai-rules/ directories.

Changes:
- Added flag description to generate command options
- Added flag description to status command options
- Added example usage to generate command examples

Amp-Thread-ID: https://ampcode.com/threads/T-1175d274-930e-41ad-bb9a-8caac30cee56
Co-authored-by: Amp <amp@ampcode.com>
- Removed no_follow_symlinks field from GenerateArgs struct
- Removed follow_symlinks field from ResolvedGenerateArgs and ResolvedStatusArgs
- Removed follow_symlinks parameter from AgentRuleGenerator trait methods
- Removed follow_symlinks parameter from CommandGeneratorTrait methods
- Updated all agent implementations to remove the parameter
- Updated all command generator implementations to always use true for symlink following
- Updated find_command_files and related operations to always follow symlinks
- Removed all test instances of the parameter (50+ occurrences)
- Removed --no-follow-symlinks documentation from README.md

The code now always follows symlinks where the OS supports it, which is the desired default behavior.

Amp-Thread-ID: https://ampcode.com/threads/T-1029f206-4d30-4b0f-97c3-4a4d1f0a462a
Co-authored-by: Amp <amp@ampcode.com>
- Removed follow_symlinks parameter from find_files_by_extension
- Removed follow_symlinks parameter from find_source_files
- Removed follow_symlinks parameter from get_md_files_in_ai_rules_dir
- Updated all call sites to use simplified signatures
- Removed test_find_files_by_extension_with_symlinks_disabled test
- These functions now always follow symlinks by default

This completes the removal of symlink-following configuration throughout the codebase.
@jonandersen jonandersen merged commit ae0e4aa into block:main Jan 6, 2026
6 checks passed
@Synesso Synesso deleted the jmawson/symlink-support branch January 7, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants