@lunaroute/cli 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +336 -40
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { Command, InvalidArgumentError, Option } from "commander";
5
5
 
6
6
  // package.json
7
- var version = "0.3.1";
7
+ var version = "0.5.0";
8
8
 
9
9
  // src/login.ts
10
10
  import { createServer } from "http";
@@ -236,6 +236,34 @@ function resolveSettings(name) {
236
236
  };
237
237
  }
238
238
 
239
+ // src/pending.ts
240
+ import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
241
+ import { join as join2 } from "path";
242
+ function pendingPath(profile) {
243
+ const safe = profile.replace(/[^A-Za-z0-9_-]/g, "_");
244
+ return join2(configDir(), `pending-login-${safe}.json`);
245
+ }
246
+ function savePending(profile, p) {
247
+ mkdirSync2(configDir(), { recursive: true, mode: 448 });
248
+ const path = pendingPath(profile);
249
+ writeFileSync2(path, JSON.stringify(p, null, 2), { mode: 384 });
250
+ chmodSync2(path, 384);
251
+ }
252
+ function loadPending(profile) {
253
+ const path = pendingPath(profile);
254
+ if (!existsSync2(path)) return null;
255
+ try {
256
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
257
+ if (!parsed?.verifier || !parsed?.challenge || !parsed?.api_url) return null;
258
+ return parsed;
259
+ } catch {
260
+ return null;
261
+ }
262
+ }
263
+ function clearPending(profile) {
264
+ rmSync(pendingPath(profile), { force: true });
265
+ }
266
+
239
267
  // src/login.ts
240
268
  var LOGIN_TIMEOUT_MS = 3 * 6e4;
241
269
  async function waitWithTimeout(server, ms) {
@@ -324,14 +352,80 @@ async function runLogin(profile) {
324
352
  \u2713 Logged in as ${result.user_email} (org ${result.org_id}).`);
325
353
  console.log(` Routing key saved to profile "${profile}".`);
326
354
  }
355
+ async function runLoginStart(profile) {
356
+ const settings = resolveSettings(profile);
357
+ const state = genState();
358
+ const verifier = genVerifier();
359
+ const challenge = challengeFor(verifier);
360
+ savePending(profile, {
361
+ verifier,
362
+ challenge,
363
+ state,
364
+ api_url: settings.api_url
365
+ });
366
+ const url = `${settings.front_url}/cli-auth?challenge=${challenge}&state=${state}&mode=code`;
367
+ console.log("Open this URL on any device to authorize:\n " + url + "\n");
368
+ console.log("Then paste the code it shows back here with:");
369
+ console.log(" lunaroute login --finish <code>");
370
+ }
371
+ async function runLoginFinish(profile, code) {
372
+ const pending = loadPending(profile);
373
+ if (!pending) {
374
+ throw new Error(
375
+ "no pending login for this profile \u2014 run `lunaroute login --start` first"
376
+ );
377
+ }
378
+ const settings = resolveSettings(profile);
379
+ let result;
380
+ try {
381
+ result = await exchangeCode(pending.api_url, {
382
+ code,
383
+ verifier: pending.verifier,
384
+ label: hostname()
385
+ });
386
+ } catch (err) {
387
+ const msg = err instanceof Error ? err.message : String(err);
388
+ if (/INVALID_CODE|PKCE_MISMATCH/.test(msg)) clearPending(profile);
389
+ throw err;
390
+ }
391
+ saveProfile(profile, {
392
+ api_url: pending.api_url,
393
+ routing_url: settings.routing_url,
394
+ front_url: settings.front_url,
395
+ org_id: result.org_id,
396
+ routing_key: result.full_key,
397
+ user_email: result.user_email
398
+ });
399
+ clearPending(profile);
400
+ console.log(`
401
+ \u2713 Logged in as ${result.user_email} (org ${result.org_id}).`);
402
+ console.log(` Routing key saved to profile "${profile}".`);
403
+ }
327
404
 
328
405
  // src/commands/login.ts
406
+ function report(err) {
407
+ console.error(`Login failed: ${err.message}`);
408
+ process.exitCode = 1;
409
+ }
329
410
  async function login(profile) {
330
411
  try {
331
412
  await runLogin(profile);
332
413
  } catch (err) {
333
- console.error(`Login failed: ${err.message}`);
334
- process.exitCode = 1;
414
+ report(err);
415
+ }
416
+ }
417
+ async function loginStart(profile) {
418
+ try {
419
+ await runLoginStart(profile);
420
+ } catch (err) {
421
+ report(err);
422
+ }
423
+ }
424
+ async function loginFinish(profile, code) {
425
+ try {
426
+ await runLoginFinish(profile, code);
427
+ } catch (err) {
428
+ report(err);
335
429
  }
336
430
  }
337
431
 
@@ -401,17 +495,18 @@ async function fetchModels(routingUrl, key, opts) {
401
495
 
402
496
  // src/setup/apply.ts
403
497
  import {
404
- mkdirSync as mkdirSync2,
405
- readFileSync as readFileSync2,
406
- writeFileSync as writeFileSync2,
498
+ mkdirSync as mkdirSync3,
499
+ readFileSync as readFileSync3,
500
+ writeFileSync as writeFileSync3,
407
501
  copyFileSync,
408
- existsSync as existsSync2,
409
- chmodSync as chmodSync2
502
+ existsSync as existsSync3,
503
+ chmodSync as chmodSync3
410
504
  } from "fs";
411
505
  import { dirname } from "path";
506
+ import { parseDocument } from "yaml";
412
507
  function readExistingJson(path) {
413
- if (!existsSync2(path)) return null;
414
- const raw = readFileSync2(path, "utf8").trim();
508
+ if (!existsSync3(path)) return null;
509
+ const raw = readFileSync3(path, "utf8").trim();
415
510
  if (raw === "") return null;
416
511
  try {
417
512
  return JSON.parse(raw);
@@ -421,11 +516,27 @@ function readExistingJson(path) {
421
516
  );
422
517
  }
423
518
  }
519
+ function resolveYamlContent(fw) {
520
+ const curStr = existsSync3(fw.path) ? readFileSync3(fw.path, "utf8") : null;
521
+ const doc = parseDocument(curStr ?? "", { logLevel: "silent" });
522
+ if (doc.errors.length > 0) {
523
+ const first = doc.errors[0];
524
+ const detail = first ? first.message.split("\n")[0] : "parse error";
525
+ throw new Error(
526
+ `refusing to modify ${fw.path}: it exists but is not valid YAML (${detail}). Fix or remove it, or re-run with --print to copy the config manually.`
527
+ );
528
+ }
529
+ fw.merge(doc);
530
+ let nextStr = String(doc);
531
+ if (!nextStr.endsWith("\n")) nextStr += "\n";
532
+ return { nextStr, curStr };
533
+ }
424
534
  function resolveContent(fw) {
425
535
  if (fw.kind === "text") {
426
- const curStr2 = existsSync2(fw.path) ? readFileSync2(fw.path, "utf8") : null;
536
+ const curStr2 = existsSync3(fw.path) ? readFileSync3(fw.path, "utf8") : null;
427
537
  return { nextStr: fw.content, curStr: curStr2 };
428
538
  }
539
+ if (fw.kind === "yaml") return resolveYamlContent(fw);
429
540
  const existing = readExistingJson(fw.path);
430
541
  const curStr = existing === null ? null : `${JSON.stringify(existing, null, 2)}
431
542
  `;
@@ -449,18 +560,26 @@ ${nextStr}`);
449
560
  summary.backedUp.push(`${fw.path}.bak`);
450
561
  }
451
562
  const dir = dirname(fw.path);
452
- const dirExisted = existsSync2(dir);
453
- mkdirSync2(dir, { recursive: true });
454
- if (!dirExisted) chmodSync2(dir, fw.dirMode ?? 448);
455
- writeFileSync2(fw.path, nextStr, { mode: fw.fileMode ?? 384 });
456
- chmodSync2(fw.path, fw.fileMode ?? 384);
563
+ const dirExisted = existsSync3(dir);
564
+ mkdirSync3(dir, { recursive: true });
565
+ if (!dirExisted) chmodSync3(dir, fw.dirMode ?? 448);
566
+ writeFileSync3(fw.path, nextStr, { mode: fw.fileMode ?? 384 });
567
+ chmodSync3(fw.path, fw.fileMode ?? 384);
457
568
  summary.written.push(fw.path);
458
569
  }
459
570
  if (plan.exports.length > 0) {
460
- console.log("\n# Add these to your shell profile:");
571
+ const printed = plan.exports.filter((e) => !process.env[e.name]);
572
+ if (printed.length > 0) {
573
+ console.log("\n# Add these to your shell profile:");
574
+ for (const e of printed) {
575
+ const value = e.value === "__KEY__" ? opts.key : e.value;
576
+ console.log(`export ${e.name}=${value}`);
577
+ }
578
+ }
461
579
  for (const e of plan.exports) {
462
- const value = e.value === "__KEY__" ? opts.key : e.value;
463
- console.log(`export ${e.name}=${value}`);
580
+ if (process.env[e.name]) {
581
+ console.log(`# ${e.name} is already set in your environment \u2014 not printing its value.`);
582
+ }
464
583
  }
465
584
  }
466
585
  for (const note of plan.notes) console.log(note);
@@ -584,42 +703,51 @@ function describeSpawnError(command, installHint, err) {
584
703
  // src/setup/paths.ts
585
704
  import { execSync } from "child_process";
586
705
  import { homedir as homedir2 } from "os";
587
- import { join as join2 } from "path";
706
+ import { join as join3 } from "path";
588
707
  function configHome() {
589
- return process.env.XDG_CONFIG_HOME || join2(homedir2(), ".config");
708
+ return process.env.XDG_CONFIG_HOME || join3(homedir2(), ".config");
590
709
  }
591
710
  function opencodeConfigPath() {
592
- return join2(configHome(), "opencode", "opencode.json");
711
+ return join3(configHome(), "opencode", "opencode.json");
593
712
  }
594
713
  function opencodeAuthPath() {
595
- const dataHome = process.env.XDG_DATA_HOME || join2(homedir2(), ".local", "share");
596
- return join2(dataHome, "opencode", "auth.json");
714
+ const dataHome = process.env.XDG_DATA_HOME || join3(homedir2(), ".local", "share");
715
+ return join3(dataHome, "opencode", "auth.json");
597
716
  }
598
717
  function openclawConfigPath() {
599
- return join2(homedir2(), ".openclaw", "openclaw.json");
718
+ return join3(homedir2(), ".openclaw", "openclaw.json");
600
719
  }
601
720
  function codexProfilePath() {
602
- const home = process.env.CODEX_HOME || join2(homedir2(), ".codex");
603
- return join2(home, "lunaroute.config.toml");
721
+ const home = process.env.CODEX_HOME || join3(homedir2(), ".codex");
722
+ return join3(home, "lunaroute.config.toml");
604
723
  }
605
724
  function piModelsPath() {
606
- return join2(homedir2(), ".pi", "agent", "models.json");
725
+ return join3(homedir2(), ".pi", "agent", "models.json");
607
726
  }
608
727
  function piAuthPath() {
609
- return join2(homedir2(), ".pi", "agent", "auth.json");
728
+ return join3(homedir2(), ".pi", "agent", "auth.json");
729
+ }
730
+ function dshHome() {
731
+ return process.env.DSH_HOME || join3(homedir2(), ".dsh");
732
+ }
733
+ function dshProfilePatchPath(profile = "web") {
734
+ return join3(dshHome(), "profiles", profile, "cordis.patch.yml");
735
+ }
736
+ function dshHomePatchPath() {
737
+ return join3(dshHome(), "cordis.patch.yml");
610
738
  }
611
739
  var LUNAROUTE_SKILL_NAME = "lunaroute-memory";
612
740
  function claudeUserConfigPath() {
613
- return join2(homedir2(), ".claude.json");
741
+ return join3(homedir2(), ".claude.json");
614
742
  }
615
743
  function claudeUserSkillPath(name = LUNAROUTE_SKILL_NAME) {
616
- return join2(homedir2(), ".claude", "skills", name, "SKILL.md");
744
+ return join3(homedir2(), ".claude", "skills", name, "SKILL.md");
617
745
  }
618
746
  function claudeProjectMcpPath(root) {
619
- return join2(root, ".mcp.json");
747
+ return join3(root, ".mcp.json");
620
748
  }
621
749
  function claudeProjectSkillPath(root, name = LUNAROUTE_SKILL_NAME) {
622
- return join2(root, ".claude", "skills", name, "SKILL.md");
750
+ return join3(root, ".claude", "skills", name, "SKILL.md");
623
751
  }
624
752
  function gitRepoRoot(cwd = process.cwd()) {
625
753
  try {
@@ -737,7 +865,7 @@ function buildKeyPlan(key) {
737
865
  }
738
866
 
739
867
  // src/setup/adapters/pi.ts
740
- import { readFileSync as readFileSync3 } from "fs";
868
+ import { readFileSync as readFileSync4 } from "fs";
741
869
  function buildPiModelEntry(m) {
742
870
  if (!m.context_window_tokens || !m.max_output_tokens) return null;
743
871
  const reasoning = m.capabilities?.reasoning === true;
@@ -749,15 +877,18 @@ function buildPiModelEntry(m) {
749
877
  contextWindow: m.context_window_tokens,
750
878
  maxTokens: m.max_output_tokens
751
879
  };
752
- if (!reasoning) return entry;
753
880
  const pi = m.client_compat?.pi;
881
+ if (m.capabilities?.vision && pi?.inputLimits !== void 0) {
882
+ entry.inputLimits = pi.inputLimits;
883
+ }
884
+ if (!reasoning) return entry;
754
885
  if (!pi) return entry;
755
886
  if (pi.thinkingLevelMap && typeof pi.thinkingLevelMap === "object") {
756
887
  entry.thinkingLevelMap = pi.thinkingLevelMap;
757
888
  }
758
889
  const compat = {};
759
890
  for (const [k, v] of Object.entries(pi)) {
760
- if (k !== "thinkingLevelMap") compat[k] = v;
891
+ if (k !== "thinkingLevelMap" && k !== "inputLimits") compat[k] = v;
761
892
  }
762
893
  if (Object.keys(compat).length > 0) entry.compat = compat;
763
894
  return entry;
@@ -808,7 +939,7 @@ function buildPlan2(ctx) {
808
939
  }
809
940
  function stalePiProviderExists() {
810
941
  try {
811
- const obj = JSON.parse(readFileSync3(piModelsPath(), "utf8"));
942
+ const obj = JSON.parse(readFileSync4(piModelsPath(), "utf8"));
812
943
  return Boolean(obj.providers?.lunaroute);
813
944
  } catch {
814
945
  return false;
@@ -1044,11 +1175,162 @@ openclaw: restart the gateway, then \`openclaw models list\` and \`openclaw mode
1044
1175
  };
1045
1176
  }
1046
1177
 
1178
+ // src/setup/adapters/dsh.ts
1179
+ import { existsSync as existsSync4, readFileSync as readFileSync5 } from "fs";
1180
+ import { isMap, isSeq, parseDocument as parseDocument2 } from "yaml";
1181
+ var PI_AI_ROW_ID = "llm-pi-ai";
1182
+ var ROUTE_KEY = "lunaroute";
1183
+ function asRecord2(v) {
1184
+ return typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
1185
+ }
1186
+ var DSH_THINKING_FORMATS = /* @__PURE__ */ new Set([
1187
+ "openai",
1188
+ "deepseek",
1189
+ "openrouter",
1190
+ "together",
1191
+ "baseten",
1192
+ "zai",
1193
+ "qwen",
1194
+ "chat-template",
1195
+ "qwen-chat-template",
1196
+ "string-thinking",
1197
+ "ant-ling"
1198
+ ]);
1199
+ function thinkingFormatOf(m) {
1200
+ const pi = asRecord2(m.client_compat?.pi);
1201
+ return typeof pi.thinkingFormat === "string" ? pi.thinkingFormat : void 0;
1202
+ }
1203
+ function buildReasoning(m) {
1204
+ if (m.capabilities?.reasoning !== true) return null;
1205
+ const pi = asRecord2(m.client_compat?.pi);
1206
+ const levelMap = asRecord2(pi.thinkingLevelMap);
1207
+ const efforts = {
1208
+ off: typeof levelMap.off === "string" ? levelMap.off : null
1209
+ };
1210
+ for (const [level, wire] of Object.entries(levelMap)) {
1211
+ if (level === "off") continue;
1212
+ if (typeof wire === "string") efforts[level] = wire;
1213
+ }
1214
+ if (Object.keys(efforts).length < 2) return null;
1215
+ const compat = {};
1216
+ if (typeof pi.thinkingFormat === "string" && DSH_THINKING_FORMATS.has(pi.thinkingFormat)) {
1217
+ compat.thinkingFormat = pi.thinkingFormat;
1218
+ }
1219
+ if (typeof pi.maxTokensField === "string") compat.maxTokensField = pi.maxTokensField;
1220
+ if (typeof pi.supportsReasoningEffort === "boolean") {
1221
+ compat.supportsReasoningEffort = pi.supportsReasoningEffort;
1222
+ }
1223
+ return Object.keys(compat).length > 0 ? { reasoningEfforts: efforts, compat } : { reasoningEfforts: efforts };
1224
+ }
1225
+ function buildModel(m) {
1226
+ const entry = { id: m.id, name: m.display_name || m.id };
1227
+ if (Number.isInteger(m.context_window_tokens) && (m.context_window_tokens ?? 0) > 0) {
1228
+ entry.contextWindow = m.context_window_tokens;
1229
+ }
1230
+ if (Number.isInteger(m.max_output_tokens) && (m.max_output_tokens ?? 0) > 0) {
1231
+ entry.maxTokens = m.max_output_tokens;
1232
+ }
1233
+ entry.input = m.capabilities?.vision === true ? ["text", "image"] : ["text"];
1234
+ const reasoning = buildReasoning(m);
1235
+ if (reasoning) {
1236
+ entry.reasoningEfforts = reasoning.reasoningEfforts;
1237
+ if (reasoning.compat) entry.compat = reasoning.compat;
1238
+ }
1239
+ return entry;
1240
+ }
1241
+ function ensureProviderRow(doc) {
1242
+ let seq;
1243
+ if (isSeq(doc.contents)) {
1244
+ seq = doc.contents;
1245
+ } else {
1246
+ seq = doc.createNode([]);
1247
+ doc.contents = seq;
1248
+ }
1249
+ for (const item of seq.items) {
1250
+ if (isMap(item) && item.get("id") === PI_AI_ROW_ID) return item;
1251
+ }
1252
+ const row = doc.createNode({ id: PI_AI_ROW_ID, config: { providers: {} } });
1253
+ seq.add(row);
1254
+ return row;
1255
+ }
1256
+ function ensureMap(doc, parent, key) {
1257
+ const existing = parent.get(key);
1258
+ if (isMap(existing)) return existing;
1259
+ const created = doc.createNode({});
1260
+ parent.set(key, created);
1261
+ return created;
1262
+ }
1263
+ function mergeProvider(doc, provider) {
1264
+ const row = ensureProviderRow(doc);
1265
+ const config = ensureMap(doc, row, "config");
1266
+ const providers = ensureMap(doc, config, "providers");
1267
+ providers.set(ROUTE_KEY, doc.createNode(provider));
1268
+ }
1269
+ function homePatchOverridesPiAi() {
1270
+ const path = dshHomePatchPath();
1271
+ if (!existsSync4(path)) return false;
1272
+ try {
1273
+ const doc = parseDocument2(readFileSync5(path, "utf8"), { logLevel: "silent" });
1274
+ if (!isSeq(doc.contents)) return false;
1275
+ return doc.contents.items.some(
1276
+ (item) => isMap(item) && item.get("id") === PI_AI_ROW_ID
1277
+ );
1278
+ } catch {
1279
+ return false;
1280
+ }
1281
+ }
1282
+ function buildPlan8(ctx) {
1283
+ const base = validatedRoutingUrl(ctx.routingUrl);
1284
+ if (ctx.models.length === 0) {
1285
+ throw new Error("no LunaRoute chat models in the catalog \u2014 nothing to configure for dsh");
1286
+ }
1287
+ const provider = {
1288
+ displayName: "LunaRoute",
1289
+ apiKeyEnv: ctx.keyEnvVar,
1290
+ api: "openai-completions",
1291
+ baseURL: `${base}/v1`,
1292
+ models: ctx.models.map(buildModel)
1293
+ };
1294
+ const notes = [
1295
+ "\ndsh: start `dsh web` (or plain `dsh`), then pick a `lunaroute/*` model in the model picker (Settings \u2192 Models).",
1296
+ "The profile patch hot-reloads, so a running `dsh web` picks it up without a restart.",
1297
+ "The key rides `Authorization: Bearer lr_\u2026` via apiKeyEnv; LunaRoute authenticates it at the edge and never forwards it upstream.",
1298
+ "Or paste the key in Settings \u2192 Models instead \u2014 dsh stores it in $DSH_HOME/.credentials.yaml."
1299
+ ];
1300
+ const unsupportedFormats = [
1301
+ ...new Set(
1302
+ ctx.models.map(thinkingFormatOf).filter((f) => f !== void 0 && !DSH_THINKING_FORMATS.has(f))
1303
+ )
1304
+ ];
1305
+ if (unsupportedFormats.length > 0) {
1306
+ notes.push(
1307
+ `dsh does not accept thinkingFormat value(s): ${unsupportedFormats.join(", ")} \u2014 omitted from the config. Fix client_compat.pi.thinkingFormat in the catalog.`
1308
+ );
1309
+ }
1310
+ if (homePatchOverridesPiAi()) {
1311
+ notes.push(
1312
+ `WARNING: $DSH_HOME/cordis.patch.yml also has an \`llm-pi-ai\` row. It is a later config layer, so it REPLACES the row setup just wrote \u2014 remove it, or move the lunaroute provider there.`
1313
+ );
1314
+ }
1315
+ return {
1316
+ fileWrites: [
1317
+ {
1318
+ kind: "yaml",
1319
+ path: dshProfilePatchPath(),
1320
+ merge: (doc) => mergeProvider(doc, provider)
1321
+ }
1322
+ ],
1323
+ exports: [{ name: ctx.keyEnvVar, value: "__KEY__" }],
1324
+ notes
1325
+ };
1326
+ }
1327
+
1047
1328
  // src/commands/setup.ts
1048
1329
  var ADAPTERS = {
1049
1330
  opencode: buildPlan,
1050
1331
  pi: buildPlan2,
1051
1332
  openclaw: buildPlan7,
1333
+ dsh: buildPlan8,
1052
1334
  "claude-code": buildPlan3,
1053
1335
  codex: buildPlan4,
1054
1336
  "copilot-cli": buildPlan5,
@@ -1171,6 +1453,11 @@ var OPENCODE_LOGIN_HINT = "Or re-run and choose the extension \u2014 it logs in
1171
1453
  var PI_LOGIN_HINT = "Or re-run and choose the extension \u2014 login happens via /login lunaroute inside pi.";
1172
1454
  async function requireCreds(opts, deps, stored, hint) {
1173
1455
  if (stored?.routing_key) return stored;
1456
+ const envKey = process.env.LUNAROUTE_API_KEY?.trim();
1457
+ if (envKey) {
1458
+ const settings = resolveSettings(opts.profile);
1459
+ return { ...settings, routing_key: envKey };
1460
+ }
1174
1461
  const decline = [NOT_LOGGED_IN, hint].filter(Boolean).join(" ");
1175
1462
  try {
1176
1463
  const ok = await deps.confirm('Not logged in. Run "lunaroute login" now? (opens your browser)');
@@ -2214,8 +2501,17 @@ if (nodeMajor < MIN_NODE_MAJOR) {
2214
2501
  }
2215
2502
  var program = new Command();
2216
2503
  program.name("lunaroute").description("LunaRoute CLI \u2014 configure coding harnesses and manage your account.").version(version).option("-p, --profile <name>", "credential profile to use", "default");
2217
- program.command("login").description("Authorize this device via the browser and store a routing key.").action(async () => {
2218
- await login(program.opts().profile);
2504
+ program.command("login").description("Authorize this device via the browser and store a routing key.").option("--start", "headless: print an authorization URL and exit (paste the code back with --finish)", false).option("--finish <code>", "headless: exchange the code shown by --start for a routing key").action(async (opts) => {
2505
+ const profile = program.opts().profile;
2506
+ if (opts.finish) {
2507
+ await loginFinish(profile, opts.finish);
2508
+ return;
2509
+ }
2510
+ if (opts.start) {
2511
+ await loginStart(profile);
2512
+ return;
2513
+ }
2514
+ await login(profile);
2219
2515
  });
2220
2516
  program.command("whoami").description("Show the signed-in user and organization.").action(() => {
2221
2517
  whoami(program.opts().profile);
@@ -2223,7 +2519,7 @@ program.command("whoami").description("Show the signed-in user and organization.
2223
2519
  program.command("logout").description("Remove stored credentials for the active profile.").action(() => {
2224
2520
  logout(program.opts().profile);
2225
2521
  });
2226
- program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | codex | copilot-cli | openclaw | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--key <key>", "a LunaRoute routing key (lr_\u2026), e.g. from the dashboard's onboarding page \u2014 stores it and skips the browser login").action(async (harness, opts) => {
2522
+ program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | codex | copilot-cli | openclaw | dsh | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--key <key>", "a LunaRoute routing key (lr_\u2026), e.g. from the dashboard's onboarding page \u2014 stores it and skips the browser login").action(async (harness, opts) => {
2227
2523
  const code = await runSetup(harness, {
2228
2524
  profile: program.opts().profile,
2229
2525
  print: opts.print,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunaroute/cli",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "LunaRoute CLI — configure coding harnesses and manage your LunaRoute account.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,6 +32,7 @@
32
32
  "commander": "^15.0.0",
33
33
  "cross-spawn": "^7.0.6",
34
34
  "open": "^11.0.1",
35
+ "yaml": "^2.9.1",
35
36
  "zod": "^4.4.3"
36
37
  },
37
38
  "devDependencies": {