jarvis-ai-assistant 0.1.179__py3-none-any.whl → 0.1.181__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 jarvis-ai-assistant might be problematic. Click here for more details.

@@ -61,6 +61,30 @@ class ScriptTool:
61
61
  "g++": "cpp",
62
62
  }
63
63
 
64
+ def get_display_output(self, file_path: str) -> str:
65
+ """消除控制字符,得到用户实际看到的文本,去除script命令首尾行"""
66
+ import re
67
+ # 读取文件内容并尝试多种编码
68
+ with open(file_path, 'rb') as f:
69
+ data = f.read()
70
+
71
+ import pyte
72
+ screen = pyte.Screen(300, 100000)
73
+ stream = pyte.ByteStream(screen)
74
+ stream.feed(data)
75
+
76
+ # 清理每行右侧空格,并过滤空行
77
+ cleaned = []
78
+ cleaned = []
79
+ for y in range(screen.lines):
80
+ line = screen.buffer[y]
81
+ stripped = "".join(
82
+ char.data for char in line.values()
83
+ ).rstrip()
84
+ if stripped:
85
+ cleaned.append(stripped)
86
+ return "\n".join(cleaned[1:-1])
87
+
64
88
  def _execute_script_with_interpreter(self, interpreter: str, script_content: str) -> Dict[str, Any]:
65
89
  """Execute a script with the specified interpreter
66
90
 
@@ -90,13 +114,8 @@ class ScriptTool:
90
114
 
91
115
  # Read and process output file
92
116
  try:
93
- with open(output_file, 'r', encoding='utf-8', errors='ignore') as f:
94
- output = f.read()
95
- # Remove header and footer added by script command (if any)
96
- if output:
97
- lines = output.splitlines()
98
- if len(lines) > 2:
99
- output = "\n".join(lines[1:-1])
117
+ # 消除控制字符,得到用户实际看到的文本
118
+ output = self.get_display_output(output_file)
100
119
  except Exception as e:
101
120
  output = f"读取输出文件失败: {str(e)}"
102
121
 
@@ -150,4 +169,8 @@ class ScriptTool:
150
169
  "success": False,
151
170
  "stdout": "",
152
171
  "stderr": str(e)
153
- }
172
+ }
173
+
174
+ if __name__ == "__main__":
175
+ script_tool = ScriptTool()
176
+ print(script_tool.get_display_output("/home/wangmaobin/code/Jarvis/a.txt"))
@@ -198,7 +198,7 @@ class ToolRegistry(OutputHandlerProtocol):
198
198
  stats_file = Path(get_data_dir()) / "tool_stat.yaml"
199
199
  try:
200
200
  with open(stats_file, "w", encoding="utf-8") as f:
201
- yaml.safe_dump(stats, f)
201
+ yaml.safe_dump(stats, f, allow_unicode=True)
202
202
  except Exception as e:
203
203
  PrettyOutput.print(
204
204
  f"保存工具调用统计失败: {str(e)}", OutputType.WARNING
@@ -229,14 +229,36 @@ class ToolRegistry(OutputHandlerProtocol):
229
229
  }
230
230
 
231
231
  def _load_mcp_tools(self) -> None:
232
- """从jarvis_data/tools/mcp加载工具"""
232
+ """加载MCP工具,优先从配置获取,其次从目录扫描"""
233
+ from jarvis.jarvis_utils.config import get_mcp_config
234
+
235
+ # 优先从配置获取MCP工具配置
236
+ mcp_configs = get_mcp_config()
237
+ if mcp_configs:
238
+ for config in mcp_configs:
239
+ self.register_mcp_tool_by_config(config)
240
+ return
241
+
242
+ # 如果配置中没有,则扫描目录
233
243
  mcp_tools_dir = Path(get_data_dir()) / "mcp"
234
244
  if not mcp_tools_dir.exists():
235
245
  return
236
246
 
247
+ # 添加警告信息
248
+ PrettyOutput.print(
249
+ "警告: 从文件目录加载MCP工具的方式将在未来版本中废弃,请尽快迁移到JARVIS_MCP配置方式",
250
+ OutputType.WARNING
251
+ )
252
+
237
253
  # 遍历目录中的所有.yaml文件
238
254
  for file_path in mcp_tools_dir.glob("*.yaml"):
239
- self.register_mcp_tool_by_file(str(file_path))
255
+ try:
256
+ config = yaml.safe_load(open(file_path, "r", encoding="utf-8"))
257
+ self.register_mcp_tool_by_config(config)
258
+ except Exception as e:
259
+ PrettyOutput.print(
260
+ f"文件 {file_path} 加载失败: {str(e)}", OutputType.WARNING
261
+ )
240
262
 
241
263
  def _load_builtin_tools(self) -> None:
242
264
  """从内置工具目录加载工具"""
@@ -264,29 +286,26 @@ class ToolRegistry(OutputHandlerProtocol):
264
286
 
265
287
  self.register_tool_by_file(str(file_path))
266
288
 
267
- def register_mcp_tool_by_file(self, file_path: str) -> bool:
268
- """从指定文件加载并注册工具
289
+ def register_mcp_tool_by_config(self, config: Dict[str, Any]) -> bool:
290
+ """从配置字典加载并注册工具
269
291
 
270
292
  参数:
271
- file_path: 工具文件的路径
293
+ config: MCP工具配置字典
272
294
 
273
295
  返回:
274
296
  bool: 工具是否加载成功
275
297
  """
276
298
  try:
277
- config = yaml.safe_load(open(file_path, "r", encoding="utf-8"))
278
299
  if "type" not in config:
279
- PrettyOutput.print(f"文件 {file_path} 缺少type字段", OutputType.WARNING)
300
+ PrettyOutput.print(f"配置{config.get('name', '')}缺少type字段", OutputType.WARNING)
280
301
  return False
281
302
 
282
303
  # 检查enable标志
283
304
  if not config.get("enable", True):
284
- PrettyOutput.print(
285
- f"文件 {file_path} 已禁用(enable=false),跳过注册", OutputType.INFO
286
- )
305
+ PrettyOutput.print(f"MCP配置{config.get('name', '')}已禁用(enable=false),跳过注册", OutputType.INFO)
287
306
  return False
288
307
 
289
- name = config.get("name", Path(file_path).stem)
308
+ name = config.get("name", "mcp")
290
309
 
291
310
  # 注册资源工具
292
311
  def create_resource_list_func(client: McpClient):
@@ -296,11 +315,11 @@ class ToolRegistry(OutputHandlerProtocol):
296
315
  args.pop("want", None)
297
316
  ret = client.get_resource_list()
298
317
  PrettyOutput.print(
299
- f"MCP {name} 资源列表:\n{yaml.safe_dump(ret)}", OutputType.TOOL
318
+ f"MCP {name} 资源列表:\n{yaml.safe_dump(ret, allow_unicode=True)}", OutputType.TOOL
300
319
  )
301
320
  return {
302
321
  "success": True,
303
- "stdout": yaml.safe_dump(ret),
322
+ "stdout": yaml.safe_dump(ret, allow_unicode=True),
304
323
  "stderr": "",
305
324
  }
306
325
 
@@ -319,7 +338,7 @@ class ToolRegistry(OutputHandlerProtocol):
319
338
  }
320
339
  ret = client.get_resource(args["uri"])
321
340
  PrettyOutput.print(
322
- f"MCP {name} 获取资源:\n{yaml.safe_dump(ret)}", OutputType.TOOL
341
+ f"MCP {name} 获取资源:\n{yaml.safe_dump(ret, allow_unicode=True)}", OutputType.TOOL
323
342
  )
324
343
  return ret
325
344
 
@@ -332,7 +351,7 @@ class ToolRegistry(OutputHandlerProtocol):
332
351
  args.pop("want", None)
333
352
  ret = client.execute(tool_name, args)
334
353
  PrettyOutput.print(
335
- f"MCP {name} {tool_name} 执行结果:\n{yaml.safe_dump(ret)}",
354
+ f"MCP {name} {tool_name} 执行结果:\n{yaml.safe_dump(ret, allow_unicode=True)}",
336
355
  OutputType.TOOL,
337
356
  )
338
357
  return ret
@@ -341,26 +360,18 @@ class ToolRegistry(OutputHandlerProtocol):
341
360
 
342
361
  if config["type"] == "stdio":
343
362
  if "command" not in config:
344
- PrettyOutput.print(
345
- f"文件 {file_path} 缺少command字段", OutputType.WARNING
346
- )
363
+ PrettyOutput.print(f"配置{config.get('name', '')}缺少command字段", OutputType.WARNING)
347
364
  return False
348
365
  elif config["type"] == "sse":
349
366
  if "base_url" not in config:
350
- PrettyOutput.print(
351
- f"文件 {file_path} 缺少base_url字段", OutputType.WARNING
352
- )
367
+ PrettyOutput.print(f"配置{config.get('name', '')}缺少base_url字段", OutputType.WARNING)
353
368
  return False
354
369
  elif config["type"] == "streamable":
355
370
  if "base_url" not in config:
356
- PrettyOutput.print(
357
- f"文件 {file_path} 缺少base_url字段", OutputType.WARNING
358
- )
371
+ PrettyOutput.print(f"配置{config.get('name', '')}缺少base_url字段", OutputType.WARNING)
359
372
  return False
360
373
  else:
361
- PrettyOutput.print(
362
- f"文件 {file_path} 类型错误: {config['type']}", OutputType.WARNING
363
- )
374
+ PrettyOutput.print(f"不支持的MCP客户端类型: {config['type']}", OutputType.WARNING)
364
375
  return False
365
376
 
366
377
  # 创建MCP客户端
@@ -376,14 +387,11 @@ class ToolRegistry(OutputHandlerProtocol):
376
387
  # 获取工具信息
377
388
  tools = mcp_client.get_tool_list()
378
389
  if not tools:
379
- PrettyOutput.print(
380
- f"从 {file_path} 获取工具列表失败", OutputType.WARNING
381
- )
390
+ PrettyOutput.print(f"从配置{config.get('name', '')}获取工具列表失败", OutputType.WARNING)
382
391
  return False
383
392
 
384
393
  # 注册每个工具
385
394
  for tool in tools:
386
-
387
395
  # 注册工具
388
396
  self.register_tool(
389
397
  name=f"{name}.tool_call.{tool['name']}",
@@ -417,9 +425,7 @@ class ToolRegistry(OutputHandlerProtocol):
417
425
  return True
418
426
 
419
427
  except Exception as e:
420
- PrettyOutput.print(
421
- f"文件 {file_path} 加载失败: {str(e)}", OutputType.WARNING
422
- )
428
+ PrettyOutput.print(f"MCP配置{config.get('name', '')}加载失败: {str(e)}", OutputType.WARNING)
423
429
  return False
424
430
 
425
431
  def register_tool_by_file(self, file_path: str) -> bool:
@@ -8,27 +8,6 @@
8
8
  from jarvis.jarvis_utils.tag import ct, ot
9
9
 
10
10
  BUILTIN_REPLACE_MAP = {
11
- "CodeBase": {
12
- "append": True,
13
- "template": f"""
14
- 请使用ask_codebase工具查询代码库,必须严格遵守以下工具调用格式:
15
-
16
- {ot("TOOL_CALL")}
17
- want: 想要从执行结果中获取到的信息
18
- name: ask_codebase
19
- arguments:
20
- question: "与xxx功能相关的文件有哪些?"
21
- {ct("TOOL_CALL")}
22
-
23
- 可以使用的提问格式包括:
24
- 1. 与xxx功能相关的文件有哪些?
25
- 2. 要实现xxx,应该要修改哪些文件?
26
- 3. xxx功能是怎么实现的?
27
- 4. xxx模块的入口函数是什么?
28
- 5. xxx功能的测试用例在哪里?
29
- """,
30
- "description": "查询代码库"
31
- },
32
11
  "Web": {
33
12
  "append": True,
34
13
  "template": f"""
@@ -50,27 +29,6 @@ arguments:
50
29
  """,
51
30
  "description": "网页搜索"
52
31
  },
53
- "Methodology": {
54
- "append": True,
55
- "template": f"""
56
- 请使用find_methodology工具查找相关方法论,必须严格遵守以下工具调用格式:
57
-
58
- {ot("TOOL_CALL")}
59
- want: 想要从执行结果中获取到的信息
60
- name: find_methodology
61
- arguments:
62
- query: "关于xxx的方法论有哪些?"
63
- {ct("TOOL_CALL")}
64
-
65
- 可以使用的提问格式包括:
66
- 1. 关于xxx的方法论有哪些?
67
- 2. 如何解决xxx问题?
68
- 3. xxx的最佳实践是什么?
69
- 4. 处理xxx的标准流程是什么?
70
- 5. 实现xxx的参考方案有哪些?
71
- """,
72
- "description": "查找相关方法论"
73
- },
74
32
  "Plan": {
75
33
  "append": True,
76
34
  "template": f"""
@@ -111,12 +69,6 @@ code_plan工具将:
111
69
  "append": False,
112
70
  "template": f"""
113
71
  请使用工具在当前目录下查找与以下功能相关的文件:
114
- """
115
- },
116
- "FindMethodology": {
117
- "append": False,
118
- "template": f"""
119
- 请使用find_methodology工具查找相关方法论:
120
72
  """
121
73
  },
122
74
  "Dev": {
@@ -2,10 +2,30 @@
2
2
  import os
3
3
  from functools import lru_cache
4
4
 
5
+ from typing import Any, Dict, List
6
+
7
+
5
8
  import yaml
6
9
 
10
+
7
11
  from jarvis.jarvis_utils.builtin_replace_map import BUILTIN_REPLACE_MAP
8
12
 
13
+
14
+ # 全局环境变量存储
15
+
16
+ GLOBAL_CONFIG_DATA: Dict[str, Any] = {}
17
+
18
+
19
+ def set_global_env_data(env_data: Dict[str, Any]) -> None:
20
+ """设置全局环境变量数据"""
21
+ global GLOBAL_CONFIG_DATA
22
+ GLOBAL_CONFIG_DATA = env_data
23
+
24
+ def set_config(key: str, value: Any) -> None:
25
+ """设置配置"""
26
+ GLOBAL_CONFIG_DATA[key] = value
27
+
28
+
9
29
  """配置管理模块。
10
30
 
11
31
  该模块提供了获取Jarvis系统各种配置设置的函数。
@@ -19,7 +39,7 @@ def get_git_commit_prompt() -> str:
19
39
  返回:
20
40
  str: Git提交信息生成提示模板,如果未配置则返回空字符串
21
41
  """
22
- return os.getenv("JARVIS_GIT_COMMIT_PROMPT", "")
42
+ return GLOBAL_CONFIG_DATA.get("JARVIS_GIT_COMMIT_PROMPT", "")
23
43
 
24
44
  # 输出窗口预留大小
25
45
  INPUT_WINDOW_REVERSE_SIZE = 2048
@@ -29,16 +49,27 @@ def get_replace_map() -> dict:
29
49
  """
30
50
  获取替换映射表。
31
51
 
32
- 从数据目录下的replace_map.yaml文件中读取替换映射表,
52
+ 优先使用GLOBAL_CONFIG_DATA['JARVIS_REPLACE_MAP']的配置,
53
+ 如果没有则从数据目录下的replace_map.yaml文件中读取替换映射表,
33
54
  如果文件不存在则返回内置替换映射表。
34
55
 
35
56
  返回:
36
57
  dict: 合并后的替换映射表字典(内置+文件中的映射表)
37
58
  """
59
+ if 'JARVIS_REPLACE_MAP' in GLOBAL_CONFIG_DATA:
60
+ return {**BUILTIN_REPLACE_MAP, **GLOBAL_CONFIG_DATA['JARVIS_REPLACE_MAP']}
61
+
38
62
  replace_map_path = os.path.join(get_data_dir(), 'replace_map.yaml')
39
63
  if not os.path.exists(replace_map_path):
40
64
  return BUILTIN_REPLACE_MAP.copy()
41
65
 
66
+ from jarvis.jarvis_utils.output import PrettyOutput, OutputType
67
+ PrettyOutput.print(
68
+ "警告:使用replace_map.yaml进行配置的方式已被弃用,将在未来版本中移除。"
69
+ "请迁移到使用GLOBAL_CONFIG_DATA中的JARVIS_REPLACE_MAP配置。",
70
+ output_type=OutputType.WARNING
71
+ )
72
+
42
73
  with open(replace_map_path, 'r', encoding='utf-8', errors='ignore') as file:
43
74
  file_map = yaml.safe_load(file) or {}
44
75
  return {**BUILTIN_REPLACE_MAP, **file_map}
@@ -50,7 +81,7 @@ def get_max_token_count() -> int:
50
81
  返回:
51
82
  int: 模型能处理的最大token数量。
52
83
  """
53
- return int(os.getenv('JARVIS_MAX_TOKEN_COUNT', '960000'))
84
+ return int(GLOBAL_CONFIG_DATA.get('JARVIS_MAX_TOKEN_COUNT', '960000'))
54
85
 
55
86
  def get_max_input_token_count() -> int:
56
87
  """
@@ -59,7 +90,7 @@ def get_max_input_token_count() -> int:
59
90
  返回:
60
91
  int: 模型能处理的最大输入token数量。
61
92
  """
62
- return int(os.getenv('JARVIS_MAX_INPUT_TOKEN_COUNT', '32000'))
93
+ return int(GLOBAL_CONFIG_DATA.get('JARVIS_MAX_INPUT_TOKEN_COUNT', '32000'))
63
94
 
64
95
 
65
96
  def is_auto_complete() -> bool:
@@ -69,7 +100,7 @@ def is_auto_complete() -> bool:
69
100
  返回:
70
101
  bool: 如果启用了自动补全则返回True,默认为False
71
102
  """
72
- return os.getenv('JARVIS_AUTO_COMPLETE', 'false') == 'true'
103
+ return GLOBAL_CONFIG_DATA.get('JARVIS_AUTO_COMPLETE', False) == True
73
104
 
74
105
 
75
106
  def get_shell_name() -> str:
@@ -79,7 +110,7 @@ def get_shell_name() -> str:
79
110
  返回:
80
111
  str: Shell名称(例如bash, zsh),默认为bash
81
112
  """
82
- shell_path = os.getenv('SHELL', '/bin/bash')
113
+ shell_path = GLOBAL_CONFIG_DATA.get('SHELL', '/bin/bash')
83
114
  return os.path.basename(shell_path)
84
115
  def get_normal_platform_name() -> str:
85
116
  """
@@ -88,7 +119,7 @@ def get_normal_platform_name() -> str:
88
119
  返回:
89
120
  str: 平台名称,默认为'yuanbao'
90
121
  """
91
- return os.getenv('JARVIS_PLATFORM', 'yuanbao')
122
+ return GLOBAL_CONFIG_DATA.get('JARVIS_PLATFORM', 'yuanbao')
92
123
  def get_normal_model_name() -> str:
93
124
  """
94
125
  获取正常操作的模型名称。
@@ -96,7 +127,7 @@ def get_normal_model_name() -> str:
96
127
  返回:
97
128
  str: 模型名称,默认为'deep_seek'
98
129
  """
99
- return os.getenv('JARVIS_MODEL', 'deep_seek_v3')
130
+ return GLOBAL_CONFIG_DATA.get('JARVIS_MODEL', 'deep_seek_v3')
100
131
 
101
132
 
102
133
  def get_thinking_platform_name() -> str:
@@ -106,7 +137,7 @@ def get_thinking_platform_name() -> str:
106
137
  返回:
107
138
  str: 平台名称,默认为'yuanbao'
108
139
  """
109
- return os.getenv('JARVIS_THINKING_PLATFORM', os.getenv('JARVIS_PLATFORM', 'yuanbao'))
140
+ return GLOBAL_CONFIG_DATA.get('JARVIS_THINKING_PLATFORM', GLOBAL_CONFIG_DATA.get('JARVIS_PLATFORM', 'yuanbao'))
110
141
  def get_thinking_model_name() -> str:
111
142
  """
112
143
  获取思考操作的模型名称。
@@ -114,7 +145,7 @@ def get_thinking_model_name() -> str:
114
145
  返回:
115
146
  str: 模型名称,默认为'deep_seek'
116
147
  """
117
- return os.getenv('JARVIS_THINKING_MODEL', os.getenv('JARVIS_MODEL', 'deep_seek'))
148
+ return GLOBAL_CONFIG_DATA.get('JARVIS_THINKING_MODEL', GLOBAL_CONFIG_DATA.get('JARVIS_MODEL', 'deep_seek'))
118
149
 
119
150
  def is_execute_tool_confirm() -> bool:
120
151
  """
@@ -123,7 +154,7 @@ def is_execute_tool_confirm() -> bool:
123
154
  返回:
124
155
  bool: 如果需要确认则返回True,默认为False
125
156
  """
126
- return os.getenv('JARVIS_EXECUTE_TOOL_CONFIRM', 'false') == 'true'
157
+ return GLOBAL_CONFIG_DATA.get('JARVIS_EXECUTE_TOOL_CONFIRM', False) == True
127
158
  def is_confirm_before_apply_patch() -> bool:
128
159
  """
129
160
  检查应用补丁前是否需要确认。
@@ -131,7 +162,7 @@ def is_confirm_before_apply_patch() -> bool:
131
162
  返回:
132
163
  bool: 如果需要确认则返回True,默认为False
133
164
  """
134
- return os.getenv('JARVIS_CONFIRM_BEFORE_APPLY_PATCH', 'true') == 'true'
165
+ return GLOBAL_CONFIG_DATA.get('JARVIS_CONFIRM_BEFORE_APPLY_PATCH', True) == True
135
166
 
136
167
  def get_max_tool_call_count() -> int:
137
168
  """
@@ -140,7 +171,7 @@ def get_max_tool_call_count() -> int:
140
171
  返回:
141
172
  int: 最大连续工具调用次数,默认为20
142
173
  """
143
- return int(os.getenv('JARVIS_MAX_TOOL_CALL_COUNT', '20'))
174
+ return int(GLOBAL_CONFIG_DATA.get('JARVIS_MAX_TOOL_CALL_COUNT', '20'))
144
175
 
145
176
 
146
177
  def get_data_dir() -> str:
@@ -151,7 +182,7 @@ def get_data_dir() -> str:
151
182
  str: 数据目录路径,优先从JARVIS_DATA_PATH环境变量获取,
152
183
  如果未设置或为空,则使用~/.jarvis作为默认值
153
184
  """
154
- data_path = os.getenv('JARVIS_DATA_PATH', '').strip()
185
+ data_path = GLOBAL_CONFIG_DATA.get('JARVIS_DATA_PATH', '').strip()
155
186
  if not data_path:
156
187
  return os.path.expanduser('~/.jarvis')
157
188
  return data_path
@@ -163,7 +194,7 @@ def get_auto_update() -> bool:
163
194
  返回:
164
195
  bool: 如果需要自动更新则返回True,默认为True
165
196
  """
166
- return os.getenv('JARVIS_AUTO_UPDATE', 'true') == 'true'
197
+ return GLOBAL_CONFIG_DATA.get('JARVIS_AUTO_UPDATE', True) == True
167
198
 
168
199
  def get_max_big_content_size() -> int:
169
200
  """
@@ -172,7 +203,7 @@ def get_max_big_content_size() -> int:
172
203
  返回:
173
204
  int: 最大大内容大小
174
205
  """
175
- return int(os.getenv('JARVIS_MAX_BIG_CONTENT_SIZE', '1024000'))
206
+ return int(GLOBAL_CONFIG_DATA.get('JARVIS_MAX_BIG_CONTENT_SIZE', '1024000'))
176
207
 
177
208
  def get_pretty_output() -> bool:
178
209
  """
@@ -181,7 +212,7 @@ def get_pretty_output() -> bool:
181
212
  返回:
182
213
  bool: 如果启用PrettyOutput则返回True,默认为True
183
214
  """
184
- return os.getenv('JARVIS_PRETTY_OUTPUT', 'false') == 'true'
215
+ return GLOBAL_CONFIG_DATA.get('JARVIS_PRETTY_OUTPUT', False) == True
185
216
 
186
217
  def is_use_methodology() -> bool:
187
218
  """
@@ -190,7 +221,7 @@ def is_use_methodology() -> bool:
190
221
  返回:
191
222
  bool: 如果启用方法论则返回True,默认为True
192
223
  """
193
- return os.getenv('JARVIS_USE_METHODOLOGY', 'false') == 'true'
224
+ return GLOBAL_CONFIG_DATA.get('JARVIS_USE_METHODOLOGY', True) == True
194
225
 
195
226
  def is_use_analysis() -> bool:
196
227
  """
@@ -199,7 +230,7 @@ def is_use_analysis() -> bool:
199
230
  返回:
200
231
  bool: 如果启用任务分析则返回True,默认为True
201
232
  """
202
- return os.getenv('JARVIS_USE_ANALYSIS', 'false') == 'true'
233
+ return GLOBAL_CONFIG_DATA.get('JARVIS_USE_ANALYSIS', True) == True
203
234
 
204
235
  def is_print_prompt() -> bool:
205
236
  """
@@ -208,4 +239,14 @@ def is_print_prompt() -> bool:
208
239
  返回:
209
240
  bool: 如果打印提示则返回True,默认为True
210
241
  """
211
- return os.getenv('JARVIS_PRINT_PROMPT', 'false') == 'true'
242
+ return GLOBAL_CONFIG_DATA.get('JARVIS_PRINT_PROMPT', False) == True
243
+
244
+
245
+ def get_mcp_config() -> List[Dict[str, Any]]:
246
+ """
247
+ 获取MCP配置列表。
248
+
249
+ 返回:
250
+ List[Dict[str, Any]]: MCP配置项列表,如果未配置则返回空列表
251
+ """
252
+ return GLOBAL_CONFIG_DATA.get("JARVIS_MCP", [])