claude-autosar 0.3.0__tar.gz
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.
- claude_autosar-0.3.0/LICENSE +21 -0
- claude_autosar-0.3.0/PKG-INFO +145 -0
- claude_autosar-0.3.0/README.md +99 -0
- claude_autosar-0.3.0/pyproject.toml +67 -0
- claude_autosar-0.3.0/setup.cfg +4 -0
- claude_autosar-0.3.0/src/claude_autosar/__init__.py +15 -0
- claude_autosar-0.3.0/src/claude_autosar/__main__.py +6 -0
- claude_autosar-0.3.0/src/claude_autosar/adapters/__init__.py +7 -0
- claude_autosar-0.3.0/src/claude_autosar/adapters/davinci.py +161 -0
- claude_autosar-0.3.0/src/claude_autosar/adapters/protocol.py +164 -0
- claude_autosar-0.3.0/src/claude_autosar/adapters/stub.py +123 -0
- claude_autosar-0.3.0/src/claude_autosar/adapters/tresos.py +329 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/__init__.py +1 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/__init__.py +1 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/arxml_apply_template.py +327 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/arxml_inspect.py +101 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/bsw_inspect.py +127 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/bsw_verify.py +109 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/davinci.py +240 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/eb.py +299 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/export.py +91 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/init.py +469 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/lint.py +332 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/log.py +82 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/session.py +152 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/xdm_apply_template.py +314 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/commands/xdm_inspect.py +100 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/main.py +158 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/mcp_server.py +1368 -0
- claude_autosar-0.3.0/src/claude_autosar/cli/repl_skin.py +221 -0
- claude_autosar-0.3.0/src/claude_autosar/core/__init__.py +1 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/__init__.py +6 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/arxml_io.py +463 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/bsw_write_path.py +427 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/bswmd.py +764 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/config.py +209 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/dispatcher.py +244 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/ecuc.py +360 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/inspector/__init__.py +40 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/inspector/arxml_report.py +783 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/inspector/xdm_report.py +543 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/io/__init__.py +23 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/io/datamodel2_io.py +648 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/__init__.py +199 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/extract.py +184 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/__init__.py +80 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/__init__.py +3 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/canif_ap_007.py +53 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/canif_ap_008.py +51 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/com_ap_001.py +64 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/com_ap_002.py +49 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/ecum_ap_001.py +47 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/ecum_ap_003.py +47 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/gen_ap_002.py +46 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/arxml_rules/nm_ap_001.py +46 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/xdm_rules/__init__.py +3 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/xdm_rules/dem_ap_001.py +52 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/rules/xdm_rules/dem_ap_004.py +55 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/lint/runner.py +160 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/path_resolver.py +103 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/schemas.py +121 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/templates/__init__.py +56 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/templates/apply.py +449 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/templates/arxml_diff.py +173 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/templates/xdm_diff.py +158 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/templates/xdm_value.py +243 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/validator.py +285 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/verify/__init__.py +31 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/verify/report_section.py +204 -0
- claude_autosar-0.3.0/src/claude_autosar/core/bsw/verify/tresos_parser.py +300 -0
- claude_autosar-0.3.0/src/claude_autosar/core/config/__init__.py +1 -0
- claude_autosar-0.3.0/src/claude_autosar/core/config/project_config.py +442 -0
- claude_autosar-0.3.0/src/claude_autosar/core/log/__init__.py +5 -0
- claude_autosar-0.3.0/src/claude_autosar/core/log/changelog.py +108 -0
- claude_autosar-0.3.0/src/claude_autosar/core/session/__init__.py +7 -0
- claude_autosar-0.3.0/src/claude_autosar/core/session/exporter.py +135 -0
- claude_autosar-0.3.0/src/claude_autosar/core/session/recorder.py +158 -0
- claude_autosar-0.3.0/src/claude_autosar/core/session/store.py +166 -0
- claude_autosar-0.3.0/src/claude_autosar/core/session/tree.py +125 -0
- claude_autosar-0.3.0/src/claude_autosar/core/settings/__init__.py +1 -0
- claude_autosar-0.3.0/src/claude_autosar/core/settings/config.py +76 -0
- claude_autosar-0.3.0/src/claude_autosar/core/settings/v2_paths.py +414 -0
- claude_autosar-0.3.0/src/claude_autosar/py.typed +0 -0
- claude_autosar-0.3.0/src/claude_autosar/utils/__init__.py +13 -0
- claude_autosar-0.3.0/src/claude_autosar/utils/html_utils.py +213 -0
- claude_autosar-0.3.0/src/claude_autosar/utils/paths.py +76 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/PKG-INFO +145 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/SOURCES.txt +90 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/dependency_links.txt +1 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/entry_points.txt +2 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/requires.txt +18 -0
- claude_autosar-0.3.0/src/claude_autosar.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AutoC Contributors
|
|
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.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claude-autosar
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: claude-autosar - AUTOSAR BSW 双格式 (.arxml + .xdm) 配置 IO / 模板 diff / lint / verify 工具集
|
|
5
|
+
Author: AutoC Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/autoc-cc/autoc-cc
|
|
8
|
+
Project-URL: Repository, https://github.com/autoc-cc/autoc-cc
|
|
9
|
+
Project-URL: Issues, https://github.com/autoc-cc/autoc-cc/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/autoc-cc/autoc-cc/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: autosar,bsw,tresos,davinci,arxml,ecu,embedded,mcp
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Manufacturing
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: lxml>=5.0
|
|
29
|
+
Requires-Dist: cantools>=39.0
|
|
30
|
+
Requires-Dist: rich>=13.0
|
|
31
|
+
Requires-Dist: mcp>=0.9
|
|
32
|
+
Requires-Dist: platformdirs>=4.0
|
|
33
|
+
Requires-Dist: tomli-w>=1.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=24.4; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
40
|
+
Requires-Dist: isort>=5.13; extra == "dev"
|
|
41
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
42
|
+
Requires-Dist: bandit>=1.7; extra == "dev"
|
|
43
|
+
Requires-Dist: pip-audit>=2.7; extra == "dev"
|
|
44
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# autoc — AUTOSAR BSW AI 配置助手(Python 核心)
|
|
48
|
+
|
|
49
|
+
`autoc` 是 AutoC Claude Code 插件的 Python 核心包。对 EB tresos / DaVinci
|
|
50
|
+
Configurator 的 BSW 配置做读、改、验证、归档、导出,与 Claude Code 通过
|
|
51
|
+
MCP 协议对接。
|
|
52
|
+
|
|
53
|
+
## 特性
|
|
54
|
+
|
|
55
|
+
- **不可变数据模型**:`BSWModule` / `BSWParam` / `ParamValue`(`frozen=True`,
|
|
56
|
+
`with_X()` 返回新实例)
|
|
57
|
+
- **MCU 差异化解耦**:`TresosAdapter.discover()` 数据驱动 — 同一段代码
|
|
58
|
+
处理 S32K3 / TC3xx / RH850,**无 if/else 分支**
|
|
59
|
+
- **协议层抽象**:`typing.Protocol + @runtime_checkable`;测试用
|
|
60
|
+
`StubTresosAdapter` / `StubDavinciAdapter`,CI 不依赖商业工具
|
|
61
|
+
- **ARXML 读写**:lxml 自写 `ARXMLDocument` / ECUC 解析(reference chain
|
|
62
|
+
+ type 启发式),无 `pyecarxml` 等不确定外部依赖
|
|
63
|
+
- **会话 / 改参日志 / 导出**:JSONL append-only 存储 + 不可变树 + fork
|
|
64
|
+
+ 自包含 HTML 导出(XSS 白名单 + 三色 callout)
|
|
65
|
+
- **MCP server**:FastMCP 10 工具(`bsw_read` / `bsw_write` / `bsw_verify` /
|
|
66
|
+
`bsw_autocalc` / `arxml_validate` / `dbc_parse` / `session_list` /
|
|
67
|
+
`session_show` / `session_export` / `log_export`)
|
|
68
|
+
- **路径防御**:MCP 工具的 `project` / `tresos_home` 入参在白名单
|
|
69
|
+
`_ALLOWED_PROJECT_ROOTS`(cwd)之内(ISO 21434 信任边界)
|
|
70
|
+
|
|
71
|
+
## 安装
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install claude-autosar
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
开发模式(含 dev 依赖):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install -e ".[dev]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 快速上手
|
|
84
|
+
|
|
85
|
+
CLI 入口 `autoc`(由 `pyproject.toml` `[project.scripts]` 提供):
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
autoc --version
|
|
89
|
+
autoc --help
|
|
90
|
+
|
|
91
|
+
# 改 EB tresos 工程下 Mcu 模块的两个参数
|
|
92
|
+
autoc eb save \
|
|
93
|
+
--project /path/to/tresos/project \
|
|
94
|
+
--module Mcu \
|
|
95
|
+
--param "Mcu/ClockConfiguration/McuClockSettingConfig_0/McuClockReferencePointFrequency=80000000" \
|
|
96
|
+
--param "Mcu/SecConfig/SecurityAttributeConfig_0/McuSecRam=ENABLE"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
MCP 集成:在 Claude Code 子 Agent 里直接调用 `bsw_write` / `arxml_validate` /
|
|
100
|
+
`session_export` 等工具,路径同 `autoc` 子命令。
|
|
101
|
+
|
|
102
|
+
## 项目状态
|
|
103
|
+
|
|
104
|
+
| 维度 | 值 |
|
|
105
|
+
|---|---|
|
|
106
|
+
| 测试 | **467 passed**(autoc 442 + plugin 25)|
|
|
107
|
+
| Coverage | **90.07%**(mcp_server 47%→91%,+44pp)|
|
|
108
|
+
| 静态检查 | ruff / isort / black / mypy strict 全清 |
|
|
109
|
+
| 安全 | bandit -ll 0 H/M(7 low 全是 subprocess 模式 + 1 path-traversal 防御);pip-audit 0 H/M(autoc 运行时无漏洞,3 个 transitive CVE 已记录在 SECURITY.md)|
|
|
110
|
+
| Python | 3.11 / 3.12 / 3.13 |
|
|
111
|
+
| License | MIT |
|
|
112
|
+
|
|
113
|
+
完整 sprint-by-sprint 进度交接见 [PROGRESS.md](https://github.com/autoc-cc/autoc-cc/blob/main/PROGRESS.md)。
|
|
114
|
+
|
|
115
|
+
## 目录结构
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
src/autoc/
|
|
119
|
+
├── __init__.py / __main__.py
|
|
120
|
+
├── cli/
|
|
121
|
+
│ ├── main.py # argparse 入口(dispatch 表 + 全局 flags)
|
|
122
|
+
│ ├── repl_skin.py # Rich 主题 + ReplSkin 业务 API
|
|
123
|
+
│ ├── mcp_server.py # FastMCP 10 工具
|
|
124
|
+
│ └── commands/ # eb / davinci / session / log / export
|
|
125
|
+
├── core/
|
|
126
|
+
│ ├── bsw/ # BSW 数据模型 + ARXML/ECUC 解析 + 验证
|
|
127
|
+
│ ├── settings/ # 配置合并(<cwd>/.autoc/ + ~/.autoc/agent/)
|
|
128
|
+
│ ├── session/ # JSONL store + 不可变树 + recorder + exporter
|
|
129
|
+
│ └── log/ # 改参 changelog
|
|
130
|
+
├── adapters/ # EB tresos / DaVinci / stub
|
|
131
|
+
└── utils/ # 跨平台路径
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 配套插件
|
|
135
|
+
|
|
136
|
+
`autoc` 是 Python 核心;要让 Claude Code 在 `~/.autoc/agent/` 工程里直接
|
|
137
|
+
调它,需要装
|
|
138
|
+
[autoc-cc 插件](https://github.com/autoc-cc/autoc-cc/tree/main/packages/plugin):
|
|
139
|
+
7 个 `/autoc:*` 斜杠命令、7 个 skill、3 个 hook(ARXML guard / BSW
|
|
140
|
+
validate / SessionStart 项目检测)、1 个 agent(bsw-config)、`.mcp.json`
|
|
141
|
+
直接挂到本包。
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT — 详见 [LICENSE](https://github.com/autoc-cc/autoc-cc/blob/main/packages/autoc/LICENSE)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# autoc — AUTOSAR BSW AI 配置助手(Python 核心)
|
|
2
|
+
|
|
3
|
+
`autoc` 是 AutoC Claude Code 插件的 Python 核心包。对 EB tresos / DaVinci
|
|
4
|
+
Configurator 的 BSW 配置做读、改、验证、归档、导出,与 Claude Code 通过
|
|
5
|
+
MCP 协议对接。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- **不可变数据模型**:`BSWModule` / `BSWParam` / `ParamValue`(`frozen=True`,
|
|
10
|
+
`with_X()` 返回新实例)
|
|
11
|
+
- **MCU 差异化解耦**:`TresosAdapter.discover()` 数据驱动 — 同一段代码
|
|
12
|
+
处理 S32K3 / TC3xx / RH850,**无 if/else 分支**
|
|
13
|
+
- **协议层抽象**:`typing.Protocol + @runtime_checkable`;测试用
|
|
14
|
+
`StubTresosAdapter` / `StubDavinciAdapter`,CI 不依赖商业工具
|
|
15
|
+
- **ARXML 读写**:lxml 自写 `ARXMLDocument` / ECUC 解析(reference chain
|
|
16
|
+
+ type 启发式),无 `pyecarxml` 等不确定外部依赖
|
|
17
|
+
- **会话 / 改参日志 / 导出**:JSONL append-only 存储 + 不可变树 + fork
|
|
18
|
+
+ 自包含 HTML 导出(XSS 白名单 + 三色 callout)
|
|
19
|
+
- **MCP server**:FastMCP 10 工具(`bsw_read` / `bsw_write` / `bsw_verify` /
|
|
20
|
+
`bsw_autocalc` / `arxml_validate` / `dbc_parse` / `session_list` /
|
|
21
|
+
`session_show` / `session_export` / `log_export`)
|
|
22
|
+
- **路径防御**:MCP 工具的 `project` / `tresos_home` 入参在白名单
|
|
23
|
+
`_ALLOWED_PROJECT_ROOTS`(cwd)之内(ISO 21434 信任边界)
|
|
24
|
+
|
|
25
|
+
## 安装
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install claude-autosar
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
开发模式(含 dev 依赖):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install -e ".[dev]"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 快速上手
|
|
38
|
+
|
|
39
|
+
CLI 入口 `autoc`(由 `pyproject.toml` `[project.scripts]` 提供):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
autoc --version
|
|
43
|
+
autoc --help
|
|
44
|
+
|
|
45
|
+
# 改 EB tresos 工程下 Mcu 模块的两个参数
|
|
46
|
+
autoc eb save \
|
|
47
|
+
--project /path/to/tresos/project \
|
|
48
|
+
--module Mcu \
|
|
49
|
+
--param "Mcu/ClockConfiguration/McuClockSettingConfig_0/McuClockReferencePointFrequency=80000000" \
|
|
50
|
+
--param "Mcu/SecConfig/SecurityAttributeConfig_0/McuSecRam=ENABLE"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
MCP 集成:在 Claude Code 子 Agent 里直接调用 `bsw_write` / `arxml_validate` /
|
|
54
|
+
`session_export` 等工具,路径同 `autoc` 子命令。
|
|
55
|
+
|
|
56
|
+
## 项目状态
|
|
57
|
+
|
|
58
|
+
| 维度 | 值 |
|
|
59
|
+
|---|---|
|
|
60
|
+
| 测试 | **467 passed**(autoc 442 + plugin 25)|
|
|
61
|
+
| Coverage | **90.07%**(mcp_server 47%→91%,+44pp)|
|
|
62
|
+
| 静态检查 | ruff / isort / black / mypy strict 全清 |
|
|
63
|
+
| 安全 | bandit -ll 0 H/M(7 low 全是 subprocess 模式 + 1 path-traversal 防御);pip-audit 0 H/M(autoc 运行时无漏洞,3 个 transitive CVE 已记录在 SECURITY.md)|
|
|
64
|
+
| Python | 3.11 / 3.12 / 3.13 |
|
|
65
|
+
| License | MIT |
|
|
66
|
+
|
|
67
|
+
完整 sprint-by-sprint 进度交接见 [PROGRESS.md](https://github.com/autoc-cc/autoc-cc/blob/main/PROGRESS.md)。
|
|
68
|
+
|
|
69
|
+
## 目录结构
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
src/autoc/
|
|
73
|
+
├── __init__.py / __main__.py
|
|
74
|
+
├── cli/
|
|
75
|
+
│ ├── main.py # argparse 入口(dispatch 表 + 全局 flags)
|
|
76
|
+
│ ├── repl_skin.py # Rich 主题 + ReplSkin 业务 API
|
|
77
|
+
│ ├── mcp_server.py # FastMCP 10 工具
|
|
78
|
+
│ └── commands/ # eb / davinci / session / log / export
|
|
79
|
+
├── core/
|
|
80
|
+
│ ├── bsw/ # BSW 数据模型 + ARXML/ECUC 解析 + 验证
|
|
81
|
+
│ ├── settings/ # 配置合并(<cwd>/.autoc/ + ~/.autoc/agent/)
|
|
82
|
+
│ ├── session/ # JSONL store + 不可变树 + recorder + exporter
|
|
83
|
+
│ └── log/ # 改参 changelog
|
|
84
|
+
├── adapters/ # EB tresos / DaVinci / stub
|
|
85
|
+
└── utils/ # 跨平台路径
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 配套插件
|
|
89
|
+
|
|
90
|
+
`autoc` 是 Python 核心;要让 Claude Code 在 `~/.autoc/agent/` 工程里直接
|
|
91
|
+
调它,需要装
|
|
92
|
+
[autoc-cc 插件](https://github.com/autoc-cc/autoc-cc/tree/main/packages/plugin):
|
|
93
|
+
7 个 `/autoc:*` 斜杠命令、7 个 skill、3 个 hook(ARXML guard / BSW
|
|
94
|
+
validate / SessionStart 项目检测)、1 个 agent(bsw-config)、`.mcp.json`
|
|
95
|
+
直接挂到本包。
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT — 详见 [LICENSE](https://github.com/autoc-cc/autoc-cc/blob/main/packages/autoc/LICENSE)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "claude-autosar"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "claude-autosar - AUTOSAR BSW 双格式 (.arxml + .xdm) 配置 IO / 模板 diff / lint / verify 工具集"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "AutoC Contributors" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["autosar", "bsw", "tresos", "davinci", "arxml", "ecu", "embedded", "mcp"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Manufacturing",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: Software Development :: Embedded Systems",
|
|
29
|
+
"Typing :: Typed",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"lxml>=5.0",
|
|
33
|
+
"cantools>=39.0",
|
|
34
|
+
"rich>=13.0",
|
|
35
|
+
"mcp>=0.9",
|
|
36
|
+
"platformdirs>=4.0",
|
|
37
|
+
"tomli-w>=1.0",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/autoc-cc/autoc-cc"
|
|
42
|
+
Repository = "https://github.com/autoc-cc/autoc-cc"
|
|
43
|
+
Issues = "https://github.com/autoc-cc/autoc-cc/issues"
|
|
44
|
+
Changelog = "https://github.com/autoc-cc/autoc-cc/blob/main/CHANGELOG.md"
|
|
45
|
+
|
|
46
|
+
[project.optional-dependencies]
|
|
47
|
+
dev = [
|
|
48
|
+
"pytest>=8.0",
|
|
49
|
+
"pytest-cov>=5.0",
|
|
50
|
+
"pytest-asyncio>=0.23",
|
|
51
|
+
"black>=24.4",
|
|
52
|
+
"ruff>=0.5",
|
|
53
|
+
"isort>=5.13",
|
|
54
|
+
"mypy>=1.10",
|
|
55
|
+
"bandit>=1.7",
|
|
56
|
+
"pip-audit>=2.7",
|
|
57
|
+
"pre-commit>=3.7",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
claude-autosar = "claude_autosar.cli.main:main"
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.packages.find]
|
|
64
|
+
where = ["src"]
|
|
65
|
+
|
|
66
|
+
[tool.setuptools.package-data]
|
|
67
|
+
claude_autosar = ["py.typed"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""AutoC - AUTOSAR BSW 配置 AI 助手 Python 核心。
|
|
2
|
+
|
|
3
|
+
AutoC 是一个面向 AUTOSAR BSW 工程师的终端 AI 助手:用自然语言描述
|
|
4
|
+
时钟、引脚、模块等配置目标,AI 在工程里完成改参、依赖计算与校验,
|
|
5
|
+
并根据结果继续调整,直到配置通过。
|
|
6
|
+
|
|
7
|
+
本包提供:
|
|
8
|
+
- 命令行入口(cli.main)
|
|
9
|
+
- BSW 领域数据模型(core.bsw)
|
|
10
|
+
- 工具适配器(adapters)
|
|
11
|
+
- 工具与配置(utils, core.settings)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""DaVinci Configurator 适配器默认实现。
|
|
2
|
+
|
|
3
|
+
对应 Vector ``DVCfgCmd.exe`` 命令行工具。``DVCfgCmd`` 默认在
|
|
4
|
+
``${SIP}/DaVinciConfigurator/Core/DVCfgCmd.exe``(SIP 路径从 ``.dpa`` 解析,
|
|
5
|
+
本适配器复用 ``EcuConfigProjectContext.tool_home`` 字段作 DAVINCI_HOME,调用方
|
|
6
|
+
按需从 ``.dpa`` 解析后填入)。
|
|
7
|
+
|
|
8
|
+
当前 Sprint 2 仅实现 verify / save 两个核心子命令,覆盖率需求 80%+
|
|
9
|
+
(Sprint 3+ 会扩展 ``Generate`` / ``Import`` 等)。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
import re
|
|
17
|
+
import subprocess
|
|
18
|
+
|
|
19
|
+
from claude_autosar.adapters.protocol import (
|
|
20
|
+
EcuConfigProjectContext,
|
|
21
|
+
SaveResult,
|
|
22
|
+
VerifyResult,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DavinciAdapterError(RuntimeError):
|
|
27
|
+
"""DaVinci 适配器错误。"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DavinciAdapter:
|
|
31
|
+
"""DaVinci Configurator 默认实现。"""
|
|
32
|
+
|
|
33
|
+
DEFAULT_TIMEOUT_S: int = 300
|
|
34
|
+
|
|
35
|
+
def __init__(self, default_timeout_s: int = DEFAULT_TIMEOUT_S) -> None:
|
|
36
|
+
if default_timeout_s <= 0:
|
|
37
|
+
raise ValueError(f"default_timeout_s must be > 0, got {default_timeout_s}")
|
|
38
|
+
self.default_timeout_s = default_timeout_s
|
|
39
|
+
|
|
40
|
+
def _dvcfg_path(self, ctx: EcuConfigProjectContext) -> Path:
|
|
41
|
+
"""定位 ``DVCfgCmd.exe``。"""
|
|
42
|
+
suffix = ".exe" if os.name == "nt" else ""
|
|
43
|
+
candidates = [
|
|
44
|
+
ctx.tool_home / "Core" / f"DVCfgCmd{suffix}",
|
|
45
|
+
ctx.tool_home / f"Core/DVCfgCmd{suffix}",
|
|
46
|
+
]
|
|
47
|
+
for c in candidates:
|
|
48
|
+
if c.is_file():
|
|
49
|
+
return c
|
|
50
|
+
raise DavinciAdapterError(
|
|
51
|
+
f"DVCfgCmd not found under {ctx.tool_home}/Core/ (tried {suffix or 'no-suffix'})"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def _run_dvcfg(
|
|
55
|
+
self,
|
|
56
|
+
ctx: EcuConfigProjectContext,
|
|
57
|
+
args: list[str],
|
|
58
|
+
) -> subprocess.CompletedProcess[str]:
|
|
59
|
+
"""运行 DVCfgCmd 子命令。"""
|
|
60
|
+
cmd_path = self._dvcfg_path(ctx)
|
|
61
|
+
cmd = [str(cmd_path), *args]
|
|
62
|
+
try:
|
|
63
|
+
return subprocess.run(
|
|
64
|
+
cmd,
|
|
65
|
+
cwd=str(ctx.project_path),
|
|
66
|
+
capture_output=True,
|
|
67
|
+
text=True,
|
|
68
|
+
encoding="utf-8",
|
|
69
|
+
errors="replace",
|
|
70
|
+
timeout=self.default_timeout_s,
|
|
71
|
+
check=False,
|
|
72
|
+
)
|
|
73
|
+
except subprocess.TimeoutExpired as e:
|
|
74
|
+
raise DavinciAdapterError(
|
|
75
|
+
f"DVCfgCmd timed out after {self.default_timeout_s}s: {' '.join(cmd)}"
|
|
76
|
+
) from e
|
|
77
|
+
except OSError as e:
|
|
78
|
+
# OSError 覆盖 FileNotFoundError / PermissionError / IsADirectoryError
|
|
79
|
+
# 等所有 "执行 DVCfgCmd 失败" 的 IO 错误
|
|
80
|
+
raise DavinciAdapterError(
|
|
81
|
+
f"DVCfgCmd not invocable ({type(e).__name__}: {e}): {cmd_path}"
|
|
82
|
+
) from e
|
|
83
|
+
|
|
84
|
+
def verify(
|
|
85
|
+
self,
|
|
86
|
+
ctx: EcuConfigProjectContext,
|
|
87
|
+
module: str | None = None,
|
|
88
|
+
) -> VerifyResult:
|
|
89
|
+
"""调用 ``DVCfgCmd AutocVerify``。"""
|
|
90
|
+
args = ["AutocVerify"]
|
|
91
|
+
if module:
|
|
92
|
+
args.extend(["--module", module])
|
|
93
|
+
result = self._run_dvcfg(ctx, args)
|
|
94
|
+
return VerifyResult(
|
|
95
|
+
success=result.returncode == 0,
|
|
96
|
+
returncode=result.returncode,
|
|
97
|
+
stdout=result.stdout,
|
|
98
|
+
stderr=result.stderr,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def save(
|
|
102
|
+
self,
|
|
103
|
+
ctx: EcuConfigProjectContext,
|
|
104
|
+
module: str | None = None,
|
|
105
|
+
) -> SaveResult:
|
|
106
|
+
"""调用 ``DVCfgCmd Save``。
|
|
107
|
+
|
|
108
|
+
从 stdout 解析 ``Wrote: <path>`` 模式以填充 ``written_files``,相对路径
|
|
109
|
+
相对于 ``ctx.project_path`` 解析。DaVinci 写出的是 ``.arxml`` 而非 ``.xdm``。
|
|
110
|
+
"""
|
|
111
|
+
args = ["Save"]
|
|
112
|
+
if module:
|
|
113
|
+
args.extend(["--module", module])
|
|
114
|
+
result = self._run_dvcfg(ctx, args)
|
|
115
|
+
written = self._extract_written_files(ctx, result.stdout)
|
|
116
|
+
return SaveResult(
|
|
117
|
+
success=result.returncode == 0,
|
|
118
|
+
returncode=result.returncode,
|
|
119
|
+
stdout=result.stdout,
|
|
120
|
+
stderr=result.stderr,
|
|
121
|
+
written_files=written,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# ------------------------------------------------------------------
|
|
125
|
+
# stdout 解析(提取写入文件路径)
|
|
126
|
+
# ------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
# DaVinci DVCfgCmd 的 Save 输出格式(Vector 文档):
|
|
129
|
+
# "Wrote: <relative-or-absolute-path>" (最常见)
|
|
130
|
+
# "Wrote file <path>" (旧版本)
|
|
131
|
+
# "Saved <path>" (罕见)
|
|
132
|
+
#
|
|
133
|
+
# 必须左锚定到行首 + 强制扩展名,否则会误匹配自然语言中的 "wrote/saved"
|
|
134
|
+
# (如 "Configuration was not saved due to validation errors" 会被错配为路径 "due")。
|
|
135
|
+
_WRITTEN_FILE_RE = re.compile(
|
|
136
|
+
r"(?:^|\n)\s*(?:wrote|written|saved)\s*(?:file\s*)?:?\s+(\S+\.(?:arxml|xdm))",
|
|
137
|
+
re.IGNORECASE,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
@classmethod
|
|
141
|
+
def _extract_written_files(
|
|
142
|
+
cls,
|
|
143
|
+
ctx: EcuConfigProjectContext,
|
|
144
|
+
stdout: str,
|
|
145
|
+
) -> tuple[Path, ...]:
|
|
146
|
+
"""从 DVCfgCmd 输出中提取已写入的文件路径。
|
|
147
|
+
|
|
148
|
+
相对路径相对于 ``ctx.project_path`` 解析。
|
|
149
|
+
"""
|
|
150
|
+
results: set[Path] = set()
|
|
151
|
+
for m in cls._WRITTEN_FILE_RE.finditer(stdout):
|
|
152
|
+
raw = m.group(1).rstrip(".,;")
|
|
153
|
+
p = Path(raw)
|
|
154
|
+
if not p.is_absolute():
|
|
155
|
+
p = ctx.project_path / p
|
|
156
|
+
try:
|
|
157
|
+
p = p.resolve()
|
|
158
|
+
except OSError:
|
|
159
|
+
continue
|
|
160
|
+
results.add(p)
|
|
161
|
+
return tuple(sorted(results))
|