@vectorize-io/hindsight-coding-agents 0.7.0 → 0.8.0

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.
Files changed (56) hide show
  1. package/README.md +137 -13
  2. package/dist/antigravity-hook.js +711 -55
  3. package/dist/antigravity-statusline.js +68 -7
  4. package/dist/antigravity-stop-hook.js +771 -57
  5. package/dist/claude-hook.js +711 -55
  6. package/dist/claude-sessionstart-hook.js +789 -68
  7. package/dist/claude-stop-hook.js +771 -57
  8. package/dist/cline.js +295 -75
  9. package/dist/codex-hook.js +711 -55
  10. package/dist/codex-sessionstart-hook.js +789 -68
  11. package/dist/codex-stop-hook.js +771 -57
  12. package/dist/copilot-hook.js +711 -55
  13. package/dist/copilot-sessionstart-hook.js +789 -68
  14. package/dist/copilot-stop-hook.js +771 -57
  15. package/dist/cursor-hook.js +711 -55
  16. package/dist/cursor-sessionstart-hook.js +789 -68
  17. package/dist/cursor-stop-hook.js +771 -57
  18. package/dist/daemon-start.js +38 -1
  19. package/dist/dcode-hook.js +711 -55
  20. package/dist/dcode-sessionstart-hook.js +789 -68
  21. package/dist/dcode-stop-hook.js +771 -57
  22. package/dist/deepen.js +236 -61
  23. package/dist/devin-hook.js +711 -55
  24. package/dist/devin-sessionstart-hook.js +789 -68
  25. package/dist/devin-stop-hook.js +771 -57
  26. package/dist/droid-hook.js +711 -55
  27. package/dist/droid-sessionstart-hook.js +789 -68
  28. package/dist/droid-stop-hook.js +771 -57
  29. package/dist/dsh.js +296 -76
  30. package/dist/grok-hook.js +711 -55
  31. package/dist/grok-sessionstart-hook.js +789 -68
  32. package/dist/grok-stop-hook.js +771 -57
  33. package/dist/hindsight-seed.js +41 -4
  34. package/dist/index.js +295 -75
  35. package/dist/installer.js +1148 -303
  36. package/dist/kilo.js +295 -75
  37. package/dist/kimi-hook.js +3909 -0
  38. package/dist/kimi-sessionstart-hook.js +4650 -0
  39. package/dist/kimi-stop-hook.js +4218 -0
  40. package/dist/mcp-server.js +162 -33
  41. package/dist/opencode2.js +298 -76
  42. package/dist/pi.js +299 -75
  43. package/dist/prime-agent.js +299 -75
  44. package/dist/qwen-hook.js +711 -55
  45. package/dist/qwen-sessionstart-hook.js +789 -68
  46. package/dist/qwen-stop-hook.js +771 -57
  47. package/dist/status.js +132 -14
  48. package/dist/traecode-hook.js +3909 -0
  49. package/dist/traecode-sessionstart-hook.js +4650 -0
  50. package/dist/traecode-stop-hook.js +4218 -0
  51. package/dist/zcode-hook.js +711 -55
  52. package/dist/zcode-sessionstart-hook.js +789 -68
  53. package/dist/zcode-stop-hook.js +771 -57
  54. package/package.json +15 -11
  55. package/plugin.json +1 -1
  56. package/skill/SKILL.md +70 -11
@@ -258,13 +258,13 @@ function isWithin(directory, configured) {
258
258
  function mapLookup(map, directory) {
259
259
  const cwd = normalize(directory);
260
260
  let best;
261
- for (const [dir, bank] of Object.entries(map)) {
261
+ for (const [dir, value] of Object.entries(map)) {
262
262
  const p = configuredDir(dir);
263
263
  if (isWithin(cwd, p)) {
264
- if (!best || p.length > best.len) best = { len: p.length, bank };
264
+ if (!best || p.length > best.len) best = { len: p.length, value };
265
265
  }
266
266
  }
267
- return best?.bank;
267
+ return best?.value;
268
268
  }
269
269
  function lookupDirectories(config, directory, sessionRoot = "") {
270
270
  const directories = [normalize(directory)];
@@ -288,6 +288,10 @@ function isOptedIn(config, directory) {
288
288
  const pathMap = config.mapPathToBank;
289
289
  return Boolean(pathMap && directories.some((candidate) => mapLookup(pathMap, candidate)));
290
290
  }
291
+ function pathSection(config, paths, directory) {
292
+ if (!directory || !paths) return void 0;
293
+ return lookupDirectories(config, directory).map((candidate) => mapLookup(paths, candidate)).find((section) => section !== void 0);
294
+ }
291
295
  function mappedBank(config, directory, sessionRoot) {
292
296
  const pathMap = config.mapPathToBank;
293
297
  if (!directory || !pathMap) return void 0;
@@ -384,6 +388,11 @@ function parseHashedCron(cron) {
384
388
  }
385
389
  return fields;
386
390
  }
391
+ var PLUGIN_GOVERNED_BANK_FIELDS = [
392
+ "retain_strategies",
393
+ "entity_labels",
394
+ "retain_extraction_mode"
395
+ ];
387
396
 
388
397
  // src/core/util.ts
389
398
  import { accessSync, constants } from "fs";
@@ -474,6 +483,7 @@ function resolveCustomPages(raw) {
474
483
  }
475
484
  var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
476
485
  var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
486
+ var DEFAULT_INJECT_TIMEOUT_MS = 7e3;
477
487
  var REFLECT_BUDGETS = ["low", "mid", "high"];
478
488
  function resolveReflectBudget(raw) {
479
489
  const value = raw.reflectBudget;
@@ -500,6 +510,22 @@ function resolveObservationScopes(raw) {
500
510
  }
501
511
  return DEFAULT_OBSERVATION_SCOPES;
502
512
  }
513
+ function resolveDefaultBankConfig(raw) {
514
+ const value = raw;
515
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
516
+ const out = {};
517
+ for (const [key, v] of Object.entries(value)) {
518
+ if (PLUGIN_GOVERNED_BANK_FIELDS.includes(key)) {
519
+ log.warn(
520
+ "config",
521
+ `ignoring defaultBankConfig.${key} \u2014 the plugin manages this field itself` + (key === "retain_extraction_mode" ? " (set retainExtractionMode instead)" : "")
522
+ );
523
+ continue;
524
+ }
525
+ out[key] = v;
526
+ }
527
+ return out;
528
+ }
503
529
  var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
504
530
  function resolveAutoInject(raw) {
505
531
  if (raw.autoReflect !== void 0) {
@@ -539,18 +565,21 @@ function resolveConfig(raw = {}) {
539
565
  // write sessions back by default, every harness
540
566
  manageBankConfig: raw.manageBankConfig ?? true,
541
567
  retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
568
+ defaultBankConfig: resolveDefaultBankConfig(raw.defaultBankConfig),
542
569
  maxParallelRetains: raw.maxParallelRetains || 10,
543
570
  reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
544
571
  // Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
545
572
  // reflect already set), but never let it LOWER the tool below the default — a short window is
546
573
  // set to bound the automatic hook, not to cut off a call the agent is waiting on.
547
574
  reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
575
+ injectTimeoutMs: raw.injectTimeoutMs || DEFAULT_INJECT_TIMEOUT_MS,
548
576
  reflectBudget: resolveReflectBudget(raw),
549
577
  autoInject: resolveAutoInject(raw),
550
578
  pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
551
579
  // Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
552
580
  // keys and reach the API as garbage, so it is rejected like any other non-object.
553
581
  recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
582
+ toolGuideExtra: typeof raw.toolGuideExtra === "string" && raw.toolGuideExtra.trim() ? raw.toolGuideExtra : void 0,
554
583
  // Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
555
584
  // at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
556
585
  // 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
@@ -570,11 +599,15 @@ function resolveConfig(raw = {}) {
570
599
  // Hostile input is a config typo, not an attack: keep only string entries so a stray number or
571
600
  // nested object cannot reach the API as a tag and fail the whole retain.
572
601
  retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
602
+ // Undefined, not "", when unset or blank: the retain call distinguishes "not configured" (use
603
+ // the built-in default) from a configured value, and an empty context would strip the default.
604
+ retainContext: typeof raw.retainContext === "string" && raw.retainContext.trim() !== "" ? raw.retainContext : void 0,
573
605
  retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
574
606
  Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
575
607
  ) : {},
576
608
  observationScopes: resolveObservationScopes(raw.observationScopes),
577
609
  banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
610
+ paths: raw.paths && typeof raw.paths === "object" ? raw.paths : {},
578
611
  logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
579
612
  autoUpdate: raw.autoUpdate ?? true
580
613
  };
@@ -591,7 +624,12 @@ function readRaw(path) {
591
624
  }
592
625
  function mergeRaw(a, b) {
593
626
  const { harnesses: _drop, ...flat } = b;
594
- return { ...a, ...flat, banks: { ...a.banks ?? {}, ...b.banks ?? {} } };
627
+ return {
628
+ ...a,
629
+ ...flat,
630
+ banks: { ...a.banks ?? {}, ...b.banks ?? {} },
631
+ paths: { ...a.paths ?? {}, ...b.paths ?? {} }
632
+ };
595
633
  }
596
634
  function applyLayer(raw, layer, harness) {
597
635
  let out = mergeRaw(raw, layer);
@@ -622,9 +660,11 @@ var ENV_KEYS = {
622
660
  maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
623
661
  reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
624
662
  reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
663
+ injectTimeoutMs: "HINDSIGHT_INJECT_TIMEOUT_MS",
625
664
  reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
626
665
  autoInject: "HINDSIGHT_AUTO_INJECT",
627
666
  pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
667
+ toolGuideExtra: "HINDSIGHT_TOOL_GUIDE_EXTRA",
628
668
  autoReflect: "HINDSIGHT_AUTO_REFLECT",
629
669
  pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
630
670
  pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
@@ -666,6 +706,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
666
706
  "maxParallelRetains",
667
707
  "reflectTimeoutMs",
668
708
  "reflectToolTimeoutMs",
709
+ "injectTimeoutMs",
669
710
  "pageSearchLimit",
670
711
  "pageRefreshEveryTurns",
671
712
  "seedLimit",
@@ -714,15 +755,25 @@ var BANK_OVERRIDE_EXCLUDED = [
714
755
  function applyBankConfig(cfg, resolvedId, directory) {
715
756
  if (directory !== void 0 && !isOptedIn(cfg, directory))
716
757
  return { cfg: { ...cfg, disabled: true }, bankId: resolvedId };
758
+ const byPath = directory === void 0 ? void 0 : pathSection(cfg, cfg.paths, directory);
759
+ if (byPath) {
760
+ const { bank: _rename, ...rest } = overrideFields(byPath);
761
+ cfg = { ...cfg, ...resolvePartial(cfg, rest) };
762
+ }
717
763
  const section = cfg.banks[resolvedId];
718
764
  if (!section) return { cfg, bankId: resolvedId };
719
- const safe = { ...section };
720
- for (const k of BANK_OVERRIDE_EXCLUDED) delete safe[k];
721
- delete safe.banks;
765
+ const safe = overrideFields(section);
722
766
  const bankId = typeof safe.bank === "string" && safe.bank ? safe.bank : resolvedId;
723
767
  delete safe.bank;
724
768
  return { cfg: { ...cfg, ...resolvePartial(cfg, safe) }, bankId };
725
769
  }
770
+ function overrideFields(section) {
771
+ const safe = { ...section };
772
+ for (const k of BANK_OVERRIDE_EXCLUDED) delete safe[k];
773
+ delete safe.banks;
774
+ delete safe.paths;
775
+ return safe;
776
+ }
726
777
  function resolvePartial(cfg, patch) {
727
778
  const full = resolveConfig(patch);
728
779
  const out = {};
@@ -731,6 +782,16 @@ function resolvePartial(cfg, patch) {
731
782
  out[key] = full[key];
732
783
  }
733
784
  if ("autoReflect" in patch && !("autoInject" in patch)) out.autoInject = full.autoInject;
785
+ if ("serverMode" in patch || "apiUrl" in patch || "apiPort" in patch) {
786
+ const conn = resolveConfig({
787
+ serverMode: patch.serverMode ?? cfg.serverMode,
788
+ apiPort: patch.apiPort ?? cfg.apiPort,
789
+ apiUrl: patch.apiUrl ?? (cfg.serverMode === "daemon" ? void 0 : cfg.apiUrl)
790
+ });
791
+ out.serverMode = conn.serverMode;
792
+ out.apiUrl = conn.apiUrl;
793
+ out.apiPort = conn.apiPort;
794
+ }
734
795
  return out;
735
796
  }
736
797