Skip to content
MohammadAlMasalmehPublic

About

AgentPrep — practice agentic coding interviews (Next.js, Supabase, E2B, pytest grading)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LeetAgent (AgentPrep)

LeetCode-style prep for agentic coding interviews: broken repo in a timed cloud sandbox, solve it in a browser-hosted IDE (Monaco editor + file tree + terminal + built-in Claude agent chat), and pytest is the grader. No SSH, no external tools — everything runs in one page.

Stack

  • Next.js (App Router) + TypeScript + Tailwind v4
  • Supabase Cloud (Postgres + Auth + RLS) — no Docker required
  • E2B sandboxes (e2b JS SDK)

Supabase (hosted) — one-time setup

  1. Create a project at supabase.com/dashboard (or use supabase projects list / supabase projects create after CLI login).

  2. Log in and link the CLI (from this repo root):

    supabase login
    npm run db:link

    When prompted, paste your project ref (Settings → General → Reference ID).

    Non-interactive CI: set SUPABASE_ACCESS_TOKEN and run
    supabase link --project-ref <ref>.

  3. Apply the database schema (runs supabase/migrations/* on the linked project):

    npm run db:push
  4. Load the 10 curated problems — pick one:

    • SQL Editor (Dashboard → SQL): paste the contents of supabase/seed.sql and run once (idempotent upserts; safe to re-run).
    • Or after the Next app is configured, call POST /api/problems/ingest with x-admin-secret (uses the service role).
  5. GitHub OAuth (Dashboard → Authentication → Providers → GitHub):

    • Add your GitHub OAuth App’s client ID and secret.
    • Redirect URL in GitHub’s app settings must include Supabase’s callback, e.g.
      https://<project-ref>.supabase.co/auth/v1/callback (see Auth URL on the provider page).
    • Under URL configuration, set Site URL to your deployed app (e.g. https://your-app.vercel.app) and add Redirect URLs for
      http://localhost:3000/**, http://127.0.0.1:3000/**, and your production /auth/callback as needed.
  6. Next.js env — Project Settings → API: copy Project URL, anon public, and service_role into .env.local (see .env.example).

NPM scripts

Script Purpose
npm run db:link Link this folder to your Supabase project (supabase link)
npm run db:push Push migrations to the linked cloud database
npm run db:generate-seed Regenerate supabase/seed.sql from data/curated-problems.json
npm run db:types Generate lib/database.types.ts from the linked DB (optional)

App commands

  • npm run dev — local dev
  • npm run build / npm run start — production

E2B & grading

  • Set E2B_API_KEY in .env.local.
  • From the repo root run npm run e2b:template once (builds the agentprep-sandbox image: Python 3, pip, compilers, common -dev libs). Then set E2B_SANDBOX_TEMPLATE=agentprep-sandbox in .env.local.

Grading: submit applies test_patch_diff with git apply, then python3 -m pytest <test_patch> …. The diff is not applied during the session.

Agent chat

The in-browser chat is powered by the Anthropic SDK. Set ANTHROPIC_API_KEY in .env.local (the key stays server-side). This is open-source — self-host and bring your own key.

API

Method Path Purpose
POST /api/sessions/start Start sandbox session
POST /api/sessions/submit Grade and tear down sandbox
GET /api/sessions/[id]/status Session status
POST /api/sandbox/files/tree List files in the session sandbox
POST /api/sandbox/files/read Read a file from the sandbox
POST /api/sandbox/files/write Write a file in the sandbox
POST /api/sandbox/exec Stream stdout/stderr from a command in the sandbox
POST /api/agent/chat Stream an Anthropic tool-use agent wired to the sandbox
POST /api/problems/ingest Upsert curated problems (admin secret)

Optional: supabase/config.toml

That file is mainly for the Supabase CLI (migrations path, optional local tools). Hosted Auth is configured in the Supabase Dashboard, not by committing secrets into config.toml.

About

AgentPrep — practice agentic coding interviews (Next.js, Supabase, E2B, pytest grading)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages