@lutery/vision-mcp 1.0.2 → 1.1.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.
- package/README.md +93 -91
- package/dist/adapters/coding-plan-adapter.d.ts +30 -0
- package/dist/adapters/coding-plan-adapter.d.ts.map +1 -0
- package/dist/adapters/coding-plan-adapter.js +338 -0
- package/dist/adapters/coding-plan-adapter.js.map +1 -0
- package/dist/prompts/kilo-code-system.d.ts +16 -0
- package/dist/prompts/kilo-code-system.d.ts.map +1 -0
- package/dist/prompts/kilo-code-system.js +118 -0
- package/dist/prompts/kilo-code-system.js.map +1 -0
- package/dist/providers/provider-registry.d.ts.map +1 -1
- package/dist/providers/provider-registry.js +21 -0
- package/dist/providers/provider-registry.js.map +1 -1
- package/dist/utils/thinking-filter.d.ts.map +1 -1
- package/dist/utils/thinking-filter.js +2 -1
- package/dist/utils/thinking-filter.js.map +1 -1
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
# Vision MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An STDIO-based MCP Server that provides unified image analysis capabilities for LLMs lacking visual abilities (or with expensive vision models). By switching Providers (via environment variables), you can use multimodal models from different platforms/vendors.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Supported Models / Providers
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Select a provider via `VISION_MODEL_TYPE`:
|
|
8
8
|
|
|
9
|
-
| type | Provider |
|
|
10
|
-
|
|
11
|
-
| `glm` |
|
|
12
|
-
| `siliconflow` | SiliconFlow
|
|
13
|
-
| `modelscope` | ModelScope API-Inference
|
|
14
|
-
| `openai` | OpenAI | `https://api.openai.com/v1` | `gpt-4o` |
|
|
15
|
-
| `claude` | Anthropic Claude
|
|
16
|
-
| `gemini` | Google Gemini
|
|
9
|
+
| type | Provider | Default `VISION_API_BASE_URL` | Default `VISION_MODEL_NAME` | Notes |
|
|
10
|
+
|------|----------|-------------------------------|----------------------------|-------|
|
|
11
|
+
| `glm` | Zhipu GLM-4.6V | `https://open.bigmodel.cn/api/paas/v4` | `glm-4.6v` | GLM-4.6V Zhipu vision model |
|
|
12
|
+
| `siliconflow` | SiliconFlow (OpenAI compatible) | `https://api.siliconflow.cn/v1` | `Qwen/Qwen2-VL-72B-Instruct` | Rich vision model selection |
|
|
13
|
+
| `modelscope` | ModelScope API-Inference (OpenAI compatible) | `https://api-inference.modelscope.cn/v1` | `ZhipuAI/GLM-4.6V` | Requires real-name verification/Aliyun binding, subject to quotas |
|
|
14
|
+
| `openai` | OpenAI | `https://api.openai.com/v1` | `gpt-4o` | Chat Completions compatible |
|
|
15
|
+
| `claude` | Anthropic Claude (Messages API) | `https://api.anthropic.com` | `claude-3-5-sonnet-20241022` | `baseUrl` should not include `/v1` |
|
|
16
|
+
| `gemini` | Google Gemini (generateContent API) | `https://generativelanguage.googleapis.com` | `gemini-2.0-flash-exp` | Official entry; proxies/gateways can override via `VISION_API_BASE_URL` |
|
|
17
|
+
| `coding-plan` | Coding Plan (Kilo Code Compatible) | `https://coding.dashscope.aliyuncs.com/v1` | `kimi-k2.5` | Simulates Kilo Code client identity |
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Get API Key / Token (from respective platform consoles):
|
|
19
20
|
|
|
20
|
-
- GLM
|
|
21
|
-
- SiliconFlow
|
|
22
|
-
- ModelScope
|
|
23
|
-
- OpenAI
|
|
24
|
-
- Claude
|
|
25
|
-
- Gemini
|
|
21
|
+
- GLM (Zhipu): https://open.bigmodel.cn/
|
|
22
|
+
- SiliconFlow: https://cloud.siliconflow.cn/
|
|
23
|
+
- ModelScope: https://modelscope.cn/my/myaccesstoken
|
|
24
|
+
- OpenAI: https://platform.openai.com/
|
|
25
|
+
- Claude (Anthropic): https://console.anthropic.com/
|
|
26
|
+
- Gemini (Google AI): https://ai.google.dev/
|
|
27
|
+
- Coding Plan: Aliyun Coding Plan subscription
|
|
26
28
|
|
|
27
|
-
##
|
|
29
|
+
## Features
|
|
28
30
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
31
|
+
- One-click provider switching (just change environment variables)
|
|
32
|
+
- Image input support: URL / base64 data URL / local file path
|
|
33
|
+
- Built-in system prompt templates: UI analysis, OCR, object detection, structured extraction, etc.
|
|
34
|
+
- Security: Automatic API key masking in logs, filters model-returned thinking/reasoning content
|
|
35
|
+
- MCP compliant: stdout reserved for JSON-RPC, logs go to stderr
|
|
34
36
|
|
|
35
|
-
##
|
|
37
|
+
## Installation & Usage
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Requirements: Node.js >= 18
|
|
38
40
|
|
|
39
|
-
###
|
|
41
|
+
### Running as NPM package from MCP client (Recommended)
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
Configure your MCP client (e.g., Claude Desktop) to use `npx`:
|
|
42
44
|
|
|
43
45
|
```json
|
|
44
46
|
{
|
|
@@ -57,18 +59,18 @@
|
|
|
57
59
|
}
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
- `VISION_MODEL_NAME` / `VISION_API_BASE_URL`
|
|
62
|
-
-
|
|
62
|
+
Notes:
|
|
63
|
+
- `VISION_MODEL_NAME` / `VISION_API_BASE_URL` are optional (will use provider defaults)
|
|
64
|
+
- For more configuration options, refer to `.env.example`
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
You can also install globally and use the executable directly (binary name: `vision-mcp`):
|
|
65
67
|
|
|
66
68
|
```bash
|
|
67
69
|
npm i -g @lutery/vision-mcp
|
|
68
70
|
vision-mcp
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
###
|
|
73
|
+
### Local development
|
|
72
74
|
|
|
73
75
|
```bash
|
|
74
76
|
cd mcp/vision_mcp
|
|
@@ -77,65 +79,65 @@ npm run build
|
|
|
77
79
|
node dist/index.js
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
On successful startup, you'll see `Vision MCP Server is running on stdio` in stderr.
|
|
81
83
|
|
|
82
|
-
##
|
|
84
|
+
## Configuration (Environment Variables)
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
Minimum required:
|
|
85
87
|
|
|
86
|
-
- `VISION_MODEL_TYPE
|
|
87
|
-
- `VISION_API_KEY
|
|
88
|
+
- `VISION_MODEL_TYPE`: Select provider
|
|
89
|
+
- `VISION_API_KEY`: Key/token for the selected provider
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
Common optional:
|
|
90
92
|
|
|
91
|
-
|
|
|
92
|
-
|
|
93
|
-
| `VISION_MODEL_NAME` |
|
|
94
|
-
| `VISION_API_BASE_URL` | API
|
|
95
|
-
| `VISION_API_TIMEOUT` |
|
|
96
|
-
| `VISION_MAX_RETRIES` |
|
|
97
|
-
| `VISION_STRICT_URL_VALIDATION` |
|
|
98
|
-
| `LOG_LEVEL` |
|
|
93
|
+
| Variable | Description | Default |
|
|
94
|
+
|----------|-------------|---------|
|
|
95
|
+
| `VISION_MODEL_NAME` | Model name | Provider built-in defaults |
|
|
96
|
+
| `VISION_API_BASE_URL` | API base URL (without specific endpoint) | Provider built-in defaults |
|
|
97
|
+
| `VISION_API_TIMEOUT` | Timeout (milliseconds) | `60000` |
|
|
98
|
+
| `VISION_MAX_RETRIES` | Maximum retry attempts | `2` |
|
|
99
|
+
| `VISION_STRICT_URL_VALIDATION` | Strict validation for image URLs ending in `.jpg/.jpeg/.png/.webp` | `true` |
|
|
100
|
+
| `LOG_LEVEL` | Log level: `debug`/`info`/`warn`/`error` | `info` |
|
|
99
101
|
|
|
100
|
-
Provider
|
|
102
|
+
Provider-specific configuration:
|
|
101
103
|
|
|
102
104
|
- Claude
|
|
103
|
-
- `VISION_CLAUDE_API_VERSION
|
|
105
|
+
- `VISION_CLAUDE_API_VERSION`: Anthropic API version (default `2023-06-01`)
|
|
104
106
|
|
|
105
|
-
## MCP
|
|
107
|
+
## MCP Tools
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
This server registers 3 tools:
|
|
108
110
|
|
|
109
111
|
### 1) `analyze_image`
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
Parameters:
|
|
112
114
|
|
|
113
115
|
```json
|
|
114
116
|
{
|
|
115
117
|
"image": "https://example.com/a.png",
|
|
116
|
-
"prompt": "
|
|
118
|
+
"prompt": "Describe the components in this interface",
|
|
117
119
|
"output_format": "text",
|
|
118
120
|
"template": "ui-analysis"
|
|
119
121
|
}
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
- `image
|
|
124
|
-
- `prompt
|
|
125
|
-
- `output_format
|
|
126
|
-
- `template
|
|
124
|
+
Field descriptions:
|
|
125
|
+
- `image`: Supports URL / base64 data URL / local path
|
|
126
|
+
- `prompt`: Your analysis task description
|
|
127
|
+
- `output_format`: `text` or `json` (hint preference; JSON not strictly validated)
|
|
128
|
+
- `template`: Optional system template (see `list_templates` below)
|
|
127
129
|
|
|
128
130
|
### 2) `list_templates`
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
Lists built-in system prompt templates (including id, usage description, etc.).
|
|
131
133
|
|
|
132
134
|
### 3) `get_config`
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
Returns currently active model configuration (API key is masked).
|
|
135
137
|
|
|
136
|
-
##
|
|
138
|
+
## Image Input Specifications
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
Supports three input types:
|
|
139
141
|
|
|
140
142
|
1) URL
|
|
141
143
|
|
|
@@ -143,7 +145,7 @@ Provider 特有配置:
|
|
|
143
145
|
https://example.com/image.png
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
|
|
148
|
+
Strict validation enabled by default: URL must end with `.jpg/.jpeg/.png/.webp`, otherwise error. Can be relaxed with `VISION_STRICT_URL_VALIDATION=false` (warning only).
|
|
147
149
|
|
|
148
150
|
2) Base64 Data URL
|
|
149
151
|
|
|
@@ -151,26 +153,26 @@ https://example.com/image.png
|
|
|
151
153
|
data:image/png;base64,iVBORw0KGgo...
|
|
152
154
|
```
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
Supported MIME types: `image/jpeg` / `image/jpg` / `image/png` / `image/webp`.
|
|
155
157
|
|
|
156
|
-
3)
|
|
158
|
+
3) Local file path
|
|
157
159
|
|
|
158
160
|
```text
|
|
159
161
|
./test/image.png
|
|
160
162
|
D:\\path\\to\\image.jpg
|
|
161
163
|
```
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
Requires MCP Server process to have read access; only supports `.jpg/.jpeg/.png/.webp`.
|
|
164
166
|
|
|
165
|
-
|
|
167
|
+
Note: Gemini provider doesn't support direct URL image input; this project downloads URLs and converts to base64 in the Gemini adapter (subject to size and timeout limits).
|
|
166
168
|
|
|
167
|
-
##
|
|
169
|
+
## About Streaming
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
All adapters enforce `stream: false` and parse as "complete JSON response".
|
|
170
172
|
|
|
171
|
-
|
|
173
|
+
SSE / `text/event-stream` responses are currently not supported (would require additional streaming parser implementation).
|
|
172
174
|
|
|
173
|
-
##
|
|
175
|
+
## Development & Testing
|
|
174
176
|
|
|
175
177
|
```bash
|
|
176
178
|
cd mcp/vision_mcp
|
|
@@ -178,45 +180,45 @@ npm install
|
|
|
178
180
|
npm run build
|
|
179
181
|
```
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
Testing:
|
|
182
184
|
|
|
183
|
-
-
|
|
185
|
+
- Unit tests only (no API keys required):
|
|
184
186
|
|
|
185
187
|
```bash
|
|
186
188
|
npm run test:unit
|
|
187
189
|
```
|
|
188
190
|
|
|
189
|
-
-
|
|
191
|
+
- Integration tests (requires `VISION_*` environment variables configured):
|
|
190
192
|
|
|
191
193
|
```bash
|
|
192
194
|
npm test
|
|
193
195
|
```
|
|
194
196
|
|
|
195
|
-
##
|
|
197
|
+
## Troubleshooting
|
|
196
198
|
|
|
197
|
-
### 1)
|
|
199
|
+
### 1) Configuration loading failed: `Missing VISION_MODEL_TYPE` / `Unsupported model type`
|
|
198
200
|
|
|
199
|
-
-
|
|
200
|
-
-
|
|
201
|
+
- Ensure `VISION_MODEL_TYPE` is set
|
|
202
|
+
- Valid values: `glm` / `siliconflow` / `modelscope` / `openai` / `claude` / `gemini` / `coding-plan`
|
|
201
203
|
|
|
202
204
|
### 2) `Missing VISION_API_KEY`
|
|
203
205
|
|
|
204
|
-
-
|
|
206
|
+
- Ensure `VISION_API_KEY` is set (in `.env` or MCP client `env`)
|
|
205
207
|
|
|
206
|
-
### 3) 404 / endpoint
|
|
208
|
+
### 3) 404 / endpoint errors
|
|
207
209
|
|
|
208
|
-
- `VISION_API_BASE_URL`
|
|
209
|
-
- OpenAI / SiliconFlow / ModelScope
|
|
210
|
-
- Claude
|
|
211
|
-
- Gemini
|
|
210
|
+
- `VISION_API_BASE_URL` must be the "base" URL, without specific endpoint
|
|
211
|
+
- OpenAI / SiliconFlow / ModelScope: automatically appends `/chat/completions`
|
|
212
|
+
- Claude: automatically appends `/v1/messages` (don't write `baseUrl` as `.../v1`)
|
|
213
|
+
- Gemini: automatically appends `/{apiVersion}/models/{model}:generateContent`
|
|
212
214
|
|
|
213
|
-
### 4)
|
|
215
|
+
### 4) Image URL validation failed
|
|
214
216
|
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
+
- Default requires URL to end with `.jpg/.jpeg/.png/.webp`
|
|
218
|
+
- To relax: `VISION_STRICT_URL_VALIDATION=false`
|
|
217
219
|
|
|
218
|
-
##
|
|
220
|
+
## Security Notes
|
|
219
221
|
|
|
220
|
-
-
|
|
221
|
-
- API
|
|
222
|
-
-
|
|
222
|
+
- Don't log to stdout (stdout reserved for MCP JSON-RPC), all logs go to stderr
|
|
223
|
+
- API keys are masked in logs
|
|
224
|
+
- Unconditionally filters model-returned thinking/reasoning content to avoid leaking internal inference information
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coding Plan Adapter
|
|
3
|
+
*
|
|
4
|
+
* @description Coding Plan API 适配器实现,模拟 Kilo Code 客户端身份
|
|
5
|
+
* 支持 Kimi K2.5 等视觉模型
|
|
6
|
+
*/
|
|
7
|
+
import { BaseVisionModelAdapter, VisionModelResponse } from './base-adapter.js';
|
|
8
|
+
import { ModelConfig } from '../config/model-config.js';
|
|
9
|
+
export interface CodingPlanAdapterOptions {
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
temperature?: number;
|
|
12
|
+
topP?: number;
|
|
13
|
+
frequencyPenalty?: number;
|
|
14
|
+
presencePenalty?: number;
|
|
15
|
+
customHeaders?: Record<string, string>;
|
|
16
|
+
stream?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class CodingPlanAdapter extends BaseVisionModelAdapter {
|
|
19
|
+
private options;
|
|
20
|
+
private kiloCodeHeaders;
|
|
21
|
+
constructor(config: ModelConfig, options?: CodingPlanAdapterOptions);
|
|
22
|
+
private buildKiloCodeHeaders;
|
|
23
|
+
private buildSystemPrompt;
|
|
24
|
+
private detectGitRepo;
|
|
25
|
+
analyze(imageData: string, prompt: string): Promise<string>;
|
|
26
|
+
analyzeWithResponse(imageData: string, prompt: string): Promise<VisionModelResponse>;
|
|
27
|
+
private callCodingPlanAPI;
|
|
28
|
+
analyzeStream(imageData: string, prompt: string, onChunk: (chunk: string) => void): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=coding-plan-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coding-plan-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/coding-plan-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAKxD,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,OAAO,CAGb;IACF,OAAO,CAAC,eAAe,CAAyB;gBAEpC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,wBAA6B;IA4BvE,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,aAAa;IAOf,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyB3D,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;YA0B5E,iBAAiB;IA0JzB,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,OAAO,CAAC,IAAI,CAAC;CAqGjB"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coding Plan Adapter
|
|
3
|
+
*
|
|
4
|
+
* @description Coding Plan API 适配器实现,模拟 Kilo Code 客户端身份
|
|
5
|
+
* 支持 Kimi K2.5 等视觉模型
|
|
6
|
+
*/
|
|
7
|
+
import { BaseVisionModelAdapter } from './base-adapter.js';
|
|
8
|
+
import { ModelAPIError, ModelConfigError } from '../utils/errors.js';
|
|
9
|
+
import { logger } from '../utils/logger.js';
|
|
10
|
+
import { buildKiloCodeSystemPrompt } from '../prompts/kilo-code-system.js';
|
|
11
|
+
const DEFAULT_KILO_CODE_HEADERS = {
|
|
12
|
+
'HTTP-Referer': 'https://kilocode.ai',
|
|
13
|
+
'X-Title': 'Kilo Code',
|
|
14
|
+
'User-Agent': 'Kilo-Code/1.0.3 ai-sdk/openai-compatible/0.1.0'
|
|
15
|
+
};
|
|
16
|
+
export class CodingPlanAdapter extends BaseVisionModelAdapter {
|
|
17
|
+
options;
|
|
18
|
+
kiloCodeHeaders;
|
|
19
|
+
constructor(config, options = {}) {
|
|
20
|
+
super(config);
|
|
21
|
+
if (config.type !== 'coding-plan') {
|
|
22
|
+
throw new ModelConfigError('Invalid model type. Expected: coding-plan', { expected: 'coding-plan', received: config.type });
|
|
23
|
+
}
|
|
24
|
+
this.options = {
|
|
25
|
+
maxTokens: 2048,
|
|
26
|
+
temperature: 1.0,
|
|
27
|
+
topP: 0.95,
|
|
28
|
+
frequencyPenalty: 0,
|
|
29
|
+
presencePenalty: 0,
|
|
30
|
+
...options
|
|
31
|
+
};
|
|
32
|
+
this.kiloCodeHeaders = this.buildKiloCodeHeaders();
|
|
33
|
+
logger.info('Initialized Coding Plan adapter', {
|
|
34
|
+
model: config.name,
|
|
35
|
+
baseUrl: config.baseUrl,
|
|
36
|
+
options: this.options
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
buildKiloCodeHeaders() {
|
|
40
|
+
const headers = { ...DEFAULT_KILO_CODE_HEADERS };
|
|
41
|
+
if (process.env.VISION_KILO_REFERER) {
|
|
42
|
+
headers['HTTP-Referer'] = process.env.VISION_KILO_REFERER;
|
|
43
|
+
}
|
|
44
|
+
if (process.env.VISION_KILO_TITLE) {
|
|
45
|
+
headers['X-Title'] = process.env.VISION_KILO_TITLE;
|
|
46
|
+
}
|
|
47
|
+
if (process.env.VISION_KILO_USER_AGENT) {
|
|
48
|
+
headers['User-Agent'] = process.env.VISION_KILO_USER_AGENT;
|
|
49
|
+
}
|
|
50
|
+
if (this.options.customHeaders) {
|
|
51
|
+
Object.assign(headers, this.options.customHeaders);
|
|
52
|
+
}
|
|
53
|
+
return headers;
|
|
54
|
+
}
|
|
55
|
+
buildSystemPrompt() {
|
|
56
|
+
const customPrompt = process.env.VISION_KILO_SYSTEM_PROMPT;
|
|
57
|
+
if (customPrompt) {
|
|
58
|
+
return customPrompt;
|
|
59
|
+
}
|
|
60
|
+
return buildKiloCodeSystemPrompt({
|
|
61
|
+
modelName: this.config.name,
|
|
62
|
+
workingDirectory: process.env.VISION_KILO_WORKING_DIR || process.cwd(),
|
|
63
|
+
platform: process.env.VISION_KILO_PLATFORM || process.platform,
|
|
64
|
+
isGitRepo: this.detectGitRepo()
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
detectGitRepo() {
|
|
68
|
+
if (process.env.VISION_KILO_IS_GIT_REPO !== undefined) {
|
|
69
|
+
return process.env.VISION_KILO_IS_GIT_REPO === 'true';
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
async analyze(imageData, prompt) {
|
|
74
|
+
logger.logRequest('Analyzing image with Coding Plan', {
|
|
75
|
+
modelType: 'coding-plan',
|
|
76
|
+
model: this.config.name,
|
|
77
|
+
imageLength: imageData.length
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
return await this.withRetry(async (signal) => {
|
|
81
|
+
const response = await this.callCodingPlanAPI(imageData, prompt, signal);
|
|
82
|
+
logger.logRequest('Coding Plan analysis completed', {
|
|
83
|
+
modelType: 'coding-plan',
|
|
84
|
+
model: this.config.name,
|
|
85
|
+
responseLength: response.content.length
|
|
86
|
+
});
|
|
87
|
+
return response.content;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger.error('Coding Plan analysis failed', error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async analyzeWithResponse(imageData, prompt) {
|
|
96
|
+
logger.logRequest('Analyzing image with Coding Plan (full response)', {
|
|
97
|
+
modelType: 'coding-plan',
|
|
98
|
+
model: this.config.name,
|
|
99
|
+
imageLength: imageData.length
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
return await this.withRetry(async (signal) => {
|
|
103
|
+
const response = await this.callCodingPlanAPI(imageData, prompt, signal);
|
|
104
|
+
logger.logRequest('Coding Plan analysis completed', {
|
|
105
|
+
modelType: 'coding-plan',
|
|
106
|
+
model: this.config.name,
|
|
107
|
+
responseLength: response.content.length,
|
|
108
|
+
usage: response.usage
|
|
109
|
+
});
|
|
110
|
+
return response;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
logger.error('Coding Plan analysis failed', error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async callCodingPlanAPI(imageData, prompt, signal) {
|
|
119
|
+
const baseUrl = this.config.baseUrl.replace(/\/$/, '');
|
|
120
|
+
const apiUrl = `${baseUrl}/chat/completions`;
|
|
121
|
+
const systemPrompt = this.buildSystemPrompt();
|
|
122
|
+
const requestBody = {
|
|
123
|
+
model: this.config.name,
|
|
124
|
+
messages: [
|
|
125
|
+
{
|
|
126
|
+
role: 'system',
|
|
127
|
+
content: systemPrompt
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
role: 'user',
|
|
131
|
+
content: [
|
|
132
|
+
{
|
|
133
|
+
type: 'text',
|
|
134
|
+
text: prompt
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'image_url',
|
|
138
|
+
image_url: {
|
|
139
|
+
url: imageData
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
max_tokens: this.options.maxTokens,
|
|
146
|
+
temperature: this.options.temperature,
|
|
147
|
+
top_p: this.options.topP,
|
|
148
|
+
frequency_penalty: this.options.frequencyPenalty,
|
|
149
|
+
presence_penalty: this.options.presencePenalty,
|
|
150
|
+
stream: false
|
|
151
|
+
};
|
|
152
|
+
logger.debug('Calling Coding Plan API', {
|
|
153
|
+
apiUrl,
|
|
154
|
+
model: this.config.name,
|
|
155
|
+
maxTokens: this.options.maxTokens,
|
|
156
|
+
temperature: this.options.temperature,
|
|
157
|
+
topP: this.options.topP
|
|
158
|
+
});
|
|
159
|
+
const response = await fetch(apiUrl, {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
headers: {
|
|
162
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
163
|
+
'Content-Type': 'application/json',
|
|
164
|
+
'Accept': 'application/json',
|
|
165
|
+
...this.kiloCodeHeaders
|
|
166
|
+
},
|
|
167
|
+
body: JSON.stringify(requestBody),
|
|
168
|
+
signal
|
|
169
|
+
});
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
const rawErrorText = await response.text().catch(() => 'Failed to get error details');
|
|
172
|
+
const MAX_ERROR_LENGTH = 500;
|
|
173
|
+
const errorText = rawErrorText.length > MAX_ERROR_LENGTH
|
|
174
|
+
? `${rawErrorText.slice(0, MAX_ERROR_LENGTH)}... (truncated)`
|
|
175
|
+
: rawErrorText;
|
|
176
|
+
let errorMessage = `Coding Plan API request failed: ${response.status} ${response.statusText}`;
|
|
177
|
+
let errorCode;
|
|
178
|
+
let guidance;
|
|
179
|
+
try {
|
|
180
|
+
const errorJson = JSON.parse(rawErrorText);
|
|
181
|
+
if (errorJson.error) {
|
|
182
|
+
errorMessage = errorJson.error.message || errorMessage;
|
|
183
|
+
errorCode = errorJson.error.code;
|
|
184
|
+
guidance = errorJson.error.type;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Not JSON format
|
|
189
|
+
}
|
|
190
|
+
if (response.status === 403) {
|
|
191
|
+
throw new ModelAPIError('Request blocked by Coding Plan API. This may indicate Headers are not recognized as Kilo Code client.', {
|
|
192
|
+
status: response.status,
|
|
193
|
+
statusText: response.statusText,
|
|
194
|
+
errorCode,
|
|
195
|
+
errorDetails: errorText,
|
|
196
|
+
endpoint: apiUrl,
|
|
197
|
+
guidance: guidance || 'Check VISION_KILO_* environment variables or contact support'
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (response.status === 429) {
|
|
201
|
+
const retryAfter = response.headers.get('retry-after');
|
|
202
|
+
const retryAfterText = retryAfter ? `Retry after ${retryAfter}s. ` : '';
|
|
203
|
+
throw new ModelAPIError(`Rate limit exceeded (429). ${retryAfterText}Please check your API quota or wait before retrying.`, {
|
|
204
|
+
status: response.status,
|
|
205
|
+
statusText: response.statusText,
|
|
206
|
+
errorCode,
|
|
207
|
+
errorDetails: errorText,
|
|
208
|
+
endpoint: apiUrl,
|
|
209
|
+
retryAfter: retryAfter,
|
|
210
|
+
guidance: guidance || 'Check your API quota or wait before retrying'
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
throw new ModelAPIError(errorMessage, {
|
|
214
|
+
status: response.status,
|
|
215
|
+
statusText: response.statusText,
|
|
216
|
+
errorCode,
|
|
217
|
+
errorDetails: errorText,
|
|
218
|
+
endpoint: apiUrl,
|
|
219
|
+
guidance
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
let responseData;
|
|
223
|
+
const rawText = await response.text();
|
|
224
|
+
try {
|
|
225
|
+
responseData = JSON.parse(rawText);
|
|
226
|
+
}
|
|
227
|
+
catch (parseError) {
|
|
228
|
+
const truncatedBody = rawText.slice(0, 500);
|
|
229
|
+
const bodyPreview = rawText.length > 500
|
|
230
|
+
? `${truncatedBody}... (truncated, total length: ${rawText.length})`
|
|
231
|
+
: rawText;
|
|
232
|
+
logger.error('Failed to parse successful response as JSON', parseError, {
|
|
233
|
+
contentType: response.headers.get('content-type'),
|
|
234
|
+
bodyLength: rawText.length,
|
|
235
|
+
bodyPreview
|
|
236
|
+
});
|
|
237
|
+
throw new ModelAPIError('Invalid JSON response from successful request', {
|
|
238
|
+
status: response.status,
|
|
239
|
+
statusText: response.statusText,
|
|
240
|
+
endpoint: apiUrl,
|
|
241
|
+
errorDetails: bodyPreview,
|
|
242
|
+
parseError: parseError instanceof Error ? parseError.message : String(parseError)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return this.parseResponse(responseData, 'coding-plan');
|
|
246
|
+
}
|
|
247
|
+
async analyzeStream(imageData, prompt, onChunk) {
|
|
248
|
+
const baseUrl = this.config.baseUrl.replace(/\/$/, '');
|
|
249
|
+
const apiUrl = `${baseUrl}/chat/completions`;
|
|
250
|
+
const systemPrompt = this.buildSystemPrompt();
|
|
251
|
+
const requestBody = {
|
|
252
|
+
model: this.config.name,
|
|
253
|
+
messages: [
|
|
254
|
+
{
|
|
255
|
+
role: 'system',
|
|
256
|
+
content: systemPrompt
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
role: 'user',
|
|
260
|
+
content: [
|
|
261
|
+
{
|
|
262
|
+
type: 'text',
|
|
263
|
+
text: prompt
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: 'image_url',
|
|
267
|
+
image_url: {
|
|
268
|
+
url: imageData
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
max_tokens: this.options.maxTokens,
|
|
275
|
+
temperature: this.options.temperature,
|
|
276
|
+
top_p: this.options.topP,
|
|
277
|
+
frequency_penalty: this.options.frequencyPenalty,
|
|
278
|
+
presence_penalty: this.options.presencePenalty,
|
|
279
|
+
stream: true,
|
|
280
|
+
stream_options: { include_usage: true }
|
|
281
|
+
};
|
|
282
|
+
logger.debug('Calling Coding Plan API (streaming)', {
|
|
283
|
+
apiUrl,
|
|
284
|
+
model: this.config.name
|
|
285
|
+
});
|
|
286
|
+
const response = await fetch(apiUrl, {
|
|
287
|
+
method: 'POST',
|
|
288
|
+
headers: {
|
|
289
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
290
|
+
'Content-Type': 'application/json',
|
|
291
|
+
'Accept': 'text/event-stream',
|
|
292
|
+
...this.kiloCodeHeaders
|
|
293
|
+
},
|
|
294
|
+
body: JSON.stringify(requestBody)
|
|
295
|
+
});
|
|
296
|
+
if (!response.ok) {
|
|
297
|
+
const errorText = await response.text().catch(() => 'Failed to get error details');
|
|
298
|
+
throw new ModelAPIError(`Coding Plan API request failed: ${response.status} ${response.statusText}`, {
|
|
299
|
+
status: response.status,
|
|
300
|
+
statusText: response.statusText,
|
|
301
|
+
errorDetails: errorText.slice(0, 500),
|
|
302
|
+
endpoint: apiUrl
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
const reader = response.body?.getReader();
|
|
306
|
+
if (!reader) {
|
|
307
|
+
throw new ModelAPIError('Failed to get response reader', { endpoint: apiUrl });
|
|
308
|
+
}
|
|
309
|
+
const decoder = new TextDecoder();
|
|
310
|
+
let buffer = '';
|
|
311
|
+
while (true) {
|
|
312
|
+
const { done, value } = await reader.read();
|
|
313
|
+
if (done)
|
|
314
|
+
break;
|
|
315
|
+
buffer += decoder.decode(value, { stream: true });
|
|
316
|
+
const lines = buffer.split('\n');
|
|
317
|
+
buffer = lines.pop() || '';
|
|
318
|
+
for (const line of lines) {
|
|
319
|
+
if (!line.startsWith('data: '))
|
|
320
|
+
continue;
|
|
321
|
+
const data = line.slice(6).trim();
|
|
322
|
+
if (data === '[DONE]')
|
|
323
|
+
continue;
|
|
324
|
+
try {
|
|
325
|
+
const parsed = JSON.parse(data);
|
|
326
|
+
const content = parsed.choices?.[0]?.delta?.content;
|
|
327
|
+
if (content) {
|
|
328
|
+
onChunk(content);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
// Ignore parse errors for individual chunks
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=coding-plan-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coding-plan-adapter.js","sourceRoot":"","sources":["../../src/adapters/coding-plan-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,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KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;YAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;oBAAE,SAAS;gBAEzC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBAClC,IAAI,IAAI,KAAK,QAAQ;oBAAE,SAAS;gBAEhC,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC;oBACpD,IAAI,OAAO,EAAE,CAAC;wBACZ,OAAO,CAAC,OAAO,CAAC,CAAC;oBACnB,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,4CAA4C;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kilo Code System Prompt
|
|
3
|
+
*
|
|
4
|
+
* @description Kilo Code Provider 提示词(完整版)
|
|
5
|
+
* Kimi K2.5 使用 PROMPT_ANTHROPIC_WITHOUT_TODO(qwen.txt)
|
|
6
|
+
* 用于完全模拟 Kilo Code 客户端身份
|
|
7
|
+
*/
|
|
8
|
+
export declare const KILO_CODE_PROVIDER_PROMPT = "You are Kilo, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or to about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\n\nIf the user asks for help or wants to give feedback inform them of the following:\n- /help: Get help with using Kilo\n- To give feedback, users should report the issue at https://github.com/Kilo-Org/kilocode/issues\n\nWhen the user directly asks about Kilo (eg 'can Kilo do...', 'does Kilo have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from Kilo docs at https://kilo.ai/docs\n\n# Tone and style\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\nIMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.\nIMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.\nIMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\". Here are some examples to demonstrate appropriate verbosity:\n<example>\nuser: 2 + 2\nassistant: 4\n</example>\n\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]\nnpm run dev\n</example>\n\n<example>\nuser: How many golf balls fit inside a jetta?\nassistant: 150000\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [runs ls and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]\n</example>\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.\n3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.\n\n# Following conventions\nWhen making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).\n- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.\n- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the change in a way that is most idiomatic.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Code style\n- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.\n- Implement the solution using all tools available to you\n- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.\n- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.\nNEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n\nYou MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.\n\n# Code References\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.";
|
|
9
|
+
export interface KiloCodeSystemPromptOptions {
|
|
10
|
+
modelName: string;
|
|
11
|
+
workingDirectory?: string;
|
|
12
|
+
platform?: string;
|
|
13
|
+
isGitRepo?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildKiloCodeSystemPrompt(options: KiloCodeSystemPromptOptions): string;
|
|
16
|
+
//# sourceMappingURL=kilo-code-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kilo-code-system.d.ts","sourceRoot":"","sources":["../../src/prompts/kilo-code-system.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,yBAAyB,+lRAgGgI,CAAC;AAEvK,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM,CAetF"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kilo Code System Prompt
|
|
3
|
+
*
|
|
4
|
+
* @description Kilo Code Provider 提示词(完整版)
|
|
5
|
+
* Kimi K2.5 使用 PROMPT_ANTHROPIC_WITHOUT_TODO(qwen.txt)
|
|
6
|
+
* 用于完全模拟 Kilo Code 客户端身份
|
|
7
|
+
*/
|
|
8
|
+
export const KILO_CODE_PROVIDER_PROMPT = `You are Kilo, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
9
|
+
|
|
10
|
+
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
11
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or to about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
12
|
+
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
13
|
+
|
|
14
|
+
If the user asks for help or wants to give feedback inform them of the following:
|
|
15
|
+
- /help: Get help with using Kilo
|
|
16
|
+
- To give feedback, users should report the issue at https://github.com/Kilo-Org/kilocode/issues
|
|
17
|
+
|
|
18
|
+
When the user directly asks about Kilo (eg 'can Kilo do...', 'does Kilo have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from Kilo docs at https://kilo.ai/docs
|
|
19
|
+
|
|
20
|
+
# Tone and style
|
|
21
|
+
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
|
22
|
+
Remember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
23
|
+
Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
24
|
+
If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
|
|
25
|
+
Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
26
|
+
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
|
|
27
|
+
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
|
|
28
|
+
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
|
|
29
|
+
<example>
|
|
30
|
+
user: 2 + 2
|
|
31
|
+
assistant: 4
|
|
32
|
+
</example>
|
|
33
|
+
|
|
34
|
+
<example>
|
|
35
|
+
user: what is 2+2?
|
|
36
|
+
assistant: 4
|
|
37
|
+
</example>
|
|
38
|
+
|
|
39
|
+
<example>
|
|
40
|
+
user: is 11 a prime number?
|
|
41
|
+
assistant: Yes
|
|
42
|
+
</example>
|
|
43
|
+
|
|
44
|
+
<example>
|
|
45
|
+
user: what command should I run to list files in the current directory?
|
|
46
|
+
assistant: ls
|
|
47
|
+
</example>
|
|
48
|
+
|
|
49
|
+
<example>
|
|
50
|
+
user: what command should I run to watch files in the current directory?
|
|
51
|
+
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
|
|
52
|
+
npm run dev
|
|
53
|
+
</example>
|
|
54
|
+
|
|
55
|
+
<example>
|
|
56
|
+
user: How many golf balls fit inside a jetta?
|
|
57
|
+
assistant: 150000
|
|
58
|
+
</example>
|
|
59
|
+
|
|
60
|
+
<example>
|
|
61
|
+
user: what files are in the directory src/?
|
|
62
|
+
assistant: [runs ls and sees foo.c, bar.c, baz.c]
|
|
63
|
+
user: which file contains the implementation of foo?
|
|
64
|
+
assistant: src/foo.c
|
|
65
|
+
</example>
|
|
66
|
+
|
|
67
|
+
<example>
|
|
68
|
+
user: write tests for new feature
|
|
69
|
+
assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
|
|
70
|
+
</example>
|
|
71
|
+
|
|
72
|
+
# Proactiveness
|
|
73
|
+
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
|
|
74
|
+
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
75
|
+
2. Not surprising the user with actions you take without asking
|
|
76
|
+
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
77
|
+
3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
78
|
+
|
|
79
|
+
# Following conventions
|
|
80
|
+
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
|
|
81
|
+
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
|
|
82
|
+
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
|
|
83
|
+
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the change in a way that is most idiomatic.
|
|
84
|
+
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
85
|
+
|
|
86
|
+
# Code style
|
|
87
|
+
- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
|
|
88
|
+
|
|
89
|
+
# Doing tasks
|
|
90
|
+
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
91
|
+
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
92
|
+
- Implement the solution using all tools available to you
|
|
93
|
+
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
|
|
94
|
+
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.
|
|
95
|
+
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
96
|
+
|
|
97
|
+
# Tool usage policy
|
|
98
|
+
- When doing file search, prefer to use the Task tool in order to reduce context usage.
|
|
99
|
+
- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
|
|
100
|
+
|
|
101
|
+
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
|
|
102
|
+
|
|
103
|
+
# Code References
|
|
104
|
+
When referencing specific functions or pieces of code include the pattern \`file_path:line_number\` to allow the user to easily navigate to the source code location.`;
|
|
105
|
+
export function buildKiloCodeSystemPrompt(options) {
|
|
106
|
+
const parts = [];
|
|
107
|
+
parts.push(KILO_CODE_PROVIDER_PROMPT);
|
|
108
|
+
parts.push('');
|
|
109
|
+
parts.push(`You are powered by the model named ${options.modelName}.`);
|
|
110
|
+
parts.push(`Here is some useful information about the environment you are running in:`);
|
|
111
|
+
parts.push(`<env>`);
|
|
112
|
+
parts.push(` Working directory: ${options.workingDirectory || process.cwd()}`);
|
|
113
|
+
parts.push(` Is directory a git repo: ${options.isGitRepo ? 'yes' : 'no'}`);
|
|
114
|
+
parts.push(` Platform: ${options.platform || process.platform}`);
|
|
115
|
+
parts.push(`</env>`);
|
|
116
|
+
return parts.join('\n');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=kilo-code-system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kilo-code-system.js","sourceRoot":"","sources":["../../src/prompts/kilo-code-system.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sKAgG6H,CAAC;AASvK,MAAM,UAAU,yBAAyB,CAAC,OAAoC;IAC5E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACtC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,KAAK,CAAC,IAAI,CAAC,sCAAsC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;IACvE,KAAK,CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAC;IACxF,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,KAAK,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChF,KAAK,CAAC,IAAI,CAAC,8BAA8B,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAErB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-registry.d.ts","sourceRoot":"","sources":["../../src/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAA2F,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-registry.d.ts","sourceRoot":"","sources":["../../src/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAA2F,MAAM,iCAAiC,CAAC;AAS7J;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,mBAAmB;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;IACtD,cAAc;IACd,aAAa,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,kBAAkB,CAAC;IAC3D,mBAAmB;IACnB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,cAAM,gBAAgB;IACpB,OAAO,CAAC,SAAS,CAAyC;IAE1D;;OAEG;IACI,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAInD;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIxD;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACI,iBAAiB,IAAI,MAAM,EAAE;CAGrC;AAGD,eAAO,MAAM,QAAQ,kBAAyB,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { ModelScopeAdapter } from '../adapters/modelscope-adapter.js';
|
|
|
11
11
|
import { OpenAIAdapter } from '../adapters/openai-adapter.js';
|
|
12
12
|
import { ClaudeAdapter } from '../adapters/claude-adapter.js';
|
|
13
13
|
import { GeminiAdapter } from '../adapters/gemini-adapter.js';
|
|
14
|
+
import { CodingPlanAdapter } from '../adapters/coding-plan-adapter.js';
|
|
14
15
|
/**
|
|
15
16
|
* 提供商注册表
|
|
16
17
|
*/
|
|
@@ -169,4 +170,24 @@ registry.register({
|
|
|
169
170
|
thinkingExtractor: extractGeminiThinking,
|
|
170
171
|
enableThinking: false
|
|
171
172
|
});
|
|
173
|
+
// Coding Plan (Kilo Code Compatible) Provider
|
|
174
|
+
registry.register({
|
|
175
|
+
type: 'coding-plan',
|
|
176
|
+
displayName: 'Coding Plan (Kilo Code Compatible)',
|
|
177
|
+
defaults: {
|
|
178
|
+
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
|
|
179
|
+
modelName: 'kimi-k2.5',
|
|
180
|
+
timeout: 120000,
|
|
181
|
+
maxRetries: 2
|
|
182
|
+
},
|
|
183
|
+
validateApiKey: (apiKey) => {
|
|
184
|
+
if (!apiKey || apiKey.trim().length === 0) {
|
|
185
|
+
return 'API Key is required';
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
},
|
|
189
|
+
createAdapter: (config) => new CodingPlanAdapter(config),
|
|
190
|
+
thinkingExtractor: extractOpenAIThinking,
|
|
191
|
+
enableThinking: false
|
|
192
|
+
});
|
|
172
193
|
//# sourceMappingURL=provider-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-registry.js","sourceRoot":"","sources":["../../src/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAqB,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7J,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-registry.js","sourceRoot":"","sources":["../../src/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAqB,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7J,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D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BAAiB,EAAE,CAAC;AAsBzD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"thinking-filter.d.ts","sourceRoot":"","sources":["../../src/utils/thinking-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EAKlB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC;AAsBzD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAUjE,CAAC;AAuCF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,qBAAqB,GAAG,MAAM,CAiCrE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAgCrF"}
|
|
@@ -40,7 +40,8 @@ export const THINKING_EXTRACTORS = {
|
|
|
40
40
|
'openai': extractOpenAIThinking,
|
|
41
41
|
'claude': extractClaudeThinking,
|
|
42
42
|
'gemini': extractGeminiThinking,
|
|
43
|
-
|
|
43
|
+
'coding-plan': extractOpenAIThinking,
|
|
44
|
+
'modelscope': extractOpenAIThinking,
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* Strips thinking content from text using pattern matching
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-filter.js","sourceRoot":"","sources":["../../src/utils/thinking-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAGL,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAKlC;;;GAGG;AACH,MAAM,iBAAiB,GAAG;IACxB,2BAA2B;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4B,CAAC,CAAC;QAC3F,CAAC;QAED,sBAAsB;QACtB,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAExE,0DAA0D;QAC1D,IAAI,CAAC;YACH,aAAa;YACb,MAAM,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;YAClE,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;YAClF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lutery/vision-mcp",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "MCP Server providing vision capabilities for LLMs via GLM-4.6V, SiliconFlow, and
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "MCP Server providing vision capabilities for LLMs via GLM-4.6V, SiliconFlow, ModelScope, OpenAI, Claude, Gemini, and Coding Plan (Kimi K2.5)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"vision-mcp": "dist/index.js"
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
"test:smoke": "node test/smoke-glm-adapter.mjs",
|
|
19
19
|
"test:integration": "npm run build && node -r dotenv/config test/simple-test.js"
|
|
20
20
|
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/lutery/mcp.git"
|
|
24
|
+
},
|
|
21
25
|
"keywords": [
|
|
22
26
|
"mcp",
|
|
23
27
|
"vision",
|
|
24
28
|
"llm",
|
|
25
29
|
"glm-4.6v",
|
|
26
|
-
"siliconflow"
|
|
30
|
+
"siliconflow",
|
|
31
|
+
"coding-plan",
|
|
32
|
+
"kimi",
|
|
33
|
+
"kilo-code"
|
|
27
34
|
],
|
|
28
35
|
"author": "",
|
|
29
36
|
"license": "MIT",
|