haansi 0.1.124 → 0.1.126

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 +52 -48
  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.124",
98
+ version: "0.1.126",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -26287,7 +26287,7 @@ var init_change_text = __esm({
26287
26287
  });
26288
26288
 
26289
26289
  // ../../packages/@company/db/src/org-purge.ts
26290
- var observability5;
26290
+ var observability5, PURGE_STATEMENT_TIMEOUT_MS;
26291
26291
  var init_org_purge = __esm({
26292
26292
  "../../packages/@company/db/src/org-purge.ts"() {
26293
26293
  "use strict";
@@ -26296,6 +26296,7 @@ var init_org_purge = __esm({
26296
26296
  init_client();
26297
26297
  init_org_context();
26298
26298
  observability5 = createObservabilityService("org-purge");
26299
+ PURGE_STATEMENT_TIMEOUT_MS = 5 * 6e4;
26299
26300
  }
26300
26301
  });
26301
26302
 
@@ -88057,11 +88058,14 @@ function parseDiff(text) {
88057
88058
  }
88058
88059
  return files;
88059
88060
  }
88061
+ function isDocFile(path2) {
88062
+ return DOC_FILE_RE.test(path2);
88063
+ }
88060
88064
  function lineKeys(files, tests) {
88061
88065
  const keys = /* @__PURE__ */ new Map();
88062
88066
  const add = (key) => keys.set(key, (keys.get(key) ?? 0) + 1);
88063
88067
  for (const f of files) {
88064
- if (tests.has(f.path)) continue;
88068
+ if (tests.has(f.path) || isDocFile(f.path)) continue;
88065
88069
  for (const l of f.added) if (l.trim()) add(`${f.path}\0+${l.trim()}`);
88066
88070
  for (const l of f.removed) if (l.trim()) add(`${f.path}\0-${l.trim()}`);
88067
88071
  }
@@ -88079,7 +88083,7 @@ function lineOverlapOf(agent, target, testFiles) {
88079
88083
  let linesAdded = 0;
88080
88084
  let linesRemoved = 0;
88081
88085
  for (const f of agent) {
88082
- if (tests.has(f.path)) continue;
88086
+ if (tests.has(f.path) || isDocFile(f.path)) continue;
88083
88087
  linesAdded += f.added.length;
88084
88088
  linesRemoved += f.removed.length;
88085
88089
  }
@@ -88143,12 +88147,13 @@ async function targetDiffOf(deps, baseSha, targetSha) {
88143
88147
  );
88144
88148
  return diff.code === 0 ? diff.output : null;
88145
88149
  }
88146
- var MAX_DIFF_CHARS, PATH_OF, count3, share;
88150
+ var MAX_DIFF_CHARS, PATH_OF, DOC_FILE_RE, count3, share;
88147
88151
  var init_replay_diff = __esm({
88148
88152
  "src/commands/replay-diff.ts"() {
88149
88153
  "use strict";
88150
88154
  MAX_DIFF_CHARS = 2e5;
88151
88155
  PATH_OF = /^diff --git a\/(.+?) b\/(.+)$/;
88156
+ DOC_FILE_RE = /^docs\/|\.(md|mdx|markdown|rst|adoc)$/i;
88152
88157
  count3 = (keys) => [...keys.values()].reduce((n, c) => n + c, 0);
88153
88158
  share = (part, whole) => whole === 0 ? null : Math.round(part / whole * 1e3) / 1e3;
88154
88159
  }
@@ -89816,11 +89821,10 @@ function storedScoreOf(task) {
89816
89821
  nearby: task.context?.nearby ?? 0
89817
89822
  };
89818
89823
  }
89819
- function gateTierOf(state, score, recurring = 0) {
89824
+ function gateTierOf(state, recurring = 0) {
89820
89825
  if (state === "found") return "found";
89821
89826
  if (state === "missed") return "missed";
89822
89827
  if (state === "none" && recurring > 0) return "recurring";
89823
- if (state === "none" && score.nearby > 0) return "nearby";
89824
89828
  return null;
89825
89829
  }
89826
89830
  function rankFound(tasks, scoreOf, tierOf = () => "found") {
@@ -90052,18 +90056,15 @@ async function gateOnContext(deps, tasks, options) {
90052
90056
  const scoreOf = (t) => scores.get(t.taskId) ?? { onPoint: 0, nearby: 0 };
90053
90057
  const tiers = /* @__PURE__ */ new Map();
90054
90058
  let noContext = 0;
90059
+ let nearby = 0;
90055
90060
  let unknown2 = 0;
90056
90061
  for (const t of tasks) {
90057
90062
  const label = t.name ?? t.taskKey;
90058
90063
  const s = states.get(t.taskId);
90059
- const tier = gateTierOf(s, scoreOf(t), recurringOf(t).length);
90064
+ const tier = gateTierOf(s, recurringOf(t).length);
90060
90065
  if (tier) {
90061
90066
  tiers.set(t.taskId, tier);
90062
- if (tier === "nearby")
90063
- deps.log(
90064
- `nearby ${label}: no on-point context, ${scoreOf(t).nearby} nearby item(s): replayed, read apart`
90065
- );
90066
- else if (tier === "missed")
90067
+ if (tier === "missed")
90067
90068
  deps.log(
90068
90069
  `missed ${label}: Haansi holds an on-point item its search did not return: replayed as decisive`
90069
90070
  );
@@ -90071,6 +90072,11 @@ async function gateOnContext(deps, tasks, options) {
90071
90072
  deps.log(
90072
90073
  `recurring ${label}: ${recurringOf(t).length} earlier bug fix(es) failed the same test and were fixed before it began: replayed as decisive`
90073
90074
  );
90075
+ } else if (s === "none" && scoreOf(t).nearby > 0) {
90076
+ nearby += 1;
90077
+ deps.log(
90078
+ `skip ${label}: nothing on point, ${scoreOf(t).nearby} nearby item(s) only: its arms would tell nothing`
90079
+ );
90074
90080
  } else if (s === "none") {
90075
90081
  noContext += 1;
90076
90082
  deps.log(
@@ -90086,19 +90092,16 @@ async function gateOnContext(deps, tasks, options) {
90086
90092
  const count4 = (tier) => replay2.filter((t) => tiers.get(t.taskId) === tier).length;
90087
90093
  return {
90088
90094
  replay: replay2,
90089
- nearby: count4("nearby"),
90095
+ nearby,
90090
90096
  missed: count4("missed"),
90091
90097
  recurring: count4("recurring"),
90092
90098
  noContext,
90093
- unknown: unknown2
90099
+ unknown: unknown2,
90100
+ tiers
90094
90101
  };
90095
90102
  }
90096
90103
  function fromChecks(tasks, limit, shard) {
90097
- const tierOf = (t) => gateTierOf(
90098
- t.context?.state,
90099
- storedScoreOf(t),
90100
- t.context?.recurringIds?.length ?? 0
90101
- );
90104
+ const tierOf = (t) => gateTierOf(t.context?.state, t.context?.recurringIds?.length ?? 0);
90102
90105
  const ready = tasks.filter(
90103
90106
  (t) => !needsCheck(t) && tierOf(t) !== null && t.calibration?.state === "valid" && t.calibration.inputsFingerprint === t.inputsFingerprint
90104
90107
  );
@@ -90119,8 +90122,7 @@ var init_replay_context = __esm({
90119
90122
  TIER_ORDER = {
90120
90123
  found: 0,
90121
90124
  missed: 1,
90122
- recurring: 2,
90123
- nearby: 3
90125
+ recurring: 2
90124
90126
  };
90125
90127
  QUERY_CHARS2 = 300;
90126
90128
  ERROR_CHARS = 1e3;
@@ -90460,10 +90462,9 @@ async function changedFiles(deps, dir, baseSha) {
90460
90462
  }
90461
90463
  function overlapOf(changed, task, reference = null) {
90462
90464
  const tests = new Set(task.testFiles);
90463
- const mine = new Set(changed.filter((f) => !tests.has(f)));
90464
- const theirs = new Set(
90465
- (reference ?? task.targetFiles).filter((f) => !tests.has(f))
90466
- );
90465
+ const graded = (f) => !tests.has(f) && !isDocFile(f);
90466
+ const mine = new Set(changed.filter(graded));
90467
+ const theirs = new Set((reference ?? task.targetFiles).filter(graded));
90467
90468
  const both = [...mine].filter((f) => theirs.has(f)).length;
90468
90469
  const myAreas = new Set([...mine].map(areaOf));
90469
90470
  const theirAreas = new Set([...theirs].map(areaOf));
@@ -90558,22 +90559,9 @@ async function runStoredReplays(options, deps) {
90558
90559
  `Shard ${options.shard.index}/${options.shard.count}: ${mine.length} of ${set2.tasks.length} task(s).`
90559
90560
  );
90560
90561
  }
90561
- const { states } = await runCalibration(
90562
- // With the context gate, --limit caps the tasks replayed (found ones),
90563
- // not the ones calibrated: calibrating only the first n left the rest
90564
- // "not valid" and the gate often found none among those n. Calibration
90565
- // runs tests only, no model. Without the gate, the first n as before.
90566
- calibrateTaskOptions(
90567
- { ...options, limit: options.anyContext ? options.limit : null },
90568
- { setupCmd, testCmd }
90569
- ),
90570
- { ...deps, report: deps.reportCalibration },
90571
- { ...set2, tasks: mine }
90562
+ const usable = mine.filter(
90563
+ (t) => t.testFiles.length > 0 && t.testFiles.every(safeTestFile) && SHA.test(t.baseSha) && SHA.test(t.targetSha)
90572
90564
  );
90573
- const valid = mine.filter(
90574
- (t) => states.get(t.taskId) === "valid" && t.testFiles.length > 0 && t.testFiles.every(safeTestFile) && SHA.test(t.baseSha) && SHA.test(t.targetSha)
90575
- );
90576
- const notValid = mine.length - valid.length;
90577
90565
  const arms = [...options.arms].sort(
90578
90566
  (a, b) => Number(a !== "baseline") - Number(b !== "baseline")
90579
90567
  );
@@ -90644,18 +90632,19 @@ async function runStoredReplays(options, deps) {
90644
90632
  let missed = 0;
90645
90633
  let recurringCount = 0;
90646
90634
  let contextUnknown = 0;
90647
- let gated = valid;
90635
+ let tiers = /* @__PURE__ */ new Map();
90636
+ let gated = usable;
90648
90637
  if (options.anyContext) {
90649
- if (valid.length)
90638
+ if (usable.length)
90650
90639
  deps.log(
90651
90640
  "--any-context: replaying valid tasks without the context check."
90652
90641
  );
90653
- } else if (valid.length) {
90642
+ } else if (usable.length) {
90654
90643
  const recurring = await recurringFailures(
90655
90644
  set2.tasks,
90656
90645
  commitTimeOf((args) => (deps.gitStdout ?? deps.git)(args, deps.repoDir))
90657
90646
  );
90658
- const gate = await gateOnContext(deps, valid, {
90647
+ const gate = await gateOnContext(deps, usable, {
90659
90648
  recurring,
90660
90649
  agentCmd: options.judgeCmd || options.agentCmd,
90661
90650
  timeoutMs: options.timeoutMs,
@@ -90672,10 +90661,25 @@ async function runStoredReplays(options, deps) {
90672
90661
  recurringCount = gate.recurring;
90673
90662
  noContext = gate.noContext;
90674
90663
  contextUnknown = gate.unknown;
90664
+ tiers = gate.tiers;
90675
90665
  }
90666
+ const { states } = await runCalibration(
90667
+ calibrateTaskOptions(
90668
+ { ...options, limit: options.anyContext ? options.limit : null },
90669
+ { setupCmd, testCmd }
90670
+ ),
90671
+ { ...deps, report: deps.reportCalibration },
90672
+ { ...set2, tasks: gated }
90673
+ );
90674
+ const calibrated = gated.length;
90675
+ gated = gated.filter((t) => states.get(t.taskId) === "valid");
90676
+ const notValid = mine.length - usable.length + (calibrated - gated.length);
90677
+ const ofTier = (tier) => gated.filter((t) => tiers.get(t.taskId) === tier).length;
90678
+ missed = ofTier("missed");
90679
+ recurringCount = ofTier("recurring");
90676
90680
  if (options.checkOnly) {
90677
90681
  deps.log(
90678
- `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.`
90682
+ `Checked: ${gated.length - 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.`
90679
90683
  );
90680
90684
  return {
90681
90685
  results: [],
@@ -90936,7 +90940,7 @@ async function runStoredReplays(options, deps) {
90936
90940
  task: label,
90937
90941
  taskId: task.taskId,
90938
90942
  kind: task.kind,
90939
- tier: gateTierOf(task.context?.state, storedScoreOf(task)),
90943
+ tier: gateTierOf(task.context?.state),
90940
90944
  arm,
90941
90945
  passed,
90942
90946
  attempts: r.attempts,
@@ -91650,7 +91654,7 @@ async function replayStored(options, token2, apiUrl2) {
91650
91654
  if (options.checkOnly) {
91651
91655
  console.log(
91652
91656
  `
91653
- 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`
91657
+ Context checked: ${(found ?? 0) - (missed ?? 0)} task(s) to replay (${missed ?? 0} of them missed: on point, not returned) \xB7 ${nearby ?? 0} skipped with nearby items only \xB7 ${noContext ?? 0} with no on-point or nearby context${contextUnknown ? ` \xB7 ${contextUnknown} could not be checked` : ""} \xB7 ${notValid} not valid to replay`
91654
91658
  );
91655
91659
  return;
91656
91660
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.124",
3
+ "version": "0.1.126",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"