@dadado/agent-kit-cli 6.18.0 → 6.19.1
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/dashboard/dashboard-data.mjs +8 -3
- package/dashboard/dashboard.html +140 -0
- package/dashboard/lib/guards.d.mts +20 -0
- package/dashboard/lib/guards.mjs +307 -0
- package/dashboard/lib/semantic-model.mjs +228 -1
- package/dist/{add-JZKFUH2O.js → add-DYRNPADR.js} +3 -3
- package/dist/{chunk-R4VLVX7B.js → chunk-2YPIQCPL.js} +9 -9
- package/dist/{chunk-H5D3HF2N.js → chunk-5EBT3V7G.js} +1 -1
- package/dist/{chunk-42AA2VFW.js → chunk-5V4C5N2P.js} +2 -2
- package/dist/{chunk-SKC6QZW4.js → chunk-6WUKLS4D.js} +1 -1
- package/dist/{chunk-CRH2Q6KY.js → chunk-6XJZLH53.js} +149 -18
- package/dist/{chunk-L7BL4246.js → chunk-BGL5DRK2.js} +2 -2
- package/dist/{chunk-44SDKJYY.js → chunk-C4LCOOL4.js} +3 -1
- package/dist/chunk-DTSL2RH7.js +433 -0
- package/dist/{chunk-BDIWC3WB.js → chunk-DY6EWD5X.js} +2 -2
- package/dist/{chunk-357Y422W.js → chunk-HJWSOZXS.js} +52 -12
- package/dist/{chunk-2CBKKCVU.js → chunk-KF544JTV.js} +2 -1
- package/dist/{chunk-4KV3TXKC.js → chunk-LX5AO7KO.js} +1 -1
- package/dist/{chunk-ZFJIJUZ4.js → chunk-MPCNPZJZ.js} +1 -1
- package/dist/{chunk-VY7AFID2.js → chunk-NA2LTNJS.js} +3 -3
- package/dist/{chunk-YP5OCR4I.js → chunk-NAU3ROWR.js} +1 -1
- package/dist/{chunk-WJRNI5FJ.js → chunk-OXLLHI2W.js} +3 -3
- package/dist/{chunk-WRCXRV2U.js → chunk-P7732A25.js} +10 -0
- package/dist/chunk-QWTBYXHN.js +751 -0
- package/dist/{chunk-UEW42NIF.js → chunk-R3QNQWLB.js} +3 -3
- package/dist/{chunk-SC2DBY2R.js → chunk-R4DUO5DA.js} +1 -0
- package/dist/{chunk-MOJRD6HF.js → chunk-SGTTC2JP.js} +4 -3
- package/dist/{chunk-B4MUKUVS.js → chunk-SPXAHVK4.js} +64 -1
- package/dist/{chunk-CTVVGKYB.js → chunk-U23SLQGX.js} +5 -5
- package/dist/chunk-UATQQDVR.js +297 -0
- package/dist/{chunk-Y7BH6KIE.js → chunk-W3ZJVBNY.js} +6 -3
- package/dist/{hook-AZ5LSJBJ.js → chunk-WF3CXK4J.js} +104 -113
- package/dist/{chunk-VRSBZKTA.js → chunk-WKZ63IZ7.js} +1 -1
- package/dist/{chunk-XHANIDPK.js → chunk-WMS3SSOO.js} +1 -1
- package/dist/{chunk-OKIFM3IH.js → chunk-XJORZUTG.js} +1 -1
- package/dist/{chunk-XDCCYBCJ.js → chunk-ZMYV6PRE.js} +13 -0
- package/dist/{commands-5P2E5LL4.js → commands-EHKVW7JR.js} +50 -16
- package/dist/{conflicts-A4B422EL.js → conflicts-XMN4PBCZ.js} +7 -7
- package/dist/{contribute-GAHG3J4Q.js → contribute-H3SOZGQQ.js} +4 -4
- package/dist/{countdown-C6NY2TSG.js → countdown-7ONIVAG6.js} +39 -11
- package/dist/{dashboard-YNCFISNO.js → dashboard-P65XHYCU.js} +1 -1
- package/dist/{dashboard-broadcast-NK7PU72L.js → dashboard-broadcast-GYK34QYL.js} +1 -1
- package/dist/{diff-EYAGGEU4.js → diff-HLBPPBUB.js} +5 -5
- package/dist/{doctor-GOMPRU6F.js → doctor-NZITN3GU.js} +10 -10
- package/dist/{engine-info-R6GXZ2VO.js → engine-info-BBI5QO5Y.js} +3 -3
- package/dist/{ground-control-MJGF5QRE.js → ground-control-IDCXN5FK.js} +4 -4
- package/dist/hook-IEB3N5WM.js +108 -0
- package/dist/index.js +27 -27
- package/dist/{init-WW5DR3DX.js → init-KBYUX7RA.js} +13 -13
- package/dist/{install-RN2DRLK6.js → install-YLGAQSP2.js} +13 -13
- package/dist/{mission-control-JIF6GFSV.js → mission-control-QJBSZVNI.js} +2 -2
- package/dist/{queue-7EBQGPPW.js → queue-OJHKFKK3.js} +54 -10
- package/dist/{run-GOMAHNV2.js → run-PFANZJ5Y.js} +174 -26
- package/dist/{run-plan-EUQ5WWF6.js → run-plan-7EB4ERSQ.js} +45 -15
- package/dist/{scan-BWA64R7I.js → scan-K3T5RQLC.js} +1 -1
- package/dist/session-start-XUAPF7TR.js +74 -0
- package/dist/sessions-4TVVZBB7.js +102 -0
- package/dist/{setup-global-DJWURJS3.js → setup-global-ND75RQEV.js} +6 -6
- package/dist/{status-2WYPLWTN.js → status-JI6ILZO7.js} +8 -8
- package/dist/{update-5VFQNBY5.js → update-B2DX5IGC.js} +10 -10
- package/package.json +1 -1
- package/dist/sessions-O7MYEMCT.js +0 -343
|
@@ -820,12 +820,225 @@ export function cadenceWindowIdFromNow(now = Date.now()) {
|
|
|
820
820
|
return `w-${d.getUTCFullYear()}${p(d.getUTCMonth() + 1)}${p(d.getUTCDate())}${p(d.getUTCHours())}${p(d.getUTCMinutes())}${p(d.getUTCSeconds())}`;
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
+
/** One `- id:` to-do row in plan frontmatter. */
|
|
824
|
+
const FRONTMATTER_TODO_ID_RE = /^\s*-\s+id:\s*(\S+)\s*$/;
|
|
825
|
+
/** `evidence:` key inside a to-do row. */
|
|
826
|
+
const FRONTMATTER_EVIDENCE_RE = /^\s*evidence:\s*(.*)$/;
|
|
827
|
+
/** Structured PR ref: `<repo>#<n>` with no space (`agent-kit-dev#1484`, `colony#125`). */
|
|
828
|
+
const EVIDENCE_STRUCTURED_PR_RE = /(?<![\w#/.-])([A-Za-z][A-Za-z0-9._-]*)#(\d+)\b/g;
|
|
829
|
+
/** Prose fallback PR ref: a bare `#<n>` (older plans: `PR #1361`, `Colony #114`). */
|
|
830
|
+
const EVIDENCE_PROSE_PR_RE = /(?<![\w#/])#(\d+)\b/g;
|
|
831
|
+
/** Commit SHA token: 7-40 lowercase hex holding at least one digit and one letter. */
|
|
832
|
+
const EVIDENCE_SHA_RE = /(?<![\w/#.-])[0-9a-f]{7,40}(?![\w-])/g;
|
|
833
|
+
/** Owed classifier: a plan with less of its delivered lines alive reads as rewritten. */
|
|
834
|
+
export const OWED_SURVIVAL_REWRITTEN_PCT = 50;
|
|
835
|
+
const MAX_OWED_EVIDENCE_LINE = 160;
|
|
836
|
+
/** Cap on per-plan evidence rows carried by the cadence attention item. */
|
|
837
|
+
const MAX_CADENCE_PLAN_EVIDENCE = 50;
|
|
838
|
+
|
|
839
|
+
function unquoteYamlScalar(raw) {
|
|
840
|
+
const v = String(raw || "").trim();
|
|
841
|
+
if (v.startsWith('"') && v.endsWith('"') && v.length >= 2) {
|
|
842
|
+
try {
|
|
843
|
+
return JSON.parse(v);
|
|
844
|
+
} catch {
|
|
845
|
+
return v.slice(1, -1);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (v.startsWith("'") && v.endsWith("'") && v.length >= 2) {
|
|
849
|
+
return v.slice(1, -1).replace(/''/g, "'");
|
|
850
|
+
}
|
|
851
|
+
return v;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Per-to-do `evidence:` strings from plan frontmatter, keyed by to-do id.
|
|
856
|
+
* Single-line scalars only (double-quoted, single-quoted or plain); a missing
|
|
857
|
+
* or empty value is omitted.
|
|
858
|
+
* @param {string} frontmatter - text between the `---` fences
|
|
859
|
+
* @returns {Map<string, string>}
|
|
860
|
+
*/
|
|
861
|
+
export function parseTodoEvidenceFromFrontmatter(frontmatter) {
|
|
862
|
+
const out = new Map();
|
|
863
|
+
if (typeof frontmatter !== "string" || !frontmatter) return out;
|
|
864
|
+
let current = null;
|
|
865
|
+
for (const line of frontmatter.split("\n")) {
|
|
866
|
+
const idMatch = FRONTMATTER_TODO_ID_RE.exec(line);
|
|
867
|
+
if (idMatch) {
|
|
868
|
+
current = idMatch[1];
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (!current) continue;
|
|
872
|
+
if (/^\S/.test(line)) {
|
|
873
|
+
current = null;
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
const ev = FRONTMATTER_EVIDENCE_RE.exec(line);
|
|
877
|
+
if (ev && !out.has(current)) {
|
|
878
|
+
const value = unquoteYamlScalar(ev[1]);
|
|
879
|
+
if (value) out.set(current, value);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return out;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Delivery refs in one to-do `evidence:` string. Structured `<repo>#<n>` refs
|
|
887
|
+
* win; a plan without them falls back to bare `#<n>` prose refs (repo null).
|
|
888
|
+
* SHAs are 7-40 hex tokens with a digit and a letter. Refs only: no prose
|
|
889
|
+
* leaves this function.
|
|
890
|
+
* @param {unknown} evidence
|
|
891
|
+
* @returns {{ prs: { repo: string|null, number: number }[], shas: string[], structured: boolean }}
|
|
892
|
+
*/
|
|
893
|
+
export function parseTodoEvidenceRefs(evidence) {
|
|
894
|
+
const empty = { prs: [], shas: [], structured: false };
|
|
895
|
+
if (typeof evidence !== "string" || !evidence.trim()) return empty;
|
|
896
|
+
const prs = [];
|
|
897
|
+
const seenPr = new Set();
|
|
898
|
+
for (const m of evidence.matchAll(EVIDENCE_STRUCTURED_PR_RE)) {
|
|
899
|
+
const repo = m[1].toLowerCase();
|
|
900
|
+
if (repo === "pr") continue;
|
|
901
|
+
const key = `${repo}#${m[2]}`;
|
|
902
|
+
if (seenPr.has(key)) continue;
|
|
903
|
+
seenPr.add(key);
|
|
904
|
+
prs.push({ repo, number: Number(m[2]) });
|
|
905
|
+
}
|
|
906
|
+
const structured = prs.length > 0;
|
|
907
|
+
if (!structured) {
|
|
908
|
+
for (const m of evidence.matchAll(EVIDENCE_PROSE_PR_RE)) {
|
|
909
|
+
const key = `#${m[1]}`;
|
|
910
|
+
if (seenPr.has(key)) continue;
|
|
911
|
+
seenPr.add(key);
|
|
912
|
+
prs.push({ repo: null, number: Number(m[1]) });
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
const shas = [];
|
|
916
|
+
for (const m of evidence.matchAll(EVIDENCE_SHA_RE)) {
|
|
917
|
+
const sha = m[0];
|
|
918
|
+
if (!/[0-9]/.test(sha) || !/[a-f]/.test(sha) || shas.includes(sha)) continue;
|
|
919
|
+
shas.push(sha);
|
|
920
|
+
}
|
|
921
|
+
return { prs, shas, structured };
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Attach `evidenceRefs` to parsed to-do items from the plan frontmatter.
|
|
926
|
+
* Mutates and returns `todos`; items without evidence are left unchanged.
|
|
927
|
+
* @param {string} frontmatter
|
|
928
|
+
* @param {{ id: string }[]} todos
|
|
929
|
+
*/
|
|
930
|
+
export function attachTodoEvidenceRefs(frontmatter, todos) {
|
|
931
|
+
const evidence = parseTodoEvidenceFromFrontmatter(frontmatter);
|
|
932
|
+
if (evidence.size === 0) return todos;
|
|
933
|
+
for (const todo of todos || []) {
|
|
934
|
+
const text = todo && evidence.get(todo.id);
|
|
935
|
+
if (!text) continue;
|
|
936
|
+
const refs = parseTodoEvidenceRefs(text);
|
|
937
|
+
if (refs.prs.length > 0 || refs.shas.length > 0) todo.evidenceRefs = refs;
|
|
938
|
+
}
|
|
939
|
+
return todos;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Merged delivery refs of a plan's completed to-dos (structured first).
|
|
944
|
+
* @param {object} plan
|
|
945
|
+
* @returns {{ prs: { repo: string|null, number: number }[], shas: string[], structured: boolean }}
|
|
946
|
+
*/
|
|
947
|
+
export function planDeliveryRefs(plan) {
|
|
948
|
+
const prs = [];
|
|
949
|
+
const shas = [];
|
|
950
|
+
const seenPr = new Set();
|
|
951
|
+
let structured = false;
|
|
952
|
+
for (const todo of plan?.todos?.items || []) {
|
|
953
|
+
if (todo?.status !== "completed") continue;
|
|
954
|
+
const refs = todo.evidenceRefs;
|
|
955
|
+
if (!refs) continue;
|
|
956
|
+
if (refs.structured) structured = true;
|
|
957
|
+
for (const pr of refs.prs || []) {
|
|
958
|
+
const key = `${pr.repo || ""}#${pr.number}`;
|
|
959
|
+
if (seenPr.has(key)) continue;
|
|
960
|
+
seenPr.add(key);
|
|
961
|
+
prs.push(pr);
|
|
962
|
+
}
|
|
963
|
+
for (const sha of refs.shas || []) {
|
|
964
|
+
if (!shas.includes(sha)) shas.push(sha);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return { prs, shas, structured };
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function formatDeliveryRefs(refs) {
|
|
971
|
+
const parts = [];
|
|
972
|
+
const prs = refs.prs.slice(0, 3).map((p) => (p.repo ? `${p.repo}#${p.number}` : `#${p.number}`));
|
|
973
|
+
if (prs.length > 0) {
|
|
974
|
+
const more = refs.prs.length > 3 ? ` +${refs.prs.length - 3}` : "";
|
|
975
|
+
parts.push(`${prs.join(", ")}${more}`);
|
|
976
|
+
}
|
|
977
|
+
if (refs.shas.length > 0) {
|
|
978
|
+
const more = refs.shas.length > 2 ? ` +${refs.shas.length - 2}` : "";
|
|
979
|
+
parts.push(`merged ${refs.shas.slice(0, 2).join(", ")}${more}`);
|
|
980
|
+
}
|
|
981
|
+
if (parts.length === 0) return "no PR ref or merge SHA in to-do evidence";
|
|
982
|
+
return parts.join(" ") + (refs.structured ? "" : " (prose refs)");
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Classify one terminal plan for the owed review set, with one evidence line.
|
|
987
|
+
* Reads frontmatter facts only (to-do status, structured `evidence:` refs);
|
|
988
|
+
* `survival` comes from the on-demand blame script and is never computed on
|
|
989
|
+
* the Mission Control snapshot path. A class never removes a plan from the
|
|
990
|
+
* owed set by itself.
|
|
991
|
+
* @param {object} plan
|
|
992
|
+
* @param {string} lifecycle - resolvePlanLifecycle result
|
|
993
|
+
* @param {{ survival?: { added: number, alive: number } | null }} [opts]
|
|
994
|
+
* @returns {{ classification: 'delivered-nothing'|'partial-parked'|'superseded-or-rewritten'|'live-unreviewed', evidenceLine: string }}
|
|
995
|
+
*/
|
|
996
|
+
export function classifyOwedPlan(plan, lifecycle, opts = {}) {
|
|
997
|
+
const stats = todoStats(plan);
|
|
998
|
+
const done = `${stats.completed} of ${stats.total} to-dos completed`;
|
|
999
|
+
if (stats.completed === 0) {
|
|
1000
|
+
const why = stats.cancelled > 0 && stats.open === 0 ? "all cancelled" : "none completed";
|
|
1001
|
+
return { classification: "delivered-nothing", evidenceLine: `${done} (${why})` };
|
|
1002
|
+
}
|
|
1003
|
+
const refs = planDeliveryRefs(plan);
|
|
1004
|
+
let refsText = formatDeliveryRefs(refs);
|
|
1005
|
+
const survival = opts.survival;
|
|
1006
|
+
if (survival && Number.isFinite(survival.added) && survival.added > 0) {
|
|
1007
|
+
const pct = Math.round((Math.max(0, survival.alive) / survival.added) * 100);
|
|
1008
|
+
const survivalText = `about ${pct}% of ${survival.added} delivered lines alive`;
|
|
1009
|
+
if (pct < OWED_SURVIVAL_REWRITTEN_PCT) {
|
|
1010
|
+
return {
|
|
1011
|
+
classification: "superseded-or-rewritten",
|
|
1012
|
+
evidenceLine: truncateStr(`${survivalText}; ${refsText}`, MAX_OWED_EVIDENCE_LINE),
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
refsText = `${survivalText}; ${refsText}`;
|
|
1016
|
+
}
|
|
1017
|
+
if (lifecycle === "parked" && stats.open > 0) {
|
|
1018
|
+
return {
|
|
1019
|
+
classification: "partial-parked",
|
|
1020
|
+
evidenceLine: truncateStr(`parked, ${done}; ${refsText}`, MAX_OWED_EVIDENCE_LINE),
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
return {
|
|
1024
|
+
classification: "live-unreviewed",
|
|
1025
|
+
evidenceLine: truncateStr(`${done}; ${refsText}`, MAX_OWED_EVIDENCE_LINE),
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
|
|
823
1029
|
/**
|
|
824
1030
|
* List still-unreviewed work for cadence emit and batch CTAs.
|
|
825
1031
|
* Includes untriaged monitors and terminal plans without a matching monitor
|
|
826
1032
|
* file (existence). Every report slug enters `monitorSlugs`; triage only gates
|
|
827
1033
|
* first-loop inclusion. Does not emit owed attention rows.
|
|
828
|
-
*
|
|
1034
|
+
* A terminal plan with zero completed to-dos delivered nothing (all cancelled,
|
|
1035
|
+
* or parked with every to-do still open) and is never owed. A parked plan with
|
|
1036
|
+
* open work is owed for its completed slice only: `completedTodoIds` names it.
|
|
1037
|
+
* Archived plans are not in `plans` (basenames only), so they are never owed.
|
|
1038
|
+
* `TERMINAL_FIELD_REPORT_LIFECYCLES` stays unchanged: it also drives prompt
|
|
1039
|
+
* clear and report demotion.
|
|
1040
|
+
* Owed targets also carry `classification` and one `evidenceLine` (classifyOwedPlan).
|
|
1041
|
+
* @returns {{ kind: 'report'|'owed', planFile: string, slug: string, path: string, lifecycle?: string, completedTodoIds?: string[], totalTodos?: number, classification?: string, evidenceLine?: string }[]}
|
|
829
1042
|
*/
|
|
830
1043
|
export function listUnreviewedReviewTargets(
|
|
831
1044
|
plans,
|
|
@@ -865,12 +1078,18 @@ export function listUnreviewedReviewTargets(
|
|
|
865
1078
|
if (!isPlanLifecycleTerminal(lifecycle)) continue;
|
|
866
1079
|
const slug = planFile.replace(/\.plan\.md$/i, "");
|
|
867
1080
|
if (!slug || monitorSlugs.has(normalizeSlug(slug))) continue;
|
|
1081
|
+
const stats = todoStats(plan);
|
|
1082
|
+
if (stats.completed === 0) continue;
|
|
868
1083
|
seenPlans.add(planFile);
|
|
869
1084
|
targets.push({
|
|
870
1085
|
kind: "owed",
|
|
871
1086
|
planFile,
|
|
872
1087
|
slug,
|
|
873
1088
|
path: `.cursor/plans/${planFile}`,
|
|
1089
|
+
lifecycle,
|
|
1090
|
+
completedTodoIds: stats.items.filter((t) => t.status === "completed").map((t) => t.id),
|
|
1091
|
+
totalTodos: stats.total,
|
|
1092
|
+
...classifyOwedPlan(plan, lifecycle),
|
|
874
1093
|
});
|
|
875
1094
|
}
|
|
876
1095
|
|
|
@@ -1025,6 +1244,14 @@ export function buildCadenceAttentionItem(ledger, targets, opts = {}) {
|
|
|
1025
1244
|
modifiedAt: parsed.lastBatchCompleteAt || null,
|
|
1026
1245
|
progress: null,
|
|
1027
1246
|
pendingPlanFiles: parsed.pendingPlanFiles.slice(),
|
|
1247
|
+
planEvidence: liveTargets
|
|
1248
|
+
.filter((t) => t && t.kind === "owed" && typeof t.evidenceLine === "string")
|
|
1249
|
+
.slice(0, MAX_CADENCE_PLAN_EVIDENCE)
|
|
1250
|
+
.map((t) => ({
|
|
1251
|
+
planFile: t.planFile,
|
|
1252
|
+
classification: t.classification || null,
|
|
1253
|
+
evidenceLine: t.evidenceLine,
|
|
1254
|
+
})),
|
|
1028
1255
|
action: {
|
|
1029
1256
|
type: "copy",
|
|
1030
1257
|
target: batchTarget,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
REGISTRY_CLI_ARGS,
|
|
7
7
|
resolveRegistryFromCli
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LX5AO7KO.js";
|
|
9
9
|
import {
|
|
10
10
|
logger
|
|
11
11
|
} from "./chunk-ZB43YMHW.js";
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
resolveProtectedGlobs,
|
|
23
23
|
saveManifest,
|
|
24
24
|
upsertIdList
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-WKZ63IZ7.js";
|
|
26
|
+
import "./chunk-SPXAHVK4.js";
|
|
27
27
|
import {
|
|
28
28
|
KIT_VERSION
|
|
29
29
|
} from "./chunk-7HDQEK6T.js";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatStaleCliRefusal,
|
|
7
7
|
installL0,
|
|
8
8
|
syncFromManifest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OXLLHI2W.js";
|
|
10
10
|
import {
|
|
11
11
|
SkippedSymlinkError,
|
|
12
12
|
formatPersonalizationSkippedSymlinks,
|
|
@@ -15,21 +15,21 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
REGISTRY_CLI_ARGS,
|
|
17
17
|
resolveRegistryFromCli
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LX5AO7KO.js";
|
|
19
19
|
import {
|
|
20
20
|
assessClaudeCommandAdapters,
|
|
21
21
|
executeSafeReadinessFixes
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-R3QNQWLB.js";
|
|
23
23
|
import {
|
|
24
24
|
writeReadinessSnapshot
|
|
25
25
|
} from "./chunk-HAFRAXGV.js";
|
|
26
26
|
import {
|
|
27
27
|
writeClaudeSessionStartHook
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-WMS3SSOO.js";
|
|
29
29
|
import {
|
|
30
30
|
CLAUDE_HITL_FALLBACK,
|
|
31
31
|
generateClaudeCommandAdapters
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-KF544JTV.js";
|
|
33
33
|
import {
|
|
34
34
|
shouldUseWelcomeColor,
|
|
35
35
|
withCliProgress
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
REPOSITORY_PROFILE_REL,
|
|
42
42
|
detectIde,
|
|
43
43
|
runScanner
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-R4DUO5DA.js";
|
|
45
45
|
import {
|
|
46
46
|
GIT_PLATFORM_META
|
|
47
47
|
} from "./chunk-F6C3GFKV.js";
|
|
@@ -56,13 +56,13 @@ import {
|
|
|
56
56
|
npxPinned,
|
|
57
57
|
pathCliStatus,
|
|
58
58
|
syncPathCliToRuntime
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-DY6EWD5X.js";
|
|
60
60
|
import {
|
|
61
61
|
assessEnvironment
|
|
62
62
|
} from "./chunk-B3VR5YBQ.js";
|
|
63
63
|
import {
|
|
64
64
|
warnIfRunningCliBehindNpm
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-5V4C5N2P.js";
|
|
66
66
|
import {
|
|
67
67
|
DOMAIN_PACK_IDS,
|
|
68
68
|
allPacks,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
resolveProtectedGlobs,
|
|
80
80
|
saveManifest,
|
|
81
81
|
skillTargetDir
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-WKZ63IZ7.js";
|
|
83
83
|
import {
|
|
84
84
|
KIT_VERSION,
|
|
85
85
|
pinnedCliSpec
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
diffAgainstRegistry,
|
|
8
8
|
summarizeDiff
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NA2LTNJS.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_REGISTRY_URL,
|
|
12
12
|
assertSafeRegistrySource,
|
|
13
13
|
loadAgentKitManifest,
|
|
14
14
|
resolveRegistryRoot
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WKZ63IZ7.js";
|
|
16
16
|
import {
|
|
17
17
|
KIT_PACKAGE_SPEC,
|
|
18
18
|
KIT_VERSION
|
|
@@ -3,15 +3,7 @@ import {
|
|
|
3
3
|
ScrollRegion,
|
|
4
4
|
renderMcLive,
|
|
5
5
|
runMcTuiLoop
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
countPendingTodos,
|
|
9
|
-
findActivePlanFile,
|
|
10
|
-
readPlan,
|
|
11
|
-
readRunQueueState,
|
|
12
|
-
resolveActivePlanFromHandoff,
|
|
13
|
-
resolveActivePlanPath
|
|
14
|
-
} from "./chunk-7ABY6DYH.js";
|
|
6
|
+
} from "./chunk-MPCNPZJZ.js";
|
|
15
7
|
import {
|
|
16
8
|
DRIVER_PROTOCOL_VERSION,
|
|
17
9
|
DriverAgentSink,
|
|
@@ -20,11 +12,34 @@ import {
|
|
|
20
12
|
createDriverEmitter,
|
|
21
13
|
driverReplies,
|
|
22
14
|
driverStop
|
|
23
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6WUKLS4D.js";
|
|
16
|
+
import {
|
|
17
|
+
QUEUE_LEASE_INTERRUPT_WAIT_MS,
|
|
18
|
+
QUEUE_LEASE_SESSION_ENV,
|
|
19
|
+
acquirePlanWriterLease,
|
|
20
|
+
forwardTermination,
|
|
21
|
+
gateCheckIn,
|
|
22
|
+
holdQueueStatus,
|
|
23
|
+
procStart
|
|
24
|
+
} from "./chunk-DTSL2RH7.js";
|
|
25
|
+
import {
|
|
26
|
+
CLAUDE_SUBAGENT_MODEL_ENV,
|
|
27
|
+
describeResolvedRoles,
|
|
28
|
+
readPlanRoleOverrides,
|
|
29
|
+
resolveSubworkerModel
|
|
30
|
+
} from "./chunk-UATQQDVR.js";
|
|
31
|
+
import {
|
|
32
|
+
countPendingTodos,
|
|
33
|
+
findActivePlanFile,
|
|
34
|
+
readPlan,
|
|
35
|
+
readRunQueueState,
|
|
36
|
+
resolveActivePlanFromHandoff,
|
|
37
|
+
resolveActivePlanPath
|
|
38
|
+
} from "./chunk-7ABY6DYH.js";
|
|
24
39
|
import {
|
|
25
40
|
classifyGateExit,
|
|
26
41
|
landGateExit
|
|
27
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-BGL5DRK2.js";
|
|
28
43
|
import {
|
|
29
44
|
parsePlanFrontmatter
|
|
30
45
|
} from "./chunk-L5V3W3DY.js";
|
|
@@ -34,13 +49,13 @@ import {
|
|
|
34
49
|
parseStreamLine,
|
|
35
50
|
redactSecrets,
|
|
36
51
|
renderStreamEvent
|
|
37
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-W3ZJVBNY.js";
|
|
38
53
|
import {
|
|
39
54
|
LineSplitter,
|
|
40
55
|
formatHitlSummary,
|
|
41
56
|
operatorQuitStop,
|
|
42
57
|
sumUsage
|
|
43
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-P7732A25.js";
|
|
44
59
|
import {
|
|
45
60
|
TtySpinner,
|
|
46
61
|
shouldUseVisualMotion,
|
|
@@ -837,9 +852,12 @@ async function runTickWithSpinner(label, backend, opts, plain) {
|
|
|
837
852
|
},
|
|
838
853
|
(seams) => backend.run({
|
|
839
854
|
...opts,
|
|
840
|
-
hitl: seams.hitl,
|
|
855
|
+
hitl: { ...seams.hitl, checkIn: opts.hitl?.checkIn },
|
|
841
856
|
render: seams.render,
|
|
842
|
-
onSpawn:
|
|
857
|
+
onSpawn: (info) => {
|
|
858
|
+
opts.onSpawn?.(info);
|
|
859
|
+
seams.onSpawn(info);
|
|
860
|
+
},
|
|
843
861
|
log: seams.log
|
|
844
862
|
})
|
|
845
863
|
);
|
|
@@ -962,7 +980,25 @@ async function runPlanLoop(opts) {
|
|
|
962
980
|
await unlink(stopFile);
|
|
963
981
|
} catch {
|
|
964
982
|
}
|
|
983
|
+
let lease = null;
|
|
984
|
+
let nestedSession = null;
|
|
985
|
+
const checkIn = gateCheckIn(opts.root, () => lease?.session ?? nestedSession, opts.lease);
|
|
986
|
+
let restoreQueue = null;
|
|
987
|
+
let previousLeaseSession;
|
|
988
|
+
let leaseSessionSet = false;
|
|
989
|
+
const releaseLease = (interrupted) => {
|
|
990
|
+
restoreQueue?.();
|
|
991
|
+
restoreQueue = null;
|
|
992
|
+
if (interrupted) lease?.releaseAfterAgent(QUEUE_LEASE_INTERRUPT_WAIT_MS);
|
|
993
|
+
else lease?.release();
|
|
994
|
+
if (leaseSessionSet) {
|
|
995
|
+
if (previousLeaseSession === void 0) delete process.env[QUEUE_LEASE_SESSION_ENV];
|
|
996
|
+
else process.env[QUEUE_LEASE_SESSION_ENV] = previousLeaseSession;
|
|
997
|
+
leaseSessionSet = false;
|
|
998
|
+
}
|
|
999
|
+
};
|
|
965
1000
|
const onSigInt = () => {
|
|
1001
|
+
releaseLease(true);
|
|
966
1002
|
if (driver) {
|
|
967
1003
|
emit({
|
|
968
1004
|
type: "run_end",
|
|
@@ -980,6 +1016,24 @@ async function runPlanLoop(opts) {
|
|
|
980
1016
|
process.exit(130);
|
|
981
1017
|
};
|
|
982
1018
|
process.on("SIGINT", onSigInt);
|
|
1019
|
+
let tickAgent = null;
|
|
1020
|
+
const offTermination = driver ? forwardTermination(
|
|
1021
|
+
() => tickAgent,
|
|
1022
|
+
(signal) => {
|
|
1023
|
+
releaseLease(true);
|
|
1024
|
+
emit({
|
|
1025
|
+
type: "run_end",
|
|
1026
|
+
exitCode: 130,
|
|
1027
|
+
ticks: ticksRun,
|
|
1028
|
+
pending: null,
|
|
1029
|
+
reason: `interrupted (${signal})`,
|
|
1030
|
+
planExhausted: false,
|
|
1031
|
+
usage: runUsage
|
|
1032
|
+
});
|
|
1033
|
+
process.exit(130);
|
|
1034
|
+
}
|
|
1035
|
+
) : () => {
|
|
1036
|
+
};
|
|
983
1037
|
try {
|
|
984
1038
|
const persona = driver ? null : await loadCliRunPlanPersona(opts.root);
|
|
985
1039
|
const banners = createPersonaBannerPrinter(persona);
|
|
@@ -1010,12 +1064,51 @@ async function runPlanLoop(opts) {
|
|
|
1010
1064
|
say(`${opts.backend.id} not found on PATH`, "error");
|
|
1011
1065
|
return finishRun(1, `${opts.backend.id} not found on PATH`, pendingAtStart);
|
|
1012
1066
|
}
|
|
1067
|
+
const writer = acquirePlanWriterLease(opts.root, "agent-kit run-plan", {
|
|
1068
|
+
...opts.lease,
|
|
1069
|
+
onLost: (by) => say(
|
|
1070
|
+
`Queue lease lost: ${by ? `session ${by.session} (pid ${by.dispatcher.pid})` : "the lease file"} replaced this run's lease. Another session may be writing this workspace's plans.`,
|
|
1071
|
+
"warn"
|
|
1072
|
+
)
|
|
1073
|
+
});
|
|
1074
|
+
if (writer.kind === "refused") {
|
|
1075
|
+
say(writer.message, "error");
|
|
1076
|
+
return finishRun(1, writer.message, pendingAtStart);
|
|
1077
|
+
}
|
|
1078
|
+
if (writer.kind === "nested") {
|
|
1079
|
+
nestedSession = writer.lease.session;
|
|
1080
|
+
say(
|
|
1081
|
+
`Queue lease: running under session ${writer.lease.session} (dispatcher pid ${writer.lease.dispatcher.pid}).`
|
|
1082
|
+
);
|
|
1083
|
+
} else {
|
|
1084
|
+
lease = writer.handle;
|
|
1085
|
+
if (lease.takeover) {
|
|
1086
|
+
say(
|
|
1087
|
+
`Queue lease: took over a stale lease (${lease.takeover.reason}); the takeover is logged in HANDOFF.`,
|
|
1088
|
+
"warn"
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
previousLeaseSession = process.env[QUEUE_LEASE_SESSION_ENV];
|
|
1092
|
+
process.env[QUEUE_LEASE_SESSION_ENV] = lease.session;
|
|
1093
|
+
leaseSessionSet = true;
|
|
1094
|
+
restoreQueue = holdQueueStatus(opts.root, {
|
|
1095
|
+
plan: path4.basename(planPath),
|
|
1096
|
+
who: `agent-kit run-plan session ${lease.session}`,
|
|
1097
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1098
|
+
});
|
|
1099
|
+
if (restoreQueue) {
|
|
1100
|
+
say(
|
|
1101
|
+
"Queue status: held while this run-plan runs outside the queue; restored when it ends."
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1013
1105
|
let stopReason;
|
|
1014
1106
|
let planExhausted = false;
|
|
1015
1107
|
let exitCode = 0;
|
|
1016
1108
|
let endReason = "";
|
|
1017
1109
|
let backend = opts.backend;
|
|
1018
1110
|
let limitSwitched = false;
|
|
1111
|
+
const rolesWarned = /* @__PURE__ */ new Set();
|
|
1019
1112
|
const stopRequested = () => {
|
|
1020
1113
|
if (!driver?.reader.stopRequested()) return false;
|
|
1021
1114
|
const msg = `Stop requested by the driver (stop_after_tick) - stopping after tick ${ticksRun}. The plan is as the tick left it.`;
|
|
@@ -1092,12 +1185,41 @@ async function runPlanLoop(opts) {
|
|
|
1092
1185
|
});
|
|
1093
1186
|
};
|
|
1094
1187
|
try {
|
|
1188
|
+
const switched = backend !== opts.backend;
|
|
1189
|
+
const tickModel = switched && opts.roles && opts.roles.modelSource !== "flag" ? void 0 : opts.model;
|
|
1190
|
+
let tickEnv;
|
|
1191
|
+
if (opts.roles) {
|
|
1192
|
+
const planOverrides = readPlanRoleOverrides(await readPlan(planPath).catch(() => ""));
|
|
1193
|
+
const sub = resolveSubworkerModel({
|
|
1194
|
+
backend: backend.id,
|
|
1195
|
+
roles: opts.roles.roles,
|
|
1196
|
+
plan: planOverrides
|
|
1197
|
+
});
|
|
1198
|
+
if (sub.warning && !rolesWarned.has(sub.warning)) {
|
|
1199
|
+
rolesWarned.add(sub.warning);
|
|
1200
|
+
say(`roles: ${sub.warning}`, "warn");
|
|
1201
|
+
}
|
|
1202
|
+
if (sub.model && backend.id === "claude") {
|
|
1203
|
+
tickEnv = { [CLAUDE_SUBAGENT_MODEL_ENV]: sub.model };
|
|
1204
|
+
}
|
|
1205
|
+
say(
|
|
1206
|
+
describeResolvedRoles({
|
|
1207
|
+
backendId: backend.id,
|
|
1208
|
+
backendSource: switched ? "flag" : opts.roles.backendSource,
|
|
1209
|
+
...tickModel ? { model: tickModel } : {},
|
|
1210
|
+
...tickModel && opts.roles.modelSource ? { modelSource: opts.roles.modelSource } : {},
|
|
1211
|
+
subworker: sub
|
|
1212
|
+
})
|
|
1213
|
+
);
|
|
1214
|
+
}
|
|
1095
1215
|
const runOpts = {
|
|
1096
1216
|
workspace: opts.root,
|
|
1097
1217
|
prompt: TICK_PROMPT,
|
|
1098
|
-
model:
|
|
1218
|
+
model: tickModel,
|
|
1099
1219
|
logPath,
|
|
1100
|
-
hitl: { policy: opts.noHitl ? "off" : "prompt" }
|
|
1220
|
+
hitl: { policy: opts.noHitl ? "off" : "prompt", checkIn },
|
|
1221
|
+
...tickEnv ? { env: tickEnv } : {},
|
|
1222
|
+
onSpawn: (info) => lease?.setAgent(info.pid)
|
|
1101
1223
|
};
|
|
1102
1224
|
const result = driver ? await backend.run({
|
|
1103
1225
|
...runOpts,
|
|
@@ -1106,9 +1228,15 @@ async function runPlanLoop(opts) {
|
|
|
1106
1228
|
hitl: {
|
|
1107
1229
|
policy: opts.noHitl ? "off" : "driver",
|
|
1108
1230
|
readAnswer: driver.reader.read,
|
|
1109
|
-
write: driver.writeErr
|
|
1231
|
+
write: driver.writeErr,
|
|
1232
|
+
checkIn
|
|
1233
|
+
},
|
|
1234
|
+
onSpawn: (info) => {
|
|
1235
|
+
lease?.setAgent(info.pid);
|
|
1236
|
+
tickAgent = info.pid === void 0 ? null : { pid: info.pid, start: procStart(info.pid) };
|
|
1110
1237
|
}
|
|
1111
1238
|
}) : await runTickWithSpinner(`tick ${tick}`, backend, runOpts, opts.plain === true);
|
|
1239
|
+
tickAgent = null;
|
|
1112
1240
|
agentExit = result.exitCode;
|
|
1113
1241
|
tickUsage = result.usage?.total() ?? null;
|
|
1114
1242
|
for (const line of formatHitlSummary(result.hitl)) say(line);
|
|
@@ -1118,6 +1246,7 @@ async function runPlanLoop(opts) {
|
|
|
1118
1246
|
landSummary = lastResult?.resultText.trim() || lastResult?.assistantTexts.at(-1)?.trim() || void 0;
|
|
1119
1247
|
landGateText = lastResult ? [lastResult.resultText, ...lastResult.assistantTexts].join("\n") : void 0;
|
|
1120
1248
|
} catch (err) {
|
|
1249
|
+
tickAgent = null;
|
|
1121
1250
|
say(String(err), "error");
|
|
1122
1251
|
agentExit = 1;
|
|
1123
1252
|
endTick(null, null);
|
|
@@ -1270,6 +1399,8 @@ async function runPlanLoop(opts) {
|
|
|
1270
1399
|
return finishRun(exitCode, endReason || "stopped", pendingNow, planExhausted);
|
|
1271
1400
|
} finally {
|
|
1272
1401
|
process.off("SIGINT", onSigInt);
|
|
1402
|
+
offTermination();
|
|
1403
|
+
releaseLease(false);
|
|
1273
1404
|
}
|
|
1274
1405
|
}
|
|
1275
1406
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
claudeRedactions,
|
|
6
6
|
redactSecrets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-W3ZJVBNY.js";
|
|
8
8
|
import {
|
|
9
9
|
findHitlGateInText
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P7732A25.js";
|
|
11
11
|
import {
|
|
12
12
|
findOnPath
|
|
13
13
|
} from "./chunk-WGLPZXNU.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
whichBinary
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W3ZJVBNY.js";
|
|
4
4
|
|
|
5
5
|
// src/plan-loop/detect.ts
|
|
6
6
|
var DETECT_ORDER = ["cursor-agent", "claude"];
|
|
@@ -64,6 +64,8 @@ async function detectAgentBackend(requested, whichFn = whichBinary) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export {
|
|
67
|
+
isBackendId,
|
|
68
|
+
isRequestedBackend,
|
|
67
69
|
listDetectBackendIds,
|
|
68
70
|
detectAgentBackend
|
|
69
71
|
};
|