@cephalization/phoenix-insight 1.0.0 → 1.0.2
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/dist/chunk-KEQDYZIE.js +237 -0
- package/dist/chunk-KEQDYZIE.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3942 -806
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -0
- package/package.json +10 -8
- package/dist/agent/index.js +0 -235
- package/dist/commands/index.js +0 -3
- package/dist/commands/px-fetch-more-spans.js +0 -98
- package/dist/commands/px-fetch-more-trace.js +0 -110
- package/dist/commands/report-tool.js +0 -239
- package/dist/config/index.js +0 -165
- package/dist/config/loader.js +0 -141
- package/dist/config/schema.js +0 -53
- package/dist/modes/index.js +0 -17
- package/dist/modes/local.js +0 -141
- package/dist/modes/sandbox.js +0 -129
- package/dist/modes/types.js +0 -1
- package/dist/observability/index.js +0 -65
- package/dist/progress.js +0 -209
- package/dist/prompts/index.js +0 -1
- package/dist/prompts/system.js +0 -37
- package/dist/server/session.js +0 -357
- package/dist/server/ui.js +0 -232
- package/dist/server/websocket.js +0 -212
- package/dist/snapshot/client.js +0 -74
- package/dist/snapshot/context.js +0 -441
- package/dist/snapshot/datasets.js +0 -68
- package/dist/snapshot/experiments.js +0 -135
- package/dist/snapshot/index.js +0 -262
- package/dist/snapshot/projects.js +0 -44
- package/dist/snapshot/prompts.js +0 -199
- package/dist/snapshot/spans.js +0 -104
- package/dist/snapshot/utils.js +0 -112
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
package/dist/snapshot/utils.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot discovery utilities
|
|
3
|
-
*
|
|
4
|
-
* Functions for listing and finding snapshots in the local filesystem.
|
|
5
|
-
*/
|
|
6
|
-
import * as fs from "node:fs/promises";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import * as os from "node:os";
|
|
9
|
-
/**
|
|
10
|
-
* Get the base snapshots directory path
|
|
11
|
-
*/
|
|
12
|
-
export function getSnapshotsDir() {
|
|
13
|
-
return path.join(os.homedir(), ".phoenix-insight", "snapshots");
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Parse a snapshot directory name to extract timestamp
|
|
17
|
-
*
|
|
18
|
-
* Directory names are in format: `<timestamp>-<random>` where timestamp is Date.now()
|
|
19
|
-
* Example: "1704067200000-abc123" -> Date(2024-01-01T00:00:00.000Z)
|
|
20
|
-
*
|
|
21
|
-
* @param dirName - The directory name to parse
|
|
22
|
-
* @returns The parsed timestamp as Date, or null if invalid
|
|
23
|
-
*/
|
|
24
|
-
function parseSnapshotDirName(dirName) {
|
|
25
|
-
// Format: <timestamp>-<random>
|
|
26
|
-
const match = dirName.match(/^(\d+)-[\w]+$/);
|
|
27
|
-
if (!match || !match[1]) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
const timestamp = parseInt(match[1], 10);
|
|
31
|
-
if (isNaN(timestamp) || timestamp <= 0) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
const date = new Date(timestamp);
|
|
35
|
-
// Validate the date is reasonable (between year 2000 and year 3000)
|
|
36
|
-
// Use UTC year to avoid timezone issues
|
|
37
|
-
const year = date.getUTCFullYear();
|
|
38
|
-
if (year < 2000 || year > 3000) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return date;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* List all available snapshots
|
|
45
|
-
*
|
|
46
|
-
* Scans the snapshots directory and returns information about each valid snapshot.
|
|
47
|
-
* Results are sorted by timestamp descending (most recent first).
|
|
48
|
-
*
|
|
49
|
-
* @returns Array of snapshot info objects, sorted by timestamp descending
|
|
50
|
-
*/
|
|
51
|
-
export async function listSnapshots() {
|
|
52
|
-
const snapshotsDir = getSnapshotsDir();
|
|
53
|
-
// Check if snapshots directory exists
|
|
54
|
-
try {
|
|
55
|
-
await fs.access(snapshotsDir);
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// Directory doesn't exist - return empty array
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
// Read directory contents
|
|
62
|
-
let entries;
|
|
63
|
-
try {
|
|
64
|
-
entries = await fs.readdir(snapshotsDir);
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// Cannot read directory - return empty array
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
// Filter and parse valid snapshot directories
|
|
71
|
-
const snapshots = [];
|
|
72
|
-
for (const entry of entries) {
|
|
73
|
-
const timestamp = parseSnapshotDirName(entry);
|
|
74
|
-
if (!timestamp) {
|
|
75
|
-
// Invalid directory name format - skip
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const snapshotPath = path.join(snapshotsDir, entry, "phoenix");
|
|
79
|
-
// Verify the phoenix subdirectory exists
|
|
80
|
-
try {
|
|
81
|
-
const stat = await fs.stat(snapshotPath);
|
|
82
|
-
if (!stat.isDirectory()) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
// Phoenix subdirectory doesn't exist or can't be accessed - skip
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
snapshots.push({
|
|
91
|
-
path: snapshotPath,
|
|
92
|
-
timestamp,
|
|
93
|
-
id: entry,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
// Sort by timestamp descending (most recent first)
|
|
97
|
-
snapshots.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
|
|
98
|
-
return snapshots;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Get the latest (most recent) snapshot
|
|
102
|
-
*
|
|
103
|
-
* @returns The most recent snapshot info, or null if no snapshots exist
|
|
104
|
-
*/
|
|
105
|
-
export async function getLatestSnapshot() {
|
|
106
|
-
const snapshots = await listSnapshots();
|
|
107
|
-
if (snapshots.length === 0) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
// First element is the most recent due to descending sort
|
|
111
|
-
return snapshots[0] ?? null;
|
|
112
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/cli.ts","../src/index.ts","../src/progress.ts","../src/agent/index.ts","../src/commands/index.ts","../src/commands/px-fetch-more-spans.ts","../src/commands/px-fetch-more-trace.ts","../src/commands/report-tool.ts","../src/config/index.ts","../src/config/loader.ts","../src/config/schema.ts","../src/modes/index.ts","../src/modes/local.ts","../src/modes/sandbox.ts","../src/modes/types.ts","../src/observability/index.ts","../src/prompts/index.ts","../src/prompts/system.ts","../src/server/session.ts","../src/server/ui.ts","../src/server/websocket.ts","../src/snapshot/client.ts","../src/snapshot/context.ts","../src/snapshot/datasets.ts","../src/snapshot/experiments.ts","../src/snapshot/index.ts","../src/snapshot/projects.ts","../src/snapshot/prompts.ts","../src/snapshot/spans.ts","../src/snapshot/utils.ts"],"version":"5.9.3"}
|