Skip to content

Commit 4749a07

Browse files
feat: adopt cli-core DCR provider + account command attachers (#5)
* feat(auth): adopt cli-core createDcrProvider for OAuth Replace the bespoke DCR AuthProvider (hand-rolled registration, PKCE authorize, HTTP Basic token exchange) with cli-core's createDcrProvider, driven by oauth4webapi. The only comms-specific piece left is validate, which probes getSessionUser and derives authMode/authScope from the folded handshake.readOnly via a shared getScopes() helper. Use client_secret_post (not the default client_secret_basic): client_ids can contain underscores, which the basic form url-encodes (_ -> %5F) and the token endpoint doesn't decode, breaking the lookup. Bump @doist/cli-core 0.16.1 -> 0.24.0 and add oauth4webapi as a direct dependency. The 0.24.0 TokenStore contract change (clear() -> ClearedAccount | null, required activeAccount/setBundle/activeBundle) is threaded through the store override and test mocks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(account): adopt cli-core account command attachers Replace the hand-rolled account list/use/remove/current commands with cli-core's attachAccount*Command, deleting list.ts/use.ts/remove.ts/ current.ts. The attachers own the command action and JSON envelopes ({accounts,default} for list, {ok,default} for use, {ok,removed} for remove), so comms-specific behaviour moves into their hooks: - current: env-token resolves as null from activeAccount() and renders the env notice via onNotAuthenticated; an identity-less manual-token account (empty id/label, persisted by `tdc auth token`) stays a resolved account and is special-cased in renderText/renderJson as source: token-only. - list: wrapped so manual-token snapshots stay out of the roster. - remove: onRemoved surfaces the keyring-fallback warning on stderr. Add an activeAccount() override to the store (env -> null) mirroring active()/activeBundle(), and forward clear()'s ClearedAccount return through withUserRefAware. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: add CODEBASE.md repo map Descriptive ~2000-token orientation file (matching the cli-core / todoist-cli style) so agents and humans can navigate the repo without exploring. Covers the lazy command registry, command/lib catalogs, ref resolution, the env-token + manual-token auth path, testing, and the skill-content flow. Complements AGENTS.md (prescriptive rules). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(account): guard manual-token refs; dedupe clear-result plumbing Address review feedback on the account-attacher refactor: - matchCommsAccount() now never matches an identity-less manual-token account, so an empty-ish ref (`""`, `id:`) passed to `account use` / `remove` can't target a row that `list` deliberately hides. - Extract the shared `logStoredTokenRemoval` helper (auth/helpers.ts) so `auth logout`'s onCleared and `account remove`'s onRemoved can't drift. - Add tests: manual-token rows hidden from `account list` (human + json), the matchCommsAccount manual-token guard, and the store's activeAccount() env-token short-circuit + delegation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f097378 commit 4749a07

16 files changed

Lines changed: 790 additions & 557 deletions

CODEBASE.md

Lines changed: 289 additions & 0 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@
5050
"CHANGELOG.md"
5151
],
5252
"dependencies": {
53-
"@doist/cli-core": "0.16.1",
53+
"@doist/cli-core": "0.24.0",
5454
"@doist/comms-sdk": "0.2.0",
5555
"@pnpm/tabtab": "0.5.4",
5656
"chalk": "5.6.2",
5757
"commander": "14.0.3",
5858
"marked": "18.0.3",
5959
"marked-terminal-renderer": "2.2.0",
60+
"oauth4webapi": "3.8.6",
6061
"open": "11.0.0"
6162
},
6263
"devDependencies": {

0 commit comments

Comments
 (0)