Skip to content

refactor(cli): convert stats command to effectCmd#25474

Merged
kitlangton merged 1 commit intodevfrom
kit/cli-effectify-stats
May 2, 2026
Merged

refactor(cli): convert stats command to effectCmd#25474
kitlangton merged 1 commit intodevfrom
kit/cli-effectify-stats

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Convert `cli/cmd/stats.ts` from `cmd()` + `bootstrap()` to `effectCmd` + `Effect.ensuring(store.dispose(ctx))`.
  • `aggregateSessionStats` previously read `Instance.project` from ALS via a `getCurrentProject()` helper (deleted). Now takes `currentProject` as an explicit third parameter — the handler passes `ctx.project`.

Behavioral notes

  • Subagent purity audit: PURE for the only caller.
  • `aggregateSessionStats` is exported but has no other callers in the repo. The new throw `"currentProject required when projectFilter is empty string"` is unreachable in practice (StatsCommand always passes ctx.project). Defensive scaffolding only.
  • Disposal coverage strictly improves (Effect.ensuring covers interruption; legacy try/finally didn't).

Test plan

  • `bun run typecheck`
  • `bun run test test/cli/` — 137 pass
  • `stats --days 30` runs and prints a valid table

bootstrap() → effectCmd + Effect.ensuring(store.dispose(ctx)). The
aggregateSessionStats helper now takes the current project as an
explicit parameter (was reading Instance.project from ALS, which the
effectCmd handler doesn't bind). Other call sites of the helper pass
undefined for currentProject — which matches existing behavior since the
ALS-read only fired when projectFilter was the empty string.
@kitlangton kitlangton merged commit c1686c6 into dev May 2, 2026
13 checks passed
@kitlangton kitlangton deleted the kit/cli-effectify-stats branch May 2, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant