firmwareloop 0.0.8__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.
@@ -0,0 +1,268 @@
1
+ Metadata-Version: 2.4
2
+ Name: firmwareloop
3
+ Version: 0.0.8
4
+ Summary: AI Agent Firmware Development and Lab Automation Platform (Dual-Tier MCP Server)
5
+ Author-email: WeilinZhang <19523330249@163.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Jeffrey1799/FirmwareLoop
8
+ Project-URL: Repository, https://github.com/Jeffrey1799/FirmwareLoop.git
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Software Development :: Embedded Systems
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: pyvisa>=1.14.0
21
+ Requires-Dist: pyvisa-py>=0.7.0
22
+ Requires-Dist: pyserial>=3.5
23
+ Requires-Dist: pytest>=8.0.0
24
+ Requires-Dist: pyocd>=0.36.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: agentic-hil>=0.14.0
27
+ Dynamic: license-file
28
+
29
+ # FirmwareLoop
30
+
31
+ > 面向 AI Agent 的固件开发与实验室自动化平台(开源版)。
32
+ > 目标不是"AI 帮工程师写代码",而是**让 AI 基于真实硬件产生的观测数据参与开发、调试、测试与回归验证**。
33
+
34
+ ![Windows](https://img.shields.io/badge/windows-10%20%7C%2011-blue)
35
+ ![PowerShell](https://img.shields.io/badge/powershell-7+-4E8B8B)
36
+ ![Python](https://img.shields.io/badge/python-3.10%2B-3776AB)
37
+ [![CI](https://github.com/Jeffrey1799/FirmwareLoop/actions/workflows/ci.yml/badge.svg)](https://github.com/Jeffrey1799/FirmwareLoop/actions/workflows/ci.yml)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
39
+
40
+ FirmwareLoop 把固件工程的完整闭环交给 AI Agent 编排:**理解工程 → 修改 → 编译 → 烧录 → 复位 → UART/CAN/Debug → 逻辑分析仪/示波器测量 → 自动测试 → PASS/FAIL → 失败分析 → 再修改 → 重新验证**。
41
+
42
+ 核心原则:**优先复用现成开源/官方能力,不构建大而全的自研 Firmware Lab MCP**。所有工具是薄适配层,任何环节失败都返回结构化 JSON + 统一 Error Class(`BUILD_ERROR` / `SAFETY_LIMIT` / `TARGET_MISMATCH` …),证据自动落盘——判定功能正确必须同时有 **Build Evidence + Runtime Evidence + Measurement Evidence + Assertion**,禁止只看 `exit code == 0`。
43
+
44
+ ---
45
+
46
+ ## 架构
47
+
48
+ ```
49
+ ┌────────────────────────────────────────────┐
50
+ │ AI Agent (Qoder / CLI) │
51
+ │ Code / Planning / Diagnosis / Orchestration│
52
+ └────────────────────┬───────────────────────┘
53
+ ┌───────────┼───────────────┐
54
+ ▼ ▼ ▼
55
+ Shell/CLI MCP pytest
56
+ │ │ │
57
+ ▼ ┌───────┴──────┐ ▼
58
+ tools/ Agentic HIL Saleae HIL 测试
59
+ │ │ │
60
+ ▼ ▼ ▼
61
+ Build Flash UART CAN Logic
62
+ Adapter Reset Debug Analyzer
63
+
64
+ └─────────┬───────────────┐
65
+ ▼ ▼
66
+ DUT PyVISA / SCPI
67
+ Scope / PSU / DMM / AWG
68
+ ```
69
+
70
+ 细节见 [AI_DEV_GUIDE.md](AI_DEV_GUIDE.md)(Agent 强制规则,设计约束由此衍生;原始内部需求文档不随仓库发布)。
71
+
72
+ ---
73
+
74
+ ## 双层 MCP 架构与接入模式
75
+
76
+ FirmwareLoop 提供开箱即用的**双层 MCP 架构**:
77
+ 1. **上层工作流 MCP (`fwloop` / `firmwareloop`)**:面向工程构建(Keil/CMake/Make 等 7 大后端)、pytest 12项自动化 HIL 测试、安全测量与全链路验收。
78
+ 2. **下层硬件驱动 MCP (`agentic-hil`)**:面向物理探针(ST-LINK / J-Link)、JTAG/SWD 固件刷写、芯片复位、串口会话与符号级断点调试。
79
+
80
+ ### 接入模式一:电脑全局安装(首选推荐,一次安装,所有工程通用)
81
+
82
+ 用户只需在终端执行以下命令,即可将 `fwloop` 与 `agentic-hil` 安装为系统全局工具:
83
+
84
+ ```bash
85
+ # 1. 全局安装 CLI 工具到系统
86
+ uv tool install git+https://github.com/Jeffrey1799/FirmwareLoop.git
87
+ uv tool install agentic-hil
88
+
89
+ # 2. 全局注册到各大 Agent(一次配置,所有单片机项目直接使用)
90
+ # Claude Code CLI (全局级):
91
+ claude mcp add --scope user fwloop -- fwloop
92
+ claude mcp add --scope user agentic-hil -- agentic-hil mcp-stdio
93
+
94
+ # Qoder IDE 接入(支持以下两种官方方式):
95
+ # 方式 A (GUI): 按快捷键 Ctrl+Shift+,(Mac: Cmd+Shift+,)-> 进入「MCP」->「我的服务」-> 点击「+ 添加」粘贴配置
96
+ # 方式 B (工作区): 项目根目录放 .mcp.json,Qoder 会自动发现并加载
97
+ # 方式 C (CLI): qoder.cmd mcp add --global fwloop -- fwloop
98
+ ```
99
+
100
+ > **效果**:在电脑任意目录、任意 STM32 / Keil 独立工程下打开 Agent,Agent 均可直接调起 MCP,无需在每个工程中重复配置!
101
+
102
+ ---
103
+
104
+ ### 接入模式二:免克隆即时运行(零安装,按需从 GitHub 拉取)
105
+
106
+ 如果不想全局安装,可直接配置 Agent 通过 `uvx` 临时拉取运行:
107
+
108
+ * **Claude Code CLI 注册**:
109
+ ```bash
110
+ claude mcp add fwloop -- uvx --from git+https://github.com/Jeffrey1799/FirmwareLoop.git fwloop
111
+ claude mcp add agentic-hil -- uvx agentic-hil mcp-stdio
112
+ ```
113
+
114
+ * **Qoder / Cursor / Antigravity(在工程 `.mcp.json` 中配置)**:
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "fwloop": {
119
+ "command": "uvx",
120
+ "args": [
121
+ "--from", "git+https://github.com/Jeffrey1799/FirmwareLoop.git",
122
+ "fwloop"
123
+ ]
124
+ },
125
+ "agentic-hil": {
126
+ "command": "uvx",
127
+ "args": ["agentic-hil", "mcp-stdio"]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ---
134
+
135
+ ### 接入模式三:源码二次开发模式(本地 Git 克隆)
136
+
137
+ 适合需要修改 FirmwareLoop 源码或离线开发的用户:
138
+ ```powershell
139
+ # 1. 克隆与环境初始化
140
+ git clone https://github.com/Jeffrey1799/FirmwareLoop.git D:\Tools\FirmwareLoop
141
+ cd D:\Tools\FirmwareLoop
142
+ uv pip install -e .
143
+
144
+ # 2. 注册到 Claude Code
145
+ claude mcp add fwloop -- "D:\Tools\FirmwareLoop\.venv\Scripts\fwloop.exe"
146
+ claude mcp add agentic-hil -- "D:\Tools\FirmwareLoop\.venv\Scripts\agentic-hil.exe" mcp-stdio
147
+ ```
148
+
149
+ ---
150
+
151
+ ### 常用 CLI 终端命令与一键更新(支持简短别名 `fwloop`)
152
+
153
+ 本项目支持名称兼容,**`fwloop` 与 `firmwareloop` 完全等价**,用户与开发者可在终端直接使用更简短的 `fwloop`:
154
+
155
+ ```bash
156
+ # 在任意单片机工程根目录下一键初始化多 Agent 规范 (AGENTS.md, CLAUDE.md, GEMINI.md) 与台架配置
157
+ fwloop init # 或: firmwareloop init
158
+
159
+ # 一键自动更新至最新版本(自动拉取最新代码并热重载依赖)
160
+ fwloop update # 或: firmwareloop update
161
+
162
+ # 环境健康体检与依赖诊断
163
+ fwloop doctor # 或: firmwareloop doctor
164
+
165
+ # 查看或生成各大 Agent MCP 注册指令
166
+ fwloop setup # 或: firmwareloop setup
167
+
168
+ # 查看当前版本
169
+ fwloop version # 或: firmwareloop version
170
+ ```
171
+
172
+ ---
173
+
174
+ ### 在任意工程中纯对话开发
175
+
176
+ 在你的任意单片机工程目录下启动 Agent,直接通过自然语言交互:
177
+ * “*帮我将当前单片机工程初始化为 FirmwareLoop 项目*” → Agent 自动调用 `fw_init_project` 生成 `AGENTS.md`、`CLAUDE.md`、`GEMINI.md` 与 `lab/lab.yaml`
178
+ * “*帮我将当前工程设为 Keil5 编译,目标芯片是 STM32F103C8T6,串口为 COM5*” → Agent 自动调用 `fw_configure_lab`
179
+ * “*扫描已连接的 ST-LINK / J-Link 调试器*” → Agent 自动调用 `fw_scan_hardware`
180
+ * “*编译当前 Keil 工程并刷入板子,复位后读取串口输出*” → Agent 自动闭环调用 `fw_build`、`fw_flash`、`fw_reset`
181
+
182
+ ---
183
+
184
+ ## 特性
185
+
186
+ - **多 Agent 规范体系**:自动生成 `AGENTS.md`、`CLAUDE.md`、`GEMINI.md` 与 `skills/firmwareloop/SKILL.md`,支持主流 Agent 无缝协同
187
+ - **Build 适配**:自动探测 Keil (UV4.exe) / CMake / Make / IAR / PlatformIO 等已有构建系统,只做包装不重造;输出结构化 `firmware-build-result/v1`(含 file/line/col 诊断)
188
+ - **pytest HIL**:12 项开箱测试(boot / UART / 协议 / 电源 / PWM / 逻辑分析),无硬件自动 skip,产物 JUnit + `firmware-hil-result/v1` + evidence
189
+ - **逻辑分析**:`capture → decode → assert` 全链路(I2C / SPI / UART),Saleae MCP 或 sigrok fallback
190
+ - **仪器层**:PyVISA/SCPI,每一次写入都受 `lab/limits.yaml` 安全限制保护,超限返回 `SAFETY_LIMIT`(`raw_scpi` 刻意未实现)
191
+ - **硬件门(Agentic HIL)**:probe → 身份校验 → 动作;目标不符立即 STOP;CAN TX 默认需人工授权;Mass Erase / OTP / RDP 等永久禁止
192
+ - **仿真模式**:无硬件也能完整验收——模拟 DUT 是真实编译产物(stdio 即 UART),仪器/逻辑分析有确定性 simulator 后端
193
+ - **审计闭环**:每次运行保存 run_id / git commit / modified files / artifact sha256 / uart.log / measurements / 报告
194
+
195
+ ---
196
+
197
+ ## 与同类项目定位
198
+
199
+ | | FirmwareLoop | pytest-embedded | PlatformIO Test | Labgrid |
200
+ |---|---|---|---|---|
201
+ | 编排主体 | AI Agent | pytest | pytest | 资源调度 |
202
+ | 测量证据 | 逻辑分析 + VISA 仪器 | 串口/日志 | 基础 | 弱 |
203
+ | 安全策略 | limits.yaml + 权限模型 | 无 | 无 | 弱 |
204
+ | 迭代闭环 | build→测→改→重测(≤3 次) | 无 | 部分 | 无 |
205
+
206
+ ---
207
+
208
+ ## 目录结构
209
+
210
+ ```
211
+ ├── tools/ fw_mcp_server / setup-agent-mcp / doctor / build / test /
212
+ │ flash / reset / can / logic_* / instrument_cli / acceptance-scenario
213
+ ├── tests/ unit/ (mcp_server) / hil/ / plans/ / safety/ / backend/
214
+ ├── lab/ lab.example.yaml / limits.example.yaml / protocol-decode.yaml
215
+ ├── test-plans/ smoke.yaml / real-smoke.yaml / regression.yaml
216
+ ├── demo-firmware/ 示例固件(CMake;宿主编译模拟 MCU,闭环验证载体)
217
+ ├── demo-make/ 示例固件(Make;构建测试载体)
218
+ ├── docs/ DEPENDENCY_MATRIX / REUSE_PLAN / V0.0.2_GAP_VERIFICATION
219
+ ├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.0.8)
220
+ ├── .mcp.example.json 双层 MCP 配置模板(firmwareloop + agentic-hil)
221
+ ├── AGENTS.md 通用智能体规范(Antigravity / Qoder / Cursor 等)
222
+ ├── CLAUDE.md Claude Code CLI 指南
223
+ ├── GEMINI.md Antigravity / Gemini CLI 指南
224
+ └── AI_DEV_GUIDE.md AGENT 强制规则
225
+ ```
226
+
227
+ ---
228
+
229
+ ## 能力验证状态(v0.0.8)
230
+
231
+ > 状态定义:`Implemented`(已实现)/ `Simulator Validated`(模拟验证)/
232
+ > `Real Hardware Validated`(真机验证)/ `Experimental` / `Not Implemented`
233
+
234
+ | 能力 | 状态 |
235
+ |---|---|
236
+ | 双层 MCP 服务(13 个工作流与硬件工具) | ✅ Implemented + Protocol Validated(31/31 测试通过) |
237
+ | 一键多 Agent 脚手架(fwloop init / fw_init_project) | ✅ Implemented + Multi-Agent Validated |
238
+ | 一键终端更新(fwloop update) | ✅ Implemented + Auto-updater Validated |
239
+ | uvx 免克隆即时运行(Zero-Clone Mode) | ✅ Implemented + PEP 517/621 Validated |
240
+ | Build:keil (UV4.exe) / cmake / make / platformio / iar / zephyr / esp-idf | ✅ Implemented + Multi-backend Validated |
241
+ | pytest HIL(12 项,simulator) | ✅ Implemented + Simulator Validated |
242
+ | pytest HIL(real UART) | ⚠️ Implemented(Agentic HIL 插件已就绪)→ Real Hardware Validated 待 DUT |
243
+ | Agentic HIL MCP(42 硬件工具) | ✅ Implemented + discovery 验证 → 真机待 DUT |
244
+ | 逻辑分析 capture/decode/assert(I2C/SPI/UART) | ✅ Simulator Validated → Real Hardware Validated 待 LA |
245
+ | VISA 仪器(simulator) | ✅ Simulator Validated → Real Hardware Validated 待仪器 |
246
+ | Safety Policy(limits.yaml) | ✅ Implemented(simulator 校验)→ 外置权威配置 |
247
+ | 自动修复闭环(M6 载体) | ✅ Simulator Validated → Real Hardware Validated 待 DUT |
248
+
249
+ ---
250
+
251
+ ## 接入真实硬件
252
+
253
+ 1. `Copy-Item lab\lab.example.yaml lab\lab.yaml`,填入 **COM 口 / 目标身份 / 探针序列号 / 仪器 resource**(真实值永不入库)
254
+ 2. `agentic-hil adopt-hardware` 载入探针(CLI 已含于 venv)
255
+ 3. `.\tools\doctor.ps1 -Json` 复核
256
+ 4. `probe_target` 确认目标身份后,`.\tools\acceptance-scenario.ps1 -Hardware agentic-hil -Json`
257
+
258
+ ---
259
+
260
+ ## 贡献
261
+
262
+ 见 [CONTRIBUTING.md](CONTRIBUTING.md)。版本记录见 [CHANGELOG.md](CHANGELOG.md),安全相关见 [SECURITY.md](SECURITY.md)。
263
+
264
+ ---
265
+
266
+ ## License
267
+
268
+ [MIT](LICENSE) © Jeffrey1799。第三方组件(Agentic HIL / Logic 2 / PyVISA / pytest / CMake / Ninja / MinGW)归各自作者所有;本项目只做薄适配层。
@@ -0,0 +1,26 @@
1
+ firmwareloop-0.0.8.dist-info/licenses/LICENSE,sha256=V41Md7EKIAQ1Hn1kf7qgPPo3zAG8xNWLIzAiZMlo3vc,1087
2
+ tools/__init__.py,sha256=onACRqToXs78m8hf-JoyfgW9mmriX0J7BnuBscuDwXA,105
3
+ tools/acceptance-scenario.ps1,sha256=W2LaF8bBQjp6VcpeRuGpf0LA4hlokF4F16DzTbq0CX0,22818
4
+ tools/build.ps1,sha256=FE8LBy-wxrSItlvif0sxySEG_GOAVC0pyMX1e-nHf1Q,8968
5
+ tools/can.ps1,sha256=oVUT_3SQCZTf_eICZcDqTtzkvm-ErUccwBZCX-Geets,6540
6
+ tools/check-qoder-mcp.ps1,sha256=HOufFkrJDJfMnJ03K8LuJyXzBcSHV_yyJ4EfEJMpyPs,4929
7
+ tools/doctor.ps1,sha256=VMqK_zd4DcLkJzbHscZ_PWdK6qSCpDGmij9oNR2gXlM,6279
8
+ tools/flash.ps1,sha256=FfM39T-q2272nBt5hRNESQ_HIAOmJNIV2mvlB9qB5oA,9388
9
+ tools/fw_mcp_server.py,sha256=z-LpgdzdoOuRKUSku7YgfzBGPS2arnpX8lD1mj5A0Cw,49132
10
+ tools/instrument_cli.py,sha256=R-sthWR_pGaigWzNO9qQrqcBknn8iG_1tPlEjEyQJ3w,19398
11
+ tools/logic_capture.ps1,sha256=VulFBErO7U0Hk9-NC-JxHlwTdfAPBTeFgo2FYGhW01g,11021
12
+ tools/logic_decode.ps1,sha256=hxbHT3_lWNR_zfZFxC_qSj-SHgLDlJcavtxRgF8-GfE,13661
13
+ tools/reset.ps1,sha256=F4lcHhg8fKodXndvCjeFpMk1qmiYMovoFEWiZspREKQ,6993
14
+ tools/setup-agent-mcp.ps1,sha256=DTsxS80gHfDnJARL0mgoJeoO_KSYBo2kBdAt7tpKH5o,5870
15
+ tools/test-backends.ps1,sha256=X3FDQ5jKNs4HNoNV6hzZTkSAZi58xL_IrV6ZpUFiXGY,5275
16
+ tools/test.ps1,sha256=sQS8xxWvGdUKtXAt6G0Kol-qayRBmI8G2yQBBASHhTk,8141
17
+ tools/common/build-backends.psm1,sha256=AuLVAQV2PaFXooRx5_6qYNE1BBQDdtNWYdJiPKg9E-I,14035
18
+ tools/common/fw.psm1,sha256=QKONiQR5WiG62bnUBXim09sUrN9rraoCNNrJ_tUlIT8,11312
19
+ tools/common/uart_probe.py,sha256=Wroj2JLQ3bhrteC2wb4s5zCO7763ChTnz-2YTRrl8z4,3139
20
+ tools/lib/__init__.py,sha256=ol9R5bqElha14dNZDGX_i7JKLqkyRWWeL9qNkUNxuOE,43
21
+ tools/lib/instruments.py,sha256=hk1kOof5rQa8m4MMWh69iCbnCNhKqkLGXzptZgzLHY8,6728
22
+ firmwareloop-0.0.8.dist-info/METADATA,sha256=yBCKpP1Q93ErxG7d_8plck0tBEElO1KUNcwBUdX7GqA,13336
23
+ firmwareloop-0.0.8.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
24
+ firmwareloop-0.0.8.dist-info/entry_points.txt,sha256=4ahknDf3pWg7dVQVnLd1tR92a45StWjeA0au5mapPY8,156
25
+ firmwareloop-0.0.8.dist-info/top_level.txt,sha256=Ib4ZA2MPBpiT0tC-0qt5RcP9g42gLddRbx9PiYGa-Fc,6
26
+ firmwareloop-0.0.8.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ firmwareloop = tools.fw_mcp_server:main
3
+ fw = tools.fw_mcp_server:main
4
+ fw-mcp = tools.fw_mcp_server:main
5
+ fwloop = tools.fw_mcp_server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeffrey1799
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 @@
1
+ tools
tools/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """
2
+ FirmwareLoop - AI Agent Firmware Development and Lab Automation Platform.
3
+ """
4
+
5
+ __version__ = "0.0.8"