Skip to main content

autoc — AUTOSAR BSW AI 配置助手(Python 核心)

autoc 是 AutoC Claude Code 插件的 Python 核心包。对 EB tresos / DaVinci Configurator 的 BSW 配置做读、改、验证、归档、导出,与 Claude Code 通过 MCP 协议对接。

特性

  • 不可变数据模型:BSWModule / BSWParam / ParamValue(frozen=True, with_X() 返回新实例)
  • MCU 差异化解耦:TresosAdapter.discover() 数据驱动 — 同一段代码 处理 S32K3 / TC3xx / RH850,无 if/else 分支
  • 协议层抽象:typing.Protocol + @runtime_checkable;测试用 StubTresosAdapter / StubDavinciAdapter,CI 不依赖商业工具
  • ARXML 读写:lxml 自写 ARXMLDocument / ECUC 解析(reference chain
    • type 启发式),无 pyecarxml 等不确定外部依赖
  • 会话 / 改参日志 / 导出:JSONL append-only 存储 + 不可变树 + fork
    • 自包含 HTML 导出(XSS 白名单 + 三色 callout)
  • MCP server:FastMCP 10 工具(bsw_read / bsw_write / bsw_verify / bsw_autocalc / arxml_validate / dbc_parse / session_list / session_show / session_export / log_export)
  • 路径防御:MCP 工具的 project / tresos_home 入参在白名单 _ALLOWED_PROJECT_ROOTS(cwd)之内(ISO 21434 信任边界)

安装

pip install claude-autosar

开发模式(含 dev 依赖):

pip install -e ".[dev]"

快速上手

CLI 入口 autoc(由 pyproject.toml [project.scripts] 提供):

autoc --version
autoc --help

# 改 EB tresos 工程下 Mcu 模块的两个参数
autoc eb save \
  --project /path/to/tresos/project \
  --module Mcu \
  --param "Mcu/ClockConfiguration/McuClockSettingConfig_0/McuClockReferencePointFrequency=80000000" \
  --param "Mcu/SecConfig/SecurityAttributeConfig_0/McuSecRam=ENABLE"

MCP 集成:在 Claude Code 子 Agent 里直接调用 bsw_write / arxml_validate / session_export 等工具,路径同 autoc 子命令。

项目状态

维度 值
测试 467 passed(autoc 442 + plugin 25)
Coverage 90.07%(mcp_server 47%→91%,+44pp)
静态检查 ruff / isort / black / mypy strict 全清
安全 bandit -ll 0 H/M(7 low 全是 subprocess 模式 + 1 path-traversal 防御);pip-audit 0 H/M(autoc 运行时无漏洞,3 个 transitive CVE 已记录在 SECURITY.md)
Python 3.11 / 3.12 / 3.13
License MIT

完整 sprint-by-sprint 进度交接见 PROGRESS.md。

目录结构

src/autoc/
├── __init__.py / __main__.py
├── cli/
│   ├── main.py                # argparse 入口(dispatch 表 + 全局 flags)
│   ├── repl_skin.py           # Rich 主题 + ReplSkin 业务 API
│   ├── mcp_server.py          # FastMCP 10 工具
│   └── commands/              # eb / davinci / session / log / export
├── core/
│   ├── bsw/                   # BSW 数据模型 + ARXML/ECUC 解析 + 验证
│   ├── settings/              # 配置合并(<cwd>/.autoc/ + ~/.autoc/agent/)
│   ├── session/               # JSONL store + 不可变树 + recorder + exporter
│   └── log/                   # 改参 changelog
├── adapters/                  # EB tresos / DaVinci / stub
└── utils/                     # 跨平台路径

配套插件

autoc 是 Python 核心;要让 Claude Code 在 ~/.autoc/agent/ 工程里直接 调它,需要装 claude-autosar 插件: 7 个 /autoc:* 斜杠命令、7 个 skill、3 个 hook(ARXML guard / BSW validate / SessionStart 项目检测)、1 个 agent(bsw-config)、.mcp.json 直接挂到本包。

License

MIT — 详见 LICENSE

Metadata

Release files for claude-autosar 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-autosar 0.4.0
File Size Uploaded Provenance Actions
claude_autosar-0.4.0.tar.gz 176.9 kB With provenance Details for claude_autosar-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for claude-autosar 0.4.0
File Interpreter ABI Platform Actions
claude_autosar-0.4.0-py3-none-any.whl Python 3 none any Details for claude_autosar-0.4.0-py3-none-any.whl

Total release size: 439.3 kB

Release files / claude_autosar-0.4.0.tar.gz

Download URL claude_autosar-0.4.0.tar.gz
Size 176.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cc2a80b8a1d7d15802b3bedac5b9dec2b04b2ba02dc58850f359cb3dc53d3990
BLAKE2b-256 checksum
How to use checksums
98da8890acdfaf48e548b312a4de9a9c4444a6d4f89103a4dcb3a0b69a8103f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.

Transparency log

Release files / claude_autosar-0.4.0-py3-none-any.whl

Download URL claude_autosar-0.4.0-py3-none-any.whl
Size 262.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d86fb2d21793a42c1449bc7051ade1eea782ff225b634c79ca9acf98fc401e1
BLAKE2b-256 checksum
How to use checksums
4b79be1aaf6866379eb5f55230f2ee159ed9acf6fdd603ee2ea342008140f123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.

Transparency log

Security for claude-autosar 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for claude_autosar-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page