codesight 1.3.0 → 1.3.1

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
@@ -64,6 +64,62 @@ Exploration cost: ~52,000 tokens (without codesight)
64
64
  Saved: ~48,800 tokens per conversation
65
65
  ```
66
66
 
67
+ ## How It Works
68
+
69
+ ```mermaid
70
+ flowchart LR
71
+ A["Your Codebase"] --> B["codesight"]
72
+ B --> C["AST Parser"]
73
+ B --> D["Regex Fallback"]
74
+ C --> E["Structured Context Map"]
75
+ D --> E
76
+ E --> F["CLAUDE.md"]
77
+ E --> G[".cursorrules"]
78
+ E --> H["codex.md"]
79
+ E --> I["MCP Server"]
80
+
81
+ style B fill:#f59e0b,stroke:#d97706,color:#000
82
+ style C fill:#10b981,stroke:#059669,color:#000
83
+ style E fill:#3b82f6,stroke:#2563eb,color:#fff
84
+ ```
85
+
86
+ ```mermaid
87
+ flowchart TD
88
+ subgraph Detectors["8 Parallel Detectors"]
89
+ R["Routes<br/>25+ frameworks"]
90
+ S["Schema<br/>8 ORMs"]
91
+ CP["Components<br/>React/Vue/Svelte"]
92
+ G["Dep Graph<br/>Import analysis"]
93
+ M["Middleware<br/>Auth/CORS/etc"]
94
+ CF["Config<br/>Env vars"]
95
+ L["Libraries<br/>Exports + sigs"]
96
+ CT["Contracts<br/>Params + types"]
97
+ end
98
+
99
+ A["File Scanner"] --> Detectors
100
+ Detectors --> O["~3K-5K tokens<br/>vs ~50K-70K exploration"]
101
+
102
+ style O fill:#10b981,stroke:#059669,color:#000
103
+ ```
104
+
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
+ ```
122
+
67
123
  ## What It Generates
68
124
 
69
125
  ```
@@ -92,6 +148,20 @@ When TypeScript is installed in the project being scanned, codesight uses the ac
92
148
  | Gets React props from TypeScript interfaces and destructuring | Regex on `{ prop }` |
93
149
  | Detects middleware in route chains: `app.get('/path', auth, handler)` | Not captured |
94
150
 
151
+ ```mermaid
152
+ flowchart TD
153
+ F["Source File"] --> Check{"TypeScript<br/>in node_modules?"}
154
+ Check -->|Yes| AST["AST Parse<br/>(TypeScript Compiler API)"]
155
+ Check -->|No| Regex["Regex Parse<br/>(Pattern Matching)"]
156
+ AST --> Result["Routes / Schema / Components"]
157
+ AST -->|"Parse failed"| Regex
158
+ Regex --> Result
159
+
160
+ style AST fill:#10b981,stroke:#059669,color:#000
161
+ style Regex fill:#f59e0b,stroke:#d97706,color:#000
162
+ style Result fill:#3b82f6,stroke:#2563eb,color:#fff
163
+ ```
164
+
95
165
  AST detection is indicated in the output:
96
166
 
97
167
  ```
@@ -144,6 +214,25 @@ The files imported the most are the ones that break the most things when changed
144
214
 
145
215
  ## Blast Radius
146
216
 
217
+ ```mermaid
218
+ 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"]
226
+
227
+ 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
234
+ ```
235
+
147
236
  See exactly what breaks if you change a file. BFS through the import graph finds all transitively affected files, routes, models, and middleware.
148
237
 
149
238
  ```bash
@@ -257,6 +346,21 @@ Runs as a Model Context Protocol server. Claude Code and Cursor call it directly
257
346
  }
258
347
  ```
259
348
 
349
+ ```mermaid
350
+ flowchart LR
351
+ AI["Claude Code<br/>or Cursor"] <-->|"JSON-RPC 2.0<br/>over stdio"| MCP["codesight<br/>MCP Server"]
352
+ MCP --> Cache["Session Cache<br/>(scan once)"]
353
+ MCP --> T1["get_summary"]
354
+ MCP --> T2["get_routes"]
355
+ MCP --> T3["get_schema"]
356
+ MCP --> T4["get_blast_radius"]
357
+ MCP --> T5["get_env"]
358
+ MCP --> T6["get_hot_files"]
359
+
360
+ style MCP fill:#f59e0b,stroke:#d97706,color:#000
361
+ style Cache fill:#10b981,stroke:#059669,color:#000
362
+ ```
363
+
260
364
  Exposes 8 specialized tools, each returning only what your AI needs:
261
365
 
262
366
  | Tool | What it does |
@@ -99,7 +99,17 @@ export async function detectRoutes(files, project) {
99
99
  break;
100
100
  }
101
101
  }
102
- return routes;
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
- const key = `${rel}:${path}`;
915
- if (globalSeen.has(key))
916
- continue;
917
- globalSeen.add(key);
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 = surrounding.match(/method\s*===?\s*['"`](GET|POST|PUT|PATCH|DELETE)['"`]/i);
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.0";
17
+ const VERSION = "1.3.1";
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.0",
3
+ "version": "1.3.1",
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": {