@klitchevo/code-council 0.0.1

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 (58) hide show
  1. package/.env.example +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +342 -0
  4. package/dist/config.d.ts +48 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/config.js +61 -0
  7. package/dist/constants.d.ts +33 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +36 -0
  10. package/dist/errors.d.ts +53 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +92 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +79 -0
  16. package/dist/logger.d.ts +22 -0
  17. package/dist/logger.d.ts.map +1 -0
  18. package/dist/logger.js +62 -0
  19. package/dist/prompts/backend-review.d.ts +6 -0
  20. package/dist/prompts/backend-review.d.ts.map +1 -0
  21. package/dist/prompts/backend-review.js +28 -0
  22. package/dist/prompts/code-review.d.ts +6 -0
  23. package/dist/prompts/code-review.d.ts.map +1 -0
  24. package/dist/prompts/code-review.js +18 -0
  25. package/dist/prompts/frontend-review.d.ts +6 -0
  26. package/dist/prompts/frontend-review.d.ts.map +1 -0
  27. package/dist/prompts/frontend-review.js +28 -0
  28. package/dist/prompts/plan-review.d.ts +6 -0
  29. package/dist/prompts/plan-review.d.ts.map +1 -0
  30. package/dist/prompts/plan-review.js +29 -0
  31. package/dist/review-client.d.ts +75 -0
  32. package/dist/review-client.d.ts.map +1 -0
  33. package/dist/review-client.js +116 -0
  34. package/dist/schemas.d.ts +60 -0
  35. package/dist/schemas.d.ts.map +1 -0
  36. package/dist/schemas.js +46 -0
  37. package/dist/tools/factory.d.ts +20 -0
  38. package/dist/tools/factory.d.ts.map +1 -0
  39. package/dist/tools/factory.js +55 -0
  40. package/dist/tools/list-config.d.ts +9 -0
  41. package/dist/tools/list-config.d.ts.map +1 -0
  42. package/dist/tools/list-config.js +31 -0
  43. package/dist/tools/review-backend.d.ts +22 -0
  44. package/dist/tools/review-backend.d.ts.map +1 -0
  45. package/dist/tools/review-backend.js +38 -0
  46. package/dist/tools/review-code.d.ts +15 -0
  47. package/dist/tools/review-code.d.ts.map +1 -0
  48. package/dist/tools/review-code.js +29 -0
  49. package/dist/tools/review-frontend.d.ts +22 -0
  50. package/dist/tools/review-frontend.d.ts.map +1 -0
  51. package/dist/tools/review-frontend.js +38 -0
  52. package/dist/tools/review-plan.d.ts +22 -0
  53. package/dist/tools/review-plan.d.ts.map +1 -0
  54. package/dist/tools/review-plan.js +35 -0
  55. package/dist/utils/parallel-executor.d.ts +10 -0
  56. package/dist/utils/parallel-executor.d.ts.map +1 -0
  57. package/dist/utils/parallel-executor.js +21 -0
  58. package/package.json +81 -0
package/.env.example ADDED
@@ -0,0 +1,21 @@
1
+ # OpenRouter API Key (required)
2
+ # Get your key from: https://openrouter.ai/keys
3
+ OPENROUTER_API_KEY=your-api-key-here
4
+
5
+ # Optional: Customize which models to use for each review type
6
+ # Format: Comma-separated list of model identifiers
7
+ # If not set, defaults to: minimax/minimax-m2.1,x-ai/grok-code-fast-1
8
+
9
+ # Models for general code reviews
10
+ # CODE_REVIEW_MODELS=anthropic/claude-3.5-sonnet,openai/gpt-4-turbo
11
+
12
+ # Models for frontend reviews (accessibility, performance, UX)
13
+ # FRONTEND_REVIEW_MODELS=anthropic/claude-3.5-sonnet
14
+
15
+ # Models for backend reviews (security, architecture, performance)
16
+ # BACKEND_REVIEW_MODELS=openai/gpt-4-turbo,google/gemini-pro
17
+
18
+ # Models for plan reviews (before implementation)
19
+ # PLAN_REVIEW_MODELS=anthropic/claude-3.5-sonnet,openai/gpt-4-turbo
20
+
21
+ # Browse available models at: https://openrouter.ai/models
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OpenRouter Review MCP Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,342 @@
1
+ # Code Council
2
+
3
+ [![npm version](https://img.shields.io/npm/v/code-council.svg)](https://www.npmjs.com/package/code-council)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![CI](https://github.com/klitchevo/code-council/workflows/CI/badge.svg)](https://github.com/klitchevo/code-council/actions)
6
+ [![codecov](https://codecov.io/gh/klitchevo/code-council/branch/main/graph/badge.svg)](https://codecov.io/gh/klitchevo/code-council)
7
+
8
+ **Your AI Code Review Council** - Get diverse perspectives from multiple AI models in parallel.
9
+
10
+ An MCP (Model Context Protocol) server that provides AI-powered code review using multiple models from [OpenRouter](https://openrouter.ai). Think of it as assembling a council of AI experts to review your code, each bringing their unique perspective.
11
+
12
+ ## Features
13
+
14
+ - 🔍 **Multi-Model Code Review** - Get diverse perspectives by running reviews across multiple AI models simultaneously
15
+ - 🎨 **Frontend Review** - Specialized reviews for accessibility, performance, and UX
16
+ - 🔒 **Backend Review** - Security, architecture, and performance analysis
17
+ - 📋 **Plan Review** - Review implementation plans before writing code
18
+ - ⚡ **Parallel Execution** - All models run concurrently for fast results
19
+
20
+ ## Quick Start
21
+
22
+ ### Using with npx (Recommended)
23
+
24
+ The easiest way to use this MCP server is via npx. Configure your MCP client with environment variable for the API key:
25
+
26
+ #### Claude Desktop
27
+
28
+ Add to your `claude_desktop_config.json`:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "code-council": {
34
+ "command": "npx",
35
+ "args": ["-y", "code-council"],
36
+ "env": {
37
+ "OPENROUTER_API_KEY": "your-api-key-here"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ **With custom models:**
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "code-council": {
50
+ "command": "npx",
51
+ "args": ["-y", "code-council"],
52
+ "env": {
53
+ "OPENROUTER_API_KEY": "your-api-key-here",
54
+ "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo"],
55
+ "FRONTEND_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet"],
56
+ "BACKEND_REVIEW_MODELS": ["openai/gpt-4-turbo", "google/gemini-pro"]
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ #### Cursor
64
+
65
+ Add to your Cursor MCP settings (`.cursor/mcp.json` or similar):
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "code-council": {
71
+ "command": "npx",
72
+ "args": ["-y", "code-council"],
73
+ "env": {
74
+ "OPENROUTER_API_KEY": "your-api-key-here"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ #### Other MCP Clients
82
+
83
+ For any MCP client that supports environment variables:
84
+
85
+ ```json
86
+ {
87
+ "command": "npx",
88
+ "args": ["-y", "code-council"],
89
+ "env": {
90
+ "OPENROUTER_API_KEY": "your-openrouter-api-key"
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Installation (Alternative)
96
+
97
+ If you prefer to install globally:
98
+
99
+ ```bash
100
+ npm install -g code-council
101
+ ```
102
+
103
+ Then configure without npx:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "code-council": {
109
+ "command": "code-council",
110
+ "env": {
111
+ "OPENROUTER_API_KEY": "your-api-key-here"
112
+ }
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ## Getting an API Key
119
+
120
+ 1. Sign up at [OpenRouter](https://openrouter.ai)
121
+ 2. Go to [Keys](https://openrouter.ai/keys) in your dashboard
122
+ 3. Create a new API key
123
+ 4. Add credits to your account at [Credits](https://openrouter.ai/credits)
124
+
125
+ ## Security Best Practices
126
+
127
+ ⚠️ **IMPORTANT**: Always provide your API key via environment variables in the MCP configuration, NOT in a `.env` file or hardcoded in config files.
128
+
129
+ ### ✅ DO:
130
+ - Store the API key in the `env` section of your MCP client configuration
131
+ - The key stays in your local config file and is never committed to version control
132
+ - Each MCP client isolates environment variables per server
133
+
134
+ ### ❌ DON'T:
135
+ - Don't put the API key directly in `.mcp.json` or similar config files
136
+ - Don't commit API keys to git repositories
137
+ - Don't share config files containing API keys
138
+
139
+ ## Available Tools
140
+
141
+ ### `review_code`
142
+
143
+ Review code for quality, bugs, performance, and security issues.
144
+
145
+ **Parameters:**
146
+ - `code` (required): The code to review
147
+ - `language` (optional): Programming language
148
+ - `context` (optional): Additional context about the code
149
+
150
+ **Example usage in Claude:**
151
+ ```
152
+ Use review_code to check this TypeScript function:
153
+ [paste your code]
154
+ ```
155
+
156
+ ### `review_frontend`
157
+
158
+ Review frontend code with focus on accessibility, performance, and UX.
159
+
160
+ **Parameters:**
161
+ - `code` (required): The frontend code to review
162
+ - `framework` (optional): Framework name (e.g., react, vue, svelte)
163
+ - `review_type` (optional): `accessibility`, `performance`, `ux`, or `full` (default)
164
+ - `context` (optional): Additional context
165
+
166
+ **Example usage in Claude:**
167
+ ```
168
+ Use review_frontend with review_type=accessibility to check this React component:
169
+ [paste your component]
170
+ ```
171
+
172
+ ### `review_backend`
173
+
174
+ Review backend code for security, performance, and architecture.
175
+
176
+ **Parameters:**
177
+ - `code` (required): The backend code to review
178
+ - `language` (optional): Language/framework (e.g., node, python, go, rust)
179
+ - `review_type` (optional): `security`, `performance`, `architecture`, or `full` (default)
180
+ - `context` (optional): Additional context
181
+
182
+ **Example usage in Claude:**
183
+ ```
184
+ Use review_backend with review_type=security to analyze this API endpoint:
185
+ [paste your code]
186
+ ```
187
+
188
+ ### `review_plan`
189
+
190
+ Review implementation plans BEFORE coding to catch issues early.
191
+
192
+ **Parameters:**
193
+ - `plan` (required): The implementation plan to review
194
+ - `review_type` (optional): `feasibility`, `completeness`, `risks`, `timeline`, or `full` (default)
195
+ - `context` (optional): Project constraints or context
196
+
197
+ **Example usage in Claude:**
198
+ ```
199
+ Use review_plan to analyze this implementation plan:
200
+ [paste your plan]
201
+ ```
202
+
203
+ ### `list_review_config`
204
+
205
+ Show which AI models are currently configured for each review type.
206
+
207
+ ## Configuration
208
+
209
+ ### Customizing Models
210
+
211
+ You can customize which AI models are used for reviews by setting environment variables in your MCP client configuration. Each review type can use different models.
212
+
213
+ **Available Environment Variables:**
214
+ - `CODE_REVIEW_MODELS` - Models for general code reviews
215
+ - `FRONTEND_REVIEW_MODELS` - Models for frontend reviews
216
+ - `BACKEND_REVIEW_MODELS` - Models for backend reviews
217
+ - `PLAN_REVIEW_MODELS` - Models for plan reviews
218
+
219
+ **Format:** Array of strings (JSON array)
220
+
221
+ **Example:**
222
+ ```json
223
+ {
224
+ "mcpServers": {
225
+ "code-council": {
226
+ "command": "npx",
227
+ "args": ["-y", "code-council"],
228
+ "env": {
229
+ "OPENROUTER_API_KEY": "your-api-key",
230
+ "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo", "google/gemini-pro"],
231
+ "FRONTEND_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet"],
232
+ "BACKEND_REVIEW_MODELS": ["openai/gpt-4-turbo", "anthropic/claude-3.5-sonnet"]
233
+ }
234
+ }
235
+ }
236
+ }
237
+ ```
238
+
239
+ **Default Models:**
240
+ If you don't specify models, the server uses these defaults:
241
+ - `minimax/minimax-m2.1`
242
+ - `x-ai/grok-code-fast-1`
243
+
244
+ **Finding Models:**
245
+ Browse all available models at [OpenRouter Models](https://openrouter.ai/models). Popular choices include:
246
+ - `anthropic/claude-3.5-sonnet` - Excellent for code review
247
+ - `openai/gpt-4-turbo` - Strong general-purpose model
248
+ - `google/gemini-pro` - Fast and cost-effective
249
+ - `meta-llama/llama-3.1-70b-instruct` - Open source option
250
+ - `x-ai/grok-code-fast-1` - Optimized for code
251
+ - `minimax/minimax-m2.1` - Good balance of speed and quality
252
+
253
+ ### Local Development
254
+
255
+ 1. Clone the repository:
256
+ ```bash
257
+ git clone <your-repo-url>
258
+ cd multi-agent
259
+ ```
260
+
261
+ 2. Install dependencies:
262
+ ```bash
263
+ npm install
264
+ ```
265
+
266
+ 3. Create `.env` file:
267
+ ```bash
268
+ cp .env.example .env
269
+ # Edit .env and add your OPENROUTER_API_KEY
270
+ ```
271
+
272
+ 4. Build:
273
+ ```bash
274
+ npm run build
275
+ ```
276
+
277
+ 5. Run:
278
+ ```bash
279
+ npm start
280
+ # or use the convenience script:
281
+ ./run.sh
282
+ ```
283
+
284
+ 6. For development with auto-rebuild:
285
+ ```bash
286
+ npm run dev
287
+ ```
288
+
289
+ ## How It Works
290
+
291
+ 1. The MCP server exposes tools that Claude (or other MCP clients) can call
292
+ 2. When you ask Claude to review code, it calls the appropriate tool
293
+ 3. The server sends your code to multiple AI models via OpenRouter in parallel
294
+ 4. Results from all models are aggregated and returned
295
+ 5. Claude presents you with diverse perspectives from different AI models
296
+
297
+ ## Cost Considerations
298
+
299
+ - Each review runs across multiple models simultaneously
300
+ - Costs vary by model - check [OpenRouter pricing](https://openrouter.ai/models)
301
+ - You can reduce costs by:
302
+ - Using fewer models (edit `src/config.ts`)
303
+ - Choosing cheaper models
304
+ - Using specific `review_type` options instead of `full` reviews
305
+
306
+ ## Troubleshooting
307
+
308
+ ### "OPENROUTER_API_KEY environment variable is required"
309
+
310
+ Make sure you've added the API key to the `env` section of your MCP client configuration, not just in a separate `.env` file.
311
+
312
+ ### Reviews are slow
313
+
314
+ - This is expected when using multiple models in parallel
315
+ - Consider using fewer models or faster models
316
+ - Check OpenRouter status at [status.openrouter.ai](https://status.openrouter.ai)
317
+
318
+ ### Models returning errors
319
+
320
+ - Check that you have sufficient credits in your OpenRouter account
321
+ - Some models may have rate limits or temporary availability issues
322
+ - The server will show which models succeeded and which failed
323
+
324
+ ## Requirements
325
+
326
+ - Node.js >= 18.0.0
327
+ - OpenRouter API key
328
+ - MCP-compatible client (Claude Desktop, Cursor, etc.)
329
+
330
+ ## License
331
+
332
+ MIT
333
+
334
+ ## Contributing
335
+
336
+ Contributions welcome! Please open an issue or PR.
337
+
338
+ ## Links
339
+
340
+ - [OpenRouter](https://openrouter.ai) - Multi-model AI API
341
+ - [Model Context Protocol](https://modelcontextprotocol.io) - MCP specification
342
+ - [Claude Desktop](https://claude.ai/download) - MCP-compatible AI assistant
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Configuration for Code Council MCP Server
3
+ *
4
+ * Models are configured via environment variables as arrays of strings.
5
+ *
6
+ * Find models at: https://openrouter.ai/models
7
+ *
8
+ * Example MCP config:
9
+ * {
10
+ * "env": {
11
+ * "OPENROUTER_API_KEY": "your-key",
12
+ * "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo"]
13
+ * }
14
+ * }
15
+ *
16
+ * Single model:
17
+ * {
18
+ * "env": {
19
+ * "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet"]
20
+ * }
21
+ * }
22
+ *
23
+ * If not configured, defaults to minimax/minimax-m2.1 and x-ai/grok-code-fast-1
24
+ */
25
+ /**
26
+ * Parse model list from environment variable
27
+ * Accepts: array of strings only
28
+ * Exported for testing
29
+ */
30
+ export declare function parseModels(envVar: string | string[] | undefined, defaults: string[]): string[];
31
+ /**
32
+ * Models to use for code review (runs in parallel)
33
+ */
34
+ export declare const CODE_REVIEW_MODELS: string[];
35
+ /**
36
+ * Models to use for frontend review (runs in parallel)
37
+ */
38
+ export declare const FRONTEND_REVIEW_MODELS: string[];
39
+ /**
40
+ * Models to use for backend review (runs in parallel)
41
+ */
42
+ export declare const BACKEND_REVIEW_MODELS: string[];
43
+ /**
44
+ * Models to use for plan review (runs in parallel)
45
+ * Reviews implementation plans before code is written
46
+ */
47
+ export declare const PLAN_REVIEW_MODELS: string[];
48
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACrC,QAAQ,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CAgBV;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAGtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAG1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAGtC,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Configuration for Code Council MCP Server
3
+ *
4
+ * Models are configured via environment variables as arrays of strings.
5
+ *
6
+ * Find models at: https://openrouter.ai/models
7
+ *
8
+ * Example MCP config:
9
+ * {
10
+ * "env": {
11
+ * "OPENROUTER_API_KEY": "your-key",
12
+ * "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo"]
13
+ * }
14
+ * }
15
+ *
16
+ * Single model:
17
+ * {
18
+ * "env": {
19
+ * "CODE_REVIEW_MODELS": ["anthropic/claude-3.5-sonnet"]
20
+ * }
21
+ * }
22
+ *
23
+ * If not configured, defaults to minimax/minimax-m2.1 and x-ai/grok-code-fast-1
24
+ */
25
+ import { DEFAULT_MODELS } from "./constants";
26
+ /**
27
+ * Parse model list from environment variable
28
+ * Accepts: array of strings only
29
+ * Exported for testing
30
+ */
31
+ export function parseModels(envVar, defaults) {
32
+ // Not configured - use defaults
33
+ if (envVar === undefined || envVar === null) {
34
+ return defaults;
35
+ }
36
+ // Must be an array
37
+ if (Array.isArray(envVar)) {
38
+ const filtered = envVar.filter((m) => m && m.trim().length > 0);
39
+ return filtered.length > 0 ? filtered : defaults;
40
+ }
41
+ // String provided - invalid format - throw error
42
+ throw new Error(`Model configuration must be an array of strings, got: ${typeof envVar}. Example: ["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo"]`);
43
+ }
44
+ /**
45
+ * Models to use for code review (runs in parallel)
46
+ */
47
+ export const CODE_REVIEW_MODELS = parseModels(process.env.CODE_REVIEW_MODELS, DEFAULT_MODELS);
48
+ /**
49
+ * Models to use for frontend review (runs in parallel)
50
+ */
51
+ export const FRONTEND_REVIEW_MODELS = parseModels(process.env.FRONTEND_REVIEW_MODELS, DEFAULT_MODELS);
52
+ /**
53
+ * Models to use for backend review (runs in parallel)
54
+ */
55
+ export const BACKEND_REVIEW_MODELS = parseModels(process.env.BACKEND_REVIEW_MODELS, DEFAULT_MODELS);
56
+ /**
57
+ * Models to use for plan review (runs in parallel)
58
+ * Reviews implementation plans before code is written
59
+ */
60
+ export const PLAN_REVIEW_MODELS = parseModels(process.env.PLAN_REVIEW_MODELS, DEFAULT_MODELS);
61
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Application-wide constants and configuration values.
3
+ * Extracted from inline "magic numbers" for maintainability.
4
+ */
5
+ /**
6
+ * Maximum input sizes to prevent abuse and excessive API costs
7
+ */
8
+ export declare const INPUT_LIMITS: {
9
+ /** Maximum code length in characters (100KB) */
10
+ readonly MAX_CODE_LENGTH: 100000;
11
+ /** Maximum context length in characters */
12
+ readonly MAX_CONTEXT_LENGTH: 5000;
13
+ /** Maximum language name length */
14
+ readonly MAX_LANGUAGE_LENGTH: 50;
15
+ /** Maximum plan length in characters */
16
+ readonly MAX_PLAN_LENGTH: 50000;
17
+ /** Maximum number of models to run in parallel */
18
+ readonly MAX_MODELS: 10;
19
+ };
20
+ /**
21
+ * OpenRouter API configuration
22
+ */
23
+ export declare const LLM_CONFIG: {
24
+ /** Default temperature for model responses */
25
+ readonly DEFAULT_TEMPERATURE: 0.3;
26
+ /** Default max tokens for responses */
27
+ readonly DEFAULT_MAX_TOKENS: 4096;
28
+ };
29
+ /**
30
+ * Default models if not configured via environment variables
31
+ */
32
+ export declare const DEFAULT_MODELS: string[];
33
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;IACxB,gDAAgD;;IAEhD,2CAA2C;;IAE3C,mCAAmC;;IAEnC,wCAAwC;;IAExC,kDAAkD;;CAEzC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;IACtB,8CAA8C;;IAE9C,uCAAuC;;CAE9B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,EAGlC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Application-wide constants and configuration values.
3
+ * Extracted from inline "magic numbers" for maintainability.
4
+ */
5
+ /**
6
+ * Maximum input sizes to prevent abuse and excessive API costs
7
+ */
8
+ export const INPUT_LIMITS = {
9
+ /** Maximum code length in characters (100KB) */
10
+ MAX_CODE_LENGTH: 100_000,
11
+ /** Maximum context length in characters */
12
+ MAX_CONTEXT_LENGTH: 5_000,
13
+ /** Maximum language name length */
14
+ MAX_LANGUAGE_LENGTH: 50,
15
+ /** Maximum plan length in characters */
16
+ MAX_PLAN_LENGTH: 50_000,
17
+ /** Maximum number of models to run in parallel */
18
+ MAX_MODELS: 10,
19
+ };
20
+ /**
21
+ * OpenRouter API configuration
22
+ */
23
+ export const LLM_CONFIG = {
24
+ /** Default temperature for model responses */
25
+ DEFAULT_TEMPERATURE: 0.3,
26
+ /** Default max tokens for responses */
27
+ DEFAULT_MAX_TOKENS: 4096,
28
+ };
29
+ /**
30
+ * Default models if not configured via environment variables
31
+ */
32
+ export const DEFAULT_MODELS = [
33
+ "minimax/minimax-m2.1",
34
+ "x-ai/grok-code-fast-1",
35
+ ];
36
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Custom error classes for better error handling and user feedback.
3
+ */
4
+ /**
5
+ * Base error class for all application errors
6
+ */
7
+ export declare class AppError extends Error {
8
+ readonly code: string;
9
+ readonly userMessage?: string | undefined;
10
+ constructor(message: string, code: string, userMessage?: string | undefined);
11
+ }
12
+ /**
13
+ * Error thrown when OpenRouter API calls fail
14
+ */
15
+ export declare class OpenRouterError extends AppError {
16
+ readonly statusCode?: number | undefined;
17
+ readonly retryable: boolean;
18
+ constructor(message: string, statusCode?: number | undefined, retryable?: boolean);
19
+ }
20
+ /**
21
+ * Error thrown when configuration is invalid
22
+ */
23
+ export declare class ConfigurationError extends AppError {
24
+ readonly field: string;
25
+ constructor(message: string, field: string);
26
+ }
27
+ /**
28
+ * Error thrown when input validation fails
29
+ */
30
+ export declare class ValidationError extends AppError {
31
+ readonly field: string;
32
+ constructor(message: string, field: string);
33
+ }
34
+ /**
35
+ * MCP tool response type
36
+ */
37
+ type MCPToolResponse = {
38
+ content: Array<{
39
+ type: "text";
40
+ text: string;
41
+ }>;
42
+ isError?: boolean;
43
+ };
44
+ /**
45
+ * Format any error for display to users (string format)
46
+ */
47
+ export declare function formatErrorMessage(error: unknown): string;
48
+ /**
49
+ * Format error for MCP tool response
50
+ */
51
+ export declare function formatError(error: unknown): MCPToolResponse;
52
+ export {};
53
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAGjB,IAAI,EAAE,MAAM;aACZ,WAAW,CAAC,EAAE,MAAM;gBAFpC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,YAAA;CAMrC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;aAG3B,UAAU,CAAC,EAAE,MAAM;aACnB,SAAS,EAAE,OAAO;gBAFlC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,SAAS,GAAE,OAAe;CAU3C;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;aAG9B,KAAK,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,KAAK,EAAE,MAAM;CAI9B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;aAG3B,KAAK,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,KAAK,EAAE,MAAM;CAQ9B;AAED;;GAEG;AACH,KAAK,eAAe,GAAG;IACtB,OAAO,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA0BzD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAU3D"}