@cocorograph/hub-agent 0.6.73 → 0.6.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.sh +22 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocorograph/hub-agent",
3
- "version": "0.6.73",
3
+ "version": "0.6.75",
4
4
  "description": "Hub Hosted Cockpit のローカル常駐 agent。Hub と outbound WSS で接続し、ローカルの tmux/pty を中継する。",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -228,8 +228,14 @@ persist_user_brew_shellenv() {
228
228
  # 後で system 版 node / npm に切り替わる可能性も考えて user 領域に逃がしておく。
229
229
  # system mode(/opt/homebrew 等)では何もしない(既存挙動を温存)。
230
230
  ensure_npm_user_prefix() {
231
- [[ "$(uname)" != "Darwin" ]] && return 0
232
- [[ -d "$HOME/homebrew" ]] || return 0 # user-mode 検知
231
+ # macOS user-mode (brew $HOME/homebrew) のときだけ切替(既存挙動を温存)。
232
+ # Linux は apt 等の global prefix が sudo 必須 / global bin PATH に通らない問題を
233
+ # 起こしやすい(npm i -g は成功しても hub-agent / claude が command not found になる)。
234
+ # そのため Linux では常に $HOME/.npm-global へ寄せ、sudo 不要・bin パス確定・PATH 反映を
235
+ # 一貫させる(WSL クリーン Ubuntu で発覚)。
236
+ if [[ "$(uname)" == "Darwin" ]]; then
237
+ [[ -d "$HOME/homebrew" ]] || return 0 # user-mode 検知
238
+ fi
233
239
 
234
240
  # 既に $HOME/.npm-global が prefix なら何もしない
235
241
  local cur_prefix
@@ -247,8 +253,17 @@ ensure_npm_user_prefix() {
247
253
  local snippet='export PATH="$HOME/.npm-global/bin:$PATH"'
248
254
  local marker="# >>> hub-agent: npm-global PATH (user-mode) >>>"
249
255
  local end_marker="# <<< hub-agent: npm-global PATH <<<"
256
+ # 永続先は OS で出し分け。Linux の hub-agent は systemd --user 起動時や
257
+ # `$SHELL -lic` 経由の env 注入で PATH を解決するため、login(.profile) と
258
+ # interactive(.bashrc) の双方に通す。macOS は従来どおり zsh/bash の profile。
259
+ local targets
260
+ if [[ "$(uname)" == "Darwin" ]]; then
261
+ targets=("$HOME/.zprofile" "$HOME/.bash_profile")
262
+ else
263
+ targets=("$HOME/.bashrc" "$HOME/.profile")
264
+ fi
250
265
  local target
251
- for target in "$HOME/.zprofile" "$HOME/.bash_profile"; do
266
+ for target in "${targets[@]}"; do
252
267
  if [[ -f "$target" ]] && grep -Fq "$snippet" "$target"; then
253
268
  continue
254
269
  fi
@@ -483,7 +498,10 @@ _install_node_lts_brew() {
483
498
  # - 範囲超過(current 系等) → LTS にダウングレード
484
499
  ensure_node_version() {
485
500
  local v
486
- v=$(node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1)
501
+ # node 皆無のクリーン環境では `node --version` exit 127。set -euo pipefail
502
+ # では pipefail がこれを拾ってスクリプトごと死ぬため、`|| v=""` で必ず吸収する
503
+ # (macOS テスト機には既に node があり露見しなかった潜在バグ。WSL クリーン Ubuntu で発覚)。
504
+ v=$(node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1) || v=""
487
505
  if [[ -z "$v" ]]; then
488
506
  color_step "node が未インストール → $NODE_DEFAULT_BREW_FORMULA (Active LTS) を install"
489
507
  if [[ "$(uname)" == "Darwin" ]]; then