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

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 (47) hide show
  1. package/README.md +44 -3
  2. package/dist/antigravity-hook.js +142 -9
  3. package/dist/antigravity-statusline.js +42 -4
  4. package/dist/antigravity-stop-hook.js +222 -59
  5. package/dist/claude-hook.js +142 -9
  6. package/dist/claude-sessionstart-hook.js +144 -9
  7. package/dist/claude-stop-hook.js +222 -59
  8. package/dist/cline.js +148 -59
  9. package/dist/codex-hook.js +142 -9
  10. package/dist/codex-sessionstart-hook.js +144 -9
  11. package/dist/codex-stop-hook.js +222 -59
  12. package/dist/copilot-hook.js +142 -9
  13. package/dist/copilot-sessionstart-hook.js +144 -9
  14. package/dist/copilot-stop-hook.js +222 -59
  15. package/dist/cursor-hook.js +142 -9
  16. package/dist/cursor-sessionstart-hook.js +144 -9
  17. package/dist/cursor-stop-hook.js +222 -59
  18. package/dist/daemon-start.js +36 -2
  19. package/dist/dcode-hook.js +142 -9
  20. package/dist/dcode-sessionstart-hook.js +144 -9
  21. package/dist/dcode-stop-hook.js +222 -59
  22. package/dist/deepen.js +97 -14
  23. package/dist/devin-hook.js +142 -9
  24. package/dist/devin-sessionstart-hook.js +144 -9
  25. package/dist/devin-stop-hook.js +222 -59
  26. package/dist/droid-hook.js +2710 -0
  27. package/dist/droid-sessionstart-hook.js +3328 -0
  28. package/dist/droid-stop-hook.js +2970 -0
  29. package/dist/dsh.js +153 -60
  30. package/dist/grok-hook.js +142 -9
  31. package/dist/grok-sessionstart-hook.js +144 -9
  32. package/dist/grok-stop-hook.js +222 -59
  33. package/dist/hindsight-seed.js +42 -4
  34. package/dist/index.js +148 -59
  35. package/dist/installer.js +155 -13
  36. package/dist/kilo.js +148 -59
  37. package/dist/mcp-server.js +474 -133
  38. package/dist/opencode2.js +148 -59
  39. package/dist/pi.js +148 -59
  40. package/dist/prime-agent.js +148 -59
  41. package/dist/qwen-hook.js +142 -9
  42. package/dist/qwen-sessionstart-hook.js +144 -9
  43. package/dist/qwen-stop-hook.js +222 -59
  44. package/dist/status.js +65 -7
  45. package/package.json +6 -3
  46. package/plugin.json +1 -1
  47. package/skill/SKILL.md +26 -2
package/dist/status.js CHANGED
@@ -270,9 +270,13 @@ function isOptedIn(config, directory) {
270
270
  const pathMap = config.mapPathToBank;
271
271
  return Boolean(pathMap && directories.some((candidate) => mapLookup(pathMap, candidate)));
272
272
  }
273
- function deriveBankId(config, directory, harness = "coding", sessionRoot) {
273
+ function mappedBank(config, directory, sessionRoot) {
274
274
  const pathMap = config.mapPathToBank;
275
- const mapped = directory && pathMap ? lookupDirectories(config, directory, sessionRoot).map((candidate) => mapLookup(pathMap, candidate)).find((bank) => bank !== void 0) : void 0;
275
+ if (!directory || !pathMap) return void 0;
276
+ return lookupDirectories(config, directory, sessionRoot).map((candidate) => mapLookup(pathMap, candidate)).find((bank) => bank !== void 0);
277
+ }
278
+ function deriveBankId(config, directory, harness = "coding", sessionRoot) {
279
+ const mapped = mappedBank(config, directory, sessionRoot);
276
280
  if (mapped) return mapped;
277
281
  const dynamic = config.dynamicBankId ?? !config.bankId;
278
282
  if (!dynamic) return config.bankId || DEFAULT_BANK_NAME;
@@ -311,6 +315,7 @@ import { fileURLToPath } from "url";
311
315
  var DEFAULT_SEED_LIMIT = 300;
312
316
 
313
317
  // src/core/missions.ts
318
+ import { createHash } from "crypto";
314
319
  var GIT_MISSION = "You are ingesting a single git commit: its message and its full diff. Extract the concrete technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities (functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and literal values verbatim. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123, PROJ-123) are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY, so a later question about that issue or PR retrieves this decision.";
315
320
  var GITLOG_MISSION = "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) \u2014 the project's recent commit-message history, newest first. Extract the project's INITIATIVES, FEATURES, ENHANCEMENTS, and notable changes or THEMES over time \u2014 what the project has been working on and how it has evolved. Do NOT extract per-line code detail (there is no diff to draw it from). Group related commits into a coherent initiative/theme where the messages make that clear; preserve exact identifiers and literal values verbatim when quoting a subject line. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY \u2014 they are how future sessions will ask about this work.";
316
321
  var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Do not invent; capture only what was actually settled.`;
@@ -422,6 +427,56 @@ function pagesFor(project) {
422
427
  var PAGE_MAX_TOKENS = 4096;
423
428
  var PAGE_TAGS_MATCH = "all";
424
429
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
430
+ var CRON_FIELD_RANGES = [
431
+ [0, 59],
432
+ // minute
433
+ [0, 23],
434
+ // hour
435
+ [1, 31],
436
+ // day of month
437
+ [1, 12],
438
+ // month
439
+ [0, 6]
440
+ // day of week
441
+ ];
442
+ var HASHED_FIELD = /^H(?:\((\d+)-(\d+)\))?$/;
443
+ function isHashedCron(cron) {
444
+ return /(^|\s)H/.test(cron);
445
+ }
446
+ function parseHashedCron(cron) {
447
+ const fields = cron.trim().split(/\s+/);
448
+ if (fields.length !== CRON_FIELD_RANGES.length) return void 0;
449
+ for (const [i, field] of fields.entries()) {
450
+ if (!field.startsWith("H")) continue;
451
+ const m = HASHED_FIELD.exec(field);
452
+ if (!m) return void 0;
453
+ if (m[1] === void 0) continue;
454
+ const [lo, hi] = [Number(m[1]), Number(m[2])];
455
+ const [min, max] = CRON_FIELD_RANGES[i];
456
+ if (lo > hi || lo < min || hi > max) return void 0;
457
+ }
458
+ return fields;
459
+ }
460
+ function hashedValue(seed, field, lo, hi) {
461
+ const digest = createHash("sha256").update(`${seed}\0${field}`).digest();
462
+ return lo + digest.readUInt32BE(0) % (hi - lo + 1);
463
+ }
464
+ function expandCronHash(cron, seed) {
465
+ if (!isHashedCron(cron)) return cron;
466
+ const fields = parseHashedCron(cron);
467
+ if (!fields) return cron;
468
+ return fields.map((field, i) => {
469
+ const m = HASHED_FIELD.exec(field);
470
+ if (!m) return field;
471
+ const [lo, hi] = m[1] === void 0 ? CRON_FIELD_RANGES[i] : [Number(m[1]), Number(m[2])];
472
+ return String(hashedValue(seed, i, lo, hi));
473
+ }).join(" ");
474
+ }
475
+ function pageTriggerFor(trigger, bank, page) {
476
+ const cron = trigger.refresh_cron;
477
+ if (!cron || !isHashedCron(cron)) return trigger;
478
+ return { ...trigger, refresh_cron: expandCronHash(cron, `${bank}\0${page}`) };
479
+ }
425
480
  function buildPageTrigger(cfg2 = {}) {
426
481
  const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
427
482
  switch (cfg2.pageTriggerType) {
@@ -956,7 +1011,9 @@ var HindsightClient = class {
956
1011
  source_query: page.source_query,
957
1012
  tags: page.tags,
958
1013
  max_tokens: PAGE_MAX_TOKENS,
959
- trigger: pageTrigger
1014
+ // Resolved HERE, not in `buildPageTrigger`: a hashed cron (`H`) needs the page's identity,
1015
+ // and one trigger is built per session for all of them.
1016
+ trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
960
1017
  };
961
1018
  if (!hit) {
962
1019
  const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
@@ -994,7 +1051,7 @@ var HindsightClient = class {
994
1051
  }
995
1052
  }
996
1053
  this.log(
997
- `[bank] knowledge pages seeded on ${this.bank}: ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
1054
+ `[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
998
1055
  );
999
1056
  }
1000
1057
  /** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
@@ -1023,7 +1080,7 @@ var HindsightClient = class {
1023
1080
  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.`,
1024
1081
  parent_id: folderId,
1025
1082
  tags: ["knowledge:feature-work"],
1026
- trigger: args.pageTrigger ?? buildPageTrigger()
1083
+ trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1027
1084
  });
1028
1085
  try {
1029
1086
  const j = await r.json();
@@ -1068,10 +1125,11 @@ var DEFAULT_DAEMON_PROFILE = "coding-agent";
1068
1125
  function resolvePageTriggerType(raw) {
1069
1126
  if (raw.pageTriggerType === "manual") return "manual";
1070
1127
  if (raw.pageTriggerType === "cron") {
1071
- if (raw.pageTriggerCron?.trim()) return "cron";
1128
+ const cron = raw.pageTriggerCron?.trim();
1129
+ if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
1072
1130
  log.warn(
1073
1131
  "config",
1074
- 'pageTriggerType "cron" needs pageTriggerCron (UTC 5-field, e.g. "0 3 * * *") \u2014 falling back to "auto-refresh"'
1132
+ 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"'
1075
1133
  );
1076
1134
  }
1077
1135
  return "auto-refresh";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",
@@ -31,7 +31,10 @@
31
31
  "hindsight-devin-hook": "dist/devin-hook.js",
32
32
  "hindsight-qwen-hook": "dist/qwen-hook.js",
33
33
  "hindsight-qwen-sessionstart-hook": "dist/qwen-sessionstart-hook.js",
34
- "hindsight-qwen-stop-hook": "dist/qwen-stop-hook.js"
34
+ "hindsight-qwen-stop-hook": "dist/qwen-stop-hook.js",
35
+ "hindsight-droid-hook": "dist/droid-hook.js",
36
+ "hindsight-droid-sessionstart-hook": "dist/droid-sessionstart-hook.js",
37
+ "hindsight-droid-stop-hook": "dist/droid-stop-hook.js"
35
38
  },
36
39
  "exports": {
37
40
  ".": {
@@ -94,7 +97,7 @@
94
97
  },
95
98
  "overrides": {
96
99
  "esbuild": ">=0.25.0 <1.0.0",
97
- "fast-uri": ">=3.1.5 <4.0.0",
100
+ "fast-uri": ">=3.1.6 <4.0.0",
98
101
  "hono": ">=4.12.34 <5.0.0",
99
102
  "ip-address": ">=10.3.1 <11.0.0",
100
103
  "postcss": ">=8.5.23 <9.0.0",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hindsight-coding-agents",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Long-term project memory for coding agents",
5
5
  "skills": "./skill",
6
6
  "hooks": "./hooks/hooks.json",
package/skill/SKILL.md CHANGED
@@ -210,14 +210,14 @@ hook by Codex...), so one shared config serves several agents side by side:
210
210
  | `autoReflect` | `true` | inject a one-time reflect synthesis on the session's **first prompt**. `false` = tool-only reflect: nothing is injected; the agent searches knowledge pages first and reflects only when they are too shallow |
211
211
  | `pageRefreshEveryTurns` | `10` | refetch the knowledge pages and re-inject the page roster + tool guide every N user turns |
212
212
  | `pageTriggerType` | `"auto-refresh"` | when NEW knowledge pages refresh, i.e. what keeping them current costs — `"auto-refresh"` after every consolidation that produced new material, `"cron"` on `pageTriggerCron` only, `"manual"` never on their own. Auto-refresh is the most current and the most expensive: one synthesis per page per consolidation. Maps to the page's `trigger.refresh_after_consolidation` in the Hindsight API (`true` for auto-refresh, `false` for manual) |
213
- | `pageTriggerCron` | — | schedule for `pageTriggerType: "cron"` — UTC, standard 5-field cron, e.g. `"0 3 * * *"`. Sets the page's `trigger.refresh_cron`, which the API treats as mutually exclusive with `refresh_after_consolidation`; a scheduled refresh is skipped when nothing changed |
213
+ | `pageTriggerCron` | — | schedule for `pageTriggerType: "cron"` — UTC, standard 5-field cron, e.g. `"0 3 * * *"`. Sets the page's `trigger.refresh_cron`, which the API treats as mutually exclusive with `refresh_after_consolidation`; a scheduled refresh is skipped when nothing changed. Write a field as `H` to give each page its own value there — see **Spreading refreshes with `H`** below |
214
214
  | `autoSeed` | `true` | SessionStart: auto-seed a cold repo's bank from git history |
215
215
  | `seedLimit` | `300` | auto-seed: most-recent-N-commits cap |
216
216
  | `codebaseSurvey` | `true` | SessionStart: headless survey of a cold repo's structure, run under the current harness's own CLI (claude/codex/antigravity/opencode), falling back to any available agent |
217
217
  | `surveyModel` | `haiku` | model for the survey — Claude recipe only (`claude -p --model`); other agents use their configured default |
218
218
  | `surveyBudgetUsd` | `2` | survey spend cap — Claude recipe only (`claude -p --max-budget-usd`); other agents rely on their read-only sandbox |
219
219
  | `surveyRefreshCommits` | `20` | re-run the survey at SessionStart once this many commits have accrued since the last one, so the structural pages track an architecture that keeps moving (`0` = survey a cold repo only, never again) |
220
- | `retainSessions` | `true` | session write-back, honored by every harness: hook harnesses write the transcript on Stop, plugin harnesses (opencode, opencode 2, Kilo) upsert it every turn plus an idle flush that captures the reply the per-turn pass can't see. Set `false` — globally, per harness, or per bank — to stop writing transcripts (the background history import stops with it) while recall, git ingest and the memory tools keep working |
220
+ | `retainSessions` | `true` | session write-back, honored by every harness: hook harnesses write the transcript on Stop, Factory Droid also writes on its cancellation notification, and plugin harnesses (opencode, opencode 2, Kilo) upsert it every turn plus an idle flush that captures the reply the per-turn pass can't see. Set `false` - globally, per harness, or per bank - to stop writing transcripts (the background history import stops with it) while recall, git ingest and the memory tools keep working |
221
221
  | `maxParallelRetains` | `10` | cap on concurrent retain-related requests: drain()'s per-op polls plus deepen's chat/git retain pools. The API rate-limits bursts, not single requests — if you see 429s, lower this rather than raising it |
222
222
  | `logLevel` | `"info"` | plugin-log verbosity (`"debug"` \| `"info"` \| `"warn"` \| `"error"`); `HINDSIGHT_LOG_LEVEL` env overrides |
223
223
  | `autoUpdate` | `true` | keep the installed runtime current by itself: once a day a session start asks npm for the published version and, when it is newer, re-stages `~/.hindsight/coding-agents` in the background. It rewires no host config, so a release adding a **new** hook entry point still needs a manual `install`. Set `false` to pin the installed version; `disabled` stops it too, since an inert plugin should stay inert. Only ever replaces a runtime installed the documented way, via `npx` — a copy installed with `npm i -g`, vendored as a project dependency, or built from a checkout is left to whoever manages it (update those the way you installed them), and it needs `npx` on `PATH` |
@@ -230,6 +230,30 @@ belongs to the server: Hindsight creates a knowledge page with a delta refresh (
230
230
  page instead of rebuilding it) that doesn't reflect over sibling pages, and these settings merge
231
231
  over those defaults rather than replacing them.
232
232
 
233
+ ### Spreading refreshes with `H`
234
+
235
+ One `pageTriggerCron` is shared by every page in every repo you point this plugin at. So a literal
236
+ `"0 3 * * *"` does not schedule _a_ refresh at 03:00 — it schedules **all** of them at 03:00, five
237
+ pages per bank, on the same worker pool that serves retain. A session ingesting at 03:0x queues
238
+ behind the pile, and moving the hour just moves the pile.
239
+
240
+ Write a field as `H` and it is replaced, per page, by a value hashed from the bank id and the page
241
+ name. Each page gets its own slot, the same slot on every run:
242
+
243
+ | `pageTriggerCron` | what each page gets |
244
+ | ------------------ | ------------------------------------------------------ |
245
+ | `"H H * * *"` | once a day, at its own minute and hour |
246
+ | `"H * * * *"` | once an hour, at its own minute |
247
+ | `"H 3 * * *"` | daily at 03:MM — spread inside the hour you chose |
248
+ | `"H H(0-5) * * *"` | daily, spread across 00:00–05:59 only |
249
+ | `"0 3 * * *"` | no `H`, no hashing — exactly what it says, all at once |
250
+
251
+ `H` is [Jenkins' syntax](https://www.jenkins.io/doc/book/pipeline/syntax/#cron-syntax) for the same
252
+ problem. It never reaches the API: the plugin resolves it to an ordinary cron expression
253
+ (`"41 17 * * *"`) when it creates the page, so the schedule you see in the control plane is a plain
254
+ one you can edit. Hashing spreads pages out, it does not partition them — two pages can still land
255
+ on the same minute, just not all of them.
256
+
233
257
  **These settings apply to pages created from here on.** Changing them does not migrate the pages a
234
258
  repo already has: a page keeps the trigger it was created with, so a bank seeded before you set
235
259
  `"manual"` keeps refreshing on every consolidation. To move an existing page, change its trigger