@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
@@ -295,13 +295,13 @@ function isWithin(directory, configured) {
295
295
  function mapLookup(map, directory) {
296
296
  const cwd = normalize(directory);
297
297
  let best;
298
- for (const [dir, bank] of Object.entries(map)) {
298
+ for (const [dir, value] of Object.entries(map)) {
299
299
  const p = configuredDir(dir);
300
300
  if (isWithin(cwd, p)) {
301
- if (!best || p.length > best.len) best = { len: p.length, bank };
301
+ if (!best || p.length > best.len) best = { len: p.length, value };
302
302
  }
303
303
  }
304
- return best?.bank;
304
+ return best?.value;
305
305
  }
306
306
  function lookupDirectories(config, directory, sessionRoot = "") {
307
307
  const directories = [normalize(directory)];
@@ -347,6 +347,36 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
347
347
 
348
348
  // src/core/missions.ts
349
349
  import { createHash } from "crypto";
350
+ var RETAIN_EXTRACTION_MODES = ["concise", "verbose", "verbatim", "chunks"];
351
+ var DEFAULT_RETAIN_EXTRACTION_MODE = "concise";
352
+ var PAGE_TAXONOMY = [
353
+ {
354
+ name: "Component map",
355
+ 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.",
356
+ tags: ["knowledge:component"]
357
+ },
358
+ {
359
+ name: "Core concepts",
360
+ 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.",
361
+ tags: ["knowledge:concept"]
362
+ },
363
+ {
364
+ name: "Conventions and patterns",
365
+ 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.",
366
+ tags: ["knowledge:convention"]
367
+ },
368
+ {
369
+ name: "Key decisions and rationale",
370
+ 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.",
371
+ tags: ["knowledge:decision"]
372
+ },
373
+ {
374
+ name: "Initiatives and enhancements",
375
+ 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.",
376
+ tags: ["knowledge:feature-work"]
377
+ }
378
+ ];
379
+ var PAGE_NAMES = PAGE_TAXONOMY.map((page) => page.name);
350
380
  var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
351
381
  var CRON_FIELD_RANGES = [
352
382
  [0, 59],
@@ -378,6 +408,11 @@ function parseHashedCron(cron) {
378
408
  }
379
409
  return fields;
380
410
  }
411
+ var PLUGIN_GOVERNED_BANK_FIELDS = [
412
+ "retain_strategies",
413
+ "entity_labels",
414
+ "retain_extraction_mode"
415
+ ];
381
416
 
382
417
  // src/core/util.ts
383
418
  import { accessSync, constants } from "fs";
@@ -385,6 +420,7 @@ import { delimiter, join as join6 } from "path";
385
420
 
386
421
  // src/core/hindsight.ts
387
422
  var DEFAULT_OBSERVATION_SCOPES = "shared";
423
+ var DEFAULT_PAGE_SEARCH_LIMIT = 10;
388
424
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
389
425
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
390
426
 
@@ -409,7 +445,65 @@ function resolvePageTrigger(raw) {
409
445
  );
410
446
  return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
411
447
  }
448
+ function resolvePages(raw) {
449
+ const value = raw;
450
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
451
+ const out = {};
452
+ for (const [name, entry] of Object.entries(value)) {
453
+ if (!PAGE_NAMES.some((known) => known.toLowerCase() === name.trim().toLowerCase())) {
454
+ log.warn(
455
+ "config",
456
+ `ignoring pages[${JSON.stringify(name)}] \u2014 no seeded page has that name; expected one of: ${PAGE_NAMES.join(", ")}`
457
+ );
458
+ continue;
459
+ }
460
+ if (entry === false) {
461
+ out[name] = false;
462
+ continue;
463
+ }
464
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
465
+ if (typeof query === "string" && query.trim()) {
466
+ out[name] = { source_query: query };
467
+ continue;
468
+ }
469
+ log.warn(
470
+ "config",
471
+ `ignoring pages[${JSON.stringify(name)}]=${JSON.stringify(entry)} \u2014 expected false, or {"source_query": "<your question>"}`
472
+ );
473
+ }
474
+ return out;
475
+ }
476
+ function resolveCustomPages(raw) {
477
+ const value = raw;
478
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
479
+ const out = {};
480
+ for (const [rawName, entry] of Object.entries(value)) {
481
+ const name = rawName.trim();
482
+ if (!name) continue;
483
+ if (PAGE_NAMES.some((known) => known.toLowerCase() === name.toLowerCase())) {
484
+ log.warn(
485
+ "config",
486
+ `ignoring customPages[${JSON.stringify(rawName)}] \u2014 that is a seeded page; reword it under \`pages\` instead`
487
+ );
488
+ continue;
489
+ }
490
+ const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
491
+ if (typeof query !== "string" || !query.trim()) {
492
+ log.warn(
493
+ "config",
494
+ `ignoring customPages[${JSON.stringify(rawName)}]=${JSON.stringify(entry)} \u2014 expected {"source_query": "<your question>"}`
495
+ );
496
+ continue;
497
+ }
498
+ const rawTags = entry.tags;
499
+ const tags = Array.isArray(rawTags) ? rawTags.filter((t) => typeof t === "string" && t.trim() !== "") : [];
500
+ out[name] = tags.length ? { source_query: query, tags } : { source_query: query };
501
+ }
502
+ return out;
503
+ }
504
+ var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
412
505
  var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
506
+ var DEFAULT_INJECT_TIMEOUT_MS = 7e3;
413
507
  var REFLECT_BUDGETS = ["low", "mid", "high"];
414
508
  function resolveReflectBudget(raw) {
415
509
  const value = raw.reflectBudget;
@@ -436,6 +530,31 @@ function resolveObservationScopes(raw) {
436
530
  }
437
531
  return DEFAULT_OBSERVATION_SCOPES;
438
532
  }
533
+ function resolveDefaultBankConfig(raw) {
534
+ const value = raw;
535
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
536
+ const out = {};
537
+ for (const [key, v] of Object.entries(value)) {
538
+ if (PLUGIN_GOVERNED_BANK_FIELDS.includes(key)) {
539
+ log.warn(
540
+ "config",
541
+ `ignoring defaultBankConfig.${key} \u2014 the plugin manages this field itself` + (key === "retain_extraction_mode" ? " (set retainExtractionMode instead)" : "")
542
+ );
543
+ continue;
544
+ }
545
+ out[key] = v;
546
+ }
547
+ return out;
548
+ }
549
+ var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
550
+ function resolveAutoInject(raw) {
551
+ if (raw.autoReflect !== void 0) {
552
+ const replacement = raw.autoReflect === false ? "none" : "reflect";
553
+ log.warn("config", `autoReflect is deprecated \u2014 use autoInject: "${replacement}" instead`);
554
+ }
555
+ if (AUTO_INJECT_MODES.includes(raw.autoInject)) return raw.autoInject;
556
+ return raw.autoReflect === false ? "none" : "reflect";
557
+ }
439
558
  function resolveConfig(raw = {}) {
440
559
  const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
441
560
  const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
@@ -465,17 +584,31 @@ function resolveConfig(raw = {}) {
465
584
  retainSessions: raw.retainSessions ?? true,
466
585
  // write sessions back by default, every harness
467
586
  manageBankConfig: raw.manageBankConfig ?? true,
587
+ retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
588
+ defaultBankConfig: resolveDefaultBankConfig(raw.defaultBankConfig),
468
589
  maxParallelRetains: raw.maxParallelRetains || 10,
469
- reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
590
+ reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
470
591
  // Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
471
592
  // reflect already set), but never let it LOWER the tool below the default — a short window is
472
593
  // set to bound the automatic hook, not to cut off a call the agent is waiting on.
473
594
  reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
595
+ injectTimeoutMs: raw.injectTimeoutMs || DEFAULT_INJECT_TIMEOUT_MS,
474
596
  reflectBudget: resolveReflectBudget(raw),
475
- autoReflect: raw.autoReflect ?? true,
476
- pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
597
+ autoInject: resolveAutoInject(raw),
598
+ pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
599
+ // Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
600
+ // keys and reach the API as garbage, so it is rejected like any other non-object.
601
+ recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
602
+ toolGuideExtra: typeof raw.toolGuideExtra === "string" && raw.toolGuideExtra.trim() ? raw.toolGuideExtra : void 0,
603
+ // Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
604
+ // at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
605
+ // 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
606
+ // with no wording change at all. The cost is the guide's ~2KB re-sent per turn, which caches.
607
+ pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 1,
477
608
  pageTriggerType: pageTrigger.type,
478
609
  pageTriggerCron: pageTrigger.cron,
610
+ pages: resolvePages(raw.pages),
611
+ customPages: resolveCustomPages(raw.customPages),
479
612
  autoSeed: raw.autoSeed ?? true,
480
613
  seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
481
614
  codebaseSurvey: raw.codebaseSurvey ?? true,
@@ -486,11 +619,15 @@ function resolveConfig(raw = {}) {
486
619
  // Hostile input is a config typo, not an attack: keep only string entries so a stray number or
487
620
  // nested object cannot reach the API as a tag and fail the whole retain.
488
621
  retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
622
+ // Undefined, not "", when unset or blank: the retain call distinguishes "not configured" (use
623
+ // the built-in default) from a configured value, and an empty context would strip the default.
624
+ retainContext: typeof raw.retainContext === "string" && raw.retainContext.trim() !== "" ? raw.retainContext : void 0,
489
625
  retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
490
626
  Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
491
627
  ) : {},
492
628
  observationScopes: resolveObservationScopes(raw.observationScopes),
493
629
  banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
630
+ paths: raw.paths && typeof raw.paths === "object" ? raw.paths : {},
494
631
  logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
495
632
  autoUpdate: raw.autoUpdate ?? true
496
633
  };
@@ -507,7 +644,12 @@ function readRaw(path) {
507
644
  }
508
645
  function mergeRaw(a, b) {
509
646
  const { harnesses: _drop, ...flat } = b;
510
- return { ...a, ...flat, banks: { ...a.banks ?? {}, ...b.banks ?? {} } };
647
+ return {
648
+ ...a,
649
+ ...flat,
650
+ banks: { ...a.banks ?? {}, ...b.banks ?? {} },
651
+ paths: { ...a.paths ?? {}, ...b.paths ?? {} }
652
+ };
511
653
  }
512
654
  function applyLayer(raw, layer, harness) {
513
655
  let out = mergeRaw(raw, layer);
@@ -538,7 +680,11 @@ var ENV_KEYS = {
538
680
  maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
539
681
  reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
540
682
  reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
683
+ injectTimeoutMs: "HINDSIGHT_INJECT_TIMEOUT_MS",
541
684
  reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
685
+ autoInject: "HINDSIGHT_AUTO_INJECT",
686
+ pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
687
+ toolGuideExtra: "HINDSIGHT_TOOL_GUIDE_EXTRA",
542
688
  autoReflect: "HINDSIGHT_AUTO_REFLECT",
543
689
  pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
544
690
  pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
@@ -558,7 +704,8 @@ var ENV_KEYS = {
558
704
  // Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
559
705
  // a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
560
706
  retainTags: "HINDSIGHT_RETAIN_TAGS",
561
- manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
707
+ manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG",
708
+ retainExtractionMode: "HINDSIGHT_RETAIN_EXTRACTION_MODE"
562
709
  };
563
710
  var ENV_BOOLEANS = /* @__PURE__ */ new Set([
564
711
  "dynamicBankId",
@@ -579,6 +726,8 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
579
726
  "maxParallelRetains",
580
727
  "reflectTimeoutMs",
581
728
  "reflectToolTimeoutMs",
729
+ "injectTimeoutMs",
730
+ "pageSearchLimit",
582
731
  "pageRefreshEveryTurns",
583
732
  "seedLimit",
584
733
  "surveyBudgetUsd",