Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add Firmament language analysis and editor services

Yuechen Lia36227fc53d2
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageServiceTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageServiceTests.cs
index f62e3689..cb542b5d 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageServiceTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageServiceTests.cs
@@ -39,4 +39,62 @@ public sealed class FirmamentLanguageServiceTests
Assert.Equal("Value", result.Context);
Assert.Empty(result.Fields);
}
+
+ [Fact]
+ public void ModelScope_OffersSchemaOwnedThreadAndBox()
+ {
+ const string thread = "Model M {\n Thr";
+ var found = FirmamentLanguageService.Complete(thread, "draft.firmament", "3", thread.Length);
+ Assert.Contains(found.Entries!, entry => entry.Name == "Thread");
+ const string box = "Model M {\n Bo";
+ Assert.Contains(FirmamentLanguageService.Complete(box, "draft.firmament", "3", box.Length).Entries!, entry => entry.Name == "Box");
+ }
+
+ [Fact]
+ public void ThreadFieldsAndBoundedValues_ComeFromSchema()
+ {
+ const string fields = "Model M { Thread T {\n Maj";
+ var found = FirmamentLanguageService.Complete(fields, "draft.firmament", "4", fields.Length);
+ Assert.Contains(found.Fields, field => field.Name == "MajorDiameter");
+ const string emptyThread = "Model M { Thread T {\n ";
+ var available = FirmamentLanguageService.Complete(emptyThread, "draft.firmament", "4", emptyThread.Length);
+ Assert.Contains(available.Fields, field => field.Name == "Surface");
+ Assert.Contains(available.Fields, field => field.Name == "Pitch");
+ Assert.Contains(available.Fields, field => field.Name == "Length");
+ const string value = "Model M { Thread T {\n Hand: R";
+ Assert.Equal(["Right"], FirmamentLanguageService.Complete(value, "draft.firmament", "5", value.Length).Values);
+ }
+
+ [Fact]
+ public void Analysis_UsesParserErrorsAndSchemaClassificationWithoutGeometry()
+ {
+ const string source = "Model M {\n Units: mm\n Thread T {\n Wrong: 1mm\n }\n Box Body { Size: [8mm, 8mm, 8mm] }\n}";
+ var analysis = FirmamentLanguageAnalysisService.Analyze(source, "test.firmament", "6");
+ Assert.Equal("6", analysis.Revision);
+ Assert.Contains(analysis.Tokens, token => token.Kind == "construct" && source.Substring(token.Start, token.Length) == "Thread");
+ Assert.Contains(analysis.Tokens, token => token.Kind == "field" && source.Substring(token.Start, token.Length) == "Size");
+ Assert.Contains(analysis.Diagnostics, diagnostic => diagnostic.Code.Contains("thread-field-invalid", StringComparison.Ordinal));
+ var hover = FirmamentLanguageAnalysisService.Hover(source, "test.firmament", "6", source.IndexOf("Thread", StringComparison.Ordinal) + 2);
+ Assert.Contains("thread", hover!.Description, StringComparison.OrdinalIgnoreCase);
+ var definition = FirmamentLanguageAnalysisService.Definition(source + "\nT", "test.firmament", source.Length + 1);
+ Assert.Equal(source.IndexOf("T {", StringComparison.Ordinal), definition!.Start);
+ }
+
+ [Fact]
+ public void Formatter_PreservesCommentsAndIsIdempotentForSimpleModel()
+ {
+ const string source = "Model M {\n Units: mm\n // important stock\n Box Body { Size: [10mm, 8mm, 4mm] }\n}\n";
+ var once = FirmamentLanguageAnalysisService.Format(source, "m.firmament", "7");
+ var twice = FirmamentLanguageAnalysisService.Format(once.Text, "m.firmament", "8");
+ Assert.Contains("// important stock", once.Text);
+ Assert.Equal(once.Text, twice.Text);
+ var before = FirmamentV2Parser.Parse(source);
+ var after = FirmamentV2Parser.Parse(once.Text);
+ Assert.True(after.IsSuccess);
+ Assert.Equal(before.Document!.ModelName, after.Document!.ModelName);
+ Assert.Equal(before.Document.Units, after.Document.Units);
+ Assert.Equal(before.Document.Solids[0].Name, after.Document.Solids[0].Name);
+ Assert.Equal(((FirmamentV2BoxRecord)before.Document.Solids[0].Primitive).Size,
+ ((FirmamentV2BoxRecord)after.Document.Solids[0].Primitive).Size);
+ }
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageAnalysis.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageAnalysis.cs
new file mode 100644
index 00000000..334b3f67
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageAnalysis.cs
@@ -0,0 +1,184 @@
+using System.Text;
+
+namespace Aetheris.Kernel.Firmament.FirmamentV2;
+
+public sealed record FirmamentLanguageToken(int Start, int Length, string Kind);
+public sealed record FirmamentLanguageDiagnostic(string Severity, string Code, string Message, int Start, int Length);
+public sealed record FirmamentLanguageAnalysis(string Document, string Revision,
+ IReadOnlyList<FirmamentLanguageToken> Tokens, IReadOnlyList<FirmamentLanguageDiagnostic> Diagnostics);
+public sealed record FirmamentLanguageLocation(string Document, int Start, int Length);
+public sealed record FirmamentLanguageHover(string Document, string Revision, int Start, int Length, string Title, string Description);
+public sealed record FirmamentLanguageFormat(string Document, string Revision, string Text, bool Changed);
+
+/// <summary>
+/// Source-side projection of the existing Firmament parser and generated semantic schema.
+/// It never constructs a BRep. Lexical spans support editor colors and source navigation;
+/// parser diagnostics and construct/field descriptions remain compiler owned.
+/// </summary>
+public static class FirmamentLanguageAnalysisService
+{
+ private sealed record Lexeme(int Start, int Length, string Text, string Shape);
+ private static readonly HashSet<string> Keywords = ["Model", "Units", "Modify", "WireForm", "Construction", "Use", "schema", "Let", "Static", "With", "Expose"];
+ private static readonly HashSet<string> Types = ["Length", "Angle", "Float", "Int", "Bool", "Box3", "Plane", "Point2", "Point3"];
+ private static readonly HashSet<string> Choices = FirmamentSemanticSchemas.All
+ .SelectMany(construct => construct.Fields).SelectMany(field => field.Choices).ToHashSet(StringComparer.Ordinal);
+
+ public static FirmamentLanguageAnalysis Analyze(string source, string document, string revision)
+ {
+ ArgumentNullException.ThrowIfNull(source);
+ var lexemes = Lex(source);
+ var tokens = lexemes.Select((lexeme, index) => new FirmamentLanguageToken(
+ lexeme.Start, lexeme.Length, Classify(lexemes, index))).ToArray();
+ var parse = FirmamentV2Parser.Parse(source);
+ var failures = parse.Diagnostics.Where(item => FirmamentV2Parser.IsFatalDiagnosticCode(item) ||
+ item == "firmament-v2-parse-failed").Distinct(StringComparer.Ordinal).ToArray();
+ if (failures.Length > 1) failures = failures.Where(item => item != "firmament-v2-parse-failed").ToArray();
+ var diagnostics = failures.Select(item => LocateDiagnostic(source, lexemes, item)).ToArray();
+ return new(document, revision, tokens, diagnostics);
+ }
+
+ public static FirmamentLanguageHover? Hover(string source, string document, string revision, int offset)
+ {
+ var lexemes = Lex(source);
+ var index = lexemes.FindIndex(item => item.Start <= offset && offset <= item.Start + item.Length && item.Shape == "identifier");
+ if (index < 0) return null;
+ var token = lexemes[index];
+ var construct = FirmamentSemanticSchemas.All.FirstOrDefault(item => item.Name == token.Text);
+ if (construct is not null)
+ return new(document, revision, token.Start, token.Length, construct.Name, construct.Description ?? construct.Context ?? "Firmament construct");
+ var field = FirmamentSemanticSchemas.All.SelectMany(item => item.Fields).FirstOrDefault(item => item.Name == token.Text);
+ if (field is not null && Classify(lexemes, index) == "field")
+ return new(document, revision, token.Start, token.Length, field.Name,
+ $"{field.Kind}{(field.Unit == FirmamentUnitKind.None ? "" : $" · {field.Unit}")}. {field.Description ?? ""}".Trim());
+ return null;
+ }
+
+ public static FirmamentLanguageLocation? Definition(string source, string document, int offset)
+ {
+ var tokens = Lex(source);
+ var selected = tokens.FirstOrDefault(item => item.Shape == "identifier" && item.Start <= offset && offset <= item.Start + item.Length);
+ if (selected is null) return null;
+ var declarations = tokens.Select((token, index) => (token, index))
+ .Where(pair => pair.index > 0 && pair.token.Text == selected.Text && pair.token.Shape == "identifier" &&
+ FirmamentSemanticSchemas.All.Any(schema => schema.Name == tokens[pair.index - 1].Text) &&
+ pair.index + 1 < tokens.Count && tokens[pair.index + 1].Text == "{")
+ .Select(pair => pair.token).ToArray();
+ return declarations.Length == 1 ? new(document, declarations[0].Start, declarations[0].Length) : null;
+ }
+
+ public static FirmamentLanguageFormat Format(string source, string document, string revision)
+ {
+ if (!FirmamentV2Parser.Parse(source).IsSuccess)
+ throw new InvalidOperationException("Format Document requires valid Firmament source. Fix syntax errors first.");
+ var lexemes = Lex(source);
+ var output = new StringBuilder(source.Length + 64);
+ var indent = 0;
+ var lineStart = true;
+ Lexeme? previous = null;
+ foreach (var token in lexemes)
+ {
+ var gap = previous is null ? string.Empty : source[(previous.Start + previous.Length)..token.Start];
+ if (token.Text == "}")
+ {
+ indent = Math.Max(0, indent - 1);
+ BreakLine();
+ }
+ else if (gap.Contains('\n') && token.Text != ";" && previous?.Text != "{") BreakLine();
+
+ if (lineStart) { output.Append(' ', indent * 2); lineStart = false; }
+ else if (NeedsSpace(previous?.Text, token.Text)) output.Append(' ');
+ output.Append(token.Text);
+ if (token.Shape == "comment" || token.Text is "{" or ";" or "}")
+ {
+ if (token.Text == "{") indent++;
+ BreakLine();
+ }
+ previous = token;
+ }
+ var formatted = output.ToString().TrimEnd() + "\n";
+ if (!FirmamentV2Parser.Parse(formatted).IsSuccess)
+ throw new InvalidOperationException("Canonical layout was refused because it changed parser admission.");
+ return new(document, revision, formatted, formatted != source);
+
+ void BreakLine()
+ {
+ if (!lineStart) { output.Append('\n'); lineStart = true; }
+ }
+ }
+
+ private static bool NeedsSpace(string? previous, string current)
+ {
+ if (previous is null || previous is "(" or "[" or "<" or "." or "+" or "-") return false;
+ if (current is ")" or "]" or ">" or "." or ":" or "," or ";" or "(" or "[") return false;
+ return true;
+ }
+
+ private static string Classify(IReadOnlyList<Lexeme> tokens, int index)
+ {
+ var token = tokens[index];
+ if (token.Shape != "identifier") return token.Shape;
+ if (Keywords.Contains(token.Text)) return "keyword";
+ if (FirmamentSemanticSchemas.All.Any(item => item.Name == token.Text)) return "construct";
+ if (Types.Contains(token.Text)) return "type";
+ if (index + 1 < tokens.Count && tokens[index + 1].Text == ":" &&
+ FirmamentSemanticSchemas.All.Any(item => item.Fields.Any(field => field.Name == token.Text))) return "field";
+ if (token.Text is "mm" or "cm" or "m" or "deg" or "rad") return "unit";
+ if (Choices.Contains(token.Text)) return "value";
+ if (token.Text == "face" && index + 1 < tokens.Count && tokens[index + 1].Text == "(") return "selector";
+ return "identifier";
+ }
+
+ private static FirmamentLanguageDiagnostic LocateDiagnostic(string source, IReadOnlyList<Lexeme> tokens, string diagnostic)
+ {
+ var separator = diagnostic.LastIndexOf(':');
+ var code = separator > 0 ? diagnostic[..separator] : diagnostic;
+ var subject = separator > 0 ? diagnostic[(separator + 1)..] : string.Empty;
+ var match = tokens.FirstOrDefault(token => token.Text == subject);
+ var start = match?.Start ?? Math.Max(0, source.Length - 1);
+ var length = match?.Length ?? (source.Length == 0 ? 0 : 1);
+ return new("error", code, diagnostic.Replace('-', ' '), start, length);
+ }
+
+ private static List<Lexeme> Lex(string source)
+ {
+ var result = new List<Lexeme>();
+ for (var at = 0; at < source.Length;)
+ {
+ if (char.IsWhiteSpace(source[at])) { at++; continue; }
+ var start = at;
+ string shape;
+ if (at + 1 < source.Length && source[at] == '/' && source[at + 1] == '/')
+ {
+ at += 2;
+ while (at < source.Length && source[at] != '\n') at++;
+ shape = "comment";
+ }
+ else if (source[at] == '"')
+ {
+ at++;
+ while (at < source.Length)
+ {
+ if (source[at++] != '"') continue;
+ if (at >= 2 && source[at - 2] == '\\') continue;
+ break;
+ }
+ shape = "string";
+ }
+ else if (char.IsLetter(source[at]) || source[at] == '_')
+ {
+ at++;
+ while (at < source.Length && (char.IsLetterOrDigit(source[at]) || source[at] == '_')) at++;
+ shape = "identifier";
+ }
+ else if (char.IsDigit(source[at]) || source[at] == '.' && at + 1 < source.Length && char.IsDigit(source[at + 1]))
+ {
+ at++;
+ while (at < source.Length && (char.IsDigit(source[at]) || source[at] == '.')) at++;
+ shape = "number";
+ }
+ else { at++; shape = "punctuation"; }
+ result.Add(new(start, at - start, source[start..at], shape));
+ }
+ return result;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
index b1bf5f33..0149dc11 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
@@ -7,7 +7,8 @@ public sealed record FirmamentLanguageCompletion(
string Document, string Revision, string Context, int ReplaceStart, int ReplaceLength,
IReadOnlyList<FirmamentAuthoringField> Fields,
IReadOnlyList<string> MissingRequiredFields,
- IReadOnlyList<FirmamentLanguageEntry>? Entries = null);
+ IReadOnlyList<FirmamentLanguageEntry>? Entries = null,
+ IReadOnlyList<string>? Values = null);
public sealed record FirmamentLanguageEntry(string ConstructId, string Name, string Context, string Source);
/// <summary>Bounded authoring help from construct owners; no BRep or export work.</summary>
@@ -22,8 +23,6 @@ public static class FirmamentLanguageService
var prefix = source[prefixStart..offset];
var lineStart = prefixStart == 0 ? 0 : source.LastIndexOf('\n', prefixStart - 1) + 1;
var beforePrefix = source[lineStart..prefixStart];
- if (beforePrefix.Contains(':')) return new(document, revision, "Value", prefixStart, prefix.Length, [], []);
-
IReadOnlyList<FirmamentAuthoringField> fields;
string context;
if (IsInsideThread(source, offset))
@@ -42,15 +41,29 @@ public static class FirmamentLanguageService
context = "Helix";
}
else if (LoftAuthoringParser.TryGetAuthoringFields(source, offset, out fields)) context = "Loft";
+ else if (IsInsideConstruct(source, offset, "Box")) { fields = FirmamentSchemaAuthoringFields.For("Box"); context = "Box"; }
+ else if (IsInsideConstruct(source, offset, "Hole")) { fields = FirmamentSchemaAuthoringFields.For("Hole"); context = "Hole"; }
else
{
+ if (beforePrefix.Contains(':')) return new(document, revision, "Value", prefixStart, prefix.Length, [], []);
+ var inModify = IsInsideConstruct(source, offset, "Modify");
var entries = FirmamentSemanticSchemas.All
- .Where(item => item.Name is "Helix" or "Loft" or "Perforation" or "Thread" && item.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && item.Entry is not null)
+ .Where(item => item.Entry is not null && item.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) &&
+ (!inModify || item.Context?.StartsWith("Modify", StringComparison.Ordinal) == true))
.Select(item => new FirmamentLanguageEntry(item.Id.Value, item.Name, item.Context ?? string.Empty, item.Entry!)).ToArray();
return new(document, revision, entries.Length > 0 ? "ConstructEntry" : "Unsupported",
prefixStart, prefix.Length, [], [], entries);
}
+ var activeField = Regex.Match(beforePrefix, @"(?<field>[A-Za-z_]\w*)\s*:\s*$", RegexOptions.CultureInvariant);
+ if (activeField.Success)
+ {
+ var field = fields.FirstOrDefault(item => item.Name == activeField.Groups["field"].Value);
+ var values = field?.Choices?.Where(choice => choice.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToArray();
+ return new(document, revision, "Value", prefixStart, prefix.Length, [], [], Values: values);
+ }
+ if (beforePrefix.Contains(':')) return new(document, revision, "Value", prefixStart, prefix.Length, [], []);
+
var open = source.LastIndexOf('{', Math.Max(0, offset - 1));
var body = open >= 0 ? source[(open + 1)..offset] : string.Empty;
var present = fields.Where(field => Regex.IsMatch(body, $@"\b{Regex.Escape(field.Name)}\s*:", RegexOptions.CultureInvariant))
@@ -74,4 +87,12 @@ public static class FirmamentLanguageService
var header = Regex.Matches(prefix, @"\bThread\s+[A-Za-z_][A-Za-z0-9_]*\s*\{", RegexOptions.CultureInvariant).Cast<Match>().LastOrDefault();
return header is not null && !prefix[(header.Index + header.Length)..].Contains('}');
}
+
+ private static bool IsInsideConstruct(string source, int offset, string construct)
+ {
+ var prefix = source[..offset];
+ var header = Regex.Matches(prefix, $@"\b{Regex.Escape(construct)}(?:\s*<[^>]+>)?\s+[A-Za-z_]\w*\s*\{{", RegexOptions.CultureInvariant)
+ .Cast<Match>().LastOrDefault();
+ return header is not null && !prefix[(header.Index + header.Length)..].Contains('}');
+ }
}
diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.cs
index ab886eec..40886981 100644
--- a/Aetheris.Web.Runtime/Program.cs
+++ b/Aetheris.Web.Runtime/Program.cs
@@ -32,11 +32,15 @@ public static partial class Program
var request = JsonSerializer.Deserialize<WebRequest>(requestJson, JsonOptions)
?? throw new WebRuntimeException("invalid-request", "The runtime request was empty.");
if (request.Performance) BuildPerfTrace.Start();
- object result = request.Operation switch
+ object? result = request.Operation switch
{
"info" => Info(),
"compile" => Compile(request),
"languageComplete" => LanguageComplete(request),
+ "languageAnalyze" => LanguageAnalyze(request),
+ "languageHover" => LanguageHover(request),
+ "languageDefinition" => LanguageDefinition(request),
+ "languageFormat" => LanguageFormat(request),
"languageSchema" => LanguageSchema(),
"describeConstruct" => DescribeConstruct(request),
"rewriteField" => RewriteField(request),
@@ -99,6 +103,40 @@ public static partial class Program
request.SourceRevision, request.Offset.Value);
}
+ private static object LanguageAnalyze(WebRequest request)
+ {
+ if (request.Source is null || string.IsNullOrWhiteSpace(request.SourceRevision))
+ throw new WebRuntimeException("language-input-required", "languageAnalyze requires source and sourceRevision.");
+ var name = request.SourceName ?? "model.firmament";
+ var analysis = FirmamentLanguageAnalysisService.Analyze(request.Source, name, request.SourceRevision);
+ return new { document = name, revision = request.SourceRevision, analysis.Tokens,
+ diagnostics = analysis.Diagnostics.Select(item => new WebDiagnostic(item.Severity, item.Code, item.Message,
+ SourceRefAt(name, request.Source, item.Start, item.Length))).ToArray() };
+ }
+
+ private static object? LanguageHover(WebRequest request)
+ {
+ if (request.Source is null || request.Offset is null || string.IsNullOrWhiteSpace(request.SourceRevision))
+ throw new WebRuntimeException("language-input-required", "languageHover requires source, offset, and sourceRevision.");
+ return FirmamentLanguageAnalysisService.Hover(request.Source, request.SourceName ?? "model.firmament", request.SourceRevision, request.Offset.Value);
+ }
+
+ private static object? LanguageDefinition(WebRequest request)
+ {
+ if (request.Source is null || request.Offset is null)
+ throw new WebRuntimeException("language-input-required", "languageDefinition requires source and offset.");
+ var location = FirmamentLanguageAnalysisService.Definition(request.Source, request.SourceName ?? "model.firmament", request.Offset.Value);
+ return location is null ? null : SourceRefAt(location.Document, request.Source, location.Start, location.Length);
+ }
+
+ private static object LanguageFormat(WebRequest request)
+ {
+ if (request.Source is null || string.IsNullOrWhiteSpace(request.SourceRevision))
+ throw new WebRuntimeException("language-input-required", "languageFormat requires source and sourceRevision.");
+ try { return FirmamentLanguageAnalysisService.Format(request.Source, request.SourceName ?? "model.firmament", request.SourceRevision); }
+ catch (InvalidOperationException exception) { throw new WebRuntimeException("format-refused", exception.Message); }
+ }
+
private static object LanguageSchema() => new
{
version = FirmamentSemanticSchemas.Version,
diff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.ts
index 8c7d7e15..38d5e088 100644
--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts
+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts
@@ -23,7 +23,11 @@ export interface CompileOptions extends OperationOptions { readonly sourceName?:
export interface LanguageOptions { readonly sourceName?: string; readonly sourceRevision: string }
export interface LanguageField { readonly name: string; readonly type: string; readonly required: boolean; readonly meaning: string; readonly default?: string | null; readonly choices?: readonly string[] | null }
export interface LanguageEntry { readonly constructId: string; readonly name: string; readonly context: string; readonly source: string }
-export interface LanguageCompletion { readonly document: string; readonly revision: string; readonly context: string; readonly replaceStart: number; readonly replaceLength: number; readonly fields: readonly LanguageField[]; readonly missingRequiredFields: readonly string[]; readonly entries?: readonly LanguageEntry[] | null }
+export interface LanguageCompletion { readonly document: string; readonly revision: string; readonly context: string; readonly replaceStart: number; readonly replaceLength: number; readonly fields: readonly LanguageField[]; readonly missingRequiredFields: readonly string[]; readonly entries?: readonly LanguageEntry[] | null; readonly values?: readonly string[] | null }
+export interface LanguageToken { readonly start: number; readonly length: number; readonly kind: 'keyword' | 'construct' | 'type' | 'identifier' | 'field' | 'number' | 'unit' | 'string' | 'comment' | 'punctuation' | 'selector' | 'value' }
+export interface LanguageAnalysis { readonly document: string; readonly revision: string; readonly tokens: readonly LanguageToken[]; readonly diagnostics: readonly Diagnostic[] }
+export interface LanguageHover { readonly document: string; readonly revision: string; readonly start: number; readonly length: number; readonly title: string; readonly description: string }
+export interface LanguageFormat { readonly document: string; readonly revision: string; readonly text: string; readonly changed: boolean }
export interface SemanticFieldSchema { readonly id: string; readonly name: string; readonly kind: string; readonly unit: 'None' | 'Length' | 'Angle'; readonly required: boolean; readonly default: string | null; readonly choices: readonly string[]; readonly description: string | null; readonly sourceEditable: boolean }
export interface SemanticOutputSchema { readonly id: string; readonly name: string; readonly kind: string; readonly sourceAddressable: boolean; readonly sourceRole: string | null }
export interface SemanticConstructSchema { readonly id: string; readonly name: string; readonly context: string | null; readonly entry: string | null; readonly description: string | null; readonly compatibilityAlias: string | null; readonly fields: readonly SemanticFieldSchema[]; readonly outputs: readonly SemanticOutputSchema[] }
@@ -39,7 +43,7 @@ export class Aetheris {
static create(options?: AetherisOptions): Promise<Aetheris>;
readonly runtimeInfo: RuntimeInfo;
readonly workerTiming: WorkerTiming | null;
- readonly language: { complete(source: string, offset: number, options: LanguageOptions): Promise<LanguageCompletion>; schema(): Promise<SemanticSchema> };
+ readonly language: { complete(source: string, offset: number, options: LanguageOptions): Promise<LanguageCompletion>; analyze(source: string, options: LanguageOptions): Promise<LanguageAnalysis>; hover(source: string, offset: number, options: LanguageOptions): Promise<LanguageHover | null>; definition(source: string, offset: number, options: LanguageOptions): Promise<SourceReference | null>; format(source: string, options: LanguageOptions): Promise<LanguageFormat>; schema(): Promise<SemanticSchema> };
info(): Promise<RuntimeInfo>;
capabilities(): Promise<RuntimeCapabilities>;
compile(source: string, options?: CompileOptions): Promise<{ model: ModelSession | null; diagnostics: readonly Diagnostic[] }>;
diff --git a/Aetheris.Web.Runtime/sdk/src/index.js b/Aetheris.Web.Runtime/sdk/src/index.js
index ad7495c9..57d0edb5 100644
--- a/Aetheris.Web.Runtime/sdk/src/index.js
+++ b/Aetheris.Web.Runtime/sdk/src/index.js
@@ -83,6 +83,14 @@ export class Aetheris {
this.language = {
schema: () => this.transport.request({ operation: 'languageSchema' }),
complete: (source, offset, options = {}) => this.transport.request({ operation: 'languageComplete', source, offset,
+ sourceName: options.sourceName, sourceRevision: options.sourceRevision }),
+ analyze: (source, options = {}) => this.transport.request({ operation: 'languageAnalyze', source,
+ sourceName: options.sourceName, sourceRevision: options.sourceRevision }),
+ hover: (source, offset, options = {}) => this.transport.request({ operation: 'languageHover', source, offset,
+ sourceName: options.sourceName, sourceRevision: options.sourceRevision }),
+ definition: (source, offset, options = {}) => this.transport.request({ operation: 'languageDefinition', source, offset,
+ sourceName: options.sourceName, sourceRevision: options.sourceRevision }),
+ format: (source, options = {}) => this.transport.request({ operation: 'languageFormat', source,
sourceName: options.sourceName, sourceRevision: options.sourceRevision })
};
}
diff --git a/docs/public/FIRMAMENT-LANGUAGE-X2.md b/docs/public/FIRMAMENT-LANGUAGE-X2.md
new file mode 100644
index 00000000..82d75b31
--- /dev/null
+++ b/docs/public/FIRMAMENT-LANGUAGE-X2.md
@@ -0,0 +1,11 @@
+# Firmament language service X2
+
+Firmament language intelligence is owned by `Aetheris.Kernel.Firmament`. `FirmamentLanguageService` supplies schema-backed completion. `FirmamentLanguageAnalysisService` supplies token spans, parser diagnostics, hover, bounded source definition, and formatting. These APIs run without BRep materialization and are exposed by `Aetheris.Web.Runtime` as `languageComplete`, `languageAnalyze`, `languageHover`, `languageDefinition`, and `languageFormat`. The npm SDK forwards those operations. Helios calls the page-thread Web/WASM runtime; geometry builds remain in its Worker. The result records carry document, source revision, and offsets so a later LSP adapter can translate them without owning Firmament semantics.
+
+Completion uses generated `FirmamentSemanticSchemas` and existing construct authoring helpers. Model-scope prefixes include legal entry scaffolds for nested constructs such as Helix and Loft. Thread, Perforation, Helix, Loft, Box, and Hole fields are context filtered; bounded choices come from field schema. Selector candidates remain compiled semantic identities in the client, with RuntimeOnly topology excluded.
+
+Analysis classifies source spans in Aetheris and takes live errors from `FirmamentV2Parser.Parse`; it does not run the geometry pipeline. Current source navigation resolves a uniquely named construct declaration in the same source. Hover covers generated construct and field descriptions. The lexical span mapper and declaration lookup are bounded initial projections; they are not a second parser, and they do not claim full symbol resolution or cross-file navigation.
+
+`Format` is one opinionated whitespace formatter in Aetheris. It requires parser admission before and after, preserves token text including comments, and is tested for idempotence and a simple Box model's semantic fields. That is not yet a broad semantic-equivalence proof for all Firmament constructs. Helios therefore exposes Format Document but leaves format-on-build disabled. The formatter refuses invalid input; build always receives the authored source.
+
+Focused language/schema tests: 14 passed. The full Firmament project passed 1,691/1,691 after the completion fix. Aetheris core fast lane: 1,002 passed. The full solution run before that fix exposed the completion regression and an unrelated CLI mesh polygon count failure (905 expected, 908 actual). The full solution gate was not rerun after the fix; the affected Firmament project was.