rucan 0.1.1 → 0.1.2
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/README.md +5 -1
- package/agents/darwin-arm64/rucan-agent +0 -0
- package/agents/darwin-x64/rucan-agent +0 -0
- package/agents/linux-arm64/rucan-agent +0 -0
- package/agents/linux-x64/rucan-agent +0 -0
- package/agents/manifest.json +5 -5
- package/dist/main.js +4 -0
- package/dist/terminal/input.js +17 -6
- package/dist/terminal/interactive.js +41 -5
- package/dist/terminal/view.js +1 -1
- package/dist/terminal/workspace-refresh.js +15 -0
- package/dist/terminal/workspaces.js +13 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ pnpm build
|
|
|
14
14
|
pnpm dev
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Type `exit` at the shell prompt to close the current shell. To open Rucan's exit screen, press Ctrl+G and then Q, or enter `/exit` in the menu. Press Enter on the exit screen to keep sessions running. Ctrl+G and F12 open the workspace menu. On Mac keyboards with media keys, press Fn+F12 to send F12. P pins a session, D closes the UI and keeps sessions running, H selects a host, and E opens the file explorer. Arrow keys, digits and sidebar clicks switch workspaces. T opens optional tmux actions, and S browses scrollback. The first launch creates a sample at `~/.config/rucan/config.yaml` or under an absolute `XDG_CONFIG_HOME`. Local and remote configuration examples follow.
|
|
18
18
|
|
|
19
19
|
```yaml
|
|
20
20
|
version: 1
|
|
@@ -28,6 +28,10 @@ workspaces:
|
|
|
28
28
|
persistence: persistent
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
The numbered workspace list contains running sessions. When the selected session exits, Rucan opens the next running session. If the list is empty, use Ctrl+G, then N to open a new workspace.
|
|
32
|
+
|
|
33
|
+
Inside a managed shell, run `rucan` to see session commands. Use `npx rucan@latest` if you run Rucan through npm without a global installation.
|
|
34
|
+
|
|
31
35
|
`pnpm dev config` validates the configuration and prints its path. The npm package installs the `rucan` command. After the first release:
|
|
32
36
|
|
|
33
37
|
```sh
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/agents/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.2",
|
|
3
3
|
"platforms": {
|
|
4
|
-
"linux-x64": "
|
|
5
|
-
"linux-arm64": "
|
|
6
|
-
"darwin-x64": "
|
|
7
|
-
"darwin-arm64": "
|
|
4
|
+
"linux-x64": "0369001ea14d9f604251eb1701871fadf8915a3f4b603eba1231a9d8cbc92e34",
|
|
5
|
+
"linux-arm64": "3bd5ae6113d92d91f9a13e17becea75949a394772ab75d54d24a778d24d4f718",
|
|
6
|
+
"darwin-x64": "39cb080a250b7bcc03af523825b9f2ca9762650453f1ff999a4300e34c5744c2",
|
|
7
|
+
"darwin-arm64": "95eaee56515ae4119b45a372ebd912ac3a4a0cd80fd7f3cc56a248bb560b5e21"
|
|
8
8
|
}
|
|
9
9
|
}
|
package/dist/main.js
CHANGED
|
@@ -15,6 +15,10 @@ async function main(args) {
|
|
|
15
15
|
console.log(`rucan ${version}`);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
+
if (args.length === 0 && process.env.RUCAN_SESSION_ID) {
|
|
19
|
+
console.log("Rucan session commands\n\n rucan ls List sessions\n rucan pin Pin this session\n rucan unpin Unpin this session\n rucan --help Show all CLI commands\n\nType exit to close this shell. Open the Rucan menu to close the UI.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
if (args.length === 1 && args[0] === "--help") {
|
|
19
23
|
console.log("Usage: rucan [attach | remote | tmux | update | doctor | config | ls | status | new | pin | unpin | detach | rename | kill | shutdown | --fixture | --help | --version]\n\nOpen the workspace UI or control a local terminal session.");
|
|
20
24
|
return;
|
package/dist/terminal/input.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const pasteStart = Buffer.from("\x1b[200~");
|
|
2
2
|
const pasteEnd = Buffer.from("\x1b[201~");
|
|
3
3
|
const mouseStart = Buffer.from("\x1b[<");
|
|
4
|
+
const f12 = Buffer.from("\x1b[24~");
|
|
4
5
|
function mouseReport(bytes) {
|
|
5
6
|
const prefix = bytes.subarray(0, mouseStart.length);
|
|
6
7
|
if (!mouseStart.subarray(0, prefix.length).equals(prefix))
|
|
@@ -66,12 +67,22 @@ export class InputRouter {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
else if (!this.#paste) {
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
incomplete =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
const key = remainder.subarray(0, f12.length);
|
|
71
|
+
if (f12.subarray(0, key.length).equals(key)) {
|
|
72
|
+
incomplete = key.length < f12.length;
|
|
73
|
+
if (!incomplete) {
|
|
74
|
+
event = { type: "prefix" };
|
|
75
|
+
length = f12.length;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const mouse = mouseReport(remainder);
|
|
80
|
+
if (mouse === "incomplete")
|
|
81
|
+
incomplete = true;
|
|
82
|
+
else if (mouse) {
|
|
83
|
+
event = { type: "mouse", ...mouse.event };
|
|
84
|
+
length = mouse.length;
|
|
85
|
+
}
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
@@ -9,10 +9,11 @@ import { mountRawInput } from "./raw-input.js";
|
|
|
9
9
|
import { exitLines, footerFor, menuFor, selectionLines, } from "./view.js";
|
|
10
10
|
import { listTmux, openTmux } from "./tmux.js";
|
|
11
11
|
import { TerminalWatch } from "./watch.js";
|
|
12
|
+
import { watchWorkspaceList } from "./workspace-refresh.js";
|
|
12
13
|
import { terminalMouse } from "./mouse.js";
|
|
13
14
|
import { geometry, Screen } from "./screen.js";
|
|
14
15
|
import { decodeSnapshot } from "./snapshot.js";
|
|
15
|
-
import { createWorkspace, decodeWorkspace, listWorkspaces, workspaceLabels, } from "./workspaces.js";
|
|
16
|
+
import { createWorkspace, decodeWorkspace, listWorkspaces, reconcileWorkspaces, workspaceLabels, } from "./workspaces.js";
|
|
16
17
|
export async function runInteractive(config, requested, host) {
|
|
17
18
|
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
18
19
|
throw new Error("The workspace UI requires a terminal.");
|
|
@@ -91,13 +92,12 @@ class InteractiveWorkspace {
|
|
|
91
92
|
this.#explorer = new Explorer(connect, config.explorer.exclusions, () => this.#draw());
|
|
92
93
|
}
|
|
93
94
|
async run(requested) {
|
|
94
|
-
this.#workspaces = await listWorkspaces(this.#client);
|
|
95
|
+
this.#workspaces = (await listWorkspaces(this.#client)).filter(({ running }) => running);
|
|
95
96
|
const target = requested
|
|
96
97
|
? this.#workspaces.find(({ id, name }) => id === requested || name === requested)
|
|
97
98
|
: this.#workspaces.find(({ running }) => running);
|
|
98
99
|
if (requested && !target)
|
|
99
100
|
throw new Error(`Unknown session ${requested}`);
|
|
100
|
-
await this.#select(target ?? (await this.#new()), false);
|
|
101
101
|
const onResize = () => {
|
|
102
102
|
if (this.#resizePending)
|
|
103
103
|
return;
|
|
@@ -114,7 +114,9 @@ class InteractiveWorkspace {
|
|
|
114
114
|
});
|
|
115
115
|
this.#screen.enter();
|
|
116
116
|
let unmount;
|
|
117
|
+
let stopRefresh;
|
|
117
118
|
try {
|
|
119
|
+
await this.#select(target ?? (await this.#new()), false);
|
|
118
120
|
unmount = mountRawInput(this.#config.terminal.prefix_key, {
|
|
119
121
|
input: (events) => this.#enqueue(async () => {
|
|
120
122
|
for (const event of events) {
|
|
@@ -127,6 +129,7 @@ class InteractiveWorkspace {
|
|
|
127
129
|
stop: () => this.#stop(),
|
|
128
130
|
});
|
|
129
131
|
this.#draw();
|
|
132
|
+
stopRefresh = watchWorkspaceList(() => this.#enqueue(() => this.#refreshWorkspaces()));
|
|
130
133
|
if (this.#config.updates.check_on_startup) {
|
|
131
134
|
void availableUpdate()
|
|
132
135
|
.then((target) => {
|
|
@@ -140,6 +143,7 @@ class InteractiveWorkspace {
|
|
|
140
143
|
await done;
|
|
141
144
|
}
|
|
142
145
|
finally {
|
|
146
|
+
stopRefresh?.();
|
|
143
147
|
this.#stop();
|
|
144
148
|
this.#client.close();
|
|
145
149
|
unmount?.();
|
|
@@ -185,16 +189,48 @@ class InteractiveWorkspace {
|
|
|
185
189
|
this.#controlsInput = controls;
|
|
186
190
|
this.#status = controls ? "" : "Read-only · input held by another client";
|
|
187
191
|
this.#snapshot = decodeSnapshot(await this.#client.request({ type: "snapshot", session: workspace.id }));
|
|
188
|
-
|
|
192
|
+
if (this.#snapshot.state !== "running") {
|
|
193
|
+
await this.#refreshWorkspaces(workspace.id, render);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
189
196
|
if (render)
|
|
190
197
|
this.#draw();
|
|
191
198
|
this.#watcher.start(workspace.id, this.#snapshot, (snapshot) => {
|
|
199
|
+
if (snapshot.state !== "running") {
|
|
200
|
+
void this.#enqueue(() => this.#refreshWorkspaces(workspace.id));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
192
203
|
this.#snapshot = snapshot;
|
|
193
204
|
this.#draw();
|
|
194
205
|
}, (error) => {
|
|
195
206
|
this.#status = error instanceof Error ? error.message : String(error);
|
|
196
207
|
this.#draw();
|
|
197
208
|
});
|
|
209
|
+
await this.#resize();
|
|
210
|
+
}
|
|
211
|
+
async #refreshWorkspaces(exitedId, render = true) {
|
|
212
|
+
const running = (await listWorkspaces(this.#client)).filter(({ id, running }) => running && id !== exitedId);
|
|
213
|
+
const selected = this.#selected;
|
|
214
|
+
const previous = this.#workspaces;
|
|
215
|
+
const { workspaces, next } = reconcileWorkspaces(previous, running, selected?.id);
|
|
216
|
+
this.#workspaces = workspaces;
|
|
217
|
+
if (selected ? !workspaces.some(({ id }) => id === selected.id) : next) {
|
|
218
|
+
this.#watcher.stop();
|
|
219
|
+
this.#selected = undefined;
|
|
220
|
+
this.#snapshot = undefined;
|
|
221
|
+
this.#controlsInput = false;
|
|
222
|
+
this.#status = "";
|
|
223
|
+
if (this.#mode === "history")
|
|
224
|
+
this.#mode = "terminal";
|
|
225
|
+
if (next) {
|
|
226
|
+
await this.#select(next, render);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (render &&
|
|
231
|
+
(previous.length !== workspaces.length ||
|
|
232
|
+
workspaces.some((workspace, index) => workspace !== previous[index])))
|
|
233
|
+
this.#draw();
|
|
198
234
|
}
|
|
199
235
|
async #recoverControl() {
|
|
200
236
|
const selected = this.#selected;
|
|
@@ -628,7 +664,7 @@ class InteractiveWorkspace {
|
|
|
628
664
|
? this.#host
|
|
629
665
|
? `${this.#host} connected`
|
|
630
666
|
: "Local agent connected"
|
|
631
|
-
: "
|
|
667
|
+
: "No active workspace"),
|
|
632
668
|
healthy: running && !this.#status,
|
|
633
669
|
},
|
|
634
670
|
footer: this.#update && this.#mode !== "exit"
|
package/dist/terminal/view.js
CHANGED
|
@@ -21,7 +21,7 @@ export function footerFor(mode, prefix, name, scrollback) {
|
|
|
21
21
|
case "menu":
|
|
22
22
|
return "Q Quit · Esc Return to terminal · ↑↓ / 1–9 Switch";
|
|
23
23
|
case "terminal":
|
|
24
|
-
return `${prefix} Menu ·
|
|
24
|
+
return `${prefix} Menu (F12) · Type exit to close the current shell`;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export function menuFor(update) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Poll workspace metadata without overlapping requests or watching inactive PTYs. */
|
|
2
|
+
export function watchWorkspaceList(refresh) {
|
|
3
|
+
let stopped = false;
|
|
4
|
+
let timer;
|
|
5
|
+
const schedule = () => {
|
|
6
|
+
if (stopped)
|
|
7
|
+
return;
|
|
8
|
+
timer = setTimeout(() => void refresh().finally(schedule), 2000);
|
|
9
|
+
};
|
|
10
|
+
schedule();
|
|
11
|
+
return () => {
|
|
12
|
+
stopped = true;
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -41,6 +41,18 @@ export async function listWorkspaces(client) {
|
|
|
41
41
|
.map(decodeWorkspace)
|
|
42
42
|
.sort((left, right) => left.name.localeCompare(right.name));
|
|
43
43
|
}
|
|
44
|
+
export function reconcileWorkspaces(previous, running, selectedId) {
|
|
45
|
+
const current = new Map(running.map((workspace) => [workspace.id, workspace]));
|
|
46
|
+
const workspaces = previous.filter(({ id }) => current.has(id));
|
|
47
|
+
for (const { id } of workspaces)
|
|
48
|
+
current.delete(id);
|
|
49
|
+
workspaces.push(...current.values());
|
|
50
|
+
const index = previous.findIndex(({ id }) => id === selectedId);
|
|
51
|
+
return {
|
|
52
|
+
workspaces,
|
|
53
|
+
next: workspaces[Math.min(Math.max(0, index), workspaces.length - 1)],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
44
56
|
function defaultWorkspace(config, host) {
|
|
45
57
|
return (config.workspaces.find(({ host: entry, backend }) => entry === host && backend === "native") ?? {
|
|
46
58
|
name: host ?? "local-shell",
|
|
@@ -71,8 +83,7 @@ export function workspaceLabels(config, sessions, activeId) {
|
|
|
71
83
|
const selected = workspace.id === activeId ? "›" : " ";
|
|
72
84
|
const pin = workspace.backend === "tmux" ? "T" : workspace.persistent ? "◆" : "◇";
|
|
73
85
|
const slot = index < 9 ? String(index + 1) : " ";
|
|
74
|
-
|
|
75
|
-
return `${selected}${slot} ${pin} ${workspace.name}${exited}`;
|
|
86
|
+
return `${selected}${slot} ${pin} ${workspace.name}`;
|
|
76
87
|
}),
|
|
77
88
|
];
|
|
78
89
|
for (const workspace of config.workspaces) {
|