Skip to content

refactor: extract command handlers to commands module, improve CLI type safety, and add security validations#1

Merged
leodiegues merged 1 commit into
mainfrom
fix/loose-ends
Feb 14, 2026
Merged

refactor: extract command handlers to commands module, improve CLI type safety, and add security validations#1
leodiegues merged 1 commit into
mainfrom
fix/loose-ends

Conversation

@leodiegues
Copy link
Copy Markdown
Owner

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:

  • The CLI now uses strongly typed enums (FileScope, AgentProvider, FileStrategy) for arguments instead of strings, which improves type safety and prevents invalid input at compile time. (src/cli.rs [1] [2]
  • The install command handler (cmd_install) and related command functions are refactored to accept these typed arguments and propagate them throughout the codebase. (src/commands.rs src/commands.rsR1-R232)

Git Operations and Security Enhancements:

  • Added a validate_git_ref function 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.rs src/git.rsR240-R263)
  • Improved error handling for git operations: git clone no longer uses --single-branch, and git reset now reports errors if the operation fails. (src/git.rs [1] [2]
  • Fixed a bug in checkout_ref where stderr output was incorrectly referenced, ensuring the correct error message is shown. (src/git.rs src/git.rsL262-R284)

Documentation and Guidance:

  • Added a new AGENTS.md file 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.md AGENTS.mdR1-R176)
  • Removed the outdated and provider-specific CLAUDE.md in favor of the unified AGENTS.md. (CLAUDE.md CLAUDE.mdL1-L113)

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9]

@leodiegues leodiegues self-assigned this Feb 14, 2026
@leodiegues leodiegues merged commit fef38b5 into main Feb 14, 2026
3 checks passed
@leodiegues leodiegues deleted the fix/loose-ends branch February 14, 2026 22:28
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.

1 participant