feat: token management commands + login UX cleanup#32
Merged
Conversation
## Summary - New `linq tokens *` command group (list/create/rename/regenerate/delete) for managing API tokens from the CLI. Mirrors the web's API Tooling page. - Reverts `linq login` to token-paste flow (drops the email-OTP login that shipped 6 days ago in v2.0.0). Signup OTP flow unchanged. - `linq init` now resolves orgId/tier/tenantType from the new `/cli/account-info` endpoint so contacts/whoami work for users who paste a token instead of going through signup. - `linq whoami` masks the token to its prefix (show-once UX). - `linq signup` bounces existing users to `linq login` and shows the new token with a "save this securely" warning. ## Detail ### `linq tokens *` - `tokens list` — `GET /v3/api-tokens`, table output with `← active` marker for the currently-stored token (matched by prefix), `--json` supported - `tokens create` — `POST /v3/api-tokens`. Bare invocation runs an interactive wizard (name + expiration preset/custom/never). With any flag, non-interactive; defaults to no expiry. - `tokens rename <id> --name X` — `PUT /v3/api-tokens/:id` - `tokens regenerate <id> [--expires-in 30d]` — mints new secret, expires the old. If the regenerated token is the currently-active one, the new secret is auto-saved to the local profile. - `tokens delete <id>` — interactive-only (refuses with CI/CLAUDECODE/ CURSOR_TRACE_ID/AIDER_API_KEY env or no TTY). Hard-refuses deleting the currently-active token. "Type yes to confirm" prompt. ### Login / init / whoami / signup - `login` accepts `--token` or interactive paste. Validates via `phoneNumbers.list()`. Pulls full account bag from `/cli/account-info` and saves the same profile shape signup produces. - `init` similarly pulls account-info; falls back to its phones list when synapse returns 0 (shared-line users have api_partner_id=NULL on phones). - `whoami` shows token as `linq_xxxxxxxx...` in pretty + `--json`. - `signup` early-returns with a "use linq login" message when the email already has an account (instead of returning the stale rolodeq token). ## Compatibility Drops `--email` from `linq login` (email-OTP login flow). The flag is 6 days old with effectively zero adoption, so this is feat: rather than feat!: — bumps 2.0.2 → 2.1.0 instead of 3.0.0. ## Tests - 31 new tests covering all 5 tokens commands + the helpers - Updated `login.test.ts` and `init.test.ts` for the new flow - Full suite: 172 passing (was 141)
- `tokens delete` error now spells out the detection: "Detected running in a script, CI, or by an AI assistant." - README drops the implementation-detail line about config file location and the misleading "Get a token from the dashboard" — tokens are show-once, not retrievable.
login.ts and init.ts now pull partnerId from the /cli/account-info response (already returned by zero-service) instead of making a separate call to webhook.linqapp.com/partner-id. auth-flow.ts now reads partnerId from the /cli/signup response (added server-side) and saves it to the profile — previously signup users had no partnerId saved, so telemetry events were missing the partner_id tag. lib/partner.ts deleted — no longer referenced.
abhiramkast
force-pushed
the
feat/cli-token-management
branch
from
May 21, 2026 16:17
dad05e9 to
dbfe164
Compare
Collaborator
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
linq loginshipped 6 days ago using email-OTP; doesn't work with the new show-once tokens in future(PNS-issued tokens aren't recoverable from rolodeq).Solution
linq tokens *— new command group (list/create/rename/regenerate/delete) backed by/v3/api-tokens.createruns as wizard when bare;deleteis interactive-only and hard-refuses the active token;regenerateauto-updates the local profile if rotating the active token.linq login— reverted to token-paste (drops--email). Pulls account info from the new/cli/account-infoendpoint so the saved profile matches what signup produces.172 tests passing (31 new).