Skip to content

工具 CLI

tools/ 下是确定性脚本(纯 Python / shell,无 LLM 依赖)。skill 调用它们做生成与校验;你也可以直接命令行跑。一键全验:sh tools/selftest.sh

gen_protocol.py

contracts/protocol.yaml 生成 C(protocol.h) 与 Python(protocol.py) 两端,并自检两端签名一致。

bash
python3 tools/gen_protocol.py [contracts/protocol.yaml]
# 输出:协议签名 yaml=… protocol.h=… protocol.py=…  ✓ 两端一致,共 N 帧

改协议后必须跑它。

pinmux_check.py

校验引脚映射:引脚冲突 / 功能非法 / 外设超限 → 退出码 1(FAIL)。

bash
python3 tools/pinmux_check.py contracts/pinmap.yaml [contracts/mcu/<MCU>.yaml]
# PASS → exit 0;冲突/非法 → 打印问题 + exit 1

power_budget.py

电机堵转电流(非标称)算每条轨负载,校验稳压余量,欠流 → FAIL。

bash
python3 tools/power_budget.py design/power.yaml
# 打印每轨 实测/含余量/稳压/判定;某轨欠流 → ✗ FAIL(防掉电复位)

render_wiring.py

pinmap.yaml 渲成接线图(Graphviz DOT/SVG)+ Markdown 接线表。

bash
python3 tools/render_wiring.py contracts/pinmap.yaml design/wiring
# → design/wiring.dot + design/harness.md(+ wiring.svg,若装了 graphviz dot)

jlc_search.py

配件表缺口时按规格现查 JLC 在库件(走 tscircuit 社区镜像;联网,离线优雅降级)。

bash
python3 tools/jlc_search.py "TB6612" --limit 5
# LCSC 141517 | SSOP-24 | 库存 3148 | ¥0.972@1+ | TB6612FNG

board.py

git 背书任务板 + 流水线 DAG 自动派活。

bash
python3 tools/board.py init                  # 建根任务 read-problem
python3 tools/board.py list [--lane 控制]     # 列就绪任务(依赖已全 done)
python3 tools/board.py done <id> [--by 控制]  # 标完成 + 自动给下游 lane 派活
python3 tools/board.py status                # 全局看板

selftest.sh

一键自测,9 项全绿才算环境/契约都正常。

bash
sh tools/selftest.sh
# 1 协议两端一致  2 pinmux 门  3 供电门  4 接线渲染
# 5 固件主机测试  6 跨语言契约  7 driver/app 语法  8 视觉 py_compile  9 任务板 DAG

bootstrap.sh / watch.sh

bash
sh tools/bootstrap.sh            # 装 host Python 依赖(pyyaml/requests/pdfplumber)
sh tools/watch.sh <lane> [秒]     # 纯终端轮询任务板(/board 的非 Claude 版)