@0dai-dev/cli 4.2.0 → 4.3.4

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 (48) hide show
  1. package/README.md +30 -5
  2. package/bin/0dai.js +289 -60
  3. package/lib/commands/audit.js +13 -0
  4. package/lib/commands/auth.js +341 -98
  5. package/lib/commands/boneyard.js +44 -0
  6. package/lib/commands/ci.js +329 -0
  7. package/lib/commands/compliance.js +20 -0
  8. package/lib/commands/doctor.js +20 -1
  9. package/lib/commands/experience.js +5 -1
  10. package/lib/commands/feedback.js +92 -5
  11. package/lib/commands/gh.js +506 -0
  12. package/lib/commands/graph.js +78 -10
  13. package/lib/commands/heatmap.js +17 -0
  14. package/lib/commands/import_claude_code_agents.js +367 -0
  15. package/lib/commands/init.js +440 -28
  16. package/lib/commands/loop.js +108 -0
  17. package/lib/commands/mcp.js +410 -0
  18. package/lib/commands/models.js +27 -3
  19. package/lib/commands/paste.js +114 -0
  20. package/lib/commands/play.js +173 -0
  21. package/lib/commands/provider.js +69 -0
  22. package/lib/commands/quota.js +76 -0
  23. package/lib/commands/receipt.js +53 -0
  24. package/lib/commands/report.js +29 -2
  25. package/lib/commands/run.js +44 -4
  26. package/lib/commands/runner.js +527 -0
  27. package/lib/commands/session.js +1 -7
  28. package/lib/commands/standup.js +40 -0
  29. package/lib/commands/status.js +26 -1
  30. package/lib/commands/swarm.js +97 -4
  31. package/lib/commands/tui.js +81 -13
  32. package/lib/commands/usage.js +87 -0
  33. package/lib/commands/vault.js +246 -0
  34. package/lib/onboarding.js +9 -3
  35. package/lib/shared.js +29 -14
  36. package/lib/tui/index.mjs +571 -187
  37. package/lib/utils/auth.js +1 -0
  38. package/lib/utils/canonical-counts.js +54 -0
  39. package/lib/utils/diff-preview.js +192 -0
  40. package/lib/utils/identity.js +76 -18
  41. package/lib/utils/mcp-auth.js +607 -0
  42. package/lib/utils/plan.js +37 -2
  43. package/lib/vault/cipher.js +125 -0
  44. package/lib/vault/identity.js +122 -0
  45. package/lib/vault/index.js +184 -0
  46. package/lib/vault/storage.js +84 -0
  47. package/lib/wizard.js +19 -12
  48. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 0dai
2
2
 
3
- One config layer for 5 AI agent CLIs — Claude Code, Codex, OpenCode, Gemini, Aider.
3
+ One config layer for <!-- canonical-count:agent_clis_total -->6<!-- /canonical-count --> AI agent CLIs — Claude Code, Codex, OpenCode, Gemini, Aider, Qoder.
4
4
 
5
5
  ## Install
6
6
 
@@ -12,18 +12,21 @@ npm install -g @0dai-dev/cli
12
12
 
13
13
  ```bash
14
14
  cd your-project
15
- 0dai auth login
16
- 0dai activate free
17
- 0dai init # detect stack, generate ai/ layer + native configs
15
+ 0dai init # guides OAuth/device auth + activation, then generates ai/ layer
16
+ 0dai init --auth-code <browser-code> --code <TEAM-CODE>
17
+ 0dai auth login # sign in separately when needed
18
+ 0dai activate code <TEAM-CODE>
18
19
  0dai sync # update after changes
19
20
  0dai detect # show detected stack
20
21
  0dai doctor # check health
21
22
  0dai status # maturity, swarm tasks, session
23
+ 0dai feedback retry # retry queued feedback after an API failure
24
+ 0dai persona-simulate "topic" # run synthetic focus-group simulation
22
25
  ```
23
26
 
24
27
  ## What it does
25
28
 
26
- `0dai init` and `0dai sync` are activation-first. They authenticate the user, require a free activation license, bind the project, then send only allowlisted project metadata (file names + package/build manifests) to the API and generate:
29
+ `0dai init` and `0dai sync` are activation-first. `init` can complete auth and plan activation in one run: browser/OAuth exchange code via `--auth-code`, Team/Pro activation code via `--code` or `--activation-code`, or the interactive OAuth/device-code prompt. After that it binds the project and sends only allowlisted project metadata (file names + package/build manifests) to the API and generates:
27
30
 
28
31
  - `ai/` — manifests, personas, skills, playbooks, delegation policy
29
32
  - `.claude/` — settings, agents, hooks, rules
@@ -34,6 +37,28 @@ cd your-project
34
37
 
35
38
  Your source code is never sent. Only file names and package/build manifests.
36
39
 
40
+ ## Why 0dai, not just Cursor or Copilot?
41
+
42
+ Cursor and Copilot are editors. They help inside one coding session. 0dai writes a project layer that Claude Code, Codex, OpenCode, Gemini, and Aider can all read. The point is not another autocomplete box; it is one manifest, one set of agent roles, one task queue, and one health check for the repo.
43
+
44
+ A fresh `0dai init` turns a repo into an AI-ready workspace. It records stack detection, safe project commands, agent preferences, MCP config, and delegation policy under `ai/`, then writes native files such as `AGENTS.md` and `.mcp.json`. Your source stays local; only file names and package/build manifests go to the API.
45
+
46
+ 0dai is useful when work needs more than one model or more than one sitting. You can ask for a backlog item with `0dai run "add password reset tests"`, check the queue with `0dai swarm status`, and continue from the same project facts in another agent CLI. Cursor or Copilot can still be your editor; 0dai keeps the repo-level context and task state outside the editor.
47
+
48
+ The first five minutes are direct: run `0dai init`, run `0dai doctor`, then try one backlog task with `0dai run "..."` or inspect state with `0dai status`. If you only want a local setup, use `0dai init --local`; cloud mode adds sync, graph history, and shared task records.
49
+
50
+ ## Free-tier examples
51
+
52
+ On the free tier you get ≈5 backlog tasks/day. Example: in one day you might ask 0dai to split and queue these tasks:
53
+
54
+ - Write missing tests for the login form.
55
+ - Add empty-state copy to the dashboard.
56
+ - Check a failing CI log and suggest the smallest code fix.
57
+ - Draft a PR checklist from the files changed.
58
+ - Summarize today's `ai/swarm/done` tasks for standup.
59
+
60
+ Each task can become one or more agent prompts, so the exact count depends on task size. Treat the free tier as enough for a daily cleanup pass; Pro is for larger task queues, graph sync with edges, and session roaming across projects.
61
+
37
62
  ## Links
38
63
 
39
64
  - Website: https://0dai.dev
package/bin/0dai.js CHANGED
@@ -8,12 +8,95 @@
8
8
  * Shared config and utilities live in lib/shared.js.
9
9
  */
10
10
 
11
+ const nodePath = require("path");
12
+
13
+ function parseTargetAndArgs(rawArgs, cwd) {
14
+ const args = rawArgs.slice();
15
+ let target = cwd;
16
+ const ti = args.indexOf("--target");
17
+ if (ti >= 0 && args[ti + 1]) { target = nodePath.resolve(args[ti + 1]); args.splice(ti, 2); }
18
+ return { args, target };
19
+ }
20
+
21
+ const earlyParsed = parseTargetAndArgs(process.argv.slice(2), process.cwd());
22
+ if ((earlyParsed.args[0] || "help") === "swarm-run") {
23
+ const { cmdSwarmRun } = require("../lib/commands/swarm");
24
+ cmdSwarmRun(earlyParsed.target, earlyParsed.args.slice(1));
25
+ process.exit(0);
26
+ }
27
+
11
28
  const shared = require("../lib/shared");
12
29
  const { T, R, D, log, VERSION, fs, path, spawnSync, findRepoScript, checkVersion } = shared;
13
30
 
31
+ /**
32
+ * Hot-path Go binary fallback (issue #2424).
33
+ *
34
+ * For read-only hot-path commands (status/doctor/version) we attempt to delegate
35
+ * to a Go binary when:
36
+ * 1. ODAI_GO_BIN is set and points at an executable file, OR a binary called
37
+ * `0dai-go` is found on PATH.
38
+ * 2. The binary reports `binary_version` matching the dispatcher VERSION
39
+ * (we accept exact match only — drift means fall back to Python/Node).
40
+ * 3. ODAI_GO_DISABLE is NOT set to a truthy value.
41
+ *
42
+ * If any of these checks fail we silently fall through to the existing
43
+ * Python/Node implementations. The goal is zero behaviour change when the Go
44
+ * binary is missing, broken, or version-skewed.
45
+ */
46
+ function locateGoBinary() {
47
+ if (process.env.ODAI_GO_DISABLE && process.env.ODAI_GO_DISABLE !== "0") return null;
48
+ const explicit = process.env.ODAI_GO_BIN;
49
+ if (explicit && fs.existsSync(explicit)) {
50
+ try { if ((fs.statSync(explicit).mode & 0o111) !== 0) return explicit; } catch {}
51
+ }
52
+ // Search PATH for `0dai-go`.
53
+ const pathEnv = process.env.PATH || "";
54
+ const sep = process.platform === "win32" ? ";" : ":";
55
+ for (const dir of pathEnv.split(sep)) {
56
+ if (!dir) continue;
57
+ const candidate = path.join(dir, "0dai-go");
58
+ try {
59
+ if (fs.existsSync(candidate) && (fs.statSync(candidate).mode & 0o111) !== 0) return candidate;
60
+ } catch {}
61
+ }
62
+ return null;
63
+ }
64
+
65
+ function goBinaryCompatible(binPath) {
66
+ try {
67
+ const res = spawnSync(binPath, ["version", "--json"], { timeout: 3000 });
68
+ if (res.status !== 0 || !res.stdout) return false;
69
+ const info = JSON.parse(res.stdout.toString());
70
+ if (!info || typeof info.binary_version !== "string") return false;
71
+ return info.binary_version === VERSION;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Attempt to dispatch a hot-path command to the Go binary.
79
+ * Returns true if Go handled the command (process should exit), false if the
80
+ * caller must fall back to the existing Python/Node path.
81
+ */
82
+ function tryGoHotPath(cmdName, target, argv) {
83
+ const bin = locateGoBinary();
84
+ if (!bin) return false;
85
+ if (!goBinaryCompatible(bin)) return false;
86
+ const forwarded = [cmdName, "--target", target, ...argv];
87
+ const res = spawnSync(bin, forwarded, { stdio: "inherit" });
88
+ if (res.error) return false;
89
+ if (typeof res.status === "number") process.exit(res.status);
90
+ process.exit(0);
91
+ }
92
+
93
+ // Export for tests; harmless at runtime.
94
+ module.exports = { locateGoBinary, goBinaryCompatible, tryGoHotPath };
95
+ const { loadCanonicalCounts, mcpToolsLabel } = require("../lib/utils/canonical-counts");
96
+
14
97
  // --- Command imports ---
15
- const { cmdAuthLogin, cmdAuthLogout, cmdRedeem, cmdAuthStatus, cmdActivateFree, cmdActivateStatus } = require("../lib/commands/auth");
16
- const { cmdInit, cmdSync } = require("../lib/commands/init");
98
+ const { cmdAuthLogin, cmdAuthLogout, cmdRedeem, cmdAuthStatus, cmdAuthMcp, cmdActivateFree, cmdActivateStatus } = require("../lib/commands/auth");
99
+ const { cmdInit, cmdSync, cmdProjectBind } = require("../lib/commands/init");
17
100
  const { cmdDetect } = require("../lib/commands/detect");
18
101
  const { cmdAudit } = require("../lib/commands/audit");
19
102
  const { cmdDoctor } = require("../lib/commands/doctor");
@@ -21,32 +104,158 @@ const { cmdValidate } = require("../lib/commands/validate");
21
104
  const { cmdUpdate } = require("../lib/commands/update");
22
105
  const { cmdReflect } = require("../lib/commands/reflect");
23
106
  const { cmdMetrics } = require("../lib/commands/metrics");
107
+ const { cmdHeatmap } = require("../lib/commands/heatmap");
24
108
  const { cmdStatus } = require("../lib/commands/status");
25
109
  const { cmdPortfolio } = require("../lib/commands/portfolio");
26
110
  const { cmdRun } = require("../lib/commands/run");
27
111
  const { cmdWatch } = require("../lib/commands/watch");
28
112
  const { cmdModels } = require("../lib/commands/models");
29
113
  const { cmdSession } = require("../lib/commands/session");
30
- const { cmdSwarm } = require("../lib/commands/swarm");
114
+ const { cmdSwarm, cmdSwarmRun } = require("../lib/commands/swarm");
115
+ const { cmdStandup } = require("../lib/commands/standup");
31
116
  const { cmdFeedback, cmdFeedbackPush } = require("../lib/commands/feedback");
117
+ const { cmdPlay } = require("../lib/commands/play");
32
118
  const { cmdGraph } = require("../lib/commands/graph");
33
119
  const { cmdReport } = require("../lib/commands/report");
120
+ const { cmdCompliance } = require("../lib/commands/compliance");
34
121
  const { cmdExperience } = require("../lib/commands/experience");
35
122
  const { cmdWorkspace } = require("../lib/commands/workspace");
36
123
  const { cmdSsh } = require("../lib/commands/ssh");
37
124
  const { cmdTui } = require("../lib/commands/tui");
38
125
  const { cmdPersonaSimulate } = require("../lib/commands/persona-simulate");
39
126
  const { cmdProvider } = require("../lib/commands/provider");
127
+ const { cmdPaste } = require("../lib/commands/paste");
128
+ const { cmdReceipt } = require("../lib/commands/receipt");
129
+ const { cmdBoneyard } = require("../lib/commands/boneyard");
130
+ const { cmdQuota } = require("../lib/commands/quota");
131
+ const { cmdGh } = require("../lib/commands/gh");
132
+ const { cmdLoop } = require("../lib/commands/loop");
133
+ const { cmdImportClaudeCodeAgents } = require("../lib/commands/import_claude_code_agents");
134
+ const { cmdRunner } = require("../lib/commands/runner");
135
+ const { cmdCi } = require("../lib/commands/ci");
136
+
137
+ function printHelp() {
138
+ const counts = loadCanonicalCounts();
139
+ console.log(`\n ${T}0dai${R} v${VERSION} — One config for ${counts.agent_clis_total} AI agent CLIs · ${mcpToolsLabel(counts)}\n`);
140
+ console.log("Start (first 5 minutes):");
141
+ console.log(" init Create ai/ layer + MCP [--local] [--dry-run] [--minimal]");
142
+ console.log(" doctor Check health, credentials, and drift [--drift]");
143
+ console.log(" status Show maturity, swarm, and session state [--json]");
144
+ console.log(" quickstart Run auth, init, doctor, and status checks in order");
145
+ console.log(" detect Show detected stack");
146
+ console.log(" auth login Authenticate (OAuth/device code flow) [--device] [--no-browser] [--code CODE] [--mcp]");
147
+ console.log(" auth mcp Store an MCP token from current auth or device code [--device] [--no-browser]");
148
+ console.log(" auth status Show account and usage");
149
+ console.log(" activate free Claim free activation license");
150
+ console.log("");
151
+ console.log("Daily (regular work):");
152
+ console.log(" sync Update ai/ layer after repo or server changes [--dry-run] [--yes] [--quiet] [--force]");
153
+ console.log(" run <goal> Split a backlog item into agent tasks [--dry-run] [--agent claude|codex|gemini] [--provider X]");
154
+ console.log(" swarm status Show queued, active, and done tasks");
155
+ console.log(" swarm add Queue one task for an agent [--task '...' --to agent]");
156
+ console.log(" swarm-run Add, dispatch, and wait for one swarm task as JSON");
157
+ console.log(" harvest Convert experience events into candidate lessons");
158
+ console.log(" watch Live task monitor: queue, active, recently done [--interval N]");
159
+ console.log(" reflect Session reflection: delivered, delegation rate, blockers");
160
+ console.log(" standup Morning voice briefing about overnight agent work");
161
+ console.log(" feedback push Send feedback to 0dai");
162
+ console.log(" feedback retry Retry queued feedback after a failed push");
163
+ console.log("");
164
+ console.log("Pro / advanced:");
165
+ console.log(" init-existing Existing-repo setup alias for init [--minimal] [--dry-run]");
166
+ console.log(" project bind Bind current repository to your 0dai account [--json]");
167
+ console.log(" project status Show local project binding and health state [--json]");
168
+ console.log(" graph push Upload local graph to server (Pro: edges, Free: nodes)");
169
+ console.log(" graph pull Download server graph and merge locally");
170
+ console.log(" graph status Show local graph stats and sync state");
171
+ console.log(" ci Plan portable 0dai CI pipelines and inspect AI-MQ [list|plan|mq-status] [--json]");
172
+ console.log(" heatmap Repo treemap: LOC x agent-edit intensity");
173
+ console.log(" session save Save session for roaming");
174
+ console.log(" provider Local provider profiles, bindings, and direct invoke");
175
+ console.log(" models Show model ratings (--fast/--balanced/--deep/--available)");
176
+ console.log(" quota Agent subscription usage table [--refresh] [--json]");
177
+ console.log(" workspace Manage tmux workspace sessions (init|up|status)");
178
+ console.log(" runner Show runner/project-host architecture, queues, labels, and burst routing [status|plan|queue-status|label-audit|route-dry-run] [--json]");
179
+ console.log(" report Privacy-safe project reports (preview|push|status)");
180
+ console.log(" compliance SOC2/ISO evidence and ADR audit-trail export");
181
+ console.log(" experience Structured experience events (list|stats|sync|warnings|dismiss)");
182
+ console.log(" persona-simulate Produce a focus-group report and optional issue drafts");
183
+ console.log(" receipt Render a 1200×630 session receipt PNG [--last|--active|--session ID]");
184
+ console.log(" boneyard Weekly digest of worst agent moves [--week YYYY-WW|current]");
185
+ console.log(" gh branch-protection [print|apply|install] Manage generated GitHub branch protection");
186
+ console.log(" import claude-code-agents Import .claude/agents/*.md as 0dai personas [--source DIR] [--target DIR] [--dry-run]");
187
+ console.log(" auth logout Remove credentials");
188
+ console.log(" activate code Redeem a Pro/Team activation code");
189
+ console.log(" activate status Show activation and bound-project status");
190
+ console.log(" redeem <CODE> Redeem a plan upgrade code");
191
+ console.log(" advanced flags:");
192
+ console.log(" --target PATH Run any command against another project path");
193
+ console.log(" init --auth-code CODE --code TEAM-CODE Sign in and activate during init");
194
+ console.log(" init --no-mcp-auth --mcp-host HOST --reset Control MCP bootstrap");
195
+ console.log(" sync --no-diff --force Control managed config updates");
196
+ console.log(" --version\n");
197
+ console.log("https://0dai.dev");
198
+ }
199
+
200
+ const SYNC_ALLOWED_FLAGS = new Set([
201
+ "--dry-run",
202
+ "--yes",
203
+ "-y",
204
+ "--quiet",
205
+ "-q",
206
+ "--force",
207
+ "--no-diff",
208
+ "--no-mcp-auth",
209
+ ]);
210
+
211
+ function printSyncHelp() {
212
+ console.log(`\n ${T}0dai sync${R} — Update the managed ai/ layer\n`);
213
+ console.log("Usage:");
214
+ console.log(" 0dai sync [--dry-run] [--yes|-y] [--quiet|-q] [--force] [--no-diff] [--no-mcp-auth] [--target PATH]");
215
+ console.log("");
216
+ console.log("Options:");
217
+ console.log(" --dry-run Preview managed file changes without writing them");
218
+ console.log(" --yes, -y Apply changes without an interactive confirmation prompt");
219
+ console.log(" --quiet, -q Reduce non-essential output");
220
+ console.log(" --force Also overwrite native config files from managed ai/ sources");
221
+ console.log(" --no-diff Hide unified diff output in previews/prompts");
222
+ console.log(" --no-mcp-auth Skip MCP cloud-token bootstrap during sync");
223
+ console.log(" --target PATH Run sync against another project path");
224
+ console.log("");
225
+ }
226
+
227
+ function handleSyncHelpOrInvalidArgs(args) {
228
+ const syncArgs = args.slice(1);
229
+ if (syncArgs.includes("--help") || syncArgs.includes("-h")) {
230
+ printSyncHelp();
231
+ return true;
232
+ }
233
+
234
+ for (const arg of syncArgs) {
235
+ if (SYNC_ALLOWED_FLAGS.has(arg)) continue;
236
+ const label = arg.startsWith("-") ? "unknown sync option" : "unexpected sync argument";
237
+ log(`${label}: ${arg}`);
238
+ printSyncHelp();
239
+ process.exit(1);
240
+ }
241
+ return false;
242
+ }
40
243
 
41
244
  async function main() {
42
- const args = process.argv.slice(2);
43
- let target = process.cwd();
44
- const ti = args.indexOf("--target");
45
- if (ti >= 0 && args[ti + 1]) { target = path.resolve(args[ti + 1]); args.splice(ti, 2); }
245
+ const { args, target } = parseTargetAndArgs(process.argv.slice(2), process.cwd());
46
246
 
47
247
  const cmd = args[0] || "help";
48
248
  const sub = args[1] || "";
49
249
 
250
+ if (cmd === "swarm-run") {
251
+ cmdSwarmRun(target, args.slice(1));
252
+ return;
253
+ }
254
+
255
+ if (cmd === "sync" && handleSyncHelpOrInvalidArgs(args)) {
256
+ return;
257
+ }
258
+
50
259
  // Non-blocking version check (runs in background, once per day)
51
260
  checkVersion();
52
261
 
@@ -54,7 +263,7 @@ async function main() {
54
263
  try { require("../lib/onboarding").trackFirstRun(target); } catch {}
55
264
 
56
265
  // First-run wizard prompt for commands that need ai/
57
- if (["status", "doctor", "sync", "swarm", "detect", "validate", "reflect", "metrics", "experience", "graph", "session", "report"].includes(cmd)) {
266
+ if (["status", "doctor", "sync", "swarm", "swarm-run", "detect", "validate", "reflect", "metrics", "experience", "graph", "session", "report", "live", "feed", "live-feed"].includes(cmd)) {
58
267
  try {
59
268
  const { maybeWizard } = require("../lib/wizard");
60
269
  const handled = await maybeWizard(target, cmd);
@@ -68,6 +277,7 @@ async function main() {
68
277
  await ob.cmdQuickstart(target, { cmdDoctor, cmdStatus, cmdInit: (t, a) => cmdInit(t, a || []), log, ensureAuthenticated: shared.makeEnsureAuthenticated(cmdAuthLogin) });
69
278
  break;
70
279
  }
280
+ case "init-existing": await cmdInit(target, args); break;
71
281
  case "run": await cmdRun(args[1] || "", target, args.slice(2)); break;
72
282
  case "watch": cmdWatch(target, args.slice(1)); break;
73
283
  case "audit": cmdAudit(target); break;
@@ -109,6 +319,11 @@ async function main() {
109
319
  case "detect": await cmdDetect(target); break;
110
320
  case "doctor": {
111
321
  const driftMode = args.includes("--drift");
322
+ // Go fast-path covers only the base read-only doctor (no --drift, no
323
+ // network). Anything else falls through to the full Node implementation.
324
+ if (!driftMode) {
325
+ tryGoHotPath("doctor", target, args.slice(1));
326
+ }
112
327
  cmdDoctor(target, { drift: driftMode });
113
328
  if (args.includes("--drift")) {
114
329
  const ds = findRepoScript(target, "drift_detector.py");
@@ -138,27 +353,83 @@ async function main() {
138
353
  case "reflect": cmdReflect(target, args); break;
139
354
  case "update": cmdUpdate(args); break;
140
355
  case "metrics": cmdMetrics(target); break;
356
+ case "heatmap": cmdHeatmap(target, args.slice(1)); break;
141
357
  case "portfolio": cmdPortfolio(); break;
142
- case "status": cmdStatus(target, { json: args.includes("--json") }); break;
358
+ case "status":
359
+ tryGoHotPath("status", target, args.slice(1));
360
+ cmdStatus(target, { json: args.includes("--json") });
361
+ break;
362
+ case "project":
363
+ if (sub === "status") cmdStatus(target, { json: args.includes("--json") });
364
+ else if (sub === "bind") await cmdProjectBind(target, args.slice(2));
365
+ else console.log("Usage: 0dai project [bind [--json]|status [--json]] [--target PATH]");
366
+ break;
143
367
  case "auth":
144
- if (sub === "login") await cmdAuthLogin();
368
+ if (sub === "login") await cmdAuthLogin(args.slice(2));
145
369
  else if (sub === "logout") cmdAuthLogout();
146
370
  else if (sub === "status") await cmdAuthStatus();
147
- else console.log("Usage: 0dai auth [login|logout|status]");
371
+ else if (sub === "mcp") await cmdAuthMcp(args.slice(2));
372
+ else console.log("Usage: 0dai auth [login [--device] [--no-browser] [--code <success-code>] [--mcp]|mcp [--device] [--no-browser]|logout|status]");
148
373
  break;
149
374
  case "activate":
150
375
  if (sub === "free" || !sub) await cmdActivateFree();
151
376
  else if (sub === "status") await cmdActivateStatus();
152
- else console.log("Usage: 0dai activate [free|status]");
377
+ else if (sub === "code" || sub === "redeem") await cmdRedeem(args[2]);
378
+ else console.log("Usage: 0dai activate [free|status|code <CODE>]");
153
379
  break;
154
380
  case "session": cmdSession(target, sub, args); break;
155
381
  case "swarm": cmdSwarm(target, sub, args); break;
156
382
  case "workspace": cmdWorkspace(target, sub, args.slice(2)); break;
383
+ case "runner": cmdRunner(target, sub, args); break;
384
+ case "ci": cmdCi(target, sub, args); break;
157
385
  case "ssh": await cmdSsh(target, sub, args); break;
158
386
  case "provider": cmdProvider(target, args.slice(1)); break;
387
+ case "standup": await cmdStandup(target, args.slice(1)); break;
159
388
  case "tui": case "dashboard": await cmdTui(target, args.slice(1)); break;
389
+ case "bundle":
390
+ case "replay": {
391
+ const glassBoxScript = findRepoScript(target, "glass_box.py");
392
+ if (!glassBoxScript) { log("glass box bundle helper unavailable"); break; }
393
+ const fwd = [glassBoxScript, cmd, "--target", target, ...args.slice(1)];
394
+ const result = spawnSync("python3", fwd, { stdio: "inherit", timeout: 30000 });
395
+ if (typeof result.status === "number" && result.status !== 0) process.exit(result.status);
396
+ break;
397
+ }
160
398
  case "feedback": await cmdFeedback(target, sub, args); break;
399
+ case "harvest": {
400
+ const harvestScript = findRepoScript(target, "harvest_experience.py");
401
+ if (!harvestScript) { log("harvest helper unavailable"); break; }
402
+ const result = spawnSync("python3", [harvestScript, "--target", target, ...args.slice(1)], { stdio: "inherit", timeout: 15000 });
403
+ if (typeof result.status === "number" && result.status !== 0) process.exit(result.status);
404
+ break;
405
+ }
406
+ case "play": await cmdPlay(target, sub, args); break;
407
+ case "paste": await cmdPaste(args.slice(1)); break;
408
+ case "receipt": cmdReceipt(target, args.slice(1)); break;
409
+ case "boneyard": cmdBoneyard(target, args.slice(1)); break;
410
+ case "quota": case "quotas": cmdQuota(target, args.slice(1)); break;
411
+ case "gh": await cmdGh(target, sub, args); break;
412
+ case "loop": cmdLoop(target, sub, args); break;
413
+ case "import": {
414
+ const what = sub || args[1];
415
+ if (what === "claude-code-agents" || what === "claude-agents") {
416
+ await cmdImportClaudeCodeAgents(target, args.slice(2));
417
+ } else {
418
+ log(`unknown import source: ${what || "(none)"}`);
419
+ console.log(` ${D}supported: claude-code-agents${R}`);
420
+ process.exit(1);
421
+ }
422
+ break;
423
+ }
424
+ case "live": case "feed": case "live-feed": {
425
+ const liveScript = findRepoScript(target, "live_feed.py");
426
+ if (!liveScript) { log("live feed helper unavailable"); break; }
427
+ const result = spawnSync("python3", [liveScript, "--target", target, ...args.slice(1)], { stdio: "inherit", timeout: 15000 });
428
+ if (typeof result.status === "number" && result.status !== 0) process.exit(result.status);
429
+ break;
430
+ }
161
431
  case "report": cmdReport(target, sub, args); break;
432
+ case "compliance": cmdCompliance(target, args.slice(1)); break;
162
433
  case "experience": cmdExperience(target, sub, args); break;
163
434
  case "persona-simulate": cmdPersonaSimulate(target, args.slice(1)); break;
164
435
  case "graph": await cmdGraph(target, sub, args); break;
@@ -251,55 +522,13 @@ async function main() {
251
522
  else log(`error: ${e.message}`);
252
523
  }
253
524
  break;
254
- case "--version": console.log(`${T}0dai${R} ${VERSION}`); break;
525
+ case "--version":
526
+ case "version":
527
+ tryGoHotPath("version", target, args.slice(1));
528
+ console.log(`${T}0dai${R} ${VERSION}`);
529
+ break;
255
530
  case "help": case "--help": case "-h":
256
- console.log(`\n ${T}0dai${R} v${VERSION} — One config for 5 AI agent CLIs\n`);
257
- console.log("Commands:");
258
- console.log(" run <goal> AI-decompose goal → swarm tasks (auto-routed) [--dry-run]");
259
- console.log(" watch Live task monitor: queue, active, recently done [--interval N]");
260
- console.log(" audit Scan ai/ and agent configs for leaked secrets");
261
- console.log(" init Initialize ai/ layer (via API) [--dry-run] [--minimal]");
262
- console.log(" sync Update ai/ layer (via API) [--dry-run] [--quiet] [--force]");
263
- console.log(" detect Show detected stack");
264
- console.log(" doctor Check health + credentials checklist [--drift]");
265
- console.log(" update Update all installed agent CLIs to latest [--dry-run]");
266
- console.log(" validate Validate ai/ layer completeness");
267
- console.log(" reflect Session reflection: delivered, delegation rate, blockers");
268
- console.log(" metrics Effectiveness score: adoption funnel, sessions, delegation");
269
- console.log(" portfolio All tracked projects: score, sessions, agents, last activity");
270
- console.log(" status Show maturity, swarm, session [--json]");
271
- console.log(" session save Save session for roaming");
272
- console.log(" swarm status Task queue & delegation");
273
- console.log(" swarm webhook add Register webhook (fires on task done/failed)");
274
- console.log(" swarm webhook list Show registered webhooks");
275
- console.log(" ssh Manage SSH keys, hosts, grants, and host-side sync");
276
- console.log(" provider Local provider profiles, bindings, and direct invoke");
277
- console.log(" swarm webhook test Send test ping to a webhook URL");
278
- console.log(" workspace init Create tmux workspace config (auto-detect services)");
279
- console.log(" workspace up Start all workspace sessions");
280
- console.log(" workspace status Show session status table");
281
- console.log(" feedback push Send feedback to 0dai");
282
- console.log(" report preview Preview privacy-safe project report");
283
- console.log(" report push Send report to 0dai (with offline queue)");
284
- console.log(" report status Show last report, queue, and auto-report status");
285
- console.log(" persona-simulate Produce a focus-group report and optional issue drafts");
286
- console.log(" experience list Show recent structured experience events");
287
- console.log(" experience stats Show success and cost stats by agent/model/type");
288
- console.log(" graph push Upload local graph to server (Pro: edges, Free: nodes)");
289
- console.log(" graph pull Download server graph and merge locally");
290
- console.log(" graph status Show local graph stats and sync state");
291
- console.log(" models Show model ratings (--fast/--balanced/--deep/--available)");
292
- console.log(" delegate Auto-route task to best agent/model (0dai delegate 'goal')");
293
- console.log(" delegation show Show current delegation policy");
294
- console.log(" terminal Launch interactive agent session");
295
- console.log(" auth login Authenticate (device code flow)");
296
- console.log(" auth logout Remove credentials");
297
- console.log(" auth status Show account and usage");
298
- console.log(" activate free Claim free activation license");
299
- console.log(" activate status Show activation and bound-project status");
300
- console.log(" redeem <CODE> Redeem a plan upgrade code");
301
- console.log(" --version\n");
302
- console.log("https://0dai.dev");
531
+ printHelp();
303
532
  break;
304
533
  default:
305
534
  log(`unknown command: ${cmd}. Run '0dai --help'`);
@@ -29,6 +29,18 @@ function cmdAudit(target) {
29
29
  "opencode.json", ".mcp.json",
30
30
  ];
31
31
 
32
+ // Paths whose contents are synthetic test fixtures by design — they contain
33
+ // realistic-looking secret patterns to exercise detection logic. Skipping
34
+ // them avoids false-positive blocking of release pipelines.
35
+ const SKIP_PATH_SEGMENTS = [
36
+ "synthetic-tests", // ai/meta/synthetic-tests/scenarios/*.json — PII/secret detection fixtures
37
+ ];
38
+
39
+ function shouldSkip(filePath) {
40
+ const rel = path.relative(target, filePath);
41
+ return SKIP_PATH_SEGMENTS.some(seg => rel.split(path.sep).includes(seg));
42
+ }
43
+
32
44
  // Walk a directory recursively, return all file paths
33
45
  function walk(dir, maxDepth = 6, _depth = 0) {
34
46
  if (_depth > maxDepth) return [];
@@ -36,6 +48,7 @@ function cmdAudit(target) {
36
48
  try {
37
49
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
38
50
  if (entry.name.startsWith(".git") || entry.name === "node_modules") continue;
51
+ if (SKIP_PATH_SEGMENTS.includes(entry.name)) continue;
39
52
  const full = path.join(dir, entry.name);
40
53
  if (entry.isDirectory()) results = results.concat(walk(full, maxDepth, _depth + 1));
41
54
  else results.push(full);