@vectorize-io/hindsight-coding-agents 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1011,11 +1011,14 @@ var HindsightClient = class {
1011
1011
 
1012
1012
  // src/core/diag.ts
1013
1013
  import { appendFileSync as appendFileSync2 } from "fs";
1014
+ function diagFilePath() {
1015
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
1016
+ }
1014
1017
  function diag(harness, event, extra = {}) {
1015
1018
  log.debug(harness, `diag:${event}`, extra);
1016
1019
  try {
1017
1020
  appendFileSync2(
1018
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
1021
+ diagFilePath(),
1019
1022
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
1020
1023
  );
1021
1024
  } catch {
@@ -15642,6 +15645,18 @@ function resolveClaudeBin(explicit) {
15642
15645
  }
15643
15646
  return "claude";
15644
15647
  }
15648
+ var SURVEY_AGENT = "hindsight-survey";
15649
+ var SURVEY_AGENT_CONFIG = {
15650
+ description: "One-time read-only structural survey that seeds this repository's Hindsight memory.",
15651
+ mode: "primary",
15652
+ permission: {
15653
+ "*": "deny",
15654
+ read: "allow",
15655
+ grep: "allow",
15656
+ glob: "allow",
15657
+ hindsight_ingest_document: "allow"
15658
+ }
15659
+ };
15645
15660
  function resolveAgentBin(harness, claudeBin) {
15646
15661
  switch (harness) {
15647
15662
  case "claude-code":
@@ -15762,7 +15777,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
15762
15777
  case "opencode": {
15763
15778
  return {
15764
15779
  bin,
15765
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
15780
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
15766
15781
  env
15767
15782
  };
15768
15783
  }
@@ -16074,10 +16089,10 @@ async function supportsAppend(client) {
16074
16089
  return false;
16075
16090
  }
16076
16091
  }
16092
+ var DEFAULT_RETRY_WINDOW_MS = 6e4;
16077
16093
  var RETAIN_RETRY_ATTEMPTS = 2;
16078
- var RETAIN_RETRY_BUDGET_MS = 6e3;
16079
- async function submitWithRetry(send, isStillNewest) {
16080
- let spent = 0;
16094
+ var REQUEST_BUDGET_MS = 15e3;
16095
+ async function submitWithRetry(send, isStillNewest, retryUntil) {
16081
16096
  for (let attempt = 0; ; attempt++) {
16082
16097
  try {
16083
16098
  return await send();
@@ -16085,8 +16100,7 @@ async function submitWithRetry(send, isStillNewest) {
16085
16100
  const limited = e instanceof RateLimitedError;
16086
16101
  if (!limited || attempt >= RETAIN_RETRY_ATTEMPTS || !isStillNewest()) throw e;
16087
16102
  const wait = e.retryAfterMs || 1e3;
16088
- if (wait > RETAIN_RETRY_BUDGET_MS - spent) throw e;
16089
- spent += wait;
16103
+ if (Date.now() + wait + REQUEST_BUDGET_MS > retryUntil) throw e;
16090
16104
  await sleep(wait);
16091
16105
  }
16092
16106
  }
@@ -16106,14 +16120,24 @@ function serialize(cursors, sessionId, write2) {
16106
16120
  }
16107
16121
  async function retainLiveSession(client, sessionId, turns, startTs, harness, opts = {}) {
16108
16122
  const cursors = opts.cursors;
16109
- if (!cursors) return writeSession(client, sessionId, turns, startTs, harness, opts.stamp);
16123
+ if (!cursors)
16124
+ return writeSession(
16125
+ client,
16126
+ sessionId,
16127
+ turns,
16128
+ startTs,
16129
+ harness,
16130
+ opts.stamp,
16131
+ void 0,
16132
+ opts.retryUntil
16133
+ );
16110
16134
  return serialize(
16111
16135
  cursors,
16112
16136
  sessionId,
16113
- () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors)
16137
+ () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors, opts.retryUntil)
16114
16138
  );
16115
16139
  }
16116
- async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors) {
16140
+ async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors, retryUntil = Date.now() + DEFAULT_RETRY_WINDOW_MS) {
16117
16141
  const refId = `conversation:${sessionId}`;
16118
16142
  const appendSupported = Boolean(cursors) && await supportsAppend(client);
16119
16143
  const plan = planRetain(turns, cursors?.read(sessionId), { appendSupported, bank: client.bank });
@@ -16165,7 +16189,8 @@ ${content}`),
16165
16189
  if (!cursors) return true;
16166
16190
  const now = cursors.read(sessionId);
16167
16191
  return now?.turns === claimed.turns && now?.fingerprint === claimed.fingerprint;
16168
- }
16192
+ },
16193
+ retryUntil
16169
16194
  );
16170
16195
  cursors?.write(sessionId, next);
16171
16196
  }
@@ -16467,6 +16492,7 @@ async function buildHookOutput(args) {
16467
16492
  const turns = (cached3.turns ?? 0) + 1;
16468
16493
  let reflectAnswer = cached3.reflectAnswer;
16469
16494
  let reflectRanThisTurn = false;
16495
+ let reflectFailed = false;
16470
16496
  const deferInitialReflect = cached3.deferInitialReflect === true;
16471
16497
  if (deferInitialReflect) {
16472
16498
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -16491,6 +16517,7 @@ async function buildHookOutput(args) {
16491
16517
  });
16492
16518
  } catch (e) {
16493
16519
  reflectAnswer = "";
16520
+ reflectFailed = true;
16494
16521
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
16495
16522
  error: String(e?.message || e).slice(0, 200)
16496
16523
  });
@@ -16538,6 +16565,8 @@ async function buildHookOutput(args) {
16538
16565
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
16539
16566
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
16540
16567
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
16568
+ } else if (reflectFailed) {
16569
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
16541
16570
  }
16542
16571
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
16543
16572
  }
@@ -29255,6 +29284,12 @@ var jsonChatReader = (harness) => ({
29255
29284
  });
29256
29285
 
29257
29286
  // src/harness/opencode.ts
29287
+ var surveyAgentHook = {
29288
+ config: async (cfg) => {
29289
+ cfg.agent ??= {};
29290
+ cfg.agent[SURVEY_AGENT] ??= SURVEY_AGENT_CONFIG;
29291
+ }
29292
+ };
29258
29293
  var textOf = (parts) => (parts || []).filter((p) => p?.type === "text" && p.text).map((p) => p.text).join("\n").trim();
29259
29294
  var chatReader = jsonChatReader("opencode");
29260
29295
  function toOpencodeTool(spec) {
@@ -29275,6 +29310,7 @@ function createRuntime(core) {
29275
29310
  const tools = {};
29276
29311
  for (const spec of core.toolSpecs()) tools[spec.name] = toOpencodeTool(spec);
29277
29312
  return {
29313
+ ...surveyAgentHook,
29278
29314
  tool: tools,
29279
29315
  // Each user turn: recall on the prompt; the injection it builds is pushed by system.transform.
29280
29316
  "chat.message": async (input, output) => {
package/dist/installer.js CHANGED
@@ -76,11 +76,14 @@ var log = {
76
76
  };
77
77
 
78
78
  // src/core/diag.ts
79
+ function diagFilePath() {
80
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
81
+ }
79
82
  function diag(harness, event, extra = {}) {
80
83
  log.debug(harness, `diag:${event}`, extra);
81
84
  try {
82
85
  appendFileSync2(
83
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
86
+ diagFilePath(),
84
87
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
85
88
  );
86
89
  } catch {
@@ -685,6 +688,7 @@ var HOOK_HARNESSES = {
685
688
  sessionStart: standardSessionStart("claude-code"),
686
689
  prompt: claudePrompt,
687
690
  retain: {
691
+ hostTimeoutSec: 60,
688
692
  harness: "claude-code",
689
693
  parse: (ev) => ({
690
694
  sessionId: ev.session_id,
@@ -703,6 +707,7 @@ var HOOK_HARNESSES = {
703
707
  sessionStart: standardSessionStart("codex"),
704
708
  prompt: codexPrompt,
705
709
  retain: {
710
+ hostTimeoutSec: 60,
706
711
  harness: "codex",
707
712
  parse: (ev) => ({
708
713
  sessionId: ev.session_id,
@@ -731,6 +736,7 @@ var HOOK_HARNESSES = {
731
736
  },
732
737
  prompt: antigravityPrompt,
733
738
  retain: {
739
+ hostTimeoutSec: 30,
734
740
  harness: "antigravity-cli",
735
741
  parse: (ev) => ({
736
742
  sessionId: ev.conversationId,
@@ -759,6 +765,7 @@ var HOOK_HARNESSES = {
759
765
  },
760
766
  prompt: cursorPrompt,
761
767
  retain: {
768
+ hostTimeoutSec: 30,
762
769
  harness: "cursor-cli",
763
770
  parse: (ev) => ({
764
771
  sessionId: ev.conversation_id ?? ev.session_id,
@@ -792,6 +799,7 @@ var HOOK_HARNESSES = {
792
799
  },
793
800
  prompt: copilotPrompt,
794
801
  retain: {
802
+ hostTimeoutSec: 60,
795
803
  harness: "copilot-cli",
796
804
  parse: (ev) => ({
797
805
  sessionId: ev.sessionId,
@@ -820,6 +828,7 @@ var HOOK_HARNESSES = {
820
828
  },
821
829
  prompt: devinPrompt,
822
830
  retain: {
831
+ hostTimeoutSec: 60,
823
832
  harness: "devin-cli",
824
833
  parse: (ev) => {
825
834
  const sessionId = ev.session_id;
@@ -859,6 +868,7 @@ var HOOK_HARNESSES = {
859
868
  })
860
869
  },
861
870
  retain: {
871
+ hostTimeoutSec: 60,
862
872
  harness: "grok-build",
863
873
  parse: (ev) => ({
864
874
  sessionId: ev.sessionId,
package/dist/kilo.js CHANGED
@@ -1011,11 +1011,14 @@ var HindsightClient = class {
1011
1011
 
1012
1012
  // src/core/diag.ts
1013
1013
  import { appendFileSync as appendFileSync2 } from "fs";
1014
+ function diagFilePath() {
1015
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
1016
+ }
1014
1017
  function diag(harness, event, extra = {}) {
1015
1018
  log.debug(harness, `diag:${event}`, extra);
1016
1019
  try {
1017
1020
  appendFileSync2(
1018
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
1021
+ diagFilePath(),
1019
1022
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
1020
1023
  );
1021
1024
  } catch {
@@ -15642,6 +15645,18 @@ function resolveClaudeBin(explicit) {
15642
15645
  }
15643
15646
  return "claude";
15644
15647
  }
15648
+ var SURVEY_AGENT = "hindsight-survey";
15649
+ var SURVEY_AGENT_CONFIG = {
15650
+ description: "One-time read-only structural survey that seeds this repository's Hindsight memory.",
15651
+ mode: "primary",
15652
+ permission: {
15653
+ "*": "deny",
15654
+ read: "allow",
15655
+ grep: "allow",
15656
+ glob: "allow",
15657
+ hindsight_ingest_document: "allow"
15658
+ }
15659
+ };
15645
15660
  function resolveAgentBin(harness, claudeBin) {
15646
15661
  switch (harness) {
15647
15662
  case "claude-code":
@@ -15762,7 +15777,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
15762
15777
  case "opencode": {
15763
15778
  return {
15764
15779
  bin,
15765
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
15780
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
15766
15781
  env
15767
15782
  };
15768
15783
  }
@@ -16074,10 +16089,10 @@ async function supportsAppend(client) {
16074
16089
  return false;
16075
16090
  }
16076
16091
  }
16092
+ var DEFAULT_RETRY_WINDOW_MS = 6e4;
16077
16093
  var RETAIN_RETRY_ATTEMPTS = 2;
16078
- var RETAIN_RETRY_BUDGET_MS = 6e3;
16079
- async function submitWithRetry(send, isStillNewest) {
16080
- let spent = 0;
16094
+ var REQUEST_BUDGET_MS = 15e3;
16095
+ async function submitWithRetry(send, isStillNewest, retryUntil) {
16081
16096
  for (let attempt = 0; ; attempt++) {
16082
16097
  try {
16083
16098
  return await send();
@@ -16085,8 +16100,7 @@ async function submitWithRetry(send, isStillNewest) {
16085
16100
  const limited = e instanceof RateLimitedError;
16086
16101
  if (!limited || attempt >= RETAIN_RETRY_ATTEMPTS || !isStillNewest()) throw e;
16087
16102
  const wait = e.retryAfterMs || 1e3;
16088
- if (wait > RETAIN_RETRY_BUDGET_MS - spent) throw e;
16089
- spent += wait;
16103
+ if (Date.now() + wait + REQUEST_BUDGET_MS > retryUntil) throw e;
16090
16104
  await sleep(wait);
16091
16105
  }
16092
16106
  }
@@ -16106,14 +16120,24 @@ function serialize(cursors, sessionId, write2) {
16106
16120
  }
16107
16121
  async function retainLiveSession(client, sessionId, turns, startTs, harness, opts = {}) {
16108
16122
  const cursors = opts.cursors;
16109
- if (!cursors) return writeSession(client, sessionId, turns, startTs, harness, opts.stamp);
16123
+ if (!cursors)
16124
+ return writeSession(
16125
+ client,
16126
+ sessionId,
16127
+ turns,
16128
+ startTs,
16129
+ harness,
16130
+ opts.stamp,
16131
+ void 0,
16132
+ opts.retryUntil
16133
+ );
16110
16134
  return serialize(
16111
16135
  cursors,
16112
16136
  sessionId,
16113
- () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors)
16137
+ () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors, opts.retryUntil)
16114
16138
  );
16115
16139
  }
16116
- async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors) {
16140
+ async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors, retryUntil = Date.now() + DEFAULT_RETRY_WINDOW_MS) {
16117
16141
  const refId = `conversation:${sessionId}`;
16118
16142
  const appendSupported = Boolean(cursors) && await supportsAppend(client);
16119
16143
  const plan = planRetain(turns, cursors?.read(sessionId), { appendSupported, bank: client.bank });
@@ -16165,7 +16189,8 @@ ${content}`),
16165
16189
  if (!cursors) return true;
16166
16190
  const now = cursors.read(sessionId);
16167
16191
  return now?.turns === claimed.turns && now?.fingerprint === claimed.fingerprint;
16168
- }
16192
+ },
16193
+ retryUntil
16169
16194
  );
16170
16195
  cursors?.write(sessionId, next);
16171
16196
  }
@@ -16467,6 +16492,7 @@ async function buildHookOutput(args) {
16467
16492
  const turns = (cached3.turns ?? 0) + 1;
16468
16493
  let reflectAnswer = cached3.reflectAnswer;
16469
16494
  let reflectRanThisTurn = false;
16495
+ let reflectFailed = false;
16470
16496
  const deferInitialReflect = cached3.deferInitialReflect === true;
16471
16497
  if (deferInitialReflect) {
16472
16498
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -16491,6 +16517,7 @@ async function buildHookOutput(args) {
16491
16517
  });
16492
16518
  } catch (e) {
16493
16519
  reflectAnswer = "";
16520
+ reflectFailed = true;
16494
16521
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
16495
16522
  error: String(e?.message || e).slice(0, 200)
16496
16523
  });
@@ -16538,6 +16565,8 @@ async function buildHookOutput(args) {
16538
16565
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
16539
16566
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
16540
16567
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
16568
+ } else if (reflectFailed) {
16569
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
16541
16570
  }
16542
16571
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
16543
16572
  }
@@ -29255,6 +29284,12 @@ var jsonChatReader = (harness) => ({
29255
29284
  });
29256
29285
 
29257
29286
  // src/harness/opencode.ts
29287
+ var surveyAgentHook = {
29288
+ config: async (cfg) => {
29289
+ cfg.agent ??= {};
29290
+ cfg.agent[SURVEY_AGENT] ??= SURVEY_AGENT_CONFIG;
29291
+ }
29292
+ };
29258
29293
  var textOf = (parts) => (parts || []).filter((p) => p?.type === "text" && p.text).map((p) => p.text).join("\n").trim();
29259
29294
  var chatReader = jsonChatReader("opencode");
29260
29295
  function toOpencodeTool(spec) {
@@ -29275,6 +29310,7 @@ function createRuntime(core) {
29275
29310
  const tools = {};
29276
29311
  for (const spec of core.toolSpecs()) tools[spec.name] = toOpencodeTool(spec);
29277
29312
  return {
29313
+ ...surveyAgentHook,
29278
29314
  tool: tools,
29279
29315
  // Each user turn: recall on the prompt; the injection it builds is pushed by system.transform.
29280
29316
  "chat.message": async (input, output) => {
@@ -14892,11 +14892,14 @@ var log = {
14892
14892
  };
14893
14893
 
14894
14894
  // src/core/diag.ts
14895
+ function diagFilePath() {
14896
+ return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
14897
+ }
14895
14898
  function diag(harness, event, extra = {}) {
14896
14899
  log.debug(harness, `diag:${event}`, extra);
14897
14900
  try {
14898
14901
  appendFileSync2(
14899
- process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
14902
+ diagFilePath(),
14900
14903
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
14901
14904
  );
14902
14905
  } catch {
@@ -15641,6 +15644,7 @@ function resolveClaudeBin(explicit) {
15641
15644
  }
15642
15645
  return "claude";
15643
15646
  }
15647
+ var SURVEY_AGENT = "hindsight-survey";
15644
15648
  function resolveAgentBin(harness, claudeBin) {
15645
15649
  switch (harness) {
15646
15650
  case "claude-code":
@@ -15761,7 +15765,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
15761
15765
  case "opencode": {
15762
15766
  return {
15763
15767
  bin,
15764
- args: ["run", "--agent", "plan", SURVEY_PROMPT],
15768
+ args: ["run", "--agent", SURVEY_AGENT, SURVEY_PROMPT],
15765
15769
  env
15766
15770
  };
15767
15771
  }
@@ -16073,10 +16077,10 @@ async function supportsAppend(client) {
16073
16077
  return false;
16074
16078
  }
16075
16079
  }
16080
+ var DEFAULT_RETRY_WINDOW_MS = 6e4;
16076
16081
  var RETAIN_RETRY_ATTEMPTS = 2;
16077
- var RETAIN_RETRY_BUDGET_MS = 6e3;
16078
- async function submitWithRetry(send, isStillNewest) {
16079
- let spent = 0;
16082
+ var REQUEST_BUDGET_MS = 15e3;
16083
+ async function submitWithRetry(send, isStillNewest, retryUntil) {
16080
16084
  for (let attempt = 0; ; attempt++) {
16081
16085
  try {
16082
16086
  return await send();
@@ -16084,8 +16088,7 @@ async function submitWithRetry(send, isStillNewest) {
16084
16088
  const limited = e instanceof RateLimitedError;
16085
16089
  if (!limited || attempt >= RETAIN_RETRY_ATTEMPTS || !isStillNewest()) throw e;
16086
16090
  const wait = e.retryAfterMs || 1e3;
16087
- if (wait > RETAIN_RETRY_BUDGET_MS - spent) throw e;
16088
- spent += wait;
16091
+ if (Date.now() + wait + REQUEST_BUDGET_MS > retryUntil) throw e;
16089
16092
  await sleep(wait);
16090
16093
  }
16091
16094
  }
@@ -16105,14 +16108,24 @@ function serialize(cursors, sessionId, write2) {
16105
16108
  }
16106
16109
  async function retainLiveSession(client, sessionId, turns, startTs, harness, opts = {}) {
16107
16110
  const cursors = opts.cursors;
16108
- if (!cursors) return writeSession(client, sessionId, turns, startTs, harness, opts.stamp);
16111
+ if (!cursors)
16112
+ return writeSession(
16113
+ client,
16114
+ sessionId,
16115
+ turns,
16116
+ startTs,
16117
+ harness,
16118
+ opts.stamp,
16119
+ void 0,
16120
+ opts.retryUntil
16121
+ );
16109
16122
  return serialize(
16110
16123
  cursors,
16111
16124
  sessionId,
16112
- () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors)
16125
+ () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors, opts.retryUntil)
16113
16126
  );
16114
16127
  }
16115
- async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors) {
16128
+ async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors, retryUntil = Date.now() + DEFAULT_RETRY_WINDOW_MS) {
16116
16129
  const refId = `conversation:${sessionId}`;
16117
16130
  const appendSupported = Boolean(cursors) && await supportsAppend(client);
16118
16131
  const plan = planRetain(turns, cursors?.read(sessionId), { appendSupported, bank: client.bank });
@@ -16164,7 +16177,8 @@ ${content}`),
16164
16177
  if (!cursors) return true;
16165
16178
  const now = cursors.read(sessionId);
16166
16179
  return now?.turns === claimed.turns && now?.fingerprint === claimed.fingerprint;
16167
- }
16180
+ },
16181
+ retryUntil
16168
16182
  );
16169
16183
  cursors?.write(sessionId, next);
16170
16184
  }
@@ -16466,6 +16480,7 @@ async function buildHookOutput(args) {
16466
16480
  const turns = (cached2.turns ?? 0) + 1;
16467
16481
  let reflectAnswer = cached2.reflectAnswer;
16468
16482
  let reflectRanThisTurn = false;
16483
+ let reflectFailed = false;
16469
16484
  const deferInitialReflect = cached2.deferInitialReflect === true;
16470
16485
  if (deferInitialReflect) {
16471
16486
  diag(harness, "reflect_deferred_new_bank", { query: prompt.slice(0, 80) });
@@ -16490,6 +16505,7 @@ async function buildHookOutput(args) {
16490
16505
  });
16491
16506
  } catch (e) {
16492
16507
  reflectAnswer = "";
16508
+ reflectFailed = true;
16493
16509
  log.warn(harness, "reflect failed \u2014 session runs without memory", {
16494
16510
  error: String(e?.message || e).slice(0, 200)
16495
16511
  });
@@ -16537,6 +16553,8 @@ async function buildHookOutput(args) {
16537
16553
  const preview = reflectAnswer.replace(/\s+/g, " ").trim();
16538
16554
  notice = `${brandWord()} \xB7 goal: recall this repo's past decisions about \u201C${excerpt}\u201D
16539
16555
  \u21B3 ${preview.length > 140 ? `${preview.slice(0, 140)}\u2026` : preview}`;
16556
+ } else if (reflectFailed) {
16557
+ notice = `${brandWord()} \xB7 no memory this turn \u2014 see ${diagFilePath()}`;
16540
16558
  }
16541
16559
  return { context: kept.length ? kept.join("\n\n") : void 0, notice, pagesKnown: pages.length };
16542
16560
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",