loki-mode 11.141.6 → 11.143.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/agents/types.json +3 -3
- package/autonomy/lib/backlog.py +157 -21
- package/autonomy/loki +7 -4
- package/autonomy/telemetry.sh +1 -2
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +4 -2
- package/dashboard/telemetry.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/dev/architecture-reference.md +5 -0
- package/docs/environment-variables.md +3 -1
- package/docs/v10/GUIDE.md +3 -1
- package/loki-ts/dist/loki.js +1789 -1785
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +336 -152
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/references/agent-types.md +3 -3
- package/references/business-ops.md +2 -2
- package/references/cursor-learnings.md +1 -1
- package/scripts/verify-pr-sandbox.sh +1 -1
- package/skills/agents.md +2 -2
- package/skills/github-integration.md +6 -0
- package/skills/model-selection.md +2 -2
- package/src/audit/compliance.js +11 -11
- package/web-app/dist/assets/{AdminPage-i9PHmMPD.js → AdminPage-Bfyaout3.js} +1 -1
- package/web-app/dist/assets/{Avatar-D_6q3v1s.js → Avatar-B4M87e2A.js} +1 -1
- package/web-app/dist/assets/{Badge-OB8s72yd.js → Badge-BdWo4Pis.js} +1 -1
- package/web-app/dist/assets/{Button-DrmV9ik6.js → Button-ga7zrGds.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-DJrzZLPZ.js → CockpitPage-BCPdCf3y.js} +1 -1
- package/web-app/dist/assets/{ComparePage-CPClwQTQ.js → ComparePage-ei74A2H-.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-EA1o3dOi.js → ErrorBoundary-DOksQdek.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-CPUmEtva.js → EvidenceReceiptPanel-BejiJCuC.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-ED2faRlk.js → GitHubIssuesPanel-B4SLdG6W.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-Bclc5nd2.js → GitHubPRsPanel-DUfmJ8-D.js} +1 -1
- package/web-app/dist/assets/{HomePage-Bv3f7LxZ.js → HomePage-DLOrsiAX.js} +2 -2
- package/web-app/dist/assets/{LoginPage-BTFpc_0h.js → LoginPage-CYX6EhD1.js} +1 -1
- package/web-app/dist/assets/{MagicPage-D6qauYXz.js → MagicPage-B9V-H8rJ.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-DZfxKmxi.js → MetricsPage-DxR4dA3v.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-C-ZQu1UW.js → NotFoundPage-62GUMrsu.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-CRFiZLSc.js → ProjectPage-aRlMvuO3.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-BavFLKKb.js → ProjectsPage-DlsVYWSU.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-zfZDQjF-.js → SettingsPage-CYBOAzSl.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-DlHcRnXc.js → ShowcasePage-Cp9h_ikU.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-pFanwBec.js → SystemSettingsPage-Bi8O5KM1.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-BLevzZIc.js → TeamsPage-CvKAy4VC.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-ylTIFbRI.js → TemplatesPage-DgZ8R3cj.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-CubbKVIZ.js → TerminalOutput-BXzQQ3ao.js} +1 -1
- package/web-app/dist/assets/{activity-CAWSp_6M.js → activity-wbwzJg71.js} +1 -1
- package/web-app/dist/assets/{bell-jGlMrpVq.js → bell-CU-k59mu.js} +1 -1
- package/web-app/dist/assets/{bot-2hTcA-8p.js → bot-nRo4H6pJ.js} +1 -1
- package/web-app/dist/assets/{check-D80eIYDT.js → check-BsSag1UJ.js} +1 -1
- package/web-app/dist/assets/{chevron-left-CnH2CR-8.js → chevron-left-CZr4us96.js} +1 -1
- package/web-app/dist/assets/{circle-alert-C7oUl8Ek.js → circle-alert-C2EwgqPt.js} +1 -1
- package/web-app/dist/assets/{clock-DOzHiqGs.js → clock-B1jzN_2i.js} +1 -1
- package/web-app/dist/assets/{cloud-FSE-P1Jp.js → cloud-Bmbi0qzP.js} +1 -1
- package/web-app/dist/assets/{code-xml-CJnb9wRC.js → code-xml-VGyACVgD.js} +1 -1
- package/web-app/dist/assets/{database-aawTQ1Q7.js → database-CWmwrahT.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-FvH5JFJr.js → dollar-sign-CTuJpB-U.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-f13oHQ3O.js → file-code-corner-CEKoA1FQ.js} +1 -1
- package/web-app/dist/assets/{file-plus-iOo8cPnc.js → file-plus-wJZDaswJ.js} +1 -1
- package/web-app/dist/assets/{globe-DQ9k16nT.js → globe-CWQQ1FMq.js} +1 -1
- package/web-app/dist/assets/{hammer-BS6OgHCv.js → hammer-CGzn_YVi.js} +1 -1
- package/web-app/dist/assets/{index-D9_qIW5t.js → index-D7HK6vkd.js} +3 -3
- package/web-app/dist/assets/{layers-DkgEg5Ww.js → layers-Db1BfC4Q.js} +1 -1
- package/web-app/dist/assets/{loader-circle-DkjkYuPZ.js → loader-circle-C0gn8jcq.js} +1 -1
- package/web-app/dist/assets/{lock-C6YNAGAd.js → lock-wrIkF7MN.js} +1 -1
- package/web-app/dist/assets/{package-EMz5m_kz.js → package-DhSgTaXb.js} +1 -1
- package/web-app/dist/assets/{plus-ALTNaQeY.js → plus-CdbYe7om.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-CHtVqI4m.js → refresh-cw-JNwtW3Ws.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-C70B3mg2.js → rotate-ccw-Dld_mqp3.js} +1 -1
- package/web-app/dist/assets/{scroll-text-BKIkCUal.js → scroll-text-DWs72mdn.js} +1 -1
- package/web-app/dist/assets/{server-DVlrE-zu.js → server-CucPfvl_.js} +1 -1
- package/web-app/dist/assets/{shield-alert-DNcGRK6A.js → shield-alert-D3IjFaYW.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-DPAOjRCj.js → thumbs-up-CHz4RJSh.js} +1 -1
- package/web-app/dist/assets/{trash-2-CLgQfWQK.js → trash-2-B6cfWy3k.js} +1 -1
- package/web-app/dist/assets/{trending-down-C_C7_So6.js → trending-down-CfrEdZcD.js} +1 -1
- package/web-app/dist/assets/{trending-up-D_L2MWc2.js → trending-up-Dn4jQ0v5.js} +1 -1
- package/web-app/dist/assets/{upload-_qHiSlwI.js → upload-BIHmbeaS.js} +1 -1
- package/web-app/dist/assets/{usePolling-z23loSZm.js → usePolling-BpfFN5gC.js} +1 -1
- package/web-app/dist/assets/{user-BeGvNcEy.js → user--rB-Jk_0.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -12625,6 +12625,171 @@ var init_lean_select = __esm(() => {
|
|
|
12625
12625
|
init_relevant_files();
|
|
12626
12626
|
});
|
|
12627
12627
|
|
|
12628
|
+
// ../../loki-ts/src/util/claude_model.ts
|
|
12629
|
+
var exports_claude_model = {};
|
|
12630
|
+
__export(exports_claude_model, {
|
|
12631
|
+
resolveClaudeModel: () => resolveClaudeModel,
|
|
12632
|
+
isUnresolvedClaudeAlias: () => isUnresolvedClaudeAlias,
|
|
12633
|
+
haikuRun: () => haikuRun,
|
|
12634
|
+
explicitSetupModel: () => explicitSetupModel,
|
|
12635
|
+
claudeTierRank: () => claudeTierRank,
|
|
12636
|
+
claudeThinkingSubstitute: () => claudeThinkingSubstitute,
|
|
12637
|
+
claudeThinkingMaxEffort: () => claudeThinkingMaxEffort,
|
|
12638
|
+
claudeThinkingHasAdaptive: () => claudeThinkingHasAdaptive,
|
|
12639
|
+
claudeThinkingAccepted: () => claudeThinkingAccepted,
|
|
12640
|
+
claudeEffortLevels: () => claudeEffortLevels,
|
|
12641
|
+
chooseSessionModel: () => chooseSessionModel,
|
|
12642
|
+
canonicalSessionPin: () => canonicalSessionPin,
|
|
12643
|
+
VALID_TIERS: () => VALID_TIERS,
|
|
12644
|
+
PROVIDER_DEFAULT_MODEL: () => PROVIDER_DEFAULT_MODEL,
|
|
12645
|
+
GENERIC_TIERS: () => GENERIC_TIERS,
|
|
12646
|
+
EXPLICIT_MODEL_ENV: () => EXPLICIT_MODEL_ENV,
|
|
12647
|
+
DEFAULT_SESSION_MODEL: () => DEFAULT_SESSION_MODEL
|
|
12648
|
+
});
|
|
12649
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
12650
|
+
import { resolve as resolve12 } from "path";
|
|
12651
|
+
function resolveClaudeModel(want) {
|
|
12652
|
+
try {
|
|
12653
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12654
|
+
return JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
12655
|
+
} catch {
|
|
12656
|
+
return want;
|
|
12657
|
+
}
|
|
12658
|
+
}
|
|
12659
|
+
function isUnresolvedClaudeAlias(model) {
|
|
12660
|
+
return FAMILY_ALIASES.has(model);
|
|
12661
|
+
}
|
|
12662
|
+
function claudeTierRank(model) {
|
|
12663
|
+
try {
|
|
12664
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12665
|
+
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12666
|
+
if (!Array.isArray(models))
|
|
12667
|
+
return null;
|
|
12668
|
+
const order2 = [];
|
|
12669
|
+
for (const m of models)
|
|
12670
|
+
if (m.tier !== "legacy" && !order2.includes(m.tier))
|
|
12671
|
+
order2.push(m.tier);
|
|
12672
|
+
const id = resolveClaudeModel(model);
|
|
12673
|
+
const hit = models.find((m) => m.id === id || m.alias === model);
|
|
12674
|
+
const rank = hit ? order2.indexOf(hit.tier) : -1;
|
|
12675
|
+
return rank >= 0 ? rank : null;
|
|
12676
|
+
} catch {
|
|
12677
|
+
return null;
|
|
12678
|
+
}
|
|
12679
|
+
}
|
|
12680
|
+
function claudeEffortLevels(model) {
|
|
12681
|
+
try {
|
|
12682
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12683
|
+
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12684
|
+
if (!Array.isArray(models))
|
|
12685
|
+
return null;
|
|
12686
|
+
const id = resolveClaudeModel(model);
|
|
12687
|
+
const levels = models.find((m) => m.id === id || m.alias === model)?.effort?.levels;
|
|
12688
|
+
return Array.isArray(levels) ? levels : null;
|
|
12689
|
+
} catch {
|
|
12690
|
+
return null;
|
|
12691
|
+
}
|
|
12692
|
+
}
|
|
12693
|
+
function claudeThinkingSpec(model) {
|
|
12694
|
+
try {
|
|
12695
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12696
|
+
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12697
|
+
if (!Array.isArray(models))
|
|
12698
|
+
return null;
|
|
12699
|
+
const id = resolveClaudeModel(model);
|
|
12700
|
+
return models.find((m) => m.id === id || m.alias === model)?.thinking ?? null;
|
|
12701
|
+
} catch {
|
|
12702
|
+
return null;
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12705
|
+
function claudeThinkingMaxEffort(model, type) {
|
|
12706
|
+
const max = claudeThinkingSpec(model)?.max_effort?.[type];
|
|
12707
|
+
return typeof max === "string" ? max : null;
|
|
12708
|
+
}
|
|
12709
|
+
function claudeThinkingSubstitute(model, type) {
|
|
12710
|
+
const sub = claudeThinkingSpec(model)?.substitute?.[type];
|
|
12711
|
+
return typeof sub === "string" ? sub : null;
|
|
12712
|
+
}
|
|
12713
|
+
function claudeThinkingAccepted(model, type) {
|
|
12714
|
+
const spec = claudeThinkingSpec(model);
|
|
12715
|
+
if (!spec || !Array.isArray(spec.types))
|
|
12716
|
+
return true;
|
|
12717
|
+
return spec.types.includes(type) || typeof spec.substitute?.[type] === "string";
|
|
12718
|
+
}
|
|
12719
|
+
function claudeThinkingHasAdaptive(model) {
|
|
12720
|
+
const types = claudeThinkingSpec(model)?.types;
|
|
12721
|
+
return Array.isArray(types) && types.includes("adaptive");
|
|
12722
|
+
}
|
|
12723
|
+
function canonicalSessionPin(raw2) {
|
|
12724
|
+
const v = (raw2 ?? "").trim().toLowerCase();
|
|
12725
|
+
if (!v)
|
|
12726
|
+
return;
|
|
12727
|
+
const pin = GENERIC_TIERS[v] ?? v;
|
|
12728
|
+
if (!VALID_TIERS.has(pin)) {
|
|
12729
|
+
throw new Error(`unknown LOKI_SESSION_MODEL '${(raw2 ?? "").trim()}' (small|medium|high, planning|development|fast, or opus|sonnet|haiku|fable)`);
|
|
12730
|
+
}
|
|
12731
|
+
return pin;
|
|
12732
|
+
}
|
|
12733
|
+
function explicitSetupModel(tier, e = process.env) {
|
|
12734
|
+
if (e["LOKI_LEGACY_TIER_SWITCHING"] === "true")
|
|
12735
|
+
return;
|
|
12736
|
+
const sess = (e["LOKI_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
12737
|
+
if (tier === "planning" && (sess === "high" || sess === "planning"))
|
|
12738
|
+
return e["LOKI_CLAUDE_MODEL_PLANNING"] || e["LOKI_MODEL_PLANNING"] ? undefined : "opus";
|
|
12739
|
+
if (tier !== "fast" || sess !== "small" && sess !== "fast" || e["LOKI_CLAUDE_MODEL_FAST"] || e["LOKI_MODEL_FAST"])
|
|
12740
|
+
return;
|
|
12741
|
+
return e["LOKI_ALLOW_HAIKU"] === undefined || e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : undefined;
|
|
12742
|
+
}
|
|
12743
|
+
function chooseSessionModel(e = process.env) {
|
|
12744
|
+
const carried = canonicalSessionPin(e["LOKI_SESSION_MODEL"]);
|
|
12745
|
+
if (e["LOKI_SESSION_MODEL_SOURCE"] === "default" && carried && EXPLICIT_MODEL_ENV.every((k) => k === "LOKI_SESSION_MODEL" || (e[k] ?? "").trim() === ""))
|
|
12746
|
+
return { source: "default", pin: carried, why: "Loki default, carried from the parent run" };
|
|
12747
|
+
const named = EXPLICIT_MODEL_ENV.find((k) => (e[k] ?? "").trim() !== "");
|
|
12748
|
+
if (named)
|
|
12749
|
+
return { source: "explicit", pin: null, why: named === "LOKI_SESSION_MODEL" ? "--session-model or LOKI_SESSION_MODEL" : named };
|
|
12750
|
+
const router = (e["LOKI_ROUTER"] ?? "").trim().toLowerCase();
|
|
12751
|
+
if (["1", "true", "on", "auto"].includes(router))
|
|
12752
|
+
return { source: "explicit", pin: null, why: `LOKI_ROUTER=${router}` };
|
|
12753
|
+
const raw2 = (e["LOKI_DEFAULT_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
12754
|
+
if (raw2 === "provider")
|
|
12755
|
+
return { source: "provider", pin: null, why: "LOKI_DEFAULT_SESSION_MODEL=provider (the Claude CLI's own default)" };
|
|
12756
|
+
const pin = canonicalSessionPin(raw2 || DEFAULT_SESSION_MODEL);
|
|
12757
|
+
return { source: "default", pin, why: raw2 ? `LOKI_DEFAULT_SESSION_MODEL=${raw2}` : "Loki default, set another with --session-model or LOKI_DEFAULT_SESSION_MODEL=provider" };
|
|
12758
|
+
}
|
|
12759
|
+
function haikuRun(e = process.env) {
|
|
12760
|
+
const H = /haiku/i, val = (k) => (e[k] ?? "").trim();
|
|
12761
|
+
if (val("LOKI_PROVIDER").toLowerCase() === "opencode")
|
|
12762
|
+
return H.test(val("LOKI_OPENCODE_MODEL"));
|
|
12763
|
+
for (const k of ["LOKI_MODEL_OVERRIDE", "LOKI_MODEL_ROUTE", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_MODEL_DEVELOPMENT"])
|
|
12764
|
+
if (val(k))
|
|
12765
|
+
return H.test(val(k));
|
|
12766
|
+
let pin;
|
|
12767
|
+
try {
|
|
12768
|
+
pin = canonicalSessionPin(e["LOKI_SESSION_MODEL"]) ?? chooseSessionModel(e).pin ?? undefined;
|
|
12769
|
+
} catch {
|
|
12770
|
+
return false;
|
|
12771
|
+
}
|
|
12772
|
+
if (pin === "haiku")
|
|
12773
|
+
return true;
|
|
12774
|
+
if (pin === "fast")
|
|
12775
|
+
return H.test(explicitSetupModel("fast", e) ?? (val("LOKI_CLAUDE_MODEL_FAST") || val("LOKI_MODEL_FAST") || (e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : "sonnet")));
|
|
12776
|
+
if (pin)
|
|
12777
|
+
return false;
|
|
12778
|
+
return routerPreset(e) && H.test(presetExecutor(e).model);
|
|
12779
|
+
}
|
|
12780
|
+
var PROVIDER_DEFAULT_MODEL = "claude (provider default)", FAMILY_ALIASES, VALID_TIERS, GENERIC_TIERS, DEFAULT_SESSION_MODEL = "sonnet", EXPLICIT_MODEL_ENV;
|
|
12781
|
+
var init_claude_model = __esm(() => {
|
|
12782
|
+
init_paths();
|
|
12783
|
+
FAMILY_ALIASES = new Set(["haiku", "sonnet", "opus", "fable"]);
|
|
12784
|
+
VALID_TIERS = new Set(["planning", "development", "fast", "opus", "sonnet", "haiku", "fable"]);
|
|
12785
|
+
GENERIC_TIERS = {
|
|
12786
|
+
small: "fast",
|
|
12787
|
+
medium: "development",
|
|
12788
|
+
high: "planning"
|
|
12789
|
+
};
|
|
12790
|
+
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"];
|
|
12791
|
+
});
|
|
12792
|
+
|
|
12628
12793
|
// ../../loki-ts/src/features/decompose.ts
|
|
12629
12794
|
function isSharedFile(path) {
|
|
12630
12795
|
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
@@ -12808,8 +12973,16 @@ function decompose(spec, map, o) {
|
|
|
12808
12973
|
edges.sort((a, b) => key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0);
|
|
12809
12974
|
return { units, sharedFiles, edges };
|
|
12810
12975
|
}
|
|
12811
|
-
var SHARED_BASENAME, LIST_RE, HEAD_RE, SOLUTION_WORD, ACCEPT_WORD, CONTEXT_WORD, LABEL_RE, kindOf = (t) => ACCEPT_WORD.test(t) ? "accept" : SOLUTION_WORD.test(t) ? "solution" : undefined, BACKEND_WORD, FRONTEND_WORD, LARGE_PARTS = 4, LARGE_CRITERIA = 4, EPIC_LABEL_RE, ISSUE_LABELS_ENV = "LOKI_E10_ISSUE_LABELS",
|
|
12976
|
+
var SHARED_BASENAME, LIST_RE, HEAD_RE, SOLUTION_WORD, ACCEPT_WORD, CONTEXT_WORD, LABEL_RE, kindOf = (t) => ACCEPT_WORD.test(t) ? "accept" : SOLUTION_WORD.test(t) ? "solution" : undefined, BACKEND_WORD, FRONTEND_WORD, LARGE_PARTS = 4, LARGE_CRITERIA = 4, EPIC_LABEL_RE, ISSUE_LABELS_ENV = "LOKI_E10_ISSUE_LABELS", issueWholeFirst = (env = process.env) => {
|
|
12977
|
+
const v = (env["LOKI_ISSUE_WHOLE_FIRST"] ?? "").trim();
|
|
12978
|
+
if (/^(1|on|true|yes)$/i.test(v))
|
|
12979
|
+
return true;
|
|
12980
|
+
if (/^(0|off|false|no)$/i.test(v))
|
|
12981
|
+
return false;
|
|
12982
|
+
return !haikuRun(env);
|
|
12983
|
+
}, MS_HEAD_RE, MS_KEY_RE, uniqSorted = (a) => [...new Set(a)].sort();
|
|
12812
12984
|
var init_decompose = __esm(() => {
|
|
12985
|
+
init_claude_model();
|
|
12813
12986
|
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;
|
|
12814
12987
|
LIST_RE = /^\s*(?:\d+[.)]|[-*+])\s+(?:\[[ xX]\]\s+)?(\S.*)$/;
|
|
12815
12988
|
HEAD_RE = /^\s{0,3}#{1,6}\s+(\S.*?)\s*#*\s*$/;
|
|
@@ -12824,149 +12997,6 @@ var init_decompose = __esm(() => {
|
|
|
12824
12997
|
MS_KEY_RE = /^milestones:\s*$/i;
|
|
12825
12998
|
});
|
|
12826
12999
|
|
|
12827
|
-
// ../../loki-ts/src/util/claude_model.ts
|
|
12828
|
-
var exports_claude_model = {};
|
|
12829
|
-
__export(exports_claude_model, {
|
|
12830
|
-
resolveClaudeModel: () => resolveClaudeModel,
|
|
12831
|
-
isUnresolvedClaudeAlias: () => isUnresolvedClaudeAlias,
|
|
12832
|
-
explicitSetupModel: () => explicitSetupModel,
|
|
12833
|
-
claudeTierRank: () => claudeTierRank,
|
|
12834
|
-
claudeThinkingSubstitute: () => claudeThinkingSubstitute,
|
|
12835
|
-
claudeThinkingMaxEffort: () => claudeThinkingMaxEffort,
|
|
12836
|
-
claudeThinkingHasAdaptive: () => claudeThinkingHasAdaptive,
|
|
12837
|
-
claudeThinkingAccepted: () => claudeThinkingAccepted,
|
|
12838
|
-
claudeEffortLevels: () => claudeEffortLevels,
|
|
12839
|
-
chooseSessionModel: () => chooseSessionModel,
|
|
12840
|
-
canonicalSessionPin: () => canonicalSessionPin,
|
|
12841
|
-
VALID_TIERS: () => VALID_TIERS,
|
|
12842
|
-
PROVIDER_DEFAULT_MODEL: () => PROVIDER_DEFAULT_MODEL,
|
|
12843
|
-
GENERIC_TIERS: () => GENERIC_TIERS,
|
|
12844
|
-
EXPLICIT_MODEL_ENV: () => EXPLICIT_MODEL_ENV,
|
|
12845
|
-
DEFAULT_SESSION_MODEL: () => DEFAULT_SESSION_MODEL
|
|
12846
|
-
});
|
|
12847
|
-
import { readFileSync as readFileSync34 } from "fs";
|
|
12848
|
-
import { resolve as resolve12 } from "path";
|
|
12849
|
-
function resolveClaudeModel(want) {
|
|
12850
|
-
try {
|
|
12851
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12852
|
-
return JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
12853
|
-
} catch {
|
|
12854
|
-
return want;
|
|
12855
|
-
}
|
|
12856
|
-
}
|
|
12857
|
-
function isUnresolvedClaudeAlias(model) {
|
|
12858
|
-
return FAMILY_ALIASES.has(model);
|
|
12859
|
-
}
|
|
12860
|
-
function claudeTierRank(model) {
|
|
12861
|
-
try {
|
|
12862
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12863
|
-
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12864
|
-
if (!Array.isArray(models))
|
|
12865
|
-
return null;
|
|
12866
|
-
const order2 = [];
|
|
12867
|
-
for (const m of models)
|
|
12868
|
-
if (m.tier !== "legacy" && !order2.includes(m.tier))
|
|
12869
|
-
order2.push(m.tier);
|
|
12870
|
-
const id = resolveClaudeModel(model);
|
|
12871
|
-
const hit = models.find((m) => m.id === id || m.alias === model);
|
|
12872
|
-
const rank = hit ? order2.indexOf(hit.tier) : -1;
|
|
12873
|
-
return rank >= 0 ? rank : null;
|
|
12874
|
-
} catch {
|
|
12875
|
-
return null;
|
|
12876
|
-
}
|
|
12877
|
-
}
|
|
12878
|
-
function claudeEffortLevels(model) {
|
|
12879
|
-
try {
|
|
12880
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12881
|
-
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12882
|
-
if (!Array.isArray(models))
|
|
12883
|
-
return null;
|
|
12884
|
-
const id = resolveClaudeModel(model);
|
|
12885
|
-
const levels = models.find((m) => m.id === id || m.alias === model)?.effort?.levels;
|
|
12886
|
-
return Array.isArray(levels) ? levels : null;
|
|
12887
|
-
} catch {
|
|
12888
|
-
return null;
|
|
12889
|
-
}
|
|
12890
|
-
}
|
|
12891
|
-
function claudeThinkingSpec(model) {
|
|
12892
|
-
try {
|
|
12893
|
-
const path = process.env["LOKI_MODEL_CATALOG"] || resolve12(REPO_ROOT, "providers/model_catalog.json");
|
|
12894
|
-
const models = JSON.parse(readFileSync34(path, "utf8")).providers?.claude?.models;
|
|
12895
|
-
if (!Array.isArray(models))
|
|
12896
|
-
return null;
|
|
12897
|
-
const id = resolveClaudeModel(model);
|
|
12898
|
-
return models.find((m) => m.id === id || m.alias === model)?.thinking ?? null;
|
|
12899
|
-
} catch {
|
|
12900
|
-
return null;
|
|
12901
|
-
}
|
|
12902
|
-
}
|
|
12903
|
-
function claudeThinkingMaxEffort(model, type) {
|
|
12904
|
-
const max = claudeThinkingSpec(model)?.max_effort?.[type];
|
|
12905
|
-
return typeof max === "string" ? max : null;
|
|
12906
|
-
}
|
|
12907
|
-
function claudeThinkingSubstitute(model, type) {
|
|
12908
|
-
const sub = claudeThinkingSpec(model)?.substitute?.[type];
|
|
12909
|
-
return typeof sub === "string" ? sub : null;
|
|
12910
|
-
}
|
|
12911
|
-
function claudeThinkingAccepted(model, type) {
|
|
12912
|
-
const spec = claudeThinkingSpec(model);
|
|
12913
|
-
if (!spec || !Array.isArray(spec.types))
|
|
12914
|
-
return true;
|
|
12915
|
-
return spec.types.includes(type) || typeof spec.substitute?.[type] === "string";
|
|
12916
|
-
}
|
|
12917
|
-
function claudeThinkingHasAdaptive(model) {
|
|
12918
|
-
const types = claudeThinkingSpec(model)?.types;
|
|
12919
|
-
return Array.isArray(types) && types.includes("adaptive");
|
|
12920
|
-
}
|
|
12921
|
-
function canonicalSessionPin(raw2) {
|
|
12922
|
-
const v = (raw2 ?? "").trim().toLowerCase();
|
|
12923
|
-
if (!v)
|
|
12924
|
-
return;
|
|
12925
|
-
const pin = GENERIC_TIERS[v] ?? v;
|
|
12926
|
-
if (!VALID_TIERS.has(pin)) {
|
|
12927
|
-
throw new Error(`unknown LOKI_SESSION_MODEL '${(raw2 ?? "").trim()}' (small|medium|high, planning|development|fast, or opus|sonnet|haiku|fable)`);
|
|
12928
|
-
}
|
|
12929
|
-
return pin;
|
|
12930
|
-
}
|
|
12931
|
-
function explicitSetupModel(tier, e = process.env) {
|
|
12932
|
-
if (e["LOKI_LEGACY_TIER_SWITCHING"] === "true")
|
|
12933
|
-
return;
|
|
12934
|
-
const sess = (e["LOKI_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
12935
|
-
if (tier === "planning" && (sess === "high" || sess === "planning"))
|
|
12936
|
-
return e["LOKI_CLAUDE_MODEL_PLANNING"] || e["LOKI_MODEL_PLANNING"] ? undefined : "opus";
|
|
12937
|
-
if (tier !== "fast" || sess !== "small" && sess !== "fast" || e["LOKI_CLAUDE_MODEL_FAST"] || e["LOKI_MODEL_FAST"])
|
|
12938
|
-
return;
|
|
12939
|
-
return e["LOKI_ALLOW_HAIKU"] === undefined || e["LOKI_ALLOW_HAIKU"] === "true" ? "haiku" : undefined;
|
|
12940
|
-
}
|
|
12941
|
-
function chooseSessionModel(e = process.env) {
|
|
12942
|
-
const carried = canonicalSessionPin(e["LOKI_SESSION_MODEL"]);
|
|
12943
|
-
if (e["LOKI_SESSION_MODEL_SOURCE"] === "default" && carried && EXPLICIT_MODEL_ENV.every((k) => k === "LOKI_SESSION_MODEL" || (e[k] ?? "").trim() === ""))
|
|
12944
|
-
return { source: "default", pin: carried, why: "Loki default, carried from the parent run" };
|
|
12945
|
-
const named = EXPLICIT_MODEL_ENV.find((k) => (e[k] ?? "").trim() !== "");
|
|
12946
|
-
if (named)
|
|
12947
|
-
return { source: "explicit", pin: null, why: named === "LOKI_SESSION_MODEL" ? "--session-model or LOKI_SESSION_MODEL" : named };
|
|
12948
|
-
const router = (e["LOKI_ROUTER"] ?? "").trim().toLowerCase();
|
|
12949
|
-
if (["1", "true", "on", "auto"].includes(router))
|
|
12950
|
-
return { source: "explicit", pin: null, why: `LOKI_ROUTER=${router}` };
|
|
12951
|
-
const raw2 = (e["LOKI_DEFAULT_SESSION_MODEL"] ?? "").trim().toLowerCase();
|
|
12952
|
-
if (raw2 === "provider")
|
|
12953
|
-
return { source: "provider", pin: null, why: "LOKI_DEFAULT_SESSION_MODEL=provider (the Claude CLI's own default)" };
|
|
12954
|
-
const pin = canonicalSessionPin(raw2 || DEFAULT_SESSION_MODEL);
|
|
12955
|
-
return { source: "default", pin, why: raw2 ? `LOKI_DEFAULT_SESSION_MODEL=${raw2}` : "Loki default, set another with --session-model or LOKI_DEFAULT_SESSION_MODEL=provider" };
|
|
12956
|
-
}
|
|
12957
|
-
var PROVIDER_DEFAULT_MODEL = "claude (provider default)", FAMILY_ALIASES, VALID_TIERS, GENERIC_TIERS, DEFAULT_SESSION_MODEL = "sonnet", EXPLICIT_MODEL_ENV;
|
|
12958
|
-
var init_claude_model = __esm(() => {
|
|
12959
|
-
init_paths();
|
|
12960
|
-
FAMILY_ALIASES = new Set(["haiku", "sonnet", "opus", "fable"]);
|
|
12961
|
-
VALID_TIERS = new Set(["planning", "development", "fast", "opus", "sonnet", "haiku", "fable"]);
|
|
12962
|
-
GENERIC_TIERS = {
|
|
12963
|
-
small: "fast",
|
|
12964
|
-
medium: "development",
|
|
12965
|
-
high: "planning"
|
|
12966
|
-
};
|
|
12967
|
-
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"];
|
|
12968
|
-
});
|
|
12969
|
-
|
|
12970
13000
|
// ../../loki-ts/src/runner/router/decision.ts
|
|
12971
13001
|
var exports_decision = {};
|
|
12972
13002
|
__export(exports_decision, {
|
|
@@ -15455,6 +15485,7 @@ async function consumeSdkStream(messages, ctx, clock) {
|
|
|
15455
15485
|
let suiteRuns = 0;
|
|
15456
15486
|
let productEditSeen = false, stopped;
|
|
15457
15487
|
let readsBeforeEdit = 0, firstEditSeen = false;
|
|
15488
|
+
let compactions = 0;
|
|
15458
15489
|
const toolTelemetry = () => {
|
|
15459
15490
|
const perTurn = [...toolsByTurn.values()].map((t) => t.size);
|
|
15460
15491
|
return {
|
|
@@ -15628,6 +15659,10 @@ async function consumeSdkStream(messages, ctx, clock) {
|
|
|
15628
15659
|
appendHookEvent(eventsJsonl, data.hook_event, data, ctx.hookEventsEnabled, clock);
|
|
15629
15660
|
continue;
|
|
15630
15661
|
}
|
|
15662
|
+
if (msgType === "system" && data.subtype === "compact_boundary") {
|
|
15663
|
+
compactions++;
|
|
15664
|
+
continue;
|
|
15665
|
+
}
|
|
15631
15666
|
if (msgType === "system" && data.subtype === "init" && typeof data.model === "string" && data.model) {
|
|
15632
15667
|
sessionModel = data.model;
|
|
15633
15668
|
if (Array.isArray(data.tools)) {
|
|
@@ -15710,7 +15745,7 @@ async function consumeSdkStream(messages, ctx, clock) {
|
|
|
15710
15745
|
sessionId = data.session_id;
|
|
15711
15746
|
if (advisorById.size === 0)
|
|
15712
15747
|
recordRouterUsage(new Map, advisorById, "#result", data.usage ?? {});
|
|
15713
|
-
writeResultCost(lokiRoot, ctx.iteration, data, data.model ?? sessionModel, firstTurnPromptTokens, { ...routerTelemetry(reqById, advisorById, advisorFaults), ...toolTelemetry() }, ctx.requestedModel);
|
|
15748
|
+
writeResultCost(lokiRoot, ctx.iteration, data, data.model ?? sessionModel, firstTurnPromptTokens, { ...routerTelemetry(reqById, advisorById, advisorFaults), ...toolTelemetry(), ...compactions > 0 ? { compactions } : {} }, ctx.requestedModel);
|
|
15714
15749
|
maxTurns = data.subtype === "error_max_turns";
|
|
15715
15750
|
exitCode = data.is_error || maxTurns ? 1 : 0;
|
|
15716
15751
|
}
|
|
@@ -28580,7 +28615,7 @@ ${body}`;
|
|
|
28580
28615
|
return { class: "human", reason: `production or destructive operation ("${clip5(prod, 40)}")`, rule: "prod" };
|
|
28581
28616
|
const size = deliverables(text3, labels);
|
|
28582
28617
|
if (size.large)
|
|
28583
|
-
return { class: "implement", reason: `large (${size.reason}); ${item.split === false ? "runs as one run, Jira and Linear items do not split yet" : "runs split into slices"}`, rule: "large" };
|
|
28618
|
+
return { class: "implement", reason: `large (${size.reason}); ${item.split === false ? "runs as one run, Jira and Linear items do not split yet" : issueWholeFirst() ? "runs as one run" : "runs split into slices"}`, rule: "large" };
|
|
28584
28619
|
const amb = scoreAmbiguity(text3), threshold = ambiguityThreshold();
|
|
28585
28620
|
if (amb.score >= threshold)
|
|
28586
28621
|
return { class: "spec", reason: `ambiguous: score ${amb.score} (threshold ${threshold}), e.g. "${clip5(amb.hits[0]?.excerpt ?? "", 50)}"`, rule: "ambiguous" };
|
|
@@ -36415,7 +36450,7 @@ var init_seal = __esm(() => {
|
|
|
36415
36450
|
const fenceRec = fenceNotes(readFenceRecord(ctx.runDir), executed);
|
|
36416
36451
|
const arbCap = Array.isArray(o.wall?.arbitrated) && o.wall.arbitrated.length > 0 && (verdict2 === "VERIFIED" || verdict2 === "ALREADY_SATISFIED"), mutCap = mp?.outcome === "no" && mutationStrict() && o.plan?.behavior_change === true, verdict3a = capFenceVerdict(mutCap || arbCap ? "PARTIAL" : verdict2, fenceRec);
|
|
36417
36452
|
const namedOpen = namedUnchangedOf(ctx.repoDir, ctx.baseSha, o.implement);
|
|
36418
|
-
const openNotes = [...neverStopNotes(o.implement), ...openDecisionNotes(o), ...namedOpen.filter((s) => s.why === null).map(namedUnchangedNote)], verdict3 = openNotes.length > 0 && verdict3a === "VERIFIED" ? "PARTIAL" : verdict3a;
|
|
36453
|
+
const openNotes = [...neverStopNotes(o.implement), ...unfinishedNotes(o.implement), ...openDecisionNotes(o), ...namedOpen.filter((s) => s.why === null).map(namedUnchangedNote)], verdict3 = openNotes.length > 0 && verdict3a === "VERIFIED" ? "PARTIAL" : verdict3a;
|
|
36419
36454
|
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]);
|
|
36420
36455
|
const wp = verdict3 === "VERIFIED" && commitWallEnabled() ? wpAll : { files: [], notes: wpAll.notes }, wallKept = verdict3 === "VERIFIED" && !commitWallEnabled() ? wpAll.files : [];
|
|
36421
36456
|
const wallPub0 = wp.files.length > 0 ? await publishWall(g(ctx), ctx.runId, ctx.repoDir, wp.files, wallDone) : false;
|
|
@@ -38101,6 +38136,7 @@ var init_implement = __esm(() => {
|
|
|
38101
38136
|
init_resolve();
|
|
38102
38137
|
init_package_suite();
|
|
38103
38138
|
init_stop_checks();
|
|
38139
|
+
init_anti_loop();
|
|
38104
38140
|
init_session();
|
|
38105
38141
|
init_worker_proc();
|
|
38106
38142
|
init_conflict_resume();
|
|
@@ -38276,6 +38312,18 @@ ${(session.summary ?? "").slice(-1500)}`, diff: currentDiff(ctx.repoDir, ctx.bas
|
|
|
38276
38312
|
ids.push(r.iterationId);
|
|
38277
38313
|
await challenge();
|
|
38278
38314
|
}
|
|
38315
|
+
let finish2;
|
|
38316
|
+
if (patch?.status !== "green" && !session.killed && session.exit === 0 && !signal.aborted && lacksFinishLine(ctx.provider, session)) {
|
|
38317
|
+
const r = await resumeToFinish(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, { fingerprint: () => treeFingerprint(ctx.repoDir, ctx.baseSha), spentUsd: () => ctx.cost.read(ctx.repoDir, ctx.sessionIds?.() ?? ids).usd, compactions: (xs) => compactionsOf(ctx, xs), signal });
|
|
38318
|
+
session = r.session;
|
|
38319
|
+
for (const id of r.iterationIds)
|
|
38320
|
+
if (!ids.includes(id))
|
|
38321
|
+
ids.push(id);
|
|
38322
|
+
finish2 = r.record;
|
|
38323
|
+
}
|
|
38324
|
+
const incomplete = finish2 !== undefined && finish2.ended !== "finish line";
|
|
38325
|
+
if (incomplete)
|
|
38326
|
+
session = { ...session, markers: { ...session.markers, done: false } };
|
|
38279
38327
|
let coverage;
|
|
38280
38328
|
let claimAbsent;
|
|
38281
38329
|
if (coverageResumeEnabled() && !plan) {
|
|
@@ -38381,6 +38429,8 @@ ${(session.summary ?? "").slice(-1500)}`, diff: currentDiff(ctx.repoDir, ctx.bas
|
|
|
38381
38429
|
let exit;
|
|
38382
38430
|
if (session.killed || session.exit === MAX_TURNS_EXIT) {
|
|
38383
38431
|
exit = "killed";
|
|
38432
|
+
} else if (incomplete && session.exit === 0) {
|
|
38433
|
+
exit = "incomplete";
|
|
38384
38434
|
} else if (session.markers.specConflict) {
|
|
38385
38435
|
exit = "spec_conflict";
|
|
38386
38436
|
} else if (session.markers.alreadyDone && treeIsEmpty(ctx)) {
|
|
@@ -38411,6 +38461,7 @@ ${(session.summary ?? "").slice(-1500)}`, diff: currentDiff(ctx.repoDir, ctx.bas
|
|
|
38411
38461
|
...session.exit === MAX_TURNS_EXIT && !session.killed ? { stop_cause: "max_turns", owner: "harness", limit_s: implementStage.limitS, elapsed_s: session.durationS, ...capStopOf(session.summary) ? { session_cap: capStopOf(session.summary) } : {} } : {},
|
|
38412
38462
|
...planChainMode ? { plan_chain: planChainMode } : {},
|
|
38413
38463
|
...sessionResume ? { session_resume: sessionResume } : {},
|
|
38464
|
+
...finish2 ? { finish: { ...finish2, compactions: compactionsOf(ctx, ids) } } : {},
|
|
38414
38465
|
...coverage ? { coverage_resume: coverage } : {},
|
|
38415
38466
|
...rankedRemedyRec ? { ranked_remedy: rankedRemedyRec } : {},
|
|
38416
38467
|
...precedenceRec ? { precedence_check: precedenceRec } : {},
|
|
@@ -45403,9 +45454,11 @@ __export(exports_issues_run, {
|
|
|
45403
45454
|
startIssueEpic: () => startIssueEpic,
|
|
45404
45455
|
splitWithReask: () => splitWithReask,
|
|
45405
45456
|
runIssues: () => runIssues,
|
|
45457
|
+
rerunGuardOn: () => rerunGuardOn,
|
|
45406
45458
|
renderIssuesDigest: () => renderIssuesDigest,
|
|
45407
45459
|
parseTriage: () => parseTriage,
|
|
45408
45460
|
parseIssuesArgs: () => parseIssuesArgs,
|
|
45461
|
+
openLokiPrGuard: () => openLokiPrGuard,
|
|
45409
45462
|
makeWorktrees: () => makeWorktrees,
|
|
45410
45463
|
makeSessionTriage: () => makeSessionTriage,
|
|
45411
45464
|
issuesRun: () => issuesRun,
|
|
@@ -45504,6 +45557,26 @@ function githubSlug(url) {
|
|
|
45504
45557
|
const m = GITHUB_URL_RE.exec(url);
|
|
45505
45558
|
return m ? `${m[1]}/${m[2]}` : null;
|
|
45506
45559
|
}
|
|
45560
|
+
function openLokiPrGuard(o) {
|
|
45561
|
+
const env = o.env ?? process.env;
|
|
45562
|
+
if (o.noPr || !rerunGuardOn(env))
|
|
45563
|
+
return null;
|
|
45564
|
+
const origin = originSlug2(o.repoDir);
|
|
45565
|
+
if (!origin)
|
|
45566
|
+
return null;
|
|
45567
|
+
const gh = o.gh ?? ((args) => {
|
|
45568
|
+
const r2 = spawnSync18("gh", [...args], { cwd: o.repoDir, env, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: ghTimeoutMs(), killSignal: "SIGKILL" });
|
|
45569
|
+
return { rc: r2.status ?? 1, stdout: r2.stdout ?? "", stderr: r2.stderr ?? "" };
|
|
45570
|
+
});
|
|
45571
|
+
const r = gh(["pr", "list", "--repo", o.slug, "--state", "open", "--json", "number,headRefName,body,url,headRepositoryOwner", "--limit", "500"]);
|
|
45572
|
+
const list = r.rc === 0 ? parseJson(r.stdout) : null;
|
|
45573
|
+
const hint = "LOKI_RERUN_GUARD=0 starts the run anyway";
|
|
45574
|
+
if (!Array.isArray(list))
|
|
45575
|
+
return { code: 2, line: `loki: could not list the open pull requests of ${o.slug} (gh pr list rc ${r.rc}); not starting a run that could open a second pull request for #${o.number} (${hint})` };
|
|
45576
|
+
const owner = origin.split("/")[0].toLowerCase();
|
|
45577
|
+
const hit2 = list.find((pr) => (pr.headRepositoryOwner?.login ?? "").toLowerCase() === owner && coveredIssues(o.slug, [pr]).has(o.number));
|
|
45578
|
+
return hit2 ? { code: 2, line: `loki: ${o.slug}#${o.number} already has an open Loki pull request: ${hit2.url ?? hit2.headRefName}; not starting a second one (${hint})` } : null;
|
|
45579
|
+
}
|
|
45507
45580
|
function originSlug2(repoDir) {
|
|
45508
45581
|
try {
|
|
45509
45582
|
return githubSlug(safeGit(repoDir, ["config", "--get", "remote.origin.url"]).trim());
|
|
@@ -46079,7 +46152,7 @@ var USAGE = `usage: loki issues run [owner/repo] [--label L] [--milestone M] [--
|
|
|
46079
46152
|
const one3 = s.replace(/[\x00-\x1f\x7f|]+/g, " ").trim();
|
|
46080
46153
|
return one3.length > n3 ? `${one3.slice(0, n3 - 3)}...` : one3;
|
|
46081
46154
|
}, lastLine = (s) => s.split(`
|
|
46082
|
-
`).map((l) => l.trim()).filter(Boolean).pop() ?? "", GITHUB_URL_RE, secs = (s) => s < 90 ? `${Math.round(s)}s` : `${Math.round(s / 60)}m`, slicePrintedReason = (out3) => /^Reason:\s+(.+)$/m.exec(out3)?.[1]?.trim() || undefined, PR_URL_RE2, noGovernor = async () => ({ ok: true, hold: false, reason: "not consulted" }), TRIAGE_RE, deepPids = (wt) => {
|
|
46155
|
+
`).map((l) => l.trim()).filter(Boolean).pop() ?? "", GITHUB_URL_RE, rerunGuardOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_RERUN_GUARD"] ?? "").trim()), secs = (s) => s < 90 ? `${Math.round(s)}s` : `${Math.round(s / 60)}m`, slicePrintedReason = (out3) => /^Reason:\s+(.+)$/m.exec(out3)?.[1]?.trim() || undefined, PR_URL_RE2, noGovernor = async () => ({ ok: true, hold: false, reason: "not consulted" }), TRIAGE_RE, deepPids = (wt) => {
|
|
46083
46156
|
try {
|
|
46084
46157
|
return readdirSync46(join125(wt, ".loki", "runs")).flatMap((id) => {
|
|
46085
46158
|
const pid = deepPid(join125(wt, ".loki", "runs", id));
|
|
@@ -46875,7 +46948,21 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
|
|
|
46875
46948
|
`);
|
|
46876
46949
|
return 2;
|
|
46877
46950
|
}
|
|
46878
|
-
if (!trackerRef && sealPatch === null
|
|
46951
|
+
if (!trackerRef && sealPatch === null) {
|
|
46952
|
+
let ref = {};
|
|
46953
|
+
try {
|
|
46954
|
+
ref = JSON.parse(readFileSync116(join127(runDir, "issue.json"), "utf8"));
|
|
46955
|
+
} catch {}
|
|
46956
|
+
if (ref.provider === "github" && typeof ref.repo === "string" && typeof ref.number === "number") {
|
|
46957
|
+
const g2 = (await Promise.resolve().then(() => (init_issues_run(), exports_issues_run))).openLokiPrGuard({ repoDir, slug: ref.repo, number: ref.number, noPr });
|
|
46958
|
+
if (g2) {
|
|
46959
|
+
process.stdout.write(`${g2.line}
|
|
46960
|
+
`);
|
|
46961
|
+
return g2.code;
|
|
46962
|
+
}
|
|
46963
|
+
}
|
|
46964
|
+
}
|
|
46965
|
+
if (!trackerRef && sealPatch === null && !deep && !json2 && !issueWholeFirst(process.env)) {
|
|
46879
46966
|
const ep = await (await Promise.resolve().then(() => (init_issues_run(), exports_issues_run))).startIssueEpic({ repoDir, runDir, noPr, provider, capUsd: cap.usd });
|
|
46880
46967
|
if (ep !== null)
|
|
46881
46968
|
return ep;
|
|
@@ -96233,6 +96320,7 @@ __export(exports_session, {
|
|
|
96233
96320
|
rememberSessionEffort: () => rememberSessionEffort,
|
|
96234
96321
|
recordCost: () => recordCost,
|
|
96235
96322
|
main: () => main8,
|
|
96323
|
+
finishLineOf: () => finishLineOf,
|
|
96236
96324
|
diffSignature: () => diffSignature,
|
|
96237
96325
|
diffShortstat: () => diffShortstat,
|
|
96238
96326
|
createSessionRunner: () => createSessionRunner,
|
|
@@ -96362,10 +96450,20 @@ function childEnv2(opts, cfg) {
|
|
|
96362
96450
|
delete env["LOKI_E10_STOP_RULES"];
|
|
96363
96451
|
return env;
|
|
96364
96452
|
}
|
|
96453
|
+
function finishLineOf(text4) {
|
|
96454
|
+
const last = text4.split(/\r?\n/).map((l) => l.trim()).filter(Boolean).pop() ?? "";
|
|
96455
|
+
if (/^\W*LOKI_DONE\W*$/.test(last))
|
|
96456
|
+
return "done";
|
|
96457
|
+
if (/^\W*LOKI_ALREADY_DONE:\s*\S/.test(last))
|
|
96458
|
+
return "already_done";
|
|
96459
|
+
if (/^\W*LOKI_SPEC_CONFLICT:\s*\S/.test(last))
|
|
96460
|
+
return "spec_conflict";
|
|
96461
|
+
return null;
|
|
96462
|
+
}
|
|
96365
96463
|
function parseMarkers(stdout) {
|
|
96366
96464
|
const doneMatch = /^\W*LOKI_ALREADY_DONE:\s*(.+)$/m.exec(stdout);
|
|
96367
96465
|
const conflictMatch = /^\W*LOKI_SPEC_CONFLICT:\s*(.+)$/m.exec(stdout);
|
|
96368
|
-
return routerMarkers(stdout, { done: !doneMatch && !conflictMatch, alreadyDone: doneMatch ? doneMatch[1].trim() : null, specConflict: conflictMatch ? conflictMatch[1].trim() : null });
|
|
96466
|
+
return routerMarkers(stdout, { done: !doneMatch && !conflictMatch, alreadyDone: doneMatch ? doneMatch[1].trim() : null, specConflict: conflictMatch ? conflictMatch[1].trim() : null, finishLine: finishLineOf(stdout) });
|
|
96369
96467
|
}
|
|
96370
96468
|
function recordCost(cfg, opts, status, durationS, outText = "") {
|
|
96371
96469
|
if (!cfg.lokiRoot)
|
|
@@ -123452,7 +123550,82 @@ async function resumeWith(ctx, first, firstSession, correction, suffix) {
|
|
|
123452
123550
|
|
|
123453
123551
|
${correction}`, ...sid ? { resumeSessionId: sid } : {} });
|
|
123454
123552
|
const terminal = !session.killed && (session.markers.done || session.markers.alreadyDone !== null || session.markers.specConflict !== null);
|
|
123455
|
-
return { session: { ...terminal ? session : firstSession, durationS: firstSession.durationS + session.durationS }, iterationId };
|
|
123553
|
+
return { session: { ...terminal ? session : firstSession, durationS: firstSession.durationS + session.durationS }, iterationId, reply: session };
|
|
123554
|
+
}
|
|
123555
|
+
function outstandingOf(summary) {
|
|
123556
|
+
const lines3 = (summary ?? "").split(`
|
|
123557
|
+
`).map((l) => l.trim()).filter(Boolean).slice(-4).join(" ").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
123558
|
+
return lines3.length > 400 ? `...${lines3.slice(-397)}` : lines3;
|
|
123559
|
+
}
|
|
123560
|
+
function continueBrief(outstanding, missing) {
|
|
123561
|
+
return [
|
|
123562
|
+
"Any earlier request to stop and write a text-only summary is over; it was not the task. The task is the one this session started with, and it is not finished: your last reply ended without a finish line.",
|
|
123563
|
+
`Your last reply ended with: "${outstanding || "(no text)"}". Do that outstanding work now, with tool calls.`,
|
|
123564
|
+
...missing.length ? [`These files from the plan scope are not in the tree yet: ${missing.slice(0, 20).join(", ")}.`] : [],
|
|
123565
|
+
FINISH_LINE
|
|
123566
|
+
].join(`
|
|
123567
|
+
|
|
123568
|
+
`);
|
|
123569
|
+
}
|
|
123570
|
+
async function resumeToFinish(ctx, first, session, o) {
|
|
123571
|
+
const env2 = o.env ?? process.env, ids = [], max = continueMax(env2), usdLine = continueMaxUsd(env2);
|
|
123572
|
+
const missing = () => readPlanScope(ctx.runDir).filter((f) => !existsSync116(join164(ctx.repoDir, f)));
|
|
123573
|
+
let cur = session, outstanding = outstandingOf(session.summary), base2 = first, ended = max === 0 ? "continue off" : "count cap", spent = null;
|
|
123574
|
+
for (let n10 = 1;n10 <= max; n10++) {
|
|
123575
|
+
if (o.signal.aborted) {
|
|
123576
|
+
ended = "aborted";
|
|
123577
|
+
break;
|
|
123578
|
+
}
|
|
123579
|
+
if ((ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S) {
|
|
123580
|
+
ended = "time";
|
|
123581
|
+
break;
|
|
123582
|
+
}
|
|
123583
|
+
spent = o.spentUsd();
|
|
123584
|
+
if (spent !== null && spent >= usdLine) {
|
|
123585
|
+
ended = "dollar line";
|
|
123586
|
+
break;
|
|
123587
|
+
}
|
|
123588
|
+
const before = o.fingerprint();
|
|
123589
|
+
const r = await resumeWith(ctx, base2, cur, continueBrief(outstanding, missing()), `-k${n10}`);
|
|
123590
|
+
ids.push(r.iterationId);
|
|
123591
|
+
base2 = { ...base2, iterationId: r.iterationId };
|
|
123592
|
+
ctx.emit("s1b.resumed", "implement", { resume: n10, iteration_id: r.iterationId, compactions: o.compactions([r.iterationId]), finish_line: r.reply.markers.finishLine ?? null });
|
|
123593
|
+
cur = { ...r.reply, durationS: cur.durationS + r.reply.durationS };
|
|
123594
|
+
if (!r.reply.killed && r.reply.exit === 0 && r.reply.markers.finishLine)
|
|
123595
|
+
return { session: cur, iterationIds: ids, record: { continues: n10, ended: "finish line", outstanding: null, spent_usd: o.spentUsd() } };
|
|
123596
|
+
outstanding = outstandingOf(r.reply.summary) || outstanding;
|
|
123597
|
+
if (r.reply.killed || r.reply.exit !== 0) {
|
|
123598
|
+
ended = "killed or error";
|
|
123599
|
+
break;
|
|
123600
|
+
}
|
|
123601
|
+
const after = o.fingerprint();
|
|
123602
|
+
if (before === null || after === null) {
|
|
123603
|
+
ended = "tree unknown";
|
|
123604
|
+
break;
|
|
123605
|
+
}
|
|
123606
|
+
if (before === after) {
|
|
123607
|
+
ended = "tree unchanged";
|
|
123608
|
+
break;
|
|
123609
|
+
}
|
|
123610
|
+
}
|
|
123611
|
+
return { session: cur, iterationIds: ids, record: { continues: ids.length, ended, outstanding: outstanding || null, spent_usd: spent ?? o.spentUsd() } };
|
|
123612
|
+
}
|
|
123613
|
+
function compactionsOf(ctx, iterationIds, env2 = process.env) {
|
|
123614
|
+
if (env2["LOKI_E10_INVOKER"] === "cli")
|
|
123615
|
+
return null;
|
|
123616
|
+
let n10 = 0;
|
|
123617
|
+
for (const id2 of iterationIds) {
|
|
123618
|
+
try {
|
|
123619
|
+
const c = JSON.parse(readFileSync149(resultCostPath(join164(ctx.repoDir, ".loki"), id2), "utf8")).compactions;
|
|
123620
|
+
if (typeof c === "number" && c > 0)
|
|
123621
|
+
n10 += c;
|
|
123622
|
+
} catch {}
|
|
123623
|
+
}
|
|
123624
|
+
return n10;
|
|
123625
|
+
}
|
|
123626
|
+
function unfinishedNotes(implement) {
|
|
123627
|
+
const f = implement?.finish;
|
|
123628
|
+
return implement?.exit === "incomplete" && f ? [`implement ended without a finish line (${f.ended} after ${f.continues} resume${f.continues === 1 ? "" : "s"}): ${f.outstanding ?? "the reply named nothing"}`] : [];
|
|
123456
123629
|
}
|
|
123457
123630
|
function namedSites(task, repoDir) {
|
|
123458
123631
|
try {
|
|
@@ -123953,7 +124126,16 @@ async function resumeForPrecedence(ctx, first, firstSession, env2 = process.env)
|
|
|
123953
124126
|
${FINISH_LINE}`, "-pr");
|
|
123954
124127
|
return { session: clean7(r.session) ? r.session : { ...firstSession, durationS: r.session.durationS }, iterationIds: [r.iterationId], sites: n10 };
|
|
123955
124128
|
}
|
|
123956
|
-
var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_WALL_TIER", "LOKI_MODEL_OVERRIDE"]), AFTER_PLAN, FROM_PLAN, CONFLICT_CORRECTION, pinConflictEnabled = (env2 = process.env) => !/^(0|off|false|no)$/i.test((env2["LOKI_E10_PINNED_TEST_UPDATE"] ?? "").trim()), CITE_RE, norm5 = (t) => t.replace(/[\s`]+/g, "").replace(/'/g, '"'), pinConflictBrief = (cite2) => `The test you cited (${cite2}) asserts the behavior the issue reports as wrong. That is not a conflict: update that expected value to the behavior the issue states (change only that assertion and keep every other one), make sure the new value fails on the unfixed code, then implement the fix. Before the last line write \`UPDATED TEST <path>:<line>: <old expectation> -> <new expectation>; issue: "<the issue sentence that asks for it>"\`. ` + FINISH_LINE, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_HEAD = "Your session finished with LOKI_DONE but the working tree has no change against the base. Make the change the task asks for, or if the task is already satisfied finish with LOKI_ALREADY_DONE: <file:line evidence>, or if the task itself conflicts finish with LOKI_SPEC_CONFLICT: <reason; cite test as path:line>. ", EMPTY_DONE_CORRECTION, CHALLENGE_STEP = "A task's example code can encode the current, wrong behaviour (expected lines commented out, or asserting today's output), so passing it is not evidence. Reproduce the problem the task's prose describes with a check of the behaviour it asks for. If that check fails on the current code, make the change and finish with LOKI_DONE. Only if the described behaviour already holds, finish with LOKI_ALREADY_DONE: <file:line evidence of that behaviour>. ", ALREADY_DONE_CHALLENGE, REDO_CHALLENGE, EMPTY_DONE_CHALLENGED,
|
|
124129
|
+
var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_WALL_TIER", "LOKI_MODEL_OVERRIDE"]), AFTER_PLAN, FROM_PLAN, CONFLICT_CORRECTION, pinConflictEnabled = (env2 = process.env) => !/^(0|off|false|no)$/i.test((env2["LOKI_E10_PINNED_TEST_UPDATE"] ?? "").trim()), CITE_RE, norm5 = (t) => t.replace(/[\s`]+/g, "").replace(/'/g, '"'), pinConflictBrief = (cite2) => `The test you cited (${cite2}) asserts the behavior the issue reports as wrong. That is not a conflict: update that expected value to the behavior the issue states (change only that assertion and keep every other one), make sure the new value fails on the unfixed code, then implement the fix. Before the last line write \`UPDATED TEST <path>:<line>: <old expectation> -> <new expectation>; issue: "<the issue sentence that asks for it>"\`. ` + FINISH_LINE, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_HEAD = "Your session finished with LOKI_DONE but the working tree has no change against the base. Make the change the task asks for, or if the task is already satisfied finish with LOKI_ALREADY_DONE: <file:line evidence>, or if the task itself conflicts finish with LOKI_SPEC_CONFLICT: <reason; cite test as path:line>. ", EMPTY_DONE_CORRECTION, CHALLENGE_STEP = "A task's example code can encode the current, wrong behaviour (expected lines commented out, or asserting today's output), so passing it is not evidence. Reproduce the problem the task's prose describes with a check of the behaviour it asks for. If that check fails on the current code, make the change and finish with LOKI_DONE. Only if the described behaviour already holds, finish with LOKI_ALREADY_DONE: <file:line evidence of that behaviour>. ", ALREADY_DONE_CHALLENGE, REDO_CHALLENGE, EMPTY_DONE_CHALLENGED, CONTINUE_MAX_DEFAULT = 4, CONTINUE_MAX_USD_DEFAULT = 1, continueMax = (env2 = process.env) => {
|
|
124130
|
+
const v10 = (env2["LOKI_E10_CONTINUE_MAX"] ?? "").trim().toLowerCase();
|
|
124131
|
+
if (isOff(v10))
|
|
124132
|
+
return 0;
|
|
124133
|
+
const n10 = Number(v10);
|
|
124134
|
+
return v10 !== "" && Number.isInteger(n10) && n10 >= 0 ? Math.min(n10, 10) : CONTINUE_MAX_DEFAULT;
|
|
124135
|
+
}, continueMaxUsd = (env2 = process.env) => {
|
|
124136
|
+
const n10 = Number((env2["LOKI_E10_CONTINUE_MAX_USD"] ?? "").trim());
|
|
124137
|
+
return (env2["LOKI_E10_CONTINUE_MAX_USD"] ?? "").trim() !== "" && Number.isFinite(n10) && n10 >= 0 ? n10 : CONTINUE_MAX_USD_DEFAULT;
|
|
124138
|
+
}, lacksFinishLine = (provider, s) => provider === "claude" && s.markers.finishLine === null, resumeAfterEmptyDone = (ctx, first, firstSession, challenge = false) => resumeWith(ctx, first, firstSession, challenge ? EMPTY_DONE_CHALLENGED : EMPTY_DONE_CORRECTION, "-e"), resumeNeverStop = (ctx, first, firstSession, reason, advice) => (ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S ? Promise.resolve({ session: firstSession, iterationId: first.iterationId }) : resumeWith(ctx, first, firstSession, neverStopBrief(reason, advice), "-n"), resumeForSelfReview = (ctx, first, firstSession, brief, maxTurns) => (ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S ? Promise.resolve(null) : resumeWith(ctx, { ...first, maxTurns }, firstSession, brief, "-rv"), resumeAfterAlreadyDone = (ctx, first, firstSession) => resumeWith(ctx, first, firstSession, ALREADY_DONE_CHALLENGE, "-a"), COVERAGE_BRIEF, claimCheckEnabled = (env2 = process.env) => keptUnderLean(env2.LOKI_E10_CLAIM_CHECK, env2), COVERAGE_CLAIM_BRIEF, coverageMode = (env2 = process.env) => {
|
|
123957
124139
|
const v10 = (env2.LOKI_E10_COVERAGE_RESUME ?? "").trim().toLowerCase();
|
|
123958
124140
|
if (isOff(v10))
|
|
123959
124141
|
return "off";
|
|
@@ -124005,6 +124187,8 @@ var init_conflict_resume = __esm(() => {
|
|
|
124005
124187
|
init_role_agents();
|
|
124006
124188
|
init_opus_consult();
|
|
124007
124189
|
init_session_resume();
|
|
124190
|
+
init_cost();
|
|
124191
|
+
init_run_cap();
|
|
124008
124192
|
init_sizing();
|
|
124009
124193
|
init_cost_profile();
|
|
124010
124194
|
init_wall_owned();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
3
|
"name": "loki-mode",
|
|
4
4
|
"displayName": "Loki Mode",
|
|
5
|
-
"version": "11.
|
|
5
|
+
"version": "11.143.0",
|
|
6
6
|
"description": "Autonomous spec-to-product build system with a built-in trust layer (RARV-C closure loop, 8 quality gates, completion council). Ships Loki's spec-hardening, drift-detection, and deterministic PR verification commands plus the Loki MCP server.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Autonomi",
|