autocoder-nano 0.1.27__py3-none-any.whl → 0.1.28__py3-none-any.whl
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.
- autocoder_nano/auto_coder_nano.py +86 -3
- autocoder_nano/llm_types.py +1 -0
- autocoder_nano/project/pyproject.py +1 -1
- autocoder_nano/project/suffixproject.py +1 -1
- autocoder_nano/version.py +1 -1
- autocoder_nano-0.1.28.dist-info/METADATA +445 -0
- {autocoder_nano-0.1.27.dist-info → autocoder_nano-0.1.28.dist-info}/RECORD +11 -11
- autocoder_nano-0.1.27.dist-info/METADATA +0 -432
- {autocoder_nano-0.1.27.dist-info → autocoder_nano-0.1.28.dist-info}/LICENSE +0 -0
- {autocoder_nano-0.1.27.dist-info → autocoder_nano-0.1.28.dist-info}/WHEEL +0 -0
- {autocoder_nano-0.1.27.dist-info → autocoder_nano-0.1.28.dist-info}/entry_points.txt +0 -0
- {autocoder_nano-0.1.27.dist-info → autocoder_nano-0.1.28.dist-info}/top_level.txt +0 -0
@@ -52,7 +52,7 @@ base_persist_dir = os.path.join(project_root, ".auto-coder", "plugins", "chat-au
|
|
52
52
|
# ".vscode", ".idea", ".hg"]
|
53
53
|
commands = [
|
54
54
|
"/add_files", "/remove_files", "/list_files", "/conf", "/coding", "/chat", "/revert", "/index/query",
|
55
|
-
"/index/build", "/exclude_dirs", "/help", "/shell", "/exit", "/mode", "/models", "/commit", "/new"
|
55
|
+
"/index/build", "/exclude_dirs", "/exclude_files", "/help", "/shell", "/exit", "/mode", "/models", "/commit", "/new"
|
56
56
|
]
|
57
57
|
|
58
58
|
memory = {
|
@@ -197,7 +197,9 @@ COMMANDS = {
|
|
197
197
|
"/conf": "",
|
198
198
|
"/mode": "",
|
199
199
|
"/models": ""
|
200
|
-
}
|
200
|
+
},
|
201
|
+
"/exclude_files": {"/list": "", "/drop": ""},
|
202
|
+
"/exclude_dirs": {}
|
201
203
|
}
|
202
204
|
|
203
205
|
|
@@ -675,6 +677,15 @@ class CommandCompleter(Completer):
|
|
675
677
|
if current_word and current_word in file_name:
|
676
678
|
yield Completion(file_name, start_position=-len(current_word))
|
677
679
|
|
680
|
+
elif words[0] == "/exclude_files":
|
681
|
+
new_text = text[len("/exclude_files"):]
|
682
|
+
parser = CommandTextParser(new_text, words[0])
|
683
|
+
parser.add_files()
|
684
|
+
current_word = parser.current_word()
|
685
|
+
for command in parser.get_sub_commands():
|
686
|
+
if command.startswith(current_word):
|
687
|
+
yield Completion(command, start_position=-len(current_word))
|
688
|
+
|
678
689
|
elif words[0] == "/models":
|
679
690
|
new_text = text[len("/models"):]
|
680
691
|
parser = CommandTextParser(new_text, words[0])
|
@@ -772,6 +783,71 @@ def load_memory():
|
|
772
783
|
completer.update_current_files(memory["current_files"]["files"])
|
773
784
|
|
774
785
|
|
786
|
+
def exclude_dirs(dir_names: List[str]):
|
787
|
+
new_dirs = dir_names
|
788
|
+
existing_dirs = memory.get("exclude_dirs", [])
|
789
|
+
dirs_to_add = [d for d in new_dirs if d not in existing_dirs]
|
790
|
+
|
791
|
+
if dirs_to_add:
|
792
|
+
existing_dirs.extend(dirs_to_add)
|
793
|
+
if "exclude_dirs" not in memory:
|
794
|
+
memory["exclude_dirs"] = existing_dirs
|
795
|
+
print(f"Added exclude dirs: {dirs_to_add}")
|
796
|
+
for d in dirs_to_add:
|
797
|
+
exclude_files(f"regex://.*/{d}/*.")
|
798
|
+
# exclude_files([f"regex://.*/{d}/*." for d in dirs_to_add])
|
799
|
+
else:
|
800
|
+
print("All specified dirs are already in the exclude list.")
|
801
|
+
save_memory()
|
802
|
+
completer.refresh_files()
|
803
|
+
|
804
|
+
|
805
|
+
def exclude_files(query: str):
|
806
|
+
if "/list" in query:
|
807
|
+
query = query.replace("/list", "", 1).strip()
|
808
|
+
existing_file_patterns = memory.get("exclude_files", [])
|
809
|
+
|
810
|
+
# 打印表格
|
811
|
+
table = Table(title="Exclude Files")
|
812
|
+
table.add_column("File Pattern")
|
813
|
+
for file_pattern in existing_file_patterns:
|
814
|
+
table.add_row(file_pattern)
|
815
|
+
console.print(table)
|
816
|
+
return
|
817
|
+
|
818
|
+
if "/drop" in query:
|
819
|
+
query = query.replace("/drop", "", 1).strip()
|
820
|
+
existing_file_patterns = memory.get("exclude_files", [])
|
821
|
+
existing_file_patterns.remove(query.strip())
|
822
|
+
memory["exclude_files"] = existing_file_patterns
|
823
|
+
if query.startswith("regex://.*/") and query.endswith("/*."):
|
824
|
+
existing_dirs_patterns = memory.get("exclude_dirs", [])
|
825
|
+
dir_query = query.replace("regex://.*/", "", 1).replace("/*.", "", 1)
|
826
|
+
if dir_query in existing_dirs_patterns:
|
827
|
+
existing_dirs_patterns.remove(dir_query.strip())
|
828
|
+
save_memory()
|
829
|
+
completer.refresh_files()
|
830
|
+
return
|
831
|
+
|
832
|
+
new_file_patterns = query.strip().split(",")
|
833
|
+
|
834
|
+
existing_file_patterns = memory.get("exclude_files", [])
|
835
|
+
file_patterns_to_add = [f for f in new_file_patterns if f not in existing_file_patterns]
|
836
|
+
|
837
|
+
for file_pattern in file_patterns_to_add:
|
838
|
+
if not file_pattern.startswith("regex://"):
|
839
|
+
raise
|
840
|
+
|
841
|
+
if file_patterns_to_add:
|
842
|
+
existing_file_patterns.extend(file_patterns_to_add)
|
843
|
+
if "exclude_files" not in memory:
|
844
|
+
memory["exclude_files"] = existing_file_patterns
|
845
|
+
save_memory()
|
846
|
+
print(f"Added exclude files: {file_patterns_to_add}")
|
847
|
+
else:
|
848
|
+
print("All specified files are already in the exclude list.")
|
849
|
+
|
850
|
+
|
775
851
|
def index_command(llm):
|
776
852
|
update_config_to_args(query="", delete_execute_file=True)
|
777
853
|
|
@@ -965,7 +1041,8 @@ def update_config_to_args(query, delete_execute_file: bool = False):
|
|
965
1041
|
"skip_confirm": conf.get("skip_confirm", "true") == "true",
|
966
1042
|
"chat_model": conf.get("chat_model", ""),
|
967
1043
|
"code_model": conf.get("code_model", ""),
|
968
|
-
"auto_merge": conf.get("auto_merge", "editblock")
|
1044
|
+
"auto_merge": conf.get("auto_merge", "editblock"),
|
1045
|
+
"exclude_files": memory.get("exclude_files", [])
|
969
1046
|
}
|
970
1047
|
current_files = memory["current_files"]["files"]
|
971
1048
|
yaml_config["urls"] = current_files
|
@@ -2509,6 +2586,12 @@ def main():
|
|
2509
2586
|
print(f"{memory['mode']} [{MODES[memory['mode']]}]")
|
2510
2587
|
else:
|
2511
2588
|
memory["mode"] = conf
|
2589
|
+
elif user_input.startswith("/exclude_dirs"):
|
2590
|
+
dir_names = user_input[len("/exclude_dirs"):].strip().split(",")
|
2591
|
+
exclude_dirs(dir_names)
|
2592
|
+
elif user_input.startswith("/exclude_files"):
|
2593
|
+
query = user_input[len("/exclude_files"):].strip()
|
2594
|
+
exclude_files(query)
|
2512
2595
|
else:
|
2513
2596
|
command = user_input
|
2514
2597
|
if user_input.startswith("/shell"):
|
autocoder_nano/llm_types.py
CHANGED
@@ -36,6 +36,7 @@ class AutoCoderArgs(BaseModel):
|
|
36
36
|
model_max_input_length: Optional[int] = 6000 # 模型最大输入长度
|
37
37
|
skip_confirm: Optional[bool] = False
|
38
38
|
silence: Optional[bool] = False
|
39
|
+
exclude_files: Optional[Union[str, List[str]]] = ""
|
39
40
|
|
40
41
|
# RAG 相关参数
|
41
42
|
rag_url: Optional[str] = ""
|
@@ -15,7 +15,7 @@ class PyProject:
|
|
15
15
|
self.args = args
|
16
16
|
self.target_file = args.target_file
|
17
17
|
self.directory = args.source_dir
|
18
|
-
self.exclude_files = exclude_files
|
18
|
+
self.exclude_files = args.exclude_files
|
19
19
|
self.exclude_patterns = self.parse_exclude_files(self.exclude_files)
|
20
20
|
self.sources = []
|
21
21
|
self.sources_set = set()
|
@@ -20,7 +20,7 @@ class SuffixProject:
|
|
20
20
|
suffix.strip() if suffix.startswith(".") else f".{suffix.strip()}"
|
21
21
|
for suffix in self.project_type.split(",") if suffix.strip()
|
22
22
|
]
|
23
|
-
self.exclude_files = exclude_files
|
23
|
+
self.exclude_files = args.exclude_files
|
24
24
|
self.exclude_patterns = self.parse_exclude_files(self.exclude_files)
|
25
25
|
self.sources = []
|
26
26
|
self.sources_set = set()
|
autocoder_nano/version.py
CHANGED
@@ -0,0 +1,445 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: autocoder_nano
|
3
|
+
Version: 0.1.28
|
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
|
+
Requires-Dist: pdfminer
|
23
|
+
Requires-Dist: pypdf
|
24
|
+
Requires-Dist: uvicorn
|
25
|
+
Requires-Dist: pathspec
|
26
|
+
Requires-Dist: fastapi
|
27
|
+
Requires-Dist: tokenizers
|
28
|
+
Requires-Dist: duckdb
|
29
|
+
Requires-Dist: numpy
|
30
|
+
Requires-Dist: requests
|
31
|
+
Requires-Dist: beautifulsoup4
|
32
|
+
Dynamic: author
|
33
|
+
Dynamic: classifier
|
34
|
+
Dynamic: description
|
35
|
+
Dynamic: description-content-type
|
36
|
+
Dynamic: requires-dist
|
37
|
+
Dynamic: requires-python
|
38
|
+
Dynamic: summary
|
39
|
+
|
40
|
+
## 概述
|
41
|
+
|
42
|
+
AutoCoder Nano 是一款轻量级的编码助手, 利用大型语言模型(LLMs)帮助开发者编写, 理解和修改代码。
|
43
|
+
|
44
|
+
它提供了一个交互式命令行界面,支持在软件开发场景中与LLMs互动,具备代码生成, 文件管理和上下文代码理解等功能。
|
45
|
+
|
46
|
+
本概述介绍了 AutoCoder Nano 的用途, 架构和核心组件。如需了解更多子系统的详细信息,请参阅相关页面,例如
|
47
|
+
|
48
|
+
- 命令行界面
|
49
|
+
- LLM集成
|
50
|
+
- RAG系统
|
51
|
+
|
52
|
+
### 1.什么是 AutoCoder Nano?
|
53
|
+
|
54
|
+
AutoCoder Nano 是 Auto-Coder 生态系统的简化版本,设计轻量且依赖极少。它旨在通过提供增强AI功能的命令行界面,弥合自然语言指令与代码修改之间的鸿沟。
|
55
|
+
|
56
|
+
Auto-Coder 主社区[点击跳转](https://github.com/allwefantasy/auto-coder)
|
57
|
+
|
58
|
+
**AutoCoder Nano 的主要特点:**
|
59
|
+
|
60
|
+
- 轻量级:依赖极少,代码库精简
|
61
|
+
- 交互式:支持丰富补全和建议的命令行界面
|
62
|
+
- AI驱动:集成多种大型语言模型
|
63
|
+
- 上下文感知:利用文件索引和检索实现上下文理解
|
64
|
+
- 多功能:支持多种项目类型和编程语言
|
65
|
+
|
66
|
+
**nano/lite/pro 有什么区别?**
|
67
|
+
|
68
|
+
- Pro:分布式架构,支持分布式部署模型,支持开源/SaaS模型管理,独特的 `human_as_model` 模式,RAG 支持,Design 设计支持,MCP支持,联网搜索支持,全局记忆支持,适合深度使用各种大模型的用户。
|
69
|
+
- Lite:放弃分布式架构,部分功能无法使用,主要针对 Windows 用户(第三方库兼容问题),以及需要快速启动并使用 auto-coder.chat 的用户。
|
70
|
+
- Nano:同样放弃分布式架构,为 auto-coder.chat 的移植版本,支持 `/chat`,`/coding`, `/文件管理`,`/索引管理` 等功能,依赖及代码极致精简,适合想要了解大模型辅助编程原理,以及想要实现自己辅助编程框架的用户
|
71
|
+
|
72
|
+
**autocoder-nano 的迭代方向:**
|
73
|
+
|
74
|
+
- 代码结构优化,便于后续维护及其他开发者魔改
|
75
|
+
- 并发支持,开发更大的项目
|
76
|
+
- 多语言优化,深度优化 Python 外的其他语言
|
77
|
+
- 候选模型支持,首选模型异常时进行切换
|
78
|
+
- RAG能力,支持一个简化的知识库,增强代码能力
|
79
|
+
|
80
|
+
### 2.系统架构
|
81
|
+
|
82
|
+
AutoCoder Nano 采用模块化架构,以命令行界面为核心,连接多个子系统。
|
83
|
+
|
84
|
+
#### 2.1.高级架构图
|
85
|
+
|
86
|
+
### 3.核心组件
|
87
|
+
|
88
|
+
#### 3.1.命令行界面(CLI)
|
89
|
+
|
90
|
+
CLI 是用户与 AutoCoder Nano 交互的主要入口,负责解析用户命令, 提供自动补全并显示响应。
|
91
|
+
|
92
|
+
主要功能:
|
93
|
+
|
94
|
+
- 命令解析与补全
|
95
|
+
- 文件和符号建议
|
96
|
+
- 响应内容的富文本渲染
|
97
|
+
- 交互式会话管理
|
98
|
+
|
99
|
+
CLI 支持多种命令类别:
|
100
|
+
|
101
|
+
| 命令类别 | 示例命令 | 用途 |
|
102
|
+
|----------|----------------------------------------------|---------------------|
|
103
|
+
| **对话** | `/chat`, `/coding` | 与LLM交互,处理通用查询或代码生成 |
|
104
|
+
| **文件管理** | `/add_files`, `/remove_files`, `/list_files` | 管理当前上下文中的活动文件 |
|
105
|
+
| **配置** | `/conf`, `/mode` | 配置系统设置和行为 |
|
106
|
+
| **模型管理** | `/models /add_model`, `/models /list` | 管理LLM集成设置 |
|
107
|
+
| **索引** | `/index/build`, `/index/query` | 构建和查询代码索引 |
|
108
|
+
| **工具** | `/help`, `/shell`, `/exit` | 获取帮助、执行Shell命令或退出应用 |
|
109
|
+
|
110
|
+
|
111
|
+
#### 3.2.内存系统
|
112
|
+
|
113
|
+
AutoCoder Nano 使用内存字典存储以下状态:
|
114
|
+
|
115
|
+
- 对话历史, 即与大模型 `/chat` 的历史
|
116
|
+
- 活动文件及文件组
|
117
|
+
- 配置设置
|
118
|
+
- 模型配置
|
119
|
+
- 目录排除设置
|
120
|
+
|
121
|
+
```python
|
122
|
+
memory = {
|
123
|
+
"conversation": [], # 对话历史
|
124
|
+
"current_files": {"files": [], "groups": {}}, # 文件管理
|
125
|
+
"conf": { # 配置设置
|
126
|
+
"auto_merge": "editblock",
|
127
|
+
"chat_model": "",
|
128
|
+
"code_model": "",
|
129
|
+
},
|
130
|
+
"exclude_dirs": [], # 目录排除设置
|
131
|
+
"mode": "normal", # 新增mode字段,默认为normal模式
|
132
|
+
"models": {} # 模型配置
|
133
|
+
}
|
134
|
+
```
|
135
|
+
|
136
|
+
内存系统支持会话间持久化,确保复杂项目的连续性。
|
137
|
+
|
138
|
+
|
139
|
+
#### 3.3.项目管理
|
140
|
+
|
141
|
+
AutoCoder Nano 支持多种项目类型, 并提供针对性支持:
|
142
|
+
|
143
|
+
- Python项目: 处理模块、导入和结构
|
144
|
+
- TypeScript项目: 支持TypeScript/JavaScript文件及依赖
|
145
|
+
- 自定义项目: 基于文件扩展名的通用支持
|
146
|
+
|
147
|
+
项目管理子系统负责理解代码库结构, 识别相关文件, 并为LLM提供适当的上下文。
|
148
|
+
|
149
|
+
#### 3.4.LLM集成
|
150
|
+
|
151
|
+
LLM集成子系统通过以下方式连接 AutoCoder Nano 与多种大型语言模型:
|
152
|
+
|
153
|
+
- 模型配置与选择
|
154
|
+
- API通信
|
155
|
+
- 响应处理
|
156
|
+
- Token管理
|
157
|
+
|
158
|
+
AutoCoder Nano 支持为聊天/索引和代码生成配置不同模型,以优化任务性能。
|
159
|
+
|
160
|
+
|
161
|
+
### 4.用户工作流
|
162
|
+
|
163
|
+
#### 4.1.项目初始化与配置
|
164
|
+
|
165
|
+
1. 通过 `/chat` 询问有关代码的问题。
|
166
|
+
2. 对于现有项目,配置项目语言(`/conf project_type:py`)
|
167
|
+
3. 配置大语言模型(`/models /add_model`)后
|
168
|
+
4. 即可使用 `/coding` 生成修改代码
|
169
|
+
5. `/coding/apply` 使用聊天历史记录
|
170
|
+
6. `/index` 管理代码索引
|
171
|
+
7. `/models` 配置模型。
|
172
|
+
|
173
|
+
#### 4.2.代码生成流程
|
174
|
+
|
175
|
+
AutoCoder Nano 的代码生成流程如下:
|
176
|
+
|
177
|
+
- 用户通过 `/coding` [请求] 发起代码生成请求
|
178
|
+
- 系统从活动文件中收集上下文 or 通过索引自动获取上下文
|
179
|
+
- 将上下文和请求发送至配置的LLM
|
180
|
+
- 生成的代码呈现给用户
|
181
|
+
- 修改可应用于代码库
|
182
|
+
- 可选的Git集成支持版本控制
|
183
|
+
|
184
|
+
### 5.关键特性
|
185
|
+
|
186
|
+
#### 5.1.文件管理
|
187
|
+
|
188
|
+
文件管理包括:
|
189
|
+
|
190
|
+
- 查找符合特定模式的文件
|
191
|
+
- 从处理中排除指定目录
|
192
|
+
- 计算文件哈希以检测变更
|
193
|
+
|
194
|
+
AutoCoder Nano 提供两种文件管理方式:
|
195
|
+
|
196
|
+
- 自动模式: 系统根据查询自动识别相关文件
|
197
|
+
- 手动模式: 用户显式管理活动文件
|
198
|
+
|
199
|
+
文件分组功能允许用户为特定任务组织相关文件:
|
200
|
+
|
201
|
+
```bash
|
202
|
+
coding@auto-coder.nano:~$ /add_files /group /add frontend
|
203
|
+
coding@auto-coder.nano:~$ /add_files /group /add backend
|
204
|
+
coding@auto-coder.nano:~$ /add_files /group frontend
|
205
|
+
```
|
206
|
+
|
207
|
+
#### 5.2.自然语言编程
|
208
|
+
|
209
|
+
AutoCoder Nano 提供自然语言模式以生成和执行脚本:
|
210
|
+
|
211
|
+
1. 通过 /mode auto_detect 或 Ctrl+K 切换模式
|
212
|
+
2. 输入自然语言指令
|
213
|
+
3. 系统生成对应脚本
|
214
|
+
4. 用户可审核并执行脚本
|
215
|
+
|
216
|
+
此功能弥合了自然语言指令与可执行命令之间的差距。
|
217
|
+
|
218
|
+
|
219
|
+
#### 5.3.代码索引与检索
|
220
|
+
|
221
|
+
AutoCoder Nano 构建并维护项目中代码实体的索引:
|
222
|
+
|
223
|
+
- 提取函数、类和变量并建立索引
|
224
|
+
- 查询可以检索相关的代码实体
|
225
|
+
- 识别相关文件以提供更好的上下文
|
226
|
+
- 索引系统有助于更有针对性和高效地理解和生成代码。
|
227
|
+
|
228
|
+
### 6.安装与设置
|
229
|
+
|
230
|
+
#### 6.1.系统要求
|
231
|
+
|
232
|
+
在安装 AutoCoder Nano 之前,请确保你的系统满足以下条件:
|
233
|
+
|
234
|
+
- Python 3.10 或更高版本(推荐 Python 3.11.9 )
|
235
|
+
- 操作系统:Windows、macOS 或 Linux
|
236
|
+
- 至少能访问一个与 OpenAI API 格式兼容的大语言模型服务
|
237
|
+
|
238
|
+
#### 6.2.安装方法
|
239
|
+
|
240
|
+
使用 pip(推荐): 推荐的安装方式是在专用虚拟环境中使用 pip 进行安装
|
241
|
+
|
242
|
+
```shell
|
243
|
+
# 创建conda环境
|
244
|
+
conda create --name autocoder python=3.11.9
|
245
|
+
# 激活环境
|
246
|
+
conda activate autocoder
|
247
|
+
# 安装AutoCoder Nano
|
248
|
+
pip install -U autocoder-nano
|
249
|
+
```
|
250
|
+
|
251
|
+
从源代码安装
|
252
|
+
|
253
|
+
```shell
|
254
|
+
# 克隆仓库
|
255
|
+
git clone https://github.com/w4n9H/autocoder-nano.git
|
256
|
+
# 进入项目目录
|
257
|
+
cd autocoder-nano
|
258
|
+
# 安装依赖
|
259
|
+
pip install -r requirements.txt
|
260
|
+
# 以开发模式安装
|
261
|
+
pip install -e .
|
262
|
+
```
|
263
|
+
|
264
|
+
安装完成后,AutoCoder Nano 提供以下三个主要命令行工具:
|
265
|
+
|
266
|
+
| 命令 | 描述 |
|
267
|
+
|---------------------|------------------------------|
|
268
|
+
| auto-coder.nano | 代码生成和聊天交互的主界面 |
|
269
|
+
| auto-coder.nano.rag | 基于检索增强生成的上下文感知响应系统 |
|
270
|
+
| auto-coder.nano.ui | AutoCoder Nano 的基于 Web 的用户界面 |
|
271
|
+
|
272
|
+
|
273
|
+
#### 6.3.项目初始化
|
274
|
+
|
275
|
+
安装完成后,需要为项目初始化 AutoCoder Nano。设置过程包括项目初始化、语言配置和 LLM 模型配置。
|
276
|
+
进入项目目录并运行 AutoCoder Nano:
|
277
|
+
|
278
|
+
```bash
|
279
|
+
cd your-project
|
280
|
+
auto-coder.nano
|
281
|
+
```
|
282
|
+
|
283
|
+
首次运行时,系统会检测到当前目录未初始化,并提示初始化:
|
284
|
+
|
285
|
+
```
|
286
|
+
! 正在初始化系统...
|
287
|
+
! 当前目录未初始化为 auto-coder 项目。
|
288
|
+
是否现在初始化项目?(y/n):y
|
289
|
+
✓ 项目初始化成功。
|
290
|
+
✓ 创建目录:/your-project/.auto-coder/plugins/chat-auto-coder
|
291
|
+
```
|
292
|
+
|
293
|
+
> 这将在项目文件夹中创建一个 `.auto-coder` 目录,用于存储配置和索引文件。
|
294
|
+
|
295
|
+
|
296
|
+
#### 6.4.项目类型配置
|
297
|
+
|
298
|
+
初始化后,系统会提示配置项目类型:
|
299
|
+
|
300
|
+
```
|
301
|
+
=== 项目类型配置 ===
|
302
|
+
|
303
|
+
项目类型支持:
|
304
|
+
- 语言后缀(例如:.py, .java, .ts)
|
305
|
+
- 预定义类型:py (Python),ts (TypeScript/JavaScript)
|
306
|
+
对于混合语言项目,使用逗号分隔的值。
|
307
|
+
示例:'.java, .scala' 或 '.py, .ts'
|
308
|
+
如果留空,默认为 'py'。
|
309
|
+
|
310
|
+
请输入项目类型:py
|
311
|
+
|
312
|
+
项目类型设置为:py
|
313
|
+
|
314
|
+
您可以稍后使用以下命令更改此设置:
|
315
|
+
/conf project_type:=new_type>
|
316
|
+
```
|
317
|
+
|
318
|
+
支持的项目类型包括:
|
319
|
+
|
320
|
+
* `py` - Python 项目
|
321
|
+
* `ts` - TypeScript/JavaScript 项目
|
322
|
+
* 自定义文件扩展名(例如 `.py,.ts,.go` 用于混合项目)
|
323
|
+
|
324
|
+
#### 6.5.LLM 配置
|
325
|
+
|
326
|
+
#### 6.6.配置管理
|
327
|
+
|
328
|
+
初始设置完成后,可以使用 `/conf` 命令查看和修改配置:
|
329
|
+
|
330
|
+
```bash
|
331
|
+
coding@auto-coder.nano:~$ /conf
|
332
|
+
使用 /conf <key>:<value> 修改这些设置
|
333
|
+
|
334
|
+
| 键 | 值 |
|
335
|
+
|-------------------|---------------|
|
336
|
+
| auto_merge | editblock |
|
337
|
+
| chat_model| model-name |
|
338
|
+
| code_model| model-name |
|
339
|
+
| project_type | py |
|
340
|
+
| skip_build_index | false |
|
341
|
+
```
|
342
|
+
|
343
|
+
### 关键配置选项
|
344
|
+
|
345
|
+
| 选项 | 描述 | 示例值 |
|
346
|
+
|------------------|------------|------------------|
|
347
|
+
| auto_merge | 代码更改的合并策略 | editblock |
|
348
|
+
| chat_model | 用于聊天和索引的模型 | deepseek-v3 |
|
349
|
+
| code_model | 用于代码生成的模型 | deepseek-v3 |
|
350
|
+
| project_type | 项目语言类型 | py, ts, .py, .ts |
|
351
|
+
| skip_build_index | 跳过自动索引构建 | true, false |
|
352
|
+
|
353
|
+
修改配置的示例:
|
354
|
+
|
355
|
+
```bash
|
356
|
+
# 更改项目类型为 TypeScript
|
357
|
+
/conf project_type:ts
|
358
|
+
|
359
|
+
# 更改代码生成模型
|
360
|
+
/conf code_model:deepseek-r1
|
361
|
+
```
|
362
|
+
|
363
|
+
#### 6.7.LLM 管理
|
364
|
+
|
365
|
+
AutoCoder Nano 需要至少一个配置好的 LLM 才能运行。可以使用 `/models` 命令管理 LLM:
|
366
|
+
|
367
|
+
**列出可用模型**
|
368
|
+
|
369
|
+
```bash
|
370
|
+
/models /list
|
371
|
+
```
|
372
|
+
|
373
|
+
**显示已配置模型的表格:**
|
374
|
+
|
375
|
+
```
|
376
|
+
模型
|
377
|
+
Name | Model Name | Base URL
|
378
|
+
------------------------------------------
|
379
|
+
| deepseek-v3 | deepseek-coder | https://api.deepseek.com |
|
380
|
+
```
|
381
|
+
|
382
|
+
**添加新模型**
|
383
|
+
|
384
|
+
```bash
|
385
|
+
/models /add_model name=model-alias base_url=https://api.provider.com api_key=sk-xxxx model=provider-model-name
|
386
|
+
```
|
387
|
+
|
388
|
+
参数:
|
389
|
+
|
390
|
+
- `name`:模型的别名(例如 `deepseek-r1`)
|
391
|
+
- `base_url`:API 端点(例如 `https://api.deepseek.com`)
|
392
|
+
- `api_key`:API 密钥
|
393
|
+
- `model`:服务商指定的具体模型名称
|
394
|
+
|
395
|
+
**移除模型**
|
396
|
+
|
397
|
+
```bash
|
398
|
+
/models /remove model-alias
|
399
|
+
```
|
400
|
+
|
401
|
+
**测试模型连接**
|
402
|
+
|
403
|
+
```bash
|
404
|
+
/models /check
|
405
|
+
```
|
406
|
+
|
407
|
+
测试所有配置的模型并报告状态:
|
408
|
+
|
409
|
+
```
|
410
|
+
模型状态检测
|
411
|
+
模型 | 状态 | 延迟 |
|
412
|
+
deepseek-v3 | ✓ | 1.36s |
|
413
|
+
```
|
414
|
+
|
415
|
+
#### 6.8.验证与下一步
|
416
|
+
|
417
|
+
安装和设置完成后,会看到以下消息:
|
418
|
+
|
419
|
+
```
|
420
|
+
✓ 初始化完成。
|
421
|
+
AutoCoder Nano v0.1.5
|
422
|
+
输入 /help 可以查看可用的命令。
|
423
|
+
|
424
|
+
coding@auto-coder.nano:~$
|
425
|
+
```
|
426
|
+
|
427
|
+
此时可以:
|
428
|
+
|
429
|
+
1. 使用 `/chat` 提问关于代码库的问题
|
430
|
+
2. 使用 `/coding` 生成或修改代码
|
431
|
+
3. 使用 `/add_files`、`/remove_files` 等命令管理文件
|
432
|
+
4. 使用 `/help` 获取帮助
|
433
|
+
|
434
|
+
|
435
|
+
### 7.总结
|
436
|
+
|
437
|
+
AutoCoder Nano 通过命令行界面提供轻量级, 多功能的AI辅助编码工具。通过将LLM与文件管理, 代码索引和上下文理解相结合, 它实现了自然语言指令与代码修改的无缝衔接。
|
438
|
+
|
439
|
+
主要优势:
|
440
|
+
|
441
|
+
- 安装简便, 依赖极少
|
442
|
+
- 支持多种编程语言和项目类型
|
443
|
+
- 灵活的配置和模型管理
|
444
|
+
- 上下文感知的代码理解与生成
|
445
|
+
- 自然语言编程能力
|
@@ -1,5 +1,5 @@
|
|
1
1
|
autocoder_nano/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
autocoder_nano/auto_coder_nano.py,sha256=
|
2
|
+
autocoder_nano/auto_coder_nano.py,sha256=CgUumtK8rfVaHWlO4ND5oTnhhNfyYQ1fSr0th4Wkwv0,104325
|
3
3
|
autocoder_nano/auto_coder_nano_rag.py,sha256=9BtNZ6nC5D5SPTIuziXZOfouCBLOMNzvJMTdDPQEgO8,10436
|
4
4
|
autocoder_nano/auto_coder_nano_ui.py,sha256=ZBskcIJMeTJY7_JipGJaee58G9fUJaOv3LV4hptLc6c,12669
|
5
5
|
autocoder_nano/file_utils.py,sha256=iGbkbQ191nKL4aNufdexYYYQSDM1XrDC9Uxp_PIbawY,661
|
@@ -7,10 +7,10 @@ autocoder_nano/git_utils.py,sha256=sq81FCdB7kUIYPb-7zRNcnjUHDLU1ObgyVT9PvXXnA0,2
|
|
7
7
|
autocoder_nano/helper.py,sha256=LbieDBKp408x9g4GHCvcujUgMgxDTV9owGHIBYpT1ww,6643
|
8
8
|
autocoder_nano/llm_client.py,sha256=D0p6EcnmM5jeoWvPxyxe7ZYUObOASF9fXEKJga4mdOE,3941
|
9
9
|
autocoder_nano/llm_prompt.py,sha256=ViWUfCZp0gDESAAPHBhZc2WhHiFUHIxK6a2xbFu0sjU,10864
|
10
|
-
autocoder_nano/llm_types.py,sha256=
|
10
|
+
autocoder_nano/llm_types.py,sha256=LIvATT40K9A_NAMuaNUKZt-6fu9zZP39uU6-dFUZNHk,9521
|
11
11
|
autocoder_nano/sys_utils.py,sha256=Sn6kr5diaEkVWbYDBrtenr9zw32jVIWvsAReY7_uEd0,1638
|
12
12
|
autocoder_nano/templates.py,sha256=Sv61fSy8V7YsM_bSqDLFMX5tinleSZ6Z2hetCDXl6g8,4270
|
13
|
-
autocoder_nano/version.py,sha256=
|
13
|
+
autocoder_nano/version.py,sha256=zeGAjY0OkOCPDTzXrM2ODQ2ng6u7KTrPi_ovWAysli8,79
|
14
14
|
autocoder_nano/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
autocoder_nano/agent/agent_base.py,sha256=aic_Od5owZEu-VJhyAfQiz9R4btfvgPLJGwtxH3WBno,16369
|
16
16
|
autocoder_nano/agent/new/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -48,8 +48,8 @@ autocoder_nano/index/entry.py,sha256=L_xoV-GDEzzwS6zP4M1-ZGQ6l6mh2R-ez8quZdhlhg0
|
|
48
48
|
autocoder_nano/index/index_manager.py,sha256=G5oD0uI78Yo07WtM8RaWpvqEUvkl6Uph2Pi-ZfIUuZg,15258
|
49
49
|
autocoder_nano/index/symbols_utils.py,sha256=z_16X6BozTfmric1uU-r2GqzDabJ5ChfAOB4lo7i-_8,1450
|
50
50
|
autocoder_nano/project/__init__.py,sha256=8R90zhCcRTHWScAOYw20lkcHI4IhSm-ywCLcfezn0Oc,227
|
51
|
-
autocoder_nano/project/pyproject.py,sha256=
|
52
|
-
autocoder_nano/project/suffixproject.py,sha256=
|
51
|
+
autocoder_nano/project/pyproject.py,sha256=UZqHBrUmsCW73YkG8shjeFSEYGB_zFDH1ezoPP_f33Q,4478
|
52
|
+
autocoder_nano/project/suffixproject.py,sha256=190GCS25qYi4kPav0Hpk2qgSFalkvJk7VM_pchnfurY,4717
|
53
53
|
autocoder_nano/project/tsproject.py,sha256=3gBS-2aup2W5ehSbhD7Bdr-9v9uL7MgY_7TkLHShh9I,5565
|
54
54
|
autocoder_nano/rag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
55
|
autocoder_nano/rag/api_server.py,sha256=uynIKPbAhMG2Au9dJFiNb4N66W_v5ZiilrWIYY58VCU,6062
|
@@ -69,9 +69,9 @@ autocoder_nano/ss/__init__.py,sha256=jp9Az7c0uafZcC6qfxjyZnSnVLtgA_4UdakSOcp8osE
|
|
69
69
|
autocoder_nano/ss/search_engine.py,sha256=4_RcxF1almJX5XlLWB7d9UXM92YDK2bOqoCrkuGg5Mc,3720
|
70
70
|
autocoder_nano/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
71
71
|
autocoder_nano/tools/http_tools.py,sha256=04Tmg8BTwfsw7_-fKBDHv787XU4yQ5UtQSDj0zJBIUc,3189
|
72
|
-
autocoder_nano-0.1.
|
73
|
-
autocoder_nano-0.1.
|
74
|
-
autocoder_nano-0.1.
|
75
|
-
autocoder_nano-0.1.
|
76
|
-
autocoder_nano-0.1.
|
77
|
-
autocoder_nano-0.1.
|
72
|
+
autocoder_nano-0.1.28.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
73
|
+
autocoder_nano-0.1.28.dist-info/METADATA,sha256=gH794GPszg5XH_Cjmz6KykMJCjvLvjclXx-vrEUwvZU,13593
|
74
|
+
autocoder_nano-0.1.28.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
75
|
+
autocoder_nano-0.1.28.dist-info/entry_points.txt,sha256=Dj8gGZ_AgLy8ANqr2do_DJjpsR3JMh-ztsrUXo4Vn5Q,194
|
76
|
+
autocoder_nano-0.1.28.dist-info/top_level.txt,sha256=D7s34cwIs1F4EAjRRDvO_zTHtUz1Z7UVccFUNlJn7HI,15
|
77
|
+
autocoder_nano-0.1.28.dist-info/RECORD,,
|
@@ -1,432 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: autocoder_nano
|
3
|
-
Version: 0.1.27
|
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
|
-
Requires-Dist: pdfminer
|
23
|
-
Requires-Dist: pypdf
|
24
|
-
Requires-Dist: uvicorn
|
25
|
-
Requires-Dist: pathspec
|
26
|
-
Requires-Dist: fastapi
|
27
|
-
Requires-Dist: tokenizers
|
28
|
-
Requires-Dist: duckdb
|
29
|
-
Requires-Dist: numpy
|
30
|
-
Requires-Dist: requests
|
31
|
-
Requires-Dist: beautifulsoup4
|
32
|
-
Dynamic: author
|
33
|
-
Dynamic: classifier
|
34
|
-
Dynamic: description
|
35
|
-
Dynamic: description-content-type
|
36
|
-
Dynamic: requires-dist
|
37
|
-
Dynamic: requires-python
|
38
|
-
Dynamic: summary
|
39
|
-
|
40
|
-
# autocoder-nano
|
41
|
-
|
42
|
-
AutoCoder 社区是一个致力于简化开发者代码开发流程,提升开发效率的社区,开发有 auto-coder.chat (lite/pro), byzerllm 等项目,
|
43
|
-
autocoder-nano 是 AutoCoder 社区的全新成员,基于 auto-coder.chat 功能简化,可以理解成 auto-coder.chat 的轻量级版本。
|
44
|
-
|
45
|
-
#### nano/lite/pro 有什么区别?
|
46
|
-
|
47
|
-
- Pro:分布式架构,支持分布式部署模型,支持开源/SaaS模型管理,独特的 `human_as_model` 模式,RAG 支持,Design 设计支持,MCP支持,联网搜索支持,全局记忆支持,适合深度使用各种大模型的用户。
|
48
|
-
- Lite:放弃分布式架构,部分功能无法使用,主要针对 Windows 用户(第三方库兼容问题),以及需要快速启动并使用 auto-coder.chat 的用户。
|
49
|
-
- Nano:同样放弃分布式架构,为 auto-coder.chat 的移植版本,支持 `/chat`,`/coding`, `/文件管理`,`/索引管理` 等功能,依赖及代码极致精简,适合想要了解大模型辅助编程原理,以及想要实现自己辅助编程框架的用户
|
50
|
-
|
51
|
-
#### 为何选择 autocoder-nano?
|
52
|
-
|
53
|
-
- 轻量高效:无需复杂部署,极致精简,即装即用,使用 auto-coder 前可以先通过 autocoder-nano 熟悉相关功能。
|
54
|
-
- 灵活扩展:第三方依赖及代码精简,非常适合学习及魔改,同时兼容主流大模型,开发者可定制私有化模型链路。
|
55
|
-
- 场景全覆盖:从代码生成到运维脚本,一站式解决开发需求。
|
56
|
-
- 开源友好:持续迭代中,欢迎贡献代码与反馈!
|
57
|
-
|
58
|
-
#### autocoder-nano 的迭代方向
|
59
|
-
|
60
|
-
- 代码结构优化,便于后续维护及其他开发者魔改
|
61
|
-
- 并发支持,开发更大的项目
|
62
|
-
- 多语言优化,深度优化 Python 外的其他语言
|
63
|
-
- 候选模型支持,首选模型异常时进行切换
|
64
|
-
- RAG能力,支持一个简化的知识库,增强代码能力
|
65
|
-
|
66
|
-
---
|
67
|
-
|
68
|
-
## 核心功能
|
69
|
-
|
70
|
-
#### 配置即服务
|
71
|
-
|
72
|
-
- 开箱即用:项目初始化向导引导配置,5 分钟即可上手。
|
73
|
-
- 动态配置:通过 `/conf` 命令实时调整项目类型,模型选择,索引策略等参数。
|
74
|
-
|
75
|
-
#### 智能代码生成
|
76
|
-
|
77
|
-
- 精准控制:通过 `/coding` 命令结合 `@文件` 或 `@@符号`,实现函数级代码生成与修改。
|
78
|
-
- 多语言支持:原生支持 Python、TypeScript/JavaScript 等语言,灵活适配混合语言项目。
|
79
|
-
- 历史上下文:使用 `/coding /apply` 将对话历史融入代码生成,确保逻辑连贯性。
|
80
|
-
|
81
|
-
#### 大模型交互与配置
|
82
|
-
|
83
|
-
- 灵活模型管理:支持 OpenAI 格式的模型接入,一键添加、删除、检测模型状态。
|
84
|
-
- 双模型策略:独立配置对话/索引模型(current_chat_model)与代码生成模型(current_code_model),满足不同场景需求。
|
85
|
-
|
86
|
-
#### 智能文件管理
|
87
|
-
|
88
|
-
- 自动/手动模式:支持自动索引构建或手动管理活动文件。
|
89
|
-
- 文件组管理:通过分组快速切换上下文,提升多模块协作效率,轻松实现前后端配合开发。
|
90
|
-
|
91
|
-
#### 自然语言编程
|
92
|
-
|
93
|
-
- 指令即代码:直接输入自然语言,自动生成并执行 Shell/Python 脚本。
|
94
|
-
- 模式切换:快捷键 Ctrl+K 快速进入自然语言模式,无缝衔接开发与运维任务。
|
95
|
-
|
96
|
-
---
|
97
|
-
|
98
|
-
## 使用场景
|
99
|
-
|
100
|
-
1. 代码维护:快速理解项目结构,生成函数级注释或单元测试。
|
101
|
-
2. 效率提升:通过自然语言指令完成文件清理、批量重命名等重复任务。
|
102
|
-
3. 混合开发:管理多语言项目,智能分析文件依赖关系。
|
103
|
-
4. 模型实验:灵活切换不同大模型,对比生成效果,找到最优配置。
|
104
|
-
|
105
|
-
---
|
106
|
-
|
107
|
-
* [安装](#安装)
|
108
|
-
* [快速开始](#快速开始)
|
109
|
-
* [模型管理](#模型管理)
|
110
|
-
* [配置管理](#配置管理)
|
111
|
-
* [文件管理](#文件管理)
|
112
|
-
* [索引管理](#索引管理)
|
113
|
-
* [Chat和Coding](#Chat和Coding)
|
114
|
-
* [自然语言模式](#自然语言模式)
|
115
|
-
|
116
|
-
---
|
117
|
-
|
118
|
-
## 安装
|
119
|
-
|
120
|
-
```shell
|
121
|
-
$ conda create --name autocoder python=3.11.9
|
122
|
-
$ conda activate autocoder
|
123
|
-
$ pip install -U autocoder_nano
|
124
|
-
```
|
125
|
-
|
126
|
-
## 快速开始
|
127
|
-
|
128
|
-
```shell
|
129
|
-
$ cd your-project
|
130
|
-
$ auto-coder.nano
|
131
|
-
```
|
132
|
-
|
133
|
-
#### step 1: 项目初始化
|
134
|
-
|
135
|
-
```
|
136
|
-
! 正在初始化系统...
|
137
|
-
! 当前目录未初始化为auto-coder项目。
|
138
|
-
是否现在初始化项目?(y/n): y
|
139
|
-
✓ 项目初始化成功。
|
140
|
-
✓ 创建目录:/user/x/code/you-project/.auto-coder/plugins/chat-auto-coder
|
141
|
-
```
|
142
|
-
|
143
|
-
#### step 2: 配置项目语言类型
|
144
|
-
|
145
|
-
```
|
146
|
-
=== 项目类型配置 ===
|
147
|
-
|
148
|
-
项目类型支持:
|
149
|
-
- 语言后缀(例如:.py, .java, .ts)
|
150
|
-
- 预定义类型:py(Python), ts(TypeScript/JavaScript)
|
151
|
-
对于混合语言项目,使用逗号分隔的值。
|
152
|
-
示例:'.java,.scala' 或 '.py,.ts'
|
153
|
-
如果留空,默认为 'py'。
|
154
|
-
|
155
|
-
请输入项目类型:py
|
156
|
-
|
157
|
-
项目类型设置为: py
|
158
|
-
|
159
|
-
您可以稍后使用以下命令更改此设置:
|
160
|
-
/conf project_type:<new_type>
|
161
|
-
```
|
162
|
-
|
163
|
-
#### step 3: 配置大模型
|
164
|
-
|
165
|
-
```
|
166
|
-
! 正在配置模型...
|
167
|
-
设置你的首选模型名称(例如: deepseek-v3/r1, ark-deepseek-v3/r1): your-user-first-llm-custom-name
|
168
|
-
请输入你使用模型的 Model Name: your-llm-model_name
|
169
|
-
请输入你使用模型的 Base URL: your-llm-base-url
|
170
|
-
请输入您的API密钥: your-llm-api-key
|
171
|
-
! 正在更新缓存...
|
172
|
-
! 正在部署 your-user-first-llm 模型...
|
173
|
-
```
|
174
|
-
|
175
|
-
#### step 4: 初始化完成, 开始与大模型交流
|
176
|
-
|
177
|
-
```
|
178
|
-
✓ 初始化完成。
|
179
|
-
AutoCoder Nano v0.1.5
|
180
|
-
输入 /help 可以查看可用的命令.
|
181
|
-
|
182
|
-
coding@auto-coder.nano:~$ /chat 描述一下这个项目的主要功能
|
183
|
-
```
|
184
|
-
|
185
|
-
|
186
|
-
## 模型管理
|
187
|
-
|
188
|
-
#### 列出模型
|
189
|
-
|
190
|
-
```
|
191
|
-
coding@auto-coder.nano:~$ /models /list
|
192
|
-
模型
|
193
|
-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
194
|
-
┃ Name ┃ Model Name ┃ Base URL ┃
|
195
|
-
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
196
|
-
│ xxx-deepseek-v3 │ xxxxxxxxxxxx │ https://xxxxx.com/api/v3 │
|
197
|
-
└──────────────────────────────┴─────────────────────┴────────────────────────────┘
|
198
|
-
```
|
199
|
-
|
200
|
-
#### 新增模型
|
201
|
-
|
202
|
-
兼容所有 OpenAI 格式的模型
|
203
|
-
|
204
|
-
- name=deepseek-r1,为新增的模型取的一个别名,可以精简,便于后续使用
|
205
|
-
- base_url=https://api.deepseek.com, 模型厂商提供的 saas api 接口
|
206
|
-
- api_key=sk-xx, 访问模型所需的key
|
207
|
-
- model=deepseek-reasoner, 模型厂商内部可能会提供多种可选的能力模型,比如 r1 / v3
|
208
|
-
|
209
|
-
```
|
210
|
-
coding@auto-coder.nano:~$ /models /add_model name=deepseek-r1 base_url=https://api.deepseek.com api_key=sk-xx model=deepseek-reasoner
|
211
|
-
2025-02-11 10:11:22.124 | INFO | autocoder_nano.auto_coder_nano:manage_models:3788 - 正在为 deepseek-r1 更新缓存信息
|
212
|
-
2025-02-11 10:11:22.125 | INFO | autocoder_nano.auto_coder_nano:manage_models:3797 - 正在部署 deepseek-r1 模型
|
213
|
-
coding@auto-coder.nano:~$ /models /list
|
214
|
-
模型
|
215
|
-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
216
|
-
┃ Name ┃ Model Name ┃ Base URL ┃
|
217
|
-
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
218
|
-
│ xxx-deepseek-v3 │ xxxxxxxxxxxx │ https://xxxxx.com/api/v3 │
|
219
|
-
├──────────────────────────────┼─────────────────────┼────────────────────────────┤
|
220
|
-
│ deepseek-r1 │ deepseek-reasoner │ https://api.deepseek.com │
|
221
|
-
└──────────────────────────────┴─────────────────────┴────────────────────────────┘
|
222
|
-
```
|
223
|
-
|
224
|
-
#### 删除模型
|
225
|
-
|
226
|
-
```
|
227
|
-
coding@auto-coder.nano:~$ /models /remove deepseek-r1
|
228
|
-
2025-02-11 10:17:59.930 | INFO | autocoder_nano.auto_coder_nano:manage_models:3801 - 正在清理 deepseek-r1 缓存信息
|
229
|
-
2025-02-11 10:17:59.930 | INFO | autocoder_nano.auto_coder_nano:manage_models:3804 - 正在卸载 deepseek-r1 模型
|
230
|
-
```
|
231
|
-
|
232
|
-
#### 模型状态检测
|
233
|
-
|
234
|
-
```
|
235
|
-
coding@auto-coder.nano:~$ /models /check
|
236
|
-
2025-02-11 10:19:23.494 | INFO | autocoder_nano.auto_coder_nano:check_models:3757 - 正在测试 xxx-deepseek-v3 模型
|
237
|
-
2025-02-11 10:19:23.495 | INFO | autocoder_nano.auto_coder_nano:stream_chat_ai:1037 - 正在使用 xxx-deepseek-v3 模型, 模型名称 xxxxxxxxxxxx
|
238
|
-
模型状态检测
|
239
|
-
┏━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━┓
|
240
|
-
┃ 模型 ┃ 状态 ┃ 延迟 ┃
|
241
|
-
┡━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━┩
|
242
|
-
│ xxx-deepseek-v3 │ ✓ │ 1.36s │
|
243
|
-
└─────────────────┴──────┴───────┘
|
244
|
-
```
|
245
|
-
|
246
|
-
## 配置管理
|
247
|
-
|
248
|
-
#### 列出配置
|
249
|
-
|
250
|
-
```
|
251
|
-
coding@auto-coder.nano:~$ /conf
|
252
|
-
使用 /conf <key>:<value> 修改这些设置
|
253
|
-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
254
|
-
┃ 键 ┃ 值 ┃
|
255
|
-
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
256
|
-
│ auto_merge │ editblock │
|
257
|
-
├───────────────────────────────┼──────────────────────────────┤
|
258
|
-
│ current_chat_model │ xxx-deepseek-v3 │
|
259
|
-
├───────────────────────────────┼──────────────────────────────┤
|
260
|
-
│ current_code_model │ xxx-deepseek-v3 │
|
261
|
-
├───────────────────────────────┼──────────────────────────────┤
|
262
|
-
│ project_type │ py │
|
263
|
-
├───────────────────────────────┼──────────────────────────────┤
|
264
|
-
│ skip_build_index │ false │
|
265
|
-
└───────────────────────────────┴──────────────────────────────┘
|
266
|
-
```
|
267
|
-
|
268
|
-
#### 更改配置
|
269
|
-
|
270
|
-
```
|
271
|
-
coding@auto-coder.nano:~$ /conf skip_filter_index:false
|
272
|
-
Set skip_filter_index to false
|
273
|
-
coding@auto-coder.nano:~$ /conf index_filter_level:2
|
274
|
-
Set index_filter_level to 2
|
275
|
-
```
|
276
|
-
|
277
|
-
#### 配置当前使用模型
|
278
|
-
|
279
|
-
当你新增某个模型后,想要进行替换使用,假设你的模型别名为 _t-deepseek-r1_ , 使用以下命令进行模型配置更改:
|
280
|
-
|
281
|
-
```shell
|
282
|
-
coding@auto-coder.nano:~$ /conf current_chat_model:t-deepseek-r1
|
283
|
-
Set current_chat_model to t-deepseek-r1
|
284
|
-
coding@auto-coder.nano:~$ /conf current_code_model:t-deepseek-r1
|
285
|
-
Set current_code_model to t-deepseek-r1
|
286
|
-
```
|
287
|
-
|
288
|
-
- current_chat_model :配置与大模型聊天以及索引生成所使用的模型
|
289
|
-
- current_code_model :配置代码生成使用的模型
|
290
|
-
|
291
|
-
|
292
|
-
## 文件管理
|
293
|
-
|
294
|
-
Auto-coder 里有两种方式管理你的项目上下文:
|
295
|
-
|
296
|
-
1. 设置 `/conf skip_index_build:false` 后,系统会自动根据你的需求自动查找相关文件。即自动管理模式。
|
297
|
-
2. 当你设置 `/conf skip_index_build:true` 后,则通过活动文件来管理,我们提供了 `/add_files /remove_files /list_files` 来组合。即手动管理模式。
|
298
|
-
|
299
|
-
Auto-coder 文件组概念:
|
300
|
-
|
301
|
-
1. Auto-coder 系列提供了一个活动文件组的概念。 你可以通过 `/add_files /group /add app` 来添加一个叫 app的组,这个组会复制当前的所有活动文件。
|
302
|
-
2. 通过手动切换文件组来完成上下文的管理,是手动管理文件的高级方法
|
303
|
-
|
304
|
-
|
305
|
-
#### /list_files 命令
|
306
|
-
|
307
|
-
```shell
|
308
|
-
# 列出当前活跃文件
|
309
|
-
coding@auto-coder.nano:~$ /list_files
|
310
|
-
```
|
311
|
-
|
312
|
-
#### /add_files 命令
|
313
|
-
|
314
|
-
```shell
|
315
|
-
# 添加单个/多个文件为活跃文件
|
316
|
-
coding@auto-coder.nano:~$ /add_files file1 file2 file3
|
317
|
-
coding@auto-coder.nano:~$ /add_files /path/abc/file4 /path/abc/file5
|
318
|
-
|
319
|
-
# 查看当前所有的文件组
|
320
|
-
coding@auto-coder.nano:~$ /add_files /group
|
321
|
-
|
322
|
-
# 将当前活跃文件添加进 app 文件组
|
323
|
-
coding@auto-coder.nano:~$ /add_files /group /add app
|
324
|
-
|
325
|
-
# 设置活跃文件组
|
326
|
-
coding@auto-coder.nano:~$ /add_files /group app
|
327
|
-
|
328
|
-
# 删除文件组
|
329
|
-
coding@auto-coder.nano:~$ /add_files /group /drop app
|
330
|
-
|
331
|
-
# 合并两个文件组的文件为当前活跃文件
|
332
|
-
coding@auto-coder.nano:~$ /add_files /group <groupname>,<groupname>
|
333
|
-
|
334
|
-
# 当目录中新增一个文件后,自动补全无法获取该文件,可执行一次刷新
|
335
|
-
coding@auto-coder.nano:~$ /add_files /refresh
|
336
|
-
```
|
337
|
-
|
338
|
-
- `/add_files` 支持文件匹配符,比如可以通过 `/add_files ./**/*.py` 把当前目录下所有的python文件加到活动文件里去(如果你项目很大,不能这么做,会超出大模型上线文限制)。
|
339
|
-
|
340
|
-
|
341
|
-
#### /remove_files 命令
|
342
|
-
|
343
|
-
```shell
|
344
|
-
# 将 file1 移出当前活跃文件
|
345
|
-
coding@auto-coder.nano:~$ /remove_files file1
|
346
|
-
|
347
|
-
# 清空当前所有活跃文件
|
348
|
-
coding@auto-coder.nano:~$ /remove_files /all
|
349
|
-
```
|
350
|
-
|
351
|
-
|
352
|
-
## 索引管理
|
353
|
-
|
354
|
-
|
355
|
-
## Chat和Coding
|
356
|
-
|
357
|
-
Chat与大模型沟通
|
358
|
-
|
359
|
-
- 当你设置了活跃文件和 `/conf skip_index_build:true` , `/chat` 可以方便的针对当前活跃文件进行提问
|
360
|
-
- 当你设置了 `/conf skip_index_build:false` , `/chat` 会根据所有代码文件来回答问题
|
361
|
-
|
362
|
-
```shell
|
363
|
-
coding@auto-coder.nano:~$ /add_files ./**/*.py
|
364
|
-
|
365
|
-
coding@auto-coder.nano:~$ /list_files
|
366
|
-
|
367
|
-
coding@auto-coder.nano:~$ /chat 请问这些文件之间的关系是什么
|
368
|
-
coding@auto-coder.nano:~$ /chat 给我描述一下这个项目的用途
|
369
|
-
```
|
370
|
-
|
371
|
-
|
372
|
-
Coding使用大模型进行编码
|
373
|
-
|
374
|
-
- `/coding` 可以根据需求,对当前活跃文件,或者自行匹配候选文件,进行修改
|
375
|
-
- `/coding /apply` 此时 Autocoder 会把我们与大模型之间的历史对话记录加入到代码生成的 Prompt 里
|
376
|
-
|
377
|
-
```shell
|
378
|
-
coding@auto-coder.nano:~$ /coding /apply 新增一个命令行参数 --chat_model
|
379
|
-
```
|
380
|
-
|
381
|
-
#### 精准控制代码生成
|
382
|
-
|
383
|
-
Autocoder 提供了两个机制:
|
384
|
-
1. 使用 `@` 自动补全文件
|
385
|
-
2. 使用 `@@` 自动补全符号(类或者函数)
|
386
|
-
|
387
|
-
在 `/coding` 或者 `/chat` 的时候,用户可以通过上述两个语法快速定位到某个文件,类或者函数,然后最小粒度是函数级别,
|
388
|
-
让 Autocoder 帮你做修改。比如你 @@函数A, 然后让大模型自动实现该函数或者让大模型给该函数生成测试
|
389
|
-
|
390
|
-
|
391
|
-
## 自然语言模式
|
392
|
-
|
393
|
-
场景:实际编程的过程中,程序员会大量使用命令行来完成一些工作
|
394
|
-
|
395
|
-
- 比如启动一个服务,发现服务端口被占用,这个时候你可能想查看这个端口到底被哪个其他服务占用
|
396
|
-
- 想要对目录中的 .jpg 文件进行批量改名
|
397
|
-
- 再或者突然忘记某个命令的参数
|
398
|
-
|
399
|
-
切换自然语言模式
|
400
|
-
|
401
|
-
使用 Ctrl + k 快捷键,或者以下方式可切换模式
|
402
|
-
|
403
|
-
```shell
|
404
|
-
coding@auto-coder.nano:~$ /mode auto_detect
|
405
|
-
```
|
406
|
-
|
407
|
-
放终端最下方显示 `当前模式: 自然语言模式 (ctl+k 切换模式)` 即切换成功
|
408
|
-
|
409
|
-
```
|
410
|
-
coding@auto-coder.nano:~$ 递归删除当前项目所有 __pycache__ 目录
|
411
|
-
╭────────────────────────────────────────────────────────── 命令生成 ─────────╮
|
412
|
-
│ 正在根据用户输入 递归删除当前项目所有 __pycache__ 目录 生成 Shell 脚本... │
|
413
|
-
╰────────────────────────────────────────────────────────────────────────────╯
|
414
|
-
2025-02-11 15:02:31.305 | INFO | autocoder_nano.auto_coder_nano:chat_ai:1057 - 正在使用 ark-deepseek-v3 模型, 模型名称 ep-20250205104003-d8hqb
|
415
|
-
╭───────────────────────────────────────────────────────── Shell 脚本 ──────────────────────╮
|
416
|
-
│ #!/bin/bash │
|
417
|
-
│ │
|
418
|
-
│ # 递归删除当前项目所有 __pycache__ 目录的脚本 │
|
419
|
-
│ │
|
420
|
-
│ # 使用 find 命令查找当前目录及其子目录中的所有 __pycache__ 目录 │
|
421
|
-
│ # -type d: 只查找目录 │
|
422
|
-
│ # -name "__pycache__": 匹配名为 __pycache__ 的目录 │
|
423
|
-
│ # -exec rm -rf {} +: 对找到的每个目录执行 rm -rf 命令,递归删除目录及其内容 │
|
424
|
-
│ # 使用 {} + 而不是 {} \; 是为了将多个结果一次性传递给 rm 命令,提高效率 │
|
425
|
-
│ │
|
426
|
-
│ find . -type d -name "__pycache__" -exec rm -rf {} + │
|
427
|
-
│ │
|
428
|
-
│ # 提示用户操作完成 │
|
429
|
-
│ echo "所有 __pycache__ 目录已成功删除。" │
|
430
|
-
╰───────────────────────────────────────────────────────────────────────────────────────────╯
|
431
|
-
是否要执行此脚本? (y/n) n
|
432
|
-
```
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|