search-visibility 1.2.1 → 1.3.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 (35) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.es.md +36 -1
  3. package/README.ja.md +36 -1
  4. package/README.ko.md +42 -6
  5. package/README.md +42 -6
  6. package/README.zh.md +36 -1
  7. package/package.json +2 -1
  8. package/skills/seo-orchestrator/scripts/ai-performance.mjs +107 -0
  9. package/skills/seo-orchestrator/scripts/canonical.mjs +175 -0
  10. package/skills/seo-orchestrator/scripts/command.mjs +6 -0
  11. package/skills/seo-orchestrator/scripts/comparison-pairs.mjs +89 -0
  12. package/skills/seo-orchestrator/scripts/crawl-report.mjs +34 -0
  13. package/skills/seo-orchestrator/scripts/fetch-page.mjs +2 -5
  14. package/skills/seo-orchestrator/scripts/hreflang.mjs +273 -0
  15. package/skills/seo-orchestrator/scripts/html.mjs +7 -80
  16. package/skills/seo-orchestrator/scripts/index-status.mjs +181 -0
  17. package/skills/seo-orchestrator/scripts/indexing.mjs +28 -39
  18. package/skills/seo-orchestrator/scripts/internal-crawl.mjs +16 -46
  19. package/skills/seo-orchestrator/scripts/link-header.mjs +93 -0
  20. package/skills/seo-orchestrator/scripts/mcp.mjs +45 -8
  21. package/skills/seo-orchestrator/scripts/naver-advisor.mjs +147 -0
  22. package/skills/seo-orchestrator/scripts/observations.mjs +42 -8
  23. package/skills/seo-orchestrator/scripts/report-html.mjs +35 -0
  24. package/skills/seo-orchestrator/scripts/report-input.mjs +142 -0
  25. package/skills/seo-orchestrator/scripts/report-sources.mjs +202 -0
  26. package/skills/seo-orchestrator/scripts/robots.mjs +270 -0
  27. package/skills/seo-orchestrator/scripts/scope.mjs +185 -0
  28. package/skills/seo-orchestrator/scripts/search-performance.mjs +1 -1
  29. package/skills/seo-orchestrator/scripts/seo-check.mjs +199 -269
  30. package/skills/seo-orchestrator/scripts/site-audit.mjs +102 -46
  31. package/skills/seo-orchestrator/scripts/structured-data.mjs +316 -0
  32. package/skills/seo-orchestrator/scripts/url-inspection.mjs +150 -0
  33. package/skills/seo-orchestrator/scripts/visibility-comparison.mjs +218 -39
  34. package/skills/seo-orchestrator/scripts/visibility-report.mjs +71 -48
  35. package/skills/seo-orchestrator/scripts/visibility.mjs +53 -50
@@ -9,10 +9,18 @@ import { readFile } from "node:fs/promises";
9
9
  import { parseArgs } from "node:util";
10
10
  import { isCliEntry } from "./cli-entry.mjs";
11
11
 
12
- import { parseHtml, checkCanonical, httpUrl } from "./html.mjs";
12
+ import { parseHtml, checkCanonical, canonicalDeclarations, httpUrl } from "./html.mjs";
13
13
  import { auditLlms } from "./llms-audit.mjs";
14
14
  import { fetchPage, fetchResource } from "./fetch-page.mjs";
15
15
  import { indexingRules, reportIndexing } from "./indexing.mjs";
16
+ import { describeBlock, describeCrawlBlock, describeIndexing, indexingStatus, normalizeIntent, unreadableExclusions } from "./index-status.mjs";
17
+ import { analyzeJsonLd, describeBlockResult, describeCheck, describeOmittedBlocks, pageFindings } from "./structured-data.mjs";
18
+ import {
19
+ decideRobotsPath, describeRobotsFetch, describeRobotsHandling, evaluateRobots, normalizeRobotsPath,
20
+ parseRobots, readRobots, robotsEngine, robotsPathFor, CRAWLERS,
21
+ } from "./robots.mjs";
22
+ import { comparableUrl, parseLinkHeader } from "./link-header.mjs";
23
+ import { analyzeHreflang, describeHreflang, keptDeclarations, pageDeclarations, usable } from "./hreflang.mjs";
16
24
 
17
25
  export { parseHtml };
18
26
 
@@ -20,68 +28,35 @@ export const UA = "seo-skills-check/0.1 (+https://github.com/shaul1991/search-vi
20
28
 
21
29
  // ---------- JSON-LD ----------
22
30
 
23
- function flattenLd(node, out = []) {
24
- if (Array.isArray(node)) node.forEach((n) => flattenLd(n, out));
25
- else if (node && typeof node === "object") {
26
- if (node["@graph"]) flattenLd(node["@graph"], out);
27
- if (node["@type"]) out.push(node);
28
- }
29
- return out;
30
- }
31
-
32
- const typesOf = (n) => [].concat(n["@type"] || []).map(String);
33
-
34
- function checkDate(value, field, add) {
35
- if (typeof value !== "string") return add("FAIL", t("구조화 데이터", "Structured data"), `Event.${field}`, (currentLocale() === "en" ? `${field} must be a string` : `${field}가 문자열이 아님`), "structured-data");
36
- if (!/^\d{4}-\d{2}-\d{2}/.test(value)) return add("FAIL", t("구조화 데이터", "Structured data"), `Event.${field}`, (currentLocale() === "en" ? `Invalid ISO 8601 value: ${value}` : `ISO-8601 아님: ${value}`), "structured-data");
37
- if (/T00:00(:00)?/.test(value)) add("WARN", t("구조화 데이터", "Structured data"), `Event.${field}`, (currentLocale() === "en" ? `Midnight placeholder (T00:00): ${value}. Use only the date when the time is unknown` : `자정(T00:00)으로 채운 값: ${value}. 시간을 모르면 날짜만 쓰기`), "structured-data");
38
- else if (/T\d{2}:\d{2}/.test(value) && !/(Z|[+-]\d{2}:?\d{2})$/.test(value)) add("WARN", t("구조화 데이터", "Structured data"), `Event.${field}`, (currentLocale() === "en" ? `Missing UTC offset: ${value} (example: +09:00)` : `시간에 UTC 오프셋 없음: ${value} (예: +09:00)`), "structured-data");
39
- }
40
-
41
31
  export function checkJsonLd(blocks, add) {
42
- const nodes = [];
43
- blocks.forEach((raw, i) => {
44
- try { flattenLd(JSON.parse(raw), nodes); }
45
- catch (e) { add("FAIL", t("구조화 데이터", "Structured data"), `JSON-LD #${i + 1}`, (currentLocale() === "en" ? `Invalid JSON: ${String(e.message).slice(0, 80)}` : `JSON 파싱 실패: ${String(e.message).slice(0, 80)}`), "structured-data"); }
32
+ const channel = () => t("구조화 데이터", "Structured data");
33
+ const report = (level, item, detail) => add(level, channel(), item, detail, "structured-data");
34
+ const failures = [];
35
+ const grouped = new WeakMap();
36
+ const analysis = analyzeJsonLd(blocks, (check, node) => {
37
+ // 연관채널 속성은 노드마다 한 줄로 묶어 보고한다.
38
+ if (check.code === "channel") {
39
+ const seen = grouped.get(node) ?? new Set();
40
+ if (seen.has(check.feature)) return;
41
+ grouped.set(node, seen.add(check.feature));
42
+ }
43
+ failures.push(check);
44
+ }, (block) => {
45
+ // 문법 오류와 타입 없는 블록은 상세 목록의 상한과 관계없이 모두 보고한다.
46
+ if (block.state === "syntax-error") report("FAIL", `JSON-LD #${block.index}`, (currentLocale() === "en" ? `Invalid JSON: ${block.error}` : `JSON 파싱 실패: ${block.error}`));
47
+ else if (block.state === "no-type") report("WARN", `JSON-LD #${block.index}`, describeBlockResult(block, currentLocale()));
46
48
  });
47
- if (!blocks.length) add("INFO", t("구조화 데이터", "Structured data"), "JSON-LD", t("없음", "Missing"), "structured-data");
48
- else add("INFO", t("구조화 데이터", "Structured data"), t("유형", "Types"), [...new Set(nodes.flatMap(typesOf))].join(", ") || t("(@type 없음)", "(No @type)"), "structured-data");
49
+ const [missing, ...eventFindings] = blocks.length ? [null, ...pageFindings(analysis, blocks.length, currentLocale())] : pageFindings(analysis, 0, currentLocale());
50
+ if (missing) report(missing.level, missing.item, missing.detail);
51
+ else report("INFO", t("유형", "Types"), analysis.types.join(", ") || t("(@type 없음)", "(No @type)"));
49
52
 
50
- for (const n of nodes) {
51
- const types = typesOf(n);
52
- if (types.some((x) => /Event$/.test(x))) {
53
- if (!n.name) add("FAIL", t("구조화 데이터", "Structured data"), "Event.name", t("필수 속성 없음", "Required property missing"), "structured-data");
54
- if (!n.startDate) add("FAIL", t("구조화 데이터", "Structured data"), "Event.startDate", t("필수 속성 없음", "Required property missing"), "structured-data");
55
- else checkDate(n.startDate, "startDate", add);
56
- if (n.endDate) checkDate(n.endDate, "endDate", add);
57
- const loc = [].concat(n.location || [])[0];
58
- if (!loc) add("FAIL", t("구조화 데이터", "Structured data"), "Event.location", t("필수 속성 없음", "Required property missing"), "structured-data");
59
- else {
60
- if (!loc.name) add("WARN", t("구조화 데이터", "Structured data"), "Event.location.name", t("장소 이름 없음", "Missing venue name"), "structured-data");
61
- if (!loc.address) add("FAIL", t("구조화 데이터", "Structured data"), "Event.location.address", t("주소 없음(Google 필수)", "Missing address (required by Google)"), "structured-data");
62
- }
63
- if (n.name && loc?.name && String(n.name).trim() === String(loc.name).trim()) add("WARN", t("구조화 데이터", "Structured data"), "Event.name", t("행사명이 장소명과 같음", "Event name matches the venue name"), "structured-data");
64
- if (!n.eventStatus) add("INFO", t("구조화 데이터", "Structured data"), "Event.eventStatus", t("없음 → Google은 EventScheduled로 간주", "Missing. Google assumes EventScheduled"), "structured-data");
65
- if (!n.image) add("WARN", t("구조화 데이터", "Structured data"), "Event.image", t("권장 속성 없음", "Recommended property missing"), "structured-data");
66
- }
67
- if (types.includes("BreadcrumbList")) {
68
- const items = [].concat(n.itemListElement || []);
69
- if (!items.length) add("FAIL", t("구조화 데이터", "Structured data"), "BreadcrumbList", t("itemListElement 없음", "Missing itemListElement"), "structured-data");
70
- for (const it of items) {
71
- const name = it.name ?? it.item?.name;
72
- if (!name) add("FAIL", t("구조화 데이터", "Structured data"), "BreadcrumbList.name", t("name 없음(네이버 필수)", "Missing name (required by Naver)"), "structured-data");
73
- else if (/^(홈|home|top)$/i.test(String(name).trim())) add("WARN", t("구조화 데이터", "Structured data"), "BreadcrumbList.name", (currentLocale() === "en" ? `Generic name "${name}". Naver recommends a name that describes the page` : `일반어 "${name}" — 네이버는 페이지를 설명하는 이름 권장`), "structured-data");
74
- }
75
- }
76
- if ((types.includes("Organization") || types.includes("Person")) && n.sameAs !== undefined) {
77
- if (!n.name || !n.url) add("WARN", t("구조화 데이터", "Structured data"), `${types[0]}.sameAs`, t("네이버 연관채널은 name·url·sameAs 필수", "Naver associated channels require name, url and sameAs"), "structured-data");
78
- }
79
- if (types.includes("WebSite") && !n.name) add("WARN", t("구조화 데이터", "Structured data"), "WebSite.name", t("사이트 이름 없음", "Missing site name"), "structured-data");
53
+ for (const check of failures) report(check.level, check.code === "channel" ? check.feature : check.property, describeCheck(check, currentLocale()));
54
+ for (const block of analysis.blocks) {
55
+ if (block.nodeCount) report("INFO", `${t("JSON-LD 검사 범위", "JSON-LD coverage")} #${block.index}`, describeBlockResult(block, currentLocale()));
80
56
  }
81
- const events = nodes.filter((n) => typesOf(n).some((x) => /Event$/.test(x)));
82
- if (events.length > 1) add("WARN", t("구조화 데이터", "Structured data"), t("Event 개수", "Event count"), (currentLocale() === "en" ? `${events.length} events. Google's event experience supports pages dedicated to one event. Use ItemList on listing pages` : `${events.length}개 — Google 이벤트 환경은 한 이벤트에 집중한 상세(리프) 페이지만 지원. 목록 페이지는 ItemList 권장`), "structured-data");
83
- if (events.length) add("INFO", t("구조화 데이터", "Structured data"), t("Event 지역", "Event regions"), t("Google 이벤트 검색 환경 제공 지역에 한국 없음(2026-11-04 확인). 네이버 Event 가이드 없음", "Google's event experience excludes South Korea (checked 2026-11-04). Naver has no Event guide"), "structured-data");
84
- return nodes;
57
+ if (analysis.omittedBlocks) report("INFO", t("JSON-LD 검사 범위", "JSON-LD coverage"), describeOmittedBlocks(analysis.omittedBlocks, currentLocale()));
58
+ for (const finding of eventFindings) report(finding.level, finding.item, finding.detail);
59
+ return analysis;
85
60
  }
86
61
 
87
62
  // ---------- 이미지 크기 ----------
@@ -111,100 +86,14 @@ export function imageSize(buf) {
111
86
 
112
87
  // ---------- robots.txt ----------
113
88
 
114
- function robotsGroups(txt) {
115
- const groups = [];
116
- let cur = null;
117
- for (const raw of txt.split(/\r?\n/)) {
118
- const line = raw.replace(/#.*/, "").trim();
119
- const m = line.match(/^([a-zA-Z-]+)\s*:\s*(.*)$/);
120
- if (!m) continue;
121
- const [, k, v] = m;
122
- const key = k.toLowerCase();
123
- if (key === "user-agent") {
124
- if (!cur || cur.rules.length) { cur = { agents: [], rules: [] }; groups.push(cur); }
125
- cur.agents.push(v.toLowerCase());
126
- } else if ((key === "allow" || key === "disallow") && cur) cur.rules.push({ type: key, path: v });
127
- }
128
- return groups;
129
- }
130
-
131
- // RFC 9309: 비 ASCII는 UTF-8 퍼센트 인코딩으로, 인코딩된 비예약 ASCII는 원래 문자로 비교한다.
132
- // %2F 같은 예약 문자는 /와 다르며, 유니코드 경로의 대소문자도 보존한다.
133
- function normalizeRobotsPath(path) {
134
- return path.replace(/%[\da-f]{2}|[^\x21-\x7e]/giu, (part) => {
135
- if (!part.startsWith("%")) return encodeURIComponent(part);
136
- const char = String.fromCharCode(parseInt(part.slice(1), 16));
137
- return /[a-zA-Z0-9._~-]/.test(char) ? char : part.toUpperCase();
138
- });
139
- }
140
-
141
- // 앞에서부터 일치시키고, * 사이의 리터럴은 순서대로 찾는다. 마지막 $는 쿼리를 포함한 URL 끝을 뜻한다.
142
- function matchesRobotsPath(pattern, path) {
143
- const exact = pattern.endsWith("$");
144
- const pieces = (exact ? pattern.slice(0, -1) : pattern).split("*");
145
- const first = pieces.shift();
146
- if (!path.startsWith(first)) return false;
147
- if (!pieces.length) return !exact || path.length === first.length;
148
-
149
- const last = exact ? pieces.pop() : "";
150
- if (!path.endsWith(last)) return false;
151
- let cursor = first.length;
152
- for (const piece of pieces) {
153
- const found = path.indexOf(piece, cursor);
154
- if (found < 0) return false;
155
- cursor = found + piece.length;
156
- }
157
- return cursor <= path.length - last.length;
158
- }
159
-
160
- function matchingGroupName(groups, agent) {
161
- let best = "";
162
- for (const group of groups) {
163
- for (const name of group.agents) {
164
- if (name !== "*" && name.length > best.length && agent.startsWith(name)) best = name;
165
- }
166
- }
167
- return best;
168
- }
169
-
170
- function decideRobotsPath(groups, agent, path) {
171
- const name = agent.toLowerCase();
172
- let groupName = matchingGroupName(groups, name);
173
- let via = "own";
174
- if (!groupName && name === "applebot") {
175
- groupName = matchingGroupName(groups, "googlebot");
176
- via = "fallback";
177
- }
178
- if (!groupName) {
179
- groupName = "*";
180
- via = groups.some((g) => g.agents.includes("*")) ? "*" : null;
181
- }
182
- let rule = null;
183
- let bestLength = -1;
184
- for (const group of groups) {
185
- if (!group.agents.includes(groupName)) continue;
186
- for (const candidate of group.rules) {
187
- if (!candidate.path || !candidate.path.startsWith("/")) continue;
188
- const pattern = normalizeRobotsPath(candidate.path);
189
- if (!matchesRobotsPath(pattern, path)) continue;
190
- const length = pattern.replace(/%[\da-f]{2}/gi, "_").length;
191
- if (length > bestLength || (length === bestLength && candidate.type === "allow")) {
192
- bestLength = length;
193
- rule = candidate;
194
- }
195
- }
196
- }
197
- return { blocked: rule?.type === "disallow", via, groupName, rule };
198
- }
199
-
200
89
  // 기존 호출의 반환 형식과 기본 경로(/)를 유지한다.
201
90
  export function robotsDecision(txt, agent, path = "/") {
202
- const { blocked, via } = decideRobotsPath(robotsGroups(txt), agent, normalizeRobotsPath(path));
91
+ const { blocked, via } = decideRobotsPath(parseRobots(txt).groups, agent, normalizeRobotsPath(path));
203
92
  return { blocked, via };
204
93
  }
205
94
 
206
95
  export function robotsAllowsPath(txt, agent) {
207
- const groups = robotsGroups(txt);
96
+ const { groups } = parseRobots(txt);
208
97
  return path => !decideRobotsPath(groups, agent, normalizeRobotsPath(path)).blocked;
209
98
  }
210
99
 
@@ -214,7 +103,7 @@ export function robotsBlocksRoot(txt, agent) {
214
103
 
215
104
  // ---------- 메인 점검 ----------
216
105
 
217
- export function checkPage(p, add, baseUrl, { robotsHeaders = [], expectIndexable = false } = {}) {
106
+ export function checkPage(p, add, baseUrl, { robotsHeaders = [], linkHeader = [], expectIndexable = false, expectExcluded = false, headersObserved = Boolean(baseUrl), httpStatus = null } = {}) {
218
107
  const abs = (u) => /^https?:\/\//i.test(u || "");
219
108
  // 제목
220
109
  if (!p.title) add("FAIL", t("공통", "General"), "<title>", t("없음", "Missing"), "google-search");
@@ -234,11 +123,13 @@ export function checkPage(p, add, baseUrl, { robotsHeaders = [], expectIndexable
234
123
  }
235
124
  if (p.h1.length === 0) add("WARN", t("공통", "General"), "<h1>", t("없음 — 페이지 기본 제목이 분명해야 함", "Missing. Provide a clear primary heading"), "google-search");
236
125
  else if (p.h1.length > 1) add("INFO", t("공통", "General"), "<h1>", (currentLocale() === "en" ? `${p.h1.length}` : `${p.h1.length}개`), "google-search");
237
- const canonical = checkCanonical(p, add, baseUrl);
126
+ const canonical = checkCanonical(p, add, baseUrl, linkHeader);
238
127
  // robots meta
239
128
  const metaTags = p.metaTags ?? Object.entries(p.meta).map(([name, content]) => ({ name, content }));
240
129
  const rules = indexingRules(metaTags, robotsHeaders);
241
- const pageNoindex = reportIndexing(rules, add, expectIndexable);
130
+ const intent = expectExcluded ? "exclude" : normalizeIntent(expectIndexable);
131
+ const indexing = indexingStatus({ rules, intent, headersObserved, httpStatus });
132
+ const pageNoindex = reportIndexing(rules, add, intent, indexing);
242
133
  const appliesTo = (agent) => rules.filter(r => r.scope === "robots" || r.scope === agent).map(r => r.value);
243
134
  const naver = appliesTo("yeti");
244
135
  const bing = appliesTo("bingbot");
@@ -282,11 +173,11 @@ export function checkPage(p, add, baseUrl, { robotsHeaders = [], expectIndexable
282
173
  if (p.meta["twitter:card"] && !p.meta["twitter:title"] && !p.meta["og:title"]) add("FAIL", "X", "twitter:title", t("없음(og:title도 없음)", "Missing (og:title is also missing)"), "social-preview");
283
174
  const xImg = p.meta["twitter:image"] || p.meta["og:image"];
284
175
  if (p.meta["twitter:image"] && !abs(p.meta["twitter:image"])) add("FAIL", "X", "twitter:image", t("절대 URL 아님", "Expected an absolute URL"), "social-preview");
285
- return { ogImage: p.meta["og:image"], xImg, pageNoindex };
176
+ return { ogImage: p.meta["og:image"], xImg, pageNoindex, rules, intent, indexing };
286
177
  }
287
178
 
288
179
  async function fetchAuxiliary(url, network) {
289
- if (!network) return fetch(url, { headers: { "user-agent": UA } });
180
+ if (!network) return fetch(url, { headers: { "user-agent": UA }, signal: AbortSignal.timeout(30_000) });
290
181
  const resource = await fetchResource(url, UA, { ...network, accept: "*/*" });
291
182
  // Fetch's Response API is also used by the standalone checker.
292
183
  const emptyBody = [204, 205, 304].includes(resource.status);
@@ -311,119 +202,124 @@ async function checkImage(url, add, network) {
311
202
  }
312
203
 
313
204
  // [robots.txt 이름, 차단 시 수준, Skill, 설명]
314
- export const ROBOT_AGENTS = [
315
- ["Googlebot", "FAIL", "google-search", "Brave Search·Applebot도 Googlebot 규칙에 영향받음"],
316
- ["Yeti", "FAIL", "naver-search", ""],
317
- ["Daum", "FAIL", "daum-search", ""],
318
- ["Bingbot", "FAIL", "other-search-engines", "DuckDuckGo 일반 결과도 대부분 Bing 기반"],
319
- ["Applebot", "WARN", "other-search-engines", "Safari·Spotlight·Siri"],
320
- ["DuckDuckBot", "WARN", "other-search-engines", ""],
321
- ["Twitterbot", "FAIL", "social-preview", "X 카드"],
322
- ["facebookexternalhit", "FAIL", "social-preview", "Meta 링크 미리보기"],
323
- ["OAI-SearchBot", "WARN", "ai-crawlers", "ChatGPT 검색 답변에서 빠짐"],
324
- ["ChatGPT-User", "WARN", "ai-crawlers", "ChatGPT 사용자 요청 열람 불가"],
325
- ["Claude-SearchBot", "WARN", "ai-crawlers", "Claude 검색 품질용 색인에서 빠짐"],
326
- ["Claude-User", "WARN", "ai-crawlers", "Claude 사용자 요청 열람 불가"],
327
- ["PerplexityBot", "WARN", "ai-crawlers", "Perplexity 검색에서 빠짐"],
328
- ["Perplexity-User", "WARN", "ai-crawlers", "Perplexity 사용자 요청(대체로 robots 무시)"],
329
- ["meta-webindexer", "WARN", "ai-crawlers", "Meta AI 검색 인용에서 빠짐"],
330
- ["MistralAI-Index", "WARN", "ai-crawlers", "Mistral 검색에서 빠짐"],
331
- ["MistralAI-User", "WARN", "ai-crawlers", "Mistral 사용자 요청 열람 불가"],
332
- ["Google-Extended", "WARN", "ai-crawlers", "Gemini 앱·Vertex AI의 Google 검색 그라운딩에서 빠짐(Google 검색 자체엔 영향 없음)"],
333
- ["GPTBot", "INFO", "ai-crawlers", "OpenAI 학습 제외"],
334
- ["ClaudeBot", "INFO", "ai-crawlers", "Anthropic 학습 제외"],
335
- ["Applebot-Extended", "INFO", "ai-crawlers", "Apple 생성형 모델 학습 제외"],
336
- ["meta-externalagent", "INFO", "ai-crawlers", "Meta 학습 제외"],
337
- ["MistralAI-Training", "INFO", "ai-crawlers", "Mistral 학습 제외"],
338
- ["__usage_ai-training", "INFO", "ai-crawlers", "Microsoft AI 학습 제외(2027-02-01부터 반영)"],
339
- ["TelegramBot", "WARN", "social-preview", "Telegram 링크 미리보기"],
340
- ["Discordbot", "WARN", "social-preview", "Discord 임베드 미리보기"],
341
- ["facebookexternalhit", "WARN", "social-preview", "Threads · Meta 공유 미리보기"],
342
- ["Twitterbot", "WARN", "social-preview", "X(Twitter) 카드 미리보기"],
343
- ["Slackbot-LinkExpanding", "WARN", "social-preview", "Slack 링크 미리보기"],
344
- ["LinkedInBot", "WARN", "social-preview", "LinkedIn 공유 미리보기"],
345
- ];
205
+ export const ROBOT_AGENTS = CRAWLERS.map(({ agent, level, skill, note }) => [agent, level, skill, note]);
206
+
207
+ // 사이트 감사가 상호 참조를 판정할 때 쓰는 페이지 단위 기록.
208
+ export function hreflangRecord(page, requested) {
209
+ const canonicals = [...(page.canonical?.html ?? []), ...(page.canonical?.header ?? [])]
210
+ .map(({ url }) => url && comparableUrl(url)).filter(Boolean);
211
+ return {
212
+ url: page.hreflang?.url ?? null, requested, status: page.status, error: page.error,
213
+ noindex: Boolean(page.indexing?.blocks.some(({ scope }) => scope === "robots" || scope === "googlebot")),
214
+ canonicals: [...new Set(canonicals)], declarations: page.hreflang?.declarations ?? [],
215
+ };
216
+ }
346
217
 
347
- function reportHreflang(page, add, baseUrl) {
348
- const alternates = [];
349
- for (const { lang, href } of page.alternates) {
350
- const absolute = href && /^https?:\/\//i.test(href) ? httpUrl(href) : null;
351
- const url = absolute ? new URL(absolute) : null;
352
- if (!lang || !url || url.username || url.password) {
353
- add("WARN", t("다국어", "International"), "hreflang",
354
- t("언어 코드와 인증정보 없는 HTTP(S) 절대 URL을 지정하세요.", "Supply a language code and an absolute HTTP(S) URL without credentials."), "google-search");
355
- continue;
356
- }
357
- url.hash = "";
358
- alternates.push({ lang, url: url.href });
359
- }
360
- if (page.alternates.length && !alternates.some(({ lang }) => lang === "x-default")) {
361
- add("WARN", t("다국어", "International"), "hreflang x-default",
362
- t("지원 언어에 일치하지 않는 사용자를 위한 기본 URL을 지정하세요.", "Declare a fallback URL for users whose language does not match."), "google-search");
218
+ export function hreflangSummary(declarations) {
219
+ const seen = new Set();
220
+ return declarations.filter(usable).filter(({ lang, url }) => {
221
+ const key = `${lang}\u0000${url}`;
222
+ return !seen.has(key) && seen.add(key);
223
+ }).map(({ lang, url }) => ({ lang, url }));
224
+ }
225
+
226
+ export function trimHreflang(hreflang) {
227
+ if (!hreflang) return;
228
+ Object.assign(hreflang, keptDeclarations(hreflang.declarations));
229
+ hreflang.alternates = hreflang.alternates.slice(0, hreflang.declarations.length);
230
+ }
231
+
232
+ export function addHreflangFindings(findings, add) {
233
+ for (const finding of findings) {
234
+ add(finding.level, t("다국어", "International"), finding.item, describeHreflang(finding, currentLocale()), "google-search");
363
235
  }
364
- return { alternates, url: baseUrl };
365
236
  }
366
237
 
367
- async function checkRobots(url, add, pageNoindex = false, expectIndexable = false, network) {
238
+ // 500 KiB를 넘는 부분은 readRobots가 잘라 내므로, 큰 파일도 실패하지 않게 페이지 한도와 별도로 넉넉히 받는다.
239
+ const ROBOTS_FETCH_BYTES = 16 * 1024 * 1024;
240
+
241
+ // robots.txt는 요청 정책 자체를 읽는 요청이다. 페이지의 출처 제한과 robots 차단 규칙을 적용하지 않고
242
+ // 다른 출처로의 리다이렉트도 리다이렉트 한도 안에서 따라간다. CLI의 점검과 크롤링이 함께 쓴다.
243
+ export async function fetchRobots(url, { signal } = {}) {
244
+ const location = new URL("/robots.txt", url);
368
245
  try {
369
- const res = await fetchAuxiliary(new URL("/robots.txt", url), network);
370
- const ct = res.headers.get("content-type") || "";
371
- if (res.status === 429) return add("WARN", t("공통", "General"), "robots.txt", t("HTTP 429 — 요청량 제한으로 규칙을 확인하지 못함. Google의 크롤링이 지연될 수 있어 재확인 필요", "HTTP 429. Rate limiting prevented a check of the rules. Check again because Google crawling may be delayed"), "google-search");
372
- if (res.status >= 500) return add("FAIL", t("공통", "General"), "robots.txt", (currentLocale() === "en" ? `HTTP ${res.status}. Naver treats 5xx as disallowing all crawling` : `HTTP ${res.status} — 네이버는 5xx를 '모두 금지'로 해석`), "naver-search");
373
- if (res.status >= 400) return add("INFO", t("공통", "General"), "robots.txt", (currentLocale() === "en" ? `HTTP ${res.status}. Google and Naver treat this as having no crawl restrictions` : `HTTP ${res.status} — Google·네이버에서 크롤링 제한 규칙 없음으로 해석`), "naver-search");
374
- const txt = await res.text();
375
- if (/text\/html/i.test(ct)) add("WARN", t("공통", "General"), "robots.txt", t("HTML로 응답 — 네이버는 '없음'으로 볼 수 있음. text/plain 권장", "Returned HTML. Naver may treat the file as missing. Use text/plain"), "naver-search");
376
- const groups = robotsGroups(txt);
377
- const target = url.pathname + url.search;
378
- const path = normalizeRobotsPath(target);
379
- const wildcard = [];
380
- const crawlers = [];
381
- let wildcardRule = null;
382
- let blockedAi = false;
383
- for (const [agent, level, skill] of ROBOT_AGENTS) {
384
- const { blocked, via, groupName, rule } = decideRobotsPath(groups, agent, path);
385
- if (skill === "ai-crawlers") {
386
- const purpose = level === "INFO" ? "training" : /-User$/i.test(agent) ? "user-request"
387
- : agent === "Google-Extended" ? "grounding" : "search";
388
- crawlers.push({ agent, purpose, decision: blocked ? "blocked" : "allowed", via,
389
- rule: rule ? { type: rule.type, path: rule.path } : null });
390
- }
391
- if (!rule) continue;
392
- if (blocked && level !== "INFO" && skill === "ai-crawlers") blockedAi = true;
393
- // 같은 * 규칙을 적용받는 봇은 한 줄에 표시한다.
394
- if (via === "*") {
395
- wildcard.push({ agent, level });
396
- wildcardRule = rule;
397
- continue;
398
- }
399
- const channel = level === "INFO" ? t("AI 학습", "AI training") : skill === "ai-crawlers" ? t("AI 검색", "AI search") : t("공통", "General");
400
- const evidence = `User-agent: ${groupName}, ${rule.type}: ${rule.path}`;
401
- add(blocked ? level : "INFO", channel, `robots.txt ${agent}`, `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (${evidence})`, skill);
246
+ const res = await fetchResource(location, UA, {
247
+ signal, maxBytes: ROBOTS_FETCH_BYTES, accept: "*/*", readBody: ({ status }) => status >= 200 && status < 300,
248
+ });
249
+ const body = res.bytes ? new TextDecoder().decode(res.bytes) : "";
250
+ return readRobots({ url: location.href, status: res.status, body, contentType: res.headers["content-type"] || "" });
251
+ } catch (error) {
252
+ const timeout = ["AbortError", "TimeoutError"].includes(error.name) || error.code === "ABORT_ERR";
253
+ return readRobots({ url: location.href, error: String(error.message).slice(0, 120), errorKind: timeout ? "timeout" : "network" });
254
+ }
255
+ }
256
+
257
+ // 크롤러의 용도(role)를 보고서의 분류로 바꾼다.
258
+ const PURPOSES = { search: "search", "ai-search": "search", "ai-user": "user-request", "ai-grounding": "grounding", "ai-training": "training", social: "preview" };
259
+
260
+ async function checkRobots(url, add, pageNoindex = false, intent = "unspecified", network) {
261
+ const source = await fetchRobots(url, { signal: network?.signal });
262
+ const { fetch: result, groups, sitemaps } = source;
263
+ const target = robotsPathFor(url);
264
+ const locale = currentLocale();
265
+ const rows = (ai) => CRAWLERS.filter(({ skill }) => (skill === "ai-crawlers") === ai)
266
+ .map(({ agent, role }) => ({ agent, purpose: PURPOSES[role], ...evaluateRobots(source, agent, target) }));
267
+ const report = { path: target, fetch: result, sitemaps, crawlers: rows(true), otherCrawlers: rows(false) };
268
+ if (result.state === "no-file") {
269
+ const handling = [...new Set(["Googlebot", "Yeti", "Bingbot"].map(agent => describeRobotsHandling(source, robotsEngine(agent), locale)))].join(" · ");
270
+ add("INFO", t("공통", "General"), "robots.txt", `${target} — ${describeRobotsFetch(source, locale)}. ${handling}`, "naver-search");
271
+ return report;
272
+ }
273
+ if (result.state !== "read") {
274
+ const level = result.state === "server-error" ? "FAIL" : "WARN";
275
+ const handling = [...new Set(["Googlebot", "Yeti"].map(agent => describeRobotsHandling(source, robotsEngine(agent), locale)))].join(" · ");
276
+ const unverified = t("크롤러의 허용·차단 여부는 미확인이며, 이전 캐시와 실제 봇의 접근은 미관측입니다.",
277
+ "Crawler access is unverified. Cached copies and actual bot access were not observed.");
278
+ add(level, t("공통", "General"), "robots.txt", `${target} — ${describeRobotsFetch(source, locale)}. ${unverified} ${handling}`,
279
+ result.state === "server-error" ? "naver-search" : "google-search");
280
+ return report;
281
+ }
282
+ if (result.html) add("WARN", t("공통", "General"), "robots.txt", t("HTML로 응답 — 네이버는 '없음'으로 볼 수 있음. text/plain 권장", "Returned HTML. Naver may treat the file as missing. Use text/plain"), "naver-search");
283
+ if (result.truncated) add("INFO", t("공통", "General"), "robots.txt", `${target} — ${describeRobotsFetch(source, locale)}`, "google-search");
284
+ const path = normalizeRobotsPath(target);
285
+ const wildcard = [];
286
+ let wildcardRule = null;
287
+ let blockedAi = false;
288
+ for (const [agent, level, skill] of ROBOT_AGENTS) {
289
+ const { blocked, via, groupName, rule } = decideRobotsPath(groups, agent, path);
290
+ if (!rule) continue;
291
+ if (blocked && level !== "INFO" && skill === "ai-crawlers") blockedAi = true;
292
+ // 같은 * 규칙을 적용받는 봇은 한 줄에 표시한다.
293
+ if (via === "*") {
294
+ wildcard.push({ agent, level });
295
+ wildcardRule = rule;
296
+ continue;
402
297
  }
403
- if (wildcardRule) {
404
- const blocked = wildcardRule.type === "disallow";
405
- const names = wildcard.map(({ agent }) => agent).join(", ");
406
- const msg = (currentLocale() === "en" ? `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (User-agent: *, ${wildcardRule.type}: ${wildcardRule.path}). Applies to: ${names}` : `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (User-agent: *, ${wildcardRule.type}: ${wildcardRule.path}). 적용 대상: ${names}`);
407
- if (blocked && pageNoindex && !expectIndexable) {
408
- add("INFO", t("공통", "General"), t("비공개 상태", "Private access"), (currentLocale() === "en" ? `${msg}. The page also declares noindex. Confirm whether it should be public` : `${msg}. 페이지에도 noindex가 있어 공개 의도 확인 필요`), "seo-orchestrator");
409
- } else {
410
- const level = ["FAIL", "WARN", "INFO"].find((severity) => wildcard.some((bot) => bot.level === severity));
411
- add(blocked ? level : "INFO", t("공통", "General"), "robots.txt *", msg, "google-search");
412
- }
298
+ const channel = level === "INFO" ? t("AI 학습", "AI training") : skill === "ai-crawlers" ? t("AI 검색", "AI search") : t("공통", "General");
299
+ const evidence = `User-agent: ${groupName}, ${rule.type}: ${rule.path}`;
300
+ add(blocked ? level : "INFO", channel, `robots.txt ${agent}`, `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (${evidence})`, skill);
301
+ }
302
+ if (wildcardRule) {
303
+ const blocked = wildcardRule.type === "disallow";
304
+ const names = wildcard.map(({ agent }) => agent).join(", ");
305
+ const msg = (currentLocale() === "en" ? `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (User-agent: *, ${wildcardRule.type}: ${wildcardRule.path}). Applies to: ${names}` : `${target} — ${blocked ? t("차단", "Blocked") : t("허용", "Allowed")} (User-agent: *, ${wildcardRule.type}: ${wildcardRule.path}). 적용 대상: ${names}`);
306
+ if (blocked && pageNoindex && intent !== "index") {
307
+ add("INFO", t("공통", "General"), t("비공개 상태", "Private access"), (currentLocale() === "en" ? `${msg}. The page also declares noindex. Confirm whether it should be public` : `${msg}. 페이지에도 noindex가 있어 공개 의도 확인 필요`), "seo-orchestrator");
308
+ } else {
309
+ const level = ["FAIL", "WARN", "INFO"].find((severity) => wildcard.some((bot) => bot.level === severity));
310
+ add(blocked ? level : "INFO", t("공통", "General"), "robots.txt *", msg, "google-search");
413
311
  }
414
- if (!blockedAi) add("INFO", t("AI 검색", "AI search"), "robots.txt", (currentLocale() === "en" ? `${target} — No blocking rule found for the AI search and user-request crawlers checked. Verify access and visibility separately` : `${target} — 점검 대상 AI 검색·사용자 요청 크롤러의 차단 규칙 없음. 실제 접근·노출은 별도 확인`), "ai-crawlers");
415
- const sitemaps = [...txt.matchAll(/^\s*sitemap[ \t]*:[ \t]*([^#\r\n]+)/gim)]
416
- .map(([, value]) => value.trim()).filter(Boolean);
417
- add(sitemaps.length ? "INFO" : "WARN", t("공통", "General"), "robots.txt Sitemap", sitemaps.length ? sitemaps.join(", ") : t("Sitemap: 줄 없음", "Missing Sitemap: directive"), "google-search");
418
- if (!res.ok || /text\/html/i.test(ct)) return;
419
- return { path: target, sitemaps, crawlers };
420
- } catch (e) { add("WARN", t("공통", "General"), "robots.txt", (currentLocale() === "en" ? `Fetch failed: ${String(e.message).slice(0, 80)}` : `가져오기 실패: ${String(e.message).slice(0, 80)}`), "google-search"); }
312
+ }
313
+ if (!blockedAi) add("INFO", t("AI 검색", "AI search"), "robots.txt", (currentLocale() === "en" ? `${target} — No blocking rule found for the AI search and user-request crawlers checked. Verify access and visibility separately` : `${target} — 점검 대상 AI 검색·사용자 요청 크롤러의 차단 규칙 없음. 실제 접근·노출은 별도 확인`), "ai-crawlers");
314
+ add(sitemaps.length ? "INFO" : "WARN", t("공통", "General"), "robots.txt Sitemap", sitemaps.length ? sitemaps.join(", ") : t("Sitemap: 줄 없음", "Missing Sitemap: directive"), "google-search");
315
+ return report;
421
316
  }
422
317
 
423
- export async function run(target, { expectIndexable = false, network, llmsByOrigin = new Map(), fetchedPage } = {}) {
318
+ export async function run(target, { expectIndexable = false, expectExcluded = false, network, llmsByOrigin = new Map(), fetchedPage, deferHreflang = false } = {}) {
424
319
  const results = [];
425
320
  const add = (level, channel, item, detail, skill) => results.push({ level, channel, item, detail, skill });
426
- let html, baseUrl = null, robots, hreflang, status, llms;
321
+ let html, baseUrl = null, robots, status, llms, parsed, checked, structuredData;
322
+ let linkHeader = [];
427
323
  if (/^https?:\/\//i.test(target)) {
428
324
  const page = fetchedPage ?? await fetchPage(target, UA, network);
429
325
  const { chain, finalUrl } = page;
@@ -440,13 +336,14 @@ export async function run(target, { expectIndexable = false, network, llmsByOrig
440
336
  const lastOgByte = lastOgIndex < 0 ? 0 : Buffer.byteLength(html.slice(0, lastOgIndex));
441
337
  if (lastOgByte > 1024 * 1024) add("WARN", t("공유", "Sharing"), t("og 위치", "Open Graph position"), (currentLocale() === "en" ? `Open Graph tag at ${Math.round(lastOgByte / 1024)} KB in HTML. Meta reads the first 1 MB` : `og 태그가 HTML ${Math.round(lastOgByte / 1024)}KB 지점 — Meta는 첫 1MB만 읽음`), "social-preview");
442
338
  if (/http-equiv\s*=\s*["']?refresh/i.test(html)) add("WARN", t("네이버", "Naver"), "meta refresh", t("있음 — 네이버 소유 확인·수집에서 해석하지 않음. HTTP 리다이렉트 사용", "Present. Naver does not interpret this for verification or crawling. Use an HTTP redirect"), "naver-search");
443
- const p = parseHtml(html);
444
- const { ogImage, pageNoindex } = checkPage(p, add, baseUrl, { robotsHeaders: page.robotsHeaders, expectIndexable });
445
- checkJsonLd(p.jsonLd, add);
339
+ parsed = parseHtml(html);
340
+ linkHeader = parseLinkHeader(page.linkHeaders ?? [], baseUrl);
341
+ checked = checkPage(parsed, add, baseUrl, { robotsHeaders: page.robotsHeaders, linkHeader, expectIndexable, expectExcluded, httpStatus: status });
342
+ structuredData = checkJsonLd(parsed.jsonLd, add);
343
+ const { ogImage, pageNoindex, intent } = checked;
446
344
  if (ogImage && /^https?:/i.test(ogImage)) await checkImage(ogImage, add, network);
447
- hreflang = reportHreflang(p, add, baseUrl);
448
345
  const final = new URL(baseUrl);
449
- robots = await checkRobots(final, add, pageNoindex, expectIndexable, network);
346
+ robots = await checkRobots(final, add, pageNoindex, intent, network);
450
347
  if (!llmsByOrigin.has(final.origin)) {
451
348
  llmsByOrigin.set(final.origin, auditLlms(final.origin, UA, network));
452
349
  }
@@ -456,16 +353,42 @@ export async function run(target, { expectIndexable = false, network, llmsByOrig
456
353
  }
457
354
  } else {
458
355
  html = await readFile(target, "utf8");
459
- const p = parseHtml(html);
460
- checkPage(p, add, null, { expectIndexable });
461
- hreflang = reportHreflang(p, add, null);
462
- checkJsonLd(p.jsonLd, add);
356
+ parsed = parseHtml(html);
357
+ checked = checkPage(parsed, add, null, { expectIndexable, expectExcluded });
358
+ structuredData = checkJsonLd(parsed.jsonLd, add);
463
359
  add("INFO", t("공통", "General"), t("범위", "Scope"), t("로컬 파일: HTTP 헤더·robots.txt·리다이렉트·이미지 응답은 확인하지 않음", "Local file. HTTP headers, robots.txt, redirects and image responses were skipped"), "seo-orchestrator");
464
360
  }
465
- return { target, checkedAt: new Date().toISOString(), results, status, hreflang, robots, llms };
361
+ const pageUrl = baseUrl && comparableUrl(baseUrl);
362
+ const { indexing } = checked;
363
+ const crawlBlocked = unreadableExclusions(indexing, [...(robots?.crawlers ?? []), ...(robots?.otherCrawlers ?? [])]);
364
+ if (crawlBlocked.length) {
365
+ indexing.crawlBlocked = crawlBlocked;
366
+ add("WARN", t("공통", "General"), t("색인 제외 의도", "Exclusion intent"), describeCrawlBlock(crawlBlocked, currentLocale()), "google-search");
367
+ }
368
+ const declarations = pageDeclarations({ html: parsed.alternates, linkHeader, page: pageUrl ?? target });
369
+ const result = {
370
+ target, finalUrl: baseUrl, checkedAt: new Date().toISOString(), results, status,
371
+ hreflang: { url: pageUrl, alternates: hreflangSummary(declarations), declarations },
372
+ robots, llms, structuredData,
373
+ indexing,
374
+ canonical: canonicalDeclarations(parsed, baseUrl, linkHeader),
375
+ };
376
+ if (!deferHreflang) {
377
+ // 사이트 감사와 달리 한 페이지만 보므로 웹 결과처럼 읽지 않은 범위를 밝힌다.
378
+ add("INFO", t("다국어", "International"), "hreflang scope", baseUrl
379
+ ? t("확인 범위: 이 URL 응답의 HTML <head>와 HTTP Link 헤더. 사이트맵과 상대 페이지는 확인하지 않음",
380
+ "Scope: the HTML <head> and HTTP Link header of this response. Sitemaps and counterpart pages were not checked")
381
+ : t("확인 범위: 이 파일의 HTML <head>. 사이트맵과 상대 페이지는 확인하지 않음",
382
+ "Scope: the HTML <head> of this file. Sitemaps and counterpart pages were not checked"), "google-search");
383
+ const requested = baseUrl ? comparableUrl(target) : null;
384
+ const [findings] = analyzeHreflang([hreflangRecord(result, requested)], { singlePage: true });
385
+ addHreflangFindings(findings, add);
386
+ trimHreflang(result.hreflang);
387
+ }
388
+ return result;
466
389
  }
467
390
 
468
- function toMarkdown({ target, checkedAt, results }) {
391
+ function toMarkdown({ target, checkedAt, results, indexing }) {
469
392
  const icon = { FAIL: "❌", WARN: "⚠️", INFO: "ℹ️" };
470
393
  const order = { FAIL: 0, WARN: 1, INFO: 2 };
471
394
  const grouped = new Map();
@@ -480,6 +403,12 @@ function toMarkdown({ target, checkedAt, results }) {
480
403
  `## seo-check: ${target}`,
481
404
  (currentLocale() === "en" ? `Checked at ${checkedAt} · ❌ ${count("FAIL")} · ⚠️ ${count("WARN")} · ℹ️ ${count("INFO")}` : `확인 시각 ${checkedAt} · ❌ ${count("FAIL")} · ⚠️ ${count("WARN")} · ℹ️ ${count("INFO")}`),
482
405
  "",
406
+ ...(indexing?.blocks.length || indexing?.intent === "exclude" ? [
407
+ `**${describeIndexing(indexing, currentLocale()).title}**`,
408
+ ...indexing.blocks.map(block => `- ${describeBlock(block, currentLocale())}`),
409
+ ...(indexing.omitted ? [`- … +${indexing.omitted}`] : []),
410
+ "",
411
+ ] : []),
483
412
  t("| 상태 | 채널 | 항목 | 내용 | Skill |", "| Status | Channel | Check | Details | Skill |"),
484
413
  "| --- | --- | --- | --- | --- |",
485
414
  ...rows.map((r) => `| ${icon[r.level]} | ${r.channel} | ${r.item}${r.n > 1 ? ` ×${r.n}` : ""} | ${String(r.detail).replace(/\|/g, "\\|")} | ${r.skill} |`),
@@ -497,19 +426,20 @@ async function main() {
497
426
  crawl: { type: "boolean" },
498
427
  "max-pages": { type: "string" },
499
428
  "expect-indexable": { type: "boolean" },
429
+ "expect-excluded": { type: "boolean" },
500
430
  help: { type: "boolean", short: "h" },
501
431
  },
502
432
  });
503
433
  return withLocale(values.lang ?? "ko", async () => {
504
434
  const help = t(
505
- "사용법: node scripts/seo-check.mjs <URL | HTML 파일> [--json] [--expect-indexable] [--crawl [--max-pages n]] [--lang en|ko]",
506
- "Usage: node scripts/seo-check.mjs <URL | HTML file> [--json] [--expect-indexable] [--crawl [--max-pages n]] [--lang en|ko]",
435
+ "사용법: node scripts/seo-check.mjs <URL | HTML 파일> [--json] [--expect-indexable | --expect-excluded] [--crawl [--max-pages n]] [--lang en|ko]",
436
+ "Usage: node scripts/seo-check.mjs <URL | HTML file> [--json] [--expect-indexable | --expect-excluded] [--crawl [--max-pages n]] [--lang en|ko]",
507
437
  );
508
438
  if (values.help) {
509
439
  console.log(help);
510
440
  return 0;
511
441
  }
512
- if (positionals.length !== 1) throw new Error(help);
442
+ if (positionals.length !== 1 || (values["expect-indexable"] && values["expect-excluded"])) throw new Error(help);
513
443
  try {
514
444
  const { crawlLimit, crawlSite, crawlLines } = await import("./internal-crawl.mjs");
515
445
  const maxPages = crawlLimit(values.crawl, values["max-pages"]);
@@ -518,7 +448,7 @@ async function main() {
518
448
  const report = scope && !scope.seedPage
519
449
  ? { target, checkedAt: new Date().toISOString(), results: [] }
520
450
  : await run(target, {
521
- expectIndexable: values["expect-indexable"], fetchedPage: scope?.seedPage,
451
+ expectIndexable: values["expect-indexable"], expectExcluded: values["expect-excluded"], fetchedPage: scope?.seedPage,
522
452
  network: scope ? { allowedOrigin: scope.origin, allowRequest: scope.allowRequest, maxBytes: 2 * 1024 * 1024, signal: AbortSignal.timeout(5000) } : undefined,
523
453
  });
524
454
  if (scope) report.crawl = scope.report;