codesight 1.3.1 → 1.4.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 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. Blast radius analysis. One `npx` call.**
5
+ **Zero dependencies. AST precision. 25+ framework detectors. 8 ORM parsers. 8 MCP tools. One `npx` call.**
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/codesight?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/codesight)
8
8
  [![npm downloads](https://img.shields.io/npm/dm/codesight?style=for-the-badge&logo=npm&color=blue&label=Monthly%20Downloads)](https://www.npmjs.com/package/codesight)
9
9
  [![npm total](https://img.shields.io/npm/dt/codesight?style=for-the-badge&logo=npm&color=cyan&label=Total%20Downloads)](https://www.npmjs.com/package/codesight)
10
10
  [![GitHub stars](https://img.shields.io/github/stars/Houseofmvps/codesight?style=for-the-badge&logo=github&color=gold)](https://github.com/Houseofmvps/codesight/stargazers)
11
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge&logo=opensourceinitiative)](LICENSE)
12
- [![Sponsor](https://img.shields.io/badge/Sponsor-EA4AAA?style=for-the-badge&logo=githubsponsors&logoColor=white)](https://github.com/sponsors/Houseofmvps)
13
12
 
14
13
  ---
15
14
 
@@ -50,19 +49,74 @@ 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
- ## What It Does
52
+ ## Benchmarks (Real Projects)
54
53
 
55
- Every AI coding conversation starts the same way. Your assistant reads files, greps for patterns, opens configs, just to understand the project. That exploration costs tens of thousands of tokens before it writes a single line of code.
54
+ Every number below comes from running `codesight v1.3.1` on real production codebases. No estimates, no hypotheticals.
56
55
 
57
- codesight scans your codebase once and generates a structured context map. Routes, database schema, components, dependencies, environment variables, middleware, all condensed into ~3,000 to 5,000 tokens of structured markdown. Your AI reads one file and knows the entire project.
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 |
58
61
 
59
- **v1.3.0: AST-level precision.** When TypeScript is available in your project, codesight uses the TypeScript compiler API for structural parsing instead of regex. This gives exact route paths, proper controller prefix combining (NestJS), accurate tRPC procedure nesting, precise Drizzle field types, and React prop extraction from type annotations. Zero new dependencies — borrows TypeScript from your project's node_modules. Falls back to regex when TypeScript is not available.
62
+ **Average: 11.2x token reduction.** Your AI reads ~3K-5K tokens instead of burning ~26K-66K exploring files.
60
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
61
81
  ```
62
- Output size: ~3,200 tokens
63
- Exploration cost: ~52,000 tokens (without codesight)
64
- Saved: ~48,800 tokens per conversation
65
- ```
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:
98
+
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
103
+
104
+ ### What Gets Detected
105
+
106
+ Measured across the three benchmark projects:
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
+ ---
66
120
 
67
121
  ## How It Works
68
122
 
@@ -97,28 +151,12 @@ flowchart TD
97
151
  end
98
152
 
99
153
  A["File Scanner"] --> Detectors
100
- Detectors --> O["~3K-5K tokens<br/>vs ~50K-70K exploration"]
154
+ Detectors --> O["~3K-5K tokens output"]
101
155
 
102
156
  style O fill:#10b981,stroke:#059669,color:#000
103
157
  ```
104
158
 
105
- ```mermaid
106
- flowchart LR
107
- subgraph Without["Without codesight"]
108
- W1["AI reads files"] --> W2["AI greps patterns"]
109
- W2 --> W3["AI opens configs"]
110
- W3 --> W4["AI explores deps"]
111
- W4 --> W5["50,000+ tokens burned"]
112
- end
113
-
114
- subgraph With["With codesight"]
115
- C1["AI reads CODESIGHT.md"] --> C2["Full project context"]
116
- C2 --> C3["~3,000 tokens"]
117
- end
118
-
119
- style W5 fill:#ef4444,stroke:#dc2626,color:#fff
120
- style C3 fill:#10b981,stroke:#059669,color:#000
121
- ```
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.
122
160
 
123
161
  ## What It Generates
124
162
 
@@ -139,65 +177,98 @@ flowchart LR
139
177
 
140
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.
141
179
 
142
- | What AST enables | Regex alone |
143
- |---|---|
144
- | Follows `router.use('/prefix', subRouter)` chains | Misses nested routers |
145
- | Combines `@Controller('users')` + `@Get(':id')` into `/users/:id` | May miss prefix |
146
- | Parses `router({ users: userRouter })` tRPC nesting | Line-by-line matching |
147
- | Extracts exact Drizzle field types from `.primaryKey().notNull()` chains | Pattern matching |
148
- | Gets React props from TypeScript interfaces and destructuring | Regex on `{ prop }` |
149
- | Detects middleware in route chains: `app.get('/path', auth, handler)` | Not captured |
150
-
151
180
  ```mermaid
152
181
  flowchart TD
153
182
  F["Source File"] --> Check{"TypeScript<br/>in node_modules?"}
154
183
  Check -->|Yes| AST["AST Parse<br/>(TypeScript Compiler API)"]
155
184
  Check -->|No| Regex["Regex Parse<br/>(Pattern Matching)"]
156
- AST --> Result["Routes / Schema / Components"]
185
+ AST --> Result["Routes / Schema / Components<br/>confidence: ast"]
157
186
  AST -->|"Parse failed"| Regex
158
- Regex --> Result
187
+ Regex --> Result2["Routes / Schema / Components<br/>confidence: regex"]
159
188
 
160
189
  style AST fill:#10b981,stroke:#059669,color:#000
161
190
  style Regex fill:#f59e0b,stroke:#d97706,color:#000
162
191
  style Result fill:#3b82f6,stroke:#2563eb,color:#fff
192
+ style Result2 fill:#3b82f6,stroke:#2563eb,color:#fff
163
193
  ```
164
194
 
165
- AST detection is indicated in the output:
195
+ | What AST enables | Regex alone |
196
+ |---|---|
197
+ | Follows `router.use('/prefix', subRouter)` chains | Misses nested routers |
198
+ | Combines `@Controller('users')` + `@Get(':id')` into `/users/:id` | May miss prefix |
199
+ | Parses `router({ users: userRouter })` tRPC nesting | Line-by-line matching |
200
+ | Extracts exact Drizzle field types from `.primaryKey().notNull()` chains | Pattern matching |
201
+ | Gets React props from TypeScript interfaces and destructuring | Regex on `{ prop }` |
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 |
204
+
205
+ AST detection is reported in the output:
166
206
 
167
207
  ```
168
- Analyzing... done (AST: 65 routes, 18 models, 16 components)
208
+ Analyzing... done (AST: 60 routes, 18 models, 16 components)
169
209
  ```
170
210
 
171
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.
172
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
+
173
215
  ## Routes
174
216
 
175
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.
176
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
+
177
232
  ```markdown
178
- - `POST` `/auth/login` [auth, db, email]
179
- - `GET` `/api/projects/:id/analytics` params(id) [auth, db, cache]
180
- - `POST` `/api/billing/checkout` [auth, db, payment]
181
- - `QUERY` `getUsers` [db] # tRPC procedures
182
- - `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]
183
237
  ```
184
238
 
185
239
  ## Schema
186
240
 
187
- 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):
188
244
 
189
245
  ```markdown
190
- ### users
191
- - id: uuid (pk, default)
246
+ ### user
247
+ - id: text (pk)
248
+ - name: text (required)
192
249
  - email: text (unique, required)
193
- - plan: text (required, default)
194
- - stripeCustomerId: text (fk)
250
+ - emailVerified: boolean (default, required)
251
+ - tier: text (default, required)
252
+ - polarCustomerId: text (fk)
195
253
 
196
- ### projects
197
- - id: uuid (pk, default)
198
- - userId: uuid (fk)
254
+ ### monitor
255
+ - id: text (default, pk)
256
+ - userId: text (fk, required)
199
257
  - name: text (required)
200
- - domain: text (unique)
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
201
272
  - _relations_: userId -> users.id
202
273
  ```
203
274
 
@@ -205,57 +276,111 @@ Models, fields, types, primary keys, foreign keys, unique constraints, relations
205
276
 
206
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.
207
278
 
279
+ Actual output from BuildRadar (101 import links):
280
+
208
281
  ```markdown
209
282
  ## Most Imported Files (change these carefully)
210
- - `packages/shared/src/index.ts` — imported by **14** files
211
- - `apps/api/src/lib/db.ts` — imported by **9** files
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
212
296
  - `apps/api/src/lib/auth.ts` — imported by **7** files
297
+ - `apps/api/src/lib/env.ts` — imported by **6** files
213
298
  ```
214
299
 
215
300
  ## Blast Radius
216
301
 
217
302
  ```mermaid
218
303
  graph TD
219
- DB["src/lib/db.ts<br/>(you change this)"] --> U["src/routes/users.ts"]
220
- DB --> P["src/routes/projects.ts"]
221
- DB --> B["src/routes/billing.ts"]
222
- DB --> A["src/routes/auth.ts"]
223
- U --> MW["src/middleware/auth.ts"]
224
- P --> MW
225
- B --> S["src/services/stripe.ts"]
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"]
226
314
 
227
315
  style DB fill:#ef4444,stroke:#dc2626,color:#fff
228
- style U fill:#f59e0b,stroke:#d97706,color:#000
229
- style P fill:#f59e0b,stroke:#d97706,color:#000
230
- style B fill:#f59e0b,stroke:#d97706,color:#000
231
- style A fill:#f59e0b,stroke:#d97706,color:#000
232
- style MW fill:#fbbf24,stroke:#f59e0b,color:#000
233
- style S fill:#fbbf24,stroke:#f59e0b,color:#000
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
234
326
  ```
235
327
 
236
- See exactly what breaks if you change a file. BFS through the import graph finds all transitively affected files, routes, models, and middleware.
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.
237
331
 
238
332
  ```bash
239
- npx codesight --blast src/lib/db.ts
333
+ npx codesight --blast src/db/index.ts
240
334
  ```
241
335
 
336
+ Actual output from BuildRadar:
337
+
242
338
  ```
243
- Blast Radius: src/lib/db.ts
339
+ Blast Radius: src/db/index.ts
244
340
  Depth: 3 hops
245
341
 
246
342
  Affected files (10):
247
- src/routes/users.ts
248
- src/routes/projects.ts
249
- src/routes/billing.ts
250
- ...
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
251
353
 
252
354
  Affected routes (33):
253
- POST /auth/login — src/routes/auth.ts
254
- GET /api/users — src/routes/users.ts
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
358
+ ...
359
+
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
255
378
  ...
256
379
 
257
- Affected models: users, projects, subscriptions
258
- Affected middleware: authMiddleware
380
+ Affected routes (17):
381
+ GET / — apps/api/src/index.ts
382
+ GET /:siteId — apps/api/src/routes/ai-citability.ts
383
+ ...
259
384
  ```
260
385
 
261
386
  Your AI can also query blast radius through the MCP server before making changes.
@@ -264,10 +389,16 @@ Your AI can also query blast radius through the MCP server before making changes
264
389
 
265
390
  Every env var across your codebase, flagged as required or has default, with the exact file where it is referenced.
266
391
 
392
+ Actual output from BuildRadar (26 env vars):
393
+
267
394
  ```markdown
268
- - `DATABASE_URL` **required** — apps/api/src/lib/db.ts
269
- - `JWT_SECRET` **required**apps/api/src/lib/auth.ts
270
- - `PORT` (has default) apps/api/src/index.ts
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
271
402
  ```
272
403
 
273
404
  ## Token Benchmark
@@ -278,23 +409,43 @@ See exactly where your token savings come from:
278
409
  npx codesight --benchmark
279
410
  ```
280
411
 
412
+ Actual output from SaveMRR (92 files, 4-workspace monorepo):
413
+
281
414
  ```
282
415
  Token Savings Breakdown:
283
416
  ┌──────────────────────────────────────────────────┐
284
417
  │ What codesight found │ Exploration cost │
285
418
  ├──────────────────────────────┼────────────────────┤
286
- 65 routes │ ~26,000 tokens │
419
+ 60 routes │ ~24,000 tokens │
287
420
  │ 18 schema models │ ~ 5,400 tokens │
288
421
  │ 16 components │ ~ 4,000 tokens │
289
422
  │ 36 library files │ ~ 7,200 tokens │
290
423
  │ 22 env vars │ ~ 2,200 tokens │
424
+ │ 5 middleware │ ~ 1,000 tokens │
425
+ │ 20 hot files │ ~ 3,000 tokens │
291
426
  │ 92 files (search overhead) │ ~ 4,000 tokens │
292
427
  ├──────────────────────────────┼────────────────────┤
293
- │ codesight output │ ~ 4,041 tokens │
294
- SAVED PER CONVERSATION │ ~64,599 tokens │
428
+ │ codesight output │ ~ 5,129 tokens │
429
+ Manual exploration (1.3x) │ ~66,040 tokens │
430
+ │ SAVED PER CONVERSATION │ ~60,911 tokens │
295
431
  └──────────────────────────────┴────────────────────┘
296
432
  ```
297
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
+
298
449
  ## Supported Stacks
299
450
 
300
451
  | Category | Supported |
@@ -361,8 +512,6 @@ flowchart LR
361
512
  style Cache fill:#10b981,stroke:#059669,color:#000
362
513
  ```
363
514
 
364
- Exposes 8 specialized tools, each returning only what your AI needs:
365
-
366
515
  | Tool | What it does |
367
516
  |---|---|
368
517
  | `codesight_scan` | Full project scan (~3K-5K tokens) |
@@ -455,20 +604,21 @@ npx codesight -d 5 # Limit directory depth
455
604
 
456
605
  ## How It Compares
457
606
 
458
- Most AI context tools dump your entire codebase into one file. codesight takes a different approach: it **parses** your code to extract structured information.
459
-
460
- | | codesight | File concatenation tools | AST-based tools |
607
+ | | codesight | File concatenation tools | AST-based tools (e.g. code-review-graph) |
461
608
  |---|---|---|---|
462
- | **Parsing** | AST when available, regex fallback | None | Tree-sitter / custom |
463
- | **Output** | Structured routes, schema, components, deps | Raw file contents | Call graphs, class diagrams |
464
- | **Token cost** | ~3,000-5,000 tokens | 50,000-500,000+ tokens | Varies |
465
- | **Route detection** | 25+ frameworks auto-detected | None | Limited |
466
- | **Schema parsing** | 8 ORMs with relations | None | Varies |
467
- | **Blast radius** | BFS through import graph | None | Some |
468
- | **AI tool profiles** | 5 tools (Claude, Cursor, Codex, Copilot, Windsurf) | None | None |
469
- | **MCP server** | 8 specialized tools with session caching | None | Some |
470
- | **Setup** | `npx codesight` (zero deps, zero config) | Copy/paste | Install compilers, runtimes |
471
- | **Dependencies** | Zero (borrows TS from your project) | Varies | Tree-sitter, SQLite, etc. |
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.
472
622
 
473
623
  ## Contributing
474
624
 
@@ -494,6 +644,5 @@ MIT
494
644
  If codesight saves you tokens, [star it on GitHub](https://github.com/Houseofmvps/codesight) so others find it too.
495
645
 
496
646
  [![GitHub stars](https://img.shields.io/github/stars/Houseofmvps/codesight?style=for-the-badge&logo=github&color=gold)](https://github.com/Houseofmvps/codesight/stargazers)
497
- [![Sponsor](https://img.shields.io/badge/Sponsor-EA4AAA?style=for-the-badge&logo=githubsponsors&logoColor=white)](https://github.com/sponsors/Houseofmvps)
498
647
 
499
648
  </div>
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Configuration loader: reads codesight.config.(ts|js|json) from project root.
3
+ */
4
+ import type { CodesightConfig } from "./types.js";
5
+ /**
6
+ * Load config from project root. Returns empty config if no config file found.
7
+ */
8
+ export declare function loadConfig(root: string): Promise<CodesightConfig>;
9
+ /**
10
+ * Merges CLI args with config file values (CLI takes precedence).
11
+ */
12
+ export declare function mergeCliConfig(config: CodesightConfig, cli: {
13
+ maxDepth?: number;
14
+ outputDir?: string;
15
+ profile?: string;
16
+ }): CodesightConfig;
package/dist/config.js ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Configuration loader: reads codesight.config.(ts|js|json) from project root.
3
+ */
4
+ import { readFile, stat } from "node:fs/promises";
5
+ import { join } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ const CONFIG_FILES = [
8
+ "codesight.config.ts",
9
+ "codesight.config.js",
10
+ "codesight.config.mjs",
11
+ "codesight.config.json",
12
+ ];
13
+ async function fileExists(path) {
14
+ try {
15
+ await stat(path);
16
+ return true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ /**
23
+ * Load config from project root. Returns empty config if no config file found.
24
+ */
25
+ export async function loadConfig(root) {
26
+ for (const filename of CONFIG_FILES) {
27
+ const configPath = join(root, filename);
28
+ if (!(await fileExists(configPath)))
29
+ continue;
30
+ try {
31
+ if (filename.endsWith(".json")) {
32
+ const content = await readFile(configPath, "utf-8");
33
+ return JSON.parse(content);
34
+ }
35
+ if (filename.endsWith(".ts")) {
36
+ // Try loading with tsx or ts-node if available
37
+ return await loadTsConfig(configPath, root);
38
+ }
39
+ // JS/MJS — dynamic import
40
+ const module = await import(pathToFileURL(configPath).href);
41
+ return (module.default || module);
42
+ }
43
+ catch (err) {
44
+ console.warn(` Warning: failed to load ${filename}: ${err.message}`);
45
+ return {};
46
+ }
47
+ }
48
+ // Also check package.json "codesight" field
49
+ try {
50
+ const pkgPath = join(root, "package.json");
51
+ if (await fileExists(pkgPath)) {
52
+ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
53
+ if (pkg.codesight && typeof pkg.codesight === "object") {
54
+ return pkg.codesight;
55
+ }
56
+ }
57
+ }
58
+ catch { }
59
+ return {};
60
+ }
61
+ async function loadTsConfig(configPath, _root) {
62
+ // Strategy 1: try tsx via dynamic import of the .ts file directly
63
+ // (works if tsx or ts-node is installed)
64
+ try {
65
+ const module = await import(pathToFileURL(configPath).href);
66
+ return (module.default || module);
67
+ }
68
+ catch { }
69
+ // Strategy 2: read as text and extract JSON-like config
70
+ // (fallback for when no TS loader is available)
71
+ const content = await readFile(configPath, "utf-8");
72
+ // Try to extract the config object from simple export default { ... }
73
+ const match = content.match(/export\s+default\s+({[\s\S]*})\s*;?\s*$/m);
74
+ if (match) {
75
+ try {
76
+ // Use Function constructor to evaluate the object literal
77
+ // Safe here since this is user's own config file in their project
78
+ const fn = new Function(`return (${match[1]})`);
79
+ return fn();
80
+ }
81
+ catch { }
82
+ }
83
+ console.warn(` Warning: cannot load codesight.config.ts (install tsx for TS config support)`);
84
+ return {};
85
+ }
86
+ /**
87
+ * Merges CLI args with config file values (CLI takes precedence).
88
+ */
89
+ export function mergeCliConfig(config, cli) {
90
+ return {
91
+ ...config,
92
+ maxDepth: cli.maxDepth ?? config.maxDepth,
93
+ outputDir: cli.outputDir ?? config.outputDir,
94
+ profile: cli.profile ?? config.profile,
95
+ };
96
+ }
@@ -257,7 +257,7 @@ async function detectSQLAlchemySchemas(files, project) {
257
257
  if (!content.includes("Base") && !content.includes("DeclarativeBase") && !content.includes("Model"))
258
258
  continue;
259
259
  // Match class definitions
260
- const classPattern = /class\s+(\w+)\s*\([^)]*(?:Base|Model|DeclarativeBase)[^)]*\)\s*:([\s\S]*?)(?=\nclass\s|\n[^\s]|\Z)/g;
260
+ const classPattern = /class\s+(\w+)\s*\([^)]*(?:Base|Model|DeclarativeBase)[^)]*\)\s*:([\s\S]*?)(?=\nclass\s|\n[^\s]|$)/g;
261
261
  let match;
262
262
  while ((match = classPattern.exec(content)) !== null) {
263
263
  const name = match[1];
package/dist/eval.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Evaluation suite: runs codesight on fixture repos and measures
3
+ * precision, recall, and F1 against ground truth.
4
+ */
5
+ export declare function runEval(): Promise<void>;