moai-domain-adb

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

moai-domain-adb: ADB Automation Domain Specialist

moai-domain-adb: ADB自动化领域专家

Tier 3 Modularized Skill for intelligent Android automation, game bot development, and real-time device orchestration.

三级模块化技能,适用于智能Android自动化、游戏机器人开发和实时设备编排。

🎯 Quick Reference

🎯 快速参考

Core Competencies

核心能力

DomainCapabilityModule
Device ControlADB connection, shell execution, property inspectionadb-fundamentals
Device ManagementMulti-device orchestration, state tracking, lifecycledevice-management
Game AutomationBot scripting, action sequences, timing controlgame-automation
Vision & DetectionTemplate matching, OCR, region-based detectioncomputer-vision
Tauri IntegrationUI-Python bridge, real-time communication, deploymenttauri-integration
领域能力模块
设备控制ADB连接、Shell执行、属性检查adb-fundamentals
设备管理多设备编排、状态跟踪、生命周期管理device-management
游戏自动化机器人脚本编写、动作序列、时序控制game-automation
视觉与检测模板匹配、OCR、基于区域的检测computer-vision
Tauri集成UI-Python桥接、实时通信、部署tauri-integration

Key Functions (Quick Access)

关键功能(快速访问)

Device Operations
python
undefined
设备操作
python
undefined

Check device status

检查设备状态

adb devices --list-long
adb devices --list-long

Execute shell command

执行Shell命令

adb shell input tap 540 960
adb shell input tap 540 960

Get device property

获取设备属性

adb shell getprop ro.build.version.sdk
adb shell getprop ro.build.version.sdk

Install APK

安装APK

adb install -r game.apk

**Bot Control**
```python
adb install -r game.apk

**机器人控制**
```python

Start bot

启动机器人

adb shell am start -n com.game/.MainActivity
adb shell am start -n com.game/.MainActivity

Send input sequence

发送输入序列

adb shell input tap x y && sleep 1 && adb shell input tap x2 y2
adb shell input tap x y && sleep 1 && adb shell input tap x2 y2

Capture screenshot

捕获截图

adb shell screencap -p /sdcard/screen.png

**Module Selection Guide**

Use when you need to...

- **Understand ADB fundamentals**: Load `adb-fundamentals` module
  - Connection protocols, authentication, basic shell operations
  - Device discovery, property reading, system interaction

- **Manage multiple devices**: Load `device-management` module
  - Device state tracking, connection pooling, failover strategies
  - Batch operations, monitoring, lifecycle management

- **Develop game bots**: Load `game-automation` module
  - Click sequences, timing, OCR parsing, state detection
  - Custom routines, action templates, bot patterns

- **Use vision for detection**: Load `computer-vision` module
  - Template matching (OpenCV), OCR (Tesseract)
  - Region-based detection, image analysis, pattern recognition

- **Integrate with Tauri UI**: Load `tauri-integration` module
  - Real-time bot status updates, command queueing
  - UI ↔ Python communication, resource management

---
adb shell screencap -p /sdcard/screen.png

**模块选择指南**

当你需要以下能力时使用对应模块...

- **了解ADB基础**: 加载 `adb-fundamentals` 模块
  - 连接协议、身份验证、基础Shell操作
  - 设备发现、属性读取、系统交互

- **管理多台设备**: 加载 `device-management` 模块
  - 设备状态跟踪、连接池、故障转移策略
  - 批量操作、监控、生命周期管理

- **开发游戏机器人**: 加载 `game-automation` 模块
  - 点击序列、时序控制、OCR解析、状态检测
  - 自定义流程、动作模板、机器人模式

- **使用视觉检测**: 加载 `computer-vision` 模块
  - 模板匹配(OpenCV)、OCR(Tesseract)
  - 基于区域的检测、图像分析、模式识别

- **与Tauri UI集成**: 加载 `tauri-integration` 模块
  - 实时机器人状态更新、命令排队
  - UI ↔ Python通信、资源管理

---

📚 Implementation Guide

📚 实施指南

Architecture Overview

架构概述

moai-domain-adb follows a 5-module progressive disclosure pattern:
moai-domain-adb/
├── SKILL.md                    # This file (documentation hub)
├── modules/
│   ├── adb-fundamentals.md     # Level 1: Core ADB operations
│   ├── device-management.md    # Level 2: Multi-device orchestration
│   ├── game-automation.md      # Level 3: Bot development patterns
│   ├── computer-vision.md      # Level 4: Vision-based detection
│   └── tauri-integration.md    # Level 5: UI orchestration
└── scripts/                    # IndieDevDan UV scripts
    ├── adb_device_analyzer.py  # Analyze device capabilities
    ├── adb_bot_generator.py    # Generate bot skeletons
    ├── adb_template_creator.py # Create action templates
    ├── adb_performance_profiler.py  # Profile bot performance
    ├── adb_config_validator.py # Validate configurations
    ├── adb_game_tester.py      # Test bot on devices
    └── adb_deployment_helper.py # Deploy to production
moai-domain-adb 遵循5模块渐进式披露模式:
moai-domain-adb/
├── SKILL.md                    # 本文档(文档中心)
├── modules/
│   ├── adb-fundamentals.md     # 第1级:核心ADB操作
│   ├── device-management.md    # 第2级:多设备编排
│   ├── game-automation.md      # 第3级:机器人开发模式
│   ├── computer-vision.md      # 第4级:基于视觉的检测
│   └── tauri-integration.md    # 第5级:UI编排
└── scripts/                    # IndieDevDan UV脚本
    ├── adb_device_analyzer.py  # 分析设备能力
    ├── adb_bot_generator.py    # 生成机器人骨架
    ├── adb_template_creator.py # 创建动作模板
    ├── adb_performance_profiler.py  # 分析机器人性能
    ├── adb_config_validator.py # 验证配置
    ├── adb_game_tester.py      # 在设备上测试机器人
    └── adb_deployment_helper.py # 部署到生产环境

Tier 3 Characteristics

三级技能特性

Modularized: 5 independent modules (no cross-module imports) ✅ Production-Ready: 500+ line SKILL.md with comprehensive docs ✅ Scripted: 7 UV scripts following IndieDevDan 13 rules ✅ Delegatable: Works with expert-* and manager-* agents ✅ Reusable: Applicable to any Android automation project
模块化: 5个独立模块(无跨模块导入) ✅ 生产就绪: 超过500行的SKILL.md,包含全面文档 ✅ 脚本化: 7个遵循IndieDevDan 13条规则的UV脚本 ✅ 可委托: 可与expert-*和manager-*类型Agent协作 ✅ 可复用: 适用于任何Android自动化项目

Usage Pattern

使用模式

python
undefined
python
undefined

Pattern 1: Load skill for general ADB knowledge

模式1:加载技能以获取通用ADB知识

Skill("moai-domain-adb")
Skill("moai-domain-adb")

Pattern 2: Load specific module for targeted expertise

模式2:加载特定模块以获取针对性专业能力

In agent prompt: "Use moai-domain-adb:adb-fundamentals for device operations"

在Agent提示中:"使用moai-domain-adb:adb-fundamentals进行设备操作"

Pattern 3: Reference UV script for automated tasks

模式3:参考UV脚本执行自动化任务

Command: uv run .claude/skills/moai-domain-adb/scripts/adb_device_analyzer.py --device emulator-5554

命令:uv run .claude/skills/moai-domain-adb/scripts/adb_device_analyzer.py --device emulator-5554

undefined
undefined

Integration Points

集成点

With Agents:
  • adb-bot-runner
    : Executes bots using game-automation patterns
  • adb-device-manager
    : Manages devices using device-management expertise
  • adb-game-tester
    : Tests bots using computer-vision and game-automation
  • adb-config-manager
    : Validates configs using config-validator script
  • adb-workflow-orchestrator
    : Coordinates all agents using tauri-integration patterns
With Commands:
  • /adb:init
    → Uses adb-fundamentals + adb_device_analyzer
  • /adb:bot
    → Uses game-automation + adb_bot_generator
  • /adb:test
    → Uses computer-vision + adb_game_tester
  • /adb:deploy
    → Uses tauri-integration + adb_deployment_helper
With UV Scripts: All 7 scripts are self-contained (zero dependencies on each other), follow PEP 723, and implement dual output (human-readable + JSON).
与Agent集成:
  • adb-bot-runner
    : 使用game-automation模式执行机器人
  • adb-device-manager
    : 使用device-management能力管理设备
  • adb-game-tester
    : 使用computer-vision和game-automation测试机器人
  • adb-config-manager
    : 使用config-validator脚本验证配置
  • adb-workflow-orchestrator
    : 使用tauri-integration模式协调所有Agent
与命令集成:
  • /adb:init
    → 使用adb-fundamentals + adb_device_analyzer
  • /adb:bot
    → 使用game-automation + adb_bot_generator
  • /adb:test
    → 使用computer-vision + adb_game_tester
  • /adb:deploy
    → 使用tauri-integration + adb_deployment_helper
与UV脚本集成: 所有7个脚本都是独立的(彼此无依赖),遵循PEP 723标准,并实现双输出(人类可读格式 + JSON格式)。

Progressive Disclosure Strategy

渐进式学习策略

Level 1: Getting Started
  • Read: adb-fundamentals module
  • Run:
    adb_device_analyzer.py
    to list devices
  • Understand: Basic device connection and property reading
Level 2: Multi-Device Workflows
  • Read: device-management module
  • Understand: Connection pooling, state tracking, failover
  • Build: Scripts that manage 5+ devices simultaneously
Level 3: Game Bot Development
  • Read: game-automation module
  • Understand: Click sequences, timing control, OCR integration
  • Build: Custom routines for game-specific tasks
Level 4: Vision-Based Automation
  • Read: computer-vision module
  • Understand: Template matching, OCR parsing, region detection
  • Build: Bots that adapt to UI changes dynamically
Level 5: Production Orchestration
  • Read: tauri-integration module
  • Understand: Real-time UI updates, command queuing, resource management
  • Build: Enterprise workflows with Tauri UI control

第1级:入门
  • 阅读:adb-fundamentals模块
  • 运行:
    adb_device_analyzer.py
    列出设备
  • 掌握:基础设备连接和属性读取
第2级:多设备工作流
  • 阅读:device-management模块
  • 掌握:连接池、状态跟踪、故障转移
  • 构建:可同时管理5台以上设备的脚本
第3级:游戏机器人开发
  • 阅读:game-automation模块
  • 掌握:点击序列、时序控制、OCR集成
  • 构建:针对特定游戏任务的自定义流程
第4级:基于视觉的自动化
  • 阅读:computer-vision模块
  • 掌握:模板匹配、OCR解析、区域检测
  • 构建:可动态适配UI变化的机器人
第5级:生产环境编排
  • 阅读:tauri-integration模块
  • 掌握:实时UI更新、命令排队、资源管理
  • 构建:带有Tauri UI控制的企业级工作流

🚀 Advanced Topics

🚀 高级主题

Skill Composition Strategy

技能组合策略

moai-domain-adb is designed for modular composition:
python
undefined
moai-domain-adb 专为模块化组合设计:
python
undefined

Example 1: Simple device check

示例1:简单设备检查

Required: adb-fundamentals

所需模块:adb-fundamentals

agent = Task( subagent_type="expert-backend", prompt="Use moai-domain-adb:adb-fundamentals to list ADB devices" )
agent = Task( subagent_type="expert-backend", prompt="使用moai-domain-adb:adb-fundamentals列出ADB设备" )

Example 2: Multi-device bot deployment

示例2:多设备机器人部署

Required: device-management + game-automation + tauri-integration

所需模块:device-management + game-automation + tauri-integration

agent = Task( subagent_type="adb-workflow-orchestrator", prompt="Deploy game bot to 3 devices" )
agent = Task( subagent_type="adb-workflow-orchestrator", prompt="将游戏机器人部署到3台设备" )

Example 3: Vision-based testing

示例3:基于视觉的测试

Required: computer-vision + game-automation

所需模块:computer-vision + game-automation

agent = Task( subagent_type="adb-game-tester", prompt="Test bot with computer vision verification" )
undefined
agent = Task( subagent_type="adb-game-tester", prompt="使用计算机视觉验证测试机器人" )
undefined

Performance Optimization

性能优化

Device Batching:
  • Group commands by device to reduce round-trip latency
  • Use
    adb_performance_profiler.py
    to identify bottlenecks
  • Target: Execute 100 actions in <5 seconds
Caching Strategies:
  • Cache device properties (refreshed every 60s)
  • Cache template images (refreshed on detection failure)
  • Cache bot configurations (invalidated on user edit)
Concurrency:
  • Run multi-device operations with ThreadPoolExecutor
  • Limit to 5 concurrent ADB operations per host
  • Use queuing for >5 devices
设备批处理:
  • 按设备分组命令以减少往返延迟
  • 使用
    adb_performance_profiler.py
    识别瓶颈
  • 目标:在5秒内执行100个动作
缓存策略:
  • 缓存设备属性(每60秒刷新一次)
  • 缓存模板图像(检测失败时刷新)
  • 缓存机器人配置(用户编辑时失效)
并发处理:
  • 使用ThreadPoolExecutor执行多设备操作
  • 限制每台主机最多5个并发ADB操作
  • 超过5台设备时使用排队机制

Security Considerations

安全注意事项

Authentication:
  • ADB uses RSA key exchange; validate device certificates
  • Never store unencrypted device pairing keys
  • Rotate pairing keys quarterly for production devices
Permissions:
  • Request minimal shell commands (avoid
    su
    unless necessary)
  • Use app-specific commands instead of root access
  • Audit bot actions for unintended side effects
Data Protection:
  • Never capture sensitive data in screenshots
  • Encrypt stored configurations containing API keys
  • Use secure storage for game credentials
身份验证:
  • ADB使用RSA密钥交换;验证设备证书
  • 绝不存储未加密的设备配对密钥
  • 生产设备每季度轮换一次配对密钥
权限:
  • 请求最小权限的Shell命令(除非必要,避免使用
    su
  • 使用应用特定命令而非root权限
  • 审核机器人操作以避免意外副作用
数据保护:
  • 绝不在截图中捕获敏感数据
  • 对包含API密钥的存储配置进行加密
  • 使用安全存储保存游戏凭据

Debugging & Troubleshooting

调试与故障排除

Common Issues:
IssueDiagnosisSolution
Device not found
adb_device_analyzer.py --check-connection
Verify USB connection, check ADB daemon
Slow bot execution
adb_performance_profiler.py --device <id>
Reduce click delays, batch operations
Template matching failsCheck image DPI/resolutionRun
adb_template_creator.py --device <id>
OCR accuracy poorPreprocess image (contrast, threshold)See computer-vision module for tips
Tauri communication lagCheck Python process CPUReduce log verbosity, optimize render loop
Debug Mode:
bash
undefined
常见问题:
问题诊断解决方案
设备未找到
adb_device_analyzer.py --check-connection
验证USB连接,检查ADB守护进程
机器人执行缓慢
adb_performance_profiler.py --device <id>
减少点击延迟,批量操作
模板匹配失败检查图像DPI/分辨率运行
adb_template_creator.py --device <id>
OCR准确率低预处理图像(对比度、阈值)查看computer-vision模块获取技巧
Tauri通信延迟检查Python进程CPU使用率减少日志冗余,优化渲染循环
调试模式:
bash
undefined

Enable verbose logging

启用详细日志

export ADB_DEBUG=1 uv run .claude/skills/moai-domain-adb/scripts/adb_device_analyzer.py --verbose
export ADB_DEBUG=1 uv run .claude/skills/moai-domain-adb/scripts/adb_device_analyzer.py --verbose

Trace ADB commands

跟踪ADB命令

adb logcat | grep "adb_bot_runner"
undefined
adb logcat | grep "adb_bot_runner"
undefined

Testing Strategy (TRUST 5 Framework)

测试策略(TRUST 5框架)

Test Coverage Target: ≥85%
  • Unit Tests: Individual module functions (py.test)
  • Integration Tests: Module interactions (device mock)
  • E2E Tests: Full workflow with real devices (optional)
  • Performance Tests: Execution time benchmarks
  • Security Tests: Input validation, permission checks
Test Execution:
bash
undefined
测试覆盖率目标: ≥85%
  • 单元测试: 单个模块功能(py.test)
  • 集成测试: 模块间交互(设备模拟)
  • 端到端测试: 使用真实设备的完整工作流(可选)
  • 性能测试: 执行时间基准测试
  • 安全测试: 输入验证、权限检查
测试执行:
bash
undefined

Run all tests

运行所有测试

pytest tests/ -v --cov=.claude/skills/moai-domain-adb
pytest tests/ -v --cov=.claude/skills/moai-domain-adb

Run specific module tests

运行特定模块测试

pytest tests/test_device_management.py -v
pytest tests/test_device_management.py -v

Profile performance

性能分析

pytest tests/ --benchmark-only

---
pytest tests/ --benchmark-only

---

📖 Module Navigation

📖 模块导航

Each module builds upon previous knowledge but is independently usable:
  • adb-fundamentals (250 lines)
    • ADB architecture, connection protocols, device discovery
    • Shell execution, property reading, device interaction
  • device-management (280 lines)
    • Multi-device orchestration, state tracking, connection pooling
    • Lifecycle management, monitoring, failover strategies
  • game-automation (300 lines)
    • Bot scripting patterns, click sequences, timing control
    • OCR integration, state detection, action templates
  • computer-vision (270 lines)
    • Template matching (OpenCV), OCR (Tesseract)
    • Region detection, image preprocessing, pattern recognition
  • tauri-integration (240 lines)
    • Tauri-Python IPC, real-time updates, command queueing
    • Resource management, deployment strategies, monitoring

每个模块都基于之前的知识构建,但也可独立使用:
  • adb-fundamentals(250行)
    • ADB架构、连接协议、设备发现
    • Shell执行、属性读取、设备交互
  • device-management(280行)
    • 多设备编排、状态跟踪、连接池
    • 生命周期管理、监控、故障转移策略
  • game-automation(300行)
    • 机器人脚本编写模式、点击序列、时序控制
    • OCR集成、状态检测、动作模板
  • computer-vision(270行)
    • 模板匹配(OpenCV)、OCR(Tesseract)
    • 区域检测、图像预处理、模式识别
  • tauri-integration(240行)
    • Tauri-Python进程间通信、实时更新、命令排队
    • 资源管理、部署策略、监控

🛠️ Scripts & Tools

🛠️ 脚本与工具

All scripts follow IndieDevDan 13 Rules (PEP 723, 9-section structure, dual output):
bash
undefined
所有脚本均遵循IndieDevDan 13条规则(PEP 723、9节结构、双输出):
bash
undefined

Analyze device capabilities

分析设备能力

uv run scripts/adb_device_analyzer.py --device emulator-5554 --json
uv run scripts/adb_device_analyzer.py --device emulator-5554 --json

Generate bot skeleton

生成机器人骨架

uv run scripts/adb_bot_generator.py --game "My Game" --output my_bot.py
uv run scripts/adb_bot_generator.py --game "我的游戏" --output my_bot.py

Create action template

创建动作模板

uv run scripts/adb_template_creator.py --screenshot screen.png --region "0,0,1080,1920"
uv run scripts/adb_template_creator.py --screenshot screen.png --region "0,0,1080,1920"

Profile bot performance

分析机器人性能

uv run scripts/adb_performance_profiler.py --bot bot.py --iterations 100
uv run scripts/adb_performance_profiler.py --bot bot.py --iterations 100

Validate configuration

验证配置

uv run scripts/adb_config_validator.py --config config.yaml --strict
uv run scripts/adb_config_validator.py --config config.yaml --strict

Test bot on device

在设备上测试机器人

uv run scripts/adb_game_tester.py --bot bot.py --device emulator-5554
uv run scripts/adb_game_tester.py --bot bot.py --device emulator-5554

Prepare deployment

准备部署

uv run scripts/adb_deployment_helper.py --bot bot.py --target production
undefined
uv run scripts/adb_deployment_helper.py --bot bot.py --target production
undefined

Complete Scripts Reference (36 scripts)

完整脚本参考(36个脚本)

All scripts are located in
scripts/
directory and organized by category. Each script supports:
  • --device/-d
    - Specify device ID (defaults to first connected)
  • --toon
    - Output in TOON/YAML format for automation
  • --verbose/-v
    - Enable verbose logging
  • --help
    - Show detailed help and usage examples
See scripts/README.md for comprehensive documentation with 150+ usage examples.
所有脚本位于
scripts/
目录,按类别组织。每个脚本支持:
  • --device/-d
    - 指定设备ID(默认使用第一个连接的设备)
  • --toon
    - 输出TOON/YAML格式以用于自动化和解析
  • --verbose/-v
    - 启用详细日志
  • --help
    - 显示详细帮助和使用示例
查看 scripts/README.md 获取包含150+使用示例的全面文档。

🔌 Connection (4 scripts)

🔌 连接类(4个脚本)

Location:
scripts/connection/
ScriptPurposeKey OptionsExample
adb_connect.py
Connect to device via IP:port
--device
(default: 127.0.0.1:5555)
uv run scripts/connection/adb_connect.py
adb_disconnect.py
Disconnect device gracefully
--device
uv run scripts/connection/adb_disconnect.py
adb_restart_server.py
Restart ADB server
--verbose
uv run scripts/connection/adb_restart_server.py
adb_device_status.py
List all devices and status
--toon
uv run scripts/connection/adb_device_status.py
位置:
scripts/connection/
脚本用途关键选项示例
adb_connect.py
通过IP:port连接设备
--device
(默认:127.0.0.1:5555)
uv run scripts/connection/adb_connect.py
adb_disconnect.py
优雅断开设备连接
--device
uv run scripts/connection/adb_disconnect.py
adb_restart_server.py
重启ADB服务器
--verbose
uv run scripts/connection/adb_restart_server.py
adb_device_status.py
列出所有设备及其状态
--toon
uv run scripts/connection/adb_device_status.py

📱 Screen (6 scripts)

📱 屏幕操作类(6个脚本)

Location:
scripts/screen/
ScriptPurposeKey OptionsExample
adb_screenshot.py
Capture screenshot
--output FILE
uv run scripts/screen/adb_screenshot.py --output capture.png
adb_tap.py
Tap at coordinates
--x X --y Y --count N
uv run scripts/screen/adb_tap.py --x 500 --y 1000
adb_swipe.py
Swipe gesture
--preset {up,down,left,right}
or
--start X,Y --end X,Y
uv run scripts/screen/adb_swipe.py --preset up
adb_keyevent.py
Send key event
--key {back,home,menu,power,volume_up}
uv run scripts/screen/adb_keyevent.py --key back
adb_text_input.py
Type text
--text TEXT
uv run scripts/screen/adb_text_input.py --text "Hello"
adb_screenrecord.py
Record screen video
--output FILE --duration SECONDS
uv run scripts/screen/adb_screenrecord.py --duration 60
位置:
scripts/screen/
脚本用途关键选项示例
adb_screenshot.py
捕获截图
--output FILE
uv run scripts/screen/adb_screenshot.py --output capture.png
adb_tap.py
在指定坐标点击
--x X --y Y --count N
uv run scripts/screen/adb_tap.py --x 500 --y 1000
adb_swipe.py
执行滑动手势
--preset {up,down,left,right}
--start X,Y --end X,Y
uv run scripts/screen/adb_swipe.py --preset up
adb_keyevent.py
发送按键事件
--key {back,home,menu,power,volume_up}
uv run scripts/screen/adb_keyevent.py --key back
adb_text_input.py
输入文本
--text TEXT
uv run scripts/screen/adb_text_input.py --text "Hello"
adb_screenrecord.py
录制屏幕视频
--output FILE --duration SECONDS
uv run scripts/screen/adb_screenrecord.py --duration 60

📦 App (5 scripts)

📦 应用操作类(5个脚本)

Location:
scripts/app/
ScriptPurposeKey OptionsExample
adb_app_list.py
List installed apps
--filter TEXT
,
--system
,
--all
uv run scripts/app/adb_app_list.py --filter afk
adb_app_start.py
Start app by package
-p PACKAGE
,
--wait
uv run scripts/app/adb_app_start.py -p com.afk.journey
adb_app_stop.py
Force stop app
-p PACKAGE
uv run scripts/app/adb_app_stop.py -p com.afk.journey
adb_app_install.py
Install APK
--apk FILE
uv run scripts/app/adb_app_install.py --apk game.apk
adb_app_uninstall.py
Uninstall app
-p PACKAGE
,
--keep-data
uv run scripts/app/adb_app_uninstall.py -p com.example
位置:
scripts/app/
脚本用途关键选项示例
adb_app_list.py
列出已安装应用
--filter TEXT
,
--system
,
--all
uv run scripts/app/adb_app_list.py --filter afk
adb_app_start.py
通过包名启动应用
-p PACKAGE
,
--wait
uv run scripts/app/adb_app_start.py -p com.afk.journey
adb_app_stop.py
强制停止应用
-p PACKAGE
uv run scripts/app/adb_app_stop.py -p com.afk.journey
adb_app_install.py
安装APK
--apk FILE
uv run scripts/app/adb_app_install.py --apk game.apk
adb_app_uninstall.py
卸载应用
-p PACKAGE
,
--keep-data
uv run scripts/app/adb_app_uninstall.py -p com.example

ℹ️ Info (4 scripts)

ℹ️ 信息查询类(4个脚本)

Location:
scripts/info/
ScriptPurposeKey OptionsExample
adb_device_info.py
Device specifications
--toon
uv run scripts/info/adb_device_info.py
adb_display_info.py
Display resolution/DPI
--toon
uv run scripts/info/adb_display_info.py
adb_running_app.py
Current foreground app
--toon
uv run scripts/info/adb_running_app.py
adb_battery_info.py
Battery status
--toon
uv run scripts/info/adb_battery_info.py
位置:
scripts/info/
脚本用途关键选项示例
adb_device_info.py
获取设备规格
--toon
uv run scripts/info/adb_device_info.py
adb_display_info.py
获取显示分辨率/DPI
--toon
uv run scripts/info/adb_display_info.py
adb_running_app.py
获取当前前台应用
--toon
uv run scripts/info/adb_running_app.py
adb_battery_info.py
获取电池状态
--toon
uv run scripts/info/adb_battery_info.py

⚡ Performance (3 scripts)

⚡ 性能监控类(3个脚本)

Location:
scripts/performance/
ScriptPurposeKey OptionsExample
adb_cpu_monitor.py
Real-time CPU monitoring
--duration SECONDS
,
--package PKG
uv run scripts/performance/adb_cpu_monitor.py --duration 60
adb_memory_monitor.py
Memory usage monitoring
--duration SECONDS
,
--package PKG
uv run scripts/performance/adb_memory_monitor.py --duration 60
adb_logcat_filter.py
Filter logcat logs
--tag TAG
,
--priority {V,D,I,W,E,F}
,
--follow
uv run scripts/performance/adb_logcat_filter.py --tag MyApp --priority E
位置:
scripts/performance/
脚本用途关键选项示例
adb_cpu_monitor.py
实时CPU监控
--duration SECONDS
,
--package PKG
uv run scripts/performance/adb_cpu_monitor.py --duration 60
adb_memory_monitor.py
内存使用监控
--duration SECONDS
,
--package PKG
uv run scripts/performance/adb_memory_monitor.py --duration 60
adb_logcat_filter.py
过滤logcat日志
--tag TAG
,
--priority {V,D,I,W,E,F}
,
--follow
uv run scripts/performance/adb_logcat_filter.py --tag MyApp --priority E

🤖 Automation (4 scripts)

🤖 自动化类(4个脚本)

Location:
scripts/automation/
ScriptPurposeKey OptionsExample
adb_game_loop.py
Execute repeating sequence
-s FILE
,
-l LOOPS
,
--infinite
uv run scripts/automation/adb_game_loop.py -s daily.json -l 10
adb_wait_for_app.py
Wait for app to start
--package PKG
,
--timeout SECONDS
uv run scripts/automation/adb_wait_for_app.py -p com.afk.journey
adb_click_sequence.py
Execute sequence once
-s FILE
uv run scripts/automation/adb_click_sequence.py -s tutorial.json
adb_screenshot_compare.py
Compare screenshots
-b BEFORE -a AFTER
,
--threshold FLOAT
uv run scripts/automation/adb_screenshot_compare.py -b ref.png -a test.png
位置:
scripts/automation/
脚本用途关键选项示例
adb_game_loop.py
执行重复动作序列
-s FILE
,
-l LOOPS
,
--infinite
uv run scripts/automation/adb_game_loop.py -s daily.json -l 10
adb_wait_for_app.py
等待应用启动
--package PKG
,
--timeout SECONDS
uv run scripts/automation/adb_wait_for_app.py -p com.afk.journey
adb_click_sequence.py
执行单次动作序列
-s FILE
uv run scripts/automation/adb_click_sequence.py -s tutorial.json
adb_screenshot_compare.py
对比截图
-b BEFORE -a AFTER
,
--threshold FLOAT
uv run scripts/automation/adb_screenshot_compare.py -b ref.png -a test.png

🛠️ Utils (3 scripts)

🛠️ 工具类(3个脚本)

Location:
scripts/utils/
ScriptPurposeKey OptionsExample
adb_shell.py
Execute shell commands
-c COMMAND
,
--timeout SECONDS
uv run scripts/utils/adb_shell.py -c "ls /sdcard"
adb_push.py
Push file to device
-l LOCAL -r REMOTE
uv run scripts/utils/adb_push.py -l file.txt -r /sdcard/
adb_pull.py
Pull file from device
-r REMOTE -l LOCAL
uv run scripts/utils/adb_pull.py -r /sdcard/screenshot.png -l .
位置:
scripts/utils/
脚本用途关键选项示例
adb_shell.py
执行Shell命令
-c COMMAND
,
--timeout SECONDS
uv run scripts/utils/adb_shell.py -c "ls /sdcard"
adb_push.py
推送文件到设备
-l LOCAL -r REMOTE
uv run scripts/utils/adb_push.py -l file.txt -r /sdcard/
adb_pull.py
从设备拉取文件
-r REMOTE -l LOCAL
uv run scripts/utils/adb_pull.py -r /sdcard/screenshot.png -l .

🔧 Monitoring (7 scripts)

🔧 监控与生成类(7个脚本)

Location:
scripts/
(root level)
ScriptPurposeKey OptionsExample
adb_bot_generator.py
Generate bot scripts
--template NAME
,
--output FILE
uv run scripts/adb_bot_generator.py --template daily_quests
adb_config_validator.py
Validate configs
--config FILE
,
--strict
uv run scripts/adb_config_validator.py --config config.json
adb_deployment_helper.py
Deploy to devices
--apk FILE
,
--all
,
--devices IDS
uv run scripts/adb_deployment_helper.py --apk game.apk --all
adb_device_analyzer.py
Analyze capabilities
--aspects LIST
,
--output FILE
uv run scripts/adb_device_analyzer.py --aspects performance,battery
adb_game_tester.py
Test game automation
--test-suite FILE
,
--screenshots
uv run scripts/adb_game_tester.py --test-suite tests.json
adb_performance_profiler.py
Profile performance
--package PKG
,
--duration SECONDS
uv run scripts/adb_performance_profiler.py -p com.afk.journey
adb_template_creator.py
Create templates
--name NAME
,
--category CAT
uv run scripts/adb_template_creator.py --name my_automation
位置:
scripts/
(根目录)
脚本用途关键选项示例
adb_bot_generator.py
生成机器人脚本
--template NAME
,
--output FILE
uv run scripts/adb_bot_generator.py --template daily_quests
adb_config_validator.py
验证配置
--config FILE
,
--strict
uv run scripts/adb_config_validator.py --config config.json
adb_deployment_helper.py
部署到设备
--apk FILE
,
--all
,
--devices IDS
uv run scripts/adb_deployment_helper.py --apk game.apk --all
adb_device_analyzer.py
分析设备能力
--aspects LIST
,
--output FILE
uv run scripts/adb_device_analyzer.py --aspects performance,battery
adb_game_tester.py
测试游戏自动化
--test-suite FILE
,
--screenshots
uv run scripts/adb_game_tester.py --test-suite tests.json
adb_performance_profiler.py
分析性能
--package PKG
,
--duration SECONDS
uv run scripts/adb_performance_profiler.py -p com.afk.journey
adb_template_creator.py
创建模板
--name NAME
,
--category CAT
uv run scripts/adb_template_creator.py --name my_automation

JSON Sequence Format (Automation Scripts)

JSON序列格式(自动化脚本)

For
adb_game_loop.py
and
adb_click_sequence.py
, use JSON format:
json
{
  "name": "Daily Quest Automation",
  "steps": [
    {"action": "tap", "x": 500, "y": 1000, "delay": 2},
    {"action": "swipe", "start": [500, 1500], "end": [500, 500], "duration": 300},
    {"action": "wait", "duration": 3},
    {"action": "screenshot", "output": "/tmp/check.png"},
    {"action": "keyevent", "key": "back"},
    {"action": "text_input", "text": "Hello World"}
  ]
}
Supported Actions: tap, swipe, wait, screenshot, keyevent, text_input
对于
adb_game_loop.py
adb_click_sequence.py
,请使用以下JSON格式:
json
{
  "name": "日常任务自动化",
  "steps": [
    {"action": "tap", "x": 500, "y": 1000, "delay": 2},
    {"action": "swipe", "start": [500, 1500], "end": [500, 500], "duration": 300},
    {"action": "wait", "duration": 3},
    {"action": "screenshot", "output": "/tmp/check.png"},
    {"action": "keyevent", "key": "back"},
    {"action": "text_input", "text": "Hello World"}
  ]
}
支持的动作: tap(点击), swipe(滑动), wait(等待), screenshot(截图), keyevent(按键事件), text_input(文本输入)

Common Utilities

通用工具类

All scripts use shared utilities from
scripts/common/
:
  • adb_utils.py
    - ADB device operations and connection management
  • cli_utils.py
    - Click decorators, Rich formatters, output helpers
  • error_handlers.py
    - Standardized error handling and exit codes (0, 2, 3, 4)
  • path_utils.py
    - Project root detection and path resolution
所有脚本使用
scripts/common/
中的共享工具:
  • adb_utils.py
    - ADB设备操作和连接管理
  • cli_utils.py
    - Click装饰器、Rich格式化器、输出助手
  • error_handlers.py
    - 标准化错误处理和退出码(0, 2, 3, 4)
  • path_utils.py
    - 项目根目录检测和路径解析

Exit Codes

退出码

All scripts use standardized exit codes:
  • 0 - Success
  • 2 - Device offline or not found
  • 3 - ADB command failed or execution error
  • 4 - Invalid argument or configuration
所有脚本使用标准化退出码:
  • 0 - 成功
  • 2 - 设备离线或未找到
  • 3 - ADB命令失败或执行错误
  • 4 - 参数或配置无效

Output Formats

输出格式

Text Output (default): Rich-formatted console output with colors and tables TOON Output (
--toon
): YAML/structured format for automation and parsing

文本输出(默认):带颜色和表格的Rich格式控制台输出 TOON输出
--toon
):YAML/结构化格式,适用于自动化和解析

📞 Support & References

📞 支持与参考

Quick Links:
  • Modules: See individual module files in
    modules/
  • Scripts: See individual scripts in
    scripts/
    with
    --help
  • Examples: See integration patterns in adb-* agents
  • Tests: See test suite in
    tests/
Context7 References:

Version: 1.0.0 Status: ✅ Production Ready (Phase 1 Foundation) Last Updated: 2025-12-01 Next Phase: Create 5 core modules + 7 UV scripts
快速链接:
  • 模块: 查看
    modules/
    中的各个模块文件
  • 脚本: 查看
    scripts/
    中的各个脚本,使用
    --help
    获取帮助
  • 示例: 查看adb-*类型Agent中的集成模式
  • 测试: 查看
    tests/
    中的测试套件
Context7参考资料:

版本: 1.0.0 状态: ✅ 生产就绪(第一阶段基础版) 最后更新: 2025-12-01 下一阶段: 创建5个核心模块 + 7个UV脚本