A web application that takes a public GitHub repository URL and uses the Gemini Managed Agents API (antigravity-preview-05-2026) inside Google-hosted Linux container sandboxes to read, explore, and document the codebase. The application renders a multi-page PDF document and displays it in the web interface.
-
Sandbox Repository Mounting & Private Repositories (
sources):- Uses the
google-genaiSDK and the Managed Agents API (client.interactions.create). - Provisions a Google-hosted Linux container (
environment="remote"). - Mounts public repositories directly, or authenticates private repositories using a GitHub Personal Access Token (PAT) mapped to basic credentials inside the remote container's network allowlist transforms.
- Uses the
-
SSE Live Output and Terminal Logs:
- Streams execution progress (
stream=True) over Server-Sent Events (/api/jobs/{id}/stream). - Displays logs from bash inspection tools (
tree,ast-grep, file reading) in the browser interface.
- Streams execution progress (
-
ReportLab PDF Engine (
pdf_generator.py):- Renders the Markdown architectural report into a PDF.
- Includes cover headers, Page X of Y footers, code block boxes, and color styling.
-
Web Interface (
index.html):- Built with Tailwind CSS, Lucide Icons, and tabs:
- Live Terminal & Logs Tab: Console showing sandbox status and agent tool calls.
- Architectural Report Tab: Markdown rendering using
marked.jsandhighlight.js. - PDF Document Tab: Embedded iframe allowing PDF inspection and downloads.
- Built with Tailwind CSS, Lucide Icons, and tabs:
-
Pluggable Agent Skills (
skills/):- Stores the documentation layout structures, formatting guidelines, and syntax constraints inside a custom agent skill file (
skills/repository_analyzer/SKILL.md). - Reads the local skill file at runtime and mounts it dynamically inside the remote sandbox workspace at
.agents/skills/repository_analyzer/SKILL.mdusing the inline sources configuration. - Allows changing the output format or analysis scope by swapping or modifying the skill file.
- Stores the documentation layout structures, formatting guidelines, and syntax constraints inside a custom agent skill file (
code-analyzer/
├── app.py # FastAPI server handling jobs, SSE streaming, and Managed Agents API
├── pdf_generator.py # ReportLab PDF rendering engine with NumberedCanvas
├── index.html # Tailwind frontend interface with logs viewer and PDF embed
├── requirements.txt # Python dependencies
├── run.sh # Launcher and virtual environment check script
└── output/ # Generated reports, jobs database (jobs.json), and PDF files
export GEMINI_API_KEY="your_api_key_here"You can use the helper script or run directly:
./run.sh
# OR via Python
.venv/bin/python app.pyNavigate to http://localhost:8000 in your browser.
Enter any public GitHub URL (or click one of the quick demo presets such as https://github.com/fastapi/fastapi) and click Launch Sandbox Agent & Render PDF.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/analyze |
Initiates a new Managed Agent sandbox analysis job for a repository URL |
GET |
/api/jobs |
Lists recent jobs and their execution/PDF status |
GET |
/api/jobs/{job_id} |
Retrieves full job metadata, output markdown text, and execution logs |
GET |
/api/jobs/{job_id}/stream |
SSE endpoint emitting real-time log lines, markdown deltas, and status updates |
GET |
/api/jobs/{job_id}/pdf |
Serves the generated PDF report (?download=1 triggers file download) |
GET |
/api/jobs/{job_id}/markdown |
Serves the raw generated Markdown architecture report |
sources = [
{
"type": "repository",
"source": repo_url,
"target": "/workspace/repo",
},
{
"type": "inline",
"target": "/workspace/INSTRUCTIONS.md",
"content": instructions
}
]
if skill_content:
sources.append({
"type": "inline",
"target": ".agents/skills/repository_analyzer/SKILL.md",
"content": skill_content
})
environment_config = {
"type": "remote",
"sources": sources
}
# Encode PAT and configure network allowlist transform for private repos
if github_token and github_token.strip():
import base64
token_val = github_token.strip()
raw_credential = f"x-oauth-basic:{token_val}"
base64_token = base64.b64encode(raw_credential.encode('utf-8')).decode('utf-8')
environment_config["network"] = {
"allowlist": [
{
"domain": "github.com",
"transform": [
{
"Authorization": f"Basic {base64_token}"
}
]
},
{
"domain": "*"
}
]
}
stream = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the mounted repository in `/workspace/repo` following `/workspace/INSTRUCTIONS.md`...",
environment=environment_config,
stream=True,
)