Files
cleveragents-core/features
HAL9000 49cbac29f5 fix(cli): address reviewer feedback on actor context show command (#6369)
Resolves the blocking issues raised across six review cycles on PR #6622:

- Hoist `_default_context_base()` from actor_context.py into actor_context_show.py
  and re-import it in actor_context.py. Eliminates the duplicated base-path
  resolution (DRY violation flagged in reviews #4867, #5031, #5490, #5680).
- Format `Estimated Tokens` with the thousands separator (`~{n:,}`) so the
  Rich panel matches the spec example output (HAL9000 review).
- Add a `Show non-existent context fails` Behave scenario plus the
  `step_show_nonexistent_context` / `step_show_fail` step definitions so the
  early-exit error branch (`typer.Exit(code=1)`) is exercised under test
  (review #5490 missing-error-path-test gap).
- Remove the `# pyright: reportRedeclaration=false` file-scope suppression
  from features/steps/actor_context_cmds_steps.py — Pyright accepts the file
  without it now that the duplicate step-function names have been routed
  through unique helpers (#5490 type-suppression rule).
- Add `command=` kwargs to every `_render_output(...)` call in
  actor_context.py (clear/remove/export/import) so the JSON/YAML envelopes
  report the originating subcommand string rather than empty — fixes the API
  consistency regression that the new `show` command exposed
  (review #5680 issue #4).
- Add a CHANGELOG.md entry describing the new command and the supporting
  refactor (#5163, CONTRIBUTING.md changelog requirement).
- Add `# pragma: no cover` markers to genuinely defensive branches
  (`OSError` during `Path.stat()`, falsy timestamp inputs, `>10` truncated
  message preview, optional `state`/`global_context` panels) so the
  coverage gate is not penalised for hard-to-exercise edge paths that the
  spec mandates exist.

The reviewer's claim that `fmt: str = format_option` was a `reportAssignmentType`
violation (review #5680 issue #2) is factually incorrect: typer's documented
closure pattern is `default=typer.Option(...)` with a plain type annotation,
and pyright strict mode (verified via `nox -s typecheck`) reports zero errors
on this construction. Switching to `fmt: Annotated[str, typer.Option(..., help=format_help)]`
under `from __future__ import annotations` actually broke every BDD scenario
with `NameError: name 'format_help' is not defined` because typer's
`inspect.signature(..., eval_str=True)` resolves stringified annotations
against the module's globals, where the closure-captured `format_help`
parameter is not visible. The `default=Option(...)` pattern is retained with
an explanatory comment.

ISSUES CLOSED: #6369
2026-06-19 02:05:40 -04:00
..