@mmerterden/multi-agent-pipeline 23.7.0 → 24.0.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/CHANGELOG.md +38 -1
- package/README.md +57 -24
- package/README.tr.md +41 -8
- package/SECURITY.md +3 -3
- package/docs/architecture.md +41 -4
- package/docs/ecosystem.md +15 -13
- package/docs/facts.json +5 -4
- package/docs/features.md +59 -15
- package/install/_codex-agents.mjs +13 -8
- package/install/_common.mjs +24 -0
- package/install/_dev-only-files.mjs +4 -0
- package/install/_mcp-register.mjs +6 -2
- package/install/_rewrite-tree.mjs +197 -0
- package/install/codex.mjs +96 -180
- package/install/copilot.mjs +24 -54
- package/install/index.mjs +29 -11
- package/install/templates/codex-instructions.md +21 -5
- package/install/templates/copilot-instructions.md +21 -14
- package/manifest.json +2082 -0
- package/package.json +6 -2
- package/pipeline/commands/multi-agent/SKILL.md +5 -4
- package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
- package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
- package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
- package/pipeline/contract/manifest.json +1 -1
- package/pipeline/contract/types/index.d.ts +1 -0
- package/pipeline/lib/_jira-auth.sh +50 -78
- package/pipeline/lib/_service-account.sh +191 -0
- package/pipeline/lib/credential-inventory.sh +49 -37
- package/pipeline/lib/credential-store.sh +48 -3
- package/pipeline/lib/fetch-confluence.sh +76 -92
- package/pipeline/lib/fetch-crashlytics.sh +30 -59
- package/pipeline/lib/fetch-figma-annotations.sh +9 -9
- package/pipeline/lib/fetch-fortify.sh +77 -81
- package/pipeline/lib/fetch-graylog.sh +38 -77
- package/pipeline/lib/figma-mcp-refresh.sh +23 -4
- package/pipeline/lib/figma-screenshot.sh +7 -8
- package/pipeline/lib/figma-token.sh +39 -46
- package/pipeline/lib/host.mjs +138 -0
- package/pipeline/lib/host.sh +48 -0
- package/pipeline/lib/issue-fetcher.sh +25 -41
- package/pipeline/lib/jira-publish.sh +23 -21
- package/pipeline/lib/local-model.mjs +93 -0
- package/pipeline/lib/md2confluence-v3.py +37 -30
- package/pipeline/lib/model-dispatch.sh +41 -4
- package/pipeline/lib/model-resolve.mjs +58 -0
- package/pipeline/lib/post-pr-review.sh +38 -53
- package/pipeline/lib/reviewer-families.mjs +70 -0
- package/pipeline/lib/service-account.mjs +2131 -0
- package/pipeline/lib/service-account.sh +35 -0
- package/pipeline/lib/usage-token.mjs +64 -24
- package/pipeline/lib/usage-vocab.mjs +1 -1
- package/pipeline/lib/user-facing.mjs +11 -3
- package/pipeline/lib/vercel-deploy.sh +17 -26
- package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
- package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
- package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
- package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
- package/pipeline/multi-agent-refs/channels/generator.md +10 -2
- package/pipeline/multi-agent-refs/channels/menu.md +3 -1
- package/pipeline/multi-agent-refs/channels/preview.md +3 -1
- package/pipeline/multi-agent-refs/channels/reference.md +16 -2
- package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
- package/pipeline/multi-agent-refs/cross-cli-contract.md +35 -27
- package/pipeline/multi-agent-refs/features/doctor.md +37 -11
- package/pipeline/multi-agent-refs/features/free-models.md +3 -3
- package/pipeline/multi-agent-refs/features/local-model.md +87 -0
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
- package/pipeline/multi-agent-refs/features/product-context.md +6 -5
- package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
- package/pipeline/multi-agent-refs/help/en.md +28 -1
- package/pipeline/multi-agent-refs/help/tr.md +28 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +2 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
- package/pipeline/multi-agent-refs/phases/modes.md +20 -1
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
- package/pipeline/multi-agent-refs/phases.md +4 -3
- package/pipeline/multi-agent-refs/review/panel.md +30 -18
- package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
- package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
- package/pipeline/multi-agent-refs/sync/overview.md +11 -5
- package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
- package/pipeline/office/index.html +3 -3
- package/pipeline/schemas/autopilot-config.schema.json +29 -4
- package/pipeline/schemas/hosts.json +512 -0
- package/pipeline/schemas/hosts.schema.json +310 -0
- package/pipeline/schemas/launch.json +22 -2
- package/pipeline/schemas/launch.schema.json +2 -1
- package/pipeline/schemas/phases.json +19 -1
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +331 -4
- package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
- package/pipeline/scripts/_autopilot-config.mjs +67 -4
- package/pipeline/scripts/_autopilot-item.mjs +67 -0
- package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
- package/pipeline/scripts/_cost.mjs +75 -3
- package/pipeline/scripts/analysis-sources.mjs +22 -5
- package/pipeline/scripts/analysis-unattended.mjs +360 -0
- package/pipeline/scripts/anonymize-findings.mjs +3 -7
- package/pipeline/scripts/autopilot-arming.mjs +19 -10
- package/pipeline/scripts/autopilot-intake.mjs +124 -27
- package/pipeline/scripts/autopilot-menubar.swift +7 -0
- package/pipeline/scripts/autopilot-runner.mjs +77 -48
- package/pipeline/scripts/autopilot-status.sh +32 -9
- package/pipeline/scripts/bulk-read.sh +37 -5
- package/pipeline/scripts/confluence-readback.mjs +15 -7
- package/pipeline/scripts/cost-table.json +65 -25
- package/pipeline/scripts/doctor.mjs +119 -32
- package/pipeline/scripts/entry-mode.mjs +101 -0
- package/pipeline/scripts/estimate.mjs +30 -16
- package/pipeline/scripts/feedback-send.mjs +11 -8
- package/pipeline/scripts/gen-facts.mjs +7 -9
- package/pipeline/scripts/jira-attach.sh +23 -28
- package/pipeline/scripts/jira-search.sh +5 -21
- package/pipeline/scripts/launch-request.mjs +15 -9
- package/pipeline/scripts/migrate-prefs.mjs +56 -0
- package/pipeline/scripts/phase-tracker.sh +146 -38
- package/pipeline/scripts/priority-review.mjs +14 -7
- package/pipeline/scripts/product-context.mjs +26 -7
- package/pipeline/scripts/prune-logs.sh +4 -2
- package/pipeline/scripts/report-file.mjs +285 -0
- package/pipeline/scripts/rework-escalation.mjs +19 -4
- package/pipeline/scripts/service-read.mjs +19 -17
- package/pipeline/scripts/skill-siblings.mjs +17 -1
- package/pipeline/scripts/status-overview.mjs +20 -10
- package/pipeline/scripts/uninstall.mjs +145 -57
- package/pipeline/scripts/usage-register.mjs +34 -11
- package/pipeline/scripts/usage-report.mjs +31 -26
- package/pipeline/scripts/validate-triage.mjs +11 -1
- package/pipeline/scripts/work-items.mjs +25 -28
- package/pipeline/scripts/write-store-config.mjs +37 -11
- package/pipeline/skills/.skill-manifest.json +4 -4
- package/pipeline/skills/.skills-index.json +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +11 -3
- package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
- package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
- package/pipeline/lib/credential-resolve.mjs +0 -75
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
* else leaves it parked. Bounded by config `maxAskRounds`.
|
|
23
23
|
* 6. RECORD attempted.jsonl, clear the pid file, refresh status.json.
|
|
24
24
|
*
|
|
25
|
+
* The item's KIND decides what step 5 runs and where it ends: a development
|
|
26
|
+
* item runs the pipeline and stops at a draft PR, an analysis item runs
|
|
27
|
+
* `/multi-agent:analysis` and stops at a document, skips the publish step
|
|
28
|
+
* entirely and is recorded as `doc-delivered`.
|
|
29
|
+
*
|
|
25
30
|
* Around the run, three operations (_autopilot-ops.mjs): a sleep inhibitor held
|
|
26
31
|
* from the launch to the end of the tick; `maxParallelAgents`, a ceiling on
|
|
27
32
|
* runner-launched sessions working at once; and two jobs at most once per
|
|
@@ -101,7 +106,7 @@ import {
|
|
|
101
106
|
resolveRunFile,
|
|
102
107
|
runDirCandidates,
|
|
103
108
|
} from "./_run-paths.mjs";
|
|
104
|
-
import { trackerUsd } from "./_cost.mjs";
|
|
109
|
+
import { CONSERVATIVE_RUNG, trackerUsd } from "./_cost.mjs";
|
|
105
110
|
import { configRefusal } from "./_autopilot-config.mjs";
|
|
106
111
|
import {
|
|
107
112
|
OUTCOME,
|
|
@@ -111,6 +116,7 @@ import {
|
|
|
111
116
|
isTerminal,
|
|
112
117
|
rateLimited,
|
|
113
118
|
} from "./_autopilot-outcomes.mjs";
|
|
119
|
+
import { historyKey, isAnalysis } from "./_autopilot-item.mjs";
|
|
114
120
|
import {
|
|
115
121
|
SESSION_ID_RE,
|
|
116
122
|
prRequestsDir,
|
|
@@ -282,9 +288,6 @@ const GUARD_MATCHERS = [
|
|
|
282
288
|
// the script path can run anything and still look registered.
|
|
283
289
|
const GUARD_COMMAND = 'bash "$HOME/.claude/scripts/agent-guard.sh"';
|
|
284
290
|
const MANAGED_SETTINGS = "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
285
|
-
// A phase record without a model is priced at the most expensive tier: an
|
|
286
|
-
// over-estimate stops the spend ceiling early, an under-estimate stops it late.
|
|
287
|
-
const CONSERVATIVE_PRICE = "fable";
|
|
288
291
|
// What the queue says when the arming script answers nothing at all. Read by a
|
|
289
292
|
// person in the menu bar and in the terminal, so it renders in the same
|
|
290
293
|
// preference every other line does.
|
|
@@ -303,14 +306,24 @@ const RATE_LIMITED_MSG = {
|
|
|
303
306
|
* scripts in every install, as runs-index.mjs reads it; a host tree without it
|
|
304
307
|
* shows the number alone rather than failing the tick.
|
|
305
308
|
*/
|
|
306
|
-
const
|
|
309
|
+
const PHASE_CONTRACT = (() => {
|
|
307
310
|
try {
|
|
308
|
-
return JSON.parse(readFileSync(new URL("../schemas/phases.json", import.meta.url), "utf-8"))
|
|
309
|
-
.phases;
|
|
311
|
+
return JSON.parse(readFileSync(new URL("../schemas/phases.json", import.meta.url), "utf-8"));
|
|
310
312
|
} catch {
|
|
311
|
-
return [];
|
|
313
|
+
return { phases: [], modes: {} };
|
|
312
314
|
}
|
|
313
315
|
})();
|
|
316
|
+
const PHASES = PHASE_CONTRACT.phases || [];
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A phase's name in the item's own mode. An analysis item runs the same six
|
|
320
|
+
* slots under its own step names, so its row says Synthesis where a development
|
|
321
|
+
* row says Dev - the name a reader checks the queue for.
|
|
322
|
+
*/
|
|
323
|
+
function phaseLabel(item, id) {
|
|
324
|
+
const names = isAnalysis(item) ? PHASE_CONTRACT.modes?.["analysis-autopilot"]?.names : null;
|
|
325
|
+
return names?.[String(id)] ?? PHASES.find((p) => p.id === id)?.name ?? null;
|
|
326
|
+
}
|
|
314
327
|
|
|
315
328
|
const log = (m) => process.stdout.write(`autopilot-runner: ${m}\n`);
|
|
316
329
|
|
|
@@ -353,6 +366,14 @@ function writeState(name, obj) {
|
|
|
353
366
|
renameSync(tmp, p);
|
|
354
367
|
}
|
|
355
368
|
|
|
369
|
+
/**
|
|
370
|
+
* The identity every ledger row carries, so a row is folded under the key of
|
|
371
|
+
* the item that produced it and not under the other kind's.
|
|
372
|
+
*/
|
|
373
|
+
function rowItem(item) {
|
|
374
|
+
return { source: item?.source, id: item?.id, ...(item?.kind ? { kind: item.kind } : {}) };
|
|
375
|
+
}
|
|
376
|
+
|
|
356
377
|
function record(entry) {
|
|
357
378
|
ensureRoot();
|
|
358
379
|
const p = join(ROOT, "attempted.jsonl");
|
|
@@ -536,13 +557,13 @@ export function compactAttempted(
|
|
|
536
557
|
const since = now - keepSec;
|
|
537
558
|
const newest = new Map();
|
|
538
559
|
rows.forEach((r, i) => {
|
|
539
|
-
const key =
|
|
560
|
+
const key = historyKey(r);
|
|
540
561
|
const cur = newest.get(key);
|
|
541
562
|
if (!cur || Number(r.at || 0) >= Number(rows[cur].at || 0)) newest.set(key, i);
|
|
542
563
|
});
|
|
543
564
|
return rows.filter((r, i) => {
|
|
544
565
|
if (Number(r.at || 0) >= since) return true;
|
|
545
|
-
const key =
|
|
566
|
+
const key = historyKey(r);
|
|
546
567
|
const last = newest.get(key);
|
|
547
568
|
if (last === i) return true;
|
|
548
569
|
if (isTerminal(rows[last].outcome)) return false;
|
|
@@ -763,7 +784,7 @@ export function runUsd(runTaskId, statePath) {
|
|
|
763
784
|
if (!trackerPath) return null;
|
|
764
785
|
const tracker = readJson(trackerPath, null);
|
|
765
786
|
const prices = readJson(join(import.meta.dirname, "cost-table.json"), null)?.prices;
|
|
766
|
-
return trackerUsd(tracker, prices,
|
|
787
|
+
return trackerUsd(tracker, prices, CONSERVATIVE_RUNG);
|
|
767
788
|
}
|
|
768
789
|
|
|
769
790
|
/**
|
|
@@ -783,13 +804,12 @@ async function retire(holder) {
|
|
|
783
804
|
const pub = await publishStep(holder.sessionId, holder.statePath, item);
|
|
784
805
|
const state = holder.statePath ? readJson(holder.statePath, null) : null;
|
|
785
806
|
const prUrl = prFromState(state);
|
|
786
|
-
const ended = pub.outcome || outcomeFor({ reason: "gone" }, state, prUrl);
|
|
807
|
+
const ended = pub.outcome || outcomeFor({ reason: "gone" }, state, prUrl, item);
|
|
787
808
|
const usd = runUsd(holder.runTaskId, holder.statePath);
|
|
788
809
|
|
|
789
810
|
if (holder.parked || isParked(ended)) {
|
|
790
811
|
record({
|
|
791
|
-
|
|
792
|
-
id: item.id,
|
|
812
|
+
...rowItem(item),
|
|
793
813
|
taskId: holder.taskId,
|
|
794
814
|
outcome: ended,
|
|
795
815
|
usd,
|
|
@@ -834,8 +854,7 @@ async function retire(holder) {
|
|
|
834
854
|
|
|
835
855
|
if (isTerminal(ended)) {
|
|
836
856
|
record({
|
|
837
|
-
|
|
838
|
-
id: item.id,
|
|
857
|
+
...rowItem(item),
|
|
839
858
|
taskId: holder.taskId,
|
|
840
859
|
outcome: ended,
|
|
841
860
|
prUrl,
|
|
@@ -861,8 +880,7 @@ async function retire(holder) {
|
|
|
861
880
|
}
|
|
862
881
|
|
|
863
882
|
record({
|
|
864
|
-
|
|
865
|
-
id: item.id,
|
|
883
|
+
...rowItem(item),
|
|
866
884
|
taskId: holder.taskId,
|
|
867
885
|
outcome: OUTCOME.DIED,
|
|
868
886
|
keptWorktree: kept,
|
|
@@ -891,11 +909,10 @@ async function reconcileParked() {
|
|
|
891
909
|
const pub = DRY ? { outcome: null } : await publishStep(e.sessionId, e.statePath, e);
|
|
892
910
|
const st = e.statePath ? readJson(e.statePath, null) : null;
|
|
893
911
|
const prUrl = prFromState(st);
|
|
894
|
-
const outcome = pub.outcome || outcomeFor({ reason: "gone" }, st, prUrl);
|
|
912
|
+
const outcome = pub.outcome || outcomeFor({ reason: "gone" }, st, prUrl, e);
|
|
895
913
|
if (!isParked(outcome) && !DRY) {
|
|
896
914
|
record({
|
|
897
|
-
|
|
898
|
-
id: e.id,
|
|
915
|
+
...rowItem(e),
|
|
899
916
|
taskId: e.taskId,
|
|
900
917
|
outcome,
|
|
901
918
|
prUrl,
|
|
@@ -983,6 +1000,10 @@ function releaseSlot(id, pidPath, queue = { queued: [], running: [] }) {
|
|
|
983
1000
|
*/
|
|
984
1001
|
async function publishStep(sessionId, statePath, item) {
|
|
985
1002
|
if (!sessionId || !statePath || !item?.repo) return { outcome: null };
|
|
1003
|
+
// An analysis run delivers a document and touches no branch, so there is no
|
|
1004
|
+
// request to verify and nothing to push. Reaching the publish step at all
|
|
1005
|
+
// would be the one way an analysis item could end at a pull request.
|
|
1006
|
+
if (isAnalysis(item)) return { outcome: null };
|
|
986
1007
|
const config = readJson(join(ROOT, "config.json"), null);
|
|
987
1008
|
let pub;
|
|
988
1009
|
try {
|
|
@@ -1154,6 +1175,10 @@ export function prFromState(state) {
|
|
|
1154
1175
|
* unattended run's own gate rejected its work, before a plain `failed`:
|
|
1155
1176
|
* retrying repeats the same work into the same rejection.
|
|
1156
1177
|
*
|
|
1178
|
+
* An analysis item ends at `doc-delivered` where a development item ends at
|
|
1179
|
+
* `completed-no-pr`: its mode ends at the document, which is delivery, and the
|
|
1180
|
+
* same completion contract decides whether the state earned it.
|
|
1181
|
+
*
|
|
1157
1182
|
* "finished with no PR" is deliberately not "failed": a run can stop
|
|
1158
1183
|
* legitimately without opening one, and calling that a failure would put a
|
|
1159
1184
|
* healthy item into the retry path. It is only that when the state earns it
|
|
@@ -1161,7 +1186,7 @@ export function prFromState(state) {
|
|
|
1161
1186
|
* without Phase 4 evidence or without a plan-coverage verdict is
|
|
1162
1187
|
* `stopped-incomplete`, which is retried, not filed as finished.
|
|
1163
1188
|
*/
|
|
1164
|
-
export function outcomeFor(supervised, state, prUrl) {
|
|
1189
|
+
export function outcomeFor(supervised, state, prUrl, item = null) {
|
|
1165
1190
|
if (prUrl) return OUTCOME.PR_OPENED;
|
|
1166
1191
|
if (state?.publish?.outcome === OUTCOME.PUSHED_AWAITING_PR) return OUTCOME.PUSHED_AWAITING_PR;
|
|
1167
1192
|
if (state && (state.waitingFor || state.status === "awaiting_input")) {
|
|
@@ -1174,7 +1199,8 @@ export function outcomeFor(supervised, state, prUrl) {
|
|
|
1174
1199
|
if (state && state.verificationFailed) return OUTCOME.VERIFICATION_FAILED;
|
|
1175
1200
|
const status = state && state.status;
|
|
1176
1201
|
if (status === "complete" || status === "completed") {
|
|
1177
|
-
|
|
1202
|
+
if (completionGaps(state).length) return OUTCOME.STOPPED_INCOMPLETE;
|
|
1203
|
+
return isAnalysis(item) ? OUTCOME.DOC_DELIVERED : OUTCOME.COMPLETED_NO_PR;
|
|
1178
1204
|
}
|
|
1179
1205
|
if (status === "failed") return OUTCOME.FAILED;
|
|
1180
1206
|
return state ? `stopped-${status || "unknown"}` : OUTCOME.NO_STATE;
|
|
@@ -1183,13 +1209,17 @@ export function outcomeFor(supervised, state, prUrl) {
|
|
|
1183
1209
|
/**
|
|
1184
1210
|
* The `claude` arguments for one item. The shape - background, a session id
|
|
1185
1211
|
* this runner chose, no permission prompts, the unattended permission profile
|
|
1186
|
-
* as an extra settings file, one unattended
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1212
|
+
* as an extra settings file, one unattended item as the positional prompt
|
|
1213
|
+
* (`--bg` refuses `--print`: the prompt is the positional, and the CLI prints
|
|
1214
|
+
* the session id and returns) - is pending a live launch trial; everything
|
|
1215
|
+
* that launches or describes a launch derives from here so a correction is one
|
|
1216
|
+
* edit. `print` starts the same launch in print mode, which waits for the run
|
|
1217
|
+
* to end: autopilot-loop judges each iteration from the state the finished run
|
|
1218
|
+
* left.
|
|
1219
|
+
*
|
|
1220
|
+
* The item's kind decides the command. An analysis item runs
|
|
1221
|
+
* `/multi-agent:analysis`, which writes a document and stops: no worktree, no
|
|
1222
|
+
* commit, no pull request, and so nothing for the publish step to verify.
|
|
1193
1223
|
*/
|
|
1194
1224
|
export function launchArgv(
|
|
1195
1225
|
item,
|
|
@@ -1205,7 +1235,7 @@ export function launchArgv(
|
|
|
1205
1235
|
"none",
|
|
1206
1236
|
"--settings",
|
|
1207
1237
|
settingsFile,
|
|
1208
|
-
|
|
1238
|
+
`${isAnalysis(item) ? "/multi-agent:analysis" : "/multi-agent"} ${item.ref || item.id} autopilot`,
|
|
1209
1239
|
];
|
|
1210
1240
|
}
|
|
1211
1241
|
|
|
@@ -1603,7 +1633,7 @@ export function researchRoute(state, prUrl, { roundsUsed = 0, maxAskRounds = 2 }
|
|
|
1603
1633
|
export function researchRoundsUsed(lines, item) {
|
|
1604
1634
|
let n = 0;
|
|
1605
1635
|
for (const row of lines || []) {
|
|
1606
|
-
if (!row || row
|
|
1636
|
+
if (!row || historyKey(row) !== historyKey(item)) continue;
|
|
1607
1637
|
const r = Number(row.researchRounds || 0);
|
|
1608
1638
|
if (Number.isFinite(r) && r > 0) n += r;
|
|
1609
1639
|
}
|
|
@@ -1845,7 +1875,7 @@ function trackRunState(claim) {
|
|
|
1845
1875
|
}
|
|
1846
1876
|
|
|
1847
1877
|
/** Mirror the run's current phase onto its `running` entry, which the status line renders. */
|
|
1848
|
-
function trackProgress(claim,
|
|
1878
|
+
function trackProgress(claim, item) {
|
|
1849
1879
|
if (!claim.statePath) return;
|
|
1850
1880
|
const st = readJson(claim.statePath, null);
|
|
1851
1881
|
const phase = st && Number.isInteger(st.currentPhase) ? st.currentPhase : null;
|
|
@@ -1854,11 +1884,11 @@ function trackProgress(claim, id) {
|
|
|
1854
1884
|
const q = readJson(join(ROOT, "queue.json"), null);
|
|
1855
1885
|
if (!q) return;
|
|
1856
1886
|
const last = PHASES.length ? PHASES[PHASES.length - 1].id : null;
|
|
1857
|
-
const phaseName =
|
|
1887
|
+
const phaseName = phaseLabel(item, phase);
|
|
1858
1888
|
writeState("queue.json", {
|
|
1859
1889
|
...q,
|
|
1860
1890
|
running: (q.running || []).map((r) =>
|
|
1861
|
-
r.id === id ? { ...r, phase, phaseName, phaseTotal: last } : r,
|
|
1891
|
+
r.id === item.id ? { ...r, phase, phaseName, phaseTotal: last } : r,
|
|
1862
1892
|
),
|
|
1863
1893
|
});
|
|
1864
1894
|
refreshStatus();
|
|
@@ -1914,7 +1944,7 @@ function supervise(sessionId, claim, item) {
|
|
|
1914
1944
|
sawLive = true;
|
|
1915
1945
|
lastRow = row;
|
|
1916
1946
|
trackRunState(claim);
|
|
1917
|
-
trackProgress(claim, item
|
|
1947
|
+
trackProgress(claim, item);
|
|
1918
1948
|
if (row.status === "busy" || row.status === "running") sawBusy = true;
|
|
1919
1949
|
if (row.status === "waiting") {
|
|
1920
1950
|
// Only terminal once the run has actually been working. A session can
|
|
@@ -1990,10 +2020,10 @@ function nextItem(queue, busyRepos, attempts) {
|
|
|
1990
2020
|
for (const i of queue.queued || []) {
|
|
1991
2021
|
if (busyRepos.has(i.repo)) continue;
|
|
1992
2022
|
if (i.localPath && existsSync(i.localPath)) return i;
|
|
1993
|
-
const prev = attempts.findLast((a) => a
|
|
2023
|
+
const prev = attempts.findLast((a) => historyKey(a) === historyKey(i));
|
|
1994
2024
|
log(`${i.id}: no checkout at ${i.localPath || "(none configured)"} - not launched`);
|
|
1995
2025
|
if (!DRY && prev?.outcome !== OUTCOME.BLOCKED_NO_PATH) {
|
|
1996
|
-
record({
|
|
2026
|
+
record({ ...rowItem(i), outcome: OUTCOME.BLOCKED_NO_PATH });
|
|
1997
2027
|
}
|
|
1998
2028
|
}
|
|
1999
2029
|
return null;
|
|
@@ -2271,7 +2301,7 @@ async function main() {
|
|
|
2271
2301
|
if (!arm.armed) {
|
|
2272
2302
|
log(`not armed: ${arm.reason}`);
|
|
2273
2303
|
if (!DRY) {
|
|
2274
|
-
record({
|
|
2304
|
+
record({ ...rowItem(next), outcome: `blocked-${arm.blockedBy}` });
|
|
2275
2305
|
writeState("queue.json", { ...queue, blockedReason: arm.reason });
|
|
2276
2306
|
refreshStatus();
|
|
2277
2307
|
}
|
|
@@ -2290,7 +2320,7 @@ async function main() {
|
|
|
2290
2320
|
`not launching: ${guard.reason} (install registers it; see features/unattended-security.md)`,
|
|
2291
2321
|
);
|
|
2292
2322
|
if (!DRY) {
|
|
2293
|
-
record({
|
|
2323
|
+
record({ ...rowItem(next), outcome: OUTCOME.BLOCKED_GUARD_MISSING });
|
|
2294
2324
|
writeState("queue.json", { ...queue, blockedReason: guard.reason });
|
|
2295
2325
|
refreshStatus();
|
|
2296
2326
|
}
|
|
@@ -2306,7 +2336,7 @@ async function main() {
|
|
|
2306
2336
|
if (!sandbox.ok) {
|
|
2307
2337
|
log(`not launching: ${sandbox.reason} (see features/unattended-security.md)`);
|
|
2308
2338
|
if (!DRY) {
|
|
2309
|
-
record({
|
|
2339
|
+
record({ ...rowItem(next), outcome: OUTCOME.BLOCKED_SANDBOX_UNAVAILABLE });
|
|
2310
2340
|
writeState("queue.json", { ...queue, blockedReason: sandbox.reason });
|
|
2311
2341
|
refreshStatus();
|
|
2312
2342
|
}
|
|
@@ -2325,7 +2355,7 @@ async function main() {
|
|
|
2325
2355
|
const reason = `installed v${local || "?"} is below the required v${required || "?"}; run the update`;
|
|
2326
2356
|
log(`not launching: ${reason}`);
|
|
2327
2357
|
if (!DRY) {
|
|
2328
|
-
record({
|
|
2358
|
+
record({ ...rowItem(next), outcome: OUTCOME.BLOCKED_VERSION_FLOOR });
|
|
2329
2359
|
writeState("queue.json", { ...queue, blockedReason: reason });
|
|
2330
2360
|
refreshStatus();
|
|
2331
2361
|
}
|
|
@@ -2367,6 +2397,7 @@ async function main() {
|
|
|
2367
2397
|
...running,
|
|
2368
2398
|
{
|
|
2369
2399
|
id: next.id,
|
|
2400
|
+
kind: next.kind,
|
|
2370
2401
|
repo: next.repo,
|
|
2371
2402
|
stack: next.stack,
|
|
2372
2403
|
startedAt: claim.startedAt,
|
|
@@ -2376,7 +2407,7 @@ async function main() {
|
|
|
2376
2407
|
taskId,
|
|
2377
2408
|
},
|
|
2378
2409
|
],
|
|
2379
|
-
queued: (queue.queued || []).filter((i) => i
|
|
2410
|
+
queued: (queue.queued || []).filter((i) => historyKey(i) !== historyKey(next)),
|
|
2380
2411
|
});
|
|
2381
2412
|
refreshStatus();
|
|
2382
2413
|
|
|
@@ -2399,8 +2430,7 @@ async function main() {
|
|
|
2399
2430
|
const why = (child.stderr || child.error?.message || "").trim().slice(0, 300);
|
|
2400
2431
|
// Nothing ran, so nothing was spent: 0 here is a measurement, not a guess.
|
|
2401
2432
|
record({
|
|
2402
|
-
|
|
2403
|
-
id: next.id,
|
|
2433
|
+
...rowItem(next),
|
|
2404
2434
|
taskId,
|
|
2405
2435
|
outcome: OUTCOME.LAUNCH_FAILED,
|
|
2406
2436
|
note: why,
|
|
@@ -2459,10 +2489,9 @@ async function main() {
|
|
|
2459
2489
|
// ---- 6. RECORD ---------------------------------------------------------
|
|
2460
2490
|
// From the run's own state file, not from the child's exit code and not from
|
|
2461
2491
|
// its stdout - with `--bg` the stdout is a session id and nothing else.
|
|
2462
|
-
const outcome = pub.outcome || outcomeFor(supervised, stateNow, prNow);
|
|
2492
|
+
const outcome = pub.outcome || outcomeFor(supervised, stateNow, prNow, next);
|
|
2463
2493
|
record({
|
|
2464
|
-
|
|
2465
|
-
id: next.id,
|
|
2494
|
+
...rowItem(next),
|
|
2466
2495
|
taskId,
|
|
2467
2496
|
outcome,
|
|
2468
2497
|
prUrl: prNow,
|
|
@@ -122,8 +122,14 @@ msg() { # $1 = key, $2.. = printf arguments
|
|
|
122
122
|
en='Running (%s):'
|
|
123
123
|
tr='Koşuyor (%s):' ;;
|
|
124
124
|
heading-queued)
|
|
125
|
-
en='Queued (%s):'
|
|
126
|
-
tr='
|
|
125
|
+
en='Queued for development (%s) - each ends at a pull request:'
|
|
126
|
+
tr='Geliştirme sırasında (%s) - her biri bir PR ile biter:' ;;
|
|
127
|
+
heading-queued-analysis)
|
|
128
|
+
en='Queued for analysis (%s) - each ends at a written document, no branch and no PR:'
|
|
129
|
+
tr='Analiz sırasında (%s) - her biri yazılı bir dokümanla biter, branch ve PR yok:' ;;
|
|
130
|
+
analysis-subject)
|
|
131
|
+
en='analysis'
|
|
132
|
+
tr='analiz' ;;
|
|
127
133
|
heading-awaiting)
|
|
128
134
|
en='Waiting for an answer (%s) - the open questions are posted, and it continues once they are answered:'
|
|
129
135
|
tr='Cevap bekliyor (%s) - açık soruları yorumladık, cevap gelince devam edecek:' ;;
|
|
@@ -164,6 +170,11 @@ QUEUE=$(ma_ap_read queue.json 2>/dev/null || echo '{}')
|
|
|
164
170
|
RUNNING=$(printf '%s' "$QUEUE" | jq -c '[.running[]? | select((.state // "running") == "running")]' 2>/dev/null || echo '[]')
|
|
165
171
|
QUEUED=$(printf '%s' "$QUEUE" | jq -c '[.queued[]?]' 2>/dev/null || echo '[]')
|
|
166
172
|
AWAITING=$(printf '%s' "$QUEUE" | jq -c '[.awaiting[]?]' 2>/dev/null || echo '[]')
|
|
173
|
+
# The two queues, shown apart because they deliver different things. A row
|
|
174
|
+
# written before the analysis kind existed carries no `kind` and is development,
|
|
175
|
+
# which is what it was.
|
|
176
|
+
QUEUED_DEV=$(printf '%s' "$QUEUED" | jq -c '[.[] | select((.kind // "development") != "analysis")]' 2>/dev/null || echo '[]')
|
|
177
|
+
QUEUED_ANALYSIS=$(printf '%s' "$QUEUED" | jq -c '[.[] | select(.kind == "analysis")]' 2>/dev/null || echo '[]')
|
|
167
178
|
LAST_TICK=$(printf '%s' "$QUEUE" | jq -r '.lastTickAt // empty' 2>/dev/null)
|
|
168
179
|
EMPTY_REASON=$(printf '%s' "$QUEUE" | jq -r '.emptyReason // empty' 2>/dev/null)
|
|
169
180
|
BLOCKED=$(printf '%s' "$QUEUE" | jq -r '.blockedReason // empty' 2>/dev/null)
|
|
@@ -241,6 +252,7 @@ build_json() {
|
|
|
241
252
|
jq -nc \
|
|
242
253
|
--argjson on "$ON" --argjson slots "$SLOTS" \
|
|
243
254
|
--argjson running "$RUNNING" --argjson queued "$QUEUED" --argjson awaiting "$AWAITING" \
|
|
255
|
+
--argjson queuedDevelopment "$QUEUED_DEV" --argjson queuedAnalysis "$QUEUED_ANALYSIS" \
|
|
244
256
|
--argjson reports "$REPORTS" --argjson todayCount "$TODAY_N" --argjson todayUsd "$TODAY_USD" \
|
|
245
257
|
--arg power "$POWER" --arg note "$NOTE" --arg stopCommand "$STOP_COMMAND" \
|
|
246
258
|
--arg emptyReason "$EMPTY_REASON" --arg blockedReason "$BLOCKED" \
|
|
@@ -250,7 +262,8 @@ build_json() {
|
|
|
250
262
|
--argjson inhibitorHeld "$INHIBITOR_HELD" --arg lastGcReport "$LAST_GC" \
|
|
251
263
|
--arg lastDigest "$LAST_DIGEST" --argjson maxParallelAgents "$MAX_PAR" \
|
|
252
264
|
--argjson awake "$AWAKE" \
|
|
253
|
-
'{on:$on, slots:$slots, running:$running, queued:$queued,
|
|
265
|
+
'{on:$on, slots:$slots, running:$running, queued:$queued,
|
|
266
|
+
queuedDevelopment:$queuedDevelopment, queuedAnalysis:$queuedAnalysis, awaiting:$awaiting,
|
|
254
267
|
reports:$reports, todayCount:$todayCount, todayUsd:$todayUsd,
|
|
255
268
|
lastTickAt:$lastTickAt, power:$power, note:$note, stopCommand:$stopCommand,
|
|
256
269
|
scanIntervalSeconds:$interval, emptyReason:$emptyReason,
|
|
@@ -296,13 +309,15 @@ fi
|
|
|
296
309
|
|
|
297
310
|
NR=$(printf '%s' "$RUNNING" | jq 'length')
|
|
298
311
|
NQ=$(printf '%s' "$QUEUED" | jq 'length')
|
|
312
|
+
NQD=$(printf '%s' "$QUEUED_DEV" | jq 'length')
|
|
313
|
+
NQA=$(printf '%s' "$QUEUED_ANALYSIS" | jq 'length')
|
|
299
314
|
NA=$(printf '%s' "$AWAITING" | jq 'length')
|
|
300
315
|
|
|
301
316
|
if [ "$MODE" = "subjects" ]; then
|
|
302
317
|
# One line per item, with the numbers INSIDE the string: the widget takes
|
|
303
318
|
# exactly one string per row, so anything the reader needs has to travel in it.
|
|
304
|
-
printf '%s' "$RUNNING" | jq -r --arg phase "$(msg phase-word)" '.[] |
|
|
305
|
-
"\(.id) · \($phase) \(.phase // "?")\(if .phaseTotal then "/\(.phaseTotal)" else "" end) \(.phaseName // "") · \(.stack // "")"'
|
|
319
|
+
printf '%s' "$RUNNING" | jq -r --arg phase "$(msg phase-word)" --arg analysis "$(msg analysis-subject)" '.[] |
|
|
320
|
+
"\(.id) · \($phase) \(.phase // "?")\(if .phaseTotal then "/\(.phaseTotal)" else "" end) \(.phaseName // "") · \(.stack // "")\(if .kind == "analysis" then " · " + $analysis else "" end)"'
|
|
306
321
|
printf '%s' "$AWAITING" | jq -r --arg awaiting "$(msg awaiting-subject)" '.[] | "\(.id) · \($awaiting)"'
|
|
307
322
|
exit 0
|
|
308
323
|
fi
|
|
@@ -339,11 +354,19 @@ fi
|
|
|
339
354
|
echo
|
|
340
355
|
if [ "$NR" -gt 0 ]; then
|
|
341
356
|
msg heading-running "$NR"
|
|
342
|
-
printf '%s' "$RUNNING" | jq -r
|
|
357
|
+
printf '%s' "$RUNNING" | jq -r --arg analysis "$(msg analysis-subject)" '.[] |
|
|
358
|
+
" \(.id) · \(.phaseName // .phase // "?") · \(.stack // "")\(if .kind == "analysis" then " · " + $analysis else "" end)"'
|
|
343
359
|
fi
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
360
|
+
# Two headings rather than one list with a column: the queues deliver different
|
|
361
|
+
# things, and "queued" without saying which one leaves the reader waiting for a
|
|
362
|
+
# pull request that was never going to arrive.
|
|
363
|
+
if [ "$NQD" -gt 0 ]; then
|
|
364
|
+
msg heading-queued "$NQD"
|
|
365
|
+
printf '%s' "$QUEUED_DEV" | jq -r '.[0:8][] | " \(.id)"'
|
|
366
|
+
fi
|
|
367
|
+
if [ "$NQA" -gt 0 ]; then
|
|
368
|
+
msg heading-queued-analysis "$NQA"
|
|
369
|
+
printf '%s' "$QUEUED_ANALYSIS" | jq -r '.[0:8][] | " \(.id)"'
|
|
347
370
|
fi
|
|
348
371
|
if [ "$NA" -gt 0 ]; then
|
|
349
372
|
msg heading-awaiting "$NA"
|
|
@@ -105,7 +105,35 @@ case "$TIMEOUT" in ""|*[!0-9]*|0) TIMEOUT=60 ;; esac
|
|
|
105
105
|
|
|
106
106
|
FALLBACK_MODEL="${PREF_MODEL:-haiku}"
|
|
107
107
|
[ "$FALLBACK_MODEL" = "free" ] && FALLBACK_MODEL="haiku"
|
|
108
|
-
|
|
108
|
+
|
|
109
|
+
# The one-shot, non-interactive call this host answers a delegated read with.
|
|
110
|
+
# Not every host has one: a host that only runs interactively cannot be asked
|
|
111
|
+
# this way at all, and saying so is the honest answer - the caller reads the
|
|
112
|
+
# region itself. The argv comes from the registry so this script never names a
|
|
113
|
+
# CLI it might not be installed beside.
|
|
114
|
+
ma_headless_argv() {
|
|
115
|
+
local hosts="$HERE/../schemas/hosts.json" id
|
|
116
|
+
[ -f "$hosts" ] || { printf 'claude\n-p\n--model\n%s\n' "$1"; return 0; }
|
|
117
|
+
command -v jq >/dev/null 2>&1 || { printf 'claude\n-p\n--model\n%s\n' "$1"; return 0; }
|
|
118
|
+
[ -f "$HERE/../lib/host.sh" ] && . "$HERE/../lib/host.sh"
|
|
119
|
+
# An unresolvable host answers with the shipped argv rather than the first
|
|
120
|
+
# registered host's: assuming one would run another CLI's binary.
|
|
121
|
+
id=$(command -v ma_host_id >/dev/null 2>&1 && ma_host_id || echo "")
|
|
122
|
+
[ -n "$id" ] || { printf 'claude\n-p\n--model\n%s\n' "$1"; return 0; }
|
|
123
|
+
# `{model}` is the MODEL this host runs, not the rung name the router returns.
|
|
124
|
+
# They are the same string on a host whose rung names are its model aliases
|
|
125
|
+
# and nowhere else, so the rung is resolved through the registry first.
|
|
126
|
+
jq -r --arg id "$id" --arg r "$1" \
|
|
127
|
+
'(.hosts[$id].models.rungs[$r].model // $r) as $m
|
|
128
|
+
| (.hosts[$id].headless.argv // []) | .[] | sub("\\{model\\}"; $m)' "$hosts" 2>/dev/null
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
HEADLESS=()
|
|
132
|
+
while IFS= read -r _arg; do [ -n "$_arg" ] && HEADLESS+=("$_arg"); done < <(ma_headless_argv "$MODEL")
|
|
133
|
+
if [ "$MODEL" != "free" ]; then
|
|
134
|
+
[ ${#HEADLESS[@]} -gt 0 ] || degrade "this host has no one-shot call a delegated read can use"
|
|
135
|
+
command -v "${HEADLESS[0]}" >/dev/null 2>&1 || degrade "the ${HEADLESS[0]} CLI is not on PATH"
|
|
136
|
+
fi
|
|
109
137
|
|
|
110
138
|
LINES=$(wc -l < "$FILE" | tr -d ' ')
|
|
111
139
|
BYTES=$(wc -c < "$FILE" | tr -d ' ')
|
|
@@ -273,11 +301,15 @@ PYEOF
|
|
|
273
301
|
if [ "$FREE_DONE" != 1 ]; then
|
|
274
302
|
echo "bulk-read: free chain not used ($FREE_REASON); reading on $FALLBACK_MODEL" >&2
|
|
275
303
|
MODEL="$FALLBACK_MODEL"
|
|
276
|
-
|
|
304
|
+
HEADLESS=()
|
|
305
|
+
while IFS= read -r _arg; do [ -n "$_arg" ] && HEADLESS+=("$_arg"); done < <(ma_headless_argv "$MODEL")
|
|
306
|
+
[ ${#HEADLESS[@]} -gt 0 ] || degrade "this host has no one-shot call a delegated read can use"
|
|
307
|
+
command -v "${HEADLESS[0]}" >/dev/null 2>&1 || degrade "the ${HEADLESS[0]} CLI is not on PATH"
|
|
277
308
|
fi
|
|
278
309
|
fi
|
|
279
310
|
|
|
280
|
-
#
|
|
311
|
+
# The headless call reads the prompt from stdin and names the rung in its own
|
|
312
|
+
# argv (registry `headless.argv`, `{model}` substituted above). A
|
|
281
313
|
# non-zero exit, an empty answer and a non-JSON answer are all degradations, and
|
|
282
314
|
# each one names itself rather than falling through to a generic failure.
|
|
283
315
|
# macOS ships no `timeout`; coreutils installs it as `gtimeout`. Naming only the
|
|
@@ -287,13 +319,13 @@ fi
|
|
|
287
319
|
if [ "$FREE_DONE" = 1 ]; then
|
|
288
320
|
STATUS=0
|
|
289
321
|
elif [ -n "$TIMEOUT_BIN" ]; then
|
|
290
|
-
"$TIMEOUT_BIN" "$TIMEOUT"
|
|
322
|
+
"$TIMEOUT_BIN" "$TIMEOUT" "${HEADLESS[@]}" < "$PROMPT_FILE" > "$OUT_FILE" 2>/dev/null
|
|
291
323
|
STATUS=$?
|
|
292
324
|
else
|
|
293
325
|
# No timeout binary: the budget cannot be enforced, so say so rather than
|
|
294
326
|
# letting the caller believe timeoutSeconds is holding.
|
|
295
327
|
echo "bulk-read: no timeout binary found; bulkRead.timeoutSeconds is not enforced on this host" >&2
|
|
296
|
-
|
|
328
|
+
"${HEADLESS[@]}" < "$PROMPT_FILE" > "$OUT_FILE" 2>/dev/null
|
|
297
329
|
STATUS=$?
|
|
298
330
|
fi
|
|
299
331
|
ELAPSED=$(( $(date +%s) - START ))
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import { existsSync, readFileSync } from "node:fs";
|
|
21
21
|
import { basename } from "node:path";
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { resolveSecretAsync, selectAccount } from "../lib/service-account.mjs";
|
|
24
24
|
import { runMain } from "../lib/fatal.mjs";
|
|
25
25
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
26
26
|
|
|
@@ -91,15 +91,23 @@ async function main() {
|
|
|
91
91
|
process.exitCode = 2;
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
94
|
+
// The base URL is a destination, not a setting: it goes to the resolver,
|
|
95
|
+
// which hands back a token only for a host a Confluence account names.
|
|
96
|
+
const asked = (process.env.CONFLUENCE_BASE_URL || "").replace(/\/+$/, "");
|
|
97
|
+
const chosen = selectAccount({ service: "confluence", url: asked || undefined });
|
|
98
|
+
if (!chosen.ok) {
|
|
99
|
+
process.stderr.write(`ERR: ${chosen.message} ${chosen.remedy}\n`);
|
|
100
|
+
process.exitCode = 2;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const base = asked || chosen.account.baseUrl || `https://${chosen.account.hosts[0]}`;
|
|
104
|
+
const answer = await resolveSecretAsync({ service: "confluence", url: base });
|
|
105
|
+
if (!answer.ok) {
|
|
106
|
+
process.stderr.write(`ERR: ${answer.message} ${answer.remedy}\n`);
|
|
100
107
|
process.exitCode = 2;
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
110
|
+
const token = answer.secret;
|
|
103
111
|
const md = readFileSync(mdPath, "utf8");
|
|
104
112
|
const id = encodeURIComponent(pageId);
|
|
105
113
|
let content;
|