jarvis-ai-assistant 0.2.1__py3-none-any.whl → 0.2.3__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.
Files changed (41) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/jarvis.py +61 -59
  3. jarvis/jarvis_agent/main.py +42 -40
  4. jarvis/jarvis_agent/prompts.py +26 -4
  5. jarvis/jarvis_code_agent/code_agent.py +35 -31
  6. jarvis/jarvis_code_analysis/code_review.py +73 -39
  7. jarvis/jarvis_data/config_schema.json +67 -12
  8. jarvis/jarvis_git_squash/main.py +16 -12
  9. jarvis/jarvis_git_utils/git_commiter.py +25 -20
  10. jarvis/jarvis_methodology/main.py +34 -49
  11. jarvis/jarvis_multi_agent/main.py +28 -23
  12. jarvis/jarvis_platform/ai8.py +31 -22
  13. jarvis/jarvis_platform/kimi.py +31 -61
  14. jarvis/jarvis_platform/tongyi.py +71 -85
  15. jarvis/jarvis_platform/yuanbao.py +44 -50
  16. jarvis/jarvis_platform_manager/main.py +55 -90
  17. jarvis/jarvis_rag/cli.py +79 -23
  18. jarvis/jarvis_rag/query_rewriter.py +61 -12
  19. jarvis/jarvis_rag/rag_pipeline.py +143 -34
  20. jarvis/jarvis_rag/retriever.py +5 -5
  21. jarvis/jarvis_smart_shell/main.py +58 -87
  22. jarvis/jarvis_tools/cli/main.py +120 -153
  23. jarvis/jarvis_tools/generate_new_tool.py +22 -1
  24. jarvis/jarvis_tools/registry.py +1 -7
  25. jarvis/jarvis_tools/search_web.py +12 -10
  26. jarvis/jarvis_utils/config.py +92 -11
  27. jarvis/jarvis_utils/globals.py +29 -8
  28. jarvis/jarvis_utils/http.py +58 -79
  29. jarvis/jarvis_utils/input.py +114 -121
  30. jarvis/jarvis_utils/output.py +1 -1
  31. jarvis/jarvis_utils/utils.py +3 -0
  32. jarvis_ai_assistant-0.2.3.dist-info/METADATA +301 -0
  33. {jarvis_ai_assistant-0.2.1.dist-info → jarvis_ai_assistant-0.2.3.dist-info}/RECORD +37 -40
  34. {jarvis_ai_assistant-0.2.1.dist-info → jarvis_ai_assistant-0.2.3.dist-info}/entry_points.txt +0 -2
  35. jarvis/jarvis_git_details/__init__.py +0 -0
  36. jarvis/jarvis_git_details/main.py +0 -265
  37. jarvis/jarvis_platform/oyi.py +0 -357
  38. jarvis_ai_assistant-0.2.1.dist-info/METADATA +0 -845
  39. {jarvis_ai_assistant-0.2.1.dist-info → jarvis_ai_assistant-0.2.3.dist-info}/WHEEL +0 -0
  40. {jarvis_ai_assistant-0.2.1.dist-info → jarvis_ai_assistant-0.2.3.dist-info}/licenses/LICENSE +0 -0
  41. {jarvis_ai_assistant-0.2.1.dist-info → jarvis_ai_assistant-0.2.3.dist-info}/top_level.txt +0 -0
@@ -8,99 +8,73 @@
8
8
  - 带有模糊匹配的文件路径补全
9
9
  - 用于输入控制的自定义键绑定
10
10
  """
11
- from colorama import Fore # type: ignore
11
+ import os
12
+ from typing import Iterable
13
+
14
+ from colorama import Fore
12
15
  from colorama import Style as ColoramaStyle # type: ignore
13
16
  from fuzzywuzzy import process # type: ignore
14
17
  from prompt_toolkit import PromptSession # type: ignore
18
+ from prompt_toolkit.completion import CompleteEvent # type: ignore
15
19
  from prompt_toolkit.completion import (
16
- CompleteEvent,
17
20
  Completer,
18
- Completion, # type: ignore
21
+ Completion,
19
22
  PathCompleter,
20
- ) # type: ignore
23
+ )
21
24
  from prompt_toolkit.document import Document # type: ignore
22
25
  from prompt_toolkit.formatted_text import FormattedText # type: ignore
26
+ from prompt_toolkit.history import FileHistory # type: ignore
23
27
  from prompt_toolkit.key_binding import KeyBindings # type: ignore
24
28
  from prompt_toolkit.styles import Style as PromptStyle # type: ignore
25
29
 
26
- from jarvis.jarvis_utils.config import get_replace_map
30
+ from jarvis.jarvis_utils.config import get_data_dir, get_replace_map
27
31
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
28
32
  from jarvis.jarvis_utils.tag import ot
29
33
  from jarvis.jarvis_utils.utils import copy_to_clipboard
30
34
 
35
+ # Sentinel value to indicate that Ctrl+O was pressed
36
+ CTRL_O_SENTINEL = "__CTRL_O_PRESSED__"
37
+
31
38
 
32
39
  def get_single_line_input(tip: str) -> str:
33
40
  """
34
41
  获取支持历史记录的单行输入。
35
-
36
- 参数:
37
- tip: 要显示的提示信息
38
-
39
- 返回:
40
- str: 用户的输入
41
42
  """
42
43
  session: PromptSession = PromptSession(history=None)
43
- style = PromptStyle.from_dict(
44
- {
45
- "prompt": "ansicyan",
46
- }
47
- )
44
+ style = PromptStyle.from_dict({"prompt": "ansicyan"})
48
45
  return session.prompt(f"{tip}", style=style)
49
46
 
50
47
 
51
48
  class FileCompleter(Completer):
52
49
  """
53
50
  带有模糊匹配的文件路径自定义补全器。
54
-
55
- 属性:
56
- path_completer: 基础路径补全器
57
- max_suggestions: 显示的最大建议数量
58
- min_score: 建议的最小匹配分数
59
51
  """
60
52
 
61
53
  def __init__(self):
62
- """使用默认设置初始化文件补全器。"""
63
54
  self.path_completer = PathCompleter()
64
55
  self.max_suggestions = 10
65
56
  self.min_score = 10
66
57
  self.replace_map = get_replace_map()
67
58
 
68
- def get_completions(self, document: Document, _: CompleteEvent) -> Completion: # type: ignore
69
- """
70
- 生成带有模糊匹配的文件路径补全建议。
71
-
72
- 参数:
73
- document: 当前正在编辑的文档
74
- complete_event: 补全事件
75
-
76
- 生成:
77
- Completion: 建议的补全项
78
- """
59
+ def get_completions(
60
+ self, document: Document, _: CompleteEvent
61
+ ) -> Iterable[Completion]:
79
62
  text = document.text_before_cursor
80
63
  cursor_pos = document.cursor_position
81
- # 查找文本中的所有@位置
82
64
  at_positions = [i for i, char in enumerate(text) if char == "@"]
83
65
  if not at_positions:
84
66
  return
85
- # 获取最后一个@位置
86
67
  current_at_pos = at_positions[-1]
87
- # 如果光标不在最后一个@之后,则不补全
88
68
  if cursor_pos <= current_at_pos:
89
69
  return
90
- # 检查@之后是否有空格
91
70
  text_after_at = text[current_at_pos + 1 : cursor_pos]
92
71
  if " " in text_after_at:
93
72
  return
94
73
 
95
- # 获取当前@之后的文本
96
74
  file_path = text_after_at.strip()
97
- # 计算替换长度
98
75
  replace_length = len(text_after_at) + 1
99
76
 
100
- # 获取所有可能的补全项
101
77
  all_completions = []
102
-
103
- # 1. 添加特殊标记
104
78
  all_completions.extend(
105
79
  [(ot(tag), self._get_description(tag)) for tag in self.replace_map.keys()]
106
80
  )
@@ -114,7 +88,6 @@ class FileCompleter(Completer):
114
88
  ]
115
89
  )
116
90
 
117
- # 2. 添加文件列表
118
91
  try:
119
92
  import subprocess
120
93
 
@@ -135,9 +108,7 @@ class FileCompleter(Completer):
135
108
  except Exception:
136
109
  pass
137
110
 
138
- # 统一过滤和排序
139
111
  if file_path:
140
- # 使用模糊匹配过滤
141
112
  scored_items = process.extract(
142
113
  file_path,
143
114
  [item[0] for item in all_completions],
@@ -146,31 +117,25 @@ class FileCompleter(Completer):
146
117
  scored_items = [
147
118
  (item[0], item[1]) for item in scored_items if item[1] > self.min_score
148
119
  ]
149
- # 创建映射以便查找描述
150
120
  completion_map = {item[0]: item[1] for item in all_completions}
151
- # 生成补全项
152
121
  for text, score in scored_items:
153
- display_text = text
154
- if score < 100:
155
- display_text = f"{text} ({score}%)"
122
+ display_text = f"{text} ({score}%)" if score < 100 else text
156
123
  yield Completion(
157
124
  text=f"'{text}'",
158
125
  start_position=-replace_length,
159
126
  display=display_text,
160
127
  display_meta=completion_map.get(text, ""),
161
- ) # type: ignore
128
+ )
162
129
  else:
163
- # 没有输入时返回前max_suggestions个建议
164
130
  for text, desc in all_completions[: self.max_suggestions]:
165
131
  yield Completion(
166
132
  text=f"'{text}'",
167
133
  start_position=-replace_length,
168
134
  display=text,
169
135
  display_meta=desc,
170
- ) # type: ignore
136
+ )
171
137
 
172
138
  def _get_description(self, tag: str) -> str:
173
- """获取标记的描述信息"""
174
139
  if tag in self.replace_map:
175
140
  return (
176
141
  self.replace_map[tag].get("description", tag) + "(Append)"
@@ -181,15 +146,7 @@ class FileCompleter(Completer):
181
146
 
182
147
 
183
148
  def user_confirm(tip: str, default: bool = True) -> bool:
184
- """提示用户确认是/否问题
185
-
186
- 参数:
187
- tip: 显示给用户的消息
188
- default: 用户直接回车时的默认响应
189
-
190
- 返回:
191
- bool: 用户确认返回True,否则返回False
192
- """
149
+ """提示用户确认是/否问题"""
193
150
  try:
194
151
  suffix = "[Y/n]" if default else "[y/N]"
195
152
  ret = get_single_line_input(f"{tip} {suffix}: ")
@@ -198,28 +155,66 @@ def user_confirm(tip: str, default: bool = True) -> bool:
198
155
  return False
199
156
 
200
157
 
201
- def get_multiline_input(tip: str) -> str:
158
+ def _show_history_and_copy():
202
159
  """
203
- 获取带有增强补全和确认功能的多行输入。
160
+ Displays message history and handles copying to clipboard.
161
+ This function uses standard I/O and is safe to call outside a prompt session.
162
+ """
163
+ from jarvis.jarvis_utils.globals import get_message_history
164
+
165
+ history = get_message_history()
166
+ if not history:
167
+ PrettyOutput.print("没有可复制的消息", OutputType.INFO)
168
+ return
204
169
 
205
- 参数:
206
- tip: 要显示的提示信息
170
+ print("\n" + "=" * 20 + " 消息历史记录 " + "=" * 20)
171
+ for i, msg in enumerate(history):
172
+ cleaned_msg = msg.replace("\n", r"\n")
173
+ display_msg = (cleaned_msg[:70] + "...") if len(cleaned_msg) > 70 else cleaned_msg
174
+ print(f" {i + 1}: {display_msg.strip()}")
175
+ print("=" * 58 + "\n")
207
176
 
208
- 返回:
209
- str: 用户的输入,如果取消则返回空字符串
177
+ while True:
178
+ try:
179
+ prompt_text = f"{Fore.CYAN}请输入要复制的条目序号 (或输入c取消, 直接回车选择最后一条): {ColoramaStyle.RESET_ALL}"
180
+ choice_str = input(prompt_text)
181
+
182
+ if not choice_str: # User pressed Enter
183
+ if not history:
184
+ print("没有历史记录可供选择。")
185
+ break
186
+ choice = len(history) - 1
187
+ elif choice_str.lower() == "c":
188
+ print("已取消")
189
+ break
190
+ else:
191
+ choice = int(choice_str) - 1
192
+
193
+ if 0 <= choice < len(history):
194
+ selected_msg = history[choice]
195
+ copy_to_clipboard(selected_msg)
196
+ PrettyOutput.print(
197
+ f"已复制消息: {selected_msg[:70]}...", OutputType.SUCCESS
198
+ )
199
+ break
200
+ else:
201
+ print("无效的序号,请重试。")
202
+ except ValueError:
203
+ print("无效的输入,请输入数字。")
204
+ except (KeyboardInterrupt, EOFError):
205
+ print("\n操作取消")
206
+ break
207
+
208
+
209
+ def _get_multiline_input_internal(tip: str) -> str:
210
+ """
211
+ Internal function to get multiline input using prompt_toolkit.
212
+ Returns a sentinel value if Ctrl+O is pressed.
210
213
  """
211
- # 显示输入说明
212
- PrettyOutput.section(
213
- "用户输入 - 使用 @ 触发文件补全,Tab 选择补全项,Ctrl+J 提交,Ctrl+O 复制最后一条消息,按 Ctrl+C 取消输入",
214
- OutputType.USER,
215
- )
216
- print(f"{Fore.GREEN}{tip}{ColoramaStyle.RESET_ALL}")
217
- # 配置键绑定
218
214
  bindings = KeyBindings()
219
215
 
220
216
  @bindings.add("enter")
221
217
  def _(event):
222
- """处理回车键以进行补全或换行。"""
223
218
  if event.current_buffer.complete_state:
224
219
  event.current_buffer.apply_completion(
225
220
  event.current_buffer.complete_state.current_completion
@@ -229,55 +224,53 @@ def get_multiline_input(tip: str) -> str:
229
224
 
230
225
  @bindings.add("c-j")
231
226
  def _(event):
232
- """处理Ctrl+J以提交输入。"""
233
227
  event.current_buffer.validate_and_handle()
234
228
 
235
229
  @bindings.add("c-o")
236
230
  def _(event):
237
- """处理Ctrl+O以复制最后一条消息到剪贴板。"""
238
- from jarvis.jarvis_utils.globals import get_last_message
239
-
240
- last_msg = get_last_message()
241
- if last_msg:
242
- print(f"{last_msg}")
243
- copy_to_clipboard(last_msg)
244
- else:
245
- PrettyOutput.print("没有可复制的消息", OutputType.INFO)
231
+ """Handle Ctrl+O by exiting the prompt and returning the sentinel value."""
232
+ event.app.exit(result=CTRL_O_SENTINEL)
233
+
234
+ style = PromptStyle.from_dict({"prompt": "ansicyan"})
235
+
236
+ history_dir = get_data_dir()
237
+ session: PromptSession = PromptSession(
238
+ history=FileHistory(os.path.join(history_dir, "multiline_input_history")),
239
+ completer=FileCompleter(),
240
+ key_bindings=bindings,
241
+ complete_while_typing=True,
242
+ multiline=True,
243
+ vi_mode=False,
244
+ mouse_support=False,
245
+ )
246
246
 
247
- event.app.invalidate()
247
+ print(f"{Fore.GREEN}{tip}{ColoramaStyle.RESET_ALL}")
248
+ prompt = FormattedText([("class:prompt", ">>> ")])
248
249
 
249
- # 配置提示会话
250
- style = PromptStyle.from_dict(
251
- {
252
- "prompt": "ansicyan",
253
- }
254
- )
255
250
  try:
256
- import os
257
-
258
- from prompt_toolkit.history import FileHistory # type: ignore
259
-
260
- from jarvis.jarvis_utils.config import get_data_dir
261
-
262
- # 获取数据目录路径
263
- history_dir = get_data_dir()
264
- # 初始化带历史记录的会话
265
- session: PromptSession = PromptSession(
266
- history=FileHistory(os.path.join(history_dir, "multiline_input_history")),
267
- completer=FileCompleter(),
268
- key_bindings=bindings,
269
- complete_while_typing=True,
270
- multiline=True,
271
- vi_mode=False,
272
- mouse_support=False,
273
- )
274
- prompt = FormattedText([("class:prompt", ">>> ")])
275
- # 获取输入
276
- text = session.prompt(
277
- prompt,
278
- style=style,
279
- ).strip()
280
- return text
281
- except KeyboardInterrupt:
282
- PrettyOutput.print("输入已取消", OutputType.INFO)
251
+ return session.prompt(prompt, style=style, pre_run=lambda: None).strip()
252
+ except (KeyboardInterrupt, EOFError):
283
253
  return ""
254
+
255
+
256
+ def get_multiline_input(tip: str) -> str:
257
+ """
258
+ 获取带有增强补全和确认功能的多行输入。
259
+ 此函数处理控制流,允许在不破坏终端状态的情况下处理历史记录复制。
260
+ """
261
+ PrettyOutput.section(
262
+ "用户输入 - 使用 @ 触发文件补全,Tab 选择补全项,Ctrl+J 提交,Ctrl+O 从历史记录中选择消息复制,按 Ctrl+C/D 取消输入",
263
+ OutputType.USER,
264
+ )
265
+
266
+ while True:
267
+ user_input = _get_multiline_input_internal(tip)
268
+
269
+ if user_input == CTRL_O_SENTINEL:
270
+ _show_history_and_copy()
271
+ tip = "请继续输入(或按Ctrl+J提交):"
272
+ continue
273
+ else:
274
+ if not user_input:
275
+ PrettyOutput.print("\n输入已取消", OutputType.INFO)
276
+ return user_input
@@ -131,7 +131,7 @@ class PrettyOutput:
131
131
  """
132
132
  try:
133
133
  lexer = guess_lexer(text)
134
- detected_lang = lexer.name
134
+ detected_lang = lexer.name # type: ignore[attr-defined]
135
135
  return PrettyOutput._lang_map.get(detected_lang, default_lang)
136
136
  except (ClassNotFound, Exception):
137
137
  return default_lang
@@ -445,6 +445,9 @@ def copy_to_clipboard(text: str) -> None:
445
445
  参数:
446
446
  text: 要复制的文本
447
447
  """
448
+ print("--- 剪贴板内容开始 ---")
449
+ print(text)
450
+ print("--- 剪贴板内容结束 ---")
448
451
  # 尝试使用 xsel
449
452
  try:
450
453
  process = subprocess.Popen(
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: jarvis-ai-assistant
3
+ Version: 0.2.3
4
+ Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
+ Home-page: https://github.com/skyfireitdiy/Jarvis
6
+ Author: skyfire
7
+ Author-email: skyfire <skyfireitdiy@hotmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 skyfire
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
30
+ Keywords: jarvis,ai,assistant,tools,automation
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: POSIX :: Linux
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Requires-Python: >=3.9,<3.13
41
+ Description-Content-Type: text/markdown
42
+ License-File: LICENSE
43
+ Requires-Dist: requests==2.32.3
44
+ Requires-Dist: colorama==0.4.6
45
+ Requires-Dist: prompt_toolkit==3.0.50
46
+ Requires-Dist: pygments==2.19.1
47
+ Requires-Dist: fuzzywuzzy==0.18.0
48
+ Requires-Dist: fastapi==0.115.12
49
+ Requires-Dist: uvicorn==0.33.0
50
+ Requires-Dist: rich==14.0.0
51
+ Requires-Dist: python-Levenshtein==0.25.1
52
+ Requires-Dist: tiktoken==0.7.0
53
+ Requires-Dist: pillow==10.2.0
54
+ Requires-Dist: openai==1.78.1
55
+ Requires-Dist: tabulate==0.9.0
56
+ Requires-Dist: pyte==0.8.2
57
+ Requires-Dist: pyyaml>=5.3.1
58
+ Requires-Dist: ddgs==9.0.2
59
+ Requires-Dist: lxml==6.0.0
60
+ Requires-Dist: markdownify>=1.1.0
61
+ Requires-Dist: typer
62
+ Requires-Dist: pathspec
63
+ Provides-Extra: dev
64
+ Requires-Dist: pytest; extra == "dev"
65
+ Requires-Dist: black; extra == "dev"
66
+ Requires-Dist: isort; extra == "dev"
67
+ Requires-Dist: mypy; extra == "dev"
68
+ Requires-Dist: build; extra == "dev"
69
+ Requires-Dist: twine; extra == "dev"
70
+ Provides-Extra: rag
71
+ Requires-Dist: langchain; extra == "rag"
72
+ Requires-Dist: langchain-community; extra == "rag"
73
+ Requires-Dist: langchain-huggingface; extra == "rag"
74
+ Requires-Dist: chromadb; extra == "rag"
75
+ Requires-Dist: diskcache; extra == "rag"
76
+ Requires-Dist: sentence-transformers==2.7.0; extra == "rag"
77
+ Requires-Dist: torch>=2.6; extra == "rag"
78
+ Requires-Dist: unstructured[md]; extra == "rag"
79
+ Requires-Dist: rank-bm25; extra == "rag"
80
+ Dynamic: author
81
+ Dynamic: home-page
82
+ Dynamic: license-file
83
+ Dynamic: requires-python
84
+
85
+ # 🤖 Jarvis AI 助手
86
+ <p align="center">
87
+ <img src="docs/images/jarvis-logo.png" alt="Jarvis Logo" width="200"/>
88
+ </p>
89
+ <div align="center">
90
+
91
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
92
+
93
+ *您的智能开发和系统交互助手*
94
+
95
+ [快速开始](#quick-start) • [核心功能](#core-features) • [配置说明](#configuration) • [Jarvis Book](#jarvis-book) • [技术细节](docs/technical_documentation.md) • [Wiki文档](docs/jarvis_book/1.项目介绍.md) • [贡献指南](#contributing) • [许可证](#license)
96
+ </div>
97
+
98
+ ---
99
+
100
+ ## 🎯 定位与优势
101
+
102
+ Jarvis 的定位是**个人开发者的高效助理**,旨在将研发流程中一次性、碎片化的工作变得更加流畅和高效。这与 `workflow` 形式的 `Agent` 平台(如 Dify)有着本质区别,专注于提升个人生产力。
103
+
104
+ ### Jarvis 的核心优势
105
+
106
+ 1. **访问本地资源**: Jarvis 能够直接与您的本地环境交互,执行诸如**软件开发、代码修复、环境搭建**等需要本地文件系统和工具链的复杂任务。
107
+ 2. **纯粹的命令行体验**: 作为一款纯命令行工具,Jarvis 可以无缝集成到您喜爱的任何IDE、终端或SSH会话中,不干扰您现有的工作流程。
108
+ 3. **Python包形式提供**: Jarvis 以标准的Python包形式分发,可以轻松地作为依赖项集成到您自己构建的AI应用或自动化脚本中。
109
+
110
+ ### 💡 Jarvis 的价值:工作流对比
111
+
112
+ #### 示例一:开发新功能
113
+
114
+ **传统工作流 (没有 Jarvis):**
115
+
116
+ 1. **理解需求**: 阅读需求文档,在代码库中全局搜索,定位可能需要修改的文件和函数。
117
+ 2. **切换上下文**: 在IDE、浏览器(查资料)、终端(执行命令)之间反复切换。
118
+ 3. **编写代码**: 手动编写新功能、单元测试和相关文档。
119
+ 4. **调试**: 反复运行、打印日志、设置断点来定位和修复bug。
120
+ 5. **代码提交**: 手动检查代码变更,撰写符合团队规范的 Git Commit Message。
121
+ > 这个过程不仅耗时,而且频繁的上下文切换极易打断心流,消耗大量精力。
122
+
123
+ **Jarvis 增强工作流:**
124
+
125
+ 1. **任务启动**: 在项目根目录,用自然语言向 `jca` (代码助理) 描述需求:`jca "为 'user' 模块增加 'profile' 接口,需要包含用户信息查询和更新功能"`。
126
+ 2. **AI 分析与编码**:
127
+ * Jarvis 自动分析代码结构,定位相关文件 (`user/service.py`, `user/controller.py`, `tests/test_user.py`)。
128
+ * 自动生成新接口的代码、必要的单元测试,并提出修改方案。
129
+ 3. **人机协作与迭代**:
130
+ * 你审查 AI 生成的代码,并提出修改意见:`"字段名需要用驼峰式"` 或 `"增加一个输入校验"`。
131
+ * Jarvis 根据反馈快速迭代,更新代码。
132
+ 4. **自动化提交**:
133
+ * 完成开发后,执行 `jgc` (Git 提交助理)。
134
+ * Jarvis 自动分析代码变更,生成一条规范的 Git Commit Message (例如: `feat(user): add user profile api with query and update`)。
135
+ > 通过 Jarvis,整个流程从“手动执行”变为了“监督和指导”,开发者可以将精力集中在**架构设计和代码审查**等高价值活动上,而不是繁琐的编码和调试细节。
136
+
137
+ #### 示例二:用 Jarvis 完善本文档
138
+
139
+ 您正在阅读的这部分文档,其诞生过程本身就是 Jarvis 价值的体现。
140
+
141
+ 1. **初始指令**: `“在README.md中补充jarvis的用户群体和应用场景等信息”`
142
+ 2. **探索与学习**: Jarvis 使用 `fd` 和 `read_code` 工具,分析了 `docs/` 目录下的说明文档,快速学习了项目的核心定位和功能。
143
+ 3. **迭代完善**: 根据 “补充用户群体”、“增加工作流对比”、“再增加一个例子” 等一系列追加指令,Jarvis 通过多次 `PATCH` 操作,逐步、精确地将新内容添加到本文档的指定位置。
144
+ 4. **人机协作**: 在整个过程中,人类提供高层次的目标和方向,Jarvis 负责具体的探索、总结和代码(文档)修改任务,将一个模糊的想法快速落地为结构清晰的文档。
145
+
146
+ ### 👥 目标用户
147
+
148
+ **谁适合使用 Jarvis?**
149
+
150
+ * **个人开发者和极客**: 希望通过AI提升个人开发、学习和探索效率的用户。
151
+ * **需要处理碎片化任务的工程师**: 面对各种一次性、非标准化的技术任务,例如快速编写脚本、调试代码、搭建新环境等。
152
+ * **AI应用探索者**: 希望有一个灵活的本地框架来实验和集成不同的大语言模型和工具。
153
+
154
+ **谁可能不适合?**
155
+
156
+ * **寻求固定工作流自动化的人**: 如果您的需求是高度固定和重复的,例如“每天定时抓取数据并生成报告”,那么编写一个专门的、功能单一的脚本可能是更直接、更高效的解决方案。Jarvis 更擅长处理多变和探索性的任务。
157
+ * **企业级团队协作者**: Jarvis 被设计为个人工具,不包含团队管理、权限控制等面向企业级协作的功能。
158
+
159
+ 总之,Jarvis 是为每一位开发者量身打造的个人助手,而非用于团队协作的集中式平台。
160
+
161
+ ---
162
+
163
+ ## 🚀 快速开始 <a id="quick-start"></a>
164
+
165
+ ### 系统要求
166
+ - **Linux**: 完全支持。
167
+ - **Windows**: 未经充分测试,建议在 [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) 中使用。
168
+
169
+ ### 安装
170
+
171
+ #### 一键安装 (推荐)
172
+ 只需一行命令即可完成所有安装和配置:
173
+ ```bash
174
+ bash -c "$(curl -fsSL https://raw.githubusercontent.com/skyfireitdiy/Jarvis/main/scripts/install.sh)"
175
+ ```
176
+ > 该脚本会自动检测Python环境、克隆项目、安装依赖并设置好路径。
177
+
178
+ #### 手动安装
179
+ ```bash
180
+ git clone https://github.com/skyfireitdiy/Jarvis
181
+ cd Jarvis
182
+ pip3 install -e .
183
+ ```
184
+ 或者从PyPI安装 (可能不是最新版):
185
+ ```bash
186
+ pip3 install jarvis-ai-assistant
187
+ ```
188
+
189
+ ### 基本使用
190
+ Jarvis 包含一系列专注于不同任务的工具。以下是主要命令及其快捷方式:
191
+
192
+ | 命令 | 快捷方式 | 功能描述 |
193
+ |------|----------|----------|
194
+ | `jarvis` | `jvs` | 通用AI代理,适用于多种任务 |
195
+ | `jarvis-code-agent` | `jca` | 专注于代码分析、修改和生成的代码代理 |
196
+ | `jarvis-git-commit` | `jgc` | 自动化分析代码变更并生成规范的Git提交信息 |
197
+ | `jarvis-platform-manager` | `jpm` | 管理和测试不同的大语言模型平台 |
198
+ | `jarvis-rag` | `jrg` | 构建和查询本地化的RAG知识库 |
199
+ | `jarvis-smart-shell` | `jss` | 实验性的智能Shell功能 |
200
+
201
+ 更多详细用法和参数,请查阅我们的 [**使用指南**](docs/jarvis_book/4.使用指南.md)。
202
+
203
+ ---
204
+
205
+ ## 🌟 核心功能 <a id="core-features"></a>
206
+
207
+ - **🆓 零成本接入**: 无缝集成腾讯元宝、Kimi等优质模型,无需支付API费用。
208
+ - **🛠️ 工具驱动**: 内置丰富工具集,涵盖脚本执行、代码开发、网页搜索、终端操作等。
209
+ - **🤖 人机协作**: 支持实时交互,用户可随时介入指导,确保AI行为符合预期。
210
+ - **🔌 高度可扩展**: 支持自定义工具、模型平台和MCP,轻松打造个性化工作流。
211
+ - **🧠 RAG 增强**: 内置RAG功能,可将本地文档作为知识库,实现精准问答。
212
+
213
+ ### 视频演示
214
+ - [使用`jca`为Jarvis快速扩展功能](https://www.bilibili.com/video/BV1TCgLzvE6Q/)
215
+ - [10分钟搭建aarch64容器化Rust开发环境](https://www.bilibili.com/video/BV1K3ghzkEzZ/)
216
+ - [`jarvis-code-agent` 功能演示](https://www.bilibili.com/video/BV1KugbzKE6U/)
217
+
218
+ ---
219
+
220
+ ## ⚙️ 配置说明 <a id="configuration"></a>
221
+
222
+ Jarvis 的主要配置文件位于 `~/.jarvis/config.yaml`。您可以在此文件中配置模型、平台和其他行为。
223
+
224
+ **基本配置示例 (腾讯元宝):**
225
+ ```yaml
226
+ # ~/.jarvis/config.yaml
227
+
228
+ # 使用的模型平台
229
+ JARVIS_PLATFORM: yuanbao
230
+ JARVIS_MODEL: deep_seek_v3
231
+
232
+ # 用于“思考”步骤的模型,通常选择能力更强的模型
233
+ JARVIS_THINKING_PLATFORM: yuanbao
234
+ JARVIS_THINKING_MODEL: deep_seek
235
+
236
+ # 平台所需的环境变量
237
+ ENV:
238
+ YUANBAO_COOKIES: "在此处粘贴您的元宝Cookies"
239
+ ```
240
+
241
+ Jarvis 支持多种平台,包括 **Kimi**, **通义千问**, **OpenAI** 等。详细的配置选项、模型组设置以及所有可用参数,请参阅 [**使用指南**](docs/jarvis_book/4.使用指南.md)。
242
+
243
+ > **模型推荐**: 目前效果最好的模型是 `gemini-1.5-pro`,可以通过国内代理商购买,例如 [FoxiAI](https://foxi-ai.top)。
244
+
245
+ ---
246
+
247
+ ## 🛠️ 扩展开发 <a id="extensions"></a>
248
+
249
+ Jarvis 被设计为高度可扩展的框架。您可以轻松地:
250
+ - **添加新工具**: 在 `~/.jarvis/tools/` 目录下创建新的工具实现。
251
+ - **集成新LLM平台**: 在 `~/.jarvis/platforms/` 目录下添加新的平台适配器。
252
+ - **定义MCP**: 通过配置文件集成外部或自定义的命令协议。
253
+
254
+ 有关扩展开发的详细指南和[**技术细节**](docs/technical_documentation.md),请访问我们的 [**开发者文档**](docs/jarvis_book/5.功能扩展.md)。
255
+
256
+ ---
257
+
258
+ ## 📖 Jarvis Book <a id="jarvis-book"></a>
259
+
260
+ 欢迎阅读 Jarvis 的官方文档,这本开源书籍旨在为您提供从入门到精通的全方位指南。
261
+
262
+ - **[第一章:项目介绍](docs/jarvis_book/1.项目介绍.md)**
263
+ - **[第二章:快速开始](docs/jarvis_book/2.快速开始.md)**
264
+ - **[第三章:核心概念与架构](docs/jarvis_book/3.核心概念与架构.md)**
265
+ - **[第四章:使用指南](docs/jarvis_book/4.使用指南.md)**
266
+ - **[第五章:功能扩展](docs/jarvis_book/5.功能扩展.md)**
267
+ - **[第六章:高级主题](docs/jarvis_book/6.高级主题.md)**
268
+ - **[第七章:参与贡献](docs/jarvis_book/7.参与贡献.md)**
269
+ - **[第八章:常见问题](docs/jarvis_book/8.常见问题.md)**
270
+ - **[第九章:附录](docs/jarvis_book/9.附录.md)**
271
+
272
+ ---
273
+
274
+ ## 🤝 贡献指南 <a id="contributing"></a>
275
+
276
+ 我们欢迎任何形式的贡献!
277
+ 1. Fork 本仓库
278
+ 2. 创建您的特性分支 (`git checkout -b feature/AmazingFeature`)
279
+ 3. 提交您的更改 (`git commit -m 'Add some AmazingFeature'`)
280
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
281
+ 5. 开启一个 Pull Request
282
+
283
+ ---
284
+
285
+ ## ⚠️ 免责声明 <a id="disclaimer"></a>
286
+
287
+ - **模型使用风险**: 频繁使用通过非官方API(如腾讯元宝、Kimi、通义千问等)接入的模型可能会导致您的账户被平台封禁。请合理使用,并自行承担相应风险。
288
+ - **命令执行风险**: Jarvis具备执行系统命令的能力。请确保您了解将要执行的命令,并避免输入可能导致系统风险的指令。为了增强安全性,您可以在配置文件中启用工具执行确认(`JARVIS_EXECUTE_TOOL_CONFIRM: true`),以便在执行每个工具前进行手动确认。
289
+
290
+ ---
291
+
292
+ ## 📄 许可证 <a id="license"></a>
293
+
294
+ 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。
295
+
296
+ ---
297
+ <div align="center">
298
+ 由 Jarvis 团队用 ❤️ 制作
299
+ </div>
300
+
301
+ ![Jarvis技术支持群](docs/images/wechat.png)