Clone‑X lets you enter any website URL and locally clone its main page and assets. An AI agent orchestrates the flow (check legal hints → analyze site → clone → validate), and you can watch its live thinking/steps via a streaming UI. Finished clones are previewable in‑app and downloadable as a zip.
- Live AI thinking stream: Real‑time START/THINK/TOOL/OBSERVE/OUTPUT events rendered in the
AIThinkingoverlay. - One‑click clone: Enter a URL, watch progress, and get a local copy with
index.htmlandassets/. - Preview + download: Preview via
/preview/[site]and download a zip of the cloned folder. - Project list: Persistent list stored in
clones/projects.jsonwith status updates.
- Next.js 15 (App Router), React 19, TypeScript
- Tailwind CSS v4, Radix UI primitives, custom UI components
- OpenAI (
gpt-4.1-mini) for the agent driver - Puppeteer + Cheerio for fetching, parsing, and rewriting assets
- Node.js 18+ (recommended 20+)
- An OpenAI API key
- Install dependencies
pnpm i
# or npm i / yarn- Create
.env.local
OPENAI_API_KEY=your_key_here
# Optional: If you need to force a local Chrome/Chromium
# PUPPETEER_EXECUTABLE_PATH="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"- Run the dev server
pnpm dev
# open http://localhost:3000- In the UI
- Enter a URL like
https://example.comand click “Clone Website”. - Watch the AI stream its steps. When complete, use “View” to preview or “Download” to get a zip.
- The agent driver (
src/agent/driver.ts) prompts the model to follow a strict sequence and to call tools:checkLegal(url)→ scans meta/links for advisory compliance hintsanalyzeWebsite(url)→ gathers basic page stats with PuppeteercloneWebsite(url, outputDir)→ fetches the page, captures assets, rewrites references, saves toclones/{hostname}validateClone(originalUrl, clonePath)→ checks for missing local assets
- The streaming endpoint (
app/api/clone/stream/route.ts) emits SSE events consumed bycomponents/ai-thinking.tsx. - Preview endpoint (
app/api/preview/[site]/route.ts) serves rewrittenindex.htmlresolving./assets/...through the static file server. - Static file server (
app/api/static/[...path]/route.ts) exposes files underclones/and is also mapped via a rewrite innext.config.mjs.
Cloned output structure:
clones/
projects.json # list + statuses
{hostname}/
index.html
assets/
... # css, js, images, fonts captured during clone
-
POST
/api/clone- Body:
{ "url": "https://example.com" } - Returns:
{ success: boolean, message?: string, error?: string }
- Body:
-
POST
/api/clone/stream(SSE)- Body:
{ "url": "https://example.com" } - Response:
text/event-streamwithdata: {...}\n\nevents. Event shape:{ "type": "start" | "thinking" | "complete" | "error", "step": "🔄 Iteration" | "🧠 THINK" | "🛠️ TOOL" | "📤 OBSERVE" | "✅ OUTPUT" | "...", "content": "string", "message": "string", "timestamp": "ISO-8601", "success": true }
- Body:
-
GET
/api/projects- Returns the deduplicated project list from
clones/projects.json.
- Returns the deduplicated project list from
-
POST
/api/projects- Upsert a project entry. Body minimally includes
{ name, url, status }.
- Upsert a project entry. Body minimally includes
-
DELETE
/api/projects- Body:
{ id?: string, name?: string }to remove a project from the list.
- Body:
-
GET
/api/preview/{site}- Serves the site’s
index.htmlafter rewriting./assets/→/api/static/{site}/assets/.
- Serves the site’s
-
GET
/api/static/{...path}- Serves files under
clones/with proper content types.
- Serves files under
-
POST
/api/download- Body:
{ "site": "{hostname}" } - Returns a zip stream of
clones/{hostname}.
- Body:
-
POST
/api/delete-folder- Body:
{ "folderName": "{hostname}" } - Recursively removes the folder under
clones/.
- Body:
- The cloner targets the landing page and referenced assets captured during a single page load; dynamic navigation/app logic is not reconstructed.
- Paths are rewritten to local
./assets/...and served via/api/static/...during preview. - The legal check is advisory only for learning purposes; you are responsible for compliance when cloning third‑party content.
- Puppeteer fails to launch Chromium
- Ensure Node 18+, reinstall deps (
pnpm i), or setPUPPETEER_EXECUTABLE_PATHto a local Chrome.
- Ensure Node 18+, reinstall deps (
- Missing
OPENAI_API_KEY- Create
.env.localwith your API key and restart the dev server.
- Create
- Nothing shows in Preview
- Check that
clones/{hostname}/index.htmlexists; see server logs for missing assets.
- Check that
pnpm dev # start dev server
pnpm build # build
pnpm start # run production build
pnpm lint # lint (builds ignore lint/type errors per next.config.mjs)app/page.tsx— dashboard UI (input, projects, actions, AI overlay)components/ai-thinking.tsx— SSE client that renders AI stepsapp/api/clone/stream/route.ts— SSE clone runnersrc/agent/driver.ts— agent driver that enforces tool callingsrc/agent/tools/*— cloning tools (Puppeteer/Cheerio)src/cloner/core.ts— asset saving and path rewriting helpersapp/api/preview/[site]/route.ts— preview rewritten HTMLapp/api/static/[...path]/route.ts— serve files fromclones/
For educational use only. Verify you have rights to copy any site you clone.


