@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/cline.js
CHANGED
|
@@ -475,6 +475,7 @@ function pagesFor(project) {
|
|
|
475
475
|
var PAGE_MAX_TOKENS = 4096;
|
|
476
476
|
var PAGE_TAGS_MATCH = "all";
|
|
477
477
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
478
|
+
var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
|
|
478
479
|
var CRON_FIELD_RANGES = [
|
|
479
480
|
[0, 59],
|
|
480
481
|
// minute
|
|
@@ -528,14 +529,23 @@ function pageTriggerFor(trigger, bank, page) {
|
|
|
528
529
|
function buildPageTrigger(cfg = {}) {
|
|
529
530
|
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
530
531
|
switch (cfg.pageTriggerType) {
|
|
531
|
-
case "
|
|
532
|
-
return { ...base,
|
|
532
|
+
case "auto-refresh":
|
|
533
|
+
return { ...base, refresh_after_consolidation: true };
|
|
533
534
|
case "manual":
|
|
534
535
|
return { ...base, refresh_after_consolidation: false };
|
|
536
|
+
// "cron" and an unset type alike: the default schedule stands in for a missing expression, so
|
|
537
|
+
// a trigger built from a partial config is never a cron trigger with nothing to fire on.
|
|
535
538
|
default:
|
|
536
|
-
return { ...base,
|
|
539
|
+
return { ...base, refresh_cron: cfg.pageTriggerCron || DEFAULT_PAGE_TRIGGER_CRON };
|
|
537
540
|
}
|
|
538
541
|
}
|
|
542
|
+
function pageTriggerDrifted(current2, desired) {
|
|
543
|
+
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);
|
|
544
|
+
}
|
|
545
|
+
function pageTriggerPatch(desired) {
|
|
546
|
+
if (desired.refresh_after_consolidation === false) return { ...desired, refresh_cron: null };
|
|
547
|
+
return desired;
|
|
548
|
+
}
|
|
539
549
|
var CODING_BANK_TEMPLATE = {
|
|
540
550
|
version: "1",
|
|
541
551
|
bank: {
|
|
@@ -1094,14 +1104,14 @@ var HindsightClient = class {
|
|
|
1094
1104
|
if (r.status !== 409) created++;
|
|
1095
1105
|
} else {
|
|
1096
1106
|
const sourceDrift = hit.description !== page.source_query;
|
|
1097
|
-
const triggerDrift = hit.trigger != null && hit.trigger
|
|
1107
|
+
const triggerDrift = hit.trigger != null && pageTriggerDrifted(hit.trigger, body.trigger);
|
|
1098
1108
|
if (!sourceDrift && !triggerDrift) continue;
|
|
1099
1109
|
const patch = {};
|
|
1100
1110
|
if (sourceDrift) {
|
|
1101
1111
|
patch.source_query = page.source_query;
|
|
1102
1112
|
patch.tags = page.tags;
|
|
1103
1113
|
}
|
|
1104
|
-
if (triggerDrift) patch.trigger =
|
|
1114
|
+
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1105
1115
|
const r = await this.req(
|
|
1106
1116
|
"PATCH",
|
|
1107
1117
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1117,10 +1127,42 @@ var HindsightClient = class {
|
|
|
1117
1127
|
updated++;
|
|
1118
1128
|
}
|
|
1119
1129
|
}
|
|
1130
|
+
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1120
1131
|
this.log(
|
|
1121
|
-
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
|
|
1132
|
+
`[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` : "")
|
|
1122
1133
|
);
|
|
1123
1134
|
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Bring the captured initiative pages onto the same refresh policy as the seeded taxonomy.
|
|
1137
|
+
*
|
|
1138
|
+
* `captureInitiative` stamps this very trigger when it creates a page, so on a bank seeded under
|
|
1139
|
+
* an older default they are the same drift as the taxonomy — and on a real repo they are most of
|
|
1140
|
+
* it: five taxonomy pages against one page per initiative, each an LLM synthesis per
|
|
1141
|
+
* consolidation under the auto-refresh that used to be the default (#3506).
|
|
1142
|
+
*
|
|
1143
|
+
* Only the trigger is touched. Their `name` and `source_query` are written once, from the
|
|
1144
|
+
* initiative's own title, and re-stating either would rebuild a page whose question never
|
|
1145
|
+
* changed. The tree read above is reused rather than re-fetched.
|
|
1146
|
+
*/
|
|
1147
|
+
async resyncInitiativeTriggers(roots, pageTrigger) {
|
|
1148
|
+
const folder = roots.find(
|
|
1149
|
+
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === "initiatives"
|
|
1150
|
+
);
|
|
1151
|
+
let updated = 0;
|
|
1152
|
+
for (const page of folder?.children ?? []) {
|
|
1153
|
+
if (page.kind !== "page" || page.trigger == null) continue;
|
|
1154
|
+
const desired = pageTriggerFor(pageTrigger, this.bank, page.name);
|
|
1155
|
+
if (!pageTriggerDrifted(page.trigger, desired)) continue;
|
|
1156
|
+
const r = await this.req(
|
|
1157
|
+
"PATCH",
|
|
1158
|
+
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1159
|
+
{ trigger: pageTriggerPatch(desired) }
|
|
1160
|
+
);
|
|
1161
|
+
if ([404, 405, 501].includes(r.status)) break;
|
|
1162
|
+
updated++;
|
|
1163
|
+
}
|
|
1164
|
+
return updated;
|
|
1165
|
+
}
|
|
1124
1166
|
/** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
|
|
1125
1167
|
slugify(s) {
|
|
1126
1168
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
@@ -1142,11 +1184,13 @@ var HindsightClient = class {
|
|
|
1142
1184
|
let pageId = args.relatesToPageId;
|
|
1143
1185
|
if (!pageId) {
|
|
1144
1186
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1187
|
+
const subject = this.project ?? this.bank;
|
|
1145
1188
|
const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
|
|
1146
1189
|
name: args.title,
|
|
1147
|
-
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
|
|
1190
|
+
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),
|
|
1148
1191
|
parent_id: folderId,
|
|
1149
1192
|
tags: ["knowledge:feature-work"],
|
|
1193
|
+
max_tokens: PAGE_MAX_TOKENS,
|
|
1150
1194
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1151
1195
|
});
|
|
1152
1196
|
try {
|
|
@@ -1189,17 +1233,22 @@ var HindsightClient = class {
|
|
|
1189
1233
|
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
|
|
1190
1234
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
1191
1235
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
1192
|
-
function
|
|
1193
|
-
if (raw.pageTriggerType === "manual") return "manual";
|
|
1194
|
-
if (raw.pageTriggerType === "
|
|
1195
|
-
|
|
1196
|
-
if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
|
|
1236
|
+
function resolvePageTrigger(raw) {
|
|
1237
|
+
if (raw.pageTriggerType === "manual") return { type: "manual" };
|
|
1238
|
+
if (raw.pageTriggerType === "auto-refresh") return { type: "auto-refresh" };
|
|
1239
|
+
if (raw.pageTriggerType !== void 0 && raw.pageTriggerType !== "cron")
|
|
1197
1240
|
log.warn(
|
|
1198
1241
|
"config",
|
|
1199
|
-
|
|
1242
|
+
`ignoring pageTriggerType=${JSON.stringify(raw.pageTriggerType)} \u2014 expected cron|auto-refresh|manual`
|
|
1200
1243
|
);
|
|
1201
|
-
|
|
1202
|
-
return "
|
|
1244
|
+
const cron = raw.pageTriggerCron?.trim();
|
|
1245
|
+
if (!cron) return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1246
|
+
if (!isHashedCron(cron) || parseHashedCron(cron)) return { type: "cron", cron };
|
|
1247
|
+
log.warn(
|
|
1248
|
+
"config",
|
|
1249
|
+
`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)}`
|
|
1250
|
+
);
|
|
1251
|
+
return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
1203
1252
|
}
|
|
1204
1253
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
1205
1254
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
@@ -1231,6 +1280,7 @@ function resolveObservationScopes(raw) {
|
|
|
1231
1280
|
function resolveConfig(raw = {}) {
|
|
1232
1281
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
1233
1282
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
1283
|
+
const pageTrigger = resolvePageTrigger(raw);
|
|
1234
1284
|
return {
|
|
1235
1285
|
serverMode,
|
|
1236
1286
|
// Daemon mode resolves the URL HERE rather than at each call site: every entry point already
|
|
@@ -1265,8 +1315,8 @@ function resolveConfig(raw = {}) {
|
|
|
1265
1315
|
reflectBudget: resolveReflectBudget(raw),
|
|
1266
1316
|
autoReflect: raw.autoReflect ?? true,
|
|
1267
1317
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
1268
|
-
pageTriggerType:
|
|
1269
|
-
pageTriggerCron:
|
|
1318
|
+
pageTriggerType: pageTrigger.type,
|
|
1319
|
+
pageTriggerCron: pageTrigger.cron,
|
|
1270
1320
|
autoSeed: raw.autoSeed ?? true,
|
|
1271
1321
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
1272
1322
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -17254,7 +17304,7 @@ async function buildSessionStartContext(args) {
|
|
|
17254
17304
|
}
|
|
17255
17305
|
|
|
17256
17306
|
// src/core/hook.ts
|
|
17257
|
-
import { existsSync as existsSync6, readFileSync as
|
|
17307
|
+
import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
|
|
17258
17308
|
|
|
17259
17309
|
// src/core/inject.ts
|
|
17260
17310
|
function buildReflectQuery(prompt) {
|
|
@@ -17285,6 +17335,12 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
|
|
|
17285
17335
|
` + memory + "\n</hindsight_memory>";
|
|
17286
17336
|
}
|
|
17287
17337
|
|
|
17338
|
+
// src/core/turn-journal.ts
|
|
17339
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync7, statSync } from "fs";
|
|
17340
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
17341
|
+
import { dirname as dirname10, join as join13 } from "path";
|
|
17342
|
+
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
17343
|
+
|
|
17288
17344
|
// src/core/hook.ts
|
|
17289
17345
|
var HOOK_REFLECT_CAP_MS = 25e3;
|
|
17290
17346
|
async function buildHookOutput(args) {
|