semantic-code-mcp 2.0.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 +22 -0
- package/README.md +259 -0
- package/config.json +85 -0
- package/features/check-last-version.js +504 -0
- package/features/clear-cache.js +75 -0
- package/features/get-status.js +210 -0
- package/features/hybrid-search.js +189 -0
- package/features/index-codebase.js +999 -0
- package/features/set-workspace.js +183 -0
- package/index.js +297 -0
- package/lib/ast-chunker.js +273 -0
- package/lib/cache-factory.js +13 -0
- package/lib/cache.js +157 -0
- package/lib/config.js +1296 -0
- package/lib/embedding-worker.js +155 -0
- package/lib/gemini-embedder.js +351 -0
- package/lib/ignore-patterns.js +896 -0
- package/lib/milvus-cache.js +478 -0
- package/lib/mrl-embedder.js +235 -0
- package/lib/project-detector.js +75 -0
- package/lib/resource-throttle.js +85 -0
- package/lib/sqlite-cache.js +468 -0
- package/lib/tokenizer.js +149 -0
- package/lib/utils.js +214 -0
- package/package.json +70 -0
- package/reindex.js +109 -0
package/lib/config.js
ADDED
|
@@ -0,0 +1,1296 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { ProjectDetector } from "./project-detector.js";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_CONFIG = {
|
|
7
|
+
searchDirectory: ".",
|
|
8
|
+
fileExtensions: [
|
|
9
|
+
// ==========================================
|
|
10
|
+
// JAVASCRIPT / TYPESCRIPT ECOSYSTEM
|
|
11
|
+
// ==========================================
|
|
12
|
+
"js", "ts", "jsx", "tsx", "mjs", "cjs", "mts", "cts",
|
|
13
|
+
|
|
14
|
+
// ==========================================
|
|
15
|
+
// WEB TECHNOLOGIES
|
|
16
|
+
// ==========================================
|
|
17
|
+
// Styles
|
|
18
|
+
"css", "scss", "sass", "less", "styl", "pcss", "postcss",
|
|
19
|
+
// Templates & Markup
|
|
20
|
+
"html", "htm", "vue", "svelte", "astro",
|
|
21
|
+
// Web Components
|
|
22
|
+
"marko", "riot",
|
|
23
|
+
|
|
24
|
+
// ==========================================
|
|
25
|
+
// PYTHON ECOSYSTEM
|
|
26
|
+
// ==========================================
|
|
27
|
+
"py", "pyw", "pyx", "pxd", "pxi",
|
|
28
|
+
|
|
29
|
+
// ==========================================
|
|
30
|
+
// JVM LANGUAGES
|
|
31
|
+
// ==========================================
|
|
32
|
+
"java", "kt", "kts", "scala", "sc", "groovy", "gvy", "gradle", "clj", "cljs", "cljc",
|
|
33
|
+
|
|
34
|
+
// ==========================================
|
|
35
|
+
// .NET LANGUAGES
|
|
36
|
+
// ==========================================
|
|
37
|
+
"cs", "csx", "fs", "fsx", "fsi", "vb",
|
|
38
|
+
|
|
39
|
+
// ==========================================
|
|
40
|
+
// SYSTEMS PROGRAMMING
|
|
41
|
+
// ==========================================
|
|
42
|
+
// C/C++
|
|
43
|
+
"c", "cpp", "cc", "cxx", "h", "hpp", "hxx", "hh", "ipp", "inl", "tpp",
|
|
44
|
+
// Rust
|
|
45
|
+
"rs",
|
|
46
|
+
// Go
|
|
47
|
+
"go",
|
|
48
|
+
// Zig
|
|
49
|
+
"zig",
|
|
50
|
+
// Nim
|
|
51
|
+
"nim", "nims",
|
|
52
|
+
// D
|
|
53
|
+
"d",
|
|
54
|
+
// V
|
|
55
|
+
"v", "vsh",
|
|
56
|
+
// Odin
|
|
57
|
+
"odin",
|
|
58
|
+
// Carbon (Google)
|
|
59
|
+
"carbon",
|
|
60
|
+
|
|
61
|
+
// ==========================================
|
|
62
|
+
// APPLE ECOSYSTEM
|
|
63
|
+
// ==========================================
|
|
64
|
+
"swift", "m", "mm",
|
|
65
|
+
|
|
66
|
+
// ==========================================
|
|
67
|
+
// SCRIPTING LANGUAGES
|
|
68
|
+
// ==========================================
|
|
69
|
+
// Ruby
|
|
70
|
+
"rb", "rake", "gemspec", "ru", "erb",
|
|
71
|
+
// PHP
|
|
72
|
+
"php", "phtml", "php3", "php4", "php5", "php7", "phps", "blade.php",
|
|
73
|
+
// Perl
|
|
74
|
+
"pl", "pm", "t", "pod",
|
|
75
|
+
// Lua
|
|
76
|
+
"lua",
|
|
77
|
+
// TCL
|
|
78
|
+
"tcl", "tk",
|
|
79
|
+
// AWK
|
|
80
|
+
"awk",
|
|
81
|
+
|
|
82
|
+
// ==========================================
|
|
83
|
+
// SHELL & COMMAND LINE
|
|
84
|
+
// ==========================================
|
|
85
|
+
"sh", "bash", "zsh", "fish", "ksh", "csh", "tcsh",
|
|
86
|
+
// PowerShell
|
|
87
|
+
"ps1", "psm1", "psd1",
|
|
88
|
+
// Batch
|
|
89
|
+
"bat", "cmd",
|
|
90
|
+
|
|
91
|
+
// ==========================================
|
|
92
|
+
// FUNCTIONAL LANGUAGES
|
|
93
|
+
// ==========================================
|
|
94
|
+
// Haskell
|
|
95
|
+
"hs", "lhs",
|
|
96
|
+
// OCaml
|
|
97
|
+
"ml", "mli",
|
|
98
|
+
// F# (already above in .NET)
|
|
99
|
+
// Elm
|
|
100
|
+
"elm",
|
|
101
|
+
// Elixir & Erlang
|
|
102
|
+
"ex", "exs", "erl", "hrl",
|
|
103
|
+
// Lisp family
|
|
104
|
+
"lisp", "lsp", "cl", "el", "scm", "ss", "rkt",
|
|
105
|
+
// PureScript
|
|
106
|
+
"purs",
|
|
107
|
+
// ReasonML / ReScript
|
|
108
|
+
"re", "rei", "res", "resi",
|
|
109
|
+
|
|
110
|
+
// ==========================================
|
|
111
|
+
// DATA & STATISTICS
|
|
112
|
+
// ==========================================
|
|
113
|
+
"r", "R", "rmd", "jl", "sas", "do", "ado", "mata",
|
|
114
|
+
|
|
115
|
+
// ==========================================
|
|
116
|
+
// MOBILE DEVELOPMENT
|
|
117
|
+
// ==========================================
|
|
118
|
+
"dart",
|
|
119
|
+
// Kotlin/Swift already covered
|
|
120
|
+
|
|
121
|
+
// ==========================================
|
|
122
|
+
// DATABASE & QUERY
|
|
123
|
+
// ==========================================
|
|
124
|
+
"sql", "psql", "plsql", "pgsql", "mysql",
|
|
125
|
+
// GraphQL
|
|
126
|
+
"graphql", "gql",
|
|
127
|
+
// Prisma
|
|
128
|
+
"prisma",
|
|
129
|
+
|
|
130
|
+
// ==========================================
|
|
131
|
+
// INFRASTRUCTURE AS CODE
|
|
132
|
+
// ==========================================
|
|
133
|
+
// Terraform/HCL
|
|
134
|
+
"tf", "hcl",
|
|
135
|
+
// Nix
|
|
136
|
+
"nix",
|
|
137
|
+
// Dhall
|
|
138
|
+
"dhall",
|
|
139
|
+
// Pulumi (uses regular languages)
|
|
140
|
+
// Ansible/Chef/Puppet use YAML/Ruby
|
|
141
|
+
|
|
142
|
+
// ==========================================
|
|
143
|
+
// BUILD & CONFIG (code-like)
|
|
144
|
+
// ==========================================
|
|
145
|
+
"cmake", "mk", "makefile",
|
|
146
|
+
// Bazel/Starlark
|
|
147
|
+
"bzl", "bazel", "star",
|
|
148
|
+
// Jsonnet
|
|
149
|
+
"jsonnet", "libsonnet",
|
|
150
|
+
// CUE
|
|
151
|
+
"cue",
|
|
152
|
+
|
|
153
|
+
// ==========================================
|
|
154
|
+
// BLOCKCHAIN & SMART CONTRACTS
|
|
155
|
+
// ==========================================
|
|
156
|
+
"sol", "vy", "move", "cairo", "fe",
|
|
157
|
+
|
|
158
|
+
// ==========================================
|
|
159
|
+
// GPU & SHADERS
|
|
160
|
+
// ==========================================
|
|
161
|
+
// CUDA
|
|
162
|
+
"cu", "cuh",
|
|
163
|
+
// OpenCL
|
|
164
|
+
"opencl",
|
|
165
|
+
// Shaders
|
|
166
|
+
"glsl", "hlsl", "wgsl", "vert", "frag", "geom", "comp", "tesc", "tese", "mesh",
|
|
167
|
+
// Metal
|
|
168
|
+
"metal",
|
|
169
|
+
|
|
170
|
+
// ==========================================
|
|
171
|
+
// HARDWARE DESCRIPTION
|
|
172
|
+
// ==========================================
|
|
173
|
+
"vhd", "vhdl", "sv", "svh",
|
|
174
|
+
|
|
175
|
+
// ==========================================
|
|
176
|
+
// SERIALIZATION & API
|
|
177
|
+
// ==========================================
|
|
178
|
+
"proto", "thrift", "avsc", "fbs",
|
|
179
|
+
|
|
180
|
+
// ==========================================
|
|
181
|
+
// MARKUP (code-like)
|
|
182
|
+
// ==========================================
|
|
183
|
+
"tex", "latex", "bib",
|
|
184
|
+
// Typst
|
|
185
|
+
"typ",
|
|
186
|
+
|
|
187
|
+
// ==========================================
|
|
188
|
+
// CONFIG (commonly searched)
|
|
189
|
+
// ==========================================
|
|
190
|
+
"json", "yaml", "yml", "toml",
|
|
191
|
+
|
|
192
|
+
// ==========================================
|
|
193
|
+
// LEGACY & ENTERPRISE
|
|
194
|
+
// ==========================================
|
|
195
|
+
"cbl", "cob", "cpy", // COBOL
|
|
196
|
+
"f", "for", "f90", "f95", "f03", "f08", // Fortran
|
|
197
|
+
"pas", "pp", // Pascal
|
|
198
|
+
"ada", "adb", "ads", // Ada
|
|
199
|
+
"abap", // SAP ABAP
|
|
200
|
+
"cls", "trigger", // Salesforce Apex
|
|
201
|
+
"rpg", "rpgle", // IBM RPG
|
|
202
|
+
"p", "i", "w", // Progress/OpenEdge
|
|
203
|
+
|
|
204
|
+
// ==========================================
|
|
205
|
+
// OTHER
|
|
206
|
+
// ==========================================
|
|
207
|
+
"coffee", // CoffeeScript
|
|
208
|
+
"ls", // LiveScript
|
|
209
|
+
"cr", // Crystal
|
|
210
|
+
"pony", // Pony
|
|
211
|
+
"wren", // Wren
|
|
212
|
+
"io", // Io
|
|
213
|
+
"factor", // Factor
|
|
214
|
+
"forth", "4th", // Forth
|
|
215
|
+
"red", "reds", // Red
|
|
216
|
+
"ring", // Ring
|
|
217
|
+
"hx", // Haxe
|
|
218
|
+
"as", // ActionScript
|
|
219
|
+
"monkey", // Monkey
|
|
220
|
+
"gd", // GDScript (Godot)
|
|
221
|
+
"shader", // Unity shaders
|
|
222
|
+
"uc", // UnrealScript
|
|
223
|
+
"angelscript" // AngelScript
|
|
224
|
+
],
|
|
225
|
+
excludePatterns: [
|
|
226
|
+
// ==========================================
|
|
227
|
+
// DEPENDENCY DIRECTORIES
|
|
228
|
+
// ==========================================
|
|
229
|
+
"**/node_modules/**",
|
|
230
|
+
"**/bower_components/**",
|
|
231
|
+
"**/jspm_packages/**",
|
|
232
|
+
"**/web_modules/**",
|
|
233
|
+
"**/vendor/**",
|
|
234
|
+
"**/vendors/**",
|
|
235
|
+
"**/third_party/**",
|
|
236
|
+
"**/third-party/**",
|
|
237
|
+
"**/thirdparty/**",
|
|
238
|
+
"**/external/**",
|
|
239
|
+
"**/externals/**",
|
|
240
|
+
"**/deps/**",
|
|
241
|
+
"**/dependencies/**",
|
|
242
|
+
"**/lib/**/*.min.js",
|
|
243
|
+
"**/libs/**",
|
|
244
|
+
"**/packages/**",
|
|
245
|
+
"**/pkg/**",
|
|
246
|
+
|
|
247
|
+
// ==========================================
|
|
248
|
+
// BUILD OUTPUT
|
|
249
|
+
// ==========================================
|
|
250
|
+
"**/dist/**",
|
|
251
|
+
"**/build/**",
|
|
252
|
+
"**/out/**",
|
|
253
|
+
"**/output/**",
|
|
254
|
+
"**/target/**",
|
|
255
|
+
"**/bin/**",
|
|
256
|
+
"**/obj/**",
|
|
257
|
+
"**/release/**",
|
|
258
|
+
"**/debug/**",
|
|
259
|
+
"**/publish/**",
|
|
260
|
+
"**/artifacts/**",
|
|
261
|
+
"**/compiled/**",
|
|
262
|
+
"**/_build/**",
|
|
263
|
+
"**/.build/**",
|
|
264
|
+
"**/cmake-build-*/**",
|
|
265
|
+
"**/CMakeFiles/**",
|
|
266
|
+
|
|
267
|
+
// ==========================================
|
|
268
|
+
// FRAMEWORK SPECIFIC BUILD
|
|
269
|
+
// ==========================================
|
|
270
|
+
"**/.next/**",
|
|
271
|
+
"**/.nuxt/**",
|
|
272
|
+
"**/.output/**",
|
|
273
|
+
"**/.svelte-kit/**",
|
|
274
|
+
"**/.astro/**",
|
|
275
|
+
"**/.vercel/**",
|
|
276
|
+
"**/.netlify/**",
|
|
277
|
+
"**/.serverless/**",
|
|
278
|
+
"**/.amplify/**",
|
|
279
|
+
"**/.firebase/**",
|
|
280
|
+
"**/.angular/**",
|
|
281
|
+
"**/.expo/**",
|
|
282
|
+
"**/android/build/**",
|
|
283
|
+
"**/ios/build/**",
|
|
284
|
+
"**/ios/Pods/**",
|
|
285
|
+
"**/.gradle/**",
|
|
286
|
+
"**/.dart_tool/**",
|
|
287
|
+
"**/.pub-cache/**",
|
|
288
|
+
"**/.flutter-plugins/**",
|
|
289
|
+
"**/DerivedData/**",
|
|
290
|
+
"**/xcuserdata/**",
|
|
291
|
+
|
|
292
|
+
// ==========================================
|
|
293
|
+
// VERSION CONTROL
|
|
294
|
+
// ==========================================
|
|
295
|
+
"**/.git/**",
|
|
296
|
+
"**/.svn/**",
|
|
297
|
+
"**/.hg/**",
|
|
298
|
+
"**/.bzr/**",
|
|
299
|
+
"**/.fossil/**",
|
|
300
|
+
|
|
301
|
+
// ==========================================
|
|
302
|
+
// CACHE DIRECTORIES
|
|
303
|
+
// ==========================================
|
|
304
|
+
"**/.cache/**",
|
|
305
|
+
"**/.smart-coding-cache/**",
|
|
306
|
+
"**/__pycache__/**",
|
|
307
|
+
"**/.pytest_cache/**",
|
|
308
|
+
"**/.mypy_cache/**",
|
|
309
|
+
"**/.ruff_cache/**",
|
|
310
|
+
"**/.hypothesis/**",
|
|
311
|
+
"**/.tox/**",
|
|
312
|
+
"**/.nox/**",
|
|
313
|
+
"**/coverage/**",
|
|
314
|
+
"**/.nyc_output/**",
|
|
315
|
+
"**/htmlcov/**",
|
|
316
|
+
"**/.phpunit.cache/**",
|
|
317
|
+
"**/.phpcs-cache/**",
|
|
318
|
+
"**/.php-cs-fixer.cache",
|
|
319
|
+
"**/.eslintcache",
|
|
320
|
+
"**/.stylelintcache",
|
|
321
|
+
"**/.prettiercache",
|
|
322
|
+
"**/.parcel-cache/**",
|
|
323
|
+
"**/.turbo/**",
|
|
324
|
+
"**/.nx/**",
|
|
325
|
+
"**/.wireit/**",
|
|
326
|
+
"**/tsconfig.tsbuildinfo",
|
|
327
|
+
"**/*.tsbuildinfo",
|
|
328
|
+
|
|
329
|
+
// ==========================================
|
|
330
|
+
// VIRTUAL ENVIRONMENTS
|
|
331
|
+
// ==========================================
|
|
332
|
+
"**/venv/**",
|
|
333
|
+
"**/.venv/**",
|
|
334
|
+
"**/env/**",
|
|
335
|
+
"**/ENV/**",
|
|
336
|
+
"**/virtualenv/**",
|
|
337
|
+
"**/.virtualenv/**",
|
|
338
|
+
"**/conda/**",
|
|
339
|
+
"**/.conda/**",
|
|
340
|
+
"**/pipenv/**",
|
|
341
|
+
|
|
342
|
+
// ==========================================
|
|
343
|
+
// LOCK FILES
|
|
344
|
+
// ==========================================
|
|
345
|
+
"**/package-lock.json",
|
|
346
|
+
"**/yarn.lock",
|
|
347
|
+
"**/pnpm-lock.yaml",
|
|
348
|
+
"**/bun.lockb",
|
|
349
|
+
"**/shrinkwrap.yaml",
|
|
350
|
+
"**/composer.lock",
|
|
351
|
+
"**/Gemfile.lock",
|
|
352
|
+
"**/Cargo.lock",
|
|
353
|
+
"**/poetry.lock",
|
|
354
|
+
"**/Pipfile.lock",
|
|
355
|
+
"**/pdm.lock",
|
|
356
|
+
"**/uv.lock",
|
|
357
|
+
"**/go.sum",
|
|
358
|
+
"**/mix.lock",
|
|
359
|
+
"**/pubspec.lock",
|
|
360
|
+
"**/Package.resolved",
|
|
361
|
+
"**/Podfile.lock",
|
|
362
|
+
"**/flake.lock",
|
|
363
|
+
"**/gradle.lockfile",
|
|
364
|
+
"**/buildscript-gradle.lockfile",
|
|
365
|
+
"**/pnpm-workspace.yaml",
|
|
366
|
+
|
|
367
|
+
// ==========================================
|
|
368
|
+
// AUTO-GENERATED CODE
|
|
369
|
+
// ==========================================
|
|
370
|
+
"**/*.d.ts",
|
|
371
|
+
"**/*.d.mts",
|
|
372
|
+
"**/*.d.cts",
|
|
373
|
+
"**/*.generated.*",
|
|
374
|
+
"**/*.auto.*",
|
|
375
|
+
"**/*.g.dart",
|
|
376
|
+
"**/*.freezed.dart",
|
|
377
|
+
"**/*.gr.dart",
|
|
378
|
+
"**/*.gen.*",
|
|
379
|
+
"**/*_generated.*",
|
|
380
|
+
"**/generated/**",
|
|
381
|
+
"**/auto-generated/**",
|
|
382
|
+
"**/autogen/**",
|
|
383
|
+
"**/__generated__/**",
|
|
384
|
+
"**/codegen/**",
|
|
385
|
+
"**/.graphql/**",
|
|
386
|
+
"**/*.pb.go",
|
|
387
|
+
"**/*.pb.cc",
|
|
388
|
+
"**/*.pb.h",
|
|
389
|
+
"**/*.grpc.go",
|
|
390
|
+
"**/*_grpc.pb.go",
|
|
391
|
+
"**/*.swagger.json",
|
|
392
|
+
"**/openapi.json",
|
|
393
|
+
"**/openapi.yaml",
|
|
394
|
+
"**/swagger.json",
|
|
395
|
+
"**/swagger.yaml",
|
|
396
|
+
|
|
397
|
+
// ==========================================
|
|
398
|
+
// MINIFIED & BUNDLED
|
|
399
|
+
// ==========================================
|
|
400
|
+
"**/*.min.js",
|
|
401
|
+
"**/*.min.css",
|
|
402
|
+
"**/*.min.html",
|
|
403
|
+
"**/*.bundle.js",
|
|
404
|
+
"**/*.bundle.css",
|
|
405
|
+
"**/*.chunk.js",
|
|
406
|
+
"**/*.chunk.css",
|
|
407
|
+
"**/*-bundle.js",
|
|
408
|
+
"**/*-chunk.js",
|
|
409
|
+
"**/vendor.js",
|
|
410
|
+
"**/vendors.js",
|
|
411
|
+
"**/polyfills.js",
|
|
412
|
+
"**/runtime.js",
|
|
413
|
+
"**/main.*.js",
|
|
414
|
+
"**/app.*.js",
|
|
415
|
+
"**/commons.*.js",
|
|
416
|
+
"**/framework.*.js",
|
|
417
|
+
"**/_buildManifest.js",
|
|
418
|
+
"**/_ssgManifest.js",
|
|
419
|
+
|
|
420
|
+
// ==========================================
|
|
421
|
+
// SOURCE MAPS
|
|
422
|
+
// ==========================================
|
|
423
|
+
"**/*.map",
|
|
424
|
+
"**/*.js.map",
|
|
425
|
+
"**/*.css.map",
|
|
426
|
+
|
|
427
|
+
// ==========================================
|
|
428
|
+
// TEST FIXTURES & DATA
|
|
429
|
+
// ==========================================
|
|
430
|
+
"**/__fixtures__/**",
|
|
431
|
+
"**/fixtures/**",
|
|
432
|
+
"**/__mocks__/**",
|
|
433
|
+
"**/mocks/**",
|
|
434
|
+
"**/__snapshots__/**",
|
|
435
|
+
"**/snapshots/**",
|
|
436
|
+
"**/__tests__/data/**",
|
|
437
|
+
"**/test-data/**",
|
|
438
|
+
"**/testdata/**",
|
|
439
|
+
"**/test_data/**",
|
|
440
|
+
"**/test-fixtures/**",
|
|
441
|
+
"**/test_fixtures/**",
|
|
442
|
+
"**/spec/fixtures/**",
|
|
443
|
+
"**/cypress/fixtures/**",
|
|
444
|
+
"**/playwright/fixtures/**",
|
|
445
|
+
|
|
446
|
+
// ==========================================
|
|
447
|
+
// TEST OUTPUT
|
|
448
|
+
// ==========================================
|
|
449
|
+
"**/test-results/**",
|
|
450
|
+
"**/test-output/**",
|
|
451
|
+
"**/test_output/**",
|
|
452
|
+
"**/playwright-report/**",
|
|
453
|
+
"**/allure-results/**",
|
|
454
|
+
"**/allure-report/**",
|
|
455
|
+
"**/cypress/videos/**",
|
|
456
|
+
"**/cypress/screenshots/**",
|
|
457
|
+
"**/reports/**",
|
|
458
|
+
"**/.reports/**",
|
|
459
|
+
"**/junit/**",
|
|
460
|
+
"**/xunit/**",
|
|
461
|
+
|
|
462
|
+
// ==========================================
|
|
463
|
+
// CI/CD CONFIGURATION
|
|
464
|
+
// ==========================================
|
|
465
|
+
"**/.github/**",
|
|
466
|
+
"**/.gitlab/**",
|
|
467
|
+
"**/.gitlab-ci.yml",
|
|
468
|
+
"**/.circleci/**",
|
|
469
|
+
"**/.travis.yml",
|
|
470
|
+
"**/azure-pipelines.yml",
|
|
471
|
+
"**/Jenkinsfile",
|
|
472
|
+
"**/.drone.yml",
|
|
473
|
+
"**/.woodpecker.yml",
|
|
474
|
+
"**/bitbucket-pipelines.yml",
|
|
475
|
+
"**/cloudbuild.yaml",
|
|
476
|
+
"**/appveyor.yml",
|
|
477
|
+
"**/buildkite/**",
|
|
478
|
+
"**/.buildkite/**",
|
|
479
|
+
"**/taskcluster/**",
|
|
480
|
+
"**/wercker.yml",
|
|
481
|
+
"**/codeship-*.yml",
|
|
482
|
+
"**/.semaphore/**",
|
|
483
|
+
"**/buddy.yml",
|
|
484
|
+
"**/codefresh.yml",
|
|
485
|
+
"**/.harness/**",
|
|
486
|
+
"**/.argo/**",
|
|
487
|
+
"**/skaffold.yaml",
|
|
488
|
+
|
|
489
|
+
// ==========================================
|
|
490
|
+
// IDE & EDITOR
|
|
491
|
+
// ==========================================
|
|
492
|
+
"**/.vscode/**",
|
|
493
|
+
"**/.idea/**",
|
|
494
|
+
"**/.vs/**",
|
|
495
|
+
"**/.eclipse/**",
|
|
496
|
+
"**/.settings/**",
|
|
497
|
+
"**/.project",
|
|
498
|
+
"**/.classpath",
|
|
499
|
+
"**/*.sublime-project",
|
|
500
|
+
"**/*.sublime-workspace",
|
|
501
|
+
"**/.atom/**",
|
|
502
|
+
"**/.fleet/**",
|
|
503
|
+
"**/.zed/**",
|
|
504
|
+
"**/*.code-workspace",
|
|
505
|
+
"**/.devcontainer/**",
|
|
506
|
+
|
|
507
|
+
// ==========================================
|
|
508
|
+
// DOCUMENTATION (non-code)
|
|
509
|
+
// ==========================================
|
|
510
|
+
"**/CHANGELOG*",
|
|
511
|
+
"**/CHANGES*",
|
|
512
|
+
"**/HISTORY*",
|
|
513
|
+
"**/LICENSE*",
|
|
514
|
+
"**/LICENCE*",
|
|
515
|
+
"**/COPYING*",
|
|
516
|
+
"**/CONTRIBUTING*",
|
|
517
|
+
"**/CONTRIBUTORS*",
|
|
518
|
+
"**/AUTHORS*",
|
|
519
|
+
"**/SECURITY*",
|
|
520
|
+
"**/CODE_OF_CONDUCT*",
|
|
521
|
+
"**/CODEOWNERS",
|
|
522
|
+
"**/OWNERS",
|
|
523
|
+
"**/MAINTAINERS*",
|
|
524
|
+
"**/README*",
|
|
525
|
+
"**/ROADMAP*",
|
|
526
|
+
"**/ARCHITECTURE*",
|
|
527
|
+
"**/DESIGN*",
|
|
528
|
+
"**/docs/**",
|
|
529
|
+
"**/documentation/**",
|
|
530
|
+
"**/.docsify/**",
|
|
531
|
+
"**/site/**",
|
|
532
|
+
"**/_site/**",
|
|
533
|
+
"**/.docusaurus/**",
|
|
534
|
+
"**/docusaurus.config.*",
|
|
535
|
+
"**/.vuepress/**",
|
|
536
|
+
"**/.vitepress/**",
|
|
537
|
+
"**/mkdocs.yml",
|
|
538
|
+
"**/book/**",
|
|
539
|
+
"**/man/**",
|
|
540
|
+
"**/manpages/**",
|
|
541
|
+
"**/wiki/**",
|
|
542
|
+
"**/api-docs/**",
|
|
543
|
+
"**/apidocs/**",
|
|
544
|
+
|
|
545
|
+
// ==========================================
|
|
546
|
+
// CONFIG FILES (not code)
|
|
547
|
+
// ==========================================
|
|
548
|
+
// TypeScript/JavaScript
|
|
549
|
+
"**/tsconfig*.json",
|
|
550
|
+
"**/jsconfig*.json",
|
|
551
|
+
"**/.eslintrc*",
|
|
552
|
+
"**/.eslintignore",
|
|
553
|
+
"**/.prettierrc*",
|
|
554
|
+
"**/.prettierignore",
|
|
555
|
+
"**/.babelrc*",
|
|
556
|
+
"**/babel.config.*",
|
|
557
|
+
"**/.swcrc",
|
|
558
|
+
"**/.browserslistrc",
|
|
559
|
+
"**/browserslist",
|
|
560
|
+
"**/.editorconfig",
|
|
561
|
+
"**/.npmrc",
|
|
562
|
+
"**/.nvmrc",
|
|
563
|
+
"**/.node-version",
|
|
564
|
+
"**/.yarnrc*",
|
|
565
|
+
"**/.pnpmfile.cjs",
|
|
566
|
+
"**/lerna.json",
|
|
567
|
+
"**/nx.json",
|
|
568
|
+
"**/turbo.json",
|
|
569
|
+
"**/rush.json",
|
|
570
|
+
// Python
|
|
571
|
+
"**/pyproject.toml",
|
|
572
|
+
"**/setup.cfg",
|
|
573
|
+
"**/setup.py",
|
|
574
|
+
"**/pytest.ini",
|
|
575
|
+
"**/tox.ini",
|
|
576
|
+
"**/noxfile.py",
|
|
577
|
+
"**/.flake8",
|
|
578
|
+
"**/.pylintrc",
|
|
579
|
+
"**/pylintrc",
|
|
580
|
+
"**/.bandit",
|
|
581
|
+
"**/.coveragerc",
|
|
582
|
+
"**/mypy.ini",
|
|
583
|
+
"**/.mypy.ini",
|
|
584
|
+
"**/pyrightconfig.json",
|
|
585
|
+
"**/pycodestyle.cfg",
|
|
586
|
+
"**/MANIFEST.in",
|
|
587
|
+
// Ruby
|
|
588
|
+
"**/.rubocop*.yml",
|
|
589
|
+
"**/.ruby-version",
|
|
590
|
+
"**/.ruby-gemset",
|
|
591
|
+
"**/.rvmrc",
|
|
592
|
+
"**/Rakefile",
|
|
593
|
+
// PHP
|
|
594
|
+
"**/phpcs.xml*",
|
|
595
|
+
"**/phpstan.neon*",
|
|
596
|
+
"**/psalm.xml*",
|
|
597
|
+
"**/phpunit.xml*",
|
|
598
|
+
// Java/Kotlin
|
|
599
|
+
"**/pom.xml",
|
|
600
|
+
"**/build.gradle*",
|
|
601
|
+
"**/settings.gradle*",
|
|
602
|
+
"**/gradle.properties",
|
|
603
|
+
"**/gradlew*",
|
|
604
|
+
"**/.mvn/**",
|
|
605
|
+
"**/mvnw*",
|
|
606
|
+
"**/checkstyle.xml",
|
|
607
|
+
"**/spotbugs.xml",
|
|
608
|
+
// Go
|
|
609
|
+
"**/.golangci.yml",
|
|
610
|
+
"**/staticcheck.conf",
|
|
611
|
+
// Rust
|
|
612
|
+
"**/rustfmt.toml",
|
|
613
|
+
"**/clippy.toml",
|
|
614
|
+
"**/rust-toolchain*",
|
|
615
|
+
"**/.cargo/config*",
|
|
616
|
+
// General
|
|
617
|
+
"**/.gitignore",
|
|
618
|
+
"**/.gitattributes",
|
|
619
|
+
"**/.gitmodules",
|
|
620
|
+
"**/.mailmap",
|
|
621
|
+
"**/.gitkeep",
|
|
622
|
+
"**/.keep",
|
|
623
|
+
"**/.dockerignore",
|
|
624
|
+
"**/.helmignore",
|
|
625
|
+
"**/Dockerfile*",
|
|
626
|
+
"**/docker-compose*.yml",
|
|
627
|
+
"**/compose*.yml",
|
|
628
|
+
"**/*.dockerfile",
|
|
629
|
+
"**/Makefile",
|
|
630
|
+
"**/makefile",
|
|
631
|
+
"**/GNUmakefile",
|
|
632
|
+
"**/Procfile",
|
|
633
|
+
"**/Vagrantfile",
|
|
634
|
+
|
|
635
|
+
// ==========================================
|
|
636
|
+
// ENVIRONMENT & SECRETS
|
|
637
|
+
// ==========================================
|
|
638
|
+
"**/.env*",
|
|
639
|
+
"**/env.*",
|
|
640
|
+
"**/*.env",
|
|
641
|
+
"**/secrets.*",
|
|
642
|
+
"**/credentials.*",
|
|
643
|
+
"**/service-account*.json",
|
|
644
|
+
"**/gcloud/**",
|
|
645
|
+
"**/.aws/**",
|
|
646
|
+
"**/.azure/**",
|
|
647
|
+
"**/.kube/**",
|
|
648
|
+
"**/.docker/**",
|
|
649
|
+
"**/id_rsa*",
|
|
650
|
+
"**/id_ed25519*",
|
|
651
|
+
"**/id_ecdsa*",
|
|
652
|
+
"**/*.pem",
|
|
653
|
+
"**/*.key",
|
|
654
|
+
"**/*.crt",
|
|
655
|
+
"**/*.cer",
|
|
656
|
+
"**/*.p12",
|
|
657
|
+
"**/*.pfx",
|
|
658
|
+
"**/*.keystore",
|
|
659
|
+
"**/*.jks",
|
|
660
|
+
"**/*.gpg",
|
|
661
|
+
"**/*.asc",
|
|
662
|
+
"**/.netrc",
|
|
663
|
+
"**/.npmrc",
|
|
664
|
+
"**/.pypirc",
|
|
665
|
+
|
|
666
|
+
// ==========================================
|
|
667
|
+
// LOGS & TEMPORARY
|
|
668
|
+
// ==========================================
|
|
669
|
+
"**/*.log",
|
|
670
|
+
"**/logs/**",
|
|
671
|
+
"**/.logs/**",
|
|
672
|
+
"**/log/**",
|
|
673
|
+
"**/tmp/**",
|
|
674
|
+
"**/temp/**",
|
|
675
|
+
"**/.tmp/**",
|
|
676
|
+
"**/.temp/**",
|
|
677
|
+
"**/*.tmp",
|
|
678
|
+
"**/*.temp",
|
|
679
|
+
"**/*.bak",
|
|
680
|
+
"**/*.backup",
|
|
681
|
+
"**/*.swp",
|
|
682
|
+
"**/*.swo",
|
|
683
|
+
"**/*~",
|
|
684
|
+
"**/#*#",
|
|
685
|
+
"**/.#*",
|
|
686
|
+
|
|
687
|
+
// ==========================================
|
|
688
|
+
// OS FILES
|
|
689
|
+
// ==========================================
|
|
690
|
+
"**/.DS_Store",
|
|
691
|
+
"**/Thumbs.db",
|
|
692
|
+
"**/desktop.ini",
|
|
693
|
+
"**/$RECYCLE.BIN/**",
|
|
694
|
+
"**/._*",
|
|
695
|
+
|
|
696
|
+
// ==========================================
|
|
697
|
+
// BINARY & MEDIA (by extension)
|
|
698
|
+
// ==========================================
|
|
699
|
+
// Images
|
|
700
|
+
"**/*.png",
|
|
701
|
+
"**/*.jpg",
|
|
702
|
+
"**/*.jpeg",
|
|
703
|
+
"**/*.gif",
|
|
704
|
+
"**/*.ico",
|
|
705
|
+
"**/*.bmp",
|
|
706
|
+
"**/*.webp",
|
|
707
|
+
"**/*.svg",
|
|
708
|
+
"**/*.tiff",
|
|
709
|
+
"**/*.tif",
|
|
710
|
+
"**/*.psd",
|
|
711
|
+
"**/*.ai",
|
|
712
|
+
"**/*.eps",
|
|
713
|
+
"**/*.raw",
|
|
714
|
+
"**/*.heic",
|
|
715
|
+
"**/*.heif",
|
|
716
|
+
"**/*.avif",
|
|
717
|
+
"**/*.jxl",
|
|
718
|
+
"**/*.xcf",
|
|
719
|
+
// Fonts
|
|
720
|
+
"**/*.woff",
|
|
721
|
+
"**/*.woff2",
|
|
722
|
+
"**/*.ttf",
|
|
723
|
+
"**/*.otf",
|
|
724
|
+
"**/*.eot",
|
|
725
|
+
"**/*.fon",
|
|
726
|
+
// Audio
|
|
727
|
+
"**/*.mp3",
|
|
728
|
+
"**/*.wav",
|
|
729
|
+
"**/*.ogg",
|
|
730
|
+
"**/*.m4a",
|
|
731
|
+
"**/*.aac",
|
|
732
|
+
"**/*.flac",
|
|
733
|
+
"**/*.wma",
|
|
734
|
+
"**/*.aiff",
|
|
735
|
+
"**/*.opus",
|
|
736
|
+
// Video
|
|
737
|
+
"**/*.mp4",
|
|
738
|
+
"**/*.avi",
|
|
739
|
+
"**/*.mov",
|
|
740
|
+
"**/*.mkv",
|
|
741
|
+
"**/*.flv",
|
|
742
|
+
"**/*.wmv",
|
|
743
|
+
"**/*.webm",
|
|
744
|
+
"**/*.m4v",
|
|
745
|
+
"**/*.mpg",
|
|
746
|
+
"**/*.mpeg",
|
|
747
|
+
"**/*.3gp",
|
|
748
|
+
// Documents
|
|
749
|
+
"**/*.pdf",
|
|
750
|
+
"**/*.doc",
|
|
751
|
+
"**/*.docx",
|
|
752
|
+
"**/*.xls",
|
|
753
|
+
"**/*.xlsx",
|
|
754
|
+
"**/*.ppt",
|
|
755
|
+
"**/*.pptx",
|
|
756
|
+
"**/*.odt",
|
|
757
|
+
"**/*.ods",
|
|
758
|
+
"**/*.odp",
|
|
759
|
+
"**/*.rtf",
|
|
760
|
+
"**/*.epub",
|
|
761
|
+
// Archives
|
|
762
|
+
"**/*.zip",
|
|
763
|
+
"**/*.tar",
|
|
764
|
+
"**/*.gz",
|
|
765
|
+
"**/*.tgz",
|
|
766
|
+
"**/*.rar",
|
|
767
|
+
"**/*.7z",
|
|
768
|
+
"**/*.bz2",
|
|
769
|
+
"**/*.xz",
|
|
770
|
+
"**/*.lz",
|
|
771
|
+
"**/*.zst",
|
|
772
|
+
// Databases
|
|
773
|
+
"**/*.sqlite",
|
|
774
|
+
"**/*.sqlite3",
|
|
775
|
+
"**/*.db",
|
|
776
|
+
"**/*.mdb",
|
|
777
|
+
"**/*.rdb",
|
|
778
|
+
// Compiled/Binary
|
|
779
|
+
"**/*.so",
|
|
780
|
+
"**/*.dylib",
|
|
781
|
+
"**/*.dll",
|
|
782
|
+
"**/*.exe",
|
|
783
|
+
"**/*.o",
|
|
784
|
+
"**/*.a",
|
|
785
|
+
"**/*.lib",
|
|
786
|
+
"**/*.class",
|
|
787
|
+
"**/*.jar",
|
|
788
|
+
"**/*.war",
|
|
789
|
+
"**/*.ear",
|
|
790
|
+
"**/*.pyc",
|
|
791
|
+
"**/*.pyo",
|
|
792
|
+
"**/*.whl",
|
|
793
|
+
"**/*.egg",
|
|
794
|
+
"**/*.beam",
|
|
795
|
+
"**/*.wasm",
|
|
796
|
+
// ML/Data
|
|
797
|
+
"**/*.h5",
|
|
798
|
+
"**/*.hdf5",
|
|
799
|
+
"**/*.pkl",
|
|
800
|
+
"**/*.pickle",
|
|
801
|
+
"**/*.pt",
|
|
802
|
+
"**/*.pth",
|
|
803
|
+
"**/*.onnx",
|
|
804
|
+
"**/*.pb",
|
|
805
|
+
"**/*.tflite",
|
|
806
|
+
"**/*.mlmodel",
|
|
807
|
+
"**/*.safetensors",
|
|
808
|
+
"**/*.gguf",
|
|
809
|
+
"**/*.parquet",
|
|
810
|
+
"**/*.arrow",
|
|
811
|
+
"**/*.feather",
|
|
812
|
+
"**/*.npy",
|
|
813
|
+
"**/*.npz",
|
|
814
|
+
|
|
815
|
+
// ==========================================
|
|
816
|
+
// SPECIFIC FRAMEWORK PATTERNS
|
|
817
|
+
// ==========================================
|
|
818
|
+
// Rails
|
|
819
|
+
"**/schema.rb",
|
|
820
|
+
"**/structure.sql",
|
|
821
|
+
// Django
|
|
822
|
+
"**/migrations/0*.py",
|
|
823
|
+
"**/migrations/__init__.py",
|
|
824
|
+
// Laravel
|
|
825
|
+
"**/storage/**",
|
|
826
|
+
"**/bootstrap/cache/**"
|
|
827
|
+
],
|
|
828
|
+
chunkSize: 25, // Lines per chunk (larger = fewer embeddings = faster indexing)
|
|
829
|
+
chunkOverlap: 5, // Overlap between chunks for context continuity
|
|
830
|
+
batchSize: 100,
|
|
831
|
+
maxFileSize: 1048576, // 1MB - skip files larger than this
|
|
832
|
+
maxResults: 5,
|
|
833
|
+
enableCache: true,
|
|
834
|
+
cacheDirectory: "./.smart-coding-cache",
|
|
835
|
+
watchFiles: false,
|
|
836
|
+
verbose: false,
|
|
837
|
+
vectorStoreProvider: "sqlite", // "sqlite" or "milvus"
|
|
838
|
+
milvusAddress: "",
|
|
839
|
+
milvusToken: "",
|
|
840
|
+
milvusDatabase: "default",
|
|
841
|
+
milvusCollection: "smart_coding_embeddings",
|
|
842
|
+
workerThreads: "auto", // "auto" = CPU cores - 1, or set a number
|
|
843
|
+
embeddingProvider: "local", // "local", "gemini", "openai", "openai-compatible", or "vertex"
|
|
844
|
+
embeddingModel: "nomic-ai/nomic-embed-text-v1.5",
|
|
845
|
+
embeddingDimension: 128, // MRL dimension: 64, 128, 256, 512, 768 (changed from 256 to 128 for better performance)
|
|
846
|
+
device: "auto", // "cpu", "webgpu", or "auto"
|
|
847
|
+
geminiApiKey: "",
|
|
848
|
+
geminiModel: "gemini-embedding-001",
|
|
849
|
+
geminiBaseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
850
|
+
embeddingApiKey: "",
|
|
851
|
+
embeddingBaseURL: "",
|
|
852
|
+
vertexProject: "",
|
|
853
|
+
vertexLocation: "us-central1",
|
|
854
|
+
geminiDimensions: 768,
|
|
855
|
+
geminiBatchSize: 24,
|
|
856
|
+
geminiBatchFlushMs: 12,
|
|
857
|
+
geminiMaxRetries: 3,
|
|
858
|
+
chunkingMode: "smart", // "smart", "ast", or "line"
|
|
859
|
+
semanticWeight: 0.7,
|
|
860
|
+
exactMatchBoost: 1.5,
|
|
861
|
+
smartIndexing: true,
|
|
862
|
+
|
|
863
|
+
// Resource throttling (balanced performance/responsiveness)
|
|
864
|
+
maxCpuPercent: 50, // Max CPU usage during indexing (default: 50%)
|
|
865
|
+
batchDelay: 10, // Delay between batches in ms (default: 10ms)
|
|
866
|
+
maxWorkers: 'auto', // Max worker threads ('auto' = 50% of cores, or specific number)
|
|
867
|
+
|
|
868
|
+
// Startup behavior
|
|
869
|
+
autoIndexDelay: 5000, // Delay before background indexing starts (ms), false = disabled
|
|
870
|
+
|
|
871
|
+
// Progressive indexing
|
|
872
|
+
incrementalSaveInterval: 5, // Save to cache every N batches
|
|
873
|
+
allowPartialSearch: true // Allow searches while indexing is in progress
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
let config = { ...DEFAULT_CONFIG };
|
|
877
|
+
|
|
878
|
+
export async function loadConfig(workspaceDir = null) {
|
|
879
|
+
try {
|
|
880
|
+
// Determine the base directory for configuration
|
|
881
|
+
let baseDir;
|
|
882
|
+
let configPath;
|
|
883
|
+
|
|
884
|
+
if (workspaceDir) {
|
|
885
|
+
// Workspace mode: load config from workspace root
|
|
886
|
+
baseDir = path.resolve(workspaceDir);
|
|
887
|
+
configPath = path.join(baseDir, "config.json");
|
|
888
|
+
console.error(`[Config] Workspace mode: ${baseDir}`);
|
|
889
|
+
} else {
|
|
890
|
+
// Server mode: load config from server directory
|
|
891
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
892
|
+
baseDir = path.resolve(scriptDir, '..');
|
|
893
|
+
configPath = path.join(baseDir, "config.json");
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
let userConfig = {};
|
|
897
|
+
try {
|
|
898
|
+
const configData = await fs.readFile(configPath, "utf-8");
|
|
899
|
+
userConfig = JSON.parse(configData);
|
|
900
|
+
} catch (configError) {
|
|
901
|
+
if (workspaceDir) {
|
|
902
|
+
console.error(`[Config] No config.json in workspace, using defaults`);
|
|
903
|
+
} else {
|
|
904
|
+
console.error(`[Config] No config.json found: ${configError.message}`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
config = { ...DEFAULT_CONFIG, ...userConfig };
|
|
909
|
+
|
|
910
|
+
// Set workspace-specific directories
|
|
911
|
+
if (workspaceDir) {
|
|
912
|
+
config.searchDirectory = baseDir;
|
|
913
|
+
config.cacheDirectory = path.join(baseDir, ".smart-coding-cache");
|
|
914
|
+
} else {
|
|
915
|
+
config.searchDirectory = path.resolve(baseDir, config.searchDirectory);
|
|
916
|
+
config.cacheDirectory = path.resolve(baseDir, config.cacheDirectory);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// Smart project detection
|
|
920
|
+
if (config.smartIndexing !== false) {
|
|
921
|
+
const detector = new ProjectDetector(config.searchDirectory);
|
|
922
|
+
const detectedTypes = await detector.detectProjectTypes();
|
|
923
|
+
const smartPatterns = detector.getSmartIgnorePatterns();
|
|
924
|
+
|
|
925
|
+
// Merge baseline default patterns with smart patterns.
|
|
926
|
+
// Smart patterns always include IGNORE_PATTERNS.common, and add type-specific
|
|
927
|
+
// ignores when project markers are detected.
|
|
928
|
+
// User patterns are appended so users can extend behavior.
|
|
929
|
+
const userPatterns = userConfig.excludePatterns || [];
|
|
930
|
+
config.excludePatterns = [
|
|
931
|
+
...DEFAULT_CONFIG.excludePatterns,
|
|
932
|
+
...smartPatterns,
|
|
933
|
+
...userPatterns
|
|
934
|
+
];
|
|
935
|
+
config.excludePatterns = [...new Set(config.excludePatterns)];
|
|
936
|
+
|
|
937
|
+
if (detectedTypes.length > 0) {
|
|
938
|
+
console.error(`[Config] Smart indexing: ${detectedTypes.join(', ')}`);
|
|
939
|
+
} else {
|
|
940
|
+
console.error("[Config] No project markers detected, applying common smart patterns");
|
|
941
|
+
}
|
|
942
|
+
console.error(`[Config] Applied ${smartPatterns.length} smart ignore patterns`);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
console.error("[Config] Loaded configuration from config.json");
|
|
946
|
+
} catch (error) {
|
|
947
|
+
console.error("[Config] Using default configuration (config.json not found or invalid)");
|
|
948
|
+
console.error(`[Config] Error: ${error.message}`);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// Apply environment variable overrides (prefix: SMART_CODING_) with validation
|
|
952
|
+
if (process.env.SMART_CODING_VERBOSE !== undefined) {
|
|
953
|
+
const value = process.env.SMART_CODING_VERBOSE;
|
|
954
|
+
if (value === 'true' || value === 'false') {
|
|
955
|
+
config.verbose = value === 'true';
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
if (process.env.SMART_CODING_BATCH_SIZE !== undefined) {
|
|
960
|
+
const value = parseInt(process.env.SMART_CODING_BATCH_SIZE, 10);
|
|
961
|
+
if (!isNaN(value) && value > 0 && value <= 1000) {
|
|
962
|
+
config.batchSize = value;
|
|
963
|
+
} else {
|
|
964
|
+
console.error(`[Config] Invalid SMART_CODING_BATCH_SIZE: ${process.env.SMART_CODING_BATCH_SIZE}, using default`);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
if (process.env.SMART_CODING_MAX_FILE_SIZE !== undefined) {
|
|
969
|
+
const value = parseInt(process.env.SMART_CODING_MAX_FILE_SIZE, 10);
|
|
970
|
+
if (!isNaN(value) && value > 0) {
|
|
971
|
+
config.maxFileSize = value;
|
|
972
|
+
} else {
|
|
973
|
+
console.error(`[Config] Invalid SMART_CODING_MAX_FILE_SIZE: ${process.env.SMART_CODING_MAX_FILE_SIZE}, using default`);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
if (process.env.SMART_CODING_CHUNK_SIZE !== undefined) {
|
|
978
|
+
const value = parseInt(process.env.SMART_CODING_CHUNK_SIZE, 10);
|
|
979
|
+
if (!isNaN(value) && value > 0 && value <= 100) {
|
|
980
|
+
config.chunkSize = value;
|
|
981
|
+
} else {
|
|
982
|
+
console.error(`[Config] Invalid SMART_CODING_CHUNK_SIZE: ${process.env.SMART_CODING_CHUNK_SIZE}, using default`);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (process.env.SMART_CODING_MAX_RESULTS !== undefined) {
|
|
987
|
+
const value = parseInt(process.env.SMART_CODING_MAX_RESULTS, 10);
|
|
988
|
+
if (!isNaN(value) && value > 0 && value <= 100) {
|
|
989
|
+
config.maxResults = value;
|
|
990
|
+
} else {
|
|
991
|
+
console.error(`[Config] Invalid SMART_CODING_MAX_RESULTS: ${process.env.SMART_CODING_MAX_RESULTS}, using default`);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
if (process.env.SMART_CODING_SMART_INDEXING !== undefined) {
|
|
996
|
+
const value = process.env.SMART_CODING_SMART_INDEXING;
|
|
997
|
+
if (value === 'true' || value === 'false') {
|
|
998
|
+
config.smartIndexing = value === 'true';
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
if (process.env.SMART_CODING_WATCH_FILES !== undefined) {
|
|
1003
|
+
const value = process.env.SMART_CODING_WATCH_FILES;
|
|
1004
|
+
if (value === 'true' || value === 'false') {
|
|
1005
|
+
config.watchFiles = value === 'true';
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
if (process.env.SMART_CODING_VECTOR_STORE_PROVIDER !== undefined) {
|
|
1010
|
+
const value = process.env.SMART_CODING_VECTOR_STORE_PROVIDER.trim().toLowerCase();
|
|
1011
|
+
const validProviders = ['sqlite', 'milvus'];
|
|
1012
|
+
if (validProviders.includes(value)) {
|
|
1013
|
+
config.vectorStoreProvider = value;
|
|
1014
|
+
console.error(`[Config] Using vector store provider: ${value}`);
|
|
1015
|
+
} else {
|
|
1016
|
+
console.error(`[Config] Invalid SMART_CODING_VECTOR_STORE_PROVIDER: ${value}, using default (must be 'sqlite' or 'milvus')`);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
if (process.env.SMART_CODING_MILVUS_ADDRESS !== undefined) {
|
|
1021
|
+
const value = process.env.SMART_CODING_MILVUS_ADDRESS.trim();
|
|
1022
|
+
if (value.length > 0) {
|
|
1023
|
+
config.milvusAddress = value;
|
|
1024
|
+
console.error(`[Config] Milvus address configured`);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
if (process.env.SMART_CODING_MILVUS_TOKEN !== undefined) {
|
|
1029
|
+
config.milvusToken = process.env.SMART_CODING_MILVUS_TOKEN.trim();
|
|
1030
|
+
console.error(`[Config] Milvus token configured`);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (process.env.SMART_CODING_MILVUS_DATABASE !== undefined) {
|
|
1034
|
+
const value = process.env.SMART_CODING_MILVUS_DATABASE.trim();
|
|
1035
|
+
if (value.length > 0) {
|
|
1036
|
+
config.milvusDatabase = value;
|
|
1037
|
+
console.error(`[Config] Milvus database: ${value}`);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (process.env.SMART_CODING_MILVUS_COLLECTION !== undefined) {
|
|
1042
|
+
const value = process.env.SMART_CODING_MILVUS_COLLECTION.trim();
|
|
1043
|
+
if (value.length > 0) {
|
|
1044
|
+
config.milvusCollection = value;
|
|
1045
|
+
console.error(`[Config] Milvus collection: ${value}`);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
if (process.env.SMART_CODING_SEMANTIC_WEIGHT !== undefined) {
|
|
1050
|
+
const value = parseFloat(process.env.SMART_CODING_SEMANTIC_WEIGHT);
|
|
1051
|
+
if (!isNaN(value) && value >= 0 && value <= 1) {
|
|
1052
|
+
config.semanticWeight = value;
|
|
1053
|
+
} else {
|
|
1054
|
+
console.error(`[Config] Invalid SMART_CODING_SEMANTIC_WEIGHT: ${process.env.SMART_CODING_SEMANTIC_WEIGHT}, using default (must be 0-1)`);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if (process.env.SMART_CODING_EXACT_MATCH_BOOST !== undefined) {
|
|
1059
|
+
const value = parseFloat(process.env.SMART_CODING_EXACT_MATCH_BOOST);
|
|
1060
|
+
if (!isNaN(value) && value >= 0) {
|
|
1061
|
+
config.exactMatchBoost = value;
|
|
1062
|
+
} else {
|
|
1063
|
+
console.error(`[Config] Invalid SMART_CODING_EXACT_MATCH_BOOST: ${process.env.SMART_CODING_EXACT_MATCH_BOOST}, using default`);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (process.env.SMART_CODING_EMBEDDING_MODEL !== undefined) {
|
|
1068
|
+
const value = process.env.SMART_CODING_EMBEDDING_MODEL.trim();
|
|
1069
|
+
if (value.length > 0) {
|
|
1070
|
+
config.embeddingModel = value;
|
|
1071
|
+
console.error(`[Config] Using custom embedding model: ${value}`);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
if (process.env.SMART_CODING_EMBEDDING_PROVIDER !== undefined) {
|
|
1076
|
+
const value = process.env.SMART_CODING_EMBEDDING_PROVIDER.trim().toLowerCase();
|
|
1077
|
+
const validProviders = ['local', 'gemini', 'openai', 'openai-compatible', 'vertex'];
|
|
1078
|
+
if (validProviders.includes(value)) {
|
|
1079
|
+
config.embeddingProvider = value;
|
|
1080
|
+
console.error(`[Config] Using embedding provider: ${value}`);
|
|
1081
|
+
} else {
|
|
1082
|
+
console.error(
|
|
1083
|
+
`[Config] Invalid SMART_CODING_EMBEDDING_PROVIDER: ${value}, using default (must be one of ${validProviders.join(", ")})`
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (process.env.SMART_CODING_EMBEDDING_API_KEY !== undefined) {
|
|
1089
|
+
const value = process.env.SMART_CODING_EMBEDDING_API_KEY.trim();
|
|
1090
|
+
if (value.length > 0) {
|
|
1091
|
+
config.embeddingApiKey = value;
|
|
1092
|
+
console.error("[Config] Embedding API key configured");
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
if (process.env.SMART_CODING_EMBEDDING_BASE_URL !== undefined) {
|
|
1097
|
+
const value = process.env.SMART_CODING_EMBEDDING_BASE_URL.trim();
|
|
1098
|
+
if (value.length > 0) {
|
|
1099
|
+
config.embeddingBaseURL = value;
|
|
1100
|
+
console.error("[Config] Embedding base URL configured");
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
if (process.env.SMART_CODING_GEMINI_API_KEY !== undefined) {
|
|
1105
|
+
const value = process.env.SMART_CODING_GEMINI_API_KEY.trim();
|
|
1106
|
+
if (value.length > 0) {
|
|
1107
|
+
config.geminiApiKey = value;
|
|
1108
|
+
console.error(`[Config] Gemini API key configured`);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
if (process.env.SMART_CODING_GEMINI_MODEL !== undefined) {
|
|
1113
|
+
const value = process.env.SMART_CODING_GEMINI_MODEL.trim();
|
|
1114
|
+
if (value.length > 0) {
|
|
1115
|
+
config.geminiModel = value;
|
|
1116
|
+
console.error(`[Config] Gemini model: ${value}`);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (process.env.SMART_CODING_GEMINI_BASE_URL !== undefined) {
|
|
1121
|
+
const value = process.env.SMART_CODING_GEMINI_BASE_URL.trim();
|
|
1122
|
+
if (value.length > 0) {
|
|
1123
|
+
config.geminiBaseURL = value;
|
|
1124
|
+
console.error(`[Config] Gemini base URL configured`);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
if (process.env.SMART_CODING_VERTEX_PROJECT !== undefined) {
|
|
1129
|
+
const value = process.env.SMART_CODING_VERTEX_PROJECT.trim();
|
|
1130
|
+
if (value.length > 0) {
|
|
1131
|
+
config.vertexProject = value;
|
|
1132
|
+
console.error("[Config] Vertex project configured");
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
if (process.env.SMART_CODING_VERTEX_LOCATION !== undefined) {
|
|
1137
|
+
const value = process.env.SMART_CODING_VERTEX_LOCATION.trim();
|
|
1138
|
+
if (value.length > 0) {
|
|
1139
|
+
config.vertexLocation = value;
|
|
1140
|
+
console.error(`[Config] Vertex location: ${value}`);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
if (process.env.SMART_CODING_GEMINI_DIMENSIONS !== undefined) {
|
|
1145
|
+
const value = parseInt(process.env.SMART_CODING_GEMINI_DIMENSIONS, 10);
|
|
1146
|
+
if (!isNaN(value) && value > 0 && value <= 3072) {
|
|
1147
|
+
config.geminiDimensions = value;
|
|
1148
|
+
console.error(`[Config] Gemini dimensions: ${value}`);
|
|
1149
|
+
} else {
|
|
1150
|
+
console.error(`[Config] Invalid SMART_CODING_GEMINI_DIMENSIONS: ${process.env.SMART_CODING_GEMINI_DIMENSIONS}, using default (must be 1-3072)`);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
if (process.env.SMART_CODING_GEMINI_BATCH_SIZE !== undefined) {
|
|
1155
|
+
const value = parseInt(process.env.SMART_CODING_GEMINI_BATCH_SIZE, 10);
|
|
1156
|
+
if (!isNaN(value) && value >= 1 && value <= 128) {
|
|
1157
|
+
config.geminiBatchSize = value;
|
|
1158
|
+
console.error(`[Config] Gemini batch size: ${value}`);
|
|
1159
|
+
} else {
|
|
1160
|
+
console.error(`[Config] Invalid SMART_CODING_GEMINI_BATCH_SIZE: ${process.env.SMART_CODING_GEMINI_BATCH_SIZE}, using default (must be 1-128)`);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (process.env.SMART_CODING_GEMINI_BATCH_FLUSH_MS !== undefined) {
|
|
1165
|
+
const value = parseInt(process.env.SMART_CODING_GEMINI_BATCH_FLUSH_MS, 10);
|
|
1166
|
+
if (!isNaN(value) && value >= 0 && value <= 1000) {
|
|
1167
|
+
config.geminiBatchFlushMs = value;
|
|
1168
|
+
console.error(`[Config] Gemini batch flush: ${value}ms`);
|
|
1169
|
+
} else {
|
|
1170
|
+
console.error(`[Config] Invalid SMART_CODING_GEMINI_BATCH_FLUSH_MS: ${process.env.SMART_CODING_GEMINI_BATCH_FLUSH_MS}, using default (must be 0-1000)`);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
if (process.env.SMART_CODING_GEMINI_MAX_RETRIES !== undefined) {
|
|
1175
|
+
const value = parseInt(process.env.SMART_CODING_GEMINI_MAX_RETRIES, 10);
|
|
1176
|
+
if (!isNaN(value) && value >= 0 && value <= 10) {
|
|
1177
|
+
config.geminiMaxRetries = value;
|
|
1178
|
+
console.error(`[Config] Gemini max retries: ${value}`);
|
|
1179
|
+
} else {
|
|
1180
|
+
console.error(`[Config] Invalid SMART_CODING_GEMINI_MAX_RETRIES: ${process.env.SMART_CODING_GEMINI_MAX_RETRIES}, using default (must be 0-10)`);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
if (process.env.SMART_CODING_WORKER_THREADS !== undefined) {
|
|
1185
|
+
const value = process.env.SMART_CODING_WORKER_THREADS.trim().toLowerCase();
|
|
1186
|
+
if (value === 'auto') {
|
|
1187
|
+
config.workerThreads = 'auto';
|
|
1188
|
+
} else {
|
|
1189
|
+
const numValue = parseInt(value, 10);
|
|
1190
|
+
if (!isNaN(numValue) && numValue >= 1 && numValue <= 32) {
|
|
1191
|
+
config.workerThreads = numValue;
|
|
1192
|
+
} else {
|
|
1193
|
+
console.error(`[Config] Invalid SMART_CODING_WORKER_THREADS: ${value}, using default (must be 'auto' or 1-32)`);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// MRL embedding dimension
|
|
1199
|
+
if (process.env.SMART_CODING_EMBEDDING_DIMENSION !== undefined) {
|
|
1200
|
+
const value = parseInt(process.env.SMART_CODING_EMBEDDING_DIMENSION, 10);
|
|
1201
|
+
const validDims = [64, 128, 256, 512, 768];
|
|
1202
|
+
if (validDims.includes(value)) {
|
|
1203
|
+
config.embeddingDimension = value;
|
|
1204
|
+
console.error(`[Config] Using embedding dimension: ${value}`);
|
|
1205
|
+
} else {
|
|
1206
|
+
console.error(`[Config] Invalid SMART_CODING_EMBEDDING_DIMENSION: ${value}, using default (must be 64, 128, 256, 512, or 768)`);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// Device selection
|
|
1211
|
+
if (process.env.SMART_CODING_DEVICE !== undefined) {
|
|
1212
|
+
const value = process.env.SMART_CODING_DEVICE.trim().toLowerCase();
|
|
1213
|
+
const validDevices = ['cpu', 'webgpu', 'auto'];
|
|
1214
|
+
if (validDevices.includes(value)) {
|
|
1215
|
+
config.device = value;
|
|
1216
|
+
console.error(`[Config] Using device: ${value}`);
|
|
1217
|
+
} else {
|
|
1218
|
+
console.error(`[Config] Invalid SMART_CODING_DEVICE: ${value}, using default (must be 'cpu', 'webgpu', or 'auto')`);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Chunking mode
|
|
1223
|
+
if (process.env.SMART_CODING_CHUNKING_MODE !== undefined) {
|
|
1224
|
+
const value = process.env.SMART_CODING_CHUNKING_MODE.trim().toLowerCase();
|
|
1225
|
+
const validModes = ['smart', 'ast', 'line'];
|
|
1226
|
+
if (validModes.includes(value)) {
|
|
1227
|
+
config.chunkingMode = value;
|
|
1228
|
+
console.error(`[Config] Using chunking mode: ${value}`);
|
|
1229
|
+
} else {
|
|
1230
|
+
console.error(`[Config] Invalid SMART_CODING_CHUNKING_MODE: ${value}, using default (must be 'smart', 'ast', or 'line')`);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// Resource throttling - Max CPU percent
|
|
1235
|
+
if (process.env.SMART_CODING_MAX_CPU_PERCENT !== undefined) {
|
|
1236
|
+
const value = parseInt(process.env.SMART_CODING_MAX_CPU_PERCENT, 10);
|
|
1237
|
+
if (!isNaN(value) && value >= 10 && value <= 100) {
|
|
1238
|
+
config.maxCpuPercent = value;
|
|
1239
|
+
console.error(`[Config] Max CPU usage: ${value}%`);
|
|
1240
|
+
} else {
|
|
1241
|
+
console.error(`[Config] Invalid SMART_CODING_MAX_CPU_PERCENT: ${value}, using default (must be 10-100)`);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// Resource throttling - Batch delay
|
|
1246
|
+
if (process.env.SMART_CODING_BATCH_DELAY !== undefined) {
|
|
1247
|
+
const value = parseInt(process.env.SMART_CODING_BATCH_DELAY, 10);
|
|
1248
|
+
if (!isNaN(value) && value >= 0 && value <= 5000) {
|
|
1249
|
+
config.batchDelay = value;
|
|
1250
|
+
console.error(`[Config] Batch delay: ${value}ms`);
|
|
1251
|
+
} else {
|
|
1252
|
+
console.error(`[Config] Invalid SMART_CODING_BATCH_DELAY: ${value}, using default (must be 0-5000)`);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
// Resource throttling - Max workers
|
|
1257
|
+
if (process.env.SMART_CODING_MAX_WORKERS !== undefined) {
|
|
1258
|
+
const value = process.env.SMART_CODING_MAX_WORKERS.trim().toLowerCase();
|
|
1259
|
+
if (value === 'auto') {
|
|
1260
|
+
config.maxWorkers = 'auto';
|
|
1261
|
+
} else {
|
|
1262
|
+
const numValue = parseInt(value, 10);
|
|
1263
|
+
if (!isNaN(numValue) && numValue >= 1 && numValue <= 32) {
|
|
1264
|
+
config.maxWorkers = numValue;
|
|
1265
|
+
console.error(`[Config] Max workers: ${numValue}`);
|
|
1266
|
+
} else {
|
|
1267
|
+
console.error(`[Config] Invalid SMART_CODING_MAX_WORKERS: ${value}, using default (must be 'auto' or 1-32)`);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// Auto-index delay (background indexing start delay)
|
|
1273
|
+
if (process.env.SMART_CODING_AUTO_INDEX_DELAY !== undefined) {
|
|
1274
|
+
const value = process.env.SMART_CODING_AUTO_INDEX_DELAY.trim().toLowerCase();
|
|
1275
|
+
if (value === 'false' || value === '0') {
|
|
1276
|
+
config.autoIndexDelay = false;
|
|
1277
|
+
console.error(`[Config] Auto-indexing disabled`);
|
|
1278
|
+
} else {
|
|
1279
|
+
const numValue = parseInt(value, 10);
|
|
1280
|
+
if (!isNaN(numValue) && numValue >= 0 && numValue <= 60000) {
|
|
1281
|
+
config.autoIndexDelay = numValue;
|
|
1282
|
+
console.error(`[Config] Auto-index delay: ${numValue}ms`);
|
|
1283
|
+
} else {
|
|
1284
|
+
console.error(`[Config] Invalid SMART_CODING_AUTO_INDEX_DELAY: ${value}, using default (must be 0-60000 or 'false')`);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
return config;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
export function getConfig() {
|
|
1293
|
+
return config;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
export { DEFAULT_CONFIG };
|