haansi 0.1.115 → 0.1.117
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 +273 -29
- 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.117",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -89648,11 +89648,39 @@ function storedScoreOf(task) {
|
|
|
89648
89648
|
nearby: task.context?.nearby ?? 0
|
|
89649
89649
|
};
|
|
89650
89650
|
}
|
|
89651
|
-
function
|
|
89652
|
-
|
|
89653
|
-
|
|
89651
|
+
function gateTierOf(state, score) {
|
|
89652
|
+
if (state === "found") return "found";
|
|
89653
|
+
if ((state === "missed" || state === "none") && score.nearby > 0)
|
|
89654
|
+
return "nearby";
|
|
89655
|
+
return null;
|
|
89656
|
+
}
|
|
89657
|
+
function rankFound(tasks, scoreOf, tierOf = () => "found") {
|
|
89658
|
+
return tasks.map((task) => ({ task, score: scoreOf(task), tier: tierOf(task) })).sort(
|
|
89659
|
+
(a, b) => Number(a.tier === "nearby") - Number(b.tier === "nearby") || b.score.onPoint - a.score.onPoint || b.score.nearby - a.score.nearby || a.task.place - b.task.place
|
|
89654
89660
|
).map((r) => r.task);
|
|
89655
89661
|
}
|
|
89662
|
+
function agreeOn(a, b, reached) {
|
|
89663
|
+
if (!a.relevantIds) return b;
|
|
89664
|
+
if (!b.relevantIds) return a;
|
|
89665
|
+
const second = new Set(b.relevantIds);
|
|
89666
|
+
const onPoint = a.relevantIds.filter((id) => second.has(id));
|
|
89667
|
+
const agreed = new Set(onPoint);
|
|
89668
|
+
const nearby = [
|
|
89669
|
+
.../* @__PURE__ */ new Set([
|
|
89670
|
+
...a.nearbyIds ?? [],
|
|
89671
|
+
...b.nearbyIds ?? [],
|
|
89672
|
+
...a.relevantIds,
|
|
89673
|
+
...b.relevantIds
|
|
89674
|
+
])
|
|
89675
|
+
].filter((id) => !agreed.has(id));
|
|
89676
|
+
return {
|
|
89677
|
+
relevantIds: onPoint,
|
|
89678
|
+
recallIds: onPoint.filter((id) => !reached.has(id)),
|
|
89679
|
+
nearbyIds: nearby,
|
|
89680
|
+
knowledge: knowledgeOf(onPoint, reached),
|
|
89681
|
+
judgeTag: a.judgeTag
|
|
89682
|
+
};
|
|
89683
|
+
}
|
|
89656
89684
|
function stateOf(knowledge) {
|
|
89657
89685
|
if (knowledge === "returned") return "found";
|
|
89658
89686
|
return knowledge;
|
|
@@ -89760,17 +89788,20 @@ async function checkContext(deps, input) {
|
|
|
89760
89788
|
filesOfDiff(input.targetText)
|
|
89761
89789
|
)
|
|
89762
89790
|
);
|
|
89763
|
-
const
|
|
89791
|
+
const targetChange = input.targetText;
|
|
89792
|
+
const judgeOnce = (n) => judgeRelevance(deps, {
|
|
89764
89793
|
label,
|
|
89765
|
-
taskId: `${task.taskId}-context`,
|
|
89794
|
+
taskId: `${task.taskId}-context-${n}`,
|
|
89766
89795
|
agentCmd: input.agentCmd,
|
|
89767
89796
|
timeoutMs: input.timeoutMs,
|
|
89768
89797
|
card: input.card,
|
|
89769
|
-
targetChange
|
|
89798
|
+
targetChange,
|
|
89770
89799
|
reached,
|
|
89771
89800
|
recall,
|
|
89772
89801
|
prompt: input.prompt
|
|
89773
89802
|
});
|
|
89803
|
+
const reachedIds = new Set(reached.flatMap((c) => c.returnedIds));
|
|
89804
|
+
const judged = agreeOn(await judgeOnce(1), await judgeOnce(2), reachedIds);
|
|
89774
89805
|
const state = stateOf(judged.knowledge);
|
|
89775
89806
|
if (!state || !judged.relevantIds) return null;
|
|
89776
89807
|
const visible = new Set(reached.flatMap((c) => c.returnedIds));
|
|
@@ -89844,29 +89875,41 @@ async function gateOnContext(deps, tasks, options) {
|
|
|
89844
89875
|
`The context checks could not be reported (${err2 instanceof Error ? err2.message : String(err2)}); the next run checks them again.`
|
|
89845
89876
|
);
|
|
89846
89877
|
}
|
|
89847
|
-
const
|
|
89878
|
+
const scoreOf = (t) => scores.get(t.taskId) ?? { onPoint: 0, nearby: 0 };
|
|
89879
|
+
const tiers = /* @__PURE__ */ new Map();
|
|
89848
89880
|
let noContext = 0;
|
|
89849
89881
|
let unknown2 = 0;
|
|
89850
89882
|
for (const t of tasks) {
|
|
89851
89883
|
const label = t.name ?? t.taskKey;
|
|
89852
89884
|
const s = states.get(t.taskId);
|
|
89853
|
-
|
|
89854
|
-
|
|
89885
|
+
const tier = gateTierOf(s, scoreOf(t));
|
|
89886
|
+
if (tier) {
|
|
89887
|
+
tiers.set(t.taskId, tier);
|
|
89888
|
+
if (tier === "nearby")
|
|
89889
|
+
deps.log(
|
|
89890
|
+
`nearby ${label}: no on-point context, ${scoreOf(t).nearby} nearby item(s): replayed, read apart`
|
|
89891
|
+
);
|
|
89892
|
+
} else if (s === "missed" || s === "none") {
|
|
89855
89893
|
noContext += 1;
|
|
89856
|
-
deps.log(
|
|
89894
|
+
deps.log(
|
|
89895
|
+
`skip ${label}: no on-point or nearby context Haansi can return (${s})`
|
|
89896
|
+
);
|
|
89857
89897
|
} else unknown2 += 1;
|
|
89858
89898
|
}
|
|
89859
89899
|
const replay2 = rankFound(
|
|
89860
|
-
|
|
89861
|
-
|
|
89900
|
+
tasks.filter((t) => tiers.has(t.taskId)),
|
|
89901
|
+
scoreOf,
|
|
89902
|
+
(t) => tiers.get(t.taskId)
|
|
89862
89903
|
);
|
|
89863
|
-
|
|
89904
|
+
const nearby = replay2.filter((t) => tiers.get(t.taskId) === "nearby").length;
|
|
89905
|
+
return { replay: replay2, nearby, noContext, unknown: unknown2 };
|
|
89864
89906
|
}
|
|
89865
89907
|
function fromChecks(tasks, limit, shard) {
|
|
89908
|
+
const tierOf = (t) => gateTierOf(t.context?.state, storedScoreOf(t));
|
|
89866
89909
|
const ready = tasks.filter(
|
|
89867
|
-
(t) => !needsCheck(t) && t
|
|
89910
|
+
(t) => !needsCheck(t) && tierOf(t) !== null && t.calibration?.state === "valid" && t.calibration.inputsFingerprint === t.inputsFingerprint
|
|
89868
89911
|
);
|
|
89869
|
-
const ranked = rankFound(ready, storedScoreOf);
|
|
89912
|
+
const ranked = rankFound(ready, storedScoreOf, (t) => tierOf(t));
|
|
89870
89913
|
const top = limit ? ranked.slice(0, limit) : ranked;
|
|
89871
89914
|
const mine = shard && shard.count > 1 ? top.filter((_, i) => i % shard.count === shard.index - 1) : top;
|
|
89872
89915
|
return { found: ready.length, top, mine };
|
|
@@ -89879,7 +89922,7 @@ var init_replay_context = __esm({
|
|
|
89879
89922
|
init_replay_diff();
|
|
89880
89923
|
init_replay_scale();
|
|
89881
89924
|
init_replay_spec();
|
|
89882
|
-
CONTEXT_CHECK_VERSION =
|
|
89925
|
+
CONTEXT_CHECK_VERSION = 6;
|
|
89883
89926
|
QUERY_CHARS2 = 300;
|
|
89884
89927
|
ERROR_CHARS = 1e3;
|
|
89885
89928
|
MAX_PATHS = 20;
|
|
@@ -89892,6 +89935,149 @@ var init_replay_context = __esm({
|
|
|
89892
89935
|
}
|
|
89893
89936
|
});
|
|
89894
89937
|
|
|
89938
|
+
// src/commands/replay-inject.ts
|
|
89939
|
+
function itemsOfReturnedText(text) {
|
|
89940
|
+
const marks = [...text.matchAll(ITEM_MARK)];
|
|
89941
|
+
return marks.map((m, i) => ({
|
|
89942
|
+
id: m[1],
|
|
89943
|
+
text: text.slice(
|
|
89944
|
+
m.index + m[0].length,
|
|
89945
|
+
i + 1 < marks.length ? marks[i + 1].index : text.length
|
|
89946
|
+
).trim()
|
|
89947
|
+
}));
|
|
89948
|
+
}
|
|
89949
|
+
function textsById(calls) {
|
|
89950
|
+
const out = /* @__PURE__ */ new Map();
|
|
89951
|
+
for (const c of calls) {
|
|
89952
|
+
if (c.refused || !c.returnedText) continue;
|
|
89953
|
+
for (const item of itemsOfReturnedText(c.returnedText)) {
|
|
89954
|
+
const known = out.get(item.id);
|
|
89955
|
+
if (!known || item.text.length > known.length)
|
|
89956
|
+
out.set(item.id, item.text);
|
|
89957
|
+
}
|
|
89958
|
+
}
|
|
89959
|
+
return out;
|
|
89960
|
+
}
|
|
89961
|
+
async function readWriteUps(session, ids, fetchImpl = fetch) {
|
|
89962
|
+
const base = session.apiUrl.replace(/\/+$/, "");
|
|
89963
|
+
await Promise.allSettled(
|
|
89964
|
+
ids.filter((id) => id.startsWith("solution:")).map(
|
|
89965
|
+
(id) => fetchImpl(
|
|
89966
|
+
`${base}/api/v1/memory/solutions/${encodeURIComponent(id.slice("solution:".length))}`,
|
|
89967
|
+
{
|
|
89968
|
+
method: "GET",
|
|
89969
|
+
headers: {
|
|
89970
|
+
Authorization: `Bearer ${session.token}`,
|
|
89971
|
+
"X-Haansi-Replay-Session": session.sessionId
|
|
89972
|
+
}
|
|
89973
|
+
}
|
|
89974
|
+
)
|
|
89975
|
+
)
|
|
89976
|
+
);
|
|
89977
|
+
}
|
|
89978
|
+
async function contextToInject(deps, input, fetchImpl) {
|
|
89979
|
+
const { task, label, targetText } = input;
|
|
89980
|
+
if (!deps.searchHaansi || targetText === null || !input.prompt) return null;
|
|
89981
|
+
const session = {
|
|
89982
|
+
...await deps.openSession(task.taskId),
|
|
89983
|
+
apiUrl: deps.apiUrl,
|
|
89984
|
+
token: deps.token
|
|
89985
|
+
};
|
|
89986
|
+
await deps.searchHaansi(session, visibleAsk(task)).catch(() => void 0);
|
|
89987
|
+
const reached = (await deps.getCalls(session.sessionId)).calls;
|
|
89988
|
+
const reachedIds = new Set(reached.flatMap((c) => c.returnedIds));
|
|
89989
|
+
if (reachedIds.size === 0)
|
|
89990
|
+
return {
|
|
89991
|
+
onPoint: [],
|
|
89992
|
+
nearby: [],
|
|
89993
|
+
sessionId: session.sessionId,
|
|
89994
|
+
judgeTag: null
|
|
89995
|
+
};
|
|
89996
|
+
const judgeOnce = (n) => judgeRelevance(deps, {
|
|
89997
|
+
label,
|
|
89998
|
+
taskId: `${task.taskId}-inject-${n}`,
|
|
89999
|
+
agentCmd: input.agentCmd,
|
|
90000
|
+
timeoutMs: input.timeoutMs,
|
|
90001
|
+
card: input.card,
|
|
90002
|
+
targetChange: targetText,
|
|
90003
|
+
reached,
|
|
90004
|
+
recall: [],
|
|
90005
|
+
prompt: input.prompt
|
|
90006
|
+
});
|
|
90007
|
+
const judged = agreeOn(await judgeOnce(1), await judgeOnce(2), reachedIds);
|
|
90008
|
+
if (!judged.relevantIds) return null;
|
|
90009
|
+
const onPointIds = judged.relevantIds.filter((id) => reachedIds.has(id)).slice(0, MAX_INJECTED_PER_TIER);
|
|
90010
|
+
const nearbyIds = (judged.nearbyIds ?? []).filter((id) => reachedIds.has(id) && !onPointIds.includes(id)).slice(0, MAX_INJECTED_PER_TIER);
|
|
90011
|
+
await readWriteUps(session, onPointIds, fetchImpl);
|
|
90012
|
+
const texts = textsById((await deps.getCalls(session.sessionId)).calls);
|
|
90013
|
+
const item = (id) => ({
|
|
90014
|
+
id,
|
|
90015
|
+
text: (texts.get(id) ?? "(only its id came back)").slice(
|
|
90016
|
+
0,
|
|
90017
|
+
MAX_INJECTED_ITEM_CHARS
|
|
90018
|
+
)
|
|
90019
|
+
});
|
|
90020
|
+
return {
|
|
90021
|
+
onPoint: onPointIds.map(item),
|
|
90022
|
+
nearby: nearbyIds.map(item),
|
|
90023
|
+
sessionId: session.sessionId,
|
|
90024
|
+
judgeTag: judged.judgeTag
|
|
90025
|
+
};
|
|
90026
|
+
}
|
|
90027
|
+
function injectionSection(injection) {
|
|
90028
|
+
if (!injection || !injection.onPoint.length && !injection.nearby.length)
|
|
90029
|
+
return [];
|
|
90030
|
+
const block = (items) => items.flatMap((i) => [`[${i.id}]`, i.text, ""]);
|
|
90031
|
+
return [
|
|
90032
|
+
"## Context Haansi found for this task",
|
|
90033
|
+
"",
|
|
90034
|
+
"Your organization's knowledge base was searched for this task before you started, as it stood when the task began. Read these before you start, and say which items you used.",
|
|
90035
|
+
"",
|
|
90036
|
+
...injection.onPoint.length ? [
|
|
90037
|
+
"### On point",
|
|
90038
|
+
"",
|
|
90039
|
+
"These were judged to bear directly on this task: what to change or check.",
|
|
90040
|
+
"",
|
|
90041
|
+
...block(injection.onPoint)
|
|
90042
|
+
] : [],
|
|
90043
|
+
...injection.nearby.length ? [
|
|
90044
|
+
"### Possibly similar",
|
|
90045
|
+
"",
|
|
90046
|
+
"These are related problems, not necessarily this one: take an idea, step or check only where it fits, and check it still applies.",
|
|
90047
|
+
"",
|
|
90048
|
+
...block(injection.nearby)
|
|
90049
|
+
] : []
|
|
90050
|
+
];
|
|
90051
|
+
}
|
|
90052
|
+
function injectionCall(injection) {
|
|
90053
|
+
if (!injection) return [];
|
|
90054
|
+
const items = [...injection.onPoint, ...injection.nearby];
|
|
90055
|
+
if (!items.length) return [];
|
|
90056
|
+
return [
|
|
90057
|
+
{
|
|
90058
|
+
server: "haansi-replay",
|
|
90059
|
+
tool: "injected_context",
|
|
90060
|
+
returnedIds: items.map((i) => i.id),
|
|
90061
|
+
refused: false,
|
|
90062
|
+
returnedText: items.map((i) => `[${i.id}] ${i.text}`).join("\n\n")
|
|
90063
|
+
}
|
|
90064
|
+
];
|
|
90065
|
+
}
|
|
90066
|
+
function experimentLine(result) {
|
|
90067
|
+
return `experiment-result ${JSON.stringify(result)}`;
|
|
90068
|
+
}
|
|
90069
|
+
var MAX_INJECTED_PER_TIER, MAX_INJECTED_ITEM_CHARS, ITEM_MARK;
|
|
90070
|
+
var init_replay_inject = __esm({
|
|
90071
|
+
"src/commands/replay-inject.ts"() {
|
|
90072
|
+
"use strict";
|
|
90073
|
+
init_replay_context();
|
|
90074
|
+
init_replay_relevance();
|
|
90075
|
+
MAX_INJECTED_PER_TIER = 5;
|
|
90076
|
+
MAX_INJECTED_ITEM_CHARS = 4e3;
|
|
90077
|
+
ITEM_MARK = /\[([a-z][a-z_]{0,40}:[A-Za-z0-9._:/-]{1,200})\]/g;
|
|
90078
|
+
}
|
|
90079
|
+
});
|
|
90080
|
+
|
|
89895
90081
|
// src/commands/replay-tasks.ts
|
|
89896
90082
|
var replay_tasks_exports = {};
|
|
89897
90083
|
__export(replay_tasks_exports, {
|
|
@@ -89982,7 +90168,7 @@ function haansiSection(tools, hint = null) {
|
|
|
89982
90168
|
""
|
|
89983
90169
|
];
|
|
89984
90170
|
}
|
|
89985
|
-
function cardPrompt(task, feedback, arm = "baseline", tools = []) {
|
|
90171
|
+
function cardPrompt(task, feedback, arm = "baseline", tools = [], injection = null) {
|
|
89986
90172
|
const failing = task.kind === "recovery" ? task.failing : null;
|
|
89987
90173
|
return [
|
|
89988
90174
|
"# Task",
|
|
@@ -90011,6 +90197,7 @@ function cardPrompt(task, feedback, arm = "baseline", tools = []) {
|
|
|
90011
90197
|
...task.card.area ? ["", "## Part of the code", "", task.card.area] : [],
|
|
90012
90198
|
"",
|
|
90013
90199
|
...interfaceSection(task.testInterface ?? []),
|
|
90200
|
+
...arm === "haansi" ? injectionSection(injection) : [],
|
|
90014
90201
|
...arm === "haansi" ? tools.length ? haansiSection(
|
|
90015
90202
|
tools,
|
|
90016
90203
|
failing?.tests.length ? "bug-fix" : task.kind !== "recovery" && task.testInterface?.length ? "feature" : null
|
|
@@ -90239,6 +90426,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90239
90426
|
);
|
|
90240
90427
|
};
|
|
90241
90428
|
let noContext = 0;
|
|
90429
|
+
let nearby = 0;
|
|
90242
90430
|
let contextUnknown = 0;
|
|
90243
90431
|
let gated = valid;
|
|
90244
90432
|
if (options.anyContext) {
|
|
@@ -90258,12 +90446,13 @@ async function runStoredReplays(options, deps) {
|
|
|
90258
90446
|
prompt: promptForRelevance
|
|
90259
90447
|
});
|
|
90260
90448
|
gated = gate.replay;
|
|
90449
|
+
nearby = gate.nearby;
|
|
90261
90450
|
noContext = gate.noContext;
|
|
90262
90451
|
contextUnknown = gate.unknown;
|
|
90263
90452
|
}
|
|
90264
90453
|
if (options.checkOnly) {
|
|
90265
90454
|
deps.log(
|
|
90266
|
-
`Checked: ${gated.length} found \xB7 ${noContext} with no on-point context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
|
|
90455
|
+
`Checked: ${gated.length - nearby} found \xB7 ${nearby} nearby \xB7 ${noContext} with no on-point or nearby context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
|
|
90267
90456
|
);
|
|
90268
90457
|
return {
|
|
90269
90458
|
results: [],
|
|
@@ -90271,6 +90460,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90271
90460
|
noContext,
|
|
90272
90461
|
contextUnknown,
|
|
90273
90462
|
found: gated.length,
|
|
90463
|
+
nearby,
|
|
90274
90464
|
recorded: null
|
|
90275
90465
|
};
|
|
90276
90466
|
}
|
|
@@ -90324,7 +90514,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90324
90514
|
let targetSent = false;
|
|
90325
90515
|
let baselineChange = null;
|
|
90326
90516
|
for (const arm of arms) {
|
|
90327
|
-
if (!options.force && alreadyMeasured(
|
|
90517
|
+
if (!options.force && !options.injectContext && alreadyMeasured(
|
|
90328
90518
|
task.measured,
|
|
90329
90519
|
arm,
|
|
90330
90520
|
options.agentName,
|
|
@@ -90368,6 +90558,26 @@ async function runStoredReplays(options, deps) {
|
|
|
90368
90558
|
}
|
|
90369
90559
|
}
|
|
90370
90560
|
const armTools = session && deps.listTools ? haansiTools ??= await deps.listTools(session).catch(() => []) : [];
|
|
90561
|
+
let injection = null;
|
|
90562
|
+
if (session && options.injectContext) {
|
|
90563
|
+
injection = await contextToInject(deps, {
|
|
90564
|
+
task,
|
|
90565
|
+
label,
|
|
90566
|
+
card: cardPrompt(task, null),
|
|
90567
|
+
targetText,
|
|
90568
|
+
agentCmd: options.judgeCmd || options.agentCmd,
|
|
90569
|
+
timeoutMs: options.timeoutMs,
|
|
90570
|
+
prompt: await promptForRelevance()
|
|
90571
|
+
}).catch((err2) => {
|
|
90572
|
+
deps.log(
|
|
90573
|
+
`\u2026 ${label}: context not injected (${err2 instanceof Error ? err2.message : String(err2)})`
|
|
90574
|
+
);
|
|
90575
|
+
return null;
|
|
90576
|
+
});
|
|
90577
|
+
deps.log(
|
|
90578
|
+
injection ? `\u2026 ${label} [haansi]: injected ${injection.onPoint.length} on point (${injection.onPoint.map((i) => i.id).join(", ") || "none"}), ${injection.nearby.length} possibly similar (${injection.nearby.map((i) => i.id).join(", ") || "none"})` : `\u2026 ${label} [haansi]: nothing injected (Haansi could not be searched or judged)`
|
|
90579
|
+
);
|
|
90580
|
+
}
|
|
90371
90581
|
const configPath = `${deps.workDir()}/${task.taskId}-${arm}.mcp.json`;
|
|
90372
90582
|
const config6 = mcpConfig(arm, session);
|
|
90373
90583
|
deps.writeFile(configPath, config6);
|
|
@@ -90380,7 +90590,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90380
90590
|
{ ...options, setupCmd, testCmd },
|
|
90381
90591
|
asTask,
|
|
90382
90592
|
arm,
|
|
90383
|
-
(feedback) => cardPrompt(task, feedback, arm, armTools),
|
|
90593
|
+
(feedback) => cardPrompt(task, feedback, arm, armTools, injection),
|
|
90384
90594
|
async (dir) => {
|
|
90385
90595
|
changed = await changedFiles(deps, dir, task.baseSha);
|
|
90386
90596
|
agentDiff = await agentDiffOf(deps, dir, task.baseSha);
|
|
@@ -90397,10 +90607,14 @@ async function runStoredReplays(options, deps) {
|
|
|
90397
90607
|
deps.removeDir(codexHome2);
|
|
90398
90608
|
}
|
|
90399
90609
|
let haansi = null;
|
|
90610
|
+
let askedIds = [];
|
|
90400
90611
|
if (session) {
|
|
90401
|
-
const
|
|
90612
|
+
const own = (await deps.getCalls(session.sessionId)).calls;
|
|
90613
|
+
askedIds = [...new Set(own.flatMap((c) => c.returnedIds))];
|
|
90614
|
+
const calls = [...injectionCall(injection), ...own];
|
|
90402
90615
|
haansi = {
|
|
90403
|
-
|
|
90616
|
+
// Its own calls only: the injection is not a call it made.
|
|
90617
|
+
...haansiUseOf(own),
|
|
90404
90618
|
...await judgeUse(deps, {
|
|
90405
90619
|
label,
|
|
90406
90620
|
taskId: task.taskId,
|
|
@@ -90417,20 +90631,20 @@ async function runStoredReplays(options, deps) {
|
|
|
90417
90631
|
if (relevancePromptNow && targetText !== null) {
|
|
90418
90632
|
let recall = [];
|
|
90419
90633
|
if (deps.searchHaansi) {
|
|
90420
|
-
const
|
|
90634
|
+
const own2 = {
|
|
90421
90635
|
...await deps.openSession(task.taskId),
|
|
90422
90636
|
apiUrl: deps.apiUrl,
|
|
90423
90637
|
token: deps.token
|
|
90424
90638
|
};
|
|
90425
90639
|
await deps.searchHaansi(
|
|
90426
|
-
|
|
90640
|
+
own2,
|
|
90427
90641
|
recallAsk(
|
|
90428
90642
|
task.card.problem,
|
|
90429
90643
|
targetText,
|
|
90430
90644
|
filesOfDiff(targetText)
|
|
90431
90645
|
)
|
|
90432
90646
|
).catch(() => void 0);
|
|
90433
|
-
recall = (await deps.getCalls(
|
|
90647
|
+
recall = (await deps.getCalls(own2.sessionId)).calls;
|
|
90434
90648
|
}
|
|
90435
90649
|
const judged = await judgeRelevance(deps, {
|
|
90436
90650
|
label,
|
|
@@ -90492,6 +90706,26 @@ async function runStoredReplays(options, deps) {
|
|
|
90492
90706
|
specGaps: task.specGaps ? task.specGaps.length : null
|
|
90493
90707
|
});
|
|
90494
90708
|
if (sendTarget) targetSent = true;
|
|
90709
|
+
if (options.injectContext)
|
|
90710
|
+
deps.log(
|
|
90711
|
+
experimentLine({
|
|
90712
|
+
task: label,
|
|
90713
|
+
taskId: task.taskId,
|
|
90714
|
+
kind: task.kind,
|
|
90715
|
+
tier: gateTierOf(task.context?.state, storedScoreOf(task)),
|
|
90716
|
+
arm,
|
|
90717
|
+
passed,
|
|
90718
|
+
attempts: r.attempts,
|
|
90719
|
+
tests: r.testCounts ?? [],
|
|
90720
|
+
fileRecall: overlap.fileRecall,
|
|
90721
|
+
injectedOnPoint: injection?.onPoint.map((i) => i.id) ?? [],
|
|
90722
|
+
injectedNearby: injection?.nearby.map((i) => i.id) ?? [],
|
|
90723
|
+
askedIds,
|
|
90724
|
+
used: haansi?.used ?? null,
|
|
90725
|
+
usedIds: haansi?.usedIds ?? [],
|
|
90726
|
+
knowledge: haansi?.knowledge ?? null
|
|
90727
|
+
})
|
|
90728
|
+
);
|
|
90495
90729
|
deps.log(
|
|
90496
90730
|
`${passed ? "pass" : "fail"} ${arm.padEnd(8)} ${label} (${r.attempts}/${r.maxAttempts} attempts; files ${pct(overlap.fileRecall)} of the target's, ${pct(overlap.filePrecision)} of its own on target; lines ${pct(lines.lineRecall)} of the target's, ${pct(lines.linePrecision)} of its own${haansi ? `; ${haansiText(haansi)}` : ""})`
|
|
90497
90731
|
);
|
|
@@ -90502,7 +90736,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90502
90736
|
}
|
|
90503
90737
|
}
|
|
90504
90738
|
results.push(...done);
|
|
90505
|
-
if (options.dryRun || done.length === 0) return;
|
|
90739
|
+
if (options.dryRun || options.injectContext || done.length === 0) return;
|
|
90506
90740
|
try {
|
|
90507
90741
|
await report(done);
|
|
90508
90742
|
} catch (err2) {
|
|
@@ -90547,6 +90781,7 @@ var init_replay_tasks = __esm({
|
|
|
90547
90781
|
init_replay_scale();
|
|
90548
90782
|
init_replay_codex();
|
|
90549
90783
|
init_replay_spec_gaps();
|
|
90784
|
+
init_replay_inject();
|
|
90550
90785
|
init_replay_interface();
|
|
90551
90786
|
init_replay_spec();
|
|
90552
90787
|
init_replay_context();
|
|
@@ -90639,6 +90874,7 @@ function parseReplayArgs(argv) {
|
|
|
90639
90874
|
else if (takeScaleArg(a, next, scale, errors)) continue;
|
|
90640
90875
|
else if (a === "--force") options.force = true;
|
|
90641
90876
|
else if (a === "--any-context") options.anyContext = true;
|
|
90877
|
+
else if (a === "--inject-context") options.injectContext = true;
|
|
90642
90878
|
else if (a === "--check-only") options.checkOnly = true;
|
|
90643
90879
|
else if (a === "--from-checks") options.fromChecks = true;
|
|
90644
90880
|
else if (a === "--max-hours") options.maxHours = Number(next());
|
|
@@ -91128,7 +91364,15 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
91128
91364
|
runCommand
|
|
91129
91365
|
);
|
|
91130
91366
|
stop = contained.stop;
|
|
91131
|
-
const {
|
|
91367
|
+
const {
|
|
91368
|
+
results,
|
|
91369
|
+
notValid,
|
|
91370
|
+
noContext,
|
|
91371
|
+
contextUnknown,
|
|
91372
|
+
found,
|
|
91373
|
+
nearby,
|
|
91374
|
+
recorded
|
|
91375
|
+
} = await runStoredReplays2(options, {
|
|
91132
91376
|
...contained.deps,
|
|
91133
91377
|
getReplaySet: (repository) => apiGet3(
|
|
91134
91378
|
`/memory/replays/tasks?repository=${encodeURIComponent(repository)}`,
|
|
@@ -91179,7 +91423,7 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
91179
91423
|
if (options.checkOnly) {
|
|
91180
91424
|
console.log(
|
|
91181
91425
|
`
|
|
91182
|
-
Context checked: ${found ?? 0} task(s) found \xB7 ${noContext ?? 0} with no on-point context${contextUnknown ? ` \xB7 ${contextUnknown} could not be checked` : ""} \xB7 ${notValid} not valid to replay`
|
|
91426
|
+
Context checked: ${(found ?? 0) - (nearby ?? 0)} task(s) found \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`
|
|
91183
91427
|
);
|
|
91184
91428
|
return;
|
|
91185
91429
|
}
|