@clipboard-health/ai-rules 2.14.3 → 2.14.5

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/setup.sh +46 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipboard-health/ai-rules",
3
- "version": "2.14.3",
3
+ "version": "2.14.5",
4
4
  "description": "Pre-built AI agent rules for consistent coding standards.",
5
5
  "keywords": [
6
6
  "ai",
package/scripts/setup.sh CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
+ # When invoked as a Claude Code SessionStart hook (`CLAUDE_ENV_FILE` set), only run in remote
5
+ # environments (`CLAUDE_CODE_REMOTE` set). Direct invocations (e.g., Devin, local) always run.
6
+ if [[ -n "${CLAUDE_ENV_FILE:-}" && -z "${CLAUDE_CODE_REMOTE:-}" ]]; then
7
+ exit 0
8
+ fi
9
+
4
10
  export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
5
11
 
6
12
  deps_only=false
@@ -29,15 +35,11 @@ if [ ! -f package.json ]; then
29
35
  exit 0
30
36
  fi
31
37
 
32
- # Source NVM if available. --no-use avoids auto-activating .nvmrc (which fails
33
- # if the version isn't installed yet). Full bootstrap calls nvm install/use below.
34
- export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
35
- [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use
36
-
37
- if [ "$deps_only" = true ]; then
38
- # Activate whatever node NVM has (try .nvmrc, then default alias).
39
- # Suppressed: version may not be installed yet, or NVM may not be present.
40
- nvm use 2>/dev/null || nvm use default 2>/dev/null || true
38
+ # Source NVM only for full bootstrap (not --deps-only, where engineers may not use NVM).
39
+ # --no-use avoids auto-activating .nvmrc (which fails if the version isn't installed yet).
40
+ if [ "$deps_only" = false ]; then
41
+ export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
42
+ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use
41
43
  fi
42
44
 
43
45
  if [ "$deps_only" = false ]; then
@@ -115,6 +117,40 @@ persist_claude_env() {
115
117
  }
116
118
  persist_claude_env
117
119
 
120
+ # npm auth for private installs is often injected by a shell wrapper. This
121
+ # Bash script does not inherit interactive aliases/functions, so bridge
122
+ # install-like commands explicitly when NPM_TOKEN is absent.
123
+ run_npm() {
124
+ local npm_args=("$@")
125
+
126
+ if [ -n "${NPM_TOKEN:-}" ]; then
127
+ npm "${npm_args[@]}"
128
+ return
129
+ fi
130
+
131
+ if command -v op >/dev/null 2>&1 && [ -f "$HOME/.1password.env" ]; then
132
+ echo "NPM_TOKEN not set; running npm ${npm_args[*]} via 1Password env"
133
+ if op run --env-file="$HOME/.1password.env" -- npm "${npm_args[@]}"; then
134
+ return
135
+ fi
136
+ echo "1Password env execution failed; trying other npm fallbacks" >&2
137
+ fi
138
+
139
+ local user_shell="${SHELL:-}"
140
+ local shell_name="${user_shell##*/}"
141
+ case "$shell_name" in
142
+ bash|zsh)
143
+ if "$user_shell" -ic 'alias npm >/dev/null 2>&1 || typeset -f npm >/dev/null 2>&1'; then
144
+ echo "NPM_TOKEN not set; running npm ${npm_args[*]} via interactive $shell_name shell"
145
+ "$user_shell" -ic 'npm "$@"' shell "${npm_args[@]}"
146
+ return
147
+ fi
148
+ ;;
149
+ esac
150
+
151
+ npm "${npm_args[@]}"
152
+ }
153
+
118
154
  actual_node="$(node -v | sed 's/^v//')"
119
155
  actual_npm="$(npm -v)"
120
156
 
@@ -174,6 +210,6 @@ fi
174
210
  if [ "$need_install" -eq 0 ]; then
175
211
  echo "Dependencies unchanged for $(basename "$repo_root"), skipping npm ci"
176
212
  else
177
- npm ci
213
+ run_npm ci
178
214
  printf '%s\n' "$dep_key" > "$stamp_file"
179
215
  fi