@formspec/ts-plugin 0.1.0-alpha.22 → 0.1.0-alpha.26
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/README.md +0 -1
- package/dist/index.cjs +57 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/semantic-service.d.ts +40 -6
- package/dist/semantic-service.d.ts.map +1 -1
- package/dist/service.d.ts +28 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/ts-plugin-alpha.d.ts +635 -0
- package/dist/ts-plugin-beta.d.ts +635 -0
- package/dist/ts-plugin-internal.d.ts +645 -0
- package/dist/ts-plugin.d.ts +185 -20
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript language service plugin entrypoint for FormSpec.
|
|
3
|
+
*
|
|
4
|
+
* This package exposes the reference tsserver plugin and the reusable semantic
|
|
5
|
+
* service used by downstream TypeScript hosts.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import * as ts from 'typescript';
|
|
11
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Hover payload for a token inside a parsed FormSpec doc comment.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare interface CommentHoverInfo {
|
|
19
|
+
/** Comment token kind currently being described. */
|
|
20
|
+
readonly kind: "tag-name" | "target" | "argument";
|
|
21
|
+
/** Markdown rendered for the hovered token. */
|
|
22
|
+
readonly markdown: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Half-open character span within a source comment string.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare interface CommentSourceSpan {
|
|
31
|
+
/** Zero-based start offset, inclusive. */
|
|
32
|
+
readonly start: number;
|
|
33
|
+
/** Zero-based end offset, exclusive. */
|
|
34
|
+
readonly end: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Source span used by serialized comment-analysis payloads.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare type CommentSpan = CommentSourceSpan;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Reference proxy wrapper that keeps FormSpec semantic snapshots fresh while
|
|
46
|
+
* delegating actual TypeScript editor features to the original service.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare function createLanguageServiceProxy(languageService: ts.LanguageService, semanticService: FormSpecSemanticService): ts.LanguageService;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Current semantic-query protocol version shared by FormSpec analysis clients
|
|
54
|
+
* and servers.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare const FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 2;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Current schema version for serialized analysis artifacts.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Serializable view of one declaration-attached doc comment in a source file.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare interface FormSpecAnalysisCommentSnapshot {
|
|
73
|
+
/** Span covering the full doc comment block. */
|
|
74
|
+
readonly commentSpan: CommentSpan;
|
|
75
|
+
/** Span covering the declaration that owns the comment. */
|
|
76
|
+
readonly declarationSpan: CommentSpan;
|
|
77
|
+
/** Normalized placement where the comment was found, if known. */
|
|
78
|
+
readonly placement: FormSpecPlacement | null;
|
|
79
|
+
/** String form of the subject type targeted by the comment, if known. */
|
|
80
|
+
readonly subjectType: string | null;
|
|
81
|
+
/** String form of the host declaration type, if known. */
|
|
82
|
+
readonly hostType: string | null;
|
|
83
|
+
/** Parsed tag snapshots found inside the comment. */
|
|
84
|
+
readonly tags: readonly FormSpecAnalysisTagSnapshot[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* File-local diagnostic derived from comment parsing or semantic analysis.
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export declare interface FormSpecAnalysisDiagnostic {
|
|
93
|
+
/** Stable diagnostic code for downstream rendering or filtering. */
|
|
94
|
+
readonly code: string;
|
|
95
|
+
/** High-level diagnostic category. */
|
|
96
|
+
readonly category: FormSpecAnalysisDiagnosticCategory;
|
|
97
|
+
/** Human-readable diagnostic message. */
|
|
98
|
+
readonly message: string;
|
|
99
|
+
/** Source range where the diagnostic applies. */
|
|
100
|
+
readonly range: CommentSpan;
|
|
101
|
+
/** Severity to surface in editor or CLI UIs. */
|
|
102
|
+
readonly severity: "error" | "warning" | "info";
|
|
103
|
+
/** Additional source locations related to the diagnostic. */
|
|
104
|
+
readonly relatedLocations: readonly FormSpecAnalysisDiagnosticLocation[];
|
|
105
|
+
/** Structured diagnostic facts for white-label downstream formatting. */
|
|
106
|
+
readonly data: Record<string, FormSpecAnalysisDiagnosticDataValue>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Machine-readable diagnostic category used by FormSpec tooling surfaces.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export declare type FormSpecAnalysisDiagnosticCategory = "tag-recognition" | "value-parsing" | "type-compatibility" | "target-resolution" | "constraint-validation" | "infrastructure";
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Primitive structured values carried in diagnostic facts for white-label
|
|
118
|
+
* downstream rendering.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export declare type FormSpecAnalysisDiagnosticDataValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Additional source location associated with a diagnostic.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare interface FormSpecAnalysisDiagnosticLocation {
|
|
130
|
+
/** Absolute file path for the related diagnostic location. */
|
|
131
|
+
readonly filePath: string;
|
|
132
|
+
/** Source range for the related diagnostic location. */
|
|
133
|
+
readonly range: CommentSpan;
|
|
134
|
+
/** Optional explanatory text for the related location. */
|
|
135
|
+
readonly message?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Serializable analysis artifact for a single source file.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export declare interface FormSpecAnalysisFileSnapshot {
|
|
144
|
+
/** Absolute path of the analyzed source file. */
|
|
145
|
+
readonly filePath: string;
|
|
146
|
+
/** Stable hash of the file text used to detect drift. */
|
|
147
|
+
readonly sourceHash: string;
|
|
148
|
+
/** ISO timestamp recording when the snapshot was generated. */
|
|
149
|
+
readonly generatedAt: string;
|
|
150
|
+
/** Parsed comment snapshots extracted from the file. */
|
|
151
|
+
readonly comments: readonly FormSpecAnalysisCommentSnapshot[];
|
|
152
|
+
/** Diagnostics produced for the file at snapshot time. */
|
|
153
|
+
readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Discovery record written by the tsserver plugin so other FormSpec tooling
|
|
158
|
+
* can locate and validate the matching semantic service for a workspace.
|
|
159
|
+
*
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
declare interface FormSpecAnalysisManifest {
|
|
163
|
+
/** Protocol version expected by both the client and semantic service. */
|
|
164
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
165
|
+
/** Schema version for serialized analysis artifacts. */
|
|
166
|
+
readonly analysisSchemaVersion: typeof FORMSPEC_ANALYSIS_SCHEMA_VERSION;
|
|
167
|
+
/** Absolute workspace root the manifest was generated for. */
|
|
168
|
+
readonly workspaceRoot: string;
|
|
169
|
+
/** Stable identifier derived from the workspace root. */
|
|
170
|
+
readonly workspaceId: string;
|
|
171
|
+
/** IPC endpoint clients should connect to for semantic queries. */
|
|
172
|
+
readonly endpoint: FormSpecIpcEndpoint;
|
|
173
|
+
/** TypeScript version reported by the host environment. */
|
|
174
|
+
readonly typescriptVersion: string;
|
|
175
|
+
/** Fingerprint representing the active extension-tag registry. */
|
|
176
|
+
readonly extensionFingerprint: string;
|
|
177
|
+
/** Monotonic generation number for manifest refreshes. */
|
|
178
|
+
readonly generation: number;
|
|
179
|
+
/** ISO timestamp for when the manifest was last written. */
|
|
180
|
+
readonly updatedAt: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Serializable view of a single parsed FormSpec tag within a doc comment.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
188
|
+
export declare interface FormSpecAnalysisTagSnapshot {
|
|
189
|
+
/** Raw tag name as written in the source comment. */
|
|
190
|
+
readonly rawTagName: string;
|
|
191
|
+
/** Canonicalized tag name used for registry lookup. */
|
|
192
|
+
readonly normalizedTagName: string;
|
|
193
|
+
/** Whether the tag matched a known FormSpec tag definition. */
|
|
194
|
+
readonly recognized: boolean;
|
|
195
|
+
/** Span covering the full tag payload on the source line. */
|
|
196
|
+
readonly fullSpan: CommentSpan;
|
|
197
|
+
/** Span covering only the tag-name token. */
|
|
198
|
+
readonly tagNameSpan: CommentSpan;
|
|
199
|
+
/** Span covering the payload after the tag name, if present. */
|
|
200
|
+
readonly payloadSpan: CommentSpan | null;
|
|
201
|
+
/** Parsed target specifier, if the tag includes one. */
|
|
202
|
+
readonly target: FormSpecSerializedCommentTargetSpecifier | null;
|
|
203
|
+
/** Span covering the argument token or payload segment, if present. */
|
|
204
|
+
readonly argumentSpan: CommentSpan | null;
|
|
205
|
+
/** Raw argument text after any target specifier. */
|
|
206
|
+
readonly argumentText: string;
|
|
207
|
+
/** Semantic context derived for the parsed tag. */
|
|
208
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Cross-process endpoint used by the language server to reach the semantic
|
|
213
|
+
* tsserver plugin on the current workspace host.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
declare interface FormSpecIpcEndpoint {
|
|
218
|
+
/** Transport kind used to connect to the workspace semantic service. */
|
|
219
|
+
readonly kind: "unix-socket" | "windows-pipe";
|
|
220
|
+
/** Absolute socket path or pipe name for the semantic service endpoint. */
|
|
221
|
+
readonly address: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Declaration contexts where a FormSpec tag may appear.
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
export declare type FormSpecPlacement = "class" | "class-field" | "class-method" | "interface" | "interface-field" | "type-alias" | "type-alias-field" | "variable" | "function" | "function-parameter" | "method-parameter";
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Reference manifest/socket wrapper around `FormSpecSemanticService`.
|
|
233
|
+
*
|
|
234
|
+
* Downstream TypeScript hosts that already control their own plugin/runtime
|
|
235
|
+
* lifecycle can use `FormSpecSemanticService` directly and skip this wrapper.
|
|
236
|
+
*
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export declare class FormSpecPluginService {
|
|
240
|
+
private readonly options;
|
|
241
|
+
private readonly manifest;
|
|
242
|
+
private readonly runtimePaths;
|
|
243
|
+
private readonly semanticService;
|
|
244
|
+
private server;
|
|
245
|
+
constructor(options: FormSpecPluginServiceOptions);
|
|
246
|
+
/**
|
|
247
|
+
* Returns the manifest written by the plugin service for workspace discovery.
|
|
248
|
+
*
|
|
249
|
+
* @internal
|
|
250
|
+
*/
|
|
251
|
+
getManifest(): FormSpecAnalysisManifest;
|
|
252
|
+
/**
|
|
253
|
+
* Returns the underlying semantic service used by this reference wrapper.
|
|
254
|
+
*
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
getSemanticService(): FormSpecSemanticService;
|
|
258
|
+
/**
|
|
259
|
+
* Starts the IPC transport and writes the current workspace manifest.
|
|
260
|
+
*
|
|
261
|
+
* Calling this more than once is a no-op.
|
|
262
|
+
*
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
start(): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Stops the IPC transport, clears semantic state, and removes runtime artifacts.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
stop(): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Schedules a background refresh for the cached semantic snapshot of a file.
|
|
274
|
+
*
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
scheduleSnapshotRefresh(filePath: string): void;
|
|
278
|
+
/**
|
|
279
|
+
* Handles a semantic query issued against the plugin transport.
|
|
280
|
+
*
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
handleQuery(query: FormSpecSemanticQuery): FormSpecSemanticResponse;
|
|
284
|
+
private executeQuery;
|
|
285
|
+
private respondToSocket;
|
|
286
|
+
private writeManifest;
|
|
287
|
+
private cleanupRuntimeArtifacts;
|
|
288
|
+
private logQueryDuration;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Public configuration for the reference plugin wrapper that exposes
|
|
293
|
+
* `FormSpecSemanticService` over the local manifest + IPC transport.
|
|
294
|
+
*
|
|
295
|
+
* Supports the same semantic-service options, including
|
|
296
|
+
* `enablePerformanceLogging`, `performanceLogThresholdMs`, and
|
|
297
|
+
* `snapshotDebounceMs`. The packaged tsserver plugin wires these from
|
|
298
|
+
* `FORMSPEC_PLUGIN_PROFILE=1` and `FORMSPEC_PLUGIN_PROFILE_THRESHOLD_MS`.
|
|
299
|
+
*
|
|
300
|
+
* @public
|
|
301
|
+
*/
|
|
302
|
+
export declare type FormSpecPluginServiceOptions = FormSpecSemanticServiceOptions;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Serialized completion result returned by the semantic service.
|
|
306
|
+
*
|
|
307
|
+
* @public
|
|
308
|
+
*/
|
|
309
|
+
export declare interface FormSpecSemanticCompletionResult {
|
|
310
|
+
/** Protocol version used by the serialized response. */
|
|
311
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
312
|
+
/** Hash of the source file used to compute the response. */
|
|
313
|
+
readonly sourceHash: string;
|
|
314
|
+
/** Serialized completion payload for the active cursor context. */
|
|
315
|
+
readonly context: FormSpecSerializedCompletionContext;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Serialized diagnostics result returned by the semantic service.
|
|
320
|
+
*
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
export declare interface FormSpecSemanticDiagnosticsResult {
|
|
324
|
+
/** Protocol version used by the serialized response. */
|
|
325
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
326
|
+
/** Hash of the source file used to compute the response. */
|
|
327
|
+
readonly sourceHash: string;
|
|
328
|
+
/** Canonical FormSpec diagnostics for the requested file. */
|
|
329
|
+
readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Serialized hover result returned by the semantic service.
|
|
334
|
+
*
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
export declare interface FormSpecSemanticHoverResult {
|
|
338
|
+
/** Protocol version used by the serialized response. */
|
|
339
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
340
|
+
/** Hash of the source file used to compute the response. */
|
|
341
|
+
readonly sourceHash: string;
|
|
342
|
+
/** Serialized hover payload, or `null` when nothing is available at the cursor. */
|
|
343
|
+
readonly hover: FormSpecSerializedHoverInfo | null;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Query variants supported by the semantic tsserver plugin.
|
|
348
|
+
*
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
351
|
+
declare type FormSpecSemanticQuery = {
|
|
352
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
353
|
+
readonly kind: "health";
|
|
354
|
+
} | {
|
|
355
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
356
|
+
readonly kind: "completion";
|
|
357
|
+
readonly filePath: string;
|
|
358
|
+
readonly offset: number;
|
|
359
|
+
} | {
|
|
360
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
361
|
+
readonly kind: "hover";
|
|
362
|
+
readonly filePath: string;
|
|
363
|
+
readonly offset: number;
|
|
364
|
+
} | {
|
|
365
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
366
|
+
readonly kind: "diagnostics";
|
|
367
|
+
readonly filePath: string;
|
|
368
|
+
} | {
|
|
369
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
370
|
+
readonly kind: "file-snapshot";
|
|
371
|
+
readonly filePath: string;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Response variants returned by the semantic tsserver plugin.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
declare type FormSpecSemanticResponse = {
|
|
380
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
381
|
+
readonly kind: "health";
|
|
382
|
+
readonly manifest: FormSpecAnalysisManifest;
|
|
383
|
+
} | {
|
|
384
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
385
|
+
readonly kind: "completion";
|
|
386
|
+
readonly sourceHash: string;
|
|
387
|
+
readonly context: FormSpecSerializedCompletionContext;
|
|
388
|
+
} | {
|
|
389
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
390
|
+
readonly kind: "hover";
|
|
391
|
+
readonly sourceHash: string;
|
|
392
|
+
readonly hover: FormSpecSerializedHoverInfo | null;
|
|
393
|
+
} | {
|
|
394
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
395
|
+
readonly kind: "diagnostics";
|
|
396
|
+
readonly sourceHash: string;
|
|
397
|
+
readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
|
|
398
|
+
} | {
|
|
399
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
400
|
+
readonly kind: "file-snapshot";
|
|
401
|
+
readonly snapshot: FormSpecAnalysisFileSnapshot | null;
|
|
402
|
+
} | {
|
|
403
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
404
|
+
readonly kind: "error";
|
|
405
|
+
readonly error: string;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Reusable in-process semantic service for FormSpec authoring features.
|
|
410
|
+
*
|
|
411
|
+
* Downstream TypeScript hosts can construct this directly against their own
|
|
412
|
+
* `Program` and own the final presentation of completions, hover, and
|
|
413
|
+
* diagnostics. The shipped tsserver plugin is a reference wrapper over this
|
|
414
|
+
* public service.
|
|
415
|
+
*
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
export declare class FormSpecSemanticService {
|
|
419
|
+
private readonly options;
|
|
420
|
+
private readonly snapshotCache;
|
|
421
|
+
private readonly refreshTimers;
|
|
422
|
+
private readonly stats;
|
|
423
|
+
constructor(options: FormSpecSemanticServiceOptions);
|
|
424
|
+
/** Resolves semantic completion context for a comment cursor position. */
|
|
425
|
+
getCompletionContext(filePath: string, offset: number): FormSpecSemanticCompletionResult | null;
|
|
426
|
+
/** Resolves semantic hover payload for a comment cursor position. */
|
|
427
|
+
getHover(filePath: string, offset: number): FormSpecSemanticHoverResult | null;
|
|
428
|
+
/** Returns canonical FormSpec diagnostics for a file in the current host program. */
|
|
429
|
+
getDiagnostics(filePath: string): FormSpecSemanticDiagnosticsResult;
|
|
430
|
+
/** Returns the full serialized semantic snapshot for a file. */
|
|
431
|
+
getFileSnapshot(filePath: string): FormSpecAnalysisFileSnapshot;
|
|
432
|
+
/** Schedules a debounced background refresh for the file snapshot cache. */
|
|
433
|
+
scheduleSnapshotRefresh(filePath: string): void;
|
|
434
|
+
/** Clears pending timers and cached semantic snapshots. */
|
|
435
|
+
dispose(): void;
|
|
436
|
+
/** Returns a copy of the current performance and cache counters. */
|
|
437
|
+
getStats(): FormSpecSemanticServiceStats;
|
|
438
|
+
private runMeasured;
|
|
439
|
+
private withCommentQueryContext;
|
|
440
|
+
private getFileSnapshotWithCacheState;
|
|
441
|
+
private getNow;
|
|
442
|
+
private getSourceEnvironment;
|
|
443
|
+
private recordQueryPath;
|
|
444
|
+
private updateStatsFromPerformanceEvents;
|
|
445
|
+
private logPerformanceEvents;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Configuration for the reusable in-process semantic service.
|
|
450
|
+
*
|
|
451
|
+
* @public
|
|
452
|
+
*/
|
|
453
|
+
export declare interface FormSpecSemanticServiceOptions {
|
|
454
|
+
/** Workspace root used for runtime paths and contextual logging. */
|
|
455
|
+
readonly workspaceRoot: string;
|
|
456
|
+
/** TypeScript version string reported by the host runtime. */
|
|
457
|
+
readonly typescriptVersion: string;
|
|
458
|
+
/** Supplies the current host program. Returns `undefined` until ready. */
|
|
459
|
+
readonly getProgram: () => ts.Program | undefined;
|
|
460
|
+
/** Optional logger used for profiling and refresh-failure messages. */
|
|
461
|
+
readonly logger?: LoggerLike;
|
|
462
|
+
/** Enables structured hotspot logging for semantic queries. */
|
|
463
|
+
readonly enablePerformanceLogging?: boolean;
|
|
464
|
+
/** Minimum query duration, in milliseconds, required before logging. */
|
|
465
|
+
readonly performanceLogThresholdMs?: number;
|
|
466
|
+
/** Debounce window, in milliseconds, for background snapshot refresh. */
|
|
467
|
+
readonly snapshotDebounceMs?: number;
|
|
468
|
+
/** Injectable clock used by tests and runtime snapshot timestamps. */
|
|
469
|
+
readonly now?: () => Date;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Performance and cache counters exposed by the semantic service.
|
|
474
|
+
*
|
|
475
|
+
* @public
|
|
476
|
+
*/
|
|
477
|
+
export declare interface FormSpecSemanticServiceStats {
|
|
478
|
+
/** Total number of calls by semantic query kind. */
|
|
479
|
+
readonly queryTotals: {
|
|
480
|
+
readonly completion: number;
|
|
481
|
+
readonly hover: number;
|
|
482
|
+
readonly diagnostics: number;
|
|
483
|
+
readonly fileSnapshot: number;
|
|
484
|
+
};
|
|
485
|
+
/** Cold vs warm query path counts for snapshot-backed operations. */
|
|
486
|
+
readonly queryPathTotals: {
|
|
487
|
+
readonly diagnostics: {
|
|
488
|
+
readonly cold: number;
|
|
489
|
+
readonly warm: number;
|
|
490
|
+
};
|
|
491
|
+
readonly fileSnapshot: {
|
|
492
|
+
readonly cold: number;
|
|
493
|
+
readonly warm: number;
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
/** Number of file snapshot cache hits. */
|
|
497
|
+
readonly fileSnapshotCacheHits: number;
|
|
498
|
+
/** Number of file snapshot cache misses. */
|
|
499
|
+
readonly fileSnapshotCacheMisses: number;
|
|
500
|
+
/** Number of synthetic batch cache hits. */
|
|
501
|
+
readonly syntheticBatchCacheHits: number;
|
|
502
|
+
/** Number of synthetic batch cache misses. */
|
|
503
|
+
readonly syntheticBatchCacheMisses: number;
|
|
504
|
+
/** Number of synthetic compiler program creations. */
|
|
505
|
+
readonly syntheticCompileCount: number;
|
|
506
|
+
/** Total synthetic application count compiled across misses. */
|
|
507
|
+
readonly syntheticCompileApplications: number;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Serialized representation of a parsed target specifier with exact spans.
|
|
512
|
+
*
|
|
513
|
+
* @public
|
|
514
|
+
*/
|
|
515
|
+
export declare interface FormSpecSerializedCommentTargetSpecifier {
|
|
516
|
+
/** Raw target text without the leading colon. */
|
|
517
|
+
readonly rawText: string;
|
|
518
|
+
/** Whether the serialized target parsed successfully. */
|
|
519
|
+
readonly valid: boolean;
|
|
520
|
+
/** Target syntax kind inferred for the serialized specifier. */
|
|
521
|
+
readonly kind: "path" | "member" | "variant" | "ambiguous";
|
|
522
|
+
/** Span covering the entire target, including the leading colon. */
|
|
523
|
+
readonly fullSpan: CommentSpan;
|
|
524
|
+
/** Span covering only the colon token. */
|
|
525
|
+
readonly colonSpan: CommentSpan;
|
|
526
|
+
/** Span covering only the target text. */
|
|
527
|
+
readonly span: CommentSpan;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Cursor-scoped completion context serialized for transport between the
|
|
532
|
+
* semantic tsserver plugin and the lightweight LSP.
|
|
533
|
+
*
|
|
534
|
+
* @public
|
|
535
|
+
*/
|
|
536
|
+
export declare type FormSpecSerializedCompletionContext = {
|
|
537
|
+
readonly kind: "tag-name";
|
|
538
|
+
readonly prefix: string;
|
|
539
|
+
readonly availableTags: readonly FormSpecSerializedTagDefinition[];
|
|
540
|
+
} | {
|
|
541
|
+
readonly kind: "target";
|
|
542
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
543
|
+
} | {
|
|
544
|
+
readonly kind: "argument";
|
|
545
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
546
|
+
readonly valueLabels: readonly string[];
|
|
547
|
+
} | {
|
|
548
|
+
readonly kind: "none";
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Hover payload for a single comment token under the cursor.
|
|
553
|
+
*
|
|
554
|
+
* @public
|
|
555
|
+
*/
|
|
556
|
+
export declare interface FormSpecSerializedHoverInfo {
|
|
557
|
+
/** Comment token kind being described. */
|
|
558
|
+
readonly kind: "tag-name" | "target" | "argument";
|
|
559
|
+
/** Markdown payload that should be rendered for the hover. */
|
|
560
|
+
readonly markdown: string;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Serializable subset of tag metadata needed by hover and completion UIs.
|
|
565
|
+
*
|
|
566
|
+
* @public
|
|
567
|
+
*/
|
|
568
|
+
export declare interface FormSpecSerializedTagDefinition {
|
|
569
|
+
/** Canonical tag name, including the `@` prefix. */
|
|
570
|
+
readonly canonicalName: string;
|
|
571
|
+
/** Short completion label shown in completion menus. */
|
|
572
|
+
readonly completionDetail: string;
|
|
573
|
+
/** Markdown hover content describing the tag. */
|
|
574
|
+
readonly hoverMarkdown: string;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Semantic facts about one parsed tag, reduced to JSON-safe data for IPC.
|
|
579
|
+
*
|
|
580
|
+
* @public
|
|
581
|
+
*/
|
|
582
|
+
export declare interface FormSpecSerializedTagSemanticContext {
|
|
583
|
+
/** Canonical tag name, including the `@` prefix. */
|
|
584
|
+
readonly tagName: string;
|
|
585
|
+
/** Tag metadata when the tag is recognized by the registry. */
|
|
586
|
+
readonly tagDefinition: FormSpecSerializedTagDefinition | null;
|
|
587
|
+
/** Declaration placement the tag was evaluated in, if known. */
|
|
588
|
+
readonly placement: FormSpecPlacement | null;
|
|
589
|
+
/** Target syntaxes supported by the matching signatures. */
|
|
590
|
+
readonly supportedTargets: readonly FormSpecTargetKind[];
|
|
591
|
+
/** Suggested targets for completion UIs. */
|
|
592
|
+
readonly targetCompletions: readonly string[];
|
|
593
|
+
/** Compatible path targets computed from the subject type, if available. */
|
|
594
|
+
readonly compatiblePathTargets: readonly string[];
|
|
595
|
+
/** Suggested value labels derived from the matching signatures. */
|
|
596
|
+
readonly valueLabels: readonly string[];
|
|
597
|
+
/** Signature summaries for the recognized tag in the current placement. */
|
|
598
|
+
readonly signatures: readonly FormSpecSerializedTagSignature[];
|
|
599
|
+
/** Markdown hover for the tag name token. */
|
|
600
|
+
readonly tagHoverMarkdown: string | null;
|
|
601
|
+
/** Markdown hover for the target token, when available. */
|
|
602
|
+
readonly targetHoverMarkdown: string | null;
|
|
603
|
+
/** Markdown hover for the argument token, when available. */
|
|
604
|
+
readonly argumentHoverMarkdown: string | null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Serializable overload/signature summary for one comment tag form.
|
|
609
|
+
*
|
|
610
|
+
* @public
|
|
611
|
+
*/
|
|
612
|
+
export declare interface FormSpecSerializedTagSignature {
|
|
613
|
+
/** Human-readable rendering of one supported tag signature. */
|
|
614
|
+
readonly label: string;
|
|
615
|
+
/** Declaration placements where this signature is valid. */
|
|
616
|
+
readonly placements: readonly FormSpecPlacement[];
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Target syntaxes that a FormSpec tag can accept.
|
|
621
|
+
*
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
export declare type FormSpecTargetKind = "none" | "path" | "member" | "variant";
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Initializes the FormSpec TypeScript language service plugin.
|
|
628
|
+
*
|
|
629
|
+
* @public
|
|
630
|
+
*/
|
|
631
|
+
export declare function init(modules: {
|
|
632
|
+
readonly typescript: typeof tsServer;
|
|
633
|
+
}): tsServer.server.PluginModule;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Minimal logging surface used by the semantic service and plugin wrapper.
|
|
637
|
+
*
|
|
638
|
+
* @public
|
|
639
|
+
*/
|
|
640
|
+
export declare interface LoggerLike {
|
|
641
|
+
/** Writes a human-readable diagnostic or profiling message. */
|
|
642
|
+
info(message: string): void;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export { }
|