@cocorograph/hub-agent 0.6.74 → 0.6.76

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 +41 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocorograph/hub-agent",
3
- "version": "0.6.74",
3
+ "version": "0.6.76",
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
@@ -476,6 +491,27 @@ _install_node_lts_brew() {
476
491
  hash -r 2>/dev/null || true
477
492
  }
478
493
 
494
+ # Linux で Active LTS の node を導入する。
495
+ # Ubuntu の apt 素 nodejs は 24.04 でも v18 でポリシー (>=22) を満たせないため、
496
+ # NodeSource (setup_<major>.x) を使ってシステムワイドに最新 LTS を導入する。既存の
497
+ # apt 版 nodejs があっても apt-get install -y nodejs が NodeSource 版へ置き換える。
498
+ _install_node_lts_linux() {
499
+ local major="${NODE_DEFAULT_BREW_FORMULA##*@}" # "node@24" -> "24"
500
+ color_step "NodeSource 経由で Node ${major} (Active LTS) を install"
501
+ if present apt-get; then
502
+ retry 3 bash -c "curl -fsSL https://deb.nodesource.com/setup_${major}.x | sudo -E bash -"
503
+ retry 3 sudo apt-get install -y nodejs
504
+ elif present dnf; then
505
+ retry 3 bash -c "curl -fsSL https://rpm.nodesource.com/setup_${major}.x | sudo -E bash -"
506
+ retry 3 sudo dnf install -y nodejs
507
+ else
508
+ color_err "NodeSource 非対応の環境です。Node ${NODE_MIN_MAJOR}+ を手動で install してください (nvm 推奨)"
509
+ exit 1
510
+ fi
511
+ hash -r 2>/dev/null || true
512
+ color_ok "node $(node --version 2>/dev/null || echo '?') を導入"
513
+ }
514
+
479
515
  # Node.js のサポート範囲ポリシー判定。
480
516
  # - 未インストール → LTS を install
481
517
  # - [MIN, MAX] 範囲内 → 現状維持(ユーザーの環境を尊重)
@@ -492,7 +528,7 @@ ensure_node_version() {
492
528
  if [[ "$(uname)" == "Darwin" ]]; then
493
529
  _install_node_lts_brew
494
530
  else
495
- ensure_pkg node node nodejs
531
+ _install_node_lts_linux
496
532
  fi
497
533
  return
498
534
  fi
@@ -510,8 +546,7 @@ ensure_node_version() {
510
546
  if [[ "$(uname)" == "Darwin" ]]; then
511
547
  _install_node_lts_brew
512
548
  else
513
- color_err "Node $NODE_MIN_MAJOR〜$NODE_MAX_MAJOR の LTS を手動で install してください (nvm 推奨)"
514
- exit 1
549
+ _install_node_lts_linux
515
550
  fi
516
551
  }
517
552