@vectorize-io/hindsight-coding-agents 0.5.2 → 0.5.3
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 +286 -76
- package/dist/antigravity-statusline.js +17 -10
- package/dist/antigravity-stop-hook.js +297 -79
- package/dist/claude-hook.js +286 -76
- package/dist/claude-sessionstart-hook.js +252 -93
- package/dist/claude-stop-hook.js +297 -79
- package/dist/cline.js +74 -18
- package/dist/codex-hook.js +286 -76
- package/dist/codex-sessionstart-hook.js +252 -93
- package/dist/codex-stop-hook.js +297 -79
- package/dist/copilot-hook.js +286 -76
- package/dist/copilot-sessionstart-hook.js +252 -93
- package/dist/copilot-stop-hook.js +297 -79
- package/dist/cursor-hook.js +286 -76
- package/dist/cursor-sessionstart-hook.js +252 -93
- package/dist/cursor-stop-hook.js +297 -79
- package/dist/daemon-start.js +17 -10
- package/dist/dcode-hook.js +286 -76
- package/dist/dcode-sessionstart-hook.js +252 -93
- package/dist/dcode-stop-hook.js +297 -79
- package/dist/deepen.js +73 -19
- package/dist/devin-hook.js +286 -76
- package/dist/devin-sessionstart-hook.js +252 -93
- package/dist/devin-stop-hook.js +297 -79
- package/dist/droid-hook.js +286 -76
- package/dist/droid-sessionstart-hook.js +252 -93
- package/dist/droid-stop-hook.js +297 -79
- package/dist/dsh.js +111 -53
- package/dist/grok-hook.js +286 -76
- package/dist/grok-sessionstart-hook.js +252 -93
- package/dist/grok-stop-hook.js +297 -79
- package/dist/hindsight-seed.js +17 -10
- package/dist/index.js +113 -55
- package/dist/installer.js +383 -218
- package/dist/kilo.js +113 -55
- package/dist/mcp-server.js +67 -17
- package/dist/opencode2.js +113 -55
- package/dist/pi.js +112 -54
- package/dist/prime-agent.js +112 -54
- package/dist/qwen-hook.js +286 -76
- package/dist/qwen-sessionstart-hook.js +252 -93
- package/dist/qwen-stop-hook.js +297 -79
- package/dist/status.js +67 -17
- package/dist/zcode-hook.js +2920 -0
- package/dist/zcode-sessionstart-hook.js +3487 -0
- package/dist/zcode-stop-hook.js +3188 -0
- package/package.json +6 -3
- package/plugin.json +1 -1
- package/skill/SKILL.md +17 -7
package/dist/index.js
CHANGED
|
@@ -478,6 +478,7 @@ function pagesFor(project) {
|
|
|
478
478
|
var PAGE_MAX_TOKENS = 4096;
|
|
479
479
|
var PAGE_TAGS_MATCH = "all";
|
|
480
480
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
481
|
+
var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
|
|
481
482
|
var CRON_FIELD_RANGES = [
|
|
482
483
|
[0, 59],
|
|
483
484
|
// minute
|
|
@@ -531,14 +532,23 @@ function pageTriggerFor(trigger, bank, page) {
|
|
|
531
532
|
function buildPageTrigger(cfg = {}) {
|
|
532
533
|
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
533
534
|
switch (cfg.pageTriggerType) {
|
|
534
|
-
case "
|
|
535
|
-
return { ...base,
|
|
535
|
+
case "auto-refresh":
|
|
536
|
+
return { ...base, refresh_after_consolidation: true };
|
|
536
537
|
case "manual":
|
|
537
538
|
return { ...base, refresh_after_consolidation: false };
|
|
539
|
+
// "cron" and an unset type alike: the default schedule stands in for a missing expression, so
|
|
540
|
+
// a trigger built from a partial config is never a cron trigger with nothing to fire on.
|
|
538
541
|
default:
|
|
539
|
-
return { ...base,
|
|
542
|
+
return { ...base, refresh_cron: cfg.pageTriggerCron || DEFAULT_PAGE_TRIGGER_CRON };
|
|
540
543
|
}
|
|
541
544
|
}
|
|
545
|
+
function pageTriggerDrifted(current2, desired) {
|
|
546
|
+
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);
|
|
547
|
+
}
|
|
548
|
+
function pageTriggerPatch(desired) {
|
|
549
|
+
if (desired.refresh_after_consolidation === false) return { ...desired, refresh_cron: null };
|
|
550
|
+
return desired;
|
|
551
|
+
}
|
|
542
552
|
var CODING_BANK_TEMPLATE = {
|
|
543
553
|
version: "1",
|
|
544
554
|
bank: {
|
|
@@ -1097,14 +1107,14 @@ var HindsightClient = class {
|
|
|
1097
1107
|
if (r.status !== 409) created++;
|
|
1098
1108
|
} else {
|
|
1099
1109
|
const sourceDrift = hit.description !== page.source_query;
|
|
1100
|
-
const triggerDrift = hit.trigger != null && hit.trigger
|
|
1110
|
+
const triggerDrift = hit.trigger != null && pageTriggerDrifted(hit.trigger, body.trigger);
|
|
1101
1111
|
if (!sourceDrift && !triggerDrift) continue;
|
|
1102
1112
|
const patch = {};
|
|
1103
1113
|
if (sourceDrift) {
|
|
1104
1114
|
patch.source_query = page.source_query;
|
|
1105
1115
|
patch.tags = page.tags;
|
|
1106
1116
|
}
|
|
1107
|
-
if (triggerDrift) patch.trigger =
|
|
1117
|
+
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1108
1118
|
const r = await this.req(
|
|
1109
1119
|
"PATCH",
|
|
1110
1120
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1120,10 +1130,42 @@ var HindsightClient = class {
|
|
|
1120
1130
|
updated++;
|
|
1121
1131
|
}
|
|
1122
1132
|
}
|
|
1133
|
+
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1123
1134
|
this.log(
|
|
1124
|
-
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
|
|
1135
|
+
`[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` : "")
|
|
1125
1136
|
);
|
|
1126
1137
|
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Bring the captured initiative pages onto the same refresh policy as the seeded taxonomy.
|
|
1140
|
+
*
|
|
1141
|
+
* `captureInitiative` stamps this very trigger when it creates a page, so on a bank seeded under
|
|
1142
|
+
* an older default they are the same drift as the taxonomy — and on a real repo they are most of
|
|
1143
|
+
* it: five taxonomy pages against one page per initiative, each an LLM synthesis per
|
|
1144
|
+
* consolidation under the auto-refresh that used to be the default (#3506).
|
|
1145
|
+
*
|
|
1146
|
+
* Only the trigger is touched. Their `name` and `source_query` are written once, from the
|
|
1147
|
+
* initiative's own title, and re-stating either would rebuild a page whose question never
|
|
1148
|
+
* changed. The tree read above is reused rather than re-fetched.
|
|
1149
|
+
*/
|
|
1150
|
+
async resyncInitiativeTriggers(roots, pageTrigger) {
|
|
1151
|
+
const folder = roots.find(
|
|
1152
|
+
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === "initiatives"
|
|
1153
|
+
);
|
|
1154
|
+
let updated = 0;
|
|
1155
|
+
for (const page of folder?.children ?? []) {
|
|
1156
|
+
if (page.kind !== "page" || page.trigger == null) continue;
|
|
1157
|
+
const desired = pageTriggerFor(pageTrigger, this.bank, page.name);
|
|
1158
|
+
if (!pageTriggerDrifted(page.trigger, desired)) continue;
|
|
1159
|
+
const r = await this.req(
|
|
1160
|
+
"PATCH",
|
|
1161
|
+
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1162
|
+
{ trigger: pageTriggerPatch(desired) }
|
|
1163
|
+
);
|
|
1164
|
+
if ([404, 405, 501].includes(r.status)) break;
|
|
1165
|
+
updated++;
|
|
1166
|
+
}
|
|
1167
|
+
return updated;
|
|
1168
|
+
}
|
|
1127
1169
|
/** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
|
|
1128
1170
|
slugify(s) {
|
|
1129
1171
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
@@ -1145,11 +1187,13 @@ var HindsightClient = class {
|
|
|
1145
1187
|
let pageId = args.relatesToPageId;
|
|
1146
1188
|
if (!pageId) {
|
|
1147
1189
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1190
|
+
const subject = this.project ?? this.bank;
|
|
1148
1191
|
const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
|
|
1149
1192
|
name: args.title,
|
|
1150
|
-
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
|
|
1193
|
+
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),
|
|
1151
1194
|
parent_id: folderId,
|
|
1152
1195
|
tags: ["knowledge:feature-work"],
|
|
1196
|
+
max_tokens: PAGE_MAX_TOKENS,
|
|
1153
1197
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1154
1198
|
});
|
|
1155
1199
|
try {
|
|
@@ -1192,17 +1236,22 @@ var HindsightClient = class {
|
|
|
1192
1236
|
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
|
|
1193
1237
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
1194
1238
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
1195
|
-
function
|
|
1196
|
-
if (raw.pageTriggerType === "manual") return "manual";
|
|
1197
|
-
if (raw.pageTriggerType === "
|
|
1198
|
-
|
|
1199
|
-
if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
|
|
1239
|
+
function resolvePageTrigger(raw) {
|
|
1240
|
+
if (raw.pageTriggerType === "manual") return { type: "manual" };
|
|
1241
|
+
if (raw.pageTriggerType === "auto-refresh") return { type: "auto-refresh" };
|
|
1242
|
+
if (raw.pageTriggerType !== void 0 && raw.pageTriggerType !== "cron")
|
|
1200
1243
|
log.warn(
|
|
1201
1244
|
"config",
|
|
1202
|
-
|
|
1245
|
+
`ignoring pageTriggerType=${JSON.stringify(raw.pageTriggerType)} \u2014 expected cron|auto-refresh|manual`
|
|
1203
1246
|
);
|
|
1204
|
-
|
|
1205
|
-
return "
|
|
1247
|
+
const cron = raw.pageTriggerCron?.trim();
|
|
1248
|
+
if (!cron) return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1249
|
+
if (!isHashedCron(cron) || parseHashedCron(cron)) return { type: "cron", cron };
|
|
1250
|
+
log.warn(
|
|
1251
|
+
"config",
|
|
1252
|
+
`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)}`
|
|
1253
|
+
);
|
|
1254
|
+
return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1206
1255
|
}
|
|
1207
1256
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
1208
1257
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
@@ -1234,6 +1283,7 @@ function resolveObservationScopes(raw) {
|
|
|
1234
1283
|
function resolveConfig(raw = {}) {
|
|
1235
1284
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
1236
1285
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
1286
|
+
const pageTrigger = resolvePageTrigger(raw);
|
|
1237
1287
|
return {
|
|
1238
1288
|
serverMode,
|
|
1239
1289
|
// Daemon mode resolves the URL HERE rather than at each call site: every entry point already
|
|
@@ -1268,8 +1318,8 @@ function resolveConfig(raw = {}) {
|
|
|
1268
1318
|
reflectBudget: resolveReflectBudget(raw),
|
|
1269
1319
|
autoReflect: raw.autoReflect ?? true,
|
|
1270
1320
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
1271
|
-
pageTriggerType:
|
|
1272
|
-
pageTriggerCron:
|
|
1321
|
+
pageTriggerType: pageTrigger.type,
|
|
1322
|
+
pageTriggerCron: pageTrigger.cron,
|
|
1273
1323
|
autoSeed: raw.autoSeed ?? true,
|
|
1274
1324
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
1275
1325
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -17268,7 +17318,7 @@ async function buildSessionStartContext(args) {
|
|
|
17268
17318
|
}
|
|
17269
17319
|
|
|
17270
17320
|
// src/core/hook.ts
|
|
17271
|
-
import { existsSync as existsSync6, readFileSync as
|
|
17321
|
+
import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
|
|
17272
17322
|
|
|
17273
17323
|
// src/core/inject.ts
|
|
17274
17324
|
function buildReflectQuery(prompt) {
|
|
@@ -17299,6 +17349,49 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
|
|
|
17299
17349
|
` + memory + "\n</hindsight_memory>";
|
|
17300
17350
|
}
|
|
17301
17351
|
|
|
17352
|
+
// src/core/turn-journal.ts
|
|
17353
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync7, statSync } from "fs";
|
|
17354
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
17355
|
+
import { dirname as dirname10, join as join13 } from "path";
|
|
17356
|
+
|
|
17357
|
+
// src/core/transcript-util.ts
|
|
17358
|
+
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
17359
|
+
function stripInjectedMemory(s) {
|
|
17360
|
+
return s.replace(MEMORY_TAG_RE, "");
|
|
17361
|
+
}
|
|
17362
|
+
var TARGET_KEYS = [
|
|
17363
|
+
"file_path",
|
|
17364
|
+
"path",
|
|
17365
|
+
"notebook_path",
|
|
17366
|
+
"command",
|
|
17367
|
+
"pattern",
|
|
17368
|
+
"query",
|
|
17369
|
+
"url",
|
|
17370
|
+
"name",
|
|
17371
|
+
"id"
|
|
17372
|
+
];
|
|
17373
|
+
var ACTION_TARGET_CAP = 100;
|
|
17374
|
+
function actionLine(tool2, input) {
|
|
17375
|
+
let target = "";
|
|
17376
|
+
if (input && typeof input === "object") {
|
|
17377
|
+
const rec = input;
|
|
17378
|
+
for (const k of TARGET_KEYS) {
|
|
17379
|
+
const v = rec[k];
|
|
17380
|
+
if (typeof v === "string" && v.trim()) {
|
|
17381
|
+
target = v.trim().split("\n")[0];
|
|
17382
|
+
break;
|
|
17383
|
+
}
|
|
17384
|
+
}
|
|
17385
|
+
} else if (typeof input === "string") {
|
|
17386
|
+
target = input.trim().split("\n")[0];
|
|
17387
|
+
}
|
|
17388
|
+
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
17389
|
+
return target ? `${tool2} ${target}` : tool2;
|
|
17390
|
+
}
|
|
17391
|
+
|
|
17392
|
+
// src/core/turn-journal.ts
|
|
17393
|
+
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
17394
|
+
|
|
17302
17395
|
// src/core/hook.ts
|
|
17303
17396
|
var HOOK_REFLECT_CAP_MS = 25e3;
|
|
17304
17397
|
async function buildHookOutput(args) {
|
|
@@ -17608,41 +17701,6 @@ var RuntimeCore = class {
|
|
|
17608
17701
|
}
|
|
17609
17702
|
};
|
|
17610
17703
|
|
|
17611
|
-
// src/core/transcript-util.ts
|
|
17612
|
-
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
17613
|
-
function stripInjectedMemory(s) {
|
|
17614
|
-
return s.replace(MEMORY_TAG_RE, "");
|
|
17615
|
-
}
|
|
17616
|
-
var TARGET_KEYS = [
|
|
17617
|
-
"file_path",
|
|
17618
|
-
"path",
|
|
17619
|
-
"notebook_path",
|
|
17620
|
-
"command",
|
|
17621
|
-
"pattern",
|
|
17622
|
-
"query",
|
|
17623
|
-
"url",
|
|
17624
|
-
"name",
|
|
17625
|
-
"id"
|
|
17626
|
-
];
|
|
17627
|
-
var ACTION_TARGET_CAP = 100;
|
|
17628
|
-
function actionLine(tool2, input) {
|
|
17629
|
-
let target = "";
|
|
17630
|
-
if (input && typeof input === "object") {
|
|
17631
|
-
const rec = input;
|
|
17632
|
-
for (const k of TARGET_KEYS) {
|
|
17633
|
-
const v = rec[k];
|
|
17634
|
-
if (typeof v === "string" && v.trim()) {
|
|
17635
|
-
target = v.trim().split("\n")[0];
|
|
17636
|
-
break;
|
|
17637
|
-
}
|
|
17638
|
-
}
|
|
17639
|
-
} else if (typeof input === "string") {
|
|
17640
|
-
target = input.trim().split("\n")[0];
|
|
17641
|
-
}
|
|
17642
|
-
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
17643
|
-
return target ? `${tool2} ${target}` : tool2;
|
|
17644
|
-
}
|
|
17645
|
-
|
|
17646
17704
|
// src/core/transcript-opencode.ts
|
|
17647
17705
|
function renderMessage(m) {
|
|
17648
17706
|
const role = m.info?.role;
|
|
@@ -30096,12 +30154,12 @@ function tool(input) {
|
|
|
30096
30154
|
tool.schema = external_exports2;
|
|
30097
30155
|
|
|
30098
30156
|
// src/harness/registry.ts
|
|
30099
|
-
import { readFileSync as
|
|
30157
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
30100
30158
|
var jsonChatReader = (harness) => ({
|
|
30101
30159
|
describe: `${harness} sessions via a normalized JSON export (--conversations file: [{ id, turns:[{role,text,timestamp?}] }])`,
|
|
30102
30160
|
async read(opts) {
|
|
30103
30161
|
if (!opts.conversations) return [];
|
|
30104
|
-
return JSON.parse(
|
|
30162
|
+
return JSON.parse(readFileSync9(opts.conversations, "utf8"));
|
|
30105
30163
|
}
|
|
30106
30164
|
});
|
|
30107
30165
|
|