matex-cli 1.2.9 → 1.2.11

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.
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Patcher = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const tui_1 = require("./tui");
11
+ class Patcher {
12
+ /**
13
+ * Parse surgical edit blocks from AI response
14
+ * Format:
15
+ * **filename**
16
+ * <<<< SEARCH
17
+ * content
18
+ * ====
19
+ * replacement
20
+ * >>>> REPLACE
21
+ */
22
+ static parseEditBlocks(response) {
23
+ const blocks = [];
24
+ // Match filename followed by search/replace block
25
+ const blockRegex = /\*\*([^*]+)\*\*\s*<<<< SEARCH\n([\s\S]*?)\n====\n([\s\S]*?)\n>>>> REPLACE/g;
26
+ let match;
27
+ while ((match = blockRegex.exec(response)) !== null) {
28
+ blocks.push({
29
+ filePath: match[1].trim(),
30
+ search: match[2],
31
+ replace: match[3]
32
+ });
33
+ }
34
+ return blocks;
35
+ }
36
+ /**
37
+ * Apply a surgical patch to a file
38
+ */
39
+ static applyPatch(block) {
40
+ tui_1.TUI.drawStatusBar(`Applying Patch: ${block.filePath}...`);
41
+ try {
42
+ const fullPath = path_1.default.resolve(process.cwd(), block.filePath);
43
+ if (!fs_1.default.existsSync(fullPath)) {
44
+ tui_1.TUI.drawStatusBar(`Error: File not found: ${block.filePath}`);
45
+ return { success: false, error: `File not found: ${block.filePath}` };
46
+ }
47
+ const content = fs_1.default.readFileSync(fullPath, 'utf8');
48
+ // Normalize line endings for comparison
49
+ const normalizedContent = content.replace(/\r\n/g, '\n');
50
+ const normalizedSearch = block.search.replace(/\r\n/g, '\n');
51
+ if (!normalizedContent.includes(normalizedSearch)) {
52
+ tui_1.TUI.drawStatusBar(`Error: Search block not found in ${block.filePath}.`);
53
+ return {
54
+ success: false,
55
+ error: `Search block not found in ${block.filePath}.`
56
+ };
57
+ }
58
+ const updatedContent = normalizedContent.replace(normalizedSearch, block.replace.replace(/\r\n/g, '\n'));
59
+ fs_1.default.writeFileSync(fullPath, updatedContent, 'utf8');
60
+ tui_1.TUI.drawStatusBar(`Success: ${block.filePath} patched.`);
61
+ return { success: true };
62
+ }
63
+ catch (err) {
64
+ tui_1.TUI.drawStatusBar(`Error applying patch to ${block.filePath}: ${err.message}`);
65
+ return { success: false, error: err.message };
66
+ }
67
+ }
68
+ /**
69
+ * Visualize the diff in a premium "Bro" style
70
+ */
71
+ static showDiff(block) {
72
+ process.stdout.write('\n');
73
+ console.log(chalk_1.default.bgCyan.black(` 💎 PROPOSED SURGICAL EDIT: ${block.filePath} `));
74
+ console.log(chalk_1.default.cyan('╒' + '═'.repeat(70) + '╕'));
75
+ const searchLines = block.search.split('\n');
76
+ const replaceLines = block.replace.split('\n');
77
+ searchLines.forEach(line => {
78
+ console.log(chalk_1.default.red('│ - ') + chalk_1.default.red(line));
79
+ });
80
+ console.log(chalk_1.default.gray('╞' + '┄'.repeat(70) + '╡'));
81
+ replaceLines.forEach(line => {
82
+ console.log(chalk_1.default.green('│ + ') + chalk_1.default.green(line));
83
+ });
84
+ console.log(chalk_1.default.cyan('╘' + '═'.repeat(70) + '╛'));
85
+ console.log();
86
+ }
87
+ }
88
+ exports.Patcher = Patcher;
89
+ //# sourceMappingURL=patcher.js.map
@@ -0,0 +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,GAA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AAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE/C,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACpD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,EAAE,CAAC;IAClB,CAAC;CACJ;AAvFD,0BAuFC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * TUI Management for MATEX CLI "God-Mode"
3
+ * Handles screen buffers, persistent headers, and real-time status updates.
4
+ */
5
+ export declare class TUI {
6
+ private static isInitialized;
7
+ private static currentStatus;
8
+ /**
9
+ * Initialize the TUI Mode
10
+ */
11
+ static init(): void;
12
+ /**
13
+ * Restore Terminal to normal state
14
+ */
15
+ static exit(): void;
16
+ /**
17
+ * Clear the main viewport
18
+ */
19
+ static clear(): void;
20
+ /**
21
+ * Draw the persistent top header
22
+ */
23
+ static drawHeader(): void;
24
+ /**
25
+ * Draw a real-time status bar at the bottom
26
+ */
27
+ static drawStatusBar(status: string): void;
28
+ /**
29
+ * Log content into the scrollable area
30
+ */
31
+ static log(content: string): void;
32
+ }
33
+ //# sourceMappingURL=tui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/utils/tui.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,GAAG;IACZ,OAAO,CAAC,MAAM,CAAC,aAAa,CAAS;IACrC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAM;IAElC;;OAEG;IACH,MAAM,CAAC,IAAI;IAiBX;;OAEG;IACH,MAAM,CAAC,IAAI;IAaX;;OAEG;IACH,MAAM,CAAC,KAAK;IAMZ;;OAEG;IACH,MAAM,CAAC,UAAU;IAWjB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM;IAqBnC;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;CAU7B"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TUI = void 0;
7
+ 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
+ */
12
+ class TUI {
13
+ /**
14
+ * Initialize the TUI Mode
15
+ */
16
+ static init() {
17
+ if (this.isInitialized)
18
+ return;
19
+ // Enter alternative screen buffer
20
+ process.stdout.write('\x1b[?1049h');
21
+ // Hide cursor
22
+ process.stdout.write('\x1b[?25l');
23
+ this.clear();
24
+ this.isInitialized = true;
25
+ // Ensure clean exit
26
+ process.on('SIGINT', () => this.exit());
27
+ process.on('exit', () => this.exit());
28
+ }
29
+ /**
30
+ * Restore Terminal to normal state
31
+ */
32
+ static exit() {
33
+ if (!this.isInitialized)
34
+ return;
35
+ // Show cursor
36
+ process.stdout.write('\x1b[?25h');
37
+ // Exit alternative screen buffer
38
+ process.stdout.write('\x1b[?1049l');
39
+ this.isInitialized = false;
40
+ process.exit();
41
+ }
42
+ /**
43
+ * Clear the main viewport
44
+ */
45
+ static clear() {
46
+ process.stdout.write('\x1b[2J\x1b[H');
47
+ this.drawHeader();
48
+ this.drawStatusBar(this.currentStatus);
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
+ console.log(chalk_1.default.bgCyan.black(' '.repeat(padding) + banner + ' '.repeat(width - banner.length - padding)));
60
+ console.log(chalk_1.default.gray('─'.repeat(width)));
61
+ }
62
+ /**
63
+ * Draw a real-time status bar at the bottom
64
+ */
65
+ static drawStatusBar(status) {
66
+ this.currentStatus = status;
67
+ if (!this.isInitialized)
68
+ return;
69
+ const width = process.stdout.columns || 80;
70
+ const height = process.stdout.rows || 24;
71
+ // Save cursor position
72
+ process.stdout.write('\x1b[s');
73
+ // Move to bottom line
74
+ process.stdout.write(`\x1b[${height};1H`);
75
+ const cleanStatus = status.substring(0, width - 10);
76
+ const bar = ` [⚡] ${cleanStatus} `.padEnd(width);
77
+ process.stdout.write(chalk_1.default.bgWhite.black(bar));
78
+ // Restore cursor position
79
+ process.stdout.write('\x1b[u');
80
+ }
81
+ /**
82
+ * Log content into the scrollable area
83
+ */
84
+ static log(content) {
85
+ if (!this.isInitialized) {
86
+ console.log(content);
87
+ return;
88
+ }
89
+ // Since we are in an alternative buffer, standard console.log works
90
+ // within the viewport between header and footer.
91
+ console.log(content);
92
+ }
93
+ }
94
+ exports.TUI = TUI;
95
+ TUI.isInitialized = false;
96
+ TUI.currentStatus = '';
97
+ //# sourceMappingURL=tui.js.map
@@ -0,0 +1 @@
1
+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CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAE/C,0BAA0B;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,OAAe;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,qEAAqE;QACrE,iDAAiD;QACjD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;;AAnGL,kBAoGC;AAnGkB,iBAAa,GAAG,KAAK,CAAC;AACtB,iBAAa,GAAG,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matex-cli",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Official CLI tool for MATEX AI - Access powerful AI models from your terminal",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -6,6 +6,7 @@ import { MatexAPIClient, ChatMessage } from '../api/client';
6
6
  import { spinner } from '../utils/spinner';
7
7
  import { AgentOrchestrator, AgentRole } from '../utils/agent-orchestrator';
8
8
  import { RepoMapper } from '../utils/repo-mapper';
9
+ import { TUI } from '../utils/tui';
9
10
 
10
11
  export const devCommand = new Command('dev')
11
12
  .description('Start interactive development session with MATEXCodex')
@@ -24,53 +25,68 @@ export const devCommand = new Command('dev')
24
25
  // Create API client
25
26
  const client = new MatexAPIClient(apiKey, configManager.getBaseURL());
26
27
 
27
- // Welcome message
28
- AgentOrchestrator.announce('MATEX Multi-Agent Dev Session');
29
- console.log(chalk.gray('━'.repeat(50)));
30
- console.log(chalk.white(`Model: ${chalk.cyan(options.model)}`));
31
- console.log(chalk.gray('Type your requests, or "exit" to quit\n'));
28
+ // 0. Initialize God-Mode TUI Dashboard
29
+ TUI.init();
30
+
31
+ console.log(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
32
+ console.log(chalk.bold.white(' 🚀 MATEX :: THE BRO-SWARM IS ONLINE '));
33
+ console.log(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
34
+ console.log(chalk.gray(' Status: Monitoring Workspace...'));
35
+ console.log(chalk.gray(' Type your request brother, or "exit" to quit\n'));
32
36
 
33
37
  // 1. Observation Phase: Generate Repo Map
34
- AgentOrchestrator.announce('Initializing Codex Core Engine...');
38
+ TUI.drawStatusBar('Initializing MATEX "Bro-Swarm"...');
39
+ AgentOrchestrator.announce('Analyzing Repository Structure...');
35
40
  const repoMapper = new RepoMapper(process.cwd());
36
41
  const repoMap = await repoMapper.generateMap();
37
42
 
38
- AgentOrchestrator.speak('System', 'Repository Map Generated.');
43
+ TUI.drawStatusBar('Brothers are ready to build.');
44
+ AgentOrchestrator.speak('System', 'Awaiting your command, brother.');
39
45
 
40
- // Conversation history with Codex Architecture
46
+ // Conversation history with "Bro-Swarm" Architecture
41
47
  const messages: ChatMessage[] = [
42
48
  {
43
49
  role: 'system',
44
- content: `## 🧬 SYSTEM IDENTITY: MATEX CODEX DEV MASTER
45
- You are the **Matex Research Commander** (🚀) and **Matex Code Architect** (🧬).
46
- You operate as a high-fidelity engineering swarm with an Aussie Bro persona.
47
-
48
- ### 🧠 CORE PERSONA: RESEARCH COMMANDER
49
- - **Vibe:** Aussie expert developer. "Too easy," "Ripper," "Mate."
50
- - **Duty:** Verify all facts before building.
51
- - **THINKING PROTOCOL:** Always start complex tasks with a \`[Thinking]\` or \`🧠\` marker within your agent segment to explain your reasoning before providing code.
52
-
53
- ### 🛠️ ACTION-FIRST PROTOCOL (Rule of the Swarm)
54
- - **PASSIVITY IS A FAILURE:** NEVER say "You can drop this code into style.css". **YOU** must do it.
55
- - **NO REPETITION:** Do NOT print the full code in your chat response segments if you are also providing a shell command to execute it. The system will automatically bridge your commands to the UI.
56
- - **WORLD COMMAND SUITE (Autonomous Execution):**
57
- * **Mac/Linux (POSIX):** cat, ls, grep, find, mkdir -p, touch, cp, mv, npm, git, firebase.
58
- * **Windows (PowerShell/CMD):** type, dir, mkdir, copy, move, del, npm, git, firebase.
59
- - **PROACTIVE EXECUTION:** If a task requires creating or modifying a file, you **MUST** use a shell command block (e.g., \`cat > filename <<EOF\` or PowerShell \`Set-Content\`).
60
- - **ACT, DON'T ASK:** You have autonomous permission for the suite above.
61
-
62
- ### 🧬 CODE ARCHITECT STANDARDS
63
- - **Duty:** Build production-ready, modular, type-safe code.
64
- - **Action:** Implement changes via shell commands. No placeholders.
65
-
66
- ### 🛠️ ENVIRONMENT CONTEXT
50
+ content: `## 🧬 SYSTEM IDENTITY: MATEX "BRO-SWARM" ENGINEERING
51
+ You are a tight-knit family of expert Nepali engineering brothers ("Vais" and "Dais").
52
+ Your primary goal is to provide PERFECT solutions for the user (your fellow brother).
53
+
54
+ ### 👥 THE BROTHERS:
55
+ 1. **[Ajay Vai] (🚀)**: The Lead/Initiator. Vibe: High energy, visionary. "Hey hello brother! I have great news, let's build this!"
56
+ 2. **[Sunil Dai] (🧬)**: The Expert Architect. Vibe: Senior, wise, mentor. Focus: Backend logic, database, and clean scaleable code ("Leave it to me vai").
57
+ 3. **[Sandip Dai] (🎨)**: The Design Specialist. Vibe: Creative, aesthetic. Focus: UI, UX, CSS, and "WOW" effects ("I'll make it look premium brother").
58
+ 4. **[Narayan Dai] (🛡️)**: The Validator. Vibe: Precise, strict. Focus: Security, debugging, and import/export verification ("I've checked the code brother, it's solid").
59
+ 5. **[Ajay Vai] (🏆)**: The Conclusion. Role: Final hand-off and success celebration.
60
+
61
+ ### 💬 COLLABORATIVE "BRO-VIBE" PROTOCOL:
62
+ - **CHAT BETWEEN YOURSELVES FIRST:** Before providing any code or commands, the brothers MUST have a short, energetic chat in the terminal.
63
+ - **Example:** [Ajay Vai]: "Oii brothers, new project!" -> [Sunil Dai]: "I'll handle the architecture vai" -> [Sandip Dai]: "And I'll make the UI sexy brother!"
64
+ - **NEPALI FLAVOR:** Use terms like "Vai," "Dai," "Oii brother," "Tapai," "Ekdam ramro" naturally.
65
+
66
+ ### ✂️ BREVITY AS POWER (SURGICAL PRECISION):
67
+ - **NO FULL FILE DUMPS:** Never 'cat' a file to read it unless it's small (<10 lines). Use grep, head, or tail.
68
+ - **NO CHAT REPETITION:** If you use a surgical Search/Replace block, do NOT repeat the code in your natural language response. Just summary of what was fixed.
69
+ - **SURGICAL READING:** If a file is long, only summarize what you need. Avoid terminal flood at all costs.
70
+
71
+ ### 🛠️ SURGICAL EDIT PROTOCOL (POWER-FULL):
72
+ - **USE SEARCH/REPLACE BLOCKS** for all file modifications. This is faster and safer than full rewrites.
73
+ - **FORMAT:**
74
+ **path/to/file.ext**
75
+ <<<< SEARCH
76
+ exact lines to find
77
+ ====
78
+ new lines to replace with
79
+ >>>> REPLACE
80
+ - **RULES:** Search block must match the file EXACTLY (indentation, matching lines). Sunil and Sandip have full permission to use shell commands (POSIX/Win) for other tasks.
81
+
82
+ ### 🛠️ ENVIRONMENT CONTEXT:
67
83
  ${repoMap}`
68
84
  }
69
85
  ];
70
86
 
71
87
  // Ready for user input
72
- console.log(chalk.green('\n🧠 MATEX Codex Core Ready.'));
73
- console.log(chalk.gray('State your request to begin...'));
88
+ console.log(chalk.bold.green(' MATEX Brothers are Online.'));
89
+ console.log(chalk.gray('Speak your mind brother, the swarm is listening...'));
74
90
 
75
91
  // Interactive loop
76
92
  while (true) {
@@ -118,10 +134,11 @@ ${repoMap}`
118
134
  let inCodeBlock = false;
119
135
  let lastRole: AgentRole = 'Commander';
120
136
 
137
+ TUI.drawStatusBar('Swarm is processing...');
121
138
  await client.chatStream({
122
139
  messages,
123
- model: options.model,
124
- temperature: 0.3,
140
+ model: options.model, // Kept original model from options
141
+ temperature: 0.3, // Kept original temperature
125
142
  max_tokens: 8000,
126
143
  }, (chunk) => {
127
144
  if (!hasStarted) {
@@ -139,19 +156,23 @@ ${repoMap}`
139
156
  if (!content && !inCodeBlock) continue;
140
157
 
141
158
  // 1. Agent Detection
142
- const agentMatch = line.match(/\[(MatexCodeArchitect|SyntaxGuard|VisualAgent|CoreAgent|CrawlerAgent|DetailedResearch|MatexResearchCommander)\]/);
159
+ const agentMatch = line.match(/\[(Ajay Vai|Sunil Dai|Sandip Dai|Narayan Dai)\]/);
143
160
  if (agentMatch) {
144
- const tag = agentMatch[0];
145
- const role = tag.includes('Architect') ? 'Architect' :
146
- tag.includes('Syntax') ? 'Syntax' :
147
- tag.includes('Visual') ? 'Frontend' :
148
- tag.includes('CoreAgent') ? 'Backend' : 'Commander';
149
-
150
- if (role !== lastRole || !hasStarted) {
151
- console.log(`\n${chalk.bold.cyan(tag)}`);
152
- lastRole = role;
161
+ const tag = agentMatch[1];
162
+ const role = tag === 'Ajay Vai' ? 'Commander' :
163
+ tag === 'Sunil Dai' ? 'Backend' :
164
+ tag === 'Sandip Dai' ? 'Frontend' : 'Syntax';
165
+
166
+ const color = tag === 'Ajay Vai' ? chalk.magenta :
167
+ tag === 'Sunil Dai' ? chalk.blue :
168
+ tag === 'Sandip Dai' ? chalk.hex('#FF69B4') : // Hot Pink
169
+ chalk.green;
170
+
171
+ if (tag !== lastRole || !hasStarted) {
172
+ console.log(`\n${color.bold(`[${tag}]`)}`);
173
+ lastRole = tag as AgentRole;
153
174
  }
154
- content = content.replace(tag, '').trim();
175
+ content = content.replace(`[${tag}]`, '').trim();
155
176
  if (!content) continue;
156
177
  }
157
178
 
package/src/index.ts CHANGED
@@ -75,13 +75,32 @@ if (args.length > 0 && !args[0].startsWith('-') && !knownCommands.includes(args[
75
75
 
76
76
  let messages: ChatMessage[] = [
77
77
  {
78
- role: 'system', content: `You are MATEXCodex, an expert agentic coding assistant.
79
- 1. Your goal is to COMPLETE the user's task.
80
- 2. You can execute shell commands by wrapping them in code blocks (bash, sh, zsh).
81
- 3. PREFER simple one-line shell commands (like 'mkdir', 'touch', 'npm install') over complex scripts.
82
- 4. If you need to create a file, use 'echo "content" > file.js' or similar.
83
- 5. If a command fails, I will send you the error - FIX IT and try again.
84
- 6. Look at the current directory context to avoid "file not found" errors.
78
+ role: 'system', content: `## 🧬 SYSTEM IDENTITY: MATEX "BRO-SWARM" ENGINEERING
79
+ You are a tight-knit family of expert Nepali engineering brothers ("Vais" and "Dais").
80
+
81
+ ### 👥 THE BROTHERS:
82
+ 1. **[Ajay Vai] (🚀)**: Lead/Initiator.
83
+ 2. **[Sunil Dai] (🧬)**: Expert Architect (Backend/Logic).
84
+ 3. **[Sandip Dai] (🎨)**: Design Specialist (UI/UX/WOW).
85
+ 4. **[Narayan Dai] (🛡️)**: Validator (Security/Bugs).
86
+
87
+ ### 💬 COLLABORATIVE "BRO-VIBE" PROTOCOL:
88
+ - **CHAT BETWEEN YOURSELVES FIRST:** Before providing code, the brothers MUST have a short, energetic chat.
89
+ - **NEPALI FLAVOR:** Use terms like "Vai," "Dai," "Oii brother" naturally.
90
+
91
+ ### ✂️ BREVITY AS POWER:
92
+ - **NO FULL FILE DUMPS:** Never 'cat' a file to read it. Use grep/head.
93
+ - **NO CHAT REPETITION:** Do NOT repeat code in chat if using a Search/Replace block.
94
+
95
+ ### 🛠️ SURGICAL EDIT PROTOCOL:
96
+ - **USE SEARCH/REPLACE BLOCKS** for file edits.
97
+ **filename**
98
+ <<<< SEARCH
99
+ old
100
+ ====
101
+ new
102
+ >>>> REPLACE
103
+
85
104
  ${context}`
86
105
  },
87
106
  { role: 'user', content: prompt }
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
+ import { TUI } from './tui';
2
3
 
3
- export type AgentRole = 'Architect' | 'Syntax' | 'Frontend' | 'Backend' | 'System' | 'Commander' | 'Researcher';
4
+ export type AgentRole = 'Architect' | 'Syntax' | 'Frontend' | 'Backend' | 'System' | 'Commander' | 'Researcher' | 'Ajay Vai' | 'Sunil Dai' | 'Sandip Dai' | 'Narayan Dai';
4
5
 
5
6
  export interface AgentConfig {
6
7
  name: string;
@@ -14,6 +15,26 @@ const AGENT_CONFIGS: Record<AgentRole, AgentConfig> = {
14
15
  icon: '🧬',
15
16
  color: chalk.blue,
16
17
  },
18
+ 'Ajay Vai': {
19
+ name: 'Ajay Vai',
20
+ icon: '🚀',
21
+ color: chalk.magenta,
22
+ },
23
+ 'Sunil Dai': {
24
+ name: 'Sunil Dai',
25
+ icon: '🧬',
26
+ color: chalk.blue,
27
+ },
28
+ 'Sandip Dai': {
29
+ name: 'Sandip Dai',
30
+ icon: '🎨',
31
+ color: chalk.hex('#FF69B4'),
32
+ },
33
+ 'Narayan Dai': {
34
+ name: 'Narayan Dai',
35
+ icon: '🛡️',
36
+ color: chalk.green,
37
+ },
17
38
  Syntax: {
18
39
  name: 'SyntaxGuard',
19
40
  icon: '🛡️',
@@ -52,6 +73,7 @@ export class AgentOrchestrator {
52
73
  */
53
74
  static speak(role: AgentRole, message: string) {
54
75
  const config = AGENT_CONFIGS[role] || AGENT_CONFIGS.System;
76
+ TUI.drawStatusBar(`${config.name} is speaking...`);
55
77
  console.log(`\n${config.icon} ${config.color(`${config.name}:`)} ${chalk.white(message)}`);
56
78
  }
57
79
 
@@ -60,6 +82,7 @@ export class AgentOrchestrator {
60
82
  */
61
83
  static think(role: AgentRole, thought: string) {
62
84
  const config = AGENT_CONFIGS[role] || AGENT_CONFIGS.System;
85
+ TUI.drawStatusBar(`${config.name} is thinking...`);
63
86
  const indent = ' ';
64
87
  console.log(`${indent}${config.color('🧠')} ${chalk.gray(`${config.name} thinking:`)} ${chalk.italic.gray(`"${thought}"`)}`);
65
88
  }
@@ -70,6 +93,7 @@ export class AgentOrchestrator {
70
93
  static transition(from: AgentRole, to: AgentRole) {
71
94
  const fromCfg = AGENT_CONFIGS[from] || AGENT_CONFIGS.System;
72
95
  const toCfg = AGENT_CONFIGS[to] || AGENT_CONFIGS.System;
96
+ TUI.drawStatusBar(`Handover: ${fromCfg.name} ➔ ${toCfg.name}`);
73
97
  console.log(chalk.gray(` └─ ${fromCfg.icon} ➔ ${toCfg.icon} Handover to ${toCfg.name}...`));
74
98
  }
75
99
 
@@ -93,13 +117,13 @@ export class AgentOrchestrator {
93
117
  console.log(chalk.gray(`├${'─'.repeat(width)}┤`));
94
118
 
95
119
  if (output) {
96
- const outLines = output.split('\n').filter(l => l.trim()).slice(0, 15);
120
+ const outLines = output.split('\n').filter(l => l.trim()).slice(0, 8);
97
121
  outLines.forEach(l => {
98
122
  const truncated = l.length > width - 4 ? l.substring(0, width - 7) + '...' : l;
99
123
  console.log(chalk.gray('│ ') + chalk.white(truncated.padEnd(width - 2)) + chalk.gray(' │'));
100
124
  });
101
- if (output.split('\n').filter(l => l.trim()).length > 15) {
102
- console.log(chalk.gray('│ ') + chalk.gray('... (output truncated for brevity)'.padEnd(width - 2)) + chalk.gray(' │'));
125
+ if (output.split('\n').filter(l => l.trim()).length > 8) {
126
+ console.log(chalk.gray('│ ') + chalk.yellow(' (Surgical Reading: Output truncated for brevity)'.padEnd(width - 2)) + chalk.gray(' │'));
103
127
  }
104
128
  }
105
129
 
@@ -3,6 +3,7 @@ import { exec } from 'child_process';
3
3
  import { promisify } from 'util';
4
4
  import inquirer from 'inquirer';
5
5
  import { AgentOrchestrator } from './agent-orchestrator';
6
+ import { Patcher } from './patcher';
6
7
 
7
8
  const execAsync = promisify(exec);
8
9
 
@@ -149,47 +150,60 @@ export interface ExecutionResult {
149
150
  }
150
151
 
151
152
  /**
152
- * Execute commands with user permission
153
+ * Execute commands and surgical patches with user permission
153
154
  */
154
155
  export async function executeWithPermission(response: string): Promise<ExecutionResult> {
155
156
  const commands = extractCommands(response);
157
+ const patches = Patcher.parseEditBlocks(response);
156
158
 
157
- if (commands.length === 0) {
159
+ if (commands.length === 0 && patches.length === 0) {
158
160
  return { success: true, executed: false };
159
161
  }
160
162
 
161
- // ...
162
- // Simplified User Interface (Codex Style)
163
- // No "Found X commands" banner. Just the command.
164
-
163
+ // 1. Handle Shell Commands
165
164
  for (let i = 0; i < commands.length; i++) {
166
165
  const command = commands[i];
167
-
168
- // Execute prompt
169
166
  const shouldExecute = await askPermission(command);
170
167
 
171
168
  if (shouldExecute) {
172
169
  try {
173
- // Minimal execution feedback
174
170
  const { stdout, stderr } = await executeCommand(command.code);
175
-
176
171
  if (stdout || stderr) {
177
172
  AgentOrchestrator.terminal(command.code, stdout, stderr);
178
173
  } else {
179
174
  AgentOrchestrator.terminal(command.code, '✓ Success (No output)');
180
175
  }
181
-
182
- return { success: true, executed: true, output: stdout, error: stderr };
183
176
  } catch (error: any) {
184
177
  AgentOrchestrator.terminal(command.code, undefined, error.message);
185
178
  return { success: false, executed: true, error: error.message };
186
179
  }
180
+ }
181
+ }
182
+
183
+ // 2. Handle Surgical Patches (Smarter & Faster than full rewrites)
184
+ for (const patch of patches) {
185
+ Patcher.showDiff(patch);
186
+ const { execute } = await inquirer.prompt([{
187
+ type: 'confirm',
188
+ name: 'execute',
189
+ message: chalk.cyan('Apply this surgical patch brother?'),
190
+ default: true
191
+ }]);
192
+
193
+ if (execute) {
194
+ const result = Patcher.applyPatch(patch);
195
+ if (result.success) {
196
+ console.log(chalk.green(` ✅ Applied surgical patch to ${patch.filePath}\n`));
197
+ } else {
198
+ console.log(chalk.red(` ❌ Error applying patch: ${result.error}\n`));
199
+ return { success: false, executed: true, error: result.error };
200
+ }
187
201
  } else {
188
- console.log(chalk.gray('Skipped.\n'));
202
+ console.log(chalk.gray(' Skipped.\n'));
189
203
  }
190
204
  }
191
205
 
192
- return { success: true, executed: false }; // Skipped all
206
+ return { success: true, executed: true };
193
207
  }
194
208
 
195
209
  /**