@jonchurch/claude-code-gh 0.1.1 → 0.1.2
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/README.md +4 -2
- package/bin/setup.sh +8 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,9 +30,11 @@ Commit that file and `gh` will be available in your next web session.
|
|
|
30
30
|
|
|
31
31
|
## Environment
|
|
32
32
|
|
|
33
|
-
Your Claude Code environment needs "
|
|
33
|
+
Your Claude Code environment needs **"Full"** network access, or **"Custom"** with `release-assets.githubusercontent.com` allowed. "Limited" won't work because GitHub release downloads redirect to that domain which isn't on the default allowlist.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Authentication
|
|
36
|
+
|
|
37
|
+
To use `gh` with private repos or higher rate limits, add `GH_TOKEN` to your environment variables.
|
|
36
38
|
|
|
37
39
|
## License
|
|
38
40
|
|
package/bin/setup.sh
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
set -eo pipefail
|
|
3
3
|
|
|
4
4
|
log() { echo "[claude-code-gh] $1" >&2; }
|
|
5
|
-
context() { echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"additionalContext\":\"$1\"}}"; }
|
|
6
5
|
|
|
7
6
|
### -------- check if we need to install the cli
|
|
8
7
|
|
|
@@ -14,14 +13,15 @@ export PATH="$LOCAL_BIN:$PATH"
|
|
|
14
13
|
|
|
15
14
|
if command -v gh &>/dev/null; then
|
|
16
15
|
log "gh already available"
|
|
17
|
-
|
|
16
|
+
echo "GitHub CLI available: $(gh --version | head -1)"
|
|
18
17
|
exit 0
|
|
19
18
|
fi
|
|
20
19
|
|
|
21
20
|
### -------- check network access
|
|
22
21
|
|
|
23
|
-
if ! curl -sL --connect-timeout 5 -o /dev/null https://
|
|
24
|
-
log "
|
|
22
|
+
if ! curl -sL --connect-timeout 5 -o /dev/null https://release-assets.githubusercontent.com 2>/dev/null; then
|
|
23
|
+
log "Cannot download gh CLI: release-assets.githubusercontent.com is not reachable."
|
|
24
|
+
log "Fix: Use 'Full' network access, or add release-assets.githubusercontent.com to your Custom allowlist."
|
|
25
25
|
exit 2
|
|
26
26
|
fi
|
|
27
27
|
|
|
@@ -36,10 +36,8 @@ case "$ARCH" in
|
|
|
36
36
|
*) log "Failed to install gh CLI: unsupported architecture '$ARCH'. Only x86_64 and arm64 are supported."; exit 2 ;;
|
|
37
37
|
esac
|
|
38
38
|
|
|
39
|
-
log "Detected arch $ARCH"
|
|
40
|
-
|
|
41
39
|
# Fetch latest version from GitHub API
|
|
42
|
-
RELEASE_JSON=$(curl -sL "https://api.github.com/repos/cli/cli/releases/latest") || { log "Failed to
|
|
40
|
+
RELEASE_JSON=$(curl -sL --retry 2 "https://api.github.com/repos/cli/cli/releases/latest") || { log "Failed to fetch release info from GitHub API"; exit 2; }
|
|
43
41
|
if command -v jq &>/dev/null; then
|
|
44
42
|
VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name | ltrimstr("v")')
|
|
45
43
|
else
|
|
@@ -54,9 +52,9 @@ trap 'rm -rf "$TEMP_DIR"' EXIT
|
|
|
54
52
|
### -------- fetch and unpack the tarball
|
|
55
53
|
|
|
56
54
|
TAR_NAME="gh_${VERSION}_linux_${GH_ARCH}"
|
|
57
|
-
|
|
58
|
-
| tar -xz -C "$TEMP_DIR" || { log "Failed to install gh CLI: could not download or extract release tarball."; exit 2; }
|
|
55
|
+
TAR_URL="https://github.com/cli/cli/releases/download/v${VERSION}/${TAR_NAME}.tar.gz"
|
|
59
56
|
|
|
57
|
+
curl -sL --retry 2 "$TAR_URL" | tar -xz -C "$TEMP_DIR" || { log "Failed to download/extract gh CLI"; exit 2; }
|
|
60
58
|
|
|
61
59
|
### -------- mv the binary to local bin
|
|
62
60
|
|
|
@@ -64,4 +62,4 @@ mv "$TEMP_DIR/${TAR_NAME}/bin/gh" "$LOCAL_BIN/" && chmod +x "$LOCAL_BIN/gh"
|
|
|
64
62
|
[[ -n "$CLAUDE_ENV_FILE" ]] && echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
|
|
65
63
|
|
|
66
64
|
log "Installed $(gh --version | head -1)"
|
|
67
|
-
|
|
65
|
+
echo "GitHub CLI installed: $(gh --version | head -1) - use gh for GitHub operations"
|