Skip to content

feat: add .presetignore support - #5020

Open
grafvonb wants to merge 3 commits into
github:mainfrom
grafvonb:feat/presetignore
Open

grafvonb wants to merge 3 commits into
github:mainfrom
grafvonb:feat/presetignore

Conversation

@grafvonb

Copy link
Copy Markdown
Contributor

Description

Add .presetignore support so preset authors can exclude development-only files from installed presets, matching the existing .extensionignore behavior.

  • Share ignore loading and matching between extensions and presets, preserving extension behavior.
  • Support Git-style patterns, comments, negation, directory patterns, root anchoring, UTF-8, and existing whitespace/backslash normalization.
  • Exclude .presetignore itself. Preserve existing copying behavior when absent; do not use .gitignore or introduce default exclusions.
  • Validate ignore files before the source-directory installer removes existing files or registration state.
  • Apply filtering to directory installs, archive installs, reinstalls, and update replacements.
  • Document supported semantics and examples.

preset update retains its documented remove-then-add behavior. The existing extension force-removal ordering remains unchanged.

Testing

Commands use this checkout鈥檚 virtual environment, following repository guidance.

  • Tested locally with .venv/bin/specify --help
  • Ran existing tests with uv sync --extra test and .venv/bin/python -m pytest tests -q
  • Tested with a sample project

Results:

  • 12,673 passed and 101 skipped across the full run and targeted retries. The sandboxed run encountered 9 failures and 628 setup errors involving network access and local HTTP servers; all 637 cases passed outside the sandbox without code changes. The initial run emitted 62 warnings.
  • Captured 25 failing preset cases before implementation and verified they pass afterward.
  • Added mirrored helper tests and installer regression coverage.
  • Validated specify init --preset, template resolution, and preset update in a temporary Codex project.
  • Executed the installed speckit-specify skill; the generated specification retained the preset template marker and satisfied all 16 quality-checklist criteria.
  • Ruff 0.15.10 and git diff --check passed.

Validation ran on macOS with Python 3.11.15. The cross-platform CI matrix remains pending.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: OpenAI Codex using GPT-6 in autonomous coding-agent mode authored the implementation, tests, documentation, commit messages, and this PR description. Codex also reviewed repository guidance, ran automated tests, and executed the sample-project workflow validation. This does not claim human manual testing or line-by-line review.

Share extension ignore loading and matching with presets while preserving
extension behavior. Validate preset ignore files before the directory
installer removes existing files, registry entries, or registered commands.

Cover pattern semantics, encoding failures, ignored manifests and assets,
archive reinstalls, and CLI updates. Document filtering rules and the
existing remove-then-add update limitation.

Validation: 1,520 tests pass in this checkout's virtual environment, with
three failure-path warnings. Capture 25 failing preset cases before the
implementation and verify that they pass afterward.

Assisted-by: Codex (model: GPT-6, autonomous)
Move all 16 pattern cases into the mirrored test_install_ignore suite and
run them for both extension and preset ignore files. Retain installer
lifecycle coverage and test absent files, self-exclusion, domain validation
errors, and read failures at the shared helper boundary.

Validation:
- 1,546 relevant tests pass with three existing failure-path warnings.
- Full-suite collection increases from 12,748 to 12,774; all original
  pattern parameter sets remain represented.
- Ruff 0.15.10 and git diff --check pass for the follow-up.
- Initialize a temporary Codex skills project with a local preset using
  .presetignore and confirm development files are excluded while a template
  matched by .gitignore remains installed.
- Execute the installed speckit-specify skill in the Codex session, resolve
  the preset template, and create a reading-list specification with its
  preset marker retained and all 16 quality-checklist criteria satisfied.
- Run preset update with replacement ignore rules and verify the new
  retained file replaces the previously retained file.

Manual workflow validation was performed by Codex on macOS with Bash
project scripts; no human testing or cross-platform CI result is claimed.
The full test suite and CI OS/Python matrix were not executed.

Assisted-by: Codex (model: GPT-6, autonomous)
@grafvonb
grafvonb requested a review from mnriem as a code owner October 18, 2026 13:11
Copilot AI max review requested due to automatic review settings October 18, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煛 Changes recommended

UTF-8 byte-order marks can silently disable the first ignore rule.

1 open issue
What changed in this PR

Adds .presetignore support so preset authors can exclude development files using the existing extension filtering semantics.

Changes:

  • Share ignore loading and matching between presets and extensions.
  • Validate preset ignore files before directory replacement.
  • Add installation regressions and document supported patterns.
File Description
tests/鈥媡est_extensions.py Verify declared files remain filterable.
tests/鈥媠pecify_cli/鈥媡est_install_ignore.py Test shared matching and validation contracts.
tests/鈥媠pecify_cli/鈥媝resets/鈥媡est_manager.py Cover filtering, reinstalls, and state preservation.
tests/鈥媔ntegration/鈥媡est_preset_update_workflow.py Verify filtering during updates.
src/鈥媠pecify_cli/鈥媝resets/鈥媉manager.py Validate and apply preset ignore rules.
src/鈥媠pecify_cli/鈥媏xtensions/鈥媉_init__.py Delegate filtering to the shared helper.
src/鈥媠pecify_cli/鈥媉install_ignore.py Centralize ignore loading and matching.
docs/鈥媟eference/鈥媝resets.md Explain patterns and installation behavior.

Review effort: Max

Comment thread src/specify_cli/_install_ignore.py Outdated
Decode preset and extension ignore files with utf-8-sig so an optional BOM does not become part of the first pattern. Cover ASCII and non-ASCII first patterns with BOM and CRLF fixtures, and document BOM support.

Validation: four new regression cases failed before the fix; the relevant preset, extension, and shared-ignore suites passed with 1550 tests and 3 warnings. Ruff and git diff --check passed.

Assisted-by: Codex (model: GPT-6, autonomous)
Copilot AI max review requested due to automatic review settings October 18, 2026 14:13

This branch has not been deployed

No deployments
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