From b34b36d869138875f34fc1f294a07b453495e6d1 Mon Sep 17 00:00:00 2001 From: bwkw <63583536+bwkw@users.noreply.github.com> Date: Sat, 28 Nov 2026 23:29:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Mac=20=E3=81=AE=E4=B8=A6=E8=A1=8C=E9=96=8B?= =?UTF-8?q?=E7=99=BA=E7=92=B0=E5=A2=83=E3=82=92=E6=95=B4=E3=81=88=E3=80=81?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E3=82=B7=E3=82=A7=E3=83=AB?= =?UTF-8?q?=E3=81=8B=E3=82=89=E8=A8=BA=E6=96=AD=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/verify.yml | 2 +- README.md | 21 ++++++++++++------ config/interactive.zsh | 4 ++++ config/tools.toml | 1 + mise.toml | 13 +++++++++++ scripts/doctor.zsh | 31 ++++++++++++++++++++++++++ tests/smoke.sh | 11 ++++++---- tests/workstation.sh | 42 ++++++++++++++++++++++++++++++++++++ 8 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 scripts/doctor.zsh create mode 100644 tests/workstation.sh diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 4a31474..8676c21 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -17,6 +17,6 @@ jobs: with: persist-credentials: false - name: Install test prerequisites - run: brew install mise fzf ripgrep git-delta + run: brew install mise fzf ripgrep git-delta worktrunk - name: Verify setup in a fresh home run: ./tests/smoke.sh --with-tools diff --git a/README.md b/README.md index 78a6301..12b3467 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,22 @@ Git や SSH 鍵をまだ設定していない場合は、GitHub の **Code → D /bin/bash ~/dotfiles/setup.sh ``` -スクリプトは不足している Homebrew と mise を導入してから `mise bootstrap` を実行する。Homebrew が求める管理者パスワードや macOS の許可は画面で入力する。GitHub、AI ツール、AWS のログインは端末ごとに行う。導入後は**新しいターミナル**で確認できる。 +スクリプトは不足している Homebrew と mise を導入してから `mise bootstrap` を実行する。Homebrew が求める管理者パスワードや macOS の許可は画面で入力する。GitHub、AI ツール、AWS のログインは端末ごとに行う。導入後はこのリポジトリで診断を実行する。 ```sh -node --version -pnpm --version -uv --version -alias gs +mise run doctor ``` ## 普段の使い方 +| やりたいこと | 操作 | +| --- | --- | +| AI が作業中のブランチを見渡す | プロジェクトで `wt list`。新しい作業には `wt switch -c fix-ui`、PR のレビューには `wt switch pr:123` で移動する。[Worktrunk](https://worktrunk.dev/) | +| 変更前と変更後の画面を並べる | 例えば Vite なら、main と作業ブランチでそれぞれ `portless run pnpm exec vite` を実行し、表示された URL を開く。アプリ名が `web` なら `web.localhost` と `fix-ui.web.localhost` を同時に開ける。[Portless](https://github.com/vercel-labs/portless) | +| Mac のホームを共有せずにコードを試す | OrbStack を起動し、初回だけ `orb create --isolated --isolate-network ubuntu ai-sandbox` で Linux 環境を作る。次からは `orb -m ai-sandbox` で入る。[OrbStack](https://docs.orbstack.dev/machines/isolated) | + +チームでも同じ URL を使うなら、そのプロジェクトで `pnpm add -DE portless` を実行し、既存の `dev` スクリプトを `portless run vite` などに変更する。以後は全員がいつもの `pnpm dev` で起動できる。 + - **Ctrl-R** を押してコマンド履歴を検索する。文字を入力して絞り込み、Enter でコマンドラインに戻せる。 - **Ctrl-T** でカレントディレクトリ以下のファイルを検索し、選んだパスを入力中のコマンドに挿入する。例えば `git add ` に続けて押すと、空白を含むファイル名も選べる。候補は ripgrep が生成し、リポジトリの `.gitignore` を反映する。 - **`gd` / `git diff`** で変更行の中の差分も色分けして読む。Git のページャーが未設定なら delta を使う。`git --no-pager diff` で通常の出力に戻せる。 @@ -37,7 +42,7 @@ alias gs | ファイル | 管理するもの | | --- | --- | -| `config/tools.toml` | Node.js・pnpm・uv のバージョンと Node のバージョンファイル対応。グローバルの `~/.config/mise/conf.d/10-dotfiles.toml` にリンクする。プロジェクト側の指定が優先される | +| `config/tools.toml` | Node.js・pnpm・uv・Portless のバージョン。グローバルの `~/.config/mise/conf.d/10-dotfiles.toml` にリンクする。プロジェクト側の指定が優先される | | `mise.toml` | Homebrew の CLI、zsh の mise 有効化、dotagents の取得とセットアップ順 | | `config/interactive.zsh`、`config/homebrew.zsh` | Git・npm・Cursor のエイリアス、ディレクトリ移動の `z`、Go・curl・psql・VS Code のパス。zsh の既存ファイルに管理ブロックを追加する | | `scripts/configure-git.sh` | Git のユーザー名・メールと差分ページャーの初期値 | @@ -61,4 +66,6 @@ mise bootstrap status # mise の設定と現在の状態を照合する 別の Mac で変更した設定を取り込む場合は、Git で取得した checkout 内で `git pull --ff-only && ./setup.sh` を実行する。ZIP から始めた場合は、更新版を同じ場所に展開して再実行する。 -設定を変えたら `./tests/smoke.sh` を実行する。一時ホームで初回のプレビュー、既存設定の引き継ぎ、再実行をオフラインで確認できる。PR の macOS CI では `./tests/smoke.sh --with-tools` を使い、Node.js・pnpm・uv をダウンロードして、新しい zsh で指定版が起動するところまで確かめる。 +`mise run doctor` は新しいログインシェルで各 CLI の起動、Worktrunk の zsh 連携、OrbStack の隔離機能を確かめる。スキルと hooks は dotagents の診断に引き継ぐ。 + +設定を変えたら `./tests/smoke.sh` を実行する。一時ホームで初回のプレビュー、既存設定の引き継ぎ、再実行、worktree の切り替えを確認できる。PR の macOS CI では `./tests/smoke.sh --with-tools` を使い、指定版のツールを新しい zsh で起動する。 diff --git a/config/interactive.zsh b/config/interactive.zsh index 16b1a50..6a71e8d 100644 --- a/config/interactive.zsh +++ b/config/interactive.zsh @@ -27,6 +27,10 @@ if [[ -n ${HOMEBREW_PREFIX:-} ]]; then fi fi +if [[ -o interactive ]] && (( $+commands[wt] && ! $+functions[wt] )); then + eval "$(command wt config shell init zsh)" +fi + if [[ -o interactive && -t 0 ]] && (( $+commands[fzf] && ! $+functions[fzf-history-widget] )); then if (( $+commands[rg] && ! ${+FZF_CTRL_T_COMMAND} )); then export FZF_CTRL_T_COMMAND="rg --files --hidden --glob '!.git'" diff --git a/config/tools.toml b/config/tools.toml index 3c1afe7..e835e9b 100644 --- a/config/tools.toml +++ b/config/tools.toml @@ -5,4 +5,5 @@ idiomatic_version_file_enable_tools = ["node"] [tools] node = "24.22.1" pnpm = "11.28.10" +"npm:portless" = "0.18.1" uv = "0.13.4" diff --git a/mise.toml b/mise.toml index 8793258..819489a 100644 --- a/mise.toml +++ b/mise.toml @@ -1,5 +1,9 @@ min_version = { hard = "2026.10.17" } +# Bootstrap installs tools explicitly. Diagnostics must also work when tools are missing. +[settings.task] +run_auto_install = false + [bootstrap.packages] "brew:git" = "latest" "brew:gh" = "latest" @@ -9,6 +13,7 @@ min_version = { hard = "2026.10.17" } "brew:ripgrep" = "latest" "brew:fzf" = "latest" "brew:git-delta" = "latest" +"brew:worktrunk" = "latest" "brew:poppler" = "latest" "brew:pup" = "latest" "brew:rtk" = "latest" @@ -31,6 +36,14 @@ min_version = { hard = "2026.10.17" } [bootstrap.mise_shell_activate] zsh = true +[tasks.doctor] +description = "新しい zsh で開発ツールと dotagents の導入状態を調べる" +run = ''' +doctor="$PWD/scripts/doctor.zsh" +cd "$HOME" +exec env PATH=/usr/bin:/bin:/usr/sbin:/sbin MISE_AUTO_INSTALL=0 /bin/zsh -il "$doctor" +''' + [tasks.bootstrap] run = [ 'bash scripts/configure-git.sh', diff --git a/scripts/doctor.zsh b/scripts/doctor.zsh new file mode 100644 index 0000000..a844001 --- /dev/null +++ b/scripts/doctor.zsh @@ -0,0 +1,31 @@ +# Runs in a fresh interactive login zsh, from the user's home. +typeset -i failures=0 +for tool in node pnpm uv portless wt codex claude; do + if version=$("$tool" --version 2>/dev/null); then + printf '✓ %s %s\n' "$tool" "$version" + else + printf '✗ %s が起動しません。./setup.sh の導入結果と PATH を確認してください。\n' "$tool" >&2 + (( ++failures )) + fi +done + +if (( $+commands[wt] && ! $+functions[wt] )); then + print -u2 '✗ wt の zsh 連携が無効です。./setup.sh でシェル設定を反映してください。' + (( ++failures )) +fi +if [[ "$(orb create --help 2>/dev/null)" == *--isolated* ]]; then + print '✓ OrbStack で隔離環境を作成できます。' +else + print -u2 '✗ orb create --isolated が見つかりません。OrbStack の導入とバージョンを確認してください。' + (( ++failures )) +fi + +dotagents="$HOME/private/dotagents/scripts/setup.sh" +if [[ ! -x "$dotagents" ]]; then + print -u2 '✗ dotagents が見つかりません。./setup.sh で取得してください。' + (( ++failures )) +elif ! "$dotagents" doctor; then + print -u2 '✗ dotagents の診断で問題が見つかりました。' + (( ++failures )) +fi +exit $(( failures > 0 )) diff --git a/tests/smoke.sh b/tests/smoke.sh index d088fdc..f0476f2 100755 --- a/tests/smoke.sh +++ b/tests/smoke.sh @@ -13,7 +13,7 @@ trap 'rm -rf "$scratch"' EXIT mkdir -p "$scratch/home" "$scratch/bin" mkdir -p "$scratch/checkout" (cd "$repo" && tar --exclude=.git -cf - .) | (cd "$scratch/checkout" && tar -xf -) -for tool in mise brew fzf rg delta; do +for tool in mise brew fzf rg delta wt; do executable=$(command -v "$tool") || { echo "Missing $tool. Run setup.sh first." >&2; exit 1; } ln -s "$executable" "$scratch/bin/$tool" done @@ -32,7 +32,7 @@ if ! preview=$("$repo/setup.sh" --dry-run --only dotfiles,mise-shell-activate,to echo "$preview" >&2 exit 1 fi -for tool in node pnpm uv; do +for tool in node pnpm uv portless; do if ! grep -Eq "$tool@[^ ]+.*would install" <<< "$preview"; then echo "Missing $tool in first-run preview:" >&2 echo "$preview" >&2 @@ -44,8 +44,10 @@ if [[ $2 == --with-tools ]]; then MISE_OFFLINE=0 "$repo/setup.sh" --only dotfiles,mise-shell-activate,tools zsh -lic ' set -e - for tool in node pnpm uv; do - expected=$(mise current "$tool") + for tool in node pnpm uv portless; do + backend=$tool + [[ $tool != portless ]] || backend=npm:portless + expected=$(mise current "$backend") binary=$(command -v "$tool") [[ "$binary" == "$HOME/"* ]] || { echo "Unexpected path: $binary" >&2; exit 1; } version=$("$tool" --version) @@ -103,4 +105,5 @@ cp "$HOME/.config/git/ignore" "$HOME/before.ignore" "$repo/setup.sh" --only dotfiles,mise-shell-activate cmp "$HOME/.zshrc" "$HOME/before.zshrc" cmp "$HOME/.config/git/ignore" "$HOME/before.ignore" +bash "$repo/tests/workstation.sh" "$repo" "$2" CHECK diff --git a/tests/workstation.sh b/tests/workstation.sh new file mode 100644 index 0000000..8d267e3 --- /dev/null +++ b/tests/workstation.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Called by smoke.sh inside its disposable home. +set -euo pipefail +repo=$1 +cd "$HOME/sample" +git -c user.name=Test -c user.email=test@example.test commit -qm 'fixture' --allow-empty +zsh -ic ' + set -e + wt switch --create review-test + [[ $(git branch --show-current) == review-test ]] + wt list --format=json > "$HOME/worktrees.json" +' +grep -q 'review-test' "$HOME/worktrees.json" + +# The CI runner has no agent accounts or OrbStack VM. Exercise just those boundaries. +mkdir -p "$HOME/fixture-bin" "$HOME/private/dotagents/scripts" +for tool in codex claude; do + printf '#!/bin/sh\n[ "$1" = --version ] && echo "%s test"\n' "$tool" > "$HOME/fixture-bin/$tool" +done +printf '#!/bin/sh\n[ "$1 $2" = "create --help" ] && echo " --isolated Create an isolated machine"\n' > "$HOME/fixture-bin/orb" +chmod +x "$HOME/fixture-bin/"* +printf '\nexport PATH="$HOME/fixture-bin:$TMPDIR/bin:$PATH"\n' >> "$HOME/.zprofile" +cat > "$HOME/private/dotagents/scripts/setup.sh" <<'DOTAGENTS' +#!/bin/sh +[ "$1" = doctor ] || exit 2 +echo "dotagents doctor called" +test ! -e "$HOME/doctor-fault" +DOTAGENTS +chmod +x "$HOME/private/dotagents/scripts/setup.sh" +cd "$repo" +if [[ $2 == --with-tools ]]; then + mise run doctor > "$HOME/doctor.log" + grep -Fq 'dotagents doctor called' "$HOME/doctor.log" +fi +touch "$HOME/doctor-fault" +printf '#!/bin/sh\nexit 1\n' > "$HOME/fixture-bin/codex" +if mise run doctor > "$HOME/doctor.log" 2>&1; then + echo 'doctor missed a broken CLI and failing dotagents check' >&2 + exit 1 +fi +grep -Fq 'codex' "$HOME/doctor.log" +grep -Fq 'dotagents doctor called' "$HOME/doctor.log" From 208e95e79ae24b627113ddfeed91321ada9411b5 Mon Sep 17 00:00:00 2001 From: bwkw <63583536+bwkw@users.noreply.github.com> Date: Sat, 28 Nov 2026 23:33:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?CI=20=E3=81=A7=20Homebrew=20=E3=81=AE=20Git?= =?UTF-8?q?=20=E3=82=92=E4=BD=BF=E3=81=84=E3=80=81dotagents=20=E3=81=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=82=82=E8=A8=BA=E6=96=AD=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/verify.yml | 2 +- README.md | 2 +- scripts/doctor.zsh | 10 +++++++--- tests/smoke.sh | 2 +- tests/workstation.sh | 16 +++++++++++----- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 8676c21..d7e831c 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -17,6 +17,6 @@ jobs: with: persist-credentials: false - name: Install test prerequisites - run: brew install mise fzf ripgrep git-delta worktrunk + run: brew install mise git fzf ripgrep git-delta worktrunk - name: Verify setup in a fresh home run: ./tests/smoke.sh --with-tools diff --git a/README.md b/README.md index 12b3467..f21d388 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,6 @@ mise bootstrap status # mise の設定と現在の状態を照合する 別の Mac で変更した設定を取り込む場合は、Git で取得した checkout 内で `git pull --ff-only && ./setup.sh` を実行する。ZIP から始めた場合は、更新版を同じ場所に展開して再実行する。 -`mise run doctor` は新しいログインシェルで各 CLI の起動、Worktrunk の zsh 連携、OrbStack の隔離機能を確かめる。スキルと hooks は dotagents の診断に引き継ぐ。 +`mise run doctor` は新しいログインシェルで各 CLI の起動、Worktrunk の zsh 連携、OrbStack の隔離機能を確かめる。スキルの配置や hooks の接続状態は dotagents の `status` と `doctor` で調べる。 設定を変えたら `./tests/smoke.sh` を実行する。一時ホームで初回のプレビュー、既存設定の引き継ぎ、再実行、worktree の切り替えを確認できる。PR の macOS CI では `./tests/smoke.sh --with-tools` を使い、指定版のツールを新しい zsh で起動する。 diff --git a/scripts/doctor.zsh b/scripts/doctor.zsh index a844001..ff823d3 100644 --- a/scripts/doctor.zsh +++ b/scripts/doctor.zsh @@ -24,8 +24,12 @@ dotagents="$HOME/private/dotagents/scripts/setup.sh" if [[ ! -x "$dotagents" ]]; then print -u2 '✗ dotagents が見つかりません。./setup.sh で取得してください。' (( ++failures )) -elif ! "$dotagents" doctor; then - print -u2 '✗ dotagents の診断で問題が見つかりました。' - (( ++failures )) +else + for check in status doctor; do + if ! "$dotagents" "$check"; then + print -u2 "✗ dotagents の $check で問題が見つかりました。" + (( ++failures )) + fi + done fi exit $(( failures > 0 )) diff --git a/tests/smoke.sh b/tests/smoke.sh index f0476f2..12141c4 100755 --- a/tests/smoke.sh +++ b/tests/smoke.sh @@ -13,7 +13,7 @@ trap 'rm -rf "$scratch"' EXIT mkdir -p "$scratch/home" "$scratch/bin" mkdir -p "$scratch/checkout" (cd "$repo" && tar --exclude=.git -cf - .) | (cd "$scratch/checkout" && tar -xf -) -for tool in mise brew fzf rg delta wt; do +for tool in mise brew git fzf rg delta wt; do executable=$(command -v "$tool") || { echo "Missing $tool. Run setup.sh first." >&2; exit 1; } ln -s "$executable" "$scratch/bin/$tool" done diff --git a/tests/workstation.sh b/tests/workstation.sh index 8d267e3..ab8d1b1 100644 --- a/tests/workstation.sh +++ b/tests/workstation.sh @@ -22,20 +22,26 @@ chmod +x "$HOME/fixture-bin/"* printf '\nexport PATH="$HOME/fixture-bin:$TMPDIR/bin:$PATH"\n' >> "$HOME/.zprofile" cat > "$HOME/private/dotagents/scripts/setup.sh" <<'DOTAGENTS' #!/bin/sh -[ "$1" = doctor ] || exit 2 -echo "dotagents doctor called" -test ! -e "$HOME/doctor-fault" +case "$1" in status|doctor) ;; *) exit 2 ;; esac +echo "dotagents $1 called" +test ! -e "$HOME/$1-fault" DOTAGENTS chmod +x "$HOME/private/dotagents/scripts/setup.sh" cd "$repo" if [[ $2 == --with-tools ]]; then mise run doctor > "$HOME/doctor.log" + grep -Fq 'dotagents status called' "$HOME/doctor.log" + touch "$HOME/status-fault" + if mise run doctor > "$HOME/doctor.log" 2>&1; then + echo 'doctor missed a failed dotagents status check' >&2 + exit 1 + fi grep -Fq 'dotagents doctor called' "$HOME/doctor.log" + rm "$HOME/status-fault" fi -touch "$HOME/doctor-fault" printf '#!/bin/sh\nexit 1\n' > "$HOME/fixture-bin/codex" if mise run doctor > "$HOME/doctor.log" 2>&1; then - echo 'doctor missed a broken CLI and failing dotagents check' >&2 + echo 'doctor missed a broken CLI' >&2 exit 1 fi grep -Fq 'codex' "$HOME/doctor.log"