@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.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +64 -0
- package/bundle/cli.js +22702 -7775
- package/codex/bundle/capture.js +228 -0
- package/codex/bundle/commands/auth-login.js +228 -0
- package/codex/bundle/graph-pull-worker.js +1370 -0
- package/codex/bundle/pre-tool-use.js +228 -0
- package/codex/bundle/session-start-setup.js +228 -0
- package/codex/bundle/session-start.js +255 -4
- package/codex/bundle/shell/deeplake-shell.js +1028 -28
- package/codex/bundle/skillify-worker.js +94 -3
- package/codex/bundle/stop.js +282 -50
- package/codex/skills/hivemind-goals/SKILL.md +157 -0
- package/cursor/bundle/capture.js +282 -50
- package/cursor/bundle/commands/auth-login.js +228 -0
- package/cursor/bundle/graph-pull-worker.js +1370 -0
- package/cursor/bundle/pre-tool-use.js +228 -0
- package/cursor/bundle/session-end.js +65 -44
- package/cursor/bundle/session-start.js +662 -6
- package/cursor/bundle/shell/deeplake-shell.js +1028 -28
- package/cursor/bundle/skillify-worker.js +94 -3
- package/hermes/bundle/capture.js +282 -50
- package/hermes/bundle/commands/auth-login.js +228 -0
- package/hermes/bundle/graph-pull-worker.js +1370 -0
- package/hermes/bundle/pre-tool-use.js +228 -0
- package/hermes/bundle/session-end.js +65 -44
- package/hermes/bundle/session-start.js +662 -6
- package/hermes/bundle/shell/deeplake-shell.js +1028 -28
- package/hermes/bundle/skillify-worker.js +94 -3
- package/mcp/bundle/server.js +228 -0
- package/openclaw/dist/chunks/config-FH6JYSJW.js +53 -0
- package/openclaw/dist/index.js +307 -2
- package/openclaw/dist/skillify-worker.js +94 -3
- package/openclaw/openclaw.plugin.json +4 -2
- package/openclaw/package.json +1 -1
- package/openclaw/skills/hivemind-goals/SKILL.md +30 -0
- package/package.json +4 -1
- package/openclaw/dist/chunks/config-XEK4MJJS.js +0 -36
|
@@ -378,6 +378,65 @@ var SKILLS_COLUMNS = Object.freeze([
|
|
|
378
378
|
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
379
379
|
{ name: "updated_at", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
380
380
|
]);
|
|
381
|
+
var RULES_COLUMNS = Object.freeze([
|
|
382
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
383
|
+
{ name: "rule_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
384
|
+
{ name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
385
|
+
{ name: "scope", sql: "TEXT NOT NULL DEFAULT 'team'" },
|
|
386
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
|
|
387
|
+
{ name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
388
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
389
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
390
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
391
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
392
|
+
]);
|
|
393
|
+
var TASKS_COLUMNS = Object.freeze([
|
|
394
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
395
|
+
{ name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
396
|
+
{ name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
397
|
+
{ name: "scope", sql: "TEXT NOT NULL DEFAULT 'me'" },
|
|
398
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
|
|
399
|
+
{ name: "assigned_to", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
400
|
+
{ name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
401
|
+
{ name: "kpis", sql: "JSONB" },
|
|
402
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
403
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
404
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
405
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
406
|
+
]);
|
|
407
|
+
var TASK_EVENTS_COLUMNS = Object.freeze([
|
|
408
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
409
|
+
{ name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
410
|
+
{ name: "task_version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
411
|
+
{ name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
412
|
+
{ name: "value", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
413
|
+
{ name: "note", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
414
|
+
{ name: "source", sql: "TEXT NOT NULL DEFAULT 'user'" },
|
|
415
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
416
|
+
{ name: "ts", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
417
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
418
|
+
]);
|
|
419
|
+
var GOALS_COLUMNS = Object.freeze([
|
|
420
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
421
|
+
{ name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
422
|
+
{ name: "owner", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
423
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'opened'" },
|
|
424
|
+
{ name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
425
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
426
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
427
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
428
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
429
|
+
]);
|
|
430
|
+
var KPIS_COLUMNS = Object.freeze([
|
|
431
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
432
|
+
{ name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
433
|
+
{ name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
434
|
+
{ name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
435
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
436
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
437
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
438
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
439
|
+
]);
|
|
381
440
|
function validateSchema(label, cols) {
|
|
382
441
|
const seen = /* @__PURE__ */ new Set();
|
|
383
442
|
for (const col of cols) {
|
|
@@ -395,9 +454,38 @@ function validateSchema(label, cols) {
|
|
|
395
454
|
}
|
|
396
455
|
}
|
|
397
456
|
}
|
|
457
|
+
var CODEBASE_COLUMNS = Object.freeze([
|
|
458
|
+
// Identity key (matches the PK below)
|
|
459
|
+
{ name: "org_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
460
|
+
{ name: "workspace_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
461
|
+
{ name: "repo_slug", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
462
|
+
{ name: "user_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
463
|
+
{ name: "worktree_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
464
|
+
{ name: "commit_sha", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
465
|
+
// Observation metadata
|
|
466
|
+
{ name: "parent_sha", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
467
|
+
{ name: "branch", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
468
|
+
{ name: "ts", sql: "TIMESTAMP" },
|
|
469
|
+
{ name: "pushed_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
470
|
+
// Snapshot payload
|
|
471
|
+
{ name: "snapshot_sha256", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
472
|
+
{ name: "snapshot_jsonb", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
473
|
+
{ name: "node_count", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
474
|
+
{ name: "edge_count", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
475
|
+
// Generator metadata (for drift diagnostics — what hivemind version produced this?)
|
|
476
|
+
{ name: "generator", sql: "TEXT NOT NULL DEFAULT 'hivemind-graph'" },
|
|
477
|
+
{ name: "generator_version", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
478
|
+
{ name: "schema_version", sql: "BIGINT NOT NULL DEFAULT 1" }
|
|
479
|
+
]);
|
|
398
480
|
validateSchema("MEMORY_COLUMNS", MEMORY_COLUMNS);
|
|
399
481
|
validateSchema("SESSIONS_COLUMNS", SESSIONS_COLUMNS);
|
|
400
482
|
validateSchema("SKILLS_COLUMNS", SKILLS_COLUMNS);
|
|
483
|
+
validateSchema("RULES_COLUMNS", RULES_COLUMNS);
|
|
484
|
+
validateSchema("TASKS_COLUMNS", TASKS_COLUMNS);
|
|
485
|
+
validateSchema("TASK_EVENTS_COLUMNS", TASK_EVENTS_COLUMNS);
|
|
486
|
+
validateSchema("GOALS_COLUMNS", GOALS_COLUMNS);
|
|
487
|
+
validateSchema("KPIS_COLUMNS", KPIS_COLUMNS);
|
|
488
|
+
validateSchema("CODEBASE_COLUMNS", CODEBASE_COLUMNS);
|
|
401
489
|
function buildCreateTableSql(tableName, cols) {
|
|
402
490
|
const safe = sqlIdent(tableName);
|
|
403
491
|
const colSql = cols.map((c) => `${c.name} ${c.sql}`).join(", ");
|
|
@@ -693,9 +781,12 @@ function resolveRecordScope(args) {
|
|
|
693
781
|
|
|
694
782
|
// dist/src/skillify/state.js
|
|
695
783
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, writeSync, mkdirSync as mkdirSync2, renameSync as renameSync2, rmdirSync, existsSync as existsSync4, lstatSync, unlinkSync, openSync, closeSync } from "node:fs";
|
|
784
|
+
import { join as join6 } from "node:path";
|
|
785
|
+
|
|
786
|
+
// dist/src/utils/repo-identity.js
|
|
696
787
|
import { execSync } from "node:child_process";
|
|
697
788
|
import { createHash } from "node:crypto";
|
|
698
|
-
import {
|
|
789
|
+
import { basename, resolve } from "node:path";
|
|
699
790
|
|
|
700
791
|
// dist/src/skillify/legacy-migration.js
|
|
701
792
|
import { existsSync as existsSync3, renameSync } from "node:fs";
|
|
@@ -881,7 +972,7 @@ async function query(sql, retries = 4) {
|
|
|
881
972
|
const base = Math.min(3e4, 2e3 * Math.pow(2, attempt));
|
|
882
973
|
const delay = base + Math.floor(Math.random() * 1e3);
|
|
883
974
|
wlog(`fetch failed (${e?.name ?? e?.code ?? e?.message}), retrying in ${delay}ms (attempt ${attempt + 1}/${retries})`);
|
|
884
|
-
await new Promise((
|
|
975
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
885
976
|
continue;
|
|
886
977
|
}
|
|
887
978
|
throw e;
|
|
@@ -897,7 +988,7 @@ async function query(sql, retries = 4) {
|
|
|
897
988
|
const base = Math.min(3e4, 2e3 * Math.pow(2, attempt));
|
|
898
989
|
const delay = base + Math.floor(Math.random() * 1e3);
|
|
899
990
|
wlog(`API ${r.status}, retrying in ${delay}ms (attempt ${attempt + 1}/${retries})`);
|
|
900
|
-
await new Promise((
|
|
991
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
901
992
|
continue;
|
|
902
993
|
}
|
|
903
994
|
throw new Error(`API ${r.status}: ${(await r.text()).slice(0, 200)}`);
|
package/mcp/bundle/server.js
CHANGED
|
@@ -23330,6 +23330,23 @@ function loadConfig() {
|
|
|
23330
23330
|
tableName: process.env.HIVEMIND_TABLE ?? "memory",
|
|
23331
23331
|
sessionsTableName: process.env.HIVEMIND_SESSIONS_TABLE ?? "sessions",
|
|
23332
23332
|
skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
|
|
23333
|
+
// Defaults match the table name written into the SQL — keep aligned
|
|
23334
|
+
// with RULES_COLUMNS / TASKS_COLUMNS / TASK_EVENTS_COLUMNS in
|
|
23335
|
+
// deeplake-schema.ts and with the e2e test-org override convention
|
|
23336
|
+
// (memory_test / sessions_test → goals_test, etc.) documented in
|
|
23337
|
+
// CLAUDE.md.
|
|
23338
|
+
rulesTableName: process.env.HIVEMIND_RULES_TABLE ?? "hivemind_rules",
|
|
23339
|
+
tasksTableName: process.env.HIVEMIND_TASKS_TABLE ?? "hivemind_tasks",
|
|
23340
|
+
taskEventsTableName: process.env.HIVEMIND_TASK_EVENTS_TABLE ?? "hivemind_task_events",
|
|
23341
|
+
// Goals + KPIs (refined design — VFS path classifier maps
|
|
23342
|
+
// memory/goal/<user>/<status>/<uuid>.md → hivemind_goals row
|
|
23343
|
+
// memory/kpi/<uuid>/<kpi_id>.md → hivemind_kpis row
|
|
23344
|
+
// See src/shell/deeplake-fs.ts for the translation logic and
|
|
23345
|
+
// GOALS_COLUMNS / KPIS_COLUMNS in deeplake-schema.ts for the
|
|
23346
|
+
// table shape.
|
|
23347
|
+
goalsTableName: process.env.HIVEMIND_GOALS_TABLE ?? "hivemind_goals",
|
|
23348
|
+
kpisTableName: process.env.HIVEMIND_KPIS_TABLE ?? "hivemind_kpis",
|
|
23349
|
+
codebaseTableName: process.env.HIVEMIND_CODEBASE_TABLE ?? "codebase",
|
|
23333
23350
|
memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join3(home, ".deeplake", "memory")
|
|
23334
23351
|
};
|
|
23335
23352
|
}
|
|
@@ -23421,6 +23438,65 @@ var SKILLS_COLUMNS = Object.freeze([
|
|
|
23421
23438
|
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23422
23439
|
{ name: "updated_at", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23423
23440
|
]);
|
|
23441
|
+
var RULES_COLUMNS = Object.freeze([
|
|
23442
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23443
|
+
{ name: "rule_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23444
|
+
{ name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23445
|
+
{ name: "scope", sql: "TEXT NOT NULL DEFAULT 'team'" },
|
|
23446
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
|
|
23447
|
+
{ name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23448
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
23449
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23450
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
23451
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23452
|
+
]);
|
|
23453
|
+
var TASKS_COLUMNS = Object.freeze([
|
|
23454
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23455
|
+
{ name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23456
|
+
{ name: "text", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23457
|
+
{ name: "scope", sql: "TEXT NOT NULL DEFAULT 'me'" },
|
|
23458
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'active'" },
|
|
23459
|
+
{ name: "assigned_to", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23460
|
+
{ name: "assigned_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23461
|
+
{ name: "kpis", sql: "JSONB" },
|
|
23462
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
23463
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23464
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
23465
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23466
|
+
]);
|
|
23467
|
+
var TASK_EVENTS_COLUMNS = Object.freeze([
|
|
23468
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23469
|
+
{ name: "task_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23470
|
+
{ name: "task_version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
23471
|
+
{ name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23472
|
+
{ name: "value", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
23473
|
+
{ name: "note", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23474
|
+
{ name: "source", sql: "TEXT NOT NULL DEFAULT 'user'" },
|
|
23475
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23476
|
+
{ name: "ts", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23477
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23478
|
+
]);
|
|
23479
|
+
var GOALS_COLUMNS = Object.freeze([
|
|
23480
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23481
|
+
{ name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23482
|
+
{ name: "owner", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23483
|
+
{ name: "status", sql: "TEXT NOT NULL DEFAULT 'opened'" },
|
|
23484
|
+
{ name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23485
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
23486
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23487
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
23488
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23489
|
+
]);
|
|
23490
|
+
var KPIS_COLUMNS = Object.freeze([
|
|
23491
|
+
{ name: "id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23492
|
+
{ name: "goal_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23493
|
+
{ name: "kpi_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23494
|
+
{ name: "content", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23495
|
+
{ name: "version", sql: "BIGINT NOT NULL DEFAULT 1" },
|
|
23496
|
+
{ name: "created_at", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23497
|
+
{ name: "agent", sql: "TEXT NOT NULL DEFAULT 'manual'" },
|
|
23498
|
+
{ name: "plugin_version", sql: "TEXT NOT NULL DEFAULT ''" }
|
|
23499
|
+
]);
|
|
23424
23500
|
function validateSchema(label, cols) {
|
|
23425
23501
|
const seen = /* @__PURE__ */ new Set();
|
|
23426
23502
|
for (const col of cols) {
|
|
@@ -23438,9 +23514,38 @@ function validateSchema(label, cols) {
|
|
|
23438
23514
|
}
|
|
23439
23515
|
}
|
|
23440
23516
|
}
|
|
23517
|
+
var CODEBASE_COLUMNS = Object.freeze([
|
|
23518
|
+
// Identity key (matches the PK below)
|
|
23519
|
+
{ name: "org_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23520
|
+
{ name: "workspace_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23521
|
+
{ name: "repo_slug", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23522
|
+
{ name: "user_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23523
|
+
{ name: "worktree_id", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23524
|
+
{ name: "commit_sha", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23525
|
+
// Observation metadata
|
|
23526
|
+
{ name: "parent_sha", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23527
|
+
{ name: "branch", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23528
|
+
{ name: "ts", sql: "TIMESTAMP" },
|
|
23529
|
+
{ name: "pushed_by", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23530
|
+
// Snapshot payload
|
|
23531
|
+
{ name: "snapshot_sha256", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23532
|
+
{ name: "snapshot_jsonb", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23533
|
+
{ name: "node_count", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
23534
|
+
{ name: "edge_count", sql: "BIGINT NOT NULL DEFAULT 0" },
|
|
23535
|
+
// Generator metadata (for drift diagnostics — what hivemind version produced this?)
|
|
23536
|
+
{ name: "generator", sql: "TEXT NOT NULL DEFAULT 'hivemind-graph'" },
|
|
23537
|
+
{ name: "generator_version", sql: "TEXT NOT NULL DEFAULT ''" },
|
|
23538
|
+
{ name: "schema_version", sql: "BIGINT NOT NULL DEFAULT 1" }
|
|
23539
|
+
]);
|
|
23441
23540
|
validateSchema("MEMORY_COLUMNS", MEMORY_COLUMNS);
|
|
23442
23541
|
validateSchema("SESSIONS_COLUMNS", SESSIONS_COLUMNS);
|
|
23443
23542
|
validateSchema("SKILLS_COLUMNS", SKILLS_COLUMNS);
|
|
23543
|
+
validateSchema("RULES_COLUMNS", RULES_COLUMNS);
|
|
23544
|
+
validateSchema("TASKS_COLUMNS", TASKS_COLUMNS);
|
|
23545
|
+
validateSchema("TASK_EVENTS_COLUMNS", TASK_EVENTS_COLUMNS);
|
|
23546
|
+
validateSchema("GOALS_COLUMNS", GOALS_COLUMNS);
|
|
23547
|
+
validateSchema("KPIS_COLUMNS", KPIS_COLUMNS);
|
|
23548
|
+
validateSchema("CODEBASE_COLUMNS", CODEBASE_COLUMNS);
|
|
23444
23549
|
function buildCreateTableSql(tableName, cols) {
|
|
23445
23550
|
const safe = sqlIdent(tableName);
|
|
23446
23551
|
const colSql = cols.map((c) => `${c.name} ${c.sql}`).join(", ");
|
|
@@ -23987,6 +24092,24 @@ var DeeplakeApi = class {
|
|
|
23987
24092
|
* This sidesteps the Deeplake UPDATE-coalescing quirk that bit the wiki
|
|
23988
24093
|
* worker.
|
|
23989
24094
|
*/
|
|
24095
|
+
/**
|
|
24096
|
+
* Create the codebase table. One row per (org, workspace, repo, user,
|
|
24097
|
+
* worktree, commit) — see CODEBASE_COLUMNS for the schema. Healing
|
|
24098
|
+
* + index follow the same pattern as ensureSessionsTable.
|
|
24099
|
+
*/
|
|
24100
|
+
async ensureCodebaseTable(name) {
|
|
24101
|
+
const safe = sqlIdent(name);
|
|
24102
|
+
const tables = await this.listTables();
|
|
24103
|
+
if (!tables.includes(safe)) {
|
|
24104
|
+
log3(`table "${safe}" not found, creating`);
|
|
24105
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, CODEBASE_COLUMNS), safe);
|
|
24106
|
+
log3(`table "${safe}" created`);
|
|
24107
|
+
if (!tables.includes(safe))
|
|
24108
|
+
this._tablesCache = [...tables, safe];
|
|
24109
|
+
}
|
|
24110
|
+
await this.healSchema(safe, CODEBASE_COLUMNS);
|
|
24111
|
+
await this.ensureLookupIndex(safe, "codebase_identity", `("org_id", "workspace_id", "repo_slug", "user_id", "worktree_id", "commit_sha")`);
|
|
24112
|
+
}
|
|
23990
24113
|
async ensureSkillsTable(name) {
|
|
23991
24114
|
const safe = sqlIdent(name);
|
|
23992
24115
|
const tables = await this.listTables();
|
|
@@ -24000,6 +24123,111 @@ var DeeplakeApi = class {
|
|
|
24000
24123
|
await this.healSchema(safe, SKILLS_COLUMNS);
|
|
24001
24124
|
await this.ensureLookupIndex(safe, "project_key_name", `("project_key", "name")`);
|
|
24002
24125
|
}
|
|
24126
|
+
/**
|
|
24127
|
+
* Create the rules table.
|
|
24128
|
+
*
|
|
24129
|
+
* One row per rule version (same write pattern as skills): edits INSERT
|
|
24130
|
+
* a fresh row with version+1, reads pick latest per rule_id via
|
|
24131
|
+
* `ORDER BY version DESC LIMIT 1`. Sidesteps the Deeplake
|
|
24132
|
+
* UPDATE-coalescing quirk by never UPDATEing.
|
|
24133
|
+
*/
|
|
24134
|
+
async ensureRulesTable(name) {
|
|
24135
|
+
const safe = sqlIdent(name);
|
|
24136
|
+
const tables = await this.listTables();
|
|
24137
|
+
if (!tables.includes(safe)) {
|
|
24138
|
+
log3(`table "${safe}" not found, creating`);
|
|
24139
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, RULES_COLUMNS), safe);
|
|
24140
|
+
log3(`table "${safe}" created`);
|
|
24141
|
+
if (!tables.includes(safe))
|
|
24142
|
+
this._tablesCache = [...tables, safe];
|
|
24143
|
+
}
|
|
24144
|
+
await this.healSchema(safe, RULES_COLUMNS);
|
|
24145
|
+
await this.ensureLookupIndex(safe, "rule_id_version", `("rule_id", "version")`);
|
|
24146
|
+
}
|
|
24147
|
+
/**
|
|
24148
|
+
* Create the tasks table.
|
|
24149
|
+
*
|
|
24150
|
+
* Same write pattern as rules + skills. `kpis` is a nullable JSONB
|
|
24151
|
+
* column with the agent's KPI metadata; KPI current values come from
|
|
24152
|
+
* `task_events` (SUM(value)), not this snapshot.
|
|
24153
|
+
*/
|
|
24154
|
+
async ensureTasksTable(name) {
|
|
24155
|
+
const safe = sqlIdent(name);
|
|
24156
|
+
const tables = await this.listTables();
|
|
24157
|
+
if (!tables.includes(safe)) {
|
|
24158
|
+
log3(`table "${safe}" not found, creating`);
|
|
24159
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, TASKS_COLUMNS), safe);
|
|
24160
|
+
log3(`table "${safe}" created`);
|
|
24161
|
+
if (!tables.includes(safe))
|
|
24162
|
+
this._tablesCache = [...tables, safe];
|
|
24163
|
+
}
|
|
24164
|
+
await this.healSchema(safe, TASKS_COLUMNS);
|
|
24165
|
+
await this.ensureLookupIndex(safe, "task_id_version", `("task_id", "version")`);
|
|
24166
|
+
}
|
|
24167
|
+
/**
|
|
24168
|
+
* Create the task-events table.
|
|
24169
|
+
*
|
|
24170
|
+
* Append-only. Every INSERT is a fresh row; never UPDATE. KPI current
|
|
24171
|
+
* value is `SUM(value) WHERE task_id=? AND kpi_id=?`. Index on
|
|
24172
|
+
* (task_id, kpi_id) is the canonical aggregation key.
|
|
24173
|
+
*/
|
|
24174
|
+
async ensureTaskEventsTable(name) {
|
|
24175
|
+
const safe = sqlIdent(name);
|
|
24176
|
+
const tables = await this.listTables();
|
|
24177
|
+
if (!tables.includes(safe)) {
|
|
24178
|
+
log3(`table "${safe}" not found, creating`);
|
|
24179
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, TASK_EVENTS_COLUMNS), safe);
|
|
24180
|
+
log3(`table "${safe}" created`);
|
|
24181
|
+
if (!tables.includes(safe))
|
|
24182
|
+
this._tablesCache = [...tables, safe];
|
|
24183
|
+
}
|
|
24184
|
+
await this.healSchema(safe, TASK_EVENTS_COLUMNS);
|
|
24185
|
+
await this.ensureLookupIndex(safe, "task_id_kpi_id", `("task_id", "kpi_id")`);
|
|
24186
|
+
}
|
|
24187
|
+
/**
|
|
24188
|
+
* Create the goals table.
|
|
24189
|
+
*
|
|
24190
|
+
* Backed by the VFS path convention memory/goal/<owner>/<status>/<goal_id>.md.
|
|
24191
|
+
* INSERT-only version-bumped: rm and mv operations translate to fresh
|
|
24192
|
+
* v=N+1 rows (status flips for mv → closed; rm is the same soft-close).
|
|
24193
|
+
* The (goal_id, version) index lets the VFS dispatch a cheap latest-row
|
|
24194
|
+
* read on cat / Read of a single goal.
|
|
24195
|
+
*/
|
|
24196
|
+
async ensureGoalsTable(name) {
|
|
24197
|
+
const safe = sqlIdent(name);
|
|
24198
|
+
const tables = await this.listTables();
|
|
24199
|
+
if (!tables.includes(safe)) {
|
|
24200
|
+
log3(`table "${safe}" not found, creating`);
|
|
24201
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, GOALS_COLUMNS), safe);
|
|
24202
|
+
log3(`table "${safe}" created`);
|
|
24203
|
+
if (!tables.includes(safe))
|
|
24204
|
+
this._tablesCache = [...tables, safe];
|
|
24205
|
+
}
|
|
24206
|
+
await this.healSchema(safe, GOALS_COLUMNS);
|
|
24207
|
+
await this.ensureLookupIndex(safe, "goal_id_version", `("goal_id", "version")`);
|
|
24208
|
+
await this.ensureLookupIndex(safe, "owner_status", `("owner", "status")`);
|
|
24209
|
+
}
|
|
24210
|
+
/**
|
|
24211
|
+
* Create the kpis table.
|
|
24212
|
+
*
|
|
24213
|
+
* Backed by memory/kpi/<goal_id>/<kpi_id>.md. KPI rows do NOT carry
|
|
24214
|
+
* owner — ownership derives from the parent goal via logical join on
|
|
24215
|
+
* goal_id. INSERT-only version-bumped. (goal_id, kpi_id) index is the
|
|
24216
|
+
* canonical lookup the VFS uses on Read and Write.
|
|
24217
|
+
*/
|
|
24218
|
+
async ensureKpisTable(name) {
|
|
24219
|
+
const safe = sqlIdent(name);
|
|
24220
|
+
const tables = await this.listTables();
|
|
24221
|
+
if (!tables.includes(safe)) {
|
|
24222
|
+
log3(`table "${safe}" not found, creating`);
|
|
24223
|
+
await this.createTableWithRetry(buildCreateTableSql(safe, KPIS_COLUMNS), safe);
|
|
24224
|
+
log3(`table "${safe}" created`);
|
|
24225
|
+
if (!tables.includes(safe))
|
|
24226
|
+
this._tablesCache = [...tables, safe];
|
|
24227
|
+
}
|
|
24228
|
+
await this.healSchema(safe, KPIS_COLUMNS);
|
|
24229
|
+
await this.ensureLookupIndex(safe, "goal_id_kpi_id", `("goal_id", "kpi_id")`);
|
|
24230
|
+
}
|
|
24003
24231
|
};
|
|
24004
24232
|
|
|
24005
24233
|
// dist/src/shell/grep-core.js
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
globalThis.__hivemind_tuning__ ??= {};
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { homedir, userInfo } from "node:os";
|
|
7
|
+
function loadConfig() {
|
|
8
|
+
const home = homedir();
|
|
9
|
+
const credPath = join(home, ".deeplake", "credentials.json");
|
|
10
|
+
let creds = null;
|
|
11
|
+
if (existsSync(credPath)) {
|
|
12
|
+
try {
|
|
13
|
+
creds = JSON.parse(readFileSync(credPath, "utf-8"));
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const token = creds?.token;
|
|
19
|
+
const orgId = creds?.orgId;
|
|
20
|
+
if (!token || !orgId) return null;
|
|
21
|
+
return {
|
|
22
|
+
token,
|
|
23
|
+
orgId,
|
|
24
|
+
orgName: creds?.orgName ?? orgId,
|
|
25
|
+
userName: creds?.userName || userInfo().username || "unknown",
|
|
26
|
+
workspaceId: creds?.workspaceId ?? "default",
|
|
27
|
+
apiUrl: creds?.apiUrl ?? "https://api.deeplake.ai",
|
|
28
|
+
tableName: "memory",
|
|
29
|
+
sessionsTableName: "sessions",
|
|
30
|
+
skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
|
|
31
|
+
// Defaults match the table name written into the SQL — keep aligned
|
|
32
|
+
// with RULES_COLUMNS / TASKS_COLUMNS / TASK_EVENTS_COLUMNS in
|
|
33
|
+
// deeplake-schema.ts and with the e2e test-org override convention
|
|
34
|
+
// (memory_test / sessions_test → goals_test, etc.) documented in
|
|
35
|
+
// CLAUDE.md.
|
|
36
|
+
rulesTableName: process.env.HIVEMIND_RULES_TABLE ?? "hivemind_rules",
|
|
37
|
+
tasksTableName: process.env.HIVEMIND_TASKS_TABLE ?? "hivemind_tasks",
|
|
38
|
+
taskEventsTableName: process.env.HIVEMIND_TASK_EVENTS_TABLE ?? "hivemind_task_events",
|
|
39
|
+
// Goals + KPIs (refined design — VFS path classifier maps
|
|
40
|
+
// memory/goal/<user>/<status>/<uuid>.md → hivemind_goals row
|
|
41
|
+
// memory/kpi/<uuid>/<kpi_id>.md → hivemind_kpis row
|
|
42
|
+
// See src/shell/deeplake-fs.ts for the translation logic and
|
|
43
|
+
// GOALS_COLUMNS / KPIS_COLUMNS in deeplake-schema.ts for the
|
|
44
|
+
// table shape.
|
|
45
|
+
goalsTableName: process.env.HIVEMIND_GOALS_TABLE ?? "hivemind_goals",
|
|
46
|
+
kpisTableName: process.env.HIVEMIND_KPIS_TABLE ?? "hivemind_kpis",
|
|
47
|
+
codebaseTableName: "codebase",
|
|
48
|
+
memoryPath: join(home, ".deeplake", "memory")
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
loadConfig
|
|
53
|
+
};
|