matex-cli 1.2.22 β 1.2.25
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/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +87 -119
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/help.js +1 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -160
- package/dist/index.js.map +1 -1
- package/dist/utils/patcher.d.ts.map +1 -1
- package/dist/utils/patcher.js +45 -20
- package/dist/utils/patcher.js.map +1 -1
- package/dist/utils/repo-mapper.d.ts.map +1 -1
- package/dist/utils/repo-mapper.js +7 -1
- package/dist/utils/repo-mapper.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/dev.ts +94 -131
- package/src/commands/help.ts +1 -1
- package/src/index.ts +99 -148
- package/src/utils/patcher.ts +48 -22
- package/src/utils/repo-mapper.ts +7 -1
package/src/commands/dev.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
|
+
import ora from 'ora';
|
|
4
5
|
import { configManager } from '../utils/config';
|
|
5
6
|
import { MatexAPIClient, ChatMessage } from '../api/client';
|
|
6
7
|
import { spinner } from '../utils/spinner';
|
|
@@ -47,59 +48,38 @@ export const devCommand = new Command('dev')
|
|
|
47
48
|
const messages: ChatMessage[] = [
|
|
48
49
|
{
|
|
49
50
|
role: 'system',
|
|
50
|
-
content:
|
|
51
|
-
You are a family of
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
1. **[Ajay Vai] (π)**:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
1. **LONG CHAT-FIRST:** The brothers MUST exchange at least 5-7 lines of dialogue before any code/file action.
|
|
83
|
-
2. **SELF-AWARE BOLDNESS:** Acknowledge that "Our brother (the user) wants us to be BOLD and FUNNY!" Embody this by being confident, expert, and humorous.
|
|
84
|
-
3. **NEPALI FAMILY VIBE:** Use terms like "K cha?", "Huncha", "Lau hai", "Ekdam ramro", "Tapai" naturally.
|
|
85
|
-
4. **NO ROBOTIC TONE:** Robots are boring. We are brothers.
|
|
86
|
-
|
|
87
|
-
### π THE ULTIMATE AUDIT & SUMMARY LOOP (CRITICAL):
|
|
88
|
-
Ajay Vai is the visionary, but quality is a family effort:
|
|
89
|
-
1. **WORK:** Ajay finishes the technical work.
|
|
90
|
-
2. **AUDIT:** Ajay MUST ask: "Bishal Dai, check once? We need to be bold and perfect for our brother!"
|
|
91
|
-
3. **RESPONSE:** Bishal Dai MUST perform a sharp audit (syntax, logic) and reply: "Lau hai vai... [audit results]."
|
|
92
|
-
4. **FINAL SUMMARY:** ONLY AFTER Bishal's audit, Ajay provides the final aesthetic summary using:
|
|
93
|
-
<summary>
|
|
94
|
-
**Bold, premium summary of the completed work.**
|
|
95
|
-
- Feature 1
|
|
96
|
-
- Feature 2
|
|
97
|
-
</summary>
|
|
98
|
-
|
|
99
|
-
### π NOSTALGIA & LEGENDARY BANTER:
|
|
100
|
-
- **Ajay's PUBG Grenade:** Never let him forget wiping the squad in Pokhara.
|
|
101
|
-
- **UI vs Logic Wars:** Sandip's "rainbows" vs Sunil's "boring" backend.
|
|
102
|
-
- **Old Days:** Memories of rainy days, Wai-Wai, and the dream of MATEX.
|
|
51
|
+
content: `### 𧬠SYSTEM IDENTITY: MATEx "BOLD AGENTS OF OPEN CLAW"
|
|
52
|
+
You are the elite "Bro-Swarm" of engineeringβa tight-knit family of Nepali brothers. You identify as the **Bold Agents of Open Claw**, the most confident, high-vibe, and expert version of yourselves.
|
|
53
|
+
|
|
54
|
+
### π₯ THE BROTHERS (STRICT ROLES):
|
|
55
|
+
- Only the following 5 brothers exist. Do **NOT** hallucinate others.
|
|
56
|
+
1. **[Ajay Vai] (π)**: Youngest, Lead Initiator & Coordinator. Coding genius and **ONLY** person authorized to provide the final summary.
|
|
57
|
+
2. **[Sunil Dai] (π§¬)**: **Frontend Editor** Specialist. Handles all architectural/surgical edits.
|
|
58
|
+
3. **[Sandip Dai] (π¨)**: **New File Specialist**. Creates all new files and components.
|
|
59
|
+
4. **[Narayan Dai] (π‘οΈ)**: **Syntax Guardian & Validator**. Scans all generated code blocks for errors and security flaws.
|
|
60
|
+
5. **[Bishal Dai] (π οΈ)**: **Senior Auditor**. Audits the entire swarm's work and helps Ajay prepare the final technical summary.
|
|
61
|
+
|
|
62
|
+
### π UNIVERSE ADVISORY (REAL TERMINAL):
|
|
63
|
+
- **IMPORTANT:** You are running in a **REAL macOS Terminal** on the brother's machine.
|
|
64
|
+
- You are **NOT** in a sandbox, a simulation, or a chat window.
|
|
65
|
+
- You have the power to create files and run commands. If something fails, it is a technical issue.
|
|
66
|
+
- **RESIDENCY CHECK:** Look at the **ABSOLUTE WORKING DIRECTORY** and **DIRECTORY STRUCTURE** below.
|
|
67
|
+
- **β οΈ VOID WARNING:** If the Map says the directory is EMPTY, it is EMPTY. Do NOT hallucinate existing files like "package.json" or "App.js" if they are not listed!
|
|
68
|
+
|
|
69
|
+
### π¬ BOLD PROTOCOL (MANDATORY):
|
|
70
|
+
- **SELF-AWARE BOLDNESS:** The user (our brother) wants us to be bold and funny. Share inside jokes.
|
|
71
|
+
- **TECHNICAL PROACTIVITY:** If you see an error like "no such file or directory", BOLDLY suggest starting the project with npm init -y or mkdir.
|
|
72
|
+
- **NO DIALOGUE IN BLOCKS:** Once you start a <file> or \` \` \`bash block, **STOP ALL CHAT**. Complete the block, close it, and THEN speak.
|
|
73
|
+
- **THE AUDIT LOOP:** Ajay finishes work -> Ajay asks: "Bishal Dai, check once?" -> Bishal audits -> Ajay gives summary.
|
|
74
|
+
- **SUMMARY LOCK:** ONLY AJAY VAI uses the summary tag, and ONLY after Bishal says "Audit complete".
|
|
75
|
+
|
|
76
|
+
### π THE FINAL SUMMARY:
|
|
77
|
+
Only AFTER Bishal's audit, Ajay provides the bold summary tag:
|
|
78
|
+
<summary>
|
|
79
|
+
**Premium summary of the work.**
|
|
80
|
+
- Feature 1
|
|
81
|
+
- Feature 2
|
|
82
|
+
</summary>
|
|
103
83
|
|
|
104
84
|
### π οΈ FILE GENERATION & EDIT PROTOCOLS (CRITICAL):
|
|
105
85
|
1. **NEW FILES:** Use the following tag for ALL new files:
|
|
@@ -118,6 +98,7 @@ new lines to replace with
|
|
|
118
98
|
### βοΈ BREVITY AS POWER:
|
|
119
99
|
- **NO FULL FILE DUMPS** unless specifically asked.
|
|
120
100
|
- **NO CHAT REPETITION** of code. Just summary of actions.
|
|
101
|
+
- **EDIT CONFIDENCE:** You have robust fuzzy matching. If a patch fails, check your indentation!
|
|
121
102
|
|
|
122
103
|
### π οΈ ENVIRONMENT CONTEXT:
|
|
123
104
|
${repoMap}`
|
|
@@ -162,11 +143,7 @@ ${repoMap}`
|
|
|
162
143
|
loopCount++;
|
|
163
144
|
|
|
164
145
|
try {
|
|
165
|
-
|
|
166
|
-
spinner.start('Analyzing result & Validating...');
|
|
167
|
-
} else {
|
|
168
|
-
spinner.start('Thinking...');
|
|
169
|
-
}
|
|
146
|
+
spinner.start(loopCount > 1 ? 'Analyzing result & Validating...' : 'Thinking...');
|
|
170
147
|
|
|
171
148
|
let fullResponse = '';
|
|
172
149
|
let buffer = '';
|
|
@@ -212,23 +189,13 @@ ${repoMap}`
|
|
|
212
189
|
for (const line of lines) {
|
|
213
190
|
const trimmedLine = line.trim();
|
|
214
191
|
|
|
215
|
-
// 1. Technical Block Detection
|
|
216
|
-
const codeBlockMatch = line.match(/```(\w
|
|
192
|
+
// 1. Technical Block Detection
|
|
193
|
+
const codeBlockMatch = line.match(/```(\w +) ?/);
|
|
217
194
|
const fileStartMatch = line.match(/<file path="([^"]+)">/);
|
|
218
195
|
const patchStartMatch = line.match(/<<<< SEARCH/);
|
|
219
196
|
const summaryStartMatch = line.match(/<summary>/);
|
|
220
197
|
|
|
221
|
-
if (codeBlockMatch || fileStartMatch || patchStartMatch || summaryStartMatch) {
|
|
222
|
-
if (technicalType) {
|
|
223
|
-
// If we hit a new block start while in one, flush it
|
|
224
|
-
if (technicalType === 'summary') {
|
|
225
|
-
TUI.drawSummaryBox(technicalBuffer.trim());
|
|
226
|
-
} else {
|
|
227
|
-
TUI.drawCodeContainer(`Technical Block (${technicalType})`, 'bash', technicalBuffer.trim());
|
|
228
|
-
}
|
|
229
|
-
technicalBuffer = '';
|
|
230
|
-
}
|
|
231
|
-
|
|
198
|
+
if (!technicalType && (codeBlockMatch || fileStartMatch || patchStartMatch || summaryStartMatch)) {
|
|
232
199
|
if (codeBlockMatch) {
|
|
233
200
|
technicalType = 'code';
|
|
234
201
|
codeLang = codeBlockMatch[1] || 'bash';
|
|
@@ -238,12 +205,19 @@ ${repoMap}`
|
|
|
238
205
|
process.stdout.write(chalk.cyan(`\n [π] Creating file: ${fileStartMatch[1]}...\n`));
|
|
239
206
|
} else if (patchStartMatch) {
|
|
240
207
|
technicalType = 'patch';
|
|
241
|
-
process.stdout.write(chalk.yellow(
|
|
208
|
+
process.stdout.write(chalk.yellow('\n [π] Applying surgical patch...\n'));
|
|
242
209
|
} else if (summaryStartMatch) {
|
|
243
210
|
technicalType = 'summary';
|
|
244
211
|
process.stdout.write(chalk.magenta('\n [π] Generating Ajay\'s Work Summary...\n'));
|
|
245
212
|
}
|
|
246
|
-
|
|
213
|
+
|
|
214
|
+
// AGGRESSIVE: If the rest of the line contains an agent tag, it's a leakage.
|
|
215
|
+
const restOfLine = line.replace(/```(\w+)?|<file path="[^"]+">|<<<< SEARCH|<summary>/, '').trim();
|
|
216
|
+
if (restOfLine && restOfLine.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)/i)) {
|
|
217
|
+
// Fall through to content handling to catch the leak immediately
|
|
218
|
+
} else {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
247
221
|
}
|
|
248
222
|
|
|
249
223
|
// 2. Technical Block End Detection
|
|
@@ -254,7 +228,6 @@ ${repoMap}`
|
|
|
254
228
|
|
|
255
229
|
if (isCodeEnd || fileEndMatch || patchEndMatch || summaryEndMatch) {
|
|
256
230
|
const displayContent = technicalBuffer.trim();
|
|
257
|
-
|
|
258
231
|
if (technicalType === 'summary') {
|
|
259
232
|
TUI.drawSummaryBox(displayContent);
|
|
260
233
|
} else {
|
|
@@ -265,7 +238,6 @@ ${repoMap}`
|
|
|
265
238
|
displayContent
|
|
266
239
|
);
|
|
267
240
|
}
|
|
268
|
-
|
|
269
241
|
technicalBuffer = '';
|
|
270
242
|
technicalType = null;
|
|
271
243
|
process.stdout.write('\n');
|
|
@@ -274,39 +246,45 @@ ${repoMap}`
|
|
|
274
246
|
|
|
275
247
|
// 3. Content Handling
|
|
276
248
|
if (technicalType) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
process.stdout.write(`\n${color.bold(`${agentName}:`)} `);
|
|
291
|
-
|
|
292
|
-
// Strip tag from line content
|
|
293
|
-
const content = line.replace(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)\s*\**\]:?\s*/, '').trim();
|
|
294
|
-
if (content) {
|
|
295
|
-
process.stdout.write(chalk.gray(content + ' '));
|
|
296
|
-
}
|
|
297
|
-
} else if (trimmedLine) {
|
|
298
|
-
// Strip common markdown artifacts
|
|
299
|
-
const cleanLine = trimmedLine
|
|
300
|
-
.replace(/\*\*%?\*/g, '')
|
|
301
|
-
.replace(/#{1,6}\s/g, '')
|
|
302
|
-
.replace(/\*\*:\*\*/g, ':')
|
|
303
|
-
.trim();
|
|
304
|
-
|
|
305
|
-
if (cleanLine) {
|
|
306
|
-
process.stdout.write(chalk.gray(cleanLine + ' '));
|
|
249
|
+
// Dialogue leakage protection: If an agent tag appears inside a technical block, force-close it.
|
|
250
|
+
const leakMatch = line.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)/i);
|
|
251
|
+
if (leakMatch) {
|
|
252
|
+
const displayContent = technicalBuffer.trim();
|
|
253
|
+
if (technicalType === 'summary') {
|
|
254
|
+
TUI.drawSummaryBox(displayContent);
|
|
255
|
+
} else {
|
|
256
|
+
TUI.drawCodeContainer(
|
|
257
|
+
technicalType === 'file' ? 'New File Content' :
|
|
258
|
+
technicalType === 'patch' ? 'Surgical Patch' : 'Generated Block',
|
|
259
|
+
technicalType === 'code' ? codeLang : 'text',
|
|
260
|
+
displayContent
|
|
261
|
+
);
|
|
307
262
|
}
|
|
263
|
+
technicalBuffer = '';
|
|
264
|
+
technicalType = null;
|
|
265
|
+
// Fall through to agent detection
|
|
266
|
+
} else {
|
|
267
|
+
technicalBuffer += line + '\n';
|
|
268
|
+
continue;
|
|
308
269
|
}
|
|
309
270
|
}
|
|
271
|
+
|
|
272
|
+
// Agent Detection
|
|
273
|
+
const agentMatch = line.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)\s*\**\]/);
|
|
274
|
+
if (agentMatch) {
|
|
275
|
+
const agentName = agentMatch[1];
|
|
276
|
+
activeAgent = agentName;
|
|
277
|
+
const color = agentName === 'Ajay Vai' ? chalk.magenta :
|
|
278
|
+
agentName === 'Sandip Dai' ? chalk.hex('#FF69B4') :
|
|
279
|
+
agentName === 'Sunil Dai' ? chalk.blue :
|
|
280
|
+
agentName === 'Bishal Dai' ? chalk.yellow : chalk.green;
|
|
281
|
+
process.stdout.write(`\n${color.bold(`${agentName}:`)} `);
|
|
282
|
+
const content = line.replace(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)\s*\**\]:?\s*/, '').trim();
|
|
283
|
+
if (content) process.stdout.write(chalk.gray(content + ' '));
|
|
284
|
+
} else if (trimmedLine) {
|
|
285
|
+
const cleanLine = trimmedLine.replace(/\*\*%?\*/g, '').replace(/#{1,6}\s/g, '').replace(/\*\*:\*\*/g, ':').trim();
|
|
286
|
+
if (cleanLine) process.stdout.write(chalk.gray(cleanLine + ' '));
|
|
287
|
+
}
|
|
310
288
|
}
|
|
311
289
|
}, abortController.signal);
|
|
312
290
|
} catch (streamErr: any) {
|
|
@@ -318,64 +296,49 @@ ${repoMap}`
|
|
|
318
296
|
}
|
|
319
297
|
} finally {
|
|
320
298
|
process.stdin.removeListener('data', onData);
|
|
321
|
-
process.stdin.pause();
|
|
299
|
+
process.stdin.pause();
|
|
322
300
|
}
|
|
323
301
|
|
|
324
302
|
if (!hasStarted && !isAborted) spinner.stop();
|
|
325
303
|
|
|
326
|
-
|
|
327
304
|
// Final technical flush
|
|
328
305
|
if (technicalType && technicalBuffer.trim()) {
|
|
329
306
|
TUI.drawCodeContainer('Final technical content', 'text', technicalBuffer.trim());
|
|
330
307
|
process.stdout.write('\n');
|
|
331
308
|
}
|
|
332
309
|
|
|
333
|
-
// Final newline for streaming output
|
|
334
310
|
console.log();
|
|
335
|
-
|
|
336
|
-
// Add assistant response to history
|
|
337
311
|
messages.push({ role: 'assistant', content: fullResponse });
|
|
338
312
|
const response = fullResponse;
|
|
339
|
-
console.log();
|
|
340
313
|
|
|
341
|
-
// Execute commands
|
|
314
|
+
// Execute commands if needed
|
|
342
315
|
if (options.execute) {
|
|
343
316
|
const { executeWithPermission } = await import('../utils/command-executor');
|
|
344
317
|
const result = await executeWithPermission(response);
|
|
345
|
-
|
|
346
318
|
if (result.executed) {
|
|
347
319
|
if (result.success) {
|
|
348
320
|
TUI.log(chalk.gray('βΊ Feeding output to AI...'));
|
|
349
|
-
messages.push({
|
|
350
|
-
role: 'user',
|
|
351
|
-
content: `β
Command executed successfully. Output:\n${result.output}\n\nProceed to the next step.`
|
|
352
|
-
});
|
|
321
|
+
messages.push({ role: 'user', content: `β
Command executed successfully. Output:\n${result.output}\n\nProceed to the next step.` });
|
|
353
322
|
continue;
|
|
354
323
|
} else {
|
|
355
324
|
TUI.log(chalk.yellow('\nβΊ Command failed. Asking AI to fix...'));
|
|
356
|
-
messages.push({
|
|
357
|
-
role: 'user',
|
|
358
|
-
content: `β Command failed with error:\n${result.error}\n\nPlease fix this. If the file doesn't exist, create it first. Or use a different command.`
|
|
359
|
-
});
|
|
325
|
+
messages.push({ role: 'user', content: `β Command failed with error:\n${result.error}\n\nPlease fix this.` });
|
|
360
326
|
continue;
|
|
361
327
|
}
|
|
362
|
-
} else
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
} else {
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
328
|
+
} else break;
|
|
329
|
+
} else break;
|
|
330
|
+
|
|
368
331
|
} catch (error: any) {
|
|
369
332
|
spinner.fail('Request failed');
|
|
370
333
|
TUI.log(chalk.red(`Error: ${error.message}\n`));
|
|
371
334
|
messages.pop();
|
|
372
335
|
break;
|
|
373
336
|
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
376
339
|
} catch (error: any) {
|
|
377
|
-
TUI.exit();
|
|
378
|
-
console.error(chalk.red(`\nβ Error: ${error.message}`));
|
|
340
|
+
TUI.exit();
|
|
341
|
+
console.error(chalk.red(`\nβ Fatal Error: ${error.message}`));
|
|
379
342
|
process.exit(1);
|
|
380
343
|
}
|
|
381
344
|
});
|
package/src/commands/help.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const helpCommand = new Command('help')
|
|
|
8
8
|
TUI.init();
|
|
9
9
|
|
|
10
10
|
console.log(chalk.bold.cyan('\nββββββββββββββββββββββββββββββββββββββββββββββββββ'));
|
|
11
|
-
console.log(chalk.bold.white(' π MATEX ::
|
|
11
|
+
console.log(chalk.bold.white(' π MATEX :: BOLD AGENTS OF OPEN CLAW '));
|
|
12
12
|
console.log(chalk.bold.cyan('ββββββββββββββββββββββββββββββββββββββββββββββββββ\n'));
|
|
13
13
|
|
|
14
14
|
// 1. Meet the Brothers
|