feat: add sshd feature and fix happy-coder installation for Codespaces - #450
Conversation
Codespace への SSH 接続を可能にするため sshd feature を追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Node.js feature がグローバルパッケージをリセットするため、 postCreateCommand で happy-coder を再インストール 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds an SSHD feature to the Codespaces devcontainer and a post-create command that runs a new script to install npm global packages from Changes
Sequence Diagram(s)sequenceDiagram
participant Codespaces
participant Devcontainer
participant PostCreateScript as InstallerScript
participant NPMRegistry as npm
participant Host as Container
Codespaces->>Devcontainer: Start workspace with devcontainer.json
Devcontainer->>Host: Provision container (includes sshd feature)
Devcontainer->>InstallerScript: Invoke postCreateCommand
InstallerScript->>Host: Read npm/global.json
InstallerScript->>NPMRegistry: Query package versions / install -g package@version
NPMRegistry-->>InstallerScript: Respond success/failure
InstallerScript-->>Devcontainer: Output install results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
両方の変更を保持: - postCreateCommand: happy-coder インストール - postStartCommand: restore-cli-auth.sh を追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review - feat: add sshd feature and fix happy-coder installation✅ 良い点
|
| 項目 | 状態 | 備考 |
|---|---|---|
| Conventional Commits | ✅ | feat: prefix 使用、リリーストリガー適合 |
| Diff サイズ (≤400行) | ✅ | 2行のみ |
| Linked Issue | Issue へのリンクがあると望ましい | |
| ドキュメント更新 | README への sshd feature 追加の記載を検討 | |
| Quality Gates | - | JSON ファイルのため Lint/Test は該当なし |
総合評価
判定: ✅ Approve with minor suggestions
変更内容は適切で、問題の解決策として妥当です。上記の改善提案は必須ではありませんが、実装すると運用面でより堅牢になります。
特に以下の2点は検討をお勧めします:
- エラーハンドリングの追加(インストール失敗時の検知)
- Dockerfile との重複管理の解消
お疲れ様でした! 🎉
Review by Claude Code - CLAUDE.md に基づくレビュー
ハードコードではなく npm/global.json からパッケージをインストール - script/install-npm-globals.sh を追加 - postCreateCommand でスクリプトを実行 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@script/install-npm-globals.sh`:
- Around line 54-61: The npm install failures are logged but ignored; modify the
install loop around npm install -g "${pkg}@${version}" so that failures are
tracked and cause a non‑zero exit: introduce a failure flag (e.g.,
INSTALL_FAIL=0) and set it to 1 in the else branch that runs error "Failed to
install $pkg@$version", then after the loop check the flag (if INSTALL_FAIL -ne
0) and exit 1 (or exit with a combined/nonzero status). Ensure you reference the
existing variables pkg and version and the npm install command so the
flag-setting logic is added in the same block and the final exit occurs after
all packages are processed.
🧹 Nitpick comments (1)
script/install-npm-globals.sh (1)
31-37: Consider deriving the package list fromglobal.jsoninstead of hardcoding it.The
PACKAGESarray must be kept in sync withnpm/global.jsonmanually. If a package is added to or removed fromglobal.json, this script silently ignores the change. You could parse the keys directly from the JSON to avoid drift.♻️ Suggested refactor
-PACKAGES=( - "happy-coder" - "@openai/codex" - "@google/gemini-cli" - "vercel" -) +mapfile -t PACKAGES < <(node -pe "Object.keys(require('${GLOBAL_JSON}').dependencies).join('\n')" 2>/dev/null) + +if [[ ${`#PACKAGES`[@]} -eq 0 ]]; then + error "No packages found in global.json" + exit 1 +fi
| else | ||
| info "Installing $pkg@$version..." | ||
| if npm install -g "${pkg}@${version}" --silent 2>/dev/null; then | ||
| success "$pkg@$version" | ||
| else | ||
| error "Failed to install $pkg@$version" | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Install failures are silently swallowed — script exits 0 regardless.
When npm install -g fails, the error is logged but the script continues and ultimately exits 0. Since this runs as postCreateCommand, a silent success could leave the Codespace in a broken state without the user noticing (e.g., happy-coder missing). Consider tracking failures and exiting non-zero at the end.
♻️ Suggested approach
+fail_count=0
+
for pkg in "${PACKAGES[@]}"; do
...
if npm install -g "${pkg}@${version}" --silent 2>/dev/null; then
success "$pkg@$version"
else
error "Failed to install $pkg@$version"
+ ((fail_count++))
fi
fi
done
-info "Done!"
+if [[ $fail_count -gt 0 ]]; then
+ error "$fail_count package(s) failed to install"
+ exit 1
+fi
+
+info "Done!"🤖 Prompt for AI Agents
In `@script/install-npm-globals.sh` around lines 54 - 61, The npm install failures
are logged but ignored; modify the install loop around npm install -g
"${pkg}@${version}" so that failures are tracked and cause a non‑zero exit:
introduce a failure flag (e.g., INSTALL_FAIL=0) and set it to 1 in the else
branch that runs error "Failed to install $pkg@$version", then after the loop
check the flag (if INSTALL_FAIL -ne 0) and exit 1 (or exit with a
combined/nonzero status). Ensure you reference the existing variables pkg and
version and the npm install command so the flag-setting logic is added in the
same block and the final exit occurs after all packages are processed.
PR Review - feat/add-sshd-feature概要Codespaces への SSH 接続を可能にする sshd feature の追加と、Node.js feature によってリセットされる npm グローバルパッケージの再インストールスクリプトの実装です。 ✅ 良い点1. 問題の明確な理解と解決
2. スクリプトの堅牢性
3. ドキュメント
|
|
🎉 This PR is included in version 1.68.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
問題
Dockerfile で npm グローバルパッケージ(happy-coder など)をインストールしていましたが、devcontainer の
nodefeature が Node.js を再インストールするため、グローバルパッケージがリセットされていました。修正内容
gh codespace sshによる接続を可能にnpm install -g happy-coder@0.13.0で再インストール動作確認
Test plan
happy --versionが動作することを確認🤖 Generated with Claude Code
Summary by CodeRabbit