pi-web 0.0.1 → 0.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +27 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "description": "Web UI for the pi coding agent",
6
6
  "bin": {
package/server.js CHANGED
@@ -6,7 +6,31 @@ import { WebSocketServer, WebSocket } from "ws";
6
6
  import { RpcSession } from "./rpc.js";
7
7
  import { listSessions, readSessionMessages } from "./sessions.js";
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const PORT = parseInt(process.env.PORT || "3100", 10);
9
+ if (process.argv.includes("--help") || process.argv.includes("-h")) {
10
+ console.log(`
11
+ pi-web - Web UI for the pi coding agent
12
+
13
+ Usage: pi-web [options]
14
+
15
+ Options:
16
+ --port <number> Port to listen on (default: 3100, env: PORT)
17
+ --host <string> Host to bind to (default: localhost, env: HOST)
18
+ -h, --help Show this help message
19
+ `.trim());
20
+ process.exit(0);
21
+ }
22
+ function getArg(name) {
23
+ const flag = `--${name}=`;
24
+ const pair = process.argv.find((a) => a.startsWith(flag));
25
+ if (pair)
26
+ return pair.slice(flag.length);
27
+ const idx = process.argv.indexOf(`--${name}`);
28
+ if (idx !== -1 && process.argv[idx + 1] && !process.argv[idx + 1].startsWith("--"))
29
+ return process.argv[idx + 1];
30
+ return undefined;
31
+ }
32
+ const PORT = parseInt(getArg("port") || process.env.PORT || "3100", 10);
33
+ const HOST = getArg("host") || process.env.HOST || "localhost";
10
34
  const PI_CMD = process.env.PI_CMD || "npx -y @mariozechner/pi-coding-agent@latest";
11
35
  const isDev = process.argv.includes("--watch") || process.env.NODE_ENV === "development";
12
36
  const distDir = join(__dirname, "dist");
@@ -149,6 +173,6 @@ wss.on("connection", (ws) => {
149
173
  rpcSessions.delete(ws);
150
174
  });
151
175
  });
152
- server.listen(PORT, () => {
153
- console.log(`pi-web running at http://localhost:${PORT}`);
176
+ server.listen(PORT, HOST, () => {
177
+ console.log(`pi-web running at http://${HOST}:${PORT}`);
154
178
  });