feat(env): devbase env init で HOST_SSH_USER / HOST_SSH_HOST を自動設定 (#48)#68
Merged
Conversation
コンテナ→ホスト SSH (ホスト側 GUI アプリ起動) ワークフロー向けに、ホストの ログインユーザー名 / SSH 先ホスト名を収集する host コレクタを追加。 - keys.py: HOST_SSH_USER / HOST_SSH_HOST 定数追加 - collectors/host.py: getpass.getuser() を既定値に提示、safe_input で上書き可 (非対話/CI は既定値設定、getuser 空時は安全スキップ) - cmd_env_sync: _sync_host() で欠落キーのみ既定値補完 (手動上書きは尊重) - docs: environment-variables.md に host 節追記 - tests: コレクタ + sync backfill の単体テスト 9 ケース Closes #48 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 1 | codex | APPROVE
指摘事項はありません。
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 1 | gemini | APPROVE
変更内容を確認し、要件通りに実装されていることを確認しました。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
devbase env initの対話セットアップに ホスト接続情報 (SSH) コレクタを追加し、ホスト (mac/Linux/WSL) のログインユーザー名をHOST_SSH_USERとして、SSH 先ホスト名をHOST_SSH_HOSTとして.envに自動設定する。コンテナからホストへ SSH してホスト側 GUI アプリ(例: Chrome をリモートデバッグモードで起動)を起動するワークフローを、
HOST_SSH_USER=<名>の手動指定なしで利用できるようにするのが目的。devbase env initはホスト上で実行される CLI のため、getpass.getuser()でホストのユーザー名を確実に取得できる。関連 Issue
変更点
lib/devbase/env/keys.py:HOST_SSH_USER/HOST_SSH_HOSTキー定数を追加lib/devbase/env/collectors/host.py(新規):hostコレクタ。getpass.getuser()を既定値として提示しsafe_inputで上書き可能。HOST_SSH_HOSTは既定host.docker.internal(WSL2/Windows 向けに上書き余地)。既存コレクタと同じCOLLECTOR定数で自動登録されるlib/devbase/commands/env.py:devbase env syncに_sync_host()を追加。ホスト情報はソースファイルを持たないため hash 比較は使わず、欠落キーのみ既定値で補完(既存値=手動上書きは尊重して上書きしない)。導入前の.envへの後付け backfill として機能するdocs/user/environment-variables.md:#### host節とコレクタ一覧へ追記tests/env/test_collector_host.py(新規): コレクタ + sync backfill の単体テスト 9 ケースissues/PLAN48_host-ssh-user-env.md(新規): 設計 plan非対話 / CI の挙動
safe_inputは EOF 時に既定値を返すため、非対話/CI でもHOST_SSH_USER=getpass.getuser()・HOST_SSH_HOST=host.docker.internalが設定される。getpass.getuser()がユーザー名を取得できない環境ではHOST_SSH_USERを安全にスキップする。セキュリティ
HOST_SSH_USERはユーザー名のみで秘密情報ではない。SSH 鍵やリモートログイン有効化はホスト側でユーザーが別途設定する前提。動作確認
tests/env/test_collector_host.py9 ケース pass./bin/devbase --helpが正常に動作するdocs/user/environment-variables.md) を更新した