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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).

## [0.78.3] - 2026-10-07

### Fixed
- **`uninstall.sh` が存在しない `claude uninstall` サブコマンドを呼んでいた問題を修正(#175)**: 「Claude Code CLI もアンインストールしますか?」に y と答えると、ネイティブ版(`~/.local/bin/claude` がある場合)、インストール方法を判別できない場合、Git Bash で `%LOCALAPPDATA%\Programs\claude` が無い場合に `claude uninstall` を実行していた。Claude Code 2.1.291 の `claude --help` のコマンド一覧に `uninstall` はなく、Usage は `claude [options] [command] [prompt]` なので、この語は削除コマンドではなくプロンプトとして渡る形になる(実 CLI で `claude uninstall` を実行した結果は確認していない)。ネイティブ版の分岐は、この呼び出しが失敗すると `~/.local/bin/claude` だけを削除して「アンインストールしました」と表示しており、ダウンロード済みの各バージョンが入った `~/.local/share/claude` が残っていた
- `claude uninstall` の呼び出しをすべてやめ、公式のアンインストール手順に合わせた。ネイティブ版は `~/.local/bin/claude` と `~/.local/share/claude` を削除する。対象は既定の配置だと確認できた場合に限る(macOS / Linux / WSL では、ランチャーが `~/.local/share/claude/versions/` 内を指す symlink で、`~/.local/bin` と `~/.local/share/claude` がどちらも symlink を経由しない実ディレクトリであること)。削除の直前に同じ確認をやり直し、ランチャーの削除と再帰削除は、ホームディレクトリ由来の固定パスに対してだけ、確認済みの親ディレクトリの中から行う。npm 版は従来どおり `npm uninstall -g @anthropic-ai/claude-code`、Homebrew 版は `brew uninstall --cask` を使い、これまで確認対象に入っていなかった `claude-code@latest` cask も検出する
- カスタムランチャー(`~/.local/bin/claude` が通常ファイルや別の場所を指す symlink)、`~/.local/bin`・`~/.local/share/claude` やその親が symlink の配置、`XDG_DATA_HOME` などで既定以外の場所へ移した配置は、このスクリプトからは削除しない。その場合も npm と Homebrew には CLI が入っているかを確認し、見つかればそれぞれのアンインストールコマンドを実行する(npm の prefix を `~/.local` にしていて npm 版のリンクが `~/.local/bin/claude` にある環境や、Homebrew cask と古い自作スクリプトが併存する環境が該当する)。どちらにも見つからない場合と、インストール方法を判別できない場合は、公式ドキュメントの URL と方法別の削除コマンドを表示する。削除に成功したあとも `claude` コマンドが見つかる場合は、別のインストールが残っている可能性を警告する。確認プロンプトの待機中に `claude` コマンドが見つからなくなった場合は、インストールされていないと表示して残りの処理を続ける
- Git Bash では、公式手順に記載のない `%LOCALAPPDATA%\Programs\claude` の再帰削除をやめ、`%USERPROFILE%\.local\bin\claude.exe` と `%USERPROFILE%\.local\share\claude` を対象にした。旧配置にある CLI は自動削除されず、手動の手順が表示される。Git Bash の分岐は実機では未検証で、テストは `_IS_MSYS` を立てた擬似環境での確認にとどまる
- 設定とセッション履歴(`~/.claude`、`~/.claude.json`)は従来どおり CLI の削除では触らず、削除後にその旨を表示する。確認プロンプトの数と順序、未入力(EOF)を「残す」として扱う点は変えていない
- **回帰テスト**: `tests/unit/test-uninstall.sh` に、使い捨ての HOME とスタブの `claude` / `npm` / `brew` で CLI 削除プロンプト以降の経路を確かめる検証を 20 件追加した(ネイティブ版の既定配置、カスタムランチャー、symlink のデータディレクトリ、symlink の親ディレクトリ、symlink の `~/.local/bin`、既定以外の場所への配置、判別不能、npm、Homebrew cask 2 種、`~/.local/bin/claude` に既定配置以外のランチャーがある状態の npm 版と Homebrew cask、npm・Homebrew・ネイティブ版それぞれの削除失敗が完了ではなく失敗として表示されること、n と EOF での辞退、プロンプト待機中に `claude` が削除された場合、削除関数が空・相対・HOME 外のパスと、検出後に symlink へ差し替えられた `~/.local/bin` を拒否すること、Git Bash 分岐の擬似環境)。修正前のコードでは 20 件中 18 件が失敗する(辞退の 2 件は従来から通る)。`tests/unit/test-codex-setup.sh` には、同梱スクリプトがコマンド位置で呼ぶ `claude <語>` / `_claude_cli <語>` の第 1 階層が、現在使っている `plugin` / `mcp` 以外でないことの静的検査を追加した。修正前のコードでは `uninstall.sh` の 3 箇所を検出する
- **既存インストールへの影響**: 以前に y を選んでランチャーだけが削除された環境には `~/.local/share/claude` が残っている場合がある。不要なら `rm -rf ~/.local/share/claude` で削除できる。今後ネイティブ版で y を選ぶと、これまで残っていた `~/.local/share/claude`(ダウンロード済みの全バージョン)も削除される

## [0.78.2] - 2026-10-06

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ Only files deployed by the starter kit (tracked in `~/.claude/.starter-kit-manif

Some things the kit installed are offered rather than removed automatically, because they may outlive the kit: the Claude Code CLI, the Codex plugin, `cc-safety-net`, and local data under `~/.claude/security/` when the kit has a durable record of a verified `security-guidance` install. Regardless of fresh/update mode or legacy manifest selections, a plugin already present in the pre-install list is not adopted into this record, and its local data is not offered for cleanup. Each item is a separate prompt that defaults to keeping it. Accepting the local-data cleanup removes only known plugin-owned leaves such as its Python environments, session state, and logs; unknown files and directories in the shared location are preserved. Data moved elsewhere through environment-variable overrides is outside the cleanup scope.

Accepting the Claude Code CLI prompt removes only the CLI itself, following the official uninstall steps. A native install loses `~/.local/bin/claude` and `~/.local/share/claude` (the downloaded versions); an npm install or a Homebrew cask (`claude-code` / `claude-code@latest`) is removed with its own uninstall command. Removing the CLI does not touch settings or session history (`~/.claude`, `~/.claude.json`). A native install is removed only when it is confirmed to be in the default layout. A custom launcher, a symlinked `~/.local/bin` or data directory, or a location moved with `XDG_DATA_HOME` is never deleted by the script itself. An npm install or a Homebrew cask found in that situation is still removed with its own uninstall command; when neither is found, the manual steps are shown instead.

## Development

Shell scripts are statically analyzed with [ShellCheck](https://www.shellcheck.net/). It runs automatically via GitHub Actions on PRs. To run locally:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,8 @@ cd claude-code-starter-kit

キットが導入したもののうち、キットより長く使う可能性があるものは自動削除せず個別に確認します(既定はすべて「残す」)。対象は Claude Code CLI、Codex プラグイン、`cc-safety-net`、そしてキットによる検証済みの導入履歴が記録された `security-guidance` が `~/.claude/security/` に作るローカルデータです。fresh / update の別や旧 manifest の選択内容にかかわらず、セットアップの導入前一覧にすでに存在したプラグインはこの履歴に採用せず、そのローカルデータには削除を提示しません。ローカルデータの削除を選んでも、Python 仮想環境・セッション状態・ログ等の既知の plugin-owned leaf だけを削除し、同じディレクトリにある未知のファイルやディレクトリは保持します。環境変数で別の場所へ移したデータは対象外です。

Claude Code CLI の削除を選ぶと、CLI 本体だけを公式のアンインストール手順どおりに削除します。ネイティブ版は `~/.local/bin/claude` と `~/.local/share/claude`(ダウンロード済みの各バージョン)を削除し、npm 版と Homebrew cask(`claude-code` / `claude-code@latest`)はそれぞれのアンインストールコマンドを実行します。CLI の削除では、設定とセッション履歴(`~/.claude`、`~/.claude.json`)には触れません。ネイティブ版として削除するのは、既定の配置だと確認できた場合だけです。カスタムランチャー、symlink になっている `~/.local/bin` やデータディレクトリ、`XDG_DATA_HOME` で移した配置は、このスクリプトからは削除しません。その場合も npm 版か Homebrew cask が見つかればそのアンインストールコマンドを実行し、見つからなければ手動の手順を表示します。

---

## ❓ FAQ
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/test-codex-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,35 @@ else
fi
fi

# The CLI treats a word it does not know as a prompt (`claude [options]
# [command] [prompt]`) and starts a session, so a shipped script must only pass
# subcommands that exist. The allowlist holds the first-level subcommands the
# shipped scripts call today; confirm a new one against `claude --help` before
# adding it. Known invocations are marked (`claude=plugin`) rather than dropping
# their whole line, so an unknown one sharing the line is still reported.
# `_claude_cli` is matched anywhere; a bare `claude` only in command position,
# which keeps display strings out. Not covered: flags before the word,
# arguments held in variables, second-level subcommands, and wrappers other
# than the listed keywords.
if ! git -C "$PROJECT_DIR" rev-parse --is-inside-work-tree &>/dev/null; then
skip "codex-setup: shipped scripts only call claude subcommands that exist" "needs a git checkout"
else
_claude_known_subcommands='plugin|mcp'
_claude_grep_bol='^[^:]+:[0-9]+:'
_unknown_claude_calls="$(
cd "$PROJECT_DIR" && git grep -nE '(^|[^A-Za-z0-9_])(_claude_cli|claude)[[:space:]]+[a-z]' \
-- setup.sh install.sh uninstall.sh 'lib/*.sh' 'wizard/*.sh' 'mdm/*.sh' 'features/*.sh' \
| grep -vE "${_claude_grep_bol}[[:space:]]*#" \
| sed -E "s/(_claude_cli|claude)[[:space:]]+(${_claude_known_subcommands})([^A-Za-z0-9_-]|\$)/\\1=\\2\\3/g" \
| grep -E "((${_claude_grep_bol}|[;&|(){!\`])[[:space:]]*|(${_claude_grep_bol}|[^A-Za-z0-9_])(if|elif|while|until|then|do|else|exec|command|time)[[:space:]]+)claude[[:space:]]+[a-z]|(${_claude_grep_bol}|[^A-Za-z0-9_])_claude_cli[[:space:]]+[a-z]" || true
)"
if assert_equals "" "$_unknown_claude_calls"; then
pass "codex-setup: shipped scripts only call claude subcommands that exist"
else
fail "codex-setup: claude was called with a word that is not a known subcommand: $_unknown_claude_calls"
fi
fi

# Legacy MCP removal should rely on scope-agnostic CLI removal
setup_fake_claude
export MOCK_CLAUDE_LIST_OUTPUT=$'codex\n'
Expand Down
Loading
Loading