auto-coder 0.1.361__py3-none-any.whl → 0.1.363__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.
Potentially problematic release.
This version of auto-coder might be problematic. Click here for more details.
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/METADATA +2 -1
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/RECORD +57 -29
- autocoder/agent/auto_learn.py +249 -262
- autocoder/agent/base_agentic/__init__.py +0 -0
- autocoder/agent/base_agentic/agent_hub.py +169 -0
- autocoder/agent/base_agentic/agentic_lang.py +112 -0
- autocoder/agent/base_agentic/agentic_tool_display.py +180 -0
- autocoder/agent/base_agentic/base_agent.py +1582 -0
- autocoder/agent/base_agentic/default_tools.py +683 -0
- autocoder/agent/base_agentic/test_base_agent.py +82 -0
- autocoder/agent/base_agentic/tool_registry.py +425 -0
- autocoder/agent/base_agentic/tools/__init__.py +12 -0
- autocoder/agent/base_agentic/tools/ask_followup_question_tool_resolver.py +72 -0
- autocoder/agent/base_agentic/tools/attempt_completion_tool_resolver.py +37 -0
- autocoder/agent/base_agentic/tools/base_tool_resolver.py +35 -0
- autocoder/agent/base_agentic/tools/example_tool_resolver.py +46 -0
- autocoder/agent/base_agentic/tools/execute_command_tool_resolver.py +72 -0
- autocoder/agent/base_agentic/tools/list_files_tool_resolver.py +110 -0
- autocoder/agent/base_agentic/tools/plan_mode_respond_tool_resolver.py +35 -0
- autocoder/agent/base_agentic/tools/read_file_tool_resolver.py +54 -0
- autocoder/agent/base_agentic/tools/replace_in_file_tool_resolver.py +156 -0
- autocoder/agent/base_agentic/tools/search_files_tool_resolver.py +134 -0
- autocoder/agent/base_agentic/tools/talk_to_group_tool_resolver.py +96 -0
- autocoder/agent/base_agentic/tools/talk_to_tool_resolver.py +79 -0
- autocoder/agent/base_agentic/tools/use_mcp_tool_resolver.py +44 -0
- autocoder/agent/base_agentic/tools/write_to_file_tool_resolver.py +58 -0
- autocoder/agent/base_agentic/types.py +189 -0
- autocoder/agent/base_agentic/utils.py +100 -0
- autocoder/auto_coder.py +1 -1
- autocoder/auto_coder_runner.py +36 -14
- autocoder/chat/conf_command.py +11 -10
- autocoder/commands/auto_command.py +227 -159
- autocoder/common/__init__.py +2 -2
- autocoder/common/ignorefiles/ignore_file_utils.py +12 -8
- autocoder/common/result_manager.py +10 -2
- autocoder/common/rulefiles/autocoderrules_utils.py +169 -0
- autocoder/common/save_formatted_log.py +1 -1
- autocoder/common/v2/agent/agentic_edit.py +53 -41
- autocoder/common/v2/agent/agentic_edit_tools/read_file_tool_resolver.py +15 -12
- autocoder/common/v2/agent/agentic_edit_tools/replace_in_file_tool_resolver.py +73 -1
- autocoder/common/v2/agent/agentic_edit_tools/write_to_file_tool_resolver.py +132 -4
- autocoder/common/v2/agent/agentic_edit_types.py +1 -2
- autocoder/common/v2/agent/agentic_tool_display.py +2 -3
- autocoder/common/v2/code_auto_generate_editblock.py +3 -1
- autocoder/index/index.py +14 -8
- autocoder/privacy/model_filter.py +297 -35
- autocoder/rag/long_context_rag.py +424 -397
- autocoder/rag/test_doc_filter.py +393 -0
- autocoder/rag/test_long_context_rag.py +473 -0
- autocoder/rag/test_token_limiter.py +342 -0
- autocoder/shadows/shadow_manager.py +1 -3
- autocoder/utils/_markitdown.py +22 -3
- autocoder/version.py +1 -1
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.361.dist-info → auto_coder-0.1.363.dist-info}/top_level.txt +0 -0
autocoder/agent/auto_learn.py
CHANGED
|
@@ -40,9 +40,7 @@ class AutoLearn:
|
|
|
40
40
|
- 识别代码变更中具有普遍应用价值的功能点和模式
|
|
41
41
|
- 将这些功能点提炼为结构化规则,便于在其他项目中快速复用
|
|
42
42
|
- 生成清晰的使用示例,包含完整依赖和调用方式
|
|
43
|
-
- 这些规则将被存储在项目的
|
|
44
|
-
|
|
45
|
-
项目根目录: {{ project_root }}
|
|
43
|
+
- 这些规则将被存储在项目的 {{ project_root }}/.autocoderrules 目录,供后续自动化代码生成使用
|
|
46
44
|
|
|
47
45
|
## 分析对象
|
|
48
46
|
下面是本次提交的代码变更:
|
|
@@ -86,144 +84,138 @@ class AutoLearn:
|
|
|
86
84
|
## 用户需求
|
|
87
85
|
{{ new_query }}
|
|
88
86
|
|
|
89
|
-
##
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
##
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if item.type == 'blob': # 只处理文件,不处理目录
|
|
164
|
-
file_path = item.path
|
|
165
|
-
# 首次提交前没有内容
|
|
166
|
-
before_content = None
|
|
167
|
-
# 获取提交后的内容
|
|
168
|
-
after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
|
|
169
|
-
changes[file_path] = (before_content, after_content)
|
|
170
|
-
else:
|
|
171
|
-
# 获取parent commit
|
|
172
|
-
parent = commit.parents[0]
|
|
173
|
-
# 获取变更的文件列表
|
|
174
|
-
for diff_item in parent.diff(commit):
|
|
175
|
-
file_path = diff_item.a_path if diff_item.a_path else diff_item.b_path
|
|
176
|
-
|
|
177
|
-
# 获取变更前内容
|
|
178
|
-
before_content = None
|
|
179
|
-
try:
|
|
180
|
-
if diff_item.a_blob:
|
|
181
|
-
before_content = repo.git.show(f"{parent.hexsha}:{file_path}")
|
|
182
|
-
except git.exc.GitCommandError:
|
|
183
|
-
pass # 文件可能是新增的
|
|
184
|
-
|
|
185
|
-
# 获取变更后内容
|
|
186
|
-
after_content = None
|
|
187
|
-
try:
|
|
188
|
-
if diff_item.b_blob:
|
|
87
|
+
## 生成或者更新的规则文件结构
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
description: [简明描述规则的功能,20字以内]
|
|
91
|
+
globs: [匹配应用此规则的文件路径,如"src/services/*.py"]
|
|
92
|
+
alwaysApply: [是否总是应用,通常为false]
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
# [规则主标题]
|
|
96
|
+
|
|
97
|
+
## 简要说明
|
|
98
|
+
[该规则的功能、适用场景和价值,100字以内]
|
|
99
|
+
|
|
100
|
+
## 典型用法
|
|
101
|
+
```python
|
|
102
|
+
# 完整的代码示例,包含:
|
|
103
|
+
# 1. 必要的import语句
|
|
104
|
+
# 2. 类/函数定义
|
|
105
|
+
# 3. 参数说明
|
|
106
|
+
# 4. 调用方式
|
|
107
|
+
# 5. 关键注释
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 依赖说明
|
|
111
|
+
- [必要的依赖库及版本]
|
|
112
|
+
- [环境要求]
|
|
113
|
+
- [初始化流程(如有)]
|
|
114
|
+
|
|
115
|
+
## 学习来源
|
|
116
|
+
[从哪个提交变更的哪部分代码中提取的该功能点]
|
|
117
|
+
|
|
118
|
+
## 生成或者更新的规则文件示例
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
description: Git提交分析工具
|
|
122
|
+
globs: "src/utils/git_analyzer.py"
|
|
123
|
+
alwaysApply: false
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
# Git提交分析工具
|
|
127
|
+
|
|
128
|
+
## 简要说明
|
|
129
|
+
提供从Git仓库中获取提交变更并分析差异的工具函数,支持首次提交和普通提交的差异获取,适用于代码审查、变更追踪和自动化分析场景。
|
|
130
|
+
|
|
131
|
+
## 典型用法
|
|
132
|
+
```python
|
|
133
|
+
import git
|
|
134
|
+
from typing import Dict, Tuple, List, Optional
|
|
135
|
+
|
|
136
|
+
def get_commit_changes(repo_path: str, commit_id: str) -> Dict[str, Tuple[Optional[str], Optional[str]]]:
|
|
137
|
+
'''
|
|
138
|
+
获取指定commit的文件变更内容
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
repo_path: Git仓库路径
|
|
142
|
+
commit_id: 提交ID
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
Dict[str, Tuple[Optional[str], Optional[str]]]: 文件路径到(变更前内容,变更后内容)的映射
|
|
146
|
+
'''
|
|
147
|
+
changes = {}
|
|
148
|
+
try:
|
|
149
|
+
repo = git.Repo(repo_path)
|
|
150
|
+
commit = repo.commit(commit_id)
|
|
151
|
+
|
|
152
|
+
# 检查是否是首次提交(没有父提交)
|
|
153
|
+
if not commit.parents:
|
|
154
|
+
# 首次提交,获取所有文件
|
|
155
|
+
for item in commit.tree.traverse():
|
|
156
|
+
if item.type == 'blob': # 只处理文件,不处理目录
|
|
157
|
+
file_path = item.path
|
|
158
|
+
# 首次提交前没有内容
|
|
159
|
+
before_content = None
|
|
160
|
+
# 获取提交后的内容
|
|
189
161
|
after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
|
|
190
|
-
|
|
191
|
-
|
|
162
|
+
changes[file_path] = (before_content, after_content)
|
|
163
|
+
else:
|
|
164
|
+
# 获取parent commit
|
|
165
|
+
parent = commit.parents[0]
|
|
166
|
+
# 获取变更的文件列表
|
|
167
|
+
for diff_item in parent.diff(commit):
|
|
168
|
+
file_path = diff_item.a_path if diff_item.a_path else diff_item.b_path
|
|
169
|
+
|
|
170
|
+
# 获取变更前内容
|
|
171
|
+
before_content = None
|
|
172
|
+
try:
|
|
173
|
+
if diff_item.a_blob:
|
|
174
|
+
before_content = repo.git.show(f"{parent.hexsha}:{file_path}")
|
|
175
|
+
except git.exc.GitCommandError:
|
|
176
|
+
pass # 文件可能是新增的
|
|
177
|
+
|
|
178
|
+
# 获取变更后内容
|
|
179
|
+
after_content = None
|
|
180
|
+
try:
|
|
181
|
+
if diff_item.b_blob:
|
|
182
|
+
after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
|
|
183
|
+
except git.exc.GitCommandError:
|
|
184
|
+
pass # 文件可能被删除
|
|
192
185
|
|
|
193
|
-
|
|
186
|
+
changes[file_path] = (before_content, after_content)
|
|
194
187
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
188
|
+
return changes
|
|
189
|
+
except Exception as e:
|
|
190
|
+
print(f"获取提交变更时出错: {str(e)}")
|
|
191
|
+
return {}
|
|
192
|
+
```
|
|
200
193
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
## 依赖说明
|
|
195
|
+
- GitPython>=3.1.0
|
|
196
|
+
- Python>=3.7
|
|
204
197
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
</markdown>
|
|
198
|
+
## 学习来源
|
|
199
|
+
从代码提交变更中提取的Git仓库差异分析功能
|
|
208
200
|
|
|
209
201
|
## 索引文件更新说明
|
|
210
202
|
|
|
211
203
|
除了生成规则文件外,请务必更新index.md索引文件,记录所有规则及其作用。如果 index.md 当前内容为空,请按如下格式创建:
|
|
212
|
-
|
|
213
|
-
<markdown>
|
|
204
|
+
|
|
214
205
|
# Rules索引
|
|
215
206
|
|
|
216
207
|
本文档记录项目中所有可用的代码规则(rules)及其用途。
|
|
217
208
|
|
|
218
209
|
## [规则文件路径]
|
|
219
210
|
[规则文件的主要功能和适用场景简述]
|
|
220
|
-
</markdown>
|
|
221
211
|
|
|
222
212
|
## 评价标准
|
|
223
213
|
- 提取的功能点必须具备独立价值,能在其他项目中实际复用
|
|
224
214
|
- 代码示例必须完整、可执行,包含所有必要组件
|
|
225
215
|
- 文档结构清晰,遵循规定格式
|
|
226
216
|
- 依赖说明明确具体,便于用户快速配置环境
|
|
217
|
+
|
|
218
|
+
请根据要求生成或者更新规则文件(markdown文件),并将规则文件存储在项目的 {{ project_root }}/.autocoderrules 目录,供后续自动化代码生成使用。
|
|
227
219
|
"""
|
|
228
220
|
return {
|
|
229
221
|
"project_root": os.path.abspath(self.args.source_dir),
|
|
@@ -239,7 +231,7 @@ class AutoLearn:
|
|
|
239
231
|
- 识别代码中具有普遍应用价值的功能点和模式
|
|
240
232
|
- 将这些功能点提炼为结构化规则,便于在其他项目中快速复用
|
|
241
233
|
- 生成清晰的使用示例,包含完整依赖和调用方式
|
|
242
|
-
- 这些规则将被存储在项目的
|
|
234
|
+
- 这些规则将被存储在项目的 {{ project_root }}/.autocoderrules 目录,供后续自动化代码生成使用
|
|
243
235
|
|
|
244
236
|
项目根目录: {{ project_root }}
|
|
245
237
|
|
|
@@ -277,165 +269,160 @@ class AutoLearn:
|
|
|
277
269
|
## 用户需求
|
|
278
270
|
{{ query }}
|
|
279
271
|
|
|
280
|
-
##
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
272
|
+
## 生成或者更新的规则文件结构
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
description: [简明描述规则的功能,20字以内]
|
|
276
|
+
globs: [匹配应用此规则的文件路径,如"src/services/*.py"]
|
|
277
|
+
alwaysApply: [是否总是应用,通常为false]
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
# [规则主标题]
|
|
281
|
+
|
|
282
|
+
## 简要说明
|
|
283
|
+
[该规则的功能、适用场景和价值,100字以内]
|
|
284
|
+
|
|
285
|
+
## 典型用法
|
|
286
|
+
```python
|
|
287
|
+
# 完整的代码示例,包含:
|
|
288
|
+
# 1. 必要的import语句
|
|
289
|
+
# 2. 类/函数定义
|
|
290
|
+
# 3. 参数说明
|
|
291
|
+
# 4. 调用方式
|
|
292
|
+
# 5. 关键注释
|
|
293
|
+
|
|
294
|
+
## 依赖说明
|
|
295
|
+
- [必要的依赖库及版本]
|
|
296
|
+
- [环境要求]
|
|
297
|
+
- [初始化流程(如有)]
|
|
298
|
+
|
|
299
|
+
## 学习来源
|
|
300
|
+
[从哪个模块的哪部分代码中提取的该功能点]
|
|
301
|
+
</markdown>
|
|
302
|
+
|
|
303
|
+
## 生成或者更新的规则文件示例
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
description: RPC服务模板
|
|
307
|
+
globs: "src/services/rpc_service.py"
|
|
308
|
+
alwaysApply: false
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
# RPC服务快速实现模板
|
|
312
|
+
|
|
313
|
+
## 简要说明
|
|
314
|
+
提供gRPC服务端与客户端的标准实现模板,包含服务定义、请求处理、错误处理和客户端调用。适用于需要高性能RPC通信的微服务架构。
|
|
315
|
+
|
|
316
|
+
## 典型用法
|
|
317
|
+
```python
|
|
318
|
+
# 服务端实现
|
|
319
|
+
import grpc
|
|
320
|
+
from concurrent import futures
|
|
321
|
+
import logging
|
|
322
|
+
import time
|
|
323
|
+
from typing import Dict, Any
|
|
324
|
+
|
|
325
|
+
import service_pb2
|
|
326
|
+
import service_pb2_grpc
|
|
327
|
+
|
|
328
|
+
class ServiceImplementation(service_pb2_grpc.MyServiceServicer):
|
|
329
|
+
def __init__(self, config: Dict[str, Any] = None):
|
|
330
|
+
self.config = config or {}
|
|
331
|
+
logging.info("RPC服务初始化完成")
|
|
332
|
+
|
|
333
|
+
def ProcessRequest(self, request, context):
|
|
334
|
+
try:
|
|
335
|
+
# 业务逻辑处理
|
|
336
|
+
result = self._process_business_logic(request)
|
|
337
|
+
|
|
338
|
+
# 构建响应
|
|
339
|
+
return service_pb2.Response(
|
|
340
|
+
status=200,
|
|
341
|
+
message="处理成功",
|
|
342
|
+
data=result
|
|
343
|
+
)
|
|
344
|
+
except Exception as e:
|
|
345
|
+
logging.error(f"处理请求时发生错误: {str(e)}")
|
|
346
|
+
context.set_code(grpc.StatusCode.INTERNAL)
|
|
347
|
+
context.set_details(f"服务器内部错误: {str(e)}")
|
|
348
|
+
return service_pb2.Response(
|
|
349
|
+
status=500,
|
|
350
|
+
message=f"处理失败: {str(e)}",
|
|
351
|
+
data={}
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
def _process_business_logic(self, request):
|
|
355
|
+
# 实际业务逻辑处理
|
|
356
|
+
return {"result": request.param1 + request.param2}
|
|
357
|
+
|
|
358
|
+
def serve(port=50051, max_workers=10):
|
|
359
|
+
server = grpc.server(futures.ThreadPoolExecutor(max_workers=max_workers))
|
|
360
|
+
service_pb2_grpc.add_MyServiceServicer_to_server(
|
|
361
|
+
ServiceImplementation(), server
|
|
362
|
+
)
|
|
363
|
+
server.add_insecure_port(f'[::]:{port}')
|
|
364
|
+
server.start()
|
|
365
|
+
logging.info(f"服务已启动,监听端口: {port}")
|
|
344
366
|
|
|
345
|
-
def ProcessRequest(self, request, context):
|
|
346
367
|
try:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if __name__ == '__main__':
|
|
387
|
-
logging.basicConfig(level=logging.INFO)
|
|
388
|
-
serve()
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## 依赖说明
|
|
392
|
-
- 需要安装 grpcio>=1.44.0 和 grpcio-tools>=1.44.0
|
|
393
|
-
- 需要预先定义proto文件并生成对应Python代码:
|
|
394
|
-
```bash
|
|
395
|
-
python -m grpc_tools.protoc -I./protos --python_out=. --grpc_python_out=. ./protos/service.proto
|
|
396
|
-
```
|
|
397
|
-
- 示例proto文件结构:
|
|
398
|
-
```protobuf
|
|
399
|
-
syntax = "proto3";
|
|
400
|
-
|
|
401
|
-
service MyService {
|
|
402
|
-
rpc ProcessRequest (Request) returns (Response) {}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
message Request {
|
|
406
|
-
int32 param1 = 1;
|
|
407
|
-
int32 param2 = 2;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
message Response {
|
|
411
|
-
int32 status = 1;
|
|
412
|
-
string message = 2;
|
|
413
|
-
map<string, string> data = 3;
|
|
414
|
-
}
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
## 学习来源
|
|
418
|
-
从src/services/rpc_service.py模块中的Server类和RequestHandler实现提取
|
|
419
|
-
</markdown>
|
|
368
|
+
while True:
|
|
369
|
+
time.sleep(86400) # 一天
|
|
370
|
+
except KeyboardInterrupt:
|
|
371
|
+
server.stop(0)
|
|
372
|
+
logging.info("服务已停止")
|
|
373
|
+
|
|
374
|
+
if __name__ == '__main__':
|
|
375
|
+
logging.basicConfig(level=logging.INFO)
|
|
376
|
+
serve()
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## 依赖说明
|
|
380
|
+
- 需要安装 grpcio>=1.44.0 和 grpcio-tools>=1.44.0
|
|
381
|
+
- 需要预先定义proto文件并生成对应Python代码:
|
|
382
|
+
```bash
|
|
383
|
+
python -m grpc_tools.protoc -I./protos --python_out=. --grpc_python_out=. ./protos/service.proto
|
|
384
|
+
```
|
|
385
|
+
- 示例proto文件结构:
|
|
386
|
+
```protobuf
|
|
387
|
+
syntax = "proto3";
|
|
388
|
+
|
|
389
|
+
service MyService {
|
|
390
|
+
rpc ProcessRequest (Request) returns (Response) {}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
message Request {
|
|
394
|
+
int32 param1 = 1;
|
|
395
|
+
int32 param2 = 2;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
message Response {
|
|
399
|
+
int32 status = 1;
|
|
400
|
+
string message = 2;
|
|
401
|
+
map<string, string> data = 3;
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## 学习来源
|
|
406
|
+
从src/services/rpc_service.py模块中的Server类和RequestHandler实现提取
|
|
420
407
|
|
|
421
408
|
## 索引文件更新说明
|
|
422
409
|
|
|
423
410
|
除了生成规则文件外,请务必更新index.md索引文件,记录所有规则及其作用。如果 index.md 当前内容为空,请按如下格式创建:
|
|
424
|
-
|
|
425
|
-
<markdown>
|
|
411
|
+
|
|
426
412
|
# Rules索引
|
|
427
413
|
|
|
428
414
|
本文档记录项目中所有可用的代码规则(rules)及其用途。
|
|
429
415
|
|
|
430
416
|
## [规则文件路径]
|
|
431
417
|
[规则文件的主要功能和适用场景简述]
|
|
432
|
-
</markdown>
|
|
433
418
|
|
|
434
419
|
## 评价标准
|
|
435
420
|
- 提取的功能点必须具备独立价值,能在其他项目中实际复用
|
|
436
421
|
- 代码示例必须完整、可执行,包含所有必要组件
|
|
437
422
|
- 文档结构清晰,遵循规定格式
|
|
438
423
|
- 依赖说明明确具体,便于用户快速配置环境
|
|
424
|
+
|
|
425
|
+
请根据要求生成或者更新规则文件(markdown文件),并将规则文件存储在项目的 {{ project_root }}/.autocoderrules 目录,供后续自动化代码生成使用。
|
|
439
426
|
"""
|
|
440
427
|
|
|
441
428
|
# 获取索引文件内容
|
|
File without changes
|