安卓设备自动化工具

用于AI编码代理的安卓设备自动化工具,通过本地命令层实现技能驱动编排。

  • by amit-nayar
  • Python
  • 本地部署
  • 28 星标
  • 更新于
在 GitHub 查看 amit-nayar/android-adb-skill

使用说明

Android ADB Skill


Android device automation for AI coding agents.
Skill-driven orchestration with a local command layer instead of MCP.

这是什么?

此仓库将代理的Android自动化打包为两层:

  • ./tools/android 是共享执行表面。
  • skills/*/SKILL.md 是组成命令层的精简任务工作流。

目标是在保持运行时契约确定性和可测试性的同时,保持代理体验的高级性。

该仓库包括本地测试和共享命令层的GitHub Actions CI。

为什么是这个形状?

最初的MCP服务器解决了传输问题,但其有用的部分实际上是命令设计:屏幕截图、UI转储、元素定位、等待、安装和日志。此仓库保留了这些功能,同时删除了额外的服务器进程。

与纯降价技能包相比,这种结构更好,因为:

  • 技能保持短暂
  • 设备处理是集中的
  • 文本输入转义存在于一个地方
  • UI解析集中在一个地方
  • 代理商可以信赖 --json 而不是草草散文

先决条件

  • Android SDK adb 在您的路径或 ANDROID_HOME 集
  • python3 在你的路上
  • 已连接的Android设备或正在运行的模拟器

快速检查:

./tools/android device list --json

安装

法典

将这些复制到您的项目根目录中:

cp AGENTS.md /path/to/project/
cp -r docs /path/to/project/docs
cp -r skills /path/to/project/skills
cp -r tools /path/to/project/tools

食品法典委员会将宣读 AGENTS.md,然后使用 docs/command-contract.md 加上相关技能档案。

克劳德代码/光标/复制品/其他代理

复制相同的核心文件夹:

cp -r docs /path/to/project/docs
cp -r skills /path/to/project/skills
cp -r tools /path/to/project/tools

然后从这个仓库中添加特定于代理的适配器文件:

  • CLAUDE.md
  • .cursor/rules/android-adb.mdc
  • .github/copilot-instructions.md
  • AGENTS.md 用于读取单个根指令文件的代理

命令层

共享执行接口为:

./tools/android ...

更喜欢 --json 每当代理需要结构化输出时。

示例:

./tools/android device list --json
./tools/android screenshot --out /tmp/screen.png --json
./tools/android ui dump --json
./tools/android ui find --by text --value "Login" --json
./tools/android input tap-element --by text --value "Login" --json
./tools/android wait element --by text --value "Home" --json
./tools/android app install --apk ./app.apk --json
./tools/android debug logs --package com.example.app --level E --json

看 docs/command-contract.md 对于完整的合同。

开发工作流程

要将此仓库用作AI驱动的Android功能/调试循环的一部分,请参阅 docs/ai-development-workflow.md.

该指南包括:

  • 如何在Android应用程序仓库中使用此仓库
  • 代理如何编辑、构建、安装、导航、验证和迭代
  • 连续验证循环的美人鱼图

测试

使用以下命令运行本地测试套件:

python3 -m unittest discover -s tests -v

CI通过以下方式对每个推送和拉取请求运行相同的套件 .github/workflows/test.yml.

测试使用假 adb 和 emulator 二进制文件,因此它们不需要CI运行器上的真正Android SDK或设备。

技能

技能 目的
android 总体编排
android-screenshot 捕获并检查屏幕截图
android-ui 转储并搜索UI树
android-tap 点击元素或坐标
android-navigate 带验证的多步导航
android-scroll 滚动以查找屏幕外元素
android-gesture 滑动、长按、双击
android-test 使用证据运行测试流
android-debug 收集日志并诊断故障
android-install 安装并启动APK
android-device 设备和仿真器管理

示例用法

/android open Settings and navigate to Privacy
/android-tap Login button
/android-test login with user@example.com and verify the home screen
/android-debug crashes in com.example.app after tapping Settings

回购结构

android-adb-skill/
├── tools/
│   └── android
├── docs/
│   ├── command-contract.md
│   └── ai-development-workflow.md
├── tests/
│   └── test_tools_android.py
├── skills/
│   ├── android/SKILL.md
│   ├── android-screenshot/SKILL.md
│   ├── android-ui/SKILL.md
│   ├── android-tap/SKILL.md
│   ├── android-navigate/SKILL.md
│   ├── android-scroll/SKILL.md
│   ├── android-gesture/SKILL.md
│   ├── android-test/SKILL.md
│   ├── android-debug/SKILL.md
│   ├── android-install/SKILL.md
│   └── android-device/SKILL.md
├── AGENTS.md
├── CLAUDE.md
├── .cursor/rules/android-adb.mdc
├── .github/copilot-instructions.md
├── .github/workflows/test.yml
└── README.md

许可证

麻省理工学院