@cephalization/phoenix-insight 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +620 -0
- package/dist/agent/index.js +230 -0
- package/dist/cli.js +640 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/px-fetch-more-spans.js +98 -0
- package/dist/commands/px-fetch-more-trace.js +110 -0
- package/dist/config/index.js +165 -0
- package/dist/config/loader.js +141 -0
- package/dist/config/schema.js +53 -0
- package/dist/index.js +1 -0
- package/dist/modes/index.js +17 -0
- package/dist/modes/local.js +134 -0
- package/dist/modes/sandbox.js +121 -0
- package/dist/modes/types.js +1 -0
- package/dist/observability/index.js +65 -0
- package/dist/progress.js +209 -0
- package/dist/prompts/index.js +1 -0
- package/dist/prompts/system.js +30 -0
- package/dist/snapshot/client.js +74 -0
- package/dist/snapshot/context.js +332 -0
- package/dist/snapshot/datasets.js +68 -0
- package/dist/snapshot/experiments.js +135 -0
- package/dist/snapshot/index.js +262 -0
- package/dist/snapshot/projects.js +44 -0
- package/dist/snapshot/prompts.js +199 -0
- package/dist/snapshot/spans.js +80 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +75 -0
- package/src/agent/index.ts +323 -0
- package/src/cli.ts +782 -0
- package/src/commands/index.ts +8 -0
- package/src/commands/px-fetch-more-spans.ts +174 -0
- package/src/commands/px-fetch-more-trace.ts +183 -0
- package/src/config/index.ts +225 -0
- package/src/config/loader.ts +173 -0
- package/src/config/schema.ts +66 -0
- package/src/index.ts +1 -0
- package/src/modes/index.ts +21 -0
- package/src/modes/local.ts +163 -0
- package/src/modes/sandbox.ts +144 -0
- package/src/modes/types.ts +31 -0
- package/src/observability/index.ts +90 -0
- package/src/progress.ts +239 -0
- package/src/prompts/index.ts +1 -0
- package/src/prompts/system.ts +31 -0
- package/src/snapshot/client.ts +129 -0
- package/src/snapshot/context.ts +462 -0
- package/src/snapshot/datasets.ts +132 -0
- package/src/snapshot/experiments.ts +246 -0
- package/src/snapshot/index.ts +403 -0
- package/src/snapshot/projects.ts +58 -0
- package/src/snapshot/prompts.ts +267 -0
- package/src/snapshot/spans.ts +142 -0
package/README.md
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
# Phoenix Insight CLI
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@cephalization/phoenix-insight)
|
|
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).
|
|
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.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install globally via npm
|
|
13
|
+
npm install -g @cephalization/phoenix-insight
|
|
14
|
+
|
|
15
|
+
# Or use with pnpm
|
|
16
|
+
pnpm add -g @cephalization/phoenix-insight
|
|
17
|
+
|
|
18
|
+
# Or run directly with npx
|
|
19
|
+
npx @cephalization/phoenix-insight "your query"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Start interactive mode (no arguments needed)
|
|
26
|
+
phoenix-insight
|
|
27
|
+
|
|
28
|
+
# Query Phoenix data with natural language
|
|
29
|
+
phoenix-insight "What are the most common errors in the last hour?"
|
|
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
|
+
# Show help
|
|
38
|
+
phoenix-insight help
|
|
39
|
+
```
|
|
40
|
+
|
|
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)
|
|
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"
|
|
118
|
+
|
|
119
|
+
# Experiment comparison
|
|
120
|
+
phoenix-insight "Compare success rates across recent experiments"
|
|
121
|
+
|
|
122
|
+
# Dataset exploration
|
|
123
|
+
phoenix-insight "Show me statistics about my datasets"
|
|
124
|
+
```
|
|
125
|
+
|
|
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
|
+
### 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
|
|
157
|
+
|
|
158
|
+
phoenix> What projects have the most spans?
|
|
159
|
+
[Agent analyzes and responds...]
|
|
160
|
+
|
|
161
|
+
phoenix> Show me error patterns in the chatbot-prod project
|
|
162
|
+
[Agent investigates specific project...]
|
|
163
|
+
|
|
164
|
+
phoenix> px-fetch-more trace --trace-id abc123
|
|
165
|
+
[Agent fetches specific trace data...]
|
|
166
|
+
|
|
167
|
+
phoenix> help
|
|
168
|
+
[Shows available commands and tips...]
|
|
169
|
+
|
|
170
|
+
phoenix> exit
|
|
171
|
+
```
|
|
172
|
+
|
|
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
|
|
183
|
+
|
|
184
|
+
# Snapshot from specific Phoenix instance
|
|
185
|
+
phoenix-insight snapshot \
|
|
186
|
+
--base-url https://phoenix.example.com \
|
|
187
|
+
--api-key your-api-key
|
|
188
|
+
|
|
189
|
+
# Enable observability tracing for snapshot process
|
|
190
|
+
phoenix-insight snapshot --trace
|
|
191
|
+
|
|
192
|
+
# Clean up local snapshots
|
|
193
|
+
phoenix-insight prune
|
|
194
|
+
|
|
195
|
+
# Preview what would be deleted
|
|
196
|
+
phoenix-insight prune --dry-run
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### On-Demand Data Fetching
|
|
200
|
+
|
|
201
|
+
The agent can fetch additional data during analysis:
|
|
202
|
+
|
|
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
|
|
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
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Configuration
|
|
214
|
+
|
|
215
|
+
Phoenix Insight uses a layered configuration system with the following priority (highest to lowest):
|
|
216
|
+
|
|
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`
|
|
220
|
+
|
|
221
|
+
### Config File
|
|
222
|
+
|
|
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.
|
|
224
|
+
|
|
225
|
+
**Config file location:**
|
|
226
|
+
|
|
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`
|
|
230
|
+
|
|
231
|
+
**Example config.json with all options:**
|
|
232
|
+
|
|
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
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
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 |
|
|
254
|
+
|
|
255
|
+
### Environment Variables
|
|
256
|
+
|
|
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 |
|
|
268
|
+
|
|
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
|
|
296
|
+
|
|
297
|
+
In local mode, data is stored in:
|
|
298
|
+
|
|
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
|
+
```
|
|
307
|
+
|
|
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
|
+
```
|
|
317
|
+
|
|
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
|
|
366
|
+
|
|
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:
|
|
424
|
+
|
|
425
|
+
- Debugging slow queries
|
|
426
|
+
- Understanding agent decision-making
|
|
427
|
+
- Monitoring Phoenix Insight usage
|
|
428
|
+
- Optimizing performance
|
|
429
|
+
|
|
430
|
+
## Agent Capabilities
|
|
431
|
+
|
|
432
|
+
The AI agent has access to:
|
|
433
|
+
|
|
434
|
+
### Bash Commands (Sandbox Mode)
|
|
435
|
+
|
|
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
|
|
441
|
+
|
|
442
|
+
### Bash Commands (Local Mode)
|
|
443
|
+
|
|
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
|
|
448
|
+
|
|
449
|
+
### Custom Commands
|
|
450
|
+
|
|
451
|
+
- `px-fetch-more spans`: Fetch additional spans
|
|
452
|
+
- `px-fetch-more trace`: Fetch specific trace by ID
|
|
453
|
+
|
|
454
|
+
### Understanding Context
|
|
455
|
+
|
|
456
|
+
The agent always starts by reading `/_context.md` which provides:
|
|
457
|
+
|
|
458
|
+
- Summary of available data
|
|
459
|
+
- Recent activity highlights
|
|
460
|
+
- Data freshness information
|
|
461
|
+
- Available commands reminder
|
|
462
|
+
|
|
463
|
+
## Development
|
|
464
|
+
|
|
465
|
+
### Building from Source
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
# Clone the repository
|
|
469
|
+
git clone https://github.com/Arize-ai/phoenix.git
|
|
470
|
+
cd phoenix/js/packages/phoenix-insight
|
|
471
|
+
|
|
472
|
+
# Install dependencies
|
|
473
|
+
pnpm install
|
|
474
|
+
|
|
475
|
+
# Run in development
|
|
476
|
+
pnpm dev "your query"
|
|
477
|
+
|
|
478
|
+
# Run tests
|
|
479
|
+
pnpm test
|
|
480
|
+
|
|
481
|
+
# Build for production
|
|
482
|
+
pnpm build
|
|
483
|
+
|
|
484
|
+
# Type checking
|
|
485
|
+
pnpm typecheck
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Architecture
|
|
489
|
+
|
|
490
|
+
Phoenix Insight uses:
|
|
491
|
+
|
|
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
|
|
499
|
+
|
|
500
|
+
```bash
|
|
501
|
+
# Run all tests
|
|
502
|
+
pnpm test
|
|
503
|
+
|
|
504
|
+
# Run with coverage
|
|
505
|
+
pnpm test -- --coverage
|
|
506
|
+
|
|
507
|
+
# Run specific test file
|
|
508
|
+
pnpm test src/modes/sandbox.test.ts
|
|
509
|
+
|
|
510
|
+
# Type checking
|
|
511
|
+
pnpm typecheck
|
|
512
|
+
```
|
|
513
|
+
|
|
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
|
|
577
|
+
|
|
578
|
+
Contributions are welcome! This project uses [changesets](https://github.com/changesets/changesets) for version management and automated releases.
|
|
579
|
+
|
|
580
|
+
### Making Changes
|
|
581
|
+
|
|
582
|
+
1. Fork the repository and create a feature branch
|
|
583
|
+
2. Make your changes and ensure tests pass (`pnpm test`)
|
|
584
|
+
3. Create a changeset to document your changes:
|
|
585
|
+
|
|
586
|
+
```bash
|
|
587
|
+
pnpm changeset
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
4. Follow the prompts to:
|
|
591
|
+
- Select the type of change (patch, minor, major)
|
|
592
|
+
- Describe what changed for the changelog
|
|
593
|
+
|
|
594
|
+
5. Commit the generated changeset file along with your changes
|
|
595
|
+
6. Open a pull request
|
|
596
|
+
|
|
597
|
+
### Release Process
|
|
598
|
+
|
|
599
|
+
When your PR is merged to `main`:
|
|
600
|
+
|
|
601
|
+
1. If there are pending changesets, a "Version Packages" PR is automatically created
|
|
602
|
+
2. This PR updates the version in `package.json` and generates `CHANGELOG.md` entries
|
|
603
|
+
3. When the Version Packages PR is merged, the package is automatically published to npm
|
|
604
|
+
|
|
605
|
+
### Changeset Guidelines
|
|
606
|
+
|
|
607
|
+
- **patch**: Bug fixes, documentation updates, internal refactoring
|
|
608
|
+
- **minor**: New features, new CLI options, non-breaking enhancements
|
|
609
|
+
- **major**: Breaking changes to CLI interface or behavior
|
|
610
|
+
|
|
611
|
+
## Support
|
|
612
|
+
|
|
613
|
+
This software is provided "as is" without warranty of any kind. Use at your own risk.
|
|
614
|
+
|
|
615
|
+
You may file GitHub issues at [https://github.com/cephalization/phoenix-insight/issues](https://github.com/cephalization/phoenix-insight/issues).
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
## License
|
|
619
|
+
|
|
620
|
+
Apache-2.0 - See [LICENSE](./LICENSE) for details.
|