matex-cli 1.0.0

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 (45) hide show
  1. package/README.md +261 -0
  2. package/USAGE_GUIDE.md +180 -0
  3. package/bin/matex +2 -0
  4. package/dist/api/client.d.ts +34 -0
  5. package/dist/api/client.d.ts.map +1 -0
  6. package/dist/api/client.js +99 -0
  7. package/dist/api/client.js.map +1 -0
  8. package/dist/commands/ask.d.ts +3 -0
  9. package/dist/commands/ask.d.ts.map +1 -0
  10. package/dist/commands/ask.js +63 -0
  11. package/dist/commands/ask.js.map +1 -0
  12. package/dist/commands/chat.d.ts +3 -0
  13. package/dist/commands/chat.d.ts.map +1 -0
  14. package/dist/commands/chat.js +95 -0
  15. package/dist/commands/chat.js.map +1 -0
  16. package/dist/commands/config.d.ts +3 -0
  17. package/dist/commands/config.d.ts.map +1 -0
  18. package/dist/commands/config.js +74 -0
  19. package/dist/commands/config.js.map +1 -0
  20. package/dist/commands/models.d.ts +3 -0
  21. package/dist/commands/models.d.ts.map +1 -0
  22. package/dist/commands/models.js +77 -0
  23. package/dist/commands/models.js.map +1 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +48 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/utils/config.d.ts +56 -0
  29. package/dist/utils/config.d.ts.map +1 -0
  30. package/dist/utils/config.js +135 -0
  31. package/dist/utils/config.js.map +1 -0
  32. package/dist/utils/spinner.d.ts +12 -0
  33. package/dist/utils/spinner.d.ts.map +1 -0
  34. package/dist/utils/spinner.js +58 -0
  35. package/dist/utils/spinner.js.map +1 -0
  36. package/package.json +44 -0
  37. package/src/api/client.ts +116 -0
  38. package/src/commands/ask.ts +62 -0
  39. package/src/commands/chat.ts +101 -0
  40. package/src/commands/config.ts +78 -0
  41. package/src/commands/models.ts +81 -0
  42. package/src/index.ts +50 -0
  43. package/src/utils/config.ts +120 -0
  44. package/src/utils/spinner.ts +57 -0
  45. package/tsconfig.json +27 -0
package/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # MATEX CLI
2
+
3
+ Official command-line interface for MATEX AI. Access powerful AI models directly from your terminal and edit code in your local files.
4
+
5
+ ## Features
6
+
7
+ - šŸš€ **Fast & Easy**: Simple commands to interact with AI
8
+ - šŸ” **Secure**: API key-based authentication
9
+ - šŸ’¬ **Interactive Chat**: Continuous conversations with context
10
+ - šŸ¤– **Multiple Models**: Access MATEXCodex, MATEXAi, Elite, and more
11
+ - šŸ’» **Local Development**: Use AI to help write and edit code on your laptop/PC
12
+ - ⚔ **Pro Plus Exclusive**: Available for Pro Plus subscribers
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install -g matex-cli
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Get Your API Key
23
+
24
+ 1. Log in to [MATEX AI Platform](https://matexai.space/platform)
25
+ 2. Navigate to **Settings** → **API Keys**
26
+ 3. Click **Generate New API Key**
27
+ 4. Copy your key (starts with `sk-matex-`)
28
+
29
+ ### 2. Configure CLI
30
+
31
+ ```bash
32
+ matex config set-key sk-matex-your-api-key-here
33
+ ```
34
+
35
+ ### 3. Start Using
36
+
37
+ ```bash
38
+ # Ask a single question
39
+ matex ask "What is 2+2?"
40
+
41
+ # Start interactive chat
42
+ matex chat
43
+
44
+ # Use for coding help
45
+ matex ask "Write a Python function to reverse a string" --model matexcodex
46
+ ```
47
+
48
+ ## Using MATEX CLI for Local Development
49
+
50
+ ### Code Generation
51
+
52
+ Generate code directly in your terminal:
53
+
54
+ ```bash
55
+ # Generate a complete function
56
+ matex ask "Create a React component for a login form" --model matexcodex
57
+
58
+ # Get code explanations
59
+ matex ask "Explain this error: TypeError: Cannot read property 'map' of undefined"
60
+
61
+ # Debug assistance
62
+ matex ask "Why is my async function not waiting for the promise?"
63
+ ```
64
+
65
+ ### Interactive Coding Session
66
+
67
+ Use chat mode for back-and-forth coding help:
68
+
69
+ ```bash
70
+ matex chat --model matexcodex
71
+ > I need to create a REST API in Node.js
72
+ > [AI provides code]
73
+ > How do I add authentication to this?
74
+ > [AI provides auth code]
75
+ > Can you show me how to test this with Jest?
76
+ > [Conversation continues...]
77
+ ```
78
+
79
+ ### Copy Code to Your Files
80
+
81
+ 1. **Ask for code**:
82
+ ```bash
83
+ matex ask "Create a Python class for user management" --model matexcodex
84
+ ```
85
+
86
+ 2. **Copy the output** from terminal
87
+
88
+ 3. **Paste into your local files** using your favorite editor (VS Code, Sublime, etc.)
89
+
90
+ ### Best Practices for Local Development
91
+
92
+ - **Use MATEXCodex model** for coding tasks (`--model matexcodex`)
93
+ - **Be specific** in your requests (mention language, framework, requirements)
94
+ - **Use chat mode** for complex projects requiring multiple steps
95
+ - **Save responses** by redirecting output: `matex ask "..." > output.txt`
96
+
97
+ ---
98
+
99
+ ## Commands
100
+
101
+ ### `matex config`
102
+
103
+ Manage CLI configuration
104
+
105
+ ```bash
106
+ # Set API key
107
+ matex config set-key <your-api-key>
108
+
109
+ # Show current configuration
110
+ matex config show
111
+
112
+ # Set default model
113
+ matex config set-model matexcodex
114
+
115
+ # Clear all configuration
116
+ matex config clear
117
+ ```
118
+
119
+ ### `matex ask`
120
+
121
+ Ask a single question
122
+
123
+ ```bash
124
+ matex ask "Your question here"
125
+
126
+ # Options:
127
+ # -m, --model <model> AI model (default: matexcodex)
128
+ # -t, --temperature <number> Temperature 0-1 (default: 0.7)
129
+ # --max-tokens <number> Max response tokens (default: 4000)
130
+ ```
131
+
132
+ **Examples:**
133
+
134
+ ```bash
135
+ matex ask "Explain quantum computing"
136
+ matex ask "Write a REST API in Python" --model matexcodex
137
+ matex ask "Tell me a story" --model matexspirit
138
+ ```
139
+
140
+ ### `matex chat`
141
+
142
+ Start an interactive chat session
143
+
144
+ ```bash
145
+ matex chat
146
+
147
+ # Options:
148
+ # -m, --model <model> AI model (default: matexcodex)
149
+ ```
150
+
151
+ **Example:**
152
+
153
+ ```bash
154
+ matex chat --model matexai
155
+ ```
156
+
157
+ Type `exit` or `quit` to end the session.
158
+
159
+ ### `matex models`
160
+
161
+ Manage AI models
162
+
163
+ ```bash
164
+ # List all available models
165
+ matex models list
166
+
167
+ # Set default model
168
+ matex models set matexcodex
169
+
170
+ # Show current default model
171
+ matex models current
172
+ ```
173
+
174
+ ## Available Models
175
+
176
+ | Model | Description | Access |
177
+ |-------|-------------|--------|
178
+ | **matexcodex** | Best for coding and technical tasks | Free (5 min/day), Starter (4M tokens/month), Pro Plus (unlimited) |
179
+ | **matexai** | General purpose conversations | Pro, Pro Plus |
180
+ | **elite** | Premium advanced capabilities | Elite Plan |
181
+ | **matexspirit** | Creative and empathetic responses | Pro, Pro Plus |
182
+
183
+ ## Configuration
184
+
185
+ Configuration is stored in `~/.matex/config.json`
186
+
187
+ ```json
188
+ {
189
+ "apiKey": "sk-matex-...",
190
+ "defaultModel": "matexcodex",
191
+ "baseURL": "https://matexai-backend-550499663766.us-central1.run.app"
192
+ }
193
+ ```
194
+
195
+ ## Error Handling
196
+
197
+ ### Invalid API Key
198
+
199
+ ```
200
+ āŒ Invalid or revoked API key.
201
+ Please check your API key or generate a new one from the MATEX AI platform.
202
+ ```
203
+
204
+ **Solution**: Generate a new API key from the platform.
205
+
206
+ ### Rate Limit Exceeded
207
+
208
+ ```
209
+ āŒ Rate limit exceeded.
210
+ Please wait a moment before trying again.
211
+ ```
212
+
213
+ **Solution**: Wait a few moments or upgrade your plan.
214
+
215
+ ### No API Key Configured
216
+
217
+ ```
218
+ āŒ No API key configured.
219
+ Run: matex config set-key <your-api-key>
220
+ ```
221
+
222
+ **Solution**: Set your API key using the config command.
223
+
224
+ ## Examples
225
+
226
+ ### Code Generation
227
+
228
+ ```bash
229
+ matex ask "Create a React component for a login form" --model matexcodex
230
+ ```
231
+
232
+ ### General Questions
233
+
234
+ ```bash
235
+ matex ask "What are the benefits of TypeScript?"
236
+ ```
237
+
238
+ ### Interactive Debugging
239
+
240
+ ```bash
241
+ matex chat --model matexcodex
242
+ > I'm getting a TypeError in my JavaScript code
243
+ > [AI provides solution]
244
+ > How can I prevent this in the future?
245
+ > [Conversation continues...]
246
+ ```
247
+
248
+ ## Support
249
+
250
+ - **Platform**: [https://matexai.space/platform](https://matexai.space/platform)
251
+ - **API Keys**: Generate from Settings → API Keys in the platform
252
+ - **Documentation**: [https://docs.matexai.space](https://docs.matexai.space)
253
+ - **Support**: support@matexai.com
254
+
255
+ ## License
256
+
257
+ MIT Ā© Ajay Sharma
258
+
259
+ ---
260
+
261
+ **Made with ā¤ļø by the MATEX AI team**
package/USAGE_GUIDE.md ADDED
@@ -0,0 +1,180 @@
1
+ # MATEX CLI - Quick Start Guide
2
+
3
+ ## Testing the CLI (Without Global Installation)
4
+
5
+ Since `npm link` requires sudo, you can test the CLI directly:
6
+
7
+ ### Method 1: Direct Node Execution
8
+
9
+ ```bash
10
+ cd /Users/ajaysharma/Downloads/FIREBASE_DEPLOYMENT_PACKAGE/matex-cli
11
+
12
+ # Test help
13
+ node dist/index.js --help
14
+
15
+ # Test config
16
+ node dist/index.js config show
17
+
18
+ # Set API key (once you have one)
19
+ node dist/index.js config set-key sk-matex-your-key
20
+
21
+ # Ask a question
22
+ node dist/index.js ask "What is 2+2?"
23
+
24
+ # Start chat
25
+ node dist/index.js chat --model matexcodex
26
+ ```
27
+
28
+ ### Method 2: Create Shell Alias
29
+
30
+ Add to your `~/.zshrc` or `~/.bashrc`:
31
+
32
+ ```bash
33
+ alias matex="node /Users/ajaysharma/Downloads/FIREBASE_DEPLOYMENT_PACKAGE/matex-cli/dist/index.js"
34
+ ```
35
+
36
+ Then reload:
37
+ ```bash
38
+ source ~/.zshrc # or source ~/.bashrc
39
+ ```
40
+
41
+ Now you can use:
42
+ ```bash
43
+ matex --help
44
+ matex ask "Hello!"
45
+ ```
46
+
47
+ ---
48
+
49
+ ## How Users Will Use MATEX CLI
50
+
51
+ ### 1. Install from npm (After Publishing)
52
+
53
+ ```bash
54
+ npm install -g matex-cli
55
+ ```
56
+
57
+ ### 2. Get API Key from Platform
58
+
59
+ - Visit: **https://matexai.space/platform**
60
+ - Go to **Settings** → **API Keys**
61
+ - Click **Generate New API Key**
62
+ - Copy the key (starts with `sk-matex-`)
63
+
64
+ ### 3. Configure CLI
65
+
66
+ ```bash
67
+ matex config set-key sk-matex-xxxxxxxxxxxxx
68
+ ```
69
+
70
+ ### 4. Use for Local Development
71
+
72
+ #### Generate Code for Local Files
73
+
74
+ ```bash
75
+ # Generate a React component
76
+ matex ask "Create a React login component with email and password" --model matexcodex
77
+
78
+ # Copy the output and paste into your local file: src/components/Login.jsx
79
+ ```
80
+
81
+ #### Debug Local Code
82
+
83
+ ```bash
84
+ # Get help with errors
85
+ matex ask "Why am I getting 'Cannot read property of undefined' in JavaScript?"
86
+
87
+ # Explain code
88
+ matex ask "Explain what this regex does: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/"
89
+ ```
90
+
91
+ #### Interactive Development Session
92
+
93
+ ```bash
94
+ matex chat --model matexcodex
95
+
96
+ > I'm building a Node.js API with Express
97
+ > [AI provides starter code]
98
+ > How do I add MongoDB connection?
99
+ > [AI provides MongoDB code]
100
+ > Show me how to create user routes
101
+ > [AI provides routes]
102
+ > exit
103
+ ```
104
+
105
+ Then copy the code from terminal into your local files!
106
+
107
+ #### Save Output to File
108
+
109
+ ```bash
110
+ # Save code directly to a file
111
+ matex ask "Create a Python Flask API" --model matexcodex > api.py
112
+
113
+ # Or save chat history
114
+ matex chat --model matexcodex | tee chat-session.txt
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Use Cases for Laptop/PC Development
120
+
121
+ ### 1. **Quick Code Generation**
122
+ - Generate functions, classes, components
123
+ - Copy-paste into your IDE (VS Code, PyCharm, etc.)
124
+
125
+ ### 2. **Debugging Assistant**
126
+ - Paste error messages
127
+ - Get explanations and solutions
128
+ - Apply fixes to local files
129
+
130
+ ### 3. **Learning & Exploration**
131
+ - Ask "how to" questions
132
+ - Get code examples
133
+ - Understand new concepts
134
+
135
+ ### 4. **Code Review**
136
+ - Ask for optimization suggestions
137
+ - Get best practices
138
+ - Improve code quality
139
+
140
+ ---
141
+
142
+ ## Platform Integration
143
+
144
+ Users will:
145
+ 1. **Sign up** at https://matexai.space/platform
146
+ 2. **Subscribe** to Pro Plus plan
147
+ 3. **Generate API key** from Settings
148
+ 4. **Install CLI**: `npm install -g matex-cli`
149
+ 5. **Configure**: `matex config set-key <key>`
150
+ 6. **Start coding** with AI assistance!
151
+
152
+ ---
153
+
154
+ ## Example Workflow
155
+
156
+ ```bash
157
+ # 1. User is working on a project
158
+ cd ~/projects/my-app
159
+
160
+ # 2. Need to create a new feature
161
+ matex ask "Create a user authentication system in Node.js with JWT" --model matexcodex
162
+
163
+ # 3. Copy the code output
164
+
165
+ # 4. Paste into local file
166
+ # File: src/auth/jwt.js
167
+
168
+ # 5. Need to add tests
169
+ matex ask "Write Jest tests for the JWT authentication code above" --model matexcodex
170
+
171
+ # 6. Copy test code
172
+
173
+ # 7. Paste into test file
174
+ # File: src/auth/jwt.test.js
175
+
176
+ # 8. Run tests locally
177
+ npm test
178
+
179
+ # Done! AI helped write code that runs on your laptop!
180
+ ```
package/bin/matex ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/index.js');
@@ -0,0 +1,34 @@
1
+ export interface ChatMessage {
2
+ role: 'user' | 'assistant' | 'system';
3
+ content: string;
4
+ }
5
+ export interface ChatRequest {
6
+ messages: ChatMessage[];
7
+ model: string;
8
+ temperature?: number;
9
+ max_tokens?: number;
10
+ stream?: boolean;
11
+ }
12
+ export declare class MatexAPIClient {
13
+ private client;
14
+ private apiKey;
15
+ private baseURL;
16
+ constructor(apiKey: string, baseURL?: string);
17
+ /**
18
+ * Send a chat request to the API
19
+ */
20
+ chat(request: ChatRequest): Promise<string>;
21
+ /**
22
+ * Handle Server-Sent Events (SSE) streaming response
23
+ */
24
+ private handleStreamingResponse;
25
+ /**
26
+ * List available API keys (requires Firebase token, not for CLI use)
27
+ */
28
+ listAPIKeys(): Promise<any>;
29
+ /**
30
+ * Test API key validity
31
+ */
32
+ testConnection(): Promise<boolean>;
33
+ }
34
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAmE;IAcxG;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBjD;;OAEG;YACW,uBAAuB;IA4BrC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAKjC;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAY3C"}
@@ -0,0 +1,99 @@
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.MatexAPIClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class MatexAPIClient {
9
+ constructor(apiKey, baseURL = 'https://matexai-backend-550499663766.us-central1.run.app') {
10
+ this.apiKey = apiKey;
11
+ this.baseURL = baseURL;
12
+ this.client = axios_1.default.create({
13
+ baseURL: this.baseURL,
14
+ headers: {
15
+ 'X-API-Key': this.apiKey,
16
+ 'Content-Type': 'application/json',
17
+ },
18
+ timeout: 60000, // 60 seconds
19
+ });
20
+ }
21
+ /**
22
+ * Send a chat request to the API
23
+ */
24
+ async chat(request) {
25
+ try {
26
+ const response = await this.client.post('/api/v1/chat', {
27
+ ...request,
28
+ uid: 'cli-user', // Placeholder, backend uses API key for auth
29
+ });
30
+ // Handle streaming response
31
+ if (request.stream) {
32
+ return this.handleStreamingResponse(response.data);
33
+ }
34
+ return response.data;
35
+ }
36
+ catch (error) {
37
+ if (error.response) {
38
+ throw new Error(`API Error: ${error.response.data.detail || error.response.statusText}`);
39
+ }
40
+ else if (error.request) {
41
+ throw new Error('No response from server. Please check your internet connection.');
42
+ }
43
+ else {
44
+ throw new Error(`Request failed: ${error.message}`);
45
+ }
46
+ }
47
+ }
48
+ /**
49
+ * Handle Server-Sent Events (SSE) streaming response
50
+ */
51
+ async handleStreamingResponse(data) {
52
+ let fullResponse = '';
53
+ // Parse SSE format: "data: {...}\n\n"
54
+ const lines = data.split('\n');
55
+ for (const line of lines) {
56
+ if (line.startsWith('data: ')) {
57
+ const jsonStr = line.substring(6);
58
+ if (jsonStr === '[DONE]') {
59
+ break;
60
+ }
61
+ try {
62
+ const parsed = JSON.parse(jsonStr);
63
+ if (parsed.content) {
64
+ fullResponse += parsed.content;
65
+ }
66
+ }
67
+ catch (e) {
68
+ // Skip invalid JSON
69
+ }
70
+ }
71
+ }
72
+ return fullResponse;
73
+ }
74
+ /**
75
+ * List available API keys (requires Firebase token, not for CLI use)
76
+ */
77
+ async listAPIKeys() {
78
+ const response = await this.client.get('/api/v1/api-keys/list');
79
+ return response.data;
80
+ }
81
+ /**
82
+ * Test API key validity
83
+ */
84
+ async testConnection() {
85
+ try {
86
+ await this.chat({
87
+ messages: [{ role: 'user', content: 'test' }],
88
+ model: 'matexcodex',
89
+ max_tokens: 10,
90
+ });
91
+ return true;
92
+ }
93
+ catch (error) {
94
+ return false;
95
+ }
96
+ }
97
+ }
98
+ exports.MatexAPIClient = MatexAPIClient;
99
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAe7C,MAAa,cAAc;IAKvB,YAAY,MAAc,EAAE,UAAkB,0DAA0D;QACpG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE;gBACL,WAAW,EAAE,IAAI,CAAC,MAAM;gBACxB,cAAc,EAAE,kBAAkB;aACrC;YACD,OAAO,EAAE,KAAK,EAAE,aAAa;SAChC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC3B,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE;gBACpD,GAAG,OAAO;gBACV,GAAG,EAAE,UAAU,EAAE,6CAA6C;aACjE,CAAC,CAAC;YAEH,4BAA4B;YAC5B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC;QACzB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,C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AC;gBACZ,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;gBAC7C,KAAK,EAAE,YAAY;gBACnB,UAAU,EAAE,EAAE;aACjB,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ;AApGD,wCAoGC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const askCommand: Command;
3
+ //# sourceMappingURL=ask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../src/commands/ask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,UAAU,SAuDjB,CAAC"}
@@ -0,0 +1,63 @@
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.askCommand = 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
+ exports.askCommand = new commander_1.Command('ask')
13
+ .description('Ask a single question to MATEX AI')
14
+ .argument('<question>', 'Your question')
15
+ .option('-m, --model <model>', 'AI model to use (matexcodex, matexai, elite, matexspirit)', config_1.configManager.getDefaultModel())
16
+ .option('-t, --temperature <number>', 'Temperature (0-1)', '0.7')
17
+ .option('--max-tokens <number>', 'Maximum tokens in response', '4000')
18
+ .action(async (question, options) => {
19
+ try {
20
+ // Check for API key
21
+ const apiKey = config_1.configManager.getAPIKey();
22
+ if (!apiKey) {
23
+ console.error(chalk_1.default.red('āŒ No API key configured.'));
24
+ console.log(chalk_1.default.yellow('Run: matex config set-key <your-api-key>'));
25
+ process.exit(1);
26
+ }
27
+ // Create API client
28
+ const client = new client_1.MatexAPIClient(apiKey, config_1.configManager.getBaseURL());
29
+ // Show thinking indicator
30
+ spinner_1.spinner.start(`Thinking with ${options.model}...`);
31
+ // Send request
32
+ const response = await client.chat({
33
+ messages: [
34
+ { role: 'user', content: question }
35
+ ],
36
+ model: options.model,
37
+ temperature: parseFloat(options.temperature),
38
+ max_tokens: parseInt(options.maxTokens),
39
+ stream: false,
40
+ });
41
+ spinner_1.spinner.succeed('Response received!');
42
+ // Display response
43
+ console.log(chalk_1.default.cyan('\nšŸ’¬ MATEX AI:\n'));
44
+ console.log(chalk_1.default.white(response));
45
+ console.log();
46
+ }
47
+ catch (error) {
48
+ spinner_1.spinner.fail('Request failed');
49
+ if (error.message.includes('403')) {
50
+ console.error(chalk_1.default.red('\nāŒ Invalid or revoked API key.'));
51
+ console.log(chalk_1.default.yellow('Please check your API key or generate a new one from the MATEX AI platform.'));
52
+ }
53
+ else if (error.message.includes('429')) {
54
+ console.error(chalk_1.default.red('\nāŒ Rate limit exceeded.'));
55
+ console.log(chalk_1.default.yellow('Please wait a moment before trying again.'));
56
+ }
57
+ else {
58
+ console.error(chalk_1.default.red(`\nāŒ Error: ${error.message}`));
59
+ }
60
+ process.exit(1);
61
+ }
62
+ });
63
+ //# sourceMappingURL=ask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask.js","sourceRoot":"","sources":["../../src/commands/ask.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,4CAAgD;AAChD,0CAA+C;AAC/C,8CAA2C;AAE9B,QAAA,UAAU,GAAG,IAAI,mBAAO,CAAC,KAAK,CAAC;KACvC,WAAW,CAAC,mCAAmC,CAAC;KAChD,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;KACvC,MAAM,CAAC,qBAAqB,EAAE,2DAA2D,EAAE,sBAAa,CAAC,eAAe,EAAE,CAA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AC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,EAAE,CAAC;IAElB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,iBAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,6EAA6E,CAAC,CAAC,CAAC;QAC7G,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;YACrD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const chatCommand: Command;
3
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,WAAW,SA6FlB,CAAC"}