@rucher/cli 0.3.0-beta.1 → 0.3.0-beta.3
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 +74 -15
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -242,7 +242,10 @@ const completionConfig = { subCommands: {
|
|
|
242
242
|
into: workspaces
|
|
243
243
|
} },
|
|
244
244
|
drop: { args: { name: workspaces } },
|
|
245
|
-
show: {
|
|
245
|
+
show: {
|
|
246
|
+
args: { name: workspaces },
|
|
247
|
+
options: workspace
|
|
248
|
+
},
|
|
246
249
|
add: {
|
|
247
250
|
args: { path: directories },
|
|
248
251
|
options: workspace
|
|
@@ -251,9 +254,18 @@ const completionConfig = { subCommands: {
|
|
|
251
254
|
args: { path: repos },
|
|
252
255
|
options: workspace
|
|
253
256
|
},
|
|
254
|
-
sync: {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
sync: {
|
|
258
|
+
args: { name: workspaces },
|
|
259
|
+
options: workspace
|
|
260
|
+
},
|
|
261
|
+
edit: {
|
|
262
|
+
args: { name: workspaces },
|
|
263
|
+
options: workspace
|
|
264
|
+
},
|
|
265
|
+
path: {
|
|
266
|
+
args: { name: workspaces },
|
|
267
|
+
options: workspace
|
|
268
|
+
}
|
|
257
269
|
}
|
|
258
270
|
}
|
|
259
271
|
} };
|
|
@@ -277,7 +289,7 @@ async function setupCompletion(main) {
|
|
|
277
289
|
};
|
|
278
290
|
}
|
|
279
291
|
// package.json
|
|
280
|
-
var version = "0.3.0-beta.
|
|
292
|
+
var version = "0.3.0-beta.3";
|
|
281
293
|
// src/plugin.ts
|
|
282
294
|
const CLI_VERSION = version;
|
|
283
295
|
function readJson(path) {
|
|
@@ -370,6 +382,11 @@ function withCarnet$1(payload, io, use) {
|
|
|
370
382
|
carnet.close();
|
|
371
383
|
}
|
|
372
384
|
}
|
|
385
|
+
function syncPluginVersion(carnet, sessionId, version) {
|
|
386
|
+
if (!version) return;
|
|
387
|
+
const session = carnet.sessions.get(sessionId);
|
|
388
|
+
if (session && session.pluginVersion !== version) carnet.sessions.recordPluginVersion(sessionId, version);
|
|
389
|
+
}
|
|
373
390
|
function sessionStart(stdinText, io) {
|
|
374
391
|
return runHook(io, () => {
|
|
375
392
|
const payload = host.parseSessionPayload(stdinText);
|
|
@@ -427,7 +444,9 @@ function userPromptSubmit(stdinText, io) {
|
|
|
427
444
|
return runHook(io, () => {
|
|
428
445
|
const payload = host.parsePromptPayload(stdinText);
|
|
429
446
|
withCarnet$1(payload, io, (carnet) => {
|
|
430
|
-
|
|
447
|
+
const plugin = installedPlugin(io.env);
|
|
448
|
+
syncPluginVersion(carnet, payload.session_id, plugin.version);
|
|
449
|
+
handleUserPromptSubmit(carnet, host, payload, { trackTurn: plugin.endsTurns });
|
|
431
450
|
});
|
|
432
451
|
});
|
|
433
452
|
}
|
|
@@ -436,10 +455,12 @@ function postToolUse(stdinText, io) {
|
|
|
436
455
|
const payload = host.parseToolPayload(stdinText);
|
|
437
456
|
if (payload.agent_id) return;
|
|
438
457
|
withCarnet$1(payload, io, (carnet) => {
|
|
458
|
+
const plugin = installedPlugin(io.env);
|
|
459
|
+
syncPluginVersion(carnet, payload.session_id, plugin.version);
|
|
439
460
|
const additionalContext = handleToolUse(carnet, payload, {
|
|
440
461
|
RUCHER_MEMORY_MAX_CHARACTERS: io.env.RUCHER_MEMORY_MAX_CHARACTERS,
|
|
441
462
|
RUCHER_MEMORY_HALF_LIFE_DAYS: io.env.RUCHER_MEMORY_HALF_LIFE_DAYS
|
|
442
|
-
}, { trackTurn:
|
|
463
|
+
}, { trackTurn: plugin.endsTurns });
|
|
443
464
|
if (!additionalContext) return;
|
|
444
465
|
const hookSpecificOutput = {
|
|
445
466
|
hookEventName: "PostToolUse",
|
|
@@ -1565,6 +1586,15 @@ const workspaceArgument = { ws: {
|
|
|
1565
1586
|
type: "string",
|
|
1566
1587
|
description: "Workspace name (default: from RUCHER_WS or the run directory, else asked)"
|
|
1567
1588
|
} };
|
|
1589
|
+
const workspaceNameArgument = { name: {
|
|
1590
|
+
type: "positional",
|
|
1591
|
+
required: false,
|
|
1592
|
+
description: "Workspace name, or --ws"
|
|
1593
|
+
} };
|
|
1594
|
+
function namedWorkspace(args) {
|
|
1595
|
+
if (args.name && args.ws && args.name !== args.ws) throw new CliError(`Two workspaces given: ${args.name} and --ws ${args.ws}`, "pass the name or --ws, not both");
|
|
1596
|
+
return args.name || args.ws;
|
|
1597
|
+
}
|
|
1568
1598
|
function forwardWorkspace({ args }) {
|
|
1569
1599
|
if (args.ws) process.env.RUCHER_WS = args.ws;
|
|
1570
1600
|
}
|
|
@@ -1809,6 +1839,7 @@ function workspaceRename(from, to, io, options = {}) {
|
|
|
1809
1839
|
const lines = [
|
|
1810
1840
|
`would rename ${from} to ${to}:`,
|
|
1811
1841
|
...moveLines(result),
|
|
1842
|
+
...treeList(result.trees),
|
|
1812
1843
|
" Claude Code project folder and trust entry, when they exist",
|
|
1813
1844
|
rowLine(result),
|
|
1814
1845
|
...result.running.length ? [`the real run would stop: ${plural(result.running.length, "session")} running (${result.running.map((row) => row.name ?? row.id.slice(0, 8)).join(", ")})`] : []
|
|
@@ -1820,6 +1851,7 @@ function workspaceRename(from, to, io, options = {}) {
|
|
|
1820
1851
|
const lines = [
|
|
1821
1852
|
`renamed ${from} to ${to}`,
|
|
1822
1853
|
...moveLines(done),
|
|
1854
|
+
...treeList(done.trees),
|
|
1823
1855
|
rowLine(done),
|
|
1824
1856
|
` paths rewritten: ${done.paths}`,
|
|
1825
1857
|
` trust entry ${done.trustMoved ? "moved" : "not found, unchanged"}`,
|
|
@@ -1837,6 +1869,19 @@ function moveList(title, moves) {
|
|
|
1837
1869
|
if (!moves.length) return [];
|
|
1838
1870
|
return [` ${title}:`, ...moves.map((move) => ` ${move.from} → ${move.to}`)];
|
|
1839
1871
|
}
|
|
1872
|
+
const TREE_KIND = {
|
|
1873
|
+
worktree: "worktree",
|
|
1874
|
+
orphan: "orphan worktree, no repo registers it, moved as is",
|
|
1875
|
+
clone: "clone"
|
|
1876
|
+
};
|
|
1877
|
+
function treeList(trees) {
|
|
1878
|
+
if (!trees.length) return [];
|
|
1879
|
+
return [" git trees, moved whole:", ...trees.map((tree) => {
|
|
1880
|
+
const what = tree.kind === "worktree" ? `worktree of ${tree.repo}, repaired` : TREE_KIND[tree.kind];
|
|
1881
|
+
const held = tree.holders.length ? `, held by ${tree.holders.map((holder) => holder.name).join(", ")}` : "";
|
|
1882
|
+
return ` ${tree.path} → ${tree.to} (${what}${held})`;
|
|
1883
|
+
})];
|
|
1884
|
+
}
|
|
1840
1885
|
function mergePlanLines(plan) {
|
|
1841
1886
|
const { sessions, notes, activeDays } = plan.rows;
|
|
1842
1887
|
return [
|
|
@@ -1848,6 +1893,7 @@ function mergePlanLines(plan) {
|
|
|
1848
1893
|
` Claude Code project folder of ${plan.from} merged into ${plan.into}'s (conversations, memory), trust entry dropped`,
|
|
1849
1894
|
...moveList("reports", plan.reports),
|
|
1850
1895
|
...moveList("sandboxes", plan.sandboxes),
|
|
1896
|
+
...treeList(plan.trees),
|
|
1851
1897
|
...moveList("other files", plan.files),
|
|
1852
1898
|
` then ${plan.from}'s definition and run directory go to the backup folder`
|
|
1853
1899
|
];
|
|
@@ -1985,6 +2031,15 @@ async function askWorkspace({ args }) {
|
|
|
1985
2031
|
fail(io, error);
|
|
1986
2032
|
}
|
|
1987
2033
|
}
|
|
2034
|
+
async function askNamedWorkspace({ args }) {
|
|
2035
|
+
let workspace;
|
|
2036
|
+
try {
|
|
2037
|
+
workspace = namedWorkspace(args);
|
|
2038
|
+
} catch (error) {
|
|
2039
|
+
fail(processIo(), error);
|
|
2040
|
+
}
|
|
2041
|
+
await askWorkspace({ args: { ws: workspace } });
|
|
2042
|
+
}
|
|
1988
2043
|
const kindArgument = { kind: {
|
|
1989
2044
|
type: "string",
|
|
1990
2045
|
description: AGENT_KINDS.join(", ")
|
|
@@ -2823,12 +2878,13 @@ const wsCommand = defineCommand({
|
|
|
2823
2878
|
description: "Name, definition, run directory and repos of the workspace"
|
|
2824
2879
|
},
|
|
2825
2880
|
args: {
|
|
2881
|
+
...workspaceNameArgument,
|
|
2826
2882
|
...workspaceArgument,
|
|
2827
2883
|
...colorArgument
|
|
2828
2884
|
},
|
|
2829
|
-
setup:
|
|
2885
|
+
setup: askNamedWorkspace,
|
|
2830
2886
|
run({ args }) {
|
|
2831
|
-
process.exitCode = workspaceShow(processIo({ color: args.color }), { workspace: args
|
|
2887
|
+
process.exitCode = workspaceShow(processIo({ color: args.color }), { workspace: namedWorkspace(args) });
|
|
2832
2888
|
}
|
|
2833
2889
|
}),
|
|
2834
2890
|
add: defineCommand({
|
|
@@ -2875,12 +2931,13 @@ const wsCommand = defineCommand({
|
|
|
2875
2931
|
description: "Render the workspace's run directory (instruction copies, generated settings)"
|
|
2876
2932
|
},
|
|
2877
2933
|
args: {
|
|
2934
|
+
...workspaceNameArgument,
|
|
2878
2935
|
...workspaceArgument,
|
|
2879
2936
|
...colorArgument
|
|
2880
2937
|
},
|
|
2881
|
-
setup:
|
|
2938
|
+
setup: askNamedWorkspace,
|
|
2882
2939
|
run({ args }) {
|
|
2883
|
-
process.exitCode = workspaceSync(processIo({ color: args.color }), { workspace: args
|
|
2940
|
+
process.exitCode = workspaceSync(processIo({ color: args.color }), { workspace: namedWorkspace(args) });
|
|
2884
2941
|
}
|
|
2885
2942
|
}),
|
|
2886
2943
|
edit: defineCommand({
|
|
@@ -2889,6 +2946,7 @@ const wsCommand = defineCommand({
|
|
|
2889
2946
|
description: "Open the instructions (or workspace.json with --json) in $EDITOR, then sync"
|
|
2890
2947
|
},
|
|
2891
2948
|
args: {
|
|
2949
|
+
...workspaceNameArgument,
|
|
2892
2950
|
json: {
|
|
2893
2951
|
type: "boolean",
|
|
2894
2952
|
default: false,
|
|
@@ -2896,10 +2954,10 @@ const wsCommand = defineCommand({
|
|
|
2896
2954
|
},
|
|
2897
2955
|
...workspaceArgument
|
|
2898
2956
|
},
|
|
2899
|
-
setup:
|
|
2957
|
+
setup: askNamedWorkspace,
|
|
2900
2958
|
async run({ args }) {
|
|
2901
2959
|
process.exitCode = await workspaceEdit(processIo(), {
|
|
2902
|
-
workspace: args
|
|
2960
|
+
workspace: namedWorkspace(args),
|
|
2903
2961
|
json: args.json,
|
|
2904
2962
|
confirm: askYes
|
|
2905
2963
|
});
|
|
@@ -2916,6 +2974,7 @@ const wsCommand = defineCommand({
|
|
|
2916
2974
|
default: false,
|
|
2917
2975
|
description: "The definition folder instead"
|
|
2918
2976
|
},
|
|
2977
|
+
...workspaceNameArgument,
|
|
2919
2978
|
run: {
|
|
2920
2979
|
type: "boolean",
|
|
2921
2980
|
default: false,
|
|
@@ -2923,10 +2982,10 @@ const wsCommand = defineCommand({
|
|
|
2923
2982
|
},
|
|
2924
2983
|
...workspaceArgument
|
|
2925
2984
|
},
|
|
2926
|
-
setup:
|
|
2985
|
+
setup: askNamedWorkspace,
|
|
2927
2986
|
run({ args }) {
|
|
2928
2987
|
process.exitCode = workspacePath(processIo(), {
|
|
2929
|
-
workspace: args
|
|
2988
|
+
workspace: namedWorkspace(args),
|
|
2930
2989
|
definition: args.def
|
|
2931
2990
|
});
|
|
2932
2991
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rucher/cli",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.3",
|
|
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.3.0-beta.
|
|
38
|
+
"@rucher/carnet": "0.3.0-beta.3",
|
|
39
39
|
"citty": "^0.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|