carto-md 1.0.19 → 1.1.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/CONTRIBUTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Contributing to Carto
2
2
 
3
- Carto is free, open source, and community-maintained. The core team owns the merger logic, AST engine, and CLI. The community owns language and framework extractors.
3
+ Carto is free, open source, and community-maintained. The core team owns the merger logic, MCP server, graph clustering, and CLI. The community owns language and framework extractors.
4
4
 
5
5
  ---
6
6
 
@@ -8,9 +8,9 @@ Carto is free, open source, and community-maintained. The core team owns the mer
8
8
 
9
9
  ### Tier 1 — Languages (safe to add, easy to review)
10
10
 
11
- New language support lives in `src/ast/languages/`. Each language is an isolated module.
11
+ New language support lives in `src/extractors/languages/`. Each language is an isolated module.
12
12
 
13
- Currently supported: JavaScript/TypeScript, Python.
13
+ Currently supported: JavaScript/TypeScript, Python, R.
14
14
 
15
15
  Wanted: Go, Rust, Ruby, Java, PHP, C#.
16
16
 
@@ -18,14 +18,15 @@ Wanted: Go, Rust, Ruby, Java, PHP, C#.
18
18
 
19
19
  Framework-specific route and model extraction lives in `src/extractors/`. Each framework is an isolated module.
20
20
 
21
- Currently supported: FastAPI, Express, Next.js App Router, Prisma, HTML fetch().
21
+ Currently supported: FastAPI, Express, Next.js App Router, Prisma, tRPC, HTML fetch(), Plumber, Shiny.
22
22
 
23
23
  Wanted: Django, Rails, Laravel, NestJS, Hono, Gin, Spring.
24
24
 
25
25
  ### Tier 3 — Core (review carefully before merging)
26
26
 
27
- - `src/agents/merger.js` — merger logic. One bad merge = developer loses manual notes = project dies. Changes here need strong justification and full test coverage.
28
- - `src/ast/`AST engine. Wrong extraction = wrong AGENTS.md = AI gets confident with wrong facts. Worse than no AGENTS.md.
27
+ - `src/agents/merger.js` — merger logic. One bad merge = developer loses manual notes = project dies.
28
+ - `src/agents/domains.js`graph-based domain clustering. Wrong clusters = wrong context files.
29
+ - `src/mcp/server.js` — MCP server tools. Breaking changes affect Kiro/Cursor/Claude integration.
29
30
  - `src/detector/` — framework detection logic.
30
31
  - `src/cli/` — CLI commands.
31
32
 
@@ -34,36 +35,46 @@ Wanted: Django, Rails, Laravel, NestJS, Hono, Gin, Spring.
34
35
  ## How to add a language
35
36
 
36
37
  1. Create `src/extractors/languages/yourlanguage.js`
37
- 2. Export a single function: `extractFromFile(filePath, fileContent)`
38
- 3. Return:
38
+ 2. Export a plugin object:
39
39
  ```js
40
- {
41
- functions: [{ name, params, returns }],
42
- classes: [{ name, fields }],
43
- imports: [{ from, symbols }],
44
- exports: [{ name }]
45
- }
40
+ module.exports = {
41
+ name: 'yourlanguage',
42
+ extensions: ['.ext'],
43
+ extract(content, relPath) {
44
+ return {
45
+ routes: [{ method, path, functionName }],
46
+ models: [{ className, fields: [{ name, type }] }],
47
+ functions: [{ name, params, returnType }],
48
+ envVars: ['VAR_NAME'],
49
+ dbTables: [{ tableName, modelName }],
50
+ fetches: [],
51
+ storageKeys: []
52
+ };
53
+ }
54
+ };
46
55
  ```
47
- 4. Add it to `src/extractors/loader.js` language map
48
- 5. Test on at least 3 real open-source projects
49
- 6. Open a PR with before/after AGENTS.md examples
56
+ 3. The loader auto-discovers it — no changes to `loader.js` needed
57
+ 4. Test on at least 3 real open-source projects
58
+ 5. Open a PR with before/after AGENTS.md examples
50
59
 
51
60
  ---
52
61
 
53
62
  ## How to add a framework extractor
54
63
 
55
- 1. Create `src/extractors/yourframework.js`
56
- 2. Export:
64
+ 1. Add detection to `src/detector/framework.js`
65
+ 2. Add route/model patterns to the relevant language plugin or create a new extractor in `src/extractors/`
66
+ 3. Test on at least 2 real projects using that framework
67
+ 4. Open a PR with before/after AGENTS.md examples
68
+
69
+ ---
70
+
71
+ ## How to add a domain keyword
72
+
73
+ Domain clustering lives in `src/agents/domains.js`. The `DOMAIN_MAP` array maps keywords to domain names. If your framework creates a new domain category, add it:
74
+
57
75
  ```js
58
- {
59
- detect(projectRoot, files) → boolean,
60
- extractRoutes(filePath, fileContent) → [{ method, path, functionName }],
61
- extractModels(filePath, fileContent) → [{ name, fields: [{ name, type }] }]
62
- }
76
+ { keywords: ['graphql', 'resolver', 'mutation'], domain: 'GRAPHQL' },
63
77
  ```
64
- 3. Add detection logic to `src/detector/framework.js`
65
- 4. Test on at least 2 real projects using that framework
66
- 5. Open a PR with before/after AGENTS.md examples
67
78
 
68
79
  ---
69
80
 
@@ -72,7 +83,7 @@ Wanted: Django, Rails, Laravel, NestJS, Hono, Gin, Spring.
72
83
  - **Never break the merger.** Manual sections in AGENTS.md are sacred. If your change could corrupt them, it needs a full merger test suite pass.
73
84
  - **Wrong output is worse than no output.** If your extractor produces incorrect routes or models, AI gets confident with wrong facts. Only ship when accurate on real projects.
74
85
  - **Test on unknown repos.** Don't just test on projects you wrote. Find a real open-source repo using the framework and verify the output is correct.
75
- - **No cloud, no telemetry, no tracking.** Carto is local only. Forever. Don't add any network calls.
86
+ - **No cloud, no telemetry, no tracking.** Carto is local only. Forever. Don't add any network calls except the existing npm update check.
76
87
  - **No paid features.** Free forever. MIT. Don't propose monetization.
77
88
 
78
89
  ---
@@ -81,9 +92,11 @@ Wanted: Django, Rails, Laravel, NestJS, Hono, Gin, Spring.
81
92
 
82
93
  ```bash
83
94
  git clone https://github.com/theanshsonkar/carto
84
- cd carto-ansh
95
+ cd carto
85
96
  npm install
86
97
  node src/cli/index.js init # test in any project
98
+ node src/cli/index.js serve # test MCP server
99
+ npm test # run test suite
87
100
  ```
88
101
 
89
102
  ---
@@ -101,8 +114,9 @@ node src/cli/index.js init # test in any project
101
114
 
102
115
  ## Issues
103
116
 
104
- - **Bug**: Open an issue with the project type, command run, and what AGENTS.md produced vs what you expected.
105
- - **Language request**: Open an issue titled "Language: [name]" — someone from the community will pick it up.
106
- - **Framework request**: Open an issue titled "Framework: [name]".
117
+ - **Bug**: Open an issue with the project type, command run, and what AGENTS.md or domain files produced vs what you expected.
118
+ - **Language request**: Open an issue titled "Language: [name]"
119
+ - **Framework request**: Open an issue titled "Framework: [name]"
120
+ - **Domain keyword**: Open an issue titled "Domain: [name]" if your codebase doesn't cluster correctly
107
121
 
108
122
  All issues acknowledged within 24 hours.
package/README.md CHANGED
@@ -4,13 +4,13 @@
4
4
  [![MIT License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/carto-md)](https://www.npmjs.com/package/carto-md)
6
6
 
7
- **Maps your codebase so AI stops guessing. Your code changes. AGENTS.md updates. Every AI always knows.**
7
+ **The codebase intelligence layer every AI tool queries instead of guessing.**
8
8
 
9
9
  ```bash
10
10
  npm install -g carto-md
11
11
  ```
12
12
 
13
- Carto auto-generates and maintains your `AGENTS.md`the standard file every AI coding tool reads for project context. Every time you save, your routes, models, functions, and dependencies are extracted and kept current.
13
+ Carto maps your codebaseroutes, models, import graph, domain context and exposes it as a live MCP server that Kiro, Cursor, and Claude can query mid-task. No hallucinations about your own project. No rebuilding context every session.
14
14
 
15
15
  ---
16
16
 
@@ -19,13 +19,13 @@ Carto auto-generates and maintains your `AGENTS.md` — the standard file every
19
19
  AI coding tools are blind to your actual project. Every session starts from zero.
20
20
 
21
21
  - Claude hallucinates your schema
22
- - Copilot suggests the wrong field names
22
+ - Copilot suggests wrong field names
23
23
  - Kiro asks what framework you're using
24
24
  - You rebuild context manually, every time
25
25
 
26
- `AGENTS.md` fixes this — a file in your project root that every AI tool reads. But it's static. You write it manually. It gets stale the moment your code changes.
26
+ `AGENTS.md` fixes this — a standard file every AI tool reads. But it's static. You write it manually. It gets stale the moment your code changes.
27
27
 
28
- **Carto makes it live.**
28
+ **Carto makes it live. And queryable.**
29
29
 
30
30
  ---
31
31
 
@@ -33,16 +33,15 @@ AI coding tools are blind to your actual project. Every session starts from zero
33
33
 
34
34
  Same task, two Claude sessions: *"Add a `notes` field to the booking model."*
35
35
 
36
- **Without AGENTS.md:**
36
+ **Without Carto:**
37
37
  - Wrong API route: suggested `POST /api/bookings` → actual is `POST /v2/bookings`
38
38
  - Wrong handler: suggested `handleNewBooking.ts` → not the creation path
39
- - Wrong file paths: pointed to v1 API (`apps/api/v1/...`) → v1 is legacy
39
+ - Wrong file paths: pointed to v1 API → v1 is legacy
40
40
  - Wrong tRPC file: `bookings.tsx` → actual is `bookings/_router.tsx`
41
41
  - Field list: ~15 fields guessed → missing 20+ real fields
42
- - Couldn't proceed without follow-up: *"Want me to write the exact diffs once you confirm the codebase location?"*
43
42
 
44
- **With AGENTS.md (generated by Carto):**
45
- - Correct API route: `POST /v2/bookings`
43
+ **With Carto:**
44
+ - Correct API route ✅
46
45
  - Correct controller path ✅
47
46
  - Correct tRPC file ✅
48
47
  - All 35+ booking fields returned accurately ✅
@@ -52,66 +51,146 @@ Same task, two Claude sessions: *"Add a `notes` field to the booking model."*
52
51
 
53
52
  Not smarter AI. The same AI with accurate facts.
54
53
 
55
- *Stress tested on cal.com (5,018 files): 87% route coverage, 100% model field accuracy, import graph with zero phantom links.*
54
+ ---
55
+
56
+ ## How it works
57
+
58
+ ```
59
+ carto init
60
+
61
+ Carto maps your codebase
62
+ → AGENTS.md (79 lines — lean map every AI reads)
63
+ → .carto/context/AUTH.md, PAYMENTS.md, TRPC.md, DATABASE.md
64
+ → .carto/map.json (import graph, routes, blast radius)
65
+ → MCP server auto-wired into Kiro, Cursor, Claude Desktop
66
+
67
+ carto watch (keeps everything live on every file save)
68
+ carto serve (MCP server — AI tools query graph mid-task)
69
+ ```
56
70
 
57
71
  ---
58
72
 
59
- ## Know what breaks before you break it
73
+ ## MCP AI queries your codebase live
74
+
75
+ `carto init` auto-wires the MCP config into Kiro, Cursor, and Claude Desktop automatically. When Kiro or Cursor is mid-task, it can call Carto directly instead of guessing:
60
76
 
61
- Most production bugs aren't logic errors. They're *"I didn't know X depended on Y."*
77
+ **`get_blast_radius("src/lib/payments.ts")`**
78
+ ```
79
+ Files affected:
80
+ → apps/web/app/api/checkout/route.ts
81
+ → apps/web/app/api/webhook/route.ts
82
+ → packages/trpc/routers/billing.ts
83
+
84
+ Routes at risk:
85
+ → POST /api/checkout
86
+ → POST /api/webhook
87
+ → POST /trpc/createSubscription
88
+ ```
62
89
 
63
- `carto impact` makes that invisible knowledge visible — before you touch anything.
90
+ **`get_routes()`**
91
+ ```
92
+ | Method | Path | Handler |
93
+ |--------|-----------------------------|---------------------|
94
+ | POST | /api/auth/signup | POST |
95
+ | GET | /api/auth/oauth/me | GET |
96
+ | POST | /trpc/createBooking | createBooking |
97
+ | GET | /trpc/getAvailability | getAvailability |
98
+ | ... | ... | ... |
99
+ ```
64
100
 
65
- ```bash
66
- carto impact app/models.py
101
+ **`get_domain("AUTH")`**
102
+ Returns `AUTH.md` — all auth routes, session models, JWT functions, env vars.
103
+
104
+ **`get_structure()`**
105
+ Returns import graph, entry points, high impact files, tech stack.
106
+
107
+ ### Manual MCP config (if auto-wire didn't detect your IDE)
108
+
109
+ **Kiro** — add to `~/.kiro/settings/mcp.json`:
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "carto": {
114
+ "command": "carto",
115
+ "args": ["serve"],
116
+ "cwd": "/path/to/your/project"
117
+ }
118
+ }
119
+ }
120
+ ```
67
121
 
68
- # Impact analysis: app/models.py
69
- #
70
- # Imported by:
71
- # → app/main.py
72
- # → app/rules.py
73
- # → app/scoring.py
74
- # → app/aws_collector.py
75
- # → tests/conftest.py
76
- #
77
- # Routes affected:
78
- # → POST /analyze
79
- # → GET /history
80
- # → POST /simulate
81
- # → ... 12 more
82
- #
83
- # Risk: HIGH — 5 files depend on this
122
+ **Cursor** add to `~/.cursor/mcp.json`:
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "carto": {
127
+ "command": "carto",
128
+ "args": ["serve"],
129
+ "cwd": "/path/to/your/project"
130
+ }
131
+ }
132
+ }
84
133
  ```
85
134
 
86
- No AI. No cloud. Runs in under a second. Locally, from your import graph.
135
+ **Claude Desktop** add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "carto": {
140
+ "command": "carto",
141
+ "args": ["serve"],
142
+ "cwd": "/path/to/your/project"
143
+ }
144
+ }
145
+ }
146
+ ```
87
147
 
88
- Make it a habit: before touching any file, run `carto impact` first. 10 seconds. Could save hours.
148
+ Then run `carto serve` in your project directory alongside `carto watch`.
89
149
 
90
150
  ---
91
151
 
92
- ## Why not just paste your code?
152
+ ## Domain context files
93
153
 
94
- Context windows are large now. But pasting code means:
154
+ Large codebases kill AI accuracy. A 2900-line AGENTS.md means AI reads 500 lines and guesses the rest.
95
155
 
96
- - You decide what's relevant — you're often wrong
97
- - AI sees a snapshot, not your live state
98
- - Bigger context ≠ better context
156
+ Carto splits context by domain automatically:
99
157
 
100
- Carto gives AI the map. You give AI the problem. Different jobs.
158
+ ```
159
+ AGENTS.md → 79 lines, always loaded
160
+ .carto/context/
161
+ AUTH.md → auth routes, session models, JWT functions
162
+ PAYMENTS.md → Stripe routes, billing models
163
+ TRPC.md → all tRPC procedures
164
+ DATABASE.md → every model, schema, table
165
+ EVENTS.md → webhooks, queues, cron jobs
166
+ CORE.md → shared utilities
167
+ ```
168
+
169
+ AI reads AGENTS.md always. Then reads only the relevant domain file for the current task. 400 lines of exact context instead of 2900 lines of everything.
170
+
171
+ Domain assignment uses your import graph — files that import each other cluster together, regardless of folder names.
101
172
 
102
173
  ---
103
174
 
104
- ## How it works
175
+ ## Know what breaks before you break it
105
176
 
177
+ ```bash
178
+ carto impact apps/web/app/api/auth/signup/route.ts
179
+
180
+ # Impact analysis: apps/web/app/api/auth/signup/route.ts
181
+ #
182
+ # Imported by:
183
+ # → apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts
184
+ # → apps/web/app/api/auth/signup/handlers/selfHostedHandler.ts
185
+ #
186
+ # Routes at risk:
187
+ # → POST /api/auth/signup
188
+ # → ALL /api/auth/signup/handlers
189
+ #
190
+ # Risk: MEDIUM
106
191
  ```
107
- You save a file
108
-
109
- Carto extracts routes, models, functions, env vars
110
-
111
- AGENTS.md updated in 300ms
112
-
113
- Cursor, Copilot, Kiro, Codex, Claude — all read current truth
114
- ```
192
+
193
+ No AI. No cloud. Runs in under a second. From your live import graph.
115
194
 
116
195
  ---
117
196
 
@@ -121,7 +200,7 @@ Cursor, Copilot, Kiro, Codex, Claude — all read current truth
121
200
  npm install -g carto-md
122
201
  ```
123
202
 
124
- Or run without installing:
203
+ Or without installing:
125
204
 
126
205
  ```bash
127
206
  npx carto-md init
@@ -132,16 +211,18 @@ npx carto-md init
132
211
  ## Usage
133
212
 
134
213
  ```bash
135
- # 1. Go to your project
136
214
  cd your-project
137
-
138
- # 2. Run once — like git init
139
215
  carto init
140
216
  ```
141
217
 
142
- That's it. Carto installs a git hook. Every `git commit` syncs AGENTS.md automatically — no watching, no manual runs, nothing to remember.
218
+ That's it. Carto:
219
+ - Maps your codebase
220
+ - Generates AGENTS.md + domain context files
221
+ - Auto-wires MCP into Kiro, Cursor, Claude Desktop
222
+ - Installs a git hook — syncs on every commit
143
223
 
144
- Want live updates on every file save too? Run `carto watch` in a background terminal.
224
+ Run `carto watch` in background for live updates on every file save.
225
+ Run `carto serve` to start the MCP server manually if needed.
145
226
 
146
227
  ---
147
228
 
@@ -149,19 +230,14 @@ Want live updates on every file save too? Run `carto watch` in a background term
149
230
 
150
231
  | Command | What it does |
151
232
  |---------|-------------|
152
- | `carto init` | Detect stack, generate AGENTS.md, install git hook auto-syncs on every commit |
153
- | `carto watch` | Live updates on every file save — optional, for between commits |
233
+ | `carto init` | Map codebase, generate context files, wire MCP into IDEs |
234
+ | `carto watch` | Live updates on every file save |
154
235
  | `carto sync` | One-time manual refresh |
236
+ | `carto serve` | Start MCP server for Kiro/Cursor/Claude queries |
155
237
  | `carto impact <file>` | Show blast radius before touching a file |
156
238
  | `carto remove` | Remove AGENTS.md and .carto/ from this project |
157
239
  | `carto --version` | Show version |
158
240
 
159
- **When to use each:**
160
- - `init` — once per project, sets everything up
161
- - `watch` — optional, if you want updates between commits
162
- - `sync` — if you skipped watch and need a fresh snapshot
163
- - `impact` — before editing anything critical
164
-
165
241
  ---
166
242
 
167
243
  ## Works with
@@ -170,30 +246,30 @@ Want live updates on every file save too? Run `carto watch` in a background term
170
246
  |----------|------------|
171
247
  | Python | FastAPI, Pydantic |
172
248
  | JavaScript | Express, Next.js |
173
- | TypeScript | Express, Next.js, Prisma |
174
- | R | Plumber, Shiny |
249
+ | TypeScript | Express, Next.js, Prisma, tRPC |
250
+ | R | Plumber, Shiny, R6, S7 |
175
251
  | HTML | fetch() calls |
176
252
 
177
253
  More languages via community — open an issue or see [CONTRIBUTING.md](CONTRIBUTING.md).
178
254
 
179
255
  ---
180
256
 
181
- ## What gets extracted automatically
257
+ ## What gets extracted
182
258
 
183
- - API routes — FastAPI, Express, Next.js App Router
184
- - Data models — Pydantic, Prisma
259
+ - API routes — FastAPI, Express, Next.js App Router, tRPC procedures
260
+ - Data models — Pydantic, Prisma, TypeScript interfaces
185
261
  - Function signatures — across all files
186
- - Dependencies — from `package.json` / `requirements.txt`
187
- - Environment variable names — never values
188
- - Frontend API calls — from `fetch()` patterns
189
262
  - Import graph — which files depend on which
190
- - Database tables
263
+ - Domain clusters — AUTH, PAYMENTS, TRPC, DATABASE, EVENTS
264
+ - Blast radius — what breaks if you change a file
265
+ - Environment variable names — never values
266
+ - Database tables — SQLAlchemy, Django ORM, Prisma
191
267
 
192
268
  ---
193
269
 
194
270
  ## What Carto never touches
195
271
 
196
- Your manual sections — architecture decisions, active bugs, business rules, coding conventions — stay yours forever. Carto only rewrites between its own markers:
272
+ Your manual sections stay yours forever. Carto only rewrites between its own markers:
197
273
 
198
274
  ```
199
275
  <!-- CARTO:AUTO:START -->
@@ -213,6 +289,7 @@ Carto fixes **factual hallucination about your own project**:
213
289
  - AI guessing wrong field names → fixed
214
290
  - AI assuming wrong framework → fixed
215
291
  - AI guessing wrong DB schema → fixed
292
+ - AI not knowing blast radius → fixed
216
293
 
217
294
  What Carto does not fix: AI reasoning badly, wrong implementation logic, misunderstanding what you want. Carto makes AI **accurate** about your project. Not smarter. Accurate. Different thing.
218
295
 
@@ -220,11 +297,11 @@ What Carto does not fix: AI reasoning badly, wrong implementation logic, misunde
220
297
 
221
298
  ## AI tools that read AGENTS.md
222
299
 
223
- Drop the file in your project root. Each tool picks it up via its own context config:
224
-
225
- - **Cursor** — via context rules
300
+ - **Cursor** via context rules + MCP
226
301
  - **GitHub Copilot** — via workspace instructions
227
- - **Kiro** — natively
302
+ - **Kiro** — natively + MCP
303
+ - **Claude Desktop** — via MCP
304
+ - **Claude Code** — natively
228
305
  - **Codex** — natively
229
306
  - **VS Code** — via workspace context
230
307
  - **Gemini CLI** — natively
@@ -273,4 +350,4 @@ MIT — free forever.
273
350
 
274
351
  ---
275
352
 
276
- *Built because AGENTS.md won. Someone had to keep it alive.*
353
+ *Built because AGENTS.md won. Someone had to keep it alive — and make it queryable.*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carto-md",
3
- "version": "1.0.19",
3
+ "version": "1.1.1",
4
4
  "description": "The context layer for AI-native development.",
5
5
  "bin": {
6
6
  "carto": "src/cli/index.js"
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@babel/parser": "^7.29.3",
14
+ "@modelcontextprotocol/sdk": "^1.0.0",
14
15
  "chokidar": "^3.6.0"
15
16
  },
16
17
  "engines": {