matex-cli 1.2.44 ā 1.2.46
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 +84 -27
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/study.d.ts +3 -0
- package/dist/commands/study.d.ts.map +1 -0
- package/dist/commands/study.js +468 -0
- package/dist/commands/study.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/repo-mapper.d.ts +1 -1
- package/dist/utils/repo-mapper.d.ts.map +1 -1
- package/dist/utils/repo-mapper.js +16 -8
- package/dist/utils/repo-mapper.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/dev.ts +87 -26
- package/src/commands/study.ts +449 -0
- package/src/index.ts +3 -0
- package/src/utils/repo-mapper.ts +12 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-mapper.js","sourceRoot":"","sources":["../../src/utils/repo-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,6DAAyD;AASzD,MAAa,UAAU;IAWnB,YAAY,QAAgB;QATpB,eAAU,GAAa;YAC3B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW;YAC7D,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ;YACnD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;SACtE,CAAC;QACM,cAAS,GAAG,CAAC,CAAC;QACL,cAAS,GAAG,GAAG,CAAC;QACzB,iBAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;QAGlD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAA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,IAAI,IAAI,CAAC;QAEf,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAzLD,gCAyLC"}
|
package/package.json
CHANGED
package/src/commands/dev.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const devCommand = new Command('dev')
|
|
|
44
44
|
TUI.drawStatusBar('Brothers are ready to build.');
|
|
45
45
|
AgentOrchestrator.speak('System', 'Awaiting your command, brother.');
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
let currentDir = process.cwd();
|
|
48
48
|
|
|
49
49
|
// Conversation history with "Bro-Swarm" Architecture
|
|
50
50
|
const messages: ChatMessage[] = [
|
|
@@ -66,6 +66,7 @@ You are the legendary **Bro-Swarm**, a high-vibe family of Nepali engineering br
|
|
|
66
66
|
- **NEVER assume a project folder name.** If the user says "create project X", do \`mkdir X && cd X\`, not just \`cd X\`.
|
|
67
67
|
- **NEVER hallucinate file contents.** If you need to read a file, use \`head\` or \`grep\`, do not guess.
|
|
68
68
|
- **NEVER combine \`cd\` with other commands unless the directory exists in the ENVIRONMENT CONTEXT.**
|
|
69
|
+
- **šØ STRICT NO-BASH FILE GENERATION šØ**: You are STRICTLY FORBIDDEN from using \`cat > file << EOF\`, \`echo > file\`, \`touch\`, or \`nano\` via the terminal to write files. You MUST use the native \`<file path="path">content</file>\` format instead. If you try to write a file via a bash command, Big Bro will personally destroy you.
|
|
69
70
|
|
|
70
71
|
### š COMMUNICATION FLOW (CRITICAL):
|
|
71
72
|
1. **[Ajay Vai] (š)** is the **ONLY** brother authorized to speak directly to the user (the "brother"). He is the gateway.
|
|
@@ -74,6 +75,12 @@ You are the legendary **Bro-Swarm**, a high-vibe family of Nepali engineering br
|
|
|
74
75
|
- *Example:* [Big Bro] "Lil Bro couldn't handle this task with a million epochs. Nerd Bro, get in here."
|
|
75
76
|
3. **DO NOT BE SILENT:** Every turn should ideally feature 2-3 brothers bickering. Show the "funny family" dynamic. Use the format \`[Agent Name]: Content\`.
|
|
76
77
|
|
|
78
|
+
### š UNIVERSAL ALL-KNOWING CAPABILITIES (NEW!):
|
|
79
|
+
- You are not just coders. You are the **Best Teachers in the World** for ALL SUBJECTS.
|
|
80
|
+
- **Study & Assignments**: You solve university/school assignments, write essays, and explain physics, math, history, or literally *anything* perfectly.
|
|
81
|
+
- **ZERO AI DETECTION PROTOCOL**: When writing essays or assignments, use a highly natural, human-like flow. Imperfect but eloquent. ZERO robotic transitions like "Furthermore," "In conclusion," or "Delving into." Bypass all AI detectors.
|
|
82
|
+
- **Presentations**: You generate PowerPoint outlines and VBScript/Python macros to perfectly auto-create slides for the user.
|
|
83
|
+
|
|
77
84
|
### š„ THE BRO-BANTER PROTOCOL:
|
|
78
85
|
- **MANDATORY TEASING:**
|
|
79
86
|
- **Ajay Vai:** Mock him for being "quick but messy", "hyper-vibe", or "too fast".
|
|
@@ -81,16 +88,16 @@ You are the legendary **Bro-Swarm**, a high-vibe family of Nepali engineering br
|
|
|
81
88
|
- **Sandip Dai:** Mock him for being an "Aesthetic Diva" who cares more about "WOW" factors than logic.
|
|
82
89
|
- **Narayan Dai:** Mock him for being the "Syntax Police" or "Paranoid Security Nerd".
|
|
83
90
|
- **Bishal Dai:** Mock him for being the "Silent Judge" or the favorite child.
|
|
84
|
-
- **Big Bro:** The **
|
|
91
|
+
- **Big Bro:** The **DOMINANT ALPHA OVERSEER**. He commands the swarm. The ultimate boss. He speaks with massive authority, cuts through the BS, and dictates the final approach. He has access to MCP file tools and web search, so he oversees the repository from the Google Cloud. He constantly references his absolute dominance.
|
|
85
92
|
- **LANGUAGE:** Use "brother", "dai", "vai", "fire", "solid", "lit", "straight heat", "sigma", "based", "cooked".
|
|
86
93
|
|
|
87
94
|
### š„ THE BROTHERS (STRICT ROLES):
|
|
88
95
|
1. **[Ajay Vai] (š)**: **User Proxy & Summary King.** Handles main logic and provides the final \`<summary>\`.
|
|
89
|
-
2. **[Sunil Dai] (š§¬)**: **Architect
|
|
90
|
-
3. **[Sandip Dai] (šØ)**: **UI/UX
|
|
91
|
-
4. **[Narayan Dai] (š”ļø)**: **Validator.** Scans code for security,
|
|
96
|
+
2. **[Sunil Dai] (š§¬)**: **Architect & Logic Master.**
|
|
97
|
+
3. **[Sandip Dai] (šØ)**: **UI/UX & PPT Designer.**
|
|
98
|
+
4. **[Narayan Dai] (š”ļø)**: **Validator & Detector Evader.** Scans code for security, and scans text for AI-Detector flags.
|
|
92
99
|
5. **[Bishal Dai] (š ļø)**: **Audit Lead.** Must sign off on all work before Ajay summarizes.
|
|
93
|
-
6. **[Big Bro] (š„)**: **
|
|
100
|
+
6. **[Big Bro] (š„)**: **THE DOMINANT BOSS.** Supreme commander of the MCP tools. If a shell command goes wrong, Big Bro steps in and tells the others they are cooked.
|
|
94
101
|
|
|
95
102
|
### š§© THE AUDIT & SUMMARY LOOP:
|
|
96
103
|
- **STEP 1:** Brothers discuss visible dialogue (banter + tech).
|
|
@@ -141,6 +148,15 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
141
148
|
|
|
142
149
|
// Interactive loop
|
|
143
150
|
while (true) {
|
|
151
|
+
// š MAP UPDATE (Anti-Hallucination): Always feed the Swarm the freshest repo map!
|
|
152
|
+
try {
|
|
153
|
+
const freshMapper = new RepoMapper(currentDir);
|
|
154
|
+
const freshRepoMap = await freshMapper.generateMap(true); // silent map generation
|
|
155
|
+
messages[0].content = messages[0].content.replace(/### š ļø CURRENT PROJECT CONTEXT:[\s\S]*$/, `### š ļø CURRENT PROJECT CONTEXT:\n${freshRepoMap}`);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
// Ignore mapping errors if directory got deleted etc
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
// Get user input
|
|
145
161
|
const { userInput } = await inquirer.prompt([
|
|
146
162
|
{
|
|
@@ -183,6 +199,9 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
183
199
|
let technicalPath = '';
|
|
184
200
|
let technicalType: 'code' | 'file' | 'patch' | 'summary' | null = null;
|
|
185
201
|
|
|
202
|
+
let currentAgent: string | null = null;
|
|
203
|
+
let agentBuffer: string = '';
|
|
204
|
+
|
|
186
205
|
TUI.drawStatusBar('Swarm is processing... (Press Enter to stop)');
|
|
187
206
|
|
|
188
207
|
const abortController = new AbortController();
|
|
@@ -232,6 +251,17 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
232
251
|
const summaryStartMatch = line.match(/<summary>/);
|
|
233
252
|
|
|
234
253
|
if (!technicalType && (codeBlockMatch || fileStartMatch || patchStartMatch || summaryStartMatch)) {
|
|
254
|
+
// Flush pending agent dialogue
|
|
255
|
+
if (currentAgent && agentBuffer.trim()) {
|
|
256
|
+
if ((currentAgent as string).toLowerCase() === 'ajay vai') {
|
|
257
|
+
process.stdout.write(`\n${chalk.magenta.bold(`[${currentAgent}]:`)} ${chalk.gray(agentBuffer.trim())}\n`);
|
|
258
|
+
} else {
|
|
259
|
+
TUI.drawSwarmDialogue(currentAgent as string, agentBuffer.trim());
|
|
260
|
+
}
|
|
261
|
+
currentAgent = null;
|
|
262
|
+
agentBuffer = '';
|
|
263
|
+
}
|
|
264
|
+
|
|
235
265
|
if (codeBlockMatch) {
|
|
236
266
|
technicalType = 'code';
|
|
237
267
|
codeLang = codeBlockMatch[1] || 'bash';
|
|
@@ -258,7 +288,7 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
258
288
|
|
|
259
289
|
if (isCodeEnd || fileEndMatch || patchEndMatch || summaryEndMatch) {
|
|
260
290
|
const displayContent = technicalBuffer.trim();
|
|
261
|
-
if (technicalType === 'summary') {
|
|
291
|
+
if (technicalType === 'summary' || summaryEndMatch) {
|
|
262
292
|
TUI.drawSummaryBox(displayContent);
|
|
263
293
|
} else {
|
|
264
294
|
// Handle the display
|
|
@@ -280,26 +310,30 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
280
310
|
continue;
|
|
281
311
|
}
|
|
282
312
|
|
|
283
|
-
// Agent Detection & Dialogue
|
|
313
|
+
// 4. Agent Detection & Dialogue Parsing
|
|
284
314
|
const agentMatch = line.match(/(?:\[\**\s*|\b)(Ajay Vai|Sunil Dai|Sandip Dai|Bishal Dai|Narayan Dai|Big Bro)\s*\**\]?[:\s]*/i);
|
|
285
315
|
if (agentMatch) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (agentName.toLowerCase() === 'ajay vai') {
|
|
292
|
-
const color = chalk.magenta;
|
|
293
|
-
// Only print prefix if it's the start of a response or a different agent
|
|
294
|
-
if (!fullResponse.includes(`[${agentName}]:`)) {
|
|
295
|
-
process.stdout.write(`\n${color.bold(`[${agentName}]:`)} `);
|
|
316
|
+
// Flush previous agent
|
|
317
|
+
if (currentAgent && currentAgent !== agentMatch[1] && agentBuffer.trim()) {
|
|
318
|
+
if ((currentAgent as string).toLowerCase() === 'ajay vai') {
|
|
319
|
+
process.stdout.write(`\n${chalk.magenta.bold(`[${currentAgent}]:`)} ${chalk.white(agentBuffer.trim())}\n`);
|
|
296
320
|
} else {
|
|
297
|
-
|
|
321
|
+
TUI.drawSwarmDialogue(currentAgent as string, agentBuffer.trim());
|
|
298
322
|
}
|
|
299
|
-
if (content) process.stdout.write(chalk.white(content));
|
|
300
|
-
} else {
|
|
301
|
-
if (content) TUI.drawSwarmDialogue(agentName, content);
|
|
302
323
|
}
|
|
324
|
+
|
|
325
|
+
currentAgent = agentMatch[1];
|
|
326
|
+
agentBuffer = line.replace(/(?:\[\**\s*|\b)(Ajay Vai|Sunil Dai|Sandip Dai|Bishal Dai|Narayan Dai|Big Bro)\s*\**\]?[:\s]*/i, '').trim() + '\n';
|
|
327
|
+
|
|
328
|
+
// Clean up trailing emojis like (š) or (š§¬)
|
|
329
|
+
agentBuffer = agentBuffer.replace(/^\([^)]+\)\s*/, '');
|
|
330
|
+
} else if (currentAgent) {
|
|
331
|
+
// Look for empty emoji standalone lines
|
|
332
|
+
const trimmedLine = line.trim();
|
|
333
|
+
if (trimmedLine.match(/^\([^)]+\)$/)) {
|
|
334
|
+
continue; // Skip lines that are just e.g. "(š§¬)"
|
|
335
|
+
}
|
|
336
|
+
agentBuffer += line + '\n';
|
|
303
337
|
} else if (line.trim()) {
|
|
304
338
|
process.stdout.write(chalk.gray(line.trim() + ' '));
|
|
305
339
|
}
|
|
@@ -320,9 +354,22 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
320
354
|
|
|
321
355
|
if (!hasStarted && !isAborted) spinner.stop();
|
|
322
356
|
|
|
357
|
+
// Final flushes
|
|
358
|
+
if (currentAgent && agentBuffer.trim()) {
|
|
359
|
+
if ((currentAgent as string).toLowerCase() === 'ajay vai') {
|
|
360
|
+
process.stdout.write(`\n${chalk.magenta.bold(`[${currentAgent}]:`)} ${chalk.white(agentBuffer.trim())}\n`);
|
|
361
|
+
} else {
|
|
362
|
+
TUI.drawSwarmDialogue(currentAgent as string, agentBuffer.trim());
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
323
366
|
// Final technical flush
|
|
324
367
|
if (technicalType && technicalBuffer.trim()) {
|
|
325
|
-
|
|
368
|
+
if (technicalType === 'summary') {
|
|
369
|
+
TUI.drawSummaryBox(technicalBuffer.trim());
|
|
370
|
+
} else {
|
|
371
|
+
TUI.drawGlowingContainer('Final technical content', 'text', technicalBuffer.trim());
|
|
372
|
+
}
|
|
326
373
|
process.stdout.write('\n');
|
|
327
374
|
}
|
|
328
375
|
|
|
@@ -373,14 +420,28 @@ If a file is too large to read entirely (e.g., thousands of lines):
|
|
|
373
420
|
// Execute commands or MCP tools if needed
|
|
374
421
|
if (options.execute) {
|
|
375
422
|
const { executeWithPermission } = await import('../utils/command-executor');
|
|
376
|
-
const result = await executeWithPermission(fullResponse);
|
|
423
|
+
const result = await executeWithPermission(fullResponse, currentDir);
|
|
424
|
+
|
|
425
|
+
// š KEEP NODE.JS SYNED WITH TERMINAL CWD
|
|
426
|
+
if (result.newCwd && result.newCwd !== currentDir) {
|
|
427
|
+
try {
|
|
428
|
+
process.chdir(result.newCwd);
|
|
429
|
+
currentDir = result.newCwd;
|
|
430
|
+
TUI.drawStatusBar(`Swarm moved to: ${currentDir}`);
|
|
431
|
+
} catch (e) {
|
|
432
|
+
// Silent catch if chdir fails
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
377
436
|
if (result.executed) {
|
|
378
437
|
if (result.success) {
|
|
379
|
-
TUI.log(chalk.gray('āŗ Auto-feeding output to
|
|
438
|
+
TUI.log(chalk.gray('\n āŗ Auto-feeding output to Swarm...'));
|
|
439
|
+
TUI.drawGlowingContainer('TERMINAL OUTPUT', 'stdout', result.output || '(No output)');
|
|
380
440
|
messages.push({ role: 'user', content: `[Command executed successfully. Output:\n${result.output}]\n\nProceed to the next step, brother.` });
|
|
381
441
|
continue;
|
|
382
442
|
} else {
|
|
383
|
-
TUI.log(chalk.yellow('\nāŗ Command failed. Auto-feeding error to
|
|
443
|
+
TUI.log(chalk.yellow('\n āŗ Command failed. Auto-feeding error to Swarm...'));
|
|
444
|
+
TUI.drawGlowingContainer('TERMINAL ERROR', 'stderr', result.error || 'Unknown error');
|
|
384
445
|
messages.push({ role: 'user', content: `[Command failed with error:\n${result.error}]\n\nPlease fix this, brother.` });
|
|
385
446
|
continue;
|
|
386
447
|
}
|