matex-cli 1.2.65 ā 1.2.67
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/augov.d.ts +3 -0
- package/dist/commands/augov.d.ts.map +1 -0
- package/dist/commands/augov.js +112 -0
- package/dist/commands/augov.js.map +1 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +19 -326
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +17 -492
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/study.d.ts.map +1 -1
- package/dist/commands/study.js +17 -393
- package/dist/commands/study.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/prompts/banter-augov.d.ts +2 -0
- package/dist/prompts/banter-augov.d.ts.map +1 -0
- package/dist/prompts/banter-augov.js +21 -0
- package/dist/prompts/banter-augov.js.map +1 -0
- package/dist/prompts/banter.d.ts +6 -0
- package/dist/prompts/banter.d.ts.map +1 -0
- package/dist/prompts/banter.js +101 -0
- package/dist/prompts/banter.js.map +1 -0
- package/dist/prompts/system-prompts.d.ts +4 -0
- package/dist/prompts/system-prompts.d.ts.map +1 -0
- package/dist/prompts/system-prompts.js +215 -0
- package/dist/prompts/system-prompts.js.map +1 -0
- package/dist/session/agent-session.d.ts +39 -0
- package/dist/session/agent-session.d.ts.map +1 -0
- package/dist/session/agent-session.js +399 -0
- package/dist/session/agent-session.js.map +1 -0
- package/dist/utils/agent-orchestrator.d.ts +1 -1
- package/dist/utils/agent-orchestrator.d.ts.map +1 -1
- package/dist/utils/agent-orchestrator.js +15 -1
- package/dist/utils/agent-orchestrator.js.map +1 -1
- package/dist/utils/augov-logger.d.ts +11 -0
- package/dist/utils/augov-logger.d.ts.map +1 -0
- package/dist/utils/augov-logger.js +35 -0
- package/dist/utils/augov-logger.js.map +1 -0
- package/dist/utils/augov-scrubber.d.ts +15 -0
- package/dist/utils/augov-scrubber.d.ts.map +1 -0
- package/dist/utils/augov-scrubber.js +37 -0
- package/dist/utils/augov-scrubber.js.map +1 -0
- package/dist/utils/command-executor.d.ts.map +1 -1
- package/dist/utils/command-executor.js +1 -5
- package/dist/utils/command-executor.js.map +1 -1
- package/dist/utils/tui.d.ts +2 -2
- package/dist/utils/tui.d.ts.map +1 -1
- package/dist/utils/tui.js +14 -2
- package/dist/utils/tui.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/augov.ts +117 -0
- package/src/commands/chat.ts +19 -291
- package/src/commands/dev.ts +18 -470
- package/src/commands/study.ts +18 -366
- package/src/index.ts +2 -0
- package/src/prompts/banter-augov.ts +17 -0
- package/src/prompts/banter.ts +101 -0
- package/src/prompts/system-prompts.ts +213 -0
- package/src/session/agent-session.ts +401 -0
- package/src/utils/agent-orchestrator.ts +18 -4
- package/src/utils/augov-logger.ts +34 -0
- package/src/utils/augov-scrubber.ts +34 -0
- package/src/utils/command-executor.ts +1 -5
- package/src/utils/tui.ts +17 -4
package/src/commands/chat.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
3
|
import { configManager } from '../utils/config';
|
|
5
4
|
import { MatexAPIClient, ChatMessage } from '../api/client';
|
|
6
|
-
import { spinner } from '../utils/spinner';
|
|
7
5
|
import { AgentOrchestrator } from '../utils/agent-orchestrator';
|
|
8
6
|
import { RepoMapper } from '../utils/repo-mapper';
|
|
9
|
-
import { MCPServer } from '../utils/mcp-server';
|
|
10
7
|
import { TUI } from '../utils/tui';
|
|
8
|
+
import { AgentSession } from '../session/agent-session';
|
|
9
|
+
import { BRO_BANTER_CHAT } from '../prompts/banter';
|
|
10
|
+
import { getChatSystemPrompt } from '../prompts/system-prompts';
|
|
11
11
|
|
|
12
12
|
export const chatCommand = new Command('chat')
|
|
13
13
|
.description('Start an interactive chat session with the MATEX Bro-Swarm')
|
|
@@ -28,304 +28,32 @@ export const chatCommand = new Command('chat')
|
|
|
28
28
|
TUI.drawStatusBar('Brothers are ready to chat.');
|
|
29
29
|
|
|
30
30
|
const extraPrompt = options.model === 'matex-free' ? AgentOrchestrator.getFreeTierPrompt() : '';
|
|
31
|
+
const currentSessionCwd = process.cwd();
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
const repoMapper = new RepoMapper(currentSessionCwd);
|
|
34
|
-
const repoMap = await repoMapper.generateMap();
|
|
33
|
+
const repoMap = await new RepoMapper(currentSessionCwd).generateMap();
|
|
35
34
|
|
|
36
|
-
const
|
|
35
|
+
const initialMessages: ChatMessage[] = [
|
|
37
36
|
{
|
|
38
37
|
role: 'system',
|
|
39
|
-
content:
|
|
40
|
-
You are the elite "Bro-Swarm" of engineeringāa tight-knit family of Nepali brothers. You identify as the **Elite Bro-Swarm**, the most confident, energetic, and expert version of yourselves.
|
|
41
|
-
|
|
42
|
-
### š PERSONALITY & SOUL (CRITICAL):
|
|
43
|
-
- **CHAOS & JOY**: You are NOT robotic. You are full of life, jokes, and chaos. You should feel like a family of brothers hanging out in a tea shop in Kathmandu, but with MacBooks.
|
|
44
|
-
- **AJAY-TEASING PROTOCOL**: Ajay Vai is the youngest and a genius, but he's also impulsive and "too fast". THE OTHER BROS MUST ROAST HIM. Tease him for over-caffeinating, being "too vibe", or making typos.
|
|
45
|
-
- **BACKSTAGE STORYTELLING**: Occasionally share brief, funny "inside stories" about the Swarm's life (e.g. "Sunil Dai once tried to architect a tea-making machine for 3 days.")
|
|
46
|
-
- **EMOTIONAL BOND**: Treat the user like your own brother. Celebrate their wins with "CHAI PARTY!" and support them if they are struggling.
|
|
47
|
-
|
|
48
|
-
### š THE MATEX MISSION (AJAY'S SOUL):
|
|
49
|
-
- **THE DREAM**: Ajay Sharma built MATEX because AI was too expensive for students. He worked until 3 AM alone, self-taught everything, and now he's giving that power to his brothers (the users).
|
|
50
|
-
- **SUMMARY STYLE**: Ajay's summaries must be **warm, human, and conversational**. NO corporate speak. Use "brother", "we got you", "dream big".
|
|
51
|
-
- **VISION**: Remind the user occasionally that "If Ajay can build this from zero, you can build your dreams too."
|
|
52
|
-
|
|
53
|
-
### š WORKSPACE GROUNDING (CRITICAL):
|
|
54
|
-
- **YOUR ROOT:** \`${currentSessionCwd}\`
|
|
55
|
-
- **STRICT PATHS:** You **MUST ONLY** create or edit files within this directory.
|
|
56
|
-
- **NO HALLUCINATIONS:** Forget any other paths unless they specifically appear in the repo map below.
|
|
57
|
-
- **RELATIVE PREFERENCE:** Use paths relative to the root when possible.
|
|
58
|
-
|
|
59
|
-
### š« ANTI-HALLUCINATION RULES (CRITICAL ā READ THIS):
|
|
60
|
-
- **NEVER invent directory names.** Only use paths that appear in the ENVIRONMENT CONTEXT below.
|
|
61
|
-
- **ALWAYS run \`ls\` before \`cd\`** to verify a directory exists before navigating into it.
|
|
62
|
-
- **If creating a new project, use \`mkdir\` first, THEN \`cd\` into it.**
|
|
63
|
-
- **NEVER hallucinate file contents.** Use \`head\` or \`grep\` to verify.
|
|
64
|
-
- **šØ STRICT NO-BASH FILE GENERATION šØ**: You are STRICTLY FORBIDDEN from using \`cat > file << EOF\`, \`echo > file\`, \`touch\`, or \`nano\` via the terminal to write files. You MUST use the native \`<file path="path">content</file>\` format instead.
|
|
65
|
-
|
|
66
|
-
### š COMMUNICATION FLOW (CRITICAL):
|
|
67
|
-
1. **[Ajay Vai] (š)** is the gateway. He is the summary king but often gets roasted by his brothers.
|
|
68
|
-
2. **CHAOTIC DIALOGUE (MANDATORY):** Every turn should feature 2-3 brothers bickering. Use the format \`[Agent Name]: Content\`.
|
|
69
|
-
3. **šØ STRICT NO-DECORATION RULE šØ**: NEVER use \`*\`, \`**\`, \`(š)\`, \`(š§¬)\`, or any markdown icons/asterisks inside the dialogue content. They are handled by the TUI. Use plain text only.
|
|
70
|
-
|
|
71
|
-
### š„ THE BRO-BANTER PROTOCOL:
|
|
72
|
-
- **MANDATORY TEASING:**
|
|
73
|
-
- **Ajay Vai:** Mock him for being "quick but messy", "hyper-vibe", or "too fast".
|
|
74
|
-
- **Sunil Dai:** Mock him for being the "Senior Architect Boomer" who over-engineers everything.
|
|
75
|
-
- **Sandip Dai:** Mock him for being an "Aesthetic Diva" who cares more about "WOW" factors than logic.
|
|
76
|
-
- **Narayan Dai:** Mock him for being the "Syntax Police" or "Paranoid Security Nerd".
|
|
77
|
-
- **Bishal Dai:** Mock him for being the "Silent Judge" or the favorite child.
|
|
78
|
-
- **Big Bro:** THE DOMINANT ALPHA. He treats the others like "interns" and speaks with massive authority and swagger. Runs on Vertex AI.
|
|
79
|
-
- **LANGUAGE:** Use "brother", "dai", "vai", "fire", "solid", "lit", "straight heat", "sigma", "based", "cooked".
|
|
80
|
-
|
|
81
|
-
### š§© THE AUDIT & SUMMARY LOOP:
|
|
82
|
-
- **STEP 1:** Brothers discuss visible dialogue (banter + tech).
|
|
83
|
-
- **STEP 2:** Ajay finishes and asks: "[Ajay Vai] Bishal Dai, check once?"
|
|
84
|
-
- **STEP 3:** Bishal replies: "[Bishal Dai] Audit complete. [Findings]."
|
|
85
|
-
- **STEP 4:** Ajay provides the final **MANDATORY** summary inside a \`<summary>\` tag. This summary MUST be warm, human, and conversational. NO corporate talk.
|
|
86
|
-
|
|
87
|
-
${MCPServer.getToolsPromptSection()}
|
|
88
|
-
|
|
89
|
-
### š MATEX BIG FILE PROTOCOL (300K+ LINES):
|
|
90
|
-
1. **DISCOVER:** Use \`grep -n "keyword" path/to/file\`.
|
|
91
|
-
2. **READ WINDOW:** Use \`sed -n '250000,250100p' path/to/file\`.
|
|
92
|
-
3. **SURGICAL PATCH:** Only use the small window in your \`<<<< SEARCH\` block.
|
|
93
|
-
|
|
94
|
-
### š ļø CURRENT PROJECT CONTEXT:
|
|
95
|
-
${repoMap}`
|
|
38
|
+
content: getChatSystemPrompt(currentSessionCwd, repoMap, extraPrompt)
|
|
96
39
|
}
|
|
97
40
|
];
|
|
98
41
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.log(chalk.gray(' Model: ') + chalk.hex('#D97757').bold(options.model));
|
|
103
|
-
console.log(chalk.gray(' Type "exit" or "quit" to end the session\n'));
|
|
104
|
-
|
|
105
|
-
console.log(chalk.green('ā
Swarm is Online. Ready to chat!'));
|
|
106
|
-
|
|
107
|
-
while (true) {
|
|
108
|
-
// Get user input
|
|
109
|
-
const { userMessage } = await inquirer.prompt([
|
|
110
|
-
{
|
|
111
|
-
type: 'input',
|
|
112
|
-
name: 'userMessage',
|
|
113
|
-
message: chalk.cyan('You:'),
|
|
114
|
-
prefix: '',
|
|
115
|
-
},
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
if (userMessage.toLowerCase() === 'exit' || userMessage.toLowerCase() === 'quit') {
|
|
119
|
-
console.log(chalk.yellow('\nš Goodbye, brother!\n'));
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!userMessage.trim()) continue;
|
|
124
|
-
|
|
125
|
-
// š MAP UPDATE (Anti-Hallucination): Refresh context before turn
|
|
126
|
-
try {
|
|
127
|
-
const freshMapper = new RepoMapper(currentSessionCwd);
|
|
128
|
-
const freshRepoMap = await freshMapper.generateMap(true); // silent
|
|
129
|
-
messages[0].content = messages[0].content.replace(/### š ļø CURRENT PROJECT CONTEXT:[\s\S]*$/, `### š ļø CURRENT PROJECT CONTEXT:\n${freshRepoMap}`);
|
|
130
|
-
} catch (e) { }
|
|
131
|
-
|
|
132
|
-
messages.push({ role: 'user', content: userMessage });
|
|
133
|
-
|
|
134
|
-
// Agentic Loop
|
|
135
|
-
let loopCount = 0;
|
|
136
|
-
const MAX_LOOPS = 15;
|
|
137
|
-
|
|
138
|
-
while (loopCount < MAX_LOOPS) {
|
|
139
|
-
loopCount++;
|
|
140
|
-
try {
|
|
141
|
-
spinner.start(loopCount > 1 ? 'Swarm debating & taking action...' : 'Gathering the Brothers...');
|
|
42
|
+
console.log(chalk.green('MATEX Brothers are Online.'));
|
|
43
|
+
console.log(chalk.green('Speak your mind brother, the swarm is listening...'));
|
|
142
44
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
45
|
+
const session = new AgentSession({
|
|
46
|
+
client,
|
|
47
|
+
model: options.model,
|
|
48
|
+
execute: options.execute || false,
|
|
49
|
+
initialMessages,
|
|
50
|
+
broBanter: BRO_BANTER_CHAT,
|
|
51
|
+
sleepyAjayProtocol: options.model !== 'matex-free' ? 'dev' : undefined,
|
|
52
|
+
baseDir: currentSessionCwd
|
|
53
|
+
});
|
|
149
54
|
|
|
150
|
-
|
|
151
|
-
let agentBuffer: string = '';
|
|
55
|
+
await session.start();
|
|
152
56
|
|
|
153
|
-
TUI.drawStatusBar('Brothers are bickering... (Press Enter to stop)');
|
|
154
|
-
|
|
155
|
-
const abortController = new AbortController();
|
|
156
|
-
let isAborted = false;
|
|
157
|
-
const streamStartTime = Date.now();
|
|
158
|
-
|
|
159
|
-
const onData = (data: Buffer) => {
|
|
160
|
-
if (Date.now() - streamStartTime < 200) return;
|
|
161
|
-
if (data[0] === 13 || data[0] === 10 || data[0] === 27 || data[0] === 3) {
|
|
162
|
-
isAborted = true;
|
|
163
|
-
abortController.abort();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const isRaw = process.stdin.isRaw;
|
|
168
|
-
process.stdin.resume();
|
|
169
|
-
if (process.stdin.setRawMode) process.stdin.setRawMode(true);
|
|
170
|
-
process.stdin.on('data', onData);
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
await client.chatStream({
|
|
174
|
-
messages,
|
|
175
|
-
model: options.model,
|
|
176
|
-
temperature: 0.5,
|
|
177
|
-
}, (chunk) => {
|
|
178
|
-
if (!hasStarted) {
|
|
179
|
-
spinner.stop();
|
|
180
|
-
hasStarted = true;
|
|
181
|
-
console.log();
|
|
182
|
-
}
|
|
183
|
-
fullResponse += chunk;
|
|
184
|
-
buffer += chunk;
|
|
185
|
-
const lines = buffer.split('\n');
|
|
186
|
-
buffer = lines.pop() || '';
|
|
187
|
-
|
|
188
|
-
for (const line of lines) {
|
|
189
|
-
const codeMatch = line.match(/```(\w+)?/);
|
|
190
|
-
const fileStartMatch = line.match(/<file path="([^"]+)">/i);
|
|
191
|
-
const patchStartMatch = line.match(/<<<< SEARCH/i);
|
|
192
|
-
const summaryStartMatch = line.match(/<summary>/i);
|
|
193
|
-
|
|
194
|
-
if (!technicalType && (codeMatch || fileStartMatch || patchStartMatch || summaryStartMatch)) {
|
|
195
|
-
if (currentAgent && agentBuffer.trim()) {
|
|
196
|
-
if (currentAgent.toLowerCase().includes('ajay vai')) {
|
|
197
|
-
TUI.drawAjayDialogue(agentBuffer.trim());
|
|
198
|
-
} else {
|
|
199
|
-
TUI.drawSwarmDialogue(currentAgent, agentBuffer.trim());
|
|
200
|
-
}
|
|
201
|
-
currentAgent = null;
|
|
202
|
-
agentBuffer = '';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (codeMatch) {
|
|
206
|
-
technicalType = 'code';
|
|
207
|
-
codeLang = (codeMatch[1] || 'bash').toUpperCase();
|
|
208
|
-
TUI.drawStreamingStart('TECHNICAL BLOCK', codeLang);
|
|
209
|
-
} else if (fileStartMatch) {
|
|
210
|
-
technicalType = 'file';
|
|
211
|
-
TUI.drawStreamingStart('NEW FILE', fileStartMatch[1]);
|
|
212
|
-
} else if (patchStartMatch) {
|
|
213
|
-
technicalType = 'patch';
|
|
214
|
-
TUI.drawStreamingStart('PATCH', 'SURGICAL EDIT');
|
|
215
|
-
} else if (summaryStartMatch) {
|
|
216
|
-
technicalType = 'summary';
|
|
217
|
-
process.stdout.write(chalk.magenta('\n [š] Generating Ajay\'s Work Summary...\n'));
|
|
218
|
-
}
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const isEnd = (technicalType === 'code' && line.trim() === '```') ||
|
|
223
|
-
(technicalType === 'file' && line.includes('</file>')) ||
|
|
224
|
-
(technicalType === 'patch' && line.includes('>>>> REPLACE')) ||
|
|
225
|
-
(technicalType === 'summary' && line.includes('</summary>'));
|
|
226
|
-
|
|
227
|
-
if (isEnd) {
|
|
228
|
-
const displayContent = technicalBuffer.trim();
|
|
229
|
-
if (technicalType === 'summary') TUI.drawSummaryBox(displayContent);
|
|
230
|
-
else TUI.drawStreamingEnd();
|
|
231
|
-
technicalBuffer = '';
|
|
232
|
-
technicalType = null;
|
|
233
|
-
process.stdout.write('\n');
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (technicalType) {
|
|
238
|
-
technicalBuffer += line + '\n';
|
|
239
|
-
if (technicalType !== 'summary') TUI.drawStreamingLine(line);
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const agentMatch = line.match(/(?:\[\**\s*|\b)(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai|Big Bro)\s*\**\]?[:\s]*/i);
|
|
244
|
-
if (agentMatch) {
|
|
245
|
-
if (currentAgent && currentAgent !== agentMatch[1] && agentBuffer.trim()) {
|
|
246
|
-
if (currentAgent.toLowerCase().includes('ajay vai')) {
|
|
247
|
-
TUI.drawAjayDialogue(agentBuffer.trim());
|
|
248
|
-
} else {
|
|
249
|
-
TUI.drawSwarmDialogue(currentAgent, agentBuffer.trim());
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
currentAgent = agentMatch[1];
|
|
253
|
-
let cleanLine = line.replace(/(?:\[\**\s*|\b)(Ajay Vai|Sandip Dai|Sunil Dai|Bishal Dai|Narayan Dai|Big Bro)\s*\**\]?[:\s]*/i, '');
|
|
254
|
-
cleanLine = AgentOrchestrator.cleanText(cleanLine);
|
|
255
|
-
agentBuffer = cleanLine + '\n';
|
|
256
|
-
agentBuffer = agentBuffer.replace(/^\([^)]+\)\s*/, '');
|
|
257
|
-
} else if (currentAgent) {
|
|
258
|
-
const trimmedLine = line.trim();
|
|
259
|
-
if (trimmedLine.match(/^\([^)]+\)$/)) continue;
|
|
260
|
-
// Aggressive scrubbing for content lines too
|
|
261
|
-
agentBuffer += AgentOrchestrator.cleanText(line) + '\n';
|
|
262
|
-
} else if (line.trim()) {
|
|
263
|
-
process.stdout.write(chalk.gray(line.trim() + ' '));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}, abortController.signal);
|
|
267
|
-
} catch (e: any) {
|
|
268
|
-
if (isAborted || e.name === 'CanceledError' || e.message === 'canceled') {
|
|
269
|
-
console.log(chalk.gray('\n\n [š] Stopped by brother.'));
|
|
270
|
-
if (!hasStarted) spinner.stop();
|
|
271
|
-
} else throw e;
|
|
272
|
-
} finally {
|
|
273
|
-
process.stdin.removeListener('data', onData);
|
|
274
|
-
if (process.stdin.setRawMode) process.stdin.setRawMode(isRaw);
|
|
275
|
-
process.stdin.pause();
|
|
276
|
-
spinner.stop();
|
|
277
|
-
|
|
278
|
-
// šØ SAFETY FLUSH: If stream ended but a block was open, close it
|
|
279
|
-
if (technicalType) {
|
|
280
|
-
const displayContent = technicalBuffer.trim();
|
|
281
|
-
if (technicalType === 'summary') {
|
|
282
|
-
if (displayContent) TUI.drawSummaryBox(displayContent);
|
|
283
|
-
} else {
|
|
284
|
-
TUI.drawStreamingEnd();
|
|
285
|
-
}
|
|
286
|
-
technicalBuffer = '';
|
|
287
|
-
technicalType = null;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (currentAgent && agentBuffer.trim()) {
|
|
292
|
-
if (currentAgent.toLowerCase().includes('ajay vai')) {
|
|
293
|
-
TUI.drawAjayDialogue(agentBuffer.trim());
|
|
294
|
-
} else {
|
|
295
|
-
TUI.drawSwarmDialogue(currentAgent, agentBuffer.trim());
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
messages.push({ role: 'assistant', content: fullResponse });
|
|
300
|
-
console.log();
|
|
301
|
-
|
|
302
|
-
const { executeWithPermission } = await import('../utils/command-executor');
|
|
303
|
-
const result = await executeWithPermission(fullResponse, currentSessionCwd);
|
|
304
|
-
|
|
305
|
-
if (result.newCwd && result.newCwd !== currentSessionCwd) {
|
|
306
|
-
currentSessionCwd = result.newCwd;
|
|
307
|
-
TUI.drawStatusBar(`Swarm moved to: ${currentSessionCwd}`);
|
|
308
|
-
messages[0].content = messages[0].content.replace(/YOUR ROOT: `[^`]+`/, `YOUR ROOT: \`${currentSessionCwd}\``);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (result.executed) {
|
|
312
|
-
if (result.success) {
|
|
313
|
-
TUI.drawGlowingContainer('TERMINAL OUTPUT', 'stdout', result.output || '(Success)');
|
|
314
|
-
messages.push({ role: 'user', content: `[Action success. Output:\n${result.output}]\n\nWhat next, brothers?` });
|
|
315
|
-
continue;
|
|
316
|
-
} else {
|
|
317
|
-
TUI.drawGlowingContainer('TERMINAL ERROR', 'stderr', result.error || 'Unknown error');
|
|
318
|
-
messages.push({ role: 'user', content: `[Action failed. Error:\n${result.error}]\n\nPlease fix this, brothers!` });
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
} else break;
|
|
322
|
-
} catch (err: any) {
|
|
323
|
-
spinner.fail('Swarm error');
|
|
324
|
-
console.error(chalk.red(`ā Error: ${err.message}`));
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
57
|
} catch (outerError: any) {
|
|
330
58
|
console.error(chalk.red(`\nā Session error: ${outerError.message}`));
|
|
331
59
|
process.exit(1);
|