@vectorize-io/hindsight-coding-agents 0.6.1 → 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 +314 -51
  2. package/dist/antigravity-hook.js +1039 -198
  3. package/dist/antigravity-statusline.js +185 -11
  4. package/dist/antigravity-stop-hook.js +1026 -163
  5. package/dist/claude-hook.js +1039 -198
  6. package/dist/claude-sessionstart-hook.js +1123 -190
  7. package/dist/claude-stop-hook.js +1026 -163
  8. package/dist/cline.js +749 -209
  9. package/dist/codex-hook.js +1039 -198
  10. package/dist/codex-sessionstart-hook.js +1123 -190
  11. package/dist/codex-stop-hook.js +1026 -163
  12. package/dist/copilot-hook.js +1039 -198
  13. package/dist/copilot-sessionstart-hook.js +1123 -190
  14. package/dist/copilot-stop-hook.js +1026 -163
  15. package/dist/cursor-hook.js +1039 -198
  16. package/dist/cursor-sessionstart-hook.js +1123 -190
  17. package/dist/cursor-stop-hook.js +1026 -163
  18. package/dist/daemon-start.js +154 -5
  19. package/dist/dcode-hook.js +1039 -198
  20. package/dist/dcode-sessionstart-hook.js +1123 -190
  21. package/dist/dcode-stop-hook.js +1026 -163
  22. package/dist/deepen.js +437 -105
  23. package/dist/devin-hook.js +1039 -198
  24. package/dist/devin-sessionstart-hook.js +1123 -190
  25. package/dist/devin-stop-hook.js +1026 -163
  26. package/dist/droid-hook.js +1039 -198
  27. package/dist/droid-sessionstart-hook.js +1123 -190
  28. package/dist/droid-stop-hook.js +1026 -163
  29. package/dist/dsh.js +750 -210
  30. package/dist/grok-hook.js +1039 -198
  31. package/dist/grok-sessionstart-hook.js +1123 -190
  32. package/dist/grok-stop-hook.js +1026 -163
  33. package/dist/hindsight-seed.js +157 -8
  34. package/dist/index.js +749 -209
  35. package/dist/installer.js +1233 -366
  36. package/dist/kilo.js +749 -209
  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 +373 -71
  41. package/dist/opencode2.js +778 -209
  42. package/dist/pi.js +754 -211
  43. package/dist/prime-agent.js +754 -211
  44. package/dist/qwen-hook.js +1039 -198
  45. package/dist/qwen-sessionstart-hook.js +1123 -190
  46. package/dist/qwen-stop-hook.js +1026 -163
  47. package/dist/status.js +333 -59
  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 +1039 -198
  52. package/dist/zcode-sessionstart-hook.js +1123 -190
  53. package/dist/zcode-stop-hook.js +1026 -163
  54. package/package.json +15 -11
  55. package/plugin.json +1 -1
  56. package/skill/SKILL.md +241 -48
@@ -382,6 +382,36 @@ import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
382
382
 
383
383
  // src/core/missions.ts
384
384
  import { createHash } from "crypto";
385
+ var RETAIN_EXTRACTION_MODES = ["concise", "verbose", "verbatim", "chunks"];
386
+ var DEFAULT_RETAIN_EXTRACTION_MODE = "concise";
387
+ var PAGE_TAXONOMY = [
388
+ {
389
+ name: "Component map",
390
+ source_query: "From this project's commit history and past discussions, what are the main components/modules/subsystems, what is each responsible for, and how do they relate to or depend on one another? Describe the structure and responsibilities.",
391
+ tags: ["knowledge:component"]
392
+ },
393
+ {
394
+ name: "Core concepts",
395
+ source_query: "What are the core concepts, domain abstractions, and key entities in this project \u2014 the vocabulary a developer must understand? For each, explain what it represents and its role, drawn from how they are introduced and discussed across the history and conversations.",
396
+ tags: ["knowledge:concept"]
397
+ },
398
+ {
399
+ name: "Conventions and patterns",
400
+ source_query: "What conventions, idioms, and recurring patterns does this project follow \u2014 its approach to testing, error handling, naming, structure, and how changes are typically made? Describe how THIS project does things, as evidenced across its history and discussions.",
401
+ tags: ["knowledge:convention"]
402
+ },
403
+ {
404
+ name: "Key decisions and rationale",
405
+ source_query: "What are the significant technical decisions made in this project and the rationale behind them \u2014 the durable 'why we do it this way' a developer should know? Summarize the decisions and their reasoning from the commit rationales and past conversations.",
406
+ tags: ["knowledge:decision"]
407
+ },
408
+ {
409
+ name: "Initiatives and enhancements",
410
+ source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
411
+ tags: ["knowledge:feature-work"]
412
+ }
413
+ ];
414
+ var PAGE_NAMES = PAGE_TAXONOMY.map((page) => page.name);
385
415
  var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
386
416
  var CRON_FIELD_RANGES = [
387
417
  [0, 59],
@@ -413,6 +443,11 @@ function parseHashedCron(cron) {
413
443
  }
414
444
  return fields;
415
445
  }
446
+ var PLUGIN_GOVERNED_BANK_FIELDS = [
447
+ "retain_strategies",
448
+ "entity_labels",
449
+ "retain_extraction_mode"
450
+ ];
416
451
 
417
452
  // src/core/util.ts
418
453
  import { accessSync, constants } from "fs";
@@ -420,6 +455,7 @@ import { delimiter, join as join6 } from "path";
420
455
 
421
456
  // src/core/hindsight.ts
422
457
  var DEFAULT_OBSERVATION_SCOPES = "shared";
458
+ var DEFAULT_PAGE_SEARCH_LIMIT = 10;
423
459
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
424
460
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
425
461
 
@@ -444,7 +480,65 @@ function resolvePageTrigger(raw) {
444
480
  );
445
481
  return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
446
482
  }
483
+ function resolvePages(raw) {
484
+ const value = raw;
485
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
486
+ const out = {};
487
+ for (const [name, entry] of Object.entries(value)) {
488
+ if (!PAGE_NAMES.some((known) => known.toLowerCase() === name.trim().toLowerCase())) {
489
+ log.warn(
490
+ "config",
491
+ `ignoring pages[${JSON.stringify(name)}] \u2014 no seeded page has that name; expected one of: ${PAGE_NAMES.join(", ")}`
492
+ );
493
+ continue;
494
+ }
495
+ if (entry === false) {
496
+ out[name] = false;
497
+ continue;
498
+ }
499
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
500
+ if (typeof query === "string" && query.trim()) {
501
+ out[name] = { source_query: query };
502
+ continue;
503
+ }
504
+ log.warn(
505
+ "config",
506
+ `ignoring pages[${JSON.stringify(name)}]=${JSON.stringify(entry)} \u2014 expected false, or {"source_query": "<your question>"}`
507
+ );
508
+ }
509
+ return out;
510
+ }
511
+ function resolveCustomPages(raw) {
512
+ const value = raw;
513
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
514
+ const out = {};
515
+ for (const [rawName, entry] of Object.entries(value)) {
516
+ const name = rawName.trim();
517
+ if (!name) continue;
518
+ if (PAGE_NAMES.some((known) => known.toLowerCase() === name.toLowerCase())) {
519
+ log.warn(
520
+ "config",
521
+ `ignoring customPages[${JSON.stringify(rawName)}] \u2014 that is a seeded page; reword it under \`pages\` instead`
522
+ );
523
+ continue;
524
+ }
525
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
526
+ if (typeof query !== "string" || !query.trim()) {
527
+ log.warn(
528
+ "config",
529
+ `ignoring customPages[${JSON.stringify(rawName)}]=${JSON.stringify(entry)} \u2014 expected {"source_query": "<your question>"}`
530
+ );
531
+ continue;
532
+ }
533
+ const rawTags = entry.tags;
534
+ const tags = Array.isArray(rawTags) ? rawTags.filter((t) => typeof t === "string" && t.trim() !== "") : [];
535
+ out[name] = tags.length ? { source_query: query, tags } : { source_query: query };
536
+ }
537
+ return out;
538
+ }
539
+ var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
447
540
  var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
541
+ var DEFAULT_INJECT_TIMEOUT_MS = 7e3;
448
542
  var REFLECT_BUDGETS = ["low", "mid", "high"];
449
543
  function resolveReflectBudget(raw) {
450
544
  const value = raw.reflectBudget;
@@ -471,6 +565,31 @@ function resolveObservationScopes(raw) {
471
565
  }
472
566
  return DEFAULT_OBSERVATION_SCOPES;
473
567
  }
568
+ function resolveDefaultBankConfig(raw) {
569
+ const value = raw;
570
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
571
+ const out = {};
572
+ for (const [key, v] of Object.entries(value)) {
573
+ if (PLUGIN_GOVERNED_BANK_FIELDS.includes(key)) {
574
+ log.warn(
575
+ "config",
576
+ `ignoring defaultBankConfig.${key} \u2014 the plugin manages this field itself` + (key === "retain_extraction_mode" ? " (set retainExtractionMode instead)" : "")
577
+ );
578
+ continue;
579
+ }
580
+ out[key] = v;
581
+ }
582
+ return out;
583
+ }
584
+ var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
585
+ function resolveAutoInject(raw) {
586
+ if (raw.autoReflect !== void 0) {
587
+ const replacement = raw.autoReflect === false ? "none" : "reflect";
588
+ log.warn("config", `autoReflect is deprecated \u2014 use autoInject: "${replacement}" instead`);
589
+ }
590
+ if (AUTO_INJECT_MODES.includes(raw.autoInject)) return raw.autoInject;
591
+ return raw.autoReflect === false ? "none" : "reflect";
592
+ }
474
593
  function resolveConfig(raw = {}) {
475
594
  const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
476
595
  const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
@@ -500,17 +619,31 @@ function resolveConfig(raw = {}) {
500
619
  retainSessions: raw.retainSessions ?? true,
501
620
  // write sessions back by default, every harness
502
621
  manageBankConfig: raw.manageBankConfig ?? true,
622
+ retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
623
+ defaultBankConfig: resolveDefaultBankConfig(raw.defaultBankConfig),
503
624
  maxParallelRetains: raw.maxParallelRetains || 10,
504
- reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
625
+ reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
505
626
  // Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
506
627
  // reflect already set), but never let it LOWER the tool below the default — a short window is
507
628
  // set to bound the automatic hook, not to cut off a call the agent is waiting on.
508
629
  reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
630
+ injectTimeoutMs: raw.injectTimeoutMs || DEFAULT_INJECT_TIMEOUT_MS,
509
631
  reflectBudget: resolveReflectBudget(raw),
510
- autoReflect: raw.autoReflect ?? true,
511
- pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
632
+ autoInject: resolveAutoInject(raw),
633
+ pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
634
+ // Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
635
+ // keys and reach the API as garbage, so it is rejected like any other non-object.
636
+ recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
637
+ toolGuideExtra: typeof raw.toolGuideExtra === "string" && raw.toolGuideExtra.trim() ? raw.toolGuideExtra : void 0,
638
+ // Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
639
+ // at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
640
+ // 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
641
+ // with no wording change at all. The cost is the guide's ~2KB re-sent per turn, which caches.
642
+ pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 1,
512
643
  pageTriggerType: pageTrigger.type,
513
644
  pageTriggerCron: pageTrigger.cron,
645
+ pages: resolvePages(raw.pages),
646
+ customPages: resolveCustomPages(raw.customPages),
514
647
  autoSeed: raw.autoSeed ?? true,
515
648
  seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
516
649
  codebaseSurvey: raw.codebaseSurvey ?? true,
@@ -521,11 +654,15 @@ function resolveConfig(raw = {}) {
521
654
  // Hostile input is a config typo, not an attack: keep only string entries so a stray number or
522
655
  // nested object cannot reach the API as a tag and fail the whole retain.
523
656
  retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
657
+ // Undefined, not "", when unset or blank: the retain call distinguishes "not configured" (use
658
+ // the built-in default) from a configured value, and an empty context would strip the default.
659
+ retainContext: typeof raw.retainContext === "string" && raw.retainContext.trim() !== "" ? raw.retainContext : void 0,
524
660
  retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
525
661
  Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
526
662
  ) : {},
527
663
  observationScopes: resolveObservationScopes(raw.observationScopes),
528
664
  banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
665
+ paths: raw.paths && typeof raw.paths === "object" ? raw.paths : {},
529
666
  logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
530
667
  autoUpdate: raw.autoUpdate ?? true
531
668
  };
@@ -542,7 +679,12 @@ function readRaw(path) {
542
679
  }
543
680
  function mergeRaw(a, b) {
544
681
  const { harnesses: _drop, ...flat } = b;
545
- return { ...a, ...flat, banks: { ...a.banks ?? {}, ...b.banks ?? {} } };
682
+ return {
683
+ ...a,
684
+ ...flat,
685
+ banks: { ...a.banks ?? {}, ...b.banks ?? {} },
686
+ paths: { ...a.paths ?? {}, ...b.paths ?? {} }
687
+ };
546
688
  }
547
689
  function applyLayer(raw, layer, harness) {
548
690
  let out = mergeRaw(raw, layer);
@@ -573,7 +715,11 @@ var ENV_KEYS = {
573
715
  maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
574
716
  reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
575
717
  reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
718
+ injectTimeoutMs: "HINDSIGHT_INJECT_TIMEOUT_MS",
576
719
  reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
720
+ autoInject: "HINDSIGHT_AUTO_INJECT",
721
+ pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
722
+ toolGuideExtra: "HINDSIGHT_TOOL_GUIDE_EXTRA",
577
723
  autoReflect: "HINDSIGHT_AUTO_REFLECT",
578
724
  pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
579
725
  pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
@@ -593,7 +739,8 @@ var ENV_KEYS = {
593
739
  // Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
594
740
  // a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
595
741
  retainTags: "HINDSIGHT_RETAIN_TAGS",
596
- manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
742
+ manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG",
743
+ retainExtractionMode: "HINDSIGHT_RETAIN_EXTRACTION_MODE"
597
744
  };
598
745
  var ENV_BOOLEANS = /* @__PURE__ */ new Set([
599
746
  "dynamicBankId",
@@ -614,6 +761,8 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
614
761
  "maxParallelRetains",
615
762
  "reflectTimeoutMs",
616
763
  "reflectToolTimeoutMs",
764
+ "injectTimeoutMs",
765
+ "pageSearchLimit",
617
766
  "pageRefreshEveryTurns",
618
767
  "seedLimit",
619
768
  "surveyBudgetUsd",