headroom/tests/test_cli
JerrettDavis 4c062319f0 fix(init): guide users when no agents are auto-detected
Fixes #245.

Running ``headroom init -g`` with no supported agents on PATH previously
produced a single-line ClickException that read like the -g flag had
been removed:

    Error: No supported user init targets were auto-detected. Specify one explicitly.

This left reporter #245 concluding the feature was gone. Replace that
message with a structured diagnostic that:

* states which scope (user / local) was tried
* lists every target probed (claude, codex, copilot, openclaw) and the
  shutil.which() result for each
* explicitly confirms that -g / --global is still a supported flag
* shows the concrete per-target invocation for each agent
  (``headroom init -g claude``, ...) so the user knows the escape hatch

The implementation factors ``detect_init_targets`` into a ``_probe_init_targets``
helper that returns ``[(name, which_result)]``. ``detect_init_targets``
keeps its existing signature so the test suite and external imports
aren't broken; the new helper backs both the auto-detection path and
the diagnostic error formatter.

Unit tests in tests/test_cli/test_init_cli.py cover:
* the end-to-end message shape (structural markers + every target name +
  the example invocation)
* the local-scope variant omitting global-only agents (copilot / openclaw)
* that found binaries are surfaced with their absolute path so users can
  debug cases where shutil.which returns an unexpected result

No behavior change when at least one target is detected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:55:12 -05:00
..
test_init_cli.py fix(init): guide users when no agents are auto-detected 2026-04-23 15:55:12 -05:00
test_install_cli.py test: expand persistent install coverage 2026-04-11 18:24:15 -05:00
test_main_help_version.py feat(cli): add Docker-native install flow and parity docs 2026-04-10 23:27:24 -05:00
test_mcp.py Enhanced MCP server with compress/stats tools, fix proxy torch crash 2026-03-16 22:56:30 -07:00
test_wrap_aider.py chore: normalize provider slice line endings 2026-04-21 23:54:28 -05:00
test_wrap_bridge.py feat(cli): support OpenClaw in Docker-native installs 2026-04-11 00:04:15 -05:00
test_wrap_codex.py fix(wrap): unwrap codex restores prior config.toml 2026-04-23 11:13:54 -05:00
test_wrap_copilot.py Merge upstream/main into feat/canonical-pipeline 2026-04-22 13:10:53 -05:00
test_wrap_openclaw.py feat(cli): support OpenClaw in Docker-native installs 2026-04-11 00:04:15 -05:00
test_wrap_persistent.py fix: stabilize cli test isolation 2026-04-22 11:28:30 +00:00