cartotree 0.2.0 → 0.2.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.
@@ -1,11 +1,11 @@
1
- {
2
- "name": "cartotree",
3
- "owner": { "name": "kingluminance" },
4
- "plugins": [
5
- {
6
- "name": "cartotree",
7
- "source": "./",
8
- "description": "Find the right files with few tokens: locate / peek / links MCP tools + a navigation skill."
9
- }
10
- ]
11
- }
1
+ {
2
+ "name": "cartotree",
3
+ "owner": { "name": "kingluminance" },
4
+ "plugins": [
5
+ {
6
+ "name": "cartotree",
7
+ "source": "./",
8
+ "description": "Find the right files with few tokens: locate / peek / links MCP tools + a navigation skill."
9
+ }
10
+ ]
11
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "name": "cartotree",
3
- "version": "0.2.0",
4
- "description": "Find the right files with few tokens: local index for locate / peek / links, as MCP tools + a skill.",
5
- "author": { "name": "kingluminance" },
6
- "repository": "https://github.com/kingluminance/cartotree",
7
- "license": "MIT",
8
- "keywords": ["navigation", "search", "tokens", "codebase", "mcp"],
9
- "mcpServers": {
10
- "cartotree": { "command": "npx", "args": ["-y", "cartotree@latest", "mcp"] }
11
- }
12
- }
1
+ {
2
+ "name": "cartotree",
3
+ "version": "0.2.0",
4
+ "description": "Find the right files with few tokens: local index for locate / peek / links, as MCP tools + a skill.",
5
+ "author": { "name": "kingluminance" },
6
+ "repository": "https://github.com/kingluminance/cartotree",
7
+ "license": "MIT",
8
+ "keywords": ["navigation", "search", "tokens", "codebase", "mcp"],
9
+ "mcpServers": {
10
+ "cartotree": { "command": "npx", "args": ["-y", "cartotree@latest", "mcp"] }
11
+ }
12
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Lumina
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
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lumina
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
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,246 +1,270 @@
1
- # 🌲 cartotree
2
-
3
- > AI-friendly codebase mapping CLI — annotated directory trees that save tokens, not just space.
4
-
5
- [![npm version](https://img.shields.io/npm/v/cartotree)](https://www.npmjs.com/package/cartotree)
6
- [![license](https://img.shields.io/npm/l/cartotree)](./LICENSE)
7
-
8
- ---
9
-
10
- ## The Problem
11
-
12
- When you paste your project structure into an AI assistant, two things happen:
13
-
14
- 1. **Token waste** — Raw `tree` output burns hundreds of tokens on ASCII box characters with zero semantic value.
15
- 2. **Hallucination** — AI has no idea what each folder *does*, so it guesses wrong.
16
-
17
- ## The Solution
18
-
19
- cartotree generates a compact, annotated map of your codebase — folder descriptions, exported functions, and an AI-optimized serialization format that fits your architecture into a fraction of the tokens.
20
-
21
- ---
22
-
23
- ## Quick Start
24
-
25
- ```bash
26
- npx cartotree
27
- ```
28
-
29
- No install required.
30
-
31
- ---
32
-
33
- ## Output Formats
34
-
35
- ### Default — Annotated ASCII Tree
36
- ```
37
- my-app/
38
- ├── src/ # Core application source
39
- │ ├── components/ # Reusable UI components
40
- │ │ ├── Button.tsx <Button, ButtonProps>
41
- │ │ └── Modal.tsx <Modal, useModal>
42
- │ ├── hooks/
43
- │ │ └── useAuth.ts <useAuth, useUser>
44
- │ └── services/
45
- │ └── api.ts <fetchUser, postData>
46
- └── package.json
47
- ```
48
-
49
- ### `--ai` — Token-Optimized Serialization
50
- ```
51
- # cartotree fmt: name{desc}[children]<exports>
52
- my-app{Core application source}[src{Core application source}[components{Reusable UI components}[Button.tsx<Button,ButtonProps>,Modal.tsx<Modal,useModal>],hooks[useAuth.ts<useAuth,useUser>],services[api.ts<fetchUser,postData>]],package.json]
53
- ```
54
-
55
- ### `--json` — JSON Format
56
- ```json
57
- {
58
- "my-app": {
59
- "src": {
60
- "_desc": "Core application source",
61
- "components": {
62
- "Button.tsx": ["Button", "ButtonProps"],
63
- "Modal.tsx": ["Modal", "useModal"]
64
- }
65
- }
66
- }
67
- }
68
- ```
69
-
70
- ---
71
-
72
- ## Usage
73
-
74
- ```bash
75
- # Default annotated ASCII tree
76
- npx cartotree
77
-
78
- # AI-optimized single-line serialization
79
- npx cartotree --ai
80
-
81
- # JSON format
82
- npx cartotree --json
83
-
84
- # Copy to clipboard (paste directly into AI)
85
- npx cartotree --ai --copy
86
-
87
- # Sync into CLAUDE.md / AGENTS.md
88
- npx cartotree --ai --sync
89
-
90
- # Sync into custom file
91
- npx cartotree --sync .cursorrules
92
-
93
- # Limit depth
94
- npx cartotree --depth 2
95
-
96
- # No depth limit
97
- npx cartotree --full
98
-
99
- # Exclude patterns
100
- npx cartotree --exclude "tests,*.log"
101
-
102
- # Disable export parsing
103
- npx cartotree --no-exports
104
- ```
105
-
106
- ---
107
-
108
- ## Options
109
-
110
- | Option | Default | Description |
111
- |--------|---------|-------------|
112
- | `--ai` | false | AI-optimized compact serialization |
113
- | `--json` | false | JSON format |
114
- | `--copy` | false | Copy output to clipboard |
115
- | `--sync [file]` | CLAUDE.md | Inject into AI config file |
116
- | `--depth <n>` | 3 | Max traversal depth |
117
- | `--full` | false | No depth limit |
118
- | `--exclude <patterns>` | — | Comma-separated exclude patterns |
119
- | `--no-exports` | false | Disable export parsing |
120
-
121
- ---
122
-
123
- ## Configuration
124
-
125
- Create `.cartotreerc` in your project root to set persistent defaults:
126
-
127
- ```json
128
- {
129
- "default": {
130
- "ai": true,
131
- "exports": false,
132
- "depth": 3
133
- }
134
- }
135
- ```
136
-
137
- Now `npx cartotree` automatically runs with `--ai --no-exports`.
138
-
139
- ---
140
-
141
- ## Folder Annotations
142
-
143
- Add a `.folder.md` to any directory — the first line becomes the annotation:
144
-
145
- ```
146
- # Reusable UI components
147
- Atomic design system built with Radix UI primitives.
148
- ```
149
-
150
- cartotree also falls back to the first line of `README.md` if no `.folder.md` exists.
151
-
152
- ---
153
-
154
- ## Ignoring Files
155
-
156
- Create `.cartotreeignore` in your project root:
157
-
158
- ```
159
- # .cartotreeignore
160
- *.log
161
- temp
162
- coverage
163
- .env*
164
- ```
165
-
166
- `node_modules`, `.git`, `dist`, `build` are excluded by default.
167
-
168
- ---
169
-
170
- ## `--sync` Integration
171
-
172
- Running `cartotree --sync` injects the tree between marker tags:
173
-
174
- ```html
175
- <!-- CARTOTREE-START -->
176
- (auto-updated on every sync)
177
- <!-- CARTOTREE-END -->
178
- ```
179
-
180
- Works with `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, or any file.
181
-
182
- ---
183
-
184
- ## Export Parsing
185
-
186
- cartotree reads your source files and surfaces exported symbols directly in the tree:
187
-
188
- ```
189
- hooks/
190
- └── useAuth.ts <useAuth, useUser, AuthProvider>
191
- ```
192
-
193
- Supports `.js`, `.ts`, `.jsx`, `.tsx`, `.mjs`, `.cjs`.
194
-
195
- ---
196
-
197
- ## License
198
- MIT
199
-
200
- ---
201
-
202
- ## For AI agents: locate · peek · links
203
-
204
- cartotree also works as a navigation layer for coding agents (Claude Code, Cursor, Codex…):
205
- it keeps a local index so the agent finds the right files **without dumping grep output or whole files** into context.
206
-
207
- ```bash
208
- npx cartotree locate "abort JSONL stream on httpBatchStreamLink unsubscribe" # which files to open first
209
- npx cartotree peek packages/client/src/links/httpBatchStreamLink.ts abort unsubscribe # only the matching lines
210
- npx cartotree links httpBatchStreamLink # where a symbol is defined and called
211
- npx cartotree links src/foo.ts # imports, importers, files usually changed with it (git)
212
- ```
213
-
214
- ### Set it up so your agent uses it automatically
215
-
216
- ```bash
217
- npx cartotree init # skill + MCP server + SessionStart reminder (shows every change)
218
- npx cartotree init --dry-run # preview only
219
- ```
220
-
221
- Or as a Claude Code plugin:
222
-
223
- ```bash
224
- claude plugin marketplace add kingluminance/cartotree
225
- claude plugin install cartotree@cartotree
226
- ```
227
-
228
- The MCP server (`npx cartotree mcp`) exposes `cartotree_locate`, `cartotree_peek` and `cartotree_links`.
229
- After the first call the index stays in memory (~10 ms per lookup). An on-disk cache in `.cartotree/` is keyed by git HEAD and your uncommitted changes.
230
-
231
- ### How locate ranks files
232
-
233
- BM25F over four fields of every source file: path words, exported names, code identifiers (scored per function so one matching function is not diluted by a long file) and **past commit messages that touched the file**. Plus light stemming, an import-neighbor boost, 1–2 evidence lines per result, a warning when the top results are close, and "usually changes with" from git co-change history. No LLM, no network.
234
-
235
- ### Benchmark
236
-
237
- [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (21,632 files), 30 real commit messages → "which files were changed?", Claude Haiku agent, compared with the same agent using only ls/find/grep:
238
-
239
- | | grep only | cartotree (fast mode) |
240
- |---|---|---|
241
- | right file in top 3 | 13.5 / 15 | 14 / 15 |
242
- | tool-output tokens | ~37k | ~7.5k (**−80%**) |
243
- | total agent tokens | ~153k | ~100k (**−35%**) |
244
- | time | ~130 s | ~45 s (**−66%**) |
245
-
246
- Accuracy is on par with grep (±1 question across runs); the gain is cost and speed. Git history was cut off before the test commits to avoid leakage.
1
+ # 🌲 cartotree
2
+
3
+ > Tell your coding agent which files to open first. Fewer grep calls, fewer tokens, same answers.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/cartotree)](https://www.npmjs.com/package/cartotree)
6
+ [![license](https://img.shields.io/npm/l/cartotree)](./LICENSE)
7
+
8
+ Ask an agent "why does this bug happen?" and it usually runs grep dozens of times and reads whole files before it finds where to look. cartotree keeps a local index of your repo and answers that first question directly: a ranked list of files with the matching lines as evidence. Works with Claude Code, Cursor, Codex and anything that speaks MCP.
9
+
10
+ ```bash
11
+ npx cartotree init # installs a skill + MCP server for your agent (shows every change, --dry-run to preview)
12
+ ```
13
+
14
+ ---
15
+
16
+ ## What the agent gets
17
+
18
+ Three commands, each returning a few lines instead of a wall of grep output:
19
+
20
+ ```bash
21
+ npx cartotree locate "abort JSONL stream on httpBatchStreamLink unsubscribe" # which files to open first
22
+ npx cartotree peek packages/client/src/links/httpBatchStreamLink.ts abort unsubscribe # only the matching lines
23
+ npx cartotree links httpBatchStreamLink # where a symbol is defined and called
24
+ npx cartotree links src/foo.ts # imports, importers, files usually changed with it (git)
25
+ ```
26
+
27
+ ## Setup
28
+
29
+ ```bash
30
+ npx cartotree init # skill + MCP server + SessionStart reminder (shows every change)
31
+ npx cartotree init --dry-run # preview only
32
+ ```
33
+
34
+ Or as a Claude Code plugin:
35
+
36
+ ```bash
37
+ claude plugin marketplace add kingluminance/cartotree
38
+ claude plugin install cartotree@cartotree
39
+ ```
40
+
41
+ The MCP server (`npx cartotree mcp`) exposes `cartotree_locate`, `cartotree_peek` and `cartotree_links`.
42
+ After the first call the index stays in memory (~10 ms per lookup). An on-disk cache in `.cartotree/` is keyed by git HEAD and your uncommitted changes.
43
+
44
+ ## How locate ranks files
45
+
46
+ BM25F over four fields of every source file: path words, exported names, code identifiers (scored per function so one matching function is not diluted by a long file) and **past commit messages that touched the file**. Plus light stemming, an import-neighbor boost, 1–2 evidence lines per result, a warning when the top results are close, and "usually changes with" from git co-change history. No LLM, no network.
47
+
48
+ ---
49
+
50
+ ## Benchmark
51
+
52
+ [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (21,632 files). Questions are real commit messages ("which files were changed?"), answered by a Claude Haiku agent with cartotree vs. the same agent with only ls/find/grep. Each setup was run twice and averaged. Git history was cut off before the test commits so the tool cannot see the answers.
53
+
54
+ **Fast mode, 15 questions** (default)
55
+
56
+ | | grep only | cartotree |
57
+ |---|---|---|
58
+ | right file in top 3 | 13.5 / 15 | 14 / 15 |
59
+ | right file ranked 1st | 12 / 15 | 11 / 15 |
60
+ | tool-output tokens | ~37k | ~7.5k (**−80%**) |
61
+ | total agent tokens | ~153k | ~100k (**−35%**) |
62
+ | time | ~130 s | ~45 s (**−66%**) |
63
+
64
+ **Careful mode, 30 questions** (agent verifies with `peek` before answering)
65
+
66
+ | | grep only | cartotree |
67
+ |---|---|---|
68
+ | right file ranked 1st | 22 / 30 | 22.5 / 30 |
69
+ | right file in top 3 | 25.5 / 30 | 24.5 / 30 |
70
+ | tool-output tokens | baseline | **−63%** |
71
+ | time | baseline | **−17%** |
72
+
73
+ Accuracy is on par with grep (within ±1.5 questions); the gain is cost and speed. One thing we tried and reverted: telling the agent to "answer immediately when confident" made it list fewer candidates and lowered top-3 accuracy.
74
+
75
+ ---
76
+
77
+ ## Annotated directory trees
78
+
79
+ The original cartotree command still works: a compact, annotated map of your codebase to paste into any AI chat.
80
+
81
+ ### The problem it started with
82
+
83
+ When you paste your project structure into an AI assistant, two things happen:
84
+
85
+ 1. **Token waste** — Raw `tree` output burns hundreds of tokens on ASCII box characters with zero semantic value.
86
+ 2. **Hallucination** — AI has no idea what each folder *does*, so it guesses wrong.
87
+
88
+ ### The Solution
89
+
90
+ cartotree generates a compact, annotated map of your codebase — folder descriptions, exported functions, and an AI-optimized serialization format that fits your architecture into a fraction of the tokens.
91
+
92
+ ---
93
+
94
+ ### Quick Start
95
+
96
+ ```bash
97
+ npx cartotree
98
+ ```
99
+
100
+ No install required.
101
+
102
+ ---
103
+
104
+ ### Output Formats
105
+
106
+ ### Default — Annotated ASCII Tree
107
+ ```
108
+ my-app/
109
+ ├── src/ # Core application source
110
+ │ ├── components/ # Reusable UI components
111
+ │ │ ├── Button.tsx <Button, ButtonProps>
112
+ │ │ └── Modal.tsx <Modal, useModal>
113
+ │ ├── hooks/
114
+ │ │ └── useAuth.ts <useAuth, useUser>
115
+ │ └── services/
116
+ │ └── api.ts <fetchUser, postData>
117
+ └── package.json
118
+ ```
119
+
120
+ ### `--ai` — Token-Optimized Serialization
121
+ ```
122
+ # cartotree fmt: name{desc}[children]<exports>
123
+ my-app{Core application source}[src{Core application source}[components{Reusable UI components}[Button.tsx<Button,ButtonProps>,Modal.tsx<Modal,useModal>],hooks[useAuth.ts<useAuth,useUser>],services[api.ts<fetchUser,postData>]],package.json]
124
+ ```
125
+
126
+ ### `--json` — JSON Format
127
+ ```json
128
+ {
129
+ "my-app": {
130
+ "src": {
131
+ "_desc": "Core application source",
132
+ "components": {
133
+ "Button.tsx": ["Button", "ButtonProps"],
134
+ "Modal.tsx": ["Modal", "useModal"]
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ ---
142
+
143
+ ### Usage
144
+
145
+ ```bash
146
+ # Default annotated ASCII tree
147
+ npx cartotree
148
+
149
+ # AI-optimized single-line serialization
150
+ npx cartotree --ai
151
+
152
+ # JSON format
153
+ npx cartotree --json
154
+
155
+ # Copy to clipboard (paste directly into AI)
156
+ npx cartotree --ai --copy
157
+
158
+ # Sync into CLAUDE.md / AGENTS.md
159
+ npx cartotree --ai --sync
160
+
161
+ # Sync into custom file
162
+ npx cartotree --sync .cursorrules
163
+
164
+ # Limit depth
165
+ npx cartotree --depth 2
166
+
167
+ # No depth limit
168
+ npx cartotree --full
169
+
170
+ # Exclude patterns
171
+ npx cartotree --exclude "tests,*.log"
172
+
173
+ # Disable export parsing
174
+ npx cartotree --no-exports
175
+ ```
176
+
177
+ ---
178
+
179
+ ### Options
180
+
181
+ | Option | Default | Description |
182
+ |--------|---------|-------------|
183
+ | `--ai` | false | AI-optimized compact serialization |
184
+ | `--json` | false | JSON format |
185
+ | `--copy` | false | Copy output to clipboard |
186
+ | `--sync [file]` | CLAUDE.md | Inject into AI config file |
187
+ | `--depth <n>` | 3 | Max traversal depth |
188
+ | `--full` | false | No depth limit |
189
+ | `--exclude <patterns>` | — | Comma-separated exclude patterns |
190
+ | `--no-exports` | false | Disable export parsing |
191
+
192
+ ---
193
+
194
+ ### Configuration
195
+
196
+ Create `.cartotreerc` in your project root to set persistent defaults:
197
+
198
+ ```json
199
+ {
200
+ "default": {
201
+ "ai": true,
202
+ "exports": false,
203
+ "depth": 3
204
+ }
205
+ }
206
+ ```
207
+
208
+ Now `npx cartotree` automatically runs with `--ai --no-exports`.
209
+
210
+ ---
211
+
212
+ ### Folder Annotations
213
+
214
+ Add a `.folder.md` to any directory — the first line becomes the annotation:
215
+
216
+ ```
217
+ # Reusable UI components
218
+ Atomic design system built with Radix UI primitives.
219
+ ```
220
+
221
+ cartotree also falls back to the first line of `README.md` if no `.folder.md` exists.
222
+
223
+ ---
224
+
225
+ ### Ignoring Files
226
+
227
+ Create `.cartotreeignore` in your project root:
228
+
229
+ ```
230
+ # .cartotreeignore
231
+ *.log
232
+ temp
233
+ coverage
234
+ .env*
235
+ ```
236
+
237
+ `node_modules`, `.git`, `dist`, `build` are excluded by default.
238
+
239
+ ---
240
+
241
+ ### `--sync` Integration
242
+
243
+ Running `cartotree --sync` injects the tree between marker tags:
244
+
245
+ ```html
246
+ <!-- CARTOTREE-START -->
247
+ (auto-updated on every sync)
248
+ <!-- CARTOTREE-END -->
249
+ ```
250
+
251
+ Works with `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, or any file.
252
+
253
+ ---
254
+
255
+ ### Export Parsing
256
+
257
+ cartotree reads your source files and surfaces exported symbols directly in the tree:
258
+
259
+ ```
260
+ hooks/
261
+ └── useAuth.ts <useAuth, useUser, AuthProvider>
262
+ ```
263
+
264
+ Supports `.js`, `.ts`, `.jsx`, `.tsx`, `.mjs`, `.cjs`.
265
+
266
+ ---
267
+
268
+ ## License
269
+
270
+ MIT