ctx-pilot 0.9.0

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.
Files changed (136) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-COMMERCIAL +32 -0
  3. package/README.md +314 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +577 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/config/index.d.ts +9 -0
  9. package/dist/config/index.d.ts.map +1 -0
  10. package/dist/config/index.js +67 -0
  11. package/dist/config/index.js.map +1 -0
  12. package/dist/config/schema.d.ts +22 -0
  13. package/dist/config/schema.d.ts.map +1 -0
  14. package/dist/config/schema.js +9 -0
  15. package/dist/config/schema.js.map +1 -0
  16. package/dist/indexer/file-scanner.d.ts +6 -0
  17. package/dist/indexer/file-scanner.d.ts.map +1 -0
  18. package/dist/indexer/file-scanner.js +37 -0
  19. package/dist/indexer/file-scanner.js.map +1 -0
  20. package/dist/indexer/index.d.ts +10 -0
  21. package/dist/indexer/index.d.ts.map +1 -0
  22. package/dist/indexer/index.js +123 -0
  23. package/dist/indexer/index.js.map +1 -0
  24. package/dist/indexer/parsers/asciidoc.d.ts +3 -0
  25. package/dist/indexer/parsers/asciidoc.d.ts.map +1 -0
  26. package/dist/indexer/parsers/asciidoc.js +55 -0
  27. package/dist/indexer/parsers/asciidoc.js.map +1 -0
  28. package/dist/indexer/parsers/c.d.ts +3 -0
  29. package/dist/indexer/parsers/c.d.ts.map +1 -0
  30. package/dist/indexer/parsers/c.js +93 -0
  31. package/dist/indexer/parsers/c.js.map +1 -0
  32. package/dist/indexer/parsers/csharp.d.ts +3 -0
  33. package/dist/indexer/parsers/csharp.d.ts.map +1 -0
  34. package/dist/indexer/parsers/csharp.js +79 -0
  35. package/dist/indexer/parsers/csharp.js.map +1 -0
  36. package/dist/indexer/parsers/dart.d.ts +3 -0
  37. package/dist/indexer/parsers/dart.d.ts.map +1 -0
  38. package/dist/indexer/parsers/dart.js +81 -0
  39. package/dist/indexer/parsers/dart.js.map +1 -0
  40. package/dist/indexer/parsers/go.d.ts +3 -0
  41. package/dist/indexer/parsers/go.d.ts.map +1 -0
  42. package/dist/indexer/parsers/go.js +64 -0
  43. package/dist/indexer/parsers/go.js.map +1 -0
  44. package/dist/indexer/parsers/index.d.ts +4 -0
  45. package/dist/indexer/parsers/index.d.ts.map +1 -0
  46. package/dist/indexer/parsers/index.js +109 -0
  47. package/dist/indexer/parsers/index.js.map +1 -0
  48. package/dist/indexer/parsers/java.d.ts +3 -0
  49. package/dist/indexer/parsers/java.d.ts.map +1 -0
  50. package/dist/indexer/parsers/java.js +84 -0
  51. package/dist/indexer/parsers/java.js.map +1 -0
  52. package/dist/indexer/parsers/javascript.d.ts +3 -0
  53. package/dist/indexer/parsers/javascript.d.ts.map +1 -0
  54. package/dist/indexer/parsers/javascript.js +78 -0
  55. package/dist/indexer/parsers/javascript.js.map +1 -0
  56. package/dist/indexer/parsers/markdown.d.ts +3 -0
  57. package/dist/indexer/parsers/markdown.d.ts.map +1 -0
  58. package/dist/indexer/parsers/markdown.js +67 -0
  59. package/dist/indexer/parsers/markdown.js.map +1 -0
  60. package/dist/indexer/parsers/php.d.ts +3 -0
  61. package/dist/indexer/parsers/php.d.ts.map +1 -0
  62. package/dist/indexer/parsers/php.js +78 -0
  63. package/dist/indexer/parsers/php.js.map +1 -0
  64. package/dist/indexer/parsers/plain.d.ts +3 -0
  65. package/dist/indexer/parsers/plain.d.ts.map +1 -0
  66. package/dist/indexer/parsers/plain.js +18 -0
  67. package/dist/indexer/parsers/plain.js.map +1 -0
  68. package/dist/indexer/parsers/python.d.ts +3 -0
  69. package/dist/indexer/parsers/python.d.ts.map +1 -0
  70. package/dist/indexer/parsers/python.js +64 -0
  71. package/dist/indexer/parsers/python.js.map +1 -0
  72. package/dist/indexer/parsers/rst.d.ts +3 -0
  73. package/dist/indexer/parsers/rst.d.ts.map +1 -0
  74. package/dist/indexer/parsers/rst.js +67 -0
  75. package/dist/indexer/parsers/rst.js.map +1 -0
  76. package/dist/indexer/parsers/ruby.d.ts +3 -0
  77. package/dist/indexer/parsers/ruby.d.ts.map +1 -0
  78. package/dist/indexer/parsers/ruby.js +77 -0
  79. package/dist/indexer/parsers/ruby.js.map +1 -0
  80. package/dist/indexer/parsers/rust.d.ts +3 -0
  81. package/dist/indexer/parsers/rust.d.ts.map +1 -0
  82. package/dist/indexer/parsers/rust.js +83 -0
  83. package/dist/indexer/parsers/rust.js.map +1 -0
  84. package/dist/indexer/parsers/shader.d.ts +3 -0
  85. package/dist/indexer/parsers/shader.d.ts.map +1 -0
  86. package/dist/indexer/parsers/shader.js +81 -0
  87. package/dist/indexer/parsers/shader.js.map +1 -0
  88. package/dist/indexer/parsers/shell.d.ts +3 -0
  89. package/dist/indexer/parsers/shell.d.ts.map +1 -0
  90. package/dist/indexer/parsers/shell.js +77 -0
  91. package/dist/indexer/parsers/shell.js.map +1 -0
  92. package/dist/indexer/parsers/structured.d.ts +3 -0
  93. package/dist/indexer/parsers/structured.d.ts.map +1 -0
  94. package/dist/indexer/parsers/structured.js +104 -0
  95. package/dist/indexer/parsers/structured.js.map +1 -0
  96. package/dist/indexer/parsers/swift.d.ts +3 -0
  97. package/dist/indexer/parsers/swift.d.ts.map +1 -0
  98. package/dist/indexer/parsers/swift.js +89 -0
  99. package/dist/indexer/parsers/swift.js.map +1 -0
  100. package/dist/indexer/parsers/toml.d.ts +3 -0
  101. package/dist/indexer/parsers/toml.d.ts.map +1 -0
  102. package/dist/indexer/parsers/toml.js +58 -0
  103. package/dist/indexer/parsers/toml.js.map +1 -0
  104. package/dist/indexer/parsers/xml.d.ts +3 -0
  105. package/dist/indexer/parsers/xml.d.ts.map +1 -0
  106. package/dist/indexer/parsers/xml.js +73 -0
  107. package/dist/indexer/parsers/xml.js.map +1 -0
  108. package/dist/search/index.d.ts +5 -0
  109. package/dist/search/index.d.ts.map +1 -0
  110. package/dist/search/index.js +84 -0
  111. package/dist/search/index.js.map +1 -0
  112. package/dist/search/keywords.d.ts +9 -0
  113. package/dist/search/keywords.d.ts.map +1 -0
  114. package/dist/search/keywords.js +79 -0
  115. package/dist/search/keywords.js.map +1 -0
  116. package/dist/types.d.ts +44 -0
  117. package/dist/types.d.ts.map +1 -0
  118. package/dist/types.js +2 -0
  119. package/dist/types.js.map +1 -0
  120. package/dist/utils/gitignore.d.ts +5 -0
  121. package/dist/utils/gitignore.d.ts.map +1 -0
  122. package/dist/utils/gitignore.js +31 -0
  123. package/dist/utils/gitignore.js.map +1 -0
  124. package/dist/utils/index.d.ts +3 -0
  125. package/dist/utils/index.d.ts.map +1 -0
  126. package/dist/utils/index.js +3 -0
  127. package/dist/utils/index.js.map +1 -0
  128. package/dist/utils/paths.d.ts +8 -0
  129. package/dist/utils/paths.d.ts.map +1 -0
  130. package/dist/utils/paths.js +23 -0
  131. package/dist/utils/paths.js.map +1 -0
  132. package/dist/utils/tokens.d.ts +3 -0
  133. package/dist/utils/tokens.d.ts.map +1 -0
  134. package/dist/utils/tokens.js +22 -0
  135. package/dist/utils/tokens.js.map +1 -0
  136. package/package.json +77 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stephen Gobin
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.
@@ -0,0 +1,32 @@
1
+ # Commercial License for ctx-pilot
2
+
3
+ Copyright (c) 2025 Stephen Gobin
4
+
5
+ ## When Commercial License is Required
6
+
7
+ A commercial license is required if you:
8
+
9
+ 1. Use ctx-pilot in a closed-source product
10
+ 2. Embed ctx-pilot in a SaaS offering where it is a core feature
11
+ 3. Are a company with >$1M annual revenue using ctx-pilot in production
12
+ 4. Redistribute ctx-pilot in commercial products
13
+
14
+ ## How to Obtain
15
+
16
+ For commercial licensing inquiries, please open an issue at:
17
+ https://github.com/Suite110/ctx-pilot/issues
18
+
19
+ Or contact the author directly through GitHub.
20
+
21
+ ## Terms
22
+
23
+ Commercial licenses are negotiated on a case-by-case basis and may include:
24
+
25
+ - Perpetual or subscription licensing options
26
+ - Support and maintenance agreements
27
+ - Custom feature development
28
+ - Priority bug fixes
29
+
30
+ ## Open Source Alternative
31
+
32
+ If your use case qualifies for the MIT License (personal, educational, or open source use), no commercial license is needed. See the LICENSE file for MIT License terms.
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # ctx-pilot
2
+
3
+ **Stop repeating yourself to AI.**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/ctx-pilot.svg)](https://www.npmjs.com/package/ctx-pilot)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Works with **Claude Code**, **Gemini CLI**, **Cursor**, **Windsurf**, and **Aider**.
9
+
10
+ ---
11
+
12
+ ## The Problem
13
+
14
+ You're deep in a coding session with Claude Code. You've explained your project's architecture, the key concepts, the naming conventions. Then, 10 messages later:
15
+
16
+ ```
17
+ You: "Update the Widget component"
18
+ Claude: "I don't see a Widget component. Can you show me where it's defined?"
19
+ You: "It's in core-concepts.md, like I showed you earlier..."
20
+ ```
21
+
22
+ Sound familiar? Context gets lost. You repeat yourself. Momentum dies.
23
+
24
+ ## The Solution
25
+
26
+ ctx-pilot automatically suggests relevant files before every prompt. Claude reads them and stays informed.
27
+
28
+ ```
29
+ You: "Update the Widget component"
30
+
31
+ <ctx-pilot>
32
+ Look into these files for context:
33
+
34
+ **Pinned (always relevant):**
35
+ - docs/core-concepts.md
36
+
37
+ **Relevant to your task:**
38
+ - src/components/Widget.tsx (lines 12-45) - function Widget
39
+ - docs/components.md (lines 88-102) - Widget Props
40
+ </ctx-pilot>
41
+
42
+ Claude: "I'll update the Widget component. Based on the props defined in
43
+ core-concepts.md, here's what I'll change..."
44
+ ```
45
+
46
+ **Zero friction.** Install once, forget it exists. Context just works.
47
+
48
+ ---
49
+
50
+ ## Why ctx-pilot?
51
+
52
+ - **File suggestions, not content injection** - Claude reads files itself, keeping you in control
53
+ - **Section-aware indexing** - Points to specific functions and headers, not entire files
54
+ - **Works offline** - Everything runs locally, no API keys or accounts needed
55
+ - **Graceful degradation** - If something breaks, your AI tool works exactly as before
56
+
57
+ ---
58
+
59
+ ## Quick Start
60
+
61
+ ```bash
62
+ # Install
63
+ npm install -g ctx-pilot
64
+
65
+ # Set up in your project
66
+ npx ctx-pilot init
67
+
68
+ # Restart Claude Code
69
+ ```
70
+
71
+ That's it. ctx-pilot now runs before every prompt, suggesting relevant files based on what you're working on.
72
+
73
+ ---
74
+
75
+ ## How It Works
76
+
77
+ 1. **You type a prompt** in Claude Code
78
+ 2. **ctx-pilot extracts topics** from your message (function names, file paths, keywords)
79
+ 3. **Searches your indexed files** for matching sections
80
+ 4. **Suggests relevant files** with specific line ranges
81
+ 5. **Claude reads them** and responds with full context
82
+
83
+ All invisible. All automatic. No commands to remember.
84
+
85
+ ---
86
+
87
+ ## Who It's For
88
+
89
+ - **Documentation-heavy projects** - Game design docs, API specs, internal wikis
90
+ - **Complex codebases** - Where context matters and getting up to speed takes time
91
+ - **Long coding sessions** - When you need Claude to remember what you discussed
92
+ - **Teams** - Share pinned files so Claude understands your conventions
93
+
94
+ ---
95
+
96
+ ## Installation
97
+
98
+ ### Requirements
99
+
100
+ - Node.js 18+
101
+ - [Claude Code](https://claude.ai/code) or [Gemini CLI](https://github.com/google-gemini/gemini-cli)
102
+
103
+ ### Setup
104
+
105
+ ```bash
106
+ npx ctx-pilot init
107
+ ```
108
+
109
+ ctx-pilot auto-detects your environment (Claude or Gemini) and installs the appropriate hook.
110
+
111
+ Restart your AI CLI to activate.
112
+
113
+ ### Manual Setup
114
+
115
+ If you prefer control:
116
+
117
+ ```bash
118
+ # 1. Create config
119
+ echo '{
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
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Configuration
137
+
138
+ Edit `.context/config.json`:
139
+
140
+ ```json
141
+ {
142
+ "pinned": ["docs/core-concepts.md", "docs/glossary.md"],
143
+ "include": ["**/*.md", "**/*.ts", "**/*.py"],
144
+ "exclude": ["node_modules/**", "dist/**"],
145
+ "tokenBudget": 32000,
146
+ "maxContextPercentage": 50
147
+ }
148
+ ```
149
+
150
+ | Field | What it does |
151
+ |-------|--------------|
152
+ | `pinned` | Files suggested on every prompt (your core docs) |
153
+ | `include` | What to index (glob patterns) |
154
+ | `exclude` | What to skip |
155
+ | `tokenBudget` | Max tokens for context |
156
+ | `maxContextPercentage` | Max % of available context to use |
157
+
158
+ ---
159
+
160
+ ## CLI Commands
161
+
162
+ ### Setup & Status
163
+
164
+ ```bash
165
+ npx ctx-pilot init # Set up config and install hook
166
+ npx ctx-pilot status # Show config, index, hooks, and exports
167
+ npx ctx-pilot index # Rebuild the index
168
+ npx ctx-pilot index --force # Force full rebuild
169
+ ```
170
+
171
+ ### Dynamic Hooks (Claude Code, Gemini CLI)
172
+
173
+ Per-prompt context suggestions - runs automatically before every message.
174
+
175
+ ```bash
176
+ npx ctx-pilot hook # Install hook (auto-detects Claude/Gemini)
177
+ npx ctx-pilot hook --claude # Install for Claude Code
178
+ npx ctx-pilot hook --gemini # Install for Gemini CLI
179
+ ```
180
+
181
+ ### Static Exports (Cursor, Windsurf, Aider)
182
+
183
+ Generate context files for tools without hook support.
184
+
185
+ ```bash
186
+ npx ctx-pilot export --cursor # Generate .cursorrules
187
+ npx ctx-pilot export --windsurf # Generate .windsurfrules
188
+ npx ctx-pilot export --aider # Generate .aider.context.md
189
+ npx ctx-pilot export --mdc # Generate .cursor/rules/ctx-pilot.mdc
190
+ npx ctx-pilot export --all # Generate all exports
191
+ ```
192
+
193
+ ### Watch Mode
194
+
195
+ Auto-regenerate exports when files change.
196
+
197
+ ```bash
198
+ npx ctx-pilot watch --cursor # Watch and update .cursorrules
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
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Supported Languages
207
+
208
+ ctx-pilot understands structure in:
209
+
210
+ **Code:**
211
+ | Language | Indexed as sections |
212
+ |----------|---------------------|
213
+ | TypeScript/JavaScript | Functions, classes, interfaces |
214
+ | Python | Functions, classes |
215
+ | Go | Functions, structs, interfaces |
216
+ | Rust | Functions, structs, enums, traits, impls |
217
+ | Java/Kotlin | Classes, interfaces, methods |
218
+ | C# | Classes, structs, interfaces, methods |
219
+ | C/C++ | Functions, structs, classes, macros |
220
+ | Ruby | Classes, modules, methods |
221
+ | PHP | Classes, interfaces, traits, functions |
222
+ | Swift | Classes, structs, protocols, funcs |
223
+ | Dart | Classes, mixins, functions |
224
+ | Shell/Bash | Functions, exports |
225
+ | HLSL/GLSL/WGSL | Functions, structs |
226
+
227
+ **Docs & Config:**
228
+ | Format | Indexed as sections |
229
+ |--------|---------------------|
230
+ | Markdown | Headers (H1, H2, H3) |
231
+ | reStructuredText | Headers (underlined) |
232
+ | AsciiDoc | Headers (= syntax) |
233
+ | YAML/JSON | Top-level keys |
234
+ | TOML | Tables and sections |
235
+ | XML/HTML | Top-level elements |
236
+
237
+ ---
238
+
239
+ ## Troubleshooting
240
+
241
+ **Nothing happening?**
242
+ - Run `npx ctx-pilot status` to check setup
243
+ - Restart Claude Code after installing
244
+
245
+ **Wrong suggestions?**
246
+ - Add important files to `pinned`
247
+ - Adjust `include`/`exclude` patterns
248
+ - Run `npx ctx-pilot index --force`
249
+
250
+ **ctx-pilot stops working?**
251
+ - It fails gracefully - your AI tool works exactly as before, just without suggestions
252
+ - Check `npx ctx-pilot status` for diagnostics
253
+ - Reinstall the hook with `npx ctx-pilot hook`
254
+
255
+ ---
256
+
257
+ ## Privacy
258
+
259
+ ctx-pilot runs **100% locally**. No telemetry, no analytics, no network requests.
260
+
261
+ - Your code stays on your machine
262
+ - No accounts or API keys required
263
+ - Works offline
264
+ - Open source - audit the code yourself
265
+
266
+ ---
267
+
268
+ ## Performance
269
+
270
+ ctx-pilot is designed to be invisible:
271
+
272
+ - **Index build**: < 2 seconds for most projects
273
+ - **Hook execution**: < 100ms per prompt
274
+ - **Memory**: Minimal - index stored on disk
275
+ - **Watch mode**: Debounced updates, low CPU usage
276
+
277
+ ---
278
+
279
+ ## Contributing
280
+
281
+ Found a bug? Have an idea? Contributions welcome!
282
+
283
+ - **Issues**: [Report bugs or request features](https://github.com/Suite110/ctx-pilot/issues)
284
+ - **PRs**: Fork, branch, submit
285
+ - **Parsers**: Add support for new languages in `src/indexer/parsers/`
286
+
287
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
288
+
289
+ ---
290
+
291
+ ## Support the Project
292
+
293
+ If ctx-pilot saves you time, consider supporting its development:
294
+
295
+ - ⭐ **Star the repo** - Helps others discover it
296
+ - 🐛 **Report issues** - Help make it better
297
+ - 💻 **Contribute code** - New features, parsers, fixes
298
+ - 💬 **Spread the word** - Tweet, blog, tell your team
299
+ - ❤️ **Sponsor** - [GitHub Sponsors](https://github.com/sponsors/stephen-gobin)
300
+
301
+ ---
302
+
303
+ ## License
304
+
305
+ **Free for most users.** Dual-licensed:
306
+
307
+ - **MIT License** - Free for individuals, education, open source, and companies with <$1M annual revenue
308
+ - **Commercial License** - Required for larger commercial entities
309
+
310
+ Most developers and small teams can use ctx-pilot freely under MIT. See [LICENSE](LICENSE) and [LICENSE-COMMERCIAL](LICENSE-COMMERCIAL) for details.
311
+
312
+ ---
313
+
314
+ **Built by [@stephen-gobin](https://github.com/stephen-gobin)** | **[Suite110](https://github.com/Suite110)**
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}