@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,17 +243,34 @@ export declare class FormSpecPluginService {
157
243
  private readonly semanticService;
158
244
  private server;
159
245
  constructor(options: FormSpecPluginServiceOptions);
160
- getManifest(): FormSpecAnalysisManifest;
246
+ /* Excluded from this release type: getManifest */
161
247
  /**
162
248
  * Returns the underlying semantic service used by this reference wrapper.
163
249
  *
164
250
  * @public
165
251
  */
166
252
  getSemanticService(): FormSpecSemanticService;
253
+ /**
254
+ * Starts the IPC transport and writes the current workspace manifest.
255
+ *
256
+ * Calling this more than once is a no-op.
257
+ *
258
+ * @public
259
+ */
167
260
  start(): Promise<void>;
261
+ /**
262
+ * Stops the IPC transport, clears semantic state, and removes runtime artifacts.
263
+ *
264
+ * @public
265
+ */
168
266
  stop(): Promise<void>;
267
+ /**
268
+ * Schedules a background refresh for the cached semantic snapshot of a file.
269
+ *
270
+ * @public
271
+ */
169
272
  scheduleSnapshotRefresh(filePath: string): void;
170
- handleQuery(query: FormSpecSemanticQuery): FormSpecSemanticResponse;
273
+ /* Excluded from this release type: handleQuery */
171
274
  private executeQuery;
172
275
  private respondToSocket;
173
276
  private writeManifest;
@@ -188,24 +291,45 @@ export declare class FormSpecPluginService {
188
291
  */
189
292
  export declare type FormSpecPluginServiceOptions = FormSpecSemanticServiceOptions;
190
293
 
191
- /** @public */
294
+ /**
295
+ * Serialized completion result returned by the semantic service.
296
+ *
297
+ * @public
298
+ */
192
299
  export declare interface FormSpecSemanticCompletionResult {
300
+ /** Protocol version used by the serialized response. */
193
301
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
302
+ /** Hash of the source file used to compute the response. */
194
303
  readonly sourceHash: string;
304
+ /** Serialized completion payload for the active cursor context. */
195
305
  readonly context: FormSpecSerializedCompletionContext;
196
306
  }
197
307
 
198
- /** @public */
308
+ /**
309
+ * Serialized diagnostics result returned by the semantic service.
310
+ *
311
+ * @public
312
+ */
199
313
  export declare interface FormSpecSemanticDiagnosticsResult {
314
+ /** Protocol version used by the serialized response. */
200
315
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
316
+ /** Hash of the source file used to compute the response. */
201
317
  readonly sourceHash: string;
318
+ /** Canonical FormSpec diagnostics for the requested file. */
202
319
  readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
203
320
  }
204
321
 
205
- /** @public */
322
+ /**
323
+ * Serialized hover result returned by the semantic service.
324
+ *
325
+ * @public
326
+ */
206
327
  export declare interface FormSpecSemanticHoverResult {
328
+ /** Protocol version used by the serialized response. */
207
329
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
330
+ /** Hash of the source file used to compute the response. */
208
331
  readonly sourceHash: string;
332
+ /** Serialized hover payload, or `null` when nothing is available at the cursor. */
209
333
  readonly hover: FormSpecSerializedHoverInfo | null;
210
334
  }
211
335
 
@@ -214,7 +338,7 @@ export declare interface FormSpecSemanticHoverResult {
214
338
  *
215
339
  * @public
216
340
  */
217
- export declare type FormSpecSemanticQuery = {
341
+ declare type FormSpecSemanticQuery = {
218
342
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
219
343
  readonly kind: "health";
220
344
  } | {
@@ -242,7 +366,7 @@ export declare type FormSpecSemanticQuery = {
242
366
  *
243
367
  * @public
244
368
  */
245
- export declare type FormSpecSemanticResponse = {
369
+ declare type FormSpecSemanticResponse = {
246
370
  readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
247
371
  readonly kind: "health";
248
372
  readonly manifest: FormSpecAnalysisManifest;
@@ -311,7 +435,11 @@ export declare class FormSpecSemanticService {
311
435
  private logPerformanceEvents;
312
436
  }
313
437
 
314
- /** @public */
438
+ /**
439
+ * Configuration for the reusable in-process semantic service.
440
+ *
441
+ * @public
442
+ */
315
443
  export declare interface FormSpecSemanticServiceOptions {
316
444
  /** Workspace root used for runtime paths and contextual logging. */
317
445
  readonly workspaceRoot: string;
@@ -331,7 +459,11 @@ export declare interface FormSpecSemanticServiceOptions {
331
459
  readonly now?: () => Date;
332
460
  }
333
461
 
334
- /** @public */
462
+ /**
463
+ * Performance and cache counters exposed by the semantic service.
464
+ *
465
+ * @public
466
+ */
335
467
  export declare interface FormSpecSemanticServiceStats {
336
468
  /** Total number of calls by semantic query kind. */
337
469
  readonly queryTotals: {
@@ -371,11 +503,17 @@ export declare interface FormSpecSemanticServiceStats {
371
503
  * @public
372
504
  */
373
505
  export declare interface FormSpecSerializedCommentTargetSpecifier {
506
+ /** Raw target text without the leading colon. */
374
507
  readonly rawText: string;
508
+ /** Whether the serialized target parsed successfully. */
375
509
  readonly valid: boolean;
510
+ /** Target syntax kind inferred for the serialized specifier. */
376
511
  readonly kind: "path" | "member" | "variant" | "ambiguous";
512
+ /** Span covering the entire target, including the leading colon. */
377
513
  readonly fullSpan: CommentSpan;
514
+ /** Span covering only the colon token. */
378
515
  readonly colonSpan: CommentSpan;
516
+ /** Span covering only the target text. */
379
517
  readonly span: CommentSpan;
380
518
  }
381
519
 
@@ -406,7 +544,9 @@ export declare type FormSpecSerializedCompletionContext = {
406
544
  * @public
407
545
  */
408
546
  export declare interface FormSpecSerializedHoverInfo {
547
+ /** Comment token kind being described. */
409
548
  readonly kind: "tag-name" | "target" | "argument";
549
+ /** Markdown payload that should be rendered for the hover. */
410
550
  readonly markdown: string;
411
551
  }
412
552
 
@@ -416,8 +556,11 @@ export declare interface FormSpecSerializedHoverInfo {
416
556
  * @public
417
557
  */
418
558
  export declare interface FormSpecSerializedTagDefinition {
559
+ /** Canonical tag name, including the `@` prefix. */
419
560
  readonly canonicalName: string;
561
+ /** Short completion label shown in completion menus. */
420
562
  readonly completionDetail: string;
563
+ /** Markdown hover content describing the tag. */
421
564
  readonly hoverMarkdown: string;
422
565
  }
423
566
 
@@ -427,16 +570,27 @@ export declare interface FormSpecSerializedTagDefinition {
427
570
  * @public
428
571
  */
429
572
  export declare interface FormSpecSerializedTagSemanticContext {
573
+ /** Canonical tag name, including the `@` prefix. */
430
574
  readonly tagName: string;
575
+ /** Tag metadata when the tag is recognized by the registry. */
431
576
  readonly tagDefinition: FormSpecSerializedTagDefinition | null;
577
+ /** Declaration placement the tag was evaluated in, if known. */
432
578
  readonly placement: FormSpecPlacement | null;
579
+ /** Target syntaxes supported by the matching signatures. */
433
580
  readonly supportedTargets: readonly FormSpecTargetKind[];
581
+ /** Suggested targets for completion UIs. */
434
582
  readonly targetCompletions: readonly string[];
583
+ /** Compatible path targets computed from the subject type, if available. */
435
584
  readonly compatiblePathTargets: readonly string[];
585
+ /** Suggested value labels derived from the matching signatures. */
436
586
  readonly valueLabels: readonly string[];
587
+ /** Signature summaries for the recognized tag in the current placement. */
437
588
  readonly signatures: readonly FormSpecSerializedTagSignature[];
589
+ /** Markdown hover for the tag name token. */
438
590
  readonly tagHoverMarkdown: string | null;
591
+ /** Markdown hover for the target token, when available. */
439
592
  readonly targetHoverMarkdown: string | null;
593
+ /** Markdown hover for the argument token, when available. */
440
594
  readonly argumentHoverMarkdown: string | null;
441
595
  }
442
596
 
@@ -446,11 +600,17 @@ export declare interface FormSpecSerializedTagSemanticContext {
446
600
  * @public
447
601
  */
448
602
  export declare interface FormSpecSerializedTagSignature {
603
+ /** Human-readable rendering of one supported tag signature. */
449
604
  readonly label: string;
605
+ /** Declaration placements where this signature is valid. */
450
606
  readonly placements: readonly FormSpecPlacement[];
451
607
  }
452
608
 
453
- /** @public */
609
+ /**
610
+ * Target syntaxes that a FormSpec tag can accept.
611
+ *
612
+ * @public
613
+ */
454
614
  export declare type FormSpecTargetKind = "none" | "path" | "member" | "variant";
455
615
 
456
616
  /**
@@ -462,8 +622,13 @@ export declare function init(modules: {
462
622
  readonly typescript: typeof tsServer;
463
623
  }): tsServer.server.PluginModule;
464
624
 
465
- /** @public */
625
+ /**
626
+ * Minimal logging surface used by the semantic service and plugin wrapper.
627
+ *
628
+ * @public
629
+ */
466
630
  export declare interface LoggerLike {
631
+ /** Writes a human-readable diagnostic or profiling message. */
467
632
  info(message: string): void;
468
633
  }
469
634
 
@@ -1,4 +1,4 @@
1
- import { type FormSpecAnalysisManifest, type FormSpecIpcEndpoint } from "@formspec/analysis/protocol";
1
+ import { type FormSpecAnalysisManifest, type FormSpecIpcEndpoint } from "@formspec/analysis/internal";
2
2
  export interface FormSpecWorkspaceRuntimePaths {
3
3
  readonly workspaceRoot: string;
4
4
  readonly workspaceId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAC;AAOrC,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACxC;AAED,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,QAAQ,kBAAmB,EAC3B,SAAS,SAAyB,GACjC,6BAA6B,CAsB/B;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAE,MAAM,EAClB,oBAAoB,SAAY,GAC/B,wBAAwB,CAa1B"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACxC;AAED,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,QAAQ,kBAAmB,EAC3B,SAAS,SAAyB,GACjC,6BAA6B,CAsB/B;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAE,MAAM,EAClB,oBAAoB,SAAY,GAC/B,wBAAwB,CAa1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formspec/ts-plugin",
3
- "version": "0.1.0-alpha.23",
3
+ "version": "0.1.0-alpha.26",
4
4
  "description": "TypeScript language service plugin for FormSpec semantic comment analysis",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
@@ -19,7 +19,7 @@
19
19
  "README.md"
20
20
  ],
21
21
  "dependencies": {
22
- "@formspec/analysis": "0.1.0-alpha.23"
22
+ "@formspec/analysis": "0.1.0-alpha.26"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "typescript": "^5.0.0"