@rucher/cli 0.2.0-beta.7 → 0.2.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/dist/cli.mjs +104 -238
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import { defineCommand, runMain } from "citty";
|
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
5
|
import tab from "@bomb.sh/tab/citty";
|
|
6
|
-
import {
|
|
7
|
-
import { tmpdir } from "node:os";
|
|
6
|
+
import { CarnetError, LEGEND, NOTES_HEADER, NOTE_KINDS, SIMILAR_PREFIX, SUBAGENT_RULES, WORKSPACE_FILE, addWorkspaceRepo, ambiguousWorkspaceContext, appendPromptFile, archiveWorkspaceSessions, claudeCode, createWorkspace, definitionInstructions, deleteWorkspaceNotes, dropWorkspace, formatClock, handleSessionEnd, handleSessionStart, handleToolUse, handleUserPromptSubmit, hostById, isWorkspaceName, listWorkspaces, loadWorkspace, memoryHalfLife, moveSession, openCarnet, openResolvedCarnet, openWorkspaceCarnet, removeWorkspaceRepo, renderRunDirectory, renderSections, repoNameFor, repoPathFor, requireWorkspace, resolveWorkspace, shortId, workspaceExists, workspaceLabel, workspaceRepoNames, workspaceSessionCounts } from "@rucher/carnet";
|
|
8
7
|
import { styleText } from "node:util";
|
|
9
8
|
import { spawnSync } from "node:child_process";
|
|
10
9
|
import { randomUUID } from "node:crypto";
|
|
@@ -79,9 +78,6 @@ function suggestRepoNames(context, complete) {
|
|
|
79
78
|
function suggestNoteKinds(complete) {
|
|
80
79
|
for (const kind of NOTE_KINDS) complete(kind, "");
|
|
81
80
|
}
|
|
82
|
-
function suggestAgentKinds(complete) {
|
|
83
|
-
for (const kind of AGENT_KINDS) complete(kind, "");
|
|
84
|
-
}
|
|
85
81
|
function suggestNotes(context, complete) {
|
|
86
82
|
quietly(() => {
|
|
87
83
|
const carnet = openCarnet(inWorkspace(context));
|
|
@@ -114,18 +110,15 @@ const repos = (complete) => suggestRepos(processContext(), complete);
|
|
|
114
110
|
const directories = (complete) => suggestDirectories(processContext(), complete);
|
|
115
111
|
const repoNames = (complete) => suggestRepoNames(processContext(), complete);
|
|
116
112
|
const noteKinds = (complete) => suggestNoteKinds(complete);
|
|
117
|
-
const agentKinds = (complete) => suggestAgentKinds(complete);
|
|
118
113
|
const notes = (complete) => suggestNotes(processContext(), complete);
|
|
119
114
|
const workspace = { ws: workspaces };
|
|
120
115
|
const completionConfig = { subCommands: {
|
|
121
116
|
status: { options: {
|
|
122
117
|
session: sessions,
|
|
123
|
-
kind: agentKinds,
|
|
124
118
|
...workspace
|
|
125
119
|
} },
|
|
126
120
|
log: { options: {
|
|
127
121
|
session: sessions,
|
|
128
|
-
kind: agentKinds,
|
|
129
122
|
...workspace
|
|
130
123
|
} },
|
|
131
124
|
new: { options: workspace },
|
|
@@ -246,14 +239,25 @@ async function setupCompletion(main) {
|
|
|
246
239
|
};
|
|
247
240
|
}
|
|
248
241
|
// package.json
|
|
249
|
-
var version = "0.2.0
|
|
242
|
+
var version = "0.2.0";
|
|
250
243
|
// src/commands/hook.ts
|
|
251
244
|
const host = claudeCode;
|
|
252
|
-
function runHook(io, run) {
|
|
245
|
+
function runHook(io, run, hookEventName) {
|
|
253
246
|
try {
|
|
254
247
|
run();
|
|
255
248
|
} catch (error) {
|
|
256
249
|
if (error instanceof CarnetError && error.code === "NO_WORKSPACE") return 0;
|
|
250
|
+
if (error instanceof CarnetError && error.code === "WORKSPACE_AMBIGUOUS") {
|
|
251
|
+
if (hookEventName) {
|
|
252
|
+
io.stderr(`rucher: ${error.message}\n`);
|
|
253
|
+
const additionalContext = ambiguousWorkspaceContext(error.message);
|
|
254
|
+
io.stdout(`${JSON.stringify({ hookSpecificOutput: {
|
|
255
|
+
hookEventName,
|
|
256
|
+
additionalContext
|
|
257
|
+
} })}\n`);
|
|
258
|
+
}
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
257
261
|
io.stderr(`rucher hook: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
258
262
|
}
|
|
259
263
|
return 0;
|
|
@@ -266,7 +270,7 @@ function withCarnet$1(payload, io, use) {
|
|
|
266
270
|
});
|
|
267
271
|
try {
|
|
268
272
|
const known = payload.session_id ? carnet.sessions.get(payload.session_id) : void 0;
|
|
269
|
-
if (!carnet.workspace && !known) return;
|
|
273
|
+
if (!carnet.workspace && !io.env.RUCHER_SESSION_ID && !known) return;
|
|
270
274
|
use(carnet);
|
|
271
275
|
} finally {
|
|
272
276
|
carnet.close();
|
|
@@ -297,7 +301,7 @@ function sessionStart(stdinText, io) {
|
|
|
297
301
|
io.stdout(`${JSON.stringify({ hookSpecificOutput })}\n`);
|
|
298
302
|
}
|
|
299
303
|
});
|
|
300
|
-
});
|
|
304
|
+
}, "SessionStart");
|
|
301
305
|
}
|
|
302
306
|
function subagentStart(stdinText, io) {
|
|
303
307
|
return runHook(io, () => {
|
|
@@ -327,12 +331,12 @@ function userPromptSubmit(stdinText, io) {
|
|
|
327
331
|
withCarnet$1(payload, io, (carnet) => {
|
|
328
332
|
handleUserPromptSubmit(carnet, host, payload);
|
|
329
333
|
});
|
|
330
|
-
});
|
|
334
|
+
}, "UserPromptSubmit");
|
|
331
335
|
}
|
|
332
336
|
function postToolUse(stdinText, io) {
|
|
333
337
|
return runHook(io, () => {
|
|
334
338
|
const payload = host.parseToolPayload(stdinText);
|
|
335
|
-
if (payload.agent_id) return;
|
|
339
|
+
if (payload.agent_id || !payload.path) return;
|
|
336
340
|
withCarnet$1(payload, io, (carnet) => {
|
|
337
341
|
const additionalContext = handleToolUse(carnet, payload, {
|
|
338
342
|
RUCHER_MEMORY_MAX_CHARACTERS: io.env.RUCHER_MEMORY_MAX_CHARACTERS,
|
|
@@ -355,36 +359,6 @@ function sessionEnd(stdinText, io) {
|
|
|
355
359
|
});
|
|
356
360
|
});
|
|
357
361
|
}
|
|
358
|
-
function scratchRoot(io) {
|
|
359
|
-
const uid = process.getuid?.() ?? 0;
|
|
360
|
-
return join(io.env.CLAUDE_CODE_TMPDIR ?? tmpdir(), `claude-${uid}`);
|
|
361
|
-
}
|
|
362
|
-
function preToolUse(stdinText, io) {
|
|
363
|
-
return runHook(io, () => {
|
|
364
|
-
const payload = host.parseToolPayload(stdinText);
|
|
365
|
-
const guarded = Boolean(payload.agent_id) && GUARDED_TOOLS.has(payload.tool_name ?? "");
|
|
366
|
-
if (!guarded && (payload.agent_id || payload.tool_name !== WAITING_TOOL)) return;
|
|
367
|
-
withCarnet$1(payload, io, (carnet) => {
|
|
368
|
-
if (!guarded) return handleToolStart(carnet, payload);
|
|
369
|
-
const reason = guardSubagentCall(carnet, payload, scratchRoot(io));
|
|
370
|
-
if (!reason) return;
|
|
371
|
-
const hookSpecificOutput = {
|
|
372
|
-
hookEventName: "PreToolUse",
|
|
373
|
-
permissionDecision: "deny",
|
|
374
|
-
permissionDecisionReason: reason
|
|
375
|
-
};
|
|
376
|
-
io.stdout(`${JSON.stringify({ hookSpecificOutput })}\n`);
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
function stopHook(stdinText, io) {
|
|
381
|
-
return runHook(io, () => {
|
|
382
|
-
const payload = host.parseStopPayload(stdinText);
|
|
383
|
-
withCarnet$1(payload, io, (carnet) => {
|
|
384
|
-
handleStop(carnet, payload);
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
362
|
// src/color.ts
|
|
389
363
|
function paint(io) {
|
|
390
364
|
const style = (name) => (text) => io.color ? styleText(name, text, { validateStream: false }) : text;
|
|
@@ -405,37 +379,29 @@ var CliError = class extends Error {
|
|
|
405
379
|
this.name = "CliError";
|
|
406
380
|
}
|
|
407
381
|
};
|
|
408
|
-
function withWorkspace(command, workspace) {
|
|
409
|
-
return workspace ? `${command} --ws ${workspace}` : command;
|
|
410
|
-
}
|
|
411
382
|
function findSession(carnet, reference) {
|
|
412
383
|
try {
|
|
413
384
|
return carnet.sessions.find(reference);
|
|
414
385
|
} catch (error) {
|
|
415
386
|
if (!(error instanceof CarnetError) || error.code !== "SESSION_NOT_FOUND") throw error;
|
|
416
387
|
const known = carnet.sessions.list().map((session) => session.name).filter(Boolean);
|
|
417
|
-
throw new CliError(error.message, known.length ? `known sessions: ${known.join(", ")}` :
|
|
388
|
+
throw new CliError(error.message, known.length ? `known sessions: ${known.join(", ")}` : "pass a session name, id or id prefix, see rucher sessions --all");
|
|
418
389
|
}
|
|
419
390
|
}
|
|
420
391
|
function resolveSession(carnet, reference) {
|
|
421
392
|
if (reference) return findSession(carnet, reference);
|
|
422
393
|
const session = carnet.sessions.default();
|
|
423
|
-
if (!session) throw new CliError("No session in this workspace yet",
|
|
394
|
+
if (!session) throw new CliError("No session in this workspace yet", "start a Claude Code session inside the workspace");
|
|
424
395
|
return session;
|
|
425
396
|
}
|
|
426
397
|
// src/commands/log.ts
|
|
427
|
-
function
|
|
428
|
-
return event.agent ? kinds.get(event.agent) : void 0;
|
|
429
|
-
}
|
|
430
|
-
function formatEvents(events, io, kinds = /* @__PURE__ */ new Map()) {
|
|
398
|
+
function formatEvents(events, io) {
|
|
431
399
|
const colors = paint(io);
|
|
432
400
|
if (events.length === 0) return colors.dim("no events yet");
|
|
433
401
|
return events.map((event) => {
|
|
434
|
-
const kind = kindOf(event, kinds);
|
|
435
402
|
return [
|
|
436
403
|
colors.dim(formatClock(new Date(event.at))),
|
|
437
404
|
colors.bold(event.type.padEnd(9)),
|
|
438
|
-
kind ? KIND_ABBREVIATIONS[kind] : "",
|
|
439
405
|
event.agent ?? "",
|
|
440
406
|
event.link ?? event.note ?? "",
|
|
441
407
|
event.commit ? colors.cyan(event.commit.slice(0, 7)) : ""
|
|
@@ -447,10 +413,8 @@ function formatDay(date) {
|
|
|
447
413
|
const day = String(date.getDate()).padStart(2, "0");
|
|
448
414
|
return `${date.getFullYear()}-${month}-${day}`;
|
|
449
415
|
}
|
|
450
|
-
function markdownEvent(event
|
|
416
|
+
function markdownEvent(event) {
|
|
451
417
|
const parts = [`${formatClock(new Date(event.at))} **${event.type}**`];
|
|
452
|
-
const kind = kindOf(event, kinds);
|
|
453
|
-
if (kind) parts.push(kind);
|
|
454
418
|
if (event.agent) parts.push(`\`${event.agent}\``);
|
|
455
419
|
const detail = [
|
|
456
420
|
event.note,
|
|
@@ -459,7 +423,7 @@ function markdownEvent(event, kinds) {
|
|
|
459
423
|
].filter(Boolean).join(" · ");
|
|
460
424
|
return `- ${parts.join(" ")}${detail ? `: ${detail}` : ""}`;
|
|
461
425
|
}
|
|
462
|
-
function formatEventsMarkdown(events, title
|
|
426
|
+
function formatEventsMarkdown(events, title) {
|
|
463
427
|
const lines = [`# Journal: ${title}`];
|
|
464
428
|
if (events.length === 0) return `${lines[0]}\n\nNo events yet.`;
|
|
465
429
|
let day = "";
|
|
@@ -469,7 +433,7 @@ function formatEventsMarkdown(events, title, kinds = /* @__PURE__ */ new Map())
|
|
|
469
433
|
day = current;
|
|
470
434
|
lines.push("", `## ${day}`, "");
|
|
471
435
|
}
|
|
472
|
-
lines.push(markdownEvent(event
|
|
436
|
+
lines.push(markdownEvent(event));
|
|
473
437
|
}
|
|
474
438
|
return lines.join("\n");
|
|
475
439
|
}
|
|
@@ -478,9 +442,43 @@ function sessionTitle(carnet, session) {
|
|
|
478
442
|
}
|
|
479
443
|
function logOnce(carnet, io, options) {
|
|
480
444
|
const session = resolveSession(carnet, options.session);
|
|
481
|
-
const events = carnet.events.read(session.id, options.count, options.agents
|
|
482
|
-
|
|
483
|
-
|
|
445
|
+
const events = carnet.events.read(session.id, options.count, options.agents);
|
|
446
|
+
io.stdout(`${options.md ? formatEventsMarkdown(events, sessionTitle(carnet, session)) : formatEvents(events, io)}\n`);
|
|
447
|
+
}
|
|
448
|
+
// src/workspace-option.ts
|
|
449
|
+
const workspaceArgument = { ws: {
|
|
450
|
+
type: "string",
|
|
451
|
+
description: "Workspace name (default: from RUCHER_WS, the run directory or the repo you are in)"
|
|
452
|
+
} };
|
|
453
|
+
function forwardWorkspace({ args }) {
|
|
454
|
+
if (args.ws) process.env.RUCHER_WS = args.ws;
|
|
455
|
+
}
|
|
456
|
+
function announceWorkspace(io, resolution) {
|
|
457
|
+
if (!resolution.workspace) return;
|
|
458
|
+
if (resolution.origin === "run-directory") io.stderr(`workspace ${resolution.workspace.name} (from its run directory)\n`);
|
|
459
|
+
else if (resolution.origin === "repo" && resolution.repo) io.stderr(`workspace ${resolution.workspace.name} (from ${resolution.repo.name})\n`);
|
|
460
|
+
}
|
|
461
|
+
function warnNoWorkspace(carnet, io) {
|
|
462
|
+
if (!carnet.workspace) io.stderr("no workspace here: pass --ws\n");
|
|
463
|
+
}
|
|
464
|
+
function openCliCarnet(io, workspace) {
|
|
465
|
+
const { carnet, resolution } = openResolvedCarnet({
|
|
466
|
+
cwd: io.cwd,
|
|
467
|
+
env: io.env,
|
|
468
|
+
workspace
|
|
469
|
+
});
|
|
470
|
+
announceWorkspace(io, resolution);
|
|
471
|
+
return carnet;
|
|
472
|
+
}
|
|
473
|
+
function currentWorkspace(io, workspace) {
|
|
474
|
+
const resolution = resolveWorkspace({
|
|
475
|
+
cwd: io.cwd,
|
|
476
|
+
env: io.env,
|
|
477
|
+
workspace
|
|
478
|
+
});
|
|
479
|
+
const found = requireWorkspace(resolution.workspace);
|
|
480
|
+
announceWorkspace(io, resolution);
|
|
481
|
+
return found;
|
|
484
482
|
}
|
|
485
483
|
// src/commands/notes.ts
|
|
486
484
|
const KIND_TITLES = {
|
|
@@ -545,8 +543,9 @@ function notesList(carnet, io, options = {}) {
|
|
|
545
543
|
return;
|
|
546
544
|
}
|
|
547
545
|
const colors = paint(io);
|
|
546
|
+
warnNoWorkspace(carnet, io);
|
|
548
547
|
if (notes.length === 0) {
|
|
549
|
-
io.stdout(`${colors.dim(options.stale ? "no note to review" : "no notes")}\n`);
|
|
548
|
+
if (carnet.workspace) io.stdout(`${colors.dim(options.stale ? "no note to review" : "no notes")}\n`);
|
|
550
549
|
return;
|
|
551
550
|
}
|
|
552
551
|
const blocks = grouped(notes).map(([kind, kindNotes]) => `${colors.bold(KIND_TITLES[kind])}\n${kindNotes.map((note) => noteLine(io, note)).join("\n")}`);
|
|
@@ -627,30 +626,29 @@ function launchEnv(workspace, session, promptVersion, kind) {
|
|
|
627
626
|
};
|
|
628
627
|
}
|
|
629
628
|
function planNew(carnet, io, options) {
|
|
630
|
-
if (options.kind === "active" && !options.name) throw new CliError("An active session needs a name",
|
|
631
|
-
const workspace = carnet.requireWorkspace();
|
|
629
|
+
if (options.kind === "active" && !options.name) throw new CliError("An active session needs a name", "rucher new <name>");
|
|
632
630
|
const session = carnet.sessions.create({
|
|
633
631
|
id: randomUUID(),
|
|
634
632
|
kind: options.kind,
|
|
635
633
|
name: options.name,
|
|
636
|
-
cwd: workspace.
|
|
637
|
-
repo: repoNameFor(workspace, io.cwd)
|
|
634
|
+
cwd: carnet.workspace?.runDirectory ?? io.cwd,
|
|
635
|
+
repo: repoNameFor(carnet.workspace, io.cwd)
|
|
638
636
|
});
|
|
639
637
|
const host = hostById(session.host);
|
|
640
|
-
renderRunDirectory(workspace, {
|
|
638
|
+
if (carnet.workspace) renderRunDirectory(carnet.workspace, {
|
|
641
639
|
env: io.env,
|
|
642
640
|
host: session.host
|
|
643
641
|
});
|
|
644
|
-
const prompt = appendPromptFile(workspace, session, io.env);
|
|
642
|
+
const prompt = appendPromptFile(carnet.workspace, session, io.env);
|
|
645
643
|
return {
|
|
646
644
|
...host.launchCommand(session.id, {
|
|
647
645
|
name: session.name,
|
|
648
646
|
appendPromptFile: prompt.path,
|
|
649
|
-
directories: repoDirectories(workspace),
|
|
647
|
+
directories: repoDirectories(carnet.workspace),
|
|
650
648
|
passthrough: options.passthrough
|
|
651
649
|
}),
|
|
652
|
-
cwd: workspace.
|
|
653
|
-
env: launchEnv(workspace, session, prompt.version),
|
|
650
|
+
cwd: carnet.workspace?.runDirectory ?? io.cwd,
|
|
651
|
+
env: launchEnv(carnet.workspace, session, prompt.version),
|
|
654
652
|
sessionId: session.id
|
|
655
653
|
};
|
|
656
654
|
}
|
|
@@ -658,7 +656,7 @@ function repoDirectories(workspace) {
|
|
|
658
656
|
return (workspace?.repos ?? []).map((repo) => repo.path).filter((path) => existsSync(path));
|
|
659
657
|
}
|
|
660
658
|
function sessionWorkspace(carnet, session, env) {
|
|
661
|
-
if (!isWorkspaceName(session.workspace)) return null;
|
|
659
|
+
if (!session.workspace || !isWorkspaceName(session.workspace)) return null;
|
|
662
660
|
return carnet.workspace?.name === session.workspace ? carnet.workspace : loadWorkspace(session.workspace, env);
|
|
663
661
|
}
|
|
664
662
|
function prepareSession(carnet, session, env) {
|
|
@@ -701,12 +699,12 @@ function planResume(carnet, io, reference, passthrough = []) {
|
|
|
701
699
|
};
|
|
702
700
|
}
|
|
703
701
|
function planFork(carnet, io, reference, options = {}) {
|
|
704
|
-
if (options.active && !options.name) throw new CliError("An active fork needs a name",
|
|
702
|
+
if (options.active && !options.name) throw new CliError("An active fork needs a name", "rucher fork <session> <name> --active");
|
|
705
703
|
if (options.name && carnet.sessions.byName(options.name)) throw new CliError(`A session named "${options.name}" already exists`);
|
|
706
704
|
const parent = findSession(carnet, reference);
|
|
707
705
|
if (!hostById(parent.host).hasConversation(parent, io.env)) {
|
|
708
706
|
const label = sessionLabel$1(parent);
|
|
709
|
-
throw new CliError(`Session ${label} has no conversation yet, nothing to fork`,
|
|
707
|
+
throw new CliError(`Session ${label} has no conversation yet, nothing to fork`, `rucher resume ${label}`);
|
|
710
708
|
}
|
|
711
709
|
const workspace = prepareSession(carnet, parent, io.env);
|
|
712
710
|
const cwd = sessionDirectory(parent);
|
|
@@ -767,27 +765,25 @@ function lastUse(at, now) {
|
|
|
767
765
|
return date.toDateString() === now.toDateString() ? formatClock(date) : date.toISOString().slice(0, 10);
|
|
768
766
|
}
|
|
769
767
|
function pickerLines(sessions, now = /* @__PURE__ */ new Date()) {
|
|
770
|
-
|
|
768
|
+
const rows = sessions.map((session, index) => [
|
|
771
769
|
String(index + 1),
|
|
772
770
|
session.name ?? shortId(session.id),
|
|
773
771
|
session.kind,
|
|
774
772
|
session.status,
|
|
775
773
|
lastUse(session.lastActiveAt, now),
|
|
776
774
|
shortId(session.id)
|
|
777
|
-
])
|
|
778
|
-
}
|
|
779
|
-
function table(rows) {
|
|
775
|
+
]);
|
|
780
776
|
const widths = (rows[0] ?? []).map((_, column) => Math.max(...rows.map((row) => (row[column] ?? "").length)));
|
|
781
777
|
return rows.map((row) => row.map((cell, column) => column < row.length - 1 ? cell.padEnd(widths[column] ?? 0) : cell).join(" "));
|
|
782
778
|
}
|
|
783
779
|
function hasFzf() {
|
|
784
780
|
return spawnSync("fzf", ["--version"], { stdio: "ignore" }).status === 0;
|
|
785
781
|
}
|
|
786
|
-
function pickWithFzf(
|
|
782
|
+
function pickWithFzf(sessions, lines) {
|
|
787
783
|
const result = spawnSync("fzf", [
|
|
788
784
|
"--with-nth=2..",
|
|
789
785
|
"--no-sort",
|
|
790
|
-
|
|
786
|
+
"--prompt=session> "
|
|
791
787
|
], {
|
|
792
788
|
input: lines.join("\n"),
|
|
793
789
|
stdio: [
|
|
@@ -797,55 +793,30 @@ function pickWithFzf(items, lines, label) {
|
|
|
797
793
|
],
|
|
798
794
|
encoding: "utf8"
|
|
799
795
|
});
|
|
800
|
-
return
|
|
796
|
+
return sessions[Number(result.stdout?.trim().split(/\s+/)[0]) - 1];
|
|
801
797
|
}
|
|
802
|
-
async function pickFromList(
|
|
798
|
+
async function pickFromList(sessions, lines) {
|
|
803
799
|
process.stderr.write(`${lines.join("\n")}\n`);
|
|
804
800
|
const prompt = createInterface({
|
|
805
801
|
input: process.stdin,
|
|
806
802
|
output: process.stderr
|
|
807
803
|
});
|
|
808
804
|
try {
|
|
809
|
-
const answer = await prompt.question(
|
|
810
|
-
return
|
|
805
|
+
const answer = await prompt.question("session number> ");
|
|
806
|
+
return sessions[Number(answer.trim()) - 1];
|
|
811
807
|
} finally {
|
|
812
808
|
prompt.close();
|
|
813
809
|
}
|
|
814
810
|
}
|
|
815
|
-
function pick(items, lines, label) {
|
|
816
|
-
return hasFzf() ? Promise.resolve(pickWithFzf(items, lines, label)) : pickFromList(items, lines, label);
|
|
817
|
-
}
|
|
818
811
|
async function pickSession(carnet) {
|
|
819
812
|
const sessions = pickerSessions(carnet);
|
|
820
|
-
|
|
821
|
-
if (
|
|
822
|
-
|
|
823
|
-
const picked =
|
|
813
|
+
if (sessions.length === 0) throw new CliError("No session to resume in this workspace", "rucher new <name>");
|
|
814
|
+
if (!process.stdin.isTTY) throw new CliError("No session given", "rucher resume <name, id or id prefix>");
|
|
815
|
+
const lines = pickerLines(sessions);
|
|
816
|
+
const picked = hasFzf() ? pickWithFzf(sessions, lines) : await pickFromList(sessions, lines);
|
|
824
817
|
if (!picked) throw new CliError("No session picked");
|
|
825
818
|
return picked;
|
|
826
819
|
}
|
|
827
|
-
function workspaceChoices(env) {
|
|
828
|
-
const carnet = openWorkspaceCarnet(null, { env });
|
|
829
|
-
try {
|
|
830
|
-
const lastActive = workspaceLastActive(carnet.db);
|
|
831
|
-
return listWorkspaces(env).map((workspace) => ({
|
|
832
|
-
name: workspace.name,
|
|
833
|
-
lastActiveAt: lastActive.get(workspace.name)
|
|
834
|
-
})).sort((a, b) => (b.lastActiveAt ?? "").localeCompare(a.lastActiveAt ?? "") || a.name.localeCompare(b.name));
|
|
835
|
-
} finally {
|
|
836
|
-
carnet.close();
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
function workspaceLines(choices, now = /* @__PURE__ */ new Date()) {
|
|
840
|
-
return table(choices.map((choice, index) => [
|
|
841
|
-
String(index + 1),
|
|
842
|
-
choice.name,
|
|
843
|
-
choice.lastActiveAt ? lastUse(choice.lastActiveAt, now) : "never"
|
|
844
|
-
]));
|
|
845
|
-
}
|
|
846
|
-
async function pickWorkspace(choices) {
|
|
847
|
-
return (await pick(choices, workspaceLines(choices), "workspace"))?.name;
|
|
848
|
-
}
|
|
849
820
|
// src/commands/serve.ts
|
|
850
821
|
function serve(io) {
|
|
851
822
|
serveCarnet({
|
|
@@ -877,9 +848,10 @@ function sessionsOnce(carnet, io, options = {}) {
|
|
|
877
848
|
includeTemp: options.all,
|
|
878
849
|
includeArchived: options.all
|
|
879
850
|
});
|
|
851
|
+
warnNoWorkspace(carnet, io);
|
|
880
852
|
if (sessions.length === 0) {
|
|
881
853
|
const hint = options.all ? "" : " (temp and archived ones are hidden, use --all)";
|
|
882
|
-
io.stdout(`${colors.dim(`no active session yet${hint}`)}\n`);
|
|
854
|
+
if (carnet.workspace) io.stdout(`${colors.dim(`no active session yet${hint}`)}\n`);
|
|
883
855
|
return;
|
|
884
856
|
}
|
|
885
857
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -1109,7 +1081,7 @@ function pressKey(state, key, noteCount) {
|
|
|
1109
1081
|
}
|
|
1110
1082
|
// src/commands/status.ts
|
|
1111
1083
|
const SECTION_HEADERS = /* @__PURE__ */ new Set([
|
|
1112
|
-
|
|
1084
|
+
"On the table",
|
|
1113
1085
|
"Waiting on you",
|
|
1114
1086
|
"Running",
|
|
1115
1087
|
NOTES_HEADER
|
|
@@ -1123,8 +1095,7 @@ function colorizeLine(line, io) {
|
|
|
1123
1095
|
if (line === LEGEND) return colors.dim(line);
|
|
1124
1096
|
const cut = truncate(line, io.columns);
|
|
1125
1097
|
if (SECTION_HEADERS.has(line)) return colors.bold(cut);
|
|
1126
|
-
if (line.startsWith("
|
|
1127
|
-
if (line.startsWith(" ⚙️") || line.startsWith(" ⏸")) return colors.yellow(cut);
|
|
1098
|
+
if (line.startsWith(" ⚙️")) return colors.yellow(cut);
|
|
1128
1099
|
if (line === " nothing") return colors.dim(cut);
|
|
1129
1100
|
if (cut.startsWith(`${NOTES_HEADER} `)) return `${colors.bold(NOTES_HEADER)}${cut.slice(NOTES_HEADER.length)}`;
|
|
1130
1101
|
const marker = /^ {2}\+ #\d+ +\S+ {2}(similar to [^·]*·)/.exec(cut);
|
|
@@ -1191,9 +1162,9 @@ function hasSomethingToShow(carnet, session) {
|
|
|
1191
1162
|
function sessionBlock(session, view, io) {
|
|
1192
1163
|
return [sessionHeader(session, io), ...sessionLines(session, view, io, "summary")].join("\n");
|
|
1193
1164
|
}
|
|
1194
|
-
function singleView(carnet, session, io,
|
|
1165
|
+
function singleView(carnet, session, io, state) {
|
|
1195
1166
|
const colors = paint(io);
|
|
1196
|
-
const view = carnet.status.view(session
|
|
1167
|
+
const view = carnet.status.view(session);
|
|
1197
1168
|
const separator = " - ";
|
|
1198
1169
|
const label = sessionLabel(carnet, session, io.columns - view.time.length - 3);
|
|
1199
1170
|
const title = `${colors.dim(view.time)}${separator}${colors.cyan(label)}`;
|
|
@@ -1205,16 +1176,15 @@ function singleView(carnet, session, io, kind, state) {
|
|
|
1205
1176
|
...body,
|
|
1206
1177
|
"",
|
|
1207
1178
|
...footer ? [footer] : [],
|
|
1208
|
-
colors.dim(truncate(KIND_LEGEND, io.columns)),
|
|
1209
1179
|
colors.dim(LEGEND)
|
|
1210
1180
|
].join("\n");
|
|
1211
1181
|
}
|
|
1212
1182
|
function renderStatusView(carnet, io, options) {
|
|
1213
1183
|
const sessions = options.all ? carnet.sessions.list({ includeTemp: true }).filter((session) => hasSomethingToShow(carnet, session)) : [];
|
|
1214
|
-
if (sessions.length === 0) return singleView(carnet, resolveSession(carnet, options.session), io, options.
|
|
1184
|
+
if (sessions.length === 0) return singleView(carnet, resolveSession(carnet, options.session), io, options.interaction);
|
|
1215
1185
|
let time = "";
|
|
1216
1186
|
const blocks = sessions.map((session) => {
|
|
1217
|
-
const view = carnet.status.view(session
|
|
1187
|
+
const view = carnet.status.view(session);
|
|
1218
1188
|
time ||= view.time;
|
|
1219
1189
|
return sessionBlock(session, view, io);
|
|
1220
1190
|
});
|
|
@@ -1226,7 +1196,6 @@ function renderStatusView(carnet, io, options) {
|
|
|
1226
1196
|
"",
|
|
1227
1197
|
blocks.join("\n\n"),
|
|
1228
1198
|
"",
|
|
1229
|
-
colors.dim(truncate(KIND_LEGEND, io.columns)),
|
|
1230
1199
|
colors.dim(LEGEND)
|
|
1231
1200
|
].join("\n");
|
|
1232
1201
|
}
|
|
@@ -1303,53 +1272,6 @@ function statusWatch(carnet, io, options) {
|
|
|
1303
1272
|
repaint();
|
|
1304
1273
|
});
|
|
1305
1274
|
}
|
|
1306
|
-
// src/workspace-option.ts
|
|
1307
|
-
const workspaceArgument = { ws: {
|
|
1308
|
-
type: "string",
|
|
1309
|
-
description: "Workspace name (default: from RUCHER_WS or the run directory, else asked)"
|
|
1310
|
-
} };
|
|
1311
|
-
function forwardWorkspace({ args }) {
|
|
1312
|
-
if (args.ws) process.env.RUCHER_WS = args.ws;
|
|
1313
|
-
}
|
|
1314
|
-
async function chooseWorkspace(io, workspace, { interactive = process.stdin.isTTY === true && process.stderr.isTTY === true, choose = pickWorkspace } = {}) {
|
|
1315
|
-
if (workspace || !interactive) return;
|
|
1316
|
-
if (resolveWorkspace({
|
|
1317
|
-
cwd: io.cwd,
|
|
1318
|
-
env: io.env
|
|
1319
|
-
}).workspace) return;
|
|
1320
|
-
const choices = workspaceChoices(io.env);
|
|
1321
|
-
if (choices.length === 0) return;
|
|
1322
|
-
const chosen = await choose(choices);
|
|
1323
|
-
if (chosen) io.env.RUCHER_WS = chosen;
|
|
1324
|
-
}
|
|
1325
|
-
function announceWorkspace(io, resolution) {
|
|
1326
|
-
if (resolution.workspace && resolution.origin === "run-directory") io.stderr(`workspace ${resolution.workspace.name} (from its run directory)\n`);
|
|
1327
|
-
}
|
|
1328
|
-
function openCliCarnet(io, workspace) {
|
|
1329
|
-
const { carnet, resolution } = openResolvedCarnet({
|
|
1330
|
-
cwd: io.cwd,
|
|
1331
|
-
env: io.env,
|
|
1332
|
-
workspace
|
|
1333
|
-
});
|
|
1334
|
-
try {
|
|
1335
|
-
requireWorkspace(resolution.workspace);
|
|
1336
|
-
} catch (error) {
|
|
1337
|
-
carnet.close();
|
|
1338
|
-
throw error;
|
|
1339
|
-
}
|
|
1340
|
-
announceWorkspace(io, resolution);
|
|
1341
|
-
return carnet;
|
|
1342
|
-
}
|
|
1343
|
-
function currentWorkspace(io, workspace) {
|
|
1344
|
-
const resolution = resolveWorkspace({
|
|
1345
|
-
cwd: io.cwd,
|
|
1346
|
-
env: io.env,
|
|
1347
|
-
workspace
|
|
1348
|
-
});
|
|
1349
|
-
const found = requireWorkspace(resolution.workspace);
|
|
1350
|
-
announceWorkspace(io, resolution);
|
|
1351
|
-
return found;
|
|
1352
|
-
}
|
|
1353
1275
|
// src/commands/ws.ts
|
|
1354
1276
|
function carnetErrors(io, run) {
|
|
1355
1277
|
try {
|
|
@@ -1601,22 +1523,6 @@ function fail(io, error) {
|
|
|
1601
1523
|
else io.stderr(`error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
1602
1524
|
process.exit(1);
|
|
1603
1525
|
}
|
|
1604
|
-
async function askWorkspace({ args }) {
|
|
1605
|
-
const io = processIo();
|
|
1606
|
-
try {
|
|
1607
|
-
await chooseWorkspace(io, args.ws);
|
|
1608
|
-
} catch (error) {
|
|
1609
|
-
fail(io, error);
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
const kindArgument = { kind: {
|
|
1613
|
-
type: "string",
|
|
1614
|
-
description: AGENT_KINDS.join(", ")
|
|
1615
|
-
} };
|
|
1616
|
-
function agentKind(value) {
|
|
1617
|
-
if (value === void 0 || isAgentKind(value)) return value;
|
|
1618
|
-
throw new CliError(`Unknown agent kind ${value}`, `use one of ${AGENT_KINDS.join(", ")}`);
|
|
1619
|
-
}
|
|
1620
1526
|
const colorArgument = { color: {
|
|
1621
1527
|
type: "boolean",
|
|
1622
1528
|
default: true,
|
|
@@ -1650,19 +1556,16 @@ const statusCommand = defineCommand({
|
|
|
1650
1556
|
default: "1",
|
|
1651
1557
|
description: "Refresh interval in seconds with --watch"
|
|
1652
1558
|
},
|
|
1653
|
-
...kindArgument,
|
|
1654
1559
|
...workspaceArgument,
|
|
1655
1560
|
...colorArgument
|
|
1656
1561
|
},
|
|
1657
|
-
setup: askWorkspace,
|
|
1658
1562
|
async run({ args }) {
|
|
1659
1563
|
const io = processIo({ color: args.color });
|
|
1660
1564
|
try {
|
|
1661
1565
|
const carnet = openCliCarnet(io, args.ws);
|
|
1662
1566
|
const options = {
|
|
1663
1567
|
session: args.session,
|
|
1664
|
-
all: args.all
|
|
1665
|
-
kind: agentKind(args.kind)
|
|
1568
|
+
all: args.all
|
|
1666
1569
|
};
|
|
1667
1570
|
if (!args.watch) {
|
|
1668
1571
|
statusOnce(carnet, io, options);
|
|
@@ -1706,11 +1609,9 @@ const logCommand = defineCommand({
|
|
|
1706
1609
|
default: false,
|
|
1707
1610
|
description: "Agent events only, without session starts and ends"
|
|
1708
1611
|
},
|
|
1709
|
-
...kindArgument,
|
|
1710
1612
|
...workspaceArgument,
|
|
1711
1613
|
...colorArgument
|
|
1712
1614
|
},
|
|
1713
|
-
setup: askWorkspace,
|
|
1714
1615
|
run({ args }) {
|
|
1715
1616
|
const io = processIo({ color: args.color });
|
|
1716
1617
|
try {
|
|
@@ -1718,8 +1619,7 @@ const logCommand = defineCommand({
|
|
|
1718
1619
|
session: args.session,
|
|
1719
1620
|
count: Number(args.count) || 20,
|
|
1720
1621
|
md: args.md,
|
|
1721
|
-
agents: args.agents
|
|
1722
|
-
kind: agentKind(args.kind)
|
|
1622
|
+
agents: args.agents
|
|
1723
1623
|
});
|
|
1724
1624
|
} catch (error) {
|
|
1725
1625
|
fail(io, error);
|
|
@@ -1740,7 +1640,6 @@ const sessionsListCommand = defineCommand({
|
|
|
1740
1640
|
...workspaceArgument,
|
|
1741
1641
|
...colorArgument
|
|
1742
1642
|
},
|
|
1743
|
-
setup: askWorkspace,
|
|
1744
1643
|
run({ args }) {
|
|
1745
1644
|
const io = processIo({ color: args.color });
|
|
1746
1645
|
try {
|
|
@@ -1768,7 +1667,6 @@ const sessionsMergeCommand = defineCommand({
|
|
|
1768
1667
|
},
|
|
1769
1668
|
...workspaceArgument
|
|
1770
1669
|
},
|
|
1771
|
-
setup: askWorkspace,
|
|
1772
1670
|
run({ args }) {
|
|
1773
1671
|
const io = processIo();
|
|
1774
1672
|
try {
|
|
@@ -1799,7 +1697,6 @@ const sessionsRenameCommand = defineCommand({
|
|
|
1799
1697
|
},
|
|
1800
1698
|
...workspaceArgument
|
|
1801
1699
|
},
|
|
1802
|
-
setup: askWorkspace,
|
|
1803
1700
|
run({ args }) {
|
|
1804
1701
|
const io = processIo();
|
|
1805
1702
|
withCarnet(io, args.ws, (carnet) => sessionsRename(carnet, args.session, args.name, io));
|
|
@@ -1819,7 +1716,6 @@ const sessionsPromoteCommand = defineCommand({
|
|
|
1819
1716
|
},
|
|
1820
1717
|
...workspaceArgument
|
|
1821
1718
|
},
|
|
1822
|
-
setup: askWorkspace,
|
|
1823
1719
|
run({ args }) {
|
|
1824
1720
|
const io = processIo();
|
|
1825
1721
|
withCarnet(io, args.ws, (carnet) => sessionsPromote(carnet, args.session, args.name, io));
|
|
@@ -1834,7 +1730,6 @@ const sessionsDemoteCommand = defineCommand({
|
|
|
1834
1730
|
session: sessionReference,
|
|
1835
1731
|
...workspaceArgument
|
|
1836
1732
|
},
|
|
1837
|
-
setup: askWorkspace,
|
|
1838
1733
|
run({ args }) {
|
|
1839
1734
|
const io = processIo();
|
|
1840
1735
|
withCarnet(io, args.ws, (carnet) => sessionsDemote(carnet, args.session, io));
|
|
@@ -1855,7 +1750,6 @@ const sessionsDropCommand = defineCommand({
|
|
|
1855
1750
|
...purgeArgument,
|
|
1856
1751
|
...workspaceArgument
|
|
1857
1752
|
},
|
|
1858
|
-
setup: askWorkspace,
|
|
1859
1753
|
run({ args }) {
|
|
1860
1754
|
const io = processIo();
|
|
1861
1755
|
withCarnet(io, args.ws, (carnet) => sessionsDrop(carnet, args.session, io, { purge: args.purge }));
|
|
@@ -1885,7 +1779,6 @@ const sessionsMoveCommand = defineCommand({
|
|
|
1885
1779
|
},
|
|
1886
1780
|
...workspaceArgument
|
|
1887
1781
|
},
|
|
1888
|
-
setup: askWorkspace,
|
|
1889
1782
|
run({ args }) {
|
|
1890
1783
|
const io = processIo();
|
|
1891
1784
|
withCarnet(io, args.ws, (carnet) => sessionsMove(carnet, args.session, args.to, io, {
|
|
@@ -1913,7 +1806,6 @@ const sessionsCleanCommand = defineCommand({
|
|
|
1913
1806
|
},
|
|
1914
1807
|
...workspaceArgument
|
|
1915
1808
|
},
|
|
1916
|
-
setup: askWorkspace,
|
|
1917
1809
|
run({ args }) {
|
|
1918
1810
|
const io = processIo();
|
|
1919
1811
|
withCarnet(io, args.ws, (carnet) => sessionsClean(carnet, io, {
|
|
@@ -1994,7 +1886,6 @@ const notesListCommand = defineCommand({
|
|
|
1994
1886
|
...workspaceArgument,
|
|
1995
1887
|
...colorArgument
|
|
1996
1888
|
},
|
|
1997
|
-
setup: askWorkspace,
|
|
1998
1889
|
run({ args }) {
|
|
1999
1890
|
const io = processIo({ color: args.color });
|
|
2000
1891
|
withCarnet(io, args.ws, (carnet) => notesList(carnet, io, {
|
|
@@ -2021,7 +1912,6 @@ const notesShowCommand = defineCommand({
|
|
|
2021
1912
|
...workspaceArgument,
|
|
2022
1913
|
...colorArgument
|
|
2023
1914
|
},
|
|
2024
|
-
setup: askWorkspace,
|
|
2025
1915
|
run({ args }) {
|
|
2026
1916
|
const io = processIo({ color: args.color });
|
|
2027
1917
|
withCarnet(io, args.ws, (carnet) => notesShow(carnet, io, parseNoteId(args.id)));
|
|
@@ -2050,7 +1940,6 @@ const notesAddCommand = defineCommand({
|
|
|
2050
1940
|
...workspaceArgument,
|
|
2051
1941
|
...colorArgument
|
|
2052
1942
|
},
|
|
2053
|
-
setup: askWorkspace,
|
|
2054
1943
|
run({ args, rawArgs }) {
|
|
2055
1944
|
const io = processIo({ color: args.color });
|
|
2056
1945
|
withCarnet(io, args.ws, (carnet) => notesAdd(carnet, io, {
|
|
@@ -2082,7 +1971,6 @@ const notesDropCommand = defineCommand({
|
|
|
2082
1971
|
},
|
|
2083
1972
|
...workspaceArgument
|
|
2084
1973
|
},
|
|
2085
|
-
setup: askWorkspace,
|
|
2086
1974
|
run({ args }) {
|
|
2087
1975
|
const io = processIo();
|
|
2088
1976
|
const replacement = args["replaced-by"];
|
|
@@ -2148,7 +2036,6 @@ const newCommand = defineCommand({
|
|
|
2148
2036
|
},
|
|
2149
2037
|
...workspaceArgument
|
|
2150
2038
|
},
|
|
2151
|
-
setup: askWorkspace,
|
|
2152
2039
|
async run({ args, rawArgs }) {
|
|
2153
2040
|
const { own, passthrough } = splitPassthrough(rawArgs);
|
|
2154
2041
|
await launch(processIo(), args.ws, (carnet) => planNew(carnet, processIo(), {
|
|
@@ -2171,7 +2058,6 @@ const tmpCommand = defineCommand({
|
|
|
2171
2058
|
},
|
|
2172
2059
|
...workspaceArgument
|
|
2173
2060
|
},
|
|
2174
|
-
setup: askWorkspace,
|
|
2175
2061
|
async run({ args, rawArgs }) {
|
|
2176
2062
|
const { own, passthrough } = splitPassthrough(rawArgs);
|
|
2177
2063
|
await launch(processIo(), args.ws, (carnet) => planNew(carnet, processIo(), {
|
|
@@ -2194,7 +2080,6 @@ const resumeCommand = defineCommand({
|
|
|
2194
2080
|
},
|
|
2195
2081
|
...workspaceArgument
|
|
2196
2082
|
},
|
|
2197
|
-
setup: askWorkspace,
|
|
2198
2083
|
async run({ args, rawArgs }) {
|
|
2199
2084
|
const { own, passthrough } = splitPassthrough(rawArgs);
|
|
2200
2085
|
const io = processIo();
|
|
@@ -2227,7 +2112,6 @@ const forkCommand = defineCommand({
|
|
|
2227
2112
|
},
|
|
2228
2113
|
...workspaceArgument
|
|
2229
2114
|
},
|
|
2230
|
-
setup: askWorkspace,
|
|
2231
2115
|
async run({ args, rawArgs }) {
|
|
2232
2116
|
const { own, passthrough } = splitPassthrough(rawArgs);
|
|
2233
2117
|
const [reference, name] = positionals(withoutWorkspaceOption(own));
|
|
@@ -2326,7 +2210,6 @@ const wsCommand = defineCommand({
|
|
|
2326
2210
|
...workspaceArgument,
|
|
2327
2211
|
...colorArgument
|
|
2328
2212
|
},
|
|
2329
|
-
setup: askWorkspace,
|
|
2330
2213
|
run({ args }) {
|
|
2331
2214
|
process.exitCode = workspaceShow(processIo({ color: args.color }), { workspace: args.ws });
|
|
2332
2215
|
}
|
|
@@ -2345,7 +2228,6 @@ const wsCommand = defineCommand({
|
|
|
2345
2228
|
...workspaceArgument,
|
|
2346
2229
|
...colorArgument
|
|
2347
2230
|
},
|
|
2348
|
-
setup: askWorkspace,
|
|
2349
2231
|
run({ args }) {
|
|
2350
2232
|
process.exitCode = workspaceAdd(args.path, processIo({ color: args.color }), { workspace: args.ws });
|
|
2351
2233
|
}
|
|
@@ -2364,7 +2246,6 @@ const wsCommand = defineCommand({
|
|
|
2364
2246
|
...workspaceArgument,
|
|
2365
2247
|
...colorArgument
|
|
2366
2248
|
},
|
|
2367
|
-
setup: askWorkspace,
|
|
2368
2249
|
run({ args }) {
|
|
2369
2250
|
process.exitCode = workspaceRemove(args.path, processIo({ color: args.color }), { workspace: args.ws });
|
|
2370
2251
|
}
|
|
@@ -2378,7 +2259,6 @@ const wsCommand = defineCommand({
|
|
|
2378
2259
|
...workspaceArgument,
|
|
2379
2260
|
...colorArgument
|
|
2380
2261
|
},
|
|
2381
|
-
setup: askWorkspace,
|
|
2382
2262
|
run({ args }) {
|
|
2383
2263
|
process.exitCode = workspaceSync(processIo({ color: args.color }), { workspace: args.ws });
|
|
2384
2264
|
}
|
|
@@ -2396,7 +2276,6 @@ const wsCommand = defineCommand({
|
|
|
2396
2276
|
},
|
|
2397
2277
|
...workspaceArgument
|
|
2398
2278
|
},
|
|
2399
|
-
setup: askWorkspace,
|
|
2400
2279
|
async run({ args }) {
|
|
2401
2280
|
process.exitCode = await workspaceEdit(processIo(), {
|
|
2402
2281
|
workspace: args.ws,
|
|
@@ -2423,7 +2302,6 @@ const wsCommand = defineCommand({
|
|
|
2423
2302
|
},
|
|
2424
2303
|
...workspaceArgument
|
|
2425
2304
|
},
|
|
2426
|
-
setup: askWorkspace,
|
|
2427
2305
|
run({ args }) {
|
|
2428
2306
|
process.exitCode = workspacePath(processIo(), {
|
|
2429
2307
|
workspace: args.ws,
|
|
@@ -2457,28 +2335,10 @@ const hookCommand = defineCommand({
|
|
|
2457
2335
|
process.exitCode = sessionEnd(await readStdin(), processIo());
|
|
2458
2336
|
}
|
|
2459
2337
|
}),
|
|
2460
|
-
"pre-tool-use": defineCommand({
|
|
2461
|
-
meta: {
|
|
2462
|
-
name: "pre-tool-use",
|
|
2463
|
-
description: "PreToolUse hook: marks the main turn as waiting on the human"
|
|
2464
|
-
},
|
|
2465
|
-
async run() {
|
|
2466
|
-
process.exitCode = preToolUse(await readStdin(), processIo());
|
|
2467
|
-
}
|
|
2468
|
-
}),
|
|
2469
|
-
stop: defineCommand({
|
|
2470
|
-
meta: {
|
|
2471
|
-
name: "stop",
|
|
2472
|
-
description: "Stop hook: ends the main agent's turn"
|
|
2473
|
-
},
|
|
2474
|
-
async run() {
|
|
2475
|
-
process.exitCode = stopHook(await readStdin(), processIo());
|
|
2476
|
-
}
|
|
2477
|
-
}),
|
|
2478
2338
|
"post-tool-use": defineCommand({
|
|
2479
2339
|
meta: {
|
|
2480
2340
|
name: "post-tool-use",
|
|
2481
|
-
description: "PostToolUse hook:
|
|
2341
|
+
description: "PostToolUse hook: adds a repo's notes the first time a tool touches it"
|
|
2482
2342
|
},
|
|
2483
2343
|
async run() {
|
|
2484
2344
|
process.exitCode = postToolUse(await readStdin(), processIo());
|
|
@@ -2487,7 +2347,7 @@ const hookCommand = defineCommand({
|
|
|
2487
2347
|
"user-prompt-submit": defineCommand({
|
|
2488
2348
|
meta: {
|
|
2489
2349
|
name: "user-prompt-submit",
|
|
2490
|
-
description: "UserPromptSubmit hook:
|
|
2350
|
+
description: "UserPromptSubmit hook: names the session after a /rename"
|
|
2491
2351
|
},
|
|
2492
2352
|
async run() {
|
|
2493
2353
|
process.exitCode = userPromptSubmit(await readStdin(), processIo());
|
|
@@ -2522,12 +2382,18 @@ const serveCommand = defineCommand({
|
|
|
2522
2382
|
serve(processIo());
|
|
2523
2383
|
}
|
|
2524
2384
|
});
|
|
2385
|
+
function refuseRemovedOption(rawArgs) {
|
|
2386
|
+
const removed = /^(-g|--group)(=|$)/;
|
|
2387
|
+
const option = splitPassthrough([...rawArgs]).own.find((argument) => removed.test(argument));
|
|
2388
|
+
if (option) fail(processIo(), new CliError(`Unknown option ${option}`, "use --ws <name>"));
|
|
2389
|
+
}
|
|
2525
2390
|
const main = defineCommand({
|
|
2526
2391
|
meta: {
|
|
2527
2392
|
name: "rucher",
|
|
2528
2393
|
version,
|
|
2529
2394
|
description: "Status, journal and sessions of your coding agents (Claude Code today)"
|
|
2530
2395
|
},
|
|
2396
|
+
setup: ({ rawArgs }) => refuseRemovedOption(rawArgs),
|
|
2531
2397
|
subCommands: {
|
|
2532
2398
|
status: statusCommand,
|
|
2533
2399
|
log: logCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rucher/cli",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "rucher: status, journal and sessions of your Claude Code sub-agents, from the terminal",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@bomb.sh/tab": "0.0.22",
|
|
38
|
-
"@rucher/carnet": "0.2.0
|
|
38
|
+
"@rucher/carnet": "0.2.0",
|
|
39
39
|
"citty": "^0.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|