Skip to content

feat(auth): adopt cli-core 0.12.0 multi-user TokenStore shape#71

Merged
scottlovegrove merged 2 commits into
mainfrom
scottl/cli-core-multi-user
May 15, 2026
Merged

feat(auth): adopt cli-core 0.12.0 multi-user TokenStore shape#71
scottlovegrove merged 2 commits into
mainfrom
scottl/cli-core-multi-user

Conversation

@scottlovegrove
Copy link
Copy Markdown
Contributor

@scottlovegrove scottlovegrove commented May 15, 2026

Summary

  • Bump @doist/cli-core from 0.9.0 → 0.12.0.
  • Reshape OutlineTokenStore to the new uniformly-multi-user TokenStore contract: active(ref?) / clear(ref?) honour the optional AccountRef and route through a shared resolveByRef helper that throws ACCOUNT_NOT_FOUND on mismatch (no more silent null / no-op). list() returns the one stored account flagged as default (or empty), setDefault(ref) validates the ref against the single account.
  • Ref matching: exact id (UUID, case-sensitive) or case-insensitive label.
  • Register ACCOUNT_NOT_FOUND in the local ErrorCode union.
  • Add ref-aware coverage in src/__tests__/auth-provider.test.ts (10 new tests).

Storage backend stays single-slot — this is contract compliance so the upstream --user <ref> flag attached by attachLogoutCommand / attachStatusCommand / attachTokenViewCommand (when wired) lands cleanly. Multi-account storage is a future PR. Mirrors the equivalent change landing in twist-cli (#225).

Test plan

  • npm run type-check
  • npm run build
  • npm test — 126 / 126 pass
  • npm run lint:check
  • npm run check:skill-sync
  • Manual: ol auth login / status / logout still work against an existing token
  • Manual: a future --user <ref> plumbed through active(ref) / clear(ref) matches an exact id or case-insensitive label; mismatched ref throws ACCOUNT_NOT_FOUND

🤖 Generated with Claude Code

Bump @doist/cli-core to 0.12.0 and reshape OutlineTokenStore to the new
uniformly-multi-user TokenStore contract:

- `active(ref?)` / `clear(ref?)` honour the optional AccountRef. With a
  ref, ref-mismatch throws `ACCOUNT_NOT_FOUND` (via a shared
  `resolveByRef` helper) instead of silently returning null / no-op-ing,
  so `auth status --user <other>` / `auth logout --user <other>` will
  surface a real error rather than the misleading "Not authenticated" /
  silent ✓ Logged out.
- New `list()` returns the single stored account flagged as default;
  empty array when nothing is stored.
- New `setDefault(ref)` validates the ref against the stored account.

Ref matching: exact id (UUID, case-sensitive) or case-insensitive label.
Registers `ACCOUNT_NOT_FOUND` in the local `ErrorCode` union and adds
ref-aware coverage in `src/__tests__/auth-provider.test.ts`.

Storage backend stays single-slot — this is contract compliance so the
upstream `--user <ref>` flag attached by `attachLogoutCommand` /
`attachStatusCommand` / `attachTokenViewCommand` (when wired) lands
cleanly. Multi-account storage is a future PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR smoothly updates the authentication provider to adopt the new multi-user TokenStore contract from @doist/cli-core 0.12.0. The implementation correctly wires up reference resolution and error handling, laying a solid foundation for future multi-account support. A few minor adjustments are suggested to optimize disk reads during token clearing, expand test coverage for empty-store scenarios, and deduplicate test fixtures.

Share FeedbackReview Logs

Comment thread src/__tests__/auth-provider.test.ts Outdated
Comment thread src/lib/auth-provider.ts Outdated
Comment thread src/__tests__/auth-provider.test.ts
Address PR review:

- P2 perf: `clear(ref)` was reading the config file twice (once via
  `resolveByRef` then again via `clearConfig`). Replace `resolveByRef`
  with an inline `deriveSnapshot(config)` pure function used by every
  ref-aware path (`active(ref)` / `clear(ref)` / `list()` /
  `setDefault(ref)`) and let `clearConfig` accept an optional
  pre-loaded config so ref-based logout stays at 1 read + 1 write.
- P2 test gap: add `clear(ref)` with no stored config — guards against
  a regression to the old silent no-op when the store is empty, which
  would let `attachLogoutCommand` emit ✓ Logged out for a ref that
  never had any backing account.
- P3 fixtures: drop the duplicate `STORED_ACCOUNT` / `STORED_CONFIG`
  fixtures and reuse the existing `sampleAccount` + a derived
  `sampleConfig` so future account-shape changes live in one place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove requested review from a team and engfragui and removed request for a team May 15, 2026 15:32
@scottlovegrove scottlovegrove self-assigned this May 15, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label May 15, 2026
@scottlovegrove scottlovegrove merged commit 53487b7 into main May 15, 2026
6 checks passed
@scottlovegrove scottlovegrove deleted the scottl/cli-core-multi-user branch May 15, 2026 15:33
doist-release-bot Bot added a commit that referenced this pull request May 15, 2026
## [1.6.0](v1.5.3...v1.6.0) (2026-05-15)

### Features

* **auth:** adopt cli-core 0.12.0 multi-user TokenStore shape ([#71](#71)) ([53487b7](53487b7))
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants