@deeplake/hivemind 0.7.16 → 0.7.18
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/bundle/cli.js +294 -105
- package/codex/bundle/session-start.js +1154 -25
- package/codex/bundle/{skilify-worker.js → skillify-worker.js} +65 -30
- package/codex/bundle/stop.js +105 -68
- package/cursor/bundle/capture.js +84 -47
- package/cursor/bundle/session-end.js +82 -45
- package/cursor/bundle/session-start.js +633 -25
- package/cursor/bundle/{skilify-worker.js → skillify-worker.js} +65 -30
- package/hermes/bundle/capture.js +84 -47
- package/hermes/bundle/session-end.js +82 -45
- package/hermes/bundle/session-start.js +631 -23
- package/hermes/bundle/{skilify-worker.js → skillify-worker.js} +65 -30
- package/openclaw/dist/index.js +47 -30
- package/openclaw/dist/{skilify-worker.js → skillify-worker.js} +65 -30
- package/openclaw/openclaw.plugin.json +1 -1
- package/openclaw/package.json +1 -1
- package/openclaw/skills/SKILL.md +19 -19
- package/package.json +1 -1
- package/pi/extension-source/hivemind.ts +94 -45
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// dist/src/
|
|
4
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as
|
|
5
|
-
import { join as
|
|
3
|
+
// dist/src/skillify/skillify-worker.js
|
|
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";
|
|
6
6
|
|
|
7
7
|
// dist/src/utils/debug.js
|
|
8
8
|
import { appendFileSync } from "node:fs";
|
|
@@ -29,7 +29,7 @@ function deeplakeClientHeader() {
|
|
|
29
29
|
return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// dist/src/
|
|
32
|
+
// dist/src/skillify/extractors/index.js
|
|
33
33
|
function extractPairs(rows) {
|
|
34
34
|
const pairs = [];
|
|
35
35
|
let pendingPrompt = null;
|
|
@@ -60,7 +60,7 @@ function extractPairs(rows) {
|
|
|
60
60
|
return pairs;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// dist/src/
|
|
63
|
+
// dist/src/skillify/skill-writer.js
|
|
64
64
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
65
65
|
import { homedir as homedir2 } from "node:os";
|
|
66
66
|
import { join as join2 } from "node:path";
|
|
@@ -216,7 +216,7 @@ function resolveSkillsRoot(install, cwd) {
|
|
|
216
216
|
return join2(cwd, ".claude", "skills");
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
// dist/src/
|
|
219
|
+
// dist/src/skillify/skills-table.js
|
|
220
220
|
import { randomUUID } from "node:crypto";
|
|
221
221
|
|
|
222
222
|
// dist/src/utils/sql.js
|
|
@@ -227,7 +227,7 @@ function sqlIdent(name) {
|
|
|
227
227
|
return name;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
// dist/src/
|
|
230
|
+
// dist/src/skillify/skills-table.js
|
|
231
231
|
function createSkillsTableSql(tableName) {
|
|
232
232
|
const safe = sqlIdent(tableName);
|
|
233
233
|
return `CREATE TABLE IF NOT EXISTS "${safe}" (id TEXT NOT NULL DEFAULT '', name TEXT NOT NULL DEFAULT '', project TEXT NOT NULL DEFAULT '', project_key TEXT NOT NULL DEFAULT '', local_path TEXT NOT NULL DEFAULT '', install TEXT NOT NULL DEFAULT 'project', source_sessions TEXT NOT NULL DEFAULT '[]', source_agent TEXT NOT NULL DEFAULT '', scope TEXT NOT NULL DEFAULT 'me', author TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', trigger_text TEXT NOT NULL DEFAULT '', body TEXT NOT NULL DEFAULT '', version BIGINT NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT '', updated_at TEXT NOT NULL DEFAULT '') USING deeplake`;
|
|
@@ -256,7 +256,7 @@ async function insertSkillRow(args) {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
// dist/src/
|
|
259
|
+
// dist/src/skillify/gate-parser.js
|
|
260
260
|
function extractJsonBlock(s) {
|
|
261
261
|
const trimmed = s.trim();
|
|
262
262
|
if (!trimmed)
|
|
@@ -294,7 +294,7 @@ function parseVerdict(raw) {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
// dist/src/
|
|
297
|
+
// dist/src/skillify/gate-runner.js
|
|
298
298
|
import { execFileSync } from "node:child_process";
|
|
299
299
|
import { existsSync as existsSync2 } from "node:fs";
|
|
300
300
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -403,28 +403,61 @@ function runGate(opts) {
|
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
// dist/src/
|
|
407
|
-
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, writeSync, mkdirSync as mkdirSync2, renameSync, existsSync as
|
|
406
|
+
// dist/src/skillify/state.js
|
|
407
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, writeSync, mkdirSync as mkdirSync2, renameSync as renameSync2, existsSync as existsSync4, unlinkSync, openSync, closeSync } from "node:fs";
|
|
408
408
|
import { execSync } from "node:child_process";
|
|
409
|
-
import { homedir as
|
|
409
|
+
import { homedir as homedir5 } from "node:os";
|
|
410
410
|
import { createHash } from "node:crypto";
|
|
411
|
-
import { join as
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
import { join as join5, basename } from "node:path";
|
|
412
|
+
|
|
413
|
+
// dist/src/skillify/legacy-migration.js
|
|
414
|
+
import { existsSync as existsSync3, renameSync } from "node:fs";
|
|
415
|
+
import { homedir as homedir4 } from "node:os";
|
|
416
|
+
import { join as join4 } from "node:path";
|
|
417
|
+
var dlog = (msg) => log("skillify-migrate", msg);
|
|
418
|
+
var attempted = false;
|
|
419
|
+
function migrateLegacyStateDir() {
|
|
420
|
+
if (attempted)
|
|
421
|
+
return;
|
|
422
|
+
attempted = true;
|
|
423
|
+
const root = join4(homedir4(), ".deeplake", "state");
|
|
424
|
+
const legacy = join4(root, "skilify");
|
|
425
|
+
const current = join4(root, "skillify");
|
|
426
|
+
if (!existsSync3(legacy))
|
|
427
|
+
return;
|
|
428
|
+
if (existsSync3(current))
|
|
429
|
+
return;
|
|
430
|
+
try {
|
|
431
|
+
renameSync(legacy, current);
|
|
432
|
+
dlog(`migrated ${legacy} -> ${current}`);
|
|
433
|
+
} catch (err) {
|
|
434
|
+
const code = err.code;
|
|
435
|
+
if (code === "EXDEV" || code === "EPERM") {
|
|
436
|
+
dlog(`migration failed (${code}); leaving legacy dir in place`);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
throw err;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// dist/src/skillify/state.js
|
|
444
|
+
var dlog2 = (msg) => log("skillify-state", msg);
|
|
445
|
+
var STATE_DIR = join5(homedir5(), ".deeplake", "state", "skillify");
|
|
414
446
|
var YIELD_BUF = new Int32Array(new SharedArrayBuffer(4));
|
|
415
447
|
var TRIGGER_THRESHOLD = (() => {
|
|
416
|
-
const n = Number(process.env.
|
|
448
|
+
const n = Number(process.env.HIVEMIND_SKILLIFY_EVERY_N_TURNS ?? "");
|
|
417
449
|
return Number.isInteger(n) && n > 0 ? n : 20;
|
|
418
450
|
})();
|
|
419
451
|
function statePath(projectKey) {
|
|
420
|
-
return
|
|
452
|
+
return join5(STATE_DIR, `${projectKey}.json`);
|
|
421
453
|
}
|
|
422
454
|
function lockPath(projectKey) {
|
|
423
|
-
return
|
|
455
|
+
return join5(STATE_DIR, `${projectKey}.lock`);
|
|
424
456
|
}
|
|
425
457
|
function readState(projectKey) {
|
|
458
|
+
migrateLegacyStateDir();
|
|
426
459
|
const p = statePath(projectKey);
|
|
427
|
-
if (!
|
|
460
|
+
if (!existsSync4(p))
|
|
428
461
|
return null;
|
|
429
462
|
try {
|
|
430
463
|
return JSON.parse(readFileSync2(p, "utf-8"));
|
|
@@ -433,13 +466,15 @@ function readState(projectKey) {
|
|
|
433
466
|
}
|
|
434
467
|
}
|
|
435
468
|
function writeState(projectKey, state) {
|
|
469
|
+
migrateLegacyStateDir();
|
|
436
470
|
mkdirSync2(STATE_DIR, { recursive: true });
|
|
437
471
|
const p = statePath(projectKey);
|
|
438
472
|
const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
|
|
439
473
|
writeFileSync2(tmp, JSON.stringify(state, null, 2));
|
|
440
|
-
|
|
474
|
+
renameSync2(tmp, p);
|
|
441
475
|
}
|
|
442
476
|
function withRmwLock(projectKey, fn) {
|
|
477
|
+
migrateLegacyStateDir();
|
|
443
478
|
mkdirSync2(STATE_DIR, { recursive: true });
|
|
444
479
|
const rmw = lockPath(projectKey) + ".rmw";
|
|
445
480
|
const deadline = Date.now() + 2e3;
|
|
@@ -451,11 +486,11 @@ function withRmwLock(projectKey, fn) {
|
|
|
451
486
|
if (e.code !== "EEXIST")
|
|
452
487
|
throw e;
|
|
453
488
|
if (Date.now() > deadline) {
|
|
454
|
-
|
|
489
|
+
dlog2(`rmw lock deadline exceeded for ${projectKey}, reclaiming stale lock`);
|
|
455
490
|
try {
|
|
456
491
|
unlinkSync(rmw);
|
|
457
492
|
} catch (unlinkErr) {
|
|
458
|
-
|
|
493
|
+
dlog2(`stale rmw lock unlink failed for ${projectKey}: ${unlinkErr.message}`);
|
|
459
494
|
}
|
|
460
495
|
continue;
|
|
461
496
|
}
|
|
@@ -469,7 +504,7 @@ function withRmwLock(projectKey, fn) {
|
|
|
469
504
|
try {
|
|
470
505
|
unlinkSync(rmw);
|
|
471
506
|
} catch (unlinkErr) {
|
|
472
|
-
|
|
507
|
+
dlog2(`rmw lock cleanup failed for ${projectKey}: ${unlinkErr.message}`);
|
|
473
508
|
}
|
|
474
509
|
}
|
|
475
510
|
}
|
|
@@ -509,18 +544,18 @@ function releaseWorkerLock(projectKey) {
|
|
|
509
544
|
}
|
|
510
545
|
}
|
|
511
546
|
|
|
512
|
-
// dist/src/
|
|
547
|
+
// dist/src/skillify/skillify-worker.js
|
|
513
548
|
var cfg = JSON.parse(readFileSync3(process.argv[2], "utf-8"));
|
|
514
549
|
var tmpDir = cfg.tmpDir;
|
|
515
|
-
var verdictPath =
|
|
516
|
-
var promptPath =
|
|
550
|
+
var verdictPath = join6(tmpDir, "verdict.json");
|
|
551
|
+
var promptPath = join6(tmpDir, "prompt.txt");
|
|
517
552
|
var SESSIONS_TO_MINE = 10;
|
|
518
553
|
var PAIR_CHAR_CAP = 2e3;
|
|
519
554
|
var TOTAL_PAIRS_CHAR_CAP = 4e4;
|
|
520
555
|
var EXISTING_SKILLS_CHAR_CAP = 3e4;
|
|
521
556
|
function wlog(msg) {
|
|
522
557
|
try {
|
|
523
|
-
appendFileSync2(cfg.
|
|
558
|
+
appendFileSync2(cfg.skillifyLog, `[${utcTimestamp()}] skillify-worker(${cfg.projectKey}): ${msg}
|
|
524
559
|
`);
|
|
525
560
|
} catch {
|
|
526
561
|
}
|
|
@@ -715,7 +750,7 @@ function buildPrompt(pairs) {
|
|
|
715
750
|
].join("\n");
|
|
716
751
|
}
|
|
717
752
|
function readVerdict(stdout) {
|
|
718
|
-
if (
|
|
753
|
+
if (existsSync5(verdictPath)) {
|
|
719
754
|
try {
|
|
720
755
|
const text = readFileSync3(verdictPath, "utf-8");
|
|
721
756
|
const v2 = parseVerdict(text);
|
|
@@ -784,9 +819,9 @@ async function main() {
|
|
|
784
819
|
timeoutMs: 12e4
|
|
785
820
|
});
|
|
786
821
|
try {
|
|
787
|
-
writeFileSync3(
|
|
822
|
+
writeFileSync3(join6(tmpDir, "gate-stdout.txt"), gate.stdout);
|
|
788
823
|
if (gate.stderr)
|
|
789
|
-
writeFileSync3(
|
|
824
|
+
writeFileSync3(join6(tmpDir, "gate-stderr.txt"), gate.stderr);
|
|
790
825
|
} catch {
|
|
791
826
|
}
|
|
792
827
|
if (gate.errored) {
|
package/hermes/bundle/capture.js
CHANGED
|
@@ -838,7 +838,7 @@ function embeddingsDisabled() {
|
|
|
838
838
|
|
|
839
839
|
// dist/src/hooks/hermes/capture.js
|
|
840
840
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
841
|
-
import { dirname as dirname3, join as
|
|
841
|
+
import { dirname as dirname3, join as join14 } from "node:path";
|
|
842
842
|
|
|
843
843
|
// dist/src/hooks/summary-state.js
|
|
844
844
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, writeSync as writeSync2, mkdirSync as mkdirSync2, renameSync, existsSync as existsSync4, unlinkSync as unlinkSync2, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
|
|
@@ -1096,14 +1096,14 @@ function bundleDirFromImportMeta(importMetaUrl) {
|
|
|
1096
1096
|
return dirname(fileURLToPath(importMetaUrl));
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
|
-
// dist/src/
|
|
1099
|
+
// dist/src/skillify/spawn-skillify-worker.js
|
|
1100
1100
|
import { spawn as spawn3 } from "node:child_process";
|
|
1101
1101
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1102
1102
|
import { dirname as dirname2, join as join10 } from "node:path";
|
|
1103
1103
|
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, appendFileSync as appendFileSync3, chmodSync } from "node:fs";
|
|
1104
1104
|
import { homedir as homedir8, tmpdir as tmpdir3 } from "node:os";
|
|
1105
1105
|
|
|
1106
|
-
// dist/src/
|
|
1106
|
+
// dist/src/skillify/gate-runner.js
|
|
1107
1107
|
import { execFileSync } from "node:child_process";
|
|
1108
1108
|
import { existsSync as existsSync5 } from "node:fs";
|
|
1109
1109
|
import { homedir as homedir7 } from "node:os";
|
|
@@ -1134,20 +1134,20 @@ function findAgentBin(agent) {
|
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
// dist/src/
|
|
1137
|
+
// dist/src/skillify/spawn-skillify-worker.js
|
|
1138
1138
|
var HOME2 = homedir8();
|
|
1139
|
-
var
|
|
1140
|
-
function
|
|
1139
|
+
var SKILLIFY_LOG = join10(HOME2, ".claude", "hooks", "skillify.log");
|
|
1140
|
+
function skillifyLog(msg) {
|
|
1141
1141
|
try {
|
|
1142
|
-
mkdirSync5(dirname2(
|
|
1143
|
-
appendFileSync3(
|
|
1142
|
+
mkdirSync5(dirname2(SKILLIFY_LOG), { recursive: true });
|
|
1143
|
+
appendFileSync3(SKILLIFY_LOG, `[${utcTimestamp()}] ${msg}
|
|
1144
1144
|
`);
|
|
1145
1145
|
} catch {
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
|
-
function
|
|
1148
|
+
function spawnSkillifyWorker(opts) {
|
|
1149
1149
|
const { config, cwd, projectKey, project, bundleDir, agent, scopeConfig, currentSessionId, reason } = opts;
|
|
1150
|
-
const tmpDir = join10(tmpdir3(), `deeplake-
|
|
1150
|
+
const tmpDir = join10(tmpdir3(), `deeplake-skillify-${projectKey}-${Date.now()}`);
|
|
1151
1151
|
mkdirSync5(tmpDir, { recursive: true, mode: 448 });
|
|
1152
1152
|
const gateBin = findAgentBin(agent);
|
|
1153
1153
|
const configFile = join10(tmpDir, "config.json");
|
|
@@ -1173,40 +1173,72 @@ function spawnSkilifyWorker(opts) {
|
|
|
1173
1173
|
hermesModel: process.env.HIVEMIND_HERMES_MODEL,
|
|
1174
1174
|
piProvider: process.env.HIVEMIND_PI_PROVIDER,
|
|
1175
1175
|
piModel: process.env.HIVEMIND_PI_MODEL,
|
|
1176
|
-
|
|
1176
|
+
skillifyLog: SKILLIFY_LOG,
|
|
1177
1177
|
currentSessionId
|
|
1178
1178
|
}), { mode: 384 });
|
|
1179
1179
|
try {
|
|
1180
1180
|
chmodSync(configFile, 384);
|
|
1181
1181
|
} catch {
|
|
1182
1182
|
}
|
|
1183
|
-
|
|
1184
|
-
const workerPath = join10(bundleDir, "
|
|
1183
|
+
skillifyLog(`${reason}: spawning skillify worker for project=${project} key=${projectKey}`);
|
|
1184
|
+
const workerPath = join10(bundleDir, "skillify-worker.js");
|
|
1185
1185
|
spawn3("nohup", ["node", workerPath, configFile], {
|
|
1186
1186
|
detached: true,
|
|
1187
1187
|
stdio: ["ignore", "ignore", "ignore"]
|
|
1188
1188
|
}).unref();
|
|
1189
|
-
|
|
1189
|
+
skillifyLog(`${reason}: spawned skillify worker for ${projectKey}`);
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
|
-
// dist/src/
|
|
1193
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, writeSync as writeSync3, mkdirSync as mkdirSync6, renameSync as
|
|
1192
|
+
// dist/src/skillify/state.js
|
|
1193
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, writeSync as writeSync3, mkdirSync as mkdirSync6, renameSync as renameSync3, existsSync as existsSync7, unlinkSync as unlinkSync3, openSync as openSync3, closeSync as closeSync3 } from "node:fs";
|
|
1194
1194
|
import { execSync as execSync2 } from "node:child_process";
|
|
1195
|
-
import { homedir as
|
|
1195
|
+
import { homedir as homedir10 } from "node:os";
|
|
1196
1196
|
import { createHash } from "node:crypto";
|
|
1197
|
-
import { join as
|
|
1198
|
-
|
|
1199
|
-
|
|
1197
|
+
import { join as join12, basename } from "node:path";
|
|
1198
|
+
|
|
1199
|
+
// dist/src/skillify/legacy-migration.js
|
|
1200
|
+
import { existsSync as existsSync6, renameSync as renameSync2 } from "node:fs";
|
|
1201
|
+
import { homedir as homedir9 } from "node:os";
|
|
1202
|
+
import { join as join11 } from "node:path";
|
|
1203
|
+
var dlog2 = (msg) => log("skillify-migrate", msg);
|
|
1204
|
+
var attempted = false;
|
|
1205
|
+
function migrateLegacyStateDir() {
|
|
1206
|
+
if (attempted)
|
|
1207
|
+
return;
|
|
1208
|
+
attempted = true;
|
|
1209
|
+
const root = join11(homedir9(), ".deeplake", "state");
|
|
1210
|
+
const legacy = join11(root, "skilify");
|
|
1211
|
+
const current = join11(root, "skillify");
|
|
1212
|
+
if (!existsSync6(legacy))
|
|
1213
|
+
return;
|
|
1214
|
+
if (existsSync6(current))
|
|
1215
|
+
return;
|
|
1216
|
+
try {
|
|
1217
|
+
renameSync2(legacy, current);
|
|
1218
|
+
dlog2(`migrated ${legacy} -> ${current}`);
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
const code = err.code;
|
|
1221
|
+
if (code === "EXDEV" || code === "EPERM") {
|
|
1222
|
+
dlog2(`migration failed (${code}); leaving legacy dir in place`);
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
throw err;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// dist/src/skillify/state.js
|
|
1230
|
+
var dlog3 = (msg) => log("skillify-state", msg);
|
|
1231
|
+
var STATE_DIR2 = join12(homedir10(), ".deeplake", "state", "skillify");
|
|
1200
1232
|
var YIELD_BUF2 = new Int32Array(new SharedArrayBuffer(4));
|
|
1201
1233
|
var TRIGGER_THRESHOLD = (() => {
|
|
1202
|
-
const n = Number(process.env.
|
|
1234
|
+
const n = Number(process.env.HIVEMIND_SKILLIFY_EVERY_N_TURNS ?? "");
|
|
1203
1235
|
return Number.isInteger(n) && n > 0 ? n : 20;
|
|
1204
1236
|
})();
|
|
1205
1237
|
function statePath2(projectKey) {
|
|
1206
|
-
return
|
|
1238
|
+
return join12(STATE_DIR2, `${projectKey}.json`);
|
|
1207
1239
|
}
|
|
1208
1240
|
function lockPath2(projectKey) {
|
|
1209
|
-
return
|
|
1241
|
+
return join12(STATE_DIR2, `${projectKey}.lock`);
|
|
1210
1242
|
}
|
|
1211
1243
|
function deriveProjectKey(cwd) {
|
|
1212
1244
|
const project = basename(cwd) || "unknown";
|
|
@@ -1224,8 +1256,9 @@ function deriveProjectKey(cwd) {
|
|
|
1224
1256
|
return { key, project };
|
|
1225
1257
|
}
|
|
1226
1258
|
function readState2(projectKey) {
|
|
1259
|
+
migrateLegacyStateDir();
|
|
1227
1260
|
const p = statePath2(projectKey);
|
|
1228
|
-
if (!
|
|
1261
|
+
if (!existsSync7(p))
|
|
1229
1262
|
return null;
|
|
1230
1263
|
try {
|
|
1231
1264
|
return JSON.parse(readFileSync5(p, "utf-8"));
|
|
@@ -1234,13 +1267,15 @@ function readState2(projectKey) {
|
|
|
1234
1267
|
}
|
|
1235
1268
|
}
|
|
1236
1269
|
function writeState2(projectKey, state) {
|
|
1270
|
+
migrateLegacyStateDir();
|
|
1237
1271
|
mkdirSync6(STATE_DIR2, { recursive: true });
|
|
1238
1272
|
const p = statePath2(projectKey);
|
|
1239
1273
|
const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
|
|
1240
1274
|
writeFileSync5(tmp, JSON.stringify(state, null, 2));
|
|
1241
|
-
|
|
1275
|
+
renameSync3(tmp, p);
|
|
1242
1276
|
}
|
|
1243
1277
|
function withRmwLock2(projectKey, fn) {
|
|
1278
|
+
migrateLegacyStateDir();
|
|
1244
1279
|
mkdirSync6(STATE_DIR2, { recursive: true });
|
|
1245
1280
|
const rmw = lockPath2(projectKey) + ".rmw";
|
|
1246
1281
|
const deadline = Date.now() + 2e3;
|
|
@@ -1252,11 +1287,11 @@ function withRmwLock2(projectKey, fn) {
|
|
|
1252
1287
|
if (e.code !== "EEXIST")
|
|
1253
1288
|
throw e;
|
|
1254
1289
|
if (Date.now() > deadline) {
|
|
1255
|
-
|
|
1290
|
+
dlog3(`rmw lock deadline exceeded for ${projectKey}, reclaiming stale lock`);
|
|
1256
1291
|
try {
|
|
1257
1292
|
unlinkSync3(rmw);
|
|
1258
1293
|
} catch (unlinkErr) {
|
|
1259
|
-
|
|
1294
|
+
dlog3(`stale rmw lock unlink failed for ${projectKey}: ${unlinkErr.message}`);
|
|
1260
1295
|
}
|
|
1261
1296
|
continue;
|
|
1262
1297
|
}
|
|
@@ -1270,7 +1305,7 @@ function withRmwLock2(projectKey, fn) {
|
|
|
1270
1305
|
try {
|
|
1271
1306
|
unlinkSync3(rmw);
|
|
1272
1307
|
} catch (unlinkErr) {
|
|
1273
|
-
|
|
1308
|
+
dlog3(`rmw lock cleanup failed for ${projectKey}: ${unlinkErr.message}`);
|
|
1274
1309
|
}
|
|
1275
1310
|
}
|
|
1276
1311
|
}
|
|
@@ -1300,20 +1335,21 @@ function resetCounter(projectKey) {
|
|
|
1300
1335
|
});
|
|
1301
1336
|
}
|
|
1302
1337
|
function tryAcquireWorkerLock(projectKey, maxAgeMs = 10 * 60 * 1e3) {
|
|
1338
|
+
migrateLegacyStateDir();
|
|
1303
1339
|
mkdirSync6(STATE_DIR2, { recursive: true });
|
|
1304
1340
|
const p = lockPath2(projectKey);
|
|
1305
|
-
if (
|
|
1341
|
+
if (existsSync7(p)) {
|
|
1306
1342
|
try {
|
|
1307
1343
|
const ageMs = Date.now() - parseInt(readFileSync5(p, "utf-8"), 10);
|
|
1308
1344
|
if (Number.isFinite(ageMs) && ageMs < maxAgeMs)
|
|
1309
1345
|
return false;
|
|
1310
1346
|
} catch (readErr) {
|
|
1311
|
-
|
|
1347
|
+
dlog3(`worker lock unreadable for ${projectKey}, treating as stale: ${readErr.message}`);
|
|
1312
1348
|
}
|
|
1313
1349
|
try {
|
|
1314
1350
|
unlinkSync3(p);
|
|
1315
1351
|
} catch (unlinkErr) {
|
|
1316
|
-
|
|
1352
|
+
dlog3(`could not unlink stale worker lock for ${projectKey}: ${unlinkErr.message}`);
|
|
1317
1353
|
return false;
|
|
1318
1354
|
}
|
|
1319
1355
|
}
|
|
@@ -1337,15 +1373,16 @@ function releaseWorkerLock(projectKey) {
|
|
|
1337
1373
|
}
|
|
1338
1374
|
}
|
|
1339
1375
|
|
|
1340
|
-
// dist/src/
|
|
1341
|
-
import { existsSync as
|
|
1342
|
-
import { homedir as
|
|
1343
|
-
import { join as
|
|
1344
|
-
var STATE_DIR3 =
|
|
1345
|
-
var CONFIG_PATH =
|
|
1376
|
+
// dist/src/skillify/scope-config.js
|
|
1377
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
1378
|
+
import { homedir as homedir11 } from "node:os";
|
|
1379
|
+
import { join as join13 } from "node:path";
|
|
1380
|
+
var STATE_DIR3 = join13(homedir11(), ".deeplake", "state", "skillify");
|
|
1381
|
+
var CONFIG_PATH = join13(STATE_DIR3, "config.json");
|
|
1346
1382
|
var DEFAULT = { scope: "me", team: [], install: "project" };
|
|
1347
1383
|
function loadScopeConfig() {
|
|
1348
|
-
|
|
1384
|
+
migrateLegacyStateDir();
|
|
1385
|
+
if (!existsSync8(CONFIG_PATH))
|
|
1349
1386
|
return DEFAULT;
|
|
1350
1387
|
try {
|
|
1351
1388
|
const raw = JSON.parse(readFileSync6(CONFIG_PATH, "utf-8"));
|
|
@@ -1358,9 +1395,9 @@ function loadScopeConfig() {
|
|
|
1358
1395
|
}
|
|
1359
1396
|
}
|
|
1360
1397
|
|
|
1361
|
-
// dist/src/
|
|
1398
|
+
// dist/src/skillify/triggers.js
|
|
1362
1399
|
function tryStopCounterTrigger(opts) {
|
|
1363
|
-
if (process.env.
|
|
1400
|
+
if (process.env.HIVEMIND_SKILLIFY_WORKER === "1")
|
|
1364
1401
|
return;
|
|
1365
1402
|
if (!opts.cwd)
|
|
1366
1403
|
return;
|
|
@@ -1369,13 +1406,13 @@ function tryStopCounterTrigger(opts) {
|
|
|
1369
1406
|
if (state.counter < TRIGGER_THRESHOLD)
|
|
1370
1407
|
return;
|
|
1371
1408
|
if (!tryAcquireWorkerLock(state.projectKey)) {
|
|
1372
|
-
|
|
1409
|
+
skillifyLog(`Stop: trigger suppressed (worker lock held) project=${state.project}`);
|
|
1373
1410
|
return;
|
|
1374
1411
|
}
|
|
1375
|
-
|
|
1412
|
+
skillifyLog(`Stop: threshold hit (counter=${state.counter}, N=${TRIGGER_THRESHOLD}) project=${state.project} agent=${opts.agent}`);
|
|
1376
1413
|
resetCounter(state.projectKey);
|
|
1377
1414
|
try {
|
|
1378
|
-
|
|
1415
|
+
spawnSkillifyWorker({
|
|
1379
1416
|
config: opts.config,
|
|
1380
1417
|
cwd: opts.cwd,
|
|
1381
1418
|
projectKey: state.projectKey,
|
|
@@ -1387,21 +1424,21 @@ function tryStopCounterTrigger(opts) {
|
|
|
1387
1424
|
reason: "Stop"
|
|
1388
1425
|
});
|
|
1389
1426
|
} catch (e) {
|
|
1390
|
-
|
|
1427
|
+
skillifyLog(`Stop spawn failed: ${e?.message ?? e}`);
|
|
1391
1428
|
try {
|
|
1392
1429
|
releaseWorkerLock(state.projectKey);
|
|
1393
1430
|
} catch {
|
|
1394
1431
|
}
|
|
1395
1432
|
}
|
|
1396
1433
|
} catch (e) {
|
|
1397
|
-
|
|
1434
|
+
skillifyLog(`Stop trigger error: ${e?.message ?? e}`);
|
|
1398
1435
|
}
|
|
1399
1436
|
}
|
|
1400
1437
|
|
|
1401
1438
|
// dist/src/hooks/hermes/capture.js
|
|
1402
1439
|
var log4 = (msg) => log("hermes-capture", msg);
|
|
1403
1440
|
function resolveEmbedDaemonPath() {
|
|
1404
|
-
return
|
|
1441
|
+
return join14(dirname3(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
|
|
1405
1442
|
}
|
|
1406
1443
|
var CAPTURE = process.env.HIVEMIND_CAPTURE !== "false";
|
|
1407
1444
|
function pickString(...candidates) {
|
|
@@ -1487,7 +1524,7 @@ async function main() {
|
|
|
1487
1524
|
}
|
|
1488
1525
|
log4("capture ok \u2192 cloud");
|
|
1489
1526
|
maybeTriggerPeriodicSummary(sessionId, cwd, config);
|
|
1490
|
-
if (event === "post_llm_call" && process.env.HIVEMIND_WIKI_WORKER !== "1" && process.env.
|
|
1527
|
+
if (event === "post_llm_call" && process.env.HIVEMIND_WIKI_WORKER !== "1" && process.env.HIVEMIND_SKILLIFY_WORKER !== "1") {
|
|
1491
1528
|
tryStopCounterTrigger({
|
|
1492
1529
|
config,
|
|
1493
1530
|
cwd,
|