haansi 0.1.108 → 0.1.110

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 +79 -19
  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.108",
98
+ version: "0.1.110",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -86135,6 +86135,17 @@ function messageAt(lines, i) {
86135
86135
  }
86136
86136
  function testErrorsOf(output, root) {
86137
86137
  const lines = output.split(/\r?\n/).map((l) => relativePaths(l.replace(ANSI, "").trimEnd(), root));
86138
+ const marker = lines.findIndex((l) => l.trim() === BUILD_FAILED_MARKER);
86139
+ if (marker >= 0) {
86140
+ const text = scrubSecrets(
86141
+ lines.slice(marker + 1).filter((l) => l.trim()).slice(-OUTPUT_LINES).join("\n")
86142
+ );
86143
+ return {
86144
+ failing: [BUILD_FAILED],
86145
+ output: text.length > MAX_ERROR_OUTPUT_CHARS ? `\u2026 (trimmed)
86146
+ ${text.slice(-MAX_ERROR_OUTPUT_CHARS)}` : text || "The build failed before any test ran."
86147
+ };
86148
+ }
86138
86149
  const failing = [];
86139
86150
  const messages = /* @__PURE__ */ new Map();
86140
86151
  for (const line of lines) {
@@ -86239,7 +86250,7 @@ function testCountsOf(output) {
86239
86250
  const goFail = lines.filter((l) => /^--- FAIL:/.test(l)).length;
86240
86251
  return goPass + goFail > 0 ? { passed: goPass, failed: goFail, total: goPass + goFail } : null;
86241
86252
  }
86242
- var MAX_ERROR_TESTS, MAX_ERROR_OUTPUT_CHARS, MAX_TEST_MESSAGE_CHARS, SUITE_LOAD_FAILED, OUTPUT_LINES, MESSAGE_LINES, ANSI, JS_FILE, SECRET_PATTERNS, TEMP_CHECKOUT, MESSAGE_END, PYTEST_SUMMARY, SUMMARY, isSummary, PYTEST_SECTION, PYTEST_WHERE, cut, count;
86253
+ var MAX_ERROR_TESTS, MAX_ERROR_OUTPUT_CHARS, MAX_TEST_MESSAGE_CHARS, SUITE_LOAD_FAILED, OUTPUT_LINES, MESSAGE_LINES, ANSI, JS_FILE, SECRET_PATTERNS, TEMP_CHECKOUT, MESSAGE_END, PYTEST_SUMMARY, SUMMARY, isSummary, PYTEST_SECTION, PYTEST_WHERE, cut, BUILD_FAILED_MARKER, BUILD_FAILED, count;
86243
86254
  var init_replay_errors = __esm({
86244
86255
  "src/commands/replay-errors.ts"() {
86245
86256
  "use strict";
@@ -86271,6 +86282,8 @@ var init_replay_errors = __esm({
86271
86282
  PYTEST_SECTION = /^_{3,}\s+(.+?)\s+_{3,}$/;
86272
86283
  PYTEST_WHERE = /^\S+\.py:\d+:\s+\S/;
86273
86284
  cut = (text, max2) => text.length > max2 ? `${text.slice(0, max2 - 2)} \u2026` : text;
86285
+ BUILD_FAILED_MARKER = "HAANSI_BUILD_FAILED";
86286
+ BUILD_FAILED = "(build failed)";
86274
86287
  count = (text, word) => {
86275
86288
  const m = new RegExp(`(\\d+)\\s+${word}`).exec(text);
86276
86289
  return m ? Number(m[1]) : 0;
@@ -87030,6 +87043,34 @@ function agentFailureLines(output, max2, scrub) {
87030
87043
  return clean.length > MAX_LOGGED_LINE_CHARS ? `${clean.slice(0, MAX_LOGGED_LINE_CHARS - 1)}\u2026` : clean;
87031
87044
  });
87032
87045
  }
87046
+ function toolUsesOf(output) {
87047
+ const counts = /* @__PURE__ */ new Map();
87048
+ let structured = false;
87049
+ for (const line of output.split("\n")) {
87050
+ const trimmed = line.trim();
87051
+ if (!trimmed.startsWith("{")) continue;
87052
+ let event;
87053
+ try {
87054
+ event = JSON.parse(trimmed);
87055
+ } catch {
87056
+ continue;
87057
+ }
87058
+ if (event.type !== "assistant") continue;
87059
+ structured = true;
87060
+ const content = Array.isArray(event.message?.content) ? event.message.content : [];
87061
+ for (const block of content) {
87062
+ if (block?.type === "tool_use" && typeof block.name === "string")
87063
+ counts.set(block.name, (counts.get(block.name) ?? 0) + 1);
87064
+ }
87065
+ }
87066
+ if (!structured) return null;
87067
+ return [...counts.entries()].sort(
87068
+ (a, b) => b[1] - a[1] || a[0].localeCompare(b[0])
87069
+ );
87070
+ }
87071
+ function toolUsesLine(uses) {
87072
+ return uses.length ? uses.map(([name, n]) => `${name}\xD7${n}`).join(", ") : "none";
87073
+ }
87033
87074
  var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS, MAX_LOGGED_LINE_CHARS;
87034
87075
  var init_replay_usage = __esm({
87035
87076
  "src/commands/replay-usage.ts"() {
@@ -87907,6 +87948,19 @@ var init_replay_diff = __esm({
87907
87948
  });
87908
87949
 
87909
87950
  // src/commands/replay-judge.ts
87951
+ function fitPrompt(render, changeChars, itemsChars, maxBytes = MAX_PROMPT_BYTES) {
87952
+ const FLOOR = 4e3;
87953
+ let change = changeChars;
87954
+ let items = itemsChars;
87955
+ let prompt2 = render(change, items);
87956
+ while (Buffer.byteLength(prompt2, "utf8") > maxBytes) {
87957
+ if (items > FLOOR) items = Math.max(FLOOR, Math.floor(items * 0.8));
87958
+ else if (change > FLOOR) change = Math.max(FLOOR, Math.floor(change * 0.8));
87959
+ else break;
87960
+ prompt2 = render(change, items);
87961
+ }
87962
+ return prompt2;
87963
+ }
87910
87964
  function renderTemplate(template, vars) {
87911
87965
  return template.replace(
87912
87966
  /\{\{(\w+)\}\}/g,
@@ -87971,16 +88025,20 @@ async function judgeUse(deps, input) {
87971
88025
  const promptFile = (0, import_node_path14.join)(dir, "prompt.md");
87972
88026
  const configFile = (0, import_node_path14.join)(dir, "mcp.json");
87973
88027
  const returned = input.calls.map((c) => c.returnedText ?? "").filter(Boolean).join("\n\n");
87974
- const prompt2 = [
87975
- input.prompt.system,
87976
- "",
87977
- renderTemplate(input.prompt.user, {
87978
- task: input.card,
87979
- returned: clip(returned || "(only ids came back)", MAX_RETURNED_CHARS),
87980
- change: input.change || "(no change)",
87981
- verdict_file: verdictFile
87982
- })
87983
- ].join("\n");
88028
+ const prompt2 = fitPrompt(
88029
+ (changeChars, returnedChars) => [
88030
+ input.prompt.system,
88031
+ "",
88032
+ renderTemplate(input.prompt.user, {
88033
+ task: input.card,
88034
+ returned: clip(returned || "(only ids came back)", returnedChars),
88035
+ change: clip(input.change || "(no change)", changeChars),
88036
+ verdict_file: verdictFile
88037
+ })
88038
+ ].join("\n"),
88039
+ MAX_CHANGE_CHARS,
88040
+ MAX_RETURNED_CHARS
88041
+ );
87984
88042
  try {
87985
88043
  deps.writeFile(promptFile, prompt2);
87986
88044
  deps.writeFile(configFile, JSON.stringify({ mcpServers: {} }));
@@ -88011,7 +88069,7 @@ async function judgeUse(deps, input) {
88011
88069
  deps.removeDir(dir);
88012
88070
  }
88013
88071
  }
88014
- var import_node_path14, MAX_CHANGE_CHARS, MAX_RETURNED_CHARS, MAX_REASON, VERDICTS, clip;
88072
+ var import_node_path14, MAX_CHANGE_CHARS, MAX_RETURNED_CHARS, MAX_PROMPT_BYTES, MAX_REASON, VERDICTS, clip;
88015
88073
  var init_replay_judge = __esm({
88016
88074
  "src/commands/replay-judge.ts"() {
88017
88075
  "use strict";
@@ -88019,6 +88077,7 @@ var init_replay_judge = __esm({
88019
88077
  init_replay_diff();
88020
88078
  MAX_CHANGE_CHARS = 6e4;
88021
88079
  MAX_RETURNED_CHARS = 6e4;
88080
+ MAX_PROMPT_BYTES = 12e4;
88022
88081
  MAX_REASON = 300;
88023
88082
  VERDICTS = ["used", "partly", "not_used"];
88024
88083
  clip = (text, max2) => text.length > max2 ? `${text.slice(0, max2)}
@@ -88118,19 +88177,17 @@ async function judgeRelevance(deps, input) {
88118
88177
  const verdictFile = (0, import_node_path15.join)(dir, "verdict.json");
88119
88178
  const promptFile = (0, import_node_path15.join)(dir, "prompt.md");
88120
88179
  const configFile = (0, import_node_path15.join)(dir, "mcp.json");
88121
- const prompt2 = [
88180
+ const render = (changeChars, itemsChars) => [
88122
88181
  input.prompt.system,
88123
88182
  "",
88124
88183
  renderTemplate(input.prompt.user, {
88125
88184
  task: input.card,
88126
- target_change: clip2(
88127
- input.targetChange || "(no change)",
88128
- MAX_CHANGE_CHARS2
88129
- ),
88130
- items: clip2(itemsText(all) || "(only ids came back)", MAX_ITEMS_CHARS),
88185
+ target_change: clip2(input.targetChange || "(no change)", changeChars),
88186
+ items: clip2(itemsText(all) || "(only ids came back)", itemsChars),
88131
88187
  verdict_file: verdictFile
88132
88188
  })
88133
88189
  ].join("\n");
88190
+ const prompt2 = fitPrompt(render, MAX_CHANGE_CHARS2, MAX_ITEMS_CHARS);
88134
88191
  try {
88135
88192
  deps.writeFile(promptFile, prompt2);
88136
88193
  deps.writeFile(configFile, JSON.stringify({ mcpServers: {} }));
@@ -88176,6 +88233,7 @@ var init_replay_relevance = __esm({
88176
88233
  "use strict";
88177
88234
  import_node_path15 = require("node:path");
88178
88235
  init_replay_judge();
88236
+ init_replay_judge();
88179
88237
  MAX_CHANGE_CHARS2 = 6e4;
88180
88238
  MAX_ITEMS_CHARS = 8e4;
88181
88239
  QUERY_CHARS = 200;
@@ -90520,6 +90578,8 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
90520
90578
  `Haansi's servers did not load for the agent (${down.join(", ")}); not graded, run it again`
90521
90579
  );
90522
90580
  }
90581
+ const uses = toolUsesOf(agent.output);
90582
+ if (uses) deps.log(`\u2026 ${label}: tools used: ${toolUsesLine(uses)}`);
90523
90583
  const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
90524
90584
  const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path18.join)(dir, f))]));
90525
90585
  for (const f of files) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.108",
3
+ "version": "0.1.110",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"