@deeplake/hivemind 0.7.45 → 0.7.47

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.
Files changed (39) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +64 -0
  4. package/bundle/cli.js +22702 -7775
  5. package/codex/bundle/capture.js +228 -0
  6. package/codex/bundle/commands/auth-login.js +228 -0
  7. package/codex/bundle/graph-pull-worker.js +1370 -0
  8. package/codex/bundle/pre-tool-use.js +228 -0
  9. package/codex/bundle/session-start-setup.js +228 -0
  10. package/codex/bundle/session-start.js +255 -4
  11. package/codex/bundle/shell/deeplake-shell.js +1028 -28
  12. package/codex/bundle/skillify-worker.js +94 -3
  13. package/codex/bundle/stop.js +282 -50
  14. package/codex/skills/hivemind-goals/SKILL.md +157 -0
  15. package/cursor/bundle/capture.js +282 -50
  16. package/cursor/bundle/commands/auth-login.js +228 -0
  17. package/cursor/bundle/graph-pull-worker.js +1370 -0
  18. package/cursor/bundle/pre-tool-use.js +228 -0
  19. package/cursor/bundle/session-end.js +65 -44
  20. package/cursor/bundle/session-start.js +662 -6
  21. package/cursor/bundle/shell/deeplake-shell.js +1028 -28
  22. package/cursor/bundle/skillify-worker.js +94 -3
  23. package/hermes/bundle/capture.js +282 -50
  24. package/hermes/bundle/commands/auth-login.js +228 -0
  25. package/hermes/bundle/graph-pull-worker.js +1370 -0
  26. package/hermes/bundle/pre-tool-use.js +228 -0
  27. package/hermes/bundle/session-end.js +65 -44
  28. package/hermes/bundle/session-start.js +662 -6
  29. package/hermes/bundle/shell/deeplake-shell.js +1028 -28
  30. package/hermes/bundle/skillify-worker.js +94 -3
  31. package/mcp/bundle/server.js +228 -0
  32. package/openclaw/dist/chunks/config-FH6JYSJW.js +53 -0
  33. package/openclaw/dist/index.js +307 -2
  34. package/openclaw/dist/skillify-worker.js +94 -3
  35. package/openclaw/openclaw.plugin.json +4 -2
  36. package/openclaw/package.json +1 -1
  37. package/openclaw/skills/hivemind-goals/SKILL.md +30 -0
  38. package/package.json +4 -1
  39. package/openclaw/dist/chunks/config-XEK4MJJS.js +0 -36
@@ -53,9 +53,9 @@ var init_index_marker_store = __esm({
53
53
  });
54
54
 
55
55
  // dist/src/hooks/codex/session-start.js
56
- import { spawn as spawn2 } from "node:child_process";
56
+ import { spawn as spawn3 } from "node:child_process";
57
57
  import { fileURLToPath as fileURLToPath2 } from "node:url";
58
- import { dirname as dirname7, join as join16 } from "node:path";
58
+ import { dirname as dirname7, join as join17 } from "node:path";
59
59
 
60
60
  // dist/src/commands/auth.js
61
61
  import { execSync } from "node:child_process";
@@ -324,6 +324,23 @@ function loadConfig() {
324
324
  tableName: process.env.HIVEMIND_TABLE ?? "memory",
325
325
  sessionsTableName: process.env.HIVEMIND_SESSIONS_TABLE ?? "sessions",
326
326
  skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
327
+ // Defaults match the table name written into the SQL — keep aligned
328
+ // with RULES_COLUMNS / TASKS_COLUMNS / TASK_EVENTS_COLUMNS in
329
+ // deeplake-schema.ts and with the e2e test-org override convention
330
+ // (memory_test / sessions_test → goals_test, etc.) documented in
331
+ // CLAUDE.md.
332
+ rulesTableName: process.env.HIVEMIND_RULES_TABLE ?? "hivemind_rules",
333
+ tasksTableName: process.env.HIVEMIND_TASKS_TABLE ?? "hivemind_tasks",
334
+ taskEventsTableName: process.env.HIVEMIND_TASK_EVENTS_TABLE ?? "hivemind_task_events",
335
+ // Goals + KPIs (refined design — VFS path classifier maps
336
+ // memory/goal/<user>/<status>/<uuid>.md → hivemind_goals row
337
+ // memory/kpi/<uuid>/<kpi_id>.md → hivemind_kpis row
338
+ // See src/shell/deeplake-fs.ts for the translation logic and
339
+ // GOALS_COLUMNS / KPIS_COLUMNS in deeplake-schema.ts for the
340
+ // table shape.
341
+ goalsTableName: process.env.HIVEMIND_GOALS_TABLE ?? "hivemind_goals",
342
+ kpisTableName: process.env.HIVEMIND_KPIS_TABLE ?? "hivemind_kpis",
343
+ codebaseTableName: process.env.HIVEMIND_CODEBASE_TABLE ?? "codebase",
327
344
  memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join7(home, ".deeplake", "memory")
328
345
  };
329
346
  }
@@ -397,6 +414,65 @@ var SKILLS_COLUMNS = Object.freeze([
397
414
  { name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
398
415
  { name: "updated_at", sql: "TEXT NOT NULL DEFAULT ''" }
399
416
  ]);
417
+ var RULES_COLUMNS = Object.freeze([
418
+ { name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
419
+ { name: "rule_id", sql: "TEXT NOT NULL DEFAULT ''" },
420
+ { name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
421
+ { name: "scope", sql: "TEXT NOT NULL DEFAULT 'team'" },
422
+ { name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
423
+ { name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
424
+ { name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
425
+ { name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
426
+ { name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
427
+ { name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
428
+ ]);
429
+ var TASKS_COLUMNS = Object.freeze([
430
+ { name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
431
+ { name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
432
+ { name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
433
+ { name: "scope", sql: "TEXT NOT NULL DEFAULT 'me'" },
434
+ { name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
435
+ { name: "assigned_to", sql: "TEXT NOT NULL DEFAULT ''" },
436
+ { name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
437
+ { name: "kpis", sql: "JSONB" },
438
+ { name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
439
+ { name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
440
+ { name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
441
+ { name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
442
+ ]);
443
+ var TASK_EVENTS_COLUMNS = Object.freeze([
444
+ { name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
445
+ { name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
446
+ { name: "task_version", sql: "BIGINT NOT NULL DEFAULT 1" },
447
+ { name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
448
+ { name: "value", sql: "BIGINT NOT NULL DEFAULT 0" },
449
+ { name: "note", sql: "TEXT NOT NULL DEFAULT ''" },
450
+ { name: "source", sql: "TEXT NOT NULL DEFAULT 'user'" },
451
+ { name: "agent", sql: "TEXT NOT NULL DEFAULT ''" },
452
+ { name: "ts", sql: "TEXT NOT NULL DEFAULT ''" },
453
+ { name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
454
+ ]);
455
+ var GOALS_COLUMNS = Object.freeze([
456
+ { name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
457
+ { name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
458
+ { name: "owner", sql: "TEXT NOT NULL DEFAULT ''" },
459
+ { name: "status", sql: "TEXT NOT NULL DEFAULT 'opened'" },
460
+ { name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
461
+ { name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
462
+ { name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
463
+ { name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
464
+ { name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
465
+ ]);
466
+ var KPIS_COLUMNS = Object.freeze([
467
+ { name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
468
+ { name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
469
+ { name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
470
+ { name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
471
+ { name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
472
+ { name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
473
+ { name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
474
+ { name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
475
+ ]);
400
476
  function validateSchema(label, cols) {
401
477
  const seen = /* @__PURE__ */ new Set();
402
478
  for (const col of cols) {
@@ -414,9 +490,38 @@ function validateSchema(label, cols) {
414
490
  }
415
491
  }
416
492
  }
493
+ var CODEBASE_COLUMNS = Object.freeze([
494
+ // Identity key (matches the PK below)
495
+ { name: "org_id", sql: "TEXT NOT NULL DEFAULT ''" },
496
+ { name: "workspace_id", sql: "TEXT NOT NULL DEFAULT ''" },
497
+ { name: "repo_slug", sql: "TEXT NOT NULL DEFAULT ''" },
498
+ { name: "user_id", sql: "TEXT NOT NULL DEFAULT ''" },
499
+ { name: "worktree_id", sql: "TEXT NOT NULL DEFAULT ''" },
500
+ { name: "commit_sha", sql: "TEXT NOT NULL DEFAULT ''" },
501
+ // Observation metadata
502
+ { name: "parent_sha", sql: "TEXT NOT NULL DEFAULT ''" },
503
+ { name: "branch", sql: "TEXT NOT NULL DEFAULT ''" },
504
+ { name: "ts", sql: "TIMESTAMP" },
505
+ { name: "pushed_by", sql: "TEXT NOT NULL DEFAULT ''" },
506
+ // Snapshot payload
507
+ { name: "snapshot_sha256", sql: "TEXT NOT NULL DEFAULT ''" },
508
+ { name: "snapshot_jsonb", sql: "TEXT NOT NULL DEFAULT ''" },
509
+ { name: "node_count", sql: "BIGINT NOT NULL DEFAULT 0" },
510
+ { name: "edge_count", sql: "BIGINT NOT NULL DEFAULT 0" },
511
+ // Generator metadata (for drift diagnostics — what hivemind version produced this?)
512
+ { name: "generator", sql: "TEXT NOT NULL DEFAULT 'hivemind-graph'" },
513
+ { name: "generator_version", sql: "TEXT NOT NULL DEFAULT ''" },
514
+ { name: "schema_version", sql: "BIGINT NOT NULL DEFAULT 1" }
515
+ ]);
417
516
  validateSchema("MEMORY_COLUMNS", MEMORY_COLUMNS);
418
517
  validateSchema("SESSIONS_COLUMNS", SESSIONS_COLUMNS);
419
518
  validateSchema("SKILLS_COLUMNS", SKILLS_COLUMNS);
519
+ validateSchema("RULES_COLUMNS", RULES_COLUMNS);
520
+ validateSchema("TASKS_COLUMNS", TASKS_COLUMNS);
521
+ validateSchema("TASK_EVENTS_COLUMNS", TASK_EVENTS_COLUMNS);
522
+ validateSchema("GOALS_COLUMNS", GOALS_COLUMNS);
523
+ validateSchema("KPIS_COLUMNS", KPIS_COLUMNS);
524
+ validateSchema("CODEBASE_COLUMNS", CODEBASE_COLUMNS);
420
525
  function buildCreateTableSql(tableName, cols) {
421
526
  const safe = sqlIdent(tableName);
422
527
  const colSql = cols.map((c) => `${c.name} ${c.sql}`).join(", ");
@@ -963,6 +1068,24 @@ var DeeplakeApi = class {
963
1068
  * This sidesteps the Deeplake UPDATE-coalescing quirk that bit the wiki
964
1069
  * worker.
965
1070
  */
1071
+ /**
1072
+ * Create the codebase table. One row per (org, workspace, repo, user,
1073
+ * worktree, commit) — see CODEBASE_COLUMNS for the schema. Healing
1074
+ * + index follow the same pattern as ensureSessionsTable.
1075
+ */
1076
+ async ensureCodebaseTable(name) {
1077
+ const safe = sqlIdent(name);
1078
+ const tables = await this.listTables();
1079
+ if (!tables.includes(safe)) {
1080
+ log3(`table "${safe}" not found, creating`);
1081
+ await this.createTableWithRetry(buildCreateTableSql(safe, CODEBASE_COLUMNS), safe);
1082
+ log3(`table "${safe}" created`);
1083
+ if (!tables.includes(safe))
1084
+ this._tablesCache = [...tables, safe];
1085
+ }
1086
+ await this.healSchema(safe, CODEBASE_COLUMNS);
1087
+ await this.ensureLookupIndex(safe, "codebase_identity", `("org_id", "workspace_id", "repo_slug", "user_id", "worktree_id", "commit_sha")`);
1088
+ }
966
1089
  async ensureSkillsTable(name) {
967
1090
  const safe = sqlIdent(name);
968
1091
  const tables = await this.listTables();
@@ -976,6 +1099,111 @@ var DeeplakeApi = class {
976
1099
  await this.healSchema(safe, SKILLS_COLUMNS);
977
1100
  await this.ensureLookupIndex(safe, "project_key_name", `("project_key", "name")`);
978
1101
  }
1102
+ /**
1103
+ * Create the rules table.
1104
+ *
1105
+ * One row per rule version (same write pattern as skills): edits INSERT
1106
+ * a fresh row with version+1, reads pick latest per rule_id via
1107
+ * `ORDER BY version DESC LIMIT 1`. Sidesteps the Deeplake
1108
+ * UPDATE-coalescing quirk by never UPDATEing.
1109
+ */
1110
+ async ensureRulesTable(name) {
1111
+ const safe = sqlIdent(name);
1112
+ const tables = await this.listTables();
1113
+ if (!tables.includes(safe)) {
1114
+ log3(`table "${safe}" not found, creating`);
1115
+ await this.createTableWithRetry(buildCreateTableSql(safe, RULES_COLUMNS), safe);
1116
+ log3(`table "${safe}" created`);
1117
+ if (!tables.includes(safe))
1118
+ this._tablesCache = [...tables, safe];
1119
+ }
1120
+ await this.healSchema(safe, RULES_COLUMNS);
1121
+ await this.ensureLookupIndex(safe, "rule_id_version", `("rule_id", "version")`);
1122
+ }
1123
+ /**
1124
+ * Create the tasks table.
1125
+ *
1126
+ * Same write pattern as rules + skills. `kpis` is a nullable JSONB
1127
+ * column with the agent's KPI metadata; KPI current values come from
1128
+ * `task_events` (SUM(value)), not this snapshot.
1129
+ */
1130
+ async ensureTasksTable(name) {
1131
+ const safe = sqlIdent(name);
1132
+ const tables = await this.listTables();
1133
+ if (!tables.includes(safe)) {
1134
+ log3(`table "${safe}" not found, creating`);
1135
+ await this.createTableWithRetry(buildCreateTableSql(safe, TASKS_COLUMNS), safe);
1136
+ log3(`table "${safe}" created`);
1137
+ if (!tables.includes(safe))
1138
+ this._tablesCache = [...tables, safe];
1139
+ }
1140
+ await this.healSchema(safe, TASKS_COLUMNS);
1141
+ await this.ensureLookupIndex(safe, "task_id_version", `("task_id", "version")`);
1142
+ }
1143
+ /**
1144
+ * Create the task-events table.
1145
+ *
1146
+ * Append-only. Every INSERT is a fresh row; never UPDATE. KPI current
1147
+ * value is `SUM(value) WHERE task_id=? AND kpi_id=?`. Index on
1148
+ * (task_id, kpi_id) is the canonical aggregation key.
1149
+ */
1150
+ async ensureTaskEventsTable(name) {
1151
+ const safe = sqlIdent(name);
1152
+ const tables = await this.listTables();
1153
+ if (!tables.includes(safe)) {
1154
+ log3(`table "${safe}" not found, creating`);
1155
+ await this.createTableWithRetry(buildCreateTableSql(safe, TASK_EVENTS_COLUMNS), safe);
1156
+ log3(`table "${safe}" created`);
1157
+ if (!tables.includes(safe))
1158
+ this._tablesCache = [...tables, safe];
1159
+ }
1160
+ await this.healSchema(safe, TASK_EVENTS_COLUMNS);
1161
+ await this.ensureLookupIndex(safe, "task_id_kpi_id", `("task_id", "kpi_id")`);
1162
+ }
1163
+ /**
1164
+ * Create the goals table.
1165
+ *
1166
+ * Backed by the VFS path convention memory/goal/<owner>/<status>/<goal_id>.md.
1167
+ * INSERT-only version-bumped: rm and mv operations translate to fresh
1168
+ * v=N+1 rows (status flips for mv → closed; rm is the same soft-close).
1169
+ * The (goal_id, version) index lets the VFS dispatch a cheap latest-row
1170
+ * read on cat / Read of a single goal.
1171
+ */
1172
+ async ensureGoalsTable(name) {
1173
+ const safe = sqlIdent(name);
1174
+ const tables = await this.listTables();
1175
+ if (!tables.includes(safe)) {
1176
+ log3(`table "${safe}" not found, creating`);
1177
+ await this.createTableWithRetry(buildCreateTableSql(safe, GOALS_COLUMNS), safe);
1178
+ log3(`table "${safe}" created`);
1179
+ if (!tables.includes(safe))
1180
+ this._tablesCache = [...tables, safe];
1181
+ }
1182
+ await this.healSchema(safe, GOALS_COLUMNS);
1183
+ await this.ensureLookupIndex(safe, "goal_id_version", `("goal_id", "version")`);
1184
+ await this.ensureLookupIndex(safe, "owner_status", `("owner", "status")`);
1185
+ }
1186
+ /**
1187
+ * Create the kpis table.
1188
+ *
1189
+ * Backed by memory/kpi/<goal_id>/<kpi_id>.md. KPI rows do NOT carry
1190
+ * owner — ownership derives from the parent goal via logical join on
1191
+ * goal_id. INSERT-only version-bumped. (goal_id, kpi_id) index is the
1192
+ * canonical lookup the VFS uses on Read and Write.
1193
+ */
1194
+ async ensureKpisTable(name) {
1195
+ const safe = sqlIdent(name);
1196
+ const tables = await this.listTables();
1197
+ if (!tables.includes(safe)) {
1198
+ log3(`table "${safe}" not found, creating`);
1199
+ await this.createTableWithRetry(buildCreateTableSql(safe, KPIS_COLUMNS), safe);
1200
+ log3(`table "${safe}" created`);
1201
+ if (!tables.includes(safe))
1202
+ this._tablesCache = [...tables, safe];
1203
+ }
1204
+ await this.healSchema(safe, KPIS_COLUMNS);
1205
+ await this.ensureLookupIndex(safe, "goal_id_kpi_id", `("goal_id", "kpi_id")`);
1206
+ }
979
1207
  };
980
1208
 
981
1209
  // dist/src/skillify/pull.js
@@ -1642,6 +1870,27 @@ async function autoPullSkills(deps = {}) {
1642
1870
  }
1643
1871
  }
1644
1872
 
1873
+ // dist/src/graph/spawn-pull-worker.js
1874
+ import { spawn as spawn2 } from "node:child_process";
1875
+ import { join as join16 } from "node:path";
1876
+ function spawnGraphPullWorker(cwd, bundleDir, deps = {}) {
1877
+ if (process.env.HIVEMIND_GRAPH_PULL === "0")
1878
+ return;
1879
+ const workerPath = join16(bundleDir, "graph-pull-worker.js");
1880
+ const opts = {
1881
+ detached: true,
1882
+ stdio: ["ignore", "ignore", "ignore"]
1883
+ };
1884
+ try {
1885
+ const sp = deps.spawn ?? spawn2;
1886
+ const child = sp("nohup", ["node", workerPath, "--cwd", cwd], opts);
1887
+ child.on("error", () => {
1888
+ });
1889
+ child.unref();
1890
+ } catch {
1891
+ }
1892
+ }
1893
+
1645
1894
  // dist/src/hooks/codex/session-start.js
1646
1895
  var log5 = (msg) => log("codex-session-start", msg);
1647
1896
  var __bundleDir = dirname7(fileURLToPath2(import.meta.url));
@@ -1658,8 +1907,8 @@ async function main() {
1658
1907
  log5(`credentials loaded: org=${creds.orgName ?? creds.orgId}`);
1659
1908
  }
1660
1909
  if (creds?.token) {
1661
- const setupScript = join16(__bundleDir, "session-start-setup.js");
1662
- const child = spawn2("node", [setupScript], {
1910
+ const setupScript = join17(__bundleDir, "session-start-setup.js");
1911
+ const child = spawn3("node", [setupScript], {
1663
1912
  detached: true,
1664
1913
  stdio: ["pipe", "ignore", "ignore"],
1665
1914
  env: { ...process.env }
@@ -1679,6 +1928,8 @@ Hivemind v${current}`;
1679
1928
  }
1680
1929
  const localMined = countLocalManifestEntries();
1681
1930
  const skillNoun = localMined === 1 ? "skill" : "skills";
1931
+ if (creds?.token)
1932
+ spawnGraphPullWorker(input.cwd, __bundleDir);
1682
1933
  const additionalContext = creds?.token ? `Hivemind: logged in as org ${creds.orgName ?? creds.orgId} (workspace: ${creds.workspaceId ?? "default"}).${versionNotice}` : `Hivemind: not logged in. Run \`hivemind login\` to enable shared memory + skill sharing.${versionNotice}`;
1683
1934
  const systemMessage = !creds?.token && localMined > 0 ? `\u{1F4A1} ${localMined} ${skillNoun} mined from your local sessions live in ~/.claude/skills/. Run 'hivemind login' to share them with your team.` : void 0;
1684
1935
  const output = {