deployai 0.1.0-beta.20 → 0.1.0-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/index.js +1048 -88
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21390,12 +21390,12 @@ var ARCH_NODES = [
21390
21390
  // Outside
21391
21391
  { id: "browser", kind: "actor", zone: "outside", label: "\u05D3\u05E4\u05D3\u05E4\u05DF", labelEn: "Browser", summary: "\u05DC\u05E7\u05D5\u05D7\u05D5\u05EA \u05D5\u05D0\u05D3\u05DE\u05D9\u05E0\u05D9\u05DD \u05E4\u05D5\u05EA\u05D7\u05D9\u05DD \u05D0\u05EA \u05D4\u05D0\u05EA\u05E8, \u05DC\u05D5\u05D7 \u05D4\u05D1\u05E7\u05E8\u05D4 \u05D5\u05D4\u05D0\u05D3\u05DE\u05D9\u05DF.", summaryEn: "Customers and admins open the site, the dashboard and the admin." },
21392
21392
  { id: "cli", kind: "actor", zone: "outside", label: "deployai CLI", summary: "\u05D4\u05E1\u05D5\u05DB\u05DF \u05D0\u05D5 \u05D4\u05DC\u05E7\u05D5\u05D7 \u05DE\u05E8\u05D9\u05E6\u05D9\u05DD check \u05D5\u05BEdeploy, \u05D5\u05D4\u05EA\u05D7\u05D1\u05E8\u05D5\u05EA \u05D1\u05E7\u05D5\u05D3 \u05DE\u05DB\u05E9\u05D9\u05E8.", summaryEn: "The agent or the customer runs check and deploy, and logs in with a device code.", code: ["packages/cli"], docs: ["docs/07-cli.md"] },
21393
- { id: "board-watcher", kind: "actor", zone: "outside", label: "Board watcher", summary: "\u05E8\u05E5 \u05D0\u05E6\u05DC \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD (pnpm board:watch): \u05DC\u05D5\u05E7\u05D7 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05DE\u05DC\u05D5\u05D7 \u05D4\u05E2\u05D1\u05D5\u05D3\u05D4 (\u05E8\u05E7 \u05DB\u05E9\u05D4\u05DE\u05EA\u05D2 \u05E9\u05DC\u05D5 \u05D1\u05D4\u05D2\u05D3\u05E8\u05D5\u05EA \u05E4\u05D5\u05E2\u05DC), \u05DE\u05E8\u05D9\u05E5 Claude Code \u05DC\u05E7\u05E8\u05D9\u05D0\u05D4 \u05D1\u05DC\u05D1\u05D3 \u05D5\u05DE\u05D7\u05D6\u05D9\u05E8 \u05EA\u05D5\u05DB\u05E0\u05D9\u05EA. \u05DB\u05E8\u05D8\u05D9\u05E1 \u05E2\u05DD \u05D1\u05E0\u05D9\u05D9\u05D4 \u05D0\u05D5\u05D8\u05D5\u05DE\u05D8\u05D9\u05EA \u05E9\u05D0\u05D5\u05E9\u05E8 \u05E0\u05D1\u05E0\u05D4 \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05EA \u05D4\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8, \u05D0\u05D7\u05D3 \u05D1\u05DB\u05DC \u05E4\u05E2\u05DD. \u05D4\u05D5\u05D0 \u05D2\u05DD \u05DB\u05D5\u05EA\u05D1 \u05D2\u05E8\u05E1\u05D0\u05D5\u05EA \u05D7\u05D3\u05E9\u05D5\u05EA \u05DC\u05E1\u05E4\u05E8\u05D9\u05D9\u05EA \u05D4\u05E4\u05E8\u05D5\u05DE\u05E4\u05D8\u05D9\u05DD \u05DC\u05E4\u05D9 \u05D4\u05E2\u05E8\u05D5\u05EA \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD, \u05DC\u05D1\u05D3\u05D9\u05E7\u05D4 \u05D5\u05E4\u05E8\u05E1\u05D5\u05DD.", summaryEn: "Runs on the owner computer (pnpm board:watch): claims a work board ticket (only while its settings switch is on), runs Claude Code read only and posts a plan back. An approved auto build ticket is built in the project folder, one at a time. It also writes new versions of prompt library prompts from the owner notes, for review and publishing.", code: ["scripts/board-watch.ts", "scripts/prompts-sync.ts"], env: ["BOARD_RUNNER_TOKEN", "BOARD_URL"], decisions: ["D-110", "D-127", "D-182", "D-250"] },
21393
+ { id: "board-watcher", kind: "actor", zone: "outside", label: "Board watcher", summary: "\u05E8\u05E5 \u05D0\u05E6\u05DC \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD (pnpm board:watch): \u05DC\u05D5\u05E7\u05D7 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05DE\u05DC\u05D5\u05D7 \u05D4\u05E2\u05D1\u05D5\u05D3\u05D4 (\u05E8\u05E7 \u05DB\u05E9\u05D4\u05DE\u05EA\u05D2 \u05E9\u05DC\u05D5 \u05D1\u05D4\u05D2\u05D3\u05E8\u05D5\u05EA \u05E4\u05D5\u05E2\u05DC, \u05D5\u05E8\u05E7 \u05D0\u05D7\u05E8\u05D9 \u05E9\u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05D5\u05E9\u05E8 \u05D5\u05E0\u05E9\u05DC\u05D7 \u05D0\u05DC\u05D9\u05D5), \u05DE\u05E8\u05D9\u05E5 Claude Code \u05DC\u05E7\u05E8\u05D9\u05D0\u05D4 \u05D1\u05DC\u05D1\u05D3 \u05D5\u05DE\u05D7\u05D6\u05D9\u05E8 \u05EA\u05D5\u05DB\u05E0\u05D9\u05EA. \u05DB\u05E8\u05D8\u05D9\u05E1 \u05E2\u05DD \u05D1\u05E0\u05D9\u05D9\u05D4 \u05D0\u05D5\u05D8\u05D5\u05DE\u05D8\u05D9\u05EA \u05E9\u05D0\u05D5\u05E9\u05E8 \u05E0\u05D1\u05E0\u05D4 \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05EA \u05D4\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8, \u05D0\u05D7\u05D3 \u05D1\u05DB\u05DC \u05E4\u05E2\u05DD. \u05D4\u05D5\u05D0 \u05D2\u05DD \u05DB\u05D5\u05EA\u05D1 \u05D2\u05E8\u05E1\u05D0\u05D5\u05EA \u05D7\u05D3\u05E9\u05D5\u05EA \u05DC\u05E1\u05E4\u05E8\u05D9\u05D9\u05EA \u05D4\u05E4\u05E8\u05D5\u05DE\u05E4\u05D8\u05D9\u05DD \u05DC\u05E4\u05D9 \u05D4\u05E2\u05E8\u05D5\u05EA \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD, \u05DC\u05D1\u05D3\u05D9\u05E7\u05D4 \u05D5\u05E4\u05E8\u05E1\u05D5\u05DD.", summaryEn: "Runs on the owner computer (pnpm board:watch): claims a work board ticket (only while its settings switch is on), runs Claude Code read only and posts a plan back. An approved auto build ticket is built in the project folder, one at a time. It also writes new versions of prompt library prompts from the owner notes, for review and publishing.", code: ["scripts/board-watch.ts", "scripts/prompts-sync.ts"], env: ["BOARD_RUNNER_TOKEN", "BOARD_URL"], decisions: ["D-110", "D-127", "D-182", "D-250"] },
21394
21394
  { id: "visitor", kind: "actor", zone: "outside", label: "\u05DE\u05D1\u05E7\u05E8 \u05D1\u05D0\u05EA\u05E8", labelEn: "Site visitor", summary: "\u05DE\u05D1\u05E7\u05E8 \u05D1\u05D0\u05EA\u05E8 \u05E9\u05DC \u05DC\u05E7\u05D5\u05D7 \u05D1\u05DB\u05EA\u05D5\u05D1\u05EA <slug>.<\u05D3\u05D5\u05DE\u05D9\u05D9\u05DF \u05D0\u05EA\u05E8\u05D9\u05DD> (\u05DB\u05DE\u05D5 deploy-net.com \u05D0\u05D5 freesite.click) \u05D0\u05D5 \u05D1\u05D3\u05D5\u05DE\u05D9\u05D9\u05DF \u05DE\u05E9\u05DC\u05D5.", summaryEn: "A visitor on a customer site at <slug>.<a sites domain> (like deploy-net.com or freesite.click) or on their own domain." },
21395
21395
  // Platform
21396
21396
  { id: "web", kind: "app", zone: "platform", label: "Web app (Next.js)", summary: "\u05D0\u05EA\u05E8 \u05D4\u05E9\u05D9\u05D5\u05D5\u05E7, \u05DC\u05D5\u05D7 \u05D4\u05D1\u05E7\u05E8\u05D4, \u05D4\u05D0\u05D3\u05DE\u05D9\u05DF \u05D5\u05D4\u05BEAPI \u05E9\u05DC \u05D4\u05BECLI. \u05DE\u05DB\u05E0\u05D9\u05E1 \u05E2\u05D1\u05D5\u05D3\u05D5\u05EA \u05DC\u05EA\u05D5\u05E8.", summaryEn: "The marketing site, the dashboard, the admin and the CLI API. Puts jobs in the queue.", code: ["apps/web/src/app", "apps/web/src/server"], env: ["DEPLOYAI_SPACE", "BETTER_AUTH_SECRET", "NEXT_PUBLIC_SUPPORT_WHATSAPP", "DEV_SUPERADMIN_PASSWORD", "OPENAI_APPS_CHALLENGE"], portability: "Our app (site, dashboard, API, builds)", docs: ["docs/04-architecture.md"], decisions: ["D-020", "D-057", "D-104", "D-149", "D-238", "D-293"] },
21397
21397
  { id: "queue", kind: "db", zone: "platform", label: "pg-boss queue", summary: "\u05DB\u05DC \u05DE\u05D4 \u05E9\u05D0\u05D9\u05D8\u05D9 \u05D0\u05D5 \u05E0\u05D5\u05D2\u05E2 \u05D1\u05BECloudflare \u05E8\u05E5 \u05DB\u05E2\u05D1\u05D5\u05D3\u05D4 \u05D1\u05EA\u05D5\u05E8.", summaryEn: "Everything slow or that touches Cloudflare runs as a job in the queue.", code: ["apps/web/src/server/queue.ts"], portability: "Job queue", decisions: ["D-058"] },
21398
- { id: "worker", kind: "app", zone: "platform", label: "Job worker", summary: "\u05EA\u05D4\u05DC\u05D9\u05DA \u05E0\u05E4\u05E8\u05D3 \u05E9\u05DE\u05E8\u05D9\u05E5 \u05D0\u05EA \u05D4\u05E2\u05D1\u05D5\u05D3\u05D5\u05EA \u05DE\u05D4\u05EA\u05D5\u05E8: \u05D1\u05E0\u05D9\u05D9\u05D4, \u05D4\u05E2\u05DC\u05D0\u05D4, \u05E0\u05D9\u05EA\u05D5\u05D1, \u05D1\u05D9\u05E7\u05D5\u05E8\u05D9\u05DD, \u05E2\u05DC\u05D5\u05D9\u05D5\u05EA \u05D5\u05DE\u05D9\u05D9\u05DC\u05D9\u05DD \u05DC\u05DE\u05E9\u05E4\u05DA (pnpm worker, \u05D0\u05D5 pnpm worker:public \u05DE\u05D0\u05D7\u05D5\u05E8\u05D9 \u05D4\u05BEtunnel).", summaryEn: "A separate process that runs the queued jobs: build, upload, routing, visits, costs and lifecycle emails (pnpm worker, or pnpm worker:public behind the tunnel).", code: ["apps/web/src/server/worker.ts", "apps/web/src/server/jobs.ts", "apps/web/src/server/site-data.ts", "apps/web/src/server/lifecycle", "apps/web/src/server/host-report.ts"], env: ["BUILD_SLOTS", "LIFECYCLE_NOW", "A11Y_RENDER", "DOCKER_HOST", "HOST_REPORT_PATH"], decisions: ["D-058", "D-148", "D-180", "D-340"] },
21398
+ { id: "worker", kind: "app", zone: "platform", label: "Job worker", summary: "\u05EA\u05D4\u05DC\u05D9\u05DA \u05E0\u05E4\u05E8\u05D3 \u05E9\u05DE\u05E8\u05D9\u05E5 \u05D0\u05EA \u05D4\u05E2\u05D1\u05D5\u05D3\u05D5\u05EA \u05DE\u05D4\u05EA\u05D5\u05E8: \u05D1\u05E0\u05D9\u05D9\u05D4, \u05D4\u05E2\u05DC\u05D0\u05D4, \u05E0\u05D9\u05EA\u05D5\u05D1, \u05D1\u05D9\u05E7\u05D5\u05E8\u05D9\u05DD, \u05E2\u05DC\u05D5\u05D9\u05D5\u05EA \u05D5\u05DE\u05D9\u05D9\u05DC\u05D9\u05DD \u05DC\u05DE\u05E9\u05E4\u05DA (pnpm worker, \u05D0\u05D5 pnpm worker:public \u05DE\u05D0\u05D7\u05D5\u05E8\u05D9 \u05D4\u05BEtunnel).", summaryEn: "A separate process that runs the queued jobs: build, upload, routing, visits, costs and lifecycle emails (pnpm worker, or pnpm worker:public behind the tunnel).", code: ["apps/web/src/server/worker.ts", "apps/web/src/server/jobs.ts", "apps/web/src/server/site-data.ts", "apps/web/src/server/lifecycle", "apps/web/src/server/host-report.ts"], env: ["BUILD_SLOTS", "LIFECYCLE_NOW", "A11Y_RENDER", "DOCKER_HOST", "HOST_REPORT_PATH", "APP_SHOTS_SITES"], decisions: ["D-058", "D-148", "D-180", "D-340"] },
21399
21399
  { id: "build", kind: "app", zone: "platform", label: "Build service (Docker)", summary: "\u05E7\u05D5\u05E0\u05D8\u05D9\u05D9\u05E0\u05E8 \u05D7\u05D3\u05E9 \u05DC\u05DB\u05DC \u05E9\u05DC\u05D1, \u05D1\u05DC\u05D9 \u05E1\u05D5\u05D3\u05D5\u05EA. \u05D1\u05D5\u05E0\u05D4 \u05D0\u05EA \u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC \u05D4\u05DC\u05E7\u05D5\u05D7 \u05DC\u05E7\u05D5\u05D1\u05E5 Worker.", summaryEn: "A fresh container for every step, with no secrets. Builds the customer's code into a Worker file.", code: ["apps/web/src/server/build.ts"], env: ["BUILD_MODE"] },
21400
21400
  { id: "postgres", kind: "db", zone: "platform", label: "Postgres", summary: "\u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E9\u05DC\u05E0\u05D5: \u05DE\u05E9\u05EA\u05DE\u05E9\u05D9\u05DD, \u05D0\u05EA\u05E8\u05D9\u05DD, \u05D2\u05E8\u05E1\u05D0\u05D5\u05EA, \u05EA\u05E9\u05DC\u05D5\u05DE\u05D9\u05DD, \u05D1\u05D9\u05E7\u05D5\u05E8\u05D9\u05DD \u05D5\u05D9\u05D5\u05DE\u05DF. \u05D1\u05D9\u05D9\u05E6\u05D5\u05E8 \u05D2\u05D9\u05D1\u05D5\u05D9 pg_dump \u05DC\u05D9\u05DC\u05D9 \u05DC\u05D3\u05DC\u05D9 R2 \u05E0\u05E4\u05E8\u05D3 (14 \u05D9\u05D5\u05DE\u05D9\u05D9\u05DD, 4 \u05E9\u05D1\u05D5\u05E2\u05D9\u05D9\u05DD), \u05DE\u05D5\u05E6\u05E4\u05DF \u05D1\u05BEage, \u05D5\u05DE\u05D2\u05D1\u05D9\u05DD \u05D2\u05DD \u05D9\u05D3\u05E0\u05D9\u05EA \u05DE\u05D0\u05D3\u05DE\u05D9\u05DF, \u05E9\u05E8\u05EA, \u05D2\u05D9\u05D1\u05D5\u05D9\u05D9\u05DD.", summaryEn: "Our database: users, sites, versions, payments, visits and the audit log. In production a nightly pg_dump goes to its own R2 bucket (14 daily, 4 weekly), encrypted with age, plus manual copies from Admin, Server, Backups.", code: ["apps/web/src/server/db/schema.ts", "scripts/backup-db.sh", "apps/web/src/server/backups.ts"], env: ["DATABASE_URL", "BACKUP_S3_ACCESS_KEY_ID", "BACKUP_S3_SECRET_ACCESS_KEY", "BACKUP_AGE_RECIPIENT"], portability: "Our database", docs: ["docs/04-architecture.md", "docs/22-go-live.md", "docs/23-server.md"], decisions: ["D-336", "D-340"] },
21401
21401
  { id: "files", kind: "storage", zone: "platform", label: "Version files", summary: "\u05D0\u05E8\u05DB\u05D9\u05D5\u05E0\u05D9 \u05DE\u05E7\u05D5\u05E8 \u05D5\u05EA\u05D5\u05E6\u05E8\u05D9 \u05D1\u05E0\u05D9\u05D9\u05D4 \u05E9\u05DC \u05DB\u05DC \u05D2\u05E8\u05E1\u05D4, \u05D3\u05E8\u05DA storage.ts \u05D1\u05DC\u05D1\u05D3. \u05D3\u05DC\u05D9 R2 \u05DC\u05DB\u05DC \u05E1\u05D1\u05D9\u05D1\u05D4, \u05D5\u05E0\u05D9\u05E7\u05D5\u05D9 \u05DC\u05D9\u05DC\u05D9 \u05E9\u05DC \u05E7\u05D1\u05E6\u05D9\u05DD \u05E9\u05D0\u05E3 \u05D2\u05E8\u05E1\u05D4 \u05DC\u05D0 \u05DE\u05E9\u05EA\u05DE\u05E9\u05EA \u05D1\u05D4\u05DD. \u05D1\u05D9\u05D9\u05E6\u05D5\u05E8 \u05E9\u05D9\u05E7\u05D5\u05E3 \u05DC\u05D9\u05DC\u05D9 \u05DC\u05D3\u05DC\u05D9 \u05D4\u05D2\u05D9\u05D1\u05D5\u05D9\u05D9\u05DD, \u05EA\u05D7\u05EA files/ (D-473).", summaryEn: "Source archives and build output of every version, through storage.ts only. One R2 bucket per place, and a nightly sweep of files no version uses. In prod a nightly mirror into the backups bucket, under files/ (D-473).", code: ["apps/web/src/server/storage.ts", "apps/web/src/server/storage-sweep.ts", "scripts/mirror-files.sh"], env: ["STORAGE_DIR", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY"], portability: "Version files (uploads and build output)", docs: ["docs/17-portability.md"], decisions: ["D-095", "D-096", "D-316", "D-473"] },
@@ -21665,6 +21665,29 @@ function parseRobots(text) {
21665
21665
  return { groups, sitemaps };
21666
21666
  }
21667
21667
 
21668
+ // ../shared/src/rtl-audit.ts
21669
+ function stylesheetLinks(html, pageUrl, max = 4) {
21670
+ let host = "";
21671
+ try {
21672
+ host = new URL(pageUrl).host.replace(/^www\./, "");
21673
+ } catch {
21674
+ return [];
21675
+ }
21676
+ const own2 = [];
21677
+ const other = [];
21678
+ for (const t of tags(html, "link")) {
21679
+ if (!/(^|\s)stylesheet(\s|$)/i.test(t.attrs.rel ?? "") || !t.attrs.href) continue;
21680
+ try {
21681
+ const u = new URL(decode3(t.attrs.href), pageUrl);
21682
+ if (!/^https?:$/.test(u.protocol) || /(^|\.)fonts\.googleapis\.com$/i.test(u.hostname)) continue;
21683
+ const list = u.host.replace(/^www\./, "") === host ? own2 : other;
21684
+ if (!list.includes(u.toString())) list.push(u.toString());
21685
+ } catch {
21686
+ }
21687
+ }
21688
+ return [...own2, ...other].slice(0, max);
21689
+ }
21690
+
21668
21691
  // ../shared/src/plan-copy.ts
21669
21692
  var PLAN_FEATURES = [
21670
21693
  { key: "sites", limit: "maxSites" },
@@ -21695,6 +21718,7 @@ var CHECK = { cmd: "npx deployai@latest check", say: "Fix every blocker it lists
21695
21718
  var DEPLOY_ASK_RULE = 'Never deploy on your own, and never after each small edit: every deploy is a full build. Deploy only when what the owner asked for is done. Then say in short what changed and ask: "Put it live, see a preview first, or not yet?" Put it live: deploy with --live. Preview first: deploy without it and send the owner the preview address. Not yet: keep working, and the next change goes up in the same deploy. If the owner said to always put changes live, deploy with --live without asking. Database changes still get their own yes.';
21696
21719
  var ASK = { say: DEPLOY_ASK_RULE };
21697
21720
  var GUEST_ASK = { say: 'Deploy only when what the owner asked for is done. Say in short what you made and ask: "Put it up now, or not yet?" On Not yet, keep working and ask again when the next request is done.' };
21721
+ var FAVICON = { cmd: "npx deployai@latest brand favicon", say: "Gives the site an icon if it has none, made from the site itself: the old site's icon, else its logo, else the first letter of its name in its own color. Add the head lines it prints to every page. It changes nothing when the site has an icon." };
21698
21722
  var LOGIN = { cmd: "npx deployai@latest login", say: "The owner approves it in the browser window it opens." };
21699
21723
  var PROMOTE = { cmd: "npx deployai@latest promote v<N>", say: "Only when deploy ran without --live, and only after the owner approves the preview. N is the version number deploy printed. Then give the owner the live address." };
21700
21724
  var DEPLOY_SAY = "Add --live only if the owner chose to put it live right away. It waits for the build: with --live it ends with the live address, else with the preview address to send the owner. When it prints database changes, a yes to going live does not cover them (D-541): show the owner the changes and ask the question it prints, and only after a yes run the promote --approve-sql command it printed; changes it says remove data only the owner approves, never you. Write the -m message in a few words in the language of the owner, about what they see changed.";
@@ -21703,6 +21727,8 @@ var MIGRATE_STEPS = [
21703
21727
  { cmd: "npx deployai@latest blocks inbox", say: "Only if the old site has a contact or quote form: the form with its own messages page for the owner." },
21704
21728
  { cmd: "npx deployai@latest blocks blog", say: "Only if the old site has posts, news or articles: the blog, with the posts as Markdown files." },
21705
21729
  { cmd: "npx deployai@latest migrate media", say: "Downloads the old site's images and files into .deployai/migration/media; run it again if it stops, it goes on where it stopped. Move the files the new pages use into the site." },
21730
+ FAVICON,
21731
+ { cmd: "npx deployai@latest brand images <the old site address> <one address of each kind of page>", say: "Measures every image against where it shows and changes nothing. Add each weak one to .deployai/migration/plan.md as Needs me, with what it shows. A move keeps the images as they are: only the owner chooses to replace one, and a photo of a real person, product or place is never replaced with a made up one." },
21706
21732
  { ...CHECK },
21707
21733
  LOGIN,
21708
21734
  { cmd: 'npx deployai@latest link --create "<the site name>"', say: "Makes the site in the owner's account and links this folder. The add-ons come with it for free while the offer lasts." },
@@ -21716,11 +21742,11 @@ var MIGRATE_STEPS = [
21716
21742
  var managedStatus = (stage, note, say) => ({ cmd: `npx deployai@latest migrate status ${stage} "${note}"`, say });
21717
21743
  var MANAGED_STEPS = [
21718
21744
  managedStatus("building", "<what is done>", "First, once the plan in .deployai/migration/plan.md is agreed: the request shows the build started."),
21719
- ...MIGRATE_STEPS.slice(0, 9),
21745
+ ...MIGRATE_STEPS.slice(0, 11),
21720
21746
  managedStatus("preview_ready", "<preview address>", "The owner gets an email with the preview address."),
21721
- ...MIGRATE_STEPS.slice(9, 11),
21747
+ ...MIGRATE_STEPS.slice(11, 13),
21722
21748
  managedStatus("live", "<live address>", "Only after it is live. Then the team transfers the site to the owner."),
21723
- ...MIGRATE_STEPS.slice(11)
21749
+ ...MIGRATE_STEPS.slice(13)
21724
21750
  ];
21725
21751
  var PULL = { cmd: "npx deployai@latest pull", say: "This folder was empty, so it downloads the code of the live site first. Work on that code." };
21726
21752
  function startSteps(kind, opts = {}) {
@@ -21729,13 +21755,14 @@ function startSteps(kind, opts = {}) {
21729
21755
  function stepsOf(kind, opts) {
21730
21756
  switch (kind) {
21731
21757
  case "new":
21732
- return [...opts.starter ? [BUILD] : [], CHECK, ASK, LOGIN, { cmd: 'npx deployai@latest deploy -m "first version"', say: DEPLOY_SAY }, PROMOTE];
21758
+ return [...opts.starter ? [BUILD] : [], FAVICON, CHECK, ASK, LOGIN, { cmd: 'npx deployai@latest deploy -m "first version"', say: DEPLOY_SAY }, PROMOTE];
21733
21759
  case "update": {
21734
21760
  const deploy = { cmd: 'npx deployai@latest deploy -m "<what changed, in a few words>"', say: DEPLOY_SAY };
21735
21761
  return opts.emptyFolder ? [LOGIN, PULL, CHECK, ASK, deploy, PROMOTE] : [CHECK, ASK, LOGIN, deploy, PROMOTE];
21736
21762
  }
21737
21763
  case "move":
21738
21764
  return [
21765
+ FAVICON,
21739
21766
  CHECK,
21740
21767
  ASK,
21741
21768
  LOGIN,
@@ -21748,6 +21775,7 @@ function stepsOf(kind, opts) {
21748
21775
  case "guest":
21749
21776
  return [
21750
21777
  ...opts.starter ? [BUILD] : [],
21778
+ FAVICON,
21751
21779
  { ...CHECK, say: "Fix every blocker it lists, then run it again until it shows none. If the site needs environment variables, secrets, file storage or sending email, never stop building for it: tell the owner once, in one plain line, that putting those parts live needs a free account (one link, about a minute), keep building what they asked, and ask about the account only at the deploy step." },
21752
21780
  GUEST_ASK,
21753
21781
  { cmd: "npx deployai@latest deploy --guest", say: "It prints the address, the claim link and any owner keys." },
@@ -21776,6 +21804,7 @@ var CLI_MAP_NODES = [
21776
21804
  n("cmd-start", "cli", "start <id>", "\u05DE\u05DB\u05D9\u05DF \u05D0\u05EA \u05D4\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05DC\u05E4\u05D9 \u05DB\u05DC \u05D4\u05D1\u05D7\u05D9\u05E8\u05D5\u05EA: \u05EA\u05D9\u05E7\u05D9\u05D9\u05D4, \u05D3\u05D5\u05D2\u05DE\u05D4 \u05D5\u05D4\u05EA\u05E7\u05E0\u05D4, \u05E7\u05D5\u05D1\u05E5 \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D5\u05D7\u05D9\u05D1\u05D5\u05E8 \u05DC\u05D0\u05EA\u05E8. \u05DE\u05D3\u05E4\u05D9\u05E1 \u05DC\u05E1\u05D5\u05DB\u05DF \u05D0\u05EA \u05D4\u05D8\u05E7\u05E1\u05D8 \u05D5\u05D0\u05EA \u05D4\u05E4\u05E7\u05D5\u05D3\u05D5\u05EA.", "Prepares the folder with every choice: folder, sample and install, the details file and the site link. Prints the text and the commands for the agent."),
21777
21805
  n("cmd-migrate", "cli", "migrate scan / media / redirects / verify / status", "\u05D4\u05D0\u05EA\u05E8 \u05D4\u05D9\u05E9\u05DF: \u05E1\u05E8\u05D9\u05E7\u05EA \u05D4\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05D5\u05D4\u05EA\u05D5\u05DB\u05DF, \u05D4\u05D5\u05E8\u05D3\u05EA \u05D4\u05E7\u05D1\u05E6\u05D9\u05DD, \u05D4\u05E4\u05E0\u05D9\u05D5\u05EA 301 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E9\u05DC\u05D0 \u05E0\u05E9\u05D0\u05E8\u05D5, \u05D5\u05D1\u05D3\u05D9\u05E7\u05D4 \u05E9\u05DB\u05DC \u05DB\u05EA\u05D5\u05D1\u05EA \u05D9\u05E9\u05E0\u05D4 \u05E0\u05E4\u05EA\u05D7\u05EA \u05D1\u05EA\u05E6\u05D5\u05D2\u05D4 \u05D4\u05DE\u05E7\u05D3\u05D9\u05DE\u05D4.", "The old site: scan its addresses and content, download its files, 301s for addresses that could not stay, and a check that every old address opens on the preview."),
21778
21806
  n("cmd-blocks", "cli", "blocks [name]", "\u05D0\u05D1\u05E0\u05D9 \u05D1\u05E0\u05D9\u05D9\u05DF \u05E9\u05DC\u05E0\u05D5 \u05DC\u05D0\u05EA\u05E8 \u05E7\u05D9\u05D9\u05DD: inbox (\u05D8\u05D5\u05E4\u05E1 \u05D5\u05E2\u05DE\u05D5\u05D3 \u05D4\u05D5\u05D3\u05E2\u05D5\u05EA \u05DC\u05D1\u05E2\u05DC\u05D9\u05DD), blog. \u05DC\u05D0 \u05D3\u05D5\u05E8\u05E1 \u05E7\u05D1\u05E6\u05D9\u05DD.", "Our building blocks for an existing site: inbox (form and owner messages page), blog. Never writes over files."),
21807
+ n("cmd-brand", "cli", "brand favicon / icons / images", "\u05D4\u05D0\u05D9\u05D9\u05E7\u05D5\u05E0\u05D9\u05DD \u05D5\u05EA\u05DE\u05D5\u05E0\u05EA \u05D4\u05E9\u05D9\u05EA\u05D5\u05E3 \u05E0\u05D5\u05E6\u05E8\u05D9\u05DD \u05D1\u05E7\u05D5\u05D3 \u05DE\u05D4\u05D0\u05EA\u05E8 \u05E2\u05E6\u05DE\u05D5: \u05D4\u05E9\u05DD, \u05D4\u05E6\u05D1\u05E2\u05D9\u05DD \u05D5\u05D4\u05DC\u05D5\u05D2\u05D5. favicon \u05D7\u05D9\u05E0\u05DD \u05DC\u05DB\u05DC \u05D0\u05EA\u05E8, \u05E1\u05D8 \u05DE\u05DC\u05D0, \u05D5\u05D3\u05D5\u05D7 \u05EA\u05DE\u05D5\u05E0\u05D5\u05EA \u05D7\u05DC\u05E9\u05D5\u05EA \u05DC\u05E4\u05D9 \u05DE\u05D3\u05D9\u05D3\u05D4. \u05DC\u05D0 \u05DE\u05D7\u05DC\u05D9\u05E3 \u05EA\u05DE\u05D5\u05E0\u05D4 \u05DC\u05D1\u05D3.", "The site's icons and share image, made by code from the site itself: its name, colors and logo. A free favicon for every site, the full set, and a measured report of weak images. Never replaces an image by itself."),
21779
21808
  n("cmd-samples", "cli", "samples [key]", "\u05E8\u05E9\u05D9\u05DE\u05EA \u05D4\u05D3\u05D5\u05D2\u05DE\u05D0\u05D5\u05EA, \u05D0\u05D5 \u05D4\u05D5\u05E8\u05D3\u05D4 \u05E9\u05DC \u05D0\u05D7\u05EA.", "Lists the samples, or downloads one."),
21780
21809
  n("cmd-check", "cli", "check", "\u05D4\u05D0\u05DD \u05D4\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8 \u05D9\u05DB\u05D5\u05DC \u05DC\u05E8\u05D5\u05E5 \u05D0\u05E6\u05DC\u05E0\u05D5: \u05D7\u05D5\u05E1\u05DE\u05D9\u05DD \u05D5\u05D0\u05D6\u05D4\u05E8\u05D5\u05EA, \u05E2\u05DD \u05E4\u05E8\u05D5\u05DE\u05E4\u05D8 \u05EA\u05D9\u05E7\u05D5\u05DF.", "Can the project run on our hosting: blockers and warnings, with a fix prompt."),
21781
21810
  n("cmd-init", "cli", "init", "\u05D9\u05D5\u05E6\u05E8 DEPLOYAI.md \u05E2\u05DD \u05D4\u05DB\u05DC\u05DC\u05D9\u05DD \u05DC\u05E1\u05D5\u05DB\u05DF, \u05E9\u05D5\u05E8\u05D4 \u05D0\u05DC\u05D9\u05D5 \u05D1 AGENTS.md \u05D5 CLAUDE.md, \u05D5 .deployai/project.json. \u05E8\u05D0\u05E9\u05D5\u05DF \u05D1\u05E4\u05E8\u05D5\u05D9\u05E7\u05D8 \u05D7\u05D3\u05E9.", "Creates DEPLOYAI.md with the agent rules, a line to it in AGENTS.md and CLAUDE.md, and .deployai/project.json. First in a new project."),
@@ -21803,7 +21832,7 @@ var CLI_MAP_NODES = [
21803
21832
  // The server routes the CLI calls.
21804
21833
  n("api-starts", "server", "GET /api/starts/:id", "\u05D4\u05D1\u05D7\u05D9\u05E8\u05D5\u05EA \u05D5\u05D4\u05D8\u05E7\u05E1\u05D8 \u05DC\u05E1\u05D5\u05DB\u05DF. 7 \u05D9\u05DE\u05D9\u05DD, 5 \u05E9\u05DC\u05D9\u05E4\u05D5\u05EA \u05DC\u05D0\u05EA\u05E8. \u05E9\u05D5\u05E8\u05D4 \u05E9\u05DC \u05D0\u05EA\u05E8 \u05E0\u05E4\u05EA\u05D7\u05EA \u05E8\u05E7 \u05E2\u05DD \u05D4\u05EA\u05D7\u05D1\u05E8\u05D5\u05EA \u05E9\u05DC \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D5 \u05E9\u05DC \u05DE\u05D9 \u05E9\u05D9\u05E9 \u05DC\u05D5 \u05D4\u05E8\u05E9\u05D0\u05EA \u05E2\u05E8\u05D9\u05DB\u05D4.", "The choices and the agent text. 7 days, 5 fetches for a site. A site's line opens only with the login of its owner or an editor."),
21805
21834
  n("api-blocks", "server", "GET /blocks-src/<key>", "\u05E7\u05D5\u05D3 \u05D4\u05DE\u05E7\u05D5\u05E8 \u05E9\u05DC \u05D0\u05D1\u05DF \u05D1\u05E0\u05D9\u05D9\u05DF, \u05E6\u05D9\u05D1\u05D5\u05E8\u05D9.", "A block's source, public."),
21806
- n("api-migrate-grant", "server", "POST /api/cli/migrations/grant", "\u05D0\u05D7\u05E8\u05D9 link \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05DE /move: \u05D4\u05EA\u05D5\u05E1\u05E4\u05D9\u05DD \u05D1\u05D7\u05D9\u05E0\u05DD \u05DC\u05D0\u05EA\u05E8 \u05E9\u05E2\u05D1\u05E8, \u05E4\u05E2\u05DD \u05D0\u05D7\u05EA \u05DC\u05DB\u05DC start \u05D5\u05E2\u05D3 3 \u05D0\u05EA\u05E8\u05D9\u05DD \u05DC\u05D7\u05E9\u05D1\u05D5\u05DF.", "After link in a folder from /move: the add-ons free for the moved site, once per start and up to 3 sites an account."),
21835
+ n("api-migrate-grant", "server", "POST /api/cli/migrations/grant", "\u05D0\u05D7\u05E8\u05D9 link \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05DE /move: \u05D4\u05EA\u05D5\u05E1\u05E4\u05D9\u05DD \u05D1\u05D7\u05D9\u05E0\u05DD \u05DC\u05D0\u05EA\u05E8 \u05E9\u05E2\u05D1\u05E8, \u05E4\u05E2\u05DD \u05D0\u05D7\u05EA \u05DC\u05DB\u05DC start \u05D5\u05E2\u05D3 3 \u05D0\u05EA\u05E8\u05D9\u05DD \u05DC\u05D7\u05E9\u05D1\u05D5\u05DF. \u05DE\u05E2\u05D1\u05E8 \u05DE\u05E0\u05D5\u05D4\u05DC \u05DE\u05E7\u05D1\u05DC \u05DB\u05D0\u05DF \u05D2\u05DD \u05D0\u05EA \u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05D5, \u05E2\u05DD \u05D4\u05DE\u05D1\u05E6\u05E2 \u05D0\u05D5 \u05D1\u05DC\u05E2\u05D3\u05D9\u05D5.", "After link in a folder from /move: the add-ons free for the moved site, once per start and up to 3 sites an account. A managed move also gets its site here, with or without the offer."),
21807
21836
  n("api-migrate-progress", "server", "POST /api/migrations/progress", "\u05DE\u05E2\u05D1\u05E8 \u05DE\u05E0\u05D5\u05D4\u05DC: \u05D4\u05E9\u05DC\u05D1 \u05D5\u05D4\u05E2\u05E8\u05D4 \u05E9\u05DC \u05E9\u05D5\u05E8\u05D4 \u05D0\u05D7\u05EA \u05DE migrate status, \u05DC\u05DC\u05D5\u05D7 \u05D4\u05D1\u05E7\u05E9\u05D5\u05EA \u05D5\u05DC\u05E2\u05DE\u05D5\u05D3 \u05D4\u05E1\u05D8\u05D8\u05D5\u05E1 \u05E9\u05DC \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD.", "Managed move: the stage and a one line note from migrate status, to the requests board and the owner's status page."),
21808
21837
  n("api-samples", "server", "GET /samples-src/<key>", "\u05E7\u05D5\u05D3 \u05D4\u05DE\u05E7\u05D5\u05E8 \u05E9\u05DC \u05D3\u05D5\u05D2\u05DE\u05D4, \u05E6\u05D9\u05D1\u05D5\u05E8\u05D9.", "A sample's source, public."),
21809
21838
  n("api-device", "server", "/api/cli/device/*", "\u05DB\u05E0\u05D9\u05E1\u05D4 \u05D1\u05DE\u05DB\u05E9\u05D9\u05E8: \u05E7\u05D5\u05D3, \u05D0\u05D9\u05E9\u05D5\u05E8 \u05D1\u05D3\u05E4\u05D3\u05E4\u05DF, \u05D8\u05D5\u05E7\u05DF.", "Device login: a code, approval in the browser, a token."),
@@ -21866,6 +21895,7 @@ var CLI_MAP_EDGES = [
21866
21895
  e("cmd-sql", "api-sql"),
21867
21896
  e("cmd-deploy", "api-sql"),
21868
21897
  e("cmd-rollback", "api-promote"),
21898
+ e("cmd-start", "cmd-brand"),
21869
21899
  e("page-move-url", "cmd-start"),
21870
21900
  e("cmd-start", "text-migrate"),
21871
21901
  e("cmd-start", "cmd-migrate"),
@@ -22095,7 +22125,11 @@ var BUILD_WITH = [
22095
22125
  "Uploaded files and images: Cloudflare R2 (object storage), never the local disk.",
22096
22126
  "Settings and secrets: environment variables, set with: npx deployai@latest env set <key>",
22097
22127
  "Images: resize at build time or serve them as they are; no native image modules at runtime.",
22128
+ // D-616: an icon is part of a finished site, and the command keeps one the site has.
22129
+ "Icon: every site has one. npx deployai@latest brand favicon keeps the one it has, or makes one from the site itself: its logo, or the first letter of its name in its own color.",
22098
22130
  "Passwords: bcryptjs or Web Crypto, never native bcrypt.",
22131
+ // D-633: Safari on an iPhone is its own engine, so every site gets these whatever add-ons it has.
22132
+ "iPhone: Safari is its own browser engine, so working in Chrome or on Android proves nothing. Full height sections use svh or dvh, never 100vh. Typing fields are at least 16px, or the page zooms. A video that plays by itself has muted and playsinline. Bars fixed to the bottom pad with env(safe-area-inset-bottom). Nothing needs a hover. Newer CSS and browser features need a working fallback.",
22099
22133
  "Server code runs per request: no long-running processes, background servers or child processes.",
22100
22134
  // D-611: Durable Objects run when the site's own code exports them; D1 stays the default, they cost more for plain data.
22101
22135
  "Data goes in D1 by default. Use a Durable Object only for live state that needs one place to coordinate (a chat room, a live counter, booking slots that must not double-book, presence): export the class from this site's Worker and bind it with a name and class_name in the wrangler config, never script_name. Never remove or rename a class once it is live: that would delete its data, so the upload is refused. A preview starts with empty objects.",
@@ -22239,10 +22273,10 @@ function normalizeSourceUrl(raw) {
22239
22273
  u.hash = "";
22240
22274
  return u.pathname === "/" && !u.search ? u.origin : u.toString();
22241
22275
  }
22242
- function parseSitemapXml(xml) {
22276
+ function parseSitemapXml(xml2) {
22243
22277
  const locs = (block) => [...block.matchAll(/<loc>\s*([\s\S]*?)\s*<\/loc>/gi)].map((m) => decode3(m[1].replace(/^<!\[CDATA\[|\]\]>$/g, "")).trim()).filter(Boolean);
22244
- const sitemaps = [...xml.matchAll(/<sitemap\b[^>]*>([\s\S]*?)<\/sitemap>/gi)].flatMap((m) => locs(m[1]));
22245
- const urls = [...xml.matchAll(/<url\b[^>]*>([\s\S]*?)<\/url>/gi)].flatMap((m) => locs(m[1]));
22278
+ const sitemaps = [...xml2.matchAll(/<sitemap\b[^>]*>([\s\S]*?)<\/sitemap>/gi)].flatMap((m) => locs(m[1]));
22279
+ const urls = [...xml2.matchAll(/<url\b[^>]*>([\s\S]*?)<\/url>/gi)].flatMap((m) => locs(m[1]));
22246
22280
  return { urls, sitemaps };
22247
22281
  }
22248
22282
  function detectPlatform(html, headers = {}) {
@@ -22344,6 +22378,271 @@ var enc2 = new TextEncoder();
22344
22378
  // ../shared/src/app-gate.ts
22345
22379
  var enc3 = new TextEncoder();
22346
22380
 
22381
+ // ../shared/src/brand.ts
22382
+ var ICO_SIZES = [32, 48];
22383
+ var ICO_TARGETS = ICO_SIZES.map((s) => ({ file: `ico-${s}.png`, width: s, height: s, icoOnly: true }));
22384
+ var FAVICON_TARGETS = [
22385
+ ...ICO_TARGETS,
22386
+ { file: "apple-touch-icon.png", width: 180, height: 180, opaque: true, pad: 0.1 }
22387
+ ];
22388
+ var BRAND_TARGETS = [
22389
+ ...FAVICON_TARGETS,
22390
+ { file: "favicon-96x96.png", width: 96, height: 96 },
22391
+ { file: "icon-192.png", width: 192, height: 192 },
22392
+ { file: "icon-512.png", width: 512, height: 512 },
22393
+ { file: "icon-maskable-512.png", width: 512, height: 512, opaque: true, pad: 0.2 },
22394
+ { file: "og-image.png", width: 1200, height: 630, opaque: true, og: true }
22395
+ ];
22396
+ var BRAND_FILES = ["favicon.ico", "favicon.svg", "site.webmanifest", ...BRAND_TARGETS.filter((t) => !t.icoOnly).map((t) => t.file)];
22397
+ function canDraw(target, source) {
22398
+ if (source.vector || target.og) return true;
22399
+ return Math.max(target.width, target.height) <= Math.max(source.width, source.height) * 2;
22400
+ }
22401
+ var xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
22402
+ function letterTileSvg(name, color) {
22403
+ const letter = [...name.trim()][0]?.toLocaleUpperCase() ?? "S";
22404
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="${xml(color)}"/><text x="32" y="33" font-family="system-ui,Arial,sans-serif" font-size="38" font-weight="700" fill="${contrastInk(color)}" text-anchor="middle" dominant-baseline="central">${xml(letter)}</text></svg>
22405
+ `;
22406
+ }
22407
+ function contrastInk(color) {
22408
+ const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
22409
+ if (!m) return "#FFFFFF";
22410
+ const [r, g, b] = [m[1], m[2], m[3]].map((h) => parseInt(h, 16));
22411
+ return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? "#0A0A0A" : "#FFFFFF";
22412
+ }
22413
+ var BRAND_DEFAULT_COLOR = "#111827";
22414
+ function webManifest(name, color) {
22415
+ return `${JSON.stringify({
22416
+ name,
22417
+ short_name: name.slice(0, 12),
22418
+ icons: [
22419
+ { src: "/icon-192.png", sizes: "192x192", type: "image/png" },
22420
+ { src: "/icon-512.png", sizes: "512x512", type: "image/png" },
22421
+ { src: "/icon-maskable-512.png", sizes: "512x512", type: "image/png", purpose: "maskable" }
22422
+ ],
22423
+ theme_color: color,
22424
+ background_color: color,
22425
+ display: "browser"
22426
+ }, null, 2)}
22427
+ `;
22428
+ }
22429
+ function brandHeadTags(files) {
22430
+ const has = (f) => files.includes(f);
22431
+ return [
22432
+ has("favicon.ico") ? '<link rel="icon" href="/favicon.ico" sizes="48x48">' : "",
22433
+ has("favicon.svg") ? '<link rel="icon" href="/favicon.svg" type="image/svg+xml">' : "",
22434
+ has("favicon-96x96.png") ? '<link rel="icon" href="/favicon-96x96.png" type="image/png" sizes="96x96">' : "",
22435
+ has("apple-touch-icon.png") ? '<link rel="apple-touch-icon" href="/apple-touch-icon.png">' : "",
22436
+ has("site.webmanifest") ? '<link rel="manifest" href="/site.webmanifest">' : "",
22437
+ has("og-image.png") ? '<meta property="og:image" content="<the site address>/og-image.png">' : "",
22438
+ has("og-image.png") ? '<meta property="og:image:width" content="1200">' : "",
22439
+ has("og-image.png") ? '<meta property="og:image:height" content="630">' : ""
22440
+ ].filter(Boolean);
22441
+ }
22442
+ function buildIco(images) {
22443
+ const headerSize = 6 + images.length * 16;
22444
+ const out2 = new Uint8Array(headerSize + images.reduce((n2, i) => n2 + i.png.length, 0));
22445
+ const view = new DataView(out2.buffer);
22446
+ view.setUint16(2, 1, true);
22447
+ view.setUint16(4, images.length, true);
22448
+ let offset = headerSize;
22449
+ images.forEach((img, i) => {
22450
+ const at = 6 + i * 16;
22451
+ out2[at] = img.size >= 256 ? 0 : img.size;
22452
+ out2[at + 1] = img.size >= 256 ? 0 : img.size;
22453
+ view.setUint16(at + 4, 1, true);
22454
+ view.setUint16(at + 6, 32, true);
22455
+ view.setUint32(at + 8, img.png.length, true);
22456
+ view.setUint32(at + 12, offset, true);
22457
+ out2.set(img.png, offset);
22458
+ offset += img.png.length;
22459
+ });
22460
+ return out2;
22461
+ }
22462
+ function imageSize(b) {
22463
+ const v = new DataView(b.buffer, b.byteOffset, b.byteLength);
22464
+ const ascii = (at, n2) => String.fromCharCode(...b.subarray(at, at + n2));
22465
+ if (b.length >= 24 && b[0] === 137 && ascii(1, 3) === "PNG") return { width: v.getUint32(16), height: v.getUint32(20), format: "png" };
22466
+ if (b.length >= 10 && ascii(0, 3) === "GIF") return { width: v.getUint16(6, true), height: v.getUint16(8, true), format: "gif" };
22467
+ if (b.length >= 22 && v.getUint16(0, true) === 0 && v.getUint16(2, true) === 1 && v.getUint16(4, true) > 0) {
22468
+ let best = 0;
22469
+ const count = v.getUint16(4, true);
22470
+ for (let i = 0; i < count && 6 + i * 16 < b.length; i++) best = Math.max(best, b[6 + i * 16] || 256);
22471
+ return { width: best, height: best, format: "ico" };
22472
+ }
22473
+ if (b.length >= 30 && ascii(0, 4) === "RIFF" && ascii(8, 4) === "WEBP") {
22474
+ const kind = ascii(12, 4);
22475
+ if (kind === "VP8X") return { width: 1 + (b[24] | b[25] << 8 | b[26] << 16), height: 1 + (b[27] | b[28] << 8 | b[29] << 16), format: "webp" };
22476
+ if (kind === "VP8 ") return { width: v.getUint16(26, true) & 16383, height: v.getUint16(28, true) & 16383, format: "webp" };
22477
+ if (kind === "VP8L") {
22478
+ const bits = v.getUint32(21, true);
22479
+ return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1, format: "webp" };
22480
+ }
22481
+ return null;
22482
+ }
22483
+ if (b.length >= 4 && b[0] === 255 && b[1] === 216) {
22484
+ let at = 2;
22485
+ while (at + 9 < b.length) {
22486
+ if (b[at] !== 255) {
22487
+ at++;
22488
+ continue;
22489
+ }
22490
+ const marker = b[at + 1];
22491
+ if (marker === 255) {
22492
+ at++;
22493
+ continue;
22494
+ }
22495
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return { width: v.getUint16(at + 7), height: v.getUint16(at + 5), format: "jpeg" };
22496
+ at += 2 + v.getUint16(at + 2);
22497
+ }
22498
+ }
22499
+ return null;
22500
+ }
22501
+ var IMAGE_MIN_DENSITY = 1.5;
22502
+ var IMAGE_SMALL_WIDTH = 400;
22503
+ var JPEG_MIN_BYTES_PER_PIXEL = 0.04;
22504
+ var IMAGE_IGNORE_UNDER = 96;
22505
+ function judgeImage(img) {
22506
+ if (img.shownWidth !== void 0) {
22507
+ if (img.shownWidth < IMAGE_IGNORE_UNDER) return "ok";
22508
+ if (img.width < img.shownWidth * IMAGE_MIN_DENSITY) return "soft";
22509
+ } else if (img.width >= IMAGE_IGNORE_UNDER && img.width < IMAGE_SMALL_WIDTH) {
22510
+ return "small";
22511
+ }
22512
+ if (img.format === "jpeg" && img.bytes !== void 0 && img.width >= IMAGE_SMALL_WIDTH && img.bytes / (img.width * img.height) < JPEG_MIN_BYTES_PER_PIXEL) return "compressed";
22513
+ return "ok";
22514
+ }
22515
+ function looksLikeLogo(path) {
22516
+ return /(^|[/_.-])logo([/_.-]|\d|$)/i.test(path) && /\.(svg|png|webp|jpe?g)(\?|$)/i.test(path);
22517
+ }
22518
+ var decode4 = (s) => s.replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#0?39;|&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\s+/g, " ").trim();
22519
+ function metaContent2(html, attr, key) {
22520
+ for (const m of html.matchAll(/<meta\b[^>]*>/gi)) {
22521
+ if (!new RegExp(`\\s${attr}=["']${key}["']`, "i").test(m[0])) continue;
22522
+ const v = m[0].match(/\scontent=["']([^"']*)/i)?.[1];
22523
+ if (v) return decode4(v);
22524
+ }
22525
+ return null;
22526
+ }
22527
+ function readSiteIdentity(html) {
22528
+ const title = decode4(html.match(/<title[^>]*>([^<]*)/i)?.[1] ?? "");
22529
+ const fromTitle = title.split(/\s[|\-\u2013\u2014\u00b7:]\s/).map((s) => s.trim()).filter((s) => s && !/^(home|home ?page|welcome|main|בית|דף הבית|ראשי|עמוד הבית|ברוכים הבאים)$/i.test(s)).sort((a, b) => a.length - b.length)[0] ?? null;
22530
+ const description = metaContent2(html, "name", "description") ?? metaContent2(html, "property", "og:description");
22531
+ return { name: metaContent2(html, "property", "og:site_name") ?? fromTitle, line: description ? shareLine(description) : null, themeColor: metaContent2(html, "name", "theme-color") };
22532
+ }
22533
+ function shareLine(text, max = 70) {
22534
+ const first = decode4(text).split(/(?<=[.!?\u05c3])\s/)[0] ?? "";
22535
+ if (first.length <= max) return first.replace(/[.\s]+$/, "");
22536
+ const cut = first.slice(0, max);
22537
+ const pause = Math.max(cut.lastIndexOf(":"), cut.lastIndexOf(","), cut.lastIndexOf(";"));
22538
+ return pause >= 20 ? cut.slice(0, pause) : cut.replace(/\s+\S*$/, "");
22539
+ }
22540
+ var hex22 = (n2) => Math.max(0, Math.min(255, Math.round(n2))).toString(16).padStart(2, "0");
22541
+ function toHexColor(value) {
22542
+ const v = value.trim().toLowerCase();
22543
+ let m = /^#([0-9a-f]{3})$/.exec(v);
22544
+ if (m) return `#${[...m[1]].map((c) => c + c).join("")}`;
22545
+ m = /^#([0-9a-f]{6})(ff)?$/.exec(v);
22546
+ if (m) return `#${m[1]}`;
22547
+ m = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*(?:[,/]\s*(1|1\.0+|100%)\s*)?\)$/.exec(v);
22548
+ if (m) return `#${hex22(+m[1])}${hex22(+m[2])}${hex22(+m[3])}`;
22549
+ m = /^hsla?\(\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/.exec(v);
22550
+ if (m) {
22551
+ const [h, s, l] = [+m[1] / 360, +m[2] / 100, +m[3] / 100];
22552
+ const f = (n2) => {
22553
+ const k = (n2 + h * 12) % 12;
22554
+ return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1));
22555
+ };
22556
+ return `#${hex22(f(0) * 255)}${hex22(f(8) * 255)}${hex22(f(4) * 255)}`;
22557
+ }
22558
+ return null;
22559
+ }
22560
+ function isBrandColor(color) {
22561
+ const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
22562
+ if (!m) return false;
22563
+ const [r, g, b] = [m[1], m[2], m[3]].map((h) => parseInt(h, 16) / 255);
22564
+ const max = Math.max(r, g, b), min = Math.min(r, g, b), l = (max + min) / 2;
22565
+ const s = max === min ? 0 : (max - min) / (1 - Math.abs(2 * l - 1));
22566
+ return s >= 0.25 && l >= 0.12 && l <= 0.8;
22567
+ }
22568
+ var COLOR_RE = /#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)/gi;
22569
+ var NAMED_RE = /(?:--|\b)(?:[\w-]*?)(primary|brand|accent|main)[\w-]*["']?\s*:\s*["']?(#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\))/gi;
22570
+ var NAMED_WEIGHT = 25;
22571
+ var THEME_WEIGHT = 100;
22572
+ var MIN_USES = 2;
22573
+ function isPageWhite(color) {
22574
+ const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
22575
+ return !!m && [m[1], m[2], m[3]].every((h) => parseInt(h, 16) >= 240);
22576
+ }
22577
+ function pickBrandColor(sources) {
22578
+ const score = /* @__PURE__ */ new Map();
22579
+ const add = (raw, by, onPurpose) => {
22580
+ const hex3 = toHexColor(raw);
22581
+ if (hex3 && (onPurpose ? !isPageWhite(hex3) : isBrandColor(hex3))) score.set(hex3, (score.get(hex3) ?? 0) + by);
22582
+ };
22583
+ for (const s of sources) {
22584
+ if (s.themeColor) add(s.themeColor, THEME_WEIGHT, true);
22585
+ for (const m of s.text.matchAll(COLOR_RE)) add(m[0], 1, false);
22586
+ for (const m of s.text.matchAll(NAMED_RE)) add(m[2], NAMED_WEIGHT, true);
22587
+ }
22588
+ return [...score.entries()].filter(([, n2]) => n2 >= MIN_USES).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0] ?? null;
22589
+ }
22590
+ function svgLogoColor(svg) {
22591
+ const count = /* @__PURE__ */ new Map();
22592
+ for (const m of svg.matchAll(/(?:fill|stroke|stop-color)\s*[=:]\s*["']?(#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\))/gi)) {
22593
+ const hex3 = toHexColor(m[1]);
22594
+ if (hex3 && !isPageWhite(hex3)) count.set(hex3, (count.get(hex3) ?? 0) + 1);
22595
+ }
22596
+ return [...count.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0] ?? null;
22597
+ }
22598
+ var isSvgText = (text) => /<svg[\s>]/i.test(text);
22599
+ function iconLinks(html) {
22600
+ const found = [];
22601
+ for (const m of html.matchAll(/<link\b[^>]*>/gi)) {
22602
+ const rel = m[0].match(/\srel=["']([^"']+)/i)?.[1]?.toLowerCase() ?? "";
22603
+ const href = m[0].match(/\shref=["']([^"']+)/i)?.[1];
22604
+ if (!href || !/(^|\s)(icon|apple-touch-icon(-precomposed)?|mask-icon)(\s|$)/.test(rel) || href.startsWith("data:")) continue;
22605
+ const size = Number(m[0].match(/\ssizes=["'](\d+)x/i)?.[1] ?? 0);
22606
+ const score = /\.svg(\?|$)/i.test(href) ? 1e4 : rel.includes("apple-touch") ? 1e3 + size : size || 16;
22607
+ found.push({ href, score });
22608
+ }
22609
+ return found.sort((a, b) => b.score - a.score).map((f) => f.href);
22610
+ }
22611
+ function logoInPage(html) {
22612
+ for (const m of html.matchAll(/<img\b[^>]*>/gi)) {
22613
+ const src = m[0].match(/\ssrc=["']([^"']+)/i)?.[1];
22614
+ if (src && !src.startsWith("data:") && /logo/i.test(m[0])) return src;
22615
+ }
22616
+ return null;
22617
+ }
22618
+
22619
+ // ../shared/src/deploy-tools.ts
22620
+ var AI_AGENT_NAMES = [
22621
+ [/claude/, "claudeCode"],
22622
+ [/codex/, "codex"],
22623
+ [/cursor/, "cursor"],
22624
+ [/copilot/, "copilot"],
22625
+ [/antigravity/, "antigravity"],
22626
+ [/gemini/, "gemini"],
22627
+ [/opencode/, "opencode"],
22628
+ [/replit/, "replit"]
22629
+ ];
22630
+ function deployToolFromEnv(env) {
22631
+ const named = env.AI_AGENT?.trim().toLowerCase();
22632
+ if (named) return AI_AGENT_NAMES.find(([re]) => re.test(named))?.[1] ?? "other";
22633
+ if (env.CLAUDECODE || env.CLAUDE_CODE) return "claudeCode";
22634
+ if (env.CODEX_SANDBOX || env.CODEX_CI || env.CODEX_THREAD_ID) return "codex";
22635
+ if (env.GEMINI_CLI) return "gemini";
22636
+ if (env.ANTIGRAVITY_AGENT) return "antigravity";
22637
+ if (env.OPENCODE === "1" || env.OPENCODE_CLIENT) return "opencode";
22638
+ if (env.CURSOR_AGENT || env.CURSOR_EXTENSION_HOST_ROLE === "agent-exec") return "cursor";
22639
+ if (env.AUGMENT_AGENT) return "other";
22640
+ if (env.COPILOT_MODEL || env.COPILOT_ALLOW_ALL) return "copilot";
22641
+ if (env.REPL_ID) return "replit";
22642
+ if (env.CURSOR_TRACE_ID) return "cursor";
22643
+ return null;
22644
+ }
22645
+
22347
22646
  // src/config.ts
22348
22647
  import { randomUUID } from "crypto";
22349
22648
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -22933,7 +23232,7 @@ function messages(root) {
22933
23232
  }
22934
23233
 
22935
23234
  // src/version.ts
22936
- var CLI_VERSION = "0.1.0-beta.20";
23235
+ var CLI_VERSION = "0.1.0-beta.22";
22937
23236
 
22938
23237
  // src/api.ts
22939
23238
  function apiContext(apiFlag) {
@@ -23107,7 +23406,8 @@ var TELEMETRY_SENT = [
23107
23406
  "After each check: compatible or not, blocker and warning codes (for example fs_write)",
23108
23407
  "OS, architecture and Node version (in the request header)",
23109
23408
  "Your user id, only after login (from the login token), and only to the API that issued the login (D-557)",
23110
- "After a failed version, the one sentence you pass with deploy --fixed (what you changed, no code)"
23409
+ "After a failed version, the one sentence you pass with deploy --fixed (what you changed, no code)",
23410
+ "With each deploy, which AI tool ran it (for example Claude Code or Codex), when the environment says so"
23111
23411
  ];
23112
23412
  var TELEMETRY_NEVER_SENT = [
23113
23413
  "Source code or file contents",
@@ -23126,7 +23426,7 @@ function buildCheckReport(analysis, installId, projectId) {
23126
23426
  warnings: [...new Set(analysis.warnings.map((w) => w.code))]
23127
23427
  };
23128
23428
  }
23129
- async function sendCheckReport(ctx, report) {
23429
+ async function sendCheckReport(ctx, report2) {
23130
23430
  if (!telemetryEnabled(ctx.config)) return;
23131
23431
  try {
23132
23432
  const headers = { "Content-Type": "application/json", "User-Agent": userAgent(ctx.config) };
@@ -23135,7 +23435,7 @@ async function sendCheckReport(ctx, report) {
23135
23435
  const res = await fetch(`${ctx.apiUrl}/api/cli/check-results`, {
23136
23436
  method: "POST",
23137
23437
  headers,
23138
- body: JSON.stringify(report),
23438
+ body: JSON.stringify(report2),
23139
23439
  signal: AbortSignal.timeout(2e3)
23140
23440
  });
23141
23441
  await res.body?.cancel().catch(() => {
@@ -23567,10 +23867,10 @@ function analyzeProject(root) {
23567
23867
  });
23568
23868
  }
23569
23869
  }
23570
- const createServer = /\b(?:http|https|net|http2)\.createServer\s*\(|\bcreateServer\s*\([^)]*\)\s*\.listen\s*\(/.exec(code);
23571
- if (createServer && /['"`](?:node:)?(?:http|https|net|http2)['"`]/.test(code)) {
23870
+ const createServer2 = /\b(?:http|https|net|http2)\.createServer\s*\(|\bcreateServer\s*\([^)]*\)\s*\.listen\s*\(/.exec(code);
23871
+ if (createServer2 && /['"`](?:node:)?(?:http|https|net|http2)['"`]/.test(code)) {
23572
23872
  isServer = true;
23573
- add({ code: "long_running_process", severity: "blocker", file: s.rel, line: lineAt3(code, createServer.index), detail: " (Node http server)" });
23873
+ add({ code: "long_running_process", severity: "blocker", file: s.rel, line: lineAt3(code, createServer2.index), detail: " (Node http server)" });
23574
23874
  }
23575
23875
  for (const mod of JOB_LIBS) {
23576
23876
  const re = importRe(mod);
@@ -23923,8 +24223,8 @@ function initCommand(root, opts) {
23923
24223
  }
23924
24224
 
23925
24225
  // src/commands/check.ts
23926
- import { existsSync as existsSync6, writeFileSync as writeFileSync4 } from "fs";
23927
- import { join as join6 } from "path";
24226
+ import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
24227
+ import { join as join7 } from "path";
23928
24228
 
23929
24229
  // src/prompt.ts
23930
24230
  var PROMPT_RULES = [
@@ -23991,6 +24291,8 @@ function buildPrompt(analysis) {
23991
24291
 
23992
24292
  // src/system.ts
23993
24293
  import { spawn, spawnSync } from "child_process";
24294
+ import { existsSync as existsSync6 } from "fs";
24295
+ import { join as join6 } from "path";
23994
24296
  function copyToClipboard(text) {
23995
24297
  if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
23996
24298
  const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
@@ -24007,6 +24309,13 @@ function copyToClipboard(text) {
24007
24309
  }
24008
24310
  return false;
24009
24311
  }
24312
+ function findBrowser() {
24313
+ if (process.env.DEPLOYAI_NO_BROWSER) return null;
24314
+ const set2 = process.env.CHROME_PATH;
24315
+ if (set2 && existsSync6(set2)) return set2;
24316
+ const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join6(d, "Google/Chrome/Application/chrome.exe"), join6(d, "Microsoft/Edge/Application/msedge.exe")] : []) : process.platform === "darwin" ? ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "/Applications/Chromium.app/Contents/MacOS/Chromium"] : ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/microsoft-edge", "/snap/bin/chromium"];
24317
+ return places.find((p) => existsSync6(p)) ?? null;
24318
+ }
24010
24319
  function openBrowser(url2) {
24011
24320
  if (process.env.DEPLOYAI_NO_BROWSER || process.env.CI) return false;
24012
24321
  if (!/^https?:\/\//.test(url2)) return false;
@@ -24115,7 +24424,7 @@ async function runCheck(root, ctx, opts = {}) {
24115
24424
  out("DeployAI check");
24116
24425
  out();
24117
24426
  out(messages(root)("emptyFolder"));
24118
- if (!existsSync6(join6(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
24427
+ if (!existsSync7(join7(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
24119
24428
  } else if (opts.print !== false) {
24120
24429
  printCheck(a);
24121
24430
  out();
@@ -24142,7 +24451,7 @@ async function runCheck(root, ctx, opts = {}) {
24142
24451
  } else {
24143
24452
  out(t("runDeploy"));
24144
24453
  }
24145
- if (!existsSync6(join6(root, "DEPLOYAI.md"))) out(t("initHint"));
24454
+ if (!existsSync7(join7(root, "DEPLOYAI.md"))) out(t("initHint"));
24146
24455
  }
24147
24456
  await telemetry;
24148
24457
  return a;
@@ -24271,8 +24580,8 @@ function telemetryCommand(action) {
24271
24580
  }
24272
24581
 
24273
24582
  // src/commands/allow.ts
24274
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2 } from "fs";
24275
- import { dirname, join as join7 } from "path";
24583
+ import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2 } from "fs";
24584
+ import { dirname, join as join8 } from "path";
24276
24585
  var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity"];
24277
24586
  var CLAUDE_RULE = "Bash(npx deployai@latest *)";
24278
24587
  var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
@@ -24282,7 +24591,7 @@ var CLICKS = {
24282
24591
  antigravity: "Antigravity: when it asks to run npx deployai@latest, choose Accept."
24283
24592
  };
24284
24593
  function readObject(file2) {
24285
- if (!existsSync7(file2)) return {};
24594
+ if (!existsSync8(file2)) return {};
24286
24595
  try {
24287
24596
  const v = JSON.parse(readFileSync6(file2, "utf8"));
24288
24597
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
@@ -24304,9 +24613,9 @@ function addTo(obj, key, list, value) {
24304
24613
  return true;
24305
24614
  }
24306
24615
  function ignoreInGit(root, path) {
24307
- if (!existsSync7(join7(root, ".git"))) return;
24308
- const gi = join7(root, ".gitignore");
24309
- const text = existsSync7(gi) ? readFileSync6(gi, "utf8") : "";
24616
+ if (!existsSync8(join8(root, ".git"))) return;
24617
+ const gi = join8(root, ".gitignore");
24618
+ const text = existsSync8(gi) ? readFileSync6(gi, "utf8") : "";
24310
24619
  if (text.split(/\r?\n/).some((l) => l.trim() === path)) return;
24311
24620
  appendFileSync2(gi, `${text && !text.endsWith("\n") ? "\n" : ""}${path}
24312
24621
  `);
@@ -24327,7 +24636,7 @@ function allowCommand(tool) {
24327
24636
  }
24328
24637
  if (picked === "claude-code") {
24329
24638
  const rel = ".claude/settings.local.json";
24330
- const file2 = join7(root, rel);
24639
+ const file2 = join8(root, rel);
24331
24640
  const obj = readObject(file2);
24332
24641
  if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is. Ask the owner to add the Allow rule ${CLAUDE_RULE} with /permissions.`, 1, "allow_file");
24333
24642
  const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
@@ -24341,7 +24650,7 @@ function allowCommand(tool) {
24341
24650
  }
24342
24651
  if (picked === "cursor") {
24343
24652
  const rel = ".cursor/permissions.json";
24344
- const file2 = join7(root, rel);
24653
+ const file2 = join8(root, rel);
24345
24654
  const obj = readObject(file2);
24346
24655
  if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
24347
24656
  const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
@@ -24358,8 +24667,8 @@ function allowCommand(tool) {
24358
24667
  import { createInterface } from "readline/promises";
24359
24668
 
24360
24669
  // src/commands/migrate.ts
24361
- import { createWriteStream, existsSync as existsSync8, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync, writeFileSync as writeFileSync6 } from "fs";
24362
- import { dirname as dirname2, join as join8, posix, relative, resolve, sep } from "path";
24670
+ import { createWriteStream, existsSync as existsSync9, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync, writeFileSync as writeFileSync6 } from "fs";
24671
+ import { dirname as dirname2, join as join9, posix, relative, resolve, sep } from "path";
24363
24672
  import { Readable } from "stream";
24364
24673
  import { pipeline } from "stream/promises";
24365
24674
  var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
@@ -24371,7 +24680,7 @@ var PAUSE_MS = 150;
24371
24680
  var SCAN_WORKERS = 4;
24372
24681
  var START_SCAN_PAGES = 300;
24373
24682
  var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
24374
- var hostDir = (root, host) => join8(root, MIGRATION_DIR, host.replace(/^www\./, ""));
24683
+ var hostDir = (root, host) => join9(root, MIGRATION_DIR, host.replace(/^www\./, ""));
24375
24684
  var readJson2 = (file2) => {
24376
24685
  try {
24377
24686
  return JSON.parse(readFileSync7(file2, "utf8"));
@@ -24391,9 +24700,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
24391
24700
  }
24392
24701
  }
24393
24702
  function scannedHosts(root) {
24394
- const dir = join8(root, MIGRATION_DIR);
24395
- if (!existsSync8(dir)) return [];
24396
- return readdirSync3(dir).filter((h) => existsSync8(join8(dir, h, "inventory.json")));
24703
+ const dir = join9(root, MIGRATION_DIR);
24704
+ if (!existsSync9(dir)) return [];
24705
+ return readdirSync3(dir).filter((h) => existsSync9(join9(dir, h, "inventory.json")));
24397
24706
  }
24398
24707
  async function migrateStatusCommand(root, ctx, stage, note) {
24399
24708
  if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
@@ -24406,18 +24715,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
24406
24715
  out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
24407
24716
  }
24408
24717
  function readChoices(root) {
24409
- return readJson2(join8(root, MIGRATION_DIR, "choices.json"));
24718
+ return readJson2(join9(root, MIGRATION_DIR, "choices.json"));
24410
24719
  }
24411
24720
  function writeChoices(root, choices) {
24412
24721
  ensureMigrationDir(root);
24413
- writeJson(join8(root, MIGRATION_DIR, "choices.json"), choices);
24722
+ writeJson(join9(root, MIGRATION_DIR, "choices.json"), choices);
24414
24723
  }
24415
24724
  function ensureMigrationDir(root) {
24416
24725
  ensureDeployaiDir(root);
24417
- const dir = join8(root, MIGRATION_DIR);
24726
+ const dir = join9(root, MIGRATION_DIR);
24418
24727
  mkdirSync4(dir, { recursive: true });
24419
- const ignore = join8(dir, ".gitignore");
24420
- if (!existsSync8(ignore)) writeFileSync6(ignore, "*/media/\n*/media-state.json\n");
24728
+ const ignore = join9(dir, ".gitignore");
24729
+ if (!existsSync9(ignore)) writeFileSync6(ignore, "*/media/\n*/media-state.json\n");
24421
24730
  }
24422
24731
  async function sitemapUrls(base, robotsSitemaps, enough) {
24423
24732
  const own2 = [`${base}/wp-sitemap.xml`, `${base}/sitemap_index.xml`, `${base}/sitemap.xml`];
@@ -24434,10 +24743,10 @@ async function sitemapUrls(base, robotsSitemaps, enough) {
24434
24743
  seen.add(next);
24435
24744
  const res = await get(next, "application/xml,text/xml,*/*;q=0.5");
24436
24745
  if (!res?.ok) continue;
24437
- const xml = await res.text();
24438
- if (!/<(urlset|sitemapindex)\b/i.test(xml)) continue;
24746
+ const xml2 = await res.text();
24747
+ if (!/<(urlset|sitemapindex)\b/i.test(xml2)) continue;
24439
24748
  found.push(next);
24440
- const parsed = parseSitemapXml(xml);
24749
+ const parsed = parseSitemapXml(xml2);
24441
24750
  queue.push(...parsed.sitemaps);
24442
24751
  for (const u of parsed.urls) {
24443
24752
  try {
@@ -24477,15 +24786,15 @@ async function wordpressContent(base, dir) {
24477
24786
  await sleep2(PAUSE_MS);
24478
24787
  }
24479
24788
  if (items.length) {
24480
- writeJson(join8(dir, "content", `${type}.json`), items);
24789
+ writeJson(join9(dir, "content", `${type}.json`), items);
24481
24790
  out(` ${type}: ${items.length}`);
24482
24791
  }
24483
24792
  }
24484
- const posts = readJson2(join8(dir, "content", "posts.json"));
24793
+ const posts = readJson2(join9(dir, "content", "posts.json"));
24485
24794
  if (posts?.length) {
24486
- const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson2(join8(dir, "content", "categories.json")) ?? [], tags: readJson2(join8(dir, "content", "tags.json")) ?? [], users: readJson2(join8(dir, "content", "users.json")) ?? [], media: readJson2(join8(dir, "content", "media.json")) ?? [] });
24487
- mkdirSync4(join8(dir, "posts"), { recursive: true });
24488
- for (const f of files) writeFileSync6(join8(dir, "posts", f.file), f.text);
24795
+ const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson2(join9(dir, "content", "categories.json")) ?? [], tags: readJson2(join9(dir, "content", "tags.json")) ?? [], users: readJson2(join9(dir, "content", "users.json")) ?? [], media: readJson2(join9(dir, "content", "media.json")) ?? [] });
24796
+ mkdirSync4(join9(dir, "posts"), { recursive: true });
24797
+ for (const f of files) writeFileSync6(join9(dir, "posts", f.file), f.text);
24489
24798
  out(` posts as Markdown: ${files.length}`);
24490
24799
  }
24491
24800
  return true;
@@ -24508,6 +24817,50 @@ function pageAssets(html, base) {
24508
24817
  for (const m of html.matchAll(/url\(["']?([^"')]+\.(?:jpe?g|png|gif|webp|svg|avif))/gi)) add(m[1]);
24509
24818
  return [...found];
24510
24819
  }
24820
+ var ICON_MAX_BYTES = 2 * 1024 * 1024;
24821
+ async function saveOldIcons(html, pageUrl, origin, dir) {
24822
+ const wanted = [];
24823
+ const add = (href, kind) => {
24824
+ if (!href) return;
24825
+ try {
24826
+ const url2 = new URL(href, pageUrl).toString();
24827
+ if (!wanted.some((w) => w.url === url2)) wanted.push({ url: url2, kind });
24828
+ } catch {
24829
+ }
24830
+ };
24831
+ iconLinks(html).forEach((h) => add(h, "icon"));
24832
+ add(`${origin}/favicon.ico`, "icon");
24833
+ add(logoInPage(html), "logo");
24834
+ const saved = [];
24835
+ const icons = join9(dir, "icons");
24836
+ for (const w of wanted.slice(0, 6)) {
24837
+ const res = await get(w.url, "image/*,*/*;q=0.8");
24838
+ if (!res?.ok) continue;
24839
+ const bytes = Buffer.from(await res.arrayBuffer());
24840
+ if (bytes.length > ICON_MAX_BYTES) continue;
24841
+ const size = imageSize(bytes);
24842
+ const svg = !size && isSvgText(bytes.subarray(0, 2048).toString("utf8"));
24843
+ if (!size && !svg) continue;
24844
+ const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
24845
+ mkdirSync4(icons, { recursive: true });
24846
+ writeFileSync6(join9(icons, file2), bytes);
24847
+ saved.push({ file: file2, kind: w.kind });
24848
+ }
24849
+ if (saved.length) writeFileSync6(join9(icons, "icons.json"), JSON.stringify(saved, null, 2));
24850
+ return saved.length;
24851
+ }
24852
+ async function saveOldStyles(html, pageUrl, dir) {
24853
+ const styles = join9(dir, "styles");
24854
+ let n2 = 0;
24855
+ for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
24856
+ const res = await get(url2, "text/css,*/*;q=0.8");
24857
+ if (!res?.ok) continue;
24858
+ const text = await res.text();
24859
+ if (text.length > ICON_MAX_BYTES) continue;
24860
+ mkdirSync4(styles, { recursive: true });
24861
+ writeFileSync6(join9(styles, `${++n2}.css`), text);
24862
+ }
24863
+ }
24511
24864
  async function migrateScanCommand(root, raw, opts = {}) {
24512
24865
  const source = normalizeSourceUrl(raw);
24513
24866
  if (!source) throw new CliError(`Not a site address: ${raw}. Use the full address, for example https://example.co.il`, 1, "usage");
@@ -24526,7 +24879,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
24526
24879
  out(`Scanning ${base} (${platform3})`);
24527
24880
  const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
24528
24881
  const robots = robotsRes?.ok ? await robotsRes.text() : "";
24529
- if (robots) writeFileSync6(join8(dir, "robots.txt"), robots);
24882
+ if (robots) writeFileSync6(join9(dir, "robots.txt"), robots);
24530
24883
  const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
24531
24884
  const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
24532
24885
  const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
@@ -24553,22 +24906,25 @@ async function migrateScanCommand(root, raw, opts = {}) {
24553
24906
  await Promise.all(Array.from({ length: SCAN_WORKERS }, worker));
24554
24907
  const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
24555
24908
  if (wordpressApi) {
24556
- const media = readJson2(join8(dir, "content", "media.json")) ?? [];
24909
+ const media = readJson2(join9(dir, "content", "media.json")) ?? [];
24557
24910
  media.forEach((m) => m.source_url && assets.add(m.source_url));
24558
24911
  }
24559
24912
  const inventory = { source: base, platform: platform3, scannedAt: (/* @__PURE__ */ new Date()).toISOString(), sitemaps: fromSitemaps.sitemaps, pages, wordpressApi, skipped: Math.max(0, all.length - list.length) };
24560
- writeJson(join8(dir, "inventory.json"), inventory);
24561
- writeJson(join8(dir, "assets.json"), [...assets].sort());
24562
- writeFileSync6(join8(dir, "home.html"), html);
24913
+ writeJson(join9(dir, "inventory.json"), inventory);
24914
+ writeJson(join9(dir, "assets.json"), [...assets].sort());
24915
+ writeFileSync6(join9(dir, "home.html"), html);
24916
+ const icons = await saveOldIcons(html, home.url, origin, dir);
24917
+ await saveOldStyles(html, home.url, dir);
24563
24918
  const rel = relative(root, dir).split(sep).join("/");
24564
24919
  const broken = pages.filter((p) => p.status >= 400).length;
24565
24920
  out();
24566
24921
  out(`Saved in ${rel}:`);
24567
24922
  out(` inventory.json ${pages.length} pages with their address, title, description and headings${broken ? ` (${broken} already broken on the old site)` : ""}`);
24568
24923
  out(` assets.json ${assets.size} images and files`);
24924
+ if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
24569
24925
  if (wordpressApi) {
24570
24926
  out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
24571
- if (existsSync8(join8(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
24927
+ if (existsSync9(join9(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
24572
24928
  } else if (platform3 === "wordpress") out(" The WordPress API is closed on this site: work from the pages, or ask the owner for an export (Tools > Export).");
24573
24929
  out();
24574
24930
  out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
@@ -24587,8 +24943,8 @@ async function migrateMediaCommand(root) {
24587
24943
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
24588
24944
  for (const host of hosts) {
24589
24945
  const dir = hostDir(root, host);
24590
- const assets = readJson2(join8(dir, "assets.json")) ?? [];
24591
- const stateFile = join8(dir, "media-state.json");
24946
+ const assets = readJson2(join9(dir, "assets.json")) ?? [];
24947
+ const stateFile = join9(dir, "media-state.json");
24592
24948
  const state = readJson2(stateFile) ?? { done: [], failed: [], bytes: 0 };
24593
24949
  const done = new Set(state.done);
24594
24950
  const todo = assets.filter((a) => !done.has(a));
@@ -24617,7 +24973,7 @@ async function migrateMediaCommand(root) {
24617
24973
  }
24618
24974
  state.done = [...done];
24619
24975
  writeJson(stateFile, state);
24620
- out(` ${formatBytes(state.bytes)} in ${relative(root, join8(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
24976
+ out(` ${formatBytes(state.bytes)} in ${relative(root, join9(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
24621
24977
  }
24622
24978
  out("Copy the files the new pages use into the site's public folder at the same path (for example public/wp-content/uploads/...), so old image addresses keep working.");
24623
24979
  }
@@ -24640,12 +24996,12 @@ function migrateRedirectsCommand(root) {
24640
24996
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
24641
24997
  const lines = /* @__PURE__ */ new Set();
24642
24998
  for (const host of hosts) {
24643
- const inv = readJson2(join8(hostDir(root, host), "inventory.json"));
24999
+ const inv = readJson2(join9(hostDir(root, host), "inventory.json"));
24644
25000
  if (inv) redirectLines(inv).forEach((l) => lines.add(l));
24645
25001
  }
24646
- const publicDir = join8(root, "public");
24647
- const file2 = join8(existsSync8(publicDir) ? publicDir : root, "_redirects");
24648
- const before = existsSync8(file2) ? readFileSync7(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
25002
+ const publicDir = join9(root, "public");
25003
+ const file2 = join9(existsSync9(publicDir) ? publicDir : root, "_redirects");
25004
+ const before = existsSync9(file2) ? readFileSync7(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
24649
25005
  const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
24650
25006
  writeFileSync6(file2, [...before, ...added].join("\n") + "\n");
24651
25007
  out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
@@ -24653,8 +25009,8 @@ function migrateRedirectsCommand(root) {
24653
25009
  }
24654
25010
  function allowedRedirects(root) {
24655
25011
  const map2 = /* @__PURE__ */ new Map();
24656
- for (const file2 of [join8(root, "public", "_redirects"), join8(root, "_redirects")]) {
24657
- if (!existsSync8(file2)) continue;
25012
+ for (const file2 of [join9(root, "public", "_redirects"), join9(root, "_redirects")]) {
25013
+ if (!existsSync9(file2)) continue;
24658
25014
  for (const line of readFileSync7(file2, "utf8").split(/\r?\n/)) {
24659
25015
  const [from, to] = line.trim().split(/\s+/);
24660
25016
  if (from && to && !from.startsWith("#")) map2.set(from, to);
@@ -24681,7 +25037,7 @@ async function migrateVerifyCommand(root, previewRaw) {
24681
25037
  const findings = [];
24682
25038
  let checked = 0;
24683
25039
  for (const host of hosts) {
24684
- const inv = readJson2(join8(hostDir(root, host), "inventory.json"));
25040
+ const inv = readJson2(join9(hostDir(root, host), "inventory.json"));
24685
25041
  for (const old of inv?.pages ?? []) {
24686
25042
  if (old.status >= 300) continue;
24687
25043
  const res = await get(previewUrl(preview, old.path));
@@ -24700,13 +25056,13 @@ async function migrateVerifyCommand(root, previewRaw) {
24700
25056
  }
24701
25057
  }
24702
25058
  const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
24703
- const report = join8(root, MIGRATION_DIR, "verify.json");
24704
- writeJson(report, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings });
25059
+ const report2 = join9(root, MIGRATION_DIR, "verify.json");
25060
+ writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings });
24705
25061
  if (!findings.length) {
24706
25062
  out(`All ${checked} old addresses open on the preview with their title and description.`);
24707
25063
  return;
24708
25064
  }
24709
- out(`${findings.length} of ${checked} old addresses need a fix (also in ${relative(root, report).split(sep).join("/")}):`);
25065
+ out(`${findings.length} of ${checked} old addresses need a fix (also in ${relative(root, report2).split(sep).join("/")}):`);
24710
25066
  for (const f of findings.slice(0, 60)) out(` ${f.path} ${words[f.problem]}${f.detail ? ` ${f.detail}` : ""}`);
24711
25067
  if (findings.length > 60) out(` and ${findings.length - 60} more in verify.json`);
24712
25068
  out("Give each page its old address back (or, only if it truly cannot stay, a line in public/_redirects), deploy again, and run verify again.");
@@ -25217,6 +25573,10 @@ async function prepare(root, ctx, maxBytes) {
25217
25573
  }
25218
25574
  return { archive, info, hasSql: plan.files.some((f) => SQL_FILE.test(f.rel) && !f.rel.includes("node_modules/")) };
25219
25575
  }
25576
+ function addTool(form, ctx) {
25577
+ const tool = telemetryEnabled(ctx.config) ? deployToolFromEnv(process.env) : null;
25578
+ if (tool) form.append("tool", tool);
25579
+ }
25220
25580
  async function deployVersion(root, ctx, opts, guest) {
25221
25581
  requireToken(ctx);
25222
25582
  const project = readProject(root);
@@ -25237,6 +25597,7 @@ async function deployVersion(root, ctx, opts, guest) {
25237
25597
  form.append("message", message);
25238
25598
  const fixed = (opts.fixed ?? "").replace(/\s+/g, " ").trim().slice(0, 300);
25239
25599
  if (fixed && telemetryEnabled(ctx.config)) form.append("fixNote", fixed);
25600
+ addTool(form, ctx);
25240
25601
  form.append("archive", new Blob([new Uint8Array(archive)], { type: "application/gzip" }), "source.tar.gz");
25241
25602
  const res = await apiRequest(ctx, "/api/cli/deploy", DeployResponse, { method: "POST", form, timeoutMs: 5 * 6e4 });
25242
25603
  out();
@@ -25350,6 +25711,7 @@ async function deployGuest(root, ctx, opts) {
25350
25711
  out(t("uploading"));
25351
25712
  const form = new FormData();
25352
25713
  form.append("message", message);
25714
+ addTool(form, ctx);
25353
25715
  form.append("archive", new Blob([new Uint8Array(archive)], { type: "application/gzip" }), "source.tar.gz");
25354
25716
  const res = await apiRequest(ctx, "/api/cli/guest", GuestResponse, { method: "POST", form, auth: false, timeoutMs: 5 * 6e4 });
25355
25717
  updateConfig({ guestTokens: { ...ctx.config.guestTokens ?? {}, [res.projectId]: res.token }, guestClaims: { ...ctx.config.guestClaims ?? {}, [res.projectId]: res.claimUrl } });
@@ -25390,13 +25752,13 @@ async function claimCommand(root, ctx, opts) {
25390
25752
 
25391
25753
  // src/commands/pull.ts
25392
25754
  import { spawnSync as spawnSync2 } from "child_process";
25393
- import { existsSync as existsSync10, readdirSync as readdirSync5, rmSync } from "fs";
25394
- import { join as join10 } from "path";
25755
+ import { existsSync as existsSync11, readdirSync as readdirSync5, rmSync } from "fs";
25756
+ import { join as join11 } from "path";
25395
25757
 
25396
25758
  // src/commands/samples.ts
25397
25759
  import { createInterface as createInterface3 } from "readline/promises";
25398
- import { existsSync as existsSync9, mkdirSync as mkdirSync5, readdirSync as readdirSync4, writeFileSync as writeFileSync7 } from "fs";
25399
- import { dirname as dirname3, join as join9, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
25760
+ import { existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync as readdirSync4, writeFileSync as writeFileSync7 } from "fs";
25761
+ import { dirname as dirname3, join as join10, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
25400
25762
  import { gunzipSync } from "zlib";
25401
25763
  var SAMPLES = [
25402
25764
  { key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
@@ -25417,7 +25779,7 @@ function listSamples(apiUrl) {
25417
25779
  out(`See them live: ${apiUrl}/samples`);
25418
25780
  }
25419
25781
  function filesIn(dir) {
25420
- return existsSync9(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
25782
+ return existsSync10(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
25421
25783
  }
25422
25784
  function freeFolder(cwd, key) {
25423
25785
  for (let n2 = 1; ; n2++) {
@@ -25501,7 +25863,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
25501
25863
  }
25502
25864
  const written = await downloadSample(ctx, sample.key, root);
25503
25865
  const base = resolve2(root);
25504
- const hasPackage = existsSync9(join9(base, "package.json"));
25866
+ const hasPackage = existsSync10(join10(base, "package.json"));
25505
25867
  out(base === resolve2(cwd) ? `Downloaded the ${sample.key} sample: ${written} files.` : `Downloaded the ${sample.key} sample into the new folder ${relative2(cwd, base)}: ${written} files. Work in that folder from now on.`);
25506
25868
  out("");
25507
25869
  const t = messages(base);
@@ -25558,7 +25920,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
25558
25920
  function clearTree(root) {
25559
25921
  for (const name of readdirSync5(root)) {
25560
25922
  if (name === ".git" || name === ".deployai") continue;
25561
- rmSync(join10(root, name), { recursive: true, force: true });
25923
+ rmSync(join11(root, name), { recursive: true, force: true });
25562
25924
  }
25563
25925
  }
25564
25926
  async function pullHistory(root, ctx, projectId) {
@@ -25568,7 +25930,7 @@ async function pullHistory(root, ctx, projectId) {
25568
25930
  const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
25569
25931
  const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
25570
25932
  if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
25571
- if (!existsSync10(join10(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
25933
+ if (!existsSync11(join11(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
25572
25934
  for (const v of chosen) {
25573
25935
  const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
25574
25936
  if (!gz) continue;
@@ -25585,12 +25947,12 @@ async function pullHistory(root, ctx, projectId) {
25585
25947
 
25586
25948
  // src/commands/start.ts
25587
25949
  import { spawnSync as spawnSync3 } from "child_process";
25588
- import { existsSync as existsSync11, writeFileSync as writeFileSync9 } from "fs";
25589
- import { join as join12, relative as relative3, resolve as resolve3 } from "path";
25950
+ import { existsSync as existsSync12, writeFileSync as writeFileSync9 } from "fs";
25951
+ import { join as join13, relative as relative3, resolve as resolve3 } from "path";
25590
25952
 
25591
25953
  // src/commands/starter.ts
25592
25954
  import { writeFileSync as writeFileSync8 } from "fs";
25593
- import { join as join11 } from "path";
25955
+ import { join as join12 } from "path";
25594
25956
  var esc2 = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
25595
25957
  var TEXT = {
25596
25958
  he: { title: "\u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05D9", soon: "\u05D4\u05D0\u05EA\u05E8 \u05D1\u05D1\u05E0\u05D9\u05D9\u05D4, \u05D1\u05E7\u05E8\u05D5\u05D1 \u05DB\u05D0\u05DF." },
@@ -25638,8 +26000,8 @@ DeployAI wrote this page so the folder starts as a working site. Build the owner
25638
26000
  - Delete this README or replace it with notes about the site.
25639
26001
  `;
25640
26002
  function writeStarter(root, name, lang, stack) {
25641
- writeFileSync8(join11(root, "index.html"), page(name ?? "", lang, stack));
25642
- writeFileSync8(join11(root, "README.md"), README);
26003
+ writeFileSync8(join12(root, "index.html"), page(name ?? "", lang, stack));
26004
+ writeFileSync8(join12(root, "README.md"), README);
25643
26005
  }
25644
26006
 
25645
26007
  // src/commands/start.ts
@@ -25697,7 +26059,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
25697
26059
  if (sample && !sameSite) {
25698
26060
  const written = await downloadSample(ctxNow, sample.key, root);
25699
26061
  done.push(t("startDownloaded", { key: sample.key, n: written }));
25700
- if (existsSync11(join12(root, "package.json"))) {
26062
+ if (existsSync12(join13(root, "package.json"))) {
25701
26063
  if (opts.install !== false && install(root)) done.push(t("startInstalled"));
25702
26064
  else steps.unshift({ cmd: "npm install", say: "Installs the sample's packages." });
25703
26065
  }
@@ -25722,7 +26084,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
25722
26084
  const stackText = choices.stack ? stackBlock(choices.stack) : "";
25723
26085
  if (choices.brief || stackText) {
25724
26086
  ensureDeployaiDir(root);
25725
- writeFileSync9(join12(root, BRIEF_FILE), [choices.brief ? `# The owner's details
26087
+ writeFileSync9(join13(root, BRIEF_FILE), [choices.brief ? `# The owner's details
25726
26088
 
25727
26089
  ${choices.brief}
25728
26090
  ` : "", stackText].filter(Boolean).join("\n"));
@@ -25865,16 +26227,16 @@ async function addonRunCommand(root, ctx, key) {
25865
26227
  }
25866
26228
  async function addonDoneCommand(root, ctx, runId, opts) {
25867
26229
  requireToken(ctx);
25868
- let report;
26230
+ let report2;
25869
26231
  if (opts.report) {
25870
26232
  try {
25871
- report = JSON.parse(readFileSync9(resolve4(root, opts.report), "utf8"));
26233
+ report2 = JSON.parse(readFileSync9(resolve4(root, opts.report), "utf8"));
25872
26234
  } catch {
25873
26235
  throw new CliError(`Cannot read the report file ${opts.report} as JSON.`, 1, "usage");
25874
26236
  }
25875
- if (!AddonReport.safeParse(report).success) throw new CliError('The report file does not match the format: {"summary", "changed", "unresolved", "unsupported", "checks"}.', 1, "usage");
26237
+ if (!AddonReport.safeParse(report2).success) throw new CliError('The report file does not match the format: {"summary", "changed", "unresolved", "unsupported", "checks"}.', 1, "usage");
25876
26238
  }
25877
- const body = AddonDoneRequest.safeParse({ status: opts.status ?? "done", report });
26239
+ const body = AddonDoneRequest.safeParse({ status: opts.status ?? "done", report: report2 });
25878
26240
  if (!body.success) throw new CliError("Status must be done, failed or skipped.", 1, "usage");
25879
26241
  const r = await apiRequest(ctx, `/api/cli/addons/runs/${encodeURIComponent(runId.trim())}`, AddonDoneResponse, { method: "POST", body: body.data });
25880
26242
  out(`Saved: add-on ${body.data.status}.`);
@@ -25925,7 +26287,7 @@ async function speedCommand(ctx, url2, opts) {
25925
26287
  }
25926
26288
 
25927
26289
  // src/commands/blocks.ts
25928
- import { existsSync as existsSync12, mkdirSync as mkdirSync6, writeFileSync as writeFileSync10 } from "fs";
26290
+ import { existsSync as existsSync13, mkdirSync as mkdirSync6, writeFileSync as writeFileSync10 } from "fs";
25929
26291
  import { dirname as dirname4, resolve as resolve5, sep as sep3 } from "path";
25930
26292
  import { gunzipSync as gunzipSync2 } from "zlib";
25931
26293
  var BLOCKS = [
@@ -25966,7 +26328,7 @@ async function blocksCommand(root, ctx, name) {
25966
26328
  if (e2.type !== "0" && e2.type !== "\0") continue;
25967
26329
  const target = resolve5(base, e2.name);
25968
26330
  if (target === base || !target.startsWith(base + sep3)) continue;
25969
- if (existsSync12(target)) {
26331
+ if (existsSync13(target)) {
25970
26332
  kept.push(e2.name);
25971
26333
  continue;
25972
26334
  }
@@ -25983,6 +26345,600 @@ async function blocksCommand(root, ctx, name) {
25983
26345
  out(`Read .deployai/blocks/${block.key}.md and follow it: it says what to wire and what to set.`);
25984
26346
  }
25985
26347
 
26348
+ // src/commands/brand.ts
26349
+ import { spawn as spawn2 } from "child_process";
26350
+ import { copyFileSync, existsSync as existsSync14, mkdirSync as mkdirSync7, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync10, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync11 } from "fs";
26351
+ import { createServer } from "http";
26352
+ import { tmpdir } from "os";
26353
+ import { basename, dirname as dirname5, extname, join as join14, relative as relative4, sep as sep4 } from "path";
26354
+ import { randomBytes } from "crypto";
26355
+
26356
+ // src/commands/brand-page.ts
26357
+ var embed = (v) => JSON.stringify(v).replace(/</g, "\\u003c");
26358
+ function drawPageHtml(state) {
26359
+ return `<!doctype html>
26360
+ <html>
26361
+ <head><meta charset="utf-8"><meta name="robots" content="noindex"><title>DeployAI</title></head>
26362
+ <body>
26363
+ <script>
26364
+ const S = ${embed(state)};
26365
+ const canDraw = ${canDraw.toString()};
26366
+ const ink = ${contrastInk.toString()};
26367
+ const api = (path) => path + (path.includes('?') ? '&' : '?') + 't=' + S.token;
26368
+ let source = null;
26369
+ let vector = false;
26370
+
26371
+ function load(url) {
26372
+ return new Promise((ok, fail) => { const i = new Image(); i.onload = () => ok(i); i.onerror = fail; i.src = url; });
26373
+ }
26374
+ function fit(ctx, text, weight, size, maxWidth) {
26375
+ let px = size;
26376
+ do { ctx.font = weight + ' ' + px + 'px system-ui, Arial, sans-serif'; px -= 2; } while (ctx.measureText(text).width > maxWidth && px > 16);
26377
+ }
26378
+ function contain(ctx, box) {
26379
+ const w = source.naturalWidth || box.w, h = source.naturalHeight || box.h;
26380
+ // A raster is never stretched past twice its size: a small logo stays small and sharp on the share image.
26381
+ const k = Math.min(box.w / w, box.h / h, vector ? Infinity : 2);
26382
+ const dw = w * k, dh = h * k;
26383
+ ctx.drawImage(source, box.x + (box.w - dw) / 2, box.y + (box.h - dh) / 2, dw, dh);
26384
+ }
26385
+ function draw(t) {
26386
+ const c = document.createElement('canvas');
26387
+ c.width = t.width; c.height = t.height;
26388
+ const ctx = c.getContext('2d');
26389
+ ctx.imageSmoothingQuality = 'high';
26390
+ if (t.opaque) { ctx.fillStyle = S.color; ctx.fillRect(0, 0, t.width, t.height); }
26391
+ if (t.og) {
26392
+ const words = S.name.trim(), sub = S.line.trim();
26393
+ contain(ctx, { x: 450, y: words ? 96 : 165, w: 300, h: 300 });
26394
+ ctx.fillStyle = ink(S.color);
26395
+ ctx.textAlign = 'center';
26396
+ ctx.direction = /[\\u0590-\\u05FF]/.test(words + sub) ? 'rtl' : 'ltr';
26397
+ if (words) { fit(ctx, words, 700, 72, 1040); ctx.fillText(words, 600, sub ? 480 : 500); }
26398
+ if (sub) { fit(ctx, sub, 500, 38, 1040); ctx.fillText(sub, 600, 545); }
26399
+ } else {
26400
+ const p = Math.round(t.width * (t.pad || 0));
26401
+ contain(ctx, { x: p, y: p, w: t.width - 2 * p, h: t.height - 2 * p });
26402
+ }
26403
+ return c;
26404
+ }
26405
+ async function run() {
26406
+ const res = await fetch(api('/source'));
26407
+ vector = /svg/.test(res.headers.get('content-type') || '');
26408
+ source = await load(URL.createObjectURL(await res.blob()));
26409
+ const skipped = [];
26410
+ for (const t of S.targets) {
26411
+ if (!canDraw(t, { width: source.naturalWidth, height: source.naturalHeight, vector })) { skipped.push(t.file); continue; }
26412
+ const blob = await new Promise((ok) => draw(t).toBlob(ok, 'image/png'));
26413
+ const r = await fetch(api('/save?file=' + encodeURIComponent(t.file)), { method: 'POST', body: blob });
26414
+ if (!r.ok) throw new Error(t.file);
26415
+ }
26416
+ const r = await fetch(api('/done'), { method: 'POST', body: JSON.stringify({ skipped }) });
26417
+ if (!r.ok) throw new Error('done');
26418
+ }
26419
+ run().catch((e) => { fetch(api('/fail'), { method: 'POST', body: String(e) }); });
26420
+ </script>
26421
+ </body>
26422
+ </html>
26423
+ `;
26424
+ }
26425
+ function measureScript(endpoint) {
26426
+ return `<script>(function(){
26427
+ var sent=false;
26428
+ function send(){if(sent)return;sent=true;
26429
+ var seen=[];document.querySelectorAll('img').forEach(function(i){var r=i.getBoundingClientRect();if(i.currentSrc&&i.naturalWidth&&r.width>0)seen.push({src:i.currentSrc,width:i.naturalWidth,height:i.naturalHeight,shownWidth:Math.round(r.width),alt:i.alt||''})});
26430
+ fetch(${embed(endpoint)},{method:'POST',body:JSON.stringify(seen),keepalive:true});}
26431
+ function go(){document.querySelectorAll('img').forEach(function(i){i.loading='eager'});setTimeout(send,2500)}
26432
+ if(document.readyState==='complete')go();else addEventListener('load',go);
26433
+ setTimeout(send,12000);
26434
+ })();</script>`;
26435
+ }
26436
+
26437
+ // src/commands/brand.ts
26438
+ var BRAND_DIR = ".deployai/brand";
26439
+ var IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
26440
+ var MAX_UPLOAD = 25 * 1024 * 1024;
26441
+ var WALK_CAP = 4e3;
26442
+ var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", ".output", ".svelte-kit", ".wrangler", ".deployai"]);
26443
+ var TYPES = { ".svg": "image/svg+xml", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".gif": "image/gif", ".ico": "image/x-icon", ".avif": "image/avif" };
26444
+ function webRoot(root) {
26445
+ for (const d of ["public", "static"]) if (existsSync14(join14(root, d))) return join14(root, d);
26446
+ return root;
26447
+ }
26448
+ function walk(dir, found = []) {
26449
+ let names;
26450
+ try {
26451
+ names = readdirSync6(dir);
26452
+ } catch {
26453
+ return found;
26454
+ }
26455
+ for (const n2 of names) {
26456
+ if (found.length >= WALK_CAP) break;
26457
+ const p = join14(dir, n2);
26458
+ let isDir = false;
26459
+ try {
26460
+ isDir = statSync2(p).isDirectory();
26461
+ } catch {
26462
+ continue;
26463
+ }
26464
+ if (isDir) {
26465
+ if (!SKIP_DIRS2.has(n2)) walk(p, found);
26466
+ } else found.push(p);
26467
+ }
26468
+ return found;
26469
+ }
26470
+ function existingFavicon(root) {
26471
+ const web = webRoot(root);
26472
+ for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync14(join14(web, f))) return relative4(root, join14(web, f)).split(sep4).join("/");
26473
+ for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync14(join14(root, d, f))) return `${d}/${f}`;
26474
+ for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
26475
+ try {
26476
+ const m = readFileSync10(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
26477
+ if (!m) continue;
26478
+ const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
26479
+ if (href.startsWith("data:") || /^https?:/.test(href) || existsSync14(join14(web, href.split("?")[0]))) return relative4(root, f).split(sep4).join("/");
26480
+ } catch {
26481
+ }
26482
+ }
26483
+ return null;
26484
+ }
26485
+ function scannedIcons(root) {
26486
+ const base = join14(root, MIGRATION_DIR);
26487
+ if (!existsSync14(base)) return [];
26488
+ const found = [];
26489
+ for (const host of readdirSync6(base)) {
26490
+ const dir = join14(base, host, "icons");
26491
+ try {
26492
+ const list = JSON.parse(readFileSync10(join14(dir, "icons.json"), "utf8"));
26493
+ for (const i of list) {
26494
+ const path = join14(dir, i.file);
26495
+ if (!existsSync14(path)) continue;
26496
+ const size = imageSize(readFileSync10(path));
26497
+ found.push({ path, kind: i.kind, big: !size || size.width >= 64 });
26498
+ }
26499
+ } catch {
26500
+ }
26501
+ }
26502
+ return found;
26503
+ }
26504
+ function findSource(root) {
26505
+ const icons = scannedIcons(root);
26506
+ const sharp = icons.find((i) => i.kind === "icon" && i.big);
26507
+ if (sharp) return { path: sharp.path, from: "old-icon" };
26508
+ const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join14(root, d));
26509
+ const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative4(root, p).split(sep4).join("/")));
26510
+ const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
26511
+ if (logo) return { path: logo, from: "logo" };
26512
+ const oldLogo = icons.find((i) => i.kind === "logo");
26513
+ if (oldLogo) return { path: oldLogo.path, from: "old-logo" };
26514
+ const small = icons.find((i) => i.kind === "icon");
26515
+ if (small) return { path: small.path, from: "old-icon" };
26516
+ return { path: null, from: "letter" };
26517
+ }
26518
+ var CODE_EXT2 = /\.(css|scss|sass|less|html|astro|vue|svelte)$/i;
26519
+ var READ_CAP = 300;
26520
+ function readText(path) {
26521
+ try {
26522
+ return readFileSync10(path, "utf8");
26523
+ } catch {
26524
+ return "";
26525
+ }
26526
+ }
26527
+ function scanDirs(root) {
26528
+ const base = join14(root, MIGRATION_DIR);
26529
+ try {
26530
+ return readdirSync6(base).map((h) => join14(base, h)).filter((d) => existsSync14(join14(d, "home.html")));
26531
+ } catch {
26532
+ return [];
26533
+ }
26534
+ }
26535
+ function homePage(root) {
26536
+ for (const d of scanDirs(root)) return readText(join14(d, "home.html"));
26537
+ for (const f of ["index.html", "public/index.html", "src/index.html", "src/pages/index.astro", "src/pages/index.html", "app/layout.tsx", "src/app/layout.tsx", "src/layouts/Layout.astro"]) {
26538
+ const text = readText(join14(root, f));
26539
+ if (text) return text;
26540
+ }
26541
+ return "";
26542
+ }
26543
+ function siteFacts(root, given = {}) {
26544
+ if (given.color !== void 0 && !/^#[0-9a-f]{6}$/i.test(given.color)) throw new CliError(`Not a color: ${given.color}. Use the form #112233.`, 1, "usage");
26545
+ const home = homePage(root);
26546
+ const id = readSiteIdentity(home);
26547
+ let pkg;
26548
+ try {
26549
+ pkg = JSON.parse(readFileSync10(join14(root, "package.json"), "utf8")).name;
26550
+ } catch {
26551
+ }
26552
+ const name = given.name?.trim() || readProject(root)?.name || id.name || (pkg && !pkg.startsWith("@") ? pkg : "") || basename(root);
26553
+ if (given.color) return { name, line: given.line ?? id.line ?? "", color: given.color, colorFrom: "given" };
26554
+ const old = scanDirs(root).flatMap((d) => walkAll(join14(d, "styles")).map((f) => ({ text: readText(f) })));
26555
+ const fromOld = scanDirs(root).length ? pickBrandColor([{ text: home, themeColor: id.themeColor }, ...old]) : null;
26556
+ const sources = [{ text: home, themeColor: id.themeColor }];
26557
+ for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText(join14(root, f)) });
26558
+ const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(join14(root, d))).filter((p) => CODE_EXT2.test(p));
26559
+ const plain2 = readdirSync6(root).filter((f) => CODE_EXT2.test(f)).map((f) => join14(root, f));
26560
+ for (const f of [...plain2, ...code].slice(0, READ_CAP)) sources.push({ text: readText(f) });
26561
+ const color = fromOld ?? pickBrandColor(sources);
26562
+ return { name, line: given.line ?? id.line ?? "", color: color ?? BRAND_DEFAULT_COLOR, colorFrom: color ? "site" : "default" };
26563
+ }
26564
+ function writeSiteFile(root, file2, data) {
26565
+ const target = join14(webRoot(root), file2);
26566
+ if (existsSync14(target)) {
26567
+ const keep = join14(root, BRAND_DIR, "originals");
26568
+ mkdirSync7(keep, { recursive: true });
26569
+ copyFileSync(target, join14(keep, file2));
26570
+ }
26571
+ mkdirSync7(dirname5(target), { recursive: true });
26572
+ writeFileSync11(target, data);
26573
+ }
26574
+ var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
26575
+ res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
26576
+ res.end(body);
26577
+ };
26578
+ function readBody(req) {
26579
+ return new Promise((ok, fail) => {
26580
+ const parts = [];
26581
+ let size = 0;
26582
+ req.on("data", (c) => {
26583
+ size += c.length;
26584
+ if (size > MAX_UPLOAD) {
26585
+ req.destroy();
26586
+ fail(new Error("too large"));
26587
+ } else parts.push(c);
26588
+ });
26589
+ req.on("end", () => ok(Buffer.concat(parts)));
26590
+ req.on("error", fail);
26591
+ });
26592
+ }
26593
+ function listen(server) {
26594
+ return new Promise((ok, fail) => {
26595
+ server.once("error", fail);
26596
+ server.listen(0, "127.0.0.1", () => {
26597
+ const a = server.address();
26598
+ if (a && typeof a === "object") ok(a.port);
26599
+ else fail(new Error("no port"));
26600
+ });
26601
+ });
26602
+ }
26603
+ function allowed(req, url2, port, token) {
26604
+ return req.headers.host === `127.0.0.1:${port}` && url2.searchParams.get("t") === token;
26605
+ }
26606
+ async function headless(browser, url2, width, until, timeoutMs) {
26607
+ const profile = mkdtempSync(join14(tmpdir(), "deployai-brand-"));
26608
+ const child = spawn2(browser, ["--headless=new", "--disable-gpu", "--no-first-run", "--no-default-browser-check", "--disable-extensions", `--user-data-dir=${profile}`, `--window-size=${width},900`, url2], { stdio: "ignore", windowsHide: true });
26609
+ child.on("error", () => {
26610
+ });
26611
+ let timer;
26612
+ try {
26613
+ await Promise.race([until, new Promise((_, fail) => {
26614
+ timer = setTimeout(() => fail(new Error("timeout")), timeoutMs);
26615
+ })]);
26616
+ } finally {
26617
+ if (timer) clearTimeout(timer);
26618
+ await new Promise((done) => {
26619
+ if (child.exitCode !== null || child.pid === void 0) return done();
26620
+ child.once("exit", () => done());
26621
+ if (process.platform === "win32") spawn2("taskkill", ["/PID", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on("error", () => {
26622
+ });
26623
+ else child.kill();
26624
+ setTimeout(done, 3e3);
26625
+ });
26626
+ try {
26627
+ rmSync2(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });
26628
+ } catch {
26629
+ }
26630
+ }
26631
+ }
26632
+ async function drawInBrowser(o, browser) {
26633
+ const token = randomBytes(24).toString("hex");
26634
+ const parts = /* @__PURE__ */ new Map();
26635
+ const source = o.source;
26636
+ let port = 0;
26637
+ let finish;
26638
+ let abort;
26639
+ const finished = new Promise((ok, fail) => {
26640
+ finish = ok;
26641
+ abort = fail;
26642
+ });
26643
+ const allowedFiles = new Set(o.targets.map((t) => t.file));
26644
+ const server = createServer((req, res) => {
26645
+ void (async () => {
26646
+ const url2 = new URL(req.url ?? "/", "http://127.0.0.1");
26647
+ if (!allowed(req, url2, port, token)) return send(res, 403);
26648
+ if (req.method === "GET" && url2.pathname === "/") {
26649
+ return send(res, 200, drawPageHtml({ token, name: o.name, line: o.line, color: o.color, targets: o.targets }), "text/html; charset=utf-8");
26650
+ }
26651
+ if (req.method === "GET" && url2.pathname === "/source") return send(res, 200, source.bytes, source.type);
26652
+ if (req.method !== "POST") return send(res, 404);
26653
+ const body = await readBody(req);
26654
+ if (url2.pathname === "/save") {
26655
+ const file2 = url2.searchParams.get("file") ?? "";
26656
+ if (!allowedFiles.has(file2) || !imageSize(body)) return send(res, 400);
26657
+ parts.set(file2, body);
26658
+ return send(res, 204);
26659
+ }
26660
+ if (url2.pathname === "/fail") {
26661
+ send(res, 204);
26662
+ return abort(new Error(body.toString("utf8").slice(0, 200)));
26663
+ }
26664
+ if (url2.pathname === "/done") {
26665
+ const done = JSON.parse(body.toString("utf8"));
26666
+ const written = [];
26667
+ for (const t of o.targets) {
26668
+ const png = parts.get(t.file);
26669
+ if (!png || t.icoOnly) continue;
26670
+ writeSiteFile(o.root, t.file, png);
26671
+ written.push(t.file);
26672
+ }
26673
+ const ico = ICO_SIZES.flatMap((size) => {
26674
+ const png = parts.get(`ico-${size}.png`);
26675
+ return png ? [{ size, png }] : [];
26676
+ });
26677
+ if (ico.length) {
26678
+ writeSiteFile(o.root, "favicon.ico", buildIco(ico));
26679
+ written.push("favicon.ico");
26680
+ }
26681
+ if (/svg/.test(source.type)) {
26682
+ writeSiteFile(o.root, "favicon.svg", source.bytes);
26683
+ written.push("favicon.svg");
26684
+ }
26685
+ if (o.full && parts.has("icon-192.png") && parts.has("icon-512.png")) {
26686
+ writeSiteFile(o.root, "site.webmanifest", webManifest(o.name, o.color));
26687
+ written.push("site.webmanifest");
26688
+ }
26689
+ send(res, 204);
26690
+ return finish({ written, skipped: done.skipped.filter((f) => !f.startsWith("ico-")) });
26691
+ }
26692
+ return send(res, 404);
26693
+ })().catch(() => {
26694
+ if (!res.headersSent) send(res, 400);
26695
+ });
26696
+ });
26697
+ port = await listen(server);
26698
+ try {
26699
+ await headless(browser, `http://127.0.0.1:${port}/?t=${token}`, 1280, finished, 45e3);
26700
+ return await finished;
26701
+ } finally {
26702
+ server.closeAllConnections();
26703
+ server.close();
26704
+ }
26705
+ }
26706
+ function sourceBytes(path) {
26707
+ return { bytes: readFileSync10(path), type: TYPES[extname(path).toLowerCase()] ?? "application/octet-stream" };
26708
+ }
26709
+ function report(root, r) {
26710
+ const where = relative4(root, webRoot(root)).split(sep4).join("/") || "the site root";
26711
+ out(`Written in ${where}: ${r.written.join(", ")}`);
26712
+ if (r.skipped.length) out(`Left out, the picture is too small to stay sharp: ${r.skipped.join(", ")}. A larger logo makes them.`);
26713
+ const tags2 = brandHeadTags(r.written);
26714
+ if (tags2.length) {
26715
+ out("");
26716
+ out("Add these lines to the <head> of every page, in place of any older icon lines:");
26717
+ tags2.forEach((t) => out(` ${t}`));
26718
+ }
26719
+ }
26720
+ function plainIcon(root, source, name, color) {
26721
+ if (source.path) {
26722
+ const ext = extname(source.path).toLowerCase();
26723
+ if (ext === ".ico" || ext === ".svg" || ext === ".png") {
26724
+ const file2 = `favicon${ext}`;
26725
+ writeSiteFile(root, file2, readFileSync10(source.path));
26726
+ return [file2];
26727
+ }
26728
+ }
26729
+ writeSiteFile(root, "favicon.svg", letterTileSvg(name, color));
26730
+ return ["favicon.svg"];
26731
+ }
26732
+ var FROM = {
26733
+ file: "the picture you named",
26734
+ "old-icon": "the old site's icon",
26735
+ logo: "the logo in this folder",
26736
+ "old-logo": "the old site's logo",
26737
+ letter: "the first letter of the name, since there is no icon or logo"
26738
+ };
26739
+ function printStatus2(root, files) {
26740
+ const web = webRoot(root);
26741
+ const icon = existingFavicon(root);
26742
+ out(icon ? `Icon: ${icon}` : "Icon: missing. Run: npx deployai@latest brand favicon");
26743
+ const missing = files.filter((f) => f !== "favicon.svg" && !existsSync14(join14(web, f)));
26744
+ if (files.length) out(missing.length ? `Missing from the full set: ${missing.join(", ")}` : "The full set is there.");
26745
+ }
26746
+ function printFacts(f, picture2) {
26747
+ const color = f.colorFrom === "site" ? `${f.color}, from the site's own colors` : f.colorFrom === "given" ? f.color : `${f.color}, since the site has no color of its own`;
26748
+ out(`Name: ${f.name}`);
26749
+ out(`Color: ${color}`);
26750
+ out(`Picture: ${picture2}`);
26751
+ }
26752
+ function picture(source, facts) {
26753
+ return source.path ? sourceBytes(source.path) : { bytes: new TextEncoder().encode(letterTileSvg(facts.name, facts.color)), type: "image/svg+xml" };
26754
+ }
26755
+ function withLogoColor(facts, source) {
26756
+ if (facts.colorFrom === "given" || !source.path || !/\.svg$/i.test(source.path)) return facts;
26757
+ const color = svgLogoColor(readText(source.path));
26758
+ return color ? { ...facts, color, colorFrom: "site" } : facts;
26759
+ }
26760
+ function pickSource(root, from) {
26761
+ const source = from ? { path: from, from: "file" } : findSource(root);
26762
+ if (source.path && !existsSync14(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
26763
+ return source;
26764
+ }
26765
+ async function brandFaviconCommand(root, opts) {
26766
+ if (opts.check) return printStatus2(root, []);
26767
+ const has = existingFavicon(root);
26768
+ if (has && !opts.force) {
26769
+ out(`This site has an icon: ${has}. Nothing changed.`);
26770
+ return;
26771
+ }
26772
+ const source = pickSource(root, opts.from);
26773
+ const facts = withLogoColor(siteFacts(root, opts), source);
26774
+ printFacts(facts, FROM[source.from]);
26775
+ const browser = findBrowser();
26776
+ let result = null;
26777
+ if (browser) {
26778
+ try {
26779
+ result = await drawInBrowser({ root, name: facts.name, line: "", color: facts.color, source: picture(source, facts), targets: FAVICON_TARGETS, full: false }, browser);
26780
+ } catch {
26781
+ out("The browser could not draw it, so the icon is kept as a plain file.");
26782
+ }
26783
+ }
26784
+ if (!result) result = { written: plainIcon(root, source, facts.name, facts.color), skipped: [] };
26785
+ report(root, result);
26786
+ if (source.from === "letter") out("Tell the owner in one line: the icon is the first letter of the name in the site's color, and a logo from them would replace it.");
26787
+ }
26788
+ async function brandIconsCommand(root, opts) {
26789
+ if (opts.check) return printStatus2(root, BRAND_FILES);
26790
+ const browser = findBrowser();
26791
+ if (!browser) throw new CliError("This needs Chrome or Edge on this computer. Install one, or set CHROME_PATH to it, and run this again.", 1, "usage");
26792
+ const source = pickSource(root, opts.from);
26793
+ const facts = withLogoColor(siteFacts(root, opts), source);
26794
+ printFacts(facts, FROM[source.from]);
26795
+ if (facts.line) out(`Line: ${facts.line}`);
26796
+ report(root, await drawInBrowser({ root, name: facts.name, line: facts.line, color: facts.color, source: picture(source, facts), targets: BRAND_TARGETS, full: true }, browser));
26797
+ }
26798
+ async function measurePage(browser, address, width, scripts) {
26799
+ const token = randomBytes(24).toString("hex");
26800
+ let port = 0;
26801
+ let finish;
26802
+ const finished = new Promise((ok) => {
26803
+ finish = ok;
26804
+ });
26805
+ const res = await fetch(address, { headers: { accept: "text/html" }, signal: AbortSignal.timeout(2e4) });
26806
+ const page2 = await res.text();
26807
+ const server = createServer((req, r) => {
26808
+ void (async () => {
26809
+ const url2 = new URL(req.url ?? "/", "http://127.0.0.1");
26810
+ if (!allowed(req, url2, port, token)) return send(r, 403);
26811
+ if (req.method === "POST" && url2.pathname === "/measure") {
26812
+ const body = await readBody(req);
26813
+ send(r, 204);
26814
+ return finish(JSON.parse(body.toString("utf8")));
26815
+ }
26816
+ const head = `<base href="${res.url.replace(/"/g, "&quot;")}">${measureScript(`http://127.0.0.1:${port}/measure?t=${token}`)}`;
26817
+ const noPolicy = page2.replace(/<meta[^>]+http-equiv=["']?content-security-policy[^>]*>/gi, "");
26818
+ const clean = scripts ? noPolicy : noPolicy.replace(/<script\b[\s\S]*?<\/script>/gi, "");
26819
+ const html = /<head[^>]*>/i.test(clean) ? clean.replace(/<head[^>]*>/i, (m) => m + head) : head + clean;
26820
+ return send(r, 200, html, "text/html; charset=utf-8");
26821
+ })().catch(() => {
26822
+ if (!r.headersSent) send(r, 400);
26823
+ });
26824
+ });
26825
+ port = await listen(server);
26826
+ try {
26827
+ await headless(browser, `http://127.0.0.1:${port}/?t=${token}`, width, finished, 3e4);
26828
+ return await finished;
26829
+ } finally {
26830
+ server.closeAllConnections();
26831
+ server.close();
26832
+ }
26833
+ }
26834
+ function imageFiles(root) {
26835
+ const dirs = [webRoot(root) === root ? null : webRoot(root), join14(root, "src"), join14(root, MIGRATION_DIR)].filter((d) => !!d);
26836
+ const files = dirs.flatMap((d) => walkAll(d));
26837
+ if (webRoot(root) === root) files.push(...walk(root));
26838
+ return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep4).includes("icons") && !BRAND_FILES.includes(basename(p)));
26839
+ }
26840
+ function walkAll(dir) {
26841
+ const found = [];
26842
+ const go = (d) => {
26843
+ let names = [];
26844
+ try {
26845
+ names = readdirSync6(d);
26846
+ } catch {
26847
+ return;
26848
+ }
26849
+ for (const n2 of names) {
26850
+ if (found.length >= WALK_CAP) return;
26851
+ const p = join14(d, n2);
26852
+ try {
26853
+ if (statSync2(p).isDirectory()) {
26854
+ if (!SKIP_DIRS2.has(n2) || n2 === ".deployai") go(p);
26855
+ } else found.push(p);
26856
+ } catch {
26857
+ }
26858
+ }
26859
+ };
26860
+ go(dir);
26861
+ return found;
26862
+ }
26863
+ function judgeFiles(root) {
26864
+ const findings = [];
26865
+ const files = imageFiles(root);
26866
+ let total = 0;
26867
+ for (const f of files) {
26868
+ let bytes;
26869
+ try {
26870
+ bytes = readFileSync10(f);
26871
+ } catch {
26872
+ continue;
26873
+ }
26874
+ const size = imageSize(bytes);
26875
+ if (!size) continue;
26876
+ total++;
26877
+ const verdict = judgeImage({ width: size.width, height: size.height, bytes: bytes.length, format: size.format });
26878
+ if (verdict !== "ok") findings.push({ where: relative4(root, f).split(sep4).join("/"), width: size.width, height: size.height, verdict });
26879
+ }
26880
+ return { findings, total };
26881
+ }
26882
+ var SAY = {
26883
+ ok: "fine",
26884
+ soft: "too few pixels for where it shows",
26885
+ small: "small, check where it shows",
26886
+ compressed: "squeezed until it shows blocks"
26887
+ };
26888
+ async function brandImagesCommand(root, urls, opts) {
26889
+ for (const u of urls) if (!/^https?:\/\//.test(u)) throw new CliError(`Not a page address: ${u}. Use the full address, with https://`, 1, "usage");
26890
+ if (urls.length > 10) throw new CliError("Up to 10 pages at a time. Pick one page of each kind.", 1, "usage");
26891
+ const { findings, total } = judgeFiles(root);
26892
+ const shown = /* @__PURE__ */ new Map();
26893
+ const browser = urls.length ? findBrowser() : null;
26894
+ const unmeasured = [];
26895
+ if (urls.length && !browser) unmeasured.push(...urls);
26896
+ if (browser) {
26897
+ for (const url2 of urls) {
26898
+ out(`Measuring ${url2}`);
26899
+ try {
26900
+ for (const width of [1440, 390]) {
26901
+ let seen = await measurePage(browser, url2, width, true).catch(() => []);
26902
+ if (!seen.length) seen = await measurePage(browser, url2, width, false);
26903
+ for (const m of seen) {
26904
+ if (/\.svg(\?|$)/i.test(m.src) || m.src.startsWith("data:")) continue;
26905
+ const had = shown.get(m.src);
26906
+ if (!had || m.shownWidth > had.shownWidth) shown.set(m.src, m);
26907
+ }
26908
+ }
26909
+ } catch {
26910
+ unmeasured.push(url2);
26911
+ }
26912
+ }
26913
+ }
26914
+ const onPages = [];
26915
+ for (const m of shown.values()) {
26916
+ const verdict = judgeImage({ width: m.width, height: m.height, shownWidth: m.shownWidth });
26917
+ if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
26918
+ }
26919
+ const weak = [...onPages, ...findings];
26920
+ mkdirSync7(join14(root, BRAND_DIR), { recursive: true });
26921
+ const file2 = `${BRAND_DIR}/images.json`;
26922
+ const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
26923
+ writeFileSync11(join14(root, file2), `${JSON.stringify(data, null, 2)}
26924
+ `);
26925
+ if (opts.json) {
26926
+ out(JSON.stringify(data));
26927
+ return;
26928
+ }
26929
+ out(`Checked ${total} image files${shown.size ? ` and measured ${shown.size} images on the pages` : ""}. Saved in ${file2}. Nothing changed.`);
26930
+ if (unmeasured.length) out(`Not measured, ${browser ? "the page did not answer" : "this needs Chrome or Edge"}: ${unmeasured.join(", ")}`);
26931
+ if (!weak.length) {
26932
+ out("No weak images.");
26933
+ return;
26934
+ }
26935
+ out("");
26936
+ out(rows(weak.slice(0, 40).map((w) => [w.where.length > 70 ? `...${w.where.slice(-67)}` : w.where, `${w.width}x${w.height}${w.shownWidth ? `, shown at ${w.shownWidth}` : ""}: ${SAY[w.verdict]}`])));
26937
+ if (weak.length > 40) out(`and ${weak.length - 40} more in ${file2}`);
26938
+ out("");
26939
+ out("Only with the owner's yes, one by one. Decoration may be replaced. A photo of a real person, product, place or job is never replaced with a made up one: ask the owner for a better photo.");
26940
+ }
26941
+
25986
26942
  // src/commands/env.ts
25987
26943
  async function readStdin() {
25988
26944
  const chunks = [];
@@ -26061,6 +27017,10 @@ function buildProgram() {
26061
27017
  migrate.command("verify").description("open every old address on the preview: lists pages that moved, are missing or lost their title or description").argument("<preview>", "the preview address deploy printed").action(async (preview, _opts, cmd) => migrateVerifyCommand(root(cmd), preview));
26062
27018
  migrate.command("status").description("a managed move: report a stage to the request (scanning, building, preview_ready, customer_review, live, blocked)").argument("<stage>", "the stage").argument("[note]", "one line: the preview address, what is done, or why it is blocked").action((stage, note, _opts, cmd) => migrateStatusCommand(root(cmd), ctx(cmd), stage, note));
26063
27019
  program.command("blocks").description("list our building blocks, or add one to this site (inbox, blog); never writes over a file").argument("[name]", "inbox or blog").action((name, _opts, cmd) => blocksCommand(root(cmd), ctx(cmd), name));
27020
+ const brand = program.command("brand").description("the site's icons and share image, made by code from the site's own name, colors and logo");
27021
+ brand.command("favicon").description("gives the site an icon if it has none: the old site's, else its logo, else a letter").option("--from <file>", "the logo or picture to use").option("--name <name>", "the site's name, for the letter").option("--color <#rrggbb>", "the background color").option("--force", "replace the icon the site has").option("--check", "only say whether the site has an icon").action((opts, cmd) => brandFaviconCommand(root(cmd), opts));
27022
+ brand.command("icons").description("makes every icon size and the 1200 by 630 share image from the site itself").option("--from <file>", "use this picture instead of the logo it finds").option("--name <name>", "correct the name it reads").option("--line <text>", "correct the line it reads").option("--color <#rrggbb>", "correct the color it reads").option("--check", "only list what is missing").action((opts, cmd) => brandIconsCommand(root(cmd), opts));
27023
+ brand.command("images").description("reports images too weak for where they show, by measuring them; never changes one").argument("[pages...]", "up to 10 page addresses to measure in a browser").option("--json", "print the result as JSON").action((pages, opts, cmd) => brandImagesCommand(root(cmd), pages, opts));
26064
27024
  program.command("addons").description("the add-ons of this site: which it has, which are done and which is next; addons run runs them all in one go").argument("[action]", "run: every add-on that is not done, one after the other").action((action, _opts, cmd) => {
26065
27025
  if (!action) return addonsCommand(root(cmd), ctx(cmd));
26066
27026
  if (action === "run") return addonsRunCommand(root(cmd), ctx(cmd));