retouche-dev 0.0.0-stage → 0.1.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/dist/cli.js ADDED
@@ -0,0 +1,601 @@
1
+ #!/usr/bin/env node
2
+ import { t as WATCHED_GROUPS } from "./class-groups-DKpPgmHx.js";
3
+ import { A as voiceIdSchema, i as FOLLOW_OUTCOMES } from "./clock-BJi08VJS.js";
4
+ import { d as FOLLOW_TOOL, l as reviewItems, p as mcpFollowPrompt, t as cardMarkdown, u as FOLLOW_PROMPT } from "./voice-markdown-BiOKT1SX.js";
5
+ import { a as writeFollow, g as failure, i as readFollower, l as readSessionFile, n as followedSession, o as writeFollower, r as readFollow, s as NO_FOLDER, t as EMPTY_FOLLOW, u as projectFolder } from "./follow-files-CfuW6Ah5.js";
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import { fileURLToPath } from "node:url";
8
+ import { z } from "zod";
9
+ import { parseArgs } from "node:util";
10
+ import { once } from "node:events";
11
+ import { createInterface } from "node:readline";
12
+ import { join } from "node:path";
13
+ import { setTimeout } from "node:timers/promises";
14
+ function sentOf({ detail, quote, title }) {
15
+ return {
16
+ detail,
17
+ quote,
18
+ title
19
+ };
20
+ }
21
+ function withCard(follow, id, card) {
22
+ return {
23
+ ...follow,
24
+ cards: {
25
+ ...follow.cards,
26
+ [id]: card
27
+ }
28
+ };
29
+ }
30
+ function isSettled(state, card) {
31
+ const { analysis, endedAt, passages } = state.session;
32
+ if (endedAt !== null) return true;
33
+ const last = Math.max(-1, ...card.passageIds.map((id) => passages.findIndex((item) => item.id === id)));
34
+ if (analysis.passageCount > last + 1) return true;
35
+ return analysis.at !== null && analysis.passageCount >= passages.length && state.now - analysis.at >= 5e3;
36
+ }
37
+ function undoDelivery({ follow, now, session }) {
38
+ const live = new Set(session.feedback.map(({ id }) => id));
39
+ const found = Object.entries(follow.cards).find(([id, card]) => !card.undoSent && (card.state === "working" || card.state === "applied") && (session.undoAsked.includes(id) || !live.has(id)));
40
+ if (found === void 0) return null;
41
+ const [id, card] = found;
42
+ const kind = session.undoAsked.includes(id) ? "undo" : "taken-back";
43
+ return {
44
+ event: {
45
+ before: card.sent,
46
+ id,
47
+ kind
48
+ },
49
+ follow: withCard(follow, id, {
50
+ ...card,
51
+ at: now,
52
+ state: "working",
53
+ undoSent: true
54
+ })
55
+ };
56
+ }
57
+ function revisedDelivery(state) {
58
+ const { follow, now, session } = state;
59
+ const card = session.feedback.find((item) => {
60
+ const known = follow.cards[item.id];
61
+ const sent = sentOf(item);
62
+ return known !== void 0 && !known.undoSent && known.state !== "reverted" && !session.undoAsked.includes(item.id) && (known.sent.detail !== sent.detail || known.sent.quote !== sent.quote || known.sent.title !== sent.title) && isSettled(state, item);
63
+ });
64
+ const known = card && follow.cards[card.id];
65
+ if (card === void 0 || known === void 0) return null;
66
+ return {
67
+ event: {
68
+ before: known.sent,
69
+ card,
70
+ kind: "revised"
71
+ },
72
+ follow: withCard(follow, card.id, {
73
+ ...known,
74
+ at: now,
75
+ note: null,
76
+ sent: sentOf(card),
77
+ state: "working"
78
+ })
79
+ };
80
+ }
81
+ function newDelivery(state) {
82
+ const { follow, now, session } = state;
83
+ const card = session.feedback.find((item) => follow.cards[item.id] === void 0 && !session.undoAsked.includes(item.id) && isSettled(state, item));
84
+ if (card === void 0) return null;
85
+ return {
86
+ event: {
87
+ card,
88
+ kind: "new"
89
+ },
90
+ follow: withCard(follow, card.id, {
91
+ at: now,
92
+ note: null,
93
+ sent: sentOf(card),
94
+ state: "working",
95
+ undoSent: false
96
+ })
97
+ };
98
+ }
99
+ function endedDelivery({ follow, now, session }) {
100
+ const { analysis, endedAt, passages } = session;
101
+ const isWritten = analysis.passageCount >= passages.length || analysis.error !== null;
102
+ if (endedAt === null || follow.closedAt !== null || !isWritten) return null;
103
+ return {
104
+ event: { kind: "ended" },
105
+ follow: {
106
+ ...follow,
107
+ closedAt: now
108
+ }
109
+ };
110
+ }
111
+ function nextDelivery(state) {
112
+ return undoDelivery(state) ?? revisedDelivery(state) ?? newDelivery(state) ?? endedDelivery(state);
113
+ }
114
+ function applyReport(state, report) {
115
+ const known = state.follow.cards[report.id];
116
+ const live = state.session.feedback.find(({ id }) => id === report.id);
117
+ const sent = known?.sent ?? (live && sentOf(live));
118
+ if (sent === void 0) return failure(`No feedback ${report.id} in this voice session.`, 404);
119
+ return {
120
+ ok: true,
121
+ value: withCard(state.follow, report.id, {
122
+ at: state.now,
123
+ note: report.note,
124
+ sent,
125
+ state: report.outcome,
126
+ undoSent: false
127
+ })
128
+ };
129
+ }
130
+ // src/server/voice/follow/follow-text.ts
131
+ function reportWith(reply, hint) {
132
+ const { id, note, outcome } = hint;
133
+ return reply.kind === "cli" ? `\`${reply.next} --${outcome} ${id} --note "${note}"\`` : `\`${FOLLOW_TOOL}\` and \`report: { id: "${id}", outcome: "${outcome}", note: "${note}" }\``;
134
+ }
135
+ function liveCard(session, id) {
136
+ const item = reviewItems(session).find((entry) => entry.id === id);
137
+ return item === void 0 ? "" : cardMarkdown(item);
138
+ }
139
+ function sentCard({ detail, quote, title }) {
140
+ return [
141
+ `### ${title}`,
142
+ `- Change: ${detail}`,
143
+ `- Said: “${quote}”`
144
+ ].join("\n");
145
+ }
146
+ function changeText(event, session, reply) {
147
+ const { id } = event.card;
148
+ const applied = reportWith(reply, {
149
+ id,
150
+ note: "<what you changed>",
151
+ outcome: "applied"
152
+ });
153
+ const skipped = `If it needs a decision from the developer, report it as skipped with the reason instead.`;
154
+ const card = liveCard(session, id);
155
+ if (event.kind === "new") return `## New feedback ${id}\n\n${card}\n\nMake this change, then report it with ${applied}. ${skipped}`;
156
+ return `## Revised feedback ${id}\n\nThe developer changed what they asked. You were given this version before:\n\n${sentCard(event.before)}\n\nIt now reads:\n\n${card}\n\nAdjust what you did for it, then report it with ${applied}. ${skipped}`;
157
+ }
158
+ const UNDO_LEADS = {
159
+ "taken-back": "The developer took this feedback back:",
160
+ undo: "The developer asked you to undo the change you made for this feedback:"
161
+ };
162
+ function eventText(event, session, reply) {
163
+ if (event.kind === "ended") return "## Session ended\n\nThe developer stopped the voice session. Stop following it.";
164
+ if (event.kind === "new" || event.kind === "revised") return changeText(event, session, reply);
165
+ const reverted = reportWith(reply, {
166
+ id: event.id,
167
+ note: "<what you undid>",
168
+ outcome: "reverted"
169
+ });
170
+ return `## Undo feedback ${event.id}\n\n${UNDO_LEADS[event.kind]}\n\n${sentCard(event.before)}\n\nUndo any change you made for it, then report it with ${reverted}.`;
171
+ }
172
+ function idleText(isRecording, reply) {
173
+ const again = reply.kind === "cli" ? `Run \`${reply.next}\` again` : `Call \`${FOLLOW_TOOL}\` again`;
174
+ return `${isRecording ? "No new feedback yet." : "No voice session is recording yet."} ${again} to keep waiting.`;
175
+ }
176
+ // src/server/voice/follow/follow-next.ts
177
+ const POLL_MS = 1e3;
178
+ const BEAT_MS = 1e4;
179
+ async function beat(folder, now) {
180
+ const follower = await readFollower(folder);
181
+ await writeFollower(folder, {
182
+ seenAt: now,
183
+ session: follower?.session ?? null
184
+ });
185
+ }
186
+ async function recordReport(folder, report, now) {
187
+ const followed = (await readFollower(folder))?.session ?? null;
188
+ const session = followed === null ? null : await readSessionFile(join(folder, followed));
189
+ if (session === null) return failure(`No feedback ${report.id} was handed out in this project.`, 404);
190
+ const outcome = applyReport({
191
+ follow: await readFollow(session.folder) ?? EMPTY_FOLLOW,
192
+ now,
193
+ session
194
+ }, report);
195
+ if (!outcome.ok) return outcome;
196
+ await writeFollow(session.folder, outcome.value);
197
+ return {
198
+ ok: true,
199
+ value: `Recorded ${report.id} as ${report.outcome}.`
200
+ };
201
+ }
202
+ async function deliver(call, folder) {
203
+ const session = await followedSession(folder);
204
+ if (session === null) return {
205
+ isRecording: false,
206
+ text: null
207
+ };
208
+ const stored = await readFollow(session.folder);
209
+ const reopened = stored === null || session.endedAt === null && stored.closedAt !== null ? {
210
+ ...stored ?? EMPTY_FOLLOW,
211
+ closedAt: null
212
+ } : stored;
213
+ const now = call.now();
214
+ const delivery = nextDelivery({
215
+ follow: reopened,
216
+ now,
217
+ session
218
+ });
219
+ const follow = delivery?.follow ?? reopened;
220
+ if (follow !== stored) await writeFollow(session.folder, follow);
221
+ if (delivery === null) return {
222
+ isRecording: true,
223
+ text: null
224
+ };
225
+ await writeFollower(folder, {
226
+ seenAt: now,
227
+ session: session.id
228
+ });
229
+ return {
230
+ isRecording: true,
231
+ text: eventText(delivery.event, session, call.reply)
232
+ };
233
+ }
234
+ async function waitForEvent(call, turn) {
235
+ const now = call.now();
236
+ const isDue = now - turn.heardAt >= BEAT_MS;
237
+ if (isDue) await beat(turn.folder, now);
238
+ const look = await deliver(call, turn.folder);
239
+ if (look.text !== null) return look.text;
240
+ if (call.now() >= turn.deadline) return idleText(look.isRecording, call.reply);
241
+ await setTimeout(POLL_MS);
242
+ return await waitForEvent(call, {
243
+ ...turn,
244
+ heardAt: isDue ? now : turn.heardAt
245
+ });
246
+ }
247
+ async function followNext(call) {
248
+ const folder = projectFolder(call.env, call.project);
249
+ if (folder === null) return failure(NO_FOLDER, 500);
250
+ const recorded = call.report === null ? null : await recordReport(folder, call.report, call.now());
251
+ if (recorded?.ok === false) return recorded;
252
+ const text = await waitForEvent(call, {
253
+ deadline: call.now() + call.waitMs,
254
+ folder,
255
+ heardAt: -1e4
256
+ });
257
+ return {
258
+ ok: true,
259
+ value: recorded === null ? text : `${recorded.value}\n\n${text}`
260
+ };
261
+ }
262
+ // src/server/voice/follow/follow-mcp.ts
263
+ const MCP_WAIT_MS = 45e3;
264
+ const SERVER_VERSION = "0.1.0";
265
+ const LATEST_VERSION = "2025-06-18";
266
+ const PROTOCOL_VERSIONS = /* @__PURE__ */ new Set([
267
+ LATEST_VERSION,
268
+ "2025-03-26",
269
+ "2024-11-05"
270
+ ]);
271
+ const RPC_ERRORS = {
272
+ internal: -32603,
273
+ invalidParams: -32602,
274
+ invalidRequest: -32600,
275
+ methodNotFound: -32601,
276
+ parse: -32700
277
+ };
278
+ const rpcIdSchema = z.union([z.string(), z.number()]);
279
+ const paramsSchema = z.json().optional();
280
+ const requestSchema = z.object({
281
+ id: rpcIdSchema.optional(),
282
+ jsonrpc: z.literal("2.0"),
283
+ method: z.string(),
284
+ params: paramsSchema
285
+ });
286
+ const looseIdSchema = z.object({ id: rpcIdSchema });
287
+ const initializeSchema = z.object({ protocolVersion: z.string().optional() }).optional();
288
+ const namedSchema = z.object({ name: z.string() });
289
+ const callSchema = namedSchema.extend({ arguments: paramsSchema });
290
+ const followArgumentsSchema = z.object({ report: z.object({
291
+ id: z.string().min(1),
292
+ note: z.string().optional(),
293
+ outcome: z.enum(FOLLOW_OUTCOMES)
294
+ }).optional() }).default({});
295
+ const TOOL_DESCRIPTION = "Waits for the next feedback card of the Retouche voice session being recorded and returns it: what the developer said, the element they pointed at, its call site and a screenshot. Report the card you just handled in the same call with `report`. Returns an idle note when nothing came in yet: call it again.";
296
+ const PROMPT_DESCRIPTION = "Follow the Retouche voice session and apply each feedback card while the developer talks.";
297
+ const FOLLOW_TOOL_ENTRY = {
298
+ description: TOOL_DESCRIPTION,
299
+ inputSchema: {
300
+ properties: { report: {
301
+ properties: {
302
+ id: {
303
+ description: "The card's id, like f-3.",
304
+ type: "string"
305
+ },
306
+ note: {
307
+ description: "One line on what you did.",
308
+ type: "string"
309
+ },
310
+ outcome: { enum: [...FOLLOW_OUTCOMES] }
311
+ },
312
+ required: ["id", "outcome"],
313
+ type: "object"
314
+ } },
315
+ type: "object"
316
+ },
317
+ name: FOLLOW_TOOL
318
+ };
319
+ function answer(result) {
320
+ return {
321
+ ok: true,
322
+ result
323
+ };
324
+ }
325
+ function rpcError(code, message) {
326
+ return {
327
+ code,
328
+ message,
329
+ ok: false
330
+ };
331
+ }
332
+ function toolText(text, isError) {
333
+ const content = [{
334
+ text,
335
+ type: "text"
336
+ }];
337
+ return answer(isError ? {
338
+ content,
339
+ isError
340
+ } : { content });
341
+ }
342
+ function method(schema, run) {
343
+ return async (params, options) => {
344
+ const parsed = schema.safeParse(params);
345
+ return parsed.success ? await run(parsed.data, options) : rpcError(RPC_ERRORS.invalidParams, z.prettifyError(parsed.error));
346
+ };
347
+ }
348
+ async function callTool(call, options) {
349
+ if (call.name !== "next_feedback") return rpcError(RPC_ERRORS.invalidParams, `Unknown tool: ${call.name}`);
350
+ const args = followArgumentsSchema.safeParse(call.arguments);
351
+ if (!args.success) return toolText(z.prettifyError(args.error), true);
352
+ const { report } = args.data;
353
+ const outcome = await followNext({
354
+ env: options.env,
355
+ now: Date.now,
356
+ project: options.project,
357
+ reply: { kind: "mcp" },
358
+ report: report ? {
359
+ ...report,
360
+ note: report.note ?? null
361
+ } : null,
362
+ waitMs: MCP_WAIT_MS
363
+ });
364
+ return outcome.ok ? toolText(outcome.value, false) : toolText(outcome.error, true);
365
+ }
366
+ const METHODS = {
367
+ initialize: method(initializeSchema, (params) => {
368
+ const asked = params?.protocolVersion ?? "";
369
+ return answer({
370
+ capabilities: {
371
+ prompts: {},
372
+ tools: {}
373
+ },
374
+ protocolVersion: PROTOCOL_VERSIONS.has(asked) ? asked : LATEST_VERSION,
375
+ serverInfo: {
376
+ name: "retouche",
377
+ version: SERVER_VERSION
378
+ }
379
+ });
380
+ }),
381
+ ping: method(paramsSchema, () => answer({})),
382
+ "prompts/get": method(namedSchema, ({ name }) => name === "follow" ? answer({
383
+ description: PROMPT_DESCRIPTION,
384
+ messages: [{
385
+ content: {
386
+ text: mcpFollowPrompt(),
387
+ type: "text"
388
+ },
389
+ role: "user"
390
+ }]
391
+ }) : rpcError(RPC_ERRORS.invalidParams, `Unknown prompt: ${name}`)),
392
+ "prompts/list": method(paramsSchema, () => answer({ prompts: [{
393
+ description: PROMPT_DESCRIPTION,
394
+ name: FOLLOW_PROMPT
395
+ }] })),
396
+ "tools/call": method(callSchema, callTool),
397
+ "tools/list": method(paramsSchema, () => answer({ tools: [FOLLOW_TOOL_ENTRY] }))
398
+ };
399
+ function isMethod(name) {
400
+ return Object.hasOwn(METHODS, name);
401
+ }
402
+ function send(output, id, reply) {
403
+ const body = reply.ok ? {
404
+ id,
405
+ jsonrpc: "2.0",
406
+ result: reply.result
407
+ } : {
408
+ error: {
409
+ code: reply.code,
410
+ message: reply.message
411
+ },
412
+ id,
413
+ jsonrpc: "2.0"
414
+ };
415
+ output.write(`${JSON.stringify(body)}\n`);
416
+ }
417
+ function readMessage(line) {
418
+ try {
419
+ const message = JSON.parse(line);
420
+ const request = requestSchema.safeParse(message);
421
+ if (request.success) return {
422
+ kind: "request",
423
+ request: request.data
424
+ };
425
+ const loose = looseIdSchema.safeParse(message);
426
+ return {
427
+ id: loose.success ? loose.data.id : null,
428
+ kind: "invalid"
429
+ };
430
+ } catch {
431
+ return { kind: "parse" };
432
+ }
433
+ }
434
+ async function run(request, options) {
435
+ if (!isMethod(request.method)) return rpcError(RPC_ERRORS.methodNotFound, `Method not found: ${request.method}`);
436
+ try {
437
+ return await METHODS[request.method](request.params, options);
438
+ } catch (error) {
439
+ const message = error instanceof Error ? error.message : String(error);
440
+ return rpcError(RPC_ERRORS.internal, message);
441
+ }
442
+ }
443
+ async function handleLine(line, options) {
444
+ if (line.trim() === "") return;
445
+ const incoming = readMessage(line);
446
+ if (incoming.kind === "parse") {
447
+ send(options.output, null, rpcError(RPC_ERRORS.parse, "Parse error"));
448
+ return;
449
+ }
450
+ if (incoming.kind === "invalid") {
451
+ send(options.output, incoming.id, rpcError(RPC_ERRORS.invalidRequest, "Invalid request"));
452
+ return;
453
+ }
454
+ const { id } = incoming.request;
455
+ if (id !== void 0) send(options.output, id, await run(incoming.request, options));
456
+ }
457
+ async function settle(handled, pending) {
458
+ try {
459
+ await handled;
460
+ } finally {
461
+ pending.delete(handled);
462
+ }
463
+ }
464
+ async function serveMcp(options) {
465
+ const lines = createInterface({
466
+ crlfDelay: 1e400,
467
+ input: options.input
468
+ });
469
+ const pending = /* @__PURE__ */ new Set();
470
+ lines.on("line", (line) => {
471
+ const handled = handleLine(line, options);
472
+ pending.add(handled);
473
+ settle(handled, pending);
474
+ });
475
+ await once(lines, "close");
476
+ await Promise.all(pending);
477
+ }
478
+ // src/server/voice/follow/follow-cli.ts
479
+ const FOLLOW_USAGE = `Usage: retouche next --project <id> [--applied|--skipped|--reverted <card>] [--note <text>] [--wait <seconds>]
480
+
481
+ Wait for the next feedback card of the voice session being recorded
482
+ and print it. Report the card you just handled in the same call.
483
+
484
+ Usage: retouche mcp --project <id>
485
+
486
+ Serve the same feed to a coding agent over MCP (stdio).\n`;
487
+ const nextArgsSchema = z.object({
488
+ applied: voiceIdSchema.optional(),
489
+ note: z.string().trim().min(1).optional(),
490
+ project: voiceIdSchema,
491
+ reverted: voiceIdSchema.optional(),
492
+ skipped: voiceIdSchema.optional(),
493
+ wait: z.coerce.number().int().min(0).max(600).default(50)
494
+ });
495
+ function parsed(args, schema) {
496
+ try {
497
+ const { values } = parseArgs({
498
+ args,
499
+ options: {
500
+ applied: { type: "string" },
501
+ note: { type: "string" },
502
+ project: { type: "string" },
503
+ reverted: { type: "string" },
504
+ skipped: { type: "string" },
505
+ wait: { type: "string" }
506
+ }
507
+ });
508
+ const result = schema.safeParse(values);
509
+ return result.success ? result.data : null;
510
+ } catch {
511
+ return null;
512
+ }
513
+ }
514
+ function reportsOf(args) {
515
+ return FOLLOW_OUTCOMES.flatMap((outcome) => {
516
+ const id = args[outcome];
517
+ return id === void 0 ? [] : [{
518
+ id,
519
+ note: args.note ?? null,
520
+ outcome
521
+ }];
522
+ });
523
+ }
524
+ const BAD_OPTIONS = "Retouche needs --project <id>, and reads only the options below.";
525
+ function fail(message) {
526
+ process.stderr.write(`${message}\n\n${FOLLOW_USAGE}`);
527
+ return 1;
528
+ }
529
+ async function runNext(args, script) {
530
+ const options = parsed(args, nextArgsSchema);
531
+ if (options === null) return fail(BAD_OPTIONS);
532
+ const reports = reportsOf(options);
533
+ if (reports.length > 1) return fail("Report one card at a time.");
534
+ const outcome = await followNext({
535
+ env: process.env,
536
+ now: Date.now,
537
+ project: options.project,
538
+ reply: {
539
+ kind: "cli",
540
+ next: `node ${JSON.stringify(script)} next --project ${options.project}`
541
+ },
542
+ report: reports[0] ?? null,
543
+ waitMs: options.wait * 1e3
544
+ });
545
+ if (!outcome.ok) return fail(outcome.error);
546
+ process.stdout.write(`${outcome.value}\n`);
547
+ return 0;
548
+ }
549
+ async function runMcp(args) {
550
+ const options = parsed(args, z.object({ project: voiceIdSchema }));
551
+ if (options === null) return fail(BAD_OPTIONS);
552
+ await serveMcp({
553
+ env: process.env,
554
+ input: process.stdin,
555
+ output: process.stdout,
556
+ project: options.project
557
+ });
558
+ return 0;
559
+ }
560
+ // src/cli.ts
561
+ const USAGE = `Usage: retouche prompt [tarball-url | --local]
562
+
563
+ Print the setup prompt to hand to your coding agent.
564
+ The prompt installs the package from npm. A tarball URL installs
565
+ that tarball instead, and --local the one \`bun run pack\` builds
566
+ in the retouche repo.\n`;
567
+ const tarballUrl = z.url({ protocol: /^https?$/ });
568
+ const packageManifest = z.object({ name: z.string() });
569
+ function packageName() {
570
+ const manifest = readFileSync(new URL("../package.json", import.meta.url), "utf-8");
571
+ return packageManifest.parse(JSON.parse(manifest)).name;
572
+ }
573
+ function localTarball() {
574
+ const tarball = fileURLToPath(new URL("../retouche.tgz", import.meta.url));
575
+ if (existsSync(tarball)) return tarball;
576
+ process.stderr.write(`No tarball at ${tarball}\n\n${USAGE}`);
577
+ return null;
578
+ }
579
+ function installSource(argument) {
580
+ if (argument === void 0) return `${packageName()}@latest`;
581
+ if (argument === "--local") return localTarball();
582
+ const url = tarballUrl.safeParse(argument);
583
+ if (url.success) return url.data;
584
+ process.stderr.write(`Not an http(s) URL: ${argument}\n\n${USAGE}`);
585
+ return null;
586
+ }
587
+ function printPrompt(source) {
588
+ const prompt = readFileSync(new URL("../PROMPT.md", import.meta.url), "utf-8");
589
+ process.stdout.write(prompt.replaceAll("{{RETOUCHE_PACKAGE}}", source).replaceAll("{{PROPERTIES}}", WATCHED_GROUPS.map((group) => `\`${group}\``).join(", ")));
590
+ }
591
+ const [command = "", ...args] = process.argv.slice(2);
592
+ if (command === "prompt") {
593
+ const source = installSource(args[0]);
594
+ if (source === null) process.exitCode = 1;
595
+ else printPrompt(source);
596
+ } else if (command === "next") process.exitCode = await runNext(args, process.argv[1] ?? "retouche");
597
+ else if (command === "mcp") process.exitCode = await runMcp(args);
598
+ else {
599
+ process.stdout.write(`${USAGE}\n${FOLLOW_USAGE}`);
600
+ process.exitCode = command === "" ? 0 : 1;
601
+ }