deepfish-ai 1.0.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 [Your Name]
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,344 @@
1
+ <div align="center" style="display:flex;align-items: center;justify-content: center;">
2
+ <img src="./images/logo2.png" alt="DeepFish" style="width:55px;" />
3
+ <span style="font-size: 30px;font-weight: bold;color:#3386FE">DeepFish</span>
4
+ </div>
5
+
6
+ ---
7
+
8
+ <div align="center" style="line-height: 1">
9
+ <img alt="QQ" src="https://img.shields.io/badge/QQ-306863030-green.svg" />
10
+ <img
11
+ alt="WeChat"
12
+ src="https://img.shields.io/badge/WeChat-MrRoman_123-green.svg"
13
+ />
14
+ <a href="https://github.com/qq306863030/deepfish">
15
+ <img
16
+ alt="GitHub"
17
+ src="https://img.shields.io/badge/GitHub-DeepFish-blue.svg"
18
+ /></a>
19
+ <a href="https://www.npmjs.com/package/deepfish">
20
+ <img alt="NPM" src="https://img.shields.io/badge/NPM-DeepFish-blue.svg"
21
+ /></a>
22
+ <img
23
+ alt="Code License"
24
+ src="https://img.shields.io/badge/Code_License-MIT-blue"
25
+ />
26
+ </div>
27
+
28
+ <img src="./images/banner.png" alt="AI Command Line Tool Screenshot" style="width:100%;text-align:center;" />
29
+
30
+
31
+
32
+ - [English](README.md) | [中文](README_CN.md)
33
+
34
+ [TOC]
35
+
36
+
37
+ ## 1. Introduction
38
+
39
+ An efficient and convenient AI-driven command-line tool designed to break down the barrier between natural language and operating system commands or file operation instructions. It enables non-professional developers to quickly generate directly executable operation instructions through simple natural language descriptions, significantly improving terminal operation efficiency.
40
+ Core Features:
41
+
42
+ - Multi-model Compatibility: Seamlessly supports DeepSeek, Ollama, and all AI models that comply with the OpenAI API specification. It can be flexibly switched according to needs to adapt to instruction generation requirements in different scenarios.
43
+
44
+ - Natural Language to Instructions: Precisely parses natural language requirements and automatically converts them into corresponding operating system commands (such as Linux, Windows, and macOS terminal commands) and file operation instructions (such as creating, deleting, and modifying files/directories), eliminating the need to manually write complex commands.
45
+
46
+ - Highly Extensible: Supports expanding functional boundaries through an extension mechanism. In addition to basic terminal and file operations, it can easily implement complex tasks such as translation, novel writing, file format conversion, and data processing to meet diverse usage needs.
47
+
48
+ - AI Automatic Extension Generation: There is no need to manually develop complex extension tools. Custom extensions can be directly generated through AI, reducing the threshold for extension development and making function expansion more efficient and flexible.[Extensions-Example](https://github.com/qq306863030/deepfish-extensions)
49
+
50
+ Suitable for various groups such as developers, operation and maintenance personnel, and daily terminal users. Whether it is quickly executing terminal operations, batch processing files, or realizing personalized needs through extensions, this tool can simplify the operation process, improve work efficiency, and empower every terminal operation with AI.
51
+
52
+
53
+ ## 2. Installation
54
+
55
+ ### Prerequisites
56
+
57
+ - Node.js (v22.14.0 or higher)
58
+ - npm or yarn
59
+
60
+ ### Installation via npm
61
+
62
+ ```bash
63
+ npm install -g deepfish-ai
64
+ ```
65
+
66
+ ### Installation from Source
67
+
68
+ ```bash
69
+ git clone https://github.com/qq306863030/deepfish.git
70
+ cd deepfish
71
+ npm install
72
+ npm link
73
+ ```
74
+
75
+ ## 3. Quick Start
76
+
77
+ ```bash
78
+ ai config add # Enter a name, then select deepseek, and enter your DeepSeek API key
79
+ ai use [the_name_you_entered]
80
+ ai "Help me write an article about future technology in the current directory, output in markdown format"
81
+ ```
82
+
83
+ ## 4. Configuration
84
+
85
+ ### Initial Setup
86
+
87
+ Run the configuration wizard to set up your AI service:
88
+
89
+ ```bash
90
+ ai config add
91
+ ```
92
+
93
+ This will prompt you to configure the following:
94
+
95
+ - **AI Service Type**: Choose DeepSeek, Ollama, or OpenAI
96
+ - **API Base URL**: Default URL provided for each service
97
+ - **Model Name**: Choose the AI model to use
98
+ - **API Key**: Required for DeepSeek and OpenAI
99
+ - **Temperature**: Controls response randomness (0-2)
100
+ - **Max Tokens**: Maximum response length
101
+ - **Streaming Output**: Enable/disable streaming response
102
+
103
+ ### Configuration Commands
104
+
105
+ ```bash
106
+ # Configuration commands
107
+ ai config add # Add a new AI configuration
108
+ ai config ls # List all AI configurations
109
+ ai config use <name> # Set the specified AI configuration as the current one
110
+ ai config del <name> # Delete the specified AI configuration
111
+ ai config view [name] # View details of the specified AI configuration
112
+ ai config edit # Edit the configuration file manually
113
+ ai config reset # Reset configuration
114
+ ai config clear # Delete the configuration file
115
+
116
+ # Extension commands
117
+ ai ext add <filename> # Add an extension tool
118
+ ai ext del <filepath> # Remove an extension tool by file path
119
+ ai ext del <index> # Remove an extension tool by index
120
+ ai ext ls # List all extension tools
121
+ ```
122
+
123
+ ### Configuration File Structure
124
+
125
+ The configuration file (`~/.ai-cmd.config.js`) has the following structure:
126
+
127
+ ```javascript
128
+ module.exports = {
129
+ ai: [
130
+ {
131
+ name: "default", // AI configuration name
132
+ type: "deepseek", // AI service type: "ollama", "deepseek", or "openai"
133
+ baseUrl: "https://api.deepseek.com", // API base URL
134
+ model: "deepseek-reasoner", // AI model name
135
+ apiKey: "", // API key (required for DeepSeek and OpenAI)
136
+ temperature: 1, // Response randomness (0-2)
137
+ maxTokens: 8192, // Maximum response length
138
+ stream: true, // Enable/disable streaming output
139
+ }
140
+ ],
141
+ currentAi: "default", // Name of the currently active AI configuration
142
+ maxIterations: -1, // Maximum iterations for agent workflow, -1 for unlimited
143
+ maxMessagesLength: 50000, // Maximum compression length
144
+ maxMessagesCount: 40, // Maximum compression count
145
+ extensions: [], // List of extension file paths
146
+ isRecordHistory: false, // Whether to create workflow execution record files
147
+ isLog: false // Whether to create workflow execution logs
148
+ };
149
+ ```
150
+
151
+ ## 5. Usage
152
+
153
+ ### Interactive Mode
154
+
155
+ Start an interactive session (multi-turn dialogue):
156
+
157
+ ```bash
158
+ ai
159
+ ```
160
+
161
+ Or explicitly specify:
162
+
163
+ ```bash
164
+ ai -i or ai -interactive
165
+ ```
166
+
167
+ ### Direct Command Mode
168
+
169
+ Execute a single command:
170
+
171
+ ```bash
172
+ ai "Create a file named hello.txt with the content 'Hello World'"
173
+ ```
174
+
175
+ ### Usage Examples
176
+
177
+ **File Operations:**
178
+
179
+ ```bash
180
+ ai "Create 10 text documents, each with 100 random characters"
181
+ ai "Clear the current directory"
182
+ ```
183
+
184
+ **Code Generation:**
185
+
186
+ ```bash
187
+ ai "Create a simple Express server with a /hello endpoint"
188
+ ai "Create a browser-based airplane shooting game"
189
+ ```
190
+
191
+ **System Commands:**
192
+
193
+ ```bash
194
+ ai "List all files in the current directory with their sizes"
195
+ ai "Check disk usage for the current directory"
196
+ ```
197
+
198
+ **Extension Tool Generation:**
199
+
200
+ ```bash
201
+ ai "Create a weather.js extension tool for querying weather"
202
+ ai ext add weather.js
203
+ ```
204
+
205
+ **Media Processing:**
206
+
207
+ ```bash
208
+ ai "I have ffmpeg5 installed on my system, help me convert all MP4 files in the directory to AVI format"
209
+ ```
210
+
211
+ **File Organization:**
212
+
213
+ ```bash
214
+ ai "Classify all files under the 'model' directory into the 'model2' directory by month, date format YYYY-MM"
215
+ ```
216
+
217
+ ## 6. Extension Development
218
+
219
+ Extensions allow you to add custom functions that AI can use in its workflows. For complex processes, you can develop them yourself or try generating extensions using this program, then register the extension with the program and use the command line to complete tasks.
220
+
221
+ ### Creating an Extension
222
+
223
+ 1. Extensions should export an object containing `descriptions` (an array of tool descriptions) and `functions` (an object of functions).
224
+ 2. Tip: You can generate extensions via AI, e.g., `ai "Create a weather.js extension tool for querying weather"`
225
+ 3. View [example extensions](https://github.com/qq306863030/deepfish-extensions).
226
+
227
+ ```javascript
228
+ // Example extension: Weather Extension
229
+ const axios = require('axios');
230
+
231
+ const descriptions = [
232
+ {
233
+ type: 'function',
234
+ function: {
235
+ name: 'getWeather',
236
+ description: 'Get current weather information for a city',
237
+ parameters: {
238
+ type: 'object',
239
+ properties: {
240
+ city: { type: 'string' }
241
+ },
242
+ required: ['city']
243
+ }
244
+ }
245
+ }
246
+ ];
247
+
248
+ const functions = {
249
+ async getWeather(city) {
250
+ // Implement weather API call
251
+ const response = await axios.get(`https://api.weatherapi.com/v1/current.json?key=YOUR_KEY&q=${city}`);
252
+ return `${city} weather: ${response.data.current.temp_c}°C, ${response.data.current.condition.text}`;
253
+ }
254
+ };
255
+
256
+ module.exports = {
257
+ descriptions,
258
+ functions
259
+ };
260
+ ```
261
+
262
+ #### Registering Extensions
263
+
264
+ **Method 1: Using Command Line**
265
+
266
+ ```bash
267
+ ai ext add <filename> # ai ext add weather.js
268
+ ai ext add . # Traverse the current directory, automatically scan and add extensions
269
+ ```
270
+
271
+ **Method 2: Manual Configuration**
272
+
273
+ 1. ai config edit
274
+ 2. Add it to your configuration:
275
+
276
+ ```javascript
277
+ module.exports = {
278
+ // ... other configurations
279
+ extensions: [
280
+ '/path/to/weather-extension.js'
281
+ ],
282
+ };
283
+ ```
284
+
285
+ **Method 3: Automatic Scanning**
286
+
287
+ The program automatically scans the following directories for directories starting with "deepfish-" on startup.
288
+ 1. The npm global node_modules directory (extensions can be installed via `npm install -g deepfish-xxx`)
289
+ 2. The node_modules directory in the current working directory
290
+ 3. The current working directory
291
+
292
+ ## 7. Recommendations
293
+
294
+ ### AI Service Selection
295
+
296
+ **Recommendation: Use online AI services (DeepSeek/OpenAI) for best results**
297
+
298
+ While local AI services (like Ollama) offer privacy and offline capabilities, they may have the following limitations:
299
+
300
+ - **Response Accuracy**: Local models may not be as rigorous and precise as online models
301
+ - **Code Quality**: Generated code may require more manual review and correction
302
+ - **Complex Task Handling**: May encounter difficulties with multi-step or complex operations
303
+ - **Language Understanding**: Online services provide better language models
304
+
305
+ For production environments or complex tasks, we recommend using DeepSeek, OpenAI services, or cloud services within Ollama for more reliable and accurate results.
306
+
307
+ ## 8. Usage Notes
308
+
309
+ ### Using Relative Paths
310
+
311
+ AI always uses paths relative to the current working directory.
312
+
313
+ ## 9. Troubleshooting
314
+
315
+ ### Configuration Issues
316
+
317
+ If you encounter configuration errors, try resetting:
318
+
319
+ ```bash
320
+ ai config reset
321
+ ```
322
+
323
+ ### AI Service Connection
324
+
325
+ - **Ollama**: Ensure Ollama is running locally on port 11434
326
+ - **DeepSeek/OpenAI**: Verify your API key is correct and you have sufficient quota
327
+
328
+ ### Extension Not Loading
329
+
330
+ - Check the file path in the configuration
331
+ - Ensure the file exports the correct object
332
+ - Verify the file has no syntax errors
333
+
334
+ ## 10. Contributing
335
+
336
+ Contributions are welcome! Please feel free to submit a Pull Request.
337
+
338
+ ## 11. License
339
+
340
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
341
+
342
+ ## 12. Support
343
+
344
+ For issues and questions, please submit an issue on the GitHub repository.
package/README_CN.md ADDED
@@ -0,0 +1,344 @@
1
+ <div align="center" style="display:flex;align-items: center;justify-content: center;">
2
+ <img src="./images/logo2.png" alt="DeepFish" style="width:55px;" />
3
+ <span style="font-size: 30px;font-weight: bold;color:#3386FE">DeepFish</span>
4
+ </div>
5
+
6
+ ---
7
+
8
+ <div align="center" style="line-height: 1">
9
+ <img alt="QQ" src="https://img.shields.io/badge/QQ-306863030-green.svg" />
10
+ <img
11
+ alt="WeChat"
12
+ src="https://img.shields.io/badge/WeChat-MrRoman_123-green.svg"
13
+ />
14
+ <a href="https://github.com/qq306863030/deepfish">
15
+ <img
16
+ alt="GitHub"
17
+ src="https://img.shields.io/badge/GitHub-DeepFish-blue.svg"
18
+ /></a>
19
+ <a href="https://www.npmjs.com/package/deepfish">
20
+ <img alt="NPM" src="https://img.shields.io/badge/NPM-DeepFish-blue.svg"
21
+ /></a>
22
+ <img
23
+ alt="Code License"
24
+ src="https://img.shields.io/badge/Code_License-MIT-blue"
25
+ />
26
+ </div>
27
+
28
+ <img src="./images/banner.png" alt="AI 命令行工具截图" style="width:100%;text-align:center;" />
29
+
30
+
31
+
32
+
33
+ - [English](README.md) | [中文](README_CN.md)
34
+
35
+ [TOC]
36
+
37
+
38
+ ## 1. 介绍
39
+
40
+ 一款高效便捷的AI驱动命令行工具,致力于打破自然语言与操作系统指令、文件操作指令之间的壁垒,让非专业开发者也能通过简单的自然语言描述,快速生成可直接执行的操作指令,大幅提升终端操作效率。
41
+ 核心特性:
42
+
43
+ - 多模型兼容:无缝支持DeepSeek、Ollama,以及所有遵循OpenAI API规范的AI模型,可根据需求灵活切换,适配不同场景下的指令生成需求。
44
+
45
+ - 自然语言转指令:精准解析自然语言需求,自动转换为对应的操作系统命令(如Linux、Windows、macOS终端指令)和文件操作指令(如创建、删除、修改文件/目录),无需手动编写复杂命令。
46
+
47
+ - 高度可扩展:支持通过扩展机制拓展功能边界,除基础的终端、文件操作外,可轻松实现翻译、小说创作、文件格式转换、数据处理等复杂任务,满足多样化使用需求。
48
+
49
+ - AI自动生成扩展:无需手动开发复杂扩展工具,可通过AI直接生成自定义扩展,降低扩展开发门槛,让功能拓展更高效、更灵活。[扩展示例](https://github.com/qq306863030/deepfish-extensions)
50
+
51
+ 适用于开发者、运维人员、日常终端使用者等各类人群,无论是快速执行终端操作、批量处理文件,还是通过扩展实现个性化需求,都能通过该工具简化操作流程,提升工作效率,让AI赋能每一次终端操作。
52
+
53
+ ## 2. 安装
54
+
55
+ ### 前置要求
56
+
57
+ - Node.js(v22.14.0或更高版本)
58
+ - npm或yarn
59
+
60
+ ### 通过npm安装
61
+
62
+ ```bash
63
+ npm install -g deepfish-ai
64
+ ```
65
+
66
+ ### 从源码安装
67
+
68
+ ```bash
69
+ git clone https://github.com/qq306863030/deepfish.git
70
+ cd deepfish
71
+ npm install
72
+ npm link
73
+ ```
74
+
75
+ ## 3. 快速使用
76
+
77
+ ```bash
78
+ ai config add # 输入名称, 然后选择deepseek,并输入你的deepseek api key
79
+ ai use 你输入的名称
80
+ ai ”帮我在当前目录写一篇关于未来科技的文章,用markdown格式输出“
81
+ ```
82
+
83
+ ## 4. 配置
84
+
85
+ ### 初始设置
86
+
87
+ 运行配置向导来设置您的AI服务:
88
+
89
+ ```bash
90
+ ai config add
91
+ ```
92
+
93
+ 这将提示你配置以下内容:
94
+
95
+ - **AI服务类型**:选择DeepSeek、Ollama或OpenAI
96
+ - **API基础URL**:为每个服务提供默认URL
97
+ - **模型名称**:选择要使用的AI模型
98
+ - **API密钥**:DeepSeek和OpenAI需要
99
+ - **Temperature**:控制响应随机性(0-2)
100
+ - **Max Tokens**:最大响应长度
101
+ - **Streaming Output**:启用/禁用流式响应
102
+
103
+ ### 配置命令
104
+
105
+ ```bash
106
+ # 配置命令
107
+ ai config add # 添加新的AI配置
108
+ ai config ls # 列出所有AI配置
109
+ ai config use <name> # 设置指定的AI配置为当前配置
110
+ ai config del <name> # 删除指定的AI配置
111
+ ai config view [name] # 查看指定AI配置的详细信息
112
+ ai config edit # 编辑配置文件手动编辑配置文件
113
+ ai config reset # 重置配置
114
+ ai config clear # 删除配置文件
115
+
116
+ # 扩展命令
117
+ ai ext add <filename> # 添加扩展工具
118
+ ai ext del <filepath> # 通过文件路径移除扩展工具
119
+ ai ext del <index> # 通过索引移除扩展工具
120
+ ai ext ls # 列出所有扩展工具
121
+ ```
122
+
123
+ ### 配置文件结构
124
+
125
+ 配置文件 (`~/.ai-cmd.config.js`) 具有以下结构:
126
+
127
+ ```javascript
128
+ module.exports = {
129
+ ai: [
130
+ {
131
+ name: "default", // AI配置名称
132
+ type: "deepseek", // AI服务类型:"ollama"、"deepseek"或"openai"
133
+ baseUrl: "https://api.deepseek.com", // API基础URL
134
+ model: "deepseek-reasoner", // AI模型名称
135
+ apiKey: "", // API密钥(DeepSeek和OpenAI需要)
136
+ temperature: 1, // 响应随机性(0-2)
137
+ maxTokens: 8192, // 最大响应长度
138
+ stream: true, // 启用/禁用流式输出
139
+ }
140
+ ],
141
+ currentAi: "default", // 当前活动的AI配置名称
142
+ maxIterations: -1, // 代理工作流的最大迭代次数,-1为不限制迭代次数
143
+ maxMessagesLength: 50000, // 最大压缩长度
144
+ maxMessagesCount: 40, // 最大压缩数量
145
+ extensions: [], // 扩展文件路径列表
146
+ isRecordHistory: false, // 是否创建工作流执行记录文件
147
+ isLog: false // 是否创建工作流执行日志
148
+ };
149
+ ```
150
+
151
+ ## 5. 使用方法
152
+
153
+ ### 交互模式
154
+
155
+ 启动交互式会话(多轮对话):
156
+
157
+ ```bash
158
+ ai
159
+ ```
160
+
161
+ 或显式指定:
162
+
163
+ ```bash
164
+ ai -i 或 ai -interactive
165
+ ```
166
+
167
+ ### 直接命令模式
168
+
169
+ 执行单个命令:
170
+
171
+ ```bash
172
+ ai "创建一个名为hello.txt的文件,内容为'Hello World'"
173
+ ```
174
+
175
+ ### 使用示例
176
+
177
+ **文件操作:**
178
+
179
+ ```bash
180
+ ai "创建10个文本文档,分别输入100个随机文本"
181
+ ai "清空当前目录"
182
+ ```
183
+
184
+ **代码生成:**
185
+
186
+ ```bash
187
+ ai "创建一个带有/hello端点的简单Express服务器"
188
+ ai "创建一个基于浏览器的飞机大战游戏"
189
+ ```
190
+
191
+ **系统命令:**
192
+
193
+ ```bash
194
+ ai "列出当前目录中所有文件及其大小"
195
+ ai "检查当前目录的磁盘使用情况"
196
+ ```
197
+
198
+ **扩展工具生成:**
199
+
200
+ ```bash
201
+ ai "创建一个用于查询天气的扩展工具weather.js"
202
+ ai ext add weather.js
203
+ ```
204
+
205
+ **媒体处理:**
206
+
207
+ ```bash
208
+ ai "我的系统上安装了ffmpeg5,帮我将目录中的所有MP4文件转换为AVI格式"
209
+ ```
210
+
211
+ **文件组织:**
212
+
213
+ ```bash
214
+ ai "将model目录下的所有文件按月份分类到model2目录中,日期格式为YYYY-MM"
215
+ ```
216
+
217
+ ## 6. 扩展开发
218
+
219
+ 扩展允许您添加AI可以在其工作流中使用的自定义函数, 对于复杂的流程也可以自行开发或尝试使用本程序生成扩展,然后将扩展注册到程序中,在使用命令行来完成任务。
220
+
221
+ ### 创建扩展
222
+
223
+ 1. 扩展应导出包含 `descriptions`(工具描述数组)和 `functions`(函数对象)的对象。
224
+ 2. 提示:可以通过AI生成扩展,例如"ai "创建一个用于查询天气的扩展工具weather.js"
225
+ 3. 可查看[示例扩展](https://github.com/qq306863030/deepfish-extensions)。
226
+
227
+ ```javascript
228
+ // 示例扩展:天气扩展
229
+ const axios = require('axios');
230
+
231
+ const descriptions = [
232
+ {
233
+ type: 'function',
234
+ function: {
235
+ name: 'getWeather',
236
+ description: '获取城市的当前天气信息',
237
+ parameters: {
238
+ type: 'object',
239
+ properties: {
240
+ city: { type: 'string' }
241
+ },
242
+ required: ['city']
243
+ }
244
+ }
245
+ }
246
+ ];
247
+
248
+ const functions = {
249
+ async getWeather(city) {
250
+ // 实现天气API调用
251
+ const response = await axios.get(`https://api.weatherapi.com/v1/current.json?key=YOUR_KEY&q=${city}`);
252
+ return `${city}的天气:${response.data.current.temp_c}°C,${response.data.current.condition.text}`;
253
+ }
254
+ };
255
+
256
+ module.exports = {
257
+ descriptions,
258
+ functions
259
+ };
260
+ ```
261
+
262
+ #### 注册扩展
263
+
264
+ **方法1:使用命令行**
265
+
266
+ ```bash
267
+ ai ext add <filename> # ai ext add weather.js
268
+ ai ext add . # 遍历当前目录,自动扫描并添加扩展
269
+ ```
270
+
271
+ **方法2:手动配置**
272
+
273
+ 1. ai config edit
274
+ 2. 将其添加到您的配置中:
275
+
276
+ ```javascript
277
+ module.exports = {
278
+ // ... 其他配置
279
+ extensions: [
280
+ '/path/to/weather-extension.js'
281
+ ],
282
+ };
283
+ ```
284
+
285
+ **方法3:自动扫描**
286
+
287
+ 程序启动时会自动扫描以下目录中以“deepfish-”开头的目录。
288
+ 1.程序npm全局node_modules目录(扩展可通过"npm install -g deepfish-xxx" 安装)
289
+ 2.当前工作目录中的node_modules目录
290
+ 3.当前工作目录
291
+
292
+ ## 7. 建议
293
+
294
+ ### AI服务选择
295
+
296
+ **建议:使用在线AI服务(DeepSeek/OpenAI)以获得最佳效果**
297
+
298
+ 虽然本地AI服务(如Ollama)提供隐私保护和离线能力,但它们可能存在以下限制:
299
+
300
+ - **响应准确性**:本地模型可能不如在线模型严谨和精确
301
+ - **代码质量**:生成的代码可能需要更多的人工审查和修正
302
+ - **复杂任务处理**:在多步骤或复杂操作上可能遇到困难
303
+ - **语言理解**:在线服务提供更好的语言模型
304
+
305
+ 对于生产环境或复杂任务,我们建议使用DeepSeek或OpenAI服务,或Ollama中的云端服务,以获得更可靠和准确的结果。
306
+
307
+ ## 8. 使用说明
308
+
309
+ ### 使用相对路径
310
+
311
+ AI始终使用相对于当前工作目录的相对路径。
312
+
313
+ ## 9. 故障排除
314
+
315
+ ### 配置问题
316
+
317
+ 如果遇到配置错误,请尝试重置:
318
+
319
+ ```bash
320
+ ai config reset
321
+ ```
322
+
323
+ ### AI服务连接
324
+
325
+ - **Ollama**:确保Ollama在本地11434端口上运行
326
+ - **DeepSeek/OpenAI**:验证您的API密钥是否正确,并且您有足够的额度
327
+
328
+ ### 扩展未加载
329
+
330
+ - 检查配置中的文件路径
331
+ - 确保文件导出正确的对象
332
+ - 验证文件没有语法错误
333
+
334
+ ## 10. 贡献
335
+
336
+ 欢迎贡献!请随时提交Pull Request。
337
+
338
+ ## 11. 许可证
339
+
340
+ 本项目采用MIT许可证 - 详见[LICENSE](LICENSE)文件。
341
+
342
+ ## 12. 支持
343
+
344
+ 如有问题和疑问,请在GitHub仓库上提交issue。