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

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 (48) hide show
  1. package/README.md +5 -2
  2. package/dist/antigravity-hook.js +185 -41
  3. package/dist/antigravity-stop-hook.js +114 -36
  4. package/dist/claude-hook.js +185 -41
  5. package/dist/claude-sessionstart-hook.js +292 -76
  6. package/dist/claude-stop-hook.js +114 -36
  7. package/dist/cline.js +331 -58
  8. package/dist/codex-hook.js +185 -41
  9. package/dist/codex-sessionstart-hook.js +292 -76
  10. package/dist/codex-stop-hook.js +114 -36
  11. package/dist/copilot-hook.js +185 -41
  12. package/dist/copilot-sessionstart-hook.js +292 -76
  13. package/dist/copilot-stop-hook.js +114 -36
  14. package/dist/cursor-hook.js +185 -41
  15. package/dist/cursor-sessionstart-hook.js +292 -76
  16. package/dist/cursor-stop-hook.js +114 -36
  17. package/dist/dcode-hook.js +185 -41
  18. package/dist/dcode-sessionstart-hook.js +292 -76
  19. package/dist/dcode-stop-hook.js +114 -36
  20. package/dist/deepen.js +93 -18
  21. package/dist/devin-hook.js +185 -41
  22. package/dist/devin-sessionstart-hook.js +292 -76
  23. package/dist/devin-stop-hook.js +114 -36
  24. package/dist/droid-hook.js +185 -41
  25. package/dist/droid-sessionstart-hook.js +292 -76
  26. package/dist/droid-stop-hook.js +114 -36
  27. package/dist/dsh.js +333 -60
  28. package/dist/grok-hook.js +185 -41
  29. package/dist/grok-sessionstart-hook.js +292 -76
  30. package/dist/grok-stop-hook.js +114 -36
  31. package/dist/index.js +333 -60
  32. package/dist/installer.js +1030 -268
  33. package/dist/kilo.js +333 -60
  34. package/dist/mcp-server.js +86 -11
  35. package/dist/opencode2.js +333 -60
  36. package/dist/pi.js +332 -59
  37. package/dist/prime-agent.js +332 -59
  38. package/dist/qwen-hook.js +185 -41
  39. package/dist/qwen-sessionstart-hook.js +292 -76
  40. package/dist/qwen-stop-hook.js +114 -36
  41. package/dist/status.js +84 -9
  42. package/dist/survey-supervisor.js +81 -0
  43. package/dist/zcode-hook.js +185 -41
  44. package/dist/zcode-sessionstart-hook.js +292 -76
  45. package/dist/zcode-stop-hook.js +114 -36
  46. package/package.json +2 -1
  47. package/plugin.json +1 -1
  48. package/skill/SKILL.md +5 -2
@@ -629,6 +629,22 @@ var KnowledgePagesUnavailableError = class extends Error {
629
629
  }
630
630
  };
631
631
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
632
+ var ReflectError = class extends Error {
633
+ constructor(message, status, timedOut, options) {
634
+ super(message, options);
635
+ this.status = status;
636
+ this.timedOut = timedOut;
637
+ this.name = "ReflectError";
638
+ }
639
+ status;
640
+ timedOut;
641
+ /** A timeout or a 5xx means reflect's synthesis (the slow LLM path) broke, while the cheap
642
+ * retrieval endpoints may still answer — worth falling back. A 4xx will fail the same way on
643
+ * every endpoint (auth, missing bank), so it is not. */
644
+ get fallbackEligible() {
645
+ return this.timedOut || this.status !== void 0 && this.status >= 500;
646
+ }
647
+ };
632
648
  var DEFAULT_MAX_PARALLEL_RETAINS = 10;
633
649
  var POLL_CYCLE_MS = 5e3;
634
650
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
@@ -712,11 +728,11 @@ var HindsightClient = class {
712
728
  return `${this.apiUrl}/v1/default/banks/${encodeURIComponent(this.bank)}${suffix}`;
713
729
  }
714
730
  /** `tolerate` adds statuses that are returned to the caller instead of thrown (404 always is). */
715
- async req(method, url, body, tolerate = []) {
731
+ async req(method, url, body, tolerate = [], timeoutMs = 15e3) {
716
732
  const r = await this.fetchWithAuth(url, {
717
733
  method,
718
734
  body: body ? JSON.stringify(body) : void 0,
719
- signal: AbortSignal.timeout(15e3)
735
+ signal: AbortSignal.timeout(timeoutMs)
720
736
  });
721
737
  if (r.status === 429 && !tolerate.includes(429))
722
738
  throw new RateLimitedError(retryAfterMs(r.headers.get("retry-after")));
@@ -909,7 +925,7 @@ var HindsightClient = class {
909
925
  /**
910
926
  * Reflect: synthesized, root-cause answer over the bank. Bounded so a slow server never hangs a
911
927
  * caller — but `timeoutMs` is REQUIRED, deliberately: the right deadline differs by an order of
912
- * magnitude between the automatic hook (25s, to fit the host's window) and the agent-invoked
928
+ * magnitude between the automatic hook (20s, to fit the host's window) and the agent-invoked
913
929
  * tool (minutes, on a populated bank). This used to default to 120s, which silently overrode the
914
930
  * tool's configured window and aborted every high-budget synthesis mid-flight (#3590).
915
931
  */
@@ -922,13 +938,46 @@ var HindsightClient = class {
922
938
  body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
923
939
  signal: ctrl.signal
924
940
  });
925
- if (!resp.ok) throw new Error(`reflect ${resp.status}${this.authHint(resp.status)}`);
941
+ if (!resp.ok)
942
+ throw new ReflectError(
943
+ `reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`,
944
+ resp.status,
945
+ false
946
+ );
926
947
  const data = await resp.json();
927
948
  return (data.text || "").trim();
949
+ } catch (e) {
950
+ if (ctrl.signal.aborted)
951
+ throw new ReflectError(`reflect timed out after ${opts.timeoutMs}ms`, void 0, true, {
952
+ cause: e
953
+ });
954
+ throw e;
928
955
  } finally {
929
956
  clearTimeout(timer);
930
957
  }
931
958
  }
959
+ /**
960
+ * Raw recall restricted to consolidated observations — no LLM in the loop, so it still answers
961
+ * when reflect's synthesis times out or 5xxs. Returns the observation texts in rank order.
962
+ */
963
+ async recallObservations(query, opts) {
964
+ const r = await this.req(
965
+ "POST",
966
+ this.bankUrl("/memories/recall"),
967
+ {
968
+ query,
969
+ types: ["observation"],
970
+ budget: "low",
971
+ max_tokens: opts.maxTokens,
972
+ include: { entities: null }
973
+ },
974
+ [],
975
+ opts.timeoutMs
976
+ );
977
+ if (r.status === 404) return [];
978
+ const j = await r.json();
979
+ return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
980
+ }
932
981
  /**
933
982
  * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
934
983
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
@@ -993,10 +1042,16 @@ var HindsightClient = class {
993
1042
  /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
994
1043
  * Returns page-level hits with a relevance snippet — the real search behind
995
1044
  * hindsight_search_knowledge_pages. */
996
- async searchKnowledgePages(query, limit = 3) {
1045
+ async searchKnowledgePages(query, limit = 3, timeoutMs) {
997
1046
  if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
998
1047
  const q = `?q=${encodeURIComponent(query)}&limit=${limit}`;
999
- const r = await this.req("GET", this.bankUrl(`/knowledge-base/search${q}`));
1048
+ const r = await this.req(
1049
+ "GET",
1050
+ this.bankUrl(`/knowledge-base/search${q}`),
1051
+ void 0,
1052
+ [],
1053
+ timeoutMs
1054
+ );
1000
1055
  const j = await r.json();
1001
1056
  return (j.results ?? []).map((x) => ({
1002
1057
  id: x.id,
@@ -2173,7 +2228,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2173
2228
  }
2174
2229
 
2175
2230
  // src/core/session-start.ts
2176
- import { readFileSync as readFileSync9 } from "fs";
2231
+ import { readFileSync as readFileSync10 } from "fs";
2177
2232
 
2178
2233
  // src/core/git.ts
2179
2234
  import { execFileSync as execFileSync2 } from "child_process";
@@ -2183,24 +2238,42 @@ import { resolve as resolve2 } from "path";
2183
2238
  import { execFileSync as execFileSync3 } from "child_process";
2184
2239
 
2185
2240
  // src/core/survey.ts
2186
- import { spawn as realSpawn3 } from "child_process";
2241
+ import { spawn as realSpawn4 } from "child_process";
2242
+ import { createHash as createHash4 } from "crypto";
2187
2243
  import { existsSync as existsSync3 } from "fs";
2188
- import { homedir as homedir3 } from "os";
2189
- import { dirname as dirname8, join as join10 } from "path";
2244
+ import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
2245
+ import { dirname as dirname8, join as join11 } from "path";
2190
2246
  import { fileURLToPath as fileURLToPath3 } from "url";
2191
2247
 
2248
+ // src/core/survey-lease.ts
2249
+ import { spawn as realSpawn3 } from "child_process";
2250
+ import { randomUUID } from "crypto";
2251
+ import {
2252
+ mkdirSync as mkdirSync4,
2253
+ mkdtempSync,
2254
+ readdirSync,
2255
+ renameSync as renameSync2,
2256
+ rmdirSync,
2257
+ rmSync as rmSync2,
2258
+ statSync as statSync3,
2259
+ unlinkSync,
2260
+ utimesSync,
2261
+ writeFileSync as writeFileSync2
2262
+ } from "fs";
2263
+ import { join as join10 } from "path";
2264
+
2192
2265
  // src/core/auto-update.ts
2193
- import { spawn as realSpawn4 } from "child_process";
2266
+ import { spawn as realSpawn5 } from "child_process";
2194
2267
  import {
2195
2268
  existsSync as existsSync4,
2196
- mkdirSync as mkdirSync4,
2269
+ mkdirSync as mkdirSync5,
2197
2270
  readFileSync as readFileSync7,
2198
2271
  realpathSync as realpathSync2,
2199
- unlinkSync,
2200
- writeFileSync as writeFileSync2
2272
+ unlinkSync as unlinkSync2,
2273
+ writeFileSync as writeFileSync3
2201
2274
  } from "fs";
2202
- import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
2203
- import { dirname as dirname9, join as join11 } from "path";
2275
+ import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
2276
+ import { dirname as dirname9, join as join12 } from "path";
2204
2277
  import { fileURLToPath as fileURLToPath4 } from "url";
2205
2278
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2206
2279
  var LOCK_STALE_MS = 10 * 60 * 1e3;
@@ -2208,9 +2281,14 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
2208
2281
  // src/core/skill-sync.ts
2209
2282
  import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
2210
2283
  import { homedir as homedir5 } from "os";
2211
- import { dirname as dirname10, join as join12 } from "path";
2284
+ import { dirname as dirname10, join as join13 } from "path";
2212
2285
  import { fileURLToPath as fileURLToPath5 } from "url";
2213
2286
 
2287
+ // src/core/legacy.ts
2288
+ import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2289
+ import { homedir as homedir6 } from "os";
2290
+ import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
2291
+
2214
2292
  // src/core/transcript-codex.ts
2215
2293
  function isSyntheticUserText(text) {
2216
2294
  const s = text.trimStart();
@@ -2341,19 +2419,19 @@ function readCopilotTranscript(path) {
2341
2419
  }
2342
2420
 
2343
2421
  // src/core/transcript-grok.ts
2344
- import { existsSync as existsSync6, readFileSync as readFileSync10, readdirSync } from "fs";
2345
- import { homedir as homedir6 } from "os";
2346
- import { join as join13 } from "path";
2422
+ import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2423
+ import { homedir as homedir7 } from "os";
2424
+ import { join as join15 } from "path";
2347
2425
  var CHAT_HISTORY = "chat_history.jsonl";
2348
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join13(homedir6(), ".grok")) {
2349
- const sessionsDir = join13(grokHome, "sessions");
2350
- const direct = join13(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2351
- if (existsSync6(direct)) return direct;
2426
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2427
+ const sessionsDir = join15(grokHome, "sessions");
2428
+ const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2429
+ if (existsSync7(direct)) return direct;
2352
2430
  try {
2353
- for (const candidate of readdirSync(sessionsDir)) {
2354
- const directory = join13(sessionsDir, candidate);
2355
- if (readFileSync10(join13(directory, ".cwd"), "utf8").trim() === cwd) {
2356
- return join13(directory, sessionId, CHAT_HISTORY);
2431
+ for (const candidate of readdirSync2(sessionsDir)) {
2432
+ const directory = join15(sessionsDir, candidate);
2433
+ if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2434
+ return join15(directory, sessionId, CHAT_HISTORY);
2357
2435
  }
2358
2436
  }
2359
2437
  } catch {
@@ -2388,12 +2466,12 @@ function readGrokTranscript(path) {
2388
2466
  }
2389
2467
 
2390
2468
  // src/core/transcript-devin.ts
2391
- import { existsSync as existsSync7 } from "fs";
2469
+ import { existsSync as existsSync8 } from "fs";
2392
2470
  import { createRequire } from "module";
2393
- import { homedir as homedir7 } from "os";
2394
- import { join as join14 } from "path";
2395
- function devinSessionDb(home = homedir7()) {
2396
- return join14(home, ".local", "share", "devin", "cli", "sessions.db");
2471
+ import { homedir as homedir8 } from "os";
2472
+ import { join as join16 } from "path";
2473
+ function devinSessionDb(home = homedir8()) {
2474
+ return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2397
2475
  }
2398
2476
  function parseDevinMessages(nodes) {
2399
2477
  const messages = /* @__PURE__ */ new Map();
@@ -2430,7 +2508,7 @@ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
2430
2508
  diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
2431
2509
  return [];
2432
2510
  }
2433
- if (!existsSync7(dbPath)) {
2511
+ if (!existsSync8(dbPath)) {
2434
2512
  diag("devin-cli", "session_db_missing", { dbPath });
2435
2513
  return [];
2436
2514
  }
@@ -2703,7 +2781,7 @@ function readDroidTranscript(path) {
2703
2781
  }
2704
2782
 
2705
2783
  // src/core/transcript-zcode.ts
2706
- import { readFileSync as readFileSync11 } from "fs";
2784
+ import { readFileSync as readFileSync12 } from "fs";
2707
2785
  function messageText2(content) {
2708
2786
  if (typeof content === "string") return content.trim();
2709
2787
  if (!Array.isArray(content)) return "";
@@ -2713,7 +2791,7 @@ function readZcodeTranscript(path) {
2713
2791
  if (!path) return [];
2714
2792
  let body;
2715
2793
  try {
2716
- body = readFileSync11(path, "utf8");
2794
+ body = readFileSync12(path, "utf8");
2717
2795
  } catch {
2718
2796
  return [];
2719
2797
  }
package/dist/deepen.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  // src/deepen.ts
4
4
  import { execFileSync as execFileSync3 } from "child_process";
5
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, unlinkSync, writeFileSync } from "fs";
6
- import { tmpdir as tmpdir2 } from "os";
7
- import { join as join8 } from "path";
5
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
6
+ import { tmpdir as tmpdir3 } from "os";
7
+ import { join as join9 } from "path";
8
8
 
9
9
  // src/core/bank.ts
10
10
  import { existsSync } from "fs";
@@ -634,6 +634,22 @@ var KnowledgePagesUnavailableError = class extends Error {
634
634
  }
635
635
  };
636
636
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
637
+ var ReflectError = class extends Error {
638
+ constructor(message, status, timedOut, options) {
639
+ super(message, options);
640
+ this.status = status;
641
+ this.timedOut = timedOut;
642
+ this.name = "ReflectError";
643
+ }
644
+ status;
645
+ timedOut;
646
+ /** A timeout or a 5xx means reflect's synthesis (the slow LLM path) broke, while the cheap
647
+ * retrieval endpoints may still answer — worth falling back. A 4xx will fail the same way on
648
+ * every endpoint (auth, missing bank), so it is not. */
649
+ get fallbackEligible() {
650
+ return this.timedOut || this.status !== void 0 && this.status >= 500;
651
+ }
652
+ };
637
653
  var DEFAULT_MAX_PARALLEL_RETAINS = 10;
638
654
  var POLL_CYCLE_MS = 5e3;
639
655
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
@@ -717,11 +733,11 @@ var HindsightClient = class {
717
733
  return `${this.apiUrl}/v1/default/banks/${encodeURIComponent(this.bank)}${suffix}`;
718
734
  }
719
735
  /** `tolerate` adds statuses that are returned to the caller instead of thrown (404 always is). */
720
- async req(method, url, body, tolerate = []) {
736
+ async req(method, url, body, tolerate = [], timeoutMs = 15e3) {
721
737
  const r = await this.fetchWithAuth(url, {
722
738
  method,
723
739
  body: body ? JSON.stringify(body) : void 0,
724
- signal: AbortSignal.timeout(15e3)
740
+ signal: AbortSignal.timeout(timeoutMs)
725
741
  });
726
742
  if (r.status === 429 && !tolerate.includes(429))
727
743
  throw new RateLimitedError(retryAfterMs(r.headers.get("retry-after")));
@@ -914,7 +930,7 @@ var HindsightClient = class {
914
930
  /**
915
931
  * Reflect: synthesized, root-cause answer over the bank. Bounded so a slow server never hangs a
916
932
  * caller — but `timeoutMs` is REQUIRED, deliberately: the right deadline differs by an order of
917
- * magnitude between the automatic hook (25s, to fit the host's window) and the agent-invoked
933
+ * magnitude between the automatic hook (20s, to fit the host's window) and the agent-invoked
918
934
  * tool (minutes, on a populated bank). This used to default to 120s, which silently overrode the
919
935
  * tool's configured window and aborted every high-budget synthesis mid-flight (#3590).
920
936
  */
@@ -927,13 +943,46 @@ var HindsightClient = class {
927
943
  body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
928
944
  signal: ctrl.signal
929
945
  });
930
- if (!resp.ok) throw new Error(`reflect ${resp.status}${this.authHint(resp.status)}`);
946
+ if (!resp.ok)
947
+ throw new ReflectError(
948
+ `reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`,
949
+ resp.status,
950
+ false
951
+ );
931
952
  const data = await resp.json();
932
953
  return (data.text || "").trim();
954
+ } catch (e) {
955
+ if (ctrl.signal.aborted)
956
+ throw new ReflectError(`reflect timed out after ${opts.timeoutMs}ms`, void 0, true, {
957
+ cause: e
958
+ });
959
+ throw e;
933
960
  } finally {
934
961
  clearTimeout(timer);
935
962
  }
936
963
  }
964
+ /**
965
+ * Raw recall restricted to consolidated observations — no LLM in the loop, so it still answers
966
+ * when reflect's synthesis times out or 5xxs. Returns the observation texts in rank order.
967
+ */
968
+ async recallObservations(query, opts) {
969
+ const r = await this.req(
970
+ "POST",
971
+ this.bankUrl("/memories/recall"),
972
+ {
973
+ query,
974
+ types: ["observation"],
975
+ budget: "low",
976
+ max_tokens: opts.maxTokens,
977
+ include: { entities: null }
978
+ },
979
+ [],
980
+ opts.timeoutMs
981
+ );
982
+ if (r.status === 404) return [];
983
+ const j = await r.json();
984
+ return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
985
+ }
937
986
  /**
938
987
  * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
939
988
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
@@ -998,10 +1047,16 @@ var HindsightClient = class {
998
1047
  /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
999
1048
  * Returns page-level hits with a relevance snippet — the real search behind
1000
1049
  * hindsight_search_knowledge_pages. */
1001
- async searchKnowledgePages(query, limit = 3) {
1050
+ async searchKnowledgePages(query, limit = 3, timeoutMs) {
1002
1051
  if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1003
1052
  const q = `?q=${encodeURIComponent(query)}&limit=${limit}`;
1004
- const r = await this.req("GET", this.bankUrl(`/knowledge-base/search${q}`));
1053
+ const r = await this.req(
1054
+ "GET",
1055
+ this.bankUrl(`/knowledge-base/search${q}`),
1056
+ void 0,
1057
+ [],
1058
+ timeoutMs
1059
+ );
1005
1060
  const j = await r.json();
1006
1061
  return (j.results ?? []).map((x) => ({
1007
1062
  id: x.id,
@@ -1681,11 +1736,31 @@ async function syncGitLog(client, repo, opts) {
1681
1736
  }
1682
1737
 
1683
1738
  // src/core/survey.ts
1684
- import { spawn as realSpawn2 } from "child_process";
1739
+ import { spawn as realSpawn3 } from "child_process";
1740
+ import { createHash as createHash4 } from "crypto";
1685
1741
  import { existsSync as existsSync2 } from "fs";
1686
- import { homedir as homedir3 } from "os";
1687
- import { dirname as dirname5, join as join7 } from "path";
1742
+ import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
1743
+ import { dirname as dirname5, join as join8 } from "path";
1688
1744
  import { fileURLToPath as fileURLToPath2 } from "url";
1745
+
1746
+ // src/core/survey-lease.ts
1747
+ import { spawn as realSpawn2 } from "child_process";
1748
+ import { randomUUID } from "crypto";
1749
+ import {
1750
+ mkdirSync as mkdirSync2,
1751
+ mkdtempSync,
1752
+ readdirSync,
1753
+ renameSync,
1754
+ rmdirSync,
1755
+ rmSync,
1756
+ statSync,
1757
+ unlinkSync,
1758
+ utimesSync,
1759
+ writeFileSync
1760
+ } from "fs";
1761
+ import { join as join7 } from "path";
1762
+
1763
+ // src/core/survey.ts
1689
1764
  var SURVEY_DOC_IDS = [
1690
1765
  "repository-component-map",
1691
1766
  "repository-core-concepts",
@@ -1871,8 +1946,8 @@ var log2 = (m) => {
1871
1946
  console.log(`${(/* @__PURE__ */ new Date()).toISOString()} ${m}`);
1872
1947
  log.info("deepen", m);
1873
1948
  };
1874
- var LOCK_DIR = join8(tmpdir2(), "hindsight-coding-agent");
1875
- var LOCK = join8(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1949
+ var LOCK_DIR = join9(tmpdir3(), "hindsight-coding-agent");
1950
+ var LOCK = join9(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1876
1951
  function acquireLock() {
1877
1952
  try {
1878
1953
  const held = JSON.parse(readFileSync4(LOCK, "utf8"));
@@ -1890,8 +1965,8 @@ function acquireLock() {
1890
1965
  } catch {
1891
1966
  }
1892
1967
  try {
1893
- mkdirSync2(LOCK_DIR, { recursive: true });
1894
- writeFileSync(LOCK, JSON.stringify({ pid: process.pid, ts: Date.now() }));
1968
+ mkdirSync3(LOCK_DIR, { recursive: true });
1969
+ writeFileSync2(LOCK, JSON.stringify({ pid: process.pid, ts: Date.now() }));
1895
1970
  return true;
1896
1971
  } catch {
1897
1972
  return false;
@@ -2046,7 +2121,7 @@ async function main() {
2046
2121
  );
2047
2122
  } finally {
2048
2123
  try {
2049
- unlinkSync(LOCK);
2124
+ unlinkSync2(LOCK);
2050
2125
  } catch {
2051
2126
  }
2052
2127
  }
@@ -2058,7 +2133,7 @@ main().catch((e) => {
2058
2133
  });
2059
2134
  console.error("deepen failed:", e.message || e);
2060
2135
  try {
2061
- unlinkSync(LOCK);
2136
+ unlinkSync2(LOCK);
2062
2137
  } catch {
2063
2138
  }
2064
2139
  process.exit(1);