@formspec/language-server 0.1.0-alpha.23 → 0.1.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -31,10 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  createServer: () => createServer,
34
+ fileUriToPathOrNull: () => fileUriToPathOrNull,
34
35
  getCompletionItems: () => getCompletionItems,
36
+ getCompletionItemsAtOffset: () => getCompletionItemsAtOffset,
35
37
  getDefinition: () => getDefinition,
38
+ getHoverAtOffset: () => getHoverAtOffset,
36
39
  getHoverForTag: () => getHoverForTag,
40
+ getPluginCompletionContextForDocument: () => getPluginCompletionContextForDocument,
37
41
  getPluginDiagnosticsForDocument: () => getPluginDiagnosticsForDocument,
42
+ getPluginHoverForDocument: () => getPluginHoverForDocument,
38
43
  toLspDiagnostics: () => toLspDiagnostics
39
44
  });
40
45
  module.exports = __toCommonJS(index_exports);
@@ -480,10 +485,15 @@ function createServer(options = {}) {
480
485
  // Annotate the CommonJS export names for ESM import in node:
481
486
  0 && (module.exports = {
482
487
  createServer,
488
+ fileUriToPathOrNull,
483
489
  getCompletionItems,
490
+ getCompletionItemsAtOffset,
484
491
  getDefinition,
492
+ getHoverAtOffset,
485
493
  getHoverForTag,
494
+ getPluginCompletionContextForDocument,
486
495
  getPluginDiagnosticsForDocument,
496
+ getPluginHoverForDocument,
487
497
  toLspDiagnostics
488
498
  });
489
499
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.ts","../src/diagnostics.ts","../src/plugin-client.ts"],"sourcesContent":["/**\n * \\@formspec/language-server\n *\n * Language server for FormSpec — provides completions, hover documentation,\n * and go-to-definition for FormSpec JSDoc constraint tags (`@Minimum`,\n * `@Maximum`, `@Pattern`, etc.) in TypeScript files.\n *\n * This package implements the Language Server Protocol (LSP) using the\n * `vscode-languageserver` library. Cheap syntax-local behaviors stay in the\n * LSP process, while TypeScript-project-aware semantics are supplied by\n * `@formspec/ts-plugin` over a local manifest + IPC transport.\n *\n * The packaged server acts as a reference implementation over the composable\n * completion, hover, and diagnostics helpers exported from this package.\n *\n * @example\n * ```ts\n * import { createServer } from '@formspec/language-server';\n *\n * const connection = createServer();\n * connection.listen();\n * ```\n *\n * @packageDocumentation\n */\n\nexport { createServer } from \"./server.js\";\nexport type { CreateServerOptions } from \"./server.js\";\nexport type {\n CommentSpan,\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticCategory,\n FormSpecAnalysisDiagnosticDataValue,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nexport {\n getPluginDiagnosticsForDocument,\n toLspDiagnostics,\n type ToLspDiagnosticsOptions,\n} from \"./diagnostics.js\";\nexport { getCompletionItems } from \"./providers/completion.js\";\nexport { getHoverForTag } from \"./providers/hover.js\";\nexport { getDefinition } from \"./providers/definition.js\";\n","/**\n * FormSpec Language Server\n *\n * Sets up an LSP server connection and registers handlers for:\n * - `textDocument/completion` — FormSpec JSDoc constraint tag completions\n * - `textDocument/hover` — Documentation for recognized constraint tags\n * - `textDocument/definition` — Go-to-definition (stub, returns null)\n *\n * The packaged language server is a reference implementation built on the same\n * composable helpers that downstream consumers can call directly.\n */\n\nimport {\n createConnection,\n Diagnostic,\n ProposedFeatures,\n TextDocuments,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { getCompletionItemsAtOffset } from \"./providers/completion.js\";\nimport { getHoverAtOffset } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\nimport { getPluginDiagnosticsForDocument, toLspDiagnostics } from \"./diagnostics.js\";\nimport {\n fileUriToPathOrNull,\n getPluginCompletionContextForDocument,\n getPluginHoverForDocument,\n} from \"./plugin-client.js\";\n\nconst PLUGIN_QUERY_TIMEOUT_ENV_VAR = \"FORMSPEC_PLUGIN_QUERY_TIMEOUT_MS\";\n\nfunction dedupeWorkspaceRoots(workspaceRoots: readonly string[]): string[] {\n return [...new Set(workspaceRoots)];\n}\n\nfunction resolvePluginQueryTimeoutMs(explicitTimeoutMs: number | undefined): number | undefined {\n if (explicitTimeoutMs !== undefined) {\n return explicitTimeoutMs;\n }\n\n const rawValue = process.env[PLUGIN_QUERY_TIMEOUT_ENV_VAR];\n if (rawValue === undefined) {\n return undefined;\n }\n\n const parsed = Number.parseInt(rawValue, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction getWorkspaceRootsFromInitializeParams(params: {\n readonly workspaceFolders?: readonly { readonly uri: string }[] | null;\n readonly rootUri?: string | null;\n readonly rootPath?: string | null;\n}): string[] {\n const workspaceFolders =\n params.workspaceFolders\n ?.map((workspaceFolder) => fileUriToPathOrNull(workspaceFolder.uri))\n .filter((workspaceRoot): workspaceRoot is string => workspaceRoot !== null) ?? [];\n const rootUri =\n params.rootUri === null || params.rootUri === undefined\n ? null\n : fileUriToPathOrNull(params.rootUri);\n const rootPath = params.rootPath ?? null;\n\n return dedupeWorkspaceRoots([\n ...workspaceFolders,\n ...(rootUri === null ? [] : [rootUri]),\n ...(rootPath === null ? [] : [rootPath]),\n ]);\n}\n\n/**\n * Public configuration for constructing the FormSpec language server.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /** Optional extension definitions whose custom tags should be surfaced by tooling. */\n readonly extensions?: readonly ExtensionDefinition[];\n /** Optional workspace roots to use before initialize() provides them. */\n readonly workspaceRoots?: readonly string[];\n /** Set to false to disable tsserver-plugin semantic enrichment. */\n readonly usePluginTransport?: boolean;\n /** IPC timeout, in milliseconds, for semantic plugin requests. */\n readonly pluginQueryTimeoutMs?: number;\n /** Optional diagnostics publishing mode for the packaged reference LSP. */\n readonly diagnosticsMode?: \"off\" | \"plugin\";\n /** Source label to use when publishing plugin-derived diagnostics. */\n readonly diagnosticSource?: string;\n}\n\n/**\n * Creates and configures the FormSpec language server connection.\n *\n * Registers LSP capability handlers and returns the connection.\n * Call `connection.listen()` to start accepting messages.\n *\n * @returns The configured LSP connection (not yet listening)\n * @public\n */\nexport function createServer(options: CreateServerOptions = {}): Connection {\n const connection = createConnection(ProposedFeatures.all);\n const documents = new TextDocuments(TextDocument);\n let workspaceRoots = [...(options.workspaceRoots ?? [])];\n const pluginQueryTimeoutMs = resolvePluginQueryTimeoutMs(options.pluginQueryTimeoutMs);\n const diagnosticsMode = options.diagnosticsMode ?? \"off\";\n const diagnosticSource = options.diagnosticSource ?? \"formspec\";\n\n documents.listen(connection);\n\n async function publishDiagnosticsForDocument(document: TextDocument): Promise<void> {\n if (diagnosticsMode !== \"plugin\" || options.usePluginTransport === false) {\n return;\n }\n\n const filePath = fileUriToPathOrNull(document.uri);\n if (filePath === null) {\n return;\n }\n\n const diagnostics =\n (await getPluginDiagnosticsForDocument(\n workspaceRoots,\n filePath,\n document.getText(),\n pluginQueryTimeoutMs\n )) ?? [];\n\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: toLspDiagnostics(document, diagnostics, {\n source: diagnosticSource,\n }),\n });\n }\n\n connection.onInitialize((params): InitializeResult => {\n workspaceRoots = dedupeWorkspaceRoots([\n ...getWorkspaceRootsFromInitializeParams(params),\n ...workspaceRoots,\n ]);\n\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments for tags and target specifiers\n triggerCharacters: [\"@\", \":\"],\n },\n hoverProvider: true,\n definitionProvider: true,\n },\n serverInfo: {\n name: \"formspec-language-server\",\n version: \"0.1.0\",\n },\n };\n });\n\n connection.onCompletion(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticContext =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginCompletionContextForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getCompletionItemsAtOffset(documentText, offset, options.extensions, semanticContext);\n });\n\n connection.onHover(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticHover =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginHoverForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getHoverAtOffset(documentText, offset, options.extensions, semanticHover);\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n documents.onDidOpen(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidChangeContent(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidClose(({ document }) => {\n if (diagnosticsMode === \"plugin\") {\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: [] satisfies Diagnostic[],\n });\n }\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Uses the shared tag registry from `@formspec/analysis` so completions stay\n * aligned with the same metadata that powers linting and build-time analysis.\n */\n\nimport {\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedTagDefinition,\n getConstraintTagDefinitions,\n getSemanticCommentCompletionContextAtOffset,\n type TagDefinition,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the full set of tag-name completions currently known to FormSpec.\n *\n * @public\n */\nexport function getCompletionItems(extensions?: readonly ExtensionDefinition[]): CompletionItem[] {\n return getConstraintTagDefinitions(extensions).map((tag) => ({\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n }));\n}\n\nfunction toCompletionItem(tag: TagDefinition | FormSpecSerializedTagDefinition): CompletionItem {\n return {\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n };\n}\n\nfunction toTargetCompletionItems(\n tagName: string,\n targetCompletions: readonly string[]\n): CompletionItem[] {\n return targetCompletions.map((target: string) => ({\n label: target,\n kind:\n target === \"singular\" || target === \"plural\"\n ? CompletionItemKind.EnumMember\n : CompletionItemKind.Field,\n detail: `Target for @${tagName}`,\n }));\n}\n\nfunction filterTagNameCompletionItems(\n prefix: string,\n availableTags: readonly (TagDefinition | FormSpecSerializedTagDefinition)[]\n): CompletionItem[] {\n const normalizedPrefix = prefix.toLowerCase();\n return availableTags\n .map(toCompletionItem)\n .filter((item) => item.label.slice(1).toLowerCase().startsWith(normalizedPrefix));\n}\n\n/** @internal */\nexport function getCompletionItemsAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticContext?: FormSpecSerializedCompletionContext | null\n): CompletionItem[] {\n if (semanticContext !== null && semanticContext !== undefined) {\n if (semanticContext.kind === \"target\") {\n return toTargetCompletionItems(\n semanticContext.semantic.tagName,\n semanticContext.semantic.targetCompletions\n );\n }\n\n if (semanticContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(semanticContext.prefix, semanticContext.availableTags);\n }\n\n const resolvedContext = getSemanticCommentCompletionContextAtOffset(\n documentText,\n offset,\n extensions ? { extensions } : undefined\n );\n\n if (resolvedContext.kind === \"target\") {\n return toTargetCompletionItems(\n resolvedContext.semantic.tag.normalizedTagName,\n resolvedContext.semantic.targetCompletions\n );\n }\n\n if (resolvedContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(resolvedContext.prefix, resolvedContext.availableTags);\n}\n","/**\n * Hover provider for FormSpec JSDoc tags.\n *\n * Uses the shared registry from `@formspec/analysis` so hover content stays in\n * sync with the tag inventory and overload metadata.\n */\n\nimport {\n type FormSpecSerializedHoverInfo,\n getCommentHoverInfoAtOffset,\n getTagDefinition,\n normalizeFormSpecTagName,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns hover content for a single FormSpec tag name.\n *\n * @public\n */\nexport function getHoverForTag(\n tagName: string,\n extensions?: readonly ExtensionDefinition[]\n): Hover | null {\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const definition = getTagDefinition(normalizeFormSpecTagName(raw), extensions);\n if (!definition) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: definition.hoverMarkdown,\n },\n };\n}\n\n/** @internal */\nexport function getHoverAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticHover?: FormSpecSerializedHoverInfo | null\n): Hover | null {\n const hoverInfo =\n semanticHover ??\n getCommentHoverInfoAtOffset(documentText, offset, extensions ? { extensions } : undefined);\n if (hoverInfo === null) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: hoverInfo.markdown,\n },\n };\n}\n","/**\n * Go-to-definition provider for FormSpec.\n *\n * This is a stub — go-to-definition support (e.g., navigating from a\n * `field.text(\"name\")` call to the form definition that references it) will\n * be implemented in a future phase.\n */\n\nimport type { Location } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the definition location for a symbol at the given position.\n *\n * Always returns `null` in this stub implementation.\n *\n * @returns `null` — not yet implemented\n * @public\n */\nexport function getDefinition(): Location | null {\n return null;\n}\n","import type {\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nimport {\n DiagnosticRelatedInformation,\n DiagnosticSeverity,\n Location,\n Range,\n type Diagnostic,\n} from \"vscode-languageserver/node.js\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { fileUriToPathOrNull } from \"./plugin-client.js\";\nexport { getPluginDiagnosticsForDocument } from \"./plugin-client.js\";\n\n/**\n * Options for converting canonical FormSpec diagnostics into LSP diagnostics.\n *\n * @public\n */\nexport interface ToLspDiagnosticsOptions {\n /** Source label shown by LSP clients. Defaults to `formspec`. */\n readonly source?: string;\n}\n\n/**\n * Converts canonical FormSpec diagnostics into LSP diagnostics.\n *\n * Downstream consumers that want complete white-label control can ignore this\n * helper and render their own messages from `code` + `data`.\n *\n * @public\n */\nexport function toLspDiagnostics(\n document: TextDocument,\n diagnostics: readonly FormSpecAnalysisDiagnostic[],\n options: ToLspDiagnosticsOptions = {}\n): Diagnostic[] {\n const source = options.source ?? \"formspec\";\n return diagnostics.map((diagnostic) => {\n const relatedInformation = toRelatedInformation(document, diagnostic.relatedLocations);\n return {\n range: spanToRange(document, diagnostic.range.start, diagnostic.range.end),\n severity: toLspSeverity(diagnostic.severity),\n source,\n code: diagnostic.code,\n message: diagnostic.message,\n ...(relatedInformation === undefined ? {} : { relatedInformation }),\n data: {\n ...diagnostic.data,\n category: diagnostic.category,\n },\n };\n });\n}\n\nfunction spanToRange(document: TextDocument, start: number, end: number): Range {\n return Range.create(document.positionAt(start), document.positionAt(end));\n}\n\nfunction toLspSeverity(severity: FormSpecAnalysisDiagnostic[\"severity\"]): DiagnosticSeverity {\n switch (severity) {\n case \"error\":\n return DiagnosticSeverity.Error;\n case \"warning\":\n return DiagnosticSeverity.Warning;\n case \"info\":\n return DiagnosticSeverity.Information;\n default:\n return DiagnosticSeverity.Information;\n }\n}\n\nfunction toRelatedInformation(\n document: TextDocument,\n locations: readonly FormSpecAnalysisDiagnosticLocation[]\n): DiagnosticRelatedInformation[] | undefined {\n if (locations.length === 0) {\n return undefined;\n }\n\n const currentDocumentFilePath = getDocumentFilePath(document);\n const relatedInformation = locations\n .filter((location) => location.filePath === currentDocumentFilePath)\n .map((location) =>\n DiagnosticRelatedInformation.create(\n Location.create(\n document.uri,\n spanToRange(document, location.range.start, location.range.end)\n ),\n location.message ?? \"Related FormSpec location\"\n )\n );\n\n return relatedInformation.length === 0 ? undefined : relatedInformation;\n}\n\nfunction getDocumentFilePath(document: TextDocument): string | null {\n return fileUriToPathOrNull(document.uri);\n}\n","import fs from \"node:fs/promises\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n computeFormSpecTextHash,\n isFormSpecAnalysisManifest,\n isFormSpecSemanticResponse,\n type FormSpecAnalysisDiagnostic,\n type FormSpecAnalysisManifest,\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedHoverInfo,\n type FormSpecSemanticQuery,\n type FormSpecSemanticResponse,\n} from \"@formspec/analysis/protocol\";\nimport { getFormSpecManifestPath } from \"@formspec/analysis/internal\";\n\nconst DEFAULT_PLUGIN_QUERY_TIMEOUT_MS = 2_000;\n\nfunction getManifestPath(workspaceRoot: string): string {\n return getFormSpecManifestPath(workspaceRoot);\n}\n\nfunction normalizeWorkspaceRoot(root: string): string {\n const resolved = path.resolve(root);\n const parsed = path.parse(resolved);\n let normalized = resolved;\n\n while (normalized.length > parsed.root.length && normalized.endsWith(path.sep)) {\n normalized = normalized.slice(0, -path.sep.length);\n }\n\n return normalized;\n}\n\nfunction getMatchingWorkspaceRoot(\n workspaceRoots: readonly string[],\n filePath: string\n): string | null {\n const normalizedFilePath = path.resolve(filePath);\n const normalizedRoots = [...workspaceRoots]\n .map(normalizeWorkspaceRoot)\n .sort((left, right) => right.length - left.length);\n return (\n normalizedRoots.find(\n (workspaceRoot) =>\n normalizedFilePath === workspaceRoot ||\n normalizedFilePath.startsWith(`${workspaceRoot}${path.sep}`)\n ) ?? null\n );\n}\n\nasync function readManifest(workspaceRoot: string): Promise<FormSpecAnalysisManifest | null> {\n try {\n const manifestText = await fs.readFile(getManifestPath(workspaceRoot), \"utf8\");\n const manifest = JSON.parse(manifestText) as unknown;\n if (!isFormSpecAnalysisManifest(manifest)) {\n return null;\n }\n\n return manifest;\n } catch {\n return null;\n }\n}\n\nasync function sendSemanticQuery(\n manifest: FormSpecAnalysisManifest,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n return new Promise((resolve) => {\n const socket = net.createConnection(manifest.endpoint.address);\n let buffer = \"\";\n let settled = false;\n\n const finish = (response: FormSpecSemanticResponse | null): void => {\n if (settled) {\n return;\n }\n settled = true;\n socket.removeAllListeners(\"data\");\n socket.destroy();\n resolve(response);\n };\n\n socket.setTimeout(timeoutMs, () => {\n finish(null);\n });\n\n socket.setEncoding(\"utf8\");\n socket.on(\"connect\", () => {\n socket.write(`${JSON.stringify(query)}\\n`);\n });\n socket.on(\"data\", (chunk) => {\n buffer += String(chunk);\n const newlineIndex = buffer.indexOf(\"\\n\");\n if (newlineIndex < 0) {\n return;\n }\n\n const payload = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n try {\n const response = JSON.parse(payload) as unknown;\n finish(isFormSpecSemanticResponse(response) ? response : null);\n } catch {\n finish(null);\n }\n });\n socket.on(\"error\", () => {\n finish(null);\n });\n socket.on(\"close\", () => {\n finish(null);\n });\n });\n}\n\nexport function fileUriToPathOrNull(uri: string): string | null {\n try {\n return fileURLToPath(uri);\n } catch {\n return null;\n }\n}\n\nasync function sendFileQuery(\n workspaceRoots: readonly string[],\n filePath: string,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n const workspaceRoot = getMatchingWorkspaceRoot(workspaceRoots, filePath);\n if (workspaceRoot === null) {\n return null;\n }\n\n const manifest = await readManifest(workspaceRoot);\n if (manifest === null) {\n return null;\n }\n\n return sendSemanticQuery(manifest, query, timeoutMs);\n}\n\nexport async function getPluginCompletionContextForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedCompletionContext | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"completion\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"completion\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.context : null;\n}\n\nexport async function getPluginHoverForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedHoverInfo | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"hover\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"hover\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.hover : null;\n}\n\n/**\n * Retrieves canonical FormSpec diagnostics for the current document revision\n * from the plugin transport. Returns `null` when the transport is missing,\n * stale, or invalid.\n *\n * @public\n */\nexport async function getPluginDiagnosticsForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<readonly FormSpecAnalysisDiagnostic[] | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"diagnostics\",\n filePath,\n },\n timeoutMs\n );\n if (response?.kind !== \"diagnostics\") {\n return null;\n }\n\n return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AO,iBAAiB,cAAc,QAAQ,QAAQ,YAAY,aAAa;AAAA,EACjF,CAAC;AAED,aAAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,YAAU,UAAU,CAAC,EAAE,SAAS,MAAM;AACpC,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,mBAAmB,CAAC,EAAE,SAAS,MAAM;AAC7C,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,WAAW,CAAC,EAAE,SAAS,MAAM;AACrC,QAAI,oBAAoB,UAAU;AAChC,WAAK,WAAW,gBAAgB;AAAA,QAC9B,KAAK,SAAS;AAAA,QACd,aAAa,CAAC;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["import_node","import_internal","import_node","import_internal","path","fs","net"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.ts","../src/diagnostics.ts","../src/plugin-client.ts"],"sourcesContent":["/**\n * \\@formspec/language-server\n *\n * Language server for FormSpec — provides completions, hover documentation,\n * and go-to-definition for FormSpec JSDoc constraint tags (`@Minimum`,\n * `@Maximum`, `@Pattern`, etc.) in TypeScript files.\n *\n * This package implements the Language Server Protocol (LSP) using the\n * `vscode-languageserver` library. Cheap syntax-local behaviors stay in the\n * LSP process, while TypeScript-project-aware semantics are supplied by\n * `@formspec/ts-plugin` over a local manifest + IPC transport.\n *\n * The packaged server acts as a reference implementation over the composable\n * completion, hover, and diagnostics helpers exported from this package.\n *\n * @example\n * ```ts\n * import { createServer } from '@formspec/language-server';\n *\n * const connection = createServer();\n * connection.listen();\n * ```\n *\n * @packageDocumentation\n */\n\nexport { createServer } from \"./server.js\";\nexport type { CreateServerOptions } from \"./server.js\";\nexport type {\n CommentSourceSpan,\n CommentSpan,\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticCategory,\n FormSpecAnalysisDiagnosticDataValue,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nexport {\n getPluginDiagnosticsForDocument,\n toLspDiagnostics,\n type ToLspDiagnosticsOptions,\n} from \"./diagnostics.js\";\nexport { getCompletionItems, getCompletionItemsAtOffset } from \"./providers/completion.js\";\nexport { getHoverForTag, getHoverAtOffset } from \"./providers/hover.js\";\nexport { getDefinition } from \"./providers/definition.js\";\nexport {\n fileUriToPathOrNull,\n getPluginCompletionContextForDocument,\n getPluginHoverForDocument,\n} from \"./plugin-client.js\";\n","/**\n * FormSpec Language Server\n *\n * Sets up an LSP server connection and registers handlers for:\n * - `textDocument/completion` — FormSpec JSDoc constraint tag completions\n * - `textDocument/hover` — Documentation for recognized constraint tags\n * - `textDocument/definition` — Go-to-definition (stub, returns null)\n *\n * The packaged language server is a reference implementation built on the same\n * composable helpers that downstream consumers can call directly.\n */\n\nimport {\n createConnection,\n Diagnostic,\n ProposedFeatures,\n TextDocuments,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { getCompletionItemsAtOffset } from \"./providers/completion.js\";\nimport { getHoverAtOffset } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\nimport { getPluginDiagnosticsForDocument, toLspDiagnostics } from \"./diagnostics.js\";\nimport {\n fileUriToPathOrNull,\n getPluginCompletionContextForDocument,\n getPluginHoverForDocument,\n} from \"./plugin-client.js\";\n\nconst PLUGIN_QUERY_TIMEOUT_ENV_VAR = \"FORMSPEC_PLUGIN_QUERY_TIMEOUT_MS\";\n\nfunction dedupeWorkspaceRoots(workspaceRoots: readonly string[]): string[] {\n return [...new Set(workspaceRoots)];\n}\n\nfunction resolvePluginQueryTimeoutMs(explicitTimeoutMs: number | undefined): number | undefined {\n if (explicitTimeoutMs !== undefined) {\n return explicitTimeoutMs;\n }\n\n const rawValue = process.env[PLUGIN_QUERY_TIMEOUT_ENV_VAR];\n if (rawValue === undefined) {\n return undefined;\n }\n\n const parsed = Number.parseInt(rawValue, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction getWorkspaceRootsFromInitializeParams(params: {\n readonly workspaceFolders?: readonly { readonly uri: string }[] | null;\n readonly rootUri?: string | null;\n readonly rootPath?: string | null;\n}): string[] {\n const workspaceFolders =\n params.workspaceFolders\n ?.map((workspaceFolder) => fileUriToPathOrNull(workspaceFolder.uri))\n .filter((workspaceRoot): workspaceRoot is string => workspaceRoot !== null) ?? [];\n const rootUri =\n params.rootUri === null || params.rootUri === undefined\n ? null\n : fileUriToPathOrNull(params.rootUri);\n const rootPath = params.rootPath ?? null;\n\n return dedupeWorkspaceRoots([\n ...workspaceFolders,\n ...(rootUri === null ? [] : [rootUri]),\n ...(rootPath === null ? [] : [rootPath]),\n ]);\n}\n\n/**\n * Public configuration for constructing the FormSpec language server.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /** Optional extension definitions whose custom tags should be surfaced by tooling. */\n readonly extensions?: readonly ExtensionDefinition[];\n /** Optional workspace roots to use before initialize() provides them. */\n readonly workspaceRoots?: readonly string[];\n /** Set to false to disable tsserver-plugin semantic enrichment. */\n readonly usePluginTransport?: boolean;\n /** IPC timeout, in milliseconds, for semantic plugin requests. */\n readonly pluginQueryTimeoutMs?: number;\n /** Optional diagnostics publishing mode for the packaged reference LSP. */\n readonly diagnosticsMode?: \"off\" | \"plugin\";\n /** Source label to use when publishing plugin-derived diagnostics. */\n readonly diagnosticSource?: string;\n}\n\n/**\n * Creates and configures the FormSpec language server connection.\n *\n * Registers LSP capability handlers and returns the connection.\n * Call `connection.listen()` to start accepting messages.\n *\n * @returns The configured LSP connection (not yet listening)\n * @public\n */\nexport function createServer(options: CreateServerOptions = {}): Connection {\n const connection = createConnection(ProposedFeatures.all);\n const documents = new TextDocuments(TextDocument);\n let workspaceRoots = [...(options.workspaceRoots ?? [])];\n const pluginQueryTimeoutMs = resolvePluginQueryTimeoutMs(options.pluginQueryTimeoutMs);\n const diagnosticsMode = options.diagnosticsMode ?? \"off\";\n const diagnosticSource = options.diagnosticSource ?? \"formspec\";\n\n documents.listen(connection);\n\n async function publishDiagnosticsForDocument(document: TextDocument): Promise<void> {\n if (diagnosticsMode !== \"plugin\" || options.usePluginTransport === false) {\n return;\n }\n\n const filePath = fileUriToPathOrNull(document.uri);\n if (filePath === null) {\n return;\n }\n\n const diagnostics =\n (await getPluginDiagnosticsForDocument(\n workspaceRoots,\n filePath,\n document.getText(),\n pluginQueryTimeoutMs\n )) ?? [];\n\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: toLspDiagnostics(document, diagnostics, {\n source: diagnosticSource,\n }),\n });\n }\n\n connection.onInitialize((params): InitializeResult => {\n workspaceRoots = dedupeWorkspaceRoots([\n ...getWorkspaceRootsFromInitializeParams(params),\n ...workspaceRoots,\n ]);\n\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments for tags and target specifiers\n triggerCharacters: [\"@\", \":\"],\n },\n hoverProvider: true,\n definitionProvider: true,\n },\n serverInfo: {\n name: \"formspec-language-server\",\n version: \"0.1.0\",\n },\n };\n });\n\n connection.onCompletion(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticContext =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginCompletionContextForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getCompletionItemsAtOffset(documentText, offset, options.extensions, semanticContext);\n });\n\n connection.onHover(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticHover =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginHoverForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getHoverAtOffset(documentText, offset, options.extensions, semanticHover);\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n documents.onDidOpen(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidChangeContent(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidClose(({ document }) => {\n if (diagnosticsMode === \"plugin\") {\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: [] satisfies Diagnostic[],\n });\n }\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Uses the shared tag registry from `@formspec/analysis` so completions stay\n * aligned with the same metadata that powers linting and build-time analysis.\n */\n\nimport {\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedTagDefinition,\n getConstraintTagDefinitions,\n getSemanticCommentCompletionContextAtOffset,\n type TagDefinition,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the full set of tag-name completions currently known to FormSpec.\n *\n * @public\n */\nexport function getCompletionItems(extensions?: readonly ExtensionDefinition[]): CompletionItem[] {\n return getConstraintTagDefinitions(extensions).map((tag) => ({\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n }));\n}\n\nfunction toCompletionItem(tag: TagDefinition | FormSpecSerializedTagDefinition): CompletionItem {\n return {\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n };\n}\n\nfunction toTargetCompletionItems(\n tagName: string,\n targetCompletions: readonly string[]\n): CompletionItem[] {\n return targetCompletions.map((target: string) => ({\n label: target,\n kind:\n target === \"singular\" || target === \"plural\"\n ? CompletionItemKind.EnumMember\n : CompletionItemKind.Field,\n detail: `Target for @${tagName}`,\n }));\n}\n\nfunction filterTagNameCompletionItems(\n prefix: string,\n availableTags: readonly (TagDefinition | FormSpecSerializedTagDefinition)[]\n): CompletionItem[] {\n const normalizedPrefix = prefix.toLowerCase();\n return availableTags\n .map(toCompletionItem)\n .filter((item) => item.label.slice(1).toLowerCase().startsWith(normalizedPrefix));\n}\n\n/**\n * Returns completion items for the cursor position at `offset` in `documentText`.\n *\n * When `semanticContext` is supplied (e.g. from {@link getPluginCompletionContextForDocument}),\n * it is used directly to produce target-value or tag-name completions. Pass `null` or omit it\n * to fall back to syntax-only analysis, which works without the TypeScript plugin.\n *\n * @public\n */\nexport function getCompletionItemsAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticContext?: FormSpecSerializedCompletionContext | null\n): CompletionItem[] {\n if (semanticContext !== null && semanticContext !== undefined) {\n if (semanticContext.kind === \"target\") {\n return toTargetCompletionItems(\n semanticContext.semantic.tagName,\n semanticContext.semantic.targetCompletions\n );\n }\n\n if (semanticContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(semanticContext.prefix, semanticContext.availableTags);\n }\n\n const resolvedContext = getSemanticCommentCompletionContextAtOffset(\n documentText,\n offset,\n extensions ? { extensions } : undefined\n );\n\n if (resolvedContext.kind === \"target\") {\n return toTargetCompletionItems(\n resolvedContext.semantic.tag.normalizedTagName,\n resolvedContext.semantic.targetCompletions\n );\n }\n\n if (resolvedContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(resolvedContext.prefix, resolvedContext.availableTags);\n}\n","/**\n * Hover provider for FormSpec JSDoc tags.\n *\n * Uses the shared registry from `@formspec/analysis` so hover content stays in\n * sync with the tag inventory and overload metadata.\n */\n\nimport {\n type FormSpecSerializedHoverInfo,\n getCommentHoverInfoAtOffset,\n getTagDefinition,\n normalizeFormSpecTagName,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns hover content for a single FormSpec tag name.\n *\n * @public\n */\nexport function getHoverForTag(\n tagName: string,\n extensions?: readonly ExtensionDefinition[]\n): Hover | null {\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const definition = getTagDefinition(normalizeFormSpecTagName(raw), extensions);\n if (!definition) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: definition.hoverMarkdown,\n },\n };\n}\n\n/**\n * Returns LSP hover content for the cursor position at `offset` in `documentText`.\n *\n * When `semanticHover` is supplied (e.g. from {@link getPluginHoverForDocument}), it is used\n * directly as the hover source. Pass `null` or omit it to fall back to syntax-only analysis,\n * which works without the TypeScript plugin. Returns `null` when the cursor is not over a\n * recognised FormSpec tag.\n *\n * @public\n */\nexport function getHoverAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticHover?: FormSpecSerializedHoverInfo | null\n): Hover | null {\n const hoverInfo =\n semanticHover ??\n getCommentHoverInfoAtOffset(documentText, offset, extensions ? { extensions } : undefined);\n if (hoverInfo === null) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: hoverInfo.markdown,\n },\n };\n}\n","/**\n * Go-to-definition provider for FormSpec.\n *\n * This is a stub — go-to-definition support (e.g., navigating from a\n * `field.text(\"name\")` call to the form definition that references it) will\n * be implemented in a future phase.\n */\n\nimport type { Location } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the definition location for a symbol at the given position.\n *\n * Always returns `null` in this stub implementation.\n *\n * @returns `null` — not yet implemented\n * @public\n */\nexport function getDefinition(): Location | null {\n return null;\n}\n","import type {\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nimport {\n DiagnosticRelatedInformation,\n DiagnosticSeverity,\n Location,\n Range,\n type Diagnostic,\n} from \"vscode-languageserver/node.js\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { fileUriToPathOrNull } from \"./plugin-client.js\";\nexport { getPluginDiagnosticsForDocument } from \"./plugin-client.js\";\n\n/**\n * Options for converting canonical FormSpec diagnostics into LSP diagnostics.\n *\n * @public\n */\nexport interface ToLspDiagnosticsOptions {\n /** Source label shown by LSP clients. Defaults to `formspec`. */\n readonly source?: string;\n}\n\n/**\n * Converts canonical FormSpec diagnostics into LSP diagnostics.\n *\n * Downstream consumers that want complete white-label control can ignore this\n * helper and render their own messages from `code` + `data`.\n *\n * @public\n */\nexport function toLspDiagnostics(\n document: TextDocument,\n diagnostics: readonly FormSpecAnalysisDiagnostic[],\n options: ToLspDiagnosticsOptions = {}\n): Diagnostic[] {\n const source = options.source ?? \"formspec\";\n return diagnostics.map((diagnostic) => {\n const relatedInformation = toRelatedInformation(document, diagnostic.relatedLocations);\n return {\n range: spanToRange(document, diagnostic.range.start, diagnostic.range.end),\n severity: toLspSeverity(diagnostic.severity),\n source,\n code: diagnostic.code,\n message: diagnostic.message,\n ...(relatedInformation === undefined ? {} : { relatedInformation }),\n data: {\n ...diagnostic.data,\n category: diagnostic.category,\n },\n };\n });\n}\n\nfunction spanToRange(document: TextDocument, start: number, end: number): Range {\n return Range.create(document.positionAt(start), document.positionAt(end));\n}\n\nfunction toLspSeverity(severity: FormSpecAnalysisDiagnostic[\"severity\"]): DiagnosticSeverity {\n switch (severity) {\n case \"error\":\n return DiagnosticSeverity.Error;\n case \"warning\":\n return DiagnosticSeverity.Warning;\n case \"info\":\n return DiagnosticSeverity.Information;\n default:\n return DiagnosticSeverity.Information;\n }\n}\n\nfunction toRelatedInformation(\n document: TextDocument,\n locations: readonly FormSpecAnalysisDiagnosticLocation[]\n): DiagnosticRelatedInformation[] | undefined {\n if (locations.length === 0) {\n return undefined;\n }\n\n const currentDocumentFilePath = getDocumentFilePath(document);\n const relatedInformation = locations\n .filter((location) => location.filePath === currentDocumentFilePath)\n .map((location) =>\n DiagnosticRelatedInformation.create(\n Location.create(\n document.uri,\n spanToRange(document, location.range.start, location.range.end)\n ),\n location.message ?? \"Related FormSpec location\"\n )\n );\n\n return relatedInformation.length === 0 ? undefined : relatedInformation;\n}\n\nfunction getDocumentFilePath(document: TextDocument): string | null {\n return fileUriToPathOrNull(document.uri);\n}\n","import fs from \"node:fs/promises\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n computeFormSpecTextHash,\n isFormSpecAnalysisManifest,\n isFormSpecSemanticResponse,\n type FormSpecAnalysisDiagnostic,\n type FormSpecAnalysisManifest,\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedHoverInfo,\n type FormSpecSemanticQuery,\n type FormSpecSemanticResponse,\n} from \"@formspec/analysis/protocol\";\nimport { getFormSpecManifestPath } from \"@formspec/analysis/internal\";\n\nconst DEFAULT_PLUGIN_QUERY_TIMEOUT_MS = 2_000;\n\nfunction getManifestPath(workspaceRoot: string): string {\n return getFormSpecManifestPath(workspaceRoot);\n}\n\nfunction normalizeWorkspaceRoot(root: string): string {\n const resolved = path.resolve(root);\n const parsed = path.parse(resolved);\n let normalized = resolved;\n\n while (normalized.length > parsed.root.length && normalized.endsWith(path.sep)) {\n normalized = normalized.slice(0, -path.sep.length);\n }\n\n return normalized;\n}\n\nfunction getMatchingWorkspaceRoot(\n workspaceRoots: readonly string[],\n filePath: string\n): string | null {\n const normalizedFilePath = path.resolve(filePath);\n const normalizedRoots = [...workspaceRoots]\n .map(normalizeWorkspaceRoot)\n .sort((left, right) => right.length - left.length);\n return (\n normalizedRoots.find(\n (workspaceRoot) =>\n normalizedFilePath === workspaceRoot ||\n normalizedFilePath.startsWith(`${workspaceRoot}${path.sep}`)\n ) ?? null\n );\n}\n\nasync function readManifest(workspaceRoot: string): Promise<FormSpecAnalysisManifest | null> {\n try {\n const manifestText = await fs.readFile(getManifestPath(workspaceRoot), \"utf8\");\n const manifest = JSON.parse(manifestText) as unknown;\n if (!isFormSpecAnalysisManifest(manifest)) {\n return null;\n }\n\n return manifest;\n } catch {\n return null;\n }\n}\n\nasync function sendSemanticQuery(\n manifest: FormSpecAnalysisManifest,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n return new Promise((resolve) => {\n const socket = net.createConnection(manifest.endpoint.address);\n let buffer = \"\";\n let settled = false;\n\n const finish = (response: FormSpecSemanticResponse | null): void => {\n if (settled) {\n return;\n }\n settled = true;\n socket.removeAllListeners(\"data\");\n socket.destroy();\n resolve(response);\n };\n\n socket.setTimeout(timeoutMs, () => {\n finish(null);\n });\n\n socket.setEncoding(\"utf8\");\n socket.on(\"connect\", () => {\n socket.write(`${JSON.stringify(query)}\\n`);\n });\n socket.on(\"data\", (chunk) => {\n buffer += String(chunk);\n const newlineIndex = buffer.indexOf(\"\\n\");\n if (newlineIndex < 0) {\n return;\n }\n\n const payload = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n try {\n const response = JSON.parse(payload) as unknown;\n finish(isFormSpecSemanticResponse(response) ? response : null);\n } catch {\n finish(null);\n }\n });\n socket.on(\"error\", () => {\n finish(null);\n });\n socket.on(\"close\", () => {\n finish(null);\n });\n });\n}\n\n/**\n * Converts a `file://` URI to an absolute filesystem path.\n *\n * Returns `null` for any URI that is not a valid `file://` URI (e.g. `untitled:`, `vscode-notebook-cell:`,\n * malformed URIs). On Windows the returned path uses backslash separators as produced by\n * `url.fileURLToPath`.\n *\n * @public\n */\nexport function fileUriToPathOrNull(uri: string): string | null {\n try {\n return fileURLToPath(uri);\n } catch {\n return null;\n }\n}\n\nasync function sendFileQuery(\n workspaceRoots: readonly string[],\n filePath: string,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n const workspaceRoot = getMatchingWorkspaceRoot(workspaceRoots, filePath);\n if (workspaceRoot === null) {\n return null;\n }\n\n const manifest = await readManifest(workspaceRoot);\n if (manifest === null) {\n return null;\n }\n\n return sendSemanticQuery(manifest, query, timeoutMs);\n}\n\n/**\n * Queries the FormSpec TypeScript plugin for semantic completion context at `offset` in the\n * document identified by `filePath`.\n *\n * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The\n * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root\n * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times\n * out (default 2 s), or the plugin's response was computed against a different version of the\n * document than `documentText` (stale response guard).\n *\n * Pass the result to {@link getCompletionItemsAtOffset} as `semanticContext`.\n *\n * @public\n */\nexport async function getPluginCompletionContextForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedCompletionContext | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"completion\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"completion\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.context : null;\n}\n\n/**\n * Queries the FormSpec TypeScript plugin for semantic hover information at `offset` in the\n * document identified by `filePath`.\n *\n * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The\n * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root\n * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times\n * out (default 2 s), or the plugin's response was computed against a different version of the\n * document than `documentText` (stale response guard).\n *\n * Pass the result to {@link getHoverAtOffset} as `semanticHover`.\n *\n * @public\n */\nexport async function getPluginHoverForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedHoverInfo | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"hover\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"hover\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.hover : null;\n}\n\n/**\n * Retrieves canonical FormSpec diagnostics for the current document revision\n * from the plugin transport. Returns `null` when the transport is missing,\n * stale, or invalid.\n *\n * @public\n */\nexport async function getPluginDiagnosticsForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<readonly FormSpecAnalysisDiagnostic[] | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"diagnostics\",\n filePath,\n },\n timeoutMs\n );\n if (response?.kind !== \"diagnostics\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText)\n ? response.diagnostics\n : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYA,IAAAA,eAQO;AAEP,gDAA6B;;;ACf7B,sBAMO;AAEP,kBAA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;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,mBAAmB,CAAC,EAAE,SAAS,MAAM;AAC7C,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,WAAW,CAAC,EAAE,SAAS,MAAM;AACrC,QAAI,oBAAoB,UAAU;AAChC,WAAK,WAAW,gBAAgB;AAAA,QAC9B,KAAK,SAAS;AAAA,QACd,aAAa,CAAC;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["import_node","import_internal","import_node","import_internal","path","fs","net"]}
package/dist/index.d.ts CHANGED
@@ -25,9 +25,10 @@
25
25
  */
26
26
  export { createServer } from "./server.js";
27
27
  export type { CreateServerOptions } from "./server.js";
28
- export type { CommentSpan, FormSpecAnalysisDiagnostic, FormSpecAnalysisDiagnosticCategory, FormSpecAnalysisDiagnosticDataValue, FormSpecAnalysisDiagnosticLocation, } from "@formspec/analysis/protocol";
28
+ export type { CommentSourceSpan, CommentSpan, FormSpecAnalysisDiagnostic, FormSpecAnalysisDiagnosticCategory, FormSpecAnalysisDiagnosticDataValue, FormSpecAnalysisDiagnosticLocation, } from "@formspec/analysis/protocol";
29
29
  export { getPluginDiagnosticsForDocument, toLspDiagnostics, type ToLspDiagnosticsOptions, } from "./diagnostics.js";
30
- export { getCompletionItems } from "./providers/completion.js";
31
- export { getHoverForTag } from "./providers/hover.js";
30
+ export { getCompletionItems, getCompletionItemsAtOffset } from "./providers/completion.js";
31
+ export { getHoverForTag, getHoverAtOffset } from "./providers/hover.js";
32
32
  export { getDefinition } from "./providers/definition.js";
33
+ export { fileUriToPathOrNull, getPluginCompletionContextForDocument, getPluginHoverForDocument, } from "./plugin-client.js";
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,mCAAmC,EACnC,kCAAkC,GACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,+BAA+B,EAC/B,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,mCAAmC,EACnC,kCAAkC,GACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,+BAA+B,EAC/B,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,qCAAqC,EACrC,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -460,10 +460,15 @@ function createServer(options = {}) {
460
460
  }
461
461
  export {
462
462
  createServer,
463
+ fileUriToPathOrNull,
463
464
  getCompletionItems,
465
+ getCompletionItemsAtOffset,
464
466
  getDefinition,
467
+ getHoverAtOffset,
465
468
  getHoverForTag,
469
+ getPluginCompletionContextForDocument,
466
470
  getPluginDiagnosticsForDocument,
471
+ getPluginHoverForDocument,
467
472
  toLspDiagnostics
468
473
  };
469
474
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.ts","../src/diagnostics.ts","../src/plugin-client.ts"],"sourcesContent":["/**\n * FormSpec Language Server\n *\n * Sets up an LSP server connection and registers handlers for:\n * - `textDocument/completion` — FormSpec JSDoc constraint tag completions\n * - `textDocument/hover` — Documentation for recognized constraint tags\n * - `textDocument/definition` — Go-to-definition (stub, returns null)\n *\n * The packaged language server is a reference implementation built on the same\n * composable helpers that downstream consumers can call directly.\n */\n\nimport {\n createConnection,\n Diagnostic,\n ProposedFeatures,\n TextDocuments,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { getCompletionItemsAtOffset } from \"./providers/completion.js\";\nimport { getHoverAtOffset } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\nimport { getPluginDiagnosticsForDocument, toLspDiagnostics } from \"./diagnostics.js\";\nimport {\n fileUriToPathOrNull,\n getPluginCompletionContextForDocument,\n getPluginHoverForDocument,\n} from \"./plugin-client.js\";\n\nconst PLUGIN_QUERY_TIMEOUT_ENV_VAR = \"FORMSPEC_PLUGIN_QUERY_TIMEOUT_MS\";\n\nfunction dedupeWorkspaceRoots(workspaceRoots: readonly string[]): string[] {\n return [...new Set(workspaceRoots)];\n}\n\nfunction resolvePluginQueryTimeoutMs(explicitTimeoutMs: number | undefined): number | undefined {\n if (explicitTimeoutMs !== undefined) {\n return explicitTimeoutMs;\n }\n\n const rawValue = process.env[PLUGIN_QUERY_TIMEOUT_ENV_VAR];\n if (rawValue === undefined) {\n return undefined;\n }\n\n const parsed = Number.parseInt(rawValue, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction getWorkspaceRootsFromInitializeParams(params: {\n readonly workspaceFolders?: readonly { readonly uri: string }[] | null;\n readonly rootUri?: string | null;\n readonly rootPath?: string | null;\n}): string[] {\n const workspaceFolders =\n params.workspaceFolders\n ?.map((workspaceFolder) => fileUriToPathOrNull(workspaceFolder.uri))\n .filter((workspaceRoot): workspaceRoot is string => workspaceRoot !== null) ?? [];\n const rootUri =\n params.rootUri === null || params.rootUri === undefined\n ? null\n : fileUriToPathOrNull(params.rootUri);\n const rootPath = params.rootPath ?? null;\n\n return dedupeWorkspaceRoots([\n ...workspaceFolders,\n ...(rootUri === null ? [] : [rootUri]),\n ...(rootPath === null ? [] : [rootPath]),\n ]);\n}\n\n/**\n * Public configuration for constructing the FormSpec language server.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /** Optional extension definitions whose custom tags should be surfaced by tooling. */\n readonly extensions?: readonly ExtensionDefinition[];\n /** Optional workspace roots to use before initialize() provides them. */\n readonly workspaceRoots?: readonly string[];\n /** Set to false to disable tsserver-plugin semantic enrichment. */\n readonly usePluginTransport?: boolean;\n /** IPC timeout, in milliseconds, for semantic plugin requests. */\n readonly pluginQueryTimeoutMs?: number;\n /** Optional diagnostics publishing mode for the packaged reference LSP. */\n readonly diagnosticsMode?: \"off\" | \"plugin\";\n /** Source label to use when publishing plugin-derived diagnostics. */\n readonly diagnosticSource?: string;\n}\n\n/**\n * Creates and configures the FormSpec language server connection.\n *\n * Registers LSP capability handlers and returns the connection.\n * Call `connection.listen()` to start accepting messages.\n *\n * @returns The configured LSP connection (not yet listening)\n * @public\n */\nexport function createServer(options: CreateServerOptions = {}): Connection {\n const connection = createConnection(ProposedFeatures.all);\n const documents = new TextDocuments(TextDocument);\n let workspaceRoots = [...(options.workspaceRoots ?? [])];\n const pluginQueryTimeoutMs = resolvePluginQueryTimeoutMs(options.pluginQueryTimeoutMs);\n const diagnosticsMode = options.diagnosticsMode ?? \"off\";\n const diagnosticSource = options.diagnosticSource ?? \"formspec\";\n\n documents.listen(connection);\n\n async function publishDiagnosticsForDocument(document: TextDocument): Promise<void> {\n if (diagnosticsMode !== \"plugin\" || options.usePluginTransport === false) {\n return;\n }\n\n const filePath = fileUriToPathOrNull(document.uri);\n if (filePath === null) {\n return;\n }\n\n const diagnostics =\n (await getPluginDiagnosticsForDocument(\n workspaceRoots,\n filePath,\n document.getText(),\n pluginQueryTimeoutMs\n )) ?? [];\n\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: toLspDiagnostics(document, diagnostics, {\n source: diagnosticSource,\n }),\n });\n }\n\n connection.onInitialize((params): InitializeResult => {\n workspaceRoots = dedupeWorkspaceRoots([\n ...getWorkspaceRootsFromInitializeParams(params),\n ...workspaceRoots,\n ]);\n\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments for tags and target specifiers\n triggerCharacters: [\"@\", \":\"],\n },\n hoverProvider: true,\n definitionProvider: true,\n },\n serverInfo: {\n name: \"formspec-language-server\",\n version: \"0.1.0\",\n },\n };\n });\n\n connection.onCompletion(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticContext =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginCompletionContextForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getCompletionItemsAtOffset(documentText, offset, options.extensions, semanticContext);\n });\n\n connection.onHover(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticHover =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginHoverForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getHoverAtOffset(documentText, offset, options.extensions, semanticHover);\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n documents.onDidOpen(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidChangeContent(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidClose(({ document }) => {\n if (diagnosticsMode === \"plugin\") {\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: [] satisfies Diagnostic[],\n });\n }\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Uses the shared tag registry from `@formspec/analysis` so completions stay\n * aligned with the same metadata that powers linting and build-time analysis.\n */\n\nimport {\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedTagDefinition,\n getConstraintTagDefinitions,\n getSemanticCommentCompletionContextAtOffset,\n type TagDefinition,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the full set of tag-name completions currently known to FormSpec.\n *\n * @public\n */\nexport function getCompletionItems(extensions?: readonly ExtensionDefinition[]): CompletionItem[] {\n return getConstraintTagDefinitions(extensions).map((tag) => ({\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n }));\n}\n\nfunction toCompletionItem(tag: TagDefinition | FormSpecSerializedTagDefinition): CompletionItem {\n return {\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n };\n}\n\nfunction toTargetCompletionItems(\n tagName: string,\n targetCompletions: readonly string[]\n): CompletionItem[] {\n return targetCompletions.map((target: string) => ({\n label: target,\n kind:\n target === \"singular\" || target === \"plural\"\n ? CompletionItemKind.EnumMember\n : CompletionItemKind.Field,\n detail: `Target for @${tagName}`,\n }));\n}\n\nfunction filterTagNameCompletionItems(\n prefix: string,\n availableTags: readonly (TagDefinition | FormSpecSerializedTagDefinition)[]\n): CompletionItem[] {\n const normalizedPrefix = prefix.toLowerCase();\n return availableTags\n .map(toCompletionItem)\n .filter((item) => item.label.slice(1).toLowerCase().startsWith(normalizedPrefix));\n}\n\n/** @internal */\nexport function getCompletionItemsAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticContext?: FormSpecSerializedCompletionContext | null\n): CompletionItem[] {\n if (semanticContext !== null && semanticContext !== undefined) {\n if (semanticContext.kind === \"target\") {\n return toTargetCompletionItems(\n semanticContext.semantic.tagName,\n semanticContext.semantic.targetCompletions\n );\n }\n\n if (semanticContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(semanticContext.prefix, semanticContext.availableTags);\n }\n\n const resolvedContext = getSemanticCommentCompletionContextAtOffset(\n documentText,\n offset,\n extensions ? { extensions } : undefined\n );\n\n if (resolvedContext.kind === \"target\") {\n return toTargetCompletionItems(\n resolvedContext.semantic.tag.normalizedTagName,\n resolvedContext.semantic.targetCompletions\n );\n }\n\n if (resolvedContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(resolvedContext.prefix, resolvedContext.availableTags);\n}\n","/**\n * Hover provider for FormSpec JSDoc tags.\n *\n * Uses the shared registry from `@formspec/analysis` so hover content stays in\n * sync with the tag inventory and overload metadata.\n */\n\nimport {\n type FormSpecSerializedHoverInfo,\n getCommentHoverInfoAtOffset,\n getTagDefinition,\n normalizeFormSpecTagName,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns hover content for a single FormSpec tag name.\n *\n * @public\n */\nexport function getHoverForTag(\n tagName: string,\n extensions?: readonly ExtensionDefinition[]\n): Hover | null {\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const definition = getTagDefinition(normalizeFormSpecTagName(raw), extensions);\n if (!definition) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: definition.hoverMarkdown,\n },\n };\n}\n\n/** @internal */\nexport function getHoverAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticHover?: FormSpecSerializedHoverInfo | null\n): Hover | null {\n const hoverInfo =\n semanticHover ??\n getCommentHoverInfoAtOffset(documentText, offset, extensions ? { extensions } : undefined);\n if (hoverInfo === null) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: hoverInfo.markdown,\n },\n };\n}\n","/**\n * Go-to-definition provider for FormSpec.\n *\n * This is a stub — go-to-definition support (e.g., navigating from a\n * `field.text(\"name\")` call to the form definition that references it) will\n * be implemented in a future phase.\n */\n\nimport type { Location } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the definition location for a symbol at the given position.\n *\n * Always returns `null` in this stub implementation.\n *\n * @returns `null` — not yet implemented\n * @public\n */\nexport function getDefinition(): Location | null {\n return null;\n}\n","import type {\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nimport {\n DiagnosticRelatedInformation,\n DiagnosticSeverity,\n Location,\n Range,\n type Diagnostic,\n} from \"vscode-languageserver/node.js\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { fileUriToPathOrNull } from \"./plugin-client.js\";\nexport { getPluginDiagnosticsForDocument } from \"./plugin-client.js\";\n\n/**\n * Options for converting canonical FormSpec diagnostics into LSP diagnostics.\n *\n * @public\n */\nexport interface ToLspDiagnosticsOptions {\n /** Source label shown by LSP clients. Defaults to `formspec`. */\n readonly source?: string;\n}\n\n/**\n * Converts canonical FormSpec diagnostics into LSP diagnostics.\n *\n * Downstream consumers that want complete white-label control can ignore this\n * helper and render their own messages from `code` + `data`.\n *\n * @public\n */\nexport function toLspDiagnostics(\n document: TextDocument,\n diagnostics: readonly FormSpecAnalysisDiagnostic[],\n options: ToLspDiagnosticsOptions = {}\n): Diagnostic[] {\n const source = options.source ?? \"formspec\";\n return diagnostics.map((diagnostic) => {\n const relatedInformation = toRelatedInformation(document, diagnostic.relatedLocations);\n return {\n range: spanToRange(document, diagnostic.range.start, diagnostic.range.end),\n severity: toLspSeverity(diagnostic.severity),\n source,\n code: diagnostic.code,\n message: diagnostic.message,\n ...(relatedInformation === undefined ? {} : { relatedInformation }),\n data: {\n ...diagnostic.data,\n category: diagnostic.category,\n },\n };\n });\n}\n\nfunction spanToRange(document: TextDocument, start: number, end: number): Range {\n return Range.create(document.positionAt(start), document.positionAt(end));\n}\n\nfunction toLspSeverity(severity: FormSpecAnalysisDiagnostic[\"severity\"]): DiagnosticSeverity {\n switch (severity) {\n case \"error\":\n return DiagnosticSeverity.Error;\n case \"warning\":\n return DiagnosticSeverity.Warning;\n case \"info\":\n return DiagnosticSeverity.Information;\n default:\n return DiagnosticSeverity.Information;\n }\n}\n\nfunction toRelatedInformation(\n document: TextDocument,\n locations: readonly FormSpecAnalysisDiagnosticLocation[]\n): DiagnosticRelatedInformation[] | undefined {\n if (locations.length === 0) {\n return undefined;\n }\n\n const currentDocumentFilePath = getDocumentFilePath(document);\n const relatedInformation = locations\n .filter((location) => location.filePath === currentDocumentFilePath)\n .map((location) =>\n DiagnosticRelatedInformation.create(\n Location.create(\n document.uri,\n spanToRange(document, location.range.start, location.range.end)\n ),\n location.message ?? \"Related FormSpec location\"\n )\n );\n\n return relatedInformation.length === 0 ? undefined : relatedInformation;\n}\n\nfunction getDocumentFilePath(document: TextDocument): string | null {\n return fileUriToPathOrNull(document.uri);\n}\n","import fs from \"node:fs/promises\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n computeFormSpecTextHash,\n isFormSpecAnalysisManifest,\n isFormSpecSemanticResponse,\n type FormSpecAnalysisDiagnostic,\n type FormSpecAnalysisManifest,\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedHoverInfo,\n type FormSpecSemanticQuery,\n type FormSpecSemanticResponse,\n} from \"@formspec/analysis/protocol\";\nimport { getFormSpecManifestPath } from \"@formspec/analysis/internal\";\n\nconst DEFAULT_PLUGIN_QUERY_TIMEOUT_MS = 2_000;\n\nfunction getManifestPath(workspaceRoot: string): string {\n return getFormSpecManifestPath(workspaceRoot);\n}\n\nfunction normalizeWorkspaceRoot(root: string): string {\n const resolved = path.resolve(root);\n const parsed = path.parse(resolved);\n let normalized = resolved;\n\n while (normalized.length > parsed.root.length && normalized.endsWith(path.sep)) {\n normalized = normalized.slice(0, -path.sep.length);\n }\n\n return normalized;\n}\n\nfunction getMatchingWorkspaceRoot(\n workspaceRoots: readonly string[],\n filePath: string\n): string | null {\n const normalizedFilePath = path.resolve(filePath);\n const normalizedRoots = [...workspaceRoots]\n .map(normalizeWorkspaceRoot)\n .sort((left, right) => right.length - left.length);\n return (\n normalizedRoots.find(\n (workspaceRoot) =>\n normalizedFilePath === workspaceRoot ||\n normalizedFilePath.startsWith(`${workspaceRoot}${path.sep}`)\n ) ?? null\n );\n}\n\nasync function readManifest(workspaceRoot: string): Promise<FormSpecAnalysisManifest | null> {\n try {\n const manifestText = await fs.readFile(getManifestPath(workspaceRoot), \"utf8\");\n const manifest = JSON.parse(manifestText) as unknown;\n if (!isFormSpecAnalysisManifest(manifest)) {\n return null;\n }\n\n return manifest;\n } catch {\n return null;\n }\n}\n\nasync function sendSemanticQuery(\n manifest: FormSpecAnalysisManifest,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n return new Promise((resolve) => {\n const socket = net.createConnection(manifest.endpoint.address);\n let buffer = \"\";\n let settled = false;\n\n const finish = (response: FormSpecSemanticResponse | null): void => {\n if (settled) {\n return;\n }\n settled = true;\n socket.removeAllListeners(\"data\");\n socket.destroy();\n resolve(response);\n };\n\n socket.setTimeout(timeoutMs, () => {\n finish(null);\n });\n\n socket.setEncoding(\"utf8\");\n socket.on(\"connect\", () => {\n socket.write(`${JSON.stringify(query)}\\n`);\n });\n socket.on(\"data\", (chunk) => {\n buffer += String(chunk);\n const newlineIndex = buffer.indexOf(\"\\n\");\n if (newlineIndex < 0) {\n return;\n }\n\n const payload = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n try {\n const response = JSON.parse(payload) as unknown;\n finish(isFormSpecSemanticResponse(response) ? response : null);\n } catch {\n finish(null);\n }\n });\n socket.on(\"error\", () => {\n finish(null);\n });\n socket.on(\"close\", () => {\n finish(null);\n });\n });\n}\n\nexport function fileUriToPathOrNull(uri: string): string | null {\n try {\n return fileURLToPath(uri);\n } catch {\n return null;\n }\n}\n\nasync function sendFileQuery(\n workspaceRoots: readonly string[],\n filePath: string,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n const workspaceRoot = getMatchingWorkspaceRoot(workspaceRoots, filePath);\n if (workspaceRoot === null) {\n return null;\n }\n\n const manifest = await readManifest(workspaceRoot);\n if (manifest === null) {\n return null;\n }\n\n return sendSemanticQuery(manifest, query, timeoutMs);\n}\n\nexport async function getPluginCompletionContextForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedCompletionContext | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"completion\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"completion\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.context : null;\n}\n\nexport async function getPluginHoverForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedHoverInfo | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"hover\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"hover\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.hover : null;\n}\n\n/**\n * Retrieves canonical FormSpec diagnostics for the current document revision\n * from the plugin transport. Returns `null` when the transport is missing,\n * stale, or invalid.\n *\n * @public\n */\nexport async function getPluginDiagnosticsForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<readonly FormSpecAnalysisDiagnostic[] | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"diagnostics\",\n filePath,\n },\n timeoutMs\n );\n if (response?.kind !== \"diagnostics\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText)\n ? response.diagnostics\n : null;\n}\n"],"mappings":";AAYA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,oBAAoB;;;ACf7B;AAAA,EAGE;AAAA,EACA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YAAU,UAAU,CAAC,EAAE,SAAS,MAAM;AACpC,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,mBAAmB,CAAC,EAAE,SAAS,MAAM;AAC7C,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,WAAW,CAAC,EAAE,SAAS,MAAM;AACrC,QAAI,oBAAoB,UAAU;AAChC,WAAK,WAAW,gBAAgB;AAAA,QAC9B,KAAK,SAAS;AAAA,QACd,aAAa,CAAC;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.ts","../src/diagnostics.ts","../src/plugin-client.ts"],"sourcesContent":["/**\n * FormSpec Language Server\n *\n * Sets up an LSP server connection and registers handlers for:\n * - `textDocument/completion` — FormSpec JSDoc constraint tag completions\n * - `textDocument/hover` — Documentation for recognized constraint tags\n * - `textDocument/definition` — Go-to-definition (stub, returns null)\n *\n * The packaged language server is a reference implementation built on the same\n * composable helpers that downstream consumers can call directly.\n */\n\nimport {\n createConnection,\n Diagnostic,\n ProposedFeatures,\n TextDocuments,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { getCompletionItemsAtOffset } from \"./providers/completion.js\";\nimport { getHoverAtOffset } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\nimport { getPluginDiagnosticsForDocument, toLspDiagnostics } from \"./diagnostics.js\";\nimport {\n fileUriToPathOrNull,\n getPluginCompletionContextForDocument,\n getPluginHoverForDocument,\n} from \"./plugin-client.js\";\n\nconst PLUGIN_QUERY_TIMEOUT_ENV_VAR = \"FORMSPEC_PLUGIN_QUERY_TIMEOUT_MS\";\n\nfunction dedupeWorkspaceRoots(workspaceRoots: readonly string[]): string[] {\n return [...new Set(workspaceRoots)];\n}\n\nfunction resolvePluginQueryTimeoutMs(explicitTimeoutMs: number | undefined): number | undefined {\n if (explicitTimeoutMs !== undefined) {\n return explicitTimeoutMs;\n }\n\n const rawValue = process.env[PLUGIN_QUERY_TIMEOUT_ENV_VAR];\n if (rawValue === undefined) {\n return undefined;\n }\n\n const parsed = Number.parseInt(rawValue, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction getWorkspaceRootsFromInitializeParams(params: {\n readonly workspaceFolders?: readonly { readonly uri: string }[] | null;\n readonly rootUri?: string | null;\n readonly rootPath?: string | null;\n}): string[] {\n const workspaceFolders =\n params.workspaceFolders\n ?.map((workspaceFolder) => fileUriToPathOrNull(workspaceFolder.uri))\n .filter((workspaceRoot): workspaceRoot is string => workspaceRoot !== null) ?? [];\n const rootUri =\n params.rootUri === null || params.rootUri === undefined\n ? null\n : fileUriToPathOrNull(params.rootUri);\n const rootPath = params.rootPath ?? null;\n\n return dedupeWorkspaceRoots([\n ...workspaceFolders,\n ...(rootUri === null ? [] : [rootUri]),\n ...(rootPath === null ? [] : [rootPath]),\n ]);\n}\n\n/**\n * Public configuration for constructing the FormSpec language server.\n *\n * @public\n */\nexport interface CreateServerOptions {\n /** Optional extension definitions whose custom tags should be surfaced by tooling. */\n readonly extensions?: readonly ExtensionDefinition[];\n /** Optional workspace roots to use before initialize() provides them. */\n readonly workspaceRoots?: readonly string[];\n /** Set to false to disable tsserver-plugin semantic enrichment. */\n readonly usePluginTransport?: boolean;\n /** IPC timeout, in milliseconds, for semantic plugin requests. */\n readonly pluginQueryTimeoutMs?: number;\n /** Optional diagnostics publishing mode for the packaged reference LSP. */\n readonly diagnosticsMode?: \"off\" | \"plugin\";\n /** Source label to use when publishing plugin-derived diagnostics. */\n readonly diagnosticSource?: string;\n}\n\n/**\n * Creates and configures the FormSpec language server connection.\n *\n * Registers LSP capability handlers and returns the connection.\n * Call `connection.listen()` to start accepting messages.\n *\n * @returns The configured LSP connection (not yet listening)\n * @public\n */\nexport function createServer(options: CreateServerOptions = {}): Connection {\n const connection = createConnection(ProposedFeatures.all);\n const documents = new TextDocuments(TextDocument);\n let workspaceRoots = [...(options.workspaceRoots ?? [])];\n const pluginQueryTimeoutMs = resolvePluginQueryTimeoutMs(options.pluginQueryTimeoutMs);\n const diagnosticsMode = options.diagnosticsMode ?? \"off\";\n const diagnosticSource = options.diagnosticSource ?? \"formspec\";\n\n documents.listen(connection);\n\n async function publishDiagnosticsForDocument(document: TextDocument): Promise<void> {\n if (diagnosticsMode !== \"plugin\" || options.usePluginTransport === false) {\n return;\n }\n\n const filePath = fileUriToPathOrNull(document.uri);\n if (filePath === null) {\n return;\n }\n\n const diagnostics =\n (await getPluginDiagnosticsForDocument(\n workspaceRoots,\n filePath,\n document.getText(),\n pluginQueryTimeoutMs\n )) ?? [];\n\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: toLspDiagnostics(document, diagnostics, {\n source: diagnosticSource,\n }),\n });\n }\n\n connection.onInitialize((params): InitializeResult => {\n workspaceRoots = dedupeWorkspaceRoots([\n ...getWorkspaceRootsFromInitializeParams(params),\n ...workspaceRoots,\n ]);\n\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments for tags and target specifiers\n triggerCharacters: [\"@\", \":\"],\n },\n hoverProvider: true,\n definitionProvider: true,\n },\n serverInfo: {\n name: \"formspec-language-server\",\n version: \"0.1.0\",\n },\n };\n });\n\n connection.onCompletion(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticContext =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginCompletionContextForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getCompletionItemsAtOffset(documentText, offset, options.extensions, semanticContext);\n });\n\n connection.onHover(async (params) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const offset = document.offsetAt(params.position);\n const documentText = document.getText();\n const filePath = fileUriToPathOrNull(params.textDocument.uri);\n const semanticHover =\n options.usePluginTransport === false || filePath === null\n ? null\n : await getPluginHoverForDocument(\n workspaceRoots,\n filePath,\n documentText,\n offset,\n pluginQueryTimeoutMs\n );\n\n return getHoverAtOffset(documentText, offset, options.extensions, semanticHover);\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n documents.onDidOpen(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidChangeContent(({ document }) => {\n void publishDiagnosticsForDocument(document).catch((error: unknown) => {\n connection.console.error(`[FormSpec] Failed to publish diagnostics: ${String(error)}`);\n });\n });\n\n documents.onDidClose(({ document }) => {\n if (diagnosticsMode === \"plugin\") {\n void connection.sendDiagnostics({\n uri: document.uri,\n diagnostics: [] satisfies Diagnostic[],\n });\n }\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Uses the shared tag registry from `@formspec/analysis` so completions stay\n * aligned with the same metadata that powers linting and build-time analysis.\n */\n\nimport {\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedTagDefinition,\n getConstraintTagDefinitions,\n getSemanticCommentCompletionContextAtOffset,\n type TagDefinition,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the full set of tag-name completions currently known to FormSpec.\n *\n * @public\n */\nexport function getCompletionItems(extensions?: readonly ExtensionDefinition[]): CompletionItem[] {\n return getConstraintTagDefinitions(extensions).map((tag) => ({\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n }));\n}\n\nfunction toCompletionItem(tag: TagDefinition | FormSpecSerializedTagDefinition): CompletionItem {\n return {\n label: `@${tag.canonicalName}`,\n kind: CompletionItemKind.Keyword,\n detail: tag.completionDetail,\n };\n}\n\nfunction toTargetCompletionItems(\n tagName: string,\n targetCompletions: readonly string[]\n): CompletionItem[] {\n return targetCompletions.map((target: string) => ({\n label: target,\n kind:\n target === \"singular\" || target === \"plural\"\n ? CompletionItemKind.EnumMember\n : CompletionItemKind.Field,\n detail: `Target for @${tagName}`,\n }));\n}\n\nfunction filterTagNameCompletionItems(\n prefix: string,\n availableTags: readonly (TagDefinition | FormSpecSerializedTagDefinition)[]\n): CompletionItem[] {\n const normalizedPrefix = prefix.toLowerCase();\n return availableTags\n .map(toCompletionItem)\n .filter((item) => item.label.slice(1).toLowerCase().startsWith(normalizedPrefix));\n}\n\n/**\n * Returns completion items for the cursor position at `offset` in `documentText`.\n *\n * When `semanticContext` is supplied (e.g. from {@link getPluginCompletionContextForDocument}),\n * it is used directly to produce target-value or tag-name completions. Pass `null` or omit it\n * to fall back to syntax-only analysis, which works without the TypeScript plugin.\n *\n * @public\n */\nexport function getCompletionItemsAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticContext?: FormSpecSerializedCompletionContext | null\n): CompletionItem[] {\n if (semanticContext !== null && semanticContext !== undefined) {\n if (semanticContext.kind === \"target\") {\n return toTargetCompletionItems(\n semanticContext.semantic.tagName,\n semanticContext.semantic.targetCompletions\n );\n }\n\n if (semanticContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(semanticContext.prefix, semanticContext.availableTags);\n }\n\n const resolvedContext = getSemanticCommentCompletionContextAtOffset(\n documentText,\n offset,\n extensions ? { extensions } : undefined\n );\n\n if (resolvedContext.kind === \"target\") {\n return toTargetCompletionItems(\n resolvedContext.semantic.tag.normalizedTagName,\n resolvedContext.semantic.targetCompletions\n );\n }\n\n if (resolvedContext.kind !== \"tag-name\") {\n return [];\n }\n\n return filterTagNameCompletionItems(resolvedContext.prefix, resolvedContext.availableTags);\n}\n","/**\n * Hover provider for FormSpec JSDoc tags.\n *\n * Uses the shared registry from `@formspec/analysis` so hover content stays in\n * sync with the tag inventory and overload metadata.\n */\n\nimport {\n type FormSpecSerializedHoverInfo,\n getCommentHoverInfoAtOffset,\n getTagDefinition,\n normalizeFormSpecTagName,\n} from \"@formspec/analysis/internal\";\nimport type { ExtensionDefinition } from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns hover content for a single FormSpec tag name.\n *\n * @public\n */\nexport function getHoverForTag(\n tagName: string,\n extensions?: readonly ExtensionDefinition[]\n): Hover | null {\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const definition = getTagDefinition(normalizeFormSpecTagName(raw), extensions);\n if (!definition) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: definition.hoverMarkdown,\n },\n };\n}\n\n/**\n * Returns LSP hover content for the cursor position at `offset` in `documentText`.\n *\n * When `semanticHover` is supplied (e.g. from {@link getPluginHoverForDocument}), it is used\n * directly as the hover source. Pass `null` or omit it to fall back to syntax-only analysis,\n * which works without the TypeScript plugin. Returns `null` when the cursor is not over a\n * recognised FormSpec tag.\n *\n * @public\n */\nexport function getHoverAtOffset(\n documentText: string,\n offset: number,\n extensions?: readonly ExtensionDefinition[],\n semanticHover?: FormSpecSerializedHoverInfo | null\n): Hover | null {\n const hoverInfo =\n semanticHover ??\n getCommentHoverInfoAtOffset(documentText, offset, extensions ? { extensions } : undefined);\n if (hoverInfo === null) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: hoverInfo.markdown,\n },\n };\n}\n","/**\n * Go-to-definition provider for FormSpec.\n *\n * This is a stub — go-to-definition support (e.g., navigating from a\n * `field.text(\"name\")` call to the form definition that references it) will\n * be implemented in a future phase.\n */\n\nimport type { Location } from \"vscode-languageserver/node.js\";\n\n/**\n * Returns the definition location for a symbol at the given position.\n *\n * Always returns `null` in this stub implementation.\n *\n * @returns `null` — not yet implemented\n * @public\n */\nexport function getDefinition(): Location | null {\n return null;\n}\n","import type {\n FormSpecAnalysisDiagnostic,\n FormSpecAnalysisDiagnosticLocation,\n} from \"@formspec/analysis/protocol\";\nimport {\n DiagnosticRelatedInformation,\n DiagnosticSeverity,\n Location,\n Range,\n type Diagnostic,\n} from \"vscode-languageserver/node.js\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { fileUriToPathOrNull } from \"./plugin-client.js\";\nexport { getPluginDiagnosticsForDocument } from \"./plugin-client.js\";\n\n/**\n * Options for converting canonical FormSpec diagnostics into LSP diagnostics.\n *\n * @public\n */\nexport interface ToLspDiagnosticsOptions {\n /** Source label shown by LSP clients. Defaults to `formspec`. */\n readonly source?: string;\n}\n\n/**\n * Converts canonical FormSpec diagnostics into LSP diagnostics.\n *\n * Downstream consumers that want complete white-label control can ignore this\n * helper and render their own messages from `code` + `data`.\n *\n * @public\n */\nexport function toLspDiagnostics(\n document: TextDocument,\n diagnostics: readonly FormSpecAnalysisDiagnostic[],\n options: ToLspDiagnosticsOptions = {}\n): Diagnostic[] {\n const source = options.source ?? \"formspec\";\n return diagnostics.map((diagnostic) => {\n const relatedInformation = toRelatedInformation(document, diagnostic.relatedLocations);\n return {\n range: spanToRange(document, diagnostic.range.start, diagnostic.range.end),\n severity: toLspSeverity(diagnostic.severity),\n source,\n code: diagnostic.code,\n message: diagnostic.message,\n ...(relatedInformation === undefined ? {} : { relatedInformation }),\n data: {\n ...diagnostic.data,\n category: diagnostic.category,\n },\n };\n });\n}\n\nfunction spanToRange(document: TextDocument, start: number, end: number): Range {\n return Range.create(document.positionAt(start), document.positionAt(end));\n}\n\nfunction toLspSeverity(severity: FormSpecAnalysisDiagnostic[\"severity\"]): DiagnosticSeverity {\n switch (severity) {\n case \"error\":\n return DiagnosticSeverity.Error;\n case \"warning\":\n return DiagnosticSeverity.Warning;\n case \"info\":\n return DiagnosticSeverity.Information;\n default:\n return DiagnosticSeverity.Information;\n }\n}\n\nfunction toRelatedInformation(\n document: TextDocument,\n locations: readonly FormSpecAnalysisDiagnosticLocation[]\n): DiagnosticRelatedInformation[] | undefined {\n if (locations.length === 0) {\n return undefined;\n }\n\n const currentDocumentFilePath = getDocumentFilePath(document);\n const relatedInformation = locations\n .filter((location) => location.filePath === currentDocumentFilePath)\n .map((location) =>\n DiagnosticRelatedInformation.create(\n Location.create(\n document.uri,\n spanToRange(document, location.range.start, location.range.end)\n ),\n location.message ?? \"Related FormSpec location\"\n )\n );\n\n return relatedInformation.length === 0 ? undefined : relatedInformation;\n}\n\nfunction getDocumentFilePath(document: TextDocument): string | null {\n return fileUriToPathOrNull(document.uri);\n}\n","import fs from \"node:fs/promises\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n computeFormSpecTextHash,\n isFormSpecAnalysisManifest,\n isFormSpecSemanticResponse,\n type FormSpecAnalysisDiagnostic,\n type FormSpecAnalysisManifest,\n type FormSpecSerializedCompletionContext,\n type FormSpecSerializedHoverInfo,\n type FormSpecSemanticQuery,\n type FormSpecSemanticResponse,\n} from \"@formspec/analysis/protocol\";\nimport { getFormSpecManifestPath } from \"@formspec/analysis/internal\";\n\nconst DEFAULT_PLUGIN_QUERY_TIMEOUT_MS = 2_000;\n\nfunction getManifestPath(workspaceRoot: string): string {\n return getFormSpecManifestPath(workspaceRoot);\n}\n\nfunction normalizeWorkspaceRoot(root: string): string {\n const resolved = path.resolve(root);\n const parsed = path.parse(resolved);\n let normalized = resolved;\n\n while (normalized.length > parsed.root.length && normalized.endsWith(path.sep)) {\n normalized = normalized.slice(0, -path.sep.length);\n }\n\n return normalized;\n}\n\nfunction getMatchingWorkspaceRoot(\n workspaceRoots: readonly string[],\n filePath: string\n): string | null {\n const normalizedFilePath = path.resolve(filePath);\n const normalizedRoots = [...workspaceRoots]\n .map(normalizeWorkspaceRoot)\n .sort((left, right) => right.length - left.length);\n return (\n normalizedRoots.find(\n (workspaceRoot) =>\n normalizedFilePath === workspaceRoot ||\n normalizedFilePath.startsWith(`${workspaceRoot}${path.sep}`)\n ) ?? null\n );\n}\n\nasync function readManifest(workspaceRoot: string): Promise<FormSpecAnalysisManifest | null> {\n try {\n const manifestText = await fs.readFile(getManifestPath(workspaceRoot), \"utf8\");\n const manifest = JSON.parse(manifestText) as unknown;\n if (!isFormSpecAnalysisManifest(manifest)) {\n return null;\n }\n\n return manifest;\n } catch {\n return null;\n }\n}\n\nasync function sendSemanticQuery(\n manifest: FormSpecAnalysisManifest,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n return new Promise((resolve) => {\n const socket = net.createConnection(manifest.endpoint.address);\n let buffer = \"\";\n let settled = false;\n\n const finish = (response: FormSpecSemanticResponse | null): void => {\n if (settled) {\n return;\n }\n settled = true;\n socket.removeAllListeners(\"data\");\n socket.destroy();\n resolve(response);\n };\n\n socket.setTimeout(timeoutMs, () => {\n finish(null);\n });\n\n socket.setEncoding(\"utf8\");\n socket.on(\"connect\", () => {\n socket.write(`${JSON.stringify(query)}\\n`);\n });\n socket.on(\"data\", (chunk) => {\n buffer += String(chunk);\n const newlineIndex = buffer.indexOf(\"\\n\");\n if (newlineIndex < 0) {\n return;\n }\n\n const payload = buffer.slice(0, newlineIndex);\n buffer = buffer.slice(newlineIndex + 1);\n try {\n const response = JSON.parse(payload) as unknown;\n finish(isFormSpecSemanticResponse(response) ? response : null);\n } catch {\n finish(null);\n }\n });\n socket.on(\"error\", () => {\n finish(null);\n });\n socket.on(\"close\", () => {\n finish(null);\n });\n });\n}\n\n/**\n * Converts a `file://` URI to an absolute filesystem path.\n *\n * Returns `null` for any URI that is not a valid `file://` URI (e.g. `untitled:`, `vscode-notebook-cell:`,\n * malformed URIs). On Windows the returned path uses backslash separators as produced by\n * `url.fileURLToPath`.\n *\n * @public\n */\nexport function fileUriToPathOrNull(uri: string): string | null {\n try {\n return fileURLToPath(uri);\n } catch {\n return null;\n }\n}\n\nasync function sendFileQuery(\n workspaceRoots: readonly string[],\n filePath: string,\n query: FormSpecSemanticQuery,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSemanticResponse | null> {\n const workspaceRoot = getMatchingWorkspaceRoot(workspaceRoots, filePath);\n if (workspaceRoot === null) {\n return null;\n }\n\n const manifest = await readManifest(workspaceRoot);\n if (manifest === null) {\n return null;\n }\n\n return sendSemanticQuery(manifest, query, timeoutMs);\n}\n\n/**\n * Queries the FormSpec TypeScript plugin for semantic completion context at `offset` in the\n * document identified by `filePath`.\n *\n * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The\n * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root\n * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times\n * out (default 2 s), or the plugin's response was computed against a different version of the\n * document than `documentText` (stale response guard).\n *\n * Pass the result to {@link getCompletionItemsAtOffset} as `semanticContext`.\n *\n * @public\n */\nexport async function getPluginCompletionContextForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedCompletionContext | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"completion\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"completion\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.context : null;\n}\n\n/**\n * Queries the FormSpec TypeScript plugin for semantic hover information at `offset` in the\n * document identified by `filePath`.\n *\n * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The\n * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root\n * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times\n * out (default 2 s), or the plugin's response was computed against a different version of the\n * document than `documentText` (stale response guard).\n *\n * Pass the result to {@link getHoverAtOffset} as `semanticHover`.\n *\n * @public\n */\nexport async function getPluginHoverForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n offset: number,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<FormSpecSerializedHoverInfo | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"hover\",\n filePath,\n offset,\n },\n timeoutMs\n );\n if (response?.kind !== \"hover\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText) ? response.hover : null;\n}\n\n/**\n * Retrieves canonical FormSpec diagnostics for the current document revision\n * from the plugin transport. Returns `null` when the transport is missing,\n * stale, or invalid.\n *\n * @public\n */\nexport async function getPluginDiagnosticsForDocument(\n workspaceRoots: readonly string[],\n filePath: string,\n documentText: string,\n timeoutMs = DEFAULT_PLUGIN_QUERY_TIMEOUT_MS\n): Promise<readonly FormSpecAnalysisDiagnostic[] | null> {\n const response = await sendFileQuery(\n workspaceRoots,\n filePath,\n {\n protocolVersion: FORMSPEC_ANALYSIS_PROTOCOL_VERSION,\n kind: \"diagnostics\",\n filePath,\n },\n timeoutMs\n );\n if (response?.kind !== \"diagnostics\") {\n return null;\n }\n\n return response.sourceHash === computeFormSpecTextHash(documentText)\n ? response.diagnostics\n : null;\n}\n"],"mappings":";AAYA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;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AAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,YAAU,UAAU,CAAC,EAAE,SAAS,MAAM;AACpC,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,mBAAmB,CAAC,EAAE,SAAS,MAAM;AAC7C,SAAK,8BAA8B,QAAQ,EAAE,MAAM,CAAC,UAAmB;AACrE,iBAAW,QAAQ,MAAM,6CAA6C,OAAO,KAAK,CAAC,EAAE;AAAA,IACvF,CAAC;AAAA,EACH,CAAC;AAED,YAAU,WAAW,CAAC,EAAE,SAAS,MAAM;AACrC,QAAI,oBAAoB,UAAU;AAChC,WAAK,WAAW,gBAAgB;AAAA,QAC9B,KAAK,SAAS;AAAA,QACd,aAAa,CAAC;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -33,11 +33,14 @@ import type { Location } from 'vscode-languageserver/node.js';
33
33
  import type { TextDocument } from 'vscode-languageserver-textdocument';
34
34
 
35
35
  /** @public */
36
- export declare interface CommentSpan {
36
+ export declare interface CommentSourceSpan {
37
37
  readonly start: number;
38
38
  readonly end: number;
39
39
  }
40
40
 
41
+ /** @public */
42
+ export declare type CommentSpan = CommentSourceSpan;
43
+
41
44
  /**
42
45
  * Creates and configures the FormSpec language server connection.
43
46
  *
@@ -69,6 +72,17 @@ export declare interface CreateServerOptions {
69
72
  readonly diagnosticSource?: string;
70
73
  }
71
74
 
75
+ /**
76
+ * Converts a `file://` URI to an absolute filesystem path.
77
+ *
78
+ * Returns `null` for any URI that is not a valid `file://` URI (e.g. `untitled:`, `vscode-notebook-cell:`,
79
+ * malformed URIs). On Windows the returned path uses backslash separators as produced by
80
+ * `url.fileURLToPath`.
81
+ *
82
+ * @public
83
+ */
84
+ export declare function fileUriToPathOrNull(uri: string): string | null;
85
+
72
86
  /**
73
87
  * File-local diagnostic derived from comment parsing or semantic analysis.
74
88
  *
@@ -110,6 +124,83 @@ export declare interface FormSpecAnalysisDiagnosticLocation {
110
124
  readonly message?: string;
111
125
  }
112
126
 
127
+ /** @public */
128
+ declare type FormSpecPlacement = "class" | "class-field" | "class-method" | "interface" | "interface-field" | "type-alias" | "type-alias-field" | "variable" | "function" | "function-parameter" | "method-parameter";
129
+
130
+ /**
131
+ * Cursor-scoped completion context serialized for transport between the
132
+ * semantic tsserver plugin and the lightweight LSP.
133
+ *
134
+ * @public
135
+ */
136
+ declare type FormSpecSerializedCompletionContext = {
137
+ readonly kind: "tag-name";
138
+ readonly prefix: string;
139
+ readonly availableTags: readonly FormSpecSerializedTagDefinition[];
140
+ } | {
141
+ readonly kind: "target";
142
+ readonly semantic: FormSpecSerializedTagSemanticContext;
143
+ } | {
144
+ readonly kind: "argument";
145
+ readonly semantic: FormSpecSerializedTagSemanticContext;
146
+ readonly valueLabels: readonly string[];
147
+ } | {
148
+ readonly kind: "none";
149
+ };
150
+
151
+ /**
152
+ * Hover payload for a single comment token under the cursor.
153
+ *
154
+ * @public
155
+ */
156
+ declare interface FormSpecSerializedHoverInfo {
157
+ readonly kind: "tag-name" | "target" | "argument";
158
+ readonly markdown: string;
159
+ }
160
+
161
+ /**
162
+ * Serializable subset of tag metadata needed by hover and completion UIs.
163
+ *
164
+ * @public
165
+ */
166
+ declare interface FormSpecSerializedTagDefinition {
167
+ readonly canonicalName: string;
168
+ readonly completionDetail: string;
169
+ readonly hoverMarkdown: string;
170
+ }
171
+
172
+ /**
173
+ * Semantic facts about one parsed tag, reduced to JSON-safe data for IPC.
174
+ *
175
+ * @public
176
+ */
177
+ declare interface FormSpecSerializedTagSemanticContext {
178
+ readonly tagName: string;
179
+ readonly tagDefinition: FormSpecSerializedTagDefinition | null;
180
+ readonly placement: FormSpecPlacement | null;
181
+ readonly supportedTargets: readonly FormSpecTargetKind[];
182
+ readonly targetCompletions: readonly string[];
183
+ readonly compatiblePathTargets: readonly string[];
184
+ readonly valueLabels: readonly string[];
185
+ readonly signatures: readonly FormSpecSerializedTagSignature[];
186
+ readonly tagHoverMarkdown: string | null;
187
+ readonly targetHoverMarkdown: string | null;
188
+ readonly argumentHoverMarkdown: string | null;
189
+ }
190
+
191
+ /**
192
+ * Serializable overload/signature summary for one comment tag form.
193
+ *
194
+ * @public
195
+ */
196
+ declare interface FormSpecSerializedTagSignature {
197
+ readonly label: string;
198
+ readonly placements: readonly FormSpecPlacement[];
199
+ }
200
+
201
+ /** @public */
202
+ declare type FormSpecTargetKind = "none" | "path" | "member" | "variant";
203
+
113
204
  /**
114
205
  * Returns the full set of tag-name completions currently known to FormSpec.
115
206
  *
@@ -117,6 +208,17 @@ export declare interface FormSpecAnalysisDiagnosticLocation {
117
208
  */
118
209
  export declare function getCompletionItems(extensions?: readonly ExtensionDefinition[]): CompletionItem[];
119
210
 
211
+ /**
212
+ * Returns completion items for the cursor position at `offset` in `documentText`.
213
+ *
214
+ * When `semanticContext` is supplied (e.g. from {@link getPluginCompletionContextForDocument}),
215
+ * it is used directly to produce target-value or tag-name completions. Pass `null` or omit it
216
+ * to fall back to syntax-only analysis, which works without the TypeScript plugin.
217
+ *
218
+ * @public
219
+ */
220
+ export declare function getCompletionItemsAtOffset(documentText: string, offset: number, extensions?: readonly ExtensionDefinition[], semanticContext?: FormSpecSerializedCompletionContext | null): CompletionItem[];
221
+
120
222
  /**
121
223
  * Returns the definition location for a symbol at the given position.
122
224
  *
@@ -127,6 +229,18 @@ export declare function getCompletionItems(extensions?: readonly ExtensionDefini
127
229
  */
128
230
  export declare function getDefinition(): Location | null;
129
231
 
232
+ /**
233
+ * Returns LSP hover content for the cursor position at `offset` in `documentText`.
234
+ *
235
+ * When `semanticHover` is supplied (e.g. from {@link getPluginHoverForDocument}), it is used
236
+ * directly as the hover source. Pass `null` or omit it to fall back to syntax-only analysis,
237
+ * which works without the TypeScript plugin. Returns `null` when the cursor is not over a
238
+ * recognised FormSpec tag.
239
+ *
240
+ * @public
241
+ */
242
+ export declare function getHoverAtOffset(documentText: string, offset: number, extensions?: readonly ExtensionDefinition[], semanticHover?: FormSpecSerializedHoverInfo | null): Hover | null;
243
+
130
244
  /**
131
245
  * Returns hover content for a single FormSpec tag name.
132
246
  *
@@ -134,6 +248,22 @@ export declare function getDefinition(): Location | null;
134
248
  */
135
249
  export declare function getHoverForTag(tagName: string, extensions?: readonly ExtensionDefinition[]): Hover | null;
136
250
 
251
+ /**
252
+ * Queries the FormSpec TypeScript plugin for semantic completion context at `offset` in the
253
+ * document identified by `filePath`.
254
+ *
255
+ * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The
256
+ * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root
257
+ * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times
258
+ * out (default 2 s), or the plugin's response was computed against a different version of the
259
+ * document than `documentText` (stale response guard).
260
+ *
261
+ * Pass the result to {@link getCompletionItemsAtOffset} as `semanticContext`.
262
+ *
263
+ * @public
264
+ */
265
+ export declare function getPluginCompletionContextForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, offset: number, timeoutMs?: number): Promise<FormSpecSerializedCompletionContext | null>;
266
+
137
267
  /**
138
268
  * Retrieves canonical FormSpec diagnostics for the current document revision
139
269
  * from the plugin transport. Returns `null` when the transport is missing,
@@ -143,6 +273,22 @@ export declare function getHoverForTag(tagName: string, extensions?: readonly Ex
143
273
  */
144
274
  export declare function getPluginDiagnosticsForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, timeoutMs?: number): Promise<readonly FormSpecAnalysisDiagnostic[] | null>;
145
275
 
276
+ /**
277
+ * Queries the FormSpec TypeScript plugin for semantic hover information at `offset` in the
278
+ * document identified by `filePath`.
279
+ *
280
+ * The workspace root containing `filePath` is located automatically from `workspaceRoots`. The
281
+ * plugin manifest is read from disk on each call. Returns `null` when no matching workspace root
282
+ * is found, the manifest is missing or invalid, the IPC socket is unavailable, the plugin times
283
+ * out (default 2 s), or the plugin's response was computed against a different version of the
284
+ * document than `documentText` (stale response guard).
285
+ *
286
+ * Pass the result to {@link getHoverAtOffset} as `semanticHover`.
287
+ *
288
+ * @public
289
+ */
290
+ export declare function getPluginHoverForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, offset: number, timeoutMs?: number): Promise<FormSpecSerializedHoverInfo | null>;
291
+
146
292
  /**
147
293
  * Converts canonical FormSpec diagnostics into LSP diagnostics.
148
294
  *