magector 1.2.5 → 1.2.7
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 +5 -5
- package/src/cli.js +7 -5
- package/src/init.js +40 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
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.
|
|
35
|
-
"@magector/cli-linux-x64": "1.2.
|
|
36
|
-
"@magector/cli-linux-arm64": "1.2.
|
|
37
|
-
"@magector/cli-win32-x64": "1.2.
|
|
34
|
+
"@magector/cli-darwin-arm64": "1.2.7",
|
|
35
|
+
"@magector/cli-linux-x64": "1.2.7",
|
|
36
|
+
"@magector/cli-linux-arm64": "1.2.7",
|
|
37
|
+
"@magector/cli-win32-x64": "1.2.7"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"magento",
|
package/src/cli.js
CHANGED
|
@@ -77,17 +77,19 @@ async function runIndex(targetPath) {
|
|
|
77
77
|
console.log(`Database: ${path.resolve(config.dbPath)}\n`);
|
|
78
78
|
|
|
79
79
|
try {
|
|
80
|
-
|
|
80
|
+
execFileSync(binary, [
|
|
81
81
|
'index',
|
|
82
82
|
'-m', path.resolve(root),
|
|
83
83
|
'-d', path.resolve(config.dbPath),
|
|
84
84
|
'-c', modelPath
|
|
85
|
-
], {
|
|
86
|
-
if (output.trim()) console.log(output.trim());
|
|
85
|
+
], { timeout: 600000, stdio: 'inherit' });
|
|
87
86
|
console.log('\nIndexing complete.');
|
|
88
87
|
} catch (err) {
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
if (err.status) {
|
|
89
|
+
console.error('Indexing failed.');
|
|
90
|
+
process.exit(err.status);
|
|
91
|
+
}
|
|
92
|
+
console.error(`Indexing error: ${err.message}`);
|
|
91
93
|
process.exit(1);
|
|
92
94
|
}
|
|
93
95
|
}
|
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
|
-
|
|
107
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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;
|
|
@@ -199,18 +208,18 @@ export async function init(projectPath) {
|
|
|
199
208
|
console.log('\nIndexing codebase...');
|
|
200
209
|
const startTime = Date.now();
|
|
201
210
|
try {
|
|
202
|
-
|
|
211
|
+
execFileSync(binary, [
|
|
203
212
|
'index',
|
|
204
213
|
'-m', projectPath,
|
|
205
214
|
'-d', dbPath,
|
|
206
215
|
'-c', modelPath
|
|
207
|
-
], {
|
|
208
|
-
if (output.trim()) {
|
|
209
|
-
console.log(output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
210
|
-
}
|
|
216
|
+
], { timeout: 600000, stdio: 'inherit' });
|
|
211
217
|
} catch (err) {
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
if (err.status) {
|
|
219
|
+
console.error('Indexing failed.');
|
|
220
|
+
process.exit(err.status);
|
|
221
|
+
}
|
|
222
|
+
console.error(`Indexing error: ${err.message}`);
|
|
214
223
|
process.exit(1);
|
|
215
224
|
}
|
|
216
225
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|