agent-dag 1.0.3 → 1.0.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.
package/bin/agent-dag.js CHANGED
@@ -23,7 +23,7 @@ if (flags.uninstall) {
23
23
  process.exit(0);
24
24
  }
25
25
 
26
- const port = Number(flags.port ?? process.env.CCGRAPH_PORT ?? 4317);
26
+ const port = Number(flags.port ?? process.env.AGENT_DAG_PORT ?? 4317);
27
27
  const workspace = flags.all ? "" : (flags.workspace ?? process.cwd());
28
28
  const openBrowser = flags.noOpen !== true;
29
29
  const persist = flags.noPersist
@@ -41,41 +41,101 @@ if (!existsSync(WEB_DIST)) {
41
41
  process.exit(1);
42
42
  }
43
43
 
44
- console.log(`
45
- ╔══════════════════════════════════╗
46
- ║ ◉ agent-dag v1.0.3 ║
47
- ║ live DAG · Claude agents ║
48
- ╚══════════════════════════════════╝
49
- `);
50
- console.log(" workspace :", workspace === "" ? "(all)" : workspace);
44
+ // ── ANSI helpers ──────────────────────────────────────────────────────────────
45
+ const tty = process.stdout.isTTY;
46
+ const C = {
47
+ reset: tty ? "\x1b[0m" : "",
48
+ bold: tty ? "\x1b[1m" : "",
49
+ dim: tty ? "\x1b[2m" : "",
50
+ cyan: tty ? "\x1b[36m" : "",
51
+ blue: tty ? "\x1b[34m" : "",
52
+ magenta: tty ? "\x1b[35m" : "",
53
+ yellow: tty ? "\x1b[33m" : "",
54
+ green: tty ? "\x1b[32m" : "",
55
+ white: tty ? "\x1b[97m" : "",
56
+ bCyan: tty ? "\x1b[96m" : "",
57
+ bMag: tty ? "\x1b[95m" : "",
58
+ };
59
+ const sleep = ms => new Promise(r => setTimeout(r, ms));
60
+
61
+ // ── Animated banner ───────────────────────────────────────────────────────────
62
+ async function printBanner() {
63
+ const W = "══════════════════════════════════════";
64
+ const lines = [
65
+ "",
66
+ ` ${C.cyan}${C.bold}╔${W}╗${C.reset}`,
67
+ ` ${C.blue}${C.bold}║${C.reset} ${C.bCyan}${C.bold}◉ agent-dag${C.reset} ${C.dim}v1.0.4${C.reset} ${C.blue}${C.bold}║${C.reset}`,
68
+ ` ${C.magenta}${C.bold}║${C.reset} ${C.dim}live DAG · Claude Code agents${C.reset} ${C.magenta}${C.bold}║${C.reset}`,
69
+ ` ${C.bMag}${C.bold}║${C.reset} ${C.yellow}watch agents fork ${C.cyan}→${C.reset} ${C.green}tools fire${C.reset} ${C.bMag}${C.bold}║${C.reset}`,
70
+ ` ${C.cyan}${C.bold}╚${W}╝${C.reset}`,
71
+ "",
72
+ ];
73
+ for (const line of lines) {
74
+ process.stdout.write(line + "\n");
75
+ if (tty) await sleep(45);
76
+ }
77
+ }
78
+
79
+ // ── Spinner ───────────────────────────────────────────────────────────────────
80
+ function spinner(label) {
81
+ if (!tty) { process.stdout.write(` … ${label}\n`); return { stop: (ok, msg) => process.stdout.write(` ${ok ? "✓" : "✗"} ${msg}\n`) }; }
82
+ const frames = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];
83
+ let i = 0;
84
+ const iv = setInterval(() => {
85
+ process.stdout.write(`\r ${C.cyan}${frames[i++ % frames.length]}${C.reset} ${label}`);
86
+ }, 80);
87
+ return {
88
+ stop(ok, msg) {
89
+ clearInterval(iv);
90
+ const icon = ok ? `${C.green}✓${C.reset}` : `${C.yellow}✗${C.reset}`;
91
+ process.stdout.write(`\r ${icon} ${msg}\n`);
92
+ }
93
+ };
94
+ }
95
+
96
+ await printBanner();
51
97
 
52
- const { settingsPath, hookPath, events } = await installHooks();
53
- console.log(" hooks :", hookPath);
54
- console.log(" settings :", settingsPath);
98
+ // ── Startup steps ─────────────────────────────────────────────────────────────
99
+ process.stdout.write(` ${C.dim}workspace :${C.reset} ${workspace === "" ? C.yellow + "(all)" + C.reset : workspace}\n`);
55
100
 
101
+ let sp = spinner("installing hooks…");
102
+ const { settingsPath, hookPath } = await installHooks();
103
+ sp.stop(true, `hooks installed ${C.dim}→ ${hookPath}${C.reset}`);
104
+
105
+ sp = spinner("starting server…");
56
106
  const server = await startServer({ port, persist }).catch(err => {
57
- console.error("agent-dag: server failed:", err.message);
107
+ sp.stop(false, `server failed: ${err.message}`);
58
108
  process.exit(1);
59
109
  });
60
-
61
110
  const addr = server.address();
62
111
  const realPort = typeof addr === "object" && addr ? addr.port : port;
63
112
  const url = `http://127.0.0.1:${realPort}`;
113
+ sp.stop(true, `server ready ${C.dim}→ ${C.reset}${C.bCyan}${C.bold}${url}${C.reset}`);
114
+
115
+ if (persist) process.stdout.write(` ${C.dim}log : ${persist}${C.reset}\n`);
116
+
117
+ process.stdout.write(`\n ${C.green}${C.bold}▶ opening browser…${C.reset}\n\n`);
64
118
 
65
119
  const discoveryFile = await writeDiscovery({ port: realPort, workspace });
66
- console.log(` url: ${url}`);
67
- if (persist) console.log(` log: ${persist}`);
68
120
 
69
121
  if (openBrowser) {
70
122
  try {
71
123
  const { default: open } = await import("open");
72
124
  await open(url);
73
- } catch {
74
- // open is optional; user can navigate manually.
75
- }
125
+ } catch {}
126
+ }
127
+
128
+ // ── Pulse indicator ───────────────────────────────────────────────────────────
129
+ if (tty) {
130
+ const pulseFrames = [`${C.green}●${C.reset}`, `${C.dim}●${C.reset}`];
131
+ let pi = 0;
132
+ setInterval(() => {
133
+ process.stdout.write(`\r ${pulseFrames[pi++ % 2]} ${C.dim}listening — Ctrl+C to stop${C.reset} `);
134
+ }, 800).unref();
76
135
  }
77
136
 
78
137
  const shutdown = async () => {
138
+ if (tty) process.stdout.write(`\n\n ${C.yellow}◉ shutting down…${C.reset}\n`);
79
139
  await removeDiscovery(discoveryFile);
80
140
  server.close(() => process.exit(0));
81
141
  setTimeout(() => process.exit(0), 1500).unref();
@@ -84,7 +144,7 @@ process.on("SIGINT", shutdown);
84
144
  process.on("SIGTERM", shutdown);
85
145
  process.on("beforeExit", () => removeDiscovery(discoveryFile));
86
146
 
87
- // --- helpers ---
147
+ // ── helpers ───────────────────────────────────────────────────────────────────
88
148
 
89
149
  function parseArgs(args) {
90
150
  const out = {};