Files
airsdb/commands/airsdb.md
2026-05-18 11:45:06 +08:00

3.5 KiB
Raw Blame History

description, argument-hint, allowed-tools
description argument-hint allowed-tools
Enter, inspect, run, or remote-run AirSDB cppcheck static analysis with exhaustive branch checking
enter|setup|status|scan|command|remote-setup|remote-status|remote-command|remote-scan|exit
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 时运行:
python "$HOME/plugins/airsdb/scripts/airsdb_mode.py" --mode <enter|setup|status|exit> --project .

如果 python 不存在,尝试 pypython3 或用户提供的 Python 绝对路径。

  1. 本机 command / scan 时运行:
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

  1. 如果 $ARGUMENTS 包含 remotessh远程或用户说明目标代码在远程设备、测试机、服务器、VM、容器宿主机或 SSH 主机上,优先运行远程 helper
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_TARGETAIRSDB_REMOTE_PROJECT。有 SSH 目标后helper 会探测远端 cppcheck缺失时自动尝试安装只使用非交互式 sudo -n,无法自动配置时停止并提示用户。远程 scan 同样默认带 --check-level=exhaustive

  1. 每次 scan 后必须检查并维护:
    • AirPlan/docs/staticanalysis.md
  • AirPlan/state/airsdb/reports/<timestamp>-cppcheck.xml
  • AirPlan/state/airsdb/reports/<timestamp>-cppcheck.json
    • 必要时更新 AGENTS.md、ADR、C4 module

输出文案

进入模式:

AirSDB 模式已开启:已初始化或检查 `AirPlan/docs/staticanalysis.md`,并检测 cppcheck。可运行本机 scan也可在远程目标上使用 remote device helper 自动检测/配置 cppcheck本机和远程 scan 默认使用 `--check-level=exhaustive`。

扫描完成:

AirSDB 静态分析完成XML/JSON 报告已写入 `AirPlan/state/airsdb/reports/`,简短 AI 上下文已追加到 `AirPlan/docs/staticanalysis.md`,可交给 AirDbg 或 AirDo 使用。

状态检查:

AirSDB 状态:<enabled|disabled>
cppcheck<ok|blocked>
关键文件:逐项列出 ok/missing。