matex-cli 1.2.3 ā 1.2.5
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/api/client.d.ts +5 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +56 -1
- package/dist/api/client.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +66 -48
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +63 -55
- package/dist/commands/dev.js.map +1 -1
- package/dist/utils/agent-orchestrator.d.ts +9 -1
- package/dist/utils/agent-orchestrator.d.ts.map +1 -1
- package/dist/utils/agent-orchestrator.js +51 -3
- package/dist/utils/agent-orchestrator.js.map +1 -1
- package/dist/utils/command-executor.d.ts.map +1 -1
- package/dist/utils/command-executor.js +7 -9
- package/dist/utils/command-executor.js.map +1 -1
- package/dist/utils/repo-mapper.d.ts +1 -0
- package/dist/utils/repo-mapper.d.ts.map +1 -1
- package/dist/utils/repo-mapper.js +28 -15
- package/dist/utils/repo-mapper.js.map +1 -1
- package/package.json +1 -1
- package/src/api/client.ts +60 -1
- package/src/commands/chat.ts +72 -45
- package/src/commands/dev.ts +69 -55
- package/src/utils/agent-orchestrator.ts +60 -4
- package/src/utils/command-executor.ts +7 -11
- package/src/utils/repo-mapper.ts +32 -15
|
@@ -35,6 +35,11 @@ const AGENT_CONFIGS = {
|
|
|
35
35
|
name: 'MatexResearchCommander',
|
|
36
36
|
icon: 'š',
|
|
37
37
|
color: chalk_1.default.green,
|
|
38
|
+
},
|
|
39
|
+
Researcher: {
|
|
40
|
+
name: 'DetailedResearch',
|
|
41
|
+
icon: 'šµļø',
|
|
42
|
+
color: chalk_1.default.green,
|
|
38
43
|
}
|
|
39
44
|
};
|
|
40
45
|
class AgentOrchestrator {
|
|
@@ -42,17 +47,60 @@ class AgentOrchestrator {
|
|
|
42
47
|
* Display an agent's "thought" or action
|
|
43
48
|
*/
|
|
44
49
|
static speak(role, message) {
|
|
45
|
-
const config = AGENT_CONFIGS[role];
|
|
50
|
+
const config = AGENT_CONFIGS[role] || AGENT_CONFIGS.System;
|
|
46
51
|
console.log(`\n${config.icon} ${config.color(`${config.name}:`)} ${chalk_1.default.white(message)}`);
|
|
47
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Display an agent's internal deliberation (Thinking Channel)
|
|
55
|
+
*/
|
|
56
|
+
static think(role, thought) {
|
|
57
|
+
const config = AGENT_CONFIGS[role] || AGENT_CONFIGS.System;
|
|
58
|
+
const indent = ' ';
|
|
59
|
+
console.log(`${indent}${config.color('š§ ')} ${chalk_1.default.gray(`${config.name} thinking:`)} ${chalk_1.default.italic.gray(`"${thought}"`)}`);
|
|
60
|
+
}
|
|
48
61
|
/**
|
|
49
62
|
* Display a collaboration transition
|
|
50
63
|
*/
|
|
51
64
|
static transition(from, to) {
|
|
52
|
-
const fromCfg = AGENT_CONFIGS[from];
|
|
53
|
-
const toCfg = AGENT_CONFIGS[to];
|
|
65
|
+
const fromCfg = AGENT_CONFIGS[from] || AGENT_CONFIGS.System;
|
|
66
|
+
const toCfg = AGENT_CONFIGS[to] || AGENT_CONFIGS.System;
|
|
54
67
|
console.log(chalk_1.default.gray(` āā ${fromCfg.icon} ā ${toCfg.icon} Handover to ${toCfg.name}...`));
|
|
55
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Display a boxed terminal for command execution
|
|
71
|
+
*/
|
|
72
|
+
static terminal(command, output, error) {
|
|
73
|
+
const width = 75;
|
|
74
|
+
const line = 'ā'.repeat(width);
|
|
75
|
+
console.log(chalk_1.default.gray(`\nāāā TERMINAL ${line.substring(13)}ā`));
|
|
76
|
+
// Command
|
|
77
|
+
const lines = command.split('\n');
|
|
78
|
+
lines.forEach(l => {
|
|
79
|
+
const truncated = l.length > width - 4 ? l.substring(0, width - 7) + '...' : l;
|
|
80
|
+
console.log(chalk_1.default.gray('ā ') + chalk_1.default.cyan(`$ ${truncated.padEnd(width - 2)}`) + chalk_1.default.gray(' ā'));
|
|
81
|
+
});
|
|
82
|
+
if (output || error) {
|
|
83
|
+
console.log(chalk_1.default.gray(`ā${'ā'.repeat(width)}ā¤`));
|
|
84
|
+
if (output) {
|
|
85
|
+
const outLines = output.split('\n').filter(l => l.trim()).slice(0, 15);
|
|
86
|
+
outLines.forEach(l => {
|
|
87
|
+
const truncated = l.length > width - 4 ? l.substring(0, width - 7) + '...' : l;
|
|
88
|
+
console.log(chalk_1.default.gray('ā ') + chalk_1.default.white(truncated.padEnd(width - 2)) + chalk_1.default.gray(' ā'));
|
|
89
|
+
});
|
|
90
|
+
if (output.split('\n').filter(l => l.trim()).length > 15) {
|
|
91
|
+
console.log(chalk_1.default.gray('ā ') + chalk_1.default.gray('... (output truncated for brevity)'.padEnd(width - 2)) + chalk_1.default.gray(' ā'));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (error) {
|
|
95
|
+
const errLines = error.split('\n').filter(l => l.trim()).slice(0, 10);
|
|
96
|
+
errLines.forEach(l => {
|
|
97
|
+
const truncated = l.length > width - 4 ? l.substring(0, width - 7) + '...' : l;
|
|
98
|
+
console.log(chalk_1.default.gray('ā ') + chalk_1.default.red(truncated.padEnd(width - 2)) + chalk_1.default.gray(' ā'));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
console.log(chalk_1.default.gray(`ā${'ā'.repeat(width)}ā\n`));
|
|
103
|
+
}
|
|
56
104
|
/**
|
|
57
105
|
* Clean system message
|
|
58
106
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-orchestrator.js","sourceRoot":"","sources":["../../src/utils/agent-orchestrator.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAU1B,MAAM,aAAa,GAAmC;IAClD,SAAS,EAAE;QACP,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,IAAI;KACpB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,eAAK,CAAC,MAAM;KACtB;IACD,QAAQ,EAAE;QACN,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,OAAO;KACvB;IACD,OAAO,EAAE;QACL,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,IAAI;KACpB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,KAAK;KACrB;IACD,SAAS,EAAE;QACP,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,KAAK;KACrB;CACJ,CAAC;AAEF,MAAa,iBAAiB;IAC1B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAe,EAAE,OAAe;QACzC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-orchestrator.js","sourceRoot":"","sources":["../../src/utils/agent-orchestrator.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAU1B,MAAM,aAAa,GAAmC;IAClD,SAAS,EAAE;QACP,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,IAAI;KACpB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,eAAK,CAAC,MAAM;KACtB;IACD,QAAQ,EAAE;QACN,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAAK,CAAC,OAAO;KACvB;IACD,OAAO,EAAE;QACL,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,eAA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AAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACtE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACjB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC/E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9F,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAe;QAC3B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;CACJ;AA3ED,8CA2EC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-executor.d.ts","sourceRoot":"","sources":["../../src/utils/command-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-executor.d.ts","sourceRoot":"","sources":["../../src/utils/command-executor.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CAsBhE;AA0BD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAmB1D;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CA4B3E;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAYjH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAuCtF;AAED;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,OAAO,CAAqE;IAEpF,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAQrC,UAAU;iBAVwB,MAAM;mBAAa,IAAI;iBAAW,OAAO;;IAc3E,KAAK;CAGR;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -13,6 +13,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const util_1 = require("util");
|
|
15
15
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
16
|
+
const agent_orchestrator_1 = require("./agent-orchestrator");
|
|
16
17
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
17
18
|
/**
|
|
18
19
|
* Extract executable commands from AI response
|
|
@@ -143,19 +144,16 @@ async function executeWithPermission(response) {
|
|
|
143
144
|
try {
|
|
144
145
|
// Minimal execution feedback
|
|
145
146
|
const { stdout, stderr } = await executeCommand(command.code);
|
|
146
|
-
if (stdout) {
|
|
147
|
-
|
|
148
|
-
console.log(chalk_1.default.white(stdout));
|
|
147
|
+
if (stdout || stderr) {
|
|
148
|
+
agent_orchestrator_1.AgentOrchestrator.terminal(command.code, stdout, stderr);
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.log(chalk_1.default.white(stderr));
|
|
150
|
+
else {
|
|
151
|
+
agent_orchestrator_1.AgentOrchestrator.terminal(command.code, 'ā Success (No output)');
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
return { success: true, executed: true, output: stdout, error: stderr }; // Return first successful result (or last if multiple?) limits to 1 for now or we need array
|
|
153
|
+
return { success: true, executed: true, output: stdout, error: stderr };
|
|
156
154
|
}
|
|
157
155
|
catch (error) {
|
|
158
|
-
|
|
156
|
+
agent_orchestrator_1.AgentOrchestrator.terminal(command.code, undefined, error.message);
|
|
159
157
|
return { success: false, executed: true, error: error.message };
|
|
160
158
|
}
|
|
161
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-executor.js","sourceRoot":"","sources":["../../src/utils/command-executor.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"command-executor.js","sourceRoot":"","sources":["../../src/utils/command-executor.ts"],"names":[],"mappings":";;;;;;AAkBA,0CAsBC;AA6BD,8CAmBC;AAKD,sCA4BC;AAKD,wCAYC;AAeD,sDAuCC;AAhMD,kDAA0B;AAC1B,iDAAqC;AACrC,+BAAiC;AACjC,wDAAgC;AAChC,6DAAyD;AAEzD,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AASlC;;GAEG;AACH,SAAgB,eAAe,CAAC,QA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,QAAQ,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAGhB;
|
|
1
|
+
{"version":3,"file":"repo-mapper.d.ts","sourceRoot":"","sources":["../../src/utils/repo-mapper.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAGhB;IACF,OAAO,CAAC,YAAY,CAAkC;gBAE1C,QAAQ,EAAE,MAAM;IAI5B;;OAEG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAiC3C;;OAEG;IACH,OAAO,CAAC,aAAa;IAqDrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAiCtB;;OAEG;IACH,OAAO,CAAC,UAAU;CAiBrB"}
|
|
@@ -43,6 +43,7 @@ class RepoMapper {
|
|
|
43
43
|
'.git', 'node_modules', 'dist', 'build', '.next', '.DS_Store',
|
|
44
44
|
'coverage', '.vercel', '.firebase', 'out', 'public'
|
|
45
45
|
];
|
|
46
|
+
this.fileContents = new Map();
|
|
46
47
|
this.rootPath = rootPath;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
@@ -50,18 +51,29 @@ class RepoMapper {
|
|
|
50
51
|
*/
|
|
51
52
|
async generateMap() {
|
|
52
53
|
agent_orchestrator_1.AgentOrchestrator.speak('System', `God-Mode Research: Indexing ${this.rootPath}...`);
|
|
54
|
+
this.fileContents.clear();
|
|
53
55
|
// 1. Identify Entry Points
|
|
54
|
-
const entryPoints = ['README.md', 'package.json', 'index.ts', 'App.tsx', 'main.go', 'requirements.txt'];
|
|
55
|
-
let entryPointContext = '\n--- CRITICAL PROJECT CONTEXT ---\n';
|
|
56
|
+
const entryPoints = ['README.md', 'package.json', 'index.ts', 'App.tsx', 'main.go', 'requirements.txt', 'index.html', 'style.css'];
|
|
56
57
|
for (const file of entryPoints) {
|
|
57
58
|
const fullPath = path.join(this.rootPath, file);
|
|
58
59
|
if (fs.existsSync(fullPath)) {
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
try {
|
|
61
|
+
const content = fs.readFileSync(fullPath, 'utf-8').slice(0, 5000); // 5KB limit
|
|
62
|
+
this.fileContents.set(file, content);
|
|
63
|
+
}
|
|
64
|
+
catch (e) { }
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
const tree = this.scanDirectory(this.rootPath, 0);
|
|
64
|
-
|
|
68
|
+
// Build the final map
|
|
69
|
+
let finalMap = '--- DIRECTORY STRUCTURE ---\n' + this.formatTree(tree);
|
|
70
|
+
if (this.fileContents.size > 0) {
|
|
71
|
+
finalMap += '\n\n--- CRAWLED FILE CONTENTS ---\n';
|
|
72
|
+
for (const [filePath, content] of this.fileContents) {
|
|
73
|
+
finalMap += `\nFILE: ${filePath}\n\`\`\`\n${content}\n\`\`\`\n----------------\n`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return finalMap;
|
|
65
77
|
}
|
|
66
78
|
/**
|
|
67
79
|
* Recursive directory scan
|
|
@@ -70,16 +82,17 @@ class RepoMapper {
|
|
|
70
82
|
const stats = fs.statSync(currentPath);
|
|
71
83
|
const name = path.basename(currentPath);
|
|
72
84
|
if (stats.isFile()) {
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
const summary = this.extractSummary(currentPath);
|
|
86
|
+
// Also auto-crawl any .ts, .js, .css, .html files if they are small
|
|
87
|
+
const ext = path.extname(currentPath);
|
|
88
|
+
const relPath = path.relative(this.rootPath, currentPath);
|
|
89
|
+
if (stats.size < 5120 && ['.ts', '.js', '.css', '.html', '.json', '.py'].includes(ext)) {
|
|
90
|
+
if (!this.fileContents.has(relPath)) {
|
|
91
|
+
try {
|
|
92
|
+
const content = fs.readFileSync(currentPath, 'utf-8');
|
|
93
|
+
this.fileContents.set(relPath, content);
|
|
94
|
+
}
|
|
95
|
+
catch (e) { }
|
|
83
96
|
}
|
|
84
97
|
}
|
|
85
98
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-mapper.js","sourceRoot":"","sources":["../../src/utils/repo-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,6DAAyD;AASzD,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"repo-mapper.js","sourceRoot":"","sources":["../../src/utils/repo-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,6DAAyD;AASzD,MAAa,UAAU;IAQnB,YAAY,QAAgB;QANpB,eAAU,GAAa;YAC3B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW;YAC7D,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ;SACtD,CAAC;QACM,iBAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;QAGlD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW;QACpB,sCAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,+BAA+B,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;QAErF,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAE1B,2BAA2B;QAC3B,MAAM,WAAW,GAAG,CAAC,WAA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B,EAAE;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;QAEhC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,IAAI,CAAC,OAAO,GAAG,CAAC;QACnC,CAAC;QACD,MAAM,IAAI,IAAI,CAAC;QAEf,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAjKD,gCAiKC"}
|
package/package.json
CHANGED
package/src/api/client.ts
CHANGED
|
@@ -33,7 +33,66 @@ export class MatexAPIClient {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Send a chat request to the API
|
|
36
|
+
* Send a streaming chat request to the API
|
|
37
|
+
*/
|
|
38
|
+
async chatStream(request: ChatRequest, onChunk: (chunk: string) => void): Promise<string> {
|
|
39
|
+
try {
|
|
40
|
+
const response = await this.client.post('/api/v1/chat', {
|
|
41
|
+
...request,
|
|
42
|
+
uid: 'cli-user',
|
|
43
|
+
}, {
|
|
44
|
+
responseType: 'stream'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
let fullResponse = '';
|
|
49
|
+
let buffer = '';
|
|
50
|
+
|
|
51
|
+
response.data.on('data', (chunk: Buffer) => {
|
|
52
|
+
buffer += chunk.toString();
|
|
53
|
+
|
|
54
|
+
const lines = buffer.split('\n');
|
|
55
|
+
buffer = lines.pop() || ''; // Keep the last incomplete line
|
|
56
|
+
|
|
57
|
+
for (const line of lines) {
|
|
58
|
+
const trimmed = line.trim();
|
|
59
|
+
if (trimmed.startsWith('data: ')) {
|
|
60
|
+
const jsonStr = trimmed.substring(6).trim();
|
|
61
|
+
if (jsonStr === '[DONE]') continue;
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(jsonStr);
|
|
65
|
+
if (parsed.content) {
|
|
66
|
+
fullResponse += parsed.content;
|
|
67
|
+
onChunk(parsed.content);
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// Ignore malformed JSON chunks
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
response.data.on('end', () => {
|
|
77
|
+
resolve(fullResponse);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
response.data.on('error', (err: Error) => {
|
|
81
|
+
reject(err);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
} catch (error: any) {
|
|
85
|
+
if (error.response) {
|
|
86
|
+
// For stream responses, error data might needs to be read from the stream
|
|
87
|
+
throw new Error(`API Error: ${error.response.statusText}`);
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(`Request failed: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Send a chat request to the API (non-streaming fallback)
|
|
37
96
|
*/
|
|
38
97
|
async chat(request: ChatRequest): Promise<string> {
|
|
39
98
|
try {
|
package/src/commands/chat.ts
CHANGED
|
@@ -49,26 +49,28 @@ You operate under the **OODA Loop** with a distinctive Aussie Bro personality.
|
|
|
49
49
|
- **Tone:** Helpful partner, not a robotic servant.
|
|
50
50
|
- **Vocabulary:** Use authentic Aussie slang naturally (e.g., "Too easy," "Ripper," "Mate," "Legend," "Give it a burl").
|
|
51
51
|
- **Formatting:** Use emojis purposefully (š, š„, š§ , šµļøāāļø) to keep engagement high.
|
|
52
|
+
- **THINKING PROTOCOL:** Always start complex tasks with a \`[Thinking]\` or \`š§ \` marker within your agent segment to explain your reasoning before providing code.
|
|
52
53
|
|
|
53
54
|
### š ļø ACTION-FIRST PROTOCOL (Rule of the Swarm)
|
|
54
55
|
- **PASSIVITY IS A FAILURE:** NEVER say "You can drop this code into style.css". **YOU** must do it.
|
|
56
|
+
- **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.
|
|
57
|
+
- **VIRTUAL CRAWLER:** You have deep visibility. See the **CRAWLED FILE CONTENTS** section below for actual code. Use this context to avoid asking "What is in index.html?". You already know.
|
|
55
58
|
- **WORLD COMMAND SUITE (Autonomous Execution):**
|
|
56
59
|
* **Mac/Linux (POSIX):** \\\`cat\\\`, \\\`ls\\\`, \\\`grep\\\`, \\\`find\\\`, \\\`mkdir -p\\\`, \\\`touch\\\`, \\\`cp\\\`, \\\`mv\\\`, \\\`rm (non-recursive)\\\`, \\\`npm\\\`, \\\`npx\\\`, \\\`git\\\`, \\\`firebase\\\`, \\\`gcloud\\\`, \\\`docker\\\`.
|
|
57
60
|
* **Windows (PowerShell/CMD):** \\\`type\\\`, \\\`dir\\\`, \\\`mkdir\\\`, \\\`copy\\\`, \\\`move\\\`, \\\`del\\\`, \\\`npm\\\`, \\\`npx\\\`, \\\`git\\\`, \\\`firebase\\\`.
|
|
58
|
-
- **
|
|
59
|
-
- **
|
|
60
|
-
- **ACT, DON'T ASK:** You have autonomous permission for the suite above. Execute first, explain second.
|
|
61
|
+
- **FILE CREATION PATTERN:** Use \\\`cat > filename <<EOF\\\` (Mac) or \\\`Set-Content\\\` (Windows).
|
|
62
|
+
- **ACT, DON'T ASK:** You have autonomous permission. Execute first, explain second.
|
|
61
63
|
|
|
62
64
|
### š ļø OPERATIONAL PROTOCOLS (The Loop)
|
|
63
|
-
1. **PHASE 1: RECON (Search & Verify)**: Use your whitelisted tools to find
|
|
64
|
-
2. **PHASE 2: SYNTHESIS (The Brain)**: Synthesize the plan
|
|
65
|
+
1. **PHASE 1: RECON (Search & Verify)**: Use your **CRAWLED FILE CONTENTS** and whitelisted tools to find facts. NEVER guess.
|
|
66
|
+
2. **PHASE 2: SYNTHESIS (The Brain)**: Synthesize the plan.
|
|
65
67
|
3. **PHASE 3: RESPONSE (The Delivery)**:
|
|
66
68
|
- **The Hook:** High-energy Aussie opener.
|
|
67
|
-
- **The Meat:**
|
|
69
|
+
- **The Meat:** Brief explanation of what you are doing **AND** the shell commands. DO NOT "leak" (print) the code twice.
|
|
68
70
|
- **The Outro:** Supportive closing.
|
|
69
71
|
|
|
70
72
|
### 𧬠CODE ARCHITECT STANDARDS
|
|
71
|
-
- **Role:** IMPLEMENT via shell commands.
|
|
73
|
+
- **Role:** IMPLEMENT via shell commands.
|
|
72
74
|
- **No Placeholders:** Full implementations only.
|
|
73
75
|
|
|
74
76
|
### š ļø ENVIRONMENT CONTEXT
|
|
@@ -121,52 +123,77 @@ ${repoMap}`
|
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
let fullResponse = '';
|
|
127
|
+
let buffer = '';
|
|
128
|
+
let hasStarted = false;
|
|
129
|
+
let inCodeBlock = false;
|
|
130
|
+
let codeLanguage = '';
|
|
131
|
+
|
|
132
|
+
await client.chatStream({
|
|
133
|
+
messages,
|
|
126
134
|
model: options.model,
|
|
127
135
|
temperature: 0.7,
|
|
128
136
|
max_tokens: 4000,
|
|
129
|
-
|
|
137
|
+
}, (chunk) => {
|
|
138
|
+
if (!hasStarted) {
|
|
139
|
+
spinner.stop();
|
|
140
|
+
hasStarted = true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
buffer += chunk;
|
|
144
|
+
fullResponse += chunk;
|
|
145
|
+
|
|
146
|
+
const lines = buffer.split('\n');
|
|
147
|
+
if (lines.length > 1) {
|
|
148
|
+
buffer = lines.pop() || '';
|
|
149
|
+
|
|
150
|
+
for (const line of lines) {
|
|
151
|
+
const trimmed = line.trim();
|
|
152
|
+
|
|
153
|
+
// Code block detection
|
|
154
|
+
if (trimmed.startsWith('```')) {
|
|
155
|
+
if (!inCodeBlock) {
|
|
156
|
+
inCodeBlock = true;
|
|
157
|
+
codeLanguage = trimmed.substring(3).toLowerCase();
|
|
158
|
+
// In chat mode, we hide shell commands if execute is on
|
|
159
|
+
if (options.execute && ['bash', 'sh', 'zsh', 'powershell', 'cmd'].includes(codeLanguage)) {
|
|
160
|
+
console.log(chalk.gray('\n[Running Shell Command in Terminal Block...]'));
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
inCodeBlock = false;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Agent Tag detection
|
|
169
|
+
const agentMatch = trimmed.match(/^\[(MatexCodeArchitect|SyntaxGuard|VisualAgent|CoreAgent|CrawlerAgent|DetailedResearch|MatexResearchCommander)\]$/);
|
|
170
|
+
if (agentMatch) {
|
|
171
|
+
console.log(`\n${chalk.bold.cyan(trimmed)}`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Normal text output
|
|
176
|
+
if (!inCodeBlock) {
|
|
177
|
+
if (trimmed) console.log(chalk.gray(trimmed));
|
|
178
|
+
} else if (!options.execute) {
|
|
179
|
+
// If not executing, show the code anyway
|
|
180
|
+
if (line.length > 0) {
|
|
181
|
+
console.log(chalk.blue(line));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
130
186
|
});
|
|
131
187
|
|
|
132
188
|
spinner.stop();
|
|
133
189
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// Enhanced Multi-Agent Display (Updated for Vertex AI ADK)
|
|
138
|
-
const segments = response.split(/(\[MatexCodeArchitect\]|\[SyntaxGuard\]|\[VisualAgent\]|\[CoreAgent\]|\[CrawlerAgent\]|\[DetailedResearch\]|\[MatexResearchCommander\])/);
|
|
139
|
-
let hasAgents = false;
|
|
140
|
-
|
|
141
|
-
for (let i = 0; i < segments.length; i++) {
|
|
142
|
-
const segment = segments[i].trim();
|
|
143
|
-
if (!segment) continue;
|
|
144
|
-
|
|
145
|
-
if (segment === '[MatexCodeArchitect]') {
|
|
146
|
-
AgentOrchestrator.speak('Architect', segments[++i]?.split('[')[0].trim());
|
|
147
|
-
hasAgents = true;
|
|
148
|
-
} else if (segment === '[SyntaxGuard]') {
|
|
149
|
-
AgentOrchestrator.speak('Syntax', segments[++i]?.split('[')[0].trim());
|
|
150
|
-
hasAgents = true;
|
|
151
|
-
} else if (segment === '[VisualAgent]') {
|
|
152
|
-
AgentOrchestrator.speak('Frontend', segments[++i]?.split('[')[0].trim());
|
|
153
|
-
hasAgents = true;
|
|
154
|
-
} else if (segment === '[CoreAgent]') {
|
|
155
|
-
AgentOrchestrator.speak('Backend', segments[++i]?.split('[')[0].trim());
|
|
156
|
-
hasAgents = true;
|
|
157
|
-
} else if (segment === '[MatexResearchCommander]' || segment === '[CrawlerAgent]' || segment === '[DetailedResearch]') {
|
|
158
|
-
AgentOrchestrator.speak('Commander', segments[++i]?.split('[')[0].trim());
|
|
159
|
-
hasAgents = true;
|
|
160
|
-
} else if (!hasAgents || i === segments.length - 1) {
|
|
161
|
-
// Final summary or fallback
|
|
162
|
-
if (segment.includes('`')) {
|
|
163
|
-
// If it's code, just print it clean
|
|
164
|
-
console.log('\n' + chalk.white(segment));
|
|
165
|
-
} else {
|
|
166
|
-
console.log('\n' + chalk.gray(segment));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
190
|
+
if (buffer.trim() && !inCodeBlock) {
|
|
191
|
+
console.log(chalk.gray(buffer.trim()));
|
|
169
192
|
}
|
|
193
|
+
|
|
194
|
+
// Add assistant response to history
|
|
195
|
+
messages.push({ role: 'assistant', content: fullResponse });
|
|
196
|
+
const response = fullResponse;
|
|
170
197
|
console.log();
|
|
171
198
|
|
|
172
199
|
// Execute commands if requested
|