qwen-code/packages/mobile-mcp/scripts/sync-from-upstream.sh
顾盼 23c6c7032a
feat(mobile-mcp): vendor mobile-mcp with opt-in 0-1000 relative coordinates (#6235)
* Squashed 'packages/mobile-mcp/' content from commit c5d7d27fd

git-subtree-dir: packages/mobile-mcp
git-subtree-split: c5d7d27fd61e4762e15ae4b1c68b6c011be88bb7

* feat(mobile-mcp): vendor mobile-mcp with opt-in 0-1000 relative coordinates

Fork mobile-next/mobile-mcp (v0.0.61) into packages/mobile-mcp/ via git
subtree, renamed to @qwen-code/mobile-mcp with the following additions:

Relative coordinate shim (src/coord-norm.ts):
- MOBILE_MCP_COORDINATE_SPACE=1 enables 0-1000 normalized coordinates
- MOBILE_MCP_COORDINATE_SCALE configurable (default 1000, 999 for mobile_use)
- Input denormalization for click/double_tap/long_press/swipe
- Output normalization for list_elements and get_screen_size
- Tool description rewriting when enabled
- Default off = zero behavior change

Android enhancements:
- mobile_install_app: -r/-g/-d/-t install flags (Android only)
- mobile_ui_dump: full UIAutomator XML hierarchy dump
- mobile_adb_pull / mobile_adb_push: file transfer via ADB

Infrastructure:
- cd-mobile-mcp.yml: npm publish workflow (tag mobile-mcp-v*)
- scripts/sync-from-upstream.sh: git subtree pull for upstream sync
- .vendored-from / .vendored-patches.md: vendoring metadata
- Upstream telemetry disabled by default
- eslint.config.js: exclude packages/mobile-mcp from root lint

* chore(mobile-mcp): update package-lock.json for workspace dependencies

* fix(mobile-mcp): quote all YAML strings to pass yamllint

* fix(mobile-mcp): fix cd workflow yaml to pass both yamllint and actionlint

* fix(mobile-mcp): address review findings on our additions

- ensureScreenSize: log warning instead of silent failure (#4)
- invalidateScreenSize on orientation change (#5)
- adb_push: path.posix.resolve to prevent /sdcard/ traversal (#6)
- adb_pull: readOnlyHint → destructiveHint (writes local file) (#9)
- adb_push: remove validateOutputPath on read-source local_path (#11)
- normalizeElementResult: log error instead of bare catch (#16)
- rewriteDescription: remove dead duplicate regex (#17)
- cd workflow: add test step between build and publish (#19)

* fix(mobile-mcp): update server.json identity and fix package.json main entrypoint

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-03 08:50:27 +00:00

48 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# sync-from-upstream.sh — pull upstream mobile-mcp changes via git subtree.
#
# Usage:
# packages/mobile-mcp/scripts/sync-from-upstream.sh [<branch-or-tag>]
#
# Default: pulls from 'main' branch of the mobile-mcp-upstream remote.
#
# Prerequisites:
# git remote add mobile-mcp-upstream https://github.com/mobile-next/mobile-mcp.git
#
# After running: review the merge, resolve any conflicts in src/server.ts
# (our coord-norm hooks and new tools), and src/coord-norm.ts (new file,
# won't conflict). Then commit.
#
# If subtree pull becomes impractical (e.g. upstream history grows too large),
# fall back to the cua-driver approach: generate a diff between two refs in a
# local upstream clone and apply with `git apply --reject`.
set -euo pipefail
BRANCH="${1:-main}"
REMOTE="mobile-mcp-upstream"
PREFIX="packages/mobile-mcp"
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
# Ensure remote exists
if ! git remote | grep -q "^${REMOTE}$"; then
echo "Adding remote ${REMOTE}..."
git remote add "$REMOTE" https://github.com/mobile-next/mobile-mcp.git
fi
echo "Fetching ${REMOTE}..."
git fetch "$REMOTE"
echo "Pulling from ${REMOTE}/${BRANCH} into ${PREFIX}..."
git subtree pull --prefix="$PREFIX" "$REMOTE" "$BRANCH" --squash \
-m "chore(mobile-mcp): sync with upstream ${REMOTE}/${BRANCH}"
# Update the vendored-from marker
UPSTREAM_SHA="$(git rev-parse "${REMOTE}/${BRANCH}")"
echo "$UPSTREAM_SHA" > "${PREFIX}/.vendored-from"
git add "${PREFIX}/.vendored-from"
echo ""
echo "Done. Upstream synced to ${UPSTREAM_SHA}."
echo "Review the merge, resolve any conflicts, then amend or commit."