Cross-editor Language Server (aihu-language-server) for .aihu Single File Components — diagnostics, hover, completion, and quick-fix code actions.
buildMigrateFixfunction buildMigrateFix(source: string): MigrateFix | nullRun the macro-simplification codemod over `source` and return the fix payload.
compileWithDiagnosticsasync function compileWithDiagnostics( source: string, filePath: string, ): Promise<CompileResult>Compile a .aihu source string via stdin, returning structured diagnostics.
createAihuLanguagePluginfunction createAihuLanguagePlugin(options?: { strictTemplates?: boolean target?: 'client' | 'server' | 'universal' }): LanguagePlugin<URI, AihuVirtualCode>Create the Volar LanguagePlugin for .aihu files.
createAihuLanguageServicePluginfunction createAihuLanguageServicePlugin(): LanguageServicePluginCreate the Volar LanguageServicePlugin for aihu.
createTestServerfunction createTestServer()Create and wire the test seam for integration / unit tests.
getBlockContextfunction getBlockContext( lines: string[], lineIndex: number, ): 'state' | 'template' | 'style' | 'agent' | 'route' | 'unknown'getHoverContentfunction getHoverContent(macro: string): string | nullgetMacroAtPositionfunction getMacroAtPosition(lineText: string, character: number): string | nullmapToOriginalfunction mapToOriginal( virtualOffset: number, map: SourceMap<CodeInformation>, ): AihuSourcePosition | nullMap a virtual-file offset back to the original .aihu source offset.
mapToVirtualfunction mapToVirtual( originalOffset: number, _block: '@state', map: SourceMap<CodeInformation>, ): AihuVirtualPosition | nullMap an original .aihu source offset to the virtual-file offset.
parseMachineErrorsfunction parseMachineErrors(stderr: string, filePath: string): AihuDiagnostic[]Parse the Rust binary's `--machine-errors` stderr stream into structured diagnostics.
startServerfunction startServer(): voidStart the language server on stdio and begin listening.
withAihuDiagnosticParityfunction withAihuDiagnosticParity(plugin: LanguageServicePlugin): LanguageServicePluginWrap a TypeScript LanguageServicePlugin (volar-service-typescript) so its diagnostics apply the SAME implicit-`any` suppression `aihu-tsc` applies to `.aihu` files by default (`IMPLICIT_ANY_CODES`, packages/tsc/src/index.ts).
BLOCK_COMPLETIONSconst BLOCK_COMPLETIONS: LspCompletionItem[]Top-level block completions (triggered by '@' at top level).
COMPOSABLE_COMPLETIONSconst COMPOSABLE_COMPLETIONS: LspCompletionItem[]`@aihu/use` composable completions, offered inside `@state` (FEL-342): the compiler auto-imports a bare `useMouse()`-style call (`use_registry.rs`), which previously meant no completion suggested the name existed at all, and TypeScript had no declaration for it until the sidecar's ambient decl landed — the two together made auto-import look like a red squiggle, invisible build magic instead of a feature.
COMPOSABLE_REGISTRYconst COMPOSABLE_REGISTRY: readonly ComposableRegistryEntry[]MIGRATE_CODESconst MIGRATE_CODESCompiler diagnostic codes whose QuickFix is the v2 macro migration codemod.
SourceMapconst SourceMapSTATE_MACRO_COMPLETIONSconst STATE_MACRO_COMPLETIONS: LspCompletionItem[]v2 macro-kind snippet completions (triggered by '$' in
AihuDiagnosticinterface AihuDiagnostic {
code: string
message: string
// `| undefined` is explicit so the raw compiler error's optional hint/fix
// (which may be undefined) assign cleanly under exactOptionalPropertyTypes.
hint?: string | undefined
fix?: string | undefined
/** Original source text to replace (for code-action text edits). */
fromText: string | null
/** Replacement text (for code-action text edits). */
toText: string | null
/** 0-based LSP range. null when position is unknown. */
range: {
start: { line: number; character: number }
end: { line: number; character: number }
} | null
}Normalised diagnostic with 0-based LSP positions.
AihuSourcePositioninterface AihuSourcePosition {
/** Character offset from the start of the .aihu source string. */
offset: number
}An offset within a .aihu source file (character offset from start of file).
AihuVirtualPositioninterface AihuVirtualPosition {
/** Character offset in the __state__.ts virtual file. */
offset: number
}An offset within a virtual __state__.ts file generated from the
CompileResultinterface CompileResult {
code: string | null
diagnostics: AihuDiagnostic[]
}ComposableRegistryEntryinterface ComposableRegistryEntry {
/** Bare call name, e.g. `useMouse`. */
name: string
/** Module specifier the compiler auto-imports, e.g. `@aihu/use/useMouse`. */
specifier: string
/** One-line purpose, extracted from the composable's doc comment. */
description: string
}packages/language-server/src/core/composable-registry.ts GENERATED — do not hand-edit.
LspCompletionIteminterface LspCompletionItem {
label: string
kind: number
insertTextFormat: number
detail: string
sortText: string
insertText: string
}MigrateFixinterface MigrateFix {
/** The full-document rewritten source. */
rewritten: string
/** Codemod warnings (e.g. @agent referencing unknown @state name). */
warnings: readonly string[]
/** Human-readable action title (includes warning count when non-zero). */
title: string
}AihuCodeMappingtype AihuCodeMapping = Mapping<CodeInformation>Alias for clarity: a Volar CodeMapping carrying CodeInformation data.
AihuVirtualCodetype AihuVirtualCode