localpov 0.1.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +309 -0
  3. package/bin/localpov-mcp.js +15 -0
  4. package/bin/localpov.js +599 -0
  5. package/dashboard/index.html +909 -0
  6. package/dist/collectors/browser-capture.d.ts +124 -0
  7. package/dist/collectors/browser-capture.js +327 -0
  8. package/dist/collectors/browser-capture.js.map +1 -0
  9. package/dist/collectors/build-parser.d.ts +18 -0
  10. package/dist/collectors/build-parser.js +192 -0
  11. package/dist/collectors/build-parser.js.map +1 -0
  12. package/dist/collectors/docker-watcher.d.ts +42 -0
  13. package/dist/collectors/docker-watcher.js +101 -0
  14. package/dist/collectors/docker-watcher.js.map +1 -0
  15. package/dist/collectors/terminal.d.ts +42 -0
  16. package/dist/collectors/terminal.js +128 -0
  17. package/dist/collectors/terminal.js.map +1 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +6 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/mcp-server.d.ts +1 -0
  22. package/dist/mcp-server.js +466 -0
  23. package/dist/mcp-server.js.map +1 -0
  24. package/dist/utils/inject.d.ts +11 -0
  25. package/dist/utils/inject.js +241 -0
  26. package/dist/utils/inject.js.map +1 -0
  27. package/dist/utils/network.d.ts +7 -0
  28. package/dist/utils/network.js +42 -0
  29. package/dist/utils/network.js.map +1 -0
  30. package/dist/utils/proxy.d.ts +24 -0
  31. package/dist/utils/proxy.js +363 -0
  32. package/dist/utils/proxy.js.map +1 -0
  33. package/dist/utils/scanner.d.ts +9 -0
  34. package/dist/utils/scanner.js +96 -0
  35. package/dist/utils/scanner.js.map +1 -0
  36. package/dist/utils/session-manager.d.ts +109 -0
  37. package/dist/utils/session-manager.js +488 -0
  38. package/dist/utils/session-manager.js.map +1 -0
  39. package/dist/utils/shell-init.d.ts +26 -0
  40. package/dist/utils/shell-init.js +422 -0
  41. package/dist/utils/shell-init.js.map +1 -0
  42. package/dist/utils/system-info.d.ts +51 -0
  43. package/dist/utils/system-info.js +170 -0
  44. package/dist/utils/system-info.js.map +1 -0
  45. package/package.json +64 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LocalPOV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,309 @@
1
+ # LocalPOV
2
+
3
+ Development context bridge for AI coding agents. Terminal output, browser console, network failures, Docker logs, build errors — one MCP server.
4
+
5
+ ```
6
+ npx -y localpov --mcp
7
+ ```
8
+
9
+ Your AI agent (Claude Code, Cursor, Windsurf, Claude Desktop) can now see everything happening in your dev environment — terminal errors, browser console output, failed network requests, build failures, Docker logs — without you copy-pasting anything.
10
+
11
+ ## Why
12
+
13
+ AI coding agents are blind. They can read and write files, but they can't see:
14
+
15
+ - What your terminal just printed
16
+ - That the browser console is full of CORS errors
17
+ - That `fetch('/api/users')` is returning 500
18
+ - That the Docker container crashed 30 seconds ago
19
+ - That TypeScript found 12 errors on build
20
+
21
+ You end up copy-pasting error messages into chat. LocalPOV fixes this — the agent reads your dev environment directly.
22
+
23
+ ## Quick start
24
+
25
+ ```bash
26
+ # Install globally (optional — npx works without installing)
27
+ npm i -g localpov
28
+
29
+ # Interactive setup (shell integration + MCP config)
30
+ localpov setup
31
+
32
+ # Or just start the MCP server directly
33
+ npx -y localpov --mcp
34
+ ```
35
+
36
+ ## Setup for your AI client
37
+
38
+ LocalPOV works with every major AI coding tool. Pick yours:
39
+
40
+ ### Claude Code
41
+
42
+ Add to `.mcp.json` in your project root:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "localpov": {
48
+ "command": "npx",
49
+ "args": ["-y", "localpov", "--mcp"]
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ Or run `localpov mcp-config` to generate this automatically.
56
+
57
+ ### Claude Desktop
58
+
59
+ Add to your `claude_desktop_config.json`:
60
+
61
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
62
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
63
+
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "localpov": {
68
+ "command": "npx",
69
+ "args": ["-y", "localpov", "--mcp"]
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ### Cursor
76
+
77
+ Add to `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "localpov": {
83
+ "command": "npx",
84
+ "args": ["-y", "localpov", "--mcp"]
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Windsurf
91
+
92
+ Add to your MCP config:
93
+
94
+ - **macOS/Linux**: `~/.codeium/windsurf/mcp_config.json`
95
+ - **Windows**: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
96
+
97
+ ```json
98
+ {
99
+ "mcpServers": {
100
+ "localpov": {
101
+ "command": "npx",
102
+ "args": ["-y", "localpov", "--mcp"]
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ Or configure via Windsurf UI: Cascade panel → MCPs icon → Add server.
109
+
110
+ ### Any other MCP client
111
+
112
+ LocalPOV uses **stdio transport** — the universal standard. Any MCP client that supports stdio works with:
113
+
114
+ ```json
115
+ {
116
+ "command": "npx",
117
+ "args": ["-y", "localpov", "--mcp"]
118
+ }
119
+ ```
120
+
121
+ ### Local development (from source)
122
+
123
+ If you've cloned the repo:
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "localpov": {
129
+ "command": "node",
130
+ "args": ["bin/localpov-mcp.js"]
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ ## What the AI agent sees
137
+
138
+ 14 tools available via MCP:
139
+
140
+ | Tool | What it does |
141
+ |------|-------------|
142
+ | `get_diagnostics` | One-call health check: terminal errors, browser console, network failures, port status, memory |
143
+ | `list_sessions` | All captured terminal sessions (PID, shell, alive/dead) |
144
+ | `read_terminal` | Last N lines from any terminal session, with pagination |
145
+ | `read_command` | Output of a specific command by index (supports negative indexing) |
146
+ | `get_errors` | Errors across all sessions (JS, TS, Python, Rust, Go patterns) |
147
+ | `search_all` | Regex search across all terminal output |
148
+ | `read_browser` | Browser console errors + failed/slow network requests |
149
+ | `take_screenshot` | Capture browser viewport |
150
+ | `get_build_errors` | Structured build errors: `{file, line, col, message}` |
151
+ | `docker` | List containers or read container logs |
152
+ | `tail_log` | Read last N lines of any log file |
153
+ | `check_ports` | What's listening, what's down |
154
+ | `check_env` | Which env vars exist (never exposes values) |
155
+ | `process_health` | System memory, CPU, uptime |
156
+
157
+ ## How it works
158
+
159
+ ### Terminal capture
160
+
161
+ Shell integration hooks into your shell startup (`bash`, `zsh`, `fish`, `powershell`). Every terminal session's output is captured to `~/.localpov/sessions/` as plain text logs.
162
+
163
+ ```bash
164
+ # Install shell integration
165
+ localpov setup
166
+
167
+ # List captured sessions
168
+ localpov sessions
169
+
170
+ # Read a session
171
+ localpov sessions read <pid> [lines]
172
+
173
+ # Find errors across all sessions
174
+ localpov sessions errors
175
+
176
+ # Remove shell integration
177
+ localpov unsetup
178
+ ```
179
+
180
+ The agent calls `read_terminal` or `get_errors` — it reads these logs directly. No copy-pasting needed.
181
+
182
+ ### Browser capture
183
+
184
+ When the LocalPOV proxy is running, it injects a lightweight capture script into HTML responses. This gives the agent access to:
185
+
186
+ - **Console output** — `console.error`, `console.warn`, unhandled exceptions, promise rejections
187
+ - **Network requests** — failed fetches (4xx/5xx) with response bodies, slow requests, CORS errors
188
+ - **Screenshots** — on-demand viewport capture
189
+
190
+ No browser extension needed. Works in any browser.
191
+
192
+ ```bash
193
+ # Start the proxy (auto-detects running dev servers)
194
+ localpov
195
+
196
+ # Or target a specific port
197
+ localpov --port 3000
198
+
199
+ # Change proxy listen port (default: 4000)
200
+ localpov --listen 8080
201
+ ```
202
+
203
+ Then open `http://localhost:4000` instead of `http://localhost:3000` — your app works exactly the same, but the agent can now see console and network activity.
204
+
205
+ ### Dashboard
206
+
207
+ Open `http://localhost:4000/__localpov__/` to see a visual debug panel:
208
+
209
+ - **Apps** — detected dev servers with one-click preview
210
+ - **Terminal** — live terminal output stream
211
+ - **Debug** — console errors, network failures, and system health in real-time
212
+
213
+ ### Architecture
214
+
215
+ ```
216
+ Terminal sessions LocalPOV MCP Server AI Agent
217
+ (bash/zsh/ps) | (Claude Code,
218
+ | | Cursor, etc.)
219
+ | ~/.localpov/sessions/ | read_terminal |
220
+ |------------------------->|<------------------------|
221
+ | |
222
+ Browser --> localpov proxy (:4000)| read_browser |
223
+ | injects capture |<------------------------|
224
+ | script into HTML | |
225
+ | | take_screenshot |
226
+ | console + fetch |<------------------------|
227
+ | errors captured | |
228
+ | get_diagnostics |
229
+ Docker containers |<------------------------|
230
+ | docker logs | |
231
+ |------------------------------>| docker |
232
+ |<------------------------|
233
+ ```
234
+
235
+ ## Config file
236
+
237
+ Create `.localpovrc` in your project root:
238
+
239
+ ```json
240
+ {
241
+ "port": 3000,
242
+ "listen": 4000,
243
+ "ports": [3000, 3001, 5173, 8080]
244
+ }
245
+ ```
246
+
247
+ CLI flags override config file values.
248
+
249
+ ## CLI reference
250
+
251
+ ```bash
252
+ localpov # Start proxy (auto-detect dev servers)
253
+ localpov --port 3000 # Proxy a specific port
254
+ localpov --listen 8080 # Change proxy listen port
255
+ localpov --mcp # Start MCP server (stdio transport)
256
+ localpov setup # Interactive first-run setup
257
+ localpov setup --shell # Install shell integration only
258
+ localpov unsetup # Remove shell integration
259
+ localpov mcp-config # Print MCP config JSON
260
+ localpov mcp-config cursor # Print config for Cursor
261
+ localpov sessions # List captured terminal sessions
262
+ localpov sessions read PID # Read a session's output
263
+ localpov sessions errors # Find errors across sessions
264
+ localpov doctor # Check your setup
265
+ ```
266
+
267
+ ## Supported shells
268
+
269
+ | Shell | Capture method | Platforms |
270
+ |-------|---------------|-----------|
271
+ | bash | `script` command + preexec/precmd hooks | Linux, macOS |
272
+ | zsh | `script` command + preexec/precmd hooks | Linux, macOS |
273
+ | fish | `script` command + fish_preexec/fish_postexec | Linux, macOS |
274
+ | PowerShell | `Start-Transcript` + prompt function flush | Windows, Linux, macOS |
275
+
276
+ ## Supported frameworks
277
+
278
+ Any HTTP dev server works. Framework detection is cosmetic (shown in dashboard):
279
+
280
+ Next.js, Vite, Express, Angular, SvelteKit, Nuxt, Astro, Django, Flask, FastAPI, and anything else on a localhost port.
281
+
282
+ ## Default scanned ports
283
+
284
+ `3000, 3001, 3002, 4200, 5173, 5174, 5175, 8000, 8080, 8888, 8081, 4321`
285
+
286
+ Customize via `.localpovrc`:
287
+
288
+ ```json
289
+ {
290
+ "ports": [3000, 3001, 4000, 5173, 8080, 9000]
291
+ }
292
+ ```
293
+
294
+ ## Safety
295
+
296
+ - **Output capped at 50KB** per MCP response — prevents flooding the AI context
297
+ - **Environment values never exposed** — `check_env` only reports existence (true/false)
298
+ - **File access restricted** — `tail_log` only reads from cwd, `~/.localpov/`, `/var/log/`, `/tmp/`
299
+ - **Sensitive paths blocked** — `.ssh`, `.env`, credentials files are never readable
300
+ - **WebSocket limits** — max 50 connections, 64KB message size cap
301
+ - **Stale data cleanup** — sessions >24h and browser data >4h auto-cleaned
302
+
303
+ ## Requirements
304
+
305
+ - Node.js 18+
306
+
307
+ ## License
308
+
309
+ MIT
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ // MCP server entry point — used by AI coding agents
4
+ // Configure in .claude/settings.json, .cursor/mcp.json, etc:
5
+ //
6
+ // {
7
+ // "mcpServers": {
8
+ // "localpov": {
9
+ // "command": "npx",
10
+ // "args": ["localpov", "--mcp"]
11
+ // }
12
+ // }
13
+ // }
14
+
15
+ require('../dist/mcp-server');