loki-mode 11.118.1 → 11.120.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 +3 -3
- package/VERSION +1 -1
- package/autonomy/lib/backlog.py +107 -37
- package/autonomy/loki +5 -2
- package/autonomy/route.sh +67 -22
- package/bin/loki +19 -78
- package/dashboard/__init__.py +1 -1
- package/docs/ARCHITECTURE.md +4 -4
- package/docs/CLI-INVENTORY.md +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/air-gapped.md +1 -1
- package/docs/alternative-installations.md +1 -1
- package/docs/cost-controls.md +0 -1
- package/docs/dev/architecture-reference.md +2 -2
- package/docs/environment-variables.md +1 -1
- package/docs/exit-codes.md +3 -4
- package/docs/trackers.md +12 -0
- package/docs/v10/GUIDE.md +3 -3
- package/loki-ts/data/child-env.json +2 -0
- package/loki-ts/dist/loki.js +1693 -1885
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +4948 -4751
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/references/sdk-mode.md +8 -10
- package/web-app/dist/assets/{AdminPage-Dl95kEpz.js → AdminPage-D1_vz1LQ.js} +1 -1
- package/web-app/dist/assets/{Avatar-CoMNZyZc.js → Avatar-BefQj_9m.js} +1 -1
- package/web-app/dist/assets/{Badge-DQ_maQj6.js → Badge-BcAowN-N.js} +1 -1
- package/web-app/dist/assets/{Button-xAjqoDGo.js → Button-BeVwFkYh.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-DLS-kNOJ.js → CockpitPage-Q-sO8Psm.js} +1 -1
- package/web-app/dist/assets/{ComparePage-xWlmnGaY.js → ComparePage-CiJ3FrSl.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-BRbWbU8C.js → ErrorBoundary-DdIh2DlF.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-CNbbIGm3.js → EvidenceReceiptPanel-cf2Jhgl3.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-DTjOTX07.js → GitHubIssuesPanel-SfgkosoM.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-B7OVy1iJ.js → GitHubPRsPanel-DsUqn99r.js} +1 -1
- package/web-app/dist/assets/{HomePage-CETALbO9.js → HomePage-C6PCzqqg.js} +2 -2
- package/web-app/dist/assets/{LoginPage-DwPyh-M5.js → LoginPage-Bqci5QVa.js} +1 -1
- package/web-app/dist/assets/{MagicPage-CmLl1poT.js → MagicPage-NO5PIrOb.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-CWQVihAs.js → MetricsPage-B0oveHbr.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-D5c8BBZa.js → NotFoundPage-CDh2DiQC.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-DUbvjiAF.js → ProjectPage-CrJ_t9m_.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-bBUlPEjC.js → ProjectsPage-UPhA-lpV.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-BpHpvLOi.js → SettingsPage-DKO1LhLq.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-BCSWtWpO.js → ShowcasePage-sZmG4qo4.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-CZMC1YjJ.js → SystemSettingsPage-Drvx9eXK.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-wNI7lC4g.js → TeamsPage-DFuLa1I9.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-BUXLMzDk.js → TemplatesPage-C_U8lRMD.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-Ci-OwQtT.js → TerminalOutput-DdU-3V0-.js} +1 -1
- package/web-app/dist/assets/{activity-DrY_CBEj.js → activity-BwXV9-sA.js} +1 -1
- package/web-app/dist/assets/{bell-zizLC58S.js → bell-DF148FeB.js} +1 -1
- package/web-app/dist/assets/{bot-DEypgLT2.js → bot-BM1t71_O.js} +1 -1
- package/web-app/dist/assets/{check-gY52vWg_.js → check-DHJPb450.js} +1 -1
- package/web-app/dist/assets/{chevron-left-DoDaUPzk.js → chevron-left-DZIgwXb6.js} +1 -1
- package/web-app/dist/assets/{circle-alert-Cfu5G_0b.js → circle-alert-31lHNmy0.js} +1 -1
- package/web-app/dist/assets/{clock-De708wI0.js → clock-D4QAxoCy.js} +1 -1
- package/web-app/dist/assets/{cloud-EGwYhSkv.js → cloud-Dd2iypzJ.js} +1 -1
- package/web-app/dist/assets/{code-xml-BJXvBR7V.js → code-xml-CnUOPwx8.js} +1 -1
- package/web-app/dist/assets/{database-D4yAsGes.js → database-Dhpbplpo.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-BUAWk_hv.js → dollar-sign-DCt7L7Pk.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-DbVIY5Ui.js → file-code-corner-D2SPiEH7.js} +1 -1
- package/web-app/dist/assets/{file-plus-TuU3vx6q.js → file-plus-cCrpp-pe.js} +1 -1
- package/web-app/dist/assets/{globe-Cf3pzF10.js → globe-Cn6TYK_z.js} +1 -1
- package/web-app/dist/assets/{hammer-CkFR5FA_.js → hammer-sMLkpUw2.js} +1 -1
- package/web-app/dist/assets/{index-BOitSoSC.js → index-Dgb8Kves.js} +3 -3
- package/web-app/dist/assets/{layers-CaH8k11R.js → layers-DuPguIVU.js} +1 -1
- package/web-app/dist/assets/{loader-circle-CS4D1KEz.js → loader-circle-BBhsXs18.js} +1 -1
- package/web-app/dist/assets/{lock-6XzWbWxF.js → lock-n-qJvU_o.js} +1 -1
- package/web-app/dist/assets/{package-BOuSIjSw.js → package-cDxKfjAD.js} +1 -1
- package/web-app/dist/assets/{plus-B3x53Byn.js → plus-COk5sQxp.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-x8YMlGSU.js → refresh-cw--VKVhvpo.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-C783lZy1.js → rotate-ccw-DvZ6KExW.js} +1 -1
- package/web-app/dist/assets/{scroll-text-CUyhyoYB.js → scroll-text-HRyHuQUy.js} +1 -1
- package/web-app/dist/assets/{server-BgM5H1lS.js → server-CoZSZtid.js} +1 -1
- package/web-app/dist/assets/{shield-alert-PhlB-cgX.js → shield-alert--WkXdHlN.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-BMv6-FAl.js → thumbs-up-YeW2Lb8g.js} +1 -1
- package/web-app/dist/assets/{trash-2-cwv6_KMs.js → trash-2-DuhNrOPo.js} +1 -1
- package/web-app/dist/assets/{trending-down-fh1-jf_B.js → trending-down-55EMrZu6.js} +1 -1
- package/web-app/dist/assets/{trending-up-CBhpOjo8.js → trending-up-BaUDEQ-n.js} +1 -1
- package/web-app/dist/assets/{upload-B6OTSfOn.js → upload-BrHq6BXI.js} +1 -1
- package/web-app/dist/assets/{usePolling-EItfhxee.js → usePolling-BEtK-_qo.js} +1 -1
- package/web-app/dist/assets/{user-BW393wzp.js → user-DL5XlCBR.js} +1 -1
- package/web-app/dist/index.html +1 -1
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: loki-mode
|
|
|
3
3
|
description: Runs an autonomous software factory that knows what it is supposed to deliver and proves it did, with a signed receipt. Use when the user says Loki Mode or asks to build, fix or verify software autonomously.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Loki Mode v11.
|
|
6
|
+
# Loki Mode v11.120.0
|
|
7
7
|
|
|
8
8
|
**Current entry points (Loki 10 engine):** `loki "<task>"`, `loki owner/repo#N` and `loki quick "<task>"` run the Loki 10 engine and end with a signed receipt (`loki verify`). `loki backlog owner/repo --all` runs many issues in parallel. Guide: `docs/v10/GUIDE.md`. The skill instructions below, and `loki start`, describe the previous bash loop. PRD-file starts (`loki start ./prd.md`) and the opencode provider still run on it until FC38-SWEEP ports them; the legacy-engine command and the LOKI_ENGINE switch remain removed. Prefer `loki owner/repo#N` for issues.
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ description: Runs an autonomous software factory that knows what it is supposed
|
|
|
17
17
|
|
|
18
18
|
**Provider-agnostic (stable since v5.0.0):** runs on Claude/Codex/Cline/Aider with abstract model tiers and degraded mode for non-Claude providers; no vendor lock-in. Gemini deprecated v7.5.18. See `skills/providers.md`. **Legacy track (v8.0.0):** the Anthropic Agent SDK route (see below), spec-mode expansion for OpenAPI/GraphQL/Postman contracts, the runtime-boot and secret-leak evidence axes, and `loki steer` / `loki why` for mid-run control. Earlier tracks: LSP grounding as a first-class agent tool (v7.7.x) and Phase 1 RARV-C closure (real provider judges, gate-failure flock, synthetic PRD e2e, status `--json`).
|
|
19
19
|
|
|
20
|
-
**Runtime migration:** Bash-to-Bun migration. `bin/loki` is the router: the commands in its Bun-route `case` (read-only ones such as `version`, `status`, `stats`, `doctor`, `provider`, `memory`, plus stateful ones such as `rollback`, `trust`, `proof`/`receipt`, `control`, `answer`) run through `loki-ts/src/cli.ts` on Bun; the rest, and some flag forms (for example `doctor --airgap`, `trust detail`), run on Bash (`autonomy/loki`). `start`
|
|
20
|
+
**Runtime migration:** Bash-to-Bun migration. `bin/loki` is the router: the commands in its Bun-route `case` (read-only ones such as `version`, `status`, `stats`, `doctor`, `provider`, `memory`, plus stateful ones such as `rollback`, `trust`, `proof`/`receipt`, `control`, `answer`) run through `loki-ts/src/cli.ts` on Bun; the rest, and some flag forms (for example `doctor --airgap`, `trust detail`), run on Bash (`autonomy/loki`). `start` and `quick` are routed by `autonomy/route.sh` to the Loki 10 engine; the Bash loop runs only on `--engine legacy`. Read `bin/loki` and `cli.ts` for the exact set rather than trusting a list here. Rollback: `LOKI_LEGACY_BASH=1`. See `docs/architecture/ADR-001-runtime-migration.md`.
|
|
21
21
|
|
|
22
22
|
**Anthropic Agent SDK route (v8.0.0, opt-in, default-off):** a claude-binary-free path where the RARV loop runs on `@anthropic-ai/claude-agent-sdk` `query()` and judges run on the raw `@anthropic-ai/sdk`. One operator switch `LOKI_SDK_MODE` (`off` default / `judges` / `full`), mirrored byte-for-byte in bash (`autonomy/lib/sdk-mode.sh`) and TypeScript (`loki-ts/src/runner/sdk_mode.ts`). Unset = byte-identical to the claude-CLI route. See `references/sdk-mode.md`.
|
|
23
23
|
|
|
@@ -473,4 +473,4 @@ Implemented, planned and deprecated items, with the version each landed in: `CHA
|
|
|
473
473
|
|
|
474
474
|
---
|
|
475
475
|
|
|
476
|
-
**v11.
|
|
476
|
+
**v11.120.0 | [Autonomi](https://www.autonomi.dev/) flagship product | core skill**
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
11.
|
|
1
|
+
11.120.0
|
package/autonomy/lib/backlog.py
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
loki backlog owner/repo --all | --label X | --issues 1,2,3
|
|
5
5
|
[--concurrency N] [--slots N] [--dry-run]
|
|
6
|
+
loki backlog jira:PROJ | linear:TEAM (same options; Jira and Linear items)
|
|
6
7
|
|
|
7
8
|
Each issue gets its own git worktree and branch (loki/backlog-N) beside the
|
|
8
9
|
checkout; the launcher runs inside it. Success = the child exited 0 (the engine's
|
|
9
|
-
ladder: 0 VERIFIED, 1 FAILED, 3 BUDGET_STOP, 4 BLOCKED, 5 STALLED). A
|
|
10
|
-
from a failed run is still FAILED
|
|
10
|
+
ladder: 0 VERIFIED, 1 FAILED, 3 BUDGET_STOP, 4 BLOCKED, 5 STALLED, 6 PARTIAL). A
|
|
11
|
+
draft PR from a failed run is still FAILED; a PARTIAL run counts only with its PR.
|
|
12
|
+
A split issue prints one Outcome and one Cost line for all its slices, so its
|
|
13
|
+
spend reaches the day ledger like any run. Exit: 0 all ok, 3 only budget stops, 1 other
|
|
11
14
|
failures, 2 usage/config error.
|
|
12
15
|
|
|
13
16
|
Unit mode (D61 slice 10): --dag FILE [--group G] also runs the units of a
|
|
@@ -21,14 +24,22 @@ Passing unit branches are kept for the integrator; issue mode is unchanged.
|
|
|
21
24
|
|
|
22
25
|
Triage: before anything runs, every issue is classified by the triage router
|
|
23
26
|
(loki-ts/src/features/triage.ts, via `loki internal triage`) as implement (run
|
|
24
|
-
it
|
|
25
|
-
|
|
26
|
-
with
|
|
27
|
+
it; a large issue, by the one rule in features/decompose.ts deliverables, runs
|
|
28
|
+
and the engine splits it into slices), spec (vague or ambiguous: draft
|
|
29
|
+
.loki/specs/<slug>.md with `loki plan --spec`, run nothing, print the command to
|
|
30
|
+
run it after review) or human (never run headless; listed with the reason). --dry-run prints the class and reason per issue. A label
|
|
27
31
|
loki:implement, loki:spec or loki:human forces the class; LOKI_TRIAGE=0 turns
|
|
28
32
|
the router off (every issue runs, as before). The class and reason reach each
|
|
29
33
|
child run as LOKI_TRIAGE_CLASS / LOKI_TRIAGE_REASON, which the engine records in
|
|
30
34
|
the run events, the receipt and the PR body.
|
|
31
35
|
|
|
36
|
+
Jira and Linear: `jira:PROJ` or `linear:TEAM` in place of owner/repo lists that
|
|
37
|
+
project's open items with `loki internal tracker-list` (features/tracker_intake.ts,
|
|
38
|
+
the same credentials as `loki jira:PROJ-1`), triages them the same way and runs
|
|
39
|
+
each as `loki jira:PROJ-N` / `loki linear:TEAM-N` from the current checkout.
|
|
40
|
+
--issues takes item numbers (12 means PROJ-12). A large Jira or Linear item runs
|
|
41
|
+
as one run: the engine splits only GitHub issues today.
|
|
42
|
+
|
|
32
43
|
Test seam: LOKI_BACKLOG_LAUNCHER replaces the real launcher (called with the
|
|
33
44
|
issue ref, cwd = the issue worktree).
|
|
34
45
|
"""
|
|
@@ -51,6 +62,10 @@ import worktree_prep # noqa: E402
|
|
|
51
62
|
|
|
52
63
|
REPO_ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
|
|
53
64
|
REPO_RE = re.compile(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$")
|
|
65
|
+
TRACKER_RE = re.compile(r"^(jira|linear):([A-Za-z][A-Za-z0-9_]*)$")
|
|
66
|
+
# A tracker item key names worktree, branch and log paths: only PROJECT-<number> of the listed project is accepted.
|
|
67
|
+
ITEM_KEY_RE = r"^%s-\d+$" # %s: the validated, uppercased project key
|
|
68
|
+
TRACKER_SECRETS = {"jira": ("JIRA_API_TOKEN", "JIRA_TOKEN", "LOKI_JIRA_TOKEN"), "linear": ("LINEAR_API_KEY", "LOKI_LINEAR_TOKEN")} # each tracker's token and its aliases
|
|
54
69
|
|
|
55
70
|
|
|
56
71
|
def say(msg):
|
|
@@ -76,9 +91,41 @@ def origin_slug(cwd):
|
|
|
76
91
|
return m.group(1) if m else ""
|
|
77
92
|
|
|
78
93
|
|
|
79
|
-
def _issue(i):
|
|
94
|
+
def _issue(i, repo):
|
|
95
|
+
"""One work item. key: the job-table key; label: how it prints; ref: what the launcher runs; slug: branch suffix."""
|
|
80
96
|
labels = [l.get("name", "") if isinstance(l, dict) else str(l) for l in i.get("labels") or []]
|
|
81
|
-
|
|
97
|
+
n = i["number"]
|
|
98
|
+
return {"number": n, "key": n, "label": "#%d" % n, "ref": "%s#%d" % (repo, n), "slug": str(n), "split": True,
|
|
99
|
+
"title": i.get("title") or "", "body": i.get("body") or "", "labels": labels}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def list_tracker(spec, label, numbers, env):
|
|
103
|
+
"""Jira/Linear items via `loki internal tracker-list` (features/tracker_intake.ts). Raises RuntimeError."""
|
|
104
|
+
source, project = spec.split(":", 1)
|
|
105
|
+
cmd = [os.path.join(REPO_ROOT, "bin", "loki"), "internal", "tracker-list", spec]
|
|
106
|
+
if label:
|
|
107
|
+
cmd += ["--label", label]
|
|
108
|
+
if numbers:
|
|
109
|
+
cmd += ["--issues", ",".join(str(n) for n in numbers)]
|
|
110
|
+
r = subprocess.run(cmd, capture_output=True, text=True, env=env, stdin=subprocess.DEVNULL)
|
|
111
|
+
try:
|
|
112
|
+
rows = json.loads(r.stdout) if r.returncode == 0 else None
|
|
113
|
+
if not isinstance(rows, list):
|
|
114
|
+
raise ValueError("not a list")
|
|
115
|
+
out = [{"number": int(x["number"]), "key": str(x["key"]), "label": str(x["key"]), "ref": "%s:%s" % (source, x["key"]),
|
|
116
|
+
"slug": str(x["key"]), "split": False, "title": str(x.get("title") or ""), "body": str(x.get("body") or ""),
|
|
117
|
+
"labels": [str(l) for l in x.get("labels") or []], "source": source} for x in rows]
|
|
118
|
+
except (ValueError, TypeError, KeyError):
|
|
119
|
+
why = (r.stderr.strip().splitlines() or ["no usable output"])[-1]
|
|
120
|
+
raise RuntimeError("listing %s failed (%s)" % (spec, why))
|
|
121
|
+
key_re = re.compile(ITEM_KEY_RE % re.escape(project))
|
|
122
|
+
for i in out:
|
|
123
|
+
if not key_re.fullmatch(i["key"]) or not str(i["number"]) == i["key"].rsplit("-", 1)[1]:
|
|
124
|
+
raise RuntimeError("listing %s returned an invalid item key %r; refusing to use it in a path" % (spec, i["key"][:40]))
|
|
125
|
+
missing = sorted(set(numbers or []) - {i["number"] for i in out})
|
|
126
|
+
if missing:
|
|
127
|
+
raise RuntimeError("%s has no item %s" % (spec, ", ".join("%s-%d" % (project.upper(), n) for n in missing)))
|
|
128
|
+
return out
|
|
82
129
|
|
|
83
130
|
|
|
84
131
|
def list_issues(repo, label, env):
|
|
@@ -89,7 +136,7 @@ def list_issues(repo, label, env):
|
|
|
89
136
|
r = subprocess.run(cmd, capture_output=True, text=True, env=env)
|
|
90
137
|
if r.returncode != 0:
|
|
91
138
|
raise RuntimeError("gh issue list failed: " + (r.stderr.strip().splitlines() or ["unknown error"])[0])
|
|
92
|
-
return sorted((_issue(i) for i in json.loads(r.stdout or "[]")), key=lambda i: i["number"])
|
|
139
|
+
return sorted((_issue(i, repo) for i in json.loads(r.stdout or "[]")), key=lambda i: i["number"])
|
|
93
140
|
|
|
94
141
|
|
|
95
142
|
def view_issues(repo, numbers, env):
|
|
@@ -99,7 +146,7 @@ def view_issues(repo, numbers, env):
|
|
|
99
146
|
capture_output=True, text=True, env=env)
|
|
100
147
|
if r.returncode != 0:
|
|
101
148
|
raise RuntimeError("gh issue view %d failed: %s" % (n, (r.stderr.strip().splitlines() or ["unknown error"])[0]))
|
|
102
|
-
out.append(_issue(json.loads(r.stdout or "{}")))
|
|
149
|
+
out.append(_issue(json.loads(r.stdout or "{}"), repo))
|
|
103
150
|
return out
|
|
104
151
|
|
|
105
152
|
|
|
@@ -107,12 +154,12 @@ TRIAGE_CLASSES = ("implement", "spec", "human")
|
|
|
107
154
|
|
|
108
155
|
|
|
109
156
|
def triage(issues, top, env):
|
|
110
|
-
"""-> {
|
|
157
|
+
"""-> {key: (class, reason)} from `loki internal triage`; raises RuntimeError (fail closed: nothing untriaged runs)."""
|
|
111
158
|
if os.environ.get("LOKI_TRIAGE") == "0":
|
|
112
|
-
return {i["
|
|
159
|
+
return {i["key"]: ("implement", "LOKI_TRIAGE=0: router off") for i in issues}
|
|
113
160
|
if not issues:
|
|
114
161
|
return {}
|
|
115
|
-
items = [{"id": i["
|
|
162
|
+
items = [{"id": i["key"], "title": i["title"], "body": i["body"], "labels": i["labels"], "split": i["split"]} for i in issues]
|
|
116
163
|
r = subprocess.run([os.path.join(REPO_ROOT, "bin", "loki"), "internal", "triage", "--repo-dir", top],
|
|
117
164
|
input=json.dumps(items), capture_output=True, text=True, env=env)
|
|
118
165
|
try:
|
|
@@ -120,12 +167,17 @@ def triage(issues, top, env):
|
|
|
120
167
|
got = {row["id"]: (row["class"], row["reason"]) for row in rows if row.get("class") in TRIAGE_CLASSES}
|
|
121
168
|
except (ValueError, TypeError, KeyError, AttributeError):
|
|
122
169
|
got = None
|
|
123
|
-
if not got or set(got) != {i["
|
|
170
|
+
if not got or set(got) != {i["key"] for i in issues}:
|
|
124
171
|
why = (r.stderr.strip().splitlines() or ["no usable output"])[-1]
|
|
125
172
|
raise RuntimeError("triage failed (%s); fix it, or set LOKI_TRIAGE=0 to run every issue untriaged" % why)
|
|
126
173
|
return got
|
|
127
174
|
|
|
128
175
|
|
|
176
|
+
def without(env, keys):
|
|
177
|
+
"""A copy of env with keys removed."""
|
|
178
|
+
return {k: v for k, v in env.items() if k not in keys}
|
|
179
|
+
|
|
180
|
+
|
|
129
181
|
def draft_spec(issue, top, env):
|
|
130
182
|
"""Draft .loki/specs/<slug>.md with `loki plan --spec` (one plan session). -> (ok, status line)."""
|
|
131
183
|
task = issue["title"] + ("\n\n" + issue["body"] if issue["body"].strip() else "")
|
|
@@ -180,10 +232,13 @@ def add_spend(usd):
|
|
|
180
232
|
|
|
181
233
|
def parse_result(rc, text):
|
|
182
234
|
"""-> (ok, status line text, cost_usd or None)."""
|
|
183
|
-
pr = re.search(r"^PR:\s+(https
|
|
235
|
+
pr = re.search(r"^PR:\s+((?:https?|local)://\S+)", text, re.M) # local://: published to a local bare origin (engine10-push.sh)
|
|
184
236
|
why = re.search(r"^Reason:\s+(.+)$", text, re.M)
|
|
185
237
|
cost = re.search(r"^Cost:\s+(?:partial:\s+)?\$([0-9]+(?:\.[0-9]+)?)", text, re.M)
|
|
186
238
|
usd = float(cost.group(1)) if cost else None
|
|
239
|
+
plan = re.search(r"^Split planning:\s+(?:partial:\s+)?\$([0-9]+(?:\.[0-9]+)?)", text, re.M) # a refused split's planning sessions
|
|
240
|
+
if plan:
|
|
241
|
+
usd = (usd or 0.0) + float(plan.group(1))
|
|
187
242
|
reason = why.group(1).strip() if why else ""
|
|
188
243
|
if rc == 0:
|
|
189
244
|
return True, ("PR " + pr.group(1)) if pr else "VERIFIED", usd
|
|
@@ -191,6 +246,8 @@ def parse_result(rc, text):
|
|
|
191
246
|
return False, "BLOCKED: " + (reason or "see the run log"), usd
|
|
192
247
|
if rc == 3:
|
|
193
248
|
return False, "BUDGET_STOP: " + (reason or "run cost cap reached"), usd
|
|
249
|
+
if rc == 6: # PARTIAL: some proof missing; counts as done only with its (draft) PR
|
|
250
|
+
return bool(pr), ("PARTIAL, PR " + pr.group(1)) if pr else "PARTIAL: " + (reason or "not every check proven"), usd
|
|
194
251
|
return False, "FAILED: " + (reason or "exit %d" % rc), usd
|
|
195
252
|
|
|
196
253
|
|
|
@@ -283,8 +340,14 @@ def main(argv):
|
|
|
283
340
|
ap.add_argument("--group", help="unit group id (default: the DAG's group, else g1)")
|
|
284
341
|
a = ap.parse_args(argv)
|
|
285
342
|
|
|
286
|
-
|
|
287
|
-
|
|
343
|
+
tracker = TRACKER_RE.match(a.repo)
|
|
344
|
+
if tracker: # jira:proj is jira:PROJ: tracker project keys are uppercase
|
|
345
|
+
a.repo = "%s:%s" % (tracker.group(1), tracker.group(2).upper())
|
|
346
|
+
tracker = TRACKER_RE.match(a.repo)
|
|
347
|
+
if tracker and os.environ.get("LOKI_TRACKER_INTAKE") == "0":
|
|
348
|
+
return die("LOKI_TRACKER_INTAKE=0 disables Jira and Linear; unset it to run %s" % a.repo)
|
|
349
|
+
if not (REPO_RE.match(a.repo) or tracker):
|
|
350
|
+
return die("repo must be owner/repo, jira:PROJ or linear:TEAM, got %r" % a.repo)
|
|
288
351
|
if not (a.all or a.label or a.issues or a.dag):
|
|
289
352
|
return die("choose one of --all, --label X, --issues 1,2,3, --dag FILE")
|
|
290
353
|
group, dag_units = None, []
|
|
@@ -329,7 +392,7 @@ def main(argv):
|
|
|
329
392
|
top = git("rev-parse", "--show-toplevel").stdout.strip()
|
|
330
393
|
if not top:
|
|
331
394
|
return die("run this from a checkout of %s" % a.repo)
|
|
332
|
-
if origin_slug(top).lower() != a.repo.lower():
|
|
395
|
+
if not tracker and origin_slug(top).lower() != a.repo.lower():
|
|
333
396
|
return die("this checkout's origin is %r, not %s; cd into a checkout of %s"
|
|
334
397
|
% (origin_slug(top) or "unknown", a.repo, a.repo))
|
|
335
398
|
|
|
@@ -345,8 +408,11 @@ def main(argv):
|
|
|
345
408
|
u["base"] = sha
|
|
346
409
|
|
|
347
410
|
try:
|
|
348
|
-
|
|
349
|
-
|
|
411
|
+
if tracker:
|
|
412
|
+
issues = list_tracker(a.repo, a.label, numbers, env) if (numbers or a.all or a.label) else []
|
|
413
|
+
else:
|
|
414
|
+
issues = (view_issues(a.repo, numbers, env) if numbers
|
|
415
|
+
else list_issues(a.repo, a.label, env) if (a.all or a.label) else [])
|
|
350
416
|
klass = triage(issues, top, env)
|
|
351
417
|
except RuntimeError as e:
|
|
352
418
|
return die(redact(str(e), token), 1)
|
|
@@ -354,13 +420,14 @@ def main(argv):
|
|
|
354
420
|
say("backlog: %s concurrency %d, %d issue(s)" % (a.repo, conc, len(issues))
|
|
355
421
|
+ (", %d unit(s) in group %s" % (len(dag_units), group) if dag_units else ""))
|
|
356
422
|
for i in issues:
|
|
357
|
-
c, why = klass[i["
|
|
358
|
-
say("backlog:
|
|
423
|
+
c, why = klass[i["key"]]
|
|
424
|
+
say("backlog: %s %-9s %s | %s" % (i["label"], c, i["title"], why))
|
|
359
425
|
if a.dry_run:
|
|
360
|
-
n_of = lambda c: sum(1 for i in issues if klass[i["
|
|
426
|
+
n_of = lambda c: sum(1 for i in issues if klass[i["key"]][0] == c) # noqa: E731
|
|
427
|
+
n_large = sum(1 for i in issues if i["split"] and klass[i["key"]][0] == "implement" and klass[i["key"]][1].startswith("large ("))
|
|
361
428
|
if issues:
|
|
362
|
-
say("backlog: dry run: %d would run, %d would get a drafted spec, %d need a human; nothing launched"
|
|
363
|
-
% (n_of("implement"), n_of("spec"), n_of("human")))
|
|
429
|
+
say("backlog: dry run: %d would run%s, %d would get a drafted spec, %d need a human; nothing launched"
|
|
430
|
+
% (n_of("implement"), " (%d split into slices)" % n_large if n_large else "", n_of("spec"), n_of("human")))
|
|
364
431
|
for u in dag_units:
|
|
365
432
|
say("backlog: would run unit %s-%d (%s) after: %s" % (group, u["n"], u["id"], ", ".join(u["deps"]) or "nothing"))
|
|
366
433
|
return 0
|
|
@@ -395,26 +462,29 @@ def main(argv):
|
|
|
395
462
|
day_cap = cfg.get("budgets", {}).get("per_day_usd")
|
|
396
463
|
|
|
397
464
|
# Triage: only implement issues run; spec issues get a drafted spec, human issues are listed.
|
|
398
|
-
routed = {} #
|
|
465
|
+
routed = {} # key -> (ok, status) for issues that do not run
|
|
466
|
+
labels = {i["key"]: i["label"] for i in issues}
|
|
399
467
|
for i in issues:
|
|
400
|
-
c, why = klass[i["
|
|
468
|
+
c, why = klass[i["key"]]
|
|
401
469
|
if c == "human":
|
|
402
|
-
routed[i["
|
|
470
|
+
routed[i["key"]] = (True, "HUMAN: " + why)
|
|
403
471
|
elif c == "spec":
|
|
404
|
-
ok, status = draft_spec(i, top, child_env)
|
|
405
|
-
routed[i["
|
|
472
|
+
ok, status = draft_spec(i, top, without(child_env, sum(TRACKER_SECRETS.values(), ())))
|
|
473
|
+
routed[i["key"]] = (ok, "%s (%s)" % (status, why))
|
|
406
474
|
if c != "implement":
|
|
407
|
-
say("backlog:
|
|
475
|
+
say("backlog: %s %s" % (i["label"], routed[i["key"]][1]))
|
|
408
476
|
|
|
409
477
|
# One job table for issues and units: they share one slot pool.
|
|
410
478
|
spec = {}
|
|
411
479
|
for i in issues:
|
|
412
|
-
n = i["
|
|
480
|
+
n = i["key"]
|
|
413
481
|
if n in routed:
|
|
414
482
|
continue
|
|
415
|
-
spec[n] = {"label": "
|
|
416
|
-
"cmd": [launcher, "
|
|
417
|
-
"env": {"LOKI_TRIAGE_CLASS": klass[n][0], "LOKI_TRIAGE_REASON": klass[n][1]}
|
|
483
|
+
spec[n] = {"label": i["label"], "branch": "loki/backlog-%s" % i["slug"], "wt": "issue-%s" % i["slug"],
|
|
484
|
+
"cmd": [launcher, i["ref"]], "deps": [], "unit": False,
|
|
485
|
+
"env": {"LOKI_TRIAGE_CLASS": klass[n][0], "LOKI_TRIAGE_REASON": klass[n][1]},
|
|
486
|
+
# a child keeps only its own tracker's token (intake and writeback need it); the other tracker's never reaches it
|
|
487
|
+
"drop": [k for src, keys in TRACKER_SECRETS.items() if src != i.get("source") for k in keys]}
|
|
418
488
|
key_of = {u["id"]: "unit-%s-%d" % (group, u["n"]) for u in dag_units}
|
|
419
489
|
for u in dag_units:
|
|
420
490
|
k = key_of[u["id"]]
|
|
@@ -423,7 +493,7 @@ def main(argv):
|
|
|
423
493
|
"deps": [key_of[d] for d in u["deps"]],
|
|
424
494
|
"env": {"LOKI_GROUP_ID": group, "LOKI_UNIT_ID": u["id"], "LOKI_UNIT_N": str(u["n"]),
|
|
425
495
|
"LOKI_UNIT_DEPS": ",".join(u["deps"]), "LOKI_UNIT_WRITE_SET": "\n".join(u["write_set"])},
|
|
426
|
-
"done": u["done"], "base": u["base"]}
|
|
496
|
+
"done": u["done"], "base": u["base"], "drop": sum(TRACKER_SECRETS.values(), ())} # a unit is a text task: no tracker token
|
|
427
497
|
if u["spec"]: # frozen group acceptance for unit_mode (wall.ts)
|
|
428
498
|
spec[k]["env"].update(LOKI_UNIT_SPEC=u["spec"], LOKI_SPEED="1")
|
|
429
499
|
state = {k: {"status": "queued", "ok": None, "cost": None, "ran": False} for k in spec}
|
|
@@ -531,7 +601,7 @@ def main(argv):
|
|
|
531
601
|
return
|
|
532
602
|
log = os.path.join(wt_root, "logs", s["wt"] + ".log")
|
|
533
603
|
with open(log, "w") as lf:
|
|
534
|
-
p = subprocess.Popen(s["cmd"], cwd=wt, env=dict(child_env, **s["env"]), stdout=lf,
|
|
604
|
+
p = subprocess.Popen(s["cmd"], cwd=wt, env=without(dict(child_env, **s["env"]), s.get("drop", ())), stdout=lf,
|
|
535
605
|
stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
536
606
|
running[k] = (p, log, wt)
|
|
537
607
|
state[k].update(status="running", ran=True)
|
|
@@ -589,7 +659,7 @@ def main(argv):
|
|
|
589
659
|
say("Summary: %s" % a.repo)
|
|
590
660
|
say("%-14s %-10s %s" % ("ITEM", "COST", "RESULT"))
|
|
591
661
|
for n, s in state.items():
|
|
592
|
-
say("%-14s %-10s %s" % (spec[n]["label"] if n in spec else
|
|
662
|
+
say("%-14s %-10s %s" % (spec[n]["label"] if n in spec else labels[n], ("$%.2f" % s["cost"] if s["cost"] is not None else "unmeasured" if s["ran"] else "-"), s["status"]))
|
|
593
663
|
measured = sum(s["cost"] or 0 for s in state.values())
|
|
594
664
|
say("Total measured cost: $%.2f%s" % (measured, " (%d run(s) unmeasured, not counted as $0)" % unmeasured if unmeasured else ""))
|
|
595
665
|
bad = [s for s in state.values() if not s["ok"]]
|
package/autonomy/loki
CHANGED
|
@@ -14873,6 +14873,7 @@ cmd_backlog() {
|
|
|
14873
14873
|
echo -e "${BOLD}loki backlog${NC} - run a v10 issue-mode run for every matching open issue"
|
|
14874
14874
|
echo ""
|
|
14875
14875
|
echo "Usage: loki backlog owner/repo (--all | --label X | --issues 1,2,3) [--concurrency N] [--dry-run]"
|
|
14876
|
+
echo " loki backlog jira:PROJ | linear:TEAM (same options; --issues 12 means PROJ-12)"
|
|
14876
14877
|
echo ""
|
|
14877
14878
|
echo " --all Every open issue"
|
|
14878
14879
|
echo " --label X Open issues with label X"
|
|
@@ -14880,8 +14881,10 @@ cmd_backlog() {
|
|
|
14880
14881
|
echo " --concurrency N Max runs in parallel (default: loki.yaml concurrency, else 2)"
|
|
14881
14882
|
echo " --dry-run Print each issue's triage class (implement, spec, human) and reason; launch nothing"
|
|
14882
14883
|
echo ""
|
|
14883
|
-
echo "Run from a checkout of owner/repo
|
|
14884
|
-
echo "
|
|
14884
|
+
echo "Run from a checkout of owner/repo (for Jira or Linear, the checkout the work lands in)."
|
|
14885
|
+
echo "Each issue runs in its own worktree on loki/backlog-N. Jira and Linear use the credentials in docs/trackers.md."
|
|
14886
|
+
echo "Triage: implement issues run, and a large one is split into slices that each run on their own;"
|
|
14887
|
+
echo "vague or ambiguous (spec) issues get .loki/specs/<slug>.md and the command to run it;"
|
|
14885
14888
|
echo "human issues are listed with the reason. Label loki:implement|loki:spec|loki:human forces a class;"
|
|
14886
14889
|
echo "LOKI_TRIAGE=0 runs every issue untriaged."
|
|
14887
14890
|
echo "Config: loki.yaml (repo root, then ~/.loki/loki.yaml); see docs/loki.yaml.example."
|
package/autonomy/route.sh
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# order and input form never change the engine:
|
|
5
5
|
# engine10 is the default for a PRD file, an issue ref, a multi-word task and a
|
|
6
6
|
# one-word brief, whether the flags come first or last.
|
|
7
|
-
# The legacy engine runs only on --engine legacy / LOKI_ENGINE=legacy
|
|
8
|
-
#
|
|
7
|
+
# The legacy engine runs only on --engine legacy / LOKI_ENGINE=legacy or for a PRD over
|
|
8
|
+
# 100000 bytes, and is refused under SDK mode with claude. A flag never changes the engine.
|
|
9
9
|
# Pure functions: no exec, no side effects except R_* globals and the printers.
|
|
10
10
|
# Bash 3.2 compatible (no associative arrays, no ${var,,}).
|
|
11
11
|
|
|
@@ -20,6 +20,10 @@ _ROUTE_OPTVAL_FLAGS=" --mirofish "
|
|
|
20
20
|
_ROUTE_FRONT_FLAGS=" --workspace --deploy --health-url --health-match --auto-rollback --destination --canary --domain "
|
|
21
21
|
# Flags engine10 honors as-is.
|
|
22
22
|
_ROUTE_E10_FLAGS=" --no-pr --deep --json --verbose --quiet --resume --provider --max-cost --spec --attempts --seal-existing "
|
|
23
|
+
# The largest PRD engine10 takes: it carries the task in env vars and CLI arguments (with a context pack added under
|
|
24
|
+
# --session-model), and Linux caps one string at 128 KiB. A bigger PRD runs on the legacy engine, or is refused under
|
|
25
|
+
# SDK mode with claude (the legacy engine has no SDK path).
|
|
26
|
+
_ROUTE_PRD_MAX=100000
|
|
23
27
|
# The most a run cap can reach (capCeilingS(true) in loki-ts/src/util/run_cap.ts: the subscription ceiling).
|
|
24
28
|
_ROUTE_CAP_CEILING_S=3600
|
|
25
29
|
# Accepted and dropped (no-ops on a non-interactive run).
|
|
@@ -40,6 +44,22 @@ _route_refusal_hint() {
|
|
|
40
44
|
|
|
41
45
|
_route_has() { case "$1" in *" $2 "*) return 0 ;; esac; return 1; }
|
|
42
46
|
|
|
47
|
+
# _route_provider FLAG_VALUE: the provider a run would use (flag, LOKI_PROVIDER, .loki/state/provider, else claude).
|
|
48
|
+
_route_provider() {
|
|
49
|
+
local p="$1"
|
|
50
|
+
if [ -z "$p" ]; then p="${LOKI_PROVIDER:-}"; fi
|
|
51
|
+
if [ -z "$p" ] && [ -f "${PWD}/.loki/state/provider" ]; then p="$(sed -n '1p' "${PWD}/.loki/state/provider" 2>/dev/null || true)"; fi
|
|
52
|
+
printf '%s' "${p:-claude}"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# _route_sdk_claude PROVIDER: true under SDK mode (LOKI_SDK_LOOP set, directly or by LOKI_SDK_MODE=full / LOKI_SDK=full)
|
|
56
|
+
# for the claude provider, where the legacy bash loop has no Agent SDK path to run on.
|
|
57
|
+
_route_sdk_claude() {
|
|
58
|
+
[ "$1" = "claude" ] || return 1
|
|
59
|
+
case "${LOKI_SDK_LOOP:-}" in 1|true) return 0 ;; esac
|
|
60
|
+
return 1
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
# _route_optval_consumes FLAG NEXT: whether an optional-value flag takes the next token as its value.
|
|
44
64
|
_route_optval_consumes() {
|
|
45
65
|
[ -n "$2" ] && [ "${2#--}" = "$2" ]
|
|
@@ -217,6 +237,10 @@ loki_route_resolve() {
|
|
|
217
237
|
engine10|e10|v10|10) engine_req=engine10 ;;
|
|
218
238
|
*) R_ERR="loki: unknown engine '$engine_req' (use --engine legacy or --engine engine10)"; R_DECIDED=1; return 0 ;;
|
|
219
239
|
esac
|
|
240
|
+
# The legacy bash loop has no Agent SDK path: under SDK mode with claude it would fail without a claude CLI or switch to it.
|
|
241
|
+
if [ "$engine_req" = "legacy" ] && _route_sdk_claude "$(_route_provider "$provider_flag")"; then
|
|
242
|
+
R_ERR="loki: the legacy engine has no Agent SDK path; drop --engine legacy (and LOKI_ENGINE=legacy) to run Loki 10 on the SDK, or unset LOKI_SDK_MODE, LOKI_SDK and LOKI_SDK_LOOP to run the legacy engine on a provider CLI"; R_DECIDED=1; return 0
|
|
243
|
+
fi
|
|
220
244
|
|
|
221
245
|
# Input. A bare `loki start` takes LOKI_PRD_FILE as its PRD (documented in `loki start --help`).
|
|
222
246
|
if [ "${#positionals[@]}" -eq 0 ] && [ "$verb" = "start" ] && [ -n "${LOKI_PRD_FILE:-}" ]; then
|
|
@@ -287,12 +311,7 @@ loki_route_resolve() {
|
|
|
287
311
|
fi
|
|
288
312
|
|
|
289
313
|
# Provider and model (display only; engine10 resolves its own at run time).
|
|
290
|
-
R_PROVIDER="$provider_flag"
|
|
291
|
-
if [ -z "$R_PROVIDER" ]; then R_PROVIDER="${LOKI_PROVIDER:-}"; fi
|
|
292
|
-
if [ -z "$R_PROVIDER" ] && [ -f "${PWD}/.loki/state/provider" ]; then
|
|
293
|
-
R_PROVIDER="$(sed -n '1p' "${PWD}/.loki/state/provider" 2>/dev/null || true)"
|
|
294
|
-
fi
|
|
295
|
-
if [ -z "$R_PROVIDER" ]; then R_PROVIDER=claude; fi
|
|
314
|
+
R_PROVIDER="$(_route_provider "$provider_flag")"
|
|
296
315
|
if [ -n "$session_model" ]; then
|
|
297
316
|
R_MODEL="$session_model"
|
|
298
317
|
elif [ -n "${LOKI_SESSION_MODEL:-}" ]; then
|
|
@@ -312,10 +331,15 @@ loki_route_resolve() {
|
|
|
312
331
|
fi
|
|
313
332
|
R_SESSION_MODEL="$session_model"
|
|
314
333
|
|
|
315
|
-
# Task text for engine10: a PRD file is read, anything else is the words.
|
|
316
|
-
local task
|
|
334
|
+
# Task text for engine10: a PRD file is read, anything else is the words. A PRD over _ROUTE_PRD_MAX never reaches engine10.
|
|
335
|
+
local task sz=0
|
|
317
336
|
if [ "$R_INPUT_TYPE" = "prd" ]; then
|
|
318
|
-
|
|
337
|
+
sz=$(wc -c < "${positionals[0]}" 2>/dev/null | tr -d ' ' || echo 0)
|
|
338
|
+
if [ "${sz:-0}" -gt "$_ROUTE_PRD_MAX" ]; then
|
|
339
|
+
task=""
|
|
340
|
+
else
|
|
341
|
+
task=$(cat "${positionals[0]}" 2>/dev/null || true)
|
|
342
|
+
fi
|
|
319
343
|
elif [ "$R_INPUT_TYPE" = "spec" ] || [ "$R_INPUT_TYPE" = "none" ]; then
|
|
320
344
|
task=""
|
|
321
345
|
else
|
|
@@ -362,9 +386,11 @@ loki_route_resolve() {
|
|
|
362
386
|
fi
|
|
363
387
|
# --dry-run (engine10 has no preview of its own for these inputs): print the route, then exit 0 without a run.
|
|
364
388
|
if [ "$dry" = "1" ] && [ "$engine_req" != "legacy" ]; then R_DRY=1; fi
|
|
365
|
-
local why=""
|
|
366
389
|
if [ "$engine_req" = "legacy" ]; then
|
|
367
390
|
R_ENGINE=legacy; R_REASON="explicit: --engine legacy or LOKI_ENGINE=legacy"
|
|
391
|
+
elif [ "$engine_req" = "engine10" ] && [ "${sz:-0}" -gt "$_ROUTE_PRD_MAX" ]; then
|
|
392
|
+
R_ERR="loki: this PRD is ${sz} bytes, over the ${_ROUTE_PRD_MAX}-byte limit of the Loki 10 engine; trim it below 100 KB, or drop --engine engine10 to run it on the legacy engine"
|
|
393
|
+
return 0
|
|
368
394
|
elif [ "$engine_req" = "engine10" ]; then
|
|
369
395
|
R_ENGINE=engine10; R_E10=1; R_HARD=1; R_REASON="explicit: --engine engine10"
|
|
370
396
|
else
|
|
@@ -373,14 +399,12 @@ loki_route_resolve() {
|
|
|
373
399
|
claude|codex|cline|aider|opencode) ;;
|
|
374
400
|
*) R_ERR="loki: provider $R_PROVIDER is not supported; use one of: claude, codex, cline, aider, opencode"; return 0 ;;
|
|
375
401
|
esac
|
|
376
|
-
if [ "$
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
R_ENGINE=legacy; R_REASON="$why"
|
|
383
|
-
R_NOTICE="loki: routing this call to the legacy engine: $why."
|
|
402
|
+
if [ "${sz:-0}" -gt "$_ROUTE_PRD_MAX" ] && _route_sdk_claude "$R_PROVIDER"; then
|
|
403
|
+
R_ERR="loki: this PRD is ${sz} bytes, over the ${_ROUTE_PRD_MAX}-byte limit of the Loki 10 engine, and the legacy engine has no Agent SDK path; trim the PRD below 100 KB, or unset LOKI_SDK_MODE, LOKI_SDK and LOKI_SDK_LOOP to run the legacy engine on a provider CLI"
|
|
404
|
+
return 0
|
|
405
|
+
elif [ "${sz:-0}" -gt "$_ROUTE_PRD_MAX" ]; then
|
|
406
|
+
R_ENGINE=legacy; R_REASON="PRD is larger than ${_ROUTE_PRD_MAX} bytes (engine10 carries the task in single strings, capped at 128 KiB on Linux)"
|
|
407
|
+
R_NOTICE="loki: routing this call to the legacy engine: $R_REASON."
|
|
384
408
|
else
|
|
385
409
|
R_ENGINE=engine10; R_E10=1
|
|
386
410
|
R_REASON="default: $R_INPUT_TYPE input runs on engine10 regardless of flag order"
|
|
@@ -471,7 +495,7 @@ loki_route_dispatch() {
|
|
|
471
495
|
fi
|
|
472
496
|
;;
|
|
473
497
|
esac
|
|
474
|
-
if [ "$R_DECIDED" != "1" ]; then return 0; fi
|
|
498
|
+
if [ "$R_DECIDED" != "1" ]; then _route_task_first "$verb" "$@"; return 0; fi
|
|
475
499
|
if [ -n "$R_ERR" ]; then echo "$R_ERR" >&2; return 8; fi
|
|
476
500
|
if [ "$R_EXPLAIN" = "1" ]; then loki_route_print; return 7; fi
|
|
477
501
|
if [ "$R_DRY" = "1" ]; then
|
|
@@ -482,6 +506,27 @@ loki_route_dispatch() {
|
|
|
482
506
|
if [ -n "$R_NOTICE" ]; then echo "$R_NOTICE" >&2; fi
|
|
483
507
|
R_VERB="$verb"
|
|
484
508
|
# A front-end call keeps its argv untouched: bin/loki hands it to autonomy/loki, which runs the workspace or deploy chain.
|
|
485
|
-
if [ "$R_FRONT" = "1" ]; then R_DECIDED=0; fi
|
|
509
|
+
if [ "$R_FRONT" = "1" ]; then R_DECIDED=0; _route_task_first "$verb" "$@"; fi
|
|
486
510
|
return 0
|
|
487
511
|
}
|
|
512
|
+
|
|
513
|
+
# _route_task_first VERB ARGS...: a start or quick call the resolver leaves to its own handler (--help, a front-end
|
|
514
|
+
# flag) still runs engine10 when its first argument is the task: `loki start "<task>" --help` shows the engine10 help.
|
|
515
|
+
# quick takes any first word; start takes a multi-word task or an issue ref, and never with --workspace or --deploy.
|
|
516
|
+
# The args go to engine10 as given. Sets R_DECIDED=1 and R_E10=1 on a match; leaves R_* alone otherwise.
|
|
517
|
+
# shellcheck disable=SC2034
|
|
518
|
+
_route_task_first() {
|
|
519
|
+
local verb="$1" a
|
|
520
|
+
shift
|
|
521
|
+
case "$verb:${1:-}" in start:|start:-*|quick:|quick:-*) return 0 ;; start:*|quick:*) ;; *) return 0 ;; esac
|
|
522
|
+
if [ "$verb" = "start" ]; then
|
|
523
|
+
for a in "$@"; do
|
|
524
|
+
case "$a" in --workspace|--workspace=*|--deploy) return 0 ;; esac
|
|
525
|
+
done
|
|
526
|
+
case "$1" in *" "*) ;; *) [ "$(_route_classify "$1")" = "issue" ] || return 0 ;; esac
|
|
527
|
+
R_E10_ARGS=("$@")
|
|
528
|
+
else
|
|
529
|
+
R_E10_ARGS=(--no-pr "$@")
|
|
530
|
+
fi
|
|
531
|
+
R_DECIDED=1; R_E10=1; R_HARD=0; R_ENGINE=engine10; R_VERB="$verb"; R_SESSION_MODEL=""; R_E10_CAP_S=""
|
|
532
|
+
}
|