@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
|
@@ -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
|
|
|
@@ -17,6 +17,7 @@ import { homedir as homedir2 } from "os";
|
|
|
17
17
|
import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
|
|
18
18
|
|
|
19
19
|
// src/core/diag.ts
|
|
20
|
+
import { readFileSync } from "fs";
|
|
20
21
|
import { join as join3 } from "path";
|
|
21
22
|
|
|
22
23
|
// src/core/log.ts
|
|
@@ -75,7 +76,7 @@ function diag(harness, event, extra = {}) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
// src/core/git-layout.ts
|
|
78
|
-
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
79
|
+
import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
|
|
79
80
|
import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
|
|
80
81
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
81
82
|
var ATTEMPTS = 3;
|
|
@@ -99,7 +100,7 @@ function entryKind(path) {
|
|
|
99
100
|
}
|
|
100
101
|
function readTextOrNull(path) {
|
|
101
102
|
try {
|
|
102
|
-
return
|
|
103
|
+
return readFileSync2(path, "utf8");
|
|
103
104
|
} catch (error) {
|
|
104
105
|
if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
|
|
105
106
|
return null;
|
|
@@ -258,13 +259,13 @@ function isWithin(directory, configured) {
|
|
|
258
259
|
function mapLookup(map, directory) {
|
|
259
260
|
const cwd = normalize(directory);
|
|
260
261
|
let best;
|
|
261
|
-
for (const [dir,
|
|
262
|
+
for (const [dir, value] of Object.entries(map)) {
|
|
262
263
|
const p = configuredDir(dir);
|
|
263
264
|
if (isWithin(cwd, p)) {
|
|
264
|
-
if (!best || p.length > best.len) best = { len: p.length,
|
|
265
|
+
if (!best || p.length > best.len) best = { len: p.length, value };
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
|
-
return best?.
|
|
268
|
+
return best?.value;
|
|
268
269
|
}
|
|
269
270
|
function lookupDirectories(config, directory, sessionRoot = "") {
|
|
270
271
|
const directories = [normalize(directory)];
|
|
@@ -288,6 +289,10 @@ function isOptedIn(config, directory) {
|
|
|
288
289
|
const pathMap = config.mapPathToBank;
|
|
289
290
|
return Boolean(pathMap && directories.some((candidate) => mapLookup(pathMap, candidate)));
|
|
290
291
|
}
|
|
292
|
+
function pathSection(config, paths, directory) {
|
|
293
|
+
if (!directory || !paths) return void 0;
|
|
294
|
+
return lookupDirectories(config, directory).map((candidate) => mapLookup(paths, candidate)).find((section) => section !== void 0);
|
|
295
|
+
}
|
|
291
296
|
function mappedBank(config, directory, sessionRoot) {
|
|
292
297
|
const pathMap = config.mapPathToBank;
|
|
293
298
|
if (!directory || !pathMap) return void 0;
|
|
@@ -384,12 +389,21 @@ function parseHashedCron(cron) {
|
|
|
384
389
|
}
|
|
385
390
|
return fields;
|
|
386
391
|
}
|
|
392
|
+
var PLUGIN_GOVERNED_BANK_FIELDS = [
|
|
393
|
+
"retain_strategies",
|
|
394
|
+
"entity_labels",
|
|
395
|
+
"retain_extraction_mode"
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
// package.json
|
|
399
|
+
var version = "0.8.1";
|
|
387
400
|
|
|
388
401
|
// src/core/util.ts
|
|
389
402
|
import { accessSync, constants } from "fs";
|
|
390
403
|
import { delimiter, join as join6 } from "path";
|
|
391
404
|
|
|
392
405
|
// src/core/hindsight.ts
|
|
406
|
+
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
393
407
|
var DEFAULT_OBSERVATION_SCOPES = "shared";
|
|
394
408
|
var DEFAULT_PAGE_SEARCH_LIMIT = 10;
|
|
395
409
|
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
@@ -474,6 +488,7 @@ function resolveCustomPages(raw) {
|
|
|
474
488
|
}
|
|
475
489
|
var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
|
|
476
490
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
491
|
+
var DEFAULT_INJECT_TIMEOUT_MS = 7e3;
|
|
477
492
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
478
493
|
function resolveReflectBudget(raw) {
|
|
479
494
|
const value = raw.reflectBudget;
|
|
@@ -500,6 +515,22 @@ function resolveObservationScopes(raw) {
|
|
|
500
515
|
}
|
|
501
516
|
return DEFAULT_OBSERVATION_SCOPES;
|
|
502
517
|
}
|
|
518
|
+
function resolveDefaultBankConfig(raw) {
|
|
519
|
+
const value = raw;
|
|
520
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
521
|
+
const out = {};
|
|
522
|
+
for (const [key, v] of Object.entries(value)) {
|
|
523
|
+
if (PLUGIN_GOVERNED_BANK_FIELDS.includes(key)) {
|
|
524
|
+
log.warn(
|
|
525
|
+
"config",
|
|
526
|
+
`ignoring defaultBankConfig.${key} \u2014 the plugin manages this field itself` + (key === "retain_extraction_mode" ? " (set retainExtractionMode instead)" : "")
|
|
527
|
+
);
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
out[key] = v;
|
|
531
|
+
}
|
|
532
|
+
return out;
|
|
533
|
+
}
|
|
503
534
|
var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
|
|
504
535
|
function resolveAutoInject(raw) {
|
|
505
536
|
if (raw.autoReflect !== void 0) {
|
|
@@ -539,18 +570,21 @@ function resolveConfig(raw = {}) {
|
|
|
539
570
|
// write sessions back by default, every harness
|
|
540
571
|
manageBankConfig: raw.manageBankConfig ?? true,
|
|
541
572
|
retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
573
|
+
defaultBankConfig: resolveDefaultBankConfig(raw.defaultBankConfig),
|
|
542
574
|
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
543
575
|
reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
|
|
544
576
|
// Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
|
|
545
577
|
// reflect already set), but never let it LOWER the tool below the default — a short window is
|
|
546
578
|
// set to bound the automatic hook, not to cut off a call the agent is waiting on.
|
|
547
579
|
reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
|
|
580
|
+
injectTimeoutMs: raw.injectTimeoutMs || DEFAULT_INJECT_TIMEOUT_MS,
|
|
548
581
|
reflectBudget: resolveReflectBudget(raw),
|
|
549
582
|
autoInject: resolveAutoInject(raw),
|
|
550
583
|
pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
|
|
551
584
|
// Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
|
|
552
585
|
// keys and reach the API as garbage, so it is rejected like any other non-object.
|
|
553
586
|
recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
|
|
587
|
+
toolGuideExtra: typeof raw.toolGuideExtra === "string" && raw.toolGuideExtra.trim() ? raw.toolGuideExtra : void 0,
|
|
554
588
|
// Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
|
|
555
589
|
// at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
|
|
556
590
|
// 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
|
|
@@ -570,18 +604,22 @@ function resolveConfig(raw = {}) {
|
|
|
570
604
|
// Hostile input is a config typo, not an attack: keep only string entries so a stray number or
|
|
571
605
|
// nested object cannot reach the API as a tag and fail the whole retain.
|
|
572
606
|
retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
|
|
607
|
+
// Undefined, not "", when unset or blank: the retain call distinguishes "not configured" (use
|
|
608
|
+
// the built-in default) from a configured value, and an empty context would strip the default.
|
|
609
|
+
retainContext: typeof raw.retainContext === "string" && raw.retainContext.trim() !== "" ? raw.retainContext : void 0,
|
|
573
610
|
retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
|
|
574
611
|
Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
|
|
575
612
|
) : {},
|
|
576
613
|
observationScopes: resolveObservationScopes(raw.observationScopes),
|
|
577
614
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
615
|
+
paths: raw.paths && typeof raw.paths === "object" ? raw.paths : {},
|
|
578
616
|
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
|
|
579
617
|
autoUpdate: raw.autoUpdate ?? true
|
|
580
618
|
};
|
|
581
619
|
}
|
|
582
620
|
function readRaw(path) {
|
|
583
621
|
try {
|
|
584
|
-
return JSON.parse(
|
|
622
|
+
return JSON.parse(readFileSync3(path, "utf8"));
|
|
585
623
|
} catch (e) {
|
|
586
624
|
if (e?.code !== "ENOENT") {
|
|
587
625
|
console.error(`hindsight: ignoring invalid config at ${path}: ${e?.message || e}`);
|
|
@@ -591,7 +629,12 @@ function readRaw(path) {
|
|
|
591
629
|
}
|
|
592
630
|
function mergeRaw(a, b) {
|
|
593
631
|
const { harnesses: _drop, ...flat } = b;
|
|
594
|
-
return {
|
|
632
|
+
return {
|
|
633
|
+
...a,
|
|
634
|
+
...flat,
|
|
635
|
+
banks: { ...a.banks ?? {}, ...b.banks ?? {} },
|
|
636
|
+
paths: { ...a.paths ?? {}, ...b.paths ?? {} }
|
|
637
|
+
};
|
|
595
638
|
}
|
|
596
639
|
function applyLayer(raw, layer, harness) {
|
|
597
640
|
let out = mergeRaw(raw, layer);
|
|
@@ -622,9 +665,11 @@ var ENV_KEYS = {
|
|
|
622
665
|
maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
|
|
623
666
|
reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
|
|
624
667
|
reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
|
|
668
|
+
injectTimeoutMs: "HINDSIGHT_INJECT_TIMEOUT_MS",
|
|
625
669
|
reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
|
|
626
670
|
autoInject: "HINDSIGHT_AUTO_INJECT",
|
|
627
671
|
pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
|
|
672
|
+
toolGuideExtra: "HINDSIGHT_TOOL_GUIDE_EXTRA",
|
|
628
673
|
autoReflect: "HINDSIGHT_AUTO_REFLECT",
|
|
629
674
|
pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
|
|
630
675
|
pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
|
|
@@ -666,6 +711,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
|
666
711
|
"maxParallelRetains",
|
|
667
712
|
"reflectTimeoutMs",
|
|
668
713
|
"reflectToolTimeoutMs",
|
|
714
|
+
"injectTimeoutMs",
|
|
669
715
|
"pageSearchLimit",
|
|
670
716
|
"pageRefreshEveryTurns",
|
|
671
717
|
"seedLimit",
|
|
@@ -714,15 +760,25 @@ var BANK_OVERRIDE_EXCLUDED = [
|
|
|
714
760
|
function applyBankConfig(cfg, resolvedId, directory) {
|
|
715
761
|
if (directory !== void 0 && !isOptedIn(cfg, directory))
|
|
716
762
|
return { cfg: { ...cfg, disabled: true }, bankId: resolvedId };
|
|
763
|
+
const byPath = directory === void 0 ? void 0 : pathSection(cfg, cfg.paths, directory);
|
|
764
|
+
if (byPath) {
|
|
765
|
+
const { bank: _rename, ...rest } = overrideFields(byPath);
|
|
766
|
+
cfg = { ...cfg, ...resolvePartial(cfg, rest) };
|
|
767
|
+
}
|
|
717
768
|
const section = cfg.banks[resolvedId];
|
|
718
769
|
if (!section) return { cfg, bankId: resolvedId };
|
|
719
|
-
const safe =
|
|
720
|
-
for (const k of BANK_OVERRIDE_EXCLUDED) delete safe[k];
|
|
721
|
-
delete safe.banks;
|
|
770
|
+
const safe = overrideFields(section);
|
|
722
771
|
const bankId = typeof safe.bank === "string" && safe.bank ? safe.bank : resolvedId;
|
|
723
772
|
delete safe.bank;
|
|
724
773
|
return { cfg: { ...cfg, ...resolvePartial(cfg, safe) }, bankId };
|
|
725
774
|
}
|
|
775
|
+
function overrideFields(section) {
|
|
776
|
+
const safe = { ...section };
|
|
777
|
+
for (const k of BANK_OVERRIDE_EXCLUDED) delete safe[k];
|
|
778
|
+
delete safe.banks;
|
|
779
|
+
delete safe.paths;
|
|
780
|
+
return safe;
|
|
781
|
+
}
|
|
726
782
|
function resolvePartial(cfg, patch) {
|
|
727
783
|
const full = resolveConfig(patch);
|
|
728
784
|
const out = {};
|
|
@@ -731,6 +787,16 @@ function resolvePartial(cfg, patch) {
|
|
|
731
787
|
out[key] = full[key];
|
|
732
788
|
}
|
|
733
789
|
if ("autoReflect" in patch && !("autoInject" in patch)) out.autoInject = full.autoInject;
|
|
790
|
+
if ("serverMode" in patch || "apiUrl" in patch || "apiPort" in patch) {
|
|
791
|
+
const conn = resolveConfig({
|
|
792
|
+
serverMode: patch.serverMode ?? cfg.serverMode,
|
|
793
|
+
apiPort: patch.apiPort ?? cfg.apiPort,
|
|
794
|
+
apiUrl: patch.apiUrl ?? (cfg.serverMode === "daemon" ? void 0 : cfg.apiUrl)
|
|
795
|
+
});
|
|
796
|
+
out.serverMode = conn.serverMode;
|
|
797
|
+
out.apiUrl = conn.apiUrl;
|
|
798
|
+
out.apiPort = conn.apiPort;
|
|
799
|
+
}
|
|
734
800
|
return out;
|
|
735
801
|
}
|
|
736
802
|
|