Skip to content

feat: add .agentignore - #300

Closed
ysrastogi wants to merge 20 commits into
openai:mainfrom
ysrastogi:feat-agentignore
Closed

ysrastogi wants to merge 20 commits into
openai:mainfrom
ysrastogi:feat-agentignore

Conversation

@ysrastogi

@ysrastogi ysrastogi commented Apr 18, 2025 •

Copy link
Copy Markdown

.agentignore Support

Overview

This PR implements support for .agentignore files, providing users with a familiar and flexible way to exclude specific files and directories from agent processing. The implementation follows the .gitignore pattern syntax that developers are already familiar with.

This PR Resolves #85

Features

  • User-defined file exclusion using .agentignore files
  • Support for all gitignore-style pattern types:
    • Basic glob patterns: *.env, *.log
    • Directory patterns: logs/
    • Non-recursive patterns: /top-level-only.txt
    • Nested wildcards: src/**/node_modules/
    • Negated patterns: !important.env
  • Seamless integration with existing default ignore patterns
  • Comprehensive pattern matching with proper handling of negations

Implementation Details

  • Added loadAgentIgnorePatterns() to read user-defined patterns
  • Created getMergedIgnorePatterns() to combine default and user patterns
  • Implemented isExplicitlyIgnored() for explicit pattern checking
  • Enhanced getSafeFileContents() for safe file access respecting all patterns

@github-actions

github-actions Bot commented Apr 18, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ysrastogi

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@ysrastogi

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Apr 18, 2025
@tibo-openai tibo-openai changed the title Feat agentignore feat: add .agentignore Apr 23, 2025
@ysrastogi

Copy link
Copy Markdown
Author

@tibo-openai any update on this PR?

@Kevinlearynet

Copy link
Copy Markdown

This is critical, any update?

The codebase does mention it here:

/** Loads ignore patterns from a file (or a default list) and returns a list of RegExp patterns. */

But has no ability to load ignore files

@Kevinlearynet

Copy link
Copy Markdown

Related to #206

@ysrastogi

Copy link
Copy Markdown
Author

Hii @fouad-openai any update on this PR?

@codex-maintainers

Copy link
Copy Markdown

Thanks for the contribution! We're primarily focused on the native/Rust implementation of Codex CLI and would love to see if this is still an issue on the latest version. If it is, we're happy to take a look at a PR to the codex-rs/ implementation.

@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to hide sensitive files from agent

4 participants