Skip to content

feat: add sshd feature and fix happy-coder installation for Codespaces - #450

Merged
keito4 merged 4 commits into
mainfrom
feat/add-sshd-feature
Feb 11, 2026
Merged

feat: add sshd feature and fix happy-coder installation for Codespaces#450
keito4 merged 4 commits into
mainfrom
feat/add-sshd-feature

Conversation

@keito4

@keito4 keito4 commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Codespaces への SSH 接続を可能にするため sshd feature を追加
  • Node.js feature がグローバルパッケージをリセットする問題を修正

問題

Dockerfile で npm グローバルパッケージ(happy-coder など)をインストールしていましたが、devcontainer の node feature が Node.js を再インストールするため、グローバルパッケージがリセットされていました。

修正内容

修正 説明
sshd feature 追加 gh codespace ssh による接続を可能に
postCreateCommand 追加 npm install -g happy-coder@0.13.0 で再インストール

動作確認

# SSH 接続
gh codespace ssh -c <codespace-name> -- "happy --version"
# => happy version: 0.13.0

Test plan

  • 新しい Codespace を作成
  • SSH で接続できることを確認
  • happy-coder がインストールされていることを確認
  • happy --version が動作することを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • SSH access enabled in the development container for remote connections.
  • Chores
    • Added automatic post-creation step to reinstall required global npm tools at specified versions.
    • Installation provides clear progress and success/error messages to ensure the container is ready on first startup.

keito4 and others added 2 commits February 11, 2026 12:28
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>
@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds an SSHD feature to the Codespaces devcontainer and a post-create command that runs a new script to install npm global packages from npm/global.json.

Changes

Cohort / File(s) Summary
Devcontainer configuration
.devcontainer/codespaces/devcontainer.json
Adds ghcr.io/devcontainers/features/sshd:1 under features and a top-level postCreateCommand set to /workspaces/config/script/install-npm-globals.sh.
NPM globals installer script
script/install-npm-globals.sh
New Bash script that reads npm/global.json, checks global package versions, and installs required npm globals (exact-version installs), with colored console output and per-package success/failure handling.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

released, size/S

Poem

🐰 I hopped into a container bright,
Opened SSH and set things right.
I fetched globals, one by one,
Install succeeded—work's begun! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: adding sshd feature and fixing happy-coder installation for Codespaces, matching the changeset modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-sshd-feature

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

両方の変更を保持:
- 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>
@claude

claude Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

PR Review - feat: add sshd feature and fix happy-coder installation

✅ 良い点

  1. 問題の根本原因を正しく特定

    • Node.js feature がグローバルパッケージをリセットする問題を的確に特定
    • postCreateCommand での再インストールは適切な解決策です
  2. 明確なPR説明

    • 問題・修正内容・動作確認が体系的に記載されており、レビューしやすい
    • Test plan も明確で、動作確認が適切に実施されています
  3. 最小限の変更

    • 必要な修正のみで、過剰な変更がない点が良いです

⚠️ 改善提案

1. バージョン固定の理由とアップデート戦略

現状:

"postCreateCommand": "npm install -g happy-coder@0.13.0"

提案:

  • @0.13.0 で固定する理由をコメントまたは README に記載
  • 将来のアップデート戦略(手動 vs 自動、どのタイミングで更新するか)を明確化
  • または latest タグの使用を検討(安定性とのトレードオフ)

2. エラーハンドリングの追加

懸念点:

  • postCreateCommand が失敗してもコンテナは起動するため、ユーザーが気づきにくい

改善案:

"postCreateCommand": "npm install -g happy-coder@0.13.0 || (echo '⚠️ Warning: happy-coder installation failed' && exit 1)"

または、より堅牢に:

# スクリプトファイル化して詳細なエラーハンドリングを実装
"postCreateCommand": "/usr/local/script/post-create.sh"

3. sshd feature の設定確認

現状:

"ghcr.io/devcontainers/features/sshd:1": {}

確認事項:

  • デフォルト設定で問題ないですが、セキュリティ観点で以下を検討:
    • ポート番号の明示(デフォルト: 2222)
    • 許可する認証方式の明示的な設定

4. Dockerfile との整合性確認

確認が必要:

  • PR説明で「Dockerfile で npm グローバルパッケージをインストールしていた」とありますが、Dockerfile 側の重複インストールを削除すべきか確認
  • 二重管理によるメンテナンス負荷を避けるため、一箇所での管理を推奨

質問:

  • ベースイメージ (ghcr.io/keito4/config-base:1.62.2) の Dockerfile から happy-coder のインストールを削除する予定はありますか?

5. CI での自動テスト追加

現状: 手動テストのみ

提案: DevContainer のビルド/起動を検証する CI ワークフローへの追加を検討


🔒 セキュリティ考慮事項

  1. sshd の公開範囲

    • Codespaces 環境での sshd は GitHub の認証を経由するため基本的に安全
    • ✅ 問題なし
  2. npm パッケージの信頼性

    • happy-coder@0.13.0 の integrity check なし
    • 供給チェーン攻撃のリスク軽減のため、将来的には lockfile の活用を検討

📊 パフォーマンス考慮事項

起動時間への影響:

  • postCreateCommand は同期的に実行されるため、Codespace 作成時間が若干増加
  • npm install -g は通常数秒程度なので、実用上は問題なし
  • ネットワーク状況により遅延の可能性があるため、タイムアウト設定があると安心

🧪 テストカバレッジ

  • ✅ 手動テストは実施済み
  • ⚠️ 自動化されたテストがないため、将来的な regression のリスクあり
  • 推奨: DevContainer のビルド/起動を検証する CI ワークフローへの追加

📋 チェックリスト(CLAUDE.md 基準)

項目 状態 備考
Conventional Commits feat: prefix 使用、リリーストリガー適合
Diff サイズ (≤400行) 2行のみ
Linked Issue ⚠️ Issue へのリンクがあると望ましい
ドキュメント更新 ⚠️ README への sshd feature 追加の記載を検討
Quality Gates - JSON ファイルのため Lint/Test は該当なし

総合評価

判定: ✅ Approve with minor suggestions

変更内容は適切で、問題の解決策として妥当です。上記の改善提案は必須ではありませんが、実装すると運用面でより堅牢になります。

特に以下の2点は検討をお勧めします:

  1. エラーハンドリングの追加(インストール失敗時の検知)
  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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from global.json instead of hardcoding it.

The PACKAGES array must be kept in sync with npm/global.json manually. If a package is added to or removed from global.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

Comment on lines +54 to +61
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

@claude

claude Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

PR Review - feat/add-sshd-feature

概要

Codespaces への SSH 接続を可能にする sshd feature の追加と、Node.js feature によってリセットされる npm グローバルパッケージの再インストールスクリプトの実装です。


✅ 良い点

1. 問題の明確な理解と解決

  • Node.js feature がグローバルパッケージをリセットする問題を正しく特定
  • postCreateCommand で適切なタイミングで再インストールを実行

2. スクリプトの堅牢性

  • set -euo pipefail でエラーハンドリングを適切に設定
  • 既存の script/lib/output.sh と一貫性のある色定義と出力関数
  • 既にインストール済みのパッケージをスキップする最適化

3. ドキュメント

  • スクリプトのヘッダーコメントで目的と使用方法を明記
  • PR 本文で問題、修正内容、動作確認を明確に記載

⚠️ 改善提案

1. [重要] npm/global.json との不一致リスク

script/install-npm-globals.sh:33-36

問題点: ハードコードされたパッケージリストが npm/global.json の全 18 パッケージのうち 4 つしかカバーしていません。

  • インストールされる: happy-coder, @openai/codex, @google/gemini-cli, vercel
  • インストールされない: @commitlint/cli, bash-language-server, codex, typescript など 14 パッケージ

提案: インストール対象を明示的に定義し、コメントで理由を記載する。

2. エラーハンドリングの改善

script/install-npm-globals.sh:56-60

問題点: インストール失敗時にスクリプトが継続し、終了コード 0 を返す

提案: 失敗を追跡して最後にエラーを報告

3. lib/output.sh の活用

既存の script/lib/output.sh には統一された出力関数があります。一貫性のため使用を検討してください。

4. テストの追加

スクリプトの動作を検証するテストを追加することを推奨します。


🔒 セキュリティ

  • ✅ パスインジェクションのリスクなし
  • ✅ 機密情報の露出なし
  • ✅ 適切な引用符の使用

🧪 テストカバレッジ

現状: 手動テストのみ

推奨: スクリプトの単体テストを追加、CI で ShellCheck を実行


📝 CLAUDE.md との整合性

✅ 準拠

  • Conventional Commits 形式のコミットメッセージ
  • PR 本文に Summary / 問題 / 修正内容 / Test plan を記載

⚠️ 要確認

  • Quality Gates: スクリプトに対する ShellCheck や単体テストの実行が必要
  • 70%+ テストカバレッジ: 新規スクリプトのテストが不足

🎯 総評

承認推奨: ✅ (軽微な改善提案あり)

実装は堅牢で、問題を正しく解決しています。上記の改善提案を検討することで、より保守性とエラーハンドリングが向上します。

優先順位

  1. High: エラーハンドリングの改善 (Add reusable devcontainer setup #2)
  2. High: npm/global.json との整合性 (Apply repository hygiene fixes #1)
  3. Medium: lib/output.sh の活用 (Add Docker image build workflow #3)
  4. Low: テストの追加 (Fix Docker build context and paths #4)

🤖 Reviewed with Claude Code

@keito4
keito4 merged commit c4e5321 into main Feb 11, 2026
20 of 21 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.68.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Feb 11, 2026
@keito4
keito4 deleted the feat/add-sshd-feature branch March 1, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant