jarvis-ai-assistant 0.1.13__py3-none-any.whl → 0.1.15__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.
- jarvis/__init__.py +1 -1
- jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/__pycache__/main.cpython-313.pyc +0 -0
- jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- jarvis/main.py +35 -20
- jarvis/utils.py +40 -22
- jarvis_ai_assistant-0.1.15.dist-info/LICENSE +21 -0
- {jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/METADATA +24 -1
- {jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/RECORD +12 -11
- {jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
jarvis/main.py
CHANGED
|
@@ -17,28 +17,43 @@ from jarvis.utils import PrettyOutput, OutputType, get_multiline_input, load_env
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def load_tasks() -> dict:
|
|
20
|
-
"""Load tasks from .jarvis
|
|
21
|
-
|
|
22
|
-
return {}
|
|
20
|
+
"""Load tasks from .jarvis files in user home and current directory."""
|
|
21
|
+
tasks = {}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return {}
|
|
31
|
-
|
|
32
|
-
# Validate format and convert all values to strings
|
|
33
|
-
validated_tasks = {}
|
|
34
|
-
for name, desc in tasks.items():
|
|
35
|
-
if desc: # Ensure description is not empty
|
|
36
|
-
validated_tasks[str(name)] = str(desc)
|
|
23
|
+
# 检查用户目录下的 .jarvis
|
|
24
|
+
user_jarvis = os.path.expanduser("~/.jarvis")
|
|
25
|
+
if os.path.exists(user_jarvis):
|
|
26
|
+
try:
|
|
27
|
+
with open(user_jarvis, "r", encoding="utf-8") as f:
|
|
28
|
+
user_tasks = yaml.safe_load(f)
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
if isinstance(user_tasks, dict):
|
|
31
|
+
# 验证并添加用户目录的任务
|
|
32
|
+
for name, desc in user_tasks.items():
|
|
33
|
+
if desc: # 确保描述不为空
|
|
34
|
+
tasks[str(name)] = str(desc)
|
|
35
|
+
else:
|
|
36
|
+
PrettyOutput.print("Warning: ~/.jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
37
|
+
except Exception as e:
|
|
38
|
+
PrettyOutput.print(f"Error loading ~/.jarvis file: {str(e)}", OutputType.ERROR)
|
|
39
|
+
|
|
40
|
+
# 检查当前目录下的 .jarvis
|
|
41
|
+
if os.path.exists(".jarvis"):
|
|
42
|
+
try:
|
|
43
|
+
with open(".jarvis", "r", encoding="utf-8") as f:
|
|
44
|
+
local_tasks = yaml.safe_load(f)
|
|
45
|
+
|
|
46
|
+
if isinstance(local_tasks, dict):
|
|
47
|
+
# 验证并添加当前目录的任务,如果有重名则覆盖用户目录的任务
|
|
48
|
+
for name, desc in local_tasks.items():
|
|
49
|
+
if desc: # 确保描述不为空
|
|
50
|
+
tasks[str(name)] = str(desc)
|
|
51
|
+
else:
|
|
52
|
+
PrettyOutput.print("Warning: .jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
53
|
+
except Exception as e:
|
|
54
|
+
PrettyOutput.print(f"Error loading .jarvis file: {str(e)}", OutputType.ERROR)
|
|
55
|
+
|
|
56
|
+
return tasks
|
|
42
57
|
|
|
43
58
|
def select_task(tasks: dict) -> str:
|
|
44
59
|
"""Let user select a task from the list or skip. Returns task description if selected."""
|
jarvis/utils.py
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import sys
|
|
3
3
|
import time
|
|
4
|
+
import os
|
|
4
5
|
from typing import Dict, Optional
|
|
5
6
|
from enum import Enum
|
|
6
7
|
from datetime import datetime
|
|
7
8
|
import colorama
|
|
8
|
-
from colorama import Fore, Style
|
|
9
|
-
import
|
|
9
|
+
from colorama import Fore, Style as ColoramaStyle
|
|
10
|
+
from prompt_toolkit import PromptSession
|
|
11
|
+
from prompt_toolkit.styles import Style as PromptStyle
|
|
12
|
+
from prompt_toolkit.formatted_text import FormattedText
|
|
10
13
|
|
|
11
14
|
# 初始化colorama
|
|
12
15
|
colorama.init()
|
|
@@ -84,10 +87,10 @@ class PrettyOutput:
|
|
|
84
87
|
prefix = PrettyOutput.PREFIXES.get(output_type, "")
|
|
85
88
|
|
|
86
89
|
# 添加时间戳 - 使用白色
|
|
87
|
-
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{
|
|
90
|
+
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{ColoramaStyle.RESET_ALL} " if timestamp else ""
|
|
88
91
|
|
|
89
92
|
# 格式化输出
|
|
90
|
-
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{
|
|
93
|
+
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{ColoramaStyle.RESET_ALL}"
|
|
91
94
|
|
|
92
95
|
return formatted_text
|
|
93
96
|
|
|
@@ -101,15 +104,15 @@ class PrettyOutput:
|
|
|
101
104
|
"""打印带分隔线的段落标题"""
|
|
102
105
|
width = 60
|
|
103
106
|
color = PrettyOutput.COLORS.get(output_type, "")
|
|
104
|
-
print(f"\n{color}" + "=" * width + f"{
|
|
107
|
+
print(f"\n{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}")
|
|
105
108
|
PrettyOutput.print(title.center(width - 10), output_type, timestamp=False)
|
|
106
|
-
print(f"{color}" + "=" * width + f"{
|
|
109
|
+
print(f"{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}\n")
|
|
107
110
|
|
|
108
111
|
@staticmethod
|
|
109
112
|
def print_stream(text: str, output_type: OutputType):
|
|
110
113
|
"""打印流式输出,不换行"""
|
|
111
114
|
color = PrettyOutput.COLORS.get(output_type, "")
|
|
112
|
-
sys.stdout.write(f"{color}{text}{
|
|
115
|
+
sys.stdout.write(f"{color}{text}{ColoramaStyle.RESET_ALL}")
|
|
113
116
|
sys.stdout.flush()
|
|
114
117
|
|
|
115
118
|
@staticmethod
|
|
@@ -119,29 +122,44 @@ class PrettyOutput:
|
|
|
119
122
|
sys.stdout.flush()
|
|
120
123
|
|
|
121
124
|
def get_multiline_input(tip: str) -> str:
|
|
122
|
-
"""
|
|
125
|
+
"""获取多行输入,支持方向键、历史记录等功能"""
|
|
123
126
|
PrettyOutput.print(tip + "\n", OutputType.INFO)
|
|
124
|
-
lines = []
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
# 创建输入会话,启用历史记录
|
|
129
|
+
session = PromptSession(history=None) # 使用默认历史记录
|
|
130
|
+
|
|
131
|
+
# 定义提示符样式
|
|
132
|
+
style = PromptStyle.from_dict({
|
|
133
|
+
'prompt': 'ansicyan',
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
lines = []
|
|
137
|
+
try:
|
|
138
|
+
while True:
|
|
139
|
+
# 设置提示符
|
|
140
|
+
prompt = FormattedText([
|
|
141
|
+
('class:prompt', '... ' if lines else '>>> ')
|
|
142
|
+
])
|
|
131
143
|
|
|
132
|
-
|
|
144
|
+
# 获取输入
|
|
145
|
+
line = session.prompt(
|
|
146
|
+
prompt,
|
|
147
|
+
style=style,
|
|
148
|
+
).strip()
|
|
149
|
+
|
|
150
|
+
# 空行处理
|
|
133
151
|
if not line:
|
|
134
|
-
if not lines: #
|
|
152
|
+
if not lines: # 第一行就输入空行
|
|
135
153
|
return ""
|
|
136
|
-
break
|
|
137
|
-
|
|
154
|
+
break # 结束多行输入
|
|
155
|
+
|
|
138
156
|
lines.append(line)
|
|
139
157
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
except KeyboardInterrupt:
|
|
159
|
+
PrettyOutput.print("\n输入已取消", OutputType.ERROR)
|
|
160
|
+
return "__interrupt__"
|
|
143
161
|
|
|
144
|
-
return "\n".join(lines)
|
|
162
|
+
return "\n".join(lines)
|
|
145
163
|
|
|
146
164
|
def load_env_from_file():
|
|
147
165
|
"""从~/.jarvis_env加载环境变量"""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 skyfire
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: Jarvis: An AI assistant that uses tools to interact with the system
|
|
5
5
|
Home-page: https://github.com/skyfireitdiy/Jarvis
|
|
6
6
|
Author: skyfire
|
|
7
7
|
Author-email: Your Name <your.email@example.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.
|
|
8
29
|
Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
|
|
9
30
|
Keywords: jarvis,ai,assistant,tools,automation
|
|
10
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -16,9 +37,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
37
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
38
|
Requires-Python: >=3.8
|
|
18
39
|
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
19
41
|
Requires-Dist: requests>=2.25.1
|
|
20
42
|
Requires-Dist: pyyaml>=5.1
|
|
21
43
|
Requires-Dist: colorama>=0.4.6
|
|
44
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
|
22
45
|
Provides-Extra: dev
|
|
23
46
|
Requires-Dist: pytest; extra == "dev"
|
|
24
47
|
Requires-Dist: black; extra == "dev"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
jarvis/__init__.py,sha256=
|
|
1
|
+
jarvis/__init__.py,sha256=niTr-MJKWue4qLJei1KCeCXRCTZSNmqWYycm5EuGUn8,50
|
|
2
2
|
jarvis/agent.py,sha256=xo5YdY8UbgE3AJaitT1dXoNoVm769LrWyFzEXxVCG7A,8672
|
|
3
|
-
jarvis/main.py,sha256=
|
|
4
|
-
jarvis/utils.py,sha256=
|
|
5
|
-
jarvis/__pycache__/__init__.cpython-313.pyc,sha256=
|
|
3
|
+
jarvis/main.py,sha256=QD8FlhpJ-PFUEOjt77gllpHEgqtfNKV_S8NQZSWRTbE,6760
|
|
4
|
+
jarvis/utils.py,sha256=YipQpEuIRwFE3y3YrgGlSVLEPDrlbBNY1gRiOJix9DU,6602
|
|
5
|
+
jarvis/__pycache__/__init__.cpython-313.pyc,sha256=IBHd-4iRW_kLVUo4GAMIjwiDzO7BYWfUAvxmj_Tx71g,209
|
|
6
6
|
jarvis/__pycache__/agent.cpython-313.pyc,sha256=DP0zgyKjGuwc62rH_vpoy_hXmGMI3zoHPlXZYu0qqp4,9956
|
|
7
|
-
jarvis/__pycache__/main.cpython-313.pyc,sha256=
|
|
7
|
+
jarvis/__pycache__/main.cpython-313.pyc,sha256=vsL4l0JZFp805S22a0uZR_9k6NhpHrb-YHFY61JXF4M,9279
|
|
8
8
|
jarvis/__pycache__/models.cpython-313.pyc,sha256=uWuRIjGrY4YDB3dGW5PGDLWaS03et8g11O725TjY_eU,5960
|
|
9
9
|
jarvis/__pycache__/tools.cpython-313.pyc,sha256=lAD4LrnnWzNZQmHXGfZ_2l7oskOpr2_2OC-gdFhxQY8,33933
|
|
10
|
-
jarvis/__pycache__/utils.cpython-313.pyc,sha256=
|
|
10
|
+
jarvis/__pycache__/utils.cpython-313.pyc,sha256=Jpkf2GOA1d_fgrRftqZch1yiO0mB75LWHzQk8IfhHRU,8977
|
|
11
11
|
jarvis/__pycache__/zte_llm.cpython-313.pyc,sha256=kMm9IGundGmOPqjsgrm9oIaWLDagYGCPRAaE3ipkc-0,5662
|
|
12
12
|
jarvis/models/__init__.py,sha256=B_IJFvKTaxdg19FAD1ea288tYp3-bRYRpkeGI0_OcBI,262
|
|
13
13
|
jarvis/models/base.py,sha256=GgVl5N0qDqn-yqRcX_PX3wHjogouE6GPFAWktG40cXg,403
|
|
@@ -32,8 +32,9 @@ jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc,sha256=wK3Ev10lHSUSRv
|
|
|
32
32
|
jarvis/tools/__pycache__/user_input.cpython-313.pyc,sha256=JjTFOhObKsKF4Pn8KBRuKfV1_Ssj083fjU7Mfc_5z7c,2531
|
|
33
33
|
jarvis/tools/__pycache__/user_interaction.cpython-313.pyc,sha256=RuVZ-pmiPBDywY3efgXSfohMAciC1avMGPmBK5qlnew,3305
|
|
34
34
|
jarvis/tools/__pycache__/webpage.cpython-313.pyc,sha256=BjzSfnNzsKCrLETCcWjt32lNDLzwnjqcVGg4JfWd9OM,3008
|
|
35
|
-
jarvis_ai_assistant-0.1.
|
|
36
|
-
jarvis_ai_assistant-0.1.
|
|
37
|
-
jarvis_ai_assistant-0.1.
|
|
38
|
-
jarvis_ai_assistant-0.1.
|
|
39
|
-
jarvis_ai_assistant-0.1.
|
|
35
|
+
jarvis_ai_assistant-0.1.15.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
36
|
+
jarvis_ai_assistant-0.1.15.dist-info/METADATA,sha256=ol6VL7pVkPjG5nS3zCBfKG2gPG8OmrsxE2KegW7PILs,6525
|
|
37
|
+
jarvis_ai_assistant-0.1.15.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
38
|
+
jarvis_ai_assistant-0.1.15.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
|
|
39
|
+
jarvis_ai_assistant-0.1.15.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
40
|
+
jarvis_ai_assistant-0.1.15.dist-info/RECORD,,
|
|
File without changes
|
{jarvis_ai_assistant-0.1.13.dist-info → jarvis_ai_assistant-0.1.15.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|