@jonchurch/claude-code-gh 0.1.2 → 1.1.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 +17 -7
- package/bin/cli.js +62 -0
- package/package.json +2 -2
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,15 +26,25 @@ 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
|
-
|
|
31
|
+
### Local Install (Alternative)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Running `npx` on every session start means executing code from npm that you don't control. If you'd rather call a script under your own version control:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx @jonchurch/claude-code-gh install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This copies the script to `.claude/hooks/` and updates your settings to use it. Commit both and you're set.
|
|
40
|
+
|
|
41
|
+
## Environment / Network Settings
|
|
42
|
+
|
|
43
|
+
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
44
|
|
|
35
45
|
## Authentication
|
|
36
46
|
|
|
37
|
-
|
|
47
|
+
For private repos or higher rate limits, add `GH_TOKEN` to your environment variables.
|
|
38
48
|
|
|
39
49
|
## License
|
|
40
50
|
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const command = process.argv[2];
|
|
8
|
+
|
|
9
|
+
if (command === 'install') {
|
|
10
|
+
install();
|
|
11
|
+
} else {
|
|
12
|
+
// Default: run setup.sh
|
|
13
|
+
const setup = path.join(__dirname, 'setup.sh');
|
|
14
|
+
const child = spawn('bash', [setup], { stdio: 'inherit' });
|
|
15
|
+
child.on('close', code => process.exit(code));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function install() {
|
|
19
|
+
const HOOKS_DIR = '.claude/hooks';
|
|
20
|
+
const SETTINGS_PATH = '.claude/settings.json';
|
|
21
|
+
const SCRIPT_NAME = 'jonchurch-claude-code-gh.sh';
|
|
22
|
+
|
|
23
|
+
// Copy setup.sh to user's repo
|
|
24
|
+
const src = path.join(__dirname, 'setup.sh');
|
|
25
|
+
const dest = path.join(HOOKS_DIR, SCRIPT_NAME);
|
|
26
|
+
|
|
27
|
+
fs.mkdirSync(HOOKS_DIR, { recursive: true });
|
|
28
|
+
fs.copyFileSync(src, dest);
|
|
29
|
+
fs.chmodSync(dest, 0o755);
|
|
30
|
+
console.log(`Copied ${dest}`);
|
|
31
|
+
|
|
32
|
+
// Update settings.json
|
|
33
|
+
let settings = {};
|
|
34
|
+
if (fs.existsSync(SETTINGS_PATH)) {
|
|
35
|
+
settings = JSON.parse(fs.readFileSync(SETTINGS_PATH, 'utf8'));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const hookCommand = `"$CLAUDE_PROJECT_DIR"/${HOOKS_DIR}/${SCRIPT_NAME}`;
|
|
39
|
+
|
|
40
|
+
// Check if already installed (look for our script name in any SessionStart hook)
|
|
41
|
+
const alreadyInstalled = settings.hooks?.SessionStart?.some(entry =>
|
|
42
|
+
entry.hooks?.some(h => h.command?.includes(SCRIPT_NAME))
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (alreadyInstalled) {
|
|
46
|
+
console.log('Hook already configured');
|
|
47
|
+
} else {
|
|
48
|
+
if (!settings.hooks) settings.hooks = {};
|
|
49
|
+
if (!settings.hooks.SessionStart) settings.hooks.SessionStart = [];
|
|
50
|
+
|
|
51
|
+
settings.hooks.SessionStart.push({
|
|
52
|
+
matcher: 'startup',
|
|
53
|
+
hooks: [{ type: 'command', command: hookCommand }]
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + '\n');
|
|
57
|
+
console.log(`Added hook to ${SETTINGS_PATH}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('\nDone! Commit the changes:');
|
|
61
|
+
console.log(` git add ${SETTINGS_PATH} ${dest}`);
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jonchurch/claude-code-gh",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Auto-install GitHub CLI (gh) for Claude Code web/remote sessions",
|
|
5
5
|
"author": "Jon Church",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"web"
|
|
24
24
|
],
|
|
25
25
|
"bin": {
|
|
26
|
-
"claude-code-gh": "bin/
|
|
26
|
+
"claude-code-gh": "bin/cli.js"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"bin"
|