Files
freemo 565e7918a3 feat(cli): add --container-id flag to agents resource add for container-instance
Implemented an explicit --container-id option as an alternative to --image
for container-instance resources and added comprehensive validation, data
storage, and fast-path container resolution.

- Added --container-id option to resource_add() in
  src/cleveragents/cli/commands/resource.py as an alternative to --image
  for container-instance resources
- Enforced mutual exclusion: --container-id and --image are mutually
  exclusive; container-instance requires one or the other
- Restricted --container-id to container-instance only (not
  devcontainer-instance)
- Persisted container_id in resource properties when provided
- Updated DevcontainerHandler._find_running_container() in
  src/cleveragents/resource/handlers/devcontainer.py to use the stored
  container_id as a fast path before falling back to docker label search
- Added container_id to container-instance cli_args in
  src/cleveragents/application/services/_resource_registry_data.py
- Created features/container_id_flag.feature and
  features/steps/container_id_flag_steps.py with 5 unit test scenarios
- Created features/container_id_integration.feature and
  features/steps/container_id_integration_steps.py with 5 integration
  test scenarios

Key design decisions:
- Used isinstance(stored_id, str) guard in handler for Pyright type narrowing
- Validation raises typer.Abort() for clean CLI error handling
- No behavioral changes for devcontainer-instance resources

ISSUES CLOSED: #2598
2026-04-05 04:33:46 +00:00
..
2026-02-23 03:11:12 +00:00