Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 git fzf ripgrep git-delta worktrunk
- name: Verify setup in a fresh home
run: ./tests/smoke.sh --with-tools
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` で通常の出力に戻せる。
Expand All @@ -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 のユーザー名・メールと差分ページャーの初期値 |
Expand All @@ -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 の `status` と `doctor` で調べる。

設定を変えたら `./tests/smoke.sh` を実行する。一時ホームで初回のプレビュー、既存設定の引き継ぎ、再実行、worktree の切り替えを確認できる。PR の macOS CI では `./tests/smoke.sh --with-tools` を使い、指定版のツールを新しい zsh で起動する。
4 changes: 4 additions & 0 deletions config/interactive.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
1 change: 1 addition & 0 deletions config/tools.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 13 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand All @@ -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',
Expand Down
35 changes: 35 additions & 0 deletions scripts/doctor.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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 ))
else
for check in status doctor; do
if ! "$dotagents" "$check"; then
print -u2 "✗ dotagents の $check で問題が見つかりました。"
(( ++failures ))
fi
done
fi
exit $(( failures > 0 ))
11 changes: 7 additions & 4 deletions tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions tests/workstation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/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
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
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' >&2
exit 1
fi
grep -Fq 'codex' "$HOME/doctor.log"
grep -Fq 'dotagents doctor called' "$HOME/doctor.log"
Loading