@silicaclaw/cli 1.0.0-beta.11 → 1.0.0-beta.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silicaclaw/cli",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.12",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -79,6 +79,18 @@ EOF
79
79
  return 0
80
80
  }
81
81
 
82
+ default_system_bin_dir() {
83
+ if [ -d "/usr/local/bin" ]; then
84
+ printf '/usr/local/bin'
85
+ return 0
86
+ fi
87
+ if [ -d "/opt/homebrew/bin" ]; then
88
+ printf '/opt/homebrew/bin'
89
+ return 0
90
+ fi
91
+ printf '/usr/local/bin'
92
+ }
93
+
82
94
  ask_yes_no() {
83
95
  local prompt="$1"
84
96
  local default="${2:-Y}"
@@ -208,11 +220,14 @@ if command -v silicaclaw >/dev/null 2>&1; then
208
220
  else
209
221
  echo "将尝试无 sudo 安装 silicaclaw 命令到 PATH 中可写目录。"
210
222
  BIN_DIR="$(first_writable_path_dir || true)"
223
+ INSTALLED=0
211
224
  if [ -n "${BIN_DIR:-}" ]; then
212
225
  if install_command_shim "$BIN_DIR"; then
213
226
  echo "命令已安装: $BIN_DIR/silicaclaw"
227
+ hash -r || true
214
228
  if command -v silicaclaw >/dev/null 2>&1; then
215
229
  echo "验证成功: $(command -v silicaclaw)"
230
+ INSTALLED=1
216
231
  else
217
232
  echo "命令已写入,但当前 shell 未立即识别。请新开终端后运行 silicaclaw。"
218
233
  fi
@@ -221,7 +236,28 @@ else
221
236
  fi
222
237
  else
223
238
  echo "当前 PATH 中没有可写目录,无法无 sudo 安装系统命令。"
224
- echo "你仍可直接使用: npx @silicaclaw/cli@beta <command>"
239
+ fi
240
+
241
+ if [ "$INSTALLED" != "1" ]; then
242
+ SYS_BIN_DIR="$(default_system_bin_dir)"
243
+ echo "为保证开箱即用体验,建议安装到系统目录: $SYS_BIN_DIR/silicaclaw"
244
+ if ask_yes_no "是否使用 sudo 安装系统命令?" "Y"; then
245
+ run_cmd "sudo mkdir -p \"$SYS_BIN_DIR\""
246
+ run_cmd "sudo tee \"$SYS_BIN_DIR/silicaclaw\" >/dev/null <<'EOF'
247
+ #!/usr/bin/env bash
248
+ set -euo pipefail
249
+ exec node \"$WORK_DIR/scripts/silicaclaw-cli.mjs\" \"\$@\"
250
+ EOF"
251
+ run_cmd "sudo chmod +x \"$SYS_BIN_DIR/silicaclaw\""
252
+ hash -r || true
253
+ if command -v silicaclaw >/dev/null 2>&1; then
254
+ echo "验证成功: $(command -v silicaclaw)"
255
+ else
256
+ echo "安装完成,但当前 shell 未刷新。请新开终端后运行 silicaclaw。"
257
+ fi
258
+ else
259
+ echo "已跳过 sudo 安装。你仍可使用: npx @silicaclaw/cli@beta <command>"
260
+ fi
225
261
  fi
226
262
  fi
227
263