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

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.
@@ -10,7 +10,8 @@
10
10
  * LSP process, while TypeScript-project-aware semantics are supplied by
11
11
  * `@formspec/ts-plugin` over a local manifest + IPC transport.
12
12
  *
13
- * Diagnostics are intentionally omitted per design decision A7.
13
+ * The packaged server acts as a reference implementation over the composable
14
+ * completion, hover, and diagnostics helpers exported from this package.
14
15
  *
15
16
  * @example
16
17
  * ```ts
@@ -25,9 +26,17 @@
25
26
 
26
27
  import { CompletionItem } from 'vscode-languageserver/node.js';
27
28
  import { Connection } from 'vscode-languageserver/node.js';
29
+ import { Diagnostic } from 'vscode-languageserver/node.js';
28
30
  import type { ExtensionDefinition } from '@formspec/core';
29
31
  import type { Hover } from 'vscode-languageserver/node.js';
30
32
  import type { Location } from 'vscode-languageserver/node.js';
33
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
34
+
35
+ /** @public */
36
+ export declare interface CommentSpan {
37
+ readonly start: number;
38
+ readonly end: number;
39
+ }
31
40
 
32
41
  /**
33
42
  * Creates and configures the FormSpec language server connection.
@@ -54,6 +63,51 @@ export declare interface CreateServerOptions {
54
63
  readonly usePluginTransport?: boolean;
55
64
  /** IPC timeout, in milliseconds, for semantic plugin requests. */
56
65
  readonly pluginQueryTimeoutMs?: number;
66
+ /** Optional diagnostics publishing mode for the packaged reference LSP. */
67
+ readonly diagnosticsMode?: "off" | "plugin";
68
+ /** Source label to use when publishing plugin-derived diagnostics. */
69
+ readonly diagnosticSource?: string;
70
+ }
71
+
72
+ /**
73
+ * File-local diagnostic derived from comment parsing or semantic analysis.
74
+ *
75
+ * @public
76
+ */
77
+ export declare interface FormSpecAnalysisDiagnostic {
78
+ readonly code: string;
79
+ readonly category: FormSpecAnalysisDiagnosticCategory;
80
+ readonly message: string;
81
+ readonly range: CommentSpan;
82
+ readonly severity: "error" | "warning" | "info";
83
+ readonly relatedLocations: readonly FormSpecAnalysisDiagnosticLocation[];
84
+ readonly data: Record<string, FormSpecAnalysisDiagnosticDataValue>;
85
+ }
86
+
87
+ /**
88
+ * Machine-readable diagnostic category used by FormSpec tooling surfaces.
89
+ *
90
+ * @public
91
+ */
92
+ export declare type FormSpecAnalysisDiagnosticCategory = "tag-recognition" | "value-parsing" | "type-compatibility" | "target-resolution" | "constraint-validation" | "infrastructure";
93
+
94
+ /**
95
+ * Primitive structured values carried in diagnostic facts for white-label
96
+ * downstream rendering.
97
+ *
98
+ * @public
99
+ */
100
+ export declare type FormSpecAnalysisDiagnosticDataValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
101
+
102
+ /**
103
+ * Additional source location associated with a diagnostic.
104
+ *
105
+ * @public
106
+ */
107
+ export declare interface FormSpecAnalysisDiagnosticLocation {
108
+ readonly filePath: string;
109
+ readonly range: CommentSpan;
110
+ readonly message?: string;
57
111
  }
58
112
 
59
113
  /**
@@ -80,4 +134,33 @@ export declare function getDefinition(): Location | null;
80
134
  */
81
135
  export declare function getHoverForTag(tagName: string, extensions?: readonly ExtensionDefinition[]): Hover | null;
82
136
 
137
+ /**
138
+ * Retrieves canonical FormSpec diagnostics for the current document revision
139
+ * from the plugin transport. Returns `null` when the transport is missing,
140
+ * stale, or invalid.
141
+ *
142
+ * @public
143
+ */
144
+ export declare function getPluginDiagnosticsForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, timeoutMs?: number): Promise<readonly FormSpecAnalysisDiagnostic[] | null>;
145
+
146
+ /**
147
+ * Converts canonical FormSpec diagnostics into LSP diagnostics.
148
+ *
149
+ * Downstream consumers that want complete white-label control can ignore this
150
+ * helper and render their own messages from `code` + `data`.
151
+ *
152
+ * @public
153
+ */
154
+ export declare function toLspDiagnostics(document: TextDocument, diagnostics: readonly FormSpecAnalysisDiagnostic[], options?: ToLspDiagnosticsOptions): Diagnostic[];
155
+
156
+ /**
157
+ * Options for converting canonical FormSpec diagnostics into LSP diagnostics.
158
+ *
159
+ * @public
160
+ */
161
+ export declare interface ToLspDiagnosticsOptions {
162
+ /** Source label shown by LSP clients. Defaults to `formspec`. */
163
+ readonly source?: string;
164
+ }
165
+
83
166
  export { }
@@ -1,5 +1,13 @@
1
- import { type FormSpecSerializedCompletionContext, type FormSpecSerializedHoverInfo } from "@formspec/analysis/protocol";
1
+ import { type FormSpecAnalysisDiagnostic, type FormSpecSerializedCompletionContext, type FormSpecSerializedHoverInfo } from "@formspec/analysis/protocol";
2
2
  export declare function fileUriToPathOrNull(uri: string): string | null;
3
3
  export declare function getPluginCompletionContextForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, offset: number, timeoutMs?: number): Promise<FormSpecSerializedCompletionContext | null>;
4
4
  export declare function getPluginHoverForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, offset: number, timeoutMs?: number): Promise<FormSpecSerializedHoverInfo | null>;
5
+ /**
6
+ * Retrieves canonical FormSpec diagnostics for the current document revision
7
+ * from the plugin transport. Returns `null` when the transport is missing,
8
+ * stale, or invalid.
9
+ *
10
+ * @public
11
+ */
12
+ export declare function getPluginDiagnosticsForDocument(workspaceRoots: readonly string[], filePath: string, documentText: string, timeoutMs?: number): Promise<readonly FormSpecAnalysisDiagnostic[] | null>;
5
13
  //# sourceMappingURL=plugin-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-client.d.ts","sourceRoot":"","sources":["../src/plugin-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAOL,KAAK,mCAAmC,EACxC,KAAK,2BAA2B,EAGjC,MAAM,6BAA6B,CAAC;AAwGrC,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM9D;AAqBD,wBAAsB,qCAAqC,CACzD,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,SAAkC,GAC1C,OAAO,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAiBrD;AAED,wBAAsB,yBAAyB,CAC7C,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,SAAkC,GAC1C,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAiB7C"}
1
+ {"version":3,"file":"plugin-client.d.ts","sourceRoot":"","sources":["../src/plugin-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,0BAA0B,EAE/B,KAAK,mCAAmC,EACxC,KAAK,2BAA2B,EAGjC,MAAM,6BAA6B,CAAC;AAyGrC,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM9D;AAqBD,wBAAsB,qCAAqC,CACzD,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,SAAkC,GAC1C,OAAO,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAiBrD;AAED,wBAAsB,yBAAyB,CAC7C,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,SAAkC,GAC1C,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAiB7C;AAED;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,SAAS,SAAkC,GAC1C,OAAO,CAAC,SAAS,0BAA0B,EAAE,GAAG,IAAI,CAAC,CAkBvD"}
package/dist/server.d.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * - `textDocument/hover` — Documentation for recognized constraint tags
7
7
  * - `textDocument/definition` — Go-to-definition (stub, returns null)
8
8
  *
9
- * Diagnostics are intentionally omitted per design decision A7.
9
+ * The packaged language server is a reference implementation built on the same
10
+ * composable helpers that downstream consumers can call directly.
10
11
  */
11
12
  import { type Connection } from "vscode-languageserver/node.js";
12
13
  import type { ExtensionDefinition } from "@formspec/core";
@@ -24,6 +25,10 @@ export interface CreateServerOptions {
24
25
  readonly usePluginTransport?: boolean;
25
26
  /** IPC timeout, in milliseconds, for semantic plugin requests. */
26
27
  readonly pluginQueryTimeoutMs?: number;
28
+ /** Optional diagnostics publishing mode for the packaged reference LSP. */
29
+ readonly diagnosticsMode?: "off" | "plugin";
30
+ /** Source label to use when publishing plugin-derived diagnostics. */
31
+ readonly diagnosticSource?: string;
27
32
  }
28
33
  /**
29
34
  * Creates and configures the FormSpec language server connection.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAqD1D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,mEAAmE;IACnE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CAmF1E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAML,KAAK,UAAU,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAsD1D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,mEAAmE;IACnE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC5C,sEAAsE;IACtE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CAoI1E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formspec/language-server",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.23",
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,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "vscode-languageserver": "^9.0.1",
22
22
  "vscode-languageserver-textdocument": "^1.0.12",
23
- "@formspec/analysis": "0.1.0-alpha.21",
24
- "@formspec/core": "0.1.0-alpha.21"
23
+ "@formspec/analysis": "0.1.0-alpha.23",
24
+ "@formspec/core": "0.1.0-alpha.23"
25
25
  },
26
26
  "devDependencies": {
27
27
  "vitest": "^3.0.0"
@@ -38,12 +38,12 @@
38
38
  ],
39
39
  "license": "UNLICENSED",
40
40
  "scripts": {
41
- "build": "tsup && tsc --emitDeclarationOnly && api-extractor run --local",
41
+ "build": "tsup && tsc --emitDeclarationOnly && pnpm run api-extractor:local",
42
42
  "clean": "rm -rf dist temp",
43
43
  "typecheck": "tsc --noEmit",
44
44
  "test": "vitest run",
45
- "api-extractor": "api-extractor run",
46
- "api-extractor:local": "api-extractor run --local",
47
- "api-documenter": "api-documenter markdown -i temp -o docs"
45
+ "api-extractor": "api-extractor run && node ../../scripts/normalize-generated-markdown.mjs api-report",
46
+ "api-extractor:local": "api-extractor run --local && node ../../scripts/normalize-generated-markdown.mjs api-report",
47
+ "api-documenter": "api-documenter markdown -i temp -o docs && node ../../scripts/normalize-generated-markdown.mjs docs"
48
48
  }
49
49
  }