feat: adopt cli-core 1.4 capabilities - #56
Conversation
|
doistbot
left a comment
There was a problem hiding this comment.
Solid adoption of cli-core 1.4: list commands gain --ids-only output with early conflict validation, and OAuth/token login now expose the shared credential-store policy, with tests and docs kept in sync. Few things worth tightening:
- In
findConversationWithUser, validate output-mode conflicts up front — currently--json --ndjsononly errors after API calls and session loading, so a bad flag combo can trigger requests or surface an unrelated error first. - Skip the workspace-wide unread fetch (and thread decoration) when using
--ids-onlywithout--unreadin the thread list, since that data isn't emitted on this path and the extra request runs on every invocation. - The new
INVALID_CREDENTIAL_STOREerror code isn't registered in theErrorCodeunion insrc/lib/errors.ts— AGENTS.md requires new codes to be added there.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (9)
src/lib/auth-provider.ts:109: New error code
INVALID_CREDENTIAL_STOREshould be added to theErrorCodeunion insrc/lib/errors.ts(under the Auth & permissions category) per the repo's error-code convention. BecauseCliErroraccepts any string, type-check won't catch the omission, so the code only surfaces via grep.src/lib/output.ts:255:
printEmptyis now a thin pass-through to cli-core'sprintEmptyCore— the only thing this wrapper adds is a requiredtypeargument that every call site must still pass (type: 'thread', etc.) and that is immediately discarded viavoid type. Consider dropping the wrapper and callingprintEmptyCore({ options, message })directly from the ~10 command call sites, which removes the dead parameter and keepssrc/lib/output.tsto the helpers that actually add local behavior (formatJson/formatNdjsonessential-field filtering,formatError, etc.).src/commands/auth/index.ts:30: Register the credential-store values with the existing
withUnvalidatedChoiceshelper (and mirror it onauth login). The custom parser preserves validation, but this.option()leavesOption.argChoicesunset, sotdc completioncannot suggestfallback,system, orplaintextafter--credential-store. Build anOptionwith that helper and retainparseCredentialStoreas its argument parser.src/commands/conversation/list.ts:41:
resolveOutputMode(options)is called here only for its side effect (throwing on conflicting flags), and its return value is discarded;renderConversationList(helpers.ts:192) resolves the same options again and actually uses the result. Every other list command doesconst outputMode = resolveOutputMode(options). The intent is fail-fast before the network fetch, which is fine, but a one-line comment would prevent a future reader from deleting this as a no-op or double-validating unnecessarily.src/commands/inbox.ts:123: With --ids-only, the output only needs thread IDs, but by this point the command has already fetched the name of every channel via
client.channels.getChannel(id)to buildchannelMap— wasted API calls unless--channelfiltering is in play. The other ids-only paths in this PR skip their enrichment deliberately (e.g. conversation list assertsgetWorkspaceUsersis not called, unread skipsgetConversation), so inbox is the odd one out. Could emit IDs before the channel-name fetch whenoptions.channelis unset.src/commands/channel/members.ts:15:
resolveChannelRefandgetWorkspaceGroupswere previously fetched in parallel (Promise.all), but the restructure now awaitsresolveChannelReffirst, then runsgetWorkspaceGroupsin parallel withfetchUsersByIds. For the default (non---ids-only) path this serializes two independent API calls and addsresolveChannelRef's latency to the critical path. You can keep the--ids-onlyshort-circuit and still overlap the channel lookup with the groups fetch by startinggetWorkspaceGroupseagerly only when not in ids-only mode, e.g.const groupsPromise = outputMode === 'ids-only' ? undefined : getWorkspaceGroups(workspaceId)before awaiting the channel, thenPromise.all([groupsPromise, fetchUsersByIds(...)]).src/commands/channel/members.ts:18: The
--ids-onlyearly return skipsgetWorkspaceGroupsandfetchUsersByIds, butmembers.test.tshas no test for it. This mirrors theconversation unread --ids-onlytest, which explicitly assertsgetConversation/getWorkspaceUsersare not called — the same reliability guarantee applies here (ids-only should still work when a workspace contains deleted users that would failfetchUsersByIds). Add a test asserting the member IDs are printed and neithergetWorkspaceGroupsnorgetWorkspaceUsersis called.src/commands/channel/threads.ts:122: The pagination notice (
More threads available. Use --cursor …) is a documented user-visible contract (README/SKILL say it goes to stderr), butthreads.test.tshas no--ids-onlytest. A regression that routes this notice to stdout would corrupt the one-ID-per-line stream for scripting. Add a test covering the paginated case and asserting the notice lands on stderr while stdout stays clean.src/commands/auth/auth.test.ts:242: The invalid-value branch of
parseCredentialStore(INVALID_CREDENTIAL_STORE) has no coverage, unlike sibling parse helpers (INVALID_SCOPE, INVALID_STATE, INVALID_DATE) which are all tested.tdc auth login --credential-store=typoandtdc auth token --credential-store=typoare both user-facing paths through this branch. A one-liner next to the plaintext test — asserting parseAsync rejects with code INVALID_CREDENTIAL_STORE — would cover it.
## [3.1.0](v3.0.0...v3.1.0) (2026-08-28) ### Features * adopt cli-core 1.4 capabilities ([#56](#56)) ([441e69c](441e69c))
|
🎉 This PR is included in version 3.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Upgrade
@doist/cli-corefrom 0.26.2 to 1.4.0 and adopt its latest shared capabilities:--ids-onlyto list commands with one clear entity IDExamples
Pipe-friendly ID output
--ids-onlyprints one stable ID per line. Empty results print nothing. It is mutually exclusive with--jsonand--ndjson. Pagination notices go to stderr so stdout stays safe for pipes.Credential storage policies
The default remains
fallbackfor backward compatibility. The three values are also available through shell completion.Upstream cli-core changes