-
-
Notifications
You must be signed in to change notification settings - Fork 185
chore(cubebot): GitHub automation bot for issue triage #1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alvarosabu
wants to merge
34
commits into
main
Choose a base branch
from
chore/tres-212-github-cubebot-automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3ad046c
chore(cubebot): scaffold cloudflare worker app
alvarosabu 8f68df3
chore(cubebot): add d1 schema and types
alvarosabu 9a63bb9
feat(cubebot): add github webhook signature verification
alvarosabu d3dc685
feat(cubebot): add github api client and helpers
alvarosabu da52d0f
feat(cubebot): add issue detection logic
alvarosabu a5c8feb
feat(cubebot): add rag retrieval with workers ai embeddings
alvarosabu 201e28d
feat(cubebot): add claude integration for issue analysis
alvarosabu 7e3b26d
feat(cubebot): add comment formatters
alvarosabu 72ea6eb
feat(cubebot): add issue opened handler
alvarosabu 6419f44
feat(cubebot): add comment handler for @mentions
alvarosabu bcbc669
feat(cubebot): add docs embedding script
alvarosabu 07cf067
docs(cubebot): add readme and project documentation
alvarosabu 3137bda
feat(cubebot): add admin endpoint to seed doc embeddings
alvarosabu 01f0aa8
docs(cubebot): update readme with correct deployment steps
alvarosabu 4c3a81d
feat(cubebot): integrate @octokit/auth-app for GitHub authentication …
alvarosabu 76bf160
feat(cubebot): implement feasibility analysis for issues with code co…
alvarosabu 55e6ac9
fix(cubebot): update prompt package format and improve issue triage l…
alvarosabu 180b546
feat(cubebot): rename and refactor issue conversion to discussion logic
alvarosabu 216e00f
Merge branch 'main' into chore/tres-212-github-cubebot-automation
alvarosabu 2b77452
feat(github): modify issue handling to skip feature request redirecti…
alvarosabu 6e49757
feat(github): add GitHub Actions workflow for deploying CubeBot to Cl…
alvarosabu 00b311a
chore(cubebot): remove outdated CubeBot implementation plan document
alvarosabu 78dc25a
chore(cubebot): update dependencies in package.json and pnpm-lock.yam…
alvarosabu a3a8e76
chore(github): add pull request trigger for CubeBot deployment workflow
alvarosabu ada19c2
chore(github): update deploy command in CubeBot workflow to use 'run'…
alvarosabu 33c2933
feat(cubebot): enhance author comment formatting with greeting and jo…
alvarosabu 20af764
Update apps/cubebot/README.md
alvarosabu 6886d28
chore(cubebot): improve seed documentation process and enhance securi…
alvarosabu c902218
Merge branch 'main' into chore/tres-212-github-cubebot-automation
alvarosabu 64309f9
Merge branch 'main' into chore/tres-212-github-cubebot-automation
alvarosabu e15867c
chore: update hono dependency to version 4.12.12 and clean up TypeScr…
alvarosabu cab270d
Merge branch 'main' into chore/tres-212-github-cubebot-automation
alvarosabu 66f8d07
chore: add undici override to package.json and pnpm-lock.yaml
alvarosabu 829ac39
Merge branch 'main' into chore/tres-212-github-cubebot-automation
alvarosabu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Deploy CubeBot | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'apps/cubebot/**' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'apps/cubebot/**' | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| name: Deploy to Cloudflare Workers | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - uses: ./.github/actions/setup-node | ||
|
|
||
| - name: Deploy | ||
| run: pnpm --filter cubebot run deploy | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| data/ | ||
| .wrangler/ | ||
| .dev.vars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # CubeBot | ||
|
|
||
| GitHub App bot for TresJS issue triage built on Cloudflare Workers. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - **Runtime:** Cloudflare Workers | ||
| - **Framework:** Hono | ||
| - **Database:** Cloudflare D1 | ||
| - **AI:** Anthropic Claude + Workers AI (embeddings) | ||
| - **GitHub:** Octokit | ||
|
|
||
| ## Key Files | ||
|
|
||
| - `src/index.ts` - Worker entry point, webhook routing | ||
| - `src/github/handlers/` - Event handlers for issues and comments | ||
| - `src/ai/` - Claude integration and RAG retrieval | ||
| - `src/triage/` - Issue detection and comment formatting | ||
| - `scripts/embed-docs.ts` - Documentation embedding script | ||
|
|
||
| ## Testing Locally | ||
|
|
||
| ```bash | ||
| pnpm dev | ||
| # Expose via ngrok for webhook testing | ||
| ``` | ||
|
|
||
| ## Secrets Required | ||
|
|
||
| - `GITHUB_APP_ID` | ||
| - `GITHUB_PRIVATE_KEY` | ||
| - `GITHUB_WEBHOOK_SECRET` | ||
| - `ANTHROPIC_API_KEY` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # CubeBot 🧊 | ||
|
|
||
| GitHub App bot for TresJS issue triage and documentation assistance. | ||
|
|
||
| ## Features | ||
|
|
||
| - Auto-triages new issues (bug vs feature detection) | ||
| - Redirects feature requests to GitHub Discussions | ||
| - Checks for required bug report info (reproduction, system info) | ||
| - Suggests relevant documentation via RAG | ||
| - Responds to @mentions with doc-based assistance | ||
|
|
||
| ## Setup | ||
|
|
||
| ### 1. Create GitHub App | ||
|
|
||
| 1. Go to github.com/settings/apps → New GitHub App | ||
| 2. Name: `tresjs-cubebot` | ||
| 3. Permissions: | ||
| - Issues: Read & Write | ||
| - Discussions: Read & Write | ||
| 4. Subscribe to events: `issues`, `issue_comment` | ||
| 5. Generate and download private key (`.pem` file) | ||
|
|
||
| ### 2. Cloudflare Setup | ||
|
|
||
| ```bash | ||
| # Create D1 database | ||
| pnpm wrangler d1 create cubebot-docs | ||
|
|
||
| # Copy the database_id from output and update wrangler.toml | ||
|
|
||
| # Apply schema to remote D1 | ||
| cd apps/cubebot | ||
| pnpm wrangler d1 execute cubebot-docs --remote --file=schema.sql | ||
| ``` | ||
|
|
||
| ### 3. Deploy Worker | ||
|
|
||
| ```bash | ||
| cd apps/cubebot | ||
| pnpm wrangler deploy | ||
| ``` | ||
|
|
||
| ### 4. Set Secrets | ||
|
|
||
| ```bash | ||
| cd apps/cubebot | ||
|
|
||
| # App ID from GitHub App page | ||
| pnpm wrangler secret put GITHUB_APP_ID | ||
|
|
||
| # Contents of the .pem private key file | ||
| pnpm wrangler secret put GITHUB_PRIVATE_KEY | ||
|
|
||
| # Generate with: openssl rand -hex 32 | ||
| # Use same value in GitHub App webhook settings | ||
| pnpm wrangler secret put GITHUB_WEBHOOK_SECRET | ||
|
|
||
| # From console.anthropic.com | ||
| pnpm wrangler secret put ANTHROPIC_API_KEY | ||
| ``` | ||
|
|
||
| ### 5. Configure GitHub App Webhook | ||
|
|
||
| 1. Go to your GitHub App settings | ||
| 2. Set Webhook URL: `https://tresjs-cubebot.<account>.workers.dev/webhook` | ||
| 3. Set Webhook secret: same value as `GITHUB_WEBHOOK_SECRET` | ||
| 4. Save | ||
|
|
||
| ### 6. Seed Documentation (RAG) | ||
|
|
||
| ```bash | ||
| # Call the admin endpoint to fetch docs and generate embeddings | ||
| curl -X POST https://tresjs-cubebot.<account>.workers.dev/admin/seed-docs | ||
| ``` | ||
|
|
||
| This fetches `llms-full.txt` from TresJS doc sites, generates embeddings via Workers AI, and stores them in D1. | ||
|
|
||
| ### 7. Install GitHub App | ||
|
|
||
| Install the app on the TresJS organization or specific repositories. | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| cd apps/cubebot | ||
|
|
||
| # Start local dev server | ||
| pnpm wrangler dev | ||
|
|
||
| # Use ngrok to expose for webhook testing | ||
| ngrok http 8787 | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| See [design doc](../../.claude/plans/2026-01-27-cubebot-design.md) for full architecture details. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { tresLintConfig } from '@tresjs/eslint-config' | ||
|
|
||
| export default tresLintConfig({ | ||
| ignores: ['**/*.md'], | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "name": "cubebot", | ||
| "type": "module", | ||
| "version": "0.0.1", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "wrangler dev", | ||
| "deploy": "wrangler deploy", | ||
| "lint": "eslint .", | ||
| "lint:fix": "eslint . --fix", | ||
| "typecheck": "tsc --noEmit", | ||
| "embed-docs": "npx tsx scripts/embed-docs.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@anthropic-ai/sdk": "^0.78.0", | ||
| "@octokit/auth-app": "^8.2.0", | ||
| "hono": "^4.12.3", | ||
| "octokit": "^5.0.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@cloudflare/workers-types": "^4.20260226.1", | ||
| "@tresjs/eslint-config": "workspace:^", | ||
| "typescript": "catalog:typescript", | ||
| "wrangler": "^4.69.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| CREATE TABLE IF NOT EXISTS doc_chunks ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| source TEXT NOT NULL, | ||
| url TEXT NOT NULL, | ||
| title TEXT NOT NULL, | ||
| content TEXT NOT NULL, | ||
| embedding TEXT NOT NULL, | ||
| created_at TEXT DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_doc_chunks_source ON doc_chunks(source); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { execSync } from 'node:child_process' | ||
|
|
||
| const DOC_SOURCES = [ | ||
| { name: 'core', url: 'https://docs.tresjs.org/llms-full.txt' }, | ||
| { name: 'cientos', url: 'https://cientos.tresjs.org/llms-full.txt' }, | ||
| { name: 'postprocessing', url: 'https://post-processing.tresjs.org/llms-full.txt' }, | ||
| ] | ||
|
|
||
| interface DocChunk { | ||
| source: string | ||
| url: string | ||
| title: string | ||
| content: string | ||
| } | ||
|
|
||
| async function fetchDocs(source: { name: string; url: string }): Promise<DocChunk[]> { | ||
| console.log(`Fetching ${source.name} docs from ${source.url}...`) | ||
|
|
||
| try { | ||
| const response = await fetch(source.url) | ||
| if (!response.ok) { | ||
| console.warn(`Failed to fetch ${source.url}: ${response.status}`) | ||
| return [] | ||
| } | ||
|
|
||
| const text = await response.text() | ||
| return parseDocsIntoChunks(source.name, source.url, text) | ||
| } | ||
| catch (error) { | ||
| console.warn(`Error fetching ${source.url}:`, error) | ||
| return [] | ||
| } | ||
| } | ||
|
|
||
| function parseDocsIntoChunks(source: string, baseUrl: string, text: string): DocChunk[] { | ||
| const chunks: DocChunk[] = [] | ||
|
|
||
| // Split by headers (## or #) | ||
| const sections = text.split(/(?=^#{1,2}\s)/m) | ||
|
|
||
| for (const section of sections) { | ||
| if (section.trim().length < 50) continue // Skip tiny sections | ||
|
|
||
| const titleMatch = section.match(/^#{1,2}\s+(.+)$/m) | ||
| const title = titleMatch?.[1] ?? 'Untitled' | ||
|
|
||
| // Extract URL if present in the section | ||
| const urlMatch = section.match(/https?:\/\/[^\s)]+/) | ||
| const url = urlMatch?.[0] ?? baseUrl | ||
|
|
||
| chunks.push({ | ||
| source, | ||
| url, | ||
| title: title.trim(), | ||
| content: section.slice(0, 2000), // Limit chunk size | ||
| }) | ||
| } | ||
|
|
||
| return chunks | ||
| } | ||
|
|
||
| async function main() { | ||
| console.log('Starting docs embedding process...\n') | ||
|
|
||
| const allChunks: DocChunk[] = [] | ||
|
|
||
| for (const source of DOC_SOURCES) { | ||
| const chunks = await fetchDocs(source) | ||
| allChunks.push(...chunks) | ||
| console.log(` → ${chunks.length} chunks from ${source.name}`) | ||
| } | ||
|
|
||
| console.log(`\nTotal chunks: ${allChunks.length}`) | ||
|
|
||
| // Write chunks to a JSON file for manual D1 import | ||
| // In production, this would call Workers AI for embeddings | ||
| const outputPath = 'apps/cubebot/data/doc-chunks.json' | ||
|
|
||
| // Create data directory | ||
| execSync('mkdir -p apps/cubebot/data') | ||
|
|
||
| const fs = await import('node:fs') | ||
| fs.writeFileSync(outputPath, JSON.stringify(allChunks, null, 2)) | ||
|
|
||
| console.log(`\nChunks written to ${outputPath}`) | ||
| console.log('\nNext steps:') | ||
| console.log('1. Run wrangler d1 execute to create the database') | ||
| console.log('2. Use a separate script to generate embeddings via Workers AI') | ||
| console.log('3. Import the embeddings into D1') | ||
| } | ||
|
|
||
| main().catch(console.error) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.