haansi 0.1.112 → 0.1.113
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 +140 -17
- 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.113",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -19663,6 +19663,42 @@ var init_exclusions = __esm({
|
|
|
19663
19663
|
"owner/repo, as in repo_conventions; unique with the org."
|
|
19664
19664
|
]
|
|
19665
19665
|
}),
|
|
19666
|
+
...exchangeExclusions(INTEL, "repo_convention_proposal_runs", {
|
|
19667
|
+
repository: [
|
|
19668
|
+
"join-key",
|
|
19669
|
+
"owner/repo a run was asked for, as in repo_conventions; NULL for the daily run."
|
|
19670
|
+
],
|
|
19671
|
+
trigger: ["operational", "Closed CHECK vocabulary (schedule, request)."],
|
|
19672
|
+
skipped_reason: [
|
|
19673
|
+
"operational",
|
|
19674
|
+
"Closed CHECK vocabulary (no_model, no_github)."
|
|
19675
|
+
]
|
|
19676
|
+
}),
|
|
19677
|
+
...exchangeExclusions(INTEL, "repo_convention_proposal_inputs", {
|
|
19678
|
+
repository: [
|
|
19679
|
+
"join-key",
|
|
19680
|
+
"owner/repo, as in repo_conventions; the primary key with the org."
|
|
19681
|
+
],
|
|
19682
|
+
input_key: [
|
|
19683
|
+
"not-personal",
|
|
19684
|
+
"sha256 hex of an input's name (file path, or CI check and target); no plaintext."
|
|
19685
|
+
],
|
|
19686
|
+
fingerprint: [
|
|
19687
|
+
"not-personal",
|
|
19688
|
+
"sha256 hex of what was sent to the model, or the commit SHA last read; no plaintext."
|
|
19689
|
+
]
|
|
19690
|
+
}),
|
|
19691
|
+
...exchangeExclusions(INTEL, "repo_convention_checks", {
|
|
19692
|
+
repository: [
|
|
19693
|
+
"join-key",
|
|
19694
|
+
"owner/repo the check covered, as in repo_conventions; matched by equality."
|
|
19695
|
+
],
|
|
19696
|
+
trigger: ["operational", "Closed CHECK vocabulary (schedule, request)."],
|
|
19697
|
+
skipped_reason: [
|
|
19698
|
+
"operational",
|
|
19699
|
+
"Closed CHECK vocabulary (no_model, no_github)."
|
|
19700
|
+
]
|
|
19701
|
+
}),
|
|
19666
19702
|
...exchangeExclusions(INTEL, "attempt_rule_configs", {
|
|
19667
19703
|
config: [
|
|
19668
19704
|
"operational",
|
|
@@ -26935,6 +26971,26 @@ var init_table_registry = __esm({
|
|
|
26935
26971
|
entry("intelligence", INTELLIGENCE_DB, "repo_convention_skills", "direct", {
|
|
26936
26972
|
scopingColumn: "organization_id"
|
|
26937
26973
|
}),
|
|
26974
|
+
// The proposer's runs and what it last sent per input (repo-conventions/004).
|
|
26975
|
+
entry(
|
|
26976
|
+
"intelligence",
|
|
26977
|
+
INTELLIGENCE_DB,
|
|
26978
|
+
"repo_convention_proposal_runs",
|
|
26979
|
+
"direct",
|
|
26980
|
+
{ scopingColumn: "organization_id" }
|
|
26981
|
+
),
|
|
26982
|
+
entry(
|
|
26983
|
+
"intelligence",
|
|
26984
|
+
INTELLIGENCE_DB,
|
|
26985
|
+
"repo_convention_proposal_inputs",
|
|
26986
|
+
"direct",
|
|
26987
|
+
{ scopingColumn: "organization_id" }
|
|
26988
|
+
),
|
|
26989
|
+
// Freshness checks of a repository's approved conventions
|
|
26990
|
+
// (repo-conventions/005).
|
|
26991
|
+
entry("intelligence", INTELLIGENCE_DB, "repo_convention_checks", "direct", {
|
|
26992
|
+
scopingColumn: "organization_id"
|
|
26993
|
+
}),
|
|
26938
26994
|
// "Mine more tasks" requests the outcome ledger polls (outcome-ledger/058).
|
|
26939
26995
|
entry("intelligence", INTELLIGENCE_DB, "replay_mining_requests", "direct", {
|
|
26940
26996
|
scopingColumn: "organization_id"
|
|
@@ -86726,6 +86782,9 @@ function unreachable(checks) {
|
|
|
86726
86782
|
const down = checks.filter((c) => !c.ok);
|
|
86727
86783
|
return down.length ? down.map((c) => `${c.name} (${c.reason ?? "no answer"})`).join(", ") : null;
|
|
86728
86784
|
}
|
|
86785
|
+
function agentLoadsMachineServers(agentCmd) {
|
|
86786
|
+
return /(^|[\s/"'])claude(\s|$)/.test(agentCmd) && !/--strict-mcp-config(?![\w-])/.test(agentCmd);
|
|
86787
|
+
}
|
|
86729
86788
|
function agentCannotCallHaansi(agentCmd) {
|
|
86730
86789
|
if (!/(^|[\s/"'])claude(\s|$)/.test(agentCmd)) return null;
|
|
86731
86790
|
if (/--dangerously-skip-permissions|bypassPermissions/.test(agentCmd))
|
|
@@ -87075,6 +87134,11 @@ function haansiServersDown(output) {
|
|
|
87075
87134
|
if (!servers) return null;
|
|
87076
87135
|
return servers.filter((s) => s.name.startsWith("haansi-") && s.status !== "connected").map((s) => `${s.name}: ${s.status}`);
|
|
87077
87136
|
}
|
|
87137
|
+
function haansiServersLoaded(output) {
|
|
87138
|
+
const servers = mcpServersOf(output);
|
|
87139
|
+
if (!servers) return null;
|
|
87140
|
+
return servers.filter((s) => s.name.startsWith("haansi-") && s.status === "connected").map((s) => s.name);
|
|
87141
|
+
}
|
|
87078
87142
|
function agentFailureLines(output, max2, scrub) {
|
|
87079
87143
|
const out = [];
|
|
87080
87144
|
for (const raw of output.trim().split(/\r?\n/)) {
|
|
@@ -88032,6 +88096,11 @@ function renderTemplate(template, vars) {
|
|
|
88032
88096
|
function judgeChange(diff) {
|
|
88033
88097
|
return clip(diff, MAX_CHANGE_CHARS);
|
|
88034
88098
|
}
|
|
88099
|
+
function baselineText(baseline) {
|
|
88100
|
+
if (baseline === null || baseline === void 0)
|
|
88101
|
+
return "(not run alongside this one: judge from the material and the change alone)";
|
|
88102
|
+
return baseline || "(it changed nothing)";
|
|
88103
|
+
}
|
|
88035
88104
|
function parseJudgement(text, returnedIds) {
|
|
88036
88105
|
const match = /\{[\s\S]*\}/.exec(text);
|
|
88037
88106
|
if (!match) return null;
|
|
@@ -88095,6 +88164,8 @@ async function judgeUse(deps, input) {
|
|
|
88095
88164
|
task: input.card,
|
|
88096
88165
|
returned: clip(returned || "(only ids came back)", returnedChars),
|
|
88097
88166
|
change: clip(input.change || "(no change)", changeChars),
|
|
88167
|
+
// Shares the change's budget: they are read side by side.
|
|
88168
|
+
baseline: clip(baselineText(input.baseline), changeChars),
|
|
88098
88169
|
verdict_file: verdictFile
|
|
88099
88170
|
})
|
|
88100
88171
|
].join("\n"),
|
|
@@ -88529,7 +88600,7 @@ function typeEnd(text, i, stops, bodyBrace) {
|
|
|
88529
88600
|
return text.length;
|
|
88530
88601
|
}
|
|
88531
88602
|
function capSignature(text) {
|
|
88532
|
-
const lines = text.trim().split("\n").map((l) => l.replace(/\s+$/, ""));
|
|
88603
|
+
const lines = text.trim().split("\n").map((l) => l.replace(/\s+$/, "")).filter((l) => l !== "");
|
|
88533
88604
|
let out = lines.slice(0, MAX_SIGNATURE_LINES).join("\n");
|
|
88534
88605
|
let cut2 = lines.length > MAX_SIGNATURE_LINES;
|
|
88535
88606
|
if (out.length > MAX_SIGNATURE_CHARS) {
|
|
@@ -88574,7 +88645,7 @@ function signatureOf(source, name) {
|
|
|
88574
88645
|
}
|
|
88575
88646
|
return capSignature(text.slice(start, end));
|
|
88576
88647
|
}
|
|
88577
|
-
const type = new RegExp(`${lead}(type\\s+${n})\\b`).exec(text);
|
|
88648
|
+
const type = new RegExp(`${lead}(type\\s+${n})\\b(?=\\s*[=<])`).exec(text);
|
|
88578
88649
|
if (type) {
|
|
88579
88650
|
const start = type.index + type[0].length - type[2].length - type[1].length;
|
|
88580
88651
|
const end = typeEnd(text, type.index + type[0].length, ";", false);
|
|
@@ -89197,16 +89268,25 @@ function interfaceSection(entries) {
|
|
|
89197
89268
|
];
|
|
89198
89269
|
const where = `\`${e.path}\`${e.newFile ? " (a new file)" : ""}`;
|
|
89199
89270
|
const declared = e.names.filter((n) => e.signatures?.[n]);
|
|
89271
|
+
const types2 = Object.entries(e.types ?? {});
|
|
89272
|
+
const fence = adapterFor(e.path)?.fence ?? "ts";
|
|
89200
89273
|
return [
|
|
89201
89274
|
`- ${where}${what.length ? `: ${what.join(", ")}` : ""}`,
|
|
89202
89275
|
// As the target declares each: its shape, never its body.
|
|
89203
89276
|
...declared.flatMap((n) => [
|
|
89204
89277
|
"",
|
|
89205
|
-
...fenced(e.signatures[n],
|
|
89206
|
-
(l) => ` ${l}`
|
|
89207
|
-
)
|
|
89278
|
+
...fenced(e.signatures[n], fence).map((l) => ` ${l}`)
|
|
89208
89279
|
]),
|
|
89209
|
-
...declared.length ? [""] : []
|
|
89280
|
+
...declared.length ? [""] : [],
|
|
89281
|
+
// The shapes those declarations name, as the module declares them.
|
|
89282
|
+
...types2.length ? [
|
|
89283
|
+
" The types these use, declared in the same module:",
|
|
89284
|
+
...types2.flatMap(([, sig]) => [
|
|
89285
|
+
"",
|
|
89286
|
+
...fenced(sig, fence).map((l) => ` ${l}`)
|
|
89287
|
+
]),
|
|
89288
|
+
""
|
|
89289
|
+
] : []
|
|
89210
89290
|
];
|
|
89211
89291
|
}),
|
|
89212
89292
|
""
|
|
@@ -89374,16 +89454,38 @@ function cappedTitles(titles) {
|
|
|
89374
89454
|
}
|
|
89375
89455
|
return { shown, more: titles.length - shown.length };
|
|
89376
89456
|
}
|
|
89457
|
+
function typeNamesIn(declaration) {
|
|
89458
|
+
return [...new Set(declaration.match(/\b[A-Z][A-Za-z0-9_]*\b/g) ?? [])];
|
|
89459
|
+
}
|
|
89377
89460
|
async function withSignatures(show, targetSha, entries) {
|
|
89378
89461
|
const out = [];
|
|
89379
89462
|
for (const e of entries) {
|
|
89380
89463
|
const source = e.names.length ? await show(targetSha, e.path) : null;
|
|
89464
|
+
const lang = adapterFor(e.path);
|
|
89381
89465
|
const signatures = {};
|
|
89382
89466
|
for (const n of e.names) {
|
|
89383
|
-
const sig = source === null ? null :
|
|
89467
|
+
const sig = source === null ? null : lang?.signatureOf(source, n) ?? null;
|
|
89384
89468
|
if (sig) signatures[n] = sig;
|
|
89385
89469
|
}
|
|
89386
|
-
|
|
89470
|
+
const types2 = {};
|
|
89471
|
+
if (source !== null && lang) {
|
|
89472
|
+
const queue = Object.values(signatures).flatMap(typeNamesIn);
|
|
89473
|
+
const seen = new Set(e.names);
|
|
89474
|
+
while (queue.length && Object.keys(types2).length < MAX_TYPE_DECLARATIONS) {
|
|
89475
|
+
const name = queue.shift();
|
|
89476
|
+
if (seen.has(name)) continue;
|
|
89477
|
+
seen.add(name);
|
|
89478
|
+
const sig = lang.signatureOf(source, name);
|
|
89479
|
+
if (!sig) continue;
|
|
89480
|
+
types2[name] = sig;
|
|
89481
|
+
queue.push(...typeNamesIn(sig));
|
|
89482
|
+
}
|
|
89483
|
+
}
|
|
89484
|
+
out.push({
|
|
89485
|
+
...e,
|
|
89486
|
+
...Object.keys(signatures).length ? { signatures } : {},
|
|
89487
|
+
...Object.keys(types2).length ? { types: types2 } : {}
|
|
89488
|
+
});
|
|
89387
89489
|
}
|
|
89388
89490
|
return out;
|
|
89389
89491
|
}
|
|
@@ -89456,7 +89558,7 @@ function baseNameOf(path2) {
|
|
|
89456
89558
|
const name = /\.py$/.test(file2) ? file2.replace(/\.py$/, "").replace(/^test_(?=.)|(?<=.)_test$/, "") : file2.replace(/\.[cm]?[jt]sx?$/, "").replace(/\.(?:test|spec)$/, "");
|
|
89457
89559
|
return (name === "index" || name === "__init__") && parts.length ? parts[parts.length - 1] : name;
|
|
89458
89560
|
}
|
|
89459
|
-
var MAX_TITLES, MAX_TITLE_CHARS, MAX_FAILING_PATHS, MAX_HOP_MODULES, norm;
|
|
89561
|
+
var MAX_TITLES, MAX_TITLE_CHARS, MAX_FAILING_PATHS, MAX_TYPE_DECLARATIONS, MAX_HOP_MODULES, norm;
|
|
89460
89562
|
var init_replay_spec = __esm({
|
|
89461
89563
|
"src/commands/replay-spec.ts"() {
|
|
89462
89564
|
"use strict";
|
|
@@ -89466,6 +89568,7 @@ var init_replay_spec = __esm({
|
|
|
89466
89568
|
MAX_TITLES = 40;
|
|
89467
89569
|
MAX_TITLE_CHARS = 4e3;
|
|
89468
89570
|
MAX_FAILING_PATHS = 12;
|
|
89571
|
+
MAX_TYPE_DECLARATIONS = 8;
|
|
89469
89572
|
MAX_HOP_MODULES = 24;
|
|
89470
89573
|
norm = (s) => s.replace(/\s+/g, " ").trim();
|
|
89471
89574
|
}
|
|
@@ -89791,12 +89894,12 @@ function haansiSection(tools, hint = null) {
|
|
|
89791
89894
|
"",
|
|
89792
89895
|
"These MCP servers hold what your organization learned before this task began. They are read-only here.",
|
|
89793
89896
|
"",
|
|
89794
|
-
"
|
|
89897
|
+
"Work on the task first, as you would without them: read the code and make your change. Then, before you finish, check your work against them, and change it where they show something wrong, missing or already tried. Search again whenever you get stuck:",
|
|
89795
89898
|
"",
|
|
89796
|
-
"- Repository conventions:
|
|
89899
|
+
"- Repository conventions: get_conventions with the files you changed: the repository's approved conventions (rules this codebase follows) that apply to them.",
|
|
89797
89900
|
"- Past fixes: search_solutions with a sentence about the problem (its error line in error, failing tests in failing_tests, the files you expect to change in files, identifiers in names), then get_solution to read the matching results in full.",
|
|
89798
89901
|
"- Team procedures: match_playbook with the task, and search_skills; get_skill loads one.",
|
|
89799
|
-
"- Earlier attempts at the same code: get_prior_attempts with the files you
|
|
89902
|
+
"- Earlier attempts at the same code: get_prior_attempts with the files you changed.",
|
|
89800
89903
|
"- Incidents like this one: search_prior_incidents.",
|
|
89801
89904
|
"- Recent work, conventions and shared answers: search_digests, search_guides and search_exchange.",
|
|
89802
89905
|
"",
|
|
@@ -89953,6 +90056,14 @@ async function runStoredReplays(options, deps) {
|
|
|
89953
90056
|
throw new Error(
|
|
89954
90057
|
`No test command: pass --test-cmd, or set one for ${repository} in Haansi.`
|
|
89955
90058
|
);
|
|
90059
|
+
for (const [flag, cmd] of [
|
|
90060
|
+
["--agent-cmd", options.agentCmd],
|
|
90061
|
+
["--judge-cmd", options.judgeCmd ?? ""]
|
|
90062
|
+
])
|
|
90063
|
+
if (cmd && agentLoadsMachineServers(cmd))
|
|
90064
|
+
deps.log(
|
|
90065
|
+
`${flag} runs Claude Code without --strict-mcp-config: it also loads the MCP servers set up on this machine. Add --strict-mcp-config so each arm and judge gets only its own servers.`
|
|
90066
|
+
);
|
|
89956
90067
|
if (set2.tasks.length === 0) {
|
|
89957
90068
|
deps.log(
|
|
89958
90069
|
`No replay tasks for ${repository} yet: they need a card (replay task cards on for the organization).`
|
|
@@ -89995,7 +90106,9 @@ async function runStoredReplays(options, deps) {
|
|
|
89995
90106
|
(t) => states.get(t.taskId) === "valid" && t.testFiles.length > 0 && t.testFiles.every(safeTestFile) && SHA.test(t.baseSha) && SHA.test(t.targetSha)
|
|
89996
90107
|
);
|
|
89997
90108
|
const notValid = mine.length - valid.length;
|
|
89998
|
-
const arms = options.arms
|
|
90109
|
+
const arms = [...options.arms].sort(
|
|
90110
|
+
(a, b) => Number(a !== "baseline") - Number(b !== "baseline")
|
|
90111
|
+
);
|
|
89999
90112
|
let judgePrompt;
|
|
90000
90113
|
const promptForJudge = async () => {
|
|
90001
90114
|
if (judgePrompt === void 0)
|
|
@@ -90125,6 +90238,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90125
90238
|
`\u2026 ${label}: the tests use ${task.testInterface.length} module(s) the start lacks; named in the prompt`
|
|
90126
90239
|
);
|
|
90127
90240
|
let targetSent = false;
|
|
90241
|
+
let baselineChange = null;
|
|
90128
90242
|
for (const arm of arms) {
|
|
90129
90243
|
if (!options.force && alreadyMeasured(
|
|
90130
90244
|
task.measured,
|
|
@@ -90187,6 +90301,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90187
90301
|
changed = await changedFiles(deps, dir, task.baseSha);
|
|
90188
90302
|
agentDiff = await agentDiffOf(deps, dir, task.baseSha);
|
|
90189
90303
|
if (arm === "haansi") change = judgeChange(agentDiff);
|
|
90304
|
+
else baselineChange = judgeChange(agentDiff);
|
|
90190
90305
|
},
|
|
90191
90306
|
{
|
|
90192
90307
|
HAANSI_REPLAY_MCP_CONFIG: configPath,
|
|
@@ -90210,6 +90325,7 @@ async function runStoredReplays(options, deps) {
|
|
|
90210
90325
|
card: cardPrompt(task, null),
|
|
90211
90326
|
calls,
|
|
90212
90327
|
change,
|
|
90328
|
+
baseline: baselineChange,
|
|
90213
90329
|
prompt: await promptForJudge()
|
|
90214
90330
|
})
|
|
90215
90331
|
};
|
|
@@ -90394,7 +90510,7 @@ function parseReplayArgs(argv) {
|
|
|
90394
90510
|
testCmd: "",
|
|
90395
90511
|
setupCmd: null,
|
|
90396
90512
|
repoCommands: false,
|
|
90397
|
-
attempts:
|
|
90513
|
+
attempts: 2,
|
|
90398
90514
|
arms: [...ARMS],
|
|
90399
90515
|
limit: null,
|
|
90400
90516
|
// 20 minutes an attempt: the longest replays (90 min) were stuck.
|
|
@@ -90641,6 +90757,13 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90641
90757
|
`Haansi's servers did not load for the agent (${down.join(", ")}); not graded, run it again`
|
|
90642
90758
|
);
|
|
90643
90759
|
}
|
|
90760
|
+
if (arm === "baseline") {
|
|
90761
|
+
const loaded = haansiServersLoaded(agent.output) ?? [];
|
|
90762
|
+
if (loaded.length)
|
|
90763
|
+
throw new Error(
|
|
90764
|
+
`the baseline's agent loaded Haansi's servers (${loaded.join(", ")}): it did not run without Haansi; not graded. Add --strict-mcp-config to a Claude Code command.`
|
|
90765
|
+
);
|
|
90766
|
+
}
|
|
90644
90767
|
const uses = toolUsesOf(agent.output);
|
|
90645
90768
|
if (uses) deps.log(`\u2026 ${label}: tools used: ${toolUsesLine(uses)}`);
|
|
90646
90769
|
const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
|
|
@@ -91019,7 +91142,7 @@ var init_replay = __esm({
|
|
|
91019
91142
|
OUTPUT_HEAD_CHARS = 4e4;
|
|
91020
91143
|
OUTPUT_TAIL_CHARS = 2e5;
|
|
91021
91144
|
USAGE2 = `Usage: haansi replay run --agent-cmd "<cmd>" --test-cmd "<cmd>"
|
|
91022
|
-
[--setup-cmd "<cmd>"] [--attempts
|
|
91145
|
+
[--setup-cmd "<cmd>"] [--attempts 2] [--arms baseline,haansi] [--limit n]
|
|
91023
91146
|
[--timeout-min 20] [--agent-name <name>] [--model <name>]
|
|
91024
91147
|
[--judge-cmd "<cmd>"]
|
|
91025
91148
|
[--run-ref <url>] [--dry-run] [--repo-commands] [--no-diffs]
|
|
@@ -91085,7 +91208,7 @@ Run from a clone of the repository. Example (GitHub Actions):
|
|
|
91085
91208
|
haansi replay run --setup-cmd 'npm ci' \\
|
|
91086
91209
|
--container node:22 --container-env ANTHROPIC_API_KEY \\
|
|
91087
91210
|
--container-setup 'npm install -g haansi @anthropic-ai/claude-code' \\
|
|
91088
|
-
--agent-cmd 'claude -p "$HAANSI_REPLAY_PROMPT" --output-format stream-json --verbose --permission-mode acceptEdits --mcp-config "$HAANSI_REPLAY_MCP_CONFIG" --allowedTools mcp__haansi-solutions,mcp__haansi-exchange,mcp__haansi-digests,mcp__haansi-onboarding,mcp__haansi-skills,mcp__haansi-incidents' \\
|
|
91211
|
+
--agent-cmd 'claude -p "$HAANSI_REPLAY_PROMPT" --output-format stream-json --verbose --permission-mode acceptEdits --mcp-config "$HAANSI_REPLAY_MCP_CONFIG" --strict-mcp-config --allowedTools mcp__haansi-solutions,mcp__haansi-exchange,mcp__haansi-digests,mcp__haansi-onboarding,mcp__haansi-skills,mcp__haansi-incidents' \\
|
|
91089
91212
|
--test-cmd 'npx vitest run $HAANSI_REPLAY_TEST_FILES -t "$HAANSI_REPLAY_TEST_PATTERN"' \\
|
|
91090
91213
|
--agent-name claude-code --model claude-sonnet-5-5`;
|
|
91091
91214
|
}
|