@vectorize-io/hindsight-coding-agents 0.3.2 → 0.3.4

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Long-term project memory for **coding agents**, backed by [Hindsight](https://vectorize.io/hindsight).
4
4
  One package, several agents: a shared reflect-and-inject core with a thin entry point per agent
5
- (**opencode**, **Kilo CLI**, **Cline CLI**, **Prime Agent**, **Claude Code**, **Codex CLI**, **Antigravity CLI**, **Cursor CLI**, **GitHub Copilot CLI**, **Grok Build**). Ingestion is fully
5
+ (**opencode**, **Kilo CLI**, **Cline CLI**, **Prime Agent**, **DeepSeek Harness**, **Claude Code**, **Codex CLI**, **Antigravity CLI**, **Cursor CLI**, **GitHub Copilot CLI**, **Grok Build**). Ingestion is fully
6
6
  automatic — there is no setup command: a repo's git history and conversations flow into its memory
7
7
  bank in the background as you work.
8
8
 
@@ -120,6 +120,21 @@ npx @vectorize-io/hindsight-coding-agents install prime-agent
120
120
 
121
121
  An extension entry in `~/.prime/agent/settings.json` — native tools, no MCP needed.
122
122
 
123
+ #### <img src="https://hindsight.vectorize.io/img/harness/dsh.svg" alt="" width="20" height="20" /> DeepSeek Harness
124
+
125
+ ```bash
126
+ npx @vectorize-io/hindsight-coding-agents install dsh
127
+ ```
128
+
129
+ A Cordis plugin row in `$DSH_HOME/cordis.patch.yml` (`~/.dsh` by default), which every dsh profile
130
+ composes — native tools, no MCP needed. Two dsh-specific notes: one dsh process serves **several
131
+ repositories** (its Web UI opens each session in whatever directory you pick), so the bank is
132
+ resolved per session workspace rather than once per process; and dsh has no plugin-facing notice
133
+ channel, so the seed line goes to the plugin log rather than the UI. Everything model-facing —
134
+ recalled memory, the knowledge preamble, the `hindsight_*` tools — is unaffected. If you prefer the
135
+ published-package route, `dsh plugin --profile web add @vectorize-io/hindsight-coding-agents` works
136
+ too: the package ships the profile patch layer, so nothing else needs editing.
137
+
123
138
  Uninstall the same way: `npx @vectorize-io/hindsight-coding-agents uninstall claude-code` (or `uninstall all`).
124
139
 
125
140
  **Devin CLI needs Node 22.5 or newer.** Its hooks pass only a session id — the conversation itself
@@ -153,7 +168,8 @@ minimal, hand-wired setup.
153
168
 
154
169
  Adding an agent: hook-based → write a `HookSpec` entry point (see `src/cursor-hook.ts`) and register
155
170
  a `hookAdapter` in `src/harness/registry.ts`; persistent-plugin → implement `HarnessAdapter`
156
- (`src/core/types.ts`) fully (see `src/harness/opencode.ts`).
171
+ (`src/core/types.ts`) fully (see `src/harness/opencode.ts`), or bind the host's own plugin API to
172
+ `RuntimeCore` directly when it is not an opencode fork (see `src/cline.ts`, `src/dsh.ts`).
157
173
 
158
174
  ## Migrating from the per-agent plugins
159
175
 
@@ -186,12 +202,14 @@ transcripts are needed either way; going through them directly is simply the sho
186
202
 
187
203
  **How sessions are matched.** A conversation is imported only when the session itself records the
188
204
  directory it ran in — never inferred from a file or folder name. Claude Code writes that directory
189
- on its entries and Codex in its `session_meta` header, so both can be attributed exactly, including
190
- sessions started in a subdirectory of the repo. Guessing was tempting (Claude names its history
205
+ on its entries, Codex in its `session_meta` header and DeepSeek Harness in its session-log header,
206
+ so all three can be attributed exactly, including sessions started in a subdirectory of the repo. Guessing was tempting (Claude names its history
191
207
  folders after the project path) but unsafe: `/` and `.` both encode to `-`, so `repo-sub` is either
192
208
  the subdirectory `repo/sub` or an unrelated sibling repo — and a wrong guess files someone else's
193
209
  conversation into your bank. Sessions that record nothing are skipped and the count is reported.
194
- The other harnesses (opencode, Kilo, Cursor, Cline, Copilot, Devin) keep history in internal SQLite
210
+ DeepSeek Harness logs are Zstandard-framed JSONL under `$DSH_HOME/sessions`, which needs Node 22.15+
211
+ to read; an older Node skips the import with that reason rather than silently importing nothing. The
212
+ other harnesses (opencode, Kilo, Cursor, Cline, Copilot, Devin) keep history in internal SQLite
195
213
  databases with unversioned schemas and are skipped with a reason.
196
214
 
197
215
  **Nothing else is translated.** The old plugin's behavioural settings — 12 `recall*`, 7 `retain*`,
@@ -0,0 +1,18 @@
1
+ # DeepSeek Harness profile layer for Hindsight memory.
2
+ #
3
+ # `dsh plugin --profile <name> add @vectorize-io/hindsight-coding-agents` installs this package into
4
+ # the profile and — because package.json declares `dsh.bundle.patch` — appends this file to the
5
+ # profile's ordered bundle list. Nothing else needs editing: the row below mounts on the host plane,
6
+ # where the pre-step/session-start/turn-stopping events and the layered tools registry all reach
7
+ # every session, including the Web surface's per-session agent presets.
8
+ #
9
+ # Memory itself is configured OUTSIDE dsh, in ~/.hindsight/coding-agent.json (server URL, token,
10
+ # bank naming, opt-outs) — the same file every other Hindsight coding-agent harness reads. To turn
11
+ # it off for one profile without uninstalling, patch this row in the profile's own
12
+ # cordis.patch.yml:
13
+ #
14
+ # - id: hindsight
15
+ # disabled: true
16
+ - insert:
17
+ - id: hindsight
18
+ name: "@vectorize-io/hindsight-coding-agents/dsh"
@@ -372,13 +372,30 @@ var log = {
372
372
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
373
373
  error: (scope, msg, extra) => write("error", scope, msg, extra)
374
374
  };
375
+ function describeError(value, maxChars = 200) {
376
+ const parts = [];
377
+ const seen = /* @__PURE__ */ new Set();
378
+ let current2 = value;
379
+ while (current2 && !seen.has(current2)) {
380
+ seen.add(current2);
381
+ const error = current2;
382
+ const text = typeof error.message === "string" ? error.message : String(current2);
383
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
384
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
385
+ current2 = error.cause;
386
+ }
387
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
388
+ }
375
389
 
376
390
  // src/core/diag.ts
391
+ function diagFilePath() {
392
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
393
+ }
377
394
  function diag(harness, event, extra = {}) {
378
395
  log.debug(harness, `diag:${event}`, extra);
379
396
  try {
380
397
  appendFileSync2(
381
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
398
+ diagFilePath(),
382
399
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
383
400
  );
384
401
  } catch {
@@ -1136,6 +1153,7 @@ async function buildHookOutput(args) {
1136
1153
  const turns = (cached.turns ?? 0) + 1;
1137
1154
  let reflectAnswer = cached.reflectAnswer;
1138
1155
  let reflectRanThisTurn = false;
1156
+ let reflectFailed = false;
1139
1157
  const deferInitialReflect = cached.deferInitialReflect === true;
1140
1158
  if (deferInitialReflect) {
1141
1159
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -1160,12 +1178,13 @@ async function buildHookOutput(args) {
1160
1178
  });
1161
1179
  } catch (e) {
1162
1180
  reflectAnswer = "";
1181
+ reflectFailed = true;
1163
1182
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
1164
- error: String(e?.message || e).slice(0, 200)
1183
+ error: describeError(e)
1165
1184
  });
1166
1185
  diag(harness, "reflect_failed", {
1167
1186
  ms: Date.now() - t0,
1168
- error: String(e?.message || e).slice(0, 200),
1187
+ error: describeError(e),
1169
1188
  query: prompt.slice(0, 80)
1170
1189
  });
1171
1190
  }
@@ -1184,7 +1203,7 @@ async function buildHookOutput(args) {
1184
1203
  client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
1185
1204
  {
1186
1205
  ms: Date.now() - t0,
1187
- error: String(e?.message || e).slice(0, 200)
1206
+ error: describeError(e)
1188
1207
  }
1189
1208
  );
1190
1209
  }
@@ -1207,6 +1226,8 @@ async function buildHookOutput(args) {
1207
1226
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
1208
1227
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
1209
1228
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
1229
+ } else if (reflectFailed) {
1230
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
1210
1231
  }
1211
1232
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
1212
1233
  }
@@ -349,13 +349,30 @@ var log = {
349
349
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
350
350
  error: (scope, msg, extra) => write("error", scope, msg, extra)
351
351
  };
352
+ function describeError(value, maxChars = 200) {
353
+ const parts = [];
354
+ const seen = /* @__PURE__ */ new Set();
355
+ let current2 = value;
356
+ while (current2 && !seen.has(current2)) {
357
+ seen.add(current2);
358
+ const error = current2;
359
+ const text = typeof error.message === "string" ? error.message : String(current2);
360
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
361
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
362
+ current2 = error.cause;
363
+ }
364
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
365
+ }
352
366
 
353
367
  // src/core/diag.ts
368
+ function diagFilePath() {
369
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
370
+ }
354
371
  function diag(harness, event, extra = {}) {
355
372
  log.debug(harness, `diag:${event}`, extra);
356
373
  try {
357
374
  appendFileSync2(
358
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
375
+ diagFilePath(),
359
376
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
360
377
  );
361
378
  } catch {
@@ -1522,11 +1539,11 @@ async function buildRetain(args) {
1522
1539
  diag(harness, "retain_ok", { ms: Date.now() - t0, turns: turns.length, session: sessionId });
1523
1540
  } catch (e) {
1524
1541
  log.warn(harness, "session write-back failed", {
1525
- error: String(e?.message || e).slice(0, 200)
1542
+ error: describeError(e)
1526
1543
  });
1527
1544
  diag(harness, "retain_failed", {
1528
1545
  ms: Date.now() - t0,
1529
- error: String(e?.message || e).slice(0, 200),
1546
+ error: describeError(e),
1530
1547
  session: sessionId
1531
1548
  });
1532
1549
  }
@@ -372,13 +372,30 @@ var log = {
372
372
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
373
373
  error: (scope, msg, extra) => write("error", scope, msg, extra)
374
374
  };
375
+ function describeError(value, maxChars = 200) {
376
+ const parts = [];
377
+ const seen = /* @__PURE__ */ new Set();
378
+ let current2 = value;
379
+ while (current2 && !seen.has(current2)) {
380
+ seen.add(current2);
381
+ const error = current2;
382
+ const text = typeof error.message === "string" ? error.message : String(current2);
383
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
384
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
385
+ current2 = error.cause;
386
+ }
387
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
388
+ }
375
389
 
376
390
  // src/core/diag.ts
391
+ function diagFilePath() {
392
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
393
+ }
377
394
  function diag(harness, event, extra = {}) {
378
395
  log.debug(harness, `diag:${event}`, extra);
379
396
  try {
380
397
  appendFileSync2(
381
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
398
+ diagFilePath(),
382
399
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
383
400
  );
384
401
  } catch {
@@ -1136,6 +1153,7 @@ async function buildHookOutput(args) {
1136
1153
  const turns = (cached.turns ?? 0) + 1;
1137
1154
  let reflectAnswer = cached.reflectAnswer;
1138
1155
  let reflectRanThisTurn = false;
1156
+ let reflectFailed = false;
1139
1157
  const deferInitialReflect = cached.deferInitialReflect === true;
1140
1158
  if (deferInitialReflect) {
1141
1159
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -1160,12 +1178,13 @@ async function buildHookOutput(args) {
1160
1178
  });
1161
1179
  } catch (e) {
1162
1180
  reflectAnswer = "";
1181
+ reflectFailed = true;
1163
1182
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
1164
- error: String(e?.message || e).slice(0, 200)
1183
+ error: describeError(e)
1165
1184
  });
1166
1185
  diag(harness, "reflect_failed", {
1167
1186
  ms: Date.now() - t0,
1168
- error: String(e?.message || e).slice(0, 200),
1187
+ error: describeError(e),
1169
1188
  query: prompt.slice(0, 80)
1170
1189
  });
1171
1190
  }
@@ -1184,7 +1203,7 @@ async function buildHookOutput(args) {
1184
1203
  client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
1185
1204
  {
1186
1205
  ms: Date.now() - t0,
1187
- error: String(e?.message || e).slice(0, 200)
1206
+ error: describeError(e)
1188
1207
  }
1189
1208
  );
1190
1209
  }
@@ -1207,6 +1226,8 @@ async function buildHookOutput(args) {
1207
1226
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
1208
1227
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
1209
1228
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
1229
+ } else if (reflectFailed) {
1230
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
1210
1231
  }
1211
1232
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
1212
1233
  }
@@ -377,11 +377,14 @@ var log = {
377
377
  };
378
378
 
379
379
  // src/core/diag.ts
380
+ function diagFilePath() {
381
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
382
+ }
380
383
  function diag(harness, event, extra = {}) {
381
384
  log.debug(harness, `diag:${event}`, extra);
382
385
  try {
383
386
  appendFileSync2(
384
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
387
+ diagFilePath(),
385
388
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
386
389
  );
387
390
  } catch {
@@ -1423,6 +1426,7 @@ function resolveClaudeBin(explicit) {
1423
1426
  }
1424
1427
  return "claude";
1425
1428
  }
1429
+ var SURVEY_AGENT = "hindsight-survey";
1426
1430
  function resolveAgentBin(harness, claudeBin) {
1427
1431
  switch (harness) {
1428
1432
  case "claude-code":
@@ -1543,7 +1547,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
1543
1547
  case "opencode": {
1544
1548
  return {
1545
1549
  bin,
1546
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
1550
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
1547
1551
  env
1548
1552
  };
1549
1553
  }
@@ -349,13 +349,30 @@ var log = {
349
349
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
350
350
  error: (scope, msg, extra) => write("error", scope, msg, extra)
351
351
  };
352
+ function describeError(value, maxChars = 200) {
353
+ const parts = [];
354
+ const seen = /* @__PURE__ */ new Set();
355
+ let current2 = value;
356
+ while (current2 && !seen.has(current2)) {
357
+ seen.add(current2);
358
+ const error = current2;
359
+ const text = typeof error.message === "string" ? error.message : String(current2);
360
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
361
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
362
+ current2 = error.cause;
363
+ }
364
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
365
+ }
352
366
 
353
367
  // src/core/diag.ts
368
+ function diagFilePath() {
369
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
370
+ }
354
371
  function diag(harness, event, extra = {}) {
355
372
  log.debug(harness, `diag:${event}`, extra);
356
373
  try {
357
374
  appendFileSync2(
358
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
375
+ diagFilePath(),
359
376
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
360
377
  );
361
378
  } catch {
@@ -1522,11 +1539,11 @@ async function buildRetain(args) {
1522
1539
  diag(harness, "retain_ok", { ms: Date.now() - t0, turns: turns.length, session: sessionId });
1523
1540
  } catch (e) {
1524
1541
  log.warn(harness, "session write-back failed", {
1525
- error: String(e?.message || e).slice(0, 200)
1542
+ error: describeError(e)
1526
1543
  });
1527
1544
  diag(harness, "retain_failed", {
1528
1545
  ms: Date.now() - t0,
1529
- error: String(e?.message || e).slice(0, 200),
1546
+ error: describeError(e),
1530
1547
  session: sessionId
1531
1548
  });
1532
1549
  }
package/dist/cline.js CHANGED
@@ -1008,13 +1008,30 @@ var log = {
1008
1008
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
1009
1009
  error: (scope, msg, extra) => write("error", scope, msg, extra)
1010
1010
  };
1011
+ function describeError(value, maxChars = 200) {
1012
+ const parts = [];
1013
+ const seen = /* @__PURE__ */ new Set();
1014
+ let current2 = value;
1015
+ while (current2 && !seen.has(current2)) {
1016
+ seen.add(current2);
1017
+ const error51 = current2;
1018
+ const text = typeof error51.message === "string" ? error51.message : String(current2);
1019
+ const withCode = error51.code ? `${text} (${String(error51.code)})` : text;
1020
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
1021
+ current2 = error51.cause;
1022
+ }
1023
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
1024
+ }
1011
1025
 
1012
1026
  // src/core/diag.ts
1027
+ function diagFilePath() {
1028
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
1029
+ }
1013
1030
  function diag(harness, event, extra = {}) {
1014
1031
  log.debug(harness, `diag:${event}`, extra);
1015
1032
  try {
1016
1033
  appendFileSync2(
1017
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
1034
+ diagFilePath(),
1018
1035
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
1019
1036
  );
1020
1037
  } catch {
@@ -15641,6 +15658,7 @@ function resolveClaudeBin(explicit) {
15641
15658
  }
15642
15659
  return "claude";
15643
15660
  }
15661
+ var SURVEY_AGENT = "hindsight-survey";
15644
15662
  function resolveAgentBin(harness, claudeBin) {
15645
15663
  switch (harness) {
15646
15664
  case "claude-code":
@@ -15761,7 +15779,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
15761
15779
  case "opencode": {
15762
15780
  return {
15763
15781
  bin,
15764
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
15782
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
15765
15783
  env
15766
15784
  };
15767
15785
  }
@@ -15870,7 +15888,7 @@ function ok(value) {
15870
15888
  return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
15871
15889
  }
15872
15890
  function err(e) {
15873
- const message = String(e?.message ?? e);
15891
+ const message = describeError(e);
15874
15892
  return { content: [{ type: "text", text: JSON.stringify({ error: message }) }], isError: true };
15875
15893
  }
15876
15894
  function guarded(fn) {
@@ -16476,6 +16494,7 @@ async function buildHookOutput(args) {
16476
16494
  const turns = (cached2.turns ?? 0) + 1;
16477
16495
  let reflectAnswer = cached2.reflectAnswer;
16478
16496
  let reflectRanThisTurn = false;
16497
+ let reflectFailed = false;
16479
16498
  const deferInitialReflect = cached2.deferInitialReflect === true;
16480
16499
  if (deferInitialReflect) {
16481
16500
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -16500,12 +16519,13 @@ async function buildHookOutput(args) {
16500
16519
  });
16501
16520
  } catch (e) {
16502
16521
  reflectAnswer = "";
16522
+ reflectFailed = true;
16503
16523
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
16504
- error: String(e?.message || e).slice(0, 200)
16524
+ error: describeError(e)
16505
16525
  });
16506
16526
  diag(harness, "reflect_failed", {
16507
16527
  ms: Date.now() - t0,
16508
- error: String(e?.message || e).slice(0, 200),
16528
+ error: describeError(e),
16509
16529
  query: prompt.slice(0, 80)
16510
16530
  });
16511
16531
  }
@@ -16524,7 +16544,7 @@ async function buildHookOutput(args) {
16524
16544
  client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
16525
16545
  {
16526
16546
  ms: Date.now() - t0,
16527
- error: String(e?.message || e).slice(0, 200)
16547
+ error: describeError(e)
16528
16548
  }
16529
16549
  );
16530
16550
  }
@@ -16547,6 +16567,8 @@ async function buildHookOutput(args) {
16547
16567
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
16548
16568
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
16549
16569
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
16570
+ } else if (reflectFailed) {
16571
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
16550
16572
  }
16551
16573
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
16552
16574
  }
@@ -16718,7 +16740,7 @@ var RuntimeCore = class {
16718
16740
  turns = await this.fetchTranscript(sessionId2);
16719
16741
  } catch (e) {
16720
16742
  diag(this.harness, "idle_fetch_failed", {
16721
- error: String(e?.message || e).slice(0, 200),
16743
+ error: describeError(e),
16722
16744
  session: sessionId2
16723
16745
  });
16724
16746
  return;
@@ -16758,7 +16780,7 @@ var RuntimeCore = class {
16758
16780
  ).catch(
16759
16781
  (e) => diag(this.harness, "retain_failed", {
16760
16782
  ms: Date.now() - t0,
16761
- error: String(e?.message || e).slice(0, 200),
16783
+ error: describeError(e),
16762
16784
  session: sessionId2,
16763
16785
  trigger
16764
16786
  })
@@ -372,13 +372,30 @@ var log = {
372
372
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
373
373
  error: (scope, msg, extra) => write("error", scope, msg, extra)
374
374
  };
375
+ function describeError(value, maxChars = 200) {
376
+ const parts = [];
377
+ const seen = /* @__PURE__ */ new Set();
378
+ let current2 = value;
379
+ while (current2 && !seen.has(current2)) {
380
+ seen.add(current2);
381
+ const error = current2;
382
+ const text = typeof error.message === "string" ? error.message : String(current2);
383
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
384
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
385
+ current2 = error.cause;
386
+ }
387
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
388
+ }
375
389
 
376
390
  // src/core/diag.ts
391
+ function diagFilePath() {
392
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
393
+ }
377
394
  function diag(harness, event, extra = {}) {
378
395
  log.debug(harness, `diag:${event}`, extra);
379
396
  try {
380
397
  appendFileSync2(
381
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
398
+ diagFilePath(),
382
399
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
383
400
  );
384
401
  } catch {
@@ -1136,6 +1153,7 @@ async function buildHookOutput(args) {
1136
1153
  const turns = (cached.turns ?? 0) + 1;
1137
1154
  let reflectAnswer = cached.reflectAnswer;
1138
1155
  let reflectRanThisTurn = false;
1156
+ let reflectFailed = false;
1139
1157
  const deferInitialReflect = cached.deferInitialReflect === true;
1140
1158
  if (deferInitialReflect) {
1141
1159
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -1160,12 +1178,13 @@ async function buildHookOutput(args) {
1160
1178
  });
1161
1179
  } catch (e) {
1162
1180
  reflectAnswer = "";
1181
+ reflectFailed = true;
1163
1182
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
1164
- error: String(e?.message || e).slice(0, 200)
1183
+ error: describeError(e)
1165
1184
  });
1166
1185
  diag(harness, "reflect_failed", {
1167
1186
  ms: Date.now() - t0,
1168
- error: String(e?.message || e).slice(0, 200),
1187
+ error: describeError(e),
1169
1188
  query: prompt.slice(0, 80)
1170
1189
  });
1171
1190
  }
@@ -1184,7 +1203,7 @@ async function buildHookOutput(args) {
1184
1203
  client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
1185
1204
  {
1186
1205
  ms: Date.now() - t0,
1187
- error: String(e?.message || e).slice(0, 200)
1206
+ error: describeError(e)
1188
1207
  }
1189
1208
  );
1190
1209
  }
@@ -1207,6 +1226,8 @@ async function buildHookOutput(args) {
1207
1226
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
1208
1227
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
1209
1228
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
1229
+ } else if (reflectFailed) {
1230
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
1210
1231
  }
1211
1232
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
1212
1233
  }
@@ -377,11 +377,14 @@ var log = {
377
377
  };
378
378
 
379
379
  // src/core/diag.ts
380
+ function diagFilePath() {
381
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
382
+ }
380
383
  function diag(harness, event, extra = {}) {
381
384
  log.debug(harness, `diag:${event}`, extra);
382
385
  try {
383
386
  appendFileSync2(
384
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
387
+ diagFilePath(),
385
388
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
386
389
  );
387
390
  } catch {
@@ -1423,6 +1426,7 @@ function resolveClaudeBin(explicit) {
1423
1426
  }
1424
1427
  return "claude";
1425
1428
  }
1429
+ var SURVEY_AGENT = "hindsight-survey";
1426
1430
  function resolveAgentBin(harness, claudeBin) {
1427
1431
  switch (harness) {
1428
1432
  case "claude-code":
@@ -1543,7 +1547,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
1543
1547
  case "opencode": {
1544
1548
  return {
1545
1549
  bin,
1546
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
1550
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
1547
1551
  env
1548
1552
  };
1549
1553
  }
@@ -349,13 +349,30 @@ var log = {
349
349
  warn: (scope, msg, extra) => write("warn", scope, msg, extra),
350
350
  error: (scope, msg, extra) => write("error", scope, msg, extra)
351
351
  };
352
+ function describeError(value, maxChars = 200) {
353
+ const parts = [];
354
+ const seen = /* @__PURE__ */ new Set();
355
+ let current2 = value;
356
+ while (current2 && !seen.has(current2)) {
357
+ seen.add(current2);
358
+ const error = current2;
359
+ const text = typeof error.message === "string" ? error.message : String(current2);
360
+ const withCode = error.code ? `${text} (${String(error.code)})` : text;
361
+ if (withCode && parts.at(-1) !== withCode) parts.push(withCode);
362
+ current2 = error.cause;
363
+ }
364
+ return (parts.join(": ") || String(value)).slice(0, maxChars);
365
+ }
352
366
 
353
367
  // src/core/diag.ts
368
+ function diagFilePath() {
369
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
370
+ }
354
371
  function diag(harness, event, extra = {}) {
355
372
  log.debug(harness, `diag:${event}`, extra);
356
373
  try {
357
374
  appendFileSync2(
358
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
375
+ diagFilePath(),
359
376
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
360
377
  );
361
378
  } catch {
@@ -1522,11 +1539,11 @@ async function buildRetain(args) {
1522
1539
  diag(harness, "retain_ok", { ms: Date.now() - t0, turns: turns.length, session: sessionId });
1523
1540
  } catch (e) {
1524
1541
  log.warn(harness, "session write-back failed", {
1525
- error: String(e?.message || e).slice(0, 200)
1542
+ error: describeError(e)
1526
1543
  });
1527
1544
  diag(harness, "retain_failed", {
1528
1545
  ms: Date.now() - t0,
1529
- error: String(e?.message || e).slice(0, 200),
1546
+ error: describeError(e),
1530
1547
  session: sessionId
1531
1548
  });
1532
1549
  }