claude-cac 1.4.2 → 1.4.3

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 CHANGED
@@ -11,7 +11,7 @@ VERSIONS_DIR="$CAC_DIR/versions"
11
11
  # ── utils: colors, read/write, UUID, proxy parsing ───────────────────────
12
12
 
13
13
  # shellcheck disable=SC2034 # used in build-concatenated cac script
14
- CAC_VERSION="1.4.2"
14
+ CAC_VERSION="1.4.3"
15
15
 
16
16
  _read() { [[ -f "$1" ]] && tr -d '[:space:]' < "$1" || echo "${2:-}"; }
17
17
  _die() { printf '%b\n' "$(_red "error:") $*" >&2; exit 1; }
@@ -1750,6 +1750,7 @@ MERGE_EOF
1750
1750
  }
1751
1751
 
1752
1752
  _env_cmd_ls() {
1753
+ _require_setup
1753
1754
  if [[ ! -d "$ENVS_DIR" ]] || [[ -z "$(ls -A "$ENVS_DIR" 2>/dev/null)" ]]; then
1754
1755
  echo "$(_dim " No environments yet.")"
1755
1756
  echo " Run $(_green "cac env create <name>") to get started."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-cac",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Isolate, protect, and manage your Claude Code — versions, environments, identity, and proxy.",
5
5
  "bin": {
6
6
  "cac": "cac"
@@ -27,6 +27,44 @@ try {
27
27
  // Non-fatal — _ensure_initialized will catch it on first cac command
28
28
  }
29
29
 
30
+ // Patch existing wrapper for known bugs — pure Node.js, no shell execution needed.
31
+ // Users who upgrade via npm install keep their old ~/.cac/bin/claude until _ensure_initialized
32
+ // runs (triggered by any cac command). This patch fixes critical bugs immediately.
33
+ var wrapperPath = path.join(cacDir, 'bin', 'claude');
34
+ if (home && fs.existsSync(wrapperPath)) {
35
+ try {
36
+ var wrapperContent = fs.readFileSync(wrapperPath, 'utf8');
37
+ var patched = wrapperContent;
38
+ // Fix: pgrep returns exit 1 when no claude process exists; under set -euo pipefail
39
+ // this aborts the wrapper before launching claude (claude appears to do nothing).
40
+ var buggyPgrep = '_claude_count=$(pgrep -x "claude" 2>/dev/null | wc -l | tr -d \'[:space:]\')';
41
+ var fixedPgrep = buggyPgrep + ' || _claude_count=0';
42
+ if (patched.indexOf(buggyPgrep) !== -1 && patched.indexOf(fixedPgrep) === -1) {
43
+ patched = patched.replace(buggyPgrep, fixedPgrep);
44
+ }
45
+ if (patched !== wrapperContent) {
46
+ fs.writeFileSync(wrapperPath, patched);
47
+ }
48
+ } catch (e) {
49
+ // Non-fatal
50
+ }
51
+ }
52
+
53
+ // Trigger _ensure_initialized to fully regenerate wrapper to current version.
54
+ // cac env ls now calls _require_setup (fixed in 1.4.3+).
55
+ if (home) {
56
+ try {
57
+ var spawnSync = require('child_process').spawnSync;
58
+ spawnSync(cacBin, ['env', 'ls'], {
59
+ stdio: 'ignore',
60
+ timeout: 8000,
61
+ env: Object.assign({}, process.env, { HOME: home })
62
+ });
63
+ } catch (e) {
64
+ // Non-fatal
65
+ }
66
+ }
67
+
30
68
  console.log([
31
69
  '',
32
70
  ' claude-cac installed successfully',