agent-orchestrator/packages/cli/__tests__/lib
Dhruv Sharma 6d48022c87
feat(cli): wire activity events into CLI commands and supervisor lifecycle (#1698)
* feat(cli): wire activity events into CLI commands and supervisor lifecycle (#1654)

Adds "cli" to ActivityEventSource and emits ~30 activity events across the CLI
surface so `ao events list --source cli` can answer RCA questions like:

- Did AO start cleanly? When? (cli.start_invoked / cli.start_failed)
- Was AO shut down gracefully or did it crash? (cli.shutdown_signal /
  cli.shutdown_completed / cli.shutdown_force_exit / cli.stale_running_pruned)
- Did ao spawn / ao update / ao stop / ao migrate-storage fail and why?
- Did the auto-restore prompt actually restore sessions?

Instrumented files:
- packages/core/src/activity-events.ts (cli source)
- packages/cli/src/lib/shutdown.ts (signal/completed/failed/force_exit/session_kill_failed)
- packages/cli/src/commands/start.ts (start_invoked/start_failed/restore_*/stop_*/daemon_*/last_stop_* /config_migrated)
- packages/cli/src/commands/spawn.ts (spawn_invoked/spawn_failed)
- packages/cli/src/commands/update.ts (update_invoked/update_failed)
- packages/cli/src/commands/setup.ts (setup_failed)
- packages/cli/src/commands/migrate-storage.ts (migration_completed/migration_failed)
- packages/cli/src/commands/project.ts (project_register_failed)
- packages/cli/src/lib/resolve-project.ts (project_resolve_failed/config_recovered/config_recovery_failed)
- packages/cli/src/lib/running-state.ts (lock_timeout/stale_running_pruned)
- packages/cli/src/lib/credential-resolver.ts (credential_load_failed)

All emits are sync, never wrapped in try/catch (recordActivityEvent never
throws), and put raw error text in data.errorMessage (not summary, which is
FTS-indexed and not credential-sanitized).

Tests:
- 16 new instrumentation tests across shutdown, migrate-storage, update,
  resolve-project, and start/stop action paths covering MUST emits.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: correct CLI activity event semantics

* fix(cli): emit migrate-storage invocation event

* fix(cli): record last-stop write failures

* fix(linear): retry transient API failures

* fix(cli): stabilize update instrumentation test

* fix(cli): stub process probes in stop instrumentation tests

* chore(ci): retrigger checks

* Fix CLI failure event review issues

* fix: bound linear integration cleanup

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: whoisasx <adil.business4064@gmail.com>
Co-authored-by: Adil Shaikh <106678504+whoisasx@users.noreply.github.com>
2026-05-18 21:04:25 +05:30
..
bun-tmp-janitor.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
daemon.test.ts fix(cli): reap daemon children on stop+SIGINT, sweep orphans on start (closes #1848) (#1849) 2026-05-15 03:38:09 +05:30
dashboard-rebuild.test.ts fix: clear stale Next.js cache on version upgrade (#1022) 2026-05-01 12:23:51 +05:30
detect-env.test.ts refactor(cli): extract shared repo helpers and support GitLab subgroups 2026-04-15 12:30:32 +05:30
format.test.ts feat: implement CLI with all commands (init, status, spawn, session, send, review-check, dashboard, open) (#6) 2026-02-14 16:14:27 +05:30
lifecycle-service.test.ts fix(cli): supervise lifecycle workers for active projects (#1600) 2026-05-01 15:45:06 +05:30
openclaw-probe.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
path-equality.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
plugins.test.ts feat(plugin): implement kimicode agent plugin (#1390) 2026-05-01 14:11:30 +05:30
preflight.test.ts refactor(spawn): plugin-owned preflight + collapse project resolution (#1622) 2026-05-04 14:03:26 +05:30
prevent-sleep.test.ts fix(power): address PR review feedback for sleep prevention 2026-04-11 21:06:32 +05:30
project-resolution.test.ts fix: detect nested project directories in CLI auto-resolution 2026-04-01 18:28:57 +05:30
project-supervisor.test.ts fix(cli): fall back to local config when global config is missing in project supervisor (#1809) 2026-05-18 19:19:39 +05:30
repo-validation.test.ts refactor(cli): extract shared repo helpers and support GitLab subgroups 2026-04-15 12:30:32 +05:30
resolve-project-instrumentation.test.ts feat(cli): wire activity events into CLI commands and supervisor lifecycle (#1698) 2026-05-18 21:04:25 +05:30
running-state.test.ts fix: tighten startup lock cleanup 2026-04-20 13:30:07 +05:30
script-runner.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
session-utils.test.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
shell.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
shutdown.test.ts feat(cli): wire activity events into CLI commands and supervisor lifecycle (#1698) 2026-05-18 21:04:25 +05:30
startup-preflight.test.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
update-channel-onboarding.test.ts fix(cli): first-run startup creates global config with project registered (#1766) (#1819) 2026-05-13 03:28:50 +05:30
update-check.test.ts feat(release): weekly release train — channels, onboarding, dashboard banner, cron (#1781) 2026-05-12 23:11:09 +05:30