@vectorize-io/hindsight-coding-agents 0.6.1 → 0.7.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 (50) hide show
  1. package/README.md +179 -40
  2. package/dist/antigravity-hook.js +343 -158
  3. package/dist/antigravity-statusline.js +117 -4
  4. package/dist/antigravity-stop-hook.js +262 -113
  5. package/dist/claude-hook.js +343 -158
  6. package/dist/claude-sessionstart-hook.js +348 -136
  7. package/dist/claude-stop-hook.js +262 -113
  8. package/dist/cline.js +493 -173
  9. package/dist/codex-hook.js +343 -158
  10. package/dist/codex-sessionstart-hook.js +348 -136
  11. package/dist/codex-stop-hook.js +262 -113
  12. package/dist/copilot-hook.js +343 -158
  13. package/dist/copilot-sessionstart-hook.js +348 -136
  14. package/dist/copilot-stop-hook.js +262 -113
  15. package/dist/cursor-hook.js +343 -158
  16. package/dist/cursor-sessionstart-hook.js +348 -136
  17. package/dist/cursor-stop-hook.js +262 -113
  18. package/dist/daemon-start.js +116 -4
  19. package/dist/dcode-hook.js +343 -158
  20. package/dist/dcode-sessionstart-hook.js +348 -136
  21. package/dist/dcode-stop-hook.js +262 -113
  22. package/dist/deepen.js +204 -47
  23. package/dist/devin-hook.js +343 -158
  24. package/dist/devin-sessionstart-hook.js +348 -136
  25. package/dist/devin-stop-hook.js +262 -113
  26. package/dist/droid-hook.js +343 -158
  27. package/dist/droid-sessionstart-hook.js +348 -136
  28. package/dist/droid-stop-hook.js +262 -113
  29. package/dist/dsh.js +493 -173
  30. package/dist/grok-hook.js +343 -158
  31. package/dist/grok-sessionstart-hook.js +348 -136
  32. package/dist/grok-stop-hook.js +262 -113
  33. package/dist/hindsight-seed.js +116 -4
  34. package/dist/index.js +493 -173
  35. package/dist/installer.js +92 -70
  36. package/dist/kilo.js +493 -173
  37. package/dist/mcp-server.js +230 -57
  38. package/dist/opencode2.js +520 -173
  39. package/dist/pi.js +494 -175
  40. package/dist/prime-agent.js +494 -175
  41. package/dist/qwen-hook.js +343 -158
  42. package/dist/qwen-sessionstart-hook.js +348 -136
  43. package/dist/qwen-stop-hook.js +262 -113
  44. package/dist/status.js +203 -47
  45. package/dist/zcode-hook.js +343 -158
  46. package/dist/zcode-sessionstart-hook.js +348 -136
  47. package/dist/zcode-stop-hook.js +262 -113
  48. package/package.json +2 -2
  49. package/plugin.json +1 -1
  50. package/skill/SKILL.md +173 -39
@@ -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],
@@ -420,6 +450,7 @@ import { delimiter, join as join6 } from "path";
420
450
 
421
451
  // src/core/hindsight.ts
422
452
  var DEFAULT_OBSERVATION_SCOPES = "shared";
453
+ var DEFAULT_PAGE_SEARCH_LIMIT = 10;
423
454
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
424
455
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
425
456
 
@@ -444,6 +475,63 @@ function resolvePageTrigger(raw) {
444
475
  );
445
476
  return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
446
477
  }
478
+ function resolvePages(raw) {
479
+ const value = raw;
480
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
481
+ const out = {};
482
+ for (const [name, entry] of Object.entries(value)) {
483
+ if (!PAGE_NAMES.some((known) => known.toLowerCase() === name.trim().toLowerCase())) {
484
+ log.warn(
485
+ "config",
486
+ `ignoring pages[${JSON.stringify(name)}] \u2014 no seeded page has that name; expected one of: ${PAGE_NAMES.join(", ")}`
487
+ );
488
+ continue;
489
+ }
490
+ if (entry === false) {
491
+ out[name] = false;
492
+ continue;
493
+ }
494
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
495
+ if (typeof query === "string" && query.trim()) {
496
+ out[name] = { source_query: query };
497
+ continue;
498
+ }
499
+ log.warn(
500
+ "config",
501
+ `ignoring pages[${JSON.stringify(name)}]=${JSON.stringify(entry)} \u2014 expected false, or {"source_query": "<your question>"}`
502
+ );
503
+ }
504
+ return out;
505
+ }
506
+ function resolveCustomPages(raw) {
507
+ const value = raw;
508
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
509
+ const out = {};
510
+ for (const [rawName, entry] of Object.entries(value)) {
511
+ const name = rawName.trim();
512
+ if (!name) continue;
513
+ if (PAGE_NAMES.some((known) => known.toLowerCase() === name.toLowerCase())) {
514
+ log.warn(
515
+ "config",
516
+ `ignoring customPages[${JSON.stringify(rawName)}] \u2014 that is a seeded page; reword it under \`pages\` instead`
517
+ );
518
+ continue;
519
+ }
520
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
521
+ if (typeof query !== "string" || !query.trim()) {
522
+ log.warn(
523
+ "config",
524
+ `ignoring customPages[${JSON.stringify(rawName)}]=${JSON.stringify(entry)} \u2014 expected {"source_query": "<your question>"}`
525
+ );
526
+ continue;
527
+ }
528
+ const rawTags = entry.tags;
529
+ const tags = Array.isArray(rawTags) ? rawTags.filter((t) => typeof t === "string" && t.trim() !== "") : [];
530
+ out[name] = tags.length ? { source_query: query, tags } : { source_query: query };
531
+ }
532
+ return out;
533
+ }
534
+ var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
447
535
  var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
448
536
  var REFLECT_BUDGETS = ["low", "mid", "high"];
449
537
  function resolveReflectBudget(raw) {
@@ -471,6 +559,15 @@ function resolveObservationScopes(raw) {
471
559
  }
472
560
  return DEFAULT_OBSERVATION_SCOPES;
473
561
  }
562
+ var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
563
+ function resolveAutoInject(raw) {
564
+ if (raw.autoReflect !== void 0) {
565
+ const replacement = raw.autoReflect === false ? "none" : "reflect";
566
+ log.warn("config", `autoReflect is deprecated \u2014 use autoInject: "${replacement}" instead`);
567
+ }
568
+ if (AUTO_INJECT_MODES.includes(raw.autoInject)) return raw.autoInject;
569
+ return raw.autoReflect === false ? "none" : "reflect";
570
+ }
474
571
  function resolveConfig(raw = {}) {
475
572
  const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
476
573
  const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
@@ -500,17 +597,28 @@ function resolveConfig(raw = {}) {
500
597
  retainSessions: raw.retainSessions ?? true,
501
598
  // write sessions back by default, every harness
502
599
  manageBankConfig: raw.manageBankConfig ?? true,
600
+ retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
503
601
  maxParallelRetains: raw.maxParallelRetains || 10,
504
- reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
602
+ reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
505
603
  // Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
506
604
  // reflect already set), but never let it LOWER the tool below the default — a short window is
507
605
  // set to bound the automatic hook, not to cut off a call the agent is waiting on.
508
606
  reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
509
607
  reflectBudget: resolveReflectBudget(raw),
510
- autoReflect: raw.autoReflect ?? true,
511
- pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
608
+ autoInject: resolveAutoInject(raw),
609
+ pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
610
+ // Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
611
+ // keys and reach the API as garbage, so it is rejected like any other non-object.
612
+ recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
613
+ // Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
614
+ // at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
615
+ // 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
616
+ // with no wording change at all. The cost is the guide's ~2KB re-sent per turn, which caches.
617
+ pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 1,
512
618
  pageTriggerType: pageTrigger.type,
513
619
  pageTriggerCron: pageTrigger.cron,
620
+ pages: resolvePages(raw.pages),
621
+ customPages: resolveCustomPages(raw.customPages),
514
622
  autoSeed: raw.autoSeed ?? true,
515
623
  seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
516
624
  codebaseSurvey: raw.codebaseSurvey ?? true,
@@ -574,6 +682,8 @@ var ENV_KEYS = {
574
682
  reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
575
683
  reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
576
684
  reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
685
+ autoInject: "HINDSIGHT_AUTO_INJECT",
686
+ pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
577
687
  autoReflect: "HINDSIGHT_AUTO_REFLECT",
578
688
  pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
579
689
  pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
@@ -593,7 +703,8 @@ var ENV_KEYS = {
593
703
  // Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
594
704
  // a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
595
705
  retainTags: "HINDSIGHT_RETAIN_TAGS",
596
- manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
706
+ manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG",
707
+ retainExtractionMode: "HINDSIGHT_RETAIN_EXTRACTION_MODE"
597
708
  };
598
709
  var ENV_BOOLEANS = /* @__PURE__ */ new Set([
599
710
  "dynamicBankId",
@@ -614,6 +725,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
614
725
  "maxParallelRetains",
615
726
  "reflectTimeoutMs",
616
727
  "reflectToolTimeoutMs",
728
+ "pageSearchLimit",
617
729
  "pageRefreshEveryTurns",
618
730
  "seedLimit",
619
731
  "surveyBudgetUsd",