agentic-hil 0.2.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.
- agentic_hil-0.2.0/AGENTS.md +15 -0
- agentic_hil-0.2.0/AI_AGENT_QUICKSTART.md +122 -0
- agentic_hil-0.2.0/LICENSE +201 -0
- agentic_hil-0.2.0/MANIFEST.in +14 -0
- agentic_hil-0.2.0/PKG-INFO +236 -0
- agentic_hil-0.2.0/README.md +199 -0
- agentic_hil-0.2.0/SECURITY.md +29 -0
- agentic_hil-0.2.0/TROUBLESHOOTING.md +121 -0
- agentic_hil-0.2.0/examples/adapters/README.md +54 -0
- agentic_hil-0.2.0/examples/adapters/sim_ntc_adapter.py +105 -0
- agentic_hil-0.2.0/examples/pytest/test_ntc_diagnosis.py +52 -0
- agentic_hil-0.2.0/llms.txt +54 -0
- agentic_hil-0.2.0/pyproject.toml +90 -0
- agentic_hil-0.2.0/setup.cfg +4 -0
- agentic_hil-0.2.0/src/agentic_hil/__init__.py +7 -0
- agentic_hil-0.2.0/src/agentic_hil/__main__.py +4 -0
- agentic_hil-0.2.0/src/agentic_hil/cli.py +5 -0
- agentic_hil-0.2.0/src/agentic_hil/pytest_plugin.py +8 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/PKG-INFO +236 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/SOURCES.txt +59 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/dependency_links.txt +1 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/entry_points.txt +5 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/requires.txt +15 -0
- agentic_hil-0.2.0/src/agentic_hil.egg-info/top_level.txt +2 -0
- agentic_hil-0.2.0/src/hardci/__init__.py +30 -0
- agentic_hil-0.2.0/src/hardci/__main__.py +4 -0
- agentic_hil-0.2.0/src/hardci/adapters.py +245 -0
- agentic_hil-0.2.0/src/hardci/artifacts.py +328 -0
- agentic_hil-0.2.0/src/hardci/backends/__init__.py +4 -0
- agentic_hil-0.2.0/src/hardci/backends/common.py +127 -0
- agentic_hil-0.2.0/src/hardci/backends/gdbdebug.py +686 -0
- agentic_hil-0.2.0/src/hardci/backends/openocd.py +357 -0
- agentic_hil-0.2.0/src/hardci/backends/pyocd.py +287 -0
- agentic_hil-0.2.0/src/hardci/backends/stlink.py +281 -0
- agentic_hil-0.2.0/src/hardci/bridge.py +106 -0
- agentic_hil-0.2.0/src/hardci/can.py +356 -0
- agentic_hil-0.2.0/src/hardci/cli.py +386 -0
- agentic_hil-0.2.0/src/hardci/comports.py +330 -0
- agentic_hil-0.2.0/src/hardci/comstdio.py +97 -0
- agentic_hil-0.2.0/src/hardci/config.py +354 -0
- agentic_hil-0.2.0/src/hardci/debugger.py +62 -0
- agentic_hil-0.2.0/src/hardci/gdbmi.py +265 -0
- agentic_hil-0.2.0/src/hardci/mcp.py +216 -0
- agentic_hil-0.2.0/src/hardci/pytest_plugin.py +103 -0
- agentic_hil-0.2.0/src/hardci/report.py +74 -0
- agentic_hil-0.2.0/src/hardci/schemas/config.schema.json +161 -0
- agentic_hil-0.2.0/src/hardci/skills/hardci-config-setup/SKILL.md +22 -0
- agentic_hil-0.2.0/src/hardci/stdio.py +76 -0
- agentic_hil-0.2.0/src/hardci/templates/mcp.json +8 -0
- agentic_hil-0.2.0/src/hardci/tools.py +195 -0
- agentic_hil-0.2.0/src/hardci/types.py +129 -0
- agentic_hil-0.2.0/tests/conftest.py +68 -0
- agentic_hil-0.2.0/tests/fixtures/fake_gdb.py +108 -0
- agentic_hil-0.2.0/tests/fixtures/fake_openocd.py +46 -0
- agentic_hil-0.2.0/tests/fixtures/fake_pyocd.py +26 -0
- agentic_hil-0.2.0/tests/fixtures/fake_stlink.py +26 -0
- agentic_hil-0.2.0/tests/fixtures/fake_stlink_unconfirmed.py +11 -0
- agentic_hil-0.2.0/tests/test_debug_sessions.py +259 -0
- agentic_hil-0.2.0/tests/test_hardci.py +482 -0
- agentic_hil-0.2.0/tests/test_hardening.py +295 -0
- agentic_hil-0.2.0/tests/test_pytest_plugin.py +87 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Agentic HIL Agent Instructions
|
|
2
|
+
|
|
3
|
+
Agentic HIL is the hardware gate. The project-local `.hardci/config.yaml` is the policy. HardCI adapters are the reference hardware.
|
|
4
|
+
|
|
5
|
+
For installation and first-time setup, follow [AI_AGENT_QUICKSTART.md](AI_AGENT_QUICKSTART.md) — everything installs user-local without admin rights.
|
|
6
|
+
|
|
7
|
+
Use Agentic HIL MCP tools for hardware actions. Do not bypass them with raw OpenOCD commands, arbitrary debugger shells, direct serial-device access, direct CAN-adapter access, or direct test-adapter access when an Agentic HIL tool is available.
|
|
8
|
+
|
|
9
|
+
If a HardCI tool returns `permission_denied`, stop. Do not loosen policy unless the user explicitly asks.
|
|
10
|
+
|
|
11
|
+
Install or update the local agent setup skill with:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
agentic-hil skill-install --agent opencode
|
|
15
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# AI Agent Quickstart
|
|
2
|
+
|
|
3
|
+
Use Agentic HIL as the local MCP server for embedded firmware development and embedded hardware actions. HardCI adapters are the reference hardware.
|
|
4
|
+
|
|
5
|
+
This file is for agents. Humans should start with `README.md` and use `TROUBLESHOOTING.md` for operator-facing diagnostics.
|
|
6
|
+
|
|
7
|
+
If you were given only the Agentic HIL repository URL and asked to set it up: run the fast path below, install the Agentic HIL skill into your own skill directory, configure the firmware project, then return to the firmware project. Do not clone, checkout, or vendor the Agentic HIL source tree into the firmware project for normal setup.
|
|
8
|
+
|
|
9
|
+
## Ground Rules
|
|
10
|
+
|
|
11
|
+
- Never use `sudo` or any administrator privileges for the Agentic HIL installation. Every step below works user-local.
|
|
12
|
+
- Never use `pip install --break-system-packages`, and do not install into the system Python (PEP 668 environments will refuse, and they are right).
|
|
13
|
+
- If the board, debugger, COM port, or artifact path cannot be inferred, ask one concise question instead of guessing.
|
|
14
|
+
|
|
15
|
+
## Reference Setup
|
|
16
|
+
|
|
17
|
+
Prefer the supported first path unless the firmware project or user clearly says otherwise:
|
|
18
|
+
|
|
19
|
+
- STM32 Nucleo-F446RE (a complete demo lives in `examples/nucleo-f446re_demo/`).
|
|
20
|
+
- ST-Link with OpenOCD (`interface/stlink.cfg`, `target/stm32f4x.cfg`).
|
|
21
|
+
- Python 3.10 or newer.
|
|
22
|
+
- Firmware artifacts under `build/`.
|
|
23
|
+
|
|
24
|
+
## Start Agentic HIL
|
|
25
|
+
|
|
26
|
+
Fast path, in order — stop at the first step that works:
|
|
27
|
+
|
|
28
|
+
1. If `agentic-hil --version` works, do not reinstall.
|
|
29
|
+
2. If `uv` is available, run Agentic HIL without installing anything (no admin rights, no `PATH` changes):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uvx agentic-hil --version
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. If the PyPI package lookup fails, use the repository as the package source (this is a package source only — it does not create a checkout):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uvx --from git+https://github.com/agentic-hil/agentic-hil agentic-hil --version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
4. If `uv` is missing but `pipx` is available, the equivalents are `pipx run agentic-hil --version` and `pipx run --spec git+https://github.com/agentic-hil/agentic-hil agentic-hil --version`.
|
|
42
|
+
5. If neither `uv` nor `pipx` is available, install `uv` user-locally (no admin rights; installs to `~/.local/bin`):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh # Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
then rerun step 2. A missing runner is a remediable setup prerequisite, not a reason to refuse the Agentic HIL setup.
|
|
49
|
+
|
|
50
|
+
For the MCP server entry it is usually better to install the `agentic-hil` command persistently (still user-local, still no admin rights):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv tool install agentic-hil # or from the repository: uv tool install git+https://github.com/agentic-hil/agentic-hil
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`pipx install agentic-hil` is the equivalent. Both place `agentic-hil` into `~/.local/bin`; if that is not on `PATH`, fix it with `uv tool update-shell` or `pipx ensurepath` — never with admin rights.
|
|
57
|
+
|
|
58
|
+
## Install Agent Skill
|
|
59
|
+
|
|
60
|
+
Agent-driven Agentic HIL installation includes installing the bundled `hardci-config-setup` skill into the active agent's user-level skill directory after the CLI is available:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
agentic-hil skill-install --agent <agent> # or: uvx agentic-hil skill-install --agent <agent>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Supported agent names and aliases: `opencode`/`open-code`, `claude-code`/`claude`, `codex`/`codex-cli`/`openai-codex`. For other skill-capable agents use `--agent <name> --target <path>` with that agent's documented user-level skill directory. The CLI package is authoritative: if the installed skill's front-matter version differs from `agentic-hil --version`, rerun `skill-install`.
|
|
67
|
+
|
|
68
|
+
## Configure Each Project
|
|
69
|
+
|
|
70
|
+
In every firmware project that should use Agentic HIL:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
agentic-hil init # writes the starter .hardci/config.yaml
|
|
74
|
+
# edit .hardci/config.yaml: target, debugger configs, allowed artifact roots,
|
|
75
|
+
# named com_ports / can_buses / adapters — keep the safety policy restrictive
|
|
76
|
+
agentic-hil doctor # validates config and checks the debugger
|
|
77
|
+
agentic-hil mcp-config --output .mcp.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Keep `.hardci/` with the project: it defines that project's hardware policy, reports, logs, and allowed artifact locations. Do not reinstall Agentic HIL inside every project.
|
|
81
|
+
|
|
82
|
+
Expected healthy `agentic-hil doctor` result: `ok: true`, `summary: "HardCI configuration loaded and debugger checked."`, and a nested debugger result with `ok: true`.
|
|
83
|
+
|
|
84
|
+
## Configure MCP
|
|
85
|
+
|
|
86
|
+
`.mcp.json` is only the MCP launch entry. The default written by `agentic-hil mcp-config` assumes `agentic-hil` is on `PATH`:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"agentic-hil": {
|
|
92
|
+
"command": "agentic-hil",
|
|
93
|
+
"args": ["mcp-stdio", "--config", ".hardci/config.yaml"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
If `agentic-hil` is not on `PATH`, use the runner form instead: `"command": "uvx", "args": ["agentic-hil", "mcp-stdio", "--config", ".hardci/config.yaml"]`.
|
|
100
|
+
|
|
101
|
+
`mcp-stdio` is project-scoped and JSON-RPC only. COM tool calls pass `port_id`, CAN tool calls pass `bus_id`, and test-adapter tool calls pass `adapter_id` as tool arguments. For a continuous plain-text serial channel use a separate `agentic-hil com-stdio --config .hardci/config.yaml --port <port_id>` process — never mix plain text into `mcp-stdio`.
|
|
102
|
+
|
|
103
|
+
## Use The Tools
|
|
104
|
+
|
|
105
|
+
Use `tools/list` to discover available MCP tools, then follow this loop:
|
|
106
|
+
|
|
107
|
+
1. Build firmware.
|
|
108
|
+
2. Check debugger availability with `hardci_debugger_info` if setup is unclear.
|
|
109
|
+
3. Probe with `hardci_probe_target`.
|
|
110
|
+
4. Flash with `hardci_flash_firmware` using `image_path` (usually `build/firmware.elf`), or first call `hardci_artifact_upload` and flash the returned `artifact_id`. Pass `reset_after_flash: true` only when a post-flash reset is explicitly needed.
|
|
111
|
+
5. For serial feedback: `hardci_com_session_start`, stimulate with `hardci_com_write`, read with `hardci_com_read`, stop with `hardci_com_session_stop`.
|
|
112
|
+
6. For CAN: `hardci_can_session_start`, `hardci_can_send`, `hardci_can_read`, `hardci_can_session_stop`.
|
|
113
|
+
7. For simulated sensors, loads, and fault states: `hardci_adapter_session_start`, `hardci_adapter_set_value`, `hardci_adapter_inject_fault`, `hardci_adapter_measure`, `hardci_adapter_clear_fault`, `hardci_adapter_session_stop`.
|
|
114
|
+
8. Read the tool result and `hardci_get_last_report`; diagnose failures with `hardci_classify_last_error`.
|
|
115
|
+
|
|
116
|
+
Healthy probe and flash signals: `target_detected: true`, `success_confirmed: true`, `verify: true`, an intentional `reset_after_flash` value, plus `report_path` and `log_path` for auditability.
|
|
117
|
+
|
|
118
|
+
Do not use raw OpenOCD commands, arbitrary COM-port shell tools, direct CAN adapter tools, or direct test-adapter access when an Agentic HIL MCP tool is available. Treat `permission_denied` as authoritative and stop.
|
|
119
|
+
|
|
120
|
+
## pytest Suites
|
|
121
|
+
|
|
122
|
+
For CI regression suites the installed package registers a pytest plugin: the `agentic_hil` fixture drives the same tools via `agentic_hil.call(name, arguments)`. Tests skip when no `.hardci/config.yaml` exists and fail loudly when the config is invalid. See `examples/pytest/` and `examples/nucleo-f446re_demo/tests/`.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Hannes Pauli
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include AGENTS.md
|
|
3
|
+
include AI_AGENT_QUICKSTART.md
|
|
4
|
+
include TROUBLESHOOTING.md
|
|
5
|
+
include SECURITY.md
|
|
6
|
+
include llms.txt
|
|
7
|
+
include LICENSE
|
|
8
|
+
recursive-include src/hardci/schemas *.json
|
|
9
|
+
recursive-include src/hardci/templates *.json
|
|
10
|
+
recursive-include src/hardci/skills *.md
|
|
11
|
+
recursive-include tests *.py
|
|
12
|
+
recursive-include examples *.py *.md
|
|
13
|
+
# The firmware demo is repository content, not package content.
|
|
14
|
+
prune examples/nucleo-f446re_demo
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentic-hil
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Agentic hardware-in-the-loop tools for AI-assisted embedded firmware loops
|
|
5
|
+
Author-email: Hannes Pauli <mail@hannes-pauli.de>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/agentic-hil/agentic-hil
|
|
8
|
+
Project-URL: Repository, https://github.com/agentic-hil/agentic-hil.git
|
|
9
|
+
Project-URL: Issues, https://github.com/agentic-hil/agentic-hil/issues
|
|
10
|
+
Keywords: mcp,model-context-protocol,embedded,hardware-in-the-loop,openocd,firmware,serial,stlink,debugger,agentic-hil,agentic,hardci,stm32
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
20
|
+
Classifier: Topic :: Software Development :: Testing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: jsonschema>=4.22
|
|
25
|
+
Requires-Dist: PyYAML>=6.0
|
|
26
|
+
Requires-Dist: pyserial>=3.5
|
|
27
|
+
Provides-Extra: can
|
|
28
|
+
Requires-Dist: python-can>=4.4; extra == "can"
|
|
29
|
+
Provides-Extra: pyocd
|
|
30
|
+
Requires-Dist: pyocd>=0.36; extra == "pyocd"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
35
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Agentic HIL
|
|
39
|
+
|
|
40
|
+
**Your AI agent can develop firmware on its own — because Agentic HIL closes the loop with real hardware.**
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
+--> build --> flash --> stimulate --> observe --+
|
|
44
|
+
| |
|
|
45
|
+
+<-------------- diagnose & fix -----------------+
|
|
46
|
+
|
|
47
|
+
your agent, unattended -- you review the pull request
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Agentic HIL is a Python package that exposes bounded MCP tools for probing, flashing, resetting, artifact validation, serial and CAN stimulus/feedback, test adapters, reports, and logs — without giving an agent arbitrary host or debugger access. A project-local policy file (`.hardci/config.yaml`) defines exactly which devices, actions, paths, and limits are allowed. That policy gate is what makes unattended hardware access workable in the first place.
|
|
51
|
+
|
|
52
|
+
HardCI adapters are the reference hardware for Agentic HIL: physical pytest fixtures for sensor simulation, loads, and fault injection.
|
|
53
|
+
|
|
54
|
+
## Why
|
|
55
|
+
|
|
56
|
+
A green build is not enough in embedded development: firmware has to behave correctly on the real board. Classic tools automate single steps — flash here, read a log there — but the moment real hardware has to respond, a human is back in the loop. Handing an agent a raw debugger shell or direct serial access instead is neither safe nor reproducible. Agentic HIL closes the gap with a small, auditable gate:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
AI agent / CI ──MCP (stdio)──▶ Agentic HIL ──policy check──▶ OpenOCD / pyOCD / STM32CubeProgrammer
|
|
60
|
+
│ serial ports (pyserial)
|
|
61
|
+
│ CAN (PEAK / SocketCAN / bridge)
|
|
62
|
+
▼
|
|
63
|
+
structured results, reports, logs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every hardware action is validated against the project policy, executed with timeouts, logged to `.hardci/logs/`, and answered with a structured JSON result (`ok`, `error_type`, `summary`, `likely_causes`, `report_path`, `log_path`) that an agent can act on.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
The easiest path: tell your AI agent
|
|
71
|
+
|
|
72
|
+
> Install Agentic HIL and set it up for this project.
|
|
73
|
+
|
|
74
|
+
Agents follow [AI_AGENT_QUICKSTART.md](AI_AGENT_QUICKSTART.md) — everything installs user-local, **no admin rights required, ever**.
|
|
75
|
+
|
|
76
|
+
By hand, without installing anything (no `PATH` changes; needs [uv](https://docs.astral.sh/uv/) or pipx):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
uvx agentic-hil --version
|
|
80
|
+
uvx --from git+https://github.com/agentic-hil/agentic-hil agentic-hil --version
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Persistent user-local install (recommended for the MCP server entry):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
uv tool install agentic-hil # or: pipx install agentic-hil
|
|
87
|
+
agentic-hil init
|
|
88
|
+
agentic-hil doctor
|
|
89
|
+
agentic-hil mcp-config --output .mcp.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For direct PEAK/SocketCAN access install the CAN extra: `uv tool install 'agentic-hil[can]'`. See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) when something does not start.
|
|
93
|
+
|
|
94
|
+
## MCP Entry
|
|
95
|
+
|
|
96
|
+
Project-local `.mcp.json`:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"agentic-hil": {
|
|
102
|
+
"command": "agentic-hil",
|
|
103
|
+
"args": ["mcp-stdio", "--config", ".hardci/config.yaml"]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
`agentic-hil init` writes a starter `.hardci/config.yaml`. The file is the policy — it names the target, the debugger backend, allowed artifact roots, named serial ports and CAN buses, and per-action permissions:
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
target:
|
|
115
|
+
name: "sensor-board"
|
|
116
|
+
controller: "stm32f4"
|
|
117
|
+
|
|
118
|
+
debugger:
|
|
119
|
+
type: "openocd" # or "pyocd" (most Cortex-M targets), or "stlink" (STM32CubeProgrammer CLI)
|
|
120
|
+
interface_cfg: "interface/stlink.cfg"
|
|
121
|
+
target_cfg: "target/stm32f4x.cfg"
|
|
122
|
+
timeout_s: 60
|
|
123
|
+
|
|
124
|
+
artifacts:
|
|
125
|
+
allowed_roots: ["build"] # firmware may only be flashed from here
|
|
126
|
+
allowed_extensions: [".elf", ".hex", ".bin"]
|
|
127
|
+
|
|
128
|
+
com_ports:
|
|
129
|
+
dut_uart:
|
|
130
|
+
device: "/dev/ttyACM0"
|
|
131
|
+
baudrate: 115200
|
|
132
|
+
|
|
133
|
+
can_buses:
|
|
134
|
+
dut_can:
|
|
135
|
+
adapter: "socketcan" # or "peak", or "process" for a custom bridge
|
|
136
|
+
channel: "can0"
|
|
137
|
+
bitrate: 500000
|
|
138
|
+
|
|
139
|
+
adapters:
|
|
140
|
+
ntc_sim: # sensor/actuator/fault-simulation bridge
|
|
141
|
+
executable: "examples/adapters/sim_ntc_adapter.py"
|
|
142
|
+
channels: ["temperature", "resistance"]
|
|
143
|
+
faults: ["open", "short_to_gnd", "short_to_vcc"]
|
|
144
|
+
|
|
145
|
+
permissions:
|
|
146
|
+
allow_flash: true
|
|
147
|
+
allow_com_write: true
|
|
148
|
+
allow_can_write: true
|
|
149
|
+
allow_adapter_write: true
|
|
150
|
+
allow_raw_debugger_commands: false
|
|
151
|
+
allow_mass_erase: false
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Export the full JSON schema with `agentic-hil schema --output agentic-hil-config.schema.json`.
|
|
155
|
+
|
|
156
|
+
## MCP Tools
|
|
157
|
+
|
|
158
|
+
| Group | Tools | Notes |
|
|
159
|
+
|-------|-------|-------|
|
|
160
|
+
| Debugger | `hardci_debugger_info`, `hardci_probe_target`, `hardci_reset_target` | OpenOCD, pyOCD, or STM32CubeProgrammer CLI |
|
|
161
|
+
| Firmware | `hardci_flash_firmware`, `hardci_artifact_upload` | artifacts are validated (path, extension, format, SHA-256) before flashing; post-flash reset requires `reset_after_flash: true` |
|
|
162
|
+
| Serial | `hardci_com_ports_list`, `hardci_com_session_start`, `hardci_com_session_stop`, `hardci_com_write`, `hardci_com_read` | named ports only, buffered background reader |
|
|
163
|
+
| CAN | `hardci_can_buses_list`, `hardci_can_session_start`, `hardci_can_session_stop`, `hardci_can_send`, `hardci_can_read` | PEAK, SocketCAN, or a process bridge |
|
|
164
|
+
| Test adapters | `hardci_adapters_list`, `hardci_adapter_session_start`, `hardci_adapter_session_stop`, `hardci_adapter_set_value`, `hardci_adapter_inject_fault`, `hardci_adapter_clear_fault`, `hardci_adapter_measure` | sensor/actuator/fault simulation via the [adapter bridge protocol](examples/adapters/README.md) |
|
|
165
|
+
| Diagnostics | `hardci_get_last_report`, `hardci_classify_last_error` | structured error classification with likely causes |
|
|
166
|
+
| Debug sessions | `hardci_debug_*` (start/stop/status, breakpoints, continue/halt, symbol info, memory dump) | typed GDB/MI sessions via the OpenOCD backend's gdbserver; unexpected breakpoints and target exceptions are returned as structured stop reasons; symbol allowlist and dump-size limits come from the `debug:` policy section |
|
|
167
|
+
|
|
168
|
+
A typical loop: build firmware → `hardci_flash_firmware` with `reset_after_flash: true` when a fresh boot is required → `hardci_com_session_start` → stimulate via `hardci_com_write`/`hardci_can_send`/`hardci_adapter_set_value` → assert on `hardci_com_read`/`hardci_can_read`/`hardci_adapter_measure` → on failure, `hardci_classify_last_error`.
|
|
169
|
+
|
|
170
|
+
## Test Adapters
|
|
171
|
+
|
|
172
|
+
Real-world firmware bugs show up under electrical conditions that standard lab tools cannot reproduce on demand: an open or shorted sensor, a drifting NTC, a missing load, a bouncing contact. The `adapters:` section connects HardCI to test adapters that simulate exactly these states — physical adapter hardware or pure-software simulators, both speaking the same [JSON bridge protocol](examples/adapters/README.md).
|
|
173
|
+
|
|
174
|
+
Example diagnosis loop with the bundled NTC simulator (`examples/adapters/sim_ntc_adapter.py`): flash the firmware, set the simulated sensor to 25 °C and assert nominal behavior, inject an `open` fault and assert the firmware reports the sensor failure, clear the fault and assert recovery — every step automated, reproducible, and policy-gated.
|
|
175
|
+
|
|
176
|
+
## Safety Model
|
|
177
|
+
|
|
178
|
+
- The agent never gets a shell, a raw debugger, or a device path — only the named, configured resources.
|
|
179
|
+
- Firmware artifacts must live under `artifacts.allowed_roots`, match an allowed extension, pass format plausibility checks, and are hashed before flashing. Path traversal is rejected.
|
|
180
|
+
- Permission switches gate high-risk action classes; `permission_denied` results are authoritative and agents are instructed to stop (see [AGENTS.md](AGENTS.md)).
|
|
181
|
+
- Deliberate interlock: flashing is refused while `allow_raw_debugger_commands` or `allow_mass_erase` is enabled — validated flashing and unrestricted debugger access are mutually exclusive policies.
|
|
182
|
+
- Serial/CAN writes are size-capped (`max_write_bytes`, `max_frame_data_bytes`); reads are buffer-capped. Debugger calls run with timeouts and TCP servers disabled (OpenOCD `gdb_port`/`tcl_port`/`telnet_port disabled`); only a typed debug session opens a `gdb_port`, bound to `localhost` on an ephemeral port for exactly that session, and it is torn down with the session.
|
|
183
|
+
- Test adapter channels and fault names are explicit allowlists — HardCI rejects anything not named in the config before it reaches the adapter bridge.
|
|
184
|
+
- All actions log to `.hardci/logs/` and write a structured report to `.hardci/reports/`.
|
|
185
|
+
|
|
186
|
+
## pytest Plugin
|
|
187
|
+
|
|
188
|
+
Installing `agentic-hil` registers a pytest plugin, so CI regression suites can drive the same policy-gated tools without an MCP client:
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
def test_open_sensor_diagnosis(agentic_hil):
|
|
192
|
+
started = agentic_hil.call("hardci_adapter_session_start", {"adapter_id": "ntc_sim"})
|
|
193
|
+
assert started["ok"] is True
|
|
194
|
+
injected = agentic_hil.call("hardci_adapter_inject_fault", {"adapter_id": "ntc_sim", "fault": "open"})
|
|
195
|
+
assert injected["ok"] is True
|
|
196
|
+
# ...assert the firmware's reaction via hardci_com_read...
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The `agentic_hil` fixture loads `.hardci/config.yaml` relative to the pytest rootdir (override with `--hardci-config` or the `hardci_config` ini option). Tests are skipped when no configuration file exists, but an existing invalid configuration fails loudly — a config typo must not silently disable the hardware suite in CI. Adapter, COM, and CAN sessions opened during a test are stopped afterwards so stimulus state cannot leak between tests. See [examples/pytest/](examples/pytest/) for a full diagnosis-loop example, and [examples/nucleo-f446re_demo/](examples/nucleo-f446re_demo/) for the complete loop on real hardware: a bare-metal STM32 firmware that is built, flashed, reset, and asserted on via its UART boot banner.
|
|
200
|
+
|
|
201
|
+
## Common Commands
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
agentic-hil init
|
|
205
|
+
agentic-hil doctor
|
|
206
|
+
agentic-hil com-ports
|
|
207
|
+
agentic-hil mcp-config --output .mcp.json
|
|
208
|
+
agentic-hil mcp-stdio --config .hardci/config.yaml
|
|
209
|
+
agentic-hil com-stdio --config .hardci/config.yaml --port dut_uart
|
|
210
|
+
agentic-hil schema --output agentic-hil-config.schema.json
|
|
211
|
+
agentic-hil skill-install --agent opencode
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Platform Support
|
|
215
|
+
|
|
216
|
+
Linux, macOS, and Windows (CI-tested on Python 3.10–3.13). Debugger backends: OpenOCD, pyOCD (`agentic-hil[pyocd]` — covers most ARM Cortex-M targets via CMSIS packs and CMSIS-DAP/ST-Link/J-Link probes, set `debugger.target_type`), and STM32CubeProgrammer CLI (auto-discovered on Windows). Direct CAN requires `agentic-hil[can]` (python-can); any other adapter can be attached through the `process` bridge protocol.
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python -m pip install -e '.[dev]'
|
|
222
|
+
ruff check src tests
|
|
223
|
+
pytest
|
|
224
|
+
python -m build
|
|
225
|
+
twine check dist/*
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The package is configured for PyPI publishing through GitHub trusted publishing in `.github/workflows/workflow.yml`.
|
|
229
|
+
|
|
230
|
+
## Security
|
|
231
|
+
|
|
232
|
+
Policy bypasses are treated as vulnerabilities — see [SECURITY.md](SECURITY.md).
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
Apache-2.0 — see [LICENSE](LICENSE).
|