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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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.2] - 2026-10-06

### Fixed
- **macOS の対話インストールでプラグインマーケットプレイスの追加とプラグインのインストールが失敗する問題を修正**: `install.sh` は `curl | bash` でもウィザードが入力を受け取れるように `setup.sh` の stdin を `/dev/tty` へ付け替えて起動する。ネイティブ版 Claude Code CLI(Bun でビルドされたバイナリ)はこの stdin を kqueue で監視しようとするが、macOS の kqueue は `/dev/tty` という別名デバイスを受け付けないため、`claude plugin marketplace add` / `claude plugin list` / `claude plugin install` が `error: EINVAL: invalid argument, kqueue` で異常終了していた。その結果、新規 Mac では `claude-plugins-official`(Full プロファイルでは `anthropic-agent-skills` も)の追加失敗に続いて「Could not refresh installed plugins after marketplace setup」が表示され、既定プラグインが 1 つも入らなかった。この失敗で `install_selected_plugins` が非 0 を返すため、後続の Codex Plugin セットアップ(有効時)と Claude CLI の最終確認も実行されずに終了していた。stdin が `/dev/null` の場合や、`/dev/tty` ではなく実際の pty デバイスの場合は発生しないため、`bash setup.sh` を直接実行した場合や非対話インストールでは再現しない
- キットから実行する `claude plugin` / `claude mcp` / `claude --version` の呼び出し(`setup.sh` のプラグイン導入、`lib/codex-setup.sh` の Codex プラグイン導入とレガシー MCP 削除、`lib/deploy.sh` のバージョン取得、`uninstall.sh` の Codex 後片付け)を、すべて stdin を `/dev/null` にして実行するよう変更した。`setup.sh` と `lib/codex-setup.sh` の呼び出しは新設の `_claude_cli()` を経由させ、`lib/deploy.sh` のバージョン取得と、自己完結が必要な `uninstall.sh` はリダイレクトを直接書いている。これらのサブコマンドは入力を読まないため挙動は変わらない。`uninstall.sh` の確認プロンプトは従来どおり利用者の入力を読む
- **回帰テスト**: `tests/unit/test-codex-setup.sh` に、`_claude_cli` が呼び出し元の stdin を引き継がないことの検証と、同梱スクリプト内の `claude plugin|mcp|--version` 呼び出しが `_claude_cli` か `</dev/null` を経由していることの静的検査を追加した。修正前のコードでは静的検査が 13 箇所を検出する
- **既存インストールへの影響**: 一度失敗した環境は、更新後に `install.sh` を再実行する(更新モードで全プラグインの再導入を試みる)か、Claude Code 内で `/plugin marketplace add anthropics/claude-plugins-official` などを実行すれば復旧できる

## [0.78.1] - 2026-09-08

`web-content-extraction` skill の `@xmldom/xmldom` 脆弱性を解消(Dependabot alert #26)。
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Rules to remember: verify fresh install, `setup.sh --update`/`/update-kit`, and
- **Windows interop from WSL/MSYS**: Use `powershell.exe -NoProfile -Command '...'` for Windows-side operations (font install, WT config). Always `tr -d '\r'` on output to strip CRLF.
- **Codex Plugin scope**: Always use `claude plugin install codex --scope user` (user scope, not project scope).
- **Timeout portability**: Use `_run_with_timeout` wrapper (macOS lacks `timeout`).
- **Claude CLI stdin**: Call non-interactive `claude` subcommands through `_claude_cli()` (`lib/codex-setup.sh`, runs `claude "$@" </dev/null`); `claude --version` in `lib/deploy.sh` and the self-contained `uninstall.sh` write `</dev/null` inline. `install.sh` execs `setup.sh` with stdin=`/dev/tty`, which the Bun-based CLI cannot register with kqueue on macOS (`EINVAL: invalid argument, kqueue`). A static guard in `tests/unit/test-codex-setup.sh` enforces this for `claude plugin|mcp|--version`.
- **Config persistence**: `~/.claude-starter-kit.conf` uses `key="value"` format, parsed by `_safe_source_config()` (allowlisted key=value parser, never sourced as shell code).
- **Temp file hygiene**: `setup.sh` sets `umask 077` at top, tracks temp files in `_SETUP_TMP_FILES` array, and registers `trap _cleanup_tmp EXIT INT TERM` for automatic cleanup.
- **Credential safety**: Pass API keys via `curl --config -` (stdin) to avoid exposing in `ps` output. Never use `curl -H "Authorization: Bearer $key"` directly.
Expand Down
25 changes: 19 additions & 6 deletions lib/codex-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# wizard/wizard.sh (is_true)
# Uses globals: ENABLE_CODEX_PLUGIN, WIZARD_NONINTERACTIVE, _SETUP_TMP_FILES[],
# STR_CODEX_*, STR_CHOICE
# Exports: run_codex_setup(), _setup_codex_plugin(), _install_codex_cli(),
# Exports: run_codex_setup(), _claude_cli(), _setup_codex_plugin(), _install_codex_cli(),
# _verify_openai_key(), _save_openai_key()
# Dry-run: guarded externally (setup.sh logs EXTERNAL, does not call run_codex_setup)
set -euo pipefail
Expand Down Expand Up @@ -33,6 +33,19 @@ _run_capture() {
return "$_rc"
}

# _claude_cli(): run a non-interactive `claude` subcommand with stdin detached.
# install.sh execs setup.sh with stdin redirected from /dev/tty so the wizard
# can prompt during `curl | bash`. The native Claude CLI (a Bun binary)
# registers stdin with kqueue in subcommands such as `plugin` and `mcp`, and
# macOS kqueue rejects the /dev/tty alias device, so those calls died with
# "EINVAL: invalid argument, kqueue" (a real /dev/ttysNNN, a pipe, or /dev/null
# all work). None of these subcommands read input, so /dev/null is safe on
# every platform. The CLI installer is unaffected: it runs under `curl | bash`,
# so the binary inherits a pipe.
_claude_cli() {
claude "$@" </dev/null
}

# _claude_plugin_list_has(): structured match against `claude plugin list`
# output. The marker check is widened from a fixed "-"/"*"/"+" set to "any
# token not starting with an alnum/underscore", since the installed CLI
Expand Down Expand Up @@ -378,12 +391,12 @@ _codex_fully_ready() {
_has_codex_plugin() {
local _plugin_list=""
command -v claude &>/dev/null \
&& _plugin_list="$(claude plugin list 2>/dev/null)" \
&& _plugin_list="$(_claude_cli plugin list 2>/dev/null)" \
&& _claude_plugin_list_has "$_plugin_list" "codex"
}

_has_legacy_mcp() {
command -v claude &>/dev/null && claude mcp list 2>/dev/null | grep -qw "codex" 2>/dev/null
command -v claude &>/dev/null && _claude_cli mcp list 2>/dev/null | grep -qw "codex" 2>/dev/null
}

_install_codex_plugin() {
Expand All @@ -394,11 +407,11 @@ _install_codex_plugin() {
return 1
fi
local _marketplace_output="" _install_output=""
if ! _run_capture _marketplace_output claude plugin marketplace add openai/codex-plugin-cc; then
if ! _run_capture _marketplace_output _claude_cli plugin marketplace add openai/codex-plugin-cc; then
warn "${STR_CODEX_PLUGIN_MARKETPLACE_FAILED:-Failed to add Codex plugin marketplace. Continuing to install attempt:}"
[[ -n "$_marketplace_output" ]] && info " $_marketplace_output"
fi
if _run_capture _install_output claude plugin install codex --scope user; then
if _run_capture _install_output _claude_cli plugin install codex --scope user; then
return 0
fi
warn "${STR_CODEX_PLUGIN_FAILED:-Failed to install Codex plugin}"
Expand All @@ -411,7 +424,7 @@ _install_codex_plugin() {
_remove_legacy_mcp() {
if _has_legacy_mcp; then
local _remove_output=""
if _run_capture _remove_output claude mcp remove codex; then
if _run_capture _remove_output _claude_cli mcp remove codex; then
return 0
fi
warn "${STR_CODEX_MCP_REMOVE_FAILED:-Failed to remove Codex MCP. Remove manually:}"
Expand Down
4 changes: 3 additions & 1 deletion lib/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ _claude_cli_semver() {
return 0
fi
_CLAUDE_SEMVER_CACHE_SET=true
raw="$(claude --version 2>/dev/null | head -1)"
# --version exits before touching stdin; detached anyway for consistency with
# _claude_cli() in lib/codex-setup.sh (macOS kqueue rejects a /dev/tty stdin).
raw="$(claude --version </dev/null 2>/dev/null | head -1)"
if ! [[ "$raw" =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
_CLAUDE_SEMVER_CACHE=""
return 1
Expand Down
6 changes: 3 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ _read_claude_plugin_list() { # <output-variable>
local output_var="$1" plugin_snapshot=""
printf -v "$output_var" '%s' ""
command -v claude &>/dev/null || return 1
if ! plugin_snapshot="$(claude plugin list 2>/dev/null)"; then
if ! plugin_snapshot="$(_claude_cli plugin list 2>/dev/null)"; then
return 1
fi
printf -v "$output_var" '%s' "$plugin_snapshot"
Expand Down Expand Up @@ -1521,7 +1521,7 @@ install_selected_plugins() {
mp_repo="${_PLUGIN_INSTALL_REPOS[$i]}"
[[ ",$registered_repos," == *",$mp_repo,"* ]] && continue
mp_output=""
if ! _run_capture mp_output claude plugin marketplace add "$mp_repo"; then
if ! _run_capture mp_output _claude_cli plugin marketplace add "$mp_repo"; then
warn "${STR_DEPLOY_PLUGINS_MARKETPLACE_FAILED:-Failed to add plugin marketplace} $p_mp"
[[ -n "$mp_output" ]] && info " $mp_output"
failed_repos="${failed_repos:+${failed_repos},}${mp_repo}"
Expand Down Expand Up @@ -1632,7 +1632,7 @@ install_selected_plugins() {

plugin_output=""
if _run_capture plugin_output \
claude plugin install "$p" --scope user; then
_claude_cli plugin install "$p" --scope user; then
post_install_plugins=""
if ! _read_claude_plugin_list post_install_plugins; then
warn "Could not verify installed plugin exactly: $p_qualified"
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/test-codex-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,50 @@ else
fi
teardown_fake_claude

# install.sh runs setup.sh with stdin from /dev/tty; the Bun-based CLI fails on
# macOS with "EINVAL: invalid argument, kqueue" when it inherits that stdin.
# _claude_cli must hand the CLI an empty, non-terminal stdin instead.
_stdin_probe_dir="$(mktemp -d)"
_SETUP_TMP_FILES+=("$_stdin_probe_dir")
cat >"$_stdin_probe_dir/claude" <<'EOF'
#!/bin/bash
if [[ -t 0 ]]; then printf 'tty\n'; else printf 'stdin=[%s]\n' "$(cat)"; fi
EOF
chmod +x "$_stdin_probe_dir/claude"
if assert_equals "stdin=[]" \
"$(printf 'inherited-input' | PATH="$_stdin_probe_dir:$PATH" _claude_cli plugin list)"; then
pass "codex-setup: _claude_cli detaches stdin from the caller"
else
fail "codex-setup: _claude_cli must run claude with stdin from /dev/null"
fi

# Every shipped `claude plugin|mcp|--version` call must detach stdin, either via
# _claude_cli or an explicit </dev/null (uninstall.sh is self-contained).
# Display lines are excluded only when the logging command (or a string-only
# continuation line) starts the line and no command separator or command
# substitution precedes the claude text, and the redirect only counts inside
# the claude command itself, so a bare call combined with `|| warn ...`,
# `warn ...; claude ...`, `info "$(claude ...)"` or `; cat </dev/null` is still
# reported.
if ! git -C "$PROJECT_DIR" rev-parse --is-inside-work-tree &>/dev/null; then
skip "codex-setup: shipped claude plugin/mcp/--version calls never inherit stdin" "needs a git checkout"
else
_bare_claude_calls="$(
cd "$PROJECT_DIR" && git grep -nE '(^|[^A-Za-z0-9_./-])claude[[:space:]]+(plugin|mcp|--version)' \
-- setup.sh install.sh uninstall.sh 'lib/*.sh' 'wizard/*.sh' 'mdm/*.sh' 'features/*.sh' \
| grep -vE ':[0-9]+:[[:space:]]*#' \
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*(info|warn|printf|echo|_dryrun_log)[[:space:]]([^;|&$`]|[$][^(])*claude[[:space:]]+(plugin|mcp|--version)' \
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*"claude plugin (marketplace add|install) ' \
| grep -vE '`claude plugin install`' \
| grep -vE 'claude[[:space:]]+(plugin|mcp|--version)([^|;&#]|>&|&>)*<[[:space:]]*/dev/null' || true
)"
if assert_equals "" "$_bare_claude_calls"; then
pass "codex-setup: shipped claude plugin/mcp/--version calls never inherit stdin"
else
fail "codex-setup: claude CLI calls must use _claude_cli or </dev/null: $_bare_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
11 changes: 7 additions & 4 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1749,14 +1749,17 @@ _claude_plugin_list_has() {
}

if command -v claude &>/dev/null; then
# Every `claude` call in this block detaches stdin: when stdin is /dev/tty (e.g. a
# `curl | bash` wrapper), the Bun-based CLI fails on macOS with
# "EINVAL: invalid argument, kqueue". Mirrors _claude_cli() in lib/codex-setup.sh.
# Check for Codex plugin
_codex_plugin_list="$(claude plugin list 2>/dev/null || true)"
_codex_plugin_list="$(claude plugin list </dev/null 2>/dev/null || true)"
if _claude_plugin_list_has "$_codex_plugin_list" "codex"; then
printf "\n"
read -r -p "$STR_CODEX_PLUGIN_REMOVE_ASK" _codex_plugin_confirm
case "$_codex_plugin_confirm" in
y|Y|yes|YES)
if claude plugin uninstall codex --scope user; then
if claude plugin uninstall codex --scope user </dev/null; then
info "$STR_CODEX_PLUGIN_REMOVED"
else
warn "$STR_CODEX_PLUGIN_REMOVE_FAILED"
Expand All @@ -1774,13 +1777,13 @@ if command -v claude &>/dev/null; then
# format), so match on an anchored "name:" prefix instead of the
# plugin-list helper above — a bare `grep -qw "codex"` would also
# false-positive on e.g. "codex-tools: ...".
_codex_mcp_list="$(claude mcp list 2>/dev/null || true)"
_codex_mcp_list="$(claude mcp list </dev/null 2>/dev/null || true)"
if echo "$_codex_mcp_list" | grep -qE '^codex:' 2>/dev/null; then
printf "\n"
read -r -p "$STR_CODEX_MCP_REMOVE_ASK" _codex_mcp_confirm
case "$_codex_mcp_confirm" in
y|Y|yes|YES)
if claude mcp remove -s user codex; then
if claude mcp remove -s user codex </dev/null; then
info "$STR_CODEX_MCP_REMOVED"
else
warn "$STR_CODEX_MCP_REMOVE_FAILED"
Expand Down
Loading