@rayburst/cli 0.1.17 → 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.
Files changed (39) hide show
  1. package/README.md +165 -257
  2. package/dist/analysis/analyze-project.d.ts +9 -0
  3. package/dist/analysis/analyze-project.js +440 -0
  4. package/dist/git-utils.d.ts +33 -0
  5. package/dist/git-utils.js +96 -0
  6. package/dist/incremental-analyzer.d.ts +128 -0
  7. package/dist/incremental-analyzer.js +259 -0
  8. package/dist/index.d.ts +6 -0
  9. package/dist/index.js +6 -0
  10. package/dist/local-storage.d.ts +39 -0
  11. package/dist/local-storage.js +117 -0
  12. package/dist/registry.d.ts +89 -0
  13. package/dist/registry.js +287 -0
  14. package/dist/vite-plugin.d.ts +7 -0
  15. package/dist/vite-plugin.js +109 -0
  16. package/package.json +33 -30
  17. package/bin/rayburst.js +0 -232
  18. package/dist/assets/_commonjsHelpers-B85MJLTf.js +0 -5
  19. package/dist/assets/hostInit-BWYxHpMp.js +0 -9
  20. package/dist/assets/index-9R1akZrm.js +0 -578
  21. package/dist/assets/index-BW-RulSg.js +0 -258
  22. package/dist/assets/index-VnAMn3JB.js +0 -16587
  23. package/dist/assets/preload-helper-Dea3Szod.js +0 -54
  24. package/dist/assets/rayburstCli__loadRemote__rayburstApp_mf_1_App__loadRemote__-CHUYMhiU.js +0 -35
  25. package/dist/assets/rayburstCli__loadShare__react__loadShare__-CE7VtFm0.js +0 -19
  26. package/dist/assets/rayburstCli__mf_v__runtimeInit__mf_v__-C_SVfzik.js +0 -4173
  27. package/dist/assets/remoteEntry-B8biLITo.js +0 -122
  28. package/dist/assets/virtualExposes-DwA08f_D.js +0 -5
  29. package/dist/index.html +0 -56
  30. package/index.html +0 -54
  31. package/scripts/analyze-project.js +0 -475
  32. package/server.js +0 -188
  33. package/src/file-watcher.js +0 -174
  34. package/src/git-utils.js +0 -105
  35. package/src/incremental-analyzer.js +0 -295
  36. package/src/main.tsx +0 -126
  37. package/src/registry.js +0 -262
  38. package/vite-plugin-api.js +0 -123
  39. package/vite.config.ts +0 -73
package/README.md CHANGED
@@ -1,344 +1,253 @@
1
- # Rayburst CLI
1
+ # Rayburst
2
2
 
3
- A powerful CLI tool for analyzing and visualizing TypeScript/JavaScript project dependencies and architecture.
3
+ Automatic code analysis for TypeScript/JavaScript projects. Rayburst runs in the background during development and generates dependency graphs that you can visualize in the Rayburst web application.
4
4
 
5
- ## Installation
6
-
7
- Install globally via npm:
5
+ ## Features
8
6
 
9
- ```bash
10
- npm install -g @rayburst/cli
11
- ```
7
+ - **Automatic Analysis**: Runs automatically when you start your dev server - no manual commands needed
8
+ - **Real-time Updates**: Watches for file changes and updates analysis instantly
9
+ - **TypeScript/JavaScript Support**: Full analysis of TS, TSX, JS, and JSX files
10
+ - **React Components**: Detects React components and their dependencies
11
+ - **Function Tracking**: Maps function calls and relationships
12
+ - **Git Integration**: Tracks branches, commits, and changes
13
+ - **Zero Configuration**: Works out of the box with sensible defaults
12
14
 
13
- ## Quick Start
15
+ ## Installation
14
16
 
15
17
  ```bash
16
- # Register your project
17
- rayburst register /path/to/your/project
18
-
19
- # Analyze the project
20
- rayburst analyze
21
-
22
- # Start the dashboard
23
- rayburst start
18
+ npm install --save-dev @rayburst/cli
24
19
  ```
25
20
 
26
- Open your browser to `http://localhost:3105` to view the interactive dashboard.
21
+ ## Usage
27
22
 
28
- ## Commands
23
+ ### Vite Projects
29
24
 
30
- ### `rayburst register [path]`
25
+ Add the Rayburst plugin to your `vite.config.ts`:
31
26
 
32
- Register a project for analysis.
27
+ ```typescript
28
+ import { defineConfig } from 'vite'
29
+ import react from '@vitejs/plugin-react'
30
+ import { rayburstPlugin } from '@rayburst/cli/vite'
33
31
 
34
- ```bash
35
- # Register current directory
36
- rayburst register
37
-
38
- # Register specific path
39
- rayburst register /path/to/project
40
-
41
- # Register with custom name
42
- rayburst register --name "My Project"
32
+ export default defineConfig({
33
+ plugins: [
34
+ rayburstPlugin(), // Add this line
35
+ react(),
36
+ ],
37
+ })
43
38
  ```
44
39
 
45
- **Options:**
46
- - `[path]` - Path to project directory (default: current directory)
47
- - `-n, --name <name>` - Custom project name
48
-
49
- ### `rayburst list`
50
-
51
- List all registered projects.
40
+ That's it! Now when you run `npm run dev`, Rayburst will automatically:
41
+ 1. Run initial code analysis
42
+ 2. Generate `.rayburst/analysis.json`
43
+ 3. Watch for file changes
44
+ 4. Update analysis in real-time
52
45
 
53
- ```bash
54
- rayburst list
55
- ```
46
+ ### Configuration Options
56
47
 
57
- Shows:
58
- - Project name
59
- - Path
60
- - Last analyzed timestamp
61
- - Number of branches
48
+ ```typescript
49
+ rayburstPlugin({
50
+ // Disable the plugin (e.g., for testing)
51
+ enabled: true,
62
52
 
63
- ### `rayburst analyze [path]`
53
+ // Debounce delay for file changes (ms)
54
+ debounceMs: 1500,
64
55
 
65
- Analyze a registered project and generate dependency graphs.
66
-
67
- ```bash
68
- # Analyze current directory
69
- rayburst analyze
70
-
71
- # Analyze specific project by path
72
- rayburst analyze /path/to/project
73
-
74
- # Analyze specific project by ID
75
- rayburst analyze abc-123
56
+ // Custom output path
57
+ outputPath: '.rayburst/analysis.json',
58
+ })
76
59
  ```
77
60
 
78
- **Options:**
79
- - `[path]` - Project path or ID (default: current directory)
80
-
81
- **What it analyzes:**
82
- - Function and class relationships
83
- - Import/export dependencies
84
- - Git branches
85
- - File structure
86
- - Code architecture
87
-
88
- ### `rayburst start`
89
-
90
- Start the interactive dashboard server.
91
-
92
- ```bash
93
- # Start on default port (3105)
94
- rayburst start
61
+ ## Output
95
62
 
96
- # Start on custom port
97
- rayburst start --port 4000
63
+ The plugin generates a `.rayburst/` directory in your project root:
98
64
 
99
- # Start in production mode
100
- rayburst start --env production
101
65
  ```
102
-
103
- **Options:**
104
- - `-p, --port <port>` - Server port (default: 3105)
105
- - `-e, --env <environment>` - Environment: development|staging|production (default: production)
106
-
107
- ### `rayburst unregister <id>`
108
-
109
- Unregister a project.
110
-
111
- ```bash
112
- # Unregister by project ID
113
- rayburst unregister abc-123
66
+ my-project/
67
+ ├── .rayburst/
68
+ │ └── analysis.json # Analysis data (nodes, edges, dependencies)
69
+ ├── .gitignore # Auto-updated to ignore .rayburst/
70
+ ├── src/
71
+ ├── vite.config.ts
72
+ └── package.json
114
73
  ```
115
74
 
116
- ## Features
75
+ The `.rayburst/` directory is automatically added to your `.gitignore`.
117
76
 
118
- ### 📊 Interactive Dependency Graphs
119
- - Visual representation of code dependencies
120
- - Function and class relationships
121
- - Import/export connections
122
- - Interactive node exploration
77
+ ## Analysis Data
123
78
 
124
- ### 🔍 Git Integration
125
- - Multi-branch support
126
- - Filter by uncommitted changes
127
- - Branch comparison
128
- - Track changes over time
79
+ The generated `analysis.json` contains:
129
80
 
130
- ### 🎨 Rich Visualization
131
- - React Flow-based graphs
132
- - Collapsible node groups
133
- - Search and filter
134
- - Auto-layout options
81
+ - **Nodes**: Components, functions, state declarations
82
+ - **Edges**: Dependencies between nodes
83
+ - **Branches**: Git branch information
84
+ - **Files**: Modification timestamps
135
85
 
136
- ### 🔄 Real-time Updates
137
- - File watching (coming soon)
138
- - Incremental analysis (coming soon)
139
- - Live graph updates (coming soon)
86
+ This data can be visualized using the [Rayburst web application](https://rayburst.app).
140
87
 
141
- ## Usage Workflow
88
+ ## Example Output
142
89
 
143
- ### 1. Register Your Projects
90
+ ```typescript
91
+ // src/App.tsx
92
+ import { Button } from './components/Button'
144
93
 
145
- ```bash
146
- cd /path/to/project1
147
- rayburst register
148
-
149
- cd /path/to/project2
150
- rayburst register
94
+ export function App() {
95
+ return <Button onClick={() => alert('Hello')} />
96
+ }
151
97
  ```
152
98
 
153
- ### 2. Analyze Projects
154
-
155
- ```bash
156
- rayburst analyze project1
157
- rayburst analyze project2
158
- ```
99
+ Rayburst detects:
100
+ - `App` component (node)
101
+ - `Button` component usage (edge: App → Button)
102
+ - JSX relationships
103
+ - File structure
159
104
 
160
- ### 3. Explore in Dashboard
105
+ ## Console Output
161
106
 
162
107
  ```bash
163
- rayburst start
164
- ```
165
-
166
- Navigate to `http://localhost:3105` and:
167
- - Browse registered projects
168
- - Select branches to view
169
- - Explore dependency graphs
170
- - Compare branches
171
- - Filter by changed files
108
+ $ npm run dev
172
109
 
173
- ## Dashboard Features
110
+ [Rayburst] Starting code analysis...
111
+ [Rayburst] Initial analysis complete: 42 nodes, 68 edges
174
112
 
175
- ### Project Management
176
- - View all registered projects
177
- - See analysis status
178
- - Browse branches
179
- - Open multiple tabs
180
-
181
- ### Workspace
182
- - Interactive dependency graphs
183
- - Node details sidebar
184
- - Command palette (⌘K)
185
- - Multi-tab support
186
-
187
- ### Filtering
188
- - **All Files**: Show complete dependency graph
189
- - **Changes Only**: Filter to show only uncommitted changes
190
- - Custom visibility controls
191
- - Search functionality
113
+ # When you edit a file:
114
+ [Rayburst] File changed: src/App.tsx
115
+ [Rayburst] Analysis updated:
116
+ Added: 1 nodes, 2 edges
117
+ Modified: 1 nodes
118
+ ```
192
119
 
193
- ## Architecture
120
+ ## How It Works
194
121
 
195
- ### Module Federation
122
+ Rayburst uses a Vite plugin that:
196
123
 
197
- The CLI uses Module Federation to load the dashboard UI dynamically:
124
+ 1. **Hooks into Vite's lifecycle**: Runs when dev server starts
125
+ 2. **Uses ts-morph**: Analyzes TypeScript/JavaScript AST
126
+ 3. **Watches files**: Leverages Vite's built-in file watcher
127
+ 4. **Incremental updates**: Only re-analyzes changed files
128
+ 5. **Generates graphs**: Produces node/edge data structures
198
129
 
199
- - **CLI (Host)**: Port 3105
200
- - **Dashboard (Remote)**: Loaded from rayburst.app
201
- - **Shared**: React, React-DOM
130
+ ## Requirements
202
131
 
203
- ### Data Storage
132
+ - **Vite**: 4.x, 5.x, 6.x, or 7.x
133
+ - **TypeScript**: Project must have `tsconfig.json`
134
+ - **package.json**: Required for project metadata
204
135
 
205
- - **Registry**: `~/.rayburst/projects.json`
206
- - **Analysis Data**: `~/.rayburst/analysis/<project-id>.json`
136
+ ## Browser Compatibility
207
137
 
208
- ## Environment Configuration
138
+ The analysis data can be viewed in the Rayburst web app, which requires:
139
+ - Chrome 86+ or Edge 86+ (for File System Access API)
209
140
 
210
- | Environment | Remote URL | Use Case |
211
- |------------|-----------|----------|
212
- | development | http://localhost:3000 | Local development |
213
- | staging | https://dev.rayburst.app | Staging/testing |
214
- | production | https://www.rayburst.app | Production (default) |
141
+ ## Advanced Usage
215
142
 
216
- ## Examples
143
+ ### Programmatic API
217
144
 
218
- ### Analyze Multiple Projects
145
+ You can also use Rayburst programmatically:
219
146
 
220
- ```bash
221
- # Register projects
222
- rayburst register ~/projects/frontend --name "Frontend"
223
- rayburst register ~/projects/backend --name "Backend"
224
- rayburst register ~/projects/shared --name "Shared Lib"
147
+ ```typescript
148
+ import { analyzeProject, writeLocalAnalysis } from '@rayburst/cli'
225
149
 
226
- # Analyze all
227
- rayburst list | xargs -I {} rayburst analyze {}
150
+ // Analyze a project
151
+ const analysis = await analyzeProject('/path/to/project')
228
152
 
229
- # Start dashboard
230
- rayburst start
153
+ // Write results
154
+ await writeLocalAnalysis('/path/to/project', analysis)
231
155
  ```
232
156
 
233
- ### Daily Workflow
157
+ ### Custom Integration
234
158
 
235
- ```bash
236
- # Morning: Start dashboard
237
- rayburst start
159
+ ```typescript
160
+ import {
161
+ analyzeProject,
162
+ ensureRayburstDir,
163
+ writeLocalAnalysis
164
+ } from '@rayburst/cli'
238
165
 
239
- # After changes: Re-analyze
240
- rayburst analyze
166
+ async function customAnalysis() {
167
+ const projectPath = process.cwd()
241
168
 
242
- # View only your changes
243
- # (Use "Changes Only" toggle in dashboard)
244
- ```
169
+ // Ensure .rayburst directory exists
170
+ await ensureRayburstDir(projectPath)
245
171
 
246
- ### Custom Port Setup
172
+ // Run analysis
173
+ const result = await analyzeProject(projectPath)
247
174
 
248
- ```bash
249
- # If port 3105 is in use
250
- rayburst start --port 8080
175
+ // Save results
176
+ await writeLocalAnalysis(projectPath, result)
177
+
178
+ console.log(`Analyzed ${result.planData.nodes.length} nodes`)
179
+ }
251
180
  ```
252
181
 
253
182
  ## Troubleshooting
254
183
 
255
- ### Port Already in Use
184
+ ### Plugin Not Running
256
185
 
257
- ```bash
258
- # Find process using port
259
- lsof -i :3105
186
+ Make sure:
187
+ 1. Plugin is added to `vite.config.ts`
188
+ 2. You're running in dev mode (`npm run dev`, not `npm run build`)
189
+ 3. Project has `tsconfig.json`
260
190
 
261
- # Kill process
262
- kill <PID>
263
- ```
191
+ ### No Analysis Generated
264
192
 
265
- ### Analysis Fails
193
+ Check:
194
+ 1. `.rayburst/` directory exists
195
+ 2. Console for error messages
196
+ 3. Project has TypeScript/JavaScript files
266
197
 
267
- - Ensure project has a `package.json`
268
- - Check for TypeScript/JavaScript files
269
- - Verify git repository (for branch support)
270
- - Check file permissions
198
+ ### Analysis Fails
271
199
 
272
- ### Dashboard Not Loading
200
+ Common causes:
201
+ - Invalid `tsconfig.json`
202
+ - TypeScript compilation errors
203
+ - Missing `package.json`
273
204
 
274
- - Verify internet connection (loads remote from rayburst.app)
275
- - Check firewall settings
276
- - Try `--env development` for local testing
205
+ Enable verbose logging:
206
+ ```typescript
207
+ rayburstPlugin({
208
+ enabled: process.env.DEBUG === 'true'
209
+ })
210
+ ```
277
211
 
278
- ### No Projects Listed
212
+ ## CI/CD
279
213
 
280
- ```bash
281
- # Check registry location
282
- rayburst list
214
+ The plugin is automatically disabled in CI environments (when `CI=true`). To force enable:
283
215
 
284
- # Re-register project
285
- rayburst register /path/to/project
216
+ ```typescript
217
+ rayburstPlugin({
218
+ enabled: true // Always enabled
219
+ })
286
220
  ```
287
221
 
288
- ## Development
222
+ ## Migration from Old Versions
289
223
 
290
- ### Local Setup
224
+ If you were using `rayburst watch` command:
291
225
 
226
+ **Before:**
292
227
  ```bash
293
- # Clone repository
294
- git clone https://github.com/your-org/rayburst-cli.git
295
- cd rayburst-cli
296
-
297
- # Install dependencies
298
- npm install
299
-
300
- # Build
301
- npm run build
228
+ # Terminal 1
229
+ npm run dev
302
230
 
303
- # Link for local testing
304
- npm link
305
-
306
- # Test commands
307
- rayburst --help
231
+ # Terminal 2
232
+ rayburst watch
308
233
  ```
309
234
 
310
- ### Project Structure
311
-
312
- ```
313
- rayburst-cli/
314
- ├── bin/
315
- │ └── rayburst.js # CLI entry point
316
- ├── src/
317
- │ ├── registry.js # Project registry
318
- │ ├── git-utils.js # Git operations
319
- │ ├── file-watcher.js # File watching
320
- │ └── main.tsx # Dashboard loader
321
- ├── scripts/
322
- │ └── analyze-project.js # Analysis engine
323
- ├── server.js # Express server
324
- ├── vite.config.ts # Build config
325
- └── package.json
235
+ **After:**
236
+ ```typescript
237
+ // vite.config.ts
238
+ export default defineConfig({
239
+ plugins: [rayburstPlugin(), react()],
240
+ })
326
241
  ```
327
242
 
328
- ## Tech Stack
329
-
330
- - **Vite** - Build tool and dev server
331
- - **React 19** - UI library
332
- - **Module Federation** - Dynamic remote loading
333
- - **Express** - Production server
334
- - **Commander** - CLI framework
335
- - **Chalk** - Terminal styling
336
- - **ts-morph** - TypeScript analysis
337
- - **chokidar** - File watching
243
+ ```bash
244
+ # Just one terminal
245
+ npm run dev # Rayburst runs automatically!
246
+ ```
338
247
 
339
248
  ## Contributing
340
249
 
341
- Contributions are welcome! Please read our contributing guidelines and submit pull requests.
250
+ Contributions welcome! Please read our contributing guidelines.
342
251
 
343
252
  ## License
344
253
 
@@ -349,4 +258,3 @@ MIT
349
258
  - [Documentation](https://rayburst.app/docs)
350
259
  - [GitHub Repository](https://github.com/your-org/rayburst)
351
260
  - [Issue Tracker](https://github.com/your-org/rayburst/issues)
352
- - [Changelog](https://github.com/your-org/rayburst/releases)
@@ -0,0 +1,9 @@
1
+ import { type AnalysisResult } from '@rayburst/types';
2
+ /**
3
+ * Analyze a TypeScript/React project and generate nodes/edges data
4
+ * @param {string} projectPath - Absolute path to project root
5
+ * @param {string} projectId - Project ID
6
+ * @param {function} onLog - Callback for logging
7
+ * @returns {Promise<AnalysisResult>} Analysis data with nodes and edges
8
+ */
9
+ export declare function analyzeProject(projectPath: string, projectId?: string, onLog?: (message: string) => void): Promise<AnalysisResult>;