refactor: extract command handlers to commands module, improve CLI type safety, and add security validations#1
Merged
Merged
Conversation
…pe safety, and add security validations
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.
This pull request introduces several improvements and refactorings to the agentfiles Rust CLI tool, focusing on enhanced type safety for CLI arguments, robust error handling for git operations, and clearer documentation for coding agents. The most significant changes include replacing string-based CLI argument parsing with strongly typed enums, adding validation for git refs to improve security, and providing comprehensive agent guidance documentation.
CLI and Argument Parsing Improvements:
FileScope,AgentProvider,FileStrategy) for arguments instead of strings, which improves type safety and prevents invalid input at compile time. (src/cli.rs[1] [2]cmd_install) and related command functions are refactored to accept these typed arguments and propagate them throughout the codebase. (src/commands.rssrc/commands.rsR1-R232)Git Operations and Security Enhancements:
validate_git_reffunction to ensure git refs cannot be used for command-line flag injection, path traversal, or contain whitespace/control characters, improving security for remote installations. (src/git.rssrc/git.rsR240-R263)git cloneno longer uses--single-branch, andgit resetnow reports errors if the operation fails. (src/git.rs[1] [2]checkout_refwhere stderr output was incorrectly referenced, ensuring the correct error message is shown. (src/git.rssrc/git.rsL262-R284)Documentation and Guidance:
AGENTS.mdfile with detailed guidance for AI coding agents, including project summary, build/test commands, module structure, code style, error handling, test conventions, and design principles. This serves as a comprehensive onboarding and reference document for contributors and AI agents. (AGENTS.mdAGENTS.mdR1-R176)CLAUDE.mdin favor of the unifiedAGENTS.md. (CLAUDE.mdCLAUDE.mdL1-L113)References:
[1] [2] [3] [4] [5] [6] [7] [8] [9]