@wb200/mgrep 0.1.10

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 (46) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +288 -0
  3. package/dist/commands/login.js +28 -0
  4. package/dist/commands/login.js.map +1 -0
  5. package/dist/commands/search.js +191 -0
  6. package/dist/commands/search.js.map +1 -0
  7. package/dist/commands/watch.js +134 -0
  8. package/dist/commands/watch.js.map +1 -0
  9. package/dist/commands/watch_mcp.js +77 -0
  10. package/dist/commands/watch_mcp.js.map +1 -0
  11. package/dist/index.js +36 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/install/claude-code.js +71 -0
  14. package/dist/install/claude-code.js.map +1 -0
  15. package/dist/install/codex.js +116 -0
  16. package/dist/install/codex.js.map +1 -0
  17. package/dist/install/droid.js +191 -0
  18. package/dist/install/droid.js.map +1 -0
  19. package/dist/install/opencode.js +161 -0
  20. package/dist/install/opencode.js.map +1 -0
  21. package/dist/lib/config.js +216 -0
  22. package/dist/lib/config.js.map +1 -0
  23. package/dist/lib/context.js +35 -0
  24. package/dist/lib/context.js.map +1 -0
  25. package/dist/lib/file.js +154 -0
  26. package/dist/lib/file.js.map +1 -0
  27. package/dist/lib/git.js +167 -0
  28. package/dist/lib/git.js.map +1 -0
  29. package/dist/lib/logger.js +80 -0
  30. package/dist/lib/logger.js.map +1 -0
  31. package/dist/lib/model-studio.js +205 -0
  32. package/dist/lib/model-studio.js.map +1 -0
  33. package/dist/lib/store.js +639 -0
  34. package/dist/lib/store.js.map +1 -0
  35. package/dist/lib/sync-helpers.js +51 -0
  36. package/dist/lib/sync-helpers.js.map +1 -0
  37. package/dist/lib/utils.js +300 -0
  38. package/dist/lib/utils.js.map +1 -0
  39. package/dist/lib/warning.js +34 -0
  40. package/dist/lib/warning.js.map +1 -0
  41. package/dist/plugins/mgrep/.claude-plugin/plugin.json +9 -0
  42. package/dist/plugins/mgrep/hooks/hook.json +27 -0
  43. package/dist/plugins/mgrep/hooks/mgrep_watch.py +55 -0
  44. package/dist/plugins/mgrep/hooks/mgrep_watch_kill.py +50 -0
  45. package/dist/plugins/mgrep/skills/mgrep/SKILL.md +59 -0
  46. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,288 @@
1
+ <div align="center">
2
+ <h1>mgrep</h1>
3
+ <p><em>Semantic code search powered by local LanceDB embeddings — feels as immediate as <code>grep</code>.</em></p>
4
+ <a href="https://www.npmjs.com/package/@wb200/mgrep"><img src="https://badge.fury.io/js/%40wb200%2Fmgrep.svg" alt="npm version" /></a>
5
+ <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0" /></a>
6
+ </div>
7
+
8
+ ## Why mgrep?
9
+
10
+ - Natural-language search that feels as immediate as `grep`.
11
+ - Semantic search over your local codebase — no cloud upload of source code required.
12
+ - Smooth background indexing via `mgrep watch`, designed to detect and keep up-to-date everything that matters inside any git repository.
13
+ - First-class coding agent integrations (Claude Code, Codex, OpenCode, Factory Droid).
14
+ - Built for agents and humans alike: quiet output, thoughtful defaults, and escape hatches everywhere.
15
+
16
+ ```bash
17
+ # index once
18
+ mgrep watch
19
+
20
+ # then ask your repo things in natural language
21
+ mgrep "where do we set up auth?"
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ 1. **Install**
27
+ ```bash
28
+ npm install -g @wb200/mgrep # or pnpm / bun
29
+ ```
30
+
31
+ 2. **Set API keys**
32
+ ```bash
33
+ export DEEPINFRA_API_KEY=your_deepinfra_key # for embeddings & rerank
34
+ export DASHSCOPE_API_KEY=your_dashscope_key # for synthesized answers
35
+ ```
36
+ - **DeepInfra**: Sign up at [deepinfra.com](https://deepinfra.com) — used for Qwen3 embeddings and reranking.
37
+ - **Alibaba Cloud DashScope (Singapore)**: Sign up at [dashscope.aliyuncs.com](https://dashscope-intl.aliyuncs.com) — used for the Responses API (answers and agentic planning). Only required if you use `--answer` or `--agentic`.
38
+
39
+ 3. **Validate your configuration**
40
+ ```bash
41
+ mgrep validate
42
+ ```
43
+
44
+ 4. **Index a project**
45
+ ```bash
46
+ cd path/to/repo
47
+ mgrep watch
48
+ ```
49
+ `watch` performs an initial sync, respects `.gitignore`, then keeps the local LanceDB store updated as files change.
50
+
51
+ 5. **Search anything**
52
+ ```bash
53
+ mgrep "where do we set up auth?" src/lib
54
+ mgrep -m 25 "store schema"
55
+ ```
56
+ Searches default to the current working directory unless you pass a path.
57
+
58
+ ## Using it with Coding Agents
59
+
60
+ > [!NOTE]
61
+ > **Default Limits**: mgrep enforces default limits to ensure optimal performance:
62
+ > - **Maximum file size**: 4MB per file
63
+ > - **Maximum file count**: 10,000 files per directory
64
+ >
65
+ > These limits can be customized via CLI flags (`--max-file-size`, `--max-file-count`),
66
+ > environment variables, or config files. See the [Configuration](#configuration) section for details.
67
+
68
+ `mgrep` supports assisted installation commands for many agents:
69
+ - `mgrep install-claude-code` for Claude Code
70
+ - `mgrep install-opencode` for OpenCode
71
+ - `mgrep install-codex` for Codex
72
+ - `mgrep install-droid` for Factory Droid
73
+
74
+ ## When to use what
75
+
76
+ `mgrep` complements `grep`, not replaces it. The best code search combines both.
77
+
78
+ | Use `grep` (or `ripgrep`) for... | Use `mgrep` for... |
79
+ | --- | --- |
80
+ | **Exact Matches** | **Intent Search** |
81
+ | Symbol tracing, Refactoring, Regex | Code exploration, Feature discovery, Onboarding |
82
+
83
+ ## mgrep as Subagent
84
+
85
+ For complex questions that require information from multiple sources, `mgrep` can act as a subagent that automatically refines queries and performs multiple searches.
86
+
87
+ ```bash
88
+ # Enable agentic search for complex multi-part questions
89
+ mgrep --agentic "What are the yearly numbers for 2020, 2021, 2022, 2023, 2024?"
90
+
91
+ # Combine with --answer for a synthesized response from multiple sources
92
+ mgrep --agentic -a "How does authentication work and where is it configured?"
93
+ ```
94
+
95
+ When `--agentic` is enabled, mgrep will:
96
+ - Automatically break down complex queries into sub-queries
97
+ - Perform multiple searches to gather comprehensive results
98
+ - Combine findings from different parts of your codebase
99
+
100
+ ## Commands at a Glance
101
+
102
+ | Command | Purpose |
103
+ | --- | --- |
104
+ | `mgrep` / `mgrep search <pattern> [path]` | Natural-language search with many `grep`-style flags (`-i`, `-r`, `-m`...). |
105
+ | `mgrep watch` | Index current repo and keep the local store in sync via file watchers. |
106
+ | `mgrep validate` | Validate DeepInfra and Alibaba Cloud API key configuration. |
107
+ | `mgrep install-claude-code` | Add the mgrep MCP plugin to Claude Code. |
108
+ | `mgrep install-opencode` | Add mgrep to OpenCode. |
109
+ | `mgrep install-codex` | Add mgrep to Codex. |
110
+ | `mgrep install-droid` | Add mgrep hooks/skills to Factory Droid. |
111
+
112
+ ### mgrep search
113
+
114
+ `mgrep search` is the default command. It searches the current directory for a pattern.
115
+
116
+ | Option | Description |
117
+ | --- | --- |
118
+ | `-m <max_count>` | The maximum number of results to return |
119
+ | `-c`, `--content` | Show content of the results |
120
+ | `-a`, `--answer` | Generate an answer to the question based on the results |
121
+ | `--agentic` | Enable agentic search to automatically refine queries and perform multiple searches |
122
+ | `-s`, `--sync` | Sync the local files to the store before searching |
123
+ | `-d`, `--dry-run` | Dry run the search process (no actual file syncing) |
124
+ | `--no-rerank` | Disable reranking of search results |
125
+ | `--max-file-size <bytes>` | Maximum file size in bytes to upload (overrides config) |
126
+ | `--max-file-count <count>` | Maximum number of files to upload (overrides config) |
127
+
128
+ All search options can also be configured via environment variables (see [Environment Variables](#environment-variables) section below).
129
+
130
+ **Examples:**
131
+ ```bash
132
+ mgrep "What code parsers are available?" # search in the current directory
133
+ mgrep "How are chunks defined?" src/models # search in the src/models directory
134
+ mgrep -m 10 "maximum concurrent workers" # limit results to 10
135
+ mgrep -a "What code parsers are available?" # generate an answer based on results
136
+ mgrep --agentic -a "How does the sync pipeline work?" # agentic multi-query answer
137
+ ```
138
+
139
+ ### mgrep watch
140
+
141
+ `mgrep watch` indexes the current repository and keeps the local LanceDB store in sync via file watchers.
142
+
143
+ It respects the current `.gitignore`, as well as a `.mgrepignore` file in the root of the repository. The `.mgrepignore` file follows the same syntax as the [`.gitignore`](https://git-scm.com/docs/gitignore) file.
144
+
145
+ | Option | Description |
146
+ | --- | --- |
147
+ | `-d`, `--dry-run` | Dry run the watch process (no actual file syncing) |
148
+ | `--max-file-size <bytes>` | Maximum file size in bytes to upload (overrides config) |
149
+ | `--max-file-count <count>` | Maximum number of files to upload (overrides config) |
150
+
151
+ **Examples:**
152
+ ```bash
153
+ mgrep watch # index the current repository and watch for changes
154
+ mgrep watch --max-file-size 1048576 # limit uploads to files under 1MB
155
+ mgrep watch --max-file-count 5000 # limit sync to 5000 changed files or fewer
156
+ ```
157
+
158
+ ## Architecture
159
+
160
+ - Files are chunked and embedded locally using Qwen3-Embedding via DeepInfra, then stored in a LanceDB vector database under `~/.mgrep/lancedb/`.
161
+ - Searches combine vector similarity (ANN) and full-text search (BM25), fused with Reciprocal Rank Fusion.
162
+ - Reranking uses Qwen3-Reranker via DeepInfra and is enabled by default (disable with `--no-rerank`).
163
+ - Synthesized answers and agentic query planning use Alibaba Cloud DashScope (Qwen3.5-plus) via the Responses API.
164
+ - All embeddings and indexes are stored locally — only API calls to DeepInfra/DashScope leave your machine.
165
+
166
+ ## Configuration
167
+
168
+ mgrep can be configured via config files, environment variables, or CLI flags.
169
+
170
+ ### Config File
171
+
172
+ Create a `.mgreprc.yaml` (or `.mgreprc.yml`) in your project root for local configuration, or `~/.config/mgrep/config.yaml` (or `config.yml`) for global configuration.
173
+
174
+ ```yaml
175
+ # Maximum file size in bytes to upload (default: 4MB)
176
+ maxFileSize: 5242880
177
+
178
+ # Maximum number of files to sync (upload/delete) per operation (default: 10000)
179
+ maxFileCount: 5000
180
+
181
+ # Concurrency for sync operations (default: 20)
182
+ syncConcurrency: 10
183
+
184
+ # Override the embedding model (default: Qwen/Qwen3-Embedding-4B)
185
+ embedModel: Qwen/Qwen3-Embedding-4B
186
+
187
+ # Embedding dimensions (default: 2560)
188
+ embedDimensions: 2560
189
+
190
+ # Override the rerank model (default: Qwen/Qwen3-Reranker-4B)
191
+ rerankModel: Qwen/Qwen3-Reranker-4B
192
+
193
+ # Override the LLM model for answers (default: qwen3.5-plus)
194
+ llmModel: qwen3.5-plus
195
+
196
+ # Custom LanceDB storage path (default: ~/.mgrep/lancedb)
197
+ lancedbPath: /path/to/lancedb
198
+ ```
199
+
200
+ **Configuration precedence** (highest to lowest):
201
+ 1. CLI flags (`--max-file-size`, `--max-file-count`)
202
+ 2. Environment variables (`MGREP_MAX_FILE_SIZE`, `MGREP_MAX_FILE_COUNT`, …)
203
+ 3. Local config file (`.mgreprc.yaml` in project directory)
204
+ 4. Global config file (`~/.config/mgrep/config.yaml`)
205
+ 5. Default values
206
+
207
+ ## Environment Variables
208
+
209
+ ### API Keys
210
+
211
+ - `DEEPINFRA_API_KEY`: DeepInfra API key for embeddings and reranking (required)
212
+ - `DASHSCOPE_API_KEY`: Alibaba Cloud DashScope API key for responses (required for `--answer` / `--agentic`)
213
+
214
+ ### Store
215
+
216
+ - `MGREP_STORE`: Override the default store name (default: `mgrep`)
217
+ - `MGREP_LANCEDB_PATH`: Override the LanceDB storage path
218
+
219
+ ### Search Options
220
+
221
+ - `MGREP_MAX_COUNT`: Maximum number of results to return (default: `10`)
222
+ - `MGREP_CONTENT`: Show content of the results (set to `1` or `true` to enable)
223
+ - `MGREP_ANSWER`: Generate an answer based on the results (set to `1` or `true` to enable)
224
+ - `MGREP_AGENTIC`: Enable agentic search (set to `1` or `true` to enable)
225
+ - `MGREP_SYNC`: Sync files before searching (set to `1` or `true` to enable)
226
+ - `MGREP_DRY_RUN`: Enable dry run mode (set to `1` or `true` to enable)
227
+ - `MGREP_RERANK`: Enable reranking (set to `0` or `false` to disable, default: enabled)
228
+
229
+ ### Sync Options
230
+
231
+ - `MGREP_MAX_FILE_SIZE`: Maximum file size in bytes to upload (default: `4194304` / 4MB)
232
+ - `MGREP_MAX_FILE_COUNT`: Maximum number of files to sync per operation (default: `10000`)
233
+ - `MGREP_SYNC_CONCURRENCY`: Concurrency for sync operations (default: `20`)
234
+
235
+ ### Model Options
236
+
237
+ - `MGREP_EMBED_MODEL`: Embedding model to use (default: `Qwen/Qwen3-Embedding-4B`)
238
+ - `MGREP_EMBED_DIMENSIONS`: Embedding dimensions (default: `2560`)
239
+ - `MGREP_RERANK_MODEL`: Rerank model to use (default: `Qwen/Qwen3-Reranker-4B`)
240
+ - `MGREP_LLM_MODEL`: LLM model for answers (default: `qwen3.5-plus`)
241
+
242
+ **Examples:**
243
+ ```bash
244
+ # Set default max results to 25
245
+ export MGREP_MAX_COUNT=25
246
+ mgrep "search query"
247
+
248
+ # Always show content in results
249
+ export MGREP_CONTENT=1
250
+ mgrep "search query"
251
+
252
+ # Disable reranking globally
253
+ export MGREP_RERANK=0
254
+ mgrep "search query"
255
+ ```
256
+
257
+ Note: Command-line options always override environment variables.
258
+
259
+ ## Development
260
+
261
+ ```bash
262
+ pnpm install
263
+ pnpm build # TypeScript compile
264
+ pnpm test # bats integration tests
265
+ pnpm format # biome formatting + linting
266
+ pnpm typecheck # type-check without emitting
267
+ ```
268
+
269
+ The executable lives at `dist/index.js` (built from TypeScript via `tsc`).
270
+
271
+ ### Testing
272
+
273
+ ```bash
274
+ pnpm test
275
+ ```
276
+
277
+ Tests are written using [bats](https://bats-core.readthedocs.io/en/stable/) and use a `TestStore` in-memory backend so no real API keys are required.
278
+
279
+ ## Troubleshooting
280
+
281
+ - **API key errors**: Run `mgrep validate` to check your `DEEPINFRA_API_KEY` and `DASHSCOPE_API_KEY` are correctly set and working.
282
+ - **Watcher feels slow**: Lower `syncConcurrency` in your config if you're hitting API rate limits, or raise it for faster initial sync on large repos.
283
+ - **Store schema mismatch**: If you change `embedModel` or `embedDimensions`, delete the store directory (`~/.mgrep/lancedb/<store-name>/`) and re-index with `mgrep watch`.
284
+ - **Unknown option errors**: Unrecognized flags now produce an error — check `mgrep --help` for supported options.
285
+
286
+ ## License
287
+
288
+ Apache-2.0. See the [LICENSE](https://opensource.org/licenses/Apache-2.0) file for details.
@@ -0,0 +1,28 @@
1
+ import { intro, outro } from "@clack/prompts";
2
+ import chalk from "chalk";
3
+ import { Command } from "commander";
4
+ import { loadConfig } from "../lib/config.js";
5
+ import { createModelStudioConfig, ModelStudioClient, } from "../lib/model-studio.js";
6
+ export async function loginAction() {
7
+ intro(chalk.bold("🔐 Provider Configuration Check"));
8
+ try {
9
+ const config = loadConfig(process.cwd());
10
+ const client = new ModelStudioClient(createModelStudioConfig({
11
+ embedModel: config.embedModel,
12
+ embedDimensions: config.embedDimensions,
13
+ rerankModel: config.rerankModel,
14
+ llmModel: config.llmModel,
15
+ }));
16
+ await client.validate();
17
+ outro(chalk.green(`Configuration looks valid. Embeddings=${config.embedModel} (${config.embedDimensions} dims), rerank=${config.rerankModel}, responses=${config.llmModel}.`));
18
+ }
19
+ catch (error) {
20
+ const message = error instanceof Error ? error.message : String(error);
21
+ console.error(message);
22
+ process.exit(1);
23
+ }
24
+ }
25
+ export const validate = new Command("validate")
26
+ .description("Validate the DeepInfra and Alibaba Cloud provider configuration")
27
+ .action(loginAction);
28
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAErD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAClC,uBAAuB,CAAC;YACtB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CACH,CAAC;QAEF,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAExB,KAAK,CACH,KAAK,CAAC,KAAK,CACT,yCAAyC,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,eAAe,kBAAkB,MAAM,CAAC,WAAW,eAAe,MAAM,CAAC,QAAQ,GAAG,CAC3J,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KAC5C,WAAW,CACV,iEAAiE,CAClE;KACA,MAAM,CAAC,WAAW,CAAC,CAAC"}