codesynapse 1.0.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 ADDED
@@ -0,0 +1,270 @@
1
+ # CodeSynapse
2
+
3
+ > Real-time codebase visualization with a neural network-style 3D graph. Watch your code evolve as you or AI agents work on it.
4
+
5
+ <div align="center">
6
+
7
+ [![npm version](https://badge.fury.io/js/codesynapse.svg)](https://www.npmjs.com/package/codesynapse)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ </div>
11
+
12
+ ## Features
13
+
14
+ - 🌐 **3D Neural Network Visualization** - Files as neurons, dependencies as synapses
15
+ - ⚡ **Real-time Updates** - Watch changes happen live as you code
16
+ - 🔗 **Dependency Mapping** - Automatically parse and visualize import/require relationships
17
+ - 📊 **Git Diff Integration** - Click any file to see code changes
18
+ - 🎨 **Beautiful Effects** - Glow effects, pulse animations, and particle flows
19
+ - 🚀 **High Performance** - Smooth 60fps visualization even with large codebases
20
+ - 🎯 **AI Agent Friendly** - Perfect for watching AI agents work on your code
21
+
22
+ ## 🎬 Demo
23
+
24
+ Watch your codebase come alive:
25
+
26
+ 1. Point CodeSynapse at any directory
27
+ 2. See all files appear as glowing nodes in 3D space
28
+ 3. Dependencies light up as connections between files
29
+ 4. When you edit a file, it pulses with cyan light
30
+ 5. Click any node to see the git diff in a side panel
31
+ 6. Watch the neural network grow as you add more code
32
+
33
+ ## Installation
34
+
35
+ ### Global Installation (Recommended)
36
+
37
+ ```bash
38
+ npm install -g codesynapse
39
+ ```
40
+
41
+ ### Local Installation
42
+
43
+ ```bash
44
+ npm install --save-dev codesynapse
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ### Quick Start
50
+
51
+ Navigate to your project directory and run:
52
+
53
+ ```bash
54
+ codesynapse
55
+ ```
56
+
57
+ This will:
58
+ 1. Start the visualization server on `http://localhost:3004`
59
+ 2. Automatically open your browser
60
+ 3. Begin watching your project directory
61
+ 4. If port 3004 is in use, it will automatically try the next available port
62
+
63
+ ### Command Line Options
64
+
65
+ ```bash
66
+ codesynapse [options]
67
+
68
+ Options:
69
+ --port <port> Specify port (default: 3004)
70
+ --no-open Don't automatically open browser
71
+ ```
72
+
73
+ Examples:
74
+
75
+ ```bash
76
+ # Run on a different port
77
+ codesynapse --port 8080
78
+
79
+ # Don't auto-open browser
80
+ codesynapse --no-open
81
+ ```
82
+
83
+ ### Using the Visualization
84
+
85
+ 1. **Start Watching** - Click "Start Watching" to begin monitoring your project
86
+ 2. **Explore the Graph** - Drag to rotate, scroll to zoom, click nodes to view code
87
+ 3. **Watch Changes** - Edit files and see them light up in real-time:
88
+ - Green (0-5s) - Just changed, pulsing
89
+ - Amber (5-30s) - Recently active
90
+ - Yellow (30-60s) - Cooling down
91
+ - Blue/Purple/etc. - Stable (color by file type)
92
+ 4. **View Code** - Click any node to see syntax-highlighted code and git diffs
93
+ 5. **Toggle Theme** - Click the sun/moon icon for light/dark mode
94
+
95
+ ### Controls
96
+
97
+ - **Mouse drag**: Rotate the camera
98
+ - **Scroll**: Zoom in/out
99
+ - **Click node**: View file details and git diff
100
+ - **Hover node**: See file info tooltip
101
+
102
+ ## Architecture
103
+
104
+ ```
105
+ code-synapse/
106
+ ├── server/ # Node.js + Express + Socket.io backend
107
+ │ ├── FileWatcher.ts # Real-time file monitoring (Chokidar)
108
+ │ ├── DependencyParser.ts # AST parsing (@babel/parser)
109
+ │ ├── GitIntegration.ts # Git diff tracking (simple-git)
110
+ │ ├── GraphBuilder.ts # Graph data structure
111
+ │ └── index.ts # WebSocket server
112
+
113
+ ├── client/ # React + Three.js frontend
114
+ │ ├── components/
115
+ │ │ ├── Graph3D.tsx # 3D visualization (react-force-graph-3d)
116
+ │ │ ├── DiffPanel.tsx # Git diff viewer
117
+ │ │ ├── Controls.tsx # UI controls
118
+ │ │ └── Stats.tsx # Live statistics
119
+ │ └── hooks/
120
+ │ └── useWebSocket.ts # Socket.io client
121
+ ```
122
+
123
+ ### Tech Stack
124
+
125
+ **Backend:**
126
+ - Express - HTTP server
127
+ - Socket.io - Real-time WebSocket communication
128
+ - Chokidar - File system watching
129
+ - @babel/parser - JavaScript/TypeScript AST parsing
130
+ - simple-git - Git integration
131
+
132
+ **Frontend:**
133
+ - React 18 - UI framework
134
+ - Three.js - 3D graphics
135
+ - react-force-graph-3d - Force-directed graph layout
136
+ - Socket.io-client - Real-time updates
137
+
138
+ **Language:**
139
+ - TypeScript throughout for type safety
140
+
141
+ ## Visualization Details
142
+
143
+ ### Node Colors
144
+
145
+ Files are colored by type:
146
+ - JavaScript (.js, .jsx, .mjs, .cjs) - Yellow
147
+ - TypeScript (.ts, .tsx) - Blue
148
+ - JSON (.json) - Green
149
+ - Styles (.css, .scss, .sass, .less) - Purple
150
+ - Markup (.html) - Red
151
+ - Markdown (.md) - Green
152
+ - Other files - Gray
153
+
154
+ ### Node Size
155
+
156
+ Nodes scale based on:
157
+ - Number of connections (imports/exports)
158
+ - File size
159
+ - Change frequency
160
+
161
+ ### Visual Effects
162
+
163
+ - **Pulse animation**: Recently changed files glow cyan and pulse
164
+ - **Particle flow**: Particles travel along dependency connections
165
+ - **Glow aura**: All nodes have a subtle glow effect
166
+ - **Connection highlighting**: Hover to see connected files
167
+
168
+ ## Use Cases
169
+
170
+ ### 1. Understanding Codebases
171
+ Quickly visualize the structure and dependencies of unfamiliar projects.
172
+
173
+ ### 2. Watching AI Agents
174
+ See exactly what files an AI agent is modifying in real-time.
175
+
176
+ ### 3. Refactoring
177
+ Understand the impact of changes by seeing which files are connected.
178
+
179
+ ### 4. Code Reviews
180
+ Visualize the scope of changes in a pull request.
181
+
182
+ ### 5. Teaching
183
+ Help others understand project architecture visually.
184
+
185
+ ## Configuration
186
+
187
+ Create a `.codesynapse.json` file in your project root:
188
+
189
+ ```json
190
+ {
191
+ "ignorePatterns": [
192
+ "**/node_modules/**",
193
+ "**/.git/**",
194
+ "**/dist/**",
195
+ "**/build/**"
196
+ ],
197
+ "colors": {
198
+ "javascript": "#f1e05a",
199
+ "typescript": "#2b7489",
200
+ "json": "#00d084"
201
+ }
202
+ }
203
+ ```
204
+
205
+ ## Development
206
+
207
+ ### Project Structure
208
+
209
+ ```bash
210
+ npm run dev # Start both server and client
211
+ npm run build # Build for production
212
+ npm start # Run production build
213
+ ```
214
+
215
+ ### Server Development
216
+
217
+ ```bash
218
+ cd server
219
+ npm run dev # Start with hot reload
220
+ npm run build # Compile TypeScript
221
+ ```
222
+
223
+ ### Client Development
224
+
225
+ ```bash
226
+ cd client
227
+ npm run dev # Start React dev server
228
+ npm run build # Build for production
229
+ ```
230
+
231
+ ## Troubleshooting
232
+
233
+ ### "Not a git repository" message
234
+ This is normal if the directory you're watching isn't a git repo. Git features will be disabled but file watching still works.
235
+
236
+ ### Large codebases slow
237
+ Try adjusting physics settings or filtering file types in the configuration.
238
+
239
+ ### Connection issues
240
+ Make sure both server (3001) and client (3000) ports are available.
241
+
242
+ ## Contributing
243
+
244
+ Contributions welcome! Please feel free to submit a Pull Request.
245
+
246
+ ## License
247
+
248
+ MIT License - feel free to use this in your own projects!
249
+
250
+ ## Acknowledgments
251
+
252
+ Built with:
253
+ - [Chokidar](https://github.com/paulmillr/chokidar) - File watching
254
+ - [react-force-graph](https://github.com/vasturiano/react-force-graph) - 3D visualization
255
+ - [Babel](https://babeljs.io/) - AST parsing
256
+ - [Socket.io](https://socket.io/) - Real-time communication
257
+
258
+ ## Future Ideas
259
+
260
+ - Support for more languages (Python, Go, Rust, Java)
261
+ - Time-travel mode to replay changes
262
+ - Heatmap visualization for hot spots
263
+ - Multi-project view
264
+ - VR mode for immersive exploration
265
+ - VS Code extension
266
+ - Collaborative mode
267
+
268
+ ---
269
+
270
+ Made for developers who love beautiful visualizations
package/bin/cli.js ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const args = process.argv.slice(2);
8
+ const cwd = process.cwd();
9
+
10
+ // Get the package root directory
11
+ const packageRoot = path.join(__dirname, '..');
12
+ const serverPath = path.join(packageRoot, 'server', 'dist', 'index.js');
13
+
14
+ // Check if server dist exists
15
+ if (!fs.existsSync(serverPath)) {
16
+ console.error('Error: CodeSynapse server not built. Please run: npm install -g codesynapse');
17
+ process.exit(1);
18
+ }
19
+
20
+ // Parse command line arguments
21
+ const port = args.includes('--port') ? args[args.indexOf('--port') + 1] : '3004';
22
+ const openBrowser = !args.includes('--no-open');
23
+
24
+ console.log(`
25
+ ╔══════════════════════════════════════════╗
26
+ ║ ║
27
+ ║ CodeSynapse v1.0.0 ║
28
+ ║ Real-time Codebase Visualization ║
29
+ ║ ║
30
+ ╚══════════════════════════════════════════╝
31
+
32
+ Starting server...
33
+ Project: ${cwd}
34
+ Port: ${port}
35
+ URL: http://localhost:${port}
36
+ `);
37
+
38
+ // Set environment variables
39
+ const env = {
40
+ ...process.env,
41
+ PORT: port,
42
+ NODE_ENV: 'production'
43
+ };
44
+
45
+ // Start the server
46
+ const server = spawn('node', [serverPath], {
47
+ cwd: packageRoot,
48
+ env,
49
+ stdio: 'inherit'
50
+ });
51
+
52
+ // Open browser after a short delay
53
+ if (openBrowser) {
54
+ setTimeout(() => {
55
+ const open = require('open');
56
+ open(`http://localhost:${port}`).catch(() => {
57
+ console.log('\nOpen your browser and navigate to:', `http://localhost:${port}`);
58
+ });
59
+ }, 2000);
60
+ }
61
+
62
+ // Handle cleanup
63
+ process.on('SIGINT', () => {
64
+ console.log('\n\nShutting down CodeSynapse...');
65
+ server.kill();
66
+ process.exit(0);
67
+ });
68
+
69
+ process.on('SIGTERM', () => {
70
+ server.kill();
71
+ process.exit(0);
72
+ });
73
+
74
+ server.on('exit', (code) => {
75
+ if (code !== 0 && code !== null) {
76
+ console.error(`Server exited with code ${code}`);
77
+ process.exit(code);
78
+ }
79
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "files": {
3
+ "main.css": "/static/css/main.23fcdbf2.css",
4
+ "main.js": "/static/js/main.5c90edac.js",
5
+ "static/media/ngraph.events.cjs": "/static/media/ngraph.events.d3dfed5ea2f996b98f21.cjs",
6
+ "index.html": "/index.html",
7
+ "main.23fcdbf2.css.map": "/static/css/main.23fcdbf2.css.map",
8
+ "main.5c90edac.js.map": "/static/js/main.5c90edac.js.map"
9
+ },
10
+ "entrypoints": [
11
+ "static/css/main.23fcdbf2.css",
12
+ "static/js/main.5c90edac.js"
13
+ ]
14
+ }
@@ -0,0 +1 @@
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#0a0e1a"/><meta name="description" content="CodeSynapse - Real-time codebase visualization tool"/><title>CodeSynapse - Neural Network Code Visualization</title><script defer="defer" src="/static/js/main.5c90edac.js"></script><link href="/static/css/main.23fcdbf2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -0,0 +1,2 @@
1
+ *{box-sizing:border-box;padding:0}*,body{margin:0}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:#0a0e1a;color:#e0e0e0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;overflow:hidden}code{font-family:Monaco,Consolas,Courier New,monospace}::-webkit-scrollbar{height:8px;width:8px}::-webkit-scrollbar-track{background:rgba(20,24,36,.5)}::-webkit-scrollbar-thumb{background:rgba(100,150,255,.5);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:rgba(100,150,255,.7)}@keyframes slideIn{0%{transform:translateX(100%)}to{transform:translateX(0)}}button:hover:not(:disabled){box-shadow:0 4px 12px rgba(0,255,255,.3);transform:translateY(-2px)}button:active:not(:disabled){transform:translateY(0)}input:focus{border-color:#0ff!important;box-shadow:0 0 0 2px rgba(0,255,255,.2)}::selection{background-color:rgba(0,255,255,.3);color:#fff}
2
+ /*# sourceMappingURL=main.23fcdbf2.css.map*/
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static/css/main.23fcdbf2.css","mappings":"AAAA,EAGE,qBAAsB,CADtB,SAEF,CAEA,OALE,QAeF,CAVA,KAKE,kCAAmC,CACnC,iCAAkC,CAClC,wBAAyB,CACzB,aAAc,CANd,mIAEY,CAKZ,eACF,CAEA,KACE,iDACF,CAGA,oBAEE,UAAW,CADX,SAEF,CAEA,0BACE,4BACF,CAEA,0BACE,+BAAoC,CACpC,iBACF,CAEA,gCACE,+BACF,CAGA,mBACE,GACE,0BACF,CACA,GACE,uBACF,CACF,CAGA,4BAEE,wCAA6C,CAD7C,0BAEF,CAEA,6BACE,uBACF,CAGA,YACE,2BAAgC,CAChC,uCACF,CAGA,YACE,mCAAwC,CACxC,UACF","sources":["index.css"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n background-color: #0a0e1a;\n color: #e0e0e0;\n overflow: hidden;\n}\n\ncode {\n font-family: Monaco, Consolas, 'Courier New', monospace;\n}\n\n/* Custom scrollbar */\n::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n::-webkit-scrollbar-track {\n background: rgba(20, 24, 36, 0.5);\n}\n\n::-webkit-scrollbar-thumb {\n background: rgba(100, 150, 255, 0.5);\n border-radius: 4px;\n}\n\n::-webkit-scrollbar-thumb:hover {\n background: rgba(100, 150, 255, 0.7);\n}\n\n/* Animations */\n@keyframes slideIn {\n from {\n transform: translateX(100%);\n }\n to {\n transform: translateX(0);\n }\n}\n\n/* Button hover effects */\nbutton:hover:not(:disabled) {\n transform: translateY(-2px);\n box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);\n}\n\nbutton:active:not(:disabled) {\n transform: translateY(0);\n}\n\n/* Input focus effects */\ninput:focus {\n border-color: #00ffff !important;\n box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);\n}\n\n/* Selection */\n::selection {\n background-color: rgba(0, 255, 255, 0.3);\n color: #ffffff;\n}\n"],"names":[],"sourceRoot":""}