serpkin 0.2.25 → 0.2.26

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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ Requires Node 22 or newer. No dependencies. Builder and Pro start with a 7-day f
39
39
  - **Cursor**: merges into `.cursor/mcp.json` and writes the project rule `.cursor/rules/serpkin.mdc` with the SEO loop.
40
40
  - **Codex**: appends `[mcp_servers.serpkin]` to `~/.codex/config.toml` once and adds a short "Serpkin SEO" section to the project's `AGENTS.md` (it asks first, and creates the file if it's missing).
41
41
 
42
- All three configs run a small local MCP bridge, `npx -y serpkin@0.2.25 mcp`, which reads the key saved at sign-in and forwards requests to `https://serpkin.com/api/mcp` (a self-hosted server adds `--server <origin>` to the args). The configs hold no key and no environment variable, so there is nothing to export.
42
+ All three configs run a small local MCP bridge, `npx -y serpkin@0.2.26 mcp`, which reads the key saved at sign-in and forwards requests to `https://serpkin.com/api/mcp` (a self-hosted server adds `--server <origin>` to the args). The configs hold no key and no environment variable, so there is nothing to export.
43
43
 
44
44
  The rule and the `AGENTS.md` section sit between `<!-- serpkin:start -->` and `<!-- serpkin:end -->`. Re-running init refreshes only that block and keeps everything else.
45
45
  4. **Registers the site**, which queues its initial audit on the server, and uploads a route map (URL path → source file), so missions can name the files to change.
@@ -77,7 +77,7 @@ Inside a session you can run `/plugin marketplace add apwn/serpkin`, then `/plug
77
77
 
78
78
  - the **`serpkin-seo` skill**, which runs the loop: next mission → implement → run checks → check the preview → submit → verify the preview → verify production after you deploy. It treats page text and search data as untrusted and never deploys.
79
79
  - **commands**: `/serpkin:next` gets the next mission and implements it. `/serpkin:ship <preview-url>` submits it, checks the preview and verifies. `/serpkin:check <preview-url>` runs `serpkin check` (the pinned CLI version from the public npm registry). `/serpkin:status` shows the site status. `/serpkin:manager` sets up a weekly SEO manager for one site, or `/serpkin:manager all` for one check-in across every site, and runs the first check-in.
80
- - the **Serpkin MCP server**, run as the same stdio bridge (`npx -y serpkin@0.2.25 mcp`). It uses the key saved at sign-in, so there is nothing to export. `SERPKIN_API_KEY` is an optional override, and `SERPKIN_SERVER` picks a self-hosted or local server (default `https://serpkin.com`).
80
+ - the **Serpkin MCP server**, run as the same stdio bridge (`npx -y serpkin@0.2.26 mcp`). It uses the key saved at sign-in, so there is nothing to export. `SERPKIN_API_KEY` is an optional override, and `SERPKIN_SERVER` picks a self-hosted or local server (default `https://serpkin.com`).
81
81
 
82
82
  - **hooks** (quiet by design, only in repositories with `.serpkin.json`):
83
83
  - **Session start**: one line with the next mission and "run /serpkin:next". It is fetched with a 2.5-second timeout and cached for an hour per site (failures for 30 minutes); submitting, verifying, starting, dismissing or creating a mission through the Serpkin tools clears the cache, so the line never names a mission you just shipped. It says nothing when you are offline, signed out or the project isn't linked.
@@ -93,7 +93,7 @@ Clients without plugins get the same loop as MCP prompts: `next_mission`, `ship_
93
93
 
94
94
  ### Where the key goes
95
95
 
96
- The key is **never written into your repository.** It is stored in `~/.config/serpkin/credentials.json` (mode 600, keyed by server). Agent configs run `npx -y serpkin@0.2.25 mcp`, which reads it from there, so they hold no key and no environment variable, and you don't need to export anything.
96
+ The key is **never written into your repository.** It is stored in `~/.config/serpkin/credentials.json` (mode 600, keyed by server). Agent configs run `npx -y serpkin@0.2.26 mcp`, which reads it from there, so they hold no key and no environment variable, and you don't need to export anything.
97
97
 
98
98
  `SERPKIN_API_KEY` still works and takes precedence over the saved key: use it in CI and GitHub Actions, or if you prefer it. Configs written by older versions (`${SERPKIN_API_KEY}` / `${env:SERPKIN_API_KEY}` / `bearer_token_env_var`) keep working while the variable is set. Re-running `npx serpkin` switches `.mcp.json` and `.cursor/mcp.json` to the bridge; an existing Codex table that reads the variable is left alone and the CLI prints the new block to replace it. A Codex bridge entry pinned to an older CLI version gets just that version updated.
99
99
 
@@ -124,13 +124,13 @@ npm run build && npm start # or your framework's production server
124
124
  npx serpkin check http://localhost:3000
125
125
  ```
126
126
 
127
- Serpkin's server never fetches `localhost`. The CLI reads the local pages on your machine (the homepage and known pages Serpkin plans, plus `robots.txt` and the sitemap), drops inline scripts and styles, and uploads them; Serpkin fetches production itself and runs the same comparison as a preview check. `localhost`, `127.0.0.1`, `[::1]` and `*.local` addresses work. This is a **pre-deploy check, not production verification**: after the deploy, check the production URL and verify the mission with environment `production`. Missions for sites known to deploy straight to production list it first in `implementation.verify` (`when: "before_deploy"`).
127
+ Serpkin's server never fetches `localhost`. The CLI reads the local pages on your machine (the homepage and up to 10 pages Serpkin plans, plus `robots.txt` and the sitemap) and lists the paths it reads. The pages of missions in progress or waiting to ship come first (their target pages and the new pages they create), marked `(mission page)`, then known pages; `--paths /a,/b` picks them yourself. It drops inline scripts and styles, and uploads them; Serpkin fetches production itself and runs the same comparison as a preview check. `localhost`, `127.0.0.1`, `[::1]` and `*.local` addresses work. This is a **pre-deploy check, not production verification**: after the deploy, check the production URL and verify the mission with environment `production`. Missions for sites known to deploy straight to production list it first in `implementation.verify` (`when: "before_deploy"`).
128
128
 
129
129
  ### Monorepos
130
130
 
131
131
  `npx serpkin` and `npx serpkin routes` find the website app at the root, in workspace folders (`package.json` workspaces, `pnpm-workspace.yaml`), in `apps/*`, `packages/*`, `sites/*`, and in any top-level folder with its own `package.json` (`web/`, `frontend/`). A folder counts when it depends on Next.js, Astro, SvelteKit, Nuxt or Remix, or has that framework's config file. With several apps the CLI asks; without a terminal it takes the one in a website-named folder (`web`, `www`, `site`, …) when that is clear and says so, else it stops and asks for `--app <dir>`. The choice is saved in `.serpkin.json` as `app`. Route-map paths are repository-relative (`web/src/app/page.tsx`), even from a subfolder.
132
132
 
133
- Without a route map, missions don't know your files: `serpkin_next_mission` warns "Routes not uploaded" and steps leave `file` empty, naming usual locations to confirm. Run `npx serpkin routes --upload` (with `--app <dir>` in a monorepo). In a repository without `.serpkin.json`, it finds the registered site (the only one, or the one matching the app's `homepage`) and writes `.serpkin.json`; pass `--site <id>` otherwise.
133
+ Without a route map, missions don't know your files: `serpkin_next_mission` warns "Routes not uploaded" and steps leave `file` empty, naming usual locations to confirm. Run `npx serpkin routes --upload` (with `--app <dir>` in a monorepo). `npx serpkin` uploads it during setup; `npx serpkin status` and `serpkin_get_site_context` (`route_map`) say when it is missing, with the command, and in a terminal `status` offers to upload it. In a repository without `.serpkin.json`, `routes --upload`, `status` and `check` find the registered site the repository names (the `homepage` in `package.json`, `NEXT_PUBLIC_SITE_URL` or a similar `*_SITE_URL`/`*_BASE_URL` in `.env*` files, `metadataBase`, next-sitemap `siteUrl`, astro `site`, a `CNAME` file, or the git remote's name), else the account's only site, and say which. `routes --upload` writes `.serpkin.json`; `status` writes it when the repository named the site (asks in a terminal; `--yes` also links the only site). Several sites and no match: `status` lists them with their ids; pass `--site <id>`. Env files are read only to compare hosts on your machine; nothing from them is sent.
134
134
 
135
135
  ## Audit status and recovery
136
136
 
@@ -145,9 +145,9 @@ Without a route map, missions don't know your files: `serpkin_next_mission` warn
145
145
  | Command | |
146
146
  | ----------------------------- | ---------------------------------------------------------------------------------- |
147
147
  | `serpkin` / `serpkin init` | Setup (above). Safe to re-run; the stored key and site are reused. |
148
- | `serpkin check <preview-url>` | Compare a preview deploy with production. Exit code 1 on regressions, 2 on errors. Without `.serpkin.json` it uses `--site <id>` or the site whose origin matches the URL. `http://localhost:PORT` checks a local build before deploying (read on your machine). `--allow-host` allows your own preview host for the site. |
148
+ | `serpkin check <preview-url>` | Compare a preview deploy with production. Exit code 1 on regressions, 2 on errors. Without `.serpkin.json` it uses `--site <id>`, the site whose origin matches the URL, or the site the repository names. `http://localhost:PORT` checks a local build before deploying (read on your machine). `--allow-host` allows your own preview host for the site. |
149
149
  | `serpkin verify` | Check ownership (verification file or DNS record). |
150
- | `serpkin status` | Site, ownership, data level, next mission and credits. |
150
+ | `serpkin status` | Site, ownership, route map, data level, next mission and credits. Without `.serpkin.json` it finds the site (see Monorepos) and offers to link the repository. |
151
151
  | `serpkin routes [--upload]` | Print the route map; `--upload` sends it (and writes `.serpkin.json` when it's missing). Monorepos: finds or asks for the app; `--app <dir>`. |
152
152
  | `serpkin next [--oneline]` | The next mission in one line (fast, cached; `--oneline` is silent when offline). |
153
153
  | `serpkin weekly [--force]` | Write the weekly mission workflow and the preview check to `.github/workflows/`. |
package/bin/serpkin.mjs CHANGED
@@ -19,7 +19,7 @@ ${c.bold("Usage")}
19
19
  npx serpkin check http://localhost:3000
20
20
  No preview? Check a local build before deploying (read here, compared with production)
21
21
  npx serpkin verify Check site ownership (verification file or DNS)
22
- npx serpkin status Site, ownership, next mission and plan
22
+ npx serpkin status Site, ownership, route map, next mission and plan (finds the site without .serpkin.json)
23
23
  npx serpkin next [--oneline] The next mission in one line (fast, cached; silent when offline)
24
24
  npx serpkin routes Print the route map (--upload to send it)
25
25
  npx serpkin weekly Add GitHub Actions: a weekly mission pull request and the preview check
package/lib/commands.mjs CHANGED
@@ -31,6 +31,8 @@ import {
31
31
  routeMapFramework,
32
32
  likelyWebsite,
33
33
  gitRoot,
34
+ repoSiteHints,
35
+ matchSiteByHints,
34
36
  } from "./detect.mjs";
35
37
  import {
36
38
  AGENTS, hermesBlock, hermesConfigPath, appendHermesConfig,
@@ -51,9 +53,11 @@ import {
51
53
  import { writeCursorRule, writeAgentsSection } from "./rules.mjs";
52
54
  import { DEFAULT_SERVER } from "./config.mjs";
53
55
  import { clean as cleanLine } from "../plugin/serpkin/scripts/next-line.mjs";
54
- import { localCheck, isLocalHost } from "./local-check.mjs";
56
+ import { localCheck, isLocalHost, readList } from "./local-check.mjs";
55
57
 
56
58
  const LANES = ["code", "content", "outreach", "research"];
59
+ /** Uploads the route map (lib/agent/repo-files.ts routesCommand is the server's wording of the same command). */
60
+ const ROUTES_UPLOAD = "npx serpkin routes --upload";
57
61
  /**
58
62
  * --lanes code,content → ["code", "content"]; absent, empty or every lane → null (all lanes, the default).
59
63
  * An unknown lane is an error, so a typo never silently gives the key every lane.
@@ -296,10 +300,12 @@ export async function init(flags, ctx = context()) {
296
300
  `${FRAMEWORK_NAMES[app.framework]}${app.router ? ` (${app.router.replace("+", " + ")} router)` : ""}` +
297
301
  `${app.root !== "." ? ` in ${app.root}` : ""}: ${routeMap.routes.length} routes${dyn ? `, ${dyn} dynamic` : ""}`,
298
302
  );
299
- } else if (!flags["connect-only"])
303
+ } else if (!flags["connect-only"]) {
300
304
  out.warn(
301
- "No supported framework found here. Missions still work by URL; the route map is skipped.",
305
+ "No supported framework found here. Missions still work by URL, but without a route map they can't name this repository's files.",
302
306
  );
307
+ out.note(`If the website is in a subfolder, run \`${ROUTES_UPLOAD} --app <dir>\` after setup.`);
308
+ }
303
309
 
304
310
  // 3. Coding agents.
305
311
  const { usedEnv, plugin, connected } = await setupAgents(flags, ctx, {
@@ -316,6 +322,8 @@ export async function init(flags, ctx = context()) {
316
322
  : "Serpkin sign-in is saved. No site was registered and no .serpkin.json was written. Restart your agent, then ask it to call serpkin_get_workspace to confirm the connection.",
317
323
  );
318
324
  out.note("For read-only or budgeted access, create a scoped key under Agents in the web app instead of using the default full-access CLI key.");
325
+ // Registered later through the agent, a site has no route map, and its first missions can't name files.
326
+ out.note(`Once the site is registered, run \`${ROUTES_UPLOAD}\` in its repository (free; routes are read on this machine), so missions name exact files from the first one.`);
319
327
  return { server, site: null, routeMap: null, app: null };
320
328
  }
321
329
 
@@ -431,14 +439,21 @@ export async function init(flags, ctx = context()) {
431
439
  // 5. Route map upload.
432
440
  if (site && routeMap?.routes.length) {
433
441
  const { truncated, ...body } = routeMap;
434
- await api.post("/api/cli/sites/route-map", {
435
- site_id: site.site_id,
436
- ...body,
437
- });
438
- out.ok(
439
- `Route map uploaded${truncated ? " (first 2,000 routes)" : ""}. Missions can now name the files to change.`,
440
- );
441
- }
442
+ // A failed upload doesn't undo setup: say what missions lose and the command that retries it.
443
+ try {
444
+ await api.post("/api/cli/sites/route-map", {
445
+ site_id: site.site_id,
446
+ ...body,
447
+ });
448
+ out.ok(
449
+ `Route map uploaded${truncated ? " (first 2,000 routes)" : ""}. Missions can now name the files to change.`,
450
+ );
451
+ } catch (e) {
452
+ out.warn(`Route map not uploaded (${cleanLine(e?.message, 200)}), so missions can't name this repository's files yet.`);
453
+ out.note(`Run \`${ROUTES_UPLOAD}${app.root !== "." ? ` --app ${app.root}` : ""}\` to retry.`);
454
+ }
455
+ } else if (site && app)
456
+ out.warn(`No routes found in ${app.root === "." ? "this app" : app.root}, so missions can't name its files. If the website is another folder, run \`${ROUTES_UPLOAD} --app <dir>\`.`);
442
457
 
443
458
  // No plan (trial mode): missions, full scans, verification and credits come with the trial, so the ending
444
459
  // shows the preview and the one offer instead of credit notes and "missions work now".
@@ -922,7 +937,7 @@ export async function check(previewUrl, flags, ctx = context()) {
922
937
  );
923
938
  const { project, api } = await session(flags, ctx);
924
939
  const local = isLocal(url);
925
- const siteId = flags.site || ctx.env.SERPKIN_SITE_ID || project?.site_id || (await siteForUrl(api, url, { local }));
940
+ const siteId = flags.site || ctx.env.SERPKIN_SITE_ID || project?.site_id || (await siteForUrl(api, url, { local, ctx, flags }));
926
941
  const paths = flags.paths
927
942
  ? flags.paths
928
943
  .split(",")
@@ -943,7 +958,12 @@ export async function check(previewUrl, flags, ctx = context()) {
943
958
  url,
944
959
  paths,
945
960
  fetchImpl: ctx.localFetch ?? ctx.fetchImpl,
946
- onRead: (n) => !flags.json && out.note(`Reading ${n} page${n === 1 ? "" : "s"} plus robots.txt and the sitemap locally.`),
961
+ onRead: (n, plan) => {
962
+ if (flags.json) return;
963
+ const m = plan.mission_paths.length;
964
+ out.note(`Reading ${n} page${n === 1 ? "" : "s"} plus robots.txt and the sitemap locally${m ? ` (${m} from missions in progress or waiting to ship, read first)` : ""}:`);
965
+ for (const l of readList(plan.paths, plan.mission_paths)) out.line(c.dim(l));
966
+ },
947
967
  });
948
968
  } else {
949
969
  if (!flags.json) out.step(`Checking ${url} against production…`);
@@ -962,30 +982,45 @@ export async function check(previewUrl, flags, ctx = context()) {
962
982
  }
963
983
  /**
964
984
  * Without --site or ${PROJECT_FILE}: the registered site whose origin is the checked URL (checking production
965
- * itself is fine), else the workspace's only site. Several sites and no match: name them.
985
+ * itself is fine), else the one this repository's files name (a local build has no registered origin), else the
986
+ * workspace's only site. Several sites and no match: name them.
966
987
  */
967
- async function siteForUrl(api, url, { local = false } = {}) {
968
- const { items = [] } = await api.get("/api/records?kind=site&limit=100");
988
+ async function siteForUrl(api, url, { local = false, ctx, flags = {} } = {}) {
969
989
  const origin = new URL(url).origin;
970
- // A local build has no registered origin to match: only a workspace with one site is unambiguous.
971
- if (local) {
972
- if (items.length === 1) return items[0].id;
973
- throw new CliError(
974
- items.length
975
- ? `Which site is this local build? Pass --site <id>: ${items.slice(0, 5).map((s) => `${s.origin} (${s.id})`).join(", ")}. Or run \`npx serpkin init\` here to write ${PROJECT_FILE}.`
976
- : "No site registered yet. Run `npx serpkin init` in this repository first.",
977
- );
990
+ const r = await findRepoSite(api, ctx, null, { origin: local ? null : origin });
991
+ if (r.site) {
992
+ if (!flags.json && r.how) out.note(`Checking against ${r.site.origin}: ${r.how}. Pass --site <id> to choose another.`);
993
+ return r.site.id;
978
994
  }
979
- const bare = (o) => String(o ?? "").replace(/^https?:\/\/(www\.)?/i, "");
980
- const match = items.find((s) => s.origin === origin) ?? items.find((s) => bare(s.origin) === bare(origin));
981
- if (match) return match.id;
982
- if (items.length === 1) return items[0].id;
983
995
  throw new CliError(
984
- items.length
985
- ? `Which site is this? Pass --site <id>: ${items.slice(0, 5).map((s) => `${s.origin} (${s.id})`).join(", ")}. Or run \`npx serpkin init\` here to write ${PROJECT_FILE}.`
996
+ r.items.length
997
+ ? `Which site is this${local ? " local build" : ""}? Pass --site <id>: ${siteList(r.items)}. Or run \`npx serpkin init\` here to write ${PROJECT_FILE}.`
986
998
  : "No site registered yet. Run `npx serpkin init` in this repository first.",
987
999
  );
988
1000
  }
1001
+ const siteList = (items) => items.slice(0, 5).map((s) => `${s.origin} (${s.id})`).join(", ");
1002
+ /**
1003
+ * Which registered site this repository is, without --site or ${PROJECT_FILE}: the site at `origin` (a checked
1004
+ * URL), else the one the repository's own files name (package.json homepage, NEXT_PUBLIC_SITE_URL and similar in
1005
+ * env files, metadataBase, next-sitemap siteUrl, a CNAME file, the git remote's name), else the account's only site.
1006
+ * Env files are read here only to compare hosts; nothing from them is sent. `how` says why, for the user.
1007
+ * @returns {Promise<{ items: any[], site: any | null, how?: string | null, fromRepo?: boolean }>}
1008
+ */
1009
+ export async function findRepoSite(api, ctx, apps = null, { origin = null } = {}) {
1010
+ const { items = [] } = await api.get("/api/records?kind=site&limit=100");
1011
+ if (!items.length) return { items, site: null };
1012
+ if (origin) {
1013
+ const bare = (o) => String(o ?? "").replace(/^https?:\/\/(www\.)?/i, "");
1014
+ const exact = items.find((s) => s.origin === origin) ?? items.find((s) => bare(s.origin) === bare(origin));
1015
+ // The URL is the site itself: nothing to explain.
1016
+ if (exact) return { items, site: exact, how: null, fromRepo: false };
1017
+ }
1018
+ const base = await repoBase(ctx.cwd);
1019
+ const found = matchSiteByHints(items, await repoSiteHints(base, apps ?? (await detectApps(ctx.cwd))));
1020
+ if (found) return { items, site: found.site, how: `it matches ${found.source}`, fromRepo: true };
1021
+ if (items.length === 1) return { items, site: items[0], how: "it is the only site in your account", fromRepo: false };
1022
+ return { items, site: null };
1023
+ }
989
1024
  /** The preview URL to check (`https://` added to a bare host), or null when it isn't an http(s) address. */
990
1025
  export function previewAddress(input) {
991
1026
  const s = String(input ?? "").trim();
@@ -1084,9 +1119,27 @@ export async function verify(flags, ctx = context()) {
1084
1119
 
1085
1120
  export async function status(flags, ctx = context()) {
1086
1121
  const { project, api, server } = await session(flags, ctx);
1087
- const siteId = siteIdFrom(flags, project, ctx.env);
1122
+ let siteId = flags.site || ctx.env.SERPKIN_SITE_ID || project?.site_id;
1123
+ // No .serpkin.json: the site is usually registered already (web app, MCP). Find it instead of failing.
1124
+ let picked = null;
1125
+ if (!siteId) {
1126
+ picked = await findRepoSite(api, ctx);
1127
+ if (!picked.site) {
1128
+ if (!picked.items.length)
1129
+ throw new CliError("No site registered yet. Run `npx serpkin init` in this repository first.");
1130
+ if (flags.json)
1131
+ throw new CliError(`Which site is this repository? Pass --site <id>: ${siteList(picked.items)}.`);
1132
+ out.warn(`No ${PROJECT_FILE} here, and nothing in this repository names one of your ${picked.items.length} sites.`);
1133
+ out.line(table(picked.items.slice(0, 20).map((x) => [x.origin, x.id]), ["Site", "Id"]));
1134
+ out.note(`Run \`npx serpkin status --site <id>\`, for example \`npx serpkin status --site ${picked.items[0].id}\`.`);
1135
+ return 1;
1136
+ }
1137
+ siteId = picked.site.id;
1138
+ if (!flags.json) out.note(`No ${PROJECT_FILE} here. Using ${picked.site.origin}: ${picked.how}.`);
1139
+ }
1088
1140
  const s = (await api.tool("serpkin_get_site_context", { site_id: siteId }))
1089
1141
  .result;
1142
+ const routeMap = await routeMapStatus(api, s, ctx);
1090
1143
  // serpkin_next_mission is the V3 primary tool; older servers only have serpkin_get_missions.
1091
1144
  let next = null;
1092
1145
  try {
@@ -1132,6 +1185,13 @@ export async function status(flags, ctx = context()) {
1132
1185
  "Framework",
1133
1186
  s.framework ? (FRAMEWORK_NAMES[s.framework] ?? s.framework) : "—",
1134
1187
  ],
1188
+ ...(routeMap
1189
+ ? [["Routes", !routeMap.uploaded
1190
+ ? c.yellow("not uploaded: missions can't name this repository's files")
1191
+ : routeMap.note
1192
+ ? c.yellow(`${routeMap.routes} uploaded, out of date`)
1193
+ : `${routeMap.routes} uploaded`]]
1194
+ : []),
1135
1195
  ...(level
1136
1196
  ? [["Level", LEVELS[level] ?? String(level).replaceAll("_", " ")]]
1137
1197
  : []),
@@ -1185,6 +1245,8 @@ export async function status(flags, ctx = context()) {
1185
1245
  ...(offer ? { preview_mission: next?.preview_mission ?? null, preview_clean: next?.preview_clean ?? null, trial_offer: next?.trial_offer ?? offer } : {}),
1186
1246
  credits,
1187
1247
  plan: state?.project?.plan ?? null,
1248
+ route_map: routeMap,
1249
+ ...(picked ? { site_source: { site_id: siteId, origin: picked.site.origin, how: picked.how } } : {}),
1188
1250
  },
1189
1251
  null,
1190
1252
  2,
@@ -1193,25 +1255,73 @@ export async function status(flags, ctx = context()) {
1193
1255
  return 0;
1194
1256
  }
1195
1257
  for (const [k, v] of rows) out.line(`${c.dim(k.padEnd(13))}${v}`);
1258
+ if (routeMap?.command) await offerRouteUpload(flags, ctx, { api, project, site: s, routeMap });
1259
+ if (picked) await offerLink(flags, ctx, { server, site: picked.site, fromRepo: picked.fromRepo });
1196
1260
  return 0;
1197
1261
  }
1198
1262
 
1263
+ /**
1264
+ * The route map as status shows it: the server's site context says (route_map); older servers don't, so ask the
1265
+ * route-map endpoint, and only when this folder has an app to map (a hosted CMS has none). Null when unknown.
1266
+ */
1267
+ async function routeMapStatus(api, s, ctx) {
1268
+ if (s?.route_map) return s.route_map;
1269
+ if (!(await detectApps(ctx.cwd)).length) return null;
1270
+ const map = await api.get(`/api/cli/sites/route-map?site_id=${encodeURIComponent(s.site_id)}&optional=1`).catch(() => undefined);
1271
+ if (map === undefined) return null;
1272
+ const command = map ? null : `npx serpkin routes --upload --site ${s.site_id}`;
1273
+ return { uploaded: !!map, routes: map?.routes?.length ?? 0, note: command ? `Routes not uploaded. Run \`${command}\`.` : null, command };
1274
+ }
1275
+
1276
+ /**
1277
+ * Missing or stale route map: say so with the command, and in a terminal offer to upload it now (free; the routes
1278
+ * are read on this machine). Without a terminal, only the command: status doesn't change the server unasked.
1279
+ */
1280
+ async function offerRouteUpload(flags, ctx, { api, project, site, routeMap }) {
1281
+ out.line();
1282
+ const apps = await detectApps(ctx.cwd);
1283
+ const monorepo = apps.length > 1;
1284
+ const cmd = `${routeMap.command}${monorepo && !project?.app ? " --app <dir>" : ""}`;
1285
+ out.warn(routeMap.uploaded
1286
+ ? "The route map is out of date: some pages match no uploaded route, so their mission steps can't name files."
1287
+ : "No route map uploaded, so mission steps can't name this repository's files (they say \"usually app/…\" instead).");
1288
+ if (apps.length && interactive(flags) && (await confirm("Upload the route map now? It's free; the routes are read on this machine.", { opts: flags }))) {
1289
+ const app = await pickApp(apps, flags, project, { siteOrigin: site.origin });
1290
+ const map = await buildRouteMap(app, await repoBase(ctx.cwd));
1291
+ const { truncated, ...body } = map;
1292
+ await api.post("/api/cli/sites/route-map", { site_id: site.site_id, ...body });
1293
+ out.ok(`Route map uploaded (${map.routes.length} routes${truncated ? ", the first 2,000" : ""}). Missions now name this repository's files.`);
1294
+ return;
1295
+ }
1296
+ out.note(`Run \`${cmd}\` at the repository root (free; read on this machine), then fetch the mission again for exact file paths.`);
1297
+ }
1298
+
1299
+ /**
1300
+ * status found the site without .serpkin.json: offer to write it (no secrets) so the next command needs no lookup.
1301
+ * Without a terminal it's written when the repository itself named the site (or with --yes), not for a guess.
1302
+ */
1303
+ async function offerLink(flags, ctx, { server, site, fromRepo }) {
1304
+ const link = interactive(flags)
1305
+ ? await confirm(`Link this repository to ${site.origin}? It writes ${PROJECT_FILE} (no secrets), so commands need no --site.`, { opts: flags })
1306
+ : fromRepo || !!flags.yes;
1307
+ if (link) {
1308
+ await saveProject(ctx.cwd, { server, site_id: site.id, origin: site.origin });
1309
+ out.ok(`Linked this repository to ${site.origin} (${PROJECT_FILE} saved; commit it).`);
1310
+ } else out.note(`To link this repository to ${site.origin}, run \`npx serpkin status --yes\` (writes ${PROJECT_FILE}).`);
1311
+ }
1312
+
1199
1313
  /* ─────────────────────────────── routes ─────────────────────────────── */
1200
1314
 
1201
1315
  /**
1202
- * The registered site this repository serves, for a repository without .serpkin.json: the only site in the
1203
- * workspace, or the one whose origin is the app's package.json homepage. Otherwise name them.
1316
+ * The registered site this repository serves, for a repository without .serpkin.json: the one its files name (see
1317
+ * findRepoSite), else the only site in the workspace. Otherwise name them.
1204
1318
  */
1205
- async function registeredSite(api, app) {
1206
- const { items = [] } = await api.get("/api/records?kind=site&limit=100");
1207
- const bare = (o) => String(o ?? "").replace(/^https?:\/\/(www\.)?/i, "").replace(/\/+$/, "");
1208
- const home = app?.homepage ? normalizeUrl(app.homepage) : null;
1209
- const match = home ? items.find((s) => bare(s.origin) === bare(home)) : null;
1210
- if (match) return match;
1211
- if (items.length === 1) return items[0];
1319
+ async function registeredSite(api, app, ctx) {
1320
+ const r = await findRepoSite(api, ctx, app ? [app] : null);
1321
+ if (r.site) return r.site;
1212
1322
  throw new CliError(
1213
- items.length
1214
- ? `Which site is this repository? Pass --site <id>: ${items.slice(0, 5).map((s) => `${s.origin} (${s.id})`).join(", ")}.`
1323
+ r.items.length
1324
+ ? `Which site is this repository? Pass --site <id>: ${siteList(r.items)}.`
1215
1325
  : "No site registered yet. Run `npx serpkin init` in this repository first.",
1216
1326
  );
1217
1327
  }
@@ -1243,7 +1353,7 @@ export async function routes(flags, ctx = context()) {
1243
1353
  // No .serpkin.json: the site is usually registered already (from the web app or MCP). Find it, so the upload
1244
1354
  // also links this repository.
1245
1355
  const known = flags.site || ctx.env.SERPKIN_SITE_ID || project?.site_id;
1246
- const site = known ? null : await registeredSite(api, app);
1356
+ const site = known ? null : await registeredSite(api, app, ctx);
1247
1357
  const siteId = known || site.id;
1248
1358
  const { truncated, ...body } = map;
1249
1359
  await api.post("/api/cli/sites/route-map", { site_id: siteId, ...body });
package/lib/detect.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Framework detection and route-map scanning. Next.js (app + pages router) is exact;
2
2
  // Astro, SvelteKit, Nuxt and Remix are best-effort. Paths in the result are POSIX, relative to `repoRoot`.
3
3
  import { readdir, readFile, stat } from "node:fs/promises";
4
- import { dirname, join, relative, sep } from "node:path";
4
+ import { dirname, isAbsolute, join, relative, sep } from "node:path";
5
5
 
6
6
  const exists = (p) =>
7
7
  stat(p).then(
@@ -398,3 +398,104 @@ export function routeMapFramework(app) {
398
398
  export function publicDir(app) {
399
399
  return join(app.dir, app.framework === "sveltekit" ? "static" : "public");
400
400
  }
401
+
402
+ /* ─────────────── Which registered site is this repository? ─────────────── */
403
+
404
+ const ENV_FILES = [".env.production", ".env.production.local", ".env", ".env.local", ".env.example", ".env.sample"];
405
+ /** Env names that hold the public site address (NEXT_PUBLIC_SITE_URL, SITE_URL, PUBLIC_BASE_URL, NUXT_PUBLIC_SITE_URL…). */
406
+ const ENV_URL = /^\s*(?:export\s+)?([A-Z0-9_]*(?:SITE|BASE|APP|CANONICAL|PUBLIC|DOMAIN)[A-Z0-9_]*URL)\s*=\s*["']?(https?:\/\/[^\s"'#]+)/gm;
407
+ /** Config and layout files where the site address is usually written down. */
408
+ const CONFIG_FILES = [
409
+ "next-sitemap.config.js", "next-sitemap.config.cjs", "next-sitemap.config.mjs", "next-sitemap.config.ts",
410
+ "next.config.js", "next.config.mjs", "next.config.ts", "astro.config.mjs", "astro.config.ts", "nuxt.config.ts", "svelte.config.js",
411
+ "app/layout.tsx", "app/layout.jsx", "app/layout.js", "src/app/layout.tsx", "src/app/layout.jsx", "src/app/layout.js",
412
+ "config/site.ts", "src/config/site.ts", "lib/site.ts", "src/lib/site.ts", "site.config.ts", "src/site.config.ts", "lib/constants.ts", "src/lib/constants.ts",
413
+ ];
414
+ /** A quoted http(s) address on a line naming the site address: metadataBase, siteUrl, astro's site, SITE_URL fallbacks. */
415
+ const CONFIG_URL = /(metadataBase|siteUrl|SITE_URL|BASE_URL|baseUrl|\bsite\s*:|\burl\s*:)[^\n]*?["'`](https?:\/\/[^"'`\s/]+)/g;
416
+ const NOT_A_SITE = /^(localhost|127\.|0\.0\.0\.0|\[::1\])|\.local$|\.localhost$|^example\.(com|org|net)$/i;
417
+
418
+ /** "https://www.Example.com/x" → "example.com"; null for local or unusable addresses. */
419
+ export function bareHost(url) {
420
+ try {
421
+ const h = new URL(/^[a-z]+:\/\//i.test(url) ? url : `https://${url}`).hostname.toLowerCase().replace(/^www\./, "").replace(/\.$/, "");
422
+ return h && h.includes(".") && !NOT_A_SITE.test(h) ? h : null;
423
+ } catch {
424
+ return null;
425
+ }
426
+ }
427
+
428
+ /** The URL of the repository's git remote ("origin" first), read from .git/config; worktrees and submodules too. */
429
+ async function gitRemote(repoRoot) {
430
+ let gitDir = join(repoRoot, ".git");
431
+ const pointer = await readFile(gitDir, "utf8").catch(() => null);
432
+ if (pointer) {
433
+ // .git is a file naming the real git dir; a worktree's config sits in its common dir.
434
+ const g = pointer.match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();
435
+ if (!g) return null;
436
+ gitDir = isAbsolute(g) ? g : join(repoRoot, g);
437
+ const common = (await readFile(join(gitDir, "commondir"), "utf8").catch(() => "")).trim();
438
+ if (common) gitDir = isAbsolute(common) ? common : join(gitDir, common);
439
+ }
440
+ const config = await readFile(join(gitDir, "config"), "utf8").catch(() => "");
441
+ const remotes = [...config.matchAll(/\[remote\s+"([^"]+)"\]([^[]*)/g)].map(([, name, body]) => ({ name, url: body.match(/^\s*url\s*=\s*(\S+)/m)?.[1] ?? null }));
442
+ return (remotes.find((r) => r.name === "origin") ?? remotes[0])?.url ?? null;
443
+ }
444
+
445
+ /**
446
+ * Where this repository says which site it is, strongest first: package.json homepage, the public site address in
447
+ * env files, config and layout files (metadataBase, next-sitemap siteUrl, astro site), a CNAME file, then the git
448
+ * remote's repository name ("owner/silotree.com" names the host; "owner/silotree" only its first label: `loose`).
449
+ * @returns {Promise<{ host: string, source: string, loose?: boolean }[]>}
450
+ */
451
+ export async function repoSiteHints(repoRoot, apps = []) {
452
+ const hints = [];
453
+ const add = (url, source, loose = false) => {
454
+ const host = loose ? String(url).toLowerCase() : bareHost(url);
455
+ if (host && !hints.some((h) => h.host === host && !!h.loose === loose)) hints.push({ host, source, ...(loose ? { loose } : {}) });
456
+ };
457
+ const rel = (p) => posix(relative(repoRoot, p)) || ".";
458
+ const read = (p) => readFile(p, "utf8").then((t) => t.slice(0, 200_000), () => "");
459
+ const dirs = [...new Set([...apps.map((a) => a.dir), repoRoot])];
460
+ for (const dir of dirs) {
461
+ const pkg = await readPkg(dir);
462
+ if (typeof pkg?.homepage === "string") add(pkg.homepage, `the homepage in ${rel(join(dir, "package.json"))}`);
463
+ }
464
+ for (const dir of dirs)
465
+ for (const f of ENV_FILES)
466
+ for (const [, name, url] of (await read(join(dir, f))).matchAll(ENV_URL)) add(url, `${name} in ${rel(join(dir, f))}`);
467
+ for (const dir of dirs)
468
+ for (const f of CONFIG_FILES)
469
+ for (const [, what, url] of (await read(join(dir, f))).matchAll(CONFIG_URL))
470
+ add(url, `${what.replace(/\s*:$/, "")} in ${rel(join(dir, f))}`);
471
+ for (const dir of dirs)
472
+ for (const f of ["CNAME", "public/CNAME", "static/CNAME"]) {
473
+ const host = (await read(join(dir, f))).trim().split(/\s+/)[0];
474
+ if (host) add(host, rel(join(dir, f)));
475
+ }
476
+ const remote = await gitRemote(repoRoot);
477
+ const name = remote?.replace(/\.git$/, "").split(/[/:]/).filter(Boolean).at(-1);
478
+ if (name) {
479
+ if (bareHost(name)) add(name, `the git remote (${name})`);
480
+ else if (/^[a-z0-9-]{2,63}$/i.test(name)) add(name, `the git remote (${name})`, true);
481
+ }
482
+ return hints;
483
+ }
484
+
485
+ /**
486
+ * The registered site the hints point to, or null: the first hint (strongest first) whose host is a site's host
487
+ * (www ignored) or a subdomain of it; a loose hint (a repository name) matches the one site whose host starts with it.
488
+ * @returns {{ site: any, source: string } | null}
489
+ */
490
+ export function matchSiteByHints(sites, hints) {
491
+ for (const h of hints) {
492
+ const hit = sites.filter((s) => {
493
+ const host = bareHost(s.origin);
494
+ if (!host) return false;
495
+ return h.loose ? host.split(".")[0] === h.host : host === h.host || h.host.endsWith(`.${host}`);
496
+ });
497
+ // One repository name for two sites (silotree.com and silotree.app) is no answer.
498
+ if (hit.length === 1 || (hit.length > 1 && !h.loose)) return { site: hit[0], source: h.source };
499
+ }
500
+ return null;
501
+ }
@@ -121,12 +121,21 @@ export async function localCheck(api, { siteId, url, paths, fetchImpl = globalTh
121
121
  throw e;
122
122
  }
123
123
  const wanted = [...plan.paths, ...plan.files.filter((f) => !plan.paths.includes(f))];
124
- onRead?.(plan.paths.length);
124
+ // Older servers send no mission_paths.
125
+ const missionPaths = Array.isArray(plan.mission_paths) ? plan.mission_paths.filter((p) => plan.paths.includes(p)) : [];
126
+ onRead?.(plan.paths.length, { paths: plan.paths, mission_paths: missionPaths });
125
127
  const pages = await pool(wanted, CONCURRENCY, (p) => readLocalPage(origin, p, { fetchImpl, maxChars: plan.max_page_chars }));
126
128
  const home = pages.find((p) => p.path === plan.paths[0]);
127
129
  if (home && !home.status && /ECONNREFUSED|ENOTFOUND|EADDRNOTAVAIL|ECONNRESET/.test(home.error ?? ""))
128
130
  throw new CliError(
129
131
  `Nothing answers at ${origin} (${home.error}). Start the site first, ideally a production build (for Next.js: \`next build && next start\`), then run this again.`,
130
132
  );
131
- return api.post("/api/check/local", { site_id: siteId, local_origin: url, pages });
133
+ const r = await api.post("/api/check/local", { site_id: siteId, local_origin: url, pages });
134
+ return { ...r, mission_paths: missionPaths };
135
+ }
136
+
137
+ /** The planned paths, one per line, mission pages marked: "read 11 pages" alone doesn't say whether yours were in it. */
138
+ export function readList(paths, missionPaths = []) {
139
+ const width = Math.min(60, Math.max(...paths.map((p) => p.length)));
140
+ return paths.map((p) => ` ${missionPaths.includes(p) ? `${p.padEnd(width)} (mission page)` : p}`);
132
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serpkin",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "Connect your coding agent to Serpkin: sign in, register your site, upload its route map, and check pull-request previews for SEO regressions.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "serpkin",
3
3
  "displayName": "Serpkin",
4
- "version": "0.2.25",
4
+ "version": "0.2.26",
5
5
  "description": "The SEO brain for your coding agent: ranked SEO missions with patch-ready plans, preview checks and verification.",
6
6
  "author": {
7
7
  "name": "Serpkin",
@@ -3,7 +3,7 @@
3
3
  "serpkin": {
4
4
  "type": "stdio",
5
5
  "command": "npx",
6
- "args": ["-y", "--registry=https://registry.npmjs.org", "serpkin@0.2.25", "mcp"]
6
+ "args": ["-y", "--registry=https://registry.npmjs.org", "serpkin@0.2.26", "mcp"]
7
7
  }
8
8
  }
9
9
  }
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  description: Check a preview deployment for SEO regressions against production
3
3
  argument-hint: "<preview-url>"
4
- allowed-tools: Bash(npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 check:*)
4
+ allowed-tools: Bash(npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 check:*)
5
5
  ---
6
6
 
7
- Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 check $ARGUMENTS` from the repository root. If no URL was given, ask for the preview URL. A site without previews can pass its local production build (for example `http://localhost:3000`): the CLI reads it on this machine and compares it with production. Report that as a pre-deploy check, not production verification.
7
+ Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 check $ARGUMENTS` from the repository root. If no URL was given, ask for the preview URL. A site without previews can pass its local production build (for example `http://localhost:3000`): the CLI reads it on this machine and compares it with production. Report that as a pre-deploy check, not production verification.
8
8
 
9
9
  Summarize the result: regressions (path, check, production vs preview) and warnings. For each regression, find the code that causes it and propose a fix. Header-level noindex on preview hosts is expected and only a warning.
@@ -5,7 +5,7 @@ argument-hint: "<preview-url> [mission-id]"
5
5
 
6
6
  Use the serpkin-seo skill to ship the mission you just implemented (mission id from the arguments, otherwise the one in progress from `serpkin_next_mission`). Arguments: $ARGUMENTS
7
7
 
8
- 1. Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 check <preview-url>`. If it exits 1, fix the regressions, push and run it again. A site without previews passes its local production build instead (for example `http://localhost:3000`): that is a pre-deploy check, not verification, so skip step 3 and verify in production after I deploy.
8
+ 1. Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 check <preview-url>`. If it exits 1, fix the regressions, push and run it again. A site without previews passes its local production build instead (for example `http://localhost:3000`): that is a pre-deploy check, not verification, so skip step 3 and verify in production after I deploy.
9
9
  2. Call `serpkin_submit_result` with the PR URL, the preview URL (no previews: `deployment_url` once deployed), a short summary of the tests you ran and `files_changed` when you know it. The answer is short; pass `view: "full"` only if you need the whole mission.
10
10
  3. Call `serpkin_verify_mission`: `environment: "preview"` with the preview_url for technical missions, `environment: "evidence"` for content, link and research missions once the change is live (evidence reads the live site; before the deploy it comes back incomplete, "waiting for the deploy", which is not a failure).
11
11
  4. Report the verification status and tier. For a speed mission, `serpkin_lab_check` (free) shows the page's lab numbers; say they are lab data. After I deploy, verify with `environment: "production"` (Serpkin does this by itself if deploy checks are on in Settings → Automation). Don't merge or deploy.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Show the Serpkin site status, next mission and credits
3
- allowed-tools: Bash(npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 status:*)
3
+ allowed-tools: Bash(npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 status:*)
4
4
  ---
5
5
 
6
- Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 status` from the repository root and show the output. If it fails because the repository isn't set up, tell me to run `npx serpkin`. Without a plan the output shows the preview's first mission and a Checkout row: show them as they are, once, and don't add a sales pitch or ask again.
6
+ Run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 status` from the repository root and show the output. If it fails because the repository isn't set up, tell me to run `npx serpkin`. Without a plan the output shows the preview's first mission and a Checkout row: show them as they are, once, and don't add a sales pitch or ask again.
@@ -12,7 +12,7 @@ Serpkin ranks this site's SEO work into missions and verifies the result. Use it
12
12
  - The MCP connection already knows the workspace: no `project_id` needed.
13
13
  - `site_id`: `site_id` in `.serpkin.json` at the repository root, or `serpkin_get_workspace`.
14
14
  - No `.serpkin.json` and no site: ask the user to run `npx serpkin` first.
15
- - Site registered but no route map (`serpkin_next_mission` warns "Routes not uploaded", `implementation.route_map` is `false`, step files are `null`): run `npx serpkin routes --upload` at the repository root, with `--app <dir>` in a monorepo (for example `--app web` or `--app apps/web`; `npx serpkin routes` lists what it found). It also writes `.serpkin.json` when it's missing. Then fetch the mission again. Until then, a step's "Usually `app/...`" is a guess to confirm, not a path: in a monorepo it lives under the app folder.
15
+ - Site registered but no route map (`serpkin_get_site_context` `route_map.uploaded` is `false`, `npx serpkin status` shows "Routes not uploaded", `serpkin_next_mission` warns "Routes not uploaded", `implementation.route_map` is `false`, step files are `null`): run `npx serpkin routes --upload` at the repository root, with `--app <dir>` in a monorepo (for example `--app web` or `--app apps/web`; `npx serpkin routes` lists what it found). It also writes `.serpkin.json` when it's missing. Then fetch the mission again. Until then, a step's "Usually `app/...`" is a guess to confirm, not a path: in a monorepo it lives under the app folder.
16
16
  - Several sites, or "how are my sites doing?": call `serpkin_sites_overview` for every site at once, with what needs the user ranked across them. For a weekly check-in across all of them, `/serpkin:manager all` sets up one task instead of one per site.
17
17
 
18
18
  ## Lanes
@@ -43,9 +43,9 @@ An unverified site gets a 6-page preview. To verify it:
43
43
  - Otherwise do the `suggested_action` (usually `serpkin_scan_site`) and stop.
44
44
  2. **Implement.** First call `serpkin_update_mission` with `action: "start"` so the user and other agents see it is in progress (several at once: `mission_ids: [...]`, one call; each id gets its own result). Start and submit answer with the mission's summary and `next_step`; pass `view: "full"` only if you need the whole mission again. Research missions are a tool call (`serpkin_research_keywords`), not a code change. Then follow `mission.implementation.steps` in order. Each step names a `file` (from the route map), an `action` (edit, create or run) and an `intent`. Adapt each `snippet` to the existing code; don't paste blindly. Use `recipe` and `acceptance_criteria` for anything the steps don't cover. Keep the change focused on this one mission.
45
45
  3. **Run checks.** Run the project's tests, type check and build.
46
- 4. **Check the preview.** Once the branch has a preview deployment, run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 check <preview-url>`. Exit code 1 means regressions; fix them and re-run.
47
- **No previews** (the site deploys straight to production, for example `wrangler deploy` to Cloudflare Workers): before the human deploys, serve a production build locally (`next build && next start`, or the project's preview script) and run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.25 check http://localhost:3000` (your port). The CLI reads the local pages and Serpkin compares them with production; Serpkin never fetches localhost. Say plainly that this is a pre-deploy check, not production verification. Preview hosts on Vercel, Netlify, Cloudflare Pages and Workers (`*.workers.dev`), Render, Fly, Railway, Firebase and Amplify work directly; for the project's own staging domain, ask the user before running `check <url> --allow-host` once.
48
- 5. **Submit.** Call `serpkin_submit_result` with the PR URL, preview URL, a short test summary and `files_changed` when you know it (no preview: `deployment_url` after the deploy, and mention the local pre-deploy check in `test_summary`).
46
+ 4. **Check the preview.** Once the branch has a preview deployment, run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 check <preview-url>`. Exit code 1 means regressions; fix them and re-run.
47
+ **No previews** (the site deploys straight to production, for example `wrangler deploy` to Cloudflare Workers): before the human deploys, serve a production build locally (`next build && next start`, or the project's preview script) and run `npx -y --registry=https://registry.npmjs.org serpkin@0.2.26 check http://localhost:3000` (your port). The CLI reads the local pages and Serpkin compares them with production; Serpkin never fetches localhost. Say plainly that this is a pre-deploy check, not production verification. Preview hosts on Vercel, Netlify, Cloudflare Pages and Workers (`*.workers.dev`), Render, Fly, Railway, Firebase and Amplify work directly; for the project's own staging domain, ask the user before running `check <url> --allow-host` once.
48
+ 5. **Submit.** Call `serpkin_submit_result` with the PR URL, preview URL, a short test summary and `files_changed` when you know it (no preview: `deployment_url` after the deploy, and mention the local pre-deploy check in `test_summary`). One PR that covers several missions: one call with `mission_ids: [...]` (up to 25) and one `artifacts`; each id gets its own result.
49
49
  6. **Verify the preview.** Technical missions: `serpkin_verify_mission` with `environment: "preview"` and `preview_url`. Content, link and research missions: `environment: "evidence"`, which reads the live site, so run it once the change is deployed (or straight away when you shipped it to production yourself). Checked earlier, it comes back incomplete with "The change is live" still to come and the mission stays shipped: tell the user it's waiting for the deploy, don't change anything. If the submit reply warns that Serpkin can't see the site's deploys, pass on its deploy-hook tip once.
50
50
  7. **Verify production.** Only after the human has merged and deployed, call `serpkin_verify_mission` with `environment: "production"`. If deploy checks are on (Settings → Automation), Serpkin does this by itself after the deploy.
51
51
  A production check that fails within minutes of the submission, with most checks failing, is usually a deploy still in flight: when the first warning says Serpkin checks again by itself (`recheck_at` on the mission), don't re-run it or investigate; tell the user it rechecks at that time. When the warning instead names specific failing checks on a live page, fix those.
@@ -37,4 +37,4 @@ jobs:
37
37
  # Passed through env, not interpolated into the script, so the URL can't inject shell.
38
38
  PREVIEW_URL: ${{ github.event.deployment_status.target_url }}
39
39
  # Pinned version and registry; update the version deliberately.
40
- run: npx --yes --registry=https://registry.npmjs.org serpkin@0.2.25 check "$PREVIEW_URL" --site "$SERPKIN_SITE_ID"
40
+ run: npx --yes --registry=https://registry.npmjs.org serpkin@0.2.26 check "$PREVIEW_URL" --site "$SERPKIN_SITE_ID"