@dadado/agent-kit-cli 6.25.0 → 6.26.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/dashboard/dashboard.html +3 -3
- package/dashboard/lib/guards.mjs +1 -0
- package/dist/{add-OYLOMCM6.js → add-G7KEZLWP.js} +7 -6
- package/dist/{chunk-7HDQEK6T.js → chunk-2G4K4ZI5.js} +7 -3
- package/dist/{chunk-QLTGHJB3.js → chunk-2GXN7HVG.js} +5 -5
- package/dist/{chunk-HSIHZWFF.js → chunk-5A72LTR3.js} +7 -7
- package/dist/{chunk-6WUKLS4D.js → chunk-BIFTTL2O.js} +1 -1
- package/dist/{chunk-NJ2SUSWX.js → chunk-BVZDPVUL.js} +1 -1
- package/dist/{chunk-QACMV46U.js → chunk-ENRXS5O6.js} +19 -12
- package/dist/{chunk-2F6NMQOA.js → chunk-FB6G6OD6.js} +3 -3
- package/dist/{chunk-MFKHIWEL.js → chunk-FOVHFMSH.js} +1 -1
- package/dist/{chunk-EO5NGAYV.js → chunk-FUSNEYGU.js} +29 -3
- package/dist/{chunk-GMG7ZH4E.js → chunk-H7KAXI5R.js} +13 -13
- package/dist/{chunk-SAQ3EE5R.js → chunk-HGB4DHXV.js} +3 -3
- package/dist/{chunk-IFBIO7VT.js → chunk-HXV6VQD4.js} +1402 -42
- package/dist/{chunk-XGZOU4DS.js → chunk-I3FGWNU5.js} +4 -4
- package/dist/{chunk-6M6UKECW.js → chunk-IHVJTGYR.js} +0 -32
- package/dist/{chunk-H7RAFRRZ.js → chunk-IUY24WPE.js} +68 -34
- package/dist/chunk-JG5MKMOM.js +248 -0
- package/dist/{chunk-KWYF7QNH.js → chunk-JWIJHO67.js} +17 -2
- package/dist/chunk-KMK4T4ZM.js +34 -0
- package/dist/{chunk-ZMYV6PRE.js → chunk-LEVNLHH3.js} +2 -1
- package/dist/{chunk-2XLI7XEY.js → chunk-MGVV6YC4.js} +1 -1
- package/dist/{chunk-C7SV7UP5.js → chunk-MWRYQLEG.js} +3 -3
- package/dist/{chunk-WKFE3RUC.js → chunk-NHJ4IAVN.js} +5 -3
- package/dist/{chunk-C4Q77GGJ.js → chunk-O7VMHCNN.js} +6 -0
- package/dist/{chunk-GQSSXDDK.js → chunk-OVRGTHZD.js} +1 -1
- package/dist/{chunk-CIV42JGT.js → chunk-PCIYXGB3.js} +2 -2
- package/dist/{chunk-7Y74KO7U.js → chunk-PLLXFSN2.js} +12 -12
- package/dist/{chunk-QX55T4UX.js → chunk-RJP47EGS.js} +6 -1
- package/dist/{chunk-JGG574RK.js → chunk-RRJVC35Y.js} +3 -3
- package/dist/{chunk-PIMGV3E5.js → chunk-SWJJW624.js} +1 -1
- package/dist/{chunk-G5MQRP6M.js → chunk-SYRJ5TTK.js} +13 -9
- package/dist/{chunk-L5V3W3DY.js → chunk-TTUFIE26.js} +60 -14
- package/dist/{chunk-JFS4GKP7.js → chunk-XXPI4H4D.js} +2 -2
- package/dist/{chunk-M4UL422I.js → chunk-Y5526WCN.js} +6 -6
- package/dist/{chunk-CXE6ASSX.js → chunk-Y575INEC.js} +1 -1
- package/dist/{chunk-JG3CNGQM.js → chunk-ZNZHDPS3.js} +6 -4
- package/dist/{commands-UW2C2ZN4.js → commands-K4HSDML5.js} +8 -6
- package/dist/{conflicts-RING6AHV.js → conflicts-4SUWIPWP.js} +9 -10
- package/dist/{contribute-LSY75JZH.js → contribute-HE4WCBRY.js} +7 -6
- package/dist/{countdown-SZ2P4XHB.js → countdown-TYQHVAIX.js} +74 -45
- package/dist/{dashboard-P65XHYCU.js → dashboard-6V6PCNYF.js} +1 -1
- package/dist/{dashboard-broadcast-GYK34QYL.js → dashboard-broadcast-PMVQ7PXU.js} +1 -1
- package/dist/{diff-NZVBVQSK.js → diff-3XUZM7ZT.js} +8 -7
- package/dist/{doctor-TJSXBVGV.js → doctor-KGUWU5SN.js} +16 -15
- package/dist/{engine-info-BBI5QO5Y.js → engine-info-VM4VPGQM.js} +2 -2
- package/dist/{ground-control-ZJXPUIQN.js → ground-control-ZIDHEOPW.js} +7 -4
- package/dist/{handoff-2OZSWGTE.js → handoff-LLT4CI6H.js} +2 -3
- package/dist/{hook-3VPKNSOO.js → hook-UPZ3CPYS.js} +22 -22
- package/dist/index.js +49 -32
- package/dist/{init-UW2BJBO2.js → init-ZHLVXEVT.js} +19 -18
- package/dist/{install-RQSI4CHG.js → install-XWOG64W3.js} +19 -18
- package/dist/{installs-7TR4H4QH.js → installs-2ROXPO6M.js} +5 -4
- package/dist/{mission-control-VSU6NT43.js → mission-control-IGOI3WHS.js} +2 -2
- package/dist/models-5BDXREWM.js +45 -0
- package/dist/paths-JTPV6SXH.js +107 -0
- package/dist/pi-DCMDOY65.js +248 -0
- package/dist/{plan-index-BNLUU6T5.js → plan-index-5QZJK4AG.js} +2 -3
- package/dist/{queue-JHYILLMX.js → queue-Z5VNNHM6.js} +11 -13
- package/dist/{run-CQF5RM5X.js → run-QURAXAR2.js} +24 -30
- package/dist/{run-plan-BEOCOJCF.js → run-plan-4MMHVCTS.js} +35 -23
- package/dist/{session-start-QV7CEFRX.js → session-start-NC2HE5X5.js} +16 -16
- package/dist/{sessions-AWAAO3DU.js → sessions-WWWLYPW6.js} +4 -4
- package/dist/{setup-global-ST4TT427.js → setup-global-WDMARD4Z.js} +11 -10
- package/dist/{status-HUBPBGUU.js → status-2WNJL7PP.js} +12 -11
- package/dist/update-YSVOYYK5.js +32 -0
- package/dist/{update-all-YYUTXHGR.js → update-all-5XLTCHPX.js} +20 -18
- package/package.json +14 -4
- package/pi/agent-kit.ts +224 -0
- package/dist/chunk-7ABY6DYH.js +0 -89
- package/dist/chunk-AQLBEEPD.js +0 -625
- package/dist/chunk-MUTTNRX4.js +0 -53
- package/dist/chunk-TOSAAQ5A.js +0 -71
- package/dist/update-DD5UZPGG.js +0 -31
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensurePathIgnored
|
|
3
|
-
} from "./chunk-MUTTNRX4.js";
|
|
4
1
|
import {
|
|
5
2
|
claudeRedactions,
|
|
6
3
|
redactSecrets
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HXV6VQD4.js";
|
|
8
5
|
import {
|
|
9
6
|
findHitlGateInText
|
|
10
7
|
} from "./chunk-P7732A25.js";
|
|
8
|
+
import {
|
|
9
|
+
ensurePathIgnored
|
|
10
|
+
} from "./chunk-TTUFIE26.js";
|
|
11
11
|
import {
|
|
12
12
|
findOnPath
|
|
13
13
|
} from "./chunk-WGLPZXNU.js";
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HANDOFF_REL
|
|
3
|
-
} from "./chunk-C4Q77GGJ.js";
|
|
4
|
-
|
|
5
|
-
// src/manifest/types.ts
|
|
6
|
-
var MANIFEST_FILENAME = "agent-kit.json";
|
|
7
|
-
var MANIFEST_RELATIVE_PATH = `.cursor/${MANIFEST_FILENAME}`;
|
|
8
|
-
var MANIFEST_SCHEMA_VERSION = 1;
|
|
9
|
-
var DEFAULT_PROTECTED_PATHS = [
|
|
10
|
-
HANDOFF_REL,
|
|
11
|
-
".cursor/plans/**",
|
|
12
|
-
".cursor/memory/**",
|
|
13
|
-
".cursor/context/config.json",
|
|
14
|
-
".cursor/context/current/**",
|
|
15
|
-
".cursor/context/backups/**"
|
|
16
|
-
];
|
|
17
|
-
var LEGACY_CONTEXT_PROTECTED_GLOB = ".cursor/context/**";
|
|
18
|
-
var DOMAIN_PACK_IDS = [
|
|
19
|
-
"cybersec",
|
|
20
|
-
"devops",
|
|
21
|
-
"engineering-architecture",
|
|
22
|
-
"clean-code",
|
|
23
|
-
"project-management",
|
|
24
|
-
"context-management",
|
|
25
|
-
"quality"
|
|
26
|
-
];
|
|
27
|
-
|
|
28
1
|
// src/utils/dir-lock.ts
|
|
29
2
|
import { randomUUID } from "crypto";
|
|
30
3
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "fs/promises";
|
|
@@ -167,10 +140,5 @@ async function acquireDirLock(target, options = {}) {
|
|
|
167
140
|
}
|
|
168
141
|
|
|
169
142
|
export {
|
|
170
|
-
MANIFEST_RELATIVE_PATH,
|
|
171
|
-
MANIFEST_SCHEMA_VERSION,
|
|
172
|
-
DEFAULT_PROTECTED_PATHS,
|
|
173
|
-
LEGACY_CONTEXT_PROTECTED_GLOB,
|
|
174
|
-
DOMAIN_PACK_IDS,
|
|
175
143
|
acquireDirLock
|
|
176
144
|
};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
NO_PROGRESS_REASON,
|
|
3
3
|
armExternalPlanReview,
|
|
4
|
-
describeIdenticalReviewModel,
|
|
5
|
-
describeResolvedRoles,
|
|
6
|
-
describeSameFamilyReviewModel,
|
|
7
4
|
formatAgentStopLine,
|
|
5
|
+
formatNoProgressLine,
|
|
8
6
|
formatSentinelLine,
|
|
9
7
|
isPlanExhaustedReason,
|
|
10
|
-
readPlanRoleOverrides,
|
|
11
|
-
resolveSubworkerModel,
|
|
12
8
|
resolveTickResultStatus,
|
|
13
9
|
resolveTickSentinel,
|
|
14
|
-
reviewModelRelation,
|
|
15
10
|
shouldArmExternalPlanReview
|
|
16
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JG5MKMOM.js";
|
|
17
12
|
import {
|
|
18
13
|
REVIEW_BACKENDS,
|
|
19
14
|
runReviewJob
|
|
20
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-5A72LTR3.js";
|
|
21
16
|
import {
|
|
22
17
|
InputLine,
|
|
23
18
|
ScrollRegion,
|
|
24
19
|
renderMcLive,
|
|
25
20
|
runMcTuiLoop
|
|
26
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-Y575INEC.js";
|
|
27
22
|
import {
|
|
28
23
|
DRIVER_PROTOCOL_VERSION,
|
|
29
24
|
DriverAgentSink,
|
|
@@ -32,25 +27,11 @@ import {
|
|
|
32
27
|
createDriverEmitter,
|
|
33
28
|
driverReplies,
|
|
34
29
|
driverStop
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import {
|
|
37
|
-
countPendingTodos,
|
|
38
|
-
findActivePlanFile,
|
|
39
|
-
readPlan,
|
|
40
|
-
readRunQueueState,
|
|
41
|
-
resolveActivePlanFromHandoff,
|
|
42
|
-
resolveActivePlanPath
|
|
43
|
-
} from "./chunk-7ABY6DYH.js";
|
|
44
|
-
import {
|
|
45
|
-
detectAgentBackend
|
|
46
|
-
} from "./chunk-TOSAAQ5A.js";
|
|
30
|
+
} from "./chunk-BIFTTL2O.js";
|
|
47
31
|
import {
|
|
48
32
|
classifyGateExit,
|
|
49
33
|
landGateExit
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import {
|
|
52
|
-
parsePlanFrontmatter
|
|
53
|
-
} from "./chunk-L5V3W3DY.js";
|
|
34
|
+
} from "./chunk-I3FGWNU5.js";
|
|
54
35
|
import {
|
|
55
36
|
QUEUE_LEASE_INTERRUPT_WAIT_MS,
|
|
56
37
|
QUEUE_LEASE_SESSION_ENV,
|
|
@@ -59,17 +40,35 @@ import {
|
|
|
59
40
|
gateCheckIn,
|
|
60
41
|
holdQueueStatus,
|
|
61
42
|
procStart
|
|
62
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-FOVHFMSH.js";
|
|
63
44
|
import {
|
|
45
|
+
CLAUDE_SUBAGENT_MODEL_ENV,
|
|
46
|
+
INSTALL_HINTS,
|
|
47
|
+
countPendingTodos,
|
|
48
|
+
describeIdenticalReviewModel,
|
|
49
|
+
describeResolvedRoles,
|
|
50
|
+
describeSameFamilyReviewModel,
|
|
51
|
+
detectAgentBackend,
|
|
52
|
+
findActivePlanFile,
|
|
64
53
|
parseStreamLine,
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
readPlan,
|
|
55
|
+
readPlanRoleOverrides,
|
|
56
|
+
readRunQueueState,
|
|
57
|
+
renderStreamEvent,
|
|
58
|
+
resolveActivePlanFromHandoff,
|
|
59
|
+
resolveActivePlanPath,
|
|
60
|
+
resolveSubworkerModel,
|
|
61
|
+
reviewModelRelation
|
|
62
|
+
} from "./chunk-HXV6VQD4.js";
|
|
67
63
|
import {
|
|
68
64
|
LineSplitter,
|
|
69
65
|
formatHitlSummary,
|
|
70
66
|
operatorQuitStop,
|
|
71
67
|
sumUsage
|
|
72
68
|
} from "./chunk-P7732A25.js";
|
|
69
|
+
import {
|
|
70
|
+
parsePlanFrontmatter
|
|
71
|
+
} from "./chunk-TTUFIE26.js";
|
|
73
72
|
import {
|
|
74
73
|
TtySpinner,
|
|
75
74
|
shouldUseVisualMotion,
|
|
@@ -84,7 +83,7 @@ import {
|
|
|
84
83
|
STATE_ROOT_ENV,
|
|
85
84
|
ensureLoopLogsDir,
|
|
86
85
|
runnerStatePaths
|
|
87
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-O7VMHCNN.js";
|
|
88
87
|
import {
|
|
89
88
|
fileExists,
|
|
90
89
|
readJson
|
|
@@ -469,6 +468,7 @@ async function withLiveTui(opts, run) {
|
|
|
469
468
|
}
|
|
470
469
|
|
|
471
470
|
// src/plan-loop/run-loop.ts
|
|
471
|
+
import { createHash } from "crypto";
|
|
472
472
|
import { readFile as readFile2, rm, unlink } from "fs/promises";
|
|
473
473
|
import path3 from "path";
|
|
474
474
|
|
|
@@ -694,6 +694,13 @@ function stamp() {
|
|
|
694
694
|
function sleep(ms) {
|
|
695
695
|
return new Promise((r) => setTimeout(r, ms));
|
|
696
696
|
}
|
|
697
|
+
async function contentHash(file) {
|
|
698
|
+
try {
|
|
699
|
+
return createHash("sha256").update(await readFile2(file)).digest("hex");
|
|
700
|
+
} catch {
|
|
701
|
+
return "absent";
|
|
702
|
+
}
|
|
703
|
+
}
|
|
697
704
|
async function runPlanLoop(opts) {
|
|
698
705
|
const statePaths = runnerStatePaths(opts.root);
|
|
699
706
|
const stopFile = statePaths.stopFile;
|
|
@@ -776,6 +783,8 @@ async function runPlanLoop(opts) {
|
|
|
776
783
|
return finishRun(1, "no active plan", null);
|
|
777
784
|
}
|
|
778
785
|
const pending = async () => countPendingTodos(await readPlan(planPath));
|
|
786
|
+
const handoffPath = path3.join(opts.root, HANDOFF_REL);
|
|
787
|
+
const fingerprint = async () => `${await contentHash(planPath)}:${await contentHash(handoffPath)}`;
|
|
779
788
|
landPlan = path3.basename(planPath);
|
|
780
789
|
if (statePaths.invalid !== void 0) {
|
|
781
790
|
say(
|
|
@@ -869,8 +878,9 @@ async function runPlanLoop(opts) {
|
|
|
869
878
|
}
|
|
870
879
|
const binary = await opts.backend.resolve();
|
|
871
880
|
if (!binary) {
|
|
872
|
-
|
|
873
|
-
|
|
881
|
+
const missing = opts.backend.id === "local" ? `local backend: pi not found on PATH. ${INSTALL_HINTS.local}` : `${opts.backend.id} not found on PATH`;
|
|
882
|
+
say(missing, "error");
|
|
883
|
+
return finishRun(1, missing, pendingAtStart);
|
|
874
884
|
}
|
|
875
885
|
const writer = acquirePlanWriterLease(opts.root, "agent-kit run-plan", {
|
|
876
886
|
...opts.lease,
|
|
@@ -927,6 +937,12 @@ async function runPlanLoop(opts) {
|
|
|
927
937
|
rolesWarned.add(line);
|
|
928
938
|
say(`roles: ${line}`, "warn");
|
|
929
939
|
};
|
|
940
|
+
if (tickBackend === "local" && (!reviewer.backend || reviewer.backend === "auto")) {
|
|
941
|
+
warnOnce(
|
|
942
|
+
"post-tick review skipped: the tick ran on the local backend and roles.reviewer.backend is not set (set it to claude or cursor-agent to review local ticks on that engine)"
|
|
943
|
+
);
|
|
944
|
+
return proceed;
|
|
945
|
+
}
|
|
930
946
|
const relation = reviewModelRelation(tickModel, reviewer.model);
|
|
931
947
|
if (relation === "identical") {
|
|
932
948
|
warnOnce(
|
|
@@ -1014,6 +1030,7 @@ async function runPlanLoop(opts) {
|
|
|
1014
1030
|
endReason = "plan exhausted";
|
|
1015
1031
|
break;
|
|
1016
1032
|
}
|
|
1033
|
+
const beforeFingerprint = await fingerprint();
|
|
1017
1034
|
const logPath = path3.join(logDir, `tick-${stamp()}.log`);
|
|
1018
1035
|
landLogPath = logPath;
|
|
1019
1036
|
landBackend = backend.id;
|
|
@@ -1105,7 +1122,16 @@ async function runPlanLoop(opts) {
|
|
|
1105
1122
|
onSpawn: (info) => {
|
|
1106
1123
|
lease?.setAgent(info.pid);
|
|
1107
1124
|
tickAgent = info.pid === void 0 ? null : { pid: info.pid, start: procStart(info.pid) };
|
|
1108
|
-
}
|
|
1125
|
+
},
|
|
1126
|
+
onProgress: (p) => emit({
|
|
1127
|
+
type: "model_loading",
|
|
1128
|
+
tick,
|
|
1129
|
+
backend: backend.id,
|
|
1130
|
+
model: p.model,
|
|
1131
|
+
phase: p.phase,
|
|
1132
|
+
elapsedMs: p.elapsedMs,
|
|
1133
|
+
...p.detail ? { detail: p.detail } : {}
|
|
1134
|
+
})
|
|
1109
1135
|
}) : await runTickWithSpinner(`tick ${tick}`, backend, runOpts, opts.plain === true);
|
|
1110
1136
|
tickAgent = null;
|
|
1111
1137
|
agentExit = result.exitCode;
|
|
@@ -1146,7 +1172,7 @@ async function runPlanLoop(opts) {
|
|
|
1146
1172
|
logText = await readFile2(logPath, "utf8");
|
|
1147
1173
|
} catch {
|
|
1148
1174
|
}
|
|
1149
|
-
limit = detectUsageLimit(logText);
|
|
1175
|
+
limit = backend.id === "local" ? null : detectUsageLimit(logText);
|
|
1150
1176
|
if (limit) {
|
|
1151
1177
|
const hit = limit;
|
|
1152
1178
|
const fallback = opts.onLimit && !limitSwitched && opts.onLimit.id !== backend.id ? opts.onLimit : null;
|
|
@@ -1214,6 +1240,14 @@ async function runPlanLoop(opts) {
|
|
|
1214
1240
|
banners.tickEnd(`pending: ${after}`);
|
|
1215
1241
|
}
|
|
1216
1242
|
endTick(after, sentinel);
|
|
1243
|
+
if (sentinel.kind === "continue" && after >= before && await fingerprint() === beforeFingerprint) {
|
|
1244
|
+
if (banners) banners.stop(NO_PROGRESS_REASON);
|
|
1245
|
+
say(formatNoProgressLine({ before, after, log: relLog }));
|
|
1246
|
+
exitCode = 1;
|
|
1247
|
+
endReason = NO_PROGRESS_REASON;
|
|
1248
|
+
landFailed = true;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1217
1251
|
const review = await reviewAfterTick(backend.id, implementerModel);
|
|
1218
1252
|
if (review.stop) {
|
|
1219
1253
|
const msg = `Post-tick review landed a gate exit after tick ${tick} - stopping. Read the ticket before the next tick.`;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RedactingStreamBuffer,
|
|
3
|
+
claudeRedactions,
|
|
4
|
+
redactSecrets
|
|
5
|
+
} from "./chunk-HXV6VQD4.js";
|
|
6
|
+
import {
|
|
7
|
+
fileExists
|
|
8
|
+
} from "./chunk-5B4DVO6C.js";
|
|
9
|
+
|
|
10
|
+
// src/plan-loop/external-review.ts
|
|
11
|
+
import { spawn } from "child_process";
|
|
12
|
+
import path from "path";
|
|
13
|
+
var CANONICAL_REL = path.join(".cursor", "scripts", "plan-external-review.sh");
|
|
14
|
+
var FALLBACK_REL = path.join("scripts", "plan-external-review.sh");
|
|
15
|
+
function isPlanExhaustedReason(reason) {
|
|
16
|
+
const r = reason.trim().toLowerCase();
|
|
17
|
+
if (!r) return false;
|
|
18
|
+
if (r.includes("plan exhausted")) return true;
|
|
19
|
+
if (r.includes("nothing to do")) return true;
|
|
20
|
+
if (r.includes("no implementable")) return true;
|
|
21
|
+
if (/\ball\s+(implementable\s+)?to-?dos?\b/.test(r) && (r.includes("completed") || r.includes("done") || r.includes("exhausted"))) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function shouldArmExternalPlanReview(input) {
|
|
27
|
+
if (input.pending === 0) return true;
|
|
28
|
+
if (input.stopReason && isPlanExhaustedReason(input.stopReason)) return true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
async function armExternalPlanReview(root, options = {}) {
|
|
32
|
+
const spawnFn = options.spawnFn ?? spawn;
|
|
33
|
+
const existsFn = options.existsFn ?? fileExists;
|
|
34
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
35
|
+
const force = options.force === true;
|
|
36
|
+
const canonicalPath = path.join(root, CANONICAL_REL);
|
|
37
|
+
const fallbackPath = path.join(root, FALLBACK_REL);
|
|
38
|
+
let scriptPath = null;
|
|
39
|
+
let scriptRel = CANONICAL_REL;
|
|
40
|
+
if (await existsFn(canonicalPath)) {
|
|
41
|
+
scriptPath = canonicalPath;
|
|
42
|
+
scriptRel = CANONICAL_REL;
|
|
43
|
+
} else if (await existsFn(fallbackPath)) {
|
|
44
|
+
scriptPath = fallbackPath;
|
|
45
|
+
scriptRel = FALLBACK_REL;
|
|
46
|
+
}
|
|
47
|
+
if (!scriptPath) {
|
|
48
|
+
log(
|
|
49
|
+
`tip: ${CANONICAL_REL} missing (optional wrapper: ${FALLBACK_REL}). Manual: /plan-external-review (enable externalPlanReview in .cursor/context/config.json).`
|
|
50
|
+
);
|
|
51
|
+
return { invoked: false, exitCode: null, output: "" };
|
|
52
|
+
}
|
|
53
|
+
log("Plan exhausted: arming optional external plan review (opt-in handled by script)...");
|
|
54
|
+
const args = force ? [scriptPath, "--force", "--print"] : [scriptPath, "--print"];
|
|
55
|
+
const implementerModel = options.implementerModel?.trim();
|
|
56
|
+
if (implementerModel) args.push("--implementer-model", implementerModel);
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
const child = spawnFn("bash", args, {
|
|
59
|
+
cwd: root,
|
|
60
|
+
env: { ...process.env, AGENT_KIT_HEADLESS: "1" }
|
|
61
|
+
});
|
|
62
|
+
const redact = claudeRedactions(process.env);
|
|
63
|
+
const outBuffer = new RedactingStreamBuffer(redact);
|
|
64
|
+
const errBuffer = new RedactingStreamBuffer(redact);
|
|
65
|
+
let output = "";
|
|
66
|
+
const emitOut = (s) => {
|
|
67
|
+
if (!s) return;
|
|
68
|
+
output += s;
|
|
69
|
+
if (options.writeOut) options.writeOut(s);
|
|
70
|
+
else process.stdout.write(s);
|
|
71
|
+
};
|
|
72
|
+
const emitErr = (s) => {
|
|
73
|
+
if (!s) return;
|
|
74
|
+
output += s;
|
|
75
|
+
process.stderr.write(s);
|
|
76
|
+
};
|
|
77
|
+
let flushed = false;
|
|
78
|
+
const flush = () => {
|
|
79
|
+
if (flushed) return;
|
|
80
|
+
flushed = true;
|
|
81
|
+
emitOut(outBuffer.flush());
|
|
82
|
+
emitErr(errBuffer.flush());
|
|
83
|
+
};
|
|
84
|
+
child.stdout?.on("data", (chunk) => emitOut(outBuffer.push(chunk)));
|
|
85
|
+
child.stderr?.on("data", (chunk) => emitErr(errBuffer.push(chunk)));
|
|
86
|
+
child.on("error", (err) => {
|
|
87
|
+
flush();
|
|
88
|
+
log(
|
|
89
|
+
`tip: external plan review launcher failed (${redactSecrets(err.message, redact)}). Manual: ${scriptRel} or /plan-external-review`
|
|
90
|
+
);
|
|
91
|
+
resolve({ invoked: true, exitCode: null, output });
|
|
92
|
+
});
|
|
93
|
+
child.on("close", (code) => {
|
|
94
|
+
flush();
|
|
95
|
+
if (code !== 0 && code !== null) {
|
|
96
|
+
log(
|
|
97
|
+
`tip: external plan review exited ${code} (ignored; does not fail the loop). Manual: ${scriptRel} or /plan-external-review`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
resolve({ invoked: true, exitCode: code, output });
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/plan-loop/sentinel.ts
|
|
106
|
+
import { readFile } from "fs/promises";
|
|
107
|
+
var SENTINEL_RE = /LOOP_TICK_RESULT:\s*(continue|stop(?:\s*[—-].*)?)/i;
|
|
108
|
+
function takeFromText(text) {
|
|
109
|
+
if (!text) return null;
|
|
110
|
+
const m = SENTINEL_RE.exec(text);
|
|
111
|
+
if (!m?.[1]) return null;
|
|
112
|
+
const raw = m[1].trim();
|
|
113
|
+
if (raw.toLowerCase().startsWith("stop")) {
|
|
114
|
+
const reason = raw.slice(4).replace(/^[—\-\s]+/, "").trim() || "requested by agent";
|
|
115
|
+
return { kind: "stop", reason };
|
|
116
|
+
}
|
|
117
|
+
return { kind: "continue" };
|
|
118
|
+
}
|
|
119
|
+
function parseSentinelFromLog(content) {
|
|
120
|
+
let lastJson = null;
|
|
121
|
+
let lastText = null;
|
|
122
|
+
let sawJson = false;
|
|
123
|
+
for (const line of content.split(/\r?\n/)) {
|
|
124
|
+
const trimmed = line.trim();
|
|
125
|
+
if (!trimmed) continue;
|
|
126
|
+
if (!trimmed.startsWith("{")) {
|
|
127
|
+
const hit = takeFromText(trimmed);
|
|
128
|
+
if (hit) lastText = hit;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const ev = JSON.parse(trimmed);
|
|
133
|
+
sawJson = true;
|
|
134
|
+
if (ev.type === "result" && typeof ev.result === "string") {
|
|
135
|
+
const hit = takeFromText(ev.result);
|
|
136
|
+
if (hit) lastJson = hit;
|
|
137
|
+
}
|
|
138
|
+
const parts = ev.type === "assistant" ? ev.message?.content : void 0;
|
|
139
|
+
if (Array.isArray(parts)) {
|
|
140
|
+
for (const part of parts) {
|
|
141
|
+
if (part && typeof part === "object" && part.type === "text" && typeof part.text === "string") {
|
|
142
|
+
const hit = takeFromText(part.text);
|
|
143
|
+
if (hit) lastJson = hit;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
const hit = takeFromText(trimmed);
|
|
149
|
+
if (hit) lastText = hit;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return (sawJson ? lastJson : lastText) ?? { kind: "missing" };
|
|
153
|
+
}
|
|
154
|
+
function parseTickResultStatus(content) {
|
|
155
|
+
let last = null;
|
|
156
|
+
for (const line of content.split(/\r?\n/)) {
|
|
157
|
+
const trimmed = line.trim();
|
|
158
|
+
if (!trimmed.startsWith("{")) continue;
|
|
159
|
+
try {
|
|
160
|
+
const ev = JSON.parse(trimmed);
|
|
161
|
+
if (ev.type !== "result") continue;
|
|
162
|
+
const errors = Array.isArray(ev.errors) ? ev.errors.filter((e) => typeof e === "string") : [];
|
|
163
|
+
last = {
|
|
164
|
+
isError: ev.is_error === true,
|
|
165
|
+
...typeof ev.subtype === "string" ? { subtype: ev.subtype } : {},
|
|
166
|
+
errors
|
|
167
|
+
};
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return last;
|
|
172
|
+
}
|
|
173
|
+
async function parseTickResultStatusFromLogFile(logPath) {
|
|
174
|
+
try {
|
|
175
|
+
return parseTickResultStatus(await readFile(logPath, "utf8"));
|
|
176
|
+
} catch {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function parseSentinelFromLogFile(logPath) {
|
|
181
|
+
try {
|
|
182
|
+
const content = await readFile(logPath, "utf8");
|
|
183
|
+
return parseSentinelFromLog(content);
|
|
184
|
+
} catch {
|
|
185
|
+
return { kind: "missing" };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function formatSentinelLine(sentinel) {
|
|
189
|
+
if (sentinel.kind === "continue") return "LOOP_TICK_RESULT: continue";
|
|
190
|
+
if (sentinel.kind === "stop") return `LOOP_TICK_RESULT: stop - ${sentinel.reason}`;
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
var AGENT_STOP_LINE_PREFIX = "Agent requested stop: ";
|
|
194
|
+
function formatAgentStopLine(sentinel) {
|
|
195
|
+
return `${AGENT_STOP_LINE_PREFIX}${formatSentinelLine(sentinel)}`;
|
|
196
|
+
}
|
|
197
|
+
var AGENT_STOP_LINE_RE = /^Agent requested stop: LOOP_TICK_RESULT: stop - (.*)$/;
|
|
198
|
+
function parseAgentStopLine(line) {
|
|
199
|
+
const m = AGENT_STOP_LINE_RE.exec(line.replace(/\r$/, ""));
|
|
200
|
+
if (!m) return null;
|
|
201
|
+
return m[1]?.trim() || "requested by agent";
|
|
202
|
+
}
|
|
203
|
+
var NO_PROGRESS_REASON = "tick reported continue without progress";
|
|
204
|
+
function formatNoProgressLine(input) {
|
|
205
|
+
return `Tick reported continue without progress (pending ${input.before} -> ${input.after}; plan and HANDOFF unchanged) - stopping for safety. See log: ${input.log}`;
|
|
206
|
+
}
|
|
207
|
+
var NO_PROGRESS_LINE_RE = /^Tick reported continue without progress \(pending \d+ -> \d+; plan and HANDOFF unchanged\) - stopping for safety\./;
|
|
208
|
+
function isNoProgressLine(line) {
|
|
209
|
+
return NO_PROGRESS_LINE_RE.test(line.replace(/\r$/, ""));
|
|
210
|
+
}
|
|
211
|
+
function sentinelFromTurn(turn) {
|
|
212
|
+
const fromResult = takeFromText(turn.resultText);
|
|
213
|
+
if (fromResult) return fromResult;
|
|
214
|
+
for (let i = turn.assistantTexts.length - 1; i >= 0; i--) {
|
|
215
|
+
const hit = takeFromText(turn.assistantTexts[i] ?? "");
|
|
216
|
+
if (hit) return hit;
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
function tickResultStatusFromTurn(turn) {
|
|
221
|
+
return {
|
|
222
|
+
isError: turn.isError,
|
|
223
|
+
...turn.subtype !== null ? { subtype: turn.subtype } : {},
|
|
224
|
+
errors: turn.errors
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
async function resolveTickResultStatus(lastResult, logPath, fromFile = parseTickResultStatusFromLogFile) {
|
|
228
|
+
if (lastResult) return tickResultStatusFromTurn(lastResult);
|
|
229
|
+
return fromFile(logPath);
|
|
230
|
+
}
|
|
231
|
+
async function resolveTickSentinel(lastResult, logPath, fromFile = parseSentinelFromLogFile) {
|
|
232
|
+
const fromTurn = lastResult ? sentinelFromTurn(lastResult) : null;
|
|
233
|
+
return fromTurn ?? fromFile(logPath);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
isPlanExhaustedReason,
|
|
238
|
+
shouldArmExternalPlanReview,
|
|
239
|
+
armExternalPlanReview,
|
|
240
|
+
formatSentinelLine,
|
|
241
|
+
formatAgentStopLine,
|
|
242
|
+
parseAgentStopLine,
|
|
243
|
+
NO_PROGRESS_REASON,
|
|
244
|
+
formatNoProgressLine,
|
|
245
|
+
isNoProgressLine,
|
|
246
|
+
resolveTickResultStatus,
|
|
247
|
+
resolveTickSentinel
|
|
248
|
+
};
|
|
@@ -9,18 +9,19 @@ import {
|
|
|
9
9
|
cursorAcpBackend,
|
|
10
10
|
cursorAgentHeadlessArgs,
|
|
11
11
|
cursorAgentReviewArgs,
|
|
12
|
+
localBackend,
|
|
12
13
|
openrouterArgs,
|
|
13
14
|
redactSecrets,
|
|
14
15
|
resolveHitlRunOptions,
|
|
15
16
|
spawnLogged
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-HXV6VQD4.js";
|
|
17
18
|
import {
|
|
18
19
|
RESERVED_GATE_IDS
|
|
19
20
|
} from "./chunk-P7732A25.js";
|
|
20
21
|
import {
|
|
21
22
|
ensureLoopLogsDir,
|
|
22
23
|
runnerStatePaths
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O7VMHCNN.js";
|
|
24
25
|
import {
|
|
25
26
|
fileExists
|
|
26
27
|
} from "./chunk-5B4DVO6C.js";
|
|
@@ -158,6 +159,20 @@ async function runHeadlessDispatch(opts) {
|
|
|
158
159
|
onSpawn: opts.onSpawn
|
|
159
160
|
});
|
|
160
161
|
}
|
|
162
|
+
if (opts.backendId === "local") {
|
|
163
|
+
return localBackend.run({
|
|
164
|
+
workspace: opts.workspace,
|
|
165
|
+
prompt: opts.prompt,
|
|
166
|
+
model: opts.model,
|
|
167
|
+
logPath: opts.logPath,
|
|
168
|
+
spawnFn: opts.spawnFn,
|
|
169
|
+
log: opts.log,
|
|
170
|
+
hitl: opts.hitl,
|
|
171
|
+
render: opts.render,
|
|
172
|
+
onSpawn: opts.onSpawn,
|
|
173
|
+
...opts.onProgress ? { onProgress: opts.onProgress } : {}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
161
176
|
if (opts.backendId === "openrouter") {
|
|
162
177
|
const log = opts.log ?? ((line) => console.log(line));
|
|
163
178
|
const env = claudeChildEnv();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HANDOFF_REL
|
|
3
|
+
} from "./chunk-O7VMHCNN.js";
|
|
4
|
+
|
|
5
|
+
// src/manifest/types.ts
|
|
6
|
+
var MANIFEST_FILENAME = "agent-kit.json";
|
|
7
|
+
var MANIFEST_RELATIVE_PATH = `.cursor/${MANIFEST_FILENAME}`;
|
|
8
|
+
var MANIFEST_SCHEMA_VERSION = 1;
|
|
9
|
+
var DEFAULT_PROTECTED_PATHS = [
|
|
10
|
+
HANDOFF_REL,
|
|
11
|
+
".cursor/plans/**",
|
|
12
|
+
".cursor/memory/**",
|
|
13
|
+
".cursor/context/config.json",
|
|
14
|
+
".cursor/context/current/**",
|
|
15
|
+
".cursor/context/backups/**"
|
|
16
|
+
];
|
|
17
|
+
var LEGACY_CONTEXT_PROTECTED_GLOB = ".cursor/context/**";
|
|
18
|
+
var DOMAIN_PACK_IDS = [
|
|
19
|
+
"cybersec",
|
|
20
|
+
"devops",
|
|
21
|
+
"engineering-architecture",
|
|
22
|
+
"clean-code",
|
|
23
|
+
"project-management",
|
|
24
|
+
"context-management",
|
|
25
|
+
"quality"
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
MANIFEST_RELATIVE_PATH,
|
|
30
|
+
MANIFEST_SCHEMA_VERSION,
|
|
31
|
+
DEFAULT_PROTECTED_PATHS,
|
|
32
|
+
LEGACY_CONTEXT_PROTECTED_GLOB,
|
|
33
|
+
DOMAIN_PACK_IDS
|
|
34
|
+
};
|
|
@@ -27,7 +27,8 @@ var ROLE_CAPABILITIES = Object.freeze({
|
|
|
27
27
|
"cursor-agent": Object.freeze({ workerModel: true, subworkerModel: false, reviewer: true }),
|
|
28
28
|
codex: Object.freeze({ workerModel: true, subworkerModel: false, reviewer: false }),
|
|
29
29
|
openrouter: Object.freeze({ workerModel: true, subworkerModel: false, reviewer: false }),
|
|
30
|
-
"cursor-acp": Object.freeze({ workerModel: false, subworkerModel: false, reviewer: false })
|
|
30
|
+
"cursor-acp": Object.freeze({ workerModel: false, subworkerModel: false, reviewer: false }),
|
|
31
|
+
local: Object.freeze({ workerModel: true, subworkerModel: false, reviewer: false })
|
|
31
32
|
});
|
|
32
33
|
var CONFIG_ROLE_WORKER_BACKENDS = Object.freeze([
|
|
33
34
|
"auto",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
managedPairs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HGB4DHXV.js";
|
|
4
4
|
import {
|
|
5
5
|
isProtectedPath,
|
|
6
6
|
resolveProtectedGlobs
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZNZHDPS3.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveContained
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RJP47EGS.js";
|
|
11
11
|
|
|
12
12
|
// src/lifecycle/diff.ts
|
|
13
13
|
import { readFile } from "fs/promises";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
MANIFEST_RELATIVE_PATH,
|
|
3
2
|
acquireDirLock
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IHVJTGYR.js";
|
|
4
|
+
import {
|
|
5
|
+
MANIFEST_RELATIVE_PATH
|
|
6
|
+
} from "./chunk-KMK4T4ZM.js";
|
|
5
7
|
import {
|
|
6
8
|
KIT_VERSION
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2G4K4ZI5.js";
|
|
8
10
|
import {
|
|
9
11
|
fileExists
|
|
10
12
|
} from "./chunk-5B4DVO6C.js";
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { mkdir, writeFile } from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
4
|
var HANDOFF_REL = ".cursor/HANDOFF.md";
|
|
5
|
+
var SKILL_DIRS_REL = [
|
|
6
|
+
".cursor/skills/core",
|
|
7
|
+
".cursor/skills/domain",
|
|
8
|
+
".cursor/skills/community"
|
|
9
|
+
];
|
|
5
10
|
var STATE_ROOT_ENV = "AGENT_KIT_STATE_ROOT";
|
|
6
11
|
var STATE_ROOT_DIRS = [".cursor", ".agent-kit"];
|
|
7
12
|
function resolveStateDir(env = process.env) {
|
|
@@ -32,6 +37,7 @@ async function ensureLoopLogsDir(paths) {
|
|
|
32
37
|
|
|
33
38
|
export {
|
|
34
39
|
HANDOFF_REL,
|
|
40
|
+
SKILL_DIRS_REL,
|
|
35
41
|
STATE_ROOT_ENV,
|
|
36
42
|
runnerStatePaths,
|
|
37
43
|
ensureLoopLogsDir
|