agent-dag 1.0.5 → 1.0.7

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
@@ -24,7 +24,11 @@ if (flags.uninstall) {
24
24
  }
25
25
 
26
26
  const port = Number(flags.port ?? process.env.AGENT_DAG_PORT ?? 4317);
27
- const workspace = flags.all ? "" : (flags.workspace ?? process.cwd());
27
+ // Default = machine-wide (capture every CC session on this box). Pass
28
+ // `--workspace <path>` (or `--scope`) to restrict to a single tree.
29
+ const workspace = flags.workspace != null
30
+ ? flags.workspace
31
+ : (flags.scope ? process.cwd() : "");
28
32
  const openBrowser = flags.noOpen !== true;
29
33
  const persist = flags.noPersist
30
34
  ? null
@@ -163,7 +167,8 @@ function parseArgs(args) {
163
167
  else if (a === "--no-open") out.noOpen = true;
164
168
  else if (a === "--uninstall") out.uninstall = true;
165
169
  else if (a === "--workspace") out.workspace = args[++i];
166
- else if (a === "--all") out.all = true;
170
+ else if (a === "--scope") out.scope = true;
171
+ else if (a === "--all") out.all = true; // legacy no-op (now default)
167
172
  else if (a === "--no-persist") out.noPersist = true;
168
173
  else if (a === "--history") out.history = args[++i];
169
174
  }
@@ -179,8 +184,9 @@ Usage:
179
184
  Options:
180
185
  -p, --port <number> Preferred port (default: 4317; falls back to random 4318–4400)
181
186
  --no-open Don't open the browser automatically
182
- --workspace <path> Workspace root (default: cwd)
183
- --all Capture sessions from ALL workspaces (machine-wide)
187
+ --workspace <path> Only capture sessions whose cwd is inside <path>
188
+ --scope Restrict to current working directory
189
+ --all Capture every Claude Code session (default)
184
190
  --history <path> Override events log file (default: ~/.claude/agent-dag/events.jsonl)
185
191
  --no-persist Don't write or replay events log (RAM-only)
186
192
  --uninstall Remove agent-dag hook entries from ~/.claude/settings.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-dag",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Live DAG of Claude Code agents — watch parallel subagents fork, call tools, and return on one calm canvas.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,6 +29,12 @@ export const HOOK_EVENTS = [
29
29
  ];
30
30
 
31
31
  const MARK_KEY = "__agent-dag";
32
+ // Legacy marks from earlier names — purged on every install/uninstall so
33
+ // duplicate forwarders don't pile up when the project gets renamed.
34
+ const LEGACY_MARKS = ["__ccgraph", "__agent-flow"];
35
+ // ~/.claude/<name>/hook.js paths used by old releases. Any unmarked entry
36
+ // pointing into one of these is recognised as ours and removed.
37
+ const LEGACY_DIRS = ["ccgraph", "agent-flow", "agent-dag"];
32
38
 
33
39
  function hookCommand(installedHookPath) {
34
40
  // process.execPath = absolute path to current node (works on Win + *nix).
@@ -36,6 +42,21 @@ function hookCommand(installedHookPath) {
36
42
  return `"${node}" "${installedHookPath}"`;
37
43
  }
38
44
 
45
+ function isOurEntry(g) {
46
+ if (!g || typeof g !== "object") return false;
47
+ if (g[MARK_KEY] === true) return true;
48
+ for (const k of LEGACY_MARKS) if (g[k] === true) return true;
49
+ // Heuristic: command points at ~/.claude/<legacy-dir>/hook.js.
50
+ const cmds = Array.isArray(g.hooks) ? g.hooks : [];
51
+ for (const h of cmds) {
52
+ const c = typeof h?.command === "string" ? h.command : "";
53
+ for (const dir of LEGACY_DIRS) {
54
+ if (c.includes(`.claude/${dir}/hook.js`) || c.includes(`.claude\\${dir}\\hook.js`)) return true;
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+
39
60
  async function ensureDir(p) {
40
61
  if (!existsSync(p)) await mkdir(p, { recursive: true });
41
62
  }
@@ -61,7 +82,7 @@ function buildHookEntry(command) {
61
82
 
62
83
  function dedupeOurEntries(group) {
63
84
  if (!Array.isArray(group)) return [];
64
- return group.filter(g => !(g && typeof g === "object" && g[MARK_KEY] === true));
85
+ return group.filter(g => !isOurEntry(g));
65
86
  }
66
87
 
67
88
  export async function installHooks() {