haansi 0.1.115 → 0.1.116
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 +74 -20
- 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.116",
|
|
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;
|
|
@@ -90239,6 +90282,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90239
90282
|
);
|
|
90240
90283
|
};
|
|
90241
90284
|
let noContext = 0;
|
|
90285
|
+
let nearby = 0;
|
|
90242
90286
|
let contextUnknown = 0;
|
|
90243
90287
|
let gated = valid;
|
|
90244
90288
|
if (options.anyContext) {
|
|
@@ -90258,12 +90302,13 @@ async function runStoredReplays(options, deps) {
|
|
|
90258
90302
|
prompt: promptForRelevance
|
|
90259
90303
|
});
|
|
90260
90304
|
gated = gate.replay;
|
|
90305
|
+
nearby = gate.nearby;
|
|
90261
90306
|
noContext = gate.noContext;
|
|
90262
90307
|
contextUnknown = gate.unknown;
|
|
90263
90308
|
}
|
|
90264
90309
|
if (options.checkOnly) {
|
|
90265
90310
|
deps.log(
|
|
90266
|
-
`Checked: ${gated.length} found \xB7 ${noContext} with no on-point context \xB7 ${contextUnknown} unknown \xB7 ${notValid} not valid.`
|
|
90311
|
+
`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
90312
|
);
|
|
90268
90313
|
return {
|
|
90269
90314
|
results: [],
|
|
@@ -90271,6 +90316,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90271
90316
|
noContext,
|
|
90272
90317
|
contextUnknown,
|
|
90273
90318
|
found: gated.length,
|
|
90319
|
+
nearby,
|
|
90274
90320
|
recorded: null
|
|
90275
90321
|
};
|
|
90276
90322
|
}
|
|
@@ -91128,7 +91174,15 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
91128
91174
|
runCommand
|
|
91129
91175
|
);
|
|
91130
91176
|
stop = contained.stop;
|
|
91131
|
-
const {
|
|
91177
|
+
const {
|
|
91178
|
+
results,
|
|
91179
|
+
notValid,
|
|
91180
|
+
noContext,
|
|
91181
|
+
contextUnknown,
|
|
91182
|
+
found,
|
|
91183
|
+
nearby,
|
|
91184
|
+
recorded
|
|
91185
|
+
} = await runStoredReplays2(options, {
|
|
91132
91186
|
...contained.deps,
|
|
91133
91187
|
getReplaySet: (repository) => apiGet3(
|
|
91134
91188
|
`/memory/replays/tasks?repository=${encodeURIComponent(repository)}`,
|
|
@@ -91179,7 +91233,7 @@ async function replayStored(options, token2, apiUrl2) {
|
|
|
91179
91233
|
if (options.checkOnly) {
|
|
91180
91234
|
console.log(
|
|
91181
91235
|
`
|
|
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`
|
|
91236
|
+
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
91237
|
);
|
|
91184
91238
|
return;
|
|
91185
91239
|
}
|