seo-supervisor 1.2.0 → 2.0.0

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 (207) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +16 -3
  4. package/CHANGELOG.md +430 -0
  5. package/NOTICE +7 -0
  6. package/README.md +230 -25
  7. package/agents/seo-auditor.md +16 -0
  8. package/agents/seo-reviewer.md +16 -0
  9. package/bin/agents.mjs +194 -29
  10. package/bin/extras.mjs +422 -0
  11. package/bin/prompt.mjs +34 -14
  12. package/bin/seo-supervisor.mjs +386 -53
  13. package/commands/seo-audit.md +29 -3
  14. package/commands/seo-brief.md +28 -0
  15. package/commands/seo-connect.md +27 -0
  16. package/commands/seo-fix.md +24 -3
  17. package/commands/seo-grow.md +26 -0
  18. package/commands/seo-launch.md +17 -3
  19. package/commands/seo-review.md +13 -1
  20. package/commands/seo-rewrite.md +25 -0
  21. package/commands/seo-setup.md +17 -1
  22. package/commands/seo-watch.md +28 -0
  23. package/hooks/hooks.json +117 -0
  24. package/package.json +20 -7
  25. package/skills/seo-supervisor/NOTICE +7 -0
  26. package/skills/seo-supervisor/SKILL.md +302 -21
  27. package/skills/seo-supervisor/audience.md +61 -0
  28. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  29. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  30. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  31. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  32. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  33. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  34. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  35. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  36. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  37. package/skills/seo-supervisor/examples/sample-audit.json +94 -2
  38. package/skills/seo-supervisor/examples/sample-report.html +111 -61
  39. package/skills/seo-supervisor/examples/sample-report.md +147 -44
  40. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  41. package/skills/seo-supervisor/examples/snippets.md +648 -1
  42. package/skills/seo-supervisor/grow.md +342 -0
  43. package/skills/seo-supervisor/og-images.md +85 -0
  44. package/skills/seo-supervisor/page-types.md +124 -0
  45. package/skills/seo-supervisor/planning.md +19 -7
  46. package/skills/seo-supervisor/profile-template.md +41 -0
  47. package/skills/seo-supervisor/report-format.md +177 -10
  48. package/skills/seo-supervisor/rewrite.md +59 -0
  49. package/skills/seo-supervisor/rules/ai-search.md +65 -12
  50. package/skills/seo-supervisor/rules/content.md +33 -9
  51. package/skills/seo-supervisor/rules/crawl-index.md +33 -6
  52. package/skills/seo-supervisor/rules/internal-linking.md +49 -6
  53. package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
  54. package/skills/seo-supervisor/rules/media.md +13 -1
  55. package/skills/seo-supervisor/rules/metadata.md +41 -9
  56. package/skills/seo-supervisor/rules/performance.md +50 -5
  57. package/skills/seo-supervisor/rules/rendering.md +39 -2
  58. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  59. package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
  60. package/skills/seo-supervisor/rules/structured-data.md +37 -14
  61. package/skills/seo-supervisor/rules/trust-security.md +25 -2
  62. package/skills/seo-supervisor/rules/urls.md +10 -2
  63. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  64. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  65. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  66. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  67. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  68. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  69. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  70. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  71. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  72. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  73. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  74. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  75. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  76. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  77. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  78. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  79. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  80. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  81. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  82. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  83. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  84. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  85. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  86. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  87. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  88. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  89. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  90. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  91. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  92. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  93. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  94. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  95. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  96. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  97. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  98. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  99. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  100. package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
  101. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  102. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  103. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  104. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  105. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  106. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  107. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  108. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  109. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  110. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  111. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  112. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  113. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  114. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  115. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  116. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  117. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  118. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  119. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  120. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  121. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  122. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  123. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  124. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  125. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  126. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  127. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  128. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  129. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  130. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  131. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  132. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  133. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  134. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  135. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  136. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  137. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  138. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  139. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  140. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  141. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  142. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  143. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  144. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  145. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  146. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  147. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  148. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  149. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  150. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  151. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  152. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  153. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  154. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  155. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  156. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  157. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  158. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  159. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  160. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  161. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  162. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  163. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  164. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  165. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  166. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  167. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  168. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  169. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  170. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  171. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  172. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  173. package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
  174. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  175. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  176. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  177. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  178. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  179. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  180. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  181. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  182. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  183. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  184. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  185. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  186. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  187. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  188. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  189. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  190. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  191. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  192. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  193. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  194. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  195. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  196. package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
  197. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  198. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
  199. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  200. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  201. package/skills/seo-supervisor/site-types/content.md +34 -1
  202. package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
  203. package/skills/seo-supervisor/site-types/local-business.md +96 -6
  204. package/skills/seo-supervisor/site-types/services.md +46 -0
  205. package/skills/seo-supervisor/site-types/tools.md +3 -3
  206. package/skills/seo-supervisor/strategy.md +232 -0
  207. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -1,15 +1,24 @@
1
- // report-plan.mjs: the SEO plan that /seo-setup proposes and builds, as numbers, HTML and Markdown.
2
- // Used by render-report.mjs when the audit JSON has a `plan`. The shape is in report-format.md.
1
+ // @ts-check
2
+ // The report's /seo-setup plan section as stats, HTML and Markdown. The plan's shape is in report-format.md.
3
+ import { safeHref, cellMd, mdSafe, noteMd } from "./report/format.mjs";
3
4
 
4
5
  const STATUSES = ["exists", "to-build", "built", "to-create"];
5
6
  const LABEL = { exists: "Already right", "to-build": "To build", built: "Built", "to-create": "To create" };
6
- const PLAN_LABEL = { proposed: "Proposed: waiting for your approval", approved: "Approved: being built", built: "Built" };
7
+ const PLAN_LABEL = {
8
+ proposed: "Proposed: waiting for your approval",
9
+ approved: "Approved: being built",
10
+ built: "Built",
11
+ };
7
12
  const NEEDS = { copy: "Copy", facts: "Facts", decision: "A decision", yes: "Your yes" };
8
13
 
9
14
  const key = r => r.url || r.pattern || "";
10
15
  const isDone = r => r.status === "exists" || r.status === "built";
11
16
  const ownerOpen = r => r.owner && r.owner.done !== true && r.owner.declined !== true;
12
17
  const yesOpen = y => y.approved !== true && y.declined !== true;
18
+ // Only an http(s) URL or a plain relative path (drafts/privacy.md) is linked. Anything else (javascript:, data:,
19
+ // //host, \\server) shows as text, so a click can't run a script in the report. Paths with spaces or non-ASCII letters
20
+ // are text too; widen the pattern if real drafts need them.
21
+ const draftHref = d => (typeof d === "string" ? safeHref(d) || (/^[\w.~-][\w.~%+/-]*$/.test(d) ? d : null) : null);
13
22
 
14
23
  export function planStats(plan) {
15
24
  const pages = Array.isArray(plan?.pages) ? plan.pages : [];
@@ -30,7 +39,11 @@ export function planStats(plan) {
30
39
  };
31
40
  }
32
41
 
33
- export function planHtml(plan, { esc, inl, num }) {
42
+ /**
43
+ * @param {any} plan
44
+ * @param {{ esc: (s: any) => string, inl: (s: any) => string, num: (n: any) => string, traffic?: (url: string) => string | null }} helpers
45
+ */
46
+ export function planHtml(plan, { esc, inl, num, traffic = () => null }) {
34
47
  const pages = Array.isArray(plan?.pages) ? plan.pages : [];
35
48
  const s = planStats(plan);
36
49
  const chip = st => `<span class="pchip s-${esc(st)}">${esc(LABEL[st] || st)}</span>`;
@@ -40,40 +53,72 @@ export function planHtml(plan, { esc, inl, num }) {
40
53
  <p class="plan-n"><span class="n">${s.progress}%</span>of the agent's work is done</p>
41
54
  <div class="pbar" role="img" aria-label="Plan progress: ${s.progress}% of the agent's work is done"><i style="width:${s.progress}%"></i></div>
42
55
  </div>
43
- <ul class="plan-counts">${STATUSES.filter(st => s.byStatus[st]).map(st => `<li>${chip(st)}<b>${num(s.byStatus[st])}</b></li>`).join("")}${s.ownerOpen ? `<li><span class="own">Needs you</span><b>${num(s.ownerOpen)}</b></li>` : ""}</ul>
56
+ <ul class="plan-counts">${STATUSES.filter(st => s.byStatus[st])
57
+ .map(st => `<li>${chip(st)}<b>${num(s.byStatus[st])}</b></li>`)
58
+ .join("")}${s.ownerOpen ? `<li><span class="own">Needs you</span><b>${num(s.ownerOpen)}</b></li>` : ""}</ul>
44
59
  ${plan.summary ? `<p class="plan-summary">${inl(plan.summary)}</p>` : ""}
45
- ${fixesLine(plan, n => num(n), ids => ids.map(id => `<a href="#${esc(id)}">${esc(id)}</a>`).join(", "))}
60
+ ${fixesLine(
61
+ plan,
62
+ n => num(n),
63
+ ids => ids.map(id => `<a href="#${esc(id)}">${esc(id)}</a>`).join(", "),
64
+ )}
46
65
  </section>`;
47
- if (!pages.length) return `<div class="plan">${head}<section class="panel empty-state"><h2>No pages in this plan yet</h2><p>Run /seo-setup to propose one.</p></section></div>`;
66
+ if (!pages.length)
67
+ return `<div class="plan">${head}<section class="panel empty-state"><h2>No pages in this plan yet</h2><p>Run /seo-setup to propose one.</p></section></div>`;
48
68
 
49
69
  const yes = [
50
- ...(plan.yes || []).filter(yesOpen).map(y => `<li><b>${esc(y.id || "")}</b> ${inl(y.what)}${y.why ? `<span class="quiet"> · ${inl(y.why)}</span>` : ""}</li>`),
51
- ...pages.filter(r => ownerOpen(r) && r.owner.needs === "yes").map(r => `<li><code>${esc(key(r))}</code> ${inl(r.owner.what || "")}</li>`),
70
+ ...(plan.yes || [])
71
+ .filter(yesOpen)
72
+ .map(
73
+ y =>
74
+ `<li><b>${esc(y.id || "")}</b> ${inl(y.what)}${y.why ? `<span class="quiet"> · ${inl(y.why)}</span>` : ""}</li>`,
75
+ ),
76
+ ...pages
77
+ .filter(r => ownerOpen(r) && r.owner.needs === "yes")
78
+ .map(r => `<li><code>${esc(key(r))}</code> ${inl(r.owner.what || "")}</li>`),
52
79
  ];
53
- const declined = [...(plan.yes || []).filter(y => y.declined === true).map(y => `<b>${esc(y.id || "")}</b> ${inl(y.what)}`),
54
- ...pages.filter(r => r.owner && r.owner.declined === true).map(r => `<code>${esc(key(r))}</code> ${inl(r.owner.what || "")}`)];
55
- const yesHtml = yes.length || declined.length ? `<section class="panel plan-yes" aria-labelledby="h-yes"><h2 id="h-yes">Needs your yes</h2>
80
+ const declined = [
81
+ ...(plan.yes || []).filter(y => y.declined === true).map(y => `<b>${esc(y.id || "")}</b> ${inl(y.what)}`),
82
+ ...pages
83
+ .filter(r => r.owner && r.owner.declined === true)
84
+ .map(r => `<code>${esc(key(r))}</code> ${inl(r.owner.what || "")}`),
85
+ ];
86
+ const yesHtml =
87
+ yes.length || declined.length
88
+ ? `<section class="panel plan-yes" aria-labelledby="h-yes"><h2 id="h-yes">Needs your yes</h2>
56
89
  ${yes.length ? `<p class="quiet">Each of these changes needs its own yes before the agent makes it. Approving the plan doesn't cover them.</p><ol>${yes.join("")}</ol>` : `<p class="quiet">Nothing is waiting for your yes.</p>`}
57
- ${declined.length ? `<p class="plan-declined"><span class="quiet">Declined by you, so the agent won't make these changes:</span> ${declined.join("; ")}</p>` : ""}</section>` : "";
90
+ ${declined.length ? `<p class="plan-declined"><span class="quiet">Declined by you, so the agent won't make these changes:</span> ${declined.join("; ")}</p>` : ""}</section>`
91
+ : "";
58
92
 
59
93
  // Site structure from `parent`; rows whose parent isn't in the plan are roots.
60
94
  const keys = new Set(pages.map(key));
61
95
  const kids = new Map();
62
- for (const r of pages) { const p = keys.has(r.parent) && r.parent !== key(r) ? r.parent : ""; (kids.get(p) || kids.set(p, []).get(p)).push(r); }
96
+ for (const r of pages) {
97
+ const p = keys.has(r.parent) && r.parent !== key(r) ? r.parent : "";
98
+ (kids.get(p) || kids.set(p, []).get(p)).push(r);
99
+ }
63
100
  const seen = new Set();
64
101
  const tree = parent => {
65
102
  const list = (kids.get(parent) || []).filter(r => !seen.has(key(r)));
66
103
  if (!list.length) return "";
67
- return `<ul>${list.map(r => { seen.add(key(r)); return `<li><code>${esc(key(r))}</code>${r.pattern ? ` <span class="pcount">×${num(r.count || 0)}</span>` : ""} ${chip(r.status)}${tree(key(r))}</li>`; }).join("")}</ul>`;
104
+ return `<ul>${list
105
+ .map(r => {
106
+ seen.add(key(r));
107
+ return `<li><code>${esc(key(r))}</code>${r.pattern ? ` <span class="pcount">×${num(r.count || 0)}</span>` : ""} ${chip(r.status)}${tree(key(r))}</li>`;
108
+ })
109
+ .join("")}</ul>`;
68
110
  };
69
111
  const treeHtml = `<section class="panel plan-tree" aria-labelledby="h-tree"><h2 id="h-tree">Site structure</h2>${tree("")}</section>`;
70
112
 
71
- const field = (label, v) => (v == null || v === "" || (Array.isArray(v) && !v.length) ? "" : `<dt>${label}</dt><dd>${Array.isArray(v) ? v.map(x => inl(x)).join(", ") : inl(v)}</dd>`);
113
+ const field = (label, v) =>
114
+ v == null || v === "" || (Array.isArray(v) && !v.length)
115
+ ? ""
116
+ : `<dt>${label}</dt><dd>${Array.isArray(v) ? v.map(x => inl(x)).join(", ") : inl(v)}</dd>`;
72
117
  const row = r => {
73
118
  const o = r.owner;
74
119
  return `<details class="prow" data-status="${esc(r.status)}">
75
120
  <summary><span class="pu"><code>${esc(key(r))}</code>${r.pattern ? ` <span class="pcount">×${num(r.count || 0)}</span>` : ""}</span><span class="pt">${r.target ? esc(r.target) : `<span class="quiet">—</span>`}</span><span class="ptype">${esc(r.type || "")}</span><span class="pst">${chip(r.status)}${ownerOpen(r) ? `<span class="own">Needs you</span>` : ""}</span></summary>
76
- <dl class="pd">${field("Intent", r.intent)}${field("Other targets", r.secondary)}${field(r.pattern ? "Title template" : "Title", r.title)}${field(r.pattern ? "Description template" : "Description", r.description)}${field(r.pattern ? "H1 template" : "H1", r.h1)}${field("Intro", r.intro)}${field("Schema", r.schema)}${field("Parent", r.parent)}${field("Links to", r.linksTo)}${r.from ? field("Moves from", `${r.from} → ${key(r)}`) : ""}${r.pattern && r.count ? field("Built", `${num(r.status === "built" || r.status === "exists" ? r.count : Number(r.built) || 0)} of ${num(r.count)}`) : ""}${(r.samples || []).length ? `<dt>Examples</dt><dd><ul class="psamples">${r.samples.map(x => `<li><code>${esc(x.url)}</code>${x.title ? ` ${esc(x.title)}` : ""}</li>`).join("")}</ul></dd>` : ""}${o ? `<dt>${o.done === true ? "Done by you" : "Needs you"}</dt><dd>${esc(NEEDS[o.needs] || o.needs || "")}: ${inl(o.what || "")}${o.draft ? ` · <a href="${esc(o.draft)}">Read the draft</a>` : ""}</dd>` : ""}${r.finding ? `<dt>Finding</dt><dd><a href="#${esc(r.finding)}">${esc(r.finding)}</a></dd>` : ""}</dl>
121
+ <dl class="pd">${field("Intent", r.intent)}${r.url ? field("Search traffic", traffic(r.url)) : ""}${field("Other targets", r.secondary)}${field(r.pattern ? "Title template" : "Title", r.title)}${field(r.pattern ? "Description template" : "Description", r.description)}${field(r.pattern ? "H1 template" : "H1", r.h1)}${field("Intro", r.intro)}${field("Schema", r.schema)}${field("Parent", r.parent)}${field("Links to", r.linksTo)}${r.from ? field("Moves from", `${r.from} → ${key(r)}`) : ""}${r.pattern && r.count ? field("Built", `${num(r.status === "built" || r.status === "exists" ? r.count : Number(r.built) || 0)} of ${num(r.count)}`) : ""}${(r.samples || []).length ? `<dt>Examples</dt><dd><ul class="psamples">${r.samples.map(x => `<li><code>${esc(x.url)}</code>${x.title ? ` ${esc(x.title)}` : ""}</li>`).join("")}</ul></dd>` : ""}${o ? `<dt>${o.done === true ? "Done by you" : "Needs you"}</dt><dd>${esc(NEEDS[o.needs] || o.needs || "")}: ${inl(o.what || "")}${o.draft ? (draftHref(o.draft) ? ` · <a href="${esc(draftHref(o.draft))}">Read the draft</a>` : ` · Draft: <code>${esc(o.draft)}</code>`) : ""}</dd>` : ""}${r.finding ? `<dt>Finding</dt><dd><a href="#${esc(r.finding)}">${esc(r.finding)}</a></dd>` : ""}</dl>
77
122
  </details>`;
78
123
  };
79
124
  const present = STATUSES.filter(st => s.byStatus[st]);
@@ -128,35 +173,69 @@ function fixesLine(plan, count, list, html = true) {
128
173
  const ids = Array.isArray(plan.alsoFixes) ? plan.alsoFixes : [];
129
174
  if (!ids.length) return "";
130
175
  const what = `${count(ids.length)} audit finding${ids.length === 1 ? "" : "s"} in code`;
131
- const text = plan.status === "built" ? `Setup also fixed ${what}: ${list(ids)}` : `After the build, setup also fixes ${what}: ${list(ids)}`;
176
+ const text =
177
+ plan.status === "built"
178
+ ? `Setup also fixed ${what}: ${list(ids)}`
179
+ : `After the build, setup also fixes ${what}: ${list(ids)}`;
132
180
  return html ? `<p class="plan-fixes">${text}</p>` : `${text}.`;
133
181
  }
134
182
 
135
- const cell = v => String(Array.isArray(v) ? v.join(", ") : v ?? "").replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ");
183
+ // Escaped like the rest of the report: mdSafe keeps `code` spans as inl does and makes URLs code spans; cellMd also
184
+ // escapes a table cell's pipes and line breaks.
185
+ const cell = v => cellMd(mdSafe(Array.isArray(v) ? v.join(", ") : v));
186
+ const item = (id, what) => `${id ? `${noteMd(id)}: ` : ""}${mdSafe(what)}`;
136
187
 
137
188
  export function planMarkdown(plan) {
138
189
  const pages = Array.isArray(plan?.pages) ? plan.pages : [];
139
190
  const s = planStats(plan);
140
191
  const L = ["## SEO plan", ""];
141
- L.push(`Status: ${PLAN_LABEL[plan.status] || plan.status || "?"}${plan.approvedOn ? ` (approved ${plan.approvedOn})` : ""} · Progress: ${s.progress}% · ${STATUSES.filter(st => s.byStatus[st]).map(st => `${s.byStatus[st]} ${LABEL[st].toLowerCase()}`).join(", ") || "no pages"}${s.ownerOpen ? ` · ${s.ownerOpen} need you` : ""}`, "");
142
- if (plan.summary) L.push(plan.summary, "");
192
+ L.push(
193
+ `Status: ${noteMd(PLAN_LABEL[plan.status] || plan.status || "?")}${plan.approvedOn ? ` (approved ${noteMd(plan.approvedOn)})` : ""} · Progress: ${s.progress}% · ${
194
+ STATUSES.filter(st => s.byStatus[st])
195
+ .map(st => `${s.byStatus[st]} ${LABEL[st].toLowerCase()}`)
196
+ .join(", ") || "no pages"
197
+ }${s.ownerOpen ? ` · ${s.ownerOpen} need you` : ""}`,
198
+ "",
199
+ );
200
+ if (plan.summary) L.push(mdSafe(plan.summary), "");
143
201
  const fixes = fixesLine(plan, String, ids => ids.join(", "), false);
144
- if (fixes) L.push(fixes, "");
145
- const yes = [...(plan.yes || []).filter(yesOpen).map(y => `- ${y.id ? `${y.id}: ` : ""}${y.what}${y.why ? ` (${y.why})` : ""}`),
146
- ...pages.filter(r => ownerOpen(r) && r.owner.needs === "yes").map(r => `- ${key(r)}: ${r.owner.what || ""}`)];
147
- if (yes.length) L.push("### Needs your yes", "", "Each needs its own yes; approving the plan doesn't cover them.", "", ...yes, "");
148
- for (const y of (plan.yes || []).filter(y => y.declined === true)) L.push(`Declined: ${y.id ? `${y.id}: ` : ""}${y.what}`);
149
- for (const r of pages.filter(r => r.owner && r.owner.declined === true)) L.push(`Declined: ${key(r)}: ${r.owner.what || ""}`);
150
- if ((plan.yes || []).some(y => y.declined === true) || pages.some(r => r.owner && r.owner.declined === true)) L.push("");
151
- if (!pages.length) { L.push("No pages in this plan yet.", ""); return L; }
152
- L.push("| Page | Type | Status | Target | Title | Description | H1 | Schema | Parent | Needs you |", "| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |");
202
+ if (fixes) L.push(mdSafe(fixes), "");
203
+ const yes = [
204
+ ...(plan.yes || []).filter(yesOpen).map(y => `- ${item(y.id, y.what)}${y.why ? ` (${mdSafe(y.why)})` : ""}`),
205
+ ...pages.filter(r => ownerOpen(r) && r.owner.needs === "yes").map(r => `- ${item(key(r), r.owner.what || "")}`),
206
+ ];
207
+ if (yes.length)
208
+ L.push("### Needs your yes", "", "Each needs its own yes; approving the plan doesn't cover them.", "", ...yes, "");
209
+ for (const y of (plan.yes || []).filter(y => y.declined === true)) L.push(`Declined: ${item(y.id, y.what)}`);
210
+ for (const r of pages.filter(r => r.owner && r.owner.declined === true))
211
+ L.push(`Declined: ${item(key(r), r.owner.what || "")}`);
212
+ if ((plan.yes || []).some(y => y.declined === true) || pages.some(r => r.owner && r.owner.declined === true))
213
+ L.push("");
214
+ if (!pages.length) {
215
+ L.push("No pages in this plan yet.", "");
216
+ return L;
217
+ }
218
+ L.push(
219
+ "| Page | Type | Status | Target | Title | Description | H1 | Schema | Parent | Needs you |",
220
+ "| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |",
221
+ );
153
222
  for (const r of pages) {
154
223
  const page = r.pattern ? `${r.pattern} ×${r.count || 0}` : r.url;
155
- const owner = ownerOpen(r) ? `${NEEDS[r.owner.needs] || r.owner.needs}: ${r.owner.what || ""}${r.owner.draft ? ` (draft: ${r.owner.draft})` : ""}` : "";
156
- L.push(`| ${cell(page)} | ${cell(r.type)} | ${cell(LABEL[r.status] || r.status)} | ${cell(r.target)} | ${cell(r.title)} | ${cell(r.description)} | ${cell(r.h1)} | ${cell(r.schema)} | ${cell(r.parent)} | ${cell(owner)} |`);
224
+ const owner = ownerOpen(r)
225
+ ? `${NEEDS[r.owner.needs] || r.owner.needs}: ${r.owner.what || ""}${r.owner.draft ? ` (draft: ${r.owner.draft})` : ""}`
226
+ : "";
227
+ L.push(
228
+ `| ${cell(page)} | ${cell(r.type)} | ${cell(LABEL[r.status] || r.status)} | ${cell(r.target)} | ${cell(r.title)} | ${cell(r.description)} | ${cell(r.h1)} | ${cell(r.schema)} | ${cell(r.parent)} | ${cell(owner)} |`,
229
+ );
157
230
  }
158
231
  L.push("");
159
232
  const intros = pages.filter(r => r.intro);
160
- if (intros.length) L.push("Intros for new pages (approving the plan approves these words):", "", ...intros.map(r => `- ${key(r)}: ${r.intro}`), "");
233
+ if (intros.length)
234
+ L.push(
235
+ "Intros for new pages (approving the plan approves these words):",
236
+ "",
237
+ ...intros.map(r => `- ${item(key(r), r.intro)}`),
238
+ "",
239
+ );
161
240
  return L;
162
241
  }