@cephalization/phoenix-insight 0.1.0 → 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.
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,139 +22,51 @@ 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
32
- phoenix-insight --local "analyze trace patterns"
33
-
34
- # Force fresh data
35
- phoenix-insight --refresh "show me the slowest endpoints"
36
-
37
31
  # Show help
38
32
  phoenix-insight help
39
33
  ```
40
34
 
41
- ## How It Works
42
-
43
- Phoenix Insight operates in three phases:
44
-
45
- 1. **Data Ingestion**: Fetches data from your Phoenix instance and creates a structured filesystem snapshot
46
- 2. **AI Analysis**: An AI agent explores the data using bash commands (cat, grep, jq, awk, etc.)
47
- 3. **Natural Language Results**: The agent synthesizes findings into clear, actionable insights
48
-
49
- ### Filesystem Structure
50
-
51
- Phoenix data is organized into an intuitive REST-like hierarchy:
52
-
53
- ```
54
- /phoenix/
55
- _context.md # Start here! Human-readable summary
56
- /projects/
57
- index.jsonl # All projects
58
- /{project_name}/
59
- metadata.json # Project details
60
- /spans/
61
- index.jsonl # Trace spans (sampled)
62
- /datasets/
63
- index.jsonl # All datasets
64
- /{dataset_name}/
65
- metadata.json
66
- examples.jsonl
67
- /experiments/
68
- index.jsonl # All experiments
69
- /{experiment_id}/
70
- metadata.json
71
- runs.jsonl
72
- /prompts/
73
- index.jsonl # All prompts
74
- /{prompt_name}/
75
- metadata.json
76
- /versions/
77
- /{version}.md # Prompt templates as markdown
78
- /traces/ # Fetched on-demand
79
- /{trace_id}/
80
- spans.jsonl
81
- metadata.json
82
- /_meta/
83
- snapshot.json # Snapshot metadata
84
- ```
85
-
86
- ## Execution Modes
87
-
88
- Phoenix Insight supports two execution modes:
89
-
90
- ### Sandbox Mode (default)
35
+ ## CLI Examples
91
36
 
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
37
+ This section covers all CLI usage, progressing from basic to advanced scenarios.
109
38
 
110
39
  ### Basic Queries
111
40
 
112
41
  ```bash
113
- # Analyze errors
42
+ # Ask a question about your Phoenix data
114
43
  phoenix-insight "What types of errors are occurring most frequently?"
115
44
 
116
- # Performance analysis
45
+ # Analyze performance patterns
117
46
  phoenix-insight "Find the slowest traces and identify patterns"
118
47
 
119
- # Experiment comparison
48
+ # Compare experiments
120
49
  phoenix-insight "Compare success rates across recent experiments"
121
50
 
122
- # Dataset exploration
51
+ # Explore datasets
123
52
  phoenix-insight "Show me statistics about my datasets"
124
53
  ```
125
54
 
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
136
-
137
- # Stream responses in real-time
138
- phoenix-insight "complex analysis task" --stream
139
-
140
- # Use local mode for persistent storage
141
- phoenix-insight "experimental query" --local
142
-
143
- # Enable observability tracing (sends traces to Phoenix)
144
- phoenix-insight "analyze performance" --trace
145
- ```
146
-
147
55
  ### Interactive Mode
148
56
 
149
- Start an interactive REPL session for multiple queries:
57
+ Start an interactive REPL session for multiple queries without re-fetching data:
150
58
 
151
59
  ```bash
152
60
  # Start interactive mode (default when no query is provided)
153
- $ phoenix-insight
61
+ phoenix-insight
154
62
 
155
63
  # Or explicitly with --interactive flag
156
- $ phoenix-insight --interactive
64
+ phoenix-insight --interactive
65
+ ```
157
66
 
67
+ Within interactive mode:
68
+
69
+ ```
158
70
  phoenix> What projects have the most spans?
159
71
  [Agent analyzes and responds...]
160
72
 
@@ -175,19 +87,23 @@ phoenix> exit
175
87
  Create or update snapshots separately from queries:
176
88
 
177
89
  ```bash
178
- # Create initial snapshot
90
+ # Create initial snapshot (explicit command)
91
+ phoenix-insight snapshot create
92
+
93
+ # Create initial snapshot (shorthand, same as 'snapshot create')
179
94
  phoenix-insight snapshot
180
95
 
181
- # Force refresh (ignore cache)
96
+ # Force refresh snapshot (ignore cache)
182
97
  phoenix-insight snapshot --refresh
183
98
 
184
- # Snapshot from specific Phoenix instance
185
- phoenix-insight snapshot \
186
- --base-url https://phoenix.example.com \
187
- --api-key your-api-key
99
+ # Snapshot from a specific Phoenix instance
100
+ phoenix-insight snapshot --base-url https://phoenix.example.com --api-key your-api-key
188
101
 
189
- # Enable observability tracing for snapshot process
190
- phoenix-insight snapshot --trace
102
+ # Get the path to the latest snapshot
103
+ phoenix-insight snapshot latest
104
+
105
+ # List all available snapshots
106
+ phoenix-insight snapshot list
191
107
 
192
108
  # Clean up local snapshots
193
109
  phoenix-insight prune
@@ -196,319 +112,345 @@ phoenix-insight prune
196
112
  phoenix-insight prune --dry-run
197
113
  ```
198
114
 
199
- ### On-Demand Data Fetching
200
-
201
- The agent can fetch additional data during analysis:
115
+ ### Local Mode
202
116
 
203
117
  ```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
207
-
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
118
+ # Run a query in local mode (persistent storage, full bash capabilities)
119
+ phoenix-insight --local "analyze trace patterns"
211
120
  ```
212
121
 
213
- ## Configuration
122
+ ### Connection Options
214
123
 
215
- Phoenix Insight uses a layered configuration system with the following priority (highest to lowest):
124
+ Connect to different Phoenix instances:
216
125
 
217
- 1. **CLI arguments** - Options passed directly to the command
218
- 2. **Environment variables** - `PHOENIX_*` environment variables
219
- 3. **Config file** - JSON file at `~/.phoenix-insight/config.json`
126
+ ```bash
127
+ # Connect to a remote Phoenix instance
128
+ phoenix-insight --base-url https://phoenix.example.com "analyze traces"
220
129
 
221
- ### Config File
130
+ # Authenticate with an API key
131
+ phoenix-insight --base-url https://phoenix.example.com --api-key your-api-key "show errors"
132
+ ```
222
133
 
223
- 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.
134
+ ### Data Fetching Options
224
135
 
225
- **Config file location:**
136
+ ```bash
137
+ # Increase span fetch limit (default: 1000 per project)
138
+ phoenix-insight --limit 5000 "deep trace analysis"
226
139
 
227
- - Default: `~/.phoenix-insight/config.json`
228
- - Override with env var: `PHOENIX_INSIGHT_CONFIG=/path/to/config.json`
229
- - Override with CLI flag: `--config /path/to/config.json`
140
+ # Force refresh of cached data
141
+ phoenix-insight --refresh "show me the latest errors"
142
+ ```
230
143
 
231
- **Example config.json with all options:**
144
+ ### Output Options
232
145
 
233
- ```json
234
- {
235
- "baseUrl": "http://localhost:6006",
236
- "apiKey": "your-api-key",
237
- "limit": 1000,
238
- "stream": true,
239
- "mode": "sandbox",
240
- "refresh": false,
241
- "trace": false
242
- }
146
+ ```bash
147
+ # Disable streaming for batch processing (streaming is enabled by default)
148
+ phoenix-insight --no-stream "generate report" > report.txt
243
149
  ```
244
150
 
245
- | Config Key | Type | Default | Description |
246
- | ---------- | ------------------------ | ----------------------- | --------------------------------------------- |
247
- | `baseUrl` | string | `http://localhost:6006` | Phoenix server URL |
248
- | `apiKey` | string | (none) | API key for authentication |
249
- | `limit` | number | `1000` | Maximum spans to fetch per project |
250
- | `stream` | boolean | `true` | Enable streaming responses from the agent |
251
- | `mode` | `"sandbox"` \| `"local"` | `"sandbox"` | Execution mode |
252
- | `refresh` | boolean | `false` | Force refresh of snapshot data |
253
- | `trace` | boolean | `false` | Enable tracing of agent operations to Phoenix |
151
+ ### Observability
254
152
 
255
- ### Environment Variables
153
+ ```bash
154
+ # Enable tracing of agent operations to Phoenix
155
+ phoenix-insight --trace "analyze performance"
156
+ ```
256
157
 
257
- | Variable | Config Key | Default | Description |
258
- | ------------------------- | ---------- | ----------------------- | -------------------------- |
259
- | `PHOENIX_BASE_URL` | `baseUrl` | `http://localhost:6006` | Phoenix server URL |
260
- | `PHOENIX_API_KEY` | `apiKey` | (none) | API key for authentication |
261
- | `PHOENIX_INSIGHT_LIMIT` | `limit` | `1000` | Max spans per project |
262
- | `PHOENIX_INSIGHT_STREAM` | `stream` | `true` | Enable streaming |
263
- | `PHOENIX_INSIGHT_MODE` | `mode` | `sandbox` | Execution mode |
264
- | `PHOENIX_INSIGHT_REFRESH` | `refresh` | `false` | Force refresh snapshot |
265
- | `PHOENIX_INSIGHT_TRACE` | `trace` | `false` | Enable tracing |
266
- | `PHOENIX_INSIGHT_CONFIG` | - | - | Custom config file path |
267
- | `DEBUG` | - | `0` | Show detailed error info |
158
+ ### On-Demand Data Fetching
268
159
 
269
- ### Commands
160
+ Within interactive mode, the agent can fetch additional data during analysis:
270
161
 
271
- Phoenix Insight provides several commands:
162
+ ```bash
163
+ px-fetch-more spans --project my-project --limit 500
164
+ px-fetch-more trace --trace-id abc123
165
+ ```
272
166
 
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
167
+ ### Combining Options
278
168
 
279
- ### Command Line Options
169
+ Combine multiple options for complex scenarios:
280
170
 
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 |
171
+ ```bash
172
+ # Remote instance with authentication, local mode, and increased limit
173
+ phoenix-insight --local --base-url https://phoenix.example.com \
174
+ --api-key your-api-key --limit 5000 "deep analysis of production traces"
294
175
 
295
- ### Local Mode Storage
176
+ # Refresh data, enable tracing, and stream output
177
+ phoenix-insight --refresh --trace --stream "analyze error patterns over time"
178
+ ```
296
179
 
297
- In local mode, data is stored in:
180
+ ## Example Queries
298
181
 
299
- ```
300
- ~/.phoenix-insight/
301
- config.json # Configuration (auto-created on first run)
302
- /snapshots/
303
- /{timestamp}/ # Each snapshot
304
- /phoenix/ # Phoenix data
305
- /cache/ # API response cache
306
- ```
182
+ Phoenix Insight understands natural language queries about your observability data. Here are examples organized by analysis type to help you get started.
307
183
 
308
- To clean up local storage:
184
+ ### Error Analysis
309
185
 
310
186
  ```bash
311
- # Delete all local snapshots
312
- phoenix-insight prune
313
-
314
- # Preview what will be deleted
315
- phoenix-insight prune --dry-run
187
+ # Find and categorize errors
188
+ phoenix-insight "What are the most common errors in the last 24 hours?"
189
+ phoenix-insight "Show me all failed spans and their error messages"
190
+ phoenix-insight "Which services have the highest error rates?"
191
+ phoenix-insight "Find traces that contain exceptions or timeouts"
316
192
  ```
317
193
 
318
- ## Troubleshooting
319
-
320
- ### Connection Issues
194
+ ### Performance & Latency
321
195
 
322
196
  ```bash
323
- # Test connection to Phoenix
324
- phoenix-insight snapshot
197
+ # Identify performance bottlenecks
198
+ phoenix-insight "What are the slowest LLM calls in my application?"
199
+ phoenix-insight "Find traces where latency exceeds 5 seconds"
200
+ phoenix-insight "Show p50, p95, and p99 latency by endpoint"
201
+ phoenix-insight "Which operations have the highest latency variance?"
202
+ ```
325
203
 
326
- # If that fails, check your Phoenix instance:
327
- curl http://localhost:6006/v1/projects
204
+ ### Token Usage & Costs
328
205
 
329
- # Verify with explicit connection:
330
- phoenix-insight snapshot --base-url http://your-phoenix:6006
206
+ ```bash
207
+ # Analyze LLM resource consumption
208
+ phoenix-insight "Which LLM calls are consuming the most tokens?"
209
+ phoenix-insight "Calculate total token usage for the chatbot project"
210
+ phoenix-insight "Show token usage breakdown by model type"
211
+ phoenix-insight "Find conversations that exceeded 10,000 tokens"
331
212
  ```
332
213
 
333
- ### Authentication Errors
214
+ ### RAG Analysis
334
215
 
335
216
  ```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"
217
+ # Examine retrieval-augmented generation patterns
218
+ phoenix-insight "Show retrieved documents with low relevance scores"
219
+ phoenix-insight "Find retrieval calls that returned no results"
220
+ phoenix-insight "What's the average number of documents retrieved per query?"
221
+ phoenix-insight "Identify queries where retrieval latency dominated total time"
342
222
  ```
343
223
 
344
- ### Debug Mode
345
-
346
- For detailed error information:
224
+ ### Evaluations & Experiments
347
225
 
348
226
  ```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
227
+ # Review evaluation results and experiment metrics
228
+ phoenix-insight "What's the hallucination rate across my experiments?"
229
+ phoenix-insight "Compare accuracy scores between model versions"
230
+ phoenix-insight "Show experiments sorted by success rate"
231
+ phoenix-insight "Find evaluation runs where quality scores dropped below threshold"
357
232
  ```
358
233
 
359
- ### Common Issues
360
-
361
- **"No snapshot found" in local mode**
234
+ ### Dataset Analysis
362
235
 
363
236
  ```bash
364
- # Create initial snapshot
365
- phoenix-insight snapshot
366
-
367
- # Or use --refresh to create on-demand
368
- phoenix-insight "query" --refresh
237
+ # Explore datasets and examples
238
+ phoenix-insight "Show statistics for my evaluation datasets"
239
+ phoenix-insight "Find examples where the model failed quality checks"
240
+ phoenix-insight "What's the distribution of example categories in my dataset?"
241
+ phoenix-insight "List datasets with the most recent updates"
369
242
  ```
370
243
 
371
- **Out of memory in sandbox mode**
244
+ ### Prompt Engineering
372
245
 
373
246
  ```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
247
+ # Analyze prompt versions and performance
248
+ phoenix-insight "List all prompt versions and their performance metrics"
249
+ phoenix-insight "Compare outputs between prompt v1 and v2"
250
+ phoenix-insight "Which prompt template has the lowest error rate?"
251
+ phoenix-insight "Show the evolution of my summarization prompt"
379
252
  ```
380
253
 
381
- **Local storage getting too large**
254
+ ### Session & Conversation Analysis
382
255
 
383
256
  ```bash
384
- # Check what will be deleted
385
- phoenix-insight prune --dry-run
386
-
387
- # Clean up all local snapshots
388
- phoenix-insight prune
257
+ # Understand user interaction patterns
258
+ phoenix-insight "Show the conversation flow for session abc123"
259
+ phoenix-insight "Find sessions with high user abandonment"
260
+ phoenix-insight "What's the average conversation length by project?"
261
+ phoenix-insight "Identify sessions where users repeated similar queries"
389
262
  ```
390
263
 
391
- **Agent can't find expected data**
264
+ ### Tool & Function Calls
392
265
 
393
266
  ```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
267
+ # Analyze agent tool usage
268
+ phoenix-insight "Which tools are being called most frequently?"
269
+ phoenix-insight "Find tool calls that failed or timed out"
270
+ phoenix-insight "Show the success rate for each tool type"
271
+ phoenix-insight "What's the average latency for function calls?"
399
272
  ```
400
273
 
401
- ## Observability
274
+ ## Command Reference
402
275
 
403
- Phoenix Insight can trace its own execution back to Phoenix for monitoring and debugging:
276
+ Phoenix Insight provides several commands, each with its own options.
404
277
 
405
- ```bash
406
- # Enable tracing for queries
407
- phoenix-insight "analyze errors" --trace
278
+ ### Query Command (Default)
408
279
 
409
- # Enable tracing in interactive mode
410
- phoenix-insight --interactive --trace
280
+ The default command analyzes Phoenix data with natural language queries.
411
281
 
412
- # Enable tracing for snapshot creation
413
- phoenix-insight snapshot --trace
282
+ ```bash
283
+ phoenix-insight [options] [query]
414
284
  ```
415
285
 
416
- When `--trace` is enabled:
286
+ | Option | Description | Default | Example |
287
+ | ------------------- | --------------------------------------------- | ----------------------- | ---------------------------------------------- |
288
+ | `--config <path>` | Custom config file path | `~/.phoenix-insight/config.json` | `--config ./my-config.json` |
289
+ | `--sandbox` | Run in sandbox mode with in-memory filesystem | `true` | `phoenix-insight --sandbox "query"` |
290
+ | `--local` | Run in local mode with persistent storage | `false` | `phoenix-insight --local "query"` |
291
+ | `--base-url <url>` | Phoenix server URL | `http://localhost:6006` | `--base-url https://phoenix.example.com` |
292
+ | `--api-key <key>` | Phoenix API key for authentication | (none) | `--api-key your-api-key` |
293
+ | `--refresh` | Force refresh of cached snapshot data | `false` | `phoenix-insight --refresh "show latest data"` |
294
+ | `--limit <n>` | Maximum spans to fetch per project | `1000` | `--limit 5000` |
295
+ | `--stream` | Stream agent responses in real-time | `true` | `--no-stream` to disable |
296
+ | `-i, --interactive` | Start interactive REPL mode | `false` | `phoenix-insight -i` |
297
+ | `--trace` | Enable tracing of agent operations to Phoenix | `false` | `phoenix-insight --trace "query"` |
417
298
 
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)
299
+ ### Snapshot Command
422
300
 
423
- This is particularly useful for:
301
+ Creates or updates a data snapshot from Phoenix without running a query.
424
302
 
425
- - Debugging slow queries
426
- - Understanding agent decision-making
427
- - Monitoring Phoenix Insight usage
428
- - Optimizing performance
303
+ ```bash
304
+ phoenix-insight snapshot [options]
305
+ phoenix-insight snapshot create [options]
306
+ ```
429
307
 
430
- ## Agent Capabilities
308
+ Note: `phoenix-insight snapshot` (without subcommand) is equivalent to `phoenix-insight snapshot create` for backward compatibility.
431
309
 
432
- The AI agent has access to:
310
+ | Option | Description | Default | Example |
311
+ | ------------------ | --------------------------------------------- | ----------------------- | ----------------------------------------------- |
312
+ | `--config <path>` | Custom config file path | `~/.phoenix-insight/config.json` | `--config ./my-config.json` |
313
+ | `--base-url <url>` | Phoenix server URL | `http://localhost:6006` | `--base-url https://phoenix.example.com` |
314
+ | `--api-key <key>` | Phoenix API key for authentication | (none) | `--api-key your-api-key` |
315
+ | `--refresh` | Force refresh (ignore existing cache) | `false` | `phoenix-insight snapshot --refresh` |
316
+ | `--limit <n>` | Maximum spans to fetch per project | `1000` | `phoenix-insight snapshot --limit 5000` |
317
+ | `--trace` | Enable tracing of snapshot operations | `false` | `phoenix-insight snapshot --trace` |
433
318
 
434
- ### Bash Commands (Sandbox Mode)
319
+ ### Snapshot Create Subcommand
435
320
 
436
- - **File operations**: `cat`, `ls`, `find`, `head`, `tail`
437
- - **Search & filter**: `grep`, `awk`, `sed`
438
- - **JSON processing**: `jq` (full featured)
439
- - **Analysis**: `sort`, `uniq`, `wc`
440
- - **And more**: 50+ commands via just-bash
321
+ Explicitly creates a new snapshot from Phoenix data. This is the preferred way to create snapshots.
441
322
 
442
- ### Bash Commands (Local Mode)
323
+ ```bash
324
+ phoenix-insight snapshot create
325
+ ```
443
326
 
444
- - All commands available on your system
445
- - Custom tools: `ripgrep`, `fd`, `bat`, etc.
446
- - Full `jq`, `awk`, `sed` features
447
- - Any installed CLI tools
327
+ Same options as `phoenix-insight snapshot`. Use `snapshot create` for clarity in scripts and automation.
448
328
 
449
- ### Custom Commands
329
+ ### Snapshot Latest Command
450
330
 
451
- - `px-fetch-more spans`: Fetch additional spans
452
- - `px-fetch-more trace`: Fetch specific trace by ID
331
+ Prints the absolute path to the latest snapshot directory.
453
332
 
454
- ### Understanding Context
333
+ ```bash
334
+ phoenix-insight snapshot latest
335
+ ```
455
336
 
456
- The agent always starts by reading `/_context.md` which provides:
337
+ Outputs the path to stdout with no decoration (just the path). Exit code 0 on success, exit code 1 if no snapshots exist.
457
338
 
458
- - Summary of available data
459
- - Recent activity highlights
460
- - Data freshness information
461
- - Available commands reminder
339
+ **Example usage:**
340
+
341
+ ```bash
342
+ # Get the latest snapshot path
343
+ phoenix-insight snapshot latest
344
+ # Output: /Users/you/.phoenix-insight/snapshots/1704067200000-abc123/phoenix
345
+
346
+ # Use in scripts
347
+ SNAPSHOT_PATH=$(phoenix-insight snapshot latest)
348
+ ls "$SNAPSHOT_PATH"
349
+
350
+ # Check if snapshots exist
351
+ if phoenix-insight snapshot latest > /dev/null 2>&1; then
352
+ echo "Snapshots available"
353
+ else
354
+ echo "No snapshots found"
355
+ fi
356
+ ```
462
357
 
463
- ## Development
358
+ ### Snapshot List Command
464
359
 
465
- ### Building from Source
360
+ Lists all available snapshots with their timestamps.
466
361
 
467
362
  ```bash
468
- # Clone the repository
469
- git clone https://github.com/Arize-ai/phoenix.git
470
- cd phoenix/js/packages/phoenix-insight
363
+ phoenix-insight snapshot list
364
+ ```
471
365
 
472
- # Install dependencies
473
- pnpm install
366
+ Outputs one snapshot per line in the format `<timestamp> <path>` where timestamp is ISO 8601. Most recent first. Exit code 0 even if empty (just prints nothing).
474
367
 
475
- # Run in development
476
- pnpm dev "your query"
368
+ **Example usage:**
477
369
 
478
- # Run tests
479
- pnpm test
370
+ ```bash
371
+ # List all snapshots
372
+ phoenix-insight snapshot list
373
+ # Output:
374
+ # 2024-01-01T12:30:00.000Z /Users/you/.phoenix-insight/snapshots/1704113400000-abc123/phoenix
375
+ # 2024-01-01T10:00:00.000Z /Users/you/.phoenix-insight/snapshots/1704104400000-def456/phoenix
376
+
377
+ # Count snapshots
378
+ phoenix-insight snapshot list | wc -l
379
+
380
+ # Get oldest snapshot path
381
+ phoenix-insight snapshot list | tail -1 | cut -d' ' -f2
382
+
383
+ # Process snapshots in a script
384
+ phoenix-insight snapshot list | while read timestamp path; do
385
+ echo "Snapshot from $timestamp at $path"
386
+ done
387
+ ```
480
388
 
481
- # Build for production
482
- pnpm build
389
+ ### Prune Command
483
390
 
484
- # Type checking
485
- pnpm typecheck
391
+ Deletes the local snapshot directory to free up disk space.
392
+
393
+ ```bash
394
+ phoenix-insight prune [options]
486
395
  ```
487
396
 
488
- ### Architecture
397
+ | Option | Description | Default | Example |
398
+ | ----------- | ---------------------------------------- | ------- | ------------------------------- |
399
+ | `--dry-run` | Preview what would be deleted without actually deleting | `false` | `phoenix-insight prune --dry-run` |
489
400
 
490
- Phoenix Insight uses:
401
+ ### Help Command
491
402
 
492
- - **Commander.js** for CLI interface
493
- - **AI SDK** with Anthropic Claude for the agent
494
- - **just-bash** for sandbox execution
495
- - **Phoenix Client** for data fetching
496
- - **TypeScript** for type safety
497
-
498
- ### Testing
403
+ Displays help information and available options.
499
404
 
500
405
  ```bash
501
- # Run all tests
502
- pnpm test
406
+ phoenix-insight help
407
+ ```
503
408
 
504
- # Run with coverage
505
- pnpm test -- --coverage
409
+ No additional options. Shows usage information, all commands, and their options.
506
410
 
507
- # Run specific test file
508
- pnpm test src/modes/sandbox.test.ts
411
+ ## How It Works
412
+
413
+ Phoenix Insight operates in three phases:
414
+
415
+ 1. **Data Ingestion**: Fetches data from your Phoenix instance and creates a structured filesystem snapshot
416
+ 2. **AI Analysis**: An AI agent explores the data using bash commands (cat, grep, jq, awk, etc.)
417
+ 3. **Natural Language Results**: The agent synthesizes findings into clear, actionable insights
418
+
419
+ ### Filesystem Structure
420
+
421
+ Phoenix data is organized into an intuitive REST-like hierarchy:
509
422
 
510
- # Type checking
511
- pnpm typecheck
423
+ ```
424
+ /phoenix/
425
+ _context.md # Start here! Human-readable summary
426
+ /projects/
427
+ index.jsonl # All projects
428
+ /{project_name}/
429
+ metadata.json # Project details
430
+ /spans/
431
+ index.jsonl # Trace spans (sampled)
432
+ /datasets/
433
+ index.jsonl # All datasets
434
+ /{dataset_name}/
435
+ metadata.json
436
+ examples.jsonl
437
+ /experiments/
438
+ index.jsonl # All experiments
439
+ /{experiment_id}/
440
+ metadata.json
441
+ runs.jsonl
442
+ /prompts/
443
+ index.jsonl # All prompts
444
+ /{prompt_name}/
445
+ metadata.json
446
+ /versions/
447
+ /{version}.md # Prompt templates as markdown
448
+ /traces/ # Fetched on-demand
449
+ /{trace_id}/
450
+ spans.jsonl
451
+ metadata.json
452
+ /_meta/
453
+ snapshot.json # Snapshot metadata
512
454
  ```
513
455
 
514
456
  ## Examples of Agent Analysis
@@ -573,11 +515,187 @@ The recommendations endpoint has high variability, suggesting cache misses.
573
515
  - Never put API keys in queries
574
516
  - Review agent actions with `--stream`
575
517
 
576
- ## Contributing & Releases
518
+ ## Advanced Topics
519
+
520
+ The following sections cover configuration, execution modes, and internal details for power users.
521
+
522
+ ### Configuration
523
+
524
+ Phoenix Insight uses a layered configuration system with the following priority (highest to lowest):
525
+
526
+ 1. **CLI arguments** - Options passed directly to the command
527
+ 2. **Environment variables** - `PHOENIX_*` environment variables
528
+ 3. **Config file** - JSON file at `~/.phoenix-insight/config.json`
529
+
530
+ #### Config File
531
+
532
+ 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.
533
+
534
+ **Config file location:**
535
+
536
+ - Default: `~/.phoenix-insight/config.json`
537
+ - Override with env var: `PHOENIX_INSIGHT_CONFIG=/path/to/config.json`
538
+ - Override with CLI flag: `--config /path/to/config.json`
539
+
540
+ **Example config.json with all options:**
541
+
542
+ ```json
543
+ {
544
+ "baseUrl": "http://localhost:6006",
545
+ "apiKey": "your-api-key",
546
+ "limit": 1000,
547
+ "stream": true,
548
+ "mode": "sandbox",
549
+ "refresh": false,
550
+ "trace": false
551
+ }
552
+ ```
553
+
554
+ | Config Key | Type | Default | Description |
555
+ | ---------- | ------------------------ | ----------------------- | --------------------------------------------- |
556
+ | `baseUrl` | string | `http://localhost:6006` | Phoenix server URL |
557
+ | `apiKey` | string | (none) | API key for authentication |
558
+ | `limit` | number | `1000` | Maximum spans to fetch per project |
559
+ | `stream` | boolean | `true` | Enable streaming responses from the agent |
560
+ | `mode` | `"sandbox"` \| `"local"` | `"sandbox"` | Execution mode |
561
+ | `refresh` | boolean | `false` | Force refresh of snapshot data |
562
+ | `trace` | boolean | `false` | Enable tracing of agent operations to Phoenix |
563
+
564
+ #### Environment Variables
565
+
566
+ | Variable | Config Key | Default | Description |
567
+ | ------------------------- | ---------- | ----------------------- | -------------------------- |
568
+ | `PHOENIX_BASE_URL` | `baseUrl` | `http://localhost:6006` | Phoenix server URL |
569
+ | `PHOENIX_API_KEY` | `apiKey` | (none) | API key for authentication |
570
+ | `PHOENIX_INSIGHT_LIMIT` | `limit` | `1000` | Max spans per project |
571
+ | `PHOENIX_INSIGHT_STREAM` | `stream` | `true` | Enable streaming |
572
+ | `PHOENIX_INSIGHT_MODE` | `mode` | `sandbox` | Execution mode |
573
+ | `PHOENIX_INSIGHT_REFRESH` | `refresh` | `false` | Force refresh snapshot |
574
+ | `PHOENIX_INSIGHT_TRACE` | `trace` | `false` | Enable tracing |
575
+ | `PHOENIX_INSIGHT_CONFIG` | - | - | Custom config file path |
576
+ | `DEBUG` | - | `0` | Show detailed error info |
577
+
578
+ #### Local Mode Storage
579
+
580
+ In local mode (`--local`), data persists at `~/.phoenix-insight/`:
581
+
582
+ ```
583
+ ~/.phoenix-insight/
584
+ config.json # Configuration (auto-created on first run)
585
+ /snapshots/{timestamp}/ # Snapshot data
586
+ /cache/ # API response cache
587
+ ```
588
+
589
+ Use `phoenix-insight prune` to clean up local storage.
590
+
591
+ ### Execution Modes
592
+
593
+ Phoenix Insight supports two execution modes:
594
+
595
+ | Mode | Flag | Filesystem | Bash | Use Case |
596
+ |------|------|------------|------|----------|
597
+ | **Sandbox** (default) | `--sandbox` | In-memory | [just-bash](https://github.com/vercel-labs/just-bash) (50+ commands) | CI/CD, demos, safe exploration |
598
+ | **Local** | `--local` | Persistent (`~/.phoenix-insight/`) | Real system bash | Power users, complex analysis |
599
+
600
+ ### Agent Capabilities
601
+
602
+ The AI agent has access to:
603
+
604
+ #### Bash Commands (Sandbox Mode)
605
+
606
+ - **File operations**: `cat`, `ls`, `find`, `head`, `tail`
607
+ - **Search & filter**: `grep`, `awk`, `sed`
608
+ - **JSON processing**: `jq` (full featured)
609
+ - **Analysis**: `sort`, `uniq`, `wc`
610
+ - **And more**: 50+ commands via just-bash
611
+
612
+ #### Bash Commands (Local Mode)
613
+
614
+ - All commands available on your system
615
+ - Custom tools: `ripgrep`, `fd`, `bat`, etc.
616
+ - Full `jq`, `awk`, `sed` features
617
+ - Any installed CLI tools
618
+
619
+ #### Custom Commands
620
+
621
+ - `px-fetch-more spans`: Fetch additional spans for deeper analysis
622
+ - `px-fetch-more trace`: Fetch a specific trace by ID
623
+
624
+ See [On-Demand Data Fetching](#on-demand-data-fetching) for usage examples.
625
+
626
+ #### Understanding Context
627
+
628
+ The agent always starts by reading `/_context.md` which provides:
629
+
630
+ - Summary of available data
631
+ - Recent activity highlights
632
+ - Data freshness information
633
+ - Available commands reminder
634
+
635
+ ### Observability
636
+
637
+ 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.
638
+
639
+ ### Troubleshooting
640
+
641
+ For connection issues, authentication errors, debug mode, and common issues, see the [Troubleshooting Guide](./TROUBLESHOOTING.md).
642
+
643
+ ### Development
644
+
645
+ #### Building from Source
646
+
647
+ ```bash
648
+ # Clone the repository
649
+ git clone https://github.com/Arize-ai/phoenix.git
650
+ cd phoenix/js/packages/phoenix-insight
651
+
652
+ # Install dependencies
653
+ pnpm install
654
+
655
+ # Run in development
656
+ pnpm dev "your query"
657
+
658
+ # Run tests
659
+ pnpm test
660
+
661
+ # Build for production
662
+ pnpm build
663
+
664
+ # Type checking
665
+ pnpm typecheck
666
+ ```
667
+
668
+ #### Architecture
669
+
670
+ Phoenix Insight uses:
671
+
672
+ - **Commander.js** for CLI interface
673
+ - **AI SDK** with Anthropic Claude for the agent
674
+ - **just-bash** for sandbox execution
675
+ - **Phoenix Client** for data fetching
676
+ - **TypeScript** for type safety
677
+
678
+ #### Testing
679
+
680
+ ```bash
681
+ # Run all tests
682
+ pnpm test
683
+
684
+ # Run with coverage
685
+ pnpm test -- --coverage
686
+
687
+ # Run specific test file
688
+ pnpm test test/modes/sandbox.test.ts
689
+
690
+ # Type checking
691
+ pnpm typecheck
692
+ ```
693
+
694
+ ### Contributing & Releases
577
695
 
578
696
  Contributions are welcome! This project uses [changesets](https://github.com/changesets/changesets) for version management and automated releases.
579
697
 
580
- ### Making Changes
698
+ #### Making Changes
581
699
 
582
700
  1. Fork the repository and create a feature branch
583
701
  2. Make your changes and ensure tests pass (`pnpm test`)
@@ -594,7 +712,7 @@ pnpm changeset
594
712
  5. Commit the generated changeset file along with your changes
595
713
  6. Open a pull request
596
714
 
597
- ### Release Process
715
+ #### Release Process
598
716
 
599
717
  When your PR is merged to `main`:
600
718
 
@@ -602,19 +720,18 @@ When your PR is merged to `main`:
602
720
  2. This PR updates the version in `package.json` and generates `CHANGELOG.md` entries
603
721
  3. When the Version Packages PR is merged, the package is automatically published to npm
604
722
 
605
- ### Changeset Guidelines
723
+ #### Changeset Guidelines
606
724
 
607
725
  - **patch**: Bug fixes, documentation updates, internal refactoring
608
726
  - **minor**: New features, new CLI options, non-breaking enhancements
609
727
  - **major**: Breaking changes to CLI interface or behavior
610
728
 
611
- ## Support
729
+ ### Support
612
730
 
613
731
  This software is provided "as is" without warranty of any kind. Use at your own risk.
614
732
 
615
733
  You may file GitHub issues at [https://github.com/cephalization/phoenix-insight/issues](https://github.com/cephalization/phoenix-insight/issues).
616
734
 
735
+ ### License
617
736
 
618
- ## License
619
-
620
- Apache-2.0 - See [LICENSE](./LICENSE) for details.
737
+ Apache-2.0 - See [LICENSE](./LICENSE) for details.