matex-cli 1.2.16 → 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 +98 -76
- package/dist/commands/dev.js.map +1 -1
- package/dist/utils/patcher.js +1 -1
- package/dist/utils/patcher.js.map +1 -1
- package/dist/utils/tui.d.ts +13 -13
- package/dist/utils/tui.d.ts.map +1 -1
- package/dist/utils/tui.js +99 -60
- package/dist/utils/tui.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/dev.ts +113 -81
- package/src/utils/patcher.ts +1 -1
- package/src/utils/tui.ts +71 -67
|
@@ -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,36 +80,38 @@ 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
|
|
91
|
-
5. **[Ajay Vai] (🏆)**: The Conclusion. Role: Final hand-off and success celebration.
|
|
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.
|
|
92
91
|
|
|
93
|
-
### 💬
|
|
94
|
-
- **CHAT
|
|
95
|
-
- **
|
|
96
|
-
- **NEPALI FLAVOR:** Use terms like "Vai," "Dai," "Oii brother," "Tapai," "Ekdam ramro" naturally.
|
|
92
|
+
### 💬 BRO-VIBE PROTOCOL:
|
|
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.
|
|
97
97
|
|
|
98
|
-
###
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
### 🛠️ FILE GENERATION & EDIT PROTOCOLS (CRITICAL):
|
|
99
|
+
1. **NEW FILES:** Use the following tag for ALL new files:
|
|
100
|
+
<file path="path/to/filename.ext">
|
|
101
|
+
content here
|
|
102
|
+
</file>
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
- **USE SEARCH/REPLACE BLOCKS** for all file modifications. This is faster and safer than full rewrites.
|
|
105
|
-
- **FORMAT:**
|
|
104
|
+
2. **SURGICAL EDITS (for existing files):**
|
|
106
105
|
**path/to/file.ext**
|
|
107
106
|
<<<< SEARCH
|
|
108
107
|
exact lines to find
|
|
109
108
|
====
|
|
110
109
|
new lines to replace with
|
|
111
110
|
>>>> REPLACE
|
|
112
|
-
|
|
111
|
+
|
|
112
|
+
### ✂️ BREVITY AS POWER:
|
|
113
|
+
- **NO FULL FILE DUMPS** unless specifically asked.
|
|
114
|
+
- **NO CHAT REPETITION** of code. Just summary of actions.
|
|
113
115
|
|
|
114
116
|
### 🛠️ ENVIRONMENT CONTEXT:
|
|
115
117
|
${repoMap}`
|
|
@@ -155,10 +157,10 @@ ${repoMap}`
|
|
|
155
157
|
let fullResponse = '';
|
|
156
158
|
let buffer = '';
|
|
157
159
|
let hasStarted = false;
|
|
158
|
-
let inCodeBlock = false;
|
|
159
|
-
let codeBuffer = '';
|
|
160
160
|
let codeLang = 'bash';
|
|
161
|
-
let
|
|
161
|
+
let activeAgent = '';
|
|
162
|
+
let technicalBuffer = '';
|
|
163
|
+
let technicalType = null;
|
|
162
164
|
tui_1.TUI.drawStatusBar('Swarm is processing...');
|
|
163
165
|
await client.chatStream({
|
|
164
166
|
messages,
|
|
@@ -169,75 +171,95 @@ ${repoMap}`
|
|
|
169
171
|
if (!hasStarted) {
|
|
170
172
|
spinner_1.spinner.stop();
|
|
171
173
|
hasStarted = true;
|
|
174
|
+
console.log(); // Initial spacing
|
|
172
175
|
}
|
|
173
176
|
buffer += chunk;
|
|
174
177
|
fullResponse += chunk;
|
|
175
178
|
const lines = buffer.split('\n');
|
|
176
179
|
buffer = lines.pop() || '';
|
|
177
180
|
for (const line of lines) {
|
|
178
|
-
|
|
179
|
-
// 1.
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
tag === 'Sandip Dai' ? chalk_1.default.hex('#FF69B4') :
|
|
189
|
-
chalk_1.default.green;
|
|
190
|
-
if (tag !== lastRole) {
|
|
191
|
-
tui_1.TUI.log(`\n${color.bold(`[${tag}]`)}`);
|
|
192
|
-
lastRole = tag;
|
|
181
|
+
const trimmedLine = line.trim();
|
|
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 = '';
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// 2. Code Block Handling
|
|
199
|
-
if (content.startsWith('```')) {
|
|
200
|
-
if (inCodeBlock) {
|
|
201
|
-
// Closing block - Draw it!
|
|
202
|
-
tui_1.TUI.drawCodeContainer('Generated Block', codeLang, codeBuffer);
|
|
203
|
-
codeBuffer = '';
|
|
204
|
-
inCodeBlock = false;
|
|
192
|
+
if (codeBlockMatch) {
|
|
193
|
+
technicalType = 'code';
|
|
194
|
+
codeLang = codeBlockMatch[1] || 'bash';
|
|
195
|
+
process.stdout.write(chalk_1.default.gray('\n [⚡] Building technical block...\n'));
|
|
205
196
|
}
|
|
206
|
-
else {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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`));
|
|
213
204
|
}
|
|
214
205
|
continue;
|
|
215
206
|
}
|
|
216
|
-
|
|
217
|
-
|
|
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;
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
// 3. Content Handling
|
|
221
|
+
if (technicalType) {
|
|
222
|
+
technicalBuffer += line + '\n';
|
|
223
|
+
}
|
|
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
|
+
}
|
|
251
|
+
}
|
|
227
252
|
}
|
|
228
253
|
}
|
|
229
254
|
});
|
|
230
255
|
spinner_1.spinner.stop();
|
|
231
|
-
// Final flush
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
tui_1.TUI.drawCodeContainer('Generated Block', codeLang, codeBuffer);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
tui_1.TUI.log(chalk_1.default.gray(buffer.trim()));
|
|
239
|
-
}
|
|
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');
|
|
240
260
|
}
|
|
261
|
+
// Final newline for streaming output
|
|
262
|
+
console.log();
|
|
241
263
|
// Add assistant response to history
|
|
242
264
|
messages.push({ role: 'assistant', content: fullResponse });
|
|
243
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":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,oEAAgE;AAChE,sDAAkD;AAClD,sCAAmC;AAEtB,QAAA,UAAU,GAAG,IAAI,mBAAO,CAAC,KAAK,CAAC;KACvC,WAAW,CAAC,uDAAuD,CAAC;KACpE,MAAM,CAAC,qBAAqB,EAAE,sEAAsE,EAAE,sBAAa,CAAC,eAAe,EAAE,CAAC;KACtI,MAAM,CAAC,cAAc,EAAE,2CAA2C,CAAC;KACnE,MAAM,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;IAC3B,IAAI,CAAC;QACD,oBAAoB;QACpB,MAAM,MAAM,GA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;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/patcher.js
CHANGED
|
@@ -41,7 +41,7 @@ class Patcher {
|
|
|
41
41
|
*/
|
|
42
42
|
static parseFileBlocks(response) {
|
|
43
43
|
const blocks = [];
|
|
44
|
-
const fileRegex = /<file path="([^"]+)"
|
|
44
|
+
const fileRegex = /<file path="([^"]+)">([\s\S]*?)<\/file>/g;
|
|
45
45
|
let match;
|
|
46
46
|
while ((match = fileRegex.exec(response)) !== null) {
|
|
47
47
|
blocks.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patcher.js","sourceRoot":"","sources":["../../src/utils/patcher.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,+BAA4B;AAQ5B,MAAa,OAAO;IAChB;;;;;;;;;OASG;IACH,MAAM,CAAC,eAAe,CAAC,QAAgB;QACnC,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,4EAA4E,CAAC;QAEhG,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAClD,MAAM,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACzB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;gBA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eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3D,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QAEH,IAAI,cAAc,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,YAAY,YAAY,CAAC,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/I,CAAC;QAED,YAAY;QACZ,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAE3D,IAAI,cAAc,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,8DAA8D,CAAC,CAAC,CAAC;QAC9F,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE3B,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AAtLD,0BAsLC"}
|
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,24 +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
|
-
* Draw a
|
|
21
|
+
* Draw a box with a title and content
|
|
26
22
|
*/
|
|
27
|
-
static
|
|
23
|
+
static drawBox(title: string, content: string, color?: (s: string) => string): void;
|
|
28
24
|
/**
|
|
29
25
|
* Draw a premium code container with traffic lights
|
|
30
26
|
*/
|
|
31
|
-
static drawCodeContainer(title: string, lang: string,
|
|
27
|
+
static drawCodeContainer(title: string, lang: string, code: string): void;
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
29
|
+
* Draw a specialized message container for agents
|
|
34
30
|
*/
|
|
35
|
-
static
|
|
31
|
+
static drawMessageContainer(agent: string, message: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Simple log with a prefix
|
|
34
|
+
*/
|
|
35
|
+
static log(message: string): void;
|
|
36
36
|
}
|
|
37
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,14 +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
|
-
|
|
9
|
-
* TUI Management for MATEX CLI "God-Mode"
|
|
10
|
-
* Handles screen buffers, persistent headers, and real-time status updates.
|
|
11
|
-
*/
|
|
41
|
+
const readline = __importStar(require("readline"));
|
|
12
42
|
class TUI {
|
|
13
43
|
/**
|
|
14
44
|
* Initialize the TUI Mode
|
|
@@ -16,11 +46,8 @@ class TUI {
|
|
|
16
46
|
static init() {
|
|
17
47
|
if (this.isInitialized)
|
|
18
48
|
return;
|
|
19
|
-
// Enter alternative screen buffer
|
|
20
|
-
process.stdout.write('\x1b[?1049h');
|
|
21
49
|
// Hide cursor
|
|
22
50
|
process.stdout.write('\x1b[?25l');
|
|
23
|
-
this.clear();
|
|
24
51
|
this.isInitialized = true;
|
|
25
52
|
// Ensure clean exit
|
|
26
53
|
process.on('SIGINT', () => this.exit());
|
|
@@ -34,86 +61,98 @@ class TUI {
|
|
|
34
61
|
return;
|
|
35
62
|
// Show cursor
|
|
36
63
|
process.stdout.write('\x1b[?25h');
|
|
37
|
-
// Exit alternative screen buffer
|
|
38
|
-
process.stdout.write('\x1b[?1049l');
|
|
39
64
|
this.isInitialized = false;
|
|
40
|
-
process.exit();
|
|
41
65
|
}
|
|
42
66
|
/**
|
|
43
|
-
* Clear the
|
|
67
|
+
* Clear the terminal
|
|
44
68
|
*/
|
|
45
69
|
static clear() {
|
|
46
|
-
process.stdout.write('\x1b[2J\x1b[
|
|
47
|
-
this.drawHeader();
|
|
48
|
-
this.drawStatusBar(this.currentStatus, true);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Draw the persistent top header
|
|
52
|
-
*/
|
|
53
|
-
static drawHeader() {
|
|
54
|
-
const width = process.stdout.columns || 80;
|
|
55
|
-
const banner = ` MATEX AI :: GOD-MODE DASHBOARD `;
|
|
56
|
-
const padding = Math.max(0, Math.floor((width - banner.length) / 2));
|
|
57
|
-
// Move to top
|
|
58
|
-
process.stdout.write('\x1b[H');
|
|
59
|
-
process.stdout.write(chalk_1.default.bgCyan.black(' '.repeat(padding) + banner + ' '.repeat(width - banner.length - padding)) + '\n');
|
|
60
|
-
process.stdout.write(chalk_1.default.gray('─'.repeat(width)) + '\n');
|
|
70
|
+
process.stdout.write('\x1b[2J\x1b[0;0H');
|
|
61
71
|
}
|
|
62
72
|
/**
|
|
63
|
-
* Draw a
|
|
73
|
+
* Draw a premium status bar at the bottom using Save/Restore cursor
|
|
64
74
|
*/
|
|
65
|
-
static drawStatusBar(
|
|
75
|
+
static drawStatusBar(message, force = false) {
|
|
66
76
|
if (!this.isInitialized)
|
|
67
77
|
return;
|
|
68
|
-
if (
|
|
69
|
-
return;
|
|
70
|
-
this.
|
|
78
|
+
if (!force && message === this.lastStatus)
|
|
79
|
+
return;
|
|
80
|
+
this.lastStatus = message;
|
|
71
81
|
const width = process.stdout.columns || 80;
|
|
72
82
|
const height = process.stdout.rows || 24;
|
|
73
|
-
// Save cursor
|
|
83
|
+
// Save cursor (\x1b[s), move to bottom, write, restore cursor (\x1b[u)
|
|
74
84
|
process.stdout.write('\x1b[s');
|
|
75
|
-
|
|
76
|
-
process.stdout.write(
|
|
77
|
-
|
|
78
|
-
const bar = ` [⚡] ${cleanStatus} `.padEnd(width);
|
|
79
|
-
process.stdout.write(chalk_1.default.bgWhite.black(bar));
|
|
80
|
-
// 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)} `));
|
|
81
88
|
process.stdout.write('\x1b[u');
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
* Draw a
|
|
91
|
+
* Draw a box with a title and content
|
|
85
92
|
*/
|
|
86
|
-
static
|
|
93
|
+
static drawBox(title, content, color = chalk_1.default.gray) {
|
|
87
94
|
const width = Math.min(process.stdout.columns || 80, 100);
|
|
88
95
|
const lines = content.split('\n');
|
|
89
|
-
console.log();
|
|
90
|
-
|
|
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) + '┛'));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Draw a premium code container with traffic lights
|
|
115
|
+
*/
|
|
116
|
+
static drawCodeContainer(title, lang, code) {
|
|
117
|
+
const width = Math.min(process.stdout.columns || 80, 100);
|
|
118
|
+
const codeLines = code.split('\n');
|
|
91
119
|
const trafficLights = chalk_1.default.red('●') + ' ' + chalk_1.default.yellow('●') + ' ' + chalk_1.default.green('●');
|
|
92
|
-
const
|
|
93
|
-
console.log(chalk_1.default.gray('┏' + '━'.repeat(width - 2) + '┓'));
|
|
94
|
-
console.log(chalk_1.default.gray('┃ ') + trafficLights + ' ' + chalk_1.default.cyan.bold(
|
|
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(' ┃'));
|
|
95
123
|
console.log(chalk_1.default.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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(' ┃'));
|
|
129
|
+
}
|
|
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);
|
|
134
|
+
}
|
|
100
135
|
});
|
|
101
|
-
|
|
102
|
-
console.log(chalk_1.default.gray('┗' + '━'.repeat(width - 2) + '┛'));
|
|
103
|
-
console.log();
|
|
136
|
+
console.log(chalk_1.default.gray('┗' + '━'.repeat(width - 2) + '┛\n'));
|
|
104
137
|
}
|
|
105
138
|
/**
|
|
106
|
-
*
|
|
139
|
+
* Draw a specialized message container for agents
|
|
107
140
|
*/
|
|
108
|
-
static
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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}`));
|
|
114
153
|
}
|
|
115
154
|
}
|
|
116
155
|
exports.TUI = TUI;
|
|
117
156
|
TUI.isInitialized = false;
|
|
118
|
-
TUI.
|
|
157
|
+
TUI.lastStatus = '';
|
|
119
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;YAA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AAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,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,36 +48,38 @@ 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
|
-
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- **
|
|
63
|
-
- **
|
|
64
|
-
- **
|
|
65
|
-
|
|
66
|
-
###
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- **FORMAT:**
|
|
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):
|
|
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
|
+
|
|
60
|
+
### 💬 BRO-VIBE PROTOCOL:
|
|
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.
|
|
65
|
+
|
|
66
|
+
### 🛠️ FILE GENERATION & EDIT PROTOCOLS (CRITICAL):
|
|
67
|
+
1. **NEW FILES:** Use the following tag for ALL new files:
|
|
68
|
+
<file path="path/to/filename.ext">
|
|
69
|
+
content here
|
|
70
|
+
</file>
|
|
71
|
+
|
|
72
|
+
2. **SURGICAL EDITS (for existing files):**
|
|
74
73
|
**path/to/file.ext**
|
|
75
74
|
<<<< SEARCH
|
|
76
75
|
exact lines to find
|
|
77
76
|
====
|
|
78
77
|
new lines to replace with
|
|
79
78
|
>>>> REPLACE
|
|
80
|
-
|
|
79
|
+
|
|
80
|
+
### ✂️ BREVITY AS POWER:
|
|
81
|
+
- **NO FULL FILE DUMPS** unless specifically asked.
|
|
82
|
+
- **NO CHAT REPETITION** of code. Just summary of actions.
|
|
81
83
|
|
|
82
84
|
### 🛠️ ENVIRONMENT CONTEXT:
|
|
83
85
|
${repoMap}`
|
|
@@ -131,10 +133,10 @@ ${repoMap}`
|
|
|
131
133
|
let fullResponse = '';
|
|
132
134
|
let buffer = '';
|
|
133
135
|
let hasStarted = false;
|
|
134
|
-
let inCodeBlock = false;
|
|
135
|
-
let codeBuffer = '';
|
|
136
136
|
let codeLang = 'bash';
|
|
137
|
-
let
|
|
137
|
+
let activeAgent = '';
|
|
138
|
+
let technicalBuffer = '';
|
|
139
|
+
let technicalType: 'code' | 'file' | 'patch' | null = null;
|
|
138
140
|
|
|
139
141
|
TUI.drawStatusBar('Swarm is processing...');
|
|
140
142
|
await client.chatStream({
|
|
@@ -146,6 +148,7 @@ ${repoMap}`
|
|
|
146
148
|
if (!hasStarted) {
|
|
147
149
|
spinner.stop();
|
|
148
150
|
hasStarted = true;
|
|
151
|
+
console.log(); // Initial spacing
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
buffer += chunk;
|
|
@@ -154,72 +157,101 @@ ${repoMap}`
|
|
|
154
157
|
buffer = lines.pop() || '';
|
|
155
158
|
|
|
156
159
|
for (const line of lines) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// 1.
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
tag === 'Sandip Dai' ? chalk.hex('#FF69B4') :
|
|
170
|
-
chalk.green;
|
|
171
|
-
|
|
172
|
-
if (tag !== lastRole) {
|
|
173
|
-
TUI.log(`\n${color.bold(`[${tag}]`)}`);
|
|
174
|
-
lastRole = tag as AgentRole;
|
|
160
|
+
const trimmedLine = line.trim();
|
|
161
|
+
|
|
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/);
|
|
166
|
+
|
|
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 = '';
|
|
175
172
|
}
|
|
176
|
-
content = line.replace(`[${tag}]`, '').trim();
|
|
177
|
-
if (!content && !inCodeBlock) continue;
|
|
178
|
-
}
|
|
179
173
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
} else {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
codeLang = content.replace('```', '').trim() || 'bash';
|
|
191
|
-
if (options.execute) {
|
|
192
|
-
TUI.log(chalk.gray(' ⚡ Building technical block...'));
|
|
193
|
-
}
|
|
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`));
|
|
194
184
|
}
|
|
195
185
|
continue;
|
|
196
186
|
}
|
|
197
187
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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');
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 3. Content Handling
|
|
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
|
+
}
|
|
239
|
+
}
|
|
207
240
|
}
|
|
208
241
|
}
|
|
209
242
|
});
|
|
210
243
|
|
|
211
244
|
spinner.stop();
|
|
212
245
|
|
|
213
|
-
// Final flush
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
TUI.drawCodeContainer('Generated Block', codeLang, codeBuffer);
|
|
218
|
-
} else {
|
|
219
|
-
TUI.log(chalk.gray(buffer.trim()));
|
|
220
|
-
}
|
|
246
|
+
// Final technical flush
|
|
247
|
+
if (technicalType && technicalBuffer.trim()) {
|
|
248
|
+
TUI.drawCodeContainer('Final technical content', 'text', technicalBuffer.trim());
|
|
249
|
+
process.stdout.write('\n');
|
|
221
250
|
}
|
|
222
251
|
|
|
252
|
+
// Final newline for streaming output
|
|
253
|
+
console.log();
|
|
254
|
+
|
|
223
255
|
// Add assistant response to history
|
|
224
256
|
messages.push({ role: 'assistant', content: fullResponse });
|
|
225
257
|
const response = fullResponse;
|
package/src/utils/patcher.ts
CHANGED
|
@@ -45,7 +45,7 @@ export class Patcher {
|
|
|
45
45
|
*/
|
|
46
46
|
static parseFileBlocks(response: string): EditBlock[] {
|
|
47
47
|
const blocks: EditBlock[] = [];
|
|
48
|
-
const fileRegex = /<file path="([^"]+)"
|
|
48
|
+
const fileRegex = /<file path="([^"]+)">([\s\S]*?)<\/file>/g;
|
|
49
49
|
|
|
50
50
|
let match;
|
|
51
51
|
while ((match = fileRegex.exec(response)) !== null) {
|
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,97 +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);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Draw the persistent top header
|
|
59
|
-
*/
|
|
60
|
-
static drawHeader() {
|
|
61
|
-
const width = process.stdout.columns || 80;
|
|
62
|
-
const banner = ` MATEX AI :: GOD-MODE DASHBOARD `;
|
|
63
|
-
const padding = Math.max(0, Math.floor((width - banner.length) / 2));
|
|
64
|
-
|
|
65
|
-
// Move to top
|
|
66
|
-
process.stdout.write('\x1b[H');
|
|
67
|
-
process.stdout.write(chalk.bgCyan.black(' '.repeat(padding) + banner + ' '.repeat(width - banner.length - padding)) + '\n');
|
|
68
|
-
process.stdout.write(chalk.gray('─'.repeat(width)) + '\n');
|
|
38
|
+
process.stdout.write('\x1b[2J\x1b[0;0H');
|
|
69
39
|
}
|
|
70
40
|
|
|
71
41
|
/**
|
|
72
|
-
* Draw a
|
|
42
|
+
* Draw a premium status bar at the bottom using Save/Restore cursor
|
|
73
43
|
*/
|
|
74
|
-
static drawStatusBar(
|
|
44
|
+
static drawStatusBar(message: string, force: boolean = false) {
|
|
75
45
|
if (!this.isInitialized) return;
|
|
76
|
-
if (
|
|
46
|
+
if (!force && message === this.lastStatus) return;
|
|
47
|
+
this.lastStatus = message;
|
|
77
48
|
|
|
78
|
-
this.currentStatus = status;
|
|
79
49
|
const width = process.stdout.columns || 80;
|
|
80
50
|
const height = process.stdout.rows || 24;
|
|
81
51
|
|
|
82
|
-
// Save cursor
|
|
52
|
+
// Save cursor (\x1b[s), move to bottom, write, restore cursor (\x1b[u)
|
|
83
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');
|
|
60
|
+
}
|
|
84
61
|
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Draw a box with a title and content
|
|
64
|
+
*/
|
|
65
|
+
static drawBox(title: string, content: string, color: (s: string) => string = chalk.gray) {
|
|
66
|
+
const width = Math.min(process.stdout.columns || 80, 100);
|
|
67
|
+
const lines = content.split('\n');
|
|
87
68
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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) + '┫'));
|
|
91
72
|
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
lines.forEach(line => {
|
|
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
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log(color('┗' + '━'.repeat(width - 2) + '┛'));
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
/**
|
|
97
90
|
* Draw a premium code container with traffic lights
|
|
98
91
|
*/
|
|
99
|
-
static drawCodeContainer(title: string, lang: string,
|
|
92
|
+
static drawCodeContainer(title: string, lang: string, code: string) {
|
|
100
93
|
const width = Math.min(process.stdout.columns || 80, 100);
|
|
101
|
-
const
|
|
94
|
+
const codeLines = code.split('\n');
|
|
102
95
|
|
|
103
|
-
console.log();
|
|
104
|
-
// 1. Title Bar
|
|
105
96
|
const trafficLights = chalk.red('●') + ' ' + chalk.yellow('●') + ' ' + chalk.green('●');
|
|
106
|
-
const
|
|
97
|
+
const headerTitle = ` 📄 ${title} (${lang}) `;
|
|
107
98
|
|
|
108
|
-
console.log(chalk.gray('┏' + '━'.repeat(width - 2) + '┓'));
|
|
109
|
-
console.log(chalk.gray('┃ ') + trafficLights + ' ' + chalk.cyan.bold(
|
|
99
|
+
console.log(chalk.gray('\n┏' + '━'.repeat(width - 2) + '┓'));
|
|
100
|
+
console.log(chalk.gray('┃ ') + trafficLights + ' ' + chalk.cyan.bold(headerTitle).padEnd(width - 10) + chalk.gray(' ┃'));
|
|
110
101
|
console.log(chalk.gray('┣' + '━'.repeat(width - 2) + '┫'));
|
|
111
102
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
}
|
|
116
114
|
});
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
console.log(chalk.gray('┗' + '━'.repeat(width - 2) + '┛\n'));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Draw a specialized message container for agents
|
|
121
|
+
*/
|
|
122
|
+
static drawMessageContainer(agent: string, message: string) {
|
|
123
|
+
const color = agent.includes('Ajay') ? chalk.magenta :
|
|
124
|
+
agent.includes('Sunil') ? chalk.blue :
|
|
125
|
+
agent.includes('Sandip') ? chalk.hex('#FF69B4') :
|
|
126
|
+
chalk.green;
|
|
127
|
+
|
|
128
|
+
this.drawBox(`🤖 ${agent}`, message, color);
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
/**
|
|
124
|
-
*
|
|
132
|
+
* Simple log with a prefix
|
|
125
133
|
*/
|
|
126
|
-
static log(
|
|
127
|
-
|
|
128
|
-
console.log(content);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
console.log(content);
|
|
134
|
+
static log(message: string) {
|
|
135
|
+
console.log(chalk.gray(` [⚡] ${message}`));
|
|
132
136
|
}
|
|
133
137
|
}
|