Skip to content

feat: enhance environment file management with gitignore-based discovery#2

Merged
aryasaatvik merged 3 commits intomainfrom
feat/env-config
Jun 11, 2025
Merged

feat: enhance environment file management with gitignore-based discovery#2
aryasaatvik merged 3 commits intomainfrom
feat/env-config

Conversation

@aryasaatvik
Copy link
Member

@aryasaatvik aryasaatvik commented Jun 10, 2025

Summary

This PR significantly enhances agentree's environment file management by implementing intelligent discovery based on .gitignore patterns. This addresses the need for better environment configuration support, especially for monorepos and AI tool configurations.

Key Improvements

  • 🔍 Gitignore-based Discovery: Uses .gitignore patterns as the source of truth for finding environment files
  • 📁 Monorepo Support: Recursively discovers nested environment files (e.g., packages/*/.env)
  • 🤖 AI Tool Configurations: Automatically copies .claude/settings.local.json, .cursorrules, and other AI configs
  • ⚙️ Flexible Configuration: New options in .agentreerc and global config for customizing behavior
  • 🎯 Include/Exclude Patterns: Add custom patterns or exclude unwanted files
  • ✅ Comprehensive Tests: Full test coverage for all new features
  • 📚 Documentation: Detailed guide for environment configuration

How It Works

  1. Parses all .gitignore files in the repository
  2. Identifies patterns that likely represent environment/configuration files
  3. Finds actual files matching those patterns
  4. Adds default AI tool configuration patterns
  5. Applies custom include/exclude patterns from configuration
  6. Copies all discovered files to the new worktree, preserving directory structure

Configuration Example

# .agentreerc
ENV_COPY_ENABLED=true
ENV_RECURSIVE=true
ENV_USE_GITIGNORE=true

ENV_INCLUDE_PATTERNS=(
  "*.env.example"
  "config/*.sample"
  ".vscode/settings.local.json"
)

ENV_EXCLUDE_PATTERNS=(
  "*.test.env"
  "node_modules/**/.env"
)

Testing

All tests pass with comprehensive coverage:

  • ✅ Gitignore parsing and pattern matching
  • ✅ Environment file discovery
  • ✅ Monorepo recursive search
  • ✅ Configuration loading and merging
  • ✅ File copying with directory preservation

Breaking Changes

None - the implementation maintains backward compatibility. If gitignore parsing fails or no files are discovered, it falls back to the legacy behavior of copying only .env and .dev.vars.

🤖 Generated with Claude Code

aryasaatvik and others added 3 commits June 10, 2025 19:37
- Add intelligent environment file discovery based on .gitignore patterns
- Support nested environment files in monorepos with recursive search
- Include AI tool configurations (.claude/settings.local.json, .cursorrules, etc.)
- Add flexible configuration options in .agentreerc and global config
- Implement include/exclude patterns for fine-grained control
- Maintain backward compatibility with legacy .env/.dev.vars copying
- Add comprehensive test coverage for all new features
- Create detailed documentation for environment configuration

This enhancement makes agentree more intelligent about discovering and copying
environment files, using .gitignore as the source of truth while supporting
monorepo structures and AI tool configurations.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
…ging

- Introduce a verbose flag to the create command for detailed logging during environment file discovery.
- Update the EnvFileCopier to log discovered files and patterns from .gitignore.
- Enhance user feedback with messages indicating the status of file discovery and copying processes.
- Remove outdated test files and related code to streamline the codebase.

This update improves the user experience by providing more visibility into the environment file management process.
- Update README to reflect intelligent environment file discovery based on .gitignore patterns.
- Simplify and clarify the environment configuration guide, emphasizing support for monorepos and AI tool configurations.
- Improve examples and best practices for using environment files and configurations.

This update improves clarity and usability for users setting up their environment with agentree.
@aryasaatvik aryasaatvik reopened this Jun 11, 2025
@aryasaatvik aryasaatvik merged commit 6ed46c7 into main Jun 11, 2025
14 checks passed
@aryasaatvik aryasaatvik deleted the feat/env-config branch June 11, 2025 05:59
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