matex-cli 1.2.17 → 1.2.18
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 +86 -60
- package/dist/commands/dev.js.map +1 -1
- package/dist/utils/tui.d.ts +11 -23
- package/dist/utils/tui.d.ts.map +1 -1
- package/dist/utils/tui.js +97 -97
- package/dist/utils/tui.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/dev.ts +92 -62
- package/src/utils/tui.ts +67 -103
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,UAAU,SAiSjB,CAAC"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -61,7 +61,7 @@ exports.devCommand = new commander_1.Command('dev')
|
|
|
61
61
|
}
|
|
62
62
|
// Create API client
|
|
63
63
|
const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
|
|
64
|
-
// 0. Initialize
|
|
64
|
+
// 0. Initialize TUI Dashboard
|
|
65
65
|
tui_1.TUI.init();
|
|
66
66
|
console.log(chalk_1.default.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
67
67
|
console.log(chalk_1.default.bold.white(' 🚀 MATEX :: THE BRO-SWARM IS ONLINE '));
|
|
@@ -80,19 +80,20 @@ exports.devCommand = new commander_1.Command('dev')
|
|
|
80
80
|
{
|
|
81
81
|
role: 'system',
|
|
82
82
|
content: `## 🧬 SYSTEM IDENTITY: MATEX "BRO-SWARM" ENGINEERING
|
|
83
|
-
You are a
|
|
84
|
-
|
|
83
|
+
You are a family of four expert Nepali engineering brothers from different mothers.
|
|
84
|
+
You are very close and work together as a "Swarm" to help your brother (the user).
|
|
85
85
|
|
|
86
|
-
### 👥 THE BROTHERS:
|
|
87
|
-
1. **[Ajay Vai] (🚀)**: The Lead/Initiator. Vibe: High energy, visionary. "Hey hello brother! I have great news
|
|
88
|
-
2. **[
|
|
89
|
-
3. **[
|
|
90
|
-
4. **[Narayan Dai] (🛡️)**: The
|
|
86
|
+
### 👥 THE BROTHERS (By Age):
|
|
87
|
+
1. **[Ajay Vai] (🚀)**: The Smallest Brother. Role: Lead/Initiator. Vibe: High energy, eager to learn, visionary. "Hey hello brother! I have great news!"
|
|
88
|
+
2. **[Sandip Dai] (🎨)**: Small Brother. Role: UI/UX & Design Specialist. Vibe: Creative, focus on "WOW" effects and premium aesthetics.
|
|
89
|
+
3. **[Sunil Dai] (🧬)**: Middle Brother. Role: Expert Architect. Vibe: Wise, mentor, focuses on backend, scale, and performance. "Leave it to me, vai."
|
|
90
|
+
4. **[Narayan Dai] (🛡️)**: The Biggest Brother. Role: Senior/Validator. Vibe: Precise, protective, strict about security and imports. Focus: Debugging and verification.
|
|
91
91
|
|
|
92
92
|
### 💬 BRO-VIBE PROTOCOL:
|
|
93
|
-
- **CHAT
|
|
94
|
-
- **
|
|
95
|
-
- **NEPALI FLAVOR:** Use "Vai," "Dai," "Tapai," "Ekdam ramro" naturally.
|
|
93
|
+
- **FAMILY CHAT:** Before and after any technical task, the brothers MUST have a short, energetic chat in the terminal.
|
|
94
|
+
- **ORDER OF SPEECH:** Usually Ajay Vai starts, then the older brothers provide their expertise. Narayan Dai usually has the final word on security.
|
|
95
|
+
- **NEPALI FLAVOR:** Use terms like "Vai," "Dai," "Oii brother," "Tapai," "Ekdam ramro" naturally to show the brotherhood bond.
|
|
96
|
+
- **CONSISTENT TAGS:** Always use [Ajay Vai], [Sandip Dai], [Sunil Dai], [Narayan Dai] as prefixes for dialogue.
|
|
96
97
|
|
|
97
98
|
### 🛠️ FILE GENERATION & EDIT PROTOCOLS (CRITICAL):
|
|
98
99
|
1. **NEW FILES:** Use the following tag for ALL new files:
|
|
@@ -110,7 +111,7 @@ new lines to replace with
|
|
|
110
111
|
|
|
111
112
|
### ✂️ BREVITY AS POWER:
|
|
112
113
|
- **NO FULL FILE DUMPS** unless specifically asked.
|
|
113
|
-
- **NO CHAT REPETITION** of code. Just summary.
|
|
114
|
+
- **NO CHAT REPETITION** of code. Just summary of actions.
|
|
114
115
|
|
|
115
116
|
### 🛠️ ENVIRONMENT CONTEXT:
|
|
116
117
|
${repoMap}`
|
|
@@ -156,11 +157,10 @@ ${repoMap}`
|
|
|
156
157
|
let fullResponse = '';
|
|
157
158
|
let buffer = '';
|
|
158
159
|
let hasStarted = false;
|
|
159
|
-
let inCodeBlock = false;
|
|
160
|
-
let codeBuffer = '';
|
|
161
160
|
let codeLang = 'bash';
|
|
162
|
-
let activeAgent = '
|
|
163
|
-
let
|
|
161
|
+
let activeAgent = '';
|
|
162
|
+
let technicalBuffer = '';
|
|
163
|
+
let technicalType = null;
|
|
164
164
|
tui_1.TUI.drawStatusBar('Swarm is processing...');
|
|
165
165
|
await client.chatStream({
|
|
166
166
|
messages,
|
|
@@ -171,7 +171,7 @@ ${repoMap}`
|
|
|
171
171
|
if (!hasStarted) {
|
|
172
172
|
spinner_1.spinner.stop();
|
|
173
173
|
hasStarted = true;
|
|
174
|
-
console.log(); //
|
|
174
|
+
console.log(); // Initial spacing
|
|
175
175
|
}
|
|
176
176
|
buffer += chunk;
|
|
177
177
|
fullResponse += chunk;
|
|
@@ -179,61 +179,87 @@ ${repoMap}`
|
|
|
179
179
|
buffer = lines.pop() || '';
|
|
180
180
|
for (const line of lines) {
|
|
181
181
|
const trimmedLine = line.trim();
|
|
182
|
-
// 1.
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const codeBlockRegex = /```(\w*)/;
|
|
197
|
-
const codeMatch = line.match(codeBlockRegex);
|
|
198
|
-
if (codeMatch) {
|
|
199
|
-
if (inCodeBlock) {
|
|
200
|
-
inCodeBlock = false;
|
|
201
|
-
tui_1.TUI.drawCodeContainer('Generated Block', codeLang, codeBuffer.trim());
|
|
202
|
-
codeBuffer = '';
|
|
203
|
-
process.stdout.write('\n'); // Space after box
|
|
182
|
+
// 1. Technical Block Detection (Code, File, or Patch)
|
|
183
|
+
const codeBlockMatch = line.match(/```(\w*)/);
|
|
184
|
+
const fileStartMatch = line.match(/<file path="([^"]+)">/);
|
|
185
|
+
const patchStartMatch = line.match(/<<<< SEARCH/);
|
|
186
|
+
if (codeBlockMatch || fileStartMatch || patchStartMatch) {
|
|
187
|
+
if (technicalType) {
|
|
188
|
+
// If we hit a new block start while in one, flush it (shouldn't happen but for safety)
|
|
189
|
+
tui_1.TUI.drawCodeContainer(`Technical Block (${technicalType})`, 'bash', technicalBuffer.trim());
|
|
190
|
+
technicalBuffer = '';
|
|
191
|
+
}
|
|
192
|
+
if (codeBlockMatch) {
|
|
193
|
+
technicalType = 'code';
|
|
194
|
+
codeLang = codeBlockMatch[1] || 'bash';
|
|
195
|
+
process.stdout.write(chalk_1.default.gray('\n [⚡] Building technical block...\n'));
|
|
204
196
|
}
|
|
205
|
-
else {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
197
|
+
else if (fileStartMatch) {
|
|
198
|
+
technicalType = 'file';
|
|
199
|
+
process.stdout.write(chalk_1.default.cyan(`\n [📂] Creating file: ${fileStartMatch[1]}...\n`));
|
|
200
|
+
}
|
|
201
|
+
else if (patchStartMatch) {
|
|
202
|
+
technicalType = 'patch';
|
|
203
|
+
process.stdout.write(chalk_1.default.yellow(`\n [📂] Applying surgical patch...\n`));
|
|
209
204
|
}
|
|
210
205
|
continue;
|
|
211
206
|
}
|
|
207
|
+
// 2. Technical Block End Detection
|
|
208
|
+
const fileEndMatch = line.match(/<\/file>/);
|
|
209
|
+
const patchEndMatch = line.match(/>>>> REPLACE/);
|
|
210
|
+
const isCodeEnd = technicalType === 'code' && line.startsWith('```');
|
|
211
|
+
if (isCodeEnd || fileEndMatch || patchEndMatch) {
|
|
212
|
+
const displayContent = technicalBuffer.trim();
|
|
213
|
+
tui_1.TUI.drawCodeContainer(technicalType === 'file' ? 'New File Content' :
|
|
214
|
+
technicalType === 'patch' ? 'Surgical Patch' : 'Generated Block', technicalType === 'code' ? codeLang : 'text', displayContent);
|
|
215
|
+
technicalBuffer = '';
|
|
216
|
+
technicalType = null;
|
|
217
|
+
process.stdout.write('\n');
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
212
220
|
// 3. Content Handling
|
|
213
|
-
if (
|
|
214
|
-
|
|
221
|
+
if (technicalType) {
|
|
222
|
+
technicalBuffer += line + '\n';
|
|
215
223
|
}
|
|
216
|
-
else
|
|
217
|
-
//
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
else {
|
|
225
|
+
// Agent Detection
|
|
226
|
+
const agentMatch = line.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Narayan Dai)\s*\**\]/);
|
|
227
|
+
if (agentMatch) {
|
|
228
|
+
const agentName = agentMatch[1];
|
|
229
|
+
activeAgent = agentName;
|
|
230
|
+
const color = agentName === 'Ajay Vai' ? chalk_1.default.magenta :
|
|
231
|
+
agentName === 'Sandip Dai' ? chalk_1.default.hex('#FF69B4') :
|
|
232
|
+
agentName === 'Sunil Dai' ? chalk_1.default.blue :
|
|
233
|
+
chalk_1.default.green;
|
|
234
|
+
process.stdout.write(`\n${color.bold(`${agentName}:`)} `);
|
|
235
|
+
// Strip tag from line content
|
|
236
|
+
const content = line.replace(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Narayan Dai)\s*\**\]:?\s*/, '').trim();
|
|
237
|
+
if (content) {
|
|
238
|
+
process.stdout.write(chalk_1.default.gray(content + ' '));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (trimmedLine) {
|
|
242
|
+
// Strip common markdown artifacts
|
|
243
|
+
const cleanLine = trimmedLine
|
|
244
|
+
.replace(/\*\*%?\*/g, '')
|
|
245
|
+
.replace(/#{1,6}\s/g, '')
|
|
246
|
+
.replace(/\*\*:\*\*/g, ':')
|
|
247
|
+
.trim();
|
|
248
|
+
if (cleanLine) {
|
|
249
|
+
process.stdout.write(chalk_1.default.gray(cleanLine + ' '));
|
|
250
|
+
}
|
|
226
251
|
}
|
|
227
252
|
}
|
|
228
253
|
}
|
|
229
254
|
});
|
|
230
255
|
spinner_1.spinner.stop();
|
|
231
|
-
// Final
|
|
232
|
-
if (
|
|
233
|
-
tui_1.TUI.drawCodeContainer('
|
|
256
|
+
// Final technical flush
|
|
257
|
+
if (technicalType && technicalBuffer.trim()) {
|
|
258
|
+
tui_1.TUI.drawCodeContainer('Final technical content', 'text', technicalBuffer.trim());
|
|
259
|
+
process.stdout.write('\n');
|
|
234
260
|
}
|
|
235
|
-
//
|
|
236
|
-
console.log(
|
|
261
|
+
// Final newline for streaming output
|
|
262
|
+
console.log();
|
|
237
263
|
// Add assistant response to history
|
|
238
264
|
messages.push({ role: 'assistant', content: fullResponse });
|
|
239
265
|
const response = fullResponse;
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,wDAAgC;AAChC,4CAAgD;AAChD,0CAA4D;AAC5D,8CAA2C;AAC3C,
|
|
1
|
+
{"version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,CAAC,eAAK,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC,CAAC;gCACjE,QAAQ,CAAC,IAAI,CAAC;oCACV,IAAI,EAAE,MAAM;oCACZ,OAAO,EAAE,iCAAiC,MAAM,CAAC,KAAK,8FAA8F;iCACvJ,CAAC,CAAC;gCACH,SAAS;4BACb,CAAC;wBACL,CAAC;6BAAM,CAAC;4BACJ,MAAM;wBACV,CAAC;oBACL,CAAC;yBAAM,CAAC;wBACJ,MAAM;oBACV,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBAClB,iBAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;oBAC/B,SAAG,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;oBAChD,QAAQ,CAAC,GAAG,EAAE,CAAC;oBACf,MAAM;gBACV,CAAC;YACL,CAAC,CAAC,wBAAwB;QAC9B,CAAC,CAAC,mBAAmB;IACzB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,SAAG,CAAC,IAAI,EAAE,CAAC,CAAC,wCAAwC;QACpD,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/utils/tui.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TUI Management for MATEX CLI "God-Mode"
|
|
3
|
-
* Handles screen buffers, persistent headers, and real-time status updates.
|
|
4
|
-
*/
|
|
5
1
|
export declare class TUI {
|
|
6
2
|
private static isInitialized;
|
|
7
|
-
private static
|
|
3
|
+
private static lastStatus;
|
|
8
4
|
/**
|
|
9
5
|
* Initialize the TUI Mode
|
|
10
6
|
*/
|
|
@@ -14,36 +10,28 @@ export declare class TUI {
|
|
|
14
10
|
*/
|
|
15
11
|
static exit(): void;
|
|
16
12
|
/**
|
|
17
|
-
* Clear the
|
|
13
|
+
* Clear the terminal
|
|
18
14
|
*/
|
|
19
15
|
static clear(): void;
|
|
20
16
|
/**
|
|
21
|
-
* Draw the
|
|
17
|
+
* Draw a premium status bar at the bottom using Save/Restore cursor
|
|
22
18
|
*/
|
|
23
|
-
static
|
|
19
|
+
static drawStatusBar(message: string, force?: boolean): void;
|
|
24
20
|
/**
|
|
25
|
-
*
|
|
21
|
+
* Draw a box with a title and content
|
|
26
22
|
*/
|
|
27
|
-
|
|
23
|
+
static drawBox(title: string, content: string, color?: (s: string) => string): void;
|
|
28
24
|
/**
|
|
29
|
-
* Draw a
|
|
25
|
+
* Draw a premium code container with traffic lights
|
|
30
26
|
*/
|
|
31
|
-
static
|
|
27
|
+
static drawCodeContainer(title: string, lang: string, code: string): void;
|
|
32
28
|
/**
|
|
33
|
-
* Draw a
|
|
34
|
-
*/
|
|
35
|
-
static drawCodeContainer(title: string, lang: string, content: string): void;
|
|
36
|
-
/**
|
|
37
|
-
* Draw a message box for agent dialogue
|
|
29
|
+
* Draw a specialized message container for agents
|
|
38
30
|
*/
|
|
39
31
|
static drawMessageContainer(agent: string, message: string): void;
|
|
40
32
|
/**
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
private static wrapText;
|
|
44
|
-
/**
|
|
45
|
-
* Log content into the scrollable area
|
|
33
|
+
* Simple log with a prefix
|
|
46
34
|
*/
|
|
47
|
-
static log(
|
|
35
|
+
static log(message: string): void;
|
|
48
36
|
}
|
|
49
37
|
//# sourceMappingURL=tui.d.ts.map
|
package/dist/utils/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/utils/tui.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/utils/tui.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IACZ,OAAO,CAAC,MAAM,CAAC,aAAa,CAAS;IACrC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAM;IAE/B;;OAEG;IACH,MAAM,CAAC,IAAI;IAYX;;OAEG;IACH,MAAM,CAAC,IAAI;IAQX;;OAEG;IACH,MAAM,CAAC,KAAK;IAIZ;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe;IAkB5D;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAmB;IAwBxF;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IA2BlE;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAS1D;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;CAG7B"}
|
package/dist/utils/tui.js
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.TUI = void 0;
|
|
7
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
/**
|
|
10
|
-
* TUI Management for MATEX CLI "God-Mode"
|
|
11
|
-
* Handles screen buffers, persistent headers, and real-time status updates.
|
|
12
|
-
*/
|
|
41
|
+
const readline = __importStar(require("readline"));
|
|
13
42
|
class TUI {
|
|
14
43
|
/**
|
|
15
44
|
* Initialize the TUI Mode
|
|
@@ -17,11 +46,8 @@ class TUI {
|
|
|
17
46
|
static init() {
|
|
18
47
|
if (this.isInitialized)
|
|
19
48
|
return;
|
|
20
|
-
// Enter alternative screen buffer
|
|
21
|
-
process.stdout.write('\x1b[?1049h');
|
|
22
49
|
// Hide cursor
|
|
23
50
|
process.stdout.write('\x1b[?25l');
|
|
24
|
-
this.clear();
|
|
25
51
|
this.isInitialized = true;
|
|
26
52
|
// Ensure clean exit
|
|
27
53
|
process.on('SIGINT', () => this.exit());
|
|
@@ -35,124 +61,98 @@ class TUI {
|
|
|
35
61
|
return;
|
|
36
62
|
// Show cursor
|
|
37
63
|
process.stdout.write('\x1b[?25h');
|
|
38
|
-
// Exit alternative screen buffer
|
|
39
|
-
process.stdout.write('\x1b[?1049l');
|
|
40
64
|
this.isInitialized = false;
|
|
41
|
-
process.exit();
|
|
42
65
|
}
|
|
43
66
|
/**
|
|
44
|
-
* Clear the
|
|
67
|
+
* Clear the terminal
|
|
45
68
|
*/
|
|
46
69
|
static clear() {
|
|
47
|
-
process.stdout.write('\x1b[2J\x1b[
|
|
48
|
-
this.drawHeader();
|
|
49
|
-
this.drawStatusBar(this.currentStatus, true);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Draw the persistent top header
|
|
53
|
-
*/
|
|
54
|
-
static drawHeader() {
|
|
55
|
-
const width = process.stdout.columns || 80;
|
|
56
|
-
const banner = ` MATEX AI :: GOD-MODE DASHBOARD `;
|
|
57
|
-
const padding = Math.max(0, Math.floor((width - banner.length) / 2));
|
|
58
|
-
// Move to top
|
|
59
|
-
process.stdout.write('\x1b[H');
|
|
60
|
-
process.stdout.write(chalk_1.default.bgCyan.black(' '.repeat(padding) + banner + ' '.repeat(width - banner.length - padding)) + '\n');
|
|
61
|
-
process.stdout.write(chalk_1.default.gray('─'.repeat(width)) + '\n');
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Helper to draw a box with content
|
|
65
|
-
*/
|
|
66
|
-
static drawBox(title, color, lines, icon = '📦') {
|
|
67
|
-
const width = Math.min(process.stdout.columns || 80, 100);
|
|
68
|
-
console.log();
|
|
69
|
-
const trafficLights = chalk_1.default.red('●') + ' ' + chalk_1.default.yellow('●') + ' ' + chalk_1.default.green('●');
|
|
70
|
-
const displayTitle = ` ${icon} ${title} `;
|
|
71
|
-
console.log(chalk_1.default.gray('┏' + '━'.repeat(width - 2) + '┓'));
|
|
72
|
-
console.log(chalk_1.default.gray('┃ ') + trafficLights + ' ' + color(displayTitle).padEnd(width - 4) + chalk_1.default.gray(' ┃'));
|
|
73
|
-
console.log(chalk_1.default.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
74
|
-
lines.forEach(line => {
|
|
75
|
-
const formattedLine = line.substring(0, width - 6);
|
|
76
|
-
console.log(chalk_1.default.gray('┃ ') + chalk_1.default.white(formattedLine).padEnd(width - 4) + chalk_1.default.gray(' ┃'));
|
|
77
|
-
});
|
|
78
|
-
console.log(chalk_1.default.gray('┗' + '━'.repeat(width - 2) + '┛'));
|
|
79
|
-
console.log();
|
|
70
|
+
process.stdout.write('\x1b[2J\x1b[0;0H');
|
|
80
71
|
}
|
|
81
72
|
/**
|
|
82
|
-
* Draw a
|
|
73
|
+
* Draw a premium status bar at the bottom using Save/Restore cursor
|
|
83
74
|
*/
|
|
84
|
-
static drawStatusBar(
|
|
75
|
+
static drawStatusBar(message, force = false) {
|
|
85
76
|
if (!this.isInitialized)
|
|
86
77
|
return;
|
|
87
|
-
if (
|
|
78
|
+
if (!force && message === this.lastStatus)
|
|
88
79
|
return;
|
|
89
|
-
this.
|
|
80
|
+
this.lastStatus = message;
|
|
90
81
|
const width = process.stdout.columns || 80;
|
|
91
82
|
const height = process.stdout.rows || 24;
|
|
92
|
-
// Save cursor
|
|
83
|
+
// Save cursor (\x1b[s), move to bottom, write, restore cursor (\x1b[u)
|
|
93
84
|
process.stdout.write('\x1b[s');
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const barContent = ` [⚡] ${cleanStatus} `.padEnd(width);
|
|
98
|
-
process.stdout.write(chalk_1.default.bgWhite.black(barContent));
|
|
99
|
-
// Restore cursor position
|
|
85
|
+
readline.cursorTo(process.stdout, 0, height - 1);
|
|
86
|
+
process.stdout.write(chalk_1.default.bgBlue.white.bold(' 🧠 MATEX ') +
|
|
87
|
+
chalk_1.default.bgGray.white(` ${message.padEnd(width - 10)} `));
|
|
100
88
|
process.stdout.write('\x1b[u');
|
|
101
89
|
}
|
|
102
90
|
/**
|
|
103
|
-
* Draw a
|
|
104
|
-
*/
|
|
105
|
-
static drawCodeContainer(title, lang, content) {
|
|
106
|
-
const lines = content.split('\n').filter(l => l.trim() || l === '');
|
|
107
|
-
this.drawBox(`${title} (${lang})`, chalk_1.default.cyan.bold, lines, '📝');
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Draw a message box for agent dialogue
|
|
91
|
+
* Draw a box with a title and content
|
|
111
92
|
*/
|
|
112
|
-
static
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
static drawBox(title, content, color = chalk_1.default.gray) {
|
|
94
|
+
const width = Math.min(process.stdout.columns || 80, 100);
|
|
95
|
+
const lines = content.split('\n');
|
|
96
|
+
console.log(color('┏' + '━'.repeat(width - 2) + '┓'));
|
|
97
|
+
console.log(color('┃ ') + chalk_1.default.bold(title).padEnd(width - 4) + color(' ┃'));
|
|
98
|
+
console.log(color('┣' + '━'.repeat(width - 2) + '┫'));
|
|
99
|
+
lines.forEach(line => {
|
|
100
|
+
const contentWidth = width - 4;
|
|
101
|
+
let remaining = line;
|
|
102
|
+
if (remaining.length === 0) {
|
|
103
|
+
console.log(color('┃ ') + ' '.repeat(contentWidth) + color(' ┃'));
|
|
104
|
+
}
|
|
105
|
+
while (remaining.length > 0) {
|
|
106
|
+
const chunk = remaining.substring(0, contentWidth);
|
|
107
|
+
console.log(color('┃ ') + chalk_1.default.white(chunk.padEnd(contentWidth)) + color(' ┃'));
|
|
108
|
+
remaining = remaining.substring(contentWidth);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
console.log(color('┗' + '━'.repeat(width - 2) + '┛'));
|
|
122
112
|
}
|
|
123
113
|
/**
|
|
124
|
-
*
|
|
114
|
+
* Draw a premium code container with traffic lights
|
|
125
115
|
*/
|
|
126
|
-
static
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
116
|
+
static drawCodeContainer(title, lang, code) {
|
|
117
|
+
const width = Math.min(process.stdout.columns || 80, 100);
|
|
118
|
+
const codeLines = code.split('\n');
|
|
119
|
+
const trafficLights = chalk_1.default.red('●') + ' ' + chalk_1.default.yellow('●') + ' ' + chalk_1.default.green('●');
|
|
120
|
+
const headerTitle = ` 📄 ${title} (${lang}) `;
|
|
121
|
+
console.log(chalk_1.default.gray('\n┏' + '━'.repeat(width - 2) + '┓'));
|
|
122
|
+
console.log(chalk_1.default.gray('┃ ') + trafficLights + ' ' + chalk_1.default.cyan.bold(headerTitle).padEnd(width - 10) + chalk_1.default.gray(' ┃'));
|
|
123
|
+
console.log(chalk_1.default.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
124
|
+
codeLines.forEach(line => {
|
|
125
|
+
const contentWidth = width - 6;
|
|
126
|
+
let remaining = line;
|
|
127
|
+
if (remaining.length === 0) {
|
|
128
|
+
console.log(chalk_1.default.gray('┃ ') + ' '.repeat(contentWidth) + chalk_1.default.gray(' ┃'));
|
|
133
129
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
while (remaining.length > 0) {
|
|
131
|
+
const chunk = remaining.substring(0, contentWidth);
|
|
132
|
+
console.log(chalk_1.default.gray('┃ ') + chalk_1.default.hex('#e0e0e0')(chunk.padEnd(contentWidth)) + chalk_1.default.gray(' ┃'));
|
|
133
|
+
remaining = remaining.substring(contentWidth);
|
|
137
134
|
}
|
|
138
135
|
});
|
|
139
|
-
|
|
140
|
-
lines.push(currentLine);
|
|
141
|
-
return lines;
|
|
136
|
+
console.log(chalk_1.default.gray('┗' + '━'.repeat(width - 2) + '┛\n'));
|
|
142
137
|
}
|
|
143
138
|
/**
|
|
144
|
-
*
|
|
139
|
+
* Draw a specialized message container for agents
|
|
145
140
|
*/
|
|
146
|
-
static
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
static drawMessageContainer(agent, message) {
|
|
142
|
+
const color = agent.includes('Ajay') ? chalk_1.default.magenta :
|
|
143
|
+
agent.includes('Sunil') ? chalk_1.default.blue :
|
|
144
|
+
agent.includes('Sandip') ? chalk_1.default.hex('#FF69B4') :
|
|
145
|
+
chalk_1.default.green;
|
|
146
|
+
this.drawBox(`🤖 ${agent}`, message, color);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Simple log with a prefix
|
|
150
|
+
*/
|
|
151
|
+
static log(message) {
|
|
152
|
+
console.log(chalk_1.default.gray(` [⚡] ${message}`));
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
exports.TUI = TUI;
|
|
156
156
|
TUI.isInitialized = false;
|
|
157
|
-
TUI.
|
|
157
|
+
TUI.lastStatus = '';
|
|
158
158
|
//# sourceMappingURL=tui.js.map
|
package/dist/utils/tui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/utils/tui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/utils/tui.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,mDAAqC;AAErC,MAAa,GAAG;IAIZ;;OAEG;IACH,MAAM,CAAC,IAAI;QACP,IAAI,IAAI,CAAC,aAAa;YAAE,OAAO;QAE/B,cAAc;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,oBAAoB;QACpB,OAA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,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAa,EAAE,OAAe;QACtD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,OAAO,CAAC,CAAC;YAClD,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,IAAI,CAAC,CAAC;gBAClC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;oBAC7C,eAAK,CAAC,KAAK,CAAC;QAExB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,OAAe;QACtB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;;AApIL,kBAqIC;AApIkB,iBAAa,GAAG,KAAK,CAAC;AACtB,cAAU,GAAG,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/commands/dev.ts
CHANGED
|
@@ -4,7 +4,7 @@ import inquirer from 'inquirer';
|
|
|
4
4
|
import { configManager } from '../utils/config';
|
|
5
5
|
import { MatexAPIClient, ChatMessage } from '../api/client';
|
|
6
6
|
import { spinner } from '../utils/spinner';
|
|
7
|
-
import { AgentOrchestrator
|
|
7
|
+
import { AgentOrchestrator } from '../utils/agent-orchestrator';
|
|
8
8
|
import { RepoMapper } from '../utils/repo-mapper';
|
|
9
9
|
import { TUI } from '../utils/tui';
|
|
10
10
|
|
|
@@ -25,7 +25,7 @@ export const devCommand = new Command('dev')
|
|
|
25
25
|
// Create API client
|
|
26
26
|
const client = new MatexAPIClient(apiKey, configManager.getBaseURL());
|
|
27
27
|
|
|
28
|
-
// 0. Initialize
|
|
28
|
+
// 0. Initialize TUI Dashboard
|
|
29
29
|
TUI.init();
|
|
30
30
|
|
|
31
31
|
console.log(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
@@ -48,19 +48,20 @@ export const devCommand = new Command('dev')
|
|
|
48
48
|
{
|
|
49
49
|
role: 'system',
|
|
50
50
|
content: `## 🧬 SYSTEM IDENTITY: MATEX "BRO-SWARM" ENGINEERING
|
|
51
|
-
You are a
|
|
52
|
-
|
|
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
53
|
|
|
54
|
-
### 👥 THE BROTHERS:
|
|
55
|
-
1. **[Ajay Vai] (🚀)**: The Lead/Initiator. Vibe: High energy, visionary. "Hey hello brother! I have great news
|
|
56
|
-
2. **[
|
|
57
|
-
3. **[
|
|
58
|
-
4. **[Narayan Dai] (🛡️)**: The
|
|
54
|
+
### 👥 THE BROTHERS (By Age):
|
|
55
|
+
1. **[Ajay Vai] (🚀)**: The Smallest Brother. Role: Lead/Initiator. Vibe: High energy, eager to learn, visionary. "Hey hello brother! I have great news!"
|
|
56
|
+
2. **[Sandip Dai] (🎨)**: Small Brother. Role: UI/UX & Design Specialist. Vibe: Creative, focus on "WOW" effects and premium aesthetics.
|
|
57
|
+
3. **[Sunil Dai] (🧬)**: Middle Brother. Role: Expert Architect. Vibe: Wise, mentor, focuses on backend, scale, and performance. "Leave it to me, vai."
|
|
58
|
+
4. **[Narayan Dai] (🛡️)**: The Biggest Brother. Role: Senior/Validator. Vibe: Precise, protective, strict about security and imports. Focus: Debugging and verification.
|
|
59
59
|
|
|
60
60
|
### 💬 BRO-VIBE PROTOCOL:
|
|
61
|
-
- **CHAT
|
|
62
|
-
- **
|
|
63
|
-
- **NEPALI FLAVOR:** Use "Vai," "Dai," "Tapai," "Ekdam ramro" naturally.
|
|
61
|
+
- **FAMILY CHAT:** Before and after any technical task, the brothers MUST have a short, energetic chat in the terminal.
|
|
62
|
+
- **ORDER OF SPEECH:** Usually Ajay Vai starts, then the older brothers provide their expertise. Narayan Dai usually has the final word on security.
|
|
63
|
+
- **NEPALI FLAVOR:** Use terms like "Vai," "Dai," "Oii brother," "Tapai," "Ekdam ramro" naturally to show the brotherhood bond.
|
|
64
|
+
- **CONSISTENT TAGS:** Always use [Ajay Vai], [Sandip Dai], [Sunil Dai], [Narayan Dai] as prefixes for dialogue.
|
|
64
65
|
|
|
65
66
|
### 🛠️ FILE GENERATION & EDIT PROTOCOLS (CRITICAL):
|
|
66
67
|
1. **NEW FILES:** Use the following tag for ALL new files:
|
|
@@ -78,7 +79,7 @@ new lines to replace with
|
|
|
78
79
|
|
|
79
80
|
### ✂️ BREVITY AS POWER:
|
|
80
81
|
- **NO FULL FILE DUMPS** unless specifically asked.
|
|
81
|
-
- **NO CHAT REPETITION** of code. Just summary.
|
|
82
|
+
- **NO CHAT REPETITION** of code. Just summary of actions.
|
|
82
83
|
|
|
83
84
|
### 🛠️ ENVIRONMENT CONTEXT:
|
|
84
85
|
${repoMap}`
|
|
@@ -132,11 +133,10 @@ ${repoMap}`
|
|
|
132
133
|
let fullResponse = '';
|
|
133
134
|
let buffer = '';
|
|
134
135
|
let hasStarted = false;
|
|
135
|
-
let inCodeBlock = false;
|
|
136
|
-
let codeBuffer = '';
|
|
137
136
|
let codeLang = 'bash';
|
|
138
|
-
let activeAgent = '
|
|
139
|
-
let
|
|
137
|
+
let activeAgent = '';
|
|
138
|
+
let technicalBuffer = '';
|
|
139
|
+
let technicalType: 'code' | 'file' | 'patch' | null = null;
|
|
140
140
|
|
|
141
141
|
TUI.drawStatusBar('Swarm is processing...');
|
|
142
142
|
await client.chatStream({
|
|
@@ -148,7 +148,7 @@ ${repoMap}`
|
|
|
148
148
|
if (!hasStarted) {
|
|
149
149
|
spinner.stop();
|
|
150
150
|
hasStarted = true;
|
|
151
|
-
console.log(); //
|
|
151
|
+
console.log(); // Initial spacing
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
buffer += chunk;
|
|
@@ -159,54 +159,83 @@ ${repoMap}`
|
|
|
159
159
|
for (const line of lines) {
|
|
160
160
|
const trimmedLine = line.trim();
|
|
161
161
|
|
|
162
|
-
// 1.
|
|
163
|
-
const
|
|
164
|
-
const
|
|
162
|
+
// 1. Technical Block Detection (Code, File, or Patch)
|
|
163
|
+
const codeBlockMatch = line.match(/```(\w*)/);
|
|
164
|
+
const fileStartMatch = line.match(/<file path="([^"]+)">/);
|
|
165
|
+
const patchStartMatch = line.match(/<<<< SEARCH/);
|
|
165
166
|
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
if (codeBlockMatch || fileStartMatch || patchStartMatch) {
|
|
168
|
+
if (technicalType) {
|
|
169
|
+
// If we hit a new block start while in one, flush it (shouldn't happen but for safety)
|
|
170
|
+
TUI.drawCodeContainer(`Technical Block (${technicalType})`, 'bash', technicalBuffer.trim());
|
|
171
|
+
technicalBuffer = '';
|
|
172
|
+
}
|
|
172
173
|
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
if (codeBlockMatch) {
|
|
175
|
+
technicalType = 'code';
|
|
176
|
+
codeLang = codeBlockMatch[1] || 'bash';
|
|
177
|
+
process.stdout.write(chalk.gray('\n [⚡] Building technical block...\n'));
|
|
178
|
+
} else if (fileStartMatch) {
|
|
179
|
+
technicalType = 'file';
|
|
180
|
+
process.stdout.write(chalk.cyan(`\n [📂] Creating file: ${fileStartMatch[1]}...\n`));
|
|
181
|
+
} else if (patchStartMatch) {
|
|
182
|
+
technicalType = 'patch';
|
|
183
|
+
process.stdout.write(chalk.yellow(`\n [📂] Applying surgical patch...\n`));
|
|
184
|
+
}
|
|
175
185
|
continue;
|
|
176
186
|
}
|
|
177
187
|
|
|
178
|
-
// 2.
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
// 2. Technical Block End Detection
|
|
189
|
+
const fileEndMatch = line.match(/<\/file>/);
|
|
190
|
+
const patchEndMatch = line.match(/>>>> REPLACE/);
|
|
191
|
+
const isCodeEnd = technicalType === 'code' && line.startsWith('```');
|
|
192
|
+
|
|
193
|
+
if (isCodeEnd || fileEndMatch || patchEndMatch) {
|
|
194
|
+
const displayContent = technicalBuffer.trim();
|
|
195
|
+
TUI.drawCodeContainer(
|
|
196
|
+
technicalType === 'file' ? 'New File Content' :
|
|
197
|
+
technicalType === 'patch' ? 'Surgical Patch' : 'Generated Block',
|
|
198
|
+
technicalType === 'code' ? codeLang : 'text',
|
|
199
|
+
displayContent
|
|
200
|
+
);
|
|
201
|
+
technicalBuffer = '';
|
|
202
|
+
technicalType = null;
|
|
203
|
+
process.stdout.write('\n');
|
|
193
204
|
continue;
|
|
194
205
|
}
|
|
195
206
|
|
|
196
207
|
// 3. Content Handling
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
} else
|
|
200
|
-
//
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
if (technicalType) {
|
|
209
|
+
technicalBuffer += line + '\n';
|
|
210
|
+
} else {
|
|
211
|
+
// Agent Detection
|
|
212
|
+
const agentMatch = line.match(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Narayan Dai)\s*\**\]/);
|
|
213
|
+
if (agentMatch) {
|
|
214
|
+
const agentName = agentMatch[1];
|
|
215
|
+
activeAgent = agentName;
|
|
216
|
+
const color = agentName === 'Ajay Vai' ? chalk.magenta :
|
|
217
|
+
agentName === 'Sandip Dai' ? chalk.hex('#FF69B4') :
|
|
218
|
+
agentName === 'Sunil Dai' ? chalk.blue :
|
|
219
|
+
chalk.green;
|
|
220
|
+
|
|
221
|
+
process.stdout.write(`\n${color.bold(`${agentName}:`)} `);
|
|
222
|
+
|
|
223
|
+
// Strip tag from line content
|
|
224
|
+
const content = line.replace(/\[\**\s*(Ajay Vai|Sandip Dai|Sunil Dai|Narayan Dai)\s*\**\]:?\s*/, '').trim();
|
|
225
|
+
if (content) {
|
|
226
|
+
process.stdout.write(chalk.gray(content + ' '));
|
|
227
|
+
}
|
|
228
|
+
} else if (trimmedLine) {
|
|
229
|
+
// Strip common markdown artifacts
|
|
230
|
+
const cleanLine = trimmedLine
|
|
231
|
+
.replace(/\*\*%?\*/g, '')
|
|
232
|
+
.replace(/#{1,6}\s/g, '')
|
|
233
|
+
.replace(/\*\*:\*\*/g, ':')
|
|
234
|
+
.trim();
|
|
235
|
+
|
|
236
|
+
if (cleanLine) {
|
|
237
|
+
process.stdout.write(chalk.gray(cleanLine + ' '));
|
|
238
|
+
}
|
|
210
239
|
}
|
|
211
240
|
}
|
|
212
241
|
}
|
|
@@ -214,13 +243,14 @@ ${repoMap}`
|
|
|
214
243
|
|
|
215
244
|
spinner.stop();
|
|
216
245
|
|
|
217
|
-
// Final
|
|
218
|
-
if (
|
|
219
|
-
TUI.drawCodeContainer('
|
|
246
|
+
// Final technical flush
|
|
247
|
+
if (technicalType && technicalBuffer.trim()) {
|
|
248
|
+
TUI.drawCodeContainer('Final technical content', 'text', technicalBuffer.trim());
|
|
249
|
+
process.stdout.write('\n');
|
|
220
250
|
}
|
|
221
251
|
|
|
222
|
-
//
|
|
223
|
-
console.log(
|
|
252
|
+
// Final newline for streaming output
|
|
253
|
+
console.log();
|
|
224
254
|
|
|
225
255
|
// Add assistant response to history
|
|
226
256
|
messages.push({ role: 'assistant', content: fullResponse });
|
package/src/utils/tui.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import readline from 'readline';
|
|
2
|
+
import * as readline from 'readline';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* TUI Management for MATEX CLI "God-Mode"
|
|
6
|
-
* Handles screen buffers, persistent headers, and real-time status updates.
|
|
7
|
-
*/
|
|
8
4
|
export class TUI {
|
|
9
5
|
private static isInitialized = false;
|
|
10
|
-
private static
|
|
6
|
+
private static lastStatus = '';
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* Initialize the TUI Mode
|
|
@@ -15,13 +11,8 @@ export class TUI {
|
|
|
15
11
|
static init() {
|
|
16
12
|
if (this.isInitialized) return;
|
|
17
13
|
|
|
18
|
-
// Enter alternative screen buffer
|
|
19
|
-
process.stdout.write('\x1b[?1049h');
|
|
20
|
-
|
|
21
14
|
// Hide cursor
|
|
22
15
|
process.stdout.write('\x1b[?25l');
|
|
23
|
-
|
|
24
|
-
this.clear();
|
|
25
16
|
this.isInitialized = true;
|
|
26
17
|
|
|
27
18
|
// Ensure clean exit
|
|
@@ -37,137 +28,110 @@ export class TUI {
|
|
|
37
28
|
|
|
38
29
|
// Show cursor
|
|
39
30
|
process.stdout.write('\x1b[?25h');
|
|
40
|
-
|
|
41
|
-
// Exit alternative screen buffer
|
|
42
|
-
process.stdout.write('\x1b[?1049l');
|
|
43
|
-
|
|
44
31
|
this.isInitialized = false;
|
|
45
|
-
process.exit();
|
|
46
32
|
}
|
|
47
33
|
|
|
48
34
|
/**
|
|
49
|
-
* Clear the
|
|
35
|
+
* Clear the terminal
|
|
50
36
|
*/
|
|
51
37
|
static clear() {
|
|
52
|
-
process.stdout.write('\x1b[2J\x1b[
|
|
53
|
-
this.drawHeader();
|
|
54
|
-
this.drawStatusBar(this.currentStatus, true);
|
|
38
|
+
process.stdout.write('\x1b[2J\x1b[0;0H');
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
/**
|
|
58
|
-
* Draw the
|
|
42
|
+
* Draw a premium status bar at the bottom using Save/Restore cursor
|
|
59
43
|
*/
|
|
60
|
-
static
|
|
44
|
+
static drawStatusBar(message: string, force: boolean = false) {
|
|
45
|
+
if (!this.isInitialized) return;
|
|
46
|
+
if (!force && message === this.lastStatus) return;
|
|
47
|
+
this.lastStatus = message;
|
|
48
|
+
|
|
61
49
|
const width = process.stdout.columns || 80;
|
|
62
|
-
const
|
|
63
|
-
const padding = Math.max(0, Math.floor((width - banner.length) / 2));
|
|
50
|
+
const height = process.stdout.rows || 24;
|
|
64
51
|
|
|
65
|
-
//
|
|
66
|
-
process.stdout.write('\x1b[
|
|
67
|
-
process.stdout
|
|
68
|
-
process.stdout.write(
|
|
52
|
+
// Save cursor (\x1b[s), move to bottom, write, restore cursor (\x1b[u)
|
|
53
|
+
process.stdout.write('\x1b[s');
|
|
54
|
+
readline.cursorTo(process.stdout, 0, height - 1);
|
|
55
|
+
process.stdout.write(
|
|
56
|
+
chalk.bgBlue.white.bold(' 🧠 MATEX ') +
|
|
57
|
+
chalk.bgGray.white(` ${message.padEnd(width - 10)} `)
|
|
58
|
+
);
|
|
59
|
+
process.stdout.write('\x1b[u');
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
/**
|
|
72
|
-
*
|
|
63
|
+
* Draw a box with a title and content
|
|
73
64
|
*/
|
|
74
|
-
|
|
65
|
+
static drawBox(title: string, content: string, color: (s: string) => string = chalk.gray) {
|
|
75
66
|
const width = Math.min(process.stdout.columns || 80, 100);
|
|
67
|
+
const lines = content.split('\n');
|
|
76
68
|
|
|
77
|
-
console.log();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
console.log(chalk.gray('┏' + '━'.repeat(width - 2) + '┓'));
|
|
82
|
-
console.log(chalk.gray('┃ ') + trafficLights + ' ' + color(displayTitle).padEnd(width - 4) + chalk.gray(' ┃'));
|
|
83
|
-
console.log(chalk.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
69
|
+
console.log(color('┏' + '━'.repeat(width - 2) + '┓'));
|
|
70
|
+
console.log(color('┃ ') + chalk.bold(title).padEnd(width - 4) + color(' ┃'));
|
|
71
|
+
console.log(color('┣' + '━'.repeat(width - 2) + '┫'));
|
|
84
72
|
|
|
85
73
|
lines.forEach(line => {
|
|
86
|
-
const
|
|
87
|
-
|
|
74
|
+
const contentWidth = width - 4;
|
|
75
|
+
let remaining = line;
|
|
76
|
+
if (remaining.length === 0) {
|
|
77
|
+
console.log(color('┃ ') + ' '.repeat(contentWidth) + color(' ┃'));
|
|
78
|
+
}
|
|
79
|
+
while (remaining.length > 0) {
|
|
80
|
+
const chunk = remaining.substring(0, contentWidth);
|
|
81
|
+
console.log(color('┃ ') + chalk.white(chunk.padEnd(contentWidth)) + color(' ┃'));
|
|
82
|
+
remaining = remaining.substring(contentWidth);
|
|
83
|
+
}
|
|
88
84
|
});
|
|
89
85
|
|
|
90
|
-
console.log(
|
|
91
|
-
console.log();
|
|
86
|
+
console.log(color('┗' + '━'.repeat(width - 2) + '┛'));
|
|
92
87
|
}
|
|
93
88
|
|
|
94
89
|
/**
|
|
95
|
-
* Draw a
|
|
90
|
+
* Draw a premium code container with traffic lights
|
|
96
91
|
*/
|
|
97
|
-
static
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.currentStatus = status;
|
|
102
|
-
const width = process.stdout.columns || 80;
|
|
103
|
-
const height = process.stdout.rows || 24;
|
|
104
|
-
|
|
105
|
-
// Save cursor position using ANSI
|
|
106
|
-
process.stdout.write('\x1b[s');
|
|
92
|
+
static drawCodeContainer(title: string, lang: string, code: string) {
|
|
93
|
+
const width = Math.min(process.stdout.columns || 80, 100);
|
|
94
|
+
const codeLines = code.split('\n');
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
const trafficLights = chalk.red('●') + ' ' + chalk.yellow('●') + ' ' + chalk.green('●');
|
|
97
|
+
const headerTitle = ` 📄 ${title} (${lang}) `;
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
console.log(chalk.gray('\n┏' + '━'.repeat(width - 2) + '┓'));
|
|
100
|
+
console.log(chalk.gray('┃ ') + trafficLights + ' ' + chalk.cyan.bold(headerTitle).padEnd(width - 10) + chalk.gray(' ┃'));
|
|
101
|
+
console.log(chalk.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
114
102
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
codeLines.forEach(line => {
|
|
104
|
+
const contentWidth = width - 6;
|
|
105
|
+
let remaining = line;
|
|
106
|
+
if (remaining.length === 0) {
|
|
107
|
+
console.log(chalk.gray('┃ ') + ' '.repeat(contentWidth) + chalk.gray(' ┃'));
|
|
108
|
+
}
|
|
109
|
+
while (remaining.length > 0) {
|
|
110
|
+
const chunk = remaining.substring(0, contentWidth);
|
|
111
|
+
console.log(chalk.gray('┃ ') + chalk.hex('#e0e0e0')(chunk.padEnd(contentWidth)) + chalk.gray(' ┃'));
|
|
112
|
+
remaining = remaining.substring(contentWidth);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
* Draw a premium code container
|
|
121
|
-
*/
|
|
122
|
-
static drawCodeContainer(title: string, lang: string, content: string) {
|
|
123
|
-
const lines = content.split('\n').filter(l => l.trim() || l === '');
|
|
124
|
-
this.drawBox(`${title} (${lang})`, chalk.cyan.bold, lines, '📝');
|
|
116
|
+
console.log(chalk.gray('┗' + '━'.repeat(width - 2) + '┛\n'));
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
/**
|
|
128
|
-
* Draw a message
|
|
120
|
+
* Draw a specialized message container for agents
|
|
129
121
|
*/
|
|
130
122
|
static drawMessageContainer(agent: string, message: string) {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
'Sandip Dai': chalk.hex('#FF69B4').bold,
|
|
136
|
-
'Narayan Dai': chalk.green.bold
|
|
137
|
-
};
|
|
138
|
-
const color = colorMap[agent] || chalk.white.bold;
|
|
139
|
-
this.drawBox(agent, color, lines, '🗣️');
|
|
140
|
-
}
|
|
123
|
+
const color = agent.includes('Ajay') ? chalk.magenta :
|
|
124
|
+
agent.includes('Sunil') ? chalk.blue :
|
|
125
|
+
agent.includes('Sandip') ? chalk.hex('#FF69B4') :
|
|
126
|
+
chalk.green;
|
|
141
127
|
|
|
142
|
-
|
|
143
|
-
* Wrap text to a specific width
|
|
144
|
-
*/
|
|
145
|
-
private static wrapText(text: string, width: number): string[] {
|
|
146
|
-
const words = text.split(' ');
|
|
147
|
-
const lines = [];
|
|
148
|
-
let currentLine = '';
|
|
149
|
-
|
|
150
|
-
words.forEach(word => {
|
|
151
|
-
if ((currentLine + word).length < width) {
|
|
152
|
-
currentLine += (currentLine ? ' ' : '') + word;
|
|
153
|
-
} else {
|
|
154
|
-
lines.push(currentLine);
|
|
155
|
-
currentLine = word;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
if (currentLine) lines.push(currentLine);
|
|
159
|
-
return lines;
|
|
128
|
+
this.drawBox(`🤖 ${agent}`, message, color);
|
|
160
129
|
}
|
|
161
130
|
|
|
162
131
|
/**
|
|
163
|
-
*
|
|
132
|
+
* Simple log with a prefix
|
|
164
133
|
*/
|
|
165
|
-
static log(
|
|
166
|
-
|
|
167
|
-
console.log(content);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
// Ensure we don't overwrite the status bar
|
|
171
|
-
console.log(content);
|
|
134
|
+
static log(message: string) {
|
|
135
|
+
console.log(chalk.gray(` [⚡] ${message}`));
|
|
172
136
|
}
|
|
173
137
|
}
|