@deeplake/hivemind 0.7.33 → 0.7.34

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.
@@ -55,7 +55,7 @@ var init_index_marker_store = __esm({
55
55
  // dist/src/hooks/codex/session-start.js
56
56
  import { spawn as spawn2 } from "node:child_process";
57
57
  import { fileURLToPath as fileURLToPath2 } from "node:url";
58
- import { dirname as dirname6, join as join14 } from "node:path";
58
+ import { dirname as dirname7, join as join15 } from "node:path";
59
59
 
60
60
  // dist/src/commands/auth.js
61
61
  import { execSync } from "node:child_process";
@@ -888,8 +888,8 @@ var DeeplakeApi = class {
888
888
 
889
889
  // dist/src/skillify/pull.js
890
890
  import { existsSync as existsSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync8, renameSync as renameSync4, lstatSync as lstatSync2, readlinkSync, symlinkSync, unlinkSync as unlinkSync5 } from "node:fs";
891
- import { homedir as homedir11 } from "node:os";
892
- import { dirname as dirname5, join as join13 } from "node:path";
891
+ import { homedir as homedir10 } from "node:os";
892
+ import { dirname as dirname6, join as join14 } from "node:path";
893
893
 
894
894
  // dist/src/skillify/skill-writer.js
895
895
  import { existsSync as existsSync5, mkdirSync as mkdirSync6, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync3, writeFileSync as writeFileSync5 } from "node:fs";
@@ -961,22 +961,31 @@ function parseFrontmatter(text) {
961
961
 
962
962
  // dist/src/skillify/manifest.js
963
963
  import { existsSync as existsSync7, lstatSync, mkdirSync as mkdirSync7, readFileSync as readFileSync8, renameSync as renameSync3, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "node:fs";
964
- import { homedir as homedir9 } from "node:os";
965
- import { dirname as dirname4, join as join11 } from "node:path";
964
+ import { dirname as dirname5, join as join12 } from "node:path";
966
965
 
967
966
  // dist/src/skillify/legacy-migration.js
968
967
  import { existsSync as existsSync6, renameSync as renameSync2 } from "node:fs";
968
+ import { dirname as dirname4, join as join11 } from "node:path";
969
+
970
+ // dist/src/skillify/state-dir.js
969
971
  import { homedir as homedir8 } from "node:os";
970
972
  import { join as join10 } from "node:path";
973
+ function getStateDir() {
974
+ const override = process.env.HIVEMIND_STATE_DIR?.trim();
975
+ return override && override.length > 0 ? override : join10(homedir8(), ".deeplake", "state", "skillify");
976
+ }
977
+
978
+ // dist/src/skillify/legacy-migration.js
971
979
  var dlog = (msg) => log("skillify-migrate", msg);
972
980
  var attempted = false;
973
981
  function migrateLegacyStateDir() {
982
+ if (process.env.HIVEMIND_STATE_DIR?.trim())
983
+ return;
974
984
  if (attempted)
975
985
  return;
976
986
  attempted = true;
977
- const root = join10(homedir8(), ".deeplake", "state");
978
- const legacy = join10(root, "skilify");
979
- const current = join10(root, "skillify");
987
+ const current = getStateDir();
988
+ const legacy = join11(dirname4(current), "skilify");
980
989
  if (!existsSync6(legacy))
981
990
  return;
982
991
  if (existsSync6(current))
@@ -986,8 +995,8 @@ function migrateLegacyStateDir() {
986
995
  dlog(`migrated ${legacy} -> ${current}`);
987
996
  } catch (err) {
988
997
  const code = err.code;
989
- if (code === "EXDEV" || code === "EPERM") {
990
- dlog(`migration failed (${code}); leaving legacy dir in place`);
998
+ if (code === "EXDEV" || code === "EPERM" || code === "ENOENT" || code === "EEXIST" || code === "ENOTEMPTY") {
999
+ dlog(`migration skipped (${code}); legacy dir left as-is or another process handled it`);
991
1000
  return;
992
1001
  }
993
1002
  throw err;
@@ -999,7 +1008,7 @@ function emptyManifest() {
999
1008
  return { version: 1, entries: [] };
1000
1009
  }
1001
1010
  function manifestPath() {
1002
- return join11(homedir9(), ".deeplake", "state", "skillify", "pulled.json");
1011
+ return join12(getStateDir(), "pulled.json");
1003
1012
  }
1004
1013
  function loadManifest(path = manifestPath()) {
1005
1014
  migrateLegacyStateDir();
@@ -1054,7 +1063,7 @@ function loadManifest(path = manifestPath()) {
1054
1063
  }
1055
1064
  function saveManifest(m, path = manifestPath()) {
1056
1065
  migrateLegacyStateDir();
1057
- mkdirSync7(dirname4(path), { recursive: true });
1066
+ mkdirSync7(dirname5(path), { recursive: true });
1058
1067
  const tmp = `${path}.tmp`;
1059
1068
  writeFileSync6(tmp, JSON.stringify(m, null, 2) + "\n", { mode: 384 });
1060
1069
  renameSync3(tmp, path);
@@ -1092,7 +1101,7 @@ function pruneOrphanedEntries(path = manifestPath()) {
1092
1101
  const live = [];
1093
1102
  let pruned = 0;
1094
1103
  for (const e of m.entries) {
1095
- if (existsSync7(join11(e.installRoot, e.dirName))) {
1104
+ if (existsSync7(join12(e.installRoot, e.dirName))) {
1096
1105
  live.push(e);
1097
1106
  continue;
1098
1107
  }
@@ -1106,25 +1115,25 @@ function pruneOrphanedEntries(path = manifestPath()) {
1106
1115
 
1107
1116
  // dist/src/skillify/agent-roots.js
1108
1117
  import { existsSync as existsSync8 } from "node:fs";
1109
- import { homedir as homedir10 } from "node:os";
1110
- import { join as join12 } from "node:path";
1118
+ import { homedir as homedir9 } from "node:os";
1119
+ import { join as join13 } from "node:path";
1111
1120
  function resolveDetected(home) {
1112
1121
  const out = [];
1113
- const codexInstalled = existsSync8(join12(home, ".codex"));
1114
- const piInstalled = existsSync8(join12(home, ".pi", "agent"));
1115
- const hermesInstalled = existsSync8(join12(home, ".hermes"));
1122
+ const codexInstalled = existsSync8(join13(home, ".codex"));
1123
+ const piInstalled = existsSync8(join13(home, ".pi", "agent"));
1124
+ const hermesInstalled = existsSync8(join13(home, ".hermes"));
1116
1125
  if (codexInstalled || piInstalled) {
1117
- out.push(join12(home, ".agents", "skills"));
1126
+ out.push(join13(home, ".agents", "skills"));
1118
1127
  }
1119
1128
  if (hermesInstalled) {
1120
- out.push(join12(home, ".hermes", "skills"));
1129
+ out.push(join13(home, ".hermes", "skills"));
1121
1130
  }
1122
1131
  if (piInstalled) {
1123
- out.push(join12(home, ".pi", "agent", "skills"));
1132
+ out.push(join13(home, ".pi", "agent", "skills"));
1124
1133
  }
1125
1134
  return out;
1126
1135
  }
1127
- function detectAgentSkillsRoots(canonicalRoot, home = homedir10()) {
1136
+ function detectAgentSkillsRoots(canonicalRoot, home = homedir9()) {
1128
1137
  return resolveDetected(home).filter((p) => p !== canonicalRoot);
1129
1138
  }
1130
1139
 
@@ -1168,15 +1177,15 @@ function isMissingTableError(message) {
1168
1177
  }
1169
1178
  function resolvePullDestination(install, cwd) {
1170
1179
  if (install === "global")
1171
- return join13(homedir11(), ".claude", "skills");
1180
+ return join14(homedir10(), ".claude", "skills");
1172
1181
  if (!cwd)
1173
1182
  throw new Error("install=project requires a cwd");
1174
- return join13(cwd, ".claude", "skills");
1183
+ return join14(cwd, ".claude", "skills");
1175
1184
  }
1176
1185
  function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
1177
1186
  const out = [];
1178
1187
  for (const root of agentRoots) {
1179
- const link = join13(root, dirName);
1188
+ const link = join14(root, dirName);
1180
1189
  let existing;
1181
1190
  try {
1182
1191
  existing = lstatSync2(link);
@@ -1204,7 +1213,7 @@ function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
1204
1213
  }
1205
1214
  }
1206
1215
  try {
1207
- mkdirSync8(dirname5(link), { recursive: true });
1216
+ mkdirSync8(dirname6(link), { recursive: true });
1208
1217
  symlinkSync(canonicalDir, link, "dir");
1209
1218
  out.push(link);
1210
1219
  } catch {
@@ -1219,7 +1228,7 @@ function backfillSymlinks(installRoot) {
1219
1228
  return;
1220
1229
  const detected = detectAgentSkillsRoots(installRoot);
1221
1230
  for (const entry of entries) {
1222
- const canonical = join13(entry.installRoot, entry.dirName);
1231
+ const canonical = join14(entry.installRoot, entry.dirName);
1223
1232
  if (!existsSync9(canonical))
1224
1233
  continue;
1225
1234
  const fresh = fanOutSymlinks(canonical, entry.dirName, detected);
@@ -1428,8 +1437,8 @@ async function runPull(opts) {
1428
1437
  summary.skipped++;
1429
1438
  continue;
1430
1439
  }
1431
- const skillDir = join13(root, dirName);
1432
- const skillFile = join13(skillDir, "SKILL.md");
1440
+ const skillDir = join14(root, dirName);
1441
+ const skillFile = join14(skillDir, "SKILL.md");
1433
1442
  const remoteVersion = Number(row.version ?? 1);
1434
1443
  const localVersion = readLocalVersion(skillFile);
1435
1444
  const action = decideAction({
@@ -1543,7 +1552,7 @@ async function autoPullSkills(deps = {}) {
1543
1552
 
1544
1553
  // dist/src/hooks/codex/session-start.js
1545
1554
  var log5 = (msg) => log("codex-session-start", msg);
1546
- var __bundleDir = dirname6(fileURLToPath2(import.meta.url));
1555
+ var __bundleDir = dirname7(fileURLToPath2(import.meta.url));
1547
1556
  async function main() {
1548
1557
  if (process.env.HIVEMIND_WIKI_WORKER === "1")
1549
1558
  return;
@@ -1557,7 +1566,7 @@ async function main() {
1557
1566
  log5(`credentials loaded: org=${creds.orgName ?? creds.orgId}`);
1558
1567
  }
1559
1568
  if (creds?.token) {
1560
- const setupScript = join14(__bundleDir, "session-start-setup.js");
1569
+ const setupScript = join15(__bundleDir, "session-start-setup.js");
1561
1570
  const child = spawn2("node", [setupScript], {
1562
1571
  detached: true,
1563
1572
  stdio: ["pipe", "ignore", "ignore"],
@@ -2,7 +2,7 @@
2
2
 
3
3
  // dist/src/skillify/skillify-worker.js
4
4
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync5, appendFileSync as appendFileSync2, rmSync } from "node:fs";
5
- import { join as join6 } from "node:path";
5
+ import { join as join7 } from "node:path";
6
6
 
7
7
  // dist/src/utils/debug.js
8
8
  import { appendFileSync } from "node:fs";
@@ -561,25 +561,34 @@ function resolveRecordScope(args) {
561
561
  }
562
562
 
563
563
  // dist/src/skillify/state.js
564
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, writeSync, mkdirSync as mkdirSync2, renameSync as renameSync2, existsSync as existsSync4, unlinkSync, openSync, closeSync } from "node:fs";
564
+ import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, writeSync, mkdirSync as mkdirSync2, renameSync as renameSync2, rmdirSync, existsSync as existsSync4, lstatSync, unlinkSync, openSync, closeSync } from "node:fs";
565
565
  import { execSync } from "node:child_process";
566
- import { homedir as homedir5 } from "node:os";
567
566
  import { createHash } from "node:crypto";
568
- import { join as join5, basename } from "node:path";
567
+ import { join as join6, basename } from "node:path";
569
568
 
570
569
  // dist/src/skillify/legacy-migration.js
571
570
  import { existsSync as existsSync3, renameSync } from "node:fs";
571
+ import { dirname, join as join5 } from "node:path";
572
+
573
+ // dist/src/skillify/state-dir.js
572
574
  import { homedir as homedir4 } from "node:os";
573
575
  import { join as join4 } from "node:path";
576
+ function getStateDir() {
577
+ const override = process.env.HIVEMIND_STATE_DIR?.trim();
578
+ return override && override.length > 0 ? override : join4(homedir4(), ".deeplake", "state", "skillify");
579
+ }
580
+
581
+ // dist/src/skillify/legacy-migration.js
574
582
  var dlog = (msg) => log("skillify-migrate", msg);
575
583
  var attempted = false;
576
584
  function migrateLegacyStateDir() {
585
+ if (process.env.HIVEMIND_STATE_DIR?.trim())
586
+ return;
577
587
  if (attempted)
578
588
  return;
579
589
  attempted = true;
580
- const root = join4(homedir4(), ".deeplake", "state");
581
- const legacy = join4(root, "skilify");
582
- const current = join4(root, "skillify");
590
+ const current = getStateDir();
591
+ const legacy = join5(dirname(current), "skilify");
583
592
  if (!existsSync3(legacy))
584
593
  return;
585
594
  if (existsSync3(current))
@@ -589,8 +598,8 @@ function migrateLegacyStateDir() {
589
598
  dlog(`migrated ${legacy} -> ${current}`);
590
599
  } catch (err) {
591
600
  const code = err.code;
592
- if (code === "EXDEV" || code === "EPERM") {
593
- dlog(`migration failed (${code}); leaving legacy dir in place`);
601
+ if (code === "EXDEV" || code === "EPERM" || code === "ENOENT" || code === "EEXIST" || code === "ENOTEMPTY") {
602
+ dlog(`migration skipped (${code}); legacy dir left as-is or another process handled it`);
594
603
  return;
595
604
  }
596
605
  throw err;
@@ -599,17 +608,16 @@ function migrateLegacyStateDir() {
599
608
 
600
609
  // dist/src/skillify/state.js
601
610
  var dlog2 = (msg) => log("skillify-state", msg);
602
- var STATE_DIR = join5(homedir5(), ".deeplake", "state", "skillify");
603
611
  var YIELD_BUF = new Int32Array(new SharedArrayBuffer(4));
604
612
  var TRIGGER_THRESHOLD = (() => {
605
613
  const n = Number(process.env.HIVEMIND_SKILLIFY_EVERY_N_TURNS ?? "");
606
614
  return Number.isInteger(n) && n > 0 ? n : 20;
607
615
  })();
608
616
  function statePath(projectKey) {
609
- return join5(STATE_DIR, `${projectKey}.json`);
617
+ return join6(getStateDir(), `${projectKey}.json`);
610
618
  }
611
619
  function lockPath(projectKey) {
612
- return join5(STATE_DIR, `${projectKey}.lock`);
620
+ return join6(getStateDir(), `${projectKey}.lock`);
613
621
  }
614
622
  function readState(projectKey) {
615
623
  migrateLegacyStateDir();
@@ -624,7 +632,7 @@ function readState(projectKey) {
624
632
  }
625
633
  function writeState(projectKey, state) {
626
634
  migrateLegacyStateDir();
627
- mkdirSync2(STATE_DIR, { recursive: true });
635
+ mkdirSync2(getStateDir(), { recursive: true });
628
636
  const p = statePath(projectKey);
629
637
  const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
630
638
  writeFileSync2(tmp, JSON.stringify(state, null, 2));
@@ -632,7 +640,7 @@ function writeState(projectKey, state) {
632
640
  }
633
641
  function withRmwLock(projectKey, fn) {
634
642
  migrateLegacyStateDir();
635
- mkdirSync2(STATE_DIR, { recursive: true });
643
+ mkdirSync2(getStateDir(), { recursive: true });
636
644
  const rmw = lockPath(projectKey) + ".rmw";
637
645
  const deadline = Date.now() + 2e3;
638
646
  let fd = null;
@@ -705,8 +713,8 @@ function releaseWorkerLock(projectKey) {
705
713
  var cfg = JSON.parse(readFileSync3(process.argv[2], "utf-8"));
706
714
  globalThis.__hivemind_tuning__ = cfg.tuning ?? {};
707
715
  var tmpDir = cfg.tmpDir;
708
- var verdictPath = join6(tmpDir, "verdict.json");
709
- var promptPath = join6(tmpDir, "prompt.txt");
716
+ var verdictPath = join7(tmpDir, "verdict.json");
717
+ var promptPath = join7(tmpDir, "prompt.txt");
710
718
  var SESSIONS_TO_MINE = 10;
711
719
  var PAIR_CHAR_CAP = 2e3;
712
720
  var TOTAL_PAIRS_CHAR_CAP = 4e4;
@@ -953,9 +961,9 @@ async function main() {
953
961
  timeoutMs: 12e4
954
962
  });
955
963
  try {
956
- writeFileSync3(join6(tmpDir, "gate-stdout.txt"), gate.stdout);
964
+ writeFileSync3(join7(tmpDir, "gate-stdout.txt"), gate.stdout);
957
965
  if (gate.stderr)
958
- writeFileSync3(join6(tmpDir, "gate-stderr.txt"), gate.stderr);
966
+ writeFileSync3(join7(tmpDir, "gate-stderr.txt"), gate.stderr);
959
967
  } catch {
960
968
  }
961
969
  if (gate.errored) {
@@ -55,7 +55,7 @@ var init_index_marker_store = __esm({
55
55
  // dist/src/hooks/codex/stop.js
56
56
  import { readFileSync as readFileSync11, existsSync as existsSync10 } from "node:fs";
57
57
  import { fileURLToPath as fileURLToPath3 } from "node:url";
58
- import { dirname as dirname5, join as join18 } from "node:path";
58
+ import { dirname as dirname6, join as join19 } from "node:path";
59
59
 
60
60
  // dist/src/utils/stdin.js
61
61
  function readStdin() {
@@ -1011,25 +1011,34 @@ function spawnSkillifyWorker(opts) {
1011
1011
  }
1012
1012
 
1013
1013
  // dist/src/skillify/state.js
1014
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, writeSync, mkdirSync as mkdirSync7, renameSync as renameSync3, existsSync as existsSync5, unlinkSync as unlinkSync3, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
1014
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, writeSync, mkdirSync as mkdirSync7, renameSync as renameSync3, rmdirSync, existsSync as existsSync5, lstatSync, unlinkSync as unlinkSync3, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
1015
1015
  import { execSync as execSync2 } from "node:child_process";
1016
- import { homedir as homedir9 } from "node:os";
1017
1016
  import { createHash } from "node:crypto";
1018
- import { join as join12, basename } from "node:path";
1017
+ import { join as join13, basename } from "node:path";
1019
1018
 
1020
1019
  // dist/src/skillify/legacy-migration.js
1021
1020
  import { existsSync as existsSync4, renameSync as renameSync2 } from "node:fs";
1021
+ import { dirname as dirname4, join as join12 } from "node:path";
1022
+
1023
+ // dist/src/skillify/state-dir.js
1022
1024
  import { homedir as homedir8 } from "node:os";
1023
1025
  import { join as join11 } from "node:path";
1026
+ function getStateDir() {
1027
+ const override = process.env.HIVEMIND_STATE_DIR?.trim();
1028
+ return override && override.length > 0 ? override : join11(homedir8(), ".deeplake", "state", "skillify");
1029
+ }
1030
+
1031
+ // dist/src/skillify/legacy-migration.js
1024
1032
  var dlog = (msg) => log("skillify-migrate", msg);
1025
1033
  var attempted = false;
1026
1034
  function migrateLegacyStateDir() {
1035
+ if (process.env.HIVEMIND_STATE_DIR?.trim())
1036
+ return;
1027
1037
  if (attempted)
1028
1038
  return;
1029
1039
  attempted = true;
1030
- const root = join11(homedir8(), ".deeplake", "state");
1031
- const legacy = join11(root, "skilify");
1032
- const current = join11(root, "skillify");
1040
+ const current = getStateDir();
1041
+ const legacy = join12(dirname4(current), "skilify");
1033
1042
  if (!existsSync4(legacy))
1034
1043
  return;
1035
1044
  if (existsSync4(current))
@@ -1039,8 +1048,8 @@ function migrateLegacyStateDir() {
1039
1048
  dlog(`migrated ${legacy} -> ${current}`);
1040
1049
  } catch (err) {
1041
1050
  const code = err.code;
1042
- if (code === "EXDEV" || code === "EPERM") {
1043
- dlog(`migration failed (${code}); leaving legacy dir in place`);
1051
+ if (code === "EXDEV" || code === "EPERM" || code === "ENOENT" || code === "EEXIST" || code === "ENOTEMPTY") {
1052
+ dlog(`migration skipped (${code}); legacy dir left as-is or another process handled it`);
1044
1053
  return;
1045
1054
  }
1046
1055
  throw err;
@@ -1049,17 +1058,16 @@ function migrateLegacyStateDir() {
1049
1058
 
1050
1059
  // dist/src/skillify/state.js
1051
1060
  var dlog2 = (msg) => log("skillify-state", msg);
1052
- var STATE_DIR = join12(homedir9(), ".deeplake", "state", "skillify");
1053
1061
  var YIELD_BUF = new Int32Array(new SharedArrayBuffer(4));
1054
1062
  var TRIGGER_THRESHOLD = (() => {
1055
1063
  const n = Number(process.env.HIVEMIND_SKILLIFY_EVERY_N_TURNS ?? "");
1056
1064
  return Number.isInteger(n) && n > 0 ? n : 20;
1057
1065
  })();
1058
1066
  function statePath(projectKey) {
1059
- return join12(STATE_DIR, `${projectKey}.json`);
1067
+ return join13(getStateDir(), `${projectKey}.json`);
1060
1068
  }
1061
1069
  function lockPath2(projectKey) {
1062
- return join12(STATE_DIR, `${projectKey}.lock`);
1070
+ return join13(getStateDir(), `${projectKey}.lock`);
1063
1071
  }
1064
1072
  var DEFAULT_PORTS = {
1065
1073
  http: "80",
@@ -1115,7 +1123,7 @@ function readState(projectKey) {
1115
1123
  }
1116
1124
  function writeState(projectKey, state) {
1117
1125
  migrateLegacyStateDir();
1118
- mkdirSync7(STATE_DIR, { recursive: true });
1126
+ mkdirSync7(getStateDir(), { recursive: true });
1119
1127
  const p = statePath(projectKey);
1120
1128
  const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
1121
1129
  writeFileSync6(tmp, JSON.stringify(state, null, 2));
@@ -1123,7 +1131,7 @@ function writeState(projectKey, state) {
1123
1131
  }
1124
1132
  function withRmwLock(projectKey, fn) {
1125
1133
  migrateLegacyStateDir();
1126
- mkdirSync7(STATE_DIR, { recursive: true });
1134
+ mkdirSync7(getStateDir(), { recursive: true });
1127
1135
  const rmw = lockPath2(projectKey) + ".rmw";
1128
1136
  const deadline = Date.now() + 2e3;
1129
1137
  let fd = null;
@@ -1166,7 +1174,7 @@ function resetCounter(projectKey) {
1166
1174
  }
1167
1175
  function tryAcquireWorkerLock(projectKey, maxAgeMs = 10 * 60 * 1e3) {
1168
1176
  migrateLegacyStateDir();
1169
- mkdirSync7(STATE_DIR, { recursive: true });
1177
+ mkdirSync7(getStateDir(), { recursive: true });
1170
1178
  const p = lockPath2(projectKey);
1171
1179
  if (existsSync5(p)) {
1172
1180
  try {
@@ -1179,8 +1187,22 @@ function tryAcquireWorkerLock(projectKey, maxAgeMs = 10 * 60 * 1e3) {
1179
1187
  try {
1180
1188
  unlinkSync3(p);
1181
1189
  } catch (unlinkErr) {
1182
- dlog2(`could not unlink stale worker lock for ${projectKey}: ${unlinkErr.message}`);
1183
- return false;
1190
+ if (unlinkErr?.code !== "EISDIR" && unlinkErr?.code !== "EPERM" && unlinkErr?.code !== "ENOENT") {
1191
+ dlog2(`could not unlink stale worker lock for ${projectKey}: ${unlinkErr.message}`);
1192
+ return false;
1193
+ }
1194
+ let isDir = false;
1195
+ try {
1196
+ isDir = lstatSync(p).isDirectory();
1197
+ } catch {
1198
+ }
1199
+ if (isDir) {
1200
+ try {
1201
+ rmdirSync(p);
1202
+ } catch (rmErr) {
1203
+ dlog2(`rmdir stale lock skipped for ${projectKey}: ${rmErr.message}`);
1204
+ }
1205
+ }
1184
1206
  }
1185
1207
  }
1186
1208
  try {
@@ -1205,13 +1227,14 @@ function releaseWorkerLock(projectKey) {
1205
1227
 
1206
1228
  // dist/src/skillify/scope-config.js
1207
1229
  import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
1208
- import { homedir as homedir10 } from "node:os";
1209
- import { join as join13 } from "node:path";
1210
- var STATE_DIR2 = join13(homedir10(), ".deeplake", "state", "skillify");
1211
- var CONFIG_PATH = join13(STATE_DIR2, "config.json");
1230
+ import { join as join14 } from "node:path";
1231
+ function configPath() {
1232
+ return join14(getStateDir(), "config.json");
1233
+ }
1212
1234
  var DEFAULT = { scope: "me", team: [], install: "project" };
1213
1235
  function loadScopeConfig() {
1214
1236
  migrateLegacyStateDir();
1237
+ const CONFIG_PATH = configPath();
1215
1238
  if (!existsSync6(CONFIG_PATH))
1216
1239
  return DEFAULT;
1217
1240
  try {
@@ -1267,16 +1290,16 @@ function forceSessionEndTrigger(opts) {
1267
1290
 
1268
1291
  // dist/src/hooks/summary-state.js
1269
1292
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync8, writeSync as writeSync2, mkdirSync as mkdirSync9, renameSync as renameSync4, existsSync as existsSync7, unlinkSync as unlinkSync4, openSync as openSync3, closeSync as closeSync3 } from "node:fs";
1270
- import { homedir as homedir11 } from "node:os";
1271
- import { join as join14 } from "node:path";
1293
+ import { homedir as homedir9 } from "node:os";
1294
+ import { join as join15 } from "node:path";
1272
1295
  var dlog3 = (msg) => log("summary-state", msg);
1273
- var STATE_DIR3 = join14(homedir11(), ".claude", "hooks", "summary-state");
1296
+ var STATE_DIR = join15(homedir9(), ".claude", "hooks", "summary-state");
1274
1297
  var YIELD_BUF2 = new Int32Array(new SharedArrayBuffer(4));
1275
1298
  function lockPath3(sessionId) {
1276
- return join14(STATE_DIR3, `${sessionId}.lock`);
1299
+ return join15(STATE_DIR, `${sessionId}.lock`);
1277
1300
  }
1278
1301
  function tryAcquireLock(sessionId, maxAgeMs = 10 * 60 * 1e3) {
1279
- mkdirSync9(STATE_DIR3, { recursive: true });
1302
+ mkdirSync9(STATE_DIR, { recursive: true });
1280
1303
  const p = lockPath3(sessionId);
1281
1304
  if (existsSync7(p)) {
1282
1305
  try {
@@ -1327,8 +1350,8 @@ function buildSessionPath(config, sessionId) {
1327
1350
  import { connect } from "node:net";
1328
1351
  import { spawn as spawn3 } from "node:child_process";
1329
1352
  import { openSync as openSync4, closeSync as closeSync4, writeSync as writeSync3, unlinkSync as unlinkSync5, existsSync as existsSync8, readFileSync as readFileSync9 } from "node:fs";
1330
- import { homedir as homedir12 } from "node:os";
1331
- import { join as join15 } from "node:path";
1353
+ import { homedir as homedir10 } from "node:os";
1354
+ import { join as join16 } from "node:path";
1332
1355
 
1333
1356
  // dist/src/embeddings/protocol.js
1334
1357
  var DEFAULT_SOCKET_DIR = "/tmp";
@@ -1342,7 +1365,7 @@ function pidPathFor(uid, dir = DEFAULT_SOCKET_DIR) {
1342
1365
  }
1343
1366
 
1344
1367
  // dist/src/embeddings/client.js
1345
- var SHARED_DAEMON_PATH = join15(homedir12(), ".hivemind", "embed-deps", "embed-daemon.js");
1368
+ var SHARED_DAEMON_PATH = join16(homedir10(), ".hivemind", "embed-deps", "embed-daemon.js");
1346
1369
  var log4 = (m) => log("embed-client", m);
1347
1370
  function getUid() {
1348
1371
  const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
@@ -1723,15 +1746,15 @@ function embeddingSqlLiteral(vec) {
1723
1746
 
1724
1747
  // dist/src/embeddings/disable.js
1725
1748
  import { createRequire as createRequire2 } from "node:module";
1726
- import { homedir as homedir14 } from "node:os";
1727
- import { join as join17 } from "node:path";
1749
+ import { homedir as homedir12 } from "node:os";
1750
+ import { join as join18 } from "node:path";
1728
1751
  import { pathToFileURL } from "node:url";
1729
1752
 
1730
1753
  // dist/src/user-config.js
1731
1754
  import { existsSync as existsSync9, mkdirSync as mkdirSync10, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync9 } from "node:fs";
1732
- import { homedir as homedir13 } from "node:os";
1733
- import { dirname as dirname4, join as join16 } from "node:path";
1734
- var _configPath = () => process.env.HIVEMIND_CONFIG_PATH ?? join16(homedir13(), ".deeplake", "config.json");
1755
+ import { homedir as homedir11 } from "node:os";
1756
+ import { dirname as dirname5, join as join17 } from "node:path";
1757
+ var _configPath = () => process.env.HIVEMIND_CONFIG_PATH ?? join17(homedir11(), ".deeplake", "config.json");
1735
1758
  var _cache = null;
1736
1759
  var _migrated = false;
1737
1760
  function readUserConfig() {
@@ -1755,7 +1778,7 @@ function writeUserConfig(patch) {
1755
1778
  const current = readUserConfig();
1756
1779
  const merged = deepMerge(current, patch);
1757
1780
  const path = _configPath();
1758
- const dir = dirname4(path);
1781
+ const dir = dirname5(path);
1759
1782
  if (!existsSync9(dir))
1760
1783
  mkdirSync10(dir, { recursive: true });
1761
1784
  const tmp = `${path}.tmp.${process.pid}`;
@@ -1809,7 +1832,7 @@ function deepMerge(base, patch) {
1809
1832
  // dist/src/embeddings/disable.js
1810
1833
  var cachedStatus = null;
1811
1834
  function defaultResolveTransformers() {
1812
- const sharedDir = join17(homedir14(), ".hivemind", "embed-deps");
1835
+ const sharedDir = join18(homedir12(), ".hivemind", "embed-deps");
1813
1836
  try {
1814
1837
  createRequire2(pathToFileURL(`${sharedDir}/`).href).resolve("@huggingface/transformers");
1815
1838
  return;
@@ -1842,9 +1865,9 @@ function embeddingsDisabled() {
1842
1865
  // dist/src/hooks/codex/stop.js
1843
1866
  var log5 = (msg) => log("codex-stop", msg);
1844
1867
  function resolveEmbedDaemonPath() {
1845
- return join18(dirname5(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
1868
+ return join19(dirname6(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
1846
1869
  }
1847
- var __bundleDir = dirname5(fileURLToPath3(import.meta.url));
1870
+ var __bundleDir = dirname6(fileURLToPath3(import.meta.url));
1848
1871
  var PLUGIN_VERSION = getInstalledVersion(__bundleDir, ".codex-plugin") ?? "";
1849
1872
  var CAPTURE = process.env.HIVEMIND_CAPTURE !== "false";
1850
1873
  async function main() {