@av-pi-studio/cli 0.0.118 → 0.0.120
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 +12 -4
- package/README.md.orig +8 -0
- package/dist/daemon-commands.d.ts +12 -3
- package/dist/daemon-commands.js +71 -20
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ pi-studio ui # serve the browser UI, connected to that daemon
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
|
-
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.
|
|
14
|
+
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.120/assets/screenshots/chat-workspace.webp" alt="Pi-Studio web UI — an agent reading, editing, and running shell commands, each as its own tool-call card" width="850">
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
---
|
|
@@ -68,20 +68,20 @@ own card, with live diff stats, right in the chat.
|
|
|
68
68
|
Review what it changed without leaving the tab — a full diff view, line by line:
|
|
69
69
|
|
|
70
70
|
<p align="center">
|
|
71
|
-
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.
|
|
71
|
+
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.120/assets/screenshots/git-diff.webp" alt="Pi-Studio web UI — git changes diff view" width="850">
|
|
72
72
|
</p>
|
|
73
73
|
|
|
74
74
|
Split the workspace into multiple panes — chat next to a live terminal (backed by `node-pty`), a
|
|
75
75
|
file, or another session — and the layout persists across reloads:
|
|
76
76
|
|
|
77
77
|
<p align="center">
|
|
78
|
-
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.
|
|
78
|
+
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.120/assets/screenshots/split-panes.webp" alt="Pi-Studio web UI — split panes with chat and a live terminal side by side" width="850">
|
|
79
79
|
</p>
|
|
80
80
|
|
|
81
81
|
Every file opens with full syntax highlighting:
|
|
82
82
|
|
|
83
83
|
<p align="center">
|
|
84
|
-
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.
|
|
84
|
+
<img src="https://cdn.jsdelivr.net/npm/@av-pi-studio/cli@0.0.120/assets/screenshots/code-viewer.webp" alt="Pi-Studio web UI — syntax-highlighted code viewer" width="850">
|
|
85
85
|
</p>
|
|
86
86
|
|
|
87
87
|
See the [`ui`](#ui) command below for every flag, and
|
|
@@ -182,6 +182,14 @@ explicit provider for non-interactive setups. Secrets are never echoed, and the
|
|
|
182
182
|
`pi-studio onboard` (top-level) is an alias for `daemon start`'s behavior, and bare `pi-studio`
|
|
183
183
|
does the same thing.
|
|
184
184
|
|
|
185
|
+
With the global `--json` flag, `daemon start`, `restart`, `pair` and `stop` each print exactly one
|
|
186
|
+
line of JSON and nothing else (no QR): `start`/`restart` →
|
|
187
|
+
`{"up":true,"started":true|false,"host","port","pairingUrl","relay"}` (failure:
|
|
188
|
+
`{"up":false,"host","port","error":"not_healthy"}`, or `"error":"no_keypair"` with `up:true` when
|
|
189
|
+
the daemon is healthy but has no key file yet), `pair` → `{"pairingUrl","relay"}` (failure
|
|
190
|
+
`{"error":"no_keypair"}`), `stop` → `{"stopped":true|false}`. Failures exit non-zero. `relay` is the
|
|
191
|
+
relay endpoint the link routes through, or `null`. `pairingUrl` is a credential on relay links.
|
|
192
|
+
|
|
185
193
|
### `relay`
|
|
186
194
|
|
|
187
195
|
| Command | Description |
|
package/README.md.orig
CHANGED
|
@@ -182,6 +182,14 @@ explicit provider for non-interactive setups. Secrets are never echoed, and the
|
|
|
182
182
|
`pi-studio onboard` (top-level) is an alias for `daemon start`'s behavior, and bare `pi-studio`
|
|
183
183
|
does the same thing.
|
|
184
184
|
|
|
185
|
+
With the global `--json` flag, `daemon start`, `restart`, `pair` and `stop` each print exactly one
|
|
186
|
+
line of JSON and nothing else (no QR): `start`/`restart` →
|
|
187
|
+
`{"up":true,"started":true|false,"host","port","pairingUrl","relay"}` (failure:
|
|
188
|
+
`{"up":false,"host","port","error":"not_healthy"}`, or `"error":"no_keypair"` with `up:true` when
|
|
189
|
+
the daemon is healthy but has no key file yet), `pair` → `{"pairingUrl","relay"}` (failure
|
|
190
|
+
`{"error":"no_keypair"}`), `stop` → `{"stopped":true|false}`. Failures exit non-zero. `relay` is the
|
|
191
|
+
relay endpoint the link routes through, or `null`. `pairingUrl` is a credential on relay links.
|
|
192
|
+
|
|
185
193
|
### `relay`
|
|
186
194
|
|
|
187
195
|
| Command | Description |
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import { type CliContext, type GlobalOptions } from "./cli-core.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Render the pairing QR + link for the daemon at `home`. Returns an exit code. With `json` it
|
|
5
|
+
* writes one `{ pairingUrl, relay }` / `{ error: "no_keypair" }` line instead (no QR, no prose).
|
|
6
|
+
*/
|
|
7
|
+
export declare function printPairing(ctx: CliContext, home: string, hostArg: string | undefined, json?: boolean): Promise<number>;
|
|
8
|
+
/**
|
|
9
|
+
* Ensure a local daemon is running (start it if not), then print the pairing QR. With
|
|
10
|
+
* `startOpts.json` (only `daemon start|restart` pass it) it writes exactly one JSON line instead:
|
|
11
|
+
* `{ up, started, host, port, pairingUrl, relay }`, `{ up: false, host, port, error: "not_healthy" }`
|
|
12
|
+
* or, when healthy but no keypair file exists, `{ up: true, started, host, port, error: "no_keypair" }`.
|
|
13
|
+
*/
|
|
6
14
|
export declare function ensureLocalDaemonAndPair(ctx: CliContext, opts: GlobalOptions, startOpts?: {
|
|
7
15
|
sleep?: (ms: number) => Promise<void>;
|
|
16
|
+
json?: boolean;
|
|
8
17
|
}): Promise<number>;
|
|
9
18
|
export declare function registerDaemonCommands(program: Command, ctx: CliContext, setExit: (code: number) => void): void;
|
|
10
19
|
//# sourceMappingURL=daemon-commands.d.ts.map
|
package/dist/daemon-commands.js
CHANGED
|
@@ -41,13 +41,11 @@ function resolvePairingRelayInfo(config) {
|
|
|
41
41
|
const useTls = relay.publicEndpoint !== undefined ? relay.publicUseTls : relay.useTls;
|
|
42
42
|
return { endpoint, useTls };
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/** Build the pairing link for the daemon at `home`; `null` when no keypair exists yet. */
|
|
45
|
+
function resolvePairing(home, hostArg) {
|
|
46
46
|
const publicKey = readDaemonPublicKey(home);
|
|
47
|
-
if (!publicKey)
|
|
48
|
-
|
|
49
|
-
return EXIT_ERROR;
|
|
50
|
-
}
|
|
47
|
+
if (!publicKey)
|
|
48
|
+
return null;
|
|
51
49
|
const config = loadConfig(daemonPaths(home).config);
|
|
52
50
|
const relay = resolvePairingRelayInfo(config);
|
|
53
51
|
const { host, port } = parseHost(hostArg);
|
|
@@ -56,6 +54,26 @@ export async function printPairing(ctx, home, hostArg) {
|
|
|
56
54
|
relay: relay ?? undefined,
|
|
57
55
|
baseUrl: config.app.baseUrl,
|
|
58
56
|
});
|
|
57
|
+
return { url, relay };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Render the pairing QR + link for the daemon at `home`. Returns an exit code. With `json` it
|
|
61
|
+
* writes one `{ pairingUrl, relay }` / `{ error: "no_keypair" }` line instead (no QR, no prose).
|
|
62
|
+
*/
|
|
63
|
+
export async function printPairing(ctx, home, hostArg, json = false) {
|
|
64
|
+
const pairing = resolvePairing(home, hostArg);
|
|
65
|
+
if (!pairing) {
|
|
66
|
+
if (json)
|
|
67
|
+
ctx.sink.write(JSON.stringify({ error: "no_keypair" }));
|
|
68
|
+
else
|
|
69
|
+
ctx.sink.error("no daemon keypair found — start the daemon first (`pi-studio daemon start`).");
|
|
70
|
+
return EXIT_ERROR;
|
|
71
|
+
}
|
|
72
|
+
const { url, relay } = pairing;
|
|
73
|
+
if (json) {
|
|
74
|
+
ctx.sink.write(JSON.stringify({ pairingUrl: url, relay: relay?.endpoint ?? null }));
|
|
75
|
+
return EXIT_OK;
|
|
76
|
+
}
|
|
59
77
|
const qr = await renderQrToTerminal(url);
|
|
60
78
|
ctx.sink.write(qr);
|
|
61
79
|
ctx.sink.write(`Pairing link: ${url}`);
|
|
@@ -64,25 +82,55 @@ export async function printPairing(ctx, home, hostArg) {
|
|
|
64
82
|
}
|
|
65
83
|
return EXIT_OK;
|
|
66
84
|
}
|
|
67
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Ensure a local daemon is running (start it if not), then print the pairing QR. With
|
|
87
|
+
* `startOpts.json` (only `daemon start|restart` pass it) it writes exactly one JSON line instead:
|
|
88
|
+
* `{ up, started, host, port, pairingUrl, relay }`, `{ up: false, host, port, error: "not_healthy" }`
|
|
89
|
+
* or, when healthy but no keypair file exists, `{ up: true, started, host, port, error: "no_keypair" }`.
|
|
90
|
+
*/
|
|
68
91
|
export async function ensureLocalDaemonAndPair(ctx, opts, startOpts = {}) {
|
|
92
|
+
const json = startOpts.json === true;
|
|
69
93
|
const runtime = runtimeOf(ctx);
|
|
70
94
|
const home = resolveCtxHome(ctx, opts);
|
|
71
95
|
persistRelayEnvOverrides(home);
|
|
72
96
|
const { host, port } = parseHost(opts.host);
|
|
97
|
+
let started = false;
|
|
73
98
|
if (await runtime.probe(host, port)) {
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
if (!json)
|
|
100
|
+
ctx.sink.write(`daemon already running at ${host}:${port}`);
|
|
76
101
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
else {
|
|
103
|
+
if (!json)
|
|
104
|
+
ctx.sink.write(`starting local daemon at ${host}:${port} …`);
|
|
105
|
+
await runtime.start({ home, listen: `${host}:${port}`, piHome: opts.piHome });
|
|
106
|
+
const up = await waitForDaemon(runtime, host, port, { sleep: startOpts.sleep });
|
|
107
|
+
if (!up) {
|
|
108
|
+
if (json)
|
|
109
|
+
ctx.sink.write(JSON.stringify({ up: false, host, port, error: "not_healthy" }));
|
|
110
|
+
else
|
|
111
|
+
ctx.sink.error("daemon did not become healthy in time.");
|
|
112
|
+
return EXIT_ERROR;
|
|
113
|
+
}
|
|
114
|
+
started = true;
|
|
115
|
+
if (!json)
|
|
116
|
+
ctx.sink.write(`daemon listening at ${host}:${port}`);
|
|
117
|
+
}
|
|
118
|
+
if (!json)
|
|
119
|
+
return printPairing(ctx, home, opts.host);
|
|
120
|
+
const pairing = resolvePairing(home, opts.host);
|
|
121
|
+
if (!pairing) {
|
|
122
|
+
ctx.sink.write(JSON.stringify({ up: true, started, host, port, error: "no_keypair" }));
|
|
82
123
|
return EXIT_ERROR;
|
|
83
124
|
}
|
|
84
|
-
ctx.sink.write(
|
|
85
|
-
|
|
125
|
+
ctx.sink.write(JSON.stringify({
|
|
126
|
+
up: true,
|
|
127
|
+
started,
|
|
128
|
+
host,
|
|
129
|
+
port,
|
|
130
|
+
pairingUrl: pairing.url,
|
|
131
|
+
relay: pairing.relay?.endpoint ?? null,
|
|
132
|
+
}));
|
|
133
|
+
return EXIT_OK;
|
|
86
134
|
}
|
|
87
135
|
export function registerDaemonCommands(program, ctx, setExit) {
|
|
88
136
|
const g = () => program.opts();
|
|
@@ -102,14 +150,17 @@ export function registerDaemonCommands(program, ctx, setExit) {
|
|
|
102
150
|
.command("start")
|
|
103
151
|
.description("start a local daemon and show a pairing QR code")
|
|
104
152
|
.action(async () => {
|
|
105
|
-
setExit(await ensureLocalDaemonAndPair(ctx, g()));
|
|
153
|
+
setExit(await ensureLocalDaemonAndPair(ctx, g(), { json: g().json }));
|
|
106
154
|
});
|
|
107
155
|
daemon
|
|
108
156
|
.command("stop")
|
|
109
157
|
.description("stop the local daemon")
|
|
110
158
|
.action(() => {
|
|
111
159
|
const stopped = stopDaemon(resolveCtxHome(ctx, g()), runtimeOf(ctx));
|
|
112
|
-
|
|
160
|
+
if (g().json)
|
|
161
|
+
ctx.sink.write(JSON.stringify({ stopped }));
|
|
162
|
+
else
|
|
163
|
+
ctx.sink.write(stopped ? "daemon stopped" : "no running daemon found");
|
|
113
164
|
setExit(stopped ? EXIT_OK : EXIT_ERROR);
|
|
114
165
|
});
|
|
115
166
|
daemon
|
|
@@ -117,13 +168,13 @@ export function registerDaemonCommands(program, ctx, setExit) {
|
|
|
117
168
|
.description("restart the local daemon")
|
|
118
169
|
.action(async () => {
|
|
119
170
|
stopDaemon(resolveCtxHome(ctx, g()), runtimeOf(ctx));
|
|
120
|
-
setExit(await ensureLocalDaemonAndPair(ctx, g()));
|
|
171
|
+
setExit(await ensureLocalDaemonAndPair(ctx, g(), { json: g().json }));
|
|
121
172
|
});
|
|
122
173
|
daemon
|
|
123
174
|
.command("pair")
|
|
124
175
|
.description("render the pairing QR code / link")
|
|
125
176
|
.action(async () => {
|
|
126
|
-
setExit(await printPairing(ctx, resolveCtxHome(ctx, g()), g().host));
|
|
177
|
+
setExit(await printPairing(ctx, resolveCtxHome(ctx, g()), g().host, g().json));
|
|
127
178
|
});
|
|
128
179
|
daemon
|
|
129
180
|
.command("set-password <password>")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@av-pi-studio/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.120",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/avatsaev/pi-studio.git",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@av-pi-studio/client": "^0.0.
|
|
33
|
-
"@av-pi-studio/protocol": "^0.0.
|
|
34
|
-
"@av-pi-studio/relay": "^0.0.
|
|
35
|
-
"@av-pi-studio/server": "^0.0.
|
|
36
|
-
"@av-pi-studio/web-client": "^0.0.
|
|
32
|
+
"@av-pi-studio/client": "^0.0.120",
|
|
33
|
+
"@av-pi-studio/protocol": "^0.0.120",
|
|
34
|
+
"@av-pi-studio/relay": "^0.0.120",
|
|
35
|
+
"@av-pi-studio/server": "^0.0.120",
|
|
36
|
+
"@av-pi-studio/web-client": "^0.0.120",
|
|
37
37
|
"@earendil-works/pi-coding-agent": "^1.4.0",
|
|
38
38
|
"@inquirer/prompts": "^8.5.2",
|
|
39
39
|
"bcryptjs": "^3.0.3",
|