@singhak/nodeui-cli 0.0.0-stage → 0.5.0

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,3 +1,79 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @singhak/nodeui-cli
2
+
3
+ Command line for NodeUI: attach the console to **any Node app without changing its code**, watch **several services from one page**, and expose the data to AI agents over MCP.
4
+
5
+ ```bash
6
+ npx @singhak/nodeui-cli attach -- node server.js
7
+ npx @singhak/nodeui-cli attach -- npm run dev
8
+ npx @singhak/nodeui-cli dashboard api=http://127.0.0.1:3000 worker=http://127.0.0.1:3001
9
+ ```
10
+
11
+ ## `attach`
12
+
13
+ Runs your command with a small preload (`NODE_OPTIONS=--require …`) that wraps `http.Server` / `https.Server`. The console is served on **your app's own port** under `/nodeui`, and the terminal prints the URL once the app is listening:
14
+
15
+ ```
16
+ [nodeui] console: http://127.0.0.1:3000/nodeui/
17
+ ```
18
+
19
+ | Option | Effect |
20
+ | ------------------ | ------------------------------------------------ |
21
+ | `--path <prefix>` | console path (default `/nodeui`) |
22
+ | `--token <secret>` | require an access token |
23
+ | `--persist <file>` | journal that survives restarts |
24
+ | `--otlp <url>` | export spans to an OTLP/HTTP collector |
25
+ | `--bodies` | capture request/response bodies (masked, capped) |
26
+ | `--force` | attach even when `NODE_ENV=production` |
27
+
28
+ What you get: requests, outgoing calls, logs, errors, health, memory/CPU/event loop, and queries from `pg`/`mysql2`. What you do not: route **patterns** and the route table for frameworks that expose them only through an adapter (Express still gets `req.route` patterns; Fastify, Koa, Hapi and Hono need their adapter), and Prisma (`server.trackPrisma`) or other manual hooks.
29
+
30
+ Notes and limits:
31
+
32
+ - It does not attach to an already running process; start the app through the CLI. Node cannot inject code into a process that is already running.
33
+ - Do not combine it with a NodeUI adapter in the same app: requests would be recorded twice.
34
+ - Production stays fail-closed: with `NODE_ENV=production` nothing is attached unless you pass `--force`. The usual loopback, Host and Origin checks apply.
35
+ - Child processes inherit `NODE_OPTIONS`, so tools that fork workers (e.g. `npm run dev`) attach in each Node process that creates an HTTP server.
36
+
37
+ ## `dashboard`
38
+
39
+ One loopback page that lists several running consoles with health, request count, error rate, p95 and error groups, and opens any of them through a proxy at `/s/<name>/`:
40
+
41
+ ```bash
42
+ nodeui dashboard --port 4000 api=http://127.0.0.1:3000 billing=http://127.0.0.1:3100/nodeui?token=secret
43
+ ```
44
+
45
+ - A service entry is `name=url` or just `url`; the console path defaults to `/nodeui`; `?token=` is the service's access token and is sent as a bearer header by the proxy (never put into the page).
46
+ - The dashboard is loopback-only, rejects foreign `Host` and `Origin` headers, and strips cookies/origin when proxying so each service's own checks still apply.
47
+ - Each service keeps its own data; the dashboard stores nothing.
48
+
49
+ ## `mcp` (AI agents)
50
+
51
+ A [Model Context Protocol](https://modelcontextprotocol.io) server over stdio, so an agent (Claude Code, Cursor, …) can read what your app is doing instead of you pasting logs:
52
+
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "nodeui": { "command": "npx", "args": ["@singhak/nodeui-cli", "mcp", "http://127.0.0.1:3000"] }
57
+ }
58
+ }
59
+ ```
60
+
61
+ Give it one console URL, or several as `name=url` (tools then take a `service` argument). Tools, all **read-only**:
62
+
63
+ | Tool | Returns |
64
+ | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | `nodeui_overview` | start here: prioritised digest of health, traffic, grouped errors, failing/slow requests, slow and N+1 queries, failing outgoing calls |
66
+ | `nodeui_errors` | grouped errors with stacks and the last linked request |
67
+ | `nodeui_requests` | recent requests; filter by `minStatus` / `minDurationMs` |
68
+ | `nodeui_request` | one request joined with its outgoing calls, queries and log lines |
69
+ | `nodeui_queries`, `nodeui_outgoing`, `nodeui_logs`, `nodeui_routes` | the matching panels, trimmed |
70
+
71
+ It reads the console's REST API, so everything is already masked, and it never calls heap snapshots or any confirmation-gated action. An agent sees only what the console would show you, and only on your machine unless you point it elsewhere.
72
+
73
+ ## Programmatic use
74
+
75
+ ```ts
76
+ import { startDashboard, parseTarget } from '@singhak/nodeui-cli';
77
+
78
+ const dashboard = await startDashboard({ services: [parseTarget('api=http://127.0.0.1:3000')] });
79
+ ```