haansi 0.1.97 → 0.1.99
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 +322 -26
- 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.99",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -19550,6 +19550,22 @@ var init_exclusions = __esm({
|
|
|
19550
19550
|
target_diff_sha: [
|
|
19551
19551
|
"not-personal",
|
|
19552
19552
|
"The target commit SHA its stored diff was read at."
|
|
19553
|
+
],
|
|
19554
|
+
context_state: [
|
|
19555
|
+
"operational",
|
|
19556
|
+
"Closed CHECK vocabulary (found, missed, none)."
|
|
19557
|
+
],
|
|
19558
|
+
context_relevant_ids: [
|
|
19559
|
+
"join-key",
|
|
19560
|
+
"Ids of Haansi items (solution:\u2026, skill:\u2026) the relevance judge found bear on the task."
|
|
19561
|
+
],
|
|
19562
|
+
context_judge_tag: [
|
|
19563
|
+
"operational",
|
|
19564
|
+
"The prompt version that judged relevance (replay-relevance-judge-vN)."
|
|
19565
|
+
],
|
|
19566
|
+
context_inputs_fingerprint: [
|
|
19567
|
+
"derived",
|
|
19568
|
+
"A SHA-256 of the task's inputs; not reversible."
|
|
19553
19569
|
]
|
|
19554
19570
|
}),
|
|
19555
19571
|
...exchangeExclusions(INTEL, "problem_family_members", {
|
|
@@ -86430,9 +86446,9 @@ function readTools(result) {
|
|
|
86430
86446
|
}));
|
|
86431
86447
|
}
|
|
86432
86448
|
function firstSentence(text) {
|
|
86433
|
-
const
|
|
86434
|
-
const end =
|
|
86435
|
-
const sentence = end >= 0 ?
|
|
86449
|
+
const flat3 = text.replace(/\s+/g, " ").trim();
|
|
86450
|
+
const end = flat3.search(/[.!?](\s|$)/);
|
|
86451
|
+
const sentence = end >= 0 ? flat3.slice(0, end + 1) : flat3;
|
|
86436
86452
|
return sentence.length > 240 ? `${sentence.slice(0, 237)}\u2026` : sentence;
|
|
86437
86453
|
}
|
|
86438
86454
|
async function httpTools(fetchImpl, url2, headers) {
|
|
@@ -86610,18 +86626,34 @@ async function searchHaansi(session, ask, fetchImpl = fetch) {
|
|
|
86610
86626
|
},
|
|
86611
86627
|
sid
|
|
86612
86628
|
).then((r) => r.text().then(rpcResult))
|
|
86629
|
+
] : [],
|
|
86630
|
+
...ask.paths?.length ? [
|
|
86631
|
+
rpc(
|
|
86632
|
+
4,
|
|
86633
|
+
"tools/call",
|
|
86634
|
+
{
|
|
86635
|
+
name: "get_prior_attempts",
|
|
86636
|
+
arguments: {
|
|
86637
|
+
paths: ask.paths,
|
|
86638
|
+
...ask.queries[0] ? { query: ask.queries[0] } : {},
|
|
86639
|
+
limit: PRIOR_ATTEMPTS_LIMIT
|
|
86640
|
+
}
|
|
86641
|
+
},
|
|
86642
|
+
sid
|
|
86643
|
+
).then((r) => r.text().then(rpcResult))
|
|
86613
86644
|
] : []
|
|
86614
86645
|
]);
|
|
86615
86646
|
})() : Promise.resolve();
|
|
86616
86647
|
await Promise.allSettled([...solutions, skills2]);
|
|
86617
86648
|
}
|
|
86618
|
-
var SOLUTIONS_PER_QUERY;
|
|
86649
|
+
var SOLUTIONS_PER_QUERY, PRIOR_ATTEMPTS_LIMIT;
|
|
86619
86650
|
var init_replay_fallback = __esm({
|
|
86620
86651
|
"src/commands/replay-fallback.ts"() {
|
|
86621
86652
|
"use strict";
|
|
86622
86653
|
init_setup_mcp();
|
|
86623
86654
|
init_replay_preflight();
|
|
86624
86655
|
SOLUTIONS_PER_QUERY = 5;
|
|
86656
|
+
PRIOR_ATTEMPTS_LIMIT = 3;
|
|
86625
86657
|
}
|
|
86626
86658
|
});
|
|
86627
86659
|
|
|
@@ -86676,7 +86708,30 @@ function usageOf(output) {
|
|
|
86676
86708
|
}
|
|
86677
86709
|
return NONE;
|
|
86678
86710
|
}
|
|
86679
|
-
|
|
86711
|
+
function modelUnreachableOf(output, exitCode) {
|
|
86712
|
+
if (exitCode === 0) return null;
|
|
86713
|
+
const used = usageOf(output);
|
|
86714
|
+
if ((used.outputTokens ?? 0) > 0) return null;
|
|
86715
|
+
const objects = jsonLines(output);
|
|
86716
|
+
const result = [...objects].reverse().find((o) => o.type === "result");
|
|
86717
|
+
if (result && result.is_error === true) {
|
|
86718
|
+
const said = typeof result.result === "string" ? result.result : "";
|
|
86719
|
+
if (result.terminal_reason === "api_error" || MODEL_REFUSAL.test(said))
|
|
86720
|
+
return clipReason(said || "the model's API returned an error");
|
|
86721
|
+
}
|
|
86722
|
+
for (const o of [...objects].reverse()) {
|
|
86723
|
+
const message = typeof o.message === "string" ? o.message : typeof o.error?.message === "string" ? String(o.error.message) : "";
|
|
86724
|
+
if ((o.type === "error" || o.type === "turn.failed") && MODEL_REFUSAL.test(message))
|
|
86725
|
+
return clipReason(message);
|
|
86726
|
+
}
|
|
86727
|
+
const line = output.split(/\r?\n/).reverse().find((l) => MODEL_REFUSAL.test(l) && !l.trim().startsWith("{"));
|
|
86728
|
+
return line ? clipReason(line) : null;
|
|
86729
|
+
}
|
|
86730
|
+
function clipReason(text) {
|
|
86731
|
+
const t = text.replace(/\s+/g, " ").trim();
|
|
86732
|
+
return t.length > MAX_REASON_CHARS ? `${t.slice(0, MAX_REASON_CHARS - 1)}\u2026` : t;
|
|
86733
|
+
}
|
|
86734
|
+
var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS;
|
|
86680
86735
|
var init_replay_usage = __esm({
|
|
86681
86736
|
"src/commands/replay-usage.ts"() {
|
|
86682
86737
|
"use strict";
|
|
@@ -86688,6 +86743,8 @@ var init_replay_usage = __esm({
|
|
|
86688
86743
|
turns: null
|
|
86689
86744
|
};
|
|
86690
86745
|
count2 = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
86746
|
+
MODEL_REFUSAL = /credit balance is too low|insufficient[_ ](?:credit|quota|balance|funds)|quota (?:exceeded|exhausted)|exceeded your (?:current )?quota|invalid (?:x-)?api[_ -]?key|authentication[_ ]error|rate[_ ]limit(?:_error| exceeded| reached)|overloaded[_ ]error|api[_ ]error/i;
|
|
86747
|
+
MAX_REASON_CHARS = 200;
|
|
86691
86748
|
}
|
|
86692
86749
|
});
|
|
86693
86750
|
|
|
@@ -87951,6 +88008,187 @@ var init_replay_interface = __esm({
|
|
|
87951
88008
|
}
|
|
87952
88009
|
});
|
|
87953
88010
|
|
|
88011
|
+
// src/commands/replay-context.ts
|
|
88012
|
+
function stateOf(knowledge) {
|
|
88013
|
+
if (knowledge === "returned") return "found";
|
|
88014
|
+
return knowledge;
|
|
88015
|
+
}
|
|
88016
|
+
function needsCheck(task) {
|
|
88017
|
+
const c = task.context;
|
|
88018
|
+
return !c || c.state === null || c.stale;
|
|
88019
|
+
}
|
|
88020
|
+
function pathsIn(text) {
|
|
88021
|
+
const found = text.match(/(?<![\w./-])(?:[\w.-]+\/)+[\w.-]*[\w-](?:\.[a-z0-9]+)?/gi) ?? [];
|
|
88022
|
+
return [
|
|
88023
|
+
...new Set(
|
|
88024
|
+
found.map((p) => p.replace(/^\.\//, "").replace(/[.,:;]+$/, "")).filter(
|
|
88025
|
+
(p) => p.includes("/") && !p.startsWith("/") && !/^https?:/i.test(p) && !p.split("/").some((part) => part === ".." || part === "")
|
|
88026
|
+
)
|
|
88027
|
+
)
|
|
88028
|
+
];
|
|
88029
|
+
}
|
|
88030
|
+
function visibleAsk(task) {
|
|
88031
|
+
const failing = task.kind === "recovery" ? task.failing : null;
|
|
88032
|
+
const problem = flat2(task.card.problem);
|
|
88033
|
+
const cardText = [
|
|
88034
|
+
task.card.problem,
|
|
88035
|
+
task.card.acceptance,
|
|
88036
|
+
task.card.area ?? ""
|
|
88037
|
+
].join("\n");
|
|
88038
|
+
const iface = task.testInterface ?? [];
|
|
88039
|
+
const paths = [
|
|
88040
|
+
.../* @__PURE__ */ new Set([...iface.map((e) => e.path), ...pathsIn(cardText)])
|
|
88041
|
+
].slice(0, MAX_PATHS);
|
|
88042
|
+
const names = iface.flatMap((e) => e.names);
|
|
88043
|
+
const queries = [
|
|
88044
|
+
problem,
|
|
88045
|
+
flat2(`${task.card.area ?? ""} ${flat2(task.card.acceptance)}`),
|
|
88046
|
+
failing?.tests.length ? flat2(failing.tests.join(" ")) : "",
|
|
88047
|
+
names.length ? names.join(" ") : ""
|
|
88048
|
+
].map((q) => q.slice(0, QUERY_CHARS2).trim()).filter((q, i, all) => q !== "" && all.indexOf(q) === i);
|
|
88049
|
+
const error2 = failing ? [
|
|
88050
|
+
...failing.tests,
|
|
88051
|
+
...failing.output ? [failing.output.slice(0, ERROR_CHARS)] : []
|
|
88052
|
+
].join("\n").trim() || null : null;
|
|
88053
|
+
return {
|
|
88054
|
+
task: [task.card.problem, task.card.acceptance].join("\n\n").slice(0, 1e3),
|
|
88055
|
+
error: error2,
|
|
88056
|
+
queries,
|
|
88057
|
+
...paths.length ? { paths } : {}
|
|
88058
|
+
};
|
|
88059
|
+
}
|
|
88060
|
+
async function checkContext(deps, input) {
|
|
88061
|
+
const { task, label } = input;
|
|
88062
|
+
if (!deps.searchHaansi) return null;
|
|
88063
|
+
if (input.targetText === null) {
|
|
88064
|
+
deps.log(
|
|
88065
|
+
`\u2026 ${label}: context not checked: the target's change could not be read`
|
|
88066
|
+
);
|
|
88067
|
+
return null;
|
|
88068
|
+
}
|
|
88069
|
+
const search = async (ask) => {
|
|
88070
|
+
const session = {
|
|
88071
|
+
...await deps.openSession(task.taskId),
|
|
88072
|
+
apiUrl: deps.apiUrl,
|
|
88073
|
+
token: deps.token
|
|
88074
|
+
};
|
|
88075
|
+
await deps.searchHaansi(session, ask).catch(() => void 0);
|
|
88076
|
+
return (await deps.getCalls(session.sessionId)).calls;
|
|
88077
|
+
};
|
|
88078
|
+
const reached = await search(visibleAsk(task));
|
|
88079
|
+
const recall = await search(
|
|
88080
|
+
recallAsk(
|
|
88081
|
+
task.card.problem,
|
|
88082
|
+
input.targetText,
|
|
88083
|
+
filesOfDiff(input.targetText)
|
|
88084
|
+
)
|
|
88085
|
+
);
|
|
88086
|
+
const judged = await judgeRelevance(deps, {
|
|
88087
|
+
label,
|
|
88088
|
+
taskId: `${task.taskId}-context`,
|
|
88089
|
+
agentCmd: input.agentCmd,
|
|
88090
|
+
timeoutMs: input.timeoutMs,
|
|
88091
|
+
card: input.card,
|
|
88092
|
+
targetChange: input.targetText,
|
|
88093
|
+
reached,
|
|
88094
|
+
recall,
|
|
88095
|
+
prompt: input.prompt
|
|
88096
|
+
});
|
|
88097
|
+
const state = stateOf(judged.knowledge);
|
|
88098
|
+
if (!state || !judged.relevantIds) return null;
|
|
88099
|
+
return {
|
|
88100
|
+
taskId: task.taskId,
|
|
88101
|
+
inputsFingerprint: task.inputsFingerprint,
|
|
88102
|
+
state,
|
|
88103
|
+
relevantIds: judged.relevantIds,
|
|
88104
|
+
judgeTag: judged.judgeTag
|
|
88105
|
+
};
|
|
88106
|
+
}
|
|
88107
|
+
async function gateOnContext(deps, tasks, options) {
|
|
88108
|
+
const states = /* @__PURE__ */ new Map();
|
|
88109
|
+
const checks = [];
|
|
88110
|
+
for (const t of tasks)
|
|
88111
|
+
if (!needsCheck(t)) states.set(t.taskId, t.context.state);
|
|
88112
|
+
const found = () => [...states.values()].filter((s) => s === "found").length;
|
|
88113
|
+
const toCheck = tasks.filter((t) => needsCheck(t));
|
|
88114
|
+
await runPool(toCheck, options.concurrency, async (task) => {
|
|
88115
|
+
if (options.limit && found() >= options.limit) return;
|
|
88116
|
+
const label = task.name ?? task.taskKey;
|
|
88117
|
+
try {
|
|
88118
|
+
await options.prepare?.(task);
|
|
88119
|
+
const check3 = await checkContext(deps, {
|
|
88120
|
+
task,
|
|
88121
|
+
label,
|
|
88122
|
+
card: options.cardOf(task),
|
|
88123
|
+
targetText: await options.targetOf(task),
|
|
88124
|
+
agentCmd: options.agentCmd,
|
|
88125
|
+
timeoutMs: options.timeoutMs,
|
|
88126
|
+
prompt: await options.prompt()
|
|
88127
|
+
});
|
|
88128
|
+
states.set(task.taskId, check3?.state ?? null);
|
|
88129
|
+
if (!check3) {
|
|
88130
|
+
deps.log(
|
|
88131
|
+
`context unknown ${label}: the relevance judge gave no verdict`
|
|
88132
|
+
);
|
|
88133
|
+
return;
|
|
88134
|
+
}
|
|
88135
|
+
checks.push(check3);
|
|
88136
|
+
const n = check3.relevantIds.length;
|
|
88137
|
+
deps.log(
|
|
88138
|
+
`context ${check3.state.padEnd(6)} ${label}${n ? ` (${n} relevant item${n === 1 ? "" : "s"})` : ""}`
|
|
88139
|
+
);
|
|
88140
|
+
} catch (err2) {
|
|
88141
|
+
states.set(task.taskId, null);
|
|
88142
|
+
deps.log(
|
|
88143
|
+
`context unknown ${label}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
88144
|
+
);
|
|
88145
|
+
}
|
|
88146
|
+
});
|
|
88147
|
+
if (!options.dryRun && checks.length && deps.reportContext)
|
|
88148
|
+
for (let i = 0; i < checks.length; i += CONTEXT_REPORT_CHUNK)
|
|
88149
|
+
try {
|
|
88150
|
+
const out = await deps.reportContext({
|
|
88151
|
+
results: checks.slice(i, i + CONTEXT_REPORT_CHUNK)
|
|
88152
|
+
});
|
|
88153
|
+
if (out.refused.length)
|
|
88154
|
+
deps.log(
|
|
88155
|
+
`Haansi did not record ${out.refused.length} context check(s): their task's inputs changed during the run.`
|
|
88156
|
+
);
|
|
88157
|
+
} catch (err2) {
|
|
88158
|
+
deps.log(
|
|
88159
|
+
`The context checks could not be reported (${err2 instanceof Error ? err2.message : String(err2)}); the next run checks them again.`
|
|
88160
|
+
);
|
|
88161
|
+
}
|
|
88162
|
+
const replay2 = [];
|
|
88163
|
+
let noContext = 0;
|
|
88164
|
+
let unknown2 = 0;
|
|
88165
|
+
for (const t of tasks) {
|
|
88166
|
+
const label = t.name ?? t.taskKey;
|
|
88167
|
+
if (!states.has(t.taskId)) continue;
|
|
88168
|
+
const s = states.get(t.taskId);
|
|
88169
|
+
if (s === "found") replay2.push(t);
|
|
88170
|
+
else if (s === "missed" || s === "none") {
|
|
88171
|
+
noContext += 1;
|
|
88172
|
+
deps.log(`skip ${label}: no relevant context Haansi can return (${s})`);
|
|
88173
|
+
} else unknown2 += 1;
|
|
88174
|
+
}
|
|
88175
|
+
return { replay: replay2, noContext, unknown: unknown2 };
|
|
88176
|
+
}
|
|
88177
|
+
var QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, CONTEXT_REPORT_CHUNK, flat2;
|
|
88178
|
+
var init_replay_context = __esm({
|
|
88179
|
+
"src/commands/replay-context.ts"() {
|
|
88180
|
+
"use strict";
|
|
88181
|
+
init_replay_relevance();
|
|
88182
|
+
init_replay_diff();
|
|
88183
|
+
init_replay_scale();
|
|
88184
|
+
QUERY_CHARS2 = 200;
|
|
88185
|
+
ERROR_CHARS = 1e3;
|
|
88186
|
+
MAX_PATHS = 20;
|
|
88187
|
+
CONTEXT_REPORT_CHUNK = 100;
|
|
88188
|
+
flat2 = (text) => text.replace(/\s+/g, " ").trim();
|
|
88189
|
+
}
|
|
88190
|
+
});
|
|
88191
|
+
|
|
87954
88192
|
// src/commands/replay-tasks.ts
|
|
87955
88193
|
var replay_tasks_exports = {};
|
|
87956
88194
|
__export(replay_tasks_exports, {
|
|
@@ -87998,8 +88236,8 @@ function fenced(text) {
|
|
|
87998
88236
|
return [fence, text, fence];
|
|
87999
88237
|
}
|
|
88000
88238
|
function listItem(name) {
|
|
88001
|
-
const
|
|
88002
|
-
return `- \`${
|
|
88239
|
+
const flat3 = name.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
|
|
88240
|
+
return `- \`${flat3.replace(/`/g, "'")}\``;
|
|
88003
88241
|
}
|
|
88004
88242
|
function haansiSection(tools) {
|
|
88005
88243
|
return [
|
|
@@ -88176,7 +88414,6 @@ async function runStoredReplays(options, deps) {
|
|
|
88176
88414
|
);
|
|
88177
88415
|
const notValid = mine.length - valid.length;
|
|
88178
88416
|
const arms = options.arms;
|
|
88179
|
-
const chosen = options.limit ? valid.slice(0, options.limit) : valid;
|
|
88180
88417
|
let judgePrompt;
|
|
88181
88418
|
const promptForJudge = async () => {
|
|
88182
88419
|
if (judgePrompt === void 0)
|
|
@@ -88189,6 +88426,48 @@ async function runStoredReplays(options, deps) {
|
|
|
88189
88426
|
relevancePrompt = deps.getRelevancePrompt ? await deps.getRelevancePrompt().catch(() => null) : null;
|
|
88190
88427
|
return relevancePrompt;
|
|
88191
88428
|
};
|
|
88429
|
+
const targets = /* @__PURE__ */ new Map();
|
|
88430
|
+
const targetOf = (task) => {
|
|
88431
|
+
let t = targets.get(task.taskId);
|
|
88432
|
+
if (!t) {
|
|
88433
|
+
t = referenceDiffOf(deps, task).catch(() => null);
|
|
88434
|
+
targets.set(task.taskId, t);
|
|
88435
|
+
}
|
|
88436
|
+
return t;
|
|
88437
|
+
};
|
|
88438
|
+
const interfaceOf = async (task) => {
|
|
88439
|
+
if (task.testInterface !== void 0) return;
|
|
88440
|
+
task.testInterface = !testNamesOf(task).length && task.baseSha && task.targetSha ? await testInterfaceOf(deps.showFile, {
|
|
88441
|
+
baseSha: task.baseSha,
|
|
88442
|
+
targetSha: task.targetSha,
|
|
88443
|
+
testFiles: task.testFiles
|
|
88444
|
+
}).catch(() => []) : [];
|
|
88445
|
+
};
|
|
88446
|
+
let noContext = 0;
|
|
88447
|
+
let contextUnknown = 0;
|
|
88448
|
+
let gated = valid;
|
|
88449
|
+
if (options.anyContext) {
|
|
88450
|
+
if (valid.length)
|
|
88451
|
+
deps.log(
|
|
88452
|
+
"--any-context: replaying valid tasks without the context check."
|
|
88453
|
+
);
|
|
88454
|
+
} else if (valid.length) {
|
|
88455
|
+
const gate = await gateOnContext(deps, valid, {
|
|
88456
|
+
agentCmd: options.agentCmd,
|
|
88457
|
+
timeoutMs: options.timeoutMs,
|
|
88458
|
+
concurrency: options.concurrency ?? 1,
|
|
88459
|
+
limit: options.limit,
|
|
88460
|
+
dryRun: options.dryRun,
|
|
88461
|
+
cardOf: (task) => cardPrompt(task, null),
|
|
88462
|
+
targetOf,
|
|
88463
|
+
prepare: interfaceOf,
|
|
88464
|
+
prompt: promptForRelevance
|
|
88465
|
+
});
|
|
88466
|
+
gated = gate.replay;
|
|
88467
|
+
noContext = gate.noContext;
|
|
88468
|
+
contextUnknown = gate.unknown;
|
|
88469
|
+
}
|
|
88470
|
+
const chosen = options.limit ? gated.slice(0, options.limit) : gated;
|
|
88192
88471
|
const results = [];
|
|
88193
88472
|
let recorded = 0;
|
|
88194
88473
|
let pending = [];
|
|
@@ -88224,19 +88503,13 @@ async function runStoredReplays(options, deps) {
|
|
|
88224
88503
|
testFiles: task.testFiles,
|
|
88225
88504
|
testNames: testNamesOf(task)
|
|
88226
88505
|
};
|
|
88227
|
-
const targetText = await
|
|
88506
|
+
const targetText = await targetOf(task);
|
|
88228
88507
|
const targetChanges = targetText === null ? null : parseDiff(targetText);
|
|
88229
|
-
|
|
88230
|
-
|
|
88231
|
-
|
|
88232
|
-
|
|
88233
|
-
|
|
88234
|
-
}).catch(() => []);
|
|
88235
|
-
if (task.testInterface.length)
|
|
88236
|
-
deps.log(
|
|
88237
|
-
`\u2026 ${label}: the tests use ${task.testInterface.length} module(s) the start lacks; named in the prompt`
|
|
88238
|
-
);
|
|
88239
|
-
}
|
|
88508
|
+
await interfaceOf(task);
|
|
88509
|
+
if (task.testInterface?.length)
|
|
88510
|
+
deps.log(
|
|
88511
|
+
`\u2026 ${label}: the tests use ${task.testInterface.length} module(s) the start lacks; named in the prompt`
|
|
88512
|
+
);
|
|
88240
88513
|
let targetSent = false;
|
|
88241
88514
|
for (const arm of arms) {
|
|
88242
88515
|
if (!options.force && alreadyMeasured(
|
|
@@ -88414,10 +88687,11 @@ async function runStoredReplays(options, deps) {
|
|
|
88414
88687
|
}
|
|
88415
88688
|
};
|
|
88416
88689
|
await runPool(chosen, options.concurrency ?? 1, replayOne);
|
|
88690
|
+
const counts = { notValid, noContext, contextUnknown };
|
|
88417
88691
|
if (options.dryRun || results.length === 0)
|
|
88418
|
-
return { results,
|
|
88692
|
+
return { results, ...counts, recorded: null };
|
|
88419
88693
|
if (pending.length) await report(pending);
|
|
88420
|
-
return { results,
|
|
88694
|
+
return { results, ...counts, recorded };
|
|
88421
88695
|
}
|
|
88422
88696
|
function haansiUseOf(calls) {
|
|
88423
88697
|
return {
|
|
@@ -88446,6 +88720,7 @@ var init_replay_tasks = __esm({
|
|
|
88446
88720
|
init_replay();
|
|
88447
88721
|
init_replay_scale();
|
|
88448
88722
|
init_replay_interface();
|
|
88723
|
+
init_replay_context();
|
|
88449
88724
|
FEEDBACK_HEADER = "Your previous attempt did not pass the tests. Their output ends with:";
|
|
88450
88725
|
REPORT_CHUNK2 = 200;
|
|
88451
88726
|
REPORT_CHARS = 4e6;
|
|
@@ -88526,6 +88801,7 @@ function parseReplayArgs(argv) {
|
|
|
88526
88801
|
else if (a === "--repo-commands") options.repoCommands = true;
|
|
88527
88802
|
else if (takeScaleArg(a, next, scale, errors)) continue;
|
|
88528
88803
|
else if (a === "--force") options.force = true;
|
|
88804
|
+
else if (a === "--any-context") options.anyContext = true;
|
|
88529
88805
|
else if (a === "--max-hours") options.maxHours = Number(next());
|
|
88530
88806
|
else if (takeContainerArg(a, next, options.container, errors)) continue;
|
|
88531
88807
|
else if (a === "--arms")
|
|
@@ -88698,6 +88974,11 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
88698
88974
|
for (const line of agent.output.trim().split("\n").slice(-FAILURE_LINES2))
|
|
88699
88975
|
deps.log(` ${line}`);
|
|
88700
88976
|
}
|
|
88977
|
+
const unreachable2 = modelUnreachableOf(agent.output, agent.code);
|
|
88978
|
+
if (unreachable2)
|
|
88979
|
+
throw new Error(
|
|
88980
|
+
`the agent could not reach its model (${unreachable2}); not graded, run it again`
|
|
88981
|
+
);
|
|
88701
88982
|
const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
|
|
88702
88983
|
const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path16.join)(dir, f))]));
|
|
88703
88984
|
for (const f of files) {
|
|
@@ -88949,7 +89230,7 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
88949
89230
|
runCommand
|
|
88950
89231
|
);
|
|
88951
89232
|
stop = contained.stop;
|
|
88952
|
-
const { results, notValid, recorded } = await runStoredReplays2(options, {
|
|
89233
|
+
const { results, notValid, noContext, contextUnknown, recorded } = await runStoredReplays2(options, {
|
|
88953
89234
|
...contained.deps,
|
|
88954
89235
|
getReplaySet: (repository) => apiGet3(
|
|
88955
89236
|
`/memory/replays/tasks?repository=${encodeURIComponent(repository)}`,
|
|
@@ -88968,6 +89249,12 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
88968
89249
|
token2,
|
|
88969
89250
|
apiUrl2
|
|
88970
89251
|
),
|
|
89252
|
+
reportContext: async (body) => await apiPost2(
|
|
89253
|
+
"/memory/replays/tasks/context",
|
|
89254
|
+
body,
|
|
89255
|
+
token2,
|
|
89256
|
+
apiUrl2
|
|
89257
|
+
),
|
|
88971
89258
|
env: process.env,
|
|
88972
89259
|
cliVersion: cliVersion2(),
|
|
88973
89260
|
preflight: (session) => preflightHaansi(session),
|
|
@@ -88997,7 +89284,7 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
88997
89284
|
};
|
|
88998
89285
|
console.log(
|
|
88999
89286
|
`
|
|
89000
|
-
Baseline: ${arm("baseline")} passed \xB7 With Haansi: ${arm("haansi")} passed \xB7 ${notValid} task(s) not valid to replay`
|
|
89287
|
+
Baseline: ${arm("baseline")} passed \xB7 With Haansi: ${arm("haansi")} passed \xB7 ${notValid} task(s) not valid to replay \xB7 ${noContext ?? 0} skipped with no relevant context${contextUnknown ? ` \xB7 ${contextUnknown} whose context could not be checked` : ""}`
|
|
89001
89288
|
);
|
|
89002
89289
|
console.log(
|
|
89003
89290
|
recorded === null ? options.dryRun ? "Dry run: nothing reported." : "Nothing to report." : `Reported ${recorded} result(s) to Haansi.`
|
|
@@ -89036,7 +89323,7 @@ var init_replay = __esm({
|
|
|
89036
89323
|
[--setup-cmd "<cmd>"] [--attempts 3] [--arms baseline,haansi] [--limit n]
|
|
89037
89324
|
[--timeout-min 20] [--agent-name <name>] [--model <name>]
|
|
89038
89325
|
[--run-ref <url>] [--dry-run] [--repo-commands] [--no-diffs]
|
|
89039
|
-
[--shard i/n] [--concurrency k] [--force] [--max-hours h]
|
|
89326
|
+
[--shard i/n] [--concurrency k] [--force] [--max-hours h] [--any-context]
|
|
89040
89327
|
[--setup-cache <files> --setup-cache-path <paths> [--setup-cache-dir <dir>]]
|
|
89041
89328
|
[--container <image> [--container-setup "<cmd>"] [--container-env NAME]...]
|
|
89042
89329
|
|
|
@@ -89060,6 +89347,15 @@ package-lock.json --setup-cache-path '**/node_modules' keeps the setup's output
|
|
|
89060
89347
|
(every workspace's node_modules) per lockfile (in ~/.cache/haansi-replay, or --setup-cache-dir) and restores
|
|
89061
89348
|
it instead of running the setup again; not with --container.
|
|
89062
89349
|
|
|
89350
|
+
Only tasks Haansi holds relevant context for are replayed. Before any agent
|
|
89351
|
+
runs, each valid task is checked: Haansi is searched with only what the agent
|
|
89352
|
+
sees at the task's start (its card, a bug fix's failing tests, what its tests
|
|
89353
|
+
import, the paths the card names), and the relevance judge (your agent
|
|
89354
|
+
command, once per task checked) says whether anything relevant came back.
|
|
89355
|
+
A task with nothing relevant Haansi can return is skipped, and checked again
|
|
89356
|
+
once the organization gains new Haansi content. --any-context replays every
|
|
89357
|
+
valid task without the check (diagnostics).
|
|
89358
|
+
|
|
89063
89359
|
--repo-commands uses the setup and test commands an org owner or admin saved for the
|
|
89064
89360
|
repository in Haansi (Impact \u2192 Replays) for any not given here.
|
|
89065
89361
|
|