Initial release: airsdb

This commit is contained in:
admin
2026-05-18 11:45:06 +08:00
commit f3464e0006
8 changed files with 1271 additions and 0 deletions

77
commands/airsdb.md Normal file
View File

@@ -0,0 +1,77 @@
---
description: Enter, inspect, run, or remote-run AirSDB cppcheck static analysis with exhaustive branch checking
argument-hint: [enter|setup|status|scan|command|remote-setup|remote-status|remote-command|remote-scan|exit]
allowed-tools: [Read, Glob, Grep, Bash, Write, Edit]
---
# /airsdb
控制当前工作区的 AirSDB 静态分析模式。
用户传入参数:`$ARGUMENTS`
- `enter` 或空参数:进入 AirSDB 模式,初始化 `AirPlan/docs/staticanalysis.md` 并检测 cppcheck。
- `setup`:检测/自动配置本机 cppcheck。
- `status`:检查 AirSDB 状态和本机 cppcheck不自动安装。
- `command`:生成本机 cppcheck 命令,不实际执行。
- `scan`:运行本机 cppcheck生成 XML/JSON 并更新 `AirPlan/docs/staticanalysis.md`
- `remote-setup`:检查远程 SSH 和远端 cppcheck缺失时自动尝试配置。
- `remote-status`:只检查远程配置和工具状态,不自动安装。
- `remote-command`:生成远程 cppcheck 命令,不实际执行。
- `remote-scan`:通过 SSH 在远端运行 cppcheck拉回报告并更新 `AirPlan/docs/staticanalysis.md`
- `exit`:退出 AirSDB 模式。
## 执行步骤
1. 解析 `$ARGUMENTS`,默认动作为 `enter`
2. `enter` / `setup` / `status` / `exit` 时运行:
```bash
python "$HOME/plugins/airsdb/scripts/airsdb_mode.py" --mode <enter|setup|status|exit> --project .
```
如果 `python` 不存在,尝试 `py``python3` 或用户提供的 Python 绝对路径。
3. 本机 `command` / `scan` 时运行:
```bash
python "$HOME/plugins/airsdb/scripts/airsdb_cppcheck.py" --project . --action <command|scan>
```
本机 scan 会优先使用 `compile_commands.json`,否则扫描当前项目并排除常见噪声目录;默认带 `--check-level=exhaustive` 以提供尽可能详细的分支分析信息。结果写入 `AirPlan/state/airsdb/reports/`,摘要写入 `AirPlan/docs/staticanalysis.md`
4. 如果 `$ARGUMENTS` 包含 `remote``ssh``远程`或用户说明目标代码在远程设备、测试机、服务器、VM、容器宿主机或 SSH 主机上,优先运行远程 helper
```bash
python "$HOME/plugins/airsdb/scripts/airsdb_remote_device.py" --project . --action <setup|status|command|scan>
```
首次缺少远程配置时helper 会生成 `AirPlan/state/airsdb/remote-device.env.example` 并提示设置 `AIRSDB_REMOTE_SSH_TARGET``AIRSDB_REMOTE_PROJECT`。有 SSH 目标后helper 会探测远端 cppcheck缺失时自动尝试安装只使用非交互式 `sudo -n`,无法自动配置时停止并提示用户。远程 scan 同样默认带 `--check-level=exhaustive`
5. 每次 scan 后必须检查并维护:
- `AirPlan/docs/staticanalysis.md`
- `AirPlan/state/airsdb/reports/<timestamp>-cppcheck.xml`
- `AirPlan/state/airsdb/reports/<timestamp>-cppcheck.json`
- 必要时更新 `AGENTS.md`、ADR、C4 module
## 输出文案
进入模式:
```text
AirSDB 模式已开启:已初始化或检查 `AirPlan/docs/staticanalysis.md`,并检测 cppcheck。可运行本机 scan也可在远程目标上使用 remote device helper 自动检测/配置 cppcheck本机和远程 scan 默认使用 `--check-level=exhaustive`。
```
扫描完成:
```text
AirSDB 静态分析完成XML/JSON 报告已写入 `AirPlan/state/airsdb/reports/`,简短 AI 上下文已追加到 `AirPlan/docs/staticanalysis.md`,可交给 AirDbg 或 AirDo 使用。
```
状态检查:
```text
AirSDB 状态:<enabled|disabled>
cppcheck<ok|blocked>
关键文件:逐项列出 ok/missing。
```