@jonchurch/claude-code-gh 0.1.1 → 1.0.0
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 +9 -7
- package/bin/setup.sh +8 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# claude-code-gh
|
|
2
2
|
|
|
3
|
-
Claude Code web sessions run on ephemeral VMs
|
|
3
|
+
Claude Code web sessions run on ephemeral VMs without the GitHub CLI (`gh`). If you're used to having Claude work with `gh` locally, you won't be able to in web sessions.
|
|
4
4
|
|
|
5
|
-
This package
|
|
5
|
+
This package fixes that by installing `gh` automatically [when your session starts](https://code.claude.com/docs/en/hooks#sessionstart).
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Remote sessions only see repo-level settings. Add to `.claude/settings.json` in your repo:
|
|
10
10
|
|
|
11
11
|
```json
|
|
12
12
|
{
|
|
@@ -26,13 +26,15 @@ Add to your repo's `.claude/settings.json` (not user level `~/.claude/settings.j
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Commit
|
|
29
|
+
Commit and `gh` will be available in your next web session.
|
|
30
30
|
|
|
31
|
-
## Environment
|
|
31
|
+
## Environment / Network Settings
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Requires **"Full"** [network access](https://code.claude.com/docs/en/claude-code-on-the-web), or **"Custom"** with `release-assets.githubusercontent.com` allowed. ("Limited" won't work - GitHub downloads redirect to that domain.)
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Authentication
|
|
36
|
+
|
|
37
|
+
For 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"
|