haansi 0.1.95 → 0.1.96
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 +97 -27
- 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.96",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -85855,10 +85855,10 @@ function scrubSecrets(text) {
|
|
|
85855
85855
|
}
|
|
85856
85856
|
function failingTestIn(line) {
|
|
85857
85857
|
const text = line.trim();
|
|
85858
|
-
const js = /^FAIL\s+(\S+)(?:\s+>\s+(
|
|
85858
|
+
const js = /^FAIL\s+(\S+)(?:\s+>\s+(.+?))?(\s+\[[^\]]*\])?$/.exec(text);
|
|
85859
85859
|
if (js && JS_FILE.test(js[1])) {
|
|
85860
|
-
|
|
85861
|
-
return
|
|
85860
|
+
if (!js[2]) return js[3] ? `${js[1]} \u203A ${SUITE_LOAD_FAILED}` : js[1];
|
|
85861
|
+
return [js[1], ...js[2].split(/\s+>\s+/)].join(" \u203A ");
|
|
85862
85862
|
}
|
|
85863
85863
|
const py = /^FAILED\s+(\S+?\.py)(?:::(\S+))?(?:\s+-\s.*)?$/.exec(text);
|
|
85864
85864
|
if (py) return py[2] ? `${py[1]} \u203A ${py[2].replace(/::/g, " \u203A ")}` : py[1];
|
|
@@ -85868,32 +85868,88 @@ function failingTestIn(line) {
|
|
|
85868
85868
|
if (goPkg && !JS_FILE.test(goPkg[1])) return goPkg[1];
|
|
85869
85869
|
return null;
|
|
85870
85870
|
}
|
|
85871
|
-
function
|
|
85872
|
-
|
|
85871
|
+
function relativePaths(text, root) {
|
|
85872
|
+
let out = text;
|
|
85873
|
+
const base = root?.replace(/\/+$/, "");
|
|
85874
|
+
if (base)
|
|
85875
|
+
for (const r of [`/private${base}/`, `${base}/`])
|
|
85876
|
+
out = out.split(r).join("");
|
|
85877
|
+
return out.replace(TEMP_CHECKOUT, "");
|
|
85878
|
+
}
|
|
85879
|
+
function messageAt(lines, i) {
|
|
85880
|
+
const inline = /^FAILED\s+\S+\s+-\s+(.+)$/.exec(lines[i].trim());
|
|
85881
|
+
if (inline) return inline[1];
|
|
85882
|
+
const kept = [];
|
|
85883
|
+
for (let j = i + 1; j < lines.length && kept.length < MESSAGE_LINES; j++) {
|
|
85884
|
+
const line = lines[j];
|
|
85885
|
+
if (!line.trim()) continue;
|
|
85886
|
+
if (failingTestIn(line) || MESSAGE_END.test(line)) break;
|
|
85887
|
+
if (line !== kept.at(-1)) kept.push(line);
|
|
85888
|
+
}
|
|
85889
|
+
if (!kept.length) return "";
|
|
85890
|
+
const indent = Math.min(...kept.map((l) => /^\s*/.exec(l)[0].length));
|
|
85891
|
+
return kept.map((l) => l.slice(indent)).join("\n");
|
|
85892
|
+
}
|
|
85893
|
+
function testErrorsOf(output, root) {
|
|
85894
|
+
const lines = output.split(/\r?\n/).map((l) => relativePaths(l.replace(ANSI, "").trimEnd(), root));
|
|
85873
85895
|
const failing = [];
|
|
85874
|
-
|
|
85896
|
+
const messages = /* @__PURE__ */ new Map();
|
|
85875
85897
|
lines.forEach((line, i) => {
|
|
85876
85898
|
const name = failingTestIn(line);
|
|
85877
85899
|
if (!name) return;
|
|
85878
|
-
if (
|
|
85879
|
-
|
|
85900
|
+
if (!failing.includes(name)) {
|
|
85901
|
+
if (failing.length >= MAX_ERROR_TESTS) return;
|
|
85880
85902
|
failing.push(name);
|
|
85903
|
+
}
|
|
85904
|
+
if (!messages.has(name)) {
|
|
85905
|
+
const message = messageAt(lines, i);
|
|
85906
|
+
if (message) messages.set(name, message);
|
|
85907
|
+
}
|
|
85881
85908
|
});
|
|
85882
|
-
const
|
|
85883
|
-
|
|
85884
|
-
|
|
85909
|
+
const tests = failing.flatMap((name) => {
|
|
85910
|
+
const message = messages.get(name);
|
|
85911
|
+
return message ? [
|
|
85912
|
+
{
|
|
85913
|
+
name: scrubSecrets(name),
|
|
85914
|
+
message: cut(scrubSecrets(message), MAX_TEST_MESSAGE_CHARS)
|
|
85915
|
+
}
|
|
85916
|
+
] : [];
|
|
85917
|
+
});
|
|
85918
|
+
const named = failing.map(scrubSecrets);
|
|
85919
|
+
if (!tests.length) {
|
|
85920
|
+
const text = scrubSecrets(
|
|
85921
|
+
lines.slice(-OUTPUT_LINES).filter((l, i, all) => l.trim() && l !== all[i - 1]).join("\n")
|
|
85922
|
+
);
|
|
85923
|
+
return {
|
|
85924
|
+
failing: named,
|
|
85925
|
+
output: text.length > MAX_ERROR_OUTPUT_CHARS ? `\u2026 (trimmed)
|
|
85926
|
+
${text.slice(-MAX_ERROR_OUTPUT_CHARS)}` : text
|
|
85927
|
+
};
|
|
85928
|
+
}
|
|
85929
|
+
const summary = scrubSecrets(
|
|
85930
|
+
[...new Set(lines.filter((l) => SUMMARY.test(l)).map((l) => l.trim()))].slice(-4).join("\n")
|
|
85885
85931
|
);
|
|
85886
|
-
|
|
85887
|
-
|
|
85888
|
-
|
|
85889
|
-
|
|
85890
|
-
|
|
85932
|
+
const budget = MAX_ERROR_OUTPUT_CHARS - summary.length - 16;
|
|
85933
|
+
const sections = [];
|
|
85934
|
+
let used = 0;
|
|
85935
|
+
for (const t of tests) {
|
|
85936
|
+
const section = `FAIL ${t.name}
|
|
85937
|
+
${t.message}`;
|
|
85938
|
+
if (used + section.length + 2 > budget) {
|
|
85939
|
+
sections.push("\u2026 (trimmed)");
|
|
85940
|
+
break;
|
|
85941
|
+
}
|
|
85942
|
+
sections.push(section);
|
|
85943
|
+
used += section.length + 2;
|
|
85944
|
+
}
|
|
85945
|
+
if (summary) sections.push(summary);
|
|
85946
|
+
return { failing: named, output: sections.join("\n\n"), tests };
|
|
85891
85947
|
}
|
|
85892
|
-
function attemptErrorOf(output, at) {
|
|
85948
|
+
function attemptErrorOf(output, at, root) {
|
|
85893
85949
|
return {
|
|
85894
85950
|
attempt: at.attempt,
|
|
85895
85951
|
agentExit: at.agentExit,
|
|
85896
|
-
...testErrorsOf(output)
|
|
85952
|
+
...testErrorsOf(output, root)
|
|
85897
85953
|
};
|
|
85898
85954
|
}
|
|
85899
85955
|
function testCountsOf(output) {
|
|
@@ -85926,13 +85982,16 @@ function testCountsOf(output) {
|
|
|
85926
85982
|
const goFail = lines.filter((l) => /^--- FAIL:/.test(l)).length;
|
|
85927
85983
|
return goPass + goFail > 0 ? { passed: goPass, failed: goFail, total: goPass + goFail } : null;
|
|
85928
85984
|
}
|
|
85929
|
-
var MAX_ERROR_TESTS, MAX_ERROR_OUTPUT_CHARS, OUTPUT_LINES, ANSI, JS_FILE, SECRET_PATTERNS, count;
|
|
85985
|
+
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, SUMMARY, cut, count;
|
|
85930
85986
|
var init_replay_errors = __esm({
|
|
85931
85987
|
"src/commands/replay-errors.ts"() {
|
|
85932
85988
|
"use strict";
|
|
85933
85989
|
MAX_ERROR_TESTS = 30;
|
|
85934
85990
|
MAX_ERROR_OUTPUT_CHARS = 4e3;
|
|
85991
|
+
MAX_TEST_MESSAGE_CHARS = 600;
|
|
85992
|
+
SUITE_LOAD_FAILED = "(suite failed to load)";
|
|
85935
85993
|
OUTPUT_LINES = 80;
|
|
85994
|
+
MESSAGE_LINES = 12;
|
|
85936
85995
|
ANSI = /\x1b\[[0-9;?]*[A-Za-z]/g;
|
|
85937
85996
|
JS_FILE = /^(\S+\.(?:test|spec)\.[cm]?[jt]sx?)$/;
|
|
85938
85997
|
SECRET_PATTERNS = [
|
|
@@ -85947,6 +86006,10 @@ var init_replay_errors = __esm({
|
|
|
85947
86006
|
/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/:@]+:[^\s/@]+@/gi,
|
|
85948
86007
|
/\b((?:[A-Za-z0-9_]*(?:password|passwd|secret|token|api[_-]?key|private[_-]?key)[A-Za-z0-9_]*)\s*[:=]\s*)(["']?)[^\s"',;]{4,}\2/gi
|
|
85949
86008
|
];
|
|
86009
|
+
TEMP_CHECKOUT = /(?:\/[^\s'"`/]+)*\/haansi-(?:replay|calibrate)-[A-Za-z0-9]{6}\/[^\s'"`/]+\//g;
|
|
86010
|
+
MESSAGE_END = /^\s*(?:⎯{3,}|❯\s|at\s|\d+\s*\|\s|>\s*\d+\s*\||Test Files\s|Tests:?\s+\d|Test Suites:|Duration\s|PASS\s|✓\s|=== RUN\s|ok\s|FAIL$)/;
|
|
86011
|
+
SUMMARY = /^\s*(?:Test Files\s+\d|Tests:?\s+\d|Test Suites:\s+\d|=+\s.*\b(?:passed|failed|error)\b.*\sin\s[\d.]+s.*=+$|(?:FAIL|ok)\s+\S+\s+[\d.]+s$)/;
|
|
86012
|
+
cut = (text, max2) => text.length > max2 ? `${text.slice(0, max2 - 2)} \u2026` : text;
|
|
85950
86013
|
count = (text, word) => {
|
|
85951
86014
|
const m = new RegExp(`(\\d+)\\s+${word}`).exec(text);
|
|
85952
86015
|
return m ? Number(m[1]) : 0;
|
|
@@ -87081,7 +87144,7 @@ async function calibrateTask(deps, options, commands, task) {
|
|
|
87081
87144
|
`\u2026 ${label} [${side}]: tests run ${i + 1}/${options.runs} ${test.code === 0 ? "passed" : "failed"} in ${since(testAt)}`
|
|
87082
87145
|
);
|
|
87083
87146
|
if (side === "base" && test.code !== 0 && !baseErrors)
|
|
87084
|
-
baseErrors = testErrorsOf(test.output);
|
|
87147
|
+
baseErrors = testErrorsOf(test.output, dir);
|
|
87085
87148
|
if (side === "target" && test.code !== 0)
|
|
87086
87149
|
for (const line of test.output.trim().split("\n").slice(-FAILURE_LINES))
|
|
87087
87150
|
deps.log(` ${line}`);
|
|
@@ -88510,10 +88573,11 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
88510
88573
|
`\u2026 ${label}: tests ${test.code === 0 ? "passed" : "failed"} in ${since(testAt)}${counted ? ` (${counted.passed}/${counted.total} passed)` : ""}`
|
|
88511
88574
|
);
|
|
88512
88575
|
if (test.code !== 0) {
|
|
88513
|
-
const error2 = attemptErrorOf(
|
|
88514
|
-
|
|
88515
|
-
agentExit: agent.code
|
|
88516
|
-
|
|
88576
|
+
const error2 = attemptErrorOf(
|
|
88577
|
+
test.output,
|
|
88578
|
+
{ attempt, agentExit: agent.code },
|
|
88579
|
+
dir
|
|
88580
|
+
);
|
|
88517
88581
|
errors.push(error2);
|
|
88518
88582
|
for (const name of error2.failing) deps.log(` failing: ${name}`);
|
|
88519
88583
|
for (const line of test.output.trim().split("\n").slice(-FAILURE_LINES2))
|
|
@@ -88524,9 +88588,15 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
88524
88588
|
const after = await wholeRun();
|
|
88525
88589
|
const verdict2 = guardVerdict(guardStart, after, MAX_ERROR_TESTS);
|
|
88526
88590
|
if (verdict2.kind === "broke") {
|
|
88591
|
+
const whole = attemptErrorOf(
|
|
88592
|
+
after.output,
|
|
88593
|
+
{ attempt, agentExit: agent.code },
|
|
88594
|
+
dir
|
|
88595
|
+
);
|
|
88527
88596
|
guarded = {
|
|
88528
|
-
...
|
|
88529
|
-
failing: verdict2.tests
|
|
88597
|
+
...whole,
|
|
88598
|
+
failing: verdict2.tests,
|
|
88599
|
+
tests: whole.tests?.filter((t) => verdict2.tests.includes(t.name))
|
|
88530
88600
|
};
|
|
88531
88601
|
errors.push(guarded);
|
|
88532
88602
|
deps.log(
|