From 2693a67e645ca12e9e29a165646e0cb7d5469d22 Mon Sep 17 00:00:00 2001 From: leeguooooo <9278645+leeguooooo@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:14:53 +0900 Subject: [PATCH] =?UTF-8?q?fix(install-use-family):=20=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=20CLI=20=E6=A3=80=E6=9F=A5=E8=A1=A5=E4=B8=8A=20image-use?= =?UTF-8?q?=EF=BC=8C=E7=BB=99=E5=87=BA=E5=8D=95=E6=96=87=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=8C=87=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit image-use 没有 install.sh,CLI 是仓库根目录的单文件,提示改为从安装器已 clone 的 checkout 安装。PowerShell 版同步补上。新增端到端回归测试(假 git + 隔离 PATH)及 CI。 Fixes #25 --- .github/workflows/test.yml | 19 +++++++++++++++ install-use-family.ps1 | 8 +++++-- install-use-family.sh | 8 +++++-- tests/install-use-family.test.sh | 41 ++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 tests/install-use-family.test.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1ad1a56 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Test + +on: + pull_request: + push: + branches: [main] + +jobs: + installers: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: sh tests/install-use-family.test.sh + - name: install-use-family.ps1 parses + shell: pwsh + run: | + $errors = $null + [System.Management.Automation.Language.Parser]::ParseFile("$PWD/install-use-family.ps1", [ref]$null, [ref]$errors) | Out-Null + if ($errors) { $errors; exit 1 } diff --git a/install-use-family.ps1 b/install-use-family.ps1 index d1935fb..730e084 100644 --- a/install-use-family.ps1 +++ b/install-use-family.ps1 @@ -58,5 +58,9 @@ foreach ($name in $Uses.Keys) { '' "Skills are in $Skills. Start a new Codex session to pick them up." -$missing = @('chrome-use', 'mail-use', 'discord-use', 'chatgpt-use', 'ocs', 'paste-use') | Where-Object { -not (Get-Command $_ -ErrorAction SilentlyContinue) } -if ($missing) { "CLIs not installed yet: $($missing -join ', '). See each repo's README for the Windows install." } +$missing = @('chrome-use', 'mail-use', 'discord-use', 'chatgpt-use', 'ocs', 'paste-use', 'image-use') | Where-Object { -not (Get-Command $_ -ErrorAction SilentlyContinue) } +if ($missing) { + "CLIs not installed yet: $($missing -join ', '). See each repo's README for the Windows install." + # image-use has no installer: the CLI is a single Python file at the root of its checkout. + if ($missing -contains 'image-use') { " image-use: run it as py `"$(Join-Path $Base 'image-use\image-use')`"" } +} diff --git a/install-use-family.sh b/install-use-family.sh index 61e2afb..840446c 100644 --- a/install-use-family.sh +++ b/install-use-family.sh @@ -18,7 +18,7 @@ mail-use:skills/mail-use wechat-use:. discord-use:. profile-use:. bitwarden-use: chatgpt-use:. image-use:. memory-use:. ocs=open-cross-session:skills/ocs message-use:. motion-use:. paste-use:." # Uses that ship a CLI on PATH (iphone-use runs as a daemon, profile-use as a script in its skill). -CLIS="chrome-use cookie-use mail-use discord-use bitwarden-use chatgpt-use memory-use ocs motion-use" +CLIS="chrome-use cookie-use mail-use discord-use bitwarden-use chatgpt-use memory-use ocs motion-use image-use" repo_of() { # repo_of : the GitHub repo a use lives in case "$1" in ocs) echo open-cross-session ;; *) echo "$1" ;; esac @@ -65,6 +65,10 @@ echo "Skills are in $SKILLS. Start a new Codex session to pick them up." if [ -n "$missing" ]; then echo "CLIs not installed yet:$missing" for name in $missing; do - echo " curl -fsSL https://raw.githubusercontent.com/leeguooooo/$(repo_of "$name")/main/install.sh | sh" + case "$name" in + # image-use has no install.sh: the CLI is the single file at the root of the checkout above. + image-use) echo " sudo install \"$BASE/image-use/image-use\" /usr/local/bin/image-use" ;; + *) echo " curl -fsSL https://raw.githubusercontent.com/leeguooooo/$(repo_of "$name")/main/install.sh | sh" ;; + esac done fi diff --git a/tests/install-use-family.test.sh b/tests/install-use-family.test.sh new file mode 100644 index 0000000..703f013 --- /dev/null +++ b/tests/install-use-family.test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Runs install-use-family.sh end to end against a fake git and an isolated HOME/PATH, +# then checks the missing-CLI hints. Nothing outside a temp dir is touched. +# sh tests/install-use-family.test.sh +set -eu +ROOT=$(cd "$(dirname "$0")/.." && pwd) +TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT +mkdir -p "$TMP/bin" "$TMP/home" + +# Fake git: `clone` makes a checkout holding SKILL.md at every place the installer looks. +cat > "$TMP/bin/git" <<'GIT' +#!/bin/sh +for dest; do :; done +case "$*" in + *clone*) mkdir -p "$dest/.git"; touch "$dest/SKILL.md" + for sub in chrome-use cookie-use iphone-use mail-use ocs; do mkdir -p "$dest/skills/$sub"; touch "$dest/skills/$sub/SKILL.md"; done + mkdir -p "$dest/plugins/use-family/skills/use-family" ;; +esac +GIT +chmod +x "$TMP/bin/git" +for tool in sh mkdir ln readlink uname touch chmod rm cat dirname basename; do + ln -s "$(command -v "$tool")" "$TMP/bin/$tool" +done + +run() { # run: the installer's stdout, with only $TMP/bin on PATH + HOME="$TMP/home" PATH="$TMP/bin" sh "$ROOT/install-use-family.sh" +} +fail() { echo "FAIL: $1"; echo "$out"; exit 1; } + +out=$(run) +echo "$out" | grep -q '^CLIs not installed yet:.* image-use' || fail "image-use missing from the not-installed list" +echo "$out" | grep -qF "sudo install \"$TMP/home/.agents/use-family/image-use/image-use\" /usr/local/bin/image-use" \ + || fail "no single-file install hint for image-use" +echo "$out" | grep -q 'leeguooooo/image-use/main/install.sh' && fail "points at an install.sh image-use does not have" +echo "$out" | grep -qF 'leeguooooo/mail-use/main/install.sh | sh' || fail "generic install.sh hint lost" + +printf '#!/bin/sh\n' > "$TMP/bin/image-use"; chmod +x "$TMP/bin/image-use" +out=$(run) +echo "$out" | grep -q 'image-use/image-use\|not installed yet:.* image-use' && fail "image-use reported although it is on PATH" + +echo "ok install-use-family.sh"