Repository navigation
Description
Summary
The -dev pre-release CLI is currently hard-pinned to the dev backend at runtime, regardless of any per-account apiUrl stored in ~/.config/nemar/config.json. This is the right default (safety: dev builds shouldn't accidentally hit prod), but it leaves no opt-in path for users who knowingly want to test a dev CLI feature against production data.
Proposal: let an account stored under `nemar auth` opt into pointing a dev build at `api.nemar.org` (or another whitelisted prod URL), with explicit warnings and at the user's own risk.
Current behavior
`src/lib/api.ts:60-68`:
```ts
function getApiUrl(): string {
if (process.env.TEST_API_URL) return process.env.TEST_API_URL;
if (IS_DEV_BUILD) return DEFAULT_API_URL; // dev build always uses dev backend
const config = getConfig();
return config.apiUrl || DEFAULT_API_URL;
}
```
`IS_DEV_BUILD` is true when the compiled-in `DEFAULT_API_URL` points at a `*.workers.dev` host. Stored `apiUrl` is silently ignored.
Use cases
- A user wants to validate a new dev-CLI flow (e.g. `dataset download`, `dataset get`) against a real production dataset that doesn't exist in dev D1.
- A power user wants bleeding-edge client features but is comfortable that the dev CLI may fail or be incomplete.
- Internal QA wants to dry-run a soon-to-ship CLI against prod before cutting the patch.
Proposed UX
Opt-in is per account, scoped under `nemar auth`:
```bash
Opt this account into prod from a dev build
nemar auth set-api-url https://api.nemar.org --allow-prod-on-dev
Or interactively:
nemar auth login --api-url https://api.nemar.org # prompts:
You are running a -dev build of nemar-cli. Pointing it at the
production backend (api.nemar.org) is opt-in and at your own risk:
- dev features may not exist on prod and will fail
- dev features may have different schemas than prod expects
- this account will not be auto-migrated when you switch builds
Continue? [y/N]
```
Visible at runtime:
```text
[nemar] dev build pointing at production backend (account: yahya)
[nemar] you opted in via 'auth set-api-url --allow-prod-on-dev'; switch back with 'auth set-api-url --reset'
```
Implementation sketch
- Add a per-account flag (e.g. `allowProdOnDev: boolean`) to the `Account` schema in `src/lib/config.ts`.
- In `src/lib/api.ts` `getApiUrl()`: when `IS_DEV_BUILD` is true, check the active account; if `allowProdOnDev` is set and the stored `apiUrl` is on a whitelist (`api.nemar.org`, the SCCN prod workers.dev host), honor the stored URL. Otherwise fall through to the dev default.
- Print a one-line banner each session when a dev build is hitting prod (similar to `printMaintenanceBanner`).
- New CLI surface:
- `nemar auth set-api-url [--allow-prod-on-dev]`
- `nemar auth set-api-url --reset` (clear back to default)
- `nemar auth login --api-url ` (existing, but on dev build prompt the warning before storing)
- Block the legacy/sunset URLs (already in `LEGACY_API_URLS`) so the opt-in cannot be used to revive them.
Risks / safety
- Schema drift: a dev CLI may send/expect fields that prod doesn't recognize. Failures are user-visible and recoverable; document that dev features may 4xx/5xx on prod.
- Auth tokens: tokens are scoped per-backend, so a prod token in a dev account directory won't accidentally leak to dev. Confirm in implementation that the token store is keyed on `apiUrl` (already true).
- Accidental opt-in: require an explicit `--allow-prod-on-dev` flag and a confirmation prompt; never auto-flip on plain `--api-url`.
- Visibility: every dev-build → prod-backend session logs a banner so the user can't forget the state.
Acceptance
- A user on a `-dev` CLI can run `nemar auth set-api-url https://api.nemar.org --allow-prod-on-dev` and have subsequent commands hit prod for that account only.
- Other accounts on the same machine continue to hit dev (or whatever they're configured for).
- Without the explicit flag, a dev CLI continues to ignore stored `apiUrl` and use the dev backend (current behavior, unchanged).
- A banner prints on every command when the dev build is hitting prod.
- Documented in `docs/getting-started/` and `docs/commands/auth.md` with an "at your own risk" callout.
Out of scope
- Making prod-on-dev the default.
- Cross-account global settings (it's per-account by design).
- Pointing prod builds at dev (already supported via stored `apiUrl` on prod builds; not part of this).
Activity
docs: separate ICA from ICLabel, and name the weights-serving gap
Add the live map for the in-browser compute epic (#1459)