@vectorize-io/hindsight-coding-agents 0.7.0 → 0.8.1
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 +201 -16
- package/dist/antigravity-hook.js +1132 -115
- package/dist/antigravity-statusline.js +77 -11
- package/dist/antigravity-stop-hook.js +1193 -133
- package/dist/claude-hook.js +1132 -115
- package/dist/claude-sessionstart-hook.js +1241 -140
- package/dist/claude-stop-hook.js +1193 -133
- package/dist/cline.js +578 -163
- package/dist/codebuddy-hook.js +4270 -0
- package/dist/codebuddy-sessionstart-hook.js +5030 -0
- package/dist/codebuddy-stop-hook.js +4564 -0
- package/dist/codex-hook.js +1132 -115
- package/dist/codex-sessionstart-hook.js +1241 -140
- package/dist/codex-stop-hook.js +1193 -133
- package/dist/copilot-hook.js +1132 -115
- package/dist/copilot-sessionstart-hook.js +1241 -140
- package/dist/copilot-stop-hook.js +1193 -133
- package/dist/cursor-hook.js +1132 -115
- package/dist/cursor-sessionstart-hook.js +1241 -140
- package/dist/cursor-stop-hook.js +1193 -133
- package/dist/daemon-start.js +54 -9
- package/dist/dcode-hook.js +1132 -115
- package/dist/dcode-sessionstart-hook.js +1241 -140
- package/dist/dcode-stop-hook.js +1193 -133
- package/dist/deepen.js +370 -104
- package/dist/devin-hook.js +1132 -115
- package/dist/devin-sessionstart-hook.js +1241 -140
- package/dist/devin-stop-hook.js +1193 -133
- package/dist/droid-hook.js +1132 -115
- package/dist/droid-sessionstart-hook.js +1241 -140
- package/dist/droid-stop-hook.js +1193 -133
- package/dist/dsh.js +586 -164
- package/dist/grok-hook.js +1132 -115
- package/dist/grok-sessionstart-hook.js +1241 -140
- package/dist/grok-stop-hook.js +1193 -133
- package/dist/hindsight-seed.js +50 -8
- package/dist/index.js +587 -172
- package/dist/installer.js +2010 -769
- package/dist/kilo.js +587 -172
- package/dist/kimi-hook.js +4270 -0
- package/dist/kimi-sessionstart-hook.js +5030 -0
- package/dist/kimi-stop-hook.js +4564 -0
- package/dist/mcp-server.js +419 -115
- package/dist/opencode2.js +586 -169
- package/dist/pi.js +644 -175
- package/dist/prime-agent.js +644 -175
- package/dist/qwen-hook.js +1132 -115
- package/dist/qwen-sessionstart-hook.js +1241 -140
- package/dist/qwen-stop-hook.js +1193 -133
- package/dist/status.js +243 -52
- package/dist/traecode-hook.js +4270 -0
- package/dist/traecode-sessionstart-hook.js +5030 -0
- package/dist/traecode-stop-hook.js +4564 -0
- package/dist/workbuddy-hook.js +4270 -0
- package/dist/workbuddy-sessionstart-hook.js +5030 -0
- package/dist/workbuddy-stop-hook.js +4564 -0
- package/dist/zcode-hook.js +1132 -115
- package/dist/zcode-sessionstart-hook.js +1241 -140
- package/dist/zcode-stop-hook.js +1193 -133
- package/package.json +22 -12
- package/plugin.json +1 -1
- package/skill/SKILL.md +73 -14
package/dist/hindsight-seed.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/core/config.ts
|
|
4
|
-
import { readFileSync as
|
|
4
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
5
5
|
import { homedir as homedir3 } from "os";
|
|
6
6
|
import { join as join7 } from "path";
|
|
7
7
|
|
|
@@ -54,6 +54,7 @@ import { homedir as homedir2 } from "os";
|
|
|
54
54
|
import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
|
|
55
55
|
|
|
56
56
|
// src/core/diag.ts
|
|
57
|
+
import { readFileSync } from "fs";
|
|
57
58
|
import { join as join3 } from "path";
|
|
58
59
|
|
|
59
60
|
// src/core/log.ts
|
|
@@ -112,7 +113,7 @@ function diag(harness, event, extra = {}) {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
// src/core/git-layout.ts
|
|
115
|
-
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
116
|
+
import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
|
|
116
117
|
import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
|
|
117
118
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
118
119
|
var ATTEMPTS = 3;
|
|
@@ -136,7 +137,7 @@ function entryKind(path) {
|
|
|
136
137
|
}
|
|
137
138
|
function readTextOrNull(path) {
|
|
138
139
|
try {
|
|
139
|
-
return
|
|
140
|
+
return readFileSync2(path, "utf8");
|
|
140
141
|
} catch (error) {
|
|
141
142
|
if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
|
|
142
143
|
return null;
|
|
@@ -295,13 +296,13 @@ function isWithin(directory, configured) {
|
|
|
295
296
|
function mapLookup(map, directory) {
|
|
296
297
|
const cwd = normalize(directory);
|
|
297
298
|
let best;
|
|
298
|
-
for (const [dir,
|
|
299
|
+
for (const [dir, value] of Object.entries(map)) {
|
|
299
300
|
const p = configuredDir(dir);
|
|
300
301
|
if (isWithin(cwd, p)) {
|
|
301
|
-
if (!best || p.length > best.len) best = { len: p.length,
|
|
302
|
+
if (!best || p.length > best.len) best = { len: p.length, value };
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
|
-
return best?.
|
|
305
|
+
return best?.value;
|
|
305
306
|
}
|
|
306
307
|
function lookupDirectories(config, directory, sessionRoot = "") {
|
|
307
308
|
const directories = [normalize(directory)];
|
|
@@ -408,12 +409,21 @@ function parseHashedCron(cron) {
|
|
|
408
409
|
}
|
|
409
410
|
return fields;
|
|
410
411
|
}
|
|
412
|
+
var PLUGIN_GOVERNED_BANK_FIELDS = [
|
|
413
|
+
"retain_strategies",
|
|
414
|
+
"entity_labels",
|
|
415
|
+
"retain_extraction_mode"
|
|
416
|
+
];
|
|
417
|
+
|
|
418
|
+
// package.json
|
|
419
|
+
var version = "0.8.1";
|
|
411
420
|
|
|
412
421
|
// src/core/util.ts
|
|
413
422
|
import { accessSync, constants } from "fs";
|
|
414
423
|
import { delimiter, join as join6 } from "path";
|
|
415
424
|
|
|
416
425
|
// src/core/hindsight.ts
|
|
426
|
+
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
417
427
|
var DEFAULT_OBSERVATION_SCOPES = "shared";
|
|
418
428
|
var DEFAULT_PAGE_SEARCH_LIMIT = 10;
|
|
419
429
|
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
@@ -498,6 +508,7 @@ function resolveCustomPages(raw) {
|
|
|
498
508
|
}
|
|
499
509
|
var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
|
|
500
510
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
511
|
+
var DEFAULT_INJECT_TIMEOUT_MS = 7e3;
|
|
501
512
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
502
513
|
function resolveReflectBudget(raw) {
|
|
503
514
|
const value = raw.reflectBudget;
|
|
@@ -524,6 +535,22 @@ function resolveObservationScopes(raw) {
|
|
|
524
535
|
}
|
|
525
536
|
return DEFAULT_OBSERVATION_SCOPES;
|
|
526
537
|
}
|
|
538
|
+
function resolveDefaultBankConfig(raw) {
|
|
539
|
+
const value = raw;
|
|
540
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
541
|
+
const out = {};
|
|
542
|
+
for (const [key, v] of Object.entries(value)) {
|
|
543
|
+
if (PLUGIN_GOVERNED_BANK_FIELDS.includes(key)) {
|
|
544
|
+
log.warn(
|
|
545
|
+
"config",
|
|
546
|
+
`ignoring defaultBankConfig.${key} \u2014 the plugin manages this field itself` + (key === "retain_extraction_mode" ? " (set retainExtractionMode instead)" : "")
|
|
547
|
+
);
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
out[key] = v;
|
|
551
|
+
}
|
|
552
|
+
return out;
|
|
553
|
+
}
|
|
527
554
|
var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
|
|
528
555
|
function resolveAutoInject(raw) {
|
|
529
556
|
if (raw.autoReflect !== void 0) {
|
|
@@ -563,18 +590,21 @@ function resolveConfig(raw = {}) {
|
|
|
563
590
|
// write sessions back by default, every harness
|
|
564
591
|
manageBankConfig: raw.manageBankConfig ?? true,
|
|
565
592
|
retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
593
|
+
defaultBankConfig: resolveDefaultBankConfig(raw.defaultBankConfig),
|
|
566
594
|
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
567
595
|
reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
|
|
568
596
|
// Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
|
|
569
597
|
// reflect already set), but never let it LOWER the tool below the default — a short window is
|
|
570
598
|
// set to bound the automatic hook, not to cut off a call the agent is waiting on.
|
|
571
599
|
reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
|
|
600
|
+
injectTimeoutMs: raw.injectTimeoutMs || DEFAULT_INJECT_TIMEOUT_MS,
|
|
572
601
|
reflectBudget: resolveReflectBudget(raw),
|
|
573
602
|
autoInject: resolveAutoInject(raw),
|
|
574
603
|
pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
|
|
575
604
|
// Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
|
|
576
605
|
// keys and reach the API as garbage, so it is rejected like any other non-object.
|
|
577
606
|
recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
|
|
607
|
+
toolGuideExtra: typeof raw.toolGuideExtra === "string" && raw.toolGuideExtra.trim() ? raw.toolGuideExtra : void 0,
|
|
578
608
|
// Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
|
|
579
609
|
// at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
|
|
580
610
|
// 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
|
|
@@ -594,18 +624,22 @@ function resolveConfig(raw = {}) {
|
|
|
594
624
|
// Hostile input is a config typo, not an attack: keep only string entries so a stray number or
|
|
595
625
|
// nested object cannot reach the API as a tag and fail the whole retain.
|
|
596
626
|
retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
|
|
627
|
+
// Undefined, not "", when unset or blank: the retain call distinguishes "not configured" (use
|
|
628
|
+
// the built-in default) from a configured value, and an empty context would strip the default.
|
|
629
|
+
retainContext: typeof raw.retainContext === "string" && raw.retainContext.trim() !== "" ? raw.retainContext : void 0,
|
|
597
630
|
retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
|
|
598
631
|
Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
|
|
599
632
|
) : {},
|
|
600
633
|
observationScopes: resolveObservationScopes(raw.observationScopes),
|
|
601
634
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
635
|
+
paths: raw.paths && typeof raw.paths === "object" ? raw.paths : {},
|
|
602
636
|
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
|
|
603
637
|
autoUpdate: raw.autoUpdate ?? true
|
|
604
638
|
};
|
|
605
639
|
}
|
|
606
640
|
function readRaw(path) {
|
|
607
641
|
try {
|
|
608
|
-
return JSON.parse(
|
|
642
|
+
return JSON.parse(readFileSync3(path, "utf8"));
|
|
609
643
|
} catch (e) {
|
|
610
644
|
if (e?.code !== "ENOENT") {
|
|
611
645
|
console.error(`hindsight: ignoring invalid config at ${path}: ${e?.message || e}`);
|
|
@@ -615,7 +649,12 @@ function readRaw(path) {
|
|
|
615
649
|
}
|
|
616
650
|
function mergeRaw(a, b) {
|
|
617
651
|
const { harnesses: _drop, ...flat } = b;
|
|
618
|
-
return {
|
|
652
|
+
return {
|
|
653
|
+
...a,
|
|
654
|
+
...flat,
|
|
655
|
+
banks: { ...a.banks ?? {}, ...b.banks ?? {} },
|
|
656
|
+
paths: { ...a.paths ?? {}, ...b.paths ?? {} }
|
|
657
|
+
};
|
|
619
658
|
}
|
|
620
659
|
function applyLayer(raw, layer, harness) {
|
|
621
660
|
let out = mergeRaw(raw, layer);
|
|
@@ -646,9 +685,11 @@ var ENV_KEYS = {
|
|
|
646
685
|
maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
|
|
647
686
|
reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
|
|
648
687
|
reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
|
|
688
|
+
injectTimeoutMs: "HINDSIGHT_INJECT_TIMEOUT_MS",
|
|
649
689
|
reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
|
|
650
690
|
autoInject: "HINDSIGHT_AUTO_INJECT",
|
|
651
691
|
pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
|
|
692
|
+
toolGuideExtra: "HINDSIGHT_TOOL_GUIDE_EXTRA",
|
|
652
693
|
autoReflect: "HINDSIGHT_AUTO_REFLECT",
|
|
653
694
|
pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
|
|
654
695
|
pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
|
|
@@ -690,6 +731,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
|
690
731
|
"maxParallelRetains",
|
|
691
732
|
"reflectTimeoutMs",
|
|
692
733
|
"reflectToolTimeoutMs",
|
|
734
|
+
"injectTimeoutMs",
|
|
693
735
|
"pageSearchLimit",
|
|
694
736
|
"pageRefreshEveryTurns",
|
|
695
737
|
"seedLimit",
|