@0dai-dev/cli 3.1.3 → 3.1.5

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/bin/0dai.js +63 -4
  2. package/package.json +1 -1
package/bin/0dai.js CHANGED
@@ -391,7 +391,12 @@ async function cmdInit(target, args = []) {
391
391
  });
392
392
 
393
393
  if (result.error) {
394
- if (result.hint) {
394
+ if (result.error.includes("authentication")) {
395
+ log(`authentication required`);
396
+ console.log(` 0dai auth is separate from your agent CLIs (Claude Code, Codex).`);
397
+ console.log(` It tracks projects, usage limits, and team features.\n`);
398
+ console.log(` ${D}Run: 0dai auth login${R}`);
399
+ } else if (result.hint) {
395
400
  log(`${result.message || result.error}`);
396
401
  console.log(` ${result.hint}\n`);
397
402
  } else {
@@ -424,10 +429,25 @@ async function cmdInit(target, args = []) {
424
429
  log(`initialized (${result.file_count || "?"} files)`);
425
430
  console.log(" skills: /build /review /status /feedback /bugfix /delegate");
426
431
 
432
+ // Detect agent auth status for smart onboarding hints
433
+ const { execFileSync: _ef } = require("child_process");
434
+ const agents = [];
435
+ try { _ef("claude", ["--version"], { timeout: 3000 }); agents.push("claude"); } catch {}
436
+ try { _ef("codex", ["--version"], { timeout: 3000 }); agents.push("codex"); } catch {}
437
+ try { _ef("gemini", ["--version"], { timeout: 3000 }); agents.push("gemini"); } catch {}
438
+
427
439
  // Next steps — guide user to first value
428
440
  console.log(`\n ${T}Next steps:${R}`);
429
441
  console.log(` ${D}1.${R} Check health: ${D}0dai doctor${R}`);
430
- console.log(` ${D}2.${R} Try delegation: ${D}0dai run "write tests for auth"${R}`);
442
+ if (agents.length > 0) {
443
+ const a = agents[0];
444
+ console.log(` ${D}2.${R} Try delegation: ${D}0dai run "write tests for auth"${R}`);
445
+ console.log(` ${D}(${agents.join(", ")} detected — delegation will use ${a} by default)${R}`);
446
+ } else {
447
+ console.log(` ${D}2.${R} Install an agent CLI to enable delegation:`);
448
+ console.log(` ${D}claude:${R} npm i -g @anthropic-ai/claude-code ${D}(or Pro subscription)${R}`);
449
+ console.log(` ${D}codex:${R} npm i -g @openai/codex ${D}(or ChatGPT Pro)${R}`);
450
+ }
431
451
  console.log(` ${D}3.${R} Open dashboard: ${D}https://0dai.dev/dashboard${R}`);
432
452
 
433
453
  // Send anonymous usage ping
@@ -484,7 +504,17 @@ async function cmdSync(target, args = []) {
484
504
  dry_run: dryRun, quiet,
485
505
  });
486
506
 
487
- if (result.error) { log(`error: ${result.error}`); process.exit(1); }
507
+ if (result.error) {
508
+ if (result.error.includes("authentication")) {
509
+ log(`authentication required`);
510
+ console.log(` 0dai auth is separate from your agent CLIs (Claude Code, Codex).`);
511
+ console.log(` It tracks projects, usage limits, and team features.\n`);
512
+ console.log(` ${D}Run: 0dai auth login${R}`);
513
+ } else {
514
+ log(`error: ${result.error}`);
515
+ }
516
+ process.exit(1);
517
+ }
488
518
 
489
519
  const updated = result.files_updated || {};
490
520
  if (dryRun) {
@@ -1232,10 +1262,38 @@ async function checkVersion() {
1232
1262
  async function cmdAuthLogin() {
1233
1263
  const isTTY = process.stdout.isTTY && process.stdin.isTTY;
1234
1264
 
1265
+ // Check if already authenticated
1266
+ try {
1267
+ const existing = JSON.parse(fs.readFileSync(AUTH_FILE, "utf8"));
1268
+ if (existing.access_token || existing.email) {
1269
+ if (isTTY) {
1270
+ const p = require("@clack/prompts");
1271
+ p.intro(`${T}0dai${R} authentication`);
1272
+ p.log.success(`Already logged in as ${T}${existing.email || "unknown"}${R} (${existing.plan || "free"} plan)`);
1273
+ const reauth = await p.confirm({ message: "Sign in with a different account?" });
1274
+ if (p.isCancel(reauth) || !reauth) {
1275
+ p.outro("Current session kept");
1276
+ return;
1277
+ }
1278
+ } else {
1279
+ log(`Already logged in as ${existing.email || "unknown"} (${existing.plan || "free"} plan)`);
1280
+ log("To switch accounts, delete ~/.0dai/auth.json and run again");
1281
+ return;
1282
+ }
1283
+ }
1284
+ } catch {}
1285
+
1235
1286
  if (isTTY) {
1236
1287
  // Interactive TUI flow
1237
1288
  const p = require("@clack/prompts");
1238
- p.intro(`${T}0dai${R} authentication`);
1289
+ if (!p._intro_shown) p.intro(`${T}0dai${R} authentication`);
1290
+
1291
+ p.note(
1292
+ "0dai auth is separate from agent CLIs (Claude Code, Codex).\n" +
1293
+ "It tracks your projects, usage limits, and team features.\n" +
1294
+ "Your agent CLIs keep their own auth (subscription/API key).",
1295
+ "Why sign in?"
1296
+ );
1239
1297
 
1240
1298
  const method = await p.select({
1241
1299
  message: "How would you like to sign in?",
@@ -1329,6 +1387,7 @@ async function cmdAuthLogin() {
1329
1387
 
1330
1388
  } else {
1331
1389
  // Non-interactive: device code only
1390
+ log("0dai auth is separate from agent CLIs. It tracks projects, limits, and team features.");
1332
1391
  const result = await apiCall("/v1/auth/device", { client_id: "cli" });
1333
1392
  if (result.error) { log(`error: ${result.error}`); process.exit(1); }
1334
1393
  log(`Open: ${result.verification_uri}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0dai-dev/cli",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "One config layer for 5 AI agent CLIs — Claude Code, Codex, OpenCode, Gemini, Aider",
5
5
  "bin": {
6
6
  "0dai": "./bin/0dai.js"