feat: add npm package support with CLI entry point
This commit is contained in:
26
.github/workflows/publish.yml
vendored
Normal file
26
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Publish to npm
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Publish to npm
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
21
.npmignore
Normal file
21
.npmignore
Normal file
@@ -0,0 +1,21 @@
|
||||
# Exclude tests
|
||||
tests/
|
||||
|
||||
# Exclude GitHub workflows
|
||||
.github/
|
||||
|
||||
# Exclude documentation (except README)
|
||||
CLAUDE.md
|
||||
CHANGELOG.md
|
||||
CONTRIBUTING.md
|
||||
docs/
|
||||
|
||||
# Exclude dev files
|
||||
.env*
|
||||
.claude/
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Exclude misc
|
||||
*.log
|
||||
.DS_Store
|
||||
109
bin/cli.js
Executable file
109
bin/cli.js
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
// Read package.json for version
|
||||
const packageJson = JSON.parse(
|
||||
readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
|
||||
);
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const command = args[0];
|
||||
|
||||
function showHelp() {
|
||||
console.log(`
|
||||
antigravity-proxy v${packageJson.version}
|
||||
|
||||
Proxy server for using Antigravity's Claude models with Claude Code CLI.
|
||||
|
||||
USAGE:
|
||||
antigravity-proxy <command> [options]
|
||||
|
||||
COMMANDS:
|
||||
start Start the proxy server (default port: 8080)
|
||||
accounts Manage Google accounts (interactive)
|
||||
accounts add Add a new Google account via OAuth
|
||||
accounts list List all configured accounts
|
||||
accounts remove Remove accounts interactively
|
||||
accounts verify Verify account tokens are valid
|
||||
accounts clear Remove all accounts
|
||||
|
||||
OPTIONS:
|
||||
--help, -h Show this help message
|
||||
--version, -v Show version number
|
||||
|
||||
ENVIRONMENT:
|
||||
PORT Server port (default: 8080)
|
||||
|
||||
EXAMPLES:
|
||||
antigravity-proxy start
|
||||
PORT=3000 antigravity-proxy start
|
||||
antigravity-proxy accounts add
|
||||
antigravity-proxy accounts list
|
||||
|
||||
CONFIGURATION:
|
||||
Claude Code CLI (~/.claude/settings.json):
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_BASE_URL": "http://localhost:8080"
|
||||
}
|
||||
}
|
||||
`);
|
||||
}
|
||||
|
||||
function showVersion() {
|
||||
console.log(packageJson.version);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Handle flags
|
||||
if (args.includes('--help') || args.includes('-h')) {
|
||||
showHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args.includes('--version') || args.includes('-v')) {
|
||||
showVersion();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Handle commands
|
||||
switch (command) {
|
||||
case 'start':
|
||||
case undefined:
|
||||
// Default to starting the server
|
||||
await import('../src/index.js');
|
||||
break;
|
||||
|
||||
case 'accounts': {
|
||||
// Pass remaining args to accounts CLI
|
||||
const subCommand = args[1] || 'add';
|
||||
process.argv = ['node', 'accounts-cli.js', subCommand, ...args.slice(2)];
|
||||
await import('../src/accounts-cli.js');
|
||||
break;
|
||||
}
|
||||
|
||||
case 'help':
|
||||
showHelp();
|
||||
break;
|
||||
|
||||
case 'version':
|
||||
showVersion();
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`Unknown command: ${command}`);
|
||||
console.error('Run "antigravity-proxy --help" for usage information.');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('Error:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
20
package.json
20
package.json
@@ -4,6 +4,13 @@
|
||||
"description": "Proxy server to use Antigravity's Claude models with Claude Code CLI",
|
||||
"main": "src/index.js",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"antigravity-proxy": "bin/cli.js"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"bin"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"dev": "node --watch src/index.js",
|
||||
@@ -27,8 +34,19 @@
|
||||
"proxy",
|
||||
"vertex-ai"
|
||||
],
|
||||
"author": "",
|
||||
"author": "Badri Narayanan",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/badri-s2001/antigravity_claude_server.git"
|
||||
},
|
||||
"homepage": "https://github.com/badri-s2001/antigravity_claude_server#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/badri-s2001/antigravity_claude_server/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2"
|
||||
|
||||
Reference in New Issue
Block a user