loki-mode 11.146.0 → 11.147.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/autonomy/lib/secret-scan.sh +7 -2
- package/autonomy/verify.sh +7 -2
- 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 +1915 -1866
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +559 -405
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-DeR4gl6L.js → AdminPage-BMvwexjQ.js} +1 -1
- package/web-app/dist/assets/{Avatar-ByWp4bxk.js → Avatar-CfkC79c3.js} +1 -1
- package/web-app/dist/assets/{Badge-D7AlqwvS.js → Badge-CQqH4Hem.js} +1 -1
- package/web-app/dist/assets/{Button-B0Mukoh2.js → Button-4UdYP24d.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-BZRQbXD_.js → CockpitPage-C7LEbCrM.js} +1 -1
- package/web-app/dist/assets/{ComparePage-B_rn9nnQ.js → ComparePage-Ve1BS_x2.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-Cp0pyJvY.js → ErrorBoundary-Cl9od_1B.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-DmWRoowG.js → EvidenceReceiptPanel-5eTo3MR7.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-B5DI_-br.js → GitHubIssuesPanel-ChxzVbJj.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-CW0LYfHT.js → GitHubPRsPanel-DMyctO75.js} +1 -1
- package/web-app/dist/assets/{HomePage-DPSWa5R5.js → HomePage-XkiUsK0I.js} +2 -2
- package/web-app/dist/assets/{LoginPage-CwoGp6Vj.js → LoginPage-Do4AESUj.js} +1 -1
- package/web-app/dist/assets/{MagicPage-gkNRlwuf.js → MagicPage-tQT4NhvK.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-CDnOCldd.js → MetricsPage-BRpQ5j9b.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-Bnvssp3g.js → NotFoundPage-CClAf7lp.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-DgtG5BlM.js → ProjectPage-Bm_5mzNw.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-Ckbjkg_L.js → ProjectsPage-BEqNV5uq.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-D-R2gEUm.js → SettingsPage-B-3niEp-.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-Em9ddqYI.js → ShowcasePage-Bgmf8L36.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-gN8Y0061.js → SystemSettingsPage-B2r4ns1l.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-CUuN5SDA.js → TeamsPage-CFnggeui.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-CXOEV__d.js → TemplatesPage-A_4uAZY6.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-BWG3HITb.js → TerminalOutput-BoEdnm-M.js} +1 -1
- package/web-app/dist/assets/{activity-DxQfYkTL.js → activity-BOSpWO2W.js} +1 -1
- package/web-app/dist/assets/{bell-BwhFGRVu.js → bell-IyUIduRQ.js} +1 -1
- package/web-app/dist/assets/{bot-CyvCOo2P.js → bot-BM1VS3XN.js} +1 -1
- package/web-app/dist/assets/{check-BO8HHeFn.js → check-DaoAoVE6.js} +1 -1
- package/web-app/dist/assets/{chevron-left-DHacGkaA.js → chevron-left-D5iMrc40.js} +1 -1
- package/web-app/dist/assets/{circle-alert-CtUDR5al.js → circle-alert-DR3HNYeA.js} +1 -1
- package/web-app/dist/assets/{clock-eFnNWkzH.js → clock-DOc4LATU.js} +1 -1
- package/web-app/dist/assets/{cloud-CNw2NygE.js → cloud-Dks7qs40.js} +1 -1
- package/web-app/dist/assets/{code-xml-epWPsMsv.js → code-xml-CMdkWBY9.js} +1 -1
- package/web-app/dist/assets/{database-DF7YXeji.js → database-CFaZAV5h.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-3qMKGL_Z.js → dollar-sign-3r252MtY.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-d4385evP.js → file-code-corner-BdfoBM6Q.js} +1 -1
- package/web-app/dist/assets/{file-plus-BdY4WvqD.js → file-plus-DWgk1WFy.js} +1 -1
- package/web-app/dist/assets/{globe-D-pzos7L.js → globe-CQs1OPNS.js} +1 -1
- package/web-app/dist/assets/{hammer-CKSu1dvx.js → hammer-BvKxwbdj.js} +1 -1
- package/web-app/dist/assets/{index-MgAdMJ-_.js → index-DymFh2L1.js} +3 -3
- package/web-app/dist/assets/{layers-Df6wyWQv.js → layers-lcbVWAxC.js} +1 -1
- package/web-app/dist/assets/{loader-circle-D7ToQmQ_.js → loader-circle-VSOQj5_P.js} +1 -1
- package/web-app/dist/assets/{lock-tnSuBc1R.js → lock-c6R6zJnw.js} +1 -1
- package/web-app/dist/assets/{package-Bjca3WQy.js → package-DELuK13T.js} +1 -1
- package/web-app/dist/assets/{plus-DuwA_qsO.js → plus-d2vcE9IO.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-Da58kJj9.js → refresh-cw-BzJ6JHvZ.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-Fkw8w7IS.js → rotate-ccw-CYKipckB.js} +1 -1
- package/web-app/dist/assets/{scroll-text-C8H6DOOY.js → scroll-text-DDzufCS2.js} +1 -1
- package/web-app/dist/assets/{server-BM6Vt7xD.js → server-BPIwN9NB.js} +1 -1
- package/web-app/dist/assets/{shield-alert-DWYdFESN.js → shield-alert-PoaTr3PN.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-Dl3OOA_N.js → thumbs-up-Bb7o5Vke.js} +1 -1
- package/web-app/dist/assets/{trash-2-BspuXMRV.js → trash-2-BT9DxpYE.js} +1 -1
- package/web-app/dist/assets/{trending-down-DK9U9VEk.js → trending-down-BG2q1nVM.js} +1 -1
- package/web-app/dist/assets/{trending-up-C5RaQYmy.js → trending-up-DI1UcsKN.js} +1 -1
- package/web-app/dist/assets/{upload-CMZ51Yr8.js → upload-ZC7osdna.js} +1 -1
- package/web-app/dist/assets/{usePolling-DZ1CmD1A.js → usePolling-T5CvoNTb.js} +1 -1
- package/web-app/dist/assets/{user-C-xZ3AXa.js → user-BBesY7Dg.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -12946,171 +12946,6 @@ var init_lean_select = __esm(() => {
|
|
|
12946
12946
|
init_relevant_files();
|
|
12947
12947
|
});
|
|
12948
12948
|
|
|
12949
|
-
// ../../loki-ts/src/util/claude_model.ts
|
|
12950
|
-
var exports_claude_model = {};
|
|
12951
|
-
__export(exports_claude_model, {
|
|
12952
|
-
resolveClaudeModel: () => resolveClaudeModel,
|
|
12953
|
-
isUnresolvedClaudeAlias: () => isUnresolvedClaudeAlias,
|
|
12954
|
-
haikuRun: () => haikuRun,
|
|
12955
|
-
explicitSetupModel: () => explicitSetupModel,
|
|
12956
|
-
claudeTierRank: () => claudeTierRank,
|
|
12957
|
-
claudeThinkingSubstitute: () => claudeThinkingSubstitute,
|
|
12958
|
-
claudeThinkingMaxEffort: () => claudeThinkingMaxEffort,
|
|
12959
|
-
claudeThinkingHasAdaptive: () => claudeThinkingHasAdaptive,
|
|
12960
|
-
claudeThinkingAccepted: () => claudeThinkingAccepted,
|
|
12961
|
-
claudeEffortLevels: () => claudeEffortLevels,
|
|
12962
|
-
chooseSessionModel: () => chooseSessionModel,
|
|
12963
|
-
canonicalSessionPin: () => canonicalSessionPin,
|
|
12964
|
-
VALID_TIERS: () => VALID_TIERS,
|
|
12965
|
-
PROVIDER_DEFAULT_MODEL: () => PROVIDER_DEFAULT_MODEL,
|
|
12966
|
-
GENERIC_TIERS: () => GENERIC_TIERS,
|
|
12967
|
-
EXPLICIT_MODEL_ENV: () => EXPLICIT_MODEL_ENV,
|
|
12968
|
-
DEFAULT_SESSION_MODEL: () => DEFAULT_SESSION_MODEL
|
|
12969
|
-
});
|
|
12970
|
-
import { readFileSync as readFileSync35 } from "fs";
|
|
12971
|
-
import { resolve as resolve12 } from "path";
|
|
12972
|
-
function resolveClaudeModel(want) {
|
|
12973
|
-
try {
|
|
12974
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12975
|
-
return JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
12976
|
-
} catch {
|
|
12977
|
-
return want;
|
|
12978
|
-
}
|
|
12979
|
-
}
|
|
12980
|
-
function isUnresolvedClaudeAlias(model) {
|
|
12981
|
-
return FAMILY_ALIASES.has(model);
|
|
12982
|
-
}
|
|
12983
|
-
function claudeTierRank(model) {
|
|
12984
|
-
try {
|
|
12985
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12986
|
-
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
12987
|
-
if (!Array.isArray(models))
|
|
12988
|
-
return null;
|
|
12989
|
-
const order2 = [];
|
|
12990
|
-
for (const m of models)
|
|
12991
|
-
if (m.tier !== "legacy" && !order2.includes(m.tier))
|
|
12992
|
-
order2.push(m.tier);
|
|
12993
|
-
const id = resolveClaudeModel(model);
|
|
12994
|
-
const hit = models.find((m) => m.id === id || m.alias === model);
|
|
12995
|
-
const rank = hit ? order2.indexOf(hit.tier) : -1;
|
|
12996
|
-
return rank >= 0 ? rank : null;
|
|
12997
|
-
} catch {
|
|
12998
|
-
return null;
|
|
12999
|
-
}
|
|
13000
|
-
}
|
|
13001
|
-
function claudeEffortLevels(model) {
|
|
13002
|
-
try {
|
|
13003
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13004
|
-
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13005
|
-
if (!Array.isArray(models))
|
|
13006
|
-
return null;
|
|
13007
|
-
const id = resolveClaudeModel(model);
|
|
13008
|
-
const levels = models.find((m) => m.id === id || m.alias === model)?.effort?.levels;
|
|
13009
|
-
return Array.isArray(levels) ? levels : null;
|
|
13010
|
-
} catch {
|
|
13011
|
-
return null;
|
|
13012
|
-
}
|
|
13013
|
-
}
|
|
13014
|
-
function claudeThinkingSpec(model) {
|
|
13015
|
-
try {
|
|
13016
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13017
|
-
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13018
|
-
if (!Array.isArray(models))
|
|
13019
|
-
return null;
|
|
13020
|
-
const id = resolveClaudeModel(model);
|
|
13021
|
-
return models.find((m) => m.id === id || m.alias === model)?.thinking ?? null;
|
|
13022
|
-
} catch {
|
|
13023
|
-
return null;
|
|
13024
|
-
}
|
|
13025
|
-
}
|
|
13026
|
-
function claudeThinkingMaxEffort(model, type) {
|
|
13027
|
-
const max = claudeThinkingSpec(model)?.max_effort?.[type];
|
|
13028
|
-
return typeof max === "string" ? max : null;
|
|
13029
|
-
}
|
|
13030
|
-
function claudeThinkingSubstitute(model, type) {
|
|
13031
|
-
const sub = claudeThinkingSpec(model)?.substitute?.[type];
|
|
13032
|
-
return typeof sub === "string" ? sub : null;
|
|
13033
|
-
}
|
|
13034
|
-
function claudeThinkingAccepted(model, type) {
|
|
13035
|
-
const spec = claudeThinkingSpec(model);
|
|
13036
|
-
if (!spec || !Array.isArray(spec.types))
|
|
13037
|
-
return true;
|
|
13038
|
-
return spec.types.includes(type) || typeof spec.substitute?.[type] === "string";
|
|
13039
|
-
}
|
|
13040
|
-
function claudeThinkingHasAdaptive(model) {
|
|
13041
|
-
const types = claudeThinkingSpec(model)?.types;
|
|
13042
|
-
return Array.isArray(types) && types.includes("adaptive");
|
|
13043
|
-
}
|
|
13044
|
-
function canonicalSessionPin(raw2) {
|
|
13045
|
-
const v = (raw2 ?? "").trim().toLowerCase();
|
|
13046
|
-
if (!v)
|
|
13047
|
-
return;
|
|
13048
|
-
const pin = GENERIC_TIERS[v] ?? v;
|
|
13049
|
-
if (!VALID_TIERS.has(pin)) {
|
|
13050
|
-
throw new Error(`unknown LOKI_SESSION_MODEL '${(raw2 ?? "").trim()}' (small|medium|high, planning|development|fast, or opus|sonnet|haiku|fable)`);
|
|
13051
|
-
}
|
|
13052
|
-
return pin;
|
|
13053
|
-
}
|
|
13054
|
-
function explicitSetupModel(tier, e = process.env) {
|
|
13055
|
-
if (e["LOKI_LEGACY_TIER_SWITCHING"] === "true")
|
|
13056
|
-
return;
|
|
13057
|
-
const sess = (e["LOKI_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
13058
|
-
if (tier === "planning" && (sess === "high" || sess === "planning"))
|
|
13059
|
-
return e["LOKI_CLAUDE_MODEL_PLANNING"] || e["LOKI_MODEL_PLANNING"] ? undefined : "opus";
|
|
13060
|
-
if (tier !== "fast" || sess !== "small" && sess !== "fast" || e["LOKI_CLAUDE_MODEL_FAST"] || e["LOKI_MODEL_FAST"])
|
|
13061
|
-
return;
|
|
13062
|
-
return e["LOKI_ALLOW_HAIKU"] === undefined || e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : undefined;
|
|
13063
|
-
}
|
|
13064
|
-
function chooseSessionModel(e = process.env) {
|
|
13065
|
-
const carried = canonicalSessionPin(e["LOKI_SESSION_MODEL"]);
|
|
13066
|
-
if (e["LOKI_SESSION_MODEL_SOURCE"] === "default" && carried && EXPLICIT_MODEL_ENV.every((k) => k === "LOKI_SESSION_MODEL" || (e[k] ?? "").trim() === ""))
|
|
13067
|
-
return { source: "default", pin: carried, why: "Loki default, carried from the parent run" };
|
|
13068
|
-
const named = EXPLICIT_MODEL_ENV.find((k) => (e[k] ?? "").trim() !== "");
|
|
13069
|
-
if (named)
|
|
13070
|
-
return { source: "explicit", pin: null, why: named === "LOKI_SESSION_MODEL" ? "--session-model or LOKI_SESSION_MODEL" : named };
|
|
13071
|
-
const router = (e["LOKI_ROUTER"] ?? "").trim().toLowerCase();
|
|
13072
|
-
if (["1", "true", "on", "auto"].includes(router))
|
|
13073
|
-
return { source: "explicit", pin: null, why: `LOKI_ROUTER=${router}` };
|
|
13074
|
-
const raw2 = (e["LOKI_DEFAULT_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
13075
|
-
if (raw2 === "provider")
|
|
13076
|
-
return { source: "provider", pin: null, why: "LOKI_DEFAULT_SESSION_MODEL=provider (the Claude CLI's own default)" };
|
|
13077
|
-
const pin = canonicalSessionPin(raw2 || DEFAULT_SESSION_MODEL);
|
|
13078
|
-
return { source: "default", pin, why: raw2 ? `LOKI_DEFAULT_SESSION_MODEL=${raw2}` : "Loki default, set another with --session-model or LOKI_DEFAULT_SESSION_MODEL=provider" };
|
|
13079
|
-
}
|
|
13080
|
-
function haikuRun(e = process.env) {
|
|
13081
|
-
const H = /haiku/i, val = (k) => (e[k] ?? "").trim();
|
|
13082
|
-
if (val("LOKI_PROVIDER").toLowerCase() === "opencode")
|
|
13083
|
-
return H.test(val("LOKI_OPENCODE_MODEL"));
|
|
13084
|
-
for (const k of ["LOKI_MODEL_OVERRIDE", "LOKI_MODEL_ROUTE", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_MODEL_DEVELOPMENT"])
|
|
13085
|
-
if (val(k))
|
|
13086
|
-
return H.test(val(k));
|
|
13087
|
-
let pin;
|
|
13088
|
-
try {
|
|
13089
|
-
pin = canonicalSessionPin(e["LOKI_SESSION_MODEL"]) ?? chooseSessionModel(e).pin ?? undefined;
|
|
13090
|
-
} catch {
|
|
13091
|
-
return false;
|
|
13092
|
-
}
|
|
13093
|
-
if (pin === "haiku")
|
|
13094
|
-
return true;
|
|
13095
|
-
if (pin === "fast")
|
|
13096
|
-
return H.test(explicitSetupModel("fast", e) ?? (val("LOKI_CLAUDE_MODEL_FAST") || val("LOKI_MODEL_FAST") || (e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : "sonnet")));
|
|
13097
|
-
if (pin)
|
|
13098
|
-
return false;
|
|
13099
|
-
return routerPreset(e) && H.test(presetExecutor(e).model);
|
|
13100
|
-
}
|
|
13101
|
-
var PROVIDER_DEFAULT_MODEL = "claude (provider default)", FAMILY_ALIASES, VALID_TIERS, GENERIC_TIERS, DEFAULT_SESSION_MODEL = "sonnet", EXPLICIT_MODEL_ENV;
|
|
13102
|
-
var init_claude_model = __esm(() => {
|
|
13103
|
-
init_paths();
|
|
13104
|
-
FAMILY_ALIASES = new Set(["haiku", "sonnet", "opus", "fable"]);
|
|
13105
|
-
VALID_TIERS = new Set(["planning", "development", "fast", "opus", "sonnet", "haiku", "fable"]);
|
|
13106
|
-
GENERIC_TIERS = {
|
|
13107
|
-
small: "fast",
|
|
13108
|
-
medium: "development",
|
|
13109
|
-
high: "planning"
|
|
13110
|
-
};
|
|
13111
|
-
EXPLICIT_MODEL_ENV = ["LOKI_SESSION_MODEL", "LOKI_MODEL_OVERRIDE", "LOKI_MODEL_ROUTE", "LOKI_MODEL_DEVELOPMENT", "LOKI_MODEL_PLANNING", "LOKI_MODEL_FAST", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_CLAUDE_MODEL_PLANNING", "LOKI_CLAUDE_MODEL_FAST"];
|
|
13112
|
-
});
|
|
13113
|
-
|
|
13114
12949
|
// ../../loki-ts/src/features/decompose.ts
|
|
13115
12950
|
function isSharedFile(path) {
|
|
13116
12951
|
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
@@ -13300,10 +13135,9 @@ var SHARED_BASENAME, LIST_RE, HEAD_RE, SOLUTION_WORD, ACCEPT_WORD, CONTEXT_WORD,
|
|
|
13300
13135
|
return true;
|
|
13301
13136
|
if (/^(0|off|false|no)$/i.test(v))
|
|
13302
13137
|
return false;
|
|
13303
|
-
return
|
|
13138
|
+
return true;
|
|
13304
13139
|
}, MS_HEAD_RE, MS_KEY_RE, uniqSorted = (a) => [...new Set(a)].sort();
|
|
13305
13140
|
var init_decompose = __esm(() => {
|
|
13306
|
-
init_claude_model();
|
|
13307
13141
|
SHARED_BASENAME = /^(package\.json|package-lock\.json|bun\.lockb?|yarn\.lock|pnpm-lock\.yaml|Cargo\.toml|Cargo\.lock|go\.mod|go\.sum|poetry\.lock|Pipfile\.lock|requirements\.txt|pyproject\.toml|CHANGELOG(\.md)?|index\.(ts|tsx|js|jsx|mjs)|__init__\.py|mod\.rs)$/i;
|
|
13308
13142
|
LIST_RE = /^\s*(?:\d+[.)]|[-*+])\s+(?:\[[ xX]\]\s+)?(\S.*)$/;
|
|
13309
13143
|
HEAD_RE = /^\s{0,3}#{1,6}\s+(\S.*?)\s*#*\s*$/;
|
|
@@ -13318,6 +13152,171 @@ var init_decompose = __esm(() => {
|
|
|
13318
13152
|
MS_KEY_RE = /^milestones:\s*$/i;
|
|
13319
13153
|
});
|
|
13320
13154
|
|
|
13155
|
+
// ../../loki-ts/src/util/claude_model.ts
|
|
13156
|
+
var exports_claude_model = {};
|
|
13157
|
+
__export(exports_claude_model, {
|
|
13158
|
+
resolveClaudeModel: () => resolveClaudeModel,
|
|
13159
|
+
isUnresolvedClaudeAlias: () => isUnresolvedClaudeAlias,
|
|
13160
|
+
haikuRun: () => haikuRun,
|
|
13161
|
+
explicitSetupModel: () => explicitSetupModel,
|
|
13162
|
+
claudeTierRank: () => claudeTierRank,
|
|
13163
|
+
claudeThinkingSubstitute: () => claudeThinkingSubstitute,
|
|
13164
|
+
claudeThinkingMaxEffort: () => claudeThinkingMaxEffort,
|
|
13165
|
+
claudeThinkingHasAdaptive: () => claudeThinkingHasAdaptive,
|
|
13166
|
+
claudeThinkingAccepted: () => claudeThinkingAccepted,
|
|
13167
|
+
claudeEffortLevels: () => claudeEffortLevels,
|
|
13168
|
+
chooseSessionModel: () => chooseSessionModel,
|
|
13169
|
+
canonicalSessionPin: () => canonicalSessionPin,
|
|
13170
|
+
VALID_TIERS: () => VALID_TIERS,
|
|
13171
|
+
PROVIDER_DEFAULT_MODEL: () => PROVIDER_DEFAULT_MODEL,
|
|
13172
|
+
GENERIC_TIERS: () => GENERIC_TIERS,
|
|
13173
|
+
EXPLICIT_MODEL_ENV: () => EXPLICIT_MODEL_ENV,
|
|
13174
|
+
DEFAULT_SESSION_MODEL: () => DEFAULT_SESSION_MODEL
|
|
13175
|
+
});
|
|
13176
|
+
import { readFileSync as readFileSync35 } from "fs";
|
|
13177
|
+
import { resolve as resolve12 } from "path";
|
|
13178
|
+
function resolveClaudeModel(want) {
|
|
13179
|
+
try {
|
|
13180
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13181
|
+
return JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
13182
|
+
} catch {
|
|
13183
|
+
return want;
|
|
13184
|
+
}
|
|
13185
|
+
}
|
|
13186
|
+
function isUnresolvedClaudeAlias(model) {
|
|
13187
|
+
return FAMILY_ALIASES.has(model);
|
|
13188
|
+
}
|
|
13189
|
+
function claudeTierRank(model) {
|
|
13190
|
+
try {
|
|
13191
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13192
|
+
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13193
|
+
if (!Array.isArray(models))
|
|
13194
|
+
return null;
|
|
13195
|
+
const order2 = [];
|
|
13196
|
+
for (const m of models)
|
|
13197
|
+
if (m.tier !== "legacy" && !order2.includes(m.tier))
|
|
13198
|
+
order2.push(m.tier);
|
|
13199
|
+
const id = resolveClaudeModel(model);
|
|
13200
|
+
const hit = models.find((m) => m.id === id || m.alias === model);
|
|
13201
|
+
const rank = hit ? order2.indexOf(hit.tier) : -1;
|
|
13202
|
+
return rank >= 0 ? rank : null;
|
|
13203
|
+
} catch {
|
|
13204
|
+
return null;
|
|
13205
|
+
}
|
|
13206
|
+
}
|
|
13207
|
+
function claudeEffortLevels(model) {
|
|
13208
|
+
try {
|
|
13209
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13210
|
+
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13211
|
+
if (!Array.isArray(models))
|
|
13212
|
+
return null;
|
|
13213
|
+
const id = resolveClaudeModel(model);
|
|
13214
|
+
const levels = models.find((m) => m.id === id || m.alias === model)?.effort?.levels;
|
|
13215
|
+
return Array.isArray(levels) ? levels : null;
|
|
13216
|
+
} catch {
|
|
13217
|
+
return null;
|
|
13218
|
+
}
|
|
13219
|
+
}
|
|
13220
|
+
function claudeThinkingSpec(model) {
|
|
13221
|
+
try {
|
|
13222
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
13223
|
+
const models = JSON.parse(readFileSync35(path, "utf8")).providers?.claude?.models;
|
|
13224
|
+
if (!Array.isArray(models))
|
|
13225
|
+
return null;
|
|
13226
|
+
const id = resolveClaudeModel(model);
|
|
13227
|
+
return models.find((m) => m.id === id || m.alias === model)?.thinking ?? null;
|
|
13228
|
+
} catch {
|
|
13229
|
+
return null;
|
|
13230
|
+
}
|
|
13231
|
+
}
|
|
13232
|
+
function claudeThinkingMaxEffort(model, type) {
|
|
13233
|
+
const max = claudeThinkingSpec(model)?.max_effort?.[type];
|
|
13234
|
+
return typeof max === "string" ? max : null;
|
|
13235
|
+
}
|
|
13236
|
+
function claudeThinkingSubstitute(model, type) {
|
|
13237
|
+
const sub = claudeThinkingSpec(model)?.substitute?.[type];
|
|
13238
|
+
return typeof sub === "string" ? sub : null;
|
|
13239
|
+
}
|
|
13240
|
+
function claudeThinkingAccepted(model, type) {
|
|
13241
|
+
const spec = claudeThinkingSpec(model);
|
|
13242
|
+
if (!spec || !Array.isArray(spec.types))
|
|
13243
|
+
return true;
|
|
13244
|
+
return spec.types.includes(type) || typeof spec.substitute?.[type] === "string";
|
|
13245
|
+
}
|
|
13246
|
+
function claudeThinkingHasAdaptive(model) {
|
|
13247
|
+
const types = claudeThinkingSpec(model)?.types;
|
|
13248
|
+
return Array.isArray(types) && types.includes("adaptive");
|
|
13249
|
+
}
|
|
13250
|
+
function canonicalSessionPin(raw2) {
|
|
13251
|
+
const v = (raw2 ?? "").trim().toLowerCase();
|
|
13252
|
+
if (!v)
|
|
13253
|
+
return;
|
|
13254
|
+
const pin = GENERIC_TIERS[v] ?? v;
|
|
13255
|
+
if (!VALID_TIERS.has(pin)) {
|
|
13256
|
+
throw new Error(`unknown LOKI_SESSION_MODEL '${(raw2 ?? "").trim()}' (small|medium|high, planning|development|fast, or opus|sonnet|haiku|fable)`);
|
|
13257
|
+
}
|
|
13258
|
+
return pin;
|
|
13259
|
+
}
|
|
13260
|
+
function explicitSetupModel(tier, e = process.env) {
|
|
13261
|
+
if (e["LOKI_LEGACY_TIER_SWITCHING"] === "true")
|
|
13262
|
+
return;
|
|
13263
|
+
const sess = (e["LOKI_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
13264
|
+
if (tier === "planning" && (sess === "high" || sess === "planning"))
|
|
13265
|
+
return e["LOKI_CLAUDE_MODEL_PLANNING"] || e["LOKI_MODEL_PLANNING"] ? undefined : "opus";
|
|
13266
|
+
if (tier !== "fast" || sess !== "small" && sess !== "fast" || e["LOKI_CLAUDE_MODEL_FAST"] || e["LOKI_MODEL_FAST"])
|
|
13267
|
+
return;
|
|
13268
|
+
return e["LOKI_ALLOW_HAIKU"] === undefined || e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : undefined;
|
|
13269
|
+
}
|
|
13270
|
+
function chooseSessionModel(e = process.env) {
|
|
13271
|
+
const carried = canonicalSessionPin(e["LOKI_SESSION_MODEL"]);
|
|
13272
|
+
if (e["LOKI_SESSION_MODEL_SOURCE"] === "default" && carried && EXPLICIT_MODEL_ENV.every((k) => k === "LOKI_SESSION_MODEL" || (e[k] ?? "").trim() === ""))
|
|
13273
|
+
return { source: "default", pin: carried, why: "Loki default, carried from the parent run" };
|
|
13274
|
+
const named = EXPLICIT_MODEL_ENV.find((k) => (e[k] ?? "").trim() !== "");
|
|
13275
|
+
if (named)
|
|
13276
|
+
return { source: "explicit", pin: null, why: named === "LOKI_SESSION_MODEL" ? "--session-model or LOKI_SESSION_MODEL" : named };
|
|
13277
|
+
const router = (e["LOKI_ROUTER"] ?? "").trim().toLowerCase();
|
|
13278
|
+
if (["1", "true", "on", "auto"].includes(router))
|
|
13279
|
+
return { source: "explicit", pin: null, why: `LOKI_ROUTER=${router}` };
|
|
13280
|
+
const raw2 = (e["LOKI_DEFAULT_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
13281
|
+
if (raw2 === "provider")
|
|
13282
|
+
return { source: "provider", pin: null, why: "LOKI_DEFAULT_SESSION_MODEL=provider (the Claude CLI's own default)" };
|
|
13283
|
+
const pin = canonicalSessionPin(raw2 || DEFAULT_SESSION_MODEL);
|
|
13284
|
+
return { source: "default", pin, why: raw2 ? `LOKI_DEFAULT_SESSION_MODEL=${raw2}` : "Loki default, set another with --session-model or LOKI_DEFAULT_SESSION_MODEL=provider" };
|
|
13285
|
+
}
|
|
13286
|
+
function haikuRun(e = process.env) {
|
|
13287
|
+
const H = /haiku/i, val = (k) => (e[k] ?? "").trim();
|
|
13288
|
+
if (val("LOKI_PROVIDER").toLowerCase() === "opencode")
|
|
13289
|
+
return H.test(val("LOKI_OPENCODE_MODEL"));
|
|
13290
|
+
for (const k of ["LOKI_MODEL_OVERRIDE", "LOKI_MODEL_ROUTE", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_MODEL_DEVELOPMENT"])
|
|
13291
|
+
if (val(k))
|
|
13292
|
+
return H.test(val(k));
|
|
13293
|
+
let pin;
|
|
13294
|
+
try {
|
|
13295
|
+
pin = canonicalSessionPin(e["LOKI_SESSION_MODEL"]) ?? chooseSessionModel(e).pin ?? undefined;
|
|
13296
|
+
} catch {
|
|
13297
|
+
return false;
|
|
13298
|
+
}
|
|
13299
|
+
if (pin === "haiku")
|
|
13300
|
+
return true;
|
|
13301
|
+
if (pin === "fast")
|
|
13302
|
+
return H.test(explicitSetupModel("fast", e) ?? (val("LOKI_CLAUDE_MODEL_FAST") || val("LOKI_MODEL_FAST") || (e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : "sonnet")));
|
|
13303
|
+
if (pin)
|
|
13304
|
+
return false;
|
|
13305
|
+
return routerPreset(e) && H.test(presetExecutor(e).model);
|
|
13306
|
+
}
|
|
13307
|
+
var PROVIDER_DEFAULT_MODEL = "claude (provider default)", FAMILY_ALIASES, VALID_TIERS, GENERIC_TIERS, DEFAULT_SESSION_MODEL = "sonnet", EXPLICIT_MODEL_ENV;
|
|
13308
|
+
var init_claude_model = __esm(() => {
|
|
13309
|
+
init_paths();
|
|
13310
|
+
FAMILY_ALIASES = new Set(["haiku", "sonnet", "opus", "fable"]);
|
|
13311
|
+
VALID_TIERS = new Set(["planning", "development", "fast", "opus", "sonnet", "haiku", "fable"]);
|
|
13312
|
+
GENERIC_TIERS = {
|
|
13313
|
+
small: "fast",
|
|
13314
|
+
medium: "development",
|
|
13315
|
+
high: "planning"
|
|
13316
|
+
};
|
|
13317
|
+
EXPLICIT_MODEL_ENV = ["LOKI_SESSION_MODEL", "LOKI_MODEL_OVERRIDE", "LOKI_MODEL_ROUTE", "LOKI_MODEL_DEVELOPMENT", "LOKI_MODEL_PLANNING", "LOKI_MODEL_FAST", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_CLAUDE_MODEL_PLANNING", "LOKI_CLAUDE_MODEL_FAST"];
|
|
13318
|
+
});
|
|
13319
|
+
|
|
13321
13320
|
// ../../loki-ts/src/runner/router/decision.ts
|
|
13322
13321
|
var exports_decision = {};
|
|
13323
13322
|
__export(exports_decision, {
|
|
@@ -17710,7 +17709,7 @@ function redOnBaseProfile(p, ids, errors2) {
|
|
|
17710
17709
|
for (const [k, v] of Object.entries(b.failing_errors ?? {}))
|
|
17711
17710
|
if (!baseErr.has(k))
|
|
17712
17711
|
baseErr.set(k, v);
|
|
17713
|
-
return ids.length > 0 && ids.every((i) => baseIds.has(i) || [...baseIds].some((b) => b.endsWith(` > ${i}`))) && sameErrors(errors2, baseErr, [...ids]);
|
|
17712
|
+
return ids.length > 0 && ids.every((i) => baseIds.has(i) || [...baseIds].some((b) => b.endsWith(` > ${i}`))) && (baseRedByIdOn() || sameErrors(errors2, baseErr, [...ids]));
|
|
17714
17713
|
}
|
|
17715
17714
|
function collateralOnBaseline(repoDir, baseSha, test, c, changed, stem) {
|
|
17716
17715
|
if (!collateralBaselineOn() || changed.includes(test))
|
|
@@ -32812,7 +32811,7 @@ ${cmds.join(`
|
|
|
32812
32811
|
return { text: text3, files: [...new Set([...files, ...pack.files])], pack: record, packText: pack.text };
|
|
32813
32812
|
}
|
|
32814
32813
|
var planHintsOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PLAN_HINTS"] ?? "").trim()), PLAN_HINT_LEAD = "A plan from an earlier session (a hint, not the scope: the task decides what to change; cover every case the task states even where the plan leaves it out, and edit any file the fix needs):", PINNED_RULE = '- Exception: when the task names an existing test file or asks to change tests, change only what it asks. An existing assertion that pins the OLD behavior the issue explicitly asks to change is not a spec conflict: change its expected value to the behavior the issue states, change nothing else in that test, and before the last line of your reply write one line per such change: `UPDATED TEST <path>:<line>: <old expectation> -> <new expectation>; issue: "<the issue sentence that asks for the new behavior>"`. Never delete a test, add skip, xfail or only, widen a tolerance, or touch a test unrelated to the behavior the issue names; any other existing test that contradicts the task is a spec conflict: cite it.', DOC_RULE_V139 = "- Write no documentation unless the task explicitly asks for it, except the release-note fragment a repository convention listed below requires. Never write documentation, changelog or README text that announces a behavior the code does not have, even to make a test pass: if the task needs code that is not in this repository, finish with LOKI_SPEC_CONFLICT.", DOC_RULE_UPDATE = "- Write no new documentation pages unless the task asks for them, except the release-note fragment a repository convention listed below requires. Do update existing docs that list what you changed: when you add or change an option, flag, method, rule or name that a README or doc page in the repository already lists, add or fix its entry there, written like the entries around it. Never write documentation, changelog or README text that announces a behavior the code does not have, even to make a test pass: if the task needs code that is not in this repository, finish with LOKI_SPEC_CONFLICT.", DOC_RULE, FIXED_RULES, FIXED_RULES_DOC_V139, docUpdateRuleOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DOC_UPDATE_RULE"] ?? "").trim()), LEGACY_FIXED_RULES, ISSUE_RULE_LINE = "- You may start this repository's own services and throwaway dependencies to exercise your change. Bind anything you start to 127.0.0.1 or a unix socket, never to all interfaces. Create data directories, sockets and scratch files under $TMPDIR. Leave what you started running; Loki stops it after the session. Never stop or signal a process you did not start. Use only a database, cache or server you started yourself under $TMPDIR; never connect to one named in the repository's env files or in your environment, and never apply migrations to it.", SERVER_RULES = `- Never leave a long-lived server running.
|
|
32815
|
-
- Never kill processes.`, PROVE_BY_RUNNING_BLOCK = "Before you finish, prove the change works by running it, not by reading it. Exercise each thing the task asks for the way its user or caller reaches it: start the service or program this repository provides (if it needs a database or another dependency, start a throwaway one in a temporary directory), and call every new or changed entry point exactly as its real caller does; for a web or API client, use the exact paths the client code sends. Never use a fixed port number: pick a port you have just checked is free, or a unix socket inside your temporary directory, and call only the processes you started; before the first call, confirm the process answering on that port is the one whose process id you recorded. Prove a fresh install, not only an existing one: start from an empty database or data directory, set it up with the repository's own migrations or setup command, and create the first account, tenant or other record through the product's own code path after your change. Fix whatever fails and run it again. You may say something cannot be run only after you have tried: list each command you tried to find or start it and what it printed. A missing program on PATH is not enough; look where this machine installs it. Before the finish line, list each requested item with the command you ran to prove it and what it returned, then one line starting `Fresh install:` with the commands that built the empty environment and created the first record, and what they returned. Loki checks the label against this list, so an item with no command and result counts as not proved.", PROOF_SCRIPT_LINE = "Put your proof in one script at exactly $LOKI_SCRATCH/loki-proof.sh (the same directory as $TMPDIR; never inside the repository, so it is not part of the change, and never delete it: Loki copies it from there when you finish) and run it yourself until it passes. The acceptance lines the label is checked against are numbered in $LOKI_SCRATCH/acceptance.txt: read it first. The script takes one argument, an empty directory, and must do everything inside it from nothing: create the database or data directory there, apply the repository's own migrations or setup, start what it needs on ports it has just checked are free (bound to 127.0.0.1), and create the first account, tenant or record through the product's own code. Then it proves each numbered line with the functions in $LOKI_SCRATCH/loki-check.sh, which it must source by that exact path (when Loki runs your script the variable points at Loki's own copy): `loki_http <line number> \"<what is proved>\" <expected status> <curl arguments>` for a request, sent the way the real caller sends it (for a page, every path its client code calls, same method and parameters; set LOKI_BODY_MATCH to a pattern the response must contain), and `loki_cmd <line number> \"<what is proved>\" <command>` for anything else (a test run, a query plan, a file that must exist). Only lines these functions print count: a line with no passing check is not met, and one failing check makes it not met, so give every line, including the fresh-install line if listed, at least one real check. It must stop what it started and exit 0 only when every required line is proved. Use paths relative to the repository root for the repository's own files. Loki runs this same script again by itself after you finish, in a new empty directory, and the label is a count of the checks that pass in that run, not of what you write about it.", TAKE_THE_TIME_LINE = "This is an issue to deliver in full, not a quick fix: take the time the work needs and finish every item the issue asks for. Starting this repository's own services and their dependencies to prove the change is expected here, not discouraged.", DELIVER_EACH_LINE = "This issue lists several things to deliver. Deliver each one. If a required one is left undone, finish with LOKI_UNFINISHED and say which. An item the issue marks optional may be skipped: say so and finish with LOKI_DONE.", proveByRunningBlock = (provider, source, env = process.env, cardLine = null) => issueRunBrief(provider, source, env) ? [PROVE_BY_RUNNING_BLOCK, PROOF_SCRIPT_LINE, TAKE_THE_TIME_LINE, DELIVER_EACH_LINE, ...cardLine ? [cardLine] : []].join(`
|
|
32814
|
+
- Never kill processes.`, PROVE_BY_RUNNING_BLOCK = "Before you finish, prove the change works by running it, not by reading it. Exercise each thing the task asks for the way its user or caller reaches it: start the service or program this repository provides (if it needs a database or another dependency, start a throwaway one in a temporary directory), and call every new or changed entry point exactly as its real caller does; for a web or API client, use the exact paths the client code sends. Never use a fixed port number: pick a port you have just checked is free, or a unix socket inside your temporary directory, and call only the processes you started; before the first call, confirm the process answering on that port is the one whose process id you recorded. Prove a fresh install, not only an existing one: start from an empty database or data directory, set it up with the repository's own migrations or setup command, and create the first account, tenant or other record through the product's own code path after your change. Fix whatever fails and run it again. You may say something cannot be run only after you have tried: list each command you tried to find or start it and what it printed. A missing program on PATH is not enough; look where this machine installs it. Before the finish line, list each requested item with the command you ran to prove it and what it returned, then one line starting `Fresh install:` with the commands that built the empty environment and created the first record, and what they returned. Loki checks the label against this list, so an item with no command and result counts as not proved.", PROOF_SCRIPT_LINE = "Put your proof in one script at exactly $LOKI_SCRATCH/loki-proof.sh (the same directory as $TMPDIR; never inside the repository, so it is not part of the change, and never delete it: Loki copies it from there when you finish) and run it yourself until it passes. The acceptance lines the label is checked against are numbered in $LOKI_SCRATCH/acceptance.txt: read it first. The script takes one argument, an empty directory, and must do everything inside it from nothing: create the database or data directory there, apply the repository's own migrations or setup, start what it needs on ports it has just checked are free (bound to 127.0.0.1), and create the first account, tenant or record through the product's own code. Then it proves each numbered line with the functions in $LOKI_SCRATCH/loki-check.sh, which it must source by that exact path (when Loki runs your script the variable points at Loki's own copy): `loki_http <line number> \"<what is proved>\" <expected status> <curl arguments>` for a request, sent the way the real caller sends it (for a page, every path its client code calls, same method and parameters; set LOKI_BODY_MATCH to a pattern the response must contain), and `loki_cmd <line number> \"<what is proved>\" <command>` for anything else (a test run, a query plan, a file that must exist). Only lines these functions print count: a line with no passing check is not met, and one failing check makes it not met, so give every line, including the fresh-install line if listed, at least one real check. It must stop what it started and exit 0 only when every required line is proved. Use paths relative to the repository root for the repository's own files. Loki runs this same script again by itself after you finish, in a new empty directory, and the label is a count of the checks that pass in that run, not of what you write about it. The same file gives you throwaway services: loki_pg_start <dir> and loki_redis_start <dir> start a new empty PostgreSQL or Redis on a free port and export its connection settings, loki_free_port prints a free port, loki_services_stop stops them. Use these for the proof and for your own runs; never use, and never expect, a database or cache that is already running on this machine.", TAKE_THE_TIME_LINE = "This is an issue to deliver in full, not a quick fix: take the time the work needs and finish every item the issue asks for. Starting this repository's own services and their dependencies to prove the change is expected here, not discouraged. Your reply ends this session and nothing runs after it: never end your turn while a subagent or a background command is still working. Wait for it, read its result, and only then reply.", DELIVER_EACH_LINE = "This issue lists several things to deliver. Deliver each one. If a required one is left undone, finish with LOKI_UNFINISHED and say which. An item the issue marks optional may be skipped: say so and finish with LOKI_DONE.", proveByRunningBlock = (provider, source, env = process.env, cardLine = null) => issueRunBrief(provider, source, env) ? [PROVE_BY_RUNNING_BLOCK, PROOF_SCRIPT_LINE, TAKE_THE_TIME_LINE, DELIVER_EACH_LINE, ...cardLine ? [cardLine] : []].join(`
|
|
32816
32815
|
|
|
32817
32816
|
`) : "", pinnedTestUpdateEnabled = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PINNED_TEST_UPDATE"] ?? "").trim()), fixedRules = (env = process.env, issue = false) => {
|
|
32818
32817
|
const r = pinnedTestUpdateEnabled(env) ? docUpdateRuleOn(env) ? FIXED_RULES : FIXED_RULES_DOC_V139 : LEGACY_FIXED_RULES;
|
|
@@ -33123,7 +33122,7 @@ ${PRESET_PLAN_INSTRUCTION}` : ""),
|
|
|
33123
33122
|
|
|
33124
33123
|
// ../../loki-ts/src/engine10/proof_rerun.ts
|
|
33125
33124
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
33126
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync63, readFileSync as readFileSync88, rmSync as rmSync29, statSync as statSync30, writeFileSync as writeFileSync49 } from "fs";
|
|
33125
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync63, mkdirSync as mkdirSync45, readFileSync as readFileSync88, realpathSync as realpathSync33, rmSync as rmSync29, statSync as statSync30, writeFileSync as writeFileSync49 } from "fs";
|
|
33127
33126
|
import { join as join97 } from "path";
|
|
33128
33127
|
function labelAsks(provider, intake, plan, repoDir, env = process.env) {
|
|
33129
33128
|
if (!issueAcceptanceCapOn(env))
|
|
@@ -33159,6 +33158,32 @@ async function worktreeTree(repoDir) {
|
|
|
33159
33158
|
} catch {}
|
|
33160
33159
|
}
|
|
33161
33160
|
}
|
|
33161
|
+
async function unusedNewFiles(repoDir, baseSha, tree) {
|
|
33162
|
+
if (!baseSha || !tree)
|
|
33163
|
+
return [];
|
|
33164
|
+
try {
|
|
33165
|
+
const a = await run(["git", "-C", repoDir, "diff", "--name-only", "--diff-filter=A", baseSha, tree, "--", ".", ":(exclude).loki"], { timeoutMs: 30000 });
|
|
33166
|
+
if (a.exitCode !== 0)
|
|
33167
|
+
return [];
|
|
33168
|
+
const added = a.stdout.split(`
|
|
33169
|
+
`).filter((f) => UNUSED_EXT.test(f) && !UNUSED_TEST.test(f) && !UNUSED_ENTRY.test(f) && !UNUSED_DIR.test(f) && !/\.d\.ts$|\.config\.[a-z]+$/.test(f)).slice(0, 60), out2 = [];
|
|
33170
|
+
for (const f of added) {
|
|
33171
|
+
const stem2 = f.slice(f.lastIndexOf("/") + 1).replace(/\.[^.]+$/, "");
|
|
33172
|
+
if (stem2.length < 4)
|
|
33173
|
+
continue;
|
|
33174
|
+
const g = await run(["git", "-C", repoDir, "grep", "-l", "-F", "-w", "-e", stem2, tree, "--", "."], { timeoutMs: 30000 });
|
|
33175
|
+
if (g.exitCode > 1)
|
|
33176
|
+
continue;
|
|
33177
|
+
const users = g.stdout.split(`
|
|
33178
|
+
`).map((l) => l.slice(l.indexOf(":") + 1)).filter((u) => u && u !== f && !UNUSED_TEST.test(u));
|
|
33179
|
+
if (users.length === 0)
|
|
33180
|
+
out2.push(f);
|
|
33181
|
+
}
|
|
33182
|
+
return out2;
|
|
33183
|
+
} catch {
|
|
33184
|
+
return [];
|
|
33185
|
+
}
|
|
33186
|
+
}
|
|
33162
33187
|
function unmetBrief(unmet) {
|
|
33163
33188
|
return [
|
|
33164
33189
|
`Loki checked your change against the acceptance lines, using its own run of your proof script. ${unmet.length} line${unmet.length === 1 ? " is" : "s are"} not met yet:`,
|
|
@@ -33205,22 +33230,50 @@ function keepProofScript(scratchDir, runDir) {
|
|
|
33205
33230
|
const st = statSync30(src);
|
|
33206
33231
|
if (!st.isFile() || st.size === 0 || st.size > MAX_SCRIPT_BYTES)
|
|
33207
33232
|
return false;
|
|
33208
|
-
|
|
33233
|
+
const real3 = (() => {
|
|
33234
|
+
try {
|
|
33235
|
+
return realpathSync33(scratchDir);
|
|
33236
|
+
} catch {
|
|
33237
|
+
return scratchDir;
|
|
33238
|
+
}
|
|
33239
|
+
})(), names = [...new Set([real3, scratchDir, real3.replace(/^\/private\//, "/")])].filter((d) => d.length > 5).sort((a, b) => b.length - a.length);
|
|
33240
|
+
let text3 = readFileSync88(src, "utf8");
|
|
33241
|
+
for (const d of names)
|
|
33242
|
+
text3 = text3.split(d).join("${LOKI_SCRATCH}");
|
|
33243
|
+
writeFileSync49(join97(runDir, PROOF_SCRIPT), text3, { mode: 448 });
|
|
33209
33244
|
return true;
|
|
33210
33245
|
} catch {
|
|
33211
33246
|
return false;
|
|
33212
33247
|
}
|
|
33213
33248
|
}
|
|
33249
|
+
function proofScriptRefusal(text3) {
|
|
33250
|
+
const code = text3.split(`
|
|
33251
|
+
`).filter((l) => !/^\s*#/.test(l)).join(`
|
|
33252
|
+
`);
|
|
33253
|
+
const writes = code.split(`
|
|
33254
|
+
`).filter((l) => /(^|[\s;&|(])(echo|printf|print|tee|cat)\b/.test(l) && !/(^|[\s;&|(])(grep|egrep|awk|sed|rg)\b[^|]*LOKI-PROOF/.test(l));
|
|
33255
|
+
if (writes.some((l) => /LOKI_PROOF_TOKEN/.test(l)))
|
|
33256
|
+
return "the proof script writes output using LOKI_PROOF_TOKEN; results count only when loki_http or loki_cmd print them";
|
|
33257
|
+
if (writes.some((l) => /LOKI-PROOF/.test(l)))
|
|
33258
|
+
return "the proof script prints a LOKI-PROOF result line itself; results count only when loki_http or loki_cmd print them";
|
|
33259
|
+
if (/(^|[\s;&|({])(function\s+)?(loki_http|loki_cmd|_lp)\s*\(\s*\)/.test(code))
|
|
33260
|
+
return "the proof script redefines loki_http, loki_cmd or _lp; source loki-check.sh and use its functions unchanged";
|
|
33261
|
+
return null;
|
|
33262
|
+
}
|
|
33214
33263
|
async function rerunProof(repoDir, runDir, signal, env = process.env) {
|
|
33215
33264
|
const script = join97(runDir, PROOF_SCRIPT);
|
|
33216
33265
|
if (!proofRerunOn(env) || !existsSync63(script))
|
|
33217
33266
|
return null;
|
|
33218
|
-
let scriptChars = 0;
|
|
33267
|
+
let scriptChars = 0, refusal = null;
|
|
33219
33268
|
try {
|
|
33220
|
-
|
|
33269
|
+
const t = readFileSync88(script, "utf8");
|
|
33270
|
+
scriptChars = t.length;
|
|
33271
|
+
refusal = proofScriptRefusal(t);
|
|
33221
33272
|
} catch {
|
|
33222
33273
|
return null;
|
|
33223
33274
|
}
|
|
33275
|
+
if (refusal)
|
|
33276
|
+
return { refused: refusal, exit: null, seconds: 0, proved: 0, failed: 0, tail: `Loki did not run this proof script: ${refusal}.`, script_chars: scriptChars, stopped: 0, left: 0, lines: {} };
|
|
33224
33277
|
let scratch;
|
|
33225
33278
|
try {
|
|
33226
33279
|
scratch = createSessionScratch();
|
|
@@ -33233,10 +33286,13 @@ async function rerunProof(repoDir, runDir, signal, env = process.env) {
|
|
|
33233
33286
|
blank[k] = "";
|
|
33234
33287
|
const token = randomBytes7(8).toString("hex");
|
|
33235
33288
|
writeProofKit(scratch.dir, null);
|
|
33289
|
+
writeProofKit(runDir, null);
|
|
33236
33290
|
const t0 = Date.now();
|
|
33237
33291
|
let exit = null, out2 = "";
|
|
33238
33292
|
try {
|
|
33239
|
-
const
|
|
33293
|
+
const emptyDir = join97(scratch.dir, "run");
|
|
33294
|
+
mkdirSync45(emptyDir, { mode: 448 });
|
|
33295
|
+
const r = await run(["bash", script, emptyDir], { cwd: repoDir, timeoutMs: proofRerunS(env) * 1000, group: true, signal, env: { ...blank, ...scratchSessionEnv(scratch), LOKI_PROOF_TOKEN: token } });
|
|
33240
33296
|
exit = r.exitCode;
|
|
33241
33297
|
out2 = `${r.stdout}
|
|
33242
33298
|
${r.stderr}`;
|
|
@@ -33269,10 +33325,10 @@ function ruleStatus(asks2, r) {
|
|
|
33269
33325
|
const e = r?.lines[String(i + 1)], opt = optionalAsk(line2) ? { optional: true } : {};
|
|
33270
33326
|
if (e && e.proved > 0 && e.failed === 0)
|
|
33271
33327
|
return { line: line2, status: "met", evidence: `Loki's own run: ${e.proved} passing check${e.proved === 1 ? "" : "s"}; first: ${e.first_proved ?? ""}`.slice(0, 300), ...opt };
|
|
33272
|
-
return { line: line2, status: "unmet", reason: (!r ? "there is no proof script for Loki to run" : r.exit === null ? "Loki's own run of the proof did not finish" : e && e.failed > 0 ? `a check failed in Loki's own run: ${e.first_failed ?? ""}` : "Loki's own run has no passing check for this line").slice(0, 300), ...opt };
|
|
33328
|
+
return { line: line2, status: "unmet", reason: (!r ? "there is no proof script for Loki to run" : r.refused ? `Loki did not run the proof script: ${r.refused}` : r.exit === null ? "Loki's own run of the proof did not finish" : e && e.failed > 0 ? `a check failed in Loki's own run: ${e.first_failed ?? ""}` : "Loki's own run has no passing check for this line").slice(0, 300), ...opt };
|
|
33273
33329
|
});
|
|
33274
33330
|
}
|
|
33275
|
-
var PROOF_SCRIPT = "loki-proof.sh", PROOF_HELPER = "loki-check.sh", ACCEPTANCE_FILE = "acceptance.txt", PROOF_HELPER_SH = `# Loki proof helpers. Source this file; never edit it. Only lines printed by these functions count toward the label.
|
|
33331
|
+
var UNUSED_EXT, UNUSED_TEST, UNUSED_ENTRY, UNUSED_DIR, unusedNewFileNote = (f) => `new file nothing uses: ${f} is not imported or named by any other file (disclosed, does not cap: on merged history this check also flags files loaded by convention, 7 in about a thousand commits of two repositories)`, PROOF_SCRIPT = "loki-proof.sh", PROOF_HELPER = "loki-check.sh", ACCEPTANCE_FILE = "acceptance.txt", PROOF_HELPER_SH = `# Loki proof helpers. Source this file; never edit it. Only lines printed by these functions count toward the label.
|
|
33276
33332
|
_lp() { printf 'LOKI-PROOF %s %s %s: %s\\n' "\${LOKI_PROOF_TOKEN:-session}" "$1" "$2" "$3"; }
|
|
33277
33333
|
# loki_http <line number> "<what is proved>" <expected status> <curl arguments...>
|
|
33278
33334
|
# Sends the request with curl. Passes when the status equals the expected one (and, when LOKI_BODY_MATCH is set, the body matches that grep -E pattern).
|
|
@@ -33296,6 +33352,49 @@ loki_cmd() {
|
|
|
33296
33352
|
snip="$(printf '%s' "$out" | tail -n 3 | tr '\\n' ' ' | cut -c1-300)"
|
|
33297
33353
|
if [ "$rc" = 0 ]; then _lp PROVED "$n" "$what | exit 0 | $snip"; else _lp FAILED "$n" "$what | exit $rc | $snip"; return 1; fi
|
|
33298
33354
|
}
|
|
33355
|
+
|
|
33356
|
+
# ---- Throwaway services. Use these; never use or expect a database or cache already running on this machine. ----
|
|
33357
|
+
# loki_free_port: prints a TCP port that is free on 127.0.0.1 right now.
|
|
33358
|
+
loki_free_port() {
|
|
33359
|
+
python3 -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1]);s.close()' 2>/dev/null || perl -MIO::Socket::INET -e '$s=IO::Socket::INET->new(Listen=>1,LocalAddr=>"127.0.0.1",LocalPort=>0) or exit 1; print $s->sockport(),"
|
|
33360
|
+
"'
|
|
33361
|
+
}
|
|
33362
|
+
# _loki_bin <name>: prints the path of a program from PATH or the usual install locations.
|
|
33363
|
+
_loki_bin() {
|
|
33364
|
+
local n="$1" d p
|
|
33365
|
+
p="$(command -v "$n" 2>/dev/null)" && [ -n "$p" ] && { printf '%s
|
|
33366
|
+
' "$p"; return 0; }
|
|
33367
|
+
for d in /opt/homebrew/opt/postgresql@*/bin /opt/homebrew/opt/postgresql/bin /usr/local/opt/postgresql@*/bin /usr/local/opt/postgresql/bin /usr/lib/postgresql/*/bin /usr/pgsql-*/bin /opt/homebrew/bin /usr/local/bin /usr/bin; do
|
|
33368
|
+
[ -x "$d/$n" ] && { printf '%s
|
|
33369
|
+
' "$d/$n"; return 0; }
|
|
33370
|
+
done
|
|
33371
|
+
return 1
|
|
33372
|
+
}
|
|
33373
|
+
# loki_pg_start <empty dir>: starts a new, empty PostgreSQL under <dir>/pg on a free 127.0.0.1 port (superuser "postgres", no password).
|
|
33374
|
+
# Exports PGHOST PGPORT PGUSER PGDATABASE and DATABASE_URL, and LOKI_PG_BIN (the directory holding psql, createdb). Non-zero with the reason on failure.
|
|
33375
|
+
loki_pg_start() {
|
|
33376
|
+
local dir="$1" initdb pgctl
|
|
33377
|
+
initdb="$(_loki_bin initdb)" && pgctl="$(_loki_bin pg_ctl)" || { echo "loki_pg_start: PostgreSQL programs (initdb, pg_ctl) are not installed on this machine" >&2; return 1; }
|
|
33378
|
+
export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
|
|
33379
|
+
LOKI_PG_DATA="$dir/pg"; LOKI_PG_CTL="$pgctl"; LOKI_PG_BIN="$(dirname "$pgctl")"; PGPORT="$(loki_free_port)" || return 1
|
|
33380
|
+
"$initdb" -D "$LOKI_PG_DATA" -U postgres -A trust -E UTF8 >"$dir/pg-init.log" 2>&1 || { echo "loki_pg_start: initdb failed, see $dir/pg-init.log" >&2; return 1; }
|
|
33381
|
+
"$pgctl" -D "$LOKI_PG_DATA" -l "$dir/pg.log" -w -t 60 -o "-p $PGPORT -c listen_addresses=127.0.0.1 -c unix_socket_directories=''" start >/dev/null 2>&1 || { echo "loki_pg_start: the server did not start, see $dir/pg.log" >&2; return 1; }
|
|
33382
|
+
export LOKI_PG_DATA LOKI_PG_CTL LOKI_PG_BIN PGPORT PGHOST=127.0.0.1 PGUSER=postgres PGDATABASE=postgres DATABASE_URL="postgres://postgres@127.0.0.1:$PGPORT/postgres"
|
|
33383
|
+
}
|
|
33384
|
+
# loki_redis_start <empty dir>: starts a new, empty Redis on a free 127.0.0.1 port. Exports REDIS_HOST REDIS_PORT REDIS_URL.
|
|
33385
|
+
loki_redis_start() {
|
|
33386
|
+
local dir="$1" rs
|
|
33387
|
+
rs="$(_loki_bin redis-server)" || { echo "loki_redis_start: redis-server is not installed on this machine" >&2; return 1; }
|
|
33388
|
+
REDIS_PORT="$(loki_free_port)" || return 1
|
|
33389
|
+
mkdir -p "$dir/redis" && "$rs" --port "$REDIS_PORT" --bind 127.0.0.1 --dir "$dir/redis" --save "" --appendonly no --daemonize yes --pidfile "$dir/redis/redis.pid" --logfile "$dir/redis/redis.log" >/dev/null 2>&1 || { echo "loki_redis_start: redis-server did not start" >&2; return 1; }
|
|
33390
|
+
export REDIS_PORT REDIS_HOST=127.0.0.1 REDIS_URL="redis://127.0.0.1:$REDIS_PORT"; LOKI_REDIS_PID="$dir/redis/redis.pid"
|
|
33391
|
+
}
|
|
33392
|
+
# loki_services_stop: stops what loki_pg_start and loki_redis_start started. Call it from your EXIT trap.
|
|
33393
|
+
loki_services_stop() {
|
|
33394
|
+
[ -n "\${LOKI_PG_DATA:-}" ] && [ -n "\${LOKI_PG_CTL:-}" ] && "$LOKI_PG_CTL" -D "$LOKI_PG_DATA" -m fast stop >/dev/null 2>&1
|
|
33395
|
+
[ -n "\${LOKI_REDIS_PID:-}" ] && [ -f "$LOKI_REDIS_PID" ] && kill "$(cat "$LOKI_REDIS_PID")" 2>/dev/null
|
|
33396
|
+
return 0
|
|
33397
|
+
}
|
|
33299
33398
|
`, MAX_SCRIPT_BYTES = 200000, TAIL_CHARS = 8000, proofRerunS = (env = process.env) => {
|
|
33300
33399
|
const n3 = Number(env["LOKI_E10_PROOF_RERUN_S"]);
|
|
33301
33400
|
return n3 > 0 ? n3 : 600;
|
|
@@ -33310,6 +33409,10 @@ var init_proof_rerun = __esm(() => {
|
|
|
33310
33409
|
init_intent_card();
|
|
33311
33410
|
init_stack_tools();
|
|
33312
33411
|
init_types2();
|
|
33412
|
+
UNUSED_EXT = /\.(tsx?|jsx?|mjs|cjs|vue|svelte|py)$/;
|
|
33413
|
+
UNUSED_TEST = /(^|\/)(__tests__|tests?|spec|e2e|__mocks__|fixtures?|stories)\/|\.(test|spec|stories)\.[a-z]+$|(^|\/)(test_[^/]*|[^/]*_test)\.py$/;
|
|
33414
|
+
UNUSED_ENTRY = /(^|\/)(page|layout|route|index|main|app|server|middleware|loading|error|not-found|template|default|global-error|instrumentation|conftest|setup|manage|__init__|__main__|cli|worker)\.[a-z]+$/;
|
|
33415
|
+
UNUSED_DIR = /(^|\/)(migrations?|scripts?|bin|tools|seeds?|config|\.github|docs?|pages|api|routes|commands|plugins|hooks\.server)\//;
|
|
33313
33416
|
});
|
|
33314
33417
|
|
|
33315
33418
|
// ../../loki-ts/src/engine10/stages/xreview.ts
|
|
@@ -33580,7 +33683,7 @@ var init_implement_route = __esm(() => {
|
|
|
33580
33683
|
});
|
|
33581
33684
|
|
|
33582
33685
|
// ../../loki-ts/src/features/patch_protocol.ts
|
|
33583
|
-
import { existsSync as existsSync64, lstatSync as lstatSync26, mkdirSync as
|
|
33686
|
+
import { existsSync as existsSync64, lstatSync as lstatSync26, mkdirSync as mkdirSync46, readFileSync as readFileSync89, realpathSync as realpathSync34, rmSync as rmSync30, writeFileSync as writeFileSync50 } from "fs";
|
|
33584
33687
|
import { basename as basename31, dirname as dirname41, join as join99, normalize as normalize5, relative as relative20, sep as sep20 } from "path";
|
|
33585
33688
|
function buildPatchBrief(task, code, conventions, checkCmds) {
|
|
33586
33689
|
return [
|
|
@@ -33645,7 +33748,7 @@ function refusal(rules, rel, before, after) {
|
|
|
33645
33748
|
}
|
|
33646
33749
|
function contained(repoDir, rel) {
|
|
33647
33750
|
try {
|
|
33648
|
-
const root =
|
|
33751
|
+
const root = realpathSync34(repoDir);
|
|
33649
33752
|
let p = join99(root, rel);
|
|
33650
33753
|
for (;; ) {
|
|
33651
33754
|
let exists2 = false;
|
|
@@ -33654,7 +33757,7 @@ function contained(repoDir, rel) {
|
|
|
33654
33757
|
exists2 = true;
|
|
33655
33758
|
} catch {}
|
|
33656
33759
|
if (exists2) {
|
|
33657
|
-
const r =
|
|
33760
|
+
const r = realpathSync34(p);
|
|
33658
33761
|
return r === p && (r === root || r.startsWith(root + sep20));
|
|
33659
33762
|
}
|
|
33660
33763
|
const up = dirname41(p);
|
|
@@ -33719,7 +33822,7 @@ ${lines2.slice(Math.max(0, near - 3), near + 6).join(`
|
|
|
33719
33822
|
try {
|
|
33720
33823
|
for (const [rel, body] of staged) {
|
|
33721
33824
|
const abs = join99(rules.repoDir, rel);
|
|
33722
|
-
|
|
33825
|
+
mkdirSync46(dirname41(abs), { recursive: true });
|
|
33723
33826
|
writeFileSync50(abs, body, "utf8");
|
|
33724
33827
|
written.push(rel);
|
|
33725
33828
|
}
|
|
@@ -33994,7 +34097,7 @@ __export(exports_implement, {
|
|
|
33994
34097
|
FOLD_PLAN_INSTRUCTION: () => FOLD_PLAN_INSTRUCTION,
|
|
33995
34098
|
ATTEMPT_BRIEF_FILE: () => ATTEMPT_BRIEF_FILE
|
|
33996
34099
|
});
|
|
33997
|
-
import { existsSync as existsSync65, mkdirSync as
|
|
34100
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync47, readFileSync as readFileSync90, rmSync as rmSync31, writeFileSync as writeFileSync51 } from "fs";
|
|
33998
34101
|
import { join as join100, relative as relative21 } from "path";
|
|
33999
34102
|
function impactedTests(ctx) {
|
|
34000
34103
|
const o = ctx.outputs();
|
|
@@ -34237,7 +34340,7 @@ var init_implement = __esm(() => {
|
|
|
34237
34340
|
|
|
34238
34341
|
`) || null, prior.intake?.assumptions, rankedRemedyEnabled() ? prior.intake?.ranked_remedy : undefined, issue);
|
|
34239
34342
|
try {
|
|
34240
|
-
|
|
34343
|
+
mkdirSync47(ctx.runDir, { recursive: true });
|
|
34241
34344
|
writeFileSync51(join100(ctx.runDir, ATTEMPT_BRIEF_FILE), fullBrief, "utf8");
|
|
34242
34345
|
} catch {}
|
|
34243
34346
|
const firstAttemptModel = attemptsK(ctx.model) > 0 ? attemptModels()[0] : undefined;
|
|
@@ -34278,7 +34381,7 @@ var init_implement = __esm(() => {
|
|
|
34278
34381
|
record: (n3, prompt, reply) => {
|
|
34279
34382
|
if (reply && n3 === 1)
|
|
34280
34383
|
patchNote = reply.split(/^FILE:/m)[0].trim();
|
|
34281
|
-
|
|
34384
|
+
mkdirSync47(ctx.runDir, { recursive: true });
|
|
34282
34385
|
writeFileSync51(join100(ctx.runDir, `implement-patch-${n3}.txt`), `${prompt}
|
|
34283
34386
|
|
|
34284
34387
|
=== REPLY ===
|
|
@@ -34440,7 +34543,9 @@ ${r.session.summary}` };
|
|
|
34440
34543
|
}
|
|
34441
34544
|
const lineRounds = [];
|
|
34442
34545
|
const proofRounds = [];
|
|
34443
|
-
|
|
34546
|
+
let proofFails = 0, lineTurns = 0;
|
|
34547
|
+
const LINE_TURNS_MAX = 2;
|
|
34548
|
+
for (let round2 = 0;proofFails < proofLoopMax() && scratch && proofRerunOn() && existsSync65(join100(scratch.dir, PROOF_SCRIPT)) && !signal.aborted && !session.killed && session.exit === 0 && !session.markers.specConflict && !session.markers.alreadyDone; round2++) {
|
|
34444
34549
|
if (!keepProofScript(scratch.dir, ctx.runDir))
|
|
34445
34550
|
break;
|
|
34446
34551
|
const pr = await rerunProof(ctx.repoDir, ctx.runDir, signal);
|
|
@@ -34453,7 +34558,7 @@ ${r.session.summary}` };
|
|
|
34453
34558
|
}
|
|
34454
34559
|
if (pr.exit === 0 && pr.failed === 0) {
|
|
34455
34560
|
const la = labelAsks(ctx.provider, prior.intake, prior.plan, ctx.repoDir);
|
|
34456
|
-
if (!la.asks.length ||
|
|
34561
|
+
if (!la.asks.length || lineTurns >= LINE_TURNS_MAX)
|
|
34457
34562
|
break;
|
|
34458
34563
|
const tree = await worktreeTree(ctx.repoDir);
|
|
34459
34564
|
if (!tree)
|
|
@@ -34466,8 +34571,11 @@ ${r.session.summary}` };
|
|
|
34466
34571
|
return [{ line: `${i + 1}. ${line2}`, reason: byRule[i].reason ?? "" }];
|
|
34467
34572
|
return lc.marks && !lc.marks.met.includes(i + 1) ? [{ line: `${i + 1}. ${line2}`, reason: `it has a passing check, but a reviewer found a gap: ${lc.reasons?.[String(i + 1)] ?? "not stated"}` }] : [];
|
|
34468
34573
|
});
|
|
34574
|
+
const lineUnmet = unmet.length;
|
|
34575
|
+
for (const f of await unusedNewFiles(ctx.repoDir, ctx.baseSha, tree))
|
|
34576
|
+
unmet.push({ line: `(not an acceptance line) ${f}`, reason: "no other file in the repository imports or names this new file, so a user cannot reach what it does. Mount it where it belongs (a page, a route, a registry, a menu) and prove that path, or remove it" });
|
|
34469
34577
|
lineRounds.push({ met: lc.marks?.met.length ?? 0, unmet: unmet.length, usd: lc.usd });
|
|
34470
|
-
ctx.emit("acceptance.round", "implement", { round: round2 + 1, met: la.asks.length - unmet.length
|
|
34578
|
+
ctx.emit("acceptance.round", "implement", { round: round2 + 1, met: la.asks.length - lineUnmet, unmet: lineUnmet, ...unmet.length > lineUnmet ? { unused_new_files: unmet.length - lineUnmet } : {} });
|
|
34471
34579
|
if (!unmet.length)
|
|
34472
34580
|
break;
|
|
34473
34581
|
const r2 = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, unmetBrief(unmet));
|
|
@@ -34475,6 +34583,7 @@ ${r.session.summary}` };
|
|
|
34475
34583
|
ids.push(r2.iterationId);
|
|
34476
34584
|
else
|
|
34477
34585
|
break;
|
|
34586
|
+
lineTurns++;
|
|
34478
34587
|
if (r2.session.summary)
|
|
34479
34588
|
session = { ...session, summary: `${session.summary ?? ""}
|
|
34480
34589
|
|
|
@@ -34491,6 +34600,7 @@ Find out why it fails when it starts from nothing. A script that passed for you
|
|
|
34491
34600
|
ids.push(r.iterationId);
|
|
34492
34601
|
else
|
|
34493
34602
|
break;
|
|
34603
|
+
proofFails++;
|
|
34494
34604
|
if (r.session.summary)
|
|
34495
34605
|
session = { ...session, summary: `${session.summary ?? ""}
|
|
34496
34606
|
|
|
@@ -34614,7 +34724,7 @@ ${session.summary.slice(-4000)}` : session.summary.slice(-16000) } : {},
|
|
|
34614
34724
|
if (exit !== "error")
|
|
34615
34725
|
return { status: "completed", data };
|
|
34616
34726
|
const stderrTail = session.stderrTail ?? "";
|
|
34617
|
-
|
|
34727
|
+
mkdirSync47(ctx.runDir, { recursive: true });
|
|
34618
34728
|
const stderrPath = join100(ctx.runDir, `${iterationId}.stderr.log`);
|
|
34619
34729
|
writeFileSync51(stderrPath, stderrTail, "utf8");
|
|
34620
34730
|
data.stderr_path = stderrPath;
|
|
@@ -34690,7 +34800,7 @@ var init_run_control = __esm(() => {
|
|
|
34690
34800
|
});
|
|
34691
34801
|
|
|
34692
34802
|
// ../../loki-ts/src/providers/provider_guard.ts
|
|
34693
|
-
import { copyFileSync as copyFileSync6, existsSync as existsSync67, lstatSync as lstatSync27, mkdirSync as
|
|
34803
|
+
import { copyFileSync as copyFileSync6, existsSync as existsSync67, lstatSync as lstatSync27, mkdirSync as mkdirSync48, readFileSync as readFileSync92, readdirSync as readdirSync36, readlinkSync as readlinkSync4, realpathSync as realpathSync35, rmSync as rmSync32 } from "fs";
|
|
34694
34804
|
import { dirname as dirname42, isAbsolute as isAbsolute16, join as join102, relative as relative22, resolve as resolve24 } from "path";
|
|
34695
34805
|
function providerSandboxFlags(provider) {
|
|
34696
34806
|
return [];
|
|
@@ -34701,7 +34811,7 @@ function beginGuard(cwd, backupRoot) {
|
|
|
34701
34811
|
return null;
|
|
34702
34812
|
const gd = gitDir(cwd);
|
|
34703
34813
|
const backupDir = join102(backupRoot, "guard-backup");
|
|
34704
|
-
|
|
34814
|
+
mkdirSync48(backupDir, { recursive: true });
|
|
34705
34815
|
if (existsSync67(join102(gd, "config")))
|
|
34706
34816
|
copyFileSync6(join102(gd, "config"), join102(backupDir, "config"));
|
|
34707
34817
|
const tracked = git6(cwd, ["ls-files"]).split(`
|
|
@@ -34715,7 +34825,7 @@ function escapesProject(root, linkPath) {
|
|
|
34715
34825
|
try {
|
|
34716
34826
|
const target = readlinkSync4(linkPath);
|
|
34717
34827
|
const abs = isAbsolute16(target) ? target : resolve24(dirname42(linkPath), target);
|
|
34718
|
-
const rel = relative22(
|
|
34828
|
+
const rel = relative22(realpathSync35(root), existsSync67(abs) ? realpathSync35(abs) : abs);
|
|
34719
34829
|
return rel.startsWith("..") || isAbsolute16(rel);
|
|
34720
34830
|
} catch {
|
|
34721
34831
|
return false;
|
|
@@ -34864,7 +34974,7 @@ var init_provider_guard = __esm(() => {
|
|
|
34864
34974
|
});
|
|
34865
34975
|
|
|
34866
34976
|
// ../../loki-ts/src/e10ext/budget_cap.ts
|
|
34867
|
-
import { appendFileSync as appendFileSync10, existsSync as existsSync68, mkdirSync as
|
|
34977
|
+
import { appendFileSync as appendFileSync10, existsSync as existsSync68, mkdirSync as mkdirSync49, readdirSync as readdirSync37, readFileSync as readFileSync93, writeFileSync as writeFileSync53 } from "fs";
|
|
34868
34978
|
import { join as join103, resolve as resolve25 } from "path";
|
|
34869
34979
|
function hasApiKey(env) {
|
|
34870
34980
|
return ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "OPENROUTER_API_KEY", "LOKI_MODEL_API_KEY"].some((k) => (env[k] ?? "") !== "");
|
|
@@ -34908,7 +35018,7 @@ function groupEnv(env, capUsd, repoDir) {
|
|
|
34908
35018
|
if (repoDir && !out2.LOKI_BUDGET_LEDGER) {
|
|
34909
35019
|
try {
|
|
34910
35020
|
const d = join103(resolve25(repoDir), ".loki", "runs");
|
|
34911
|
-
|
|
35021
|
+
mkdirSync49(d, { recursive: true });
|
|
34912
35022
|
out2.LOKI_BUDGET_LEDGER = join103(d, `group-${process.pid}-${Date.now()}.ledger`);
|
|
34913
35023
|
} catch (e) {
|
|
34914
35024
|
out2.LOKI_BUDGET_LEDGER = join103(resolve25(repoDir), ".loki", "runs", "unusable", "group.ledger");
|
|
@@ -35036,7 +35146,7 @@ function childBudgetLimit(remaining) {
|
|
|
35036
35146
|
function writeBudgetStop(repoDir, runId, rec2) {
|
|
35037
35147
|
try {
|
|
35038
35148
|
const d = join103(repoDir, ".loki", "runs", runId);
|
|
35039
|
-
|
|
35149
|
+
mkdirSync49(d, { recursive: true });
|
|
35040
35150
|
writeFileSync53(join103(d, "budget.json"), JSON.stringify({ ...rec2, outcome: "budget_stopped" }) + `
|
|
35041
35151
|
`);
|
|
35042
35152
|
} catch {}
|
|
@@ -35105,7 +35215,7 @@ __export(exports_machine, {
|
|
|
35105
35215
|
FLOW: () => FLOW,
|
|
35106
35216
|
BASE_RED_CONFLICT: () => BASE_RED_CONFLICT
|
|
35107
35217
|
});
|
|
35108
|
-
import { existsSync as existsSync69, mkdirSync as
|
|
35218
|
+
import { existsSync as existsSync69, mkdirSync as mkdirSync50, mkdtempSync as mkdtempSync15, rmSync as rmSync33, writeFileSync as writeFileSync54 } from "fs";
|
|
35109
35219
|
import { tmpdir as tmpdir19 } from "os";
|
|
35110
35220
|
import { isAbsolute as isAbsolute17, join as join104, relative as relative23 } from "path";
|
|
35111
35221
|
async function optional(path) {
|
|
@@ -35486,7 +35596,7 @@ ${wallTail}` : brief0;
|
|
|
35486
35596
|
else
|
|
35487
35597
|
try {
|
|
35488
35598
|
const w = a;
|
|
35489
|
-
|
|
35599
|
+
mkdirSync50(join104(base, relative23(ctx.repoDir, w.targetDir)), { recursive: true });
|
|
35490
35600
|
for (const [n3, c] of w.contents)
|
|
35491
35601
|
writeFileSync54(join104(base, relative23(ctx.repoDir, w.targetDir), n3), c, "utf8");
|
|
35492
35602
|
r = j.split.install(sctx, a, base);
|
|
@@ -35849,7 +35959,7 @@ __export(exports_prove, {
|
|
|
35849
35959
|
LIST_S: () => LIST_S,
|
|
35850
35960
|
ALSO_ON_BASE: () => ALSO_ON_BASE
|
|
35851
35961
|
});
|
|
35852
|
-
import { existsSync as existsSync70, mkdirSync as
|
|
35962
|
+
import { existsSync as existsSync70, mkdirSync as mkdirSync51, mkdtempSync as mkdtempSync16, readdirSync as readdirSync38, readFileSync as readFileSync94, readlinkSync as readlinkSync5, realpathSync as realpathSync36, rmSync as rmSync34, writeFileSync as writeFileSync55 } from "fs";
|
|
35853
35963
|
import { tmpdir as tmpdir20 } from "os";
|
|
35854
35964
|
import { join as join105, relative as relative24 } from "path";
|
|
35855
35965
|
function proverBrief(issue, asks2, dir, card, scriptS) {
|
|
@@ -36014,7 +36124,7 @@ function cancelProve() {
|
|
|
36014
36124
|
}
|
|
36015
36125
|
async function runPass(root, dir, out2, ids, signal, o = {}) {
|
|
36016
36126
|
rmSync34(out2, { recursive: true, force: true });
|
|
36017
|
-
|
|
36127
|
+
mkdirSync51(out2, { recursive: true });
|
|
36018
36128
|
for (const f of ["endpoints", "pids"])
|
|
36019
36129
|
rmSync34(join105(dir, f), { force: true });
|
|
36020
36130
|
const scratch = createSessionScratch(join105(dir, "..")), tmp = scratch.dir, since = Date.now(), scriptS = o.scriptS ?? scriptLimitS(), passS = o.passS ?? 480, teardownS = o.teardownS ?? TEARDOWN_S;
|
|
@@ -36178,7 +36288,7 @@ var off2 = (v) => /^(0|off|false|no)$/i.test((v ?? "").trim()), num6 = (v, d) =>
|
|
|
36178
36288
|
return m ? Number(m[1]) : null;
|
|
36179
36289
|
}, real3 = (p) => {
|
|
36180
36290
|
try {
|
|
36181
|
-
return
|
|
36291
|
+
return realpathSync36(p);
|
|
36182
36292
|
} catch {
|
|
36183
36293
|
return p;
|
|
36184
36294
|
}
|
|
@@ -36281,7 +36391,7 @@ var init_prove = __esm(() => {
|
|
|
36281
36391
|
ctx.emit("prove.started", "prove", { dir: dirRel, budget_s: budgetS, reused: fixed !== null });
|
|
36282
36392
|
if (!fixed) {
|
|
36283
36393
|
rmSync34(dir, { recursive: true, force: true });
|
|
36284
|
-
|
|
36394
|
+
mkdirSync51(dir, { recursive: true });
|
|
36285
36395
|
let accepted = null, rejected = [];
|
|
36286
36396
|
for (let attempt = 1;attempt <= 2 && !signal.aborted && accepted === null; attempt++) {
|
|
36287
36397
|
const out2 = join105(dir, `asks-list-${attempt}.json`), cwd = mkdtempSync16(join105(tmpdir20(), "loki-prove-list-")), id = `${ctx.runId}-prove-ls${attempt}`;
|
|
@@ -36581,7 +36691,7 @@ var init_reviewer_body = __esm(() => {
|
|
|
36581
36691
|
// ../../loki-ts/src/features/visual_evidence.ts
|
|
36582
36692
|
import { spawn as spawn9 } from "child_process";
|
|
36583
36693
|
import { createHash as createHash23, randomBytes as randomBytes8 } from "crypto";
|
|
36584
|
-
import { existsSync as existsSync71, lstatSync as lstatSync28, mkdirSync as
|
|
36694
|
+
import { existsSync as existsSync71, lstatSync as lstatSync28, mkdirSync as mkdirSync52, readdirSync as readdirSync39, readFileSync as readFileSync96, writeFileSync as writeFileSync56 } from "fs";
|
|
36585
36695
|
import { createServer } from "net";
|
|
36586
36696
|
import { dirname as dirname45, isAbsolute as isAbsolute18, join as join106, normalize as normalize6, relative as relative25, sep as sep21 } from "path";
|
|
36587
36697
|
function routeFor(file) {
|
|
@@ -36675,7 +36785,7 @@ async function recordE2eMedia(repoDir, runDir, relDir, base, routes, ms, signal)
|
|
|
36675
36785
|
return { rels: [], skipped: "playwright e2e video and trace skipped: @playwright/test is not installed in the repo" };
|
|
36676
36786
|
try {
|
|
36677
36787
|
const dir = join106(runDir, relDir, "e2e");
|
|
36678
|
-
|
|
36788
|
+
mkdirSync52(dir, { recursive: true });
|
|
36679
36789
|
writeFileSync56(join106(dir, "walk.spec.cjs"), e2eSpecSource(pkg, base, routes));
|
|
36680
36790
|
writeFileSync56(join106(dir, "playwright.config.cjs"), `module.exports = { testDir: ".", testMatch: "walk.spec.cjs", outputDir: "./out", reporter: "null", use: { video: "on", trace: "on" } };
|
|
36681
36791
|
`);
|
|
@@ -36815,10 +36925,10 @@ async function captureVisualEvidence(repoDir, runDir, changed, opts = {}) {
|
|
|
36815
36925
|
const evRoot = join106(runDir, "evidence");
|
|
36816
36926
|
if (isSymlink(evRoot))
|
|
36817
36927
|
return skip2("evidence dir is a symlink");
|
|
36818
|
-
|
|
36928
|
+
mkdirSync52(evRoot, { recursive: true });
|
|
36819
36929
|
if (pages.length > 0) {
|
|
36820
36930
|
const rel0 = join106("evidence", randomBytes8(6).toString("hex"));
|
|
36821
|
-
|
|
36931
|
+
mkdirSync52(join106(runDir, rel0));
|
|
36822
36932
|
const rels = [];
|
|
36823
36933
|
for (const route of [...new Set(pages.map(routeFor))].slice(0, opts.maxRoutes ?? MAX_ROUTES)) {
|
|
36824
36934
|
if (aborted() || left() <= 0)
|
|
@@ -36851,7 +36961,7 @@ async function captureVisualEvidence(repoDir, runDir, changed, opts = {}) {
|
|
|
36851
36961
|
if (aborted())
|
|
36852
36962
|
return skip2("aborted");
|
|
36853
36963
|
const hdir = join106(evRoot, randomBytes8(6).toString("hex"));
|
|
36854
|
-
|
|
36964
|
+
mkdirSync52(hdir);
|
|
36855
36965
|
writeFileSync56(join106(hdir, "http.json"), JSON.stringify(rows, null, 2) + `
|
|
36856
36966
|
`);
|
|
36857
36967
|
return { screens: [], http: true, skipped: null };
|
|
@@ -36939,7 +37049,7 @@ var init_visual_evidence = __esm(() => {
|
|
|
36939
37049
|
});
|
|
36940
37050
|
|
|
36941
37051
|
// ../../loki-ts/src/integrations/before_after.ts
|
|
36942
|
-
import { existsSync as existsSync72, mkdirSync as
|
|
37052
|
+
import { existsSync as existsSync72, mkdirSync as mkdirSync53, symlinkSync as symlinkSync4 } from "fs";
|
|
36943
37053
|
import { join as join107 } from "path";
|
|
36944
37054
|
function hasDevCommand(repoDir) {
|
|
36945
37055
|
try {
|
|
@@ -36969,14 +37079,14 @@ async function captureBeforeAfter(repoDir, runDir, changed, baseRef, o = {}) {
|
|
|
36969
37079
|
let added = false;
|
|
36970
37080
|
const cap = (tree, side) => {
|
|
36971
37081
|
const sub = join107(base, side);
|
|
36972
|
-
|
|
37082
|
+
mkdirSync53(sub, { recursive: true });
|
|
36973
37083
|
return deps.capture(tree, sub, changed, { env, budgetMs: bootMs, signal: o.signal, onServer: (p) => {
|
|
36974
37084
|
pgids.push(p);
|
|
36975
37085
|
} });
|
|
36976
37086
|
};
|
|
36977
37087
|
const rel = (side, s) => s.filter((x) => /\.png$/.test(x.path)).map((x) => ({ path: join107("before_after", side, x.path), sha256: x.sha256 }));
|
|
36978
37088
|
try {
|
|
36979
|
-
|
|
37089
|
+
mkdirSync53(base, { recursive: true });
|
|
36980
37090
|
try {
|
|
36981
37091
|
deps.worktreeAdd(repoDir, wt, baseRef);
|
|
36982
37092
|
added = true;
|
|
@@ -37223,7 +37333,7 @@ var init_receipt_dsse = __esm(() => {
|
|
|
37223
37333
|
|
|
37224
37334
|
// ../../loki-ts/src/util/receipt_bundle.ts
|
|
37225
37335
|
import { createPublicKey as createPublicKey4 } from "crypto";
|
|
37226
|
-
import { cpSync as cpSync4, copyFileSync as copyFileSync7, existsSync as existsSync73, mkdirSync as
|
|
37336
|
+
import { cpSync as cpSync4, copyFileSync as copyFileSync7, existsSync as existsSync73, mkdirSync as mkdirSync54, readdirSync as readdirSync40, readFileSync as readFileSync98, renameSync as renameSync21, rmSync as rmSync35, writeFileSync as writeFileSync57 } from "fs";
|
|
37227
37337
|
import { homedir as homedir11 } from "os";
|
|
37228
37338
|
import { basename as basename32, dirname as dirname46, join as join108, normalize as normalize7 } from "path";
|
|
37229
37339
|
function publicJwk(pub) {
|
|
@@ -37356,13 +37466,13 @@ exit 0
|
|
|
37356
37466
|
|
|
37357
37467
|
// ../../loki-ts/src/util/outbox.ts
|
|
37358
37468
|
import { createHash as createHash24 } from "crypto";
|
|
37359
|
-
import { existsSync as existsSync74, mkdirSync as
|
|
37469
|
+
import { existsSync as existsSync74, mkdirSync as mkdirSync55, readFileSync as readFileSync99, renameSync as renameSync22 } from "fs";
|
|
37360
37470
|
import { join as join109 } from "path";
|
|
37361
37471
|
function idempotencyKey(kind, runId, discriminator) {
|
|
37362
37472
|
return createHash24("sha256").update(`${kind}\x00${runId}\x00${discriminator}`).digest("hex").slice(0, 32);
|
|
37363
37473
|
}
|
|
37364
37474
|
function runOnce2(a) {
|
|
37365
|
-
|
|
37475
|
+
mkdirSync55(a.dir, { recursive: true });
|
|
37366
37476
|
const file = join109(a.dir, `outbox-${a.key}.json`);
|
|
37367
37477
|
let rec2 = null;
|
|
37368
37478
|
if (existsSync74(file)) {
|
|
@@ -37507,7 +37617,7 @@ __export(exports_pr, {
|
|
|
37507
37617
|
DEFAULT_PUSH_GITLAB_SH: () => DEFAULT_PUSH_GITLAB_SH
|
|
37508
37618
|
});
|
|
37509
37619
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
37510
|
-
import { mkdirSync as
|
|
37620
|
+
import { mkdirSync as mkdirSync56, readFileSync as readFileSync100, writeFileSync as writeFileSync58 } from "fs";
|
|
37511
37621
|
import { join as join110 } from "path";
|
|
37512
37622
|
function resolvePrAuthor(repoDir, environ = process.env) {
|
|
37513
37623
|
let v = (environ.LOKI_PR_AUTHOR ?? "").trim() || null;
|
|
@@ -37725,7 +37835,7 @@ async function runPr(ctx, signal, opts = {}) {
|
|
|
37725
37835
|
const base = stackBase(process.env);
|
|
37726
37836
|
if (base === null)
|
|
37727
37837
|
return { status: "failed", data: {}, reason: "LOKI_PR_BASE is not a valid branch name: refusing to push" };
|
|
37728
|
-
|
|
37838
|
+
mkdirSync56(ctx.runDir, { recursive: true });
|
|
37729
37839
|
const link = issueLink(ctx.runDir, verdict);
|
|
37730
37840
|
const bodyFile = join110(ctx.runDir, "pr-body.md");
|
|
37731
37841
|
const beforeAfter = await beforeAfterBlock(ctx.repoDir, ctx.runDir, (ctx.outputs().verify?.["changed_files"] ?? []).map(String), ctx.baseSha, { signal });
|
|
@@ -37888,7 +37998,7 @@ __export(exports_pr_lessons, {
|
|
|
37888
37998
|
EXAMPLE_CAP: () => EXAMPLE_CAP,
|
|
37889
37999
|
DEMOTE_AFTER: () => DEMOTE_AFTER
|
|
37890
38000
|
});
|
|
37891
|
-
import { appendFileSync as appendFileSync11, existsSync as existsSync75, mkdirSync as
|
|
38001
|
+
import { appendFileSync as appendFileSync11, existsSync as existsSync75, mkdirSync as mkdirSync57, mkdtempSync as mkdtempSync17, readFileSync as readFileSync101, rmSync as rmSync36, writeFileSync as writeFileSync59 } from "fs";
|
|
37892
38002
|
import { homedir as homedir12, tmpdir as tmpdir21 } from "os";
|
|
37893
38003
|
import { dirname as dirname47, join as join111 } from "path";
|
|
37894
38004
|
import { createHash as createHash25 } from "crypto";
|
|
@@ -37906,7 +38016,7 @@ function loadLessons(repoDir) {
|
|
|
37906
38016
|
}
|
|
37907
38017
|
function save2(repoDir, lessons) {
|
|
37908
38018
|
const p = lessonsPath(repoDir);
|
|
37909
|
-
|
|
38019
|
+
mkdirSync57(dirname47(p), { recursive: true });
|
|
37910
38020
|
atomicWriteJson(p, { version: 2, lessons });
|
|
37911
38021
|
}
|
|
37912
38022
|
function loadPromoted() {
|
|
@@ -37918,7 +38028,7 @@ function loadPromoted() {
|
|
|
37918
38028
|
}
|
|
37919
38029
|
}
|
|
37920
38030
|
function savePromoted(lessons) {
|
|
37921
|
-
|
|
38031
|
+
mkdirSync57(dirname47(promotedPath()), { recursive: true });
|
|
37922
38032
|
atomicWriteJson(promotedPath(), { version: 2, lessons });
|
|
37923
38033
|
}
|
|
37924
38034
|
function promoteLesson(repoDir, id) {
|
|
@@ -38252,7 +38362,7 @@ async function replayKnownVerdict(repoDir, task, o) {
|
|
|
38252
38362
|
return null;
|
|
38253
38363
|
const code = r.verdict === "SPEC_CONFLICT" ? 4 : 0;
|
|
38254
38364
|
const dir = join111(repoDir, ".loki", "memory");
|
|
38255
|
-
|
|
38365
|
+
mkdirSync57(dir, { recursive: true });
|
|
38256
38366
|
appendFileSync11(join111(dir, "replays.jsonl"), JSON.stringify({ v: 1, seq: 0, ts: new Date().toISOString(), run: r.runId, type: "run.replayed", stage: null, data: { prior_run_id: r.runId, receipt_sha256: r.receiptSha256, verdict: r.verdict, prior_runs: r.runs, ...key } }) + `
|
|
38257
38367
|
`);
|
|
38258
38368
|
if (o.json) {
|
|
@@ -39015,7 +39125,7 @@ __export(exports_contract, {
|
|
|
39015
39125
|
MAX_CONTRACT_BYTES: () => MAX_CONTRACT_BYTES,
|
|
39016
39126
|
CONSTRAINT_KINDS: () => CONSTRAINT_KINDS
|
|
39017
39127
|
});
|
|
39018
|
-
import { existsSync as existsSync76, lstatSync as lstatSync29, mkdirSync as
|
|
39128
|
+
import { existsSync as existsSync76, lstatSync as lstatSync29, mkdirSync as mkdirSync58, readFileSync as readFileSync102, rmSync as rmSync37, writeFileSync as writeFileSync60 } from "fs";
|
|
39019
39129
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
39020
39130
|
import { dirname as dirname48, join as join112 } from "path";
|
|
39021
39131
|
import { createHash as createHash26 } from "crypto";
|
|
@@ -39092,7 +39202,7 @@ function freezeGroupContract(repoDir, groupId, units, contract) {
|
|
|
39092
39202
|
return { ok: false, reason: `NOT PROVEN: group contract has ${a.orphans.length} criterion owned by no unit: ${a.orphans.map((o) => `${sanitizeCriterion(o.id)} ${sanitizeCriterion(o.text)}`).join("; ")}`, orphans: a.orphans };
|
|
39093
39203
|
const gc = { group: groupId, units: a.units, orphans: [] };
|
|
39094
39204
|
const path = groupContractPath(repoDir, groupId);
|
|
39095
|
-
|
|
39205
|
+
mkdirSync58(dirname48(path), { recursive: true });
|
|
39096
39206
|
atomicWriteJson(path, gc);
|
|
39097
39207
|
return { ok: true, path, contract: gc };
|
|
39098
39208
|
}
|
|
@@ -39239,7 +39349,7 @@ function main(args) {
|
|
|
39239
39349
|
}
|
|
39240
39350
|
const contract = parseContract(readFileSync102(file, "utf8"), file);
|
|
39241
39351
|
const out2 = contractPath(repoRoot(process.cwd()));
|
|
39242
|
-
|
|
39352
|
+
mkdirSync58(dirname48(out2), { recursive: true });
|
|
39243
39353
|
writeFileSync60(out2, JSON.stringify(contract, null, 2) + `
|
|
39244
39354
|
`);
|
|
39245
39355
|
process.stdout.write(renderContract(contract));
|
|
@@ -39455,7 +39565,7 @@ var init_contract = __esm(() => {
|
|
|
39455
39565
|
|
|
39456
39566
|
// ../../loki-ts/src/features/speed/seal_group.ts
|
|
39457
39567
|
import { createHash as createHash27 } from "crypto";
|
|
39458
|
-
import { existsSync as existsSync77, mkdirSync as
|
|
39568
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync59, readdirSync as readdirSync41, readFileSync as readFileSync103, renameSync as renameSync23, statSync as statSync32, writeFileSync as writeFileSync61 } from "fs";
|
|
39459
39569
|
import { dirname as dirname49, join as join113 } from "path";
|
|
39460
39570
|
function sealGroup(runDir, rh) {
|
|
39461
39571
|
const manifestPath = join113(runDir, "group", "manifest.json");
|
|
@@ -39586,7 +39696,7 @@ function composeGroupReceipt(groupDir, rh, o) {
|
|
|
39586
39696
|
const hash = rh(body), sig = signReceipt(gid, hash);
|
|
39587
39697
|
const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
39588
39698
|
const path = join113(groupDir, "receipt.json"), tmp = `${path}.${process.pid}.tmp`;
|
|
39589
|
-
|
|
39699
|
+
mkdirSync59(groupDir, { recursive: true });
|
|
39590
39700
|
writeFileSync61(tmp, JSON.stringify(receipt, null, 2) + `
|
|
39591
39701
|
`);
|
|
39592
39702
|
renameSync23(tmp, path);
|
|
@@ -39905,7 +40015,7 @@ __export(exports_seal, {
|
|
|
39905
40015
|
});
|
|
39906
40016
|
import { createHash as createHash28 } from "crypto";
|
|
39907
40017
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
39908
|
-
import { existsSync as existsSync79, readdirSync as readdirSync42, mkdirSync as
|
|
40018
|
+
import { existsSync as existsSync79, readdirSync as readdirSync42, mkdirSync as mkdirSync60, readFileSync as readFileSync105, rmSync as rmSync38 } from "fs";
|
|
39909
40019
|
import { basename as basename34, isAbsolute as isAbsolute19, join as join115, relative as relative26 } from "path";
|
|
39910
40020
|
function missingLintChecks(vraw, env = process.env) {
|
|
39911
40021
|
if (/^(0|off|false|no)$/i.test((env["LOKI_E10_LINT_MISSING_DISCLOSE"] ?? "").trim()))
|
|
@@ -40404,7 +40514,9 @@ var init_seal = __esm(() => {
|
|
|
40404
40514
|
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);
|
|
40405
40515
|
const allLinesMet = !!issueSt && (byRule ? true : !!lineCheck && !lineCheck.not_reviewed) && notAddressedNotes(issueSt).length === 0, unfinished = unfinishedNotes(o.implement);
|
|
40406
40516
|
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))`] : [];
|
|
40407
|
-
const
|
|
40517
|
+
const twoReaders = (xr?.notes ?? []).filter(isUnmetNote).filter((n3) => issueAsks.some((line2, i) => advisory?.[i]?.status === "unmet" && n3.toLowerCase().includes(line2.toLowerCase().slice(0, 60)))).map((n3) => `${n3} (the acceptance check also reads this line as not delivered: two readers agree, so the count does not carry it)`);
|
|
40518
|
+
const unusedNotes = issueAsks.length ? (await unusedNewFiles(ctx.repoDir, ctx.baseSha, head)).map(unusedNewFileNote) : [];
|
|
40519
|
+
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;
|
|
40408
40520
|
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]);
|
|
40409
40521
|
const wp = verdict3 === "VERIFIED" && commitWallEnabled() ? wpAll : { files: [], notes: wpAll.notes }, wallKept = verdict3 === "VERIFIED" && !commitWallEnabled() ? wpAll.files : [];
|
|
40410
40522
|
const wallPub0 = wp.files.length > 0 ? await publishWall(g(ctx), ctx.runId, ctx.repoDir, wp.files, wallDone) : false;
|
|
@@ -40423,6 +40535,8 @@ var init_seal = __esm(() => {
|
|
|
40423
40535
|
if (sites.length)
|
|
40424
40536
|
notProven2.add(`completed by rule, no model (LOKI_E10_SYSEDIT; a failing check now passes): ${sites.join(", ")}`);
|
|
40425
40537
|
}
|
|
40538
|
+
for (const n3 of unusedNotes)
|
|
40539
|
+
notProven2.add(n3);
|
|
40426
40540
|
if (allLinesMet)
|
|
40427
40541
|
for (const n3 of unfinished)
|
|
40428
40542
|
notProven2.add(`${n3} (outside the issue's acceptance lines, every one of which is met; disclosed, does not cap)`);
|
|
@@ -40682,7 +40796,7 @@ var init_seal = __esm(() => {
|
|
|
40682
40796
|
hash = receiptSha256(body);
|
|
40683
40797
|
}
|
|
40684
40798
|
const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
40685
|
-
|
|
40799
|
+
mkdirSync60(ctx.runDir, { recursive: true });
|
|
40686
40800
|
const path = join115(ctx.runDir, "receipt.json");
|
|
40687
40801
|
atomicWriteText(path, JSON.stringify(receipt, null, 2) + `
|
|
40688
40802
|
`);
|
|
@@ -40713,7 +40827,7 @@ var init_seal = __esm(() => {
|
|
|
40713
40827
|
|
|
40714
40828
|
// ../../loki-ts/src/util/seal_drift.ts
|
|
40715
40829
|
import { createHash as createHash29, createPublicKey as createPublicKey5, sign as sign3, verify as verify4 } from "crypto";
|
|
40716
|
-
import { existsSync as existsSync80, lstatSync as lstatSync30, readFileSync as readFileSync106, realpathSync as
|
|
40830
|
+
import { existsSync as existsSync80, lstatSync as lstatSync30, readFileSync as readFileSync106, realpathSync as realpathSync38 } from "fs";
|
|
40717
40831
|
import { basename as basename35, dirname as dirname51, join as join116, relative as relative27 } from "path";
|
|
40718
40832
|
function tornTail(raw2) {
|
|
40719
40833
|
if (raw2 === "" || raw2.endsWith(`
|
|
@@ -40842,7 +40956,7 @@ function onlyWallPublish(repo, r, sealedHead, head) {
|
|
|
40842
40956
|
try {
|
|
40843
40957
|
const real4 = (x) => {
|
|
40844
40958
|
try {
|
|
40845
|
-
return
|
|
40959
|
+
return realpathSync38(x);
|
|
40846
40960
|
} catch {
|
|
40847
40961
|
return x;
|
|
40848
40962
|
}
|
|
@@ -40884,7 +40998,7 @@ function claimsWallPublish(repo, r, sealedHead, head) {
|
|
|
40884
40998
|
function sealDrift(given, r, env = process.env) {
|
|
40885
40999
|
let receiptPath = given;
|
|
40886
41000
|
try {
|
|
40887
|
-
receiptPath = join116(
|
|
41001
|
+
receiptPath = join116(realpathSync38(dirname51(given)), basename35(given));
|
|
40888
41002
|
} catch {}
|
|
40889
41003
|
const fab = fabricatedPass(receiptPath, r);
|
|
40890
41004
|
if (fab)
|
|
@@ -42993,7 +43107,7 @@ __export(exports_doctor_fix, {
|
|
|
42993
43107
|
runDoctorFix: () => runDoctorFix,
|
|
42994
43108
|
applyDoctorFixes: () => applyDoctorFixes
|
|
42995
43109
|
});
|
|
42996
|
-
import { copyFileSync as copyFileSync8, existsSync as existsSync82, mkdirSync as
|
|
43110
|
+
import { copyFileSync as copyFileSync8, existsSync as existsSync82, mkdirSync as mkdirSync61, readFileSync as readFileSync109, readSync as readSync13, writeFileSync as writeFileSync64 } from "fs";
|
|
42997
43111
|
import { homedir as homedir13 } from "os";
|
|
42998
43112
|
import { join as join119 } from "path";
|
|
42999
43113
|
import { spawnSync as spawnSync15 } from "child_process";
|
|
@@ -43040,7 +43154,7 @@ function applyDoctorFixes(cwd = process.cwd(), home = homedir13(), deps = {}) {
|
|
|
43040
43154
|
for (const dir of [join119(home, ".loki"), join119(home, ".config", "loki-mode"), join119(cwd, ".loki")]) {
|
|
43041
43155
|
if (!existsSync82(dir)) {
|
|
43042
43156
|
try {
|
|
43043
|
-
|
|
43157
|
+
mkdirSync61(dir, { recursive: true });
|
|
43044
43158
|
applied.push(`created ${dir}`);
|
|
43045
43159
|
} catch (e) {
|
|
43046
43160
|
manual.push(`mkdir -p ${dir} (${e.message})`);
|
|
@@ -43052,7 +43166,7 @@ function applyDoctorFixes(cwd = process.cwd(), home = homedir13(), deps = {}) {
|
|
|
43052
43166
|
const cfgFile = join119(cfgDir, "settings.json");
|
|
43053
43167
|
if (!existsSync82(cfgFile)) {
|
|
43054
43168
|
try {
|
|
43055
|
-
|
|
43169
|
+
mkdirSync61(cfgDir, { recursive: true });
|
|
43056
43170
|
writeFileSync64(cfgFile, JSON.stringify({ provider: seedProvider }, null, 2) + `
|
|
43057
43171
|
`);
|
|
43058
43172
|
applied.push(`wrote default config ${cfgFile} (provider=${seedProvider})`);
|
|
@@ -43218,7 +43332,7 @@ __export(exports_doctor, {
|
|
|
43218
43332
|
CLAUDE_LOGIN_TTL_MS: () => CLAUDE_LOGIN_TTL_MS,
|
|
43219
43333
|
AUTH_PROVIDERS: () => AUTH_PROVIDERS
|
|
43220
43334
|
});
|
|
43221
|
-
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync65, mkdirSync as
|
|
43335
|
+
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync65, mkdirSync as mkdirSync62, accessSync as accessSync3, constants as fsConstants3, existsSync as existsSync83, lstatSync as lstatSync31, readdirSync as readdirSync44, readFileSync as readFileSync110, readlinkSync as readlinkSync6, realpathSync as realpathSync39, statSync as statSync36, statfsSync } from "fs";
|
|
43222
43336
|
import { spawnSync as spawnSync16 } from "child_process";
|
|
43223
43337
|
import { homedir as homedir14, tmpdir as tmpdir22 } from "os";
|
|
43224
43338
|
import { basename as basename36, join as join120, resolve as resolve28 } from "path";
|
|
@@ -44020,7 +44134,7 @@ function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
|
|
|
44020
44134
|
li = claudeAuthStatusLoggedIn(cli, env);
|
|
44021
44135
|
if (li === "yes") {
|
|
44022
44136
|
try {
|
|
44023
|
-
|
|
44137
|
+
mkdirSync62(join120(file, ".."), { recursive: true });
|
|
44024
44138
|
writeFileSync65(file, JSON.stringify({ cli, at: now2 }));
|
|
44025
44139
|
} catch {}
|
|
44026
44140
|
}
|
|
@@ -44038,7 +44152,7 @@ async function ghAuthProbeCached(env, probe, now2 = Date.now()) {
|
|
|
44038
44152
|
const ok = await probe();
|
|
44039
44153
|
if (ok) {
|
|
44040
44154
|
try {
|
|
44041
|
-
|
|
44155
|
+
mkdirSync62(join120(file, ".."), { recursive: true });
|
|
44042
44156
|
writeFileSync65(file, JSON.stringify({ gh, at: now2 }));
|
|
44043
44157
|
} catch {}
|
|
44044
44158
|
}
|
|
@@ -44690,7 +44804,7 @@ async function runText(deps = {}) {
|
|
|
44690
44804
|
{
|
|
44691
44805
|
const resolveReal = (p) => {
|
|
44692
44806
|
try {
|
|
44693
|
-
return
|
|
44807
|
+
return realpathSync39(p);
|
|
44694
44808
|
} catch {
|
|
44695
44809
|
return p;
|
|
44696
44810
|
}
|
|
@@ -44921,7 +45035,7 @@ async function runDoctor2(argv, deps = {}) {
|
|
|
44921
45035
|
}
|
|
44922
45036
|
try {
|
|
44923
45037
|
const dir = join120(process.cwd(), ".loki", "state");
|
|
44924
|
-
|
|
45038
|
+
mkdirSync62(dir, { recursive: true });
|
|
44925
45039
|
const checks = rep.paths.flatMap((x) => x.items).map((i) => ({ id: i.id, level: i.level, status: i.status }));
|
|
44926
45040
|
appendFileSync12(join120(dir, "readiness.jsonl"), JSON.stringify({ ts: new Date().toISOString(), checks, pass: ready, score: withReadiness?.readiness?.score ?? null, roundTrip: rt }) + `
|
|
44927
45041
|
`);
|
|
@@ -45099,7 +45213,7 @@ __export(exports_preflight, {
|
|
|
45099
45213
|
PreflightError: () => PreflightError,
|
|
45100
45214
|
CLI_ENV_VAR: () => CLI_ENV_VAR
|
|
45101
45215
|
});
|
|
45102
|
-
import { accessSync as accessSync4, constants as fsc2, mkdirSync as
|
|
45216
|
+
import { accessSync as accessSync4, constants as fsc2, mkdirSync as mkdirSync63, statfsSync as statfsSync2, writeFileSync as writeFileSync66 } from "fs";
|
|
45103
45217
|
import { join as join122 } from "path";
|
|
45104
45218
|
async function sh3(argv, opts) {
|
|
45105
45219
|
try {
|
|
@@ -45190,7 +45304,7 @@ async function checkPreflight(o) {
|
|
|
45190
45304
|
}
|
|
45191
45305
|
if (o.runDir && hits.every(([b]) => b === "not_logged_in")) {
|
|
45192
45306
|
try {
|
|
45193
|
-
|
|
45307
|
+
mkdirSync63(o.runDir, { recursive: true });
|
|
45194
45308
|
writeFileSync66(join122(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
|
|
45195
45309
|
`);
|
|
45196
45310
|
} catch {}
|
|
@@ -45354,7 +45468,7 @@ var init_one_line_goal = __esm(() => {
|
|
|
45354
45468
|
});
|
|
45355
45469
|
|
|
45356
45470
|
// ../../loki-ts/src/util/group_integrate.ts
|
|
45357
|
-
import { existsSync as existsSync84, mkdirSync as
|
|
45471
|
+
import { existsSync as existsSync84, mkdirSync as mkdirSync64, readFileSync as readFileSync111, rmSync as rmSync39, writeFileSync as writeFileSync67 } from "fs";
|
|
45358
45472
|
import { basename as basename37, dirname as dirname53, join as join123, normalize as normalize8 } from "path";
|
|
45359
45473
|
function integrationOrder(dag) {
|
|
45360
45474
|
const ids = dag.units.map((u) => u.id), indeg = new Map(ids.map((i) => [i, 0]));
|
|
@@ -45395,7 +45509,7 @@ async function rerunWalls(runner, repoDir, merged, walls) {
|
|
|
45395
45509
|
if (bad = wallPathProblem(repoDir, rel) ?? (r2 ? undefined : `no runner for ${f.rel}`))
|
|
45396
45510
|
break;
|
|
45397
45511
|
written.push({ abs, prev: existsSync84(abs) ? readFileSync111(abs) : null });
|
|
45398
|
-
|
|
45512
|
+
mkdirSync64(dirname53(abs), { recursive: true });
|
|
45399
45513
|
writeFileSync67(abs, f.bytes);
|
|
45400
45514
|
tests.push({ runner: r2, path: rel });
|
|
45401
45515
|
}
|
|
@@ -45853,7 +45967,7 @@ __export(exports_run_group, {
|
|
|
45853
45967
|
groupCostLine: () => groupCostLine,
|
|
45854
45968
|
NOT_PROVEN: () => NOT_PROVEN
|
|
45855
45969
|
});
|
|
45856
|
-
import { cpSync as cpSync5, existsSync as existsSync85, mkdirSync as
|
|
45970
|
+
import { cpSync as cpSync5, existsSync as existsSync85, mkdirSync as mkdirSync65, readdirSync as readdirSync46, readFileSync as readFileSync112, rmSync as rmSync40, statSync as statSync38 } from "fs";
|
|
45857
45971
|
import { createHash as createHash30 } from "crypto";
|
|
45858
45972
|
import { spawn as spawn11 } from "child_process";
|
|
45859
45973
|
import { join as join124, resolve as resolve29 } from "path";
|
|
@@ -45906,7 +46020,7 @@ function writeGroupCostRecord(repoDir, name, costs, provider) {
|
|
|
45906
46020
|
}
|
|
45907
46021
|
if (recs.length === 0)
|
|
45908
46022
|
return;
|
|
45909
|
-
|
|
46023
|
+
mkdirSync65(dir, { recursive: true });
|
|
45910
46024
|
recs.forEach((r, k) => atomicWriteJson(join124(dir, `iteration-group-${name}-${String(k).padStart(3, "0")}.json`), r));
|
|
45911
46025
|
} catch {}
|
|
45912
46026
|
}
|
|
@@ -46125,7 +46239,7 @@ async function runGroupCore(launcher, dag, ctx) {
|
|
|
46125
46239
|
for (const cu of Array.isArray(gc?.["units"]) ? gc["units"] : [])
|
|
46126
46240
|
accOf.set(cu.id, cu.criteria.map((c) => c.text));
|
|
46127
46241
|
const specDir = join124(groupDir, "unit_specs");
|
|
46128
|
-
|
|
46242
|
+
mkdirSync65(specDir, { recursive: true });
|
|
46129
46243
|
for (const u of units) {
|
|
46130
46244
|
const spec = join124(specDir, `${u.id}.json`);
|
|
46131
46245
|
const isFix = !!u.fixKind;
|
|
@@ -46363,7 +46477,7 @@ __export(exports_route, {
|
|
|
46363
46477
|
MAX_SPEC_BYTES: () => MAX_SPEC_BYTES2,
|
|
46364
46478
|
MAX_SEQ_TASK_BYTES: () => MAX_SEQ_TASK_BYTES
|
|
46365
46479
|
});
|
|
46366
|
-
import { closeSync as closeSync17, constants as constants4, fstatSync as fstatSync9, openSync as openSync17, readFileSync as readFileSync113, realpathSync as
|
|
46480
|
+
import { closeSync as closeSync17, constants as constants4, fstatSync as fstatSync9, openSync as openSync17, readFileSync as readFileSync113, realpathSync as realpathSync40 } from "fs";
|
|
46367
46481
|
import { isAbsolute as isAbsolute20, relative as relative28, resolve as resolve30 } from "path";
|
|
46368
46482
|
function providerSlots(env, provider) {
|
|
46369
46483
|
provider = (provider || env.LOKI_PROVIDER || "claude").toLowerCase();
|
|
@@ -46375,11 +46489,11 @@ function readSpec(task, repoDir, cwd) {
|
|
|
46375
46489
|
const p = isAbsolute20(task) ? task : resolve30(cwd, task);
|
|
46376
46490
|
let real4;
|
|
46377
46491
|
try {
|
|
46378
|
-
real4 =
|
|
46492
|
+
real4 = realpathSync40(p);
|
|
46379
46493
|
} catch {
|
|
46380
46494
|
return { kind: "missing", path: p };
|
|
46381
46495
|
}
|
|
46382
|
-
const rel = relative28(
|
|
46496
|
+
const rel = relative28(realpathSync40(repoDir), real4);
|
|
46383
46497
|
if (rel === ".." || rel.startsWith("../") || isAbsolute20(rel))
|
|
46384
46498
|
return { kind: "reject", reason: `spec path escapes the repo: ${task}` };
|
|
46385
46499
|
let fd = -1;
|
|
@@ -46514,7 +46628,7 @@ var init_route = __esm(() => {
|
|
|
46514
46628
|
});
|
|
46515
46629
|
|
|
46516
46630
|
// ../../loki-ts/src/contrib/forecast.ts
|
|
46517
|
-
import { appendFileSync as appendFileSync13, existsSync as existsSync86, mkdirSync as
|
|
46631
|
+
import { appendFileSync as appendFileSync13, existsSync as existsSync86, mkdirSync as mkdirSync66, readFileSync as readFileSync114 } from "fs";
|
|
46518
46632
|
import { join as join125 } from "path";
|
|
46519
46633
|
function readWindowDeltas(lokiDir2) {
|
|
46520
46634
|
const p = historyPath2(lokiDir2);
|
|
@@ -46545,7 +46659,7 @@ function recordWindowDelta(lokiDir2, before, after) {
|
|
|
46545
46659
|
if (session < 0 || week < 0 || session === 0 && week === 0)
|
|
46546
46660
|
return false;
|
|
46547
46661
|
try {
|
|
46548
|
-
|
|
46662
|
+
mkdirSync66(lokiDir2, { recursive: true });
|
|
46549
46663
|
appendFileSync13(historyPath2(lokiDir2), JSON.stringify({ session, week }) + `
|
|
46550
46664
|
`);
|
|
46551
46665
|
return true;
|
|
@@ -46592,7 +46706,7 @@ var init_forecast = __esm(() => {
|
|
|
46592
46706
|
});
|
|
46593
46707
|
|
|
46594
46708
|
// ../../loki-ts/src/commands/queue.ts
|
|
46595
|
-
import { existsSync as existsSync87, mkdirSync as
|
|
46709
|
+
import { existsSync as existsSync87, mkdirSync as mkdirSync67, readFileSync as readFileSync115, readdirSync as readdirSync47, renameSync as renameSync24, statSync as statSync39, writeFileSync as writeFileSync68 } from "fs";
|
|
46596
46710
|
import { join as join126, resolve as resolve31 } from "path";
|
|
46597
46711
|
function normalizeRef(raw2) {
|
|
46598
46712
|
const m = URL_RE.exec(raw2);
|
|
@@ -46630,7 +46744,7 @@ function quarantineCorruptQueue(lokiDir2, now2, warn) {
|
|
|
46630
46744
|
} catch {}
|
|
46631
46745
|
}
|
|
46632
46746
|
function writeQueue(lokiDir2, items2) {
|
|
46633
|
-
|
|
46747
|
+
mkdirSync67(lokiDir2, { recursive: true });
|
|
46634
46748
|
const p = queuePath(lokiDir2);
|
|
46635
46749
|
atomicWriteText(p, JSON.stringify({ version: 1, items: items2 }, null, 2) + `
|
|
46636
46750
|
`);
|
|
@@ -46818,7 +46932,7 @@ ${QUEUE_USAGE}`);
|
|
|
46818
46932
|
const finished = d.now();
|
|
46819
46933
|
const text4 = renderDigest(started, finished, rows, skipped2, stopReason2);
|
|
46820
46934
|
try {
|
|
46821
|
-
|
|
46935
|
+
mkdirSync67(d.lokiDir, { recursive: true });
|
|
46822
46936
|
const stamp2 = finished.toISOString().replace(/[:.]/g, "-");
|
|
46823
46937
|
writeFileSync68(join126(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
|
|
46824
46938
|
writeFileSync68(join126(d.lokiDir, "queue-digest-latest.txt"), text4);
|
|
@@ -46892,7 +47006,7 @@ function makeDefaultRunner(lokiDir2) {
|
|
|
46892
47006
|
const output = so + se;
|
|
46893
47007
|
try {
|
|
46894
47008
|
const logDir = join126(lokiDir2, "queue-logs");
|
|
46895
|
-
|
|
47009
|
+
mkdirSync67(logDir, { recursive: true });
|
|
46896
47010
|
writeFileSync68(join126(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
|
|
46897
47011
|
} catch {}
|
|
46898
47012
|
const proof = newestRecord(runLoki, since);
|
|
@@ -47126,12 +47240,12 @@ function decomposeReply(outPath, logPath, summary) {
|
|
|
47126
47240
|
}
|
|
47127
47241
|
function makeSessionDecompose(repoDir, lokiDir2, provider, onCost) {
|
|
47128
47242
|
return async (slug, issue, triageReason, note) => {
|
|
47129
|
-
const { mkdirSync:
|
|
47243
|
+
const { mkdirSync: mkdirSync68, writeFileSync: writeFileSync69 } = await import("fs");
|
|
47130
47244
|
const { join: join127 } = await import("path");
|
|
47131
47245
|
const { createSessionRunner: createSessionRunner2 } = await Promise.resolve().then(() => (init_session(), exports_session));
|
|
47132
47246
|
const { envOverride: envOverride2 } = await Promise.resolve().then(() => (init_decision(), exports_decision));
|
|
47133
47247
|
const dir = join127(lokiDir2, "issues-run", "decompose");
|
|
47134
|
-
|
|
47248
|
+
mkdirSync68(dir, { recursive: true });
|
|
47135
47249
|
const stamp2 = Date.now(), outPath = join127(dir, `issue-${issue.number}-${stamp2}.json`), iterationId = `issues-decompose-${issue.number}-${stamp2}`;
|
|
47136
47250
|
let usd = null;
|
|
47137
47251
|
const runner = createSessionRunner2({ provider, lokiRoot: lokiDir2, emit: (type, _stage, data) => {
|
|
@@ -47223,7 +47337,7 @@ var init_issues_epic = __esm(() => {
|
|
|
47223
47337
|
});
|
|
47224
47338
|
|
|
47225
47339
|
// ../../loki-ts/src/commands/issues_combine.ts
|
|
47226
|
-
import { cpSync as cpSync6, existsSync as existsSync89, mkdirSync as
|
|
47340
|
+
import { cpSync as cpSync6, existsSync as existsSync89, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync18, readFileSync as readFileSync117, rmSync as rmSync41, symlinkSync as symlinkSync5, writeFileSync as writeFileSync69 } from "fs";
|
|
47227
47341
|
import { tmpdir as tmpdir23 } from "os";
|
|
47228
47342
|
import { dirname as dirname54, join as join127 } from "path";
|
|
47229
47343
|
function oneMaxFiles(env = process.env) {
|
|
@@ -47352,7 +47466,7 @@ function resetTo(wt, sha5) {
|
|
|
47352
47466
|
}
|
|
47353
47467
|
async function combineSlices(o) {
|
|
47354
47468
|
const { io } = o, n3 = o.issue.number, branch = combinedBranch(n3), dir = join127(o.runDir, "combined");
|
|
47355
|
-
|
|
47469
|
+
mkdirSync68(dir, { recursive: true });
|
|
47356
47470
|
const res = { branch, pr: null, verdict: "PARTIAL", commits: [], fallback: [], notProven: [], receiptPath: null, resolveUsd: [] };
|
|
47357
47471
|
const byId = new Map(o.slices.map((s) => [s.id, s]));
|
|
47358
47472
|
const filesOf = (s) => lines2(out2(o.repoDir, ["-c", "core.quotePath=false", "diff", "--no-renames", "--name-only", parentTipOf(s), s.branch, "--", ".", ":(exclude).loki"]));
|
|
@@ -47487,7 +47601,7 @@ async function combineSlices(o) {
|
|
|
47487
47601
|
const s = byId.get(id);
|
|
47488
47602
|
if (!s.receiptDir)
|
|
47489
47603
|
throw new Error(`slice ${id} kept no receipt`);
|
|
47490
|
-
|
|
47604
|
+
mkdirSync68(join127(unitsDir2, id), { recursive: true });
|
|
47491
47605
|
for (const f of ["receipt.json", "events.jsonl"])
|
|
47492
47606
|
if (existsSync89(join127(s.receiptDir, f)))
|
|
47493
47607
|
cpSync6(join127(s.receiptDir, f), join127(unitsDir2, id, f));
|
|
@@ -47594,7 +47708,7 @@ async function publishFallback2(o, dropped2, res) {
|
|
|
47594
47708
|
const base2 = s.parent && pushedBranch.has(s.parent) ? pushedBranch.get(s.parent) : null;
|
|
47595
47709
|
const rec2 = readReceipt2(s.receiptDir), dir = join127(o.runDir, "combined"), bodyFile = join127(dir, `pr-body-${s.id}.md`);
|
|
47596
47710
|
const files = lines2(out2(o.repoDir, ["-c", "core.quotePath=false", "diff", "--no-renames", "--name-only", s.parent && o.slices.some((x) => x.id === s.parent) ? o.slices.find((x) => x.id === s.parent).branch : o.baseSha, s.branch, "--", ".", ":(exclude).loki"]));
|
|
47597
|
-
|
|
47711
|
+
mkdirSync68(dir, { recursive: true });
|
|
47598
47712
|
writeFileSync69(bodyFile, [`Slice ${s.id} of ${o.slug}#${o.issue.number}, opened as its own pull request because ${one2(why)}.${s.parent && !base2 ? ` This branch also holds slice ${s.parent}${res.pr ? `, which is in ${res.pr}` : ""}; merge that first.` : ""}`, "", sliceSection(s, { files, notProven: receiptNotProven(rec2), receiptSha: typeof rec2?.["receipt_sha256"] === "string" ? rec2["receipt_sha256"] : null }), o.io.link("PARTIAL").trim()].join(`
|
|
47599
47713
|
`) + `
|
|
47600
47714
|
`);
|
|
@@ -47685,7 +47799,7 @@ __export(exports_issues_run, {
|
|
|
47685
47799
|
REAPER_SH: () => REAPER_SH
|
|
47686
47800
|
});
|
|
47687
47801
|
import { spawnSync as spawnSync19 } from "child_process";
|
|
47688
|
-
import { cpSync as cpSync7, existsSync as existsSync90, mkdirSync as
|
|
47802
|
+
import { cpSync as cpSync7, existsSync as existsSync90, mkdirSync as mkdirSync69, mkdtempSync as mkdtempSync19, readdirSync as readdirSync48, readFileSync as readFileSync118, rmdirSync as rmdirSync2, rmSync as rmSync42, writeFileSync as writeFileSync70 } from "fs";
|
|
47689
47803
|
import { tmpdir as tmpdir24 } from "os";
|
|
47690
47804
|
import { join as join128, resolve as resolve32 } from "path";
|
|
47691
47805
|
import { createInterface as createInterface3 } from "readline";
|
|
@@ -47968,7 +48082,7 @@ ${USAGE}`);
|
|
|
47968
48082
|
}
|
|
47969
48083
|
const stamp2 = started.toISOString().replace(/[:.]/g, "-");
|
|
47970
48084
|
const runDir = join128(d.lokiDir, "issues-run", stamp2);
|
|
47971
|
-
|
|
48085
|
+
mkdirSync69(runDir, { recursive: true });
|
|
47972
48086
|
const byRef = new Map(actionable.map((i) => [`${slug}#${i.number}`, i]));
|
|
47973
48087
|
const sink = () => {};
|
|
47974
48088
|
if (actionable.length > 0) {
|
|
@@ -48299,7 +48413,7 @@ function makeWorktrees(repoDir) {
|
|
|
48299
48413
|
return {
|
|
48300
48414
|
create: (name, base2) => {
|
|
48301
48415
|
root ??= mkdtempSync19(join128(tmpdir24(), "loki-issues-"));
|
|
48302
|
-
|
|
48416
|
+
mkdirSync69(root, { recursive: true });
|
|
48303
48417
|
const p = join128(root, name);
|
|
48304
48418
|
safeGit(repoDir, ["worktree", "add", "-B", `loki/${name}`, p, base2]);
|
|
48305
48419
|
return p;
|
|
@@ -48440,7 +48554,7 @@ __export(exports_supervisor, {
|
|
|
48440
48554
|
});
|
|
48441
48555
|
import { spawnSync as spawnSync20 } from "child_process";
|
|
48442
48556
|
import { createHash as createHash31, createPublicKey as createPublicKey6, sign as sign4 } from "crypto";
|
|
48443
|
-
import { existsSync as existsSync91, mkdirSync as
|
|
48557
|
+
import { existsSync as existsSync91, mkdirSync as mkdirSync70, readFileSync as readFileSync119, writeFileSync as writeFileSync71 } from "fs";
|
|
48444
48558
|
import { dirname as dirname55, join as join129, relative as relative29, resolve as resolve33 } from "path";
|
|
48445
48559
|
async function slackEvent(...a) {
|
|
48446
48560
|
try {
|
|
@@ -49068,7 +49182,7 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
|
|
|
49068
49182
|
task = g2.task;
|
|
49069
49183
|
}
|
|
49070
49184
|
if (spec) {
|
|
49071
|
-
|
|
49185
|
+
mkdirSync70(runDir, { recursive: true });
|
|
49072
49186
|
writeFileSync71(join129(runDir, "spec.snapshot.md"), spec.raw);
|
|
49073
49187
|
for (const e of [env, process.env]) {
|
|
49074
49188
|
e.LOKI_E10_SPEC_PATH = relative29(repoDir, spec.path);
|
|
@@ -49091,7 +49205,7 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
|
|
|
49091
49205
|
if (!isIssue)
|
|
49092
49206
|
env.LOKI_E10_TASK_TEXT = task;
|
|
49093
49207
|
else if (isIssue) {
|
|
49094
|
-
|
|
49208
|
+
mkdirSync70(runDir, { recursive: true });
|
|
49095
49209
|
try {
|
|
49096
49210
|
if (trackerRef)
|
|
49097
49211
|
await fetchTrackerIssueToFile(trackerRef, join129(runDir, "issue.json"));
|
|
@@ -49272,7 +49386,7 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
|
|
|
49272
49386
|
},
|
|
49273
49387
|
comment: noPr ? undefined : async ({ issueRef, reason, prUrl }) => {
|
|
49274
49388
|
const { DEFAULT_PUSH_SH: DEFAULT_PUSH_SH2 } = await Promise.resolve().then(() => (init_pr(), exports_pr));
|
|
49275
|
-
|
|
49389
|
+
mkdirSync70(runDir, { recursive: true });
|
|
49276
49390
|
const bodyFile = join129(runDir, "backstop-comment.md");
|
|
49277
49391
|
writeFileSync71(bodyFile, `<!-- loki-backstop -->
|
|
49278
49392
|
Loki 10 run ${runId2} ${prUrl ? `opened draft PR ${prUrl}` : "ended without a PR"}.
|
|
@@ -49755,7 +49869,7 @@ __export(exports_warm, {
|
|
|
49755
49869
|
WarmEngine: () => WarmEngine
|
|
49756
49870
|
});
|
|
49757
49871
|
import { createHash as createHash32 } from "crypto";
|
|
49758
|
-
import { existsSync as existsSync93, mkdirSync as
|
|
49872
|
+
import { existsSync as existsSync93, mkdirSync as mkdirSync71, readFileSync as readFileSync122, statSync as statSync40, unlinkSync as unlinkSync11 } from "fs";
|
|
49759
49873
|
import { createServer as createServer2 } from "net";
|
|
49760
49874
|
import { dirname as dirname56, resolve as resolve34 } from "path";
|
|
49761
49875
|
function speedEnabled() {
|
|
@@ -49838,7 +49952,7 @@ function startWarmIfEnabled() {
|
|
|
49838
49952
|
}
|
|
49839
49953
|
}
|
|
49840
49954
|
function startWarmServer(path = warmSocketPath(), engine = new WarmEngine) {
|
|
49841
|
-
|
|
49955
|
+
mkdirSync71(dirname56(path), { recursive: true });
|
|
49842
49956
|
try {
|
|
49843
49957
|
unlinkSync11(path);
|
|
49844
49958
|
} catch {}
|
|
@@ -49895,7 +50009,7 @@ var init_warm = __esm(() => {
|
|
|
49895
50009
|
|
|
49896
50010
|
// ../../loki-ts/src/features/speed/already_done_async.ts
|
|
49897
50011
|
import { execFile as execFile2 } from "child_process";
|
|
49898
|
-
import { mkdirSync as
|
|
50012
|
+
import { mkdirSync as mkdirSync72, mkdtempSync as mkdtempSync20, rmSync as rmSync43 } from "fs";
|
|
49899
50013
|
import { tmpdir as tmpdir25 } from "os";
|
|
49900
50014
|
import { join as join132 } from "path";
|
|
49901
50015
|
function hitsUnchangedFromBase(repoDir, baseSha, paths) {
|
|
@@ -49941,7 +50055,7 @@ function pinBaseTree(ctx, signal) {
|
|
|
49941
50055
|
}
|
|
49942
50056
|
trackRoot(root);
|
|
49943
50057
|
try {
|
|
49944
|
-
|
|
50058
|
+
mkdirSync72(join132(root, "tree"));
|
|
49945
50059
|
} catch {
|
|
49946
50060
|
dropRoot(root);
|
|
49947
50061
|
return Promise.resolve(null);
|
|
@@ -50036,7 +50150,7 @@ __export(exports_intake, {
|
|
|
50036
50150
|
runIntake: () => runIntake,
|
|
50037
50151
|
alreadyDoneCheckOn: () => alreadyDoneCheckOn
|
|
50038
50152
|
});
|
|
50039
|
-
import { appendFileSync as appendFileSync14, existsSync as existsSync94, mkdirSync as
|
|
50153
|
+
import { appendFileSync as appendFileSync14, existsSync as existsSync94, mkdirSync as mkdirSync73, readFileSync as readFileSync123, writeFileSync as writeFileSync72 } from "fs";
|
|
50040
50154
|
import { dirname as dirname57, join as join133, resolve as resolve35 } from "path";
|
|
50041
50155
|
function issueRefOf(raw2) {
|
|
50042
50156
|
return typeof raw2.repo === "string" && raw2.repo && typeof raw2.number === "number" ? `${raw2.repo}#${raw2.number}` : null;
|
|
@@ -50065,7 +50179,7 @@ function excludeLokiDir(repoDir) {
|
|
|
50065
50179
|
if (existing.split(`
|
|
50066
50180
|
`).some((l) => l.trim() === ".loki/"))
|
|
50067
50181
|
return;
|
|
50068
|
-
|
|
50182
|
+
mkdirSync73(dirname57(path), { recursive: true });
|
|
50069
50183
|
const sep22 = existing.length > 0 && !existing.endsWith(`
|
|
50070
50184
|
`) ? `
|
|
50071
50185
|
` : "";
|
|
@@ -50177,7 +50291,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
|
|
|
50177
50291
|
const ambiguity = gate.data;
|
|
50178
50292
|
if (gate.stop)
|
|
50179
50293
|
return { status: "failed", data: { ...common, task_sha256: taskSha256, source, base_sha: baseSha, tree, branch: ctx.branch, ...gate.stop.failData }, reason: gate.stop.reason };
|
|
50180
|
-
|
|
50294
|
+
mkdirSync73(ctx.runDir, { recursive: true });
|
|
50181
50295
|
const repomapRef = join133(ctx.runDir, "repomap.json");
|
|
50182
50296
|
const cacheDir = repoCacheDir(repoKey(null, ctx.repoDir));
|
|
50183
50297
|
const tm = { setup: { ms: Date.now() - t0, at: 0 } }, lap = () => {
|
|
@@ -50450,7 +50564,7 @@ ${g2.sample}`)].join(`
|
|
|
50450
50564
|
|
|
50451
50565
|
// ../../loki-ts/src/util/app_probe.ts
|
|
50452
50566
|
import { spawnSync as spawnSync21 } from "child_process";
|
|
50453
|
-
import { existsSync as existsSync95, mkdirSync as
|
|
50567
|
+
import { existsSync as existsSync95, mkdirSync as mkdirSync74, readFileSync as readFileSync124, renameSync as renameSync25, writeFileSync as writeFileSync73 } from "fs";
|
|
50454
50568
|
import { join as join134 } from "path";
|
|
50455
50569
|
function readJson8(p) {
|
|
50456
50570
|
try {
|
|
@@ -50528,7 +50642,7 @@ async function functionalVerify(opts, url, dir, lokiDir2, timeoutMs) {
|
|
|
50528
50642
|
if (!out3 || r.status !== 0)
|
|
50529
50643
|
return res("not_run", "functional harness produced no result");
|
|
50530
50644
|
const q = join134(lokiDir2, "quality");
|
|
50531
|
-
|
|
50645
|
+
mkdirSync74(q, { recursive: true });
|
|
50532
50646
|
const tmp = join134(q, `functional-results.json.tmp.${process.pid}`);
|
|
50533
50647
|
writeFileSync73(tmp, JSON.stringify(out3, null, 2));
|
|
50534
50648
|
renameSync25(tmp, join134(q, "functional-results.json"));
|
|
@@ -50576,7 +50690,7 @@ __export(exports_deep, {
|
|
|
50576
50690
|
addedLineNumbers: () => addedLineNumbers,
|
|
50577
50691
|
DEFAULT_SECRET_SCAN_SH: () => DEFAULT_SECRET_SCAN_SH
|
|
50578
50692
|
});
|
|
50579
|
-
import { copyFileSync as copyFileSync9, existsSync as existsSync96, mkdirSync as
|
|
50693
|
+
import { copyFileSync as copyFileSync9, existsSync as existsSync96, mkdirSync as mkdirSync75, mkdtempSync as mkdtempSync21, readFileSync as readFileSync125, rmSync as rmSync44, writeFileSync as writeFileSync74 } from "fs";
|
|
50580
50694
|
import { tmpdir as tmpdir26 } from "os";
|
|
50581
50695
|
import { dirname as dirname58, join as join135 } from "path";
|
|
50582
50696
|
async function runFullSuite(ctx, signal, opts, checks, notProven2) {
|
|
@@ -50682,7 +50796,7 @@ async function secretLines(scriptPath, root, rel, cap = 5) {
|
|
|
50682
50796
|
await walk(mid, hi);
|
|
50683
50797
|
};
|
|
50684
50798
|
try {
|
|
50685
|
-
|
|
50799
|
+
mkdirSync75(dirname58(probe), { recursive: true });
|
|
50686
50800
|
await walk(0, lines3.length);
|
|
50687
50801
|
return found;
|
|
50688
50802
|
} catch {
|
|
@@ -50759,7 +50873,7 @@ async function runSecretScan(ctx, changed, opts, checks, notProven2) {
|
|
|
50759
50873
|
headLines.set(f, addedLineNumbers(d.stdout));
|
|
50760
50874
|
} else
|
|
50761
50875
|
fresh.push(f);
|
|
50762
|
-
|
|
50876
|
+
mkdirSync75(dirname58(join135(root, f)), { recursive: true });
|
|
50763
50877
|
if (added === null)
|
|
50764
50878
|
copyFileSync9(join135(ctx.repoDir, f), join135(root, f));
|
|
50765
50879
|
else
|
|
@@ -50843,7 +50957,7 @@ async function runDeep(ctx, signal, opts = {}) {
|
|
|
50843
50957
|
const addendumSha256 = sha2562(canonicalJson(addendumBody));
|
|
50844
50958
|
const sig = signReceipt(`${ctx.runId}-deep`, addendumSha256);
|
|
50845
50959
|
const addendum = { ...addendumBody, addendum_sha256: addendumSha256, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
50846
|
-
|
|
50960
|
+
mkdirSync75(ctx.runDir, { recursive: true });
|
|
50847
50961
|
writeFileSync74(join135(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
|
|
50848
50962
|
`);
|
|
50849
50963
|
if (opts.post === false) {
|
|
@@ -51979,7 +52093,7 @@ var init_codemod = __esm(() => {
|
|
|
51979
52093
|
|
|
51980
52094
|
// ../../loki-ts/src/engine10/modernize/oracle/seal.ts
|
|
51981
52095
|
import { createHash as createHash33 } from "crypto";
|
|
51982
|
-
import { existsSync as existsSync98, mkdirSync as
|
|
52096
|
+
import { existsSync as existsSync98, mkdirSync as mkdirSync76, readFileSync as readFileSync128, writeFileSync as writeFileSync75 } from "fs";
|
|
51983
52097
|
import { join as join140 } from "path";
|
|
51984
52098
|
function normalizersSha(n3) {
|
|
51985
52099
|
return sha2564(JSON.stringify({
|
|
@@ -52059,7 +52173,7 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
|
|
|
52059
52173
|
const coverageRaw = readFileSync128(coveragePath, "utf8");
|
|
52060
52174
|
const normalizersHash = normalizersSha(normalizers);
|
|
52061
52175
|
const sealed = buildSealedOracle(unit, casesRaw, coverageRaw, normalizersHash);
|
|
52062
|
-
|
|
52176
|
+
mkdirSync76(dir, { recursive: true });
|
|
52063
52177
|
writeFileSync75(sealedPath, JSON.stringify(sealed, null, 2));
|
|
52064
52178
|
log.append(sealed.verdict === "PROVEN_ORACLE" ? "oracle.captured" : "oracle.flagged", {
|
|
52065
52179
|
unit,
|
|
@@ -52124,7 +52238,7 @@ var init_seal2 = __esm(() => {
|
|
|
52124
52238
|
|
|
52125
52239
|
// ../../loki-ts/src/engine10/modernize/oracle/search.ts
|
|
52126
52240
|
import { spawnSync as spawnSync23 } from "child_process";
|
|
52127
|
-
import { copyFileSync as copyFileSync10, existsSync as existsSync99, linkSync as linkSync4, mkdirSync as
|
|
52241
|
+
import { copyFileSync as copyFileSync10, existsSync as existsSync99, linkSync as linkSync4, mkdirSync as mkdirSync77, mkdtempSync as mkdtempSync22, readFileSync as readFileSync129, renameSync as renameSync26, rmSync as rmSync45, rmdirSync as rmdirSync3, writeFileSync as writeFileSync76 } from "fs";
|
|
52128
52242
|
import { tmpdir as tmpdir27 } from "os";
|
|
52129
52243
|
import { basename as basename40, dirname as dirname60, join as join141 } from "path";
|
|
52130
52244
|
function search(unitSource, seedCases, propose, runCapture, opts = {}) {
|
|
@@ -52301,7 +52415,7 @@ function captureUnitOracle(a) {
|
|
|
52301
52415
|
rec2.not_proven = [...rec2.not_proven ?? [], `nondeterministic field ${f}`];
|
|
52302
52416
|
}
|
|
52303
52417
|
});
|
|
52304
|
-
|
|
52418
|
+
mkdirSync77(dir, { recursive: true });
|
|
52305
52419
|
writeFileSync76(tmpCases, recs.map((x) => JSON.stringify(x)).join(`
|
|
52306
52420
|
`) + `
|
|
52307
52421
|
`);
|
|
@@ -53094,7 +53208,7 @@ var init_resume = __esm(() => {
|
|
|
53094
53208
|
});
|
|
53095
53209
|
|
|
53096
53210
|
// ../../loki-ts/src/engine10/modernize/report.ts
|
|
53097
|
-
import { mkdirSync as
|
|
53211
|
+
import { mkdirSync as mkdirSync78, readFileSync as readFileSync132, writeFileSync as writeFileSync77 } from "fs";
|
|
53098
53212
|
import { dirname as dirname61 } from "path";
|
|
53099
53213
|
function buildReport(o) {
|
|
53100
53214
|
const units = o.units.map((x) => ({ unit: x.unit, verdict: x.verdict, not_proven: [...x.not_proven], rate: x.rate, branchPct: x.branchPct, receiptPath: x.receiptPath, receiptSha256: x.receiptSha256 }));
|
|
@@ -53138,7 +53252,7 @@ function renderReportMd(r) {
|
|
|
53138
53252
|
function writeReport(o) {
|
|
53139
53253
|
const sealed = sealReport(buildReport(o), o.sign);
|
|
53140
53254
|
const jp = reportJsonPath(o.repoDir, o.mid);
|
|
53141
|
-
|
|
53255
|
+
mkdirSync78(dirname61(jp), { recursive: true });
|
|
53142
53256
|
writeFileSync77(jp, JSON.stringify(sealed, null, 2) + `
|
|
53143
53257
|
`, "utf8");
|
|
53144
53258
|
writeFileSync77(reportMdPath(o.repoDir, o.mid), renderReportMd(sealed), "utf8");
|
|
@@ -53154,7 +53268,7 @@ var init_report = __esm(() => {
|
|
|
53154
53268
|
});
|
|
53155
53269
|
|
|
53156
53270
|
// ../../loki-ts/src/engine10/modernize/ship.ts
|
|
53157
|
-
import { mkdirSync as
|
|
53271
|
+
import { mkdirSync as mkdirSync79, writeFileSync as writeFileSync78 } from "fs";
|
|
53158
53272
|
import { join as join144 } from "path";
|
|
53159
53273
|
function waveIsDraft(verdict, units) {
|
|
53160
53274
|
return verdict === null || verdict.verified !== true || units.length === 0 || units.some((x) => x.verdict !== "PROVEN");
|
|
@@ -53177,7 +53291,7 @@ function shipWave(o) {
|
|
|
53177
53291
|
if (draft)
|
|
53178
53292
|
return fail2("wave not verified: branch stays local, not pushed");
|
|
53179
53293
|
const dir = join144(o.repoDir, ".loki", "modernize", o.mid);
|
|
53180
|
-
|
|
53294
|
+
mkdirSync79(dir, { recursive: true });
|
|
53181
53295
|
const bodyFile = join144(dir, `wave-${o.wave}-pr-body.md`);
|
|
53182
53296
|
writeFileSync78(bodyFile, renderWaveBody(o.wave, o.verdict, o.units), "utf8");
|
|
53183
53297
|
const r = (o.push ?? runPushPr)({ repoDir: o.repoDir, branch: o.branch, title: `Loki modernize: wave ${o.wave}`, bodyFile, draft, pinnedOrigin });
|
|
@@ -53198,7 +53312,7 @@ var init_ship2 = __esm(() => {
|
|
|
53198
53312
|
});
|
|
53199
53313
|
|
|
53200
53314
|
// ../../loki-ts/src/engine10/modernize/presealed_wall.ts
|
|
53201
|
-
import { existsSync as existsSync101, mkdirSync as
|
|
53315
|
+
import { existsSync as existsSync101, mkdirSync as mkdirSync80, readFileSync as readFileSync133, writeFileSync as writeFileSync79 } from "fs";
|
|
53202
53316
|
import { join as join145 } from "path";
|
|
53203
53317
|
function isRealFailCount(n3) {
|
|
53204
53318
|
return typeof n3 === "number" && Number.isInteger(n3) && n3 >= 1;
|
|
@@ -53263,7 +53377,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
|
|
|
53263
53377
|
reason: `conformance did not run (D42 (3)): exit ${String(outcome.exitCode)}${outcome.timedOut ? ", timeout" : ""}; seal refused, NOT PROVEN`
|
|
53264
53378
|
};
|
|
53265
53379
|
}
|
|
53266
|
-
|
|
53380
|
+
mkdirSync80(dir, { recursive: true });
|
|
53267
53381
|
const sealedPath = preSealedPath(repoDir, mid, unit);
|
|
53268
53382
|
if (existsSync101(sealedPath)) {
|
|
53269
53383
|
throw new Error(`presealed wall: ${unit} already has a sealed presealed_wall.json; re-seal refused (seal is write-once)`);
|
|
@@ -53340,7 +53454,7 @@ var init_presealed_wall = __esm(() => {
|
|
|
53340
53454
|
// ../../loki-ts/src/engine10/modernize/unit.ts
|
|
53341
53455
|
import { spawnSync as spawnSync24 } from "child_process";
|
|
53342
53456
|
import { createHash as createHash34 } from "crypto";
|
|
53343
|
-
import { lstatSync as lstatSync32, readFileSync as readFileSync134, readdirSync as readdirSync50, readlinkSync as readlinkSync7, realpathSync as
|
|
53457
|
+
import { lstatSync as lstatSync32, readFileSync as readFileSync134, readdirSync as readdirSync50, readlinkSync as readlinkSync7, realpathSync as realpathSync41, rmSync as rmSync46 } from "fs";
|
|
53344
53458
|
import { tmpdir as tmpdir28 } from "os";
|
|
53345
53459
|
import { join as join146, sep as sep22 } from "path";
|
|
53346
53460
|
function isSealedName(rel) {
|
|
@@ -53369,13 +53483,13 @@ function purgePycache(dir) {
|
|
|
53369
53483
|
function outsideTargetDigest(dir, full) {
|
|
53370
53484
|
let real4;
|
|
53371
53485
|
try {
|
|
53372
|
-
real4 =
|
|
53486
|
+
real4 = realpathSync41(full);
|
|
53373
53487
|
} catch {
|
|
53374
53488
|
return "dangling";
|
|
53375
53489
|
}
|
|
53376
53490
|
let root;
|
|
53377
53491
|
try {
|
|
53378
|
-
root =
|
|
53492
|
+
root = realpathSync41(dir);
|
|
53379
53493
|
} catch {
|
|
53380
53494
|
return "noroot";
|
|
53381
53495
|
}
|
|
@@ -53767,7 +53881,7 @@ var init_wave = __esm(() => {
|
|
|
53767
53881
|
|
|
53768
53882
|
// ../../loki-ts/src/util/modernize_unit.ts
|
|
53769
53883
|
import { spawnSync as spawnSync26 } from "child_process";
|
|
53770
|
-
import { existsSync as existsSync102, lstatSync as lstatSync33, mkdtempSync as mkdtempSync23, readFileSync as readFileSync136, realpathSync as
|
|
53884
|
+
import { existsSync as existsSync102, lstatSync as lstatSync33, mkdtempSync as mkdtempSync23, readFileSync as readFileSync136, realpathSync as realpathSync42, rmSync as rmSync47, statSync as statSync42, writeFileSync as writeFileSync80 } from "fs";
|
|
53771
53885
|
import { tmpdir as tmpdir29 } from "os";
|
|
53772
53886
|
import { join as join148, sep as sep23 } from "path";
|
|
53773
53887
|
function parseUnitArgs(args) {
|
|
@@ -53848,8 +53962,8 @@ function defaultUnitFile(unitId, newTreeDir) {
|
|
|
53848
53962
|
if (!isSafeUnitId(unitId))
|
|
53849
53963
|
return null;
|
|
53850
53964
|
try {
|
|
53851
|
-
const root =
|
|
53852
|
-
const real4 =
|
|
53965
|
+
const root = realpathSync42(newTreeDir);
|
|
53966
|
+
const real4 = realpathSync42(join148(root, unitId));
|
|
53853
53967
|
return real4.startsWith(root + sep23) ? real4 : null;
|
|
53854
53968
|
} catch {
|
|
53855
53969
|
return null;
|
|
@@ -55011,7 +55125,7 @@ __export(exports_base_guard, {
|
|
|
55011
55125
|
});
|
|
55012
55126
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
55013
55127
|
import { createHash as createHash37 } from "crypto";
|
|
55014
|
-
import { existsSync as existsSync107, mkdirSync as
|
|
55128
|
+
import { existsSync as existsSync107, mkdirSync as mkdirSync81, mkdtempSync as mkdtempSync25, readdirSync as readdirSync52, readFileSync as readFileSync140, readlinkSync as readlinkSync8, realpathSync as realpathSync43, rmSync as rmSync49, statSync as statSync45, symlinkSync as symlinkSync6, utimesSync, writeFileSync as writeFileSync82 } from "fs";
|
|
55015
55129
|
import { tmpdir as tmpdir31 } from "os";
|
|
55016
55130
|
import { basename as basename42, dirname as dirname63, join as join152, relative as relative31, resolve as resolve38, sep as sep24 } from "path";
|
|
55017
55131
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -55113,7 +55227,7 @@ function insideAny(p, roots) {
|
|
|
55113
55227
|
if (under3(resolve38(p)))
|
|
55114
55228
|
return true;
|
|
55115
55229
|
try {
|
|
55116
|
-
return under3(
|
|
55230
|
+
return under3(realpathSync43(p));
|
|
55117
55231
|
} catch {
|
|
55118
55232
|
return false;
|
|
55119
55233
|
}
|
|
@@ -55128,7 +55242,7 @@ function namedPaths2(file, text4) {
|
|
|
55128
55242
|
function depsSeeHead(pkgDir, repoDir) {
|
|
55129
55243
|
let roots;
|
|
55130
55244
|
try {
|
|
55131
|
-
roots = [...new Set([resolve38(repoDir),
|
|
55245
|
+
roots = [...new Set([resolve38(repoDir), realpathSync43(repoDir)])];
|
|
55132
55246
|
} catch {
|
|
55133
55247
|
return true;
|
|
55134
55248
|
}
|
|
@@ -55142,7 +55256,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
55142
55256
|
const t = resolve38(dir, readlinkSync8(p));
|
|
55143
55257
|
let rt = t;
|
|
55144
55258
|
try {
|
|
55145
|
-
rt =
|
|
55259
|
+
rt = realpathSync43(t);
|
|
55146
55260
|
} catch {}
|
|
55147
55261
|
if (insideAny(t, roots) && !own.some((r) => rt === r || rt.startsWith(r + sep24)))
|
|
55148
55262
|
return true;
|
|
@@ -55161,7 +55275,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
55161
55275
|
return ["node_modules", ".venv"].some((d) => {
|
|
55162
55276
|
try {
|
|
55163
55277
|
const top = join152(pkgDir, d);
|
|
55164
|
-
return walk(top, [...new Set([resolve38(top),
|
|
55278
|
+
return walk(top, [...new Set([resolve38(top), realpathSync43(top)])]);
|
|
55165
55279
|
} catch (e) {
|
|
55166
55280
|
if (e.code === "ENOENT")
|
|
55167
55281
|
return false;
|
|
@@ -55338,7 +55452,7 @@ function splitDeclaredAdvisories(notes, c) {
|
|
|
55338
55452
|
const named2 = (f) => new RegExp(`${f.includes("/") ? `(?<![\\w./-])${escapeRegex(f)}(?![\\w-])|` : ""}[/"'\`]${escapeRegex(basename42(f))}(?=["'\`\\s);]|$)`).test(wall());
|
|
55339
55453
|
const linkOk = (f) => {
|
|
55340
55454
|
try {
|
|
55341
|
-
const root =
|
|
55455
|
+
const root = realpathSync43(c.repoDir), t = realpathSync43(join152(c.repoDir, f)), rel = relative31(root, t);
|
|
55342
55456
|
return !rel.startsWith("..") && !rel.split(sep24).includes(".git") && statSync45(t).isFile() && changed.has(rel.split(sep24).join("/")) && !isTestFile(rel) && !c.wallPaths.includes(rel);
|
|
55343
55457
|
} catch {
|
|
55344
55458
|
return false;
|
|
@@ -55371,7 +55485,7 @@ function removeRunWorktrees(repoDir, baseSha) {
|
|
|
55371
55485
|
return;
|
|
55372
55486
|
const roots = [tmpdir31()];
|
|
55373
55487
|
try {
|
|
55374
|
-
roots.push(
|
|
55488
|
+
roots.push(realpathSync43(tmpdir31()));
|
|
55375
55489
|
} catch {}
|
|
55376
55490
|
for (const t of checkedOut(repoDir).trees.slice(1)) {
|
|
55377
55491
|
const named2 = RUN_TMP_WORKTREE_RE.test(basename42(t.path)) || RUN_TMP_WORKTREE_RE.test(basename42(dirname63(t.path)));
|
|
@@ -55389,7 +55503,7 @@ function settleBranch(repoDir, branch, dir, stem2, pushed, extra = {}) {
|
|
|
55389
55503
|
`, deleted: false };
|
|
55390
55504
|
let bundle = null;
|
|
55391
55505
|
try {
|
|
55392
|
-
|
|
55506
|
+
mkdirSync81(dir, { recursive: true });
|
|
55393
55507
|
if (unique > 0) {
|
|
55394
55508
|
const file = join152(dir, `${stem2}.bundle`);
|
|
55395
55509
|
if (git14(repoDir, ["bundle", "create", file, `refs/heads/${branch}`, ...NOT_ELSEWHERE], 120000) === null || git14(repoDir, ["bundle", "verify", file], 120000) === null)
|
|
@@ -55464,7 +55578,7 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
|
|
|
55464
55578
|
const branch = `loki/${runId2}`, runDir = join152(repoDir, ".loki", "runs", runId2), tip = tipOf(repoDir, `refs/heads/${branch}`);
|
|
55465
55579
|
try {
|
|
55466
55580
|
if (end.deferred && tip) {
|
|
55467
|
-
|
|
55581
|
+
mkdirSync81(runDir, { recursive: true });
|
|
55468
55582
|
writeFileSync82(join152(runDir, "branch.json"), JSON.stringify({ branch, head_sha: tip, pushed: end.pushed, bundle: null, orig_branch: end.orig, deferred: true }, null, 2) + `
|
|
55469
55583
|
`);
|
|
55470
55584
|
return `engine10: the checkout stays on ${branch} while the background deep verify runs, then returns to ${end.orig ?? "the starting branch"}
|
|
@@ -55631,9 +55745,9 @@ __export(exports_verify, {
|
|
|
55631
55745
|
COLLATERAL_RED: () => COLLATERAL_RED,
|
|
55632
55746
|
BCE_REASON: () => BCE_REASON
|
|
55633
55747
|
});
|
|
55634
|
-
import { existsSync as existsSync108, mkdtempSync as mkdtempSync26, readFileSync as readFileSync141, realpathSync as
|
|
55748
|
+
import { existsSync as existsSync108, mkdtempSync as mkdtempSync26, readFileSync as readFileSync141, realpathSync as realpathSync44, rmSync as rmSync50, statSync as statSync46 } from "fs";
|
|
55635
55749
|
import { tmpdir as tmpdir32 } from "os";
|
|
55636
|
-
import { basename as basename43, isAbsolute as isAbsolute21, join as join153, relative as relative32, resolve as resolve39 } from "path";
|
|
55750
|
+
import { basename as basename43, dirname as dirname64, isAbsolute as isAbsolute21, join as join153, relative as relative32, resolve as resolve39 } from "path";
|
|
55637
55751
|
function carriedTimeouts(prev, tests, changed, keep, env = process.env) {
|
|
55638
55752
|
if (!timeoutCarryOn(env))
|
|
55639
55753
|
return [];
|
|
@@ -55874,7 +55988,7 @@ async function vitestBatch(cwd, rels, signal, opts = {}) {
|
|
|
55874
55988
|
return null;
|
|
55875
55989
|
const real4 = (p) => {
|
|
55876
55990
|
try {
|
|
55877
|
-
return
|
|
55991
|
+
return realpathSync44(p);
|
|
55878
55992
|
} catch {
|
|
55879
55993
|
return p;
|
|
55880
55994
|
}
|
|
@@ -56253,6 +56367,39 @@ function tscLocalKeys(out3, pkgRel, keep, changed) {
|
|
|
56253
56367
|
return null;
|
|
56254
56368
|
return found.every((m) => TSC_LOCAL.has(m[2]) && !keep.has(join153(pkgRel === "." ? "" : pkgRel, m[1].trim()))) ? found.map((m) => `${m[1].trim()}|${m[2]}`) : null;
|
|
56255
56369
|
}
|
|
56370
|
+
function tscOnlyIgnored(repoDir, cwd, out3) {
|
|
56371
|
+
if (!out3 || out3.length >= 60000)
|
|
56372
|
+
return false;
|
|
56373
|
+
const lines3 = out3.split(`
|
|
56374
|
+
`).filter((l) => /error TS\d+/.test(l));
|
|
56375
|
+
if (lines3.length === 0)
|
|
56376
|
+
return false;
|
|
56377
|
+
try {
|
|
56378
|
+
return lines3.every((l) => {
|
|
56379
|
+
const m = /^(\S.*?)(?:\(\d+,\d+\)|:\d+:\d+)\s*(?::|-)\s*error TS2307: Cannot find module '([^']+)'/.exec(l.trim());
|
|
56380
|
+
if (!m)
|
|
56381
|
+
return false;
|
|
56382
|
+
const file = join153(cwd, m[1].trim()), mod = m[2];
|
|
56383
|
+
if (!mod.startsWith("."))
|
|
56384
|
+
return false;
|
|
56385
|
+
try {
|
|
56386
|
+
safeGit(repoDir, ["check-ignore", "-q", "--", file]);
|
|
56387
|
+
} catch {
|
|
56388
|
+
return false;
|
|
56389
|
+
}
|
|
56390
|
+
const target = join153(dirname64(file), mod).replace(/\.(js|mjs|cjs|jsx)$/, "");
|
|
56391
|
+
return ![target, ...[".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".d.ts"].map((e) => target + e), ...["index.ts", "index.tsx", "index.js"].map((e) => join153(target, e))].some((t) => {
|
|
56392
|
+
try {
|
|
56393
|
+
return statSync46(t).isFile();
|
|
56394
|
+
} catch {
|
|
56395
|
+
return false;
|
|
56396
|
+
}
|
|
56397
|
+
});
|
|
56398
|
+
});
|
|
56399
|
+
} catch {
|
|
56400
|
+
return false;
|
|
56401
|
+
}
|
|
56402
|
+
}
|
|
56256
56403
|
function tscUntouchedShape(out3, pkgRel, touched, symbols) {
|
|
56257
56404
|
if (out3.length >= 60000 || [...touched].some((f) => LINT_CONFIG.test(f)))
|
|
56258
56405
|
return false;
|
|
@@ -56333,7 +56480,9 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
|
|
|
56333
56480
|
const sfx = g2.root === "." ? "" : `:${g2.root}`, co = g2.root === "." ? opts : { ...opts, cwd: g2.cwd };
|
|
56334
56481
|
if (existsSync108(join153(g2.cwd, "tsconfig.json"))) {
|
|
56335
56482
|
const c = await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
|
|
56336
|
-
if (c.result === "fail" &&
|
|
56483
|
+
if (c.result === "fail" && tscOnlyIgnored(ctx.repoDir, g2.cwd, tscOut.get(c) ?? ""))
|
|
56484
|
+
pre.push(c.name);
|
|
56485
|
+
else if (c.result === "fail" && keep && tscLocalKeys(tscOut.get(c) ?? "", g2.root, keep, [...keep]) && tscUntouchedLocal(tscOut.get(c) ?? "", g2.root, keep, [...keep], await tscOnBase(ctx, g2.cwd, signal, co)))
|
|
56337
56486
|
pre.push(c.name);
|
|
56338
56487
|
else if (c.result === "fail" && keep && untouched && lintUntouchedOn()) {
|
|
56339
56488
|
const syms = diffSymbols(ctx, [...keep]), o = tscOut.get(c) ?? "";
|
|
@@ -56686,8 +56835,9 @@ var init_verify = __esm(() => {
|
|
|
56686
56835
|
return [...testFileWeakened(ctx.repoDir, ctx.baseSha, null, t.path, "M", intake?.task ?? "") ? [`weakened test: ${t.path}`] : [], ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
|
|
56687
56836
|
});
|
|
56688
56837
|
const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n3) => `skipped or fewer tests than base: ${n3}`), ...collateralRed.map((n3) => `${COLLATERAL_RED}: ${n3}`), ...preRed.quiet.filter((n3) => preRed.names.includes(n3)).map((n3) => `${QUIET_RED}: ${n3}`)];
|
|
56838
|
+
const fullChecks = checks.filter((c) => c.name.startsWith("full suite")), fullSuiteRan = fullChecks.length > 0 && fullChecks.every((c) => c.result === "pass" || c.result === "fail");
|
|
56689
56839
|
const depsNotes = unusedInstallNotes(intake?.deps_not_proven ?? [], api, changed, checks.map((c) => c.name), ctx.repoDir);
|
|
56690
|
-
const notProven2 = [...complete ? [] : [QUICK_ONLY_NOTE], ...preRed.envCrash.map((e) => `${e.name}: ${BCE_REASON} (${e.sig})`), ...weakened, ...hiddenEdits(ctx.repoDir), ...ignoreRuleChanges(ctx.repoDir, intake?.ignore_snapshot, ctx.baseSha), ...dependentNotes(dep), ...depsNotes.cap, ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n3) => !naNote(n3)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
|
|
56840
|
+
const notProven2 = [...complete ? [] : [QUICK_ONLY_NOTE], ...preRed.envCrash.map((e) => `${e.name}: ${BCE_REASON} (${e.sig})`), ...weakened, ...hiddenEdits(ctx.repoDir), ...ignoreRuleChanges(ctx.repoDir, intake?.ignore_snapshot, ctx.baseSha), ...dependentNotes(dep).filter((n3) => !(fullSuiteRan && n3.startsWith("reverse-dependent tests dropped"))), ...depsNotes.cap, ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n3) => !naNote(n3)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
|
|
56691
56841
|
const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
56692
56842
|
notProven2.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
|
|
56693
56843
|
const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallFailTail = writeWallFailureTail(ctx.runDir, checks.filter((c) => wallNames.has(c.name) && c.result === "fail" && !isHold(c) && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, out: failTails.get(c) ?? "" }))), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
|
|
@@ -56701,7 +56851,7 @@ var init_verify = __esm(() => {
|
|
|
56701
56851
|
});
|
|
56702
56852
|
|
|
56703
56853
|
// ../../loki-ts/src/runner/stop_checks.ts
|
|
56704
|
-
import { appendFileSync as appendFileSync15, existsSync as existsSync109, mkdirSync as
|
|
56854
|
+
import { appendFileSync as appendFileSync15, existsSync as existsSync109, mkdirSync as mkdirSync82, readFileSync as readFileSync142, statSync as statSync47 } from "fs";
|
|
56705
56855
|
import { basename as basename44, isAbsolute as isAbsolute22, join as join154, relative as relative33 } from "path";
|
|
56706
56856
|
function redOnBase(repoDir) {
|
|
56707
56857
|
try {
|
|
@@ -56755,9 +56905,9 @@ function recordStopBlock(repoDir, name, err, env = process.env) {
|
|
|
56755
56905
|
return;
|
|
56756
56906
|
try {
|
|
56757
56907
|
const p = stopBlocksPath(repoDir);
|
|
56758
|
-
if (existsSync109(p) &&
|
|
56908
|
+
if (existsSync109(p) && statSync47(p).size >= STOP_BLOCKS_MAX_BYTES)
|
|
56759
56909
|
return;
|
|
56760
|
-
|
|
56910
|
+
mkdirSync82(join154(repoDir, ".loki", "state"), { recursive: true });
|
|
56761
56911
|
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) }) + `
|
|
56762
56912
|
`);
|
|
56763
56913
|
} catch {}
|
|
@@ -56807,8 +56957,8 @@ var init_stop_checks = __esm(() => {
|
|
|
56807
56957
|
});
|
|
56808
56958
|
|
|
56809
56959
|
// ../../loki-ts/src/runner/provider_opencode.ts
|
|
56810
|
-
import { mkdirSync as
|
|
56811
|
-
import { dirname as
|
|
56960
|
+
import { mkdirSync as mkdirSync83 } from "fs";
|
|
56961
|
+
import { dirname as dirname65 } from "path";
|
|
56812
56962
|
function buildOpencodeArgv(prompt, env = process.env) {
|
|
56813
56963
|
const cliOverride = env["LOKI_OPENCODE_CLI"];
|
|
56814
56964
|
const cli = cliOverride && cliOverride.length > 0 ? cliOverride : "opencode";
|
|
@@ -56829,7 +56979,7 @@ function opencodeProvider() {
|
|
|
56829
56979
|
return {
|
|
56830
56980
|
async invoke(call) {
|
|
56831
56981
|
const r = await run(buildOpencodeArgv(call.prompt), { cwd: call.cwd });
|
|
56832
|
-
|
|
56982
|
+
mkdirSync83(dirname65(call.iterationOutputPath), { recursive: true });
|
|
56833
56983
|
await Bun.write(call.iterationOutputPath, r.stderr.length > 0 ? `${r.stderr}
|
|
56834
56984
|
${r.stdout}` : r.stdout);
|
|
56835
56985
|
return { exitCode: r.exitCode, capturedOutputPath: call.iterationOutputPath };
|
|
@@ -98015,8 +98165,8 @@ __export(exports_providers, {
|
|
|
98015
98165
|
SDK_BUNDLED_CLAUDE_CODE: () => SDK_BUNDLED_CLAUDE_CODE,
|
|
98016
98166
|
PROVIDER_COMMIT_HYGIENE: () => PROVIDER_COMMIT_HYGIENE
|
|
98017
98167
|
});
|
|
98018
|
-
import { mkdirSync as
|
|
98019
|
-
import { delimiter as delimiter5, dirname as
|
|
98168
|
+
import { mkdirSync as mkdirSync85, existsSync as existsSync111, readFileSync as readFileSync144, realpathSync as realpathSync46, appendFileSync as appendFileSync17 } from "fs";
|
|
98169
|
+
import { delimiter as delimiter5, dirname as dirname67, isAbsolute as isAbsolute24, relative as relative34, resolve as resolve41, sep as sep26 } from "path";
|
|
98020
98170
|
function mergeDisallowedTools(policy, stageCsv) {
|
|
98021
98171
|
return [...new Set([...policy ?? [], ...stageCsv.split(",").filter(Boolean)])];
|
|
98022
98172
|
}
|
|
@@ -98159,14 +98309,14 @@ function applyMaxTierCeiling(tier, model) {
|
|
|
98159
98309
|
}
|
|
98160
98310
|
}
|
|
98161
98311
|
function ensureParentDir(path) {
|
|
98162
|
-
const parent =
|
|
98312
|
+
const parent = dirname67(path);
|
|
98163
98313
|
if (!parent || parent === "." || parent === "/")
|
|
98164
98314
|
return;
|
|
98165
|
-
|
|
98315
|
+
mkdirSync85(parent, { recursive: true });
|
|
98166
98316
|
}
|
|
98167
98317
|
function physicalPath(path) {
|
|
98168
98318
|
try {
|
|
98169
|
-
return
|
|
98319
|
+
return realpathSync46(path);
|
|
98170
98320
|
} catch {
|
|
98171
98321
|
return resolve41(path);
|
|
98172
98322
|
}
|
|
@@ -98356,7 +98506,7 @@ function providerCallTimeoutMs(env) {
|
|
|
98356
98506
|
function emitSdkDegradationEvent(cwd, payload) {
|
|
98357
98507
|
try {
|
|
98358
98508
|
const lokiRoot = process.env["LOKI_DIR"] ?? resolve41(cwd, ".loki");
|
|
98359
|
-
|
|
98509
|
+
mkdirSync85(lokiRoot, { recursive: true });
|
|
98360
98510
|
const record = {
|
|
98361
98511
|
type: "capability_degraded",
|
|
98362
98512
|
source: "sdk_loop",
|
|
@@ -98629,8 +98779,8 @@ __export(exports_session, {
|
|
|
98629
98779
|
CONNECTION_ENV: () => CONNECTION_ENV
|
|
98630
98780
|
});
|
|
98631
98781
|
import { spawn as spawn12 } from "child_process";
|
|
98632
|
-
import { copyFileSync as copyFileSync11, existsSync as existsSync112, mkdirSync as
|
|
98633
|
-
import { dirname as
|
|
98782
|
+
import { copyFileSync as copyFileSync11, existsSync as existsSync112, mkdirSync as mkdirSync86, readFileSync as readFileSync145, writeFileSync as writeFileSync84, writeSync as writeSync4 } from "fs";
|
|
98783
|
+
import { dirname as dirname68, join as join157, resolve as resolve42 } from "path";
|
|
98634
98784
|
import { tmpdir as tmpdir33 } from "os";
|
|
98635
98785
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
98636
98786
|
function capStopOf(summary) {
|
|
@@ -98759,7 +98909,7 @@ function childEnv2(opts, cfg) {
|
|
|
98759
98909
|
env[`LOKI_CLAUDE_MODEL_${t}`] = pin;
|
|
98760
98910
|
env[`LOKI_MODEL_${t}`] = pin;
|
|
98761
98911
|
}
|
|
98762
|
-
const caps = cfg.provider === "claude" ? hooks.effort?.caps?.(opts.stage, process.env["LOKI_MODEL_OVERRIDE"] || sessionPinModel(process.env) || (pin && pin !== PROVIDER_DEFAULT_MODEL ? pin : "") || opts.model || cfg.model || resolveModel(cfg.provider)) : undefined;
|
|
98912
|
+
const caps = cfg.provider === "claude" && env["LOKI_E10_FULL_SESSION"] !== "1" ? hooks.effort?.caps?.(opts.stage, process.env["LOKI_MODEL_OVERRIDE"] || sessionPinModel(process.env) || (pin && pin !== PROVIDER_DEFAULT_MODEL ? pin : "") || opts.model || cfg.model || resolveModel(cfg.provider)) : undefined;
|
|
98763
98913
|
if (caps)
|
|
98764
98914
|
env["LOKI_E10_STOP_RULES"] = JSON.stringify(caps);
|
|
98765
98915
|
else
|
|
@@ -98787,17 +98937,17 @@ function recordCost(cfg, opts, status, durationS, outText = "") {
|
|
|
98787
98937
|
const ownRoot = join157(opts.cwd ?? process.cwd(), ".loki");
|
|
98788
98938
|
const own = resultCostPath(ownRoot, opts.iterationId), dest = resultCostPath(cfg.lokiRoot, opts.iterationId);
|
|
98789
98939
|
if (own !== dest && existsSync112(own)) {
|
|
98790
|
-
|
|
98940
|
+
mkdirSync86(dirname68(dest), { recursive: true });
|
|
98791
98941
|
copyFileSync11(own, dest);
|
|
98792
98942
|
}
|
|
98793
98943
|
const ownPartial = partialUsagePath(ownRoot, opts.iterationId), destPartial = partialUsagePath(cfg.lokiRoot, opts.iterationId);
|
|
98794
98944
|
if (ownPartial !== destPartial && existsSync112(ownPartial)) {
|
|
98795
|
-
|
|
98945
|
+
mkdirSync86(dirname68(destPartial), { recursive: true });
|
|
98796
98946
|
copyFileSync11(ownPartial, destPartial);
|
|
98797
98947
|
}
|
|
98798
98948
|
const model = opts.model ?? cfg.model ?? resolveModel(cfg.provider);
|
|
98799
98949
|
if (process.env["LOKI_E10_INVOKER"] === "cli" && cfg.provider === "claude" && status !== "killed" && !existsSync112(dest)) {
|
|
98800
|
-
|
|
98950
|
+
mkdirSync86(dirname68(dest), { recursive: true });
|
|
98801
98951
|
writeFileSync84(dest, JSON.stringify({ total_cost_usd: 0, input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_creation_tokens: 0, model, source: UNMETERED }));
|
|
98802
98952
|
}
|
|
98803
98953
|
const pcost = existsSync112(dest) ? null : writeProviderCost(dest, cfg.provider, model, opts.brief, outText);
|
|
@@ -99207,21 +99357,21 @@ var init_model_downgrades = __esm(() => {
|
|
|
99207
99357
|
});
|
|
99208
99358
|
|
|
99209
99359
|
// ../../loki-ts/src/util/run_shape.ts
|
|
99210
|
-
import { existsSync as existsSync114, mkdirSync as
|
|
99360
|
+
import { existsSync as existsSync114, mkdirSync as mkdirSync87, writeFileSync as writeFileSync85 } from "fs";
|
|
99211
99361
|
import { join as join159 } from "path";
|
|
99212
99362
|
function recordRunShape(runDir, model) {
|
|
99213
99363
|
try {
|
|
99214
99364
|
const p = join159(runDir, "project-model.answer.json");
|
|
99215
99365
|
if (existsSync114(p))
|
|
99216
99366
|
return;
|
|
99217
|
-
|
|
99367
|
+
mkdirSync87(runDir, { recursive: true });
|
|
99218
99368
|
writeFileSync85(p, JSON.stringify(model));
|
|
99219
99369
|
} catch {}
|
|
99220
99370
|
}
|
|
99221
99371
|
var init_run_shape = () => {};
|
|
99222
99372
|
|
|
99223
99373
|
// ../../loki-ts/src/project_model/discover.ts
|
|
99224
|
-
import { existsSync as existsSync115, mkdirSync as
|
|
99374
|
+
import { existsSync as existsSync115, mkdirSync as mkdirSync88, readFileSync as readFileSync147, rmSync as rmSync52, writeFileSync as writeFileSync86 } from "fs";
|
|
99225
99375
|
import { join as join160 } from "path";
|
|
99226
99376
|
function projectModelEnabled(env = process.env) {
|
|
99227
99377
|
return env["LOKI_E10_PROJECT_MODEL"] !== "0";
|
|
@@ -99277,7 +99427,7 @@ function saveShared(repoDir, model) {
|
|
|
99277
99427
|
function save3(repoDir, model) {
|
|
99278
99428
|
if (isGitTracked(repoDir, PROJECT_FILE))
|
|
99279
99429
|
return;
|
|
99280
|
-
|
|
99430
|
+
mkdirSync88(join160(repoDir, ".loki"), { recursive: true });
|
|
99281
99431
|
writeFileSync86(join160(repoDir, PROJECT_FILE), `${JSON.stringify(model, null, 2)}
|
|
99282
99432
|
`);
|
|
99283
99433
|
}
|
|
@@ -99370,7 +99520,7 @@ async function discoverProjectModel(ctx, signal, opts = {}) {
|
|
|
99370
99520
|
}
|
|
99371
99521
|
const deadline = Date.now() + (opts.budgetS ?? Infinity) * 1000;
|
|
99372
99522
|
const g10 = gather(ctx.repoDir);
|
|
99373
|
-
|
|
99523
|
+
mkdirSync88(ctx.runDir, { recursive: true });
|
|
99374
99524
|
const answerPath = join160(ctx.runDir, "project-model.answer.json");
|
|
99375
99525
|
let errors2 = null;
|
|
99376
99526
|
let lastModel;
|
|
@@ -99589,9 +99739,9 @@ var init_python_build_check = __esm(() => {
|
|
|
99589
99739
|
// ../../loki-ts/src/util/check_result.ts
|
|
99590
99740
|
import { spawn as spawn13, spawnSync as spawnSync27 } from "child_process";
|
|
99591
99741
|
import { createHash as createHash38 } from "crypto";
|
|
99592
|
-
import { copyFileSync as copyFileSync12, existsSync as existsSync116, lstatSync as lstatSync35, mkdirSync as
|
|
99742
|
+
import { copyFileSync as copyFileSync12, existsSync as existsSync116, lstatSync as lstatSync35, mkdirSync as mkdirSync89, readlinkSync as readlinkSync10, mkdtempSync as mkdtempSync27, readdirSync as readdirSync54, readFileSync as readFileSync148, realpathSync as realpathSync47, renameSync as renameSync28, rmSync as rmSync53, statSync as statSync49, writeFileSync as writeFileSync87 } from "fs";
|
|
99593
99743
|
import { homedir as homedir15, tmpdir as tmpdir34 } from "os";
|
|
99594
|
-
import { basename as basename46, dirname as
|
|
99744
|
+
import { basename as basename46, dirname as dirname69, isAbsolute as isAbsolute25, join as join162, normalize as normalize9, relative as relative35, resolve as resolve43, sep as sep27 } from "path";
|
|
99595
99745
|
function plainTestEnv(base2 = process.env) {
|
|
99596
99746
|
const e10 = {};
|
|
99597
99747
|
for (const [k10, v10] of Object.entries(tokenFreeEnv(base2)))
|
|
@@ -99753,7 +99903,7 @@ function plannedGoDir(repoDir, texts) {
|
|
|
99753
99903
|
for (const t of texts)
|
|
99754
99904
|
for (const sentence of t.split(/(?<=[.!?])\s+|\n+/))
|
|
99755
99905
|
for (const m of sentence.matchAll(GO_SRC)) {
|
|
99756
|
-
const stem2 = goRel(m[1]), rel =
|
|
99906
|
+
const stem2 = goRel(m[1]), rel = dirname69(`${stem2}.go`), base2 = stem2.split("/").pop();
|
|
99757
99907
|
if (stem2.endsWith("_test") || base2.startsWith("_") || base2.startsWith(".") || rel !== "." && goIgnoredPath(rel))
|
|
99758
99908
|
continue;
|
|
99759
99909
|
const dir = join162(repoDir, rel === "." ? "" : rel);
|
|
@@ -100005,7 +100155,7 @@ function cargoRunnerConfigured(cwd, env, toks2) {
|
|
|
100005
100155
|
return true;
|
|
100006
100156
|
}
|
|
100007
100157
|
const dirs = [env["CARGO_HOME"] ?? join162(env["HOME"] ?? homedir15(), ".cargo"), join162(homedir15(), ".cargo")];
|
|
100008
|
-
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d =
|
|
100158
|
+
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d = dirname69(d))
|
|
100009
100159
|
dirs.push(join162(d, ".cargo"));
|
|
100010
100160
|
return dirs.some((dir) => ["config", "config.toml"].some((f) => existsSync116(join162(dir, f)) && doubtful(join162(dir, f))));
|
|
100011
100161
|
}
|
|
@@ -100024,7 +100174,7 @@ function cargoToolchainRedirected(cwd, env) {
|
|
|
100024
100174
|
return true;
|
|
100025
100175
|
}
|
|
100026
100176
|
};
|
|
100027
|
-
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d =
|
|
100177
|
+
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d = dirname69(d))
|
|
100028
100178
|
if (["rust-toolchain", "rust-toolchain.toml"].some((f) => lstatOk(join162(d, f)) && doubtful(join162(d, f))))
|
|
100029
100179
|
return true;
|
|
100030
100180
|
return false;
|
|
@@ -100093,7 +100243,7 @@ function compilerSettingIn(raw2) {
|
|
|
100093
100243
|
}
|
|
100094
100244
|
function cargoRepoRoot(cwd) {
|
|
100095
100245
|
let top = null;
|
|
100096
|
-
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d =
|
|
100246
|
+
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d = dirname69(d)) {
|
|
100097
100247
|
if (existsSync116(join162(d, ".git")))
|
|
100098
100248
|
return d;
|
|
100099
100249
|
if (existsSync116(join162(d, "Cargo.toml")))
|
|
@@ -100148,7 +100298,7 @@ function cargoProfileRustflagsManifest(root, cwd, toks2) {
|
|
|
100148
100298
|
}
|
|
100149
100299
|
};
|
|
100150
100300
|
const seen = new Set, files = [];
|
|
100151
|
-
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d =
|
|
100301
|
+
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d = dirname69(d)) {
|
|
100152
100302
|
files.push(join162(d, "Cargo.toml"));
|
|
100153
100303
|
if (d === root)
|
|
100154
100304
|
break;
|
|
@@ -100206,10 +100356,10 @@ function cargoRepoCompilerRedirected(cwd, env, toks2) {
|
|
|
100206
100356
|
}
|
|
100207
100357
|
const home = new Set([resolve43(env["CARGO_HOME"] || join162(env["HOME"] || homedir15(), ".cargo")), resolve43(homedir15(), ".cargo")]);
|
|
100208
100358
|
const aboveRoot = (dir) => {
|
|
100209
|
-
const r = relative35(
|
|
100359
|
+
const r = relative35(dirname69(dir), root);
|
|
100210
100360
|
return r !== "" && !r.startsWith("..") && !isAbsolute25(r);
|
|
100211
100361
|
};
|
|
100212
|
-
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d =
|
|
100362
|
+
for (let d = resolve43(cwd), prev = "";d !== prev; prev = d, d = dirname69(d)) {
|
|
100213
100363
|
const dir = join162(d, ".cargo");
|
|
100214
100364
|
if (home.has(dir) && aboveRoot(dir))
|
|
100215
100365
|
continue;
|
|
@@ -101035,7 +101185,7 @@ function wallPathProblem(repoDir, relPath) {
|
|
|
101035
101185
|
if (isAbsolute25(rel) || rel.split(sep27).includes(".."))
|
|
101036
101186
|
return `Wall path outside the repo: ${relPath}`;
|
|
101037
101187
|
let cur = repoDir;
|
|
101038
|
-
for (const part of
|
|
101188
|
+
for (const part of dirname69(rel) === "." ? [] : dirname69(rel).split(sep27)) {
|
|
101039
101189
|
cur = join162(cur, part);
|
|
101040
101190
|
try {
|
|
101041
101191
|
const st2 = lstatSync35(cur);
|
|
@@ -101119,9 +101269,9 @@ function sparseExcluded(repoDir, tmp, paths) {
|
|
|
101119
101269
|
return new Set;
|
|
101120
101270
|
const rel = safeGit(repoDir, ["rev-parse", "--git-path", "info/sparse-checkout"]).trim(), pf2 = isAbsolute25(rel) ? rel : join162(repoDir, rel);
|
|
101121
101271
|
const scratch = join162(tmp, "sparse");
|
|
101122
|
-
|
|
101272
|
+
mkdirSync89(scratch);
|
|
101123
101273
|
safeGit(scratch, ["init", "-q"]);
|
|
101124
|
-
|
|
101274
|
+
mkdirSync89(join162(scratch, ".git", "info"), { recursive: true });
|
|
101125
101275
|
copyFileSync12(pf2, join162(scratch, ".git", "info", "exclude"));
|
|
101126
101276
|
const r = safeGitSpawn(scratch, ["-c", "core.ignorecase=false", "-c", "core.excludesFile=/dev/null", "check-ignore", "--no-index", "-z", "--stdin"], { input: Buffer.from(paths.map((p) => `${p}\x00`).join("")) });
|
|
101127
101277
|
if (r.error || r.status !== 0 && r.status !== 1)
|
|
@@ -101137,7 +101287,7 @@ function hiddenEdits(repoDir) {
|
|
|
101137
101287
|
try {
|
|
101138
101288
|
const idxRel = safeGit(repoDir, ["rev-parse", "--git-path", "index"]).trim(), idx = isAbsolute25(idxRel) ? idxRel : join162(repoDir, idxRel);
|
|
101139
101289
|
const flags = new Map;
|
|
101140
|
-
for (const l of safeGit(repoDir, ["-c", "core.quotePath=false", "ls-files", "-v", "-z"], { maxBuffer: Math.max(64 << 20,
|
|
101290
|
+
for (const l of safeGit(repoDir, ["-c", "core.quotePath=false", "ls-files", "-v", "-z"], { maxBuffer: Math.max(64 << 20, statSync49(idx).size * 32) }).split("\x00")) {
|
|
101141
101291
|
const m = /^([a-zS]) ([\s\S]+)$/.exec(l);
|
|
101142
101292
|
if (m)
|
|
101143
101293
|
flags.set(m[2], m[1]);
|
|
@@ -101182,10 +101332,10 @@ function execFiles(repoDir) {
|
|
|
101182
101332
|
} catch {
|
|
101183
101333
|
return null;
|
|
101184
101334
|
}
|
|
101185
|
-
const roots = new Set([".venv", "venv", ...all.filter((f) => basename46(f) === "pyvenv.cfg").map((f) =>
|
|
101335
|
+
const roots = new Set([".venv", "venv", ...all.filter((f) => basename46(f) === "pyvenv.cfg").map((f) => dirname69(f))]);
|
|
101186
101336
|
const inVenvBin = (f) => {
|
|
101187
|
-
for (let d =
|
|
101188
|
-
if ((basename46(d) === "bin" || basename46(d) === "Scripts") && roots.has(
|
|
101337
|
+
for (let d = dirname69(f);d !== "." && d !== "/"; d = dirname69(d))
|
|
101338
|
+
if ((basename46(d) === "bin" || basename46(d) === "Scripts") && roots.has(dirname69(d)))
|
|
101189
101339
|
return true;
|
|
101190
101340
|
return false;
|
|
101191
101341
|
};
|
|
@@ -101254,7 +101404,7 @@ function pureToolCache(repoDir, dir) {
|
|
|
101254
101404
|
return false;
|
|
101255
101405
|
continue;
|
|
101256
101406
|
}
|
|
101257
|
-
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) || (
|
|
101407
|
+
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) || (statSync49(join162(repoDir, r)).mode & 73) !== 0)
|
|
101258
101408
|
return false;
|
|
101259
101409
|
}
|
|
101260
101410
|
return true;
|
|
@@ -101287,7 +101437,7 @@ function ignoreRuleChanges(repoDir, snap, baseSha) {
|
|
|
101287
101437
|
for (const [f, h10] of Object.entries(cur)) {
|
|
101288
101438
|
if (prior[f] === h10)
|
|
101289
101439
|
continue;
|
|
101290
|
-
if (basename46(f) === ".gitignore" && pureToolCache(repoDir,
|
|
101440
|
+
if (basename46(f) === ".gitignore" && pureToolCache(repoDir, dirname69(f)))
|
|
101291
101441
|
continue;
|
|
101292
101442
|
if (basename46(f) === ".gitignore")
|
|
101293
101443
|
gi2.add(f);
|
|
@@ -101302,7 +101452,7 @@ function ignoreRuleChanges(repoDir, snap, baseSha) {
|
|
|
101302
101452
|
return [];
|
|
101303
101453
|
const made = listIgnoredFiles(repoDir).filter((f) => {
|
|
101304
101454
|
try {
|
|
101305
|
-
const st2 =
|
|
101455
|
+
const st2 = statSync49(join162(repoDir, f));
|
|
101306
101456
|
return Math.max(st2.birthtimeMs, st2.mtimeMs) >= s.at;
|
|
101307
101457
|
} catch {
|
|
101308
101458
|
return false;
|
|
@@ -101386,7 +101536,7 @@ function diffFiles(repoDir, baseSha, skip2) {
|
|
|
101386
101536
|
function recordRisk(repoDir, a) {
|
|
101387
101537
|
try {
|
|
101388
101538
|
const dir = join162(repoDir, ".loki", "state"), p = join162(dir, "risk-tier.json");
|
|
101389
|
-
|
|
101539
|
+
mkdirSync89(dir, { recursive: true });
|
|
101390
101540
|
writeFileSync87(`${p}.tmp`, JSON.stringify(a, null, 2) + `
|
|
101391
101541
|
`);
|
|
101392
101542
|
renameSync28(`${p}.tmp`, p);
|
|
@@ -101443,7 +101593,7 @@ function pytestCollectionIsRed(output, repoDir) {
|
|
|
101443
101593
|
return moduleToBeCreated(output, repoDir);
|
|
101444
101594
|
const real4 = (p) => {
|
|
101445
101595
|
try {
|
|
101446
|
-
return
|
|
101596
|
+
return realpathSync47(isAbsolute25(p) ? p : join162(repoDir, p));
|
|
101447
101597
|
} catch {
|
|
101448
101598
|
return null;
|
|
101449
101599
|
}
|
|
@@ -101638,11 +101788,11 @@ function missingRelativeImportIsRed(f, raw2, repoDir) {
|
|
|
101638
101788
|
return hits.every(({ spec, importer }) => {
|
|
101639
101789
|
if (!/^\.\.?(?:\/|$)/.test(spec) || !(abs === importer || abs.endsWith("/" + importer.replace(/^\.\//, "")) || importer.endsWith("/" + f.path) || importer === f.path))
|
|
101640
101790
|
return false;
|
|
101641
|
-
const target = resolve43(
|
|
101791
|
+
const target = resolve43(dirname69(abs), spec.replace(/[?#].*$/, ""));
|
|
101642
101792
|
const stem2 = target.replace(/\.(?:jsx?|mjs|cjs)$/, "");
|
|
101643
|
-
if (existsSync116(target) &&
|
|
101793
|
+
if (existsSync116(target) && statSync49(target).isDirectory())
|
|
101644
101794
|
return false;
|
|
101645
|
-
return ![target, stem2].some((t) => ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".json"].some((x10) => existsSync116(t + x10) &&
|
|
101795
|
+
return ![target, stem2].some((t) => ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".json"].some((x10) => existsSync116(t + x10) && statSync49(t + x10).isFile())) && !["ts", "tsx", "js", "jsx", "mjs", "cjs"].some((x10) => existsSync116(join162(target, `index.${x10}`)));
|
|
101646
101796
|
});
|
|
101647
101797
|
}
|
|
101648
101798
|
function classify(f, status, output, repoDir, interpreter) {
|
|
@@ -101978,7 +102128,7 @@ function toolFallbacks(repoDir, tool, env = process.env) {
|
|
|
101978
102128
|
function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
|
|
101979
102129
|
const inRepo2 = (p) => {
|
|
101980
102130
|
try {
|
|
101981
|
-
const r = relative35(
|
|
102131
|
+
const r = relative35(realpathSync47(repoDir), realpathSync47(p));
|
|
101982
102132
|
return r !== "" && !r.startsWith("..") && !isAbsolute25(r);
|
|
101983
102133
|
} catch {
|
|
101984
102134
|
return false;
|
|
@@ -102024,7 +102174,7 @@ function runnerCmd(t, repoDir) {
|
|
|
102024
102174
|
return ["npm", ["test", "--silent"]];
|
|
102025
102175
|
case "go": {
|
|
102026
102176
|
const names = goTestNames(join162(repoDir, t.path));
|
|
102027
|
-
return ["go", ["test", "-json", ...names.length ? ["-run", `^(${names.join("|")})$`] : [], `./${
|
|
102177
|
+
return ["go", ["test", "-json", ...names.length ? ["-run", `^(${names.join("|")})$`] : [], `./${dirname69(t.path)}`]];
|
|
102028
102178
|
}
|
|
102029
102179
|
case "maven": {
|
|
102030
102180
|
const j10 = javaTestClass(t.path);
|
|
@@ -102061,7 +102211,7 @@ function fullSuiteCmd(runner, repoDir) {
|
|
|
102061
102211
|
}
|
|
102062
102212
|
function ownVitestSite(repoDir, path) {
|
|
102063
102213
|
const cfg = /^vite(st)?\.config\.(?:[cm]?[jt]s|mts)$/;
|
|
102064
|
-
for (let d =
|
|
102214
|
+
for (let d = dirname69(path);d !== "." && d !== "" && d !== "/" && !d.startsWith(".."); d = dirname69(d)) {
|
|
102065
102215
|
try {
|
|
102066
102216
|
const abs = join162(repoDir, d);
|
|
102067
102217
|
if (!existsSync116(join162(abs, "package.json")))
|
|
@@ -102096,11 +102246,11 @@ function commandFor(t, repoDir, api) {
|
|
|
102096
102246
|
return { cwd: mod === base2 ? base2 : mod, cmd: cmd2, args, argv: [cmd2, ...args], ...interpreter ? { interpreter } : {}, pkgRoot: mod === base2 ? site?.root ?? "." : relative35(repoDir, mod) || "." };
|
|
102097
102247
|
}
|
|
102098
102248
|
function goModDir(base2, rel) {
|
|
102099
|
-
let d =
|
|
102249
|
+
let d = dirname69(join162(base2, rel));
|
|
102100
102250
|
while (d !== base2 && relative35(base2, d) !== "" && !relative35(base2, d).startsWith("..")) {
|
|
102101
102251
|
if (existsSync116(join162(d, "go.mod")))
|
|
102102
102252
|
return d;
|
|
102103
|
-
d =
|
|
102253
|
+
d = dirname69(d);
|
|
102104
102254
|
}
|
|
102105
102255
|
return base2;
|
|
102106
102256
|
}
|
|
@@ -102235,11 +102385,11 @@ async function publishWall(git15, runId2, repoDir, files, done) {
|
|
|
102235
102385
|
for (const f of files) {
|
|
102236
102386
|
const abs = join162(repoDir, f.rel);
|
|
102237
102387
|
try {
|
|
102238
|
-
if (!
|
|
102388
|
+
if (!realpathSync47(dirname69(abs)).startsWith(realpathSync47(repoDir)))
|
|
102239
102389
|
return false;
|
|
102240
102390
|
} catch {}
|
|
102241
102391
|
rmSync53(abs, { force: true });
|
|
102242
|
-
|
|
102392
|
+
mkdirSync89(dirname69(abs), { recursive: true });
|
|
102243
102393
|
writeFileSync87(abs, f.bytes);
|
|
102244
102394
|
}
|
|
102245
102395
|
if ((await git15(["--literal-pathspecs", "add", "--", ...rels])).code !== 0 || (await git15(["--literal-pathspecs", "commit", "-q", "-m", "test: loki acceptance checks (Wall)", "-m", `Loki-Wall-Publish: ${runId2}
|
|
@@ -102503,8 +102653,8 @@ var init_check_result = __esm(() => {
|
|
|
102503
102653
|
});
|
|
102504
102654
|
|
|
102505
102655
|
// ../../loki-ts/src/council/finding_schema.ts
|
|
102506
|
-
import { existsSync as existsSync117, readdirSync as readdirSync55, readFileSync as readFileSync149, statSync as
|
|
102507
|
-
import { resolve as resolvePath3, dirname as
|
|
102656
|
+
import { existsSync as existsSync117, readdirSync as readdirSync55, readFileSync as readFileSync149, statSync as statSync50 } from "fs";
|
|
102657
|
+
import { resolve as resolvePath3, dirname as dirname70, relative as relative36, isAbsolute as isAbsolute26, join as join163, sep as sep28 } from "path";
|
|
102508
102658
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
102509
102659
|
function resolveSchemaDataDir(moduleDir = _moduleDir, candidates2 = SCHEMA_DATA_DIR_CANDIDATES) {
|
|
102510
102660
|
for (const rel of candidates2) {
|
|
@@ -102581,7 +102731,7 @@ function isRecord(v10) {
|
|
|
102581
102731
|
var _moduleDir, SCHEMA_DATA_DIR_CANDIDATES, _dataDir, _schemaPath, FINDING_SCHEMA, SchemaLiteralError, _static = null, VOTE_ENUM, SEVERITY_ENUM, BLOCKING_SEVERITY, ANCHOR_EXEMPT_ROLES, MAX_CITATION_FILE_BYTES, SKIP_DIRS5, treeFiles;
|
|
102582
102732
|
var init_finding_schema = __esm(() => {
|
|
102583
102733
|
init_check_result();
|
|
102584
|
-
_moduleDir =
|
|
102734
|
+
_moduleDir = dirname70(fileURLToPath6(import.meta.url));
|
|
102585
102735
|
SCHEMA_DATA_DIR_CANDIDATES = [["..", "..", "data"], ["..", "data"], ["..", "..", "..", "loki-ts", "data"]];
|
|
102586
102736
|
_dataDir = resolveSchemaDataDir();
|
|
102587
102737
|
_schemaPath = resolvePath3(_dataDir, "finding-schema.json");
|
|
@@ -109441,10 +109591,10 @@ async function setupSkills(ctx) {
|
|
|
109441
109591
|
for (const skill of session.agent.skills) {
|
|
109442
109592
|
try {
|
|
109443
109593
|
const version2 = await client.beta.skills.versions.retrieve(skill.version, { skill_id: skill.skill_id });
|
|
109444
|
-
let
|
|
109445
|
-
if (
|
|
109446
|
-
|
|
109447
|
-
const dest = path2.resolve(skillsRoot,
|
|
109594
|
+
let dirname71 = path2.basename(version2.name.trim());
|
|
109595
|
+
if (dirname71 === "" || dirname71 === "." || dirname71 === "..")
|
|
109596
|
+
dirname71 = skill.skill_id;
|
|
109597
|
+
const dest = path2.resolve(skillsRoot, dirname71);
|
|
109448
109598
|
if (dest !== skillsRoot && !dest.startsWith(skillsRoot + path2.sep)) {
|
|
109449
109599
|
log2.warn("skill name escapes the skills dir; skipping", {
|
|
109450
109600
|
component: "agent-tool-context",
|
|
@@ -125684,7 +125834,7 @@ __export(exports_opus_consult, {
|
|
|
125684
125834
|
CONSULT_MODEL_DEFAULT: () => CONSULT_MODEL_DEFAULT,
|
|
125685
125835
|
CONSULT_FILE: () => CONSULT_FILE
|
|
125686
125836
|
});
|
|
125687
|
-
import { mkdirSync as
|
|
125837
|
+
import { mkdirSync as mkdirSync90, readFileSync as readFileSync151, writeFileSync as writeFileSync88 } from "fs";
|
|
125688
125838
|
import { join as join165 } from "path";
|
|
125689
125839
|
function readConsults(runDir) {
|
|
125690
125840
|
try {
|
|
@@ -125732,7 +125882,7 @@ async function runConsult(o, env2 = process.env) {
|
|
|
125732
125882
|
const prior = readConsults(o.runDir), slot = { trigger: o.trigger, stage: o.stage, model, outcome: "started", usd: null, advice: null };
|
|
125733
125883
|
const save4 = (xs2) => {
|
|
125734
125884
|
try {
|
|
125735
|
-
|
|
125885
|
+
mkdirSync90(o.runDir, { recursive: true });
|
|
125736
125886
|
writeFileSync88(join165(o.runDir, CONSULT_FILE), JSON.stringify(xs2), "utf8");
|
|
125737
125887
|
} catch {}
|
|
125738
125888
|
};
|
|
@@ -125777,9 +125927,9 @@ var init_opus_consult = __esm(() => {
|
|
|
125777
125927
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
125778
125928
|
import { createHash as createHash39 } from "crypto";
|
|
125779
125929
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
125780
|
-
import { chmodSync as chmodSync9, existsSync as existsSync118, mkdirSync as
|
|
125930
|
+
import { chmodSync as chmodSync9, existsSync as existsSync118, mkdirSync as mkdirSync91, mkdtempSync as mkdtempSync28, readdirSync as readdirSync56, readFileSync as readFileSync152, rmSync as rmSync54, statSync as statSync51, symlinkSync as symlinkSync7, writeFileSync as writeFileSync89 } from "fs";
|
|
125781
125931
|
import { tmpdir as tmpdir36 } from "os";
|
|
125782
|
-
import { basename as basename47, dirname as
|
|
125932
|
+
import { basename as basename47, dirname as dirname72, isAbsolute as isAbsolute28, join as join166, relative as relative37 } from "path";
|
|
125783
125933
|
function answerMark(events2, assumeNext = false) {
|
|
125784
125934
|
if (assumeNext)
|
|
125785
125935
|
return events2.length;
|
|
@@ -125895,6 +126045,7 @@ function citesTestFile(text4) {
|
|
|
125895
126045
|
async function resumeToFinish(ctx, first, session, o) {
|
|
125896
126046
|
const env2 = o.env ?? process.env, ids = [], max = continueMax(env2), usdLine = continueMaxUsd(env2);
|
|
125897
126047
|
const missing = () => readPlanScope(ctx.runDir).filter((f) => !existsSync118(join166(ctx.repoDir, f)));
|
|
126048
|
+
let unchanged = 0;
|
|
125898
126049
|
let cur = session, outstanding = outstandingOf(session.summary), base2 = first, ended = max === 0 ? "continue off" : "count cap", spent = null;
|
|
125899
126050
|
for (let n10 = 1;n10 <= max; n10++) {
|
|
125900
126051
|
if (o.signal.aborted) {
|
|
@@ -125931,9 +126082,12 @@ async function resumeToFinish(ctx, first, session, o) {
|
|
|
125931
126082
|
break;
|
|
125932
126083
|
}
|
|
125933
126084
|
if (before === after) {
|
|
125934
|
-
|
|
125935
|
-
|
|
125936
|
-
|
|
126085
|
+
if (++unchanged >= 2) {
|
|
126086
|
+
ended = "tree unchanged";
|
|
126087
|
+
break;
|
|
126088
|
+
}
|
|
126089
|
+
} else
|
|
126090
|
+
unchanged = 0;
|
|
125937
126091
|
}
|
|
125938
126092
|
return { session: cur, iterationIds: ids, record: { continues: ids.length, ended, outstanding: outstanding || null, spent_usd: spent ?? o.spentUsd() } };
|
|
125939
126093
|
}
|
|
@@ -126190,7 +126344,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
126190
126344
|
declined("no copy of the base tree could be made, so red-on-base was not run");
|
|
126191
126345
|
return null;
|
|
126192
126346
|
}
|
|
126193
|
-
|
|
126347
|
+
mkdirSync91(dirname72(join166(base2, a.file)), { recursive: true });
|
|
126194
126348
|
writeFileSync89(join166(base2, a.file), next, "utf8");
|
|
126195
126349
|
const onBase = runCheck2(base2, ref);
|
|
126196
126350
|
if (onBase !== "fail") {
|
|
@@ -126200,7 +126354,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
126200
126354
|
}
|
|
126201
126355
|
f.content = next;
|
|
126202
126356
|
const sealedCopy = join166(sealedWallDir(ctx.runDir), name);
|
|
126203
|
-
if (existsSync118(
|
|
126357
|
+
if (existsSync118(dirname72(sealedCopy)))
|
|
126204
126358
|
writeFileSync89(sealedCopy, next, "utf8");
|
|
126205
126359
|
sf2.sha256 = createHash39("sha256").update(next).digest("hex");
|
|
126206
126360
|
const sealedNow = existsSync118(sealedCopy) ? readFileSync152(sealedCopy, "utf8") : null;
|
|
@@ -126272,7 +126426,7 @@ async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
|
|
|
126272
126426
|
const sf2 = o.wall?.files?.find((x10) => x10.path === f.path), sha6 = createHash39("sha256").update(next).digest("hex");
|
|
126273
126427
|
if (sf2)
|
|
126274
126428
|
sf2.sha256 = sha6;
|
|
126275
|
-
|
|
126429
|
+
mkdirSync91(sealedWallDir(ctx.runDir), { recursive: true });
|
|
126276
126430
|
writeFileSync89(sealedWallCopy(ctx.runDir, f.path), next, "utf8");
|
|
126277
126431
|
const arb = { check: a.file, test: "(whole file)", old_assertion: "(not validated)", new_assertion: "(not validated)", spec_quote: oneLine6(reason), spec_quote_2: "", sha256: sha6, kind: "legacy" };
|
|
126278
126432
|
if (o.wall)
|
|
@@ -126340,7 +126494,7 @@ async function deliverOverWallConflict(o, repoDir, reverify, emit2, opts = {}) {
|
|
|
126340
126494
|
}
|
|
126341
126495
|
}, modeOf = (p) => {
|
|
126342
126496
|
try {
|
|
126343
|
-
return
|
|
126497
|
+
return statSync51(p).mode & 4095;
|
|
126344
126498
|
} catch {
|
|
126345
126499
|
return null;
|
|
126346
126500
|
}
|
|
@@ -126427,7 +126581,7 @@ async function resumeForPrecedence(ctx, first, firstSession, env2 = process.env)
|
|
|
126427
126581
|
return none;
|
|
126428
126582
|
const sameDir = (p) => {
|
|
126429
126583
|
try {
|
|
126430
|
-
const d =
|
|
126584
|
+
const d = dirname72(p);
|
|
126431
126585
|
return readdirSync56(join166(ctx.repoDir, d)).slice(0, 60).map((f) => d === "." ? f : `${d}/${f}`);
|
|
126432
126586
|
} catch {
|
|
126433
126587
|
return [];
|
|
@@ -126607,7 +126761,7 @@ __export(exports_run_outputs, {
|
|
|
126607
126761
|
});
|
|
126608
126762
|
import { execFile as execFile3, spawnSync as spawnSync28 } from "child_process";
|
|
126609
126763
|
import { createHash as createHash40 } from "crypto";
|
|
126610
|
-
import { existsSync as existsSync119, lstatSync as lstatSync36, mkdirSync as
|
|
126764
|
+
import { existsSync as existsSync119, lstatSync as lstatSync36, mkdirSync as mkdirSync92, readdirSync as readdirSync57, readFileSync as readFileSync153, statSync as statSync52, writeFileSync as writeFileSync90 } from "fs";
|
|
126611
126765
|
import { basename as basename48, join as join167, resolve as resolve45 } from "path";
|
|
126612
126766
|
function intentRevisionsBlock(revs) {
|
|
126613
126767
|
const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
|
|
@@ -126789,7 +126943,7 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
|
|
|
126789
126943
|
} catch {
|
|
126790
126944
|
return null;
|
|
126791
126945
|
}
|
|
126792
|
-
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync119(join167(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m:
|
|
126946
|
+
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync119(join167(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync52(join167(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
|
|
126793
126947
|
const top = rows[0];
|
|
126794
126948
|
if (!top)
|
|
126795
126949
|
return null;
|
|
@@ -127439,7 +127593,7 @@ function issueStatusProjector(o) {
|
|
|
127439
127593
|
const body = issueStatusBody(events2, { runId: o.runId, steerRevs: revs, controlUrl: controlRunLink(o.env.LOKI_CONTROL_PLANE_URL || o.env.LOKI_CONTROL_URL, o.repoDir, o.runId), ...x10 }), bodyFile = join167(o.runDir, "status-comment.md"), argv = argvOf(bodyFile);
|
|
127440
127594
|
if (body === last)
|
|
127441
127595
|
return { argv, ok: true };
|
|
127442
|
-
|
|
127596
|
+
mkdirSync92(o.runDir, { recursive: true });
|
|
127443
127597
|
writeFileSync90(bodyFile, body);
|
|
127444
127598
|
const [ok2, skipped3] = await new Promise((res) => {
|
|
127445
127599
|
execFile3("bash", [o.pushSh, ...argv], { env: env2 }, (err, out3) => res([!err, /^skipped: /m.test(String(out3))]));
|
|
@@ -127574,7 +127728,7 @@ async function sealRefusal(o) {
|
|
|
127574
127728
|
const [{ SupervisorLog: SupervisorLog2 }, seal, signer, { atomicWriteText: atomicWriteText2 }, { githubRepoFromUrl: githubRepoFromUrl2 }] = await Promise.all([Promise.resolve().then(() => (init_supervisor(), exports_supervisor)), Promise.resolve().then(() => (init_seal(), exports_seal)), Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer)), Promise.resolve().then(() => (init_atomic(), exports_atomic)), Promise.resolve().then(() => (init_engine_origin(), exports_engine_origin))]);
|
|
127575
127729
|
const runId2 = `e10-${new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${Math.random().toString(16).slice(2, 6)}`;
|
|
127576
127730
|
const runDir = join167(o.repoDir, ".loki", "runs", runId2), provider = o.provider ?? "claude", repo = githubRepoFromUrl2(readOriginUrl(o.repoDir));
|
|
127577
|
-
|
|
127731
|
+
mkdirSync92(runDir, { recursive: true });
|
|
127578
127732
|
const log2 = new SupervisorLog2(join167(o.repoDir, eventsRelPath(runId2)), runId2);
|
|
127579
127733
|
log2.append("run.started", null, { task_source: "text", provider, refused: true, origin_repo: repo });
|
|
127580
127734
|
const git15 = (a) => {
|
|
@@ -127688,7 +127842,7 @@ var init_run_outputs = __esm(() => {
|
|
|
127688
127842
|
|
|
127689
127843
|
// ../../loki-ts/src/util/composite_seal.ts
|
|
127690
127844
|
import { existsSync as existsSync120, readFileSync as readFileSync154 } from "fs";
|
|
127691
|
-
import { basename as basename49, dirname as
|
|
127845
|
+
import { basename as basename49, dirname as dirname73, join as join168 } from "path";
|
|
127692
127846
|
function logProblem(runDir, integ) {
|
|
127693
127847
|
if (typeof integ["log_sha256"] !== "string")
|
|
127694
127848
|
return null;
|
|
@@ -127759,7 +127913,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
127759
127913
|
throw new Error("workspace has no repos");
|
|
127760
127914
|
return {
|
|
127761
127915
|
schema: COMPOSITE_SCHEMA,
|
|
127762
|
-
workspace: basename49(
|
|
127916
|
+
workspace: basename49(dirname73(runDir)),
|
|
127763
127917
|
run_id: basename49(runDir),
|
|
127764
127918
|
integration_sha256: sha3(ibytes),
|
|
127765
127919
|
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 },
|
|
@@ -127769,7 +127923,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
127769
127923
|
};
|
|
127770
127924
|
}
|
|
127771
127925
|
async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
127772
|
-
const runDir =
|
|
127926
|
+
const runDir = dirname73(receiptPath);
|
|
127773
127927
|
const signed = isObj10(receipt["verification"]) && typeof receipt["verification"]["jwt"] === "string";
|
|
127774
127928
|
const bad = (reason) => ({ problem: { verdict: "TAMPERED", reason: `composite: ${reason}` }, verdict: "FAILED" });
|
|
127775
127929
|
const deep = (what) => ({ problem: { verdict: "UNCHECKED", reason: `composite: ${what} cannot be hashed (nested too deeply)` }, verdict: "FAILED" });
|
|
@@ -127887,8 +128041,8 @@ __export(exports_verify_cmd, {
|
|
|
127887
128041
|
checkEventLog: () => checkEventLog,
|
|
127888
128042
|
checkAttestation: () => checkAttestation
|
|
127889
128043
|
});
|
|
127890
|
-
import { existsSync as existsSync121, readFileSync as readFileSync155, renameSync as renameSync29, statSync as
|
|
127891
|
-
import { basename as basename50, dirname as
|
|
128044
|
+
import { existsSync as existsSync121, readFileSync as readFileSync155, renameSync as renameSync29, statSync as statSync53, writeFileSync as writeFileSync91 } from "fs";
|
|
128045
|
+
import { basename as basename50, dirname as dirname74, join as join169 } from "path";
|
|
127892
128046
|
import { createHash as createHash41, verify as verify5 } from "crypto";
|
|
127893
128047
|
function checkAttestation(jwt, expectedHash, given) {
|
|
127894
128048
|
const bad = (reason) => ({ status: "tampered", reason });
|
|
@@ -127913,11 +128067,11 @@ function checkAttestation(jwt, expectedHash, given) {
|
|
|
127913
128067
|
}
|
|
127914
128068
|
function wallTamperProblem(receiptPath, receipt) {
|
|
127915
128069
|
const wall = receipt["wall"], files = Array.isArray(wall?.files) ? wall.files : [];
|
|
127916
|
-
const wallDir = sealedWallDir(
|
|
128070
|
+
const wallDir = sealedWallDir(dirname74(receiptPath)), haveWallDir = existsSync121(wallDir);
|
|
127917
128071
|
for (const f of files) {
|
|
127918
128072
|
if (typeof f?.path !== "string" || typeof f.sha256 !== "string")
|
|
127919
128073
|
continue;
|
|
127920
|
-
const copy = sealedWallCopy(
|
|
128074
|
+
const copy = sealedWallCopy(dirname74(receiptPath), f.path);
|
|
127921
128075
|
let cur;
|
|
127922
128076
|
try {
|
|
127923
128077
|
cur = createHash41("sha256").update(readFileSync155(copy)).digest("hex");
|
|
@@ -127947,7 +128101,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
127947
128101
|
const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
|
|
127948
128102
|
return claims ? "the receipt records stages but binds the empty-log hash, so no events.jsonl can back it (missing, empty or non-empty); the receipt is forged or was sealed without a log. Re-run the task to produce a fresh receipt" : null;
|
|
127949
128103
|
}
|
|
127950
|
-
const path4 = join169(
|
|
128104
|
+
const path4 = join169(dirname74(receiptPath), "events.jsonl");
|
|
127951
128105
|
if (!existsSync121(path4))
|
|
127952
128106
|
return "events.jsonl is missing";
|
|
127953
128107
|
const raw2 = readFileSync155(path4, "utf8"), events2 = readEvents(path4), all = raw2.split(`
|
|
@@ -127980,7 +128134,7 @@ function resumeCheckpointOk(events2, done, i) {
|
|
|
127980
128134
|
return m > done && isAnsweredResume(events2[m]);
|
|
127981
128135
|
}
|
|
127982
128136
|
function checkLogSeal(receiptPath, hash, kid, given) {
|
|
127983
|
-
const path4 = join169(
|
|
128137
|
+
const path4 = join169(dirname74(receiptPath), "events.jsonl"), events2 = readEvents(path4), done = events2.findLastIndex((e10) => e10.type === "run.completed");
|
|
127984
128138
|
const rs2 = events2.findIndex((e10) => e10.type === "receipt.sealed" && e10.data["receipt_sha256"] === hash);
|
|
127985
128139
|
if (rs2 < 0)
|
|
127986
128140
|
return { verdict: "TAMPERED", reason: "events.jsonl has no receipt.sealed event for this receipt" };
|
|
@@ -128205,7 +128359,7 @@ ${/^(unknown option|expected at most one)/.test(pk.error) ? `Usage: loki verify
|
|
|
128205
128359
|
if (!runId2)
|
|
128206
128360
|
return process.stderr.write(`loki verify: no runs found
|
|
128207
128361
|
`), 66;
|
|
128208
|
-
const isFile2 = existsSync121(runId2) &&
|
|
128362
|
+
const isFile2 = existsSync121(runId2) && statSync53(runId2).isFile();
|
|
128209
128363
|
const isPath = isFile2 || /[\\/]/.test(runId2) || runId2.endsWith(".json");
|
|
128210
128364
|
const receiptPath = isPath ? runId2 : join169(runsRoot2, runId2, "receipt.json");
|
|
128211
128365
|
const byRunId = !isPath;
|
|
@@ -128351,7 +128505,7 @@ var init_verify_cmd = __esm(() => {
|
|
|
128351
128505
|
});
|
|
128352
128506
|
|
|
128353
128507
|
// src/server/app.ts
|
|
128354
|
-
import { existsSync as existsSync124, readFileSync as readFileSync159, statSync as
|
|
128508
|
+
import { existsSync as existsSync124, readFileSync as readFileSync159, statSync as statSync55 } from "fs";
|
|
128355
128509
|
import { join as join173, resolve as resolve47, sep as sep31 } from "path";
|
|
128356
128510
|
|
|
128357
128511
|
// node_modules/hono/dist/request/constants.js
|
|
@@ -138812,7 +138966,7 @@ function mount20(ctx) {
|
|
|
138812
138966
|
}
|
|
138813
138967
|
|
|
138814
138968
|
// src/server/routes/verify.ts
|
|
138815
|
-
import { readFileSync as readFileSync156, realpathSync as
|
|
138969
|
+
import { readFileSync as readFileSync156, realpathSync as realpathSync48 } from "fs";
|
|
138816
138970
|
import { createPublicKey as createPublicKey9 } from "crypto";
|
|
138817
138971
|
import { join as join170, sep as sep29 } from "path";
|
|
138818
138972
|
init_verify_cmd();
|
|
@@ -138841,11 +138995,11 @@ function mount21(ctx) {
|
|
|
138841
138995
|
return done(404, "receipt not available", "not_found");
|
|
138842
138996
|
let runDir, file;
|
|
138843
138997
|
try {
|
|
138844
|
-
const root =
|
|
138845
|
-
runDir =
|
|
138998
|
+
const root = realpathSync48(join170(repo.p, ".loki", "runs"));
|
|
138999
|
+
runDir = realpathSync48(join170(root, run2));
|
|
138846
139000
|
if (runDir !== join170(root, run2))
|
|
138847
139001
|
return done(404, "receipt not found", "not_found");
|
|
138848
|
-
file =
|
|
139002
|
+
file = realpathSync48(join170(runDir, "receipt.json"));
|
|
138849
139003
|
} catch {
|
|
138850
139004
|
return done(404, "receipt not found", "not_found");
|
|
138851
139005
|
}
|
|
@@ -138899,9 +139053,9 @@ function mount21(ctx) {
|
|
|
138899
139053
|
}
|
|
138900
139054
|
|
|
138901
139055
|
// src/server/routes/workspace.ts
|
|
138902
|
-
import { existsSync as existsSync122, mkdirSync as
|
|
139056
|
+
import { existsSync as existsSync122, mkdirSync as mkdirSync93, readFileSync as readFileSync157, readdirSync as readdirSync58, renameSync as renameSync30, statSync as statSync54, writeFileSync as writeFileSync92 } from "fs";
|
|
138903
139057
|
import { homedir as homedir17, userInfo } from "os";
|
|
138904
|
-
import { dirname as
|
|
139058
|
+
import { dirname as dirname75, join as join171, resolve as resolve46, sep as sep30 } from "path";
|
|
138905
139059
|
var ID7 = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
138906
139060
|
var MAX_BYTES3 = 200000;
|
|
138907
139061
|
var workspaceFile = (env2 = process.env) => env2["LOKI_WORKSPACE_FILE"] || join171(homedir17(), ".loki", "control", "workspace.json");
|
|
@@ -138952,7 +139106,7 @@ function loadWorkspace(known, file = workspaceFile()) {
|
|
|
138952
139106
|
return { account: { name: accountName() }, orgs: [{ id: "personal", name: "Personal", projects: [{ id: "default", name: "My project", repos: [...known] }] }] };
|
|
138953
139107
|
}
|
|
138954
139108
|
function saveWorkspace(ws2, file = workspaceFile()) {
|
|
138955
|
-
|
|
139109
|
+
mkdirSync93(dirname75(file), { recursive: true, mode: 448 });
|
|
138956
139110
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
138957
139111
|
writeFileSync92(tmp, JSON.stringify(ws2, null, 2) + `
|
|
138958
139112
|
`, { mode: 384 });
|
|
@@ -138971,7 +139125,7 @@ function repoDirsOf(db2, name) {
|
|
|
138971
139125
|
const rows = db2.select({ name: localRepos.name, realpath: localRepos.realpath }).from(localRepos).all().filter((r) => r.name === name);
|
|
138972
139126
|
return [...new Set(rows.map((r) => r.realpath))].filter((d) => {
|
|
138973
139127
|
try {
|
|
138974
|
-
return
|
|
139128
|
+
return statSync54(d).isDirectory();
|
|
138975
139129
|
} catch {
|
|
138976
139130
|
return false;
|
|
138977
139131
|
}
|
|
@@ -138982,7 +139136,7 @@ var INSTRUCTION_FILES = ["CLAUDE.md", "CLAUDE.local.md", ".claude/CLAUDE.md", "A
|
|
|
138982
139136
|
var NOTE_DIRS = [".loki/memory", ".loki/learnings", ".claude/rules"];
|
|
138983
139137
|
var readCapped3 = (p) => {
|
|
138984
139138
|
try {
|
|
138985
|
-
const st2 =
|
|
139139
|
+
const st2 = statSync54(p);
|
|
138986
139140
|
if (!st2.isFile())
|
|
138987
139141
|
return null;
|
|
138988
139142
|
const b = readFileSync157(p);
|
|
@@ -139827,7 +139981,7 @@ function createApp(opts) {
|
|
|
139827
139981
|
return c.json({ error: "not found" }, 404);
|
|
139828
139982
|
const root = resolve47(uiDir);
|
|
139829
139983
|
const f = resolve47(root, `.${p}`);
|
|
139830
|
-
if (f.startsWith(root + sep31) && existsSync124(f) &&
|
|
139984
|
+
if (f.startsWith(root + sep31) && existsSync124(f) && statSync55(f).isFile())
|
|
139831
139985
|
return new Response(Bun.file(f));
|
|
139832
139986
|
if (/\.[a-z0-9]+$/i.test(p))
|
|
139833
139987
|
return c.json({ error: "not found" }, 404);
|