@formspec/language-server 0.1.0-alpha.14 → 0.1.0-alpha.16

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,6 +31,7 @@ module.exports = __toCommonJS(index_exports);
31
31
  var import_node2 = require("vscode-languageserver/node.js");
32
32
 
33
33
  // src/providers/completion.ts
34
+ var import_core = require("@formspec/core");
34
35
  var import_node = require("vscode-languageserver/node.js");
35
36
  var CONSTRAINT_DETAIL = {
36
37
  minimum: "Minimum numeric value (inclusive). Example: `@minimum 0`",
@@ -42,19 +43,21 @@ var CONSTRAINT_DETAIL = {
42
43
  maxLength: "Maximum string length. Example: `@maxLength 255`",
43
44
  minItems: "Minimum number of array items. Example: `@minItems 1`",
44
45
  maxItems: "Maximum number of array items. Example: `@maxItems 10`",
46
+ uniqueItems: "Require all array items to be distinct. Example: `@uniqueItems`",
45
47
  pattern: "Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`",
46
- enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions ["a","b","c"]`'
48
+ enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions ["a","b","c"]`',
49
+ const: 'Require a constant JSON value. Example: `@const "USD"`'
47
50
  };
48
51
  function getCompletionItems() {
49
- return Object.entries(CONSTRAINT_DETAIL).map(([name, detail]) => ({
52
+ return Object.keys(import_core.BUILTIN_CONSTRAINT_DEFINITIONS).map((name) => ({
50
53
  label: `@${name}`,
51
54
  kind: import_node.CompletionItemKind.Keyword,
52
- detail
55
+ detail: CONSTRAINT_DETAIL[name]
53
56
  }));
54
57
  }
55
58
 
56
59
  // src/providers/hover.ts
57
- var import_core = require("@formspec/core");
60
+ var import_core2 = require("@formspec/core");
58
61
  var CONSTRAINT_HOVER_DOCS = {
59
62
  minimum: [
60
63
  "**@minimum** `<number>`",
@@ -173,6 +176,19 @@ var CONSTRAINT_HOVER_DOCS = {
173
176
  "tags: string[];",
174
177
  "```"
175
178
  ].join("\n"),
179
+ uniqueItems: [
180
+ "**@uniqueItems**",
181
+ "",
182
+ "Requires all items in an array field to be distinct.",
183
+ "",
184
+ "Maps to `uniqueItems` in JSON Schema.",
185
+ "",
186
+ "**Example:**",
187
+ "```typescript",
188
+ "/** @uniqueItems */",
189
+ "tags: string[];",
190
+ "```"
191
+ ].join("\n"),
176
192
  pattern: [
177
193
  "**@pattern** `<regex>`",
178
194
  "",
@@ -198,12 +214,25 @@ var CONSTRAINT_HOVER_DOCS = {
198
214
  '/** @enumOptions ["draft","sent","archived"] */',
199
215
  "status: string;",
200
216
  "```"
217
+ ].join("\n"),
218
+ const: [
219
+ "**@const** `<json-literal>`",
220
+ "",
221
+ "Requires the field value to equal a single constant JSON value.",
222
+ "",
223
+ "Maps to `const` in JSON Schema.",
224
+ "",
225
+ "**Example:**",
226
+ "```typescript",
227
+ '/** @const "USD" */',
228
+ "currency: string;",
229
+ "```"
201
230
  ].join("\n")
202
231
  };
203
232
  function getHoverForTag(tagName) {
204
233
  const raw = tagName.startsWith("@") ? tagName.slice(1) : tagName;
205
- const name = (0, import_core.normalizeConstraintTagName)(raw);
206
- if (!(0, import_core.isBuiltinConstraintName)(name)) {
234
+ const name = (0, import_core2.normalizeConstraintTagName)(raw);
235
+ if (!(0, import_core2.isBuiltinConstraintName)(name)) {
207
236
  return null;
208
237
  }
209
238
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.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. Constraint names are sourced from\n * `BUILTIN_CONSTRAINT_DEFINITIONS` in `@formspec/core`, ensuring the\n * language server stays in sync with the single source of truth.\n *\n * Diagnostics are intentionally omitted per design decision A7.\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 { 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 * Diagnostics are intentionally omitted per design decision A7.\n */\n\nimport {\n createConnection,\n ProposedFeatures,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport { getCompletionItems } from \"./providers/completion.js\";\nimport { getHoverForTag } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\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 */\nexport function createServer(): Connection {\n const connection = createConnection(ProposedFeatures.all);\n\n connection.onInitialize((): InitializeResult => {\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments when `@` is typed\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(() => {\n // Return all FormSpec constraint tag completions.\n // Future phases will add context-aware filtering based on field type and\n // cursor position within JSDoc comment ranges.\n return getCompletionItems();\n });\n\n connection.onHover((_params) => {\n // Extract the word under the cursor and look up hover documentation.\n // This is a stub — precise JSDoc token detection (checking that the\n // cursor is within a JSDoc comment and extracting the tag name) will be\n // added in a future phase.\n //\n // For now we return null to signal no hover is available until the\n // token extraction is implemented.\n return getHoverForTag(\"\");\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Returns completion items for all recognized FormSpec JSDoc constraint tags\n * (e.g., `@minimum`, `@maximum`, `@pattern`), derived from\n * `BUILTIN_CONSTRAINT_DEFINITIONS`. This is a skeleton — context-aware\n * filtering will be added in a future phase.\n */\n\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Human-readable detail strings for each built-in constraint tag.\n *\n * Keys match the camelCase constraint names (matching keys in `BUILTIN_CONSTRAINT_DEFINITIONS`).\n * Values are shown as the detail string in completion items.\n */\nconst CONSTRAINT_DETAIL: Record<string, string> = {\n minimum: \"Minimum numeric value (inclusive). Example: `@minimum 0`\",\n maximum: \"Maximum numeric value (inclusive). Example: `@maximum 100`\",\n exclusiveMinimum: \"Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`\",\n exclusiveMaximum: \"Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`\",\n multipleOf: \"Value must be a multiple of this number. Example: `@multipleOf 0.01`\",\n minLength: \"Minimum string length. Example: `@minLength 1`\",\n maxLength: \"Maximum string length. Example: `@maxLength 255`\",\n minItems: \"Minimum number of array items. Example: `@minItems 1`\",\n maxItems: \"Maximum number of array items. Example: `@maxItems 10`\",\n pattern: \"Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`\",\n enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions [\"a\",\"b\",\"c\"]`',\n};\n\n/**\n * Returns completion items for all FormSpec JSDoc constraint tags.\n *\n * Items are derived from `BUILTIN_CONSTRAINT_DEFINITIONS`, ensuring this list\n * stays in sync with the single source of truth in `@formspec/core`.\n *\n * Each item uses `CompletionItemKind.Keyword` since these are annotation\n * tags used within JSDoc comments rather than language symbols.\n *\n * @returns An array of LSP completion items for FormSpec constraint tags\n */\nexport function getCompletionItems(): CompletionItem[] {\n return Object.entries(CONSTRAINT_DETAIL).map(([name, detail]) => ({\n label: `@${name}`,\n kind: CompletionItemKind.Keyword,\n detail,\n }));\n}\n","/**\n * Hover provider for FormSpec JSDoc constraint tags.\n *\n * Returns Markdown documentation for a recognized FormSpec JSDoc tag when\n * the cursor is positioned over it. This is a skeleton — precise token\n * detection within JSDoc comment ranges will be added in a future phase.\n */\n\nimport {\n normalizeConstraintTagName,\n isBuiltinConstraintName,\n type BuiltinConstraintName,\n} from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Markdown documentation for each built-in FormSpec constraint tag.\n *\n * Keys are the canonical constraint names from `BUILTIN_CONSTRAINT_DEFINITIONS`.\n * Values are Markdown strings suitable for LSP hover responses.\n */\nconst CONSTRAINT_HOVER_DOCS: Record<BuiltinConstraintName, string> = {\n minimum: [\n \"**@minimum** `<number>`\",\n \"\",\n \"Sets an inclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `minimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minimum 0 */\",\n \"amount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n maximum: [\n \"**@maximum** `<number>`\",\n \"\",\n \"Sets an inclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `maximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maximum 100 */\",\n \"percentage: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMinimum: [\n \"**@exclusiveMinimum** `<number>`\",\n \"\",\n \"Sets an exclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMinimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMinimum 0 */\",\n \"positiveAmount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMaximum: [\n \"**@exclusiveMaximum** `<number>`\",\n \"\",\n \"Sets an exclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMaximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMaximum 1 */\",\n \"ratio: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n multipleOf: [\n \"**@multipleOf** `<number>`\",\n \"\",\n \"Requires the numeric value to be a multiple of the given number.\",\n \"\",\n \"Maps to `multipleOf` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @multipleOf 0.01 */\",\n \"price: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n minLength: [\n \"**@minLength** `<number>`\",\n \"\",\n \"Sets a minimum character length on a string field.\",\n \"\",\n \"Maps to `minLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minLength 1 */\",\n \"name: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n maxLength: [\n \"**@maxLength** `<number>`\",\n \"\",\n \"Sets a maximum character length on a string field.\",\n \"\",\n \"Maps to `maxLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxLength 255 */\",\n \"description: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n minItems: [\n \"**@minItems** `<number>`\",\n \"\",\n \"Sets a minimum number of items in an array field.\",\n \"\",\n \"Maps to `minItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minItems 1 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n maxItems: [\n \"**@maxItems** `<number>`\",\n \"\",\n \"Sets a maximum number of items in an array field.\",\n \"\",\n \"Maps to `maxItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxItems 10 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n pattern: [\n \"**@pattern** `<regex>`\",\n \"\",\n \"Sets a regular expression pattern that a string field must match.\",\n \"\",\n \"Maps to `pattern` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @pattern ^[a-z0-9]+$ */\",\n \"slug: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n enumOptions: [\n \"**@enumOptions** `<json-array>`\",\n \"\",\n \"Specifies the allowed values for an enum field as an inline JSON array.\",\n \"\",\n \"Maps to `enum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @enumOptions [\"draft\",\"sent\",\"archived\"] */',\n \"status: string;\",\n \"```\",\n ].join(\"\\n\"),\n} satisfies Record<BuiltinConstraintName, string>;\n\n/**\n * Returns hover documentation for a FormSpec JSDoc tag name.\n *\n * Accepts both camelCase (`\"minimum\"`) and PascalCase (`\"Minimum\"`) forms.\n * The `@` prefix is stripped before lookup if present.\n * Returns `null` when the tag is not a recognized FormSpec constraint tag.\n *\n * @param tagName - The tag name to look up (e.g., `\"minimum\"`, `\"@pattern\"`)\n * @returns An LSP `Hover` response, or `null` if the tag is not recognized\n */\nexport function getHoverForTag(tagName: string): Hover | null {\n // Strip leading `@` prefix if present\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const name = normalizeConstraintTagName(raw);\n\n if (!isBuiltinConstraintName(name)) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: CONSTRAINT_HOVER_DOCS[name],\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 */\nexport function getDefinition(): Location | null {\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAAA,eAMO;;;ACRP,kBAAmD;AAQnD,IAAM,o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SAAO;AAAA,IACL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO,sBAAsB,IAAI;AAAA,IACnC;AAAA,EACF;AACF;;;ACzLO,SAAS,gBAAiC;AAC/C,SAAO;AACT;;;AHWO,SAAS,eAA2B;AACzC,QAAM,iBAAa,+BAAiB,8BAAiB,GAAG;AAExD,aAAW,aAAa,MAAwB;AAC9C,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,kBAAkB,kCAAqB;AAAA,QACvC,oBAAoB;AAAA;AAAA,UAElB,mBAAmB,CAAC,GAAG;AAAA,QACzB;AAAA,QACA,eAAe;AAAA,QACf,oBAAoB;AAAA,MACtB;AAAA,MACA,YAAY;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AAED,aAAW,aAAa,MAAM;AAI5B,WAAO,mBAAmB;AAAA,EAC5B,CAAC;AAED,aAAW,QAAQ,CAAC,YAAY;AAQ9B,WAAO,eAAe,EAAE;AAAA,EAC1B,CAAC;AAED,aAAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,SAAO;AACT;","names":["import_node"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.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. Constraint names are sourced from\n * `BUILTIN_CONSTRAINT_DEFINITIONS` in `@formspec/core`, ensuring the\n * language server stays in sync with the single source of truth.\n *\n * Diagnostics are intentionally omitted per design decision A7.\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 { 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 * Diagnostics are intentionally omitted per design decision A7.\n */\n\nimport {\n createConnection,\n ProposedFeatures,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport { getCompletionItems } from \"./providers/completion.js\";\nimport { getHoverForTag } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\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 */\nexport function createServer(): Connection {\n const connection = createConnection(ProposedFeatures.all);\n\n connection.onInitialize((): InitializeResult => {\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments when `@` is typed\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(() => {\n // Return all FormSpec constraint tag completions.\n // Future phases will add context-aware filtering based on field type and\n // cursor position within JSDoc comment ranges.\n return getCompletionItems();\n });\n\n connection.onHover((_params) => {\n // Extract the word under the cursor and look up hover documentation.\n // This is a stub — precise JSDoc token detection (checking that the\n // cursor is within a JSDoc comment and extracting the tag name) will be\n // added in a future phase.\n //\n // For now we return null to signal no hover is available until the\n // token extraction is implemented.\n return getHoverForTag(\"\");\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Returns completion items for all recognized FormSpec JSDoc constraint tags\n * (e.g., `@minimum`, `@maximum`, `@pattern`), derived from\n * `BUILTIN_CONSTRAINT_DEFINITIONS`. This is a skeleton — context-aware\n * filtering will be added in a future phase.\n */\n\nimport { BUILTIN_CONSTRAINT_DEFINITIONS, type BuiltinConstraintName } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Human-readable detail strings for each built-in constraint tag.\n *\n * Keys match the camelCase constraint names (matching keys in `BUILTIN_CONSTRAINT_DEFINITIONS`).\n * Values are shown as the detail string in completion items.\n */\nconst CONSTRAINT_DETAIL: Record<BuiltinConstraintName, string> = {\n minimum: \"Minimum numeric value (inclusive). Example: `@minimum 0`\",\n maximum: \"Maximum numeric value (inclusive). Example: `@maximum 100`\",\n exclusiveMinimum: \"Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`\",\n exclusiveMaximum: \"Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`\",\n multipleOf: \"Value must be a multiple of this number. Example: `@multipleOf 0.01`\",\n minLength: \"Minimum string length. Example: `@minLength 1`\",\n maxLength: \"Maximum string length. Example: `@maxLength 255`\",\n minItems: \"Minimum number of array items. Example: `@minItems 1`\",\n maxItems: \"Maximum number of array items. Example: `@maxItems 10`\",\n uniqueItems: \"Require all array items to be distinct. Example: `@uniqueItems`\",\n pattern: \"Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`\",\n enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions [\"a\",\"b\",\"c\"]`',\n const: 'Require a constant JSON value. Example: `@const \"USD\"`',\n};\n\n/**\n * Returns completion items for all FormSpec JSDoc constraint tags.\n *\n * Items are derived from `BUILTIN_CONSTRAINT_DEFINITIONS`, ensuring this list\n * stays in sync with the single source of truth in `@formspec/core`.\n *\n * Each item uses `CompletionItemKind.Keyword` since these are annotation\n * tags used within JSDoc comments rather than language symbols.\n *\n * @returns An array of LSP completion items for FormSpec constraint tags\n */\nexport function getCompletionItems(): CompletionItem[] {\n return (Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS) as BuiltinConstraintName[]).map((name) => ({\n label: `@${name}`,\n kind: CompletionItemKind.Keyword,\n detail: CONSTRAINT_DETAIL[name],\n }));\n}\n","/**\n * Hover provider for FormSpec JSDoc constraint tags.\n *\n * Returns Markdown documentation for a recognized FormSpec JSDoc tag when\n * the cursor is positioned over it. This is a skeleton — precise token\n * detection within JSDoc comment ranges will be added in a future phase.\n */\n\nimport {\n normalizeConstraintTagName,\n isBuiltinConstraintName,\n type BuiltinConstraintName,\n} from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Markdown documentation for each built-in FormSpec constraint tag.\n *\n * Keys are the canonical constraint names from `BUILTIN_CONSTRAINT_DEFINITIONS`.\n * Values are Markdown strings suitable for LSP hover responses.\n */\nconst CONSTRAINT_HOVER_DOCS: Record<BuiltinConstraintName, string> = {\n minimum: [\n \"**@minimum** `<number>`\",\n \"\",\n \"Sets an inclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `minimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minimum 0 */\",\n \"amount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n maximum: [\n \"**@maximum** `<number>`\",\n \"\",\n \"Sets an inclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `maximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maximum 100 */\",\n \"percentage: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMinimum: [\n \"**@exclusiveMinimum** `<number>`\",\n \"\",\n \"Sets an exclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMinimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMinimum 0 */\",\n \"positiveAmount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMaximum: [\n \"**@exclusiveMaximum** `<number>`\",\n \"\",\n \"Sets an exclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMaximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMaximum 1 */\",\n \"ratio: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n multipleOf: [\n \"**@multipleOf** `<number>`\",\n \"\",\n \"Requires the numeric value to be a multiple of the given number.\",\n \"\",\n \"Maps to `multipleOf` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @multipleOf 0.01 */\",\n \"price: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n minLength: [\n \"**@minLength** `<number>`\",\n \"\",\n \"Sets a minimum character length on a string field.\",\n \"\",\n \"Maps to `minLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minLength 1 */\",\n \"name: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n maxLength: [\n \"**@maxLength** `<number>`\",\n \"\",\n \"Sets a maximum character length on a string field.\",\n \"\",\n \"Maps to `maxLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxLength 255 */\",\n \"description: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n minItems: [\n \"**@minItems** `<number>`\",\n \"\",\n \"Sets a minimum number of items in an array field.\",\n \"\",\n \"Maps to `minItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minItems 1 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n maxItems: [\n \"**@maxItems** `<number>`\",\n \"\",\n \"Sets a maximum number of items in an array field.\",\n \"\",\n \"Maps to `maxItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxItems 10 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n uniqueItems: [\n \"**@uniqueItems**\",\n \"\",\n \"Requires all items in an array field to be distinct.\",\n \"\",\n \"Maps to `uniqueItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @uniqueItems */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n pattern: [\n \"**@pattern** `<regex>`\",\n \"\",\n \"Sets a regular expression pattern that a string field must match.\",\n \"\",\n \"Maps to `pattern` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @pattern ^[a-z0-9]+$ */\",\n \"slug: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n enumOptions: [\n \"**@enumOptions** `<json-array>`\",\n \"\",\n \"Specifies the allowed values for an enum field as an inline JSON array.\",\n \"\",\n \"Maps to `enum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @enumOptions [\"draft\",\"sent\",\"archived\"] */',\n \"status: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n const: [\n \"**@const** `<json-literal>`\",\n \"\",\n \"Requires the field value to equal a single constant JSON value.\",\n \"\",\n \"Maps to `const` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @const \"USD\" */',\n \"currency: string;\",\n \"```\",\n ].join(\"\\n\"),\n} satisfies Record<BuiltinConstraintName, string>;\n\n/**\n * Returns hover documentation for a FormSpec JSDoc tag name.\n *\n * Accepts both camelCase (`\"minimum\"`) and PascalCase (`\"Minimum\"`) forms.\n * The `@` prefix is stripped before lookup if present.\n * Returns `null` when the tag is not a recognized FormSpec constraint tag.\n *\n * @param tagName - The tag name to look up (e.g., `\"minimum\"`, `\"@pattern\"`)\n * @returns An LSP `Hover` response, or `null` if the tag is not recognized\n */\nexport function getHoverForTag(tagName: string): Hover | null {\n // Strip leading `@` prefix if present\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const name = normalizeConstraintTagName(raw);\n\n if (!isBuiltinConstraintName(name)) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: CONSTRAINT_HOVER_DOCS[name],\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 */\nexport function getDefinition(): Location | null {\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAAA,eAMO;;;ACRP,kBAA2E;AAC3E,kBAAmD;AAQnD,IAAM,oBAA2D;AAAA,EAC/D,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS;AAAA,EACT,aAAa;AAAA,EACb,OAAO;AACT;AAaO,SAAS,qBAAuC;AACrD,SAAQ,OAAO,KAAK,0CAA8B,EAA8B,IAAI,CAAC,UAAU;AAAA,IAC7F,OAAO,IAAI,IAAI;AAAA,IACf,MAAM,+BAAmB;AAAA,IACzB,QAAQ,kBAAkB,IAAI;AAAA,EAChC,EAAE;AACJ;;;AC3CA,IAAAC,eAIO;AASP,IAAM,wBAA+D;AAAA,EACnE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AAAA,EAEX,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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AoB;AAAA,MACtB;AAAA,MACA,YAAY;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AAED,aAAW,aAAa,MAAM;AAI5B,WAAO,mBAAmB;AAAA,EAC5B,CAAC;AAED,aAAW,QAAQ,CAAC,YAAY;AAQ9B,WAAO,eAAe,EAAE;AAAA,EAC1B,CAAC;AAED,aAAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,SAAO;AACT;","names":["import_node","import_core"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @formspec/language-server
2
+ * \@formspec/language-server
3
3
  *
4
4
  * Language server for FormSpec — provides completions, hover documentation,
5
5
  * and go-to-definition for FormSpec JSDoc constraint tags (`@Minimum`,
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  } from "vscode-languageserver/node.js";
7
7
 
8
8
  // src/providers/completion.ts
9
+ import { BUILTIN_CONSTRAINT_DEFINITIONS } from "@formspec/core";
9
10
  import { CompletionItemKind } from "vscode-languageserver/node.js";
10
11
  var CONSTRAINT_DETAIL = {
11
12
  minimum: "Minimum numeric value (inclusive). Example: `@minimum 0`",
@@ -17,14 +18,16 @@ var CONSTRAINT_DETAIL = {
17
18
  maxLength: "Maximum string length. Example: `@maxLength 255`",
18
19
  minItems: "Minimum number of array items. Example: `@minItems 1`",
19
20
  maxItems: "Maximum number of array items. Example: `@maxItems 10`",
21
+ uniqueItems: "Require all array items to be distinct. Example: `@uniqueItems`",
20
22
  pattern: "Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`",
21
- enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions ["a","b","c"]`'
23
+ enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions ["a","b","c"]`',
24
+ const: 'Require a constant JSON value. Example: `@const "USD"`'
22
25
  };
23
26
  function getCompletionItems() {
24
- return Object.entries(CONSTRAINT_DETAIL).map(([name, detail]) => ({
27
+ return Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS).map((name) => ({
25
28
  label: `@${name}`,
26
29
  kind: CompletionItemKind.Keyword,
27
- detail
30
+ detail: CONSTRAINT_DETAIL[name]
28
31
  }));
29
32
  }
30
33
 
@@ -151,6 +154,19 @@ var CONSTRAINT_HOVER_DOCS = {
151
154
  "tags: string[];",
152
155
  "```"
153
156
  ].join("\n"),
157
+ uniqueItems: [
158
+ "**@uniqueItems**",
159
+ "",
160
+ "Requires all items in an array field to be distinct.",
161
+ "",
162
+ "Maps to `uniqueItems` in JSON Schema.",
163
+ "",
164
+ "**Example:**",
165
+ "```typescript",
166
+ "/** @uniqueItems */",
167
+ "tags: string[];",
168
+ "```"
169
+ ].join("\n"),
154
170
  pattern: [
155
171
  "**@pattern** `<regex>`",
156
172
  "",
@@ -176,6 +192,19 @@ var CONSTRAINT_HOVER_DOCS = {
176
192
  '/** @enumOptions ["draft","sent","archived"] */',
177
193
  "status: string;",
178
194
  "```"
195
+ ].join("\n"),
196
+ const: [
197
+ "**@const** `<json-literal>`",
198
+ "",
199
+ "Requires the field value to equal a single constant JSON value.",
200
+ "",
201
+ "Maps to `const` in JSON Schema.",
202
+ "",
203
+ "**Example:**",
204
+ "```typescript",
205
+ '/** @const "USD" */',
206
+ "currency: string;",
207
+ "```"
179
208
  ].join("\n")
180
209
  };
181
210
  function getHoverForTag(tagName) {
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"],"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 * Diagnostics are intentionally omitted per design decision A7.\n */\n\nimport {\n createConnection,\n ProposedFeatures,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport { getCompletionItems } from \"./providers/completion.js\";\nimport { getHoverForTag } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\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 */\nexport function createServer(): Connection {\n const connection = createConnection(ProposedFeatures.all);\n\n connection.onInitialize((): InitializeResult => {\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments when `@` is typed\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(() => {\n // Return all FormSpec constraint tag completions.\n // Future phases will add context-aware filtering based on field type and\n // cursor position within JSDoc comment ranges.\n return getCompletionItems();\n });\n\n connection.onHover((_params) => {\n // Extract the word under the cursor and look up hover documentation.\n // This is a stub — precise JSDoc token detection (checking that the\n // cursor is within a JSDoc comment and extracting the tag name) will be\n // added in a future phase.\n //\n // For now we return null to signal no hover is available until the\n // token extraction is implemented.\n return getHoverForTag(\"\");\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Returns completion items for all recognized FormSpec JSDoc constraint tags\n * (e.g., `@minimum`, `@maximum`, `@pattern`), derived from\n * `BUILTIN_CONSTRAINT_DEFINITIONS`. This is a skeleton — context-aware\n * filtering will be added in a future phase.\n */\n\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Human-readable detail strings for each built-in constraint tag.\n *\n * Keys match the camelCase constraint names (matching keys in `BUILTIN_CONSTRAINT_DEFINITIONS`).\n * Values are shown as the detail string in completion items.\n */\nconst CONSTRAINT_DETAIL: Record<string, string> = {\n minimum: \"Minimum numeric value (inclusive). Example: `@minimum 0`\",\n maximum: \"Maximum numeric value (inclusive). Example: `@maximum 100`\",\n exclusiveMinimum: \"Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`\",\n exclusiveMaximum: \"Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`\",\n multipleOf: \"Value must be a multiple of this number. Example: `@multipleOf 0.01`\",\n minLength: \"Minimum string length. Example: `@minLength 1`\",\n maxLength: \"Maximum string length. Example: `@maxLength 255`\",\n minItems: \"Minimum number of array items. Example: `@minItems 1`\",\n maxItems: \"Maximum number of array items. Example: `@maxItems 10`\",\n pattern: \"Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`\",\n enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions [\"a\",\"b\",\"c\"]`',\n};\n\n/**\n * Returns completion items for all FormSpec JSDoc constraint tags.\n *\n * Items are derived from `BUILTIN_CONSTRAINT_DEFINITIONS`, ensuring this list\n * stays in sync with the single source of truth in `@formspec/core`.\n *\n * Each item uses `CompletionItemKind.Keyword` since these are annotation\n * tags used within JSDoc comments rather than language symbols.\n *\n * @returns An array of LSP completion items for FormSpec constraint tags\n */\nexport function getCompletionItems(): CompletionItem[] {\n return Object.entries(CONSTRAINT_DETAIL).map(([name, detail]) => ({\n label: `@${name}`,\n kind: CompletionItemKind.Keyword,\n detail,\n }));\n}\n","/**\n * Hover provider for FormSpec JSDoc constraint tags.\n *\n * Returns Markdown documentation for a recognized FormSpec JSDoc tag when\n * the cursor is positioned over it. This is a skeleton — precise token\n * detection within JSDoc comment ranges will be added in a future phase.\n */\n\nimport {\n normalizeConstraintTagName,\n isBuiltinConstraintName,\n type BuiltinConstraintName,\n} from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Markdown documentation for each built-in FormSpec constraint tag.\n *\n * Keys are the canonical constraint names from `BUILTIN_CONSTRAINT_DEFINITIONS`.\n * Values are Markdown strings suitable for LSP hover responses.\n */\nconst CONSTRAINT_HOVER_DOCS: Record<BuiltinConstraintName, string> = {\n minimum: [\n \"**@minimum** `<number>`\",\n \"\",\n \"Sets an inclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `minimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minimum 0 */\",\n \"amount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n maximum: [\n \"**@maximum** `<number>`\",\n \"\",\n \"Sets an inclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `maximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maximum 100 */\",\n \"percentage: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMinimum: [\n \"**@exclusiveMinimum** `<number>`\",\n \"\",\n \"Sets an exclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMinimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMinimum 0 */\",\n \"positiveAmount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMaximum: [\n \"**@exclusiveMaximum** `<number>`\",\n \"\",\n \"Sets an exclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMaximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMaximum 1 */\",\n \"ratio: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n multipleOf: [\n \"**@multipleOf** `<number>`\",\n \"\",\n \"Requires the numeric value to be a multiple of the given number.\",\n \"\",\n \"Maps to `multipleOf` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @multipleOf 0.01 */\",\n \"price: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n minLength: [\n \"**@minLength** `<number>`\",\n \"\",\n \"Sets a minimum character length on a string field.\",\n \"\",\n \"Maps to `minLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minLength 1 */\",\n \"name: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n maxLength: [\n \"**@maxLength** `<number>`\",\n \"\",\n \"Sets a maximum character length on a string field.\",\n \"\",\n \"Maps to `maxLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxLength 255 */\",\n \"description: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n minItems: [\n \"**@minItems** `<number>`\",\n \"\",\n \"Sets a minimum number of items in an array field.\",\n \"\",\n \"Maps to `minItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minItems 1 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n maxItems: [\n \"**@maxItems** `<number>`\",\n \"\",\n \"Sets a maximum number of items in an array field.\",\n \"\",\n \"Maps to `maxItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxItems 10 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n pattern: [\n \"**@pattern** `<regex>`\",\n \"\",\n \"Sets a regular expression pattern that a string field must match.\",\n \"\",\n \"Maps to `pattern` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @pattern ^[a-z0-9]+$ */\",\n \"slug: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n enumOptions: [\n \"**@enumOptions** `<json-array>`\",\n \"\",\n \"Specifies the allowed values for an enum field as an inline JSON array.\",\n \"\",\n \"Maps to `enum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @enumOptions [\"draft\",\"sent\",\"archived\"] */',\n \"status: string;\",\n \"```\",\n ].join(\"\\n\"),\n} satisfies Record<BuiltinConstraintName, string>;\n\n/**\n * Returns hover documentation for a FormSpec JSDoc tag name.\n *\n * Accepts both camelCase (`\"minimum\"`) and PascalCase (`\"Minimum\"`) forms.\n * The `@` prefix is stripped before lookup if present.\n * Returns `null` when the tag is not a recognized FormSpec constraint tag.\n *\n * @param tagName - The tag name to look up (e.g., `\"minimum\"`, `\"@pattern\"`)\n * @returns An LSP `Hover` response, or `null` if the tag is not recognized\n */\nexport function getHoverForTag(tagName: string): Hover | null {\n // Strip leading `@` prefix if present\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const name = normalizeConstraintTagName(raw);\n\n if (!isBuiltinConstraintName(name)) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: CONSTRAINT_HOVER_DOCS[name],\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 */\nexport function getDefinition(): Location | null {\n return null;\n}\n"],"mappings":";AAWA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;;;ACRP,SAAyB,0BAA0B;AAQnD,IAAM,oBAA4C;AAAA,EAChD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf;AAaO,SAAS,qBAAuC;AACrD,SAAO,OAAO,QAAQ,iBAAiB,EAAE,IAAI,CAAC,CAAC,MAAM,MAAM,OAAO;AAAA,IAChE,OAAO,IAAI,IAAI;AAAA,IACf,MAAM,mBAAmB;AAAA,IACzB;AAAA,EACF,EAAE;AACJ;;;ACxCA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AASP,IAAM,wBAA+D;AAAA,EACnE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAA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,EACF,CAAC;AAED,aAAW,aAAa,MAAM;AAI5B,WAAO,mBAAmB;AAAA,EAC5B,CAAC;AAED,aAAW,QAAQ,CAAC,YAAY;AAQ9B,WAAO,eAAe,EAAE;AAAA,EAC1B,CAAC;AAED,aAAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts","../src/providers/completion.ts","../src/providers/hover.ts","../src/providers/definition.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 * Diagnostics are intentionally omitted per design decision A7.\n */\n\nimport {\n createConnection,\n ProposedFeatures,\n TextDocumentSyncKind,\n type Connection,\n type InitializeResult,\n} from \"vscode-languageserver/node.js\";\nimport { getCompletionItems } from \"./providers/completion.js\";\nimport { getHoverForTag } from \"./providers/hover.js\";\nimport { getDefinition } from \"./providers/definition.js\";\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 */\nexport function createServer(): Connection {\n const connection = createConnection(ProposedFeatures.all);\n\n connection.onInitialize((): InitializeResult => {\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n completionProvider: {\n // Trigger completions inside JSDoc comments when `@` is typed\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(() => {\n // Return all FormSpec constraint tag completions.\n // Future phases will add context-aware filtering based on field type and\n // cursor position within JSDoc comment ranges.\n return getCompletionItems();\n });\n\n connection.onHover((_params) => {\n // Extract the word under the cursor and look up hover documentation.\n // This is a stub — precise JSDoc token detection (checking that the\n // cursor is within a JSDoc comment and extracting the tag name) will be\n // added in a future phase.\n //\n // For now we return null to signal no hover is available until the\n // token extraction is implemented.\n return getHoverForTag(\"\");\n });\n\n connection.onDefinition((_params) => {\n // Go-to-definition is not yet implemented.\n return getDefinition();\n });\n\n return connection;\n}\n","/**\n * Completion provider for FormSpec JSDoc constraint tags.\n *\n * Returns completion items for all recognized FormSpec JSDoc constraint tags\n * (e.g., `@minimum`, `@maximum`, `@pattern`), derived from\n * `BUILTIN_CONSTRAINT_DEFINITIONS`. This is a skeleton — context-aware\n * filtering will be added in a future phase.\n */\n\nimport { BUILTIN_CONSTRAINT_DEFINITIONS, type BuiltinConstraintName } from \"@formspec/core\";\nimport { CompletionItem, CompletionItemKind } from \"vscode-languageserver/node.js\";\n\n/**\n * Human-readable detail strings for each built-in constraint tag.\n *\n * Keys match the camelCase constraint names (matching keys in `BUILTIN_CONSTRAINT_DEFINITIONS`).\n * Values are shown as the detail string in completion items.\n */\nconst CONSTRAINT_DETAIL: Record<BuiltinConstraintName, string> = {\n minimum: \"Minimum numeric value (inclusive). Example: `@minimum 0`\",\n maximum: \"Maximum numeric value (inclusive). Example: `@maximum 100`\",\n exclusiveMinimum: \"Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`\",\n exclusiveMaximum: \"Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`\",\n multipleOf: \"Value must be a multiple of this number. Example: `@multipleOf 0.01`\",\n minLength: \"Minimum string length. Example: `@minLength 1`\",\n maxLength: \"Maximum string length. Example: `@maxLength 255`\",\n minItems: \"Minimum number of array items. Example: `@minItems 1`\",\n maxItems: \"Maximum number of array items. Example: `@maxItems 10`\",\n uniqueItems: \"Require all array items to be distinct. Example: `@uniqueItems`\",\n pattern: \"Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`\",\n enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions [\"a\",\"b\",\"c\"]`',\n const: 'Require a constant JSON value. Example: `@const \"USD\"`',\n};\n\n/**\n * Returns completion items for all FormSpec JSDoc constraint tags.\n *\n * Items are derived from `BUILTIN_CONSTRAINT_DEFINITIONS`, ensuring this list\n * stays in sync with the single source of truth in `@formspec/core`.\n *\n * Each item uses `CompletionItemKind.Keyword` since these are annotation\n * tags used within JSDoc comments rather than language symbols.\n *\n * @returns An array of LSP completion items for FormSpec constraint tags\n */\nexport function getCompletionItems(): CompletionItem[] {\n return (Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS) as BuiltinConstraintName[]).map((name) => ({\n label: `@${name}`,\n kind: CompletionItemKind.Keyword,\n detail: CONSTRAINT_DETAIL[name],\n }));\n}\n","/**\n * Hover provider for FormSpec JSDoc constraint tags.\n *\n * Returns Markdown documentation for a recognized FormSpec JSDoc tag when\n * the cursor is positioned over it. This is a skeleton — precise token\n * detection within JSDoc comment ranges will be added in a future phase.\n */\n\nimport {\n normalizeConstraintTagName,\n isBuiltinConstraintName,\n type BuiltinConstraintName,\n} from \"@formspec/core\";\nimport type { Hover } from \"vscode-languageserver/node.js\";\n\n/**\n * Markdown documentation for each built-in FormSpec constraint tag.\n *\n * Keys are the canonical constraint names from `BUILTIN_CONSTRAINT_DEFINITIONS`.\n * Values are Markdown strings suitable for LSP hover responses.\n */\nconst CONSTRAINT_HOVER_DOCS: Record<BuiltinConstraintName, string> = {\n minimum: [\n \"**@minimum** `<number>`\",\n \"\",\n \"Sets an inclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `minimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minimum 0 */\",\n \"amount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n maximum: [\n \"**@maximum** `<number>`\",\n \"\",\n \"Sets an inclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `maximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maximum 100 */\",\n \"percentage: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMinimum: [\n \"**@exclusiveMinimum** `<number>`\",\n \"\",\n \"Sets an exclusive lower bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMinimum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMinimum 0 */\",\n \"positiveAmount: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n exclusiveMaximum: [\n \"**@exclusiveMaximum** `<number>`\",\n \"\",\n \"Sets an exclusive upper bound on a numeric field.\",\n \"\",\n \"Maps to `exclusiveMaximum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @exclusiveMaximum 1 */\",\n \"ratio: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n multipleOf: [\n \"**@multipleOf** `<number>`\",\n \"\",\n \"Requires the numeric value to be a multiple of the given number.\",\n \"\",\n \"Maps to `multipleOf` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @multipleOf 0.01 */\",\n \"price: number;\",\n \"```\",\n ].join(\"\\n\"),\n\n minLength: [\n \"**@minLength** `<number>`\",\n \"\",\n \"Sets a minimum character length on a string field.\",\n \"\",\n \"Maps to `minLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minLength 1 */\",\n \"name: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n maxLength: [\n \"**@maxLength** `<number>`\",\n \"\",\n \"Sets a maximum character length on a string field.\",\n \"\",\n \"Maps to `maxLength` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxLength 255 */\",\n \"description: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n minItems: [\n \"**@minItems** `<number>`\",\n \"\",\n \"Sets a minimum number of items in an array field.\",\n \"\",\n \"Maps to `minItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @minItems 1 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n maxItems: [\n \"**@maxItems** `<number>`\",\n \"\",\n \"Sets a maximum number of items in an array field.\",\n \"\",\n \"Maps to `maxItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @maxItems 10 */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n uniqueItems: [\n \"**@uniqueItems**\",\n \"\",\n \"Requires all items in an array field to be distinct.\",\n \"\",\n \"Maps to `uniqueItems` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @uniqueItems */\",\n \"tags: string[];\",\n \"```\",\n ].join(\"\\n\"),\n\n pattern: [\n \"**@pattern** `<regex>`\",\n \"\",\n \"Sets a regular expression pattern that a string field must match.\",\n \"\",\n \"Maps to `pattern` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n \"/** @pattern ^[a-z0-9]+$ */\",\n \"slug: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n enumOptions: [\n \"**@enumOptions** `<json-array>`\",\n \"\",\n \"Specifies the allowed values for an enum field as an inline JSON array.\",\n \"\",\n \"Maps to `enum` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @enumOptions [\"draft\",\"sent\",\"archived\"] */',\n \"status: string;\",\n \"```\",\n ].join(\"\\n\"),\n\n const: [\n \"**@const** `<json-literal>`\",\n \"\",\n \"Requires the field value to equal a single constant JSON value.\",\n \"\",\n \"Maps to `const` in JSON Schema.\",\n \"\",\n \"**Example:**\",\n \"```typescript\",\n '/** @const \"USD\" */',\n \"currency: string;\",\n \"```\",\n ].join(\"\\n\"),\n} satisfies Record<BuiltinConstraintName, string>;\n\n/**\n * Returns hover documentation for a FormSpec JSDoc tag name.\n *\n * Accepts both camelCase (`\"minimum\"`) and PascalCase (`\"Minimum\"`) forms.\n * The `@` prefix is stripped before lookup if present.\n * Returns `null` when the tag is not a recognized FormSpec constraint tag.\n *\n * @param tagName - The tag name to look up (e.g., `\"minimum\"`, `\"@pattern\"`)\n * @returns An LSP `Hover` response, or `null` if the tag is not recognized\n */\nexport function getHoverForTag(tagName: string): Hover | null {\n // Strip leading `@` prefix if present\n const raw = tagName.startsWith(\"@\") ? tagName.slice(1) : tagName;\n const name = normalizeConstraintTagName(raw);\n\n if (!isBuiltinConstraintName(name)) {\n return null;\n }\n\n return {\n contents: {\n kind: \"markdown\",\n value: CONSTRAINT_HOVER_DOCS[name],\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 */\nexport function getDefinition(): Location | null {\n return null;\n}\n"],"mappings":";AAWA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;;;ACRP,SAAS,sCAAkE;AAC3E,SAAyB,0BAA0B;AAQnD,IAAM,oBAA2D;AAAA,EAC/D,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS;AAAA,EACT,aAAa;AAAA,EACb,OAAO;AACT;AAaO,SAAS,qBAAuC;AACrD,SAAQ,OAAO,KAAK,8BAA8B,EAA8B,IAAI,CAAC,UAAU;AAAA,IAC7F,OAAO,IAAI,IAAI;AAAA,IACf,MAAM,mBAAmB;AAAA,IACzB,QAAQ,kBAAkB,IAAI;AAAA,EAChC,EAAE;AACJ;;;AC3CA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AASP,IAAM,wBAA+D;AAAA,EACnE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;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iBAAiB,iBAAiB,GAAG;AAExD,aAAW,aAAa,MAAwB;AAC9C,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,kBAAkB,qBAAqB;AAAA,QACvC,oBAAoB;AAAA;AAAA,UAElB,mBAAmB,CAAC,GAAG;AAAA,QACzB;AAAA,QACA,eAAe;AAAA,QACf,oBAAoB;AAAA,MACtB;AAAA,MACA,YAAY;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AAED,aAAW,aAAa,MAAM;AAI5B,WAAO,mBAAmB;AAAA,EAC5B,CAAC;AAED,aAAW,QAAQ,CAAC,YAAY;AAQ9B,WAAO,eAAe,EAAE;AAAA,EAC1B,CAAC;AAED,aAAW,aAAa,CAAC,YAAY;AAEnC,WAAO,cAAc;AAAA,EACvB,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @formspec/language-server
2
+ * \@formspec/language-server
3
3
  *
4
4
  * Language server for FormSpec — provides completions, hover documentation,
5
5
  * and go-to-definition for FormSpec JSDoc constraint tags (`@Minimum`,
@@ -1 +1 @@
1
- {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/providers/completion.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAsB,MAAM,+BAA+B,CAAC;AAsBnF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAMrD"}
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/providers/completion.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAsB,MAAM,+BAA+B,CAAC;AAwBnF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAMrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../src/providers/hover.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAoK3D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAe5D"}
1
+ {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../src/providers/hover.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAgM3D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAe5D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formspec/language-server",
3
- "version": "0.1.0-alpha.14",
3
+ "version": "0.1.0-alpha.16",
4
4
  "description": "Language server for FormSpec — completions, hover, and go-to-definition for JSDoc constraint tags",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "vscode-languageserver": "^9.0.1",
22
22
  "vscode-languageserver-textdocument": "^1.0.12",
23
- "@formspec/core": "0.1.0-alpha.14"
23
+ "@formspec/core": "0.1.0-alpha.16"
24
24
  },
25
25
  "devDependencies": {
26
26
  "vitest": "^3.0.0"