Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions OpenHW-studio-frontend-danish/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 68 additions & 5 deletions openhw-studio-cli-danish/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
# OpenHW Studio CLI

Terminal-first CLI for OpenHW Studio project management, headless simulation, serial monitoring, and library management.
Expand Down Expand Up @@ -54,6 +53,10 @@ npm run cli -- project connect temp/project.json --from board1:GND --to led1:C
# Update board code (inline or file)
npm run cli -- project set-code temp/project.json --board-id board1 --code-file examples/blink.ino

# Set block-coding metadata (Blockly XML + generated code preference)
npm run cli -- project set-blockly temp/project.json --xml-file temp/workspace.xml --generated-code-file temp/generated.cpp --use-blockly-code true
npm run cli -- project block-summary temp/project.json

# Update project/library.txt from a text file
npm run cli -- project set-library-file temp/project.json --input temp/libs.txt
```
Expand Down Expand Up @@ -98,6 +101,15 @@ npm run cli -- sim screenshot temp/project.json --duration-ms 1200 --output out/
# Inspect input/output component automation templates
npm run cli -- sim capabilities temp/project.json --json

# Probe one component with diffed before/after state + pin/display behavior
npm run cli -- sim probe temp/project.json --component-id ldr1 --event SET_ATTR --key lux --value 700 --assertions-file temp/assertions.yaml

# Display-focused normalized state capture for AI agents
npm run cli -- sim display temp/project.json --duration-ms 1500 --output out/display.json

# Multi-step scenario with timed inputs and assertions
npm run cli -- sim scenario temp/project.json --scenario scenarios/sensor-check.yaml --output out/scenario-report.json

# Print simulation-focused summary and validation
npm run cli -- sim summary temp/project.json
```
Expand Down Expand Up @@ -126,7 +138,16 @@ npm run cli -- mcp serve
npm run cli -- mcp serve --auth-token local-dev-token
```

MCP tools now include `sim_execute`, `sim_trace`, and `sim_inspect` with support for debug/GDB trace capture (`debug_mode`, `include_trace`) and simulation console capture (`include_console`) without polluting stdio transport.
MCP tools now include `sim_execute`, `sim_trace`, `sim_inspect`, `simulation_step`, and `simulation_assert` with support for debug/GDB trace capture (`debug_mode`, `include_trace`) and simulation console capture (`include_console`) without polluting stdio transport.

Additional MCP lifecycle and diagnostics tools:
- `project_open` (set active session from an existing project file)
- `project_status` (active session state + summary)
- `project_validate` (schema/reference validation for active session)
- `component_catalog` (discover component capabilities/pins/onEvent/telemetry metadata)
- `simulation_capabilities` (project-scoped observability and interaction affordances for AI agents)
- `component_input_schema` (event templates + sensor profiles per component instance)
- `wiring_validate` (dry-run endpoint/wire validation without project mutation)

### Library management

Expand All @@ -138,6 +159,40 @@ npm run cli -- lib uninstall "Adafruit NeoPixel"
npm run cli -- lib sync-project temp/project.json --dry-run
```

### Advanced MCP testing + behavior reports

```bash
# MCP response contract coverage (positive + negative paths)
npm run test:mcp:contracts

# Validate block-coding project workflow through CLI
npm run test:cli:block-coding

# Deterministic scenario runner dry-run (YAML/JSON manifest parse + wiring diagnostics + report export)
npm run test:mcp:scenario

# Dry-run fixture coverage for display-heavy and sensor-heavy projects
npm run test:mcp:scenario:display
npm run test:mcp:scenario:sensor

# Full runtime scenario execution (requires simulation dependencies/backend)
npm run test:mcp:scenario:full

# Override scenario/report paths
node scripts/mcp-scenario-runner.mjs \
--scenario scenarios/pico-led-lifecycle.yaml \
--output-json temp/mcp-scenario-report.json \
--output-md temp/mcp-scenario-report.md \
--baseline temp/mcp-scenario-report-baseline.json
```

The scenario runner report includes:
- per-component state timeline (`trace.componentTimeline`)
- board pin activity timeline (`trace.boardPinTimeline`)
- wire/connectivity diagnostics (`wiring`)
- serial + telemetry + trace correlation (`serial`, `telemetry`, `trace`)
- optional behavior-diff gate against a baseline report (`--baseline`)

### Interactive REPL

```bash
Expand All @@ -155,6 +210,14 @@ npm run cli -- repl
- `sim interact` can inject component events for interactive parts (e.g. LDR, potentiometer, pushbutton).
- `mcp serve` starts a local Model Context Protocol server over stdio, including simulation trace/inspect tools for remote automation.
- Default backend URL is `http://localhost:5001/api` and can be overridden with `--backend-url`.
=======
# OpenHW-studio--cli
>>>>>>> origin/develop

## MCP CLI completion checklist

- [x] Project lifecycle tools: init/open/status/validate
- [x] Component catalog/discovery with pin and capability metadata
- [x] Dry-run wiring validation diagnostics before mutation
- [x] Simulation execution, trace capture, and inspect/event injection
- [x] Scenario-driven test runner with JSON/YAML manifests
- [x] Unified report export in JSON + human-readable Markdown
- [x] Contract tests for MCP tool response shape + negative cases
- [x] Pico component matrix scripts for broad and per-component coverage
20 changes: 17 additions & 3 deletions openhw-studio-cli-danish/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions openhw-studio-cli-danish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
"mcp": "tsx src/cli.ts mcp serve",
"typecheck": "tsc --noEmit",
"test:mcp:smoke": "node scripts/mcp-smoke.mjs",
"test:mcp:pico-all-components": "node scripts/test-mcp-pico-all-components.mjs"
"test:mcp:pico-all-components": "node scripts/test-mcp-pico-all-components.mjs",
"test:mcp:pico-components-individual": "node scripts/test-mcp-pico-components-individual.mjs",
"test:mcp:contracts": "node scripts/test-mcp-contracts.mjs",
"test:mcp:scenario": "node scripts/mcp-scenario-runner.mjs --scenario scenarios/pico-led-lifecycle.yaml --dry-run",
"test:mcp:scenario:full": "node scripts/mcp-scenario-runner.mjs --scenario scenarios/pico-led-lifecycle.yaml",
"test:mcp:scenario:display": "node scripts/mcp-scenario-runner.mjs --scenario scenarios/pico-display-observability.yaml --dry-run",
"test:mcp:scenario:sensor": "node scripts/mcp-scenario-runner.mjs --scenario scenarios/pico-sensor-observability.yaml --dry-run",
"test:cli:block-coding": "node scripts/test-cli-block-coding.mjs"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",
"commander": "^12.1.0",
"serialport": "^12.0.0"
"serialport": "^12.0.0",
"yaml": "^2.8.3"
},
"devDependencies": {
"@types/node": "^22.10.1",
Expand Down
34 changes: 34 additions & 0 deletions openhw-studio-cli-danish/scenarios/pico-display-observability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: pico-display-observability
board: wokwi-raspberry-pi-pico
durationMs: 1800
envs:
- key: native
boardEnv: native
ms: 1800
components:
- type: wokwi-ssd1306-oled
id: oled1
x: 300
y: 120
- type: wokwi-led
id: led1
x: 360
y: 220
wires:
- from: board1:GP0
to: oled1:SDA
- from: board1:GP1
to: oled1:SCL
- from: board1:3V3
to: oled1:VCC
- from: board1:GND
to: oled1:GND
- from: board1:GP2
to: led1:A
- from: board1:GND
to: led1:K
inspect:
- id: oled1
includeTrace: true
includeConsole: false
traceEventTypes: [state, serial, fault, debug]
46 changes: 46 additions & 0 deletions openhw-studio-cli-danish/scenarios/pico-led-lifecycle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: pico-led-lifecycle
board: wokwi-raspberry-pi-pico
durationMs: 1800
traceEventTypes:
- state
- serial
- fault
- debug
envs:
- key: micropython
boardEnv: micropython
ms: 2200
codeFile: project/board1/main.py
source: |
from machine import Pin
from time import sleep
led = Pin(25, Pin.OUT)
print("MCP_SCENARIO_MP_BOOT")
for i in range(8):
led.value(i % 2)
print("MCP_SCENARIO_MP_STEP", i)
sleep(0.05)
- key: circuitpython
boardEnv: circuitpython
ms: 2600
codeFile: project/board1/code.py
source: |
import time
print("MCP_SCENARIO_CP_BOOT")
for i in range(8):
print("MCP_SCENARIO_CP_STEP", i)
time.sleep(0.05)
components:
- type: wokwi-led
id: led1
x: 360
y: 120
wires:
- from: board1:GP2
to: led1:A
- from: board1:GND
to: led1:K
inspect:
- id: led1
ms: 1200
includeTrace: true
44 changes: 44 additions & 0 deletions openhw-studio-cli-danish/scenarios/pico-sensor-observability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: pico-sensor-observability
board: wokwi-raspberry-pi-pico
durationMs: 2000
envs:
- key: native
boardEnv: native
ms: 2000
components:
- type: wokwi-ldr-module
id: ldr1
x: 300
y: 120
- type: wokwi-slide-potentiometer
id: pot1
x: 300
y: 240
wires:
- from: board1:GP26
to: ldr1:AO
- from: board1:3V3
to: ldr1:VCC
- from: board1:GND
to: ldr1:GND
- from: board1:GP27
to: pot1:SIG
- from: board1:3V3
to: pot1:VCC
- from: board1:GND
to: pot1:GND
inspect:
- id: ldr1
includeTrace: true
event:
type: SET_ATTR
key: lux
value: 650
atMs: 300
- id: pot1
includeTrace: true
event:
type: input
value: 75
atMs: 700
traceEventTypes: [state, serial, fault, debug]
Loading
Loading