https://github.com/gooseware/opencode-antigravity-autopilot
Quota management and model rotation for opencode-antigravity-auth
https://github.com/gooseware/opencode-antigravity-autopilot
antigravity claude gemini model-rotation oh-my-opencode opencode quota-management typescript
Last synced: 4 months ago
JSON representation
Quota management and model rotation for opencode-antigravity-auth
- Host: GitHub
- URL: https://github.com/gooseware/opencode-antigravity-autopilot
- Owner: Gooseware
- License: mit
- Created: 2026-01-14T14:13:36.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-23T14:46:05.000Z (5 months ago)
- Last Synced: 2026-01-23T16:20:26.346Z (5 months ago)
- Topics: antigravity, claude, gemini, model-rotation, oh-my-opencode, opencode, quota-management, typescript
- Language: TypeScript
- Homepage:
- Size: 12.8 MB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenCode Antigravity Autopilot
[](https://www.npmjs.com/package/opencode-antigravity-autopilot)
[](LICENSE)
**Intelligent quota monitoring and automatic model switching for OpenCode with Antigravity.**
Zero OpenCode source modifications required - works as a pure plugin!
## โจ Features
- ๐ **Real-time Quota Monitoring** - Check quota via LLM tools
- ๐ **Automatic Model Switching** - Switch models when quota exhausted
- ๐ฏ **Proactive Optimization** - Switch before hitting hard limits
- ๐ **Account Rotation** - Automatically rotate between accounts
- ๐ ๏ธ **Plugin-Based** - No OpenCode source modifications needed
- ๐ค **LLM-Aware** - Assistant can check quota and make decisions
## ๐ Quick Start
### ๐ค Install with LLM
Simply copy and paste this prompt to your OpenCode assistant:
> Please read the documentation at https://github.com/Gooseware/opencode-antigravity-autopilot#readme to understand the installation steps.
> Install the `opencode-antigravity-autopilot` plugin from npm.
> Then, configure `~/.config/opencode/opencode.json` to add `"opencode-antigravity-autopilot"` to the `plugin` list.
> Finally, create a default quota config in `~/.config/opencode/quota.json` with auto-rotation enabled for models like `antigravity-gemini-3-pro-high` and `antigravity-claude-sonnet-4-5`.
### From NPM
```bash
npm install opencode-antigravity-autopilot
```
### From GitHub (Source)
```bash
git clone https://github.com/Gooseware/opencode-antigravity-autopilot.git
cd opencode-antigravity-autopilot
npm install
npm run build
npm link
```
### Prerequisites
- Node.js >= 20.0.0
- [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) installed and configured
- OpenCode with plugin support
### Configuration
#### Plugin Registration
Add to `~/.config/opencode/opencode.json`:
```json
{
"plugin": [
"opencode-antigravity-auth",
"opencode-antigravity-autopilot"
]
}
```
#### Quota Configuration
Create `~/.config/opencode/quota.json` to configure thresholds and models:
```json
{
"quotaThreshold": 0.05,
"preferredModels": [
"antigravity-gemini-3-pro-high", // Try this first
"antigravity-claude-sonnet-4-5", // Then this
"antigravity-gemini-3-flash" // Fallback
],
"autoRotate": true
}
```
That's it! The plugin is now active.
## ๐ Usage
### Check Quota via LLM
Simply ask your assistant:
```
"Check my quota status"
"Show detailed quota for all models"
"Can I use antigravity-gemini-3-pro-high right now?"
```
The LLM will call the appropriate tools and show results like:
```
# Quota Status
โ **Current Model:** antigravity-gemini-3-pro-high
**Status:** Quota healthy at 67%
**Accounts:** 1 of 3 active
```
### Available Tools
The plugin exposes three tools to the LLM:
#### `quota_status`
Check current quota with optional detailed view
```typescript
quota_status()
quota_status({ detailed: true })
```
#### `quota_check_model`
Check if a specific model has enough quota
```typescript
quota_check_model({ model: "antigravity-gemini-3-pro-high" })
```
#### `quota_rotate_account`
Manually rotate to next available account
```typescript
quota_rotate_account()
```
### Programmatic Usage
```typescript
import { HardLimitDetector } from 'opencode-antigravity-autopilot';
const detector = new HardLimitDetector({
quotaThreshold: 0.2, // Switch when below 20%
preferredModels: [
'google/antigravity-gemini-3-pro-high',
'google/antigravity-claude-sonnet-4-5'
]
});
// Before using a model
const result = await detector.checkHardLimit('antigravity-gemini-3-pro-high');
if (result.shouldRotate) {
console.log(`Switching to: ${result.nextModel}`);
}
```
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OpenCode (No modifications) โ
โ โ
โ LLM Tools: โ
โ - quota_status โ
โ - quota_check_model โ
โ - quota_rotate_account โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Autopilot Plugin โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ApiQuotaPoller โ โ
โ โ Real-time API data โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ HardLimitDetector โ โ
โ โ Auto model switch โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## ๐ง Configuration
### Quota Threshold
Configure when to proactively switch models:
```typescript
import { QuotaManager } from 'opencode-antigravity-autopilot';
const manager = new QuotaManager({
quotaThreshold: 0.2 // Switch when below 20%
});
```
### Preferred Models
Set model preference order:
```typescript
import { HardLimitDetector } from 'opencode-antigravity-autopilot';
const detector = new HardLimitDetector({
preferredModels: [
'google/antigravity-gemini-3-pro-high', // Try first
'google/antigravity-claude-sonnet-4-5', // Try second
'google/antigravity-gemini-3-flash' // Fallback
]
});
```
## ๐งช Testing
```bash
# Test hard limit detection
npm run test:quota
# Run full test suite
npm test
```
## ๐ API Reference
### HardLimitDetector
```typescript
class HardLimitDetector {
constructor(config?: PluginConfig);
checkHardLimit(currentModel: string): Promise;
updateAllQuotas(): Promise;
rotateAccount(): Promise;
}
interface HardLimitCheckResult {
isExhausted: boolean;
shouldRotate: boolean;
nextModel?: string;
message?: string;
}
```
### QuotaManager
```typescript
class QuotaManager {
constructor(config?: PluginConfig);
initialize(): Promise;
getQuotaViaApi(modelName?: string): Promise;
getAllQuotasViaApi(): Promise>;
rotateAccount(): Promise;
}
```
### QuotaCacheUpdater
```typescript
class QuotaCacheUpdater {
constructor(manager: QuotaManager, updateIntervalMs?: number);
updateCache(): Promise;
start(): void;
stop(): void;
}
function startQuotaCacheService(updateIntervalMs?: number): Promise;
```
## ๐ ๏ธ Advanced Usage
### Background Quota Service
Run a background service to keep quota cache updated:
```bash
npm run service:start
```
Or programmatically:
```typescript
import { startQuotaCacheService } from 'opencode-antigravity-autopilot';
const updater = await startQuotaCacheService(60000); // Update every 60s
updater.start();
// Later...
updater.stop();
```
### oh-my-opencode Integration
```typescript
import {
createOhMyOpenCodeIntegration,
QuotaManager
} from 'opencode-antigravity-autopilot';
const manager = new QuotaManager();
await manager.initialize();
const integration = createOhMyOpenCodeIntegration(manager, {
defaultModel: 'google/antigravity-gemini-3-flash'
});
const model = await integration.getModelForAgent('oracle');
console.log(`Oracle will use: ${model}`);
```
## ๐ Troubleshooting
### Tools Not Showing Up
```bash
# Verify plugin is installed
npm list opencode-antigravity-autopilot
# Check OpenCode config
cat ~/.config/opencode/opencode.json
```
### Quota Check Fails
```bash
# Verify authentication
cat ~/.config/opencode/antigravity-accounts.json
# Test manually
node -e "const {QuotaManager} = require('opencode-antigravity-autopilot'); const m = new QuotaManager(); m.initialize().then(() => m.getQuotaViaApi().then());"
```
### Model Switch Not Working
```bash
# Test hard limit detector
npm run test:quota
```
## ๐ Changelog
See [CHANGELOG.md](CHANGELOG.md) for release history.
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
MIT ยฉ [gooseware](https://github.com/gooseware)
## ๐ Credits
Built on top of:
- [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) by [@NoeFabris](https://github.com/NoeFabris)
- [OpenCode](https://github.com/opencode-ai/opencode)
## ๐ Related Projects
- [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) - Authentication for Antigravity
- [opencode-antigravity-quota](https://github.com/gooseware/opencode-antigravity-quota) - Standalone quota checker
- [oh-my-opencode](https://github.com/opencode-ai/oh-my-opencode) - Enhanced OpenCode experience
## ๐ฌ Support
- [GitHub Issues](https://github.com/gooseware/opencode-antigravity-autopilot/issues)
- [Discussions](https://github.com/gooseware/opencode-antigravity-autopilot/discussions)
---
**Made with โค๏ธ for the OpenCode community**