@dadado/agent-kit-cli 6.10.1 → 6.12.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.
Files changed (43) hide show
  1. package/dist/{add-7GH3K44T.js → add-CLRIMPN4.js} +3 -3
  2. package/dist/{chunk-52WYZFP5.js → chunk-2R4HYPQH.js} +2 -2
  3. package/dist/{chunk-26KXYR5T.js → chunk-2TKPKRHO.js} +2 -2
  4. package/dist/{chunk-CXDAT76O.js → chunk-4WHPZGF4.js} +17 -6
  5. package/dist/{chunk-6LRY2CYU.js → chunk-5RWTDCJ7.js} +5 -1
  6. package/dist/{chunk-75ELVLBY.js → chunk-5T4CHRRR.js} +1 -1
  7. package/dist/chunk-7ABY6DYH.js +89 -0
  8. package/dist/{chunk-BZI5G3OZ.js → chunk-7TEEGAED.js} +35 -5
  9. package/dist/{chunk-BSYQJ5WF.js → chunk-CRLMS2JX.js} +1 -1
  10. package/dist/{chunk-O5FKTKOW.js → chunk-DVCNJNCF.js} +3 -3
  11. package/dist/{chunk-BB22FGQ4.js → chunk-EE3LTOBZ.js} +1 -1
  12. package/dist/{chunk-LPZ2KXVE.js → chunk-FX6BIH4C.js} +1 -1
  13. package/dist/{chunk-6UKI4CAN.js → chunk-GDKTTV2A.js} +13 -2
  14. package/dist/{chunk-HIJTNHJE.js → chunk-HWYVLEET.js} +3 -3
  15. package/dist/{chunk-TZA7MT4I.js → chunk-I2SG2VPJ.js} +2 -2
  16. package/dist/{chunk-LGSNC4OI.js → chunk-IBE2EJZS.js} +1 -1
  17. package/dist/{chunk-ZF4YBL7F.js → chunk-LAYMAMPL.js} +1 -1
  18. package/dist/{chunk-GQ6Q3P7C.js → chunk-ODI2N2BN.js} +2 -2
  19. package/dist/{chunk-BIFWN6BJ.js → chunk-OKQ3SAHK.js} +1 -1
  20. package/dist/{chunk-K5OCGZWA.js → chunk-PGCRP5A6.js} +8 -8
  21. package/dist/chunk-TFKEHC2D.js +273 -0
  22. package/dist/{chunk-S7XAV6JK.js → chunk-UX6FHSO7.js} +5 -5
  23. package/dist/{chunk-TUZVOPKY.js → chunk-WAWCS5PJ.js} +75 -122
  24. package/dist/{chunk-MTLQN57O.js → chunk-WRCXRV2U.js} +114 -6
  25. package/dist/{chunk-HVH24VRL.js → chunk-XJWCL4PO.js} +1 -1
  26. package/dist/{commands-EQHK3ZEP.js → commands-DVEZOEEO.js} +5 -5
  27. package/dist/{contribute-VSVPRHQ7.js → contribute-E3COXKH4.js} +4 -4
  28. package/dist/{countdown-XYRE4GZU.js → countdown-F6EIHGDR.js} +7 -7
  29. package/dist/{diff-4P7LMQK5.js → diff-SCGNC4SF.js} +5 -5
  30. package/dist/{doctor-E6LOBJYK.js → doctor-QGO4QB7R.js} +9 -9
  31. package/dist/{engine-info-3MQML5I2.js → engine-info-MNCKB55Y.js} +2 -2
  32. package/dist/{ground-control-726LRB6Q.js → ground-control-DB5RSYAT.js} +4 -4
  33. package/dist/{hook-HJW5SXQG.js → hook-R7V4NG3C.js} +5 -5
  34. package/dist/index.js +22 -20
  35. package/dist/{init-KKVT2RW4.js → init-ONPKZS63.js} +12 -12
  36. package/dist/{install-BPZTP5KT.js → install-NHTYTVSG.js} +12 -12
  37. package/dist/queue-XI4HUFLJ.js +172 -0
  38. package/dist/{run-326EEQYY.js → run-EO5P2YZG.js} +50 -271
  39. package/dist/{run-plan-2IFO4G4Y.js → run-plan-VMW34QY6.js} +8 -7
  40. package/dist/{setup-global-BFBSR2RZ.js → setup-global-PMKGHX2S.js} +6 -6
  41. package/dist/{status-LNXVLDMP.js → status-P2I6LE6Y.js} +7 -7
  42. package/dist/{update-PX5XFCSG.js → update-K6L24JDP.js} +10 -10
  43. package/package.json +20 -13
@@ -0,0 +1,172 @@
1
+ import {
2
+ readHandoffText
3
+ } from "./chunk-TFKEHC2D.js";
4
+ import "./chunk-7ABY6DYH.js";
5
+ import "./chunk-4WHPZGF4.js";
6
+ import "./chunk-EE3LTOBZ.js";
7
+ import "./chunk-2TKPKRHO.js";
8
+ import {
9
+ extractFieldBlock
10
+ } from "./chunk-L5V3W3DY.js";
11
+ import "./chunk-MUTTNRX4.js";
12
+ import "./chunk-7TEEGAED.js";
13
+ import "./chunk-GDKTTV2A.js";
14
+ import "./chunk-WRCXRV2U.js";
15
+ import "./chunk-WGLPZXNU.js";
16
+ import "./chunk-6RRG3WOE.js";
17
+ import "./chunk-QTON2GQX.js";
18
+ import "./chunk-C4Q77GGJ.js";
19
+ import "./chunk-5B4DVO6C.js";
20
+
21
+ // src/commands/queue.ts
22
+ import path from "path";
23
+ import { defineCommand } from "citty";
24
+
25
+ // src/plan-loop/run-plan-all-intake-runbook.ts
26
+ var DEFAULT_KNOWN_SHIP_RECOVERIES = [
27
+ "ci_fix_once",
28
+ "hold_path",
29
+ "no_product_diff",
30
+ "release_preflight",
31
+ "converging_poll"
32
+ ];
33
+ var RECOVERY_SET = new Set(DEFAULT_KNOWN_SHIP_RECOVERIES);
34
+
35
+ // src/plan-loop/run-plan-all-orchestrator.ts
36
+ var PLAN_WORKER_OUTCOMES = ["completed", "blocked", "partial"];
37
+ var QUEUE_END_GATES_ASK_LABELS = [
38
+ "Resolve gates now",
39
+ "Print resolution prompt",
40
+ "Later"
41
+ ];
42
+ var OUTCOME_SET = new Set(PLAN_WORKER_OUTCOMES);
43
+ var ASK_ID = "`?[a-z0-9]+(?:-[a-z0-9]+)+`?";
44
+ var NAMED_ASKS = new RegExp(
45
+ `\\bAsks?\\s+(${ASK_ID}(?:(?:\\s*[+,]\\s*|\\s+and\\s+)${ASK_ID})*)`,
46
+ "g"
47
+ );
48
+ function namedAsks(gate) {
49
+ const ids = [...gate.matchAll(NAMED_ASKS)].flatMap(
50
+ (m) => m[1].match(/[a-z0-9]+(?:-[a-z0-9]+)+/g) ?? []
51
+ );
52
+ return [...new Set(ids)];
53
+ }
54
+ function decideQueueEndGatesAsk(deferred) {
55
+ const labels = QUEUE_END_GATES_ASK_LABELS;
56
+ const gates = Object.entries(deferred).map(([plan, gate]) => ({
57
+ plan,
58
+ gate,
59
+ asks: namedAsks(gate)
60
+ }));
61
+ if (gates.length === 0) return { ask: false, reason: "no_deferred", labels, gates };
62
+ return { ask: true, reason: "deferred_gates", labels, gates };
63
+ }
64
+ function formatQueueEndResolutionPrompt(gates, backend = "claude") {
65
+ const lines = [
66
+ `agent-kit run-plan-all --backend ${backend}`,
67
+ "",
68
+ "Re-probe the deferred-operator rows first. Operator steps done since the last run:",
69
+ ...gates.map(
70
+ (g) => `- ${g.plan}: ${g.gate}${g.asks.length ? ` (open Asks: ${g.asks.join(", ")})` : ""}`
71
+ )
72
+ ];
73
+ return `${lines.join("\n")}
74
+ `;
75
+ }
76
+ var OUTCOME_ROW_RE = /^`?([^\s`:]+\.plan\.md)`?:\s*(.*)$/;
77
+ var DEFERRED_PREFIX = "deferred-operator";
78
+ function balancedParenBody(text, open) {
79
+ let depth = 0;
80
+ for (let i = open; i < text.length; i += 1) {
81
+ const ch = text[i];
82
+ if (ch === "(") depth += 1;
83
+ else if (ch === ")") {
84
+ depth -= 1;
85
+ if (depth === 0) return text.slice(open + 1, i);
86
+ }
87
+ }
88
+ return text.slice(open + 1);
89
+ }
90
+ function readDeferredGatesFromHandoff(handoff) {
91
+ const block = extractFieldBlock(handoff, "Queue outcomes");
92
+ const deferred = {};
93
+ if (!block) return deferred;
94
+ for (const line of block.split("\n")) {
95
+ const row = OUTCOME_ROW_RE.exec(line.trim());
96
+ if (!row) continue;
97
+ const plan = row[1];
98
+ const outcome = row[2].trim();
99
+ if (!outcome.startsWith(DEFERRED_PREFIX)) continue;
100
+ const rest = outcome.slice(DEFERRED_PREFIX.length);
101
+ const open = rest.search(/\(\s*gate:/);
102
+ const gate = open >= 0 ? balancedParenBody(rest, open).replace(/^\s*gate:\s*/, "") : rest.replace(/^[\s:(-]+/, "").replace(/\)\s*$/, "");
103
+ deferred[plan] = gate.trim() || "operator gate";
104
+ }
105
+ return deferred;
106
+ }
107
+
108
+ // src/commands/queue.ts
109
+ function renderQueueGates(handoff, format, backend = "claude") {
110
+ const decision = decideQueueEndGatesAsk(
111
+ readDeferredGatesFromHandoff(handoff)
112
+ );
113
+ if (format === "json") return `${JSON.stringify(decision, null, 2)}
114
+ `;
115
+ if (format === "prompt") {
116
+ return decision.ask ? formatQueueEndResolutionPrompt(decision.gates, backend) : "";
117
+ }
118
+ if (!decision.ask) return "No deferred operator gates in HANDOFF Queue outcomes.\n";
119
+ const lines = [`Deferred operator gates (${decision.gates.length}):`];
120
+ for (const g of decision.gates) {
121
+ lines.push(`- ${g.plan}: ${g.gate}`);
122
+ if (g.asks.length) lines.push(` open Asks: ${g.asks.join(", ")}`);
123
+ }
124
+ lines.push(
125
+ "",
126
+ "Relaunch with the resolution prompt: agent-kit queue gates --prompt > note.md && agent-kit run-plan-all --note @note.md"
127
+ );
128
+ return `${lines.join("\n")}
129
+ `;
130
+ }
131
+ var gatesCommand = defineCommand({
132
+ meta: {
133
+ name: "gates",
134
+ description: "Print the deferred operator gates from HANDOFF Queue outcomes (zero inference); --prompt prints the relaunch command and resolution prompt"
135
+ },
136
+ args: {
137
+ json: { type: "boolean", description: "Print the gates decision as JSON", default: false },
138
+ prompt: {
139
+ type: "boolean",
140
+ description: "Print the relaunch command and resolution prompt (input for `run-plan-all --note @file`); empty when no gate is deferred",
141
+ default: false
142
+ },
143
+ backend: {
144
+ type: "string",
145
+ description: "Backend named in the --prompt command line (default: claude)",
146
+ default: "claude"
147
+ },
148
+ cwd: { type: "string", description: "Workspace folder (default: current directory)" }
149
+ },
150
+ async run({ args }) {
151
+ if (args.json && args.prompt) {
152
+ process.stderr.write("Use either --json or --prompt, not both.\n");
153
+ process.exitCode = 1;
154
+ return;
155
+ }
156
+ const root = path.resolve(typeof args.cwd === "string" && args.cwd ? args.cwd : ".");
157
+ const handoff = await readHandoffText(root) ?? "";
158
+ const format = args.json ? "json" : args.prompt ? "prompt" : "text";
159
+ process.stdout.write(renderQueueGates(handoff, format, String(args.backend || "claude")));
160
+ }
161
+ });
162
+ var queueCommand = defineCommand({
163
+ meta: {
164
+ name: "queue",
165
+ description: "Read the /run-plan-all queue from HANDOFF (`gates`: deferred operator gates)"
166
+ },
167
+ subCommands: { gates: gatesCommand }
168
+ });
169
+ export {
170
+ queueCommand,
171
+ renderQueueGates
172
+ };
@@ -1,33 +1,29 @@
1
1
  import {
2
- readRunQueueState,
3
2
  runPlanLoop,
4
3
  shouldUseLiveTui,
5
4
  withLiveTui
6
- } from "./chunk-TUZVOPKY.js";
5
+ } from "./chunk-WAWCS5PJ.js";
6
+ import "./chunk-LFWPB2JR.js";
7
+ import {
8
+ landDispatchOutcome,
9
+ runDispatchDriver
10
+ } from "./chunk-TFKEHC2D.js";
11
+ import "./chunk-7ABY6DYH.js";
7
12
  import {
8
- DRIVER_EVENTS_FORMATS,
9
- DRIVER_PROTOCOL_VERSION,
10
- DriverAgentSink,
11
- createDriverAnswerReader,
12
- createDriverEmitter,
13
- driverReplies,
14
- driverStop
15
- } from "./chunk-CXDAT76O.js";
13
+ DRIVER_EVENTS_FORMATS
14
+ } from "./chunk-4WHPZGF4.js";
16
15
  import {
17
16
  REVIEW_PACK_SLASH,
18
17
  runReviewJob
19
- } from "./chunk-S7XAV6JK.js";
18
+ } from "./chunk-UX6FHSO7.js";
20
19
  import {
21
20
  detectAgentBackend,
22
21
  listDetectBackendIds
23
- } from "./chunk-BB22FGQ4.js";
24
- import "./chunk-BSYQJ5WF.js";
22
+ } from "./chunk-EE3LTOBZ.js";
23
+ import "./chunk-CRLMS2JX.js";
25
24
  import {
26
- LAND_ON_GATE_DESCRIPTION,
27
- classifyGateExit,
28
- landGateExit
29
- } from "./chunk-26KXYR5T.js";
30
- import "./chunk-LFWPB2JR.js";
25
+ LAND_ON_GATE_DESCRIPTION
26
+ } from "./chunk-2TKPKRHO.js";
31
27
  import {
32
28
  negatedFlag
33
29
  } from "./chunk-XDCCYBCJ.js";
@@ -40,277 +36,40 @@ import {
40
36
  normalizeSlashName,
41
37
  promoteBlockedMessage,
42
38
  readCommandFile,
39
+ resolveOperatorNote,
43
40
  runHeadlessDispatch,
44
41
  unknownSlashMessage
45
- } from "./chunk-BZI5G3OZ.js";
42
+ } from "./chunk-7TEEGAED.js";
46
43
  import {
47
44
  getBackend
48
- } from "./chunk-6UKI4CAN.js";
45
+ } from "./chunk-GDKTTV2A.js";
49
46
  import {
50
47
  HITL_UNANSWERED_EXIT_CODE,
51
48
  formatHitlSummary,
52
49
  hitlExitCode
53
- } from "./chunk-MTLQN57O.js";
50
+ } from "./chunk-WRCXRV2U.js";
54
51
  import "./chunk-WGLPZXNU.js";
55
52
  import "./chunk-6RRG3WOE.js";
56
53
  import "./chunk-QTON2GQX.js";
57
54
  import {
58
55
  logger
59
56
  } from "./chunk-ZB43YMHW.js";
60
- import {
61
- HANDOFF_REL
62
- } from "./chunk-C4Q77GGJ.js";
57
+ import "./chunk-C4Q77GGJ.js";
63
58
  import "./chunk-5B4DVO6C.js";
64
59
 
65
60
  // src/commands/run.ts
66
61
  import { homedir } from "os";
67
- import path2 from "path";
68
- import { defineCommand } from "citty";
69
-
70
- // src/plan-loop/dispatch-driver.ts
71
- import { readFile } from "fs/promises";
72
62
  import path from "path";
73
- var DISPATCH_DRIVER_TICK = 1;
74
- var QUEUE_STATE_POLL_MS = 1e3;
75
- function projectQueueState(handoff) {
76
- const { queue, cursor, current, status } = readRunQueueState(handoff);
77
- if (queue.length === 0) return { cursor: null, total: 0, current: null, status: null };
78
- return { cursor, total: queue.length, current, status };
79
- }
80
- async function readHandoffText(root) {
81
- try {
82
- return await readFile(path.join(root, HANDOFF_REL), "utf8");
83
- } catch {
84
- return null;
85
- }
86
- }
87
- async function readQueueState(root) {
88
- return projectQueueState(await readHandoffText(root) ?? "");
89
- }
90
- function createQueueStateWatcher(opts) {
91
- const read = opts.read ?? (() => readHandoffText(opts.root));
92
- let last = JSON.stringify(opts.initial);
93
- let pending = null;
94
- let busy = null;
95
- let stopped = false;
96
- const emit = (next, key) => {
97
- last = key;
98
- pending = null;
99
- opts.emitter.emit({ type: "queue_state", ...next });
100
- };
101
- const sample = async () => {
102
- const text = await read();
103
- if (text !== null && text.trim() === "") return null;
104
- const next = projectQueueState(text ?? "");
105
- return { next, key: JSON.stringify(next) };
106
- };
107
- const check = async () => {
108
- const got = await sample();
109
- if (!got || stopped) return;
110
- if (got.key === last) {
111
- pending = null;
112
- return;
113
- }
114
- if (got.key !== pending) {
115
- pending = got.key;
116
- return;
117
- }
118
- emit(got.next, got.key);
119
- };
120
- const tick = () => {
121
- if (busy) return busy;
122
- busy = check().finally(() => {
123
- busy = null;
124
- });
125
- return busy;
126
- };
127
- opts.emitter.emit({ type: "queue_state", ...opts.initial });
128
- const timer = setInterval(() => {
129
- void tick();
130
- }, opts.pollMs ?? QUEUE_STATE_POLL_MS);
131
- timer.unref?.();
132
- return {
133
- flush: async () => {
134
- if (busy) await busy;
135
- const got = await sample();
136
- if (!got || stopped || got.key === last) return;
137
- emit(got.next, got.key);
138
- },
139
- stop: () => {
140
- stopped = true;
141
- clearInterval(timer);
142
- }
143
- };
144
- }
145
- async function landDispatchOutcome(opts) {
146
- const { result } = opts;
147
- const stop = result.hitl?.stop;
148
- const trigger = classifyGateExit({ stop, failed: opts.exitCode !== 0 });
149
- if (!trigger) return;
150
- const summary = result.lastResult?.resultText.trim() || result.lastResult?.assistantTexts.at(-1)?.trim() || void 0;
151
- try {
152
- await landGateExit({
153
- root: opts.root,
154
- outcome: {
155
- trigger,
156
- exitCode: opts.exitCode,
157
- reason: stop?.message ?? `${opts.backendId} exited with code ${opts.exitCode}`,
158
- command: `run ${opts.slash}`,
159
- backend: opts.backendId,
160
- logPath: opts.logPath,
161
- ...stop ? { askId: stop.askId } : {},
162
- ...summary ? { summary } : {},
163
- ...result.lastResult ? {
164
- gateText: [result.lastResult.resultText, ...result.lastResult.assistantTexts].join(
165
- "\n"
166
- )
167
- } : {}
168
- },
169
- log: opts.log
170
- });
171
- } catch (err) {
172
- opts.log(`gate-exit: landing failed: ${String(err)}`);
173
- }
174
- }
175
- async function runDispatchDriver(opts) {
176
- const root = path.resolve(opts.root);
177
- const emitter = createDriverEmitter(opts.events.write, opts.events.now);
178
- const reader = createDriverAnswerReader({
179
- input: opts.events.input,
180
- emitter,
181
- tick: () => DISPATCH_DRIVER_TICK
182
- });
183
- const writeErr = opts.events.writeErr ?? ((text) => {
184
- process.stderr.write(text);
185
- });
186
- const say = (message, level = "info") => emitter.emit({ type: "log", level, message });
187
- let ticks = 0;
188
- let queue = null;
189
- const finish = async (exitCode, reason, result) => {
190
- if (queue) {
191
- await queue.flush();
192
- queue.stop();
193
- }
194
- emitter.emit({
195
- type: "run_end",
196
- exitCode,
197
- ticks,
198
- pending: null,
199
- reason,
200
- planExhausted: false,
201
- replies: driverReplies(result?.hitl?.replies),
202
- stop: driverStop(result?.hitl?.stop)
203
- });
204
- reader.close();
205
- return exitCode;
206
- };
207
- const detected = await detectAgentBackend(opts.backend, opts.whichFn);
208
- if (!detected.ok) {
209
- say(detected.message, "error");
210
- return finish(1, detected.message);
211
- }
212
- const file = await readCommandFile(root, opts.slash);
213
- if (!file.ok) {
214
- say(file.message, "error");
215
- return finish(1, file.message);
216
- }
217
- const prompt = buildDispatchPrompt(file.body);
218
- const initialQueue = await readQueueState(root);
219
- emitter.emit({
220
- type: "run_start",
221
- protocol: DRIVER_PROTOCOL_VERSION,
222
- command: opts.slash,
223
- backend: detected.id,
224
- plan: null,
225
- pending: null,
226
- maxTicks: null,
227
- hitl: opts.noHitl ? "off" : "driver",
228
- queue: initialQueue
229
- });
230
- queue = createQueueStateWatcher({
231
- root,
232
- emitter,
233
- initial: initialQueue,
234
- pollMs: opts.queuePollMs
235
- });
236
- say(`Dispatch: ${opts.slash} via ${detected.id}`);
237
- say(`Command file: ${path.relative(root, file.path)}`);
238
- if (opts.dryRun) {
239
- say("--dry-run: no agent will be started. Prompt:");
240
- say(prompt);
241
- return finish(0, "dry-run");
242
- }
243
- const logPath = await ensureDispatchLogPath(root);
244
- say(`Log: ${path.relative(root, logPath)}`);
245
- const onSigInt = () => {
246
- queue?.stop();
247
- emitter.emit({
248
- type: "run_end",
249
- exitCode: 130,
250
- ticks,
251
- pending: null,
252
- reason: "interrupted (SIGINT)",
253
- planExhausted: false
254
- });
255
- process.exit(130);
256
- };
257
- process.on("SIGINT", onSigInt);
258
- try {
259
- ticks = DISPATCH_DRIVER_TICK;
260
- let result;
261
- try {
262
- result = await runHeadlessDispatch({
263
- backendId: detected.id,
264
- bin: detected.bin,
265
- workspace: root,
266
- prompt,
267
- model: opts.model,
268
- logPath,
269
- spawnFn: opts.spawnFn,
270
- versionFn: opts.versionFn,
271
- log: (line) => say(line),
272
- render: new DriverAgentSink(emitter, DISPATCH_DRIVER_TICK),
273
- hitl: {
274
- policy: opts.noHitl ? "off" : "driver",
275
- readAnswer: reader.read,
276
- write: writeErr
277
- }
278
- });
279
- } catch (err) {
280
- say(String(err), "error");
281
- return finish(1, `${opts.slash} failed to start: ${String(err)}`);
282
- }
283
- for (const line of formatHitlSummary(result.hitl)) say(line);
284
- const exitCode = hitlExitCode(result.exitCode, result.hitl);
285
- if (opts.landOnGate) {
286
- await landDispatchOutcome({
287
- root,
288
- slash: opts.slash,
289
- backendId: detected.id,
290
- logPath,
291
- exitCode,
292
- result,
293
- log: (line) => say(line, "warn")
294
- });
295
- }
296
- const stop = result.hitl?.stop;
297
- const reason = stop ? stop.message : exitCode === 0 ? "session ended" : `${detected.id} exited with code ${exitCode}`;
298
- return finish(exitCode, reason, result);
299
- } finally {
300
- process.off("SIGINT", onSigInt);
301
- }
302
- }
303
-
304
- // src/commands/run.ts
63
+ import { defineCommand } from "citty";
305
64
  var DRIVER_DISPATCH_SLASH = "run-plan-all";
306
65
  function displayPath(target, home = homedir()) {
307
- const resolvedHome = path2.resolve(home);
66
+ const resolvedHome = path.resolve(home);
308
67
  if (target === resolvedHome) return "~";
309
- const prefix = resolvedHome.endsWith(path2.sep) ? resolvedHome : `${resolvedHome}${path2.sep}`;
310
- return target.startsWith(prefix) ? `~${path2.sep}${target.slice(prefix.length)}` : target;
68
+ const prefix = resolvedHome.endsWith(path.sep) ? resolvedHome : `${resolvedHome}${path.sep}`;
69
+ return target.startsWith(prefix) ? `~${path.sep}${target.slice(prefix.length)}` : target;
311
70
  }
312
71
  async function executeRun(input) {
313
- const root = path2.resolve(input.cwd);
72
+ const root = path.resolve(input.cwd);
314
73
  const slash = normalizeSlashName(input.slash);
315
74
  if (!slash) {
316
75
  return { exitCode: 1, error: "Provide a slash: agent-kit run <slash>" };
@@ -328,6 +87,9 @@ async function executeRun(input) {
328
87
  if (input.includeReviewed && slash !== REVIEW_PACK_SLASH) {
329
88
  return { exitCode: 1, error: `--include-reviewed only applies to ${REVIEW_PACK_SLASH}` };
330
89
  }
90
+ if (input.note !== void 0 && slash !== DRIVER_DISPATCH_SLASH) {
91
+ return { exitCode: 1, error: `--note only applies to ${DRIVER_DISPATCH_SLASH}` };
92
+ }
331
93
  if (input.events) {
332
94
  if (slash !== DRIVER_DISPATCH_SLASH) {
333
95
  return {
@@ -344,6 +106,7 @@ async function executeRun(input) {
344
106
  noHitl: input.noHitl === true,
345
107
  landOnGate: input.landOnGate === true,
346
108
  events: input.events,
109
+ ...input.note !== void 0 ? { note: input.note } : {},
347
110
  whichFn: input.whichFn
348
111
  });
349
112
  return { exitCode };
@@ -399,12 +162,12 @@ async function executeRun(input) {
399
162
  if (!file.ok) {
400
163
  return { exitCode: 1, error: file.message };
401
164
  }
402
- const prompt = buildDispatchPrompt(file.body);
165
+ const prompt = buildDispatchPrompt(file.body, input.note);
403
166
  if (input.dryRun) {
404
167
  const stdout = [
405
168
  "--dry-run: no agent will be started.",
406
169
  `Slash: ${slash}`,
407
- `Command file: ${path2.relative(root, file.path)}`,
170
+ `Command file: ${path.relative(root, file.path)}`,
408
171
  `Backend: ${detected.id} (${displayPath(detected.bin)})`,
409
172
  "Prompt:",
410
173
  prompt
@@ -413,8 +176,8 @@ async function executeRun(input) {
413
176
  }
414
177
  const logPath = await ensureDispatchLogPath(root);
415
178
  console.log(`Dispatch: ${slash} via ${detected.id}`);
416
- console.log(`Command file: ${path2.relative(root, file.path)}`);
417
- console.log(`Log: ${path2.relative(root, logPath)}`);
179
+ console.log(`Command file: ${path.relative(root, file.path)}`);
180
+ console.log(`Log: ${path.relative(root, logPath)}`);
418
181
  try {
419
182
  const dispatch = {
420
183
  backendId: detected.id,
@@ -531,6 +294,16 @@ async function runSlashCli(slash, args) {
531
294
  process.exitCode = 1;
532
295
  return;
533
296
  }
297
+ let note;
298
+ if (args.note) {
299
+ const resolved = await resolveOperatorNote(String(args.note), path.resolve(String(args.cwd)));
300
+ if (!resolved.ok) {
301
+ logger.error(resolved.message);
302
+ process.exitCode = 1;
303
+ return;
304
+ }
305
+ note = resolved.note;
306
+ }
534
307
  const result = await executeRun({
535
308
  slash,
536
309
  cwd: String(args.cwd),
@@ -544,7 +317,8 @@ async function runSlashCli(slash, args) {
544
317
  landOnGate: Boolean(args["land-on-gate"]),
545
318
  ...args["max-pack-bytes"] ? { maxPackBytes: String(args["max-pack-bytes"]) } : {},
546
319
  ...args["include-reviewed"] ? { includeReviewed: true } : {},
547
- ...events ? { events: {} } : {}
320
+ ...events ? { events: {} } : {},
321
+ ...note !== void 0 ? { note } : {}
548
322
  });
549
323
  if (result.stdout) {
550
324
  console.log(result.stdout);
@@ -582,7 +356,12 @@ var runPlanAllCommand = defineCommand({
582
356
  ...runDispatchArgs,
583
357
  events: {
584
358
  type: "string",
585
- description: "Driver mode for apps: `ndjson` writes only NDJSON events to stdout and reads HITL answers as JSON lines on stdin (no TTY needed; driver protocol 1.2.0, see docs/driver-events-protocol.md)",
359
+ description: "Driver mode for apps: `ndjson` writes only NDJSON events to stdout and reads HITL answers as JSON lines on stdin (no TTY needed; driver protocol 1.4.0, see docs/driver-events-protocol.md)",
360
+ default: ""
361
+ },
362
+ note: {
363
+ type: "string",
364
+ description: "Operator resolution note appended to the session prompt: text or @file (e.g. the output of `agent-kit queue gates --prompt`). Context only, never a gate answer: a HITL_GATE:/HITL_REPLY: line is rejected",
586
365
  default: ""
587
366
  }
588
367
  },
@@ -1,17 +1,18 @@
1
1
  import {
2
2
  runPlanLoop
3
- } from "./chunk-TUZVOPKY.js";
3
+ } from "./chunk-WAWCS5PJ.js";
4
+ import "./chunk-LFWPB2JR.js";
5
+ import "./chunk-7ABY6DYH.js";
4
6
  import {
5
7
  DRIVER_EVENTS_FORMATS
6
- } from "./chunk-CXDAT76O.js";
8
+ } from "./chunk-4WHPZGF4.js";
7
9
  import {
8
10
  detectAgentBackend,
9
11
  listDetectBackendIds
10
- } from "./chunk-BB22FGQ4.js";
12
+ } from "./chunk-EE3LTOBZ.js";
11
13
  import {
12
14
  LAND_ON_GATE_DESCRIPTION
13
- } from "./chunk-26KXYR5T.js";
14
- import "./chunk-LFWPB2JR.js";
15
+ } from "./chunk-2TKPKRHO.js";
15
16
  import {
16
17
  negatedFlag
17
18
  } from "./chunk-XDCCYBCJ.js";
@@ -19,10 +20,10 @@ import "./chunk-L5V3W3DY.js";
19
20
  import "./chunk-MUTTNRX4.js";
20
21
  import {
21
22
  getBackend
22
- } from "./chunk-6UKI4CAN.js";
23
+ } from "./chunk-GDKTTV2A.js";
23
24
  import {
24
25
  HITL_UNANSWERED_EXIT_CODE
25
- } from "./chunk-MTLQN57O.js";
26
+ } from "./chunk-WRCXRV2U.js";
26
27
  import "./chunk-WGLPZXNU.js";
27
28
  import "./chunk-6RRG3WOE.js";
28
29
  import "./chunk-QTON2GQX.js";
@@ -2,17 +2,17 @@ import {
2
2
  classifyInstallError,
3
3
  isNonInteractive,
4
4
  pathCliStatus
5
- } from "./chunk-TZA7MT4I.js";
5
+ } from "./chunk-I2SG2VPJ.js";
6
6
  import {
7
7
  assessEnvironment
8
8
  } from "./chunk-B3VR5YBQ.js";
9
- import "./chunk-52WYZFP5.js";
9
+ import "./chunk-2R4HYPQH.js";
10
10
  import "./chunk-PFEUZXVT.js";
11
- import "./chunk-O5FKTKOW.js";
12
- import "./chunk-LPZ2KXVE.js";
11
+ import "./chunk-DVCNJNCF.js";
12
+ import "./chunk-FX6BIH4C.js";
13
13
  import "./chunk-2KIOZMTV.js";
14
- import "./chunk-HVH24VRL.js";
15
- import "./chunk-6LRY2CYU.js";
14
+ import "./chunk-XJWCL4PO.js";
15
+ import "./chunk-5RWTDCJ7.js";
16
16
  import {
17
17
  KIT_VERSION,
18
18
  pinnedCliSpec
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  detectWorkspaceParent,
3
3
  workspaceParentAdvisoryLines
4
- } from "./chunk-BIFWN6BJ.js";
4
+ } from "./chunk-OKQ3SAHK.js";
5
5
  import {
6
6
  createReadinessReport
7
7
  } from "./chunk-PNFF6OU3.js";
@@ -15,21 +15,21 @@ import {
15
15
  import {
16
16
  npxPinned,
17
17
  pathCliStatus
18
- } from "./chunk-TZA7MT4I.js";
18
+ } from "./chunk-I2SG2VPJ.js";
19
19
  import {
20
20
  assessEnvironment
21
21
  } from "./chunk-B3VR5YBQ.js";
22
- import "./chunk-52WYZFP5.js";
22
+ import "./chunk-2R4HYPQH.js";
23
23
  import "./chunk-PFEUZXVT.js";
24
- import "./chunk-O5FKTKOW.js";
25
- import "./chunk-LPZ2KXVE.js";
24
+ import "./chunk-DVCNJNCF.js";
25
+ import "./chunk-FX6BIH4C.js";
26
26
  import "./chunk-2KIOZMTV.js";
27
27
  import {
28
28
  MANIFEST_RELATIVE_PATH,
29
29
  loadAgentKitManifest,
30
30
  resolveProtectedGlobs
31
- } from "./chunk-HVH24VRL.js";
32
- import "./chunk-6LRY2CYU.js";
31
+ } from "./chunk-XJWCL4PO.js";
32
+ import "./chunk-5RWTDCJ7.js";
33
33
  import {
34
34
  KIT_VERSION
35
35
  } from "./chunk-7HDQEK6T.js";