@cephalization/phoenix-insight 0.1.0 → 0.2.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
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@cephalization/phoenix-insight.svg)](https://www.npmjs.com/package/@cephalization/phoenix-insight)
4
4
 
5
- A filesystem-native AI agent CLI for querying Phoenix instances using the "bash + files" paradigm inspired by [Vercel's agent architecture](https://vercel.com/blog/how-to-build-agents-with-filesystems-and-bash).
5
+ Phoenix Insight brings AI-powered analysis to your [Phoenix](https://github.com/Arize-ai/phoenix) observability data using the ["bash + files" paradigm](https://vercel.com/blog/how-to-build-agents-with-filesystems-and-bash). Instead of hiding data behind opaque API calls, Phoenix Insight materializes your traces, experiments, datasets, and prompts as a structured filesystem. An AI agent then explores this data using standard bash commands you already know: `cat`, `grep`, `jq`, `awk`, and more.
6
6
 
7
- Phoenix Insight transforms your Phoenix observability data into a structured filesystem, then uses an AI agent with bash tools to analyze it through natural language queries. This approach provides transparency, flexibility, and power that traditional APIs can't match.
7
+ This filesystem-native approach provides transparency that traditional APIs can't match. Every query the agent runs is visible and reproducible. You can inspect the exact files it reads, copy its commands, and run them yourself. The data is just files, and the analysis is just bash, making AI-driven observability debuggable, auditable, and extensible with any tool in your Unix toolkit.
8
8
 
9
9
  ## Installation
10
10
 
@@ -22,22 +22,310 @@ npx @cephalization/phoenix-insight "your query"
22
22
  ## Quick Start
23
23
 
24
24
  ```bash
25
- # Start interactive mode (no arguments needed)
25
+ # Start interactive mode
26
26
  phoenix-insight
27
27
 
28
- # Query Phoenix data with natural language
28
+ # Analyze Phoenix data with natural language
29
29
  phoenix-insight "What are the most common errors in the last hour?"
30
30
 
31
- # Local mode with persistent storage
31
+ # Show help
32
+ phoenix-insight help
33
+ ```
34
+
35
+ ## CLI Examples
36
+
37
+ This section covers all CLI usage, progressing from basic to advanced scenarios.
38
+
39
+ ### Basic Queries
40
+
41
+ ```bash
42
+ # Ask a question about your Phoenix data
43
+ phoenix-insight "What types of errors are occurring most frequently?"
44
+
45
+ # Analyze performance patterns
46
+ phoenix-insight "Find the slowest traces and identify patterns"
47
+
48
+ # Compare experiments
49
+ phoenix-insight "Compare success rates across recent experiments"
50
+
51
+ # Explore datasets
52
+ phoenix-insight "Show me statistics about my datasets"
53
+ ```
54
+
55
+ ### Interactive Mode
56
+
57
+ Start an interactive REPL session for multiple queries without re-fetching data:
58
+
59
+ ```bash
60
+ # Start interactive mode (default when no query is provided)
61
+ phoenix-insight
62
+
63
+ # Or explicitly with --interactive flag
64
+ phoenix-insight --interactive
65
+ ```
66
+
67
+ Within interactive mode:
68
+
69
+ ```
70
+ phoenix> What projects have the most spans?
71
+ [Agent analyzes and responds...]
72
+
73
+ phoenix> Show me error patterns in the chatbot-prod project
74
+ [Agent investigates specific project...]
75
+
76
+ phoenix> px-fetch-more trace --trace-id abc123
77
+ [Agent fetches specific trace data...]
78
+
79
+ phoenix> help
80
+ [Shows available commands and tips...]
81
+
82
+ phoenix> exit
83
+ ```
84
+
85
+ ### Snapshot Management
86
+
87
+ Create or update snapshots separately from queries:
88
+
89
+ ```bash
90
+ # Create initial snapshot
91
+ phoenix-insight snapshot
92
+
93
+ # Force refresh snapshot (ignore cache)
94
+ phoenix-insight snapshot --refresh
95
+
96
+ # Snapshot from a specific Phoenix instance
97
+ phoenix-insight snapshot --base-url https://phoenix.example.com --api-key your-api-key
98
+
99
+ # Clean up local snapshots
100
+ phoenix-insight prune
101
+
102
+ # Preview what would be deleted
103
+ phoenix-insight prune --dry-run
104
+ ```
105
+
106
+ ### Local Mode
107
+
108
+ ```bash
109
+ # Run a query in local mode (persistent storage, full bash capabilities)
32
110
  phoenix-insight --local "analyze trace patterns"
111
+ ```
33
112
 
34
- # Force fresh data
35
- phoenix-insight --refresh "show me the slowest endpoints"
113
+ ### Connection Options
36
114
 
37
- # Show help
115
+ Connect to different Phoenix instances:
116
+
117
+ ```bash
118
+ # Connect to a remote Phoenix instance
119
+ phoenix-insight --base-url https://phoenix.example.com "analyze traces"
120
+
121
+ # Authenticate with an API key
122
+ phoenix-insight --base-url https://phoenix.example.com --api-key your-api-key "show errors"
123
+ ```
124
+
125
+ ### Data Fetching Options
126
+
127
+ ```bash
128
+ # Increase span fetch limit (default: 1000 per project)
129
+ phoenix-insight --limit 5000 "deep trace analysis"
130
+
131
+ # Force refresh of cached data
132
+ phoenix-insight --refresh "show me the latest errors"
133
+ ```
134
+
135
+ ### Output Options
136
+
137
+ ```bash
138
+ # Disable streaming for batch processing (streaming is enabled by default)
139
+ phoenix-insight --no-stream "generate report" > report.txt
140
+ ```
141
+
142
+ ### Observability
143
+
144
+ ```bash
145
+ # Enable tracing of agent operations to Phoenix
146
+ phoenix-insight --trace "analyze performance"
147
+ ```
148
+
149
+ ### On-Demand Data Fetching
150
+
151
+ Within interactive mode, the agent can fetch additional data during analysis:
152
+
153
+ ```bash
154
+ px-fetch-more spans --project my-project --limit 500
155
+ px-fetch-more trace --trace-id abc123
156
+ ```
157
+
158
+ ### Combining Options
159
+
160
+ Combine multiple options for complex scenarios:
161
+
162
+ ```bash
163
+ # Remote instance with authentication, local mode, and increased limit
164
+ phoenix-insight --local --base-url https://phoenix.example.com \
165
+ --api-key your-api-key --limit 5000 "deep analysis of production traces"
166
+
167
+ # Refresh data, enable tracing, and stream output
168
+ phoenix-insight --refresh --trace --stream "analyze error patterns over time"
169
+ ```
170
+
171
+ ## Example Queries
172
+
173
+ Phoenix Insight understands natural language queries about your observability data. Here are examples organized by analysis type to help you get started.
174
+
175
+ ### Error Analysis
176
+
177
+ ```bash
178
+ # Find and categorize errors
179
+ phoenix-insight "What are the most common errors in the last 24 hours?"
180
+ phoenix-insight "Show me all failed spans and their error messages"
181
+ phoenix-insight "Which services have the highest error rates?"
182
+ phoenix-insight "Find traces that contain exceptions or timeouts"
183
+ ```
184
+
185
+ ### Performance & Latency
186
+
187
+ ```bash
188
+ # Identify performance bottlenecks
189
+ phoenix-insight "What are the slowest LLM calls in my application?"
190
+ phoenix-insight "Find traces where latency exceeds 5 seconds"
191
+ phoenix-insight "Show p50, p95, and p99 latency by endpoint"
192
+ phoenix-insight "Which operations have the highest latency variance?"
193
+ ```
194
+
195
+ ### Token Usage & Costs
196
+
197
+ ```bash
198
+ # Analyze LLM resource consumption
199
+ phoenix-insight "Which LLM calls are consuming the most tokens?"
200
+ phoenix-insight "Calculate total token usage for the chatbot project"
201
+ phoenix-insight "Show token usage breakdown by model type"
202
+ phoenix-insight "Find conversations that exceeded 10,000 tokens"
203
+ ```
204
+
205
+ ### RAG Analysis
206
+
207
+ ```bash
208
+ # Examine retrieval-augmented generation patterns
209
+ phoenix-insight "Show retrieved documents with low relevance scores"
210
+ phoenix-insight "Find retrieval calls that returned no results"
211
+ phoenix-insight "What's the average number of documents retrieved per query?"
212
+ phoenix-insight "Identify queries where retrieval latency dominated total time"
213
+ ```
214
+
215
+ ### Evaluations & Experiments
216
+
217
+ ```bash
218
+ # Review evaluation results and experiment metrics
219
+ phoenix-insight "What's the hallucination rate across my experiments?"
220
+ phoenix-insight "Compare accuracy scores between model versions"
221
+ phoenix-insight "Show experiments sorted by success rate"
222
+ phoenix-insight "Find evaluation runs where quality scores dropped below threshold"
223
+ ```
224
+
225
+ ### Dataset Analysis
226
+
227
+ ```bash
228
+ # Explore datasets and examples
229
+ phoenix-insight "Show statistics for my evaluation datasets"
230
+ phoenix-insight "Find examples where the model failed quality checks"
231
+ phoenix-insight "What's the distribution of example categories in my dataset?"
232
+ phoenix-insight "List datasets with the most recent updates"
233
+ ```
234
+
235
+ ### Prompt Engineering
236
+
237
+ ```bash
238
+ # Analyze prompt versions and performance
239
+ phoenix-insight "List all prompt versions and their performance metrics"
240
+ phoenix-insight "Compare outputs between prompt v1 and v2"
241
+ phoenix-insight "Which prompt template has the lowest error rate?"
242
+ phoenix-insight "Show the evolution of my summarization prompt"
243
+ ```
244
+
245
+ ### Session & Conversation Analysis
246
+
247
+ ```bash
248
+ # Understand user interaction patterns
249
+ phoenix-insight "Show the conversation flow for session abc123"
250
+ phoenix-insight "Find sessions with high user abandonment"
251
+ phoenix-insight "What's the average conversation length by project?"
252
+ phoenix-insight "Identify sessions where users repeated similar queries"
253
+ ```
254
+
255
+ ### Tool & Function Calls
256
+
257
+ ```bash
258
+ # Analyze agent tool usage
259
+ phoenix-insight "Which tools are being called most frequently?"
260
+ phoenix-insight "Find tool calls that failed or timed out"
261
+ phoenix-insight "Show the success rate for each tool type"
262
+ phoenix-insight "What's the average latency for function calls?"
263
+ ```
264
+
265
+ ## Command Reference
266
+
267
+ Phoenix Insight provides several commands, each with its own options.
268
+
269
+ ### Query Command (Default)
270
+
271
+ The default command analyzes Phoenix data with natural language queries.
272
+
273
+ ```bash
274
+ phoenix-insight [options] [query]
275
+ ```
276
+
277
+ | Option | Description | Default | Example |
278
+ | ------------------- | --------------------------------------------- | ----------------------- | ---------------------------------------------- |
279
+ | `--config <path>` | Custom config file path | `~/.phoenix-insight/config.json` | `--config ./my-config.json` |
280
+ | `--sandbox` | Run in sandbox mode with in-memory filesystem | `true` | `phoenix-insight --sandbox "query"` |
281
+ | `--local` | Run in local mode with persistent storage | `false` | `phoenix-insight --local "query"` |
282
+ | `--base-url <url>` | Phoenix server URL | `http://localhost:6006` | `--base-url https://phoenix.example.com` |
283
+ | `--api-key <key>` | Phoenix API key for authentication | (none) | `--api-key your-api-key` |
284
+ | `--refresh` | Force refresh of cached snapshot data | `false` | `phoenix-insight --refresh "show latest data"` |
285
+ | `--limit <n>` | Maximum spans to fetch per project | `1000` | `--limit 5000` |
286
+ | `--stream` | Stream agent responses in real-time | `true` | `--no-stream` to disable |
287
+ | `-i, --interactive` | Start interactive REPL mode | `false` | `phoenix-insight -i` |
288
+ | `--trace` | Enable tracing of agent operations to Phoenix | `false` | `phoenix-insight --trace "query"` |
289
+
290
+ ### Snapshot Command
291
+
292
+ Creates or updates a data snapshot from Phoenix without running a query.
293
+
294
+ ```bash
295
+ phoenix-insight snapshot [options]
296
+ ```
297
+
298
+ | Option | Description | Default | Example |
299
+ | ------------------ | --------------------------------------------- | ----------------------- | ----------------------------------------------- |
300
+ | `--config <path>` | Custom config file path | `~/.phoenix-insight/config.json` | `--config ./my-config.json` |
301
+ | `--base-url <url>` | Phoenix server URL | `http://localhost:6006` | `--base-url https://phoenix.example.com` |
302
+ | `--api-key <key>` | Phoenix API key for authentication | (none) | `--api-key your-api-key` |
303
+ | `--refresh` | Force refresh (ignore existing cache) | `false` | `phoenix-insight snapshot --refresh` |
304
+ | `--limit <n>` | Maximum spans to fetch per project | `1000` | `phoenix-insight snapshot --limit 5000` |
305
+ | `--trace` | Enable tracing of snapshot operations | `false` | `phoenix-insight snapshot --trace` |
306
+
307
+ ### Prune Command
308
+
309
+ Deletes the local snapshot directory to free up disk space.
310
+
311
+ ```bash
312
+ phoenix-insight prune [options]
313
+ ```
314
+
315
+ | Option | Description | Default | Example |
316
+ | ----------- | ---------------------------------------- | ------- | ------------------------------- |
317
+ | `--dry-run` | Preview what would be deleted without actually deleting | `false` | `phoenix-insight prune --dry-run` |
318
+
319
+ ### Help Command
320
+
321
+ Displays help information and available options.
322
+
323
+ ```bash
38
324
  phoenix-insight help
39
325
  ```
40
326
 
327
+ No additional options. Shows usage information, all commands, and their options.
328
+
41
329
  ## How It Works
42
330
 
43
331
  Phoenix Insight operates in three phases:
@@ -83,134 +371,73 @@ Phoenix data is organized into an intuitive REST-like hierarchy:
83
371
  snapshot.json # Snapshot metadata
84
372
  ```
85
373
 
86
- ## Execution Modes
87
-
88
- Phoenix Insight supports two execution modes:
89
-
90
- ### Sandbox Mode (default)
91
-
92
- Uses [just-bash](https://github.com/vercel-labs/just-bash) for complete isolation:
93
-
94
- - **In-memory filesystem**: No disk writes
95
- - **Simulated bash**: 50+ built-in commands
96
- - **Zero risk**: Cannot access your system
97
- - **Perfect for**: CI/CD, demos, safe exploration
98
-
99
- ### Local Mode (--local)
100
-
101
- Uses real bash and persistent storage:
102
-
103
- - **Persistent data**: Snapshots saved to `~/.phoenix-insight/`
104
- - **Full bash power**: All system commands available
105
- - **Incremental updates**: Only fetches new data
106
- - **Perfect for**: Power users, complex analysis, custom tools
107
-
108
- ## Usage Examples
109
-
110
- ### Basic Queries
111
-
112
- ```bash
113
- # Analyze errors
114
- phoenix-insight "What types of errors are occurring most frequently?"
115
-
116
- # Performance analysis
117
- phoenix-insight "Find the slowest traces and identify patterns"
374
+ ## Examples of Agent Analysis
118
375
 
119
- # Experiment comparison
120
- phoenix-insight "Compare success rates across recent experiments"
376
+ ### Error Pattern Detection
121
377
 
122
- # Dataset exploration
123
- phoenix-insight "Show me statistics about my datasets"
124
378
  ```
379
+ User: "What are the most common errors in my traces?"
125
380
 
126
- ### Advanced Options
127
-
128
- ```bash
129
- # Connect to remote Phoenix instance
130
- phoenix-insight "analyze traces" \
131
- --base-url https://phoenix.example.com \
132
- --api-key your-api-key
133
-
134
- # Increase span fetch limit (default: 1000 per project)
135
- phoenix-insight "deep trace analysis" --limit 5000
381
+ Agent: I'll analyze the error patterns in your traces. Let me start by examining the context...
136
382
 
137
- # Stream responses in real-time
138
- phoenix-insight "complex analysis task" --stream
383
+ *reads _context.md*
384
+ *searches for error spans across projects*
385
+ *aggregates by error type*
386
+ *identifies patterns*
139
387
 
140
- # Use local mode for persistent storage
141
- phoenix-insight "experimental query" --local
388
+ I found 3 main error patterns in your traces:
389
+ 1. **Database timeouts** (42% of errors): Occurring in user-service, primarily during peak hours
390
+ 2. **API rate limits** (31% of errors): Third-party integration hitting limits
391
+ 3. **Null pointer exceptions** (27% of errors): In the recommendation engine
142
392
 
143
- # Enable observability tracing (sends traces to Phoenix)
144
- phoenix-insight "analyze performance" --trace
393
+ The database timeouts show a clear pattern during 9-10am and 2-3pm daily.
145
394
  ```
146
395
 
147
- ### Interactive Mode
148
-
149
- Start an interactive REPL session for multiple queries:
150
-
151
- ```bash
152
- # Start interactive mode (default when no query is provided)
153
- $ phoenix-insight
154
-
155
- # Or explicitly with --interactive flag
156
- $ phoenix-insight --interactive
396
+ ### Performance Analysis
157
397
 
158
- phoenix> What projects have the most spans?
159
- [Agent analyzes and responds...]
398
+ ```
399
+ User: "Find the slowest API endpoints"
160
400
 
161
- phoenix> Show me error patterns in the chatbot-prod project
162
- [Agent investigates specific project...]
401
+ Agent: I'll analyze your API endpoint performance. Let me examine the span data...
163
402
 
164
- phoenix> px-fetch-more trace --trace-id abc123
165
- [Agent fetches specific trace data...]
403
+ *reads project spans*
404
+ *calculates latency percentiles*
405
+ *groups by endpoint*
406
+ *identifies outliers*
166
407
 
167
- phoenix> help
168
- [Shows available commands and tips...]
408
+ Here are your slowest API endpoints by p95 latency:
409
+ 1. `/api/v1/recommendations` - 3.2s p95 (8.1s p99)
410
+ 2. `/api/v1/search` - 2.8s p95 (5.2s p99)
411
+ 3. `/api/v1/user/history` - 1.9s p95 (3.1s p99)
169
412
 
170
- phoenix> exit
413
+ The recommendations endpoint has high variability, suggesting cache misses.
171
414
  ```
172
415
 
173
- ### Snapshot Management
174
-
175
- Create or update snapshots separately from queries:
176
-
177
- ```bash
178
- # Create initial snapshot
179
- phoenix-insight snapshot
180
-
181
- # Force refresh (ignore cache)
182
- phoenix-insight snapshot --refresh
416
+ ## Tips and Best Practices
183
417
 
184
- # Snapshot from specific Phoenix instance
185
- phoenix-insight snapshot \
186
- --base-url https://phoenix.example.com \
187
- --api-key your-api-key
418
+ ### Query Formulation
188
419
 
189
- # Enable observability tracing for snapshot process
190
- phoenix-insight snapshot --trace
420
+ - Be specific about what you want to analyze
421
+ - Mention time ranges if relevant
422
+ - Ask for patterns, not just raw data
191
423
 
192
- # Clean up local snapshots
193
- phoenix-insight prune
424
+ ### Performance
194
425
 
195
- # Preview what would be deleted
196
- phoenix-insight prune --dry-run
197
- ```
426
+ - Use `--limit` to control data volume
427
+ - In sandbox mode, start with smaller datasets
428
+ - Use local mode for production analysis
198
429
 
199
- ### On-Demand Data Fetching
430
+ ### Security
200
431
 
201
- The agent can fetch additional data during analysis:
432
+ - Use sandbox mode when trying new queries
433
+ - Never put API keys in queries
434
+ - Review agent actions with `--stream`
202
435
 
203
- ```bash
204
- # In your query, the agent might discover it needs more data:
205
- "I need more spans to complete this analysis. Let me fetch them..."
206
- px-fetch-more spans --project my-project --limit 500
436
+ ## Advanced Topics
207
437
 
208
- # Or fetch a specific trace:
209
- "I'll get the full trace to understand the error..."
210
- px-fetch-more trace --trace-id abc123
211
- ```
438
+ The following sections cover configuration, execution modes, and internal details for power users.
212
439
 
213
- ## Configuration
440
+ ### Configuration
214
441
 
215
442
  Phoenix Insight uses a layered configuration system with the following priority (highest to lowest):
216
443
 
@@ -218,7 +445,7 @@ Phoenix Insight uses a layered configuration system with the following priority
218
445
  2. **Environment variables** - `PHOENIX_*` environment variables
219
446
  3. **Config file** - JSON file at `~/.phoenix-insight/config.json`
220
447
 
221
- ### Config File
448
+ #### Config File
222
449
 
223
450
  On first run, Phoenix Insight automatically creates a default config file at `~/.phoenix-insight/config.json` with all default values. You can edit this file to customize your settings.
224
451
 
@@ -252,7 +479,7 @@ On first run, Phoenix Insight automatically creates a default config file at `~/
252
479
  | `refresh` | boolean | `false` | Force refresh of snapshot data |
253
480
  | `trace` | boolean | `false` | Enable tracing of agent operations to Phoenix |
254
481
 
255
- ### Environment Variables
482
+ #### Environment Variables
256
483
 
257
484
  | Variable | Config Key | Default | Description |
258
485
  | ------------------------- | ---------- | ----------------------- | -------------------------- |
@@ -266,172 +493,33 @@ On first run, Phoenix Insight automatically creates a default config file at `~/
266
493
  | `PHOENIX_INSIGHT_CONFIG` | - | - | Custom config file path |
267
494
  | `DEBUG` | - | `0` | Show detailed error info |
268
495
 
269
- ### Commands
270
-
271
- Phoenix Insight provides several commands:
272
-
273
- - **Default (interactive mode)**: `phoenix-insight` - Start interactive REPL when no query is provided
274
- - **Query mode**: `phoenix-insight "your query"` - Analyze Phoenix data with natural language
275
- - **`help`**: Show help information
276
- - **`snapshot`**: Create or update a data snapshot from Phoenix
277
- - **`prune`**: Delete local snapshot directory to free up space
278
-
279
- ### Command Line Options
280
-
281
- | Option | Description | Default | Applies to |
282
- | --------------------- | ---------------------------------- | ---------------- | -------------- |
283
- | `--config <path>` | Custom config file path | (auto-detected) | all |
284
- | `--sandbox` | Run in sandbox mode (default) | true | query |
285
- | `--local` | Run in local mode | false | query |
286
- | `--base-url <url>` | Phoenix server URL | env or localhost | all |
287
- | `--api-key <key>` | Phoenix API key | env or none | all |
288
- | `--refresh` | Force fresh snapshot | false | query/snapshot |
289
- | `--limit <n>` | Max spans per project | 1000 | query |
290
- | `--stream` | Stream agent responses | true | query |
291
- | `--interactive`, `-i` | Interactive REPL mode | false | query |
292
- | `--trace` | Enable tracing to Phoenix instance | false | query/snapshot |
293
- | `--dry-run` | Preview without making changes | false | prune |
294
-
295
- ### Local Mode Storage
496
+ #### Local Mode Storage
296
497
 
297
- In local mode, data is stored in:
498
+ In local mode (`--local`), data persists at `~/.phoenix-insight/`:
298
499
 
299
500
  ```
300
501
  ~/.phoenix-insight/
301
502
  config.json # Configuration (auto-created on first run)
302
- /snapshots/
303
- /{timestamp}/ # Each snapshot
304
- /phoenix/ # Phoenix data
503
+ /snapshots/{timestamp}/ # Snapshot data
305
504
  /cache/ # API response cache
306
505
  ```
307
506
 
308
- To clean up local storage:
309
-
310
- ```bash
311
- # Delete all local snapshots
312
- phoenix-insight prune
313
-
314
- # Preview what will be deleted
315
- phoenix-insight prune --dry-run
316
- ```
507
+ Use `phoenix-insight prune` to clean up local storage.
317
508
 
318
- ## Troubleshooting
319
-
320
- ### Connection Issues
321
-
322
- ```bash
323
- # Test connection to Phoenix
324
- phoenix-insight snapshot
325
-
326
- # If that fails, check your Phoenix instance:
327
- curl http://localhost:6006/v1/projects
328
-
329
- # Verify with explicit connection:
330
- phoenix-insight snapshot --base-url http://your-phoenix:6006
331
- ```
332
-
333
- ### Authentication Errors
334
-
335
- ```bash
336
- # Set API key via environment
337
- export PHOENIX_API_KEY="your-key"
338
- phoenix-insight "your query"
339
-
340
- # Or pass directly
341
- phoenix-insight "your query" --api-key "your-key"
342
- ```
343
-
344
- ### Debug Mode
345
-
346
- For detailed error information:
347
-
348
- ```bash
349
- # Enable debug output
350
- DEBUG=1 phoenix-insight "problematic query"
351
-
352
- # This shows:
353
- # - Full stack traces
354
- # - API request details
355
- # - Agent tool calls
356
- # - Raw responses
357
- ```
358
-
359
- ### Common Issues
360
-
361
- **"No snapshot found" in local mode**
362
-
363
- ```bash
364
- # Create initial snapshot
365
- phoenix-insight snapshot
509
+ ### Execution Modes
366
510
 
367
- # Or use --refresh to create on-demand
368
- phoenix-insight "query" --refresh
369
- ```
370
-
371
- **Out of memory in sandbox mode**
372
-
373
- ```bash
374
- # Reduce span limit
375
- phoenix-insight "query" --sandbox --limit 500
376
-
377
- # Or use local mode for large datasets
378
- phoenix-insight "query" --local
379
- ```
380
-
381
- **Local storage getting too large**
382
-
383
- ```bash
384
- # Check what will be deleted
385
- phoenix-insight prune --dry-run
386
-
387
- # Clean up all local snapshots
388
- phoenix-insight prune
389
- ```
390
-
391
- **Agent can't find expected data**
392
-
393
- ```bash
394
- # Force refresh to get latest
395
- phoenix-insight "query" --refresh
396
-
397
- # Fetch more data on-demand (agent will do this automatically)
398
- px-fetch-more spans --project my-project --limit 2000
399
- ```
400
-
401
- ## Observability
402
-
403
- Phoenix Insight can trace its own execution back to Phoenix for monitoring and debugging:
404
-
405
- ```bash
406
- # Enable tracing for queries
407
- phoenix-insight "analyze errors" --trace
408
-
409
- # Enable tracing in interactive mode
410
- phoenix-insight --interactive --trace
411
-
412
- # Enable tracing for snapshot creation
413
- phoenix-insight snapshot --trace
414
- ```
415
-
416
- When `--trace` is enabled:
417
-
418
- - All agent operations are traced as spans
419
- - Tool calls and responses are captured
420
- - Performance metrics are recorded
421
- - Traces are sent to the same Phoenix instance being queried (or the one specified by --base-url)
422
-
423
- This is particularly useful for:
511
+ Phoenix Insight supports two execution modes:
424
512
 
425
- - Debugging slow queries
426
- - Understanding agent decision-making
427
- - Monitoring Phoenix Insight usage
428
- - Optimizing performance
513
+ | Mode | Flag | Filesystem | Bash | Use Case |
514
+ |------|------|------------|------|----------|
515
+ | **Sandbox** (default) | `--sandbox` | In-memory | [just-bash](https://github.com/vercel-labs/just-bash) (50+ commands) | CI/CD, demos, safe exploration |
516
+ | **Local** | `--local` | Persistent (`~/.phoenix-insight/`) | Real system bash | Power users, complex analysis |
429
517
 
430
- ## Agent Capabilities
518
+ ### Agent Capabilities
431
519
 
432
520
  The AI agent has access to:
433
521
 
434
- ### Bash Commands (Sandbox Mode)
522
+ #### Bash Commands (Sandbox Mode)
435
523
 
436
524
  - **File operations**: `cat`, `ls`, `find`, `head`, `tail`
437
525
  - **Search & filter**: `grep`, `awk`, `sed`
@@ -439,19 +527,21 @@ The AI agent has access to:
439
527
  - **Analysis**: `sort`, `uniq`, `wc`
440
528
  - **And more**: 50+ commands via just-bash
441
529
 
442
- ### Bash Commands (Local Mode)
530
+ #### Bash Commands (Local Mode)
443
531
 
444
532
  - All commands available on your system
445
533
  - Custom tools: `ripgrep`, `fd`, `bat`, etc.
446
534
  - Full `jq`, `awk`, `sed` features
447
535
  - Any installed CLI tools
448
536
 
449
- ### Custom Commands
537
+ #### Custom Commands
538
+
539
+ - `px-fetch-more spans`: Fetch additional spans for deeper analysis
540
+ - `px-fetch-more trace`: Fetch a specific trace by ID
450
541
 
451
- - `px-fetch-more spans`: Fetch additional spans
452
- - `px-fetch-more trace`: Fetch specific trace by ID
542
+ See [On-Demand Data Fetching](#on-demand-data-fetching) for usage examples.
453
543
 
454
- ### Understanding Context
544
+ #### Understanding Context
455
545
 
456
546
  The agent always starts by reading `/_context.md` which provides:
457
547
 
@@ -460,9 +550,17 @@ The agent always starts by reading `/_context.md` which provides:
460
550
  - Data freshness information
461
551
  - Available commands reminder
462
552
 
463
- ## Development
553
+ ### Observability
554
+
555
+ Phoenix Insight can trace its own execution back to Phoenix using `--trace`. When enabled, all agent operations, tool calls, and responses are traced as spans and sent to the Phoenix instance being queried. This is useful for debugging slow queries and understanding agent decision-making.
464
556
 
465
- ### Building from Source
557
+ ### Troubleshooting
558
+
559
+ For connection issues, authentication errors, debug mode, and common issues, see the [Troubleshooting Guide](./TROUBLESHOOTING.md).
560
+
561
+ ### Development
562
+
563
+ #### Building from Source
466
564
 
467
565
  ```bash
468
566
  # Clone the repository
@@ -485,7 +583,7 @@ pnpm build
485
583
  pnpm typecheck
486
584
  ```
487
585
 
488
- ### Architecture
586
+ #### Architecture
489
587
 
490
588
  Phoenix Insight uses:
491
589
 
@@ -495,7 +593,7 @@ Phoenix Insight uses:
495
593
  - **Phoenix Client** for data fetching
496
594
  - **TypeScript** for type safety
497
595
 
498
- ### Testing
596
+ #### Testing
499
597
 
500
598
  ```bash
501
599
  # Run all tests
@@ -505,79 +603,17 @@ pnpm test
505
603
  pnpm test -- --coverage
506
604
 
507
605
  # Run specific test file
508
- pnpm test src/modes/sandbox.test.ts
606
+ pnpm test test/modes/sandbox.test.ts
509
607
 
510
608
  # Type checking
511
609
  pnpm typecheck
512
610
  ```
513
611
 
514
- ## Examples of Agent Analysis
515
-
516
- ### Error Pattern Detection
517
-
518
- ```
519
- User: "What are the most common errors in my traces?"
520
-
521
- Agent: I'll analyze the error patterns in your traces. Let me start by examining the context...
522
-
523
- *reads _context.md*
524
- *searches for error spans across projects*
525
- *aggregates by error type*
526
- *identifies patterns*
527
-
528
- I found 3 main error patterns in your traces:
529
- 1. **Database timeouts** (42% of errors): Occurring in user-service, primarily during peak hours
530
- 2. **API rate limits** (31% of errors): Third-party integration hitting limits
531
- 3. **Null pointer exceptions** (27% of errors): In the recommendation engine
532
-
533
- The database timeouts show a clear pattern during 9-10am and 2-3pm daily.
534
- ```
535
-
536
- ### Performance Analysis
537
-
538
- ```
539
- User: "Find the slowest API endpoints"
540
-
541
- Agent: I'll analyze your API endpoint performance. Let me examine the span data...
542
-
543
- *reads project spans*
544
- *calculates latency percentiles*
545
- *groups by endpoint*
546
- *identifies outliers*
547
-
548
- Here are your slowest API endpoints by p95 latency:
549
- 1. `/api/v1/recommendations` - 3.2s p95 (8.1s p99)
550
- 2. `/api/v1/search` - 2.8s p95 (5.2s p99)
551
- 3. `/api/v1/user/history` - 1.9s p95 (3.1s p99)
552
-
553
- The recommendations endpoint has high variability, suggesting cache misses.
554
- ```
555
-
556
- ## Tips and Best Practices
557
-
558
- ### Query Formulation
559
-
560
- - Be specific about what you want to analyze
561
- - Mention time ranges if relevant
562
- - Ask for patterns, not just raw data
563
-
564
- ### Performance
565
-
566
- - Use `--limit` to control data volume
567
- - In sandbox mode, start with smaller datasets
568
- - Use local mode for production analysis
569
-
570
- ### Security
571
-
572
- - Use sandbox mode when trying new queries
573
- - Never put API keys in queries
574
- - Review agent actions with `--stream`
575
-
576
- ## Contributing & Releases
612
+ ### Contributing & Releases
577
613
 
578
614
  Contributions are welcome! This project uses [changesets](https://github.com/changesets/changesets) for version management and automated releases.
579
615
 
580
- ### Making Changes
616
+ #### Making Changes
581
617
 
582
618
  1. Fork the repository and create a feature branch
583
619
  2. Make your changes and ensure tests pass (`pnpm test`)
@@ -594,7 +630,7 @@ pnpm changeset
594
630
  5. Commit the generated changeset file along with your changes
595
631
  6. Open a pull request
596
632
 
597
- ### Release Process
633
+ #### Release Process
598
634
 
599
635
  When your PR is merged to `main`:
600
636
 
@@ -602,19 +638,18 @@ When your PR is merged to `main`:
602
638
  2. This PR updates the version in `package.json` and generates `CHANGELOG.md` entries
603
639
  3. When the Version Packages PR is merged, the package is automatically published to npm
604
640
 
605
- ### Changeset Guidelines
641
+ #### Changeset Guidelines
606
642
 
607
643
  - **patch**: Bug fixes, documentation updates, internal refactoring
608
644
  - **minor**: New features, new CLI options, non-breaking enhancements
609
645
  - **major**: Breaking changes to CLI interface or behavior
610
646
 
611
- ## Support
647
+ ### Support
612
648
 
613
649
  This software is provided "as is" without warranty of any kind. Use at your own risk.
614
650
 
615
651
  You may file GitHub issues at [https://github.com/cephalization/phoenix-insight/issues](https://github.com/cephalization/phoenix-insight/issues).
616
652
 
653
+ ### License
617
654
 
618
- ## License
619
-
620
- Apache-2.0 - See [LICENSE](./LICENSE) for details.
655
+ Apache-2.0 - See [LICENSE](./LICENSE) for details.
package/dist/cli.js CHANGED
@@ -225,10 +225,10 @@ program
225
225
  });
226
226
  program
227
227
  .command("prune")
228
- .description("Delete the local snapshot directory (~/.phoenix-insight/)")
228
+ .description("Delete the local snapshot directory (~/.phoenix-insight/snapshots)")
229
229
  .option("--dry-run", "Show what would be deleted without actually deleting")
230
230
  .action(async (options) => {
231
- const snapshotDir = path.join(os.homedir(), ".phoenix-insight");
231
+ const snapshotDir = path.join(os.homedir(), ".phoenix-insight", "snapshots");
232
232
  try {
233
233
  // Check if the directory exists
234
234
  const stats = await fs.stat(snapshotDir).catch(() => null);
@@ -240,9 +240,7 @@ program
240
240
  console.log("🔍 Dry run mode - would delete:");
241
241
  console.log(` ${snapshotDir}`);
242
242
  // Show size and count of snapshots
243
- const snapshots = await fs
244
- .readdir(path.join(snapshotDir, "snapshots"))
245
- .catch(() => []);
243
+ const snapshots = await fs.readdir(snapshotDir).catch(() => []);
246
244
  console.log(` 📊 Contains ${snapshots.length} snapshot(s)`);
247
245
  return;
248
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cephalization/phoenix-insight",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A CLI for Arize AI Phoenix data analysis with AI agents",
5
5
  "type": "module",
6
6
  "exports": {
package/src/cli.ts CHANGED
@@ -268,10 +268,16 @@ program
268
268
 
269
269
  program
270
270
  .command("prune")
271
- .description("Delete the local snapshot directory (~/.phoenix-insight/)")
271
+ .description(
272
+ "Delete the local snapshot directory (~/.phoenix-insight/snapshots)"
273
+ )
272
274
  .option("--dry-run", "Show what would be deleted without actually deleting")
273
275
  .action(async (options) => {
274
- const snapshotDir = path.join(os.homedir(), ".phoenix-insight");
276
+ const snapshotDir = path.join(
277
+ os.homedir(),
278
+ ".phoenix-insight",
279
+ "snapshots"
280
+ );
275
281
 
276
282
  try {
277
283
  // Check if the directory exists
@@ -287,9 +293,7 @@ program
287
293
  console.log(` ${snapshotDir}`);
288
294
 
289
295
  // Show size and count of snapshots
290
- const snapshots = await fs
291
- .readdir(path.join(snapshotDir, "snapshots"))
292
- .catch(() => []);
296
+ const snapshots = await fs.readdir(snapshotDir).catch(() => []);
293
297
  console.log(` 📊 Contains ${snapshots.length} snapshot(s)`);
294
298
 
295
299
  return;