proofscan 0.1.1 → 0.3.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 (109) hide show
  1. package/README.md +231 -159
  2. package/dist/cli.d.ts +15 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +129 -7
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/archive.d.ts +6 -0
  7. package/dist/commands/archive.d.ts.map +1 -0
  8. package/dist/commands/archive.js +245 -0
  9. package/dist/commands/archive.js.map +1 -0
  10. package/dist/commands/explore.d.ts +9 -0
  11. package/dist/commands/explore.d.ts.map +1 -0
  12. package/dist/commands/explore.js +345 -0
  13. package/dist/commands/explore.js.map +1 -0
  14. package/dist/commands/index.d.ts +6 -0
  15. package/dist/commands/index.d.ts.map +1 -1
  16. package/dist/commands/index.js +8 -0
  17. package/dist/commands/index.js.map +1 -1
  18. package/dist/commands/monitor.d.ts +1 -1
  19. package/dist/commands/monitor.d.ts.map +1 -1
  20. package/dist/commands/monitor.js +33 -21
  21. package/dist/commands/monitor.js.map +1 -1
  22. package/dist/commands/scan.d.ts.map +1 -1
  23. package/dist/commands/scan.js +4 -0
  24. package/dist/commands/scan.js.map +1 -1
  25. package/dist/commands/sessions.d.ts +6 -0
  26. package/dist/commands/sessions.d.ts.map +1 -0
  27. package/dist/commands/sessions.js +203 -0
  28. package/dist/commands/sessions.js.map +1 -0
  29. package/dist/commands/status.d.ts +7 -0
  30. package/dist/commands/status.d.ts.map +1 -0
  31. package/dist/commands/status.js +108 -0
  32. package/dist/commands/status.js.map +1 -0
  33. package/dist/commands/tree.d.ts +7 -0
  34. package/dist/commands/tree.d.ts.map +1 -0
  35. package/dist/commands/tree.js +184 -0
  36. package/dist/commands/tree.js.map +1 -0
  37. package/dist/commands/view.d.ts +9 -0
  38. package/dist/commands/view.d.ts.map +1 -0
  39. package/dist/commands/view.js +143 -0
  40. package/dist/commands/view.js.map +1 -0
  41. package/dist/db/connection.d.ts +28 -0
  42. package/dist/db/connection.d.ts.map +1 -0
  43. package/dist/db/connection.js +123 -0
  44. package/dist/db/connection.js.map +1 -0
  45. package/dist/db/events-store.d.ts +56 -0
  46. package/dist/db/events-store.d.ts.map +1 -0
  47. package/dist/db/events-store.js +269 -0
  48. package/dist/db/events-store.js.map +1 -0
  49. package/dist/db/index.d.ts +6 -0
  50. package/dist/db/index.d.ts.map +1 -0
  51. package/dist/db/index.js +6 -0
  52. package/dist/db/index.js.map +1 -0
  53. package/dist/db/proofs-store.d.ts +56 -0
  54. package/dist/db/proofs-store.d.ts.map +1 -0
  55. package/dist/db/proofs-store.js +116 -0
  56. package/dist/db/proofs-store.js.map +1 -0
  57. package/dist/db/schema.d.ts +8 -0
  58. package/dist/db/schema.d.ts.map +1 -0
  59. package/dist/db/schema.js +76 -0
  60. package/dist/db/schema.js.map +1 -0
  61. package/dist/db/types.d.ts +64 -0
  62. package/dist/db/types.d.ts.map +1 -0
  63. package/dist/db/types.js +5 -0
  64. package/dist/db/types.js.map +1 -0
  65. package/dist/eventline/index.d.ts +8 -0
  66. package/dist/eventline/index.d.ts.map +1 -0
  67. package/dist/eventline/index.js +8 -0
  68. package/dist/eventline/index.js.map +1 -0
  69. package/dist/eventline/normalizer.d.ts +61 -0
  70. package/dist/eventline/normalizer.d.ts.map +1 -0
  71. package/dist/eventline/normalizer.js +298 -0
  72. package/dist/eventline/normalizer.js.map +1 -0
  73. package/dist/eventline/schema-discovery.d.ts +79 -0
  74. package/dist/eventline/schema-discovery.d.ts.map +1 -0
  75. package/dist/eventline/schema-discovery.js +154 -0
  76. package/dist/eventline/schema-discovery.js.map +1 -0
  77. package/dist/eventline/store.d.ts +88 -0
  78. package/dist/eventline/store.d.ts.map +1 -0
  79. package/dist/eventline/store.js +358 -0
  80. package/dist/eventline/store.js.map +1 -0
  81. package/dist/eventline/types.d.ts +88 -0
  82. package/dist/eventline/types.d.ts.map +1 -0
  83. package/dist/eventline/types.js +67 -0
  84. package/dist/eventline/types.js.map +1 -0
  85. package/dist/index.d.ts +14 -6
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +15 -6
  88. package/dist/index.js.map +1 -1
  89. package/dist/scanner/index.d.ts +3 -2
  90. package/dist/scanner/index.d.ts.map +1 -1
  91. package/dist/scanner/index.js +66 -51
  92. package/dist/scanner/index.js.map +1 -1
  93. package/dist/types/config.d.ts +7 -0
  94. package/dist/types/config.d.ts.map +1 -1
  95. package/dist/types/config.js +5 -0
  96. package/dist/types/config.js.map +1 -1
  97. package/dist/types/events.d.ts +1 -17
  98. package/dist/types/events.d.ts.map +1 -1
  99. package/dist/types/events.js +1 -0
  100. package/dist/types/events.js.map +1 -1
  101. package/package.json +3 -1
  102. package/dist/events/index.d.ts +0 -2
  103. package/dist/events/index.d.ts.map +0 -1
  104. package/dist/events/index.js +0 -2
  105. package/dist/events/index.js.map +0 -1
  106. package/dist/events/store.d.ts +0 -25
  107. package/dist/events/store.d.ts.map +0 -1
  108. package/dist/events/store.js +0 -91
  109. package/dist/events/store.js.map +0 -1
package/README.md CHANGED
@@ -8,8 +8,9 @@ proofscan provides visibility into MCP (Model Context Protocol) server communica
8
8
 
9
9
  - Connects to MCP servers via stdio transport
10
10
  - Captures all JSON-RPC messages (requests, responses, notifications)
11
- - Stores events in JSONL format for later analysis
11
+ - Stores events in SQLite for efficient querying and analysis
12
12
  - Supports importing server configurations from mcp.so / Claude Desktop format
13
+ - Provides intuitive CLI commands for viewing and exploring data
13
14
 
14
15
  ## Installation
15
16
 
@@ -23,99 +24,195 @@ Or run without installing:
23
24
  npx proofscan --help
24
25
  ```
25
26
 
26
- ## CLI Commands
27
+ ## CLI Commands (v0.3.0)
27
28
 
28
29
  The CLI is available as both `pfscan` (short) and `proofscan` (full).
29
30
 
31
+ ### Command Structure (git-style)
32
+
33
+ ```
34
+ Common Commands:
35
+ view, v View recent events timeline (default)
36
+ tree, t Show connector → session → rpc structure
37
+ explore, e Interactive data browser
38
+ scan, s Run a new scan
39
+ status, st Show system status
40
+
41
+ Management:
42
+ archive, a Archive and prune old data
43
+ config, c Configuration management
44
+ connectors Connector management
45
+
46
+ Shortcuts:
47
+ v=view t=tree e=explore s=scan st=status a=archive c=config
48
+ ```
49
+
50
+ **Note:** Running `pfscan` without arguments is equivalent to `pfscan view`.
51
+
30
52
  ## Quickstart
31
53
 
32
54
  ### 1. Initialize Configuration
33
55
 
34
56
  ```bash
35
- # Create config in OS-standard location
36
57
  pfscan config init
37
-
38
- # Check where config is stored
39
- pfscan config path
58
+ pfscan config path # Show config location
40
59
  ```
41
60
 
42
- ### 2. Import MCP Server from mcp.so / Claude Desktop
43
-
44
- Copy the `mcpServers` JSON from mcp.so or Claude Desktop settings and import via stdin:
61
+ ### 2. Import MCP Server
45
62
 
46
63
  ```bash
47
- # Full mcpServers format
48
- echo '{ "mcpServers": { "time": { "command": "uvx", "args": ["mcp-server-time"] } } }' | pfscan connectors import --from mcpServers --stdin
49
-
50
- # Or just the server definition (requires --name)
51
- echo '{ "command": "uvx", "args": ["mcp-server-time"] }' | pfscan connectors import --from mcpServers --stdin --name time
52
-
53
- # Import from file
54
- pfscan connectors import --from mcpServers --file ./servers.json
64
+ # From mcp.so / Claude Desktop format
65
+ echo '{"mcpServers":{"time":{"command":"uvx","args":["mcp-server-time"]}}}' \
66
+ | pfscan connectors import --from mcpServers --stdin
55
67
  ```
56
68
 
57
- ### 3. List Connectors
69
+ ### 3. Scan and View
58
70
 
59
71
  ```bash
60
- pfscan connectors list
72
+ pfscan scan start --id time # Run scan
73
+ pfscan # View recent events (same as pfscan view)
74
+ pfscan tree # Show structure
75
+ pfscan status # Show system status
61
76
  ```
62
77
 
63
- ### 4. Scan a Connector
78
+ ## View Command (Phase 2.1)
79
+
80
+ The `view` command displays a timeline of recent events with millisecond precision.
64
81
 
65
82
  ```bash
66
- pfscan scan start --id time
83
+ $ pfscan view --limit 10
84
+ Time Sym Dir St Method Session Extra
85
+ -------------------------------------------------------------------------
86
+ 21:01:58.743 → → ✓ initialize ses=f2442c... lat=269ms size=183B
87
+ 21:01:59.018 ← ← ✓ initialize ses=f2442c...
88
+ 21:01:59.025 • → notifications/initialized ses=f2442c...
89
+ 21:01:59.037 → → ✓ tools/list ses=f2442c...
90
+ 21:01:59.049 ← ← ✓ tools/list ses=f2442c... lat=12ms size=1.0KB
67
91
  ```
68
92
 
69
- ### 5. View Events
93
+ ### View Options
70
94
 
71
95
  ```bash
72
- pfscan monitor tail --id time --last 20
96
+ pfscan view --limit 50 # Show 50 events
97
+ pfscan view --since 24h # Events in last 24 hours
98
+ pfscan view --since 7d # Events in last 7 days
99
+ pfscan view --errors # Show only errors
100
+ pfscan view --method tools # Filter by method name
101
+ pfscan view --connector time # Filter by connector
102
+ pfscan view --session abc123 # Filter by session (partial match)
103
+ pfscan view --fulltime # Show full timestamp (YYYY-MM-DD HH:MM:SS.mmm)
104
+ pfscan view --with-sessions # Include session start/end events
105
+ pfscan view --json # Output as JSON (EventLine array)
73
106
  ```
74
107
 
75
- ## Commands
108
+ ### Event Symbols
76
109
 
77
- ### Global Options
110
+ | Symbol | Meaning |
111
+ |--------|---------|
112
+ | ▶ | Session start |
113
+ | ■ | Session end |
114
+ | → | Request (Client → Server) |
115
+ | ← | Response (Server → Client) |
116
+ | • | Notification |
117
+ | ✖ | Error |
78
118
 
79
- ```
80
- -c, --config <path> Path to config file
81
- --json Output in JSON format
82
- -v, --verbose Verbose output
119
+ ## Tree Command (Phase 2.1)
120
+
121
+ The `tree` command shows a hierarchical view of connector → session → rpc.
122
+
123
+ ```bash
124
+ $ pfscan tree
125
+ └── 📦 time
126
+ ├── 📋 f2442c9b... (2 rpcs, 8 events)
127
+ │ ├── ↔️ ✓ tools/list (id=2, 12ms)
128
+ │ └── ↔️ ✓ initialize (id=1, 269ms)
129
+ └── 📋 3cf5a66e... (2 rpcs, 8 events)
130
+ ├── ↔️ ✓ tools/list (id=2, 13ms)
131
+ └── ↔️ ✓ initialize (id=1, 271ms)
132
+
133
+ 1 connector(s), 2 session(s), 4 rpc(s)
83
134
  ```
84
135
 
85
- ### Config
136
+ ### Tree Options
86
137
 
87
138
  ```bash
88
- pfscan config path # Show config file path
89
- pfscan config init [--force] # Initialize config
90
- pfscan config show # Show config (secrets masked)
91
- pfscan config validate # Validate config
139
+ pfscan tree time # Show specific connector
140
+ pfscan tree --sessions 10 # Show 10 sessions per connector
141
+ pfscan tree --rpc 20 # Show 20 RPCs per session
142
+ pfscan tree --rpc-all # Show all RPCs
143
+ pfscan tree --method init # Filter by method name
144
+ pfscan tree --status ok # Filter by status (ok, err, all)
145
+ pfscan tree --compact # Compact output (no icons)
146
+ pfscan tree --since 24h # Filter by time
147
+ pfscan tree --json # Output as JSON (TreeNode array)
92
148
  ```
93
149
 
94
- ### Connectors
150
+ ## Explore Command (Phase 2.1)
151
+
152
+ The `explore` command provides interactive navigation through data.
95
153
 
96
154
  ```bash
97
- pfscan connectors list # List all connectors
98
- pfscan connectors show --id <id> # Show connector details
99
- pfscan connectors add --id <id> --stdio "cmd" # Add stdio connector
100
- pfscan connectors enable --id <id> # Enable connector
101
- pfscan connectors disable --id <id> # Disable connector
102
- pfscan connectors remove --id <id> # Remove connector
155
+ $ pfscan explore
156
+ ═══════════════════════════════════════════════════════════════
157
+ proofscan explore
158
+ ═══════════════════════════════════════════════════════════════
159
+ Path: connectors
160
+ ───────────────────────────────────────────────────────────────
103
161
 
104
- # Import from mcpServers format
105
- pfscan connectors import --from mcpServers --stdin
106
- pfscan connectors import --from mcpServers --file <path> [--name <id>]
162
+ Connectors:
163
+
164
+ [1] time (3 sessions)
165
+
166
+ > 1
107
167
  ```
108
168
 
109
- ### Scan
169
+ ### Explore Navigation
170
+
171
+ - **Number**: Select item
172
+ - **b**: Go back
173
+ - **t**: Show tree view
174
+ - **?**: Help
175
+ - **q**: Quit
176
+ - **p**: View request/response pair (in RPC view)
110
177
 
111
178
  ```bash
112
- pfscan scan start --id <id> [--timeout <sec>]
179
+ pfscan explore # Start from connectors
180
+ pfscan explore --session abc123 # Jump to specific session
113
181
  ```
114
182
 
115
- ### Monitor
183
+ ## Status Command (Phase 2.1)
184
+
185
+ The `status` command shows database and system status.
116
186
 
117
187
  ```bash
118
- pfscan monitor tail --id <id> [--last <N>]
188
+ $ pfscan status
189
+ proofscan Status
190
+ ═════════════════════════════════════════════════════
191
+
192
+ Configuration:
193
+ Config file: /home/user/.config/proofscan/config.json
194
+ Data dir: /home/user/.config/proofscan
195
+
196
+ Database:
197
+ events.db: 72.0KB
198
+ proofs.db: 24.0KB
199
+ Schema ver: 1
200
+ Tables: sessions, rpc_calls, events
201
+
202
+ Data Summary:
203
+ Connectors: 1
204
+ Sessions: 3
205
+ RPC calls: 6
206
+ Events: 24
207
+ Latest: 2025-12-28T12:01:58.610Z
208
+ ```
209
+
210
+ ## Global Options
211
+
212
+ ```
213
+ -c, --config <path> Path to config file
214
+ --json Output in JSON format
215
+ -v, --verbose Verbose output
119
216
  ```
120
217
 
121
218
  ## Config File Format
@@ -136,151 +233,126 @@ Config is stored in the OS-standard location:
136
233
  "transport": {
137
234
  "type": "stdio",
138
235
  "command": "uvx",
139
- "args": ["mcp-server-time", "--local-timezone=America/New_York"]
236
+ "args": ["mcp-server-time"]
140
237
  }
141
238
  }
142
- ]
239
+ ],
240
+ "retention": {
241
+ "keep_last_sessions": 50,
242
+ "raw_days": 7,
243
+ "max_db_mb": 500
244
+ }
143
245
  }
144
246
  ```
145
247
 
146
- ## Event Storage
248
+ ### Retention Settings
249
+
250
+ | Setting | Default | Description |
251
+ |---------|---------|-------------|
252
+ | `keep_last_sessions` | 50 | Keep last N sessions per connector |
253
+ | `raw_days` | 7 | Clear raw JSON after N days |
254
+ | `max_db_mb` | 500 | Target database size limit |
147
255
 
148
- Events are stored in JSONL format:
256
+ ## Data Storage
257
+
258
+ proofscan uses a 2-file SQLite structure:
149
259
 
150
260
  ```
151
- ~/.config/proofscan/events/<connector_id>/<YYYYMMDD>.jsonl
261
+ ~/.config/proofscan/
262
+ ├── config.json
263
+ ├── events.db # Sessions, events, RPC calls (can be pruned)
264
+ └── proofs.db # Immutable proof records (never pruned)
152
265
  ```
153
266
 
154
- Each event contains:
155
-
156
- ```json
157
- {
158
- "event_id": "uuid",
159
- "ts": "2024-01-15T10:30:00.000Z",
160
- "connector_id": "time",
161
- "direction": "client_to_server",
162
- "kind": "request",
163
- "method": "tools/list",
164
- "rpc_id": 1,
165
- "ok": true,
166
- "raw": "{...}"
267
+ ### EventLine Model (Phase 2.1)
268
+
269
+ Internally, all events are normalized to the `EventLine` format:
270
+
271
+ ```typescript
272
+ interface EventLine {
273
+ ts_ms: number; // Timestamp (epoch ms)
274
+ kind: 'session_start' | 'session_end' | 'req' | 'res' | 'notify' | 'error';
275
+ direction?: '→' | '←'; // → = Client→Server, ← = Server→Client
276
+ label: string; // Method name or event type
277
+ connector_id?: string;
278
+ session_id?: string;
279
+ rpc_id?: string | number;
280
+ status: 'OK' | 'ERR' | '-';
281
+ latency_ms?: number;
282
+ size_bytes?: number;
283
+ raw_json?: string;
284
+ meta?: Record<string, unknown>;
167
285
  }
168
286
  ```
169
287
 
170
- ## Example Session
288
+ This normalized model allows the schema to evolve without breaking the CLI.
171
289
 
172
- ```bash
173
- # Initialize
174
- $ pfscan config init
175
- ✓ Config created at: /home/user/.config/proofscan/config.json
290
+ ## Archive Command
176
291
 
177
- # Import a server
178
- $ echo '{"mcpServers":{"time":{"command":"uvx","args":["mcp-server-time"]}}}' \
179
- | pfscan connectors import --from mcpServers --stdin
180
- Imported 1 connector(s): time
181
-
182
- # List connectors
183
- $ pfscan connectors list
184
- ID Enabled Type Command/URL
185
- -----------------------------------
186
- time yes stdio uvx mcp-server-time
187
-
188
- # Scan the server
189
- $ pfscan scan start --id time
190
- Scanning connector: time...
191
- ✓ Scan successful!
192
- Connector: time
193
- Tools found: 1
194
- Tool names: get_current_time
195
- Events recorded: 8
196
-
197
- # View events
198
- $ pfscan monitor tail --id time --last 5
199
- Recent events for 'time' (last 5):
200
-
201
- Time Dir Status Kind Summary
202
- ----------------------------------------------------------------------
203
- 10:30:01 → ✓ request initialize
204
- 10:30:01 ← response
205
- 10:30:01 → notification notifications/initialized
206
- 10:30:01 → ✓ request tools/list
207
- 10:30:01 ← response
292
+ Archive and prune old data based on retention settings.
293
+
294
+ ```bash
295
+ pfscan archive status # Show database status
296
+ pfscan archive plan # Show what would be archived
297
+ pfscan archive run # Dry run
298
+ pfscan archive run --yes # Actually execute
299
+ pfscan archive run --yes --vacuum # Execute and reclaim space
208
300
  ```
209
301
 
210
302
  ## JSON Output
211
303
 
212
- Add `--json` for machine-readable output:
304
+ All commands support `--json` for machine-readable output:
213
305
 
214
306
  ```bash
215
- $ pfscan connectors list --json
307
+ $ pfscan view --json --limit 3
216
308
  [
217
309
  {
218
- "ID": "time",
219
- "Enabled": "yes",
220
- "Type": "stdio",
221
- "Command/URL": "uvx mcp-server-time"
222
- }
310
+ "ts_ms": 1766923317974,
311
+ "kind": "req",
312
+ "direction": "",
313
+ "label": "tools/list",
314
+ "connector_id": "time",
315
+ "session_id": "3cf5a66e-...",
316
+ "rpc_id": "2",
317
+ "status": "OK",
318
+ "size_bytes": 58
319
+ },
320
+ ...
223
321
  ]
224
322
 
225
- $ pfscan scan start --id time --json
226
- {
227
- "success": true,
228
- "connector_id": "time",
229
- "tools_count": 1,
230
- "tools": ["get_current_time"],
231
- "event_count": 8
232
- }
233
- ```
234
-
235
- ## Supported mcpServers Input Formats
236
-
237
- proofscan accepts several JSON formats for import:
238
-
239
- ### A) Full wrapper
240
-
241
- ```json
242
- {
243
- "mcpServers": {
244
- "time": { "command": "uvx", "args": ["mcp-server-time"] }
323
+ $ pfscan tree --json
324
+ [
325
+ {
326
+ "type": "connector",
327
+ "id": "time",
328
+ "label": "time",
329
+ "meta": { "session_count": 3 },
330
+ "children": [...]
245
331
  }
246
- }
332
+ ]
247
333
  ```
248
334
 
249
- ### B) Direct mcpServers object
335
+ ## Connector Management
250
336
 
251
- ```json
252
- {
253
- "time": { "command": "uvx", "args": ["mcp-server-time"] }
254
- }
255
- ```
256
-
257
- ### C) Single server definition (requires `--name`)
337
+ ```bash
338
+ pfscan connectors list # List all
339
+ pfscan connectors show --id <id> # Show details
340
+ pfscan connectors add --id <id> --stdio "cmd" # Add connector
341
+ pfscan connectors enable --id <id> # Enable
342
+ pfscan connectors disable --id <id> # Disable
343
+ pfscan connectors remove --id <id> # Remove
258
344
 
259
- ```json
260
- {
261
- "command": "uvx",
262
- "args": ["mcp-server-time"]
263
- }
345
+ # Import from mcpServers format
346
+ pfscan connectors import --from mcpServers --stdin
347
+ pfscan connectors import --from mcpServers --file <path>
264
348
  ```
265
349
 
266
- ## Failure Handling
267
-
268
- Failures are always recorded as events. Even if a scan fails, you can inspect what happened:
350
+ ## Session Management
269
351
 
270
352
  ```bash
271
- $ pfscan scan start --id broken-server
272
- Scanning connector: broken-server...
273
- Scan failed!
274
- Connector: broken-server
275
- Error: Initialize failed: Request timeout for method: initialize
276
- Events recorded: 3
277
-
278
- $ pfscan monitor tail --id broken-server --last 5
279
- Time Dir Status Kind Summary
280
- ----------------------------------------------------------------------
281
- 10:35:01 → transport [connect_attempt]
282
- 10:35:01 ← transport [connected]
283
- 10:35:31 → transport [initialize_failed] Initialize failed: Request timeout...
353
+ pfscan sessions list [--connector <id>] [--last <N>]
354
+ pfscan sessions show --id <session_id>
355
+ pfscan sessions prune [--before <date>] [--keep-last <N>] [--yes]
284
356
  ```
285
357
 
286
358
  ## Development
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * proofscan CLI
3
+ * proofscan CLI - Phase 2.1
4
4
  * MCP Server scanner - eliminate black boxes
5
+ *
6
+ * Command structure (git-style flat):
7
+ * pfscan view # View events (default)
8
+ * pfscan tree # Structure overview
9
+ * pfscan explore # Interactive browse
10
+ * pfscan scan # Run scan
11
+ * pfscan status # System status
12
+ * pfscan archive # Archive/prune data
13
+ * pfscan config # Configuration
14
+ * pfscan connectors # Connector management
15
+ *
16
+ * Shortcuts:
17
+ * v = view, t = tree, e = explore, s = scan
18
+ * st = status, a = archive, c = config
5
19
  */
6
20
  export {};
7
21
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG"}
package/dist/cli.js CHANGED
@@ -1,25 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * proofscan CLI
3
+ * proofscan CLI - Phase 2.1
4
4
  * MCP Server scanner - eliminate black boxes
5
+ *
6
+ * Command structure (git-style flat):
7
+ * pfscan view # View events (default)
8
+ * pfscan tree # Structure overview
9
+ * pfscan explore # Interactive browse
10
+ * pfscan scan # Run scan
11
+ * pfscan status # System status
12
+ * pfscan archive # Archive/prune data
13
+ * pfscan config # Configuration
14
+ * pfscan connectors # Connector management
15
+ *
16
+ * Shortcuts:
17
+ * v = view, t = tree, e = explore, s = scan
18
+ * st = status, a = archive, c = config
5
19
  */
6
20
  import { Command } from 'commander';
7
21
  import { resolveConfigPath } from './utils/config-path.js';
8
22
  import { setOutputOptions } from './utils/output.js';
9
- import { createConfigCommand, createConnectorsCommand, createScanCommand, createMonitorCommand, } from './commands/index.js';
23
+ import { createConfigCommand, createConnectorsCommand, createScanCommand, createMonitorCommand, createSessionsCommand, createArchiveCommand, createViewCommand, createTreeCommand, createExploreCommand, createStatusCommand, } from './commands/index.js';
10
24
  const program = new Command();
11
25
  // Global state for config path
12
26
  let globalConfigPath;
13
27
  function getConfigPath() {
14
28
  return resolveConfigPath({ configPath: globalConfigPath });
15
29
  }
30
+ // Custom help formatting
31
+ const HELP_HEADER = `
32
+ proofscan - MCP Server scanner
33
+ Eliminate black boxes by capturing JSON-RPC communication.
34
+
35
+ Common Commands:
36
+ view, v View recent events timeline (default)
37
+ tree, t Show connector → session → rpc structure
38
+ explore, e Interactive data browser
39
+ scan, s Run a new scan
40
+ status, st Show system status
41
+
42
+ Management:
43
+ archive, a Archive and prune old data
44
+ config, c Configuration management
45
+ connectors Connector management
46
+
47
+ Shortcuts:
48
+ v=view t=tree e=explore s=scan st=status a=archive c=config
49
+ `;
16
50
  program
17
51
  .name('pfscan')
18
- .description('MCP Server scanner - eliminate black boxes by capturing JSON-RPC from connection to tools/list')
19
- .version('0.1.1')
52
+ .description('MCP Server scanner - eliminate black boxes by capturing JSON-RPC')
53
+ .version('0.3.0')
20
54
  .option('-c, --config <path>', 'Path to config file')
21
55
  .option('--json', 'Output in JSON format')
22
56
  .option('-v, --verbose', 'Verbose output')
57
+ .addHelpText('before', HELP_HEADER)
23
58
  .hook('preAction', (thisCommand) => {
24
59
  const opts = thisCommand.opts();
25
60
  globalConfigPath = opts.config;
@@ -28,11 +63,98 @@ program
28
63
  verbose: opts.verbose,
29
64
  });
30
65
  });
31
- // Add subcommands
32
- program.addCommand(createConfigCommand(getConfigPath));
66
+ // ============================================================
67
+ // Primary commands (Phase 2.1 - git style)
68
+ // ============================================================
69
+ // view (default command)
70
+ const viewCmd = createViewCommand(getConfigPath);
71
+ program.addCommand(viewCmd);
72
+ // Alias: v = view
73
+ const vCmd = createViewCommand(getConfigPath);
74
+ vCmd.name('v').description('Alias for view');
75
+ program.addCommand(vCmd);
76
+ // tree
77
+ const treeCmd = createTreeCommand(getConfigPath);
78
+ program.addCommand(treeCmd);
79
+ // Alias: t = tree
80
+ const tCmd = createTreeCommand(getConfigPath);
81
+ tCmd.name('t').description('Alias for tree');
82
+ program.addCommand(tCmd);
83
+ // explore
84
+ const exploreCmd = createExploreCommand(getConfigPath);
85
+ program.addCommand(exploreCmd);
86
+ // Alias: e = explore
87
+ const eCmd = createExploreCommand(getConfigPath);
88
+ eCmd.name('e').description('Alias for explore');
89
+ program.addCommand(eCmd);
90
+ // status
91
+ const statusCmd = createStatusCommand(getConfigPath);
92
+ program.addCommand(statusCmd);
93
+ // Alias: st = status
94
+ const stCmd = createStatusCommand(getConfigPath);
95
+ stCmd.name('st').description('Alias for status');
96
+ program.addCommand(stCmd);
97
+ // ============================================================
98
+ // Existing commands (maintained for compatibility)
99
+ // ============================================================
100
+ // scan
101
+ const scanCmd = createScanCommand(getConfigPath);
102
+ program.addCommand(scanCmd);
103
+ // Alias: s = scan
104
+ const sCmd = createScanCommand(getConfigPath);
105
+ sCmd.name('s').description('Alias for scan');
106
+ program.addCommand(sCmd);
107
+ // archive
108
+ const archiveCmd = createArchiveCommand(getConfigPath);
109
+ program.addCommand(archiveCmd);
110
+ // Alias: a = archive
111
+ const aCmd = createArchiveCommand(getConfigPath);
112
+ aCmd.name('a').description('Alias for archive');
113
+ program.addCommand(aCmd);
114
+ // config
115
+ const configCmd = createConfigCommand(getConfigPath);
116
+ program.addCommand(configCmd);
117
+ // Alias: c = config
118
+ const cCmd = createConfigCommand(getConfigPath);
119
+ cCmd.name('c').description('Alias for config');
120
+ program.addCommand(cCmd);
121
+ // connectors (no short alias - too long)
33
122
  program.addCommand(createConnectorsCommand(getConfigPath));
34
- program.addCommand(createScanCommand(getConfigPath));
123
+ // sessions (kept for compatibility, but sessions list → view --with-sessions)
124
+ program.addCommand(createSessionsCommand(getConfigPath));
125
+ // monitor (kept for compatibility, but monitor tail → view)
35
126
  program.addCommand(createMonitorCommand(getConfigPath));
127
+ // ============================================================
128
+ // Default action: pfscan → pfscan view
129
+ // ============================================================
130
+ // Check if no subcommand is provided (only options like --config, --json)
131
+ function hasSubcommand() {
132
+ const knownCommands = new Set([
133
+ 'view', 'v', 'tree', 't', 'explore', 'e', 'status', 'st',
134
+ 'scan', 's', 'archive', 'a', 'config', 'c',
135
+ 'connectors', 'sessions', 'monitor', 'help'
136
+ ]);
137
+ for (let i = 2; i < process.argv.length; i++) {
138
+ const arg = process.argv[i];
139
+ // Skip option flags and their values
140
+ if (arg.startsWith('-')) {
141
+ // If it's --config, skip the next arg too
142
+ if (arg === '-c' || arg === '--config') {
143
+ i++;
144
+ }
145
+ continue;
146
+ }
147
+ // This is a positional argument - check if it's a command
148
+ if (knownCommands.has(arg)) {
149
+ return true;
150
+ }
151
+ }
152
+ return false;
153
+ }
154
+ // If no subcommand, insert 'view' right after program name (before any options)
155
+ if (!hasSubcommand()) {
156
+ process.argv.splice(2, 0, 'view');
157
+ }
36
158
  // Parse and run
37
159
  program.parse();
38
160
  //# sourceMappingURL=cli.js.map