jarvis-ai-assistant 0.3.30__py3-none-any.whl → 0.7.6__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +458 -152
- jarvis/jarvis_agent/agent_manager.py +17 -13
- jarvis/jarvis_agent/builtin_input_handler.py +2 -6
- jarvis/jarvis_agent/config_editor.py +2 -7
- jarvis/jarvis_agent/event_bus.py +82 -12
- jarvis/jarvis_agent/file_context_handler.py +329 -0
- jarvis/jarvis_agent/file_methodology_manager.py +3 -4
- jarvis/jarvis_agent/jarvis.py +628 -55
- jarvis/jarvis_agent/language_extractors/__init__.py +57 -0
- jarvis/jarvis_agent/language_extractors/c_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/cpp_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/go_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/java_extractor.py +84 -0
- jarvis/jarvis_agent/language_extractors/javascript_extractor.py +79 -0
- jarvis/jarvis_agent/language_extractors/python_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/rust_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/typescript_extractor.py +84 -0
- jarvis/jarvis_agent/language_support_info.py +486 -0
- jarvis/jarvis_agent/main.py +34 -10
- jarvis/jarvis_agent/memory_manager.py +7 -16
- jarvis/jarvis_agent/methodology_share_manager.py +10 -16
- jarvis/jarvis_agent/prompt_manager.py +1 -1
- jarvis/jarvis_agent/prompts.py +193 -171
- jarvis/jarvis_agent/protocols.py +8 -12
- jarvis/jarvis_agent/run_loop.py +105 -9
- jarvis/jarvis_agent/session_manager.py +2 -3
- jarvis/jarvis_agent/share_manager.py +20 -22
- jarvis/jarvis_agent/shell_input_handler.py +1 -2
- jarvis/jarvis_agent/stdio_redirect.py +295 -0
- jarvis/jarvis_agent/task_analyzer.py +31 -6
- jarvis/jarvis_agent/task_manager.py +11 -27
- jarvis/jarvis_agent/tool_executor.py +2 -3
- jarvis/jarvis_agent/tool_share_manager.py +12 -24
- jarvis/jarvis_agent/utils.py +5 -1
- jarvis/jarvis_agent/web_bridge.py +189 -0
- jarvis/jarvis_agent/web_output_sink.py +53 -0
- jarvis/jarvis_agent/web_server.py +786 -0
- jarvis/jarvis_c2rust/__init__.py +26 -0
- jarvis/jarvis_c2rust/cli.py +575 -0
- jarvis/jarvis_c2rust/collector.py +250 -0
- jarvis/jarvis_c2rust/constants.py +26 -0
- jarvis/jarvis_c2rust/library_replacer.py +1254 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +1272 -0
- jarvis/jarvis_c2rust/loaders.py +207 -0
- jarvis/jarvis_c2rust/models.py +28 -0
- jarvis/jarvis_c2rust/optimizer.py +2157 -0
- jarvis/jarvis_c2rust/scanner.py +1681 -0
- jarvis/jarvis_c2rust/transpiler.py +2983 -0
- jarvis/jarvis_c2rust/utils.py +385 -0
- jarvis/jarvis_code_agent/build_validation_config.py +132 -0
- jarvis/jarvis_code_agent/code_agent.py +1371 -220
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +65 -0
- jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +106 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +72 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +70 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +53 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +47 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +61 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +154 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +153 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +648 -0
- jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
- jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
- jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
- jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
- jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +49 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +299 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +215 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +269 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +281 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +605 -0
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +252 -0
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +58 -0
- jarvis/jarvis_code_agent/lint.py +501 -8
- jarvis/jarvis_code_agent/utils.py +141 -0
- jarvis/jarvis_code_analysis/code_review.py +493 -584
- jarvis/jarvis_data/config_schema.json +128 -12
- jarvis/jarvis_git_squash/main.py +4 -5
- jarvis/jarvis_git_utils/git_commiter.py +82 -75
- jarvis/jarvis_mcp/sse_mcp_client.py +22 -29
- jarvis/jarvis_mcp/stdio_mcp_client.py +12 -13
- jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
- jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
- jarvis/jarvis_methodology/main.py +32 -48
- jarvis/jarvis_multi_agent/__init__.py +287 -55
- jarvis/jarvis_multi_agent/main.py +36 -4
- jarvis/jarvis_platform/base.py +524 -202
- jarvis/jarvis_platform/human.py +7 -8
- jarvis/jarvis_platform/kimi.py +30 -36
- jarvis/jarvis_platform/openai.py +88 -25
- jarvis/jarvis_platform/registry.py +26 -10
- jarvis/jarvis_platform/tongyi.py +24 -25
- jarvis/jarvis_platform/yuanbao.py +32 -43
- jarvis/jarvis_platform_manager/main.py +66 -77
- jarvis/jarvis_platform_manager/service.py +8 -13
- jarvis/jarvis_rag/cli.py +53 -55
- jarvis/jarvis_rag/embedding_manager.py +13 -18
- jarvis/jarvis_rag/llm_interface.py +8 -9
- jarvis/jarvis_rag/query_rewriter.py +10 -21
- jarvis/jarvis_rag/rag_pipeline.py +24 -27
- jarvis/jarvis_rag/reranker.py +4 -5
- jarvis/jarvis_rag/retriever.py +28 -30
- jarvis/jarvis_sec/__init__.py +305 -0
- jarvis/jarvis_sec/agents.py +143 -0
- jarvis/jarvis_sec/analysis.py +276 -0
- jarvis/jarvis_sec/checkers/__init__.py +32 -0
- jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
- jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
- jarvis/jarvis_sec/cli.py +139 -0
- jarvis/jarvis_sec/clustering.py +1439 -0
- jarvis/jarvis_sec/file_manager.py +427 -0
- jarvis/jarvis_sec/parsers.py +73 -0
- jarvis/jarvis_sec/prompts.py +268 -0
- jarvis/jarvis_sec/report.py +336 -0
- jarvis/jarvis_sec/review.py +453 -0
- jarvis/jarvis_sec/status.py +264 -0
- jarvis/jarvis_sec/types.py +20 -0
- jarvis/jarvis_sec/utils.py +499 -0
- jarvis/jarvis_sec/verification.py +848 -0
- jarvis/jarvis_sec/workflow.py +226 -0
- jarvis/jarvis_smart_shell/main.py +38 -87
- jarvis/jarvis_stats/cli.py +2 -2
- jarvis/jarvis_stats/stats.py +8 -8
- jarvis/jarvis_stats/storage.py +15 -21
- jarvis/jarvis_stats/visualizer.py +1 -1
- jarvis/jarvis_tools/clear_memory.py +3 -20
- jarvis/jarvis_tools/cli/main.py +21 -23
- jarvis/jarvis_tools/edit_file.py +1019 -132
- jarvis/jarvis_tools/execute_script.py +83 -25
- jarvis/jarvis_tools/file_analyzer.py +6 -9
- jarvis/jarvis_tools/generate_new_tool.py +14 -21
- jarvis/jarvis_tools/lsp_client.py +1552 -0
- jarvis/jarvis_tools/methodology.py +2 -3
- jarvis/jarvis_tools/read_code.py +1736 -35
- jarvis/jarvis_tools/read_symbols.py +140 -0
- jarvis/jarvis_tools/read_webpage.py +12 -13
- jarvis/jarvis_tools/registry.py +427 -200
- jarvis/jarvis_tools/retrieve_memory.py +20 -19
- jarvis/jarvis_tools/rewrite_file.py +72 -158
- jarvis/jarvis_tools/save_memory.py +3 -15
- jarvis/jarvis_tools/search_web.py +18 -18
- jarvis/jarvis_tools/sub_agent.py +36 -43
- jarvis/jarvis_tools/sub_code_agent.py +25 -26
- jarvis/jarvis_tools/virtual_tty.py +55 -33
- jarvis/jarvis_utils/clipboard.py +7 -10
- jarvis/jarvis_utils/config.py +232 -45
- jarvis/jarvis_utils/embedding.py +8 -5
- jarvis/jarvis_utils/fzf.py +8 -8
- jarvis/jarvis_utils/git_utils.py +225 -36
- jarvis/jarvis_utils/globals.py +3 -3
- jarvis/jarvis_utils/http.py +1 -1
- jarvis/jarvis_utils/input.py +99 -48
- jarvis/jarvis_utils/jsonnet_compat.py +465 -0
- jarvis/jarvis_utils/methodology.py +52 -48
- jarvis/jarvis_utils/utils.py +819 -491
- jarvis_ai_assistant-0.7.6.dist-info/METADATA +600 -0
- jarvis_ai_assistant-0.7.6.dist-info/RECORD +218 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/entry_points.txt +4 -0
- jarvis/jarvis_agent/config.py +0 -92
- jarvis/jarvis_agent/edit_file_handler.py +0 -296
- jarvis/jarvis_platform/ai8.py +0 -332
- jarvis/jarvis_tools/ask_user.py +0 -54
- jarvis_ai_assistant-0.3.30.dist-info/METADATA +0 -381
- jarvis_ai_assistant-0.3.30.dist-info/RECORD +0 -137
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/top_level.txt +0 -0
jarvis/jarvis_sec/cli.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Jarvis 安全演进套件 —— 命令行入口(Typer 版本)
|
|
4
|
+
|
|
5
|
+
用法示例:
|
|
6
|
+
- Agent模式(单Agent,逐条子任务分析)
|
|
7
|
+
python -m jarvis.jarvis_sec.cli agent --path ./target_project
|
|
8
|
+
python -m jarvis.jarvis_sec.cli agent # 默认分析当前目录
|
|
9
|
+
|
|
10
|
+
可选参数:
|
|
11
|
+
|
|
12
|
+
- --path, -p: 待分析的根目录(默认当前目录)
|
|
13
|
+
- --output, -o: 最终报告输出路径(默认 ./report.md)。如果后缀为 .csv,则输出 CSV 格式;否则输出 Markdown 格式
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Optional
|
|
21
|
+
|
|
22
|
+
import typer
|
|
23
|
+
from jarvis.jarvis_utils.utils import init_env
|
|
24
|
+
# removed: set_config import(避免全局覆盖模型组配置)
|
|
25
|
+
from jarvis.jarvis_sec.workflow import run_with_agent, direct_scan, format_markdown_report as format_markdown_report_workflow
|
|
26
|
+
from jarvis.jarvis_sec.report import format_csv_report, aggregate_issues
|
|
27
|
+
|
|
28
|
+
app = typer.Typer(
|
|
29
|
+
add_completion=False,
|
|
30
|
+
no_args_is_help=True,
|
|
31
|
+
help="Jarvis 安全演进套件(单Agent逐条子任务分析)",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@app.command("agent", help="Agent模式(单Agent逐条子任务分析)")
|
|
38
|
+
def agent(
|
|
39
|
+
path: str = typer.Option(".", "--path", "-p", help="待分析的根目录(默认当前目录)"),
|
|
40
|
+
|
|
41
|
+
llm_group: Optional[str] = typer.Option(
|
|
42
|
+
None, "--llm-group", "-g", help="使用的模型组(仅对本次运行生效,不修改全局配置)"
|
|
43
|
+
),
|
|
44
|
+
output: Optional[str] = typer.Option(
|
|
45
|
+
"report.md", "--output", "-o", help="最终报告输出路径(默认 ./report.md)。如果后缀为 .csv,则输出 CSV 格式;否则输出 Markdown 格式"
|
|
46
|
+
),
|
|
47
|
+
|
|
48
|
+
cluster_limit: int = typer.Option(
|
|
49
|
+
50, "--cluster-limit", "-c", help="聚类每批最多处理的告警数(按文件分批聚类,默认50)"
|
|
50
|
+
),
|
|
51
|
+
enable_verification: bool = typer.Option(
|
|
52
|
+
True, "--enable-verification/--no-verification", help="是否启用二次验证(默认开启)"
|
|
53
|
+
),
|
|
54
|
+
force_save_memory: bool = typer.Option(
|
|
55
|
+
False, "--force-save-memory/--no-force-save-memory", help="强制使用记忆(默认关闭)"
|
|
56
|
+
),
|
|
57
|
+
) -> None:
|
|
58
|
+
# 初始化环境,确保平台/模型等全局配置就绪(避免 NoneType 平台)
|
|
59
|
+
try:
|
|
60
|
+
init_env()
|
|
61
|
+
except Exception:
|
|
62
|
+
# 环境初始化失败不应阻塞CLI基础功能,继续后续流程
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
# 若指定了模型组:仅对本次运行生效,透传给 Agent;不修改全局配置(无需 set_config)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
text: Optional[str] = None
|
|
69
|
+
try:
|
|
70
|
+
text = run_with_agent(
|
|
71
|
+
path,
|
|
72
|
+
llm_group=llm_group,
|
|
73
|
+
cluster_limit=cluster_limit,
|
|
74
|
+
enable_verification=enable_verification,
|
|
75
|
+
force_save_memory=force_save_memory,
|
|
76
|
+
output_file=output,
|
|
77
|
+
)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
try:
|
|
80
|
+
typer.secho(f"[jarvis_sec] Agent 分析过程出错,将回退到直扫基线(fast):{e}", fg=typer.colors.YELLOW, err=True)
|
|
81
|
+
except Exception:
|
|
82
|
+
pass
|
|
83
|
+
text = None
|
|
84
|
+
|
|
85
|
+
if not text or not str(text).strip():
|
|
86
|
+
try:
|
|
87
|
+
typer.secho("[jarvis_sec] Agent 无输出,回退到直扫基线(fast)。", fg=typer.colors.YELLOW, err=True)
|
|
88
|
+
except Exception:
|
|
89
|
+
pass
|
|
90
|
+
result = direct_scan(path)
|
|
91
|
+
# 根据输出文件后缀选择格式
|
|
92
|
+
if output and output.lower().endswith('.csv'):
|
|
93
|
+
# 使用 report.py 中的函数来格式化 CSV
|
|
94
|
+
report_json = aggregate_issues(
|
|
95
|
+
result.get("issues", []),
|
|
96
|
+
scanned_root=result.get("summary", {}).get("scanned_root"),
|
|
97
|
+
scanned_files=result.get("summary", {}).get("scanned_files"),
|
|
98
|
+
)
|
|
99
|
+
text = format_csv_report(report_json)
|
|
100
|
+
else:
|
|
101
|
+
# 使用 workflow.py 中的 format_markdown_report(与 direct_scan 返回结构匹配)
|
|
102
|
+
text = format_markdown_report_workflow(result)
|
|
103
|
+
|
|
104
|
+
if output:
|
|
105
|
+
try:
|
|
106
|
+
md_text = text or ""
|
|
107
|
+
try:
|
|
108
|
+
lines = (text or "").splitlines()
|
|
109
|
+
idx = -1
|
|
110
|
+
for i, ln in enumerate(lines):
|
|
111
|
+
if ln.strip().startswith("# Jarvis 安全问题分析报告"):
|
|
112
|
+
idx = i
|
|
113
|
+
break
|
|
114
|
+
if idx >= 0:
|
|
115
|
+
md_text = "\n".join(lines[idx:])
|
|
116
|
+
except Exception:
|
|
117
|
+
md_text = text or ""
|
|
118
|
+
p = Path(output)
|
|
119
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
p.write_text(md_text, encoding="utf-8")
|
|
121
|
+
try:
|
|
122
|
+
typer.secho(f"[jarvis_sec] Markdown 报告已写入: {p}", fg=typer.colors.GREEN)
|
|
123
|
+
except Exception:
|
|
124
|
+
pass
|
|
125
|
+
except Exception as e:
|
|
126
|
+
try:
|
|
127
|
+
typer.secho(f"[jarvis_sec] 写入Markdown报告失败: {e}", fg=typer.colors.RED, err=True)
|
|
128
|
+
except Exception:
|
|
129
|
+
pass
|
|
130
|
+
typer.echo(text)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def main() -> int:
|
|
134
|
+
app()
|
|
135
|
+
return 0
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
sys.exit(main())
|