rcoder 1.0.0__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.
- rcoder/__init__.py +8 -0
- rcoder/async_feedback.py +725 -0
- rcoder/async_proxy.py +556 -0
- rcoder/auto_optimizer.py +648 -0
- rcoder/cli.py +145 -0
- rcoder/conversational_config.py +345 -0
- rcoder/core.py +584 -0
- rcoder/core_optimized.py +958 -0
- rcoder/process_manager.py +443 -0
- rcoder/remote_tools.py +434 -0
- rcoder/server_installer.py +373 -0
- rcoder/utils.py +213 -0
- rcoder-1.0.0.dist-info/METADATA +442 -0
- rcoder-1.0.0.dist-info/RECORD +18 -0
- rcoder-1.0.0.dist-info/WHEEL +5 -0
- rcoder-1.0.0.dist-info/entry_points.txt +2 -0
- rcoder-1.0.0.dist-info/licenses/LICENSE +21 -0
- rcoder-1.0.0.dist-info/top_level.txt +1 -0
rcoder/cli.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Rcoder 命令行工具
|
|
4
|
+
提供命令行界面,降低使用门槛
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
import argparse
|
|
9
|
+
from rcoder.utils import (
|
|
10
|
+
quick_setup, get_default_remote, validate_config,
|
|
11
|
+
export_config, import_config, create_alias
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def cli():
|
|
16
|
+
"""命令行入口函数"""
|
|
17
|
+
parser = argparse.ArgumentParser(
|
|
18
|
+
description='Rcoder - 远程代码执行与管理系统',
|
|
19
|
+
epilog='示例: rcoder run "ls -la"'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# 子命令
|
|
23
|
+
subparsers = parser.add_subparsers(dest='command', help='可用命令')
|
|
24
|
+
|
|
25
|
+
# setup 命令
|
|
26
|
+
setup_parser = subparsers.add_parser('setup', help='快速设置向导')
|
|
27
|
+
|
|
28
|
+
# run 命令
|
|
29
|
+
run_parser = subparsers.add_parser('run', help='执行命令')
|
|
30
|
+
run_parser.add_argument('cmd', help='要执行的命令')
|
|
31
|
+
run_parser.add_argument('-s', '--server', help='服务器名称')
|
|
32
|
+
run_parser.add_argument('-t', '--timeout', type=int, default=60, help='超时时间')
|
|
33
|
+
|
|
34
|
+
# batch 命令
|
|
35
|
+
batch_parser = subparsers.add_parser('batch', help='批量执行命令')
|
|
36
|
+
batch_parser.add_argument('cmds', nargs='+', help='要执行的命令列表')
|
|
37
|
+
batch_parser.add_argument('-s', '--server', help='服务器名称')
|
|
38
|
+
batch_parser.add_argument('-t', '--timeout', type=int, default=60, help='超时时间')
|
|
39
|
+
|
|
40
|
+
# ls 命令
|
|
41
|
+
ls_parser = subparsers.add_parser('ls', help='列出目录内容')
|
|
42
|
+
ls_parser.add_argument('path', nargs='?', default='.', help='目录路径')
|
|
43
|
+
ls_parser.add_argument('-s', '--server', help='服务器名称')
|
|
44
|
+
|
|
45
|
+
# cat 命令
|
|
46
|
+
cat_parser = subparsers.add_parser('cat', help='查看文件内容')
|
|
47
|
+
cat_parser.add_argument('file', help='文件路径')
|
|
48
|
+
cat_parser.add_argument('-s', '--server', help='服务器名称')
|
|
49
|
+
|
|
50
|
+
# status 命令
|
|
51
|
+
status_parser = subparsers.add_parser('status', help='查看系统状态')
|
|
52
|
+
status_parser.add_argument('-s', '--server', help='服务器名称')
|
|
53
|
+
|
|
54
|
+
# config 命令
|
|
55
|
+
config_parser = subparsers.add_parser('config', help='配置管理')
|
|
56
|
+
config_parser.add_argument('action', choices=['validate', 'export', 'import', 'alias'],
|
|
57
|
+
help='配置操作')
|
|
58
|
+
config_parser.add_argument('file', nargs='?', help='导入的配置文件路径')
|
|
59
|
+
|
|
60
|
+
# 解析参数
|
|
61
|
+
args = parser.parse_args()
|
|
62
|
+
|
|
63
|
+
# 处理命令
|
|
64
|
+
if args.command == 'setup':
|
|
65
|
+
quick_setup()
|
|
66
|
+
|
|
67
|
+
elif args.command == 'run':
|
|
68
|
+
try:
|
|
69
|
+
remote = get_default_remote()
|
|
70
|
+
result = remote.run(args.cmd, timeout=args.timeout)
|
|
71
|
+
print(result)
|
|
72
|
+
except Exception as e:
|
|
73
|
+
print(f"❌ 执行命令失败: {e}")
|
|
74
|
+
sys.exit(1)
|
|
75
|
+
|
|
76
|
+
elif args.command == 'batch':
|
|
77
|
+
try:
|
|
78
|
+
remote = get_default_remote()
|
|
79
|
+
results = remote.run_batch(args.cmds, timeout=args.timeout)
|
|
80
|
+
for cmd, res in results.items():
|
|
81
|
+
print(f"命令: {cmd}")
|
|
82
|
+
print(f"结果: {res}")
|
|
83
|
+
print('-' * 50)
|
|
84
|
+
except Exception as e:
|
|
85
|
+
print(f"❌ 批量执行命令失败: {e}")
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
|
|
88
|
+
elif args.command == 'ls':
|
|
89
|
+
try:
|
|
90
|
+
remote = get_default_remote()
|
|
91
|
+
result = remote.ls(args.path)
|
|
92
|
+
print(result)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
print(f"❌ 列出目录失败: {e}")
|
|
95
|
+
sys.exit(1)
|
|
96
|
+
|
|
97
|
+
elif args.command == 'cat':
|
|
98
|
+
try:
|
|
99
|
+
remote = get_default_remote()
|
|
100
|
+
result = remote.cat(args.file)
|
|
101
|
+
print(result)
|
|
102
|
+
except Exception as e:
|
|
103
|
+
print(f"❌ 查看文件失败: {e}")
|
|
104
|
+
sys.exit(1)
|
|
105
|
+
|
|
106
|
+
elif args.command == 'status':
|
|
107
|
+
try:
|
|
108
|
+
remote = get_default_remote()
|
|
109
|
+
print("=== 系统状态 ===")
|
|
110
|
+
print("主机名:")
|
|
111
|
+
print(remote.hostname())
|
|
112
|
+
print()
|
|
113
|
+
print("运行时间:")
|
|
114
|
+
print(remote.uptime())
|
|
115
|
+
print()
|
|
116
|
+
print("内存使用:")
|
|
117
|
+
print(remote.free())
|
|
118
|
+
print()
|
|
119
|
+
print("磁盘使用:")
|
|
120
|
+
print(remote.df())
|
|
121
|
+
print()
|
|
122
|
+
print("IP地址:")
|
|
123
|
+
print(remote.ip())
|
|
124
|
+
except Exception as e:
|
|
125
|
+
print(f"❌ 获取系统状态失败: {e}")
|
|
126
|
+
sys.exit(1)
|
|
127
|
+
|
|
128
|
+
elif args.command == 'config':
|
|
129
|
+
if args.action == 'validate':
|
|
130
|
+
validate_config()
|
|
131
|
+
elif args.action == 'export':
|
|
132
|
+
export_config()
|
|
133
|
+
elif args.action == 'import' and args.file:
|
|
134
|
+
import_config(args.file)
|
|
135
|
+
elif args.action == 'alias':
|
|
136
|
+
create_alias()
|
|
137
|
+
else:
|
|
138
|
+
config_parser.print_help()
|
|
139
|
+
|
|
140
|
+
else:
|
|
141
|
+
parser.print_help()
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if __name__ == '__main__':
|
|
145
|
+
cli()
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Rcoder 对话式配置模块
|
|
4
|
+
允许用户通过对话方式配置Rcoder,包括MCP服务器和技能配置
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import time
|
|
10
|
+
from typing import Dict, Any, Optional
|
|
11
|
+
|
|
12
|
+
class ConversationalConfig:
|
|
13
|
+
"""
|
|
14
|
+
对话式配置类
|
|
15
|
+
提供交互式配置界面,支持MCP服务器和技能配置
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, config_file: str = '~/.rcoder/config.json'):
|
|
19
|
+
"""
|
|
20
|
+
初始化对话式配置
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
config_file: 配置文件路径
|
|
24
|
+
"""
|
|
25
|
+
self.config_file = os.path.expanduser(config_file)
|
|
26
|
+
self.config = self._load_config()
|
|
27
|
+
self._conversations = []
|
|
28
|
+
|
|
29
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
30
|
+
"""
|
|
31
|
+
加载配置文件
|
|
32
|
+
"""
|
|
33
|
+
default_config = {
|
|
34
|
+
"mcp": {
|
|
35
|
+
"enabled": False,
|
|
36
|
+
"server": "",
|
|
37
|
+
"port": 443,
|
|
38
|
+
"api_key": "",
|
|
39
|
+
"timeout": 30
|
|
40
|
+
},
|
|
41
|
+
"skills": {
|
|
42
|
+
"enabled": False,
|
|
43
|
+
"directory": "~/.rcoder/skills",
|
|
44
|
+
"auto_load": True
|
|
45
|
+
},
|
|
46
|
+
"network": {
|
|
47
|
+
"auto_optimize": True,
|
|
48
|
+
"use_proxy": False,
|
|
49
|
+
"proxy_server": "",
|
|
50
|
+
"proxy_port": 443,
|
|
51
|
+
"password": ""
|
|
52
|
+
},
|
|
53
|
+
"optimization": {
|
|
54
|
+
"enable_compression": True,
|
|
55
|
+
"enable_connection_pool": True,
|
|
56
|
+
"connection_pool_size": 5
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
if os.path.exists(self.config_file):
|
|
62
|
+
with open(self.config_file, 'r', encoding='utf-8') as f:
|
|
63
|
+
config = json.load(f)
|
|
64
|
+
# 合并默认配置
|
|
65
|
+
self._merge_config(default_config, config)
|
|
66
|
+
return default_config
|
|
67
|
+
except Exception as e:
|
|
68
|
+
print(f"警告: 加载配置文件失败: {e}")
|
|
69
|
+
|
|
70
|
+
# 保存默认配置
|
|
71
|
+
self._save_config(default_config)
|
|
72
|
+
return default_config
|
|
73
|
+
|
|
74
|
+
def _merge_config(self, default: Dict[str, Any], user: Dict[str, Any]):
|
|
75
|
+
"""
|
|
76
|
+
合并配置
|
|
77
|
+
"""
|
|
78
|
+
for key, value in user.items():
|
|
79
|
+
if key in default and isinstance(default[key], dict) and isinstance(value, dict):
|
|
80
|
+
self._merge_config(default[key], value)
|
|
81
|
+
else:
|
|
82
|
+
default[key] = value
|
|
83
|
+
|
|
84
|
+
def _save_config(self, config: Dict[str, Any]):
|
|
85
|
+
"""
|
|
86
|
+
保存配置文件
|
|
87
|
+
"""
|
|
88
|
+
try:
|
|
89
|
+
os.makedirs(os.path.dirname(self.config_file), exist_ok=True)
|
|
90
|
+
with open(self.config_file, 'w', encoding='utf-8') as f:
|
|
91
|
+
json.dump(config, f, indent=2, ensure_ascii=False)
|
|
92
|
+
except Exception as e:
|
|
93
|
+
print(f"警告: 保存配置文件失败: {e}")
|
|
94
|
+
|
|
95
|
+
def _ask_question(self, question: str, default: Optional[str] = None) -> str:
|
|
96
|
+
"""
|
|
97
|
+
询问问题并获取回答
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
question: 问题
|
|
101
|
+
default: 默认回答
|
|
102
|
+
"""
|
|
103
|
+
prompt = f"{question}"
|
|
104
|
+
if default is not None:
|
|
105
|
+
prompt += f" (默认: {default})"
|
|
106
|
+
prompt += ": "
|
|
107
|
+
|
|
108
|
+
answer = input(prompt)
|
|
109
|
+
if not answer and default is not None:
|
|
110
|
+
return default
|
|
111
|
+
return answer
|
|
112
|
+
|
|
113
|
+
def _ask_yes_no(self, question: str, default: bool = True) -> bool:
|
|
114
|
+
"""
|
|
115
|
+
询问是/否问题
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
question: 问题
|
|
119
|
+
default: 默认回答
|
|
120
|
+
"""
|
|
121
|
+
prompt = f"{question} ({'Y/n' if default else 'y/N'}): "
|
|
122
|
+
answer = input(prompt).lower().strip()
|
|
123
|
+
|
|
124
|
+
if not answer:
|
|
125
|
+
return default
|
|
126
|
+
return answer in ['y', 'yes']
|
|
127
|
+
|
|
128
|
+
def start_configuration(self):
|
|
129
|
+
"""
|
|
130
|
+
开始对话式配置
|
|
131
|
+
"""
|
|
132
|
+
print("=== Rcoder 对话式配置 ===")
|
|
133
|
+
print("欢迎使用Rcoder对话式配置助手。")
|
|
134
|
+
print("我会引导您完成MCP服务器和技能配置。")
|
|
135
|
+
print()
|
|
136
|
+
|
|
137
|
+
# 配置MCP服务器
|
|
138
|
+
self._configure_mcp()
|
|
139
|
+
print()
|
|
140
|
+
|
|
141
|
+
# 配置技能
|
|
142
|
+
self._configure_skills()
|
|
143
|
+
print()
|
|
144
|
+
|
|
145
|
+
# 配置网络设置
|
|
146
|
+
self._configure_network()
|
|
147
|
+
print()
|
|
148
|
+
|
|
149
|
+
# 配置优化设置
|
|
150
|
+
self._configure_optimization()
|
|
151
|
+
print()
|
|
152
|
+
|
|
153
|
+
# 保存配置
|
|
154
|
+
self._save_config(self.config)
|
|
155
|
+
print("✅ 配置已保存到:", self.config_file)
|
|
156
|
+
print()
|
|
157
|
+
|
|
158
|
+
# 显示配置摘要
|
|
159
|
+
self._show_config_summary()
|
|
160
|
+
print()
|
|
161
|
+
print("=== 配置完成 ===")
|
|
162
|
+
print("您现在可以使用配置好的Rcoder了。")
|
|
163
|
+
|
|
164
|
+
def _configure_mcp(self):
|
|
165
|
+
"""
|
|
166
|
+
配置MCP服务器
|
|
167
|
+
"""
|
|
168
|
+
print("1. MCP服务器配置")
|
|
169
|
+
print("MCP服务器提供额外的功能和集成能力。")
|
|
170
|
+
|
|
171
|
+
enable_mcp = self._ask_yes_no("是否启用MCP服务器", self.config['mcp']['enabled'])
|
|
172
|
+
self.config['mcp']['enabled'] = enable_mcp
|
|
173
|
+
|
|
174
|
+
if enable_mcp:
|
|
175
|
+
server = self._ask_question("MCP服务器地址", self.config['mcp']['server'])
|
|
176
|
+
self.config['mcp']['server'] = server
|
|
177
|
+
|
|
178
|
+
port = self._ask_question("MCP服务器端口", str(self.config['mcp']['port']))
|
|
179
|
+
try:
|
|
180
|
+
self.config['mcp']['port'] = int(port)
|
|
181
|
+
except:
|
|
182
|
+
self.config['mcp']['port'] = 443
|
|
183
|
+
|
|
184
|
+
api_key = self._ask_question("MCP API密钥", self.config['mcp']['api_key'])
|
|
185
|
+
self.config['mcp']['api_key'] = api_key
|
|
186
|
+
|
|
187
|
+
timeout = self._ask_question("MCP超时时间(秒)", str(self.config['mcp']['timeout']))
|
|
188
|
+
try:
|
|
189
|
+
self.config['mcp']['timeout'] = int(timeout)
|
|
190
|
+
except:
|
|
191
|
+
self.config['mcp']['timeout'] = 30
|
|
192
|
+
|
|
193
|
+
print("✅ MCP服务器配置完成")
|
|
194
|
+
|
|
195
|
+
def _configure_skills(self):
|
|
196
|
+
"""
|
|
197
|
+
配置技能
|
|
198
|
+
"""
|
|
199
|
+
print("2. 技能配置")
|
|
200
|
+
print("技能扩展了Rcoder的功能。")
|
|
201
|
+
|
|
202
|
+
enable_skills = self._ask_yes_no("是否启用技能系统", self.config['skills']['enabled'])
|
|
203
|
+
self.config['skills']['enabled'] = enable_skills
|
|
204
|
+
|
|
205
|
+
if enable_skills:
|
|
206
|
+
directory = self._ask_question("技能目录", self.config['skills']['directory'])
|
|
207
|
+
self.config['skills']['directory'] = directory
|
|
208
|
+
|
|
209
|
+
auto_load = self._ask_yes_no("是否自动加载技能", self.config['skills']['auto_load'])
|
|
210
|
+
self.config['skills']['auto_load'] = auto_load
|
|
211
|
+
|
|
212
|
+
print("✅ 技能配置完成")
|
|
213
|
+
|
|
214
|
+
def _configure_network(self):
|
|
215
|
+
"""
|
|
216
|
+
配置网络设置
|
|
217
|
+
"""
|
|
218
|
+
print("3. 网络设置")
|
|
219
|
+
print("网络设置影响Rcoder的连接和性能。")
|
|
220
|
+
|
|
221
|
+
auto_optimize = self._ask_yes_no("是否启用自动网络优化", self.config['network']['auto_optimize'])
|
|
222
|
+
self.config['network']['auto_optimize'] = auto_optimize
|
|
223
|
+
|
|
224
|
+
use_proxy = self._ask_yes_no("是否使用代理服务器", self.config['network']['use_proxy'])
|
|
225
|
+
self.config['network']['use_proxy'] = use_proxy
|
|
226
|
+
|
|
227
|
+
if use_proxy:
|
|
228
|
+
proxy_server = self._ask_question("代理服务器地址", self.config['network']['proxy_server'])
|
|
229
|
+
self.config['network']['proxy_server'] = proxy_server
|
|
230
|
+
|
|
231
|
+
proxy_port = self._ask_question("代理服务器端口", str(self.config['network']['proxy_port']))
|
|
232
|
+
try:
|
|
233
|
+
self.config['network']['proxy_port'] = int(proxy_port)
|
|
234
|
+
except:
|
|
235
|
+
self.config['network']['proxy_port'] = 443
|
|
236
|
+
|
|
237
|
+
# 配置认证密码
|
|
238
|
+
use_password = self._ask_yes_no("是否使用认证密码", bool(self.config['network']['password']))
|
|
239
|
+
if use_password:
|
|
240
|
+
password = self._ask_question("认证密码", self.config['network']['password'])
|
|
241
|
+
self.config['network']['password'] = password
|
|
242
|
+
else:
|
|
243
|
+
self.config['network']['password'] = ""
|
|
244
|
+
|
|
245
|
+
print("✅ 网络设置配置完成")
|
|
246
|
+
|
|
247
|
+
def _configure_optimization(self):
|
|
248
|
+
"""
|
|
249
|
+
配置优化设置
|
|
250
|
+
"""
|
|
251
|
+
print("4. 优化设置")
|
|
252
|
+
print("优化设置可以提高Rcoder的性能和可靠性。")
|
|
253
|
+
|
|
254
|
+
enable_compression = self._ask_yes_no("是否启用数据压缩", self.config['optimization']['enable_compression'])
|
|
255
|
+
self.config['optimization']['enable_compression'] = enable_compression
|
|
256
|
+
|
|
257
|
+
enable_connection_pool = self._ask_yes_no("是否启用连接池", self.config['optimization']['enable_connection_pool'])
|
|
258
|
+
self.config['optimization']['enable_connection_pool'] = enable_connection_pool
|
|
259
|
+
|
|
260
|
+
if enable_connection_pool:
|
|
261
|
+
pool_size = self._ask_question("连接池大小", str(self.config['optimization']['connection_pool_size']))
|
|
262
|
+
try:
|
|
263
|
+
self.config['optimization']['connection_pool_size'] = int(pool_size)
|
|
264
|
+
except:
|
|
265
|
+
self.config['optimization']['connection_pool_size'] = 5
|
|
266
|
+
|
|
267
|
+
print("✅ 优化设置配置完成")
|
|
268
|
+
|
|
269
|
+
def _show_config_summary(self):
|
|
270
|
+
"""
|
|
271
|
+
显示配置摘要
|
|
272
|
+
"""
|
|
273
|
+
print("=== 配置摘要 ===")
|
|
274
|
+
|
|
275
|
+
print("MCP服务器:")
|
|
276
|
+
print(f" 启用: {'是' if self.config['mcp']['enabled'] else '否'}")
|
|
277
|
+
if self.config['mcp']['enabled']:
|
|
278
|
+
print(f" 服务器: {self.config['mcp']['server']}:{self.config['mcp']['port']}")
|
|
279
|
+
print(f" API密钥: {'***' if self.config['mcp']['api_key'] else '未设置'}")
|
|
280
|
+
|
|
281
|
+
print("\n技能系统:")
|
|
282
|
+
print(f" 启用: {'是' if self.config['skills']['enabled'] else '否'}")
|
|
283
|
+
if self.config['skills']['enabled']:
|
|
284
|
+
print(f" 目录: {self.config['skills']['directory']}")
|
|
285
|
+
print(f" 自动加载: {'是' if self.config['skills']['auto_load'] else '否'}")
|
|
286
|
+
|
|
287
|
+
print("\n网络设置:")
|
|
288
|
+
print(f" 自动优化: {'是' if self.config['network']['auto_optimize'] else '否'}")
|
|
289
|
+
print(f" 使用代理: {'是' if self.config['network']['use_proxy'] else '否'}")
|
|
290
|
+
if self.config['network']['use_proxy']:
|
|
291
|
+
print(f" 代理服务器: {self.config['network']['proxy_server']}:{self.config['network']['proxy_port']}")
|
|
292
|
+
print(f" 使用密码认证: {'是' if self.config['network']['password'] else '否'}")
|
|
293
|
+
|
|
294
|
+
print("\n优化设置:")
|
|
295
|
+
print(f" 数据压缩: {'是' if self.config['optimization']['enable_compression'] else '否'}")
|
|
296
|
+
print(f" 连接池: {'是' if self.config['optimization']['enable_connection_pool'] else '否'}")
|
|
297
|
+
if self.config['optimization']['enable_connection_pool']:
|
|
298
|
+
print(f" 连接池大小: {self.config['optimization']['connection_pool_size']}")
|
|
299
|
+
|
|
300
|
+
def get_config(self) -> Dict[str, Any]:
|
|
301
|
+
"""
|
|
302
|
+
获取当前配置
|
|
303
|
+
|
|
304
|
+
Returns:
|
|
305
|
+
当前配置字典
|
|
306
|
+
"""
|
|
307
|
+
return self.config
|
|
308
|
+
|
|
309
|
+
def update_config(self, updates: Dict[str, Any]):
|
|
310
|
+
"""
|
|
311
|
+
更新配置
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
updates: 要更新的配置项
|
|
315
|
+
"""
|
|
316
|
+
self._merge_config(self.config, updates)
|
|
317
|
+
self._save_config(self.config)
|
|
318
|
+
|
|
319
|
+
def load_from_conversation(self, conversation: str):
|
|
320
|
+
"""
|
|
321
|
+
从对话历史加载配置
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
conversation: 对话历史
|
|
325
|
+
"""
|
|
326
|
+
# 这里可以实现从对话历史解析配置的逻辑
|
|
327
|
+
# 例如,从用户的自然语言描述中提取配置信息
|
|
328
|
+
pass
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def start_conversational_config(config_file: str = '~/.rcoder/config.json'):
|
|
332
|
+
"""
|
|
333
|
+
启动对话式配置
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
config_file: 配置文件路径
|
|
337
|
+
"""
|
|
338
|
+
config = ConversationalConfig(config_file)
|
|
339
|
+
config.start_configuration()
|
|
340
|
+
return config
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# 示例代码
|
|
344
|
+
if __name__ == "__main__":
|
|
345
|
+
start_conversational_config()
|