miniprogram-minium-cli
v1.4.0
Published
面向 Agent 的小程序 Minium CLI 工具
Downloads
216
Readme
miniprogram-minium-cli
miniprogram-minium-cli is a command-line product for executing structured mini program automation plans.
It is designed for agent-driven workflows:
- the agent generates a plan
- the CLI validates and executes that plan
- the CLI writes structured results and screenshots to
.minium-cli/runs
This package uses Minium as the underlying automation engine.
Product Positioning
miniprogram-minium-cli is an execution layer, not a planner.
Its responsibility is to:
- accept a structured plan
- prepare the managed runtime
- connect to WeChat DevTools
- execute supported automation steps
- produce machine-readable and human-readable run artifacts
It does not include an MCP server, and it does not depend on a built-in natural-language planner.
Functional Scope
The current product supports:
- plan execution from files through
--plan - plan execution from inline JSON through
--plan-json - exact selectors and fuzzy text matching
- clicks, text input, waits, and assertions
- network observation and interception for
wx.request,wx.uploadFile, andwx.downloadFile, including listener, wait, assertion, fail, delay, and mock controls - bridge-backed miniapp actions for storage, navigation, app context, settings, clipboard, feedback UI, location, media, file, device, auth, and subscription flows
- explicit screenshots and automatic screenshots
- single-finger and multi-finger gestures
- structured outputs including
summary.json,result.json,comparison.json,network.json, and screenshot files
Step Categories
Automation plans combine four step categories:
- session and artifact steps such as
session.start,artifact.screenshot, andsession.close - UI steps such as
element.click,element.input,page.read,wait.for, andgesture.* - network steps such as
network.listen.start,network.wait,network.intercept.add,assert.networkRequest, andassert.networkResponse - bridge-backed steps such as
storage.set,navigation.navigateTo,clipboard.get,settings.authorize,auth.login, andlocation.get - assertion steps such as
assert.pagePath,assert.elementText, andassert.elementVisible
Bridge-backed steps expose a controlled subset of mini program native capabilities through structured plan types instead of a raw wx method passthrough.
For the full step catalog and per-step input fields, see API_REFERENCE.md.
Network Controls
Network steps let a plan observe or control request-side behavior without dropping into ad hoc scripts.
- use
network.listen.startandnetwork.listen.stopto scope evidence collection to a session - use
network.wait,assert.networkRequest, andassert.networkResponseto verify that a click or bridge step emitted the expected request or response - use
network.intercept.add,network.intercept.remove, andnetwork.intercept.clearto continue, fail, delay, or mock matching requests - inspect
result.json.stepResults[].details.networkEvidencebefore opening the full network artifact - use
node skills/miniprogram-minium-cli/scripts/filter-network-artifact.mjs --result /path/to/result.json --prettyto shrinknetwork.jsondown to the relevant subgraph - inspect the full
network.jsonwhen you need the normalized run-level event log plusrequests,listeners, andinterceptsindexes
Typical network matcher fields include url, urlPattern, method, resourceType, query, headers, body, statusCode, responseHeaders, and responseBody.
Current runtime notes:
- placeholder mode provides deterministic in-memory network events for bundled examples and regression plans
- real runtime is wired through Minium hooks for
wx.request,wx.uploadFile, andwx.downloadFile - response-body assertions remain best-effort because Minium only exposes what the underlying runtime callback returns
Plan Input
The CLI accepts two plan input modes.
For the complete plan schema, command surface, and step-level field reference, see API_REFERENCE.md.
File-Based Plan
Use --plan <file> when the plan already exists on disk.
Relative paths inside the plan are resolved from the plan file directory.
Inline JSON Plan
Use --plan-json <json> when an agent wants to execute a generated plan immediately.
Relative paths inside the inline JSON are resolved from the current working directory.
Installation
pnpm add -g miniprogram-minium-cliHost requirement:
- Node.js
>= 18
The CLI prepares and reuses its own private uv-managed Python runtime on demand. It does not require the user to install or manage a global Python environment for this tool.
Install the bundled skills into the default local skills directory:
miniprogram-minium-cli install --skillsInstall directly from this repository through the open skills tool:
npx skills add diaz-zeng/miniprogram-minium-cli --skill miniprogram-minium-cliList the skills exposed by this repository before installing:
npx skills add diaz-zeng/miniprogram-minium-cli --listInstall into a custom skills root:
miniprogram-minium-cli install --skills --path /path/to/skillsBy default, the command installs into ./.agents/skills under the current working directory. For Claude Code, GitHub Copilot, and other coding agents, use --path to target an agent-specific local or global skills directory.
If your agent already supports the open skills ecosystem, you can also install from the repository with npx skills add diaz-zeng/miniprogram-minium-cli --skill miniprogram-minium-cli.
Bundled Skills
The repository currently bundles these skills:
miniprogram-minium-cli: product-use guidance for runtime setup, plan authoring, execution, skill installation, and run analysisinteractive-classname-tagging: development-time guidance for explicitminium-anchor-<4hex>markers on interactive miniapp elements
Install a specific repository skill through the open skills tool:
npx skills add diaz-zeng/miniprogram-minium-cli --skill interactive-classname-taggingRelease Channels
The repository publishes three npm channels:
alpha: MAJOR prerelease builds published from activenext/x.y.zbranchesnext: MINOR beta builds published from activerelease/x.y.zbrancheslatest: stable releases published after a formal release PR merges intomain
Install prerelease channels explicitly:
pnpm add -g miniprogram-minium-cli@alpha
pnpm add -g miniprogram-minium-cli@nextMaintainer Release Flow
This repository treats package.json.version as the source of truth for the target stable version on each active release line.
mainalways represents the current stable release and only accepts formal release PRs.- Create
release/x.y.zfor the next MINOR line,next/x.y.zfor the next MAJOR line, andhotfix/x.y.zfor PATCH fixes against the current stable line. - Ensure the branch version and
package.json.versionmatch exactly, for examplerelease/1.5.0withpackage.json.version = 1.5.0. - Pushes on
release/x.y.zpublish MINOR beta builds such as1.5.0-beta.<run-id>.<attempt>.<sha>to npmnext. - Pushes on
next/x.y.zpublish MAJOR alpha builds such as2.0.0-alpha.<run-id>.<attempt>.<sha>to npmalpha. - When a version line is ready, merge its formal release PR into
main. The stable workflow validates the merged release branch, publishes npmlatest, creates thevX.Y.Ztag, and creates the GitHub Release. - Stable GitHub Releases use the matching
CHANGELOG.mdsection as the primary release body and append auto-generated release notes. If the changelog entry is missing, the stable release fails. - After every PATCH or MINOR stable release, forward-port the applicable fixes into the currently active
release/*andnext/*lines.
Important release guards:
- If the stable version in an active release line is already published to npm, the
alphaandnextprerelease workflows fail beforenpm publish. - If the stable release cannot resolve a merged release PR into
main, the workflow fails closed instead of publishing. - If the stable release cannot find the current version section in
CHANGELOG.md, the workflow fails closed instead of creating the GitHub Release. - The floating
@alphaand@nextdist-tags always point to the latest successful publish for that channel. Install the full version string if you need a specific build.
For local debugging of the release helpers:
pnpm run release:assert-release-branch -- --branch release/1.5.0
pnpm run release:assert-unpublished-base
pnpm run release:assert-stable-unpublished
pnpm run release:compute-prerelease -- --preid beta --run-id 123 --run-attempt 1 --sha abcdef1
pnpm run release:extract-changelog -- --version 1.5.0GitHub Actions publishing is designed for npm trusted publishing first. If trusted publishing is not configured yet, the publish steps also accept NPM_TOKEN as a temporary fallback through repository secrets.
Quick Start
Warm up the managed runtime:
miniprogram-minium-cli prepare-runtimeExecute a plan file:
miniprogram-minium-cli exec \
--plan ./plans/login-check.json \
--wechat-devtool-path /path/to/wechat-devtools-cliExecute an inline plan:
miniprogram-minium-cli exec --plan-json '{
"version": 1,
"kind": "miniapp-test-plan",
"metadata": { "draft": false, "name": "inline-demo" },
"execution": { "mode": "serial", "failFast": true },
"environment": {
"projectPath": "./miniapp",
"artifactsDir": null,
"wechatDevtoolPath": null,
"testPort": 9420,
"language": "en-US",
"runtimeMode": "placeholder",
"autoScreenshot": "off"
},
"steps": [
{
"id": "step-1",
"type": "session.start",
"input": { "projectPath": "./miniapp" }
},
{
"id": "step-2",
"type": "session.close",
"input": {}
}
]
}' --jsonExecute a bridge-backed inline plan:
miniprogram-minium-cli exec --plan-json '{
"version": 1,
"kind": "miniapp-test-plan",
"metadata": { "draft": false, "name": "bridge-inline-demo" },
"execution": { "mode": "serial", "failFast": true },
"environment": {
"projectPath": "./miniapp",
"artifactsDir": null,
"wechatDevtoolPath": null,
"testPort": 9420,
"language": "en-US",
"runtimeMode": "auto",
"autoScreenshot": "off"
},
"steps": [
{
"id": "start",
"type": "session.start",
"input": { "projectPath": "./miniapp" }
},
{
"id": "set-storage",
"type": "storage.set",
"input": { "key": "demo-key", "value": "demo-value" }
},
{
"id": "get-storage",
"type": "storage.get",
"input": { "key": "demo-key" }
},
{
"id": "close",
"type": "session.close",
"input": {}
}
]
}' --jsonCommand Reference
For the complete command, parameter, and plan format reference, see API_REFERENCE.md.
exec
miniprogram-minium-cli exec (--plan <file> | --plan-json <json>) [--project-path <path>] [--wechat-devtool-path <path>] [--runtime-mode <mode>] [--auto-screenshot <mode>] [--json]Purpose:
- validate and execute a structured plan
Primary options:
--plan <file>: execute a plan file--plan-json <json>: execute an inline JSON plan--project-path <path>: overrideenvironment.projectPath--wechat-devtool-path <path>: overrideenvironment.wechatDevtoolPath--artifacts-dir <path>: overrideenvironment.artifactsDir--test-port <port>: overrideenvironment.testPort--runtime-mode <mode>: overrideenvironment.runtimeMode--auto-screenshot <mode>: set screenshot strategy--json: print structured execution output
Screenshot modes:
offon-successalways
prepare-runtime
miniprogram-minium-cli prepare-runtime [--json]Purpose:
- preload
uv - prepare the managed Python runtime
- reduce cold-start cost before the first real execution
install
miniprogram-minium-cli install --skills [--path <path>] [--json]Purpose:
- install all bundled repository skills into
./.agents/skillsunder the current working directory, or a custom skills root for other coding agents
Primary options:
--skills: install all bundled skills from this package--path <path>: install into a custom skills root instead of./.agents/skillsunder the current working directory--json: print structured installation output
Default installation root:
./.agents/skillsunder the current working directory
Use --path when you want a shared global directory or an agent-specific local skills directory.
Execution Output
By default, execution outputs are written to:
.minium-cli/runsEach run produces a dedicated run directory containing:
plan.jsonsummary.jsonresult.jsoncomparison.jsonnetwork.jsonfor network-aware runs- screenshots when configured or when failure forensics are triggered
For network-aware runs:
network.jsonuses a normalized shape:schemaVersion,events,requests,listeners,intercepts, andmetaresult.json.stepResults[]may includedetails.networkEvidenceso a caller can jump back intonetwork.jsonwithout scraping step-specific output fields
Runtime Behavior
- the CLI lazily prepares its runtime when Python execution is first needed
- the managed runtime is private to this CLI
- the CLI does not modify the user's global Python, pip, PATH, or shell configuration
- the CLI requests Python
3.14by default - the minimum supported Python version for the managed runtime is
3.11
Operating Constraints
Projects that still use touristappid should treat real-runtime results as limited validation only.
They are not representative for flows that depend on native dialogs or authorization APIs such as:
wx.showModalwx.showActionSheetwx.authorizewx.getLocationwx.chooseLocationwx.getUserProfilewx.requestSubscribeMessage
If those flows matter, use a developer-owned AppID instead of touristappid.
Product Rationale
Why Minium Instead of miniprogram-automator
Minium is the better fit for this product for three reasons:
- The CLI needs a strong execution backend for reusable plans, assertions, artifacts, and complex interaction playback, not just a thin DevTools wrapper.
- The product requires multi-step touch interaction, including stateful single-finger and multi-finger gesture execution.
- The product is optimized for agent-generated plan execution rather than for a lightweight Node-only scripting surface.
License
MIT. See LICENSE.
