@av-pi-studio/cli 0.0.1

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.
Files changed (54) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/agent-commands.d.ts +70 -0
  3. package/dist/agent-commands.d.ts.map +1 -0
  4. package/dist/agent-commands.js +296 -0
  5. package/dist/agent-commands.js.map +1 -0
  6. package/dist/cli-core.d.ts +55 -0
  7. package/dist/cli-core.d.ts.map +1 -0
  8. package/dist/cli-core.js +85 -0
  9. package/dist/cli-core.js.map +1 -0
  10. package/dist/cli.d.ts +3 -0
  11. package/dist/cli.d.ts.map +1 -0
  12. package/dist/cli.js +16 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/client-id.d.ts +12 -0
  15. package/dist/client-id.d.ts.map +1 -0
  16. package/dist/client-id.js +47 -0
  17. package/dist/client-id.js.map +1 -0
  18. package/dist/connection.d.ts +44 -0
  19. package/dist/connection.d.ts.map +1 -0
  20. package/dist/connection.js +83 -0
  21. package/dist/connection.js.map +1 -0
  22. package/dist/daemon-commands.d.ts +10 -0
  23. package/dist/daemon-commands.d.ts.map +1 -0
  24. package/dist/daemon-commands.js +108 -0
  25. package/dist/daemon-commands.js.map +1 -0
  26. package/dist/daemon-control.d.ts +67 -0
  27. package/dist/daemon-control.d.ts.map +1 -0
  28. package/dist/daemon-control.js +140 -0
  29. package/dist/daemon-control.js.map +1 -0
  30. package/dist/feature-commands.d.ts +56 -0
  31. package/dist/feature-commands.d.ts.map +1 -0
  32. package/dist/feature-commands.js +250 -0
  33. package/dist/feature-commands.js.map +1 -0
  34. package/dist/index.d.ts +15 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +18 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/output.d.ts +25 -0
  39. package/dist/output.d.ts.map +1 -0
  40. package/dist/output.js +65 -0
  41. package/dist/output.js.map +1 -0
  42. package/dist/pairing.d.ts +17 -0
  43. package/dist/pairing.d.ts.map +1 -0
  44. package/dist/pairing.js +33 -0
  45. package/dist/pairing.js.map +1 -0
  46. package/dist/program.d.ts +17 -0
  47. package/dist/program.d.ts.map +1 -0
  48. package/dist/program.js +75 -0
  49. package/dist/program.js.map +1 -0
  50. package/dist/qr.d.ts +6 -0
  51. package/dist/qr.d.ts.map +1 -0
  52. package/dist/qr.js +9 -0
  53. package/dist/qr.js.map +1 -0
  54. package/package.json +34 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Pairing helpers (architecture/relay-e2ee.md § Pairing). The daemon's persistent Curve25519 public
3
+ * key is carried to clients in a **pairing URL** rendered as a QR code. The key rides in the URL
4
+ * fragment, so the web origin (`app.pi-studio.sh`) never sees it.
5
+ */
6
+ export declare const DEFAULT_PAIRING_BASE = "https://app.pi-studio.sh";
7
+ /** Read the daemon's persistent public key (base64) from `$PI_STUDIO_HOME/daemon-keypair.json`. */
8
+ export declare function readDaemonPublicKey(home: string): string | null;
9
+ /**
10
+ * Build the pairing URL. The public key (and optional direct host) ride in the **fragment**, never
11
+ * sent to the server. TODO(verify): exact bytes/encoding of the `offer` fragment.
12
+ */
13
+ export declare function buildPairingUrl(publicKeyB64: string, opts?: {
14
+ baseUrl?: string;
15
+ host?: string;
16
+ }): string;
17
+ //# sourceMappingURL=pairing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../src/pairing.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAE/D,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS/D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7C,MAAM,CAKR"}
@@ -0,0 +1,33 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Pairing helpers (architecture/relay-e2ee.md § Pairing). The daemon's persistent Curve25519 public
5
+ * key is carried to clients in a **pairing URL** rendered as a QR code. The key rides in the URL
6
+ * fragment, so the web origin (`app.pi-studio.sh`) never sees it.
7
+ */
8
+ export const DEFAULT_PAIRING_BASE = "https://app.pi-studio.sh";
9
+ /** Read the daemon's persistent public key (base64) from `$PI_STUDIO_HOME/daemon-keypair.json`. */
10
+ export function readDaemonPublicKey(home) {
11
+ const path = join(home, "daemon-keypair.json");
12
+ if (!existsSync(path))
13
+ return null;
14
+ try {
15
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
16
+ return parsed.publicKeyB64 ?? null;
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ /**
23
+ * Build the pairing URL. The public key (and optional direct host) ride in the **fragment**, never
24
+ * sent to the server. TODO(verify): exact bytes/encoding of the `offer` fragment.
25
+ */
26
+ export function buildPairingUrl(publicKeyB64, opts = {}) {
27
+ const base = opts.baseUrl ?? DEFAULT_PAIRING_BASE;
28
+ const params = new URLSearchParams({ offer: publicKeyB64 });
29
+ if (opts.host)
30
+ params.set("host", opts.host);
31
+ return `${base}/#${params.toString()}`;
32
+ }
33
+ //# sourceMappingURL=pairing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing.js","sourceRoot":"","sources":["../src/pairing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;GAIG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAE/D,mGAAmG;AACnG,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA8B,CAAC;QACnF,OAAO,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAoB,EACpB,OAA4C,EAAE;IAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,oBAAoB,CAAC;IAClD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IAC5D,IAAI,IAAI,CAAC,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,IAAI,KAAK,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Command } from "commander";
2
+ import { type CliContext, type GlobalOptions } from "./cli-core.js";
3
+ /**
4
+ * Build the root Commander program (features/cli.md § Global options). Global options are attached
5
+ * here; command groups register via `registerCommands` (added incrementally by later tasks). Each
6
+ * command action reports its exit code through `setExit` because Commander actions cannot return
7
+ * one directly.
8
+ */
9
+ export declare function buildProgram(ctx: CliContext, setExit: (code: number) => void): Command;
10
+ /** Read the resolved global options off the root program. */
11
+ export declare function globalOptions(program: Command): GlobalOptions;
12
+ /**
13
+ * Parse argv and run. Returns the process exit code. Commander's help/version short-circuits are
14
+ * treated as success; usage errors as failure.
15
+ */
16
+ export declare function run(argv: string[], ctx?: CliContext): Promise<number>;
17
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CA2BtF;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAE7D;AAgBD;;;GAGG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,UAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB7F"}
@@ -0,0 +1,75 @@
1
+ import { Command } from "commander";
2
+ import { registerAgentCommands } from "./agent-commands.js";
3
+ import { registerDaemonCommands, ensureLocalDaemonAndPair } from "./daemon-commands.js";
4
+ import { registerFeatureCommands, runOpenProject } from "./feature-commands.js";
5
+ import { defaultContext } from "./cli-core.js";
6
+ /**
7
+ * Build the root Commander program (features/cli.md § Global options). Global options are attached
8
+ * here; command groups register via `registerCommands` (added incrementally by later tasks). Each
9
+ * command action reports its exit code through `setExit` because Commander actions cannot return
10
+ * one directly.
11
+ */
12
+ export function buildProgram(ctx, setExit) {
13
+ const program = new Command();
14
+ program
15
+ .name("pi-studio")
16
+ .description("Pi-Studio terminal client — speaks the daemon WebSocket protocol")
17
+ .version("0.0.0")
18
+ .option("-H, --host <host>", "daemon/host target (e.g. workstation.local:6767)")
19
+ .option("--password <password>", "daemon password (for password-protected daemons)")
20
+ .option("--home <dir>", "override $PI_STUDIO_HOME (client-id store)")
21
+ .option("--json", "render output as JSON instead of a table", false)
22
+ .enablePositionalOptions()
23
+ .argument("[path]", "open a project at this path (bare `pi-studio <path>`)")
24
+ .exitOverride();
25
+ // Default action (no subcommand): `pi-studio <path>` opens a project; bare `pi-studio` starts a
26
+ // local daemon (if needed) and shows a pairing QR.
27
+ program.action(async (path) => {
28
+ const opts = program.opts();
29
+ if (path) {
30
+ setExit(await runOpenProject(ctx, opts, path));
31
+ return;
32
+ }
33
+ setExit(await ensureLocalDaemonAndPair(ctx, opts));
34
+ });
35
+ registerCommands(program, ctx, setExit);
36
+ return program;
37
+ }
38
+ /** Read the resolved global options off the root program. */
39
+ export function globalOptions(program) {
40
+ return program.opts();
41
+ }
42
+ /**
43
+ * Register command groups. Each task in this sprint adds its groups here. Kept as a single seam so
44
+ * the program assembly stays declarative.
45
+ */
46
+ function registerCommands(program, ctx, setExit) {
47
+ registerAgentCommands(program, ctx, setExit);
48
+ registerDaemonCommands(program, ctx, setExit);
49
+ registerFeatureCommands(program, ctx, setExit);
50
+ }
51
+ /**
52
+ * Parse argv and run. Returns the process exit code. Commander's help/version short-circuits are
53
+ * treated as success; usage errors as failure.
54
+ */
55
+ export async function run(argv, ctx = defaultContext()) {
56
+ let exitCode = 0;
57
+ const program = buildProgram(ctx, (code) => {
58
+ exitCode = code;
59
+ });
60
+ try {
61
+ await program.parseAsync(argv, { from: "user" });
62
+ }
63
+ catch (error) {
64
+ const err = error;
65
+ // Help/version requested → success; everything else → that code (or 1).
66
+ if (err.code === "commander.helpDisplayed" || err.code === "commander.version") {
67
+ return 0;
68
+ }
69
+ if (err.code === "commander.help")
70
+ return 0;
71
+ return typeof err.exitCode === "number" ? err.exitCode : 1;
72
+ }
73
+ return exitCode;
74
+ }
75
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,uBAA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AAgB,EAChB,GAAe,EACf,OAA+B;IAE/B,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7C,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,MAAkB,cAAc,EAAE;IAC1E,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACzC,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAA6C,CAAC;QAC1D,wEAAwE;QACxE,IAAI,GAAG,CAAC,IAAI,KAAK,yBAAyB,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YAC/E,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB;YAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/dist/qr.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Render a string as a QR code drawn with terminal block characters (features/cli.md § Behavior —
3
+ * "render a QR code / pairing link"). Used for the daemon pairing link.
4
+ */
5
+ export declare function renderQrToTerminal(text: string): Promise<string>;
6
+ //# sourceMappingURL=qr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr.d.ts","sourceRoot":"","sources":["../src/qr.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhE"}
package/dist/qr.js ADDED
@@ -0,0 +1,9 @@
1
+ import QRCode from "qrcode";
2
+ /**
3
+ * Render a string as a QR code drawn with terminal block characters (features/cli.md § Behavior —
4
+ * "render a QR code / pairing link"). Used for the daemon pairing link.
5
+ */
6
+ export function renderQrToTerminal(text) {
7
+ return QRCode.toString(text, { type: "terminal", small: true });
8
+ }
9
+ //# sourceMappingURL=qr.js.map
package/dist/qr.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr.js","sourceRoot":"","sources":["../src/qr.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@av-pi-studio/cli",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "bin": {
11
+ "pi-studio": "dist/cli.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "tsc -b && chmod +x dist/cli.js",
21
+ "clean": "rm -rf dist *.tsbuildinfo"
22
+ },
23
+ "dependencies": {
24
+ "@av-pi-studio/client": "^0.0.1",
25
+ "@av-pi-studio/protocol": "^0.0.1",
26
+ "bcryptjs": "^3.0.3",
27
+ "commander": "^14.0.3",
28
+ "qrcode": "^1.5.4"
29
+ },
30
+ "devDependencies": {
31
+ "@types/bcryptjs": "^3.0.0",
32
+ "@types/qrcode": "^1.5.6"
33
+ }
34
+ }