Skip to content

feat: token management commands + login UX cleanup#32

Merged
abhiramkast merged 4 commits into
mainfrom
feat/cli-token-management
May 21, 2026
Merged

feat: token management commands + login UX cleanup#32
abhiramkast merged 4 commits into
mainfrom
feat/cli-token-management

Conversation

@abhiramkast

@abhiramkast abhiramkast commented May 21, 2026

Copy link
Copy Markdown
Contributor

Problem

  • linq login shipped 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).
  • No way to manage API tokens from the CLI — partners had to go to the web dashboard.

Solution

  • linq tokens * — new command group (list/create/rename/regenerate/delete) backed by /v3/api-tokens. create runs as wizard when bare; delete is interactive-only and hard-refuses the active token; regenerate auto-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-info endpoint so the saved profile matches what signup produces.

172 tests passing (31 new).

## 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)
@abhiramkast
abhiramkast requested a review from jflayhart as a code owner May 21, 2026 04:48
- `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
abhiramkast force-pushed the feat/cli-token-management branch from dad05e9 to dbfe164 Compare May 21, 2026 16:17
@abhiramkast
abhiramkast merged commit 4760f65 into main May 21, 2026
4 checks passed
@abhiramkast
abhiramkast deleted the feat/cli-token-management branch May 21, 2026 16:23
@jflayhart

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants