matex-cli 1.2.81 → 1.2.84

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.
Files changed (142) hide show
  1. package/dist/commands/chaos.js +3 -8
  2. package/dist/prompts/chaos-prompts.js +26 -21
  3. package/dist/session/agent-session.js +38 -9
  4. package/dist/utils/agent-orchestrator.js +7 -0
  5. package/dist/utils/mcp-server.js +6 -0
  6. package/dist/utils/tui.js +84 -7
  7. package/package.json +7 -1
  8. package/.agents/skills/mcp-server-dev/SKILL.md +0 -60
  9. package/.agents/skills/mcp-server-dev/examples/basic-ts-server/package.json +0 -20
  10. package/.agents/skills/mcp-server-dev/examples/basic-ts-server/src/index.ts +0 -66
  11. package/.agents/skills/mcp-server-dev/resources/best_practices.md +0 -20
  12. package/.agents/skills/pptx-presentation-builder/SKILL.md +0 -338
  13. package/.agents/workflows/deploy.md +0 -27
  14. package/dist/api/client.d.ts +0 -40
  15. package/dist/api/client.d.ts.map +0 -1
  16. package/dist/api/client.js.map +0 -1
  17. package/dist/commands/ask.d.ts +0 -3
  18. package/dist/commands/ask.d.ts.map +0 -1
  19. package/dist/commands/ask.js.map +0 -1
  20. package/dist/commands/augov.d.ts +0 -3
  21. package/dist/commands/augov.d.ts.map +0 -1
  22. package/dist/commands/augov.js.map +0 -1
  23. package/dist/commands/bro.d.ts +0 -4
  24. package/dist/commands/bro.d.ts.map +0 -1
  25. package/dist/commands/bro.js.map +0 -1
  26. package/dist/commands/chaos.d.ts +0 -3
  27. package/dist/commands/chaos.d.ts.map +0 -1
  28. package/dist/commands/chaos.js.map +0 -1
  29. package/dist/commands/chat.d.ts +0 -3
  30. package/dist/commands/chat.d.ts.map +0 -1
  31. package/dist/commands/chat.js.map +0 -1
  32. package/dist/commands/code.d.ts +0 -3
  33. package/dist/commands/code.d.ts.map +0 -1
  34. package/dist/commands/code.js.map +0 -1
  35. package/dist/commands/config.d.ts +0 -3
  36. package/dist/commands/config.d.ts.map +0 -1
  37. package/dist/commands/config.js.map +0 -1
  38. package/dist/commands/dev.d.ts +0 -3
  39. package/dist/commands/dev.d.ts.map +0 -1
  40. package/dist/commands/dev.js.map +0 -1
  41. package/dist/commands/help.d.ts +0 -3
  42. package/dist/commands/help.d.ts.map +0 -1
  43. package/dist/commands/help.js.map +0 -1
  44. package/dist/commands/login.d.ts +0 -3
  45. package/dist/commands/login.d.ts.map +0 -1
  46. package/dist/commands/login.js.map +0 -1
  47. package/dist/commands/models.d.ts +0 -3
  48. package/dist/commands/models.d.ts.map +0 -1
  49. package/dist/commands/models.js.map +0 -1
  50. package/dist/commands/student.d.ts +0 -3
  51. package/dist/commands/student.d.ts.map +0 -1
  52. package/dist/commands/student.js.map +0 -1
  53. package/dist/commands/study.d.ts +0 -3
  54. package/dist/commands/study.d.ts.map +0 -1
  55. package/dist/commands/study.js.map +0 -1
  56. package/dist/index.d.ts +0 -3
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/prompts/banter-augov.d.ts +0 -2
  60. package/dist/prompts/banter-augov.d.ts.map +0 -1
  61. package/dist/prompts/banter-augov.js.map +0 -1
  62. package/dist/prompts/banter.d.ts +0 -6
  63. package/dist/prompts/banter.d.ts.map +0 -1
  64. package/dist/prompts/banter.js.map +0 -1
  65. package/dist/prompts/chaos-prompts.d.ts +0 -3
  66. package/dist/prompts/chaos-prompts.d.ts.map +0 -1
  67. package/dist/prompts/chaos-prompts.js.map +0 -1
  68. package/dist/prompts/system-prompts.d.ts +0 -4
  69. package/dist/prompts/system-prompts.d.ts.map +0 -1
  70. package/dist/prompts/system-prompts.js.map +0 -1
  71. package/dist/session/agent-session.d.ts +0 -41
  72. package/dist/session/agent-session.d.ts.map +0 -1
  73. package/dist/session/agent-session.js.map +0 -1
  74. package/dist/utils/agent-orchestrator.d.ts +0 -44
  75. package/dist/utils/agent-orchestrator.d.ts.map +0 -1
  76. package/dist/utils/agent-orchestrator.js.map +0 -1
  77. package/dist/utils/augov-logger.d.ts +0 -11
  78. package/dist/utils/augov-logger.d.ts.map +0 -1
  79. package/dist/utils/augov-logger.js.map +0 -1
  80. package/dist/utils/augov-scrubber.d.ts +0 -23
  81. package/dist/utils/augov-scrubber.d.ts.map +0 -1
  82. package/dist/utils/augov-scrubber.js.map +0 -1
  83. package/dist/utils/command-executor.d.ts +0 -56
  84. package/dist/utils/command-executor.d.ts.map +0 -1
  85. package/dist/utils/command-executor.js.map +0 -1
  86. package/dist/utils/config.d.ts +0 -56
  87. package/dist/utils/config.d.ts.map +0 -1
  88. package/dist/utils/config.js.map +0 -1
  89. package/dist/utils/mcp-server.d.ts +0 -77
  90. package/dist/utils/mcp-server.d.ts.map +0 -1
  91. package/dist/utils/mcp-server.js.map +0 -1
  92. package/dist/utils/patcher.d.ts +0 -45
  93. package/dist/utils/patcher.d.ts.map +0 -1
  94. package/dist/utils/patcher.js.map +0 -1
  95. package/dist/utils/repo-mapper.d.ts +0 -32
  96. package/dist/utils/repo-mapper.d.ts.map +0 -1
  97. package/dist/utils/repo-mapper.js.map +0 -1
  98. package/dist/utils/spinner.d.ts +0 -15
  99. package/dist/utils/spinner.d.ts.map +0 -1
  100. package/dist/utils/spinner.js.map +0 -1
  101. package/dist/utils/tui.d.ts +0 -134
  102. package/dist/utils/tui.d.ts.map +0 -1
  103. package/dist/utils/tui.js.map +0 -1
  104. package/fix-npm-permissions.sh +0 -23
  105. package/publish-local.sh +0 -16
  106. package/skills-lock.json +0 -10
  107. package/src/api/client.ts +0 -197
  108. package/src/commands/ask.ts +0 -62
  109. package/src/commands/augov.ts +0 -301
  110. package/src/commands/bro.ts +0 -336
  111. package/src/commands/chaos.ts +0 -67
  112. package/src/commands/chat.ts +0 -61
  113. package/src/commands/code.ts +0 -99
  114. package/src/commands/config.ts +0 -78
  115. package/src/commands/dev.ts +0 -68
  116. package/src/commands/help.ts +0 -67
  117. package/src/commands/login.ts +0 -47
  118. package/src/commands/models.ts +0 -81
  119. package/src/commands/student.ts +0 -23
  120. package/src/commands/study.ts +0 -75
  121. package/src/index.ts +0 -284
  122. package/src/prompts/banter-augov.ts +0 -17
  123. package/src/prompts/banter.ts +0 -101
  124. package/src/prompts/chaos-prompts.ts +0 -48
  125. package/src/prompts/system-prompts.ts +0 -145
  126. package/src/session/agent-session.ts +0 -428
  127. package/src/utils/agent-orchestrator.ts +0 -264
  128. package/src/utils/augov-logger.ts +0 -34
  129. package/src/utils/augov-scrubber.ts +0 -67
  130. package/src/utils/command-executor.ts +0 -529
  131. package/src/utils/config.ts +0 -124
  132. package/src/utils/mcp-server.ts +0 -388
  133. package/src/utils/patcher.ts +0 -229
  134. package/src/utils/repo-mapper.ts +0 -198
  135. package/src/utils/spinner.ts +0 -66
  136. package/src/utils/tui.ts +0 -749
  137. package/test-chaos-container.js +0 -16
  138. package/test-chaos-fix.js +0 -18
  139. package/test-config.ts +0 -2
  140. package/test-ui-output.js +0 -16
  141. package/tsconfig.json +0 -27
  142. package/vertex_ai_agent.py +0 -52
@@ -1,62 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { configManager } from '../utils/config';
4
- import { MatexAPIClient } from '../api/client';
5
- import { spinner } from '../utils/spinner';
6
-
7
- export const askCommand = new Command('ask')
8
- .description('Ask a single question to MATEX AI')
9
- .argument('<question>', 'Your question')
10
- .option('-m, --model <model>', 'AI model to use (matexcore, matexcodex, matexai, elite, matexspirit)', configManager.getDefaultModel())
11
- .option('-t, --temperature <number>', 'Temperature (0-1)', '0.7')
12
- .option('--max-tokens <number>', 'Maximum tokens in response', '4000')
13
- .action(async (question: string, options: any) => {
14
- try {
15
- // Check for API key
16
- const apiKey = configManager.getAPIKey();
17
- if (!apiKey) {
18
- console.error(chalk.red('❌ No API key configured.'));
19
- console.log(chalk.yellow('Run: matex config set-key <your-api-key>'));
20
- process.exit(1);
21
- }
22
-
23
- // Create API client
24
- const client = new MatexAPIClient(apiKey, configManager.getBaseURL());
25
-
26
- // Show thinking indicator
27
- spinner.start(`Thinking with ${options.model}...`);
28
-
29
- // Send request
30
- const response = await client.chat({
31
- messages: [
32
- { role: 'user', content: question }
33
- ],
34
- model: options.model,
35
- temperature: parseFloat(options.temperature),
36
- max_tokens: parseInt(options.maxTokens),
37
- stream: false,
38
- });
39
-
40
- spinner.succeed('Response received!');
41
-
42
- // Display response
43
- console.log(chalk.cyan('\n💬 MATEX AI:\n'));
44
- console.log(chalk.white(response));
45
- console.log();
46
-
47
- } catch (error: any) {
48
- spinner.fail('Request failed');
49
-
50
- if (error.message.includes('403')) {
51
- console.error(chalk.red('\n❌ Invalid or revoked API key.'));
52
- console.log(chalk.yellow('Please check your API key or generate a new one from the MATEX AI platform.'));
53
- } else if (error.message.includes('429')) {
54
- console.error(chalk.red('\n❌ Rate limit exceeded.'));
55
- console.log(chalk.yellow('Please wait a moment before trying again.'));
56
- } else {
57
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
58
- }
59
-
60
- process.exit(1);
61
- }
62
- });
@@ -1,301 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { configManager } from '../utils/config';
4
- import { MatexAPIClient, ChatMessage } from '../api/client';
5
- import { AgentOrchestrator } from '../utils/agent-orchestrator';
6
- import { RepoMapper } from '../utils/repo-mapper';
7
- import { TUI } from '../utils/tui';
8
- import { AgentSession } from '../session/agent-session';
9
- import { BRO_BANTER_AUGOV } from '../prompts/banter-augov';
10
- import { GovPrivacyScrubber } from '../utils/augov-scrubber';
11
- import { GovAuditLogger } from '../utils/augov-logger';
12
-
13
- import fs from 'fs';
14
- import path from 'path';
15
- import inquirer from 'inquirer';
16
-
17
- export const augovCommand = new Command('augov')
18
- .description('🇦🇺 Launch AU-GOV in Secure Government Compliance Mode (APS/Cyber Ready)')
19
- .option('-m, --model <model>', 'AI model to use', configManager.getDefaultModel())
20
- .option('--execute', 'Enable command auto-execution')
21
- .option('--offline', 'Enable Tactical Edge Deployment (Offline Mode using local Llama-3-8B model)')
22
- .action(async (options: any) => {
23
- try {
24
- const apiKey = configManager.getAPIKey();
25
- if (!apiKey) {
26
- console.error(chalk.red('❌ No API key configured. Run: matex config set-key <key>'));
27
- process.exit(1);
28
- }
29
-
30
- // Security Gatekeeper: Mandatory key for AU-GOV mode
31
- const { securityKey } = await inquirer.prompt([
32
- {
33
- type: 'password',
34
- name: 'securityKey',
35
- message: chalk.hex('#3B82F6').bold('🔑 Enter AU-GOV Security Key:'),
36
- mask: '*'
37
- }
38
- ]);
39
-
40
- if (securityKey !== 'Buildex@9847') {
41
- console.error(chalk.red('\n ❌ ACCESS DENIED: Invalid Sovereign Security Key.'));
42
- process.exit(1);
43
- }
44
-
45
- console.log(chalk.green(' ✅ Access Granted. Initiating Sovereign Handshake...\n'));
46
-
47
- if (options.offline) {
48
- options.model = 'matexcodexlite'; // Force local quantized model
49
- }
50
-
51
- // Zero-Trust Architecture: Connect directly to the sovereign Sydney backend, or localhost if Tactical Edge is active.
52
- const AU_GOV_BACKEND_URL = options.offline ? "http://localhost:8000" : "https://matexaibackendgovernment-964562696516.australia-southeast1.run.app";
53
- const client = new MatexAPIClient(apiKey, AU_GOV_BACKEND_URL);
54
-
55
- // We override the default client chat endpoint to hit our specific AU-GOV proxy (or local fallback)
56
- client.chatStream = async (request: any, onChunk: (chunk: string) => void, signal?: AbortSignal): Promise<string> => {
57
- const endpoint = options.offline ? '/api/v1/chat' : '/api/v1/augov/chat';
58
- const response = await fetch(`${AU_GOV_BACKEND_URL}${endpoint}`, {
59
- method: 'POST',
60
- headers: {
61
- 'Content-Type': 'application/json',
62
- 'Authorization': `Bearer ${apiKey}`,
63
- 'X-Sovereign-Key': securityKey
64
- },
65
- body: JSON.stringify(request),
66
- signal: signal
67
- });
68
-
69
- if (!response.ok) throw new Error(`AU-GOV Backend Error: ${response.status} ${response.statusText}`);
70
- if (!response.body) throw new Error('No response body from AU-GOV backend');
71
-
72
- const reader = response.body.getReader();
73
- const decoder = new TextDecoder('utf-8');
74
- let buffer = "";
75
- let fullResponse = "";
76
-
77
- while (true) {
78
- const { done, value } = await reader.read();
79
- if (done) break;
80
-
81
- buffer += decoder.decode(value, { stream: true });
82
- const lines = buffer.split('\n');
83
- buffer = lines.pop() || "";
84
-
85
- for (const line of lines) {
86
- if (line.startsWith('data: ')) {
87
- const dataStr = line.slice(6);
88
- if (dataStr.trim() === '[DONE]') continue;
89
- try {
90
- const data = JSON.parse(dataStr);
91
- if (data.content) {
92
- fullResponse += data.content;
93
- onChunk(data.content);
94
- }
95
- } catch (e) { /* Ignore parse errors on chunks */ }
96
- }
97
- }
98
- }
99
- return fullResponse;
100
- };
101
-
102
- TUI.init();
103
- AgentOrchestrator.setMode('augov'); // Use secure AU-GOV styling
104
-
105
- TUI.drawAugovOrchestratorUI();
106
-
107
- const pkiClearance = 'PROTECTED'; // Mocked PKI Certificate Clearance
108
- console.log(chalk.gray(` Verification: `) + chalk.hex('#10b981').bold(`PKI Cert Validated. Clearance Level: [${pkiClearance}]\n`));
109
-
110
- if (options.offline) {
111
- console.log(chalk.hex('#f59e0b').bold(' [TACTICAL EDGE] OFFLINE MODE ACTIVE: Routing to local MatexCodexLite (Llama-3-8B).\n'));
112
- }
113
-
114
- const currentDir = process.cwd();
115
- const repoMap = await new RepoMapper(currentDir).generateMap();
116
-
117
- const extraPrompt = '';
118
-
119
- const initialMessages: ChatMessage[] = [
120
- {
121
- role: 'system',
122
- // Zero-Trust Architecture: The CLI sends a handshake and environment context only.
123
- // The actual secure AU-GOV system prompt is injected on the backend to prevent NPM leaks.
124
- content: `[AUGOV_MODE_HANDSHAKE]\n<PKI_CERT_CLEARANCE>${pkiClearance}</PKI_CERT_CLEARANCE>\nCURRENT_DIR: ${currentDir}\n\nSECURE ENVIRONMENT CONTEXT:\n${repoMap}`
125
- }
126
- ];
127
-
128
- const session = new AgentSession({
129
- client,
130
- model: options.model,
131
- execute: options.execute || false,
132
- initialMessages,
133
- broBanter: BRO_BANTER_AUGOV,
134
- baseDir: currentDir,
135
- messageScrubber: (input: string) => GovPrivacyScrubber.scrub(input),
136
- auditLogger: new GovAuditLogger(currentDir),
137
- isAugovMode: true
138
- });
139
-
140
- await session.start();
141
-
142
- } catch (error: any) {
143
- TUI.exit();
144
- console.error(chalk.red(`\n❌ Secure Session Error: ${error.message}`));
145
- process.exit(1);
146
- }
147
- });
148
-
149
- // Freedom of Information (FOI) Document Redactor
150
- augovCommand
151
- .command('redact <file>')
152
- .description('🇦🇺 Automate FOI Redaction (Blacks out TFNs, Cabinet Data, Military Assets)')
153
- .action(async (file: string) => {
154
- TUI.init();
155
- AgentOrchestrator.setMode('augov');
156
- TUI.drawAugovOrchestratorUI();
157
-
158
- console.log(chalk.bold.yellow('\n [FOI REDACTION PROTOCOL INITIATED]'));
159
- const filePath = path.resolve(process.cwd(), file);
160
-
161
- if (!fs.existsSync(filePath)) {
162
- console.error(chalk.red(`\n❌ Error: Document not found at ${filePath}`));
163
- TUI.exit();
164
- process.exit(1);
165
- }
166
-
167
- try {
168
- console.log(chalk.gray(` Scanning Document: ${file}...`));
169
- const content = fs.readFileSync(filePath, 'utf-8');
170
-
171
- // Execute the highly secure local scrubber
172
- const { scrubbed, redactionCount } = await GovPrivacyScrubber.redactDocumentContent(content);
173
-
174
- TUI.drawGlowingContainer('FOI CLEARED DOCUMENT', 'txt', scrubbed);
175
-
176
- console.log(chalk.bold.green(`\n ✅ Scanning Complete.`));
177
- console.log(chalk.gray(` Total sensitive assets redacted locally: `) + chalk.bgBlack.white.bold(` ${redactionCount} `));
178
- console.log(chalk.gray(` Document is now cleared for Public Release.`));
179
-
180
- } catch (error: any) {
181
- console.error(chalk.red(`\n❌ FOI Processing Error: ${error.message}`));
182
- } finally {
183
- TUI.exit();
184
- }
185
- });
186
-
187
- // Legislative & Policy War-Gaming
188
- augovCommand
189
- .command('simulate-policy')
190
- .description('🇦🇺 Simulate the impact of new legislation against existing frameworks (e.g. Privacy Act 1988)')
191
- .requiredOption('--bill <file>', 'Path to the drafted bill text document')
192
- .option('-m, --model <model>', 'AI model to use', configManager.getDefaultModel())
193
- .action(async (options: any) => {
194
- try {
195
- const apiKey = configManager.getAPIKey();
196
- if (!apiKey) {
197
- console.error(chalk.red('❌ No API key configured. Run: matex config set-key <key>'));
198
- process.exit(1);
199
- }
200
-
201
- const AU_GOV_BACKEND_URL = "https://matexaibackendgovernment-964562696516.australia-southeast1.run.app";
202
- const client = new MatexAPIClient(apiKey, AU_GOV_BACKEND_URL);
203
-
204
- // Override stream endpoint
205
- client.chatStream = async (request: any, onChunk: (chunk: string) => void, signal?: AbortSignal): Promise<string> => {
206
- const response = await fetch(`${AU_GOV_BACKEND_URL}/api/v1/augov/chat`, {
207
- method: 'POST',
208
- headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` },
209
- body: JSON.stringify(request),
210
- signal: signal
211
- });
212
-
213
- if (!response.ok) throw new Error(`AU-GOV Backend Error: ${response.status} ${response.statusText}`);
214
- if (!response.body) throw new Error('No response body from AU-GOV backend');
215
-
216
- const reader = response.body.getReader();
217
- const decoder = new TextDecoder('utf-8');
218
- let buffer = "";
219
- let fullResponse = "";
220
-
221
- while (true) {
222
- const { done, value } = await reader.read();
223
- if (done) break;
224
-
225
- buffer += decoder.decode(value, { stream: true });
226
- const lines = buffer.split('\n');
227
- buffer = lines.pop() || "";
228
-
229
- for (const line of lines) {
230
- if (line.startsWith('data: ')) {
231
- const dataStr = line.slice(6);
232
- if (dataStr.trim() === '[DONE]') continue;
233
- try {
234
- const data = JSON.parse(dataStr);
235
- if (data.content) {
236
- fullResponse += data.content;
237
- onChunk(data.content);
238
- }
239
- } catch (e) { /* Ignore parse errors on chunks */ }
240
- }
241
- }
242
- }
243
- return fullResponse;
244
- };
245
-
246
- TUI.init();
247
- AgentOrchestrator.setMode('augov');
248
- TUI.drawAugovOrchestratorUI();
249
-
250
- console.log(chalk.bold.magenta('\n [POLICY WAR-GAMING INITIATED]'));
251
- const filePath = path.resolve(process.cwd(), options.bill);
252
-
253
- if (!fs.existsSync(filePath)) {
254
- console.error(chalk.red(`\n❌ Error: Bill document not found at ${filePath}`));
255
- TUI.exit();
256
- process.exit(1);
257
- }
258
-
259
- console.log(chalk.gray(` Ingesting Draft Bill: ${options.bill}...`));
260
- const billContent = fs.readFileSync(filePath, 'utf-8');
261
- const pkiClearance = 'TOP SECRET';
262
-
263
- console.log(chalk.gray(` Clearance Validated: `) + chalk.hex('#10b981').bold(`[${pkiClearance}]\n`));
264
-
265
- const initialMessages: ChatMessage[] = [
266
- {
267
- role: 'system',
268
- content: `[AUGOV_MODE_HANDSHAKE]\n<PKI_CERT_CLEARANCE>${pkiClearance}</PKI_CERT_CLEARANCE>\nCURRENT_DIR: ${process.cwd()}`
269
- },
270
- {
271
- role: 'user',
272
- content: `Please run a Legislative War-Game on the following drafted text. Your primary objective is to cross-reference this draft against the Australian Privacy Act 1988 and the Protective Security Policy Framework (PSPF). Identify any conflicts, constitutional overreach, or compliance vulnerabilities.\n\n### DRAFT BILL TEXT ###\n${billContent}`
273
- }
274
- ];
275
-
276
- const session = new AgentSession({
277
- client,
278
- model: options.model,
279
- execute: false, // War-gaming does not execute terminal commands
280
- initialMessages,
281
- broBanter: BRO_BANTER_AUGOV,
282
- baseDir: process.cwd(),
283
- messageScrubber: (input: string) => GovPrivacyScrubber.scrub(input),
284
- auditLogger: new GovAuditLogger(process.cwd()),
285
- isAugovMode: true
286
- });
287
-
288
- // Fast-forward straight to the agent loop without waiting for user input since the prompt is pre-loaded
289
- console.log(chalk.gray(` Executing Multi-Agent Swarm Simulation...\n`));
290
-
291
- // We just trigger a custom agent pass and let it stream
292
- await (session as any).agenticLoopPass(1);
293
-
294
- console.log(chalk.bold.green(`\n ✅ Policy Simulation Complete.`));
295
-
296
- } catch (error: any) {
297
- console.error(chalk.red(`\n❌ Simulation Error: ${error.message}`));
298
- } finally {
299
- TUI.exit();
300
- }
301
- });