Skip to content

Feature request: ignorePatterns setting to hide paths from pi tools #3504

Description

@floogy

Summary

Add an ignorePatterns (or ignorePaths) array to settings.json that causes pi's built-in tools (read, bash globbing helpers, any future grep/glob/ls tools, autocomplete file pickers, @file mentions, etc.) to refuse or skip matching paths by default.

Today the only way to keep pi away from directories like .svn, node_modules, build outputs, vendored code, secrets, or very large data dirs is to instruct the model via AGENTS.md. That is:

  • Best-effort only — the model can still read or bash cat the file.
  • Wasteful — instructions must be repeated per project/globally and burn context.
  • Inconsistent — different models honor it to varying degrees.

A declarative setting would make this a hard guardrail in the tool layer.

Motivating examples

  • SVN working copies: .svn/ at any depth contains huge text-base blobs that destroy context windows and leak old source.
  • node_modules/, vendor/, .venv/, dist/, build/, .next/, target/ — rarely what you want the agent reading.
  • Secrets dirs: .env*, secrets/, *.pem, *.key.
  • Generated caches: .aider.tags.cache.*, .mypy_cache/, __pycache__/.

Proposed shape

{
  "ignorePatterns": [
    "**/.svn/**",
    "**/node_modules/**",
    "**/.venv/**",
    "**/dist/**",
    "**/*.pem",
    "!**/docs/examples/node_modules/**"
  ]
}

Semantics (mirroring the existing resource-loading arrays described in docs/settings.md):

  • Gitignore-style globs, matched against absolute and repo-relative paths.
  • !pattern re-includes.
  • +path / -path force-include / force-exclude exact paths.
  • Project .pi/settings.json merges with / overrides ~/.pi/agent/settings.json.

Tool-layer enforcement

When a tool is about to touch a path that matches ignorePatterns:

  • read → return a short error like "refused: path matches ignorePatterns (\"**/.svn/**\"). Override with +path in settings or ask the user."
  • edit / write → same refusal.
  • bashnot filtered (too invasive), but pi could inject a reminder into the system prompt listing the ignore globs so the model naturally scopes find/rg/grep calls. Optionally a bashIgnoreHint: true setting.
  • Autocomplete / @file pickers / file listing tools → silently skip matching entries.
  • Session file tracking, /tree, and context summarization → skip matching entries.

Escape hatch

  • Per-call: allow the model to pass { bypassIgnore: true } with a reason string, which surfaces a user confirmation prompt (similar to destructive-command confirmation).
  • Per-settings: +path override as noted above.

Relationship to .gitignore

Tempting to just "respect .gitignore," but I'd argue not by default:

  • Many git-ignored paths are exactly what the agent should read: .env.example, lockfiles, dist/ when debugging a shipped bug, generated clients, build logs, IDE configs, local fixtures.
  • Non-git projects (SVN, Perforce, plain dirs) have no .gitignore.
  • .gitignore is hierarchical (per-dir files, .git/info/exclude, core.excludesfile) — faithful support is non-trivial and couples pi behavior to git state.
  • Confusing failure mode: "why can't pi read my build output?" requires users to debug via git internals.

But it's a reasonable opt-in:

{
  "ignorePatterns": ["**/.svn/**"],
  "ignorePatternsFromGitignore": true
}

When true, pi loads .gitignore (and .git/info/exclude) via a library like ignore and unions the patterns with ignorePatterns. Explicit +path / !pattern entries in ignorePatterns still win, so users can re-include specific git-ignored files they actually want pi to see.

Alternatives considered

  1. Document-only approach via AGENTS.md — current state; soft, leaky.
  2. Auto-respect .gitignore — see above; viable as opt-in, wrong as default.
  3. Filesystem-level (bind mounts, chmod) — works but hostile to non-pi tooling and cross-platform broken.

A dedicated ignorePatterns (with optional .gitignore union) is the minimal, explicit, portable solution.

Nice-to-haves

  • /settings UI entry to view/edit the list.
  • An /ignored diagnostic showing which patterns are ignored.
  • Built-in default set behind an ignorePatternsDefaults: true flag (ships with **/.git/objects/**, **/.svn/**, **/node_modules/**, **/__pycache__/**, etc.) so new users get sane behavior out of the box, overridable by project config.

Version

@mariozechner/pi-coding-agent 0.68.0 on Artix Linux / Node 20.20.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions