Skip to content

Add .celestoignore support for excluding files during deployment#4

Merged
aniketmaurya merged 3 commits intoCelestoAI:mainfrom
craigpfeifer:feature/celestoignore-support
Feb 4, 2026
Merged

Add .celestoignore support for excluding files during deployment#4
aniketmaurya merged 3 commits intoCelestoAI:mainfrom
craigpfeifer:feature/celestoignore-support

Conversation

@craigpfeifer
Copy link
Contributor

Summary

This PR adds .celestoignore functionality to the Celesto SDK, allowing users to exclude files and directories from agent deployments using gitignore-style pattern matching.

Features

  • .celestoignore file support: Users can create a .celestoignore file in their agent folder to specify files/directories to exclude
  • Gitignore-compatible syntax: Uses the same pattern matching as .gitignore (powered by the pathspec library)
  • Inline comment support: Patterns can include explanatory comments: *.pyc # Python compiled files
  • Full-line comments: Lines starting with # are treated as comments
  • Graceful error handling: Warns on stderr if .celestoignore can't be read/parsed, but continues deployment
  • Efficient directory filtering: Directories are filtered before recursion to avoid unnecessary file system traversal
  • Cross-platform compatibility: Handles path separators correctly on all platforms

Changes

Core Implementation

  • Added pathspec>=0.11.0 dependency to pyproject.toml
  • Implemented _load_ignore_patterns() method in Deployment class
  • Updated deploy() method to use recursive directory walking with pattern filtering
  • Added proper error handling with user-friendly stderr messages

Documentation

  • Updated README.md with .celestoignore usage examples
  • Added comprehensive CLAUDE.md file for AI assistant guidance
  • Included .celestoignore.example with common patterns for Python projects

Testing

  • Created comprehensive test suite in tests/test_celestoignore.py with 6 tests:
    • Comment lines (starting with #) are properly ignored
    • Empty lines are handled correctly
    • Files starting with # are included (not excluded by comment syntax)
    • Mixed comments and patterns work as expected
    • .celestoignore file itself is not excluded
    • Inline comments are supported

All tests pass (9/9).

Example Usage

Create a .celestoignore file in your agent folder:

# Python artifacts
__pycache__/        # Bytecode cache
*.pyc               # Compiled Python files

# Virtual environments
venv/
.venv/

# Environment files
.env                # Secrets and config
.env.local

# Development files
.vscode/            # IDE settings
tests/              # Test files

These files will be automatically excluded when deploying with celesto deploy.

Test Plan

  • All existing tests pass
  • 6 new tests for .celestoignore functionality pass
  • Verified inline comment stripping works correctly
  • Verified full-line comments are ignored
  • Verified error handling with invalid patterns
  • Verified deployment continues with warnings on parse errors

🤖 Generated with Claude Code

Implement .celestoignore functionality to allow users to exclude files and
directories from agent deployments, similar to how .gitignore works with Git.

Changes:
- Add pathspec>=0.11.0 dependency for gitignore-style pattern matching
- Implement _load_ignore_patterns() method in Deployment class to parse .celestoignore files
- Update deploy() to recursively walk directories and filter files/directories matching ignore patterns
- Support both full-line comments (lines starting with #) and inline comments (text after # on pattern lines)
- Add graceful error handling with stderr warnings if .celestoignore fails to load
- Add comprehensive test suite with 6 tests covering comment handling, empty lines, and inline comments
- Update README.md with .celestoignore usage examples
- Add CLAUDE.md documentation file for AI assistant guidance
- Include .celestoignore.example with common patterns for Python projects

Key features:
- Format identical to .gitignore (supports all gitignore patterns)
- Inline comments supported: "*.pyc # Python compiled files"
- Directories filtered before recursion for efficiency
- Cross-platform path handling with forward slashes
- Continues deployment with warning if .celestoignore has errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.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

This PR adds .celestoignore functionality to the Celesto SDK, allowing users to exclude files and directories from agent deployments using pattern matching. The implementation uses the pathspec library to provide gitignore-style pattern support.

Changes:

  • Added pathspec>=0.11.0 dependency for gitignore-style pattern matching
  • Implemented _load_ignore_patterns() method in the Deployment class to parse .celestoignore files
  • Modified the deploy() method to recursively walk directories and filter files/directories based on ignore patterns
  • Added comprehensive documentation in README.md, CLAUDE.md, and a .celestoignore.example file
  • Created test suite with 6 tests covering comment handling, empty lines, and pattern matching

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/celesto/sdk/client.py Implements .celestoignore loading and filtering logic in deployment workflow
pyproject.toml Adds pathspec>=0.11.0 dependency for gitignore pattern matching
tests/test_celestoignore.py Comprehensive test suite for .celestoignore functionality (6 tests)
README.md User-facing documentation with .celestoignore usage examples
CLAUDE.md AI assistant guide with detailed implementation notes and examples
.celestoignore.example Example file with common ignore patterns for Python projects

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

craigpfeifer and others added 2 commits February 2, 2026 12:26
The previous implementation incorrectly stripped ANY # character from
patterns, even when it should be treated as literal. Updated to follow
gitignore spec where only ' #' (space followed by #) starts a comment.

Changes:
- Fix _load_ignore_patterns() to only strip inline comments when # is preceded by space
- # without preceding space is now treated as literal character (e.g., file#name.txt)
- Add comprehensive test suite (11 tests) in test_celestoignore_spec.py to verify spec compliance
- Update CLAUDE.md documentation to accurately describe inline comment behavior

Test cases now cover:
- Patterns with # in the middle (literal)
- Patterns ending with # (literal)
- Wildcard patterns containing # (literal)
- Inline comments with space before # (comment)
- Patterns with both literal # and inline comments
- Full-line comment variations
- Trailing space handling
- Negation patterns with comments

All 20 tests pass (6 original + 11 spec compliance + 3 other tests).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes based on PR feedback:
- Move os import to module level in test_celestoignore.py for consistency
- Fix MockConnection in both test files to properly call base class __init__
- Add test for empty archive scenario when all files are ignored

All 21 tests pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@craigpfeifer
Copy link
Contributor Author

@aniketmaurya ready for another copilot pass

@aniketmaurya aniketmaurya merged commit e129b3d into CelestoAI:main Feb 4, 2026
1 check passed
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