@danielblomma/cortex-mcp 2.4.1 → 2.4.2

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 (45) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +5 -0
  3. package/bin/cli/arguments.mjs +60 -0
  4. package/bin/cli/context-passthrough.mjs +129 -0
  5. package/bin/cli/daemon.mjs +157 -0
  6. package/bin/cli/enterprise.mjs +516 -0
  7. package/bin/cli/help.mjs +88 -0
  8. package/bin/cli/hooks.mjs +199 -0
  9. package/bin/cli/mcp-command.mjs +87 -0
  10. package/bin/cli/paths.mjs +14 -0
  11. package/bin/cli/process.mjs +49 -0
  12. package/bin/cli/project-commands.mjs +237 -0
  13. package/bin/cli/project-runtime.mjs +34 -0
  14. package/bin/cli/query-command.mjs +18 -0
  15. package/bin/cli/router.mjs +66 -0
  16. package/bin/cli/run-command.mjs +44 -0
  17. package/bin/cli/scaffold-ownership.mjs +936 -0
  18. package/bin/cli/scaffold.mjs +687 -0
  19. package/bin/cli/stage-command.mjs +9 -0
  20. package/bin/cli/telemetry-command.mjs +18 -0
  21. package/bin/cli/trusted-runtime.mjs +18 -0
  22. package/bin/cortex.mjs +6 -1834
  23. package/mcp-registry-submission.json +1 -1
  24. package/package.json +3 -2
  25. package/scaffold/ownership/baseline-v2.4.1.json +22 -0
  26. package/scaffold/ownership/current.json +4 -0
  27. package/scaffold/ownership/v1.json +456 -0
  28. package/scaffold/scripts/ingest-parsers.mjs +1 -387
  29. package/scaffold/scripts/ingest-worker.mjs +4 -1
  30. package/scaffold/scripts/ingest.mjs +5 -3899
  31. package/scaffold/scripts/lib/ingest/arguments.mjs +78 -0
  32. package/scaffold/scripts/lib/ingest/chunks.mjs +212 -0
  33. package/scaffold/scripts/lib/ingest/config.mjs +120 -0
  34. package/scaffold/scripts/lib/ingest/constants.mjs +222 -0
  35. package/scaffold/scripts/lib/ingest/files.mjs +387 -0
  36. package/scaffold/scripts/lib/ingest/incremental-state.mjs +131 -0
  37. package/scaffold/scripts/lib/ingest/io.mjs +78 -0
  38. package/scaffold/scripts/lib/ingest/main.mjs +76 -0
  39. package/scaffold/scripts/lib/ingest/parser-composition.mjs +140 -0
  40. package/scaffold/scripts/lib/ingest/parser-registry.mjs +387 -0
  41. package/scaffold/scripts/lib/ingest/pipeline-stages.mjs +1625 -0
  42. package/scaffold/scripts/lib/ingest/projects.mjs +272 -0
  43. package/scaffold/scripts/lib/ingest/relations.mjs +860 -0
  44. package/scaffold/scripts/lib/ingest/runtime-paths.mjs +11 -0
  45. package/scaffold/scripts/lib/ingest/workers.mjs +264 -0
@@ -1,387 +1 @@
1
- /**
2
- * Shared chunk-parser registry.
3
- *
4
- * Single source of truth for "which parser handles which extension", used by
5
- * both the main ingest process and the worker-thread pool. Keeping one table
6
- * guarantees a file parses identically whether it runs inline or in a worker.
7
- *
8
- * Parsers self-initialize lazily (tree-sitter grammars load WASM on first
9
- * parse and cache per module instance), so a worker amortizes that cost over
10
- * its lifetime.
11
- */
12
- import { parseCode } from "./parsers/javascript.mjs";
13
-
14
- const parseJavaScriptCode = parseCode;
15
- let parseVbNetCode = null;
16
- let parseCSharpCode = null;
17
- let parseCSharpProjectImpl = null;
18
- let parseCppCode = null;
19
- let parseConfigCode = null;
20
- let parseResourcesCode = null;
21
- let parseSqlCode = null;
22
- let parseRustCode = null;
23
- let parsePythonCode = null;
24
- let parseGoCode = null;
25
- let parseJavaCode = null;
26
- let parseRubyCode = null;
27
- let parseBashCode = null;
28
- let parseVb6Code = null;
29
- let parseMarkdownCode = null;
30
- let isVbNetParserAvailable = () => false;
31
- let isCSharpParserAvailableImpl = () => false;
32
- let isCppParserAvailable = () => false;
33
- let getCSharpParserRuntimeImpl = () => ({ available: false, reason: "parser module not loaded" });
34
-
35
- let loadPromise = null;
36
-
37
- // Languages whose parser runs purely in-process (JS or WASM) with no
38
- // subprocess and no cross-file global state, so they are safe to run in a
39
- // worker thread. csharp (Roslyn subprocess + project-wide batch parse in the
40
- // main process), vbnet (subprocess), and cpp (clang-bridge fallback
41
- // subprocess) stay on the main thread.
42
- export const PARALLEL_SAFE_LANGUAGES = new Set([
43
- "javascript",
44
- "jsx",
45
- "typescript",
46
- "tsx",
47
- "python",
48
- "go",
49
- "java",
50
- "ruby",
51
- "bash",
52
- "sql",
53
- "config",
54
- "resource",
55
- "settings",
56
- "markdown",
57
- "rust",
58
- "vb6"
59
- ]);
60
-
61
- export async function loadParsers() {
62
- if (loadPromise) {
63
- return loadPromise;
64
- }
65
- const loaders = [
66
- import("./parsers/vbnet.mjs").then((module) => {
67
- parseVbNetCode = module.parseCode;
68
- isVbNetParserAvailable =
69
- typeof module.isVbNetParserAvailable === "function"
70
- ? module.isVbNetParserAvailable
71
- : () => typeof module.parseCode === "function";
72
- }),
73
- import("./parsers/csharp.mjs").then((module) => {
74
- parseCSharpCode = module.parseCode;
75
- parseCSharpProjectImpl = module.parseProject ?? null;
76
- getCSharpParserRuntimeImpl =
77
- typeof module.getCSharpParserRuntime === "function"
78
- ? module.getCSharpParserRuntime
79
- : () => ({ available: typeof module.parseCode === "function", reason: "runtime details unavailable" });
80
- isCSharpParserAvailableImpl =
81
- typeof module.isCSharpParserAvailable === "function"
82
- ? module.isCSharpParserAvailable
83
- : () => typeof module.parseCode === "function";
84
- }),
85
- import("./parsers/cpp-dispatch.mjs").then((module) => {
86
- parseCppCode = module.parseCode;
87
- isCppParserAvailable =
88
- typeof module.isCppParserAvailable === "function"
89
- ? module.isCppParserAvailable
90
- : () => typeof module.parseCode === "function";
91
- }),
92
- import("./parsers/config.mjs").then((module) => {
93
- parseConfigCode = module.parseCode;
94
- }),
95
- import("./parsers/resources.mjs").then((module) => {
96
- parseResourcesCode = module.parseCode;
97
- }),
98
- import("./parsers/sql.mjs").then((module) => {
99
- parseSqlCode = module.parseCode;
100
- }),
101
- import("./parsers/rust-dispatch.mjs").then((module) => {
102
- parseRustCode = module.parseCode;
103
- }),
104
- import("./parsers/python-treesitter.mjs").then((module) => {
105
- parsePythonCode = module.parseCode;
106
- }),
107
- import("./parsers/go-treesitter.mjs").then((module) => {
108
- parseGoCode = module.parseCode;
109
- }),
110
- import("./parsers/java-treesitter.mjs").then((module) => {
111
- parseJavaCode = module.parseCode;
112
- }),
113
- import("./parsers/ruby-treesitter.mjs").then((module) => {
114
- parseRubyCode = module.parseCode;
115
- }),
116
- import("./parsers/bash-treesitter.mjs").then((module) => {
117
- parseBashCode = module.parseCode;
118
- }),
119
- import("./parsers/vb6.mjs").then((module) => {
120
- parseVb6Code = module.parseCode;
121
- }),
122
- import("./parsers/markdown.mjs").then((module) => {
123
- parseMarkdownCode = module.parseCode;
124
- })
125
- ];
126
-
127
- loadPromise = Promise.allSettled(loaders).then(() => undefined);
128
- return loadPromise;
129
- }
130
-
131
- const CHUNK_PARSERS = new Map([
132
- [".js", { language: "javascript", parse: parseJavaScriptCode }],
133
- [".jsx", { language: "jsx", parse: parseJavaScriptCode }],
134
- [".mjs", { language: "javascript", parse: parseJavaScriptCode }],
135
- [".cjs", { language: "javascript", parse: parseJavaScriptCode }],
136
- [".ts", { language: "typescript", parse: parseJavaScriptCode }],
137
- [".tsx", { language: "tsx", parse: parseJavaScriptCode }],
138
- [".mts", { language: "typescript", parse: parseJavaScriptCode }],
139
- [".cts", { language: "typescript", parse: parseJavaScriptCode }],
140
- [
141
- ".vb",
142
- {
143
- language: "vbnet",
144
- parse: (...args) => parseVbNetCode(...args),
145
- isAvailable: () => typeof parseVbNetCode === "function" && isVbNetParserAvailable()
146
- }
147
- ],
148
- [
149
- ".cs",
150
- {
151
- language: "csharp",
152
- parse: (...args) => parseCSharpCode(...args),
153
- isAvailable: () => typeof parseCSharpCode === "function" && isCSharpParserAvailableImpl()
154
- }
155
- ],
156
- [
157
- ".sql",
158
- {
159
- language: "sql",
160
- parse: (...args) => parseSqlCode(...args),
161
- isAvailable: () => typeof parseSqlCode === "function"
162
- }
163
- ],
164
- [
165
- ".md",
166
- {
167
- language: "markdown",
168
- parse: (...args) => parseMarkdownCode(...args),
169
- isAvailable: () => typeof parseMarkdownCode === "function"
170
- }
171
- ],
172
- [
173
- ".mdx",
174
- {
175
- language: "markdown",
176
- parse: (...args) => parseMarkdownCode(...args),
177
- isAvailable: () => typeof parseMarkdownCode === "function"
178
- }
179
- ],
180
- [
181
- ".config",
182
- {
183
- language: "config",
184
- parse: (...args) => parseConfigCode(...args),
185
- isAvailable: () => typeof parseConfigCode === "function"
186
- }
187
- ],
188
- [
189
- ".resx",
190
- {
191
- language: "resource",
192
- parse: (...args) => parseResourcesCode(...args),
193
- isAvailable: () => typeof parseResourcesCode === "function"
194
- }
195
- ],
196
- [
197
- ".settings",
198
- {
199
- language: "settings",
200
- parse: (...args) => parseResourcesCode(...args),
201
- isAvailable: () => typeof parseResourcesCode === "function"
202
- }
203
- ],
204
- [
205
- ".c",
206
- {
207
- language: "c",
208
- parse: (...args) => parseCppCode(...args),
209
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
210
- }
211
- ],
212
- [
213
- ".h",
214
- {
215
- language: "c",
216
- parse: (...args) => parseCppCode(...args),
217
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
218
- }
219
- ],
220
- [
221
- ".cpp",
222
- {
223
- language: "cpp",
224
- parse: (...args) => parseCppCode(...args),
225
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
226
- }
227
- ],
228
- [
229
- ".cc",
230
- {
231
- language: "cpp",
232
- parse: (...args) => parseCppCode(...args),
233
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
234
- }
235
- ],
236
- [
237
- ".hpp",
238
- {
239
- language: "cpp",
240
- parse: (...args) => parseCppCode(...args),
241
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
242
- }
243
- ],
244
- [
245
- ".hh",
246
- {
247
- language: "cpp",
248
- parse: (...args) => parseCppCode(...args),
249
- isAvailable: () => typeof parseCppCode === "function" && isCppParserAvailable()
250
- }
251
- ],
252
- [
253
- ".rs",
254
- {
255
- language: "rust",
256
- parse: (...args) => parseRustCode(...args),
257
- isAvailable: () => typeof parseRustCode === "function"
258
- }
259
- ],
260
- [
261
- ".py",
262
- {
263
- language: "python",
264
- parse: (...args) => parsePythonCode(...args),
265
- isAvailable: () => typeof parsePythonCode === "function"
266
- }
267
- ],
268
- [
269
- ".go",
270
- {
271
- language: "go",
272
- parse: (...args) => parseGoCode(...args),
273
- isAvailable: () => typeof parseGoCode === "function"
274
- }
275
- ],
276
- [
277
- ".java",
278
- {
279
- language: "java",
280
- parse: (...args) => parseJavaCode(...args),
281
- isAvailable: () => typeof parseJavaCode === "function"
282
- }
283
- ],
284
- [
285
- ".rb",
286
- {
287
- language: "ruby",
288
- parse: (...args) => parseRubyCode(...args),
289
- isAvailable: () => typeof parseRubyCode === "function"
290
- }
291
- ],
292
- [
293
- ".sh",
294
- {
295
- language: "bash",
296
- parse: (...args) => parseBashCode(...args),
297
- isAvailable: () => typeof parseBashCode === "function"
298
- }
299
- ],
300
- [
301
- ".bash",
302
- {
303
- language: "bash",
304
- parse: (...args) => parseBashCode(...args),
305
- isAvailable: () => typeof parseBashCode === "function"
306
- }
307
- ],
308
- [
309
- ".zsh",
310
- {
311
- language: "bash",
312
- parse: (...args) => parseBashCode(...args),
313
- isAvailable: () => typeof parseBashCode === "function"
314
- }
315
- ],
316
- [
317
- ".bas",
318
- {
319
- language: "vb6",
320
- parse: (...args) => parseVb6Code(...args),
321
- isAvailable: () => typeof parseVb6Code === "function"
322
- }
323
- ],
324
- [
325
- ".cls",
326
- {
327
- language: "vb6",
328
- parse: (...args) => parseVb6Code(...args),
329
- isAvailable: () => typeof parseVb6Code === "function"
330
- }
331
- ],
332
- [
333
- ".frm",
334
- {
335
- language: "vb6",
336
- parse: (...args) => parseVb6Code(...args),
337
- isAvailable: () => typeof parseVb6Code === "function"
338
- }
339
- ],
340
- [
341
- ".ctl",
342
- {
343
- language: "vb6",
344
- parse: (...args) => parseVb6Code(...args),
345
- isAvailable: () => typeof parseVb6Code === "function"
346
- }
347
- ]
348
- ]);
349
-
350
- export function getChunkParserForExtension(ext) {
351
- return CHUNK_PARSERS.get(ext) ?? null;
352
- }
353
-
354
- // Stable wrappers so callers can import these once; they delegate to whatever
355
- // the dynamic import populated.
356
- export function isCSharpParserAvailable() {
357
- return isCSharpParserAvailableImpl();
358
- }
359
-
360
- export function getCSharpParserRuntime() {
361
- return getCSharpParserRuntimeImpl();
362
- }
363
-
364
- export function parseCSharpProject(inputs) {
365
- if (typeof parseCSharpProjectImpl !== "function") {
366
- return null;
367
- }
368
- return parseCSharpProjectImpl(inputs);
369
- }
370
-
371
- export function hasCSharpProjectParser() {
372
- return typeof parseCSharpProjectImpl === "function";
373
- }
374
-
375
- // Parse a single file with the registered parser for its extension. Used by
376
- // the worker; returns the parser's { chunks, errors } result, or null if no
377
- // parser is registered or it is unavailable in this process.
378
- export async function parseFileContent(ext, content, filePath) {
379
- const parser = getChunkParserForExtension(ext);
380
- if (!parser) {
381
- return null;
382
- }
383
- if (typeof parser.isAvailable === "function" && !(await parser.isAvailable())) {
384
- return null;
385
- }
386
- return { language: parser.language, result: await parser.parse(content, filePath, parser.language) };
387
- }
1
+ export * from "./lib/ingest/parser-registry.mjs";
@@ -12,7 +12,10 @@
12
12
  */
13
13
  import fs from "node:fs";
14
14
  import { parentPort } from "node:worker_threads";
15
- import { loadParsers, parseFileContent } from "./ingest-parsers.mjs";
15
+ import {
16
+ loadParsers,
17
+ parseFileContent
18
+ } from "./lib/ingest/parser-registry.mjs";
16
19
 
17
20
  if (!parentPort) {
18
21
  throw new Error("ingest-worker.mjs must be run as a worker thread");