@vectorize-io/hindsight-coding-agents 0.5.2 → 0.5.4
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/README.md +42 -8
- package/dist/antigravity-hook.js +335 -91
- package/dist/antigravity-statusline.js +17 -10
- package/dist/antigravity-stop-hook.js +340 -92
- package/dist/claude-hook.js +335 -91
- package/dist/claude-sessionstart-hook.js +459 -132
- package/dist/claude-stop-hook.js +340 -92
- package/dist/cline.js +283 -64
- package/dist/codex-hook.js +335 -91
- package/dist/codex-sessionstart-hook.js +459 -132
- package/dist/codex-stop-hook.js +340 -92
- package/dist/copilot-hook.js +335 -91
- package/dist/copilot-sessionstart-hook.js +459 -132
- package/dist/copilot-stop-hook.js +340 -92
- package/dist/cursor-hook.js +335 -91
- package/dist/cursor-sessionstart-hook.js +459 -132
- package/dist/cursor-stop-hook.js +340 -92
- package/dist/daemon-start.js +17 -10
- package/dist/dcode-hook.js +335 -91
- package/dist/dcode-sessionstart-hook.js +459 -132
- package/dist/dcode-stop-hook.js +340 -92
- package/dist/deepen.js +113 -32
- package/dist/devin-hook.js +335 -91
- package/dist/devin-sessionstart-hook.js +459 -132
- package/dist/devin-stop-hook.js +340 -92
- package/dist/droid-hook.js +335 -91
- package/dist/droid-sessionstart-hook.js +459 -132
- package/dist/droid-stop-hook.js +340 -92
- package/dist/dsh.js +322 -101
- package/dist/grok-hook.js +335 -91
- package/dist/grok-sessionstart-hook.js +459 -132
- package/dist/grok-stop-hook.js +340 -92
- package/dist/hindsight-seed.js +17 -10
- package/dist/index.js +322 -101
- package/dist/installer.js +1252 -325
- package/dist/kilo.js +322 -101
- package/dist/mcp-server.js +100 -23
- package/dist/opencode2.js +322 -101
- package/dist/pi.js +321 -100
- package/dist/prime-agent.js +321 -100
- package/dist/qwen-hook.js +335 -91
- package/dist/qwen-sessionstart-hook.js +459 -132
- package/dist/qwen-stop-hook.js +340 -92
- package/dist/status.js +98 -21
- package/dist/survey-supervisor.js +81 -0
- package/dist/zcode-hook.js +2954 -0
- package/dist/zcode-sessionstart-hook.js +3655 -0
- package/dist/zcode-stop-hook.js +3218 -0
- package/package.json +7 -3
- package/plugin.json +1 -1
- package/skill/SKILL.md +17 -7
package/dist/deepen.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/deepen.ts
|
|
4
4
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
5
|
-
import { mkdirSync as
|
|
6
|
-
import { tmpdir as
|
|
7
|
-
import { join as
|
|
5
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
6
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
7
|
+
import { join as join9 } from "path";
|
|
8
8
|
|
|
9
9
|
// src/core/bank.ts
|
|
10
10
|
import { existsSync } from "fs";
|
|
@@ -452,6 +452,7 @@ function pagesFor(project) {
|
|
|
452
452
|
var PAGE_MAX_TOKENS = 4096;
|
|
453
453
|
var PAGE_TAGS_MATCH = "all";
|
|
454
454
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
455
|
+
var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
|
|
455
456
|
var CRON_FIELD_RANGES = [
|
|
456
457
|
[0, 59],
|
|
457
458
|
// minute
|
|
@@ -505,14 +506,23 @@ function pageTriggerFor(trigger, bank, page) {
|
|
|
505
506
|
function buildPageTrigger(cfg2 = {}) {
|
|
506
507
|
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
507
508
|
switch (cfg2.pageTriggerType) {
|
|
508
|
-
case "
|
|
509
|
-
return { ...base,
|
|
509
|
+
case "auto-refresh":
|
|
510
|
+
return { ...base, refresh_after_consolidation: true };
|
|
510
511
|
case "manual":
|
|
511
512
|
return { ...base, refresh_after_consolidation: false };
|
|
513
|
+
// "cron" and an unset type alike: the default schedule stands in for a missing expression, so
|
|
514
|
+
// a trigger built from a partial config is never a cron trigger with nothing to fire on.
|
|
512
515
|
default:
|
|
513
|
-
return { ...base,
|
|
516
|
+
return { ...base, refresh_cron: cfg2.pageTriggerCron || DEFAULT_PAGE_TRIGGER_CRON };
|
|
514
517
|
}
|
|
515
518
|
}
|
|
519
|
+
function pageTriggerDrifted(current2, desired) {
|
|
520
|
+
return current2.tags_match !== desired.tags_match || (current2.refresh_cron ?? null) !== (desired.refresh_cron ?? null) || Boolean(current2.refresh_after_consolidation) !== Boolean(desired.refresh_after_consolidation);
|
|
521
|
+
}
|
|
522
|
+
function pageTriggerPatch(desired) {
|
|
523
|
+
if (desired.refresh_after_consolidation === false) return { ...desired, refresh_cron: null };
|
|
524
|
+
return desired;
|
|
525
|
+
}
|
|
516
526
|
var CODING_BANK_TEMPLATE = {
|
|
517
527
|
version: "1",
|
|
518
528
|
bank: {
|
|
@@ -917,9 +927,16 @@ var HindsightClient = class {
|
|
|
917
927
|
body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
|
|
918
928
|
signal: ctrl.signal
|
|
919
929
|
});
|
|
920
|
-
if (!resp.ok)
|
|
930
|
+
if (!resp.ok)
|
|
931
|
+
throw new Error(
|
|
932
|
+
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
|
|
933
|
+
);
|
|
921
934
|
const data = await resp.json();
|
|
922
935
|
return (data.text || "").trim();
|
|
936
|
+
} catch (e) {
|
|
937
|
+
if (ctrl.signal.aborted)
|
|
938
|
+
throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
|
|
939
|
+
throw e;
|
|
923
940
|
} finally {
|
|
924
941
|
clearTimeout(timer);
|
|
925
942
|
}
|
|
@@ -1052,14 +1069,14 @@ var HindsightClient = class {
|
|
|
1052
1069
|
if (r.status !== 409) created++;
|
|
1053
1070
|
} else {
|
|
1054
1071
|
const sourceDrift = hit.description !== page.source_query;
|
|
1055
|
-
const triggerDrift = hit.trigger != null && hit.trigger
|
|
1072
|
+
const triggerDrift = hit.trigger != null && pageTriggerDrifted(hit.trigger, body.trigger);
|
|
1056
1073
|
if (!sourceDrift && !triggerDrift) continue;
|
|
1057
1074
|
const patch = {};
|
|
1058
1075
|
if (sourceDrift) {
|
|
1059
1076
|
patch.source_query = page.source_query;
|
|
1060
1077
|
patch.tags = page.tags;
|
|
1061
1078
|
}
|
|
1062
|
-
if (triggerDrift) patch.trigger =
|
|
1079
|
+
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1063
1080
|
const r = await this.req(
|
|
1064
1081
|
"PATCH",
|
|
1065
1082
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1075,9 +1092,41 @@ var HindsightClient = class {
|
|
|
1075
1092
|
updated++;
|
|
1076
1093
|
}
|
|
1077
1094
|
}
|
|
1095
|
+
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1078
1096
|
this.log(
|
|
1079
|
-
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
|
|
1097
|
+
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged` + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Bring the captured initiative pages onto the same refresh policy as the seeded taxonomy.
|
|
1102
|
+
*
|
|
1103
|
+
* `captureInitiative` stamps this very trigger when it creates a page, so on a bank seeded under
|
|
1104
|
+
* an older default they are the same drift as the taxonomy — and on a real repo they are most of
|
|
1105
|
+
* it: five taxonomy pages against one page per initiative, each an LLM synthesis per
|
|
1106
|
+
* consolidation under the auto-refresh that used to be the default (#3506).
|
|
1107
|
+
*
|
|
1108
|
+
* Only the trigger is touched. Their `name` and `source_query` are written once, from the
|
|
1109
|
+
* initiative's own title, and re-stating either would rebuild a page whose question never
|
|
1110
|
+
* changed. The tree read above is reused rather than re-fetched.
|
|
1111
|
+
*/
|
|
1112
|
+
async resyncInitiativeTriggers(roots, pageTrigger) {
|
|
1113
|
+
const folder = roots.find(
|
|
1114
|
+
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === "initiatives"
|
|
1080
1115
|
);
|
|
1116
|
+
let updated = 0;
|
|
1117
|
+
for (const page of folder?.children ?? []) {
|
|
1118
|
+
if (page.kind !== "page" || page.trigger == null) continue;
|
|
1119
|
+
const desired = pageTriggerFor(pageTrigger, this.bank, page.name);
|
|
1120
|
+
if (!pageTriggerDrifted(page.trigger, desired)) continue;
|
|
1121
|
+
const r = await this.req(
|
|
1122
|
+
"PATCH",
|
|
1123
|
+
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1124
|
+
{ trigger: pageTriggerPatch(desired) }
|
|
1125
|
+
);
|
|
1126
|
+
if ([404, 405, 501].includes(r.status)) break;
|
|
1127
|
+
updated++;
|
|
1128
|
+
}
|
|
1129
|
+
return updated;
|
|
1081
1130
|
}
|
|
1082
1131
|
/** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
|
|
1083
1132
|
slugify(s) {
|
|
@@ -1100,11 +1149,13 @@ var HindsightClient = class {
|
|
|
1100
1149
|
let pageId = args.relatesToPageId;
|
|
1101
1150
|
if (!pageId) {
|
|
1102
1151
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1152
|
+
const subject = this.project ?? this.bank;
|
|
1103
1153
|
const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
|
|
1104
1154
|
name: args.title,
|
|
1105
|
-
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory
|
|
1155
|
+
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(subject),
|
|
1106
1156
|
parent_id: folderId,
|
|
1107
1157
|
tags: ["knowledge:feature-work"],
|
|
1158
|
+
max_tokens: PAGE_MAX_TOKENS,
|
|
1108
1159
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1109
1160
|
});
|
|
1110
1161
|
try {
|
|
@@ -1223,17 +1274,22 @@ var DEFAULT_SEED_LIMIT = 300;
|
|
|
1223
1274
|
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
|
|
1224
1275
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
1225
1276
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
1226
|
-
function
|
|
1227
|
-
if (raw.pageTriggerType === "manual") return "manual";
|
|
1228
|
-
if (raw.pageTriggerType === "
|
|
1229
|
-
|
|
1230
|
-
if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
|
|
1277
|
+
function resolvePageTrigger(raw) {
|
|
1278
|
+
if (raw.pageTriggerType === "manual") return { type: "manual" };
|
|
1279
|
+
if (raw.pageTriggerType === "auto-refresh") return { type: "auto-refresh" };
|
|
1280
|
+
if (raw.pageTriggerType !== void 0 && raw.pageTriggerType !== "cron")
|
|
1231
1281
|
log.warn(
|
|
1232
1282
|
"config",
|
|
1233
|
-
|
|
1283
|
+
`ignoring pageTriggerType=${JSON.stringify(raw.pageTriggerType)} \u2014 expected cron|auto-refresh|manual`
|
|
1234
1284
|
);
|
|
1235
|
-
|
|
1236
|
-
return "
|
|
1285
|
+
const cron = raw.pageTriggerCron?.trim();
|
|
1286
|
+
if (!cron) return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1287
|
+
if (!isHashedCron(cron) || parseHashedCron(cron)) return { type: "cron", cron };
|
|
1288
|
+
log.warn(
|
|
1289
|
+
"config",
|
|
1290
|
+
`pageTriggerCron ${JSON.stringify(cron)} has a malformed hashed field \u2014 write \`H\` or \`H(<lo>-<hi>)\` within the field's own range, e.g. "H H(0-5) * * *" \u2014 falling back to ${JSON.stringify(DEFAULT_PAGE_TRIGGER_CRON)}`
|
|
1291
|
+
);
|
|
1292
|
+
return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1237
1293
|
}
|
|
1238
1294
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
1239
1295
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
@@ -1265,6 +1321,7 @@ function resolveObservationScopes(raw) {
|
|
|
1265
1321
|
function resolveConfig(raw = {}) {
|
|
1266
1322
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
1267
1323
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
1324
|
+
const pageTrigger = resolvePageTrigger(raw);
|
|
1268
1325
|
return {
|
|
1269
1326
|
serverMode,
|
|
1270
1327
|
// Daemon mode resolves the URL HERE rather than at each call site: every entry point already
|
|
@@ -1299,8 +1356,8 @@ function resolveConfig(raw = {}) {
|
|
|
1299
1356
|
reflectBudget: resolveReflectBudget(raw),
|
|
1300
1357
|
autoReflect: raw.autoReflect ?? true,
|
|
1301
1358
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
1302
|
-
pageTriggerType:
|
|
1303
|
-
pageTriggerCron:
|
|
1359
|
+
pageTriggerType: pageTrigger.type,
|
|
1360
|
+
pageTriggerCron: pageTrigger.cron,
|
|
1304
1361
|
autoSeed: raw.autoSeed ?? true,
|
|
1305
1362
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
1306
1363
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -1631,11 +1688,31 @@ async function syncGitLog(client, repo, opts) {
|
|
|
1631
1688
|
}
|
|
1632
1689
|
|
|
1633
1690
|
// src/core/survey.ts
|
|
1634
|
-
import { spawn as
|
|
1691
|
+
import { spawn as realSpawn3 } from "child_process";
|
|
1692
|
+
import { createHash as createHash4 } from "crypto";
|
|
1635
1693
|
import { existsSync as existsSync2 } from "fs";
|
|
1636
|
-
import { homedir as homedir3 } from "os";
|
|
1637
|
-
import { dirname as dirname5, join as
|
|
1694
|
+
import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
|
|
1695
|
+
import { dirname as dirname5, join as join8 } from "path";
|
|
1638
1696
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1697
|
+
|
|
1698
|
+
// src/core/survey-lease.ts
|
|
1699
|
+
import { spawn as realSpawn2 } from "child_process";
|
|
1700
|
+
import { randomUUID } from "crypto";
|
|
1701
|
+
import {
|
|
1702
|
+
mkdirSync as mkdirSync2,
|
|
1703
|
+
mkdtempSync,
|
|
1704
|
+
readdirSync,
|
|
1705
|
+
renameSync,
|
|
1706
|
+
rmdirSync,
|
|
1707
|
+
rmSync,
|
|
1708
|
+
statSync,
|
|
1709
|
+
unlinkSync,
|
|
1710
|
+
utimesSync,
|
|
1711
|
+
writeFileSync
|
|
1712
|
+
} from "fs";
|
|
1713
|
+
import { join as join7 } from "path";
|
|
1714
|
+
|
|
1715
|
+
// src/core/survey.ts
|
|
1639
1716
|
var SURVEY_DOC_IDS = [
|
|
1640
1717
|
"repository-component-map",
|
|
1641
1718
|
"repository-core-concepts",
|
|
@@ -1691,7 +1768,10 @@ var HARNESS_NAMES = [
|
|
|
1691
1768
|
"qwen-code",
|
|
1692
1769
|
// Factory Droid is a per-prompt HOOK host: the installer wires ~/.factory/hooks.json and the
|
|
1693
1770
|
// stdio MCP registration in ~/.factory/mcp.json (see src/installer.ts).
|
|
1694
|
-
"factory-droid"
|
|
1771
|
+
"factory-droid",
|
|
1772
|
+
// ZCode is a per-prompt HOOK host too, registered in its own CLI config
|
|
1773
|
+
// (~/.zcode/cli/config.json) under `hooks.events` — never the user's real Claude Code settings.
|
|
1774
|
+
"zcode"
|
|
1695
1775
|
];
|
|
1696
1776
|
var HOOK_BINS = {
|
|
1697
1777
|
"claude-code": "hindsight-claude-hook",
|
|
@@ -1703,7 +1783,8 @@ var HOOK_BINS = {
|
|
|
1703
1783
|
"copilot-cli": "hindsight-copilot-hook",
|
|
1704
1784
|
"grok-build": "hindsight-grok-hook",
|
|
1705
1785
|
"qwen-code": "hindsight-qwen-hook",
|
|
1706
|
-
"factory-droid": "hindsight-droid-hook"
|
|
1786
|
+
"factory-droid": "hindsight-droid-hook",
|
|
1787
|
+
zcode: "hindsight-zcode-hook"
|
|
1707
1788
|
// more hook harnesses: add a HookSpec entry point (see src/cursor-hook.ts) + a registration here.
|
|
1708
1789
|
};
|
|
1709
1790
|
var PLUGIN_ENTRYPOINTS = {
|
|
@@ -1817,8 +1898,8 @@ var log2 = (m) => {
|
|
|
1817
1898
|
console.log(`${(/* @__PURE__ */ new Date()).toISOString()} ${m}`);
|
|
1818
1899
|
log.info("deepen", m);
|
|
1819
1900
|
};
|
|
1820
|
-
var LOCK_DIR =
|
|
1821
|
-
var LOCK =
|
|
1901
|
+
var LOCK_DIR = join9(tmpdir3(), "hindsight-coding-agent");
|
|
1902
|
+
var LOCK = join9(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
|
|
1822
1903
|
function acquireLock() {
|
|
1823
1904
|
try {
|
|
1824
1905
|
const held = JSON.parse(readFileSync4(LOCK, "utf8"));
|
|
@@ -1836,8 +1917,8 @@ function acquireLock() {
|
|
|
1836
1917
|
} catch {
|
|
1837
1918
|
}
|
|
1838
1919
|
try {
|
|
1839
|
-
|
|
1840
|
-
|
|
1920
|
+
mkdirSync3(LOCK_DIR, { recursive: true });
|
|
1921
|
+
writeFileSync2(LOCK, JSON.stringify({ pid: process.pid, ts: Date.now() }));
|
|
1841
1922
|
return true;
|
|
1842
1923
|
} catch {
|
|
1843
1924
|
return false;
|
|
@@ -1992,7 +2073,7 @@ async function main() {
|
|
|
1992
2073
|
);
|
|
1993
2074
|
} finally {
|
|
1994
2075
|
try {
|
|
1995
|
-
|
|
2076
|
+
unlinkSync2(LOCK);
|
|
1996
2077
|
} catch {
|
|
1997
2078
|
}
|
|
1998
2079
|
}
|
|
@@ -2004,7 +2085,7 @@ main().catch((e) => {
|
|
|
2004
2085
|
});
|
|
2005
2086
|
console.error("deepen failed:", e.message || e);
|
|
2006
2087
|
try {
|
|
2007
|
-
|
|
2088
|
+
unlinkSync2(LOCK);
|
|
2008
2089
|
} catch {
|
|
2009
2090
|
}
|
|
2010
2091
|
process.exit(1);
|