@rucher/cli 0.2.0-beta.3 → 0.2.0-beta.4
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 +49 -13
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +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 { CarnetError, GROUP_FILE,
|
|
6
|
+
import { CarnetError, GROUP_FILE, LEGEND, NOTES_HEADER, NOTE_KINDS, SIMILAR_PREFIX, SUBAGENT_RULES, addGroupRepo, ambiguousGroupContext, appendPromptFile, archiveGroupSessions, claudeCode, createGroup, deleteGroupNotes, dropGroup, formatClock, groupExists, groupLabel, groupRepoNames, groupSessionCounts, handleSessionEnd, handleSessionStart, handleToolUse, handleUserPromptSubmit, hostById, isGroupName, listGroups, loadGroup, memoryHalfLife, moveSession, openCarnet, openGroupCarnet, openResolvedCarnet, removeGroupRepo, renameGroup, renameGroupRows, renderSections, renderWorkspace, repoNameFor, repoPathFor, requireGroup, resolveGroup, shortId, sourceInstructions } from "@rucher/carnet";
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
8
|
import { styleText } from "node:util";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
@@ -17,10 +17,34 @@ function quietly(suggest) {
|
|
|
17
17
|
suggest();
|
|
18
18
|
} catch {}
|
|
19
19
|
}
|
|
20
|
+
function splitInlineValues(words) {
|
|
21
|
+
return words.flatMap((word, index) => {
|
|
22
|
+
const inline = index < words.length - 1 ? /^(--?[\w-]+)=(.*)$/.exec(word) : null;
|
|
23
|
+
return inline ? [inline[1], inline[2]] : [word];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function readTypedWords({ typedWords }) {
|
|
27
|
+
const typed = typedWords.slice(0, -1);
|
|
28
|
+
const passthrough = typed.indexOf("--");
|
|
29
|
+
const own = passthrough === -1 ? typed : typed.slice(0, passthrough);
|
|
30
|
+
const flag = own.findLastIndex((word) => word === "-g" || word === "--group");
|
|
31
|
+
return {
|
|
32
|
+
group: flag === -1 ? void 0 : own[flag + 1],
|
|
33
|
+
words: own.filter((_, index) => !(index > 0 && (own[index - 1] === "-g" || own[index - 1] === "--group")))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function inGroup(context) {
|
|
37
|
+
return {
|
|
38
|
+
cwd: context.cwd,
|
|
39
|
+
env: context.env,
|
|
40
|
+
group: readTypedWords(context).group
|
|
41
|
+
};
|
|
42
|
+
}
|
|
20
43
|
function suggestSessions(context, complete) {
|
|
21
44
|
quietly(() => {
|
|
22
|
-
const carnet = openCarnet(context);
|
|
45
|
+
const carnet = openCarnet(inGroup(context));
|
|
23
46
|
try {
|
|
47
|
+
const typed = readTypedWords(context).words;
|
|
24
48
|
const sessions = carnet.sessions.list({ includeTemp: true });
|
|
25
49
|
const suggestions = [...sessions.flatMap((session) => session.name ? [{
|
|
26
50
|
value: session.name,
|
|
@@ -29,7 +53,7 @@ function suggestSessions(context, complete) {
|
|
|
29
53
|
value: shortId(session.id),
|
|
30
54
|
description: session.status
|
|
31
55
|
}])];
|
|
32
|
-
for (const suggestion of suggestions) if (!
|
|
56
|
+
for (const suggestion of suggestions) if (!typed.includes(suggestion.value)) complete(suggestion.value, suggestion.description);
|
|
33
57
|
} finally {
|
|
34
58
|
carnet.close();
|
|
35
59
|
}
|
|
@@ -42,12 +66,12 @@ function suggestGroups(context, complete) {
|
|
|
42
66
|
}
|
|
43
67
|
function suggestRepos(context, complete) {
|
|
44
68
|
quietly(() => {
|
|
45
|
-
for (const repo of resolveGroup(context).group?.repos ?? []) complete(repo.path, repo.name);
|
|
69
|
+
for (const repo of resolveGroup(inGroup(context)).group?.repos ?? []) complete(repo.path, repo.name);
|
|
46
70
|
});
|
|
47
71
|
}
|
|
48
72
|
function suggestRepoNames(context, complete) {
|
|
49
73
|
quietly(() => {
|
|
50
|
-
const { group } = resolveGroup(context);
|
|
74
|
+
const { group } = resolveGroup(inGroup(context));
|
|
51
75
|
for (const repo of group ? groupRepoNames(group) : []) complete(repo, "");
|
|
52
76
|
});
|
|
53
77
|
}
|
|
@@ -56,7 +80,7 @@ function suggestNoteKinds(complete) {
|
|
|
56
80
|
}
|
|
57
81
|
function suggestNotes(context, complete) {
|
|
58
82
|
quietly(() => {
|
|
59
|
-
const carnet = openCarnet(context);
|
|
83
|
+
const carnet = openCarnet(inGroup(context));
|
|
60
84
|
try {
|
|
61
85
|
for (const note of carnet.notes.list()) complete(String(note.id), note.text.slice(0, 60));
|
|
62
86
|
} finally {
|
|
@@ -73,7 +97,7 @@ function suggestDirectories(context, complete) {
|
|
|
73
97
|
}
|
|
74
98
|
function processContext() {
|
|
75
99
|
const separator = process.argv.indexOf("--");
|
|
76
|
-
const typedWords = separator === -1 ? [] : process.argv.slice(separator + 1);
|
|
100
|
+
const typedWords = separator === -1 ? [] : splitInlineValues(process.argv.slice(separator + 1));
|
|
77
101
|
return {
|
|
78
102
|
cwd: process.cwd(),
|
|
79
103
|
env: process.env,
|
|
@@ -205,11 +229,17 @@ async function setupCompletion(main) {
|
|
|
205
229
|
const complete = visible["complete"];
|
|
206
230
|
if (complete) main.subCommands = {
|
|
207
231
|
...subCommands,
|
|
208
|
-
complete
|
|
232
|
+
complete: {
|
|
233
|
+
...complete,
|
|
234
|
+
run: (context) => {
|
|
235
|
+
context.rawArgs = splitInlineValues(context.rawArgs);
|
|
236
|
+
return complete.run?.(context);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
209
239
|
};
|
|
210
240
|
}
|
|
211
241
|
// package.json
|
|
212
|
-
var version = "0.2.0-beta.
|
|
242
|
+
var version = "0.2.0-beta.4";
|
|
213
243
|
// src/color.ts
|
|
214
244
|
function paint(io) {
|
|
215
245
|
const style = (name) => (text) => io.color ? styleText(name, text, { validateStream: false }) : text;
|
|
@@ -232,6 +262,9 @@ function announceGroup(io, resolution) {
|
|
|
232
262
|
if (resolution.origin === "workspace") io.stderr(`group ${resolution.group.name} (from its workspace)\n`);
|
|
233
263
|
else if (resolution.origin === "repo" && resolution.repo) io.stderr(`group ${resolution.group.name} (from ${resolution.repo.name})\n`);
|
|
234
264
|
}
|
|
265
|
+
function warnNoGroup(carnet, io) {
|
|
266
|
+
if (!carnet.group) io.stderr("no group here: pass -g after the subcommand\n");
|
|
267
|
+
}
|
|
235
268
|
function openCliCarnet(io, group) {
|
|
236
269
|
const { carnet, resolution } = openResolvedCarnet({
|
|
237
270
|
cwd: io.cwd,
|
|
@@ -336,8 +369,10 @@ function invalidGroupFile(name, io) {
|
|
|
336
369
|
}
|
|
337
370
|
async function groupEdit(io, options = {}) {
|
|
338
371
|
let group;
|
|
372
|
+
let file;
|
|
339
373
|
try {
|
|
340
374
|
group = currentGroup(io, options.group);
|
|
375
|
+
file = join(group.source, options.json ? GROUP_FILE : sourceInstructions(group));
|
|
341
376
|
} catch (error) {
|
|
342
377
|
if (error instanceof CarnetError) {
|
|
343
378
|
io.stderr(`error: ${error.message}\n`);
|
|
@@ -345,7 +380,6 @@ async function groupEdit(io, options = {}) {
|
|
|
345
380
|
}
|
|
346
381
|
throw error;
|
|
347
382
|
}
|
|
348
|
-
const file = join(group.source, options.json ? GROUP_FILE : INSTRUCTIONS_FILE);
|
|
349
383
|
const original = readFileSync(file, "utf8");
|
|
350
384
|
const openEditor = options.openEditor ?? openEditorFor(io);
|
|
351
385
|
for (;;) {
|
|
@@ -411,9 +445,10 @@ function sessionsOnce(carnet, io, options = {}) {
|
|
|
411
445
|
includeTemp: options.all,
|
|
412
446
|
includeArchived: options.all
|
|
413
447
|
});
|
|
448
|
+
warnNoGroup(carnet, io);
|
|
414
449
|
if (sessions.length === 0) {
|
|
415
450
|
const hint = options.all ? "" : " (temp and archived ones are hidden, use --all)";
|
|
416
|
-
io.stdout(`${colors.dim(`no active session yet${hint}`)}\n`);
|
|
451
|
+
if (carnet.group) io.stdout(`${colors.dim(`no active session yet${hint}`)}\n`);
|
|
417
452
|
return;
|
|
418
453
|
}
|
|
419
454
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -868,8 +903,9 @@ function notesList(carnet, io, options = {}) {
|
|
|
868
903
|
return;
|
|
869
904
|
}
|
|
870
905
|
const colors = paint(io);
|
|
906
|
+
warnNoGroup(carnet, io);
|
|
871
907
|
if (notes.length === 0) {
|
|
872
|
-
io.stdout(`${colors.dim(options.stale ? "no note to review" : "no notes")}\n`);
|
|
908
|
+
if (carnet.group) io.stdout(`${colors.dim(options.stale ? "no note to review" : "no notes")}\n`);
|
|
873
909
|
return;
|
|
874
910
|
}
|
|
875
911
|
const blocks = grouped(notes).map(([kind, kindNotes]) => `${colors.bold(KIND_TITLES[kind])}\n${kindNotes.map((note) => noteLine(io, note)).join("\n")}`);
|
|
@@ -2145,7 +2181,7 @@ const groupCommand = defineCommand({
|
|
|
2145
2181
|
sync: defineCommand({
|
|
2146
2182
|
meta: {
|
|
2147
2183
|
name: "sync",
|
|
2148
|
-
description: "Render the group's workspace (
|
|
2184
|
+
description: "Render the group's workspace (instruction copies, generated settings)"
|
|
2149
2185
|
},
|
|
2150
2186
|
args: {
|
|
2151
2187
|
...groupArgument,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rucher/cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.4",
|
|
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-beta.
|
|
38
|
+
"@rucher/carnet": "0.2.0-beta.4",
|
|
39
39
|
"citty": "^0.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|