carto-md 1.0.10 → 1.0.13
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/LICENSE +21 -0
- package/README.md +91 -85
- package/package.json +1 -1
- package/src/cli/impact.js +9 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ansh Sonkar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -6,21 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
**Your code changes. AGENTS.md updates. Every AI always knows.**
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Origin
|
|
14
|
-
|
|
15
|
-
I was building [Emfirge](https://emfirge.com) — a cloud security advisor for AWS.
|
|
16
|
-
|
|
17
|
-
To make the AI inside Emfirge understand infrastructure, I wrote a module called `cartography.py`. It scanned AWS resources, built a graph of how they connected, and wrote it into a structured map. The AI stopped hallucinating. It worked with accurate facts about the actual infrastructure — not guesses.
|
|
18
|
-
|
|
19
|
-
Halfway through, I switched AI tools. Opened a new session. Had to explain everything again from scratch.
|
|
20
|
-
|
|
21
|
-
I thought: *I just built a cartography system so AI can understand infrastructure. Why doesn't this exist for codebases?*
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g carto-md
|
|
11
|
+
```
|
|
22
12
|
|
|
23
|
-
Carto
|
|
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.
|
|
24
14
|
|
|
25
15
|
---
|
|
26
16
|
|
|
@@ -33,12 +23,70 @@ AI coding tools are blind to your actual project. Every session starts from zero
|
|
|
33
23
|
- Kiro asks what framework you're using
|
|
34
24
|
- You rebuild context manually, every time
|
|
35
25
|
|
|
36
|
-
`AGENTS.md`
|
|
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.
|
|
37
27
|
|
|
38
28
|
**Carto makes it live.**
|
|
39
29
|
|
|
40
30
|
---
|
|
41
31
|
|
|
32
|
+
## Proof — cal.com (800k lines)
|
|
33
|
+
|
|
34
|
+
Same task, two Claude sessions: *"Add a `notes` field to the booking model."*
|
|
35
|
+
|
|
36
|
+
**Without AGENTS.md:**
|
|
37
|
+
- Wrong API route: suggested `POST /api/bookings` → actual is `POST /v2/bookings`
|
|
38
|
+
- Wrong handler: suggested `handleNewBooking.ts` → not the creation path
|
|
39
|
+
- Wrong file paths: pointed to v1 API (`apps/api/v1/...`) → v1 is legacy
|
|
40
|
+
- Wrong tRPC file: `bookings.tsx` → actual is `bookings/_router.tsx`
|
|
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
|
+
|
|
44
|
+
**With AGENTS.md (generated by Carto):**
|
|
45
|
+
- Correct API route: `POST /v2/bookings` ✅
|
|
46
|
+
- Correct controller path ✅
|
|
47
|
+
- Correct tRPC file ✅
|
|
48
|
+
- All 35+ booking fields returned accurately ✅
|
|
49
|
+
- Answered in one shot. No follow-up needed.
|
|
50
|
+
|
|
51
|
+
**4 wrong file paths → 0. 20 missing fields → 0. Zero follow-up clarifications.**
|
|
52
|
+
|
|
53
|
+
Not smarter AI. The same AI with accurate facts.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Know what breaks before you break it
|
|
58
|
+
|
|
59
|
+
Most production bugs aren't logic errors. They're *"I didn't know X depended on Y."*
|
|
60
|
+
|
|
61
|
+
`carto impact` makes that invisible knowledge visible — before you touch anything.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
carto impact app/models.py
|
|
65
|
+
|
|
66
|
+
# Impact analysis: app/models.py
|
|
67
|
+
#
|
|
68
|
+
# Imported by:
|
|
69
|
+
# → app/main.py
|
|
70
|
+
# → app/rules.py
|
|
71
|
+
# → app/scoring.py
|
|
72
|
+
# → app/aws_collector.py
|
|
73
|
+
# → tests/conftest.py
|
|
74
|
+
#
|
|
75
|
+
# Routes affected:
|
|
76
|
+
# → POST /analyze
|
|
77
|
+
# → GET /history
|
|
78
|
+
# → POST /simulate
|
|
79
|
+
# → ... 12 more
|
|
80
|
+
#
|
|
81
|
+
# Risk: HIGH — 5 files depend on this
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
No AI. No cloud. Runs in under a second. Locally, from your import graph.
|
|
85
|
+
|
|
86
|
+
Make it a habit: before touching any file, run `carto impact` first. 10 seconds. Could save hours.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
42
90
|
## Why not just paste your code?
|
|
43
91
|
|
|
44
92
|
Context windows are large now. But pasting code means:
|
|
@@ -109,11 +157,24 @@ Leave `carto watch` running in a background terminal. Every file save updates AG
|
|
|
109
157
|
**When to use each:**
|
|
110
158
|
- `init` — once, when you add Carto to a project
|
|
111
159
|
- `watch` — every work session, leave it running
|
|
112
|
-
- `sync` —
|
|
160
|
+
- `sync` — skipped watch and need a fresh snapshot
|
|
113
161
|
- `impact` — before editing anything critical
|
|
114
162
|
|
|
115
163
|
---
|
|
116
164
|
|
|
165
|
+
## Works with
|
|
166
|
+
|
|
167
|
+
| Language | Frameworks |
|
|
168
|
+
|----------|------------|
|
|
169
|
+
| Python | FastAPI, Pydantic |
|
|
170
|
+
| JavaScript | Express, Next.js |
|
|
171
|
+
| TypeScript | Express, Next.js, Prisma |
|
|
172
|
+
| HTML | fetch() calls |
|
|
173
|
+
|
|
174
|
+
More languages via community — open an issue or see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
117
178
|
## What gets extracted automatically
|
|
118
179
|
|
|
119
180
|
- API routes — FastAPI, Express, Next.js App Router
|
|
@@ -129,7 +190,7 @@ Leave `carto watch` running in a background terminal. Every file save updates AG
|
|
|
129
190
|
|
|
130
191
|
## What Carto never touches
|
|
131
192
|
|
|
132
|
-
|
|
193
|
+
Your manual sections — architecture decisions, active bugs, business rules, coding conventions — stay yours forever. Carto only rewrites between its own markers:
|
|
133
194
|
|
|
134
195
|
```
|
|
135
196
|
<!-- CARTO:AUTO:START -->
|
|
@@ -141,35 +202,6 @@ Your manual notes here. Never touched.
|
|
|
141
202
|
|
|
142
203
|
---
|
|
143
204
|
|
|
144
|
-
## carto impact
|
|
145
|
-
|
|
146
|
-
Before touching any file, know the blast radius:
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
carto impact app/models.py
|
|
150
|
-
|
|
151
|
-
# Impact analysis: app/models.py
|
|
152
|
-
#
|
|
153
|
-
# Imported by:
|
|
154
|
-
# → app/main.py
|
|
155
|
-
# → app/rules.py
|
|
156
|
-
# → app/scoring.py
|
|
157
|
-
# → app/aws_collector.py
|
|
158
|
-
# → tests/conftest.py
|
|
159
|
-
#
|
|
160
|
-
# Routes affected:
|
|
161
|
-
# → POST /analyze
|
|
162
|
-
# → GET /history
|
|
163
|
-
# → POST /simulate
|
|
164
|
-
# → ... 12 more
|
|
165
|
-
#
|
|
166
|
-
# Risk: HIGH — 5 files depend on this
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Most production bugs aren't logic errors. They're *"I didn't know X depended on Y."* Carto makes that invisible knowledge visible before you break something.
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
205
|
## What Carto fixes
|
|
174
206
|
|
|
175
207
|
Carto fixes **factual hallucination about your own project**:
|
|
@@ -183,31 +215,6 @@ What Carto does not fix: AI reasoning badly, wrong implementation logic, misunde
|
|
|
183
215
|
|
|
184
216
|
---
|
|
185
217
|
|
|
186
|
-
## Real test — cal.com (800k lines)
|
|
187
|
-
|
|
188
|
-
We ran the same task in two Claude sessions: *"Add a `notes` field to the booking model."*
|
|
189
|
-
|
|
190
|
-
**Without AGENTS.md:**
|
|
191
|
-
- Wrong API route: suggested `POST /api/bookings` → actual is `POST /v2/bookings`
|
|
192
|
-
- Wrong handler: suggested `handleNewBooking.ts` → not the creation path
|
|
193
|
-
- Wrong file paths: pointed to v1 API (`apps/api/v1/...`) → v1 is legacy
|
|
194
|
-
- Wrong tRPC file: `bookings.tsx` → actual is `bookings/_router.tsx`
|
|
195
|
-
- Field list: ~15 fields guessed → missing 20+ real fields
|
|
196
|
-
- Couldn't proceed without follow-up: *"Want me to write the exact diffs once you confirm the codebase location?"*
|
|
197
|
-
|
|
198
|
-
**With AGENTS.md (generated by Carto):**
|
|
199
|
-
- Correct API route: `POST /v2/bookings` ✅
|
|
200
|
-
- Correct controller path ✅
|
|
201
|
-
- Correct tRPC file ✅
|
|
202
|
-
- All 35+ booking fields returned accurately ✅
|
|
203
|
-
- Answered in one shot. No follow-up needed.
|
|
204
|
-
|
|
205
|
-
**4 wrong file paths → 0. 20 missing fields → 0. Zero follow-up clarifications.**
|
|
206
|
-
|
|
207
|
-
This is what Carto does. Not smarter AI. The same AI with accurate facts.
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
218
|
## AI tools that read AGENTS.md
|
|
212
219
|
|
|
213
220
|
Drop the file in your project root. Each tool picks it up via its own context config:
|
|
@@ -223,16 +230,6 @@ Drop the file in your project root. Each tool picks it up via its own context co
|
|
|
223
230
|
|
|
224
231
|
---
|
|
225
232
|
|
|
226
|
-
## Tested on
|
|
227
|
-
|
|
228
|
-
- FastAPI + Python projects
|
|
229
|
-
- Next.js App Router
|
|
230
|
-
- Next.js + Prisma
|
|
231
|
-
- React + FastAPI monorepos
|
|
232
|
-
- Large monorepos (5000+ files — tested on Supabase and cal.com for stability, caps at 50 most important files on projects this scale)
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
233
|
## What it does NOT do
|
|
237
234
|
|
|
238
235
|
- No cloud. No servers. No telemetry. No tracking.
|
|
@@ -249,12 +246,21 @@ Carto never writes secrets into AGENTS.md. `.cartoignore` blocks `.env` files, s
|
|
|
249
246
|
|
|
250
247
|
## Contributing
|
|
251
248
|
|
|
252
|
-
Python and JS/TS
|
|
249
|
+
Python and JS/TS today. Want Go, Ruby, Django, Rails? Open an issue — or read [CONTRIBUTING.md](CONTRIBUTING.md) to add it yourself.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Origin
|
|
254
|
+
|
|
255
|
+
I was building [Emfirge](https://emfirge.cloud) — a cloud security agent for AWS.
|
|
253
256
|
|
|
254
|
-
|
|
255
|
-
|
|
257
|
+
To make the AI inside Emfirge understand infrastructure, I wrote a module called `cartography.py`. It mapped AWS resources, built a graph of how they connected, and wrote it into a structured map. The AI stopped hallucinating. It worked with accurate facts — not guesses.
|
|
258
|
+
|
|
259
|
+
Halfway through, I switched AI tools. Opened a new session. Had to explain everything again from scratch.
|
|
260
|
+
|
|
261
|
+
I thought: *I just built a cartography system so AI can understand infrastructure. Why doesn't this exist for codebases?*
|
|
256
262
|
|
|
257
|
-
|
|
263
|
+
Carto is that. Same insight, different domain.
|
|
258
264
|
|
|
259
265
|
---
|
|
260
266
|
|
package/package.json
CHANGED
package/src/cli/impact.js
CHANGED
|
@@ -137,7 +137,6 @@ function run(projectRoot, fileArg) {
|
|
|
137
137
|
* Matches by basename or partial path suffix.
|
|
138
138
|
*/
|
|
139
139
|
function resolveFile(fileArg, imports) {
|
|
140
|
-
// Collect all known files (keys + all values)
|
|
141
140
|
const allFiles = new Set();
|
|
142
141
|
for (const [file, deps] of Object.entries(imports)) {
|
|
143
142
|
allFiles.add(file);
|
|
@@ -145,6 +144,7 @@ function resolveFile(fileArg, imports) {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
const normalized = fileArg.replace(/\\/g, '/');
|
|
147
|
+
const hasPathSeparator = normalized.includes('/');
|
|
148
148
|
|
|
149
149
|
// Exact match
|
|
150
150
|
if (allFiles.has(normalized)) return normalized;
|
|
@@ -153,16 +153,17 @@ function resolveFile(fileArg, imports) {
|
|
|
153
153
|
const matches = [...allFiles].filter(f => f.endsWith('/' + normalized) || f === normalized);
|
|
154
154
|
if (matches.length === 1) return matches[0];
|
|
155
155
|
|
|
156
|
-
//
|
|
156
|
+
// If input was a path (contains /), don't fall back to basename — it's ambiguous
|
|
157
|
+
if (hasPathSeparator) {
|
|
158
|
+
if (matches.length > 1) return null;
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Input is just a filename — fall back to basename matching
|
|
157
163
|
const byBasename = [...allFiles].filter(f => path.basename(f) === path.basename(normalized));
|
|
158
164
|
if (byBasename.length === 1) return byBasename[0];
|
|
159
165
|
|
|
160
|
-
//
|
|
161
|
-
if (byBasename.length > 1) {
|
|
162
|
-
byBasename.sort((a, b) => a.length - b.length);
|
|
163
|
-
return byBasename[0];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
+
// Multiple basename matches — ambiguous, don't guess
|
|
166
167
|
return null;
|
|
167
168
|
}
|
|
168
169
|
|