npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

miniprogram-remote-control

v1.0.0

Published

微信小程序自动化命令行工具 - 基于 miniprogram-automator 封装

Downloads

16

Readme

MRC (Miniprogram Remote Control)

微信小程序自动化命令行工具 - 基于微信官方 miniprogram-automator 封装的高度抽象、可复用的自动化控制方案。

🎯 核心特性

  • 连接复用: Driver 层确保单例连接,支持断线重连
  • 高度抽象: 将原子操作封装为可插拔的 Action 模块
  • 管道友好: 支持 JSON 输出,便于 AI 链式调用
  • 模块化设计: UI、交互、网络、调试四大模块独立扩展

📦 安装

方式一:npm 全局安装

npm install -g miniprogram-remote-control

方式二:本地开发

git clone https://github.com/LSTM-Kirigaya/miniprogram-remote-control.git
cd miniprogram-remote-control
npm install
npm link

方式三:npx 直接使用

npx miniprogram-remote-control <命令> [选项]

🚀 快速开始

1. 开启微信开发者工具自动化

在微信开发者工具中:

  • 方式一:菜单栏 → 工具 → 自动化
  • 方式二:使用 CLI 启动
/Applications/wechatwebdevtools.app/Contents/MacOS/cli auto --project /path/to/project --auto-port 9420

2. 验证连接

mrc where --port 9420

3. 常用命令示例

# 截图
mrc screenshot ./shot.png --port 9420

# 查看当前页面
mrc where -p 9420

# 切换到圈子页面
mrc switchTab /pages/community/index -p 9420

# 检查元素是否存在
mrc exists textarea -p 9420

# 输入文本(需先检查元素存在)
mrc type textarea "测试文本" -p 9420

# 点击元素
mrc click view -p 9420

# 返回上一页
mrc back -p 9420

# 获取页面栈
mrc stack -p 9420

# 获取系统信息
mrc sysinfo -p 9420

# 等待指定时间
mrc wait 1000 -p 9420

# 重启到指定页面
mrc relaunch /pages/index/index -p 9420

📋 命令列表

安装后使用 mrc 命令

| 命令 | 说明 | 示例 | |:---|:---|:---| | mrc where | 获取当前页面信息 | mrc where --port 9420 | | mrc screenshot [路径] | 截图并保存 | mrc screenshot ./shot.png --port 9420 | | mrc switchTab <URL> | 切换到 tabBar 页面 | mrc switchTab /pages/community/index --port 9420 | | mrc back | 返回上一页 | mrc back --port 9420 | | mrc relaunch <URL> | 重启到指定页面 | mrc relaunch /pages/index/index --port 9420 | | mrc click <选择器> | 点击元素 | mrc click view --port 9420 | | mrc type <选择器> <文本> | 输入文本 | mrc type textarea "文本" --port 9420 | | mrc exists <选择器> | 检查元素是否存在 | mrc exists input --port 9420 | | mrc stack | 获取页面栈信息 | mrc stack --port 9420 | | mrc sysinfo | 获取系统信息 | mrc sysinfo --port 9420 | | mrc wait <毫秒> | 等待指定时间 | mrc wait 1000 --port 9420 |

常用选项

| 选项 | 简写 | 说明 | 示例 | |:---|:---:|:---|:---| | --port | -p | 指定开发者工具端口(默认 9420) | -p 9420 | | --json | -j | 以 JSON 格式输出 | --json | | --help | -h | 显示帮助信息 | --help |

导航命令说明

food_link 项目的页面结构:

TabBar 页面(使用 switchTab):

  • /pages/index/index - 首页
  • /pages/community/index - 圈子
  • /pages/record/index - 记录
  • /pages/profile/index - 我的

非 TabBar 页面(使用 relaunch):

  • /pages/analyze/index - 分析页面(有 textarea 输入框)
  • /pages/food-library/index - 食物库
  • /pages/login/index - 登录
  • /pages/about/index - 关于
  • 其他...

📝 完整工作流示例

示例 1:截图并检查页面

# 切换到首页
mrc switchTab /pages/index/index --port 9420

# 截图保存
mrc screenshot ./home.png --port 9420

# 获取页面信息
mrc where --json --port 9420

示例 2:文字记录流程

# 1. 重启到分析页面(有输入框)
mrc relaunch /pages/analyze/index --port 9420

# 2. 检查 textarea 是否存在
mrc exists textarea --port 9420

# 3. 输入文本
mrc type textarea "这是一份测试的早餐记录,包含鸡蛋和牛奶" --port 9420

# 4. 截图验证
mrc screenshot ./typed.png --port 9420

示例 3:页面导航与返回

# 切换到圈子页面
mrc switchTab /pages/community/index --port 9420

# 点击某个元素
mrc click view --port 9420

# 查看页面栈
mrc stack --port 9420

# 返回上一页
mrc back --port 9420

示例 4:配合 AI 使用(JSON 输出)

# 获取结构化数据
mrc where --json --port 9420
# 输出: {"success":true,"data":{"path":"pages/index/index",...}}

mrc sysinfo --json --port 9420
# 输出: {"success":true,"data":{"model":"iPhone 12/13 (Pro)",...}}

🔧 架构设计

mrc-cli/
├── index.js              # CLI 入口
├── driver.js             # WebSocket 连接管理(单例)
├── utils.js              # 工具函数
├── actions/
│   ├── index.js          # 命令统一导出
│   ├── ui.js             # screenshot, where
│   ├── interaction.js    # click, type
│   ├── navigation.js     # switchTab, back, relaunch
│   ├── network.js        # mock(预留)
│   └── debug.js          # exists, stack, sysinfo, wait
├── package.json
└── README.md

🔌 连接方式

方式一:CLI 启动自动化(推荐)

/Applications/wechatwebdevtools.app/Contents/MacOS/cli auto \
  --project /path/to/project \
  --auto-port 9420

方式二:开发者工具界面

菜单栏 → 工具 → 自动化

🧪 测试

npm test

📄 许可证

MIT


GitHub: https://github.com/LSTM-Kirigaya/miniprogram-remote-control