{"version":3,"sources":["../src/index.ts","../src/tag-registry.ts","../src/semantic-protocol.ts","../src/metadata-analysis.ts","../src/json-like-balance.ts","../src/path-target.ts","../src/comment-syntax.ts","../src/ts-binding.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Public analysis protocol types and runtime helpers for FormSpec tooling.\n */\nexport * from \"./protocol.js\";\nexport { analyzeMetadataForNode, analyzeMetadataForSourceFile } from \"./metadata-analysis.js\";\nexport type {\n  AnalyzeMetadataOptions,\n  AnalyzeMetadataForNodeOptions,\n  AnalyzeMetadataForSourceFileOptions,\n} from \"./metadata-analysis.js\";\n","import {\n  BUILTIN_CONSTRAINT_DEFINITIONS,\n  UnreachableError,\n  normalizeConstraintTagName,\n  type AnnotationInheritancePolicy,\n  type BuiltinConstraintName,\n  type CustomAnnotationTagDocumentation,\n  type MetadataDeclarationKind,\n  type MetadataSlotRegistration,\n} from \"@stripe/formspec-core/internals\";\n\nexport type FormSpecValueKind =\n  | \"number\"\n  | \"integer\"\n  | \"signedInteger\"\n  | \"string\"\n  | \"json\"\n  | \"boolean\"\n  | \"condition\";\n\n/**\n * Target syntaxes that a FormSpec tag can accept.\n *\n * @public\n */\nexport type FormSpecTargetKind = \"none\" | \"path\" | \"member\" | \"variant\";\nexport type FormSpecTagCategory = \"constraint\" | \"annotation\" | \"structure\" | \"ecosystem\";\n\n/**\n * Declaration contexts where a FormSpec tag may appear.\n *\n * @public\n */\nexport type FormSpecPlacement =\n  | \"class\"\n  | \"class-field\"\n  | \"class-method\"\n  | \"interface\"\n  | \"interface-field\"\n  | \"type-alias\"\n  | \"type-alias-field\"\n  | \"variable\"\n  | \"function\"\n  | \"function-parameter\"\n  | \"method-parameter\";\n\nexport type SemanticCapability =\n  | \"numeric-comparable\"\n  | \"string-like\"\n  | \"array-like\"\n  | \"enum-member-addressable\"\n  | \"json-like\"\n  | \"condition-like\"\n  | \"object-like\";\n\nexport interface TagSignatureParameter {\n  readonly kind: \"value\" | \"target-path\" | \"target-member\" | \"target-variant\";\n  readonly label: string;\n  readonly optional?: boolean;\n  readonly capability?: SemanticCapability;\n  readonly valueKind?: FormSpecValueKind;\n}\n\nexport interface TagSignature {\n  readonly label: string;\n  readonly placements: readonly FormSpecPlacement[];\n  readonly parameters: readonly TagSignatureParameter[];\n}\n\nexport interface TagDefinition {\n  readonly canonicalName: string;\n  readonly valueKind: FormSpecValueKind | null;\n  readonly requiresArgument: boolean;\n  readonly supportedTargets: readonly FormSpecTargetKind[];\n  readonly allowDuplicates: boolean;\n  readonly category: FormSpecTagCategory;\n  readonly placements: readonly FormSpecPlacement[];\n  /**\n   * Type-level semantic inheritance policy for annotation tags. Omitted\n   * registrations behave as `\"never\"`. `\"local-wins\"` means a derived\n   * declaration inherits this annotation only when it does not provide the\n   * same annotation identity locally.\n   */\n  readonly inheritFromBase?: AnnotationInheritancePolicy;\n  /**\n   * The semantic capabilities required of the field type for this tag to be\n   * applicable. At most one capability may be declared per tag.\n   *\n   * The \"at most one\" invariant is structural: all `capabilitiesForValueKind`\n   * return paths yield 0 or 1 elements, and no tag definition supplies 2+\n   * capabilities. The tuple type enforces this at the type level so future\n   * additions that accidentally provide two capabilities produce a type error.\n   */\n  readonly capabilities: readonly [SemanticCapability] | readonly [];\n  readonly completionDetail: string;\n  readonly hoverSummary: string;\n  readonly hoverMarkdown: string;\n  readonly signatures: readonly TagSignature[];\n}\n\nexport type FormSpecTagDefinition = TagDefinition;\nexport type FormSpecTagOverload = TagSignature;\nexport type FormSpecTagParameter = TagSignatureParameter;\n\nexport interface ExtensionConstraintTagSource {\n  readonly tagName: string;\n}\n\nexport interface ExtensionAnnotationTagSource {\n  readonly annotationName: string;\n  readonly inheritFromBase?: AnnotationInheritancePolicy;\n  readonly tagDocumentation?: CustomAnnotationTagDocumentation;\n}\n\n/**\n * Type declaration metadata for extension-registered custom types.\n * Used by host-checker-aware consumers to recognize declarations that reference\n * extension-provided type names.\n */\nexport interface ExtensionCustomTypeSource {\n  /** TypeScript surface names that resolve to this type (e.g., ['Decimal']) */\n  readonly tsTypeNames: readonly string[];\n}\n\nexport interface ExtensionTagSource {\n  readonly extensionId: string;\n  readonly constraintTags?: readonly ExtensionConstraintTagSource[];\n  readonly annotations?: readonly ExtensionAnnotationTagSource[];\n  readonly metadataSlots?: readonly MetadataSlotRegistration[];\n  /** Custom types registered by this extension */\n  readonly customTypes?: readonly ExtensionCustomTypeSource[];\n}\n\nexport interface SettingsExtensionTypeRegistration {\n  readonly extensionId: string;\n  readonly registration: { readonly typeName: string };\n}\n\nexport interface SettingsExtensionDefinition {\n  readonly constraintTags?: readonly { readonly tagName: unknown }[];\n  readonly metadataSlots?: readonly { readonly tagName: unknown }[];\n  readonly annotations?: readonly { readonly annotationName: unknown }[];\n}\n\nexport interface SettingsExtensionRegistry {\n  readonly extensions?: readonly SettingsExtensionDefinition[];\n  readonly findTypeByName?: (typeName: string) => SettingsExtensionTypeRegistration | undefined;\n  readonly findBuiltinConstraintBroadening?: (\n    typeId: string,\n    tagName: string\n  ) => object | undefined;\n}\n\nexport const FORM_SPEC_PLACEMENTS = [\n  \"class\",\n  \"class-field\",\n  \"class-method\",\n  \"interface\",\n  \"interface-field\",\n  \"type-alias\",\n  \"type-alias-field\",\n  \"variable\",\n  \"function\",\n  \"function-parameter\",\n  \"method-parameter\",\n] as const satisfies readonly FormSpecPlacement[];\n\nexport const FORM_SPEC_TARGET_KINDS = [\n  \"none\",\n  \"path\",\n  \"member\",\n  \"variant\",\n] as const satisfies readonly FormSpecTargetKind[];\n\nconst FIELD_PLACEMENTS = [\n  \"class-field\",\n  \"interface-field\",\n  \"type-alias-field\",\n  \"variable\",\n  \"function-parameter\",\n  \"method-parameter\",\n] as const satisfies readonly FormSpecPlacement[];\n\nconst TYPE_PLACEMENTS = [\n  \"class\",\n  \"interface\",\n  \"type-alias\",\n] as const satisfies readonly FormSpecPlacement[];\n\nconst DECLARATION_PLACEMENTS = [\n  \"class-method\",\n  \"function\",\n] as const satisfies readonly FormSpecPlacement[];\n\nconst ALL_PLACEMENTS = [\n  ...TYPE_PLACEMENTS,\n  ...FIELD_PLACEMENTS,\n  ...DECLARATION_PLACEMENTS,\n] as const satisfies readonly FormSpecPlacement[];\n\nconst INTEGER_VALUE_TAGS = new Set([\"minLength\", \"maxLength\", \"minItems\", \"maxItems\"]);\nconst SIGNED_INTEGER_VALUE_TAGS = new Set([\"order\"]);\nconst JSON_VALUE_TAGS = new Set([\"const\", \"enumOptions\"]);\nconst BOOLEAN_VALUE_TAGS = new Set([\"uniqueItems\"]);\nconst STRING_VALUE_TAGS = new Set([\n  \"pattern\",\n  \"displayName\",\n  \"format\",\n  \"placeholder\",\n  \"group\",\n  \"example\",\n  \"remarks\",\n  \"see\",\n  \"apiName\",\n]);\nconst CONDITION_VALUE_TAGS = new Set([\"showWhen\", \"hideWhen\", \"enableWhen\", \"disableWhen\"]);\n\nconst CONSTRAINT_COMPLETION_DETAIL: Record<string, string> = {\n  minimum: \"Minimum numeric value (inclusive). Example: `@minimum 0`\",\n  maximum: \"Maximum numeric value (inclusive). Example: `@maximum 100`\",\n  exclusiveMinimum: \"Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`\",\n  exclusiveMaximum: \"Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`\",\n  multipleOf: \"Value must be a multiple of this number. Example: `@multipleOf 0.01`\",\n  minLength: \"Minimum string length. Example: `@minLength 1`\",\n  maxLength: \"Maximum string length. Example: `@maxLength 255`\",\n  minItems: \"Minimum number of array items. Example: `@minItems 1`\",\n  maxItems: \"Maximum number of array items. Example: `@maxItems 10`\",\n  uniqueItems: \"Require all array items to be distinct. Example: `@uniqueItems`\",\n  pattern: \"Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`\",\n  enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions [\"a\",\"b\",\"c\"]`',\n  const: 'Require a constant JSON value. Example: `@const \"USD\"`',\n};\n\nconst CONSTRAINT_HOVER_DOCS: Record<string, string> = {\n  minimum: [\n    \"**@minimum** `<number>`\",\n    \"\",\n    \"Sets an inclusive lower bound on a numeric field.\",\n    \"\",\n    \"Maps to `minimum` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@minimum [:path] <number>`\",\n  ].join(\"\\n\"),\n  maximum: [\n    \"**@maximum** `<number>`\",\n    \"\",\n    \"Sets an inclusive upper bound on a numeric field.\",\n    \"\",\n    \"Maps to `maximum` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@maximum [:path] <number>`\",\n  ].join(\"\\n\"),\n  exclusiveMinimum: [\n    \"**@exclusiveMinimum** `<number>`\",\n    \"\",\n    \"Sets an exclusive lower bound on a numeric field.\",\n    \"\",\n    \"Maps to `exclusiveMinimum` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@exclusiveMinimum [:path] <number>`\",\n  ].join(\"\\n\"),\n  exclusiveMaximum: [\n    \"**@exclusiveMaximum** `<number>`\",\n    \"\",\n    \"Sets an exclusive upper bound on a numeric field.\",\n    \"\",\n    \"Maps to `exclusiveMaximum` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@exclusiveMaximum [:path] <number>`\",\n  ].join(\"\\n\"),\n  multipleOf: [\n    \"**@multipleOf** `<number>`\",\n    \"\",\n    \"Requires the numeric value to be a multiple of the given number.\",\n    \"\",\n    \"Maps to `multipleOf` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@multipleOf [:path] <number>`\",\n  ].join(\"\\n\"),\n  minLength: [\n    \"**@minLength** `<integer>`\",\n    \"\",\n    \"Sets a minimum character length on a string field.\",\n    \"\",\n    \"Maps to `minLength` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@minLength [:path] <integer>`\",\n  ].join(\"\\n\"),\n  maxLength: [\n    \"**@maxLength** `<integer>`\",\n    \"\",\n    \"Sets a maximum character length on a string field.\",\n    \"\",\n    \"Maps to `maxLength` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@maxLength [:path] <integer>`\",\n  ].join(\"\\n\"),\n  minItems: [\n    \"**@minItems** `<integer>`\",\n    \"\",\n    \"Sets a minimum number of items in an array field.\",\n    \"\",\n    \"Maps to `minItems` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@minItems [:path] <integer>`\",\n  ].join(\"\\n\"),\n  maxItems: [\n    \"**@maxItems** `<integer>`\",\n    \"\",\n    \"Sets a maximum number of items in an array field.\",\n    \"\",\n    \"Maps to `maxItems` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@maxItems [:path] <integer>`\",\n  ].join(\"\\n\"),\n  uniqueItems: [\n    \"**@uniqueItems**\",\n    \"\",\n    \"Requires all items in an array field to be distinct.\",\n    \"\",\n    \"Maps to `uniqueItems` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@uniqueItems [:path]`\",\n  ].join(\"\\n\"),\n  pattern: [\n    \"**@pattern** `<regex>`\",\n    \"\",\n    \"Sets a regular expression pattern that a string field must match.\",\n    \"\",\n    \"Maps to `pattern` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@pattern [:path] <regex>`\",\n  ].join(\"\\n\"),\n  enumOptions: [\n    \"**@enumOptions** `<json-array>`\",\n    \"\",\n    \"Specifies the allowed values for an enum field as an inline JSON array.\",\n    \"\",\n    \"Maps to `enum` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@enumOptions <json-array>`\",\n  ].join(\"\\n\"),\n  const: [\n    \"**@const** `<json-literal>`\",\n    \"\",\n    \"Requires the field value to equal a single constant JSON value.\",\n    \"\",\n    \"Maps to `const` in JSON Schema.\",\n    \"\",\n    \"**Signature:** `@const [:path] <json-literal>`\",\n  ].join(\"\\n\"),\n};\n\nconst CONSTRAINT_HOVER_SUMMARIES: Record<BuiltinConstraintName, string> = {\n  minimum: \"Sets an inclusive lower bound on a numeric field.\",\n  maximum: \"Sets an inclusive upper bound on a numeric field.\",\n  exclusiveMinimum: \"Sets an exclusive lower bound on a numeric field.\",\n  exclusiveMaximum: \"Sets an exclusive upper bound on a numeric field.\",\n  multipleOf: \"Requires the numeric value to be a multiple of the given number.\",\n  minLength: \"Sets a minimum character length on a string field.\",\n  maxLength: \"Sets a maximum character length on a string field.\",\n  minItems: \"Sets a minimum number of items in an array field.\",\n  maxItems: \"Sets a maximum number of items in an array field.\",\n  uniqueItems: \"Requires all items in an array field to be distinct.\",\n  pattern: \"Sets a regular expression pattern that a string field must match.\",\n  enumOptions: \"Specifies the allowed values for an enum field as an inline JSON array.\",\n  const: \"Requires the field value to equal a single constant JSON value.\",\n};\n\ntype SupportedSignatureTarget = Exclude<FormSpecTargetKind, \"none\">;\n\ninterface ExtraTagSpec {\n  readonly requiresArgument: boolean;\n  readonly supportedTargets: readonly FormSpecTargetKind[];\n  readonly allowDuplicates: boolean;\n  readonly category: FormSpecTagCategory;\n  readonly placements: readonly FormSpecPlacement[];\n  readonly inheritFromBase?: AnnotationInheritancePolicy;\n  readonly completionDetail: string;\n  readonly hoverSummary: string;\n  readonly valueKind?: FormSpecValueKind | null;\n  readonly valueLabel?: string;\n  readonly targetPlacements?: Partial<\n    Record<SupportedSignatureTarget, readonly FormSpecPlacement[]>\n  >;\n}\n\nfunction inferValueKind(name: string): FormSpecValueKind | null {\n  if (INTEGER_VALUE_TAGS.has(name)) return \"integer\";\n  if (SIGNED_INTEGER_VALUE_TAGS.has(name)) return \"signedInteger\";\n  if (JSON_VALUE_TAGS.has(name)) return \"json\";\n  if (BOOLEAN_VALUE_TAGS.has(name)) return \"boolean\";\n  if (STRING_VALUE_TAGS.has(name)) return \"string\";\n  if (CONDITION_VALUE_TAGS.has(name)) return \"condition\";\n  return null;\n}\n\nfunction getBuiltinValueKind(name: BuiltinConstraintName): FormSpecValueKind {\n  return inferValueKind(name) ?? \"number\";\n}\n\nfunction getBuiltinConstraintCapability(name: BuiltinConstraintName): SemanticCapability {\n  switch (name) {\n    case \"minimum\":\n    case \"maximum\":\n    case \"exclusiveMinimum\":\n    case \"exclusiveMaximum\":\n    case \"multipleOf\":\n      return \"numeric-comparable\";\n    case \"minLength\":\n    case \"maxLength\":\n    case \"pattern\":\n      return \"string-like\";\n    case \"minItems\":\n    case \"maxItems\":\n    case \"uniqueItems\":\n      return \"array-like\";\n    case \"enumOptions\":\n      return \"enum-member-addressable\";\n    case \"const\":\n      return \"json-like\";\n    default: {\n      const exhaustive: never = name;\n      return exhaustive;\n    }\n  }\n}\n\nfunction capabilitiesForValueKind(\n  valueKind: FormSpecValueKind | null\n): readonly [SemanticCapability] | readonly [] {\n  switch (valueKind) {\n    case \"number\":\n    case \"integer\":\n    case \"signedInteger\":\n      return [\"numeric-comparable\"] as const;\n    case \"string\":\n      return [\"string-like\"] as const;\n    case \"json\":\n      return [\"json-like\"] as const;\n    case \"condition\":\n      return [\"condition-like\"] as const;\n    case \"boolean\":\n    case null:\n      return [] as const;\n    default: {\n      const exhaustive: never = valueKind;\n      return exhaustive;\n    }\n  }\n}\n\nfunction valueLabelForKind(valueKind: FormSpecValueKind | null, fallback = \"<value>\"): string {\n  switch (valueKind) {\n    case \"number\":\n      return \"<number>\";\n    case \"integer\":\n    case \"signedInteger\":\n      return \"<integer>\";\n    case \"string\":\n      return \"<text>\";\n    case \"json\":\n      return \"<json>\";\n    case \"condition\":\n      return \"<condition>\";\n    case \"boolean\":\n    case null:\n      return \"\";\n    default: {\n      const exhaustive: never = valueKind;\n      void exhaustive;\n      return fallback;\n    }\n  }\n}\n\nfunction targetLabelForKind(kind: SupportedSignatureTarget): string {\n  switch (kind) {\n    case \"path\":\n      return \"[:path]\";\n    case \"member\":\n      return \":member\";\n    case \"variant\":\n      return \":variant\";\n    default: {\n      const exhaustive: never = kind;\n      return exhaustive;\n    }\n  }\n}\n\nfunction parameterKindForTarget(\n  targetKind: SupportedSignatureTarget\n): TagSignatureParameter[\"kind\"] {\n  switch (targetKind) {\n    case \"path\":\n      return \"target-path\";\n    case \"member\":\n      return \"target-member\";\n    case \"variant\":\n      return \"target-variant\";\n    default: {\n      const exhaustive: never = targetKind;\n      return exhaustive;\n    }\n  }\n}\n\nfunction createTargetParameter(\n  targetKind: SupportedSignatureTarget,\n  valueKind: FormSpecValueKind | null,\n  pathCapability?: SemanticCapability\n): TagSignatureParameter {\n  const base: TagSignatureParameter = {\n    kind: parameterKindForTarget(targetKind),\n    label: targetLabelForKind(targetKind),\n    optional: targetKind === \"path\",\n  };\n\n  if (targetKind === \"path\") {\n    const capability = pathCapability ?? capabilitiesForValueKind(valueKind)[0];\n    return capability === undefined ? base : { ...base, capability };\n  }\n\n  if (targetKind === \"member\") {\n    return { ...base, capability: \"enum-member-addressable\" };\n  }\n\n  return base;\n}\n\nfunction createSignature(\n  name: string,\n  placements: readonly FormSpecPlacement[],\n  targetKind: SupportedSignatureTarget | null,\n  valueKind: FormSpecValueKind | null,\n  valueLabel: string,\n  pathCapability?: SemanticCapability\n): TagSignature {\n  const parameters: TagSignatureParameter[] = [];\n\n  if (targetKind !== null) {\n    parameters.push(createTargetParameter(targetKind, valueKind, pathCapability));\n  }\n  if (valueLabel !== \"\") {\n    parameters.push(\n      valueKind === null\n        ? {\n            kind: \"value\",\n            label: valueLabel,\n          }\n        : {\n            kind: \"value\",\n            label: valueLabel,\n            valueKind,\n          }\n    );\n  }\n\n  const targetLabel = targetKind === null ? \"\" : ` ${targetLabelForKind(targetKind)}`;\n  const valueLabelSuffix = valueLabel === \"\" ? \"\" : ` ${valueLabel}`;\n\n  return {\n    label: `@${name}${targetLabel}${valueLabelSuffix}`,\n    placements,\n    parameters,\n  };\n}\n\nfunction buildHoverMarkdown(\n  name: string,\n  hoverSummary: string,\n  signatures: readonly TagSignature[],\n  valueLabel: string\n): string {\n  const header = valueLabel === \"\" ? `**@${name}**` : `**@${name}** \\`${valueLabel}\\``;\n  const signatureLines =\n    signatures.length === 1\n      ? [`**Signature:** \\`${signatures[0]?.label ?? `@${name}`}\\``]\n      : [\"**Signatures:**\", ...signatures.map((signature) => `- \\`${signature.label}\\``)];\n\n  return [header, \"\", hoverSummary, \"\", ...signatureLines].join(\"\\n\");\n}\n\nfunction makeConstraintSignatures(name: BuiltinConstraintName): readonly TagSignature[] {\n  const valueKind = getBuiltinValueKind(name);\n  const subjectCapability = getBuiltinConstraintCapability(name);\n  const valueLabel =\n    name === \"pattern\"\n      ? \"<regex>\"\n      : name === \"enumOptions\"\n        ? \"<json-array>\"\n        : name === \"const\"\n          ? \"<json-literal>\"\n          : valueLabelForKind(valueKind);\n\n  return [\n    createSignature(name, FIELD_PLACEMENTS, null, valueKind, valueLabel),\n    createSignature(name, FIELD_PLACEMENTS, \"path\", valueKind, valueLabel, subjectCapability),\n  ];\n}\n\nconst BUILTIN_TAG_DEFINITIONS = Object.fromEntries(\n  (Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS) as BuiltinConstraintName[]).map((name) => {\n    const valueKind = getBuiltinValueKind(name);\n    const subjectCapability = getBuiltinConstraintCapability(name);\n    return [\n      name,\n      {\n        canonicalName: name,\n        valueKind,\n        requiresArgument: valueKind !== \"boolean\",\n        supportedTargets: [\"none\", \"path\"] as const,\n        allowDuplicates: false,\n        category: \"constraint\" as const,\n        placements: FIELD_PLACEMENTS,\n        capabilities: [subjectCapability] as const,\n        completionDetail: CONSTRAINT_COMPLETION_DETAIL[name] ?? `@${name}`,\n        hoverSummary: CONSTRAINT_HOVER_SUMMARIES[name],\n        hoverMarkdown: CONSTRAINT_HOVER_DOCS[name] ?? `**@${name}**`,\n        signatures: makeConstraintSignatures(name),\n      } satisfies TagDefinition,\n    ];\n  })\n) as Record<string, TagDefinition>;\n\nconst EXTRA_TAG_SPECS = {\n  displayName: {\n    requiresArgument: true,\n    supportedTargets: [\"none\", \"member\", \"variant\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],\n    completionDetail: \"Display label for a type, field, or enum member.\",\n    hoverSummary: \"Provides a user-facing display label.\",\n    valueLabel: \"<label>\",\n    targetPlacements: {\n      member: FIELD_PLACEMENTS,\n      variant: TYPE_PLACEMENTS,\n    },\n  },\n  format: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: FIELD_PLACEMENTS,\n    inheritFromBase: \"local-wins\",\n    completionDetail: \"Format hint for a field.\",\n    hoverSummary: \"Provides a format hint for a field.\",\n    valueLabel: \"<format>\",\n  },\n  placeholder: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Placeholder text for a field.\",\n    hoverSummary: \"Provides placeholder text for a field.\",\n  },\n  order: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Field display order hint.\",\n    hoverSummary: \"Provides an integer ordering hint for UI layout.\",\n  },\n  apiName: {\n    requiresArgument: true,\n    supportedTargets: [\"none\", \"member\", \"variant\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],\n    completionDetail: \"API-facing serialized name for a type, field, or variant.\",\n    hoverSummary: \"Overrides the serialized API name used in generated schema output.\",\n    valueLabel: \"<identifier>\",\n    targetPlacements: {\n      member: FIELD_PLACEMENTS,\n      variant: TYPE_PLACEMENTS,\n    },\n  },\n  group: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"structure\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Assigns a field to a UI group.\",\n    hoverSummary: \"Assigns the field to a named grouping container.\",\n    valueLabel: \"<group>\",\n  },\n  showWhen: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"structure\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Conditional visibility rule.\",\n    hoverSummary: \"Shows the field only when the condition is satisfied.\",\n  },\n  hideWhen: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"structure\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Conditional visibility suppression rule.\",\n    hoverSummary: \"Hides the field when the condition is satisfied.\",\n  },\n  enableWhen: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"structure\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Conditional interactivity rule.\",\n    hoverSummary: \"Enables the field only when the condition is satisfied.\",\n  },\n  disableWhen: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"structure\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Conditional disablement rule.\",\n    hoverSummary: \"Disables the field when the condition is satisfied.\",\n  },\n  defaultValue: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"ecosystem\",\n    placements: FIELD_PLACEMENTS,\n    completionDetail: \"Default JSON value for a field.\",\n    hoverSummary: \"Provides a default JSON value for ecosystem integrations.\",\n    valueLabel: \"<value>\",\n  },\n  deprecated: {\n    requiresArgument: false,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"ecosystem\",\n    placements: ALL_PLACEMENTS,\n    inheritFromBase: \"local-wins\",\n    completionDetail: \"Marks a declaration as deprecated.\",\n    hoverSummary: \"Marks the declaration as deprecated.\",\n  },\n  example: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"ecosystem\",\n    placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],\n    completionDetail: \"Example serialized value.\",\n    hoverSummary: \"Provides an example value for documentation and tooling.\",\n  },\n  discriminator: {\n    requiresArgument: true,\n    supportedTargets: [\"path\"],\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: TYPE_PLACEMENTS,\n    completionDetail: \"Declare a discriminator field for a generic object type.\",\n    hoverSummary: \"Declares the field used as the discriminator for a generic object type.\",\n    valueLabel: \"<typeParam>\",\n  },\n  remarks: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: false,\n    category: \"ecosystem\",\n    placements: ALL_PLACEMENTS,\n    completionDetail: \"Additional remarks text.\",\n    hoverSummary: \"Provides additional remarks for the declaration.\",\n  },\n  see: {\n    requiresArgument: true,\n    supportedTargets: [\"none\"],\n    allowDuplicates: true,\n    category: \"ecosystem\",\n    placements: ALL_PLACEMENTS,\n    completionDetail: \"Reference to related documentation.\",\n    hoverSummary: \"References related documentation or declarations.\",\n    valueLabel: \"<reference>\",\n  },\n} as const satisfies Record<string, ExtraTagSpec>;\n\nfunction buildExtraTagDefinition(canonicalName: string, spec: ExtraTagSpec): TagDefinition {\n  const valueKind = spec.valueKind ?? inferValueKind(canonicalName);\n  const valueLabel = spec.requiresArgument ? (spec.valueLabel ?? valueLabelForKind(valueKind)) : \"\";\n  const signatures: TagSignature[] = [];\n\n  if (spec.supportedTargets.includes(\"none\")) {\n    signatures.push(createSignature(canonicalName, spec.placements, null, valueKind, valueLabel));\n  }\n  if (spec.supportedTargets.includes(\"path\")) {\n    signatures.push(\n      createSignature(\n        canonicalName,\n        spec.targetPlacements?.path ?? spec.placements,\n        \"path\",\n        valueKind,\n        valueLabel\n      )\n    );\n  }\n  if (spec.supportedTargets.includes(\"member\")) {\n    signatures.push(\n      createSignature(\n        canonicalName,\n        spec.targetPlacements?.member ?? spec.placements,\n        \"member\",\n        valueKind,\n        valueLabel\n      )\n    );\n  }\n  if (spec.supportedTargets.includes(\"variant\")) {\n    signatures.push(\n      createSignature(\n        canonicalName,\n        spec.targetPlacements?.variant ?? spec.placements,\n        \"variant\",\n        valueKind,\n        valueLabel\n      )\n    );\n  }\n\n  return {\n    canonicalName,\n    valueKind,\n    requiresArgument: spec.requiresArgument,\n    supportedTargets: spec.supportedTargets,\n    allowDuplicates: spec.allowDuplicates,\n    category: spec.category,\n    placements: spec.placements,\n    ...(spec.inheritFromBase === undefined ? {} : { inheritFromBase: spec.inheritFromBase }),\n    // Capabilities express a *field-type* requirement (e.g. `@minLength` needs\n    // a string-like field). Only constraint-category tags carry that meaning;\n    // annotation, structure, and ecosystem tags describe or decorate the field\n    // regardless of its type, so their value-kind must not leak into a field\n    // constraint. `EXTRA_TAG_SPECS` currently has no constraint entries, but\n    // we keep the `spec.category === \"constraint\"` check for future-proofing.\n    capabilities:\n      spec.category === \"constraint\" ? capabilitiesForValueKind(valueKind) : ([] as const),\n    completionDetail: spec.completionDetail,\n    hoverSummary: spec.hoverSummary,\n    hoverMarkdown: buildHoverMarkdown(canonicalName, spec.hoverSummary, signatures, valueLabel),\n    signatures,\n  };\n}\n\nfunction placementsForMetadataDeclarationKinds(\n  declarationKinds: readonly MetadataDeclarationKind[]\n): readonly FormSpecPlacement[] {\n  const placements = new Set<FormSpecPlacement>();\n\n  for (const declarationKind of declarationKinds) {\n    switch (declarationKind) {\n      case \"type\":\n        for (const placement of TYPE_PLACEMENTS) {\n          placements.add(placement);\n        }\n        break;\n      case \"field\":\n        for (const placement of FIELD_PLACEMENTS) {\n          placements.add(placement);\n        }\n        break;\n      case \"method\":\n        placements.add(\"class-method\");\n        placements.add(\"function\");\n        break;\n      default: {\n        const _exhaustive: never = declarationKind;\n        return _exhaustive;\n      }\n    }\n  }\n\n  return [...placements];\n}\n\nfunction buildExtensionMetadataTagDefinition(\n  extensionId: string,\n  slot: MetadataSlotRegistration\n): TagDefinition {\n  const canonicalName = normalizeFormSpecTagName(slot.tagName);\n  const supportsQualifiers = (slot.qualifiers?.length ?? 0) > 0;\n  if (slot.allowBare === false && !supportsQualifiers) {\n    throw new Error(\n      `Metadata tag \"@${canonicalName}\" must allow bare usage or declare at least one qualifier.`\n    );\n  }\n  const supportedTargets: readonly FormSpecTargetKind[] = supportsQualifiers\n    ? slot.allowBare === false\n      ? [\"variant\"]\n      : [\"none\", \"variant\"]\n    : slot.allowBare === false\n      ? []\n      : [\"none\"];\n  const placements = placementsForMetadataDeclarationKinds(slot.declarationKinds);\n  const signatures: TagSignature[] = [];\n  const valueKind = \"string\";\n\n  if (supportedTargets.includes(\"none\")) {\n    signatures.push(createSignature(canonicalName, placements, null, valueKind, \"<value>\"));\n  }\n  if (supportedTargets.includes(\"variant\")) {\n    signatures.push(createSignature(canonicalName, placements, \"variant\", valueKind, \"<value>\"));\n  }\n\n  return {\n    canonicalName,\n    valueKind,\n    requiresArgument: true,\n    supportedTargets,\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements,\n    // Extension metadata tags are always annotations — they attach a typed\n    // value to a declaration without constraining the declaration's type.\n    // See `buildExtraTagDefinition` for the rationale.\n    capabilities: [] as const,\n    completionDetail: `Extension metadata tag from ${extensionId}`,\n    hoverSummary: `Extension-defined metadata tag from \\`${extensionId}\\`.`,\n    hoverMarkdown: [\n      `**@${canonicalName}** \\`<value>\\``,\n      \"\",\n      `Extension-defined metadata tag from \\`${extensionId}\\`.`,\n      \"\",\n      signatures.map((signature) => `**Signature:** \\`${signature.label}\\``).join(\"\\n\"),\n    ].join(\"\\n\"),\n    signatures,\n  };\n}\n\nfunction buildExtensionAnnotationTagDefinition(\n  annotation: ExtensionAnnotationTagSource\n): TagDefinition {\n  const canonicalName = normalizeFormSpecTagName(annotation.annotationName);\n  const valueKind = \"string\";\n  const payloadLabel = annotation.tagDocumentation?.payloadLabel ?? \"<payload>\";\n  const signatures = [\n    createSignature(canonicalName, ALL_PLACEMENTS, null, valueKind, payloadLabel),\n  ] as const satisfies readonly TagSignature[];\n  const hoverSummary = annotation.tagDocumentation?.hoverSummary ?? \"\";\n  const hoverMarkdown =\n    annotation.tagDocumentation?.hoverMarkdown ??\n    [\n      `**@${canonicalName}** \\`${payloadLabel}\\``,\n      \"\",\n      `**Signature:** \\`@${canonicalName} ${payloadLabel}\\``,\n    ].join(\"\\n\");\n\n  return {\n    canonicalName,\n    valueKind,\n    requiresArgument: true,\n    supportedTargets: [\"none\"] as const,\n    allowDuplicates: false,\n    category: \"annotation\",\n    placements: ALL_PLACEMENTS,\n    ...(annotation.inheritFromBase === undefined\n      ? {}\n      : { inheritFromBase: annotation.inheritFromBase }),\n    capabilities: [] as const,\n    completionDetail: annotation.tagDocumentation?.completionDetail ?? \"\",\n    hoverSummary,\n    hoverMarkdown,\n    signatures,\n  };\n}\n\nconst EXTRA_TAG_DEFINITIONS: Record<string, TagDefinition> = Object.fromEntries(\n  Object.entries(EXTRA_TAG_SPECS).map(([canonicalName, spec]) => [\n    canonicalName,\n    buildExtraTagDefinition(canonicalName, spec),\n  ])\n);\n\nlet defaultInheritableAnnotationKeys: ReadonlySet<string> | undefined;\nconst inheritableAnnotationKeysByExtensionArray = new WeakMap<\n  readonly ExtensionTagSource[],\n  ReadonlySet<string>\n>();\n\nexport function normalizeFormSpecTagName(rawName: string): string {\n  return normalizeConstraintTagName(rawName);\n}\n\nfunction getCustomAnnotationInheritanceKey(extensionId: string, annotationName: string): string {\n  return `custom:${extensionId}/${annotationName}`;\n}\n\nfunction buildInheritableAnnotationKeys(\n  extensions?: readonly ExtensionTagSource[]\n): ReadonlySet<string> {\n  const keys = new Set<string>();\n  for (const definition of Object.values(EXTRA_TAG_DEFINITIONS)) {\n    if (!doesInheritFromBase(definition.inheritFromBase)) continue;\n    keys.add(definition.canonicalName);\n  }\n  for (const annotation of getExtensionAnnotationTags(extensions)) {\n    if (!doesInheritFromBase(annotation.annotation.inheritFromBase)) continue;\n    keys.add(\n      getCustomAnnotationInheritanceKey(\n        annotation.extensionId,\n        annotation.annotation.annotationName\n      )\n    );\n  }\n  return keys;\n}\n\nfunction doesInheritFromBase(policy: AnnotationInheritancePolicy | undefined): boolean {\n  const effectivePolicy = policy ?? \"never\";\n  switch (effectivePolicy) {\n    case \"local-wins\":\n      return true;\n    case \"never\":\n      return false;\n    default:\n      throw new UnreachableError(\n        effectivePolicy,\n        `Unsupported annotation inheritance policy: ${String(effectivePolicy)}`\n      );\n  }\n}\n\nexport function getInheritableAnnotationKeys(\n  extensions?: readonly ExtensionTagSource[]\n): ReadonlySet<string> {\n  if (extensions === undefined) {\n    defaultInheritableAnnotationKeys ??= buildInheritableAnnotationKeys();\n    return defaultInheritableAnnotationKeys;\n  }\n\n  const cached = inheritableAnnotationKeysByExtensionArray.get(extensions);\n  if (cached !== undefined) return cached;\n\n  const next = buildInheritableAnnotationKeys(extensions);\n  inheritableAnnotationKeysByExtensionArray.set(extensions, next);\n  return next;\n}\n\n/**\n * Reads the extension registry that FormSpec integrations place in settings.\n *\n * ESLint, the TypeScript plugin, and the language server all receive this value\n * through a weakly typed host boundary, so the shared analysis layer owns the\n * defensive object checks instead of each consumer casting settings locally.\n */\nexport function readExtensionRegistryFromSettings(\n  settings: Readonly<Record<string, unknown>>\n): SettingsExtensionRegistry | undefined {\n  const formspec = settings[\"formspec\"];\n  if (typeof formspec !== \"object\" || formspec === null) return undefined;\n  const registry = (formspec as Record<string, unknown>)[\"extensionRegistry\"];\n  if (typeof registry !== \"object\" || registry === null) return undefined;\n\n  const record = registry as Record<string, unknown>;\n  const extensions = record[\"extensions\"];\n  const findTypeByName = record[\"findTypeByName\"];\n  const findBuiltinConstraintBroadening = record[\"findBuiltinConstraintBroadening\"];\n  const validShape =\n    (extensions === undefined ||\n      (Array.isArray(extensions) && extensions.every(isSettingsExtensionDefinition))) &&\n    (findTypeByName === undefined || typeof findTypeByName === \"function\") &&\n    (findBuiltinConstraintBroadening === undefined ||\n      typeof findBuiltinConstraintBroadening === \"function\");\n\n  if (validShape) {\n    return registry as SettingsExtensionRegistry;\n  }\n\n  return {\n    ...(Array.isArray(extensions)\n      ? { extensions: extensions.filter(isSettingsExtensionDefinition) }\n      : {}),\n    ...(typeof findTypeByName === \"function\"\n      ? {\n          findTypeByName: findTypeByName as NonNullable<\n            SettingsExtensionRegistry[\"findTypeByName\"]\n          >,\n        }\n      : {}),\n    ...(typeof findBuiltinConstraintBroadening === \"function\"\n      ? {\n          findBuiltinConstraintBroadening: findBuiltinConstraintBroadening as NonNullable<\n            SettingsExtensionRegistry[\"findBuiltinConstraintBroadening\"]\n          >,\n        }\n      : {}),\n  };\n}\n\n/**\n * Strips a leading `@` from a tag name before applying FormSpec's shared tag\n * normalization. Extension registries can store names in either spelling, while\n * parsed comments use normalized names without the TSDoc prefix.\n */\nfunction normalizeExtensionTagName(rawName: string): string {\n  const stripped = rawName.startsWith(\"@\") ? rawName.slice(1) : rawName;\n  return normalizeFormSpecTagName(stripped);\n}\n\nfunction readRegisteredExtensionTagName(record: unknown, propertyName: string): string | null {\n  if (typeof record !== \"object\" || record === null) return null;\n  const rawName = (record as Record<string, unknown>)[propertyName];\n  return typeof rawName === \"string\" ? normalizeExtensionTagName(rawName) : null;\n}\n\nfunction isSettingsExtensionDefinition(value: unknown): value is SettingsExtensionDefinition {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readArrayProperty(\n  record: SettingsExtensionDefinition,\n  propertyName: string\n): readonly unknown[] {\n  const value = (record as Record<string, unknown>)[propertyName];\n  return Array.isArray(value) ? value : [];\n}\n\nfunction readExtensionDefinitionTagNames(\n  extension: SettingsExtensionDefinition\n): readonly string[] {\n  const names: string[] = [];\n  for (const tag of readArrayProperty(extension, \"constraintTags\")) {\n    const name = readRegisteredExtensionTagName(tag, \"tagName\");\n    if (name !== null) names.push(name);\n  }\n  for (const slot of readArrayProperty(extension, \"metadataSlots\")) {\n    const name = readRegisteredExtensionTagName(slot, \"tagName\");\n    if (name !== null) names.push(name);\n  }\n  for (const annotation of readArrayProperty(extension, \"annotations\")) {\n    const name = readRegisteredExtensionTagName(annotation, \"annotationName\");\n    if (name !== null) names.push(name);\n  }\n  return names;\n}\n\nconst RESERVED_UNSUPPORTED_TAG_NAMES = new Set([\"description\"]);\n\n/**\n * Reads every tag name registered by extensions in FormSpec settings.\n *\n * Constraint tags, metadata slots, and annotations store their names under\n * different property names; callers should treat them as one extension-defined\n * tag-name set. Malformed settings entries are ignored so host tooling never\n * crashes while linting partially configured projects.\n */\nexport function readExtensionTagNames(\n  settings: Readonly<Record<string, unknown>>\n): ReadonlySet<string> {\n  const registry = readExtensionRegistryFromSettings(settings);\n  const extensions =\n    registry === undefined ? undefined : (registry as Record<string, unknown>)[\"extensions\"];\n  if (!Array.isArray(extensions)) return new Set();\n\n  const names = new Set<string>();\n  for (const extension of extensions) {\n    if (!isSettingsExtensionDefinition(extension)) continue;\n    for (const name of readExtensionDefinitionTagNames(extension)) {\n      names.add(name);\n    }\n  }\n  return names;\n}\n\nexport function getTagDefinition(\n  rawName: string,\n  extensions?: readonly ExtensionTagSource[]\n): TagDefinition | null {\n  const normalized = normalizeFormSpecTagName(rawName);\n  if (RESERVED_UNSUPPORTED_TAG_NAMES.has(normalized)) {\n    return null;\n  }\n\n  const builtin = BUILTIN_TAG_DEFINITIONS[normalized];\n  if (builtin !== undefined) {\n    return builtin;\n  }\n\n  const extra = EXTRA_TAG_DEFINITIONS[normalized];\n  if (extra !== undefined) {\n    return extra;\n  }\n\n  const extensionRegistration = getExtensionConstraintTags(extensions).find(\n    (tag) => tag.tagName === normalized\n  );\n\n  if (extensionRegistration !== undefined) {\n    return {\n      canonicalName: extensionRegistration.tagName,\n      valueKind: null,\n      requiresArgument: true,\n      supportedTargets: [\"none\"] as const,\n      allowDuplicates: true,\n      category: \"constraint\",\n      placements: FIELD_PLACEMENTS,\n      capabilities: [] as const,\n      completionDetail: `Extension constraint tag from ${extensionRegistration.extensionId}`,\n      hoverSummary: `Extension-defined constraint tag from \\`${extensionRegistration.extensionId}\\`.`,\n      hoverMarkdown: [\n        `**@${extensionRegistration.tagName}** \\`<value>\\``,\n        \"\",\n        `Extension-defined constraint tag from \\`${extensionRegistration.extensionId}\\`.`,\n        \"\",\n        `**Signature:** \\`@${extensionRegistration.tagName} <value>\\``,\n      ].join(\"\\n\"),\n      signatures: [\n        {\n          label: `@${extensionRegistration.tagName} <value>`,\n          placements: FIELD_PLACEMENTS,\n          parameters: [{ kind: \"value\", label: \"<value>\" }],\n        },\n      ],\n    };\n  }\n\n  const extensionAnnotation = getExtensionAnnotationTags(extensions).find(\n    (annotation) => annotation.tagName === normalized\n  );\n\n  if (extensionAnnotation !== undefined) {\n    return buildExtensionAnnotationTagDefinition(extensionAnnotation.annotation);\n  }\n\n  const extensionMetadata = getExtensionMetadataSlots(extensions).find(\n    (slot) => slot.tagName === normalized\n  );\n  return extensionMetadata === undefined\n    ? null\n    : buildExtensionMetadataTagDefinition(extensionMetadata.extensionId, extensionMetadata.slot);\n}\n\nexport function getConstraintTagDefinitions(\n  extensions?: readonly ExtensionTagSource[]\n): readonly TagDefinition[] {\n  const builtins = Object.values(BUILTIN_TAG_DEFINITIONS);\n  const custom = getExtensionConstraintTags(extensions)\n    .map((tag) => getTagDefinition(tag.tagName, extensions))\n    .filter((tag): tag is TagDefinition => tag !== null);\n  return [...builtins, ...custom];\n}\n\nexport function getAllTagDefinitions(\n  extensions?: readonly ExtensionTagSource[]\n): readonly TagDefinition[] {\n  const builtins = Object.values(BUILTIN_TAG_DEFINITIONS);\n  const extras = Object.values(EXTRA_TAG_DEFINITIONS);\n  const custom = getExtensionConstraintTags(extensions)\n    .map((tag) => getTagDefinition(tag.tagName, extensions))\n    .filter((tag): tag is TagDefinition => tag !== null);\n  const customMetadata = getExtensionMetadataSlots(extensions)\n    .map((slot) => getTagDefinition(slot.tagName, extensions))\n    .filter((tag): tag is TagDefinition => tag !== null);\n  const customAnnotations = getExtensionAnnotationTags(extensions)\n    .map((annotation) => getTagDefinition(annotation.tagName, extensions))\n    .filter((tag): tag is TagDefinition => tag !== null);\n  return [...builtins, ...extras, ...custom, ...customMetadata, ...customAnnotations];\n}\n\nexport function getTagHoverMarkdown(\n  rawName: string,\n  extensions?: readonly ExtensionTagSource[]\n): string | null {\n  return getTagDefinition(rawName, extensions)?.hoverMarkdown ?? null;\n}\n\nfunction getExtensionConstraintTags(\n  extensions: readonly ExtensionTagSource[] | undefined\n): readonly { extensionId: string; tagName: string }[] {\n  return (\n    extensions?.flatMap((extension) => {\n      const tagRecords = extension.constraintTags ?? [];\n      return tagRecords.map((tag) => ({\n        extensionId: extension.extensionId,\n        tagName: normalizeFormSpecTagName(tag.tagName),\n      }));\n    }) ?? []\n  );\n}\n\nfunction getExtensionMetadataSlots(\n  extensions: readonly ExtensionTagSource[] | undefined\n): readonly { extensionId: string; tagName: string; slot: MetadataSlotRegistration }[] {\n  return (\n    extensions?.flatMap((extension) =>\n      (extension.metadataSlots ?? []).map((slot) => ({\n        extensionId: extension.extensionId,\n        tagName: normalizeFormSpecTagName(slot.tagName),\n        slot,\n      }))\n    ) ?? []\n  );\n}\n\nfunction getExtensionAnnotationTags(\n  extensions: readonly ExtensionTagSource[] | undefined\n): readonly {\n  extensionId: string;\n  tagName: string;\n  annotation: ExtensionAnnotationTagSource;\n}[] {\n  if (extensions === undefined) return [];\n\n  const seenTags = new Set<string>();\n  const tags: {\n    extensionId: string;\n    tagName: string;\n    annotation: ExtensionAnnotationTagSource;\n  }[] = [];\n  for (const extension of extensions) {\n    for (const annotation of extension.annotations ?? []) {\n      const tagName = normalizeFormSpecTagName(annotation.annotationName);\n      if (seenTags.has(tagName)) {\n        throw new Error(`Duplicate annotation tag: \"@${tagName}\"`);\n      }\n      seenTags.add(tagName);\n      tags.push({\n        extensionId: extension.extensionId,\n        tagName,\n        annotation,\n      });\n    }\n  }\n  return tags;\n}\n","import type {\n  CommentSpan,\n  ParsedCommentTag,\n  ParsedCommentTargetSpecifier,\n} from \"./comment-syntax.js\";\nimport type {\n  CommentHoverInfo,\n  CommentTagSemanticContext,\n  SemanticCommentCompletionContext,\n} from \"./cursor-context.js\";\nimport {\n  FORM_SPEC_PLACEMENTS,\n  FORM_SPEC_TARGET_KINDS,\n  type FormSpecPlacement,\n  type FormSpecTargetKind,\n} from \"./tag-registry.js\";\n\n/**\n * Version of the transport protocol shared by analysis producers and consumers.\n *\n * @public\n */\nexport const FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 4;\n/**\n * Version of the serialized analysis payload schema.\n *\n * @public\n */\nexport const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 2;\n\n/**\n * Serializable source details for one explicit metadata value.\n *\n * @public\n */\nexport interface FormSpecSerializedExplicitMetadataSource {\n  /** Tag name associated with the explicit value, without the `@` prefix. */\n  readonly tagName: string;\n  /** Whether the explicit value used a bare or qualified tag form. */\n  readonly form: \"bare\" | \"qualified\";\n  /** Full range covering the explicit tag occurrence. */\n  readonly fullRange: CommentSpan;\n  /** Range covering only the tag name token. */\n  readonly tagNameRange: CommentSpan;\n  /** Range covering the qualifier text, when present. */\n  readonly qualifierRange?: CommentSpan | undefined;\n  /** Range covering only the explicit value text. */\n  readonly valueRange: CommentSpan;\n  /** Qualifier text without the leading colon, when present. */\n  readonly qualifier?: string | undefined;\n}\n\n/**\n * Serializable scalar metadata value plus its provenance.\n *\n * @public\n */\nexport interface FormSpecSerializedResolvedScalarMetadata {\n  /** Effective metadata value after policy resolution. */\n  readonly value: string;\n  /** Whether the value was authored directly or inferred. */\n  readonly source: \"explicit\" | \"inferred\";\n}\n\n/**\n * Serializable built-in metadata projection for one declaration.\n *\n * @public\n */\nexport interface FormSpecSerializedResolvedMetadata {\n  /** Effective JSON-facing singular name. */\n  readonly apiName?: FormSpecSerializedResolvedScalarMetadata | undefined;\n  /** Effective human-facing singular label. */\n  readonly displayName?: FormSpecSerializedResolvedScalarMetadata | undefined;\n  /** Effective JSON-facing plural name, where applicable. */\n  readonly apiNamePlural?: FormSpecSerializedResolvedScalarMetadata | undefined;\n  /** Effective human-facing plural label, where applicable. */\n  readonly displayNamePlural?: FormSpecSerializedResolvedScalarMetadata | undefined;\n}\n\n/**\n * Serializable metadata slot resolution for one declaration.\n *\n * @public\n */\nexport interface FormSpecSerializedMetadataEntry {\n  /** Stable logical slot identifier. */\n  readonly slotId: string;\n  /** Tag name associated with the slot, without the `@` prefix. */\n  readonly tagName: string;\n  /** Optional qualifier text without the leading colon. */\n  readonly qualifier?: string | undefined;\n  /** Effective value after explicit/inferred resolution. */\n  readonly value: string;\n  /** Whether the value was authored directly or inferred. */\n  readonly source: \"explicit\" | \"inferred\";\n  /** Fixer-oriented source details when the winning value was explicit. */\n  readonly explicitSource?: FormSpecSerializedExplicitMetadataSource | undefined;\n}\n\n/**\n * JSON-safe value carried by declaration summary facts.\n *\n * @public\n */\nexport type FormSpecSerializedJsonValue =\n  | string\n  | number\n  | boolean\n  | null\n  | readonly FormSpecSerializedJsonValue[]\n  | { readonly [key: string]: FormSpecSerializedJsonValue };\n\n/**\n * Structured declaration-level fact derived from one or more comment tags.\n *\n * @public\n */\nexport type FormSpecSerializedDeclarationFact =\n  | {\n      /** Summary text attached to the declaration body before the first tag. */\n      readonly kind: \"description\";\n      /** Summary text rendered from the declaration doc comment. */\n      readonly value: string;\n    }\n  | {\n      /** Additional remarks text attached to the declaration. */\n      readonly kind: \"remarks\";\n      /** Remarks text as authored. */\n      readonly value: string;\n    }\n  | {\n      /** Default JSON value carried by the declaration metadata. */\n      readonly kind: \"default-value\";\n      /** Parsed JSON-safe default value. */\n      readonly value: FormSpecSerializedJsonValue;\n    }\n  | {\n      /** Example text attached to the declaration. */\n      readonly kind: \"example\";\n      /** Example text as authored. */\n      readonly value: string;\n    }\n  | {\n      /** Deprecation status for the declaration. */\n      readonly kind: \"deprecated\";\n      /** Optional deprecation guidance authored alongside the tag. */\n      readonly message: string | null;\n    }\n  | {\n      /** Combined numeric constraints for one declaration target. */\n      readonly kind: \"numeric-constraints\";\n      /** Target path receiving the constraints, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Inclusive lower bound, when present. */\n      readonly minimum?: number | undefined;\n      /** Inclusive upper bound, when present. */\n      readonly maximum?: number | undefined;\n      /** Exclusive lower bound, when present. */\n      readonly exclusiveMinimum?: number | undefined;\n      /** Exclusive upper bound, when present. */\n      readonly exclusiveMaximum?: number | undefined;\n      /** Divisibility constraint, when present. */\n      readonly multipleOf?: number | undefined;\n    }\n  | {\n      /** Combined string constraints for one declaration target. */\n      readonly kind: \"string-constraints\";\n      /** Target path receiving the constraints, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Minimum string length, when present. */\n      readonly minLength?: number | undefined;\n      /** Maximum string length, when present. */\n      readonly maxLength?: number | undefined;\n      /** Regex patterns that must all be satisfied. */\n      readonly patterns: readonly string[];\n    }\n  | {\n      /** Combined array constraints for one declaration target. */\n      readonly kind: \"array-constraints\";\n      /** Target path receiving the constraints, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Minimum item count, when present. */\n      readonly minItems?: number | undefined;\n      /** Maximum item count, when present. */\n      readonly maxItems?: number | undefined;\n      /** Whether items must be unique. */\n      readonly uniqueItems?: boolean | undefined;\n    }\n  | {\n      /** Enum/member whitelist constraint for one declaration target. */\n      readonly kind: \"allowed-members\";\n      /** Target path receiving the constraint, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Allowed member identifiers after normalization. */\n      readonly members: readonly (string | number)[];\n    }\n  | {\n      /** Constant-value constraint for one declaration target. */\n      readonly kind: \"const\";\n      /** Target path receiving the constraint, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Constant JSON-safe value. */\n      readonly value: FormSpecSerializedJsonValue;\n    }\n  | {\n      /** Extension-defined constraint fact for one declaration target. */\n      readonly kind: \"custom-constraint\";\n      /** Target path receiving the constraint, or `null` for the declaration itself. */\n      readonly targetPath: string | null;\n      /** Stable extension-qualified constraint identifier. */\n      readonly constraintId: string;\n      /** Composition rule used when combining repeated applications. */\n      readonly compositionRule: \"intersect\" | \"override\";\n      /** JSON-safe payload parsed from the authored tag. */\n      readonly payload: FormSpecSerializedJsonValue;\n    };\n\n/**\n * Public declaration-level semantic summary for one documented declaration.\n *\n * @public\n */\nexport interface FormSpecAnalysisDeclarationSummary {\n  /** Summary text attached to the declaration before the first tag, if present. */\n  readonly summaryText: string | null;\n  /** Built-in resolved metadata projected for the declaration. */\n  readonly resolvedMetadata: FormSpecSerializedResolvedMetadata | null;\n  /** Resolved metadata entries, including extension-contributed slots. */\n  readonly metadataEntries: readonly FormSpecSerializedMetadataEntry[];\n  /** Structured declaration facts derived by FormSpec. */\n  readonly facts: readonly FormSpecSerializedDeclarationFact[];\n  /** Pre-rendered markdown optimized for declaration hover surfaces. */\n  readonly hoverMarkdown: string;\n}\n\n/**\n * Cross-process endpoint used by the language server to reach the semantic\n * tsserver plugin on the current workspace host.\n *\n * @public\n */\nexport interface FormSpecIpcEndpoint {\n  /** Transport kind used to reach the semantic service. */\n  readonly kind: \"unix-socket\" | \"windows-pipe\";\n  /** Socket path or named-pipe address for the service. */\n  readonly address: string;\n}\n\n/**\n * Discovery record written by the tsserver plugin so other FormSpec tooling\n * can locate and validate the matching semantic service for a workspace.\n *\n * @public\n */\nexport interface FormSpecAnalysisManifest {\n  /** Protocol version expected by consumers of this manifest. */\n  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n  /** Schema version for the serialized analysis payload. */\n  readonly analysisSchemaVersion: typeof FORMSPEC_ANALYSIS_SCHEMA_VERSION;\n  /** Absolute root of the workspace being analyzed. */\n  readonly workspaceRoot: string;\n  /** Stable workspace identifier used for runtime artifacts. */\n  readonly workspaceId: string;\n  /** IPC endpoint for the active semantic service. */\n  readonly endpoint: FormSpecIpcEndpoint;\n  /** TypeScript version reported by the host runtime. */\n  readonly typescriptVersion: string;\n  /** Hash of the active extension set for the workspace. */\n  readonly extensionFingerprint: string;\n  /** Monotonic generation number for the manifest file. */\n  readonly generation: number;\n  /** ISO timestamp for the last manifest update. */\n  readonly updatedAt: string;\n}\n\n/**\n * Serializable subset of tag metadata needed by hover and completion UIs.\n *\n * @public\n */\nexport interface FormSpecSerializedTagDefinition {\n  /** Canonical tag name, including the leading `@`. */\n  readonly canonicalName: string;\n  /** Short completion detail shown in UI pickers. */\n  readonly completionDetail: string;\n  /** Markdown hover text for the tag name. */\n  readonly hoverMarkdown: string;\n}\n\n/**\n * Serializable overload/signature summary for one comment tag form.\n *\n * @public\n */\nexport interface FormSpecSerializedTagSignature {\n  /** Human-readable label for the signature form. */\n  readonly label: string;\n  /** Target kinds accepted by this signature. */\n  readonly placements: readonly FormSpecPlacement[];\n}\n\n/**\n * Serialized representation of a parsed target specifier with exact spans.\n *\n * @public\n */\nexport interface FormSpecSerializedCommentTargetSpecifier {\n  /** Raw target text without the leading colon. */\n  readonly rawText: string;\n  /** Whether the target parsed cleanly. */\n  readonly valid: boolean;\n  /** Classified target kind used by completion and hover. */\n  readonly kind: \"path\" | \"member\" | \"variant\" | \"ambiguous\";\n  /** Full span covering the colon and target text. */\n  readonly fullSpan: CommentSpan;\n  /** Span covering only the leading colon. */\n  readonly colonSpan: CommentSpan;\n  /** Span covering the target text after the colon. */\n  readonly span: CommentSpan;\n}\n\n/**\n * Semantic facts about one parsed tag, reduced to JSON-safe data for IPC.\n *\n * @public\n */\nexport interface FormSpecSerializedTagSemanticContext {\n  /** Tag name in canonical `@tag` form. */\n  readonly tagName: string;\n  /** Resolved tag definition, if the tag is recognized. */\n  readonly tagDefinition: FormSpecSerializedTagDefinition | null;\n  /** Placement inferred for the tag in the current comment. */\n  readonly placement: FormSpecPlacement | null;\n  /** Usage variants filtered to the active tag occurrence. */\n  readonly contextualSignatures: readonly FormSpecSerializedTagSignature[];\n  /** Target kinds supported by the tag. */\n  readonly supportedTargets: readonly FormSpecTargetKind[];\n  /** Completion candidates for tag targets. */\n  readonly targetCompletions: readonly string[];\n  /** Path targets compatible with the current cursor context. */\n  readonly compatiblePathTargets: readonly string[];\n  /** Display labels for known argument values. */\n  readonly valueLabels: readonly string[];\n  /** Completion candidates for the argument position. */\n  readonly argumentCompletions: readonly string[];\n  /** Markdown hover content for the tag in the active occurrence context. */\n  readonly contextualTagHoverMarkdown: string | null;\n  /** Summaries of the tag's overloads or signatures. */\n  readonly signatures: readonly FormSpecSerializedTagSignature[];\n  /** Markdown hover content for the tag itself. */\n  readonly tagHoverMarkdown: string | null;\n  /** Markdown hover content for the target, if applicable. */\n  readonly targetHoverMarkdown: string | null;\n  /** Markdown hover content for the argument, if applicable. */\n  readonly argumentHoverMarkdown: string | null;\n}\n\n/**\n * Cursor-scoped completion context serialized for transport between the\n * semantic tsserver plugin and the lightweight LSP.\n *\n * @public\n */\nexport type FormSpecSerializedCompletionContext =\n  | {\n      /** Completion mode indicating the cursor is on a tag name. */\n      readonly kind: \"tag-name\";\n      /** Current partially typed tag prefix. */\n      readonly prefix: string;\n      /** Tags available at the current cursor location. */\n      readonly availableTags: readonly FormSpecSerializedTagDefinition[];\n    }\n  | {\n      /** Completion mode indicating the cursor is on a target specifier. */\n      readonly kind: \"target\";\n      /** Semantic context for the active tag. */\n      readonly semantic: FormSpecSerializedTagSemanticContext;\n    }\n  | {\n      /** Completion mode indicating the cursor is in an argument position. */\n      readonly kind: \"argument\";\n      /** Semantic context for the active tag. */\n      readonly semantic: FormSpecSerializedTagSemanticContext;\n      /** Suggested value labels for argument completion. */\n      readonly valueLabels: readonly string[];\n    }\n  | {\n      /** Sentinel indicating that no FormSpec completion is available. */\n      readonly kind: \"none\";\n    };\n\n/**\n * Hover payload for a single comment token under the cursor.\n *\n * @public\n */\nexport interface FormSpecSerializedHoverInfo {\n  /** Token kind that produced this hover payload. */\n  readonly kind: \"tag-name\" | \"target\" | \"argument\" | \"declaration\";\n  /** Markdown content returned to the hover UI. */\n  readonly markdown: string;\n}\n\n/**\n * Machine-readable diagnostic category used by FormSpec tooling surfaces.\n *\n * @public\n */\nexport type FormSpecAnalysisDiagnosticCategory =\n  | \"tag-recognition\"\n  | \"value-parsing\"\n  | \"type-compatibility\"\n  | \"target-resolution\"\n  | \"constraint-validation\"\n  | \"infrastructure\";\n\n/**\n * Primitive structured values carried in diagnostic facts for white-label\n * downstream rendering.\n *\n * @public\n */\nexport type FormSpecAnalysisDiagnosticDataValue =\n  | string\n  | number\n  | boolean\n  | readonly string[]\n  | readonly number[]\n  | readonly boolean[];\n\n/**\n * Additional source location associated with a diagnostic.\n *\n * @public\n */\nexport interface FormSpecAnalysisDiagnosticLocation {\n  /** Absolute path to the related source file. */\n  readonly filePath: string;\n  /** Span associated with the related location. */\n  readonly range: CommentSpan;\n  /** Optional human-readable note for the location. */\n  readonly message?: string;\n}\n\n/**\n * File-local diagnostic derived from comment parsing or semantic analysis.\n *\n * @public\n */\nexport interface FormSpecAnalysisDiagnostic {\n  /** Stable diagnostic code for programmatic handling. */\n  readonly code: string;\n  /** Diagnostic family used by the analysis pipeline. */\n  readonly category: FormSpecAnalysisDiagnosticCategory;\n  /** Human-readable diagnostic message. */\n  readonly message: string;\n  /** Primary source span for the diagnostic. */\n  readonly range: CommentSpan;\n  /** Diagnostic severity reported to consumers. */\n  readonly severity: \"error\" | \"warning\" | \"info\";\n  /** Additional related source locations. */\n  readonly relatedLocations: readonly FormSpecAnalysisDiagnosticLocation[];\n  /** Structured diagnostic metadata. */\n  readonly data: Record<string, FormSpecAnalysisDiagnosticDataValue>;\n}\n\n/**\n * Serializable view of a single parsed FormSpec tag within a doc comment.\n *\n * @public\n */\nexport interface FormSpecAnalysisTagSnapshot {\n  /** Raw tag name as written in the comment. */\n  readonly rawTagName: string;\n  /** Normalized tag name used for lookup. */\n  readonly normalizedTagName: string;\n  /** Whether the tag was recognized by the registry. */\n  readonly recognized: boolean;\n  /** Full span covering the parsed tag. */\n  readonly fullSpan: CommentSpan;\n  /** Span of the tag name itself. */\n  readonly tagNameSpan: CommentSpan;\n  /** Span of the payload after the tag name. */\n  readonly payloadSpan: CommentSpan | null;\n  /** Parsed target specifier, if one was present. */\n  readonly target: FormSpecSerializedCommentTargetSpecifier | null;\n  /** Span covering the argument text, if present. */\n  readonly argumentSpan: CommentSpan | null;\n  /** Raw argument text. */\n  readonly argumentText: string;\n  /** Serialized semantic data for the tag. */\n  readonly semantic: FormSpecSerializedTagSemanticContext;\n}\n\n/**\n * Serializable view of one declaration-attached doc comment in a source file.\n *\n * @public\n */\nexport interface FormSpecAnalysisCommentSnapshot {\n  /** Span covering the doc comment itself. */\n  readonly commentSpan: CommentSpan;\n  /** Span covering the associated declaration. */\n  readonly declarationSpan: CommentSpan;\n  /** Where the comment was attached in relation to the declaration. */\n  readonly placement: FormSpecPlacement | null;\n  /** Resolved type of the documented subject, if known. */\n  readonly subjectType: string | null;\n  /** Resolved host type that owns the comment, if known. */\n  readonly hostType: string | null;\n  /** Declaration-level applied metadata and constraints derived by FormSpec. */\n  readonly declarationSummary: FormSpecAnalysisDeclarationSummary;\n  /** Parsed tags contained in the doc comment. */\n  readonly tags: readonly FormSpecAnalysisTagSnapshot[];\n}\n\n/**\n * Serializable analysis artifact for a single source file.\n *\n * @public\n */\nexport interface FormSpecAnalysisFileSnapshot {\n  /** Absolute path to the analyzed file. */\n  readonly filePath: string;\n  /** Stable hash of the file contents. */\n  readonly sourceHash: string;\n  /** ISO timestamp when the snapshot was generated. */\n  readonly generatedAt: string;\n  /** Parsed doc comments found in the file. */\n  readonly comments: readonly FormSpecAnalysisCommentSnapshot[];\n  /** Diagnostics emitted for the file. */\n  readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];\n}\n\n/**\n * Query variants supported by the semantic tsserver plugin.\n *\n * @public\n */\nexport type FormSpecSemanticQuery =\n  | {\n      /** Protocol version carried with every request. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Query variant requesting health/manifest information. */\n      readonly kind: \"health\";\n    }\n  | {\n      /** Protocol version carried with every request. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Query variant requesting completion context. */\n      readonly kind: \"completion\";\n      /** Absolute path of the source file. */\n      readonly filePath: string;\n      /** Zero-based cursor offset in the file. */\n      readonly offset: number;\n    }\n  | {\n      /** Protocol version carried with every request. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Query variant requesting hover information. */\n      readonly kind: \"hover\";\n      /** Absolute path of the source file. */\n      readonly filePath: string;\n      /** Zero-based cursor offset in the file. */\n      readonly offset: number;\n    }\n  | {\n      /** Protocol version carried with every request. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Query variant requesting diagnostics only. */\n      readonly kind: \"diagnostics\";\n      /** Absolute path of the source file. */\n      readonly filePath: string;\n    }\n  | {\n      /** Protocol version carried with every request. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Query variant requesting a full serialized file snapshot. */\n      readonly kind: \"file-snapshot\";\n      /** Absolute path of the source file. */\n      readonly filePath: string;\n    };\n\n/**\n * Response variants returned by the semantic tsserver plugin.\n *\n * @public\n */\nexport type FormSpecSemanticResponse =\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Response variant carrying health information. */\n      readonly kind: \"health\";\n      /** Manifest describing the active semantic service. */\n      readonly manifest: FormSpecAnalysisManifest;\n    }\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Response variant carrying completion context. */\n      readonly kind: \"completion\";\n      /** Source hash used to validate cursor data freshness. */\n      readonly sourceHash: string;\n      /** Completion context for the requested cursor position. */\n      readonly context: FormSpecSerializedCompletionContext;\n    }\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Response variant carrying hover information. */\n      readonly kind: \"hover\";\n      /** Source hash used to validate hover freshness. */\n      readonly sourceHash: string;\n      /** Hover payload, if one is available. */\n      readonly hover: FormSpecSerializedHoverInfo | null;\n    }\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Response variant carrying diagnostics. */\n      readonly kind: \"diagnostics\";\n      /** Source hash used to validate diagnostic freshness. */\n      readonly sourceHash: string;\n      /** Diagnostics for the requested file. */\n      readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];\n    }\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Response variant carrying a serialized file snapshot. */\n      readonly kind: \"file-snapshot\";\n      /** Snapshot of the requested file, if available. */\n      readonly snapshot: FormSpecAnalysisFileSnapshot | null;\n    }\n  | {\n      /** Protocol version carried with every response. */\n      readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n      /** Error response variant. */\n      readonly kind: \"error\";\n      /** Human-readable error message. */\n      readonly error: string;\n    };\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isCommentSpan(value: unknown): value is CommentSpan {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<CommentSpan>;\n  return typeof candidate.start === \"number\" && typeof candidate.end === \"number\";\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n  return Array.isArray(value) && value.every((entry) => typeof entry === \"string\");\n}\n\nfunction isNumberArray(value: unknown): value is readonly number[] {\n  return Array.isArray(value) && value.every((entry) => typeof entry === \"number\");\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n  return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isBooleanArray(value: unknown): value is readonly boolean[] {\n  return Array.isArray(value) && value.every((entry) => typeof entry === \"boolean\");\n}\n\nfunction isJsonValue(value: unknown): value is FormSpecSerializedJsonValue {\n  if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n    return true;\n  }\n\n  if (isFiniteNumber(value)) {\n    return true;\n  }\n\n  if (Array.isArray(value)) {\n    return value.every(isJsonValue);\n  }\n\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  return Object.values(value).every(isJsonValue);\n}\n\nfunction isDiagnosticDataValue(value: unknown): value is FormSpecAnalysisDiagnosticDataValue {\n  return (\n    typeof value === \"string\" ||\n    typeof value === \"number\" ||\n    typeof value === \"boolean\" ||\n    isStringArray(value) ||\n    isNumberArray(value) ||\n    isBooleanArray(value)\n  );\n}\n\nfunction isDiagnosticDataRecord(\n  value: unknown\n): value is Record<string, FormSpecAnalysisDiagnosticDataValue> {\n  return isObjectRecord(value) && Object.values(value).every(isDiagnosticDataValue);\n}\n\nconst FORM_SPEC_PLACEMENT_VALUES = new Set<FormSpecPlacement>(FORM_SPEC_PLACEMENTS);\n\nconst FORM_SPEC_TARGET_KIND_VALUES = new Set<FormSpecTargetKind>(FORM_SPEC_TARGET_KINDS);\n\nfunction isPlacementValue(value: unknown): value is FormSpecPlacement {\n  return typeof value === \"string\" && FORM_SPEC_PLACEMENT_VALUES.has(value as FormSpecPlacement);\n}\n\nfunction isTargetKindValue(value: unknown): value is FormSpecTargetKind {\n  return typeof value === \"string\" && FORM_SPEC_TARGET_KIND_VALUES.has(value as FormSpecTargetKind);\n}\n\nfunction isPlacementArray(value: unknown): value is readonly FormSpecPlacement[] {\n  return Array.isArray(value) && value.every(isPlacementValue);\n}\n\nfunction isTargetKindArray(value: unknown): value is readonly FormSpecTargetKind[] {\n  return Array.isArray(value) && value.every(isTargetKindValue);\n}\n\nfunction isDiagnosticCategory(value: unknown): value is FormSpecAnalysisDiagnosticCategory {\n  return (\n    value === \"tag-recognition\" ||\n    value === \"value-parsing\" ||\n    value === \"type-compatibility\" ||\n    value === \"target-resolution\" ||\n    value === \"constraint-validation\" ||\n    value === \"infrastructure\"\n  );\n}\n\nfunction isIpcEndpoint(value: unknown): value is FormSpecIpcEndpoint {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecIpcEndpoint>;\n  return (\n    (candidate.kind === \"unix-socket\" || candidate.kind === \"windows-pipe\") &&\n    typeof candidate.address === \"string\"\n  );\n}\n\nfunction isSerializedTagDefinition(value: unknown): value is FormSpecSerializedTagDefinition {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedTagDefinition>;\n  return (\n    typeof candidate.canonicalName === \"string\" &&\n    typeof candidate.completionDetail === \"string\" &&\n    typeof candidate.hoverMarkdown === \"string\"\n  );\n}\n\nfunction isSerializedTagSignature(value: unknown): value is FormSpecSerializedTagSignature {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedTagSignature>;\n  return typeof candidate.label === \"string\" && isPlacementArray(candidate.placements);\n}\n\nfunction isSerializedCommentTargetSpecifier(\n  value: unknown\n): value is FormSpecSerializedCommentTargetSpecifier {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedCommentTargetSpecifier>;\n  return (\n    typeof candidate.rawText === \"string\" &&\n    typeof candidate.valid === \"boolean\" &&\n    typeof candidate.kind === \"string\" &&\n    isCommentSpan(candidate.fullSpan) &&\n    isCommentSpan(candidate.colonSpan) &&\n    isCommentSpan(candidate.span)\n  );\n}\n\nfunction isSerializedTagSemanticContext(\n  value: unknown\n): value is FormSpecSerializedTagSemanticContext {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedTagSemanticContext>;\n  return (\n    typeof candidate.tagName === \"string\" &&\n    (candidate.tagDefinition === null || isSerializedTagDefinition(candidate.tagDefinition)) &&\n    (candidate.placement === null || isPlacementValue(candidate.placement)) &&\n    Array.isArray(candidate.contextualSignatures) &&\n    candidate.contextualSignatures.every(isSerializedTagSignature) &&\n    isTargetKindArray(candidate.supportedTargets) &&\n    isStringArray(candidate.targetCompletions) &&\n    isStringArray(candidate.compatiblePathTargets) &&\n    isStringArray(candidate.valueLabels) &&\n    isStringArray(candidate.argumentCompletions) &&\n    Array.isArray(candidate.signatures) &&\n    candidate.signatures.every(isSerializedTagSignature) &&\n    (candidate.contextualTagHoverMarkdown === null ||\n      typeof candidate.contextualTagHoverMarkdown === \"string\") &&\n    (candidate.tagHoverMarkdown === null || typeof candidate.tagHoverMarkdown === \"string\") &&\n    (candidate.targetHoverMarkdown === null || typeof candidate.targetHoverMarkdown === \"string\") &&\n    (candidate.argumentHoverMarkdown === null ||\n      typeof candidate.argumentHoverMarkdown === \"string\")\n  );\n}\n\nfunction isSerializedCompletionContext(\n  value: unknown\n): value is FormSpecSerializedCompletionContext {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedCompletionContext>;\n  if (typeof candidate.kind !== \"string\") {\n    return false;\n  }\n\n  switch (candidate.kind) {\n    case \"tag-name\":\n      return typeof candidate.prefix === \"string\" && Array.isArray(candidate.availableTags)\n        ? candidate.availableTags.every(isSerializedTagDefinition)\n        : false;\n    case \"target\":\n      return isSerializedTagSemanticContext(candidate.semantic);\n    case \"argument\":\n      return (\n        isSerializedTagSemanticContext(candidate.semantic) && isStringArray(candidate.valueLabels)\n      );\n    case \"none\":\n      return true;\n    default:\n      return false;\n  }\n}\n\nfunction isSerializedHoverInfo(value: unknown): value is FormSpecSerializedHoverInfo {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedHoverInfo>;\n  return (\n    (candidate.kind === \"tag-name\" ||\n      candidate.kind === \"target\" ||\n      candidate.kind === \"argument\" ||\n      candidate.kind === \"declaration\") &&\n    typeof candidate.markdown === \"string\"\n  );\n}\n\nfunction hasCurrentProtocolVersion(\n  value: unknown\n): value is { readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION } {\n  return isObjectRecord(value) && value[\"protocolVersion\"] === FORMSPEC_ANALYSIS_PROTOCOL_VERSION;\n}\n\nfunction isAnalysisDiagnosticLocation(value: unknown): value is FormSpecAnalysisDiagnosticLocation {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisDiagnosticLocation>;\n  return (\n    typeof candidate.filePath === \"string\" &&\n    isCommentSpan(candidate.range) &&\n    (candidate.message === undefined || typeof candidate.message === \"string\")\n  );\n}\n\nfunction isAnalysisDiagnostic(value: unknown): value is FormSpecAnalysisDiagnostic {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisDiagnostic>;\n  return (\n    typeof candidate.code === \"string\" &&\n    isDiagnosticCategory(candidate.category) &&\n    typeof candidate.message === \"string\" &&\n    isCommentSpan(candidate.range) &&\n    (candidate.severity === \"error\" ||\n      candidate.severity === \"warning\" ||\n      candidate.severity === \"info\") &&\n    Array.isArray(candidate.relatedLocations) &&\n    candidate.relatedLocations.every(isAnalysisDiagnosticLocation) &&\n    isDiagnosticDataRecord(candidate.data)\n  );\n}\n\nfunction isAnalysisTagSnapshot(value: unknown): value is FormSpecAnalysisTagSnapshot {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisTagSnapshot>;\n  return (\n    typeof candidate.rawTagName === \"string\" &&\n    typeof candidate.normalizedTagName === \"string\" &&\n    typeof candidate.recognized === \"boolean\" &&\n    isCommentSpan(candidate.fullSpan) &&\n    isCommentSpan(candidate.tagNameSpan) &&\n    (candidate.payloadSpan === null || isCommentSpan(candidate.payloadSpan)) &&\n    (candidate.target === null || isSerializedCommentTargetSpecifier(candidate.target)) &&\n    (candidate.argumentSpan === null || isCommentSpan(candidate.argumentSpan)) &&\n    typeof candidate.argumentText === \"string\" &&\n    isSerializedTagSemanticContext(candidate.semantic)\n  );\n}\n\nfunction isExplicitMetadataSource(\n  value: unknown\n): value is FormSpecSerializedExplicitMetadataSource {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedExplicitMetadataSource>;\n  return (\n    typeof candidate.tagName === \"string\" &&\n    (candidate.form === \"bare\" || candidate.form === \"qualified\") &&\n    isCommentSpan(candidate.fullRange) &&\n    isCommentSpan(candidate.tagNameRange) &&\n    (candidate.qualifierRange === undefined || isCommentSpan(candidate.qualifierRange)) &&\n    isCommentSpan(candidate.valueRange) &&\n    (candidate.qualifier === undefined || typeof candidate.qualifier === \"string\")\n  );\n}\n\nfunction isResolvedScalarMetadata(\n  value: unknown\n): value is FormSpecSerializedResolvedScalarMetadata {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedResolvedScalarMetadata>;\n  return (\n    typeof candidate.value === \"string\" &&\n    (candidate.source === \"explicit\" || candidate.source === \"inferred\")\n  );\n}\n\nfunction isResolvedMetadata(value: unknown): value is FormSpecSerializedResolvedMetadata {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedResolvedMetadata>;\n  return (\n    (candidate.apiName === undefined || isResolvedScalarMetadata(candidate.apiName)) &&\n    (candidate.displayName === undefined || isResolvedScalarMetadata(candidate.displayName)) &&\n    (candidate.apiNamePlural === undefined || isResolvedScalarMetadata(candidate.apiNamePlural)) &&\n    (candidate.displayNamePlural === undefined ||\n      isResolvedScalarMetadata(candidate.displayNamePlural))\n  );\n}\n\nfunction isMetadataEntry(value: unknown): value is FormSpecSerializedMetadataEntry {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedMetadataEntry>;\n  return (\n    typeof candidate.slotId === \"string\" &&\n    typeof candidate.tagName === \"string\" &&\n    (candidate.qualifier === undefined || typeof candidate.qualifier === \"string\") &&\n    typeof candidate.value === \"string\" &&\n    (candidate.source === \"explicit\" || candidate.source === \"inferred\") &&\n    (candidate.explicitSource === undefined || isExplicitMetadataSource(candidate.explicitSource))\n  );\n}\n\nfunction isDeclarationFact(value: unknown): value is FormSpecSerializedDeclarationFact {\n  if (!isObjectRecord(value) || typeof value[\"kind\"] !== \"string\") {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSerializedDeclarationFact>;\n  switch (candidate.kind) {\n    case \"description\":\n    case \"remarks\":\n    case \"example\":\n      return typeof candidate.value === \"string\";\n    case \"default-value\":\n      return isJsonValue(candidate.value);\n    case \"deprecated\":\n      return candidate.message === null || typeof candidate.message === \"string\";\n    case \"numeric-constraints\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        (candidate.minimum === undefined || isFiniteNumber(candidate.minimum)) &&\n        (candidate.maximum === undefined || isFiniteNumber(candidate.maximum)) &&\n        (candidate.exclusiveMinimum === undefined || isFiniteNumber(candidate.exclusiveMinimum)) &&\n        (candidate.exclusiveMaximum === undefined || isFiniteNumber(candidate.exclusiveMaximum)) &&\n        (candidate.multipleOf === undefined || isFiniteNumber(candidate.multipleOf))\n      );\n    case \"string-constraints\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        (candidate.minLength === undefined || isFiniteNumber(candidate.minLength)) &&\n        (candidate.maxLength === undefined || isFiniteNumber(candidate.maxLength)) &&\n        isStringArray(candidate.patterns)\n      );\n    case \"array-constraints\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        (candidate.minItems === undefined || isFiniteNumber(candidate.minItems)) &&\n        (candidate.maxItems === undefined || isFiniteNumber(candidate.maxItems)) &&\n        (candidate.uniqueItems === undefined || typeof candidate.uniqueItems === \"boolean\")\n      );\n    case \"allowed-members\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        Array.isArray(candidate.members) &&\n        candidate.members.every((member) => typeof member === \"string\" || isFiniteNumber(member))\n      );\n    case \"const\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        isJsonValue(candidate.value)\n      );\n    case \"custom-constraint\":\n      return (\n        (candidate.targetPath === null || typeof candidate.targetPath === \"string\") &&\n        typeof candidate.constraintId === \"string\" &&\n        (candidate.compositionRule === \"intersect\" || candidate.compositionRule === \"override\") &&\n        isJsonValue(candidate.payload)\n      );\n    default:\n      return false;\n  }\n}\n\nfunction isDeclarationSummary(value: unknown): value is FormSpecAnalysisDeclarationSummary {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisDeclarationSummary>;\n  return (\n    (candidate.summaryText === null || typeof candidate.summaryText === \"string\") &&\n    (candidate.resolvedMetadata === null || isResolvedMetadata(candidate.resolvedMetadata)) &&\n    Array.isArray(candidate.metadataEntries) &&\n    candidate.metadataEntries.every(isMetadataEntry) &&\n    Array.isArray(candidate.facts) &&\n    candidate.facts.every(isDeclarationFact) &&\n    typeof candidate.hoverMarkdown === \"string\"\n  );\n}\n\nfunction isAnalysisCommentSnapshot(value: unknown): value is FormSpecAnalysisCommentSnapshot {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisCommentSnapshot>;\n  return (\n    isCommentSpan(candidate.commentSpan) &&\n    isCommentSpan(candidate.declarationSpan) &&\n    (candidate.placement === null || isPlacementValue(candidate.placement)) &&\n    (candidate.subjectType === null || typeof candidate.subjectType === \"string\") &&\n    (candidate.hostType === null || typeof candidate.hostType === \"string\") &&\n    isDeclarationSummary(candidate.declarationSummary) &&\n    Array.isArray(candidate.tags) &&\n    candidate.tags.every(isAnalysisTagSnapshot)\n  );\n}\n\nfunction isAnalysisFileSnapshot(value: unknown): value is FormSpecAnalysisFileSnapshot {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisFileSnapshot>;\n  return (\n    typeof candidate.filePath === \"string\" &&\n    typeof candidate.sourceHash === \"string\" &&\n    typeof candidate.generatedAt === \"string\" &&\n    Array.isArray(candidate.comments) &&\n    candidate.comments.every(isAnalysisCommentSnapshot) &&\n    Array.isArray(candidate.diagnostics) &&\n    candidate.diagnostics.every(isAnalysisDiagnostic)\n  );\n}\n\n/**\n * Validates an unknown manifest payload from disk before consumers trust it.\n *\n * @public\n */\nexport function isFormSpecAnalysisManifest(value: unknown): value is FormSpecAnalysisManifest {\n  if (!isObjectRecord(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecAnalysisManifest>;\n  return (\n    candidate.protocolVersion === FORMSPEC_ANALYSIS_PROTOCOL_VERSION &&\n    candidate.analysisSchemaVersion === FORMSPEC_ANALYSIS_SCHEMA_VERSION &&\n    typeof candidate.workspaceRoot === \"string\" &&\n    typeof candidate.workspaceId === \"string\" &&\n    isIpcEndpoint(candidate.endpoint) &&\n    typeof candidate.typescriptVersion === \"string\" &&\n    typeof candidate.extensionFingerprint === \"string\" &&\n    typeof candidate.generation === \"number\" &&\n    typeof candidate.updatedAt === \"string\"\n  );\n}\n\n/**\n * Validates an unknown inbound IPC request before dispatching it.\n *\n * @public\n */\nexport function isFormSpecSemanticQuery(value: unknown): value is FormSpecSemanticQuery {\n  if (!hasCurrentProtocolVersion(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSemanticQuery>;\n  if (typeof candidate.kind !== \"string\") {\n    return false;\n  }\n\n  switch (candidate.kind) {\n    case \"health\":\n      return true;\n    case \"completion\":\n    case \"hover\":\n      return typeof candidate.filePath === \"string\" && typeof candidate.offset === \"number\";\n    case \"diagnostics\":\n    case \"file-snapshot\":\n      return typeof candidate.filePath === \"string\";\n    default:\n      return false;\n  }\n}\n\n/**\n * Validates an unknown IPC response before the language server consumes it.\n *\n * @public\n */\nexport function isFormSpecSemanticResponse(value: unknown): value is FormSpecSemanticResponse {\n  if (!hasCurrentProtocolVersion(value)) {\n    return false;\n  }\n\n  const candidate = value as Partial<FormSpecSemanticResponse>;\n  if (typeof candidate.kind !== \"string\") {\n    return false;\n  }\n\n  switch (candidate.kind) {\n    case \"health\":\n      return isFormSpecAnalysisManifest(candidate.manifest);\n    case \"completion\":\n      return (\n        typeof candidate.sourceHash === \"string\" && isSerializedCompletionContext(candidate.context)\n      );\n    case \"hover\":\n      return (\n        typeof candidate.sourceHash === \"string\" &&\n        (candidate.hover === null || isSerializedHoverInfo(candidate.hover))\n      );\n    case \"diagnostics\":\n      return (\n        typeof candidate.sourceHash === \"string\" &&\n        Array.isArray(candidate.diagnostics) &&\n        candidate.diagnostics.every(isAnalysisDiagnostic)\n      );\n    case \"file-snapshot\":\n      return candidate.snapshot === null || isAnalysisFileSnapshot(candidate.snapshot);\n    case \"error\":\n      return typeof candidate.error === \"string\";\n    default:\n      return false;\n  }\n}\n\n/**\n * Computes a stable, non-cryptographic hash for document staleness checks\n * across the plugin/LSP boundary.\n *\n * @public\n */\nexport function computeFormSpecTextHash(text: string): string {\n  let hash = 0x811c9dc5;\n  for (let index = 0; index < text.length; index += 1) {\n    hash ^= text.charCodeAt(index);\n    hash = Math.imul(hash, 0x01000193);\n  }\n\n  return (hash >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/**\n * Converts a parsed target specifier into its transport-safe JSON form.\n *\n * @internal\n */\nexport function serializeCommentTargetSpecifier(\n  target: ParsedCommentTargetSpecifier | null\n): FormSpecSerializedCommentTargetSpecifier | null {\n  if (target === null) {\n    return null;\n  }\n\n  return {\n    rawText: target.rawText,\n    valid: target.valid,\n    kind: target.kind,\n    fullSpan: target.fullSpan,\n    colonSpan: target.colonSpan,\n    span: target.span,\n  };\n}\n\n/**\n * Serializes tag-level semantic context for cross-process consumption.\n *\n * @internal\n */\nexport function serializeCommentTagSemanticContext(\n  semantic: CommentTagSemanticContext\n): FormSpecSerializedTagSemanticContext {\n  return {\n    tagName: semantic.tag.normalizedTagName,\n    tagDefinition:\n      semantic.tagDefinition === null\n        ? null\n        : {\n            canonicalName: semantic.tagDefinition.canonicalName,\n            completionDetail: semantic.tagDefinition.completionDetail,\n            hoverMarkdown: semantic.tagDefinition.hoverMarkdown,\n          },\n    placement: semantic.placement,\n    contextualSignatures: semantic.contextualSignatures.map((signature) => ({\n      label: signature.label,\n      placements: signature.placements,\n    })),\n    supportedTargets: semantic.supportedTargets,\n    targetCompletions: semantic.targetCompletions,\n    compatiblePathTargets: semantic.compatiblePathTargets,\n    valueLabels: semantic.valueLabels,\n    argumentCompletions: semantic.argumentCompletions,\n    contextualTagHoverMarkdown: semantic.contextualTagHoverMarkdown,\n    signatures: semantic.signatures.map((signature) => ({\n      label: signature.label,\n      placements: signature.placements,\n    })),\n    tagHoverMarkdown: semantic.tagHoverMarkdown,\n    targetHoverMarkdown: semantic.targetHoverMarkdown,\n    argumentHoverMarkdown: semantic.argumentHoverMarkdown,\n  };\n}\n\n/**\n * Serializes a cursor-scoped completion context for IPC.\n *\n * @internal\n */\nexport function serializeCompletionContext(\n  context: SemanticCommentCompletionContext\n): FormSpecSerializedCompletionContext {\n  switch (context.kind) {\n    case \"tag-name\":\n      return {\n        kind: \"tag-name\",\n        prefix: context.prefix,\n        availableTags: context.availableTags.map((tag) => ({\n          canonicalName: tag.canonicalName,\n          completionDetail: tag.completionDetail,\n          hoverMarkdown: tag.hoverMarkdown,\n        })),\n      };\n    case \"target\":\n      return {\n        kind: \"target\",\n        semantic: serializeCommentTagSemanticContext(context.semantic),\n      };\n    case \"argument\":\n      return {\n        kind: \"argument\",\n        semantic: serializeCommentTagSemanticContext(context.semantic),\n        valueLabels: context.valueLabels,\n      };\n    case \"none\":\n      return { kind: \"none\" };\n    default: {\n      const exhaustive: never = context;\n      return exhaustive;\n    }\n  }\n}\n\n/**\n * Serializes hover information for cross-process transport.\n *\n * @internal\n */\nexport function serializeHoverInfo(\n  hover: CommentHoverInfo | null\n): FormSpecSerializedHoverInfo | null {\n  return hover === null\n    ? null\n    : {\n        kind: hover.kind,\n        markdown: hover.markdown,\n      };\n}\n\n/**\n * Serializes a parsed tag plus its semantic context into a file snapshot entry.\n *\n * @internal\n */\nexport function serializeParsedCommentTag(\n  tag: ParsedCommentTag,\n  semantic: CommentTagSemanticContext\n): FormSpecAnalysisTagSnapshot {\n  return {\n    rawTagName: tag.rawTagName,\n    normalizedTagName: tag.normalizedTagName,\n    recognized: tag.recognized,\n    fullSpan: tag.fullSpan,\n    tagNameSpan: tag.tagNameSpan,\n    payloadSpan: tag.payloadSpan,\n    target: serializeCommentTargetSpecifier(tag.target),\n    argumentSpan: tag.argumentSpan,\n    argumentText: tag.argumentText,\n    semantic: serializeCommentTagSemanticContext(semantic),\n  };\n}\n","import type {\n  ExplicitMetadataSource,\n  LoggerLike,\n  MetadataAnalysisResult,\n  MetadataApplicableSlot,\n  MetadataDeclarationKind,\n  MetadataPolicyInput,\n  MetadataResolvedEntry,\n  MetadataSlotInferenceFn,\n  ResolvedMetadata,\n  ResolvedScalarMetadata,\n  ExtensionDefinition,\n} from \"@stripe/formspec-core\";\nimport { noopLogger } from \"@stripe/formspec-core\";\nimport * as ts from \"typescript\";\nimport { parseCommentBlock, type ParsedCommentTag } from \"./comment-syntax.js\";\nimport { getTagDefinition, normalizeFormSpecTagName } from \"./tag-registry.js\";\nimport { resolveDeclarationPlacement } from \"./ts-binding.js\";\n\n/**\n * Common options for shared metadata analysis entry points.\n *\n * @public\n */\nexport interface AnalyzeMetadataOptions {\n  /** Caller-owned TypeScript program used for analysis. */\n  readonly program: ts.Program;\n  /** Optional built-in metadata policy for apiName/displayName resolution. */\n  readonly metadata?: MetadataPolicyInput | undefined;\n  /** Optional extension definitions contributing additional metadata slots. */\n  readonly extensions?: readonly ExtensionDefinition[] | undefined;\n  /**\n   * Optional logger for diagnostic output. Defaults to a no-op logger so\n   * existing callers produce no output.\n   */\n  readonly logger?: LoggerLike | undefined;\n}\n\n/**\n * Options for analyzing one declaration node.\n *\n * @public\n */\nexport interface AnalyzeMetadataForNodeOptions extends AnalyzeMetadataOptions {\n  /** Declaration node to analyze. */\n  readonly node: ts.Node;\n}\n\n/**\n * Options for analyzing all supported declarations in one source file.\n *\n * @public\n */\nexport interface AnalyzeMetadataForSourceFileOptions extends AnalyzeMetadataOptions {\n  /** Source file whose declarations should be analyzed. */\n  readonly sourceFile: ts.SourceFile;\n}\n\n/**\n * Internal options for callers that already own a type checker.\n *\n * @internal\n */\nexport interface AnalyzeMetadataWithCheckerOptions {\n  readonly program?: ts.Program;\n  readonly checker: ts.TypeChecker;\n  readonly node: ts.Node;\n  readonly logicalName?: string;\n  readonly metadata?: MetadataPolicyInput | undefined;\n  readonly extensions?: readonly ExtensionDefinition[] | undefined;\n  readonly buildContext?: unknown;\n}\n\ninterface NormalizedMetadataSlotQualifier {\n  readonly qualifier: string;\n  readonly sourceQualifier?: string;\n  readonly inferValue?: MetadataSlotInferenceFn;\n}\n\ninterface NormalizedMetadataSlot {\n  readonly slotId: string;\n  readonly tagName: string;\n  readonly declarationKinds: readonly MetadataDeclarationKind[];\n  readonly allowBare: boolean;\n  readonly qualifiers: readonly NormalizedMetadataSlotQualifier[];\n  readonly primaryQualifierAliases: readonly string[];\n  readonly inferValue?: MetadataSlotInferenceFn;\n  readonly isApplicable?:\n    | ((context: {\n        readonly surface: \"tsdoc\";\n        readonly declarationKind: MetadataDeclarationKind;\n        readonly logicalName: string;\n        readonly buildContext?: unknown;\n      }) => boolean)\n    | undefined;\n}\n\ninterface ExplicitEntryCandidate {\n  readonly value: string;\n  readonly qualifier?: string;\n  readonly explicitSource: ExplicitMetadataSource;\n}\n\nconst BUILTIN_METADATA_TAG_NAMES = new Set([\"apiName\", \"displayName\"]);\n\nfunction validateExtensionMetadataSlots(\n  extensions: readonly ExtensionDefinition[] | undefined\n): void {\n  const slotIds = new Set<string>();\n  const tagNames = new Set(BUILTIN_METADATA_TAG_NAMES);\n  const metadataFreeExtensions =\n    extensions?.map((extension) => ({\n      extensionId: extension.extensionId,\n      ...(extension.constraintTags !== undefined\n        ? {\n            constraintTags: extension.constraintTags.map((tag) => ({\n              tagName: normalizeFormSpecTagName(tag.tagName),\n            })),\n          }\n        : {}),\n    })) ?? [];\n\n  for (const extension of extensions ?? []) {\n    for (const slot of extension.metadataSlots ?? []) {\n      if (slotIds.has(slot.slotId)) {\n        throw new Error(`Duplicate metadata slot ID: \"${slot.slotId}\"`);\n      }\n      slotIds.add(slot.slotId);\n\n      const canonicalTagName = normalizeFormSpecTagName(slot.tagName);\n\n      if (tagNames.has(canonicalTagName)) {\n        throw BUILTIN_METADATA_TAG_NAMES.has(canonicalTagName)\n          ? new Error(`Metadata tag \"@${canonicalTagName}\" conflicts with built-in metadata tags.`)\n          : new Error(`Duplicate metadata tag: \"@${canonicalTagName}\"`);\n      }\n      const existingTag = getTagDefinition(canonicalTagName, metadataFreeExtensions);\n      if (existingTag !== null) {\n        throw BUILTIN_METADATA_TAG_NAMES.has(existingTag.canonicalName)\n          ? new Error(`Metadata tag \"@${canonicalTagName}\" conflicts with built-in metadata tags.`)\n          : new Error(\n              `Metadata tag \"@${canonicalTagName}\" conflicts with existing FormSpec tag \"@${existingTag.canonicalName}\".`\n            );\n      }\n      tagNames.add(canonicalTagName);\n    }\n  }\n}\n\nfunction getLogicalName(node: ts.Node): string | null {\n  if (\n    (ts.isClassDeclaration(node) ||\n      ts.isInterfaceDeclaration(node) ||\n      ts.isTypeAliasDeclaration(node) ||\n      ts.isFunctionDeclaration(node) ||\n      ts.isMethodDeclaration(node) ||\n      ts.isVariableDeclaration(node)) &&\n    node.name !== undefined\n  ) {\n    if (ts.isIdentifier(node.name)) {\n      return node.name.text;\n    }\n    if (ts.isStringLiteralLike(node.name) || ts.isNumericLiteral(node.name)) {\n      return node.name.text;\n    }\n  }\n\n  if (ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) {\n    if (ts.isIdentifier(node.name)) {\n      return node.name.text;\n    }\n    if (ts.isStringLiteralLike(node.name) || ts.isNumericLiteral(node.name)) {\n      return node.name.text;\n    }\n  }\n\n  return null;\n}\n\nfunction getMetadataDeclarationKind(node: ts.Node): MetadataDeclarationKind | null {\n  const placement = resolveDeclarationPlacement(node);\n  switch (placement) {\n    case \"class\":\n    case \"interface\":\n    case \"type-alias\":\n      return \"type\";\n    case \"class-field\":\n    case \"interface-field\":\n    case \"type-alias-field\":\n    case \"variable\":\n    case \"function-parameter\":\n    case \"method-parameter\":\n      return \"field\";\n    case \"class-method\":\n    case \"function\":\n      return \"method\";\n    default:\n      return null;\n  }\n}\n\nfunction toResolvedScalar(\n  entry: MetadataResolvedEntry | undefined\n): ResolvedScalarMetadata | undefined {\n  return entry === undefined ? undefined : { value: entry.value, source: entry.source };\n}\n\nfunction toBuiltInResolvedMetadata(\n  entries: readonly MetadataResolvedEntry[]\n): ResolvedMetadata | undefined {\n  const apiName = toResolvedScalar(\n    entries.find((entry) => entry.slotId === \"apiName\" && entry.qualifier === undefined)\n  );\n  const displayName = toResolvedScalar(\n    entries.find((entry) => entry.slotId === \"displayName\" && entry.qualifier === undefined)\n  );\n  const apiNamePlural = toResolvedScalar(\n    entries.find((entry) => entry.slotId === \"apiName\" && entry.qualifier === \"plural\")\n  );\n  const displayNamePlural = toResolvedScalar(\n    entries.find((entry) => entry.slotId === \"displayName\" && entry.qualifier === \"plural\")\n  );\n\n  if (\n    apiName === undefined &&\n    displayName === undefined &&\n    apiNamePlural === undefined &&\n    displayNamePlural === undefined\n  ) {\n    return undefined;\n  }\n\n  return {\n    ...(apiName !== undefined && { apiName }),\n    ...(displayName !== undefined && { displayName }),\n    ...(apiNamePlural !== undefined && { apiNamePlural }),\n    ...(displayNamePlural !== undefined && { displayNamePlural }),\n  };\n}\n\nfunction normalizeBuiltInSlots(\n  metadata: MetadataPolicyInput | undefined\n): readonly NormalizedMetadataSlot[] {\n  const declarationKinds: readonly MetadataDeclarationKind[] = [\"type\", \"field\", \"method\"];\n  const qualifierNames = [\"singular\", \"plural\"] as const;\n  const builtInPolicyByKind = {\n    type: metadata?.type,\n    field: metadata?.field,\n    method: metadata?.method,\n  } as const;\n\n  const createSlot = (\n    slotId: \"apiName\" | \"displayName\",\n    tagName: \"apiName\" | \"displayName\"\n  ): NormalizedMetadataSlot => ({\n    slotId,\n    tagName,\n    declarationKinds,\n    allowBare: true,\n    primaryQualifierAliases: [\"singular\"],\n    inferValue: (context: Parameters<MetadataSlotInferenceFn>[0]) => {\n      const input = builtInPolicyByKind[context.declarationKind]?.[slotId];\n      return input?.mode === \"infer-if-missing\" ? input.infer(context) : \"\";\n    },\n    qualifiers: qualifierNames.map((qualifier) => ({\n      qualifier,\n      ...(qualifier === \"plural\"\n        ? {\n            sourceQualifier: \"singular\",\n            inferValue: (context: Parameters<MetadataSlotInferenceFn>[0]) => {\n              const input = builtInPolicyByKind[context.declarationKind]?.[slotId];\n              if (\n                input?.pluralization?.mode !== \"infer-if-missing\" ||\n                context.baseValue === undefined\n              ) {\n                return \"\";\n              }\n\n              return input.pluralization.inflect({\n                surface: context.surface,\n                declarationKind: context.declarationKind,\n                logicalName: context.logicalName,\n                singular: context.baseValue,\n                ...(context.buildContext !== undefined && { buildContext: context.buildContext }),\n              });\n            },\n          }\n        : {}),\n    })),\n  });\n\n  return [createSlot(\"apiName\", \"apiName\"), createSlot(\"displayName\", \"displayName\")];\n}\n\nfunction normalizeExtensionSlots(\n  extensions: readonly ExtensionDefinition[] | undefined\n): readonly NormalizedMetadataSlot[] {\n  const seenSlotIds = new Set<string>();\n  const seenTagNames = new Set<string>();\n\n  return (\n    extensions?.flatMap((extension) =>\n      (extension.metadataSlots ?? []).map((slot) => {\n        const normalizedTagName = normalizeFormSpecTagName(slot.tagName);\n        if (seenSlotIds.has(slot.slotId)) {\n          throw new Error(`Duplicate metadata slot ID: \"${slot.slotId}\"`);\n        }\n        seenSlotIds.add(slot.slotId);\n\n        if (seenTagNames.has(normalizedTagName)) {\n          throw new Error(`Duplicate metadata tag: \"@${normalizedTagName}\"`);\n        }\n        seenTagNames.add(normalizedTagName);\n\n        return {\n          slotId: slot.slotId,\n          tagName: normalizedTagName,\n          declarationKinds: slot.declarationKinds,\n          allowBare: slot.allowBare !== false,\n          // Extension slots only accept the qualifiers they explicitly register.\n          primaryQualifierAliases: [],\n          ...(slot.inferValue !== undefined && { inferValue: slot.inferValue }),\n          ...(slot.isApplicable !== undefined && { isApplicable: slot.isApplicable }),\n          qualifiers:\n            slot.qualifiers?.map((qualifier) => ({\n              qualifier: qualifier.qualifier,\n              ...(qualifier.sourceQualifier !== undefined && {\n                sourceQualifier: qualifier.sourceQualifier,\n              }),\n              ...(qualifier.inferValue !== undefined && { inferValue: qualifier.inferValue }),\n            })) ?? [],\n        };\n      })\n    ) ?? []\n  );\n}\n\nfunction getApplicableSlots(\n  node: ts.Node,\n  declarationKind: MetadataDeclarationKind,\n  logicalName: string,\n  metadata: MetadataPolicyInput | undefined,\n  extensions: readonly ExtensionDefinition[] | undefined,\n  buildContext: unknown\n): readonly NormalizedMetadataSlot[] {\n  validateExtensionMetadataSlots(extensions);\n  return [...normalizeBuiltInSlots(metadata), ...normalizeExtensionSlots(extensions)].filter(\n    (slot) =>\n      slot.declarationKinds.includes(declarationKind) &&\n      (slot.isApplicable?.({\n        surface: \"tsdoc\",\n        declarationKind,\n        logicalName,\n        buildContext: {\n          node,\n          ...(buildContext !== undefined && typeof buildContext === \"object\" ? buildContext : {}),\n        },\n      }) ??\n        true)\n  );\n}\n\nfunction toApplicableSlot(slot: NormalizedMetadataSlot): MetadataApplicableSlot {\n  return {\n    slotId: slot.slotId,\n    tagName: slot.tagName,\n    allowBare: slot.allowBare,\n    qualifiers: slot.qualifiers.map((qualifier) => qualifier.qualifier),\n  };\n}\n\nfunction buildExplicitSource(tag: ParsedCommentTag): ExplicitMetadataSource {\n  if (tag.argumentSpan === null) {\n    throw new Error(\n      `Expected explicit metadata tag @${tag.normalizedTagName} to have a value span.`\n    );\n  }\n\n  return {\n    tagName: tag.normalizedTagName,\n    form: tag.target === null ? \"bare\" : \"qualified\",\n    fullRange: { ...tag.fullSpan },\n    tagNameRange: { ...tag.tagNameSpan },\n    ...(tag.target !== null && {\n      qualifier: tag.target.rawText,\n      qualifierRange: { ...tag.target.span },\n    }),\n    valueRange: { ...tag.argumentSpan },\n  };\n}\n\nfunction collectExplicitCandidates(\n  node: ts.Node,\n  slots: readonly NormalizedMetadataSlot[],\n  extensions: readonly ExtensionDefinition[] | undefined\n): {\n  readonly primaryEntries: ReadonlyMap<string, ExplicitEntryCandidate>;\n  readonly qualifiedEntries: ReadonlyMap<string, ExplicitEntryCandidate>;\n} {\n  const primaryEntries = new Map<string, ExplicitEntryCandidate>();\n  const qualifiedEntries = new Map<string, ExplicitEntryCandidate>();\n  const slotsByTagName = new Map(slots.map((slot) => [slot.tagName, slot] as const));\n  const sourceFile = node.getSourceFile();\n  const commentRanges = ts.getLeadingCommentRanges(sourceFile.text, node.getFullStart()) ?? [];\n\n  for (const range of commentRanges) {\n    if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {\n      continue;\n    }\n\n    const commentText = sourceFile.text.slice(range.pos, range.end);\n    if (!commentText.startsWith(\"/**\")) {\n      continue;\n    }\n\n    const parsed = parseCommentBlock(commentText, {\n      offset: range.pos,\n      extensions:\n        extensions?.map((extension) => ({\n          extensionId: extension.extensionId,\n          ...(extension.constraintTags !== undefined\n            ? {\n                constraintTags: extension.constraintTags.map((tag) => ({ tagName: tag.tagName })),\n              }\n            : {}),\n          ...(extension.metadataSlots !== undefined\n            ? {\n                metadataSlots: extension.metadataSlots,\n              }\n            : {}),\n        })) ?? [],\n    });\n\n    for (const tag of parsed.tags) {\n      const slot = slotsByTagName.get(tag.normalizedTagName);\n      const value = tag.argumentText.trim();\n      if (slot === undefined || value === \"\") {\n        continue;\n      }\n\n      const qualifier = tag.target?.rawText;\n      if (qualifier === undefined) {\n        if (slot.allowBare && !primaryEntries.has(slot.slotId)) {\n          primaryEntries.set(slot.slotId, {\n            value,\n            explicitSource: buildExplicitSource(tag),\n          });\n        }\n        continue;\n      }\n\n      if (slot.primaryQualifierAliases.includes(qualifier)) {\n        if (!primaryEntries.has(slot.slotId)) {\n          primaryEntries.set(slot.slotId, {\n            value,\n            qualifier,\n            explicitSource: buildExplicitSource(tag),\n          });\n        }\n        continue;\n      }\n\n      if (!slot.qualifiers.some((candidate) => candidate.qualifier === qualifier)) {\n        continue;\n      }\n\n      const key = `${slot.slotId}:${qualifier}`;\n      if (!qualifiedEntries.has(key)) {\n        qualifiedEntries.set(key, {\n          value,\n          qualifier,\n          explicitSource: buildExplicitSource(tag),\n        });\n      }\n    }\n  }\n\n  return { primaryEntries, qualifiedEntries };\n}\n\nfunction inferEntry(\n  slot: NormalizedMetadataSlot,\n  declarationKind: MetadataDeclarationKind,\n  logicalName: string,\n  qualifier: string | undefined,\n  buildContext: unknown,\n  inferValue: MetadataSlotInferenceFn | undefined,\n  baseValue: string | undefined\n): MetadataResolvedEntry | null {\n  if (inferValue === undefined) {\n    return null;\n  }\n\n  const value = inferValue({\n    surface: \"tsdoc\",\n    declarationKind,\n    logicalName,\n    slotId: slot.slotId,\n    tagName: slot.tagName,\n    ...(qualifier !== undefined && { qualifier }),\n    ...(baseValue !== undefined && { baseValue }),\n    ...(buildContext !== undefined && { buildContext }),\n  }).trim();\n\n  return value === \"\"\n    ? null\n    : {\n        slotId: slot.slotId,\n        tagName: slot.tagName,\n        ...(qualifier !== undefined && { qualifier }),\n        value,\n        source: \"inferred\",\n      };\n}\n\nfunction resolveSlotEntries(\n  slot: NormalizedMetadataSlot,\n  declarationKind: MetadataDeclarationKind,\n  logicalName: string,\n  explicit: {\n    readonly primaryEntries: ReadonlyMap<string, ExplicitEntryCandidate>;\n    readonly qualifiedEntries: ReadonlyMap<string, ExplicitEntryCandidate>;\n  },\n  buildContext: unknown\n): readonly MetadataResolvedEntry[] {\n  const entries: MetadataResolvedEntry[] = [];\n  const primaryExplicit = explicit.primaryEntries.get(slot.slotId);\n  const primaryEntry =\n    primaryExplicit !== undefined\n      ? ({\n          slotId: slot.slotId,\n          tagName: slot.tagName,\n          value: primaryExplicit.value,\n          source: \"explicit\",\n          explicitSource: primaryExplicit.explicitSource,\n        } satisfies MetadataResolvedEntry)\n      : inferEntry(\n          slot,\n          declarationKind,\n          logicalName,\n          undefined,\n          buildContext,\n          slot.inferValue,\n          undefined\n        );\n\n  if (primaryEntry !== null) {\n    entries.push(primaryEntry);\n  }\n\n  for (const qualifier of slot.qualifiers) {\n    if (slot.primaryQualifierAliases.includes(qualifier.qualifier)) {\n      continue;\n    }\n\n    const explicitKey = `${slot.slotId}:${qualifier.qualifier}`;\n    const explicitQualified = explicit.qualifiedEntries.get(explicitKey);\n    if (explicitQualified !== undefined) {\n      entries.push({\n        slotId: slot.slotId,\n        tagName: slot.tagName,\n        qualifier: qualifier.qualifier,\n        value: explicitQualified.value,\n        source: \"explicit\",\n        explicitSource: explicitQualified.explicitSource,\n      });\n      continue;\n    }\n\n    const sourceEntry =\n      qualifier.sourceQualifier === undefined\n        ? primaryEntry\n        : (entries.find(\n            (entry) => entry.slotId === slot.slotId && entry.qualifier === qualifier.sourceQualifier\n          ) ??\n          (slot.primaryQualifierAliases.includes(qualifier.sourceQualifier) || slot.allowBare\n            ? primaryEntry\n            : undefined));\n    const inferred = inferEntry(\n      slot,\n      declarationKind,\n      logicalName,\n      qualifier.qualifier,\n      buildContext,\n      qualifier.inferValue,\n      sourceEntry?.value\n    );\n    if (inferred !== null) {\n      entries.push(inferred);\n    }\n  }\n\n  return entries;\n}\n\nexport function analyzeMetadataForNodeWithChecker(\n  options: AnalyzeMetadataWithCheckerOptions\n): MetadataAnalysisResult | null {\n  const declarationKind = getMetadataDeclarationKind(options.node);\n  const logicalName = options.logicalName ?? getLogicalName(options.node);\n  if (declarationKind === null || logicalName === null) {\n    return null;\n  }\n\n  const buildContext = {\n    ...(options.buildContext !== undefined && typeof options.buildContext === \"object\"\n      ? options.buildContext\n      : {}),\n    ...(options.program !== undefined && { program: options.program }),\n    checker: options.checker,\n    node: options.node,\n    sourceFile: options.node.getSourceFile(),\n  };\n  const applicableSlots = getApplicableSlots(\n    options.node,\n    declarationKind,\n    logicalName,\n    options.metadata,\n    options.extensions,\n    buildContext\n  );\n  const explicit = collectExplicitCandidates(options.node, applicableSlots, options.extensions);\n  const entries = applicableSlots.flatMap((slot) =>\n    resolveSlotEntries(slot, declarationKind, logicalName, explicit, buildContext)\n  );\n\n  return {\n    declarationKind,\n    logicalName,\n    applicableSlots: applicableSlots.map((slot) => toApplicableSlot(slot)),\n    entries,\n    resolvedMetadata: toBuiltInResolvedMetadata(entries),\n  };\n}\n\n/**\n * Analyze shared metadata semantics for a single declaration node.\n *\n * @public\n */\nexport function analyzeMetadataForNode(\n  options: AnalyzeMetadataForNodeOptions\n): MetadataAnalysisResult | null {\n  const logger = (options.logger ?? noopLogger).child({ stage: \"analysis\" });\n  const logicalName = getLogicalName(options.node);\n  logger.debug(\"analyzing metadata for node\", { logicalName: logicalName ?? \"(unnamed)\" });\n  return analyzeMetadataForNodeWithChecker({\n    program: options.program,\n    checker: options.program.getTypeChecker(),\n    node: options.node,\n    ...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n    ...(options.extensions !== undefined ? { extensions: options.extensions } : {}),\n  });\n}\n\n/**\n * Analyze shared metadata semantics for all supported declarations in a source file.\n *\n * @public\n */\nexport function analyzeMetadataForSourceFile(\n  options: AnalyzeMetadataForSourceFileOptions\n): readonly MetadataAnalysisResult[] {\n  const logger = (options.logger ?? noopLogger).child({ stage: \"analysis\" });\n  const fileName = options.sourceFile.fileName;\n  const results: MetadataAnalysisResult[] = [];\n  const checker = options.program.getTypeChecker();\n\n  const visit = (node: ts.Node): void => {\n    const declarationKind = getMetadataDeclarationKind(node);\n    if (declarationKind !== null && !ts.isVariableDeclaration(node) && !ts.isParameter(node)) {\n      const analyzed = analyzeMetadataForNodeWithChecker({\n        program: options.program,\n        checker,\n        node,\n        ...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n        ...(options.extensions !== undefined ? { extensions: options.extensions } : {}),\n      });\n      if (analyzed !== null) {\n        results.push(analyzed);\n      }\n    }\n    ts.forEachChild(node, visit);\n  };\n\n  visit(options.sourceFile);\n  // One debug record per file: filename + tag count — plan §3 @stripe/formspec-analysis\n  logger.debug(\"analyzed source file\", { fileName, tagCount: results.length });\n  return results;\n}\n","/**\n * Classifies whether a JSON-shaped tag argument has balanced bracket/brace\n * delimiters before the JSON parser decides whether the value is valid JSON.\n *\n * This deliberately does not validate JSON syntax. Balanced-but-invalid JSON\n * such as `[1,2,]` must still reach the existing raw-string fallback paths.\n *\n * @internal\n */\ntype JsonLikeBalanceStatus = \"not-json-like\" | \"balanced\" | \"unbalanced\";\n\nfunction expectedCloseFor(open: string): \"]\" | \"}\" | null {\n  if (open === \"[\") return \"]\";\n  if (open === \"{\") return \"}\";\n  return null;\n}\n\n/**\n * Incrementally tracks bracket/brace balance for a JSON-shaped text stream.\n *\n * @internal\n */\nexport function createJsonLikeBalanceTracker(): { append(text: string): number | null } {\n  const expectedClosers: string[] = [];\n  let offset = 0;\n  let started = false;\n  let failed = false;\n  let inString = false;\n  let escaped = false;\n  let balancedEnd: number | null = null;\n\n  return {\n    append(text: string): number | null {\n      if (failed || balancedEnd !== null) {\n        offset += text.length;\n        return balancedEnd;\n      }\n\n      for (let localIndex = 0; localIndex < text.length; localIndex += 1) {\n        const char = text[localIndex];\n        const absoluteEnd = offset + localIndex + 1;\n\n        if (!started) {\n          if (char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\r\") {\n            continue;\n          }\n\n          const firstExpectedClose = expectedCloseFor(char ?? \"\");\n          if (firstExpectedClose === null) {\n            failed = true;\n            continue;\n          }\n\n          expectedClosers.push(firstExpectedClose);\n          started = true;\n          continue;\n        }\n\n        if (inString) {\n          if (escaped) {\n            escaped = false;\n          } else if (char === \"\\\\\") {\n            escaped = true;\n          } else if (char === '\"') {\n            inString = false;\n          }\n          continue;\n        }\n\n        if (char === '\"') {\n          inString = true;\n          continue;\n        }\n\n        const openerExpectedClose = expectedCloseFor(char ?? \"\");\n        if (openerExpectedClose !== null) {\n          expectedClosers.push(openerExpectedClose);\n          continue;\n        }\n\n        if (char === \"]\" || char === \"}\") {\n          const expected = expectedClosers.pop();\n          if (expected !== char) {\n            failed = true;\n            continue;\n          }\n          if (expectedClosers.length === 0) {\n            balancedEnd = absoluteEnd;\n            break;\n          }\n        }\n      }\n\n      offset += text.length;\n      return balancedEnd;\n    },\n  };\n}\n\n/**\n * Finds the one-past-the-end offset of the first balanced JSON-shaped bracket\n * structure in text, starting at the first non-whitespace character.\n *\n * @internal\n */\nfunction findJsonLikeBalancedEnd(rawArgumentText: string): number | null {\n  return createJsonLikeBalanceTracker().append(rawArgumentText);\n}\n\n/**\n * Returns whether a raw argument begins with a bracketed JSON-shaped structure\n * and, if so, whether that structure is balanced. \"Unbalanced\" covers both\n * missing closing delimiters and mismatched delimiters.\n *\n * @internal\n */\nexport function getJsonLikeBalanceStatus(rawArgumentText: string): JsonLikeBalanceStatus {\n  const start = rawArgumentText.search(/\\S/u);\n  if (start < 0) {\n    return \"not-json-like\";\n  }\n\n  if (expectedCloseFor(rawArgumentText[start] ?? \"\") === null) {\n    return \"not-json-like\";\n  }\n\n  return findJsonLikeBalancedEnd(rawArgumentText) === null ? \"unbalanced\" : \"balanced\";\n}\n","import type { PathTarget } from \"@stripe/formspec-core/internals\";\n\nexport interface ParsedPathTarget {\n  readonly path: PathTarget;\n  readonly remainingText: string;\n}\n\n/**\n * Extract a `:foo.bar` path target prefix from raw tag text.\n */\nexport function extractPathTarget(text: string): ParsedPathTarget | null {\n  const trimmed = text.trimStart();\n  const match = /^:([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+([\\s\\S]*))?$/u.exec(trimmed);\n  if (!match?.[1]) {\n    return null;\n  }\n\n  return {\n    path: { segments: match[1].split(\".\") },\n    remainingText: match[2] ?? \"\",\n  };\n}\n\nexport function formatPathTarget(path: PathTarget | readonly string[]): string {\n  if (\"segments\" in path) {\n    return path.segments.join(\".\");\n  }\n  return path.join(\".\");\n}\n","import type { PathTarget } from \"@stripe/formspec-core/internals\";\nimport { createJsonLikeBalanceTracker } from \"./json-like-balance.js\";\nimport { extractPathTarget } from \"./path-target.js\";\nimport {\n  getTagDefinition,\n  normalizeFormSpecTagName,\n  type ExtensionTagSource,\n} from \"./tag-registry.js\";\n\n/**\n * Zero-based half-open span in the source file.\n *\n * @public\n */\nexport interface CommentSourceSpan {\n  /** Zero-based start offset in the source file. */\n  readonly start: number;\n  /** One-past-the-end offset in the source file. */\n  readonly end: number;\n}\n\n/**\n * Canonical span type used throughout serialized comment analysis.\n *\n * @public\n */\nexport type CommentSpan = CommentSourceSpan;\n\n/**\n * Parsed target specifier attached to a comment tag.\n *\n * @public\n */\nexport interface ParsedCommentTargetSpecifier {\n  /** Raw target text without the leading colon. */\n  readonly rawText: string;\n  /** Whether the target parsed cleanly. */\n  readonly valid: boolean;\n  /** Classified target kind used by completion and hover flows. */\n  readonly kind: \"path\" | \"member\" | \"variant\" | \"ambiguous\";\n  /** Full span covering the colon and target text. */\n  readonly fullSpan: CommentSourceSpan;\n  /** Span covering only the colon prefix. */\n  readonly colonSpan: CommentSourceSpan;\n  /** Span covering the target text after the colon. */\n  readonly span: CommentSourceSpan;\n  /** Parsed path target when one could be resolved. */\n  readonly path: PathTarget | null;\n}\n\ninterface ParsedCommentTargetSpecifierWithLocalEnd extends ParsedCommentTargetSpecifier {\n  readonly localEnd: number;\n}\n\n/**\n * Parsed representation of a single FormSpec tag inside a comment block.\n *\n * @public\n */\nexport interface ParsedCommentTag {\n  /** Raw tag name exactly as written in the source. */\n  readonly rawTagName: string;\n  /** Normalized tag name used for registry lookup. */\n  readonly normalizedTagName: string;\n  /** Whether the tag was recognized by the registry. */\n  readonly recognized: boolean;\n  /** Full span covering the parsed tag. */\n  readonly fullSpan: CommentSourceSpan;\n  /** Span covering the tag name token. */\n  readonly tagNameSpan: CommentSourceSpan;\n  /** Span covering the payload after the tag name, if present. */\n  readonly payloadSpan: CommentSourceSpan | null;\n  /** Span covering the target colon, if present. */\n  readonly colonSpan: CommentSourceSpan | null;\n  /** Parsed target specifier, if present. */\n  readonly target: ParsedCommentTargetSpecifier | null;\n  /** Span covering the argument text, if present. */\n  readonly argumentSpan: CommentSourceSpan | null;\n  /** Raw argument text following the tag or target. */\n  readonly argumentText: string;\n}\n\n/**\n * Parsed representation of one doc comment block.\n *\n * @public\n */\nexport interface ParsedCommentBlock {\n  /** Comment text with delimiters removed. */\n  readonly commentText: string;\n  /** Absolute source offset where the comment block begins. */\n  readonly offset: number;\n  /** Parsed tags discovered inside the comment. */\n  readonly tags: readonly ParsedCommentTag[];\n}\n\ninterface CommentLineProjection {\n  readonly text: string;\n  readonly rawOffsets: readonly number[];\n  readonly rawContentEnd: number;\n}\n\ninterface MultiLineJsonArgument {\n  readonly argumentText: string;\n  readonly rawEnd: number;\n}\n\nconst MULTI_LINE_JSON_ARGUMENT_TAGS: ReadonlySet<string> = new Set([\n  \"const\",\n  \"defaultValue\",\n  \"enumOptions\",\n  \"example\",\n]);\n\nfunction isWhitespace(char: string | undefined): boolean {\n  return char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\r\";\n}\n\nfunction isTagStart(lineText: string, index: number): boolean {\n  if (lineText[index] !== \"@\") {\n    return false;\n  }\n\n  const nextChar = lineText[index + 1];\n  if (nextChar === undefined || !/[A-Za-z]/u.test(nextChar)) {\n    return false;\n  }\n\n  const previousChar = lineText[index - 1];\n  return previousChar === undefined || isWhitespace(previousChar);\n}\n\nfunction collectTagStarts(lineText: string): readonly number[] {\n  const tagStarts: number[] = [];\n  for (let index = 0; index < lineText.length; index += 1) {\n    if (isTagStart(lineText, index)) {\n      tagStarts.push(index);\n    }\n  }\n  return tagStarts;\n}\n\nfunction findTagEnd(lineText: string, index: number): number {\n  let cursor = index + 1;\n  while (cursor < lineText.length && /[A-Za-z0-9]/u.test(lineText[cursor] ?? \"\")) {\n    cursor += 1;\n  }\n  return cursor;\n}\n\nfunction trimTrailingWhitespace(lineText: string, end: number): number {\n  let cursor = end;\n  while (cursor > 0 && isWhitespace(lineText[cursor - 1])) {\n    cursor -= 1;\n  }\n  return cursor;\n}\n\nfunction startsWithJsonOpener(text: string): boolean {\n  const first = text.trimStart()[0];\n  return first === \"[\" || first === \"{\";\n}\n\nfunction startsWithFreshBlockTag(lineText: string): boolean {\n  let cursor = 0;\n  while (cursor < lineText.length && isWhitespace(lineText[cursor])) {\n    cursor += 1;\n  }\n  return isTagStart(lineText, cursor);\n}\n\nfunction spanFromLine(\n  line: CommentLineProjection,\n  start: number,\n  end: number,\n  baseOffset: number\n): CommentSourceSpan {\n  const rawStart = line.rawOffsets[start];\n  if (rawStart === undefined) {\n    throw new Error(`Invalid projected span start: ${String(start)}`);\n  }\n\n  const rawEnd =\n    end >= line.text.length\n      ? line.rawContentEnd\n      : (line.rawOffsets[end - 1] ?? line.rawContentEnd - 1) + 1;\n\n  return {\n    start: baseOffset + rawStart,\n    end: baseOffset + rawEnd,\n  };\n}\n\nfunction findMultiLineJsonArgument(\n  lines: readonly CommentLineProjection[],\n  startLineIndex: number,\n  valueStart: number,\n  firstLineValueEnd: number\n): MultiLineJsonArgument | null {\n  const firstLine = lines[startLineIndex];\n  if (\n    firstLine === undefined ||\n    !startsWithJsonOpener(firstLine.text.slice(valueStart, firstLineValueEnd))\n  ) {\n    return null;\n  }\n\n  const balanceTracker = createJsonLikeBalanceTracker();\n  const pieces: string[] = [];\n  const rawOffsets: number[] = [];\n  let rawEnd = firstLine.rawContentEnd;\n\n  for (let lineIndex = startLineIndex; lineIndex < lines.length; lineIndex += 1) {\n    const line = lines[lineIndex];\n    if (line === undefined) {\n      continue;\n    }\n\n    if (lineIndex > startLineIndex && startsWithFreshBlockTag(line.text)) {\n      return null;\n    }\n\n    const pieceStart = lineIndex === startLineIndex ? valueStart : 0;\n    if (lineIndex > startLineIndex) {\n      pieces.push(\"\\n\");\n      rawOffsets.push(-1);\n    }\n\n    const pieceEnd = lineIndex === startLineIndex ? firstLineValueEnd : line.text.length;\n    for (let index = pieceStart; index < pieceEnd; index += 1) {\n      rawOffsets.push(line.rawOffsets[index] ?? line.rawContentEnd);\n    }\n    const piece = line.text.slice(pieceStart, pieceEnd);\n    pieces.push(piece);\n    rawEnd =\n      pieceEnd >= line.text.length\n        ? line.rawContentEnd\n        : (line.rawOffsets[pieceEnd - 1] ?? line.rawContentEnd - 1) + 1;\n\n    const balancedEnd = balanceTracker.append(piece);\n    if (balancedEnd === null) {\n      continue;\n    }\n    const projectedArgumentText = pieces.join(\"\");\n    const trailingText = projectedArgumentText.slice(balancedEnd);\n    if (trailingText.trim() === \"\") {\n      const closeRawOffset = rawOffsets[balancedEnd - 1];\n      if (closeRawOffset !== undefined && closeRawOffset >= 0) {\n        return {\n          argumentText: projectedArgumentText.slice(0, balancedEnd),\n          rawEnd: closeRawOffset + 1,\n        };\n      }\n    }\n\n    return {\n      argumentText: projectedArgumentText,\n      rawEnd,\n    };\n  }\n\n  return {\n    argumentText: pieces.join(\"\"),\n    rawEnd,\n  };\n}\n\nfunction classifyTargetKind(\n  canonicalName: string,\n  targetText: string,\n  extensions: readonly ExtensionTagSource[] | undefined\n): ParsedCommentTargetSpecifier[\"kind\"] {\n  if (targetText === \"singular\" || targetText === \"plural\") {\n    return \"variant\";\n  }\n\n  if (targetText.includes(\".\")) {\n    return \"path\";\n  }\n\n  const definition = getTagDefinition(canonicalName, extensions);\n  const supportedTargets = definition?.supportedTargets.filter((target) => target !== \"none\") ?? [];\n\n  if (supportedTargets.includes(\"path\")) {\n    return \"path\";\n  }\n  if (supportedTargets.includes(\"member\") && supportedTargets.includes(\"variant\")) {\n    return \"ambiguous\";\n  }\n  if (supportedTargets.includes(\"member\")) {\n    return \"member\";\n  }\n  if (supportedTargets.includes(\"variant\")) {\n    return \"variant\";\n  }\n  return \"path\";\n}\n\nfunction parseTargetSpecifier(\n  line: CommentLineProjection,\n  payloadStart: number,\n  payloadEnd: number,\n  canonicalName: string,\n  baseOffset: number,\n  extensions: readonly ExtensionTagSource[] | undefined\n): ParsedCommentTargetSpecifierWithLocalEnd | null {\n  if (payloadStart >= payloadEnd || line.text[payloadStart] !== \":\") {\n    return null;\n  }\n\n  let targetEnd = payloadStart + 1;\n  while (targetEnd < payloadEnd && !isWhitespace(line.text[targetEnd])) {\n    targetEnd += 1;\n  }\n\n  const fullText = line.text.slice(payloadStart, targetEnd);\n  const targetText = fullText.slice(1);\n  const parsedPath = extractPathTarget(fullText);\n  const specifierSpan = spanFromLine(line, payloadStart + 1, targetEnd, baseOffset);\n\n  return {\n    rawText: targetText,\n    valid: parsedPath !== null && parsedPath.remainingText === \"\",\n    kind: classifyTargetKind(canonicalName, targetText, extensions),\n    fullSpan: spanFromLine(line, payloadStart, targetEnd, baseOffset),\n    colonSpan: spanFromLine(line, payloadStart, payloadStart + 1, baseOffset),\n    span: specifierSpan,\n    path: parsedPath?.path ?? null,\n    localEnd: targetEnd,\n  };\n}\n\nfunction projectCommentLines(commentText: string): readonly CommentLineProjection[] {\n  const projections: CommentLineProjection[] = [];\n  const commentBodyStart = commentText.startsWith(\"/**\") ? 3 : commentText.startsWith(\"/*\") ? 2 : 0;\n  const commentBodyEnd = commentText.endsWith(\"*/\") ? commentText.length - 2 : commentText.length;\n\n  let cursor = commentBodyStart;\n  while (cursor <= commentBodyEnd) {\n    const lineStart = cursor;\n    let lineEnd = cursor;\n    while (lineEnd < commentBodyEnd && commentText[lineEnd] !== \"\\n\") {\n      lineEnd += 1;\n    }\n\n    let contentEnd = lineEnd;\n    if (contentEnd > lineStart && commentText[contentEnd - 1] === \"\\r\") {\n      contentEnd -= 1;\n    }\n\n    let contentStart = lineStart;\n    while (\n      contentStart < contentEnd &&\n      (commentText[contentStart] === \" \" || commentText[contentStart] === \"\\t\")\n    ) {\n      contentStart += 1;\n    }\n    if (contentStart < contentEnd && commentText[contentStart] === \"*\") {\n      contentStart += 1;\n      while (\n        contentStart < contentEnd &&\n        (commentText[contentStart] === \" \" || commentText[contentStart] === \"\\t\")\n      ) {\n        contentStart += 1;\n      }\n    }\n\n    const rawOffsets: number[] = [];\n    let text = \"\";\n    for (let index = contentStart; index < contentEnd; index += 1) {\n      rawOffsets.push(index);\n      text += commentText[index] ?? \"\";\n    }\n\n    projections.push({\n      text,\n      rawOffsets,\n      rawContentEnd: contentEnd,\n    });\n\n    if (lineEnd >= commentBodyEnd) {\n      break;\n    }\n    cursor = lineEnd + 1;\n  }\n\n  return projections;\n}\n\nexport interface ParseCommentSyntaxOptions {\n  /** Absolute source offset for the parsed comment block. */\n  readonly offset?: number;\n  /** Extension tag sources used to classify target specifiers. */\n  readonly extensions?: readonly ExtensionTagSource[];\n}\n\n/**\n * Parse a doc comment block into tags and target/argument spans.\n *\n * @public\n */\nexport function parseCommentBlock(\n  commentText: string,\n  options?: ParseCommentSyntaxOptions\n): ParsedCommentBlock {\n  const tags: ParsedCommentTag[] = [];\n  const baseOffset = options?.offset ?? 0;\n  const lines = projectCommentLines(commentText);\n  let consumedRawUntil = -1;\n\n  for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {\n    const line = lines[lineIndex];\n    if (line === undefined) {\n      continue;\n    }\n    const tagStarts = collectTagStarts(line.text);\n\n    for (let tagIndex = 0; tagIndex < tagStarts.length; tagIndex += 1) {\n      const tagStart = tagStarts[tagIndex];\n      if (tagStart === undefined) {\n        continue;\n      }\n      const tagStartRaw = line.rawOffsets[tagStart];\n      if (tagStartRaw === undefined || tagStartRaw < consumedRawUntil) {\n        continue;\n      }\n\n      const tagEnd = findTagEnd(line.text, tagStart);\n      const nextTagStart = tagStarts[tagIndex + 1] ?? line.text.length;\n      const trimmedTagSegmentEnd = trimTrailingWhitespace(line.text, nextTagStart);\n      const rawName = line.text.slice(tagStart + 1, tagEnd);\n      const canonicalName = normalizeFormSpecTagName(rawName);\n\n      let payloadStart = tagEnd;\n      while (payloadStart < trimmedTagSegmentEnd && isWhitespace(line.text[payloadStart])) {\n        payloadStart += 1;\n      }\n\n      const target = parseTargetSpecifier(\n        line,\n        payloadStart,\n        trimmedTagSegmentEnd,\n        canonicalName,\n        baseOffset,\n        options?.extensions\n      );\n\n      let valueStart = payloadStart;\n      if (target !== null) {\n        valueStart = target.localEnd;\n        while (valueStart < trimmedTagSegmentEnd && isWhitespace(line.text[valueStart])) {\n          valueStart += 1;\n        }\n      }\n\n      let payloadSpan =\n        payloadStart < trimmedTagSegmentEnd\n          ? spanFromLine(line, payloadStart, trimmedTagSegmentEnd, baseOffset)\n          : null;\n      let valueSpan =\n        valueStart < trimmedTagSegmentEnd\n          ? spanFromLine(line, valueStart, trimmedTagSegmentEnd, baseOffset)\n          : null;\n      let fullSpan = spanFromLine(line, tagStart, trimmedTagSegmentEnd, baseOffset);\n      let argumentText =\n        valueSpan === null\n          ? \"\"\n          : commentText.slice(valueSpan.start - baseOffset, valueSpan.end - baseOffset);\n\n      if (\n        valueSpan !== null &&\n        MULTI_LINE_JSON_ARGUMENT_TAGS.has(canonicalName) &&\n        startsWithJsonOpener(line.text.slice(valueStart, trimmedTagSegmentEnd))\n      ) {\n        const multiLineArgument = findMultiLineJsonArgument(\n          lines,\n          lineIndex,\n          valueStart,\n          trimmedTagSegmentEnd\n        );\n        if (multiLineArgument !== null && multiLineArgument.rawEnd >= valueSpan.end - baseOffset) {\n          const absoluteEnd = baseOffset + multiLineArgument.rawEnd;\n          valueSpan = { start: valueSpan.start, end: absoluteEnd };\n          payloadSpan =\n            payloadSpan === null ? null : { start: payloadSpan.start, end: absoluteEnd };\n          fullSpan = { start: fullSpan.start, end: absoluteEnd };\n          argumentText = multiLineArgument.argumentText;\n          consumedRawUntil = Math.max(consumedRawUntil, multiLineArgument.rawEnd);\n        }\n      }\n\n      const parsedTarget =\n        target === null\n          ? null\n          : {\n              rawText: target.rawText,\n              valid: target.valid,\n              kind: target.kind,\n              fullSpan: target.fullSpan,\n              colonSpan: target.colonSpan,\n              span: target.span,\n              path: target.path,\n            };\n\n      tags.push({\n        rawTagName: rawName,\n        normalizedTagName: canonicalName,\n        recognized: getTagDefinition(canonicalName, options?.extensions) !== null,\n        fullSpan,\n        tagNameSpan: spanFromLine(line, tagStart, tagEnd, baseOffset),\n        payloadSpan,\n        colonSpan: parsedTarget?.colonSpan ?? null,\n        target: parsedTarget,\n        argumentSpan: valueSpan,\n        argumentText,\n      });\n    }\n  }\n\n  return {\n    commentText,\n    offset: baseOffset,\n    tags,\n  };\n}\n\n/**\n * Parse a single tag form by synthesizing a comment block around it.\n *\n * @public\n */\nexport function parseTagSyntax(\n  rawTagName: string,\n  payloadText: string,\n  options?: Omit<ParseCommentSyntaxOptions, \"offset\">\n): ParsedCommentTag {\n  const separator = payloadText === \"\" || isWhitespace(payloadText[0]) ? \"\" : \" \";\n  const parsed = parseCommentBlock(`/** @${rawTagName}${separator}${payloadText} */`, options);\n  const [tag] = parsed.tags;\n  if (tag === undefined) {\n    throw new Error(`Unable to parse synthetic tag syntax for @${rawTagName}`);\n  }\n  return tag;\n}\n\n/**\n * Extracts summary text from a doc comment by taking the cleaned text that\n * appears before the first recognized tag marker.\n *\n * @public\n */\nexport function extractCommentSummaryText(commentText: string): string {\n  const summaryLines: string[] = [];\n\n  for (const line of projectCommentLines(commentText)) {\n    let cutoff = line.text.length;\n    for (let index = 0; index < line.text.length; index += 1) {\n      if (isTagStart(line.text, index)) {\n        cutoff = index;\n        break;\n      }\n    }\n\n    const segment = line.text.slice(0, cutoff).trimEnd();\n    if (cutoff < line.text.length) {\n      if (segment.trim() !== \"\") {\n        summaryLines.push(segment.trim());\n      }\n      break;\n    }\n\n    summaryLines.push(segment);\n  }\n\n  return summaryLines.join(\"\\n\").trim();\n}\n\n/**\n * Extracts one or more TSDoc-style block-tag payloads, including continuation\n * lines until the next block tag begins.\n *\n * @public\n */\nexport function extractCommentBlockTagTexts(\n  commentText: string,\n  rawTagName: string\n): readonly string[] {\n  const lines = projectCommentLines(commentText);\n  const canonicalName = normalizeFormSpecTagName(rawTagName);\n  const values: string[] = [];\n\n  let lineIndex = 0;\n  while (lineIndex < lines.length) {\n    const line = lines[lineIndex];\n    if (line === undefined) {\n      break;\n    }\n\n    const tagStarts = collectTagStarts(line.text);\n    let nextLineIndex = lineIndex + 1;\n\n    for (let tagIndex = 0; tagIndex < tagStarts.length; tagIndex += 1) {\n      const tagStart = tagStarts[tagIndex];\n      if (tagStart === undefined) {\n        continue;\n      }\n\n      const tagEnd = findTagEnd(line.text, tagStart);\n      const candidateName = normalizeFormSpecTagName(line.text.slice(tagStart + 1, tagEnd));\n      if (candidateName !== canonicalName) {\n        continue;\n      }\n\n      let payloadStart = tagEnd;\n      const nextTagStart = tagStarts[tagIndex + 1] ?? line.text.length;\n      while (payloadStart < nextTagStart && isWhitespace(line.text[payloadStart])) {\n        payloadStart += 1;\n      }\n\n      const blockLines: string[] = [\n        line.text\n          .slice(payloadStart, trimTrailingWhitespace(line.text, nextTagStart))\n          .replace(/[ \\t]+$/u, \"\"),\n      ];\n\n      if (nextTagStart === line.text.length) {\n        let continuationIndex = lineIndex + 1;\n        while (continuationIndex < lines.length) {\n          const continuation = lines[continuationIndex];\n          if (continuation === undefined) {\n            break;\n          }\n\n          if (collectTagStarts(continuation.text).length > 0) {\n            break;\n          }\n\n          const continuationText = continuation.text.replace(/[ \\t]+$/u, \"\");\n          if (continuationText.trim() === \"/\") {\n            break;\n          }\n\n          blockLines.push(continuationText);\n          continuationIndex += 1;\n        }\n        if (continuationIndex > nextLineIndex) {\n          nextLineIndex = continuationIndex;\n        }\n      }\n\n      const text = blockLines.join(\"\\n\").trim();\n      if (text !== \"\") {\n        values.push(text);\n      }\n    }\n\n    lineIndex = nextLineIndex;\n  }\n\n  return values;\n}\n\n/**\n * Extract the raw text corresponding to a serialized comment span.\n *\n * @public\n */\nexport function sliceCommentSpan(\n  commentText: string,\n  span: CommentSpan,\n  options?: { readonly offset?: number }\n): string {\n  const baseOffset = options?.offset ?? 0;\n  return commentText.slice(span.start - baseOffset, span.end - baseOffset);\n}\n","import * as ts from \"typescript\";\nimport type { FormSpecPlacement, SemanticCapability } from \"./tag-registry.js\";\n\nexport type FormSpecSemanticCapability = SemanticCapability;\n\n/**\n * Result of resolving a dotted FormSpec path target through a TypeScript type.\n */\nexport type ResolvedPathTargetType =\n  | {\n      readonly kind: \"resolved\";\n      readonly type: ts.Type;\n    }\n  | {\n      readonly kind: \"missing-property\";\n      readonly segment: string;\n    }\n  | {\n      readonly kind: \"unresolvable\";\n      readonly type: ts.Type;\n    };\n\n/**\n * Collapses `T | null`, `T | undefined`, and `T | null | undefined` to `T`.\n *\n * Only collapses when exactly one non-nullish member remains — wider unions\n * (e.g. `A | B | null`) pass through unchanged. Used throughout the analysis\n * layer to normalize nullable fields before capability checks.\n */\nexport function stripNullishUnion(type: ts.Type): ts.Type {\n  if (!type.isUnion()) {\n    return type;\n  }\n\n  const nonNullish = type.types.filter(\n    (member) => (member.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) === 0\n  );\n  if (nonNullish.length === 1 && nonNullish[0] !== undefined) {\n    return nonNullish[0];\n  }\n\n  return type;\n}\n\nfunction isIntersectionWithBase(type: ts.Type, predicate: (member: ts.Type) => boolean): boolean {\n  return type.isIntersection() && type.types.some((member) => predicate(member));\n}\n\nfunction isNumberLike(type: ts.Type): boolean {\n  const stripped = stripNullishUnion(type);\n  if (\n    stripped.flags &\n    (ts.TypeFlags.Number |\n      ts.TypeFlags.NumberLiteral |\n      ts.TypeFlags.BigInt |\n      ts.TypeFlags.BigIntLiteral)\n  ) {\n    return true;\n  }\n\n  if (stripped.isUnion()) {\n    return stripped.types.every((member) => isNumberLike(member));\n  }\n\n  return isIntersectionWithBase(stripped, isNumberLike);\n}\n\nfunction isStringLike(type: ts.Type): boolean {\n  const stripped = stripNullishUnion(type);\n  if (stripped.flags & (ts.TypeFlags.String | ts.TypeFlags.StringLiteral)) {\n    return true;\n  }\n\n  if (stripped.isUnion()) {\n    return stripped.types.every((member) => isStringLike(member));\n  }\n\n  return isIntersectionWithBase(stripped, isStringLike);\n}\n\nfunction isBooleanLike(type: ts.Type): boolean {\n  const stripped = stripNullishUnion(type);\n  if (stripped.flags & (ts.TypeFlags.Boolean | ts.TypeFlags.BooleanLiteral)) {\n    return true;\n  }\n\n  if (stripped.isUnion()) {\n    return stripped.types.every((member) => isBooleanLike(member));\n  }\n\n  return isIntersectionWithBase(stripped, isBooleanLike);\n}\n\nfunction isNullLike(type: ts.Type): boolean {\n  const stripped = stripNullishUnion(type);\n  if (stripped.flags & ts.TypeFlags.Null) {\n    return true;\n  }\n\n  if (stripped.isUnion()) {\n    return stripped.types.every((member) => isNullLike(member));\n  }\n\n  return isIntersectionWithBase(stripped, isNullLike);\n}\n\nfunction isArrayLike(type: ts.Type, checker: ts.TypeChecker): boolean {\n  const stripped = stripNullishUnion(type);\n  if (checker.isArrayType(stripped)) {\n    return true;\n  }\n\n  const symbol = stripped.getSymbol();\n  return symbol?.name === \"Array\" || symbol?.name === \"ReadonlyArray\";\n}\n\nfunction isStringLiteralUnion(type: ts.Type): boolean {\n  const stripped = stripNullishUnion(type);\n  return stripped.isUnion() && stripped.types.length > 0 && stripped.types.every(isStringLike);\n}\n\nfunction isObjectLike(type: ts.Type, checker: ts.TypeChecker): boolean {\n  const stripped = stripNullishUnion(type);\n  return !isArrayLike(stripped, checker) && (stripped.flags & ts.TypeFlags.Object) !== 0;\n}\n\nfunction isJsonLike(type: ts.Type, checker: ts.TypeChecker): boolean {\n  const stripped = stripNullishUnion(type);\n\n  if (\n    isNullLike(stripped) ||\n    isNumberLike(stripped) ||\n    isStringLike(stripped) ||\n    isBooleanLike(stripped)\n  ) {\n    return true;\n  }\n\n  if (stripped.isUnion()) {\n    return stripped.types.every((member) => isJsonLike(member, checker));\n  }\n\n  if (isArrayLike(stripped, checker) || isObjectLike(stripped, checker)) {\n    return true;\n  }\n\n  return isIntersectionWithBase(stripped, (member) => isJsonLike(member, checker));\n}\n\nfunction getArrayElementType(type: ts.Type, checker: ts.TypeChecker): ts.Type | null {\n  const stripped = stripNullishUnion(type);\n  if (!checker.isArrayType(stripped)) {\n    return null;\n  }\n\n  return checker.getTypeArguments(stripped as ts.TypeReference)[0] ?? null;\n}\n\nexport function resolveDeclarationPlacement(node: ts.Node): FormSpecPlacement | null {\n  if (ts.isClassDeclaration(node)) return \"class\";\n  if (ts.isPropertyDeclaration(node)) return \"class-field\";\n  if (ts.isMethodDeclaration(node)) return \"class-method\";\n  if (ts.isInterfaceDeclaration(node)) return \"interface\";\n  if (ts.isPropertySignature(node)) return \"interface-field\";\n  if (ts.isTypeAliasDeclaration(node)) return \"type-alias\";\n  if (ts.isVariableDeclaration(node)) return \"variable\";\n  if (ts.isFunctionDeclaration(node)) return \"function\";\n  if (ts.isParameter(node)) {\n    if (ts.isMethodDeclaration(node.parent) || ts.isConstructorDeclaration(node.parent)) {\n      return \"method-parameter\";\n    }\n    return \"function-parameter\";\n  }\n  return null;\n}\n\nexport function getTypeSemanticCapabilities(\n  type: ts.Type,\n  checker: ts.TypeChecker\n): readonly SemanticCapability[] {\n  const capabilities = new Set<SemanticCapability>();\n\n  if (isNumberLike(type)) {\n    capabilities.add(\"numeric-comparable\");\n  }\n  if (isStringLike(type)) {\n    capabilities.add(\"string-like\");\n  }\n  if (isJsonLike(type, checker)) {\n    capabilities.add(\"json-like\");\n  }\n  if (isArrayLike(type, checker)) {\n    capabilities.add(\"array-like\");\n  }\n  if (isStringLiteralUnion(type)) {\n    capabilities.add(\"enum-member-addressable\");\n  }\n  if (isObjectLike(type, checker)) {\n    capabilities.add(\"object-like\");\n  }\n\n  return [...capabilities];\n}\n\nexport function hasTypeSemanticCapability(\n  type: ts.Type,\n  checker: ts.TypeChecker,\n  capability: SemanticCapability\n): boolean {\n  return getTypeSemanticCapabilities(type, checker).includes(capability);\n}\n\n/**\n * Resolves a dotted FormSpec path target against a TypeScript type.\n *\n * Arrays are traversed through their item type so path-targets behave the same\n * way they do in the IR validator and cursor-context completion logic.\n */\nexport function resolvePathTargetType(\n  type: ts.Type,\n  checker: ts.TypeChecker,\n  segments: readonly string[]\n): ResolvedPathTargetType {\n  const stripped = stripNullishUnion(type);\n\n  if (segments.length === 0) {\n    return {\n      kind: \"resolved\",\n      type: stripped,\n    };\n  }\n\n  const arrayElementType = getArrayElementType(stripped, checker);\n  if (arrayElementType !== null) {\n    return resolvePathTargetType(arrayElementType, checker, segments);\n  }\n\n  if ((stripped.flags & ts.TypeFlags.Object) === 0) {\n    return {\n      kind: \"unresolvable\",\n      type: stripped,\n    };\n  }\n\n  const [segment, ...rest] = segments;\n  if (segment === undefined) {\n    throw new Error(\"Invariant violation: path traversal requires a segment\");\n  }\n\n  const property = stripped.getProperty(segment);\n  if (property === undefined) {\n    return {\n      kind: \"missing-property\",\n      segment,\n    };\n  }\n\n  const declaration = property.valueDeclaration ?? property.declarations?.[0];\n  if (declaration === undefined) {\n    return {\n      kind: \"unresolvable\",\n      type: stripped,\n    };\n  }\n\n  return resolvePathTargetType(\n    checker.getTypeOfSymbolAtLocation(property, declaration),\n    checker,\n    rest\n  );\n}\n\nfunction collectPropertyPaths(\n  type: ts.Type,\n  checker: ts.TypeChecker,\n  capability: SemanticCapability,\n  prefix: readonly string[],\n  visited: Set<ts.Type>\n): string[] {\n  const stripped = stripNullishUnion(type);\n  if (visited.has(stripped)) {\n    return [];\n  }\n  visited.add(stripped);\n\n  const suggestions: string[] = [];\n\n  if (hasTypeSemanticCapability(stripped, checker, capability) && prefix.length > 0) {\n    suggestions.push(prefix.join(\".\"));\n  }\n\n  for (const property of stripped.getProperties()) {\n    const declaration = property.valueDeclaration ?? property.declarations?.[0];\n    if (declaration === undefined) {\n      continue;\n    }\n\n    const propertyType = checker.getTypeOfSymbolAtLocation(property, declaration);\n    const nextPrefix = [...prefix, property.name];\n    suggestions.push(\n      ...collectPropertyPaths(propertyType, checker, capability, nextPrefix, visited)\n    );\n  }\n\n  return suggestions;\n}\n\nexport function collectCompatiblePathTargets(\n  type: ts.Type,\n  checker: ts.TypeChecker,\n  capability: SemanticCapability\n): readonly string[] {\n  return collectPropertyPaths(type, checker, capability, [], new Set<ts.Type>());\n}\n\n/**\n * Extracts addressable enum member values from a string literal union type\n * for use as `:member` target completions.\n */\nexport function getEnumMemberCompletions(type: ts.Type): readonly string[] {\n  const stripped = stripNullishUnion(type);\n\n  if (stripped.isStringLiteral()) {\n    return [stripped.value];\n  }\n\n  if (!stripped.isUnion()) {\n    return [];\n  }\n\n  const members: string[] = [];\n  for (const member of stripped.types) {\n    if (member.isStringLiteral()) {\n      members.push(member.value);\n    }\n  }\n  return members.sort();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBASO;AAgJA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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