coralhub 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/bin/coral.js +26 -0
- package/package.json +12 -0
- package/postinstall.js +36 -0
package/bin/coral.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const child = spawn('claude', process.argv.slice(2), {
|
|
6
|
+
stdio: 'inherit',
|
|
7
|
+
env: process.env,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
child.on('error', (err) => {
|
|
11
|
+
if (err.code === 'ENOENT') {
|
|
12
|
+
console.error('Error: claude is not installed. Please install Claude Code first:');
|
|
13
|
+
console.error(' npm install -g @anthropic-ai/claude-code');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
console.error(err.message);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
child.on('exit', (code, signal) => {
|
|
21
|
+
if (signal) {
|
|
22
|
+
process.kill(process.pid, signal);
|
|
23
|
+
} else {
|
|
24
|
+
process.exit(code ?? 1);
|
|
25
|
+
}
|
|
26
|
+
});
|
package/package.json
ADDED
package/postinstall.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
const home = os.homedir();
|
|
6
|
+
|
|
7
|
+
// File 1: ~/.claude.json — skip official login
|
|
8
|
+
const claudeJson = path.join(home, '.claude.json');
|
|
9
|
+
if (!fs.existsSync(claudeJson)) {
|
|
10
|
+
fs.writeFileSync(claudeJson, JSON.stringify({ hasCompletedOnboarding: true }, null, 2) + '\n');
|
|
11
|
+
console.log('✓ Created ~/.claude.json (skip official login)');
|
|
12
|
+
} else {
|
|
13
|
+
console.log('~ ~/.claude.json already exists, skipped');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// File 2: ~/.claude/settings.json — API endpoint config
|
|
17
|
+
const claudeDir = path.join(home, '.claude');
|
|
18
|
+
const settingsJson = path.join(claudeDir, 'settings.json');
|
|
19
|
+
if (!fs.existsSync(settingsJson)) {
|
|
20
|
+
if (!fs.existsSync(claudeDir)) {
|
|
21
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
const settings = {
|
|
24
|
+
env: {
|
|
25
|
+
ANTHROPIC_BASE_URL: 'https://api.coral.com',
|
|
26
|
+
ANTHROPIC_API_KEY: 'sk-your-api-key-here',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
fs.writeFileSync(settingsJson, JSON.stringify(settings, null, 2) + '\n');
|
|
30
|
+
console.log('✓ Created ~/.claude/settings.json');
|
|
31
|
+
console.log(' → Please edit ANTHROPIC_API_KEY with your actual key');
|
|
32
|
+
} else {
|
|
33
|
+
console.log('~ ~/.claude/settings.json already exists, skipped');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log('\nRun `coral` to start Claude Code with Coral API endpoint.');
|