-
Notifications
You must be signed in to change notification settings - Fork 6
Add symlink support for ai-rules generate command #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
There was a problem hiding this 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-symlinksCLI flag to control symlink behavior during file discovery - Modified
find_files_by_extension()to usefs::metadata()when following symlinks vsentry.metadata()when not following them - Threaded the
follow_symlinksparameter through multiple modules includingsource_reader.rsandgenerate.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.
- 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>
Amp-Thread-ID: https://ampcode.com/threads/T-1175d274-930e-41ad-bb9a-8caac30cee56 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this 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.
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.
Summary
This PR implements symlink support for the
ai-rules generatecommand, enabling users to share rule files across repositories using symlinks.Changes
--no-follow-symlinksflag to exclude symlinked files (default: symlinks are followed)find_files_by_extension()to usefs::metadata()when following symlinkssource_reader.rs,generate.rs, and related modules to passfollow_symlinksparameterBehavior
--no-follow-symlinksto exclude symlinked markdown filesTesting
All 336 tests pass with no clippy warnings.