cc-safe-setup 29.6.29 → 29.6.30
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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# direnv-auto-reload.sh — Auto-reload environment when directory changes
|
|
3
|
+
#
|
|
4
|
+
# Uses the CwdChanged hook event (v2.1.83+) to detect directory changes
|
|
5
|
+
# and source .envrc/.env files for the new directory.
|
|
6
|
+
#
|
|
7
|
+
# Solves: Claude Code doesn't automatically pick up directory-specific
|
|
8
|
+
# environment variables when switching between projects.
|
|
9
|
+
# This can lead to using wrong API endpoints, wrong database
|
|
10
|
+
# connections, or missing required env vars.
|
|
11
|
+
#
|
|
12
|
+
# TRIGGER: CwdChanged (no matcher support — fires on every cd)
|
|
13
|
+
#
|
|
14
|
+
# INPUT: {"old_cwd": "/path/from", "new_cwd": "/path/to"}
|
|
15
|
+
#
|
|
16
|
+
# DECISION CONTROL: None (notification only — shows stderr to user)
|
|
17
|
+
|
|
18
|
+
INPUT=$(cat)
|
|
19
|
+
NEW_CWD=$(echo "$INPUT" | jq -r '.new_cwd // empty' 2>/dev/null)
|
|
20
|
+
OLD_CWD=$(echo "$INPUT" | jq -r '.old_cwd // empty' 2>/dev/null)
|
|
21
|
+
[ -z "$NEW_CWD" ] && exit 0
|
|
22
|
+
|
|
23
|
+
# Check for .envrc (direnv)
|
|
24
|
+
if [ -f "${NEW_CWD}/.envrc" ]; then
|
|
25
|
+
echo "📂 Directory changed: found .envrc in ${NEW_CWD}" >&2
|
|
26
|
+
if command -v direnv &>/dev/null; then
|
|
27
|
+
echo " direnv: auto-allowing and loading" >&2
|
|
28
|
+
cd "$NEW_CWD" && direnv allow . 2>/dev/null && eval "$(direnv export bash 2>/dev/null)"
|
|
29
|
+
else
|
|
30
|
+
echo " ⚠ direnv not installed — .envrc found but not loaded" >&2
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Check for .env
|
|
35
|
+
if [ -f "${NEW_CWD}/.env" ]; then
|
|
36
|
+
echo "📂 Directory changed: .env found in ${NEW_CWD}" >&2
|
|
37
|
+
echo " Environment variables available but not auto-sourced (security)" >&2
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Check for .node-version / .nvmrc
|
|
41
|
+
if [ -f "${NEW_CWD}/.node-version" ] || [ -f "${NEW_CWD}/.nvmrc" ]; then
|
|
42
|
+
EXPECTED=$(cat "${NEW_CWD}/.node-version" 2>/dev/null || cat "${NEW_CWD}/.nvmrc" 2>/dev/null)
|
|
43
|
+
CURRENT=$(node -v 2>/dev/null | sed 's/^v//')
|
|
44
|
+
if [ -n "$EXPECTED" ] && [ -n "$CURRENT" ]; then
|
|
45
|
+
if [ "$EXPECTED" != "$CURRENT" ]; then
|
|
46
|
+
echo "⚠ Node version mismatch: expected ${EXPECTED}, running ${CURRENT}" >&2
|
|
47
|
+
fi
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
exit 0
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# dotenv-watch.sh — Alert when .env files change on disk
|
|
3
|
+
#
|
|
4
|
+
# Uses the FileChanged hook event (v2.1.83+) to detect when
|
|
5
|
+
# environment configuration files are modified outside of Claude Code.
|
|
6
|
+
#
|
|
7
|
+
# Solves: When .env files are modified by another process (git pull,
|
|
8
|
+
# manual edit, dotenv rotation script), Claude Code doesn't
|
|
9
|
+
# know the environment has changed. This can cause stale
|
|
10
|
+
# API keys, wrong database URLs, or missing config values.
|
|
11
|
+
#
|
|
12
|
+
# TRIGGER: FileChanged
|
|
13
|
+
# MATCHER: ".env" (watches .env files — also catches .env.local, .env.production)
|
|
14
|
+
#
|
|
15
|
+
# INPUT: {"file_path": "/path/to/.env", "event": "modified|created|deleted"}
|
|
16
|
+
#
|
|
17
|
+
# DECISION CONTROL: None (notification only — shows stderr to user)
|
|
18
|
+
|
|
19
|
+
INPUT=$(cat)
|
|
20
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.file_path // empty' 2>/dev/null)
|
|
21
|
+
EVENT=$(echo "$INPUT" | jq -r '.event // empty' 2>/dev/null)
|
|
22
|
+
[ -z "$FILE_PATH" ] && exit 0
|
|
23
|
+
|
|
24
|
+
FILENAME=$(basename "$FILE_PATH")
|
|
25
|
+
|
|
26
|
+
case "$EVENT" in
|
|
27
|
+
modified)
|
|
28
|
+
echo "⚠ Environment file changed: ${FILENAME}" >&2
|
|
29
|
+
echo " Path: ${FILE_PATH}" >&2
|
|
30
|
+
echo " Action: Verify environment variables are still correct" >&2
|
|
31
|
+
;;
|
|
32
|
+
created)
|
|
33
|
+
echo "📝 New environment file: ${FILENAME}" >&2
|
|
34
|
+
echo " Path: ${FILE_PATH}" >&2
|
|
35
|
+
echo " Action: Review contents before use" >&2
|
|
36
|
+
;;
|
|
37
|
+
deleted)
|
|
38
|
+
echo "🗑 Environment file deleted: ${FILENAME}" >&2
|
|
39
|
+
echo " Path: ${FILE_PATH}" >&2
|
|
40
|
+
echo " Action: Check if environment variables are still available" >&2
|
|
41
|
+
;;
|
|
42
|
+
*)
|
|
43
|
+
echo "📂 Environment file event (${EVENT}): ${FILENAME}" >&2
|
|
44
|
+
;;
|
|
45
|
+
esac
|
|
46
|
+
|
|
47
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "29.6.
|
|
4
|
-
"description": "One command to make Claude Code safe.
|
|
3
|
+
"version": "29.6.30",
|
|
4
|
+
"description": "One command to make Claude Code safe. 516 example hooks + 8 built-in. 56 CLI commands. 7582 tests. Works with Auto Mode.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|