@deeplake/hivemind 0.7.17 → 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 +148 -111
- package/codex/bundle/session-start.js +89 -55
- 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 +87 -53
- 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 +87 -53
- 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 +43 -43
|
@@ -55,7 +55,7 @@ var init_index_marker_store = __esm({
|
|
|
55
55
|
// dist/src/hooks/codex/session-start.js
|
|
56
56
|
import { spawn } from "node:child_process";
|
|
57
57
|
import { fileURLToPath } from "node:url";
|
|
58
|
-
import { dirname as dirname4, join as
|
|
58
|
+
import { dirname as dirname4, join as join11 } from "node:path";
|
|
59
59
|
|
|
60
60
|
// dist/src/commands/auth.js
|
|
61
61
|
import { execSync } from "node:child_process";
|
|
@@ -619,12 +619,12 @@ var DeeplakeApi = class {
|
|
|
619
619
|
}
|
|
620
620
|
};
|
|
621
621
|
|
|
622
|
-
// dist/src/
|
|
623
|
-
import { existsSync as
|
|
624
|
-
import { homedir as
|
|
625
|
-
import { dirname as dirname3, join as
|
|
622
|
+
// dist/src/skillify/pull.js
|
|
623
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, renameSync as renameSync3, lstatSync as lstatSync2, readlinkSync, symlinkSync, unlinkSync as unlinkSync3 } from "node:fs";
|
|
624
|
+
import { homedir as homedir8 } from "node:os";
|
|
625
|
+
import { dirname as dirname3, join as join10 } from "node:path";
|
|
626
626
|
|
|
627
|
-
// dist/src/
|
|
627
|
+
// dist/src/skillify/skill-writer.js
|
|
628
628
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, readdirSync, statSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
629
629
|
import { homedir as homedir4 } from "node:os";
|
|
630
630
|
import { join as join6 } from "node:path";
|
|
@@ -685,18 +685,51 @@ function parseFrontmatter(text) {
|
|
|
685
685
|
return { fm, body };
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
// dist/src/
|
|
689
|
-
import { existsSync as
|
|
688
|
+
// dist/src/skillify/manifest.js
|
|
689
|
+
import { existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync4, readFileSync as readFileSync6, renameSync as renameSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
690
|
+
import { homedir as homedir6 } from "node:os";
|
|
691
|
+
import { dirname as dirname2, join as join8 } from "node:path";
|
|
692
|
+
|
|
693
|
+
// dist/src/skillify/legacy-migration.js
|
|
694
|
+
import { existsSync as existsSync4, renameSync } from "node:fs";
|
|
690
695
|
import { homedir as homedir5 } from "node:os";
|
|
691
|
-
import {
|
|
696
|
+
import { join as join7 } from "node:path";
|
|
697
|
+
var dlog = (msg) => log("skillify-migrate", msg);
|
|
698
|
+
var attempted = false;
|
|
699
|
+
function migrateLegacyStateDir() {
|
|
700
|
+
if (attempted)
|
|
701
|
+
return;
|
|
702
|
+
attempted = true;
|
|
703
|
+
const root = join7(homedir5(), ".deeplake", "state");
|
|
704
|
+
const legacy = join7(root, "skilify");
|
|
705
|
+
const current = join7(root, "skillify");
|
|
706
|
+
if (!existsSync4(legacy))
|
|
707
|
+
return;
|
|
708
|
+
if (existsSync4(current))
|
|
709
|
+
return;
|
|
710
|
+
try {
|
|
711
|
+
renameSync(legacy, current);
|
|
712
|
+
dlog(`migrated ${legacy} -> ${current}`);
|
|
713
|
+
} catch (err) {
|
|
714
|
+
const code = err.code;
|
|
715
|
+
if (code === "EXDEV" || code === "EPERM") {
|
|
716
|
+
dlog(`migration failed (${code}); leaving legacy dir in place`);
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
throw err;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// dist/src/skillify/manifest.js
|
|
692
724
|
function emptyManifest() {
|
|
693
725
|
return { version: 1, entries: [] };
|
|
694
726
|
}
|
|
695
727
|
function manifestPath() {
|
|
696
|
-
return
|
|
728
|
+
return join8(homedir6(), ".deeplake", "state", "skillify", "pulled.json");
|
|
697
729
|
}
|
|
698
730
|
function loadManifest(path = manifestPath()) {
|
|
699
|
-
|
|
731
|
+
migrateLegacyStateDir();
|
|
732
|
+
if (!existsSync5(path))
|
|
700
733
|
return emptyManifest();
|
|
701
734
|
let raw;
|
|
702
735
|
try {
|
|
@@ -746,10 +779,11 @@ function loadManifest(path = manifestPath()) {
|
|
|
746
779
|
}
|
|
747
780
|
}
|
|
748
781
|
function saveManifest(m, path = manifestPath()) {
|
|
782
|
+
migrateLegacyStateDir();
|
|
749
783
|
mkdirSync4(dirname2(path), { recursive: true });
|
|
750
784
|
const tmp = `${path}.tmp`;
|
|
751
785
|
writeFileSync4(tmp, JSON.stringify(m, null, 2) + "\n", { mode: 384 });
|
|
752
|
-
|
|
786
|
+
renameSync2(tmp, path);
|
|
753
787
|
}
|
|
754
788
|
function recordPull(entry, path = manifestPath()) {
|
|
755
789
|
const m = loadManifest(path);
|
|
@@ -784,7 +818,7 @@ function pruneOrphanedEntries(path = manifestPath()) {
|
|
|
784
818
|
const live = [];
|
|
785
819
|
let pruned = 0;
|
|
786
820
|
for (const e of m.entries) {
|
|
787
|
-
if (
|
|
821
|
+
if (existsSync5(join8(e.installRoot, e.dirName))) {
|
|
788
822
|
live.push(e);
|
|
789
823
|
continue;
|
|
790
824
|
}
|
|
@@ -796,31 +830,31 @@ function pruneOrphanedEntries(path = manifestPath()) {
|
|
|
796
830
|
return pruned;
|
|
797
831
|
}
|
|
798
832
|
|
|
799
|
-
// dist/src/
|
|
800
|
-
import { existsSync as
|
|
801
|
-
import { homedir as
|
|
802
|
-
import { join as
|
|
833
|
+
// dist/src/skillify/agent-roots.js
|
|
834
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
835
|
+
import { homedir as homedir7 } from "node:os";
|
|
836
|
+
import { join as join9 } from "node:path";
|
|
803
837
|
function resolveDetected(home) {
|
|
804
838
|
const out = [];
|
|
805
|
-
const codexInstalled =
|
|
806
|
-
const piInstalled =
|
|
807
|
-
const hermesInstalled =
|
|
839
|
+
const codexInstalled = existsSync6(join9(home, ".codex"));
|
|
840
|
+
const piInstalled = existsSync6(join9(home, ".pi", "agent"));
|
|
841
|
+
const hermesInstalled = existsSync6(join9(home, ".hermes"));
|
|
808
842
|
if (codexInstalled || piInstalled) {
|
|
809
|
-
out.push(
|
|
843
|
+
out.push(join9(home, ".agents", "skills"));
|
|
810
844
|
}
|
|
811
845
|
if (hermesInstalled) {
|
|
812
|
-
out.push(
|
|
846
|
+
out.push(join9(home, ".hermes", "skills"));
|
|
813
847
|
}
|
|
814
848
|
if (piInstalled) {
|
|
815
|
-
out.push(
|
|
849
|
+
out.push(join9(home, ".pi", "agent", "skills"));
|
|
816
850
|
}
|
|
817
851
|
return out;
|
|
818
852
|
}
|
|
819
|
-
function detectAgentSkillsRoots(canonicalRoot, home =
|
|
853
|
+
function detectAgentSkillsRoots(canonicalRoot, home = homedir7()) {
|
|
820
854
|
return resolveDetected(home).filter((p) => p !== canonicalRoot);
|
|
821
855
|
}
|
|
822
856
|
|
|
823
|
-
// dist/src/
|
|
857
|
+
// dist/src/skillify/pull.js
|
|
824
858
|
function assertValidAuthor(author) {
|
|
825
859
|
if (!author)
|
|
826
860
|
throw new Error("author is empty");
|
|
@@ -852,15 +886,15 @@ function isMissingTableError(message) {
|
|
|
852
886
|
}
|
|
853
887
|
function resolvePullDestination(install, cwd) {
|
|
854
888
|
if (install === "global")
|
|
855
|
-
return
|
|
889
|
+
return join10(homedir8(), ".claude", "skills");
|
|
856
890
|
if (!cwd)
|
|
857
891
|
throw new Error("install=project requires a cwd");
|
|
858
|
-
return
|
|
892
|
+
return join10(cwd, ".claude", "skills");
|
|
859
893
|
}
|
|
860
894
|
function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
|
|
861
895
|
const out = [];
|
|
862
896
|
for (const root of agentRoots) {
|
|
863
|
-
const link =
|
|
897
|
+
const link = join10(root, dirName);
|
|
864
898
|
let existing;
|
|
865
899
|
try {
|
|
866
900
|
existing = lstatSync2(link);
|
|
@@ -903,8 +937,8 @@ function backfillSymlinks(installRoot) {
|
|
|
903
937
|
return;
|
|
904
938
|
const detected = detectAgentSkillsRoots(installRoot);
|
|
905
939
|
for (const entry of entries) {
|
|
906
|
-
const canonical =
|
|
907
|
-
if (!
|
|
940
|
+
const canonical = join10(entry.installRoot, entry.dirName);
|
|
941
|
+
if (!existsSync7(canonical))
|
|
908
942
|
continue;
|
|
909
943
|
const fresh = fanOutSymlinks(canonical, entry.dirName, detected);
|
|
910
944
|
if (sameSorted(fresh, entry.symlinks))
|
|
@@ -989,7 +1023,7 @@ function renderFrontmatter(fm) {
|
|
|
989
1023
|
return lines.join("\n");
|
|
990
1024
|
}
|
|
991
1025
|
function readLocalVersion(path) {
|
|
992
|
-
if (!
|
|
1026
|
+
if (!existsSync7(path))
|
|
993
1027
|
return null;
|
|
994
1028
|
try {
|
|
995
1029
|
const text = readFileSync7(path, "utf-8");
|
|
@@ -1078,8 +1112,8 @@ async function runPull(opts) {
|
|
|
1078
1112
|
summary.skipped++;
|
|
1079
1113
|
continue;
|
|
1080
1114
|
}
|
|
1081
|
-
const skillDir =
|
|
1082
|
-
const skillFile =
|
|
1115
|
+
const skillDir = join10(root, dirName);
|
|
1116
|
+
const skillFile = join10(skillDir, "SKILL.md");
|
|
1083
1117
|
const remoteVersion = Number(row.version ?? 1);
|
|
1084
1118
|
const localVersion = readLocalVersion(skillFile);
|
|
1085
1119
|
const action = decideAction({
|
|
@@ -1091,9 +1125,9 @@ async function runPull(opts) {
|
|
|
1091
1125
|
let manifestError;
|
|
1092
1126
|
if (action === "wrote") {
|
|
1093
1127
|
mkdirSync5(skillDir, { recursive: true });
|
|
1094
|
-
if (
|
|
1128
|
+
if (existsSync7(skillFile)) {
|
|
1095
1129
|
try {
|
|
1096
|
-
|
|
1130
|
+
renameSync3(skillFile, `${skillFile}.bak`);
|
|
1097
1131
|
} catch {
|
|
1098
1132
|
}
|
|
1099
1133
|
}
|
|
@@ -1138,8 +1172,8 @@ async function runPull(opts) {
|
|
|
1138
1172
|
return summary;
|
|
1139
1173
|
}
|
|
1140
1174
|
|
|
1141
|
-
// dist/src/
|
|
1142
|
-
var log3 = (msg) => log("
|
|
1175
|
+
// dist/src/skillify/auto-pull.js
|
|
1176
|
+
var log3 = (msg) => log("skillify-autopull", msg);
|
|
1143
1177
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
1144
1178
|
function withTimeout(p, ms) {
|
|
1145
1179
|
let timer = null;
|
|
@@ -1223,23 +1257,23 @@ Organization management \u2014 each argument is SEPARATE (do NOT quote subcomman
|
|
|
1223
1257
|
- hivemind members \u2014 list members
|
|
1224
1258
|
- hivemind remove <user-id> \u2014 remove member
|
|
1225
1259
|
|
|
1226
|
-
SKILLS (
|
|
1227
|
-
- hivemind
|
|
1228
|
-
- hivemind
|
|
1229
|
-
- hivemind
|
|
1230
|
-
- hivemind
|
|
1231
|
-
- hivemind
|
|
1232
|
-
- hivemind
|
|
1233
|
-
- hivemind
|
|
1234
|
-
- hivemind
|
|
1235
|
-
- hivemind
|
|
1236
|
-
- hivemind
|
|
1237
|
-
- hivemind
|
|
1238
|
-
- hivemind
|
|
1239
|
-
- hivemind
|
|
1240
|
-
- hivemind
|
|
1241
|
-
- hivemind
|
|
1242
|
-
- hivemind
|
|
1260
|
+
SKILLS (skillify) \u2014 mine + share reusable skills across the org:
|
|
1261
|
+
- hivemind skillify \u2014 show scope/team/install + per-project state
|
|
1262
|
+
- hivemind skillify pull \u2014 sync project skills from the org table
|
|
1263
|
+
- hivemind skillify pull --user <email> \u2014 only that author's skills
|
|
1264
|
+
- hivemind skillify pull --users a,b,c \u2014 multiple authors (CSV)
|
|
1265
|
+
- hivemind skillify pull --all-users \u2014 explicit "no author filter"
|
|
1266
|
+
- hivemind skillify pull --to project|global \u2014 install location
|
|
1267
|
+
- hivemind skillify pull --dry-run \u2014 preview only
|
|
1268
|
+
- hivemind skillify pull --force \u2014 overwrite local (creates .bak)
|
|
1269
|
+
- hivemind skillify pull <skill-name> \u2014 pull only that skill (combines with --user)
|
|
1270
|
+
- hivemind skillify unpull \u2014 remove every skill previously installed by pull
|
|
1271
|
+
- hivemind skillify unpull --user <email> \u2014 remove only that author's pulls
|
|
1272
|
+
- hivemind skillify unpull --not-mine \u2014 remove all pulls except your own
|
|
1273
|
+
- hivemind skillify unpull --dry-run \u2014 preview without touching disk
|
|
1274
|
+
- hivemind skillify scope <me|team|org> \u2014 sharing scope for new skills
|
|
1275
|
+
- hivemind skillify install <project|global> \u2014 default install location
|
|
1276
|
+
- hivemind skillify team add|remove|list <name> \u2014 manage team list`;
|
|
1243
1277
|
async function main() {
|
|
1244
1278
|
if (process.env.HIVEMIND_WIKI_WORKER === "1")
|
|
1245
1279
|
return;
|
|
@@ -1251,7 +1285,7 @@ async function main() {
|
|
|
1251
1285
|
log4(`credentials loaded: org=${creds.orgName ?? creds.orgId}`);
|
|
1252
1286
|
}
|
|
1253
1287
|
if (creds?.token) {
|
|
1254
|
-
const setupScript =
|
|
1288
|
+
const setupScript = join11(__bundleDir, "session-start-setup.js");
|
|
1255
1289
|
const child = spawn("node", [setupScript], {
|
|
1256
1290
|
detached: true,
|
|
1257
1291
|
stdio: ["pipe", "ignore", "ignore"],
|
|
@@ -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) {
|