autocoder-nano 0.1.6__tar.gz

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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,422 @@
1
+ Metadata-Version: 2.2
2
+ Name: autocoder_nano
3
+ Version: 0.1.6
4
+ Summary: AutoCoder Nano
5
+ Author: moofs
6
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: loguru
13
+ Requires-Dist: tabulate
14
+ Requires-Dist: GitPython
15
+ Requires-Dist: jinja2
16
+ Requires-Dist: openai>=1.14.3
17
+ Requires-Dist: prompt_toolkit
18
+ Requires-Dist: pydantic
19
+ Requires-Dist: rich
20
+ Requires-Dist: pylint
21
+ Requires-Dist: PyYAML
22
+ Dynamic: author
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # autocoder-nano
31
+
32
+ AutoCoder 社区是一个致力于简化开发者代码开发流程,提升开发效率的社区,开发有 auto-coder.chat (lite/pro), byzerllm 等项目,
33
+ autocoder-nano 是 AutoCoder 社区的全新成员,基于 auto-coder.chat 功能简化,可以理解成 auto-coder.chat 的轻量级版本。
34
+
35
+ #### nano/lite/pro 有什么区别?
36
+
37
+ - Pro:分布式架构,支持分布式部署模型,支持开源/SaaS模型管理,独特的 `human_as_model` 模式,RAG 支持,Design 设计支持,MCP支持,联网搜索支持,全局记忆支持,适合深度使用各种大模型的用户。
38
+ - Lite:放弃分布式架构,部分功能无法使用,主要针对 Windows 用户(第三方库兼容问题),以及需要快速启动并使用 auto-coder.chat 的用户。
39
+ - Nano:同样放弃分布式架构,为 auto-coder.chat 的移植版本,支持 `/chat`,`/coding`, `/文件管理`,`/索引管理` 等功能,依赖及代码极致精简,适合想要了解大模型辅助编程原理,以及想要实现自己辅助编程框架的用户
40
+
41
+ #### 为何选择 autocoder-nano?
42
+
43
+ - 轻量高效:无需复杂部署,极致精简,即装即用,使用 auto-coder 前可以先通过 autocoder-nano 熟悉相关功能。
44
+ - 灵活扩展:第三方依赖及代码精简,非常适合学习及魔改,同时兼容主流大模型,开发者可定制私有化模型链路。
45
+ - 场景全覆盖:从代码生成到运维脚本,一站式解决开发需求。
46
+ - 开源友好:持续迭代中,欢迎贡献代码与反馈!
47
+
48
+ #### autocoder-nano 的迭代方向
49
+
50
+ - 代码结构优化,便于后续维护及其他开发者魔改
51
+ - 并发支持,开发更大的项目
52
+ - 多语言优化,深度优化 Python 外的其他语言
53
+ - 候选模型支持,首选模型异常时进行切换
54
+ - RAG能力,支持一个简化的知识库,增强代码能力
55
+
56
+ ---
57
+
58
+ ## 核心功能
59
+
60
+ #### 配置即服务
61
+
62
+ - 开箱即用:项目初始化向导引导配置,5 分钟即可上手。
63
+ - 动态配置:通过 `/conf` 命令实时调整项目类型,模型选择,索引策略等参数。
64
+
65
+ #### 智能代码生成
66
+
67
+ - 精准控制:通过 `/coding` 命令结合 `@文件` 或 `@@符号`,实现函数级代码生成与修改。
68
+ - 多语言支持:原生支持 Python、TypeScript/JavaScript 等语言,灵活适配混合语言项目。
69
+ - 历史上下文:使用 `/coding /apply` 将对话历史融入代码生成,确保逻辑连贯性。
70
+
71
+ #### 大模型交互与配置
72
+
73
+ - 灵活模型管理:支持 OpenAI 格式的模型接入,一键添加、删除、检测模型状态。
74
+ - 双模型策略:独立配置对话/索引模型(current_chat_model)与代码生成模型(current_code_model),满足不同场景需求。
75
+
76
+ #### 智能文件管理
77
+
78
+ - 自动/手动模式:支持自动索引构建或手动管理活动文件。
79
+ - 文件组管理:通过分组快速切换上下文,提升多模块协作效率,轻松实现前后端配合开发。
80
+
81
+ #### 自然语言编程
82
+
83
+ - 指令即代码:直接输入自然语言,自动生成并执行 Shell/Python 脚本。
84
+ - 模式切换:快捷键 Ctrl+K 快速进入自然语言模式,无缝衔接开发与运维任务。
85
+
86
+ ---
87
+
88
+ ## 使用场景
89
+
90
+ 1. 代码维护:快速理解项目结构,生成函数级注释或单元测试。
91
+ 2. 效率提升:通过自然语言指令完成文件清理、批量重命名等重复任务。
92
+ 3. 混合开发:管理多语言项目,智能分析文件依赖关系。
93
+ 4. 模型实验:灵活切换不同大模型,对比生成效果,找到最优配置。
94
+
95
+ ---
96
+
97
+ * [安装](#安装)
98
+ * [快速开始](#快速开始)
99
+ * [模型管理](#模型管理)
100
+ * [配置管理](#配置管理)
101
+ * [文件管理](#文件管理)
102
+ * [索引管理](#索引管理)
103
+ * [Chat和Coding](#Chat和Coding)
104
+ * [自然语言模式](#自然语言模式)
105
+
106
+ ---
107
+
108
+ ## 安装
109
+
110
+ ```shell
111
+ $ conda create --name autocoder python=3.11.9
112
+ $ conda activate autocoder
113
+ $ pip install -U autocoder_nano
114
+ ```
115
+
116
+ ## 快速开始
117
+
118
+ ```shell
119
+ $ cd your-project
120
+ $ auto-coder.nano
121
+ ```
122
+
123
+ #### step 1: 项目初始化
124
+
125
+ ```
126
+ ! 正在初始化系统...
127
+ ! 当前目录未初始化为auto-coder项目。
128
+ 是否现在初始化项目?(y/n): y
129
+ ✓ 项目初始化成功。
130
+ ✓ 创建目录:/user/x/code/you-project/.auto-coder/plugins/chat-auto-coder
131
+ ```
132
+
133
+ #### step 2: 配置项目语言类型
134
+
135
+ ```
136
+ === 项目类型配置 ===
137
+
138
+ 项目类型支持:
139
+ - 语言后缀(例如:.py, .java, .ts)
140
+ - 预定义类型:py(Python), ts(TypeScript/JavaScript)
141
+ 对于混合语言项目,使用逗号分隔的值。
142
+ 示例:'.java,.scala' 或 '.py,.ts'
143
+ 如果留空,默认为 'py'。
144
+
145
+ 请输入项目类型:py
146
+
147
+ 项目类型设置为: py
148
+
149
+ 您可以稍后使用以下命令更改此设置:
150
+ /conf project_type:<new_type>
151
+ ```
152
+
153
+ #### step 3: 配置大模型
154
+
155
+ ```
156
+ ! 正在配置模型...
157
+ 设置你的首选模型名称(例如: deepseek-v3/r1, ark-deepseek-v3/r1): your-user-first-llm-custom-name
158
+ 请输入你使用模型的 Model Name: your-llm-model_name
159
+ 请输入你使用模型的 Base URL: your-llm-base-url
160
+ 请输入您的API密钥: your-llm-api-key
161
+ ! 正在更新缓存...
162
+ ! 正在部署 your-user-first-llm 模型...
163
+ ```
164
+
165
+ #### step 4: 初始化完成, 开始与大模型交流
166
+
167
+ ```
168
+ ✓ 初始化完成。
169
+ AutoCoder Nano v0.1.5
170
+ 输入 /help 可以查看可用的命令.
171
+
172
+ coding@auto-coder.nano:~$ /chat 描述一下这个项目的主要功能
173
+ ```
174
+
175
+
176
+ ## 模型管理
177
+
178
+ #### 列出模型
179
+
180
+ ```
181
+ coding@auto-coder.nano:~$ /models /list
182
+ 模型
183
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
184
+ ┃ Name ┃ Model Name ┃ Base URL ┃
185
+ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
186
+ │ xxx-deepseek-v3 │ xxxxxxxxxxxx │ https://xxxxx.com/api/v3 │
187
+ └──────────────────────────────┴─────────────────────┴────────────────────────────┘
188
+ ```
189
+
190
+ #### 新增模型
191
+
192
+ 兼容所有 OpenAI 格式的模型
193
+
194
+ - name=deepseek-r1,为新增的模型取的一个别名,可以精简,便于后续使用
195
+ - base_url=https://api.deepseek.com, 模型厂商提供的 saas api 接口
196
+ - api_key=sk-xx, 访问模型所需的key
197
+ - model=deepseek-reasoner, 模型厂商内部可能会提供多种可选的能力模型,比如 r1 / v3
198
+
199
+ ```
200
+ coding@auto-coder.nano:~$ /models /add_model name=deepseek-r1 base_url=https://api.deepseek.com api_key=sk-xx model=deepseek-reasoner
201
+ 2025-02-11 10:11:22.124 | INFO | autocoder_nano.auto_coder_nano:manage_models:3788 - 正在为 deepseek-r1 更新缓存信息
202
+ 2025-02-11 10:11:22.125 | INFO | autocoder_nano.auto_coder_nano:manage_models:3797 - 正在部署 deepseek-r1 模型
203
+ coding@auto-coder.nano:~$ /models /list
204
+ 模型
205
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
206
+ ┃ Name ┃ Model Name ┃ Base URL ┃
207
+ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
208
+ │ xxx-deepseek-v3 │ xxxxxxxxxxxx │ https://xxxxx.com/api/v3 │
209
+ ├──────────────────────────────┼─────────────────────┼────────────────────────────┤
210
+ │ deepseek-r1 │ deepseek-reasoner │ https://api.deepseek.com │
211
+ └──────────────────────────────┴─────────────────────┴────────────────────────────┘
212
+ ```
213
+
214
+ #### 删除模型
215
+
216
+ ```
217
+ coding@auto-coder.nano:~$ /models /remove deepseek-r1
218
+ 2025-02-11 10:17:59.930 | INFO | autocoder_nano.auto_coder_nano:manage_models:3801 - 正在清理 deepseek-r1 缓存信息
219
+ 2025-02-11 10:17:59.930 | INFO | autocoder_nano.auto_coder_nano:manage_models:3804 - 正在卸载 deepseek-r1 模型
220
+ ```
221
+
222
+ #### 模型状态检测
223
+
224
+ ```
225
+ coding@auto-coder.nano:~$ /models /check
226
+ 2025-02-11 10:19:23.494 | INFO | autocoder_nano.auto_coder_nano:check_models:3757 - 正在测试 xxx-deepseek-v3 模型
227
+ 2025-02-11 10:19:23.495 | INFO | autocoder_nano.auto_coder_nano:stream_chat_ai:1037 - 正在使用 xxx-deepseek-v3 模型, 模型名称 xxxxxxxxxxxx
228
+ 模型状态检测
229
+ ┏━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━┓
230
+ ┃ 模型 ┃ 状态 ┃ 延迟 ┃
231
+ ┡━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━┩
232
+ │ xxx-deepseek-v3 │ ✓ │ 1.36s │
233
+ └─────────────────┴──────┴───────┘
234
+ ```
235
+
236
+ ## 配置管理
237
+
238
+ #### 列出配置
239
+
240
+ ```
241
+ coding@auto-coder.nano:~$ /conf
242
+ 使用 /conf <key>:<value> 修改这些设置
243
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
244
+ ┃ 键 ┃ 值 ┃
245
+ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
246
+ │ auto_merge │ editblock │
247
+ ├───────────────────────────────┼──────────────────────────────┤
248
+ │ current_chat_model │ xxx-deepseek-v3 │
249
+ ├───────────────────────────────┼──────────────────────────────┤
250
+ │ current_code_model │ xxx-deepseek-v3 │
251
+ ├───────────────────────────────┼──────────────────────────────┤
252
+ │ project_type │ py │
253
+ ├───────────────────────────────┼──────────────────────────────┤
254
+ │ skip_build_index │ false │
255
+ └───────────────────────────────┴──────────────────────────────┘
256
+ ```
257
+
258
+ #### 更改配置
259
+
260
+ ```
261
+ coding@auto-coder.nano:~$ /conf skip_filter_index:false
262
+ Set skip_filter_index to false
263
+ coding@auto-coder.nano:~$ /conf index_filter_level:2
264
+ Set index_filter_level to 2
265
+ ```
266
+
267
+ #### 配置当前使用模型
268
+
269
+ 当你新增某个模型后,想要进行替换使用,假设你的模型别名为 _t-deepseek-r1_ , 使用以下命令进行模型配置更改:
270
+
271
+ ```shell
272
+ coding@auto-coder.nano:~$ /conf current_chat_model:t-deepseek-r1
273
+ Set current_chat_model to t-deepseek-r1
274
+ coding@auto-coder.nano:~$ /conf current_code_model:t-deepseek-r1
275
+ Set current_code_model to t-deepseek-r1
276
+ ```
277
+
278
+ - current_chat_model :配置与大模型聊天以及索引生成所使用的模型
279
+ - current_code_model :配置代码生成使用的模型
280
+
281
+
282
+ ## 文件管理
283
+
284
+ Auto-coder 里有两种方式管理你的项目上下文:
285
+
286
+ 1. 设置 `/conf skip_index_build:false` 后,系统会自动根据你的需求自动查找相关文件。即自动管理模式。
287
+ 2. 当你设置 `/conf skip_index_build:true` 后,则通过活动文件来管理,我们提供了 `/add_files /remove_files /list_files` 来组合。即手动管理模式。
288
+
289
+ Auto-coder 文件组概念:
290
+
291
+ 1. Auto-coder 系列提供了一个活动文件组的概念。 你可以通过 `/add_files /group /add app` 来添加一个叫 app的组,这个组会复制当前的所有活动文件。
292
+ 2. 通过手动切换文件组来完成上下文的管理,是手动管理文件的高级方法
293
+
294
+
295
+ #### /list_files 命令
296
+
297
+ ```shell
298
+ # 列出当前活跃文件
299
+ coding@auto-coder.nano:~$ /list_files
300
+ ```
301
+
302
+ #### /add_files 命令
303
+
304
+ ```shell
305
+ # 添加单个/多个文件为活跃文件
306
+ coding@auto-coder.nano:~$ /add_files file1 file2 file3
307
+ coding@auto-coder.nano:~$ /add_files /path/abc/file4 /path/abc/file5
308
+
309
+ # 查看当前所有的文件组
310
+ coding@auto-coder.nano:~$ /add_files /group
311
+
312
+ # 将当前活跃文件添加进 app 文件组
313
+ coding@auto-coder.nano:~$ /add_files /group /add app
314
+
315
+ # 设置活跃文件组
316
+ coding@auto-coder.nano:~$ /add_files /group app
317
+
318
+ # 删除文件组
319
+ coding@auto-coder.nano:~$ /add_files /group /drop app
320
+
321
+ # 合并两个文件组的文件为当前活跃文件
322
+ coding@auto-coder.nano:~$ /add_files /group <groupname>,<groupname>
323
+
324
+ # 当目录中新增一个文件后,自动补全无法获取该文件,可执行一次刷新
325
+ coding@auto-coder.nano:~$ /add_files /refresh
326
+ ```
327
+
328
+ - `/add_files` 支持文件匹配符,比如可以通过 `/add_files ./**/*.py` 把当前目录下所有的python文件加到活动文件里去(如果你项目很大,不能这么做,会超出大模型上线文限制)。
329
+
330
+
331
+ #### /remove_files 命令
332
+
333
+ ```shell
334
+ # 将 file1 移出当前活跃文件
335
+ coding@auto-coder.nano:~$ /remove_files file1
336
+
337
+ # 清空当前所有活跃文件
338
+ coding@auto-coder.nano:~$ /remove_files /all
339
+ ```
340
+
341
+
342
+ ## 索引管理
343
+
344
+
345
+ ## Chat和Coding
346
+
347
+ Chat与大模型沟通
348
+
349
+ - 当你设置了活跃文件和 `/conf skip_index_build:true` , `/chat` 可以方便的针对当前活跃文件进行提问
350
+ - 当你设置了 `/conf skip_index_build:false` , `/chat` 会根据所有代码文件来回答问题
351
+
352
+ ```shell
353
+ coding@auto-coder.nano:~$ /add_files ./**/*.py
354
+
355
+ coding@auto-coder.nano:~$ /list_files
356
+
357
+ coding@auto-coder.nano:~$ /chat 请问这些文件之间的关系是什么
358
+ coding@auto-coder.nano:~$ /chat 给我描述一下这个项目的用途
359
+ ```
360
+
361
+
362
+ Coding使用大模型进行编码
363
+
364
+ - `/coding` 可以根据需求,对当前活跃文件,或者自行匹配候选文件,进行修改
365
+ - `/coding /apply` 此时 Autocoder 会把我们与大模型之间的历史对话记录加入到代码生成的 Prompt 里
366
+
367
+ ```shell
368
+ coding@auto-coder.nano:~$ /coding /apply 新增一个命令行参数 --chat_model
369
+ ```
370
+
371
+ #### 精准控制代码生成
372
+
373
+ Autocoder 提供了两个机制:
374
+ 1. 使用 `@` 自动补全文件
375
+ 2. 使用 `@@` 自动补全符号(类或者函数)
376
+
377
+ 在 `/coding` 或者 `/chat` 的时候,用户可以通过上述两个语法快速定位到某个文件,类或者函数,然后最小粒度是函数级别,
378
+ 让 Autocoder 帮你做修改。比如你 @@函数A, 然后让大模型自动实现该函数或者让大模型给该函数生成测试
379
+
380
+
381
+ ## 自然语言模式
382
+
383
+ 场景:实际编程的过程中,程序员会大量使用命令行来完成一些工作
384
+
385
+ - 比如启动一个服务,发现服务端口被占用,这个时候你可能想查看这个端口到底被哪个其他服务占用
386
+ - 想要对目录中的 .jpg 文件进行批量改名
387
+ - 再或者突然忘记某个命令的参数
388
+
389
+ 切换自然语言模式
390
+
391
+ 使用 Ctrl + k 快捷键,或者以下方式可切换模式
392
+
393
+ ```shell
394
+ coding@auto-coder.nano:~$ /mode auto_detect
395
+ ```
396
+
397
+ 放终端最下方显示 `当前模式: 自然语言模式 (ctl+k 切换模式)` 即切换成功
398
+
399
+ ```
400
+ coding@auto-coder.nano:~$ 递归删除当前项目所有 __pycache__ 目录
401
+ ╭────────────────────────────────────────────────────────── 命令生成 ─────────╮
402
+ │ 正在根据用户输入 递归删除当前项目所有 __pycache__ 目录 生成 Shell 脚本... │
403
+ ╰────────────────────────────────────────────────────────────────────────────╯
404
+ 2025-02-11 15:02:31.305 | INFO | autocoder_nano.auto_coder_nano:chat_ai:1057 - 正在使用 ark-deepseek-v3 模型, 模型名称 ep-20250205104003-d8hqb
405
+ ╭───────────────────────────────────────────────────────── Shell 脚本 ──────────────────────╮
406
+ │ #!/bin/bash │
407
+ │ │
408
+ │ # 递归删除当前项目所有 __pycache__ 目录的脚本 │
409
+ │ │
410
+ │ # 使用 find 命令查找当前目录及其子目录中的所有 __pycache__ 目录 │
411
+ │ # -type d: 只查找目录 │
412
+ │ # -name "__pycache__": 匹配名为 __pycache__ 的目录 │
413
+ │ # -exec rm -rf {} +: 对找到的每个目录执行 rm -rf 命令,递归删除目录及其内容 │
414
+ │ # 使用 {} + 而不是 {} \; 是为了将多个结果一次性传递给 rm 命令,提高效率 │
415
+ │ │
416
+ │ find . -type d -name "__pycache__" -exec rm -rf {} + │
417
+ │ │
418
+ │ # 提示用户操作完成 │
419
+ │ echo "所有 __pycache__ 目录已成功删除。" │
420
+ ╰───────────────────────────────────────────────────────────────────────────────────────────╯
421
+ 是否要执行此脚本? (y/n) n
422
+ ```