grepmax 0.1.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.
- package/LICENSE +202 -0
- package/NOTICE +33 -0
- package/README.md +375 -0
- package/dist/commands/claude-code.js +60 -0
- package/dist/commands/codex.js +98 -0
- package/dist/commands/doctor.js +92 -0
- package/dist/commands/droid.js +189 -0
- package/dist/commands/index.js +125 -0
- package/dist/commands/list.js +120 -0
- package/dist/commands/mcp.js +567 -0
- package/dist/commands/opencode.js +199 -0
- package/dist/commands/search.js +539 -0
- package/dist/commands/serve.js +502 -0
- package/dist/commands/setup.js +160 -0
- package/dist/commands/skeleton.js +288 -0
- package/dist/commands/symbols.js +129 -0
- package/dist/commands/trace.js +50 -0
- package/dist/commands/verify.js +174 -0
- package/dist/config.js +120 -0
- package/dist/eval.js +618 -0
- package/dist/index.js +82 -0
- package/dist/lib/core/languages.js +237 -0
- package/dist/lib/graph/graph-builder.js +105 -0
- package/dist/lib/index/chunker.js +663 -0
- package/dist/lib/index/grammar-loader.js +110 -0
- package/dist/lib/index/ignore-patterns.js +63 -0
- package/dist/lib/index/index-config.js +86 -0
- package/dist/lib/index/sync-helpers.js +97 -0
- package/dist/lib/index/syncer.js +396 -0
- package/dist/lib/index/walker.js +164 -0
- package/dist/lib/index/watcher.js +245 -0
- package/dist/lib/output/formatter.js +161 -0
- package/dist/lib/output/json-formatter.js +6 -0
- package/dist/lib/search/intent.js +23 -0
- package/dist/lib/search/searcher.js +475 -0
- package/dist/lib/setup/model-loader.js +107 -0
- package/dist/lib/setup/setup-helpers.js +106 -0
- package/dist/lib/skeleton/body-fields.js +175 -0
- package/dist/lib/skeleton/index.js +24 -0
- package/dist/lib/skeleton/retriever.js +36 -0
- package/dist/lib/skeleton/skeletonizer.js +483 -0
- package/dist/lib/skeleton/summary-formatter.js +92 -0
- package/dist/lib/store/meta-cache.js +143 -0
- package/dist/lib/store/types.js +2 -0
- package/dist/lib/store/vector-db.js +340 -0
- package/dist/lib/utils/cleanup.js +33 -0
- package/dist/lib/utils/exit.js +38 -0
- package/dist/lib/utils/file-utils.js +131 -0
- package/dist/lib/utils/filter-builder.js +17 -0
- package/dist/lib/utils/formatter.js +230 -0
- package/dist/lib/utils/git.js +83 -0
- package/dist/lib/utils/lock.js +157 -0
- package/dist/lib/utils/project-root.js +107 -0
- package/dist/lib/utils/server-registry.js +97 -0
- package/dist/lib/workers/colbert-math.js +107 -0
- package/dist/lib/workers/colbert-tokenizer.js +113 -0
- package/dist/lib/workers/download-worker.js +169 -0
- package/dist/lib/workers/embeddings/colbert.js +213 -0
- package/dist/lib/workers/embeddings/granite.js +180 -0
- package/dist/lib/workers/embeddings/mlx-client.js +144 -0
- package/dist/lib/workers/orchestrator.js +350 -0
- package/dist/lib/workers/pool.js +373 -0
- package/dist/lib/workers/process-child.js +92 -0
- package/dist/lib/workers/worker.js +31 -0
- package/package.json +80 -0
- package/plugins/osgrep/.claude-plugin/plugin.json +20 -0
- package/plugins/osgrep/hooks/start.js +90 -0
- package/plugins/osgrep/hooks/stop.js +3 -0
- package/plugins/osgrep/hooks.json +26 -0
- package/plugins/osgrep/skills/osgrep/SKILL.md +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Mixedbread AI (original mgrep work)
|
|
190
|
+
Copyright 2025 Robert Owens (osgrep modifications and enhancements)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
osgrep
|
|
2
|
+
Copyright 2025 Ryan Donofrio
|
|
3
|
+
|
|
4
|
+
This product includes software originally developed by MixedBread as mgrep.
|
|
5
|
+
Original mgrep Copyright 2025 MixedBread
|
|
6
|
+
https://github.com/mixedbread-ai/mgrep
|
|
7
|
+
|
|
8
|
+
================================================================================
|
|
9
|
+
|
|
10
|
+
MODIFICATIONS AND ENHANCEMENTS
|
|
11
|
+
|
|
12
|
+
osgrep is a substantial modification and enhancement of the original mgrep
|
|
13
|
+
codebase. The following major changes and additions have been made by
|
|
14
|
+
Ryan Donofrio:
|
|
15
|
+
|
|
16
|
+
- Complete rewrite to use local-only embeddings (removing remote API dependencies)
|
|
17
|
+
- Integration with @huggingface/transformers for local model inference
|
|
18
|
+
- Implementation of LanceDB for local vector storage
|
|
19
|
+
- New local storage architecture and indexing system
|
|
20
|
+
- Enhanced chunking and context management
|
|
21
|
+
- Addition of watch mode for real-time index updates
|
|
22
|
+
- New CLI commands and improved user experience
|
|
23
|
+
- Comprehensive benchmarking and evaluation tools
|
|
24
|
+
- Extensive test suite additions
|
|
25
|
+
- Documentation and setup improvements
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
================================================================================
|
|
29
|
+
|
|
30
|
+
THIRD-PARTY DEPENDENCIES
|
|
31
|
+
|
|
32
|
+
This software depends on various open-source libraries. See package.json for
|
|
33
|
+
a complete list of dependencies and their respective licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>grepmax</h1>
|
|
3
|
+
<p><em>Slash tokens. Save time. Semantic search for your coding agent.</em></p>
|
|
4
|
+
|
|
5
|
+
<a href="https://opensource.org/licenses/Apache-2.0">
|
|
6
|
+
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0" />
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
<a href="https://deepwiki.com/reowens/grepmax">
|
|
10
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" />
|
|
11
|
+
</a>
|
|
12
|
+
|
|
13
|
+
<a>
|
|
14
|
+
<img alt="CodeRabbit Pull Request Reviews" src="https://img.shields.io/coderabbit/prs/github/reowens/grepmax">
|
|
15
|
+
</a>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Natural-language search that works like `grep`. Fast, local, and built for coding agents.
|
|
21
|
+
|
|
22
|
+
- **Semantic:** Finds concepts ("where do transactions get created?"), not just strings.
|
|
23
|
+
- **Call Graph Tracing:** Map dependencies with `trace` to see who calls what.
|
|
24
|
+
- **Role Detection:** Distinguishes `ORCHESTRATION` (high-level logic) from `DEFINITION` (types/classes).
|
|
25
|
+
- **Local & Private:** 100% local embeddings via ONNX (CPU) or MLX (Apple Silicon GPU).
|
|
26
|
+
- **Auto-Isolated:** Each repository gets its own index automatically.
|
|
27
|
+
- **Agent-Ready:** Native output with symbols, roles, and call graphs.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
1. **Install**
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g grepmax
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. **Setup (Recommended)**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
osgrep setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Downloads embedding models (~150MB) upfront and lets you choose between CPU (ONNX) and GPU (MLX) embedding modes. If you skip this, models download automatically on first use.
|
|
43
|
+
|
|
44
|
+
3. **Search**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
cd my-repo
|
|
48
|
+
osgrep "where do we handle authentication?"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Your first search will automatically index the repository.** Each repository is automatically isolated with its own index. Switching between repos "just works" — no manual configuration needed. If the background server is running (`osgrep serve`), search goes through the hot daemon; otherwise it falls back to on-demand indexing.
|
|
52
|
+
|
|
53
|
+
4. **Trace** (Call Graph)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
osgrep trace "function_name"
|
|
57
|
+
```
|
|
58
|
+
See who calls a function (upstream dependencies) and what it calls (downstream dependencies). Perfect for impact analysis and understanding code flow.
|
|
59
|
+
|
|
60
|
+
To find the symbols in your code base:
|
|
61
|
+
```bash
|
|
62
|
+
osgrep symbols
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
In our public benchmarks, `grepmax` can save about 20% of your LLM tokens and deliver a 30% speedup.
|
|
66
|
+
|
|
67
|
+
<div align="center">
|
|
68
|
+
<img src="public/bench.png" alt="osgrep benchmark" width="100%" style="border-radius: 8px; margin: 20px 0;" />
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Claude Code Plugin
|
|
74
|
+
|
|
75
|
+
1. Run `osgrep install-claude-code`
|
|
76
|
+
2. Open Claude Code (`claude`) and ask it questions about your codebase.
|
|
77
|
+
3. Highly recommend indexing your code base before using the plugin.
|
|
78
|
+
4. The plugin's hooks auto-start `osgrep serve` in the background and shut it down on session end. Claude will use `osgrep` for semantic searches automatically but can be encouraged to do so.
|
|
79
|
+
|
|
80
|
+
### Opencode Plugin
|
|
81
|
+
1. Run `osgrep install-opencode`
|
|
82
|
+
2. Open OC (`opencode`) and ask it questions about your codebase.
|
|
83
|
+
3. Highly recommend indexing your code base before using the plugin.
|
|
84
|
+
4. The plugin's hooks auto-start `osgrep serve` in the background and shut it down on session end. OC will use `osgrep` for semantic searches automatically but can be encouraged to do so.
|
|
85
|
+
|
|
86
|
+
### Codex Plugin
|
|
87
|
+
1. Run `osgrep install-codex`
|
|
88
|
+
2. Codex will use `osgrep` for semantic searches.
|
|
89
|
+
|
|
90
|
+
### Factory Droid Plugin
|
|
91
|
+
1. Run `osgrep install-droid`
|
|
92
|
+
2. To remove: `osgrep uninstall-droid`
|
|
93
|
+
|
|
94
|
+
### MCP Server
|
|
95
|
+
|
|
96
|
+
osgrep exposes tools via the [Model Context Protocol](https://modelcontextprotocol.io/) for any MCP-compatible AI agent or editor.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
osgrep mcp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This starts a stdio-based MCP server that auto-launches the `osgrep serve` daemon. Available tools:
|
|
103
|
+
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| `semantic_search` | Natural language code search with score filtering and per-file caps |
|
|
107
|
+
| `code_skeleton` | Collapsed file structure (~4x fewer tokens than reading the full file) |
|
|
108
|
+
| `trace_calls` | Call graph — who calls a symbol and what it calls |
|
|
109
|
+
| `list_symbols` | List indexed functions, classes, and types with definition locations |
|
|
110
|
+
| `index_status` | Check daemon status, file count, embed mode, and index age |
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Commands
|
|
114
|
+
|
|
115
|
+
### `osgrep search`
|
|
116
|
+
|
|
117
|
+
The default command. Searches the current directory using semantic meaning.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
osgrep "how is the database connection pooled?"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Options:**
|
|
124
|
+
|
|
125
|
+
| Flag | Description | Default |
|
|
126
|
+
| --- | --- | --- |
|
|
127
|
+
| `-m <n>` | Max total results to return. | `5` |
|
|
128
|
+
| `--per-file <n>` | Max matches to show per file. | `3` |
|
|
129
|
+
| `-c`, `--content` | Show full chunk content instead of snippets. | `false` |
|
|
130
|
+
| `--scores` | Show relevance scores (0-1) for each result. | `false` |
|
|
131
|
+
| `--min-score <n>` | Filter out results below this score threshold. | `0` |
|
|
132
|
+
| `--compact` | Compact hits view (paths + line ranges + role/preview). | `false` |
|
|
133
|
+
| `--skeleton` | Show code skeleton for matching files instead of snippets. | `false` |
|
|
134
|
+
| `--plain` | Disable ANSI colors and use simpler formatting. | `false` |
|
|
135
|
+
| `-s`, `--sync` | Force re-index changed files before searching. | `false` |
|
|
136
|
+
| `-d`, `--dry-run` | Show what would be indexed without actually indexing. | `false` |
|
|
137
|
+
|
|
138
|
+
**Examples:**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# General concept search
|
|
142
|
+
osgrep "API rate limiting logic"
|
|
143
|
+
|
|
144
|
+
# Deep dive (show more matches per file)
|
|
145
|
+
osgrep "error handling" --per-file 5
|
|
146
|
+
|
|
147
|
+
# Just give me the files
|
|
148
|
+
osgrep "user validation" --compact
|
|
149
|
+
|
|
150
|
+
# Show relevance scores and filter low-confidence matches
|
|
151
|
+
osgrep "authentication" --scores --min-score 0.5
|
|
152
|
+
|
|
153
|
+
# Show skeletons of matching files
|
|
154
|
+
osgrep "database connection" --skeleton
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### `osgrep index`
|
|
158
|
+
|
|
159
|
+
Manually indexes the repository. Useful if you want to pre-warm the cache or if you've made massive changes outside of the editor.
|
|
160
|
+
|
|
161
|
+
- Respects `.gitignore` and `.osgrepignore` (see [Configuration](#ignoring-files) section).
|
|
162
|
+
- **Smart Indexing:** Only embeds code and config files. Skips binaries, lockfiles, and minified assets.
|
|
163
|
+
- **Bounded Concurrency:** Uses a fixed thread pool to keep your system responsive.
|
|
164
|
+
- **Semantic Chunking:** Uses TreeSitter grammars for supported languages (TypeScript, JavaScript, Python, Go, Rust, C/C++, Java, C#, Ruby, PHP, Swift, Kotlin, JSON).
|
|
165
|
+
|
|
166
|
+
**Options:**
|
|
167
|
+
|
|
168
|
+
| Flag | Description | Default |
|
|
169
|
+
| --- | --- | --- |
|
|
170
|
+
| `-d`, `--dry-run` | See what would be indexed without making changes. | `false` |
|
|
171
|
+
| `-p`, `--path <dir>` | Path to index (defaults to current directory). | `.` |
|
|
172
|
+
| `-r`, `--reset` | Remove existing index and re-index from scratch. | `false` |
|
|
173
|
+
| `-v`, `--verbose` | Show detailed progress with file names. | `false` |
|
|
174
|
+
|
|
175
|
+
**Examples:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
osgrep index # Index current dir
|
|
179
|
+
osgrep index --dry-run # See what would be indexed
|
|
180
|
+
osgrep index --verbose # Watch detailed progress (useful for debugging)
|
|
181
|
+
osgrep index --reset # Full re-index from scratch
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `osgrep serve`
|
|
185
|
+
|
|
186
|
+
Runs a lightweight HTTP server with live file watching so searches stay hot in RAM.
|
|
187
|
+
|
|
188
|
+
- Keeps LanceDB and the embedding worker resident for <50ms responses.
|
|
189
|
+
- **Live reindexing:** Watches the repo (via chokidar) and incrementally re-indexes on file change.
|
|
190
|
+
- **Idle timeout:** Automatically shuts down after 30 minutes of inactivity (disable with `--no-idle-timeout`).
|
|
191
|
+
- Endpoints:
|
|
192
|
+
- `GET /health` — liveness check
|
|
193
|
+
- `GET /stats` — file count, chunk count, embed mode, index age, watcher status
|
|
194
|
+
- `POST /search` — `{ query, limit, path }`
|
|
195
|
+
|
|
196
|
+
**Options:**
|
|
197
|
+
|
|
198
|
+
| Flag | Description |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| `-p, --port <port>` | Port to listen on (default `4444`, retries up to 10 ports if taken) |
|
|
201
|
+
| `-b, --background` | Run server in background and exit immediately |
|
|
202
|
+
| `--cpu` | Use CPU-only embeddings (skip MLX GPU server) |
|
|
203
|
+
| `--no-idle-timeout` | Disable the 30-minute idle shutdown |
|
|
204
|
+
|
|
205
|
+
**Port Selection (priority order):**
|
|
206
|
+
1. Explicit `-p <port>` flag
|
|
207
|
+
2. `OSGREP_PORT` environment variable
|
|
208
|
+
3. Default `4444` (auto-increments if in use)
|
|
209
|
+
|
|
210
|
+
**Usage:**
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
osgrep serve # Foreground, port 4444 (or next available)
|
|
214
|
+
osgrep serve --background # Background mode, auto port
|
|
215
|
+
osgrep serve -b -p 5000 # Background on specific port
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Subcommands:**
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
osgrep serve status # Show server status for current directory
|
|
222
|
+
osgrep serve stop # Stop server in current directory
|
|
223
|
+
osgrep serve stop --all # Stop all running osgrep servers
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Example workflow:**
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Start servers in multiple projects
|
|
230
|
+
cd ~/project-a && osgrep serve -b # Starts on port 4444
|
|
231
|
+
cd ~/project-b && osgrep serve -b # Starts on port 4445 (auto-increment)
|
|
232
|
+
|
|
233
|
+
# Check status
|
|
234
|
+
osgrep serve status
|
|
235
|
+
|
|
236
|
+
# Stop all when done
|
|
237
|
+
osgrep serve stop --all
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Claude Code hooks start/stop this automatically; you rarely need to run it manually.
|
|
241
|
+
|
|
242
|
+
### `osgrep list`
|
|
243
|
+
|
|
244
|
+
Lists all indexed repositories (stores) and their metadata.
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
osgrep list
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Shows store names, sizes, and last modified times. Useful for seeing what's indexed and cleaning up old stores.
|
|
251
|
+
|
|
252
|
+
### `osgrep skeleton`
|
|
253
|
+
|
|
254
|
+
Generates a compressed "skeleton" of a file, showing only signatures, types, and class structures while eliding function bodies.
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
osgrep skeleton src/lib/auth.ts
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Output:**
|
|
261
|
+
```typescript
|
|
262
|
+
class AuthService {
|
|
263
|
+
validate(token: string): boolean {
|
|
264
|
+
// → jwt.verify, checkScope, .. | C:5 | ORCH
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Modes:**
|
|
270
|
+
- `osgrep skeleton <file>`: Skeletonize specific file.
|
|
271
|
+
- `osgrep skeleton <Symbol>`: Find symbol in index and skeletonize its file.
|
|
272
|
+
- `osgrep skeleton "query"`: Search for query and skeletonize top matches.
|
|
273
|
+
|
|
274
|
+
**Supported Languages:**
|
|
275
|
+
TypeScript, JavaScript, Python, Go, Rust, Java, C#, C++, C, Ruby, PHP, Swift, Kotlin.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
### `osgrep doctor`
|
|
279
|
+
|
|
280
|
+
Checks installation health, model paths, and database integrity.
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
osgrep doctor
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Performance & Architecture
|
|
287
|
+
|
|
288
|
+
osgrep is designed to be a "good citizen" on your machine:
|
|
289
|
+
|
|
290
|
+
1. **Bounded Concurrency:** Chunking/embedding stay within small thread pools (1–4) and capped batch sizes to keep laptops responsive.
|
|
291
|
+
2. **Smart Chunking:** Uses `tree-sitter` to split code by function/class boundaries, ensuring embeddings capture complete logical blocks.
|
|
292
|
+
3. **Deduplication:** Identical code blocks (boilerplate, license headers) are embedded once and cached, saving space and time.
|
|
293
|
+
4. **Semantic Split Search:** Queries both "Code" and "Docs" separately to ensure documentation doesn't drown out implementation details, then reranks with ColBERT.
|
|
294
|
+
5. **Global Batching:** A producer/consumer pipeline decouples chunking from embedding. Files are chunked concurrently, queued, embedded in fat batches, and written to LanceDB in bulk.
|
|
295
|
+
6. **Anchor-Only Scans & Batch Deletes:** File discovery and stale cleanup hit only anchor rows, and stale/changed paths are removed with a single `IN` delete to minimize I/O.
|
|
296
|
+
7. **Structural Boosting:** Function/class chunks get a small score boost; test/spec paths are slightly downweighted to bubble up primary definitions first.
|
|
297
|
+
8. **Role Classification:** Detects `ORCHESTRATION` functions (high complexity, many calls) vs `DEFINITION` (types/classes) to help agents prioritize where to read.
|
|
298
|
+
|
|
299
|
+
## Configuration
|
|
300
|
+
|
|
301
|
+
### Automatic Repository Isolation
|
|
302
|
+
|
|
303
|
+
osgrep automatically creates a unique index for each repository based on:
|
|
304
|
+
|
|
305
|
+
1. **Git Remote URL** (e.g., `github.com/facebook/react` → `facebook-react`)
|
|
306
|
+
2. **Git Repo without Remote** → directory name + hash (e.g., `utils-7f8a2b3c`)
|
|
307
|
+
3. **Non-Git Directory** → directory name + hash for collision safety
|
|
308
|
+
|
|
309
|
+
**Examples:**
|
|
310
|
+
```bash
|
|
311
|
+
cd ~/work/myproject # Auto-detected: owner-myproject
|
|
312
|
+
osgrep "API handlers"
|
|
313
|
+
|
|
314
|
+
cd ~/personal/utils # Auto-detected: utils-abc12345
|
|
315
|
+
osgrep "helper functions"
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Stores are isolated automatically — no manual `--store` flags needed!
|
|
319
|
+
|
|
320
|
+
### Ignoring Files
|
|
321
|
+
|
|
322
|
+
osgrep respects both `.gitignore` and `.osgrepignore` files when indexing. Create a `.osgrepignore` file in your repository root to exclude additional files or patterns from indexing.
|
|
323
|
+
|
|
324
|
+
**`.osgrepignore` syntax:**
|
|
325
|
+
- Uses the same pattern syntax as `.gitignore`
|
|
326
|
+
- Patterns are relative to the repository root
|
|
327
|
+
- Supports glob patterns, negation (`!`), and directory patterns (`/`)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
### Index Management
|
|
331
|
+
|
|
332
|
+
- **View indexed projects:** `osgrep list`
|
|
333
|
+
- **Index location:** `.osgrep/` in each project root
|
|
334
|
+
- **Clean up a project index:** `rm -rf .osgrep/` in the project directory
|
|
335
|
+
- **Global data (models, grammars):** `~/.osgrep/`
|
|
336
|
+
|
|
337
|
+
### GPU Embeddings (Apple Silicon)
|
|
338
|
+
|
|
339
|
+
On Macs with Apple Silicon, osgrep can use MLX for GPU-accelerated embeddings instead of ONNX on CPU.
|
|
340
|
+
|
|
341
|
+
1. Run `osgrep setup` and select **GPU (MLX)** when prompted.
|
|
342
|
+
2. Start the server: `osgrep serve` (automatically starts the MLX embed server).
|
|
343
|
+
3. To force CPU mode on a GPU-configured project: `osgrep serve --cpu`.
|
|
344
|
+
|
|
345
|
+
The MLX embed server runs on port `8100` by default (configurable via `MLX_EMBED_PORT`). It is managed automatically by `osgrep serve` — you don't need to start it manually.
|
|
346
|
+
|
|
347
|
+
## Development
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
pnpm install
|
|
351
|
+
pnpm build # or pnpm dev
|
|
352
|
+
pnpm test # vitest
|
|
353
|
+
pnpm format # biome check
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Troubleshooting
|
|
357
|
+
|
|
358
|
+
- **Index feels stale?** Run `osgrep index` to refresh, or use `osgrep serve` for live reindexing.
|
|
359
|
+
- **Weird results?** Run `osgrep doctor` to verify models.
|
|
360
|
+
- **Index getting stuck?** Run `osgrep index --verbose` to see which file is being processed.
|
|
361
|
+
- **Need a fresh start?** Delete `.osgrep/` in your project root and run `osgrep index`.
|
|
362
|
+
- **MLX server won't start?** Check `/tmp/mlx-embed-server.log` for errors. Use `osgrep serve --cpu` to fall back to CPU.
|
|
363
|
+
|
|
364
|
+
## Attribution
|
|
365
|
+
|
|
366
|
+
osgrep is built upon the foundation of [mgrep](https://github.com/mixedbread-ai/mgrep) by MixedBread. We acknowledge and appreciate the original architectural concepts and design decisions that informed this work.
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
See the [NOTICE](NOTICE) file for detailed attribution information.
|
|
370
|
+
|
|
371
|
+
## License
|
|
372
|
+
|
|
373
|
+
Licensed under the Apache License, Version 2.0.
|
|
374
|
+
See [LICENSE](LICENSE) and [Apache-2.0](https://opensource.org/licenses/Apache-2.0) for details.
|
|
375
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.installClaudeCode = void 0;
|
|
13
|
+
const node_child_process_1 = require("node:child_process");
|
|
14
|
+
const commander_1 = require("commander");
|
|
15
|
+
function runClaudeCommand(args) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const child = (0, node_child_process_1.spawn)("claude", ["plugin", ...args], {
|
|
18
|
+
env: process.env,
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
});
|
|
21
|
+
child.on("error", (error) => reject(error));
|
|
22
|
+
child.on("exit", (code) => {
|
|
23
|
+
if (code === 0) {
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
reject(new Error(`claude exited with code ${code !== null && code !== void 0 ? code : "unknown"}`));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function installPlugin() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
try {
|
|
35
|
+
yield runClaudeCommand(["marketplace", "add", "reowens/osgrep-max"]);
|
|
36
|
+
console.log("✅ Successfully added the osgrep marketplace");
|
|
37
|
+
yield runClaudeCommand(["install", "osgrep"]);
|
|
38
|
+
console.log("✅ Successfully installed the osgrep plugin for Claude Code");
|
|
39
|
+
console.log("\nNext steps:");
|
|
40
|
+
console.log("1. Restart Claude Code if it's running");
|
|
41
|
+
console.log("2. The plugin will automatically index your project when you open it");
|
|
42
|
+
console.log("3. Claude will use osgrep for semantic code search automatically");
|
|
43
|
+
console.log("4. You can also use `osgrep` commands directly in your terminal");
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error("❌ Error installing plugin:");
|
|
47
|
+
console.error(error);
|
|
48
|
+
console.error("\nTroubleshooting:");
|
|
49
|
+
console.error("- Ensure you have Claude Code version 2.0.36 or higher installed");
|
|
50
|
+
console.error("- Try running: claude plugin marketplace list");
|
|
51
|
+
console.error("- Check the Claude Code documentation: https://code.claude.com/docs");
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.installClaudeCode = new commander_1.Command("install-claude-code")
|
|
57
|
+
.description("Install the Claude Code plugin")
|
|
58
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
yield installPlugin();
|
|
60
|
+
}));
|