@vectorize-io/hindsight-coding-agents 0.5.2 → 0.5.3

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 +42 -8
  2. package/dist/antigravity-hook.js +286 -76
  3. package/dist/antigravity-statusline.js +17 -10
  4. package/dist/antigravity-stop-hook.js +297 -79
  5. package/dist/claude-hook.js +286 -76
  6. package/dist/claude-sessionstart-hook.js +252 -93
  7. package/dist/claude-stop-hook.js +297 -79
  8. package/dist/cline.js +74 -18
  9. package/dist/codex-hook.js +286 -76
  10. package/dist/codex-sessionstart-hook.js +252 -93
  11. package/dist/codex-stop-hook.js +297 -79
  12. package/dist/copilot-hook.js +286 -76
  13. package/dist/copilot-sessionstart-hook.js +252 -93
  14. package/dist/copilot-stop-hook.js +297 -79
  15. package/dist/cursor-hook.js +286 -76
  16. package/dist/cursor-sessionstart-hook.js +252 -93
  17. package/dist/cursor-stop-hook.js +297 -79
  18. package/dist/daemon-start.js +17 -10
  19. package/dist/dcode-hook.js +286 -76
  20. package/dist/dcode-sessionstart-hook.js +252 -93
  21. package/dist/dcode-stop-hook.js +297 -79
  22. package/dist/deepen.js +73 -19
  23. package/dist/devin-hook.js +286 -76
  24. package/dist/devin-sessionstart-hook.js +252 -93
  25. package/dist/devin-stop-hook.js +297 -79
  26. package/dist/droid-hook.js +286 -76
  27. package/dist/droid-sessionstart-hook.js +252 -93
  28. package/dist/droid-stop-hook.js +297 -79
  29. package/dist/dsh.js +111 -53
  30. package/dist/grok-hook.js +286 -76
  31. package/dist/grok-sessionstart-hook.js +252 -93
  32. package/dist/grok-stop-hook.js +297 -79
  33. package/dist/hindsight-seed.js +17 -10
  34. package/dist/index.js +113 -55
  35. package/dist/installer.js +383 -218
  36. package/dist/kilo.js +113 -55
  37. package/dist/mcp-server.js +67 -17
  38. package/dist/opencode2.js +113 -55
  39. package/dist/pi.js +112 -54
  40. package/dist/prime-agent.js +112 -54
  41. package/dist/qwen-hook.js +286 -76
  42. package/dist/qwen-sessionstart-hook.js +252 -93
  43. package/dist/qwen-stop-hook.js +297 -79
  44. package/dist/status.js +67 -17
  45. package/dist/zcode-hook.js +2920 -0
  46. package/dist/zcode-sessionstart-hook.js +3487 -0
  47. package/dist/zcode-stop-hook.js +3188 -0
  48. package/package.json +6 -3
  49. package/plugin.json +1 -1
  50. package/skill/SKILL.md +17 -7
@@ -14989,6 +14989,7 @@ function pagesFor(project) {
14989
14989
  var PAGE_MAX_TOKENS = 4096;
14990
14990
  var PAGE_TAGS_MATCH = "all";
14991
14991
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
14992
+ var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
14992
14993
  var CRON_FIELD_RANGES = [
14993
14994
  [0, 59],
14994
14995
  // minute
@@ -15042,14 +15043,23 @@ function pageTriggerFor(trigger, bank, page) {
15042
15043
  function buildPageTrigger(cfg = {}) {
15043
15044
  const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
15044
15045
  switch (cfg.pageTriggerType) {
15045
- case "cron":
15046
- return { ...base, refresh_cron: cfg.pageTriggerCron };
15046
+ case "auto-refresh":
15047
+ return { ...base, refresh_after_consolidation: true };
15047
15048
  case "manual":
15048
15049
  return { ...base, refresh_after_consolidation: false };
15050
+ // "cron" and an unset type alike: the default schedule stands in for a missing expression, so
15051
+ // a trigger built from a partial config is never a cron trigger with nothing to fire on.
15049
15052
  default:
15050
- return { ...base, refresh_after_consolidation: true };
15053
+ return { ...base, refresh_cron: cfg.pageTriggerCron || DEFAULT_PAGE_TRIGGER_CRON };
15051
15054
  }
15052
15055
  }
15056
+ function pageTriggerDrifted(current2, desired) {
15057
+ return current2.tags_match !== desired.tags_match || (current2.refresh_cron ?? null) !== (desired.refresh_cron ?? null) || Boolean(current2.refresh_after_consolidation) !== Boolean(desired.refresh_after_consolidation);
15058
+ }
15059
+ function pageTriggerPatch(desired) {
15060
+ if (desired.refresh_after_consolidation === false) return { ...desired, refresh_cron: null };
15061
+ return desired;
15062
+ }
15053
15063
  var CODING_BANK_TEMPLATE = {
15054
15064
  version: "1",
15055
15065
  bank: {
@@ -15608,14 +15618,14 @@ var HindsightClient = class {
15608
15618
  if (r.status !== 409) created++;
15609
15619
  } else {
15610
15620
  const sourceDrift = hit.description !== page.source_query;
15611
- const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
15621
+ const triggerDrift = hit.trigger != null && pageTriggerDrifted(hit.trigger, body.trigger);
15612
15622
  if (!sourceDrift && !triggerDrift) continue;
15613
15623
  const patch = {};
15614
15624
  if (sourceDrift) {
15615
15625
  patch.source_query = page.source_query;
15616
15626
  patch.tags = page.tags;
15617
15627
  }
15618
- if (triggerDrift) patch.trigger = pageTrigger;
15628
+ if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
15619
15629
  const r = await this.req(
15620
15630
  "PATCH",
15621
15631
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
@@ -15631,10 +15641,42 @@ var HindsightClient = class {
15631
15641
  updated++;
15632
15642
  }
15633
15643
  }
15644
+ const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
15634
15645
  this.log(
15635
- `[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
15646
+ `[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged` + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
15636
15647
  );
15637
15648
  }
15649
+ /**
15650
+ * Bring the captured initiative pages onto the same refresh policy as the seeded taxonomy.
15651
+ *
15652
+ * `captureInitiative` stamps this very trigger when it creates a page, so on a bank seeded under
15653
+ * an older default they are the same drift as the taxonomy — and on a real repo they are most of
15654
+ * it: five taxonomy pages against one page per initiative, each an LLM synthesis per
15655
+ * consolidation under the auto-refresh that used to be the default (#3506).
15656
+ *
15657
+ * Only the trigger is touched. Their `name` and `source_query` are written once, from the
15658
+ * initiative's own title, and re-stating either would rebuild a page whose question never
15659
+ * changed. The tree read above is reused rather than re-fetched.
15660
+ */
15661
+ async resyncInitiativeTriggers(roots, pageTrigger) {
15662
+ const folder = roots.find(
15663
+ (n) => n.kind === "folder" && (n.name || "").toLowerCase() === "initiatives"
15664
+ );
15665
+ let updated = 0;
15666
+ for (const page of folder?.children ?? []) {
15667
+ if (page.kind !== "page" || page.trigger == null) continue;
15668
+ const desired = pageTriggerFor(pageTrigger, this.bank, page.name);
15669
+ if (!pageTriggerDrifted(page.trigger, desired)) continue;
15670
+ const r = await this.req(
15671
+ "PATCH",
15672
+ this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
15673
+ { trigger: pageTriggerPatch(desired) }
15674
+ );
15675
+ if ([404, 405, 501].includes(r.status)) break;
15676
+ updated++;
15677
+ }
15678
+ return updated;
15679
+ }
15638
15680
  /** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
15639
15681
  slugify(s) {
15640
15682
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
@@ -15656,11 +15698,13 @@ var HindsightClient = class {
15656
15698
  let pageId = args.relatesToPageId;
15657
15699
  if (!pageId) {
15658
15700
  const folderId = await this.ensureFolder("Initiatives");
15701
+ const subject = this.project ?? this.bank;
15659
15702
  const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
15660
15703
  name: args.title,
15661
- source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.`,
15704
+ source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(subject),
15662
15705
  parent_id: folderId,
15663
15706
  tags: ["knowledge:feature-work"],
15707
+ max_tokens: PAGE_MAX_TOKENS,
15664
15708
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
15665
15709
  });
15666
15710
  try {
@@ -15703,17 +15747,22 @@ var HindsightClient = class {
15703
15747
  var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
15704
15748
  var DEFAULT_DAEMON_PORT = 9077;
15705
15749
  var DEFAULT_DAEMON_PROFILE = "coding-agent";
15706
- function resolvePageTriggerType(raw) {
15707
- if (raw.pageTriggerType === "manual") return "manual";
15708
- if (raw.pageTriggerType === "cron") {
15709
- const cron = raw.pageTriggerCron?.trim();
15710
- if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
15750
+ function resolvePageTrigger(raw) {
15751
+ if (raw.pageTriggerType === "manual") return { type: "manual" };
15752
+ if (raw.pageTriggerType === "auto-refresh") return { type: "auto-refresh" };
15753
+ if (raw.pageTriggerType !== void 0 && raw.pageTriggerType !== "cron")
15711
15754
  log.warn(
15712
15755
  "config",
15713
- cron ? `pageTriggerCron ${JSON.stringify(cron)} has a malformed hashed field \u2014 write \`H\` or \`H(<lo>-<hi>)\` within the field's own range, e.g. "H H(0-5) * * *" \u2014 falling back to "auto-refresh"` : 'pageTriggerType "cron" needs pageTriggerCron (UTC 5-field, e.g. "H H * * *") \u2014 falling back to "auto-refresh"'
15756
+ `ignoring pageTriggerType=${JSON.stringify(raw.pageTriggerType)} \u2014 expected cron|auto-refresh|manual`
15714
15757
  );
15715
- }
15716
- return "auto-refresh";
15758
+ const cron = raw.pageTriggerCron?.trim();
15759
+ if (!cron) return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
15760
+ if (!isHashedCron(cron) || parseHashedCron(cron)) return { type: "cron", cron };
15761
+ log.warn(
15762
+ "config",
15763
+ `pageTriggerCron ${JSON.stringify(cron)} has a malformed hashed field \u2014 write \`H\` or \`H(<lo>-<hi>)\` within the field's own range, e.g. "H H(0-5) * * *" \u2014 falling back to ${JSON.stringify(DEFAULT_PAGE_TRIGGER_CRON)}`
15764
+ );
15765
+ return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
15717
15766
  }
15718
15767
  var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
15719
15768
  var REFLECT_BUDGETS = ["low", "mid", "high"];
@@ -15745,6 +15794,7 @@ function resolveObservationScopes(raw) {
15745
15794
  function resolveConfig(raw = {}) {
15746
15795
  const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
15747
15796
  const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
15797
+ const pageTrigger = resolvePageTrigger(raw);
15748
15798
  return {
15749
15799
  serverMode,
15750
15800
  // Daemon mode resolves the URL HERE rather than at each call site: every entry point already
@@ -15779,8 +15829,8 @@ function resolveConfig(raw = {}) {
15779
15829
  reflectBudget: resolveReflectBudget(raw),
15780
15830
  autoReflect: raw.autoReflect ?? true,
15781
15831
  pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
15782
- pageTriggerType: resolvePageTriggerType(raw),
15783
- pageTriggerCron: raw.pageTriggerCron?.trim() || void 0,
15832
+ pageTriggerType: pageTrigger.type,
15833
+ pageTriggerCron: pageTrigger.cron,
15784
15834
  autoSeed: raw.autoSeed ?? true,
15785
15835
  seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
15786
15836
  codebaseSurvey: raw.codebaseSurvey ?? true,
@@ -17254,7 +17304,7 @@ async function buildSessionStartContext(args) {
17254
17304
  }
17255
17305
 
17256
17306
  // src/core/hook.ts
17257
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
17307
+ import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
17258
17308
 
17259
17309
  // src/core/inject.ts
17260
17310
  function buildReflectQuery(prompt) {
@@ -17285,6 +17335,49 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
17285
17335
  ` + memory + "\n</hindsight_memory>";
17286
17336
  }
17287
17337
 
17338
+ // src/core/turn-journal.ts
17339
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync7, statSync } from "fs";
17340
+ import { tmpdir as tmpdir4 } from "os";
17341
+ import { dirname as dirname10, join as join13 } from "path";
17342
+
17343
+ // src/core/transcript-util.ts
17344
+ var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
17345
+ function stripInjectedMemory(s) {
17346
+ return s.replace(MEMORY_TAG_RE, "");
17347
+ }
17348
+ var TARGET_KEYS = [
17349
+ "file_path",
17350
+ "path",
17351
+ "notebook_path",
17352
+ "command",
17353
+ "pattern",
17354
+ "query",
17355
+ "url",
17356
+ "name",
17357
+ "id"
17358
+ ];
17359
+ var ACTION_TARGET_CAP = 100;
17360
+ function actionLine(tool, input) {
17361
+ let target = "";
17362
+ if (input && typeof input === "object") {
17363
+ const rec = input;
17364
+ for (const k of TARGET_KEYS) {
17365
+ const v = rec[k];
17366
+ if (typeof v === "string" && v.trim()) {
17367
+ target = v.trim().split("\n")[0];
17368
+ break;
17369
+ }
17370
+ }
17371
+ } else if (typeof input === "string") {
17372
+ target = input.trim().split("\n")[0];
17373
+ }
17374
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
17375
+ return target ? `${tool} ${target}` : tool;
17376
+ }
17377
+
17378
+ // src/core/turn-journal.ts
17379
+ var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
17380
+
17288
17381
  // src/core/hook.ts
17289
17382
  var HOOK_REFLECT_CAP_MS = 25e3;
17290
17383
  async function buildHookOutput(args) {
@@ -17595,46 +17688,11 @@ var RuntimeCore = class {
17595
17688
  };
17596
17689
 
17597
17690
  // src/core/jsonl.ts
17598
- import { closeSync, openSync, readSync, statSync } from "fs";
17691
+ import { closeSync, openSync, readSync, statSync as statSync2 } from "fs";
17599
17692
  import { StringDecoder } from "string_decoder";
17600
17693
  var CHUNK_BYTES = 64 * 1024;
17601
17694
  var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
17602
17695
 
17603
- // src/core/transcript-util.ts
17604
- var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
17605
- function stripInjectedMemory(s) {
17606
- return s.replace(MEMORY_TAG_RE, "");
17607
- }
17608
- var TARGET_KEYS = [
17609
- "file_path",
17610
- "path",
17611
- "notebook_path",
17612
- "command",
17613
- "pattern",
17614
- "query",
17615
- "url",
17616
- "name",
17617
- "id"
17618
- ];
17619
- var ACTION_TARGET_CAP = 100;
17620
- function actionLine(tool, input) {
17621
- let target = "";
17622
- if (input && typeof input === "object") {
17623
- const rec = input;
17624
- for (const k of TARGET_KEYS) {
17625
- const v = rec[k];
17626
- if (typeof v === "string" && v.trim()) {
17627
- target = v.trim().split("\n")[0];
17628
- break;
17629
- }
17630
- }
17631
- } else if (typeof input === "string") {
17632
- target = input.trim().split("\n")[0];
17633
- }
17634
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
17635
- return target ? `${tool} ${target}` : tool;
17636
- }
17637
-
17638
17696
  // src/core/transcript-pi.ts
17639
17697
  function renderMessage(m) {
17640
17698
  if (!m || typeof m !== "object") return [];