@dadado/agent-kit-cli 6.17.0 → 6.19.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-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-DRV3T42D.js → add-MRI5BXHH.js} +3 -3
- package/dist/{chunk-3IEE6Q37.js → chunk-2TX6NJEG.js} +1 -1
- package/dist/{chunk-IOQ6YXA3.js → chunk-3HNTNYPR.js} +1 -1
- package/dist/{chunk-MEZU47IB.js → chunk-5EBT3V7G.js} +1 -1
- package/dist/{chunk-5IJQGIOY.js → chunk-677W4QO3.js} +63 -1
- package/dist/{chunk-SKC6QZW4.js → chunk-6WUKLS4D.js} +1 -1
- package/dist/{chunk-YO4BLHDT.js → chunk-6XJZLH53.js} +149 -18
- package/dist/{chunk-J3YLSHRK.js → chunk-7MUTZHWP.js} +23 -4
- package/dist/{chunk-CJ3JAH7L.js → chunk-BGL5DRK2.js} +2 -2
- package/dist/{chunk-IJQAFPY3.js → chunk-C4LCOOL4.js} +3 -1
- package/dist/chunk-DTSL2RH7.js +433 -0
- package/dist/{chunk-4DLMU44M.js → chunk-EBDQYFA4.js} +71 -4
- package/dist/{chunk-AQTCXUYS.js → chunk-EOQMAU2J.js} +1 -1
- package/dist/{chunk-RAMT55TC.js → chunk-G2Z37XFM.js} +3 -3
- package/dist/{chunk-HKZH2IEE.js → chunk-GTP224FI.js} +1 -1
- package/dist/{chunk-QYIV6ZP6.js → chunk-HJWSOZXS.js} +52 -12
- package/dist/{chunk-AZCPUJJO.js → chunk-IQQQDEQ4.js} +2 -2
- package/dist/{chunk-ZFJIJUZ4.js → chunk-MPCNPZJZ.js} +1 -1
- package/dist/{hook-2YEC7GT5.js → chunk-NL3I2BWA.js} +104 -113
- package/dist/{chunk-WGAOM37Y.js → chunk-OKQ37A7E.js} +9 -9
- package/dist/{chunk-WRCXRV2U.js → chunk-P7732A25.js} +10 -0
- package/dist/{chunk-6RRG3WOE.js → chunk-Q35TWISF.js} +22 -1
- package/dist/{chunk-WA7IBNIL.js → chunk-QBYJNGCD.js} +2 -2
- package/dist/chunk-QWTBYXHN.js +751 -0
- package/dist/{chunk-SC2DBY2R.js → chunk-R4DUO5DA.js} +1 -0
- package/dist/{chunk-2Y27P6KC.js → chunk-SGTTC2JP.js} +4 -3
- package/dist/{chunk-TICKIKCQ.js → chunk-U23SLQGX.js} +5 -5
- package/dist/chunk-UATQQDVR.js +297 -0
- package/dist/{chunk-3YTFXTXH.js → chunk-UXQH2CNC.js} +2 -1
- package/dist/{chunk-VBQHBSIB.js → chunk-VJWWJA36.js} +3 -3
- package/dist/{chunk-OQNJRQPZ.js → chunk-W3ZJVBNY.js} +7 -4
- package/dist/{chunk-XDCCYBCJ.js → chunk-ZMYV6PRE.js} +13 -0
- package/dist/{commands-3O2HFLTW.js → commands-NL6UOEP7.js} +51 -17
- package/dist/{conflicts-UY6VTYIO.js → conflicts-XMN4PBCZ.js} +8 -8
- package/dist/{contribute-RF47NPZ2.js → contribute-QDTEJ42W.js} +4 -4
- package/dist/{countdown-JX3DZ2QU.js → countdown-7ONIVAG6.js} +40 -12
- 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-SVFAUOVP.js → diff-RLB7R2NE.js} +5 -5
- package/dist/{doctor-ATKYRCT4.js → doctor-OXMDSOXL.js} +11 -11
- package/dist/{engine-info-R6GXZ2VO.js → engine-info-BBI5QO5Y.js} +3 -3
- package/dist/{ground-control-D2X6CI66.js → ground-control-IDCXN5FK.js} +5 -5
- package/dist/hook-B4VUQOQF.js +108 -0
- package/dist/index.js +28 -28
- package/dist/{init-LUJRWMHC.js → init-BYONEUCW.js} +14 -14
- package/dist/{install-VQSO2JR7.js → install-HOR6VR44.js} +14 -14
- package/dist/{mission-control-JIF6GFSV.js → mission-control-QJBSZVNI.js} +2 -2
- package/dist/{queue-IEOXOBNL.js → queue-OJHKFKK3.js} +55 -11
- package/dist/{run-L63NZHAJ.js → run-PFANZJ5Y.js} +175 -27
- package/dist/{run-plan-BWJX6R7Q.js → run-plan-7EB4ERSQ.js} +46 -16
- package/dist/{scan-BWA64R7I.js → scan-K3T5RQLC.js} +1 -1
- package/dist/session-start-OSFSF4OZ.js +74 -0
- package/dist/sessions-WQU5DONU.js +102 -0
- package/dist/{setup-global-2X5TMDCB.js → setup-global-O34KFL2C.js} +6 -6
- package/dist/{status-MOOZCB5D.js → status-QB2FFYUP.js} +8 -8
- package/dist/{update-NMSO56CQ.js → update-N2EKKSE7.js} +16 -11
- package/package.json +1 -1
- package/dist/sessions-O7MYEMCT.js +0 -343
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readRunQueueState
|
|
3
|
-
} from "./chunk-7ABY6DYH.js";
|
|
4
1
|
import {
|
|
5
2
|
DRIVER_PROTOCOL_VERSION,
|
|
6
3
|
DriverAgentSink,
|
|
@@ -8,24 +5,34 @@ import {
|
|
|
8
5
|
createDriverEmitter,
|
|
9
6
|
driverReplies,
|
|
10
7
|
driverStop
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6WUKLS4D.js";
|
|
9
|
+
import {
|
|
10
|
+
QUEUE_LEASE_INTERRUPT_WAIT_MS,
|
|
11
|
+
QUEUE_LEASE_SESSION_ENV,
|
|
12
|
+
acquireQueueLease,
|
|
13
|
+
forwardTermination,
|
|
14
|
+
gateCheckIn
|
|
15
|
+
} from "./chunk-DTSL2RH7.js";
|
|
16
|
+
import {
|
|
17
|
+
readRunQueueState
|
|
18
|
+
} from "./chunk-7ABY6DYH.js";
|
|
12
19
|
import {
|
|
13
20
|
detectAgentBackend
|
|
14
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-C4LCOOL4.js";
|
|
15
22
|
import {
|
|
16
23
|
classifyGateExit,
|
|
17
24
|
landGateExit
|
|
18
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BGL5DRK2.js";
|
|
19
26
|
import {
|
|
20
27
|
buildDispatchPrompt,
|
|
21
28
|
ensureDispatchLogPath,
|
|
22
29
|
readCommandFile,
|
|
23
30
|
runHeadlessDispatch
|
|
24
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-SGTTC2JP.js";
|
|
25
32
|
import {
|
|
26
33
|
formatHitlSummary,
|
|
27
34
|
hitlExitCode
|
|
28
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-P7732A25.js";
|
|
29
36
|
import {
|
|
30
37
|
HANDOFF_REL
|
|
31
38
|
} from "./chunk-C4Q77GGJ.js";
|
|
@@ -210,20 +217,46 @@ async function runDispatchDriver(opts) {
|
|
|
210
217
|
}
|
|
211
218
|
const logPath = await ensureDispatchLogPath(root);
|
|
212
219
|
say(`Log: ${path.relative(root, logPath)}`);
|
|
213
|
-
const
|
|
220
|
+
const acquired = acquireQueueLease(root, {
|
|
221
|
+
...opts.lease,
|
|
222
|
+
onLost: (by) => say(
|
|
223
|
+
`Queue lease lost: ${by ? `session ${by.session} (pid ${by.dispatcher.pid})` : "the lease file"} replaced this session's lease. Another /run-plan-all may be writing this queue.`,
|
|
224
|
+
"warn"
|
|
225
|
+
)
|
|
226
|
+
});
|
|
227
|
+
if (!acquired.ok) {
|
|
228
|
+
say(acquired.message, "error");
|
|
229
|
+
return finish(1, acquired.message);
|
|
230
|
+
}
|
|
231
|
+
const lease = acquired.handle;
|
|
232
|
+
if (lease.takeover) {
|
|
233
|
+
say(
|
|
234
|
+
`Queue lease: took over a stale lease (${lease.takeover.reason}); the takeover is logged in HANDOFF.`,
|
|
235
|
+
"warn"
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
const previousSession = process.env[QUEUE_LEASE_SESSION_ENV];
|
|
239
|
+
process.env[QUEUE_LEASE_SESSION_ENV] = lease.session;
|
|
240
|
+
const interrupted = (reason) => {
|
|
214
241
|
queue?.stop();
|
|
242
|
+
lease.releaseAfterAgent(QUEUE_LEASE_INTERRUPT_WAIT_MS);
|
|
215
243
|
emitter.emit({
|
|
216
244
|
type: "run_end",
|
|
217
245
|
exitCode: 130,
|
|
218
246
|
ticks,
|
|
219
247
|
pending: null,
|
|
220
|
-
reason
|
|
248
|
+
reason,
|
|
221
249
|
planExhausted: false,
|
|
222
250
|
usage: null
|
|
223
251
|
});
|
|
224
252
|
process.exit(130);
|
|
225
253
|
};
|
|
254
|
+
const onSigInt = () => interrupted("interrupted (SIGINT)");
|
|
226
255
|
process.on("SIGINT", onSigInt);
|
|
256
|
+
const offTermination = forwardTermination(
|
|
257
|
+
() => lease.agent(),
|
|
258
|
+
(signal) => interrupted(`interrupted (${signal})`)
|
|
259
|
+
);
|
|
227
260
|
try {
|
|
228
261
|
ticks = DISPATCH_DRIVER_TICK;
|
|
229
262
|
let result;
|
|
@@ -235,6 +268,7 @@ async function runDispatchDriver(opts) {
|
|
|
235
268
|
prompt,
|
|
236
269
|
model: opts.model,
|
|
237
270
|
logPath,
|
|
271
|
+
...opts.env ? { env: opts.env } : {},
|
|
238
272
|
spawnFn: opts.spawnFn,
|
|
239
273
|
versionFn: opts.versionFn,
|
|
240
274
|
log: (line) => say(line),
|
|
@@ -242,8 +276,10 @@ async function runDispatchDriver(opts) {
|
|
|
242
276
|
hitl: {
|
|
243
277
|
policy: opts.noHitl ? "off" : "driver",
|
|
244
278
|
readAnswer: reader.read,
|
|
245
|
-
write: writeErr
|
|
246
|
-
|
|
279
|
+
write: writeErr,
|
|
280
|
+
checkIn: gateCheckIn(root, () => lease.session, opts.lease)
|
|
281
|
+
},
|
|
282
|
+
onSpawn: (info) => lease.setAgent(info.pid)
|
|
247
283
|
});
|
|
248
284
|
} catch (err) {
|
|
249
285
|
say(String(err), "error");
|
|
@@ -267,6 +303,10 @@ async function runDispatchDriver(opts) {
|
|
|
267
303
|
return finish(exitCode, reason, result);
|
|
268
304
|
} finally {
|
|
269
305
|
process.off("SIGINT", onSigInt);
|
|
306
|
+
offTermination();
|
|
307
|
+
lease.release();
|
|
308
|
+
if (previousSession === void 0) delete process.env[QUEUE_LEASE_SESSION_ENV];
|
|
309
|
+
else process.env[QUEUE_LEASE_SESSION_ENV] = previousSession;
|
|
270
310
|
}
|
|
271
311
|
}
|
|
272
312
|
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
diffAgainstRegistry,
|
|
8
8
|
summarizeDiff
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VJWWJA36.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_REGISTRY_URL,
|
|
12
12
|
assertSafeRegistrySource,
|
|
13
13
|
loadAgentKitManifest,
|
|
14
14
|
resolveRegistryRoot
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3HNTNYPR.js";
|
|
16
16
|
import {
|
|
17
17
|
KIT_PACKAGE_SPEC,
|
|
18
18
|
KIT_VERSION
|
|
@@ -2,8 +2,10 @@ import {
|
|
|
2
2
|
validateHandoffText
|
|
3
3
|
} from "./chunk-2YU2H7I6.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
collectLiveRoster,
|
|
6
|
+
formatRosterLease,
|
|
7
|
+
formatRosterRow
|
|
8
|
+
} from "./chunk-QWTBYXHN.js";
|
|
7
9
|
import {
|
|
8
10
|
CHANGELOG_FETCH_TIMEOUT_MS,
|
|
9
11
|
resolveInventoryRoot,
|
|
@@ -17,24 +19,18 @@ import {
|
|
|
17
19
|
formatPlanIndexSection,
|
|
18
20
|
writePlanIndex
|
|
19
21
|
} from "./chunk-L5V3W3DY.js";
|
|
20
|
-
import "./chunk-MUTTNRX4.js";
|
|
21
22
|
import {
|
|
22
23
|
READINESS_SNAPSHOT_RELATIVE_PATH
|
|
23
24
|
} from "./chunk-HAFRAXGV.js";
|
|
24
25
|
import {
|
|
25
26
|
stampLastCheckedAt
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-IQQQDEQ4.js";
|
|
27
28
|
import {
|
|
28
29
|
loadContextConfig
|
|
29
30
|
} from "./chunk-PFEUZXVT.js";
|
|
30
|
-
import "./chunk-VBQHBSIB.js";
|
|
31
|
-
import "./chunk-AQTCXUYS.js";
|
|
32
|
-
import "./chunk-WS6OX2IG.js";
|
|
33
31
|
import {
|
|
34
32
|
MANIFEST_RELATIVE_PATH
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-5IJQGIOY.js";
|
|
37
|
-
import "./chunk-7HDQEK6T.js";
|
|
33
|
+
} from "./chunk-3HNTNYPR.js";
|
|
38
34
|
import {
|
|
39
35
|
HANDOFF_REL
|
|
40
36
|
} from "./chunk-C4Q77GGJ.js";
|
|
@@ -42,31 +38,6 @@ import {
|
|
|
42
38
|
fileExists
|
|
43
39
|
} from "./chunk-5B4DVO6C.js";
|
|
44
40
|
|
|
45
|
-
// src/commands/hook.ts
|
|
46
|
-
import path2 from "path";
|
|
47
|
-
import { defineCommand } from "citty";
|
|
48
|
-
|
|
49
|
-
// src/hooks/format-session-start.ts
|
|
50
|
-
function resolveSessionStartFormat(value) {
|
|
51
|
-
return value === "claude" ? "claude" : "cursor";
|
|
52
|
-
}
|
|
53
|
-
function formatSessionStartOutput(additionalContext, format) {
|
|
54
|
-
if (format === "claude") return additionalContext;
|
|
55
|
-
return JSON.stringify({ additional_context: additionalContext });
|
|
56
|
-
}
|
|
57
|
-
var SESSION_START_DEGRADED_MESSAGE = "Agent Kit session-start context is unavailable this session (internal error, fail-open mode). Nothing else is affected; retry next session.";
|
|
58
|
-
|
|
59
|
-
// src/hooks/pre-compact.ts
|
|
60
|
-
var CONTEXT_USAGE_CAP_PERCENT = 50;
|
|
61
|
-
function buildPreCompactUserMessage(payload = {}) {
|
|
62
|
-
const pct = payload.context_usage_percent;
|
|
63
|
-
const trigger = payload.trigger || "auto";
|
|
64
|
-
const pctTxt = pct !== void 0 && pct !== null ? `~${pct}%` : "high";
|
|
65
|
-
const overCap = pct === void 0 || pct === null || pct >= CONTEXT_USAGE_CAP_PERCENT;
|
|
66
|
-
const msg = overCap ? `Context compacting (${trigger}, usage ${pctTxt}) \u2014 over the ${CONTEXT_USAGE_CAP_PERCENT}% per-agent context-usage cap. Update \`.cursor/HANDOFF.md\` now (forced checkpoint) and open a new chat with \`/continue-plan\` so the next agent starts fresh.` : `Context compacting (${trigger}, usage ${pctTxt}). Update \`.cursor/HANDOFF.md\` and open a new chat with \`/continue-plan\` so the next agent starts fresh.`;
|
|
67
|
-
return { user_message: msg };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
41
|
// src/hooks/session-start.ts
|
|
71
42
|
import { spawn } from "child_process";
|
|
72
43
|
import { readFile, stat } from "fs/promises";
|
|
@@ -887,32 +858,32 @@ function formatSessionAge(seconds) {
|
|
|
887
858
|
if (seconds >= 60) return `${Math.floor(seconds / 60)}m`;
|
|
888
859
|
return `${seconds}s`;
|
|
889
860
|
}
|
|
890
|
-
async function
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (entry.socketPath) {
|
|
907
|
-
try {
|
|
908
|
-
const { mtimeMs } = await stat(entry.socketPath);
|
|
909
|
-
if (nowMs >= mtimeMs) ageSeconds = Math.floor((nowMs - mtimeMs) / 1e3);
|
|
910
|
-
} catch {
|
|
911
|
-
}
|
|
861
|
+
async function listDetachedAuditSessions(deps = {}) {
|
|
862
|
+
const run = deps.runCommand ?? runAuditSessionCommand;
|
|
863
|
+
const nowMs = (deps.now ?? Date.now)();
|
|
864
|
+
const [tmuxOut, screenOut] = await Promise.all([
|
|
865
|
+
run("tmux", ["list-sessions", "-F", "#{session_name} #{session_attached} #{session_created}"]),
|
|
866
|
+
run("screen", ["-ls"])
|
|
867
|
+
]);
|
|
868
|
+
const sessions = tmuxOut ? parseTmuxDetachedAuditSessions(tmuxOut, Math.floor(nowMs / 1e3)) : [];
|
|
869
|
+
if (screenOut) {
|
|
870
|
+
for (const entry of parseScreenDetachedAuditSessions(screenOut)) {
|
|
871
|
+
let ageSeconds = -1;
|
|
872
|
+
if (entry.socketPath) {
|
|
873
|
+
try {
|
|
874
|
+
const { mtimeMs } = await stat(entry.socketPath);
|
|
875
|
+
if (nowMs >= mtimeMs) ageSeconds = Math.floor((nowMs - mtimeMs) / 1e3);
|
|
876
|
+
} catch {
|
|
912
877
|
}
|
|
913
|
-
sessions.push({ channel: "screen", name: entry.name, ageSeconds });
|
|
914
878
|
}
|
|
879
|
+
sessions.push({ channel: "screen", name: entry.name, ageSeconds });
|
|
915
880
|
}
|
|
881
|
+
}
|
|
882
|
+
return sessions;
|
|
883
|
+
}
|
|
884
|
+
async function detachedAuditSessionsSection(deps = {}) {
|
|
885
|
+
try {
|
|
886
|
+
const sessions = await listDetachedAuditSessions(deps);
|
|
916
887
|
if (sessions.length === 0) return null;
|
|
917
888
|
const knownAges = sessions.map((s) => s.ageSeconds).filter((a) => a >= 0);
|
|
918
889
|
const oldest = knownAges.length ? `oldest ~${formatSessionAge(Math.max(...knownAges))}` : "oldest age unknown";
|
|
@@ -924,8 +895,55 @@ ${sessions.length} detached \`agent-kit-audit-*\` PTY ${noun} on this host (${ol
|
|
|
924
895
|
return null;
|
|
925
896
|
}
|
|
926
897
|
}
|
|
898
|
+
var LIVE_AGENTS_SECTION_DEADLINE_MS = 3e3;
|
|
899
|
+
var LIVE_AGENTS_SECTION_MAX_ROWS = 5;
|
|
900
|
+
var LIVE_AGENTS_SECTION_MAX_WORKTREES = 3;
|
|
901
|
+
var LIVE_AGENTS_SECTION_MAX_CHARS = 2e3;
|
|
902
|
+
function formatLiveAgentsSection(roster) {
|
|
903
|
+
const others = roster.rows.filter((r) => !r.self && r.kind !== "audit");
|
|
904
|
+
const held = roster.lease.kind === "held";
|
|
905
|
+
if (!held && others.length === 0) return null;
|
|
906
|
+
const lines = ["## Other live agents in this workspace", "", formatRosterLease(roster)];
|
|
907
|
+
for (const row of others.slice(0, LIVE_AGENTS_SECTION_MAX_ROWS)) {
|
|
908
|
+
lines.push(formatRosterRow(row, roster.root));
|
|
909
|
+
}
|
|
910
|
+
if (others.length > LIVE_AGENTS_SECTION_MAX_ROWS) {
|
|
911
|
+
lines.push(
|
|
912
|
+
` +${others.length - LIVE_AGENTS_SECTION_MAX_ROWS} more (agent-kit sessions --live)`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
const busy = roster.worktrees.filter((w) => !w.self);
|
|
916
|
+
if (busy.length > 0) {
|
|
917
|
+
const shown = busy.slice(0, LIVE_AGENTS_SECTION_MAX_WORKTREES).map((w) => w.path).join(", ");
|
|
918
|
+
const more = busy.length > LIVE_AGENTS_SECTION_MAX_WORKTREES ? ` (+${busy.length - LIVE_AGENTS_SECTION_MAX_WORKTREES} more)` : "";
|
|
919
|
+
lines.push(`Worktrees in use by a live process (never reuse them): ${shown}${more}`);
|
|
920
|
+
}
|
|
921
|
+
lines.push(
|
|
922
|
+
"",
|
|
923
|
+
held ? "Another live session holds the queue lease: do not write Plan, Next to-dos, queue fields or plan to-do status, and do not dispatch; report the lease line instead. Re-check with `agent-kit queue lease`." : "Check in with `agent-kit queue lease` before each Ask and before each write to Plan, Next to-dos, queue fields or plan to-do status; held by another live session means stop and report that line."
|
|
924
|
+
);
|
|
925
|
+
let text = lines.join("\n");
|
|
926
|
+
if (text.length > LIVE_AGENTS_SECTION_MAX_CHARS) {
|
|
927
|
+
text = `${text.slice(0, LIVE_AGENTS_SECTION_MAX_CHARS - 40).trimEnd()}
|
|
928
|
+
\u2026 (agent-kit sessions --live)`;
|
|
929
|
+
}
|
|
930
|
+
return text;
|
|
931
|
+
}
|
|
932
|
+
async function liveAgentsSection(root, deps = {}) {
|
|
933
|
+
try {
|
|
934
|
+
const collect = deps.collect ?? ((r) => collectLiveRoster(r, { listAudit: async () => [] }));
|
|
935
|
+
const roster = await withDeadline(
|
|
936
|
+
collect(root),
|
|
937
|
+
deps.deadlineMs ?? LIVE_AGENTS_SECTION_DEADLINE_MS
|
|
938
|
+
);
|
|
939
|
+
return roster ? formatLiveAgentsSection(roster) : null;
|
|
940
|
+
} catch {
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
927
944
|
async function buildSessionStartAdditionalContext(rootDir, _payload = {}, deps = {}) {
|
|
928
945
|
const root = path.resolve(rootDir);
|
|
946
|
+
const liveAgentsPending = liveAgentsSection(root, { collect: deps.liveRoster });
|
|
929
947
|
const handoffPath = path.join(root, HANDOFF_REL);
|
|
930
948
|
const handoffFull = await readFull(handoffPath);
|
|
931
949
|
const handoff = capHandoffExcerpt(handoffFull);
|
|
@@ -953,6 +971,8 @@ async function buildSessionStartAdditionalContext(rootDir, _payload = {}, deps =
|
|
|
953
971
|
if (updateNudge) parts.push(updateNudge);
|
|
954
972
|
if (cursorNudge) parts.push(cursorNudge);
|
|
955
973
|
if (inboundNudge) parts.push(inboundNudge);
|
|
974
|
+
const liveAgents = await liveAgentsPending.catch(() => null);
|
|
975
|
+
if (liveAgents) parts.push(liveAgents);
|
|
956
976
|
const auditSessions = await detachedAuditSessionsSection().catch(() => null);
|
|
957
977
|
if (auditSessions) parts.push(auditSessions);
|
|
958
978
|
const formatWarnings = validateHandoffText(handoffFull);
|
|
@@ -1024,60 +1044,31 @@ function resolveSessionRoot(payload, cwd = process.cwd()) {
|
|
|
1024
1044
|
return cwd;
|
|
1025
1045
|
}
|
|
1026
1046
|
|
|
1027
|
-
// src/commands/hook.ts
|
|
1028
|
-
async function runSessionStartHook(cwd, formatArg, deps = {}) {
|
|
1029
|
-
const format = resolveSessionStartFormat(formatArg);
|
|
1030
|
-
try {
|
|
1031
|
-
const readStdin = deps.readStdin ?? readStdinJson;
|
|
1032
|
-
const buildContext = deps.buildContext ?? buildSessionStartAdditionalContext;
|
|
1033
|
-
const payload = await readStdin();
|
|
1034
|
-
const root = resolveSessionRoot(payload, path2.resolve(cwd));
|
|
1035
|
-
const out = await buildContext(root, payload);
|
|
1036
|
-
return formatSessionStartOutput(out.additional_context, format);
|
|
1037
|
-
} catch {
|
|
1038
|
-
return formatSessionStartOutput(SESSION_START_DEGRADED_MESSAGE, format);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
var hookCommand = defineCommand({
|
|
1042
|
-
meta: {
|
|
1043
|
-
name: "hook",
|
|
1044
|
-
description: "Cursor + Claude Code hook adapters (session-start, pre-compact). CLI is SoT."
|
|
1045
|
-
},
|
|
1046
|
-
subCommands: {
|
|
1047
|
-
"session-start": defineCommand({
|
|
1048
|
-
meta: {
|
|
1049
|
-
name: "session-start",
|
|
1050
|
-
description: "Emit sessionStart context (stdin: host payload). --format cursor (default, JSON additional_context) | claude (plain stdout)"
|
|
1051
|
-
},
|
|
1052
|
-
args: {
|
|
1053
|
-
cwd: {
|
|
1054
|
-
type: "string",
|
|
1055
|
-
default: process.cwd()
|
|
1056
|
-
},
|
|
1057
|
-
format: {
|
|
1058
|
-
type: "string",
|
|
1059
|
-
default: "cursor",
|
|
1060
|
-
description: "cursor (default) | claude"
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
async run({ args }) {
|
|
1064
|
-
const cwd = typeof args.cwd === "string" ? args.cwd : process.cwd();
|
|
1065
|
-
console.log(await runSessionStartHook(cwd, args.format));
|
|
1066
|
-
}
|
|
1067
|
-
}),
|
|
1068
|
-
"pre-compact": defineCommand({
|
|
1069
|
-
meta: {
|
|
1070
|
-
name: "pre-compact",
|
|
1071
|
-
description: "Emit preCompact user_message JSON (stdin: Cursor payload)"
|
|
1072
|
-
},
|
|
1073
|
-
async run() {
|
|
1074
|
-
const payload = await readStdinJson();
|
|
1075
|
-
console.log(JSON.stringify(buildPreCompactUserMessage(payload)));
|
|
1076
|
-
}
|
|
1077
|
-
})
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
1047
|
export {
|
|
1081
|
-
|
|
1082
|
-
|
|
1048
|
+
CURSOR_AWARENESS_SPAWN_TIMEOUT_MS,
|
|
1049
|
+
parseUnprocessedDogfoodItems,
|
|
1050
|
+
colonyHostSection,
|
|
1051
|
+
SESSION_START_SECTION_DEADLINE_MS,
|
|
1052
|
+
withDeadline,
|
|
1053
|
+
runSectionWithDeadline,
|
|
1054
|
+
sectionAttemptNeedsStamp,
|
|
1055
|
+
updateCheckSection,
|
|
1056
|
+
shouldEmitCursorAwarenessNudge,
|
|
1057
|
+
cursorAwarenessSection,
|
|
1058
|
+
PUBLIC_INBOUND_SPAWN_TIMEOUT_MS,
|
|
1059
|
+
publicInboundSection,
|
|
1060
|
+
AUDIT_SESSION_LIST_TIMEOUT_MS,
|
|
1061
|
+
parseTmuxDetachedAuditSessions,
|
|
1062
|
+
parseScreenDetachedAuditSessions,
|
|
1063
|
+
formatSessionAge,
|
|
1064
|
+
listDetachedAuditSessions,
|
|
1065
|
+
detachedAuditSessionsSection,
|
|
1066
|
+
LIVE_AGENTS_SECTION_DEADLINE_MS,
|
|
1067
|
+
LIVE_AGENTS_SECTION_MAX_ROWS,
|
|
1068
|
+
LIVE_AGENTS_SECTION_MAX_WORKTREES,
|
|
1069
|
+
LIVE_AGENTS_SECTION_MAX_CHARS,
|
|
1070
|
+
formatLiveAgentsSection,
|
|
1071
|
+
liveAgentsSection,
|
|
1072
|
+
buildSessionStartAdditionalContext,
|
|
1073
|
+
resolveSessionRoot
|
|
1083
1074
|
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatStaleCliRefusal,
|
|
7
7
|
installL0,
|
|
8
8
|
syncFromManifest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-G2Z37XFM.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-GTP224FI.js";
|
|
19
19
|
import {
|
|
20
20
|
assessClaudeCommandAdapters,
|
|
21
21
|
executeSafeReadinessFixes
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7MUTZHWP.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-EBDQYFA4.js";
|
|
29
29
|
import {
|
|
30
30
|
CLAUDE_HITL_FALLBACK,
|
|
31
31
|
generateClaudeCommandAdapters
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UXQH2CNC.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-QBYJNGCD.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-IQQQDEQ4.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-3HNTNYPR.js";
|
|
83
83
|
import {
|
|
84
84
|
KIT_VERSION,
|
|
85
85
|
pinnedCliSpec
|
|
@@ -314,6 +314,14 @@ function driverStop(askId, raw) {
|
|
|
314
314
|
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
+
function leaseHeldStop(askId, line) {
|
|
318
|
+
return {
|
|
319
|
+
askId,
|
|
320
|
+
cause: "lease held",
|
|
321
|
+
message: `stopped: gate ${askId} not offered (${line})`,
|
|
322
|
+
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
323
|
+
};
|
|
324
|
+
}
|
|
317
325
|
function noRelayStop(askId, backend) {
|
|
318
326
|
return {
|
|
319
327
|
askId,
|
|
@@ -346,6 +354,8 @@ async function askOperator(gate, opts) {
|
|
|
346
354
|
if (!opts.isTTY && opts.policy !== "driver") {
|
|
347
355
|
return { kind: "stop", stop: unansweredStop(gate.askId, "no TTY") };
|
|
348
356
|
}
|
|
357
|
+
const held = opts.checkIn?.() ?? null;
|
|
358
|
+
if (held) return { kind: "stop", stop: leaseHeldStop(gate.askId, held) };
|
|
349
359
|
opts.onPromptStart?.();
|
|
350
360
|
let raw;
|
|
351
361
|
try {
|
|
@@ -42,9 +42,30 @@ var INTERACTIVE_ALLOW_RULES = [
|
|
|
42
42
|
"Bash(glab mr merge)",
|
|
43
43
|
"Bash(glab mr merge *)"
|
|
44
44
|
];
|
|
45
|
+
var MERGE_ALLOW_CONTROL = {
|
|
46
|
+
guardRule: "pr-merge-protected-base",
|
|
47
|
+
summary: "the PreToolUse(Bash) hook `agent-kit guard shell` denies a merge into main/master/prod or into a base it cannot resolve"
|
|
48
|
+
};
|
|
49
|
+
var INTERACTIVE_ALLOW_CONTROLS = {
|
|
50
|
+
"Bash(gh pr merge)": MERGE_ALLOW_CONTROL,
|
|
51
|
+
"Bash(gh pr merge *)": MERGE_ALLOW_CONTROL,
|
|
52
|
+
"Bash(glab mr merge)": MERGE_ALLOW_CONTROL,
|
|
53
|
+
"Bash(glab mr merge *)": MERGE_ALLOW_CONTROL
|
|
54
|
+
};
|
|
55
|
+
function isMergeAllowRow(row) {
|
|
56
|
+
return /^Bash\(\s*(?:gh\s+pr|glab\s+mr)\s+merge\b/.test(row);
|
|
57
|
+
}
|
|
58
|
+
function permissionRowControl(kind, row) {
|
|
59
|
+
if (kind === "deny") return "narrows permissions (native deny backstop)";
|
|
60
|
+
const control = INTERACTIVE_ALLOW_CONTROLS[row] ?? (isMergeAllowRow(row) ? MERGE_ALLOW_CONTROL : void 0);
|
|
61
|
+
if (!control) return "no kit control (not a kit row)";
|
|
62
|
+
return `compensating control: guard rule \`${control.guardRule}\` (${control.summary})`;
|
|
63
|
+
}
|
|
45
64
|
|
|
46
65
|
export {
|
|
47
66
|
HEADLESS_DENY_RULES,
|
|
48
67
|
INTERACTIVE_DENY_RULES,
|
|
49
|
-
INTERACTIVE_ALLOW_RULES
|
|
68
|
+
INTERACTIVE_ALLOW_RULES,
|
|
69
|
+
isMergeAllowRow,
|
|
70
|
+
permissionRowControl
|
|
50
71
|
};
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
compareSemver,
|
|
6
6
|
normalizeSemver
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IQQQDEQ4.js";
|
|
8
8
|
import {
|
|
9
9
|
MANIFEST_RELATIVE_PATH
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3HNTNYPR.js";
|
|
11
11
|
import {
|
|
12
12
|
KIT_VERSION,
|
|
13
13
|
pinnedCliSpec
|