@sightmap/sightmap 0.9.0 → 0.10.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.
package/dist/index.d.ts CHANGED
@@ -75,6 +75,19 @@ interface EnrichSnapshotInput {
75
75
  sightmap: Sightmap;
76
76
  currentUrl: string;
77
77
  inPageMatches: InPageSightmapMatch[];
78
+ /**
79
+ * Optional raw a11y snapshot text from the engine (e.g. `playwright-cli
80
+ * snapshot`). When provided together with `refAnnotations`, the kernel
81
+ * additively annotates it and returns `enrichedAriaText`. The engine's
82
+ * native `[ref=eN]` tokens are preserved verbatim.
83
+ */
84
+ ariaText?: string;
85
+ /**
86
+ * Map of engine ref token (`e3`) → sightmap component name(s) covering
87
+ * that node. Built by the adapter from its browser-side join. Only used
88
+ * when `ariaText` is also provided.
89
+ */
90
+ refAnnotations?: Map<string, string[]>;
78
91
  }
79
92
  interface SightmapSnapshotComponent {
80
93
  name: string;
@@ -92,6 +105,13 @@ interface EnrichedSnapshot {
92
105
  } | null;
93
106
  components: SightmapSnapshotComponent[];
94
107
  memory: string[];
108
+ /**
109
+ * The engine's a11y snapshot text with `[sightmap=Name]` tokens added
110
+ * inline on matched nodes. Present only when the caller supplied
111
+ * `ariaText`. Byte-identical to the input when nothing matched, so an
112
+ * agent's bootstrap-by-ref path is never disturbed.
113
+ */
114
+ enrichedAriaText?: string;
95
115
  }
96
116
  /**
97
117
  * Pure function: combines a sightmap, the agent's current URL, and the
package/dist/index.js CHANGED
@@ -973,6 +973,16 @@ function serialize(doc) {
973
973
  return out.endsWith("\n") ? out : out + "\n";
974
974
  }
975
975
 
976
+ // src/enrich/a11y/annotate.ts
977
+ function annotateAriaText(ariaText, refAnnotations) {
978
+ if (refAnnotations.size === 0) return ariaText;
979
+ return ariaText.replace(/\[ref=(e\d+)\]/g, (full, ref) => {
980
+ const names = refAnnotations.get(ref);
981
+ if (names === void 0 || names.length === 0) return full;
982
+ return `${full} [sightmap=${names.join(",")}]`;
983
+ });
984
+ }
985
+
976
986
  // src/enrich/snapshot.ts
977
987
  function enrichSnapshot(input) {
978
988
  const { sightmap, currentUrl, inPageMatches } = input;
@@ -997,7 +1007,13 @@ function enrichSnapshot(input) {
997
1007
  memory: result.view.memory ?? []
998
1008
  } : null,
999
1009
  components,
1000
- memory: result.memory ?? []
1010
+ memory: result.memory ?? [],
1011
+ ...input.ariaText !== void 0 ? {
1012
+ enrichedAriaText: annotateAriaText(
1013
+ input.ariaText,
1014
+ input.refAnnotations ?? /* @__PURE__ */ new Map()
1015
+ )
1016
+ } : {}
1001
1017
  };
1002
1018
  }
1003
1019
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parse.ts","../src/validate.ts","../src/diagnostics.ts","../src/merge.ts","../src/loadDirectory.ts","../src/routeMatch.ts","../src/resolver.ts","../src/match.ts","../src/explain.ts","../src/lintRules/duplicateName.ts","../src/lintRules/duplicateRoute.ts","../src/lintRules/routeShadowing.ts","../src/lintRules/unknownSource.ts","../src/lintRules/selectorSyntax.ts","../src/lint.ts","../src/format/index.ts","../src/format/canonical-rules.ts","../src/format/canonicalize.ts","../src/enrich/snapshot.ts","../src/enrich/act.ts","../src/enrich/network.ts","../src/enrich/in-page.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport type { SightmapFragment } from \"./sightmap.js\";\nimport type { Component } from \"./types.js\";\n\nexport interface ParseOptions {\n /** Optional source file path; recorded on the fragment for canonical-order merging. */\n sourceFile?: string;\n}\n\n/**\n * Parse a single sightmap file (YAML string or pre-parsed object).\n * Throws on parse error, missing version, or version mismatch.\n * Normalizes `selector: string` to `selector: [string]` everywhere.\n */\nexport function parse(input: string | object, opts: ParseOptions = {}): SightmapFragment {\n let doc: unknown;\n if (typeof input === \"string\") {\n try {\n doc = yaml.load(input);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`YAML parse error: ${msg}`);\n }\n } else {\n // Shallow-clone caller's object so we don't mutate it.\n doc = { ...input };\n }\n\n if (doc === null || typeof doc !== \"object\" || Array.isArray(doc)) {\n throw new Error(\"Expected sightmap document to be an object at the root\");\n }\n\n const obj = doc as Record<string, unknown>;\n if (obj[\"version\"] === undefined) {\n throw new Error(\"Missing required `version` field\");\n }\n if (obj[\"version\"] !== 1) {\n throw new Error(`Unsupported version: ${String(obj[\"version\"])} (expected 1)`);\n }\n\n // Normalize selectors recursively. Spread each view to avoid mutating\n // shared view objects when the caller passed a pre-parsed input.\n if (Array.isArray(obj[\"components\"])) {\n obj[\"components\"] = (obj[\"components\"] as Component[]).map(normalizeComponent);\n }\n if (Array.isArray(obj[\"views\"])) {\n obj[\"views\"] = (obj[\"views\"] as Array<Record<string, unknown>>).map((v) => {\n const out = { ...v };\n if (Array.isArray(out[\"components\"])) {\n out[\"components\"] = (out[\"components\"] as Component[]).map(normalizeComponent);\n }\n return out;\n });\n }\n\n const fragment = {\n ...obj,\n __brand: \"SightmapFragment\" as const,\n ...(opts.sourceFile !== undefined ? { __sourceFile: opts.sourceFile } : {}),\n } as SightmapFragment;\n return fragment;\n}\n\nfunction normalizeComponent(c: Component): Component {\n // Common migration error: `selectors` (plural) instead of `selector` (singular).\n // The schema only accepts singular `selector`; the singular field already takes\n // a string or string-array, so a plural alias would be redundant. Surface\n // explicitly rather than silently dropping the value.\n if ((c as unknown as Record<string, unknown>)[\"selectors\"] !== undefined && c.selector === undefined) {\n const name = (c as { name?: string }).name ?? \"(unnamed)\";\n throw new Error(\n `Component \"${name}\": use \\`selector\\` (singular), not \\`selectors\\` (plural). ` +\n `\\`selector\\` accepts either a single string or an array of strings.`,\n );\n }\n const sel = c.selector;\n const normalized: Component = {\n ...c,\n selector: typeof sel === \"string\" ? [sel] : (sel as [string, ...string[]]),\n };\n if (Array.isArray(c.children)) {\n normalized.children = c.children.map(normalizeComponent);\n }\n return normalized;\n}\n","import yaml from \"js-yaml\";\nimport { Ajv2020 } from \"ajv/dist/2020.js\";\nimport type { ValidateResult, SightmapFragment } from \"./sightmap.js\";\nimport {\n PARSE_ERROR,\n SCHEMA_VALIDATION_FAILED,\n UNKNOWN_VERSION,\n type Diagnostic,\n} from \"./diagnostics.js\";\nimport { parse } from \"./parse.js\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { resolve, dirname } from \"node:path\";\n\n// Lazily initialized to avoid crashing when this module is bundled into a\n// browser context (fileURLToPath is Node-only). validate() itself is Node-only\n// and should never be called from browser code.\nlet _ajvValidate: ReturnType<InstanceType<typeof Ajv2020>[\"compile\"]> | undefined;\n\nfunction getValidator() {\n if (_ajvValidate) return _ajvValidate;\n // These Node APIs run only on first call to validate(), not at module load.\n const __dirname = dirname(fileURLToPath(import.meta.url));\n // Resolve the vendored schema in two contexts:\n // - Production (published package): bundled file lives at dist/index.js, schema at dist/vendored/.\n // - Dev (vitest, source files): validate.ts lives at src/, schema at ../vendored/.\n const schemaCandidates = [\n resolve(__dirname, \"./vendored/sightmap.schema.json\"),\n resolve(__dirname, \"../vendored/sightmap.schema.json\"),\n ];\n const schemaPath = schemaCandidates.find((p) => existsSync(p));\n if (schemaPath === undefined) {\n throw new Error(\n `vendored sightmap.schema.json not found. Looked in: ${schemaCandidates.join(\", \")}`,\n );\n }\n const schema = JSON.parse(readFileSync(schemaPath, \"utf8\")) as unknown;\n const ajv = new Ajv2020({ allErrors: true, strict: false });\n _ajvValidate = ajv.compile(schema as object);\n return _ajvValidate;\n}\n\nexport interface ValidateOptions {\n sourceFile?: string;\n}\n\nexport function validate(input: string | object, opts: ValidateOptions = {}): ValidateResult {\n const diagnostics: Diagnostic[] = [];\n let doc: unknown;\n\n if (typeof input === \"string\") {\n try {\n doc = yaml.load(input);\n } catch (err) {\n const e = err as { message?: string; mark?: { line?: number; column?: number } };\n diagnostics.push({\n severity: \"error\",\n code: PARSE_ERROR,\n message: e.message ?? \"YAML parse error\",\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n ...(e.mark\n ? { loc: { line: (e.mark.line ?? 0) + 1, column: (e.mark.column ?? 0) + 1 } }\n : {}),\n });\n return { ok: false, diagnostics };\n }\n } else {\n doc = input;\n }\n\n if (doc === null || typeof doc !== \"object\" || Array.isArray(doc)) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: \"Expected document root to be an object\",\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n });\n return { ok: false, diagnostics };\n }\n\n const obj = doc as Record<string, unknown>;\n if (obj[\"version\"] !== 1) {\n diagnostics.push({\n severity: \"error\",\n code: UNKNOWN_VERSION,\n message:\n obj[\"version\"] === undefined\n ? \"Missing required `version` field\"\n : `Unsupported version: ${String(obj[\"version\"])} (expected 1)`,\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n path: \"/version\",\n });\n return { ok: false, diagnostics };\n }\n\n const ajvValidate = getValidator();\n const ok = ajvValidate(obj);\n if (!ok) {\n for (const e of ajvValidate.errors ?? []) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: `${e.instancePath || \"(root)\"} ${e.message ?? \"\"}`.trim(),\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n ...(e.instancePath ? { path: e.instancePath } : {}),\n });\n }\n return { ok: false, diagnostics };\n }\n\n // Schema-valid: now run parse() (which normalizes selectors and brands).\n let value: SightmapFragment;\n try {\n value = parse(obj, opts.sourceFile !== undefined ? { sourceFile: opts.sourceFile } : {});\n } catch (err) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: err instanceof Error ? err.message : String(err),\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n });\n return { ok: false, diagnostics };\n }\n return { ok: true, value };\n}\n","export type Severity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n severity: Severity;\n code: string;\n message: string;\n file?: string;\n path?: string;\n loc?: { line: number; column: number };\n source?: string;\n}\n\n// Stable, kebab-case codes. Renames require an SEP.\nexport const PARSE_ERROR = \"parse-error\";\nexport const SCHEMA_VALIDATION_FAILED = \"schema-validation-failed\";\nexport const UNKNOWN_VERSION = \"unknown-version\";\nexport const MERGE_COLLISION_VIEW = \"merge-collision-view\";\nexport const MERGE_COLLISION_COMPONENT = \"merge-collision-component\";\nexport const DUPLICATE_VIEW_NAME = \"duplicate-view-name\";\nexport const DUPLICATE_ROUTE = \"duplicate-route\";\nexport const ROUTE_SHADOWING = \"route-shadowing\";\nexport const UNKNOWN_SOURCE = \"unknown-source\";\nexport const SELECTOR_SYNTAX = \"selector-syntax\";\n\n// fmt CLI diagnostic codes (sightmap/spec docs/authoring-conventions.md#diagnostic-codes-authoring-side).\nexport const FMT_NOT_CANONICAL = \"fmt.not-canonical\";\nexport const FMT_PARSE_ERROR = \"fmt.parse-error\";\nexport const FMT_SCHEMA_INVALID = \"fmt.schema-invalid\";\n\n// Repo-conventions codes (WI-6). See docs/repo-conventions.md in the spec repo.\nexport const CONVENTION_SEP_FILENAME = \"convention.sep-filename\";\nexport const CONVENTION_FIXTURE_DIRNAME = \"convention.fixture-dirname\";\nexport const CONVENTION_INVALID_SLUG = \"convention.invalid-slug\";\nexport const CONVENTION_UNEXPECTED_FILE = \"convention.unexpected-file\";\n","import type { SightmapFragment, Sightmap } from \"./sightmap.js\";\nimport type { View, Component, Request } from \"./types.js\";\nimport {\n MERGE_COLLISION_VIEW,\n MERGE_COLLISION_COMPONENT,\n type Diagnostic,\n} from \"./diagnostics.js\";\n\n/**\n * Merge fragments into a queryable Sightmap.\n *\n * Canonical order: fragments are sorted by `__sourceFile` (code-point order; locale-independent\n * for cross-environment determinism). Fragments without a `__sourceFile` sort first, and ES2019\n * sort stability preserves their input order. Within each fragment, declaration order is\n * preserved. The merged collection's order = (sourceFile order, then declaration order).\n *\n * Duplicate view names produce `merge-collision-view` warnings; duplicate global component\n * names produce `merge-collision-component`. The first occurrence wins.\n *\n * Returned arrays are fresh, but element objects (View/Component/Request) are shared with\n * the input fragments — callers must not mutate them.\n */\nexport function merge(fragments: SightmapFragment[]): Sightmap {\n const sorted = [...fragments].sort((a, b) => {\n const aFile = a.__sourceFile ?? \"\";\n const bFile = b.__sourceFile ?? \"\";\n return aFile < bFile ? -1 : aFile > bFile ? 1 : 0;\n });\n\n const views: View[] = [];\n const globalComponents: Component[] = [];\n const globalRequests: Request[] = [];\n const fileMemory: { memory: string[]; sourceFile: string }[] = [];\n const diagnostics: Diagnostic[] = [];\n\n const seenViewNames = new Map<string, string>(); // name → sourceFile\n const seenComponentNames = new Map<string, string>();\n\n for (const f of sorted) {\n const file = f.__sourceFile ?? \"<unknown>\";\n\n for (const v of f.views ?? []) {\n const prev = seenViewNames.get(v.name);\n if (prev !== undefined) {\n diagnostics.push({\n severity: \"warning\",\n code: MERGE_COLLISION_VIEW,\n message: `View name \"${v.name}\" defined in both \"${prev}\" and \"${file}\"; first occurrence wins.`,\n file,\n });\n } else {\n seenViewNames.set(v.name, file);\n }\n views.push(v); // keep all views; resolveByUrl picks the most-specific match at query time\n }\n\n for (const c of f.components ?? []) {\n const prev = seenComponentNames.get(c.name);\n if (prev !== undefined) {\n diagnostics.push({\n severity: \"warning\",\n code: MERGE_COLLISION_COMPONENT,\n message: `Component name \"${c.name}\" defined in both \"${prev}\" and \"${file}\"; first occurrence wins.`,\n file,\n });\n } else {\n seenComponentNames.set(c.name, file);\n }\n globalComponents.push(c);\n }\n\n for (const r of f.requests ?? []) {\n globalRequests.push(r);\n }\n\n if (Array.isArray(f.memory) && f.memory.length > 0) {\n fileMemory.push({ memory: [...f.memory], sourceFile: file });\n }\n }\n\n return {\n version: 1,\n views,\n globalComponents,\n globalRequests,\n fileMemory,\n diagnostics,\n __brand: \"Sightmap\",\n };\n}\n","import { readFile, readdir } from \"node:fs/promises\";\nimport { join, extname, relative, resolve } from \"node:path\";\nimport { merge } from \"./merge.js\";\nimport { validate } from \"./validate.js\";\nimport type { Sightmap, SightmapFragment } from \"./sightmap.js\";\nimport type { Diagnostic } from \"./diagnostics.js\";\n\nexport interface LoadDirectoryOptions {\n /** Optional root for `file` fields in diagnostics. Default: the directory passed in. */\n diagnosticRoot?: string;\n}\n\n/**\n * Recursively load all *.yaml/*.yml files under `dir`, validate each, and merge.\n *\n * Files that fail validation contribute their diagnostics to the merged Sightmap's\n * `diagnostics` array but are otherwise skipped. This keeps loadDirectory total —\n * a single bad file doesn't abort the whole load.\n */\nexport async function loadDirectory(\n dir: string,\n opts: LoadDirectoryOptions = {},\n): Promise<Sightmap> {\n const absDir = resolve(dir);\n const root = opts.diagnosticRoot !== undefined ? resolve(opts.diagnosticRoot) : absDir;\n\n const files = await collectYamlFiles(absDir);\n files.sort(); // alphabetical canonical order\n\n const fragments: SightmapFragment[] = [];\n const loadDiagnostics: Diagnostic[] = [];\n\n for (const file of files) {\n const relPath = relative(root, file);\n const text = await readFile(file, \"utf8\");\n const r = validate(text, { sourceFile: relPath });\n if (r.ok) {\n fragments.push(r.value);\n } else {\n loadDiagnostics.push(...r.diagnostics);\n }\n }\n\n const merged = merge(fragments);\n return {\n ...merged,\n diagnostics: [...loadDiagnostics, ...merged.diagnostics],\n };\n}\n\nasync function collectYamlFiles(dir: string): Promise<string[]> {\n const out: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n for (const e of entries) {\n const p = join(dir, e.name);\n if (e.isDirectory()) {\n out.push(...(await collectYamlFiles(p)));\n } else if (e.isFile()) {\n const ext = extname(p).toLowerCase();\n if (ext === \".yaml\" || ext === \".yml\") out.push(p);\n }\n }\n return out;\n}\n","/**\n * Canonicalize a URL or pathname for matching.\n * - Accepts absolute URL or pathname.\n * - Strips scheme, host, query string, and fragment.\n * - Normalizes trailing slashes (except for the root \"/\").\n */\nexport function canonicalizeUrl(input: string): string {\n let s = input;\n // Strip absolute prefix.\n const protoMatch = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(s);\n if (protoMatch) {\n s = s.slice(protoMatch[0].length) || \"/\";\n }\n // Strip fragment.\n const hash = s.indexOf(\"#\");\n if (hash !== -1) s = s.slice(0, hash);\n // Strip query.\n const q = s.indexOf(\"?\");\n if (q !== -1) s = s.slice(0, q);\n // Trailing slash.\n if (s.length > 1 && s.endsWith(\"/\")) s = s.slice(0, -1);\n return s;\n}\n\n/**\n * Test whether a glob route pattern matches a URL pathname.\n * Pattern syntax (per spec):\n * - Literal segments match themselves\n * - \"*\" matches exactly one path segment\n * - \"**\" matches any depth of segments\n * - \":param\" segments normalize to \"*\"\n * - Matching is case-sensitive\n * - Trailing slashes ignored\n */\nexport function routeMatch(pattern: string, url: string): boolean {\n const p = normalizePattern(pattern);\n const u = canonicalizeUrl(url);\n const patternSegs = splitSegments(p);\n const urlSegs = splitSegments(u);\n return matchSegs(patternSegs, urlSegs);\n}\n\nfunction normalizePattern(p: string): string {\n // Replace \":param\" segments with \"*\"\n let s = p\n .split(\"/\")\n .map((seg) => (seg.startsWith(\":\") ? \"*\" : seg))\n .join(\"/\");\n if (s.length > 1 && s.endsWith(\"/\")) s = s.slice(0, -1);\n return s;\n}\n\nfunction splitSegments(path: string): string[] {\n if (path === \"/\" || path === \"\") return [];\n const trimmed = path.startsWith(\"/\") ? path.slice(1) : path;\n return trimmed.split(\"/\");\n}\n\n/**\n * Specificity score for a route pattern (higher = more specific).\n *\n * Used by the matcher to pick among multiple views whose `route` patterns\n * all match a given URL. Per-segment weights: literal = 3, `:param` = 2,\n * `*` = 1, `**` and empty segments contribute 0. Declaration order is the\n * tiebreak when two patterns score equal — enforced by the caller, not\n * here.\n *\n * Total-sum scoring matches React Router 7's general spirit: static\n * segments dominate, parameters outrank single-segment wildcards, and\n * `**` is the catchall fallback that only wins when nothing else matches.\n */\nexport function routeSpecificity(route: string): number {\n // The root route \"/\" is a literal match for exactly one URL and is more\n // specific than any wildcard-only pattern (e.g. \"/**\" scores 0).\n if (route === \"/\") return 1;\n let total = 0;\n for (const seg of route.split(\"/\")) {\n if (seg === \"\" || seg === \"**\") continue;\n if (seg === \"*\") total += 1;\n else if (seg.startsWith(\":\")) total += 2;\n else total += 3;\n }\n return total;\n}\n\nfunction matchSegs(pattern: string[], url: string[]): boolean {\n if (pattern.length === 0 && url.length === 0) return true;\n if (pattern.length === 0) return false;\n\n const head = pattern[0]!;\n const rest = pattern.slice(1);\n\n if (head === \"**\") {\n // Match zero or more segments.\n if (rest.length === 0) return true;\n for (let i = 0; i <= url.length; i++) {\n if (matchSegs(rest, url.slice(i))) return true;\n }\n return false;\n }\n\n if (url.length === 0) return false;\n if (head === \"*\" || head === url[0]) {\n return matchSegs(rest, url.slice(1));\n }\n return false;\n}\n","import type {\n Sightmap,\n MatchResult,\n ExplainHit,\n ResolvedView,\n ResolvedComponent,\n ResolvedRequest,\n} from \"./sightmap.js\";\nimport type { View, Component, Request } from \"./types.js\";\nimport { routeMatch, routeSpecificity } from \"./routeMatch.js\";\n\nexport function resolveByUrl(\n sightmap: Sightmap,\n url: string,\n method?: string,\n): MatchResult {\n // Most-specific match wins; declaration order tiebreaks equal specificity.\n // Strict `>` keeps the earlier-declared view on ties (declaration order =\n // the order views appear in `sightmap.views`, which is `merge.ts`'s\n // sourceFile-sorted view list).\n let matchedView: View | null = null;\n let bestScore = -1;\n for (const v of sightmap.views) {\n if (!routeMatch(v.route, url)) continue;\n // routeSpecificity expects the raw route string (preserves `:param` segments).\n const score = routeSpecificity(v.route);\n if (score > bestScore) {\n bestScore = score;\n matchedView = v;\n }\n }\n\n const components: ResolvedComponent[] = [];\n for (const c of sightmap.globalComponents) {\n components.push(...flattenComponent(c, [], \"global\", undefined));\n }\n if (matchedView !== null && Array.isArray(matchedView.components)) {\n for (const c of matchedView.components) {\n components.push(...flattenComponent(c, [], \"view-scoped\", matchedView.name));\n }\n }\n\n const requests: ResolvedRequest[] = [];\n const requestPool: Request[] = [\n ...sightmap.globalRequests,\n ...((matchedView?.requests ?? [])),\n ];\n for (const req of requestPool) {\n if (!routeMatch(req.route, url)) continue;\n if (method !== undefined && req.method !== undefined && req.method !== method) continue;\n requests.push(toResolvedRequest(req));\n }\n\n const memory: string[] = [];\n for (const fm of sightmap.fileMemory) memory.push(...fm.memory);\n if (matchedView?.memory) memory.push(...matchedView.memory);\n\n return {\n view: matchedView !== null ? toResolvedView(matchedView) : null,\n components,\n requests,\n memory,\n };\n}\n\nexport function resolveByName(sightmap: Sightmap, name: string): ExplainHit[] {\n const hits: ExplainHit[] = [];\n for (const v of sightmap.views) {\n if (v.name === name) hits.push({ type: \"view\", matchedAs: \"name\", entry: toResolvedView(v) });\n }\n for (const c of sightmap.globalComponents) {\n for (const rc of flattenComponent(c, [], \"global\", undefined)) {\n if (rc.name === name) hits.push({ type: \"component\", matchedAs: \"name\", entry: rc });\n }\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n for (const rc of flattenComponent(c, [], \"view-scoped\", v.name)) {\n if (rc.name === name) hits.push({ type: \"component\", matchedAs: \"name\", entry: rc });\n }\n }\n }\n for (const r of sightmap.globalRequests) {\n if (r.name === name) hits.push({ type: \"request\", matchedAs: \"name\", entry: toResolvedRequest(r) });\n }\n for (const v of sightmap.views) {\n for (const r of v.requests ?? []) {\n if (r.name === name) hits.push({ type: \"request\", matchedAs: \"name\", entry: toResolvedRequest(r) });\n }\n }\n return hits;\n}\n\nexport function resolveBySourcePath(sightmap: Sightmap, path: string): ExplainHit[] {\n const hits: ExplainHit[] = [];\n for (const v of sightmap.views) {\n if (v.source === path) hits.push({ type: \"view\", matchedAs: \"path\", entry: toResolvedView(v) });\n }\n for (const c of sightmap.globalComponents) {\n for (const rc of flattenComponent(c, [], \"global\", undefined)) {\n if (rc.source === path) hits.push({ type: \"component\", matchedAs: \"path\", entry: rc });\n }\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n for (const rc of flattenComponent(c, [], \"view-scoped\", v.name)) {\n if (rc.source === path) hits.push({ type: \"component\", matchedAs: \"path\", entry: rc });\n }\n }\n }\n for (const r of sightmap.globalRequests) {\n if (r.source === path) hits.push({ type: \"request\", matchedAs: \"path\", entry: toResolvedRequest(r) });\n }\n return hits;\n}\n\nfunction flattenComponent(\n c: Component,\n parentChain: string[],\n scope: \"global\" | \"view-scoped\",\n scopedToView: string | undefined,\n): ResolvedComponent[] {\n const out: ResolvedComponent[] = [];\n const selector = Array.isArray(c.selector) ? c.selector : [c.selector as unknown as string];\n out.push({\n name: c.name,\n selector,\n ...(c.source !== undefined ? { source: c.source } : {}),\n ...(c.description !== undefined ? { description: c.description } : {}),\n memory: c.memory ? [...c.memory] : [],\n parentChain: [...parentChain],\n scope,\n ...(scopedToView !== undefined ? { scopedToView } : {}),\n definedIn: { file: \"<unknown>\" },\n });\n for (const child of c.children ?? []) {\n out.push(...flattenComponent(child, [...parentChain, c.name], scope, scopedToView));\n }\n return out;\n}\n\nfunction toResolvedView(v: View): ResolvedView {\n return {\n name: v.name,\n route: v.route,\n ...(v.source !== undefined ? { source: v.source } : {}),\n ...(v.description !== undefined ? { description: v.description } : {}),\n memory: v.memory ? [...v.memory] : [],\n definedIn: { file: \"<unknown>\" },\n };\n}\n\nfunction toResolvedRequest(r: Request): ResolvedRequest {\n return {\n name: r.name,\n route: r.route,\n ...(r.method !== undefined ? { method: r.method } : {}),\n ...(r.source !== undefined ? { source: r.source } : {}),\n ...(r.description !== undefined ? { description: r.description } : {}),\n ...(r.request !== undefined ? { request: { fields: r.request.fields ?? [] } } : {}),\n ...(r.response !== undefined ? { response: { fields: r.response.fields ?? [] } } : {}),\n ...(r.headers !== undefined ? { headers: r.headers } : {}),\n memory: r.memory ? [...r.memory] : [],\n definedIn: { file: \"<unknown>\" },\n };\n}\n","import type { Sightmap, MatchResult } from \"./sightmap.js\";\nimport { resolveByUrl } from \"./resolver.js\";\n\nexport interface MatchOptions {\n url: string;\n method?: string;\n}\n\nexport function match(sightmap: Sightmap, opts: MatchOptions): MatchResult {\n return resolveByUrl(sightmap, opts.url, opts.method);\n}\n","import type { Sightmap, ExplainResult, ExplainHit, ExplainMatchedAs } from \"./sightmap.js\";\nimport { resolveByName, resolveBySourcePath } from \"./resolver.js\";\n\nexport interface ExplainOptions {\n by?: \"name\" | \"path\";\n type?: \"view\" | \"component\" | \"request\";\n}\n\nexport function explain(\n sightmap: Sightmap,\n query: string,\n opts: ExplainOptions = {},\n): ExplainResult {\n const byName = opts.by === \"path\" ? [] : resolveByName(sightmap, query);\n const byPath = opts.by === \"name\" ? [] : resolveBySourcePath(sightmap, query);\n\n // Merge: when an entry appears in both lookups, label as \"name-and-path\".\n // Use entry identity (type + name) as the dedup key.\n const key = (h: ExplainHit): string => `${h.type}:${h.entry.name}`;\n const namedKeys = new Set(byName.map(key));\n const pathKeys = new Set(byPath.map(key));\n\n const merged: ExplainHit[] = [];\n for (const h of byName) {\n if (pathKeys.has(key(h))) {\n merged.push(withMatchedAs(h, \"name-and-path\"));\n } else {\n merged.push(h);\n }\n }\n for (const h of byPath) {\n if (!namedKeys.has(key(h))) {\n merged.push(h);\n }\n // (entries already in both have been pushed above with \"name-and-path\".)\n }\n\n const filtered =\n opts.type !== undefined ? merged.filter((h) => h.type === opts.type) : merged;\n return { query, hits: filtered };\n}\n\nfunction withMatchedAs(h: ExplainHit, matchedAs: ExplainMatchedAs): ExplainHit {\n switch (h.type) {\n case \"view\":\n return { type: \"view\", matchedAs, entry: h.entry };\n case \"component\":\n return { type: \"component\", matchedAs, entry: h.entry };\n case \"request\":\n return { type: \"request\", matchedAs, entry: h.entry };\n }\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { DUPLICATE_VIEW_NAME, type Diagnostic } from \"../diagnostics.js\";\n\nexport function duplicateName(sightmap: Sightmap): Diagnostic[] {\n const seen = new Map<string, number>();\n const out: Diagnostic[] = [];\n sightmap.views.forEach((v) => {\n const count = (seen.get(v.name) ?? 0) + 1;\n seen.set(v.name, count);\n if (count > 1) {\n out.push({\n severity: \"warning\",\n code: DUPLICATE_VIEW_NAME,\n message: `Duplicate view name \"${v.name}\" (occurrence ${count}).`,\n });\n }\n });\n return out;\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { DUPLICATE_ROUTE, type Diagnostic } from \"../diagnostics.js\";\n\nexport function duplicateRoute(sightmap: Sightmap): Diagnostic[] {\n const seen = new Map<string, string>(); // route → first-view-name\n const out: Diagnostic[] = [];\n for (const v of sightmap.views) {\n const prev = seen.get(v.route);\n if (prev !== undefined) {\n out.push({\n severity: \"warning\",\n code: DUPLICATE_ROUTE,\n message: `Route \"${v.route}\" is defined by both \"${prev}\" and \"${v.name}\". Only \"${prev}\" will match.`,\n });\n } else {\n seen.set(v.route, v.name);\n }\n }\n return out;\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { ROUTE_SHADOWING, type Diagnostic } from \"../diagnostics.js\";\nimport { routeSpecificity } from \"../routeMatch.js\";\n\n/**\n * Detect routes made unreachable under sightmap's matcher rules.\n *\n * `resolveByUrl` picks the most specific matching view, with declaration\n * order as the tiebreak when two patterns score equal. So a wildcard like\n * `/*` does not shadow a more specific route like `/login`, regardless of\n * declaration order. A route B is truly shadowed by an earlier route A only\n * when:\n *\n * 1. A and B match the exact same set of URLs (same shape; `*` and `:param`\n * are treated as equivalent placeholders here, since both match a single\n * arbitrary segment), AND\n * 2. A is at least as specific as B. When scores tie, the earlier-declared\n * route wins via the tiebreak, leaving B unreachable.\n */\nexport function routeShadowing(sightmap: Sightmap): Diagnostic[] {\n const out: Diagnostic[] = [];\n const views = sightmap.views;\n for (let j = 1; j < views.length; j++) {\n const later = views[j]!;\n const laterKey = matchSetKey(later.route);\n const laterScore = routeSpecificity(later.route);\n for (let i = 0; i < j; i++) {\n const earlier = views[i]!;\n if (earlier.route === later.route) continue; // duplicate-route covers this\n if (matchSetKey(earlier.route) !== laterKey) continue;\n if (routeSpecificity(earlier.route) < laterScore) continue;\n out.push({\n severity: \"warning\",\n code: ROUTE_SHADOWING,\n message: `Route \"${later.route}\" (view \"${later.name}\") is shadowed by earlier route \"${earlier.route}\" (view \"${earlier.name}\"); they match the same URLs and the earlier route is at least as specific, making this route unreachable.`,\n });\n break; // only report the first shadower\n }\n }\n return out;\n}\n\n/**\n * Canonical \"match-set\" key for a pattern: literal segments are kept; `:param`\n * is normalized to `*` (both match exactly one arbitrary segment); `**` is\n * preserved (variable-depth). Two patterns with the same key match the same\n * set of URLs under the spec's matching rules.\n */\nfunction matchSetKey(route: string): string {\n return route\n .split(\"/\")\n .map((seg) => (seg.startsWith(\":\") ? \"*\" : seg))\n .join(\"/\");\n}\n\n","import { stat } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\nimport { UNKNOWN_SOURCE, type Diagnostic } from \"../diagnostics.js\";\n\nexport interface UnknownSourceOptions {\n /** Filesystem root for resolving `source:` paths. Defaults to process.cwd(). */\n root?: string;\n}\n\nexport async function unknownSource(\n sightmap: Sightmap,\n opts: UnknownSourceOptions = {},\n): Promise<Diagnostic[]> {\n const root = opts.root ?? process.cwd();\n const out: Diagnostic[] = [];\n const seen = new Set<string>();\n\n const check = async (source: string | undefined, label: string): Promise<void> => {\n if (source === undefined) return;\n if (seen.has(source)) return;\n seen.add(source);\n try {\n await stat(resolve(root, source));\n } catch {\n out.push({\n severity: \"warning\",\n code: UNKNOWN_SOURCE,\n message: `${label}: source path \"${source}\" does not exist on disk (relative to ${root}).`,\n });\n }\n };\n\n for (const v of sightmap.views) {\n await check(v.source, `view \"${v.name}\"`);\n for (const c of v.components ?? []) {\n await walkComponent(c, `component \"${c.name}\"`, check);\n }\n }\n for (const c of sightmap.globalComponents) {\n await walkComponent(c, `component \"${c.name}\"`, check);\n }\n for (const r of sightmap.globalRequests) {\n await check(r.source, `request \"${r.name}\"`);\n }\n\n return out;\n}\n\nasync function walkComponent(\n c: Component,\n label: string,\n check: (source: string | undefined, label: string) => Promise<void>,\n): Promise<void> {\n await check(c.source, label);\n for (const child of c.children ?? []) {\n await walkComponent(child, `component \"${child.name}\"`, check);\n }\n}\n","import { parse as parseSelector } from \"css-what\";\nimport type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\nimport { SELECTOR_SYNTAX, type Diagnostic } from \"../diagnostics.js\";\n\nexport function selectorSyntax(sightmap: Sightmap): Diagnostic[] {\n const out: Diagnostic[] = [];\n const visit = (c: Component, scope: string): void => {\n const selectors: string[] = Array.isArray(c.selector)\n ? c.selector\n : [c.selector as unknown as string];\n selectors.forEach((sel, i) => {\n try {\n parseSelector(sel);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n out.push({\n severity: \"warning\",\n code: SELECTOR_SYNTAX,\n message: `${scope}: selector at index ${i} (\"${sel}\") failed to parse: ${msg}`,\n });\n }\n });\n for (const child of c.children ?? []) visit(child, `component \"${child.name}\"`);\n };\n\n for (const c of sightmap.globalComponents) visit(c, `component \"${c.name}\"`);\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) visit(c, `component \"${c.name}\"`);\n }\n return out;\n}\n","import type { Sightmap } from \"./sightmap.js\";\nimport type { Diagnostic } from \"./diagnostics.js\";\nimport { duplicateName } from \"./lintRules/duplicateName.js\";\nimport { duplicateRoute } from \"./lintRules/duplicateRoute.js\";\nimport { routeShadowing } from \"./lintRules/routeShadowing.js\";\nimport { unknownSource } from \"./lintRules/unknownSource.js\";\nimport { selectorSyntax } from \"./lintRules/selectorSyntax.js\";\n\nexport interface LintOptions {\n /** Per-rule enable/disable. Default: all rules enabled. */\n rules?: Record<string, boolean>;\n /** Filesystem root for `unknown-source`. Defaults to process.cwd(). */\n root?: string;\n}\n\nexport async function lint(sightmap: Sightmap, opts: LintOptions = {}): Promise<Diagnostic[]> {\n const enabled = (code: string): boolean => opts.rules?.[code] !== false;\n const out: Diagnostic[] = [];\n if (enabled(\"duplicate-view-name\")) out.push(...duplicateName(sightmap));\n if (enabled(\"duplicate-route\")) out.push(...duplicateRoute(sightmap));\n if (enabled(\"route-shadowing\")) out.push(...routeShadowing(sightmap));\n if (enabled(\"selector-syntax\")) out.push(...selectorSyntax(sightmap));\n if (enabled(\"unknown-source\")) {\n out.push(...(await unknownSource(sightmap, opts.root !== undefined ? { root: opts.root } : {})));\n }\n return out;\n}\n","// Canonical YAML writer for sightmap documents.\n//\n// Takes a value-shaped sightmap (the same shape `parse()` returns, minus the\n// internal `__brand` / `__sourceFile` markers, or any plain `SightmapV1`\n// object) and emits canonical YAML:\n//\n// * Top-level keys are emitted in spec order: version, memory, views,\n// components, requests. Unknown keys come last in input order.\n// * Block style throughout (no flow mapping/sequence collapse).\n// * Selector arrays single-quote strings that contain reserved chars (per\n// YAML's default quoting), so `[data-sightmap=\"X\"]` reads as\n// `'[data-sightmap=\"X\"]'`.\n// * Output ends with a single trailing newline.\n//\n// The writer is value-based: it does not preserve user comments or original\n// key ordering. Comment-preserving rewrites belong in\n// `@sightmap/react`'s smart-merge (codegen path), not here.\n\nimport { stringify } from \"yaml\";\nimport type { SightmapV1 } from \"../types.js\";\nimport { TOP_LEVEL_KEY_ORDER } from \"./canonical-rules.js\";\n\n/**\n * Input shape for `format`: the value-side of `SightmapV1` plus any\n * forward-compat unknown keys we should pass through.\n */\nexport type FormatInput = SightmapV1 & Record<string, unknown>;\n\nexport function format(input: FormatInput): string {\n const ordered: Record<string, unknown> = {};\n for (const key of TOP_LEVEL_KEY_ORDER) {\n if ((input as Record<string, unknown>)[key] !== undefined) {\n ordered[key] = (input as Record<string, unknown>)[key];\n }\n }\n for (const key of Object.keys(input)) {\n if (key.startsWith(\"__\")) continue; // drop SightmapFragment internal markers\n if (!(key in ordered)) ordered[key] = input[key];\n }\n\n const yaml = stringify(ordered, {\n indent: 2,\n lineWidth: 0,\n minContentWidth: 0,\n });\n\n return yaml.endsWith(\"\\n\") ? yaml : yaml + \"\\n\";\n}\n","// Shared canonical-form constants and comparators used by both the value-based\n// format() writer and the CST-preserving canonicalize() writer.\n//\n// Source of truth for the spec rules in\n// sightmap/spec docs/authoring-conventions.md#canonical-formatting-rules.\n\nexport const TOP_LEVEL_KEY_ORDER = [\n \"version\",\n \"memory\",\n \"views\",\n \"components\",\n \"requests\",\n] as const;\n\nexport const VIEW_KEY_ORDER = [\n \"name\",\n \"route\",\n \"description\",\n \"components\",\n \"memory\",\n \"requests\",\n] as const;\n\nexport const COMPONENT_KEY_ORDER = [\n \"name\",\n \"selector\",\n \"description\",\n \"children\",\n \"memory\",\n] as const;\n\n// Schema-derived order. The spec's authoring-conventions doc table lists\n// `method, url, description, memory` for Request — that table is stale\n// relative to the JSON Schema, which has `name, route, method, description,\n// source, request, response, headers, memory` (no `url` field exists). The\n// schema is the source of truth tools enforce; we follow it here.\nexport const REQUEST_KEY_ORDER = [\n \"name\",\n \"route\",\n \"method\",\n \"description\",\n \"source\",\n \"request\",\n \"response\",\n \"headers\",\n \"memory\",\n] as const;\n\n// Lexicographic byte-by-byte comparison on YAML scalar strings.\n// No Unicode normalization, no case folding (per spec).\nexport function compareByName(a: { name: string }, b: { name: string }): number {\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;\n}\n\n// Sort requests by (route, method). Spec doc says (url, method) but `url`\n// is not a real field — see REQUEST_KEY_ORDER comment above.\n// `method?: string | undefined` (rather than `method?: string`) so callers\n// can pass through optional-or-undefined extractions without spreading.\nexport function compareRequests(\n a: { route: string; method?: string | undefined },\n b: { route: string; method?: string | undefined },\n): number {\n if (a.route !== b.route) return a.route < b.route ? -1 : 1;\n const am = a.method ?? \"\";\n const bm = b.method ?? \"\";\n return am < bm ? -1 : am > bm ? 1 : 0;\n}\n","// CST-preserving canonical YAML writer. Backs `sightmap fmt`.\n//\n// See sightmap/spec docs/authoring-conventions.md#canonical-formatting-rules\n// for the normative rules this implements.\n\nimport { parseDocument, isMap, isSeq, isScalar, type Document, type YAMLMap, type YAMLSeq, type Pair, type Scalar } from \"yaml\";\nimport { validate } from \"../validate.js\";\nimport {\n FMT_PARSE_ERROR,\n FMT_SCHEMA_INVALID,\n type Diagnostic,\n} from \"../diagnostics.js\";\nimport {\n TOP_LEVEL_KEY_ORDER,\n VIEW_KEY_ORDER,\n COMPONENT_KEY_ORDER,\n REQUEST_KEY_ORDER,\n compareByName,\n compareRequests,\n} from \"./canonical-rules.js\";\n\nexport type CanonicalizeResult =\n | { kind: \"canonical\"; text: string; changed: boolean }\n | { kind: \"parse-error\"; diagnostics: Diagnostic[] }\n | { kind: \"schema-invalid\"; diagnostics: Diagnostic[] };\n\nexport interface CanonicalizeOptions {\n /** Source-file path for diagnostics (relative to cwd, typically). */\n file: string;\n}\n\nexport function canonicalize(input: string, opts: CanonicalizeOptions): CanonicalizeResult {\n const doc = parseDocument(input, { keepSourceTokens: false });\n\n const first = doc.errors[0];\n if (first !== undefined) {\n const loc = first.linePos?.[0]\n ? { line: first.linePos[0].line, column: first.linePos[0].col }\n : undefined;\n return {\n kind: \"parse-error\",\n diagnostics: [\n {\n severity: \"error\",\n code: FMT_PARSE_ERROR,\n message: first.message,\n file: opts.file,\n ...(loc !== undefined ? { loc } : {}),\n },\n ],\n };\n }\n\n const v = validate(input, { sourceFile: opts.file });\n if (!v.ok) {\n // Re-code the validate diagnostics under fmt.schema-invalid; preserve\n // message/loc but normalize severity to error and overwrite the code.\n const diagnostics: Diagnostic[] = v.diagnostics.map((d) => ({\n ...d,\n severity: \"error\" as const,\n code: FMT_SCHEMA_INVALID,\n file: opts.file,\n }));\n return { kind: \"schema-invalid\", diagnostics };\n }\n\n // Mutation passes (only run when input parses + validates).\n if (isMap(doc.contents)) {\n reorderTopLevelKeys(doc.contents);\n reorderEntriesUnder(doc.contents, \"views\", VIEW_KEY_ORDER);\n reorderEntriesUnder(doc.contents, \"components\", COMPONENT_KEY_ORDER);\n reorderEntriesUnder(doc.contents, \"requests\", REQUEST_KEY_ORDER);\n // Per-spec: nested seqs (view.components, view.requests) also follow per-entry-type key order.\n forEachViewEntry(doc.contents, (view) => {\n reorderEntriesUnder(view, \"components\", COMPONENT_KEY_ORDER);\n reorderEntriesUnder(view, \"requests\", REQUEST_KEY_ORDER);\n forEachComponentEntry(view, \"components\", (cmp) => {\n reorderChildrenRecursive(cmp);\n });\n });\n forEachComponentEntry(doc.contents, \"components\", (cmp) => {\n reorderChildrenRecursive(cmp);\n });\n sortTopLevelSeq(doc.contents, \"views\", (a, b) => {\n const an = scalarPropFromMapItem(a, \"name\");\n const bn = scalarPropFromMapItem(b, \"name\");\n return compareByName({ name: an ?? \"\" }, { name: bn ?? \"\" });\n });\n sortTopLevelSeq(doc.contents, \"components\", (a, b) => {\n const an = scalarPropFromMapItem(a, \"name\");\n const bn = scalarPropFromMapItem(b, \"name\");\n return compareByName({ name: an ?? \"\" }, { name: bn ?? \"\" });\n });\n sortTopLevelSeq(doc.contents, \"requests\", (a, b) => {\n return compareRequests(\n { route: scalarPropFromMapItem(a, \"route\") ?? \"\", method: scalarPropFromMapItem(a, \"method\") },\n { route: scalarPropFromMapItem(b, \"route\") ?? \"\", method: scalarPropFromMapItem(b, \"method\") },\n );\n });\n visitAllScalars(doc, (scalar) => {\n if (typeof scalar.value !== \"string\") return;\n scalar.type = chooseQuoteType(scalar.value);\n });\n normalizeBlankLines(doc);\n }\n\n const output = serialize(doc);\n return { kind: \"canonical\", text: output, changed: output !== input };\n}\n\nfunction reorderTopLevelKeys(map: YAMLMap): void {\n reorderMapKeys(map, TOP_LEVEL_KEY_ORDER);\n}\n\nfunction reorderMapKeys(map: YAMLMap, keyOrder: readonly string[]): void {\n const items = map.items as Pair[];\n const byKey = new Map<string, Pair>();\n const unknownInOrder: Pair[] = [];\n for (const item of items) {\n const key = scalarKey(item);\n if (key === null) {\n unknownInOrder.push(item);\n continue;\n }\n if (keyOrder.includes(key)) {\n byKey.set(key, item);\n } else {\n unknownInOrder.push(item);\n }\n }\n const reordered: Pair[] = [];\n for (const k of keyOrder) {\n const p = byKey.get(k);\n if (p !== undefined) reordered.push(p);\n }\n reordered.push(...unknownInOrder);\n map.items = reordered;\n}\n\nfunction reorderEntriesUnder(map: YAMLMap, key: string, keyOrder: readonly string[]): void {\n const seq = lookupSeq(map, key);\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) reorderMapKeys(item, keyOrder);\n }\n}\n\nfunction forEachViewEntry(root: YAMLMap, fn: (view: YAMLMap) => void): void {\n const seq = lookupSeq(root, \"views\");\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) fn(item);\n }\n}\n\nfunction forEachComponentEntry(root: YAMLMap, key: string, fn: (cmp: YAMLMap) => void): void {\n const seq = lookupSeq(root, key);\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) fn(item);\n }\n}\n\nfunction reorderChildrenRecursive(cmp: YAMLMap): void {\n const children = lookupSeq(cmp, \"children\");\n if (children === null) return;\n for (const child of children.items) {\n if (!isMap(child)) continue;\n reorderMapKeys(child, COMPONENT_KEY_ORDER);\n reorderChildrenRecursive(child);\n }\n}\n\nfunction lookupSeq(map: YAMLMap, key: string): YAMLSeq | null {\n for (const item of map.items as Pair[]) {\n if (scalarKey(item) === key && isSeq(item.value)) return item.value;\n }\n return null;\n}\n\nfunction scalarKey(pair: Pair): string | null {\n // Pair.key may be a Scalar node or a raw value depending on parse path.\n const k = (pair.key as { value?: unknown }) ?? null;\n if (k === null) return null;\n const v = typeof k === \"object\" && k !== null && \"value\" in k ? k.value : k;\n return typeof v === \"string\" ? v : null;\n}\n\nfunction sortTopLevelSeq(\n root: YAMLMap,\n key: string,\n cmp: (a: unknown, b: unknown) => number,\n): void {\n const seq = lookupSeq(root, key);\n if (seq === null) return;\n // Array.prototype.sort is stable in V8/JSC since 2019.\n seq.items = (seq.items as unknown[]).slice().sort(cmp);\n}\n\nfunction scalarPropFromMapItem(item: unknown, key: string): string | undefined {\n if (!isMap(item)) return undefined;\n for (const pair of item.items as Pair[]) {\n if (scalarKey(pair) !== key) continue;\n const v = pair.value as { value?: unknown } | unknown;\n if (v !== null && typeof v === \"object\" && \"value\" in (v as object)) {\n const inner = (v as { value: unknown }).value;\n return typeof inner === \"string\" ? inner : undefined;\n }\n return typeof v === \"string\" ? v : undefined;\n }\n return undefined;\n}\n\nfunction visitAllScalars(doc: Document, fn: (scalar: Scalar) => void): void {\n walk(doc.contents, fn);\n}\n\nfunction walk(node: unknown, fn: (scalar: Scalar) => void): void {\n if (node === null || node === undefined) return;\n if (isScalar(node)) {\n fn(node);\n return;\n }\n if (isMap(node)) {\n for (const pair of node.items as Pair[]) {\n walk(pair.key, fn);\n walk(pair.value, fn);\n }\n return;\n }\n if (isSeq(node)) {\n for (const item of node.items) walk(item, fn);\n }\n}\n\nfunction normalizeBlankLines(doc: Document): void {\n const root = doc.contents;\n if (!isMap(root)) return;\n\n // HEADER blank-line normalization: emit exactly one blank line between a\n // leading comment block (HEADER) and the first content. Per spec: if no\n // HEADER, no leading blank.\n //\n // eemeli/yaml attaches a leading `# foo` block to the first Pair's *key*\n // (`firstPair.key.commentBefore`), not to `doc.commentBefore`. Setting\n // `spaceBefore` on the key produces a blank BEFORE the comment (wrong);\n // setting it on the Pair has no effect while the comment lives on the key.\n // Workaround: lift the key's commentBefore up to `doc.commentBefore`, clear\n // it on the key, then set `spaceBefore = true` on the first Pair so the\n // serializer emits the desired `<header>\\n\\n<content>` shape.\n const firstPair = (root.items as Pair[])[0];\n if (firstPair !== undefined) {\n const keyNode = firstPair.key as { commentBefore?: string | null } | null;\n const docMutable = doc as { commentBefore?: string | null };\n const keyComment = keyNode?.commentBefore;\n const docComment = docMutable.commentBefore;\n if (typeof keyComment === \"string\" && keyComment.length > 0) {\n docMutable.commentBefore = keyComment;\n keyNode!.commentBefore = null;\n }\n const hasHeader =\n (typeof docMutable.commentBefore === \"string\" && docMutable.commentBefore.length > 0) ||\n (typeof docComment === \"string\" && docComment.length > 0);\n (firstPair as { spaceBefore?: boolean }).spaceBefore = hasHeader;\n }\n\n for (const key of [\"views\", \"components\", \"requests\"] as const) {\n const seq = lookupSeq(root, key);\n if (seq === null) continue;\n seq.items.forEach((item, idx) => {\n // Items at the top level of these seqs get a blank line before them\n // (except the first item). spaceBefore may not be pre-set; assign directly.\n if (typeof item === \"object\" && item !== null) {\n (item as { spaceBefore: boolean }).spaceBefore = idx > 0;\n }\n });\n // Recurse into nested entries to clear any blank lines within an entry's body.\n for (const item of seq.items) {\n if (isMap(item)) clearInnerBlankLines(item);\n }\n }\n}\n\nfunction clearInnerBlankLines(map: YAMLMap): void {\n for (const pair of map.items as Pair[]) {\n (pair as { spaceBefore?: boolean }).spaceBefore = false;\n if (isSeq(pair.value)) {\n for (const item of (pair.value as YAMLSeq).items) {\n if (typeof item === \"object\" && item !== null) {\n (item as { spaceBefore?: boolean }).spaceBefore = false;\n }\n if (isMap(item)) clearInnerBlankLines(item);\n }\n } else if (isMap(pair.value)) {\n clearInnerBlankLines(pair.value);\n }\n }\n}\n\n// Quote-type selection per sightmap/spec authoring-conventions.md#quoting.\nfunction chooseQuoteType(value: string): Scalar.Type {\n if (requiresDoubleQuotes(value)) return \"QUOTE_DOUBLE\";\n if (value.includes('\"')) return \"QUOTE_SINGLE\";\n if (isPlainSafe(value)) return \"PLAIN\";\n return \"QUOTE_SINGLE\";\n}\n\nfunction requiresDoubleQuotes(s: string): boolean {\n // Any ASCII control character (\\x00-\\x1f) requires double-quoted escaping.\n // Includes tab, newline, CR, which canonical form encodes via \\t / \\n / \\r\n // escapes to keep one-line representation (spec: \"Long strings stay on one\n // line. Do not wrap.\").\n // eslint-disable-next-line no-control-regex\n return /[\\x00-\\x1f]/.test(s);\n}\n\nfunction isPlainSafe(s: string): boolean {\n if (s.length === 0) return false;\n // Leading character restrictions per YAML 1.2 plain scalar rules.\n const first = s[0]!;\n if (\"-?:,[]{}#&*!|>'\\\"%@`\".includes(first)) return false;\n if (first === \" \" || first === \"\\t\") return false;\n // Sequences that change parse semantics anywhere in the string.\n if (s.includes(\": \")) return false;\n if (s.includes(\" #\")) return false;\n // Reserved YAML true/false/null/numeric forms.\n if (/^(true|false|null|~|y|n|yes|no|on|off|True|False|Null|Yes|No|On|Off|TRUE|FALSE|NULL|YES|NO|ON|OFF)$/.test(s)) return false;\n if (/^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/.test(s)) return false;\n if (/^0[xob]/.test(s)) return false;\n return true;\n}\n\nfunction serialize(doc: Document): string {\n const out = doc.toString({\n indent: 2,\n lineWidth: 0,\n minContentWidth: 0,\n blockQuote: \"literal\",\n });\n return out.endsWith(\"\\n\") ? out : out + \"\\n\";\n}\n","import { match as sightmapMatch } from \"../match.js\";\nimport type { Sightmap } from \"../sightmap.js\";\n\nexport interface BoundingRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * What an engine adapter's in-page evaluate returns for each sightmap\n * component. matchCount is the number of DOM elements matched (after\n * dedup); samplePosition is the bounding rect of the first match.\n *\n * Engine adapters produce this shape from their own browser-evaluate\n * mechanism; the kernel does not care how.\n */\nexport interface InPageSightmapMatch {\n name: string;\n selector: string[];\n matchCount: number;\n samplePosition?: BoundingRect | undefined;\n}\n\nexport interface EnrichSnapshotInput {\n sightmap: Sightmap;\n currentUrl: string;\n inPageMatches: InPageSightmapMatch[];\n}\n\nexport interface SightmapSnapshotComponent {\n name: string;\n selector: string[];\n memory: string[];\n scope: \"global\" | \"view-scoped\";\n matchCount: number;\n samplePosition?: BoundingRect | undefined;\n}\n\nexport interface EnrichedSnapshot {\n view: { name: string; route: string; memory: string[] } | null;\n components: SightmapSnapshotComponent[];\n memory: string[];\n}\n\n/**\n * Pure function: combines a sightmap, the agent's current URL, and the\n * in-page sightmap match results into an engine-agnostic enriched snapshot.\n *\n * Engine adapters typically wrap this and add their own passthrough fields\n * (e.g. @sightmap/mcp adds ariaSnapshot for the Playwright MCP a11y text).\n * The kernel never touches engine-specific text formats.\n */\nexport function enrichSnapshot(input: EnrichSnapshotInput): EnrichedSnapshot {\n const { sightmap, currentUrl, inPageMatches } = input;\n const result = sightmapMatch(sightmap, { url: currentUrl });\n\n const inPageByName = new Map<string, InPageSightmapMatch>();\n for (const m of inPageMatches) inPageByName.set(m.name, m);\n\n const components: SightmapSnapshotComponent[] = result.components.map((c) => {\n const inPage = inPageByName.get(c.name);\n return {\n name: c.name,\n selector: c.selector,\n memory: c.memory ?? [],\n scope: c.scope,\n matchCount: inPage?.matchCount ?? 0,\n ...(inPage?.samplePosition !== undefined\n ? { samplePosition: inPage.samplePosition }\n : {}),\n };\n });\n\n return {\n view: result.view\n ? {\n name: result.view.name,\n route: result.view.route,\n memory: result.view.memory ?? [],\n }\n : null,\n components,\n memory: result.memory ?? [],\n };\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\n\nexport interface ResolveSightmapActInput {\n componentName: string;\n}\n\nexport type ResolveSightmapActResult =\n | {\n kind: \"ok\";\n componentName: string;\n selector: string;\n allSelectors: string[];\n }\n | { kind: \"error\"; message: string };\n\n/**\n * Resolve a sightmap component by name to a CSS selector that an engine\n * adapter's action verb (click/type/hover/...) can use as the target.\n *\n * Lookup order:\n * 1. Global components (sightmap.globalComponents)\n * 2. View-scoped components, walking each view's components list\n *\n * The first selector in the matching component's selector array is\n * returned; additional selectors are exposed in allSelectors so callers\n * can fall back if the engine's first-selector resolution fails.\n */\nexport function resolveSightmapAct(\n sightmap: Sightmap,\n input: ResolveSightmapActInput,\n): ResolveSightmapActResult {\n const found = findComponentByName(sightmap, input.componentName);\n if (found === null) {\n return {\n kind: \"error\",\n message: `Component \"${input.componentName}\" not found in the loaded sightmap.`,\n };\n }\n\n const selectors = Array.isArray(found.selector) ? found.selector : [];\n if (selectors.length === 0) {\n return {\n kind: \"error\",\n message: `Component \"${input.componentName}\" has no selector — cannot dispatch an action.`,\n };\n }\n\n return {\n kind: \"ok\",\n componentName: input.componentName,\n selector: selectors[0]!,\n allSelectors: selectors,\n };\n}\n\nfunction findComponentByName(sightmap: Sightmap, name: string): Component | null {\n for (const c of sightmap.globalComponents) {\n if (c.name === name) return c;\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n if (c.name === name) return c;\n }\n }\n return null;\n}\n","import { match as sightmapMatch } from \"../match.js\";\nimport type { Sightmap } from \"../sightmap.js\";\n\nexport interface ParsedNetworkRequest {\n method: string;\n url: string;\n status: number;\n statusText: string;\n}\n\nexport interface AnnotatedNetworkRequest extends ParsedNetworkRequest {\n sightmapName?: string;\n sightmapMemory?: string[];\n}\n\n/**\n * Cross-reference each captured network request with sightmap's `requests:`\n * declarations. When a match is found, attaches the sightmap name + memory\n * to the response. Unmatched requests are returned unchanged.\n *\n * The `requests` input is already normalized; this function does not parse\n * any engine-specific text format. Engine adapters do their own parsing.\n */\nexport function annotateNetworkRequests(\n sightmap: Sightmap,\n requests: ParsedNetworkRequest[],\n): AnnotatedNetworkRequest[] {\n return requests.map((req) => {\n const result = sightmapMatch(sightmap, { url: req.url, method: req.method });\n const first = result.requests[0];\n if (first === undefined) return req;\n const annotated: AnnotatedNetworkRequest = { ...req, sightmapName: first.name };\n if (first.memory && first.memory.length > 0) {\n annotated.sightmapMemory = first.memory;\n }\n return annotated;\n });\n}\n","/**\n * Build the in-page evaluate function body. Embeds the component selectors\n * inline; the page only needs to query the DOM. No sightmap-js dependency\n * in the page context.\n *\n * Engine adapters serialize this string and pass it to their browser's\n * `evaluate` primitive (Playwright MCP's `browser_evaluate`, Playwright\n * CLI's `playwright-cli eval`, etc.). The output shape is\n * `{ url: string, matches: InPageSightmapMatch[] }` — adapters do their\n * own parsing of the engine's wrapping (e.g. Playwright MCP's\n * `### Result` framing).\n */\nexport function buildInPageEvalFunction(\n components: Array<{ name: string; selector: string[] }>,\n): string {\n const componentsJson = JSON.stringify(components);\n return `() => {\n const components = ${componentsJson};\n const matches = components.map((c) => {\n const selectors = c.selector || [];\n const seen = new Set();\n const elements = [];\n for (const sel of selectors) {\n try {\n const found = document.querySelectorAll(sel);\n for (const el of Array.from(found)) {\n if (!seen.has(el)) {\n seen.add(el);\n elements.push(el);\n }\n }\n } catch {\n // Invalid selector — skip silently.\n }\n }\n const first = elements[0];\n let samplePosition;\n if (first && typeof first.getBoundingClientRect === \"function\") {\n const r = first.getBoundingClientRect();\n samplePosition = { x: r.x, y: r.y, width: r.width, height: r.height };\n }\n return {\n name: c.name,\n selector: selectors,\n matchCount: elements.length,\n samplePosition,\n };\n });\n return { url: window.location.href, matches };\n }`;\n}\n"],"mappings":";AAAA,OAAO,UAAU;AAcV,SAAS,MAAM,OAAwB,OAAqB,CAAC,GAAqB;AACvF,MAAI;AACJ,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI;AACF,YAAM,KAAK,KAAK,KAAK;AAAA,IACvB,SAAS,KAAK;AACZ,YAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAM,IAAI,MAAM,qBAAqB,GAAG,EAAE;AAAA,IAC5C;AAAA,EACF,OAAO;AAEL,UAAM,EAAE,GAAG,MAAM;AAAA,EACnB;AAEA,MAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG;AACjE,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AAEA,QAAM,MAAM;AACZ,MAAI,IAAI,SAAS,MAAM,QAAW;AAChC,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AACA,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,UAAM,IAAI,MAAM,wBAAwB,OAAO,IAAI,SAAS,CAAC,CAAC,eAAe;AAAA,EAC/E;AAIA,MAAI,MAAM,QAAQ,IAAI,YAAY,CAAC,GAAG;AACpC,QAAI,YAAY,IAAK,IAAI,YAAY,EAAkB,IAAI,kBAAkB;AAAA,EAC/E;AACA,MAAI,MAAM,QAAQ,IAAI,OAAO,CAAC,GAAG;AAC/B,QAAI,OAAO,IAAK,IAAI,OAAO,EAAqC,IAAI,CAAC,MAAM;AACzE,YAAM,MAAM,EAAE,GAAG,EAAE;AACnB,UAAI,MAAM,QAAQ,IAAI,YAAY,CAAC,GAAG;AACpC,YAAI,YAAY,IAAK,IAAI,YAAY,EAAkB,IAAI,kBAAkB;AAAA,MAC/E;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QA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,QAAO;AAAA,EAC9B;AACA,aAAW,KAAK,SAAS,OAAO;AAC9B,eAAW,KAAK,EAAE,cAAc,CAAC,GAAG;AAClC,UAAI,EAAE,SAAS,KAAM,QAAO;AAAA,IAC9B;AAAA,EACF;AACA,SAAO;AACT;;;AC3CO,SAAS,wBACd,UACA,UAC2B;AAC3B,SAAO,SAAS,IAAI,CAAC,QAAQ;AAC3B,UAAM,SAAS,MAAc,UAAU,EAAE,KAAK,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC;AAC3E,UAAM,QAAQ,OAAO,SAAS,CAAC;AAC/B,QAAI,UAAU,OAAW,QAAO;AAChC,UAAM,YAAqC,EAAE,GAAG,KAAK,cAAc,MAAM,KAAK;AAC9E,QAAI,MAAM,UAAU,MAAM,OAAO,SAAS,GAAG;AAC3C,gBAAU,iBAAiB,MAAM;AAAA,IACnC;AACA,WAAO;AAAA,EACT,CAAC;AACH;;;ACzBO,SAAS,wBACd,YACQ;AACR,QAAM,iBAAiB,KAAK,UAAU,UAAU;AAChD,SAAO;AAAA,yBACgB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCvC;","names":["yaml","yaml","resolve","resolve","resolve","resolve","yaml"]}
1
+ {"version":3,"sources":["../src/parse.ts","../src/validate.ts","../src/diagnostics.ts","../src/merge.ts","../src/loadDirectory.ts","../src/routeMatch.ts","../src/resolver.ts","../src/match.ts","../src/explain.ts","../src/lintRules/duplicateName.ts","../src/lintRules/duplicateRoute.ts","../src/lintRules/routeShadowing.ts","../src/lintRules/unknownSource.ts","../src/lintRules/selectorSyntax.ts","../src/lint.ts","../src/format/index.ts","../src/format/canonical-rules.ts","../src/format/canonicalize.ts","../src/enrich/a11y/annotate.ts","../src/enrich/snapshot.ts","../src/enrich/act.ts","../src/enrich/network.ts","../src/enrich/in-page.ts"],"sourcesContent":["import yaml from \"js-yaml\";\nimport type { SightmapFragment } from \"./sightmap.js\";\nimport type { Component } from \"./types.js\";\n\nexport interface ParseOptions {\n /** Optional source file path; recorded on the fragment for canonical-order merging. */\n sourceFile?: string;\n}\n\n/**\n * Parse a single sightmap file (YAML string or pre-parsed object).\n * Throws on parse error, missing version, or version mismatch.\n * Normalizes `selector: string` to `selector: [string]` everywhere.\n */\nexport function parse(input: string | object, opts: ParseOptions = {}): SightmapFragment {\n let doc: unknown;\n if (typeof input === \"string\") {\n try {\n doc = yaml.load(input);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`YAML parse error: ${msg}`);\n }\n } else {\n // Shallow-clone caller's object so we don't mutate it.\n doc = { ...input };\n }\n\n if (doc === null || typeof doc !== \"object\" || Array.isArray(doc)) {\n throw new Error(\"Expected sightmap document to be an object at the root\");\n }\n\n const obj = doc as Record<string, unknown>;\n if (obj[\"version\"] === undefined) {\n throw new Error(\"Missing required `version` field\");\n }\n if (obj[\"version\"] !== 1) {\n throw new Error(`Unsupported version: ${String(obj[\"version\"])} (expected 1)`);\n }\n\n // Normalize selectors recursively. Spread each view to avoid mutating\n // shared view objects when the caller passed a pre-parsed input.\n if (Array.isArray(obj[\"components\"])) {\n obj[\"components\"] = (obj[\"components\"] as Component[]).map(normalizeComponent);\n }\n if (Array.isArray(obj[\"views\"])) {\n obj[\"views\"] = (obj[\"views\"] as Array<Record<string, unknown>>).map((v) => {\n const out = { ...v };\n if (Array.isArray(out[\"components\"])) {\n out[\"components\"] = (out[\"components\"] as Component[]).map(normalizeComponent);\n }\n return out;\n });\n }\n\n const fragment = {\n ...obj,\n __brand: \"SightmapFragment\" as const,\n ...(opts.sourceFile !== undefined ? { __sourceFile: opts.sourceFile } : {}),\n } as SightmapFragment;\n return fragment;\n}\n\nfunction normalizeComponent(c: Component): Component {\n // Common migration error: `selectors` (plural) instead of `selector` (singular).\n // The schema only accepts singular `selector`; the singular field already takes\n // a string or string-array, so a plural alias would be redundant. Surface\n // explicitly rather than silently dropping the value.\n if ((c as unknown as Record<string, unknown>)[\"selectors\"] !== undefined && c.selector === undefined) {\n const name = (c as { name?: string }).name ?? \"(unnamed)\";\n throw new Error(\n `Component \"${name}\": use \\`selector\\` (singular), not \\`selectors\\` (plural). ` +\n `\\`selector\\` accepts either a single string or an array of strings.`,\n );\n }\n const sel = c.selector;\n const normalized: Component = {\n ...c,\n selector: typeof sel === \"string\" ? [sel] : (sel as [string, ...string[]]),\n };\n if (Array.isArray(c.children)) {\n normalized.children = c.children.map(normalizeComponent);\n }\n return normalized;\n}\n","import yaml from \"js-yaml\";\nimport { Ajv2020 } from \"ajv/dist/2020.js\";\nimport type { ValidateResult, SightmapFragment } from \"./sightmap.js\";\nimport {\n PARSE_ERROR,\n SCHEMA_VALIDATION_FAILED,\n UNKNOWN_VERSION,\n type Diagnostic,\n} from \"./diagnostics.js\";\nimport { parse } from \"./parse.js\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { resolve, dirname } from \"node:path\";\n\n// Lazily initialized to avoid crashing when this module is bundled into a\n// browser context (fileURLToPath is Node-only). validate() itself is Node-only\n// and should never be called from browser code.\nlet _ajvValidate: ReturnType<InstanceType<typeof Ajv2020>[\"compile\"]> | undefined;\n\nfunction getValidator() {\n if (_ajvValidate) return _ajvValidate;\n // These Node APIs run only on first call to validate(), not at module load.\n const __dirname = dirname(fileURLToPath(import.meta.url));\n // Resolve the vendored schema in two contexts:\n // - Production (published package): bundled file lives at dist/index.js, schema at dist/vendored/.\n // - Dev (vitest, source files): validate.ts lives at src/, schema at ../vendored/.\n const schemaCandidates = [\n resolve(__dirname, \"./vendored/sightmap.schema.json\"),\n resolve(__dirname, \"../vendored/sightmap.schema.json\"),\n ];\n const schemaPath = schemaCandidates.find((p) => existsSync(p));\n if (schemaPath === undefined) {\n throw new Error(\n `vendored sightmap.schema.json not found. Looked in: ${schemaCandidates.join(\", \")}`,\n );\n }\n const schema = JSON.parse(readFileSync(schemaPath, \"utf8\")) as unknown;\n const ajv = new Ajv2020({ allErrors: true, strict: false });\n _ajvValidate = ajv.compile(schema as object);\n return _ajvValidate;\n}\n\nexport interface ValidateOptions {\n sourceFile?: string;\n}\n\nexport function validate(input: string | object, opts: ValidateOptions = {}): ValidateResult {\n const diagnostics: Diagnostic[] = [];\n let doc: unknown;\n\n if (typeof input === \"string\") {\n try {\n doc = yaml.load(input);\n } catch (err) {\n const e = err as { message?: string; mark?: { line?: number; column?: number } };\n diagnostics.push({\n severity: \"error\",\n code: PARSE_ERROR,\n message: e.message ?? \"YAML parse error\",\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n ...(e.mark\n ? { loc: { line: (e.mark.line ?? 0) + 1, column: (e.mark.column ?? 0) + 1 } }\n : {}),\n });\n return { ok: false, diagnostics };\n }\n } else {\n doc = input;\n }\n\n if (doc === null || typeof doc !== \"object\" || Array.isArray(doc)) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: \"Expected document root to be an object\",\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n });\n return { ok: false, diagnostics };\n }\n\n const obj = doc as Record<string, unknown>;\n if (obj[\"version\"] !== 1) {\n diagnostics.push({\n severity: \"error\",\n code: UNKNOWN_VERSION,\n message:\n obj[\"version\"] === undefined\n ? \"Missing required `version` field\"\n : `Unsupported version: ${String(obj[\"version\"])} (expected 1)`,\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n path: \"/version\",\n });\n return { ok: false, diagnostics };\n }\n\n const ajvValidate = getValidator();\n const ok = ajvValidate(obj);\n if (!ok) {\n for (const e of ajvValidate.errors ?? []) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: `${e.instancePath || \"(root)\"} ${e.message ?? \"\"}`.trim(),\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n ...(e.instancePath ? { path: e.instancePath } : {}),\n });\n }\n return { ok: false, diagnostics };\n }\n\n // Schema-valid: now run parse() (which normalizes selectors and brands).\n let value: SightmapFragment;\n try {\n value = parse(obj, opts.sourceFile !== undefined ? { sourceFile: opts.sourceFile } : {});\n } catch (err) {\n diagnostics.push({\n severity: \"error\",\n code: SCHEMA_VALIDATION_FAILED,\n message: err instanceof Error ? err.message : String(err),\n ...(opts.sourceFile !== undefined ? { file: opts.sourceFile } : {}),\n });\n return { ok: false, diagnostics };\n }\n return { ok: true, value };\n}\n","export type Severity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n severity: Severity;\n code: string;\n message: string;\n file?: string;\n path?: string;\n loc?: { line: number; column: number };\n source?: string;\n}\n\n// Stable, kebab-case codes. Renames require an SEP.\nexport const PARSE_ERROR = \"parse-error\";\nexport const SCHEMA_VALIDATION_FAILED = \"schema-validation-failed\";\nexport const UNKNOWN_VERSION = \"unknown-version\";\nexport const MERGE_COLLISION_VIEW = \"merge-collision-view\";\nexport const MERGE_COLLISION_COMPONENT = \"merge-collision-component\";\nexport const DUPLICATE_VIEW_NAME = \"duplicate-view-name\";\nexport const DUPLICATE_ROUTE = \"duplicate-route\";\nexport const ROUTE_SHADOWING = \"route-shadowing\";\nexport const UNKNOWN_SOURCE = \"unknown-source\";\nexport const SELECTOR_SYNTAX = \"selector-syntax\";\n\n// fmt CLI diagnostic codes (sightmap/spec docs/authoring-conventions.md#diagnostic-codes-authoring-side).\nexport const FMT_NOT_CANONICAL = \"fmt.not-canonical\";\nexport const FMT_PARSE_ERROR = \"fmt.parse-error\";\nexport const FMT_SCHEMA_INVALID = \"fmt.schema-invalid\";\n\n// Repo-conventions codes (WI-6). See docs/repo-conventions.md in the spec repo.\nexport const CONVENTION_SEP_FILENAME = \"convention.sep-filename\";\nexport const CONVENTION_FIXTURE_DIRNAME = \"convention.fixture-dirname\";\nexport const CONVENTION_INVALID_SLUG = \"convention.invalid-slug\";\nexport const CONVENTION_UNEXPECTED_FILE = \"convention.unexpected-file\";\n","import type { SightmapFragment, Sightmap } from \"./sightmap.js\";\nimport type { View, Component, Request } from \"./types.js\";\nimport {\n MERGE_COLLISION_VIEW,\n MERGE_COLLISION_COMPONENT,\n type Diagnostic,\n} from \"./diagnostics.js\";\n\n/**\n * Merge fragments into a queryable Sightmap.\n *\n * Canonical order: fragments are sorted by `__sourceFile` (code-point order; locale-independent\n * for cross-environment determinism). Fragments without a `__sourceFile` sort first, and ES2019\n * sort stability preserves their input order. Within each fragment, declaration order is\n * preserved. The merged collection's order = (sourceFile order, then declaration order).\n *\n * Duplicate view names produce `merge-collision-view` warnings; duplicate global component\n * names produce `merge-collision-component`. The first occurrence wins.\n *\n * Returned arrays are fresh, but element objects (View/Component/Request) are shared with\n * the input fragments — callers must not mutate them.\n */\nexport function merge(fragments: SightmapFragment[]): Sightmap {\n const sorted = [...fragments].sort((a, b) => {\n const aFile = a.__sourceFile ?? \"\";\n const bFile = b.__sourceFile ?? \"\";\n return aFile < bFile ? -1 : aFile > bFile ? 1 : 0;\n });\n\n const views: View[] = [];\n const globalComponents: Component[] = [];\n const globalRequests: Request[] = [];\n const fileMemory: { memory: string[]; sourceFile: string }[] = [];\n const diagnostics: Diagnostic[] = [];\n\n const seenViewNames = new Map<string, string>(); // name → sourceFile\n const seenComponentNames = new Map<string, string>();\n\n for (const f of sorted) {\n const file = f.__sourceFile ?? \"<unknown>\";\n\n for (const v of f.views ?? []) {\n const prev = seenViewNames.get(v.name);\n if (prev !== undefined) {\n diagnostics.push({\n severity: \"warning\",\n code: MERGE_COLLISION_VIEW,\n message: `View name \"${v.name}\" defined in both \"${prev}\" and \"${file}\"; first occurrence wins.`,\n file,\n });\n } else {\n seenViewNames.set(v.name, file);\n }\n views.push(v); // keep all views; resolveByUrl picks the most-specific match at query time\n }\n\n for (const c of f.components ?? []) {\n const prev = seenComponentNames.get(c.name);\n if (prev !== undefined) {\n diagnostics.push({\n severity: \"warning\",\n code: MERGE_COLLISION_COMPONENT,\n message: `Component name \"${c.name}\" defined in both \"${prev}\" and \"${file}\"; first occurrence wins.`,\n file,\n });\n } else {\n seenComponentNames.set(c.name, file);\n }\n globalComponents.push(c);\n }\n\n for (const r of f.requests ?? []) {\n globalRequests.push(r);\n }\n\n if (Array.isArray(f.memory) && f.memory.length > 0) {\n fileMemory.push({ memory: [...f.memory], sourceFile: file });\n }\n }\n\n return {\n version: 1,\n views,\n globalComponents,\n globalRequests,\n fileMemory,\n diagnostics,\n __brand: \"Sightmap\",\n };\n}\n","import { readFile, readdir } from \"node:fs/promises\";\nimport { join, extname, relative, resolve } from \"node:path\";\nimport { merge } from \"./merge.js\";\nimport { validate } from \"./validate.js\";\nimport type { Sightmap, SightmapFragment } from \"./sightmap.js\";\nimport type { Diagnostic } from \"./diagnostics.js\";\n\nexport interface LoadDirectoryOptions {\n /** Optional root for `file` fields in diagnostics. Default: the directory passed in. */\n diagnosticRoot?: string;\n}\n\n/**\n * Recursively load all *.yaml/*.yml files under `dir`, validate each, and merge.\n *\n * Files that fail validation contribute their diagnostics to the merged Sightmap's\n * `diagnostics` array but are otherwise skipped. This keeps loadDirectory total —\n * a single bad file doesn't abort the whole load.\n */\nexport async function loadDirectory(\n dir: string,\n opts: LoadDirectoryOptions = {},\n): Promise<Sightmap> {\n const absDir = resolve(dir);\n const root = opts.diagnosticRoot !== undefined ? resolve(opts.diagnosticRoot) : absDir;\n\n const files = await collectYamlFiles(absDir);\n files.sort(); // alphabetical canonical order\n\n const fragments: SightmapFragment[] = [];\n const loadDiagnostics: Diagnostic[] = [];\n\n for (const file of files) {\n const relPath = relative(root, file);\n const text = await readFile(file, \"utf8\");\n const r = validate(text, { sourceFile: relPath });\n if (r.ok) {\n fragments.push(r.value);\n } else {\n loadDiagnostics.push(...r.diagnostics);\n }\n }\n\n const merged = merge(fragments);\n return {\n ...merged,\n diagnostics: [...loadDiagnostics, ...merged.diagnostics],\n };\n}\n\nasync function collectYamlFiles(dir: string): Promise<string[]> {\n const out: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n for (const e of entries) {\n const p = join(dir, e.name);\n if (e.isDirectory()) {\n out.push(...(await collectYamlFiles(p)));\n } else if (e.isFile()) {\n const ext = extname(p).toLowerCase();\n if (ext === \".yaml\" || ext === \".yml\") out.push(p);\n }\n }\n return out;\n}\n","/**\n * Canonicalize a URL or pathname for matching.\n * - Accepts absolute URL or pathname.\n * - Strips scheme, host, query string, and fragment.\n * - Normalizes trailing slashes (except for the root \"/\").\n */\nexport function canonicalizeUrl(input: string): string {\n let s = input;\n // Strip absolute prefix.\n const protoMatch = /^[a-z][a-z0-9+.-]*:\\/\\/[^/]*/i.exec(s);\n if (protoMatch) {\n s = s.slice(protoMatch[0].length) || \"/\";\n }\n // Strip fragment.\n const hash = s.indexOf(\"#\");\n if (hash !== -1) s = s.slice(0, hash);\n // Strip query.\n const q = s.indexOf(\"?\");\n if (q !== -1) s = s.slice(0, q);\n // Trailing slash.\n if (s.length > 1 && s.endsWith(\"/\")) s = s.slice(0, -1);\n return s;\n}\n\n/**\n * Test whether a glob route pattern matches a URL pathname.\n * Pattern syntax (per spec):\n * - Literal segments match themselves\n * - \"*\" matches exactly one path segment\n * - \"**\" matches any depth of segments\n * - \":param\" segments normalize to \"*\"\n * - Matching is case-sensitive\n * - Trailing slashes ignored\n */\nexport function routeMatch(pattern: string, url: string): boolean {\n const p = normalizePattern(pattern);\n const u = canonicalizeUrl(url);\n const patternSegs = splitSegments(p);\n const urlSegs = splitSegments(u);\n return matchSegs(patternSegs, urlSegs);\n}\n\nfunction normalizePattern(p: string): string {\n // Replace \":param\" segments with \"*\"\n let s = p\n .split(\"/\")\n .map((seg) => (seg.startsWith(\":\") ? \"*\" : seg))\n .join(\"/\");\n if (s.length > 1 && s.endsWith(\"/\")) s = s.slice(0, -1);\n return s;\n}\n\nfunction splitSegments(path: string): string[] {\n if (path === \"/\" || path === \"\") return [];\n const trimmed = path.startsWith(\"/\") ? path.slice(1) : path;\n return trimmed.split(\"/\");\n}\n\n/**\n * Specificity score for a route pattern (higher = more specific).\n *\n * Used by the matcher to pick among multiple views whose `route` patterns\n * all match a given URL. Per-segment weights: literal = 3, `:param` = 2,\n * `*` = 1, `**` and empty segments contribute 0. Declaration order is the\n * tiebreak when two patterns score equal — enforced by the caller, not\n * here.\n *\n * Total-sum scoring matches React Router 7's general spirit: static\n * segments dominate, parameters outrank single-segment wildcards, and\n * `**` is the catchall fallback that only wins when nothing else matches.\n */\nexport function routeSpecificity(route: string): number {\n // The root route \"/\" is a literal match for exactly one URL and is more\n // specific than any wildcard-only pattern (e.g. \"/**\" scores 0).\n if (route === \"/\") return 1;\n let total = 0;\n for (const seg of route.split(\"/\")) {\n if (seg === \"\" || seg === \"**\") continue;\n if (seg === \"*\") total += 1;\n else if (seg.startsWith(\":\")) total += 2;\n else total += 3;\n }\n return total;\n}\n\nfunction matchSegs(pattern: string[], url: string[]): boolean {\n if (pattern.length === 0 && url.length === 0) return true;\n if (pattern.length === 0) return false;\n\n const head = pattern[0]!;\n const rest = pattern.slice(1);\n\n if (head === \"**\") {\n // Match zero or more segments.\n if (rest.length === 0) return true;\n for (let i = 0; i <= url.length; i++) {\n if (matchSegs(rest, url.slice(i))) return true;\n }\n return false;\n }\n\n if (url.length === 0) return false;\n if (head === \"*\" || head === url[0]) {\n return matchSegs(rest, url.slice(1));\n }\n return false;\n}\n","import type {\n Sightmap,\n MatchResult,\n ExplainHit,\n ResolvedView,\n ResolvedComponent,\n ResolvedRequest,\n} from \"./sightmap.js\";\nimport type { View, Component, Request } from \"./types.js\";\nimport { routeMatch, routeSpecificity } from \"./routeMatch.js\";\n\nexport function resolveByUrl(\n sightmap: Sightmap,\n url: string,\n method?: string,\n): MatchResult {\n // Most-specific match wins; declaration order tiebreaks equal specificity.\n // Strict `>` keeps the earlier-declared view on ties (declaration order =\n // the order views appear in `sightmap.views`, which is `merge.ts`'s\n // sourceFile-sorted view list).\n let matchedView: View | null = null;\n let bestScore = -1;\n for (const v of sightmap.views) {\n if (!routeMatch(v.route, url)) continue;\n // routeSpecificity expects the raw route string (preserves `:param` segments).\n const score = routeSpecificity(v.route);\n if (score > bestScore) {\n bestScore = score;\n matchedView = v;\n }\n }\n\n const components: ResolvedComponent[] = [];\n for (const c of sightmap.globalComponents) {\n components.push(...flattenComponent(c, [], \"global\", undefined));\n }\n if (matchedView !== null && Array.isArray(matchedView.components)) {\n for (const c of matchedView.components) {\n components.push(...flattenComponent(c, [], \"view-scoped\", matchedView.name));\n }\n }\n\n const requests: ResolvedRequest[] = [];\n const requestPool: Request[] = [\n ...sightmap.globalRequests,\n ...((matchedView?.requests ?? [])),\n ];\n for (const req of requestPool) {\n if (!routeMatch(req.route, url)) continue;\n if (method !== undefined && req.method !== undefined && req.method !== method) continue;\n requests.push(toResolvedRequest(req));\n }\n\n const memory: string[] = [];\n for (const fm of sightmap.fileMemory) memory.push(...fm.memory);\n if (matchedView?.memory) memory.push(...matchedView.memory);\n\n return {\n view: matchedView !== null ? toResolvedView(matchedView) : null,\n components,\n requests,\n memory,\n };\n}\n\nexport function resolveByName(sightmap: Sightmap, name: string): ExplainHit[] {\n const hits: ExplainHit[] = [];\n for (const v of sightmap.views) {\n if (v.name === name) hits.push({ type: \"view\", matchedAs: \"name\", entry: toResolvedView(v) });\n }\n for (const c of sightmap.globalComponents) {\n for (const rc of flattenComponent(c, [], \"global\", undefined)) {\n if (rc.name === name) hits.push({ type: \"component\", matchedAs: \"name\", entry: rc });\n }\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n for (const rc of flattenComponent(c, [], \"view-scoped\", v.name)) {\n if (rc.name === name) hits.push({ type: \"component\", matchedAs: \"name\", entry: rc });\n }\n }\n }\n for (const r of sightmap.globalRequests) {\n if (r.name === name) hits.push({ type: \"request\", matchedAs: \"name\", entry: toResolvedRequest(r) });\n }\n for (const v of sightmap.views) {\n for (const r of v.requests ?? []) {\n if (r.name === name) hits.push({ type: \"request\", matchedAs: \"name\", entry: toResolvedRequest(r) });\n }\n }\n return hits;\n}\n\nexport function resolveBySourcePath(sightmap: Sightmap, path: string): ExplainHit[] {\n const hits: ExplainHit[] = [];\n for (const v of sightmap.views) {\n if (v.source === path) hits.push({ type: \"view\", matchedAs: \"path\", entry: toResolvedView(v) });\n }\n for (const c of sightmap.globalComponents) {\n for (const rc of flattenComponent(c, [], \"global\", undefined)) {\n if (rc.source === path) hits.push({ type: \"component\", matchedAs: \"path\", entry: rc });\n }\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n for (const rc of flattenComponent(c, [], \"view-scoped\", v.name)) {\n if (rc.source === path) hits.push({ type: \"component\", matchedAs: \"path\", entry: rc });\n }\n }\n }\n for (const r of sightmap.globalRequests) {\n if (r.source === path) hits.push({ type: \"request\", matchedAs: \"path\", entry: toResolvedRequest(r) });\n }\n return hits;\n}\n\nfunction flattenComponent(\n c: Component,\n parentChain: string[],\n scope: \"global\" | \"view-scoped\",\n scopedToView: string | undefined,\n): ResolvedComponent[] {\n const out: ResolvedComponent[] = [];\n const selector = Array.isArray(c.selector) ? c.selector : [c.selector as unknown as string];\n out.push({\n name: c.name,\n selector,\n ...(c.source !== undefined ? { source: c.source } : {}),\n ...(c.description !== undefined ? { description: c.description } : {}),\n memory: c.memory ? [...c.memory] : [],\n parentChain: [...parentChain],\n scope,\n ...(scopedToView !== undefined ? { scopedToView } : {}),\n definedIn: { file: \"<unknown>\" },\n });\n for (const child of c.children ?? []) {\n out.push(...flattenComponent(child, [...parentChain, c.name], scope, scopedToView));\n }\n return out;\n}\n\nfunction toResolvedView(v: View): ResolvedView {\n return {\n name: v.name,\n route: v.route,\n ...(v.source !== undefined ? { source: v.source } : {}),\n ...(v.description !== undefined ? { description: v.description } : {}),\n memory: v.memory ? [...v.memory] : [],\n definedIn: { file: \"<unknown>\" },\n };\n}\n\nfunction toResolvedRequest(r: Request): ResolvedRequest {\n return {\n name: r.name,\n route: r.route,\n ...(r.method !== undefined ? { method: r.method } : {}),\n ...(r.source !== undefined ? { source: r.source } : {}),\n ...(r.description !== undefined ? { description: r.description } : {}),\n ...(r.request !== undefined ? { request: { fields: r.request.fields ?? [] } } : {}),\n ...(r.response !== undefined ? { response: { fields: r.response.fields ?? [] } } : {}),\n ...(r.headers !== undefined ? { headers: r.headers } : {}),\n memory: r.memory ? [...r.memory] : [],\n definedIn: { file: \"<unknown>\" },\n };\n}\n","import type { Sightmap, MatchResult } from \"./sightmap.js\";\nimport { resolveByUrl } from \"./resolver.js\";\n\nexport interface MatchOptions {\n url: string;\n method?: string;\n}\n\nexport function match(sightmap: Sightmap, opts: MatchOptions): MatchResult {\n return resolveByUrl(sightmap, opts.url, opts.method);\n}\n","import type { Sightmap, ExplainResult, ExplainHit, ExplainMatchedAs } from \"./sightmap.js\";\nimport { resolveByName, resolveBySourcePath } from \"./resolver.js\";\n\nexport interface ExplainOptions {\n by?: \"name\" | \"path\";\n type?: \"view\" | \"component\" | \"request\";\n}\n\nexport function explain(\n sightmap: Sightmap,\n query: string,\n opts: ExplainOptions = {},\n): ExplainResult {\n const byName = opts.by === \"path\" ? [] : resolveByName(sightmap, query);\n const byPath = opts.by === \"name\" ? [] : resolveBySourcePath(sightmap, query);\n\n // Merge: when an entry appears in both lookups, label as \"name-and-path\".\n // Use entry identity (type + name) as the dedup key.\n const key = (h: ExplainHit): string => `${h.type}:${h.entry.name}`;\n const namedKeys = new Set(byName.map(key));\n const pathKeys = new Set(byPath.map(key));\n\n const merged: ExplainHit[] = [];\n for (const h of byName) {\n if (pathKeys.has(key(h))) {\n merged.push(withMatchedAs(h, \"name-and-path\"));\n } else {\n merged.push(h);\n }\n }\n for (const h of byPath) {\n if (!namedKeys.has(key(h))) {\n merged.push(h);\n }\n // (entries already in both have been pushed above with \"name-and-path\".)\n }\n\n const filtered =\n opts.type !== undefined ? merged.filter((h) => h.type === opts.type) : merged;\n return { query, hits: filtered };\n}\n\nfunction withMatchedAs(h: ExplainHit, matchedAs: ExplainMatchedAs): ExplainHit {\n switch (h.type) {\n case \"view\":\n return { type: \"view\", matchedAs, entry: h.entry };\n case \"component\":\n return { type: \"component\", matchedAs, entry: h.entry };\n case \"request\":\n return { type: \"request\", matchedAs, entry: h.entry };\n }\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { DUPLICATE_VIEW_NAME, type Diagnostic } from \"../diagnostics.js\";\n\nexport function duplicateName(sightmap: Sightmap): Diagnostic[] {\n const seen = new Map<string, number>();\n const out: Diagnostic[] = [];\n sightmap.views.forEach((v) => {\n const count = (seen.get(v.name) ?? 0) + 1;\n seen.set(v.name, count);\n if (count > 1) {\n out.push({\n severity: \"warning\",\n code: DUPLICATE_VIEW_NAME,\n message: `Duplicate view name \"${v.name}\" (occurrence ${count}).`,\n });\n }\n });\n return out;\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { DUPLICATE_ROUTE, type Diagnostic } from \"../diagnostics.js\";\n\nexport function duplicateRoute(sightmap: Sightmap): Diagnostic[] {\n const seen = new Map<string, string>(); // route → first-view-name\n const out: Diagnostic[] = [];\n for (const v of sightmap.views) {\n const prev = seen.get(v.route);\n if (prev !== undefined) {\n out.push({\n severity: \"warning\",\n code: DUPLICATE_ROUTE,\n message: `Route \"${v.route}\" is defined by both \"${prev}\" and \"${v.name}\". Only \"${prev}\" will match.`,\n });\n } else {\n seen.set(v.route, v.name);\n }\n }\n return out;\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport { ROUTE_SHADOWING, type Diagnostic } from \"../diagnostics.js\";\nimport { routeSpecificity } from \"../routeMatch.js\";\n\n/**\n * Detect routes made unreachable under sightmap's matcher rules.\n *\n * `resolveByUrl` picks the most specific matching view, with declaration\n * order as the tiebreak when two patterns score equal. So a wildcard like\n * `/*` does not shadow a more specific route like `/login`, regardless of\n * declaration order. A route B is truly shadowed by an earlier route A only\n * when:\n *\n * 1. A and B match the exact same set of URLs (same shape; `*` and `:param`\n * are treated as equivalent placeholders here, since both match a single\n * arbitrary segment), AND\n * 2. A is at least as specific as B. When scores tie, the earlier-declared\n * route wins via the tiebreak, leaving B unreachable.\n */\nexport function routeShadowing(sightmap: Sightmap): Diagnostic[] {\n const out: Diagnostic[] = [];\n const views = sightmap.views;\n for (let j = 1; j < views.length; j++) {\n const later = views[j]!;\n const laterKey = matchSetKey(later.route);\n const laterScore = routeSpecificity(later.route);\n for (let i = 0; i < j; i++) {\n const earlier = views[i]!;\n if (earlier.route === later.route) continue; // duplicate-route covers this\n if (matchSetKey(earlier.route) !== laterKey) continue;\n if (routeSpecificity(earlier.route) < laterScore) continue;\n out.push({\n severity: \"warning\",\n code: ROUTE_SHADOWING,\n message: `Route \"${later.route}\" (view \"${later.name}\") is shadowed by earlier route \"${earlier.route}\" (view \"${earlier.name}\"); they match the same URLs and the earlier route is at least as specific, making this route unreachable.`,\n });\n break; // only report the first shadower\n }\n }\n return out;\n}\n\n/**\n * Canonical \"match-set\" key for a pattern: literal segments are kept; `:param`\n * is normalized to `*` (both match exactly one arbitrary segment); `**` is\n * preserved (variable-depth). Two patterns with the same key match the same\n * set of URLs under the spec's matching rules.\n */\nfunction matchSetKey(route: string): string {\n return route\n .split(\"/\")\n .map((seg) => (seg.startsWith(\":\") ? \"*\" : seg))\n .join(\"/\");\n}\n\n","import { stat } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\nimport { UNKNOWN_SOURCE, type Diagnostic } from \"../diagnostics.js\";\n\nexport interface UnknownSourceOptions {\n /** Filesystem root for resolving `source:` paths. Defaults to process.cwd(). */\n root?: string;\n}\n\nexport async function unknownSource(\n sightmap: Sightmap,\n opts: UnknownSourceOptions = {},\n): Promise<Diagnostic[]> {\n const root = opts.root ?? process.cwd();\n const out: Diagnostic[] = [];\n const seen = new Set<string>();\n\n const check = async (source: string | undefined, label: string): Promise<void> => {\n if (source === undefined) return;\n if (seen.has(source)) return;\n seen.add(source);\n try {\n await stat(resolve(root, source));\n } catch {\n out.push({\n severity: \"warning\",\n code: UNKNOWN_SOURCE,\n message: `${label}: source path \"${source}\" does not exist on disk (relative to ${root}).`,\n });\n }\n };\n\n for (const v of sightmap.views) {\n await check(v.source, `view \"${v.name}\"`);\n for (const c of v.components ?? []) {\n await walkComponent(c, `component \"${c.name}\"`, check);\n }\n }\n for (const c of sightmap.globalComponents) {\n await walkComponent(c, `component \"${c.name}\"`, check);\n }\n for (const r of sightmap.globalRequests) {\n await check(r.source, `request \"${r.name}\"`);\n }\n\n return out;\n}\n\nasync function walkComponent(\n c: Component,\n label: string,\n check: (source: string | undefined, label: string) => Promise<void>,\n): Promise<void> {\n await check(c.source, label);\n for (const child of c.children ?? []) {\n await walkComponent(child, `component \"${child.name}\"`, check);\n }\n}\n","import { parse as parseSelector } from \"css-what\";\nimport type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\nimport { SELECTOR_SYNTAX, type Diagnostic } from \"../diagnostics.js\";\n\nexport function selectorSyntax(sightmap: Sightmap): Diagnostic[] {\n const out: Diagnostic[] = [];\n const visit = (c: Component, scope: string): void => {\n const selectors: string[] = Array.isArray(c.selector)\n ? c.selector\n : [c.selector as unknown as string];\n selectors.forEach((sel, i) => {\n try {\n parseSelector(sel);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n out.push({\n severity: \"warning\",\n code: SELECTOR_SYNTAX,\n message: `${scope}: selector at index ${i} (\"${sel}\") failed to parse: ${msg}`,\n });\n }\n });\n for (const child of c.children ?? []) visit(child, `component \"${child.name}\"`);\n };\n\n for (const c of sightmap.globalComponents) visit(c, `component \"${c.name}\"`);\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) visit(c, `component \"${c.name}\"`);\n }\n return out;\n}\n","import type { Sightmap } from \"./sightmap.js\";\nimport type { Diagnostic } from \"./diagnostics.js\";\nimport { duplicateName } from \"./lintRules/duplicateName.js\";\nimport { duplicateRoute } from \"./lintRules/duplicateRoute.js\";\nimport { routeShadowing } from \"./lintRules/routeShadowing.js\";\nimport { unknownSource } from \"./lintRules/unknownSource.js\";\nimport { selectorSyntax } from \"./lintRules/selectorSyntax.js\";\n\nexport interface LintOptions {\n /** Per-rule enable/disable. Default: all rules enabled. */\n rules?: Record<string, boolean>;\n /** Filesystem root for `unknown-source`. Defaults to process.cwd(). */\n root?: string;\n}\n\nexport async function lint(sightmap: Sightmap, opts: LintOptions = {}): Promise<Diagnostic[]> {\n const enabled = (code: string): boolean => opts.rules?.[code] !== false;\n const out: Diagnostic[] = [];\n if (enabled(\"duplicate-view-name\")) out.push(...duplicateName(sightmap));\n if (enabled(\"duplicate-route\")) out.push(...duplicateRoute(sightmap));\n if (enabled(\"route-shadowing\")) out.push(...routeShadowing(sightmap));\n if (enabled(\"selector-syntax\")) out.push(...selectorSyntax(sightmap));\n if (enabled(\"unknown-source\")) {\n out.push(...(await unknownSource(sightmap, opts.root !== undefined ? { root: opts.root } : {})));\n }\n return out;\n}\n","// Canonical YAML writer for sightmap documents.\n//\n// Takes a value-shaped sightmap (the same shape `parse()` returns, minus the\n// internal `__brand` / `__sourceFile` markers, or any plain `SightmapV1`\n// object) and emits canonical YAML:\n//\n// * Top-level keys are emitted in spec order: version, memory, views,\n// components, requests. Unknown keys come last in input order.\n// * Block style throughout (no flow mapping/sequence collapse).\n// * Selector arrays single-quote strings that contain reserved chars (per\n// YAML's default quoting), so `[data-sightmap=\"X\"]` reads as\n// `'[data-sightmap=\"X\"]'`.\n// * Output ends with a single trailing newline.\n//\n// The writer is value-based: it does not preserve user comments or original\n// key ordering. Comment-preserving rewrites belong in\n// `@sightmap/react`'s smart-merge (codegen path), not here.\n\nimport { stringify } from \"yaml\";\nimport type { SightmapV1 } from \"../types.js\";\nimport { TOP_LEVEL_KEY_ORDER } from \"./canonical-rules.js\";\n\n/**\n * Input shape for `format`: the value-side of `SightmapV1` plus any\n * forward-compat unknown keys we should pass through.\n */\nexport type FormatInput = SightmapV1 & Record<string, unknown>;\n\nexport function format(input: FormatInput): string {\n const ordered: Record<string, unknown> = {};\n for (const key of TOP_LEVEL_KEY_ORDER) {\n if ((input as Record<string, unknown>)[key] !== undefined) {\n ordered[key] = (input as Record<string, unknown>)[key];\n }\n }\n for (const key of Object.keys(input)) {\n if (key.startsWith(\"__\")) continue; // drop SightmapFragment internal markers\n if (!(key in ordered)) ordered[key] = input[key];\n }\n\n const yaml = stringify(ordered, {\n indent: 2,\n lineWidth: 0,\n minContentWidth: 0,\n });\n\n return yaml.endsWith(\"\\n\") ? yaml : yaml + \"\\n\";\n}\n","// Shared canonical-form constants and comparators used by both the value-based\n// format() writer and the CST-preserving canonicalize() writer.\n//\n// Source of truth for the spec rules in\n// sightmap/spec docs/authoring-conventions.md#canonical-formatting-rules.\n\nexport const TOP_LEVEL_KEY_ORDER = [\n \"version\",\n \"memory\",\n \"views\",\n \"components\",\n \"requests\",\n] as const;\n\nexport const VIEW_KEY_ORDER = [\n \"name\",\n \"route\",\n \"description\",\n \"components\",\n \"memory\",\n \"requests\",\n] as const;\n\nexport const COMPONENT_KEY_ORDER = [\n \"name\",\n \"selector\",\n \"description\",\n \"children\",\n \"memory\",\n] as const;\n\n// Schema-derived order. The spec's authoring-conventions doc table lists\n// `method, url, description, memory` for Request — that table is stale\n// relative to the JSON Schema, which has `name, route, method, description,\n// source, request, response, headers, memory` (no `url` field exists). The\n// schema is the source of truth tools enforce; we follow it here.\nexport const REQUEST_KEY_ORDER = [\n \"name\",\n \"route\",\n \"method\",\n \"description\",\n \"source\",\n \"request\",\n \"response\",\n \"headers\",\n \"memory\",\n] as const;\n\n// Lexicographic byte-by-byte comparison on YAML scalar strings.\n// No Unicode normalization, no case folding (per spec).\nexport function compareByName(a: { name: string }, b: { name: string }): number {\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;\n}\n\n// Sort requests by (route, method). Spec doc says (url, method) but `url`\n// is not a real field — see REQUEST_KEY_ORDER comment above.\n// `method?: string | undefined` (rather than `method?: string`) so callers\n// can pass through optional-or-undefined extractions without spreading.\nexport function compareRequests(\n a: { route: string; method?: string | undefined },\n b: { route: string; method?: string | undefined },\n): number {\n if (a.route !== b.route) return a.route < b.route ? -1 : 1;\n const am = a.method ?? \"\";\n const bm = b.method ?? \"\";\n return am < bm ? -1 : am > bm ? 1 : 0;\n}\n","// CST-preserving canonical YAML writer. Backs `sightmap fmt`.\n//\n// See sightmap/spec docs/authoring-conventions.md#canonical-formatting-rules\n// for the normative rules this implements.\n\nimport { parseDocument, isMap, isSeq, isScalar, type Document, type YAMLMap, type YAMLSeq, type Pair, type Scalar } from \"yaml\";\nimport { validate } from \"../validate.js\";\nimport {\n FMT_PARSE_ERROR,\n FMT_SCHEMA_INVALID,\n type Diagnostic,\n} from \"../diagnostics.js\";\nimport {\n TOP_LEVEL_KEY_ORDER,\n VIEW_KEY_ORDER,\n COMPONENT_KEY_ORDER,\n REQUEST_KEY_ORDER,\n compareByName,\n compareRequests,\n} from \"./canonical-rules.js\";\n\nexport type CanonicalizeResult =\n | { kind: \"canonical\"; text: string; changed: boolean }\n | { kind: \"parse-error\"; diagnostics: Diagnostic[] }\n | { kind: \"schema-invalid\"; diagnostics: Diagnostic[] };\n\nexport interface CanonicalizeOptions {\n /** Source-file path for diagnostics (relative to cwd, typically). */\n file: string;\n}\n\nexport function canonicalize(input: string, opts: CanonicalizeOptions): CanonicalizeResult {\n const doc = parseDocument(input, { keepSourceTokens: false });\n\n const first = doc.errors[0];\n if (first !== undefined) {\n const loc = first.linePos?.[0]\n ? { line: first.linePos[0].line, column: first.linePos[0].col }\n : undefined;\n return {\n kind: \"parse-error\",\n diagnostics: [\n {\n severity: \"error\",\n code: FMT_PARSE_ERROR,\n message: first.message,\n file: opts.file,\n ...(loc !== undefined ? { loc } : {}),\n },\n ],\n };\n }\n\n const v = validate(input, { sourceFile: opts.file });\n if (!v.ok) {\n // Re-code the validate diagnostics under fmt.schema-invalid; preserve\n // message/loc but normalize severity to error and overwrite the code.\n const diagnostics: Diagnostic[] = v.diagnostics.map((d) => ({\n ...d,\n severity: \"error\" as const,\n code: FMT_SCHEMA_INVALID,\n file: opts.file,\n }));\n return { kind: \"schema-invalid\", diagnostics };\n }\n\n // Mutation passes (only run when input parses + validates).\n if (isMap(doc.contents)) {\n reorderTopLevelKeys(doc.contents);\n reorderEntriesUnder(doc.contents, \"views\", VIEW_KEY_ORDER);\n reorderEntriesUnder(doc.contents, \"components\", COMPONENT_KEY_ORDER);\n reorderEntriesUnder(doc.contents, \"requests\", REQUEST_KEY_ORDER);\n // Per-spec: nested seqs (view.components, view.requests) also follow per-entry-type key order.\n forEachViewEntry(doc.contents, (view) => {\n reorderEntriesUnder(view, \"components\", COMPONENT_KEY_ORDER);\n reorderEntriesUnder(view, \"requests\", REQUEST_KEY_ORDER);\n forEachComponentEntry(view, \"components\", (cmp) => {\n reorderChildrenRecursive(cmp);\n });\n });\n forEachComponentEntry(doc.contents, \"components\", (cmp) => {\n reorderChildrenRecursive(cmp);\n });\n sortTopLevelSeq(doc.contents, \"views\", (a, b) => {\n const an = scalarPropFromMapItem(a, \"name\");\n const bn = scalarPropFromMapItem(b, \"name\");\n return compareByName({ name: an ?? \"\" }, { name: bn ?? \"\" });\n });\n sortTopLevelSeq(doc.contents, \"components\", (a, b) => {\n const an = scalarPropFromMapItem(a, \"name\");\n const bn = scalarPropFromMapItem(b, \"name\");\n return compareByName({ name: an ?? \"\" }, { name: bn ?? \"\" });\n });\n sortTopLevelSeq(doc.contents, \"requests\", (a, b) => {\n return compareRequests(\n { route: scalarPropFromMapItem(a, \"route\") ?? \"\", method: scalarPropFromMapItem(a, \"method\") },\n { route: scalarPropFromMapItem(b, \"route\") ?? \"\", method: scalarPropFromMapItem(b, \"method\") },\n );\n });\n visitAllScalars(doc, (scalar) => {\n if (typeof scalar.value !== \"string\") return;\n scalar.type = chooseQuoteType(scalar.value);\n });\n normalizeBlankLines(doc);\n }\n\n const output = serialize(doc);\n return { kind: \"canonical\", text: output, changed: output !== input };\n}\n\nfunction reorderTopLevelKeys(map: YAMLMap): void {\n reorderMapKeys(map, TOP_LEVEL_KEY_ORDER);\n}\n\nfunction reorderMapKeys(map: YAMLMap, keyOrder: readonly string[]): void {\n const items = map.items as Pair[];\n const byKey = new Map<string, Pair>();\n const unknownInOrder: Pair[] = [];\n for (const item of items) {\n const key = scalarKey(item);\n if (key === null) {\n unknownInOrder.push(item);\n continue;\n }\n if (keyOrder.includes(key)) {\n byKey.set(key, item);\n } else {\n unknownInOrder.push(item);\n }\n }\n const reordered: Pair[] = [];\n for (const k of keyOrder) {\n const p = byKey.get(k);\n if (p !== undefined) reordered.push(p);\n }\n reordered.push(...unknownInOrder);\n map.items = reordered;\n}\n\nfunction reorderEntriesUnder(map: YAMLMap, key: string, keyOrder: readonly string[]): void {\n const seq = lookupSeq(map, key);\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) reorderMapKeys(item, keyOrder);\n }\n}\n\nfunction forEachViewEntry(root: YAMLMap, fn: (view: YAMLMap) => void): void {\n const seq = lookupSeq(root, \"views\");\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) fn(item);\n }\n}\n\nfunction forEachComponentEntry(root: YAMLMap, key: string, fn: (cmp: YAMLMap) => void): void {\n const seq = lookupSeq(root, key);\n if (seq === null) return;\n for (const item of seq.items) {\n if (isMap(item)) fn(item);\n }\n}\n\nfunction reorderChildrenRecursive(cmp: YAMLMap): void {\n const children = lookupSeq(cmp, \"children\");\n if (children === null) return;\n for (const child of children.items) {\n if (!isMap(child)) continue;\n reorderMapKeys(child, COMPONENT_KEY_ORDER);\n reorderChildrenRecursive(child);\n }\n}\n\nfunction lookupSeq(map: YAMLMap, key: string): YAMLSeq | null {\n for (const item of map.items as Pair[]) {\n if (scalarKey(item) === key && isSeq(item.value)) return item.value;\n }\n return null;\n}\n\nfunction scalarKey(pair: Pair): string | null {\n // Pair.key may be a Scalar node or a raw value depending on parse path.\n const k = (pair.key as { value?: unknown }) ?? null;\n if (k === null) return null;\n const v = typeof k === \"object\" && k !== null && \"value\" in k ? k.value : k;\n return typeof v === \"string\" ? v : null;\n}\n\nfunction sortTopLevelSeq(\n root: YAMLMap,\n key: string,\n cmp: (a: unknown, b: unknown) => number,\n): void {\n const seq = lookupSeq(root, key);\n if (seq === null) return;\n // Array.prototype.sort is stable in V8/JSC since 2019.\n seq.items = (seq.items as unknown[]).slice().sort(cmp);\n}\n\nfunction scalarPropFromMapItem(item: unknown, key: string): string | undefined {\n if (!isMap(item)) return undefined;\n for (const pair of item.items as Pair[]) {\n if (scalarKey(pair) !== key) continue;\n const v = pair.value as { value?: unknown } | unknown;\n if (v !== null && typeof v === \"object\" && \"value\" in (v as object)) {\n const inner = (v as { value: unknown }).value;\n return typeof inner === \"string\" ? inner : undefined;\n }\n return typeof v === \"string\" ? v : undefined;\n }\n return undefined;\n}\n\nfunction visitAllScalars(doc: Document, fn: (scalar: Scalar) => void): void {\n walk(doc.contents, fn);\n}\n\nfunction walk(node: unknown, fn: (scalar: Scalar) => void): void {\n if (node === null || node === undefined) return;\n if (isScalar(node)) {\n fn(node);\n return;\n }\n if (isMap(node)) {\n for (const pair of node.items as Pair[]) {\n walk(pair.key, fn);\n walk(pair.value, fn);\n }\n return;\n }\n if (isSeq(node)) {\n for (const item of node.items) walk(item, fn);\n }\n}\n\nfunction normalizeBlankLines(doc: Document): void {\n const root = doc.contents;\n if (!isMap(root)) return;\n\n // HEADER blank-line normalization: emit exactly one blank line between a\n // leading comment block (HEADER) and the first content. Per spec: if no\n // HEADER, no leading blank.\n //\n // eemeli/yaml attaches a leading `# foo` block to the first Pair's *key*\n // (`firstPair.key.commentBefore`), not to `doc.commentBefore`. Setting\n // `spaceBefore` on the key produces a blank BEFORE the comment (wrong);\n // setting it on the Pair has no effect while the comment lives on the key.\n // Workaround: lift the key's commentBefore up to `doc.commentBefore`, clear\n // it on the key, then set `spaceBefore = true` on the first Pair so the\n // serializer emits the desired `<header>\\n\\n<content>` shape.\n const firstPair = (root.items as Pair[])[0];\n if (firstPair !== undefined) {\n const keyNode = firstPair.key as { commentBefore?: string | null } | null;\n const docMutable = doc as { commentBefore?: string | null };\n const keyComment = keyNode?.commentBefore;\n const docComment = docMutable.commentBefore;\n if (typeof keyComment === \"string\" && keyComment.length > 0) {\n docMutable.commentBefore = keyComment;\n keyNode!.commentBefore = null;\n }\n const hasHeader =\n (typeof docMutable.commentBefore === \"string\" && docMutable.commentBefore.length > 0) ||\n (typeof docComment === \"string\" && docComment.length > 0);\n (firstPair as { spaceBefore?: boolean }).spaceBefore = hasHeader;\n }\n\n for (const key of [\"views\", \"components\", \"requests\"] as const) {\n const seq = lookupSeq(root, key);\n if (seq === null) continue;\n seq.items.forEach((item, idx) => {\n // Items at the top level of these seqs get a blank line before them\n // (except the first item). spaceBefore may not be pre-set; assign directly.\n if (typeof item === \"object\" && item !== null) {\n (item as { spaceBefore: boolean }).spaceBefore = idx > 0;\n }\n });\n // Recurse into nested entries to clear any blank lines within an entry's body.\n for (const item of seq.items) {\n if (isMap(item)) clearInnerBlankLines(item);\n }\n }\n}\n\nfunction clearInnerBlankLines(map: YAMLMap): void {\n for (const pair of map.items as Pair[]) {\n (pair as { spaceBefore?: boolean }).spaceBefore = false;\n if (isSeq(pair.value)) {\n for (const item of (pair.value as YAMLSeq).items) {\n if (typeof item === \"object\" && item !== null) {\n (item as { spaceBefore?: boolean }).spaceBefore = false;\n }\n if (isMap(item)) clearInnerBlankLines(item);\n }\n } else if (isMap(pair.value)) {\n clearInnerBlankLines(pair.value);\n }\n }\n}\n\n// Quote-type selection per sightmap/spec authoring-conventions.md#quoting.\nfunction chooseQuoteType(value: string): Scalar.Type {\n if (requiresDoubleQuotes(value)) return \"QUOTE_DOUBLE\";\n if (value.includes('\"')) return \"QUOTE_SINGLE\";\n if (isPlainSafe(value)) return \"PLAIN\";\n return \"QUOTE_SINGLE\";\n}\n\nfunction requiresDoubleQuotes(s: string): boolean {\n // Any ASCII control character (\\x00-\\x1f) requires double-quoted escaping.\n // Includes tab, newline, CR, which canonical form encodes via \\t / \\n / \\r\n // escapes to keep one-line representation (spec: \"Long strings stay on one\n // line. Do not wrap.\").\n // eslint-disable-next-line no-control-regex\n return /[\\x00-\\x1f]/.test(s);\n}\n\nfunction isPlainSafe(s: string): boolean {\n if (s.length === 0) return false;\n // Leading character restrictions per YAML 1.2 plain scalar rules.\n const first = s[0]!;\n if (\"-?:,[]{}#&*!|>'\\\"%@`\".includes(first)) return false;\n if (first === \" \" || first === \"\\t\") return false;\n // Sequences that change parse semantics anywhere in the string.\n if (s.includes(\": \")) return false;\n if (s.includes(\" #\")) return false;\n // Reserved YAML true/false/null/numeric forms.\n if (/^(true|false|null|~|y|n|yes|no|on|off|True|False|Null|Yes|No|On|Off|TRUE|FALSE|NULL|YES|NO|ON|OFF)$/.test(s)) return false;\n if (/^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/.test(s)) return false;\n if (/^0[xob]/.test(s)) return false;\n return true;\n}\n\nfunction serialize(doc: Document): string {\n const out = doc.toString({\n indent: 2,\n lineWidth: 0,\n minContentWidth: 0,\n blockQuote: \"literal\",\n });\n return out.endsWith(\"\\n\") ? out : out + \"\\n\";\n}\n","/**\n * Additive a11y-text annotator.\n *\n * Appends a `[sightmap=Name1,Name2]` token immediately after the engine's\n * `[ref=eN]` token on any node whose ref is present in `refAnnotations`.\n * Every other byte — headers, code fences, indentation, unmatched node\n * lines, line endings, trailing newline — is preserved verbatim.\n *\n * Byte-identical when `refAnnotations` is empty: a page with zero sightmap\n * coverage produces a snapshot indistinguishable from the un-enriched tool,\n * so the agent's bootstrap-by-ref path is never disturbed.\n *\n * The engine's `[ref=eN]` tokens only ever appear on snapshot node lines\n * (the `### Page` / `### Events` sections carry no ref tokens), so a global\n * substitution on the ref token is sufficient and inherently section-safe.\n */\nexport function annotateAriaText(\n ariaText: string,\n refAnnotations: Map<string, string[]>,\n): string {\n if (refAnnotations.size === 0) return ariaText;\n return ariaText.replace(/\\[ref=(e\\d+)\\]/g, (full, ref: string) => {\n const names = refAnnotations.get(ref);\n if (names === undefined || names.length === 0) return full;\n return `${full} [sightmap=${names.join(\",\")}]`;\n });\n}\n","import { match as sightmapMatch } from \"../match.js\";\nimport type { Sightmap } from \"../sightmap.js\";\nimport { annotateAriaText } from \"./a11y/annotate.js\";\n\nexport interface BoundingRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * What an engine adapter's in-page evaluate returns for each sightmap\n * component. matchCount is the number of DOM elements matched (after\n * dedup); samplePosition is the bounding rect of the first match.\n *\n * Engine adapters produce this shape from their own browser-evaluate\n * mechanism; the kernel does not care how.\n */\nexport interface InPageSightmapMatch {\n name: string;\n selector: string[];\n matchCount: number;\n samplePosition?: BoundingRect | undefined;\n}\n\nexport interface EnrichSnapshotInput {\n sightmap: Sightmap;\n currentUrl: string;\n inPageMatches: InPageSightmapMatch[];\n /**\n * Optional raw a11y snapshot text from the engine (e.g. `playwright-cli\n * snapshot`). When provided together with `refAnnotations`, the kernel\n * additively annotates it and returns `enrichedAriaText`. The engine's\n * native `[ref=eN]` tokens are preserved verbatim.\n */\n ariaText?: string;\n /**\n * Map of engine ref token (`e3`) → sightmap component name(s) covering\n * that node. Built by the adapter from its browser-side join. Only used\n * when `ariaText` is also provided.\n */\n refAnnotations?: Map<string, string[]>;\n}\n\nexport interface SightmapSnapshotComponent {\n name: string;\n selector: string[];\n memory: string[];\n scope: \"global\" | \"view-scoped\";\n matchCount: number;\n samplePosition?: BoundingRect | undefined;\n}\n\nexport interface EnrichedSnapshot {\n view: { name: string; route: string; memory: string[] } | null;\n components: SightmapSnapshotComponent[];\n memory: string[];\n /**\n * The engine's a11y snapshot text with `[sightmap=Name]` tokens added\n * inline on matched nodes. Present only when the caller supplied\n * `ariaText`. Byte-identical to the input when nothing matched, so an\n * agent's bootstrap-by-ref path is never disturbed.\n */\n enrichedAriaText?: string;\n}\n\n/**\n * Pure function: combines a sightmap, the agent's current URL, and the\n * in-page sightmap match results into an engine-agnostic enriched snapshot.\n *\n * Engine adapters typically wrap this and add their own passthrough fields\n * (e.g. @sightmap/mcp adds ariaSnapshot for the Playwright MCP a11y text).\n * The kernel never touches engine-specific text formats.\n */\nexport function enrichSnapshot(input: EnrichSnapshotInput): EnrichedSnapshot {\n const { sightmap, currentUrl, inPageMatches } = input;\n const result = sightmapMatch(sightmap, { url: currentUrl });\n\n const inPageByName = new Map<string, InPageSightmapMatch>();\n for (const m of inPageMatches) inPageByName.set(m.name, m);\n\n const components: SightmapSnapshotComponent[] = result.components.map((c) => {\n const inPage = inPageByName.get(c.name);\n return {\n name: c.name,\n selector: c.selector,\n memory: c.memory ?? [],\n scope: c.scope,\n matchCount: inPage?.matchCount ?? 0,\n ...(inPage?.samplePosition !== undefined\n ? { samplePosition: inPage.samplePosition }\n : {}),\n };\n });\n\n return {\n view: result.view\n ? {\n name: result.view.name,\n route: result.view.route,\n memory: result.view.memory ?? [],\n }\n : null,\n components,\n memory: result.memory ?? [],\n ...(input.ariaText !== undefined\n ? {\n enrichedAriaText: annotateAriaText(\n input.ariaText,\n input.refAnnotations ?? new Map(),\n ),\n }\n : {}),\n };\n}\n","import type { Sightmap } from \"../sightmap.js\";\nimport type { Component } from \"../types.js\";\n\nexport interface ResolveSightmapActInput {\n componentName: string;\n}\n\nexport type ResolveSightmapActResult =\n | {\n kind: \"ok\";\n componentName: string;\n selector: string;\n allSelectors: string[];\n }\n | { kind: \"error\"; message: string };\n\n/**\n * Resolve a sightmap component by name to a CSS selector that an engine\n * adapter's action verb (click/type/hover/...) can use as the target.\n *\n * Lookup order:\n * 1. Global components (sightmap.globalComponents)\n * 2. View-scoped components, walking each view's components list\n *\n * The first selector in the matching component's selector array is\n * returned; additional selectors are exposed in allSelectors so callers\n * can fall back if the engine's first-selector resolution fails.\n */\nexport function resolveSightmapAct(\n sightmap: Sightmap,\n input: ResolveSightmapActInput,\n): ResolveSightmapActResult {\n const found = findComponentByName(sightmap, input.componentName);\n if (found === null) {\n return {\n kind: \"error\",\n message: `Component \"${input.componentName}\" not found in the loaded sightmap.`,\n };\n }\n\n const selectors = Array.isArray(found.selector) ? found.selector : [];\n if (selectors.length === 0) {\n return {\n kind: \"error\",\n message: `Component \"${input.componentName}\" has no selector — cannot dispatch an action.`,\n };\n }\n\n return {\n kind: \"ok\",\n componentName: input.componentName,\n selector: selectors[0]!,\n allSelectors: selectors,\n };\n}\n\nfunction findComponentByName(sightmap: Sightmap, name: string): Component | null {\n for (const c of sightmap.globalComponents) {\n if (c.name === name) return c;\n }\n for (const v of sightmap.views) {\n for (const c of v.components ?? []) {\n if (c.name === name) return c;\n }\n }\n return null;\n}\n","import { match as sightmapMatch } from \"../match.js\";\nimport type { Sightmap } from \"../sightmap.js\";\n\nexport interface ParsedNetworkRequest {\n method: string;\n url: string;\n status: number;\n statusText: string;\n}\n\nexport interface AnnotatedNetworkRequest extends ParsedNetworkRequest {\n sightmapName?: string;\n sightmapMemory?: string[];\n}\n\n/**\n * Cross-reference each captured network request with sightmap's `requests:`\n * declarations. When a match is found, attaches the sightmap name + memory\n * to the response. Unmatched requests are returned unchanged.\n *\n * The `requests` input is already normalized; this function does not parse\n * any engine-specific text format. Engine adapters do their own parsing.\n */\nexport function annotateNetworkRequests(\n sightmap: Sightmap,\n requests: ParsedNetworkRequest[],\n): AnnotatedNetworkRequest[] {\n return requests.map((req) => {\n const result = sightmapMatch(sightmap, { url: req.url, method: req.method });\n const first = result.requests[0];\n if (first === undefined) return req;\n const annotated: AnnotatedNetworkRequest = { ...req, sightmapName: first.name };\n if (first.memory && first.memory.length > 0) {\n annotated.sightmapMemory = first.memory;\n }\n return annotated;\n });\n}\n","/**\n * Build the in-page evaluate function body. Embeds the component selectors\n * inline; the page only needs to query the DOM. No sightmap-js dependency\n * in the page context.\n *\n * Engine adapters serialize this string and pass it to their browser's\n * `evaluate` primitive (Playwright MCP's `browser_evaluate`, Playwright\n * CLI's `playwright-cli eval`, etc.). The output shape is\n * `{ url: string, matches: InPageSightmapMatch[] }` — adapters do their\n * own parsing of the engine's wrapping (e.g. Playwright MCP's\n * `### Result` framing).\n */\nexport function buildInPageEvalFunction(\n components: Array<{ name: string; selector: string[] }>,\n): string {\n const componentsJson = JSON.stringify(components);\n return `() => {\n const components = ${componentsJson};\n const matches = components.map((c) => {\n const selectors = c.selector || [];\n const seen = new Set();\n const elements = [];\n for (const sel of selectors) {\n try {\n const found = document.querySelectorAll(sel);\n for (const el of Array.from(found)) {\n if (!seen.has(el)) {\n seen.add(el);\n elements.push(el);\n }\n }\n } catch {\n // Invalid selector — skip silently.\n }\n }\n const first = elements[0];\n let samplePosition;\n if (first && typeof first.getBoundingClientRect === \"function\") {\n const r = first.getBoundingClientRect();\n samplePosition = { x: r.x, y: r.y, width: r.width, height: r.height };\n }\n return {\n name: c.name,\n selector: selectors,\n matchCount: elements.length,\n samplePosition,\n };\n });\n return { url: window.location.href, matches };\n }`;\n}\n"],"mappings":";AAAA,OAAO,UAAU;AAcV,SAAS,MAAM,OAAwB,OAAqB,CAAC,GAAqB;AACvF,MAAI;AACJ,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI;AACF,YAAM,KAAK,KAAK,KAAK;AAAA,IACvB,SAAS,KAAK;AACZ,YAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAM,IAAI,MAAM,qBAAqB,GAAG,EAAE;AAAA,IAC5C;AAAA,EACF,OAAO;AAEL,UAAM,EAAE,GAAG,MAAM;AAAA,EACnB;AAEA,MAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG;AACjE,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AAEA,QAAM,MAAM;AACZ,MAAI,IAAI,SAAS,MAAM,QAAW;AAChC,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AACA,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,UAAM,IAAI,MAAM,wBAAwB,OAAO,IAAI,SAAS,CAAC,CAAC,eAAe;AAAA,EAC/E;AAIA,MAAI,MA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W,QAAO;AAChC,UAAM,YAAqC,EAAE,GAAG,KAAK,cAAc,MAAM,KAAK;AAC9E,QAAI,MAAM,UAAU,MAAM,OAAO,SAAS,GAAG;AAC3C,gBAAU,iBAAiB,MAAM;AAAA,IACnC;AACA,WAAO;AAAA,EACT,CAAC;AACH;;;ACzBO,SAAS,wBACd,YACQ;AACR,QAAM,iBAAiB,KAAK,UAAU,UAAU;AAChD,SAAO;AAAA,yBACgB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCvC;","names":["yaml","yaml","resolve","resolve","resolve","resolve","yaml"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sightmap/sightmap",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Library and CLI for the Sightmap spec — parse, validate, merge, match, explain, lint.",
5
5
  "license": "MIT",
6
6
  "repository": {