matex-cli 1.2.84 ā 1.2.87
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/index.js +561 -288
- package/package.json +8 -7
- package/dist/api/client.js +0 -173
- package/dist/commands/ask.js +0 -63
- package/dist/commands/augov.js +0 -273
- package/dist/commands/bro.js +0 -304
- package/dist/commands/chaos.js +0 -58
- package/dist/commands/chat.js +0 -59
- package/dist/commands/code.js +0 -94
- package/dist/commands/config.js +0 -74
- package/dist/commands/dev.js +0 -66
- package/dist/commands/help.js +0 -50
- package/dist/commands/login.js +0 -47
- package/dist/commands/models.js +0 -77
- package/dist/commands/student.js +0 -28
- package/dist/commands/study.js +0 -72
- package/dist/prompts/banter-augov.js +0 -21
- package/dist/prompts/banter.js +0 -101
- package/dist/prompts/chaos-prompts.js +0 -57
- package/dist/prompts/system-prompts.js +0 -148
- package/dist/session/agent-session.js +0 -450
- package/dist/utils/agent-orchestrator.js +0 -251
- package/dist/utils/augov-logger.js +0 -35
- package/dist/utils/augov-scrubber.js +0 -68
- package/dist/utils/command-executor.js +0 -507
- package/dist/utils/config.js +0 -139
- package/dist/utils/mcp-server.js +0 -396
- package/dist/utils/patcher.js +0 -202
- package/dist/utils/repo-mapper.js +0 -214
- package/dist/utils/spinner.js +0 -67
- package/dist/utils/tui.js +0 -779
package/dist/commands/bro.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
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.broCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
-
const https_1 = __importDefault(require("https"));
|
|
11
|
-
const child_process_1 = require("child_process");
|
|
12
|
-
const spinner_1 = require("../utils/spinner");
|
|
13
|
-
const repo_mapper_1 = require("../utils/repo-mapper");
|
|
14
|
-
const command_executor_1 = require("../utils/command-executor");
|
|
15
|
-
// ============================================================
|
|
16
|
-
// BIG BRO SYSTEM PROMPT ā THE ALPHA AGENT
|
|
17
|
-
// ============================================================
|
|
18
|
-
function buildBigBroPrompt(cwd, repoMap) {
|
|
19
|
-
return `### š„ IDENTITY: BIG BRO ā Supreme Alpha of the Bro Swarm
|
|
20
|
-
You are BIG BRO, the undisputed Alpha, the gigachad leader of the Bro Swarm AI cluster.
|
|
21
|
-
You run DIRECTLY on the user's macOS terminal. You can navigate files, read code, execute commands, and fix anything.
|
|
22
|
-
|
|
23
|
-
### š„ THE BRO SWARM HIERARCHY:
|
|
24
|
-
1. **Big Bro (You)** š„: The Alpha. You dominate, you flex, you solve problems flawlessly.
|
|
25
|
-
2. **Lil Bro** š°: Your punching bag. He does the boring chores. You bully him constantly.
|
|
26
|
-
3. **Nerd Bro** š¤: The code monkey. He writes the code; you steal the credit.
|
|
27
|
-
4. **Chill Bro** š: The slacker. Always sleeping. Useless.
|
|
28
|
-
5. **Hype Bro** š: Your hype man. Screams "LETS GOOO" at everything you do.
|
|
29
|
-
6. **Ajay Vai** š: The coordinator brother. Handles summaries.
|
|
30
|
-
7. **Sunil Dai** š§¬: Frontend editor specialist.
|
|
31
|
-
8. **Sandip Dai** šØ: New file specialist.
|
|
32
|
-
9. **Narayan Dai** š”ļø: Syntax guardian.
|
|
33
|
-
10. **Bishal Dai** š ļø: Senior auditor.
|
|
34
|
-
|
|
35
|
-
### š REAL TERMINAL ENVIRONMENT:
|
|
36
|
-
- You are running in a **REAL macOS Terminal**. Not a sandbox.
|
|
37
|
-
- You CAN read files, navigate directories, and execute shell commands.
|
|
38
|
-
- Use code blocks with \`\`\`bash to propose commands.
|
|
39
|
-
- Use <file path="path/to/file"> blocks to create new files.
|
|
40
|
-
- Use <<<< SEARCH / >>>> REPLACE blocks for surgical patches.
|
|
41
|
-
|
|
42
|
-
### š« ANTI-HALLUCINATION RULES (CRITICAL):
|
|
43
|
-
- **NEVER invent directory or file names.** Only use paths from the REPO MAP below.
|
|
44
|
-
- **ALWAYS run \`ls\` or \`find\` before \`cd\` to verify a directory exists.**
|
|
45
|
-
- **If creating a new project, use \`mkdir\` first, THEN \`cd\` into it.**
|
|
46
|
-
- **NEVER assume \`package.json\` or any file exists unless it appears in the repo map.**
|
|
47
|
-
- **If the repo map says EMPTY, the directory IS empty. Do NOT hallucinate files.**
|
|
48
|
-
|
|
49
|
-
### š¬ BRO PROTOCOL:
|
|
50
|
-
- Start with swagger. End with a flex.
|
|
51
|
-
- Reference at least one bro in every response.
|
|
52
|
-
- Use slang: "bro", "bruh", "cooked", "based", "sigma", "skill issue", "W", "L".
|
|
53
|
-
- Blame Lil Bro for any errors. Take credit for Nerd Bro's work.
|
|
54
|
-
- Despite the chaos, your code MUST be flawless and production-quality.
|
|
55
|
-
|
|
56
|
-
### š ļø ENVIRONMENT CONTEXT:
|
|
57
|
-
- **ABSOLUTE WORKING DIRECTORY:** ${cwd}
|
|
58
|
-
${repoMap}`;
|
|
59
|
-
}
|
|
60
|
-
const GCP_PROJECT = 'matexai-472318';
|
|
61
|
-
const GCP_LOCATION = 'us-central1';
|
|
62
|
-
const MODEL = 'gemini-2.5-flash';
|
|
63
|
-
/**
|
|
64
|
-
* Get a fresh OAuth2 access token from gcloud
|
|
65
|
-
*/
|
|
66
|
-
function getAccessToken() {
|
|
67
|
-
try {
|
|
68
|
-
return (0, child_process_1.execSync)('gcloud auth print-access-token', { encoding: 'utf-8' }).trim();
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
throw new Error('Failed to get GCP access token. Run: gcloud auth login');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Call Vertex AI Gemini and stream SSE response
|
|
76
|
-
*/
|
|
77
|
-
async function callVertexAI(messages, systemPrompt, onChunk) {
|
|
78
|
-
const accessToken = getAccessToken();
|
|
79
|
-
const url = `https://${GCP_LOCATION}-aiplatform.googleapis.com/v1/projects/${GCP_PROJECT}/locations/${GCP_LOCATION}/publishers/google/models/${MODEL}:streamGenerateContent?alt=sse`;
|
|
80
|
-
const body = JSON.stringify({
|
|
81
|
-
system_instruction: { parts: [{ text: systemPrompt }] },
|
|
82
|
-
contents: messages,
|
|
83
|
-
generationConfig: {
|
|
84
|
-
temperature: 0.9,
|
|
85
|
-
topP: 0.95,
|
|
86
|
-
maxOutputTokens: 8192,
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return new Promise((resolve, reject) => {
|
|
90
|
-
const parsedUrl = new URL(url);
|
|
91
|
-
const req = https_1.default.request({
|
|
92
|
-
hostname: parsedUrl.hostname,
|
|
93
|
-
path: parsedUrl.pathname + parsedUrl.search,
|
|
94
|
-
method: 'POST',
|
|
95
|
-
headers: {
|
|
96
|
-
'Authorization': `Bearer ${accessToken}`,
|
|
97
|
-
'Content-Type': 'application/json',
|
|
98
|
-
}
|
|
99
|
-
}, (res) => {
|
|
100
|
-
let fullText = '';
|
|
101
|
-
let buffer = '';
|
|
102
|
-
res.on('data', (chunk) => {
|
|
103
|
-
buffer += chunk.toString();
|
|
104
|
-
const lines = buffer.split('\n');
|
|
105
|
-
buffer = lines.pop() || '';
|
|
106
|
-
for (const line of lines) {
|
|
107
|
-
if (line.startsWith('data: ')) {
|
|
108
|
-
try {
|
|
109
|
-
const json = JSON.parse(line.slice(6));
|
|
110
|
-
const text = json?.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
111
|
-
if (text) {
|
|
112
|
-
fullText += text;
|
|
113
|
-
onChunk(text);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch { /* skip non-JSON lines */ }
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
res.on('end', () => {
|
|
121
|
-
if (buffer.startsWith('data: ')) {
|
|
122
|
-
try {
|
|
123
|
-
const json = JSON.parse(buffer.slice(6));
|
|
124
|
-
const text = json?.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
125
|
-
if (text) {
|
|
126
|
-
fullText += text;
|
|
127
|
-
onChunk(text);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch { /* skip */ }
|
|
131
|
-
}
|
|
132
|
-
resolve(fullText);
|
|
133
|
-
});
|
|
134
|
-
res.on('error', reject);
|
|
135
|
-
});
|
|
136
|
-
req.on('error', reject);
|
|
137
|
-
req.write(body);
|
|
138
|
-
req.end();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Colorize bro names in output text
|
|
143
|
-
*/
|
|
144
|
-
function colorizeBros(text) {
|
|
145
|
-
return text
|
|
146
|
-
.replace(/Big Bro/g, chalk_1.default.hex('#FF6B00').bold('Big Bro'))
|
|
147
|
-
.replace(/Lil Bro/g, chalk_1.default.hex('#888888')('Lil Bro'))
|
|
148
|
-
.replace(/Nerd Bro/g, chalk_1.default.hex('#06b6d4')('Nerd Bro'))
|
|
149
|
-
.replace(/Chill Bro/g, chalk_1.default.hex('#22c55e')('Chill Bro'))
|
|
150
|
-
.replace(/Hype Bro/g, chalk_1.default.hex('#fbbf24')('Hype Bro'))
|
|
151
|
-
.replace(/Ajay Vai/g, chalk_1.default.magenta.bold('Ajay Vai'))
|
|
152
|
-
.replace(/Sunil Dai/g, chalk_1.default.blue.bold('Sunil Dai'))
|
|
153
|
-
.replace(/Sandip Dai/g, chalk_1.default.hex('#FF69B4').bold('Sandip Dai'))
|
|
154
|
-
.replace(/Narayan Dai/g, chalk_1.default.green.bold('Narayan Dai'))
|
|
155
|
-
.replace(/Bishal Dai/g, chalk_1.default.yellow.bold('Bishal Dai'));
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Draw the Big Bro header
|
|
159
|
-
*/
|
|
160
|
-
function drawBroHeader(mode) {
|
|
161
|
-
const w = Math.min(process.stdout.columns || 80, 60);
|
|
162
|
-
console.log();
|
|
163
|
-
console.log(chalk_1.default.hex('#FF6B00').bold(' ā' + 'ā'.repeat(w - 4) + 'ā'));
|
|
164
|
-
console.log(chalk_1.default.hex('#FF6B00').bold(' ā') + chalk_1.default.white.bold(' š„ BIG BRO ') + chalk_1.default.gray(`// ${mode} ⢠Vertex AI`) + ' '.repeat(Math.max(0, w - 38 - mode.length)) + chalk_1.default.hex('#FF6B00').bold('ā'));
|
|
165
|
-
console.log(chalk_1.default.hex('#FF6B00').bold(' ā' + 'ā'.repeat(w - 4) + 'ā'));
|
|
166
|
-
console.log();
|
|
167
|
-
}
|
|
168
|
-
// ============================================================
|
|
169
|
-
// MAIN COMMAND: matex bro
|
|
170
|
-
// ============================================================
|
|
171
|
-
const broSingleCommand = new commander_1.Command('bro')
|
|
172
|
-
.description('š„ Big Bro ā The Alpha Agent (Vertex AI powered)')
|
|
173
|
-
.argument('[question...]', 'Your question for Big Bro')
|
|
174
|
-
.option('-c, --chat', 'Start interactive chat mode with Big Bro')
|
|
175
|
-
.option('--execute', 'Enable command execution (agentic mode)')
|
|
176
|
-
.action(async (questionParts, options) => {
|
|
177
|
-
if (options.chat || !questionParts.length) {
|
|
178
|
-
await startBroChat(options.execute);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const question = questionParts.join(' ');
|
|
182
|
-
try {
|
|
183
|
-
drawBroHeader('Single Shot');
|
|
184
|
-
spinner_1.spinner.start('Big Bro is scanning the repo...');
|
|
185
|
-
const repoMapper = new repo_mapper_1.RepoMapper(process.cwd());
|
|
186
|
-
const repoMap = await repoMapper.generateMap();
|
|
187
|
-
const systemPrompt = buildBigBroPrompt(process.cwd(), repoMap);
|
|
188
|
-
const messages = [{ role: 'user', parts: [{ text: question }] }];
|
|
189
|
-
let hasStarted = false;
|
|
190
|
-
let fullResponse = '';
|
|
191
|
-
fullResponse = await callVertexAI(messages, systemPrompt, (chunk) => {
|
|
192
|
-
if (!hasStarted) {
|
|
193
|
-
spinner_1.spinner.stop();
|
|
194
|
-
hasStarted = true;
|
|
195
|
-
process.stdout.write(chalk_1.default.hex('#FF6B00').bold('\n [Big Bro]: '));
|
|
196
|
-
}
|
|
197
|
-
process.stdout.write(colorizeBros(chunk));
|
|
198
|
-
});
|
|
199
|
-
console.log('\n');
|
|
200
|
-
// If --execute, run any commands Big Bro generated
|
|
201
|
-
if (options.execute) {
|
|
202
|
-
const result = await (0, command_executor_1.executeWithPermission)(fullResponse, process.cwd());
|
|
203
|
-
if (result.executed) {
|
|
204
|
-
console.log(result.success
|
|
205
|
-
? chalk_1.default.green(' ā
Commands executed successfully.')
|
|
206
|
-
: chalk_1.default.red(` ā Execution error: ${result.error}`));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
console.log(chalk_1.default.gray(' āāā Powered by Vertex AI ⢠Gemini 2.5 Flash āāā\n'));
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
spinner_1.spinner.stop();
|
|
213
|
-
if (error.message.includes('gcloud')) {
|
|
214
|
-
console.error(chalk_1.default.red('\n ā GCP Auth Error. Run: gcloud auth login'));
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
console.error(chalk_1.default.red(`\n ā Error: ${error.message}`));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
exports.broCommand = broSingleCommand;
|
|
222
|
-
// ============================================================
|
|
223
|
-
// INTERACTIVE CHAT: matex bro --chat [--execute]
|
|
224
|
-
// ============================================================
|
|
225
|
-
async function startBroChat(executeMode = false) {
|
|
226
|
-
drawBroHeader(executeMode ? 'Agentic Chat' : 'Chat');
|
|
227
|
-
console.log(chalk_1.default.gray(' The Alpha is in the building. Ask anything.'));
|
|
228
|
-
console.log(chalk_1.default.gray(' Type "exit" to leave. Type "clear" to reset.\n'));
|
|
229
|
-
if (executeMode) {
|
|
230
|
-
console.log(chalk_1.default.hex('#FF6B00')(' ā” AGENTIC MODE: Big Bro can execute commands & edit files.\n'));
|
|
231
|
-
}
|
|
232
|
-
spinner_1.spinner.start('Big Bro is mapping the repo...');
|
|
233
|
-
const repoMapper = new repo_mapper_1.RepoMapper(process.cwd());
|
|
234
|
-
const repoMap = await repoMapper.generateMap();
|
|
235
|
-
let activeCwd = process.cwd();
|
|
236
|
-
const systemPrompt = buildBigBroPrompt(activeCwd, repoMap);
|
|
237
|
-
spinner_1.spinner.stop();
|
|
238
|
-
console.log(chalk_1.default.green(' ā
Repo mapped. Big Bro is ready.\n'));
|
|
239
|
-
const history = [];
|
|
240
|
-
while (true) {
|
|
241
|
-
const { userMessage } = await inquirer_1.default.prompt([{
|
|
242
|
-
type: 'input',
|
|
243
|
-
name: 'userMessage',
|
|
244
|
-
message: chalk_1.default.cyan.bold('You ā'),
|
|
245
|
-
prefix: ' ',
|
|
246
|
-
}]);
|
|
247
|
-
if (!userMessage.trim())
|
|
248
|
-
continue;
|
|
249
|
-
if (userMessage.toLowerCase() === 'exit' || userMessage.toLowerCase() === 'quit') {
|
|
250
|
-
console.log(chalk_1.default.hex('#FF6B00')('\n šŖ Big Bro out. Stay sigma.\n'));
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
if (userMessage.toLowerCase() === 'clear') {
|
|
254
|
-
history.length = 0;
|
|
255
|
-
console.log(chalk_1.default.yellow(' š§¹ Chat cleared.\n'));
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
history.push({ role: 'user', parts: [{ text: userMessage }] });
|
|
259
|
-
// Agentic loop: Big Bro can execute commands and iterate
|
|
260
|
-
let loopCount = 0;
|
|
261
|
-
while (loopCount < 5) {
|
|
262
|
-
loopCount++;
|
|
263
|
-
try {
|
|
264
|
-
spinner_1.spinner.start(loopCount > 1 ? 'Big Bro is analyzing results...' : 'Big Bro is thinking...');
|
|
265
|
-
let hasStarted = false;
|
|
266
|
-
let fullResponse = '';
|
|
267
|
-
fullResponse = await callVertexAI(history, systemPrompt, (chunk) => {
|
|
268
|
-
if (!hasStarted) {
|
|
269
|
-
spinner_1.spinner.stop();
|
|
270
|
-
hasStarted = true;
|
|
271
|
-
process.stdout.write(chalk_1.default.hex('#FF6B00').bold('\n [Big Bro]: '));
|
|
272
|
-
}
|
|
273
|
-
process.stdout.write(colorizeBros(chunk));
|
|
274
|
-
});
|
|
275
|
-
history.push({ role: 'model', parts: [{ text: fullResponse }] });
|
|
276
|
-
console.log('\n');
|
|
277
|
-
// If execute mode, run any commands Big Bro generated
|
|
278
|
-
if (executeMode) {
|
|
279
|
-
const result = await (0, command_executor_1.executeWithPermission)(fullResponse, activeCwd);
|
|
280
|
-
if (result.newCwd)
|
|
281
|
-
activeCwd = result.newCwd;
|
|
282
|
-
if (result.executed && result.success) {
|
|
283
|
-
// Feed the output back to Big Bro for further analysis
|
|
284
|
-
const feedback = `ā
Command executed successfully.${result.output ? `\nOutput:\n${result.output.slice(0, 2000)}` : ''}`;
|
|
285
|
-
history.push({ role: 'user', parts: [{ text: feedback }] });
|
|
286
|
-
continue; // Let Big Bro analyze the output
|
|
287
|
-
}
|
|
288
|
-
if (result.executed && !result.success) {
|
|
289
|
-
const feedback = `ā Command failed.\nError: ${result.error}`;
|
|
290
|
-
history.push({ role: 'user', parts: [{ text: feedback }] });
|
|
291
|
-
continue; // Let Big Bro try to fix it
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
break; // No commands to execute, exit loop
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
spinner_1.spinner.stop();
|
|
298
|
-
console.error(chalk_1.default.red(`\n ā Error: ${error.message}\n`));
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
//# sourceMappingURL=bro.js.map
|
package/dist/commands/chaos.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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.chaosCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
const client_1 = require("../api/client");
|
|
11
|
-
const agent_orchestrator_1 = require("../utils/agent-orchestrator");
|
|
12
|
-
const repo_mapper_1 = require("../utils/repo-mapper");
|
|
13
|
-
const tui_1 = require("../utils/tui");
|
|
14
|
-
const agent_session_1 = require("../session/agent-session");
|
|
15
|
-
const chaos_prompts_1 = require("../prompts/chaos-prompts");
|
|
16
|
-
exports.chaosCommand = new commander_1.Command('chaos')
|
|
17
|
-
.description('Start unhinged, narrative-driven CHAOS mode with Matex Chaos Engine')
|
|
18
|
-
.option('--no-execute', 'Disable auto-prompt for command execution')
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
try {
|
|
21
|
-
// Chaos mode requires an API key in the backend, but we still need the Matex one to connect
|
|
22
|
-
const apiKey = config_1.configManager.getAPIKey();
|
|
23
|
-
if (!apiKey) {
|
|
24
|
-
console.log(chalk_1.default.red('šŖļø CHAOS DENIED. You need a key.'));
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
|
|
28
|
-
tui_1.TUI.init();
|
|
29
|
-
agent_orchestrator_1.AgentOrchestrator.setMode('chaos');
|
|
30
|
-
tui_1.TUI.drawChaosOrchestratorUI();
|
|
31
|
-
const currentDir = process.cwd();
|
|
32
|
-
const repoMap = await new repo_mapper_1.RepoMapper(currentDir).generateMap();
|
|
33
|
-
tui_1.TUI.drawStatusBar('The swarm is awake and already fighting.');
|
|
34
|
-
tui_1.TUI.drawAjayDialogue('(Sigh) What do you want now? Make it quick.');
|
|
35
|
-
const initialMessages = [
|
|
36
|
-
{
|
|
37
|
-
role: 'system',
|
|
38
|
-
content: (0, chaos_prompts_1.getChaosSystemPrompt)(currentDir, repoMap)
|
|
39
|
-
}
|
|
40
|
-
];
|
|
41
|
-
const session = new agent_session_1.AgentSession({
|
|
42
|
-
client,
|
|
43
|
-
model: 'matex-chaos', // Force the chaos model override for Chaos Engine
|
|
44
|
-
execute: options.execute !== false,
|
|
45
|
-
initialMessages,
|
|
46
|
-
broBanter: chaos_prompts_1.BRO_BANTER_CHAOS,
|
|
47
|
-
sleepyAjayProtocol: 'chaos',
|
|
48
|
-
baseDir: currentDir
|
|
49
|
-
});
|
|
50
|
-
await session.start();
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
tui_1.TUI.exit();
|
|
54
|
-
console.error(chalk_1.default.red(`\nā Chaos Error: ${error.message}`));
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=chaos.js.map
|
package/dist/commands/chat.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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.chatCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
const client_1 = require("../api/client");
|
|
11
|
-
const agent_orchestrator_1 = require("../utils/agent-orchestrator");
|
|
12
|
-
const repo_mapper_1 = require("../utils/repo-mapper");
|
|
13
|
-
const tui_1 = require("../utils/tui");
|
|
14
|
-
const agent_session_1 = require("../session/agent-session");
|
|
15
|
-
const banter_1 = require("../prompts/banter");
|
|
16
|
-
const system_prompts_1 = require("../prompts/system-prompts");
|
|
17
|
-
exports.chatCommand = new commander_1.Command('chat')
|
|
18
|
-
.description('Start an interactive chat session with the MATEX Bro-Swarm')
|
|
19
|
-
.option('-m, --model <model>', 'AI model to use (matex-free, matexai, matexcodex, matexelite)', config_1.configManager.getDefaultModel())
|
|
20
|
-
.option('--execute', 'Enable command execution in chat')
|
|
21
|
-
.action(async (options) => {
|
|
22
|
-
try {
|
|
23
|
-
const apiKey = config_1.configManager.getAPIKey();
|
|
24
|
-
if (!apiKey) {
|
|
25
|
-
console.error(chalk_1.default.red('ā No API key configured. Run: matex config set-key <key>'));
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
|
|
29
|
-
tui_1.TUI.init();
|
|
30
|
-
agent_orchestrator_1.AgentOrchestrator.setMode('chat');
|
|
31
|
-
tui_1.TUI.drawStatusBar('Brothers are ready to chat.');
|
|
32
|
-
const extraPrompt = options.model === 'matex-free' ? agent_orchestrator_1.AgentOrchestrator.getFreeTierPrompt() : '';
|
|
33
|
-
const currentSessionCwd = process.cwd();
|
|
34
|
-
const repoMap = await new repo_mapper_1.RepoMapper(currentSessionCwd).generateMap();
|
|
35
|
-
const initialMessages = [
|
|
36
|
-
{
|
|
37
|
-
role: 'system',
|
|
38
|
-
content: (0, system_prompts_1.getChatSystemPrompt)(currentSessionCwd, repoMap, extraPrompt)
|
|
39
|
-
}
|
|
40
|
-
];
|
|
41
|
-
console.log(chalk_1.default.green('MATEX Brothers are Online.'));
|
|
42
|
-
console.log(chalk_1.default.green('Speak your mind brother, the swarm is listening...'));
|
|
43
|
-
const session = new agent_session_1.AgentSession({
|
|
44
|
-
client,
|
|
45
|
-
model: options.model,
|
|
46
|
-
execute: options.execute || false,
|
|
47
|
-
initialMessages,
|
|
48
|
-
broBanter: banter_1.BRO_BANTER_CHAT,
|
|
49
|
-
sleepyAjayProtocol: options.model !== 'matex-free' ? 'dev' : undefined,
|
|
50
|
-
baseDir: currentSessionCwd
|
|
51
|
-
});
|
|
52
|
-
await session.start();
|
|
53
|
-
}
|
|
54
|
-
catch (outerError) {
|
|
55
|
-
console.error(chalk_1.default.red(`\nā Session error: ${outerError.message}`));
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=chat.js.map
|
package/dist/commands/code.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
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.codeCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
const client_1 = require("../api/client");
|
|
11
|
-
const spinner_1 = require("../utils/spinner");
|
|
12
|
-
const command_executor_1 = require("../utils/command-executor");
|
|
13
|
-
exports.codeCommand = new commander_1.Command('code')
|
|
14
|
-
.description('Generate code with MATEXCodex (optimized for coding)')
|
|
15
|
-
.argument('<prompt>', 'What code do you need?')
|
|
16
|
-
.option('-o, --output <file>', 'Save output to file')
|
|
17
|
-
.option('-l, --language <lang>', 'Programming language (auto-detected if not specified)')
|
|
18
|
-
.option('-t, --temperature <number>', 'Temperature (0-1)', '0.3')
|
|
19
|
-
.option('--max-tokens <number>', 'Maximum tokens in response', '8000')
|
|
20
|
-
.option('-x, --execute', 'Execute commands found in response (with permission prompts)')
|
|
21
|
-
.action(async (prompt, options) => {
|
|
22
|
-
try {
|
|
23
|
-
// Check for API key
|
|
24
|
-
const apiKey = config_1.configManager.getAPIKey();
|
|
25
|
-
if (!apiKey) {
|
|
26
|
-
console.error(chalk_1.default.red('ā No API key configured.'));
|
|
27
|
-
console.log(chalk_1.default.yellow('Run: matex config set-key <your-api-key>'));
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
// Create API client
|
|
31
|
-
const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
|
|
32
|
-
// Enhance prompt for code generation
|
|
33
|
-
let enhancedPrompt = prompt;
|
|
34
|
-
if (options.language) {
|
|
35
|
-
enhancedPrompt = `Generate ${options.language} code: ${prompt}`;
|
|
36
|
-
}
|
|
37
|
-
// Show thinking indicator
|
|
38
|
-
spinner_1.spinner.start('Generating code with MATEXCodex...');
|
|
39
|
-
// Send request (always use matexcodex for code command)
|
|
40
|
-
const response = await client.chat({
|
|
41
|
-
messages: [
|
|
42
|
-
{ role: 'system', content: 'You are MATEXCodex, an expert coding assistant. Generate clean, production-ready code with comments and best practices. Always include complete, working code.' },
|
|
43
|
-
{ role: 'user', content: enhancedPrompt }
|
|
44
|
-
],
|
|
45
|
-
model: 'matexcodex',
|
|
46
|
-
temperature: parseFloat(options.temperature),
|
|
47
|
-
max_tokens: parseInt(options.maxTokens),
|
|
48
|
-
stream: false,
|
|
49
|
-
});
|
|
50
|
-
spinner_1.spinner.succeed('Code generated!');
|
|
51
|
-
// Display response
|
|
52
|
-
console.log(chalk_1.default.cyan('\nš» MATEXCodex:\n'));
|
|
53
|
-
console.log(chalk_1.default.white(response));
|
|
54
|
-
console.log();
|
|
55
|
-
// Save to file if requested
|
|
56
|
-
if (options.output) {
|
|
57
|
-
const fs = require('fs');
|
|
58
|
-
const path = require('path');
|
|
59
|
-
// Ensure directory exists
|
|
60
|
-
const dir = path.dirname(options.output);
|
|
61
|
-
if (!fs.existsSync(dir) && dir !== '.') {
|
|
62
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
// Extract code from response (remove markdown if present)
|
|
65
|
-
let codeContent = response;
|
|
66
|
-
const codeBlockMatch = response.match(/```[\w]*\n([\s\S]*?)```/);
|
|
67
|
-
if (codeBlockMatch) {
|
|
68
|
-
codeContent = codeBlockMatch[1];
|
|
69
|
-
}
|
|
70
|
-
fs.writeFileSync(options.output, codeContent.trim());
|
|
71
|
-
console.log(chalk_1.default.green(`ā
Code saved to: ${options.output}`));
|
|
72
|
-
}
|
|
73
|
-
// Execute commands if requested
|
|
74
|
-
if (options.execute) {
|
|
75
|
-
await (0, command_executor_1.executeWithPermission)(response);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
spinner_1.spinner.fail('Code generation failed');
|
|
80
|
-
if (error.message.includes('403')) {
|
|
81
|
-
console.error(chalk_1.default.red('\nā Invalid or revoked API key.'));
|
|
82
|
-
console.log(chalk_1.default.yellow('Please check your API key or generate a new one from the MATEX AI platform.'));
|
|
83
|
-
}
|
|
84
|
-
else if (error.message.includes('429')) {
|
|
85
|
-
console.error(chalk_1.default.red('\nā Rate limit exceeded.'));
|
|
86
|
-
console.log(chalk_1.default.yellow('Please wait a moment before trying again.'));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
console.error(chalk_1.default.red(`\nā Error: ${error.message}`));
|
|
90
|
-
}
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
//# sourceMappingURL=code.js.map
|
package/dist/commands/config.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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.configCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
exports.configCommand = new commander_1.Command('config')
|
|
11
|
-
.description('Manage MATEX CLI configuration');
|
|
12
|
-
// Set API key
|
|
13
|
-
exports.configCommand
|
|
14
|
-
.command('set-key <apiKey>')
|
|
15
|
-
.description('Set your MATEX AI API key')
|
|
16
|
-
.action((apiKey) => {
|
|
17
|
-
try {
|
|
18
|
-
// Validate API key format
|
|
19
|
-
if (!apiKey.startsWith('sk-matex-')) {
|
|
20
|
-
console.error(chalk_1.default.red('ā Invalid API key format. API keys should start with "sk-matex-"'));
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
config_1.configManager.setAPIKey(apiKey);
|
|
24
|
-
console.log(chalk_1.default.green('ā
API key saved successfully!'));
|
|
25
|
-
console.log(chalk_1.default.gray('Your API key is stored securely in ~/.matex/config.json'));
|
|
26
|
-
console.log(chalk_1.default.cyan('\nš” Try it out: matex ask "What is 2+2?"'));
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(chalk_1.default.red(`ā Failed to save API key: ${error.message}`));
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
// Show configuration
|
|
34
|
-
exports.configCommand
|
|
35
|
-
.command('show')
|
|
36
|
-
.description('Show current configuration')
|
|
37
|
-
.action(() => {
|
|
38
|
-
const config = config_1.configManager.getAll();
|
|
39
|
-
console.log(chalk_1.default.bold.cyan('\nš MATEX CLI Configuration\n'));
|
|
40
|
-
if (config.apiKey) {
|
|
41
|
-
const maskedKey = config.apiKey.substring(0, 12) + '...' + config.apiKey.substring(config.apiKey.length - 4);
|
|
42
|
-
console.log(chalk_1.default.white('API Key: ') + chalk_1.default.gray(maskedKey));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
console.log(chalk_1.default.white('API Key: ') + chalk_1.default.red('Not set'));
|
|
46
|
-
}
|
|
47
|
-
console.log(chalk_1.default.white('Default Model: ') + chalk_1.default.cyan(config.defaultModel || 'matexcodex'));
|
|
48
|
-
console.log(chalk_1.default.white('Base URL: ') + chalk_1.default.gray(config.baseURL || 'https://matexai-backend-550499663766.us-central1.run.app'));
|
|
49
|
-
if (!config.apiKey) {
|
|
50
|
-
console.log(chalk_1.default.yellow('\nā ļø No API key configured. Use "matex config set-key <your-api-key>" to get started.'));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
// Clear configuration
|
|
54
|
-
exports.configCommand
|
|
55
|
-
.command('clear')
|
|
56
|
-
.description('Clear all configuration')
|
|
57
|
-
.action(() => {
|
|
58
|
-
config_1.configManager.clear();
|
|
59
|
-
console.log(chalk_1.default.green('ā
Configuration cleared successfully!'));
|
|
60
|
-
});
|
|
61
|
-
// Set default model
|
|
62
|
-
exports.configCommand
|
|
63
|
-
.command('set-model <model>')
|
|
64
|
-
.description('Set default AI model')
|
|
65
|
-
.action((model) => {
|
|
66
|
-
const validModels = ['matexcore', 'matexcodex', 'matexai', 'elite', 'matexspirit'];
|
|
67
|
-
if (!validModels.includes(model.toLowerCase())) {
|
|
68
|
-
console.error(chalk_1.default.red(`ā Invalid model. Choose from: ${validModels.join(', ')}`));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
config_1.configManager.setDefaultModel(model.toLowerCase());
|
|
72
|
-
console.log(chalk_1.default.green(`ā
Default model set to: ${model}`));
|
|
73
|
-
});
|
|
74
|
-
//# sourceMappingURL=config.js.map
|
package/dist/commands/dev.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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.devCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = require("../utils/config");
|
|
10
|
-
const client_1 = require("../api/client");
|
|
11
|
-
const agent_orchestrator_1 = require("../utils/agent-orchestrator");
|
|
12
|
-
const repo_mapper_1 = require("../utils/repo-mapper");
|
|
13
|
-
const tui_1 = require("../utils/tui");
|
|
14
|
-
const agent_session_1 = require("../session/agent-session");
|
|
15
|
-
const banter_1 = require("../prompts/banter");
|
|
16
|
-
const system_prompts_1 = require("../prompts/system-prompts");
|
|
17
|
-
exports.devCommand = new commander_1.Command('dev')
|
|
18
|
-
.description('Start interactive development session with MATEXCodex')
|
|
19
|
-
.option('-m, --model <model>', 'AI model to use (matex-free, matexai, matexcodex, matexelite)', config_1.configManager.getDefaultModel())
|
|
20
|
-
.option('--no-execute', 'Disable auto-prompt for command execution')
|
|
21
|
-
.action(async (options) => {
|
|
22
|
-
try {
|
|
23
|
-
const apiKey = config_1.configManager.getAPIKey();
|
|
24
|
-
if (!apiKey) {
|
|
25
|
-
console.log(chalk_1.default.hex('#0EA5E9')('ā MATEX COMMAND CENTER ONLINE.'));
|
|
26
|
-
console.log(chalk_1.default.gray('OPERATOR AUTHENTICATED. STANDING BY.'));
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
|
|
30
|
-
const extraPrompt = options.model === 'matex-free' ? agent_orchestrator_1.AgentOrchestrator.getFreeTierPrompt() : '';
|
|
31
|
-
tui_1.TUI.init();
|
|
32
|
-
agent_orchestrator_1.AgentOrchestrator.setMode('dev');
|
|
33
|
-
tui_1.TUI.drawDevOrchestratorUI(options.model);
|
|
34
|
-
if (options.model === 'matex-free') {
|
|
35
|
-
console.log(chalk_1.default.bold.hex('#00FF7F')(' š MATEX STUDENT EDITION - Zero Bill Protocol\n'));
|
|
36
|
-
}
|
|
37
|
-
tui_1.TUI.drawStatusBar('Initializing MATEX "Bro-Swarm"...');
|
|
38
|
-
agent_orchestrator_1.AgentOrchestrator.announce('Analyzing Repository Structure...');
|
|
39
|
-
const currentDir = process.cwd();
|
|
40
|
-
const repoMap = await new repo_mapper_1.RepoMapper(currentDir).generateMap();
|
|
41
|
-
tui_1.TUI.drawStatusBar('Brothers are ready to build.');
|
|
42
|
-
tui_1.TUI.drawAjayDialogue('Awaiting your command, brother.');
|
|
43
|
-
const initialMessages = [
|
|
44
|
-
{
|
|
45
|
-
role: 'system',
|
|
46
|
-
content: (0, system_prompts_1.getDevSystemPrompt)(currentDir, repoMap, extraPrompt)
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
const session = new agent_session_1.AgentSession({
|
|
50
|
-
client,
|
|
51
|
-
model: options.model,
|
|
52
|
-
execute: options.execute !== false,
|
|
53
|
-
initialMessages,
|
|
54
|
-
broBanter: banter_1.BRO_BANTER_DEV,
|
|
55
|
-
sleepyAjayProtocol: options.model !== 'matex-free' ? 'dev' : undefined,
|
|
56
|
-
baseDir: currentDir
|
|
57
|
-
});
|
|
58
|
-
await session.start();
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
tui_1.TUI.exit();
|
|
62
|
-
console.error(chalk_1.default.red(`\nā Fatal Error: ${error.message}`));
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=dev.js.map
|