@vectorize-io/hindsight-coding-agents 0.4.2 → 0.5.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 (46) hide show
  1. package/README.md +202 -51
  2. package/dist/antigravity-hook.js +637 -199
  3. package/dist/antigravity-statusline.js +219 -84
  4. package/dist/antigravity-stop-hook.js +654 -205
  5. package/dist/claude-hook.js +637 -199
  6. package/dist/claude-sessionstart-hook.js +863 -236
  7. package/dist/claude-stop-hook.js +654 -205
  8. package/dist/cline.js +589 -234
  9. package/dist/codex-hook.js +637 -199
  10. package/dist/codex-sessionstart-hook.js +863 -236
  11. package/dist/codex-stop-hook.js +654 -205
  12. package/dist/copilot-hook.js +637 -199
  13. package/dist/copilot-sessionstart-hook.js +863 -236
  14. package/dist/copilot-stop-hook.js +654 -205
  15. package/dist/cursor-hook.js +637 -199
  16. package/dist/cursor-sessionstart-hook.js +863 -236
  17. package/dist/cursor-stop-hook.js +654 -205
  18. package/dist/daemon-start.js +62 -43
  19. package/dist/dcode-hook.js +2577 -0
  20. package/dist/dcode-sessionstart-hook.js +3194 -0
  21. package/dist/dcode-stop-hook.js +2807 -0
  22. package/dist/deepen.js +361 -204
  23. package/dist/devin-hook.js +637 -199
  24. package/dist/devin-sessionstart-hook.js +863 -236
  25. package/dist/devin-stop-hook.js +654 -205
  26. package/dist/dsh.js +592 -235
  27. package/dist/grok-hook.js +637 -199
  28. package/dist/grok-sessionstart-hook.js +863 -236
  29. package/dist/grok-stop-hook.js +654 -205
  30. package/dist/hindsight-seed.js +222 -83
  31. package/dist/index.js +589 -234
  32. package/dist/installer.js +2343 -302
  33. package/dist/kilo.js +589 -234
  34. package/dist/mcp-server.js +363 -169
  35. package/dist/opencode2.js +30092 -0
  36. package/dist/pi.js +17650 -0
  37. package/dist/prime-agent.js +625 -260
  38. package/dist/qwen-hook.js +2577 -0
  39. package/dist/qwen-sessionstart-hook.js +3194 -0
  40. package/dist/qwen-stop-hook.js +2807 -0
  41. package/dist/status.js +300 -136
  42. package/hooks/hooks.json +37 -0
  43. package/index.js +10 -0
  44. package/package.json +15 -8
  45. package/plugin.json +16 -0
  46. package/skill/SKILL.md +114 -43
package/dist/deepen.js CHANGED
@@ -1,70 +1,213 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/deepen.ts
4
- import { execFileSync as execFileSync4 } from "child_process";
5
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync, writeFileSync } from "fs";
4
+ import { execFileSync as execFileSync3 } from "child_process";
5
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, unlinkSync, writeFileSync } from "fs";
6
6
  import { tmpdir as tmpdir2 } from "os";
7
- import { join as join6 } from "path";
7
+ import { join as join8 } from "path";
8
8
 
9
9
  // src/core/bank.ts
10
- import { execFileSync } from "child_process";
11
10
  import { existsSync } from "fs";
12
11
  import { homedir } from "os";
13
- import { basename, dirname, join, normalize, sep } from "path";
12
+ import { basename, dirname as dirname3, join as join3, normalize, sep } from "path";
13
+
14
+ // src/core/diag.ts
15
+ import { appendFileSync as appendFileSync2 } from "fs";
16
+
17
+ // src/core/log.ts
18
+ import { appendFileSync, mkdirSync } from "fs";
19
+ import { tmpdir } from "os";
20
+ import { dirname, join } from "path";
21
+ var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
22
+ var current = ["debug", "info", "warn", "error"].find(
23
+ (l) => l === process.env.HINDSIGHT_LOG_LEVEL
24
+ ) ?? "info";
25
+ function setLogLevel(level) {
26
+ if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
27
+ }
28
+ function logFilePath() {
29
+ return process.env.HINDSIGHT_LOG_FILE || join(tmpdir(), "hindsight-coding-agent", "plugin.log");
30
+ }
31
+ function write(level, scope, msg, extra) {
32
+ if (WEIGHT[level] < WEIGHT[current]) return;
33
+ try {
34
+ const file = logFilePath();
35
+ mkdirSync(dirname(file), { recursive: true });
36
+ appendFileSync(
37
+ file,
38
+ `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
39
+ );
40
+ } catch {
41
+ }
42
+ }
43
+ var log = {
44
+ debug: (scope, msg, extra) => write("debug", scope, msg, extra),
45
+ info: (scope, msg, extra) => write("info", scope, msg, extra),
46
+ warn: (scope, msg, extra) => write("warn", scope, msg, extra),
47
+ error: (scope, msg, extra) => write("error", scope, msg, extra)
48
+ };
49
+ function describeError(value, maxChars = 200) {
50
+ const parts = [];
51
+ const seen = /* @__PURE__ */ new Set();
52
+ let current2 = value;
53
+ while (current2 && !seen.has(current2)) {
54
+ seen.add(current2);
55
+ const error = current2;
56
+ const text = typeof error.message === "string" ? error.message : String(current2);
57
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
58
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
59
+ current2 = error.cause;
60
+ }
61
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
62
+ }
63
+
64
+ // src/core/diag.ts
65
+ function diagFilePath() {
66
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
67
+ }
68
+ function diag(harness, event, extra = {}) {
69
+ log.debug(harness, `diag:${event}`, extra);
70
+ try {
71
+ appendFileSync2(
72
+ diagFilePath(),
73
+ JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
74
+ );
75
+ } catch {
76
+ }
77
+ }
78
+
79
+ // src/core/git-layout.ts
80
+ import { lstatSync, readFileSync, realpathSync } from "fs";
81
+ import { dirname as dirname2, isAbsolute, join as join2, resolve } from "path";
82
+ var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
83
+ var ATTEMPTS = 3;
84
+ var BACKOFF_MS = 20;
85
+ function errorCode(error) {
86
+ return error?.code ?? "";
87
+ }
88
+ function sleepSync(ms) {
89
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
90
+ }
91
+ var TransientProbeError = class extends Error {
92
+ };
93
+ function entryKind(path) {
94
+ try {
95
+ const st = lstatSync(path);
96
+ return st.isDirectory() ? "dir" : "file";
97
+ } catch (error) {
98
+ if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
99
+ return "none";
100
+ }
101
+ }
102
+ function readTextOrNull(path) {
103
+ try {
104
+ return readFileSync(path, "utf8");
105
+ } catch (error) {
106
+ if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
107
+ return null;
108
+ }
109
+ }
110
+ function gitDirFromPointer(text, holder) {
111
+ const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
112
+ if (!match) return null;
113
+ const target = match[1];
114
+ return isAbsolute(target) ? target : resolve(holder, target);
115
+ }
116
+ function commonDirOf(gitDir) {
117
+ const pointer = entryKind(join2(gitDir, "commondir")) === "file" ? readTextOrNull(join2(gitDir, "commondir"))?.trim() : null;
118
+ if (!pointer) return gitDir;
119
+ return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
120
+ }
121
+ function isBare(commonDir) {
122
+ const config = readTextOrNull(join2(commonDir, "config"));
123
+ return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
124
+ }
125
+ function looksLikeBareRepository(directory) {
126
+ return entryKind(join2(directory, "HEAD")) === "file" && entryKind(join2(directory, "objects")) === "dir" && entryKind(join2(directory, "refs")) === "dir";
127
+ }
128
+ function canonical(path) {
129
+ try {
130
+ return realpathSync(path);
131
+ } catch {
132
+ return path;
133
+ }
134
+ }
135
+ function resolved(commonDir) {
136
+ if (entryKind(commonDir) !== "dir") return null;
137
+ const canonicalDir = canonical(commonDir);
138
+ return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
139
+ }
140
+ function probeOnce(directory) {
141
+ let current2 = resolve(directory);
142
+ for (; ; ) {
143
+ const dotGit = join2(current2, ".git");
144
+ const kind = entryKind(dotGit);
145
+ if (kind === "dir") {
146
+ const layout = resolved(commonDirOf(dotGit));
147
+ if (layout) return layout;
148
+ } else if (kind === "file") {
149
+ const text = readTextOrNull(dotGit);
150
+ const gitDir = text ? gitDirFromPointer(text, current2) : null;
151
+ const layout = gitDir ? resolved(commonDirOf(gitDir)) : null;
152
+ if (layout) return layout;
153
+ }
154
+ if (looksLikeBareRepository(current2)) {
155
+ const layout = resolved(current2);
156
+ if (layout) return layout;
157
+ }
158
+ const parent = dirname2(current2);
159
+ if (parent === current2) return { status: "absent" };
160
+ current2 = parent;
161
+ }
162
+ }
163
+ function probeGitLayout(directory) {
164
+ if (!directory) return { status: "absent" };
165
+ let last = "";
166
+ for (let attempt = 0; attempt < ATTEMPTS; attempt++) {
167
+ if (attempt) sleepSync(BACKOFF_MS * attempt);
168
+ try {
169
+ return probeOnce(directory);
170
+ } catch (error) {
171
+ last = error instanceof TransientProbeError ? error.message : errorCode(error) || "unknown";
172
+ }
173
+ }
174
+ return { status: "failed", reason: last };
175
+ }
14
176
 
15
177
  // src/core/template.ts
16
178
  var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
17
179
  function applyTemplate(template, resolvers, what) {
18
180
  return template.replace(PLACEHOLDER, (_, name) => {
19
- const resolve2 = resolvers[name];
20
- if (!resolve2) {
181
+ const resolve3 = resolvers[name];
182
+ if (!resolve3) {
21
183
  console.error(
22
184
  `hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
23
185
  );
24
186
  return "unknown";
25
187
  }
26
- return resolve2();
188
+ return resolve3();
27
189
  });
28
190
  }
29
191
 
30
192
  // src/core/bank.ts
31
193
  var DEFAULT_BANK_NAME = "coding";
32
194
  var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
33
- function getProjectRootFromGit(directory) {
34
- if (!directory) return null;
35
- try {
36
- const commonDir = execFileSync(
37
- "git",
38
- ["rev-parse", "--path-format=absolute", "--git-common-dir"],
39
- {
40
- cwd: directory,
41
- encoding: "utf-8",
42
- stdio: ["ignore", "pipe", "ignore"],
43
- timeout: 1e3,
44
- windowsHide: true
45
- }
46
- ).trim();
47
- if (!commonDir) return null;
48
- if (basename(commonDir) === ".git") return dirname(commonDir);
49
- if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
50
- return dirname(commonDir);
51
- }
52
- return commonDir;
53
- } catch {
54
- return null;
55
- }
56
- }
57
- function isBareRepository(commonDir) {
58
- try {
59
- return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
60
- encoding: "utf-8",
61
- stdio: ["ignore", "pipe", "ignore"],
62
- timeout: 1e3,
63
- env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
64
- }).trim() === "true";
65
- } catch {
66
- return false;
195
+ var BankResolutionError = class extends Error {
196
+ constructor(message) {
197
+ super(message);
198
+ this.name = "BankResolutionError";
67
199
  }
200
+ };
201
+ function resolveProjectRoot(directory) {
202
+ if (!directory) return { status: "absent" };
203
+ const layout = probeGitLayout(directory);
204
+ if (layout.status !== "resolved") return layout;
205
+ const commonDir = layout.commonDir;
206
+ if (basename(commonDir) === ".git") return { status: "resolved", root: dirname3(commonDir) };
207
+ if (basename(commonDir).startsWith(".") && layout.bare) {
208
+ return { status: "resolved", root: dirname3(commonDir) };
209
+ }
210
+ return { status: "resolved", root: commonDir };
68
211
  }
69
212
  function projectNameOf(directory, sessionRoot) {
70
213
  return gitProjectName(directory, true, sessionRoot);
@@ -74,7 +217,7 @@ function nearestExistingDir(directory) {
74
217
  let current2 = directory;
75
218
  while (current2) {
76
219
  if (existsSync(current2)) return current2;
77
- const parent = dirname(current2);
220
+ const parent = dirname3(current2);
78
221
  if (parent === current2) return "";
79
222
  current2 = parent;
80
223
  }
@@ -89,21 +232,29 @@ function mainWorktreeRoot(directory, sessionRoot = "") {
89
232
  sessionRoot,
90
233
  ...PROJECT_ROOT_ENV.map((v) => process.env[v] || "")
91
234
  ];
235
+ let failure = null;
92
236
  for (const candidate of candidates) {
93
- const root = candidate ? getProjectRootFromGit(candidate) : null;
94
- if (root) return root;
237
+ if (!candidate) continue;
238
+ const projectRoot = resolveProjectRoot(candidate);
239
+ if (projectRoot.status === "resolved") return projectRoot;
240
+ if (projectRoot.status === "failed") failure = projectRoot;
95
241
  }
96
- return null;
242
+ return failure ?? { status: "absent" };
97
243
  }
98
244
  function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
99
245
  if (resolveWorktrees) {
100
- const root = mainWorktreeRoot(directory, sessionRoot);
101
- if (root) return basename(root);
246
+ const projectRoot = mainWorktreeRoot(directory, sessionRoot);
247
+ if (projectRoot.status === "resolved") return basename(projectRoot.root);
248
+ if (projectRoot.status === "failed") {
249
+ throw new BankResolutionError(
250
+ `git probe failed for ${directory} (${projectRoot.reason}) \u2014 refusing to guess a bank id`
251
+ );
252
+ }
102
253
  }
103
254
  return dirName(sessionRoot || directory);
104
255
  }
105
256
  function configuredDir(dir) {
106
- const expanded = dir === "~" || dir.startsWith("~/") ? join(homedir(), dir.slice(1)) : dir;
257
+ const expanded = dir === "~" || dir.startsWith("~/") ? join3(homedir(), dir.slice(1)) : dir;
107
258
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
108
259
  }
109
260
  function isWithin(directory, configured) {
@@ -123,8 +274,8 @@ function mapLookup(map, directory) {
123
274
  function lookupDirectories(config, directory, sessionRoot = "") {
124
275
  const directories = [normalize(directory)];
125
276
  if (config.resolveWorktrees ?? true) {
126
- const root = mainWorktreeRoot(directory, sessionRoot);
127
- const normalizedRoot = root ? normalize(root) : "";
277
+ const projectRoot = mainWorktreeRoot(directory, sessionRoot);
278
+ const normalizedRoot = projectRoot.status === "resolved" ? normalize(projectRoot.root) : "";
128
279
  if (normalizedRoot && normalizedRoot !== directories[0]) directories.push(normalizedRoot);
129
280
  }
130
281
  return directories;
@@ -157,6 +308,19 @@ function deriveBankId(config, directory, harness = "coding", sessionRoot) {
157
308
  };
158
309
  return applyTemplate(config.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
159
310
  }
311
+ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot) {
312
+ try {
313
+ return deriveBankId(config, directory, harness, sessionRoot);
314
+ } catch (error) {
315
+ if (!(error instanceof BankResolutionError)) throw error;
316
+ log.warn(harness, "bank unresolved: skipping (repository could not be identified)", {
317
+ directory,
318
+ error: error.message
319
+ });
320
+ diag(harness, "bank_unresolved", { directory, error: error.message });
321
+ return null;
322
+ }
323
+ }
160
324
 
161
325
  // src/core/missions.ts
162
326
  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.";
@@ -295,15 +459,41 @@ var CODING_BANK_TEMPLATE = {
295
459
  entities_allow_free_form: true
296
460
  }
297
461
  };
298
- var CODING_BANK_STRUCTURE = {
299
- version: "1",
300
- bank: {
301
- retain_strategies: RETAIN_STRATEGIES,
302
- entity_labels: [KNOWLEDGE_LABELS]
303
- }
304
- };
462
+ var MISSION_FIELDS = ["reflect_mission", "retain_mission", "observations_mission"];
463
+ function isSet(v) {
464
+ if (v === null || v === void 0) return false;
465
+ if (typeof v === "string") return v.trim() !== "";
466
+ return true;
467
+ }
468
+ function codingBankManifest(overrides) {
469
+ const current2 = overrides ?? {};
470
+ const template = CODING_BANK_TEMPLATE.bank;
471
+ const bank = {};
472
+ if (!MISSION_FIELDS.some((f) => isSet(current2[f]))) {
473
+ bank.reflect_mission = template.reflect_mission;
474
+ bank.enable_observations = template.enable_observations;
475
+ bank.observations_mission = template.observations_mission;
476
+ bank.retain_mission = template.retain_mission;
477
+ bank.retain_extraction_mode = template.retain_extraction_mode;
478
+ }
479
+ if (!isSet(current2.retain_default_strategy))
480
+ bank.retain_default_strategy = template.retain_default_strategy;
481
+ if (!isSet(current2.entities_allow_free_form))
482
+ bank.entities_allow_free_form = template.entities_allow_free_form;
483
+ const strategies = current2.retain_strategies && typeof current2.retain_strategies === "object" ? current2.retain_strategies : {};
484
+ const missing = Object.entries(template.retain_strategies).filter(([n]) => !(n in strategies));
485
+ if (missing.length > 0)
486
+ bank.retain_strategies = { ...strategies, ...Object.fromEntries(missing) };
487
+ const labels = Array.isArray(current2.entity_labels) ? current2.entity_labels : [];
488
+ const [knowledgeGroup] = template.entity_labels;
489
+ if (!labels.some((g) => g?.key === knowledgeGroup.key))
490
+ bank.entity_labels = [...labels, knowledgeGroup];
491
+ return Object.keys(bank).length > 0 ? { version: "1", bank } : void 0;
492
+ }
305
493
 
306
494
  // src/core/util.ts
495
+ import { accessSync, constants } from "fs";
496
+ import { delimiter, join as join4 } from "path";
307
497
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
308
498
  function semverGte(version, min) {
309
499
  const parts = (v) => {
@@ -335,6 +525,11 @@ async function pool(items, n, fn, onError, onProgress) {
335
525
  }
336
526
 
337
527
  // src/core/hindsight.ts
528
+ function resolveRetainScopes(tags, configured) {
529
+ if (configured !== "per_source") return configured;
530
+ const sources = [...new Set((tags ?? []).filter((t) => t.startsWith("source:")))].sort();
531
+ return [[], ...sources.map((s) => [s])];
532
+ }
338
533
  var DEFAULT_OBSERVATION_SCOPES = "shared";
339
534
  var MIN_IDEMPOTENT_RETAIN_VERSION = "0.8.6";
340
535
  var RateLimitedError = class extends Error {
@@ -365,7 +560,6 @@ var DEFAULT_MAX_PARALLEL_RETAINS = 10;
365
560
  var POLL_CYCLE_MS = 5e3;
366
561
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
367
562
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
368
- var MISSION_FIELDS = ["reflect_mission", "retain_mission", "observations_mission"];
369
563
  var HindsightClient = class {
370
564
  apiUrl;
371
565
  /** The credential the NEXT request will sign with — NOT the one the config file holds. The two
@@ -471,7 +665,7 @@ var HindsightClient = class {
471
665
  // Sent on EVERY retain, including the server default `combined`, so the scoping a bank's
472
666
  // observations were built under is a property of the write rather than of whichever server
473
667
  // version happened to process it. Servers older than 0.4.15 ignore the field.
474
- observation_scopes: this.observationScopes
668
+ observation_scopes: resolveRetainScopes(tags, this.observationScopes)
475
669
  };
476
670
  if (opts.timestamp) item.timestamp = opts.timestamp;
477
671
  if (opts.metadata) item.metadata = opts.metadata;
@@ -512,11 +706,11 @@ var HindsightClient = class {
512
706
  * Set. Powers the incremental git-sync's "what's already ingested?" check — since git commits are stored
513
707
  * with document_id `git:<sha>`, the returned Set lets a caller diff a ref's commits against memory.
514
708
  */
515
- async listDocumentIds(tag) {
709
+ async listDocumentIds(tag, tagsMatch = "all") {
516
710
  const ids = /* @__PURE__ */ new Set();
517
711
  const limit = 500;
518
712
  for (let offset = 0; ; offset += limit) {
519
- const q = `?tags=${encodeURIComponent(tag)}&tags_match=all&limit=${limit}&offset=${offset}`;
713
+ const q = `?tags=${encodeURIComponent(tag)}&tags_match=${tagsMatch}&limit=${limit}&offset=${offset}`;
520
714
  const r = await this.req("GET", this.bankUrl(`/documents${q}`));
521
715
  let items = [];
522
716
  let total = 0;
@@ -532,49 +726,54 @@ var HindsightClient = class {
532
726
  }
533
727
  return ids;
534
728
  }
535
- /** Configure the bank: POST the coding bank template manifest to /import (missions, retain
536
- * strategies, entity labels), then seed knowledge pages when the server supports them. Both
537
- * halves are idempotent, so the deepen engine can re-run this every pass. Creates the bank if
538
- * missing; legacy servers continue with the template-only path. */
729
+ /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
730
+ * entity labels), then seed knowledge pages when the server supports them. Both halves are
731
+ * idempotent and strictly ADDITIVE — nothing the bank already says is overwritten (#3927) — so
732
+ * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
733
+ * continue with the template-only path.
734
+ *
735
+ * `manage: false` skips the config half entirely, for a bank whose owner shapes it themselves.
736
+ * That bank should then define the strategies this plugin writes under (`git`, `gitlog`,
737
+ * `conversation`, `document`, `survey`): an unknown strategy name is not an error server-side,
738
+ * it just falls back to the bank's own config, so the miss is silent. */
539
739
  async configureBank(opts = {}) {
540
740
  if (opts.reset) {
541
741
  await this.req("DELETE", this.bankUrl());
542
742
  this.log(`[bank] reset ${this.bank}`);
543
743
  }
544
- const seeded = opts.reset ? false : await this.hasBankMissions();
545
- await this.req(
546
- "POST",
547
- this.bankUrl("/import"),
548
- seeded ? CODING_BANK_STRUCTURE : CODING_BANK_TEMPLATE
549
- );
550
- this.log(
551
- seeded ? `[bank] structure applied to ${this.bank}: entity_labels {knowledge}, strategies {git, gitlog, conversation, document} \u2014 missions left as configured` : `[bank] template applied to ${this.bank}: missions, entity_labels {knowledge}, strategies {git, gitlog, conversation, document}`
552
- );
744
+ if (opts.manage === false) {
745
+ this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
746
+ } else {
747
+ const manifest = codingBankManifest(opts.reset ? void 0 : await this.readBankOverrides());
748
+ if (!manifest) {
749
+ this.log(`[bank] ${this.bank} already carries the coding structure \u2014 nothing to apply`);
750
+ } else {
751
+ await this.req("POST", this.bankUrl("/import"), manifest);
752
+ this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
753
+ }
754
+ }
553
755
  await this.seedPages(opts.pageTrigger);
554
756
  }
555
757
  /**
556
- * Whether this bank already carries bank-level mission overrides — ours from an earlier seed, or
557
- * the user's own edit. Either way they are not ours to overwrite.
758
+ * This bank's own config OVERRIDES, or undefined when there are none to read.
558
759
  *
559
- * Reads the bank-scoped OVERRIDES, not the resolved config, so inherited global defaults don't
560
- * read as "already set". A missing bank, or a deployment with the bank-config API switched off,
561
- * answers false: there is nothing to preserve, and without that API a user cannot set per-bank
562
- * missions in the first place.
760
+ * Deliberately the overrides and not the resolved config: an inherited global default is not
761
+ * something this bank's owner chose, so it must not read as "already set". `undefined` means the
762
+ * bank does not exist yet, or the deployment has the bank-config API switched off — in neither
763
+ * case can anything have been customised, so the caller seeds the full template.
563
764
  */
564
- async hasBankMissions() {
765
+ async readBankOverrides() {
565
766
  try {
566
767
  const r = await this.req("GET", this.bankUrl("/config"));
567
- if (!r.ok) return false;
768
+ if (!r.ok) return void 0;
568
769
  const j = await r.json();
569
- return MISSION_FIELDS.some((f) => {
570
- const v = j.overrides?.[f];
571
- return typeof v === "string" && v.trim() !== "";
572
- });
770
+ return j.overrides ?? {};
573
771
  } catch {
574
- return false;
772
+ return void 0;
575
773
  }
576
774
  }
577
- /** Delete one document (cascades its memory units/links). Used by deepen's self-cleanup. */
775
+ /** Explicitly delete one document (and its cascaded memory units/links). Background sync must
776
+ * never use this as a cleanup primitive: a document id alone does not prove repository ownership. */
578
777
  async deleteDocument(documentId) {
579
778
  await this.req("DELETE", this.bankUrl(`/documents/${encodeURIComponent(documentId)}`));
580
779
  }
@@ -938,65 +1137,18 @@ async function ingestChats(client, sessions, opts = {}) {
938
1137
  }
939
1138
 
940
1139
  // src/core/config.ts
941
- import { readFileSync } from "fs";
1140
+ import { readFileSync as readFileSync2 } from "fs";
942
1141
  import { homedir as homedir2 } from "os";
943
- import { join as join4 } from "path";
1142
+ import { join as join6 } from "path";
944
1143
 
945
1144
  // src/core/seed.ts
946
1145
  import { spawn as realSpawn } from "child_process";
947
- import { dirname as dirname2, join as join2 } from "path";
1146
+ import { dirname as dirname4, join as join5 } from "path";
948
1147
  import { fileURLToPath } from "url";
949
1148
  var DEFAULT_SEED_LIMIT = 300;
950
1149
 
951
- // src/core/log.ts
952
- import { appendFileSync, mkdirSync } from "fs";
953
- import { tmpdir } from "os";
954
- import { dirname as dirname3, join as join3 } from "path";
955
- var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
956
- var current = ["debug", "info", "warn", "error"].find(
957
- (l) => l === process.env.HINDSIGHT_LOG_LEVEL
958
- ) ?? "info";
959
- function setLogLevel(level) {
960
- if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
961
- }
962
- function logFilePath() {
963
- return process.env.HINDSIGHT_LOG_FILE || join3(tmpdir(), "hindsight-coding-agent", "plugin.log");
964
- }
965
- function write(level, scope, msg, extra) {
966
- if (WEIGHT[level] < WEIGHT[current]) return;
967
- try {
968
- const file = logFilePath();
969
- mkdirSync(dirname3(file), { recursive: true });
970
- appendFileSync(
971
- file,
972
- `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
973
- );
974
- } catch {
975
- }
976
- }
977
- var log = {
978
- debug: (scope, msg, extra) => write("debug", scope, msg, extra),
979
- info: (scope, msg, extra) => write("info", scope, msg, extra),
980
- warn: (scope, msg, extra) => write("warn", scope, msg, extra),
981
- error: (scope, msg, extra) => write("error", scope, msg, extra)
982
- };
983
- function describeError(value, maxChars = 200) {
984
- const parts = [];
985
- const seen = /* @__PURE__ */ new Set();
986
- let current2 = value;
987
- while (current2 && !seen.has(current2)) {
988
- seen.add(current2);
989
- const error = current2;
990
- const text = typeof error.message === "string" ? error.message : String(current2);
991
- const withCode = error.code ? `${text} (${String(error.code)})` : text;
992
- if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
993
- current2 = error.cause;
994
- }
995
- return (parts.join(": ") || String(value)).slice(0, maxChars);
996
- }
997
-
998
1150
  // src/core/config.ts
999
- var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join4(homedir2(), ".hindsight", "coding-agent.json");
1151
+ var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
1000
1152
  var DEFAULT_DAEMON_PORT = 9077;
1001
1153
  var DEFAULT_DAEMON_PROFILE = "coding-agent";
1002
1154
  function resolvePageTriggerType(raw) {
@@ -1020,7 +1172,13 @@ function resolveReflectBudget(raw) {
1020
1172
  log.warn("config", `ignoring reflectBudget=${JSON.stringify(value)} \u2014 expected low|mid|high`);
1021
1173
  return "high";
1022
1174
  }
1023
- var OBSERVATION_SCOPE_MODES = ["shared", "combined", "per_tag", "all_combinations"];
1175
+ var OBSERVATION_SCOPE_MODES = [
1176
+ "shared",
1177
+ "combined",
1178
+ "per_tag",
1179
+ "all_combinations",
1180
+ "per_source"
1181
+ ];
1024
1182
  function resolveObservationScopes(raw) {
1025
1183
  const value = raw;
1026
1184
  if (typeof value === "string")
@@ -1058,6 +1216,7 @@ function resolveConfig(raw = {}) {
1058
1216
  disabled: raw.disabled ?? false,
1059
1217
  retainSessions: raw.retainSessions ?? true,
1060
1218
  // write sessions back by default, every harness
1219
+ manageBankConfig: raw.manageBankConfig ?? true,
1061
1220
  maxParallelRetains: raw.maxParallelRetains || 10,
1062
1221
  reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
1063
1222
  // Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
@@ -1084,12 +1243,13 @@ function resolveConfig(raw = {}) {
1084
1243
  ) : {},
1085
1244
  observationScopes: resolveObservationScopes(raw.observationScopes),
1086
1245
  banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
1087
- logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info"
1246
+ logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
1247
+ autoUpdate: raw.autoUpdate ?? true
1088
1248
  };
1089
1249
  }
1090
1250
  function readRaw(path) {
1091
1251
  try {
1092
- return JSON.parse(readFileSync(path, "utf8"));
1252
+ return JSON.parse(readFileSync2(path, "utf8"));
1093
1253
  } catch (e) {
1094
1254
  if (e?.code !== "ENOENT") {
1095
1255
  console.error(`hindsight: ignoring invalid config at ${path}: ${e?.message || e}`);
@@ -1142,13 +1302,15 @@ var ENV_KEYS = {
1142
1302
  surveyBudgetUsd: "HINDSIGHT_SURVEY_BUDGET_USD",
1143
1303
  surveyRefreshCommits: "HINDSIGHT_SURVEY_REFRESH_COMMITS",
1144
1304
  logLevel: "HINDSIGHT_LOG_LEVEL",
1305
+ autoUpdate: "HINDSIGHT_AUTO_UPDATE",
1145
1306
  gitIngest: "HINDSIGHT_GIT_INGEST",
1146
1307
  // Scalar modes only ("shared", "combined", "per_tag", "all_combinations"). An explicit scope
1147
1308
  // list is a list OF lists, which does not survive flattening into one variable — file-only.
1148
1309
  observationScopes: "HINDSIGHT_OBSERVATION_SCOPES",
1149
1310
  // Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
1150
1311
  // a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
1151
- retainTags: "HINDSIGHT_RETAIN_TAGS"
1312
+ retainTags: "HINDSIGHT_RETAIN_TAGS",
1313
+ manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
1152
1314
  };
1153
1315
  var ENV_BOOLEANS = /* @__PURE__ */ new Set([
1154
1316
  "dynamicBankId",
@@ -1158,7 +1320,9 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
1158
1320
  "retainSessions",
1159
1321
  "autoReflect",
1160
1322
  "autoSeed",
1161
- "codebaseSurvey"
1323
+ "codebaseSurvey",
1324
+ "autoUpdate",
1325
+ "manageBankConfig"
1162
1326
  ]);
1163
1327
  var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
1164
1328
  var ENV_NUMBERS = /* @__PURE__ */ new Set([
@@ -1234,19 +1398,19 @@ function resolvePartial(cfg2, patch) {
1234
1398
  }
1235
1399
 
1236
1400
  // src/core/git.ts
1237
- import { execFileSync as execFileSync2 } from "child_process";
1238
- import { resolve } from "path";
1401
+ import { execFileSync } from "child_process";
1402
+ import { resolve as resolve2 } from "path";
1239
1403
  var US = "";
1240
1404
  var RS = "";
1241
1405
  function git(repo, ...args) {
1242
- return execFileSync2("git", ["-C", repo, ...args], {
1406
+ return execFileSync("git", ["-C", repo, ...args], {
1243
1407
  encoding: "utf8",
1244
1408
  maxBuffer: 1 << 28,
1245
1409
  windowsHide: true
1246
1410
  });
1247
1411
  }
1248
1412
  function repoNameOf(repo) {
1249
- return projectNameOf(resolve(repo));
1413
+ return projectNameOf(resolve2(repo));
1250
1414
  }
1251
1415
  function gitHeadSha(dir) {
1252
1416
  try {
@@ -1380,12 +1544,24 @@ async function ingestGitLog(client, repo, opts = { limit: 300 }) {
1380
1544
  return 1;
1381
1545
  }
1382
1546
  }
1547
+ async function syncGitLog(client, repo, opts) {
1548
+ const log3 = opts.log ?? (() => {
1549
+ });
1550
+ const head = gitHeadSha(repo);
1551
+ const canonical2 = `gitlog:${repoNameOf(repo)}`;
1552
+ const current2 = head !== null && (await client.listDocumentIds(`gitlog-head:${head}`, "all_strict").catch(() => /* @__PURE__ */ new Set())).has(canonical2);
1553
+ if (current2) {
1554
+ log3("[gitlog] current with HEAD \u2014 skipping");
1555
+ return 0;
1556
+ }
1557
+ return ingestGitLog(client, repo, opts);
1558
+ }
1383
1559
 
1384
1560
  // src/core/survey.ts
1385
1561
  import { spawn as realSpawn2 } from "child_process";
1386
- import { accessSync, constants, existsSync as existsSync2 } from "fs";
1562
+ import { existsSync as existsSync2 } from "fs";
1387
1563
  import { homedir as homedir3 } from "os";
1388
- import { delimiter, dirname as dirname4, join as join5 } from "path";
1564
+ import { dirname as dirname5, join as join7 } from "path";
1389
1565
  import { fileURLToPath as fileURLToPath2 } from "url";
1390
1566
  var SURVEY_DOC_IDS = [
1391
1567
  "repository-component-map",
@@ -1395,16 +1571,16 @@ var SURVEY_DOC_IDS = [
1395
1571
  ];
1396
1572
 
1397
1573
  // src/core/status.ts
1398
- import { execFileSync as execFileSync3 } from "child_process";
1574
+ import { execFileSync as execFileSync2 } from "child_process";
1399
1575
  var DEEPEN_DIFF_TARGET = 300;
1400
1576
 
1401
1577
  // src/harness/registry.ts
1402
- import { readFileSync as readFileSync2 } from "fs";
1578
+ import { readFileSync as readFileSync3 } from "fs";
1403
1579
  var jsonChatReader = (harness) => ({
1404
1580
  describe: `${harness} sessions via a normalized JSON export (--conversations file: [{ id, turns:[{role,text,timestamp?}] }])`,
1405
1581
  async read(opts) {
1406
1582
  if (!opts.conversations) return [];
1407
- return JSON.parse(readFileSync2(opts.conversations, "utf8"));
1583
+ return JSON.parse(readFileSync3(opts.conversations, "utf8"));
1408
1584
  }
1409
1585
  });
1410
1586
  var noRuntimeAdapter = (name, hint) => ({
@@ -1416,6 +1592,9 @@ var noRuntimeAdapter = (name, hint) => ({
1416
1592
  });
1417
1593
  var HARNESS_NAMES = [
1418
1594
  "opencode",
1595
+ // opencode v2 (binary `opencode2`) — a ground-up rewrite of the plugin API, loaded from the
1596
+ // package's root index.js (src/opencode2.ts). Like opencode it has NO hook binary.
1597
+ "opencode2",
1419
1598
  // Kilo CLI is an opencode fork loaded as a persistent plugin (src/kilo.ts), so like opencode it
1420
1599
  // has NO hook binary — deliberately absent from HOOK_BINS below.
1421
1600
  "kilo",
@@ -1424,30 +1603,38 @@ var HARNESS_NAMES = [
1424
1603
  // DeepSeek Harness loads dist/dsh.js as a native Cordis plugin (src/dsh.ts). Its Claude Code /
1425
1604
  // Codex hook bridges are optional packages, so there is no hook binary to install either.
1426
1605
  "dsh",
1427
- // Prime Agent loads dist/prime-agent.js as an extension (src/prime-agent.ts); no hook binary.
1606
+ // pi loads dist/pi.js as an extension (src/pi.ts), and Prime Agent — a fork of pi — loads
1607
+ // dist/prime-agent.js the same way (src/prime-agent.ts). Neither has a hook binary.
1608
+ "pi",
1428
1609
  "prime-agent",
1429
1610
  "claude-code",
1430
1611
  "cursor-cli",
1431
1612
  "codex",
1613
+ "dcode",
1432
1614
  "antigravity-cli",
1433
1615
  "devin-cli",
1434
1616
  "copilot-cli",
1435
- "grok-build"
1617
+ "grok-build",
1618
+ "qwen-code"
1436
1619
  ];
1437
1620
  var HOOK_BINS = {
1438
1621
  "claude-code": "hindsight-claude-hook",
1439
1622
  "cursor-cli": "hindsight-cursor-hook",
1440
1623
  codex: "hindsight-codex-hook",
1624
+ dcode: "hindsight-dcode-hook",
1441
1625
  "antigravity-cli": "hindsight-antigravity-hook",
1442
1626
  "devin-cli": "hindsight-devin-hook",
1443
1627
  "copilot-cli": "hindsight-copilot-hook",
1444
- "grok-build": "hindsight-grok-hook"
1628
+ "grok-build": "hindsight-grok-hook",
1629
+ "qwen-code": "hindsight-qwen-hook"
1445
1630
  // more hook harnesses: add a HookSpec entry point (see src/cursor-hook.ts) + a registration here.
1446
1631
  };
1447
1632
  var PLUGIN_ENTRYPOINTS = {
1448
1633
  opencode: "src/index.ts",
1634
+ opencode2: "src/opencode2.ts",
1449
1635
  kilo: "src/kilo.ts",
1450
1636
  "cline-cli": "src/cline.ts",
1637
+ pi: "src/pi.ts",
1451
1638
  "prime-agent": "src/prime-agent.ts",
1452
1639
  dsh: "src/dsh.ts"
1453
1640
  };
@@ -1469,22 +1656,6 @@ async function getHarness(name) {
1469
1656
  );
1470
1657
  }
1471
1658
 
1472
- // src/core/diag.ts
1473
- import { appendFileSync as appendFileSync2 } from "fs";
1474
- function diagFilePath() {
1475
- return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
1476
- }
1477
- function diag(harness, event, extra = {}) {
1478
- log.debug(harness, `diag:${event}`, extra);
1479
- try {
1480
- appendFileSync2(
1481
- diagFilePath(),
1482
- JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
1483
- );
1484
- } catch {
1485
- }
1486
- }
1487
-
1488
1659
  // src/core/retain-stamp.ts
1489
1660
  import { basename as basename2 } from "path";
1490
1661
  var RESERVED_TAG_PREFIX = /^(source|harness):/;
@@ -1509,12 +1680,12 @@ function buildRetainStamp(cfg2, ctx) {
1509
1680
  const base = resolversFor(ctx);
1510
1681
  const cache = /* @__PURE__ */ new Map();
1511
1682
  const resolvers = Object.fromEntries(
1512
- Object.entries(base).map(([name, resolve2]) => [
1683
+ Object.entries(base).map(([name, resolve3]) => [
1513
1684
  name,
1514
1685
  () => {
1515
1686
  const hit = cache.get(name);
1516
1687
  if (hit !== void 0) return hit;
1517
- const value = resolve2();
1688
+ const value = resolve3();
1518
1689
  cache.set(name, value);
1519
1690
  return value;
1520
1691
  }
@@ -1542,7 +1713,7 @@ function arg(name, def) {
1542
1713
  }
1543
1714
  var REPO = arg("repo");
1544
1715
  var cfg0 = loadConfig({ harness: arg("harness") ?? void 0, path: arg("config") });
1545
- var BANK = arg("bank") ?? (REPO ? deriveBankId(cfg0, REPO, arg("harness") ?? cfg0.harness) : cfg0.bankId);
1716
+ var BANK = arg("bank") ?? (REPO ? deriveBankIdOrSkip(cfg0, REPO, arg("harness") ?? cfg0.harness) : cfg0.bankId) ?? void 0;
1546
1717
  var resolved0 = BANK ? applyBankConfig(cfg0, BANK, REPO ?? void 0) : { cfg: cfg0, bankId: BANK };
1547
1718
  var cfg = resolved0.cfg;
1548
1719
  var FINAL_BANK = resolved0.bankId ?? BANK;
@@ -1568,11 +1739,11 @@ var log2 = (m) => {
1568
1739
  console.log(`${(/* @__PURE__ */ new Date()).toISOString()} ${m}`);
1569
1740
  log.info("deepen", m);
1570
1741
  };
1571
- var LOCK_DIR = join6(tmpdir2(), "hindsight-coding-agent");
1572
- var LOCK = join6(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1742
+ var LOCK_DIR = join8(tmpdir2(), "hindsight-coding-agent");
1743
+ var LOCK = join8(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1573
1744
  function acquireLock() {
1574
1745
  try {
1575
- const held = JSON.parse(readFileSync3(LOCK, "utf8"));
1746
+ const held = JSON.parse(readFileSync4(LOCK, "utf8"));
1576
1747
  if (held.ts && Date.now() - held.ts < LOCK_STALE_MS) {
1577
1748
  let holderAlive = false;
1578
1749
  if (held.pid) {
@@ -1622,19 +1793,22 @@ async function main() {
1622
1793
  bankId: FINAL_BANK,
1623
1794
  sessionId
1624
1795
  });
1625
- await client.configureBank({ pageTrigger: buildPageTrigger(cfg) });
1796
+ await client.configureBank({
1797
+ pageTrigger: buildPageTrigger(cfg),
1798
+ manage: cfg.manageBankConfig
1799
+ });
1626
1800
  if (client.knowledgePagesSupported === false) {
1627
1801
  diag(harness.name, "knowledge_pages_unavailable", {
1628
1802
  bank: FINAL_BANK,
1629
1803
  apiUrl: client.apiUrl
1630
1804
  });
1631
1805
  }
1632
- const gitIds = await client.listDocumentIds("source:git");
1806
+ const gitIds = await client.listDocumentIds("source:git", "all_strict");
1633
1807
  let sessions = [];
1634
1808
  if (!cfg.retainSessions) {
1635
1809
  log2("[chat] retainSessions: false \u2014 skipping conversation import");
1636
1810
  } else {
1637
- const chatIds = await client.listDocumentIds("source:chat").catch(() => /* @__PURE__ */ new Set());
1811
+ const chatIds = await client.listDocumentIds("source:chat", "all_strict").catch(() => /* @__PURE__ */ new Set());
1638
1812
  const all = await harness.chatReader.read({ conversations: CONV, repo: REPO });
1639
1813
  sessions = all.filter((s, i) => !chatIds.has(`chat:${s.id || `s${i}`}`));
1640
1814
  if (all.length !== sessions.length)
@@ -1651,27 +1825,10 @@ async function main() {
1651
1825
  if (GIT_INGEST === "none") {
1652
1826
  log2("[git] gitIngest=none \u2014 git ingestion disabled");
1653
1827
  } else {
1654
- const head = gitHeadSha(REPO);
1655
- const gitlogCurrent = head !== null && (await client.listDocumentIds(`gitlog-head:${head}`).catch(() => /* @__PURE__ */ new Set())).size > 0;
1656
- if (gitlogCurrent) {
1657
- log2("[gitlog] current with HEAD \u2014 skipping");
1658
- } else {
1659
- gitFails += await ingestGitLog(client, REPO, { limit: GITLOG_LIMIT, log: log2, stampFor });
1660
- }
1661
- try {
1662
- const canonical = `gitlog:${repoNameOf(REPO)}`;
1663
- const logDocs = await client.listDocumentIds("source:git-log");
1664
- for (const id of logDocs) {
1665
- if (id !== canonical) {
1666
- await client.deleteDocument(id);
1667
- log2(`[gitlog] removed stale duplicate ${id} (canonical: ${canonical})`);
1668
- }
1669
- }
1670
- } catch {
1671
- }
1828
+ gitFails += await syncGitLog(client, REPO, { limit: GITLOG_LIMIT, log: log2, stampFor });
1672
1829
  if (GIT_INGEST === "full") {
1673
1830
  try {
1674
- const shas = execFileSync4(
1831
+ const shas = execFileSync3(
1675
1832
  "git",
1676
1833
  ["-C", REPO, "rev-list", `-n`, String(DEEPEN_DIFF_TARGET), "HEAD"],
1677
1834
  { encoding: "utf8", windowsHide: true }
@@ -1696,10 +1853,10 @@ async function main() {
1696
1853
  }
1697
1854
  }
1698
1855
  try {
1699
- const uploads = await client.listDocumentIds("source:upload").catch(() => /* @__PURE__ */ new Set());
1856
+ const uploads = await client.listDocumentIds("source:upload", "all_strict").catch(() => /* @__PURE__ */ new Set());
1700
1857
  if (SURVEY_DOC_IDS.some((id) => uploads.has(id))) {
1701
- const markers = await client.listDocumentIds("source:survey-baseline");
1702
- const done = await client.listDocumentIds("survey-state:done").catch(() => /* @__PURE__ */ new Set());
1858
+ const markers = await client.listDocumentIds("source:survey-baseline", "all_strict");
1859
+ const done = await client.listDocumentIds("survey-state:done", "all_strict").catch(() => /* @__PURE__ */ new Set());
1703
1860
  let best;
1704
1861
  for (const id of markers) {
1705
1862
  if (done.has(id)) continue;