@formspec/ts-plugin 0.1.0-alpha.23 → 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.
@@ -1,15 +1,46 @@
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
+
1
10
  import * as ts from 'typescript';
2
11
  import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
3
12
 
4
- /** @public */
5
- export declare type CommentSourceSpan = CommentSpan;
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
+ }
6
24
 
7
- /** @public */
8
- export declare interface CommentSpan {
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. */
9
32
  readonly start: number;
33
+ /** Zero-based end offset, exclusive. */
10
34
  readonly end: number;
11
35
  }
12
36
 
37
+ /**
38
+ * Source span used by serialized comment-analysis payloads.
39
+ *
40
+ * @public
41
+ */
42
+ export declare type CommentSpan = CommentSourceSpan;
43
+
13
44
  /**
14
45
  * Reference proxy wrapper that keeps FormSpec semantic snapshots fresh while
15
46
  * delegating actual TypeScript editor features to the original service.
@@ -18,10 +49,19 @@ export declare interface CommentSpan {
18
49
  */
19
50
  export declare function createLanguageServiceProxy(languageService: ts.LanguageService, semanticService: FormSpecSemanticService): ts.LanguageService;
20
51
 
21
- /** @public */
52
+ /**
53
+ * Current semantic-query protocol version shared by FormSpec analysis clients
54
+ * and servers.
55
+ *
56
+ * @public
57
+ */
22
58
  export declare const FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 2;
23
59
 
24
- /** @public */
60
+ /**
61
+ * Current schema version for serialized analysis artifacts.
62
+ *
63
+ * @public
64
+ */
25
65
  export declare const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
26
66
 
27
67
  /**
@@ -30,11 +70,17 @@ export declare const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
30
70
  * @public
31
71
  */
32
72
  export declare interface FormSpecAnalysisCommentSnapshot {
73
+ /** Span covering the full doc comment block. */
33
74
  readonly commentSpan: CommentSpan;
75
+ /** Span covering the declaration that owns the comment. */
34
76
  readonly declarationSpan: CommentSpan;
77
+ /** Normalized placement where the comment was found, if known. */
35
78
  readonly placement: FormSpecPlacement | null;
79
+ /** String form of the subject type targeted by the comment, if known. */
36
80
  readonly subjectType: string | null;
81
+ /** String form of the host declaration type, if known. */
37
82
  readonly hostType: string | null;
83
+ /** Parsed tag snapshots found inside the comment. */
38
84
  readonly tags: readonly FormSpecAnalysisTagSnapshot[];
39
85
  }
40
86
 
@@ -44,12 +90,19 @@ export declare interface FormSpecAnalysisCommentSnapshot {
44
90
  * @public
45
91
  */
46
92
  export declare interface FormSpecAnalysisDiagnostic {
93
+ /** Stable diagnostic code for downstream rendering or filtering. */
47
94
  readonly code: string;
95
+ /** High-level diagnostic category. */
48
96
  readonly category: FormSpecAnalysisDiagnosticCategory;
97
+ /** Human-readable diagnostic message. */
49
98
  readonly message: string;
99
+ /** Source range where the diagnostic applies. */
50
100
  readonly range: CommentSpan;
101
+ /** Severity to surface in editor or CLI UIs. */
51
102
  readonly severity: "error" | "warning" | "info";
103
+ /** Additional source locations related to the diagnostic. */
52
104
  readonly relatedLocations: readonly FormSpecAnalysisDiagnosticLocation[];
105
+ /** Structured diagnostic facts for white-label downstream formatting. */
53
106
  readonly data: Record<string, FormSpecAnalysisDiagnosticDataValue>;
54
107
  }
55
108
 
@@ -74,8 +127,11 @@ export declare type FormSpecAnalysisDiagnosticDataValue = string | number | bool
74
127
  * @public
75
128
  */
76
129
  export declare interface FormSpecAnalysisDiagnosticLocation {
130
+ /** Absolute file path for the related diagnostic location. */
77
131
  readonly filePath: string;
132
+ /** Source range for the related diagnostic location. */
78
133
  readonly range: CommentSpan;
134
+ /** Optional explanatory text for the related location. */
79
135
  readonly message?: string;
80
136
  }
81
137
 
@@ -85,10 +141,15 @@ export declare interface FormSpecAnalysisDiagnosticLocation {
85
141
  * @public
86
142
  */
87
143
  export declare interface FormSpecAnalysisFileSnapshot {
144
+ /** Absolute path of the analyzed source file. */
88
145
  readonly filePath: string;
146
+ /** Stable hash of the file text used to detect drift. */
89
147
  readonly sourceHash: string;
148
+ /** ISO timestamp recording when the snapshot was generated. */
90
149
  readonly generatedAt: string;
150
+ /** Parsed comment snapshots extracted from the file. */
91
151
  readonly comments: readonly FormSpecAnalysisCommentSnapshot[];
152
+ /** Diagnostics produced for the file at snapshot time. */
92
153
  readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
93
154
  }
94
155
 
@@ -98,15 +159,24 @@ export declare interface FormSpecAnalysisFileSnapshot {
98
159
  *
99
160
  * @public
100
161
  */
101
- export declare interface FormSpecAnalysisManifest {
162
+ declare interface FormSpecAnalysisManifest {
163
+ /** Protocol version expected by both the client and semantic service. */
102
164
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
165
+ /** Schema version for serialized analysis artifacts. */
103
166
  readonly analysisSchemaVersion: typeof FORMSPEC_ANALYSIS_SCHEMA_VERSION;
167
+ /** Absolute workspace root the manifest was generated for. */
104
168
  readonly workspaceRoot: string;
169
+ /** Stable identifier derived from the workspace root. */
105
170
  readonly workspaceId: string;
171
+ /** IPC endpoint clients should connect to for semantic queries. */
106
172
  readonly endpoint: FormSpecIpcEndpoint;
173
+ /** TypeScript version reported by the host environment. */
107
174
  readonly typescriptVersion: string;
175
+ /** Fingerprint representing the active extension-tag registry. */
108
176
  readonly extensionFingerprint: string;
177
+ /** Monotonic generation number for manifest refreshes. */
109
178
  readonly generation: number;
179
+ /** ISO timestamp for when the manifest was last written. */
110
180
  readonly updatedAt: string;
111
181
  }
112
182
 
@@ -116,15 +186,25 @@ export declare interface FormSpecAnalysisManifest {
116
186
  * @public
117
187
  */
118
188
  export declare interface FormSpecAnalysisTagSnapshot {
189
+ /** Raw tag name as written in the source comment. */
119
190
  readonly rawTagName: string;
191
+ /** Canonicalized tag name used for registry lookup. */
120
192
  readonly normalizedTagName: string;
193
+ /** Whether the tag matched a known FormSpec tag definition. */
121
194
  readonly recognized: boolean;
195
+ /** Span covering the full tag payload on the source line. */
122
196
  readonly fullSpan: CommentSpan;
197
+ /** Span covering only the tag-name token. */
123
198
  readonly tagNameSpan: CommentSpan;
199
+ /** Span covering the payload after the tag name, if present. */
124
200
  readonly payloadSpan: CommentSpan | null;
201
+ /** Parsed target specifier, if the tag includes one. */
125
202
  readonly target: FormSpecSerializedCommentTargetSpecifier | null;
203
+ /** Span covering the argument token or payload segment, if present. */
126
204
  readonly argumentSpan: CommentSpan | null;
205
+ /** Raw argument text after any target specifier. */
127
206
  readonly argumentText: string;
207
+ /** Semantic context derived for the parsed tag. */
128
208
  readonly semantic: FormSpecSerializedTagSemanticContext;
129
209
  }
130
210
 
@@ -134,12 +214,18 @@ export declare interface FormSpecAnalysisTagSnapshot {
134
214
  *
135
215
  * @public
136
216
  */
137
- export declare interface FormSpecIpcEndpoint {
217
+ declare interface FormSpecIpcEndpoint {
218
+ /** Transport kind used to connect to the workspace semantic service. */
138
219
  readonly kind: "unix-socket" | "windows-pipe";
220
+ /** Absolute socket path or pipe name for the semantic service endpoint. */
139
221
  readonly address: string;
140
222
  }
141
223
 
142
- /** @public */
224
+ /**
225
+ * Declaration contexts where a FormSpec tag may appear.
226
+ *
227
+ * @public
228
+ */
143
229
  export declare type FormSpecPlacement = "class" | "class-field" | "class-method" | "interface" | "interface-field" | "type-alias" | "type-alias-field" | "variable" | "function" | "function-parameter" | "method-parameter";
144
230
 
145
231
  /**
@@ -157,6 +243,11 @@ export declare class FormSpecPluginService {
157
243
  private readonly semanticService;
158
244
  private server;
159
245
  constructor(options: FormSpecPluginServiceOptions);
246
+ /**
247
+ * Returns the manifest written by the plugin service for workspace discovery.
248
+ *
249
+ * @internal
250
+ */
160
251
  getManifest(): FormSpecAnalysisManifest;
161
252
  /**
162
253
  * Returns the underlying semantic service used by this reference wrapper.
@@ -164,9 +255,31 @@ export declare class FormSpecPluginService {
164
255
  * @public
165
256
  */
166
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
+ */
167
265
  start(): Promise<void>;
266
+ /**
267
+ * Stops the IPC transport, clears semantic state, and removes runtime artifacts.
268
+ *
269
+ * @public
270
+ */
168
271
  stop(): Promise<void>;
272
+ /**
273
+ * Schedules a background refresh for the cached semantic snapshot of a file.
274
+ *
275
+ * @public
276
+ */
169
277
  scheduleSnapshotRefresh(filePath: string): void;
278
+ /**
279
+ * Handles a semantic query issued against the plugin transport.
280
+ *
281
+ * @internal
282
+ */
170
283
  handleQuery(query: FormSpecSemanticQuery): FormSpecSemanticResponse;
171
284
  private executeQuery;
172
285
  private respondToSocket;
@@ -188,24 +301,45 @@ export declare class FormSpecPluginService {
188
301
  */
189
302
  export declare type FormSpecPluginServiceOptions = FormSpecSemanticServiceOptions;
190
303
 
191
- /** @public */
304
+ /**
305
+ * Serialized completion result returned by the semantic service.
306
+ *
307
+ * @public
308
+ */
192
309
  export declare interface FormSpecSemanticCompletionResult {
310
+ /** Protocol version used by the serialized response. */
193
311
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
312
+ /** Hash of the source file used to compute the response. */
194
313
  readonly sourceHash: string;
314
+ /** Serialized completion payload for the active cursor context. */
195
315
  readonly context: FormSpecSerializedCompletionContext;
196
316
  }
197
317
 
198
- /** @public */
318
+ /**
319
+ * Serialized diagnostics result returned by the semantic service.
320
+ *
321
+ * @public
322
+ */
199
323
  export declare interface FormSpecSemanticDiagnosticsResult {
324
+ /** Protocol version used by the serialized response. */
200
325
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
326
+ /** Hash of the source file used to compute the response. */
201
327
  readonly sourceHash: string;
328
+ /** Canonical FormSpec diagnostics for the requested file. */
202
329
  readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
203
330
  }
204
331
 
205
- /** @public */
332
+ /**
333
+ * Serialized hover result returned by the semantic service.
334
+ *
335
+ * @public
336
+ */
206
337
  export declare interface FormSpecSemanticHoverResult {
338
+ /** Protocol version used by the serialized response. */
207
339
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
340
+ /** Hash of the source file used to compute the response. */
208
341
  readonly sourceHash: string;
342
+ /** Serialized hover payload, or `null` when nothing is available at the cursor. */
209
343
  readonly hover: FormSpecSerializedHoverInfo | null;
210
344
  }
211
345
 
@@ -214,7 +348,7 @@ export declare interface FormSpecSemanticHoverResult {
214
348
  *
215
349
  * @public
216
350
  */
217
- export declare type FormSpecSemanticQuery = {
351
+ declare type FormSpecSemanticQuery = {
218
352
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
219
353
  readonly kind: "health";
220
354
  } | {
@@ -242,7 +376,7 @@ export declare type FormSpecSemanticQuery = {
242
376
  *
243
377
  * @public
244
378
  */
245
- export declare type FormSpecSemanticResponse = {
379
+ declare type FormSpecSemanticResponse = {
246
380
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
247
381
  readonly kind: "health";
248
382
  readonly manifest: FormSpecAnalysisManifest;
@@ -311,7 +445,11 @@ export declare class FormSpecSemanticService {
311
445
  private logPerformanceEvents;
312
446
  }
313
447
 
314
- /** @public */
448
+ /**
449
+ * Configuration for the reusable in-process semantic service.
450
+ *
451
+ * @public
452
+ */
315
453
  export declare interface FormSpecSemanticServiceOptions {
316
454
  /** Workspace root used for runtime paths and contextual logging. */
317
455
  readonly workspaceRoot: string;
@@ -331,7 +469,11 @@ export declare interface FormSpecSemanticServiceOptions {
331
469
  readonly now?: () => Date;
332
470
  }
333
471
 
334
- /** @public */
472
+ /**
473
+ * Performance and cache counters exposed by the semantic service.
474
+ *
475
+ * @public
476
+ */
335
477
  export declare interface FormSpecSemanticServiceStats {
336
478
  /** Total number of calls by semantic query kind. */
337
479
  readonly queryTotals: {
@@ -371,11 +513,17 @@ export declare interface FormSpecSemanticServiceStats {
371
513
  * @public
372
514
  */
373
515
  export declare interface FormSpecSerializedCommentTargetSpecifier {
516
+ /** Raw target text without the leading colon. */
374
517
  readonly rawText: string;
518
+ /** Whether the serialized target parsed successfully. */
375
519
  readonly valid: boolean;
520
+ /** Target syntax kind inferred for the serialized specifier. */
376
521
  readonly kind: "path" | "member" | "variant" | "ambiguous";
522
+ /** Span covering the entire target, including the leading colon. */
377
523
  readonly fullSpan: CommentSpan;
524
+ /** Span covering only the colon token. */
378
525
  readonly colonSpan: CommentSpan;
526
+ /** Span covering only the target text. */
379
527
  readonly span: CommentSpan;
380
528
  }
381
529
 
@@ -406,7 +554,9 @@ export declare type FormSpecSerializedCompletionContext = {
406
554
  * @public
407
555
  */
408
556
  export declare interface FormSpecSerializedHoverInfo {
557
+ /** Comment token kind being described. */
409
558
  readonly kind: "tag-name" | "target" | "argument";
559
+ /** Markdown payload that should be rendered for the hover. */
410
560
  readonly markdown: string;
411
561
  }
412
562
 
@@ -416,8 +566,11 @@ export declare interface FormSpecSerializedHoverInfo {
416
566
  * @public
417
567
  */
418
568
  export declare interface FormSpecSerializedTagDefinition {
569
+ /** Canonical tag name, including the `@` prefix. */
419
570
  readonly canonicalName: string;
571
+ /** Short completion label shown in completion menus. */
420
572
  readonly completionDetail: string;
573
+ /** Markdown hover content describing the tag. */
421
574
  readonly hoverMarkdown: string;
422
575
  }
423
576
 
@@ -427,16 +580,27 @@ export declare interface FormSpecSerializedTagDefinition {
427
580
  * @public
428
581
  */
429
582
  export declare interface FormSpecSerializedTagSemanticContext {
583
+ /** Canonical tag name, including the `@` prefix. */
430
584
  readonly tagName: string;
585
+ /** Tag metadata when the tag is recognized by the registry. */
431
586
  readonly tagDefinition: FormSpecSerializedTagDefinition | null;
587
+ /** Declaration placement the tag was evaluated in, if known. */
432
588
  readonly placement: FormSpecPlacement | null;
589
+ /** Target syntaxes supported by the matching signatures. */
433
590
  readonly supportedTargets: readonly FormSpecTargetKind[];
591
+ /** Suggested targets for completion UIs. */
434
592
  readonly targetCompletions: readonly string[];
593
+ /** Compatible path targets computed from the subject type, if available. */
435
594
  readonly compatiblePathTargets: readonly string[];
595
+ /** Suggested value labels derived from the matching signatures. */
436
596
  readonly valueLabels: readonly string[];
597
+ /** Signature summaries for the recognized tag in the current placement. */
437
598
  readonly signatures: readonly FormSpecSerializedTagSignature[];
599
+ /** Markdown hover for the tag name token. */
438
600
  readonly tagHoverMarkdown: string | null;
601
+ /** Markdown hover for the target token, when available. */
439
602
  readonly targetHoverMarkdown: string | null;
603
+ /** Markdown hover for the argument token, when available. */
440
604
  readonly argumentHoverMarkdown: string | null;
441
605
  }
442
606
 
@@ -446,11 +610,17 @@ export declare interface FormSpecSerializedTagSemanticContext {
446
610
  * @public
447
611
  */
448
612
  export declare interface FormSpecSerializedTagSignature {
613
+ /** Human-readable rendering of one supported tag signature. */
449
614
  readonly label: string;
615
+ /** Declaration placements where this signature is valid. */
450
616
  readonly placements: readonly FormSpecPlacement[];
451
617
  }
452
618
 
453
- /** @public */
619
+ /**
620
+ * Target syntaxes that a FormSpec tag can accept.
621
+ *
622
+ * @public
623
+ */
454
624
  export declare type FormSpecTargetKind = "none" | "path" | "member" | "variant";
455
625
 
456
626
  /**
@@ -462,8 +632,13 @@ export declare function init(modules: {
462
632
  readonly typescript: typeof tsServer;
463
633
  }): tsServer.server.PluginModule;
464
634
 
465
- /** @public */
635
+ /**
636
+ * Minimal logging surface used by the semantic service and plugin wrapper.
637
+ *
638
+ * @public
639
+ */
466
640
  export declare interface LoggerLike {
641
+ /** Writes a human-readable diagnostic or profiling message. */
467
642
  info(message: string): void;
468
643
  }
469
644