Skip to content

Comments

Fix parameter ordering issues in CLI#1669

Merged
mnriem merged 3 commits intogithub:mainfrom
mnriem:fix/parameter-ordering-issue-1641
Feb 23, 2026
Merged

Fix parameter ordering issues in CLI#1669
mnriem merged 3 commits intogithub:mainfrom
mnriem:fix/parameter-ordering-issue-1641

Conversation

@mnriem
Copy link
Collaborator

@mnriem mnriem commented Feb 23, 2026

Problem

Fixes #1641

When users forgot to provide a value for the --ai flag, CLI parameter parsing would consume the next token (often another flag like --here), leading to:

  • Confusing error messages
  • Parameter order dependency
  • Flags being misinterpreted as values

Original Failing Command

specify init --ai-skills --ai --here
# Error: Must specify either a project name, use '.' for current directory, or use --here flag

Solution

Added early validation to detect when option values look like flags (start with --):

  1. Parameter Validation: Checks --ai and --ai-commands-dir values for flag patterns
  2. Clear Error Messages: Provides actionable feedback with:
    • Specific invalid value detected
    • Helpful usage hints
    • Correct usage examples
    • List of available agents
  3. Comprehensive Tests: 5 new tests prevent regressions

Improved Error Output

Before (confusing):

Error: Must specify either a project name, use '.' for current directory, or use --here flag

After (clear and actionable):

Error: Invalid value for --ai: '--here'
Hint: Did you forget to provide a value for --ai?
Example: specify init --ai claude --here
Available agents: copilot, claude, gemini, cursor-agent, ...

Testing

✅ All 56 tests pass (51 existing + 5 new)

Changes

  • src/specify_cli/__init__.py: Added validation logic (+14 lines)
  • tests/test_ai_skills.py: Added comprehensive test suite (+62 lines)
  • pyproject.toml: Version bump to 0.1.6
  • CHANGELOG.md: Added release notes
  • .github/CODEOWNERS: Updated to @mnriem

github-actions bot and others added 2 commits February 21, 2026 14:08
- Add validation to detect when option flags are consumed as values
- Provide clear error messages with helpful hints and examples
- Add 5 comprehensive tests to prevent regressions
- Update CODEOWNERS to @mnriem
- Bump version to 0.1.6 with changelog entry

Fixes: github#1641
Copilot AI review requested due to automatic review settings February 23, 2026 19:12
Copy link
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 fixes CLI argument parsing edge-cases where --ai / --ai-commands-dir can accidentally consume a following flag (e.g., --here), causing confusing validation errors and parameter-order dependency.

Changes:

  • Add early validation in init to detect when --ai / --ai-commands-dir values look like flags and emit actionable errors.
  • Add regression tests covering the broken parameter-ordering scenarios.
  • Bump version and update release notes / ownership metadata.

Reviewed changes

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

Show a summary per file
File Description
src/specify_cli/__init__.py Adds early “value looks like a flag” validation for --ai and --ai-commands-dir.
tests/test_ai_skills.py Adds 5 CLI tests to prevent regressions for issue #1641 scenarios.
pyproject.toml Bumps package version to 0.1.6.
CHANGELOG.md Adds 0.1.6 notes and adjusts changelog structure/content.
.github/CODEOWNERS Updates global code owner.

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

Comment on lines +10 to +21
## [0.1.6] - 2026-02-23

### Fixed

- **Parameter Ordering Issues (#1641)**: Fixed CLI parameter parsing issue where option flags were incorrectly consumed as values for preceding options
- Added validation to detect when `--ai` or `--ai-commands-dir` incorrectly consume following flags like `--here` or `--ai-skills`
- Now provides clear error messages: "Invalid value for --ai: '--here'"
- Includes helpful hints suggesting proper usage and listing available agents
- Commands like `specify init --ai-skills --ai --here` now fail with actionable feedback instead of confusing "Must specify project name" errors
- Added comprehensive test suite (5 new tests) to prevent regressions

## [0.1.5] - 2026-02-21
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

CHANGELOG no longer includes an "Unreleased" section (it now jumps straight into dated releases). If any tooling/docs expect Keep a Changelog structure, this makes it harder to stage changes before a release. Consider reintroducing an "Unreleased" section at the top and moving the 0.1.6 notes under a released heading only when cutting the release.

Copilot uses AI. Check for mistakes.
@@ -69,7 +80,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.0.94] - 2026-02-11

- Add stale workflow for 180-day inactive issues and PRs (#1594)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

This change removes older changelog history (e.g., the 0.0.93 entry and anything below it). Changelogs are typically append-only; please restore the removed sections so historical release notes remain available.

Suggested change
- Add stale workflow for 180-day inactive issues and PRs (#1594)
- Add stale workflow for 180-day inactive issues and PRs (#1594)
## [0.0.93] - 2026-02-10
- Historical changelog entry for version 0.0.93 was previously present and is preserved in the project’s git history (tag `v0.0.93`).
- Refer to the `CHANGELOG.md` content from that tag or the corresponding GitHub release page for the full list of changes.
## Earlier releases (0.0.1–0.0.92)
- Detailed release notes for versions 0.0.1 through 0.0.92 are also available in version control history.
- To view them, check out an earlier revision of `CHANGELOG.md` (before this truncation) or consult the project’s tagged releases.

Copilot uses AI. Check for mistakes.
Comment on lines +1259 to +1265
# Detect when option values are likely misinterpreted flags (parameter ordering issue)
if ai_assistant and ai_assistant.startswith("--"):
console.print(f"[red]Error:[/red] Invalid value for --ai: '{ai_assistant}'")
console.print("[yellow]Hint:[/yellow] Did you forget to provide a value for --ai?")
console.print("[yellow]Example:[/yellow] specify init --ai claude --here")
console.print(f"[yellow]Available agents:[/yellow] {', '.join(AGENT_CONFIG.keys())}")
raise typer.Exit(1)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The new validation block duplicates agent-list rendering and error formatting that already exists later in init() (e.g., the "Invalid AI assistant" path). To reduce drift and keep messaging consistent, consider factoring the shared "available agents" string / rendering into a small helper or constant and reusing it in both places.

Copilot uses AI. Check for mistakes.
@mnriem mnriem merged commit 3040d33 into github:main Feb 23, 2026
8 checks passed
@mnriem mnriem deleted the fix/parameter-ordering-issue-1641 branch February 23, 2026 19:17
brianluby pushed a commit to brianluby/spec-kit that referenced this pull request Feb 24, 2026
* chore: bump version to v0.0.6 [skip ci]

* Fix parameter ordering issues in CLI (github#1641)

- Add validation to detect when option flags are consumed as values
- Provide clear error messages with helpful hints and examples
- Add 5 comprehensive tests to prevent regressions
- Update CODEOWNERS to @mnriem
- Bump version to 0.1.6 with changelog entry

Fixes: github#1641

* Fix ruff linting errors: remove f-string prefix from strings without placeholders

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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.

Parameter ordering issues

1 participant