@aihu/language-server 0.1.0

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.
@@ -0,0 +1,101 @@
1
+ //#region src/core/code-action.d.ts
2
+ /** Compiler diagnostic codes whose QuickFix is the v2 macro migration codemod. */
3
+ declare const MIGRATE_CODES: Set<string>;
4
+ interface MigrateFix {
5
+ /** The full-document rewritten source. */
6
+ rewritten: string;
7
+ /** Codemod warnings (e.g. @agent referencing unknown @state name). */
8
+ warnings: readonly string[];
9
+ /** Human-readable action title (includes warning count when non-zero). */
10
+ title: string;
11
+ }
12
+ /**
13
+ * Run the macro-simplification codemod over `source` and return the fix payload.
14
+ * Returns `null` when the codemod throws (malformed source) so callers can fall
15
+ * back to offering no action rather than surfacing a crash.
16
+ */
17
+ declare function buildMigrateFix(source: string): MigrateFix | null;
18
+ //#endregion
19
+ //#region src/core/completion.d.ts
20
+ /**
21
+ * packages/language-server/src/core/completion.ts
22
+ *
23
+ * LSP completion items for aihu v2 macro-kind collection-form snippets.
24
+ * Triggered by '$' inside @state block, '@' at top level.
25
+ *
26
+ * Uses inline numeric constants for CompletionItemKind and InsertTextFormat
27
+ * to avoid importing vscode-languageserver at module load time (enables testing
28
+ * without the vscode-languageserver package installed, and keeps this module
29
+ * editor-agnostic — the clean seam for a future Volar adoption).
30
+ */
31
+ interface LspCompletionItem {
32
+ label: string;
33
+ kind: number;
34
+ insertTextFormat: number;
35
+ detail: string;
36
+ sortText: string;
37
+ insertText: string;
38
+ }
39
+ /** v2 macro-kind snippet completions (triggered by '$' in @state block). */
40
+ declare const STATE_MACRO_COMPLETIONS: LspCompletionItem[];
41
+ /** Top-level block completions (triggered by '@' at top level). */
42
+ declare const BLOCK_COMPLETIONS: LspCompletionItem[];
43
+ //#endregion
44
+ //#region src/core/diagnostics.d.ts
45
+ /** Normalised diagnostic with 0-based LSP positions. */
46
+ interface AihuDiagnostic {
47
+ code: string;
48
+ message: string;
49
+ hint?: string | undefined;
50
+ fix?: string | undefined;
51
+ /** Original source text to replace (for code-action text edits). */
52
+ fromText: string | null;
53
+ /** Replacement text (for code-action text edits). */
54
+ toText: string | null;
55
+ /** 0-based LSP range. null when position is unknown. */
56
+ range: {
57
+ start: {
58
+ line: number;
59
+ character: number;
60
+ };
61
+ end: {
62
+ line: number;
63
+ character: number;
64
+ };
65
+ } | null;
66
+ }
67
+ interface CompileResult {
68
+ code: string | null;
69
+ diagnostics: AihuDiagnostic[];
70
+ }
71
+ /**
72
+ * Parse the Rust binary's `--machine-errors` stderr stream into structured
73
+ * diagnostics. Each JSON line is one error; non-JSON lines are skipped. When no
74
+ * JSON is present at all, falls back to a single synthetic plain-text diagnostic.
75
+ *
76
+ * Pure function — no I/O. Exposed so editors/tests can exercise the mapping
77
+ * without spawning the compiler.
78
+ */
79
+ declare function parseMachineErrors(stderr: string, filePath: string): AihuDiagnostic[];
80
+ /**
81
+ * Compile a .aihu source string via stdin, returning structured diagnostics.
82
+ */
83
+ declare function compileWithDiagnostics(source: string, filePath: string): Promise<CompileResult>;
84
+ //#endregion
85
+ //#region src/core/hover.d.ts
86
+ /**
87
+ * packages/language-server/src/core/hover.ts
88
+ *
89
+ * Static hover lookup table for aihu macro keywords.
90
+ * Used by the LSP server textDocument/hover handler.
91
+ *
92
+ * Editor-agnostic: returns Markdown strings + does pure position math. The
93
+ * connection layer wraps the result in a protocol `Hover`. Clean seam for a
94
+ * future Volar virtual-code hover provider.
95
+ */
96
+ declare function getBlockContext(lines: string[], lineIndex: number): 'state' | 'template' | 'unknown';
97
+ declare function getMacroAtPosition(lineText: string, character: number): string | null;
98
+ declare function getHoverContent(macro: string): string | null;
99
+ //#endregion
100
+ export { type AihuDiagnostic, BLOCK_COMPLETIONS, type CompileResult, type LspCompletionItem, MIGRATE_CODES, type MigrateFix, STATE_MACRO_COMPLETIONS, buildMigrateFix, compileWithDiagnostics, getBlockContext, getHoverContent, getMacroAtPosition, parseMachineErrors };
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/code-action.ts","../../src/core/completion.ts","../../src/core/diagnostics.ts","../../src/core/hover.ts"],"mappings":";;cAmBa,aAAA,EAAa,GAAA;AAAA,UAET,UAAA;;EAEf,SAAA;EAJwB;EAMxB,QAAA;EAJyB;EAMzB,KAAA;AAAA;;;;;;iBAQc,eAAA,CAAgB,MAAA,WAAiB,UAAA;;;;AAhBjD;;;;;AAEA;;;;;UCLiB,iBAAA;EACf,KAAA;EACA,IAAA;EACA,gBAAA;EACA,MAAA;EACA,QAAA;EACA,UAAA;AAAA;;cAIW,uBAAA,EAAyB,iBAAA;;cAuFzB,iBAAA,EAAmB,iBAAA;;;;UC3Df,cAAA;EACf,IAAA;EACA,OAAA;EAGA,IAAA;EACA,GAAA;EFvCe;EEyCf,QAAA;;EAEA,MAAA;EFzCA;EE2CA,KAAA;IACE,KAAA;MAAS,IAAA;MAAc,SAAA;IAAA;IACvB,GAAA;MAAO,IAAA;MAAc,SAAA;IAAA;EAAA;AAAA;AAAA,UA+CR,aAAA;EACf,IAAA;EACA,WAAA,EAAa,cAAA;AAAA;;;;;;;;;iBAWC,kBAAA,CAAmB,MAAA,UAAgB,QAAA,WAAmB,cAAA;ADtGtE;;;AAAA,iBC6HsB,sBAAA,CACpB,MAAA,UACA,QAAA,WACC,OAAA,CAAQ,aAAA;;;;AFvIX;;;;;AAEA;;;;iBGyKgB,eAAA,CACd,KAAA,YACA,SAAA;AAAA,iBAWc,kBAAA,CAAmB,QAAA,UAAkB,SAAA;AAAA,iBAwBrC,eAAA,CAAgB,KAAA"}
@@ -0,0 +1,2 @@
1
+ import { a as parseMachineErrors, c as MIGRATE_CODES, i as compileWithDiagnostics, l as buildMigrateFix, n as getHoverContent, o as BLOCK_COMPLETIONS, r as getMacroAtPosition, s as STATE_MACRO_COMPLETIONS, t as getBlockContext } from "../core-BHishSOT.js";
2
+ export { BLOCK_COMPLETIONS, MIGRATE_CODES, STATE_MACRO_COMPLETIONS, buildMigrateFix, compileWithDiagnostics, getBlockContext, getHoverContent, getMacroAtPosition, parseMachineErrors };