Skip to content

feat(presets): support regex resource selectors - #4776

Open
lmtyy wants to merge 2 commits into
github:mainfrom
lmtyy:feat/4659-regex-preset-selectors
Open

lmtyy wants to merge 2 commits into
github:mainfrom
lmtyy:feat/4659-regex-preset-selectors

Conversation

@lmtyy

@lmtyy lmtyy commented Sep 28, 2026

Copy link
Copy Markdown

Add regex: selectors for preset templates, scripts, and commands. Existing exact-name matching remains unchanged; regex patterns are validated and matched against complete resource names.

Command selectors are expanded to concrete lower-layer command names before registration, keeping selector expressions out of command filenames and registry records. Reconciliation and diagnostics handle matched resources across preset lifecycle changes.

Closes #4659

Testing

  • Tested locally with uv run specify --help
  • Ran the full test suite: 8415 passed, 211 skipped
  • Ran targeted selector, resolver, manifest, and command lifecycle tests: 376 passed
  • Ran Python parity tests: 98 passed, 2 skipped
  • Ran Ruff checks, ShellCheck, PowerShell syntax parsing, Python compilation, and git diff --check

AI Disclosure

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

AI disclosure: Implemented with Hermes Agent (Nous Research), using the gpt-6-Astra model in an interactive, human-supervised workflow. AI assistance was used for code changes, tests, debugging, and validation; the contributor should review the final diff before merging.

Add regex:<pattern> selectors for preset templates, scripts, and commands while preserving exact-name behavior. Validate regex patterns and use full-name matching. Expand command selectors to concrete lower-layer commands before registration and reconcile affected commands across preset lifecycle changes.

Add selector, resolver, command lifecycle, and diagnostic coverage. Verified with the full test suite (8415 passed, 211 skipped), Ruff, ShellCheck, PowerShell syntax parsing, Python compilation, and git diff --check.

Closes github#4659

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.

Copilot review overview

馃煛 Changes recommended

Command resolution, skill registration, diagnostics, warnings, and lifecycle reconciliation have unresolved functional gaps.

Review effort: Balanced
Findings: 3 High severity 路 2 Medium severity

Open (5)
What changed in this PR

Adds regex: resource selectors to preset resolution and command materialization.

Changes:

  • Validates and full-matches regex selectors.
  • Expands command selectors and adds lifecycle reconciliation.
  • Adds resolver and selector coverage.
File Description
tests/鈥媠pecify_cli/鈥媝resets/鈥媡est_regex_selectors.py Tests selector matching and resolution.
src/鈥媠pecify_cli/鈥媝resets/鈥媍ommand_set_priority.py Reconciles commands after priority changes.
src/鈥媠pecify_cli/鈥媝resets/鈥媍ommand_info.py Displays selector matches.
src/鈥媠pecify_cli/鈥媝resets/鈥媍ommand_enable.py Reconciles enabled preset commands.
src/鈥媠pecify_cli/鈥媝resets/鈥媉selectors.py Implements selector helpers.
src/鈥媠pecify_cli/鈥媝resets/鈥媉resolver.py Resolves regex template and script layers.
src/鈥媠pecify_cli/鈥媝resets/鈥媉manifest.py Validates regex expressions.
src/鈥媠pecify_cli/鈥媝resets/鈥媉manager.py Integrates expansion into lifecycle handling.
src/鈥媠pecify_cli/鈥媝resets/鈥媉manager_commands.py Expands command selectors.

馃挕 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/specify_cli/presets/_resolver.py Outdated
Comment thread src/specify_cli/presets/_resolver.py Outdated
Comment thread src/specify_cli/presets/command_info.py Outdated
Comment thread src/specify_cli/presets/_manager.py
Comment thread src/specify_cli/presets/_manager_commands.py
@mnriem

mnriem commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

Add regex:<pattern> selectors for preset templates, scripts, and commands while preserving exact-name behavior. Resolve all matching declarations in manifest order, expand command selectors before registration, and reconcile matches after preset and extension changes. Add selector diagnostics and regression coverage.

Closes github#4659
@lmtyy

lmtyy commented Sep 28, 2026

Copy link
Copy Markdown
Author

Addressed all five Copilot review findings:

  • Added command regex selectors to normal layer resolution and composition.
  • Preserved all matching regex declarations in manifest order.
  • Fixed the invalid _selectors imports used by diagnostics.
  • Reused selector expansion for AI-skill registration.
  • Added selector-aware reconciliation for relevant preset/extension lifecycle changes.

Also added regression coverage for overlapping selectors, command composition strategies, diagnostics, AI-skill registration, and lifecycle state changes.

Validation:

  • 8624 passed, 17 skipped
  • 183 targeted regression tests passed
  • Ruff passed
  • Python compilation passed
  • git diff --check passed

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mnriem mnriem added the triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate label Sep 28, 2026
@lmtyy

lmtyy commented Sep 29, 2026

Copy link
Copy Markdown
Author

All previous Copilot review findings have been addressed and the updated test suite is passing. The latest Copilot re-review appears to have failed due to a review error, so the PR is ready for another review when convenient.

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

triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support regex selectors for preset commands, templates, and scripts

3 participants