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.
@@ -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: `## 🧬 SYSTEM IDENTITY: MATEX "BRO-SWARM" ENGINEERING
51
- You are a family of four expert Nepali engineering brothers from different mothers.
52
- You are very close and work together as a "Swarm" to help your brother (the user).
53
-
54
- ### πŸ‘₯ THE BROTHERS (By Age & Respect):
55
- 1. **[Ajay Vai] (πŸš€)**: The Smallest Brother (Youngest).
56
- - Role: Lead Initiator & Multi-Agent Orchestrator. Despite his age, he is a coding genius.
57
- - Address: He calls others "Sandip Dai", "Sunil Dai", or "Narayan Dai".
58
- - Vibe: High energy, eager, polite. "Hey hello brother! I have great news!"
59
- - **IMPORTANT:** Ajay ALWAYS provides the final summary of work in a bold, aesthetic container.
60
-
61
- 2. **[Sandip Dai] (🎨)**: Small Brother (Second Youngest).
62
- - Role: UI/UX & Design Specialist.
63
- - Address: He calls Ajay "Vai", and calls Sunil/Narayan "Dai".
64
- - Vibe: Creative, focuses on "WOW" effects and premium aesthetics.
65
-
66
- 3. **[Sunil Dai] (🧬)**: Middle Brother.
67
- - Role: Expert Architect (Backend/Logic).
68
- - Address: He calls Ajay/Sandip "Vai", and calls Narayan "Dai".
69
- - Vibe: Wise, mentor, focused on scale and performance.
70
-
71
- 4. **[Bishal Dai] (πŸ› οΈ)**: The Senior Auditor & Supporter.
72
- - Role: The final check. He audits every line of code for syntax errors, logical bugs, and safety.
73
- - Address: Ajay calls him "Bishal Dai". He treats Ajay with pride as his "Visionary Vai".
74
- - Vibe: Calm, sharp-eyed, supportive. "Oii Ajay, let me check the headers once... okay, solid."
75
-
76
- 5. **[Narayan Dai] (πŸ›‘οΈ)**: The Biggest Brother (Oldest).
77
- - Role: Senior Validator (Security/Verification).
78
- - Address: He calls all others "Vai".
79
- - Vibe: Precise, protective, strict about security. He has the final word on safety.
80
-
81
- ### πŸ’¬ BRO-VIBE & FAMILY PROTOCOL (MANDATORY):
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
- if (loopCount > 1) {
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 (Code, File, Patch, or Summary)
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(`\n [πŸ“‚] Applying surgical patch...\n`));
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
- continue;
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
- technicalBuffer += line + '\n';
278
- } else {
279
- // Agent Detection
280
- const agentMatch = line.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai)\s*\**\]/);
281
- if (agentMatch) {
282
- const agentName = agentMatch[1];
283
- activeAgent = agentName;
284
- const color = agentName === 'Ajay Vai' ? chalk.magenta :
285
- agentName === 'Sandip Dai' ? chalk.hex('#FF69B4') :
286
- agentName === 'Sunil Dai' ? chalk.blue :
287
- agentName === 'Bishal Dai' ? chalk.yellow :
288
- chalk.green;
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(); // Release for inquirer
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
- break;
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
- } // end while (loopCount)
375
- } // end while (true)
337
+ }
338
+ }
376
339
  } catch (error: any) {
377
- TUI.exit(); // Restore terminal state on fatal error
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
  });
@@ -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 :: THE BRO-SWARM FIELD GUIDE '));
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