@mrxkun/mcfast-mcp 4.2.1 → 4.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrxkun/mcfast-mcp",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Ultra-fast code editing with WASM acceleration, fuzzy patching, multi-layer caching, and 8 unified tools. v4.1.12: Implement proper MCP stdio transport lifecycle and cleanup to prevent zombie processes.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -61,4 +61,4 @@
61
61
  "tree-sitter-rust": "^0.24.0",
62
62
  "web-tree-sitter": "^0.26.5"
63
63
  }
64
- }
64
+ }
@@ -18,17 +18,17 @@ export class CodeIndexer {
18
18
 
19
19
  async indexFile(filePath, content) {
20
20
  const startTime = Date.now();
21
-
21
+
22
22
  const language = detectLanguage(filePath);
23
23
  const contentHash = crypto.createHash('md5').update(content).digest('hex');
24
-
24
+
25
25
  const ast = await this.parseAST(content, filePath, language);
26
26
  const facts = ast ? await this.extractFacts(ast, filePath, language) : [];
27
27
  const chunks = this.chunker.chunk(content, { filePath, language });
28
28
  const embeddings = await this.generateEmbeddings(chunks, language);
29
-
29
+
30
30
  const duration = Date.now() - startTime;
31
-
31
+
32
32
  return {
33
33
  file: {
34
34
  id: this.generateFileId(filePath),
@@ -191,19 +191,20 @@ export class CodeIndexer {
191
191
  // Check if a symbol is exported
192
192
  isExported(content, symbolName) {
193
193
  return new RegExp(`export\\s+.*\\b${symbolName}\\b`).test(content) ||
194
- new RegExp(`export\\s+default`).test(content);
194
+ new RegExp(`export\\s+default`).test(content);
195
195
  }
196
196
 
197
197
  async generateEmbeddings(chunks, language = 'javascript') {
198
198
  const embeddings = [];
199
-
199
+
200
200
  try {
201
201
  for (const chunk of chunks) {
202
202
  const vector = await this.embedder.embedCode(chunk.content, language);
203
203
  embeddings.push({
204
204
  chunk_id: chunk.id,
205
205
  embedding: Buffer.from(new Float32Array(vector).buffer),
206
- model: 'simple-embedder'
206
+ model: 'simple-embedder',
207
+ dimensions: vector.length
207
208
  });
208
209
  }
209
210
  } catch (error) {
@@ -6,20 +6,19 @@ export const QUERIES = {
6
6
  typescript: {
7
7
  definitions: `
8
8
  (function_declaration name: (identifier) @name) @function
9
- (class_declaration name: (type_identifier) @name) @class
10
- (method_definition key: (property_identifier) @name) @method
11
- (interface_declaration name: (type_identifier) @name) @interface
9
+ (class_declaration name: (identifier) @name) @class
10
+ (method_definition name: (property_identifier) @name) @method
11
+ (variable_declarator name: (identifier) @name value: (arrow_function)) @arrow_function
12
12
  (export_statement
13
13
  (function_declaration name: (identifier) @name)) @export_function
14
14
  (export_statement
15
- (class_declaration name: (type_identifier) @name)) @export_class
15
+ (class_declaration name: (identifier) @name)) @export_class
16
16
  (export_statement
17
17
  (lexical_declaration
18
18
  (variable_declarator name: (identifier) @name))) @export_const
19
19
  `,
20
20
  references: `
21
21
  (identifier) @ref
22
- (type_identifier) @ref
23
22
  (property_identifier) @ref
24
23
  (shorthand_property_identifier_pattern) @ref
25
24
  `,
@@ -13,12 +13,12 @@ export class ParallelSearch {
13
13
  * Returns results as soon as all complete (or timeout)
14
14
  */
15
15
  async searchAll(searchFns, query, limit) {
16
- const searchPromises = searchFns.map(fn =>
16
+ const searchPromises = searchFns.map(fn =>
17
17
  this.executeWithTimeout(fn, query, limit)
18
18
  );
19
19
 
20
20
  const results = await Promise.allSettled(searchPromises);
21
-
21
+
22
22
  return results.map((result, index) => ({
23
23
  strategy: searchFns[index].name || `search-${index}`,
24
24
  status: result.status,
@@ -33,7 +33,7 @@ export class ParallelSearch {
33
33
  async executeWithTimeout(fn, query, limit) {
34
34
  return Promise.race([
35
35
  fn(query, limit),
36
- new Promise((_, reject) =>
36
+ new Promise((_, reject) =>
37
37
  setTimeout(() => reject(new Error('Search timeout')), this.timeout)
38
38
  )
39
39
  ]);
@@ -44,14 +44,22 @@ export class ParallelSearch {
44
44
  */
45
45
  mergeResults(results, maxResults = 10) {
46
46
  const allItems = [];
47
-
47
+
48
48
  for (const result of results) {
49
49
  if (result.status === 'fulfilled' && result.data) {
50
- const items = Array.isArray(result.data) ? result.data : [result.data];
50
+ let items = [];
51
+ if (Array.isArray(result.data)) {
52
+ items = result.data;
53
+ } else if (result.data.results && Array.isArray(result.data.results)) {
54
+ items = result.data.results;
55
+ } else {
56
+ items = [result.data];
57
+ }
58
+
51
59
  allItems.push(...items.map(item => ({
52
60
  ...item,
53
61
  _source: result.strategy,
54
- _score: item.score || item.similarity || item.confidence || 0.5
62
+ _score: item.score || item.similarity || item.confidence || item.bm25_score || 0.5
55
63
  })));
56
64
  }
57
65
  }
@@ -96,7 +104,7 @@ export class ParallelSearch {
96
104
  query,
97
105
  limit
98
106
  );
99
-
107
+
100
108
  results = [...results, ...slowResults];
101
109
  return this.mergeResults(results, limit);
102
110
  }
@@ -108,10 +116,10 @@ export class ParallelSearch {
108
116
  // Helper for MemoryEngine parallel search
109
117
  export async function parallelMemorySearch(engine, query, limit) {
110
118
  const parallel = new ParallelSearch();
111
-
119
+
112
120
  const strategies = [
113
121
  { fn: (q, l) => engine.searchFacts(q, l), name: 'facts', fast: true },
114
- { fn: (q, l) => engine.searchFTS(q, l), name: 'fts', fast: true },
122
+ { fn: (q, l) => engine.codebaseDb?.searchFTS?.(q, l) || { results: [] }, name: 'fts', fast: true },
115
123
  { fn: (q, l) => engine.searchVector(q, l), name: 'vector', fast: false }
116
124
  ];
117
125