fix: ensure idempotent project-relative path rewriting in CommandRegistrar - #4553
darion-yaphet wants to merge 2 commits into
Conversation
|
The delimiter and deeper-parent-path improvements have useful regression coverage. Before merge, please preserve parent-relative paths following Please also clarify the description: the supplied samples already remain stable under repeated rewriting on the old code; the demonstrated improvements are routing and delimiter handling. Finally, complete this PR’s AI disclosure with the tool, model, mode/settings, and extent of assistance—the checkbox alone does not describe the contribution. Drafted for @mnriem by GitHub Copilot (model: GPT-6 Astra; comment drafting). |
There was a problem hiding this comment.
🟢 Approval recommended
The refactor preserves routing behavior and includes focused regression coverage.
Pull request overview
Refactors project-relative path rewriting into an idempotent, single-pass implementation.
Changes:
- Consolidates path normalization into one regex callback.
- Adds regression coverage for idempotency, delimiters, and invalid inputs.
File summaries
| File | Description |
|---|---|
src/specify_cli/agents.py |
Implements unified path rewriting. |
tests/test_extensions.py |
Adds comprehensive regression tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…strar
Replace the fragile pattern of three sequential string replacements followed by three re.sub calls and trailing `.replace(".specify/.specify/", ".specify/")` / `.replace(".specify.specify/", ".specify/")` patches in CommandRegistrar.rewrite_project_relative_paths.
Consolidate the transformation into a unified regex match callback that:
- Inspects matched path prefixes (`.specify/`, `../`, `./`, `/`, or bare)
- Naturally guards already-normalized `.specify/` paths from double-prefixing
- Directs parent relative references (`../`) to root `.specify/<target>/`
- Preserves extension-local script scoping when extension_id is provided
- Expands boundary delimiters to include Markdown brackets, parentheses, braces, angle brackets, and backticks
Add unit tests in tests/test_extensions.py covering repeated passes for idempotency, markdown enclosure delimiters, and edge-case inputs.
Assisted-by: Antigravity (supervised)
…lative_paths Extend the delimiter boundary character class in CommandRegistrar.rewrite_project_relative_paths to include '=', ensuring option flags (e.g., '--template=../../templates/spec.md') and environment variable assignments (e.g., 'SCRIPT=../../scripts/bash/run.sh') continue to be rewritten properly. Add regression test coverage in tests/test_extensions.py covering '=' assignments and verifying repeated passes for idempotency. Assisted-by: Google Antigravity (model: Gemini 3.8 Flash, supervised)
661957c to
f6ecaa9
Compare
|
Thanks for the thorough review and catching the I have addressed the feedback in commit f6ecaa9:
Drafted on behalf of @darion-yaphet by Google Antigravity (model: Gemini 3.8 Flash (High), human-supervised; comment drafting and code refinement). |
Description
Refactors
CommandRegistrar.rewrite_project_relative_paths()from multi-step string replacements and sequential regex passes into a unified single-pass regex callback.Key improvements:
re.subpasses and trailing.replace(".specify/.specify/", ".specify/")cleanup with a clean, unified regex match callback.../../,../../../) to root.specify/<target>/while preserving extension-local scoping for top-level scripts whenextension_idis supplied.[],(),{},<>), quotes, backticks, and option/variable assignment delimiters (=, e.g.,--template=../../templates/spec.mdandSCRIPT=../../scripts/bash/run.sh)..specify/paths from duplicate prefixing across repeated passes without needing post-hoc string stripping.Testing
pytest tests/test_extensions.py(542 passed)pytest tests/test_extensions.py -k "test_rewrite_project_relative_paths"(5 passed)ruff check src/specify_cli/agents.py tests/test_extensions.py(0 errors)AI Disclosure
AI disclosure: Implemented with Google Antigravity using Gemini 3.8 Flash (High) in human-supervised mode for code refactoring, test case generation, and addressing review feedback.