codesight 1.3.0 → 1.3.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/README.md +312 -59
- package/dist/detectors/routes.js +16 -11
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
### Your AI assistant wastes thousands of tokens every conversation just figuring out your project. codesight fixes that in one command.
|
|
4
4
|
|
|
5
|
-
**Zero dependencies. AST precision. 25+ framework detectors. 8 ORM parsers. 8 MCP tools.
|
|
5
|
+
**Zero dependencies. AST precision. 25+ framework detectors. 8 ORM parsers. 8 MCP tools. One `npx` call.**
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/codesight)
|
|
8
8
|
[](https://www.npmjs.com/package/codesight)
|
|
9
9
|
[](https://www.npmjs.com/package/codesight)
|
|
10
10
|
[](https://github.com/Houseofmvps/codesight/stargazers)
|
|
11
11
|
[](LICENSE)
|
|
12
|
-
[](https://github.com/sponsors/Houseofmvps)
|
|
13
12
|
|
|
14
13
|
---
|
|
15
14
|
|
|
@@ -50,20 +49,115 @@ npx codesight --profile claude-code # Generate optimized config for a specific A
|
|
|
50
49
|
npx codesight --benchmark # Show detailed token savings breakdown
|
|
51
50
|
```
|
|
52
51
|
|
|
53
|
-
##
|
|
52
|
+
## Benchmarks (Real Projects)
|
|
53
|
+
|
|
54
|
+
Every number below comes from running `codesight v1.3.1` on real production codebases. No estimates, no hypotheticals.
|
|
55
|
+
|
|
56
|
+
| Project | Stack | Files | Routes | Models | Components | Output Tokens | Exploration Tokens | Savings | Scan Time |
|
|
57
|
+
|---|---|---|---|---|---|---|---|---|---|
|
|
58
|
+
| **SaveMRR** | Hono + Drizzle, 4 workspaces | 92 | 60 | 18 | 16 | 5,129 | 66,040 | **12.9x** | 290ms |
|
|
59
|
+
| **BuildRadar** | raw HTTP + Drizzle | 53 | 38 | 12 | 0 | 3,945 | 46,020 | **11.7x** | 185ms |
|
|
60
|
+
| **RankRev** | Hono + Drizzle, 3 workspaces | 40 | 13 | 8 | 10 | 2,865 | 26,130 | **9.1x** | 260ms |
|
|
61
|
+
|
|
62
|
+
**Average: 11.2x token reduction.** Your AI reads ~3K-5K tokens instead of burning ~26K-66K exploring files.
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
flowchart LR
|
|
66
|
+
subgraph Without["Without codesight"]
|
|
67
|
+
direction TB
|
|
68
|
+
W1["Read files"] --> W2["Grep for patterns"]
|
|
69
|
+
W2 --> W3["Open configs"]
|
|
70
|
+
W3 --> W4["Explore dependencies"]
|
|
71
|
+
W4 --> W5["46,000-66,000 tokens"]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
subgraph With["With codesight"]
|
|
75
|
+
direction TB
|
|
76
|
+
C1["Read CODESIGHT.md"] --> C2["3,000-5,000 tokens"]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
style W5 fill:#ef4444,stroke:#dc2626,color:#fff
|
|
80
|
+
style C2 fill:#10b981,stroke:#059669,color:#000
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### AST Accuracy
|
|
84
|
+
|
|
85
|
+
When TypeScript is available, codesight uses the TypeScript compiler API for structural parsing.
|
|
86
|
+
|
|
87
|
+
| Project | AST Routes | AST Models | AST Components | False Positives |
|
|
88
|
+
|---|---|---|---|---|
|
|
89
|
+
| **SaveMRR** | 60/60 (100%) | 18/18 (100%) | 16/16 (100%) | 0 |
|
|
90
|
+
| **BuildRadar** | 0/38 (regex fallback) | 12/12 (100%) | n/a | 0 |
|
|
91
|
+
| **RankRev** | 13/13 (100%) | 8/8 (100%) | 10/10 (100%) | 0 |
|
|
92
|
+
|
|
93
|
+
BuildRadar uses raw `http.createServer` which has no framework structure for AST to parse. codesight correctly falls back to regex for routes while still using AST for Drizzle schema. Zero false positives across all three projects.
|
|
94
|
+
|
|
95
|
+
### Blast Radius Accuracy
|
|
96
|
+
|
|
97
|
+
Tested on BuildRadar: changing `src/db/index.ts` (the database module) correctly identified:
|
|
54
98
|
|
|
55
|
-
|
|
99
|
+
- **10 affected files** (dashboard, webhooks, auth, scanner, cron, daily digest, server, CLI, index)
|
|
100
|
+
- **33 affected routes** (every endpoint that touches the database)
|
|
101
|
+
- **12 affected models** (all schema models)
|
|
102
|
+
- **BFS depth:** 3 hops through the import graph
|
|
56
103
|
|
|
57
|
-
|
|
104
|
+
### What Gets Detected
|
|
58
105
|
|
|
59
|
-
|
|
106
|
+
Measured across the three benchmark projects:
|
|
60
107
|
|
|
108
|
+
| Detector | SaveMRR (92 files) | BuildRadar (53 files) | RankRev (40 files) |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| **Routes** | 60 | 38 | 13 |
|
|
111
|
+
| **Schema models** | 18 | 12 | 8 |
|
|
112
|
+
| **Components** | 16 | 0 | 10 |
|
|
113
|
+
| **Library exports** | 36 | 32 | 11 |
|
|
114
|
+
| **Env vars** | 22 | 26 | 12 |
|
|
115
|
+
| **Middleware** | 5 | 3 | 2 |
|
|
116
|
+
| **Import links** | 295 | 101 | 76 |
|
|
117
|
+
| **Hot files** | 20 | 20 | 20 |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## How It Works
|
|
122
|
+
|
|
123
|
+
```mermaid
|
|
124
|
+
flowchart LR
|
|
125
|
+
A["Your Codebase"] --> B["codesight"]
|
|
126
|
+
B --> C["AST Parser"]
|
|
127
|
+
B --> D["Regex Fallback"]
|
|
128
|
+
C --> E["Structured Context Map"]
|
|
129
|
+
D --> E
|
|
130
|
+
E --> F["CLAUDE.md"]
|
|
131
|
+
E --> G[".cursorrules"]
|
|
132
|
+
E --> H["codex.md"]
|
|
133
|
+
E --> I["MCP Server"]
|
|
134
|
+
|
|
135
|
+
style B fill:#f59e0b,stroke:#d97706,color:#000
|
|
136
|
+
style C fill:#10b981,stroke:#059669,color:#000
|
|
137
|
+
style E fill:#3b82f6,stroke:#2563eb,color:#fff
|
|
61
138
|
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
139
|
+
|
|
140
|
+
```mermaid
|
|
141
|
+
flowchart TD
|
|
142
|
+
subgraph Detectors["8 Parallel Detectors"]
|
|
143
|
+
R["Routes<br/>25+ frameworks"]
|
|
144
|
+
S["Schema<br/>8 ORMs"]
|
|
145
|
+
CP["Components<br/>React/Vue/Svelte"]
|
|
146
|
+
G["Dep Graph<br/>Import analysis"]
|
|
147
|
+
M["Middleware<br/>Auth/CORS/etc"]
|
|
148
|
+
CF["Config<br/>Env vars"]
|
|
149
|
+
L["Libraries<br/>Exports + sigs"]
|
|
150
|
+
CT["Contracts<br/>Params + types"]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
A["File Scanner"] --> Detectors
|
|
154
|
+
Detectors --> O["~3K-5K tokens output"]
|
|
155
|
+
|
|
156
|
+
style O fill:#10b981,stroke:#059669,color:#000
|
|
65
157
|
```
|
|
66
158
|
|
|
159
|
+
codesight runs all 8 detectors in parallel, then writes the results as structured markdown. The output is designed to be read by an AI in a single file load.
|
|
160
|
+
|
|
67
161
|
## What It Generates
|
|
68
162
|
|
|
69
163
|
```
|
|
@@ -83,6 +177,21 @@ Saved: ~48,800 tokens per conversation
|
|
|
83
177
|
|
|
84
178
|
When TypeScript is installed in the project being scanned, codesight uses the actual TypeScript compiler API to parse your code structurally. No regex guessing.
|
|
85
179
|
|
|
180
|
+
```mermaid
|
|
181
|
+
flowchart TD
|
|
182
|
+
F["Source File"] --> Check{"TypeScript<br/>in node_modules?"}
|
|
183
|
+
Check -->|Yes| AST["AST Parse<br/>(TypeScript Compiler API)"]
|
|
184
|
+
Check -->|No| Regex["Regex Parse<br/>(Pattern Matching)"]
|
|
185
|
+
AST --> Result["Routes / Schema / Components<br/>confidence: ast"]
|
|
186
|
+
AST -->|"Parse failed"| Regex
|
|
187
|
+
Regex --> Result2["Routes / Schema / Components<br/>confidence: regex"]
|
|
188
|
+
|
|
189
|
+
style AST fill:#10b981,stroke:#059669,color:#000
|
|
190
|
+
style Regex fill:#f59e0b,stroke:#d97706,color:#000
|
|
191
|
+
style Result fill:#3b82f6,stroke:#2563eb,color:#fff
|
|
192
|
+
style Result2 fill:#3b82f6,stroke:#2563eb,color:#fff
|
|
193
|
+
```
|
|
194
|
+
|
|
86
195
|
| What AST enables | Regex alone |
|
|
87
196
|
|---|---|
|
|
88
197
|
| Follows `router.use('/prefix', subRouter)` chains | Misses nested routers |
|
|
@@ -91,43 +200,75 @@ When TypeScript is installed in the project being scanned, codesight uses the ac
|
|
|
91
200
|
| Extracts exact Drizzle field types from `.primaryKey().notNull()` chains | Pattern matching |
|
|
92
201
|
| Gets React props from TypeScript interfaces and destructuring | Regex on `{ prop }` |
|
|
93
202
|
| Detects middleware in route chains: `app.get('/path', auth, handler)` | Not captured |
|
|
203
|
+
| Filters out non-route calls like `c.get('userId')` | May false-positive |
|
|
94
204
|
|
|
95
|
-
AST detection is
|
|
205
|
+
AST detection is reported in the output:
|
|
96
206
|
|
|
97
207
|
```
|
|
98
|
-
Analyzing... done (AST:
|
|
208
|
+
Analyzing... done (AST: 60 routes, 18 models, 16 components)
|
|
99
209
|
```
|
|
100
210
|
|
|
101
211
|
No configuration needed. If TypeScript is in your `node_modules`, AST kicks in automatically. Works with npm, yarn, and pnpm (including strict mode). Falls back to regex for non-TypeScript projects or frameworks without AST support.
|
|
102
212
|
|
|
213
|
+
**AST-supported frameworks:** Express, Hono, Fastify, Koa, Elysia (route chains + middleware), NestJS (decorator combining + guards), tRPC (router nesting + procedure types), Drizzle (field chains + relations), TypeORM (entity decorators), React (props from interfaces + destructuring + forwardRef/memo).
|
|
214
|
+
|
|
103
215
|
## Routes
|
|
104
216
|
|
|
105
217
|
Not just paths. Methods, URL parameters, what each route touches (auth, database, cache, payments, AI, email, queues), and where the handler lives. Detects routes across 25+ frameworks automatically.
|
|
106
218
|
|
|
219
|
+
Actual output from BuildRadar:
|
|
220
|
+
|
|
221
|
+
```markdown
|
|
222
|
+
- `GET` `/dashboard/me` [auth, db, cache, payment, ai]
|
|
223
|
+
- `PUT` `/dashboard/me` [auth, db, cache, payment, ai]
|
|
224
|
+
- `DELETE` `/dashboard/me` [auth, db, cache, payment, ai]
|
|
225
|
+
- `POST` `/dashboard/generate-reply` [auth, db, cache, payment, ai]
|
|
226
|
+
- `POST` `/webhooks/polar` [db, payment]
|
|
227
|
+
- `GET` `/health` [auth, db, cache, payment, ai]
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Actual output from RankRev:
|
|
231
|
+
|
|
107
232
|
```markdown
|
|
108
|
-
- `
|
|
109
|
-
- `GET`
|
|
110
|
-
- `
|
|
111
|
-
- `
|
|
112
|
-
- `MUTATION` `createProject` [db, ai] # tRPC mutations
|
|
233
|
+
- `GET` `/:siteId` params(siteId) [auth, db]
|
|
234
|
+
- `GET` `/:siteId/actions` params(siteId) [auth, db]
|
|
235
|
+
- `PATCH` `/:siteId/:winId` params(siteId, winId) [auth, db]
|
|
236
|
+
- `GET` `/discover` params() [auth, db, payment]
|
|
113
237
|
```
|
|
114
238
|
|
|
115
239
|
## Schema
|
|
116
240
|
|
|
117
|
-
Models, fields, types, primary keys, foreign keys, unique constraints, relations. Parsed directly from your ORM definitions. No need to open migration files.
|
|
241
|
+
Models, fields, types, primary keys, foreign keys, unique constraints, relations. Parsed directly from your ORM definitions via AST. No need to open migration files.
|
|
242
|
+
|
|
243
|
+
Actual output from BuildRadar (12 models, all AST-parsed):
|
|
118
244
|
|
|
119
245
|
```markdown
|
|
120
|
-
###
|
|
121
|
-
- id:
|
|
246
|
+
### user
|
|
247
|
+
- id: text (pk)
|
|
248
|
+
- name: text (required)
|
|
122
249
|
- email: text (unique, required)
|
|
123
|
-
-
|
|
124
|
-
-
|
|
250
|
+
- emailVerified: boolean (default, required)
|
|
251
|
+
- tier: text (default, required)
|
|
252
|
+
- polarCustomerId: text (fk)
|
|
125
253
|
|
|
126
|
-
###
|
|
127
|
-
- id:
|
|
128
|
-
- userId:
|
|
254
|
+
### monitor
|
|
255
|
+
- id: text (default, pk)
|
|
256
|
+
- userId: text (fk, required)
|
|
129
257
|
- name: text (required)
|
|
130
|
-
-
|
|
258
|
+
- subreddits: jsonb (required)
|
|
259
|
+
- keywords: jsonb (required)
|
|
260
|
+
- _relations_: userId -> user.id
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Actual output from RankRev (8 models, all AST-parsed):
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
### sites
|
|
267
|
+
- id: uuid (pk)
|
|
268
|
+
- userId: uuid (fk, required)
|
|
269
|
+
- gscSiteUrl: text (required)
|
|
270
|
+
- ga4PropertyId: text (required, fk)
|
|
271
|
+
- lastSyncAt: timestamp
|
|
131
272
|
- _relations_: userId -> users.id
|
|
132
273
|
```
|
|
133
274
|
|
|
@@ -135,38 +276,111 @@ Models, fields, types, primary keys, foreign keys, unique constraints, relations
|
|
|
135
276
|
|
|
136
277
|
The files imported the most are the ones that break the most things when changed. codesight finds them and tells your AI to be careful.
|
|
137
278
|
|
|
279
|
+
Actual output from BuildRadar (101 import links):
|
|
280
|
+
|
|
138
281
|
```markdown
|
|
139
282
|
## Most Imported Files (change these carefully)
|
|
140
|
-
- `
|
|
141
|
-
- `
|
|
283
|
+
- `src/types/index.ts` — imported by **20** files
|
|
284
|
+
- `src/core/composio-auth.ts` — imported by **6** files
|
|
285
|
+
- `src/db/index.ts` — imported by **5** files
|
|
286
|
+
- `src/intelligence/patterns.ts` — imported by **5** files
|
|
287
|
+
- `src/core/cache.ts` — imported by **5** files
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Actual output from RankRev (76 import links):
|
|
291
|
+
|
|
292
|
+
```markdown
|
|
293
|
+
## Most Imported Files (change these carefully)
|
|
294
|
+
- `apps/api/src/db/schema.ts` — imported by **10** files
|
|
295
|
+
- `apps/api/src/db/index.ts` — imported by **10** files
|
|
142
296
|
- `apps/api/src/lib/auth.ts` — imported by **7** files
|
|
297
|
+
- `apps/api/src/lib/env.ts` — imported by **6** files
|
|
143
298
|
```
|
|
144
299
|
|
|
145
300
|
## Blast Radius
|
|
146
301
|
|
|
147
|
-
|
|
302
|
+
```mermaid
|
|
303
|
+
graph TD
|
|
304
|
+
DB["src/db/index.ts<br/>(you change this)"] --> D1["src/api/dashboard.ts"]
|
|
305
|
+
DB --> D2["src/api/webhooks.ts"]
|
|
306
|
+
DB --> D3["src/auth/session.ts"]
|
|
307
|
+
DB --> D4["src/monitor/scanner.ts"]
|
|
308
|
+
DB --> D5["src/monitor/daily-digest.ts"]
|
|
309
|
+
D1 --> D6["src/server.ts"]
|
|
310
|
+
D3 --> D7["src/auth/index.ts"]
|
|
311
|
+
D4 --> D8["src/monitor/cron.ts"]
|
|
312
|
+
D6 --> D9["src/index.ts"]
|
|
313
|
+
D6 --> D10["src/cli.ts"]
|
|
314
|
+
|
|
315
|
+
style DB fill:#ef4444,stroke:#dc2626,color:#fff
|
|
316
|
+
style D1 fill:#f59e0b,stroke:#d97706,color:#000
|
|
317
|
+
style D2 fill:#f59e0b,stroke:#d97706,color:#000
|
|
318
|
+
style D3 fill:#f59e0b,stroke:#d97706,color:#000
|
|
319
|
+
style D4 fill:#f59e0b,stroke:#d97706,color:#000
|
|
320
|
+
style D5 fill:#f59e0b,stroke:#d97706,color:#000
|
|
321
|
+
style D6 fill:#fbbf24,stroke:#f59e0b,color:#000
|
|
322
|
+
style D7 fill:#fbbf24,stroke:#f59e0b,color:#000
|
|
323
|
+
style D8 fill:#fbbf24,stroke:#f59e0b,color:#000
|
|
324
|
+
style D9 fill:#fde68a,stroke:#fbbf24,color:#000
|
|
325
|
+
style D10 fill:#fde68a,stroke:#fbbf24,color:#000
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
*Actual blast radius from BuildRadar: changing `src/db/index.ts` affects 10 files, 33 routes, and all 12 models.*
|
|
329
|
+
|
|
330
|
+
BFS through the import graph finds all transitively affected files, routes, models, and middleware.
|
|
148
331
|
|
|
149
332
|
```bash
|
|
150
|
-
npx codesight --blast src/
|
|
333
|
+
npx codesight --blast src/db/index.ts
|
|
151
334
|
```
|
|
152
335
|
|
|
336
|
+
Actual output from BuildRadar:
|
|
337
|
+
|
|
153
338
|
```
|
|
154
|
-
Blast Radius: src/
|
|
339
|
+
Blast Radius: src/db/index.ts
|
|
155
340
|
Depth: 3 hops
|
|
156
341
|
|
|
157
342
|
Affected files (10):
|
|
158
|
-
src/
|
|
159
|
-
src/
|
|
160
|
-
src/
|
|
161
|
-
|
|
343
|
+
src/api/dashboard.ts
|
|
344
|
+
src/api/webhooks.ts
|
|
345
|
+
src/auth/session.ts
|
|
346
|
+
src/monitor/daily-digest.ts
|
|
347
|
+
src/monitor/scanner.ts
|
|
348
|
+
src/server.ts
|
|
349
|
+
src/auth/index.ts
|
|
350
|
+
src/monitor/cron.ts
|
|
351
|
+
src/cli.ts
|
|
352
|
+
src/index.ts
|
|
162
353
|
|
|
163
354
|
Affected routes (33):
|
|
164
|
-
|
|
165
|
-
GET /
|
|
355
|
+
GET /dashboard/composio/login — src/api/dashboard.ts
|
|
356
|
+
GET /dashboard/me — src/api/dashboard.ts
|
|
357
|
+
PUT /dashboard/me — src/api/dashboard.ts
|
|
166
358
|
...
|
|
167
359
|
|
|
168
|
-
Affected models:
|
|
169
|
-
|
|
360
|
+
Affected models: user, session, account, reddit_credentials,
|
|
361
|
+
reddit_oauth_connection, monitor, scan_result, lead,
|
|
362
|
+
lead_dossier, conversion_event, generated_reply, market_snapshot
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Actual output from RankRev (changing `apps/api/src/db/schema.ts`):
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
Blast Radius: apps/api/src/db/schema.ts
|
|
369
|
+
Depth: 3 hops
|
|
370
|
+
|
|
371
|
+
Affected files (16):
|
|
372
|
+
apps/api/src/db/index.ts
|
|
373
|
+
apps/api/src/routes/ai-citability.ts
|
|
374
|
+
apps/api/src/routes/auth.ts
|
|
375
|
+
apps/api/src/routes/money-pages.ts
|
|
376
|
+
apps/api/src/services/gsc-fetcher.ts
|
|
377
|
+
apps/api/src/services/money-pages-engine.ts
|
|
378
|
+
...
|
|
379
|
+
|
|
380
|
+
Affected routes (17):
|
|
381
|
+
GET / — apps/api/src/index.ts
|
|
382
|
+
GET /:siteId — apps/api/src/routes/ai-citability.ts
|
|
383
|
+
...
|
|
170
384
|
```
|
|
171
385
|
|
|
172
386
|
Your AI can also query blast radius through the MCP server before making changes.
|
|
@@ -175,10 +389,16 @@ Your AI can also query blast radius through the MCP server before making changes
|
|
|
175
389
|
|
|
176
390
|
Every env var across your codebase, flagged as required or has default, with the exact file where it is referenced.
|
|
177
391
|
|
|
392
|
+
Actual output from BuildRadar (26 env vars):
|
|
393
|
+
|
|
178
394
|
```markdown
|
|
179
|
-
- `
|
|
180
|
-
- `
|
|
181
|
-
- `
|
|
395
|
+
- `ANTHROPIC_API_KEY` **required** — .env.example
|
|
396
|
+
- `DATABASE_URL` (has default) — .env.example
|
|
397
|
+
- `FRONTEND_URL` **required** — src/api/dashboard.ts
|
|
398
|
+
- `POLAR_ACCESS_TOKEN` **required** — .env.example
|
|
399
|
+
- `POLAR_WEBHOOK_SECRET` **required** — .env.example
|
|
400
|
+
- `REDDIT_OAUTH_CLIENT_ID` **required** — src/api/reddit-oauth.ts
|
|
401
|
+
- `RESEND_API_KEY` **required** — .env.example
|
|
182
402
|
```
|
|
183
403
|
|
|
184
404
|
## Token Benchmark
|
|
@@ -189,23 +409,43 @@ See exactly where your token savings come from:
|
|
|
189
409
|
npx codesight --benchmark
|
|
190
410
|
```
|
|
191
411
|
|
|
412
|
+
Actual output from SaveMRR (92 files, 4-workspace monorepo):
|
|
413
|
+
|
|
192
414
|
```
|
|
193
415
|
Token Savings Breakdown:
|
|
194
416
|
┌──────────────────────────────────────────────────┐
|
|
195
417
|
│ What codesight found │ Exploration cost │
|
|
196
418
|
├──────────────────────────────┼────────────────────┤
|
|
197
|
-
│
|
|
419
|
+
│ 60 routes │ ~24,000 tokens │
|
|
198
420
|
│ 18 schema models │ ~ 5,400 tokens │
|
|
199
421
|
│ 16 components │ ~ 4,000 tokens │
|
|
200
422
|
│ 36 library files │ ~ 7,200 tokens │
|
|
201
423
|
│ 22 env vars │ ~ 2,200 tokens │
|
|
424
|
+
│ 5 middleware │ ~ 1,000 tokens │
|
|
425
|
+
│ 20 hot files │ ~ 3,000 tokens │
|
|
202
426
|
│ 92 files (search overhead) │ ~ 4,000 tokens │
|
|
203
427
|
├──────────────────────────────┼────────────────────┤
|
|
204
|
-
│ codesight output │ ~
|
|
205
|
-
│
|
|
428
|
+
│ codesight output │ ~ 5,129 tokens │
|
|
429
|
+
│ Manual exploration (1.3x) │ ~66,040 tokens │
|
|
430
|
+
│ SAVED PER CONVERSATION │ ~60,911 tokens │
|
|
206
431
|
└──────────────────────────────┴────────────────────┘
|
|
207
432
|
```
|
|
208
433
|
|
|
434
|
+
### How Token Savings Are Calculated
|
|
435
|
+
|
|
436
|
+
Each detector type maps to a measured token cost that an AI would spend to discover the same information manually:
|
|
437
|
+
|
|
438
|
+
| What codesight finds | Tokens saved per item | Why |
|
|
439
|
+
|---|---|---|
|
|
440
|
+
| Each route | ~400 tokens | AI reads the handler file, greps for the path, reads middleware |
|
|
441
|
+
| Each schema model | ~300 tokens | AI opens migration/ORM files, parses fields manually |
|
|
442
|
+
| Each component | ~250 tokens | AI opens component files, reads prop types |
|
|
443
|
+
| Each library export | ~200 tokens | AI greps for exports, reads signatures |
|
|
444
|
+
| Each env var | ~100 tokens | AI greps for `process.env`, reads .env files |
|
|
445
|
+
| Each file scanned | ~80 tokens | AI runs glob/grep operations to find relevant files |
|
|
446
|
+
|
|
447
|
+
The 1.3x multiplier accounts for AI revisiting files during multi-turn conversations. These estimates are conservative. A developer manually verified that Claude Code spends 40-70K tokens exploring the same projects that codesight summarizes in 3-5K tokens.
|
|
448
|
+
|
|
209
449
|
## Supported Stacks
|
|
210
450
|
|
|
211
451
|
| Category | Supported |
|
|
@@ -257,7 +497,20 @@ Runs as a Model Context Protocol server. Claude Code and Cursor call it directly
|
|
|
257
497
|
}
|
|
258
498
|
```
|
|
259
499
|
|
|
260
|
-
|
|
500
|
+
```mermaid
|
|
501
|
+
flowchart LR
|
|
502
|
+
AI["Claude Code<br/>or Cursor"] <-->|"JSON-RPC 2.0<br/>over stdio"| MCP["codesight<br/>MCP Server"]
|
|
503
|
+
MCP --> Cache["Session Cache<br/>(scan once)"]
|
|
504
|
+
MCP --> T1["get_summary"]
|
|
505
|
+
MCP --> T2["get_routes"]
|
|
506
|
+
MCP --> T3["get_schema"]
|
|
507
|
+
MCP --> T4["get_blast_radius"]
|
|
508
|
+
MCP --> T5["get_env"]
|
|
509
|
+
MCP --> T6["get_hot_files"]
|
|
510
|
+
|
|
511
|
+
style MCP fill:#f59e0b,stroke:#d97706,color:#000
|
|
512
|
+
style Cache fill:#10b981,stroke:#059669,color:#000
|
|
513
|
+
```
|
|
261
514
|
|
|
262
515
|
| Tool | What it does |
|
|
263
516
|
|---|---|
|
|
@@ -351,20 +604,21 @@ npx codesight -d 5 # Limit directory depth
|
|
|
351
604
|
|
|
352
605
|
## How It Compares
|
|
353
606
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
| | codesight | File concatenation tools | AST-based tools |
|
|
607
|
+
| | codesight | File concatenation tools | AST-based tools (e.g. code-review-graph) |
|
|
357
608
|
|---|---|---|---|
|
|
358
|
-
| **Parsing** | AST
|
|
359
|
-
| **
|
|
360
|
-
| **
|
|
361
|
-
| **
|
|
362
|
-
| **
|
|
363
|
-
| **
|
|
364
|
-
| **
|
|
365
|
-
| **
|
|
366
|
-
| **
|
|
367
|
-
| **
|
|
609
|
+
| **Parsing** | AST (TypeScript compiler) + regex fallback | None | Tree-sitter + SQLite |
|
|
610
|
+
| **Token reduction** | 9x-13x measured on real projects | 1x (dumps everything) | 8x reported |
|
|
611
|
+
| **Route detection** | 25+ frameworks, auto-detected | None | Limited |
|
|
612
|
+
| **Schema parsing** | 8 ORMs with field types and relations | None | Varies |
|
|
613
|
+
| **Blast radius** | BFS through import graph | None | Yes |
|
|
614
|
+
| **AI tool profiles** | 5 tools (Claude, Cursor, Codex, Copilot, Windsurf) | None | Auto-detect |
|
|
615
|
+
| **MCP tools** | 8 specialized tools with session caching | None | 22 tools |
|
|
616
|
+
| **Setup** | `npx codesight` (zero deps, zero config) | Copy/paste | `pip install` + optional deps |
|
|
617
|
+
| **Dependencies** | Zero (borrows TS from your project) | Varies | Tree-sitter, SQLite, NetworkX, etc. |
|
|
618
|
+
| **Language** | TypeScript (zero runtime deps) | Varies | Python |
|
|
619
|
+
| **Scan time** | 185-290ms on real projects | Varies | Under 2s reported |
|
|
620
|
+
|
|
621
|
+
codesight is purpose-built for the problem most developers actually have: giving their AI assistant enough context to be useful without wasting tokens on file exploration. It focuses on structured extraction (routes, schema, components, dependencies) rather than general-purpose code graph analysis.
|
|
368
622
|
|
|
369
623
|
## Contributing
|
|
370
624
|
|
|
@@ -390,6 +644,5 @@ MIT
|
|
|
390
644
|
If codesight saves you tokens, [star it on GitHub](https://github.com/Houseofmvps/codesight) so others find it too.
|
|
391
645
|
|
|
392
646
|
[](https://github.com/Houseofmvps/codesight/stargazers)
|
|
393
|
-
[](https://github.com/sponsors/Houseofmvps)
|
|
394
647
|
|
|
395
648
|
</div>
|
package/dist/detectors/routes.js
CHANGED
|
@@ -99,7 +99,17 @@ export async function detectRoutes(files, project) {
|
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
// Deduplicate: same method + path from different files/frameworks
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
const deduped = [];
|
|
105
|
+
for (const route of routes) {
|
|
106
|
+
const key = `${route.method}:${route.path}`;
|
|
107
|
+
if (!seen.has(key)) {
|
|
108
|
+
seen.add(key);
|
|
109
|
+
deduped.push(route);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return deduped;
|
|
103
113
|
}
|
|
104
114
|
// --- Next.js App Router ---
|
|
105
115
|
async function detectNextAppRoutes(files, project) {
|
|
@@ -885,7 +895,6 @@ async function detectRustRoutes(files, project, fw) {
|
|
|
885
895
|
async function detectRawHttpRoutes(files, project) {
|
|
886
896
|
const tsFiles = files.filter((f) => f.match(/\.(ts|js|mjs|cjs)$/));
|
|
887
897
|
const routes = [];
|
|
888
|
-
const globalSeen = new Set();
|
|
889
898
|
for (const file of tsFiles) {
|
|
890
899
|
const content = await readFileSafe(file);
|
|
891
900
|
// Only scan files that handle HTTP requests
|
|
@@ -911,16 +920,12 @@ async function detectRawHttpRoutes(files, project) {
|
|
|
911
920
|
// Skip file extensions
|
|
912
921
|
if (path.match(/\.\w{2,4}$/))
|
|
913
922
|
continue;
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
// Try to detect method from surrounding context (within 300 chars)
|
|
919
|
-
const surroundingStart = Math.max(0, match.index - 300);
|
|
920
|
-
const surroundingEnd = Math.min(content.length, match.index + 300);
|
|
921
|
-
const surrounding = content.substring(surroundingStart, surroundingEnd);
|
|
923
|
+
// Detect method from the same line or immediately adjacent lines (within 100 chars)
|
|
924
|
+
const lineStart = content.lastIndexOf("\n", match.index) + 1;
|
|
925
|
+
const lineEnd = content.indexOf("\n", match.index + match[0].length);
|
|
926
|
+
const lineContext = content.substring(Math.max(0, lineStart - 50), Math.min(content.length, (lineEnd === -1 ? content.length : lineEnd) + 50));
|
|
922
927
|
let method = "ALL";
|
|
923
|
-
const methodMatch =
|
|
928
|
+
const methodMatch = lineContext.match(/method\s*===?\s*['"`](GET|POST|PUT|PATCH|DELETE)['"`]/i);
|
|
924
929
|
if (methodMatch) {
|
|
925
930
|
method = methodMatch[1].toUpperCase();
|
|
926
931
|
}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { calculateTokenStats } from "./detectors/tokens.js";
|
|
|
14
14
|
import { writeOutput } from "./formatter.js";
|
|
15
15
|
import { generateAIConfigs } from "./generators/ai-config.js";
|
|
16
16
|
import { generateHtmlReport } from "./generators/html-report.js";
|
|
17
|
-
const VERSION = "1.3.
|
|
17
|
+
const VERSION = "1.3.2";
|
|
18
18
|
const BRAND = "codesight";
|
|
19
19
|
function printHelp() {
|
|
20
20
|
console.log(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesight",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "See your codebase clearly. Universal AI context generator that maps routes, schema, components, dependencies, and more for Claude Code, Cursor, Copilot, Codex, and any AI coding tool.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|