---
title: "Tasks: ALKS CLI Basic Auth Removal"
plan_source: spec-driven/alks-cli-basic-auth-removal/plan.md
plan_hash: sha256:8e5fe412f180d07248fa61c7530df47ffa21f5e2d944c96bced93bdc430b8239
spec_source: spec-driven/alks-cli-basic-auth-removal/spec.md
spec_hash: sha256:0328ec19413e92f93dc8c534dc72576b8722e7bf5d8565ca3b250c81f016f5b3
status: final
version: 1.0
date: 2026-07-19
total_tasks: 12
total_bundles: 4
bundle_mode: sequential
validation: subagent
---

# Tasks: ALKS CLI Basic Auth Removal

> Plan: spec-driven/alks-cli-basic-auth-removal/plan.md | Spec: spec-driven/alks-cli-basic-auth-removal/spec.md | Generated: 2026-07-19 | Status: Final

> Do not edit this document. Track completion in spec-driven/alks-cli-basic-auth-removal/progress.md, not here.

> Execute bundles in order. Each bundle depends on the previous one completing.

## Traceability

| FR | AC | STEP | Tasks |
|----|----|------|-------|
| FR-1 | AC-1.1 | STEP-2 | TASK-2 |
| FR-1 | AC-1.2 | STEP-10 | TASK-10 |
| FR-1 | AC-1.3 | STEP-3, STEP-12 | TASK-3, TASK-12 |
| FR-2 | AC-2.1, AC-2.2 | STEP-1 | TASK-1 |
| FR-3 | AC-3.1 | STEP-4 | TASK-4 |
| FR-3 | AC-3.2, AC-3.3, AC-3.4 | STEP-5 | TASK-5 |
| FR-4 | AC-4.1 | STEP-6 | TASK-6 |
| FR-4 | AC-4.2, AC-4.3 | STEP-7 | TASK-7 |
| FR-5 | AC-5.1 | STEP-7 | TASK-7 |
| FR-5 | AC-5.2, AC-5.3, AC-5.5 | STEP-9 | TASK-9 |
| FR-5 | AC-5.4 | STEP-8 | TASK-8 |
| FR-5 | AC-5.5 | STEP-12 | TASK-12 |
| FR-6 | AC-6.1, AC-6.2 | STEP-3 | TASK-3 |
| FR-7 | AC-7.1 | STEP-11 | TASK-11 |
| FR-7 | AC-7.2 | STEP-12 | TASK-12 |

---

## Bundle 1: Foundation (Walking Skeleton — token-only type core)
> Phase: Foundation | Parallel: no | Files: src/lib/getAuth.ts, src/lib/getAlks.ts, src/model/auth.ts, src/lib/getKeys.ts, src/lib/addKey.ts, src/lib/isTokenAuth.ts, src/lib/getIamKey.test.ts, src/lib/getAuth.test.ts

### TASK-1: `getAuth` throws a directed error when no token exists
[STEP-1 → FR-2, AC-2.1, AC-2.2] | modify `src/lib/getAuth.ts` | Effort: S

> **Intent**: The behavioral heart of the removal — when no refresh token exists the CLI must stop silently falling back to basic auth and fail with actionable guidance. Removing the fallback (the only code that builds `{ userid, password }`) is what makes the union collapse in TASK-3 safe.

- Remove the basic-auth fallback (lines 19-45) and the one-time deprecation banner; drop imports `promptForPassword`, `getPassword`, `getUserId`
- When `getToken()` yields no token, `throw` an error directing the user to run `alks developer login2fa` or `alks developer configure`
- Leave the existing valid-token path untouched: when a token exists, still return `{ token }` (AC-2.2)
- Write tests in `src/lib/getAuth.test.ts` (create; follow the mock pattern from `src/lib/handlers/alks-developer-configure.test.ts`): no token → throws with the directed `login2fa`/`configure` message (AC-2.1); valid token → returns `{ token }` (AC-2.2)
- **Verify**: `npx jest src/lib/getAuth` passes (no-token case throws the directed error; token case returns `{ token }`); `npx tsc --noEmit` clean

> Depends on: — | Enables: TASK-3 | Parallel with: TASK-2

### TASK-2: `getAlks` accepts token props only
[STEP-2 → FR-1, AC-1.1] | modify `src/lib/getAlks.ts` | Effort: S

> **Intent**: Removes the second and last consumer of password auth — the `else` branch that casts `userid/password` into `AlksProps`. After this, nothing consumes `PasswordAuth`, unblocking the union collapse.

- Remove `PasswordProps` and the basic `else` branch (lines 84-91); set `Props = TokenProps`
- Keep the token flow intact: `create()` + `getAccessToken({ refreshToken })` → recreate with `accessToken`
- Write/adjust tests for `getAlks` (create `src/lib/getAlks.test.ts` if none): builds a client from token props; no path accepts `userid`/`password` (AC-1.1)
- **Verify**: `npx jest src/lib/getAlks` passes (client built from token props); `npx tsc --noEmit` clean

> Depends on: — | Enables: TASK-3 | Parallel with: TASK-1

### TASK-3: Collapse the `Auth` union, fix the cache-key landmine, delete `isTokenAuth`
[STEP-3 → FR-1, AC-1.3 | FR-6, AC-6.1, AC-6.2] | modify `src/model/auth.ts`, `src/lib/getKeys.ts`, `src/lib/addKey.ts`; delete `src/lib/isTokenAuth.ts` | Effort: M

> **Intent**: The landmine — `enc = isTokenAuth(auth) ? auth.token : auth.password` at `getKeys.ts:16`/`addKey.ts:17` is on the token path. The replacement **must stay `auth.token`** so the LokiDB cache key does not change and existing token sessions keep decrypting (NFR-3). Kept atomic: collapsing the union makes `auth.password` a type error at exactly these two sites, so model change + landmine fix land together.

- In `src/model/auth.ts`: remove `PasswordAuth`; `Auth` becomes `TokenAuth`
- In `src/lib/getKeys.ts` (:16) and `src/lib/addKey.ts` (:17): change the ternary to `enc = auth.token`; drop the `isTokenAuth` import at `getKeys.ts:4` / `addKey.ts:4`
- Delete `src/lib/isTokenAuth.ts`
- Extend the `{ token }` fixture in `src/lib/getIamKey.test.ts` with a regression assertion: `getKeys`/`addKey` derive `enc = auth.token` and the cache encrypts/decrypts stably under a token session (AC-6.1)
- **Verify**: `npx jest src/lib/getIamKey` passes (stable-key regression); `npx tsc --noEmit` clean project-wide; `grep -rn "isTokenAuth" src` returns nothing (AC-6.2)

> Depends on: TASK-1, TASK-2 | Enables: TASK-8, TASK-9 | Parallel with: —

---

## Bundle 2: Command & Configure Surface
> Phase: Command & Configure Surface | Parallel: no | Files: src/lib/promptForAuthType.ts, src/lib/handlers/alks-developer-configure.ts, src/lib/handlers/alks-developer-configure.test.ts, src/lib/handlers/alks-developer-login.ts, src/lib/program.ts, src/lib/handlers/alks-developer-logout.ts, src/lib/handlers/alks-developer-info.ts

### TASK-4: Remove basic-auth choices from the auth-type picker
[STEP-4 → FR-3, AC-3.1] | modify `src/lib/promptForAuthType.ts` | Effort: S

> **Intent**: The picker is the single source of the auth-type choice list; removing the two basic entries (and their constants, which `configure`'s switch references) is what makes `configure` offer only token options.

- Remove the `PASSWORD_AUTH_CHOICE` and `ALWAYS_ASK_AUTH_CHOICE` constants and their choices-list entries; keep `REFRESH_TOKEN_AUTH_CHOICE` and `CREDENTIAL_PROCESS_AUTH_CHOICE`
- Write/adjust a test (create `src/lib/promptForAuthType.test.ts` if none) asserting exactly two choices are offered: `refresh-token`, `credential-process` (AC-3.1)
- **Verify**: `npx jest src/lib/promptForAuthType` passes (choice list is exactly the two token types); `npx tsc --noEmit` clean

> Depends on: — | Enables: TASK-5 | Parallel with: TASK-6, TASK-8

### TASK-5: Strip password/always-ask cases from `configure`; reject removed `-A` values
[STEP-5 → FR-3, AC-3.2, AC-3.3, AC-3.4] | modify `src/lib/handlers/alks-developer-configure.ts` | Effort: M

> **Intent**: `configure` is where a user picks an auth type; it must no longer branch into password or always-ask, and a removed value passed via `-A/--auth-type` must error clearly (listing remaining choices) rather than no-op or prompt for a password (NFR-2).

- Remove the `PASSWORD_AUTH_CHOICE` case (lines 61-72) and the `ALWAYS_ASK_AUTH_CHOICE` case (lines 79-82); drop imports `promptForPassword`, `promptForUserId`, `setUserId`, `setPassword`
- Ensure the switch default/unmatched path errors on a removed/invalid `-A` value, reporting it is not valid and listing the remaining choices (AC-3.3); keep `-A` handling for the two valid types (AC-3.2)
- Update `src/lib/handlers/alks-developer-configure.test.ts`: strip password/username/always-ask cases and their mocks (`promptForPassword`, `promptForUserId`, `state/userId`, `state/password`); keep refresh-token + credential-process; add an invalid-`-A` rejection test (AC-3.3)
- **Verify**: `npx jest src/lib/handlers/alks-developer-configure` passes (only the two token types configure successfully; a `password` value for `-A` is rejected); `npx tsc --noEmit` clean

> Depends on: TASK-4 | Enables: TASK-9 | Parallel with: —

### TASK-6: Convert `developer login` to a directed error stub
[STEP-6 → FR-4, AC-4.1] | modify `src/lib/handlers/alks-developer-login.ts` | Effort: S

> **Intent**: The command stays wired but its handler becomes an error pointing to `login2fa` — giving muscle-memory users and scripts a directed message instead of "unknown command" (AD-1, NFR-2). It also removes the last password-storing handler, a prerequisite for deleting the password helpers.

- Replace the basic-auth handler body (banner, `promptForUserId`→`setUserId`, `promptForPassword`→`setPassword`) with a `throw` of a directed error: "Basic auth has been removed; run `alks developer login2fa`"
- Remove imports of `promptForUserId`, `setUserId`, `promptForPassword`, `setPassword`
- Write a test (create `src/lib/handlers/alks-developer-login.test.ts`): the handler throws the directed error and performs no password/userId writes (AC-4.1)
- **Verify**: `npx jest src/lib/handlers/alks-developer-login` passes (handler throws the directed error, no `setPassword`/`setUserId` calls); `npx tsc --noEmit` clean

> Depends on: — | Enables: TASK-7, TASK-9 | Parallel with: TASK-4, TASK-8

### TASK-7: Remove `logout`, login/logout wiring, and auth password/username flags from `program.ts`
[STEP-7 → FR-4, AC-4.2, AC-4.3 | FR-5, AC-5.1] | modify `src/lib/program.ts`; delete `src/lib/handlers/alks-developer-logout.ts` | Effort: M

> **Intent**: `program.ts` is the commander wiring; this removes the password-only `logout` command entirely (2FA twin `logout2fa` remains) and strips the auth `-p/--password` and `-u/--username` inputs so no removed credential can be supplied on the CLI. `login` stays wired to the TASK-6 error stub; `-A/--auth-type` is explicitly retained.

- Delete `src/lib/handlers/alks-developer-logout.ts`
- In `src/lib/program.ts`: remove the `developer logout` command wiring (lines 434-437) and its handler import; keep `developer login` wired to the (now error-stub) handler; leave `login2fa`/`logout2fa` untouched (AC-4.3)
- Remove the auth `-p/--password` options (lines 126, 149, 172, 470) and the `-u/--username` option on `configure` (lines 384-386); keep `-A/--auth-type` (lines 388-391)
- **Verify**: `npx tsc --noEmit` clean; `grep -nE "developer-logout|logout\b|--password|--username" src/lib/program.ts` shows no `logout` command wiring, no logout handler import, and no auth `--password`/`--username` flags remain (AC-4.2, AC-5.1)

> Depends on: TASK-6 | Enables: TASK-9 | Parallel with: —

### TASK-8: Remove password/userid rows from `developer info`
[STEP-8 → FR-5, AC-5.4] | modify `src/lib/handlers/alks-developer-info.ts` | Effort: S

> **Intent**: `developer info` prints a diagnostic table; it must stop reading `getPassword` (a prerequisite for deleting `state/password.ts`) and stop showing the meaningless Password and Network Login/userid rows, while keeping server/account/role/output and the 2FA-token row.

- Remove the `getPassword` import and call, and the "Password" table row
- Remove the orphaned `userid` / "Network Login" row; keep server, account, role, output, and the 2FA-token rows
- Write/update a test (create `src/lib/handlers/alks-developer-info.test.ts` if none; follow the mock pattern from `alks-developer-configure.test.ts`) that invokes the handler and asserts the rendered table has no Password or Network Login rows and still includes the 2FA-token row (AC-5.4)
- **Verify**: `npx jest src/lib/handlers/alks-developer-info` passes (rendered output omits Password/Network Login rows, retains the token row — AC-5.4); `grep -nE "getPassword|Password|Network Login" src/lib/handlers/alks-developer-info.ts` returns none; `npx tsc --noEmit` clean

> Depends on: TASK-3 | Enables: TASK-9 | Parallel with: TASK-4, TASK-6

---

## Bundle 3: Delete Helper Surface & Residual Type Fields
> Phase: Delete Helper Surface & Residual Type Fields | Parallel: no | Files: src/lib/state/password.ts, src/lib/state/userId.ts, src/lib/storePassword.ts, src/lib/getPasswordFromKeystore.ts, src/lib/removePassword.ts, src/lib/promptForPassword.ts, src/lib/promptForUserId.ts, src/lib/getUserIdFromPrompt.ts, src/lib/getCredentialsFromProcess.ts, src/lib/state/credentials.ts, src/model/developer.ts, src/lib/state/developer.test.ts, src/lib/convertNetrcToIni.ts, src/lib/ensureConfigured.ts

### TASK-9: Delete the password/userId helper files
[STEP-9 → FR-5, AC-5.2, AC-5.3, AC-5.5] | delete `src/lib/state/password.ts`, `src/lib/state/userId.ts`, `src/lib/storePassword.ts`, `src/lib/getPasswordFromKeystore.ts`, `src/lib/removePassword.ts`, `src/lib/promptForPassword.ts`, `src/lib/promptForUserId.ts`, `src/lib/getUserIdFromPrompt.ts` | Effort: M

> **Intent**: These eight files are the basic-auth helper surface; their only consumers are the code removed in TASK-1/5/6/8, so they are now safe to delete. The trap: **do NOT delete `getPasswordFromPrompt.ts`** — despite the name it is a generic masked-input widget still imported by `promptForToken.ts` (the token flow), confirmed as its surviving importer once `promptForPassword.ts` is gone.

- Delete the eight files listed in the header (keytar `alkspassword` store/get/remove, userId state, password/userId prompts, the already-orphaned `getUserIdFromPrompt.ts`)
- Delete any co-located `.test.ts` files for the deleted helpers
- Preserve `src/lib/getPasswordFromPrompt.ts` (AC-5.3)
- **Verify**: `test -f src/lib/getPasswordFromPrompt.ts` (kept); `npx tsc --noEmit` clean (no dangling imports); `grep -rn "state/password\|state/userId\|storePassword\|getPasswordFromKeystore\|removePassword\|promptForPassword\|promptForUserId\|getUserIdFromPrompt" src` returns no references to the deleted modules (AC-5.2, AC-5.5)

> Depends on: TASK-3, TASK-5, TASK-6, TASK-7, TASK-8 | Enables: TASK-10 | Parallel with: —

### TASK-10: Remove residual `password?` type fields
[STEP-10 → FR-1, AC-1.2] | modify `src/lib/getCredentialsFromProcess.ts`, `src/lib/state/credentials.ts`, `src/model/developer.ts` | Effort: S

> **Intent**: With `state/password.ts` gone (the only reader of `credential_process.password`), the `password?` fields are dead. Removing `password?` from `CredentialProcessResult` makes the contract token-only — a `credential_process` emitting a password is no longer honored (AC-1.2, AD-3). Ordered after TASK-9 so removing the field cannot break the now-deleted reader.

- In `src/lib/getCredentialsFromProcess.ts`: remove `password?` from `CredentialProcessResult` (leaving `refresh_token?`)
- In `src/lib/state/credentials.ts` and `src/model/developer.ts`: drop the `password` field; keep `refresh_token` / `credential_process`
- Update `src/lib/state/developer.test.ts` as the password/userid fields are removed
- **Verify**: `npx jest src/lib/state/developer` passes; `grep -rn "password" src/lib/getCredentialsFromProcess.ts src/model/developer.ts` shows no `password` field remains (AC-1.2); `npx tsc --noEmit` clean

> Depends on: TASK-9 | Enables: TASK-11 | Parallel with: —

### TASK-11: Drop the legacy `.netrc` password-migration branch
[STEP-11 → FR-7, AC-7.1] | modify `src/lib/convertNetrcToIni.ts` | Effort: S

> **Intent**: Legacy cleanup — the `.netrc` importer should no longer migrate an `alkscli` password while keeping the `alksclitoken` token migration. Per Open Question 3, the pre-existing line-43 bug (updates the wrong netrc key) is deferred, not fixed here — leave a comment so it is not silently changed mid-refactor.

- In `src/lib/convertNetrcToIni.ts`: remove the password-migration branch (lines 30-36); keep the token migration (lines 38-44); add a comment flagging the pre-existing line-43 bug as out of scope
- Optional: in `src/lib/ensureConfigured.ts`, tidy the `developer.userid` "configured?" guard and its `ALKS_USERID` error text now that userId state is gone
- Update the `convertNetrcToIni` test if present: a legacy `alkscli` password is not migrated; `alksclitoken` token migration still works (AC-7.1)
- **Verify**: `npx jest src/lib/convertNetrcToIni` passes if a test exists (password not migrated, token migration intact); otherwise `npx tsc --noEmit` clean and `grep -n "alkscli\b" src/lib/convertNetrcToIni.ts` shows the password branch removed (AC-7.1); `grep -niE "line[ -]?43|pre-existing|out of scope" src/lib/convertNetrcToIni.ts` confirms the deferred line-43-bug comment is present

> Depends on: TASK-10 | Enables: TASK-12 | Parallel with: —

---

## Bundle 4: Verification & Release Hygiene
> Phase: Verification | Parallel: no | Files: changelog.txt, package.json

### TASK-12: Full build, test, grep sweep, and release hygiene
[STEP-12 → FR-1, AC-1.3 | FR-5, AC-5.5 | FR-7, AC-7.2] | modify `changelog.txt`, `package.json` | Effort: S

> **Intent**: The final gate proves the removal is complete and consistent: build and full suite green (NFR-3), no removed symbol lingers anywhere (NFR-1), and the release signals the breaking change as a major semver bump with a changelog entry (NFR-2).

> **Standards**: Update `changelog.txt` before opening a PR (CLAUDE.md).

- Add a `changelog.txt` entry describing the basic-auth removal and enumerating every removed input (`ALKS_PASSWORD`, `-p/--password`, `-u/--username`, `developer login`/`logout`, `credential_process` password); set `package.json` version to a major bump (AC-7.2 — pending Open Question 1)
- Run the full build and suite; confirm zero regressions for token + credential-process flows
- Run the grep sweep for removed symbols
- **Verify**: `npm run build` completes (tsc clean); `CI=true npx jest` passes with no failures; `grep -rn "PASSWORD_AUTH_CHOICE\|ALWAYS_ASK_AUTH_CHOICE\|promptForPassword\|setPassword\|getPassword\|ALKS_PASSWORD\|isTokenAuth" src` returns no matches and `grep -n -- "--password" src/lib/program.ts` shows no auth password flag (AC-5.5); `git diff HEAD~1 -- package.json | grep '"version"'` shows the major-version increment and `changelog.txt` contains a new entry referencing the basic-auth removal (AC-7.2)

> Depends on: TASK-11 | Enables: — | Parallel with: —

---

## Conflict Analysis

> Note: Covers explicitly declared file paths only. Implicit touches (barrel files, shared configs, type re-exports, route registration) may require manual sequencing during execution.

No file is created or modified by tasks in more than one bundle — each declared file path is owned by a single task, and cross-bundle ordering is enforced by dependencies rather than shared-file contention.

| Hot File | Touched By | Strategy |
|----------|------------|----------|
| (none) | — | Each file is owned by exactly one task; deletion ordering (TASK-9) is handled by dependencies on the tasks that remove its importers (TASK-1, TASK-5, TASK-6, TASK-8) |

**Implicit-touch notes** (not declared file paths — verify during execution):
- `src/lib/program.ts` imports many handlers; deleting `alks-developer-logout.ts` (TASK-7) requires its import there to be removed in the same task — already covered.
- The eight helpers deleted in TASK-9 are imported across `getAuth.ts`, `alks-developer-configure.ts`, `alks-developer-login.ts`, and `alks-developer-info.ts`; those import removals (TASK-1, TASK-5, TASK-6, TASK-8) must all complete before TASK-9 — enforced by TASK-9's dependencies.
- `package.json` is touched only by TASK-12 (version bump); no other task modifies it.

---

## Architecture Decisions

See: spec-driven/alks-cli-basic-auth-removal/plan.md § Architecture Decisions

---

## Effort Legend

| Size | Guideline |
|------|-----------|
| XS | < 1 hour: trivial change, single function/config |
| S | 1-4 hours: small feature, single file |
| M | 4-8 hours: moderate feature, 2-3 files |
| L | 1-3 days: significant feature, multiple files |
| XL | 3+ days: complex feature — should be split |
