Skip to content

fix(cli): fold hyphen/case --agent names - #885

Merged
Birfy merged 1 commit into
mainfrom
fix/884-agent-aliases
Nov 8, 2026
Merged

Birfy merged 1 commit into
mainfrom
fix/884-agent-aliases

Conversation

@Birfy

@Birfy Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #884

--agent now folds case and -/_ the same way algorithm names, parameter names, and --kind already do. init --agent claude-code and algorithms run … --agent openai-compatible write the canonical agent.ref (claude_code, openai_compatible) instead of rejecting a spelling doctor / install already print.

Kind mismatch checks still run on the folded name (--agent claude-code on kind=text is still refused as a WorkspaceAgent, #456). Install-only aliases that are not a spelling fold (deepseek-harness, claudecode, open-code) still hint; grok-bot still explains it has no worker CLI.

Verification

  • pytest -q tests/test_init_honor_agent.py tests/test_changelog_fragments.py tests/test_init_default_agent.py tests/test_workspace_agent_hint.py tests/test_cli_json_usage_errors.py tests/test_cli_algorithms_run.py tests/test_install_host_aliases.py passed
  • live init --agent claude-code / --agent openai-compatible write the canonical refs

Closes #884

## What changed
`--agent` now behaves like algorithm names, parameter names, and `--kind`:
a value that matches exactly one built-in worker short ref once case and
`-`/`_` are ignored resolves to it (`claude-code` → `claude_code`,
`openai-compatible` → `openai_compatible`). Written specs use the
canonical `agent.ref`. Kind mismatch checks still run on the folded name
(`--agent claude-code` on kind=text is still refused as a WorkspaceAgent).

Install-only aliases that are not a spelling fold (`deepseek-harness`,
`claudecode`, `open-code`) still hint; `grok-bot` still explains it has
no worker CLI.

## Verification at the tip
Ran:
- pytest -q tests/test_init_honor_agent.py tests/test_changelog_fragments.py
  tests/test_init_default_agent.py tests/test_workspace_agent_hint.py
  tests/test_cli_json_usage_errors.py tests/test_cli_algorithms_run.py
  tests/test_install_host_aliases.py → passed
- live `init --agent claude-code` / `--agent openai-compatible` write the
  canonical refs; `grok-bot` and `kind=text --agent claude-code` still refuse
Not run:
- full suite — CI covers 3.9–3.13
@Birfy

Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS
Tip SHA: fbe66d8
Ran: pytest -q tests/test_init_honor_agent.py tests/test_changelog_fragments.py tests/test_init_default_agent.py tests/test_workspace_agent_hint.py tests/test_cli_json_usage_errors.py tests/test_cli_algorithms_run.py tests/test_install_host_aliases.py at the tip → passed; live init --agent claude-code / --agent openai-compatible write the canonical refs; grok-bot and kind=text --agent claude-code still refuse. risk_gate.py from main → T2 (91 changed lines / 3 files).
Not run: full suite (CI covers 3.9–3.13).

Correctness. --agent now folds case and -/_ the same way algorithm names, parameter names, and --kind already do, so a spelling copied from doctor / install (claude-code, openai-compatible, CLAUDE_CODE) writes the canonical agent.ref. Kind mismatch still runs on the folded name (no silent swap, #456). Install-only aliases that are not a spelling fold (deepseek-harness, claudecode, open-code) still hint; grok-bot still explains it has no worker CLI.

Risk. T2 by size/path (CLI validation only; no evolve-loop change).

@Birfy
Birfy enabled auto-merge (squash) November 8, 2026 08:10
@Birfy

Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS
Tip SHA: fbe66d8
Ran: pytest -q tests/test_init_honor_agent.py tests/test_changelog_fragments.py tests/test_init_default_agent.py tests/test_workspace_agent_hint.py tests/test_cli_json_usage_errors.py tests/test_cli_algorithms_run.py tests/test_install_host_aliases.py at the tip → passed (exit 0). risk_gate.py from main → T2 (91 changed lines / 3 files).
Not run: full suite (CI covers 3.9–3.13).

Correctness. --agent now folds case and -/_ onto a built-in short ref (claude-code / CLAUDE_CODE → claude_code, openai-compatible → openai_compatible) in write_starter_spec, so both init and algorithms run write the canonical agent.ref instead of rejecting a spelling doctor / install already print. Kind-mismatch checks still run on the folded name (--agent claude-code on kind=text is still refused as a WorkspaceAgent, #456). Install-only aliases that are not a spelling fold (deepseek-harness, claudecode, open-code) still hint at the worker; grok-bot still explains it has no worker CLI; module:attribute refs and unrelated names like bogus are unchanged.

Design. fold_agent_ref matches the existing algorithm-name / parameter-name / --kind fold (strip + casefold + hyphen-to-underscore, accept only when the result is exactly one known ref). Applying it once in the shared writer is the right layer — no second parser path to drift. The leftover did-you-mean branch in init_agent_unknown for hyphen/case aliases is now dead for this call site (fold happens first) and remains a safe fallback if another caller forgets to fold.

Tests / docs. New cases cover hyphen/case aliases on init, algorithms run, the #456 kind-mismatch gate, fold_agent_ref itself (including leaving deepseek-harness and module:attribute alone), and changelog fragment 884-agent-aliases.md. Existing install-host hint tests still pass.

Risk. T2 by size (package CLI validation only; 91 lines / 3 files, under the 250-line cap). No evolve-loop or installer change. AGENT_PAUSE=false; will squash-merge when required CI is green.

@Birfy
Birfy merged commit 02b11ba into main Nov 8, 2026
9 checks passed
@Birfy
Birfy deleted the fix/884-agent-aliases branch November 8, 2026 08:35
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.

cli: --agent rejects hyphen/case variants that install and doctor already use (claude-code → claude_code)

1 participant