@deeplake/hivemind 0.7.33 → 0.7.35
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 +126 -116
- package/codex/bundle/session-start.js +40 -31
- package/codex/bundle/skillify-worker.js +26 -18
- package/codex/bundle/stop.js +61 -38
- package/cursor/bundle/capture.js +46 -23
- package/cursor/bundle/session-end.js +43 -20
- package/cursor/bundle/session-start.js +39 -30
- package/cursor/bundle/skillify-worker.js +26 -18
- package/hermes/bundle/capture.js +46 -23
- package/hermes/bundle/session-end.js +43 -20
- package/hermes/bundle/session-start.js +39 -30
- package/hermes/bundle/skillify-worker.js +26 -18
- package/openclaw/dist/index.js +236 -7
- package/openclaw/dist/skillify-worker.js +26 -18
- package/openclaw/openclaw.plugin.json +1 -1
- package/openclaw/package.json +1 -1
- package/package.json +1 -1
- package/pi/extension-source/hivemind.ts +188 -62
package/bundle/cli.js
CHANGED
|
@@ -519,19 +519,19 @@ function isPluginsAllowMissingHivemind(allow) {
|
|
|
519
519
|
return Array.isArray(allow) && allow.length > 0 && !allow.includes("hivemind");
|
|
520
520
|
}
|
|
521
521
|
function ensureHivemindAllowlisted() {
|
|
522
|
-
const
|
|
523
|
-
if (!existsSync4(
|
|
524
|
-
return { status: "error", configPath, error: "openclaw config file not found" };
|
|
522
|
+
const configPath2 = getOpenclawConfigPath();
|
|
523
|
+
if (!existsSync4(configPath2)) {
|
|
524
|
+
return { status: "error", configPath: configPath2, error: "openclaw config file not found" };
|
|
525
525
|
}
|
|
526
526
|
let parsed;
|
|
527
527
|
try {
|
|
528
|
-
const raw = readFileSync5(
|
|
528
|
+
const raw = readFileSync5(configPath2, "utf-8");
|
|
529
529
|
parsed = JSON.parse(raw);
|
|
530
530
|
} catch (e) {
|
|
531
|
-
return { status: "error", configPath, error: `could not read/parse config: ${e instanceof Error ? e.message : String(e)}` };
|
|
531
|
+
return { status: "error", configPath: configPath2, error: `could not read/parse config: ${e instanceof Error ? e.message : String(e)}` };
|
|
532
532
|
}
|
|
533
533
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
534
|
-
return { status: "error", configPath, error: "openclaw config is not a JSON object" };
|
|
534
|
+
return { status: "error", configPath: configPath2, error: "openclaw config is not a JSON object" };
|
|
535
535
|
}
|
|
536
536
|
const plugins = parsed.plugins ?? {};
|
|
537
537
|
const pluginsAllowRaw = plugins.allow;
|
|
@@ -540,7 +540,7 @@ function ensureHivemindAllowlisted() {
|
|
|
540
540
|
const pluginsAllowNeedsPatch = isPluginsAllowMissingHivemind(pluginsAllowRaw);
|
|
541
541
|
const toolsAlsoAllowNeedsPatch = Array.isArray(alsoAllowRaw) && alsoAllowRaw.length > 0 && !isAllowlistCoveringHivemind(alsoAllowRaw);
|
|
542
542
|
if (!pluginsAllowNeedsPatch && !toolsAlsoAllowNeedsPatch) {
|
|
543
|
-
return { status: "already-set", configPath };
|
|
543
|
+
return { status: "already-set", configPath: configPath2 };
|
|
544
544
|
}
|
|
545
545
|
const updated = { ...parsed };
|
|
546
546
|
if (pluginsAllowNeedsPatch) {
|
|
@@ -557,18 +557,18 @@ function ensureHivemindAllowlisted() {
|
|
|
557
557
|
alsoAllow: [...alsoAllowRaw, "hivemind"]
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
|
-
const backupPath = `${
|
|
561
|
-
const tmpPath = `${
|
|
560
|
+
const backupPath = `${configPath2}.bak-hivemind-${Date.now()}`;
|
|
561
|
+
const tmpPath = `${configPath2}.tmp-hivemind-${process.pid}`;
|
|
562
562
|
try {
|
|
563
|
-
writeFileSync3(backupPath, readFileSync5(
|
|
563
|
+
writeFileSync3(backupPath, readFileSync5(configPath2, "utf-8"));
|
|
564
564
|
writeFileSync3(tmpPath, JSON.stringify(updated, null, 2) + "\n");
|
|
565
|
-
renameSync(tmpPath,
|
|
565
|
+
renameSync(tmpPath, configPath2);
|
|
566
566
|
} catch (e) {
|
|
567
|
-
return { status: "error", configPath, error: `could not write config: ${e instanceof Error ? e.message : String(e)}` };
|
|
567
|
+
return { status: "error", configPath: configPath2, error: `could not write config: ${e instanceof Error ? e.message : String(e)}` };
|
|
568
568
|
}
|
|
569
569
|
return {
|
|
570
570
|
status: "added",
|
|
571
|
-
configPath,
|
|
571
|
+
configPath: configPath2,
|
|
572
572
|
backupPath,
|
|
573
573
|
delta: {
|
|
574
574
|
pluginsAllow: pluginsAllowNeedsPatch,
|
|
@@ -5219,27 +5219,36 @@ if (process.argv[1] && process.argv[1].endsWith("auth-login.js")) {
|
|
|
5219
5219
|
|
|
5220
5220
|
// dist/src/commands/skillify.js
|
|
5221
5221
|
import { readdirSync as readdirSync5, existsSync as existsSync26, readFileSync as readFileSync21, mkdirSync as mkdirSync12, renameSync as renameSync7 } from "node:fs";
|
|
5222
|
-
import { homedir as
|
|
5223
|
-
import { dirname as
|
|
5222
|
+
import { homedir as homedir18 } from "node:os";
|
|
5223
|
+
import { dirname as dirname8, join as join31 } from "node:path";
|
|
5224
5224
|
|
|
5225
5225
|
// dist/src/skillify/scope-config.js
|
|
5226
5226
|
import { existsSync as existsSync16, mkdirSync as mkdirSync6, readFileSync as readFileSync14, writeFileSync as writeFileSync10 } from "node:fs";
|
|
5227
|
-
import {
|
|
5228
|
-
import { join as join20 } from "node:path";
|
|
5227
|
+
import { join as join21 } from "node:path";
|
|
5229
5228
|
|
|
5230
5229
|
// dist/src/skillify/legacy-migration.js
|
|
5231
5230
|
import { existsSync as existsSync15, renameSync as renameSync4 } from "node:fs";
|
|
5231
|
+
import { dirname as dirname3, join as join20 } from "node:path";
|
|
5232
|
+
|
|
5233
|
+
// dist/src/skillify/state-dir.js
|
|
5232
5234
|
import { homedir as homedir9 } from "node:os";
|
|
5233
5235
|
import { join as join19 } from "node:path";
|
|
5236
|
+
function getStateDir() {
|
|
5237
|
+
const override = process.env.HIVEMIND_STATE_DIR?.trim();
|
|
5238
|
+
return override && override.length > 0 ? override : join19(homedir9(), ".deeplake", "state", "skillify");
|
|
5239
|
+
}
|
|
5240
|
+
|
|
5241
|
+
// dist/src/skillify/legacy-migration.js
|
|
5234
5242
|
var dlog = (msg) => log2("skillify-migrate", msg);
|
|
5235
5243
|
var attempted = false;
|
|
5236
5244
|
function migrateLegacyStateDir() {
|
|
5245
|
+
if (process.env.HIVEMIND_STATE_DIR?.trim())
|
|
5246
|
+
return;
|
|
5237
5247
|
if (attempted)
|
|
5238
5248
|
return;
|
|
5239
5249
|
attempted = true;
|
|
5240
|
-
const
|
|
5241
|
-
const legacy =
|
|
5242
|
-
const current = join19(root, "skillify");
|
|
5250
|
+
const current = getStateDir();
|
|
5251
|
+
const legacy = join20(dirname3(current), "skilify");
|
|
5243
5252
|
if (!existsSync15(legacy))
|
|
5244
5253
|
return;
|
|
5245
5254
|
if (existsSync15(current))
|
|
@@ -5249,8 +5258,8 @@ function migrateLegacyStateDir() {
|
|
|
5249
5258
|
dlog(`migrated ${legacy} -> ${current}`);
|
|
5250
5259
|
} catch (err) {
|
|
5251
5260
|
const code = err.code;
|
|
5252
|
-
if (code === "EXDEV" || code === "EPERM") {
|
|
5253
|
-
dlog(`migration
|
|
5261
|
+
if (code === "EXDEV" || code === "EPERM" || code === "ENOENT" || code === "EEXIST" || code === "ENOTEMPTY") {
|
|
5262
|
+
dlog(`migration skipped (${code}); legacy dir left as-is or another process handled it`);
|
|
5254
5263
|
return;
|
|
5255
5264
|
}
|
|
5256
5265
|
throw err;
|
|
@@ -5258,11 +5267,13 @@ function migrateLegacyStateDir() {
|
|
|
5258
5267
|
}
|
|
5259
5268
|
|
|
5260
5269
|
// dist/src/skillify/scope-config.js
|
|
5261
|
-
|
|
5262
|
-
|
|
5270
|
+
function configPath() {
|
|
5271
|
+
return join21(getStateDir(), "config.json");
|
|
5272
|
+
}
|
|
5263
5273
|
var DEFAULT = { scope: "me", team: [], install: "project" };
|
|
5264
5274
|
function loadScopeConfig() {
|
|
5265
5275
|
migrateLegacyStateDir();
|
|
5276
|
+
const CONFIG_PATH2 = configPath();
|
|
5266
5277
|
if (!existsSync16(CONFIG_PATH2))
|
|
5267
5278
|
return DEFAULT;
|
|
5268
5279
|
try {
|
|
@@ -5277,19 +5288,19 @@ function loadScopeConfig() {
|
|
|
5277
5288
|
}
|
|
5278
5289
|
function saveScopeConfig(cfg) {
|
|
5279
5290
|
migrateLegacyStateDir();
|
|
5280
|
-
mkdirSync6(
|
|
5281
|
-
writeFileSync10(
|
|
5291
|
+
mkdirSync6(getStateDir(), { recursive: true });
|
|
5292
|
+
writeFileSync10(configPath(), JSON.stringify(cfg, null, 2));
|
|
5282
5293
|
}
|
|
5283
5294
|
|
|
5284
5295
|
// dist/src/skillify/pull.js
|
|
5285
5296
|
import { existsSync as existsSync20, readFileSync as readFileSync17, writeFileSync as writeFileSync13, mkdirSync as mkdirSync9, renameSync as renameSync6, lstatSync as lstatSync4, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, unlinkSync as unlinkSync9 } from "node:fs";
|
|
5286
|
-
import { homedir as
|
|
5287
|
-
import { dirname as
|
|
5297
|
+
import { homedir as homedir12 } from "node:os";
|
|
5298
|
+
import { dirname as dirname5, join as join25 } from "node:path";
|
|
5288
5299
|
|
|
5289
5300
|
// dist/src/skillify/skill-writer.js
|
|
5290
5301
|
import { existsSync as existsSync17, mkdirSync as mkdirSync7, readFileSync as readFileSync15, readdirSync as readdirSync2, statSync as statSync3, writeFileSync as writeFileSync11 } from "node:fs";
|
|
5291
|
-
import { homedir as
|
|
5292
|
-
import { join as
|
|
5302
|
+
import { homedir as homedir10 } from "node:os";
|
|
5303
|
+
import { join as join22 } from "node:path";
|
|
5293
5304
|
function assertValidSkillName(name) {
|
|
5294
5305
|
if (typeof name !== "string" || name.length === 0) {
|
|
5295
5306
|
throw new Error(`invalid skill name: empty or non-string`);
|
|
@@ -5305,10 +5316,10 @@ function assertValidSkillName(name) {
|
|
|
5305
5316
|
}
|
|
5306
5317
|
}
|
|
5307
5318
|
function skillDir(skillsRoot, name) {
|
|
5308
|
-
return
|
|
5319
|
+
return join22(skillsRoot, name);
|
|
5309
5320
|
}
|
|
5310
5321
|
function skillPath(skillsRoot, name) {
|
|
5311
|
-
return
|
|
5322
|
+
return join22(skillDir(skillsRoot, name), "SKILL.md");
|
|
5312
5323
|
}
|
|
5313
5324
|
function renderFrontmatter(fm) {
|
|
5314
5325
|
const lines = ["---"];
|
|
@@ -5425,7 +5436,7 @@ function listSkills(skillsRoot) {
|
|
|
5425
5436
|
return [];
|
|
5426
5437
|
const out = [];
|
|
5427
5438
|
for (const name of readdirSync2(skillsRoot)) {
|
|
5428
|
-
const skillFile =
|
|
5439
|
+
const skillFile = join22(skillsRoot, name, "SKILL.md");
|
|
5429
5440
|
if (existsSync17(skillFile) && statSync3(skillFile).isFile()) {
|
|
5430
5441
|
out.push({ name, body: readFileSync15(skillFile, "utf-8") });
|
|
5431
5442
|
}
|
|
@@ -5434,20 +5445,19 @@ function listSkills(skillsRoot) {
|
|
|
5434
5445
|
}
|
|
5435
5446
|
function resolveSkillsRoot(install, cwd) {
|
|
5436
5447
|
if (install === "global") {
|
|
5437
|
-
return
|
|
5448
|
+
return join22(homedir10(), ".claude", "skills");
|
|
5438
5449
|
}
|
|
5439
|
-
return
|
|
5450
|
+
return join22(cwd, ".claude", "skills");
|
|
5440
5451
|
}
|
|
5441
5452
|
|
|
5442
5453
|
// dist/src/skillify/manifest.js
|
|
5443
5454
|
import { existsSync as existsSync18, lstatSync as lstatSync3, mkdirSync as mkdirSync8, readFileSync as readFileSync16, renameSync as renameSync5, unlinkSync as unlinkSync8, writeFileSync as writeFileSync12 } from "node:fs";
|
|
5444
|
-
import {
|
|
5445
|
-
import { dirname as dirname3, join as join22 } from "node:path";
|
|
5455
|
+
import { dirname as dirname4, join as join23 } from "node:path";
|
|
5446
5456
|
function emptyManifest() {
|
|
5447
5457
|
return { version: 1, entries: [] };
|
|
5448
5458
|
}
|
|
5449
5459
|
function manifestPath() {
|
|
5450
|
-
return
|
|
5460
|
+
return join23(getStateDir(), "pulled.json");
|
|
5451
5461
|
}
|
|
5452
5462
|
function loadManifest(path = manifestPath()) {
|
|
5453
5463
|
migrateLegacyStateDir();
|
|
@@ -5502,7 +5512,7 @@ function loadManifest(path = manifestPath()) {
|
|
|
5502
5512
|
}
|
|
5503
5513
|
function saveManifest(m, path = manifestPath()) {
|
|
5504
5514
|
migrateLegacyStateDir();
|
|
5505
|
-
mkdirSync8(
|
|
5515
|
+
mkdirSync8(dirname4(path), { recursive: true });
|
|
5506
5516
|
const tmp = `${path}.tmp`;
|
|
5507
5517
|
writeFileSync12(tmp, JSON.stringify(m, null, 2) + "\n", { mode: 384 });
|
|
5508
5518
|
renameSync5(tmp, path);
|
|
@@ -5547,7 +5557,7 @@ function pruneOrphanedEntries(path = manifestPath()) {
|
|
|
5547
5557
|
const live = [];
|
|
5548
5558
|
let pruned = 0;
|
|
5549
5559
|
for (const e of m.entries) {
|
|
5550
|
-
if (existsSync18(
|
|
5560
|
+
if (existsSync18(join23(e.installRoot, e.dirName))) {
|
|
5551
5561
|
live.push(e);
|
|
5552
5562
|
continue;
|
|
5553
5563
|
}
|
|
@@ -5561,25 +5571,25 @@ function pruneOrphanedEntries(path = manifestPath()) {
|
|
|
5561
5571
|
|
|
5562
5572
|
// dist/src/skillify/agent-roots.js
|
|
5563
5573
|
import { existsSync as existsSync19 } from "node:fs";
|
|
5564
|
-
import { homedir as
|
|
5565
|
-
import { join as
|
|
5574
|
+
import { homedir as homedir11 } from "node:os";
|
|
5575
|
+
import { join as join24 } from "node:path";
|
|
5566
5576
|
function resolveDetected(home) {
|
|
5567
5577
|
const out = [];
|
|
5568
|
-
const codexInstalled = existsSync19(
|
|
5569
|
-
const piInstalled = existsSync19(
|
|
5570
|
-
const hermesInstalled = existsSync19(
|
|
5578
|
+
const codexInstalled = existsSync19(join24(home, ".codex"));
|
|
5579
|
+
const piInstalled = existsSync19(join24(home, ".pi", "agent"));
|
|
5580
|
+
const hermesInstalled = existsSync19(join24(home, ".hermes"));
|
|
5571
5581
|
if (codexInstalled || piInstalled) {
|
|
5572
|
-
out.push(
|
|
5582
|
+
out.push(join24(home, ".agents", "skills"));
|
|
5573
5583
|
}
|
|
5574
5584
|
if (hermesInstalled) {
|
|
5575
|
-
out.push(
|
|
5585
|
+
out.push(join24(home, ".hermes", "skills"));
|
|
5576
5586
|
}
|
|
5577
5587
|
if (piInstalled) {
|
|
5578
|
-
out.push(
|
|
5588
|
+
out.push(join24(home, ".pi", "agent", "skills"));
|
|
5579
5589
|
}
|
|
5580
5590
|
return out;
|
|
5581
5591
|
}
|
|
5582
|
-
function detectAgentSkillsRoots(canonicalRoot, home =
|
|
5592
|
+
function detectAgentSkillsRoots(canonicalRoot, home = homedir11()) {
|
|
5583
5593
|
return resolveDetected(home).filter((p) => p !== canonicalRoot);
|
|
5584
5594
|
}
|
|
5585
5595
|
|
|
@@ -5623,15 +5633,15 @@ function isMissingTableError(message) {
|
|
|
5623
5633
|
}
|
|
5624
5634
|
function resolvePullDestination(install, cwd) {
|
|
5625
5635
|
if (install === "global")
|
|
5626
|
-
return
|
|
5636
|
+
return join25(homedir12(), ".claude", "skills");
|
|
5627
5637
|
if (!cwd)
|
|
5628
5638
|
throw new Error("install=project requires a cwd");
|
|
5629
|
-
return
|
|
5639
|
+
return join25(cwd, ".claude", "skills");
|
|
5630
5640
|
}
|
|
5631
5641
|
function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
|
|
5632
5642
|
const out = [];
|
|
5633
5643
|
for (const root of agentRoots) {
|
|
5634
|
-
const link =
|
|
5644
|
+
const link = join25(root, dirName);
|
|
5635
5645
|
let existing;
|
|
5636
5646
|
try {
|
|
5637
5647
|
existing = lstatSync4(link);
|
|
@@ -5659,7 +5669,7 @@ function fanOutSymlinks(canonicalDir, dirName, agentRoots) {
|
|
|
5659
5669
|
}
|
|
5660
5670
|
}
|
|
5661
5671
|
try {
|
|
5662
|
-
mkdirSync9(
|
|
5672
|
+
mkdirSync9(dirname5(link), { recursive: true });
|
|
5663
5673
|
symlinkSync2(canonicalDir, link, "dir");
|
|
5664
5674
|
out.push(link);
|
|
5665
5675
|
} catch {
|
|
@@ -5674,7 +5684,7 @@ function backfillSymlinks(installRoot) {
|
|
|
5674
5684
|
return;
|
|
5675
5685
|
const detected = detectAgentSkillsRoots(installRoot);
|
|
5676
5686
|
for (const entry of entries) {
|
|
5677
|
-
const canonical =
|
|
5687
|
+
const canonical = join25(entry.installRoot, entry.dirName);
|
|
5678
5688
|
if (!existsSync20(canonical))
|
|
5679
5689
|
continue;
|
|
5680
5690
|
const fresh = fanOutSymlinks(canonical, entry.dirName, detected);
|
|
@@ -5883,8 +5893,8 @@ async function runPull(opts) {
|
|
|
5883
5893
|
summary.skipped++;
|
|
5884
5894
|
continue;
|
|
5885
5895
|
}
|
|
5886
|
-
const skillDir2 =
|
|
5887
|
-
const skillFile =
|
|
5896
|
+
const skillDir2 = join25(root, dirName);
|
|
5897
|
+
const skillFile = join25(skillDir2, "SKILL.md");
|
|
5888
5898
|
const remoteVersion = Number(row.version ?? 1);
|
|
5889
5899
|
const localVersion = readLocalVersion(skillFile);
|
|
5890
5900
|
const action = decideAction({
|
|
@@ -5945,14 +5955,14 @@ async function runPull(opts) {
|
|
|
5945
5955
|
|
|
5946
5956
|
// dist/src/skillify/unpull.js
|
|
5947
5957
|
import { existsSync as existsSync21, readdirSync as readdirSync3, rmSync as rmSync5, statSync as statSync4 } from "node:fs";
|
|
5948
|
-
import { homedir as
|
|
5949
|
-
import { join as
|
|
5958
|
+
import { homedir as homedir13 } from "node:os";
|
|
5959
|
+
import { join as join26 } from "node:path";
|
|
5950
5960
|
function resolveUnpullRoot(install, cwd) {
|
|
5951
5961
|
if (install === "global")
|
|
5952
|
-
return
|
|
5962
|
+
return join26(homedir13(), ".claude", "skills");
|
|
5953
5963
|
if (!cwd)
|
|
5954
5964
|
throw new Error("cwd required when install === 'project'");
|
|
5955
|
-
return
|
|
5965
|
+
return join26(cwd, ".claude", "skills");
|
|
5956
5966
|
}
|
|
5957
5967
|
function runUnpull(opts) {
|
|
5958
5968
|
const root = resolveUnpullRoot(opts.install, opts.cwd);
|
|
@@ -5975,7 +5985,7 @@ function runUnpull(opts) {
|
|
|
5975
5985
|
const entries = entriesForRoot(manifest, opts.install, root);
|
|
5976
5986
|
for (const entry of entries) {
|
|
5977
5987
|
summary.scanned++;
|
|
5978
|
-
const path =
|
|
5988
|
+
const path = join26(root, entry.dirName);
|
|
5979
5989
|
if (!existsSync21(path)) {
|
|
5980
5990
|
if (!opts.dryRun) {
|
|
5981
5991
|
unlinkSymlinks(entry.symlinks);
|
|
@@ -6034,7 +6044,7 @@ function runUnpull(opts) {
|
|
|
6034
6044
|
for (const dirName of readdirSync3(root)) {
|
|
6035
6045
|
if (manifestDirNames.has(dirName))
|
|
6036
6046
|
continue;
|
|
6037
|
-
const path =
|
|
6047
|
+
const path = join26(root, dirName);
|
|
6038
6048
|
let st;
|
|
6039
6049
|
try {
|
|
6040
6050
|
st = statSync4(path);
|
|
@@ -6114,20 +6124,20 @@ function decideTargetForManifestEntry(entry, opts, userFilter, haveUserFilter) {
|
|
|
6114
6124
|
// dist/src/commands/mine-local.js
|
|
6115
6125
|
import { spawn } from "node:child_process";
|
|
6116
6126
|
import { existsSync as existsSync25, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
|
|
6117
|
-
import { homedir as
|
|
6118
|
-
import { basename, dirname as
|
|
6127
|
+
import { homedir as homedir17 } from "node:os";
|
|
6128
|
+
import { basename, dirname as dirname7, join as join30 } from "node:path";
|
|
6119
6129
|
|
|
6120
6130
|
// dist/src/skillify/local-source.js
|
|
6121
6131
|
import { readdirSync as readdirSync4, readFileSync as readFileSync18, existsSync as existsSync22, statSync as statSync5 } from "node:fs";
|
|
6122
|
-
import { homedir as
|
|
6123
|
-
import { join as
|
|
6124
|
-
var HOME2 =
|
|
6132
|
+
import { homedir as homedir14 } from "node:os";
|
|
6133
|
+
import { join as join27 } from "node:path";
|
|
6134
|
+
var HOME2 = homedir14();
|
|
6125
6135
|
function encodeCwdClaudeCode(cwd) {
|
|
6126
6136
|
return cwd.replace(/[/_]/g, "-");
|
|
6127
6137
|
}
|
|
6128
6138
|
function detectInstalledAgents() {
|
|
6129
6139
|
const installs = [];
|
|
6130
|
-
const claudeRoot =
|
|
6140
|
+
const claudeRoot = join27(HOME2, ".claude", "projects");
|
|
6131
6141
|
if (existsSync22(claudeRoot)) {
|
|
6132
6142
|
installs.push({
|
|
6133
6143
|
agent: "claude_code",
|
|
@@ -6135,7 +6145,7 @@ function detectInstalledAgents() {
|
|
|
6135
6145
|
encodeCwd: encodeCwdClaudeCode
|
|
6136
6146
|
});
|
|
6137
6147
|
}
|
|
6138
|
-
const codexRoot =
|
|
6148
|
+
const codexRoot = join27(HOME2, ".codex", "sessions");
|
|
6139
6149
|
if (existsSync22(codexRoot)) {
|
|
6140
6150
|
installs.push({
|
|
6141
6151
|
agent: "codex",
|
|
@@ -6163,7 +6173,7 @@ function listLocalSessions(installs, cwd) {
|
|
|
6163
6173
|
continue;
|
|
6164
6174
|
}
|
|
6165
6175
|
for (const sub of subdirs) {
|
|
6166
|
-
const subdirPath =
|
|
6176
|
+
const subdirPath = join27(install.sessionRoot, sub);
|
|
6167
6177
|
try {
|
|
6168
6178
|
if (!statSync5(subdirPath).isDirectory())
|
|
6169
6179
|
continue;
|
|
@@ -6180,7 +6190,7 @@ function listLocalSessions(installs, cwd) {
|
|
|
6180
6190
|
for (const f of files) {
|
|
6181
6191
|
if (!f.endsWith(".jsonl"))
|
|
6182
6192
|
continue;
|
|
6183
|
-
const fullPath =
|
|
6193
|
+
const fullPath = join27(subdirPath, f);
|
|
6184
6194
|
let stats;
|
|
6185
6195
|
try {
|
|
6186
6196
|
stats = statSync5(fullPath);
|
|
@@ -6333,8 +6343,8 @@ function extractPairs(rows) {
|
|
|
6333
6343
|
// dist/src/skillify/gate-runner.js
|
|
6334
6344
|
import { existsSync as existsSync23 } from "node:fs";
|
|
6335
6345
|
import { createRequire } from "node:module";
|
|
6336
|
-
import { homedir as
|
|
6337
|
-
import { join as
|
|
6346
|
+
import { homedir as homedir15 } from "node:os";
|
|
6347
|
+
import { join as join28 } from "node:path";
|
|
6338
6348
|
var requireForCp = createRequire(import.meta.url);
|
|
6339
6349
|
var { execFileSync: runChildProcess } = requireForCp("node:child_process");
|
|
6340
6350
|
var inheritedEnv = process;
|
|
@@ -6346,7 +6356,7 @@ function firstExistingPath(candidates) {
|
|
|
6346
6356
|
return null;
|
|
6347
6357
|
}
|
|
6348
6358
|
function findAgentBin(agent) {
|
|
6349
|
-
const home =
|
|
6359
|
+
const home = homedir15();
|
|
6350
6360
|
switch (agent) {
|
|
6351
6361
|
// /usr/bin/<name> is included in every candidate list — that's the
|
|
6352
6362
|
// common Linux package-manager install path (apt, dnf, pacman). Old
|
|
@@ -6355,45 +6365,45 @@ function findAgentBin(agent) {
|
|
|
6355
6365
|
// #170 caught the gap.
|
|
6356
6366
|
case "claude_code":
|
|
6357
6367
|
return firstExistingPath([
|
|
6358
|
-
|
|
6368
|
+
join28(home, ".claude", "local", "claude"),
|
|
6359
6369
|
"/usr/local/bin/claude",
|
|
6360
6370
|
"/usr/bin/claude",
|
|
6361
|
-
|
|
6362
|
-
|
|
6371
|
+
join28(home, ".npm-global", "bin", "claude"),
|
|
6372
|
+
join28(home, ".local", "bin", "claude"),
|
|
6363
6373
|
"/opt/homebrew/bin/claude"
|
|
6364
|
-
]) ??
|
|
6374
|
+
]) ?? join28(home, ".claude", "local", "claude");
|
|
6365
6375
|
case "codex":
|
|
6366
6376
|
return firstExistingPath([
|
|
6367
6377
|
"/usr/local/bin/codex",
|
|
6368
6378
|
"/usr/bin/codex",
|
|
6369
|
-
|
|
6370
|
-
|
|
6379
|
+
join28(home, ".npm-global", "bin", "codex"),
|
|
6380
|
+
join28(home, ".local", "bin", "codex"),
|
|
6371
6381
|
"/opt/homebrew/bin/codex"
|
|
6372
6382
|
]) ?? "/usr/local/bin/codex";
|
|
6373
6383
|
case "cursor":
|
|
6374
6384
|
return firstExistingPath([
|
|
6375
6385
|
"/usr/local/bin/cursor-agent",
|
|
6376
6386
|
"/usr/bin/cursor-agent",
|
|
6377
|
-
|
|
6378
|
-
|
|
6387
|
+
join28(home, ".npm-global", "bin", "cursor-agent"),
|
|
6388
|
+
join28(home, ".local", "bin", "cursor-agent"),
|
|
6379
6389
|
"/opt/homebrew/bin/cursor-agent"
|
|
6380
6390
|
]) ?? "/usr/local/bin/cursor-agent";
|
|
6381
6391
|
case "hermes":
|
|
6382
6392
|
return firstExistingPath([
|
|
6383
|
-
|
|
6393
|
+
join28(home, ".local", "bin", "hermes"),
|
|
6384
6394
|
"/usr/local/bin/hermes",
|
|
6385
6395
|
"/usr/bin/hermes",
|
|
6386
|
-
|
|
6396
|
+
join28(home, ".npm-global", "bin", "hermes"),
|
|
6387
6397
|
"/opt/homebrew/bin/hermes"
|
|
6388
|
-
]) ??
|
|
6398
|
+
]) ?? join28(home, ".local", "bin", "hermes");
|
|
6389
6399
|
case "pi":
|
|
6390
6400
|
return firstExistingPath([
|
|
6391
|
-
|
|
6401
|
+
join28(home, ".local", "bin", "pi"),
|
|
6392
6402
|
"/usr/local/bin/pi",
|
|
6393
6403
|
"/usr/bin/pi",
|
|
6394
|
-
|
|
6404
|
+
join28(home, ".npm-global", "bin", "pi"),
|
|
6395
6405
|
"/opt/homebrew/bin/pi"
|
|
6396
|
-
]) ??
|
|
6406
|
+
]) ?? join28(home, ".local", "bin", "pi");
|
|
6397
6407
|
}
|
|
6398
6408
|
}
|
|
6399
6409
|
|
|
@@ -6424,10 +6434,10 @@ function extractJsonBlock(s) {
|
|
|
6424
6434
|
|
|
6425
6435
|
// dist/src/skillify/local-manifest.js
|
|
6426
6436
|
import { existsSync as existsSync24, mkdirSync as mkdirSync10, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
|
|
6427
|
-
import { homedir as
|
|
6428
|
-
import { dirname as
|
|
6429
|
-
var LOCAL_MANIFEST_PATH =
|
|
6430
|
-
var LOCAL_MINE_LOCK_PATH =
|
|
6437
|
+
import { homedir as homedir16 } from "node:os";
|
|
6438
|
+
import { dirname as dirname6, join as join29 } from "node:path";
|
|
6439
|
+
var LOCAL_MANIFEST_PATH = join29(homedir16(), ".claude", "hivemind", "local-mined.json");
|
|
6440
|
+
var LOCAL_MINE_LOCK_PATH = join29(homedir16(), ".claude", "hivemind", "local-mined.lock");
|
|
6431
6441
|
function readLocalManifest(path = LOCAL_MANIFEST_PATH) {
|
|
6432
6442
|
if (!existsSync24(path))
|
|
6433
6443
|
return null;
|
|
@@ -6438,7 +6448,7 @@ function readLocalManifest(path = LOCAL_MANIFEST_PATH) {
|
|
|
6438
6448
|
}
|
|
6439
6449
|
}
|
|
6440
6450
|
function writeLocalManifest(m, path = LOCAL_MANIFEST_PATH) {
|
|
6441
|
-
mkdirSync10(
|
|
6451
|
+
mkdirSync10(dirname6(path), { recursive: true });
|
|
6442
6452
|
writeFileSync14(path, JSON.stringify(m, null, 2));
|
|
6443
6453
|
}
|
|
6444
6454
|
|
|
@@ -6809,7 +6819,7 @@ async function runMineLocalImpl(args) {
|
|
|
6809
6819
|
console.log(`Dry-run: would invoke ${gateAgent} gate on ${picked.length} session(s) in parallel (concurrency=${GATE_CONCURRENCY}).`);
|
|
6810
6820
|
return;
|
|
6811
6821
|
}
|
|
6812
|
-
const tmpDir =
|
|
6822
|
+
const tmpDir = join30(homedir17(), ".claude", "hivemind", `mine-local-${Date.now()}`);
|
|
6813
6823
|
mkdirSync11(tmpDir, { recursive: true });
|
|
6814
6824
|
console.log(`Running ${picked.length} gate call(s) in parallel (concurrency=${GATE_CONCURRENCY}, timeout=${GATE_TIMEOUT_MS / 1e3}s each)...`);
|
|
6815
6825
|
const results = await parallelMap(picked, GATE_CONCURRENCY, async (s) => {
|
|
@@ -6821,16 +6831,16 @@ async function runMineLocalImpl(args) {
|
|
|
6821
6831
|
return { session: s, skills: [], reason: "no pairs", error: null };
|
|
6822
6832
|
}
|
|
6823
6833
|
const tail = pairs2.slice(-PER_SESSION_PAIR_CAP);
|
|
6824
|
-
const sessionTmp =
|
|
6834
|
+
const sessionTmp = join30(tmpDir, `s-${shortId}`);
|
|
6825
6835
|
mkdirSync11(sessionTmp, { recursive: true });
|
|
6826
|
-
const verdictPath =
|
|
6836
|
+
const verdictPath = join30(sessionTmp, "verdict.json");
|
|
6827
6837
|
const prompt = buildSessionPrompt(tail, s, verdictPath);
|
|
6828
|
-
writeFileSync15(
|
|
6838
|
+
writeFileSync15(join30(sessionTmp, "prompt.txt"), prompt);
|
|
6829
6839
|
const gate = await runGateViaStdin({ agent: gateAgent, bin: gateBin, prompt, timeoutMs: GATE_TIMEOUT_MS });
|
|
6830
6840
|
try {
|
|
6831
|
-
writeFileSync15(
|
|
6841
|
+
writeFileSync15(join30(sessionTmp, "gate-stdout.txt"), gate.stdout);
|
|
6832
6842
|
if (gate.stderr)
|
|
6833
|
-
writeFileSync15(
|
|
6843
|
+
writeFileSync15(join30(sessionTmp, "gate-stderr.txt"), gate.stderr);
|
|
6834
6844
|
} catch {
|
|
6835
6845
|
}
|
|
6836
6846
|
if (gate.errored) {
|
|
@@ -6889,7 +6899,7 @@ async function runMineLocalImpl(args) {
|
|
|
6889
6899
|
sourceSessions: [session.sessionId],
|
|
6890
6900
|
agent: gateAgent
|
|
6891
6901
|
});
|
|
6892
|
-
const canonicalDir =
|
|
6902
|
+
const canonicalDir = dirname7(result.path);
|
|
6893
6903
|
const symlinks = fanOutRoots.length > 0 ? fanOutSymlinks(canonicalDir, basename(canonicalDir), fanOutRoots) : [];
|
|
6894
6904
|
const symlinkSuffix = symlinks.length > 0 ? `, fan-out \u2192 ${symlinks.length} root(s)` : "";
|
|
6895
6905
|
console.log(` wrote ${skill.name} \u2190 session ${session.sessionId.slice(0, 8)} (${session.agent}${symlinkSuffix})`);
|
|
@@ -7053,7 +7063,7 @@ function wrapAt(s, max) {
|
|
|
7053
7063
|
|
|
7054
7064
|
// dist/src/commands/skillify.js
|
|
7055
7065
|
function stateDir() {
|
|
7056
|
-
return
|
|
7066
|
+
return getStateDir();
|
|
7057
7067
|
}
|
|
7058
7068
|
function showStatus() {
|
|
7059
7069
|
const cfg = loadScopeConfig();
|
|
@@ -7073,7 +7083,7 @@ function showStatus() {
|
|
|
7073
7083
|
console.log(`state: ${files.length} project(s) tracked`);
|
|
7074
7084
|
for (const f of files) {
|
|
7075
7085
|
try {
|
|
7076
|
-
const s = JSON.parse(readFileSync21(
|
|
7086
|
+
const s = JSON.parse(readFileSync21(join31(dir, f), "utf-8"));
|
|
7077
7087
|
const last = typeof s.updatedAt === "number" ? new Date(s.updatedAt).toISOString() : s.lastDate ?? "never";
|
|
7078
7088
|
const skills = Array.isArray(s.skillsGenerated) && s.skillsGenerated.length > 0 ? s.skillsGenerated.join(", ") : "none";
|
|
7079
7089
|
console.log(` - ${s.project} (counter=${s.counter}, last=${last}, skills=${skills})`);
|
|
@@ -7100,7 +7110,7 @@ function setInstall(loc) {
|
|
|
7100
7110
|
}
|
|
7101
7111
|
const cfg = loadScopeConfig();
|
|
7102
7112
|
saveScopeConfig({ ...cfg, install: loc });
|
|
7103
|
-
const path = loc === "global" ?
|
|
7113
|
+
const path = loc === "global" ? join31(homedir18(), ".claude", "skills") : "<cwd>/.claude/skills";
|
|
7104
7114
|
console.log(`Install location set to '${loc}'. New skills will be written to ${path}/<name>/SKILL.md.`);
|
|
7105
7115
|
}
|
|
7106
7116
|
function promoteSkill(name, cwd) {
|
|
@@ -7108,17 +7118,17 @@ function promoteSkill(name, cwd) {
|
|
|
7108
7118
|
console.error("Usage: hivemind skillify promote <skill-name>");
|
|
7109
7119
|
process.exit(1);
|
|
7110
7120
|
}
|
|
7111
|
-
const projectPath =
|
|
7112
|
-
const globalPath =
|
|
7113
|
-
if (!existsSync26(
|
|
7121
|
+
const projectPath = join31(cwd, ".claude", "skills", name);
|
|
7122
|
+
const globalPath = join31(homedir18(), ".claude", "skills", name);
|
|
7123
|
+
if (!existsSync26(join31(projectPath, "SKILL.md"))) {
|
|
7114
7124
|
console.error(`Skill '${name}' not found at ${projectPath}/SKILL.md`);
|
|
7115
7125
|
process.exit(1);
|
|
7116
7126
|
}
|
|
7117
|
-
if (existsSync26(
|
|
7127
|
+
if (existsSync26(join31(globalPath, "SKILL.md"))) {
|
|
7118
7128
|
console.error(`Skill '${name}' already exists at ${globalPath}/SKILL.md \u2014 refusing to overwrite. Remove it first or rename the project skill.`);
|
|
7119
7129
|
process.exit(1);
|
|
7120
7130
|
}
|
|
7121
|
-
mkdirSync12(
|
|
7131
|
+
mkdirSync12(dirname8(globalPath), { recursive: true });
|
|
7122
7132
|
renameSync7(projectPath, globalPath);
|
|
7123
7133
|
console.log(`Promoted '${name}' from ${projectPath} \u2192 ${globalPath}.`);
|
|
7124
7134
|
}
|
|
@@ -7225,7 +7235,7 @@ async function pullSkills(args) {
|
|
|
7225
7235
|
console.error(`pull failed: ${e?.message ?? e}`);
|
|
7226
7236
|
process.exit(1);
|
|
7227
7237
|
}
|
|
7228
|
-
const dest = toRaw === "global" ?
|
|
7238
|
+
const dest = toRaw === "global" ? join31(homedir18(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
|
|
7229
7239
|
const filterDesc = users.length === 0 ? "all users" : users.join(", ");
|
|
7230
7240
|
console.log(`Destination: ${dest}`);
|
|
7231
7241
|
console.log(`Filter: ${filterDesc}${skillName ? ` \xB7 skill='${skillName}'` : ""}${dryRun ? " \xB7 dry-run" : ""}${force ? " \xB7 force" : ""}`);
|
|
@@ -7275,7 +7285,7 @@ async function unpullSkills(args) {
|
|
|
7275
7285
|
all,
|
|
7276
7286
|
legacyCleanup
|
|
7277
7287
|
});
|
|
7278
|
-
const dest = toRaw === "global" ?
|
|
7288
|
+
const dest = toRaw === "global" ? join31(homedir18(), ".claude", "skills") : `${process.cwd()}/.claude/skills`;
|
|
7279
7289
|
const filterParts = [];
|
|
7280
7290
|
if (users.length > 0)
|
|
7281
7291
|
filterParts.push(`users=${users.join(",")}`);
|
|
@@ -7372,12 +7382,12 @@ if (process.argv[1] && process.argv[1].endsWith("skillify.js")) {
|
|
|
7372
7382
|
// dist/src/cli/update.js
|
|
7373
7383
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7374
7384
|
import { existsSync as existsSync27, readFileSync as readFileSync23, realpathSync } from "node:fs";
|
|
7375
|
-
import { dirname as
|
|
7385
|
+
import { dirname as dirname10, sep } from "node:path";
|
|
7376
7386
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7377
7387
|
|
|
7378
7388
|
// dist/src/utils/version-check.js
|
|
7379
7389
|
import { readFileSync as readFileSync22 } from "node:fs";
|
|
7380
|
-
import { dirname as
|
|
7390
|
+
import { dirname as dirname9, join as join32 } from "node:path";
|
|
7381
7391
|
function isNewer(latest, current) {
|
|
7382
7392
|
const parse = (v) => v.split(".").map(Number);
|
|
7383
7393
|
const [la, lb, lc] = parse(latest);
|
|
@@ -7396,7 +7406,7 @@ function detectInstallKind(argv1) {
|
|
|
7396
7406
|
return argv1 ?? process.argv[1] ?? fileURLToPath2(import.meta.url);
|
|
7397
7407
|
}
|
|
7398
7408
|
})();
|
|
7399
|
-
let dir =
|
|
7409
|
+
let dir = dirname10(realArgv1);
|
|
7400
7410
|
let installDir = null;
|
|
7401
7411
|
for (let i = 0; i < 10; i++) {
|
|
7402
7412
|
const pkgPath = `${dir}${sep}package.json`;
|
|
@@ -7408,12 +7418,12 @@ function detectInstallKind(argv1) {
|
|
|
7408
7418
|
}
|
|
7409
7419
|
} catch {
|
|
7410
7420
|
}
|
|
7411
|
-
const parent =
|
|
7421
|
+
const parent = dirname10(dir);
|
|
7412
7422
|
if (parent === dir)
|
|
7413
7423
|
break;
|
|
7414
7424
|
dir = parent;
|
|
7415
7425
|
}
|
|
7416
|
-
installDir ??=
|
|
7426
|
+
installDir ??= dirname10(realArgv1);
|
|
7417
7427
|
if (realArgv1.includes(`${sep}_npx${sep}`) || realArgv1.includes(`${sep}.npx${sep}`)) {
|
|
7418
7428
|
return { kind: "npx", installDir };
|
|
7419
7429
|
}
|
|
@@ -7425,7 +7435,7 @@ function detectInstallKind(argv1) {
|
|
|
7425
7435
|
if (existsSync27(`${gitDir}${sep}.git`)) {
|
|
7426
7436
|
return { kind: "local-dev", installDir };
|
|
7427
7437
|
}
|
|
7428
|
-
const parent =
|
|
7438
|
+
const parent = dirname10(gitDir);
|
|
7429
7439
|
if (parent === gitDir)
|
|
7430
7440
|
break;
|
|
7431
7441
|
gitDir = parent;
|