Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::IgnoreMatcher Class Reference

gitignore-style path matcher (#15, v2.1.4). More...

#include <entropic/mcp/servers/ignore_matcher.h>

Classes

struct  Rule
 One compiled gitignore rule (public so internal helpers in the .cpp can construct Rules without friend declarations). More...
 

Public Member Functions

 IgnoreMatcher ()=default
 Construct an empty matcher (no rules).
 
void load (const std::filesystem::path &root)
 Load gitignore + explorerignore from a workspace root.
 
void add_pattern (const std::string &pattern, const std::filesystem::path &base={})
 Add a single pattern programmatically (test surface).
 
bool is_ignored (const std::string &rel_path, bool is_dir) const
 Test whether a path is ignored.
 
std::size_t rule_count () const
 Number of compiled rules (test surface).
 

Detailed Description

gitignore-style path matcher (#15, v2.1.4).

Single instance owns a compiled rule set. is_ignored is O(rules) per call; rules are evaluated in source order, last-match-wins so that negation patterns (!keep.log) can re-include paths that earlier patterns excluded.

Version
2.1.4

Definition at line 56 of file ignore_matcher.h.

Constructor & Destructor Documentation

◆ IgnoreMatcher()

entropic::IgnoreMatcher::IgnoreMatcher ( )
default

Construct an empty matcher (no rules).

Version
2.1.4

Member Function Documentation

◆ add_pattern()

void entropic::IgnoreMatcher::add_pattern ( const std::string &  pattern,
const std::filesystem::path &  base = {} 
)

Add a single pattern programmatically (test surface).

Add a pattern programmatically.

Parameters
patternGitignore-syntax pattern.
baseAnchor directory (relative to root). Empty means "anchored at root."
Version
2.1.4

Comments and blank lines are skipped here as well as on the file path, so a caller cannot inject a rule that matches everything.

Parameters
patternGitignore-syntax line.
baseDirectory the rule is anchored at, relative to the root. @req REQ-MCP-022
Version
2.1.4

Definition at line 358 of file ignore_matcher.cpp.

◆ is_ignored()

bool entropic::IgnoreMatcher::is_ignored ( const std::string &  rel_path,
bool  is_dir 
) const

Test whether a path is ignored.

Test a path against the rule set (last-match-wins for negation).

Parameters
rel_pathForward-slash, relative-to-root path. Must NOT start with /. Trailing slash optional.
is_dirTrue if the path refers to a directory.
Returns
true if the path matches an active (non-negated) exclusion rule.
Version
2.1.4

Matching is path-relative, never filename-only, and every rule is evaluated so a later negation can re-include what an earlier rule excluded — negation is order-sensitive by construction.

Parameters
rel_pathPath relative to the workspace root, forward-slashed.
is_dirWhether the path names a directory — a dir/ pattern matches the directory and its descendants but not a same-named regular file.
Returns
true when the LAST matching rule excludes the path; false when it re-includes it or nothing matched. @req REQ-MCP-022
Version
2.1.4

Definition at line 471 of file ignore_matcher.cpp.

◆ load()

void entropic::IgnoreMatcher::load ( const std::filesystem::path &  root)

Load gitignore + explorerignore from a workspace root.

Load all .gitignore files (recursive) + .explorerignore.

Walks root recursively for .gitignore files and loads them with their per-directory anchoring. Then loads <root>/.explorerignore (if present) anchored at root. Existing rules are cleared first.

Safe to call repeatedly when the working directory changes.

Parameters
rootWorkspace root directory (must exist; non-canonical paths are accepted).
Version
2.1.4

Clears any prior rules first, so load() is safe to call again when the working directory changes. The root .explorerignore is layered LAST, and matching is last-match-wins, so a workspace can both add exclusions and re-include with !.

Parameters
rootWorkspace root to load from; a missing or non-directory root leaves the matcher empty and is logged. @req REQ-MCP-022
Version
2.3.7

Definition at line 407 of file ignore_matcher.cpp.

◆ rule_count()

std::size_t entropic::IgnoreMatcher::rule_count ( ) const
inline

Number of compiled rules (test surface).

Returns
Rule count. @utility
Version
2.1.4

Definition at line 110 of file ignore_matcher.h.


The documentation for this class was generated from the following files: