agent-dag 1.0.3 → 1.0.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.
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.
|
|
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,109 @@ if (!existsSync(WEB_DIST)) {
|
|
|
41
41
|
process.exit(1);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 IW = 38; // inner visible width between ║ chars
|
|
64
|
+
const pad = (visLen) => " ".repeat(Math.max(0, IW - visLen));
|
|
65
|
+
const HR = "═".repeat(IW);
|
|
66
|
+
|
|
67
|
+
// Each entry: [rendered string with ANSI, visible char count, left-border color, right-border color]
|
|
68
|
+
const rows = [
|
|
69
|
+
{ l: ` ${C.bCyan}${C.bold}◉${C.reset} ${C.white}${C.bold}agent-dag${C.reset} ${C.dim}v1.0.4${C.reset}`, vis: 22, lc: C.blue, rc: C.blue },
|
|
70
|
+
{ l: ` ${C.dim}live DAG · Claude Code agents${C.reset}`, vis: 31, lc: C.magenta, rc: C.magenta },
|
|
71
|
+
{ l: ` ${C.yellow}watch agents fork ${C.cyan}→${C.reset} ${C.green}tools fire${C.reset}`, vis: 34, lc: C.bMag, rc: C.bMag },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const lines = [
|
|
75
|
+
"",
|
|
76
|
+
` ${C.cyan}${C.bold}╔${HR}╗${C.reset}`,
|
|
77
|
+
...rows.map(r => ` ${r.lc}${C.bold}║${C.reset}${r.l}${pad(r.vis)}${r.rc}${C.bold}║${C.reset}`),
|
|
78
|
+
` ${C.cyan}${C.bold}╚${HR}╝${C.reset}`,
|
|
79
|
+
"",
|
|
80
|
+
];
|
|
81
|
+
for (const line of lines) {
|
|
82
|
+
process.stdout.write(line + "\n");
|
|
83
|
+
if (tty) await sleep(45);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ── Spinner ───────────────────────────────────────────────────────────────────
|
|
88
|
+
function spinner(label) {
|
|
89
|
+
if (!tty) { process.stdout.write(` … ${label}\n`); return { stop: (ok, msg) => process.stdout.write(` ${ok ? "✓" : "✗"} ${msg}\n`) }; }
|
|
90
|
+
const frames = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];
|
|
91
|
+
let i = 0;
|
|
92
|
+
const iv = setInterval(() => {
|
|
93
|
+
process.stdout.write(`\r ${C.cyan}${frames[i++ % frames.length]}${C.reset} ${label}`);
|
|
94
|
+
}, 80);
|
|
95
|
+
return {
|
|
96
|
+
stop(ok, msg) {
|
|
97
|
+
clearInterval(iv);
|
|
98
|
+
const icon = ok ? `${C.green}✓${C.reset}` : `${C.yellow}✗${C.reset}`;
|
|
99
|
+
process.stdout.write(`\r ${icon} ${msg}\n`);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
await printBanner();
|
|
51
105
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(" settings :", settingsPath);
|
|
106
|
+
// ── Startup steps ─────────────────────────────────────────────────────────────
|
|
107
|
+
process.stdout.write(` ${C.dim}workspace :${C.reset} ${workspace === "" ? C.yellow + "(all)" + C.reset : workspace}\n`);
|
|
55
108
|
|
|
109
|
+
let sp = spinner("installing hooks…");
|
|
110
|
+
const { settingsPath, hookPath } = await installHooks();
|
|
111
|
+
sp.stop(true, `hooks installed ${C.dim}→ ${hookPath}${C.reset}`);
|
|
112
|
+
|
|
113
|
+
sp = spinner("starting server…");
|
|
56
114
|
const server = await startServer({ port, persist }).catch(err => {
|
|
57
|
-
|
|
115
|
+
sp.stop(false, `server failed: ${err.message}`);
|
|
58
116
|
process.exit(1);
|
|
59
117
|
});
|
|
60
|
-
|
|
61
118
|
const addr = server.address();
|
|
62
119
|
const realPort = typeof addr === "object" && addr ? addr.port : port;
|
|
63
120
|
const url = `http://127.0.0.1:${realPort}`;
|
|
121
|
+
sp.stop(true, `server ready ${C.dim}→ ${C.reset}${C.bCyan}${C.bold}${url}${C.reset}`);
|
|
122
|
+
|
|
123
|
+
if (persist) process.stdout.write(` ${C.dim}log : ${persist}${C.reset}\n`);
|
|
124
|
+
|
|
125
|
+
process.stdout.write(`\n ${C.green}${C.bold}▶ opening browser…${C.reset}\n\n`);
|
|
64
126
|
|
|
65
127
|
const discoveryFile = await writeDiscovery({ port: realPort, workspace });
|
|
66
|
-
console.log(` url: ${url}`);
|
|
67
|
-
if (persist) console.log(` log: ${persist}`);
|
|
68
128
|
|
|
69
129
|
if (openBrowser) {
|
|
70
130
|
try {
|
|
71
131
|
const { default: open } = await import("open");
|
|
72
132
|
await open(url);
|
|
73
|
-
} catch {
|
|
74
|
-
|
|
75
|
-
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ── Pulse indicator ───────────────────────────────────────────────────────────
|
|
137
|
+
if (tty) {
|
|
138
|
+
const pulseFrames = [`${C.green}●${C.reset}`, `${C.dim}●${C.reset}`];
|
|
139
|
+
let pi = 0;
|
|
140
|
+
setInterval(() => {
|
|
141
|
+
process.stdout.write(`\r ${pulseFrames[pi++ % 2]} ${C.dim}listening — Ctrl+C to stop${C.reset} `);
|
|
142
|
+
}, 800).unref();
|
|
76
143
|
}
|
|
77
144
|
|
|
78
145
|
const shutdown = async () => {
|
|
146
|
+
if (tty) process.stdout.write(`\n\n ${C.yellow}◉ shutting down…${C.reset}\n`);
|
|
79
147
|
await removeDiscovery(discoveryFile);
|
|
80
148
|
server.close(() => process.exit(0));
|
|
81
149
|
setTimeout(() => process.exit(0), 1500).unref();
|
|
@@ -84,7 +152,7 @@ process.on("SIGINT", shutdown);
|
|
|
84
152
|
process.on("SIGTERM", shutdown);
|
|
85
153
|
process.on("beforeExit", () => removeDiscovery(discoveryFile));
|
|
86
154
|
|
|
87
|
-
//
|
|
155
|
+
// ── helpers ───────────────────────────────────────────────────────────────────
|
|
88
156
|
|
|
89
157
|
function parseArgs(args) {
|
|
90
158
|
const out = {};
|