@formspec/analysis 0.1.0-alpha.20

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.
Files changed (53) hide show
  1. package/README.md +14 -0
  2. package/dist/__tests__/comment-syntax.test.d.ts +2 -0
  3. package/dist/__tests__/comment-syntax.test.d.ts.map +1 -0
  4. package/dist/__tests__/compiler-signatures.test.d.ts +2 -0
  5. package/dist/__tests__/compiler-signatures.test.d.ts.map +1 -0
  6. package/dist/__tests__/cursor-context.test.d.ts +2 -0
  7. package/dist/__tests__/cursor-context.test.d.ts.map +1 -0
  8. package/dist/__tests__/file-snapshots.test.d.ts +2 -0
  9. package/dist/__tests__/file-snapshots.test.d.ts.map +1 -0
  10. package/dist/__tests__/helpers.d.ts +7 -0
  11. package/dist/__tests__/helpers.d.ts.map +1 -0
  12. package/dist/__tests__/semantic-protocol.test.d.ts +2 -0
  13. package/dist/__tests__/semantic-protocol.test.d.ts.map +1 -0
  14. package/dist/__tests__/semantic-targets.test.d.ts +2 -0
  15. package/dist/__tests__/semantic-targets.test.d.ts.map +1 -0
  16. package/dist/__tests__/tag-registry.test.d.ts +2 -0
  17. package/dist/__tests__/tag-registry.test.d.ts.map +1 -0
  18. package/dist/__tests__/tag-value-parser.test.d.ts +2 -0
  19. package/dist/__tests__/tag-value-parser.test.d.ts.map +1 -0
  20. package/dist/__tests__/ts-binding.test.d.ts +2 -0
  21. package/dist/__tests__/ts-binding.test.d.ts.map +1 -0
  22. package/dist/analysis.d.ts +812 -0
  23. package/dist/comment-syntax.d.ts +43 -0
  24. package/dist/comment-syntax.d.ts.map +1 -0
  25. package/dist/compiler-signatures.d.ts +100 -0
  26. package/dist/compiler-signatures.d.ts.map +1 -0
  27. package/dist/cursor-context.d.ts +89 -0
  28. package/dist/cursor-context.d.ts.map +1 -0
  29. package/dist/file-snapshots.d.ts +18 -0
  30. package/dist/file-snapshots.d.ts.map +1 -0
  31. package/dist/index.cjs +3582 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.ts +20 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +3497 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/path-target.d.ts +11 -0
  38. package/dist/path-target.d.ts.map +1 -0
  39. package/dist/semantic-protocol.d.ts +234 -0
  40. package/dist/semantic-protocol.d.ts.map +1 -0
  41. package/dist/semantic-targets.d.ts +86 -0
  42. package/dist/semantic-targets.d.ts.map +1 -0
  43. package/dist/source-bindings.d.ts +21 -0
  44. package/dist/source-bindings.d.ts.map +1 -0
  45. package/dist/tag-registry.d.ts +46 -0
  46. package/dist/tag-registry.d.ts.map +1 -0
  47. package/dist/tag-value-parser.d.ts +20 -0
  48. package/dist/tag-value-parser.d.ts.map +1 -0
  49. package/dist/ts-binding.d.ts +28 -0
  50. package/dist/ts-binding.d.ts.map +1 -0
  51. package/dist/workspace-runtime.d.ts +15 -0
  52. package/dist/workspace-runtime.d.ts.map +1 -0
  53. package/package.json +42 -0
@@ -0,0 +1,812 @@
1
+ import { AnnotationNode } from '@formspec/core';
2
+ import { BuiltinConstraintBroadeningRegistration } from '@formspec/core';
3
+ import { ConstraintNode } from '@formspec/core';
4
+ import { ConstraintTagRegistration } from '@formspec/core';
5
+ import { CustomConstraintRegistration } from '@formspec/core';
6
+ import { ExtensionDefinition } from '@formspec/core';
7
+ import type { JsonValue } from '@formspec/core';
8
+ import type { PathTarget } from '@formspec/core';
9
+ import { Provenance } from '@formspec/core';
10
+ import * as ts from 'typescript';
11
+ import { TypeNode } from '@formspec/core';
12
+
13
+ export declare interface AnalysisTypeDefinition {
14
+ readonly name: string;
15
+ readonly type: TypeNode;
16
+ readonly constraints?: readonly ConstraintNode[];
17
+ readonly annotations?: readonly AnnotationNode[];
18
+ readonly provenance: Provenance;
19
+ }
20
+
21
+ export declare type AnalysisTypeRegistry = Record<string, AnalysisTypeDefinition>;
22
+
23
+ /**
24
+ * Resolves targeted constraints against a field type, producing effective
25
+ * target states plus semantic diagnostics such as contradictions, unknown
26
+ * paths, and type mismatches.
27
+ */
28
+ export declare function analyzeConstraintTargets(fieldName: string, fieldType: TypeNode, constraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry, options?: {
29
+ readonly extensionRegistry?: ConstraintRegistryLike;
30
+ }): ConstraintTargetAnalysisResult;
31
+
32
+ export declare function buildConstraintTargetStates(fieldName: string, fieldType: TypeNode, constraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry): readonly ResolvedTargetState[];
33
+
34
+ /**
35
+ * Builds a transport-safe snapshot of every FormSpec-bearing doc comment in a
36
+ * source file, including semantic hover/completion context and file-local
37
+ * diagnostics.
38
+ */
39
+ export declare function buildFormSpecAnalysisFileSnapshot(sourceFile: ts.SourceFile, options: BuildFormSpecAnalysisFileSnapshotOptions): FormSpecAnalysisFileSnapshot;
40
+
41
+ /**
42
+ * Options used when building a serializable, editor-oriented snapshot for a
43
+ * TypeScript source file.
44
+ */
45
+ export declare interface BuildFormSpecAnalysisFileSnapshotOptions {
46
+ readonly checker: ts.TypeChecker;
47
+ readonly extensions?: readonly ExtensionTagSource[];
48
+ }
49
+
50
+ /**
51
+ * Builds the synthetic helper declarations used to validate FormSpec tag
52
+ * applications through the TypeScript checker.
53
+ *
54
+ * The returned string is a virtual `.d.ts`-style prelude that declares the
55
+ * `__formspec.*` helper namespace together with context, path, member, and
56
+ * variant helper types. It is intended to be embedded into an in-memory
57
+ * TypeScript program, never emitted to disk.
58
+ */
59
+ export declare function buildSyntheticHelperPrelude(extensions?: readonly ExtensionTagSource[]): string;
60
+
61
+ /**
62
+ * Runs the TypeScript checker against a lowered synthetic tag application.
63
+ *
64
+ * This is the compiler-backed validation entrypoint used by FormSpec analysis
65
+ * to verify placement, target binding, and argument compatibility without
66
+ * requiring comment tags themselves to be valid TypeScript syntax.
67
+ */
68
+ export declare function checkSyntheticTagApplication(options: CheckSyntheticTagApplicationOptions): SyntheticTagCheckResult;
69
+
70
+ /**
71
+ * Options for running the TypeScript checker against a synthetic tag call.
72
+ */
73
+ export declare interface CheckSyntheticTagApplicationOptions extends LowerSyntheticTagApplicationOptions {
74
+ readonly supportingDeclarations?: readonly string[];
75
+ }
76
+
77
+ export declare function collectCompatiblePathTargets(type: ts.Type, checker: ts.TypeChecker, capability: SemanticCapability): readonly string[];
78
+
79
+ export declare function collectReferencedTypeAnnotations(type: TypeNode, typeRegistry: AnalysisTypeRegistry): readonly AnnotationNode[];
80
+
81
+ export declare function collectReferencedTypeConstraints(type: TypeNode, typeRegistry: AnalysisTypeRegistry): readonly ConstraintNode[];
82
+
83
+ export declare type CommentCompletionContext = {
84
+ readonly kind: "tag-name";
85
+ readonly prefix: string;
86
+ } | {
87
+ readonly kind: "target";
88
+ readonly tag: ParsedCommentTag;
89
+ } | {
90
+ readonly kind: "argument";
91
+ readonly tag: ParsedCommentTag;
92
+ } | {
93
+ readonly kind: "none";
94
+ };
95
+
96
+ export declare interface CommentCursorTarget {
97
+ readonly kind: "tag-name" | "colon" | "target" | "argument";
98
+ readonly tag: ParsedCommentTag;
99
+ }
100
+
101
+ export declare interface CommentHoverInfo {
102
+ readonly kind: "tag-name" | "target" | "argument";
103
+ readonly markdown: string;
104
+ }
105
+
106
+ export declare interface CommentSemanticContextOptions {
107
+ readonly extensions?: readonly ExtensionTagSource[];
108
+ readonly placement?: FormSpecPlacement | null;
109
+ readonly checker?: ts.TypeChecker;
110
+ readonly subjectType?: ts.Type;
111
+ }
112
+
113
+ export declare interface CommentSourceSpan {
114
+ readonly start: number;
115
+ readonly end: number;
116
+ }
117
+
118
+ export declare type CommentSpan = CommentSourceSpan;
119
+
120
+ export declare interface CommentTagSemanticContext {
121
+ readonly tag: ParsedCommentTag;
122
+ readonly tagDefinition: TagDefinition | null;
123
+ readonly placement: FormSpecPlacement | null;
124
+ readonly signatures: readonly TagSignature[];
125
+ readonly supportedTargets: readonly FormSpecTargetKind[];
126
+ readonly targetCompletions: readonly string[];
127
+ readonly compatiblePathTargets: readonly string[];
128
+ readonly valueLabels: readonly string[];
129
+ readonly tagHoverMarkdown: string | null;
130
+ readonly targetHoverMarkdown: string | null;
131
+ readonly argumentHoverMarkdown: string | null;
132
+ }
133
+
134
+ /**
135
+ * Computes a stable, non-cryptographic hash for document staleness checks
136
+ * across the plugin/LSP boundary.
137
+ */
138
+ export declare function computeFormSpecTextHash(text: string): string;
139
+
140
+ export declare interface ConstraintRegistrationLike {
141
+ readonly constraintName: string;
142
+ readonly applicableTypes: readonly TypeNode["kind"][] | null;
143
+ readonly isApplicableToType?: (type: TypeNode) => boolean;
144
+ readonly comparePayloads?: (left: JsonValue, right: JsonValue) => number;
145
+ readonly semanticRole?: ConstraintSemanticRoleLike;
146
+ }
147
+
148
+ export declare interface ConstraintRegistryLike {
149
+ findConstraint(constraintId: string): ConstraintRegistrationLike | undefined;
150
+ findConstraintTag(tagName: string): {
151
+ readonly extensionId: string;
152
+ readonly registration: ConstraintTagRegistrationLike;
153
+ } | undefined;
154
+ }
155
+
156
+ export declare interface ConstraintSemanticDiagnostic {
157
+ readonly code: string;
158
+ readonly message: string;
159
+ readonly severity: "error" | "warning";
160
+ readonly primaryLocation: Provenance;
161
+ readonly relatedLocations: readonly Provenance[];
162
+ }
163
+
164
+ export declare interface ConstraintSemanticRoleLike {
165
+ readonly family: string;
166
+ readonly bound: "lower" | "upper" | "exact";
167
+ readonly inclusive: boolean;
168
+ }
169
+
170
+ export declare interface ConstraintTagParseRegistryLike {
171
+ readonly extensions: readonly ExtensionDefinition[];
172
+ findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
173
+ findConstraintTag(tagName: string): {
174
+ readonly extensionId: string;
175
+ readonly registration: ConstraintTagRegistration;
176
+ } | undefined;
177
+ findBuiltinConstraintBroadening(typeId: string, tagName: string): {
178
+ readonly extensionId: string;
179
+ readonly registration: BuiltinConstraintBroadeningRegistration;
180
+ } | undefined;
181
+ }
182
+
183
+ export declare interface ConstraintTagRegistrationLike {
184
+ readonly tagName: string;
185
+ readonly constraintName: string;
186
+ readonly isApplicableToType?: (type: TypeNode) => boolean;
187
+ }
188
+
189
+ export declare interface ConstraintTargetAnalysisResult {
190
+ readonly diagnostics: readonly ConstraintSemanticDiagnostic[];
191
+ readonly targetStates: readonly ResolvedTargetState[];
192
+ }
193
+
194
+ export declare function dereferenceAnalysisType(type: TypeNode, typeRegistry: AnalysisTypeRegistry): TypeNode;
195
+
196
+ export declare interface EffectiveTargetState {
197
+ readonly fieldName: string;
198
+ readonly path: PathTarget | null;
199
+ readonly targetName: string;
200
+ readonly type: TypeNode;
201
+ readonly inheritedConstraints: readonly ConstraintNode[];
202
+ readonly inheritedAnnotations: readonly AnnotationNode[];
203
+ readonly localConstraints: readonly ConstraintNode[];
204
+ readonly effectiveConstraints: readonly ConstraintNode[];
205
+ }
206
+
207
+ export declare interface EnclosingDocComment {
208
+ readonly text: string;
209
+ readonly start: number;
210
+ readonly end: number;
211
+ readonly parsed: ParsedCommentBlock;
212
+ }
213
+
214
+ export declare interface ExtensionConstraintTagSource {
215
+ readonly tagName: string;
216
+ }
217
+
218
+ export declare interface ExtensionTagSource {
219
+ readonly extensionId: string;
220
+ readonly constraintTags?: readonly ExtensionConstraintTagSource[];
221
+ }
222
+
223
+ /**
224
+ * Extract a `:foo.bar` path target prefix from raw tag text.
225
+ */
226
+ export declare function extractPathTarget(text: string): ParsedPathTarget | null;
227
+
228
+ export declare function findCommentTagAtOffset(documentText: string, offset: number, options?: {
229
+ readonly extensions?: readonly ExtensionTagSource[];
230
+ }): ParsedCommentTag | null;
231
+
232
+ /**
233
+ * Finds the smallest declaration whose leading doc comment contains the given
234
+ * source offset.
235
+ */
236
+ export declare function findDeclarationForCommentOffset(sourceFile: ts.SourceFile, offset: number): ts.Node | null;
237
+
238
+ export declare function findEnclosingDocComment(documentText: string, offset: number, options?: {
239
+ readonly extensions?: readonly ExtensionTagSource[];
240
+ }): EnclosingDocComment | null;
241
+
242
+ export declare function formatConstraintTargetName(fieldName: string, path: PathTarget | null): string;
243
+
244
+ export declare function formatPathTarget(path: PathTarget | readonly string[]): string;
245
+
246
+ export declare const FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 1;
247
+
248
+ export declare const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
249
+
250
+ /**
251
+ * Serializable view of one declaration-attached doc comment in a source file.
252
+ */
253
+ export declare interface FormSpecAnalysisCommentSnapshot {
254
+ readonly commentSpan: CommentSpan;
255
+ readonly declarationSpan: CommentSpan;
256
+ readonly placement: FormSpecPlacement | null;
257
+ readonly subjectType: string | null;
258
+ readonly hostType: string | null;
259
+ readonly tags: readonly FormSpecAnalysisTagSnapshot[];
260
+ }
261
+
262
+ /**
263
+ * File-local diagnostic derived from comment parsing or semantic analysis.
264
+ */
265
+ export declare interface FormSpecAnalysisDiagnostic {
266
+ readonly code: string;
267
+ readonly message: string;
268
+ readonly range: CommentSpan;
269
+ readonly severity: "error" | "warning" | "info";
270
+ }
271
+
272
+ /**
273
+ * Serializable analysis artifact for a single source file.
274
+ */
275
+ export declare interface FormSpecAnalysisFileSnapshot {
276
+ readonly filePath: string;
277
+ readonly sourceHash: string;
278
+ readonly generatedAt: string;
279
+ readonly comments: readonly FormSpecAnalysisCommentSnapshot[];
280
+ readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
281
+ }
282
+
283
+ /**
284
+ * Discovery record written by the tsserver plugin so other FormSpec tooling
285
+ * can locate and validate the matching semantic service for a workspace.
286
+ */
287
+ export declare interface FormSpecAnalysisManifest {
288
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
289
+ readonly analysisSchemaVersion: typeof FORMSPEC_ANALYSIS_SCHEMA_VERSION;
290
+ readonly workspaceRoot: string;
291
+ readonly workspaceId: string;
292
+ readonly endpoint: FormSpecIpcEndpoint;
293
+ readonly typescriptVersion: string;
294
+ readonly extensionFingerprint: string;
295
+ readonly generation: number;
296
+ readonly updatedAt: string;
297
+ }
298
+
299
+ /**
300
+ * Serializable view of a single parsed FormSpec tag within a doc comment.
301
+ */
302
+ export declare interface FormSpecAnalysisTagSnapshot {
303
+ readonly rawTagName: string;
304
+ readonly normalizedTagName: string;
305
+ readonly recognized: boolean;
306
+ readonly fullSpan: CommentSpan;
307
+ readonly tagNameSpan: CommentSpan;
308
+ readonly payloadSpan: CommentSpan | null;
309
+ readonly target: FormSpecSerializedCommentTargetSpecifier | null;
310
+ readonly argumentSpan: CommentSpan | null;
311
+ readonly argumentText: string;
312
+ readonly semantic: FormSpecSerializedTagSemanticContext;
313
+ }
314
+
315
+ /**
316
+ * Cross-process endpoint used by the language server to reach the semantic
317
+ * tsserver plugin on the current workspace host.
318
+ */
319
+ export declare interface FormSpecIpcEndpoint {
320
+ readonly kind: "unix-socket" | "windows-pipe";
321
+ readonly address: string;
322
+ }
323
+
324
+ export declare type FormSpecPlacement = "class" | "class-field" | "class-method" | "interface" | "interface-field" | "type-alias" | "type-alias-field" | "variable" | "function" | "function-parameter" | "method-parameter";
325
+
326
+ export declare type FormSpecSemanticCapability = SemanticCapability;
327
+
328
+ /**
329
+ * Query variants supported by the semantic tsserver plugin.
330
+ */
331
+ export declare type FormSpecSemanticQuery = {
332
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
333
+ readonly kind: "health";
334
+ } | {
335
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
336
+ readonly kind: "completion";
337
+ readonly filePath: string;
338
+ readonly offset: number;
339
+ } | {
340
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
341
+ readonly kind: "hover";
342
+ readonly filePath: string;
343
+ readonly offset: number;
344
+ } | {
345
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
346
+ readonly kind: "diagnostics";
347
+ readonly filePath: string;
348
+ } | {
349
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
350
+ readonly kind: "file-snapshot";
351
+ readonly filePath: string;
352
+ };
353
+
354
+ /**
355
+ * Response variants returned by the semantic tsserver plugin.
356
+ */
357
+ export declare type FormSpecSemanticResponse = {
358
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
359
+ readonly kind: "health";
360
+ readonly manifest: FormSpecAnalysisManifest;
361
+ } | {
362
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
363
+ readonly kind: "completion";
364
+ readonly sourceHash: string;
365
+ readonly context: FormSpecSerializedCompletionContext;
366
+ } | {
367
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
368
+ readonly kind: "hover";
369
+ readonly sourceHash: string;
370
+ readonly hover: FormSpecSerializedHoverInfo | null;
371
+ } | {
372
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
373
+ readonly kind: "diagnostics";
374
+ readonly sourceHash: string;
375
+ readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
376
+ } | {
377
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
378
+ readonly kind: "file-snapshot";
379
+ readonly snapshot: FormSpecAnalysisFileSnapshot | null;
380
+ } | {
381
+ readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
382
+ readonly kind: "error";
383
+ readonly error: string;
384
+ };
385
+
386
+ /**
387
+ * Serialized representation of a parsed target specifier with exact spans.
388
+ */
389
+ export declare interface FormSpecSerializedCommentTargetSpecifier {
390
+ readonly rawText: string;
391
+ readonly valid: boolean;
392
+ readonly kind: ParsedCommentTargetSpecifier["kind"];
393
+ readonly fullSpan: CommentSpan;
394
+ readonly colonSpan: CommentSpan;
395
+ readonly span: CommentSpan;
396
+ }
397
+
398
+ /**
399
+ * Cursor-scoped completion context serialized for transport between the
400
+ * semantic tsserver plugin and the lightweight LSP.
401
+ */
402
+ export declare type FormSpecSerializedCompletionContext = {
403
+ readonly kind: "tag-name";
404
+ readonly prefix: string;
405
+ readonly availableTags: readonly FormSpecSerializedTagDefinition[];
406
+ } | {
407
+ readonly kind: "target";
408
+ readonly semantic: FormSpecSerializedTagSemanticContext;
409
+ } | {
410
+ readonly kind: "argument";
411
+ readonly semantic: FormSpecSerializedTagSemanticContext;
412
+ readonly valueLabels: readonly string[];
413
+ } | {
414
+ readonly kind: "none";
415
+ };
416
+
417
+ /**
418
+ * Hover payload for a single comment token under the cursor.
419
+ */
420
+ export declare interface FormSpecSerializedHoverInfo {
421
+ readonly kind: CommentHoverInfo["kind"];
422
+ readonly markdown: string;
423
+ }
424
+
425
+ /**
426
+ * Serializable subset of tag metadata needed by hover and completion UIs.
427
+ */
428
+ export declare interface FormSpecSerializedTagDefinition {
429
+ readonly canonicalName: string;
430
+ readonly completionDetail: string;
431
+ readonly hoverMarkdown: string;
432
+ }
433
+
434
+ /**
435
+ * Semantic facts about one parsed tag, reduced to JSON-safe data for IPC.
436
+ */
437
+ export declare interface FormSpecSerializedTagSemanticContext {
438
+ readonly tagName: string;
439
+ readonly tagDefinition: FormSpecSerializedTagDefinition | null;
440
+ readonly placement: FormSpecPlacement | null;
441
+ readonly supportedTargets: readonly FormSpecTargetKind[];
442
+ readonly targetCompletions: readonly string[];
443
+ readonly compatiblePathTargets: readonly string[];
444
+ readonly valueLabels: readonly string[];
445
+ readonly signatures: readonly FormSpecSerializedTagSignature[];
446
+ readonly tagHoverMarkdown: string | null;
447
+ readonly targetHoverMarkdown: string | null;
448
+ readonly argumentHoverMarkdown: string | null;
449
+ }
450
+
451
+ /**
452
+ * Serializable overload/signature summary for one comment tag form.
453
+ */
454
+ export declare interface FormSpecSerializedTagSignature {
455
+ readonly label: string;
456
+ readonly placements: readonly FormSpecPlacement[];
457
+ }
458
+
459
+ export declare type FormSpecTagCategory = "constraint" | "annotation" | "structure" | "ecosystem";
460
+
461
+ export declare type FormSpecTagDefinition = TagDefinition;
462
+
463
+ export declare type FormSpecTagOverload = TagSignature;
464
+
465
+ export declare type FormSpecTagParameter = TagSignatureParameter;
466
+
467
+ export declare type FormSpecTargetKind = "none" | "path" | "member" | "variant";
468
+
469
+ export declare type FormSpecValueKind = "number" | "integer" | "signedInteger" | "string" | "json" | "boolean" | "condition";
470
+
471
+ export declare function getAllTagDefinitions(extensions?: readonly ExtensionTagSource[]): readonly TagDefinition[];
472
+
473
+ export declare function getCommentCompletionContextAtOffset(documentText: string, offset: number, options?: {
474
+ readonly extensions?: readonly ExtensionTagSource[];
475
+ }): CommentCompletionContext;
476
+
477
+ export declare function getCommentCursorTargetAtOffset(documentText: string, offset: number, options?: {
478
+ readonly extensions?: readonly ExtensionTagSource[];
479
+ }): CommentCursorTarget | null;
480
+
481
+ /**
482
+ * Returns hover information for the comment token under the given document
483
+ * offset, including semantic target/argument help when binding data is
484
+ * available.
485
+ */
486
+ export declare function getCommentHoverInfoAtOffset(documentText: string, offset: number, options?: CommentSemanticContextOptions): CommentHoverInfo | null;
487
+
488
+ export declare function getCommentTagSemanticContext(tag: ParsedCommentTag, options?: CommentSemanticContextOptions): CommentTagSemanticContext;
489
+
490
+ export declare function getConstraintTagDefinitions(extensions?: readonly ExtensionTagSource[]): readonly TagDefinition[];
491
+
492
+ /**
493
+ * Path to the manifest that advertises the local FormSpec semantic service for
494
+ * a workspace.
495
+ */
496
+ export declare function getFormSpecManifestPath(workspaceRoot: string): string;
497
+
498
+ /**
499
+ * Stable workspace-scoped identifier derived from the absolute workspace root.
500
+ */
501
+ export declare function getFormSpecWorkspaceId(workspaceRoot: string): string;
502
+
503
+ /**
504
+ * Directory used for machine-generated FormSpec tooling state inside a
505
+ * workspace.
506
+ */
507
+ export declare function getFormSpecWorkspaceRuntimeDirectory(workspaceRoot: string): string;
508
+
509
+ /**
510
+ * Resolves the enclosing host type for declarations nested under a containing
511
+ * class, interface, or type literal.
512
+ */
513
+ export declare function getHostType(node: ts.Node, checker: ts.TypeChecker): ts.Type | undefined;
514
+
515
+ /**
516
+ * Returns the last leading TSDoc/JSDoc block attached to a declaration node.
517
+ */
518
+ export declare function getLastLeadingDocCommentRange(node: ts.Node, sourceFile: ts.SourceFile): ts.CommentRange | null;
519
+
520
+ /**
521
+ * Filters a tag definition's overloads down to the ones that apply to the
522
+ * requested placement and synthetic target form.
523
+ *
524
+ * This is the overload-selection primitive used by both the lowering phase
525
+ * and cursor-aware tooling that wants to show only the currently-applicable
526
+ * signatures for a tag.
527
+ */
528
+ export declare function getMatchingTagSignatures(definition: TagDefinition, placement: FormSpecPlacement, targetKind: SyntheticTagTargetKind | null): readonly TagSignature[];
529
+
530
+ /**
531
+ * Resolves the completion context at a document offset, upgrading syntax-only
532
+ * results with placement/type-aware semantics when TypeScript binding data is
533
+ * available.
534
+ */
535
+ export declare function getSemanticCommentCompletionContextAtOffset(documentText: string, offset: number, options?: CommentSemanticContextOptions): SemanticCommentCompletionContext;
536
+
537
+ /**
538
+ * Resolves the direct subject type for declarations that can carry FormSpec
539
+ * comment tags.
540
+ */
541
+ export declare function getSubjectType(node: ts.Node, checker: ts.TypeChecker): ts.Type | undefined;
542
+
543
+ export declare function getTagCompletionPrefixAtOffset(documentText: string, offset: number): string | null;
544
+
545
+ export declare function getTagDefinition(rawName: string, extensions?: readonly ExtensionTagSource[]): TagDefinition | null;
546
+
547
+ export declare function getTagHoverMarkdown(rawName: string, extensions?: readonly ExtensionTagSource[]): string | null;
548
+
549
+ export declare function getTypeSemanticCapabilities(type: ts.Type, checker: ts.TypeChecker): readonly SemanticCapability[];
550
+
551
+ export declare function hasTypeSemanticCapability(type: ts.Type, checker: ts.TypeChecker, capability: SemanticCapability): boolean;
552
+
553
+ /**
554
+ * Validates an unknown manifest payload from disk before consumers trust it.
555
+ */
556
+ export declare function isFormSpecAnalysisManifest(value: unknown): value is FormSpecAnalysisManifest;
557
+
558
+ /**
559
+ * Validates an unknown inbound IPC request before dispatching it.
560
+ */
561
+ export declare function isFormSpecSemanticQuery(value: unknown): value is FormSpecSemanticQuery;
562
+
563
+ /**
564
+ * Validates an unknown IPC response before the language server consumes it.
565
+ */
566
+ export declare function isFormSpecSemanticResponse(value: unknown): value is FormSpecSemanticResponse;
567
+
568
+ /**
569
+ * Result of lowering a tag application into the synthetic call representation
570
+ * used for compiler-backed validation.
571
+ */
572
+ export declare interface LoweredSyntheticTagApplication {
573
+ readonly definition: TagDefinition;
574
+ readonly matchingSignatures: readonly TagSignature[];
575
+ readonly callExpression: string;
576
+ }
577
+
578
+ /**
579
+ * Inputs required to lower a parsed FormSpec tag into a synthetic TypeScript
580
+ * helper call.
581
+ *
582
+ * `hostType` and `subjectType` are trusted snippets of TypeScript type syntax
583
+ * supplied by the caller. They are embedded into an in-memory synthetic source
584
+ * file and are never executed.
585
+ */
586
+ export declare interface LowerSyntheticTagApplicationOptions {
587
+ readonly tagName: string;
588
+ readonly placement: FormSpecPlacement;
589
+ readonly hostType: string;
590
+ readonly subjectType: string;
591
+ readonly target?: SyntheticTagTargetSpecifier | null;
592
+ readonly argumentExpression?: string | null;
593
+ readonly extensions?: readonly ExtensionTagSource[];
594
+ }
595
+
596
+ /**
597
+ * Lowers a normalized tag application into a synthetic helper call.
598
+ *
599
+ * The caller is responsible for supplying trusted `hostType` and `subjectType`
600
+ * snippets that are valid TypeScript type syntax in the generated synthetic
601
+ * program. This function does not sanitize those snippets; it only assembles
602
+ * the helper call and selects the matching overload metadata.
603
+ */
604
+ export declare function lowerTagApplicationToSyntheticCall(options: LowerSyntheticTagApplicationOptions): LoweredSyntheticTagApplication;
605
+
606
+ export declare function normalizeFormSpecTagName(rawName: string): string;
607
+
608
+ export declare function parseCommentBlock(commentText: string, options?: ParseCommentSyntaxOptions): ParsedCommentBlock;
609
+
610
+ export declare interface ParseCommentSyntaxOptions {
611
+ readonly offset?: number;
612
+ readonly extensions?: readonly ExtensionTagSource[];
613
+ }
614
+
615
+ export declare function parseConstraintTagValue(tagName: string, text: string, provenance: Provenance, options?: ParseConstraintTagValueOptions): ConstraintNode | null;
616
+
617
+ export declare interface ParseConstraintTagValueOptions {
618
+ readonly registry?: ConstraintTagParseRegistryLike;
619
+ readonly fieldType?: TypeNode;
620
+ }
621
+
622
+ export declare interface ParsedCommentBlock {
623
+ readonly commentText: string;
624
+ readonly offset: number;
625
+ readonly tags: readonly ParsedCommentTag[];
626
+ }
627
+
628
+ export declare interface ParsedCommentTag {
629
+ readonly rawTagName: string;
630
+ readonly normalizedTagName: string;
631
+ readonly recognized: boolean;
632
+ readonly fullSpan: CommentSourceSpan;
633
+ readonly tagNameSpan: CommentSourceSpan;
634
+ readonly payloadSpan: CommentSourceSpan | null;
635
+ readonly colonSpan: CommentSourceSpan | null;
636
+ readonly target: ParsedCommentTargetSpecifier | null;
637
+ readonly argumentSpan: CommentSourceSpan | null;
638
+ readonly argumentText: string;
639
+ }
640
+
641
+ export declare interface ParsedCommentTargetSpecifier {
642
+ readonly rawText: string;
643
+ readonly valid: boolean;
644
+ readonly kind: "path" | "member" | "variant" | "ambiguous";
645
+ readonly fullSpan: CommentSourceSpan;
646
+ readonly colonSpan: CommentSourceSpan;
647
+ readonly span: CommentSourceSpan;
648
+ readonly path: PathTarget | null;
649
+ }
650
+
651
+ export declare function parseDefaultValueTagValue(text: string, provenance: Provenance): AnnotationNode;
652
+
653
+ export declare interface ParsedPathTarget {
654
+ readonly path: PathTarget;
655
+ readonly remainingText: string;
656
+ }
657
+
658
+ export declare function parseTagSyntax(rawTagName: string, payloadText: string, options?: Omit<ParseCommentSyntaxOptions, "offset">): ParsedCommentTag;
659
+
660
+ export declare function resolveConstraintTargetState(fieldName: string, fieldType: TypeNode, path: PathTarget | null, localConstraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry): ResolvedTargetState;
661
+
662
+ export declare function resolveDeclarationPlacement(node: ts.Node): FormSpecPlacement | null;
663
+
664
+ /**
665
+ * Result of resolving a dotted FormSpec path target through a TypeScript type.
666
+ */
667
+ export declare type ResolvedPathTargetType = {
668
+ readonly kind: "resolved";
669
+ readonly type: ts.Type;
670
+ } | {
671
+ readonly kind: "missing-property";
672
+ readonly segment: string;
673
+ } | {
674
+ readonly kind: "unresolvable";
675
+ readonly type: ts.Type;
676
+ };
677
+
678
+ export declare type ResolvedTargetState = ({
679
+ readonly kind: "resolved";
680
+ } & EffectiveTargetState) | {
681
+ readonly kind: "missing-property";
682
+ readonly fieldName: string;
683
+ readonly path: PathTarget;
684
+ readonly targetName: string;
685
+ readonly segment: string;
686
+ readonly localConstraints: readonly ConstraintNode[];
687
+ } | {
688
+ readonly kind: "unresolvable";
689
+ readonly fieldName: string;
690
+ readonly path: PathTarget;
691
+ readonly targetName: string;
692
+ readonly type: TypeNode;
693
+ readonly localConstraints: readonly ConstraintNode[];
694
+ };
695
+
696
+ /**
697
+ * Resolves a dotted FormSpec path target against a TypeScript type.
698
+ *
699
+ * Arrays are traversed through their item type so path-targets behave the same
700
+ * way they do in the IR validator and cursor-context completion logic.
701
+ */
702
+ export declare function resolvePathTargetType(type: ts.Type, checker: ts.TypeChecker, segments: readonly string[]): ResolvedPathTargetType;
703
+
704
+ export declare type SemanticCapability = "numeric-comparable" | "string-like" | "array-like" | "enum-member-addressable" | "json-like" | "condition-like" | "object-like";
705
+
706
+ export declare type SemanticCommentCompletionContext = {
707
+ readonly kind: "tag-name";
708
+ readonly prefix: string;
709
+ readonly availableTags: readonly TagDefinition[];
710
+ } | {
711
+ readonly kind: "target";
712
+ readonly semantic: CommentTagSemanticContext;
713
+ } | {
714
+ readonly kind: "argument";
715
+ readonly semantic: CommentTagSemanticContext;
716
+ readonly valueLabels: readonly string[];
717
+ } | {
718
+ readonly kind: "none";
719
+ };
720
+
721
+ /**
722
+ * Serializes tag-level semantic context for cross-process consumption.
723
+ */
724
+ export declare function serializeCommentTagSemanticContext(semantic: CommentTagSemanticContext): FormSpecSerializedTagSemanticContext;
725
+
726
+ /**
727
+ * Converts a parsed target specifier into its transport-safe JSON form.
728
+ */
729
+ export declare function serializeCommentTargetSpecifier(target: ParsedCommentTargetSpecifier | null): FormSpecSerializedCommentTargetSpecifier | null;
730
+
731
+ /**
732
+ * Serializes a cursor-scoped completion context for IPC.
733
+ */
734
+ export declare function serializeCompletionContext(context: SemanticCommentCompletionContext): FormSpecSerializedCompletionContext;
735
+
736
+ /**
737
+ * Serializes hover information for cross-process transport.
738
+ */
739
+ export declare function serializeHoverInfo(hover: CommentHoverInfo | null): FormSpecSerializedHoverInfo | null;
740
+
741
+ /**
742
+ * Serializes a parsed tag plus its semantic context into a file snapshot entry.
743
+ */
744
+ export declare function serializeParsedCommentTag(tag: ParsedCommentTag, semantic: CommentTagSemanticContext): FormSpecAnalysisTagSnapshot;
745
+
746
+ export declare function sliceCommentSpan(commentText: string, span: CommentSpan, options?: {
747
+ readonly offset?: number;
748
+ }): string;
749
+
750
+ /**
751
+ * A simplified TypeScript diagnostic surfaced from the synthetic compiler pass.
752
+ */
753
+ export declare interface SyntheticCompilerDiagnostic {
754
+ readonly code: number;
755
+ readonly message: string;
756
+ }
757
+
758
+ /**
759
+ * Result of checking a lowered synthetic tag application with the TypeScript
760
+ * compiler.
761
+ */
762
+ export declare interface SyntheticTagCheckResult {
763
+ readonly sourceText: string;
764
+ readonly diagnostics: readonly SyntheticCompilerDiagnostic[];
765
+ }
766
+
767
+ /**
768
+ * Target kinds that can be represented in a synthetic compiler call.
769
+ *
770
+ * This intentionally excludes `"none"`, because a missing target is modeled by
771
+ * omitting the synthetic target argument entirely.
772
+ */
773
+ export declare type SyntheticTagTargetKind = "path" | "member" | "variant";
774
+
775
+ /**
776
+ * A normalized target argument that can be lowered into a synthetic helper
777
+ * call for compiler-backed validation.
778
+ */
779
+ export declare interface SyntheticTagTargetSpecifier {
780
+ readonly kind: SyntheticTagTargetKind;
781
+ readonly text: string;
782
+ }
783
+
784
+ export declare interface TagDefinition {
785
+ readonly canonicalName: string;
786
+ readonly valueKind: FormSpecValueKind | null;
787
+ readonly requiresArgument: boolean;
788
+ readonly supportedTargets: readonly FormSpecTargetKind[];
789
+ readonly allowDuplicates: boolean;
790
+ readonly category: FormSpecTagCategory;
791
+ readonly placements: readonly FormSpecPlacement[];
792
+ readonly capabilities: readonly SemanticCapability[];
793
+ readonly completionDetail: string;
794
+ readonly hoverMarkdown: string;
795
+ readonly signatures: readonly TagSignature[];
796
+ }
797
+
798
+ export declare interface TagSignature {
799
+ readonly label: string;
800
+ readonly placements: readonly FormSpecPlacement[];
801
+ readonly parameters: readonly TagSignatureParameter[];
802
+ }
803
+
804
+ export declare interface TagSignatureParameter {
805
+ readonly kind: "value" | "target-path" | "target-member" | "target-variant";
806
+ readonly label: string;
807
+ readonly optional?: boolean;
808
+ readonly capability?: SemanticCapability;
809
+ readonly valueKind?: FormSpecValueKind;
810
+ }
811
+
812
+ export { }