deployai 0.1.0-beta.33 → 0.1.0-beta.35

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 (2) hide show
  1. package/dist/index.js +338 -256
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,8 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/cli.ts
9
- import { resolve as resolve8 } from "path";
9
+ import { existsSync as existsSync21 } from "fs";
10
+ import { join as join24, resolve as resolve8 } from "path";
10
11
  import { Command, CommanderError } from "commander";
11
12
 
12
13
  // ../shared/src/plans.ts
@@ -21149,16 +21150,11 @@ function privateProjectFile(path) {
21149
21150
  const base = parts2[parts2.length - 1] ?? "";
21150
21151
  return PRIVATE_FILES.has(base) || parts2.slice(0, -1).some((p) => PRIVATE_DIRS.has(p)) || PRIVATE_DIRS.has(base);
21151
21152
  }
21152
- function dotPath(path) {
21153
- const parts2 = segments(path);
21154
- if (parts2[0] === SERVED_DOT_DIR) parts2.shift();
21155
- return parts2.some((p) => p.startsWith("."));
21156
- }
21157
21153
  function neverUploadedFile(rel) {
21158
21154
  if (privateProjectFile(rel)) return true;
21159
21155
  const parts2 = segments(rel);
21160
21156
  if (parts2.length === 1 && BUILD_DOTFILES.has(parts2[0])) return false;
21161
- return dotPath(rel);
21157
+ return parts2.some((p) => p.startsWith(".") && p !== SERVED_DOT_DIR);
21162
21158
  }
21163
21159
 
21164
21160
  // ../shared/src/agent-feedback.ts
@@ -22293,6 +22289,8 @@ var CHECK = { cmd: "npx deployai@latest check", say: "Fix every blocker it lists
22293
22289
  var FIRST_LOOK_MESSAGE = "first look";
22294
22290
  var FIRST_SITE_RULE = 'A site that has never been live (this folder is not linked yet, or npx deployai@latest status shows no live version) follows this, and not the rule for later changes. Right at the start, before you build, ask once, naming the site and its address when you know it: "When your site is ready, should I put it live for you? Anyone will be able to see it." The answers: Yes, put it live (recommended), or Show me first. Then go on working, and do not ask it again for this first version. Deploy twice. First, the first look: when a first version works, deploy without --live and send the owner the preview address. Make every change they ask for in the folder, without deploying. Second, when everything they asked for is done: on Yes, deploy with --live and give them the live address, with no more questions. On Show me first, deploy without it, send the preview address and ask: "Put it live, or change something first?" If nothing changed since the first look, there is nothing to build: run promote on that version instead of a second deploy. Deploy again only when a deploy failed, or the owner asks for more after the last one, and then put all of it in one deploy. Database changes still get their own yes.';
22295
22291
  var DEPLOY_ASK_RULE = 'Once a site has been live, 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.';
22292
+ var LOCAL_PREVIEW_RULE = "While you build, show the site on this computer, never a deploy after each change. Start the site's own dev command (the dev script in package.json, for example npm run dev) yourself, in the background, so it keeps running while you work: in Claude Code as a background command, in another tool with its own way to run a command in the background or in a terminal of its own. Never ask the owner to open a terminal or type a command. If a local preview of this folder is already running, use it instead of starting a second one. Send the owner the local address it prints once, as a link, and say in one line that it updates by itself while you work and opens only on this computer. Check every change there yourself. The local preview is not the hosting: it has a local test database that starts empty, and the built-in email to the owner, visitor countries, 301 redirects and the DeployAI badge work only on a deployed preview, so test those there, and the owner checks a phone there. When to deploy does not change. When the work is done, stop the local preview you started.";
22293
+ var GIT_HISTORY_RULE = "Keep the site's history with git in this folder: run git init if there is none, commit before you start and after each part that works, with a short message in the owner's language about what they see changed. Never commit .env files or secrets. When the owner asks to undo a change, or to bring back or remove a feature, do it from the git history yourself and tell them in one line what changed; never ask them to run git. Git brings back code, not data: rows, files and tables that were deleted stay deleted, so ask the owner before a change that removes data.";
22296
22294
  var ASK_OWNER_RULE = `When a question to the owner has set answers, use your tool's own question feature with clickable choices if it has one, for example AskUserQuestion in Claude Code, AskQuestion in Cursor, askQuestions in Copilot in VS Code, request_user_input in Codex, or ask_user_question in Grok Build. Use the owner's language, with each answer as its own choice. If your tool has no such feature, or it is refused or fails, ask the same question once in plain text and go on. Never change a mode or a setting to get it. A yes or no question has set answers too. This holds for every question, also one you think of yourself in the middle of the work: say what you have to say, then ask through the feature, never as the last line of your message. A question about going live names the site and its address when you know it, and says anyone will be able to see it, so the owner's answer is about this exact site (D-691). Open details, like a phone number or hours, stay in plain text, in one short list. How the owner wants you to work is saved in .deployai/owner-mode (D-865): on-my-own or check-with-me. If the file is missing, ask once, "How should I work?", with "On my own (recommended)": I build and choose the recommended option at every step, I stop only for money, deleting your content or your real domain, and I leave you a short list at the end; and "Check with me". Save the answer there, and change it when the owner says so. On my own: take the recommended option without asking, install the tools you need, and stop only for money, deleting the owner's content, a real domain going live or a fact you would have to invent, which you leave out and list. Every question opens with a short tag naming who asks, like "Search add-on \xB7 1 of 2" or "Move \xB7 forms", and a question with several items offers "Approve all (recommended)" first. Never ask the owner about a package, library, framework, tool, file path or size: ask about the outcome in plain words.`;
22297
22295
  var QUESTION_FEATURE = { claudeCode: "AskUserQuestion", cursor: "AskQuestion", copilot: "askQuestions", codex: "request_user_input", grok: "ask_user_question" };
22298
22296
  function toolAskLine(tool) {
@@ -22300,6 +22298,7 @@ function toolAskLine(tool) {
22300
22298
  return feature ? `You run in ${DEPLOY_TOOL_NAMES[tool]}, so every question with set answers goes through ${feature}.` : "";
22301
22299
  }
22302
22300
  var ASK = { say: DEPLOY_ASK_RULE };
22301
+ var LOCAL_STEP = { say: `${LOCAL_PREVIEW_RULE} ${GIT_HISTORY_RULE}` };
22303
22302
  var GUEST_ASK = { say: 'Right at the start, before you build, ask once: "When your site is ready, should I put it up for you? Anyone with the address will be able to see it." The answers: Yes, put it up (recommended), or Ask me first. Then go on working. Deploy twice at most, never after each small edit: once when a first version works, as the first look (on Ask me first, ask then: "Put it up now, or not yet?", and on Not yet keep working), and once when everything the owner asked for is done. The second deploy keeps the same address.' };
22304
22303
  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." };
22305
22304
  var LOGIN = { cmd: "npx deployai@latest login", say: "The owner approves it in the browser window it opens." };
@@ -22327,6 +22326,7 @@ var SELF_SEND = { say: 'If the owner chose to put it live when it is ready: when
22327
22326
  var MIGRATE_STEPS = [
22328
22327
  TAGS_SEEN,
22329
22328
  MOVE_REPORT,
22329
+ LOCAL_STEP,
22330
22330
  { 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." },
22331
22331
  LOOK_BUILD,
22332
22332
  FAVICON,
@@ -22356,6 +22356,7 @@ var MANAGED_STEPS = [
22356
22356
  TAGS_SEEN,
22357
22357
  { cmd: MOVE_REPORT.cmd, say: `${REPORT_SAY} ${PLAN_SHOW} Then ask: "Go ahead with this plan?" The answers: Go ahead (recommended), or Change something.` },
22358
22358
  managedStatus("building", "<what is done>", "First, once the plan in .deployai/migration/plan.md is agreed: the request shows the build started."),
22359
+ LOCAL_STEP,
22359
22360
  stepWith("migrate media"),
22360
22361
  LOOK_BUILD,
22361
22362
  FAVICON,
@@ -22399,15 +22400,16 @@ var startStepsQuery = (kind, opts) => `kind=${kind}&o=${["emptyFolder", "starter
22399
22400
  function stepsOf(kind, opts) {
22400
22401
  switch (kind) {
22401
22402
  case "new":
22402
- return [FIRST_ASK, ...opts.starter ? [BUILD] : [], FAVICON, CHECK, LOGIN, FIRST_LOOK, FIRST_DONE, PROMOTE, OFFER_DASHBOARD];
22403
+ return [FIRST_ASK, LOCAL_STEP, ...opts.starter ? [BUILD] : [], FAVICON, CHECK, LOGIN, FIRST_LOOK, FIRST_DONE, PROMOTE, OFFER_DASHBOARD];
22403
22404
  case "update": {
22404
22405
  const deploy = { cmd: 'npx deployai@latest deploy -m "<what changed, in a few words>"', say: DEPLOY_SAY };
22405
- if (opts.addons) return [LOGIN, ...opts.emptyFolder ? [PULL] : [], ADDONS_RUN, CHECK, ASK, deploy, PROMOTE];
22406
- return opts.emptyFolder ? [LOGIN, PULL, CHECK, ASK, deploy, PROMOTE] : [CHECK, ASK, LOGIN, deploy, PROMOTE];
22406
+ if (opts.addons) return [LOGIN, ...opts.emptyFolder ? [PULL] : [], LOCAL_STEP, ADDONS_RUN, CHECK, ASK, deploy, PROMOTE];
22407
+ return opts.emptyFolder ? [LOGIN, PULL, LOCAL_STEP, CHECK, ASK, deploy, PROMOTE] : [LOCAL_STEP, CHECK, ASK, LOGIN, deploy, PROMOTE];
22407
22408
  }
22408
22409
  case "move":
22409
22410
  return [
22410
22411
  FIRST_ASK,
22412
+ LOCAL_STEP,
22411
22413
  FAVICON,
22412
22414
  CHECK,
22413
22415
  LOGIN,
@@ -22422,6 +22424,7 @@ function stepsOf(kind, opts) {
22422
22424
  case "guest":
22423
22425
  return [
22424
22426
  GUEST_ASK,
22427
+ LOCAL_STEP,
22425
22428
  ...opts.starter ? [BUILD] : [],
22426
22429
  FAVICON,
22427
22430
  { ...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." },
@@ -22484,6 +22487,7 @@ var CLI_MAP_NODES = [
22484
22487
  n("cmd-shot", "cli", "shot <url>", "\u05EA\u05DE\u05D5\u05E0\u05D5\u05EA \u05D8\u05DC\u05E4\u05D5\u05DF \u05D5\u05DE\u05D7\u05E9\u05D1 \u05E9\u05DC \u05E2\u05DE\u05D5\u05D3, \u05D1\u05D3\u05E4\u05D3\u05E4\u05DF \u05E9\u05DB\u05D1\u05E8 \u05D1\u05DE\u05D7\u05E9\u05D1.", "Phone and desktop pictures of a page, with the browser already on the computer."),
22485
22488
  n("cmd-optimize", "cli", "optimize [folder]", "AVIF \u05D5\u05BEWebP \u05DC\u05D9\u05D3 \u05DB\u05DC \u05EA\u05DE\u05D5\u05E0\u05D4, \u05D1\u05DC\u05D9 \u05DC\u05D2\u05E2\u05EA \u05D1\u05DE\u05E7\u05D5\u05E8.", "AVIF and WebP next to each image, originals untouched."),
22486
22489
  n("cmd-allow", "cli", "allow [tool]", "\u05D0\u05D7\u05E8\u05D9 \u05E9\u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D9\u05E9\u05E8: \u05DB\u05DC\u05D9 \u05D4\u05E7\u05D5\u05D3 \u05DE\u05E4\u05E1\u05D9\u05E7 \u05DC\u05E9\u05D0\u05D5\u05DC \u05DC\u05E4\u05E0\u05D9 \u05DB\u05DC \u05E4\u05E7\u05D5\u05D3\u05EA DeployAI, \u05E8\u05E7 \u05D1\u05EA\u05D9\u05E7\u05D9\u05D9\u05D4 \u05D4\u05D6\u05D5.", "After the owner says yes: the coding tool stops asking before every DeployAI command, in this folder only."),
22490
+ n("cmd-rules", "cli", "rules", "\u05DE\u05D3\u05E4\u05D9\u05E1 \u05D0\u05EA \u05D4\u05DB\u05DC\u05DC\u05D9\u05DD \u05D4\u05E2\u05D3\u05DB\u05E0\u05D9\u05D9\u05DD \u05DC\u05E1\u05D5\u05DB\u05DF \u05DE\u05D4\u05E9\u05E8\u05EA \u05D5\u05DE\u05E2\u05D3\u05DB\u05DF \u05D0\u05DC\u05D9\u05D4\u05DD \u05D0\u05EA DEPLOYAI.md. \u05DB\u05DC \u05E4\u05E7\u05D5\u05D3\u05D4 \u05D0\u05D7\u05E8\u05EA \u05DE\u05E2\u05D3\u05DB\u05E0\u05EA \u05D0\u05EA DEPLOYAI.md \u05D1\u05E2\u05E6\u05DE\u05D4, \u05D0\u05DD \u05DC\u05D0 \u05E0\u05E2\u05E8\u05DA.", "Prints the current agent rules from the server and brings DEPLOYAI.md up to them. Every other command updates DEPLOYAI.md too, unless it was edited."),
22487
22491
  n("cmd-sound", "cli", "sound", "\u05E6\u05DC\u05D9\u05DC \u05D1\u05DE\u05D7\u05E9\u05D1 \u05DB\u05E9\u05D4\u05D0\u05EA\u05E8 \u05DE\u05D5\u05DB\u05DF, \u05D0\u05D7\u05E8\u05D9 \u05E9\u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D0\u05D9\u05E9\u05E8. \u05D1-Claude Code \u05D4\u05D0\u05D9\u05E9\u05D5\u05E8 \u05D4\u05D6\u05D4 \u05DE\u05D5\u05E1\u05D9\u05E3 \u05D2\u05DD \u05E6\u05DC\u05D9\u05DC \u05D5\u05E0\u05E7\u05D5\u05D3\u05D4 \u05D1\u05DC\u05E9\u05D5\u05E0\u05D9\u05EA \u05E9\u05DC \u05D4\u05D8\u05E8\u05DE\u05D9\u05E0\u05DC.", "A sound on this computer when the site is ready, after the owner says yes. In Claude Code that yes also adds a sound and a tab dot in the terminal."),
22488
22492
  n("cmd-telemetry", "cli", "telemetry", "\u05D4\u05E4\u05E2\u05DC\u05D4 \u05D0\u05D5 \u05DB\u05D9\u05D1\u05D5\u05D9 \u05E9\u05DC \u05E0\u05EA\u05D5\u05E0\u05D9 \u05E9\u05D9\u05DE\u05D5\u05E9 \u05D0\u05E0\u05D5\u05E0\u05D9\u05DE\u05D9\u05D9\u05DD.", "Turns anonymous usage data on or off."),
22489
22493
  n("cmd-feedback", "cli", "feedback", "\u05D4\u05E1\u05D5\u05DB\u05DF \u05DE\u05E1\u05E4\u05E8 \u05DC\u05E0\u05D5 \u05DE\u05D4 \u05D4\u05E4\u05E8\u05D9\u05E2 \u05DC\u05D5 \u05D5\u05DE\u05D4 \u05D4\u05D9\u05D4 \u05E2\u05D5\u05D6\u05E8, \u05D1\u05DC\u05D9 \u05E7\u05D5\u05D3, \u05E9\u05DE\u05D5\u05EA \u05D0\u05D5 \u05DB\u05EA\u05D5\u05D1\u05D5\u05EA.", "The agent tells us what got in its way and what would help, with no code, names or addresses."),
@@ -23296,7 +23300,7 @@ When the owner wants an outside service, such as card payments, invoices or send
23296
23300
 
23297
23301
  - local file system writes
23298
23302
  - database drivers DeployAI does not support (see: npx deployai@latest inspect)
23299
- - long-running processes or background servers
23303
+ - long-running processes or background servers in the site's code (the local preview while you build is fine)
23300
23304
  - Durable Objects (not supported yet; keep state in D1)
23301
23305
  - native binary modules
23302
23306
  - DeployAI or any cloud credentials in source code
@@ -23323,6 +23327,12 @@ Never stop building for an account, a plan or a limit. Build what the owner asks
23323
23327
 
23324
23328
  ${FIRST_SITE_RULE}
23325
23329
 
23330
+ ## While you build
23331
+
23332
+ ${LOCAL_PREVIEW_RULE}
23333
+
23334
+ ${GIT_HISTORY_RULE}
23335
+
23326
23336
  ## When to deploy
23327
23337
 
23328
23338
  ${DEPLOY_ASK_RULE}
@@ -23339,6 +23349,7 @@ Ask the owner before removing any existing functionality.
23339
23349
  Files:
23340
23350
  - .deployai/project.json: project id and settings (safe to commit)
23341
23351
  - .deployai/last-check.json: latest check result (not committed)
23352
+ - .deployai/rules.json: which rules this file has. Every DeployAI command updates this file to the current rules unless it was edited. The current rules: npx deployai@latest rules
23342
23353
  `;
23343
23354
  var DEPLOYAI_LATER_RULES = [
23344
23355
  { has: "iPhone:", text: IPHONE_RULE },
@@ -23346,7 +23357,9 @@ var DEPLOYAI_LATER_RULES = [
23346
23357
  { has: "one or two short sentences", text: START_FAIL_LINE },
23347
23358
  { has: "direction marks", text: OWNER_TEXT_RULE },
23348
23359
  { has: "deployai@latest feedback", text: AGENT_FEEDBACK_RULES.join(" ") },
23349
- { has: "never been live", text: FIRST_SITE_RULE }
23360
+ { has: "never been live", text: FIRST_SITE_RULE },
23361
+ { has: "local preview", text: LOCAL_PREVIEW_RULE },
23362
+ { has: "git history", text: GIT_HISTORY_RULE }
23350
23363
  ];
23351
23364
  function parseLaterRules(json2) {
23352
23365
  try {
@@ -24294,7 +24307,7 @@ function ensureDeployaiDir(root) {
24294
24307
  if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
24295
24308
  const ignore = join2(dir, ".gitignore");
24296
24309
  const have = existsSync2(ignore) ? readFileSync3(ignore, "utf8") : "";
24297
- const missing = ["last-check.json", "brief.md", "start.md"].filter((f) => !have.split(/\r?\n/).includes(f));
24310
+ const missing = ["last-check.json", "brief.md", "start.md", "blocks/*.md"].filter((f) => !have.split(/\r?\n/).includes(f));
24298
24311
  if (missing.length) writeFileSync2(ignore, have + (have && !have.endsWith("\n") ? "\n" : "") + missing.join("\n") + "\n");
24299
24312
  }
24300
24313
  function readProject(root) {
@@ -24833,7 +24846,7 @@ function messages(root) {
24833
24846
  }
24834
24847
 
24835
24848
  // src/version.ts
24836
- var CLI_VERSION = "0.1.0-beta.33";
24849
+ var CLI_VERSION = "0.1.0-beta.35";
24837
24850
 
24838
24851
  // src/api.ts
24839
24852
  function apiContext(apiFlag) {
@@ -25142,8 +25155,8 @@ async function feedbackCommand(root, ctx, opts) {
25142
25155
  }
25143
25156
 
25144
25157
  // src/commands/init.ts
25145
- import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
25146
- import { join as join6 } from "path";
25158
+ import { appendFileSync as appendFileSync2, existsSync as existsSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
25159
+ import { join as join7 } from "path";
25147
25160
 
25148
25161
  // src/analyze.ts
25149
25162
  import { execFileSync } from "child_process";
@@ -25840,36 +25853,76 @@ async function serverSteps(apiUrl, query, fetcher = fetch) {
25840
25853
  }
25841
25854
  }
25842
25855
 
25843
- // src/commands/init.ts
25844
- var AGENT_FILES = ["AGENTS.md", "CLAUDE.md"];
25845
- function addMissingRules(md, later = DEPLOYAI_LATER_RULES) {
25846
- const text2 = readFileSync6(md, "utf8");
25856
+ // src/rules-file.ts
25857
+ import { createHash } from "crypto";
25858
+ import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
25859
+ import { join as join6 } from "path";
25860
+ var RULES_FILE = "DEPLOYAI.md";
25861
+ var RULES_STAMP = `${DEPLOYAI_DIR}/rules.json`;
25862
+ var rulesHash = (text2) => createHash("sha256").update(text2.replace(/\r\n/g, "\n")).digest("hex");
25863
+ function readStamp(root) {
25864
+ try {
25865
+ const v = readJson(join6(root, RULES_STAMP));
25866
+ return typeof v.deployaiMd === "string" ? v.deployaiMd : null;
25867
+ } catch {
25868
+ return null;
25869
+ }
25870
+ }
25871
+ function writeStamp(root, text2) {
25872
+ ensureDeployaiDir(root);
25873
+ writeFileSync4(join6(root, RULES_STAMP), `${JSON.stringify({ deployaiMd: rulesHash(text2) }, null, 2)}
25874
+ `);
25875
+ }
25876
+ function writeRulesFile(root, md) {
25877
+ writeFileSync4(join6(root, RULES_FILE), md);
25878
+ writeStamp(root, md);
25879
+ }
25880
+ function addMissingRules(file2, text2, later) {
25847
25881
  const missing = later.filter((r) => !text2.includes(r.has));
25848
25882
  if (!missing.length) return false;
25849
25883
  const eol = text2.includes("\r\n") ? "\r\n" : "\n";
25850
25884
  const gap = text2.endsWith("\n") ? eol : eol + eol;
25851
- appendFileSync(md, `${gap}## Added later by DeployAI${eol}${eol}${missing.map((r) => r.text).join(eol + eol)}${eol}`);
25885
+ appendFileSync(file2, `${gap}## Added later by DeployAI${eol}${eol}${missing.map((r) => r.text).join(eol + eol)}${eol}`);
25852
25886
  return true;
25853
25887
  }
25888
+ function syncRulesFile(root, md, later = DEPLOYAI_LATER_RULES) {
25889
+ const file2 = join6(root, RULES_FILE);
25890
+ if (!existsSync5(file2)) return "none";
25891
+ const text2 = readFileSync6(file2, "utf8");
25892
+ const now = rulesHash(text2);
25893
+ if (now === rulesHash(md)) {
25894
+ if (readStamp(root) !== now) writeStamp(root, md);
25895
+ return "current";
25896
+ }
25897
+ if (readStamp(root) === now) {
25898
+ writeRulesFile(root, text2.includes("\r\n") ? md.replace(/\r?\n/g, "\r\n") : md);
25899
+ return "updated";
25900
+ }
25901
+ return addMissingRules(file2, text2, later) ? "added" : "edited";
25902
+ }
25903
+
25904
+ // src/commands/init.ts
25905
+ var AGENT_FILES = ["AGENTS.md", "CLAUDE.md"];
25854
25906
  function runInit(root, opts = {}) {
25855
25907
  const created = [];
25856
25908
  const kept = [];
25857
25909
  const updated = [];
25858
- const md = join6(root, "DEPLOYAI.md");
25910
+ const md = join7(root, "DEPLOYAI.md");
25859
25911
  let rulesAdded = false;
25860
- if (existsSync5(md) && !opts.force) {
25912
+ if (existsSync6(md) && !opts.force) {
25861
25913
  kept.push("DEPLOYAI.md");
25862
- rulesAdded = addMissingRules(md, opts.texts?.later);
25914
+ const sync = syncRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD, opts.texts?.later);
25915
+ rulesAdded = sync === "updated" || sync === "added";
25863
25916
  } else {
25864
- writeFileSync4(md, opts.texts?.md ?? DEPLOYAI_MD);
25917
+ writeRulesFile(root, opts.texts?.md ?? DEPLOYAI_MD);
25865
25918
  created.push("DEPLOYAI.md");
25866
25919
  }
25867
25920
  if (opts.agentFiles !== false) {
25868
25921
  for (const name of AGENT_FILES) {
25869
- const file2 = join6(root, name);
25870
- const text2 = existsSync5(file2) ? readFileSync6(file2, "utf8") : null;
25922
+ const file2 = join7(root, name);
25923
+ const text2 = existsSync6(file2) ? readFileSync7(file2, "utf8") : null;
25871
25924
  if (text2 === null) {
25872
- writeFileSync4(file2, `${AGENT_POINTER}
25925
+ writeFileSync5(file2, `${AGENT_POINTER}
25873
25926
  `);
25874
25927
  created.push(name);
25875
25928
  } else if (text2.includes("DEPLOYAI.md")) {
@@ -25877,7 +25930,7 @@ function runInit(root, opts = {}) {
25877
25930
  } else {
25878
25931
  const eol = text2.includes("\r\n") ? "\r\n" : "\n";
25879
25932
  const gap = !text2.trim() ? "" : text2.endsWith("\n") ? eol : eol + eol;
25880
- appendFileSync(file2, `${gap}${AGENT_POINTER}${eol}`);
25933
+ appendFileSync2(file2, `${gap}${AGENT_POINTER}${eol}`);
25881
25934
  updated.push(name);
25882
25935
  }
25883
25936
  }
@@ -25891,7 +25944,7 @@ function runInit(root, opts = {}) {
25891
25944
  writeProject(root, { projectId: null, framework, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
25892
25945
  created.push(".deployai/project.json");
25893
25946
  }
25894
- const hasCode = existsSync5(join6(root, "package.json")) || framework !== "unknown";
25947
+ const hasCode = existsSync6(join7(root, "package.json")) || framework !== "unknown";
25895
25948
  return { rulesAdded, created, kept, updated, hasCode };
25896
25949
  }
25897
25950
  async function initCommand(root, opts, apiUrl) {
@@ -25920,8 +25973,8 @@ async function initCommand(root, opts, apiUrl) {
25920
25973
  }
25921
25974
 
25922
25975
  // src/commands/check.ts
25923
- import { existsSync as existsSync7, writeFileSync as writeFileSync5 } from "fs";
25924
- import { join as join8 } from "path";
25976
+ import { existsSync as existsSync8, writeFileSync as writeFileSync6 } from "fs";
25977
+ import { join as join9 } from "path";
25925
25978
 
25926
25979
  // src/prompt.ts
25927
25980
  var PROMPT_RULES = [
@@ -25990,8 +26043,8 @@ function buildPrompt(analysis) {
25990
26043
 
25991
26044
  // src/system.ts
25992
26045
  import { spawn, spawnSync } from "child_process";
25993
- import { existsSync as existsSync6 } from "fs";
25994
- import { join as join7 } from "path";
26046
+ import { existsSync as existsSync7 } from "fs";
26047
+ import { join as join8 } from "path";
25995
26048
  function copyToClipboard(text2) {
25996
26049
  if (process.env.DEPLOYAI_NO_CLIPBOARD) return false;
25997
26050
  const candidates = process.platform === "win32" ? [["clip", []]] : process.platform === "darwin" ? [["pbcopy", []]] : [
@@ -26011,9 +26064,9 @@ function copyToClipboard(text2) {
26011
26064
  function findBrowser() {
26012
26065
  if (process.env.DEPLOYAI_NO_BROWSER) return null;
26013
26066
  const set2 = process.env.CHROME_PATH;
26014
- if (set2 && existsSync6(set2)) return set2;
26015
- const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join7(d, "Google/Chrome/Application/chrome.exe"), join7(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"];
26016
- return places.find((p) => existsSync6(p)) ?? null;
26067
+ if (set2 && existsSync7(set2)) return set2;
26068
+ const places = process.platform === "win32" ? [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"], process.env.LOCALAPPDATA].flatMap((d) => d ? [join8(d, "Google/Chrome/Application/chrome.exe"), join8(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"];
26069
+ return places.find((p) => existsSync7(p)) ?? null;
26017
26070
  }
26018
26071
  function openBrowser(url2) {
26019
26072
  if (process.env.DEPLOYAI_NO_BROWSER || process.env.CI) return false;
@@ -26113,7 +26166,7 @@ async function runCheck(root, ctx, opts = {}) {
26113
26166
  const json2 = checkJson(a, prompt);
26114
26167
  try {
26115
26168
  ensureDeployaiDir(root);
26116
- writeFileSync5(lastCheckFile(root), JSON.stringify(json2, null, 2) + "\n");
26169
+ writeFileSync6(lastCheckFile(root), JSON.stringify(json2, null, 2) + "\n");
26117
26170
  } catch {
26118
26171
  }
26119
26172
  const empty = a.findings.length > 0 && a.findings.every((f) => f.code === "no_files");
@@ -26123,7 +26176,7 @@ async function runCheck(root, ctx, opts = {}) {
26123
26176
  out("DeployAI check");
26124
26177
  out();
26125
26178
  out(messages(root)("emptyFolder"));
26126
- if (!existsSync7(join8(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
26179
+ if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(messages(root)("initHint"));
26127
26180
  } else if (opts.print !== false) {
26128
26181
  printCheck(a);
26129
26182
  out();
@@ -26150,7 +26203,7 @@ async function runCheck(root, ctx, opts = {}) {
26150
26203
  } else {
26151
26204
  out(t("runDeploy"));
26152
26205
  }
26153
- if (!existsSync7(join8(root, "DEPLOYAI.md"))) out(t("initHint"));
26206
+ if (!existsSync8(join9(root, "DEPLOYAI.md"))) out(t("initHint"));
26154
26207
  }
26155
26208
  await telemetry;
26156
26209
  return a;
@@ -26293,8 +26346,8 @@ function telemetryCommand(action) {
26293
26346
  }
26294
26347
 
26295
26348
  // src/commands/allow.ts
26296
- import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync6, appendFileSync as appendFileSync2 } from "fs";
26297
- import { dirname, join as join9 } from "path";
26349
+ import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync7, appendFileSync as appendFileSync3 } from "fs";
26350
+ import { dirname, join as join10 } from "path";
26298
26351
  var ALLOW_TOOLS = ["claude-code", "cursor", "copilot", "codex", "antigravity", "grok"];
26299
26352
  var CLAUDE_RULE = "Bash(npx deployai@latest *)";
26300
26353
  var CURSOR_LINE = "Running npx deployai@latest commands is allowed without approval.";
@@ -26304,7 +26357,7 @@ var CLICKS = {
26304
26357
  antigravity: "Antigravity: when it asks to run npx deployai@latest, choose Accept."
26305
26358
  };
26306
26359
  function readObject(file2) {
26307
- if (!existsSync8(file2)) return {};
26360
+ if (!existsSync9(file2)) return {};
26308
26361
  try {
26309
26362
  const v = readJson(file2);
26310
26363
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
@@ -26314,7 +26367,7 @@ function readObject(file2) {
26314
26367
  }
26315
26368
  function writeObject(file2, value) {
26316
26369
  mkdirSync4(dirname(file2), { recursive: true });
26317
- writeFileSync6(file2, `${JSON.stringify(value, null, 2)}
26370
+ writeFileSync7(file2, `${JSON.stringify(value, null, 2)}
26318
26371
  `);
26319
26372
  }
26320
26373
  function addTo(obj, key, list, value) {
@@ -26326,11 +26379,11 @@ function addTo(obj, key, list, value) {
26326
26379
  return true;
26327
26380
  }
26328
26381
  function ignoreInGit(root, path) {
26329
- if (!existsSync8(join9(root, ".git"))) return;
26330
- const gi = join9(root, ".gitignore");
26331
- const text2 = existsSync8(gi) ? readFileSync7(gi, "utf8") : "";
26382
+ if (!existsSync9(join10(root, ".git"))) return;
26383
+ const gi = join10(root, ".gitignore");
26384
+ const text2 = existsSync9(gi) ? readFileSync8(gi, "utf8") : "";
26332
26385
  if (text2.split(/\r?\n/).some((l) => l.trim() === path)) return;
26333
- appendFileSync2(gi, `${text2 && !text2.endsWith("\n") ? "\n" : ""}${path}
26386
+ appendFileSync3(gi, `${text2 && !text2.endsWith("\n") ? "\n" : ""}${path}
26334
26387
  `);
26335
26388
  }
26336
26389
  function detectTool() {
@@ -26351,7 +26404,7 @@ function allowCommand(tool) {
26351
26404
  if (picked === "claude-code" || picked === "grok") {
26352
26405
  const grok = picked === "grok";
26353
26406
  const rel = ".claude/settings.local.json";
26354
- const file2 = join9(root, rel);
26407
+ const file2 = join10(root, rel);
26355
26408
  const obj = readObject(file2);
26356
26409
  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");
26357
26410
  const added = addTo(obj, "permissions", "allow", CLAUDE_RULE);
@@ -26372,7 +26425,7 @@ function allowCommand(tool) {
26372
26425
  }
26373
26426
  if (picked === "cursor") {
26374
26427
  const rel = ".cursor/permissions.json";
26375
- const file2 = join9(root, rel);
26428
+ const file2 = join10(root, rel);
26376
26429
  const obj = readObject(file2);
26377
26430
  if (!obj) throw new CliError(`${rel} is not valid JSON, so it was left as is.`, 1, "allow_file");
26378
26431
  const added = addTo(obj, "autoRun", "allow_instructions", CURSOR_LINE);
@@ -26386,14 +26439,14 @@ function allowCommand(tool) {
26386
26439
  }
26387
26440
 
26388
26441
  // src/commands/sound.ts
26389
- import { existsSync as existsSync10, readFileSync as readFileSync8, rmSync, writeFileSync as writeFileSync8 } from "fs";
26442
+ import { existsSync as existsSync11, readFileSync as readFileSync9, rmSync, writeFileSync as writeFileSync9 } from "fs";
26390
26443
  import { homedir as homedir2 } from "os";
26391
- import { join as join11 } from "path";
26444
+ import { join as join12 } from "path";
26392
26445
 
26393
26446
  // src/sound.ts
26394
26447
  import { spawn as spawn2 } from "child_process";
26395
- import { existsSync as existsSync9, mkdirSync as mkdirSync5, statSync, writeFileSync as writeFileSync7 } from "fs";
26396
- import { join as join10 } from "path";
26448
+ import { existsSync as existsSync10, mkdirSync as mkdirSync5, statSync, writeFileSync as writeFileSync8 } from "fs";
26449
+ import { join as join11 } from "path";
26397
26450
 
26398
26451
  // src/sound-files.ts
26399
26452
  var SOUND_FILES = {
@@ -26410,13 +26463,13 @@ function soundWanted(cfg, env = process.env) {
26410
26463
  const s = env.DEPLOYAI_SOUND;
26411
26464
  return !(s !== void 0 && ["0", "false", "off", "no"].includes(s.toLowerCase()));
26412
26465
  }
26413
- var soundsDir = () => join10(configDir(), "sounds");
26466
+ var soundsDir = () => join11(configDir(), "sounds");
26414
26467
  function writeSoundFiles() {
26415
26468
  mkdirSync5(soundsDir(), { recursive: true });
26416
26469
  for (const [name, b64] of Object.entries(SOUND_FILES)) {
26417
26470
  const data = Buffer.from(b64, "base64");
26418
- const file2 = join10(soundsDir(), `${name}.wav`);
26419
- if (!existsSync9(file2) || statSync(file2).size !== data.length) writeFileSync7(file2, data);
26471
+ const file2 = join11(soundsDir(), `${name}.wav`);
26472
+ if (!existsSync10(file2) || statSync(file2).size !== data.length) writeFileSync8(file2, data);
26420
26473
  }
26421
26474
  }
26422
26475
  function playerFor(platform3, file2) {
@@ -26429,7 +26482,7 @@ function playSound(name, cfg) {
26429
26482
  if (!soundWanted(cfg)) return;
26430
26483
  try {
26431
26484
  writeSoundFiles();
26432
- const player = playerFor(process.platform, join10(soundsDir(), `${name}.wav`));
26485
+ const player = playerFor(process.platform, join11(soundsDir(), `${name}.wav`));
26433
26486
  if (!player) return;
26434
26487
  const child = spawn2(player.cmd, player.args, { detached: true, stdio: "ignore", windowsHide: true });
26435
26488
  child.on("error", () => void 0);
@@ -26508,17 +26561,17 @@ function foreignHooks(files) {
26508
26561
  return [...found];
26509
26562
  }
26510
26563
  function agentOn(root, opts = {}) {
26511
- const file2 = join11(root, SETTINGS);
26564
+ const file2 = join12(root, SETTINGS);
26512
26565
  const obj = readObject(file2);
26513
26566
  if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
26514
- const home = process.env.CLAUDE_CONFIG_DIR || join11(opts.home ?? homedir2(), ".claude");
26515
- if (!opts.alongside && foreignHooks([join11(home, "settings.json"), join11(root, ".claude/settings.json"), file2]).length) return "has_own";
26567
+ const home = process.env.CLAUDE_CONFIG_DIR || join12(opts.home ?? homedir2(), ".claude");
26568
+ if (!opts.alongside && foreignHooks([join12(home, "settings.json"), join12(root, ".claude/settings.json"), file2]).length) return "has_own";
26516
26569
  writeSoundFiles();
26517
26570
  ensureDeployaiDir(root);
26518
- const script = join11(root, AGENT_SCRIPT);
26571
+ const script = join12(root, AGENT_SCRIPT);
26519
26572
  const text2 = agentScript(soundsDir());
26520
- const scriptSame = existsSync10(script) && readFileSync8(script, "utf8") === text2;
26521
- if (!scriptSame) writeFileSync8(script, text2);
26573
+ const scriptSame = existsSync11(script) && readFileSync9(script, "utf8") === text2;
26574
+ if (!scriptSame) writeFileSync9(script, text2);
26522
26575
  const hooks = hooksOf(obj);
26523
26576
  const env = obj.env && typeof obj.env === "object" ? obj.env : {};
26524
26577
  let added = env[TITLE_ENV] !== "1";
@@ -26536,7 +26589,7 @@ function agentOn(root, opts = {}) {
26536
26589
  return added || !scriptSame ? "on" : "already";
26537
26590
  }
26538
26591
  function agentOff(root) {
26539
- const file2 = join11(root, SETTINGS);
26592
+ const file2 = join12(root, SETTINGS);
26540
26593
  const obj = readObject(file2);
26541
26594
  if (!obj) throw new CliError(`${SETTINGS} is not valid JSON, so it was left as is.`, 1, "allow_file");
26542
26595
  const hooks = hooksOf(obj);
@@ -26558,8 +26611,8 @@ function agentOff(root) {
26558
26611
  else delete obj.hooks;
26559
26612
  writeObject(file2, obj);
26560
26613
  }
26561
- const script = join11(root, AGENT_SCRIPT);
26562
- if (existsSync10(script)) {
26614
+ const script = join12(root, AGENT_SCRIPT);
26615
+ if (existsSync11(script)) {
26563
26616
  rmSync(script);
26564
26617
  removed = true;
26565
26618
  }
@@ -26626,22 +26679,46 @@ function soundCommand(root, action, state, tool, opts = {}) {
26626
26679
  out(t(soundWanted(cfg) ? "soundOn" : "soundOff"));
26627
26680
  }
26628
26681
  function refreshAgentScript(root) {
26629
- const script = join11(root, AGENT_SCRIPT);
26630
- if (!existsSync10(script)) return false;
26682
+ const script = join12(root, AGENT_SCRIPT);
26683
+ if (!existsSync11(script)) return false;
26631
26684
  const text2 = agentScript(soundsDir());
26632
- const now = readFileSync8(script, "utf8");
26685
+ const now = readFileSync9(script, "utf8");
26633
26686
  if (now === text2 || !now.startsWith("// DeployAI's sound and tab dot")) return false;
26634
26687
  writeSoundFiles();
26635
- writeFileSync8(script, text2);
26688
+ writeFileSync9(script, text2);
26636
26689
  return true;
26637
26690
  }
26638
26691
 
26692
+ // src/commands/rules.ts
26693
+ var SAID = {
26694
+ updated: "DEPLOYAI.md was updated to the current DeployAI rules. Read it again before you go on.",
26695
+ added: "DEPLOYAI.md got the DeployAI rules it lacked, at its end. Read them before you go on."
26696
+ };
26697
+ async function rulesCommand(root, apiUrl) {
26698
+ const texts = initTexts(await serverRules(apiUrl));
26699
+ out(texts.md.trimEnd());
26700
+ out();
26701
+ const sync = syncRulesFile(root, texts.md, texts.later);
26702
+ if (sync === "current") out("DEPLOYAI.md here has these rules.");
26703
+ else if (sync === "none") out("No DEPLOYAI.md in this folder. To add one: npx deployai@latest init");
26704
+ else if (SAID[sync]) out(SAID[sync]);
26705
+ else out("DEPLOYAI.md here was edited, so it was left as it is. Follow the rules above. To replace it with them: npx deployai@latest init --force");
26706
+ }
26707
+ async function refreshRules(root, apiUrl) {
26708
+ try {
26709
+ const texts = initTexts(await serverRules(apiUrl));
26710
+ const sync = syncRulesFile(root, texts.md, texts.later);
26711
+ if (SAID[sync]) err(SAID[sync]);
26712
+ } catch {
26713
+ }
26714
+ }
26715
+
26639
26716
  // src/commands/link.ts
26640
26717
  import { createInterface } from "readline/promises";
26641
26718
 
26642
26719
  // src/commands/migrate.ts
26643
- import { createWriteStream, existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync2, writeFileSync as writeFileSync9 } from "fs";
26644
- import { dirname as dirname2, join as join12, posix, relative, resolve, sep } from "path";
26720
+ import { createWriteStream, existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync10 } from "fs";
26721
+ import { dirname as dirname2, join as join13, posix, relative, resolve, sep } from "path";
26645
26722
  import { Readable } from "stream";
26646
26723
  import { pipeline } from "stream/promises";
26647
26724
  var UA = `deployai-migrate/${CLI_VERSION} (+https://deployai.co.il/move)`;
@@ -26653,7 +26730,7 @@ var PAUSE_MS = 150;
26653
26730
  var SCAN_WORKERS = 4;
26654
26731
  var START_SCAN_PAGES = 300;
26655
26732
  var sleep2 = (ms2) => new Promise((r) => setTimeout(r, ms2));
26656
- var hostDir = (root, host) => join12(root, MIGRATION_DIR, host.replace(/^www\./, ""));
26733
+ var hostDir = (root, host) => join13(root, MIGRATION_DIR, host.replace(/^www\./, ""));
26657
26734
  var readJson3 = (file2) => {
26658
26735
  try {
26659
26736
  return readJson(file2);
@@ -26663,7 +26740,7 @@ var readJson3 = (file2) => {
26663
26740
  };
26664
26741
  var writeJson = (file2, data) => {
26665
26742
  mkdirSync6(dirname2(file2), { recursive: true });
26666
- writeFileSync9(file2, JSON.stringify(data, null, 2) + "\n");
26743
+ writeFileSync10(file2, JSON.stringify(data, null, 2) + "\n");
26667
26744
  };
26668
26745
  async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", redirect = "follow", cookie) {
26669
26746
  try {
@@ -26673,9 +26750,9 @@ async function get(url2, accept = "text/html,application/xhtml+xml,*/*;q=0.8", r
26673
26750
  }
26674
26751
  }
26675
26752
  function scannedHosts(root) {
26676
- const dir = join12(root, MIGRATION_DIR);
26677
- if (!existsSync11(dir)) return [];
26678
- return readdirSync3(dir).filter((h) => existsSync11(join12(dir, h, "inventory.json")));
26753
+ const dir = join13(root, MIGRATION_DIR);
26754
+ if (!existsSync12(dir)) return [];
26755
+ return readdirSync3(dir).filter((h) => existsSync12(join13(dir, h, "inventory.json")));
26679
26756
  }
26680
26757
  async function migrateStatusCommand(root, ctx, stage, note) {
26681
26758
  if (!isAgentStage(stage)) throw new CliError(`Unknown stage: ${stage}. One of: ${AGENT_STAGES.join(", ")}.`, 1, "usage");
@@ -26688,18 +26765,18 @@ async function migrateStatusCommand(root, ctx, stage, note) {
26688
26765
  out(`Reported: ${stage}${note ? ` (${stageNote(note)})` : ""}.`);
26689
26766
  }
26690
26767
  function readChoices(root) {
26691
- return readJson3(join12(root, MIGRATION_DIR, "choices.json"));
26768
+ return readJson3(join13(root, MIGRATION_DIR, "choices.json"));
26692
26769
  }
26693
26770
  function writeChoices(root, choices) {
26694
26771
  ensureMigrationDir(root);
26695
- writeJson(join12(root, MIGRATION_DIR, "choices.json"), choices);
26772
+ writeJson(join13(root, MIGRATION_DIR, "choices.json"), choices);
26696
26773
  }
26697
26774
  function ensureMigrationDir(root) {
26698
26775
  ensureDeployaiDir(root);
26699
- const dir = join12(root, MIGRATION_DIR);
26776
+ const dir = join13(root, MIGRATION_DIR);
26700
26777
  mkdirSync6(dir, { recursive: true });
26701
- const ignore = join12(dir, ".gitignore");
26702
- if (!existsSync11(ignore)) writeFileSync9(ignore, "*/media/\n*/media-state.json\n");
26778
+ const ignore = join13(dir, ".gitignore");
26779
+ if (!existsSync12(ignore)) writeFileSync10(ignore, "*/media/\n*/media-state.json\n");
26703
26780
  }
26704
26781
  function sameAddress(from, to) {
26705
26782
  try {
@@ -26770,15 +26847,15 @@ async function wordpressContent(base, dir) {
26770
26847
  await sleep2(PAUSE_MS);
26771
26848
  }
26772
26849
  if (items.length) {
26773
- writeJson(join12(dir, "content", `${type}.json`), items);
26850
+ writeJson(join13(dir, "content", `${type}.json`), items);
26774
26851
  out(` ${type}: ${items.length}`);
26775
26852
  }
26776
26853
  }
26777
- const posts = readJson3(join12(dir, "content", "posts.json"));
26854
+ const posts = readJson3(join13(dir, "content", "posts.json"));
26778
26855
  if (posts?.length) {
26779
- const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(join12(dir, "content", "categories.json")) ?? [], tags: readJson3(join12(dir, "content", "tags.json")) ?? [], users: readJson3(join12(dir, "content", "users.json")) ?? [], media: readJson3(join12(dir, "content", "media.json")) ?? [] });
26780
- mkdirSync6(join12(dir, "posts"), { recursive: true });
26781
- for (const f of files) writeFileSync9(join12(dir, "posts", f.file), f.text);
26856
+ const files = wpPostsToMarkdown({ origin: new URL(base).origin, posts, categories: readJson3(join13(dir, "content", "categories.json")) ?? [], tags: readJson3(join13(dir, "content", "tags.json")) ?? [], users: readJson3(join13(dir, "content", "users.json")) ?? [], media: readJson3(join13(dir, "content", "media.json")) ?? [] });
26857
+ mkdirSync6(join13(dir, "posts"), { recursive: true });
26858
+ for (const f of files) writeFileSync10(join13(dir, "posts", f.file), f.text);
26782
26859
  out(` posts as Markdown: ${files.length}`);
26783
26860
  }
26784
26861
  return true;
@@ -26849,7 +26926,7 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
26849
26926
  add(`${origin}/favicon.ico`, "icon");
26850
26927
  add(logoInPage(html), "logo");
26851
26928
  const saved = [];
26852
- const icons = join12(dir, "icons");
26929
+ const icons = join13(dir, "icons");
26853
26930
  for (const w of wanted.slice(0, 6)) {
26854
26931
  const res = await get(w.url, "image/*,*/*;q=0.8");
26855
26932
  if (!res?.ok) continue;
@@ -26860,14 +26937,14 @@ async function saveOldIcons(html, pageUrl, origin, dir) {
26860
26937
  if (!size && !svg) continue;
26861
26938
  const file2 = `${saved.length + 1}-${w.kind}.${svg ? "svg" : size?.format === "jpeg" ? "jpg" : size?.format}`;
26862
26939
  mkdirSync6(icons, { recursive: true });
26863
- writeFileSync9(join12(icons, file2), bytes);
26940
+ writeFileSync10(join13(icons, file2), bytes);
26864
26941
  saved.push({ file: file2, kind: w.kind });
26865
26942
  }
26866
- if (saved.length) writeFileSync9(join12(icons, "icons.json"), JSON.stringify(saved, null, 2));
26943
+ if (saved.length) writeFileSync10(join13(icons, "icons.json"), JSON.stringify(saved, null, 2));
26867
26944
  return saved.length;
26868
26945
  }
26869
26946
  async function saveOldStyles(html, pageUrl, dir) {
26870
- const styles = join12(dir, "styles");
26947
+ const styles = join13(dir, "styles");
26871
26948
  let n2 = 0;
26872
26949
  for (const url2 of stylesheetLinks(html, pageUrl, 6)) {
26873
26950
  const res = await get(url2, "text/css,*/*;q=0.8");
@@ -26875,7 +26952,7 @@ async function saveOldStyles(html, pageUrl, dir) {
26875
26952
  const text2 = await res.text();
26876
26953
  if (text2.length > ICON_MAX_BYTES) continue;
26877
26954
  mkdirSync6(styles, { recursive: true });
26878
- writeFileSync9(join12(styles, `${++n2}.css`), text2);
26955
+ writeFileSync10(join13(styles, `${++n2}.css`), text2);
26879
26956
  }
26880
26957
  }
26881
26958
  var TRIGGER_PAGES_CAP = 30;
@@ -26903,15 +26980,15 @@ async function hasRootFile(origin, path, query = "", cookie) {
26903
26980
  const res = await get(`${origin}${path}${query}`, "*/*", "follow", cookie);
26904
26981
  return Boolean(res?.ok && !/text\/html/i.test(res.headers.get("content-type") ?? ""));
26905
26982
  }
26906
- var tagsFile = (dir) => join12(dir, "tags.json");
26907
- var stateFile = (dir) => join12(dir, "report-state.json");
26983
+ var tagsFile = (dir) => join13(dir, "tags.json");
26984
+ var stateFile = (dir) => join13(dir, "report-state.json");
26908
26985
  function kitMap(root) {
26909
- if (!existsSync11(join12(root, "src/kit/schema.ts"))) return {};
26986
+ if (!existsSync12(join13(root, "src/kit/schema.ts"))) return {};
26910
26987
  const cut = (s, n2) => String(s ?? "").slice(0, n2);
26911
- const pages = (readJson3(join12(root, MOVED_PAGES_FILE)) ?? []).slice(0, 150).map((p) => ({ path: cut(p.path, 300), title: cut(p.title, 80), inNav: Boolean(p.inNav) }));
26912
- const posts = readJson3(join12(root, "src/kit/moved-posts.json")) ?? [];
26913
- const docs = [...new Set((readJson3(join12(root, MOVED_LEGAL_FILE))?.docs ?? []).map((d) => d.key).filter((k) => k === "privacy" || k === "terms" || k === "cancellation"))];
26914
- const forms = (readJson3(join12(root, "src/kit/forms.json")) ?? []).filter((f) => /^[a-z0-9-]{1,40}$/.test(f.key ?? "")).slice(0, 30).map((f) => ({
26988
+ const pages = (readJson3(join13(root, MOVED_PAGES_FILE)) ?? []).slice(0, 150).map((p) => ({ path: cut(p.path, 300), title: cut(p.title, 80), inNav: Boolean(p.inNav) }));
26989
+ const posts = readJson3(join13(root, "src/kit/moved-posts.json")) ?? [];
26990
+ const docs = [...new Set((readJson3(join13(root, MOVED_LEGAL_FILE))?.docs ?? []).map((d) => d.key).filter((k) => k === "privacy" || k === "terms" || k === "cancellation"))];
26991
+ const forms = (readJson3(join13(root, "src/kit/forms.json")) ?? []).filter((f) => /^[a-z0-9-]{1,40}$/.test(f.key ?? "")).slice(0, 30).map((f) => ({
26915
26992
  key: f.key,
26916
26993
  label: cut(f.label, 80),
26917
26994
  ...f.page ? { page: cut(f.page, 300) } : {},
@@ -26922,11 +26999,11 @@ function kitMap(root) {
26922
26999
  }
26923
27000
  async function sendReport(root, ctx, host, open2, verify) {
26924
27001
  const dir = hostDir(root, host);
26925
- const inv = readJson3(join12(dir, "inventory.json"));
27002
+ const inv = readJson3(join13(dir, "inventory.json"));
26926
27003
  const site = readJson3(tagsFile(dir));
26927
27004
  const startId = readChoices(root)?.startId;
26928
27005
  if (!inv || !site) return;
26929
- const dns = readJson3(join12(dir, "dns.json"));
27006
+ const dns = readJson3(join13(dir, "dns.json"));
26930
27007
  const thanksPages = findThanksPages(inv.pages);
26931
27008
  if (open2 === "scan") {
26932
27009
  if (thanksPages.length && site.forms.length) {
@@ -26956,9 +27033,9 @@ async function sendReport(root, ctx, host, open2, verify) {
26956
27033
  return;
26957
27034
  }
26958
27035
  const state = readJson3(stateFile(dir)) ?? {};
26959
- const plan = existsSync11(join12(root, MIGRATION_DIR, "plan.md")) ? readFileSync9(join12(root, MIGRATION_DIR, "plan.md"), "utf8") : "";
26960
- const saved = verify ?? readJson3(join12(dir, "verify-report.json"))?.report ?? null;
26961
- const assets = readJson3(join12(dir, "assets.json")) ?? [];
27036
+ const plan = existsSync12(join13(root, MIGRATION_DIR, "plan.md")) ? readFileSync10(join13(root, MIGRATION_DIR, "plan.md"), "utf8") : "";
27037
+ const saved = verify ?? readJson3(join13(dir, "verify-report.json"))?.report ?? null;
27038
+ const assets = readJson3(join13(dir, "assets.json")) ?? [];
26962
27039
  const report2 = {
26963
27040
  source: inv.source,
26964
27041
  platform: inv.platform,
@@ -27015,7 +27092,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
27015
27092
  out(`Scanning ${base} (${platform3})`);
27016
27093
  const robotsRes = await get(`${origin}/robots.txt`, "text/plain");
27017
27094
  const robots = robotsRes?.ok ? await robotsRes.text() : "";
27018
- if (robots) writeFileSync9(join12(dir, "robots.txt"), robots);
27095
+ if (robots) writeFileSync10(join13(dir, "robots.txt"), robots);
27019
27096
  const cap = Math.min(opts.max ?? PAGE_CAP, PAGE_CAP);
27020
27097
  const fromSitemaps = await sitemapUrls(base, robots ? parseRobots(robots).sitemaps : [], cap * 5);
27021
27098
  const all = [.../* @__PURE__ */ new Set([`${base}/`, ...fromSitemaps.urls, ...fromSitemaps.urls.length ? [] : homeLinks(html, base)])];
@@ -27055,7 +27132,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
27055
27132
  await addStylesheetAssets(assets);
27056
27133
  const wordpressApi = platform3 === "wordpress" ? await wordpressContent(base, dir) : false;
27057
27134
  if (wordpressApi) {
27058
- const media = readJson3(join12(dir, "content", "media.json")) ?? [];
27135
+ const media = readJson3(join13(dir, "content", "media.json")) ?? [];
27059
27136
  media.forEach((m) => m.source_url && assets.add(m.source_url));
27060
27137
  }
27061
27138
  const known = new Set(pages.map((p) => p.path));
@@ -27080,13 +27157,13 @@ async function migrateScanCommand(root, raw, opts = {}) {
27080
27157
  const bare = registrableDomain(host);
27081
27158
  try {
27082
27159
  const { records, unread } = await collectSnapshot(bare, { extraNames: [...site.ownNames, ...site.serverContainers], deadlineMs: 3e4 });
27083
- writeJson(join12(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
27160
+ writeJson(join13(dir, "dns.json"), { records: records.slice(0, 600), unread: unread.slice(0, 300), services: dnsServices(records).slice(0, 40) });
27084
27161
  } catch {
27085
27162
  }
27086
27163
  const inventory = { source: base, platform: platform3, scannedAt: (/* @__PURE__ */ new Date()).toISOString(), sitemaps: fromSitemaps.sitemaps, pages, wordpressApi, skipped: Math.max(0, all.length - list.length) };
27087
- writeJson(join12(dir, "inventory.json"), inventory);
27088
- writeJson(join12(dir, "assets.json"), [...assets].sort());
27089
- writeFileSync9(join12(dir, "home.html"), html);
27164
+ writeJson(join13(dir, "inventory.json"), inventory);
27165
+ writeJson(join13(dir, "assets.json"), [...assets].sort());
27166
+ writeFileSync10(join13(dir, "home.html"), html);
27090
27167
  const icons = await saveOldIcons(html, home.url, origin, dir);
27091
27168
  await saveOldStyles(html, home.url, dir);
27092
27169
  const rel = relative(root, dir).split(sep).join("/");
@@ -27100,7 +27177,7 @@ async function migrateScanCommand(root, raw, opts = {}) {
27100
27177
  if (icons) out(` icons/ ${icons} icons and logo of the old site, for: npx deployai@latest brand favicon`);
27101
27178
  if (wordpressApi) {
27102
27179
  out(" content/ the WordPress pages, posts, categories, tags, media and authors as JSON");
27103
- if (existsSync11(join12(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
27180
+ if (existsSync12(join13(dir, "posts"))) out(" posts/ the posts as Markdown for the blog block, each with its old address");
27104
27181
  } 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).");
27105
27182
  out();
27106
27183
  out("Keep every path in inventory.json exactly as it is: same address, same title and description.");
@@ -27120,8 +27197,8 @@ async function migrateMediaCommand(root) {
27120
27197
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
27121
27198
  for (const host of hosts) {
27122
27199
  const dir = hostDir(root, host);
27123
- const assets = readJson3(join12(dir, "assets.json")) ?? [];
27124
- const stateFile2 = join12(dir, "media-state.json");
27200
+ const assets = readJson3(join13(dir, "assets.json")) ?? [];
27201
+ const stateFile2 = join13(dir, "media-state.json");
27125
27202
  const state = readJson3(stateFile2) ?? { done: [], failed: [], bytes: 0 };
27126
27203
  const done = new Set(state.done);
27127
27204
  const todo = assets.filter((a) => !done.has(a));
@@ -27151,7 +27228,7 @@ async function migrateMediaCommand(root) {
27151
27228
  }
27152
27229
  state.done = [...done];
27153
27230
  writeJson(stateFile2, state);
27154
- out(` ${formatBytes(state.bytes)} in ${relative(root, join12(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
27231
+ out(` ${formatBytes(state.bytes)} in ${relative(root, join13(dir, "media")).split(sep).join("/")}${state.failed.length ? `, ${state.failed.length} could not be downloaded (listed in media-state.json)` : ""}`);
27155
27232
  }
27156
27233
  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.");
27157
27234
  }
@@ -27172,19 +27249,19 @@ function redirectLines(inv, rss = "/rss.xml") {
27172
27249
  function migratePostsCommand(root) {
27173
27250
  const hosts = scannedHosts(root);
27174
27251
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
27175
- if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27252
+ if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27176
27253
  const posts = [];
27177
27254
  for (const host of hosts) {
27178
27255
  const dir = hostDir(root, host);
27179
- const inv = readJson3(join12(dir, "inventory.json"));
27180
- const list = readJson3(join12(dir, "content", "posts.json"));
27181
- if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(join12(dir, "content", "categories.json")) ?? [], media: readJson3(join12(dir, "content", "media.json")) ?? [] }));
27256
+ const inv = readJson3(join13(dir, "inventory.json"));
27257
+ const list = readJson3(join13(dir, "content", "posts.json"));
27258
+ if (inv && list?.length) posts.push(...wpPostsToKit({ origin: new URL(inv.source).origin, posts: list, categories: readJson3(join13(dir, "content", "categories.json")) ?? [], media: readJson3(join13(dir, "content", "media.json")) ?? [] }));
27182
27259
  }
27183
27260
  if (!posts.length) {
27184
27261
  out("No posts in the scan. If the old site has posts, write src/kit/moved-posts.json yourself: .deployai/blocks/dashboard.md says how.");
27185
27262
  return;
27186
27263
  }
27187
- writeFileSync9(join12(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
27264
+ writeFileSync10(join13(root, "src/kit/moved-posts.json"), JSON.stringify(posts.map(({ lost: _lost, ...p }) => p), null, 1));
27188
27265
  out(`Wrote ${posts.length} posts to src/kit/moved-posts.json. Turn on blog in src/kit/site.config.ts.`);
27189
27266
  const short = posts.filter((p) => p.lost.length);
27190
27267
  if (short.length) {
@@ -27195,31 +27272,31 @@ function migratePostsCommand(root) {
27195
27272
  function migratePagesCommand(root) {
27196
27273
  const hosts = scannedHosts(root);
27197
27274
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
27198
- if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27199
- const file2 = join12(root, MOVED_PAGES_FILE);
27275
+ if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27276
+ const file2 = join13(root, MOVED_PAGES_FILE);
27200
27277
  const before = readJson3(file2);
27201
27278
  const pages = [];
27202
27279
  for (const host of hosts) {
27203
27280
  const dir = hostDir(root, host);
27204
- const inv = readJson3(join12(dir, "inventory.json"));
27281
+ const inv = readJson3(join13(dir, "inventory.json"));
27205
27282
  if (!inv) continue;
27206
- const homeHtml = existsSync11(join12(dir, "home.html")) ? readFileSync9(join12(dir, "home.html"), "utf8") : null;
27283
+ const homeHtml = existsSync12(join13(dir, "home.html")) ? readFileSync10(join13(dir, "home.html"), "utf8") : null;
27207
27284
  for (const p of movedPagesFromScan({ pages: inv.pages, homeHtml, origin: new URL(inv.source).origin })) if (!pages.some((x) => x.path === p.path)) pages.push(p);
27208
27285
  }
27209
27286
  const kept = before?.length ? pages.filter((p) => before.some((b) => b.path === p.path)) : pages;
27210
- writeFileSync9(file2, JSON.stringify(kept, null, 1));
27287
+ writeFileSync10(file2, JSON.stringify(kept, null, 1));
27211
27288
  out(`Wrote ${MOVED_PAGES_FILE}: ${kept.length} pages for the dashboard's Pages, ${kept.filter((p) => p.inNav).length} of them in the menu.`);
27212
27289
  out("Build each page at exactly its path, as a page of the site's code with its own look and words. Draw the site's menu from navItems() in src/kit/store.ts. A page the plan drops: remove it from this file.");
27213
27290
  }
27214
27291
  function migrateLegalCommand(root) {
27215
27292
  const hosts = scannedHosts(root);
27216
27293
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
27217
- if (!existsSync11(join12(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27294
+ if (!existsSync12(join13(root, "src/kit/schema.ts"))) throw new CliError("The dashboard is not in this folder yet. Run: npx deployai@latest blocks dashboard", 1, "usage");
27218
27295
  const pages = [];
27219
27296
  const site = emptySiteTags();
27220
27297
  for (const host of hosts) {
27221
27298
  const dir = hostDir(root, host);
27222
- pages.push(...readJson3(join12(dir, "inventory.json"))?.pages ?? []);
27299
+ pages.push(...readJson3(join13(dir, "inventory.json"))?.pages ?? []);
27223
27300
  const found = readJson3(tagsFile(dir));
27224
27301
  if (found) {
27225
27302
  site.tags.push(...found.tags);
@@ -27227,9 +27304,9 @@ function migrateLegalCommand(root) {
27227
27304
  site.forms.push(...found.forms);
27228
27305
  }
27229
27306
  }
27230
- const file2 = join12(root, MOVED_LEGAL_FILE);
27307
+ const file2 = join13(root, MOVED_LEGAL_FILE);
27231
27308
  const legal = { ...movedLegalFromScan({ pages, site }), docs: readJson3(file2)?.docs ?? [] };
27232
- writeFileSync9(file2, JSON.stringify(legal, null, 1));
27309
+ writeFileSync10(file2, JSON.stringify(legal, null, 1));
27233
27310
  out(`Wrote ${MOVED_LEGAL_FILE}: ${legal.duties.length} rows for the dashboard's Documents page, ${legal.forms.length} forms, ${legal.services.length} outside services.`);
27234
27311
  for (const d of legal.duties) if (d.old) out(` ${d.key}: the old site has its own page at ${d.old}. Keep it. See "Accessibility and documents" in .deployai/blocks/dashboard.md.`);
27235
27312
  out("Nothing here is finished or checked: it tells the owner what to look at. Keep tags, forms and pages as they are.");
@@ -27239,22 +27316,22 @@ function migrateRedirectsCommand(root) {
27239
27316
  if (!hosts.length) throw new CliError("Nothing scanned yet. Run: npx deployai@latest migrate scan <the old site address>", 1, "usage");
27240
27317
  const lines = /* @__PURE__ */ new Set();
27241
27318
  for (const host of hosts) {
27242
- const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
27319
+ const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
27243
27320
  if (inv) redirectLines(inv).forEach((l) => lines.add(l));
27244
27321
  }
27245
- const publicDir = join12(root, "public");
27246
- const file2 = join12(existsSync11(publicDir) ? publicDir : root, "_redirects");
27247
- const before = existsSync11(file2) ? readFileSync9(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
27322
+ const publicDir = join13(root, "public");
27323
+ const file2 = join13(existsSync12(publicDir) ? publicDir : root, "_redirects");
27324
+ const before = existsSync12(file2) ? readFileSync10(file2, "utf8").split(/\r?\n/).filter(Boolean) : [];
27248
27325
  const added = [...lines].filter((l) => !before.some((b) => b.split(/\s+/)[0] === l.split(/\s+/)[0]));
27249
- writeFileSync9(file2, [...before, ...added].join("\n") + "\n");
27326
+ writeFileSync10(file2, [...before, ...added].join("\n") + "\n");
27250
27327
  out(`${relative(root, file2).split(sep).join("/")}: ${added.length} added, ${before.length + added.length} in all (at most 2,000; no query strings).`);
27251
27328
  out('Add a line "<old path> <new path> 301" only for a page that truly could not keep its address.');
27252
27329
  }
27253
27330
  function allowedRedirects(root) {
27254
27331
  const map2 = /* @__PURE__ */ new Map();
27255
- for (const file2 of [join12(root, "public", "_redirects"), join12(root, "_redirects")]) {
27256
- if (!existsSync11(file2)) continue;
27257
- for (const line of readFileSync9(file2, "utf8").split(/\r?\n/)) {
27332
+ for (const file2 of [join13(root, "public", "_redirects"), join13(root, "_redirects")]) {
27333
+ if (!existsSync12(file2)) continue;
27334
+ for (const line of readFileSync10(file2, "utf8").split(/\r?\n/)) {
27258
27335
  const [from, to] = line.trim().split(/\s+/);
27259
27336
  if (from && to && !from.startsWith("#")) map2.set(from, to);
27260
27337
  }
@@ -27284,11 +27361,11 @@ async function migrateTagsCommand(root, ctx, opts) {
27284
27361
  const [k, v] = a.split("=");
27285
27362
  if (!QUESTION_KEYS.includes(k) || !ANSWERS.includes(v)) throw new CliError(`Not an answer: ${a}. Use one of ${QUESTION_KEYS.join(", ")} = ${ANSWERS.join(", ")}, for example serverPixel=yes.`, 1, "usage");
27286
27363
  }
27287
- const urls = opts.requests ? readFileSync9(resolve(root, opts.requests), "utf8").split(/\r?\n/) : [];
27364
+ const urls = opts.requests ? readFileSync10(resolve(root, opts.requests), "utf8").split(/\r?\n/) : [];
27288
27365
  for (const host of hosts) {
27289
27366
  const dir = hostDir(root, host);
27290
27367
  const site = readJson3(tagsFile(dir));
27291
- const inv = readJson3(join12(dir, "inventory.json"));
27368
+ const inv = readJson3(join13(dir, "inventory.json"));
27292
27369
  if (!site || !inv) continue;
27293
27370
  const state = readJson3(stateFile(dir)) ?? {};
27294
27371
  if (urls.length && opts.fired) {
@@ -27358,7 +27435,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
27358
27435
  const tagFindings = [];
27359
27436
  const perHost = [];
27360
27437
  for (const host of hosts) {
27361
- const inv = readJson3(join12(hostDir(root, host), "inventory.json"));
27438
+ const inv = readJson3(join13(hostDir(root, host), "inventory.json"));
27362
27439
  const oldSite = readJson3(tagsFile(hostDir(root, host)));
27363
27440
  const state = readJson3(stateFile(hostDir(root, host))) ?? {};
27364
27441
  const nextSite = emptySiteTags();
@@ -27407,7 +27484,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
27407
27484
  }
27408
27485
  }
27409
27486
  const words = { missing: "not found on the preview", moved: "moved to", error: "answers", title_lost: "lost its title", description_lost: "lost its description" };
27410
- const report2 = join12(root, MIGRATION_DIR, "verify.json");
27487
+ const report2 = join13(root, MIGRATION_DIR, "verify.json");
27411
27488
  writeJson(report2, { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), preview: preview.origin, checked, findings, credits: [...credits.keys()], vendors: [...vendors.keys()], tags: tagFindings });
27412
27489
  if (credits.size) {
27413
27490
  out(`A builder's credit is still on the preview:`);
@@ -27432,7 +27509,7 @@ async function migrateVerifyCommand(root, previewRaw, ctx, retryMs = PREVIEW_RET
27432
27509
  for (const h of perHost) {
27433
27510
  const dir = hostDir(root, h.host);
27434
27511
  const verify = { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), pagesChecked: h.checked, pageProblems: h.problems, findings: h.found.map((f) => ({ problem: f.problem, what: f.what.slice(0, 240), ...f.detail ? { detail: f.detail.slice(0, 300) } : {}, ...f.page ? { page: f.page.slice(0, 300) } : {} })).slice(0, 300), seen: h.seen.slice(0, 300), removed: h.removed, vendors: [...vendors.keys()].map((v) => v.slice(0, 80)).slice(0, 40) };
27435
- writeJson(join12(dir, "verify-report.json"), { report: verify });
27512
+ writeJson(join13(dir, "verify-report.json"), { report: verify });
27436
27513
  await sendReport(root, ctx, h.host, clean3 ? "verify" : null, verify);
27437
27514
  }
27438
27515
  if (!findings.length) {
@@ -27560,32 +27637,32 @@ async function askYes(question) {
27560
27637
  }
27561
27638
 
27562
27639
  // src/same-name.ts
27563
- import { createHash } from "crypto";
27564
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "fs";
27565
- import { dirname as dirname3, join as join13 } from "path";
27640
+ import { createHash as createHash2 } from "crypto";
27641
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "fs";
27642
+ import { dirname as dirname3, join as join14 } from "path";
27566
27643
  var LAST_FILES = ".deployai/last-files.json";
27567
27644
  var KEPT = /^(public|static)\/.*\.(avif|webp|png|jpe?g|gif|svg|ico|woff2?|ttf|otf|mp4|webm|css|js|mjs)$/i;
27568
27645
  var HASHED = /[.-][A-Za-z0-9_]{6,20}\.[a-z0-9]+$/;
27569
- var digest = (abs) => createHash("sha1").update(readFileSync10(abs)).digest("hex").slice(0, 16);
27646
+ var digest = (abs) => createHash2("sha1").update(readFileSync11(abs)).digest("hex").slice(0, 16);
27570
27647
  function changedUnderSameName(root, files) {
27571
27648
  const now = {};
27572
27649
  for (const f of files) if (KEPT.test(f.rel) && !HASHED.test(f.rel.split("/").pop() ?? "")) now[f.rel] = digest(f.abs);
27573
27650
  let before = {};
27574
27651
  try {
27575
- before = readJson(join13(root, LAST_FILES));
27652
+ before = readJson(join14(root, LAST_FILES));
27576
27653
  } catch {
27577
27654
  }
27578
27655
  const changed = Object.keys(now).filter((rel) => before[rel] && before[rel] !== now[rel]).sort();
27579
27656
  try {
27580
- mkdirSync7(dirname3(join13(root, LAST_FILES)), { recursive: true });
27581
- writeFileSync10(join13(root, LAST_FILES), JSON.stringify(now));
27657
+ mkdirSync7(dirname3(join14(root, LAST_FILES)), { recursive: true });
27658
+ writeFileSync11(join14(root, LAST_FILES), JSON.stringify(now));
27582
27659
  } catch {
27583
27660
  }
27584
27661
  return changed;
27585
27662
  }
27586
27663
 
27587
27664
  // src/tar.ts
27588
- import { readFileSync as readFileSync11 } from "fs";
27665
+ import { readFileSync as readFileSync12 } from "fs";
27589
27666
  import { gzipSync } from "zlib";
27590
27667
  var BLOCK = 512;
27591
27668
  function writeString(buf, offset, length, value) {
@@ -27669,7 +27746,7 @@ function packFiles(files) {
27669
27746
  return createTarGz(
27670
27747
  files.map((f) => ({
27671
27748
  name: f.rel,
27672
- data: readFileSync11(f.abs),
27749
+ data: readFileSync12(f.abs),
27673
27750
  mtimeMs: f.mtimeMs,
27674
27751
  mode: f.mode & 64 ? 493 : 420
27675
27752
  }))
@@ -28267,13 +28344,13 @@ async function claimCommand(root, ctx, opts) {
28267
28344
 
28268
28345
  // src/commands/pull.ts
28269
28346
  import { spawnSync as spawnSync2 } from "child_process";
28270
- import { existsSync as existsSync13, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
28271
- import { join as join15 } from "path";
28347
+ import { existsSync as existsSync14, readdirSync as readdirSync5, rmSync as rmSync2 } from "fs";
28348
+ import { join as join16 } from "path";
28272
28349
 
28273
28350
  // src/commands/samples.ts
28274
28351
  import { createInterface as createInterface3 } from "readline/promises";
28275
- import { existsSync as existsSync12, mkdirSync as mkdirSync8, readdirSync as readdirSync4, writeFileSync as writeFileSync11 } from "fs";
28276
- import { dirname as dirname4, join as join14, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
28352
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readdirSync as readdirSync4, writeFileSync as writeFileSync12 } from "fs";
28353
+ import { dirname as dirname4, join as join15, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
28277
28354
  import { gunzipSync } from "zlib";
28278
28355
  var SAMPLES = [
28279
28356
  { key: "landing", title: "Landing page: a full one-page site with WhatsApp sign-up", stack: "static HTML and CSS" },
@@ -28294,7 +28371,7 @@ function listSamples(apiUrl) {
28294
28371
  out(`See them live: ${apiUrl}/samples`);
28295
28372
  }
28296
28373
  function filesIn(dir) {
28297
- return existsSync12(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
28374
+ return existsSync13(dir) ? readdirSync4(dir).filter((f) => !IGNORED.has(f)) : [];
28298
28375
  }
28299
28376
  function freeFolder(cwd, key) {
28300
28377
  for (let n2 = 1; ; n2++) {
@@ -28354,7 +28431,7 @@ function extractInto(gz, root, damaged) {
28354
28431
  const target = resolve2(base, e3.name);
28355
28432
  if (target !== base && !target.startsWith(base + sep2)) continue;
28356
28433
  mkdirSync8(dirname4(target), { recursive: true });
28357
- writeFileSync11(target, e3.data);
28434
+ writeFileSync12(target, e3.data);
28358
28435
  written++;
28359
28436
  }
28360
28437
  return written;
@@ -28378,7 +28455,7 @@ async function samplesCommand(cwd, ctx, key, opts = {}) {
28378
28455
  }
28379
28456
  const written = await downloadSample(ctx, sample.key, root);
28380
28457
  const base = resolve2(root);
28381
- const hasPackage = existsSync12(join14(base, "package.json"));
28458
+ const hasPackage = existsSync13(join15(base, "package.json"));
28382
28459
  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.`);
28383
28460
  out("");
28384
28461
  const t = messages(base);
@@ -28435,7 +28512,7 @@ var git = (root, args, env = {}) => spawnSync2("git", args, { cwd: root, encodin
28435
28512
  function clearTree(root) {
28436
28513
  for (const name of readdirSync5(root)) {
28437
28514
  if (name === ".git" || name === ".deployai") continue;
28438
- rmSync2(join15(root, name), { recursive: true, force: true });
28515
+ rmSync2(join16(root, name), { recursive: true, force: true });
28439
28516
  }
28440
28517
  }
28441
28518
  async function pullHistory(root, ctx, projectId) {
@@ -28445,7 +28522,7 @@ async function pullHistory(root, ctx, projectId) {
28445
28522
  const live = versions.find((v) => v.isLive)?.number ?? Math.max(0, ...versions.filter((v) => v.status === "ready").map((v) => v.number));
28446
28523
  const chosen = versions.filter((v) => v.number <= live && v.status !== "failed" && v.status !== "queued").sort((a, b) => a.number - b.number);
28447
28524
  if (!chosen.length) throw new CliError(t("pullNoSource"), 1, "not_found");
28448
- if (!existsSync13(join15(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
28525
+ if (!existsSync14(join16(root, ".git")) && git(root, ["init", "-q"]).status !== 0) throw new CliError(t("pullNoGit"), 1, "usage");
28449
28526
  for (const v of chosen) {
28450
28527
  const gz = await fetchSource(root, ctx, projectId, v.number).catch(() => null);
28451
28528
  if (!gz) continue;
@@ -28496,12 +28573,12 @@ async function requestsOpenCommand(root, ctx, path, open2) {
28496
28573
 
28497
28574
  // src/commands/start.ts
28498
28575
  import { spawnSync as spawnSync3 } from "child_process";
28499
- import { existsSync as existsSync14, writeFileSync as writeFileSync13 } from "fs";
28500
- import { join as join17, relative as relative3, resolve as resolve3 } from "path";
28576
+ import { existsSync as existsSync15, writeFileSync as writeFileSync14 } from "fs";
28577
+ import { join as join18, relative as relative3, resolve as resolve3 } from "path";
28501
28578
 
28502
28579
  // src/commands/starter.ts
28503
- import { writeFileSync as writeFileSync12 } from "fs";
28504
- import { join as join16 } from "path";
28580
+ import { writeFileSync as writeFileSync13 } from "fs";
28581
+ import { join as join17 } from "path";
28505
28582
  var esc2 = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
28506
28583
  var TEXT = {
28507
28584
  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." },
@@ -28549,8 +28626,8 @@ DeployAI wrote this page so the folder starts as a working site. Build the owner
28549
28626
  - Delete this README or replace it with notes about the site.
28550
28627
  `;
28551
28628
  function writeStarter(root, name, lang, stack) {
28552
- writeFileSync12(join16(root, "index.html"), page2(name ?? "", lang, stack));
28553
- writeFileSync12(join16(root, "README.md"), README);
28629
+ writeFileSync13(join17(root, "index.html"), page2(name ?? "", lang, stack));
28630
+ writeFileSync13(join17(root, "README.md"), README);
28554
28631
  }
28555
28632
 
28556
28633
  // src/commands/start.ts
@@ -28624,7 +28701,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
28624
28701
  if (sample && !sameSite) {
28625
28702
  const written = await downloadSample(ctxNow, sample.key, root);
28626
28703
  done.push(t("startDownloaded", { key: sample.key, n: written }));
28627
- if (existsSync14(join17(root, "package.json"))) {
28704
+ if (existsSync15(join18(root, "package.json"))) {
28628
28705
  if (opts.install !== false && install(root)) done.push(t("startInstalled"));
28629
28706
  else steps.unshift({ cmd: "npm install", say: "Installs the sample's packages." });
28630
28707
  }
@@ -28649,7 +28726,7 @@ async function startCommand(cwd, ctx, id, opts = {}) {
28649
28726
  const stackText = choices.stack ? stackBlock(choices.stack) : "";
28650
28727
  if (choices.brief || stackText) {
28651
28728
  ensureDeployaiDir(root);
28652
- writeFileSync13(join17(root, BRIEF_FILE), [choices.brief ? `# The owner's details
28729
+ writeFileSync14(join18(root, BRIEF_FILE), [choices.brief ? `# The owner's details
28653
28730
 
28654
28731
  ${choices.brief}
28655
28732
  ` : "", stackText].filter(Boolean).join("\n"));
@@ -28707,14 +28784,14 @@ ${choices.brief}
28707
28784
  for (const line of server.extra) say(line);
28708
28785
  say(rule(server, "startFail", START_FAIL_LINE));
28709
28786
  ensureDeployaiDir(root);
28710
- writeFileSync13(join17(root, START_FILE), `${lines.join("\n")}
28787
+ writeFileSync14(join18(root, START_FILE), `${lines.join("\n")}
28711
28788
  `);
28712
28789
  }
28713
28790
 
28714
28791
  // src/commands/addon.ts
28715
- import { dirname as dirname5, join as join18, resolve as resolve4 } from "path";
28792
+ import { dirname as dirname5, join as join19, resolve as resolve4 } from "path";
28716
28793
  import { mkdirSync as mkdirSync9 } from "fs";
28717
- import { existsSync as existsSync15, writeFileSync as writeFileSync14 } from "fs";
28794
+ import { existsSync as existsSync16, writeFileSync as writeFileSync15 } from "fs";
28718
28795
  function linkedProjectId2(root) {
28719
28796
  const id = readProject(root)?.projectId;
28720
28797
  if (!id) throw new CliError("This folder is not linked to a DeployAI site. Run: npx deployai@latest login, then npx deployai@latest link", 1, "not_linked");
@@ -28771,7 +28848,7 @@ async function addonsRunCommand(root, ctx, opts = {}) {
28771
28848
  const all = opts.all === true || !opts.oneByOne && readProject(root)?.addonsAll === true;
28772
28849
  if (!order && r.picked && !r.agreed && todo.length > 1 && (opts.all || !all)) {
28773
28850
  const stamps = readStamps(root);
28774
- const items = todo.map((a) => ({ ...a, trace: addonTrace(a.key, (path) => existsSync15(join18(root, path)), stamps) }));
28851
+ const items = todo.map((a) => ({ ...a, trace: addonTrace(a.key, (path) => existsSync16(join19(root, path)), stamps) }));
28775
28852
  addonOrderBrief(items, opts.all ? "all" : opts.oneByOne ? "one-by-one" : null).forEach((line) => out(line));
28776
28853
  return;
28777
28854
  }
@@ -28819,19 +28896,19 @@ async function addonBuyCommand(root, ctx, key) {
28819
28896
  }
28820
28897
  function readStamps(root) {
28821
28898
  try {
28822
- return readJson(join18(root, ADDON_STAMP_FILE));
28899
+ return readJson(join19(root, ADDON_STAMP_FILE));
28823
28900
  } catch {
28824
28901
  return {};
28825
28902
  }
28826
28903
  }
28827
28904
  function writeStamps(root, stamps) {
28828
- const file2 = join18(root, ADDON_STAMP_FILE);
28905
+ const file2 = join19(root, ADDON_STAMP_FILE);
28829
28906
  mkdirSync9(dirname5(file2), { recursive: true });
28830
- writeFileSync14(file2, JSON.stringify(stamps, null, 2));
28907
+ writeFileSync15(file2, JSON.stringify(stamps, null, 2));
28831
28908
  }
28832
28909
  function printAddon(root, a) {
28833
28910
  const stamps = readStamps(root);
28834
- const trace = addonTrace(a.key, (path) => existsSync15(join18(root, path)), stamps);
28911
+ const trace = addonTrace(a.key, (path) => existsSync16(join19(root, path)), stamps);
28835
28912
  writeStamps(root, { ...stamps, [a.key]: { ...stamps[a.key], runId: a.runId } });
28836
28913
  out(`DeployAI add-on ${a.position} of ${a.total}: ${a.name} (${a.key}, run ${a.runId}).`);
28837
28914
  const line = addonTraceLine(a.key, a.runId, trace);
@@ -28890,9 +28967,9 @@ async function addonDoneCommand(root, ctx, runId, opts) {
28890
28967
 
28891
28968
  // src/commands/speed.ts
28892
28969
  import { spawn as spawn3 } from "child_process";
28893
- import { mkdtempSync, readFileSync as readFileSync12, rmSync as rmSync3 } from "fs";
28970
+ import { mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync3 } from "fs";
28894
28971
  import { tmpdir } from "os";
28895
- import { join as join19 } from "path";
28972
+ import { join as join20 } from "path";
28896
28973
  var ms = (v) => v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${Math.round(v)} ms`;
28897
28974
  var LOCAL_WAIT_MS = 18e4;
28898
28975
  function runLighthouse(url2, strategy, browser, file2) {
@@ -28916,11 +28993,11 @@ function runLighthouse(url2, strategy, browser, file2) {
28916
28993
  }
28917
28994
  async function localSpeed(url2, strategy, run = runLighthouse, browser = findBrowser()) {
28918
28995
  if (!browser) return null;
28919
- const dir = mkdtempSync(join19(tmpdir(), "deployai-speed-"));
28996
+ const dir = mkdtempSync(join20(tmpdir(), "deployai-speed-"));
28920
28997
  try {
28921
- const file2 = join19(dir, "report.json");
28998
+ const file2 = join20(dir, "report.json");
28922
28999
  await run(url2, strategy, browser, file2);
28923
- const lighthouseResult = JSON.parse(readFileSync12(file2, "utf8"));
29000
+ const lighthouseResult = JSON.parse(readFileSync13(file2, "utf8"));
28924
29001
  return lighthouseResult.categories ? mapPsi({ lighthouseResult }, strategy) : null;
28925
29002
  } catch {
28926
29003
  return null;
@@ -28984,8 +29061,8 @@ async function speedCommand(ctx, url2, opts, deps = {}) {
28984
29061
 
28985
29062
  // src/commands/shot.ts
28986
29063
  import { spawn as spawn4 } from "child_process";
28987
- import { existsSync as existsSync16, mkdirSync as mkdirSync10 } from "fs";
28988
- import { join as join20, resolve as resolve5 } from "path";
29064
+ import { existsSync as existsSync17, mkdirSync as mkdirSync10 } from "fs";
29065
+ import { join as join21, resolve as resolve5 } from "path";
28989
29066
  var SHOT_SIZES = [{ name: "phone", size: "390,844" }, { name: "desktop", size: "1440,900" }];
28990
29067
  var PLAYWRIGHT = "playwright@1.56";
28991
29068
  var WAIT_MS3 = 18e4;
@@ -29021,14 +29098,14 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
29021
29098
  const browser = opts.webkit ? null : findBrowser();
29022
29099
  if (!opts.webkit && !browser) throw new CliError("No Chrome or Edge was found on this computer. Install Chrome, set CHROME_PATH to its path, or run shot again with --webkit (it downloads Safari's engine first).", 1, "no_browser");
29023
29100
  if (opts.webkit && await run(["--yes", PLAYWRIGHT, "install", "webkit"]) !== 0) throw new CliError("Safari's engine could not be installed. Run shot without --webkit to use Chrome or Edge.", 1, "shot_failed");
29024
- const dir = resolve5(root, opts.out ?? join20(".deployai", "shots"));
29101
+ const dir = resolve5(root, opts.out ?? join21(".deployai", "shots"));
29025
29102
  mkdirSync10(dir, { recursive: true });
29026
29103
  const saved = [];
29027
29104
  for (const s of SHOT_SIZES) {
29028
- const file2 = join20(dir, shotName(url2.toString(), s.name));
29105
+ const file2 = join21(dir, shotName(url2.toString(), s.name));
29029
29106
  const engine = opts.webkit ? ["--browser=webkit"] : [`--channel=${channelFor(browser)}`];
29030
29107
  const code = await run(["--yes", PLAYWRIGHT, "screenshot", ...engine, `--viewport-size=${s.size}`, "--full-page", "--wait-for-timeout=1500", url2.toString(), file2]);
29031
- if (code !== 0 || !existsSync16(file2)) throw new CliError(`The ${s.name} picture of ${url2} could not be taken. Check that the page opens, then run shot again.`, 1, "shot_failed");
29108
+ if (code !== 0 || !existsSync17(file2)) throw new CliError(`The ${s.name} picture of ${url2} could not be taken. Check that the page opens, then run shot again.`, 1, "shot_failed");
29032
29109
  saved.push(file2);
29033
29110
  out(`${s.name.padEnd(8)} ${file2}`);
29034
29111
  }
@@ -29038,10 +29115,10 @@ async function shotCommand(root, address, opts = {}, run = runNpx) {
29038
29115
 
29039
29116
  // src/commands/images.ts
29040
29117
  import { spawnSync as spawnSync4 } from "child_process";
29041
- import { existsSync as existsSync17, mkdirSync as mkdirSync11, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync15 } from "fs";
29118
+ import { existsSync as existsSync18, mkdirSync as mkdirSync11, readdirSync as readdirSync6, statSync as statSync3, writeFileSync as writeFileSync16 } from "fs";
29042
29119
  import { createRequire } from "module";
29043
29120
  import { homedir as homedir3 } from "os";
29044
- import { extname, join as join21, relative as relative4, resolve as resolve6 } from "path";
29121
+ import { extname, join as join22, relative as relative4, resolve as resolve6 } from "path";
29045
29122
  var PHONE_WIDTH = 640;
29046
29123
  var SHARP = "sharp@0.34";
29047
29124
  var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", ".git", ".deployai", "dist", ".astro", ".next"]);
@@ -29049,14 +29126,14 @@ function imagesIn(dir) {
29049
29126
  const found = [];
29050
29127
  const walk2 = (d) => {
29051
29128
  for (const name of readdirSync6(d)) {
29052
- const p = join21(d, name);
29129
+ const p = join22(d, name);
29053
29130
  const st = statSync3(p);
29054
29131
  if (st.isDirectory()) {
29055
29132
  if (!SKIP_DIRS2.has(name)) walk2(p);
29056
29133
  } else if (/\.(jpe?g|png)$/i.test(name)) found.push(p);
29057
29134
  }
29058
29135
  };
29059
- if (existsSync17(dir)) walk2(dir);
29136
+ if (existsSync18(dir)) walk2(dir);
29060
29137
  return found.sort();
29061
29138
  }
29062
29139
  function outputsFor(file2, width) {
@@ -29066,15 +29143,15 @@ function outputsFor(file2, width) {
29066
29143
  return list;
29067
29144
  }
29068
29145
  function loadSharp() {
29069
- const dir = join21(homedir3(), ".deployai", "tools", "sharp");
29070
- if (!existsSync17(join21(dir, "node_modules", "sharp"))) {
29146
+ const dir = join22(homedir3(), ".deployai", "tools", "sharp");
29147
+ if (!existsSync18(join22(dir, "node_modules", "sharp"))) {
29071
29148
  mkdirSync11(dir, { recursive: true });
29072
- if (!existsSync17(join21(dir, "package.json"))) writeFileSync15(join21(dir, "package.json"), '{"private":true}');
29149
+ if (!existsSync18(join22(dir, "package.json"))) writeFileSync16(join22(dir, "package.json"), '{"private":true}');
29073
29150
  out("Getting the image tool once (it stays outside the site)...");
29074
29151
  const r = spawnSync4(process.platform === "win32" ? "npm.cmd" : "npm", ["install", SHARP, "--no-audit", "--no-fund", "--silent"], { cwd: dir, stdio: "ignore", shell: process.platform === "win32" });
29075
29152
  if (r.status !== 0) throw new CliError("The image tool could not be installed. Check the internet connection and run optimize again.", 1, "images_failed");
29076
29153
  }
29077
- return createRequire(join21(dir, "package.json"))("sharp");
29154
+ return createRequire(join22(dir, "package.json"))("sharp");
29078
29155
  }
29079
29156
  async function imagesCommand(root, folder, sharp = loadSharp) {
29080
29157
  const dir = resolve6(root, folder ?? "public");
@@ -29091,7 +29168,7 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
29091
29168
  const size = statSync3(file2).size;
29092
29169
  const meta3 = await make(file2).metadata();
29093
29170
  const outputs = outputsFor(file2, meta3.width);
29094
- if (outputs.every((o) => existsSync17(o.file) && statSync3(o.file).mtimeMs >= statSync3(file2).mtimeMs)) {
29171
+ if (outputs.every((o) => existsSync18(o.file) && statSync3(o.file).mtimeMs >= statSync3(file2).mtimeMs)) {
29095
29172
  skipped++;
29096
29173
  continue;
29097
29174
  }
@@ -29110,8 +29187,8 @@ async function imagesCommand(root, folder, sharp = loadSharp) {
29110
29187
  }
29111
29188
 
29112
29189
  // src/commands/blocks.ts
29113
- import { createHash as createHash2 } from "crypto";
29114
- import { existsSync as existsSync18, mkdirSync as mkdirSync12, readFileSync as readFileSync13, writeFileSync as writeFileSync16 } from "fs";
29190
+ import { createHash as createHash3 } from "crypto";
29191
+ import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync14, writeFileSync as writeFileSync17 } from "fs";
29115
29192
  import { dirname as dirname6, resolve as resolve7, sep as sep3 } from "path";
29116
29193
  import { gunzipSync as gunzipSync2 } from "zlib";
29117
29194
  var BLOCKS = [
@@ -29121,7 +29198,7 @@ var BLOCKS = [
29121
29198
  { key: "late-tags", title: "Tracking tags (Tag Manager, Google, Meta, Clarity) that load a moment after the page shows, at once on conversion pages and ad clicks" }
29122
29199
  ];
29123
29200
  var MAX_BYTES3 = 5 * 1024 * 1024;
29124
- var sha = (data) => createHash2("sha256").update(data).digest("hex");
29201
+ var sha = (data) => createHash3("sha256").update(data).digest("hex");
29125
29202
  var lockPath = (base, key) => resolve7(base, ".deployai", "blocks", `${key}.lock.json`);
29126
29203
  function readLock(base, key) {
29127
29204
  try {
@@ -29165,12 +29242,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
29165
29242
  if (e3.type !== "0" && e3.type !== "\0") continue;
29166
29243
  const target = resolve7(base, e3.name);
29167
29244
  if (target === base || !target.startsWith(base + sep3)) continue;
29168
- if (existsSync18(target)) {
29169
- const now = sha(readFileSync13(target));
29245
+ if (existsSync19(target)) {
29246
+ const now = sha(readFileSync14(target));
29170
29247
  if (now === sha(e3.data)) {
29171
29248
  lock[e3.name] = now;
29172
29249
  } else if (opts.update && lock[e3.name] === now) {
29173
- writeFileSync16(target, e3.data);
29250
+ writeFileSync17(target, e3.data);
29174
29251
  lock[e3.name] = sha(e3.data);
29175
29252
  updated.push(e3.name);
29176
29253
  } else {
@@ -29179,12 +29256,12 @@ async function blocksCommand(root, ctx, name, opts = {}) {
29179
29256
  continue;
29180
29257
  }
29181
29258
  mkdirSync12(dirname6(target), { recursive: true });
29182
- writeFileSync16(target, e3.data);
29259
+ writeFileSync17(target, e3.data);
29183
29260
  lock[e3.name] = sha(e3.data);
29184
29261
  written.push(e3.name);
29185
29262
  }
29186
29263
  mkdirSync12(dirname6(lockPath(base, block.key)), { recursive: true });
29187
- writeFileSync16(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
29264
+ writeFileSync17(lockPath(base, block.key), `${JSON.stringify(lock, null, 2)}
29188
29265
  `);
29189
29266
  out(`Added the ${block.key} block: ${written.length} files.`);
29190
29267
  written.forEach((f) => out(` + ${f}`));
@@ -29245,10 +29322,10 @@ async function integrationsCommand(ctx, name, opts = {}) {
29245
29322
 
29246
29323
  // src/commands/brand.ts
29247
29324
  import { spawn as spawn5 } from "child_process";
29248
- import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync2, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync4, statSync as statSync4, writeFileSync as writeFileSync17 } from "fs";
29325
+ import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync2, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync4, statSync as statSync4, writeFileSync as writeFileSync18 } from "fs";
29249
29326
  import { createServer } from "http";
29250
29327
  import { tmpdir as tmpdir2 } from "os";
29251
- import { basename as basename2, dirname as dirname7, extname as extname2, join as join22, relative as relative5, sep as sep4 } from "path";
29328
+ import { basename as basename2, dirname as dirname7, extname as extname2, join as join23, relative as relative5, sep as sep4 } from "path";
29252
29329
  import { randomBytes } from "crypto";
29253
29330
 
29254
29331
  // src/commands/brand-page.ts
@@ -29340,7 +29417,7 @@ var WALK_CAP = 4e3;
29340
29417
  var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", ".output", ".svelte-kit", ".wrangler", ".deployai"]);
29341
29418
  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" };
29342
29419
  function webRoot(root) {
29343
- for (const d of ["public", "static"]) if (existsSync19(join22(root, d))) return join22(root, d);
29420
+ for (const d of ["public", "static"]) if (existsSync20(join23(root, d))) return join23(root, d);
29344
29421
  return root;
29345
29422
  }
29346
29423
  function walk(dir, found = []) {
@@ -29352,7 +29429,7 @@ function walk(dir, found = []) {
29352
29429
  }
29353
29430
  for (const n2 of names) {
29354
29431
  if (found.length >= WALK_CAP) break;
29355
- const p = join22(dir, n2);
29432
+ const p = join23(dir, n2);
29356
29433
  let isDir = false;
29357
29434
  try {
29358
29435
  isDir = statSync4(p).isDirectory();
@@ -29367,31 +29444,31 @@ function walk(dir, found = []) {
29367
29444
  }
29368
29445
  function existingFavicon(root) {
29369
29446
  const web = webRoot(root);
29370
- for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync19(join22(web, f))) return relative5(root, join22(web, f)).split(sep4).join("/");
29371
- for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync19(join22(root, d, f))) return `${d}/${f}`;
29447
+ for (const f of ["favicon.ico", "favicon.svg", "favicon.png", "icon.svg", "icon.png"]) if (existsSync20(join23(web, f))) return relative5(root, join23(web, f)).split(sep4).join("/");
29448
+ for (const d of ["app", "src/app"]) for (const f of ["favicon.ico", "icon.svg", "icon.png", "icon.tsx", "icon.jpg"]) if (existsSync20(join23(root, d, f))) return `${d}/${f}`;
29372
29449
  for (const f of walk(root).filter((p) => /\.(html|astro|tsx|jsx|vue|svelte)$/.test(p)).slice(0, 400)) {
29373
29450
  try {
29374
- const m = readFileSync14(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
29451
+ const m = readFileSync15(f, "utf8").match(/<link\b[^>]*\brel=["'](?:shortcut )?icon["'][^>]*>/i);
29375
29452
  if (!m) continue;
29376
29453
  const href = m[0].match(/\shref=["']([^"']+)/i)?.[1] ?? "";
29377
- if (href.startsWith("data:") || /^https?:/.test(href) || existsSync19(join22(web, href.split("?")[0]))) return relative5(root, f).split(sep4).join("/");
29454
+ if (href.startsWith("data:") || /^https?:/.test(href) || existsSync20(join23(web, href.split("?")[0]))) return relative5(root, f).split(sep4).join("/");
29378
29455
  } catch {
29379
29456
  }
29380
29457
  }
29381
29458
  return null;
29382
29459
  }
29383
29460
  function scannedIcons(root) {
29384
- const base = join22(root, MIGRATION_DIR);
29385
- if (!existsSync19(base)) return [];
29461
+ const base = join23(root, MIGRATION_DIR);
29462
+ if (!existsSync20(base)) return [];
29386
29463
  const found = [];
29387
29464
  for (const host of readdirSync7(base)) {
29388
- const dir = join22(base, host, "icons");
29465
+ const dir = join23(base, host, "icons");
29389
29466
  try {
29390
- const list = readJson(join22(dir, "icons.json"));
29467
+ const list = readJson(join23(dir, "icons.json"));
29391
29468
  for (const i of list) {
29392
- const path = join22(dir, i.file);
29393
- if (!existsSync19(path)) continue;
29394
- const size = imageSize(readFileSync14(path));
29469
+ const path = join23(dir, i.file);
29470
+ if (!existsSync20(path)) continue;
29471
+ const size = imageSize(readFileSync15(path));
29395
29472
  found.push({ path, kind: i.kind, big: !size || size.width >= 64 });
29396
29473
  }
29397
29474
  } catch {
@@ -29403,7 +29480,7 @@ function findSource(root) {
29403
29480
  const icons = scannedIcons(root);
29404
29481
  const sharp = icons.find((i) => i.kind === "icon" && i.big);
29405
29482
  if (sharp) return { path: sharp.path, from: "old-icon" };
29406
- const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join22(root, d));
29483
+ const dirs = ["public", "static", "src/assets", "assets", "images", "img"].map((d) => join23(root, d));
29407
29484
  const logos = dirs.flatMap((d) => walk(d)).filter((p) => looksLikeLogo(relative5(root, p).split(sep4).join("/")));
29408
29485
  const logo = logos.find((p) => /\.svg$/i.test(p)) ?? logos[0];
29409
29486
  if (logo) return { path: logo, from: "logo" };
@@ -29417,23 +29494,23 @@ var CODE_EXT2 = /\.(css|scss|sass|less|html|astro|vue|svelte)$/i;
29417
29494
  var READ_CAP = 300;
29418
29495
  function readText2(path) {
29419
29496
  try {
29420
- return readFileSync14(path, "utf8");
29497
+ return readFileSync15(path, "utf8");
29421
29498
  } catch {
29422
29499
  return "";
29423
29500
  }
29424
29501
  }
29425
29502
  function scanDirs(root) {
29426
- const base = join22(root, MIGRATION_DIR);
29503
+ const base = join23(root, MIGRATION_DIR);
29427
29504
  try {
29428
- return readdirSync7(base).map((h) => join22(base, h)).filter((d) => existsSync19(join22(d, "home.html")));
29505
+ return readdirSync7(base).map((h) => join23(base, h)).filter((d) => existsSync20(join23(d, "home.html")));
29429
29506
  } catch {
29430
29507
  return [];
29431
29508
  }
29432
29509
  }
29433
29510
  function homePage(root) {
29434
- for (const d of scanDirs(root)) return readText2(join22(d, "home.html"));
29511
+ for (const d of scanDirs(root)) return readText2(join23(d, "home.html"));
29435
29512
  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"]) {
29436
- const text2 = readText2(join22(root, f));
29513
+ const text2 = readText2(join23(root, f));
29437
29514
  if (text2) return text2;
29438
29515
  }
29439
29516
  return "";
@@ -29444,30 +29521,30 @@ function siteFacts(root, given = {}) {
29444
29521
  const id = readSiteIdentity(home);
29445
29522
  let pkg;
29446
29523
  try {
29447
- pkg = readJson(join22(root, "package.json")).name;
29524
+ pkg = readJson(join23(root, "package.json")).name;
29448
29525
  } catch {
29449
29526
  }
29450
29527
  const name = given.name?.trim() || readProject(root)?.name || id.name || (pkg && !pkg.startsWith("@") ? pkg : "") || basename2(root);
29451
29528
  if (given.color) return { name, line: given.line ?? id.line ?? "", color: given.color, colorFrom: "given" };
29452
- const old = scanDirs(root).flatMap((d) => walkAll(join22(d, "styles")).map((f) => ({ text: readText2(f) })));
29529
+ const old = scanDirs(root).flatMap((d) => walkAll(join23(d, "styles")).map((f) => ({ text: readText2(f) })));
29453
29530
  const fromOld = scanDirs(root).length ? pickBrandColor([{ text: home, themeColor: id.themeColor }, ...old]) : null;
29454
29531
  const sources = [{ text: home, themeColor: id.themeColor }];
29455
- for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText2(join22(root, f)) });
29456
- const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(join22(root, d))).filter((p) => CODE_EXT2.test(p));
29457
- const plain2 = readdirSync7(root).filter((f) => CODE_EXT2.test(f)).map((f) => join22(root, f));
29532
+ for (const f of ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs", "tailwind.config.cjs"]) sources.push({ text: readText2(join23(root, f)) });
29533
+ const code = ["src", "app", "styles", "css", "public", "static"].flatMap((d) => walk(join23(root, d))).filter((p) => CODE_EXT2.test(p));
29534
+ const plain2 = readdirSync7(root).filter((f) => CODE_EXT2.test(f)).map((f) => join23(root, f));
29458
29535
  for (const f of [...plain2, ...code].slice(0, READ_CAP)) sources.push({ text: readText2(f) });
29459
29536
  const color = fromOld ?? pickBrandColor(sources);
29460
29537
  return { name, line: given.line ?? id.line ?? "", color: color ?? BRAND_DEFAULT_COLOR, colorFrom: color ? "site" : "default" };
29461
29538
  }
29462
29539
  function writeSiteFile(root, file2, data) {
29463
- const target = join22(webRoot(root), file2);
29464
- if (existsSync19(target)) {
29465
- const keep = join22(root, BRAND_DIR, "originals");
29540
+ const target = join23(webRoot(root), file2);
29541
+ if (existsSync20(target)) {
29542
+ const keep = join23(root, BRAND_DIR, "originals");
29466
29543
  mkdirSync13(keep, { recursive: true });
29467
- copyFileSync(target, join22(keep, file2));
29544
+ copyFileSync(target, join23(keep, file2));
29468
29545
  }
29469
29546
  mkdirSync13(dirname7(target), { recursive: true });
29470
- writeFileSync17(target, data);
29547
+ writeFileSync18(target, data);
29471
29548
  }
29472
29549
  var send = (res, status, body = "", type = "text/plain; charset=utf-8") => {
29473
29550
  res.writeHead(status, { "content-type": type, "cache-control": "no-store", "x-content-type-options": "nosniff" });
@@ -29502,7 +29579,7 @@ function allowed(req, url2, port, token) {
29502
29579
  return req.headers.host === `127.0.0.1:${port}` && url2.searchParams.get("t") === token;
29503
29580
  }
29504
29581
  async function headless(browser, url2, width, until, timeoutMs) {
29505
- const profile = mkdtempSync2(join22(tmpdir2(), "deployai-brand-"));
29582
+ const profile = mkdtempSync2(join23(tmpdir2(), "deployai-brand-"));
29506
29583
  const child = spawn5(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 });
29507
29584
  child.on("error", () => {
29508
29585
  });
@@ -29602,7 +29679,7 @@ async function drawInBrowser(o, browser) {
29602
29679
  }
29603
29680
  }
29604
29681
  function sourceBytes(path) {
29605
- return { bytes: readFileSync14(path), type: TYPES[extname2(path).toLowerCase()] ?? "application/octet-stream" };
29682
+ return { bytes: readFileSync15(path), type: TYPES[extname2(path).toLowerCase()] ?? "application/octet-stream" };
29606
29683
  }
29607
29684
  function report(root, r) {
29608
29685
  const where = relative5(root, webRoot(root)).split(sep4).join("/") || "the site root";
@@ -29620,7 +29697,7 @@ function plainIcon(root, source, name, color) {
29620
29697
  const ext = extname2(source.path).toLowerCase();
29621
29698
  if (ext === ".ico" || ext === ".svg" || ext === ".png") {
29622
29699
  const file2 = `favicon${ext}`;
29623
- writeSiteFile(root, file2, readFileSync14(source.path));
29700
+ writeSiteFile(root, file2, readFileSync15(source.path));
29624
29701
  return [file2];
29625
29702
  }
29626
29703
  }
@@ -29638,7 +29715,7 @@ function printStatus2(root, files) {
29638
29715
  const web = webRoot(root);
29639
29716
  const icon = existingFavicon(root);
29640
29717
  out(icon ? `Icon: ${icon}` : "Icon: missing. Run: npx deployai@latest brand favicon");
29641
- const missing = files.filter((f) => f !== "favicon.svg" && !existsSync19(join22(web, f)));
29718
+ const missing = files.filter((f) => f !== "favicon.svg" && !existsSync20(join23(web, f)));
29642
29719
  if (files.length) out(missing.length ? `Missing from the full set: ${missing.join(", ")}` : "The full set is there.");
29643
29720
  }
29644
29721
  function printFacts(f, picture2) {
@@ -29657,7 +29734,7 @@ function withLogoColor(facts, source) {
29657
29734
  }
29658
29735
  function pickSource(root, from) {
29659
29736
  const source = from ? { path: from, from: "file" } : findSource(root);
29660
- if (source.path && !existsSync19(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
29737
+ if (source.path && !existsSync20(source.path)) throw new CliError(`No such file: ${source.path}`, 1, "usage");
29661
29738
  return source;
29662
29739
  }
29663
29740
  async function brandFaviconCommand(root, opts) {
@@ -29685,7 +29762,7 @@ async function brandFaviconCommand(root, opts) {
29685
29762
  }
29686
29763
  function iconsToDraw(root, force) {
29687
29764
  const icon = force ? null : existingFavicon(root);
29688
- const keepOg = !force && existsSync19(join22(webRoot(root), "og-image.png"));
29765
+ const keepOg = !force && existsSync20(join23(webRoot(root), "og-image.png"));
29689
29766
  return {
29690
29767
  targets: BRAND_TARGETS.filter((t) => !(keepOg && t.file === "og-image.png") && !(icon && t.icoOnly)),
29691
29768
  keepIcon: Boolean(icon),
@@ -29741,7 +29818,7 @@ async function measurePage(browser, address, width, scripts) {
29741
29818
  }
29742
29819
  }
29743
29820
  function imageFiles(root) {
29744
- const dirs = [webRoot(root) === root ? null : webRoot(root), join22(root, "src"), join22(root, MIGRATION_DIR)].filter((d) => !!d);
29821
+ const dirs = [webRoot(root) === root ? null : webRoot(root), join23(root, "src"), join23(root, MIGRATION_DIR)].filter((d) => !!d);
29745
29822
  const files = dirs.flatMap((d) => walkAll(d));
29746
29823
  if (webRoot(root) === root) files.push(...walk(root));
29747
29824
  return [...new Set(files)].filter((p) => IMAGE_EXT.test(p) && !p.split(sep4).includes("icons") && !BRAND_FILES.includes(basename2(p)));
@@ -29757,7 +29834,7 @@ function walkAll(dir) {
29757
29834
  }
29758
29835
  for (const n2 of names) {
29759
29836
  if (found.length >= WALK_CAP) return;
29760
- const p = join22(d, n2);
29837
+ const p = join23(d, n2);
29761
29838
  try {
29762
29839
  if (statSync4(p).isDirectory()) {
29763
29840
  if (!SKIP_DIRS3.has(n2) || n2 === ".deployai") go(p);
@@ -29776,7 +29853,7 @@ function judgeFiles(root) {
29776
29853
  for (const f of files) {
29777
29854
  let bytes;
29778
29855
  try {
29779
- bytes = readFileSync14(f);
29856
+ bytes = readFileSync15(f);
29780
29857
  } catch {
29781
29858
  continue;
29782
29859
  }
@@ -29826,10 +29903,10 @@ async function brandImagesCommand(root, urls, opts) {
29826
29903
  if (verdict !== "ok") onPages.push({ where: m.src, width: m.width, height: m.height, shownWidth: m.shownWidth, verdict, alt: m.alt });
29827
29904
  }
29828
29905
  const weak = [...onPages, ...findings];
29829
- mkdirSync13(join22(root, BRAND_DIR), { recursive: true });
29906
+ mkdirSync13(join23(root, BRAND_DIR), { recursive: true });
29830
29907
  const file2 = `${BRAND_DIR}/images.json`;
29831
29908
  const data = { measuredAt: (/* @__PURE__ */ new Date()).toISOString(), pages: urls, unmeasured, filesChecked: total, imagesMeasured: shown.size, weak };
29832
- writeFileSync17(join22(root, file2), `${JSON.stringify(data, null, 2)}
29909
+ writeFileSync18(join23(root, file2), `${JSON.stringify(data, null, 2)}
29833
29910
  `);
29834
29911
  if (opts.json) {
29835
29912
  out(JSON.stringify(data));
@@ -29894,7 +29971,12 @@ function buildProgram() {
29894
29971
  const g = (cmd) => cmd.optsWithGlobals();
29895
29972
  const root = (cmd) => resolve8(g(cmd).dir ?? process.cwd());
29896
29973
  const ctx = (cmd) => apiContext(g(cmd).api);
29974
+ program.hook("preAction", async (_p, action) => {
29975
+ if (["init", "start", "rules"].includes(action.name()) || !existsSync21(join24(root(action), "DEPLOYAI.md"))) return;
29976
+ await refreshRules(root(action), ctx(action).apiUrl);
29977
+ });
29897
29978
  program.command("init").description("create DEPLOYAI.md and .deployai/ guard files").option("--force", "overwrite DEPLOYAI.md").option("--no-agent-files", "do not add the DEPLOYAI.md line to AGENTS.md and CLAUDE.md").action((opts, cmd) => initCommand(root(cmd), opts, ctx(cmd).apiUrl));
29979
+ program.command("rules").description("the current DeployAI rules for the agent, and DEPLOYAI.md brought up to them").action((_o, cmd) => rulesCommand(root(cmd), ctx(cmd).apiUrl));
29898
29980
  program.command("inspect").description("show framework, package manager, language, database, storage").option("--json", "machine readable output").action((opts, cmd) => inspectCommand(root(cmd), opts));
29899
29981
  program.command("check").description("can this project run on DeployAI: blockers and warnings, with the AI prompt").option("--json", "machine readable output").option("--no-clipboard", "do not copy the prompt to the clipboard").action(async (opts, cmd) => {
29900
29982
  const a = await runCheck(root(cmd), ctx(cmd), opts);
@@ -30046,8 +30128,8 @@ async function main(argv = process.argv) {
30046
30128
 
30047
30129
  // src/update.ts
30048
30130
  import { spawnSync as spawnSync5 } from "child_process";
30049
- import { existsSync as existsSync20, mkdirSync as mkdirSync14, readdirSync as readdirSync8, readFileSync as readFileSync15, rmSync as rmSync5, writeFileSync as writeFileSync18 } from "fs";
30050
- import { join as join23 } from "path";
30131
+ import { existsSync as existsSync22, mkdirSync as mkdirSync14, readdirSync as readdirSync8, readFileSync as readFileSync16, rmSync as rmSync5, writeFileSync as writeFileSync19 } from "fs";
30132
+ import { join as join25 } from "path";
30051
30133
  var CHECK_EVERY_MS = 60 * 60 * 1e3;
30052
30134
  var ASK_NPM_MS = 1500;
30053
30135
  var GET_VERSION_MS = 12e4;
@@ -30085,11 +30167,11 @@ function updateAllowed(env, args) {
30085
30167
  return resolveApiUrl(void 0, loadConfig()) === API_BASE_DEFAULT.replace(/\/+$/, "");
30086
30168
  }
30087
30169
  function statePath() {
30088
- return join23(configDir(), "update-check.json");
30170
+ return join25(configDir(), "update-check.json");
30089
30171
  }
30090
30172
  function readState() {
30091
30173
  try {
30092
- const data = JSON.parse(readFileSync15(statePath(), "utf8"));
30174
+ const data = JSON.parse(readFileSync16(statePath(), "utf8"));
30093
30175
  return data && typeof data === "object" ? data : {};
30094
30176
  } catch {
30095
30177
  return {};
@@ -30098,7 +30180,7 @@ function readState() {
30098
30180
  function writeState(state) {
30099
30181
  try {
30100
30182
  mkdirSync14(configDir(), { recursive: true });
30101
- writeFileSync18(statePath(), JSON.stringify(state) + "\n");
30183
+ writeFileSync19(statePath(), JSON.stringify(state) + "\n");
30102
30184
  } catch {
30103
30185
  }
30104
30186
  }
@@ -30114,20 +30196,20 @@ async function askNpmLatest(env) {
30114
30196
  }
30115
30197
  }
30116
30198
  function versionEntry(version2) {
30117
- return join23(configDir(), "cli", version2, "node_modules", "deployai", "dist", "index.js");
30199
+ return join25(configDir(), "cli", version2, "node_modules", "deployai", "dist", "index.js");
30118
30200
  }
30119
30201
  function getVersion(version2, env) {
30120
30202
  process.stderr.write(`Getting the newest DeployAI CLI, version ${version2}.
30121
30203
  `);
30122
- const root = join23(configDir(), "cli");
30123
- const dir = join23(root, version2);
30204
+ const root = join25(configDir(), "cli");
30205
+ const dir = join25(root, version2);
30124
30206
  mkdirSync14(dir, { recursive: true });
30125
- writeFileSync18(join23(dir, "package.json"), '{"private":true}\n');
30207
+ writeFileSync19(join25(dir, "package.json"), '{"private":true}\n');
30126
30208
  const installed = spawnSync5(`npm install deployai@${version2} --ignore-scripts --no-audit --no-fund --silent`, { cwd: dir, env, shell: true, stdio: "ignore", windowsHide: true, timeout: GET_VERSION_MS });
30127
30209
  if (installed.status !== 0) return false;
30128
30210
  const ran = spawnSync5(process.execPath, [versionEntry(version2), "--version"], { env: { ...env, DEPLOYAI_NO_UPDATE: "1" }, encoding: "utf8", timeout: GET_VERSION_MS });
30129
30211
  if (ran.status !== 0 || ran.stdout.trim() !== version2) return false;
30130
- for (const old of readdirSync8(root)) if (old !== version2) rmSync5(join23(root, old), { recursive: true, force: true });
30212
+ for (const old of readdirSync8(root)) if (old !== version2) rmSync5(join25(root, old), { recursive: true, force: true });
30131
30213
  return true;
30132
30214
  }
30133
30215
  function runVersion(version2, args, env = process.env) {
@@ -30146,7 +30228,7 @@ async function versionToRun(current, args, env = process.env, deps = {}) {
30146
30228
  }
30147
30229
  const latest = state.latest;
30148
30230
  if (!latest || !PLAIN_VERSION.test(latest) || compareVersions(latest, current) <= 0) return null;
30149
- if (state.ready === latest && existsSync20(versionEntry(latest))) return latest;
30231
+ if (state.ready === latest && existsSync22(versionEntry(latest))) return latest;
30150
30232
  if (now - (state.triedAt ?? 0) < CHECK_EVERY_MS) return null;
30151
30233
  state.triedAt = now;
30152
30234
  if (get2(latest, env)) state.ready = latest;