Skip to content

fix: unofficial PyPI warning (#1982) and legacy extension command name auto-correction (#2017)#2027

Draft
mbachorik wants to merge 7 commits intogithub:mainfrom
mbachorik:fix/pypi-warning-and-legacy-extension-names
Draft

fix: unofficial PyPI warning (#1982) and legacy extension command name auto-correction (#2017)#2027
mbachorik wants to merge 7 commits intogithub:mainfrom
mbachorik:fix/pypi-warning-and-legacy-extension-names

Conversation

@mbachorik
Copy link
Copy Markdown
Contributor

@mbachorik mbachorik commented Mar 30, 2026

Summary

  • [Bug]: 0.4.2 removed "extension" command from specify #1982 — Adds a clear warning to README.md and docs/installation.md that the only official packages are published from github/spec-kit; any same-named PyPI packages are unaffiliated. Also adds specify version as a recommended post-install verification step.
  • [Bug]: PR #1776 alias validation breaks all community extensions — alias pattern not documented #2017 — Instead of hard-failing when a community extension uses a legacy 2-part command name (e.g. docguard.guard or speckit.verify), auto-correct it to the required speckit.{extension}.{command} pattern and emit a compatibility warning so authors know to update their manifest. Names that cannot be safely corrected still raise ValidationError.
  • Bonus — Fixes a pre-existing flaky test (TestPresetCatalog::test_search_with_cached_data) that was making live network calls to the community catalog, causing non-deterministic result counts.

Changes

docs/installation.md / README.md

  • Warning block clarifying GitHub is the only official source
  • specify version verification step added after install instructions

src/specify_cli/extensions.py

  • ExtensionManifest.__init__: initialises self.warnings: List[str]
  • ExtensionManifest._validate(): on invalid command name, attempts auto-correction before raising
  • ExtensionManifest._try_correct_command_name(): new static method handling X.Y → speckit.X.Y and speckit.Y → speckit.{ext_id}.Y
  • _COMMAND_NAME_RE: compiled class-level regex constant (replaces two raw re.match calls)

src/specify_cli/__init__.py

  • extension_add: prints compatibility warnings from manifest.warnings after successful install

tests/test_extensions.py

  • 3 new tests covering both auto-correction paths and the no-warning happy path
  • Updated docstring on existing invalid-name test

tests/test_presets.py

  • test_search_with_cached_data: writes a project-level preset-catalogs.yml to restrict the test to the default catalog only, preventing live community catalog network calls

Test plan

  • All 819 tests pass
  • specify extension add --from <legacy-zip> installs with a compatibility warning instead of failing
  • specify extension add --from <valid-zip> installs silently (no warning)
  • Completely uncorrectable names (e.g. invalid-name) still raise ValidationError

🤖 Generated with Claude Code

@mbachorik mbachorik requested a review from mnriem as a code owner March 30, 2026 21:25
Copilot AI review requested due to automatic review settings March 30, 2026 21:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves user safety and extension compatibility by warning against unofficial PyPI packages, adding a post-install verification step, and making legacy community extension command names auto-correct (with warnings) instead of hard-failing. It also stabilizes a previously flaky preset-catalog test by preventing unintended live community catalog lookups.

Changes:

  • Add prominent documentation warnings that Spec Kit’s official packages are only distributed from github/spec-kit, plus a recommended specify version verification step.
  • In extension manifest validation, auto-correct common legacy 2-part command names to the required 3-part speckit.{extension}.{command} form and surface compatibility warnings on install.
  • Make TestPresetCatalog::test_search_with_cached_data deterministic by restricting catalogs to default-only via a project-level preset-catalogs.yml.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Adds an “official source only” warning and a specify version verification step after install instructions.
docs/installation.md Adds the same warning and a verification section recommending specify version.
src/specify_cli/extensions.py Adds command-name regex constant, manifest warnings, and auto-correction logic for legacy command names.
src/specify_cli/__init__.py Prints manifest compatibility warnings after successful specify extension add.
tests/test_extensions.py Adds tests for both auto-correction paths and the no-warning valid path; updates an existing docstring.
tests/test_presets.py Writes .specify/preset-catalogs.yml in a test to avoid community-catalog network flakiness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mbachorik mbachorik force-pushed the fix/pypi-warning-and-legacy-extension-names branch from 56c6b66 to 44d1996 Compare March 30, 2026 21:33
Copilot AI review requested due to automatic review settings March 30, 2026 21:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

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

Please address Copilot feedback. If not applicable, please explain why

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem mnriem self-requested a review March 31, 2026 19:55
Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

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

Please address Copilot feedback

@mbachorik
Copy link
Copy Markdown
Contributor Author

@mnriem I've bundled this with the fix for 2/3dot alias notation. Will wait for feedback from the reporter (or we decide tonight and agree on fix). Will address all copilot feedback as usual .. (switching it to draft so it does not spam you)

@mbachorik mbachorik marked this pull request as draft April 1, 2026 11:27
iamaeroplane and others added 6 commits April 4, 2026 08:12
…ication (github#1982)

Clarify that only packages from github/spec-kit are official, and add
`specify version` as a post-install verification step to help users
catch accidental installation of an unrelated package with the same name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iling (github#2017)

Community extensions that predate the strict naming requirement use two
common legacy formats ('speckit.command' and 'extension.command').
Instead of rejecting them outright, auto-correct to the required
'speckit.{extension}.{command}' pattern and emit a compatibility warning
so authors know they need to update their manifest. Names that cannot be
safely corrected (e.g. single-segment names) still raise ValidationError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… network calls

test_search_with_cached_data asserted exactly 2 results but was getting 4
because _get_merged_packs() queries the full built-in catalog stack
(default + community). The community catalog had no local cache and hit
the network, returning real presets. Writing a project-level
preset-catalogs.yml that pins the test to the default URL only makes
the count assertions deterministic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The upstream github#1994 added alias validation in _collect_manifest_command_names,
which also rejected legacy 2-part alias names (e.g. 'speckit.verify').
Extend the same auto-correction logic from _validate() to cover aliases,
so both 'speckit.command' and 'extension.command' alias formats are
corrected to 'speckit.{ext_id}.{command}' with a compatibility warning
instead of hard-failing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _try_correct_command_name: only correct 'X.Y' to 'speckit.ext_id.Y'
  when X matches ext_id, preventing misleading warnings followed by
  install failure due to namespace mismatch
- _validate: add aliases type/string guards matching _collect_manifest
  _command_names defensive checks
- _validate: track command renames and rewrite any hook.*.command
  references that pointed at a renamed command, emitting a warning
- test: fix test_command_name_autocorrect_no_speckit_prefix to use
  ext_id matching the legacy namespace; add namespace-mismatch test
- test: replace redundant preset-catalogs.yml isolation with
  monkeypatch.delenv("SPECKIT_PRESET_CATALOG_URL") so the env var
  cannot bypass catalog restriction in CI environments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t validation (github#2017)

- Remove accidental hook reference from alias auto-correction test (fixture
  has after_tasks hook whose command matches the alias being renamed, causing
  a spurious second warning)
- Update collision test fixture to use a primary command collision instead of
  an alias-based one (alias namespace enforcement now makes cross-extension
  alias collisions impossible by design)
- Update test_command_with_aliases and test_copilot_aliases_get_companion_prompts
  to use the new 2-part alias format (ext-id.command) rather than the legacy
  3-part speckit.ext.command form
- Normalize aliases: null to aliases: [] in _validate() so downstream
  cmd_info.get('aliases', []) cannot return None when the YAML key exists
  but is explicitly null

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mbachorik mbachorik force-pushed the fix/pypi-warning-and-legacy-extension-names branch from 3fed7f7 to caee3e0 Compare April 4, 2026 07:34
Copilot AI review requested due to automatic review settings April 4, 2026 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…orrection to ext_id (github#2017)

- Raise ValidationError with a clear message if the manifest 'hooks' value
  is not a mapping (previously would AttributeError on .items())
- Restrict _try_correct_alias_name 3-part correction (speckit.X.Y → X.Y)
  to only apply when X == ext_id; when X differs the alias is squatting a
  foreign namespace and should be rejected, not silently rewritten

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants