claude-cac 1.1.2 → 1.1.4
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/cac +19 -16
- package/package.json +1 -1
package/cac
CHANGED
|
@@ -10,7 +10,7 @@ VERSIONS_DIR="$CAC_DIR/versions"
|
|
|
10
10
|
# ━━━ utils.sh ━━━
|
|
11
11
|
# ── utils: 颜色、读写、UUID、proxy 解析 ───────────────────────
|
|
12
12
|
|
|
13
|
-
CAC_VERSION="1.1.
|
|
13
|
+
CAC_VERSION="1.1.4"
|
|
14
14
|
|
|
15
15
|
_read() { [[ -f "$1" ]] && tr -d '[:space:]' < "$1" || echo "${2:-}"; }
|
|
16
16
|
_die() { printf '%b\n' "$(_red "error:") $*" >&2; exit 1; }
|
|
@@ -1192,22 +1192,35 @@ IFCONFIG_EOF
|
|
|
1192
1192
|
|
|
1193
1193
|
# Silent, idempotent initialization — called automatically by any command
|
|
1194
1194
|
_ensure_initialized() {
|
|
1195
|
-
|
|
1196
|
-
[[ -f "$CAC_DIR/bin/claude" ]] && [[ -d "$ENVS_DIR" ]] && [[ -d "$VERSIONS_DIR" ]] && return 0
|
|
1195
|
+
mkdir -p "$CAC_DIR" "$ENVS_DIR" "$VERSIONS_DIR"
|
|
1197
1196
|
|
|
1198
|
-
|
|
1197
|
+
# Always sync JS hooks + dns-guard (they update with cac versions)
|
|
1198
|
+
# Resolve symlink — npm global install creates: /usr/local/bin/cac → .../node_modules/claude-cac/cac
|
|
1199
|
+
local _self_path="${BASH_SOURCE[0]:-$0}"
|
|
1200
|
+
if [[ -L "$_self_path" ]]; then
|
|
1201
|
+
local _link; _link="$(readlink "$_self_path")"
|
|
1202
|
+
[[ "$_link" != /* ]] && _link="$(dirname "$_self_path")/$_link"
|
|
1203
|
+
_self_path="$_link"
|
|
1204
|
+
fi
|
|
1205
|
+
local _self_dir
|
|
1206
|
+
_self_dir="$(cd "$(dirname "$_self_path")" && pwd)"
|
|
1207
|
+
[[ -f "$_self_dir/fingerprint-hook.js" ]] && cp "$_self_dir/fingerprint-hook.js" "$CAC_DIR/fingerprint-hook.js"
|
|
1208
|
+
[[ -f "$_self_dir/relay.js" ]] && cp "$_self_dir/relay.js" "$CAC_DIR/relay.js"
|
|
1209
|
+
_write_dns_guard_js 2>/dev/null || true
|
|
1210
|
+
_write_blocked_hosts 2>/dev/null || true
|
|
1211
|
+
|
|
1212
|
+
# Rest only needed on first init
|
|
1213
|
+
[[ -f "$CAC_DIR/bin/claude" ]] && return 0
|
|
1199
1214
|
|
|
1200
1215
|
# Find real claude (system-installed or managed)
|
|
1201
1216
|
local real_claude
|
|
1202
1217
|
real_claude=$(_find_real_claude)
|
|
1203
1218
|
if [[ -z "$real_claude" ]]; then
|
|
1204
|
-
# Check managed versions
|
|
1205
1219
|
local latest_ver; latest_ver=$(_read "$VERSIONS_DIR/.latest" "")
|
|
1206
1220
|
if [[ -n "$latest_ver" ]]; then
|
|
1207
1221
|
real_claude="$VERSIONS_DIR/$latest_ver/claude"
|
|
1208
1222
|
fi
|
|
1209
1223
|
fi
|
|
1210
|
-
# If still not found, we can still initialize — env create will handle it
|
|
1211
1224
|
if [[ -n "$real_claude" ]] && [[ -x "$real_claude" ]]; then
|
|
1212
1225
|
echo "$real_claude" > "$CAC_DIR/real_claude"
|
|
1213
1226
|
fi
|
|
@@ -1215,12 +1228,6 @@ _ensure_initialized() {
|
|
|
1215
1228
|
local os; os=$(_detect_os)
|
|
1216
1229
|
_write_wrapper
|
|
1217
1230
|
|
|
1218
|
-
# Copy JS hooks from source location (build.sh puts them alongside cac)
|
|
1219
|
-
local _self_dir
|
|
1220
|
-
_self_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
1221
|
-
[[ -f "$_self_dir/fingerprint-hook.js" ]] && cp "$_self_dir/fingerprint-hook.js" "$CAC_DIR/fingerprint-hook.js"
|
|
1222
|
-
[[ -f "$_self_dir/relay.js" ]] && cp "$_self_dir/relay.js" "$CAC_DIR/relay.js"
|
|
1223
|
-
|
|
1224
1231
|
# Shims
|
|
1225
1232
|
_write_hostname_shim
|
|
1226
1233
|
_write_ifconfig_shim
|
|
@@ -1230,10 +1237,6 @@ _ensure_initialized() {
|
|
|
1230
1237
|
_write_machine_id_shim
|
|
1231
1238
|
fi
|
|
1232
1239
|
|
|
1233
|
-
# DNS guard + blocked hosts
|
|
1234
|
-
_write_dns_guard_js 2>/dev/null || true
|
|
1235
|
-
_write_blocked_hosts 2>/dev/null || true
|
|
1236
|
-
|
|
1237
1240
|
# mTLS CA
|
|
1238
1241
|
_generate_ca_cert 2>/dev/null || true
|
|
1239
1242
|
|