haansi 0.1.106 → 0.1.108
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 +129 -93
- 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.108",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -60178,7 +60178,7 @@ var init_stdio2 = __esm({
|
|
|
60178
60178
|
function searchSolutionsTool(contextSchema2) {
|
|
60179
60179
|
return {
|
|
60180
60180
|
name: "search_solutions",
|
|
60181
|
-
description: "Search previously solved similar questions from your organization's knowledge base. Finds how bugs were fixed, what patterns were used, and past resolutions to similar problems. Results are ranked by a composite of relevance, quality, recency, and verification status. For a failing test, pass its name in failing_tests and the error line in error. Pass the files you expect to change, or that the failure runs through, in files.",
|
|
60181
|
+
description: "Search previously solved similar questions from your organization's knowledge base. Finds how bugs were fixed, what patterns were used, and past resolutions to similar problems. Results are ranked by a composite of relevance, quality, recency, and verification status. Describe the problem in a sentence in query: a test name, an identifier or a list of file names alone rarely matches; pass those in the structured inputs instead. For a failing test, pass its name in failing_tests and the error line in error. Pass the files you expect to change, or that the failure runs through, in files.",
|
|
60182
60182
|
inputSchema: {
|
|
60183
60183
|
type: "object",
|
|
60184
60184
|
properties: {
|
|
@@ -78230,7 +78230,7 @@ var require_view = __commonJS({
|
|
|
78230
78230
|
var dirname6 = path2.dirname;
|
|
78231
78231
|
var basename4 = path2.basename;
|
|
78232
78232
|
var extname = path2.extname;
|
|
78233
|
-
var
|
|
78233
|
+
var join23 = path2.join;
|
|
78234
78234
|
var resolve5 = path2.resolve;
|
|
78235
78235
|
module2.exports = View;
|
|
78236
78236
|
function View(name, options) {
|
|
@@ -78292,12 +78292,12 @@ var require_view = __commonJS({
|
|
|
78292
78292
|
};
|
|
78293
78293
|
View.prototype.resolve = function resolve6(dir, file2) {
|
|
78294
78294
|
var ext = this.ext;
|
|
78295
|
-
var path3 =
|
|
78295
|
+
var path3 = join23(dir, file2);
|
|
78296
78296
|
var stat = tryStat(path3);
|
|
78297
78297
|
if (stat && stat.isFile()) {
|
|
78298
78298
|
return path3;
|
|
78299
78299
|
}
|
|
78300
|
-
path3 =
|
|
78300
|
+
path3 = join23(dir, basename4(file2, ext), "index" + ext);
|
|
78301
78301
|
stat = tryStat(path3);
|
|
78302
78302
|
if (stat && stat.isFile()) {
|
|
78303
78303
|
return path3;
|
|
@@ -81942,7 +81942,7 @@ var require_send = __commonJS({
|
|
|
81942
81942
|
var Stream = require("stream");
|
|
81943
81943
|
var util2 = require("util");
|
|
81944
81944
|
var extname = path2.extname;
|
|
81945
|
-
var
|
|
81945
|
+
var join23 = path2.join;
|
|
81946
81946
|
var normalize2 = path2.normalize;
|
|
81947
81947
|
var resolve5 = path2.resolve;
|
|
81948
81948
|
var sep3 = path2.sep;
|
|
@@ -82114,7 +82114,7 @@ var require_send = __commonJS({
|
|
|
82114
82114
|
return res;
|
|
82115
82115
|
}
|
|
82116
82116
|
parts = path3.split(sep3);
|
|
82117
|
-
path3 = normalize2(
|
|
82117
|
+
path3 = normalize2(join23(root, path3));
|
|
82118
82118
|
} else {
|
|
82119
82119
|
if (UP_PATH_REGEXP.test(path3)) {
|
|
82120
82120
|
debug('malicious path "%s"', path3);
|
|
@@ -82247,7 +82247,7 @@ var require_send = __commonJS({
|
|
|
82247
82247
|
if (err2) return self.onStatError(err2);
|
|
82248
82248
|
return self.error(404);
|
|
82249
82249
|
}
|
|
82250
|
-
var p =
|
|
82250
|
+
var p = join23(path3, self._index[i]);
|
|
82251
82251
|
debug('stat "%s"', p);
|
|
82252
82252
|
fs.stat(p, function(err3, stat) {
|
|
82253
82253
|
if (err3) return next(err3);
|
|
@@ -86008,6 +86008,37 @@ var init_skills = __esm({
|
|
|
86008
86008
|
}
|
|
86009
86009
|
});
|
|
86010
86010
|
|
|
86011
|
+
// src/commands/replay-workdir.ts
|
|
86012
|
+
function makeWritable(dir) {
|
|
86013
|
+
const stat = (0, import_node_fs11.lstatSync)(dir);
|
|
86014
|
+
if (!stat.isDirectory()) return;
|
|
86015
|
+
(0, import_node_fs11.chmodSync)(dir, stat.mode | 448);
|
|
86016
|
+
for (const entry2 of (0, import_node_fs11.readdirSync)(dir)) makeWritable((0, import_node_path10.join)(dir, entry2));
|
|
86017
|
+
}
|
|
86018
|
+
function removeWorkDir(dir, log = (line) => console.error(line)) {
|
|
86019
|
+
try {
|
|
86020
|
+
(0, import_node_fs11.rmSync)(dir, { recursive: true, force: true });
|
|
86021
|
+
return;
|
|
86022
|
+
} catch {
|
|
86023
|
+
}
|
|
86024
|
+
try {
|
|
86025
|
+
makeWritable(dir);
|
|
86026
|
+
(0, import_node_fs11.rmSync)(dir, { recursive: true, force: true });
|
|
86027
|
+
} catch (err2) {
|
|
86028
|
+
log(
|
|
86029
|
+
`Could not remove the work directory ${dir}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
86030
|
+
);
|
|
86031
|
+
}
|
|
86032
|
+
}
|
|
86033
|
+
var import_node_fs11, import_node_path10;
|
|
86034
|
+
var init_replay_workdir = __esm({
|
|
86035
|
+
"src/commands/replay-workdir.ts"() {
|
|
86036
|
+
"use strict";
|
|
86037
|
+
import_node_fs11 = require("node:fs");
|
|
86038
|
+
import_node_path10 = require("node:path");
|
|
86039
|
+
}
|
|
86040
|
+
});
|
|
86041
|
+
|
|
86011
86042
|
// src/commands/replay-errors.ts
|
|
86012
86043
|
function scrubSecrets(text) {
|
|
86013
86044
|
let out = text;
|
|
@@ -86273,13 +86304,13 @@ function containerRefusal(env, options) {
|
|
|
86273
86304
|
return 'This job can ask GitHub for an identity token ("permissions: id-token: write"), so the agent and the tests it edits could too. Run them in a container: add --container node:22 (and --container-setup to install your agent).';
|
|
86274
86305
|
}
|
|
86275
86306
|
function inside(work, cwd) {
|
|
86276
|
-
const rel = (0,
|
|
86277
|
-
return rel === "" || !rel.startsWith("..") && !(0,
|
|
86307
|
+
const rel = (0, import_node_path11.relative)(work, cwd);
|
|
86308
|
+
return rel === "" || !rel.startsWith("..") && !(0, import_node_path11.isAbsolute)(rel) ? cwd : work;
|
|
86278
86309
|
}
|
|
86279
86310
|
async function startContainer(work, options, run3, log, user = currentUser()) {
|
|
86280
86311
|
const name = `haansi-replay-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
|
|
86281
|
-
const home = (0,
|
|
86282
|
-
(0,
|
|
86312
|
+
const home = (0, import_node_path11.join)(work, ".home");
|
|
86313
|
+
(0, import_node_fs12.mkdirSync)(home, { recursive: true });
|
|
86283
86314
|
log(`\u2026 starting container ${options.image}`);
|
|
86284
86315
|
const started = await run3(
|
|
86285
86316
|
"docker",
|
|
@@ -86446,13 +86477,13 @@ async function withContainer(deps, work, options, run3) {
|
|
|
86446
86477
|
function hostGit(work, repoDir, args, cwd) {
|
|
86447
86478
|
return inside(work, cwd) !== cwd || args.includes(repoDir);
|
|
86448
86479
|
}
|
|
86449
|
-
var import_node_crypto3,
|
|
86480
|
+
var import_node_crypto3, import_node_fs12, import_node_path11, NO_CONTAINER, ENV_NAME, IMAGE, SETUP_TIMEOUT_MS, KILL_SLACK_MS, PIDS_LIMIT, SETTLE_SCRIPT, GIT_TIMEOUT_MS;
|
|
86450
86481
|
var init_replay_container = __esm({
|
|
86451
86482
|
"src/commands/replay-container.ts"() {
|
|
86452
86483
|
"use strict";
|
|
86453
86484
|
import_node_crypto3 = require("node:crypto");
|
|
86454
|
-
|
|
86455
|
-
|
|
86485
|
+
import_node_fs12 = require("node:fs");
|
|
86486
|
+
import_node_path11 = require("node:path");
|
|
86456
86487
|
NO_CONTAINER = {
|
|
86457
86488
|
image: null,
|
|
86458
86489
|
setupCmd: null,
|
|
@@ -87092,20 +87123,20 @@ async function setUpClone(deps, dir, setupCmd, timeoutMs, cache, platform2 = pro
|
|
|
87092
87123
|
`${setupCmd}\0${cache.paths.join(",")}`,
|
|
87093
87124
|
cache.keyFiles.filter(safeCachePath).map((path2) => ({
|
|
87094
87125
|
path: path2,
|
|
87095
|
-
content: deps.readFile((0,
|
|
87126
|
+
content: deps.readFile((0, import_node_path12.join)(dir, path2))
|
|
87096
87127
|
}))
|
|
87097
87128
|
) : null;
|
|
87098
|
-
const kept = key && cache ? (0,
|
|
87129
|
+
const kept = key && cache ? (0, import_node_path12.join)(cache.dir, key) : null;
|
|
87099
87130
|
const q = shellPath;
|
|
87100
87131
|
const run3 = (command2) => deps.shell(command2, dir, {}, timeoutMs);
|
|
87101
87132
|
if (kept && cache) {
|
|
87102
|
-
const manifest = deps.readFile((0,
|
|
87133
|
+
const manifest = deps.readFile((0, import_node_path12.join)(kept, MANIFEST));
|
|
87103
87134
|
const paths = manifest === null ? null : foundPaths(manifest);
|
|
87104
|
-
if (paths && (await run3(`test -f ${q((0,
|
|
87135
|
+
if (paths && (await run3(`test -f ${q((0, import_node_path12.join)(kept, ".complete"))}`)).code === 0) {
|
|
87105
87136
|
let restored = true;
|
|
87106
87137
|
for (const p of paths) {
|
|
87107
87138
|
const copied = await run3(
|
|
87108
|
-
`rm -rf ${q((0,
|
|
87139
|
+
`rm -rf ${q((0, import_node_path12.join)(dir, p))} && mkdir -p ${q((0, import_node_path12.join)(dir, p, ".."))} && ${copyCommand(platform2, (0, import_node_path12.join)(kept, p), (0, import_node_path12.join)(dir, p), true)}`
|
|
87109
87140
|
);
|
|
87110
87141
|
if (copied.code !== 0) {
|
|
87111
87142
|
restored = false;
|
|
@@ -87131,10 +87162,10 @@ async function setUpClone(deps, dir, setupCmd, timeoutMs, cache, platform2 = pro
|
|
|
87131
87162
|
let ok = (await run3(`mkdir -p ${q(tmp)}`)).code === 0;
|
|
87132
87163
|
for (const p of [...new Set(paths)].sort()) {
|
|
87133
87164
|
if (!ok) break;
|
|
87134
|
-
ok = (await run3(`mkdir -p ${q((0,
|
|
87165
|
+
ok = (await run3(`mkdir -p ${q((0, import_node_path12.join)(tmp, p, ".."))}`)).code === 0 && (await run3(copyCommand(platform2, (0, import_node_path12.join)(dir, p), (0, import_node_path12.join)(tmp, p), false))).code === 0;
|
|
87135
87166
|
}
|
|
87136
87167
|
await run3(
|
|
87137
|
-
ok ? `printf '%s\\n' ${[...new Set(paths)].sort().map(q).join(" ")} > ${q((0,
|
|
87168
|
+
ok ? `printf '%s\\n' ${[...new Set(paths)].sort().map(q).join(" ")} > ${q((0, import_node_path12.join)(tmp, MANIFEST))} && touch ${q((0, import_node_path12.join)(tmp, ".complete"))} && rm -rf ${q(kept)} && mv ${q(tmp)} ${q(kept)}` : `rm -rf ${q(tmp)}`
|
|
87138
87169
|
);
|
|
87139
87170
|
}
|
|
87140
87171
|
return { ...setup, cached: false };
|
|
@@ -87145,7 +87176,7 @@ function newScaleArgs(home) {
|
|
|
87145
87176
|
concurrency: 1,
|
|
87146
87177
|
cacheFiles: [],
|
|
87147
87178
|
cachePaths: [],
|
|
87148
|
-
cacheDir: (0,
|
|
87179
|
+
cacheDir: (0, import_node_path12.join)(home, ".cache", "haansi-replay")
|
|
87149
87180
|
};
|
|
87150
87181
|
}
|
|
87151
87182
|
function takeScaleArg(a, next, state, errors) {
|
|
@@ -87189,12 +87220,12 @@ function finishScaleArgs(state, containerImage, errors) {
|
|
|
87189
87220
|
}
|
|
87190
87221
|
return { shard: state.shard, concurrency: state.concurrency, setupCache };
|
|
87191
87222
|
}
|
|
87192
|
-
var import_node_crypto4,
|
|
87223
|
+
var import_node_crypto4, import_node_path12, shellPath, MANIFEST, commaList;
|
|
87193
87224
|
var init_replay_scale = __esm({
|
|
87194
87225
|
"src/commands/replay-scale.ts"() {
|
|
87195
87226
|
"use strict";
|
|
87196
87227
|
import_node_crypto4 = require("node:crypto");
|
|
87197
|
-
|
|
87228
|
+
import_node_path12 = require("node:path");
|
|
87198
87229
|
shellPath = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
87199
87230
|
MANIFEST = ".paths";
|
|
87200
87231
|
commaList = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -87404,7 +87435,7 @@ async function calibrateTask(deps, options, commands, task) {
|
|
|
87404
87435
|
});
|
|
87405
87436
|
const sides = isFeatureDelivery(task) ? ["target"] : ["base", "target"];
|
|
87406
87437
|
for (const side of sides) {
|
|
87407
|
-
const dir = (0,
|
|
87438
|
+
const dir = (0, import_node_path13.join)(
|
|
87408
87439
|
deps.workDir(),
|
|
87409
87440
|
`${task.taskId.replace(/[^a-zA-Z0-9-]/g, "")}-${side}`
|
|
87410
87441
|
);
|
|
@@ -87447,8 +87478,8 @@ async function calibrateTask(deps, options, commands, task) {
|
|
|
87447
87478
|
if (side === "base" && testNamesOf(task).length === 0) {
|
|
87448
87479
|
for (const f of task.testFiles) {
|
|
87449
87480
|
const content = await deps.showFile(task.targetSha, f);
|
|
87450
|
-
if (content === null) deps.removeFile((0,
|
|
87451
|
-
else deps.writeFile((0,
|
|
87481
|
+
if (content === null) deps.removeFile((0, import_node_path13.join)(dir, f));
|
|
87482
|
+
else deps.writeFile((0, import_node_path13.join)(dir, f), content);
|
|
87452
87483
|
}
|
|
87453
87484
|
}
|
|
87454
87485
|
for (let i = 0; i < options.runs; i++) {
|
|
@@ -87648,7 +87679,7 @@ async function calibrate(argv) {
|
|
|
87648
87679
|
process.exitCode = 1;
|
|
87649
87680
|
return;
|
|
87650
87681
|
}
|
|
87651
|
-
const work = (0,
|
|
87682
|
+
const work = (0, import_node_fs13.mkdtempSync)((0, import_node_path13.join)((0, import_node_os10.tmpdir)(), "haansi-calibrate-"));
|
|
87652
87683
|
let stop = null;
|
|
87653
87684
|
try {
|
|
87654
87685
|
const contained = await withContainer(
|
|
@@ -87690,7 +87721,7 @@ Valid: ${count4("valid")} \xB7 Invalid: ${count4("invalid")} \xB7 Flaky: ${count
|
|
|
87690
87721
|
process.exitCode = 1;
|
|
87691
87722
|
} finally {
|
|
87692
87723
|
await stop?.();
|
|
87693
|
-
(
|
|
87724
|
+
removeWorkDir(work);
|
|
87694
87725
|
}
|
|
87695
87726
|
}
|
|
87696
87727
|
function cliVersion() {
|
|
@@ -87700,14 +87731,15 @@ function cliVersion() {
|
|
|
87700
87731
|
return null;
|
|
87701
87732
|
}
|
|
87702
87733
|
}
|
|
87703
|
-
var import_node_crypto5,
|
|
87734
|
+
var import_node_crypto5, import_node_fs13, import_node_os10, import_node_path13, RUNTIMES, REPORT_CHUNK, FAILURE_LINES, STATE, CALIBRATION_VERSION, isFeatureDelivery, USAGE;
|
|
87704
87735
|
var init_replay_calibrate = __esm({
|
|
87705
87736
|
"src/commands/replay-calibrate.ts"() {
|
|
87706
87737
|
"use strict";
|
|
87738
|
+
init_replay_workdir();
|
|
87707
87739
|
import_node_crypto5 = require("node:crypto");
|
|
87708
|
-
|
|
87740
|
+
import_node_fs13 = require("node:fs");
|
|
87709
87741
|
import_node_os10 = require("node:os");
|
|
87710
|
-
|
|
87742
|
+
import_node_path13 = require("node:path");
|
|
87711
87743
|
init_paths();
|
|
87712
87744
|
init_api2();
|
|
87713
87745
|
init_replay_errors();
|
|
@@ -87934,10 +87966,10 @@ async function judgeUse(deps, input) {
|
|
|
87934
87966
|
judgeTag: null
|
|
87935
87967
|
};
|
|
87936
87968
|
const tag = input.prompt.edited ? `${input.prompt.tag}+edited` : input.prompt.tag;
|
|
87937
|
-
const dir = (0,
|
|
87938
|
-
const verdictFile = (0,
|
|
87939
|
-
const promptFile = (0,
|
|
87940
|
-
const configFile = (0,
|
|
87969
|
+
const dir = (0, import_node_path14.join)(deps.workDir(), `${input.taskId}-judge`);
|
|
87970
|
+
const verdictFile = (0, import_node_path14.join)(dir, "verdict.json");
|
|
87971
|
+
const promptFile = (0, import_node_path14.join)(dir, "prompt.md");
|
|
87972
|
+
const configFile = (0, import_node_path14.join)(dir, "mcp.json");
|
|
87941
87973
|
const returned = input.calls.map((c) => c.returnedText ?? "").filter(Boolean).join("\n\n");
|
|
87942
87974
|
const prompt2 = [
|
|
87943
87975
|
input.prompt.system,
|
|
@@ -87979,11 +88011,11 @@ async function judgeUse(deps, input) {
|
|
|
87979
88011
|
deps.removeDir(dir);
|
|
87980
88012
|
}
|
|
87981
88013
|
}
|
|
87982
|
-
var
|
|
88014
|
+
var import_node_path14, MAX_CHANGE_CHARS, MAX_RETURNED_CHARS, MAX_REASON, VERDICTS, clip;
|
|
87983
88015
|
var init_replay_judge = __esm({
|
|
87984
88016
|
"src/commands/replay-judge.ts"() {
|
|
87985
88017
|
"use strict";
|
|
87986
|
-
|
|
88018
|
+
import_node_path14 = require("node:path");
|
|
87987
88019
|
init_replay_diff();
|
|
87988
88020
|
MAX_CHANGE_CHARS = 6e4;
|
|
87989
88021
|
MAX_RETURNED_CHARS = 6e4;
|
|
@@ -88082,10 +88114,10 @@ async function judgeRelevance(deps, input) {
|
|
|
88082
88114
|
judgeTag: null
|
|
88083
88115
|
};
|
|
88084
88116
|
const tag = input.prompt.edited ? `${input.prompt.tag}+edited` : input.prompt.tag;
|
|
88085
|
-
const dir = (0,
|
|
88086
|
-
const verdictFile = (0,
|
|
88087
|
-
const promptFile = (0,
|
|
88088
|
-
const configFile = (0,
|
|
88117
|
+
const dir = (0, import_node_path15.join)(deps.workDir(), `${input.taskId}-relevance`);
|
|
88118
|
+
const verdictFile = (0, import_node_path15.join)(dir, "verdict.json");
|
|
88119
|
+
const promptFile = (0, import_node_path15.join)(dir, "prompt.md");
|
|
88120
|
+
const configFile = (0, import_node_path15.join)(dir, "mcp.json");
|
|
88089
88121
|
const prompt2 = [
|
|
88090
88122
|
input.prompt.system,
|
|
88091
88123
|
"",
|
|
@@ -88138,11 +88170,11 @@ async function judgeRelevance(deps, input) {
|
|
|
88138
88170
|
deps.removeDir(dir);
|
|
88139
88171
|
}
|
|
88140
88172
|
}
|
|
88141
|
-
var
|
|
88173
|
+
var import_node_path15, MAX_CHANGE_CHARS2, MAX_ITEMS_CHARS, QUERY_CHARS, TERMS, clip2, COMMON, said;
|
|
88142
88174
|
var init_replay_relevance = __esm({
|
|
88143
88175
|
"src/commands/replay-relevance.ts"() {
|
|
88144
88176
|
"use strict";
|
|
88145
|
-
|
|
88177
|
+
import_node_path15 = require("node:path");
|
|
88146
88178
|
init_replay_judge();
|
|
88147
88179
|
MAX_CHANGE_CHARS2 = 6e4;
|
|
88148
88180
|
MAX_ITEMS_CHARS = 8e4;
|
|
@@ -88242,7 +88274,7 @@ function hasDefaultExport(source) {
|
|
|
88242
88274
|
/\bmodule\.exports\s*=/.test(text);
|
|
88243
88275
|
}
|
|
88244
88276
|
function candidatesFor(fromFile, spec2) {
|
|
88245
|
-
const base = (0,
|
|
88277
|
+
const base = (0, import_node_path16.normalize)((0, import_node_path16.join)((0, import_node_path16.dirname)(fromFile), spec2)).replace(/\\/g, "/");
|
|
88246
88278
|
if (base.startsWith("..")) return [];
|
|
88247
88279
|
const stem2 = base.replace(/\.(?:[cm]?js|jsx)$/, "");
|
|
88248
88280
|
const withExt = /\.[cm]?[jt]sx?$/.test(base) ? [base] : [];
|
|
@@ -88482,11 +88514,11 @@ function packageSpecsOf(source) {
|
|
|
88482
88514
|
if (!out.includes(m[1])) out.push(m[1]);
|
|
88483
88515
|
return out;
|
|
88484
88516
|
}
|
|
88485
|
-
var
|
|
88517
|
+
var import_node_path16, MAX_SIGNATURE_LINES, MAX_SIGNATURE_CHARS, JS_SOURCE, JS_TEST_FILE, EXTENSIONS, IDENT, stripComments, CALL, jsAdapter;
|
|
88486
88518
|
var init_replay_lang_js = __esm({
|
|
88487
88519
|
"src/commands/replay-lang-js.ts"() {
|
|
88488
88520
|
"use strict";
|
|
88489
|
-
|
|
88521
|
+
import_node_path16 = require("node:path");
|
|
88490
88522
|
MAX_SIGNATURE_LINES = 15;
|
|
88491
88523
|
MAX_SIGNATURE_CHARS = 600;
|
|
88492
88524
|
JS_SOURCE = /\.[cm]?[jt]sx?$/;
|
|
@@ -88610,14 +88642,14 @@ function pythonModuleCandidates(fromPath, spec2) {
|
|
|
88610
88642
|
const parts = rest ? rest.split(".") : [];
|
|
88611
88643
|
if (!parts.every((p) => IDENT2.test(p))) return [];
|
|
88612
88644
|
const at = (dir2) => {
|
|
88613
|
-
const base =
|
|
88614
|
-
return parts.length ? [`${base}.py`,
|
|
88645
|
+
const base = import_node_path17.posix.join(dir2, ...parts);
|
|
88646
|
+
return parts.length ? [`${base}.py`, import_node_path17.posix.join(base, "__init__.py")] : [import_node_path17.posix.join(base, "__init__.py")];
|
|
88615
88647
|
};
|
|
88616
|
-
let dir =
|
|
88648
|
+
let dir = import_node_path17.posix.dirname(fromPath);
|
|
88617
88649
|
if (level) {
|
|
88618
88650
|
for (let k = 1; k < level; k++) {
|
|
88619
88651
|
if (dir === "." || dir === "/") return [];
|
|
88620
|
-
dir =
|
|
88652
|
+
dir = import_node_path17.posix.dirname(dir);
|
|
88621
88653
|
}
|
|
88622
88654
|
return at(dir);
|
|
88623
88655
|
}
|
|
@@ -88626,7 +88658,7 @@ function pythonModuleCandidates(fromPath, spec2) {
|
|
|
88626
88658
|
for (; ; ) {
|
|
88627
88659
|
out.push(...at(dir));
|
|
88628
88660
|
if (dir === "." || dir === "/" || dir === "") break;
|
|
88629
|
-
dir =
|
|
88661
|
+
dir = import_node_path17.posix.dirname(dir);
|
|
88630
88662
|
}
|
|
88631
88663
|
return out;
|
|
88632
88664
|
}
|
|
@@ -88851,11 +88883,11 @@ function pythonDependencies(source, fromPath) {
|
|
|
88851
88883
|
out.push(...pythonMocks(source, fromPath));
|
|
88852
88884
|
return out.filter((c) => c.length > 0);
|
|
88853
88885
|
}
|
|
88854
|
-
var
|
|
88886
|
+
var import_node_path17, PY, IDENT2, EXTERNAL, indentOf, pythonAdapter;
|
|
88855
88887
|
var init_replay_lang_python = __esm({
|
|
88856
88888
|
"src/commands/replay-lang-python.ts"() {
|
|
88857
88889
|
"use strict";
|
|
88858
|
-
|
|
88890
|
+
import_node_path17 = require("node:path");
|
|
88859
88891
|
init_replay_lang_js();
|
|
88860
88892
|
PY = /\.py$/;
|
|
88861
88893
|
IDENT2 = /^[A-Za-z_]\w*$/;
|
|
@@ -89359,6 +89391,7 @@ function visibleAsk(task) {
|
|
|
89359
89391
|
task.card.acceptance,
|
|
89360
89392
|
task.card.area ?? ""
|
|
89361
89393
|
].join("\n");
|
|
89394
|
+
const anchored = (q) => q.trim() ? `${head} ${q}` : "";
|
|
89362
89395
|
let paths;
|
|
89363
89396
|
let queries;
|
|
89364
89397
|
let hints;
|
|
@@ -89372,10 +89405,12 @@ function visibleAsk(task) {
|
|
|
89372
89405
|
].slice(0, MAX_FAILING_PATHS);
|
|
89373
89406
|
const files = [...new Set(paths.map(baseNameOf))];
|
|
89374
89407
|
const errorLine = errorLineOf(failing.output);
|
|
89408
|
+
const titles = failing.tests.slice(0, FAILING_QUERIES).map(titleOfTest);
|
|
89375
89409
|
queries = [
|
|
89376
|
-
|
|
89377
|
-
errorLine ?? "",
|
|
89378
|
-
|
|
89410
|
+
anchored(titles[0] ?? ""),
|
|
89411
|
+
anchored(errorLine ?? ""),
|
|
89412
|
+
...titles.slice(1).map(anchored),
|
|
89413
|
+
anchored(files.slice(0, 6).join(" "))
|
|
89379
89414
|
];
|
|
89380
89415
|
hints = {
|
|
89381
89416
|
failingTests: failing.tests,
|
|
@@ -89390,8 +89425,8 @@ function visibleAsk(task) {
|
|
|
89390
89425
|
const names = iface.flatMap((e) => e.names);
|
|
89391
89426
|
queries = [
|
|
89392
89427
|
head,
|
|
89393
|
-
...(task.kind !== "recovery" ? task.testTitles ?? [] : []).slice(0, TITLE_QUERIES).map(titleOfTest),
|
|
89394
|
-
names.join(" ")
|
|
89428
|
+
...(task.kind !== "recovery" ? task.testTitles ?? [] : []).slice(0, TITLE_QUERIES).map((t) => anchored(titleOfTest(t))),
|
|
89429
|
+
anchored(names.join(" "))
|
|
89395
89430
|
];
|
|
89396
89431
|
hints = { files: paths, names: [...new Set(names)] };
|
|
89397
89432
|
}
|
|
@@ -89554,8 +89589,8 @@ var init_replay_context = __esm({
|
|
|
89554
89589
|
init_replay_diff();
|
|
89555
89590
|
init_replay_scale();
|
|
89556
89591
|
init_replay_spec();
|
|
89557
|
-
CONTEXT_CHECK_VERSION =
|
|
89558
|
-
QUERY_CHARS2 =
|
|
89592
|
+
CONTEXT_CHECK_VERSION = 5;
|
|
89593
|
+
QUERY_CHARS2 = 300;
|
|
89559
89594
|
ERROR_CHARS = 1e3;
|
|
89560
89595
|
MAX_PATHS = 20;
|
|
89561
89596
|
HEAD_CHARS = 120;
|
|
@@ -90384,7 +90419,7 @@ function cleanCheckout(deps, dir, task) {
|
|
|
90384
90419
|
}
|
|
90385
90420
|
async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv = {}) {
|
|
90386
90421
|
const started = deps.now();
|
|
90387
|
-
const dir = (0,
|
|
90422
|
+
const dir = (0, import_node_path18.join)(
|
|
90388
90423
|
deps.workDir(),
|
|
90389
90424
|
`${task.processId.replace(/[^a-zA-Z0-9_-]/g, "")}-${arm}`
|
|
90390
90425
|
);
|
|
@@ -90413,7 +90448,7 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90413
90448
|
`\u2026 ${label}: set up in ${since(at)}${setup.cached ? " (from the setup cache)" : ""}`
|
|
90414
90449
|
);
|
|
90415
90450
|
}
|
|
90416
|
-
const promptFile = (0,
|
|
90451
|
+
const promptFile = (0, import_node_path18.join)(dir, ".haansi-replay", "prompt.md");
|
|
90417
90452
|
let mcpConfigFile = agentEnv.HAANSI_REPLAY_MCP_CONFIG;
|
|
90418
90453
|
if (!mcpConfigFile) {
|
|
90419
90454
|
mcpConfigFile = `${dir}.mcp.json`;
|
|
@@ -90486,11 +90521,11 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90486
90521
|
);
|
|
90487
90522
|
}
|
|
90488
90523
|
const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
|
|
90489
|
-
const own = new Map(files.map((f) => [f, deps.readFile((0,
|
|
90524
|
+
const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path18.join)(dir, f))]));
|
|
90490
90525
|
for (const f of files) {
|
|
90491
90526
|
const content = await deps.showFile(gradeSha, f);
|
|
90492
|
-
if (content === null) deps.removeFile((0,
|
|
90493
|
-
else deps.writeFile((0,
|
|
90527
|
+
if (content === null) deps.removeFile((0, import_node_path18.join)(dir, f));
|
|
90528
|
+
else deps.writeFile((0, import_node_path18.join)(dir, f), content);
|
|
90494
90529
|
}
|
|
90495
90530
|
const testAt = deps.now();
|
|
90496
90531
|
deps.log(`\u2026 ${label}: agent done in ${since(agentAt)}, grading`);
|
|
@@ -90541,8 +90576,8 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90541
90576
|
}
|
|
90542
90577
|
if (test.code === 0 && !guarded) {
|
|
90543
90578
|
for (const [file2, content] of own) {
|
|
90544
|
-
if (content === null) deps.removeFile((0,
|
|
90545
|
-
else deps.writeFile((0,
|
|
90579
|
+
if (content === null) deps.removeFile((0, import_node_path18.join)(dir, file2));
|
|
90580
|
+
else deps.writeFile((0, import_node_path18.join)(dir, file2), content);
|
|
90546
90581
|
}
|
|
90547
90582
|
if (inspect) await inspect(dir);
|
|
90548
90583
|
return {
|
|
@@ -90558,8 +90593,8 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
90558
90593
|
};
|
|
90559
90594
|
}
|
|
90560
90595
|
for (const [file2, content] of own) {
|
|
90561
|
-
if (content === null) deps.removeFile((0,
|
|
90562
|
-
else deps.writeFile((0,
|
|
90596
|
+
if (content === null) deps.removeFile((0, import_node_path18.join)(dir, file2));
|
|
90597
|
+
else deps.writeFile((0, import_node_path18.join)(dir, file2), content);
|
|
90563
90598
|
}
|
|
90564
90599
|
feedback = guarded ? [
|
|
90565
90600
|
GUARD_FEEDBACK,
|
|
@@ -90651,19 +90686,19 @@ function runCommand(file2, args, cwd, env, timeoutMs, stdoutOnly = false) {
|
|
|
90651
90686
|
});
|
|
90652
90687
|
}
|
|
90653
90688
|
function dropLinks(work, path2) {
|
|
90654
|
-
const rel = (0,
|
|
90655
|
-
if (rel === "" || rel.startsWith("..") || (0,
|
|
90689
|
+
const rel = (0, import_node_path18.relative)(work, path2);
|
|
90690
|
+
if (rel === "" || rel.startsWith("..") || (0, import_node_path18.isAbsolute)(rel)) return;
|
|
90656
90691
|
let at = work;
|
|
90657
|
-
for (const part of rel.split(
|
|
90658
|
-
at = (0,
|
|
90692
|
+
for (const part of rel.split(import_node_path18.sep)) {
|
|
90693
|
+
at = (0, import_node_path18.join)(at, part);
|
|
90659
90694
|
let link = false;
|
|
90660
90695
|
try {
|
|
90661
|
-
link = (0,
|
|
90696
|
+
link = (0, import_node_fs14.lstatSync)(at).isSymbolicLink();
|
|
90662
90697
|
} catch {
|
|
90663
90698
|
return;
|
|
90664
90699
|
}
|
|
90665
90700
|
if (link) {
|
|
90666
|
-
(0,
|
|
90701
|
+
(0, import_node_fs14.rmSync)(at, { force: true });
|
|
90667
90702
|
return;
|
|
90668
90703
|
}
|
|
90669
90704
|
}
|
|
@@ -90690,29 +90725,29 @@ function localDeps(work) {
|
|
|
90690
90725
|
// dropLinks: with a container, nothing runs in it while these do.
|
|
90691
90726
|
writeFile: (path2, content) => {
|
|
90692
90727
|
dropLinks(work, path2);
|
|
90693
|
-
(0,
|
|
90694
|
-
const fd2 = (0,
|
|
90728
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path18.dirname)(path2), { recursive: true });
|
|
90729
|
+
const fd2 = (0, import_node_fs14.openSync)(
|
|
90695
90730
|
path2,
|
|
90696
|
-
|
|
90731
|
+
import_node_fs14.constants.O_WRONLY | import_node_fs14.constants.O_CREAT | import_node_fs14.constants.O_TRUNC | import_node_fs14.constants.O_NOFOLLOW
|
|
90697
90732
|
);
|
|
90698
90733
|
try {
|
|
90699
|
-
(0,
|
|
90734
|
+
(0, import_node_fs14.writeFileSync)(fd2, content);
|
|
90700
90735
|
} finally {
|
|
90701
|
-
(0,
|
|
90736
|
+
(0, import_node_fs14.closeSync)(fd2);
|
|
90702
90737
|
}
|
|
90703
90738
|
},
|
|
90704
90739
|
readFile: (path2) => {
|
|
90705
90740
|
dropLinks(work, path2);
|
|
90706
|
-
if (!(0,
|
|
90707
|
-
const fd2 = (0,
|
|
90741
|
+
if (!(0, import_node_fs14.existsSync)(path2)) return null;
|
|
90742
|
+
const fd2 = (0, import_node_fs14.openSync)(path2, import_node_fs14.constants.O_RDONLY | import_node_fs14.constants.O_NOFOLLOW);
|
|
90708
90743
|
try {
|
|
90709
|
-
return (0,
|
|
90744
|
+
return (0, import_node_fs14.readFileSync)(fd2, "utf-8");
|
|
90710
90745
|
} finally {
|
|
90711
|
-
(0,
|
|
90746
|
+
(0, import_node_fs14.closeSync)(fd2);
|
|
90712
90747
|
}
|
|
90713
90748
|
},
|
|
90714
|
-
removeFile: (path2) => (0,
|
|
90715
|
-
removeDir: (path2) => (0,
|
|
90749
|
+
removeFile: (path2) => (0, import_node_fs14.rmSync)(path2, { force: true }),
|
|
90750
|
+
removeDir: (path2) => (0, import_node_fs14.rmSync)(path2, { recursive: true, force: true }),
|
|
90716
90751
|
now: () => Date.now(),
|
|
90717
90752
|
log: (line) => console.log(line)
|
|
90718
90753
|
};
|
|
@@ -90751,7 +90786,7 @@ async function replay(argv) {
|
|
|
90751
90786
|
async function replayStored(options, token2, apiUrl2) {
|
|
90752
90787
|
const { runStoredReplays: runStoredReplays2 } = await Promise.resolve().then(() => (init_replay_tasks(), replay_tasks_exports));
|
|
90753
90788
|
const { cliVersion: cliVersion2 } = await Promise.resolve().then(() => (init_replay_calibrate(), replay_calibrate_exports));
|
|
90754
|
-
const work = (0,
|
|
90789
|
+
const work = (0, import_node_fs14.mkdtempSync)((0, import_node_path18.join)((0, import_node_os11.tmpdir)(), "haansi-replay-"));
|
|
90755
90790
|
let stop = null;
|
|
90756
90791
|
try {
|
|
90757
90792
|
const contained = await withContainer(
|
|
@@ -90832,17 +90867,18 @@ Baseline: ${arm("baseline")} passed \xB7 With Haansi: ${arm("haansi")} passed \x
|
|
|
90832
90867
|
process.exitCode = 1;
|
|
90833
90868
|
} finally {
|
|
90834
90869
|
await stop?.();
|
|
90835
|
-
(
|
|
90870
|
+
removeWorkDir(work);
|
|
90836
90871
|
}
|
|
90837
90872
|
}
|
|
90838
|
-
var import_node_child_process5,
|
|
90873
|
+
var import_node_child_process5, import_node_fs14, import_node_os11, import_node_path18, SHA, ARMS, FEEDBACK_CHARS, FAILURE_LINES2, REPLAY_BRANCH, OUTPUT_HEAD_CHARS, OUTPUT_TAIL_CHARS, USAGE2;
|
|
90839
90874
|
var init_replay = __esm({
|
|
90840
90875
|
"src/commands/replay.ts"() {
|
|
90841
90876
|
"use strict";
|
|
90877
|
+
init_replay_workdir();
|
|
90842
90878
|
import_node_child_process5 = require("node:child_process");
|
|
90843
|
-
|
|
90879
|
+
import_node_fs14 = require("node:fs");
|
|
90844
90880
|
import_node_os11 = require("node:os");
|
|
90845
|
-
|
|
90881
|
+
import_node_path18 = require("node:path");
|
|
90846
90882
|
init_paths();
|
|
90847
90883
|
init_replay_errors();
|
|
90848
90884
|
init_api2();
|