@0dai-dev/cli 3.2.1 → 3.2.3

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 +48 -6
  2. package/package.json +1 -1
package/bin/0dai.js CHANGED
@@ -2056,20 +2056,62 @@ async function main() {
2056
2056
  try {
2057
2057
  const SessionManager = require("../lib/session-manager");
2058
2058
  const sm = new SessionManager();
2059
- if (sub === "launch" || !sub) {
2060
- const tool = args.find((_, i) => args[i - 1] === "--tool") || "codex";
2061
- const id = sm.spawn(tool, [], target);
2059
+ if (sub === "launch" || !sub || sub.startsWith("--")) {
2060
+ const toolIdx = args.indexOf("--tool");
2061
+ const tool = toolIdx >= 0 && args[toolIdx + 1] ? args[toolIdx + 1] : "codex";
2062
+ const TOOL_CMDS = {
2063
+ codex: { bin: "codex", args: [] },
2064
+ claude: { bin: "claude", args: [] },
2065
+ gemini: { bin: "gemini", args: [] },
2066
+ opencode: { bin: "opencode", args: [] },
2067
+ aider: { bin: "aider", args: [] },
2068
+ };
2069
+ const toolConfig = TOOL_CMDS[tool];
2070
+ if (!toolConfig) {
2071
+ log(`unknown tool: ${tool}. Available: ${Object.keys(TOOL_CMDS).join(", ")}`);
2072
+ break;
2073
+ }
2074
+ // Pass initial prompt if provided after --
2075
+ const dashIdx = args.indexOf("--");
2076
+ const prompt = dashIdx >= 0 ? args.slice(dashIdx + 1).join(" ") : "";
2077
+ const spawnArgs = [...toolConfig.args];
2078
+ if (prompt) spawnArgs.push(prompt);
2079
+ const id = sm.spawn(toolConfig.bin, spawnArgs, target);
2062
2080
  log(`session ${id.slice(0, 8)} started (${tool})`);
2081
+ console.log(` ${D}Ctrl+C to exit, session keeps running in background${R}`);
2082
+ console.log(` ${D}Re-attach: 0dai terminal attach ${id.slice(0, 8)}${R}`);
2063
2083
  sm.attach(id);
2064
2084
  } else if (sub === "list") {
2065
2085
  const sessions = sm.list();
2066
2086
  if (!sessions.length) { log("no active sessions"); break; }
2067
- for (const s of sessions) console.log(` ${s.id.slice(0, 8)} [${s.tool}] ${s.status} ${s.attached ? "(attached)" : ""}`);
2087
+ for (const s of sessions) {
2088
+ const elapsed = Math.round((Date.now() - new Date(s.createdAt).getTime()) / 1000);
2089
+ console.log(` ${s.id.slice(0, 8)} [${s.tool}] ${s.status} ${elapsed}s ${s.attached ? "(attached)" : ""}`);
2090
+ }
2091
+ } else if (sub === "attach") {
2092
+ const prefix = args[1] || "";
2093
+ if (!prefix) { log("usage: 0dai terminal attach <session-id-prefix>"); break; }
2094
+ const sessions = sm.list();
2095
+ const match = sessions.find(s => s.id.startsWith(prefix));
2096
+ if (!match) { log(`no running session matching '${prefix}'`); break; }
2097
+ log(`re-attaching to ${match.id.slice(0, 8)} (${match.tool})`);
2098
+ sm.attach(match.id);
2099
+ } else if (sub === "kill") {
2100
+ const prefix = args[1] || "";
2101
+ if (!prefix) { log("usage: 0dai terminal kill <session-id-prefix>"); break; }
2102
+ const all = Array.from(sm.sessions || []);
2103
+ // Kill by prefix match
2104
+ let found = false;
2105
+ for (const [id] of all) {
2106
+ if (id.startsWith(prefix)) { sm.kill(id); log(`killed ${id.slice(0, 8)}`); found = true; }
2107
+ }
2108
+ if (!found) log(`no session matching '${prefix}'`);
2068
2109
  } else {
2069
- console.log("Usage: 0dai terminal [launch|list] [--tool codex|claude|gemini]");
2110
+ console.log("Usage: 0dai terminal [launch|list|attach|kill] [--tool codex|claude|gemini|opencode|aider]");
2111
+ console.log(" 0dai terminal --tool opencode -- 'fix the auth bug'");
2070
2112
  }
2071
2113
  } catch (e) {
2072
- if (e.code === "MODULE_NOT_FOUND") log("install node-pty first: cd ~/.0dai && npm install node-pty");
2114
+ if (e.code === "MODULE_NOT_FOUND") log("install node-pty first: npm i -g node-pty");
2073
2115
  else log(`error: ${e.message}`);
2074
2116
  }
2075
2117
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0dai-dev/cli",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
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"