haansi 0.1.117 → 0.1.119

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 +110 -20
  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.117",
98
+ version: "0.1.119",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -89253,6 +89253,53 @@ var init_replay_spec_gaps = __esm({
89253
89253
  }
89254
89254
  });
89255
89255
 
89256
+ // src/commands/replay-recurring.ts
89257
+ function commitTimeOf(run3) {
89258
+ const seen = /* @__PURE__ */ new Map();
89259
+ return (sha) => {
89260
+ if (!SHA2.test(sha)) return Promise.resolve(null);
89261
+ let at = seen.get(sha);
89262
+ if (!at) {
89263
+ at = run3(["log", "-1", "--format=%cI", "--end-of-options", sha]).then((r) => {
89264
+ const t = r.code === 0 ? Date.parse(r.output.trim()) : NaN;
89265
+ return Number.isFinite(t) ? t : null;
89266
+ }).catch(() => null);
89267
+ seen.set(sha, at);
89268
+ }
89269
+ return at;
89270
+ };
89271
+ }
89272
+ async function recurringFailures(tasks, committedAt) {
89273
+ const bugs = tasks.filter(
89274
+ (t) => t.kind === "recovery" && (t.failing?.tests.length ?? 0) > 0
89275
+ );
89276
+ const out = /* @__PURE__ */ new Map();
89277
+ for (const t of bugs) {
89278
+ const start = t.startsAt ? Date.parse(t.startsAt) : NaN;
89279
+ if (!Number.isFinite(start)) continue;
89280
+ const mine = new Set(t.failing.tests);
89281
+ const earlier = [];
89282
+ for (const e of bugs) {
89283
+ if (e.taskId === t.taskId || e.repository !== t.repository) continue;
89284
+ if (e.processId && e.processId === t.processId) continue;
89285
+ if (!e.failing.tests.some((name) => mine.has(name))) continue;
89286
+ const fixed = await committedAt(e.targetSha);
89287
+ if (fixed !== null && fixed < start) earlier.push(e.taskId);
89288
+ }
89289
+ if (earlier.length)
89290
+ out.set(t.taskId, earlier.sort().slice(0, MAX_RECURRING));
89291
+ }
89292
+ return out;
89293
+ }
89294
+ var MAX_RECURRING, SHA2;
89295
+ var init_replay_recurring = __esm({
89296
+ "src/commands/replay-recurring.ts"() {
89297
+ "use strict";
89298
+ MAX_RECURRING = 20;
89299
+ SHA2 = /^[0-9a-f]{40}$/i;
89300
+ }
89301
+ });
89302
+
89256
89303
  // src/commands/replay-interface.ts
89257
89304
  async function firstAt(show, sha, paths) {
89258
89305
  for (const path2 of paths) {
@@ -89447,7 +89494,7 @@ async function blamedPaths(git, baseSha, frames) {
89447
89494
  ]);
89448
89495
  if (out.code !== 0) continue;
89449
89496
  const sha = out.output.split(/\s/)[0] ?? "";
89450
- if (SHA2.test(sha) && !/^0+$/.test(sha) && !commits.includes(sha))
89497
+ if (SHA3.test(sha) && !/^0+$/.test(sha) && !commits.includes(sha))
89451
89498
  commits.push(sha);
89452
89499
  }
89453
89500
  const files = await filesOfCommits(git, commits);
@@ -89471,14 +89518,14 @@ async function historyPaths(git, baseSha, files) {
89471
89518
  if (out.code !== 0) continue;
89472
89519
  for (const line of out.output.split("\n")) {
89473
89520
  const [sha, at] = line.trim().split(/\s+/);
89474
- if (sha && SHA2.test(sha) && !commits.has(sha))
89521
+ if (sha && SHA3.test(sha) && !commits.has(sha))
89475
89522
  commits.set(sha, Number(at) || 0);
89476
89523
  }
89477
89524
  }
89478
89525
  const newest = [...commits.entries()].sort((a, b) => b[1] - a[1]).map(([sha]) => sha);
89479
89526
  return filesOfCommits(git, newest);
89480
89527
  }
89481
- var MAX_FRAMES, COMMITS_PER_FILE, MAX_HISTORY_FILES, MAX_COMMITS, FILES_PER_COMMIT, MAX_WHERE_PATHS, MAX_GIT_CALLS, ABSOLUTE_TRIES, SOURCE, TEST_FILE, SHA2, FRAME;
89528
+ var MAX_FRAMES, COMMITS_PER_FILE, MAX_HISTORY_FILES, MAX_COMMITS, FILES_PER_COMMIT, MAX_WHERE_PATHS, MAX_GIT_CALLS, ABSOLUTE_TRIES, SOURCE, TEST_FILE, SHA3, FRAME;
89482
89529
  var init_replay_failure_paths = __esm({
89483
89530
  "src/commands/replay-failure-paths.ts"() {
89484
89531
  "use strict";
@@ -89494,7 +89541,7 @@ var init_replay_failure_paths = __esm({
89494
89541
  ABSOLUTE_TRIES = 6;
89495
89542
  SOURCE = /\.(?:[cm]?[jt]sx?|py|go)$/;
89496
89543
  TEST_FILE = /(?:\.(?:test|spec)\.[cm]?[jt]sx?|_test\.go|(?:^|\/)test_[^/]*\.py|_test\.py)$/;
89497
- SHA2 = /^[0-9a-f]{40}$/;
89544
+ SHA3 = /^[0-9a-f]{40}$/;
89498
89545
  FRAME = /(?:file:\/\/)?((?:\/|\.{0,2}\/)?(?:[\w.@+-]+\/)*[\w.@+-]+\.(?:[cm]?[jt]sx?|py|go)):(\d+)(?::\d+)?/g;
89499
89546
  }
89500
89547
  });
@@ -89648,15 +89695,16 @@ function storedScoreOf(task) {
89648
89695
  nearby: task.context?.nearby ?? 0
89649
89696
  };
89650
89697
  }
89651
- function gateTierOf(state, score) {
89698
+ function gateTierOf(state, score, recurring = 0) {
89652
89699
  if (state === "found") return "found";
89653
- if ((state === "missed" || state === "none") && score.nearby > 0)
89654
- return "nearby";
89700
+ if (state === "missed") return "missed";
89701
+ if (state === "none" && recurring > 0) return "recurring";
89702
+ if (state === "none" && score.nearby > 0) return "nearby";
89655
89703
  return null;
89656
89704
  }
89657
89705
  function rankFound(tasks, scoreOf, tierOf = () => "found") {
89658
89706
  return tasks.map((task) => ({ task, score: scoreOf(task), tier: tierOf(task) })).sort(
89659
- (a, b) => Number(a.tier === "nearby") - Number(b.tier === "nearby") || b.score.onPoint - a.score.onPoint || b.score.nearby - a.score.nearby || a.task.place - b.task.place
89707
+ (a, b) => TIER_ORDER[a.tier] - TIER_ORDER[b.tier] || b.score.onPoint - a.score.onPoint || b.score.nearby - a.score.nearby || a.task.place - b.task.place
89660
89708
  ).map((r) => r.task);
89661
89709
  }
89662
89710
  function agreeOn(a, b, reached) {
@@ -89814,10 +89862,15 @@ async function checkContext(deps, input) {
89814
89862
  judgeTag: judged.judgeTag,
89815
89863
  checkVersion: CONTEXT_CHECK_VERSION,
89816
89864
  onPoint: count4(judged.relevantIds),
89817
- nearby: count4(judged.nearbyIds)
89865
+ nearby: count4(judged.nearbyIds),
89866
+ // The gate adds them: they come from the set, not this task's search.
89867
+ recurringIds: []
89818
89868
  };
89819
89869
  }
89820
89870
  async function gateOnContext(deps, tasks, options) {
89871
+ const recurringOf = (t) => [
89872
+ ...options.recurring?.get(t.taskId) ?? []
89873
+ ];
89821
89874
  const states = /* @__PURE__ */ new Map();
89822
89875
  const scores = /* @__PURE__ */ new Map();
89823
89876
  const checks = [];
@@ -89847,7 +89900,7 @@ async function gateOnContext(deps, tasks, options) {
89847
89900
  );
89848
89901
  return;
89849
89902
  }
89850
- checks.push(check3);
89903
+ checks.push({ ...check3, recurringIds: recurringOf(task) });
89851
89904
  scores.set(task.taskId, { onPoint: check3.onPoint, nearby: check3.nearby });
89852
89905
  const n = check3.relevantIds.length;
89853
89906
  deps.log(
@@ -89882,14 +89935,22 @@ async function gateOnContext(deps, tasks, options) {
89882
89935
  for (const t of tasks) {
89883
89936
  const label = t.name ?? t.taskKey;
89884
89937
  const s = states.get(t.taskId);
89885
- const tier = gateTierOf(s, scoreOf(t));
89938
+ const tier = gateTierOf(s, scoreOf(t), recurringOf(t).length);
89886
89939
  if (tier) {
89887
89940
  tiers.set(t.taskId, tier);
89888
89941
  if (tier === "nearby")
89889
89942
  deps.log(
89890
89943
  `nearby ${label}: no on-point context, ${scoreOf(t).nearby} nearby item(s): replayed, read apart`
89891
89944
  );
89892
- } else if (s === "missed" || s === "none") {
89945
+ else if (tier === "missed")
89946
+ deps.log(
89947
+ `missed ${label}: Haansi holds an on-point item its search did not return: replayed as decisive`
89948
+ );
89949
+ else if (tier === "recurring")
89950
+ deps.log(
89951
+ `recurring ${label}: ${recurringOf(t).length} earlier bug fix(es) failed the same test and were fixed before it began: replayed as decisive`
89952
+ );
89953
+ } else if (s === "none") {
89893
89954
  noContext += 1;
89894
89955
  deps.log(
89895
89956
  `skip ${label}: no on-point or nearby context Haansi can return (${s})`
@@ -89901,11 +89962,22 @@ async function gateOnContext(deps, tasks, options) {
89901
89962
  scoreOf,
89902
89963
  (t) => tiers.get(t.taskId)
89903
89964
  );
89904
- const nearby = replay2.filter((t) => tiers.get(t.taskId) === "nearby").length;
89905
- return { replay: replay2, nearby, noContext, unknown: unknown2 };
89965
+ const count4 = (tier) => replay2.filter((t) => tiers.get(t.taskId) === tier).length;
89966
+ return {
89967
+ replay: replay2,
89968
+ nearby: count4("nearby"),
89969
+ missed: count4("missed"),
89970
+ recurring: count4("recurring"),
89971
+ noContext,
89972
+ unknown: unknown2
89973
+ };
89906
89974
  }
89907
89975
  function fromChecks(tasks, limit, shard) {
89908
- const tierOf = (t) => gateTierOf(t.context?.state, storedScoreOf(t));
89976
+ const tierOf = (t) => gateTierOf(
89977
+ t.context?.state,
89978
+ storedScoreOf(t),
89979
+ t.context?.recurringIds?.length ?? 0
89980
+ );
89909
89981
  const ready = tasks.filter(
89910
89982
  (t) => !needsCheck(t) && tierOf(t) !== null && t.calibration?.state === "valid" && t.calibration.inputsFingerprint === t.inputsFingerprint
89911
89983
  );
@@ -89914,7 +89986,7 @@ function fromChecks(tasks, limit, shard) {
89914
89986
  const mine = shard && shard.count > 1 ? top.filter((_, i) => i % shard.count === shard.index - 1) : top;
89915
89987
  return { found: ready.length, top, mine };
89916
89988
  }
89917
- var CONTEXT_CHECK_VERSION, QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, HEAD_CHARS, MAX_QUERIES, FAILING_QUERIES, TITLE_QUERIES, CONTEXT_REPORT_CHUNK, flat2;
89989
+ var CONTEXT_CHECK_VERSION, TIER_ORDER, QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, HEAD_CHARS, MAX_QUERIES, FAILING_QUERIES, TITLE_QUERIES, CONTEXT_REPORT_CHUNK, flat2;
89918
89990
  var init_replay_context = __esm({
89919
89991
  "src/commands/replay-context.ts"() {
89920
89992
  "use strict";
@@ -89922,7 +89994,13 @@ var init_replay_context = __esm({
89922
89994
  init_replay_diff();
89923
89995
  init_replay_scale();
89924
89996
  init_replay_spec();
89925
- CONTEXT_CHECK_VERSION = 6;
89997
+ CONTEXT_CHECK_VERSION = 8;
89998
+ TIER_ORDER = {
89999
+ found: 0,
90000
+ missed: 1,
90001
+ recurring: 2,
90002
+ nearby: 3
90003
+ };
89926
90004
  QUERY_CHARS2 = 300;
89927
90005
  ERROR_CHARS = 1e3;
89928
90006
  MAX_PATHS = 20;
@@ -90427,6 +90505,8 @@ async function runStoredReplays(options, deps) {
90427
90505
  };
90428
90506
  let noContext = 0;
90429
90507
  let nearby = 0;
90508
+ let missed = 0;
90509
+ let recurringCount = 0;
90430
90510
  let contextUnknown = 0;
90431
90511
  let gated = valid;
90432
90512
  if (options.anyContext) {
@@ -90435,7 +90515,12 @@ async function runStoredReplays(options, deps) {
90435
90515
  "--any-context: replaying valid tasks without the context check."
90436
90516
  );
90437
90517
  } else if (valid.length) {
90518
+ const recurring = await recurringFailures(
90519
+ set2.tasks,
90520
+ commitTimeOf((args) => (deps.gitStdout ?? deps.git)(args, deps.repoDir))
90521
+ );
90438
90522
  const gate = await gateOnContext(deps, valid, {
90523
+ recurring,
90439
90524
  agentCmd: options.judgeCmd || options.agentCmd,
90440
90525
  timeoutMs: options.timeoutMs,
90441
90526
  concurrency: options.concurrency ?? 1,
@@ -90447,12 +90532,14 @@ async function runStoredReplays(options, deps) {
90447
90532
  });
90448
90533
  gated = gate.replay;
90449
90534
  nearby = gate.nearby;
90535
+ missed = gate.missed;
90536
+ recurringCount = gate.recurring;
90450
90537
  noContext = gate.noContext;
90451
90538
  contextUnknown = gate.unknown;
90452
90539
  }
90453
90540
  if (options.checkOnly) {
90454
90541
  deps.log(
90455
- `Checked: ${gated.length - nearby} found \xB7 ${nearby} nearby \xB7 ${noContext} with no on-point or nearby context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
90542
+ `Checked: ${gated.length - nearby - missed - recurringCount} found \xB7 ${missed} missed \xB7 ${recurringCount} recurring \xB7 ${nearby} nearby \xB7 ${noContext} with no on-point or nearby context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
90456
90543
  );
90457
90544
  return {
90458
90545
  results: [],
@@ -90461,6 +90548,7 @@ async function runStoredReplays(options, deps) {
90461
90548
  contextUnknown,
90462
90549
  found: gated.length,
90463
90550
  nearby,
90551
+ missed,
90464
90552
  recorded: null
90465
90553
  };
90466
90554
  }
@@ -90781,6 +90869,7 @@ var init_replay_tasks = __esm({
90781
90869
  init_replay_scale();
90782
90870
  init_replay_codex();
90783
90871
  init_replay_spec_gaps();
90872
+ init_replay_recurring();
90784
90873
  init_replay_inject();
90785
90874
  init_replay_interface();
90786
90875
  init_replay_spec();
@@ -91371,6 +91460,7 @@ async function replayStored(options, token2, apiUrl2) {
91371
91460
  contextUnknown,
91372
91461
  found,
91373
91462
  nearby,
91463
+ missed,
91374
91464
  recorded
91375
91465
  } = await runStoredReplays2(options, {
91376
91466
  ...contained.deps,
@@ -91423,7 +91513,7 @@ async function replayStored(options, token2, apiUrl2) {
91423
91513
  if (options.checkOnly) {
91424
91514
  console.log(
91425
91515
  `
91426
- Context checked: ${(found ?? 0) - (nearby ?? 0)} task(s) found \xB7 ${nearby ?? 0} with nearby context only \xB7 ${noContext ?? 0} with no on-point or nearby context${contextUnknown ? ` \xB7 ${contextUnknown} could not be checked` : ""} \xB7 ${notValid} not valid to replay`
91516
+ Context checked: ${(found ?? 0) - (nearby ?? 0) - (missed ?? 0)} task(s) found \xB7 ${missed ?? 0} missed (on point, not returned) \xB7 ${nearby ?? 0} with nearby context only \xB7 ${noContext ?? 0} with no on-point or nearby context${contextUnknown ? ` \xB7 ${contextUnknown} could not be checked` : ""} \xB7 ${notValid} not valid to replay`
91427
91517
  );
91428
91518
  return;
91429
91519
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"