loki-mode 11.151.0 → 11.153.0
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/SKILL.md +2 -2
- package/VERSION +1 -1
- package/dashboard/__init__.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/loki-ts/dist/loki.js +1921 -1919
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +619 -523
- package/packages/control-plane/src/server/repos.ts +8 -0
- package/packages/control-plane/src/server/routes/start.ts +11 -1
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-BmnyVwpM.js → AdminPage-DbZu7ddP.js} +1 -1
- package/web-app/dist/assets/{Avatar-DeNxWgFZ.js → Avatar-DAUwn6hI.js} +1 -1
- package/web-app/dist/assets/{Badge-BEsJV8yb.js → Badge-jfM-X3V8.js} +1 -1
- package/web-app/dist/assets/{Button-B-mL2Qy9.js → Button-DPQtwxuu.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-JPxHIkX7.js → CockpitPage-_R18YJ80.js} +1 -1
- package/web-app/dist/assets/{ComparePage-WUiY03I4.js → ComparePage-B8G0ncAB.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-C7vAiydc.js → ErrorBoundary-BfsmlmUv.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-C3-cBj8e.js → EvidenceReceiptPanel-C2cDyG7P.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-yo7w7mOG.js → GitHubIssuesPanel-m_epB_9T.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-RDyh8wz-.js → GitHubPRsPanel-C3e2E4tR.js} +1 -1
- package/web-app/dist/assets/{HomePage-DUqDf6Kg.js → HomePage-DufEN9yU.js} +2 -2
- package/web-app/dist/assets/{LoginPage-q0Ido8bg.js → LoginPage-B9crVo53.js} +1 -1
- package/web-app/dist/assets/{MagicPage-C76FSJRe.js → MagicPage-D2CxnNve.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-BQpyZimx.js → MetricsPage-CB89RXmW.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-Blt7OSnp.js → NotFoundPage-DsT1R9Nv.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-DfK-FPKE.js → ProjectPage-DUB7qHau.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-fcFia6fE.js → ProjectsPage-BGXk5sdH.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-CJ-OK4Vm.js → SettingsPage-CM-HClE1.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-DdGMO5tx.js → ShowcasePage-bIdIymaJ.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-BZDZOAvO.js → SystemSettingsPage-Cepwl537.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-EcXyjJ17.js → TeamsPage-BxtK3rw2.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-CX1KlPua.js → TemplatesPage-qwpDk5T0.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-SvE_BM6F.js → TerminalOutput-BnM3M3pB.js} +1 -1
- package/web-app/dist/assets/{activity-CfVno3iH.js → activity-CawceXZd.js} +1 -1
- package/web-app/dist/assets/{bell-BrQJaBQs.js → bell-CsKWxejH.js} +1 -1
- package/web-app/dist/assets/{bot-Cagvkdve.js → bot-D3510Z28.js} +1 -1
- package/web-app/dist/assets/{check-DnUFy9mS.js → check-C2LOCCOY.js} +1 -1
- package/web-app/dist/assets/{chevron-left-CLYWbdFg.js → chevron-left-BB9kFeem.js} +1 -1
- package/web-app/dist/assets/{circle-alert-DInpAyw4.js → circle-alert-B2Cp1Ig9.js} +1 -1
- package/web-app/dist/assets/{clock-BX0pMQtn.js → clock-CMyPpDIq.js} +1 -1
- package/web-app/dist/assets/{cloud-GkAlLmBL.js → cloud-PSbWAP8z.js} +1 -1
- package/web-app/dist/assets/{code-xml-nqvWK_pZ.js → code-xml-BrxGLiE7.js} +1 -1
- package/web-app/dist/assets/{database-D740CNgE.js → database-Dvb3EBwQ.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-C3ibTpyr.js → dollar-sign-B04ktJSv.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-ROAJY-pM.js → file-code-corner-CohHD1q-.js} +1 -1
- package/web-app/dist/assets/{file-plus-Dh88QsvN.js → file-plus-CNXxBPL0.js} +1 -1
- package/web-app/dist/assets/{globe-WxIkc9QX.js → globe-VbFCeKXo.js} +1 -1
- package/web-app/dist/assets/{hammer-BMi8Zdle.js → hammer-zDl_5fsf.js} +1 -1
- package/web-app/dist/assets/{index-Bgu5dPGT.js → index-B9FaIM3t.js} +3 -3
- package/web-app/dist/assets/{layers-RR6QbC1B.js → layers-ybdXw7tA.js} +1 -1
- package/web-app/dist/assets/{loader-circle-CG38ZV_7.js → loader-circle-Df0W4piv.js} +1 -1
- package/web-app/dist/assets/{lock-DebNBeeG.js → lock-BwHhoraW.js} +1 -1
- package/web-app/dist/assets/{package-BFdNsrpc.js → package-DvX-5_gZ.js} +1 -1
- package/web-app/dist/assets/{plus-BnMql3IP.js → plus-C8BtEtIx.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-DRwfvmNn.js → refresh-cw-DzlXJr-S.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-DjkMZOkU.js → rotate-ccw-CEzK4HJF.js} +1 -1
- package/web-app/dist/assets/{scroll-text-Dk7rgY03.js → scroll-text-c7tRHJkn.js} +1 -1
- package/web-app/dist/assets/{server-CipsfEoT.js → server-kPzCaOGi.js} +1 -1
- package/web-app/dist/assets/{shield-alert-D0cs4BJP.js → shield-alert-5XEfb5as.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-qEUCiiP5.js → thumbs-up-ZMTB2fvb.js} +1 -1
- package/web-app/dist/assets/{trash-2-jrfGgU4Z.js → trash-2-C_NKhJ52.js} +1 -1
- package/web-app/dist/assets/{trending-down-BtLIqdd5.js → trending-down-B5RqvF8F.js} +1 -1
- package/web-app/dist/assets/{trending-up-DuXwbg1V.js → trending-up-BRi1caL4.js} +1 -1
- package/web-app/dist/assets/{upload-Cxdmxjxq.js → upload-DVYE4Uwe.js} +1 -1
- package/web-app/dist/assets/{usePolling-B1GFLmdm.js → usePolling-CJhQhw27.js} +1 -1
- package/web-app/dist/assets/{user-B7kllKO3.js → user-DbKPy6Y-.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -9824,7 +9824,7 @@ var init_retry_class = __esm(() => {
|
|
|
9824
9824
|
// ../../loki-ts/src/runner/worker_proc.ts
|
|
9825
9825
|
import { spawn as spawn7, spawnSync as spawnSync2 } from "child_process";
|
|
9826
9826
|
import { createInterface } from "readline";
|
|
9827
|
-
import { join as join32, resolve as
|
|
9827
|
+
import { join as join32, resolve as resolve10 } from "path";
|
|
9828
9828
|
import { accessSync, chmodSync as chmodSync4, constants as fsConstants2, existsSync as existsSync17, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, readdirSync as readdirSync14, readFileSync as readFileSync24, readlinkSync, realpathSync as realpathSync14, rmSync as rmSync7, writeFileSync as writeFileSync12 } from "fs";
|
|
9829
9829
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
9830
9830
|
import { tmpdir as tmpdir6 } from "os";
|
|
@@ -9882,7 +9882,7 @@ function pinBashShellEnv(env, canExec = isExecutable) {
|
|
|
9882
9882
|
env["SHELL"] = POSIX_BASH;
|
|
9883
9883
|
}
|
|
9884
9884
|
function envWithPwd(env, cwd) {
|
|
9885
|
-
return cwd === undefined ? env : { ...env, PWD:
|
|
9885
|
+
return cwd === undefined ? env : { ...env, PWD: resolve10(cwd) };
|
|
9886
9886
|
}
|
|
9887
9887
|
function ulimitArgv(argv, env) {
|
|
9888
9888
|
const set = ULIMIT_KNOBS.filter(([name]) => env[name] !== undefined && env[name] !== "");
|
|
@@ -9900,16 +9900,16 @@ function ulimitArgv(argv, env) {
|
|
|
9900
9900
|
return [LIMIT_SHELL, "-c", script, "sh", ...values, ...argv];
|
|
9901
9901
|
}
|
|
9902
9902
|
function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, onStopped = () => {}) {
|
|
9903
|
-
return new Promise((
|
|
9903
|
+
return new Promise((resolve11) => {
|
|
9904
9904
|
if (!argv[0])
|
|
9905
|
-
return
|
|
9905
|
+
return resolve11({ code: null, killed: false });
|
|
9906
9906
|
let wrapped;
|
|
9907
9907
|
try {
|
|
9908
9908
|
wrapped = ulimitArgv(argv, env);
|
|
9909
9909
|
} catch (e) {
|
|
9910
9910
|
process.stderr.write(`${e.message}
|
|
9911
9911
|
`);
|
|
9912
|
-
return
|
|
9912
|
+
return resolve11({ code: ULIMIT_REFUSED_EXIT, killed: false });
|
|
9913
9913
|
}
|
|
9914
9914
|
const [cmd, ...args] = wrapped;
|
|
9915
9915
|
const child = spawn7(cmd, args, { cwd, env: envWithPwd(env, cwd), stdio: ["ignore", "pipe", "inherit"], detached: true });
|
|
@@ -9946,7 +9946,7 @@ function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, onStopped =
|
|
|
9946
9946
|
child.stdout?.destroy();
|
|
9947
9947
|
killGroup2(child.pid, "SIGKILL");
|
|
9948
9948
|
onStopped(cancelled2 !== undefined);
|
|
9949
|
-
|
|
9949
|
+
resolve11({ code, killed, ...cancelled2 ? { cancelled: cancelled2 } : {} });
|
|
9950
9950
|
};
|
|
9951
9951
|
timers.push(setTimeout(() => {
|
|
9952
9952
|
killed = true;
|
|
@@ -10970,7 +10970,7 @@ var init_stack_tools = __esm(() => {
|
|
|
10970
10970
|
|
|
10971
10971
|
// ../../loki-ts/src/util/dotnet_test.ts
|
|
10972
10972
|
import { existsSync as existsSync21, readFileSync as readFileSync29 } from "fs";
|
|
10973
|
-
import { basename as
|
|
10973
|
+
import { basename as basename9, join as join37 } from "path";
|
|
10974
10974
|
function dotnetSummary(text2) {
|
|
10975
10975
|
const ls2 = text2.split(`
|
|
10976
10976
|
`).map((l) => l.trimEnd());
|
|
@@ -11031,7 +11031,7 @@ function dotnetClasses(file) {
|
|
|
11031
11031
|
text2 = readFileSync29(file, "utf8");
|
|
11032
11032
|
} catch {}
|
|
11033
11033
|
const found = [...new Set([...text2.matchAll(/\bclass\s+([A-Za-z_]\w*)/g)].map((m) => m[1]))];
|
|
11034
|
-
return found.length ? found : [
|
|
11034
|
+
return found.length ? found : [basename9(file, ".cs")];
|
|
11035
11035
|
}
|
|
11036
11036
|
function dotnetTestCmd(repoDir, testRel) {
|
|
11037
11037
|
const proj = dotnetProjectOf(repoDir, testRel) ?? dotnetTarget(repoDir), filter = dotnetClasses(join37(repoDir, testRel)).map((c) => `FullyQualifiedName~${c}`).join("|");
|
|
@@ -11066,12 +11066,12 @@ var init_wall_knobs = __esm(() => {
|
|
|
11066
11066
|
// ../../loki-ts/src/util/producer_fingerprint.ts
|
|
11067
11067
|
import { createHash as createHash7 } from "crypto";
|
|
11068
11068
|
import { readdirSync as readdirSync17, readFileSync as readFileSync30 } from "fs";
|
|
11069
|
-
import { relative as relative2, resolve as
|
|
11069
|
+
import { relative as relative2, resolve as resolve11 } from "path";
|
|
11070
11070
|
function sourceFingerprint(root) {
|
|
11071
11071
|
const h = createHash7("sha256");
|
|
11072
11072
|
const walk = (dir) => {
|
|
11073
11073
|
for (const e of readdirSync17(dir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : 1)) {
|
|
11074
|
-
const p =
|
|
11074
|
+
const p = resolve11(dir, e.name);
|
|
11075
11075
|
if (e.isDirectory()) {
|
|
11076
11076
|
if (e.name !== "node_modules")
|
|
11077
11077
|
walk(p);
|
|
@@ -11082,7 +11082,7 @@ function sourceFingerprint(root) {
|
|
|
11082
11082
|
walk(root);
|
|
11083
11083
|
return h.digest("hex");
|
|
11084
11084
|
}
|
|
11085
|
-
function computeProducerFingerprint(root =
|
|
11085
|
+
function computeProducerFingerprint(root = resolve11(import.meta.dir, ".."), injected = globalThis.__LOKI_PRODUCER_FP__) {
|
|
11086
11086
|
if (typeof injected === "string" && /^[0-9a-f]{64}$/.test(injected))
|
|
11087
11087
|
return injected;
|
|
11088
11088
|
try {
|
|
@@ -11099,17 +11099,17 @@ var init_producer_fingerprint = () => {};
|
|
|
11099
11099
|
|
|
11100
11100
|
// ../../loki-ts/src/engine10/cache.ts
|
|
11101
11101
|
import { createHash as createHash8 } from "crypto";
|
|
11102
|
-
import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync14, readdirSync as readdirSync18, readFileSync as readFileSync31, renameSync as renameSync6, statSync as
|
|
11103
|
-
import { basename as
|
|
11102
|
+
import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync14, readdirSync as readdirSync18, readFileSync as readFileSync31, renameSync as renameSync6, statSync as statSync15, unlinkSync as unlinkSync4, writeFileSync as writeFileSync15 } from "fs";
|
|
11103
|
+
import { basename as basename10, resolve as resolve12 } from "path";
|
|
11104
11104
|
function repoKey(originUrl, repoDir) {
|
|
11105
|
-
const basis = originUrl && originUrl.trim() !== "" ? originUrl :
|
|
11105
|
+
const basis = originUrl && originUrl.trim() !== "" ? originUrl : resolve12(repoDir);
|
|
11106
11106
|
return createHash8("sha256").update(basis).digest("hex");
|
|
11107
11107
|
}
|
|
11108
11108
|
function defaultCacheRoot() {
|
|
11109
|
-
return
|
|
11109
|
+
return resolve12(homeLokiDir(), "cache", "v10");
|
|
11110
11110
|
}
|
|
11111
11111
|
function repoCacheDir(key, cacheRoot = defaultCacheRoot()) {
|
|
11112
|
-
return
|
|
11112
|
+
return resolve12(cacheRoot, key);
|
|
11113
11113
|
}
|
|
11114
11114
|
function readJson3(path, isValid = (_v) => true) {
|
|
11115
11115
|
if (!existsSync22(path))
|
|
@@ -11145,15 +11145,15 @@ function writeJson(path, dir, data) {
|
|
|
11145
11145
|
function pruneCache(dir, prefix, keepPath, keep = prefix === "slice-" ? 500 : 5) {
|
|
11146
11146
|
const mt = (f) => {
|
|
11147
11147
|
try {
|
|
11148
|
-
return
|
|
11148
|
+
return statSync15(resolve12(dir, f)).mtimeMs;
|
|
11149
11149
|
} catch {
|
|
11150
11150
|
return 0;
|
|
11151
11151
|
}
|
|
11152
11152
|
};
|
|
11153
11153
|
try {
|
|
11154
|
-
readdirSync18(dir).filter((f) => f.startsWith(prefix) && f.endsWith(".json") && f !==
|
|
11154
|
+
readdirSync18(dir).filter((f) => f.startsWith(prefix) && f.endsWith(".json") && f !== basename10(keepPath)).sort((x, y) => mt(y) - mt(x) || (x < y ? 1 : -1)).slice(keep - 1).forEach((f) => {
|
|
11155
11155
|
try {
|
|
11156
|
-
unlinkSync4(
|
|
11156
|
+
unlinkSync4(resolve12(dir, f));
|
|
11157
11157
|
} catch {}
|
|
11158
11158
|
});
|
|
11159
11159
|
} catch {}
|
|
@@ -11176,10 +11176,10 @@ var tmpSeq = 0, LEGACY_PREFIX, writeAndPrune = (path, dir, prefix, data) => {
|
|
|
11176
11176
|
const old = LEGACY_PREFIX[prefix];
|
|
11177
11177
|
if (old)
|
|
11178
11178
|
pruneCache(dir, old, path, 1);
|
|
11179
|
-
}, cacheFileName = (kind, tree, fp = producerFingerprint()) => `${kind}-${fp.slice(0, 16)}-${tree}.json`, readRepoMapCache = (dir, tree, fp = producerFingerprint()) => readJson3(
|
|
11179
|
+
}, cacheFileName = (kind, tree, fp = producerFingerprint()) => `${kind}-${fp.slice(0, 16)}-${tree}.json`, readRepoMapCache = (dir, tree, fp = producerFingerprint()) => readJson3(resolve12(dir, cacheFileName("repomap", tree, fp)), isRepoMap), writeRepoMapCache = (dir, tree, map, fp = producerFingerprint()) => writeAndPrune(resolve12(dir, cacheFileName("repomap", tree, fp)), dir, "repomap-", map), readTestMapCache = (dir, tree, fp = producerFingerprint()) => readJson3(resolve12(dir, cacheFileName("testmap", tree, fp)), isTestMap), writeTestMapCache = (dir, tree, map, fp = producerFingerprint()) => writeAndPrune(resolve12(dir, cacheFileName("testmap", tree, fp)), dir, "testmap-", map), cacheStats, cachedRepoMap = (dir, tree, build, fp = producerFingerprint()) => viaCache(readRepoMapCache(dir, tree, fp), build, (m) => writeRepoMapCache(dir, tree, m, fp)), sliceKey = (card, baseSha) => createHash8("sha256").update(`${card.length}:${card}\x00${baseSha}`).digest("hex"), isJournalEntry = (v) => {
|
|
11180
11180
|
const e = v;
|
|
11181
11181
|
return typeof e === "object" && e !== null && typeof e.gid === "string" && typeof e.id === "string" && typeof e.head === "string" && Number.isInteger(e.n);
|
|
11182
|
-
}, readSliceJournal = (dir, key) => readJson3(
|
|
11182
|
+
}, readSliceJournal = (dir, key) => readJson3(resolve12(dir, `slice-${key}.json`), isJournalEntry), writeSliceJournal = (dir, key, entry) => writeAndPrune(resolve12(dir, `slice-${key}.json`), dir, "slice-", entry);
|
|
11183
11183
|
var init_cache = __esm(() => {
|
|
11184
11184
|
init_paths();
|
|
11185
11185
|
init_producer_fingerprint();
|
|
@@ -11189,7 +11189,7 @@ var init_cache = __esm(() => {
|
|
|
11189
11189
|
|
|
11190
11190
|
// ../../loki-ts/src/util/lock_ecosystems.ts
|
|
11191
11191
|
import { existsSync as existsSync23, readdirSync as readdirSync19, readFileSync as readFileSync32 } from "fs";
|
|
11192
|
-
import { basename as
|
|
11192
|
+
import { basename as basename11, dirname as dirname11, join as join38 } from "path";
|
|
11193
11193
|
function isYarnBerry(dir) {
|
|
11194
11194
|
if (existsSync23(join38(dir, ".yarnrc.yml")))
|
|
11195
11195
|
return true;
|
|
@@ -11239,7 +11239,7 @@ function declaredPythonDeps(repoDir, manifests) {
|
|
|
11239
11239
|
} catch {
|
|
11240
11240
|
continue;
|
|
11241
11241
|
}
|
|
11242
|
-
const base =
|
|
11242
|
+
const base = basename11(f), lines = t.split(`
|
|
11243
11243
|
`);
|
|
11244
11244
|
if (base.endsWith(".txt")) {
|
|
11245
11245
|
for (const l of lines)
|
|
@@ -11427,7 +11427,7 @@ function exportsDiverge(x) {
|
|
|
11427
11427
|
return "import" in o && "require" in o && JSON.stringify(o["import"]) !== JSON.stringify(o["require"]) || Object.values(o).some(exportsDiverge);
|
|
11428
11428
|
}
|
|
11429
11429
|
function addedManifestOk(f, c, wall, esc, notes) {
|
|
11430
|
-
if (
|
|
11430
|
+
if (basename11(f) !== "package.json" || dirname11(f) === "." || !c.wallPassedN)
|
|
11431
11431
|
return false;
|
|
11432
11432
|
const dir = dirname11(f), g = (a) => {
|
|
11433
11433
|
try {
|
|
@@ -11476,7 +11476,7 @@ function addedManifestOk(f, c, wall, esc, notes) {
|
|
|
11476
11476
|
if (all === null)
|
|
11477
11477
|
return false;
|
|
11478
11478
|
const baseManifests = all.split(`
|
|
11479
|
-
`).filter((p) =>
|
|
11479
|
+
`).filter((p) => basename11(p) === "package.json" && !p.split("/").includes("node_modules"));
|
|
11480
11480
|
if (baseManifests.length > MAX_BASE_MANIFESTS)
|
|
11481
11481
|
return false;
|
|
11482
11482
|
const baseNames = new Set, baseDeps = new Set;
|
|
@@ -11951,9 +11951,9 @@ var init_runner_boot = __esm(() => {
|
|
|
11951
11951
|
});
|
|
11952
11952
|
|
|
11953
11953
|
// ../../loki-ts/src/util/test_file_text.ts
|
|
11954
|
-
import { basename as
|
|
11954
|
+
import { basename as basename12, dirname as dirname12 } from "path";
|
|
11955
11955
|
function isTestFile(rel) {
|
|
11956
|
-
const name =
|
|
11956
|
+
const name = basename12(rel);
|
|
11957
11957
|
return JS_TEST_RE.test(name) || PY_TEST_RE.test(name) || GO_TEST_RE.test(name) || RS_TEST_RE.test(rel) || SH_TEST_RE.test(rel) || /^test[-_].+\.(sh|bash)$/.test(name) || JAVA_TEST_RE.test(rel) || CS_TEST_RE.test(rel);
|
|
11958
11958
|
}
|
|
11959
11959
|
function detectFromPackageJson(text3, rel, mark) {
|
|
@@ -12007,7 +12007,7 @@ function referencedBasenames(text3) {
|
|
|
12007
12007
|
return out2;
|
|
12008
12008
|
}
|
|
12009
12009
|
function coveredStem(testPath) {
|
|
12010
|
-
const name =
|
|
12010
|
+
const name = basename12(testPath);
|
|
12011
12011
|
if (JS_TEST_RE.test(name))
|
|
12012
12012
|
return name.replace(JS_TEST_RE, "");
|
|
12013
12013
|
if (/\.(?:java|cs)$/.test(name))
|
|
@@ -12017,7 +12017,7 @@ function coveredStem(testPath) {
|
|
|
12017
12017
|
return name.replace(/_test\.(py|go)$/, "");
|
|
12018
12018
|
}
|
|
12019
12019
|
function scopeRunnersByPackage(files, evidence, jsText, api, order2, read, marks) {
|
|
12020
|
-
const roots = [...new Set([".", ...api?.packages().map((p) => p.root) ?? [], ...files.filter((f) =>
|
|
12020
|
+
const roots = [...new Set([".", ...api?.packages().map((p) => p.root) ?? [], ...files.filter((f) => basename12(f) === "package.json").map((f) => dirname12(f))])];
|
|
12021
12021
|
const ownerRoot = (file) => api?.packageRootOf(file) ?? roots.filter((p) => p === "." || file.startsWith(`${p}/`)).sort((a, b) => b.length - a.length)[0] ?? ".";
|
|
12022
12022
|
const packageRunners = new Map;
|
|
12023
12023
|
for (const pkgRoot of roots) {
|
|
@@ -12098,7 +12098,7 @@ var init_test_file_text = __esm(() => {
|
|
|
12098
12098
|
});
|
|
12099
12099
|
|
|
12100
12100
|
// ../../loki-ts/src/util/context_pack.ts
|
|
12101
|
-
import { closeSync as closeSync8, openSync as openSync8, readdirSync as readdirSync20, readFileSync as readFileSync34, readSync as readSync7, statSync as
|
|
12101
|
+
import { closeSync as closeSync8, openSync as openSync8, readdirSync as readdirSync20, readFileSync as readFileSync34, readSync as readSync7, statSync as statSync16 } from "fs";
|
|
12102
12102
|
import { join as join41 } from "path";
|
|
12103
12103
|
function langOf(path) {
|
|
12104
12104
|
if (/\.[cm]?[jt]sx?$/.test(path))
|
|
@@ -13174,10 +13174,10 @@ __export(exports_claude_model, {
|
|
|
13174
13174
|
DEFAULT_SESSION_MODEL: () => DEFAULT_SESSION_MODEL
|
|
13175
13175
|
});
|
|
13176
13176
|
import { readFileSync as readFileSync35 } from "fs";
|
|
13177
|
-
import { resolve as
|
|
13177
|
+
import { resolve as resolve13 } from "path";
|
|
13178
13178
|
function resolveClaudeModel(want) {
|
|
13179
13179
|
try {
|
|
13180
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
13180
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve13(REPO_ROOT, "providers/model_catalog.json");
|
|
13181
13181
|
return JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
13182
13182
|
} catch {
|
|
13183
13183
|
return want;
|
|
@@ -13188,7 +13188,7 @@ function isUnresolvedClaudeAlias(model) {
|
|
|
13188
13188
|
}
|
|
13189
13189
|
function claudeTierRank(model) {
|
|
13190
13190
|
try {
|
|
13191
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
13191
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve13(REPO_ROOT, "providers/model_catalog.json");
|
|
13192
13192
|
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13193
13193
|
if (!Array.isArray(models))
|
|
13194
13194
|
return null;
|
|
@@ -13206,7 +13206,7 @@ function claudeTierRank(model) {
|
|
|
13206
13206
|
}
|
|
13207
13207
|
function claudeEffortLevels(model) {
|
|
13208
13208
|
try {
|
|
13209
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
13209
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve13(REPO_ROOT, "providers/model_catalog.json");
|
|
13210
13210
|
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13211
13211
|
if (!Array.isArray(models))
|
|
13212
13212
|
return null;
|
|
@@ -13219,7 +13219,7 @@ function claudeEffortLevels(model) {
|
|
|
13219
13219
|
}
|
|
13220
13220
|
function claudeThinkingSpec(model) {
|
|
13221
13221
|
try {
|
|
13222
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
13222
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve13(REPO_ROOT, "providers/model_catalog.json");
|
|
13223
13223
|
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13224
13224
|
if (!Array.isArray(models))
|
|
13225
13225
|
return null;
|
|
@@ -13540,7 +13540,7 @@ var init_watchdog = __esm(() => {
|
|
|
13540
13540
|
|
|
13541
13541
|
// ../../loki-ts/src/util/anti_loop.ts
|
|
13542
13542
|
import { createHash as createHash9 } from "crypto";
|
|
13543
|
-
import { readFileSync as readFileSync36, statSync as
|
|
13543
|
+
import { readFileSync as readFileSync36, statSync as statSync17 } from "fs";
|
|
13544
13544
|
import { join as join43 } from "path";
|
|
13545
13545
|
function treeFingerprint(repoDir, baseSha) {
|
|
13546
13546
|
try {
|
|
@@ -13550,7 +13550,7 @@ function treeFingerprint(repoDir, baseSha) {
|
|
|
13550
13550
|
for (const f of fresh) {
|
|
13551
13551
|
h.update(`\x00${f}\x00`);
|
|
13552
13552
|
const path = join43(repoDir, f);
|
|
13553
|
-
if (
|
|
13553
|
+
if (statSync17(path).size > MAX_BUFFER)
|
|
13554
13554
|
return null;
|
|
13555
13555
|
h.update(readFileSync36(path));
|
|
13556
13556
|
}
|
|
@@ -13592,7 +13592,7 @@ function diffSignature(cwd, stat, untrackedRaw = untrackedList(cwd)) {
|
|
|
13592
13592
|
if (n3++ >= 1000)
|
|
13593
13593
|
return;
|
|
13594
13594
|
try {
|
|
13595
|
-
const st =
|
|
13595
|
+
const st = statSync17(join43(dir, f));
|
|
13596
13596
|
bytes += st.size;
|
|
13597
13597
|
if (st.mtimeMs > newest)
|
|
13598
13598
|
newest = st.mtimeMs;
|
|
@@ -13614,7 +13614,7 @@ var init_anti_loop = __esm(() => {
|
|
|
13614
13614
|
|
|
13615
13615
|
// ../../loki-ts/src/runner/session_resume.ts
|
|
13616
13616
|
import { existsSync as existsSync24, mkdirSync as mkdirSync15, readdirSync as readdirSync21, readFileSync as readFileSync37, renameSync as renameSync7, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "fs";
|
|
13617
|
-
import { basename as
|
|
13617
|
+
import { basename as basename13, dirname as dirname13, join as join44 } from "path";
|
|
13618
13618
|
function readFirstTurnTokens(repoDir, iterationId) {
|
|
13619
13619
|
try {
|
|
13620
13620
|
const v = JSON.parse(readFileSync37(join44(repoDir, ".loki", "metrics", `result-cost-${iterationId}.json`), "utf8")).first_turn_prompt_tokens;
|
|
@@ -13660,7 +13660,7 @@ function migrateSessionFiles(repoDir, isLive = () => false) {
|
|
|
13660
13660
|
}
|
|
13661
13661
|
for (const name of names) {
|
|
13662
13662
|
const iter = name.slice("e10-session-".length, -".json".length), from = legacySessionPath(repoDir, iter), dest = sessionFilePath(repoDir, iter), destDir = dirname13(dest);
|
|
13663
|
-
if (
|
|
13663
|
+
if (basename13(dirname13(destDir)) === "runs" && isLive(destDir))
|
|
13664
13664
|
continue;
|
|
13665
13665
|
try {
|
|
13666
13666
|
mkdirSync15(destDir, { recursive: true });
|
|
@@ -13795,7 +13795,7 @@ var init_session_resume = __esm(() => {
|
|
|
13795
13795
|
});
|
|
13796
13796
|
|
|
13797
13797
|
// ../../loki-ts/src/project_model/schema.ts
|
|
13798
|
-
import { existsSync as existsSync25, lstatSync as lstatSync8, realpathSync as realpathSync15, statSync as
|
|
13798
|
+
import { existsSync as existsSync25, lstatSync as lstatSync8, realpathSync as realpathSync15, statSync as statSync18 } from "fs";
|
|
13799
13799
|
import { isAbsolute, join as join45, normalize, sep as sep10 } from "path";
|
|
13800
13800
|
function safeRel(p) {
|
|
13801
13801
|
const n3 = normalize(p.trim()).split(sep10).join("/").replace(/\/$/, "");
|
|
@@ -13819,7 +13819,7 @@ function checkCitation(repoDir, raw2) {
|
|
|
13819
13819
|
if (rel === null)
|
|
13820
13820
|
return `citation "${raw2}" is not a repo-relative path`;
|
|
13821
13821
|
const abs = join45(repoDir, rel);
|
|
13822
|
-
if (!existsSync25(abs) || !
|
|
13822
|
+
if (!existsSync25(abs) || !statSync18(abs).isFile() || !insideRepo(repoDir, rel))
|
|
13823
13823
|
return `citation "${raw2}" names a file that does not exist`;
|
|
13824
13824
|
return null;
|
|
13825
13825
|
}
|
|
@@ -13859,7 +13859,7 @@ function checkDir(repoDir, v, where, errs) {
|
|
|
13859
13859
|
return ".";
|
|
13860
13860
|
}
|
|
13861
13861
|
const abs = join45(repoDir, rel);
|
|
13862
|
-
if (!existsSync25(abs) || !
|
|
13862
|
+
if (!existsSync25(abs) || !statSync18(abs).isDirectory() || !insideRepo(repoDir, rel))
|
|
13863
13863
|
errs.push(`${where}: directory "${rel}" does not exist`);
|
|
13864
13864
|
return rel;
|
|
13865
13865
|
}
|
|
@@ -13988,10 +13988,10 @@ __export(exports_receipt_signer, {
|
|
|
13988
13988
|
DEPLOY_SCHEMA: () => DEPLOY_SCHEMA
|
|
13989
13989
|
});
|
|
13990
13990
|
import { createHash as createHash10, randomBytes as randomBytes4, createPrivateKey, createPublicKey as createPublicKey2, generateKeyPairSync, sign, verify as verify2 } from "crypto";
|
|
13991
|
-
import { chmodSync as chmodSync6, linkSync, mkdirSync as mkdirSync16, readdirSync as readdirSync22, readFileSync as readFileSync38, renameSync as renameSync8, statSync as
|
|
13991
|
+
import { chmodSync as chmodSync6, linkSync, mkdirSync as mkdirSync16, readdirSync as readdirSync22, readFileSync as readFileSync38, renameSync as renameSync8, statSync as statSync19, unlinkSync as unlinkSync5, writeFileSync as writeFileSync17 } from "fs";
|
|
13992
13992
|
import { homedir as homedir10 } from "os";
|
|
13993
13993
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
13994
|
-
import { basename as
|
|
13994
|
+
import { basename as basename14, dirname as dirname14, join as join46 } from "path";
|
|
13995
13995
|
function jsonTooDeep(v) {
|
|
13996
13996
|
const stack = [[v, 1]];
|
|
13997
13997
|
while (stack.length > 0) {
|
|
@@ -14036,7 +14036,7 @@ function loadSigningKey(generate = true) {
|
|
|
14036
14036
|
pem = readFileSync38(file);
|
|
14037
14037
|
if (!given) {
|
|
14038
14038
|
for (const [f, m] of [[file, 384], [dirname14(file), 448]])
|
|
14039
|
-
if (
|
|
14039
|
+
if (statSync19(f).mode & 63)
|
|
14040
14040
|
chmodSync6(f, m);
|
|
14041
14041
|
}
|
|
14042
14042
|
} catch (e) {
|
|
@@ -14046,7 +14046,7 @@ function loadSigningKey(generate = true) {
|
|
|
14046
14046
|
return null;
|
|
14047
14047
|
mkdirSync16(dirname14(dirname14(file)), { recursive: true, mode: 448 });
|
|
14048
14048
|
mkdirSync16(dirname14(file), { recursive: true, mode: 448 });
|
|
14049
|
-
sweepStaleTmp(dirname14(file), new RegExp(`${escapeRegex(
|
|
14049
|
+
sweepStaleTmp(dirname14(file), new RegExp(`${escapeRegex(basename14(file))}\\.[0-9a-f]{12}\\.tmp`));
|
|
14050
14050
|
const tmp = `${file}.${randomBytes4(6).toString("hex")}.tmp`;
|
|
14051
14051
|
writeFileSync17(tmp, generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" }), { flag: "wx", mode: 384 });
|
|
14052
14052
|
try {
|
|
@@ -14374,7 +14374,7 @@ async function deployAttestCmd(args, env) {
|
|
|
14374
14374
|
return null;
|
|
14375
14375
|
let rec;
|
|
14376
14376
|
try {
|
|
14377
|
-
if (
|
|
14377
|
+
if (statSync19(file).size > 1e6)
|
|
14378
14378
|
return null;
|
|
14379
14379
|
rec = JSON.parse(readFileSync38(file, "utf8"));
|
|
14380
14380
|
} catch {
|
|
@@ -14448,7 +14448,7 @@ var init_receipt_signer = __esm(() => {
|
|
|
14448
14448
|
|
|
14449
14449
|
// ../../loki-ts/src/runner/router/history_store.ts
|
|
14450
14450
|
import { existsSync as existsSync26, mkdirSync as mkdirSync17, readFileSync as readFileSync39, renameSync as renameSync9, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "fs";
|
|
14451
|
-
import { resolve as
|
|
14451
|
+
import { resolve as resolve14 } from "path";
|
|
14452
14452
|
function validRun(v) {
|
|
14453
14453
|
if (typeof v !== "object" || v === null)
|
|
14454
14454
|
return false;
|
|
@@ -14456,7 +14456,7 @@ function validRun(v) {
|
|
|
14456
14456
|
return typeof r["shape"] === "string" && typeof r["executor"] === "string" && EXECUTORS2.includes(r["executor"]) && typeof r["verdict"] === "string" && VERDICTS.includes(r["verdict"]) && (r["owner"] === null || typeof r["owner"] === "string" && OWNERS.includes(r["owner"])) && typeof r["escalated"] === "boolean" && typeof r["usd"] === "number" && Number.isFinite(r["usd"]) && typeof r["wallS"] === "number" && Number.isFinite(r["wallS"]);
|
|
14457
14457
|
}
|
|
14458
14458
|
function historyPath(key, cacheRoot) {
|
|
14459
|
-
return
|
|
14459
|
+
return resolve14(repoCacheDir(key, cacheRoot), HISTORY_FILE);
|
|
14460
14460
|
}
|
|
14461
14461
|
function readRunHistory(key, cacheRoot) {
|
|
14462
14462
|
const path = historyPath(key, cacheRoot);
|
|
@@ -14731,7 +14731,7 @@ var init_engine_origin = __esm(() => {
|
|
|
14731
14731
|
|
|
14732
14732
|
// ../../loki-ts/src/runner/router/history.ts
|
|
14733
14733
|
import { existsSync as existsSync28, readFileSync as readFileSync42 } from "fs";
|
|
14734
|
-
import { dirname as dirname16, join as join49, resolve as
|
|
14734
|
+
import { dirname as dirname16, join as join49, resolve as resolve15 } from "path";
|
|
14735
14735
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
14736
14736
|
function shapeKey(model) {
|
|
14737
14737
|
if (!model || model.status !== "ok")
|
|
@@ -14821,7 +14821,7 @@ var init_history = __esm(() => {
|
|
|
14821
14821
|
init_cache();
|
|
14822
14822
|
init_engine_origin();
|
|
14823
14823
|
init_history_store();
|
|
14824
|
-
SHAPE_DEFAULTS_FILE =
|
|
14824
|
+
SHAPE_DEFAULTS_FILE = resolve15(dirname16(fileURLToPath2(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
|
|
14825
14825
|
});
|
|
14826
14826
|
|
|
14827
14827
|
// ../../loki-ts/src/runner/router/unit_model.ts
|
|
@@ -14941,7 +14941,7 @@ var init_session_route = __esm(() => {
|
|
|
14941
14941
|
});
|
|
14942
14942
|
|
|
14943
14943
|
// ../../loki-ts/src/providers/mcp_config.ts
|
|
14944
|
-
import { existsSync as existsSync29, readFileSync as readFileSync44, mkdirSync as mkdirSync18, statSync as
|
|
14944
|
+
import { existsSync as existsSync29, readFileSync as readFileSync44, mkdirSync as mkdirSync18, statSync as statSync20, renameSync as renameSync10 } from "fs";
|
|
14945
14945
|
import { resolve as resolvePath, join as join50, delimiter as delimiter3 } from "path";
|
|
14946
14946
|
function detectLsp() {
|
|
14947
14947
|
const pathEnv = process.env["PATH"] ?? "";
|
|
@@ -14952,7 +14952,7 @@ function detectLsp() {
|
|
|
14952
14952
|
for (const dir of dirs) {
|
|
14953
14953
|
const candidate = join50(dir, bin);
|
|
14954
14954
|
try {
|
|
14955
|
-
const s =
|
|
14955
|
+
const s = statSync20(candidate);
|
|
14956
14956
|
if (s.isFile())
|
|
14957
14957
|
return true;
|
|
14958
14958
|
} catch {}
|
|
@@ -15011,7 +15011,7 @@ function userMcpConfigPath() {
|
|
|
15011
15011
|
if (!existsSync29(p))
|
|
15012
15012
|
return null;
|
|
15013
15013
|
try {
|
|
15014
|
-
const s =
|
|
15014
|
+
const s = statSync20(p);
|
|
15015
15015
|
if (!s.isFile())
|
|
15016
15016
|
return null;
|
|
15017
15017
|
if (s.size > 1024 * 1024) {
|
|
@@ -16797,7 +16797,7 @@ import {
|
|
|
16797
16797
|
readFileSync as readFileSync49,
|
|
16798
16798
|
readdirSync as readdirSync23,
|
|
16799
16799
|
renameSync as renameSync12,
|
|
16800
|
-
statSync as
|
|
16800
|
+
statSync as statSync21,
|
|
16801
16801
|
unlinkSync as unlinkSync6,
|
|
16802
16802
|
writeFileSync as writeFileSync22
|
|
16803
16803
|
} from "fs";
|
|
@@ -16965,7 +16965,7 @@ __export(exports_repo_profile, {
|
|
|
16965
16965
|
import { createHash as createHash14 } from "crypto";
|
|
16966
16966
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
16967
16967
|
import { existsSync as existsSync35, lstatSync as lstatSync12, readFileSync as readFileSync50, mkdirSync as mkdirSync22, readdirSync as readdirSync24, realpathSync as realpathSync16, renameSync as renameSync13, rmSync as rmSync11, writeFileSync as writeFileSync23 } from "fs";
|
|
16968
|
-
import { basename as
|
|
16968
|
+
import { basename as basename15, dirname as dirname19, join as join57, relative as relative3, resolve as resolve16, isAbsolute as isAbsolute2 } from "path";
|
|
16969
16969
|
function num5(env, name, fallback) {
|
|
16970
16970
|
const raw2 = env[name];
|
|
16971
16971
|
if (raw2 === undefined || raw2 === "")
|
|
@@ -16979,15 +16979,15 @@ function profileEnabled(env = process.env) {
|
|
|
16979
16979
|
function redactEvidence(path, repoRoot) {
|
|
16980
16980
|
if (!isAbsolute2(path))
|
|
16981
16981
|
return path;
|
|
16982
|
-
const root =
|
|
16983
|
-
const abs =
|
|
16982
|
+
const root = resolve16(repoRoot);
|
|
16983
|
+
const abs = resolve16(path);
|
|
16984
16984
|
if (abs.startsWith(root + "/"))
|
|
16985
16985
|
return abs.slice(root.length + 1);
|
|
16986
|
-
return
|
|
16986
|
+
return basename15(abs);
|
|
16987
16987
|
}
|
|
16988
16988
|
function extractFacts(repoRoot) {
|
|
16989
16989
|
const facts = [];
|
|
16990
|
-
const pkgPath =
|
|
16990
|
+
const pkgPath = resolve16(repoRoot, "package.json");
|
|
16991
16991
|
if (existsSync35(pkgPath)) {
|
|
16992
16992
|
try {
|
|
16993
16993
|
const pkg = JSON.parse(readFileSync50(pkgPath, "utf8"));
|
|
@@ -17007,31 +17007,31 @@ function extractFacts(repoRoot) {
|
|
|
17007
17007
|
["go.mod", "language", "go"],
|
|
17008
17008
|
["Makefile", "build.system", "make"]
|
|
17009
17009
|
]) {
|
|
17010
|
-
if (existsSync35(
|
|
17010
|
+
if (existsSync35(resolve16(repoRoot, rel))) {
|
|
17011
17011
|
facts.push({ key, value, evidence: rel });
|
|
17012
17012
|
}
|
|
17013
17013
|
}
|
|
17014
17014
|
return facts;
|
|
17015
17015
|
}
|
|
17016
17016
|
function profilePath(lokiDirOverride) {
|
|
17017
|
-
return
|
|
17017
|
+
return resolve16(lokiDirOverride ?? lokiDir(), "profile", "repo-profile.json");
|
|
17018
17018
|
}
|
|
17019
17019
|
function buildProfile(opts, cacheKey = null) {
|
|
17020
|
-
const root =
|
|
17020
|
+
const root = resolve16(opts.repoRoot);
|
|
17021
17021
|
const facts = extractFacts(root).map((f) => ({
|
|
17022
17022
|
...f,
|
|
17023
17023
|
evidence: redactEvidence(f.evidence, root)
|
|
17024
17024
|
}));
|
|
17025
17025
|
const profile = {
|
|
17026
17026
|
schema_version: PROFILE_SCHEMA_VERSION,
|
|
17027
|
-
namespace:
|
|
17027
|
+
namespace: basename15(root),
|
|
17028
17028
|
content_hash: manifestHash(root),
|
|
17029
17029
|
generated_at: (opts.now ?? new Date).toISOString().replace(/\.\d{3}Z$/, "Z"),
|
|
17030
17030
|
...cacheKey !== null ? { cache_key: cacheKey } : {},
|
|
17031
17031
|
facts
|
|
17032
17032
|
};
|
|
17033
17033
|
const target = profilePath(opts.lokiDirOverride);
|
|
17034
|
-
mkdirSync22(
|
|
17034
|
+
mkdirSync22(resolve16(target, ".."), { recursive: true });
|
|
17035
17035
|
atomicWriteFileSync(target, JSON.stringify(profile, null, 2) + `
|
|
17036
17036
|
`);
|
|
17037
17037
|
return profile;
|
|
@@ -17048,7 +17048,7 @@ function repoCacheKey(root) {
|
|
|
17048
17048
|
}
|
|
17049
17049
|
}
|
|
17050
17050
|
function buildProfileCached(opts) {
|
|
17051
|
-
const key = repoCacheKey(
|
|
17051
|
+
const key = repoCacheKey(resolve16(opts.repoRoot));
|
|
17052
17052
|
if (key !== null) {
|
|
17053
17053
|
const r = readProfile(opts);
|
|
17054
17054
|
if (r.status === "fresh" && r.profile && r.profile.cache_key === key)
|
|
@@ -17058,7 +17058,7 @@ function buildProfileCached(opts) {
|
|
|
17058
17058
|
}
|
|
17059
17059
|
function readProfile(opts) {
|
|
17060
17060
|
const env = opts.env ?? process.env;
|
|
17061
|
-
const root =
|
|
17061
|
+
const root = resolve16(opts.repoRoot);
|
|
17062
17062
|
const target = profilePath(opts.lokiDirOverride);
|
|
17063
17063
|
if (!existsSync35(target))
|
|
17064
17064
|
return { status: "absent", profile: null };
|
|
@@ -17235,7 +17235,7 @@ function manifestModel(repoDir) {
|
|
|
17235
17235
|
}
|
|
17236
17236
|
})();
|
|
17237
17237
|
const wsPats = [...pkgWorkspaces(repoDir), ...pnpmWorkspaces(repoDir)];
|
|
17238
|
-
const manifestDirs = [...new Set(tracked.filter((p) => PKG_MANIFESTS.includes(
|
|
17238
|
+
const manifestDirs = [...new Set(tracked.filter((p) => PKG_MANIFESTS.includes(basename15(p))).map((p) => dirname19(p)))];
|
|
17239
17239
|
const trackedDirs = new Set;
|
|
17240
17240
|
for (const p of tracked)
|
|
17241
17241
|
for (let d = dirname19(p);d !== "." && !trackedDirs.has(d); d = dirname19(d))
|
|
@@ -17271,7 +17271,7 @@ function manifestModel(repoDir) {
|
|
|
17271
17271
|
const boot = uiDep && typeof scripts["dev"] === "string" ? { cmd: `${pm} run dev`, cwd: d, cite: [at(d, "package.json")] } : uiDep && typeof scripts["start"] === "string" ? { cmd: `${pm} start`, cwd: d, cite: [at(d, "package.json")] } : null;
|
|
17272
17272
|
const js = d === "." || isMember ? pj ? { dependsOn: [...new Set(deps.map((x) => nameToRoot.get(x)).filter((r) => r !== undefined && r !== d))] } : {} : {};
|
|
17273
17273
|
return {
|
|
17274
|
-
name: typeof pj?.["name"] === "string" && pj["name"] ? pj["name"] : d === "." ?
|
|
17274
|
+
name: typeof pj?.["name"] === "string" && pj["name"] ? pj["name"] : d === "." ? basename15(resolve16(repoDir)) : d,
|
|
17275
17275
|
root: d,
|
|
17276
17276
|
runner: null,
|
|
17277
17277
|
cite: own.length ? own : [cmds[0] ? at(d, cmds[0].source) : at(d, "package.json")],
|
|
@@ -17552,7 +17552,7 @@ function attribute(repoDir, baseSha, failing) {
|
|
|
17552
17552
|
const s = name ? p.suites?.find((x) => x.name === name && x.ran && x.attributable) : undefined;
|
|
17553
17553
|
return s ? s.failing_ids : root;
|
|
17554
17554
|
};
|
|
17555
|
-
const rows = failing.map((f) => ({ ...f, base: new Set(own(f.suite)) })), known = new Set(rows.flatMap((r) => [...r.base]));
|
|
17555
|
+
const byId = baseRedByIdOn(), rows = failing.map((f) => ({ ...f, base: new Set(own(f.rerun === "same" || byId && f.rerun !== "differs" ? f.suite : undefined)) })), known = new Set(rows.flatMap((r) => [...r.base]));
|
|
17556
17556
|
if (known.size === 0)
|
|
17557
17557
|
return none;
|
|
17558
17558
|
return split(rows, known.size);
|
|
@@ -18034,7 +18034,7 @@ var init_runner_errors = __esm(() => {
|
|
|
18034
18034
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
18035
18035
|
import { mkdtempSync as mkdtempSync6, realpathSync as realpathSync17, rmSync as rmSync12 } from "fs";
|
|
18036
18036
|
import { tmpdir as tmpdir9 } from "os";
|
|
18037
|
-
import { basename as
|
|
18037
|
+
import { basename as basename16, extname as extname2, join as join58 } from "path";
|
|
18038
18038
|
function changedFilesNamed(out2, repoDir, changed) {
|
|
18039
18039
|
return changed.filter((f) => {
|
|
18040
18040
|
if (out2.includes(f) || out2.includes(join58(repoDir, f)))
|
|
@@ -18044,7 +18044,7 @@ function changedFilesNamed(out2, repoDir, changed) {
|
|
|
18044
18044
|
return true;
|
|
18045
18045
|
if (extname2(f) === ".go" && segs.length > 1 && suffixes(segs.slice(0, -1), 1).some((d) => new RegExp(`(?<=[\\w-])/${escapeRegex(d)}(?![\\w./-])`).test(out2)))
|
|
18046
18046
|
return true;
|
|
18047
|
-
const stem =
|
|
18047
|
+
const stem = basename16(f, extname2(f));
|
|
18048
18048
|
if (stem.length < 2 || stem === "index" || stem === "__init__")
|
|
18049
18049
|
return false;
|
|
18050
18050
|
return new RegExp(`(?<![\\w-])${escapeRegex(stem)}(?![\\w-])`).test(out2);
|
|
@@ -18493,12 +18493,12 @@ async function groupGone(pid) {
|
|
|
18493
18493
|
await new Promise((r) => setTimeout(r, 50));
|
|
18494
18494
|
}
|
|
18495
18495
|
function runDetached(cmd, cwd, env, signal, timeoutMs) {
|
|
18496
|
-
return new Promise((
|
|
18496
|
+
return new Promise((resolve17) => {
|
|
18497
18497
|
let child;
|
|
18498
18498
|
try {
|
|
18499
18499
|
child = spawn8("bash", ["-c", cmd], { cwd, env, detached: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
18500
18500
|
} catch (e) {
|
|
18501
|
-
|
|
18501
|
+
resolve17({ code: null, cut: null, err: String(e), tail: "" });
|
|
18502
18502
|
return;
|
|
18503
18503
|
}
|
|
18504
18504
|
const pid = child.pid;
|
|
@@ -18525,7 +18525,7 @@ function runDetached(cmd, cwd, env, signal, timeoutMs) {
|
|
|
18525
18525
|
await groupGone(pid);
|
|
18526
18526
|
child.stdout?.destroy();
|
|
18527
18527
|
child.stderr?.destroy();
|
|
18528
|
-
|
|
18528
|
+
resolve17({ ...r, tail: tail2 });
|
|
18529
18529
|
};
|
|
18530
18530
|
const onAbort = () => {
|
|
18531
18531
|
cut = "abort";
|
|
@@ -18874,7 +18874,7 @@ var init_install = __esm(() => {
|
|
|
18874
18874
|
|
|
18875
18875
|
// ../../loki-ts/src/e10ext/commit_filter.ts
|
|
18876
18876
|
import { existsSync as existsSync38, lstatSync as lstatSync14, mkdirSync as mkdirSync23, readFileSync as readFileSync53, rmSync as rmSync13, writeFileSync as writeFileSync24 } from "fs";
|
|
18877
|
-
import { basename as
|
|
18877
|
+
import { basename as basename17, dirname as dirname21, join as join61 } from "path";
|
|
18878
18878
|
function dropSet(repoDir, staged, preexistingDirty, env = process.env, installCreated, untrackedBlobs, baseSha, task) {
|
|
18879
18879
|
const owned = installOwned(repoDir, installCreated, env), made = installCreated?.files ?? {}, tc = toolchainOutputs(repoDir, staged.filter(({ st }) => st === "A").map(({ f }) => f), baseSha);
|
|
18880
18880
|
const art = buildArtifactDropEnabled(env) ? buildArtifacts(repoDir, staged.filter(({ st }) => st === "A").map(({ f }) => f), baseSha, task) : new Set;
|
|
@@ -18898,7 +18898,7 @@ function buildArtifacts(repoDir, added, baseSha, task = "") {
|
|
|
18898
18898
|
const out2 = new Set;
|
|
18899
18899
|
if (added.length === 0)
|
|
18900
18900
|
return out2;
|
|
18901
|
-
const named = (f) => task.includes(f) || new RegExp(`(?<![\\w./-])${escapeRegex(
|
|
18901
|
+
const named = (f) => task.includes(f) || new RegExp(`(?<![\\w./-])${escapeRegex(basename17(f))}(?![\\w-])`).test(task);
|
|
18902
18902
|
let ignored = new Set;
|
|
18903
18903
|
try {
|
|
18904
18904
|
const r = safeGitSpawn(repoDir, ["check-ignore", "--no-index", "--stdin", "-z"], { input: added.join("\x00") + "\x00", encoding: "utf8", timeout: 20000 });
|
|
@@ -18931,7 +18931,7 @@ function buildArtifacts(repoDir, added, baseSha, task = "") {
|
|
|
18931
18931
|
return out2;
|
|
18932
18932
|
}
|
|
18933
18933
|
function runOutputs(repoDir, added, baseSha, task = "") {
|
|
18934
|
-
const out2 = new Set, named = (f) => task.includes(f) || new RegExp(`(?<![\\w./-])${escapeRegex(
|
|
18934
|
+
const out2 = new Set, named = (f) => task.includes(f) || new RegExp(`(?<![\\w./-])${escapeRegex(basename17(f))}(?![\\w-])`).test(task);
|
|
18935
18935
|
const tracked = new Map, dirTracked = (d) => {
|
|
18936
18936
|
if (!tracked.has(d)) {
|
|
18937
18937
|
try {
|
|
@@ -19053,7 +19053,7 @@ function needDrops(staged, task, read2, scopeOutside, env = process.env) {
|
|
|
19053
19053
|
const asksFormat = /\b(?:format(?:ting|ter)?|re-?format|prettier|black|ruff format|gofmt|rustfmt|whitespace|indent(?:ation)?)\b/i.test(task), asksLint = /\b(?:lint(?:er|ing)?|noqa|eslint|suppress(?:ion)?|warnings?|type:\s*ignore|ts-ignore)\b/i.test(task);
|
|
19054
19054
|
const out2 = [];
|
|
19055
19055
|
for (const { st, f } of staged) {
|
|
19056
|
-
if (st !== "M" || f.startsWith(".loki/") || task.includes(f) || task.includes(
|
|
19056
|
+
if (st !== "M" || f.startsWith(".loki/") || task.includes(f) || task.includes(basename17(f)))
|
|
19057
19057
|
continue;
|
|
19058
19058
|
const { base, head } = read2(f);
|
|
19059
19059
|
if (base === null || head === null)
|
|
@@ -19147,13 +19147,13 @@ function commitUnsealedWork(intact, repoDir, workerEnv, runId, intake) {
|
|
|
19147
19147
|
var WALL_FILE, parseStaged = (out2) => out2.split("\x00").reduce((a, t, i, all) => i % 2 === 0 && t ? [...a, { st: t, f: all[i + 1] }] : a, []), MANIFEST, manifestChanged = (staged, lock) => {
|
|
19148
19148
|
const d = dirname21(lock);
|
|
19149
19149
|
return staged.some(({ f: m }) => MANIFEST.test(m) && (d === "." || dirname21(m) === d || dirname21(m).startsWith(`${d}/`)));
|
|
19150
|
-
}, taskWantsLockChange = (task, lock) => !!task && (task.includes(lock) || task.includes(
|
|
19150
|
+
}, taskWantsLockChange = (task, lock) => !!task && (task.includes(lock) || task.includes(basename17(lock)) || /\bCVE-\d{4}-\d+/i.test(task) || /\b(?:update|upgrade|bump)\b[^.\n]{0,60}\b(?:dependenc\w*|packages?|lockfile|lock file|version)\b/i.test(task) || /\b(?:refresh|regenerate|re-generate|sync|rebuild)\b[^.\n]{0,40}\b(?:lockfile|lock file|lock-file)\b/i.test(task) || /\b(?:bump|upgrade)\s+[@\w./-]+\s+(?:to|from)\s+v?\d/i.test(task) || /\bpin\s+[@\w./-]+\s+(?:to|at)\s+v?\d/i.test(task) || /\b(?:lock-?file|lock file)\s+(?:merge\s+)?conflicts?\b/i.test(task) || /\bconflicts?\b[^.\n]{0,20}\b(?:in|on|of)\s+(?:the\s+)?(?:lock-?file|lock file)(?![\w-])/i.test(task) || /\bre-?install\b[^.\n]{0,30}\b(?:fix|repair)\b[^.\n]{0,30}\b(?:lock-?file|lock file)(?![\w-])/i.test(task) || /\b(?:fix|repair)\s+(?:the\s+|our\s+)?(?:lock-?file|lock file)(?![\w-])/i.test(task)), buildArtifactDropEnabled = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BUILD_ARTIFACT_DROP"] ?? "").trim()), BYTECODE, CACHE_DIR, OUT_DIR, PKG_MANIFEST, runOutputDropEnabled = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_RUN_OUTPUT_DROP"] ?? "").trim()), RUN_DIR, RUN_FILE, regenDropOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_REGEN_DROP"] ?? "").trim()), REGEN_FILE = "regenerated.json", regeneratedPaths = (runDir) => {
|
|
19151
19151
|
try {
|
|
19152
19152
|
return JSON.parse(readFileSync53(join61(runDir, REGEN_FILE), "utf8")).paths ?? [];
|
|
19153
19153
|
} catch {
|
|
19154
19154
|
return [];
|
|
19155
19155
|
}
|
|
19156
|
-
}, taskNamesPath = (task, f) => task.includes(f) || task.includes(
|
|
19156
|
+
}, taskNamesPath = (task, f) => task.includes(f) || task.includes(basename17(f)), regenDropNote = (f) => `rewritten only by Loki's own check run, not by the change, and left out of the commit: ${f}`, regenKeptNote = (f) => `rewritten by Loki's own check run and kept: a targeted test fails without it: ${f}`, diffNeedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DIFF_NEED"] ?? "").trim()), WS_SIGNIFICANT, SUPPRESS, suppressionOnly = (base, head) => base !== head && base.replace(SUPPRESS, "").replace(/[ \t]+$/gm, "").replace(/\n{2,}/g, `
|
|
19157
19157
|
`) === head.replace(SUPPRESS, "").replace(/[ \t]+$/gm, "").replace(/\n{2,}/g, `
|
|
19158
19158
|
`), needDropNote = (d) => `${d.why} left out of the delivered diff: ${d.f}`, buildArtifactNotes = (repoDir, droppedAdded, baseSha, task) => {
|
|
19159
19159
|
const s = new Set([...buildArtifactDropEnabled() ? buildArtifacts(repoDir, droppedAdded, baseSha, task) : [], ...runOutputDropEnabled() ? runOutputs(repoDir, droppedAdded, baseSha, task) : []]);
|
|
@@ -19180,11 +19180,11 @@ var init_commit_filter = __esm(() => {
|
|
|
19180
19180
|
});
|
|
19181
19181
|
|
|
19182
19182
|
// ../../loki-ts/src/util/config_paths.ts
|
|
19183
|
-
import { basename as
|
|
19183
|
+
import { basename as basename18 } from "path";
|
|
19184
19184
|
function taskNamesFenced(task, rel) {
|
|
19185
19185
|
if (!task)
|
|
19186
19186
|
return false;
|
|
19187
|
-
const t = task.toLowerCase(), bn =
|
|
19187
|
+
const t = task.toLowerCase(), bn = basename18(rel).toLowerCase(), stem = bn.replace(/\.[^.]*$/, "").replace(/^\./, "");
|
|
19188
19188
|
if (LOCKFILE_RE.test(rel))
|
|
19189
19189
|
return taskWantsLockChange(task, rel) || DEP_TASK.test(task);
|
|
19190
19190
|
if (CONCEPTS.some(([c, w]) => c.test(rel) && w.test(task)))
|
|
@@ -19208,8 +19208,8 @@ var init_config_paths = __esm(() => {
|
|
|
19208
19208
|
});
|
|
19209
19209
|
|
|
19210
19210
|
// ../../loki-ts/src/util/config_fence.ts
|
|
19211
|
-
import { appendFileSync as appendFileSync5, existsSync as existsSync39, mkdirSync as mkdirSync24, readdirSync as readdirSync26, readFileSync as readFileSync54, rmSync as rmSync14, statSync as
|
|
19212
|
-
import { dirname as dirname22, isAbsolute as isAbsolute5, join as join62, relative as relative6, resolve as
|
|
19211
|
+
import { appendFileSync as appendFileSync5, existsSync as existsSync39, mkdirSync as mkdirSync24, readdirSync as readdirSync26, readFileSync as readFileSync54, rmSync as rmSync14, statSync as statSync22, writeFileSync as writeFileSync25 } from "fs";
|
|
19212
|
+
import { dirname as dirname22, isAbsolute as isAbsolute5, join as join62, relative as relative6, resolve as resolve17 } from "path";
|
|
19213
19213
|
function fenceTask(env = process.env, runDir) {
|
|
19214
19214
|
if (env["LOKI_E10_TASK_TEXT"])
|
|
19215
19215
|
return env["LOKI_E10_TASK_TEXT"].slice(0, FENCE_TASK_MAX);
|
|
@@ -19236,8 +19236,8 @@ function harnessOutputs(cwd, env = process.env) {
|
|
|
19236
19236
|
}
|
|
19237
19237
|
if (!Array.isArray(a))
|
|
19238
19238
|
return [];
|
|
19239
|
-
const root =
|
|
19240
|
-
return [...new Set(a.filter((p) => typeof p === "string" && isAbsolute5(p)).map((p) =>
|
|
19239
|
+
const root = resolve17(cwd, ".loki");
|
|
19240
|
+
return [...new Set(a.filter((p) => typeof p === "string" && isAbsolute5(p)).map((p) => resolve17(p)).filter((p) => {
|
|
19241
19241
|
const r = relative6(root, p);
|
|
19242
19242
|
return r !== "" && !r.startsWith("..") && !isAbsolute5(r) && !RUN_RECORD.test(r);
|
|
19243
19243
|
}))];
|
|
@@ -19245,14 +19245,14 @@ function harnessOutputs(cwd, env = process.env) {
|
|
|
19245
19245
|
function fenceDenied(tool, file, cwd, allow, state = false, onNewTestFile, outputs = []) {
|
|
19246
19246
|
if (!/^(Edit|Write|MultiEdit)$/.test(tool) || typeof file !== "string" || !file)
|
|
19247
19247
|
return null;
|
|
19248
|
-
const abs =
|
|
19248
|
+
const abs = resolve17(cwd, file), rel = relative6(resolve17(cwd), abs);
|
|
19249
19249
|
if (state && /^\.loki(\/|$)/.test(rel) && outputs.includes(abs))
|
|
19250
19250
|
return null;
|
|
19251
19251
|
if (state && /^\.loki(\/|$)/.test(rel))
|
|
19252
19252
|
return { rel, reason: `LOKI_RUN_STATE: ${rel} is the harness's own run state (the receipt and checkpoints are built from it), so the edit was denied. Nothing in the task needs it.` };
|
|
19253
19253
|
if (rel === "" || rel.startsWith("..") || isAbsolute5(rel) || !isFencedPath(rel) || allow(rel))
|
|
19254
19254
|
return null;
|
|
19255
|
-
if (TEST_DIR.test(rel) && !existsSync39(
|
|
19255
|
+
if (TEST_DIR.test(rel) && !existsSync39(resolve17(cwd, rel))) {
|
|
19256
19256
|
onNewTestFile?.(rel);
|
|
19257
19257
|
return null;
|
|
19258
19258
|
}
|
|
@@ -19376,7 +19376,7 @@ function fenceNotes(r, provenPass = false) {
|
|
|
19376
19376
|
};
|
|
19377
19377
|
}
|
|
19378
19378
|
function stateDenyRules(cwd, outputs = []) {
|
|
19379
|
-
const root =
|
|
19379
|
+
const root = resolve17(cwd, ".loki");
|
|
19380
19380
|
if (outputs.length === 0)
|
|
19381
19381
|
return [`Edit(/${root}/**)`];
|
|
19382
19382
|
const keep = new Set(outputs), chain = new Set([root]), rules = new Set;
|
|
@@ -19412,7 +19412,7 @@ function fencedDenyRules(cwd, env = process.env) {
|
|
|
19412
19412
|
} catch {}
|
|
19413
19413
|
const allow = allowFor(env["LOKI_E10_FENCE_TASK"] ?? fenceTask(env), allowed);
|
|
19414
19414
|
try {
|
|
19415
|
-
return scan(cwd).filter((rel) => isFencedPath(rel) && !allow(rel)).map((rel) => `Edit(/${
|
|
19415
|
+
return scan(cwd).filter((rel) => isFencedPath(rel) && !allow(rel)).map((rel) => `Edit(/${resolve17(cwd, rel)})`);
|
|
19416
19416
|
} catch {
|
|
19417
19417
|
return [];
|
|
19418
19418
|
}
|
|
@@ -19423,7 +19423,7 @@ var MAX_BYTES2, LIST_BUFFER, LIST_TIMEOUT_MS = 60000, FENCE_TASK_MAX = 8000, FEN
|
|
|
19423
19423
|
return (rel) => a.has(rel) || taskNamesFenced(task, rel);
|
|
19424
19424
|
}, HARNESS_OUTPUTS_ENV = "LOKI_E10_WRITE_OUTPUTS", RUN_RECORD, scan = (cwd) => safeGit(cwd, ["ls-files", "-z", "-c", "-o", "--exclude-standard"], { maxBuffer: LIST_BUFFER, timeout: LIST_TIMEOUT_MS }).split("\x00").filter((f) => f && !/(^|\/)node_modules\//.test(f)), readSmall = (p) => {
|
|
19425
19425
|
try {
|
|
19426
|
-
return
|
|
19426
|
+
return statSync22(p).size <= MAX_BYTES2 ? readFileSync54(p) : null;
|
|
19427
19427
|
} catch {
|
|
19428
19428
|
return null;
|
|
19429
19429
|
}
|
|
@@ -19471,7 +19471,7 @@ var init_config_fence = __esm(() => {
|
|
|
19471
19471
|
|
|
19472
19472
|
// ../../loki-ts/src/runner/host_guard.ts
|
|
19473
19473
|
import { appendFileSync as appendFileSync6, mkdirSync as mkdirSync25, realpathSync as realpathSync19 } from "fs";
|
|
19474
|
-
import { isAbsolute as isAbsolute6, join as join63, resolve as
|
|
19474
|
+
import { isAbsolute as isAbsolute6, join as join63, resolve as resolve18, sep as sep11 } from "path";
|
|
19475
19475
|
function hookTimeoutSeconds(env = process.env) {
|
|
19476
19476
|
const raw2 = env["LOKI_HOOK_TIMEOUT"] ?? "";
|
|
19477
19477
|
return /^[1-9][0-9]{0,4}$/.test(raw2) ? Number(raw2) : HOOK_TIMEOUT_DEFAULT_S;
|
|
@@ -19662,7 +19662,7 @@ var init_host_guard = __esm(() => {
|
|
|
19662
19662
|
init_worker_proc();
|
|
19663
19663
|
init_claude_flags();
|
|
19664
19664
|
init_config_fence();
|
|
19665
|
-
HOST_GUARD_SCRIPT =
|
|
19665
|
+
HOST_GUARD_SCRIPT = resolve18(REPO_ROOT, "autonomy", "hooks", "validate-bash.sh");
|
|
19666
19666
|
ALLOW = { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "allow" } };
|
|
19667
19667
|
PY_BLANK = new RegExp(`^${PY_SPACE}*$`);
|
|
19668
19668
|
CONTINUATION = /(?<!\\)((?:\\\\)*)\\\r?\n/g;
|
|
@@ -19774,7 +19774,7 @@ var init_scope = __esm(() => {
|
|
|
19774
19774
|
});
|
|
19775
19775
|
|
|
19776
19776
|
// ../../loki-ts/src/util/python.ts
|
|
19777
|
-
import { accessSync as accessSync2, constants, existsSync as existsSync40, mkdtempSync as mkdtempSync7, readFileSync as readFileSync55, realpathSync as realpathSync20, rmSync as rmSync15, statSync as
|
|
19777
|
+
import { accessSync as accessSync2, constants, existsSync as existsSync40, mkdtempSync as mkdtempSync7, readFileSync as readFileSync55, realpathSync as realpathSync20, rmSync as rmSync15, statSync as statSync23 } from "fs";
|
|
19778
19778
|
import { isAbsolute as isAbsolute7, join as join64, relative as relative7 } from "path";
|
|
19779
19779
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
19780
19780
|
import { tmpdir as tmpdir10 } from "os";
|
|
@@ -19813,7 +19813,7 @@ function resolvePython3() {
|
|
|
19813
19813
|
const cand = `${dir}/python3`;
|
|
19814
19814
|
try {
|
|
19815
19815
|
accessSync2(cand, constants.X_OK);
|
|
19816
|
-
if (
|
|
19816
|
+
if (statSync23(cand).isFile())
|
|
19817
19817
|
return cand;
|
|
19818
19818
|
} catch {}
|
|
19819
19819
|
}
|
|
@@ -20214,7 +20214,7 @@ __export(exports_testmap, {
|
|
|
20214
20214
|
});
|
|
20215
20215
|
import { existsSync as existsSync41, lstatSync as lstatSync15, readdirSync as readdirSync27, readFileSync as readFileSync56 } from "fs";
|
|
20216
20216
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
20217
|
-
import { basename as
|
|
20217
|
+
import { basename as basename19, dirname as dirname23, extname as extname3, join as join65, sep as sep12 } from "path";
|
|
20218
20218
|
function untestableReason(runners, files, env = process.env, root) {
|
|
20219
20219
|
if (root && repoTestCommand(root) || harnessRunners(runners, files, env, root).length > 0)
|
|
20220
20220
|
return null;
|
|
@@ -20244,7 +20244,7 @@ function buildTestMap(root) {
|
|
|
20244
20244
|
const api = loadProjectApi(root);
|
|
20245
20245
|
let pyCfg = false;
|
|
20246
20246
|
for (const rel of files) {
|
|
20247
|
-
const name =
|
|
20247
|
+
const name = basename19(rel);
|
|
20248
20248
|
const full = join65(root, rel);
|
|
20249
20249
|
if (JS_TEST_RE.test(name)) {
|
|
20250
20250
|
const text3 = readText(full);
|
|
@@ -20297,7 +20297,7 @@ function buildTestMap(root) {
|
|
|
20297
20297
|
const tests = [];
|
|
20298
20298
|
const testPackages = Object.create(null);
|
|
20299
20299
|
for (const rel of files) {
|
|
20300
|
-
const name =
|
|
20300
|
+
const name = basename19(rel), pkgRoot = ownerRoot(rel);
|
|
20301
20301
|
const scope = packageRunners.get(pkgRoot) ?? packageRunners.get(".") ?? [];
|
|
20302
20302
|
let jr;
|
|
20303
20303
|
const jsRunner = JS_TEST_RE.test(name) ? importedRunners(jsText.get(rel) ?? "")[0] ?? ["vitest", "jest", "bun", "node"].find((r) => scope.includes(r)) : undefined;
|
|
@@ -20319,7 +20319,7 @@ function buildTestMap(root) {
|
|
|
20319
20319
|
}
|
|
20320
20320
|
}
|
|
20321
20321
|
const sourceRefs = Object.create(null);
|
|
20322
|
-
const goMods = files.filter((f) =>
|
|
20322
|
+
const goMods = files.filter((f) => basename19(f) === "go.mod").map((f) => ({ dir: dirname23(f), path: /^module\s+(\S+)/m.exec(readText(join65(root, f)))?.[1] })).filter((m) => !!m.path).sort((a, b) => b.path.length - a.path.length);
|
|
20323
20323
|
const goImportDir = (imp) => {
|
|
20324
20324
|
const m = goMods.find((x) => imp === x.path || imp.startsWith(`${x.path}/`));
|
|
20325
20325
|
if (!m)
|
|
@@ -20371,11 +20371,11 @@ function impactedRefs(map, changedFiles) {
|
|
|
20371
20371
|
add3(self2);
|
|
20372
20372
|
continue;
|
|
20373
20373
|
}
|
|
20374
|
-
const stem =
|
|
20374
|
+
const stem = basename19(rel, extname3(rel));
|
|
20375
20375
|
const stems = [stem];
|
|
20376
20376
|
const entry2 = stem === "index" || stem === "__init__" || stem === "mod" && extname3(rel) === ".rs";
|
|
20377
20377
|
if (entry2 && dirname23(rel) !== ".")
|
|
20378
|
-
stems.push(
|
|
20378
|
+
stems.push(basename19(dirname23(rel)));
|
|
20379
20379
|
for (const s of stems)
|
|
20380
20380
|
for (const p of sourceRefs[s] ?? [])
|
|
20381
20381
|
add3(map.tests.find((t) => t.path === p));
|
|
@@ -20424,7 +20424,7 @@ function avaTargets(root, changed, env = process.env) {
|
|
|
20424
20424
|
if (!existsSync41(join65(root, dir, "package.json")) || !avaDeclared(join65(root, dir)))
|
|
20425
20425
|
continue;
|
|
20426
20426
|
const inPkg = dir === "." ? rel : rel.slice(dir.length + 1), at = (p) => dir === "." ? p : `${dir}/${p}`;
|
|
20427
|
-
const stem =
|
|
20427
|
+
const stem = basename19(inPkg).replace(/\.[^.]+$/, "").replace(/\.(?:test|spec)$/, "");
|
|
20428
20428
|
const cands = AVA_TEST_DIRS.includes(inPkg.split("/")[0]) ? [inPkg] : AVA_TEST_DIRS.flatMap((d) => AVA_EXT.map((e) => `${d}/${stem}${e}`));
|
|
20429
20429
|
for (const c of cands)
|
|
20430
20430
|
if (isFile(join65(root, at(c))) && !out2.includes(at(c)))
|
|
@@ -20517,7 +20517,7 @@ import {
|
|
|
20517
20517
|
unlinkSync as unlinkSync7,
|
|
20518
20518
|
writeFileSync as writeFileSync26
|
|
20519
20519
|
} from "fs";
|
|
20520
|
-
import { dirname as dirname24, isAbsolute as isAbsolute8, join as join66, relative as relative9, resolve as
|
|
20520
|
+
import { dirname as dirname24, isAbsolute as isAbsolute8, join as join66, relative as relative9, resolve as resolve19, sep as sep13 } from "path";
|
|
20521
20521
|
function git2(root, args) {
|
|
20522
20522
|
return safeGit(root, args);
|
|
20523
20523
|
}
|
|
@@ -20551,7 +20551,7 @@ function safeJoin(root, relPath) {
|
|
|
20551
20551
|
const segments = relPath.split("/").filter((s) => s.length > 0);
|
|
20552
20552
|
if (relPath.startsWith("/") || segments.includes("..") || segments.includes(".") || segments.length === 0)
|
|
20553
20553
|
throw new TreeSwapUnsafePathError(`unsafe path ${relPath}`);
|
|
20554
|
-
const rootAbs =
|
|
20554
|
+
const rootAbs = resolve19(root);
|
|
20555
20555
|
let cur = rootAbs;
|
|
20556
20556
|
for (let i = 0;i < segments.length; i++) {
|
|
20557
20557
|
const segment = segments[i];
|
|
@@ -20574,8 +20574,8 @@ function safeJoin(root, relPath) {
|
|
|
20574
20574
|
function assertSymlinkWithinRoot(root, relPath, target) {
|
|
20575
20575
|
if (isAbsolute8(target))
|
|
20576
20576
|
throw new TreeSwapUnsafePathError(`symlink ${relPath} has an absolute target`);
|
|
20577
|
-
const resolvedTarget =
|
|
20578
|
-
const rel = relative9(
|
|
20577
|
+
const resolvedTarget = resolve19(dirname24(join66(resolve19(root), relPath)), target);
|
|
20578
|
+
const rel = relative9(resolve19(root), resolvedTarget);
|
|
20579
20579
|
if (rel === ".." || rel.startsWith(`..${"/"}`) || isAbsolute8(rel)) {
|
|
20580
20580
|
throw new TreeSwapUnsafePathError(`symlink ${relPath} escapes tree root`);
|
|
20581
20581
|
}
|
|
@@ -20690,7 +20690,7 @@ function trackedChanges(root, excludes) {
|
|
|
20690
20690
|
return out2;
|
|
20691
20691
|
}
|
|
20692
20692
|
function gitPath(root, name) {
|
|
20693
|
-
return
|
|
20693
|
+
return resolve19(root, git2(root, ["rev-parse", "--git-path", name]).trim());
|
|
20694
20694
|
}
|
|
20695
20695
|
function swapAttemptIntoWorkingTree(opts) {
|
|
20696
20696
|
const excludes = opts.excludes ?? DEFAULT_EXCLUDES;
|
|
@@ -20812,9 +20812,9 @@ import { execFileSync as execFileSync5 } from "child_process";
|
|
|
20812
20812
|
import { mkdtempSync as mkdtempSync8, readFileSync as readFileSync58, rmSync as rmSync17 } from "fs";
|
|
20813
20813
|
import { tmpdir as tmpdir11 } from "os";
|
|
20814
20814
|
import { join as join67 } from "path";
|
|
20815
|
-
import { basename as
|
|
20815
|
+
import { basename as basename20 } from "path";
|
|
20816
20816
|
function classifyAssertDelta(inp) {
|
|
20817
|
-
const f =
|
|
20817
|
+
const f = basename20(inp.path);
|
|
20818
20818
|
if (!/^(test_.*|.*_test)\.py$/.test(f))
|
|
20819
20819
|
return WEAKENED;
|
|
20820
20820
|
if (inp.headCounts.run !== inp.baseCounts.run || inp.headCounts.skipped !== inp.baseCounts.skipped)
|
|
@@ -21081,7 +21081,8 @@ out("value-change" if ok and items else "weakened", items if ok else [])
|
|
|
21081
21081
|
import { readFileSync as readFileSync59 } from "fs";
|
|
21082
21082
|
import { join as join68 } from "path";
|
|
21083
21083
|
function weakensTest(baseText, newText) {
|
|
21084
|
-
|
|
21084
|
+
const moreCases = count2(CASE_RE, newText) > count2(CASE_RE, baseText);
|
|
21085
|
+
return count2(ASSERT_RE, newText) < count2(ASSERT_RE, baseText) || count2(CASE_RE, newText) < count2(CASE_RE, baseText) || count2(SKIP_RE, newText) > count2(SKIP_RE, baseText) || count2(SETUP_RE, newText) > count2(SETUP_RE, baseText) || !moreCases && count2(LOCAL_SETUP_RE, newText) > count2(LOCAL_SETUP_RE, baseText);
|
|
21085
21086
|
}
|
|
21086
21087
|
function testFileWeakened(repoDir, baseSha, headSha, rel, status, task = "") {
|
|
21087
21088
|
if (status === "D" || status === "T")
|
|
@@ -21191,6 +21192,32 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
|
|
|
21191
21192
|
const stem = p.replace(/\.(?:js|mjs|cjs|jsx)$/, "");
|
|
21192
21193
|
return [...new Set([p, ...["ts", "tsx", "js", "mjs", "cjs", "jsx", "mts", "cts"].map((x) => `${stem}.${x}`), ...["ts", "tsx", "js"].map((x) => `${stem}/index.${x}`)])];
|
|
21193
21194
|
};
|
|
21195
|
+
let addedImports = null;
|
|
21196
|
+
const newlyImported = (spec) => {
|
|
21197
|
+
if (/^(0|off|false|no)$/i.test((process.env["LOKI_E10_WEAK_MOCK_PKG"] ?? "").trim()) || spec.startsWith(".") || spec.startsWith("/"))
|
|
21198
|
+
return false;
|
|
21199
|
+
if (addedImports === null) {
|
|
21200
|
+
try {
|
|
21201
|
+
let file = "";
|
|
21202
|
+
const keep = [];
|
|
21203
|
+
for (const l of safeGit(repoDir, ["diff", "-U0", baseSha, ...headSha ? [headSha] : []]).split(`
|
|
21204
|
+
`)) {
|
|
21205
|
+
if (l.startsWith("+++ "))
|
|
21206
|
+
file = l.slice(6);
|
|
21207
|
+
else if (l.startsWith("-") && !l.startsWith("---") && file && !isTestFile(file))
|
|
21208
|
+
keep.push(`gone ${l.slice(1)}`);
|
|
21209
|
+
else if (l.startsWith("+") && !l.startsWith("+++") && file && !isTestFile(file))
|
|
21210
|
+
keep.push(`new ${l.slice(1)}`);
|
|
21211
|
+
}
|
|
21212
|
+
addedImports = keep.join(`
|
|
21213
|
+
`);
|
|
21214
|
+
} catch {
|
|
21215
|
+
addedImports = "";
|
|
21216
|
+
}
|
|
21217
|
+
}
|
|
21218
|
+
const q = spec.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), imp = (kind) => new RegExp(`^${kind} .*(?:\\bfrom\\s*|\\brequire\\(\\s*|\\bimport\\s*\\(?\\s*)['"]${q}['"]`, "m");
|
|
21219
|
+
return imp("new").test(addedImports) && !imp("gone").test(addedImports);
|
|
21220
|
+
};
|
|
21194
21221
|
let excused = 0;
|
|
21195
21222
|
for (const n3 of added) {
|
|
21196
21223
|
const line2 = hl[n3 - 1] ?? "";
|
|
@@ -21220,6 +21247,10 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
|
|
|
21220
21247
|
excused += hits;
|
|
21221
21248
|
continue;
|
|
21222
21249
|
}
|
|
21250
|
+
if (allAdded && newlyImported(spec)) {
|
|
21251
|
+
excused += hits;
|
|
21252
|
+
continue;
|
|
21253
|
+
}
|
|
21223
21254
|
return null;
|
|
21224
21255
|
}
|
|
21225
21256
|
if (HOOK_RE.test(line2)) {
|
|
@@ -21242,7 +21273,7 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
|
|
|
21242
21273
|
}
|
|
21243
21274
|
if (count2(SETUP_RE, head) - excused > count2(SETUP_RE, base))
|
|
21244
21275
|
return null;
|
|
21245
|
-
why.push("added setup only in describe blocks the change added, or mocks of modules new in the change");
|
|
21276
|
+
why.push("added setup only in describe blocks the change added, or mocks of modules new in the change or of a package its source starts importing");
|
|
21246
21277
|
}
|
|
21247
21278
|
return why.join("; ") || null;
|
|
21248
21279
|
}
|
|
@@ -21345,7 +21376,7 @@ function pinnedTestUpdates(repoDir, baseSha, reply, task) {
|
|
|
21345
21376
|
}
|
|
21346
21377
|
return out2.slice(0, 12);
|
|
21347
21378
|
}
|
|
21348
|
-
var ASSERT_RE, CASE_RE, SKIP_RE, SETUP_RE, count2 = (re, text3) => (text3.match(re) ?? []).length, weakenExcuseOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_WEAK_EXCUSE"] ?? "").trim()), weakMockNewOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_WEAK_MOCK_NEW"] ?? "").trim()), UPDATE_ASK_RE, CASE_START_RE, ANY_CASE_RE, HOOK_RE, MOCK_RE, OBSERVABILITY_RE, STUB_FACTORY_RE, normalizeRel2 = (p) => {
|
|
21379
|
+
var ASSERT_RE, CASE_RE, SKIP_RE, SETUP_RE, LOCAL_SETUP_RE, count2 = (re, text3) => (text3.match(re) ?? []).length, weakenExcuseOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_WEAK_EXCUSE"] ?? "").trim()), weakMockNewOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_WEAK_MOCK_NEW"] ?? "").trim()), UPDATE_ASK_RE, CASE_START_RE, ANY_CASE_RE, HOOK_RE, MOCK_RE, OBSERVABILITY_RE, STUB_FACTORY_RE, normalizeRel2 = (p) => {
|
|
21349
21380
|
const out2 = [];
|
|
21350
21381
|
for (const s of p.split("/")) {
|
|
21351
21382
|
if (s === "" || s === ".")
|
|
@@ -21366,7 +21397,8 @@ var init_test_guard = __esm(() => {
|
|
|
21366
21397
|
ASSERT_RE = /\b(?:expect|assert\w*|should|XCTAssert\w*|require\.\w+|self\.assert\w*|Assert\.\w+|t\.(?:is|not|equal|deepEqual|true|false|truthy|falsy|throws|ok|notOk|match|snapshot))\s*[(.]|^\s*assert\s/gm;
|
|
21367
21398
|
CASE_RE = /\b(?:it|test|describe|context)\s*(?:\.each\b[^(]*)?\(|\bdef\s+test_\w+|@Test\b|\[(?:Fact|Theory|Test|TestMethod)\]|\bfunc\s+Test\w+/g;
|
|
21368
21399
|
SKIP_RE = /\.(?:skip|only|todo|fails)\s*\(|\b(?:xit|xdescribe|xtest|fit|fdescribe)\s*\(|@pytest\.mark\.(?:skip|skipif|xfail)\b|@(?:Disabled|Ignore)\b|\bt\.Skip\w*\(|\bpytest\.skip\(|\[Ignore\]/g;
|
|
21369
|
-
SETUP_RE = /\b(?:beforeEach|afterEach|beforeAll|afterAll|vi\.(?:mock|doMock
|
|
21400
|
+
SETUP_RE = /\b(?:beforeEach|afterEach|beforeAll|afterAll|vi\.(?:mock|doMock)|jest\.(?:mock|doMock)|mock\.module|setUp|tearDown|setup_method|teardown_method|autouse)\b|@pytest\.fixture\b|@(?:Before|After)(?:Each|All|Class)?\b|\[(?:SetUp|TearDown|OneTimeSetUp)\]/g;
|
|
21401
|
+
LOCAL_SETUP_RE = /\b(?:vi\.(?:spyOn|stubGlobal|stubEnv)|jest\.spyOn|monkeypatch)\b/g;
|
|
21370
21402
|
UPDATE_ASK_RE = /\btests?\b(?:(?!\.\s)[^\n]){0,200}?\b(?:is|are|be|gets?|must be|should be)\s+(?:updated|changed|rewritten|replaced)\b|\b(?:update|change|rewrite|replace)\s+(?:the\s+|this\s+|that\s+|its\s+)?(?:existing\s+)?(?:test|assertion|expectation)s?\b/i;
|
|
21371
21403
|
CASE_START_RE = /^\s*(?:it|test)(?:\.\w+)?\s*\(\s*(['"`])((?:\\.|(?!\1).)*)\1/;
|
|
21372
21404
|
ANY_CASE_RE = /^\s*(?:it|test|describe|context)(?:\.\w+)?\s*\(/;
|
|
@@ -21431,7 +21463,7 @@ function resizeCap(runDir, api, subscription, fixedS) {
|
|
|
21431
21463
|
if (fixedS && fixedS > 0)
|
|
21432
21464
|
return fixedS;
|
|
21433
21465
|
const sized = scopeCapS(readPlanScope(runDir), api, subscription);
|
|
21434
|
-
return existsSync42(join69(runDir, "issue.json")) ? Math.min(capCeilingS(subscription), Math.round(sized * issueCapFactor())) : sized;
|
|
21466
|
+
return existsSync42(join69(runDir, "issue.json")) ? Math.min(capCeilingS(subscription), Math.max(issueMinCapS(), Math.round(sized * issueCapFactor()))) : sized;
|
|
21435
21467
|
}
|
|
21436
21468
|
function yamlRunCapS(text3) {
|
|
21437
21469
|
const raw2 = yamlKey(text3, "budgets", "run_cap_s");
|
|
@@ -21478,6 +21510,9 @@ function planOutOfRepo(runDir) {
|
|
|
21478
21510
|
var PLAN_SCOPE_FILE = "plan-scope.json", MAX_SCOPE_BYTES, CEILING_SUBSCRIPTION_S = 3600, CEILING_DOLLAR_S = 2400, PER_PACKAGE_S = 450, PER_FILE_S = 20, FREE_FILES = 3, capCeilingS = (subscription) => subscription ? CEILING_SUBSCRIPTION_S : CEILING_DOLLAR_S, fixedCapS = (explicitS, yamlS) => explicitS && explicitS > 0 ? explicitS : yamlS && yamlS > 0 ? yamlS : undefined, issueCapFactor = (env = process.env) => {
|
|
21479
21511
|
const n3 = Number((env["LOKI_E10_ISSUE_CAP_FACTOR"] ?? "").trim());
|
|
21480
21512
|
return (env["LOKI_E10_ISSUE_CAP_FACTOR"] ?? "").trim() !== "" && Number.isFinite(n3) && n3 >= 1 && n3 <= 4 ? n3 : 1.5;
|
|
21513
|
+
}, issueMinCapS = (env = process.env) => {
|
|
21514
|
+
const v = (env["LOKI_E10_ISSUE_MIN_CAP_S"] ?? "").trim(), n3 = Number(v);
|
|
21515
|
+
return v !== "" && Number.isFinite(n3) && n3 >= 0 ? n3 : 2400;
|
|
21481
21516
|
}, DEADLINE_MARGIN_S = 30, DEADLINE_MIN_CAP_S = 60, timeNoteOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TIME_NOTE"] ?? "").trim()), timeBudgetNote = (limitS) => `Time budget: about ${Math.max(1, Math.round(limitS / 60))} minutes left for this session. Work in small steps, keep the test suite passing at every checkpoint, and leave the tree in a working state when time runs out.`, outOfRepoInstruction = (scopePath) => `If the requested change has no target in this repository (for example the code lives in a hosted service or another repo), write {"files":[],"out_of_repo":"<one sentence why>"} to ${scopePath} and do not guess files.`, localBranchNote = (runId, verdict, repoDir) => `engine10: run ${runId} sealed ${verdict}, not verified: branch loki/${runId} stays local (not pushed); inspect it in ${repoDir}
|
|
21482
21517
|
`;
|
|
21483
21518
|
var init_run_cap = __esm(() => {
|
|
@@ -21561,7 +21596,7 @@ __export(exports_unit_mode, {
|
|
|
21561
21596
|
});
|
|
21562
21597
|
import { createHash as createHash16 } from "crypto";
|
|
21563
21598
|
import { closeSync as closeSync13, constants as constants2, fstatSync as fstatSync6, lstatSync as lstatSync18, openSync as openSync13, readSync as readSync10, realpathSync as realpathSync22 } from "fs";
|
|
21564
|
-
import { isAbsolute as isAbsolute9, relative as relative10, resolve as
|
|
21599
|
+
import { isAbsolute as isAbsolute9, relative as relative10, resolve as resolve20 } from "path";
|
|
21565
21600
|
function readBounded(path) {
|
|
21566
21601
|
const l = lstatSync18(path);
|
|
21567
21602
|
if (l.isSymbolicLink() || !l.isFile() || l.size > MAX_SPEC_BYTES)
|
|
@@ -21663,7 +21698,7 @@ function unitIntake(env, repoDir, existingCapUsd) {
|
|
|
21663
21698
|
const bad = (why) => ({ ok: false, note: UNIT_NOT_PROVEN(why) });
|
|
21664
21699
|
let txt;
|
|
21665
21700
|
try {
|
|
21666
|
-
const real3 = realpathSync22(
|
|
21701
|
+
const real3 = realpathSync22(resolve20(path)), root = realpathSync22(repoDir), rel = relative10(root, real3);
|
|
21667
21702
|
if (!(rel === ".." || rel.startsWith("../") || isAbsolute9(rel)))
|
|
21668
21703
|
return bad("its spec file is inside the worktree where the agent could edit it");
|
|
21669
21704
|
txt = readBounded(real3);
|
|
@@ -21685,7 +21720,7 @@ var init_unit_mode = __esm(() => {
|
|
|
21685
21720
|
});
|
|
21686
21721
|
|
|
21687
21722
|
// ../../loki-ts/src/features/exec_spec.ts
|
|
21688
|
-
import { existsSync as existsSync43, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync9, readFileSync as readFileSync61, readdirSync as readdirSync28, rmSync as rmSync18, statSync as
|
|
21723
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync9, readFileSync as readFileSync61, readdirSync as readdirSync28, rmSync as rmSync18, statSync as statSync24, writeFileSync as writeFileSync28 } from "fs";
|
|
21689
21724
|
import { tmpdir as tmpdir12 } from "os";
|
|
21690
21725
|
import { dirname as dirname25, join as join70, relative as relative11 } from "path";
|
|
21691
21726
|
function sections(task) {
|
|
@@ -21760,7 +21795,7 @@ function sourceFiles(dir, root = dir, out2 = []) {
|
|
|
21760
21795
|
const p = join70(dir, e);
|
|
21761
21796
|
let st;
|
|
21762
21797
|
try {
|
|
21763
|
-
st =
|
|
21798
|
+
st = statSync24(p);
|
|
21764
21799
|
} catch {
|
|
21765
21800
|
continue;
|
|
21766
21801
|
}
|
|
@@ -22656,8 +22691,8 @@ var init_exec_spec = __esm(() => {
|
|
|
22656
22691
|
});
|
|
22657
22692
|
|
|
22658
22693
|
// ../../loki-ts/src/project_model/conventions.ts
|
|
22659
|
-
import { existsSync as existsSync44, readdirSync as readdirSync29, readFileSync as readFileSync62, realpathSync as realpathSync23, renameSync as renameSync14, rmSync as rmSync19, statSync as
|
|
22660
|
-
import { basename as
|
|
22694
|
+
import { existsSync as existsSync44, readdirSync as readdirSync29, readFileSync as readFileSync62, realpathSync as realpathSync23, renameSync as renameSync14, rmSync as rmSync19, statSync as statSync25, writeFileSync as writeFileSync29 } from "fs";
|
|
22695
|
+
import { basename as basename21, dirname as dirname26, isAbsolute as isAbsolute10, join as join71, relative as relative12, resolve as resolve21, sep as sep14 } from "path";
|
|
22661
22696
|
function parseJsonc(text3) {
|
|
22662
22697
|
let out2 = "", i = 0;
|
|
22663
22698
|
while (i < text3.length) {
|
|
@@ -22801,11 +22836,11 @@ function changelogFileConvention(repoDir) {
|
|
|
22801
22836
|
files.push(d === "." ? n3 : `${d}/${n3}`);
|
|
22802
22837
|
} catch {}
|
|
22803
22838
|
}
|
|
22804
|
-
const g = guide.toLowerCase(), rank = (f) => f.includes("/") && g.includes(f.toLowerCase()) ? 0 : g.includes(
|
|
22839
|
+
const g = guide.toLowerCase(), rank = (f) => f.includes("/") && g.includes(f.toLowerCase()) ? 0 : g.includes(basename21(f).toLowerCase()) ? 1 : 2;
|
|
22805
22840
|
for (const f of [...files].sort((a, b) => rank(a) - rank(b))) {
|
|
22806
22841
|
let t = "";
|
|
22807
22842
|
try {
|
|
22808
|
-
if (!
|
|
22843
|
+
if (!statSync25(join71(repoDir, f)).isFile())
|
|
22809
22844
|
continue;
|
|
22810
22845
|
t = readFileSync62(join71(repoDir, f), "utf8");
|
|
22811
22846
|
} catch {
|
|
@@ -22932,10 +22967,10 @@ function releaseNoteProblems(repoDir, conv2, added, changed, task, env = process
|
|
|
22932
22967
|
for (const f of added.keys()) {
|
|
22933
22968
|
if (!f.startsWith(`${conv2.dir}/`))
|
|
22934
22969
|
continue;
|
|
22935
|
-
const n3 = /^(\d+)\./.exec(
|
|
22970
|
+
const n3 = /^(\d+)\./.exec(basename21(f))?.[1];
|
|
22936
22971
|
if (!n3 || nums.includes(n3))
|
|
22937
22972
|
continue;
|
|
22938
|
-
out2.push(nums.length ? `${f} is numbered ${n3}, but the task gives #${nums.join(", #")}` : `${f} is numbered ${n3}, a number the task never gives${p ? `; rename it to the orphan form ${conv2.dir}/${p}<short-slug>${
|
|
22973
|
+
out2.push(nums.length ? `${f} is numbered ${n3}, but the task gives #${nums.join(", #")}` : `${f} is numbered ${n3}, a number the task never gives${p ? `; rename it to the orphan form ${conv2.dir}/${p}<short-slug>${basename21(f).slice(n3.length)}` : ""}`);
|
|
22939
22974
|
}
|
|
22940
22975
|
}
|
|
22941
22976
|
return out2;
|
|
@@ -22983,7 +23018,7 @@ function towncrierTypes(repoDir) {
|
|
|
22983
23018
|
function towncrierExample(repoDir, dir) {
|
|
22984
23019
|
const types = towncrierTypes(repoDir);
|
|
22985
23020
|
try {
|
|
22986
|
-
const frags = readdirSync29(join71(repoDir, dir)).filter((n3) => /^\+?[\w-]+\.[a-z]+(?:\.[a-z]+)?$/.test(n3) && types.includes(n3.split(".")[1])).map((n3) => ({ n: n3, ext: n3.split(".").slice(2).join("."), t:
|
|
23021
|
+
const frags = readdirSync29(join71(repoDir, dir)).filter((n3) => /^\+?[\w-]+\.[a-z]+(?:\.[a-z]+)?$/.test(n3) && types.includes(n3.split(".")[1])).map((n3) => ({ n: n3, ext: n3.split(".").slice(2).join("."), t: statSync25(join71(repoDir, dir, n3)).mtimeMs }));
|
|
22987
23022
|
const count3 = new Map;
|
|
22988
23023
|
for (const f2 of frags)
|
|
22989
23024
|
count3.set(f2.ext, (count3.get(f2.ext) ?? 0) + 1);
|
|
@@ -23027,13 +23062,13 @@ function towncrierOrphansAllowed(repoDir) {
|
|
|
23027
23062
|
function renameInventedFragment(repoDir, conv2, f, task, env = process.env) {
|
|
23028
23063
|
if (!orphanRenameOn(env) || conv2.kind !== "towncrier" || !f.startsWith(`${conv2.dir}/`) || taskNumbers(task).length)
|
|
23029
23064
|
return null;
|
|
23030
|
-
const n3 = /^(\d+)\./.exec(
|
|
23065
|
+
const n3 = /^(\d+)\./.exec(basename21(f))?.[1], p = towncrierOrphanPrefix(repoDir, conv2.dir);
|
|
23031
23066
|
if (!n3 || !p)
|
|
23032
23067
|
return null;
|
|
23033
23068
|
const slug = fragmentTitle(task).toLowerCase().replace(/[`'"]/g, "").split(/[^a-z0-9]+/).filter(Boolean).slice(0, 6).join("-") || "change";
|
|
23034
|
-
let to = `${conv2.dir}/${p}${slug}${
|
|
23069
|
+
let to = `${conv2.dir}/${p}${slug}${basename21(f).slice(n3.length)}`;
|
|
23035
23070
|
for (let i = 2;existsSync44(join71(repoDir, to)); i++)
|
|
23036
|
-
to = `${conv2.dir}/${p}${slug}-${i}${
|
|
23071
|
+
to = `${conv2.dir}/${p}${slug}-${i}${basename21(f).slice(n3.length)}`;
|
|
23037
23072
|
try {
|
|
23038
23073
|
renameSync14(join71(repoDir, f), join71(repoDir, to));
|
|
23039
23074
|
} catch {
|
|
@@ -23473,7 +23508,7 @@ function topLevelSymbols2(src) {
|
|
|
23473
23508
|
function misplacedNamedNotes(task, rawDiff, repoDir, head) {
|
|
23474
23509
|
const named = taskNamedPaths(task), added = rawDiff.flatMap((m, i) => i % 2 === 0 && m.trim().split(" ").pop() === "A" && rawDiff[i + 1] ? [rawDiff[i + 1]] : []), changed = new Set(rawDiff.filter((_, i) => i % 2 === 1));
|
|
23475
23510
|
return named.filter((x) => !x.includes("/") && !TEST_NAME.test(x)).flatMap((x) => {
|
|
23476
|
-
const hit = added.find((f) => f.includes("/") &&
|
|
23511
|
+
const hit = added.find((f) => f.includes("/") && basename21(f) === x && TEST_DIR2.test(f.split("/")[0]));
|
|
23477
23512
|
if (!hit || named.some((p) => p.endsWith(`/${x}`)) || taskNamesDir(task, dirname26(hit)))
|
|
23478
23513
|
return [];
|
|
23479
23514
|
const root = safeGitSpawn(repoDir, ["show", `${head}:${x}`], { timeout: 5000, encoding: "utf8" });
|
|
@@ -23553,7 +23588,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText, task =
|
|
|
23553
23588
|
return join71(testDir, "__self__");
|
|
23554
23589
|
const url = /^fileURLToPath\(new URL\((["'])([^"']*)\1\s*,\s*import\.meta\.url\)\)$/.exec(e);
|
|
23555
23590
|
if (url)
|
|
23556
|
-
return
|
|
23591
|
+
return resolve21(testDir, url[2]);
|
|
23557
23592
|
const lit = /^(["'`])((?:\\.|(?!\1)[^\\])*)\1$/.exec(e);
|
|
23558
23593
|
if (lit)
|
|
23559
23594
|
return lit[2].includes("${") ? null : lit[2];
|
|
@@ -23567,7 +23602,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText, task =
|
|
|
23567
23602
|
return null;
|
|
23568
23603
|
if (call[1] === "dirname")
|
|
23569
23604
|
return dirname26(args[0]);
|
|
23570
|
-
const out2 =
|
|
23605
|
+
const out2 = resolve21(...args);
|
|
23571
23606
|
const first = parts.slice(1).map((a) => /^\s*["'`]([^"'`]*)["'`]\s*$/.exec(a)?.[1]).find((x) => x), viaWalk = !!first && walk.has(parts[0].trim()) && [pkg, repoDir].some((d) => existsSync44(join71(d, first.split("/").filter(Boolean)[0] ?? "\x00")));
|
|
23572
23607
|
if (report && (viaWalk || !parts.some((a) => walk.has(a.trim()) || taint.has(a.trim())) && (relative12(testDir, out2).startsWith("..") || strayInTestDir(out2) || namedStray(out2))) && parts.some((a) => /^\s*["'`]/.test(a)))
|
|
23573
23608
|
reports.set(`${ln}|${e}`, { out: out2, rel: relative12(repoDir, out2), tail: viaWalk ? join71(...args.slice(1)) : undefined });
|
|
@@ -23672,7 +23707,7 @@ function phantomReason(miss, repoFiles, testDir = "", pkgRoot = "", task = null)
|
|
|
23672
23707
|
};
|
|
23673
23708
|
const own = miss.map((m) => [m, at(m) ?? (beside(m) ? `the task names ${beside(m)} at the repo path ${beside(m)}, not beside the test file` : null)]), loc = own.filter(([, w]) => w).map(([, w]) => w), rest = own.filter(([, w]) => !w).map(([m]) => m);
|
|
23674
23709
|
const hint = (m) => {
|
|
23675
|
-
const n3 =
|
|
23710
|
+
const n3 = basename21(m), near = [...new Set(repoFiles.flatMap((f) => {
|
|
23676
23711
|
const s = f.split("/"), k = s.indexOf(n3);
|
|
23677
23712
|
return k >= 0 && s.slice(0, k + 1).join("/") !== m ? [s.slice(0, k + 1).join("/")] : [];
|
|
23678
23713
|
}))].slice(0, 3);
|
|
@@ -23690,7 +23725,7 @@ var readJson4 = (p) => {
|
|
|
23690
23725
|
}
|
|
23691
23726
|
}, newestIn = (abs, rel, pat) => {
|
|
23692
23727
|
try {
|
|
23693
|
-
const f = readdirSync29(abs).filter((n3) => pat.test(n3) && !/^readme/i.test(n3)).map((n3) => ({ n: n3, t:
|
|
23728
|
+
const f = readdirSync29(abs).filter((n3) => pat.test(n3) && !/^readme/i.test(n3)).map((n3) => ({ n: n3, t: statSync25(join71(abs, n3)).mtimeMs })).sort((a, b) => b.t - a.t || b.n.localeCompare(a.n))[0];
|
|
23694
23729
|
return f ? `${rel}/${f.n}` : null;
|
|
23695
23730
|
} catch {
|
|
23696
23731
|
return null;
|
|
@@ -23759,7 +23794,7 @@ var init_conventions = __esm(() => {
|
|
|
23759
23794
|
|
|
23760
23795
|
// ../../loki-ts/src/e10ext/scope.ts
|
|
23761
23796
|
import { existsSync as existsSync45, readFileSync as readFileSync63 } from "fs";
|
|
23762
|
-
import { basename as
|
|
23797
|
+
import { basename as basename22, dirname as dirname27, join as join72 } from "path";
|
|
23763
23798
|
function contractText(o) {
|
|
23764
23799
|
const c = o.intake?.contract_snapshot?.contract;
|
|
23765
23800
|
return Array.isArray(c?.criteria) ? c.criteria.map((x) => typeof x?.text === "string" ? x.text : "").join(`
|
|
@@ -23773,7 +23808,7 @@ function outsideScope(o, staged, planFiles = []) {
|
|
|
23773
23808
|
const text3 = `${plan}
|
|
23774
23809
|
${typeof o.intake?.task === "string" ? o.intake.task : ""}
|
|
23775
23810
|
${contractText(o)}`, pre = o.intake?.preexisting_dirty ?? {};
|
|
23776
|
-
const kept = (f) => isTestFile(f) || Object.hasOwn(pre, f) || mentions(text3, f) || mentions(text3,
|
|
23811
|
+
const kept = (f) => isTestFile(f) || Object.hasOwn(pre, f) || mentions(text3, f) || mentions(text3, basename22(f));
|
|
23777
23812
|
if (planFiles.length > 0)
|
|
23778
23813
|
return staged.filter(({ st, f }) => st !== "A" && !kept(f) && !planFiles.includes(f)).map(({ f }) => f);
|
|
23779
23814
|
const toks = surfaceTokens(text3), plannedDirs = new Set(rel.map((r) => dirname27(r)).filter((d) => d !== "."));
|
|
@@ -23783,7 +23818,7 @@ function anchoredPlanScope(files, task, repoDir, env = process.env) {
|
|
|
23783
23818
|
if (!files.length || !planScopeAnchorEnabled(env) || !task.trim())
|
|
23784
23819
|
return files;
|
|
23785
23820
|
const syms = [...new Set(extractSpecAtoms(task).filter((a) => a.kind === "site").map((a) => a.text.split(".").pop()).filter(Boolean))];
|
|
23786
|
-
const namesFile = (f) => mentions(task, f) || mentions(task,
|
|
23821
|
+
const namesFile = (f) => mentions(task, f) || mentions(task, basename22(f));
|
|
23787
23822
|
const defines = (f) => {
|
|
23788
23823
|
if (!repoDir || !syms.length)
|
|
23789
23824
|
return false;
|
|
@@ -23819,14 +23854,14 @@ function briefChangelog(repoDir, env = process.env) {
|
|
|
23819
23854
|
function ownerOf(repoDir, f) {
|
|
23820
23855
|
if (f.endsWith(".go")) {
|
|
23821
23856
|
const d = dirname27(f);
|
|
23822
|
-
return { dir: d, name:
|
|
23857
|
+
return { dir: d, name: basename22(d) };
|
|
23823
23858
|
}
|
|
23824
23859
|
if (!JS_EXT.test(f))
|
|
23825
23860
|
return null;
|
|
23826
23861
|
for (let d = dirname27(f);; d = dirname27(d)) {
|
|
23827
23862
|
const pj = join72(repoDir, d, "package.json");
|
|
23828
23863
|
if (existsSync45(pj)) {
|
|
23829
|
-
let name =
|
|
23864
|
+
let name = basename22(d === "." ? repoDir : d);
|
|
23830
23865
|
try {
|
|
23831
23866
|
const n3 = JSON.parse(readFileSync63(pj, "utf8")).name;
|
|
23832
23867
|
if (typeof n3 === "string")
|
|
@@ -23852,7 +23887,7 @@ function crossPackageTestEdits(repoDir, staged, task, tracked) {
|
|
|
23852
23887
|
const o = ownerOf(repoDir, f);
|
|
23853
23888
|
if (!o || srcOwners.has(o.dir))
|
|
23854
23889
|
return false;
|
|
23855
|
-
if (mentions(task, f) || mentions(task,
|
|
23890
|
+
if (mentions(task, f) || mentions(task, basename22(f)) || o.dir !== "." && (mentions(task, o.dir) || mentions(task, basename22(o.dir))) || mentions(task, o.name))
|
|
23856
23891
|
return false;
|
|
23857
23892
|
if (testReachEnabled() && exercisesChange(repoDir, f, src.map(({ f: s }) => s)))
|
|
23858
23893
|
return false;
|
|
@@ -23908,7 +23943,7 @@ var init_scope2 = __esm(() => {
|
|
|
23908
23943
|
// ../../loki-ts/src/features/attempts.ts
|
|
23909
23944
|
import { existsSync as existsSync46, lstatSync as lstatSync19, mkdtempSync as mkdtempSync10, readFileSync as readFileSync64, realpathSync as realpathSync24, rmSync as rmSync20, symlinkSync as symlinkSync2 } from "fs";
|
|
23910
23945
|
import { tmpdir as tmpdir13 } from "os";
|
|
23911
|
-
import { basename as
|
|
23946
|
+
import { basename as basename23, dirname as dirname28, join as join73 } from "path";
|
|
23912
23947
|
function attemptsTotal(model, env = process.env) {
|
|
23913
23948
|
const raw2 = (env.LOKI_E10_ATTEMPTS ?? "").trim().toLowerCase() || (attemptsEarly(env) && /haiku/i.test(model ?? "") ? "on" : "");
|
|
23914
23949
|
if (["on", "true", "yes"].includes(raw2))
|
|
@@ -23920,7 +23955,7 @@ function cascadeWallTail(runDir, v) {
|
|
|
23920
23955
|
if (!wallFailedOf(v))
|
|
23921
23956
|
return null;
|
|
23922
23957
|
try {
|
|
23923
|
-
const t = readFileSync64(join73(runDir,
|
|
23958
|
+
const t = readFileSync64(join73(runDir, basename23(String(v.wall_failure_tail))), "utf8").trim();
|
|
23924
23959
|
return t ? t.slice(-6000) : null;
|
|
23925
23960
|
} catch {
|
|
23926
23961
|
return null;
|
|
@@ -24034,7 +24069,7 @@ function removeAttemptTrees(primary, root, dirs) {
|
|
|
24034
24069
|
safeGit(primary, ["worktree", "prune"]);
|
|
24035
24070
|
} catch {}
|
|
24036
24071
|
try {
|
|
24037
|
-
if (
|
|
24072
|
+
if (basename23(root).startsWith(ATTEMPTS_TMP_PREFIX) && dirname28(realpathSync24(root)) === realpathSync24(tmpdir13()) && !lstatSync19(root).isSymbolicLink())
|
|
24038
24073
|
rmSync20(root, { recursive: true, force: true });
|
|
24039
24074
|
} catch {}
|
|
24040
24075
|
}
|
|
@@ -24289,10 +24324,10 @@ var init_attempts = __esm(() => {
|
|
|
24289
24324
|
});
|
|
24290
24325
|
|
|
24291
24326
|
// ../../loki-ts/src/util/secure_scan.ts
|
|
24292
|
-
import { copyFileSync as copyFileSync3, existsSync as existsSync47, lstatSync as lstatSync20, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync11, readFileSync as readFileSync65, realpathSync as realpathSync25, rmSync as rmSync21, statSync as
|
|
24327
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync47, lstatSync as lstatSync20, mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync11, readFileSync as readFileSync65, realpathSync as realpathSync25, rmSync as rmSync21, statSync as statSync26, writeFileSync as writeFileSync30 } from "fs";
|
|
24293
24328
|
import { randomBytes as randomBytes5 } from "crypto";
|
|
24294
24329
|
import { tmpdir as tmpdir14 } from "os";
|
|
24295
|
-
import { basename as
|
|
24330
|
+
import { basename as basename24, dirname as dirname29, join as join74, resolve as resolve22, sep as sep15 } from "path";
|
|
24296
24331
|
function fail(error) {
|
|
24297
24332
|
return { ok: false, findings: [], error };
|
|
24298
24333
|
}
|
|
@@ -24491,7 +24526,7 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
24491
24526
|
const skipped = [];
|
|
24492
24527
|
for (const p of untracked3.split("\x00").filter(Boolean)) {
|
|
24493
24528
|
try {
|
|
24494
|
-
const st =
|
|
24529
|
+
const st = statSync26(join74(repoDir, p));
|
|
24495
24530
|
if (!st.isFile())
|
|
24496
24531
|
continue;
|
|
24497
24532
|
if (st.size > MAX_ADDED_FILE_BYTES) {
|
|
@@ -24515,14 +24550,14 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
24515
24550
|
return { ok: true, findings: skipped };
|
|
24516
24551
|
const mirror = mkdtempSync11(join74(tmpdir14(), "loki-secure-added-"));
|
|
24517
24552
|
try {
|
|
24518
|
-
const root =
|
|
24553
|
+
const root = resolve22(mirror) + sep15;
|
|
24519
24554
|
const chunkMap = new Map;
|
|
24520
24555
|
const chunkRoot = `.loki-chunks-${randomBytes5(6).toString("hex")}`;
|
|
24521
24556
|
let chunkSeq = 0;
|
|
24522
24557
|
for (const [p, lines] of added) {
|
|
24523
24558
|
if (lines.size === 0)
|
|
24524
24559
|
continue;
|
|
24525
|
-
const dest =
|
|
24560
|
+
const dest = resolve22(mirror, p);
|
|
24526
24561
|
if (!dest.startsWith(root))
|
|
24527
24562
|
continue;
|
|
24528
24563
|
let max = 0;
|
|
@@ -24559,8 +24594,8 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
24559
24594
|
chunks.push(cur);
|
|
24560
24595
|
const whole = chunks.length === 1;
|
|
24561
24596
|
for (const c of chunks) {
|
|
24562
|
-
const rel = whole ? p : join74(chunkRoot, String(chunkSeq++),
|
|
24563
|
-
const out2 = whole ? dest :
|
|
24597
|
+
const rel = whole ? p : join74(chunkRoot, String(chunkSeq++), basename24(p));
|
|
24598
|
+
const out2 = whole ? dest : resolve22(mirror, rel);
|
|
24564
24599
|
if (!out2.startsWith(root))
|
|
24565
24600
|
break;
|
|
24566
24601
|
chunkMap.set(rel, { file: p, lines: c.orig });
|
|
@@ -25812,7 +25847,7 @@ var init_tournament = __esm(() => {
|
|
|
25812
25847
|
import { execFileSync as execFileSync6, spawnSync as spawnSync9 } from "child_process";
|
|
25813
25848
|
import { cpSync as cpSync2, lstatSync as lstatSync21, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync12, readFileSync as readFileSync67, realpathSync as realpathSync27, rmSync as rmSync23, writeFileSync as writeFileSync32 } from "fs";
|
|
25814
25849
|
import { tmpdir as tmpdir15 } from "os";
|
|
25815
|
-
import { basename as
|
|
25850
|
+
import { basename as basename25, dirname as dirname31, join as join76 } from "path";
|
|
25816
25851
|
function goStringLiterals(body) {
|
|
25817
25852
|
const out2 = [];
|
|
25818
25853
|
for (const m of body.matchAll(/"((?:[^"\\\n]|\\.)*)"/g)) {
|
|
@@ -26172,7 +26207,7 @@ function makeScratch(repoDir, baseSha, skip, userUntracked = [], diff) {
|
|
|
26172
26207
|
const root = mkdtempSync12(join76(tmpdir15(), SCRATCH_PREFIX)), base = join76(root, "base"), patched = join76(root, "patched"), replay = join76(root, "replay");
|
|
26173
26208
|
const dispose = () => {
|
|
26174
26209
|
try {
|
|
26175
|
-
if (
|
|
26210
|
+
if (basename25(root).startsWith(SCRATCH_PREFIX) && dirname31(realpathSync27(root)) === realpathSync27(tmpdir15()) && !lstatSync21(root).isSymbolicLink())
|
|
26176
26211
|
rmSync23(root, { recursive: true, force: true });
|
|
26177
26212
|
} catch {}
|
|
26178
26213
|
};
|
|
@@ -27155,7 +27190,7 @@ var init_wall_owned = __esm(() => {
|
|
|
27155
27190
|
import { createHash as createHash18 } from "crypto";
|
|
27156
27191
|
import { appendFileSync as appendFileSync7, copyFileSync as copyFileSync4, cpSync as cpSync3, existsSync as existsSync49, mkdirSync as mkdirSync32, readFileSync as readFileSync71, rmSync as rmSync24, writeFileSync as writeFileSync33 } from "fs";
|
|
27157
27192
|
import { tmpdir as tmpdir16 } from "os";
|
|
27158
|
-
import { basename as
|
|
27193
|
+
import { basename as basename26, join as join81, relative as relative14 } from "path";
|
|
27159
27194
|
function wallHoldoutRatio(env = process.env) {
|
|
27160
27195
|
if (env["LOKI_WALL_HOLDOUT"]?.trim() === "0")
|
|
27161
27196
|
return 0;
|
|
@@ -27211,7 +27246,7 @@ function stageHoldout(dir, repoDir) {
|
|
|
27211
27246
|
man = JSON.parse(readFileSync71(join81(dir, MANIFEST2), "utf8"));
|
|
27212
27247
|
} catch {}
|
|
27213
27248
|
if (!man)
|
|
27214
|
-
return { tests, missing: [`holdout store unreadable: ${
|
|
27249
|
+
return { tests, missing: [`holdout store unreadable: ${basename26(dir)}`], cleanup: () => {} };
|
|
27215
27250
|
mkdirSync32(man.targetDir, { recursive: true });
|
|
27216
27251
|
man.files.forEach((f, i) => {
|
|
27217
27252
|
const src = join81(dir, f.name);
|
|
@@ -27489,7 +27524,7 @@ var init_colors = __esm(() => {
|
|
|
27489
27524
|
});
|
|
27490
27525
|
|
|
27491
27526
|
// ../../loki-ts/src/util/run_summary.ts
|
|
27492
|
-
import { existsSync as existsSync50, mkdirSync as mkdirSync33, readFileSync as readFileSync72, renameSync as renameSync16, statSync as
|
|
27527
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync33, readFileSync as readFileSync72, renameSync as renameSync16, statSync as statSync27, writeFileSync as writeFileSync34 } from "fs";
|
|
27493
27528
|
import { join as join82 } from "path";
|
|
27494
27529
|
function resultOf(outcome) {
|
|
27495
27530
|
if (outcome === "VERIFIED" || outcome === "ALREADY_SATISFIED")
|
|
@@ -27591,7 +27626,7 @@ function diffStat(repoDir, base, head = "HEAD") {
|
|
|
27591
27626
|
function readRiskRecord(repoDir, sinceMs = 0) {
|
|
27592
27627
|
try {
|
|
27593
27628
|
const p = join82(repoDir, ".loki", "state", "risk-tier.json");
|
|
27594
|
-
if (
|
|
27629
|
+
if (statSync27(p).mtimeMs < sinceMs)
|
|
27595
27630
|
return null;
|
|
27596
27631
|
const r = JSON.parse(readFileSync72(p, "utf8"));
|
|
27597
27632
|
return r && typeof r === "object" ? r : null;
|
|
@@ -27727,7 +27762,7 @@ function composeHandoff(f) {
|
|
|
27727
27762
|
if (count3 === null) {
|
|
27728
27763
|
try {
|
|
27729
27764
|
const p = join82(f.repoDir, ".loki", "state", "interventions.json");
|
|
27730
|
-
const r =
|
|
27765
|
+
const r = statSync27(p).mtimeMs < (f.sinceMs ?? 0) ? null : JSON.parse(readFileSync72(p, "utf8"));
|
|
27731
27766
|
const nn = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : null;
|
|
27732
27767
|
if (r && nn(r.count) !== null) {
|
|
27733
27768
|
count3 = nn(r.count);
|
|
@@ -28472,7 +28507,7 @@ var init_fetch_issue = __esm(() => {
|
|
|
28472
28507
|
});
|
|
28473
28508
|
|
|
28474
28509
|
// ../../loki-ts/src/features/spec_ambiguity.ts
|
|
28475
|
-
import { mkdirSync as mkdirSync35, readFileSync as readFileSync75, statSync as
|
|
28510
|
+
import { mkdirSync as mkdirSync35, readFileSync as readFileSync75, statSync as statSync28, writeFileSync as writeFileSync38 } from "fs";
|
|
28476
28511
|
import { join as join86 } from "path";
|
|
28477
28512
|
function scoreAmbiguity(task) {
|
|
28478
28513
|
const hits = [];
|
|
@@ -28591,7 +28626,7 @@ function corpus(repoDir) {
|
|
|
28591
28626
|
} catch {}
|
|
28592
28627
|
for (const f of tracked.filter((p) => TEST_DOC.test(p)).slice(0, 600)) {
|
|
28593
28628
|
try {
|
|
28594
|
-
if (
|
|
28629
|
+
if (statSync28(join86(repoDir, f)).size <= 200000)
|
|
28595
28630
|
out2.push({ path: f, text: readFileSync75(join86(repoDir, f), "utf8").replace(/\s+/g, "") });
|
|
28596
28631
|
} catch {}
|
|
28597
28632
|
}
|
|
@@ -28649,7 +28684,7 @@ function precedentFor(c, repoDir) {
|
|
|
28649
28684
|
for (const f of tracked) {
|
|
28650
28685
|
let lines2;
|
|
28651
28686
|
try {
|
|
28652
|
-
if (
|
|
28687
|
+
if (statSync28(join86(repoDir, f)).size > 200000)
|
|
28653
28688
|
continue;
|
|
28654
28689
|
lines2 = readFileSync75(join86(repoDir, f), "utf8").split(`
|
|
28655
28690
|
`);
|
|
@@ -29070,9 +29105,9 @@ var init_triage = __esm(() => {
|
|
|
29070
29105
|
});
|
|
29071
29106
|
|
|
29072
29107
|
// ../../loki-ts/src/util/steer.ts
|
|
29073
|
-
import { appendFileSync as appendFileSync8, closeSync as closeSync14, constants as constants3, fstatSync as fstatSync7, readdirSync as readdirSync31, lstatSync as lstatSync22, mkdirSync as mkdirSync36, linkSync as linkSync2, openSync as openSync14, readFileSync as readFileSync76, readSync as readSync11, renameSync as renameSync17, statSync as
|
|
29108
|
+
import { appendFileSync as appendFileSync8, closeSync as closeSync14, constants as constants3, fstatSync as fstatSync7, readdirSync as readdirSync31, lstatSync as lstatSync22, mkdirSync as mkdirSync36, linkSync as linkSync2, openSync as openSync14, readFileSync as readFileSync76, readSync as readSync11, renameSync as renameSync17, statSync as statSync29, lutimesSync, rmSync as rmSync25, unlinkSync as unlinkSync8, writeFileSync as writeFileSync39, existsSync as existsSync53 } from "fs";
|
|
29074
29109
|
import { createHash as createHash20, randomBytes as randomBytes6 } from "crypto";
|
|
29075
|
-
import { basename as
|
|
29110
|
+
import { basename as basename27, join as join87 } from "path";
|
|
29076
29111
|
function archiveTo(logs, prefix, src, link = linkSync2, onLinked) {
|
|
29077
29112
|
for (let i = 0;; i++) {
|
|
29078
29113
|
const name = i === 0 ? `${prefix}.md` : `${prefix}-${i}.md`;
|
|
@@ -29104,7 +29139,7 @@ function orphanAlreadyArchived(logs, claim) {
|
|
|
29104
29139
|
if (!/^human-input-.*\.md$/.test(a))
|
|
29105
29140
|
continue;
|
|
29106
29141
|
try {
|
|
29107
|
-
const s =
|
|
29142
|
+
const s = statSync29(join87(logs, a));
|
|
29108
29143
|
if (s.ino !== c.ino || s.dev !== c.dev)
|
|
29109
29144
|
continue;
|
|
29110
29145
|
if (/^human-input-(ORPHAN|REJECTED)-/.test(a) || existsSync53(appliedMarker(logs, a)))
|
|
@@ -29141,7 +29176,7 @@ function sweepOrphans(logs, stamp2, unapplied, link, nowMs = Date.now()) {
|
|
|
29141
29176
|
if (alive2) {
|
|
29142
29177
|
let ageMs = 0;
|
|
29143
29178
|
try {
|
|
29144
|
-
ageMs = nowMs -
|
|
29179
|
+
ageMs = nowMs - statSync29(join87(logs, n3)).mtimeMs;
|
|
29145
29180
|
} catch {
|
|
29146
29181
|
continue;
|
|
29147
29182
|
}
|
|
@@ -29269,7 +29304,7 @@ function consumeSteer(repoDir, env = process.env, now2 = () => new Date, sink, h
|
|
|
29269
29304
|
archiveTo(join87(repoDir, ".loki", "logs"), `human-input-${now2().toISOString().replace(/[-:]/g, "").replace(/\..*/, "")}`, claimed, hooks2?.link);
|
|
29270
29305
|
unapplied("logs dir unwritable or file unreadable");
|
|
29271
29306
|
} catch {
|
|
29272
|
-
unapplied(`steer stranded at .loki/logs/${
|
|
29307
|
+
unapplied(`steer stranded at .loki/logs/${basename27(claimed)}`);
|
|
29273
29308
|
}
|
|
29274
29309
|
} else
|
|
29275
29310
|
try {
|
|
@@ -29388,7 +29423,7 @@ var init_steer = __esm(() => {
|
|
|
29388
29423
|
});
|
|
29389
29424
|
|
|
29390
29425
|
// ../../loki-ts/src/util/reviewer_brief.ts
|
|
29391
|
-
import { closeSync as closeSync15, existsSync as existsSync54, fstatSync as fstatSync8, lstatSync as lstatSync23, openSync as openSync15, readFileSync as readFileSync77, readSync as readSync12, readdirSync as readdirSync32, realpathSync as realpathSync29, statSync as
|
|
29426
|
+
import { closeSync as closeSync15, existsSync as existsSync54, fstatSync as fstatSync8, lstatSync as lstatSync23, openSync as openSync15, readFileSync as readFileSync77, readSync as readSync12, readdirSync as readdirSync32, realpathSync as realpathSync29, statSync as statSync30 } from "fs";
|
|
29392
29427
|
import { dirname as dirname35, join as join88, normalize as normalize4, sep as sep17 } from "path";
|
|
29393
29428
|
function reviewFlagLines(text3) {
|
|
29394
29429
|
const out2 = [];
|
|
@@ -29545,10 +29580,10 @@ function lcovFor(repoDir, changed) {
|
|
|
29545
29580
|
const p = LCOV_PATHS.map((r) => join88(repoDir, r)).find((x) => existsSync54(x));
|
|
29546
29581
|
if (!p)
|
|
29547
29582
|
return { reason: "no coverage report from an executed test run (coverage/lcov.info absent)" };
|
|
29548
|
-
const t =
|
|
29583
|
+
const t = statSync30(p).mtimeMs;
|
|
29549
29584
|
for (const f of changed) {
|
|
29550
29585
|
try {
|
|
29551
|
-
if (
|
|
29586
|
+
if (statSync30(join88(repoDir, f)).mtimeMs > t)
|
|
29552
29587
|
return { reason: `coverage report is older than ${f}` };
|
|
29553
29588
|
} catch {}
|
|
29554
29589
|
}
|
|
@@ -30081,7 +30116,7 @@ var init_mutation_proof = __esm(() => {
|
|
|
30081
30116
|
|
|
30082
30117
|
// ../../loki-ts/src/features/self_review.ts
|
|
30083
30118
|
import { existsSync as existsSync56, mkdirSync as mkdirSync38, readFileSync as readFileSync79, writeFileSync as writeFileSync41 } from "fs";
|
|
30084
|
-
import { basename as
|
|
30119
|
+
import { basename as basename29, dirname as dirname37, join as join90 } from "path";
|
|
30085
30120
|
function pyRegex(src, flags = "") {
|
|
30086
30121
|
let p = src.trim();
|
|
30087
30122
|
if (p.startsWith("(?x)"))
|
|
@@ -30227,7 +30262,7 @@ function selfReviewChecks(repoDir, baseSha, staged, task, outputs, env = process
|
|
|
30227
30262
|
}
|
|
30228
30263
|
})();
|
|
30229
30264
|
const fragDir = conv2 && conv2.kind !== "changelog" ? `${conv2.dir}/` : null;
|
|
30230
|
-
const stray = trackedDirs ? added.filter((f) => !art.includes(f) && !isTestFile3(f) && !(fragDir && f.startsWith(fragDir)) && !trackedDirs.has(dirname37(f)) && !task.includes(f) && !task.includes(
|
|
30265
|
+
const stray = trackedDirs ? added.filter((f) => !art.includes(f) && !isTestFile3(f) && !(fragDir && f.startsWith(fragDir)) && !trackedDirs.has(dirname37(f)) && !task.includes(f) && !task.includes(basename29(f))) : [];
|
|
30231
30266
|
items.push(stray.length ? { item: "stray_files", status: "flagged", detail: `new files outside every directory the repo tracks: ${stray.slice(0, 8).join(", ")}` } : art.length ? { item: "stray_files", status: "auto", detail: `build output the commit leaves out: ${art.slice(0, 8).join(", ")}` } : { item: "stray_files", status: "ok", detail: "no generated or stray file" });
|
|
30232
30267
|
items.push(src.length === 0 ? { item: "test", status: "ok", detail: "no source change" } : tests.length ? { item: "test", status: "ok", detail: `test changes: ${tests.slice(0, 5).join(", ")}` } : { item: "test", status: "flagged", detail: `source changed (${src.slice(0, 5).join(", ")}) and the diff has no test` });
|
|
30233
30268
|
const fmts = (() => {
|
|
@@ -30316,8 +30351,8 @@ function docEnumerations(repoDir, baseSha, live2) {
|
|
|
30316
30351
|
`))].filter((t) => !baseTok.has(t));
|
|
30317
30352
|
if (!added.length)
|
|
30318
30353
|
continue;
|
|
30319
|
-
const dir = dirname37(f), stems = new Set([
|
|
30320
|
-
const docs = tracked.filter((d) => /\.mdx?$/i.test(d) && !touched.has(d) && (dirname37(d) === dir || /(^|\/)docs?\//.test(d) && stems.has(
|
|
30354
|
+
const dir = dirname37(f), stems = new Set([basename29(dir), basename29(f).replace(/\.[^.]+$/, "")].filter((s) => s && s !== "." && s !== "index" && s !== "src" && s !== "lib"));
|
|
30355
|
+
const docs = tracked.filter((d) => /\.mdx?$/i.test(d) && !touched.has(d) && (dirname37(d) === dir || /(^|\/)docs?\//.test(d) && stems.has(basename29(d).replace(/\.mdx?$/i, ""))));
|
|
30321
30356
|
for (const d of docs) {
|
|
30322
30357
|
let text3 = "";
|
|
30323
30358
|
try {
|
|
@@ -31696,7 +31731,7 @@ var init_wall_manifest = __esm(() => {
|
|
|
31696
31731
|
|
|
31697
31732
|
// ../../loki-ts/src/features/wall_manifest_wire.ts
|
|
31698
31733
|
import { createHash as createHash21 } from "crypto";
|
|
31699
|
-
import { basename as
|
|
31734
|
+
import { basename as basename30, dirname as dirname38 } from "path";
|
|
31700
31735
|
function blobEntries(ls2) {
|
|
31701
31736
|
const out2 = [];
|
|
31702
31737
|
for (const raw2 of ls2.toString("latin1").split("\x00")) {
|
|
@@ -31726,12 +31761,12 @@ function wallManifestFor(repoDir, tree, task, env = process.env) {
|
|
|
31726
31761
|
return null;
|
|
31727
31762
|
const low = task.toLowerCase().replace(/\\/g, "/");
|
|
31728
31763
|
const token = (n3) => new RegExp(`(?<![A-Za-z0-9_])${escapeRegex(n3.toLowerCase())}(?![A-Za-z0-9_])`).test(low);
|
|
31729
|
-
const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(
|
|
31730
|
-
const matched = all.filter((e) => SOURCE.test(e.path) && (token(
|
|
31764
|
+
const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(basename30(e.path)) && e.path.includes("/") && token(dirname38(e.path));
|
|
31765
|
+
const matched = all.filter((e) => SOURCE.test(e.path) && (token(basename30(e.path)) || token(e.path) || token(basename30(e.path).replace(/\.[^.]*$/, "")) || dirModule(e)));
|
|
31731
31766
|
const spans = (p) => [...low.matchAll(new RegExp(`(?<![A-Za-z0-9_])${escapeRegex(p.toLowerCase())}(?![A-Za-z0-9_])`, "g"))].map((m) => [m.index, m.index + m[0].length]);
|
|
31732
31767
|
const occ = new Map(matched.map((e) => [e, spans(e.path)]));
|
|
31733
31768
|
const exact = (e) => occ.get(e).some(([s, t]) => !matched.some((o) => o !== e && o.path.length > e.path.length && occ.get(o).some(([s2, t2]) => s2 <= s && t <= t2)));
|
|
31734
|
-
const byPath2 = matched.filter(exact).sort((a, b) => b.path.length - a.path.length), byBase = matched.filter((e) => !byPath2.includes(e) && token(
|
|
31769
|
+
const byPath2 = matched.filter(exact).sort((a, b) => b.path.length - a.path.length), byBase = matched.filter((e) => !byPath2.includes(e) && token(basename30(e.path)));
|
|
31735
31770
|
const named = [...byPath2, ...byBase, ...matched.filter((e) => !byPath2.includes(e) && !byBase.includes(e))].slice(0, MAX_NAMED);
|
|
31736
31771
|
const tests = all.filter((e) => TESTISH.test(e.path)).slice(0, MAX_FILES), listed = tests.filter((e) => !SOURCE.test(e.path));
|
|
31737
31772
|
const want = [...new Set([...all.filter((e) => CONFIG.test(e.path)), ...tests.filter((e) => SOURCE.test(e.path)), ...named])];
|
|
@@ -32102,7 +32137,7 @@ __export(exports_wall, {
|
|
|
32102
32137
|
});
|
|
32103
32138
|
import { existsSync as existsSync58, mkdirSync as mkdirSync39, mkdtempSync as mkdtempSync14, readFileSync as readFileSync82, readdirSync as readdirSync35, realpathSync as realpathSync31, rmSync as rmSync28, writeFileSync as writeFileSync43 } from "fs";
|
|
32104
32139
|
import { tmpdir as tmpdir18 } from "os";
|
|
32105
|
-
import { basename as
|
|
32140
|
+
import { basename as basename31, dirname as dirname39, join as join93, relative as relative18 } from "path";
|
|
32106
32141
|
|
|
32107
32142
|
class RealBaseTestRunner {
|
|
32108
32143
|
api;
|
|
@@ -32350,8 +32385,8 @@ async function execSpecWall(ctx, signal, task, sizeName, runners, existingTests,
|
|
|
32350
32385
|
rmSync28(sealedDir, { recursive: true, force: true });
|
|
32351
32386
|
mkdirSync39(sealedDir, { recursive: true });
|
|
32352
32387
|
for (const f of sealedFiles)
|
|
32353
|
-
writeFileSync43(join93(sealedDir,
|
|
32354
|
-
return { kind: "authored", staged: true, execSpec: summary, model: execSpecModel(), iterationId, task, sizeName, runners: [out2.runner], targetDir: join93(ctx.repoDir, dirname39(sealedFiles[0].rel)), generated: sealedFiles.map((f) =>
|
|
32388
|
+
writeFileSync43(join93(sealedDir, basename31(f.rel)), f.text, "utf8");
|
|
32389
|
+
return { kind: "authored", staged: true, execSpec: summary, model: execSpecModel(), iterationId, task, sizeName, runners: [out2.runner], targetDir: join93(ctx.repoDir, dirname39(sealedFiles[0].rel)), generated: sealedFiles.map((f) => basename31(f.rel)), contents: new Map(sealedFiles.map((f) => [basename31(f.rel), f.text])), discarded: [] };
|
|
32355
32390
|
}
|
|
32356
32391
|
function wallInstallReject(repoDir, task, runners, afterImplement) {
|
|
32357
32392
|
if (!afterImplement || !runners.includes("cargo"))
|
|
@@ -32700,11 +32735,11 @@ import { spawnSync as spawnSync12 } from "child_process";
|
|
|
32700
32735
|
import { createHash as createHash22 } from "crypto";
|
|
32701
32736
|
import { chmodSync as chmodSync8, existsSync as existsSync59, mkdirSync as mkdirSync41, readFileSync as readFileSync84, realpathSync as realpathSync33, renameSync as renameSync19, writeFileSync as writeFileSync45 } from "fs";
|
|
32702
32737
|
import { homedir as homedir11 } from "os";
|
|
32703
|
-
import { dirname as dirname41, join as join95, resolve as
|
|
32738
|
+
import { dirname as dirname41, join as join95, resolve as resolve23 } from "path";
|
|
32704
32739
|
function repoName(repoDir) {
|
|
32705
32740
|
const u = (readOriginUrl(repoDir) ?? "").trim();
|
|
32706
32741
|
if (!u)
|
|
32707
|
-
return
|
|
32742
|
+
return resolve23(repoDir);
|
|
32708
32743
|
const m = /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:[^@/]+@)?([^/:]+)[:/](.+?)(?:\.git)?\/?$/i.exec(u);
|
|
32709
32744
|
return m && !u.startsWith("/") ? `${m[1].toLowerCase()}/${m[2]}` : u.replace(/\/+$/, "");
|
|
32710
32745
|
}
|
|
@@ -32818,9 +32853,9 @@ function extractSetup(script, repoDir) {
|
|
|
32818
32853
|
try {
|
|
32819
32854
|
return realpathSync33(repoDir);
|
|
32820
32855
|
} catch {
|
|
32821
|
-
return
|
|
32856
|
+
return resolve23(repoDir);
|
|
32822
32857
|
}
|
|
32823
|
-
})(), names = [...new Set([real3,
|
|
32858
|
+
})(), names = [...new Set([real3, resolve23(repoDir), real3.replace(/^\/private\//, "/")])].filter((d) => d.length > 5).sort((a, b) => b.length - a.length);
|
|
32824
32859
|
let swapped = false;
|
|
32825
32860
|
for (const d of names)
|
|
32826
32861
|
if (text3.includes(d)) {
|
|
@@ -33222,7 +33257,7 @@ var init_context = __esm(() => {
|
|
|
33222
33257
|
|
|
33223
33258
|
// ../../loki-ts/src/engine10/proof_rerun.ts
|
|
33224
33259
|
import { createHash as createHash23, randomBytes as randomBytes7 } from "crypto";
|
|
33225
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync60, mkdirSync as mkdirSync42, readdirSync as readdirSync36, readFileSync as readFileSync85, realpathSync as realpathSync34, rmSync as rmSync29, statfsSync, statSync as
|
|
33260
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync60, mkdirSync as mkdirSync42, readdirSync as readdirSync36, readFileSync as readFileSync85, realpathSync as realpathSync34, rmSync as rmSync29, statfsSync, statSync as statSync31, writeFileSync as writeFileSync46 } from "fs";
|
|
33226
33261
|
import { dirname as dirname42, join as join96, relative as relative20 } from "path";
|
|
33227
33262
|
function labelAsks(provider, intake, plan, repoDir, env = process.env) {
|
|
33228
33263
|
if (!issueAcceptanceCapOn(env))
|
|
@@ -33336,7 +33371,7 @@ function keepProofScript(scratchDir, runDir) {
|
|
|
33336
33371
|
const src = join96(scratchDir, PROOF_SCRIPT);
|
|
33337
33372
|
if (!existsSync60(src))
|
|
33338
33373
|
return false;
|
|
33339
|
-
const st =
|
|
33374
|
+
const st = statSync31(src);
|
|
33340
33375
|
if (!st.isFile() || st.size === 0 || st.size > MAX_SCRIPT_BYTES)
|
|
33341
33376
|
return false;
|
|
33342
33377
|
const real3 = (() => {
|
|
@@ -33353,7 +33388,7 @@ function keepProofScript(scratchDir, runDir) {
|
|
|
33353
33388
|
for (const f of HANDED) {
|
|
33354
33389
|
try {
|
|
33355
33390
|
const su = join96(scratchDir, f);
|
|
33356
|
-
if (existsSync60(su) &&
|
|
33391
|
+
if (existsSync60(su) && statSync31(su).size <= MAX_SCRIPT_BYTES) {
|
|
33357
33392
|
let t = readFileSync85(su, "utf8");
|
|
33358
33393
|
if (f === SETUP_FILE2)
|
|
33359
33394
|
for (const d of names)
|
|
@@ -34172,7 +34207,7 @@ async function issueLineCheck(ctx, asks2, head, checks, reply, facts = []) {
|
|
|
34172
34207
|
return { model, outcome: "no_diff", usd: null, calls: 0, input_chars: 0, diff_cut: [], diff_truncated: false, not_reviewed: "the diff could not be read" };
|
|
34173
34208
|
const cd = lineCheckDiff(d.stdout), prompt = lineCheckPrompt(asks2, cd.text, (n3?.stdout ?? "").split(`
|
|
34174
34209
|
`).filter(Boolean), checks, reply, facts);
|
|
34175
|
-
const call = lineCheckOverride ?? consultCallFor(model, join99(ctx.repoDir, ".loki"), process.env, 120000, { maxTokens:
|
|
34210
|
+
const call = lineCheckOverride ?? consultCallFor(model, join99(ctx.repoDir, ".loki"), process.env, 120000, { maxTokens: 8000, thinking: "off" });
|
|
34176
34211
|
let usd = null, calls = 0, outcome = "failed", parsed = null;
|
|
34177
34212
|
for (let i = 0;i < 2 && !parsed; i++) {
|
|
34178
34213
|
let r;
|
|
@@ -34320,7 +34355,7 @@ var init_implement_route = __esm(() => {
|
|
|
34320
34355
|
|
|
34321
34356
|
// ../../loki-ts/src/features/patch_protocol.ts
|
|
34322
34357
|
import { existsSync as existsSync63, lstatSync as lstatSync26, mkdirSync as mkdirSync45, readFileSync as readFileSync88, realpathSync as realpathSync35, rmSync as rmSync30, writeFileSync as writeFileSync49 } from "fs";
|
|
34323
|
-
import { basename as
|
|
34358
|
+
import { basename as basename32, dirname as dirname43, join as join100, normalize as normalize5, relative as relative21, sep as sep20 } from "path";
|
|
34324
34359
|
function buildPatchBrief(task, code, conventions, checkCmds) {
|
|
34325
34360
|
return [
|
|
34326
34361
|
PATCH_RULES,
|
|
@@ -34376,7 +34411,7 @@ function refusal(rules, rel, before, after) {
|
|
|
34376
34411
|
return "inside .git or .loki";
|
|
34377
34412
|
if (WALL_FILE.test(n3) || rules.readOnly.includes(n3))
|
|
34378
34413
|
return "a read-only Wall test";
|
|
34379
|
-
if (LOCKFILES.has(
|
|
34414
|
+
if (LOCKFILES.has(basename32(n3)) && !taskWantsLockChange(rules.task, n3))
|
|
34380
34415
|
return "a lockfile the task does not ask to change";
|
|
34381
34416
|
if (steersRunner(n3, before ?? "", after))
|
|
34382
34417
|
return "a test-runner or compiler config (it steers how tests run)";
|
|
@@ -35196,6 +35231,30 @@ ${r.session.summary}` };
|
|
|
35196
35231
|
let reviewedEarly = false, earlyReviewCost = null;
|
|
35197
35232
|
let proofFails = 0, lineTurns = 0;
|
|
35198
35233
|
const LINE_TURNS_MAX = 2;
|
|
35234
|
+
const reviewRound = async (tree) => {
|
|
35235
|
+
if (reviewedEarly || !reviewFixOn())
|
|
35236
|
+
return false;
|
|
35237
|
+
reviewedEarly = true;
|
|
35238
|
+
const xr = await crossReview(ctx, "VERIFIED", tree, signal, true);
|
|
35239
|
+
if (xr?.cost_iteration)
|
|
35240
|
+
earlyReviewCost = xr.cost_iteration;
|
|
35241
|
+
const found = xr && (xr.level === "block" || xr.level === "flag") ? xr.notes.filter((n3) => /^cross-review (block|flag) /.test(n3) || isUnmetNote(n3)).slice(0, 8) : [];
|
|
35242
|
+
ctx.emit("review.early", "implement", { level: xr?.level ?? "not_run", findings: found.length });
|
|
35243
|
+
if (!found.length)
|
|
35244
|
+
return false;
|
|
35245
|
+
const r3 = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, [`An independent reviewer read your whole change and found ${found.length} problem${found.length === 1 ? "" : "s"}:`, "", ...found.map((n3, i) => `${i + 1}. ${n3.replace(/^cross-review \w+ \([^)]*\):\s*/, "")}`), "", "Check each one against the code. Where the reviewer is right, fix the product (and the documentation when the two disagree), add a check for it to $LOKI_SCRATCH/loki-proof.sh under the acceptance item it belongs to, and run the proof again until it passes. Where the reviewer is wrong, say why in one line and change nothing for it. Do not remove or loosen an existing check. End with the same finish line as before."].join(`
|
|
35246
|
+
`));
|
|
35247
|
+
if (r3.iterationId !== ids[ids.length - 1])
|
|
35248
|
+
ids.push(r3.iterationId);
|
|
35249
|
+
else
|
|
35250
|
+
return false;
|
|
35251
|
+
if (r3.session.summary)
|
|
35252
|
+
session = { ...session, summary: `${session.summary ?? ""}
|
|
35253
|
+
|
|
35254
|
+
[after the independent review]
|
|
35255
|
+
${r3.session.summary}` };
|
|
35256
|
+
return true;
|
|
35257
|
+
};
|
|
35199
35258
|
for (let round2 = 0;proofFails < proofLoopMax() && scratch && proofRerunOn() && existsSync64(join101(scratch.dir, PROOF_SCRIPT)) && !signal.aborted && !session.killed && session.exit === 0 && !session.markers.specConflict && !session.markers.alreadyDone; round2++) {
|
|
35200
35259
|
if (!keepProofScript(scratch.dir, ctx.runDir))
|
|
35201
35260
|
break;
|
|
@@ -35212,8 +35271,14 @@ ${r.session.summary}` };
|
|
|
35212
35271
|
}
|
|
35213
35272
|
if (pr.exit === 0 && pr.failed === 0) {
|
|
35214
35273
|
const la = labelAsks(ctx.provider, prior.intake, prior.plan, ctx.repoDir);
|
|
35215
|
-
if (!la.asks.length
|
|
35274
|
+
if (!la.asks.length)
|
|
35216
35275
|
break;
|
|
35276
|
+
if (lineTurns >= LINE_TURNS_MAX) {
|
|
35277
|
+
const t = await worktreeTree(ctx.repoDir);
|
|
35278
|
+
if (t && await reviewRound(t))
|
|
35279
|
+
continue;
|
|
35280
|
+
break;
|
|
35281
|
+
}
|
|
35217
35282
|
const tree = await worktreeTree(ctx.repoDir);
|
|
35218
35283
|
if (!tree)
|
|
35219
35284
|
break;
|
|
@@ -35233,28 +35298,9 @@ ${r.session.summary}` };
|
|
|
35233
35298
|
lineRounds.push({ met: lc.marks?.met.length ?? 0, unmet: unmet.length, usd: lc.usd });
|
|
35234
35299
|
ctx.emit("acceptance.round", "implement", { round: round2 + 1, met: la.asks.length - lineUnmet, unmet: lineUnmet, ...empty.size ? { pass_on_base_too: empty.size } : {}, ...unmet.length > lineUnmet ? { unused_new_files: unmet.length - lineUnmet } : {} });
|
|
35235
35300
|
if (!unmet.length) {
|
|
35236
|
-
if (
|
|
35237
|
-
|
|
35238
|
-
|
|
35239
|
-
const xr = await crossReview(ctx, "VERIFIED", tree, signal, true);
|
|
35240
|
-
if (xr?.cost_iteration)
|
|
35241
|
-
earlyReviewCost = xr.cost_iteration;
|
|
35242
|
-
const found = xr && (xr.level === "block" || xr.notes.some(isUnmetNote)) ? xr.notes.filter((n3) => /^cross-review (block|flag) /.test(n3) || isUnmetNote(n3)).slice(0, 8) : [];
|
|
35243
|
-
ctx.emit("review.early", "implement", { level: xr?.level ?? "not_run", findings: found.length });
|
|
35244
|
-
if (!found.length)
|
|
35245
|
-
break;
|
|
35246
|
-
const r3 = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, [`An independent reviewer read your whole change and found ${found.length} problem${found.length === 1 ? "" : "s"}:`, "", ...found.map((n3, i) => `${i + 1}. ${n3.replace(/^cross-review \w+ \([^)]*\):\s*/, "")}`), "", "Check each one against the code. Where the reviewer is right, fix the product (and the documentation when the two disagree), add a check for it to $LOKI_SCRATCH/loki-proof.sh under the acceptance item it belongs to, and run the proof again until it passes. Where the reviewer is wrong, say why in one line and change nothing for it. Do not remove or loosen an existing check. End with the same finish line as before."].join(`
|
|
35247
|
-
`));
|
|
35248
|
-
if (r3.iterationId !== ids[ids.length - 1])
|
|
35249
|
-
ids.push(r3.iterationId);
|
|
35250
|
-
else
|
|
35251
|
-
break;
|
|
35252
|
-
if (r3.session.summary)
|
|
35253
|
-
session = { ...session, summary: `${session.summary ?? ""}
|
|
35254
|
-
|
|
35255
|
-
[after the independent review]
|
|
35256
|
-
${r3.session.summary}` };
|
|
35257
|
-
continue;
|
|
35301
|
+
if (await reviewRound(tree))
|
|
35302
|
+
continue;
|
|
35303
|
+
break;
|
|
35258
35304
|
}
|
|
35259
35305
|
const stray = Object.keys(pr.lines).filter((k) => Number(k) > la.asks.length || Number(k) < 1);
|
|
35260
35306
|
const r2 = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, unmetBrief(unmet, stray.length ? `Your proof script passes, but ${stray.length} of its check numbers (${stray.slice(0, 6).join(", ")}) are not acceptance item numbers, so those checks count for no item. The first argument of loki_http and loki_cmd is the item's number in $LOKI_SCRATCH/acceptance.txt (1 to ${la.asks.length}), never a line number of the script. Renumber them.` : ""));
|
|
@@ -35481,7 +35527,7 @@ var init_run_control = __esm(() => {
|
|
|
35481
35527
|
|
|
35482
35528
|
// ../../loki-ts/src/providers/provider_guard.ts
|
|
35483
35529
|
import { copyFileSync as copyFileSync6, existsSync as existsSync66, lstatSync as lstatSync27, mkdirSync as mkdirSync47, readFileSync as readFileSync91, readdirSync as readdirSync37, readlinkSync as readlinkSync4, realpathSync as realpathSync36, rmSync as rmSync32 } from "fs";
|
|
35484
|
-
import { dirname as dirname44, isAbsolute as isAbsolute16, join as join103, relative as relative23, resolve as
|
|
35530
|
+
import { dirname as dirname44, isAbsolute as isAbsolute16, join as join103, relative as relative23, resolve as resolve24 } from "path";
|
|
35485
35531
|
function providerSandboxFlags(provider) {
|
|
35486
35532
|
return [];
|
|
35487
35533
|
}
|
|
@@ -35504,7 +35550,7 @@ function isRepoDeletion(deleted, tracked) {
|
|
|
35504
35550
|
function escapesProject(root, linkPath) {
|
|
35505
35551
|
try {
|
|
35506
35552
|
const target = readlinkSync4(linkPath);
|
|
35507
|
-
const abs = isAbsolute16(target) ? target :
|
|
35553
|
+
const abs = isAbsolute16(target) ? target : resolve24(dirname44(linkPath), target);
|
|
35508
35554
|
const rel = relative23(realpathSync36(root), existsSync66(abs) ? realpathSync36(abs) : abs);
|
|
35509
35555
|
return rel.startsWith("..") || isAbsolute16(rel);
|
|
35510
35556
|
} catch {
|
|
@@ -35655,7 +35701,7 @@ var init_provider_guard = __esm(() => {
|
|
|
35655
35701
|
|
|
35656
35702
|
// ../../loki-ts/src/e10ext/budget_cap.ts
|
|
35657
35703
|
import { appendFileSync as appendFileSync9, existsSync as existsSync67, mkdirSync as mkdirSync48, readdirSync as readdirSync38, readFileSync as readFileSync92, writeFileSync as writeFileSync52 } from "fs";
|
|
35658
|
-
import { join as join104, resolve as
|
|
35704
|
+
import { join as join104, resolve as resolve25 } from "path";
|
|
35659
35705
|
function hasApiKey(env) {
|
|
35660
35706
|
return ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "OPENROUTER_API_KEY", "LOKI_MODEL_API_KEY"].some((k) => (env[k] ?? "") !== "");
|
|
35661
35707
|
}
|
|
@@ -35697,11 +35743,11 @@ function groupEnv(env, capUsd, repoDir) {
|
|
|
35697
35743
|
const out2 = { ...env, LOKI_BUDGET_LIMIT: String(capUsd) };
|
|
35698
35744
|
if (repoDir && !out2.LOKI_BUDGET_LEDGER) {
|
|
35699
35745
|
try {
|
|
35700
|
-
const d = join104(
|
|
35746
|
+
const d = join104(resolve25(repoDir), ".loki", "runs");
|
|
35701
35747
|
mkdirSync48(d, { recursive: true });
|
|
35702
35748
|
out2.LOKI_BUDGET_LEDGER = join104(d, `group-${process.pid}-${Date.now()}.ledger`);
|
|
35703
35749
|
} catch (e) {
|
|
35704
|
-
out2.LOKI_BUDGET_LEDGER = join104(
|
|
35750
|
+
out2.LOKI_BUDGET_LEDGER = join104(resolve25(repoDir), ".loki", "runs", "unusable", "group.ledger");
|
|
35705
35751
|
process.stderr.write(`budget: cannot create the shared ledger dir (${e instanceof Error ? e.message : String(e)}); units will stop, failing closed
|
|
35706
35752
|
`);
|
|
35707
35753
|
}
|
|
@@ -35711,7 +35757,7 @@ function groupEnv(env, capUsd, repoDir) {
|
|
|
35711
35757
|
function capMeter(raw2, env, onBudget, childDelta) {
|
|
35712
35758
|
const capUsd = parseCapUsd(env.LOKI_E10_MAX_COST_USD) ?? 0, seed = Number(env.LOKI_E10_SPENT_USD);
|
|
35713
35759
|
const m = costMeter(capUsd, seed);
|
|
35714
|
-
const ledger2 = env.LOKI_BUDGET_LEDGER ?
|
|
35760
|
+
const ledger2 = env.LOKI_BUDGET_LEDGER ? resolve25(env.LOKI_BUDGET_LEDGER) : "";
|
|
35715
35761
|
let broken = false;
|
|
35716
35762
|
if (ledger2) {
|
|
35717
35763
|
try {
|
|
@@ -37225,7 +37271,7 @@ var init_prove = __esm(() => {
|
|
|
37225
37271
|
|
|
37226
37272
|
// ../../loki-ts/src/version.ts
|
|
37227
37273
|
import { readFileSync as readFileSync94 } from "fs";
|
|
37228
|
-
import { resolve as
|
|
37274
|
+
import { resolve as resolve26, dirname as dirname46 } from "path";
|
|
37229
37275
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
37230
37276
|
function getVersion() {
|
|
37231
37277
|
if (_version !== null)
|
|
@@ -37238,7 +37284,7 @@ function getVersion() {
|
|
|
37238
37284
|
try {
|
|
37239
37285
|
const here = dirname46(fileURLToPath4(import.meta.url));
|
|
37240
37286
|
const repoRoot = findRepoRootForVersion(here);
|
|
37241
|
-
_version = readFileSync94(
|
|
37287
|
+
_version = readFileSync94(resolve26(repoRoot, "VERSION"), "utf-8").trim();
|
|
37242
37288
|
} catch {
|
|
37243
37289
|
_version = "unknown";
|
|
37244
37290
|
}
|
|
@@ -38015,7 +38061,7 @@ var init_receipt_dsse = __esm(() => {
|
|
|
38015
38061
|
import { createPublicKey as createPublicKey4 } from "crypto";
|
|
38016
38062
|
import { cpSync as cpSync4, copyFileSync as copyFileSync7, existsSync as existsSync72, mkdirSync as mkdirSync53, readdirSync as readdirSync41, readFileSync as readFileSync97, renameSync as renameSync21, rmSync as rmSync35, writeFileSync as writeFileSync56 } from "fs";
|
|
38017
38063
|
import { homedir as homedir12 } from "os";
|
|
38018
|
-
import { basename as
|
|
38064
|
+
import { basename as basename33, dirname as dirname48, join as join109, normalize as normalize7 } from "path";
|
|
38019
38065
|
function publicJwk(pub) {
|
|
38020
38066
|
const { kty, crv, x } = pub.export({ format: "jwk" });
|
|
38021
38067
|
return JSON.stringify({ kty, crv, x, kid: kidOf2(pub), alg: "EdDSA", use: "sig" });
|
|
@@ -38042,7 +38088,7 @@ async function buildPassport(runDir, env = process.env) {
|
|
|
38042
38088
|
return { missing: "receipt holds local paths; passport not published (run loki proof bundle)" };
|
|
38043
38089
|
const envelope = JSON.stringify(signEnvelope(parsed, priv, kid)), jwk = publicJwk(pub);
|
|
38044
38090
|
if (envelope.length + jwk.length > PASSPORT_MAX)
|
|
38045
|
-
return { missing: `passport too large for a PR comment (${envelope.length + jwk.length} bytes); run loki proof bundle ${
|
|
38091
|
+
return { missing: `passport too large for a PR comment (${envelope.length + jwk.length} bytes); run loki proof bundle ${basename33(runDir)}` };
|
|
38046
38092
|
return { envelope, jwk, kid, head: String(parsed["head_sha"]) };
|
|
38047
38093
|
} catch (e) {
|
|
38048
38094
|
return { missing: `passport not issued: ${e instanceof Error ? e.message.split(`
|
|
@@ -38193,12 +38239,12 @@ var init_outbox = __esm(() => {
|
|
|
38193
38239
|
// ../../loki-ts/src/util/failure_memory.ts
|
|
38194
38240
|
import { createHash as createHash26 } from "crypto";
|
|
38195
38241
|
import { appendFileSync as appendFileSync10, existsSync as existsSync74, mkdirSync as mkdirSync55, readFileSync as readFileSync99, renameSync as renameSync23, writeFileSync as writeFileSync57 } from "fs";
|
|
38196
|
-
import { resolve as
|
|
38242
|
+
import { resolve as resolve27 } from "path";
|
|
38197
38243
|
function failureFingerprint(cls, name) {
|
|
38198
38244
|
return createHash26("sha256").update(`${cls}\x00${name}`).digest("hex").slice(0, 16);
|
|
38199
38245
|
}
|
|
38200
38246
|
function readFingerprints(dir) {
|
|
38201
|
-
const p =
|
|
38247
|
+
const p = resolve27(dir, "fingerprints.jsonl");
|
|
38202
38248
|
if (!existsSync74(p))
|
|
38203
38249
|
return [];
|
|
38204
38250
|
try {
|
|
@@ -38220,7 +38266,7 @@ function recordFingerprints(dir, runId, cls, names, tree = "") {
|
|
|
38220
38266
|
if (list.length === 0)
|
|
38221
38267
|
return list;
|
|
38222
38268
|
try {
|
|
38223
|
-
const p =
|
|
38269
|
+
const p = resolve27(dir, "fingerprints.jsonl");
|
|
38224
38270
|
mkdirSync55(dir, { recursive: true });
|
|
38225
38271
|
const ts = new Date().toISOString();
|
|
38226
38272
|
appendFileSync10(p, `${list.map((name) => JSON.stringify({ ts, run: runId, cls, fp: failureFingerprint(cls, name), name, ...tree !== "" ? { tree } : {} })).join(`
|
|
@@ -40316,7 +40362,7 @@ var init_contract = __esm(() => {
|
|
|
40316
40362
|
|
|
40317
40363
|
// ../../loki-ts/src/features/speed/seal_group.ts
|
|
40318
40364
|
import { createHash as createHash29 } from "crypto";
|
|
40319
|
-
import { existsSync as existsSync77, mkdirSync as mkdirSync59, readdirSync as readdirSync42, readFileSync as readFileSync103, renameSync as renameSync24, statSync as
|
|
40365
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync59, readdirSync as readdirSync42, readFileSync as readFileSync103, renameSync as renameSync24, statSync as statSync33, writeFileSync as writeFileSync61 } from "fs";
|
|
40320
40366
|
import { dirname as dirname51, join as join114 } from "path";
|
|
40321
40367
|
function sealGroup(runDir, rh) {
|
|
40322
40368
|
const manifestPath = join114(runDir, "group", "manifest.json");
|
|
@@ -40408,7 +40454,7 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
40408
40454
|
return bad(`unit ${id} is out of order (index ${String(e["index"])} at position ${i})`);
|
|
40409
40455
|
let bytes;
|
|
40410
40456
|
try {
|
|
40411
|
-
if (!
|
|
40457
|
+
if (!statSync33(dir).isDirectory())
|
|
40412
40458
|
return bad(`unit ${id} is not a directory`);
|
|
40413
40459
|
bytes = readFileSync103(rp);
|
|
40414
40460
|
} catch {
|
|
@@ -40478,8 +40524,8 @@ var init_seal_group = __esm(() => {
|
|
|
40478
40524
|
});
|
|
40479
40525
|
|
|
40480
40526
|
// ../../loki-ts/src/supply/supply_guard.ts
|
|
40481
|
-
import { existsSync as existsSync78, readFileSync as readFileSync104, statSync as
|
|
40482
|
-
import { basename as
|
|
40527
|
+
import { existsSync as existsSync78, readFileSync as readFileSync104, statSync as statSync34 } from "fs";
|
|
40528
|
+
import { basename as basename34, join as join115 } from "path";
|
|
40483
40529
|
function supplyEnabled(env) {
|
|
40484
40530
|
return env["LOKI_SUPPLY_GUARD"] !== "0";
|
|
40485
40531
|
}
|
|
@@ -40491,14 +40537,14 @@ function supplyVerdict(verdict, r) {
|
|
|
40491
40537
|
return r.blocked && verdict === "VERIFIED" ? "FAILED" : verdict;
|
|
40492
40538
|
}
|
|
40493
40539
|
function isManifestPath(path) {
|
|
40494
|
-
return MANIFESTS3.test(
|
|
40540
|
+
return MANIFESTS3.test(basename34(path));
|
|
40495
40541
|
}
|
|
40496
40542
|
function readDeclared(repoDir) {
|
|
40497
40543
|
const p = join115(repoDir, ".loki", DECLARED_FILE);
|
|
40498
40544
|
if (!existsSync78(p))
|
|
40499
40545
|
return { deps: [], problem: null };
|
|
40500
40546
|
try {
|
|
40501
|
-
if (
|
|
40547
|
+
if (statSync34(p).size > MAX_FILE_BYTES)
|
|
40502
40548
|
return { deps: [], problem: "declaration file too large" };
|
|
40503
40549
|
const j = JSON.parse(readFileSync104(p, "utf8"));
|
|
40504
40550
|
if (!Array.isArray(j))
|
|
@@ -40707,7 +40753,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
|
|
|
40707
40753
|
}
|
|
40708
40754
|
}, PUBLIC_HOSTS, hostOf = (u) => u.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^www\./, "").split(/[/?#\s]/)[0].replace(/^[^@]*@/, "").replace(/:\d+$/, ""), privateUrl = (u) => /[a-z0-9]/i.test(u) && !PUBLIC_HOSTS.has(hostOf(u)), readSmall2 = (p) => {
|
|
40709
40755
|
try {
|
|
40710
|
-
return
|
|
40756
|
+
return statSync34(p).size <= MAX_FILE_BYTES ? readFileSync104(p, "utf8") : "";
|
|
40711
40757
|
} catch {
|
|
40712
40758
|
return "";
|
|
40713
40759
|
}
|
|
@@ -40767,7 +40813,7 @@ __export(exports_seal, {
|
|
|
40767
40813
|
import { createHash as createHash30 } from "crypto";
|
|
40768
40814
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
40769
40815
|
import { existsSync as existsSync79, readdirSync as readdirSync43, mkdirSync as mkdirSync60, readFileSync as readFileSync105, rmSync as rmSync38 } from "fs";
|
|
40770
|
-
import { basename as
|
|
40816
|
+
import { basename as basename35, isAbsolute as isAbsolute19, join as join116, relative as relative27 } from "path";
|
|
40771
40817
|
function missingLintChecks(vraw, env = process.env) {
|
|
40772
40818
|
if (/^(0|off|false|no)$/i.test((env["LOKI_E10_LINT_MISSING_DISCLOSE"] ?? "").trim()))
|
|
40773
40819
|
return [];
|
|
@@ -41215,7 +41261,20 @@ var init_seal = __esm(() => {
|
|
|
41215
41261
|
const DECLARED_SUFFIX = " (declared by the plan or required by the passing Wall; disclosed, does not cap)";
|
|
41216
41262
|
const grp = sealGroup(ctx.runDir, receiptSha256);
|
|
41217
41263
|
const lintGone = missingLintChecks(Array.isArray(o.verify?.checks) ? o.verify.checks : []);
|
|
41218
|
-
const
|
|
41264
|
+
const proofText = (() => {
|
|
41265
|
+
try {
|
|
41266
|
+
return readFileSync105(join116(ctx.runDir, PROOF_SCRIPT), "utf8");
|
|
41267
|
+
} catch {
|
|
41268
|
+
return "";
|
|
41269
|
+
}
|
|
41270
|
+
})();
|
|
41271
|
+
const proofOnly = proofText ? checks.filter((c) => {
|
|
41272
|
+
if (c.result !== "not_run")
|
|
41273
|
+
return false;
|
|
41274
|
+
const f = c.name.slice(c.name.indexOf(":") + 1), b = f.slice(f.lastIndexOf("/") + 1);
|
|
41275
|
+
return b.length > 5 && pctx.addedFiles.some((a) => a === f || a.endsWith(`/${f}`)) && proofText.includes(b);
|
|
41276
|
+
}).map((c) => c.name) : [];
|
|
41277
|
+
const live2 = checks.filter((c) => !(c.result === "fail" && preRedChecks.includes(c.name)) && c.repo_skipped !== true && !lintGone.includes(c.name) && !proofOnly.includes(c.name)), executed = hasExecutedProof(vraw), strictProof = process.env["LOKI_EXOGENOUS_PROOF"] !== "0", noWall = !(Array.isArray(o.wall?.files) && o.wall.files.length > 0);
|
|
41219
41278
|
const ftpGate = strictProof && noWall && diffOk && !externalRun(o) && o.intake?.already_satisfied !== true && o.implement?.exit !== "already_done" && weakTests.length === 0 && !live2.some((c) => c.result === "fail") && mutationEnabled();
|
|
41220
41279
|
const pinEdits = diffOk ? rawDiff.flatMap((m, i) => {
|
|
41221
41280
|
const st = m.trim().split(" ").pop() ?? "";
|
|
@@ -41280,7 +41339,8 @@ var init_seal = __esm(() => {
|
|
|
41280
41339
|
const issueSt = byRule ? byRule.map((r, i) => ({ ...r, ...advisory && advisory[i].status === "unmet" && r.status === "met" ? { note: `reviewer note: ${advisory[i].reason ?? ""}`.slice(0, 300) } : {} })) : advisory, issueNotes = !issueSt || verdict3a !== "VERIFIED" ? [] : !byRule && lineCheck?.not_reviewed ? [`acceptance not reviewed: ${lineCheck.not_reviewed}`] : notAddressedNotes(issueSt);
|
|
41281
41340
|
const allLinesMet = !!issueSt && (byRule ? true : !!lineCheck && !lineCheck.not_reviewed) && notAddressedNotes(issueSt).length === 0, unfinished = unfinishedNotes(o.implement);
|
|
41282
41341
|
const proofNotes = proofRun && proofRun.exit !== 0 ? [`Loki's own re-run of the session's proof script did not pass (exit ${proofRun.exit === null ? "none" : proofRun.exit}, ${proofRun.failed} FAILED line(s))`] : [];
|
|
41283
|
-
const
|
|
41342
|
+
const noSecond = !!lineCheck?.not_reviewed;
|
|
41343
|
+
const twoReaders = (xr?.notes ?? []).filter(isUnmetNote).filter((n3) => noSecond || issueAsks.some((line2, i) => advisory?.[i]?.status === "unmet" && n3.toLowerCase().includes(line2.toLowerCase().slice(0, 60)))).map((n3) => noSecond ? `${n3} (the acceptance check did not answer, ${lineCheck.not_reviewed}, so nothing contradicts the review and the count does not carry this line)` : `${n3} (the acceptance check also reads this line as not delivered: two readers agree, so the count does not carry it)`);
|
|
41284
41344
|
const unusedNotes = issueAsks.length ? (await unusedNewFiles(ctx.repoDir, ctx.baseSha, head)).map(unusedNewFileNote) : [];
|
|
41285
41345
|
const openNotes = [...issueNotes, ...proofNotes, ...neverStopNotes(o.implement), ...allLinesMet ? [] : unfinished, ...proveNotes(ctx.provider, o, process.env, ctx.runDir), ...allLinesMet && proofRun?.exit === 0 ? twoReaders : (xr?.notes ?? []).filter(isUnmetNote), ...openDecisionNotes(o), ...namedOpen.filter((s) => s.why === null).map(namedUnchangedNote)], verdict3 = openNotes.length > 0 && verdict3a === "VERIFIED" ? "PARTIAL" : verdict3a;
|
|
41286
41346
|
const deepG = deepGaps(o.verify?.risk, vraw, Array.isArray(o.deep?.checks) ? o.deep.checks : [], modelReviewRan(xr)), notProven2 = new Set([...sealOnlyPass() ? [TIME_RAN_OUT_NOTE] : [], ...deepG.notProven, ...supply.notProven, ...grp.notProven, ...xr?.notes ?? [], ...reviewReceipt(ctx.provider, xr).notProven, ...openNotes]);
|
|
@@ -41330,7 +41390,7 @@ var init_seal = __esm(() => {
|
|
|
41330
41390
|
for (const n3 of strs2(o.fix?.not_proven))
|
|
41331
41391
|
notProven2.add(n3);
|
|
41332
41392
|
if (typeof o.verify?.wall_failure_tail === "string" && o.verify.wall_passed === false) {
|
|
41333
|
-
const tailFile =
|
|
41393
|
+
const tailFile = basename35(o.verify.wall_failure_tail), rel = relative27(ctx.repoDir, join116(ctx.runDir, tailFile));
|
|
41334
41394
|
notProven2.add(`Wall failure output kept: ${rel.startsWith("..") || isAbsolute19(rel) ? `.loki/runs/${ctx.runId}/${tailFile}` : rel}`);
|
|
41335
41395
|
}
|
|
41336
41396
|
for (const x of Array.isArray(o.wall?.arbitrated) ? o.wall.arbitrated : [])
|
|
@@ -41343,7 +41403,7 @@ var init_seal = __esm(() => {
|
|
|
41343
41403
|
notProven2.add(`Wall test not executed: ${wallNotRun} file(s), no reason recorded`);
|
|
41344
41404
|
if (wallNotRun > 0) {
|
|
41345
41405
|
try {
|
|
41346
|
-
const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) =>
|
|
41406
|
+
const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) => basename35(String(f.path))));
|
|
41347
41407
|
for (const n3 of readdirSync43(sealedWallDir(ctx.runDir)).sort())
|
|
41348
41408
|
if (!kept.has(n3))
|
|
41349
41409
|
notProven2.add(`wall test discarded: ${n3} (not_run)`);
|
|
@@ -41385,7 +41445,7 @@ var init_seal = __esm(() => {
|
|
|
41385
41445
|
notProven2.add(`changed, untested after limit: ${f}`);
|
|
41386
41446
|
for (const c of checks)
|
|
41387
41447
|
if (c.result === "not_run" && c.repo_skipped !== true)
|
|
41388
|
-
notProven2.add(lintGone.includes(c.name) ? `${LINT_MISSING_NOTE}: ${c.name}` : `not run: ${c.name}`);
|
|
41448
|
+
notProven2.add(lintGone.includes(c.name) ? `${LINT_MISSING_NOTE}: ${c.name}` : proofOnly.includes(c.name) ? `ran no test in verify, runs in the proof script (a new test gated on the proof's environment; disclosed, does not cap): ${c.name}` : `not run: ${c.name}`);
|
|
41389
41449
|
for (const n3 of repoSkipped)
|
|
41390
41450
|
notProven2.add(`${SKIPPED_BY_REPO}: ${n3}`);
|
|
41391
41451
|
for (const f of strs2(o.verify?.flaky))
|
|
@@ -41597,7 +41657,7 @@ var init_seal = __esm(() => {
|
|
|
41597
41657
|
// ../../loki-ts/src/util/seal_drift.ts
|
|
41598
41658
|
import { createHash as createHash31, createPublicKey as createPublicKey5, sign as sign3, verify as verify4 } from "crypto";
|
|
41599
41659
|
import { existsSync as existsSync80, lstatSync as lstatSync30, readFileSync as readFileSync106, realpathSync as realpathSync39 } from "fs";
|
|
41600
|
-
import { basename as
|
|
41660
|
+
import { basename as basename36, dirname as dirname53, join as join117, relative as relative28 } from "path";
|
|
41601
41661
|
function tornTail(raw2) {
|
|
41602
41662
|
if (raw2 === "" || raw2.endsWith(`
|
|
41603
41663
|
`))
|
|
@@ -41703,7 +41763,7 @@ function currentTaskSha(runDir, source, env) {
|
|
|
41703
41763
|
}
|
|
41704
41764
|
function repoOf(receiptPath) {
|
|
41705
41765
|
const runs2 = dirname53(dirname53(receiptPath));
|
|
41706
|
-
return
|
|
41766
|
+
return basename36(runs2) === "runs" && basename36(dirname53(runs2)) === ".loki" ? dirname53(dirname53(runs2)) : null;
|
|
41707
41767
|
}
|
|
41708
41768
|
function overlap(repo, base2, sealedHead, head) {
|
|
41709
41769
|
if (typeof base2 !== "string" || !/^[0-9a-f]{40,64}$/.test(base2) || !/^[0-9a-f]{40,64}$/.test(sealedHead))
|
|
@@ -41729,7 +41789,7 @@ function onlyWallPublish(repo, r, sealedHead, head) {
|
|
|
41729
41789
|
} catch {
|
|
41730
41790
|
return x;
|
|
41731
41791
|
}
|
|
41732
|
-
}, rr = real4(repo), want = new Map(wall.map((w) => [relative28(rr, join117(real4(dirname53(String(w.path))),
|
|
41792
|
+
}, rr = real4(repo), want = new Map(wall.map((w) => [relative28(rr, join117(real4(dirname53(String(w.path))), basename36(String(w.path)))), String(w.sha256)]));
|
|
41733
41793
|
const commits = safeGit(repo, ["rev-list", "--reverse", "--topo-order", `${sealedHead}..${head}`]).split(`
|
|
41734
41794
|
`).filter(Boolean);
|
|
41735
41795
|
if (commits.length === 0 || safeGit(repo, ["rev-list", "--merges", "--count", `${sealedHead}..${head}`]).trim() !== "0")
|
|
@@ -41767,7 +41827,7 @@ function claimsWallPublish(repo, r, sealedHead, head) {
|
|
|
41767
41827
|
function sealDrift(given, r, env = process.env) {
|
|
41768
41828
|
let receiptPath = given;
|
|
41769
41829
|
try {
|
|
41770
|
-
receiptPath = join117(realpathSync39(dirname53(given)),
|
|
41830
|
+
receiptPath = join117(realpathSync39(dirname53(given)), basename36(given));
|
|
41771
41831
|
} catch {}
|
|
41772
41832
|
const fab = fabricatedPass(receiptPath, r);
|
|
41773
41833
|
if (fab)
|
|
@@ -43434,11 +43494,11 @@ var init_provider = __esm(() => {
|
|
|
43434
43494
|
|
|
43435
43495
|
// ../../loki-ts/src/util/funnel.ts
|
|
43436
43496
|
import { spawn as spawn10 } from "child_process";
|
|
43437
|
-
import { existsSync as existsSync82, readdirSync as readdirSync45, readFileSync as readFileSync109, statSync as
|
|
43438
|
-
import { join as join120, resolve as
|
|
43497
|
+
import { existsSync as existsSync82, readdirSync as readdirSync45, readFileSync as readFileSync109, statSync as statSync36 } from "fs";
|
|
43498
|
+
import { join as join120, resolve as resolve28 } from "path";
|
|
43439
43499
|
function emitFunnel(kind, key, extra = []) {
|
|
43440
43500
|
try {
|
|
43441
|
-
const script =
|
|
43501
|
+
const script = resolve28(REPO_ROOT, "autonomy", "telemetry.sh");
|
|
43442
43502
|
if (!existsSync82(script))
|
|
43443
43503
|
return;
|
|
43444
43504
|
const fn = kind === "first_run_blocked" ? 'loki_emit_first_run_blocked "$2"' : kind === "run_started" ? "loki_emit_run_started" : kind === "run_finished" ? 'loki_emit_run_finished "$2" "${@:3}"' : 'loki_emit_build_verified_enum VERIFIED "$2"';
|
|
@@ -44259,10 +44319,10 @@ __export(exports_doctor, {
|
|
|
44259
44319
|
CLAUDE_LOGIN_TTL_MS: () => CLAUDE_LOGIN_TTL_MS,
|
|
44260
44320
|
AUTH_PROVIDERS: () => AUTH_PROVIDERS
|
|
44261
44321
|
});
|
|
44262
|
-
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync65, mkdirSync as mkdirSync62, accessSync as accessSync3, constants as fsConstants3, existsSync as existsSync84, lstatSync as lstatSync31, readdirSync as readdirSync46, readFileSync as readFileSync111, readlinkSync as readlinkSync6, realpathSync as realpathSync40, statSync as
|
|
44322
|
+
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync65, mkdirSync as mkdirSync62, accessSync as accessSync3, constants as fsConstants3, existsSync as existsSync84, lstatSync as lstatSync31, readdirSync as readdirSync46, readFileSync as readFileSync111, readlinkSync as readlinkSync6, realpathSync as realpathSync40, statSync as statSync37, statfsSync as statfsSync2 } from "fs";
|
|
44263
44323
|
import { spawnSync as spawnSync17 } from "child_process";
|
|
44264
44324
|
import { homedir as homedir15, tmpdir as tmpdir22 } from "os";
|
|
44265
|
-
import { basename as
|
|
44325
|
+
import { basename as basename37, join as join122, resolve as resolve29 } from "path";
|
|
44266
44326
|
function loadRequirements(file = REQUIREMENTS_FILE) {
|
|
44267
44327
|
if (file === REQUIREMENTS_FILE && cached)
|
|
44268
44328
|
return cached;
|
|
@@ -44307,11 +44367,11 @@ function sdkSearchRoots(env, root = REPO_ROOT) {
|
|
|
44307
44367
|
const seam = env["LOKI_SDK_NODE_MODULES"];
|
|
44308
44368
|
if (seam)
|
|
44309
44369
|
return [seam];
|
|
44310
|
-
return [
|
|
44370
|
+
return [resolve29(root, "node_modules"), resolve29(root, "loki-ts/node_modules"), resolve29(root, ".."), resolve29(root, "../..")];
|
|
44311
44371
|
}
|
|
44312
44372
|
function sdkBinaryPath(env, root = REPO_ROOT) {
|
|
44313
44373
|
for (const nm of sdkSearchRoots(env, root)) {
|
|
44314
|
-
const scope =
|
|
44374
|
+
const scope = resolve29(nm, "@anthropic-ai");
|
|
44315
44375
|
if (!existsSync84(scope))
|
|
44316
44376
|
continue;
|
|
44317
44377
|
let names = [];
|
|
@@ -44323,7 +44383,7 @@ function sdkBinaryPath(env, root = REPO_ROOT) {
|
|
|
44323
44383
|
for (const n3 of names) {
|
|
44324
44384
|
if (!n3.startsWith("claude-agent-sdk-"))
|
|
44325
44385
|
continue;
|
|
44326
|
-
const bin =
|
|
44386
|
+
const bin = resolve29(scope, n3, "claude");
|
|
44327
44387
|
try {
|
|
44328
44388
|
accessSync3(bin, fsConstants3.X_OK);
|
|
44329
44389
|
return bin;
|
|
@@ -44549,7 +44609,7 @@ async function probeIntegrations(mfUrl) {
|
|
|
44549
44609
|
}
|
|
44550
44610
|
function loadClaudeCliRange(root = REPO_ROOT) {
|
|
44551
44611
|
try {
|
|
44552
|
-
const cat = JSON.parse(readFileSync111(
|
|
44612
|
+
const cat = JSON.parse(readFileSync111(resolve29(root, "providers/model_catalog.json"), "utf8"));
|
|
44553
44613
|
const cli = cat?.providers?.claude?.cli;
|
|
44554
44614
|
return cli && typeof cli === "object" ? cli : null;
|
|
44555
44615
|
} catch {
|
|
@@ -44570,9 +44630,9 @@ function _setClaudeVersionForTest(fn) {
|
|
|
44570
44630
|
}
|
|
44571
44631
|
function bundledClaudeCodeVersion() {
|
|
44572
44632
|
const rel = "node_modules/@anthropic-ai/claude-agent-sdk/manifest.json";
|
|
44573
|
-
for (const base2 of [
|
|
44633
|
+
for (const base2 of [resolve29(REPO_ROOT, "loki-ts"), REPO_ROOT]) {
|
|
44574
44634
|
try {
|
|
44575
|
-
const v = JSON.parse(readFileSync111(
|
|
44635
|
+
const v = JSON.parse(readFileSync111(resolve29(base2, rel), "utf8"))?.version;
|
|
44576
44636
|
if (typeof v === "string" && v !== "")
|
|
44577
44637
|
return v;
|
|
44578
44638
|
} catch {}
|
|
@@ -44611,9 +44671,9 @@ function checkSkills(selected) {
|
|
|
44611
44671
|
const effective = selected === undefined ? readEffectiveProvider() : selected;
|
|
44612
44672
|
const home = homedir15();
|
|
44613
44673
|
return SKILL_ENTRIES.map(({ name, dir, id }) => {
|
|
44614
|
-
const sdir =
|
|
44674
|
+
const sdir = resolve29(home, dir);
|
|
44615
44675
|
const shortPath = sdir;
|
|
44616
|
-
const skillFile =
|
|
44676
|
+
const skillFile = resolve29(sdir, "SKILL.md");
|
|
44617
44677
|
if (existsSync84(skillFile)) {
|
|
44618
44678
|
return { name, path: shortPath, status: "pass", detail: "", dangling: false };
|
|
44619
44679
|
}
|
|
@@ -44658,7 +44718,7 @@ async function runAllToolChecks() {
|
|
|
44658
44718
|
}));
|
|
44659
44719
|
}
|
|
44660
44720
|
function providerOfferScript() {
|
|
44661
|
-
const p =
|
|
44721
|
+
const p = resolve29(REPO_ROOT, "autonomy/provider-offer.sh");
|
|
44662
44722
|
return existsSync84(p) ? p : null;
|
|
44663
44723
|
}
|
|
44664
44724
|
function readProviderAvailability() {
|
|
@@ -44698,7 +44758,7 @@ async function checkSentrux() {
|
|
|
44698
44758
|
return { found, version: version2, status, required: "optional" };
|
|
44699
44759
|
}
|
|
44700
44760
|
async function checkMemoryHealth() {
|
|
44701
|
-
const { openSync: openSync17, statSync:
|
|
44761
|
+
const { openSync: openSync17, statSync: statSync38, readSync: readSync14, closeSync: closeSync17, existsSync: existsSync85 } = await import("fs");
|
|
44702
44762
|
const { join: join123 } = await import("path");
|
|
44703
44763
|
const TAIL_BYTES2 = 65536;
|
|
44704
44764
|
const lokiDir2 = process.env["LOKI_DIR"] ?? ".loki";
|
|
@@ -44708,7 +44768,7 @@ async function checkMemoryHealth() {
|
|
|
44708
44768
|
try {
|
|
44709
44769
|
if (existsSync85(logPath)) {
|
|
44710
44770
|
exists2 = true;
|
|
44711
|
-
const size =
|
|
44771
|
+
const size = statSync38(logPath).size;
|
|
44712
44772
|
const offset = Math.max(0, size - TAIL_BYTES2);
|
|
44713
44773
|
const len = size - offset;
|
|
44714
44774
|
const buf = Buffer.alloc(len);
|
|
@@ -44738,11 +44798,11 @@ async function checkMemoryHealth() {
|
|
|
44738
44798
|
};
|
|
44739
44799
|
}
|
|
44740
44800
|
function agentSdkFixText(root) {
|
|
44741
|
-
if (existsSync84(
|
|
44801
|
+
if (existsSync84(resolve29(root, "loki-ts/bun.lock")))
|
|
44742
44802
|
return "cd loki-ts && bun install";
|
|
44743
|
-
const parent =
|
|
44744
|
-
if (
|
|
44745
|
-
return
|
|
44803
|
+
const parent = resolve29(root, "..");
|
|
44804
|
+
if (basename37(parent) === "node_modules") {
|
|
44805
|
+
return basename37(resolve29(parent, "..")) === "lib" ? "npm install -g loki-mode@latest" : "npm install loki-mode@latest";
|
|
44746
44806
|
}
|
|
44747
44807
|
return "reinstall loki-mode (npm install -g loki-mode@latest)";
|
|
44748
44808
|
}
|
|
@@ -44755,11 +44815,11 @@ function checkAgentSdkPin(root = REPO_ROOT, env = process.env) {
|
|
|
44755
44815
|
return null;
|
|
44756
44816
|
}
|
|
44757
44817
|
};
|
|
44758
|
-
const deps = readJson7(
|
|
44818
|
+
const deps = readJson7(resolve29(root, "loki-ts/package.json"))?.["dependencies"];
|
|
44759
44819
|
const pinned = typeof deps?.[name] === "string" ? deps[name] : null;
|
|
44760
44820
|
let installed = null;
|
|
44761
44821
|
for (const nm of sdkSearchRoots(env, root)) {
|
|
44762
|
-
const v = readJson7(
|
|
44822
|
+
const v = readJson7(resolve29(nm, name, "package.json"))?.["version"];
|
|
44763
44823
|
if (typeof v === "string" && v !== "") {
|
|
44764
44824
|
installed = v;
|
|
44765
44825
|
break;
|
|
@@ -44780,7 +44840,7 @@ function checkAgentSdkPin(root = REPO_ROOT, env = process.env) {
|
|
|
44780
44840
|
return { status: "pass", pinned, installed, detail: `Agent SDK ${installed} matches the pin` };
|
|
44781
44841
|
}
|
|
44782
44842
|
function describeCatalogFreshness() {
|
|
44783
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
44843
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve29(REPO_ROOT, "providers/model_catalog.json");
|
|
44784
44844
|
let updated;
|
|
44785
44845
|
let ageDays;
|
|
44786
44846
|
try {
|
|
@@ -44855,7 +44915,7 @@ async function checkModelCapabilities(env = process.env) {
|
|
|
44855
44915
|
return { status: "warn", detail: "Skipped: set ANTHROPIC_API_KEY to compare the catalog with models.retrieve", mismatches: [] };
|
|
44856
44916
|
let models;
|
|
44857
44917
|
try {
|
|
44858
|
-
const path = env["LOKI_MODEL_CATALOG"] ||
|
|
44918
|
+
const path = env["LOKI_MODEL_CATALOG"] || resolve29(REPO_ROOT, "providers/model_catalog.json");
|
|
44859
44919
|
models = JSON.parse(readFileSync111(path, "utf-8")).providers?.claude?.models;
|
|
44860
44920
|
if (!Array.isArray(models))
|
|
44861
44921
|
throw new Error("no claude models");
|
|
@@ -45290,7 +45350,7 @@ async function runText(deps = {}) {
|
|
|
45290
45350
|
}
|
|
45291
45351
|
if (!anyProvider) {
|
|
45292
45352
|
let sdkUsable = claudeSdkReady(process.env);
|
|
45293
|
-
const sdkOfferScript =
|
|
45353
|
+
const sdkOfferScript = resolve29(REPO_ROOT, "autonomy/provider-offer.sh");
|
|
45294
45354
|
if (!sdkUsable && existsSync84(sdkOfferScript)) {
|
|
45295
45355
|
const probe = helperSpawn("bash", [sdkOfferScript, "detect-sdk"], { stdio: "ignore" });
|
|
45296
45356
|
sdkUsable = probe.status === 0;
|
|
@@ -45312,7 +45372,7 @@ async function runText(deps = {}) {
|
|
|
45312
45372
|
bump(tally, "fail");
|
|
45313
45373
|
tally.blockers.push("No AI provider CLI. Fix: npm install -g @anthropic-ai/claude-code");
|
|
45314
45374
|
if (process.stdout.isTTY) {
|
|
45315
|
-
const offerScript =
|
|
45375
|
+
const offerScript = resolve29(REPO_ROOT, "autonomy/provider-offer.sh");
|
|
45316
45376
|
if (existsSync84(offerScript)) {
|
|
45317
45377
|
spawnSync17("bash", [offerScript, "report"], { env: tokenFreeEnv(), stdio: "inherit" });
|
|
45318
45378
|
}
|
|
@@ -45709,7 +45769,7 @@ async function runText(deps = {}) {
|
|
|
45709
45769
|
];
|
|
45710
45770
|
const missingDetectors = [];
|
|
45711
45771
|
for (const det of detectors) {
|
|
45712
|
-
if (existsSync84(
|
|
45772
|
+
if (existsSync84(resolve29(REPO_ROOT, "tests", `${det}.sh`))) {
|
|
45713
45773
|
bump(tally, "pass");
|
|
45714
45774
|
} else {
|
|
45715
45775
|
missingDetectors.push(`${det}.sh`);
|
|
@@ -45739,7 +45799,7 @@ async function runText(deps = {}) {
|
|
|
45739
45799
|
const isExec = (p) => {
|
|
45740
45800
|
try {
|
|
45741
45801
|
accessSync3(p, fsConstants3.X_OK);
|
|
45742
|
-
return
|
|
45802
|
+
return statSync37(p).isFile();
|
|
45743
45803
|
} catch {
|
|
45744
45804
|
return false;
|
|
45745
45805
|
}
|
|
@@ -45760,7 +45820,7 @@ async function runText(deps = {}) {
|
|
|
45760
45820
|
seen.add(real4);
|
|
45761
45821
|
if (real4 === runningReal)
|
|
45762
45822
|
continue;
|
|
45763
|
-
const pj =
|
|
45823
|
+
const pj = resolve29(real4, "..", "..", "package.json");
|
|
45764
45824
|
let ver = "";
|
|
45765
45825
|
try {
|
|
45766
45826
|
ver = String(JSON.parse(readFileSync111(pj, "utf8")).version ?? "");
|
|
@@ -45838,7 +45898,7 @@ async function runText(deps = {}) {
|
|
|
45838
45898
|
`);
|
|
45839
45899
|
}
|
|
45840
45900
|
const id = process.env["LOKI_PROVIDER"] || readEffectiveProvider() || "claude";
|
|
45841
|
-
const modelRun = helperSpawn("bash", ["-c", 'source "$1" >/dev/null 2>&1; printf %s "${PROVIDER_MODEL_DEVELOPMENT:-}"', "_",
|
|
45901
|
+
const modelRun = helperSpawn("bash", ["-c", 'source "$1" >/dev/null 2>&1; printf %s "${PROVIDER_MODEL_DEVELOPMENT:-}"', "_", resolve29(REPO_ROOT, "providers", `${id}.sh`)], { encoding: "utf8" });
|
|
45842
45902
|
const model = (modelRun.stdout ?? "").toString().trim() || "default";
|
|
45843
45903
|
const { createPublicKey: createPublicKey6 } = await import("crypto");
|
|
45844
45904
|
const signer = await Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer));
|
|
@@ -46026,7 +46086,7 @@ var init_doctor = __esm(() => {
|
|
|
46026
46086
|
init_model_routes();
|
|
46027
46087
|
init_js_resolve();
|
|
46028
46088
|
init_types();
|
|
46029
|
-
REQUIREMENTS_FILE =
|
|
46089
|
+
REQUIREMENTS_FILE = resolve29(REPO_ROOT, "autonomy/lib/setup-requirements.json");
|
|
46030
46090
|
VERSION_NUMBER_RE = /(\d+\.\d+(?:\.\d+)*)/;
|
|
46031
46091
|
pyImpl = { fn: pythonImportOk };
|
|
46032
46092
|
LSP_BINS = [
|
|
@@ -46086,7 +46146,7 @@ __export(exports_first_run_repo, {
|
|
|
46086
46146
|
initEmptyRepo: () => initEmptyRepo,
|
|
46087
46147
|
NOT_A_REPO: () => NOT_A_REPO
|
|
46088
46148
|
});
|
|
46089
|
-
import { readdirSync as readdirSync47, statSync as
|
|
46149
|
+
import { readdirSync as readdirSync47, statSync as statSync38 } from "fs";
|
|
46090
46150
|
import { join as join123 } from "path";
|
|
46091
46151
|
async function initEmptyRepo(dir, env) {
|
|
46092
46152
|
if (env["LOKI_AUTO_GIT_INIT"] === "0")
|
|
@@ -46095,7 +46155,7 @@ async function initEmptyRepo(dir, env) {
|
|
|
46095
46155
|
let empty = false, written = [];
|
|
46096
46156
|
const isFile2 = (f) => {
|
|
46097
46157
|
try {
|
|
46098
|
-
return
|
|
46158
|
+
return statSync38(join123(dir, f)).isFile();
|
|
46099
46159
|
} catch {
|
|
46100
46160
|
return false;
|
|
46101
46161
|
}
|
|
@@ -46473,8 +46533,8 @@ var init_forecast = __esm(() => {
|
|
|
46473
46533
|
});
|
|
46474
46534
|
|
|
46475
46535
|
// ../../loki-ts/src/commands/queue.ts
|
|
46476
|
-
import { existsSync as existsSync86, mkdirSync as mkdirSync65, readFileSync as readFileSync113, readdirSync as readdirSync48, renameSync as renameSync25, statSync as
|
|
46477
|
-
import { join as join126, resolve as
|
|
46536
|
+
import { existsSync as existsSync86, mkdirSync as mkdirSync65, readFileSync as readFileSync113, readdirSync as readdirSync48, renameSync as renameSync25, statSync as statSync39, writeFileSync as writeFileSync67 } from "fs";
|
|
46537
|
+
import { join as join126, resolve as resolve30 } from "path";
|
|
46478
46538
|
function normalizeRef(raw2) {
|
|
46479
46539
|
const m = URL_RE.exec(raw2);
|
|
46480
46540
|
if (m)
|
|
@@ -46719,7 +46779,7 @@ function newestRecord(lokiDir2, since) {
|
|
|
46719
46779
|
const p = join126(dir, name, file);
|
|
46720
46780
|
if (!existsSync86(p))
|
|
46721
46781
|
continue;
|
|
46722
|
-
const t =
|
|
46782
|
+
const t = statSync39(p).mtimeMs;
|
|
46723
46783
|
if (t >= since && (!best || t > best.t))
|
|
46724
46784
|
best = { t, p, name };
|
|
46725
46785
|
}
|
|
@@ -46761,7 +46821,7 @@ function queueStartArgs(ref, pr) {
|
|
|
46761
46821
|
function makeDefaultRunner(lokiDir2) {
|
|
46762
46822
|
return async (ref, opts) => {
|
|
46763
46823
|
const since = Date.now();
|
|
46764
|
-
const argv = [
|
|
46824
|
+
const argv = [resolve30(REPO_ROOT, "bin", "loki"), ...queueStartArgs(ref, !!opts.pr)];
|
|
46765
46825
|
const runLoki = opts.cwd ? join126(opts.cwd, ".loki") : lokiDir2;
|
|
46766
46826
|
const env = runnerEnv(opts, runLoki);
|
|
46767
46827
|
const proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe", stdin: "ignore", env, ...opts.cwd ? { cwd: opts.cwd } : {} });
|
|
@@ -47105,7 +47165,7 @@ var init_issues_epic = __esm(() => {
|
|
|
47105
47165
|
|
|
47106
47166
|
// ../../loki-ts/src/util/group_integrate.ts
|
|
47107
47167
|
import { existsSync as existsSync88, mkdirSync as mkdirSync66, readFileSync as readFileSync115, rmSync as rmSync39, writeFileSync as writeFileSync68 } from "fs";
|
|
47108
|
-
import { basename as
|
|
47168
|
+
import { basename as basename38, dirname as dirname55, join as join127, normalize as normalize8 } from "path";
|
|
47109
47169
|
function integrationOrder(dag) {
|
|
47110
47170
|
const ids = dag.units.map((u) => u.id), indeg = new Map(ids.map((i) => [i, 0]));
|
|
47111
47171
|
for (const e of dag.edges)
|
|
@@ -47141,7 +47201,7 @@ async function rerunWalls(runner, repoDir, merged, walls) {
|
|
|
47141
47201
|
}
|
|
47142
47202
|
try {
|
|
47143
47203
|
for (const f of bad ? [] : files) {
|
|
47144
|
-
const rel = normalize8(f.rel), abs = join127(repoDir, rel), r2 = f.runner ?? guessRunner(
|
|
47204
|
+
const rel = normalize8(f.rel), abs = join127(repoDir, rel), r2 = f.runner ?? guessRunner(basename38(rel), harnessRunners([], [rel], process.env, repoDir, [rel]), rel);
|
|
47145
47205
|
if (bad = wallPathProblem(repoDir, rel) ?? (r2 ? undefined : `no runner for ${f.rel}`))
|
|
47146
47206
|
break;
|
|
47147
47207
|
written.push({ abs, prev: existsSync88(abs) ? readFileSync115(abs) : null });
|
|
@@ -48043,10 +48103,10 @@ __export(exports_run_group, {
|
|
|
48043
48103
|
groupCostLine: () => groupCostLine,
|
|
48044
48104
|
NOT_PROVEN: () => NOT_PROVEN
|
|
48045
48105
|
});
|
|
48046
|
-
import { cpSync as cpSync6, existsSync as existsSync90, mkdirSync as mkdirSync68, readdirSync as readdirSync49, readFileSync as readFileSync117, rmSync as rmSync41, statSync as
|
|
48106
|
+
import { cpSync as cpSync6, existsSync as existsSync90, mkdirSync as mkdirSync68, readdirSync as readdirSync49, readFileSync as readFileSync117, rmSync as rmSync41, statSync as statSync40 } from "fs";
|
|
48047
48107
|
import { createHash as createHash32 } from "crypto";
|
|
48048
48108
|
import { spawn as spawn11 } from "child_process";
|
|
48049
|
-
import { join as join129, resolve as
|
|
48109
|
+
import { join as join129, resolve as resolve31 } from "path";
|
|
48050
48110
|
function scopedEnv(env) {
|
|
48051
48111
|
const out3 = {};
|
|
48052
48112
|
for (const [k, v] of Object.entries(env))
|
|
@@ -48126,7 +48186,7 @@ function findResumable(repoDir, specSha, unitIds) {
|
|
|
48126
48186
|
continue;
|
|
48127
48187
|
let at = 0;
|
|
48128
48188
|
try {
|
|
48129
|
-
at =
|
|
48189
|
+
at = statSync40(p).mtimeMs;
|
|
48130
48190
|
} catch {
|
|
48131
48191
|
continue;
|
|
48132
48192
|
}
|
|
@@ -48324,7 +48384,7 @@ async function runGroupCore(launcher, dag, ctx) {
|
|
|
48324
48384
|
atomicWriteJson(spec, { id: u.id, writeSet: u.writeSet, pack: u.writeSet, tokenBudget: 1e9, acceptance: u.acceptance ?? accOf.get(u.id) ?? [], items: u.items ?? [], base: u.base ?? "" });
|
|
48325
48385
|
u.spec = spec;
|
|
48326
48386
|
}
|
|
48327
|
-
const jdir = repoCacheDir(repoKey(git11(repoDir, ["remote", "get-url", "origin"]) || null, repoDir), env.LOKI_CACHE_ROOT ?
|
|
48387
|
+
const jdir = repoCacheDir(repoKey(git11(repoDir, ["remote", "get-url", "origin"]) || null, repoDir), env.LOKI_CACHE_ROOT ? resolve31(env.LOKI_CACHE_ROOT) : undefined);
|
|
48328
48388
|
const keyOf = (u) => sliceKey(JSON.stringify({ id: u.id, items: u.items, writeSet: u.writeSet, acceptance: accOf.get(u.id) ?? [] }), baseRef);
|
|
48329
48389
|
let doneCount = 0;
|
|
48330
48390
|
for (const [i, u] of units.entries()) {
|
|
@@ -48499,7 +48559,7 @@ async function runGroupCore(launcher, dag, ctx) {
|
|
|
48499
48559
|
`);
|
|
48500
48560
|
return 0;
|
|
48501
48561
|
}
|
|
48502
|
-
var NOT_PROVEN = 4, ENV_KEEP, defaultLauncher = (argv, env, cwd, onOut) => new Promise((
|
|
48562
|
+
var NOT_PROVEN = 4, ENV_KEEP, defaultLauncher = (argv, env, cwd, onOut) => new Promise((resolve32) => {
|
|
48503
48563
|
const child = spawn11("python3", argv, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
|
|
48504
48564
|
let out3 = "";
|
|
48505
48565
|
child.stdout.on("data", (b) => {
|
|
@@ -48510,8 +48570,8 @@ var NOT_PROVEN = 4, ENV_KEEP, defaultLauncher = (argv, env, cwd, onOut) => new P
|
|
|
48510
48570
|
child.stderr.on("data", (b) => {
|
|
48511
48571
|
process.stderr.write(b);
|
|
48512
48572
|
});
|
|
48513
|
-
child.on("error", (e) =>
|
|
48514
|
-
child.on("close", (c) =>
|
|
48573
|
+
child.on("error", (e) => resolve32({ code: 127, stdout: out3 + String(e) }));
|
|
48574
|
+
child.on("close", (c) => resolve32({ code: c ?? 1, stdout: out3 }));
|
|
48515
48575
|
}), git11 = (dir, args) => {
|
|
48516
48576
|
const r = safeGitSpawn(dir, args, { encoding: "utf8" });
|
|
48517
48577
|
return r.status === 0 ? String(r.stdout).trim() : "";
|
|
@@ -48554,7 +48614,7 @@ __export(exports_route, {
|
|
|
48554
48614
|
MAX_SEQ_TASK_BYTES: () => MAX_SEQ_TASK_BYTES
|
|
48555
48615
|
});
|
|
48556
48616
|
import { closeSync as closeSync17, constants as constants4, fstatSync as fstatSync9, openSync as openSync17, readFileSync as readFileSync118, realpathSync as realpathSync41 } from "fs";
|
|
48557
|
-
import { isAbsolute as isAbsolute20, relative as relative29, resolve as
|
|
48617
|
+
import { isAbsolute as isAbsolute20, relative as relative29, resolve as resolve32 } from "path";
|
|
48558
48618
|
function providerSlots(env, provider) {
|
|
48559
48619
|
provider = (provider || env.LOKI_PROVIDER || "claude").toLowerCase();
|
|
48560
48620
|
return { provider, slots: PROVIDER_SLOTS[provider] ?? 1 };
|
|
@@ -48562,7 +48622,7 @@ function providerSlots(env, provider) {
|
|
|
48562
48622
|
function readSpec(task, repoDir, cwd) {
|
|
48563
48623
|
if (/\s/.test(task) || !SPEC_PATH_RE.test(task))
|
|
48564
48624
|
return { kind: "text" };
|
|
48565
|
-
const p = isAbsolute20(task) ? task :
|
|
48625
|
+
const p = isAbsolute20(task) ? task : resolve32(cwd, task);
|
|
48566
48626
|
let real4;
|
|
48567
48627
|
try {
|
|
48568
48628
|
real4 = realpathSync41(p);
|
|
@@ -48731,7 +48791,7 @@ __export(exports_issues_run, {
|
|
|
48731
48791
|
import { spawnSync as spawnSync20 } from "child_process";
|
|
48732
48792
|
import { cpSync as cpSync7, existsSync as existsSync91, mkdirSync as mkdirSync69, mkdtempSync as mkdtempSync19, readdirSync as readdirSync50, readFileSync as readFileSync119, rmdirSync as rmdirSync2, rmSync as rmSync42, writeFileSync as writeFileSync70 } from "fs";
|
|
48733
48793
|
import { tmpdir as tmpdir24 } from "os";
|
|
48734
|
-
import { join as join130, resolve as
|
|
48794
|
+
import { join as join130, resolve as resolve33 } from "path";
|
|
48735
48795
|
import { createInterface as createInterface3 } from "readline";
|
|
48736
48796
|
function epicParallel(env, provider) {
|
|
48737
48797
|
const n3 = Number(env["LOKI_EPIC_PARALLEL"]);
|
|
@@ -49441,7 +49501,7 @@ async function startMany(o) {
|
|
|
49441
49501
|
const env = o.env ?? process.env, { ManyStatus: ManyStatus2, consoleOn: consoleOn2 } = await Promise.resolve().then(() => (init_console(), exports_console));
|
|
49442
49502
|
const userEnv = groupEnv({ ...env, ...o.provider ? { LOKI_PROVIDER: o.provider } : {} }, o.capUsd, o.repoDir);
|
|
49443
49503
|
const tty = consoleOn2(env), status = new ManyStatus2({ write: (s) => void process.stdout.write(s), tty });
|
|
49444
|
-
const d = issuesDeps(o.repoDir, env["LOKI_DIR"] ??
|
|
49504
|
+
const d = issuesDeps(o.repoDir, env["LOKI_DIR"] ?? resolve33(o.repoDir, ".loki"), userEnv, { out: (s) => status.print(s), ...tty ? { err: (s) => status.print(s) } : {}, status, ...o.inject });
|
|
49445
49505
|
try {
|
|
49446
49506
|
return await issuesRun({ slug: o.slug, label: o.label, milestone: null, limit: DEFAULT_LIMIT, parallel: startParallel(env), draft: false, dryRun: false, yes: false, comment: false, split: false, triage: false, json: false, fromStart: true, noPr: o.noPr, ...o.numbers ? { numbers: o.numbers } : {} }, d);
|
|
49447
49507
|
} finally {
|
|
@@ -49484,7 +49544,7 @@ async function runIssues(args, inject) {
|
|
|
49484
49544
|
return 2;
|
|
49485
49545
|
}
|
|
49486
49546
|
const repoDir = inject?.repoDir ?? process.cwd();
|
|
49487
|
-
const lokiDir2 = inject?.lokiDir ?? process.env["LOKI_DIR"] ??
|
|
49547
|
+
const lokiDir2 = inject?.lokiDir ?? process.env["LOKI_DIR"] ?? resolve33(repoDir, ".loki");
|
|
49488
49548
|
const userEnv = { ...process.env };
|
|
49489
49549
|
if (!inject?.triage)
|
|
49490
49550
|
(await Promise.resolve().then(() => (init_github_token(), exports_github_token))).withholdGithubTokens(process.env, () => {});
|
|
@@ -49572,7 +49632,7 @@ __export(exports_supervisor, {
|
|
|
49572
49632
|
import { spawnSync as spawnSync21 } from "child_process";
|
|
49573
49633
|
import { createHash as createHash33, createPublicKey as createPublicKey6, sign as sign4 } from "crypto";
|
|
49574
49634
|
import { existsSync as existsSync92, mkdirSync as mkdirSync70, readFileSync as readFileSync120, writeFileSync as writeFileSync71 } from "fs";
|
|
49575
|
-
import { dirname as dirname57, join as join131, relative as relative30, resolve as
|
|
49635
|
+
import { dirname as dirname57, join as join131, relative as relative30, resolve as resolve34 } from "path";
|
|
49576
49636
|
async function slackEvent(...a) {
|
|
49577
49637
|
try {
|
|
49578
49638
|
await (await Promise.resolve().then(() => (init_slack_events(), exports_slack_events))).notifyEvent(...a);
|
|
@@ -50033,7 +50093,7 @@ async function main3(args) {
|
|
|
50033
50093
|
noteRefusal("unsupported_flag");
|
|
50034
50094
|
return 2;
|
|
50035
50095
|
}
|
|
50036
|
-
sealPatch =
|
|
50096
|
+
sealPatch = resolve34(v);
|
|
50037
50097
|
noPr = true;
|
|
50038
50098
|
i++;
|
|
50039
50099
|
} else if (a === "--" && !eoo)
|
|
@@ -50053,7 +50113,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
50053
50113
|
let spec = null;
|
|
50054
50114
|
if (specFile !== null) {
|
|
50055
50115
|
try {
|
|
50056
|
-
spec = loadSpecFile(
|
|
50116
|
+
spec = loadSpecFile(resolve34(specFile));
|
|
50057
50117
|
} catch (e) {
|
|
50058
50118
|
process.stderr.write(`engine10: ${e.message}
|
|
50059
50119
|
`);
|
|
@@ -50387,8 +50447,8 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
|
|
|
50387
50447
|
env,
|
|
50388
50448
|
capS,
|
|
50389
50449
|
capCeilingS: sized?.ceilingS,
|
|
50390
|
-
workerArgv: [process.execPath, ...SAFE_BUN_FLAGS,
|
|
50391
|
-
deepArgv: noPr ? undefined : [process.execPath, ...SAFE_BUN_FLAGS,
|
|
50450
|
+
workerArgv: [process.execPath, ...SAFE_BUN_FLAGS, resolve34(process.argv[1]), "engine10", "worker", runId2, provider, model, deep ? "deep" : "fast"],
|
|
50451
|
+
deepArgv: noPr ? undefined : [process.execPath, ...SAFE_BUN_FLAGS, resolve34(process.argv[1]), "engine10", "deep-worker", runId2, provider, model],
|
|
50392
50452
|
status: statusStep,
|
|
50393
50453
|
started: {
|
|
50394
50454
|
task_source: isIssue ? "issue" : "text",
|
|
@@ -50571,7 +50631,7 @@ var init_supervisor = __esm(() => {
|
|
|
50571
50631
|
|
|
50572
50632
|
// ../../loki-ts/src/e10ext/compound_match.ts
|
|
50573
50633
|
import { readFileSync as readFileSync121 } from "fs";
|
|
50574
|
-
import { basename as
|
|
50634
|
+
import { basename as basename39, join as join132 } from "path";
|
|
50575
50635
|
function parts(s) {
|
|
50576
50636
|
return s.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
50577
50637
|
}
|
|
@@ -50592,9 +50652,9 @@ function fuzzyHit(word2, ps) {
|
|
|
50592
50652
|
}
|
|
50593
50653
|
function linkedHits(word2, repoMap, testMap, repoDir) {
|
|
50594
50654
|
const out3 = [];
|
|
50595
|
-
const srcs = repoMap.entries.filter((e) => !vendored(e.path) && e.symbols.some((s) => fuzzyHit(word2, parts(s))) && fuzzyHit(word2, parts(
|
|
50655
|
+
const srcs = repoMap.entries.filter((e) => !vendored(e.path) && e.symbols.some((s) => fuzzyHit(word2, parts(s))) && fuzzyHit(word2, parts(basename39(e.path))));
|
|
50596
50656
|
for (const t of testMap.tests) {
|
|
50597
|
-
if (vendored(t.path) || !fuzzyHit(word2, parts(
|
|
50657
|
+
if (vendored(t.path) || !fuzzyHit(word2, parts(basename39(t.path))))
|
|
50598
50658
|
continue;
|
|
50599
50659
|
let body;
|
|
50600
50660
|
try {
|
|
@@ -50612,7 +50672,7 @@ function linkedHits(word2, repoMap, testMap, repoDir) {
|
|
|
50612
50672
|
}
|
|
50613
50673
|
return out3;
|
|
50614
50674
|
}
|
|
50615
|
-
var MIN_PREFIX = 5, SUFFIX, VENDORED, vendored = (p) => p.split("/").some((s) => VENDORED.has(s)), stemOf2 = (p) => parts(
|
|
50675
|
+
var MIN_PREFIX = 5, SUFFIX, VENDORED, vendored = (p) => p.split("/").some((s) => VENDORED.has(s)), stemOf2 = (p) => parts(basename39(p)).slice(0, -1).filter((x) => x !== "test" && x !== "spec").join("-");
|
|
50616
50676
|
var init_compound_match = __esm(() => {
|
|
50617
50677
|
SUFFIX = /^(ation|ization|isation|ity|ivity|ments?|ives?|als?|ures?|ness|ism|ist|ize|ise|able|ible|ous|ics?|ings?|ed|ers?|ions?|ly|less|es|s|(ful|hood|ship|dom|ance|ence|ancy|ency|ator|ant|ent|ary|ery|ory|ward|wise|like|ish)s?)$/;
|
|
50618
50678
|
VENDORED = new Set(["vendor", "third_party", "build", ".venv", "__generated__", "coverage", "node_modules", "dist"]);
|
|
@@ -50620,7 +50680,7 @@ var init_compound_match = __esm(() => {
|
|
|
50620
50680
|
|
|
50621
50681
|
// ../../loki-ts/src/util/already_done_evidence.ts
|
|
50622
50682
|
import { existsSync as existsSync93, readFileSync as readFileSync122 } from "fs";
|
|
50623
|
-
import { basename as
|
|
50683
|
+
import { basename as basename40, join as join133 } from "path";
|
|
50624
50684
|
function keywords2(task) {
|
|
50625
50685
|
const words3 = task.toLowerCase().match(/[a-z0-9_]+/g) ?? [];
|
|
50626
50686
|
return Array.from(new Set(words3.filter((w) => w.length > 2 && !STOP_WORDS.has(w))));
|
|
@@ -50641,7 +50701,7 @@ function codeEvidence(words3, repoMap) {
|
|
|
50641
50701
|
function testEvidence(words3, testMap) {
|
|
50642
50702
|
const hits = [];
|
|
50643
50703
|
for (const t of testMap.tests) {
|
|
50644
|
-
const toks2 = tokenSet(
|
|
50704
|
+
const toks2 = tokenSet(basename40(t.path));
|
|
50645
50705
|
if (words3.some((w) => toks2.has(w)))
|
|
50646
50706
|
hits.push({ source: "test", path: t.path, line: t.path });
|
|
50647
50707
|
}
|
|
@@ -50714,7 +50774,7 @@ function citesToken(text4, token) {
|
|
|
50714
50774
|
function citesRealHit(text4, hit2, repoDir) {
|
|
50715
50775
|
if (hit2.source === "changelog")
|
|
50716
50776
|
return false;
|
|
50717
|
-
return (citesToken(text4, hit2.path) || citesToken(text4,
|
|
50777
|
+
return (citesToken(text4, hit2.path) || citesToken(text4, basename40(hit2.path))) && existsSync93(join133(repoDir, hit2.path));
|
|
50718
50778
|
}
|
|
50719
50779
|
function renderAlreadyDoneComment(evidence) {
|
|
50720
50780
|
return ["Loki 10: no change needed. This already appears to be implemented.", "", "Evidence:", ...evidence.map((e) => `- ${e}`), ""].join(`
|
|
@@ -50916,15 +50976,15 @@ __export(exports_warm, {
|
|
|
50916
50976
|
WarmEngine: () => WarmEngine
|
|
50917
50977
|
});
|
|
50918
50978
|
import { createHash as createHash34 } from "crypto";
|
|
50919
|
-
import { existsSync as existsSync94, mkdirSync as mkdirSync71, readFileSync as readFileSync123, statSync as
|
|
50979
|
+
import { existsSync as existsSync94, mkdirSync as mkdirSync71, readFileSync as readFileSync123, statSync as statSync41, unlinkSync as unlinkSync11 } from "fs";
|
|
50920
50980
|
import { createServer as createServer2 } from "net";
|
|
50921
|
-
import { dirname as dirname58, resolve as
|
|
50981
|
+
import { dirname as dirname58, resolve as resolve35 } from "path";
|
|
50922
50982
|
function speedEnabled() {
|
|
50923
50983
|
return process.env["LOKI_SPEED"] !== "0";
|
|
50924
50984
|
}
|
|
50925
50985
|
function warmSocketPath() {
|
|
50926
50986
|
const o = process.env["LOKI_WARM_SOCK"];
|
|
50927
|
-
return o && o.trim() ? o.trim() :
|
|
50987
|
+
return o && o.trim() ? o.trim() : resolve35(homeLokiDir(), "run", "engine.sock");
|
|
50928
50988
|
}
|
|
50929
50989
|
function git12(repoDir, args) {
|
|
50930
50990
|
try {
|
|
@@ -50944,8 +51004,8 @@ function dirtyHash(repoDir) {
|
|
|
50944
51004
|
`);
|
|
50945
51005
|
const rel = line2.slice(3).split(" -> ").pop().replace(/^"|"$/g, "");
|
|
50946
51006
|
try {
|
|
50947
|
-
const p =
|
|
50948
|
-
if (existsSync94(p) &&
|
|
51007
|
+
const p = resolve35(repoDir, rel);
|
|
51008
|
+
if (existsSync94(p) && statSync41(p).isFile() && statSync41(p).size <= MAX_HASHED_BYTES)
|
|
50949
51009
|
h.update(readFileSync123(p));
|
|
50950
51010
|
} catch {}
|
|
50951
51011
|
}
|
|
@@ -50955,7 +51015,7 @@ function warmKey(repoDir) {
|
|
|
50955
51015
|
const tree = git12(repoDir, ["rev-parse", "HEAD^{tree}"]);
|
|
50956
51016
|
if (tree === null)
|
|
50957
51017
|
return null;
|
|
50958
|
-
return `${
|
|
51018
|
+
return `${resolve35(repoDir)}|${tree.trim()}|${dirtyHash(repoDir)}`;
|
|
50959
51019
|
}
|
|
50960
51020
|
|
|
50961
51021
|
class WarmEngine {
|
|
@@ -51198,7 +51258,7 @@ __export(exports_intake, {
|
|
|
51198
51258
|
alreadyDoneCheckOn: () => alreadyDoneCheckOn
|
|
51199
51259
|
});
|
|
51200
51260
|
import { appendFileSync as appendFileSync14, existsSync as existsSync95, mkdirSync as mkdirSync73, readFileSync as readFileSync124, writeFileSync as writeFileSync72 } from "fs";
|
|
51201
|
-
import { dirname as dirname59, join as join135, resolve as
|
|
51261
|
+
import { dirname as dirname59, join as join135, resolve as resolve36 } from "path";
|
|
51202
51262
|
function issueRefOf(raw2) {
|
|
51203
51263
|
return typeof raw2.repo === "string" && raw2.repo && typeof raw2.number === "number" ? `${raw2.repo}#${raw2.number}` : null;
|
|
51204
51264
|
}
|
|
@@ -51220,7 +51280,7 @@ function ensureBranch(repoDir, branch, from) {
|
|
|
51220
51280
|
function excludeLokiDir(repoDir) {
|
|
51221
51281
|
let path = join135(repoDir, ".git", "info", "exclude");
|
|
51222
51282
|
try {
|
|
51223
|
-
path =
|
|
51283
|
+
path = resolve36(repoDir, git13(repoDir, ["rev-parse", "--git-path", "info/exclude"]));
|
|
51224
51284
|
} catch {}
|
|
51225
51285
|
const existing = existsSync95(path) ? readFileSync124(path, "utf8") : "";
|
|
51226
51286
|
if (existing.split(`
|
|
@@ -51469,7 +51529,7 @@ __export(exports_fix, {
|
|
|
51469
51529
|
fixStage: () => fixStage,
|
|
51470
51530
|
buildFixBrief: () => buildFixBrief
|
|
51471
51531
|
});
|
|
51472
|
-
import { relative as relative31, resolve as
|
|
51532
|
+
import { relative as relative31, resolve as resolve37 } from "path";
|
|
51473
51533
|
function isTestFailure(g2) {
|
|
51474
51534
|
return !g2.signature.startsWith("lint:") && g2.signature !== "select-tests";
|
|
51475
51535
|
}
|
|
@@ -51560,7 +51620,7 @@ ${g2.sample}`)].join(`
|
|
|
51560
51620
|
|
|
51561
51621
|
`) || null;
|
|
51562
51622
|
const fullBrief = buildFixBrief(task, groups, diffStat2, repeated ? { priorDiagnosis: prevDiag } : undefined, holdoutFailed, hintsPlus);
|
|
51563
|
-
let r = await runFixSession(ctx, sessionBase, `${ctx.runId}-fix${round2}`, prior.fix?.iteration_ids ?? [], chain, actualModel, fullBrief, buildFixResumeBrief(groups, diffStat2, prevDiag, holdoutFailed, [...prior.implement?.tests_reverted ?? [], ...prior.fix?.tests_reverted ?? []].map((f) => relative31(ctx.repoDir,
|
|
51623
|
+
let r = await runFixSession(ctx, sessionBase, `${ctx.runId}-fix${round2}`, prior.fix?.iteration_ids ?? [], chain, actualModel, fullBrief, buildFixResumeBrief(groups, diffStat2, prevDiag, holdoutFailed, [...prior.implement?.tests_reverted ?? [], ...prior.fix?.tests_reverted ?? []].map((f) => relative31(ctx.repoDir, resolve37(ctx.repoDir, f))), hintsPlus));
|
|
51564
51624
|
const ro = prior.wall?.readOnlyFiles ?? [], wd = r.session.markers.specConflict && !r.session.killed ? await adjudicateWallConflict(ctx, { ...sessionBase, iterationId: r.ids[r.ids.length - 1], brief: fullBrief }, r.session, ro) : null;
|
|
51565
51625
|
if (wd)
|
|
51566
51626
|
r = { ...r, session: wd.session, ids: [...r.ids, ...wd.ids] };
|
|
@@ -53287,7 +53347,7 @@ var init_seal2 = __esm(() => {
|
|
|
53287
53347
|
import { spawnSync as spawnSync24 } from "child_process";
|
|
53288
53348
|
import { copyFileSync as copyFileSync10, existsSync as existsSync100, linkSync as linkSync4, mkdirSync as mkdirSync77, mkdtempSync as mkdtempSync22, readFileSync as readFileSync130, renameSync as renameSync27, rmSync as rmSync45, rmdirSync as rmdirSync3, writeFileSync as writeFileSync76 } from "fs";
|
|
53289
53349
|
import { tmpdir as tmpdir27 } from "os";
|
|
53290
|
-
import { basename as
|
|
53350
|
+
import { basename as basename41, dirname as dirname62, join as join143 } from "path";
|
|
53291
53351
|
function search(unitSource, seedCases, propose, runCapture, opts = {}) {
|
|
53292
53352
|
const maxRounds = opts.maxRounds ?? 10;
|
|
53293
53353
|
const plateauLimit = opts.plateauRounds ?? 2;
|
|
@@ -53397,7 +53457,7 @@ function makeProposeInputs(session, cap = 20) {
|
|
|
53397
53457
|
return (unitPath, missing, round2) => {
|
|
53398
53458
|
const cwd = mkdtempSync22(join143(tmpdir27(), "m27-propose-"));
|
|
53399
53459
|
try {
|
|
53400
|
-
const unitFile = join143(cwd,
|
|
53460
|
+
const unitFile = join143(cwd, basename41(unitPath));
|
|
53401
53461
|
copyFileSync10(unitPath, unitFile);
|
|
53402
53462
|
session({ cwd, env: tokenFreeEnv(), unitFile, missing, round: round2 });
|
|
53403
53463
|
const out3 = [];
|
|
@@ -54802,7 +54862,7 @@ var init_unit = __esm(() => {
|
|
|
54802
54862
|
|
|
54803
54863
|
// ../../loki-ts/src/engine10/modernize/wave.ts
|
|
54804
54864
|
import { spawnSync as spawnSync26 } from "child_process";
|
|
54805
|
-
import { readFileSync as readFileSync136, statSync as
|
|
54865
|
+
import { readFileSync as readFileSync136, statSync as statSync42 } from "fs";
|
|
54806
54866
|
import { join as join149 } from "path";
|
|
54807
54867
|
function clampTimeout(ms) {
|
|
54808
54868
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0)
|
|
@@ -54884,7 +54944,7 @@ function detectWaveCommands(inv, target) {
|
|
|
54884
54944
|
if (system === "gradle") {
|
|
54885
54945
|
let gw = "gradle";
|
|
54886
54946
|
try {
|
|
54887
|
-
if (inv.files.includes("gradlew") && (
|
|
54947
|
+
if (inv.files.includes("gradlew") && (statSync42(join149(target, "gradlew")).mode & 73) !== 0)
|
|
54888
54948
|
gw = "./gradlew";
|
|
54889
54949
|
} catch {}
|
|
54890
54950
|
return { build: { argv: [gw, "assemble"] }, integration: text4().includes("integrationTest") ? { argv: [gw, "integrationTest"] } : null, original_suite: { argv: [gw, "test"] } };
|
|
@@ -54928,7 +54988,7 @@ var init_wave = __esm(() => {
|
|
|
54928
54988
|
|
|
54929
54989
|
// ../../loki-ts/src/util/modernize_unit.ts
|
|
54930
54990
|
import { spawnSync as spawnSync27 } from "child_process";
|
|
54931
|
-
import { existsSync as existsSync103, lstatSync as lstatSync33, mkdtempSync as mkdtempSync23, readFileSync as readFileSync137, realpathSync as realpathSync43, rmSync as rmSync47, statSync as
|
|
54991
|
+
import { existsSync as existsSync103, lstatSync as lstatSync33, mkdtempSync as mkdtempSync23, readFileSync as readFileSync137, realpathSync as realpathSync43, rmSync as rmSync47, statSync as statSync43, writeFileSync as writeFileSync80 } from "fs";
|
|
54932
54992
|
import { tmpdir as tmpdir29 } from "os";
|
|
54933
54993
|
import { join as join150, sep as sep23 } from "path";
|
|
54934
54994
|
function parseUnitArgs(args) {
|
|
@@ -55153,7 +55213,7 @@ var UNIT_USAGE = "loki modernize unit --repo <owner/name> --ref <ref> --unit <id
|
|
|
55153
55213
|
return s.size === 1 ? [...s][0] : null;
|
|
55154
55214
|
}, isRealDir = (p) => {
|
|
55155
55215
|
try {
|
|
55156
|
-
return !lstatSync33(p).isSymbolicLink() &&
|
|
55216
|
+
return !lstatSync33(p).isSymbolicLink() && statSync43(p).isDirectory();
|
|
55157
55217
|
} catch {
|
|
55158
55218
|
return false;
|
|
55159
55219
|
}
|
|
@@ -55467,7 +55527,7 @@ __export(exports_cli, {
|
|
|
55467
55527
|
main: () => main6,
|
|
55468
55528
|
USAGE: () => USAGE2
|
|
55469
55529
|
});
|
|
55470
|
-
import { existsSync as existsSync105, statSync as
|
|
55530
|
+
import { existsSync as existsSync105, statSync as statSync44 } from "fs";
|
|
55471
55531
|
function parseArgs2(args) {
|
|
55472
55532
|
let repoDir = null;
|
|
55473
55533
|
let target = null;
|
|
@@ -55604,7 +55664,7 @@ ${USAGE2}`);
|
|
|
55604
55664
|
return 2;
|
|
55605
55665
|
}
|
|
55606
55666
|
const opts = parsed.opts;
|
|
55607
|
-
if (!existsSync105(opts.repoDir) || !
|
|
55667
|
+
if (!existsSync105(opts.repoDir) || !statSync44(opts.repoDir).isDirectory()) {
|
|
55608
55668
|
process.stderr.write(`modernize: not a directory: ${opts.repoDir}
|
|
55609
55669
|
`);
|
|
55610
55670
|
return 2;
|
|
@@ -56113,10 +56173,10 @@ var init_undo = __esm(() => {
|
|
|
56113
56173
|
});
|
|
56114
56174
|
|
|
56115
56175
|
// ../../loki-ts/src/commands/run_status.ts
|
|
56116
|
-
import { existsSync as existsSync107, readdirSync as readdirSync53, readFileSync as readFileSync140, statSync as
|
|
56117
|
-
import { basename as
|
|
56176
|
+
import { existsSync as existsSync107, readdirSync as readdirSync53, readFileSync as readFileSync140, statSync as statSync45 } from "fs";
|
|
56177
|
+
import { basename as basename42, dirname as dirname64, join as join153, resolve as resolve38 } from "path";
|
|
56118
56178
|
function runsRoot(env, repoDir) {
|
|
56119
|
-
return env.LOKI_DIR ? join153(
|
|
56179
|
+
return env.LOKI_DIR ? join153(resolve38(repoDir, env.LOKI_DIR), "runs") : join153(repoDir, ".loki", "runs");
|
|
56120
56180
|
}
|
|
56121
56181
|
function listRunIds(root) {
|
|
56122
56182
|
if (!existsSync107(root))
|
|
@@ -56172,9 +56232,9 @@ __export(exports_base_guard, {
|
|
|
56172
56232
|
});
|
|
56173
56233
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
56174
56234
|
import { createHash as createHash39 } from "crypto";
|
|
56175
|
-
import { existsSync as existsSync108, mkdirSync as mkdirSync81, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as readFileSync141, readlinkSync as readlinkSync8, realpathSync as realpathSync44, rmSync as rmSync49, statSync as
|
|
56235
|
+
import { existsSync as existsSync108, mkdirSync as mkdirSync81, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as readFileSync141, readlinkSync as readlinkSync8, realpathSync as realpathSync44, rmSync as rmSync49, statSync as statSync46, symlinkSync as symlinkSync6, utimesSync, writeFileSync as writeFileSync82 } from "fs";
|
|
56176
56236
|
import { tmpdir as tmpdir31 } from "os";
|
|
56177
|
-
import { basename as
|
|
56237
|
+
import { basename as basename43, dirname as dirname65, join as join154, relative as relative32, resolve as resolve39, sep as sep24 } from "path";
|
|
56178
56238
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
56179
56239
|
function git14(repoDir, args, timeout = 20000, extraEnv = {}) {
|
|
56180
56240
|
try {
|
|
@@ -56271,7 +56331,7 @@ function noteOf(intake) {
|
|
|
56271
56331
|
}
|
|
56272
56332
|
function insideAny(p, roots) {
|
|
56273
56333
|
const under3 = (q) => roots.some((r) => q === r || q.startsWith(r + sep24));
|
|
56274
|
-
if (under3(
|
|
56334
|
+
if (under3(resolve39(p)))
|
|
56275
56335
|
return true;
|
|
56276
56336
|
try {
|
|
56277
56337
|
return under3(realpathSync44(p));
|
|
@@ -56281,7 +56341,7 @@ function insideAny(p, roots) {
|
|
|
56281
56341
|
}
|
|
56282
56342
|
function namedPaths2(file, text4) {
|
|
56283
56343
|
const out3 = text4.split(/\r?\n/).map((l) => l.trim()).filter((l) => l !== "");
|
|
56284
|
-
if (
|
|
56344
|
+
if (basename43(file) !== "direct_url.json")
|
|
56285
56345
|
return out3;
|
|
56286
56346
|
const url = JSON.parse(text4).url;
|
|
56287
56347
|
return typeof url === "string" && url.startsWith("file:") ? [...out3, fileURLToPath5(url)] : out3;
|
|
@@ -56289,7 +56349,7 @@ function namedPaths2(file, text4) {
|
|
|
56289
56349
|
function depsSeeHead(pkgDir, repoDir) {
|
|
56290
56350
|
let roots;
|
|
56291
56351
|
try {
|
|
56292
|
-
roots = [...new Set([
|
|
56352
|
+
roots = [...new Set([resolve39(repoDir), realpathSync44(repoDir)])];
|
|
56293
56353
|
} catch {
|
|
56294
56354
|
return true;
|
|
56295
56355
|
}
|
|
@@ -56300,7 +56360,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
56300
56360
|
return true;
|
|
56301
56361
|
const p = join154(dir, e.name);
|
|
56302
56362
|
if (e.isSymbolicLink()) {
|
|
56303
|
-
const t =
|
|
56363
|
+
const t = resolve39(dir, readlinkSync8(p));
|
|
56304
56364
|
let rt = t;
|
|
56305
56365
|
try {
|
|
56306
56366
|
rt = realpathSync44(t);
|
|
@@ -56322,7 +56382,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
56322
56382
|
return ["node_modules", ".venv"].some((d) => {
|
|
56323
56383
|
try {
|
|
56324
56384
|
const top = join154(pkgDir, d);
|
|
56325
|
-
return walk(top, [...new Set([
|
|
56385
|
+
return walk(top, [...new Set([resolve39(top), realpathSync44(top)])]);
|
|
56326
56386
|
} catch (e) {
|
|
56327
56387
|
if (e.code === "ENOENT")
|
|
56328
56388
|
return false;
|
|
@@ -56394,7 +56454,7 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored, deps) {
|
|
|
56394
56454
|
try {
|
|
56395
56455
|
const roots = [];
|
|
56396
56456
|
for (const rel of ignored) {
|
|
56397
|
-
const st =
|
|
56457
|
+
const st = statSync46(join154(repoDir, rel), { throwIfNoEntry: false });
|
|
56398
56458
|
if (!st)
|
|
56399
56459
|
return true;
|
|
56400
56460
|
if (!st.isDirectory() && !TOOL_OUTPUT_FILE.test(rel))
|
|
@@ -56496,11 +56556,11 @@ function splitDeclaredAdvisories(notes, c) {
|
|
|
56496
56556
|
return "";
|
|
56497
56557
|
}).join(`
|
|
56498
56558
|
`);
|
|
56499
|
-
const named2 = (f) => new RegExp(`${f.includes("/") ? `(?<![\\w./-])${escapeRegex(f)}(?![\\w-])|` : ""}[/"'\`]${escapeRegex(
|
|
56559
|
+
const named2 = (f) => new RegExp(`${f.includes("/") ? `(?<![\\w./-])${escapeRegex(f)}(?![\\w-])|` : ""}[/"'\`]${escapeRegex(basename43(f))}(?=["'\`\\s);]|$)`).test(wall());
|
|
56500
56560
|
const linkOk = (f) => {
|
|
56501
56561
|
try {
|
|
56502
56562
|
const root = realpathSync44(c.repoDir), t = realpathSync44(join154(c.repoDir, f)), rel = relative32(root, t);
|
|
56503
|
-
return !rel.startsWith("..") && !rel.split(sep24).includes(".git") &&
|
|
56563
|
+
return !rel.startsWith("..") && !rel.split(sep24).includes(".git") && statSync46(t).isFile() && changed.has(rel.split(sep24).join("/")) && !isTestFile(rel) && !c.wallPaths.includes(rel);
|
|
56504
56564
|
} catch {
|
|
56505
56565
|
return false;
|
|
56506
56566
|
}
|
|
@@ -56535,7 +56595,7 @@ function removeRunWorktrees(repoDir, baseSha) {
|
|
|
56535
56595
|
roots.push(realpathSync44(tmpdir31()));
|
|
56536
56596
|
} catch {}
|
|
56537
56597
|
for (const t of checkedOut(repoDir).trees.slice(1)) {
|
|
56538
|
-
const named2 = RUN_TMP_WORKTREE_RE.test(
|
|
56598
|
+
const named2 = RUN_TMP_WORKTREE_RE.test(basename43(t.path)) || RUN_TMP_WORKTREE_RE.test(basename43(dirname65(t.path)));
|
|
56539
56599
|
if (t.detached && t.head === baseSha && named2 && roots.some((r) => t.path.startsWith(r + sep24)))
|
|
56540
56600
|
git14(repoDir, ["worktree", "remove", "--force", "--force", t.path]);
|
|
56541
56601
|
}
|
|
@@ -56599,8 +56659,8 @@ function removeOwnWallFiles(repoDir, runId2) {
|
|
|
56599
56659
|
for (const f of files) {
|
|
56600
56660
|
if (typeof f.path !== "string" || typeof f.sha256 !== "string")
|
|
56601
56661
|
continue;
|
|
56602
|
-
const abs =
|
|
56603
|
-
if (rel.startsWith("..") || rel.startsWith(".loki/") || !
|
|
56662
|
+
const abs = resolve39(repoDir, f.path), rel = relative32(repoDir, abs);
|
|
56663
|
+
if (rel.startsWith("..") || rel.startsWith(".loki/") || !basename43(rel).startsWith("loki_wall_"))
|
|
56604
56664
|
continue;
|
|
56605
56665
|
if (git14(repoDir, ["ls-files", "--error-unmatch", "--", rel]) !== null)
|
|
56606
56666
|
continue;
|
|
@@ -56726,7 +56786,7 @@ var init_base_guard = __esm(() => {
|
|
|
56726
56786
|
init_stop_restore();
|
|
56727
56787
|
REPO_LINK_FILE = /\.pth$|\.egg-link$|^direct_url\.json$|^__editable___.*_finder\.py$/;
|
|
56728
56788
|
RUNNER_CACHE_DIRS = [".vite", ".vite-temp", ".vitest", ".vitest-cache", ".cache", "__pycache__", ".pytest_cache"];
|
|
56729
|
-
TOOL_OUTPUT_FILE = /(?:^|\/)(?:[^/]*\.tsbuildinfo|\.eslintcache|\.stylelintcache|\.DS_Store)$/;
|
|
56789
|
+
TOOL_OUTPUT_FILE = /(?:^|\/)(?:[^/]*\.tsbuildinfo|\.eslintcache|\.stylelintcache|\.DS_Store|next-env\.d\.ts)$/;
|
|
56730
56790
|
ADVISORY_PATH = /^(?:test configuration changed|runner config changed): (.+?)(?: \(.*\))?$|^symlink added by the change .*?\): (.+)$/;
|
|
56731
56791
|
E10_BRANCH_RE = /^loki\/(e10-[A-Za-z0-9-]+)$/;
|
|
56732
56792
|
RUN_TMP_WORKTREE_RE = /^(?:e10-base-|e10-loadown-|loki-mutproof-)/;
|
|
@@ -56792,9 +56852,9 @@ __export(exports_verify, {
|
|
|
56792
56852
|
COLLATERAL_RED: () => COLLATERAL_RED,
|
|
56793
56853
|
BCE_REASON: () => BCE_REASON
|
|
56794
56854
|
});
|
|
56795
|
-
import { existsSync as existsSync109, mkdtempSync as mkdtempSync26, readFileSync as readFileSync142, realpathSync as realpathSync45, rmSync as rmSync50, statSync as
|
|
56855
|
+
import { existsSync as existsSync109, mkdtempSync as mkdtempSync26, readFileSync as readFileSync142, realpathSync as realpathSync45, rmSync as rmSync50, statSync as statSync47 } from "fs";
|
|
56796
56856
|
import { tmpdir as tmpdir32 } from "os";
|
|
56797
|
-
import { basename as
|
|
56857
|
+
import { basename as basename44, dirname as dirname66, isAbsolute as isAbsolute21, join as join155, relative as relative33, resolve as resolve40 } from "path";
|
|
56798
56858
|
function carriedTimeouts(prev, tests, changed, keep, env = process.env) {
|
|
56799
56859
|
if (!timeoutCarryOn(env))
|
|
56800
56860
|
return [];
|
|
@@ -56833,15 +56893,15 @@ ${tail2(f.out)}
|
|
|
56833
56893
|
}
|
|
56834
56894
|
function collateralTests(relevant2, named2) {
|
|
56835
56895
|
const stems = new Set(named2.flatMap((f) => {
|
|
56836
|
-
const s =
|
|
56837
|
-
return /^(index|__init__|mod)$/.test(s) && f.includes("/") ? [s,
|
|
56896
|
+
const s = basename44(f).replace(/\.[^.]+$/, "");
|
|
56897
|
+
return /^(index|__init__|mod)$/.test(s) && f.includes("/") ? [s, basename44(f.slice(0, f.lastIndexOf("/")))] : [s];
|
|
56838
56898
|
}));
|
|
56839
56899
|
return relevant2.filter((t) => !named2.includes(t.path) && !stems.has(coveredStem(t.path)));
|
|
56840
56900
|
}
|
|
56841
56901
|
function ownTests(relevant2, named2, changed) {
|
|
56842
56902
|
const src = named2.filter((f) => !isTestFile(f) && changed.includes(f)).map((f) => {
|
|
56843
56903
|
const d = f.includes("/") ? f.slice(0, f.lastIndexOf("/")) : ".";
|
|
56844
|
-
const s =
|
|
56904
|
+
const s = basename44(f).replace(/\.[^.]+$/, "");
|
|
56845
56905
|
return { d, s };
|
|
56846
56906
|
});
|
|
56847
56907
|
const inDir = (t, d) => {
|
|
@@ -57041,7 +57101,7 @@ async function vitestBatch(cwd, rels, signal, opts = {}) {
|
|
|
57041
57101
|
}
|
|
57042
57102
|
}, byAbs = new Map;
|
|
57043
57103
|
for (const rel of rels)
|
|
57044
|
-
for (const p of [
|
|
57104
|
+
for (const p of [resolve40(cwd, rel), real4(resolve40(cwd, rel))])
|
|
57045
57105
|
byAbs.set(p, rel);
|
|
57046
57106
|
const out3 = new Map;
|
|
57047
57107
|
for (const tr of tests) {
|
|
@@ -57180,7 +57240,7 @@ function changedSymbolsFirst(ctx, tests, changed) {
|
|
|
57180
57240
|
return [...hits, ...tests.filter((t) => !hits.includes(t))];
|
|
57181
57241
|
}
|
|
57182
57242
|
function uncausedRed(c, changed, symbols, excerpt2) {
|
|
57183
|
-
const names = (t) => changed.some((f) => t.includes(f) || t.includes(
|
|
57243
|
+
const names = (t) => changed.some((f) => t.includes(f) || t.includes(basename44(f)));
|
|
57184
57244
|
if ((c.ids ?? []).some(names) || names(c.name))
|
|
57185
57245
|
return false;
|
|
57186
57246
|
if (c.name.startsWith("lint:")) {
|
|
@@ -57278,7 +57338,7 @@ function baseMemo(runDir, baseSha, on = baseMemoOn()) {
|
|
|
57278
57338
|
};
|
|
57279
57339
|
}
|
|
57280
57340
|
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set, own = rel, symbols = []) {
|
|
57281
|
-
const out3 = { ids: [], names: [], knownRed: [], sameError: [], quiet: [], shapeDiffers: [], weak: [], zero: [], cnt: {}, envCrash: [] };
|
|
57341
|
+
const out3 = { ids: [], names: [], knownRed: [], sameError: [], quiet: [], shapeDiffers: [], compared: [], weak: [], zero: [], cnt: {}, envCrash: [] };
|
|
57282
57342
|
const pairs = checks.flatMap((c) => {
|
|
57283
57343
|
const t = tests.find((x) => testCheckName(x) === c.name);
|
|
57284
57344
|
return t ? [{ c, t }] : [];
|
|
@@ -57307,7 +57367,8 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
57307
57367
|
git15(["-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", dir, ctx.baseSha]);
|
|
57308
57368
|
const base2 = new Map;
|
|
57309
57369
|
const record = (c, b) => {
|
|
57310
|
-
|
|
57370
|
+
const red2 = !b.ok && !b.cut ? failIds(b.out) : [];
|
|
57371
|
+
base2.set(c, { red: red2, n: ran(b.out) ?? summaryPassFailCount(b.out), sk: skipped2(b.out), out: b.cut ? "" : b.out, live: b.ok && !b.cut || red2.length > 0 });
|
|
57311
57372
|
};
|
|
57312
57373
|
await baseGoBatch(sus.map(({ c, t }) => ({ c, t, bc: commandFor(t, dir, api) })), signal, record);
|
|
57313
57374
|
for (const { c, t } of sus) {
|
|
@@ -57368,6 +57429,8 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
57368
57429
|
const progress = checks.some((c) => wall.has(c.name) && c.result === "pass") || sus.some(({ c }) => !out3.weak.includes(c.name) && base2.get(c).red.length > 0 && (c.n ?? 0) >= base2.get(c).n);
|
|
57369
57430
|
{
|
|
57370
57431
|
for (const { c } of un) {
|
|
57432
|
+
if (c.result === "fail" && c.ids?.length && base2.get(c)?.live)
|
|
57433
|
+
out3.compared.push(c.name);
|
|
57371
57434
|
if (own.has(c.name) || c.result !== "fail" || !c.ids?.length || !comparableIds(c.ids).every((i) => base2.get(c)?.red.includes(i)))
|
|
57372
57435
|
continue;
|
|
57373
57436
|
out3.knownRed.push(c.name);
|
|
@@ -57437,7 +57500,7 @@ function tscOnlyIgnored(repoDir, cwd, out3) {
|
|
|
57437
57500
|
const target = join155(dirname66(file), mod).replace(/\.(js|mjs|cjs|jsx)$/, "");
|
|
57438
57501
|
return ![target, ...[".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".d.ts"].map((e) => target + e), ...["index.ts", "index.tsx", "index.js"].map((e) => join155(target, e))].some((t) => {
|
|
57439
57502
|
try {
|
|
57440
|
-
return
|
|
57503
|
+
return statSync47(t).isFile();
|
|
57441
57504
|
} catch {
|
|
57442
57505
|
return false;
|
|
57443
57506
|
}
|
|
@@ -57649,7 +57712,7 @@ var init_verify = __esm(() => {
|
|
|
57649
57712
|
const rec2 = recorded.get(p), found = map.tests.find((t) => t.path === p && (!rec2 || t.runner === rec2));
|
|
57650
57713
|
if (found)
|
|
57651
57714
|
return [found];
|
|
57652
|
-
const runner = rec2 ?? guessRunner(
|
|
57715
|
+
const runner = rec2 ?? guessRunner(basename44(p), map.runners, p);
|
|
57653
57716
|
return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
|
|
57654
57717
|
});
|
|
57655
57718
|
const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
|
|
@@ -57717,6 +57780,15 @@ var init_verify = __esm(() => {
|
|
|
57717
57780
|
const root = api?.packageRootOf(rel) ?? ".";
|
|
57718
57781
|
return [...new Set([root, "."])].every((d) => !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, zgEnv.ignored ?? null, zgEnv.deps));
|
|
57719
57782
|
};
|
|
57783
|
+
const depsSeen = new Map, depsAsIntake = (rel) => {
|
|
57784
|
+
if (zgEnv.sinceMs === undefined)
|
|
57785
|
+
return false;
|
|
57786
|
+
return [...new Set([api?.packageRootOf(rel) ?? ".", "."])].every((d) => {
|
|
57787
|
+
if (!depsSeen.has(d))
|
|
57788
|
+
depsSeen.set(d, !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, [], zgEnv.deps));
|
|
57789
|
+
return depsSeen.get(d);
|
|
57790
|
+
});
|
|
57791
|
+
};
|
|
57720
57792
|
const touchedRed = new Set(checks.filter((c) => {
|
|
57721
57793
|
const rel = c.name.slice(c.name.indexOf(":") + 1);
|
|
57722
57794
|
return c.result === "fail" && changed.includes(rel) && !wallNames0.has(c.name) && !isHold(c) && envAsIntake(rel) && touchedRedOnBase(ctx.repoDir, ctx.baseSha, { ids: c.ids, errors: headErrors.get(c) }, editedTestTitles(ctx.repoDir, ctx.baseSha, rel));
|
|
@@ -57780,7 +57852,7 @@ var init_verify = __esm(() => {
|
|
|
57780
57852
|
const t = tests.find((x) => testCheckName(x) === name), pkg = t ? api?.packageOf(t.path) : null;
|
|
57781
57853
|
return pkg?.commands.test ? `full suite: ${pkg.name}` : undefined;
|
|
57782
57854
|
};
|
|
57783
|
-
const attr = attribute(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, ids: c.ids, eligible: !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)), ...suiteOf(c.name) && preRed.
|
|
57855
|
+
const attr = attribute(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, ids: c.ids, eligible: !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)), ...suiteOf(c.name) && (preRed.compared.includes(c.name) || depsAsIntake(c.name.slice(c.name.indexOf(":") + 1))) ? { suite: suiteOf(c.name), ...preRed.sameError.includes(c.name) ? { rerun: "same" } : preRed.compared.includes(c.name) ? { rerun: "differs" } : {} } : {} })));
|
|
57784
57856
|
attr.introducedChecks = [...new Set(attr.introducedChecks.map((n3) => isHoldoutCheck(n3) ? "holdout" : n3))];
|
|
57785
57857
|
preRed.names.push(...attr.preExistingChecks);
|
|
57786
57858
|
preRed.ids.push(...attr.preExistingIds);
|
|
@@ -57898,8 +57970,8 @@ var init_verify = __esm(() => {
|
|
|
57898
57970
|
});
|
|
57899
57971
|
|
|
57900
57972
|
// ../../loki-ts/src/runner/stop_checks.ts
|
|
57901
|
-
import { appendFileSync as appendFileSync15, existsSync as existsSync110, mkdirSync as mkdirSync82, readFileSync as readFileSync143, statSync as
|
|
57902
|
-
import { basename as
|
|
57973
|
+
import { appendFileSync as appendFileSync15, existsSync as existsSync110, mkdirSync as mkdirSync82, readFileSync as readFileSync143, statSync as statSync48 } from "fs";
|
|
57974
|
+
import { basename as basename45, isAbsolute as isAbsolute22, join as join156, relative as relative34 } from "path";
|
|
57903
57975
|
function redOnBase(repoDir) {
|
|
57904
57976
|
try {
|
|
57905
57977
|
const b = JSON.parse(readFileSync143(join156(repoDir, ".loki", "state", "repo-profile.json"), "utf8")).baseline;
|
|
@@ -57918,7 +57990,7 @@ function planStopChecks(repoDir, outputs, impacted, stageLimitS, baseSha, env =
|
|
|
57918
57990
|
const p = rel(f.path), found = map.tests.find((t) => t.path === p && (!f.runner || t.runner === f.runner));
|
|
57919
57991
|
if (found)
|
|
57920
57992
|
return [found];
|
|
57921
|
-
const runner = f.runner ?? guessRunner(
|
|
57993
|
+
const runner = f.runner ?? guessRunner(basename45(p), map.runners, p);
|
|
57922
57994
|
return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
|
|
57923
57995
|
});
|
|
57924
57996
|
const red = redOnBase(repoDir), api = loadProjectApi(repoDir), seen = new Set;
|
|
@@ -57952,7 +58024,7 @@ function recordStopBlock(repoDir, name, err, env = process.env) {
|
|
|
57952
58024
|
return;
|
|
57953
58025
|
try {
|
|
57954
58026
|
const p = stopBlocksPath(repoDir);
|
|
57955
|
-
if (existsSync110(p) &&
|
|
58027
|
+
if (existsSync110(p) && statSync48(p).size >= STOP_BLOCKS_MAX_BYTES)
|
|
57956
58028
|
return;
|
|
57957
58029
|
mkdirSync82(join156(repoDir, ".loki", "state"), { recursive: true });
|
|
57958
58030
|
appendFileSync15(p, JSON.stringify({ at: new Date().toISOString(), run_id: runId2.slice(0, 128), name: redactSecrets(name).slice(0, 200), first_error: redactSecrets(err).slice(0, 300) }) + `
|
|
@@ -99213,7 +99285,7 @@ __export(exports_providers, {
|
|
|
99213
99285
|
PROVIDER_COMMIT_HYGIENE: () => PROVIDER_COMMIT_HYGIENE
|
|
99214
99286
|
});
|
|
99215
99287
|
import { mkdirSync as mkdirSync85, existsSync as existsSync112, readFileSync as readFileSync145, realpathSync as realpathSync47, appendFileSync as appendFileSync17 } from "fs";
|
|
99216
|
-
import { delimiter as delimiter5, dirname as dirname69, isAbsolute as isAbsolute24, relative as relative35, resolve as
|
|
99288
|
+
import { delimiter as delimiter5, dirname as dirname69, isAbsolute as isAbsolute24, relative as relative35, resolve as resolve42, sep as sep26 } from "path";
|
|
99217
99289
|
function mergeDisallowedTools(policy, stageCsv) {
|
|
99218
99290
|
return [...new Set([...policy ?? [], ...stageCsv.split(",").filter(Boolean)])];
|
|
99219
99291
|
}
|
|
@@ -99365,7 +99437,7 @@ function physicalPath(path) {
|
|
|
99365
99437
|
try {
|
|
99366
99438
|
return realpathSync47(path);
|
|
99367
99439
|
} catch {
|
|
99368
|
-
return
|
|
99440
|
+
return resolve42(path);
|
|
99369
99441
|
}
|
|
99370
99442
|
}
|
|
99371
99443
|
function hostGuardRequired(cwd) {
|
|
@@ -99478,7 +99550,7 @@ function claudeProvider() {
|
|
|
99478
99550
|
const baseModel = claudeModelFor(call);
|
|
99479
99551
|
const routed = sessionPlanEnabled() ? planRouterSession({
|
|
99480
99552
|
model: baseModel,
|
|
99481
|
-
runDir: process.env["LOKI_DIR"] ??
|
|
99553
|
+
runDir: process.env["LOKI_DIR"] ?? resolve42(call.cwd, ".loki"),
|
|
99482
99554
|
claudeCodeVersion: await installedClaudeCodeVersion(cli)
|
|
99483
99555
|
}) : null;
|
|
99484
99556
|
const model = routed ? routed.model : baseModel;
|
|
@@ -99552,7 +99624,7 @@ function providerCallTimeoutMs(env) {
|
|
|
99552
99624
|
}
|
|
99553
99625
|
function emitSdkDegradationEvent(cwd, payload) {
|
|
99554
99626
|
try {
|
|
99555
|
-
const lokiRoot = process.env["LOKI_DIR"] ??
|
|
99627
|
+
const lokiRoot = process.env["LOKI_DIR"] ?? resolve42(cwd, ".loki");
|
|
99556
99628
|
mkdirSync85(lokiRoot, { recursive: true });
|
|
99557
99629
|
const record = {
|
|
99558
99630
|
type: "capability_degraded",
|
|
@@ -99560,7 +99632,7 @@ function emitSdkDegradationEvent(cwd, payload) {
|
|
|
99560
99632
|
timestamp: new Date().toISOString(),
|
|
99561
99633
|
payload: { capability: "sdk_query", fail_closed: true, ...payload }
|
|
99562
99634
|
};
|
|
99563
|
-
appendFileSync17(
|
|
99635
|
+
appendFileSync17(resolve42(lokiRoot, "events.jsonl"), `${JSON.stringify(record)}
|
|
99564
99636
|
`);
|
|
99565
99637
|
} catch {}
|
|
99566
99638
|
}
|
|
@@ -99574,7 +99646,7 @@ function buildSdkLoopOptions(args) {
|
|
|
99574
99646
|
const out3 = {};
|
|
99575
99647
|
const router = sessionPlanEnabled() ? planRouterSession({
|
|
99576
99648
|
model: args.model,
|
|
99577
|
-
runDir: args.runDir ?? process.env["LOKI_DIR"] ??
|
|
99649
|
+
runDir: args.runDir ?? process.env["LOKI_DIR"] ?? resolve42(args.cwd, ".loki"),
|
|
99578
99650
|
claudeCodeVersion: args.claudeCodeVersion ?? bundledClaudeCodeVersion2()
|
|
99579
99651
|
}) : null;
|
|
99580
99652
|
if (router) {
|
|
@@ -99827,7 +99899,7 @@ __export(exports_session, {
|
|
|
99827
99899
|
});
|
|
99828
99900
|
import { spawn as spawn12 } from "child_process";
|
|
99829
99901
|
import { copyFileSync as copyFileSync11, existsSync as existsSync113, mkdirSync as mkdirSync86, readFileSync as readFileSync146, writeFileSync as writeFileSync84, writeSync as writeSync4 } from "fs";
|
|
99830
|
-
import { dirname as dirname70, join as join159, resolve as
|
|
99902
|
+
import { dirname as dirname70, join as join159, resolve as resolve43 } from "path";
|
|
99831
99903
|
import { tmpdir as tmpdir33 } from "os";
|
|
99832
99904
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
99833
99905
|
function capStopOf(summary) {
|
|
@@ -99896,7 +99968,7 @@ function childEnv2(opts, cfg) {
|
|
|
99896
99968
|
else
|
|
99897
99969
|
delete env["LOKI_E10_DISALLOWED_TOOLS"];
|
|
99898
99970
|
if (opts.outputs?.length)
|
|
99899
|
-
env[HARNESS_OUTPUTS_ENV] = JSON.stringify(opts.outputs.map((p) =>
|
|
99971
|
+
env[HARNESS_OUTPUTS_ENV] = JSON.stringify(opts.outputs.map((p) => resolve43(opts.cwd ?? process.cwd(), p)));
|
|
99900
99972
|
else
|
|
99901
99973
|
delete env[HARNESS_OUTPUTS_ENV];
|
|
99902
99974
|
if (opts.suiteCmds?.length)
|
|
@@ -100102,7 +100174,7 @@ function createSessionRunner(cfg) {
|
|
|
100102
100174
|
}, cfg.heartbeatMs ?? HEARTBEAT_MS_DEFAULT);
|
|
100103
100175
|
opts.signal.addEventListener("abort", onAbort, { once: true });
|
|
100104
100176
|
const untrack = trackSession(() => kill("aborted"));
|
|
100105
|
-
return new Promise((
|
|
100177
|
+
return new Promise((resolve44) => {
|
|
100106
100178
|
child.on("exit", () => reapLiveGroup(pgid, () => cfg.emit?.("session.group_reaped", opts.stage, { session_id: sessionId, pgid })));
|
|
100107
100179
|
child.on("close", (code) => {
|
|
100108
100180
|
clearTimeout(limitTimer);
|
|
@@ -100164,7 +100236,7 @@ function createSessionRunner(cfg) {
|
|
|
100164
100236
|
rememberSessionEffort(psid, ran2);
|
|
100165
100237
|
recordCost(cfg, opts, killed ? "killed" : code === 0 ? "completed" : "failed", durationS, stdout + logText);
|
|
100166
100238
|
untrack();
|
|
100167
|
-
|
|
100239
|
+
resolve44({ exit: guard.ok ? code : 1, markers, durationS, killed, summary: (stdout + logText).trim().slice(-4096), stderrTail: (guard.ok ? "" : `guard violation: ${guard.violations.map((v10) => v10.detail).join("; ")}
|
|
100168
100240
|
`) + stderrTail.toString("utf8") + (logText.match(/^\[sdk-loop error: .*\]$/gm) ?? []).join(`
|
|
100169
100241
|
`) });
|
|
100170
100242
|
});
|
|
@@ -100252,10 +100324,10 @@ var init_model_rank = __esm(() => {
|
|
|
100252
100324
|
|
|
100253
100325
|
// ../../loki-ts/src/engine10/sizing.ts
|
|
100254
100326
|
import { existsSync as existsSync114, readFileSync as readFileSync147 } from "fs";
|
|
100255
|
-
import { basename as
|
|
100327
|
+
import { basename as basename46 } from "path";
|
|
100256
100328
|
function namedFiles(task, map) {
|
|
100257
100329
|
const text4 = task.toLowerCase();
|
|
100258
|
-
const hit2 = (map?.files ?? []).filter((f) => new RegExp(`(?<![\\w.-])${escapeRegex(
|
|
100330
|
+
const hit2 = (map?.files ?? []).filter((f) => new RegExp(`(?<![\\w.-])${escapeRegex(basename46(f).toLowerCase())}(?![\\w-]|\\.\\w)`).test(text4));
|
|
100259
100331
|
if (!namedExactOn())
|
|
100260
100332
|
return hit2;
|
|
100261
100333
|
const spelled = text4.split(/[^\w@.()[\]\/-]+/).filter((t) => t.includes("/")).flatMap((t) => {
|
|
@@ -100263,11 +100335,11 @@ function namedFiles(task, map) {
|
|
|
100263
100335
|
return m ? [m[1]] : [];
|
|
100264
100336
|
});
|
|
100265
100337
|
return hit2.filter((f) => {
|
|
100266
|
-
const b =
|
|
100338
|
+
const b = basename46(f).toLowerCase();
|
|
100267
100339
|
if (new RegExp(`(?<![\\w./-])${escapeRegex(b)}(?![\\w-]|\\.\\w)`).test(text4))
|
|
100268
100340
|
return true;
|
|
100269
100341
|
const lf2 = f.toLowerCase();
|
|
100270
|
-
return spelled.some((t) =>
|
|
100342
|
+
return spelled.some((t) => basename46(t) === b && (lf2 === t || lf2.endsWith(`/${t}`) || t.endsWith(`/${lf2}`)));
|
|
100271
100343
|
});
|
|
100272
100344
|
}
|
|
100273
100345
|
function sizeTask(task, map, tests) {
|
|
@@ -100291,8 +100363,8 @@ function sizeTask(task, map, tests) {
|
|
|
100291
100363
|
function namedDistinct(task, map) {
|
|
100292
100364
|
const text4 = task.toLowerCase(), named2 = namedFiles(task, map).filter((f) => !isTestFile(f)).map((f) => f.toLowerCase());
|
|
100293
100365
|
const spelled = new Set(named2.filter((f) => f.includes("/") && new RegExp(`(?<![\\w./-])(?:\\./)?${escapeRegex(f)}(?![\\w-]|\\.\\w)`).test(text4)));
|
|
100294
|
-
const spelledBase = new Set([...spelled].map((f) =>
|
|
100295
|
-
return spelled.size + new Set(named2.map((f) =>
|
|
100366
|
+
const spelledBase = new Set([...spelled].map((f) => basename46(f)));
|
|
100367
|
+
return spelled.size + new Set(named2.map((f) => basename46(f)).filter((b) => !spelledBase.has(b))).size;
|
|
100296
100368
|
}
|
|
100297
100369
|
function hardReason(size, map, task) {
|
|
100298
100370
|
if (size === "large")
|
|
@@ -100785,9 +100857,9 @@ var init_python_build_check = __esm(() => {
|
|
|
100785
100857
|
// ../../loki-ts/src/util/check_result.ts
|
|
100786
100858
|
import { spawn as spawn13, spawnSync as spawnSync28 } from "child_process";
|
|
100787
100859
|
import { createHash as createHash40 } from "crypto";
|
|
100788
|
-
import { copyFileSync as copyFileSync12, existsSync as existsSync117, lstatSync as lstatSync35, mkdirSync as mkdirSync89, readlinkSync as readlinkSync10, mkdtempSync as mkdtempSync27, readdirSync as readdirSync56, readFileSync as readFileSync149, realpathSync as realpathSync48, renameSync as renameSync29, rmSync as rmSync53, statSync as
|
|
100860
|
+
import { copyFileSync as copyFileSync12, existsSync as existsSync117, lstatSync as lstatSync35, mkdirSync as mkdirSync89, readlinkSync as readlinkSync10, mkdtempSync as mkdtempSync27, readdirSync as readdirSync56, readFileSync as readFileSync149, realpathSync as realpathSync48, renameSync as renameSync29, rmSync as rmSync53, statSync as statSync50, writeFileSync as writeFileSync87 } from "fs";
|
|
100789
100861
|
import { homedir as homedir16, tmpdir as tmpdir34 } from "os";
|
|
100790
|
-
import { basename as
|
|
100862
|
+
import { basename as basename47, dirname as dirname71, isAbsolute as isAbsolute25, join as join164, normalize as normalize9, relative as relative36, resolve as resolve44, sep as sep27 } from "path";
|
|
100791
100863
|
function plainTestEnv(base2 = process.env) {
|
|
100792
100864
|
const e10 = {};
|
|
100793
100865
|
for (const [k10, v10] of Object.entries(tokenFreeEnv(base2)))
|
|
@@ -100806,7 +100878,7 @@ function ran(raw2, path, ok2) {
|
|
|
100806
100878
|
if (blk) {
|
|
100807
100879
|
const c = n10(blk, /(?:#|\u2139) pass (\d+)/) + n10(blk, /(?:#|\u2139) fail (\d+)/);
|
|
100808
100880
|
const nm2 = out3.match(/^(?:ok \d+ - |\u2714 )(\S+\.[cm]?[jt]s)(?: \(|$)/m)?.[1];
|
|
100809
|
-
return c === 1 && nm2 && (!path ||
|
|
100881
|
+
return c === 1 && nm2 && (!path || basename47(nm2) === basename47(path)) ? 0 : c;
|
|
100810
100882
|
}
|
|
100811
100883
|
const cg2 = cargoTrailer(out3);
|
|
100812
100884
|
if (cg2.length)
|
|
@@ -101061,7 +101133,7 @@ function runsTool(tool, words3, depth) {
|
|
|
101061
101133
|
return NO2;
|
|
101062
101134
|
if (w.includes("$"))
|
|
101063
101135
|
return varIsTool(tool, w) ? YES : UNKNOWN;
|
|
101064
|
-
const name =
|
|
101136
|
+
const name = basename47(w);
|
|
101065
101137
|
if (wordIsTool(tool, w))
|
|
101066
101138
|
return YES;
|
|
101067
101139
|
if (SHELL_WORDS.has(name)) {
|
|
@@ -101115,7 +101187,7 @@ function goRunner(cmd2, args) {
|
|
|
101115
101187
|
return mentionsTool("go", cmd2, args) ? { runner: "go" } : {};
|
|
101116
101188
|
}
|
|
101117
101189
|
function parseCargo(toks2) {
|
|
101118
|
-
if (
|
|
101190
|
+
if (basename47(toks2[0] ?? "") !== "cargo" || toks2.some((t) => /[&|;$`"'<>()\\]/.test(t)))
|
|
101119
101191
|
return null;
|
|
101120
101192
|
let k10 = 1;
|
|
101121
101193
|
for (;k10 < toks2.length; k10++) {
|
|
@@ -101196,12 +101268,12 @@ function cargoRunnerConfigured(cwd, env, toks2) {
|
|
|
101196
101268
|
for (const v10 of vals) {
|
|
101197
101269
|
if (CARGO_REDIRECT_TEXT(v10))
|
|
101198
101270
|
return true;
|
|
101199
|
-
const f =
|
|
101271
|
+
const f = resolve44(cwd, v10);
|
|
101200
101272
|
if (existsSync117(f) && lstatSync35(f).isFile() && doubtful(f))
|
|
101201
101273
|
return true;
|
|
101202
101274
|
}
|
|
101203
101275
|
const dirs = [env["CARGO_HOME"] ?? join164(env["HOME"] ?? homedir16(), ".cargo"), join164(homedir16(), ".cargo")];
|
|
101204
|
-
for (let d =
|
|
101276
|
+
for (let d = resolve44(cwd), prev = "";d !== prev; prev = d, d = dirname71(d))
|
|
101205
101277
|
dirs.push(join164(d, ".cargo"));
|
|
101206
101278
|
return dirs.some((dir) => ["config", "config.toml"].some((f) => existsSync117(join164(dir, f)) && doubtful(join164(dir, f))));
|
|
101207
101279
|
}
|
|
@@ -101220,7 +101292,7 @@ function cargoToolchainRedirected(cwd, env) {
|
|
|
101220
101292
|
return true;
|
|
101221
101293
|
}
|
|
101222
101294
|
};
|
|
101223
|
-
for (let d =
|
|
101295
|
+
for (let d = resolve44(cwd), prev = "";d !== prev; prev = d, d = dirname71(d))
|
|
101224
101296
|
if (["rust-toolchain", "rust-toolchain.toml"].some((f) => lstatOk(join164(d, f)) && doubtful(join164(d, f))))
|
|
101225
101297
|
return true;
|
|
101226
101298
|
return false;
|
|
@@ -101289,13 +101361,13 @@ function compilerSettingIn(raw2) {
|
|
|
101289
101361
|
}
|
|
101290
101362
|
function cargoRepoRoot(cwd) {
|
|
101291
101363
|
let top = null;
|
|
101292
|
-
for (let d =
|
|
101364
|
+
for (let d = resolve44(cwd), prev = "";d !== prev; prev = d, d = dirname71(d)) {
|
|
101293
101365
|
if (existsSync117(join164(d, ".git")))
|
|
101294
101366
|
return d;
|
|
101295
101367
|
if (existsSync117(join164(d, "Cargo.toml")))
|
|
101296
101368
|
top = d;
|
|
101297
101369
|
}
|
|
101298
|
-
return top ??
|
|
101370
|
+
return top ?? resolve44(cwd);
|
|
101299
101371
|
}
|
|
101300
101372
|
function topLevelDoubt(t) {
|
|
101301
101373
|
let q = "", depth = 0, lineStart = true;
|
|
@@ -101344,16 +101416,16 @@ function cargoProfileRustflagsManifest(root, cwd, toks2) {
|
|
|
101344
101416
|
}
|
|
101345
101417
|
};
|
|
101346
101418
|
const seen = new Set, files = [];
|
|
101347
|
-
for (let d =
|
|
101419
|
+
for (let d = resolve44(cwd), prev = "";d !== prev; prev = d, d = dirname71(d)) {
|
|
101348
101420
|
files.push(join164(d, "Cargo.toml"));
|
|
101349
101421
|
if (d === root)
|
|
101350
101422
|
break;
|
|
101351
101423
|
}
|
|
101352
101424
|
toks2.forEach((t, i) => {
|
|
101353
101425
|
if (t === "--manifest-path")
|
|
101354
|
-
files.push(
|
|
101426
|
+
files.push(resolve44(cwd, toks2[i + 1] ?? ""));
|
|
101355
101427
|
else if (t.startsWith("--manifest-path="))
|
|
101356
|
-
files.push(
|
|
101428
|
+
files.push(resolve44(cwd, t.slice(16)));
|
|
101357
101429
|
});
|
|
101358
101430
|
for (let stack = [[root, 0]], seenDirs = 0;stack.length && seenDirs < 500; ) {
|
|
101359
101431
|
const [d, depth] = stack.pop();
|
|
@@ -101393,19 +101465,19 @@ function cargoRepoCompilerRedirected(cwd, env, toks2) {
|
|
|
101393
101465
|
const inline = compilerSettingIn(v10);
|
|
101394
101466
|
if (inline)
|
|
101395
101467
|
return cargoCompilerReason(inline, "--config");
|
|
101396
|
-
const f =
|
|
101468
|
+
const f = resolve44(cwd, v10);
|
|
101397
101469
|
if (existsSync117(f) && lstatSync35(f).isFile()) {
|
|
101398
101470
|
const w = inFile(f);
|
|
101399
101471
|
if (w)
|
|
101400
101472
|
return cargoCompilerReason(w, v10);
|
|
101401
101473
|
}
|
|
101402
101474
|
}
|
|
101403
|
-
const home = new Set([
|
|
101475
|
+
const home = new Set([resolve44(env["CARGO_HOME"] || join164(env["HOME"] || homedir16(), ".cargo")), resolve44(homedir16(), ".cargo")]);
|
|
101404
101476
|
const aboveRoot = (dir) => {
|
|
101405
101477
|
const r = relative36(dirname71(dir), root);
|
|
101406
101478
|
return r !== "" && !r.startsWith("..") && !isAbsolute25(r);
|
|
101407
101479
|
};
|
|
101408
|
-
for (let d =
|
|
101480
|
+
for (let d = resolve44(cwd), prev = "";d !== prev; prev = d, d = dirname71(d)) {
|
|
101409
101481
|
const dir = join164(d, ".cargo");
|
|
101410
101482
|
if (home.has(dir) && aboveRoot(dir))
|
|
101411
101483
|
continue;
|
|
@@ -101498,7 +101570,7 @@ function* corroborateGoSteps(c, out3, cmdOrLine, args, toks2, o) {
|
|
|
101498
101570
|
const first = goJson(stripAnsi(out3));
|
|
101499
101571
|
const names = first?.passedNames ?? [];
|
|
101500
101572
|
const shellish = (t, i) => /[&|;$`"'<>()\\]/.test(t) && !(args !== undefined && toks2[i - 1] === "-run" && /^\^\([A-Za-z0-9_|]+\)\$$/.test(t));
|
|
101501
|
-
if (!names.length || toks2.some(shellish) ||
|
|
101573
|
+
if (!names.length || toks2.some(shellish) || basename47(toks2[0] ?? "") !== "go" || toks2[1] !== "test")
|
|
101502
101574
|
return refuse;
|
|
101503
101575
|
const pkgs = [], run2 = [];
|
|
101504
101576
|
for (let k10 = 2;k10 < toks2.length; k10++) {
|
|
@@ -101668,7 +101740,7 @@ function javaSummary(raw2) {
|
|
|
101668
101740
|
return null;
|
|
101669
101741
|
}
|
|
101670
101742
|
function javaTestClass(path) {
|
|
101671
|
-
const m = /^(.*?)\/?src\/test\/java\/(.+)\.java$/.exec(path), cls = (m ? m[2] :
|
|
101743
|
+
const m = /^(.*?)\/?src\/test\/java\/(.+)\.java$/.exec(path), cls = (m ? m[2] : basename47(path, ".java")).split("/").join(".");
|
|
101672
101744
|
return { root: m?.[1] || ".", cls, rel: m ? `src/test/java/${m[2]}.java` : path };
|
|
101673
101745
|
}
|
|
101674
101746
|
function testCount(raw2, path, ok2) {
|
|
@@ -102204,7 +102276,7 @@ function publishableWall(repoDir, runDir, o, env = process.env, task) {
|
|
|
102204
102276
|
const listed = arr5(o.wall?.["files"]);
|
|
102205
102277
|
for (const w of listed) {
|
|
102206
102278
|
const rel = relative36(repoDir, String(w["path"])), hit2 = arr5(o.verify?.["checks"]).find((c) => tgt.has(String(c["name"])) && String(c["name"]).slice(String(c["name"]).indexOf(":") + 1) === rel && hasExecutedProof([c]));
|
|
102207
|
-
if (!hit2 || rel.startsWith("..") || isAbsolute25(rel) || rel.startsWith(".loki/") || !
|
|
102279
|
+
if (!hit2 || rel.startsWith("..") || isAbsolute25(rel) || rel.startsWith(".loki/") || !basename47(rel).startsWith("loki_wall_"))
|
|
102208
102280
|
continue;
|
|
102209
102281
|
try {
|
|
102210
102282
|
const bytes = readFileSync149(sealedWallCopy(runDir, rel));
|
|
@@ -102262,12 +102334,12 @@ function loadSealedWall(runDir, unitRepoDir) {
|
|
|
102262
102334
|
continue;
|
|
102263
102335
|
}
|
|
102264
102336
|
try {
|
|
102265
|
-
const bytes = readFileSync149(join164(runDir, "wall",
|
|
102337
|
+
const bytes = readFileSync149(join164(runDir, "wall", basename47(rel)));
|
|
102266
102338
|
if (createHash40("sha256").update(bytes).digest("hex") !== w.sha256)
|
|
102267
102339
|
throw new Error("hash");
|
|
102268
102340
|
files.push({ rel, bytes, ...typeof w.runner === "string" ? { runner: w.runner } : {} });
|
|
102269
102341
|
} catch {
|
|
102270
|
-
problems.push(`sealed Wall copy ${
|
|
102342
|
+
problems.push(`sealed Wall copy ${basename47(rel)} missing or not the sealed bytes`);
|
|
102271
102343
|
}
|
|
102272
102344
|
}
|
|
102273
102345
|
return { files, problems };
|
|
@@ -102333,7 +102405,7 @@ function hiddenEdits(repoDir) {
|
|
|
102333
102405
|
try {
|
|
102334
102406
|
const idxRel = safeGit(repoDir, ["rev-parse", "--git-path", "index"]).trim(), idx = isAbsolute25(idxRel) ? idxRel : join164(repoDir, idxRel);
|
|
102335
102407
|
const flags = new Map;
|
|
102336
|
-
for (const l of safeGit(repoDir, ["-c", "core.quotePath=false", "ls-files", "-v", "-z"], { maxBuffer: Math.max(64 << 20,
|
|
102408
|
+
for (const l of safeGit(repoDir, ["-c", "core.quotePath=false", "ls-files", "-v", "-z"], { maxBuffer: Math.max(64 << 20, statSync50(idx).size * 32) }).split("\x00")) {
|
|
102337
102409
|
const m = /^([a-zS]) ([\s\S]+)$/.exec(l);
|
|
102338
102410
|
if (m)
|
|
102339
102411
|
flags.set(m[2], m[1]);
|
|
@@ -102378,16 +102450,16 @@ function execFiles(repoDir) {
|
|
|
102378
102450
|
} catch {
|
|
102379
102451
|
return null;
|
|
102380
102452
|
}
|
|
102381
|
-
const roots = new Set([".venv", "venv", ...all.filter((f) =>
|
|
102453
|
+
const roots = new Set([".venv", "venv", ...all.filter((f) => basename47(f) === "pyvenv.cfg").map((f) => dirname71(f))]);
|
|
102382
102454
|
const inVenvBin = (f) => {
|
|
102383
102455
|
for (let d = dirname71(f);d !== "." && d !== "/"; d = dirname71(d))
|
|
102384
|
-
if ((
|
|
102456
|
+
if ((basename47(d) === "bin" || basename47(d) === "Scripts") && roots.has(dirname71(d)))
|
|
102385
102457
|
return true;
|
|
102386
102458
|
return false;
|
|
102387
102459
|
};
|
|
102388
102460
|
const out3 = {};
|
|
102389
102461
|
for (const f of all) {
|
|
102390
|
-
if (!(EXEC_NAMES.has(
|
|
102462
|
+
if (!(EXEC_NAMES.has(basename47(f)) || VENV_TOOL.test(basename47(f)) && inVenvBin(f)))
|
|
102391
102463
|
continue;
|
|
102392
102464
|
const abs = join164(repoDir, f);
|
|
102393
102465
|
try {
|
|
@@ -102409,7 +102481,7 @@ function ignoreSnapshot(repoDir) {
|
|
|
102409
102481
|
const resolved = (args, dflt) => {
|
|
102410
102482
|
try {
|
|
102411
102483
|
const v10 = safeGit(repoDir, args).trim();
|
|
102412
|
-
return v10 ?
|
|
102484
|
+
return v10 ? resolve44(repoDir, v10) : dflt;
|
|
102413
102485
|
} catch {
|
|
102414
102486
|
return dflt;
|
|
102415
102487
|
}
|
|
@@ -102430,10 +102502,10 @@ function noteLabel(repoDir, p) {
|
|
|
102430
102502
|
const h10 = home ? inside2(home) : null;
|
|
102431
102503
|
if (h10)
|
|
102432
102504
|
return `~/${h10}`;
|
|
102433
|
-
return
|
|
102505
|
+
return basename47(p);
|
|
102434
102506
|
}
|
|
102435
102507
|
function pureToolCache(repoDir, dir) {
|
|
102436
|
-
const text4 = TOOL_CACHE_GITIGNORE[
|
|
102508
|
+
const text4 = TOOL_CACHE_GITIGNORE[basename47(dir)];
|
|
102437
102509
|
if (text4 === undefined)
|
|
102438
102510
|
return false;
|
|
102439
102511
|
try {
|
|
@@ -102450,7 +102522,7 @@ function pureToolCache(repoDir, dir) {
|
|
|
102450
102522
|
return false;
|
|
102451
102523
|
continue;
|
|
102452
102524
|
}
|
|
102453
|
-
if (!e10.isFile() || CACHE_CODE_EXT.test(e10.name) || (EXEC_NAMES.has(e10.name) || /^(conftest|sitecustomize|usercustomize)\./.test(e10.name)) && e10.name !== ".gitignore" || /^python/i.test(e10.name) || (
|
|
102525
|
+
if (!e10.isFile() || CACHE_CODE_EXT.test(e10.name) || (EXEC_NAMES.has(e10.name) || /^(conftest|sitecustomize|usercustomize)\./.test(e10.name)) && e10.name !== ".gitignore" || /^python/i.test(e10.name) || (statSync50(join164(repoDir, r)).mode & 73) !== 0)
|
|
102454
102526
|
return false;
|
|
102455
102527
|
}
|
|
102456
102528
|
return true;
|
|
@@ -102478,14 +102550,14 @@ function ignoreRuleChanges(repoDir, snap, baseSha) {
|
|
|
102478
102550
|
const prior = s.exec_files, cur = execFiles(repoDir);
|
|
102479
102551
|
if (!prior || !cur)
|
|
102480
102552
|
return ["ignore rules could not be compared with the intake snapshot: the ignored files that can change what verify runs were not recorded or could not be listed"];
|
|
102481
|
-
const gi2 = new Set(changedFiles(repoDir, baseSha ?? "HEAD").filter((f) =>
|
|
102553
|
+
const gi2 = new Set(changedFiles(repoDir, baseSha ?? "HEAD").filter((f) => basename47(f) === ".gitignore"));
|
|
102482
102554
|
const hidden = [];
|
|
102483
102555
|
for (const [f, h10] of Object.entries(cur)) {
|
|
102484
102556
|
if (prior[f] === h10)
|
|
102485
102557
|
continue;
|
|
102486
|
-
if (
|
|
102558
|
+
if (basename47(f) === ".gitignore" && pureToolCache(repoDir, dirname71(f)))
|
|
102487
102559
|
continue;
|
|
102488
|
-
if (
|
|
102560
|
+
if (basename47(f) === ".gitignore")
|
|
102489
102561
|
gi2.add(f);
|
|
102490
102562
|
else
|
|
102491
102563
|
hidden.push(f);
|
|
@@ -102498,7 +102570,7 @@ function ignoreRuleChanges(repoDir, snap, baseSha) {
|
|
|
102498
102570
|
return [];
|
|
102499
102571
|
const made = listIgnoredFiles(repoDir).filter((f) => {
|
|
102500
102572
|
try {
|
|
102501
|
-
const st2 =
|
|
102573
|
+
const st2 = statSync50(join164(repoDir, f));
|
|
102502
102574
|
return Math.max(st2.birthtimeMs, st2.mtimeMs) >= s.at;
|
|
102503
102575
|
} catch {
|
|
102504
102576
|
return false;
|
|
@@ -102830,15 +102902,15 @@ function missingRelativeImportIsRed(f, raw2, repoDir) {
|
|
|
102830
102902
|
hits.push({ spec: m[1], importer: m[2] });
|
|
102831
102903
|
if (hits.length === 0)
|
|
102832
102904
|
return false;
|
|
102833
|
-
const abs =
|
|
102905
|
+
const abs = resolve44(repoDir, f.path);
|
|
102834
102906
|
return hits.every(({ spec, importer }) => {
|
|
102835
102907
|
if (!/^\.\.?(?:\/|$)/.test(spec) || !(abs === importer || abs.endsWith("/" + importer.replace(/^\.\//, "")) || importer.endsWith("/" + f.path) || importer === f.path))
|
|
102836
102908
|
return false;
|
|
102837
|
-
const target =
|
|
102909
|
+
const target = resolve44(dirname71(abs), spec.replace(/[?#].*$/, ""));
|
|
102838
102910
|
const stem2 = target.replace(/\.(?:jsx?|mjs|cjs)$/, "");
|
|
102839
|
-
if (existsSync117(target) &&
|
|
102911
|
+
if (existsSync117(target) && statSync50(target).isDirectory())
|
|
102840
102912
|
return false;
|
|
102841
|
-
return ![target, stem2].some((t) => ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".json"].some((x10) => existsSync117(t + x10) &&
|
|
102913
|
+
return ![target, stem2].some((t) => ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".json"].some((x10) => existsSync117(t + x10) && statSync50(t + x10).isFile())) && !["ts", "tsx", "js", "jsx", "mjs", "cjs"].some((x10) => existsSync117(join164(target, `index.${x10}`)));
|
|
102842
102914
|
});
|
|
102843
102915
|
}
|
|
102844
102916
|
function classify(f, status, output, repoDir, interpreter) {
|
|
@@ -103090,7 +103162,7 @@ ${r.stderr ?? ""}` };
|
|
|
103090
103162
|
}
|
|
103091
103163
|
}
|
|
103092
103164
|
function spawnCollect(cmd2, args, o) {
|
|
103093
|
-
return new Promise((
|
|
103165
|
+
return new Promise((resolve45) => {
|
|
103094
103166
|
let out3 = "", err = "", error = false, done = false;
|
|
103095
103167
|
const MAX = o.maxBytes ?? 1024 * 1024;
|
|
103096
103168
|
const timers = [];
|
|
@@ -103101,7 +103173,7 @@ function spawnCollect(cmd2, args, o) {
|
|
|
103101
103173
|
o.signal?.removeEventListener("abort", abort);
|
|
103102
103174
|
killGroup2(c.pid, "SIGKILL");
|
|
103103
103175
|
wd2?.kill("SIGKILL");
|
|
103104
|
-
|
|
103176
|
+
resolve45({ status: error ? null : status, output: `${out3}
|
|
103105
103177
|
${err}` });
|
|
103106
103178
|
}
|
|
103107
103179
|
};
|
|
@@ -103237,7 +103309,7 @@ function runnerCmd(t, repoDir) {
|
|
|
103237
103309
|
case "dotnet":
|
|
103238
103310
|
return dotnetTestCmd(repoDir, t.path);
|
|
103239
103311
|
case "cargo":
|
|
103240
|
-
return CARGO_TEST_FILE_RE.test(t.path) ? ["cargo", ["test", "--test",
|
|
103312
|
+
return CARGO_TEST_FILE_RE.test(t.path) ? ["cargo", ["test", "--test", basename47(t.path, ".rs")]] : ["cargo", ["test"]];
|
|
103241
103313
|
}
|
|
103242
103314
|
}
|
|
103243
103315
|
function fullSuiteCmd(runner, repoDir) {
|
|
@@ -103455,7 +103527,7 @@ function firstFileLineAnchor(desc2) {
|
|
|
103455
103527
|
}
|
|
103456
103528
|
return null;
|
|
103457
103529
|
}
|
|
103458
|
-
var NO_TESTS_REASON = "no tests executed", sealedWallDir = (runDir) => join164(runDir, "wall"), sealedWallCopy = (runDir, path) => join164(sealedWallDir(runDir),
|
|
103530
|
+
var NO_TESTS_REASON = "no tests executed", sealedWallDir = (runDir) => join164(runDir, "wall"), sealedWallCopy = (runDir, path) => join164(sealedWallDir(runDir), basename47(path)), NO_RUNNER_REASON = "no runner of this repo runs this file", harnessSkipCode = (env = process.env) => env.LOKI_WALL_HARNESS_RUNNER === "0" ? "harness_runner_disabled" : Bun.which("bun", { PATH: env.PATH ?? "" }) ? "no_toolchain" : "bun_not_on_path", GO_EXIT0_REASON = "test count could not be confirmed: go test output is produced by the code under test and cannot confirm execution (a Go exit 0 is never a pass)", UNCONFIRMED_REASON = "test count could not be confirmed", FAIL_EVIDENCE, GO_FAIL_EVIDENCE, UNMEASURED_REASON = "executed count unmeasured (Loki could not parse the runner summary, harness-owned)", pytestPrettyOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PYTEST_PRETTY"] ?? "").trim()), stripAnsi = (s) => s.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, "").replace(/(?:\u001b\[|\u009b)[0-9;?]*[ -\/]*[@-~]/g, "").replace(/\r\n?/g, `
|
|
103459
103531
|
`), tailLines = (out3) => out3.split(`
|
|
103460
103532
|
`).filter((x10) => x10.trim()).slice(-12), CARGO_NOISE, cargoMergedDoctestOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_CARGO_MERGED_DOCTEST"] ?? "").trim()), DOCTEST_NOTE, cargoNoise = (l) => CARGO_NOISE.test(l) || cargoMergedDoctestOn() && DOCTEST_NOTE.test(l), GO_PKG_RE, GO_SRC, GO_DIR, GO_PKG_AFTER, GO_MAIN_BEFORE, GO_IDENT, GO_MAJOR, GO_KEYWORDS, goRel = (r) => r.replace(/^(?:\.\/)+/, ""), GO_NON_PKG_WORD, goIgnoredPath = (rel) => rel.split("/").some((g10) => g10 === "testdata" || g10.startsWith("_") || g10.startsWith(".")), goSiblingPkg = (dir) => existsSync117(dir) ? readdirSync56(dir).filter((f) => f.endsWith(".go") && !f.endsWith("_test.go")).map((f) => /^package\s+(\w+)/m.exec(readFileSync149(join164(dir, f), "utf8"))?.[1]).find(Boolean) : undefined, goDirPackage = (dir) => goSiblingPkg(dir) ?? (existsSync117(dir) ? readdirSync56(dir).filter((f) => f.endsWith("_test.go")).map((f) => /^package\s+(\w+)/m.exec(readFileSync149(join164(dir, f), "utf8"))?.[1]?.replace(/_test$/, "")).find(Boolean) : undefined), goPackageBrief = (repoDir, targetDir, runners, texts, importPathOf) => {
|
|
103461
103533
|
if (!runners.includes("go"))
|
|
@@ -103470,7 +103542,7 @@ Go: your test files sit in the package directory, so each one starts with "packa
|
|
|
103470
103542
|
|
|
103471
103543
|
Go: your test files are copied into ${relative36(repoDir, targetDir) || "the repository root"}/, whose existing Go files declare "package ${here}". Start each file with "package ${here}"; any other package clause breaks that directory's build and the file is discarded.${imp ? ` Import the package under test as "${imp}" and call its identifiers qualified (${p.pkg}.Name).` : ""}` : "";
|
|
103472
103544
|
}, KNOWN_RUNNERS, SHELL_WORDS, RESERVED_WORDS, WRAPPERS, NO2 = 0, YES = 1, UNKNOWN = 2, triOr = (a, b) => a === YES || b === YES ? YES : a === UNKNOWN || b === UNKNOWN ? UNKNOWN : NO2, TOOL_ALIASES, INLINE_CODE_FLAGS, INTERPRETERS, GO_VERSIONED, wordIsTool = (tool, w) => {
|
|
103473
|
-
const name =
|
|
103545
|
+
const name = basename47(w);
|
|
103474
103546
|
return name === tool || (TOOL_ALIASES[tool]?.includes(name) ?? false) || tool === "go" && GO_VERSIONED.test(name);
|
|
103475
103547
|
}, TOOL_PATH_VARS, varNamesTool = (tool, v10) => {
|
|
103476
103548
|
const l = v10.toLowerCase(), last = l.split("_").pop();
|
|
@@ -103699,7 +103771,7 @@ var init_check_result = __esm(() => {
|
|
|
103699
103771
|
});
|
|
103700
103772
|
|
|
103701
103773
|
// ../../loki-ts/src/council/finding_schema.ts
|
|
103702
|
-
import { existsSync as existsSync118, readdirSync as readdirSync57, readFileSync as readFileSync150, statSync as
|
|
103774
|
+
import { existsSync as existsSync118, readdirSync as readdirSync57, readFileSync as readFileSync150, statSync as statSync51 } from "fs";
|
|
103703
103775
|
import { resolve as resolvePath3, dirname as dirname72, relative as relative37, isAbsolute as isAbsolute26, join as join165, sep as sep28 } from "path";
|
|
103704
103776
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
103705
103777
|
function resolveSchemaDataDir(moduleDir = _moduleDir, candidates2 = SCHEMA_DATA_DIR_CANDIDATES) {
|
|
@@ -104182,16 +104254,16 @@ var init_values = __esm(() => {
|
|
|
104182
104254
|
});
|
|
104183
104255
|
|
|
104184
104256
|
// ../../loki-ts/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs
|
|
104185
|
-
var sleep = (ms, signal) => new Promise((
|
|
104257
|
+
var sleep = (ms, signal) => new Promise((resolve45) => {
|
|
104186
104258
|
if (signal?.aborted)
|
|
104187
|
-
return
|
|
104259
|
+
return resolve45();
|
|
104188
104260
|
const onAbort = () => {
|
|
104189
104261
|
clearTimeout(timer);
|
|
104190
|
-
|
|
104262
|
+
resolve45();
|
|
104191
104263
|
};
|
|
104192
104264
|
const timer = setTimeout(() => {
|
|
104193
104265
|
signal?.removeEventListener("abort", onAbort);
|
|
104194
|
-
|
|
104266
|
+
resolve45();
|
|
104195
104267
|
}, ms);
|
|
104196
104268
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
104197
104269
|
});
|
|
@@ -107528,8 +107600,8 @@ var init_api_promise = __esm(() => {
|
|
|
107528
107600
|
|
|
107529
107601
|
class APIPromise2 extends Promise {
|
|
107530
107602
|
constructor(client, responsePromise, parseResponse = defaultParseResponse) {
|
|
107531
|
-
super((
|
|
107532
|
-
|
|
107603
|
+
super((resolve45) => {
|
|
107604
|
+
resolve45(null);
|
|
107533
107605
|
});
|
|
107534
107606
|
this.responsePromise = responsePromise;
|
|
107535
107607
|
this.parseResponse = parseResponse;
|
|
@@ -109808,16 +109880,16 @@ var init_async_queue = __esm(() => {
|
|
|
109808
109880
|
if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f") || signal?.aborted) {
|
|
109809
109881
|
return Promise.resolve({ done: true, value: undefined });
|
|
109810
109882
|
}
|
|
109811
|
-
return new Promise((
|
|
109883
|
+
return new Promise((resolve45) => {
|
|
109812
109884
|
const waiter = (r) => {
|
|
109813
109885
|
signal?.removeEventListener("abort", onAbort);
|
|
109814
|
-
|
|
109886
|
+
resolve45(r);
|
|
109815
109887
|
};
|
|
109816
109888
|
const onAbort = () => {
|
|
109817
109889
|
const idx = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").indexOf(waiter);
|
|
109818
109890
|
if (idx >= 0)
|
|
109819
109891
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").splice(idx, 1);
|
|
109820
|
-
|
|
109892
|
+
resolve45({ done: true, value: undefined });
|
|
109821
109893
|
};
|
|
109822
109894
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").push(waiter);
|
|
109823
109895
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -110470,13 +110542,13 @@ var init_json_schema = () => {};
|
|
|
110470
110542
|
|
|
110471
110543
|
// ../../loki-ts/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs
|
|
110472
110544
|
function promiseWithResolvers() {
|
|
110473
|
-
let
|
|
110545
|
+
let resolve45;
|
|
110474
110546
|
let reject;
|
|
110475
110547
|
const promise = new Promise((res, rej) => {
|
|
110476
|
-
|
|
110548
|
+
resolve45 = res;
|
|
110477
110549
|
reject = rej;
|
|
110478
110550
|
});
|
|
110479
|
-
return { promise, resolve:
|
|
110551
|
+
return { promise, resolve: resolve45, reject };
|
|
110480
110552
|
}
|
|
110481
110553
|
|
|
110482
110554
|
// ../../loki-ts/node_modules/@anthropic-ai/sdk/internal/node.mjs
|
|
@@ -111257,10 +111329,10 @@ async function settledOrAborted(p, signal) {
|
|
|
111257
111329
|
return;
|
|
111258
111330
|
}
|
|
111259
111331
|
let onAbort;
|
|
111260
|
-
const aborted = new Promise((
|
|
111261
|
-
onAbort =
|
|
111332
|
+
const aborted = new Promise((resolve45) => {
|
|
111333
|
+
onAbort = resolve45;
|
|
111262
111334
|
if (signal.aborted)
|
|
111263
|
-
|
|
111335
|
+
resolve45();
|
|
111264
111336
|
});
|
|
111265
111337
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
111266
111338
|
try {
|
|
@@ -112217,7 +112289,7 @@ function betaGrepTool(ctx) {
|
|
|
112217
112289
|
});
|
|
112218
112290
|
}
|
|
112219
112291
|
function runRipgrep(rg2, pattern, searchPath, signal) {
|
|
112220
|
-
return new Promise((
|
|
112292
|
+
return new Promise((resolve46, reject) => {
|
|
112221
112293
|
const proc = cp2.spawn(rg2, ["-n", "--no-heading", "-e", pattern, "--", searchPath], {
|
|
112222
112294
|
...signal ? { signal } : {}
|
|
112223
112295
|
});
|
|
@@ -112239,12 +112311,12 @@ function runRipgrep(rg2, pattern, searchPath, signal) {
|
|
|
112239
112311
|
if (signal?.aborted)
|
|
112240
112312
|
return reject(new ToolError("grep: aborted"));
|
|
112241
112313
|
if (truncated)
|
|
112242
|
-
return
|
|
112314
|
+
return resolve46(out3 + `
|
|
112243
112315
|
[output truncated at ${GREP_OUTPUT_LIMIT} bytes]`);
|
|
112244
112316
|
if (code === 0)
|
|
112245
|
-
return
|
|
112317
|
+
return resolve46(out3);
|
|
112246
112318
|
if (code === 1)
|
|
112247
|
-
return
|
|
112319
|
+
return resolve46("no matches");
|
|
112248
112320
|
reject(new ToolError(`grep: rg failed: ${errOut || `exit ${code}`}`));
|
|
112249
112321
|
});
|
|
112250
112322
|
proc.on("error", (e10) => {
|
|
@@ -112416,8 +112488,8 @@ var init_node2 = __esm(() => {
|
|
|
112416
112488
|
`;
|
|
112417
112489
|
__classPrivateFieldGet(this, _BashSession_proc, "f").stdin.write(wrapped);
|
|
112418
112490
|
if (__classPrivateFieldGet(this, _BashSession_buf, "f").indexOf(sentinel3) < 0) {
|
|
112419
|
-
const { promise: sentinelSeen, resolve:
|
|
112420
|
-
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve:
|
|
112491
|
+
const { promise: sentinelSeen, resolve: resolve46 } = promiseWithResolvers();
|
|
112492
|
+
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve: resolve46 }, "f");
|
|
112421
112493
|
let timer;
|
|
112422
112494
|
let onAbort;
|
|
112423
112495
|
try {
|
|
@@ -112577,8 +112649,8 @@ async function withTimeout(p, ms) {
|
|
|
112577
112649
|
try {
|
|
112578
112650
|
return await Promise.race([
|
|
112579
112651
|
p.then(() => false, () => false),
|
|
112580
|
-
new Promise((
|
|
112581
|
-
timer = setTimeout(() =>
|
|
112652
|
+
new Promise((resolve46) => {
|
|
112653
|
+
timer = setTimeout(() => resolve46(true), ms);
|
|
112582
112654
|
})
|
|
112583
112655
|
]);
|
|
112584
112656
|
} finally {
|
|
@@ -114251,12 +114323,12 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
114251
114323
|
}
|
|
114252
114324
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
114253
114325
|
});
|
|
114254
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
114255
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
114326
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve46, reject) => {
|
|
114327
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve46, "f");
|
|
114256
114328
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
114257
114329
|
}), "f");
|
|
114258
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
114259
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
114330
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve46, reject) => {
|
|
114331
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve46, "f");
|
|
114260
114332
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
114261
114333
|
}), "f");
|
|
114262
114334
|
__classPrivateFieldGet(this, _BetaMessageStream_connectedPromise, "f").catch(() => {});
|
|
@@ -114416,11 +114488,11 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
114416
114488
|
return this;
|
|
114417
114489
|
}
|
|
114418
114490
|
emitted(event) {
|
|
114419
|
-
return new Promise((
|
|
114491
|
+
return new Promise((resolve46, reject) => {
|
|
114420
114492
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
114421
114493
|
if (event !== "error")
|
|
114422
114494
|
this.once("error", reject);
|
|
114423
|
-
this.once(event,
|
|
114495
|
+
this.once(event, resolve46);
|
|
114424
114496
|
});
|
|
114425
114497
|
}
|
|
114426
114498
|
async done() {
|
|
@@ -114797,7 +114869,7 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
114797
114869
|
if (done) {
|
|
114798
114870
|
return { value: undefined, done: true };
|
|
114799
114871
|
}
|
|
114800
|
-
return new Promise((
|
|
114872
|
+
return new Promise((resolve46, reject) => readQueue2.push({ resolve: resolve46, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
|
|
114801
114873
|
}
|
|
114802
114874
|
const chunk = pushQueue.shift();
|
|
114803
114875
|
return { value: chunk, done: false };
|
|
@@ -121188,12 +121260,12 @@ var init_MessageStream = __esm(() => {
|
|
|
121188
121260
|
}
|
|
121189
121261
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
121190
121262
|
});
|
|
121191
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
121192
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
121263
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve46, reject) => {
|
|
121264
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve46, "f");
|
|
121193
121265
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
121194
121266
|
}), "f");
|
|
121195
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
121196
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
121267
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve46, reject) => {
|
|
121268
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve46, "f");
|
|
121197
121269
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
121198
121270
|
}), "f");
|
|
121199
121271
|
__classPrivateFieldGet(this, _MessageStream_connectedPromise, "f").catch(() => {});
|
|
@@ -121336,11 +121408,11 @@ var init_MessageStream = __esm(() => {
|
|
|
121336
121408
|
return this;
|
|
121337
121409
|
}
|
|
121338
121410
|
emitted(event) {
|
|
121339
|
-
return new Promise((
|
|
121411
|
+
return new Promise((resolve46, reject) => {
|
|
121340
121412
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
121341
121413
|
if (event !== "error")
|
|
121342
121414
|
this.once("error", reject);
|
|
121343
|
-
this.once(event,
|
|
121415
|
+
this.once(event, resolve46);
|
|
121344
121416
|
});
|
|
121345
121417
|
}
|
|
121346
121418
|
async done() {
|
|
@@ -121665,7 +121737,7 @@ var init_MessageStream = __esm(() => {
|
|
|
121665
121737
|
if (done) {
|
|
121666
121738
|
return { value: undefined, done: true };
|
|
121667
121739
|
}
|
|
121668
|
-
return new Promise((
|
|
121740
|
+
return new Promise((resolve46, reject) => readQueue2.push({ resolve: resolve46, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
|
|
121669
121741
|
}
|
|
121670
121742
|
const chunk = pushQueue.shift();
|
|
121671
121743
|
return { value: chunk, done: false };
|
|
@@ -126973,9 +127045,9 @@ var init_opus_consult = __esm(() => {
|
|
|
126973
127045
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
126974
127046
|
import { createHash as createHash41 } from "crypto";
|
|
126975
127047
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
126976
|
-
import { chmodSync as chmodSync10, existsSync as existsSync119, mkdirSync as mkdirSync91, mkdtempSync as mkdtempSync28, readdirSync as readdirSync58, readFileSync as readFileSync153, rmSync as rmSync54, statSync as
|
|
127048
|
+
import { chmodSync as chmodSync10, existsSync as existsSync119, mkdirSync as mkdirSync91, mkdtempSync as mkdtempSync28, readdirSync as readdirSync58, readFileSync as readFileSync153, rmSync as rmSync54, statSync as statSync52, symlinkSync as symlinkSync7, writeFileSync as writeFileSync89 } from "fs";
|
|
126977
127049
|
import { tmpdir as tmpdir36 } from "os";
|
|
126978
|
-
import { basename as
|
|
127050
|
+
import { basename as basename48, dirname as dirname74, isAbsolute as isAbsolute28, join as join168, relative as relative38 } from "path";
|
|
126979
127051
|
function answerMark(events2, assumeNext = false) {
|
|
126980
127052
|
if (assumeNext)
|
|
126981
127053
|
return events2.length;
|
|
@@ -127342,7 +127414,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
127342
127414
|
const reason = firstSession.markers.specConflict, rels = wall.map((f5) => relative38(ctx.repoDir, f5.path)), a = reason ? wallAnchor(reason, rels) : null;
|
|
127343
127415
|
if (!reason || !a)
|
|
127344
127416
|
return null;
|
|
127345
|
-
const f = wall[rels.indexOf(a.file)], o = ctx.outputs(), task = o.intake?.task ?? "", name =
|
|
127417
|
+
const f = wall[rels.indexOf(a.file)], o = ctx.outputs(), task = o.intake?.task ?? "", name = basename48(f.path), original = f.content;
|
|
127346
127418
|
if (!wallRefereeEnabled())
|
|
127347
127419
|
return legacyReauthor(ctx, first, firstSession, f, a, reason, task);
|
|
127348
127420
|
const done = o.wall?.arbitration_rounds ?? [];
|
|
@@ -127442,7 +127514,7 @@ ${brief}`, ...sid ? { resumeSessionId: sid } : {} });
|
|
|
127442
127514
|
}
|
|
127443
127515
|
}
|
|
127444
127516
|
async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
|
|
127445
|
-
const ids = [], o = ctx.outputs(), cwd = mkdtempSync28(join168(tmpdir36(), "loki-e15-wall-")), name =
|
|
127517
|
+
const ids = [], o = ctx.outputs(), cwd = mkdtempSync28(join168(tmpdir36(), "loki-e15-wall-")), name = basename48(f.path);
|
|
127446
127518
|
try {
|
|
127447
127519
|
writeFileSync89(join168(cwd, name), f.content, "utf8");
|
|
127448
127520
|
const id2 = `${first.iterationId}-wa`;
|
|
@@ -127540,7 +127612,7 @@ async function deliverOverWallConflict(o, repoDir, reverify, emit2, opts = {}) {
|
|
|
127540
127612
|
}
|
|
127541
127613
|
}, modeOf = (p) => {
|
|
127542
127614
|
try {
|
|
127543
|
-
return
|
|
127615
|
+
return statSync52(p).mode & 4095;
|
|
127544
127616
|
} catch {
|
|
127545
127617
|
return null;
|
|
127546
127618
|
}
|
|
@@ -127807,8 +127879,8 @@ __export(exports_run_outputs, {
|
|
|
127807
127879
|
});
|
|
127808
127880
|
import { execFile as execFile3, spawnSync as spawnSync29 } from "child_process";
|
|
127809
127881
|
import { createHash as createHash42 } from "crypto";
|
|
127810
|
-
import { existsSync as existsSync120, lstatSync as lstatSync36, mkdirSync as mkdirSync92, readdirSync as readdirSync59, readFileSync as readFileSync154, statSync as
|
|
127811
|
-
import { basename as
|
|
127882
|
+
import { existsSync as existsSync120, lstatSync as lstatSync36, mkdirSync as mkdirSync92, readdirSync as readdirSync59, readFileSync as readFileSync154, statSync as statSync53, writeFileSync as writeFileSync90 } from "fs";
|
|
127883
|
+
import { basename as basename49, join as join169, resolve as resolve46 } from "path";
|
|
127812
127884
|
function intentRevisionsBlock(revs) {
|
|
127813
127885
|
const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
|
|
127814
127886
|
return r.length ? { intent_revisions: r } : {};
|
|
@@ -127841,7 +127913,7 @@ function sealAccuracyLine(changed, checks, model, env2 = process.env, nowMs = Da
|
|
|
127841
127913
|
const res = JSON.parse(readFileSync154(file, "utf8"));
|
|
127842
127914
|
if (res.manifest_sha256 !== corpus2 || !Array.isArray(res.runs))
|
|
127843
127915
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
127844
|
-
const first = changed.map((f) =>
|
|
127916
|
+
const first = changed.map((f) => basename49(f)).find((b) => !SPEC_PREFIXES.some((p) => b.startsWith(p)));
|
|
127845
127917
|
const lang = first === undefined ? "unknown" : LANG_BY_EXT[first.slice(first.lastIndexOf(".")).toLowerCase()] ?? "unknown";
|
|
127846
127918
|
const runner = checks.find((c) => c.result === "pass")?.cmd.trim().split(/\s+/)[0];
|
|
127847
127919
|
const run2 = res.runs.find((r) => typeof r["model"] === "string" && resolveClaudeModel(r["model"]) === resolveClaudeModel(model));
|
|
@@ -127989,7 +128061,7 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
|
|
|
127989
128061
|
} catch {
|
|
127990
128062
|
return null;
|
|
127991
128063
|
}
|
|
127992
|
-
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync120(join169(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m:
|
|
128064
|
+
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync120(join169(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync53(join169(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
|
|
127993
128065
|
const top = rows[0];
|
|
127994
128066
|
if (!top)
|
|
127995
128067
|
return null;
|
|
@@ -128267,7 +128339,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
|
|
|
128267
128339
|
};
|
|
128268
128340
|
const supervise = deps.supervise ?? (async (o) => (await Promise.resolve().then(() => (init_supervisor(), exports_supervisor))).runSupervisor(o));
|
|
128269
128341
|
const { exitCodeOf: exitCodeOf2 } = await Promise.resolve().then(() => (init_output(), exports_output));
|
|
128270
|
-
const res = await supervise({ runId: it2.runId, repoDir, env: env2, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS,
|
|
128342
|
+
const res = await supervise({ runId: it2.runId, repoDir, env: env2, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS, resolve46(process.argv[1] ?? ""), "engine10", "worker", it2.runId, provider, model, deep ? "deep" : "fast"], started: { ...st2, resumed_from: rp2.stage, ...answer !== undefined ? { answered: true, answer: redactSecrets(answer), answer_sha256: createHash42("sha256").update(redactSecrets(answer)).digest("hex"), question: String(conflictReasonOf(it2.events) ?? "the run is blocked on a spec conflict").replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, 500) } : {} }, pr: pr2 });
|
|
128271
128343
|
out3(`engine10: resumed run ${it2.runId}: ${res.outcome}
|
|
128272
128344
|
`);
|
|
128273
128345
|
return exitCodeOf2(res.outcome);
|
|
@@ -128286,7 +128358,7 @@ async function signedReceiptFacts(runDir, runId2, events2) {
|
|
|
128286
128358
|
for (const f of [file, join169(runDir, "events.jsonl")]) {
|
|
128287
128359
|
try {
|
|
128288
128360
|
if (lstatSync36(f).isSymbolicLink())
|
|
128289
|
-
return { problem: `${
|
|
128361
|
+
return { problem: `${basename49(f)} is a symlink; a run's own files are never links` };
|
|
128290
128362
|
} catch {}
|
|
128291
128363
|
}
|
|
128292
128364
|
let r;
|
|
@@ -128656,7 +128728,7 @@ function issueStatusProjector(o) {
|
|
|
128656
128728
|
return r.catch(() => null);
|
|
128657
128729
|
};
|
|
128658
128730
|
}
|
|
128659
|
-
function policyGate(repoDir, action, env2 = process.env, checkJs =
|
|
128731
|
+
function policyGate(repoDir, action, env2 = process.env, checkJs = resolve46(import.meta.dir, "../../../src/policies/check.js"), timeoutMs = 30000) {
|
|
128660
128732
|
if (policyFile(repoDir, env2) === null)
|
|
128661
128733
|
return { decision: "allow", reason: "no policy file" };
|
|
128662
128734
|
if (env2.LOKI_POLICY_REQUIRE_NODE === "0" && spawnSync29("node", ["--version"], { env: { PATH: env2.PATH }, encoding: "utf8" }).status !== 0)
|
|
@@ -128891,7 +128963,7 @@ var init_run_outputs = __esm(() => {
|
|
|
128891
128963
|
|
|
128892
128964
|
// ../../loki-ts/src/util/composite_seal.ts
|
|
128893
128965
|
import { existsSync as existsSync121, readFileSync as readFileSync155 } from "fs";
|
|
128894
|
-
import { basename as
|
|
128966
|
+
import { basename as basename50, dirname as dirname75, join as join170 } from "path";
|
|
128895
128967
|
function logProblem(runDir, integ) {
|
|
128896
128968
|
if (typeof integ["log_sha256"] !== "string")
|
|
128897
128969
|
return null;
|
|
@@ -128962,8 +129034,8 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
128962
129034
|
throw new Error("workspace has no repos");
|
|
128963
129035
|
return {
|
|
128964
129036
|
schema: COMPOSITE_SCHEMA,
|
|
128965
|
-
workspace:
|
|
128966
|
-
run_id:
|
|
129037
|
+
workspace: basename50(dirname75(runDir)),
|
|
129038
|
+
run_id: basename50(runDir),
|
|
128967
129039
|
integration_sha256: sha3(ibytes),
|
|
128968
129040
|
integration: { status: String(integ["status"]), exit_code: typeof integ["exit_code"] === "number" ? integ["exit_code"] : null, log_sha256: typeof integ["log_sha256"] === "string" ? integ["log_sha256"] : null, heads },
|
|
128969
129041
|
children,
|
|
@@ -129090,8 +129162,8 @@ __export(exports_verify_cmd, {
|
|
|
129090
129162
|
checkEventLog: () => checkEventLog,
|
|
129091
129163
|
checkAttestation: () => checkAttestation
|
|
129092
129164
|
});
|
|
129093
|
-
import { existsSync as existsSync122, readFileSync as readFileSync156, renameSync as renameSync30, statSync as
|
|
129094
|
-
import { basename as
|
|
129165
|
+
import { existsSync as existsSync122, readFileSync as readFileSync156, renameSync as renameSync30, statSync as statSync54, writeFileSync as writeFileSync91 } from "fs";
|
|
129166
|
+
import { basename as basename51, dirname as dirname76, join as join171 } from "path";
|
|
129095
129167
|
import { createHash as createHash43, verify as verify5 } from "crypto";
|
|
129096
129168
|
function checkAttestation(jwt, expectedHash, given) {
|
|
129097
129169
|
const bad = (reason) => ({ status: "tampered", reason });
|
|
@@ -129126,11 +129198,11 @@ function wallTamperProblem(receiptPath, receipt) {
|
|
|
129126
129198
|
cur = createHash43("sha256").update(readFileSync156(copy)).digest("hex");
|
|
129127
129199
|
} catch {
|
|
129128
129200
|
if (haveWallDir)
|
|
129129
|
-
return `sealed Wall file ${
|
|
129201
|
+
return `sealed Wall file ${basename51(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
|
|
129130
129202
|
continue;
|
|
129131
129203
|
}
|
|
129132
129204
|
if (cur !== f.sha256)
|
|
129133
|
-
return `sealed Wall file ${
|
|
129205
|
+
return `sealed Wall file ${basename51(f.path)} changed after the seal: receipt recorded sha256 ${f.sha256}, on disk ${cur}`;
|
|
129134
129206
|
}
|
|
129135
129207
|
return null;
|
|
129136
129208
|
}
|
|
@@ -129312,7 +129384,7 @@ async function verifyCompositeFile(receiptPath, receipt, deps) {
|
|
|
129312
129384
|
}
|
|
129313
129385
|
function sealCompositeCmd(runDir) {
|
|
129314
129386
|
let body;
|
|
129315
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(
|
|
129387
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(basename51(runDir.replace(/\/+$/, ""))))
|
|
129316
129388
|
return process.stderr.write(`loki verify: run directory name is not a valid run id; composite would never verify
|
|
129317
129389
|
`), 2;
|
|
129318
129390
|
try {
|
|
@@ -129408,7 +129480,7 @@ ${/^(unknown option|expected at most one)/.test(pk.error) ? `Usage: loki verify
|
|
|
129408
129480
|
if (!runId2)
|
|
129409
129481
|
return process.stderr.write(`loki verify: no runs found
|
|
129410
129482
|
`), 66;
|
|
129411
|
-
const isFile2 = existsSync122(runId2) &&
|
|
129483
|
+
const isFile2 = existsSync122(runId2) && statSync54(runId2).isFile();
|
|
129412
129484
|
const isPath = isFile2 || /[\\/]/.test(runId2) || runId2.endsWith(".json");
|
|
129413
129485
|
const receiptPath = isPath ? runId2 : join171(runsRoot2, runId2, "receipt.json");
|
|
129414
129486
|
const byRunId = !isPath;
|
|
@@ -129554,8 +129626,8 @@ var init_verify_cmd = __esm(() => {
|
|
|
129554
129626
|
});
|
|
129555
129627
|
|
|
129556
129628
|
// src/server/app.ts
|
|
129557
|
-
import { existsSync as existsSync125, readFileSync as readFileSync160, statSync as
|
|
129558
|
-
import { join as join175, resolve as
|
|
129629
|
+
import { existsSync as existsSync125, readFileSync as readFileSync160, statSync as statSync56 } from "fs";
|
|
129630
|
+
import { join as join175, resolve as resolve48, sep as sep31 } from "path";
|
|
129559
129631
|
|
|
129560
129632
|
// node_modules/hono/dist/request/constants.js
|
|
129561
129633
|
var GET_MATCH_RESULT = Symbol();
|
|
@@ -136200,6 +136272,7 @@ function reconcileDeadRuns(db, o = {}) {
|
|
|
136200
136272
|
|
|
136201
136273
|
// src/server/repos.ts
|
|
136202
136274
|
import { execFile } from "child_process";
|
|
136275
|
+
import { statSync as statSync6 } from "fs";
|
|
136203
136276
|
import { basename as basename2, resolve as resolve5 } from "path";
|
|
136204
136277
|
init_discover();
|
|
136205
136278
|
function syncLocalRepos(db, repoDir, env = process.env) {
|
|
@@ -136210,6 +136283,17 @@ function syncLocalRepos(db, repoDir, env = process.env) {
|
|
|
136210
136283
|
}
|
|
136211
136284
|
return found.length;
|
|
136212
136285
|
}
|
|
136286
|
+
function repoPathsByName(db, name) {
|
|
136287
|
+
const rows = db.select({ sourceId: localRepos.sourceId, realpath: localRepos.realpath, name: localRepos.name }).from(localRepos).all();
|
|
136288
|
+
const byOrigin = new Set(db.selectDistinct({ s: runs.sourceId, r: runs.originRepo }).from(runs).all().filter((x) => x.r !== null && x.r.split("/").pop() === name).map((x) => x.s));
|
|
136289
|
+
return [...new Set(rows.filter((r) => r.name === name || byOrigin.has(r.sourceId)).map((r) => r.realpath))].filter((d) => {
|
|
136290
|
+
try {
|
|
136291
|
+
return statSync6(d).isDirectory();
|
|
136292
|
+
} catch {
|
|
136293
|
+
return false;
|
|
136294
|
+
}
|
|
136295
|
+
});
|
|
136296
|
+
}
|
|
136213
136297
|
function repoNames(db) {
|
|
136214
136298
|
return [...new Set(db.select({ name: localRepos.name }).from(localRepos).all().map((r) => r.name))].sort();
|
|
136215
136299
|
}
|
|
@@ -136372,7 +136456,7 @@ function mount2(ctx) {
|
|
|
136372
136456
|
import { basename as basename4 } from "path";
|
|
136373
136457
|
|
|
136374
136458
|
// src/ask/policy.ts
|
|
136375
|
-
import { chmodSync as chmodSync3, existsSync as existsSync8, lstatSync as lstatSync4, mkdtempSync as mkdtempSync3, readFileSync as readFileSync13, realpathSync as realpathSync7, rmSync as rmSync5, statSync as
|
|
136459
|
+
import { chmodSync as chmodSync3, existsSync as existsSync8, lstatSync as lstatSync4, mkdtempSync as mkdtempSync3, readFileSync as readFileSync13, realpathSync as realpathSync7, rmSync as rmSync5, statSync as statSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
136376
136460
|
import { tmpdir as tmpdir5 } from "os";
|
|
136377
136461
|
import { dirname as dirname7, join as join19, parse } from "path";
|
|
136378
136462
|
var MCP_SERVER_NAME = "loki-ask";
|
|
@@ -136487,7 +136571,7 @@ function removeJobDir(dir) {
|
|
|
136487
136571
|
const marker = join19(dir, MARKER);
|
|
136488
136572
|
if (!existsSync8(marker) || readFileSync13(marker, "utf8") !== dir)
|
|
136489
136573
|
refuse("marker missing or wrong");
|
|
136490
|
-
if (!
|
|
136574
|
+
if (!statSync7(marker).isFile())
|
|
136491
136575
|
refuse("marker is not a file");
|
|
136492
136576
|
rmSync5(dir, { recursive: true, force: true });
|
|
136493
136577
|
}
|
|
@@ -136608,7 +136692,7 @@ import { join as join21 } from "path";
|
|
|
136608
136692
|
// src/server/spawn.ts
|
|
136609
136693
|
init_types();
|
|
136610
136694
|
import { spawn } from "child_process";
|
|
136611
|
-
import { existsSync as existsSync9, readFileSync as readFileSync14, realpathSync as realpathSync8, statSync as
|
|
136695
|
+
import { existsSync as existsSync9, readFileSync as readFileSync14, realpathSync as realpathSync8, statSync as statSync8 } from "fs";
|
|
136612
136696
|
import { homedir as homedir7 } from "os";
|
|
136613
136697
|
import { basename as basename3, dirname as dirname8, join as join20, resolve as resolve6 } from "path";
|
|
136614
136698
|
var ISSUE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}\/[A-Za-z0-9._-]{1,100}#[1-9][0-9]{0,8}$/;
|
|
@@ -136647,7 +136731,7 @@ function repoRefusal(cwd, env = process.env) {
|
|
|
136647
136731
|
function registryRepos2(env = process.env) {
|
|
136648
136732
|
try {
|
|
136649
136733
|
const j = JSON.parse(readFileSync14(join20(env.HOME || homedir7(), ".loki", "dashboard", "projects.json"), "utf8"));
|
|
136650
|
-
return Object.values(j.projects ?? {}).map((p) => typeof p?.path === "string" ? p.path : "").filter((p) => p && existsSync9(p) &&
|
|
136734
|
+
return Object.values(j.projects ?? {}).map((p) => typeof p?.path === "string" ? p.path : "").filter((p) => p && existsSync9(p) && statSync8(p).isDirectory());
|
|
136651
136735
|
} catch {
|
|
136652
136736
|
return [];
|
|
136653
136737
|
}
|
|
@@ -137347,11 +137431,11 @@ function mount5(ctx) {
|
|
|
137347
137431
|
|
|
137348
137432
|
// src/server/routes/checkpoints.ts
|
|
137349
137433
|
init_safe_git();
|
|
137350
|
-
import { appendFileSync as appendFileSync3, copyFileSync, cpSync, existsSync as existsSync11, lstatSync as lstatSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync9, readFileSync as readFileSync16, realpathSync as realpathSync9, rmSync as rmSync6, statSync as
|
|
137434
|
+
import { appendFileSync as appendFileSync3, copyFileSync, cpSync, existsSync as existsSync11, lstatSync as lstatSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync9, readFileSync as readFileSync16, realpathSync as realpathSync9, rmSync as rmSync6, statSync as statSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
137351
137435
|
import { join as join23, sep as sep6 } from "path";
|
|
137352
137436
|
|
|
137353
137437
|
// src/server/routes/cost_ledger.ts
|
|
137354
|
-
import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync as readFileSync15, statSync as
|
|
137438
|
+
import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync as readFileSync15, statSync as statSync9 } from "fs";
|
|
137355
137439
|
import { join as join22 } from "path";
|
|
137356
137440
|
var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
137357
137441
|
var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -137576,7 +137660,7 @@ function costTimeline(lokiDir2) {
|
|
|
137576
137660
|
} catch {}
|
|
137577
137661
|
for (const e of entries) {
|
|
137578
137662
|
try {
|
|
137579
|
-
if (!
|
|
137663
|
+
if (!statSync9(join22(proofs, e)).isDirectory())
|
|
137580
137664
|
continue;
|
|
137581
137665
|
} catch {
|
|
137582
137666
|
continue;
|
|
@@ -137741,7 +137825,7 @@ function rollbackCheckpoint(repoDir, id, now2 = new Date) {
|
|
|
137741
137825
|
} catch {
|
|
137742
137826
|
return null;
|
|
137743
137827
|
}
|
|
137744
|
-
if (!real3.startsWith(`${realStore}${sep6}`) || !
|
|
137828
|
+
if (!real3.startsWith(`${realStore}${sep6}`) || !statSync10(real3).isDirectory())
|
|
137745
137829
|
return null;
|
|
137746
137830
|
const preId = `rb-pre-${stamp(now2)}`, pre = join23(store, preId);
|
|
137747
137831
|
mkdirSync9(pre, { recursive: true });
|
|
@@ -137873,8 +137957,8 @@ function mount7(ctx) {
|
|
|
137873
137957
|
|
|
137874
137958
|
// src/server/routes/config.ts
|
|
137875
137959
|
import { createHash as createHash6, randomBytes as randomBytes2 } from "crypto";
|
|
137876
|
-
import { closeSync as closeSync6, fchmodSync, fsyncSync as fsyncSync2, lstatSync as lstatSync6, openSync as openSync6, readFileSync as readFileSync17, realpathSync as realpathSync10, renameSync as renameSync5, statSync as
|
|
137877
|
-
import { basename as
|
|
137960
|
+
import { closeSync as closeSync6, fchmodSync, fsyncSync as fsyncSync2, lstatSync as lstatSync6, openSync as openSync6, readFileSync as readFileSync17, realpathSync as realpathSync10, renameSync as renameSync5, statSync as statSync11, unlinkSync as unlinkSync2, writeSync as writeSync3 } from "fs";
|
|
137961
|
+
import { basename as basename6, dirname as dirname9, join as join24, sep as sep7 } from "path";
|
|
137878
137962
|
|
|
137879
137963
|
// node_modules/yaml/dist/index.js
|
|
137880
137964
|
var composer = require_composer();
|
|
@@ -137923,6 +138007,7 @@ var $visit = visit.visit;
|
|
|
137923
138007
|
var $visitAsync = visit.visitAsync;
|
|
137924
138008
|
|
|
137925
138009
|
// src/server/routes/start.ts
|
|
138010
|
+
import { basename as basename5, resolve as resolve7 } from "path";
|
|
137926
138011
|
function originOk(origin) {
|
|
137927
138012
|
if (origin === undefined || origin === null)
|
|
137928
138013
|
return true;
|
|
@@ -137951,7 +138036,18 @@ function mount8(ctx) {
|
|
|
137951
138036
|
return c.json({ error: "invalid JSON" }, 400);
|
|
137952
138037
|
}
|
|
137953
138038
|
const target = typeof body?.target === "string" ? body.target : undefined;
|
|
137954
|
-
const
|
|
138039
|
+
const b = body, known = [repoDir, ...registryRepos2()];
|
|
138040
|
+
if (b && typeof b.repo === "string" && b.repo !== "" && !b.repo.includes("/") && !known.some((k) => basename5(resolve7(k)) === b.repo)) {
|
|
138041
|
+
const hits = repoPathsByName(db, b.repo);
|
|
138042
|
+
if (hits.length === 1) {
|
|
138043
|
+
known.push(hits[0]);
|
|
138044
|
+
b.repo = hits[0];
|
|
138045
|
+
} else if (hits.length > 1) {
|
|
138046
|
+
audit3(db, { kind: "run.start", target, result: "refused", detail: `${hits.length} checkouts match ${b.repo}` });
|
|
138047
|
+
return c.json({ error: `${hits.length} checkouts on this machine belong to ${b.repo}; start the run from the one you mean with loki start` }, 400);
|
|
138048
|
+
}
|
|
138049
|
+
}
|
|
138050
|
+
const plan = planStart(body, known, ctx.startBin);
|
|
137955
138051
|
if (!plan.ok) {
|
|
137956
138052
|
audit3(db, { kind: "run.start", target, result: "refused", detail: plan.error });
|
|
137957
138053
|
return c.json({ error: plan.error }, 400);
|
|
@@ -138330,7 +138426,7 @@ function resolveConfigFile(repoDir) {
|
|
|
138330
138426
|
}
|
|
138331
138427
|
if (!real3.startsWith(root + sep7))
|
|
138332
138428
|
return { ok: false, status: 400, error: "loki.yaml is a symlink that resolves outside the repo" };
|
|
138333
|
-
if (!
|
|
138429
|
+
if (!statSync11(real3).isFile())
|
|
138334
138430
|
return { ok: false, status: 422, error: "loki.yaml is not a regular file" };
|
|
138335
138431
|
return { ok: true, file: real3, exists: true };
|
|
138336
138432
|
}
|
|
@@ -138339,7 +138435,7 @@ function resolveConfigFile(repoDir) {
|
|
|
138339
138435
|
return { ok: true, file: p, exists: true };
|
|
138340
138436
|
}
|
|
138341
138437
|
function atomicWrite(file, text2, mode) {
|
|
138342
|
-
const tmp = join24(dirname9(file), `.${
|
|
138438
|
+
const tmp = join24(dirname9(file), `.${basename6(file)}.${process.pid}.${randomBytes2(6).toString("hex")}.tmp`);
|
|
138343
138439
|
const fd = openSync6(tmp, "wx", mode);
|
|
138344
138440
|
try {
|
|
138345
138441
|
writeSync3(fd, text2);
|
|
@@ -138379,7 +138475,7 @@ function mount9(ctx) {
|
|
|
138379
138475
|
return deny(c, "config.read", r.status, r.error);
|
|
138380
138476
|
let raw2 = "";
|
|
138381
138477
|
if (r.exists) {
|
|
138382
|
-
if (
|
|
138478
|
+
if (statSync11(r.file).size > MAX_FILE)
|
|
138383
138479
|
return deny(c, "config.read", 413, "loki.yaml is too large");
|
|
138384
138480
|
raw2 = readFileSync17(r.file, "utf8");
|
|
138385
138481
|
}
|
|
@@ -138444,7 +138540,7 @@ function mount9(ctx) {
|
|
|
138444
138540
|
return refuse(r.status, r.error);
|
|
138445
138541
|
let raw2 = "";
|
|
138446
138542
|
if (r.exists) {
|
|
138447
|
-
if (
|
|
138543
|
+
if (statSync11(r.file).size > MAX_FILE)
|
|
138448
138544
|
return refuse(400, "loki.yaml is too large");
|
|
138449
138545
|
raw2 = readFileSync17(r.file, "utf8");
|
|
138450
138546
|
}
|
|
@@ -138471,7 +138567,7 @@ function mount9(ctx) {
|
|
|
138471
138567
|
return refuse(400, "could not render the config safely");
|
|
138472
138568
|
const changed = [...new Set([...Object.keys(prev), ...Object.keys(next)])].filter((k) => !deepEq(prev[k], next[k]));
|
|
138473
138569
|
try {
|
|
138474
|
-
const mode = r.exists ?
|
|
138570
|
+
const mode = r.exists ? statSync11(r.file).mode & 511 : 420;
|
|
138475
138571
|
if (r.exists)
|
|
138476
138572
|
atomicWrite(`${r.file}.bak`, raw2, 384);
|
|
138477
138573
|
atomicWrite(r.file, out, mode);
|
|
@@ -138490,7 +138586,7 @@ function mount9(ctx) {
|
|
|
138490
138586
|
|
|
138491
138587
|
// src/server/routes/control.ts
|
|
138492
138588
|
import { existsSync as existsSync12, realpathSync as realpathSync11 } from "fs";
|
|
138493
|
-
import { join as join25, resolve as
|
|
138589
|
+
import { join as join25, resolve as resolve8, sep as sep8 } from "path";
|
|
138494
138590
|
init_run_pid();
|
|
138495
138591
|
var ID4 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
138496
138592
|
var busy = new Set;
|
|
@@ -138516,7 +138612,7 @@ function mount10(ctx) {
|
|
|
138516
138612
|
}
|
|
138517
138613
|
if (!repo)
|
|
138518
138614
|
return done(404, "refused", { error: "this run's repo is not known on this machine" });
|
|
138519
|
-
const runsRoot = join25(repo, ".loki", "runs"), runDir =
|
|
138615
|
+
const runsRoot = join25(repo, ".loki", "runs"), runDir = resolve8(runsRoot, id);
|
|
138520
138616
|
if (!runDir.startsWith(runsRoot + sep8))
|
|
138521
138617
|
return done(400, "refused", { error: "invalid run id" }, "path escape");
|
|
138522
138618
|
return handler({ source, run: id, repo, runDir }, done);
|
|
@@ -138673,7 +138769,7 @@ var DOCTOR_TIMEOUT_MS = 25000;
|
|
|
138673
138769
|
var MAX_OUT = 1e6;
|
|
138674
138770
|
var isStatus = (s) => s === "pass" || s === "warn" || s === "fail";
|
|
138675
138771
|
function runDoctor(bin, timeoutMs = DOCTOR_TIMEOUT_MS) {
|
|
138676
|
-
return new Promise((
|
|
138772
|
+
return new Promise((resolve9, reject) => {
|
|
138677
138773
|
let out2 = "";
|
|
138678
138774
|
let done = false;
|
|
138679
138775
|
let child;
|
|
@@ -138700,7 +138796,7 @@ function runDoctor(bin, timeoutMs = DOCTOR_TIMEOUT_MS) {
|
|
|
138700
138796
|
out2 += d.toString("utf8");
|
|
138701
138797
|
});
|
|
138702
138798
|
child.on("error", (e) => finish2(() => reject(new Error(`could not run loki doctor: ${e.message}`))));
|
|
138703
|
-
child.on("close", () => finish2(() =>
|
|
138799
|
+
child.on("close", () => finish2(() => resolve9(out2)));
|
|
138704
138800
|
});
|
|
138705
138801
|
}
|
|
138706
138802
|
function mapDoctor(raw2) {
|
|
@@ -138746,7 +138842,7 @@ function mount12(ctx) {
|
|
|
138746
138842
|
// src/server/routes/fleet.ts
|
|
138747
138843
|
import { readdirSync as readdirSync10, readFileSync as readFileSync18 } from "fs";
|
|
138748
138844
|
import { homedir as homedir8 } from "os";
|
|
138749
|
-
import { basename as
|
|
138845
|
+
import { basename as basename7, join as join26 } from "path";
|
|
138750
138846
|
var isNum3 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
138751
138847
|
var isObj6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
138752
138848
|
var registryFile = () => join26(process.env.HOME ?? homedir8(), ".loki", "dashboard", "projects.json");
|
|
@@ -138827,7 +138923,7 @@ function fleetRuns(includeInactive = true, file = registryFile()) {
|
|
|
138827
138923
|
}
|
|
138828
138924
|
return {
|
|
138829
138925
|
id: p.id ?? null,
|
|
138830
|
-
name: p.name || (path ?
|
|
138926
|
+
name: p.name || (path ? basename7(path) : "project"),
|
|
138831
138927
|
path,
|
|
138832
138928
|
status,
|
|
138833
138929
|
running,
|
|
@@ -138863,7 +138959,7 @@ function mount13(ctx) {
|
|
|
138863
138959
|
}
|
|
138864
138960
|
|
|
138865
138961
|
// src/server/routes/memory.ts
|
|
138866
|
-
import { existsSync as existsSync13, readFileSync as readFileSync19, readdirSync as readdirSync11, realpathSync as realpathSync12, statSync as
|
|
138962
|
+
import { existsSync as existsSync13, readFileSync as readFileSync19, readdirSync as readdirSync11, realpathSync as realpathSync12, statSync as statSync12 } from "fs";
|
|
138867
138963
|
import { join as join27, sep as sep9 } from "path";
|
|
138868
138964
|
var isObj7 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
138869
138965
|
var nonEmpty = (v) => !(v === undefined || v === null || v === "" || Array.isArray(v) && v.length === 0 || isObj7(v) && Object.keys(v).length === 0);
|
|
@@ -138917,12 +139013,12 @@ function setFocus(repoDir, raw2, registry = registryFile()) {
|
|
|
138917
139013
|
let real3 = "";
|
|
138918
139014
|
try {
|
|
138919
139015
|
real3 = realpathSync12(s);
|
|
138920
|
-
if (!
|
|
139016
|
+
if (!statSync12(real3).isDirectory())
|
|
138921
139017
|
throw new Error("not a dir");
|
|
138922
139018
|
} catch {
|
|
138923
139019
|
return { ok: false, error: `Directory does not exist: ${s}` };
|
|
138924
139020
|
}
|
|
138925
|
-
if (!existsSync13(join27(real3, ".loki")) || !
|
|
139021
|
+
if (!existsSync13(join27(real3, ".loki")) || !statSync12(join27(real3, ".loki")).isDirectory())
|
|
138926
139022
|
return { ok: false, error: `Directory does not contain a .loki/ subdirectory: ${s}` };
|
|
138927
139023
|
const allowed = new Set;
|
|
138928
139024
|
try {
|
|
@@ -139141,7 +139237,7 @@ function mount14(ctx) {
|
|
|
139141
139237
|
}
|
|
139142
139238
|
|
|
139143
139239
|
// src/server/routes/metrics.ts
|
|
139144
|
-
import { readdirSync as readdirSync12, readFileSync as readFileSync20, statSync as
|
|
139240
|
+
import { readdirSync as readdirSync12, readFileSync as readFileSync20, statSync as statSync13 } from "fs";
|
|
139145
139241
|
import { join as join28 } from "path";
|
|
139146
139242
|
var isObj8 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
139147
139243
|
var arr = (v) => Array.isArray(v) ? v : [];
|
|
@@ -139215,7 +139311,7 @@ function buildMetricsText(repoDir, now2 = Date.now()) {
|
|
|
139215
139311
|
} catch {}
|
|
139216
139312
|
for (const e of entries) {
|
|
139217
139313
|
try {
|
|
139218
|
-
if (!
|
|
139314
|
+
if (!statSync13(join28(pdir, e)).isDirectory())
|
|
139219
139315
|
continue;
|
|
139220
139316
|
} catch {
|
|
139221
139317
|
continue;
|
|
@@ -139467,7 +139563,7 @@ function mount16(ctx) {
|
|
|
139467
139563
|
|
|
139468
139564
|
// src/server/routes/integrations.ts
|
|
139469
139565
|
import { spawn as spawn4 } from "child_process";
|
|
139470
|
-
import { existsSync as existsSync15, readFileSync as readFileSync22, statSync as
|
|
139566
|
+
import { existsSync as existsSync15, readFileSync as readFileSync22, statSync as statSync14 } from "fs";
|
|
139471
139567
|
import { delimiter, join as join30 } from "path";
|
|
139472
139568
|
var GH_TIMEOUT_MS = 3000;
|
|
139473
139569
|
var isSet = (n3) => !!n3 && (process.env[n3] ?? "") !== "";
|
|
@@ -139475,21 +139571,21 @@ function ghAuthed(pathVar = process.env.PATH ?? "", timeoutMs = GH_TIMEOUT_MS) {
|
|
|
139475
139571
|
const exe = pathVar.split(delimiter).filter(Boolean).map((d) => join30(d, "gh")).find((p) => existsSync15(p));
|
|
139476
139572
|
if (!exe)
|
|
139477
139573
|
return Promise.resolve(null);
|
|
139478
|
-
return new Promise((
|
|
139574
|
+
return new Promise((resolve9) => {
|
|
139479
139575
|
let done = false;
|
|
139480
139576
|
let timer;
|
|
139481
139577
|
const finish2 = (v) => {
|
|
139482
139578
|
if (!done) {
|
|
139483
139579
|
done = true;
|
|
139484
139580
|
clearTimeout(timer);
|
|
139485
|
-
|
|
139581
|
+
resolve9(v);
|
|
139486
139582
|
}
|
|
139487
139583
|
};
|
|
139488
139584
|
let child;
|
|
139489
139585
|
try {
|
|
139490
139586
|
child = spawn4(exe, ["auth", "status"], { stdio: "ignore", env: { ...process.env, NO_COLOR: "1" } });
|
|
139491
139587
|
} catch {
|
|
139492
|
-
return
|
|
139588
|
+
return resolve9(null);
|
|
139493
139589
|
}
|
|
139494
139590
|
timer = setTimeout(() => {
|
|
139495
139591
|
try {
|
|
@@ -139504,7 +139600,7 @@ function ghAuthed(pathVar = process.env.PATH ?? "", timeoutMs = GH_TIMEOUT_MS) {
|
|
|
139504
139600
|
function configuredName(repoDir, path) {
|
|
139505
139601
|
try {
|
|
139506
139602
|
const r = resolveConfigFile(repoDir);
|
|
139507
|
-
if (!r.ok || !r.exists ||
|
|
139603
|
+
if (!r.ok || !r.exists || statSync14(r.file).size > 1e6)
|
|
139508
139604
|
return null;
|
|
139509
139605
|
const doc = $parseDocument(readFileSync22(r.file, "utf8"));
|
|
139510
139606
|
if (doc.errors.length)
|
|
@@ -139518,7 +139614,7 @@ function configuredName(repoDir, path) {
|
|
|
139518
139614
|
function mcpServers(repoDir) {
|
|
139519
139615
|
try {
|
|
139520
139616
|
const p = join30(repoDir, ".mcp.json");
|
|
139521
|
-
if (!existsSync15(p) ||
|
|
139617
|
+
if (!existsSync15(p) || statSync14(p).size > 1e6)
|
|
139522
139618
|
return null;
|
|
139523
139619
|
const j = JSON.parse(readFileSync22(p, "utf8"));
|
|
139524
139620
|
return j.mcpServers && typeof j.mcpServers === "object" ? Object.keys(j.mcpServers).length : null;
|
|
@@ -139599,7 +139695,7 @@ function mount17(ctx) {
|
|
|
139599
139695
|
// src/server/routes/merge_risk.ts
|
|
139600
139696
|
import { spawn as spawn5 } from "child_process";
|
|
139601
139697
|
import { realpathSync as realpathSync13 } from "fs";
|
|
139602
|
-
import { basename as
|
|
139698
|
+
import { basename as basename8, resolve as resolve9 } from "path";
|
|
139603
139699
|
var PR = /^[0-9]{1,7}$/;
|
|
139604
139700
|
var REF = /^[A-Za-z0-9._/][A-Za-z0-9._/-]{0,99}$/;
|
|
139605
139701
|
var MAX_OUT2 = 256 * 1024;
|
|
@@ -139711,12 +139807,12 @@ function mount18(ctx) {
|
|
|
139711
139807
|
for (const k of [ctx.repoDir, ...registryRepos2()]) {
|
|
139712
139808
|
const r = real3(k);
|
|
139713
139809
|
if (r)
|
|
139714
|
-
known.set(r,
|
|
139810
|
+
known.set(r, basename8(resolve9(k)));
|
|
139715
139811
|
}
|
|
139716
139812
|
const wantReal = real3(want);
|
|
139717
139813
|
if (wantReal && known.has(wantReal))
|
|
139718
139814
|
return wantReal;
|
|
139719
|
-
const named = [...known].filter(([r, label2]) => label2 === want ||
|
|
139815
|
+
const named = [...known].filter(([r, label2]) => label2 === want || basename8(r) === want).map(([r]) => r);
|
|
139720
139816
|
return named.length === 1 ? named[0] : null;
|
|
139721
139817
|
};
|
|
139722
139818
|
const slot = async (c, kind, auditKind, fn) => {
|
|
@@ -139931,7 +140027,7 @@ function probeCli(bin, timeoutMs, pathVar = process.env.PATH ?? "") {
|
|
|
139931
140027
|
const exe = findOnPath(bin, pathVar);
|
|
139932
140028
|
if (!exe)
|
|
139933
140029
|
return Promise.resolve({ installed: false, version: null, probe: "not_found" });
|
|
139934
|
-
return new Promise((
|
|
140030
|
+
return new Promise((resolve10) => {
|
|
139935
140031
|
let out2 = "";
|
|
139936
140032
|
let done = false;
|
|
139937
140033
|
let timer;
|
|
@@ -139939,14 +140035,14 @@ function probeCli(bin, timeoutMs, pathVar = process.env.PATH ?? "") {
|
|
|
139939
140035
|
if (!done) {
|
|
139940
140036
|
done = true;
|
|
139941
140037
|
clearTimeout(timer);
|
|
139942
|
-
|
|
140038
|
+
resolve10(r);
|
|
139943
140039
|
}
|
|
139944
140040
|
};
|
|
139945
140041
|
let child;
|
|
139946
140042
|
try {
|
|
139947
140043
|
child = spawn6(exe, ["--version"], { stdio: ["ignore", "pipe", "ignore"], env: { ...process.env, NO_COLOR: "1" } });
|
|
139948
140044
|
} catch {
|
|
139949
|
-
return
|
|
140045
|
+
return resolve10({ installed: true, version: null, probe: "error" });
|
|
139950
140046
|
}
|
|
139951
140047
|
timer = setTimeout(() => {
|
|
139952
140048
|
try {
|
|
@@ -140102,9 +140198,9 @@ function mount21(ctx) {
|
|
|
140102
140198
|
}
|
|
140103
140199
|
|
|
140104
140200
|
// src/server/routes/workspace.ts
|
|
140105
|
-
import { existsSync as existsSync123, mkdirSync as mkdirSync93, readFileSync as readFileSync158, readdirSync as readdirSync60, renameSync as renameSync31, statSync as
|
|
140201
|
+
import { existsSync as existsSync123, mkdirSync as mkdirSync93, readFileSync as readFileSync158, readdirSync as readdirSync60, renameSync as renameSync31, statSync as statSync55, writeFileSync as writeFileSync92 } from "fs";
|
|
140106
140202
|
import { homedir as homedir18, userInfo } from "os";
|
|
140107
|
-
import { dirname as dirname77, join as join173, resolve as
|
|
140203
|
+
import { dirname as dirname77, join as join173, resolve as resolve47, sep as sep30 } from "path";
|
|
140108
140204
|
var ID7 = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
140109
140205
|
var MAX_BYTES3 = 200000;
|
|
140110
140206
|
var workspaceFile = (env2 = process.env) => env2["LOKI_WORKSPACE_FILE"] || join173(homedir18(), ".loki", "control", "workspace.json");
|
|
@@ -140174,7 +140270,7 @@ function repoDirsOf(db2, name) {
|
|
|
140174
140270
|
const rows = db2.select({ name: localRepos.name, realpath: localRepos.realpath }).from(localRepos).all().filter((r) => r.name === name);
|
|
140175
140271
|
return [...new Set(rows.map((r) => r.realpath))].filter((d) => {
|
|
140176
140272
|
try {
|
|
140177
|
-
return
|
|
140273
|
+
return statSync55(d).isDirectory();
|
|
140178
140274
|
} catch {
|
|
140179
140275
|
return false;
|
|
140180
140276
|
}
|
|
@@ -140185,7 +140281,7 @@ var INSTRUCTION_FILES = ["CLAUDE.md", "CLAUDE.local.md", ".claude/CLAUDE.md", "A
|
|
|
140185
140281
|
var NOTE_DIRS = [".loki/memory", ".loki/learnings", ".claude/rules"];
|
|
140186
140282
|
var readCapped3 = (p) => {
|
|
140187
140283
|
try {
|
|
140188
|
-
const st2 =
|
|
140284
|
+
const st2 = statSync55(p);
|
|
140189
140285
|
if (!st2.isFile())
|
|
140190
140286
|
return null;
|
|
140191
140287
|
const b = readFileSync158(p);
|
|
@@ -140216,7 +140312,7 @@ function repoKnowledge(dir) {
|
|
|
140216
140312
|
return { instructions, notes };
|
|
140217
140313
|
}
|
|
140218
140314
|
function writeInstructions(dir, content) {
|
|
140219
|
-
const root =
|
|
140315
|
+
const root = resolve47(dir), target = join173(root, "CLAUDE.md");
|
|
140220
140316
|
if (!target.startsWith(root + sep30))
|
|
140221
140317
|
throw new Error("path outside the repository");
|
|
140222
140318
|
const tmp = `${target}.${process.pid}.tmp`;
|
|
@@ -141028,9 +141124,9 @@ function createApp(opts) {
|
|
|
141028
141124
|
}
|
|
141029
141125
|
if (!uiDir || p.startsWith("/v1/"))
|
|
141030
141126
|
return c.json({ error: "not found" }, 404);
|
|
141031
|
-
const root =
|
|
141032
|
-
const f =
|
|
141033
|
-
if (f.startsWith(root + sep31) && existsSync125(f) &&
|
|
141127
|
+
const root = resolve48(uiDir);
|
|
141128
|
+
const f = resolve48(root, `.${p}`);
|
|
141129
|
+
if (f.startsWith(root + sep31) && existsSync125(f) && statSync56(f).isFile())
|
|
141034
141130
|
return new Response(Bun.file(f));
|
|
141035
141131
|
if (/\.[a-z0-9]+$/i.test(p))
|
|
141036
141132
|
return c.json({ error: "not found" }, 404);
|