magector 1.2.6 → 1.2.8

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": "magector",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "Semantic code search for Magento 2 — index, search, MCP server",
5
5
  "type": "module",
6
6
  "main": "src/mcp-server.js",
@@ -31,10 +31,10 @@
31
31
  "ruvector": "^0.1.96"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@magector/cli-darwin-arm64": "1.2.6",
35
- "@magector/cli-linux-x64": "1.2.6",
36
- "@magector/cli-linux-arm64": "1.2.6",
37
- "@magector/cli-win32-x64": "1.2.6"
34
+ "@magector/cli-darwin-arm64": "1.2.8",
35
+ "@magector/cli-linux-x64": "1.2.8",
36
+ "@magector/cli-linux-arm64": "1.2.8",
37
+ "@magector/cli-win32-x64": "1.2.8"
38
38
  },
39
39
  "keywords": [
40
40
  "magento",
package/src/init.js CHANGED
@@ -95,6 +95,35 @@ function writeMcpConfig(projectPath, ides, dbPath) {
95
95
  /**
96
96
  * Write IDE rules files.
97
97
  */
98
+ /**
99
+ * Replace the Magector section in an existing file, or append if not present.
100
+ * Magector sections are delimited by marker comments.
101
+ */
102
+ function upsertMagectorSection(filePath, content, markerStart, markerEnd) {
103
+ if (!existsSync(filePath)) {
104
+ writeFileSync(filePath, markerStart + '\n' + content + markerEnd + '\n');
105
+ return 'created';
106
+ }
107
+ const existing = readFileSync(filePath, 'utf-8');
108
+ const startIdx = existing.indexOf(markerStart);
109
+ const endIdx = existing.indexOf(markerEnd);
110
+ if (startIdx !== -1 && endIdx !== -1) {
111
+ const updated = existing.slice(0, startIdx) + markerStart + '\n' + content + existing.slice(endIdx);
112
+ writeFileSync(filePath, updated);
113
+ return 'updated';
114
+ }
115
+ if (existing.includes('Magector')) {
116
+ // Legacy format without markers — append fresh section
117
+ appendFileSync(filePath, '\n\n' + markerStart + '\n' + content + markerEnd + '\n');
118
+ return 'updated';
119
+ }
120
+ appendFileSync(filePath, '\n\n' + markerStart + '\n' + content + markerEnd + '\n');
121
+ return 'appended';
122
+ }
123
+
124
+ const MARKER_START = '<!-- magector:start -->';
125
+ const MARKER_END = '<!-- magector:end -->';
126
+
98
127
  function writeRules(projectPath, ides) {
99
128
  const written = [];
100
129
 
@@ -103,34 +132,14 @@ function writeRules(projectPath, ides) {
103
132
 
104
133
  if (writeCursor) {
105
134
  const rulesPath = path.join(projectPath, '.cursorrules');
106
- if (!existsSync(rulesPath)) {
107
- writeFileSync(rulesPath, CURSORRULES);
108
- written.push('.cursorrules (created)');
109
- } else {
110
- const existing = readFileSync(rulesPath, 'utf-8');
111
- if (!existing.includes('Magector')) {
112
- appendFileSync(rulesPath, '\n\n' + CURSORRULES);
113
- written.push('.cursorrules (appended)');
114
- } else {
115
- written.push('.cursorrules (already configured)');
116
- }
117
- }
135
+ const result = upsertMagectorSection(rulesPath, CURSORRULES, MARKER_START, MARKER_END);
136
+ written.push(`.cursorrules (${result})`);
118
137
  }
119
138
 
120
139
  if (writeClaude) {
121
140
  const claudePath = path.join(projectPath, 'CLAUDE.md');
122
- if (!existsSync(claudePath)) {
123
- writeFileSync(claudePath, CLAUDE_MD);
124
- written.push('CLAUDE.md (created)');
125
- } else {
126
- const existing = readFileSync(claudePath, 'utf-8');
127
- if (!existing.includes('Magector')) {
128
- appendFileSync(claudePath, '\n\n' + CLAUDE_MD);
129
- written.push('CLAUDE.md (appended)');
130
- } else {
131
- written.push('CLAUDE.md (already configured)');
132
- }
133
- }
141
+ const result = upsertMagectorSection(claudePath, CLAUDE_MD, MARKER_START, MARKER_END);
142
+ written.push(`CLAUDE.md (${result})`);
134
143
  }
135
144
 
136
145
  return written;
package/src/mcp-server.js CHANGED
@@ -40,6 +40,13 @@ const config = {
40
40
 
41
41
  // ─── Rust Core Integration ──────────────────────────────────────
42
42
 
43
+ // Env vars to suppress ONNX Runtime native logs that would pollute stdout/JSON-RPC
44
+ const rustEnv = {
45
+ ...process.env,
46
+ ORT_LOG_LEVEL: 'error',
47
+ RUST_LOG: 'error',
48
+ };
49
+
43
50
  function rustSearch(query, limit = 10) {
44
51
  const result = execFileSync(config.rustBinary, [
45
52
  'search', query,
@@ -47,7 +54,7 @@ function rustSearch(query, limit = 10) {
47
54
  '-c', config.modelCache,
48
55
  '-l', String(limit),
49
56
  '-f', 'json'
50
- ], { encoding: 'utf-8', timeout: 30000, stdio: ['pipe', 'pipe', 'pipe'] });
57
+ ], { encoding: 'utf-8', timeout: 30000, stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
51
58
  return JSON.parse(result);
52
59
  }
53
60
 
@@ -57,7 +64,7 @@ function rustIndex(magentoRoot) {
57
64
  '-m', magentoRoot,
58
65
  '-d', config.dbPath,
59
66
  '-c', config.modelCache
60
- ], { encoding: 'utf-8', timeout: 600000, stdio: ['pipe', 'pipe', 'pipe'] });
67
+ ], { encoding: 'utf-8', timeout: 600000, stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
61
68
  return result;
62
69
  }
63
70
 
@@ -65,7 +72,7 @@ function rustStats() {
65
72
  const result = execFileSync(config.rustBinary, [
66
73
  'stats',
67
74
  '-d', config.dbPath
68
- ], { encoding: 'utf-8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'] });
75
+ ], { encoding: 'utf-8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
69
76
  // Parse text output: "Total vectors: N" and "Embedding dim: N"
70
77
  const vectors = result.match(/Total vectors:\s*(\d+)/)?.[1] || '0';
71
78
  const dim = result.match(/Embedding dim:\s*(\d+)/)?.[1] || '384';