https://github.com/ai-ecoverse/as-a-bot
If I were I bot, I'dā¦
https://github.com/ai-ecoverse/as-a-bot
ai ai-agents cloudflare-worker github github-app
Last synced: 3 months ago
JSON representation
If I were I bot, I'dā¦
- Host: GitHub
- URL: https://github.com/ai-ecoverse/as-a-bot
- Owner: ai-ecoverse
- License: apache-2.0
- Created: 2025-09-01T21:10:35.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-03-12T08:44:39.000Z (4 months ago)
- Last Synced: 2026-03-12T15:33:50.444Z (4 months ago)
- Topics: ai, ai-agents, cloudflare-worker, github, github-app
- Language: JavaScript
- Homepage: https://github.com/apps/as-a-bot
- Size: 230 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub App Token Broker for ai-aligned-gh
[](https://github.com/ai-ecoverse/vibe-coded-badge-action)
A minimal Cloudflare Worker that provides user-to-server GitHub tokens via device flow for `ai-aligned-gh`.
**Key Feature**: Actions appear as the user (with app badge), not as "app/as-a-bot".
## šÆ Problem Solved
- ā **Without this worker**: PRs show `app/as-a-bot` as author
- ā
**With this worker**: PRs show `username` + app badge as author
## š Quick Start
### Prerequisites
1. **GitHub App with Device Flow enabled**:
- Go to your GitHub App settings
- Check ā
"Enable Device Flow"
- Note the Client ID
2. **Cloudflare Workers account**
### Deploy
```bash
# Clone and install
git clone https://github.com/ai-ecoverse/as-a-bot
cd as-a-bot
npm install
# Configure
wrangler secret put GITHUB_CLIENT_ID # Enter your GitHub App Client ID
# Deploy
wrangler deploy
```
## š API Endpoints
Only two endpoints needed for device flow:
### Start Device Flow
```bash
POST /user-token/start
Body: {"scopes": "repo"}
Response:
{
"device_code": "...",
"user_code": "ABCD-1234",
"verification_uri": "https://github.com/login/device",
"expires_in": 900,
"interval": 5
}
```
### Poll for Token
```bash
POST /user-token/poll
Body: {"device_code": "..."}
Response:
{
"access_token": "ghu_...", # User-to-server token
"token_type": "bearer",
"expires_at": "...",
"scope": "repo"
}
```
## š§ Integration with ai-aligned-gh
`ai-aligned-gh` will automatically use this worker to get properly attributed tokens:
```bash
# Configure ai-aligned-gh with your worker URL
export AS_A_BOT_WORKER_URL="https://your-worker.workers.dev"
# Use ai-aligned-gh normally - it handles the device flow
ai-aligned-gh pr create --title "My PR" --body "Properly attributed!"
```
## š Manual Testing
```bash
# Start device flow
RESPONSE=$(curl -sS -X POST https://your-worker.workers.dev/user-token/start \
-H "Content-Type: application/json" \
-d '{"scopes": "repo"}')
# Extract values
USER_CODE=$(echo $RESPONSE | jq -r .user_code)
DEVICE_CODE=$(echo $RESPONSE | jq -r .device_code)
# Show instructions
echo "1. Go to: https://github.com/login/device"
echo "2. Enter code: $USER_CODE"
echo "3. Then run: curl -X POST https://your-worker.workers.dev/user-token/poll -d '{\"device_code\":\"$DEVICE_CODE\"}'"
```
## š Verify Attribution
Create a test issue to verify proper attribution:
```bash
# Get token from device flow
TOKEN="ghu_..." # Your user-to-server token
# Create issue
curl -X POST https://api.github.com/repos/OWNER/REPO/issues \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "Test", "body": "Should show me as author with app badge"}'
```
**Expected**: Issue shows your username + app badge, NOT "app/as-a-bot"
## āļø Configuration
| Variable | Description | Required |
|----------|-------------|----------|
| `GITHUB_CLIENT_ID` | GitHub App Client ID | Yes |
| `GITHUB_API` | GitHub API URL (default: https://api.github.com) | No |
## šļø Architecture
```
ai-aligned-gh
ā
[Device Flow Start] ā User authorizes on GitHub
ā
[Device Flow Poll] ā Receives user-to-server token
ā
GitHub API calls show proper user attribution
```
## Related Projects
Part of the **[AI Ecoverse](https://github.com/ai-ecoverse/.github)** - a comprehensive ecosystem of tools for AI-assisted development:
- **[yolo](https://github.com/ai-ecoverse/yolo)** - AI CLI launcher with worktree isolation
- **[ai-aligned-git](https://github.com/ai-ecoverse/ai-aligned-git)** - Git wrapper for safe AI commit practices
- **[ai-aligned-gh](https://github.com/ai-ecoverse/ai-aligned-gh)** - GitHub CLI wrapper for proper AI attribution
- **[vibe-coded-badge-action](https://github.com/ai-ecoverse/vibe-coded-badge-action)** - Badge showing AI-generated code percentage
- **[gh-workflow-peek](https://github.com/ai-ecoverse/gh-workflow-peek)** - Smarter GitHub Actions log filtering
- **[upskill](https://github.com/ai-ecoverse/gh-upskill)** - Install Claude/Agent skills from other repositories
## š License
Apache 2.0