Lines 1-32javascript
2// op0 — ONE CLI (op0.ai). Your account + cloud AND your workbench, one identity, one binary.
3// cloud: login · deploy · connect · whoami · logout
4// workbench: make · list · status · logs · pull · eject · dev · push · wire
5// Identity (D11): `op0 login` runs the device flow and stores the tenant-bound key in
6// $OP0_CONFIG_DIR/config.json (default ~/.op0, 0600). Every command rides that one session.
7// Self-host/CI escape hatch: `op0 login --key <usectx-key>` (most-specific, cord-local, wins).
8// Merged 2026-07-09 from the retired @op0-ai/cord-cli + @op0-ai/op0 — the op0.ai consolidation.
9import { parseArgs, loadConfig, saveConfig, loadSession, CONFIG_PATH, OP0_CONFIG_PATH, collectPushFiles, parseCordId } from "../lib/core.mjs";
10import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
11import { join, resolve } from "node:path";
12import { homedir } from "node:os";
13import { execSync, spawnSync } from "node:child_process";
14import * as p from "@clack/prompts";
15import color from "picocolors";
17// ── the op0 session (the device-flow key lives here; the workbench rides it via loadSession) ──
18const CONSOLE = process.env.OP0_CONSOLE ?? "https://console.op0.ai";
19const FACTORY_DEFAULT = process.env.OP0_FACTORY ?? "https://api.op0.dev";
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
bin/op0.mjsView on unpkg · L12 20const DIR = process.env.OP0_CONFIG_DIR ?? join(homedir(), ".op0");
21const CFG = join(DIR, "config.json");
22const readCfg = () => (existsSync(CFG) ? JSON.parse(readFileSync(CFG, "utf8")) : {});
23const writeCfg = (c) => { mkdirSync(DIR, { recursive: true }); writeFileSync(CFG, JSON.stringify(c, null, 2), { mode: 0o600 }); };
24const bail = (m) => { p.cancel(m); process.exit(1); };
25const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
27// Hosts for the workbench commands ride the active session; api.op0.dev is the live control plane.
28// (Host flips to op0.dev deployment routing are lane 2 — dual-served, so these stay correct today.)
29const session = loadSession();
31 factory: session?.hosts?.factory ?? FACTORY_DEFAULT,
32 evlog: session?.hosts?.evlog ?? "https://evlog.usectx.com",