pi-kot 0.1.10 → 0.1.12

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 CHANGED
@@ -1,4 +1,4 @@
1
- # pi-kot v0.1.10
1
+ # pi-kot v0.1.12
2
2
 
3
3
  Browser UI for the [pi coding agent](https://pi.dev).
4
4
  Self-hosted React workbench: streaming chat, session tree, file browser, terminal, git panel.
package/bin/pi-kot.mjs CHANGED
@@ -1,136 +1,136 @@
1
- #!/usr/bin/env node
2
- /**
3
- * pi-kot CLI launcher.
4
- *
5
- * Published npm package layout:
6
- *
7
- * pi-kot/
8
- * ├── bin/pi-kot.mjs ← this file (npm links as the binary)
9
- * ├── dist/server/ ← compiled Fastify server
10
- * └── dist/client/ ← compiled Vite SPA
11
- *
12
- * The server's default CLIENT_DIST_PATH resolves relative to its own
13
- * compiled file, which works for the in-repo dev flow but NOT for the
14
- * flat published package. We override it here so the same server entry
15
- * point works in all deployment shapes without touching server code.
16
- *
17
- * Supported env vars (all optional):
18
- * PORT default 3333
19
- * HOST default 0.0.0.0 (use 127.0.0.1 for loopback-only)
20
- * UI_PASSWORD enable password auth
21
- * API_KEY static API key for scripts/CI
22
- * WORKSPACE_PATH default ~/.pi-kot/workspace/default
23
- * LOG_LEVEL default info
24
- *
25
- * Supported flags:
26
- * --port <n>
27
- * --host <h>
28
- * --password <pw> sets UI_PASSWORD
29
- * --api-key <key> sets API_KEY
30
- * --workspace <path> sets WORKSPACE_PATH
31
- * --log-level <level>
32
- * --help / -h
33
- * --version / -v
34
- */
35
- import { readFileSync } from "node:fs";
36
- import { dirname, resolve } from "node:path";
37
- import { fileURLToPath, pathToFileURL } from "node:url";
38
- import { homedir } from "node:os";
39
-
40
- const here = dirname(fileURLToPath(import.meta.url));
41
- const packageRoot = resolve(here, "..");
42
- const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
43
-
44
- // ── Flag parser ──────────────────────────────────────────────────────────────
45
-
46
- const args = process.argv.slice(2);
47
-
48
- if (args.includes("--help") || args.includes("-h")) {
49
- process.stdout.write(`
50
- pi-kot v${pkg.version} — Browser UI for the pi coding agent
51
-
52
- Usage:
53
- npx pi-kot [options]
54
- pi-kot [options]
55
-
56
- Options:
57
- --port <n> Port to listen on (default: 3333)
58
- --host <h> Host/interface to bind to (default: 0.0.0.0)
59
- --password <pw> Enable UI password auth
60
- --api-key <key> Static API key for scripts/CI
61
- --workspace <path> Workspace root directory (default: ~/.pi-kot/workspace/default)
62
- --log-level <level> Logging level (default: info)
63
- --help, -h Show this help
64
- --version, -v Show version
65
-
66
- All options can also be set via environment variables:
67
- PORT, HOST, UI_PASSWORD, API_KEY, WORKSPACE_PATH, LOG_LEVEL
68
-
69
- Examples:
70
- npx pi-kot
71
- npx pi-kot --port 4000 --workspace ~/Code
72
- npx pi-kot --password secret --host 127.0.0.1
73
- PORT=8080 npx pi-kot
74
- `.trimStart());
75
- process.exit(0);
76
- }
77
-
78
- if (args.includes("--version") || args.includes("-v")) {
79
- process.stdout.write(`pi-kot ${pkg.version}\n`);
80
- process.exit(0);
81
- }
82
-
83
- // Parse --flag value pairs and apply to process.env before config.ts loads
84
- const flagMap = {
85
- "--port": "PORT",
86
- "--host": "HOST",
87
- "--password": "UI_PASSWORD",
88
- "--api-key": "API_KEY",
89
- "--workspace": "WORKSPACE_PATH",
90
- "--log-level": "LOG_LEVEL",
91
- };
92
-
93
- for (let i = 0; i < args.length; i++) {
94
- const envKey = flagMap[args[i]];
95
- if (envKey !== undefined) {
96
- const val = args[i + 1];
97
- if (val === undefined || val.startsWith("--")) {
98
- process.stderr.write(`pi-kot: ${args[i]} requires a value\n`);
99
- process.exit(2);
100
- }
101
- process.env[envKey] = val;
102
- i++; // skip value
103
- } else {
104
- process.stderr.write(`pi-kot: unknown option: ${args[i]}\n`);
105
- process.stderr.write(`pi-kot: run with --help for usage\n`);
106
- process.exit(2);
107
- }
108
- }
109
-
110
- // ── Bootstrap ────────────────────────────────────────────────────────────────
111
-
112
- // Override CLIENT_DIST_PATH so the server finds the client in the flat
113
- // published layout (dist/client/) rather than the in-repo relative path.
114
- process.env.CLIENT_DIST_PATH ??= resolve(packageRoot, "dist", "client");
115
- process.env.NODE_ENV ??= "production";
116
-
117
- // Auto-mount the current working directory as a project if it's not the
118
- // workspace root itself. This makes `npx pi-kot` from any project folder
119
- // show that folder in the project list automatically.
120
- const cwd = process.cwd();
121
- const defaultWorkspace = resolve(homedir(), ".pi-kot", "workspace", "default");
122
- const workspacePath = resolve(process.env.WORKSPACE_PATH ?? defaultWorkspace);
123
- if (cwd !== workspacePath) {
124
- process.env.MOUNT_CWD_PROJECT = cwd;
125
- }
126
-
127
- // Log startup info
128
- const port = process.env.PORT ?? "3333";
129
- const host = process.env.HOST ?? "0.0.0.0";
130
- const displayHost = host === "0.0.0.0" ? "localhost" : host;
131
- process.stdout.write(`pi-kot v${pkg.version} starting on http://${displayHost}:${port}\n`);
132
-
133
- // Import and start the server
134
- const serverEntry = resolve(packageRoot, "dist", "server", "index.js");
135
- const { start } = await import(pathToFileURL(serverEntry).href);
136
- await start();
1
+ #!/usr/bin/env node
2
+ /**
3
+ * pi-kot CLI launcher.
4
+ *
5
+ * Published npm package layout:
6
+ *
7
+ * pi-kot/
8
+ * ├── bin/pi-kot.mjs ← this file (npm links as the binary)
9
+ * ├── dist/server/ ← compiled Fastify server
10
+ * └── dist/client/ ← compiled Vite SPA
11
+ *
12
+ * The server's default CLIENT_DIST_PATH resolves relative to its own
13
+ * compiled file, which works for the in-repo dev flow but NOT for the
14
+ * flat published package. We override it here so the same server entry
15
+ * point works in all deployment shapes without touching server code.
16
+ *
17
+ * Supported env vars (all optional):
18
+ * PORT default 3333
19
+ * HOST default 0.0.0.0 (use 127.0.0.1 for loopback-only)
20
+ * UI_PASSWORD enable password auth
21
+ * API_KEY static API key for scripts/CI
22
+ * WORKSPACE_PATH default ~/.pi-kot/workspace/default
23
+ * LOG_LEVEL default info
24
+ *
25
+ * Supported flags:
26
+ * --port <n>
27
+ * --host <h>
28
+ * --password <pw> sets UI_PASSWORD
29
+ * --api-key <key> sets API_KEY
30
+ * --workspace <path> sets WORKSPACE_PATH
31
+ * --log-level <level>
32
+ * --help / -h
33
+ * --version / -v
34
+ */
35
+ import { readFileSync } from "node:fs";
36
+ import { dirname, resolve } from "node:path";
37
+ import { fileURLToPath, pathToFileURL } from "node:url";
38
+ import { homedir } from "node:os";
39
+
40
+ const here = dirname(fileURLToPath(import.meta.url));
41
+ const packageRoot = resolve(here, "..");
42
+ const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
43
+
44
+ // ── Flag parser ──────────────────────────────────────────────────────────────
45
+
46
+ const args = process.argv.slice(2);
47
+
48
+ if (args.includes("--help") || args.includes("-h")) {
49
+ process.stdout.write(`
50
+ pi-kot v${pkg.version} — Browser UI for the pi coding agent
51
+
52
+ Usage:
53
+ npx pi-kot [options]
54
+ pi-kot [options]
55
+
56
+ Options:
57
+ --port <n> Port to listen on (default: 3333)
58
+ --host <h> Host/interface to bind to (default: 0.0.0.0)
59
+ --password <pw> Enable UI password auth
60
+ --api-key <key> Static API key for scripts/CI
61
+ --workspace <path> Workspace root directory (default: ~/.pi-kot/workspace/default)
62
+ --log-level <level> Logging level (default: info)
63
+ --help, -h Show this help
64
+ --version, -v Show version
65
+
66
+ All options can also be set via environment variables:
67
+ PORT, HOST, UI_PASSWORD, API_KEY, WORKSPACE_PATH, LOG_LEVEL
68
+
69
+ Examples:
70
+ npx pi-kot
71
+ npx pi-kot --port 4000 --workspace ~/Code
72
+ npx pi-kot --password secret --host 127.0.0.1
73
+ PORT=8080 npx pi-kot
74
+ `.trimStart());
75
+ process.exit(0);
76
+ }
77
+
78
+ if (args.includes("--version") || args.includes("-v")) {
79
+ process.stdout.write(`pi-kot ${pkg.version}\n`);
80
+ process.exit(0);
81
+ }
82
+
83
+ // Parse --flag value pairs and apply to process.env before config.ts loads
84
+ const flagMap = {
85
+ "--port": "PORT",
86
+ "--host": "HOST",
87
+ "--password": "UI_PASSWORD",
88
+ "--api-key": "API_KEY",
89
+ "--workspace": "WORKSPACE_PATH",
90
+ "--log-level": "LOG_LEVEL",
91
+ };
92
+
93
+ for (let i = 0; i < args.length; i++) {
94
+ const envKey = flagMap[args[i]];
95
+ if (envKey !== undefined) {
96
+ const val = args[i + 1];
97
+ if (val === undefined || val.startsWith("--")) {
98
+ process.stderr.write(`pi-kot: ${args[i]} requires a value\n`);
99
+ process.exit(2);
100
+ }
101
+ process.env[envKey] = val;
102
+ i++; // skip value
103
+ } else {
104
+ process.stderr.write(`pi-kot: unknown option: ${args[i]}\n`);
105
+ process.stderr.write(`pi-kot: run with --help for usage\n`);
106
+ process.exit(2);
107
+ }
108
+ }
109
+
110
+ // ── Bootstrap ────────────────────────────────────────────────────────────────
111
+
112
+ // Override CLIENT_DIST_PATH so the server finds the client in the flat
113
+ // published layout (dist/client/) rather than the in-repo relative path.
114
+ process.env.CLIENT_DIST_PATH ??= resolve(packageRoot, "dist", "client");
115
+ process.env.NODE_ENV ??= "production";
116
+
117
+ // Auto-mount the current working directory as a project if it's not the
118
+ // workspace root itself. This makes `npx pi-kot` from any project folder
119
+ // show that folder in the project list automatically.
120
+ const cwd = process.cwd();
121
+ const defaultWorkspace = resolve(homedir(), ".pi-kot", "workspace", "default");
122
+ const workspacePath = resolve(process.env.WORKSPACE_PATH ?? defaultWorkspace);
123
+ if (cwd !== workspacePath) {
124
+ process.env.MOUNT_CWD_PROJECT = cwd;
125
+ }
126
+
127
+ // Log startup info
128
+ const port = process.env.PORT ?? "3333";
129
+ const host = process.env.HOST ?? "0.0.0.0";
130
+ const displayHost = host === "0.0.0.0" ? "localhost" : host;
131
+ process.stdout.write(`pi-kot v${pkg.version} starting on http://${displayHost}:${port}\n`);
132
+
133
+ // Import and start the server
134
+ const serverEntry = resolve(packageRoot, "dist", "server", "index.js");
135
+ const { start } = await import(pathToFileURL(serverEntry).href);
136
+ await start();