@cocorograph/hub-agent 0.8.58 → 0.8.59
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.
- package/README.md +3 -1
- package/package.json +1 -1
- package/scripts/install.sh +230 -21
package/README.md
CHANGED
|
@@ -17,8 +17,10 @@ curl -fsSL https://api.hub.cocorograph.com/api/cockpit/agents/install-script | b
|
|
|
17
17
|
|
|
18
18
|
このスクリプトは以下を **全自動** で実行します:
|
|
19
19
|
- Homebrew (macOS で無ければ install)
|
|
20
|
-
- tmux + node
|
|
20
|
+
- tmux + node (Active LTS) + python3 (無ければ install)
|
|
21
|
+
- GNU coreutils の `timeout` (補助コマンド。macOS では brew で導入して `gtimeout` への symlink を `~/.local/bin` に作成、Linux は存在確認のみで不在なら手動導入を案内。無くてもセットアップは続行)
|
|
21
22
|
- `npm i -g @cocorograph/hub-agent`
|
|
23
|
+
- `npm i -g @anthropic-ai/claude-code` / `npm i -g @openai/codex` (Claude Code / Codex CLI。既存なら更新)
|
|
22
24
|
- `hub-agent enroll <token>` (token は Hub session 経由で埋め込み済、5 分有効)
|
|
23
25
|
- `hub-agent install-service` で OS サービス登録
|
|
24
26
|
|
package/package.json
CHANGED
package/scripts/install.sh
CHANGED
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
# 1. macOS なら Homebrew (なければ install)
|
|
13
13
|
# - 管理者権限が無い環境では自動で $HOME/homebrew にユーザーローカル
|
|
14
14
|
# インストールに切り替わる (HUB_AGENT_USER_BREW=1 で強制も可)
|
|
15
|
-
# 2. tmux + node (なければ install via brew / apt)
|
|
16
|
-
# 3.
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
15
|
+
# 2. tmux + node + python3 (なければ install via brew / apt 等)
|
|
16
|
+
# 3. GNU coreutils の timeout (補助コマンド。macOS では brew で入れて gtimeout への
|
|
17
|
+
# symlink を ~/.local/bin に作成。Linux は存在確認のみで、不在なら手動導入を案内)
|
|
18
|
+
# 4. npm i -g @cocorograph/hub-agent
|
|
19
|
+
# 5. npm i -g @anthropic-ai/claude-code (既存があれば upgrade のみ)
|
|
20
|
+
# 6. npm i -g @openai/codex (常に install / upgrade)
|
|
21
|
+
# 7. HUB_AGENT_TOKEN が設定されていれば hub-agent enroll を自動実行
|
|
22
|
+
# 8. hub-agent install-service で OS サービス化
|
|
20
23
|
# =============================================================================
|
|
21
24
|
|
|
22
25
|
set -euo pipefail
|
|
@@ -41,6 +44,7 @@ NODE_DEFAULT_BREW_FORMULA="node@24"
|
|
|
41
44
|
|
|
42
45
|
PACKAGE_NAME="@cocorograph/hub-agent"
|
|
43
46
|
CLAUDE_CODE_PACKAGE="@anthropic-ai/claude-code"
|
|
47
|
+
CODEX_PACKAGE="@openai/codex"
|
|
44
48
|
|
|
45
49
|
color_step() { printf "\033[1;34m==> %s\033[0m\n" "$1"; }
|
|
46
50
|
color_ok() { printf "\033[1;32m✓ %s\033[0m\n" "$1"; }
|
|
@@ -223,6 +227,49 @@ persist_user_brew_shellenv() {
|
|
|
223
227
|
done
|
|
224
228
|
}
|
|
225
229
|
|
|
230
|
+
# snippet をマーカーで囲んで各 profile に冪等追記する。
|
|
231
|
+
# 使い方: persist_profile_snippet '<snippet>' '<label>' '<marker>' '<end_marker>' <profile>...
|
|
232
|
+
# 既に「snippet と完全一致する行」があれば skip する(部分一致だとコメントアウトされた
|
|
233
|
+
# `#export PATH=...` を既存扱いにして追記を飛ばす。マーカーの有無は見ない——マーカーだけ
|
|
234
|
+
# 残って snippet が欠けた部分書込みを再実行で補完できるようにするため)。
|
|
235
|
+
# 追記できない profile(root 所有・読み取り専用)は警告して次へ進み、最後に 1 を返す。
|
|
236
|
+
# 呼び出し側が失敗を致命にするか警告に留めるかを決める(set -e 下で裸で呼べば致命)。
|
|
237
|
+
persist_profile_snippet() {
|
|
238
|
+
local snippet="$1" label="$2" marker="$3" end_marker="$4"
|
|
239
|
+
shift 4
|
|
240
|
+
local target rc=0
|
|
241
|
+
for target in "$@"; do
|
|
242
|
+
if [[ -f "$target" ]] && grep -Fxq "$snippet" "$target"; then
|
|
243
|
+
continue
|
|
244
|
+
fi
|
|
245
|
+
if {
|
|
246
|
+
printf '\n%s\n' "$marker"
|
|
247
|
+
printf '%s\n' "$snippet"
|
|
248
|
+
printf '%s\n' "$end_marker"
|
|
249
|
+
} >> "$target" 2>/dev/null; then
|
|
250
|
+
color_ok "$target に $label を追記 (新規シェルから有効)"
|
|
251
|
+
else
|
|
252
|
+
color_warn "$target に $label を追記できません (書き込み権限を確認してください)"
|
|
253
|
+
rc=1
|
|
254
|
+
fi
|
|
255
|
+
done
|
|
256
|
+
return "$rc"
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# bash の login profile を 1 つ選ぶ。bash は ~/.bash_profile → ~/.bash_login → ~/.profile の
|
|
260
|
+
# うち最初に存在するものだけを読むため、~/.profile しか無い環境で ~/.bash_profile を
|
|
261
|
+
# 新規作成すると ~/.profile が読まれなくなる。既存のものを優先し、無ければ ~/.bash_profile。
|
|
262
|
+
bash_login_profile() {
|
|
263
|
+
local f
|
|
264
|
+
for f in "$HOME/.bash_profile" "$HOME/.bash_login" "$HOME/.profile"; do
|
|
265
|
+
if [[ -f "$f" ]]; then
|
|
266
|
+
printf '%s\n' "$f"
|
|
267
|
+
return 0
|
|
268
|
+
fi
|
|
269
|
+
done
|
|
270
|
+
printf '%s\n' "$HOME/.bash_profile"
|
|
271
|
+
}
|
|
272
|
+
|
|
226
273
|
# user-mode の場合、npm の global prefix を $HOME/.npm-global に切り替える。
|
|
227
274
|
# brew が $HOME/homebrew にいるとき、その prefix への書き込み権限はあるものの、
|
|
228
275
|
# 後で system 版 node / npm に切り替わる可能性も考えて user 領域に逃がしておく。
|
|
@@ -256,8 +303,6 @@ ensure_npm_user_prefix() {
|
|
|
256
303
|
export PATH="$HOME/.npm-global/bin:$PATH"
|
|
257
304
|
|
|
258
305
|
local snippet='export PATH="$HOME/.npm-global/bin:$PATH"'
|
|
259
|
-
local marker="# >>> hub-agent: npm-global PATH (user-mode) >>>"
|
|
260
|
-
local end_marker="# <<< hub-agent: npm-global PATH <<<"
|
|
261
306
|
# 永続先は OS で出し分け。Linux の hub-agent は systemd --user 起動時や
|
|
262
307
|
# `$SHELL -lic` 経由の env 注入で PATH を解決するため、login(.profile) と
|
|
263
308
|
# interactive(.bashrc) の双方に通す。macOS は従来どおり zsh/bash の profile。
|
|
@@ -267,18 +312,9 @@ ensure_npm_user_prefix() {
|
|
|
267
312
|
else
|
|
268
313
|
targets=("$HOME/.bashrc" "$HOME/.profile")
|
|
269
314
|
fi
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
continue
|
|
274
|
-
fi
|
|
275
|
-
{
|
|
276
|
-
printf '\n%s\n' "$marker"
|
|
277
|
-
printf '%s\n' "$snippet"
|
|
278
|
-
printf '%s\n' "$end_marker"
|
|
279
|
-
} >> "$target"
|
|
280
|
-
color_ok "$target に npm-global PATH を追記"
|
|
281
|
-
done
|
|
315
|
+
persist_profile_snippet "$snippet" "npm-global PATH" \
|
|
316
|
+
"# >>> hub-agent: npm-global PATH (user-mode) >>>" "# <<< hub-agent: npm-global PATH <<<" \
|
|
317
|
+
"${targets[@]}"
|
|
282
318
|
}
|
|
283
319
|
|
|
284
320
|
# =============================================================================
|
|
@@ -544,6 +580,120 @@ ensure_build_tools() {
|
|
|
544
580
|
fi
|
|
545
581
|
}
|
|
546
582
|
|
|
583
|
+
# Hub AI bundle のフック・helper と hub-agent bootstrap が使う python3 を保証する。
|
|
584
|
+
# macOS の /usr/bin/python3 は Xcode CLT 未導入時にスタブの場合があるため、
|
|
585
|
+
# command の存在ではなく実際の version コマンドが成功するかで判定する。
|
|
586
|
+
ensure_python3() {
|
|
587
|
+
if python3 --version >/dev/null 2>&1; then
|
|
588
|
+
color_ok "$(python3 --version 2>&1)"
|
|
589
|
+
return 0
|
|
590
|
+
fi
|
|
591
|
+
|
|
592
|
+
color_step "python3 をインストール"
|
|
593
|
+
if [[ "$(uname)" == "Darwin" ]]; then
|
|
594
|
+
# macOS で python3 が動かないのは、ほぼ Xcode CLT 未導入(/usr/bin/python3 がスタブ)。
|
|
595
|
+
# brew 経路が失敗したら、set -e で黙って落ちる前に実際の復旧手順を出す。
|
|
596
|
+
if ! retry 3 brew install python; then
|
|
597
|
+
color_err "python3 を導入できません。\`xcode-select --install\` を実行してから再実行してください"
|
|
598
|
+
exit 1
|
|
599
|
+
fi
|
|
600
|
+
elif present apt-get; then
|
|
601
|
+
retry 3 sudo apt-get update -y
|
|
602
|
+
retry 3 sudo apt-get install -y python3
|
|
603
|
+
elif present dnf; then
|
|
604
|
+
retry 3 sudo dnf install -y python3
|
|
605
|
+
elif present pacman; then
|
|
606
|
+
retry 3 sudo pacman -S --noconfirm python
|
|
607
|
+
else
|
|
608
|
+
color_err "対応するパッケージマネージャ (brew/apt/dnf/pacman) が見つかりません。python3 を手動で install してください"
|
|
609
|
+
exit 1
|
|
610
|
+
fi
|
|
611
|
+
hash -r 2>/dev/null || true
|
|
612
|
+
|
|
613
|
+
if python3 --version >/dev/null 2>&1; then
|
|
614
|
+
color_ok "$(python3 --version 2>&1)"
|
|
615
|
+
else
|
|
616
|
+
color_err "python3 の導入後も実行できません"
|
|
617
|
+
exit 1
|
|
618
|
+
fi
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
# timeout を保証する(補助コマンド。AI セッションの Bash やスクリプトが使うが、
|
|
622
|
+
# hub-agent の常駐動作には必須ではないため、導入失敗は警告して継続する。
|
|
623
|
+
# 必須ランタイムの python3 とは契約を分けている)。
|
|
624
|
+
# macOS の coreutils は gtimeout 名で入るため、timeout だけを ~/.local/bin に公開する。
|
|
625
|
+
# coreutils の gnubin 全体を PATH に足すと sed / date 等まで GNU 版へ置き換わり、
|
|
626
|
+
# 既存スクリプトの挙動が変わるため採用しない。
|
|
627
|
+
_report_timeout() {
|
|
628
|
+
if present timeout; then
|
|
629
|
+
color_ok "timeout $(timeout --version 2>/dev/null </dev/null | head -1 || echo 'installed')"
|
|
630
|
+
else
|
|
631
|
+
color_warn "timeout コマンドが PATH に見つかりません (補助コマンドのため継続。新規シェルで再確認してください)"
|
|
632
|
+
fi
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
ensure_timeout() {
|
|
636
|
+
if [[ "$(uname)" != "Darwin" ]]; then
|
|
637
|
+
# Linux の timeout は coreutils (Debian の essential / busybox にも同梱) なので
|
|
638
|
+
# 通常は存在する。無い環境はインストーラが推測で入れず、警告に留める。
|
|
639
|
+
if ! present timeout; then
|
|
640
|
+
color_warn "timeout が見つかりません (coreutils を手動で導入してください。補助コマンドのため継続)"
|
|
641
|
+
fi
|
|
642
|
+
_report_timeout
|
|
643
|
+
return 0
|
|
644
|
+
fi
|
|
645
|
+
|
|
646
|
+
local local_bin="$HOME/.local/bin"
|
|
647
|
+
local link="$local_bin/timeout"
|
|
648
|
+
local found
|
|
649
|
+
found="$(command -v timeout 2>/dev/null || true)"
|
|
650
|
+
# このインストーラ管理の symlink 以外の timeout が既に見えていれば、それを尊重する
|
|
651
|
+
if [[ -n "$found" && "$found" != "$link" ]]; then
|
|
652
|
+
color_ok "timeout already installed ($found)"
|
|
653
|
+
return 0
|
|
654
|
+
fi
|
|
655
|
+
|
|
656
|
+
if [[ -e "$link" && ! -L "$link" ]]; then
|
|
657
|
+
# ユーザーが自前で置いた実体は上書きしない(PATH 永続化だけ揃える)
|
|
658
|
+
color_ok "$link は手動管理のため変更しません"
|
|
659
|
+
else
|
|
660
|
+
local gtimeout
|
|
661
|
+
gtimeout="$(command -v gtimeout 2>/dev/null || true)"
|
|
662
|
+
if [[ -z "$gtimeout" ]]; then
|
|
663
|
+
color_step "GNU coreutils (timeout) をインストール"
|
|
664
|
+
if ! retry 3 brew install coreutils; then
|
|
665
|
+
color_warn "coreutils の導入に失敗しました (timeout は補助コマンドのため継続)"
|
|
666
|
+
return 0
|
|
667
|
+
fi
|
|
668
|
+
hash -r 2>/dev/null || true
|
|
669
|
+
gtimeout="$(command -v gtimeout 2>/dev/null || true)"
|
|
670
|
+
fi
|
|
671
|
+
if [[ -z "$gtimeout" ]]; then
|
|
672
|
+
color_warn "gtimeout が PATH に見つかりません (timeout は補助コマンドのため継続)"
|
|
673
|
+
return 0
|
|
674
|
+
fi
|
|
675
|
+
if ! mkdir -p "$local_bin" 2>/dev/null || ! ln -sfn "$gtimeout" "$link" 2>/dev/null; then
|
|
676
|
+
color_warn "$link を作成できません (書き込み権限を確認してください。補助コマンドのため継続)"
|
|
677
|
+
return 0
|
|
678
|
+
fi
|
|
679
|
+
fi
|
|
680
|
+
|
|
681
|
+
# symlink の有無と PATH 永続化は別々に収束させる。再実行時に片方だけ欠けていても
|
|
682
|
+
# ここで補完される(早期 return で profile の修復を飛ばさない)。
|
|
683
|
+
# ~/.local/bin は PATH の「末尾」に足す。先頭に置くと pipx / pyenv 等が置いた
|
|
684
|
+
# ~/.local/bin/python3 や node のシムが brew / system のものを隠してしまう。
|
|
685
|
+
# timeout を見つけるだけなら末尾で足りる(別の timeout があれば上で return 済み)。
|
|
686
|
+
# PATH 代入で bash の command hash は全消去されるので、この後の hash -r は不要。
|
|
687
|
+
export PATH="$PATH:$local_bin"
|
|
688
|
+
# npm prefix と同じく zsh / bash 双方の login profile へ永続化する。
|
|
689
|
+
# 追記失敗(root 所有の profile 等)はこの補助コマンドの契約に合わせて警告に留める。
|
|
690
|
+
persist_profile_snippet 'export PATH="$PATH:$HOME/.local/bin"' "~/.local/bin PATH" \
|
|
691
|
+
"# >>> hub-agent: local-bin PATH (timeout) >>>" "# <<< hub-agent: local-bin PATH <<<" \
|
|
692
|
+
"$HOME/.zprofile" "$(bash_login_profile)" \
|
|
693
|
+
|| color_warn "PATH の永続化に失敗した profile があります (timeout は補助コマンドのため継続)"
|
|
694
|
+
_report_timeout
|
|
695
|
+
}
|
|
696
|
+
|
|
547
697
|
# Node.js のサポート範囲ポリシー判定。
|
|
548
698
|
# - 未インストール → LTS を install
|
|
549
699
|
# - [MIN, MAX] 範囲内 → 現状維持(ユーザーの環境を尊重)
|
|
@@ -622,6 +772,30 @@ ensure_claude_code() {
|
|
|
622
772
|
fi
|
|
623
773
|
}
|
|
624
774
|
|
|
775
|
+
# Codex CLI を同梱でセットアップ。hub-agent 自体の動作には必須ではないため、
|
|
776
|
+
# 新規導入・upgrade とも失敗時は警告してセットアップを継続する。
|
|
777
|
+
ensure_codex() {
|
|
778
|
+
if present codex; then
|
|
779
|
+
local cur
|
|
780
|
+
cur=$(codex --version 2>/dev/null </dev/null || echo "unknown")
|
|
781
|
+
color_step "Codex CLI (現在 $cur) を最新版にアップデート"
|
|
782
|
+
retry 2 npm install -g "${CODEX_PACKAGE}@latest" --force \
|
|
783
|
+
|| color_warn "Codex CLI upgrade に失敗 (既存版で継続)"
|
|
784
|
+
else
|
|
785
|
+
color_step "$CODEX_PACKAGE を install"
|
|
786
|
+
if ! retry 3 npm install -g "${CODEX_PACKAGE}@latest" --force; then
|
|
787
|
+
color_warn "Codex CLI の導入に失敗しました。Codex チャット / 委譲 / 画像生成は使えません"
|
|
788
|
+
color_warn " 手動で実行: npm install -g @openai/codex@latest"
|
|
789
|
+
fi
|
|
790
|
+
fi
|
|
791
|
+
hash -r 2>/dev/null || true
|
|
792
|
+
if present codex; then
|
|
793
|
+
color_ok "codex $(codex --version 2>/dev/null </dev/null || echo 'installed')"
|
|
794
|
+
else
|
|
795
|
+
color_warn "codex コマンドが PATH に見つかりません。新規シェルで再確認してください"
|
|
796
|
+
fi
|
|
797
|
+
}
|
|
798
|
+
|
|
625
799
|
do_enroll() {
|
|
626
800
|
if [[ -z "${HUB_AGENT_TOKEN:-}" ]]; then
|
|
627
801
|
color_warn "HUB_AGENT_TOKEN が未設定。enroll は skip します"
|
|
@@ -767,6 +941,24 @@ verify_setup() {
|
|
|
767
941
|
color_warn "Claude Code (claude) コマンドが見つかりません (cockpit から claude を呼ぶ場合は必要)"
|
|
768
942
|
fi
|
|
769
943
|
|
|
944
|
+
# Codex CLI (任意なので warn のみ)
|
|
945
|
+
if present codex; then
|
|
946
|
+
color_ok "Codex CLI: $(codex --version 2>/dev/null </dev/null || echo 'installed')"
|
|
947
|
+
else
|
|
948
|
+
color_warn "Codex CLI (codex) コマンドが見つかりません (Codex チャット / 委譲 / 画像生成には必要)"
|
|
949
|
+
fi
|
|
950
|
+
|
|
951
|
+
# python3 (Hub AI bundle と hub-agent bootstrap に必須)
|
|
952
|
+
if python3 --version >/dev/null 2>&1; then
|
|
953
|
+
color_ok "Python 3: $(python3 --version 2>&1)"
|
|
954
|
+
else
|
|
955
|
+
color_err "python3 コマンドが実行できません"
|
|
956
|
+
errors=$((errors + 1))
|
|
957
|
+
fi
|
|
958
|
+
|
|
959
|
+
# timeout は補助コマンド (ensure_timeout と同じ契約) なので warn のみ
|
|
960
|
+
_report_timeout
|
|
961
|
+
|
|
770
962
|
# 3. Hub AI bundle 展開を **CLI 別** に検証(manifest / CONFIG_MD マーカー /
|
|
771
963
|
# hooks の Hub SessionStart hook / 正規 .hub_token.json)。Codex 未インストールなら
|
|
772
964
|
# codex は検証しない(2026-07-15)。
|
|
@@ -831,7 +1023,7 @@ EOF
|
|
|
831
1023
|
|
|
832
1024
|
main() {
|
|
833
1025
|
color_step "hub-agent ワンライナーセットアップを開始"
|
|
834
|
-
STEP_TOTAL=
|
|
1026
|
+
STEP_TOTAL=15
|
|
835
1027
|
STEP_NUM=0
|
|
836
1028
|
|
|
837
1029
|
step_header "Homebrew"
|
|
@@ -842,6 +1034,10 @@ main() {
|
|
|
842
1034
|
ensure_node_version
|
|
843
1035
|
step_header "Build tools (native addons)"
|
|
844
1036
|
ensure_build_tools
|
|
1037
|
+
step_header "Python 3"
|
|
1038
|
+
ensure_python3
|
|
1039
|
+
step_header "GNU coreutils (timeout)"
|
|
1040
|
+
ensure_timeout
|
|
845
1041
|
step_header "npm global prefix"
|
|
846
1042
|
ensure_npm_user_prefix
|
|
847
1043
|
# ensure_node_version 直後だと brew link でシェルの command hash がズレている
|
|
@@ -854,6 +1050,8 @@ main() {
|
|
|
854
1050
|
ensure_global_install
|
|
855
1051
|
step_header "Claude Code install"
|
|
856
1052
|
ensure_claude_code
|
|
1053
|
+
step_header "Codex CLI install"
|
|
1054
|
+
ensure_codex
|
|
857
1055
|
step_header "enroll + bundle 同期"
|
|
858
1056
|
do_enroll
|
|
859
1057
|
step_header "Hub AI bootstrap (CLAUDE.md / hooks 初期化)"
|
|
@@ -869,4 +1067,15 @@ main() {
|
|
|
869
1067
|
macos_perm_guidance
|
|
870
1068
|
}
|
|
871
1069
|
|
|
872
|
-
|
|
1070
|
+
# このファイルが source されたか(実行されたか)を判定する。
|
|
1071
|
+
# - `bash -c "$(curl ...)"` / `curl ... | bash` : BASH_SOURCE が空 → 実行
|
|
1072
|
+
# - `bash install.sh` / `./install.sh` : BASH_SOURCE[0] == $0 → 実行
|
|
1073
|
+
# - `source install.sh`(test/install-sh.test.mjs): BASH_SOURCE[0] != $0 → source
|
|
1074
|
+
# 環境変数で切り替えると、変数が残ったシェルや CI でワンライナーが無言の no-op になるため使わない。
|
|
1075
|
+
_install_sh_is_sourced() {
|
|
1076
|
+
[[ -n "${BASH_SOURCE[0]:-}" && "${BASH_SOURCE[0]}" != "$0" ]]
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
if ! _install_sh_is_sourced; then
|
|
1080
|
+
main "$@"
|
|
1081
|
+
fi
|