@deeplake/hivemind 0.7.30 → 0.7.32

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/bundle/cli.js CHANGED
@@ -17,21 +17,21 @@ __export(index_marker_store_exports, {
17
17
  hasFreshIndexMarker: () => hasFreshIndexMarker,
18
18
  writeIndexMarker: () => writeIndexMarker
19
19
  });
20
- import { existsSync as existsSync12, mkdirSync as mkdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
21
- import { join as join15 } from "node:path";
20
+ import { existsSync as existsSync14, mkdirSync as mkdirSync4, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "node:fs";
21
+ import { join as join17 } from "node:path";
22
22
  import { tmpdir } from "node:os";
23
23
  function getIndexMarkerDir() {
24
- return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join15(tmpdir(), "hivemind-deeplake-indexes");
24
+ return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join17(tmpdir(), "hivemind-deeplake-indexes");
25
25
  }
26
26
  function buildIndexMarkerPath(workspaceId, orgId, table, suffix) {
27
27
  const markerKey = [workspaceId, orgId, table, suffix].join("__").replace(/[^a-zA-Z0-9_.-]/g, "_");
28
- return join15(getIndexMarkerDir(), `${markerKey}.json`);
28
+ return join17(getIndexMarkerDir(), `${markerKey}.json`);
29
29
  }
30
30
  function hasFreshIndexMarker(markerPath) {
31
- if (!existsSync12(markerPath))
31
+ if (!existsSync14(markerPath))
32
32
  return false;
33
33
  try {
34
- const raw = JSON.parse(readFileSync9(markerPath, "utf-8"));
34
+ const raw = JSON.parse(readFileSync12(markerPath, "utf-8"));
35
35
  const updatedAt = raw.updatedAt ? new Date(raw.updatedAt).getTime() : NaN;
36
36
  if (!Number.isFinite(updatedAt) || Date.now() - updatedAt > INDEX_MARKER_TTL_MS)
37
37
  return false;
@@ -41,8 +41,8 @@ function hasFreshIndexMarker(markerPath) {
41
41
  }
42
42
  }
43
43
  function writeIndexMarker(markerPath) {
44
- mkdirSync3(getIndexMarkerDir(), { recursive: true });
45
- writeFileSync6(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
44
+ mkdirSync4(getIndexMarkerDir(), { recursive: true });
45
+ writeFileSync8(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
46
46
  }
47
47
  var INDEX_MARKER_TTL_MS;
48
48
  var init_index_marker_store = __esm({
@@ -488,31 +488,139 @@ function uninstallCodex() {
488
488
  }
489
489
 
490
490
  // dist/src/cli/install-openclaw.js
491
- import { existsSync as existsSync4, copyFileSync, rmSync } from "node:fs";
491
+ import { existsSync as existsSync5, copyFileSync, rmSync } from "node:fs";
492
+ import { join as join6 } from "node:path";
493
+
494
+ // dist/openclaw/src/setup-config.js
495
+ import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3, renameSync } from "node:fs";
496
+ import { homedir as homedir3 } from "node:os";
492
497
  import { join as join5 } from "node:path";
493
- var PLUGIN_DIR2 = join5(HOME, ".openclaw", "extensions", "hivemind");
498
+ var HIVEMIND_TOOL_NAMES = ["hivemind_search", "hivemind_read", "hivemind_index"];
499
+ function getOpenclawConfigPath() {
500
+ return join5(homedir3(), ".openclaw", "openclaw.json");
501
+ }
502
+ function isAllowlistCoveringHivemind(alsoAllow) {
503
+ if (!Array.isArray(alsoAllow))
504
+ return false;
505
+ for (const entry of alsoAllow) {
506
+ if (typeof entry !== "string")
507
+ continue;
508
+ const normalized = entry.trim().toLowerCase();
509
+ if (normalized === "hivemind")
510
+ return true;
511
+ if (normalized === "group:plugins")
512
+ return true;
513
+ if (HIVEMIND_TOOL_NAMES.includes(normalized))
514
+ return true;
515
+ }
516
+ return false;
517
+ }
518
+ function isPluginsAllowMissingHivemind(allow) {
519
+ return Array.isArray(allow) && allow.length > 0 && !allow.includes("hivemind");
520
+ }
521
+ function ensureHivemindAllowlisted() {
522
+ const configPath = getOpenclawConfigPath();
523
+ if (!existsSync4(configPath)) {
524
+ return { status: "error", configPath, error: "openclaw config file not found" };
525
+ }
526
+ let parsed;
527
+ try {
528
+ const raw = readFileSync5(configPath, "utf-8");
529
+ parsed = JSON.parse(raw);
530
+ } catch (e) {
531
+ return { status: "error", configPath, error: `could not read/parse config: ${e instanceof Error ? e.message : String(e)}` };
532
+ }
533
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
534
+ return { status: "error", configPath, error: "openclaw config is not a JSON object" };
535
+ }
536
+ const plugins = parsed.plugins ?? {};
537
+ const pluginsAllowRaw = plugins.allow;
538
+ const tools = parsed.tools ?? {};
539
+ const alsoAllowRaw = tools.alsoAllow;
540
+ const pluginsAllowNeedsPatch = isPluginsAllowMissingHivemind(pluginsAllowRaw);
541
+ const toolsAlsoAllowNeedsPatch = Array.isArray(alsoAllowRaw) && alsoAllowRaw.length > 0 && !isAllowlistCoveringHivemind(alsoAllowRaw);
542
+ if (!pluginsAllowNeedsPatch && !toolsAlsoAllowNeedsPatch) {
543
+ return { status: "already-set", configPath };
544
+ }
545
+ const updated = { ...parsed };
546
+ if (pluginsAllowNeedsPatch) {
547
+ updated.plugins = {
548
+ ...plugins,
549
+ // Cast safe — isPluginsAllowMissingHivemind guarantees Array.
550
+ allow: [...pluginsAllowRaw, "hivemind"]
551
+ };
552
+ }
553
+ if (toolsAlsoAllowNeedsPatch) {
554
+ updated.tools = {
555
+ ...tools,
556
+ // Cast safe — the needs-patch check above guarantees Array.
557
+ alsoAllow: [...alsoAllowRaw, "hivemind"]
558
+ };
559
+ }
560
+ const backupPath = `${configPath}.bak-hivemind-${Date.now()}`;
561
+ const tmpPath = `${configPath}.tmp-hivemind-${process.pid}`;
562
+ try {
563
+ writeFileSync3(backupPath, readFileSync5(configPath, "utf-8"));
564
+ writeFileSync3(tmpPath, JSON.stringify(updated, null, 2) + "\n");
565
+ renameSync(tmpPath, configPath);
566
+ } catch (e) {
567
+ return { status: "error", configPath, error: `could not write config: ${e instanceof Error ? e.message : String(e)}` };
568
+ }
569
+ return {
570
+ status: "added",
571
+ configPath,
572
+ backupPath,
573
+ delta: {
574
+ pluginsAllow: pluginsAllowNeedsPatch,
575
+ toolsAlsoAllow: toolsAlsoAllowNeedsPatch
576
+ }
577
+ };
578
+ }
579
+
580
+ // dist/src/cli/install-openclaw.js
581
+ var PLUGIN_DIR2 = join6(HOME, ".openclaw", "extensions", "hivemind");
494
582
  function installOpenclaw() {
495
- const srcDist = join5(pkgRoot(), "openclaw", "dist");
496
- const srcManifest = join5(pkgRoot(), "openclaw", "openclaw.plugin.json");
497
- const srcPkg = join5(pkgRoot(), "openclaw", "package.json");
498
- const srcSkills = join5(pkgRoot(), "openclaw", "skills");
499
- if (!existsSync4(srcDist)) {
583
+ const srcDist = join6(pkgRoot(), "openclaw", "dist");
584
+ const srcManifest = join6(pkgRoot(), "openclaw", "openclaw.plugin.json");
585
+ const srcPkg = join6(pkgRoot(), "openclaw", "package.json");
586
+ const srcSkills = join6(pkgRoot(), "openclaw", "skills");
587
+ if (!existsSync5(srcDist)) {
500
588
  throw new Error(`OpenClaw bundle missing at ${srcDist}. Run 'npm run build' first.`);
501
589
  }
502
590
  ensureDir(PLUGIN_DIR2);
503
- rmSync(join5(PLUGIN_DIR2, "dist"), { recursive: true, force: true });
504
- copyDir(srcDist, join5(PLUGIN_DIR2, "dist"));
505
- if (existsSync4(srcManifest))
506
- copyFileSync(srcManifest, join5(PLUGIN_DIR2, "openclaw.plugin.json"));
507
- if (existsSync4(srcPkg))
508
- copyFileSync(srcPkg, join5(PLUGIN_DIR2, "package.json"));
509
- if (existsSync4(srcSkills))
510
- copyDir(srcSkills, join5(PLUGIN_DIR2, "skills"));
591
+ rmSync(join6(PLUGIN_DIR2, "dist"), { recursive: true, force: true });
592
+ copyDir(srcDist, join6(PLUGIN_DIR2, "dist"));
593
+ if (existsSync5(srcManifest))
594
+ copyFileSync(srcManifest, join6(PLUGIN_DIR2, "openclaw.plugin.json"));
595
+ if (existsSync5(srcPkg))
596
+ copyFileSync(srcPkg, join6(PLUGIN_DIR2, "package.json"));
597
+ if (existsSync5(srcSkills))
598
+ copyDir(srcSkills, join6(PLUGIN_DIR2, "skills"));
511
599
  writeVersionStamp(PLUGIN_DIR2, getVersion());
512
600
  log(` OpenClaw installed -> ${PLUGIN_DIR2}`);
601
+ const result = ensureHivemindAllowlisted();
602
+ if (result.status === "added") {
603
+ const touched = [];
604
+ if (result.delta.pluginsAllow)
605
+ touched.push("plugins.allow");
606
+ if (result.delta.toolsAlsoAllow)
607
+ touched.push("tools.alsoAllow");
608
+ log(` OpenClaw patched ${touched.join(" + ")} in ${result.configPath}`);
609
+ log(` OpenClaw backup: ${result.backupPath}`);
610
+ log(` OpenClaw restart the gateway to activate: systemctl --user restart openclaw-gateway.service`);
611
+ log(` OpenClaw capture starts on the NEXT turn \u2014 earlier turns are NOT backfilled`);
612
+ } else if (result.status === "already-set") {
613
+ log(` OpenClaw allowlist already covers hivemind in ${result.configPath}`);
614
+ } else if (result.status === "error") {
615
+ if (result.error === "openclaw config file not found") {
616
+ log(` OpenClaw openclaw.json not present at ${result.configPath} \u2014 run openclaw once, then \`hivemind claw install\` again`);
617
+ } else {
618
+ warn(` OpenClaw could not patch allowlist in ${result.configPath}: ${result.error}`);
619
+ }
620
+ }
513
621
  }
514
622
  function uninstallOpenclaw() {
515
- if (existsSync4(PLUGIN_DIR2)) {
623
+ if (existsSync5(PLUGIN_DIR2)) {
516
624
  rmSync(PLUGIN_DIR2, { recursive: true, force: true });
517
625
  log(` OpenClaw removed ${PLUGIN_DIR2}`);
518
626
  } else {
@@ -521,23 +629,23 @@ function uninstallOpenclaw() {
521
629
  }
522
630
 
523
631
  // dist/src/cli/install-cursor.js
524
- import { existsSync as existsSync5, unlinkSync as unlinkSync3 } from "node:fs";
525
- import { join as join6 } from "node:path";
526
- var CURSOR_HOME = join6(HOME, ".cursor");
527
- var PLUGIN_DIR3 = join6(CURSOR_HOME, "hivemind");
528
- var HOOKS_PATH2 = join6(CURSOR_HOME, "hooks.json");
632
+ import { existsSync as existsSync6, unlinkSync as unlinkSync3 } from "node:fs";
633
+ import { join as join7 } from "node:path";
634
+ var CURSOR_HOME = join7(HOME, ".cursor");
635
+ var PLUGIN_DIR3 = join7(CURSOR_HOME, "hivemind");
636
+ var HOOKS_PATH2 = join7(CURSOR_HOME, "hooks.json");
529
637
  var HIVEMIND_MARKER_KEY = "_hivemindManaged";
530
638
  function buildHookCmd(bundleFile, timeout) {
531
639
  return {
532
640
  type: "command",
533
- command: `node "${join6(PLUGIN_DIR3, "bundle", bundleFile)}"`,
641
+ command: `node "${join7(PLUGIN_DIR3, "bundle", bundleFile)}"`,
534
642
  timeout
535
643
  };
536
644
  }
537
645
  function buildHookCmdShellMatcher(bundleFile, timeout) {
538
646
  return {
539
647
  type: "command",
540
- command: `node "${join6(PLUGIN_DIR3, "bundle", bundleFile)}"`,
648
+ command: `node "${join7(PLUGIN_DIR3, "bundle", bundleFile)}"`,
541
649
  timeout,
542
650
  matcher: "Shell"
543
651
  };
@@ -593,12 +701,12 @@ function stripHooksFromConfig(existing) {
593
701
  return existing;
594
702
  }
595
703
  function installCursor() {
596
- const srcBundle = join6(pkgRoot(), "cursor", "bundle");
597
- if (!existsSync5(srcBundle)) {
704
+ const srcBundle = join7(pkgRoot(), "cursor", "bundle");
705
+ if (!existsSync6(srcBundle)) {
598
706
  throw new Error(`Cursor bundle missing at ${srcBundle}. Run 'npm run build' first.`);
599
707
  }
600
708
  ensureDir(PLUGIN_DIR3);
601
- copyDir(srcBundle, join6(PLUGIN_DIR3, "bundle"));
709
+ copyDir(srcBundle, join7(PLUGIN_DIR3, "bundle"));
602
710
  const existing = readJson(HOOKS_PATH2);
603
711
  const merged = mergeHooks2(existing);
604
712
  writeJson(HOOKS_PATH2, merged);
@@ -614,7 +722,7 @@ function uninstallCursor() {
614
722
  const stripped = stripHooksFromConfig(existing);
615
723
  const meaningfulKeys = stripped ? Object.keys(stripped).filter((k) => k !== "version").length : 0;
616
724
  if (!stripped || meaningfulKeys === 0) {
617
- if (existsSync5(HOOKS_PATH2))
725
+ if (existsSync6(HOOKS_PATH2))
618
726
  unlinkSync3(HOOKS_PATH2);
619
727
  } else {
620
728
  writeJson(HOOKS_PATH2, stripped);
@@ -623,8 +731,8 @@ function uninstallCursor() {
623
731
  }
624
732
 
625
733
  // dist/src/cli/install-hermes.js
626
- import { existsSync as existsSync7, writeFileSync as writeFileSync3, readFileSync as readFileSync5, rmSync as rmSync2, unlinkSync as unlinkSync4 } from "node:fs";
627
- import { join as join8 } from "node:path";
734
+ import { existsSync as existsSync8, writeFileSync as writeFileSync4, readFileSync as readFileSync6, rmSync as rmSync2, unlinkSync as unlinkSync4 } from "node:fs";
735
+ import { join as join9 } from "node:path";
628
736
 
629
737
  // node_modules/js-yaml/dist/js-yaml.mjs
630
738
  function isNothing(subject) {
@@ -3213,15 +3321,15 @@ var safeLoadAll = renamed("safeLoadAll", "loadAll");
3213
3321
  var safeDump = renamed("safeDump", "dump");
3214
3322
 
3215
3323
  // dist/src/cli/install-mcp-shared.js
3216
- import { existsSync as existsSync6 } from "node:fs";
3217
- import { join as join7 } from "node:path";
3218
- var HIVEMIND_DIR = join7(HOME, ".hivemind");
3219
- var MCP_DIR = join7(HIVEMIND_DIR, "mcp");
3220
- var MCP_SERVER_PATH = join7(MCP_DIR, "server.js");
3221
- var MCP_PACKAGE_JSON = join7(MCP_DIR, "package.json");
3324
+ import { existsSync as existsSync7 } from "node:fs";
3325
+ import { join as join8 } from "node:path";
3326
+ var HIVEMIND_DIR = join8(HOME, ".hivemind");
3327
+ var MCP_DIR = join8(HIVEMIND_DIR, "mcp");
3328
+ var MCP_SERVER_PATH = join8(MCP_DIR, "server.js");
3329
+ var MCP_PACKAGE_JSON = join8(MCP_DIR, "package.json");
3222
3330
  function ensureMcpServerInstalled() {
3223
- const srcDir = join7(pkgRoot(), "mcp", "bundle");
3224
- if (!existsSync6(srcDir)) {
3331
+ const srcDir = join8(pkgRoot(), "mcp", "bundle");
3332
+ if (!existsSync7(srcDir)) {
3225
3333
  throw new Error(`MCP server bundle missing at ${srcDir}. Run 'npm run build' to produce it before installing Tier B consumers.`);
3226
3334
  }
3227
3335
  ensureDir(MCP_DIR);
@@ -3231,11 +3339,11 @@ function ensureMcpServerInstalled() {
3231
3339
  }
3232
3340
 
3233
3341
  // dist/src/cli/install-hermes.js
3234
- var HERMES_HOME = join8(HOME, ".hermes");
3235
- var SKILLS_DIR = join8(HERMES_HOME, "skills", "hivemind-memory");
3236
- var HIVEMIND_DIR2 = join8(HERMES_HOME, "hivemind");
3237
- var BUNDLE_DIR = join8(HIVEMIND_DIR2, "bundle");
3238
- var CONFIG_PATH = join8(HERMES_HOME, "config.yaml");
3342
+ var HERMES_HOME = join9(HOME, ".hermes");
3343
+ var SKILLS_DIR = join9(HERMES_HOME, "skills", "hivemind-memory");
3344
+ var HIVEMIND_DIR2 = join9(HERMES_HOME, "hivemind");
3345
+ var BUNDLE_DIR = join9(HIVEMIND_DIR2, "bundle");
3346
+ var CONFIG_PATH = join9(HERMES_HOME, "config.yaml");
3239
3347
  var SERVER_KEY = "hivemind";
3240
3348
  var SKILL_BODY = `---
3241
3349
  name: hivemind-memory
@@ -3293,7 +3401,7 @@ function isHivemindHook(entry) {
3293
3401
  }
3294
3402
  function buildHookEntry(bundleFile, timeout, matcher) {
3295
3403
  const entry = {
3296
- command: `node ${join8(BUNDLE_DIR, bundleFile)}`,
3404
+ command: `node ${join9(BUNDLE_DIR, bundleFile)}`,
3297
3405
  timeout
3298
3406
  };
3299
3407
  if (matcher)
@@ -3337,10 +3445,10 @@ function stripHivemindHooks(existing) {
3337
3445
  return Object.keys(out).length > 0 ? out : void 0;
3338
3446
  }
3339
3447
  function readConfig() {
3340
- if (!existsSync7(CONFIG_PATH))
3448
+ if (!existsSync8(CONFIG_PATH))
3341
3449
  return {};
3342
3450
  try {
3343
- const raw = readFileSync5(CONFIG_PATH, "utf-8");
3451
+ const raw = readFileSync6(CONFIG_PATH, "utf-8");
3344
3452
  const parsed = load(raw);
3345
3453
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
3346
3454
  return parsed;
@@ -3353,15 +3461,15 @@ function readConfig() {
3353
3461
  function writeConfig(cfg) {
3354
3462
  ensureDir(HERMES_HOME);
3355
3463
  const dumped = dump(cfg, { lineWidth: 100, noRefs: true });
3356
- writeFileSync3(CONFIG_PATH, dumped);
3464
+ writeFileSync4(CONFIG_PATH, dumped);
3357
3465
  }
3358
3466
  function installHermes() {
3359
3467
  ensureDir(SKILLS_DIR);
3360
- writeFileSync3(join8(SKILLS_DIR, "SKILL.md"), SKILL_BODY);
3468
+ writeFileSync4(join9(SKILLS_DIR, "SKILL.md"), SKILL_BODY);
3361
3469
  writeVersionStamp(SKILLS_DIR, getVersion());
3362
3470
  log(` Hermes skill installed -> ${SKILLS_DIR}`);
3363
- const srcBundle = join8(pkgRoot(), "hermes", "bundle");
3364
- if (!existsSync7(srcBundle)) {
3471
+ const srcBundle = join9(pkgRoot(), "hermes", "bundle");
3472
+ if (!existsSync8(srcBundle)) {
3365
3473
  throw new Error(`Hermes bundle missing at ${srcBundle}. Run 'npm run build' first.`);
3366
3474
  }
3367
3475
  ensureDir(HIVEMIND_DIR2);
@@ -3382,15 +3490,15 @@ function installHermes() {
3382
3490
  log(` Hermes config updated -> ${CONFIG_PATH} (mcp_servers + hooks + hooks_auto_accept)`);
3383
3491
  }
3384
3492
  function uninstallHermes() {
3385
- if (existsSync7(SKILLS_DIR)) {
3493
+ if (existsSync8(SKILLS_DIR)) {
3386
3494
  rmSync2(SKILLS_DIR, { recursive: true, force: true });
3387
3495
  log(` Hermes removed ${SKILLS_DIR}`);
3388
3496
  }
3389
- if (existsSync7(HIVEMIND_DIR2)) {
3497
+ if (existsSync8(HIVEMIND_DIR2)) {
3390
3498
  rmSync2(HIVEMIND_DIR2, { recursive: true, force: true });
3391
3499
  log(` Hermes removed ${HIVEMIND_DIR2}`);
3392
3500
  }
3393
- if (existsSync7(CONFIG_PATH)) {
3501
+ if (existsSync8(CONFIG_PATH)) {
3394
3502
  const cfg = readConfig();
3395
3503
  let touched = false;
3396
3504
  if (cfg.mcp_servers && typeof cfg.mcp_servers === "object" && SERVER_KEY in cfg.mcp_servers) {
@@ -3423,18 +3531,18 @@ function uninstallHermes() {
3423
3531
  }
3424
3532
 
3425
3533
  // dist/src/cli/install-pi.js
3426
- import { existsSync as existsSync8, writeFileSync as writeFileSync4, rmSync as rmSync3, readFileSync as readFileSync6, copyFileSync as copyFileSync2 } from "node:fs";
3427
- import { join as join9 } from "node:path";
3428
- var PI_AGENT_DIR = join9(HOME, ".pi", "agent");
3429
- var AGENTS_MD = join9(PI_AGENT_DIR, "AGENTS.md");
3430
- var LEGACY_SKILL_DIR = join9(PI_AGENT_DIR, "skills", "hivemind-memory");
3431
- var EXTENSIONS_DIR = join9(PI_AGENT_DIR, "extensions");
3432
- var EXTENSION_PATH = join9(EXTENSIONS_DIR, "hivemind.ts");
3433
- var VERSION_DIR = join9(PI_AGENT_DIR, ".hivemind");
3434
- var WIKI_WORKER_DIR = join9(PI_AGENT_DIR, "hivemind");
3435
- var WIKI_WORKER_PATH = join9(WIKI_WORKER_DIR, "wiki-worker.js");
3436
- var SKILLIFY_WORKER_PATH = join9(WIKI_WORKER_DIR, "skillify-worker.js");
3437
- var AUTOPULL_WORKER_PATH = join9(WIKI_WORKER_DIR, "autopull-worker.js");
3534
+ import { existsSync as existsSync9, writeFileSync as writeFileSync5, rmSync as rmSync3, readFileSync as readFileSync7, copyFileSync as copyFileSync2 } from "node:fs";
3535
+ import { join as join10 } from "node:path";
3536
+ var PI_AGENT_DIR = join10(HOME, ".pi", "agent");
3537
+ var AGENTS_MD = join10(PI_AGENT_DIR, "AGENTS.md");
3538
+ var LEGACY_SKILL_DIR = join10(PI_AGENT_DIR, "skills", "hivemind-memory");
3539
+ var EXTENSIONS_DIR = join10(PI_AGENT_DIR, "extensions");
3540
+ var EXTENSION_PATH = join10(EXTENSIONS_DIR, "hivemind.ts");
3541
+ var VERSION_DIR = join10(PI_AGENT_DIR, ".hivemind");
3542
+ var WIKI_WORKER_DIR = join10(PI_AGENT_DIR, "hivemind");
3543
+ var WIKI_WORKER_PATH = join10(WIKI_WORKER_DIR, "wiki-worker.js");
3544
+ var SKILLIFY_WORKER_PATH = join10(WIKI_WORKER_DIR, "skillify-worker.js");
3545
+ var AUTOPULL_WORKER_PATH = join10(WIKI_WORKER_DIR, "autopull-worker.js");
3438
3546
  var HIVEMIND_BLOCK_START = "<!-- BEGIN hivemind-memory -->";
3439
3547
  var HIVEMIND_BLOCK_END = "<!-- END hivemind-memory -->";
3440
3548
  var HIVEMIND_BLOCK_BODY = `${HIVEMIND_BLOCK_START}
@@ -3502,30 +3610,30 @@ ${after}`;
3502
3610
  }
3503
3611
  function installPi() {
3504
3612
  ensureDir(PI_AGENT_DIR);
3505
- if (existsSync8(LEGACY_SKILL_DIR)) {
3613
+ if (existsSync9(LEGACY_SKILL_DIR)) {
3506
3614
  rmSync3(LEGACY_SKILL_DIR, { recursive: true, force: true });
3507
3615
  }
3508
- const prior = existsSync8(AGENTS_MD) ? readFileSync6(AGENTS_MD, "utf-8") : null;
3616
+ const prior = existsSync9(AGENTS_MD) ? readFileSync7(AGENTS_MD, "utf-8") : null;
3509
3617
  const next = upsertHivemindBlock(prior);
3510
- writeFileSync4(AGENTS_MD, next);
3511
- const srcExtension = join9(pkgRoot(), "pi", "extension-source", "hivemind.ts");
3512
- if (!existsSync8(srcExtension)) {
3618
+ writeFileSync5(AGENTS_MD, next);
3619
+ const srcExtension = join10(pkgRoot(), "pi", "extension-source", "hivemind.ts");
3620
+ if (!existsSync9(srcExtension)) {
3513
3621
  throw new Error(`pi extension source missing at ${srcExtension}. Reinstall the @deeplake/hivemind package.`);
3514
3622
  }
3515
3623
  ensureDir(EXTENSIONS_DIR);
3516
3624
  copyFileSync2(srcExtension, EXTENSION_PATH);
3517
- const srcWorker = join9(pkgRoot(), "pi", "bundle", "wiki-worker.js");
3518
- if (existsSync8(srcWorker)) {
3625
+ const srcWorker = join10(pkgRoot(), "pi", "bundle", "wiki-worker.js");
3626
+ if (existsSync9(srcWorker)) {
3519
3627
  ensureDir(WIKI_WORKER_DIR);
3520
3628
  copyFileSync2(srcWorker, WIKI_WORKER_PATH);
3521
3629
  }
3522
- const srcSkillifyWorker = join9(pkgRoot(), "pi", "bundle", "skillify-worker.js");
3523
- if (existsSync8(srcSkillifyWorker)) {
3630
+ const srcSkillifyWorker = join10(pkgRoot(), "pi", "bundle", "skillify-worker.js");
3631
+ if (existsSync9(srcSkillifyWorker)) {
3524
3632
  ensureDir(WIKI_WORKER_DIR);
3525
3633
  copyFileSync2(srcSkillifyWorker, SKILLIFY_WORKER_PATH);
3526
3634
  }
3527
- const srcAutopullWorker = join9(pkgRoot(), "pi", "bundle", "autopull-worker.js");
3528
- if (existsSync8(srcAutopullWorker)) {
3635
+ const srcAutopullWorker = join10(pkgRoot(), "pi", "bundle", "autopull-worker.js");
3636
+ if (existsSync9(srcAutopullWorker)) {
3529
3637
  ensureDir(WIKI_WORKER_DIR);
3530
3638
  copyFileSync2(srcAutopullWorker, AUTOPULL_WORKER_PATH);
3531
3639
  }
@@ -3533,82 +3641,177 @@ function installPi() {
3533
3641
  writeVersionStamp(VERSION_DIR, getVersion());
3534
3642
  log(` pi AGENTS.md updated -> ${AGENTS_MD}`);
3535
3643
  log(` pi extension installed -> ${EXTENSION_PATH}`);
3536
- if (existsSync8(WIKI_WORKER_PATH)) {
3644
+ if (existsSync9(WIKI_WORKER_PATH)) {
3537
3645
  log(` pi wiki-worker installed -> ${WIKI_WORKER_PATH}`);
3538
3646
  }
3539
- if (existsSync8(SKILLIFY_WORKER_PATH)) {
3647
+ if (existsSync9(SKILLIFY_WORKER_PATH)) {
3540
3648
  log(` pi skillify-worker installed -> ${SKILLIFY_WORKER_PATH}`);
3541
3649
  }
3542
- if (existsSync8(AUTOPULL_WORKER_PATH)) {
3650
+ if (existsSync9(AUTOPULL_WORKER_PATH)) {
3543
3651
  log(` pi autopull-worker installed -> ${AUTOPULL_WORKER_PATH}`);
3544
3652
  }
3545
3653
  }
3546
3654
  function uninstallPi() {
3547
- if (existsSync8(LEGACY_SKILL_DIR)) {
3655
+ if (existsSync9(LEGACY_SKILL_DIR)) {
3548
3656
  rmSync3(LEGACY_SKILL_DIR, { recursive: true, force: true });
3549
3657
  log(` pi removed ${LEGACY_SKILL_DIR}`);
3550
3658
  }
3551
- if (existsSync8(EXTENSION_PATH)) {
3659
+ if (existsSync9(EXTENSION_PATH)) {
3552
3660
  rmSync3(EXTENSION_PATH, { force: true });
3553
3661
  log(` pi removed extension ${EXTENSION_PATH}`);
3554
3662
  }
3555
- if (existsSync8(WIKI_WORKER_DIR)) {
3663
+ if (existsSync9(WIKI_WORKER_DIR)) {
3556
3664
  rmSync3(WIKI_WORKER_DIR, { recursive: true, force: true });
3557
3665
  log(` pi removed wiki-worker dir ${WIKI_WORKER_DIR}`);
3558
3666
  }
3559
- if (existsSync8(AGENTS_MD)) {
3560
- const prior = readFileSync6(AGENTS_MD, "utf-8");
3667
+ if (existsSync9(AGENTS_MD)) {
3668
+ const prior = readFileSync7(AGENTS_MD, "utf-8");
3561
3669
  const stripped = stripHivemindBlock(prior);
3562
3670
  if (stripped.trim().length === 0) {
3563
3671
  rmSync3(AGENTS_MD, { force: true });
3564
3672
  log(` pi removed empty ${AGENTS_MD}`);
3565
3673
  } else {
3566
- writeFileSync4(AGENTS_MD, stripped);
3674
+ writeFileSync5(AGENTS_MD, stripped);
3567
3675
  log(` pi stripped hivemind block from ${AGENTS_MD}`);
3568
3676
  }
3569
3677
  }
3570
- if (existsSync8(VERSION_DIR)) {
3678
+ if (existsSync9(VERSION_DIR)) {
3571
3679
  rmSync3(VERSION_DIR, { recursive: true, force: true });
3572
3680
  }
3573
3681
  }
3574
3682
 
3575
3683
  // dist/src/cli/embeddings.js
3576
- import { copyFileSync as copyFileSync3, chmodSync, existsSync as existsSync9, lstatSync as lstatSync2, readdirSync, readlinkSync, rmSync as rmSync4, statSync, unlinkSync as unlinkSync5 } from "node:fs";
3577
- import { execFileSync as execFileSync3 } from "node:child_process";
3578
- import { join as join10 } from "node:path";
3579
- var SHARED_DIR = join10(HOME, ".hivemind", "embed-deps");
3580
- var SHARED_NODE_MODULES = join10(SHARED_DIR, "node_modules");
3581
- var SHARED_DAEMON_PATH = join10(SHARED_DIR, "embed-daemon.js");
3684
+ import { copyFileSync as copyFileSync3, chmodSync, existsSync as existsSync11, lstatSync as lstatSync2, readdirSync, readFileSync as readFileSync9, readlinkSync, rmSync as rmSync4, statSync, unlinkSync as unlinkSync5 } from "node:fs";
3685
+ import { execFileSync as execFileSync3, spawnSync } from "node:child_process";
3686
+ import { userInfo } from "node:os";
3687
+ import { join as join12 } from "node:path";
3688
+
3689
+ // dist/src/embeddings/protocol.js
3690
+ var DEFAULT_SOCKET_DIR = "/tmp";
3691
+ var DEFAULT_IDLE_TIMEOUT_MS = 10 * 60 * 1e3;
3692
+ function socketPathFor(uid, dir = DEFAULT_SOCKET_DIR) {
3693
+ return `${dir}/hivemind-embed-${uid}.sock`;
3694
+ }
3695
+ function pidPathFor(uid, dir = DEFAULT_SOCKET_DIR) {
3696
+ return `${dir}/hivemind-embed-${uid}.pid`;
3697
+ }
3698
+
3699
+ // dist/src/user-config.js
3700
+ import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as readFileSync8, renameSync as renameSync2, writeFileSync as writeFileSync6 } from "node:fs";
3701
+ import { homedir as homedir4 } from "node:os";
3702
+ import { dirname as dirname2, join as join11 } from "node:path";
3703
+ var _configPath = () => process.env.HIVEMIND_CONFIG_PATH ?? join11(homedir4(), ".deeplake", "config.json");
3704
+ var _cache = null;
3705
+ var _migrated = false;
3706
+ function readUserConfig() {
3707
+ if (_cache !== null)
3708
+ return _cache;
3709
+ const path = _configPath();
3710
+ if (!existsSync10(path)) {
3711
+ _cache = {};
3712
+ return _cache;
3713
+ }
3714
+ try {
3715
+ const raw = readFileSync8(path, "utf-8");
3716
+ const parsed = JSON.parse(raw);
3717
+ _cache = isPlainObject(parsed) ? parsed : {};
3718
+ } catch {
3719
+ _cache = {};
3720
+ }
3721
+ return _cache;
3722
+ }
3723
+ function writeUserConfig(patch) {
3724
+ const current = readUserConfig();
3725
+ const merged = deepMerge(current, patch);
3726
+ const path = _configPath();
3727
+ const dir = dirname2(path);
3728
+ if (!existsSync10(dir))
3729
+ mkdirSync2(dir, { recursive: true });
3730
+ const tmp = `${path}.tmp.${process.pid}`;
3731
+ writeFileSync6(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
3732
+ renameSync2(tmp, path);
3733
+ _cache = merged;
3734
+ return merged;
3735
+ }
3736
+ function getEmbeddingsEnabled() {
3737
+ const cfg = readUserConfig();
3738
+ if (cfg.embeddings && typeof cfg.embeddings.enabled === "boolean") {
3739
+ return cfg.embeddings.enabled;
3740
+ }
3741
+ if (_migrated) {
3742
+ return migrationValueFromEnv();
3743
+ }
3744
+ _migrated = true;
3745
+ const enabled = migrationValueFromEnv();
3746
+ try {
3747
+ writeUserConfig({ embeddings: { enabled } });
3748
+ } catch {
3749
+ _cache = { ...cfg ?? {}, embeddings: { ...cfg?.embeddings ?? {}, enabled } };
3750
+ }
3751
+ return enabled;
3752
+ }
3753
+ function migrationValueFromEnv() {
3754
+ const raw = process.env.HIVEMIND_EMBEDDINGS;
3755
+ if (raw === void 0)
3756
+ return false;
3757
+ if (raw === "false")
3758
+ return false;
3759
+ return true;
3760
+ }
3761
+ function setEmbeddingsEnabled(enabled) {
3762
+ writeUserConfig({ embeddings: { enabled } });
3763
+ }
3764
+ function isPlainObject(value) {
3765
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3766
+ }
3767
+ function deepMerge(base, patch) {
3768
+ const out = { ...base };
3769
+ for (const key of Object.keys(patch)) {
3770
+ const patchVal = patch[key];
3771
+ const baseVal = base[key];
3772
+ if (isPlainObject(patchVal) && isPlainObject(baseVal)) {
3773
+ out[key] = { ...baseVal, ...patchVal };
3774
+ } else if (patchVal !== void 0) {
3775
+ out[key] = patchVal;
3776
+ }
3777
+ }
3778
+ return out;
3779
+ }
3780
+
3781
+ // dist/src/cli/embeddings.js
3782
+ var SHARED_DIR = join12(HOME, ".hivemind", "embed-deps");
3783
+ var SHARED_NODE_MODULES = join12(SHARED_DIR, "node_modules");
3784
+ var SHARED_DAEMON_PATH = join12(SHARED_DIR, "embed-daemon.js");
3582
3785
  var TRANSFORMERS_PKG = "@huggingface/transformers";
3583
3786
  var TRANSFORMERS_RANGE = "^3.0.0";
3584
3787
  function findHivemindInstalls(home = HOME) {
3585
3788
  const out = [];
3586
3789
  const fixed = [
3587
- { id: "codex", pluginDir: join10(home, ".codex", "hivemind") },
3588
- { id: "cursor", pluginDir: join10(home, ".cursor", "hivemind") },
3589
- { id: "hermes", pluginDir: join10(home, ".hermes", "hivemind") }
3790
+ { id: "codex", pluginDir: join12(home, ".codex", "hivemind") },
3791
+ { id: "cursor", pluginDir: join12(home, ".cursor", "hivemind") },
3792
+ { id: "hermes", pluginDir: join12(home, ".hermes", "hivemind") }
3590
3793
  ];
3591
3794
  for (const inst of fixed) {
3592
- if (existsSync9(join10(inst.pluginDir, "bundle")))
3795
+ if (existsSync11(join12(inst.pluginDir, "bundle")))
3593
3796
  out.push(inst);
3594
3797
  }
3595
- const ccCache = join10(home, ".claude", "plugins", "cache", "hivemind", "hivemind");
3596
- if (existsSync9(ccCache)) {
3798
+ const ccCache = join12(home, ".claude", "plugins", "cache", "hivemind", "hivemind");
3799
+ if (existsSync11(ccCache)) {
3597
3800
  let entries = [];
3598
3801
  try {
3599
3802
  entries = readdirSync(ccCache);
3600
3803
  } catch {
3601
3804
  }
3602
3805
  for (const ver of entries) {
3603
- const dir = join10(ccCache, ver);
3806
+ const dir = join12(ccCache, ver);
3604
3807
  try {
3605
3808
  if (!statSync(dir).isDirectory())
3606
3809
  continue;
3607
3810
  } catch {
3608
3811
  continue;
3609
3812
  }
3610
- const candidates = [join10(dir, "bundle"), join10(dir, "claude-code", "bundle")];
3611
- if (candidates.some((p) => existsSync9(p))) {
3813
+ const candidates = [join12(dir, "bundle"), join12(dir, "claude-code", "bundle")];
3814
+ if (candidates.some((p) => existsSync11(p))) {
3612
3815
  out.push({ id: `claude (${ver})`, pluginDir: dir });
3613
3816
  }
3614
3817
  }
@@ -3616,10 +3819,10 @@ function findHivemindInstalls(home = HOME) {
3616
3819
  return out;
3617
3820
  }
3618
3821
  function isSharedDepsInstalled(sharedNodeModules = SHARED_NODE_MODULES) {
3619
- return existsSync9(join10(sharedNodeModules, TRANSFORMERS_PKG));
3822
+ return existsSync11(join12(sharedNodeModules, TRANSFORMERS_PKG));
3620
3823
  }
3621
3824
  function isSymlinkToSharedDeps(linkPath, sharedNodeModules) {
3622
- if (!existsSync9(linkPath))
3825
+ if (!existsSync11(linkPath))
3623
3826
  return false;
3624
3827
  try {
3625
3828
  if (!lstatSync2(linkPath).isSymbolicLink())
@@ -3630,8 +3833,8 @@ function isSymlinkToSharedDeps(linkPath, sharedNodeModules) {
3630
3833
  }
3631
3834
  }
3632
3835
  function linkStateFor(install, sharedNodeModules = SHARED_NODE_MODULES) {
3633
- const link = join10(install.pluginDir, "node_modules");
3634
- if (!existsSync9(link) && !isSymbolicLink(link))
3836
+ const link = join12(install.pluginDir, "node_modules");
3837
+ if (!existsSync11(link) && !isSymbolicLink(link))
3635
3838
  return { kind: "no-node-modules" };
3636
3839
  try {
3637
3840
  if (lstatSync2(link).isSymbolicLink()) {
@@ -3655,7 +3858,7 @@ function ensureSharedDeps() {
3655
3858
  log(` Embeddings installing ${TRANSFORMERS_PKG}@${TRANSFORMERS_RANGE} into ${SHARED_DIR}`);
3656
3859
  log(` (~600 MB; first install only \u2014 every agent will share this)`);
3657
3860
  ensureDir(SHARED_DIR);
3658
- writeJson(join10(SHARED_DIR, "package.json"), {
3861
+ writeJson(join12(SHARED_DIR, "package.json"), {
3659
3862
  name: "hivemind-embed-deps",
3660
3863
  version: "1.0.0",
3661
3864
  private: true,
@@ -3669,8 +3872,8 @@ function ensureSharedDeps() {
3669
3872
  log(` Embeddings shared deps already present at ${SHARED_DIR}`);
3670
3873
  }
3671
3874
  ensureDir(SHARED_DIR);
3672
- const src = join10(pkgRoot(), "embeddings", "embed-daemon.js");
3673
- if (existsSync9(src)) {
3875
+ const src = join12(pkgRoot(), "embeddings", "embed-daemon.js");
3876
+ if (existsSync11(src)) {
3674
3877
  copyFileSync3(src, SHARED_DAEMON_PATH);
3675
3878
  chmodSync(SHARED_DAEMON_PATH, 493);
3676
3879
  } else {
@@ -3678,40 +3881,115 @@ function ensureSharedDeps() {
3678
3881
  }
3679
3882
  }
3680
3883
  function linkAgent(install) {
3681
- const link = join10(install.pluginDir, "node_modules");
3884
+ const link = join12(install.pluginDir, "node_modules");
3885
+ const state = linkStateFor(install);
3886
+ if (state.kind === "owns-own-node-modules") {
3887
+ warn(` Embeddings ${install.id.padEnd(20)} owns its own node_modules \u2014 skipping symlink (status: owns-own-node-modules)`);
3888
+ return;
3889
+ }
3682
3890
  symlinkForce(SHARED_NODE_MODULES, link);
3683
3891
  log(` Embeddings linked ${install.id.padEnd(20)} -> shared deps`);
3684
3892
  }
3685
- function enableEmbeddings() {
3893
+ function installEmbeddings() {
3686
3894
  ensureSharedDeps();
3687
3895
  const installs = findHivemindInstalls();
3688
3896
  if (installs.length === 0) {
3689
3897
  warn(" Embeddings no hivemind installs detected \u2014 run `hivemind install` first");
3690
3898
  warn(" (the shared deps are in place; subsequent agent installs will pick them up if you re-run `hivemind embeddings install`)");
3691
- return;
3899
+ } else {
3900
+ for (const inst of installs)
3901
+ linkAgent(inst);
3692
3902
  }
3693
- for (const inst of installs)
3694
- linkAgent(inst);
3695
- log(` Embeddings enabled. Restart your agents to pick up.`);
3903
+ setEmbeddingsEnabled(true);
3904
+ log(` Embeddings enabled in ~/.deeplake/config.json`);
3905
+ log(` Embeddings ready. Restart your agents to pick up.`);
3696
3906
  }
3697
- function disableEmbeddings(opts) {
3907
+ function enableEmbeddings() {
3908
+ setEmbeddingsEnabled(true);
3909
+ log(` Embeddings enabled in ~/.deeplake/config.json`);
3910
+ if (!isSharedDepsInstalled()) {
3911
+ warn(` Embeddings shared deps not installed yet \u2014 run \`hivemind embeddings install\` to download them`);
3912
+ } else {
3913
+ log(` Embeddings shared deps present \u2014 sessions will start producing embeddings on next restart`);
3914
+ }
3915
+ }
3916
+ function uninstallEmbeddings(opts) {
3698
3917
  const installs = findHivemindInstalls();
3699
3918
  for (const inst of installs) {
3700
- const link = join10(inst.pluginDir, "node_modules");
3919
+ const link = join12(inst.pluginDir, "node_modules");
3701
3920
  if (isSymlinkToSharedDeps(link, SHARED_NODE_MODULES)) {
3702
3921
  unlinkSync5(link);
3703
3922
  log(` Embeddings unlinked ${inst.id}`);
3704
3923
  }
3705
3924
  }
3706
- if (opts?.prune && existsSync9(SHARED_DIR)) {
3925
+ if (opts?.prune && existsSync11(SHARED_DIR)) {
3707
3926
  rmSync4(SHARED_DIR, { recursive: true, force: true });
3708
3927
  log(` Embeddings pruned ${SHARED_DIR}`);
3709
3928
  }
3929
+ setEmbeddingsEnabled(false);
3930
+ killEmbedDaemon();
3931
+ log(` Embeddings disabled in ~/.deeplake/config.json`);
3932
+ }
3933
+ function disableEmbeddings() {
3934
+ setEmbeddingsEnabled(false);
3935
+ killEmbedDaemon();
3936
+ log(` Embeddings disabled in ~/.deeplake/config.json`);
3937
+ log(` Embeddings daemon terminated; shared deps preserved (run \`hivemind embeddings uninstall\` to remove)`);
3938
+ }
3939
+ function killEmbedDaemon(socketDir) {
3940
+ const uid = typeof process.getuid === "function" ? process.getuid() : userInfo().uid;
3941
+ const pidPath = pidPathFor(String(uid), socketDir);
3942
+ const sockPath = socketPathFor(String(uid), socketDir);
3943
+ let pid = null;
3944
+ try {
3945
+ pid = Number.parseInt(readFileSync9(pidPath, "utf-8").trim(), 10);
3946
+ } catch {
3947
+ }
3948
+ if (pid !== null && Number.isFinite(pid) && _isDaemonAliveOnSocket(sockPath)) {
3949
+ try {
3950
+ process.kill(pid, "SIGTERM");
3951
+ } catch {
3952
+ }
3953
+ } else if (pid !== null) {
3954
+ log(` Embeddings pidfile present but socket dead \u2014 skipping SIGTERM on possibly-stale pid ${pid}`);
3955
+ }
3956
+ try {
3957
+ unlinkSync5(sockPath);
3958
+ } catch {
3959
+ }
3960
+ try {
3961
+ unlinkSync5(pidPath);
3962
+ } catch {
3963
+ }
3964
+ }
3965
+ function _isDaemonAliveOnSocket(sockPath, timeoutMs = 200) {
3966
+ if (!existsSync11(sockPath))
3967
+ return false;
3968
+ try {
3969
+ const child = spawnSync("node", [
3970
+ "-e",
3971
+ `const n=require("node:net");const s=n.connect(${JSON.stringify(sockPath)});s.once("connect",()=>{s.end();process.exit(0)});s.once("error",()=>process.exit(2));setTimeout(()=>process.exit(3),${timeoutMs});`
3972
+ ], { timeout: timeoutMs + 1e3, stdio: "ignore" });
3973
+ return child.status === 0;
3974
+ } catch {
3975
+ return false;
3976
+ }
3710
3977
  }
3711
3978
  function statusEmbeddings() {
3979
+ const enabled = getEmbeddingsEnabled();
3980
+ log(`Config: ~/.deeplake/config.json embeddings.enabled = ${enabled}`);
3712
3981
  log(`Shared deps: ${SHARED_DIR}`);
3713
3982
  log(`Installed: ${isSharedDepsInstalled() ? "yes" : "no"}`);
3714
- log(`Daemon: ${existsSync9(SHARED_DAEMON_PATH) ? SHARED_DAEMON_PATH : "(not present)"}`);
3983
+ log(`Daemon: ${existsSync11(SHARED_DAEMON_PATH) ? SHARED_DAEMON_PATH : "(not present)"}`);
3984
+ if (!enabled) {
3985
+ log("");
3986
+ log(`Embeddings are DISABLED in user config. Run \`hivemind embeddings enable\` to opt in,`);
3987
+ log(`or \`hivemind embeddings install\` if the shared deps are not yet downloaded.`);
3988
+ } else if (!isSharedDepsInstalled()) {
3989
+ log("");
3990
+ warn(`Embeddings are enabled in config but shared deps are missing.`);
3991
+ warn(`Run \`hivemind embeddings install\` to download @huggingface/transformers.`);
3992
+ }
3715
3993
  log("");
3716
3994
  log(`Agent installs:`);
3717
3995
  const installs = findHivemindInstalls();
@@ -3727,7 +4005,7 @@ function statusEmbeddings() {
3727
4005
  label = "\u2713 linked \u2192 shared";
3728
4006
  break;
3729
4007
  case "no-node-modules":
3730
- label = "\u2717 not linked (embeddings disabled)";
4008
+ label = "\u2717 not linked";
3731
4009
  break;
3732
4010
  case "owns-own-node-modules":
3733
4011
  label = "\u25B3 has its own node_modules (not shared)";
@@ -3742,8 +4020,8 @@ function statusEmbeddings() {
3742
4020
  }
3743
4021
 
3744
4022
  // dist/src/cli/auth.js
3745
- import { existsSync as existsSync10 } from "node:fs";
3746
- import { join as join12 } from "node:path";
4023
+ import { existsSync as existsSync12 } from "node:fs";
4024
+ import { join as join14 } from "node:path";
3747
4025
 
3748
4026
  // dist/src/commands/auth.js
3749
4027
  import { execSync } from "node:child_process";
@@ -3758,25 +4036,25 @@ function deeplakeClientHeader() {
3758
4036
  }
3759
4037
 
3760
4038
  // dist/src/commands/auth-creds.js
3761
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync2, unlinkSync as unlinkSync6 } from "node:fs";
3762
- import { join as join11 } from "node:path";
3763
- import { homedir as homedir3 } from "node:os";
4039
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync3, unlinkSync as unlinkSync6 } from "node:fs";
4040
+ import { join as join13 } from "node:path";
4041
+ import { homedir as homedir5 } from "node:os";
3764
4042
  function configDir() {
3765
- return join11(homedir3(), ".deeplake");
4043
+ return join13(homedir5(), ".deeplake");
3766
4044
  }
3767
4045
  function credsPath() {
3768
- return join11(configDir(), "credentials.json");
4046
+ return join13(configDir(), "credentials.json");
3769
4047
  }
3770
4048
  function loadCredentials() {
3771
4049
  try {
3772
- return JSON.parse(readFileSync7(credsPath(), "utf-8"));
4050
+ return JSON.parse(readFileSync10(credsPath(), "utf-8"));
3773
4051
  } catch {
3774
4052
  return null;
3775
4053
  }
3776
4054
  }
3777
4055
  function saveCredentials(creds) {
3778
- mkdirSync2(configDir(), { recursive: true, mode: 448 });
3779
- writeFileSync5(credsPath(), JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
4056
+ mkdirSync3(configDir(), { recursive: true, mode: 448 });
4057
+ writeFileSync7(credsPath(), JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
3780
4058
  }
3781
4059
  function deleteCredentials() {
3782
4060
  try {
@@ -3965,9 +4243,9 @@ Using: ${orgName}
3965
4243
  }
3966
4244
 
3967
4245
  // dist/src/cli/auth.js
3968
- var CREDS_PATH = join12(HOME, ".deeplake", "credentials.json");
4246
+ var CREDS_PATH = join14(HOME, ".deeplake", "credentials.json");
3969
4247
  function isLoggedIn() {
3970
- return existsSync10(CREDS_PATH) && loadCredentials() !== null;
4248
+ return existsSync12(CREDS_PATH) && loadCredentials() !== null;
3971
4249
  }
3972
4250
  async function ensureLoggedIn() {
3973
4251
  if (isLoggedIn())
@@ -4000,16 +4278,16 @@ async function maybeShowOrgChoice() {
4000
4278
  }
4001
4279
 
4002
4280
  // dist/src/config.js
4003
- import { readFileSync as readFileSync8, existsSync as existsSync11 } from "node:fs";
4004
- import { join as join13 } from "node:path";
4005
- import { homedir as homedir4, userInfo } from "node:os";
4281
+ import { readFileSync as readFileSync11, existsSync as existsSync13 } from "node:fs";
4282
+ import { join as join15 } from "node:path";
4283
+ import { homedir as homedir6, userInfo as userInfo2 } from "node:os";
4006
4284
  function loadConfig() {
4007
- const home = homedir4();
4008
- const credPath = join13(home, ".deeplake", "credentials.json");
4285
+ const home = homedir6();
4286
+ const credPath = join15(home, ".deeplake", "credentials.json");
4009
4287
  let creds = null;
4010
- if (existsSync11(credPath)) {
4288
+ if (existsSync13(credPath)) {
4011
4289
  try {
4012
- creds = JSON.parse(readFileSync8(credPath, "utf-8"));
4290
+ creds = JSON.parse(readFileSync11(credPath, "utf-8"));
4013
4291
  } catch {
4014
4292
  return null;
4015
4293
  }
@@ -4022,13 +4300,13 @@ function loadConfig() {
4022
4300
  token,
4023
4301
  orgId,
4024
4302
  orgName: creds?.orgName ?? orgId,
4025
- userName: creds?.userName || userInfo().username || "unknown",
4303
+ userName: creds?.userName || userInfo2().username || "unknown",
4026
4304
  workspaceId: process.env.HIVEMIND_WORKSPACE_ID ?? creds?.workspaceId ?? "default",
4027
4305
  apiUrl: process.env.HIVEMIND_API_URL ?? creds?.apiUrl ?? "https://api.deeplake.ai",
4028
4306
  tableName: process.env.HIVEMIND_TABLE ?? "memory",
4029
4307
  sessionsTableName: process.env.HIVEMIND_SESSIONS_TABLE ?? "sessions",
4030
4308
  skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
4031
- memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join13(home, ".deeplake", "memory")
4309
+ memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join15(home, ".deeplake", "memory")
4032
4310
  };
4033
4311
  }
4034
4312
 
@@ -4037,9 +4315,9 @@ import { randomUUID } from "node:crypto";
4037
4315
 
4038
4316
  // dist/src/utils/debug.js
4039
4317
  import { appendFileSync } from "node:fs";
4040
- import { join as join14 } from "node:path";
4041
- import { homedir as homedir5 } from "node:os";
4042
- var LOG = join14(homedir5(), ".deeplake", "hook-debug.log");
4318
+ import { join as join16 } from "node:path";
4319
+ import { homedir as homedir7 } from "node:os";
4320
+ var LOG = join16(homedir7(), ".deeplake", "hook-debug.log");
4043
4321
  function isDebug() {
4044
4322
  return process.env.HIVEMIND_DEBUG === "1";
4045
4323
  }
@@ -4807,34 +5085,34 @@ if (process.argv[1] && process.argv[1].endsWith("auth-login.js")) {
4807
5085
  }
4808
5086
 
4809
5087
  // dist/src/commands/skillify.js
4810
- import { readdirSync as readdirSync5, existsSync as existsSync24, readFileSync as readFileSync17, mkdirSync as mkdirSync10, renameSync as renameSync4 } from "node:fs";
4811
- import { homedir as homedir17 } from "node:os";
4812
- import { dirname as dirname6, join as join27 } from "node:path";
5088
+ import { readdirSync as readdirSync5, existsSync as existsSync26, readFileSync as readFileSync20, mkdirSync as mkdirSync11, renameSync as renameSync6 } from "node:fs";
5089
+ import { homedir as homedir19 } from "node:os";
5090
+ import { dirname as dirname7, join as join29 } from "node:path";
4813
5091
 
4814
5092
  // dist/src/skillify/scope-config.js
4815
- import { existsSync as existsSync14, mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
4816
- import { homedir as homedir7 } from "node:os";
4817
- import { join as join17 } from "node:path";
5093
+ import { existsSync as existsSync16, mkdirSync as mkdirSync5, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "node:fs";
5094
+ import { homedir as homedir9 } from "node:os";
5095
+ import { join as join19 } from "node:path";
4818
5096
 
4819
5097
  // dist/src/skillify/legacy-migration.js
4820
- import { existsSync as existsSync13, renameSync } from "node:fs";
4821
- import { homedir as homedir6 } from "node:os";
4822
- import { join as join16 } from "node:path";
5098
+ import { existsSync as existsSync15, renameSync as renameSync3 } from "node:fs";
5099
+ import { homedir as homedir8 } from "node:os";
5100
+ import { join as join18 } from "node:path";
4823
5101
  var dlog = (msg) => log2("skillify-migrate", msg);
4824
5102
  var attempted = false;
4825
5103
  function migrateLegacyStateDir() {
4826
5104
  if (attempted)
4827
5105
  return;
4828
5106
  attempted = true;
4829
- const root = join16(homedir6(), ".deeplake", "state");
4830
- const legacy = join16(root, "skilify");
4831
- const current = join16(root, "skillify");
4832
- if (!existsSync13(legacy))
5107
+ const root = join18(homedir8(), ".deeplake", "state");
5108
+ const legacy = join18(root, "skilify");
5109
+ const current = join18(root, "skillify");
5110
+ if (!existsSync15(legacy))
4833
5111
  return;
4834
- if (existsSync13(current))
5112
+ if (existsSync15(current))
4835
5113
  return;
4836
5114
  try {
4837
- renameSync(legacy, current);
5115
+ renameSync3(legacy, current);
4838
5116
  dlog(`migrated ${legacy} -> ${current}`);
4839
5117
  } catch (err) {
4840
5118
  const code = err.code;
@@ -4847,15 +5125,15 @@ function migrateLegacyStateDir() {
4847
5125
  }
4848
5126
 
4849
5127
  // dist/src/skillify/scope-config.js
4850
- var STATE_DIR = join17(homedir7(), ".deeplake", "state", "skillify");
4851
- var CONFIG_PATH2 = join17(STATE_DIR, "config.json");
5128
+ var STATE_DIR = join19(homedir9(), ".deeplake", "state", "skillify");
5129
+ var CONFIG_PATH2 = join19(STATE_DIR, "config.json");
4852
5130
  var DEFAULT = { scope: "me", team: [], install: "project" };
4853
5131
  function loadScopeConfig() {
4854
5132
  migrateLegacyStateDir();
4855
- if (!existsSync14(CONFIG_PATH2))
5133
+ if (!existsSync16(CONFIG_PATH2))
4856
5134
  return DEFAULT;
4857
5135
  try {
4858
- const raw = JSON.parse(readFileSync10(CONFIG_PATH2, "utf-8"));
5136
+ const raw = JSON.parse(readFileSync13(CONFIG_PATH2, "utf-8"));
4859
5137
  const scope = raw.scope === "team" ? "team" : raw.scope === "org" ? "team" : "me";
4860
5138
  const team = Array.isArray(raw.team) ? raw.team.filter((s) => typeof s === "string") : [];
4861
5139
  const install = raw.install === "global" ? "global" : "project";
@@ -4866,19 +5144,19 @@ function loadScopeConfig() {
4866
5144
  }
4867
5145
  function saveScopeConfig(cfg) {
4868
5146
  migrateLegacyStateDir();
4869
- mkdirSync4(STATE_DIR, { recursive: true });
4870
- writeFileSync7(CONFIG_PATH2, JSON.stringify(cfg, null, 2));
5147
+ mkdirSync5(STATE_DIR, { recursive: true });
5148
+ writeFileSync9(CONFIG_PATH2, JSON.stringify(cfg, null, 2));
4871
5149
  }
4872
5150
 
4873
5151
  // dist/src/skillify/pull.js
4874
- import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync10, mkdirSync as mkdirSync7, renameSync as renameSync3, lstatSync as lstatSync4, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, unlinkSync as unlinkSync8 } from "node:fs";
4875
- import { homedir as homedir11 } from "node:os";
4876
- import { dirname as dirname3, join as join21 } from "node:path";
5152
+ import { existsSync as existsSync20, readFileSync as readFileSync16, writeFileSync as writeFileSync12, mkdirSync as mkdirSync8, renameSync as renameSync5, lstatSync as lstatSync4, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, unlinkSync as unlinkSync8 } from "node:fs";
5153
+ import { homedir as homedir13 } from "node:os";
5154
+ import { dirname as dirname4, join as join23 } from "node:path";
4877
5155
 
4878
5156
  // dist/src/skillify/skill-writer.js
4879
- import { existsSync as existsSync15, mkdirSync as mkdirSync5, readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync8 } from "node:fs";
4880
- import { homedir as homedir8 } from "node:os";
4881
- import { join as join18 } from "node:path";
5157
+ import { existsSync as existsSync17, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync10 } from "node:fs";
5158
+ import { homedir as homedir10 } from "node:os";
5159
+ import { join as join20 } from "node:path";
4882
5160
  function assertValidSkillName(name) {
4883
5161
  if (typeof name !== "string" || name.length === 0) {
4884
5162
  throw new Error(`invalid skill name: empty or non-string`);
@@ -4894,10 +5172,10 @@ function assertValidSkillName(name) {
4894
5172
  }
4895
5173
  }
4896
5174
  function skillDir(skillsRoot, name) {
4897
- return join18(skillsRoot, name);
5175
+ return join20(skillsRoot, name);
4898
5176
  }
4899
5177
  function skillPath(skillsRoot, name) {
4900
- return join18(skillDir(skillsRoot, name), "SKILL.md");
5178
+ return join20(skillDir(skillsRoot, name), "SKILL.md");
4901
5179
  }
4902
5180
  function renderFrontmatter(fm) {
4903
5181
  const lines = ["---"];
@@ -4975,10 +5253,10 @@ function writeNewSkill(args) {
4975
5253
  assertValidSkillName(args.name);
4976
5254
  const dir = skillDir(args.skillsRoot, args.name);
4977
5255
  const path = skillPath(args.skillsRoot, args.name);
4978
- if (existsSync15(path)) {
5256
+ if (existsSync17(path)) {
4979
5257
  throw new Error(`skill already exists at ${path}; use mergeSkill`);
4980
5258
  }
4981
- mkdirSync5(dir, { recursive: true });
5259
+ mkdirSync6(dir, { recursive: true });
4982
5260
  const now = (/* @__PURE__ */ new Date()).toISOString();
4983
5261
  const author = args.author && args.author.length > 0 ? args.author : void 0;
4984
5262
  const contributors = author ? [author] : [];
@@ -4998,7 +5276,7 @@ function writeNewSkill(args) {
4998
5276
 
4999
5277
  ${args.body.trim()}
5000
5278
  `;
5001
- writeFileSync8(path, text);
5279
+ writeFileSync10(path, text);
5002
5280
  return {
5003
5281
  path,
5004
5282
  action: "created",
@@ -5010,41 +5288,41 @@ ${args.body.trim()}
5010
5288
  };
5011
5289
  }
5012
5290
  function listSkills(skillsRoot) {
5013
- if (!existsSync15(skillsRoot))
5291
+ if (!existsSync17(skillsRoot))
5014
5292
  return [];
5015
5293
  const out = [];
5016
5294
  for (const name of readdirSync2(skillsRoot)) {
5017
- const skillFile = join18(skillsRoot, name, "SKILL.md");
5018
- if (existsSync15(skillFile) && statSync2(skillFile).isFile()) {
5019
- out.push({ name, body: readFileSync11(skillFile, "utf-8") });
5295
+ const skillFile = join20(skillsRoot, name, "SKILL.md");
5296
+ if (existsSync17(skillFile) && statSync2(skillFile).isFile()) {
5297
+ out.push({ name, body: readFileSync14(skillFile, "utf-8") });
5020
5298
  }
5021
5299
  }
5022
5300
  return out;
5023
5301
  }
5024
5302
  function resolveSkillsRoot(install, cwd) {
5025
5303
  if (install === "global") {
5026
- return join18(homedir8(), ".claude", "skills");
5304
+ return join20(homedir10(), ".claude", "skills");
5027
5305
  }
5028
- return join18(cwd, ".claude", "skills");
5306
+ return join20(cwd, ".claude", "skills");
5029
5307
  }
5030
5308
 
5031
5309
  // dist/src/skillify/manifest.js
5032
- import { existsSync as existsSync16, lstatSync as lstatSync3, mkdirSync as mkdirSync6, readFileSync as readFileSync12, renameSync as renameSync2, unlinkSync as unlinkSync7, writeFileSync as writeFileSync9 } from "node:fs";
5033
- import { homedir as homedir9 } from "node:os";
5034
- import { dirname as dirname2, join as join19 } from "node:path";
5310
+ import { existsSync as existsSync18, lstatSync as lstatSync3, mkdirSync as mkdirSync7, readFileSync as readFileSync15, renameSync as renameSync4, unlinkSync as unlinkSync7, writeFileSync as writeFileSync11 } from "node:fs";
5311
+ import { homedir as homedir11 } from "node:os";
5312
+ import { dirname as dirname3, join as join21 } from "node:path";
5035
5313
  function emptyManifest() {
5036
5314
  return { version: 1, entries: [] };
5037
5315
  }
5038
5316
  function manifestPath() {
5039
- return join19(homedir9(), ".deeplake", "state", "skillify", "pulled.json");
5317
+ return join21(homedir11(), ".deeplake", "state", "skillify", "pulled.json");
5040
5318
  }
5041
5319
  function loadManifest(path = manifestPath()) {
5042
5320
  migrateLegacyStateDir();
5043
- if (!existsSync16(path))
5321
+ if (!existsSync18(path))
5044
5322
  return emptyManifest();
5045
5323
  let raw;
5046
5324
  try {
5047
- raw = readFileSync12(path, "utf-8");
5325
+ raw = readFileSync15(path, "utf-8");
5048
5326
  } catch {
5049
5327
  return emptyManifest();
5050
5328
  }
@@ -5091,10 +5369,10 @@ function loadManifest(path = manifestPath()) {
5091
5369
  }
5092
5370
  function saveManifest(m, path = manifestPath()) {
5093
5371
  migrateLegacyStateDir();
5094
- mkdirSync6(dirname2(path), { recursive: true });
5372
+ mkdirSync7(dirname3(path), { recursive: true });
5095
5373
  const tmp = `${path}.tmp`;
5096
- writeFileSync9(tmp, JSON.stringify(m, null, 2) + "\n", { mode: 384 });
5097
- renameSync2(tmp, path);
5374
+ writeFileSync11(tmp, JSON.stringify(m, null, 2) + "\n", { mode: 384 });
5375
+ renameSync4(tmp, path);
5098
5376
  }
5099
5377
  function recordPull(entry, path = manifestPath()) {
5100
5378
  const m = loadManifest(path);
@@ -5136,7 +5414,7 @@ function pruneOrphanedEntries(path = manifestPath()) {
5136
5414
  const live = [];
5137
5415
  let pruned = 0;
5138
5416
  for (const e of m.entries) {
5139
- if (existsSync16(join19(e.installRoot, e.dirName))) {
5417
+ if (existsSync18(join21(e.installRoot, e.dirName))) {
5140
5418
  live.push(e);
5141
5419
  continue;
5142
5420
  }
@@ -5149,26 +5427,26 @@ function pruneOrphanedEntries(path = manifestPath()) {
5149
5427
  }
5150
5428
 
5151
5429
  // dist/src/skillify/agent-roots.js
5152
- import { existsSync as existsSync17 } from "node:fs";
5153
- import { homedir as homedir10 } from "node:os";
5154
- import { join as join20 } from "node:path";
5430
+ import { existsSync as existsSync19 } from "node:fs";
5431
+ import { homedir as homedir12 } from "node:os";
5432
+ import { join as join22 } from "node:path";
5155
5433
  function resolveDetected(home) {
5156
5434
  const out = [];
5157
- const codexInstalled = existsSync17(join20(home, ".codex"));
5158
- const piInstalled = existsSync17(join20(home, ".pi", "agent"));
5159
- const hermesInstalled = existsSync17(join20(home, ".hermes"));
5435
+ const codexInstalled = existsSync19(join22(home, ".codex"));
5436
+ const piInstalled = existsSync19(join22(home, ".pi", "agent"));
5437
+ const hermesInstalled = existsSync19(join22(home, ".hermes"));
5160
5438
  if (codexInstalled || piInstalled) {
5161
- out.push(join20(home, ".agents", "skills"));
5439
+ out.push(join22(home, ".agents", "skills"));
5162
5440
  }
5163
5441
  if (hermesInstalled) {
5164
- out.push(join20(home, ".hermes", "skills"));
5442
+ out.push(join22(home, ".hermes", "skills"));
5165
5443
  }
5166
5444
  if (piInstalled) {
5167
- out.push(join20(home, ".pi", "agent", "skills"));
5445
+ out.push(join22(home, ".pi", "agent", "skills"));
5168
5446
  }
5169
5447
  return out;
5170
5448
  }
5171
- function detectAgentSkillsRoots(canonicalRoot, home = homedir10()) {
5449
+ function detectAgentSkillsRoots(canonicalRoot, home = homedir12()) {
5172
5450
  return resolveDetected(home).filter((p) => p !== canonicalRoot);
5173
5451
  }
5174
5452
 
@@ -5212,15 +5490,15 @@ function isMissingTableError(message) {
5212
5490
  }
5213
5491
  function resolvePullDestination(install, cwd) {
5214
5492
  if (install === "global")
5215
- return join21(homedir11(), ".claude", "skills");
5493
+ return join23(homedir13(), ".claude", "skills");
5216
5494
  if (!cwd)
5217
5495
  throw new Error("install=project requires a cwd");
5218
- return join21(cwd, ".claude", "skills");
5496
+ return join23(cwd, ".claude", "skills");
5219
5497
  }
5220
5498
  function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
5221
5499
  const out = [];
5222
5500
  for (const root of agentRoots) {
5223
- const link = join21(root, dirName);
5501
+ const link = join23(root, dirName);
5224
5502
  let existing;
5225
5503
  try {
5226
5504
  existing = lstatSync4(link);
@@ -5248,7 +5526,7 @@ function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
5248
5526
  }
5249
5527
  }
5250
5528
  try {
5251
- mkdirSync7(dirname3(link), { recursive: true });
5529
+ mkdirSync8(dirname4(link), { recursive: true });
5252
5530
  symlinkSync2(canonicalDir, link, "dir");
5253
5531
  out.push(link);
5254
5532
  } catch {
@@ -5263,8 +5541,8 @@ function backfillSymlinks(installRoot) {
5263
5541
  return;
5264
5542
  const detected = detectAgentSkillsRoots(installRoot);
5265
5543
  for (const entry of entries) {
5266
- const canonical = join21(entry.installRoot, entry.dirName);
5267
- if (!existsSync18(canonical))
5544
+ const canonical = join23(entry.installRoot, entry.dirName);
5545
+ if (!existsSync20(canonical))
5268
5546
  continue;
5269
5547
  const fresh = fanOutSymlinks(canonical, entry.dirName, detected);
5270
5548
  if (sameSorted(fresh, entry.symlinks))
@@ -5374,10 +5652,10 @@ function renderFrontmatter2(fm) {
5374
5652
  return lines.join("\n");
5375
5653
  }
5376
5654
  function readLocalVersion(path) {
5377
- if (!existsSync18(path))
5655
+ if (!existsSync20(path))
5378
5656
  return null;
5379
5657
  try {
5380
- const text = readFileSync13(path, "utf-8");
5658
+ const text = readFileSync16(path, "utf-8");
5381
5659
  const parsed = parseFrontmatter(text);
5382
5660
  if (!parsed)
5383
5661
  return null;
@@ -5472,8 +5750,8 @@ async function runPull(opts) {
5472
5750
  summary.skipped++;
5473
5751
  continue;
5474
5752
  }
5475
- const skillDir2 = join21(root, dirName);
5476
- const skillFile = join21(skillDir2, "SKILL.md");
5753
+ const skillDir2 = join23(root, dirName);
5754
+ const skillFile = join23(skillDir2, "SKILL.md");
5477
5755
  const remoteVersion = Number(row.version ?? 1);
5478
5756
  const localVersion = readLocalVersion(skillFile);
5479
5757
  const action = decideAction({
@@ -5484,14 +5762,14 @@ async function runPull(opts) {
5484
5762
  });
5485
5763
  let manifestError;
5486
5764
  if (action === "wrote") {
5487
- mkdirSync7(skillDir2, { recursive: true });
5488
- if (existsSync18(skillFile)) {
5765
+ mkdirSync8(skillDir2, { recursive: true });
5766
+ if (existsSync20(skillFile)) {
5489
5767
  try {
5490
- renameSync3(skillFile, `${skillFile}.bak`);
5768
+ renameSync5(skillFile, `${skillFile}.bak`);
5491
5769
  } catch {
5492
5770
  }
5493
5771
  }
5494
- writeFileSync10(skillFile, renderSkillFile(row));
5772
+ writeFileSync12(skillFile, renderSkillFile(row));
5495
5773
  const symlinks = opts.install === "global" ? fanOutSymlinks(skillDir2, dirName, detectAgentSkillsRoots(root)) : [];
5496
5774
  try {
5497
5775
  recordPull({
@@ -5533,15 +5811,15 @@ async function runPull(opts) {
5533
5811
  }
5534
5812
 
5535
5813
  // dist/src/skillify/unpull.js
5536
- import { existsSync as existsSync19, readdirSync as readdirSync3, rmSync as rmSync5, statSync as statSync3 } from "node:fs";
5537
- import { homedir as homedir12 } from "node:os";
5538
- import { join as join22 } from "node:path";
5814
+ import { existsSync as existsSync21, readdirSync as readdirSync3, rmSync as rmSync5, statSync as statSync3 } from "node:fs";
5815
+ import { homedir as homedir14 } from "node:os";
5816
+ import { join as join24 } from "node:path";
5539
5817
  function resolveUnpullRoot(install, cwd) {
5540
5818
  if (install === "global")
5541
- return join22(homedir12(), ".claude", "skills");
5819
+ return join24(homedir14(), ".claude", "skills");
5542
5820
  if (!cwd)
5543
5821
  throw new Error("cwd required when install === 'project'");
5544
- return join22(cwd, ".claude", "skills");
5822
+ return join24(cwd, ".claude", "skills");
5545
5823
  }
5546
5824
  function runUnpull(opts) {
5547
5825
  const root = resolveUnpullRoot(opts.install, opts.cwd);
@@ -5564,8 +5842,8 @@ function runUnpull(opts) {
5564
5842
  const entries = entriesForRoot(manifest, opts.install, root);
5565
5843
  for (const entry of entries) {
5566
5844
  summary.scanned++;
5567
- const path = join22(root, entry.dirName);
5568
- if (!existsSync19(path)) {
5845
+ const path = join24(root, entry.dirName);
5846
+ if (!existsSync21(path)) {
5569
5847
  if (!opts.dryRun) {
5570
5848
  unlinkSymlinks(entry.symlinks);
5571
5849
  removePullEntry(opts.install, entry.installRoot, entry.dirName);
@@ -5618,12 +5896,12 @@ function runUnpull(opts) {
5618
5896
  }
5619
5897
  summary.entries.push(result);
5620
5898
  }
5621
- if (existsSync19(root) && (opts.all || opts.legacyCleanup)) {
5899
+ if (existsSync21(root) && (opts.all || opts.legacyCleanup)) {
5622
5900
  const manifestDirNames = new Set(entries.map((e) => e.dirName));
5623
5901
  for (const dirName of readdirSync3(root)) {
5624
5902
  if (manifestDirNames.has(dirName))
5625
5903
  continue;
5626
- const path = join22(root, dirName);
5904
+ const path = join24(root, dirName);
5627
5905
  let st;
5628
5906
  try {
5629
5907
  st = statSync3(path);
@@ -5702,30 +5980,30 @@ function decideTargetForManifestEntry(entry, opts, userFilter, haveUserFilter) {
5702
5980
 
5703
5981
  // dist/src/commands/mine-local.js
5704
5982
  import { spawn } from "node:child_process";
5705
- import { existsSync as existsSync23, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync12 } from "node:fs";
5706
- import { homedir as homedir16 } from "node:os";
5707
- import { basename, dirname as dirname5, join as join26 } from "node:path";
5983
+ import { existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
5984
+ import { homedir as homedir18 } from "node:os";
5985
+ import { basename, dirname as dirname6, join as join28 } from "node:path";
5708
5986
 
5709
5987
  // dist/src/skillify/local-source.js
5710
- import { readdirSync as readdirSync4, readFileSync as readFileSync14, existsSync as existsSync20, statSync as statSync4 } from "node:fs";
5711
- import { homedir as homedir13 } from "node:os";
5712
- import { join as join23 } from "node:path";
5713
- var HOME2 = homedir13();
5988
+ import { readdirSync as readdirSync4, readFileSync as readFileSync17, existsSync as existsSync22, statSync as statSync4 } from "node:fs";
5989
+ import { homedir as homedir15 } from "node:os";
5990
+ import { join as join25 } from "node:path";
5991
+ var HOME2 = homedir15();
5714
5992
  function encodeCwdClaudeCode(cwd) {
5715
5993
  return cwd.replace(/[/_]/g, "-");
5716
5994
  }
5717
5995
  function detectInstalledAgents() {
5718
5996
  const installs = [];
5719
- const claudeRoot = join23(HOME2, ".claude", "projects");
5720
- if (existsSync20(claudeRoot)) {
5997
+ const claudeRoot = join25(HOME2, ".claude", "projects");
5998
+ if (existsSync22(claudeRoot)) {
5721
5999
  installs.push({
5722
6000
  agent: "claude_code",
5723
6001
  sessionRoot: claudeRoot,
5724
6002
  encodeCwd: encodeCwdClaudeCode
5725
6003
  });
5726
6004
  }
5727
- const codexRoot = join23(HOME2, ".codex", "sessions");
5728
- if (existsSync20(codexRoot)) {
6005
+ const codexRoot = join25(HOME2, ".codex", "sessions");
6006
+ if (existsSync22(codexRoot)) {
5729
6007
  installs.push({
5730
6008
  agent: "codex",
5731
6009
  sessionRoot: codexRoot,
@@ -5752,7 +6030,7 @@ function listLocalSessions(installs, cwd) {
5752
6030
  continue;
5753
6031
  }
5754
6032
  for (const sub of subdirs) {
5755
- const subdirPath = join23(install.sessionRoot, sub);
6033
+ const subdirPath = join25(install.sessionRoot, sub);
5756
6034
  try {
5757
6035
  if (!statSync4(subdirPath).isDirectory())
5758
6036
  continue;
@@ -5769,7 +6047,7 @@ function listLocalSessions(installs, cwd) {
5769
6047
  for (const f of files) {
5770
6048
  if (!f.endsWith(".jsonl"))
5771
6049
  continue;
5772
- const fullPath = join23(subdirPath, f);
6050
+ const fullPath = join25(subdirPath, f);
5773
6051
  let stats;
5774
6052
  try {
5775
6053
  stats = statSync4(fullPath);
@@ -5830,7 +6108,7 @@ function pickSessions(candidates, opts) {
5830
6108
  function nativeJsonlToRows(filePath, sessionId, agent) {
5831
6109
  let raw;
5832
6110
  try {
5833
- raw = readFileSync14(filePath, "utf-8");
6111
+ raw = readFileSync17(filePath, "utf-8");
5834
6112
  } catch {
5835
6113
  return [];
5836
6114
  }
@@ -5920,22 +6198,22 @@ function extractPairs(rows) {
5920
6198
  }
5921
6199
 
5922
6200
  // dist/src/skillify/gate-runner.js
5923
- import { existsSync as existsSync21 } from "node:fs";
6201
+ import { existsSync as existsSync23 } from "node:fs";
5924
6202
  import { createRequire } from "node:module";
5925
- import { homedir as homedir14 } from "node:os";
5926
- import { join as join24 } from "node:path";
6203
+ import { homedir as homedir16 } from "node:os";
6204
+ import { join as join26 } from "node:path";
5927
6205
  var requireForCp = createRequire(import.meta.url);
5928
6206
  var { execFileSync: runChildProcess } = requireForCp("node:child_process");
5929
6207
  var inheritedEnv = process;
5930
6208
  function firstExistingPath(candidates) {
5931
6209
  for (const c of candidates) {
5932
- if (existsSync21(c))
6210
+ if (existsSync23(c))
5933
6211
  return c;
5934
6212
  }
5935
6213
  return null;
5936
6214
  }
5937
6215
  function findAgentBin(agent) {
5938
- const home = homedir14();
6216
+ const home = homedir16();
5939
6217
  switch (agent) {
5940
6218
  // /usr/bin/<name> is included in every candidate list — that's the
5941
6219
  // common Linux package-manager install path (apt, dnf, pacman). Old
@@ -5944,45 +6222,45 @@ function findAgentBin(agent) {
5944
6222
  // #170 caught the gap.
5945
6223
  case "claude_code":
5946
6224
  return firstExistingPath([
5947
- join24(home, ".claude", "local", "claude"),
6225
+ join26(home, ".claude", "local", "claude"),
5948
6226
  "/usr/local/bin/claude",
5949
6227
  "/usr/bin/claude",
5950
- join24(home, ".npm-global", "bin", "claude"),
5951
- join24(home, ".local", "bin", "claude"),
6228
+ join26(home, ".npm-global", "bin", "claude"),
6229
+ join26(home, ".local", "bin", "claude"),
5952
6230
  "/opt/homebrew/bin/claude"
5953
- ]) ?? join24(home, ".claude", "local", "claude");
6231
+ ]) ?? join26(home, ".claude", "local", "claude");
5954
6232
  case "codex":
5955
6233
  return firstExistingPath([
5956
6234
  "/usr/local/bin/codex",
5957
6235
  "/usr/bin/codex",
5958
- join24(home, ".npm-global", "bin", "codex"),
5959
- join24(home, ".local", "bin", "codex"),
6236
+ join26(home, ".npm-global", "bin", "codex"),
6237
+ join26(home, ".local", "bin", "codex"),
5960
6238
  "/opt/homebrew/bin/codex"
5961
6239
  ]) ?? "/usr/local/bin/codex";
5962
6240
  case "cursor":
5963
6241
  return firstExistingPath([
5964
6242
  "/usr/local/bin/cursor-agent",
5965
6243
  "/usr/bin/cursor-agent",
5966
- join24(home, ".npm-global", "bin", "cursor-agent"),
5967
- join24(home, ".local", "bin", "cursor-agent"),
6244
+ join26(home, ".npm-global", "bin", "cursor-agent"),
6245
+ join26(home, ".local", "bin", "cursor-agent"),
5968
6246
  "/opt/homebrew/bin/cursor-agent"
5969
6247
  ]) ?? "/usr/local/bin/cursor-agent";
5970
6248
  case "hermes":
5971
6249
  return firstExistingPath([
5972
- join24(home, ".local", "bin", "hermes"),
6250
+ join26(home, ".local", "bin", "hermes"),
5973
6251
  "/usr/local/bin/hermes",
5974
6252
  "/usr/bin/hermes",
5975
- join24(home, ".npm-global", "bin", "hermes"),
6253
+ join26(home, ".npm-global", "bin", "hermes"),
5976
6254
  "/opt/homebrew/bin/hermes"
5977
- ]) ?? join24(home, ".local", "bin", "hermes");
6255
+ ]) ?? join26(home, ".local", "bin", "hermes");
5978
6256
  case "pi":
5979
6257
  return firstExistingPath([
5980
- join24(home, ".local", "bin", "pi"),
6258
+ join26(home, ".local", "bin", "pi"),
5981
6259
  "/usr/local/bin/pi",
5982
6260
  "/usr/bin/pi",
5983
- join24(home, ".npm-global", "bin", "pi"),
6261
+ join26(home, ".npm-global", "bin", "pi"),
5984
6262
  "/opt/homebrew/bin/pi"
5985
- ]) ?? join24(home, ".local", "bin", "pi");
6263
+ ]) ?? join26(home, ".local", "bin", "pi");
5986
6264
  }
5987
6265
  }
5988
6266
 
@@ -6012,23 +6290,23 @@ function extractJsonBlock(s) {
6012
6290
  }
6013
6291
 
6014
6292
  // dist/src/skillify/local-manifest.js
6015
- import { existsSync as existsSync22, mkdirSync as mkdirSync8, readFileSync as readFileSync15, writeFileSync as writeFileSync11 } from "node:fs";
6016
- import { homedir as homedir15 } from "node:os";
6017
- import { dirname as dirname4, join as join25 } from "node:path";
6018
- var LOCAL_MANIFEST_PATH = join25(homedir15(), ".claude", "hivemind", "local-mined.json");
6019
- var LOCAL_MINE_LOCK_PATH = join25(homedir15(), ".claude", "hivemind", "local-mined.lock");
6293
+ import { existsSync as existsSync24, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as writeFileSync13 } from "node:fs";
6294
+ import { homedir as homedir17 } from "node:os";
6295
+ import { dirname as dirname5, join as join27 } from "node:path";
6296
+ var LOCAL_MANIFEST_PATH = join27(homedir17(), ".claude", "hivemind", "local-mined.json");
6297
+ var LOCAL_MINE_LOCK_PATH = join27(homedir17(), ".claude", "hivemind", "local-mined.lock");
6020
6298
  function readLocalManifest(path = LOCAL_MANIFEST_PATH) {
6021
- if (!existsSync22(path))
6299
+ if (!existsSync24(path))
6022
6300
  return null;
6023
6301
  try {
6024
- return JSON.parse(readFileSync15(path, "utf-8"));
6302
+ return JSON.parse(readFileSync18(path, "utf-8"));
6025
6303
  } catch {
6026
6304
  return null;
6027
6305
  }
6028
6306
  }
6029
6307
  function writeLocalManifest(m, path = LOCAL_MANIFEST_PATH) {
6030
- mkdirSync8(dirname4(path), { recursive: true });
6031
- writeFileSync11(path, JSON.stringify(m, null, 2));
6308
+ mkdirSync9(dirname5(path), { recursive: true });
6309
+ writeFileSync13(path, JSON.stringify(m, null, 2));
6032
6310
  }
6033
6311
 
6034
6312
  // dist/src/commands/mine-local.js
@@ -6053,7 +6331,7 @@ function runGateViaStdin(opts) {
6053
6331
  });
6054
6332
  return;
6055
6333
  }
6056
- if (!existsSync23(opts.bin)) {
6334
+ if (!existsSync25(opts.bin)) {
6057
6335
  resolve({
6058
6336
  stdout: "",
6059
6337
  stderr: "",
@@ -6398,8 +6676,8 @@ async function runMineLocalImpl(args) {
6398
6676
  console.log(`Dry-run: would invoke ${gateAgent} gate on ${picked.length} session(s) in parallel (concurrency=${GATE_CONCURRENCY}).`);
6399
6677
  return;
6400
6678
  }
6401
- const tmpDir = join26(homedir16(), ".claude", "hivemind", `mine-local-${Date.now()}`);
6402
- mkdirSync9(tmpDir, { recursive: true });
6679
+ const tmpDir = join28(homedir18(), ".claude", "hivemind", `mine-local-${Date.now()}`);
6680
+ mkdirSync10(tmpDir, { recursive: true });
6403
6681
  console.log(`Running ${picked.length} gate call(s) in parallel (concurrency=${GATE_CONCURRENCY}, timeout=${GATE_TIMEOUT_MS / 1e3}s each)...`);
6404
6682
  const results = await parallelMap(picked, GATE_CONCURRENCY, async (s) => {
6405
6683
  const shortId = s.sessionId.slice(0, 8);
@@ -6410,23 +6688,23 @@ async function runMineLocalImpl(args) {
6410
6688
  return { session: s, skills: [], reason: "no pairs", error: null };
6411
6689
  }
6412
6690
  const tail = pairs2.slice(-PER_SESSION_PAIR_CAP);
6413
- const sessionTmp = join26(tmpDir, `s-${shortId}`);
6414
- mkdirSync9(sessionTmp, { recursive: true });
6415
- const verdictPath = join26(sessionTmp, "verdict.json");
6691
+ const sessionTmp = join28(tmpDir, `s-${shortId}`);
6692
+ mkdirSync10(sessionTmp, { recursive: true });
6693
+ const verdictPath = join28(sessionTmp, "verdict.json");
6416
6694
  const prompt = buildSessionPrompt(tail, s, verdictPath);
6417
- writeFileSync12(join26(sessionTmp, "prompt.txt"), prompt);
6695
+ writeFileSync14(join28(sessionTmp, "prompt.txt"), prompt);
6418
6696
  const gate = await runGateViaStdin({ agent: gateAgent, bin: gateBin, prompt, timeoutMs: GATE_TIMEOUT_MS });
6419
6697
  try {
6420
- writeFileSync12(join26(sessionTmp, "gate-stdout.txt"), gate.stdout);
6698
+ writeFileSync14(join28(sessionTmp, "gate-stdout.txt"), gate.stdout);
6421
6699
  if (gate.stderr)
6422
- writeFileSync12(join26(sessionTmp, "gate-stderr.txt"), gate.stderr);
6700
+ writeFileSync14(join28(sessionTmp, "gate-stderr.txt"), gate.stderr);
6423
6701
  } catch {
6424
6702
  }
6425
6703
  if (gate.errored) {
6426
6704
  console.log(` [${shortId}] gate failed: ${gate.errorMessage}`);
6427
6705
  return { session: s, skills: [], reason: null, error: gate.errorMessage ?? "gate failed" };
6428
6706
  }
6429
- const verdictText = existsSync23(verdictPath) ? readFileSync16(verdictPath, "utf-8") : gate.stdout;
6707
+ const verdictText = existsSync25(verdictPath) ? readFileSync19(verdictPath, "utf-8") : gate.stdout;
6430
6708
  const mv = parseMultiVerdict(verdictText);
6431
6709
  if (!mv) {
6432
6710
  console.log(` [${shortId}] unparseable verdict (kept at ${sessionTmp})`);
@@ -6478,7 +6756,7 @@ async function runMineLocalImpl(args) {
6478
6756
  sourceSessions: [session.sessionId],
6479
6757
  agent: gateAgent
6480
6758
  });
6481
- const canonicalDir = dirname5(result.path);
6759
+ const canonicalDir = dirname6(result.path);
6482
6760
  const symlinks = fanOutRoots.length > 0 ? fanOutSymlinks(canonicalDir, basename(canonicalDir), fanOutRoots) : [];
6483
6761
  const symlinkSuffix = symlinks.length > 0 ? `, fan-out \u2192 ${symlinks.length} root(s)` : "";
6484
6762
  console.log(` wrote ${skill.name} \u2190 session ${session.sessionId.slice(0, 8)} (${session.agent}${symlinkSuffix})`);
@@ -6642,7 +6920,7 @@ function wrapAt(s, max) {
6642
6920
 
6643
6921
  // dist/src/commands/skillify.js
6644
6922
  function stateDir() {
6645
- return join27(homedir17(), ".deeplake", "state", "skillify");
6923
+ return join29(homedir19(), ".deeplake", "state", "skillify");
6646
6924
  }
6647
6925
  function showStatus() {
6648
6926
  const cfg = loadScopeConfig();
@@ -6650,7 +6928,7 @@ function showStatus() {
6650
6928
  console.log(`team: ${cfg.team.length === 0 ? "(empty)" : cfg.team.join(", ")}`);
6651
6929
  console.log(`install: ${cfg.install} (${cfg.install === "global" ? "~/.claude/skills/" : "<project>/.claude/skills/"})`);
6652
6930
  const dir = stateDir();
6653
- if (!existsSync24(dir)) {
6931
+ if (!existsSync26(dir)) {
6654
6932
  console.log(`state: (no projects tracked yet)`);
6655
6933
  return;
6656
6934
  }
@@ -6662,7 +6940,7 @@ function showStatus() {
6662
6940
  console.log(`state: ${files.length} project(s) tracked`);
6663
6941
  for (const f of files) {
6664
6942
  try {
6665
- const s = JSON.parse(readFileSync17(join27(dir, f), "utf-8"));
6943
+ const s = JSON.parse(readFileSync20(join29(dir, f), "utf-8"));
6666
6944
  const last = typeof s.updatedAt === "number" ? new Date(s.updatedAt).toISOString() : s.lastDate ?? "never";
6667
6945
  const skills = Array.isArray(s.skillsGenerated) && s.skillsGenerated.length > 0 ? s.skillsGenerated.join(", ") : "none";
6668
6946
  console.log(` - ${s.project} (counter=${s.counter}, last=${last}, skills=${skills})`);
@@ -6689,7 +6967,7 @@ function setInstall(loc) {
6689
6967
  }
6690
6968
  const cfg = loadScopeConfig();
6691
6969
  saveScopeConfig({ ...cfg, install: loc });
6692
- const path = loc === "global" ? join27(homedir17(), ".claude", "skills") : "<cwd>/.claude/skills";
6970
+ const path = loc === "global" ? join29(homedir19(), ".claude", "skills") : "<cwd>/.claude/skills";
6693
6971
  console.log(`Install location set to '${loc}'. New skills will be written to ${path}/<name>/SKILL.md.`);
6694
6972
  }
6695
6973
  function promoteSkill(name, cwd) {
@@ -6697,18 +6975,18 @@ function promoteSkill(name, cwd) {
6697
6975
  console.error("Usage: hivemind skillify promote <skill-name>");
6698
6976
  process.exit(1);
6699
6977
  }
6700
- const projectPath = join27(cwd, ".claude", "skills", name);
6701
- const globalPath = join27(homedir17(), ".claude", "skills", name);
6702
- if (!existsSync24(join27(projectPath, "SKILL.md"))) {
6978
+ const projectPath = join29(cwd, ".claude", "skills", name);
6979
+ const globalPath = join29(homedir19(), ".claude", "skills", name);
6980
+ if (!existsSync26(join29(projectPath, "SKILL.md"))) {
6703
6981
  console.error(`Skill '${name}' not found at ${projectPath}/SKILL.md`);
6704
6982
  process.exit(1);
6705
6983
  }
6706
- if (existsSync24(join27(globalPath, "SKILL.md"))) {
6984
+ if (existsSync26(join29(globalPath, "SKILL.md"))) {
6707
6985
  console.error(`Skill '${name}' already exists at ${globalPath}/SKILL.md \u2014 refusing to overwrite. Remove it first or rename the project skill.`);
6708
6986
  process.exit(1);
6709
6987
  }
6710
- mkdirSync10(dirname6(globalPath), { recursive: true });
6711
- renameSync4(projectPath, globalPath);
6988
+ mkdirSync11(dirname7(globalPath), { recursive: true });
6989
+ renameSync6(projectPath, globalPath);
6712
6990
  console.log(`Promoted '${name}' from ${projectPath} \u2192 ${globalPath}.`);
6713
6991
  }
6714
6992
  function teamAdd(name) {
@@ -6814,7 +7092,7 @@ async function pullSkills(args) {
6814
7092
  console.error(`pull failed: ${e?.message ?? e}`);
6815
7093
  process.exit(1);
6816
7094
  }
6817
- const dest = toRaw === "global" ? join27(homedir17(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
7095
+ const dest = toRaw === "global" ? join29(homedir19(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
6818
7096
  const filterDesc = users.length === 0 ? "all users" : users.join(", ");
6819
7097
  console.log(`Destination: ${dest}`);
6820
7098
  console.log(`Filter: ${filterDesc}${skillName ? ` \xB7 skill='${skillName}'` : ""}${dryRun ? " \xB7 dry-run" : ""}${force ? " \xB7 force" : ""}`);
@@ -6864,7 +7142,7 @@ async function unpullSkills(args) {
6864
7142
  all,
6865
7143
  legacyCleanup
6866
7144
  });
6867
- const dest = toRaw === "global" ? join27(homedir17(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
7145
+ const dest = toRaw === "global" ? join29(homedir19(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
6868
7146
  const filterParts = [];
6869
7147
  if (users.length > 0)
6870
7148
  filterParts.push(`users=${users.join(",")}`);
@@ -6960,13 +7238,13 @@ if (process.argv[1] && process.argv[1].endsWith("skillify.js")) {
6960
7238
 
6961
7239
  // dist/src/cli/update.js
6962
7240
  import { execFileSync as execFileSync4 } from "node:child_process";
6963
- import { existsSync as existsSync25, readFileSync as readFileSync19, realpathSync } from "node:fs";
6964
- import { dirname as dirname8, sep } from "node:path";
7241
+ import { existsSync as existsSync27, readFileSync as readFileSync22, realpathSync } from "node:fs";
7242
+ import { dirname as dirname9, sep } from "node:path";
6965
7243
  import { fileURLToPath as fileURLToPath2 } from "node:url";
6966
7244
 
6967
7245
  // dist/src/utils/version-check.js
6968
- import { readFileSync as readFileSync18 } from "node:fs";
6969
- import { dirname as dirname7, join as join28 } from "node:path";
7246
+ import { readFileSync as readFileSync21 } from "node:fs";
7247
+ import { dirname as dirname8, join as join30 } from "node:path";
6970
7248
  function isNewer(latest, current) {
6971
7249
  const parse = (v) => v.split(".").map(Number);
6972
7250
  const [la, lb, lc] = parse(latest);
@@ -6985,24 +7263,24 @@ function detectInstallKind(argv1) {
6985
7263
  return argv1 ?? process.argv[1] ?? fileURLToPath2(import.meta.url);
6986
7264
  }
6987
7265
  })();
6988
- let dir = dirname8(realArgv1);
7266
+ let dir = dirname9(realArgv1);
6989
7267
  let installDir = null;
6990
7268
  for (let i = 0; i < 10; i++) {
6991
7269
  const pkgPath = `${dir}${sep}package.json`;
6992
7270
  try {
6993
- const pkg = JSON.parse(readFileSync19(pkgPath, "utf-8"));
7271
+ const pkg = JSON.parse(readFileSync22(pkgPath, "utf-8"));
6994
7272
  if (pkg.name === PKG_NAME || pkg.name === "hivemind") {
6995
7273
  installDir = dir;
6996
7274
  break;
6997
7275
  }
6998
7276
  } catch {
6999
7277
  }
7000
- const parent = dirname8(dir);
7278
+ const parent = dirname9(dir);
7001
7279
  if (parent === dir)
7002
7280
  break;
7003
7281
  dir = parent;
7004
7282
  }
7005
- installDir ??= dirname8(realArgv1);
7283
+ installDir ??= dirname9(realArgv1);
7006
7284
  if (realArgv1.includes(`${sep}_npx${sep}`) || realArgv1.includes(`${sep}.npx${sep}`)) {
7007
7285
  return { kind: "npx", installDir };
7008
7286
  }
@@ -7011,10 +7289,10 @@ function detectInstallKind(argv1) {
7011
7289
  }
7012
7290
  let gitDir = installDir;
7013
7291
  for (let i = 0; i < 6; i++) {
7014
- if (existsSync25(`${gitDir}${sep}.git`)) {
7292
+ if (existsSync27(`${gitDir}${sep}.git`)) {
7015
7293
  return { kind: "local-dev", installDir };
7016
7294
  }
7017
- const parent = dirname8(gitDir);
7295
+ const parent = dirname9(gitDir);
7018
7296
  if (parent === gitDir)
7019
7297
  break;
7020
7298
  gitDir = parent;
@@ -7157,12 +7435,28 @@ Usage:
7157
7435
 
7158
7436
  Semantic search (embeddings):
7159
7437
  hivemind embeddings install Download @huggingface/transformers
7160
- once (~600 MB) into a shared dir
7161
- and symlink every detected agent
7162
- plugin to it. Idempotent.
7163
- hivemind embeddings uninstall [--prune] Remove the per-agent symlinks.
7164
- --prune also deletes the shared dir.
7165
- hivemind embeddings status Show shared-deps + per-agent state.
7438
+ once (~600 MB) into a shared dir,
7439
+ symlink every detected agent
7440
+ plugin to it, and set
7441
+ embeddings.enabled = true in
7442
+ ~/.deeplake/config.json. Idempotent.
7443
+ hivemind embeddings enable Light opt-in: flip
7444
+ embeddings.enabled = true in
7445
+ ~/.deeplake/config.json. Use this
7446
+ after \`disable\` to turn back on
7447
+ without re-running install.
7448
+ hivemind embeddings disable Light opt-out: flip
7449
+ embeddings.enabled = false and
7450
+ SIGTERM the running daemon. Shared
7451
+ deps stay on disk.
7452
+ hivemind embeddings uninstall [--prune] Full opt-out: remove the per-agent
7453
+ symlinks, flip
7454
+ embeddings.enabled = false, and
7455
+ SIGTERM the daemon. --prune also
7456
+ deletes the shared dir to reclaim
7457
+ ~600 MB.
7458
+ hivemind embeddings status Show config + shared-deps + per-
7459
+ agent state.
7166
7460
 
7167
7461
  Add --with-embeddings to "hivemind install" (or "hivemind <agent> install")
7168
7462
  to run "embeddings install" automatically after installing the agent(s).
@@ -7232,7 +7526,7 @@ async function runInstallAll(args) {
7232
7526
  runSingleInstall(id);
7233
7527
  if (withEmbeddings) {
7234
7528
  log("");
7235
- enableEmbeddings();
7529
+ installEmbeddings();
7236
7530
  }
7237
7531
  await maybeShowOrgChoice();
7238
7532
  log("");
@@ -7325,19 +7619,27 @@ async function main() {
7325
7619
  }
7326
7620
  if (cmd === "embeddings") {
7327
7621
  const sub = args[1];
7328
- if (sub === "install" || sub === "enable") {
7622
+ if (sub === "install") {
7623
+ installEmbeddings();
7624
+ return;
7625
+ }
7626
+ if (sub === "enable") {
7329
7627
  enableEmbeddings();
7330
7628
  return;
7331
7629
  }
7332
- if (sub === "uninstall" || sub === "disable") {
7333
- disableEmbeddings({ prune: hasFlag(args.slice(2), "--prune") });
7630
+ if (sub === "disable") {
7631
+ disableEmbeddings();
7632
+ return;
7633
+ }
7634
+ if (sub === "uninstall") {
7635
+ uninstallEmbeddings({ prune: hasFlag(args.slice(2), "--prune") });
7334
7636
  return;
7335
7637
  }
7336
7638
  if (sub === "status") {
7337
7639
  statusEmbeddings();
7338
7640
  return;
7339
7641
  }
7340
- warn("Usage: hivemind embeddings install | uninstall [--prune] | status");
7642
+ warn("Usage: hivemind embeddings install | enable | disable | uninstall [--prune] | status");
7341
7643
  process.exit(1);
7342
7644
  }
7343
7645
  if (AUTH_SUBCOMMANDS.has(cmd)) {
@@ -7351,7 +7653,7 @@ async function main() {
7351
7653
  runSingleInstall(cmd);
7352
7654
  if (hasFlag(args.slice(2), "--with-embeddings")) {
7353
7655
  log("");
7354
- enableEmbeddings();
7656
+ installEmbeddings();
7355
7657
  }
7356
7658
  } else if (sub === "uninstall")
7357
7659
  runSingleUninstall(cmd);