ctx-pilot 0.9.0 → 0.9.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 +244 -75
- package/dist/cli.js +193 -123
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +0 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.d.ts +3 -6
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +2 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/indexer/index.d.ts +3 -4
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +32 -87
- package/dist/indexer/index.js.map +1 -1
- package/dist/search/fuzzy.d.ts +30 -0
- package/dist/search/fuzzy.d.ts.map +1 -0
- package/dist/search/fuzzy.js +93 -0
- package/dist/search/fuzzy.js.map +1 -0
- package/dist/search/index.d.ts +0 -1
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +47 -36
- package/dist/search/index.js.map +1 -1
- package/dist/search/intent.d.ts +25 -0
- package/dist/search/intent.d.ts.map +1 -0
- package/dist/search/intent.js +206 -0
- package/dist/search/intent.js.map +1 -0
- package/dist/search/keywords.d.ts +1 -0
- package/dist/search/keywords.d.ts.map +1 -1
- package/dist/search/keywords.js +10 -2
- package/dist/search/keywords.js.map +1 -1
- package/dist/search/stemmer.d.ts +4 -0
- package/dist/search/stemmer.d.ts.map +1 -0
- package/dist/search/stemmer.js +226 -0
- package/dist/search/stemmer.js.map +1 -0
- package/dist/types.d.ts +27 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +108 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Sound familiar? Context gets lost. You repeat yourself. Momentum dies.
|
|
|
23
23
|
|
|
24
24
|
## The Solution
|
|
25
25
|
|
|
26
|
-
ctx-pilot
|
|
26
|
+
ctx-pilot suggests relevant files when you need them. Claude reads them and stays informed.
|
|
27
27
|
|
|
28
28
|
```
|
|
29
29
|
You: "Update the Widget component"
|
|
@@ -51,6 +51,9 @@ Claude: "I'll update the Widget component. Based on the props defined in
|
|
|
51
51
|
|
|
52
52
|
- **File suggestions, not content injection** - Claude reads files itself, keeping you in control
|
|
53
53
|
- **Section-aware indexing** - Points to specific functions and headers, not entire files
|
|
54
|
+
- **Smart search** - Stemming and fuzzy matching find what you mean, not just what you type
|
|
55
|
+
- **Smart skip** - Stays silent when there's nothing useful to add
|
|
56
|
+
- **Automatic indexing** - Built-in parsers for 20+ languages, no AI required
|
|
54
57
|
- **Works offline** - Everything runs locally, no API keys or accounts needed
|
|
55
58
|
- **Graceful degradation** - If something breaks, your AI tool works exactly as before
|
|
56
59
|
|
|
@@ -59,16 +62,21 @@ Claude: "I'll update the Widget component. Based on the props defined in
|
|
|
59
62
|
## Quick Start
|
|
60
63
|
|
|
61
64
|
```bash
|
|
62
|
-
# Install
|
|
63
|
-
npm install -g ctx-pilot
|
|
64
|
-
|
|
65
|
-
# Set up in your project
|
|
66
65
|
npx ctx-pilot init
|
|
66
|
+
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Restart your AI CLI, then ask:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Follow the instructions in .context/optimize.md
|
|
69
72
|
```
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
Your AI analyzes your codebase and builds an optimized index. Done - ctx-pilot now suggests relevant files before every prompt.
|
|
75
|
+
|
|
76
|
+
**Alternative (instant setup):** If you want to skip the AI step:
|
|
77
|
+
```bash
|
|
78
|
+
npx ctx-pilot auto-index
|
|
79
|
+
```
|
|
72
80
|
|
|
73
81
|
---
|
|
74
82
|
|
|
@@ -106,29 +114,17 @@ All invisible. All automatic. No commands to remember.
|
|
|
106
114
|
npx ctx-pilot init
|
|
107
115
|
```
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
Restart your AI CLI, then ask: `Follow the instructions in .context/optimize.md`
|
|
110
118
|
|
|
111
|
-
|
|
119
|
+
Your AI builds an optimized, section-aware index of your codebase.
|
|
112
120
|
|
|
113
|
-
### Manual
|
|
121
|
+
### Manual Hook Install
|
|
114
122
|
|
|
115
|
-
If you
|
|
123
|
+
If you need to install the hook separately:
|
|
116
124
|
|
|
117
125
|
```bash
|
|
118
|
-
#
|
|
119
|
-
|
|
120
|
-
"pinned": ["docs/core-concepts.md"],
|
|
121
|
-
"include": ["**/*.md", "**/*.ts"],
|
|
122
|
-
"exclude": []
|
|
123
|
-
}' > .context/config.json
|
|
124
|
-
|
|
125
|
-
# 2. Build index
|
|
126
|
-
npx ctx-pilot index
|
|
127
|
-
|
|
128
|
-
# 3. Install hook
|
|
129
|
-
npx ctx-pilot hook
|
|
130
|
-
|
|
131
|
-
# 4. Restart Claude Code
|
|
126
|
+
npx ctx-pilot hook --claude # For Claude Code
|
|
127
|
+
npx ctx-pilot hook --gemini # For Gemini CLI
|
|
132
128
|
```
|
|
133
129
|
|
|
134
130
|
---
|
|
@@ -141,9 +137,7 @@ Edit `.context/config.json`:
|
|
|
141
137
|
{
|
|
142
138
|
"pinned": ["docs/core-concepts.md", "docs/glossary.md"],
|
|
143
139
|
"include": ["**/*.md", "**/*.ts", "**/*.py"],
|
|
144
|
-
"exclude": ["node_modules/**", "dist/**"]
|
|
145
|
-
"tokenBudget": 32000,
|
|
146
|
-
"maxContextPercentage": 50
|
|
140
|
+
"exclude": ["node_modules/**", "dist/**"]
|
|
147
141
|
}
|
|
148
142
|
```
|
|
149
143
|
|
|
@@ -152,22 +146,156 @@ Edit `.context/config.json`:
|
|
|
152
146
|
| `pinned` | Files suggested on every prompt (your core docs) |
|
|
153
147
|
| `include` | What to index (glob patterns) |
|
|
154
148
|
| `exclude` | What to skip |
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Customizing for Your Project
|
|
153
|
+
|
|
154
|
+
The default config indexes markdown files only. Here's how to tailor ctx-pilot to your codebase.
|
|
155
|
+
|
|
156
|
+
### Step 1: Decide What to Index
|
|
157
|
+
|
|
158
|
+
Think about what files contain useful context:
|
|
159
|
+
|
|
160
|
+
- **Source code** - Functions, classes, components
|
|
161
|
+
- **Documentation** - READMEs, guides, API docs
|
|
162
|
+
- **Tests** - Show expected behavior and edge cases
|
|
163
|
+
- **Config files** - Project structure and settings
|
|
164
|
+
|
|
165
|
+
Update your `include` patterns:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"include": [
|
|
170
|
+
"**/*.md",
|
|
171
|
+
"src/**/*.ts",
|
|
172
|
+
"tests/**/*.ts"
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Common patterns:
|
|
178
|
+
- `**/*.md` - All markdown files
|
|
179
|
+
- `src/**/*.ts` - TypeScript in src folder
|
|
180
|
+
- `docs/**/*` - Everything in docs folder
|
|
181
|
+
- `*.json` - JSON files in root only
|
|
182
|
+
|
|
183
|
+
### Step 2: Exclude Noise
|
|
184
|
+
|
|
185
|
+
Keep generated files and dependencies out:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"exclude": [
|
|
190
|
+
"node_modules/**",
|
|
191
|
+
"dist/**",
|
|
192
|
+
"build/**",
|
|
193
|
+
"coverage/**",
|
|
194
|
+
"*.min.js"
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Step 3: Pin Your Core Docs
|
|
200
|
+
|
|
201
|
+
Pinned files appear in every suggestion. Use sparingly - these are your "always relevant" files:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"pinned": [
|
|
206
|
+
"CLAUDE.md",
|
|
207
|
+
"docs/architecture.md"
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Good candidates:
|
|
213
|
+
- Project overview docs
|
|
214
|
+
- Architecture decisions
|
|
215
|
+
- Coding conventions
|
|
216
|
+
- Glossaries
|
|
217
|
+
|
|
218
|
+
### Step 4: Build the Index
|
|
219
|
+
|
|
220
|
+
Ask your AI to build the index:
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
Follow the instructions in .context/optimize.md
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Your AI analyzes your codebase and creates a section-aware index with:
|
|
227
|
+
- Meaningful section titles
|
|
228
|
+
- Rich keywords including synonyms
|
|
229
|
+
- Descriptive previews explaining what code does
|
|
230
|
+
|
|
231
|
+
**Alternative (quick baseline):** For instant setup without AI:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npx ctx-pilot auto-index
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This uses built-in parsers to extract functions, classes, and headers. Works immediately but produces more generic results.
|
|
238
|
+
|
|
239
|
+
### Advanced: Domain Stopwords
|
|
240
|
+
|
|
241
|
+
If certain words appear everywhere in your project and aren't useful for search, filter them out:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"pinned": ["CLAUDE.md"],
|
|
246
|
+
"include": ["**/*.md", "src/**/*.ts"],
|
|
247
|
+
"exclude": ["node_modules/**"],
|
|
248
|
+
"domainStopwords": ["myapp", "widget", "util"]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Use this when common project terms are drowning out more specific matches.
|
|
253
|
+
|
|
254
|
+
### Example: Full Config
|
|
255
|
+
|
|
256
|
+
Here's a complete config for a TypeScript project:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"pinned": ["CLAUDE.md", "docs/architecture.md"],
|
|
261
|
+
"include": [
|
|
262
|
+
"**/*.md",
|
|
263
|
+
"src/**/*.ts",
|
|
264
|
+
"tests/**/*.ts"
|
|
265
|
+
],
|
|
266
|
+
"exclude": [
|
|
267
|
+
"node_modules/**",
|
|
268
|
+
"dist/**",
|
|
269
|
+
"coverage/**"
|
|
270
|
+
],
|
|
271
|
+
"domainStopwords": ["myproject"]
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
After saving, rebuild and verify:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
npx ctx-pilot auto-index
|
|
279
|
+
npx ctx-pilot validate
|
|
280
|
+
npx ctx-pilot status
|
|
281
|
+
```
|
|
157
282
|
|
|
158
283
|
---
|
|
159
284
|
|
|
160
285
|
## CLI Commands
|
|
161
286
|
|
|
162
|
-
### Setup &
|
|
287
|
+
### Setup & Indexing
|
|
163
288
|
|
|
164
289
|
```bash
|
|
165
290
|
npx ctx-pilot init # Set up config and install hook
|
|
166
291
|
npx ctx-pilot status # Show config, index, hooks, and exports
|
|
167
|
-
npx ctx-pilot
|
|
168
|
-
npx ctx-pilot index
|
|
292
|
+
npx ctx-pilot validate # Check index for issues
|
|
293
|
+
npx ctx-pilot auto-index # Build index automatically (fallback)
|
|
294
|
+
npx ctx-pilot auto-index -v # Build with verbose output
|
|
169
295
|
```
|
|
170
296
|
|
|
297
|
+
The primary way to build the index is asking your AI: `Follow the instructions in .context/optimize.md`
|
|
298
|
+
|
|
171
299
|
### Dynamic Hooks (Claude Code, Gemini CLI)
|
|
172
300
|
|
|
173
301
|
Per-prompt context suggestions - runs automatically before every message.
|
|
@@ -190,49 +318,81 @@ npx ctx-pilot export --mdc # Generate .cursor/rules/ctx-pilot.mdc
|
|
|
190
318
|
npx ctx-pilot export --all # Generate all exports
|
|
191
319
|
```
|
|
192
320
|
|
|
193
|
-
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## How Indexing Works
|
|
324
|
+
|
|
325
|
+
ctx-pilot uses **AI-driven indexing**. Your AI analyzes your codebase and builds a section-aware index:
|
|
326
|
+
|
|
327
|
+
### AI Indexing (Recommended)
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
Follow the instructions in .context/optimize.md
|
|
331
|
+
```
|
|
194
332
|
|
|
195
|
-
|
|
333
|
+
Your AI:
|
|
334
|
+
- Understands your code semantically, not just syntactically
|
|
335
|
+
- Creates meaningful section titles and previews
|
|
336
|
+
- Adds rich keywords including synonyms and related terms
|
|
337
|
+
- Identifies what actually matters in your codebase
|
|
338
|
+
|
|
339
|
+
This produces the best results because your AI understands context.
|
|
340
|
+
|
|
341
|
+
### Automatic Indexing (Fallback)
|
|
342
|
+
|
|
343
|
+
For instant setup without AI involvement:
|
|
196
344
|
|
|
197
345
|
```bash
|
|
198
|
-
npx ctx-pilot
|
|
199
|
-
npx ctx-pilot watch --windsurf # Watch and update .windsurfrules
|
|
200
|
-
npx ctx-pilot watch --aider # Watch and update .aider.context.md
|
|
201
|
-
npx ctx-pilot watch --all # Watch and update all exports
|
|
346
|
+
npx ctx-pilot auto-index
|
|
202
347
|
```
|
|
203
348
|
|
|
204
|
-
|
|
349
|
+
Built-in parsers extract sections from 20+ file types:
|
|
350
|
+
- **Markdown** - Headers and code blocks
|
|
351
|
+
- **JavaScript/TypeScript** - Functions, classes, interfaces, types
|
|
352
|
+
- **Python** - Functions and classes
|
|
353
|
+
- **Go, Rust, Java, C#, Ruby, Swift, PHP, Shell** - Functions and types
|
|
354
|
+
- **Structured data** - YAML, JSON, TOML sections
|
|
355
|
+
|
|
356
|
+
This works immediately but produces more generic results (function names as titles, extracted keywords rather than curated ones).
|
|
357
|
+
|
|
358
|
+
### Smart Search
|
|
359
|
+
|
|
360
|
+
ctx-pilot uses intelligent matching to find relevant sections:
|
|
361
|
+
- **Stemming** - "authentication" matches "authenticate", "auth"
|
|
362
|
+
- **Fuzzy matching** - Typos like "authentification" still match
|
|
363
|
+
- **Weighted scoring** - Title matches rank higher than keyword matches
|
|
205
364
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
ctx-pilot
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
365
|
+
### Smart Skip
|
|
366
|
+
|
|
367
|
+
ctx-pilot stays silent when it has nothing useful to add:
|
|
368
|
+
- Short prompts with few searchable terms (like "thanks" or "looks good") produce no output
|
|
369
|
+
- Low-confidence matches are filtered out
|
|
370
|
+
- Only results above a relevance threshold are shown
|
|
371
|
+
|
|
372
|
+
This prevents noise - you only see suggestions when they're actually helpful.
|
|
373
|
+
|
|
374
|
+
### Stale File Detection
|
|
375
|
+
|
|
376
|
+
ctx-pilot automatically detects when indexed files have changed:
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
**Relevant to your task:**
|
|
380
|
+
- src/auth.ts (lines 12-45) - function login ⚠️
|
|
381
|
+
|
|
382
|
+
⚠️ Before answering, update .context/index.json for files marked ⚠️.
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Claude automatically updates the index for stale files before responding - no action needed from you.
|
|
386
|
+
|
|
387
|
+
### Validation
|
|
388
|
+
|
|
389
|
+
Check your index for issues:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
npx ctx-pilot validate
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
This checks for missing pinned files, invalid line numbers, empty keywords, and orphaned entries.
|
|
236
396
|
|
|
237
397
|
---
|
|
238
398
|
|
|
@@ -240,12 +400,24 @@ ctx-pilot understands structure in:
|
|
|
240
400
|
|
|
241
401
|
**Nothing happening?**
|
|
242
402
|
- Run `npx ctx-pilot status` to check setup
|
|
403
|
+
- Make sure you ran `npx ctx-pilot auto-index`
|
|
243
404
|
- Restart Claude Code after installing
|
|
244
405
|
|
|
245
406
|
**Wrong suggestions?**
|
|
246
407
|
- Add important files to `pinned`
|
|
247
408
|
- Adjust `include`/`exclude` patterns
|
|
248
|
-
-
|
|
409
|
+
- Rebuild with `npx ctx-pilot auto-index`
|
|
410
|
+
- Check for issues with `npx ctx-pilot validate`
|
|
411
|
+
|
|
412
|
+
**Seeing ⚠️ warnings?**
|
|
413
|
+
- Files changed since the index was built
|
|
414
|
+
- Claude updates the index automatically before answering
|
|
415
|
+
- Or rebuild manually with `npx ctx-pilot auto-index`
|
|
416
|
+
|
|
417
|
+
**No suggestions appearing?**
|
|
418
|
+
- This is often intentional - ctx-pilot stays silent when there's nothing useful to add
|
|
419
|
+
- Try prompts with specific terms (function names, file paths, technical concepts)
|
|
420
|
+
- Check `npx ctx-pilot status` to verify the hook is installed and index exists
|
|
249
421
|
|
|
250
422
|
**ctx-pilot stops working?**
|
|
251
423
|
- It fails gracefully - your AI tool works exactly as before, just without suggestions
|
|
@@ -269,10 +441,8 @@ ctx-pilot runs **100% locally**. No telemetry, no analytics, no network requests
|
|
|
269
441
|
|
|
270
442
|
ctx-pilot is designed to be invisible:
|
|
271
443
|
|
|
272
|
-
- **Index build**: < 2 seconds for most projects
|
|
273
444
|
- **Hook execution**: < 100ms per prompt
|
|
274
445
|
- **Memory**: Minimal - index stored on disk
|
|
275
|
-
- **Watch mode**: Debounced updates, low CPU usage
|
|
276
446
|
|
|
277
447
|
---
|
|
278
448
|
|
|
@@ -282,7 +452,6 @@ Found a bug? Have an idea? Contributions welcome!
|
|
|
282
452
|
|
|
283
453
|
- **Issues**: [Report bugs or request features](https://github.com/Suite110/ctx-pilot/issues)
|
|
284
454
|
- **PRs**: Fork, branch, submit
|
|
285
|
-
- **Parsers**: Add support for new languages in `src/indexer/parsers/`
|
|
286
455
|
|
|
287
456
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
288
457
|
|
|
@@ -294,7 +463,7 @@ If ctx-pilot saves you time, consider supporting its development:
|
|
|
294
463
|
|
|
295
464
|
- ⭐ **Star the repo** - Helps others discover it
|
|
296
465
|
- 🐛 **Report issues** - Help make it better
|
|
297
|
-
- 💻 **Contribute code** - New features,
|
|
466
|
+
- 💻 **Contribute code** - New features, bug fixes
|
|
298
467
|
- 💬 **Spread the word** - Tweet, blog, tell your team
|
|
299
468
|
- ❤️ **Sponsor** - [GitHub Sponsors](https://github.com/sponsors/stephen-gobin)
|
|
300
469
|
|