haansi 0.1.104 → 0.1.105

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 (2) hide show
  1. package/dist/haansi.js +161 -40
  2. package/package.json +1 -1
package/dist/haansi.js CHANGED
@@ -95,7 +95,7 @@ var require_package = __commonJS({
95
95
  "package.json"(exports2, module2) {
96
96
  module2.exports = {
97
97
  name: "haansi",
98
- version: "0.1.104",
98
+ version: "0.1.105",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -86485,14 +86485,14 @@ var init_replay_focus = __esm({
86485
86485
 
86486
86486
  // src/commands/replay-preflight.ts
86487
86487
  function refusalOf(status, body) {
86488
- let said = body.trim();
86488
+ let said2 = body.trim();
86489
86489
  try {
86490
86490
  const parsed = JSON.parse(body);
86491
86491
  const m = parsed.message ?? parsed.error;
86492
- if (typeof m === "string" && m.trim()) said = m.trim();
86492
+ if (typeof m === "string" && m.trim()) said2 = m.trim();
86493
86493
  } catch {
86494
86494
  }
86495
- const short = said.replace(/\s+/g, " ").slice(0, 120);
86495
+ const short = said2.replace(/\s+/g, " ").slice(0, 120);
86496
86496
  return short ? `${status}: ${short}` : String(status);
86497
86497
  }
86498
86498
  async function check2(fetchImpl, name, url2, init2) {
@@ -86713,6 +86713,18 @@ var init_replay_preflight = __esm({
86713
86713
  });
86714
86714
 
86715
86715
  // src/commands/replay-fallback.ts
86716
+ function solutionsSearchQuery(q, hints) {
86717
+ const params = new URLSearchParams();
86718
+ params.set("q", q);
86719
+ params.set("top_k", String(SOLUTIONS_PER_QUERY));
86720
+ for (const t of clipList2(hints?.failingTests))
86721
+ params.append("failing_tests", t);
86722
+ const error2 = hints?.error?.trim();
86723
+ if (error2) params.set("error", error2.slice(0, MAX_HINT_ERROR_CHARS2));
86724
+ for (const f of clipList2(hints?.files)) params.append("files", f);
86725
+ for (const n of clipList2(hints?.names)) params.append("names", n);
86726
+ return params.toString();
86727
+ }
86716
86728
  async function searchHaansi(session, ask, fetchImpl = fetch) {
86717
86729
  const base = session.apiUrl.replace(/\/+$/, "");
86718
86730
  const headers = {
@@ -86721,7 +86733,7 @@ async function searchHaansi(session, ask, fetchImpl = fetch) {
86721
86733
  };
86722
86734
  const solutions = ask.queries.map(
86723
86735
  (q) => fetchImpl(
86724
- `${base}/api/v1/memory/solutions/search?q=${encodeURIComponent(q)}&top_k=${SOLUTIONS_PER_QUERY}`,
86736
+ `${base}/api/v1/memory/solutions/search?${solutionsSearchQuery(q, ask.hints)}`,
86725
86737
  { method: "GET", headers }
86726
86738
  )
86727
86739
  );
@@ -86791,13 +86803,17 @@ async function searchHaansi(session, ask, fetchImpl = fetch) {
86791
86803
  })() : Promise.resolve();
86792
86804
  await Promise.allSettled([...solutions, skills2]);
86793
86805
  }
86794
- var SOLUTIONS_PER_QUERY, PRIOR_ATTEMPTS_LIMIT;
86806
+ var SOLUTIONS_PER_QUERY, MAX_HINT_ITEMS2, MAX_HINT_ITEM_CHARS2, MAX_HINT_ERROR_CHARS2, clipList2, PRIOR_ATTEMPTS_LIMIT;
86795
86807
  var init_replay_fallback = __esm({
86796
86808
  "src/commands/replay-fallback.ts"() {
86797
86809
  "use strict";
86798
86810
  init_setup_mcp();
86799
86811
  init_replay_preflight();
86800
86812
  SOLUTIONS_PER_QUERY = 5;
86813
+ MAX_HINT_ITEMS2 = 10;
86814
+ MAX_HINT_ITEM_CHARS2 = 300;
86815
+ MAX_HINT_ERROR_CHARS2 = 1e3;
86816
+ clipList2 = (items) => (items ?? []).map((v) => v.trim().slice(0, MAX_HINT_ITEM_CHARS2)).filter(Boolean).slice(0, MAX_HINT_ITEMS2);
86801
86817
  PRIOR_ATTEMPTS_LIMIT = 3;
86802
86818
  }
86803
86819
  });
@@ -86858,9 +86874,9 @@ function modelUnreachableOf(output, exitCode) {
86858
86874
  const objects = jsonLines(output);
86859
86875
  const result = [...objects].reverse().find((o) => o.type === "result");
86860
86876
  if (result && result.is_error === true) {
86861
- const said = typeof result.result === "string" ? result.result : "";
86862
- if (result.terminal_reason === "api_error" || MODEL_REFUSAL.test(said))
86863
- return clipReason(said || "the model's API returned an error");
86877
+ const said2 = typeof result.result === "string" ? result.result : "";
86878
+ if (result.terminal_reason === "api_error" || MODEL_REFUSAL.test(said2))
86879
+ return clipReason(said2 || "the model's API returned an error");
86864
86880
  }
86865
86881
  const used = usageOf(output);
86866
86882
  if ((used.outputTokens ?? 0) > 0) return null;
@@ -86907,12 +86923,12 @@ function agentFailureLines(output, max2, scrub) {
86907
86923
  }
86908
86924
  if (event && typeof event === "object") {
86909
86925
  if (event.type !== "result") continue;
86910
- const said = [
86926
+ const said2 = [
86911
86927
  typeof event.terminal_reason === "string" ? `terminal_reason=${event.terminal_reason}` : "",
86912
86928
  event.is_error === true ? "is_error" : "",
86913
86929
  typeof event.result === "string" ? event.result : ""
86914
86930
  ].filter(Boolean).join(" ");
86915
- if (said) out.push(said);
86931
+ if (said2) out.push(said2);
86916
86932
  continue;
86917
86933
  }
86918
86934
  }
@@ -87954,13 +87970,20 @@ function parseRelevance(text, shown) {
87954
87970
  return null;
87955
87971
  }
87956
87972
  if (!Array.isArray(v.items)) return null;
87957
- const relevant = /* @__PURE__ */ new Set();
87973
+ const onPoint = /* @__PURE__ */ new Set();
87974
+ const nearby = /* @__PURE__ */ new Set();
87958
87975
  for (const item of v.items) {
87959
87976
  const it = item ?? {};
87960
87977
  if (typeof it.id !== "string" || !shown.has(it.id)) continue;
87961
- if (it.relevant === true) relevant.add(it.id);
87978
+ if (it.grade === "on_point") {
87979
+ const e = it.evidence ?? {};
87980
+ if (said(e.quote) && said(e.change)) onPoint.add(it.id);
87981
+ else nearby.add(it.id);
87982
+ } else if (it.grade === "nearby") nearby.add(it.id);
87983
+ else if (it.grade === void 0 && it.relevant === true) onPoint.add(it.id);
87962
87984
  }
87963
- return [...relevant].sort();
87985
+ for (const id of onPoint) nearby.delete(id);
87986
+ return { onPoint: [...onPoint].sort(), nearby: [...nearby].sort() };
87964
87987
  }
87965
87988
  function knowledgeOf(relevantIds, reachedAgent) {
87966
87989
  if (relevantIds.some((id) => reachedAgent.has(id))) return "returned";
@@ -87986,6 +88009,7 @@ async function judgeRelevance(deps, input) {
87986
88009
  return {
87987
88010
  relevantIds: [],
87988
88011
  recallIds: [],
88012
+ nearbyIds: [],
87989
88013
  knowledge: "none",
87990
88014
  judgeTag: null
87991
88015
  };
@@ -87993,6 +88017,7 @@ async function judgeRelevance(deps, input) {
87993
88017
  return {
87994
88018
  relevantIds: null,
87995
88019
  recallIds: null,
88020
+ nearbyIds: null,
87996
88021
  knowledge: null,
87997
88022
  judgeTag: null
87998
88023
  };
@@ -88028,21 +88053,24 @@ async function judgeRelevance(deps, input) {
88028
88053
  },
88029
88054
  input.timeoutMs
88030
88055
  );
88031
- const relevant = parseRelevance(deps.readFile(verdictFile) ?? "", shown) ?? parseRelevance(ran.output, shown);
88032
- if (!relevant) {
88056
+ const grades = parseRelevance(deps.readFile(verdictFile) ?? "", shown) ?? parseRelevance(ran.output, shown);
88057
+ if (!grades) {
88033
88058
  deps.log(
88034
88059
  `\u2026 ${input.label} [haansi]: the relevance judge gave no verdict`
88035
88060
  );
88036
88061
  return {
88037
88062
  relevantIds: null,
88038
88063
  recallIds: null,
88064
+ nearbyIds: null,
88039
88065
  knowledge: null,
88040
88066
  judgeTag: tag
88041
88067
  };
88042
88068
  }
88069
+ const relevant = grades.onPoint;
88043
88070
  return {
88044
88071
  relevantIds: relevant,
88045
88072
  recallIds: relevant.filter((id) => !reachedIds.has(id)),
88073
+ nearbyIds: grades.nearby,
88046
88074
  knowledge: knowledgeOf(relevant, reachedIds),
88047
88075
  judgeTag: tag
88048
88076
  };
@@ -88050,7 +88078,7 @@ async function judgeRelevance(deps, input) {
88050
88078
  deps.removeDir(dir);
88051
88079
  }
88052
88080
  }
88053
- var import_node_path14, MAX_CHANGE_CHARS2, MAX_ITEMS_CHARS, QUERY_CHARS, TERMS, clip2, COMMON;
88081
+ var import_node_path14, MAX_CHANGE_CHARS2, MAX_ITEMS_CHARS, QUERY_CHARS, TERMS, clip2, COMMON, said;
88054
88082
  var init_replay_relevance = __esm({
88055
88083
  "src/commands/replay-relevance.ts"() {
88056
88084
  "use strict";
@@ -88065,6 +88093,7 @@ var init_replay_relevance = __esm({
88065
88093
  COMMON = new Set(
88066
88094
  "this that with from have will when then than they them their there what which while where return const function export import class true false null undefined async await string number value values type types test tests expect should data item items list name names error errors".split(" ")
88067
88095
  );
88096
+ said = (v) => typeof v === "string" && v.trim() !== "";
88068
88097
  }
88069
88098
  });
88070
88099
 
@@ -89231,6 +89260,17 @@ var init_replay_spec = __esm({
89231
89260
  });
89232
89261
 
89233
89262
  // src/commands/replay-context.ts
89263
+ function storedScoreOf(task) {
89264
+ return {
89265
+ onPoint: task.context?.onPoint ?? 0,
89266
+ nearby: task.context?.nearby ?? 0
89267
+ };
89268
+ }
89269
+ function rankFound(tasks, scoreOf) {
89270
+ return tasks.map((task) => ({ task, score: scoreOf(task) })).sort(
89271
+ (a, b) => b.score.onPoint - a.score.onPoint || b.score.nearby - a.score.nearby || a.task.place - b.task.place
89272
+ ).map((r) => r.task);
89273
+ }
89234
89274
  function stateOf(knowledge) {
89235
89275
  if (knowledge === "returned") return "found";
89236
89276
  return knowledge;
@@ -89261,6 +89301,7 @@ function visibleAsk(task) {
89261
89301
  ].join("\n");
89262
89302
  let paths;
89263
89303
  let queries;
89304
+ let hints;
89264
89305
  if (failing?.tests.length) {
89265
89306
  const named = failing.tests.map(fileOfTest).filter((f) => !!f);
89266
89307
  paths = [
@@ -89270,11 +89311,17 @@ function visibleAsk(task) {
89270
89311
  ])
89271
89312
  ].slice(0, MAX_FAILING_PATHS);
89272
89313
  const files = [...new Set(paths.map(baseNameOf))];
89314
+ const errorLine = errorLineOf(failing.output);
89273
89315
  queries = [
89274
89316
  ...failing.tests.slice(0, FAILING_QUERIES).map(titleOfTest),
89275
- errorLineOf(failing.output) ?? "",
89317
+ errorLine ?? "",
89276
89318
  files.slice(0, 6).join(" ")
89277
89319
  ];
89320
+ hints = {
89321
+ failingTests: failing.tests,
89322
+ ...errorLine ? { error: errorLine } : {},
89323
+ files: paths
89324
+ };
89278
89325
  } else {
89279
89326
  const iface = task.testInterface ?? [];
89280
89327
  paths = [
@@ -89286,6 +89333,7 @@ function visibleAsk(task) {
89286
89333
  ...(task.kind !== "recovery" ? task.testTitles ?? [] : []).slice(0, TITLE_QUERIES).map(titleOfTest),
89287
89334
  names.join(" ")
89288
89335
  ];
89336
+ hints = { files: paths, names: [...new Set(names)] };
89289
89337
  }
89290
89338
  queries = queries.map((q) => flat2(q).slice(0, QUERY_CHARS2).trim()).filter((q, i, all) => q !== "" && all.indexOf(q) === i).slice(0, MAX_QUERIES);
89291
89339
  if (!queries.length && head) queries = [head];
@@ -89297,7 +89345,8 @@ function visibleAsk(task) {
89297
89345
  task: [task.card.problem, task.card.acceptance].join("\n\n").slice(0, 1e3),
89298
89346
  error: error2,
89299
89347
  queries,
89300
- ...paths.length ? { paths } : {}
89348
+ ...paths.length ? { paths } : {},
89349
+ hints
89301
89350
  };
89302
89351
  }
89303
89352
  async function checkContext(deps, input) {
@@ -89339,24 +89388,30 @@ async function checkContext(deps, input) {
89339
89388
  });
89340
89389
  const state = stateOf(judged.knowledge);
89341
89390
  if (!state || !judged.relevantIds) return null;
89391
+ const visible = new Set(reached.flatMap((c) => c.returnedIds));
89392
+ const count4 = (ids) => (ids ?? []).filter((id) => visible.has(id)).length;
89342
89393
  return {
89343
89394
  taskId: task.taskId,
89344
89395
  inputsFingerprint: task.inputsFingerprint,
89345
89396
  state,
89346
89397
  relevantIds: judged.relevantIds,
89347
89398
  judgeTag: judged.judgeTag,
89348
- checkVersion: CONTEXT_CHECK_VERSION
89399
+ checkVersion: CONTEXT_CHECK_VERSION,
89400
+ onPoint: count4(judged.relevantIds),
89401
+ nearby: count4(judged.nearbyIds)
89349
89402
  };
89350
89403
  }
89351
89404
  async function gateOnContext(deps, tasks, options) {
89352
89405
  const states = /* @__PURE__ */ new Map();
89406
+ const scores = /* @__PURE__ */ new Map();
89353
89407
  const checks = [];
89354
89408
  for (const t of tasks)
89355
- if (!needsCheck(t)) states.set(t.taskId, t.context.state);
89356
- const found = () => [...states.values()].filter((s) => s === "found").length;
89409
+ if (!needsCheck(t)) {
89410
+ states.set(t.taskId, t.context.state);
89411
+ scores.set(t.taskId, storedScoreOf(t));
89412
+ }
89357
89413
  const toCheck = tasks.filter((t) => needsCheck(t));
89358
89414
  await runPool(toCheck, options.concurrency, async (task) => {
89359
- if (options.limit && found() >= options.limit) return;
89360
89415
  const label = task.name ?? task.taskKey;
89361
89416
  try {
89362
89417
  await options.prepare?.(task);
@@ -89377,9 +89432,10 @@ async function gateOnContext(deps, tasks, options) {
89377
89432
  return;
89378
89433
  }
89379
89434
  checks.push(check3);
89435
+ scores.set(task.taskId, { onPoint: check3.onPoint, nearby: check3.nearby });
89380
89436
  const n = check3.relevantIds.length;
89381
89437
  deps.log(
89382
- `context ${check3.state.padEnd(6)} ${label}${n ? ` (${n} relevant item${n === 1 ? "" : "s"})` : ""}`
89438
+ `context ${check3.state.padEnd(6)} ${label}${n ? ` (${n} on-point item${n === 1 ? "" : "s"}; returned: ${check3.onPoint} on point, ${check3.nearby} nearby)` : check3.nearby ? ` (${check3.nearby} nearby only)` : ""}`
89383
89439
  );
89384
89440
  } catch (err2) {
89385
89441
  states.set(task.taskId, null);
@@ -89403,21 +89459,33 @@ async function gateOnContext(deps, tasks, options) {
89403
89459
  `The context checks could not be reported (${err2 instanceof Error ? err2.message : String(err2)}); the next run checks them again.`
89404
89460
  );
89405
89461
  }
89406
- const replay2 = [];
89462
+ const found = [];
89407
89463
  let noContext = 0;
89408
89464
  let unknown2 = 0;
89409
89465
  for (const t of tasks) {
89410
89466
  const label = t.name ?? t.taskKey;
89411
- if (!states.has(t.taskId)) continue;
89412
89467
  const s = states.get(t.taskId);
89413
- if (s === "found") replay2.push(t);
89468
+ if (s === "found") found.push(t);
89414
89469
  else if (s === "missed" || s === "none") {
89415
89470
  noContext += 1;
89416
- deps.log(`skip ${label}: no relevant context Haansi can return (${s})`);
89471
+ deps.log(`skip ${label}: no on-point context Haansi can return (${s})`);
89417
89472
  } else unknown2 += 1;
89418
89473
  }
89474
+ const replay2 = rankFound(
89475
+ found,
89476
+ (t) => scores.get(t.taskId) ?? { onPoint: 0, nearby: 0 }
89477
+ );
89419
89478
  return { replay: replay2, noContext, unknown: unknown2 };
89420
89479
  }
89480
+ function fromChecks(tasks, limit, shard) {
89481
+ const ready = tasks.filter(
89482
+ (t) => !needsCheck(t) && t.context?.state === "found" && t.calibration?.state === "valid" && t.calibration.inputsFingerprint === t.inputsFingerprint
89483
+ );
89484
+ const ranked = rankFound(ready, storedScoreOf);
89485
+ const top = limit ? ranked.slice(0, limit) : ranked;
89486
+ const mine = shard && shard.count > 1 ? top.filter((_, i) => i % shard.count === shard.index - 1) : top;
89487
+ return { found: ready.length, top, mine };
89488
+ }
89421
89489
  var CONTEXT_CHECK_VERSION, QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, HEAD_CHARS, MAX_QUERIES, FAILING_QUERIES, TITLE_QUERIES, CONTEXT_REPORT_CHUNK, flat2;
89422
89490
  var init_replay_context = __esm({
89423
89491
  "src/commands/replay-context.ts"() {
@@ -89426,7 +89494,7 @@ var init_replay_context = __esm({
89426
89494
  init_replay_diff();
89427
89495
  init_replay_scale();
89428
89496
  init_replay_spec();
89429
- CONTEXT_CHECK_VERSION = 2;
89497
+ CONTEXT_CHECK_VERSION = 3;
89430
89498
  QUERY_CHARS2 = 200;
89431
89499
  ERROR_CHARS = 1e3;
89432
89500
  MAX_PATHS = 20;
@@ -89667,13 +89735,26 @@ async function runStoredReplays(options, deps) {
89667
89735
  );
89668
89736
  return { results: [], notValid: 0, recorded: null };
89669
89737
  }
89670
- const mine = set2.tasks.filter(
89671
- (t) => inShard(t.taskId, options.shard ?? null)
89672
- );
89673
- if (options.shard && options.shard.count > 1)
89738
+ let mine;
89739
+ if (options.fromChecks) {
89740
+ const picked = fromChecks(set2.tasks, options.limit, options.shard ?? null);
89741
+ mine = picked.mine;
89674
89742
  deps.log(
89675
- `Shard ${options.shard.index}/${options.shard.count}: ${mine.length} of ${set2.tasks.length} task(s).`
89743
+ `From stored checks: ${picked.found} found task(s) in the set; the run takes ${picked.top.length}${options.limit ? ` (--limit ${options.limit})` : ""}, best scored first.`
89676
89744
  );
89745
+ if (options.shard && options.shard.count > 1)
89746
+ deps.log(
89747
+ `Shard ${options.shard.index}/${options.shard.count}: ${mine.length} of the run's ${picked.top.length} task(s).`
89748
+ );
89749
+ if (mine.length === 0)
89750
+ return { results: [], notValid: 0, noContext: 0, recorded: null };
89751
+ } else {
89752
+ mine = set2.tasks.filter((t) => inShard(t.taskId, options.shard ?? null));
89753
+ if (options.shard && options.shard.count > 1)
89754
+ deps.log(
89755
+ `Shard ${options.shard.index}/${options.shard.count}: ${mine.length} of ${set2.tasks.length} task(s).`
89756
+ );
89757
+ }
89677
89758
  const { states } = await runCalibration(
89678
89759
  // With the context gate, --limit caps the tasks replayed (found ones),
89679
89760
  // not the ones calibrated: calibrating only the first n left the rest
@@ -89753,7 +89834,6 @@ async function runStoredReplays(options, deps) {
89753
89834
  agentCmd: options.judgeCmd || options.agentCmd,
89754
89835
  timeoutMs: options.timeoutMs,
89755
89836
  concurrency: options.concurrency ?? 1,
89756
- limit: options.limit,
89757
89837
  dryRun: options.dryRun,
89758
89838
  cardOf: (task) => cardPrompt(task, null),
89759
89839
  targetOf,
@@ -89764,6 +89844,19 @@ async function runStoredReplays(options, deps) {
89764
89844
  noContext = gate.noContext;
89765
89845
  contextUnknown = gate.unknown;
89766
89846
  }
89847
+ if (options.checkOnly) {
89848
+ deps.log(
89849
+ `Checked: ${gated.length} found \xB7 ${noContext} with no on-point context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
89850
+ );
89851
+ return {
89852
+ results: [],
89853
+ notValid,
89854
+ noContext,
89855
+ contextUnknown,
89856
+ found: gated.length,
89857
+ recorded: null
89858
+ };
89859
+ }
89767
89860
  const chosen = options.limit ? gated.slice(0, options.limit) : gated;
89768
89861
  const results = [];
89769
89862
  let recorded = 0;
@@ -90120,6 +90213,8 @@ function parseReplayArgs(argv) {
90120
90213
  else if (takeScaleArg(a, next, scale, errors)) continue;
90121
90214
  else if (a === "--force") options.force = true;
90122
90215
  else if (a === "--any-context") options.anyContext = true;
90216
+ else if (a === "--check-only") options.checkOnly = true;
90217
+ else if (a === "--from-checks") options.fromChecks = true;
90123
90218
  else if (a === "--max-hours") options.maxHours = Number(next());
90124
90219
  else if (takeContainerArg(a, next, options.container, errors)) continue;
90125
90220
  else if (a === "--arms")
@@ -90141,6 +90236,16 @@ function parseReplayArgs(argv) {
90141
90236
  if (options.arms.length === 0 || options.arms.some((a) => !ARMS.includes(a)))
90142
90237
  errors.push("--arms must list baseline and/or haansi.");
90143
90238
  errors.push(...containerErrors(options.container));
90239
+ if (options.checkOnly && options.fromChecks)
90240
+ errors.push("--check-only and --from-checks are the two phases: pass one.");
90241
+ if ((options.checkOnly || options.fromChecks) && options.anyContext)
90242
+ errors.push(
90243
+ "--any-context skips the context check: not with --check-only or --from-checks."
90244
+ );
90245
+ if (options.checkOnly && options.limit !== null)
90246
+ errors.push(
90247
+ "--check-only checks every task: --limit belongs to the --from-checks phase."
90248
+ );
90144
90249
  if (options.maxHours !== null && options.maxHours !== void 0 && (!Number.isFinite(options.maxHours) || options.maxHours <= 0))
90145
90250
  errors.push("--max-hours must be a positive number.");
90146
90251
  Object.assign(
@@ -90588,7 +90693,7 @@ async function replayStored(options, token2, apiUrl2) {
90588
90693
  runCommand
90589
90694
  );
90590
90695
  stop = contained.stop;
90591
- const { results, notValid, noContext, contextUnknown, recorded } = await runStoredReplays2(options, {
90696
+ const { results, notValid, noContext, contextUnknown, found, recorded } = await runStoredReplays2(options, {
90592
90697
  ...contained.deps,
90593
90698
  getReplaySet: (repository) => apiGet3(
90594
90699
  `/memory/replays/tasks?repository=${encodeURIComponent(repository)}`,
@@ -90636,6 +90741,13 @@ async function replayStored(options, token2, apiUrl2) {
90636
90741
  apiUrl: apiUrl2,
90637
90742
  token: token2
90638
90743
  });
90744
+ if (options.checkOnly) {
90745
+ console.log(
90746
+ `
90747
+ Context checked: ${found ?? 0} task(s) found \xB7 ${noContext ?? 0} with no on-point context${contextUnknown ? ` \xB7 ${contextUnknown} could not be checked` : ""} \xB7 ${notValid} not valid to replay`
90748
+ );
90749
+ return;
90750
+ }
90639
90751
  const arm = (a) => {
90640
90752
  const mine = results.filter((r) => r.arm === a);
90641
90753
  return `${mine.filter((r) => r.passed).length}/${mine.length}`;
@@ -90685,6 +90797,7 @@ var init_replay = __esm({
90685
90797
  [--judge-cmd "<cmd>"]
90686
90798
  [--run-ref <url>] [--dry-run] [--repo-commands] [--no-diffs]
90687
90799
  [--shard i/n] [--concurrency k] [--force] [--max-hours h] [--any-context]
90800
+ [--check-only | --from-checks]
90688
90801
  [--setup-cache <files> --setup-cache-path <paths> [--setup-cache-dir <dir>]]
90689
90802
  [--container <image> [--container-setup "<cmd>"] [--container-env NAME]...]
90690
90803
 
@@ -90715,10 +90828,18 @@ files they are and import, and the files changed by the commits that wrote
90715
90828
  the lines its stack frames name, or by those files' own last commits before
90716
90829
  the start; a feature's problem, its tests' titles and the
90717
90830
  names they use; the paths the card names), and the relevance judge (your agent
90718
- command, once per task checked) says whether anything relevant came back.
90719
- A task with nothing relevant Haansi can return is skipped, and checked again
90720
- once the organization gains new Haansi content. --any-context replays every
90721
- valid task without the check (diagnostics).
90831
+ command, once per task checked) grades each item that came back on point (it
90832
+ says part of what to change or check), nearby (same area, another problem)
90833
+ or unrelated. A task is replayed only when an on-point item came back; one
90834
+ without is skipped, and checked again once the organization gains new Haansi
90835
+ content. Found tasks are replayed most on-point items first (then most
90836
+ nearby), and --limit takes the best. --any-context replays every valid task
90837
+ without the check (diagnostics).
90838
+
90839
+ Across shards, run two phases so --limit takes the best of the whole set:
90840
+ --check-only --shard i/n calibrates and checks each share (no agent runs);
90841
+ then --from-checks --limit N --shard i/n ranks every stored found task, takes
90842
+ the top N for the run, and replays this shard's share of them.
90722
90843
 
90723
90844
  --judge-cmd runs the judges (whether the agent used what Haansi returned,
90724
90845
  which of it was relevant, and the context check before replaying) with their
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"