@jonchurch/claude-code-gh 1.0.0 → 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 +10 -0
- package/bin/cli.js +62 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,6 +28,16 @@ Remote sessions only see repo-level settings. Add to `.claude/settings.json` in
|
|
|
28
28
|
|
|
29
29
|
Commit and `gh` will be available in your next web session.
|
|
30
30
|
|
|
31
|
+
### Local Install (Alternative)
|
|
32
|
+
|
|
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
|
+
|
|
31
41
|
## Environment / Network Settings
|
|
32
42
|
|
|
33
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.)
|
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": "1.
|
|
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"
|