This guide explains how to set up and use the on-demand bundle generation feature.
The on-demand bundle generation feature allows users to:
- Enter any public GitHub repository URL on your website
- Automatically trigger indexing and bundle creation via GitHub Actions
- Download the generated
.cgcbundle file
User (Website) → API Endpoint → GitHub Actions → Bundle Created → GitHub Release
You need a GitHub Personal Access Token (PAT) with the following permissions:
Required Scopes:
repo(Full control of private repositories)workflow(Update GitHub Action workflows)
Steps to create:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Select scopes:
repoandworkflow - Generate and copy the token
Create /website/.env:
GITHUB_TOKEN="ghp_your_token_here"
GITHUB_REPOSITORY="CodeGraphContext/CodeGraphContext"- Go to your Vercel project settings
- Navigate to "Environment Variables"
- Add the following variables:
GITHUB_TOKEN= your GitHub PATGITHUB_REPOSITORY=CodeGraphContext/CodeGraphContext
- Go to your repository on GitHub
- Click "Actions" tab
- Select "Generate Bundle On-Demand" workflow
- Click "Run workflow"
- Enter a repository URL (e.g.,
https://github.com/psf/requests) - Click "Run workflow"
- Wait 5-10 minutes
- Check the "on-demand-bundles" release for the generated bundle
# Start the website locally
cd website
npm run dev
# In another terminal, trigger bundle generation
curl -X POST http://localhost:5173/api/trigger-bundle \
-H "Content-Type: application/json" \
-d '{"repoUrl": "https://github.com/psf/requests"}'cd website
vercel --prodMake sure environment variables are set in Vercel dashboard before deploying.
- Visit your website
- Scroll to "Generate Custom Bundle" section
- Enter a GitHub repository URL
- Click "Generate Bundle"
- Wait for completion (5-10 minutes)
- Download the
.cgcfile - Run:
cgc load bundle.cgc
POST /api/trigger-bundle
Content-Type: application/json
{
"repoUrl": "https://github.com/owner/repo"
}Response (Success):
{
"status": "triggered",
"message": "Bundle generation started",
"repository": "owner/repo",
"repo_size_mb": "15.23",
"estimated_time": "5-10 minutes",
"run_id": "12345",
"run_url": "https://github.com/.../actions/runs/12345",
"status_url": "/api/bundle-status?repo=owner/repo"
}Response (Already Exists):
{
"status": "exists",
"message": "Bundle already exists",
"bundle": {
"repo": "owner/repo",
"bundle_name": "repo-v1.0.0-abc123.cgc",
"download_url": "https://github.com/.../releases/download/..."
}
}GET /api/bundle-status?run_id=12345
# or
GET /api/bundle-status?repo=owner/repoResponse:
{
"status": "completed",
"conclusion": "success",
"progress": 100,
"run_url": "https://github.com/.../actions/runs/12345"
}Cause: Invalid GitHub token or insufficient permissions
Solution:
- Verify
GITHUB_TOKENis set correctly - Ensure token has
repoandworkflowscopes - Check token hasn't expired
Cause: Repository exceeds 1GB size limit
Solution:
- This is a safety limit to prevent long-running workflows
- Consider increasing the limit in
/website/api/trigger-bundle.tsif needed - Or add the repository to the weekly pre-indexed list instead
Cause: Indexing error or unsupported language
Solution:
- Check the GitHub Actions workflow logs
- Verify the repository has supported languages (Python, JavaScript, etc.)
- Check if the repository has unusual structure
Cause: GitHub Actions quota exceeded or workflow disabled
Solution:
- Check GitHub Actions usage in repository settings
- Ensure workflow file is in
mainbranch - Verify workflow is enabled in Actions settings
- Repository Size: Max 1GB (configurable)
- Processing Time: 5-30 minutes depending on size
- GitHub Actions Quota: 2000 minutes/month (free tier)
- Public Repositories Only: Private repos require user's own token
- Bundle Retention: 30 days (configurable)
- Email notifications when bundle is ready
- Priority queue for premium users
- Support for private repositories
- Batch generation (multiple repos at once)
- Automatic cleanup of old bundles
- Bundle analytics and popularity tracking
- Never commit
.envfile with real tokens - Use Vercel environment variables for production
- GitHub token should have minimal required permissions
- Consider implementing rate limiting to prevent abuse
- Monitor GitHub Actions usage to avoid quota exhaustion
If you encounter issues:
- Check the GitHub Actions workflow logs
- Review the API response error messages
- Open an issue on GitHub with details
Last Updated: 2026-01-21