haansi 0.1.108 → 0.1.109
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/haansi.js +65 -18
- 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.
|
|
98
|
+
version: "0.1.109",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -87030,6 +87030,34 @@ function agentFailureLines(output, max2, scrub) {
|
|
|
87030
87030
|
return clean.length > MAX_LOGGED_LINE_CHARS ? `${clean.slice(0, MAX_LOGGED_LINE_CHARS - 1)}\u2026` : clean;
|
|
87031
87031
|
});
|
|
87032
87032
|
}
|
|
87033
|
+
function toolUsesOf(output) {
|
|
87034
|
+
const counts = /* @__PURE__ */ new Map();
|
|
87035
|
+
let structured = false;
|
|
87036
|
+
for (const line of output.split("\n")) {
|
|
87037
|
+
const trimmed = line.trim();
|
|
87038
|
+
if (!trimmed.startsWith("{")) continue;
|
|
87039
|
+
let event;
|
|
87040
|
+
try {
|
|
87041
|
+
event = JSON.parse(trimmed);
|
|
87042
|
+
} catch {
|
|
87043
|
+
continue;
|
|
87044
|
+
}
|
|
87045
|
+
if (event.type !== "assistant") continue;
|
|
87046
|
+
structured = true;
|
|
87047
|
+
const content = Array.isArray(event.message?.content) ? event.message.content : [];
|
|
87048
|
+
for (const block of content) {
|
|
87049
|
+
if (block?.type === "tool_use" && typeof block.name === "string")
|
|
87050
|
+
counts.set(block.name, (counts.get(block.name) ?? 0) + 1);
|
|
87051
|
+
}
|
|
87052
|
+
}
|
|
87053
|
+
if (!structured) return null;
|
|
87054
|
+
return [...counts.entries()].sort(
|
|
87055
|
+
(a, b) => b[1] - a[1] || a[0].localeCompare(b[0])
|
|
87056
|
+
);
|
|
87057
|
+
}
|
|
87058
|
+
function toolUsesLine(uses) {
|
|
87059
|
+
return uses.length ? uses.map(([name, n]) => `${name}\xD7${n}`).join(", ") : "none";
|
|
87060
|
+
}
|
|
87033
87061
|
var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS, MAX_LOGGED_LINE_CHARS;
|
|
87034
87062
|
var init_replay_usage = __esm({
|
|
87035
87063
|
"src/commands/replay-usage.ts"() {
|
|
@@ -87907,6 +87935,19 @@ var init_replay_diff = __esm({
|
|
|
87907
87935
|
});
|
|
87908
87936
|
|
|
87909
87937
|
// src/commands/replay-judge.ts
|
|
87938
|
+
function fitPrompt(render, changeChars, itemsChars, maxBytes = MAX_PROMPT_BYTES) {
|
|
87939
|
+
const FLOOR = 4e3;
|
|
87940
|
+
let change = changeChars;
|
|
87941
|
+
let items = itemsChars;
|
|
87942
|
+
let prompt2 = render(change, items);
|
|
87943
|
+
while (Buffer.byteLength(prompt2, "utf8") > maxBytes) {
|
|
87944
|
+
if (items > FLOOR) items = Math.max(FLOOR, Math.floor(items * 0.8));
|
|
87945
|
+
else if (change > FLOOR) change = Math.max(FLOOR, Math.floor(change * 0.8));
|
|
87946
|
+
else break;
|
|
87947
|
+
prompt2 = render(change, items);
|
|
87948
|
+
}
|
|
87949
|
+
return prompt2;
|
|
87950
|
+
}
|
|
87910
87951
|
function renderTemplate(template, vars) {
|
|
87911
87952
|
return template.replace(
|
|
87912
87953
|
/\{\{(\w+)\}\}/g,
|
|
@@ -87971,16 +88012,20 @@ async function judgeUse(deps, input) {
|
|
|
87971
88012
|
const promptFile = (0, import_node_path14.join)(dir, "prompt.md");
|
|
87972
88013
|
const configFile = (0, import_node_path14.join)(dir, "mcp.json");
|
|
87973
88014
|
const returned = input.calls.map((c) => c.returnedText ?? "").filter(Boolean).join("\n\n");
|
|
87974
|
-
const prompt2 =
|
|
87975
|
-
|
|
87976
|
-
|
|
87977
|
-
|
|
87978
|
-
|
|
87979
|
-
|
|
87980
|
-
|
|
87981
|
-
|
|
87982
|
-
|
|
87983
|
-
|
|
88015
|
+
const prompt2 = fitPrompt(
|
|
88016
|
+
(changeChars, returnedChars) => [
|
|
88017
|
+
input.prompt.system,
|
|
88018
|
+
"",
|
|
88019
|
+
renderTemplate(input.prompt.user, {
|
|
88020
|
+
task: input.card,
|
|
88021
|
+
returned: clip(returned || "(only ids came back)", returnedChars),
|
|
88022
|
+
change: clip(input.change || "(no change)", changeChars),
|
|
88023
|
+
verdict_file: verdictFile
|
|
88024
|
+
})
|
|
88025
|
+
].join("\n"),
|
|
88026
|
+
MAX_CHANGE_CHARS,
|
|
88027
|
+
MAX_RETURNED_CHARS
|
|
88028
|
+
);
|
|
87984
88029
|
try {
|
|
87985
88030
|
deps.writeFile(promptFile, prompt2);
|
|
87986
88031
|
deps.writeFile(configFile, JSON.stringify({ mcpServers: {} }));
|
|
@@ -88011,7 +88056,7 @@ async function judgeUse(deps, input) {
|
|
|
88011
88056
|
deps.removeDir(dir);
|
|
88012
88057
|
}
|
|
88013
88058
|
}
|
|
88014
|
-
var import_node_path14, MAX_CHANGE_CHARS, MAX_RETURNED_CHARS, MAX_REASON, VERDICTS, clip;
|
|
88059
|
+
var import_node_path14, MAX_CHANGE_CHARS, MAX_RETURNED_CHARS, MAX_PROMPT_BYTES, MAX_REASON, VERDICTS, clip;
|
|
88015
88060
|
var init_replay_judge = __esm({
|
|
88016
88061
|
"src/commands/replay-judge.ts"() {
|
|
88017
88062
|
"use strict";
|
|
@@ -88019,6 +88064,7 @@ var init_replay_judge = __esm({
|
|
|
88019
88064
|
init_replay_diff();
|
|
88020
88065
|
MAX_CHANGE_CHARS = 6e4;
|
|
88021
88066
|
MAX_RETURNED_CHARS = 6e4;
|
|
88067
|
+
MAX_PROMPT_BYTES = 12e4;
|
|
88022
88068
|
MAX_REASON = 300;
|
|
88023
88069
|
VERDICTS = ["used", "partly", "not_used"];
|
|
88024
88070
|
clip = (text, max2) => text.length > max2 ? `${text.slice(0, max2)}
|
|
@@ -88118,19 +88164,17 @@ async function judgeRelevance(deps, input) {
|
|
|
88118
88164
|
const verdictFile = (0, import_node_path15.join)(dir, "verdict.json");
|
|
88119
88165
|
const promptFile = (0, import_node_path15.join)(dir, "prompt.md");
|
|
88120
88166
|
const configFile = (0, import_node_path15.join)(dir, "mcp.json");
|
|
88121
|
-
const
|
|
88167
|
+
const render = (changeChars, itemsChars) => [
|
|
88122
88168
|
input.prompt.system,
|
|
88123
88169
|
"",
|
|
88124
88170
|
renderTemplate(input.prompt.user, {
|
|
88125
88171
|
task: input.card,
|
|
88126
|
-
target_change: clip2(
|
|
88127
|
-
|
|
88128
|
-
MAX_CHANGE_CHARS2
|
|
88129
|
-
),
|
|
88130
|
-
items: clip2(itemsText(all) || "(only ids came back)", MAX_ITEMS_CHARS),
|
|
88172
|
+
target_change: clip2(input.targetChange || "(no change)", changeChars),
|
|
88173
|
+
items: clip2(itemsText(all) || "(only ids came back)", itemsChars),
|
|
88131
88174
|
verdict_file: verdictFile
|
|
88132
88175
|
})
|
|
88133
88176
|
].join("\n");
|
|
88177
|
+
const prompt2 = fitPrompt(render, MAX_CHANGE_CHARS2, MAX_ITEMS_CHARS);
|
|
88134
88178
|
try {
|
|
88135
88179
|
deps.writeFile(promptFile, prompt2);
|
|
88136
88180
|
deps.writeFile(configFile, JSON.stringify({ mcpServers: {} }));
|
|
@@ -88176,6 +88220,7 @@ var init_replay_relevance = __esm({
|
|
|
88176
88220
|
"use strict";
|
|
88177
88221
|
import_node_path15 = require("node:path");
|
|
88178
88222
|
init_replay_judge();
|
|
88223
|
+
init_replay_judge();
|
|
88179
88224
|
MAX_CHANGE_CHARS2 = 6e4;
|
|
88180
88225
|
MAX_ITEMS_CHARS = 8e4;
|
|
88181
88226
|
QUERY_CHARS = 200;
|
|
@@ -90520,6 +90565,8 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90520
90565
|
`Haansi's servers did not load for the agent (${down.join(", ")}); not graded, run it again`
|
|
90521
90566
|
);
|
|
90522
90567
|
}
|
|
90568
|
+
const uses = toolUsesOf(agent.output);
|
|
90569
|
+
if (uses) deps.log(`\u2026 ${label}: tools used: ${toolUsesLine(uses)}`);
|
|
90523
90570
|
const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
|
|
90524
90571
|
const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path18.join)(dir, f))]));
|
|
90525
90572
|
for (const f of files) {
|