@lokascript/compilation-service 3.3.0 → 4.0.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.
- package/CHANGELOG.md +162 -0
- package/dist/{chunk-AMTQUPKJ.js → chunk-GWYYJAZY.js} +76 -293
- package/dist/chunk-GWYYJAZY.js.map +1 -0
- package/dist/http.cjs +147 -33187
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.js +2 -22
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +141 -33166
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -45
- package/dist/index.d.ts +3 -45
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/{service-Da54XrEI.d.cts → service-2lEnO5hA.d.cts} +35 -73
- package/dist/{service-Da54XrEI.d.ts → service-2lEnO5hA.d.ts} +35 -73
- package/package.json +11 -7
- package/dist/chunk-AMTQUPKJ.js.map +0 -1
- package/dist/chunk-GBPMR66W.js +0 -23
- package/dist/chunk-GBPMR66W.js.map +0 -1
- package/dist/chunk-IFSCZ7JT.js +0 -85
- package/dist/chunk-IFSCZ7JT.js.map +0 -1
- package/dist/chunk-PEL4Z7TK.js +0 -58
- package/dist/chunk-PEL4Z7TK.js.map +0 -1
- package/dist/core-parser-adapter-W5UPZR4X-QSTMJ42V.js +0 -12
- package/dist/core-parser-adapter-W5UPZR4X-QSTMJ42V.js.map +0 -1
- package/dist/dist-6EMM5HXE.js +0 -4463
- package/dist/dist-6EMM5HXE.js.map +0 -1
- package/dist/dist-OK2I5ODH.js +0 -27680
- package/dist/dist-OK2I5ODH.js.map +0 -1
- package/dist/multilingual-TCFUREGW.js +0 -485
- package/dist/multilingual-TCFUREGW.js.map +0 -1
- package/dist/semantic-adapter-JAAALHRO-WXAFQY4T.js +0 -12
- package/dist/semantic-adapter-JAAALHRO-WXAFQY4T.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InputFormat,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InputFormat, B as BehaviorSpec, A as AbstractOperation, T as TriggerDiff, O as OperationDiff, a as TestRenderer, b as TestRenderOptions, G as GeneratedTest, c as ComponentRenderer, d as ComponentRenderOptions, e as GeneratedComponent } from './service-2lEnO5hA.cjs';
|
|
2
|
+
export { f as AddClassOp, g as AppendContentOp, h as BlurOp, C as CompilationService, i as CompileRequest, j as ComponentRequest, k as ComponentResponse, D as DecrementOp, l as Diagnostic, m as DiffInput, n as DiffRequest, o as DiffResponse, F as FetchOp, p as FocusOp, q as GeneratedTestOutput, H as HideOp, r as IncrementOp, L as LogOp, N as NavigateOp, s as OperationChangeKind, R as RemoveClassOp, S as ScoreRequest, t as ScoreResponse, u as SemanticJSON, v as SemanticJSONValue, w as ServiceOptions, x as SetContentOp, y as SetVariableOp, z as ShowOp, E as TargetRef, J as TestRequest, K as TestResponse, M as ToggleClassOp, P as TranslateRequest, Q as TranslateResponse, U as TriggerEventOp, V as ValidationResponse, W as WaitOp } from './service-2lEnO5hA.cjs';
|
|
3
3
|
export { jsonToSemanticNode, validateSemanticJSON } from '@lokascript/framework/ir';
|
|
4
4
|
export { FidelityReport, FidelityScores, scoreNodes } from '@lokascript/semantic/fidelity';
|
|
5
5
|
|
|
@@ -14,48 +14,6 @@ export { FidelityReport, FidelityScores, scoreNodes } from '@lokascript/semantic
|
|
|
14
14
|
*/
|
|
15
15
|
declare function detectFormat(input: string): InputFormat;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Semantic-keyed LRU cache.
|
|
19
|
-
*
|
|
20
|
-
* Caches compilation results keyed by canonical semantic representation.
|
|
21
|
-
* Different input languages that produce the same semantics hit the same cache.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Simple LRU cache using Map insertion order.
|
|
26
|
-
*/
|
|
27
|
-
declare class SemanticCache {
|
|
28
|
-
private cache;
|
|
29
|
-
private readonly maxSize;
|
|
30
|
-
/** Cache hit/miss statistics */
|
|
31
|
-
hits: number;
|
|
32
|
-
misses: number;
|
|
33
|
-
constructor(maxSize?: number);
|
|
34
|
-
/**
|
|
35
|
-
* Get a cached response, or undefined if not cached.
|
|
36
|
-
*/
|
|
37
|
-
get(key: string): CompileResponse | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Store a response in the cache.
|
|
40
|
-
*/
|
|
41
|
-
set(key: string, value: CompileResponse): void;
|
|
42
|
-
/** Current cache size */
|
|
43
|
-
get size(): number;
|
|
44
|
-
/** Clear all entries */
|
|
45
|
-
clear(): void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Generate a canonical cache key from a semantic node and compilation options.
|
|
49
|
-
*
|
|
50
|
-
* The key is based on semantic identity, not syntax — so the same behavior
|
|
51
|
-
* described in English, Japanese, or explicit syntax produces the same key.
|
|
52
|
-
*/
|
|
53
|
-
declare function generateCacheKey(node: unknown, options: {
|
|
54
|
-
optimization?: number;
|
|
55
|
-
target?: string;
|
|
56
|
-
minify?: boolean;
|
|
57
|
-
}): string;
|
|
58
|
-
|
|
59
17
|
/**
|
|
60
18
|
* Operation Extraction
|
|
61
19
|
*
|
|
@@ -147,4 +105,4 @@ declare class SvelteRenderer implements ComponentRenderer {
|
|
|
147
105
|
render(spec: BehaviorSpec, options?: ComponentRenderOptions): GeneratedComponent;
|
|
148
106
|
}
|
|
149
107
|
|
|
150
|
-
export { AbstractOperation, BehaviorSpec,
|
|
108
|
+
export { AbstractOperation, BehaviorSpec, ComponentRenderOptions, ComponentRenderer, GeneratedComponent, GeneratedTest, InputFormat, OperationDiff, PlaywrightRenderer, ReactRenderer, SvelteRenderer, TestRenderOptions, TestRenderer, TriggerDiff, VueRenderer, canonicalizeOp, detectFormat, diffBehaviors, extractOperations };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InputFormat,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InputFormat, B as BehaviorSpec, A as AbstractOperation, T as TriggerDiff, O as OperationDiff, a as TestRenderer, b as TestRenderOptions, G as GeneratedTest, c as ComponentRenderer, d as ComponentRenderOptions, e as GeneratedComponent } from './service-2lEnO5hA.js';
|
|
2
|
+
export { f as AddClassOp, g as AppendContentOp, h as BlurOp, C as CompilationService, i as CompileRequest, j as ComponentRequest, k as ComponentResponse, D as DecrementOp, l as Diagnostic, m as DiffInput, n as DiffRequest, o as DiffResponse, F as FetchOp, p as FocusOp, q as GeneratedTestOutput, H as HideOp, r as IncrementOp, L as LogOp, N as NavigateOp, s as OperationChangeKind, R as RemoveClassOp, S as ScoreRequest, t as ScoreResponse, u as SemanticJSON, v as SemanticJSONValue, w as ServiceOptions, x as SetContentOp, y as SetVariableOp, z as ShowOp, E as TargetRef, J as TestRequest, K as TestResponse, M as ToggleClassOp, P as TranslateRequest, Q as TranslateResponse, U as TriggerEventOp, V as ValidationResponse, W as WaitOp } from './service-2lEnO5hA.js';
|
|
3
3
|
export { jsonToSemanticNode, validateSemanticJSON } from '@lokascript/framework/ir';
|
|
4
4
|
export { FidelityReport, FidelityScores, scoreNodes } from '@lokascript/semantic/fidelity';
|
|
5
5
|
|
|
@@ -14,48 +14,6 @@ export { FidelityReport, FidelityScores, scoreNodes } from '@lokascript/semantic
|
|
|
14
14
|
*/
|
|
15
15
|
declare function detectFormat(input: string): InputFormat;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Semantic-keyed LRU cache.
|
|
19
|
-
*
|
|
20
|
-
* Caches compilation results keyed by canonical semantic representation.
|
|
21
|
-
* Different input languages that produce the same semantics hit the same cache.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Simple LRU cache using Map insertion order.
|
|
26
|
-
*/
|
|
27
|
-
declare class SemanticCache {
|
|
28
|
-
private cache;
|
|
29
|
-
private readonly maxSize;
|
|
30
|
-
/** Cache hit/miss statistics */
|
|
31
|
-
hits: number;
|
|
32
|
-
misses: number;
|
|
33
|
-
constructor(maxSize?: number);
|
|
34
|
-
/**
|
|
35
|
-
* Get a cached response, or undefined if not cached.
|
|
36
|
-
*/
|
|
37
|
-
get(key: string): CompileResponse | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Store a response in the cache.
|
|
40
|
-
*/
|
|
41
|
-
set(key: string, value: CompileResponse): void;
|
|
42
|
-
/** Current cache size */
|
|
43
|
-
get size(): number;
|
|
44
|
-
/** Clear all entries */
|
|
45
|
-
clear(): void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Generate a canonical cache key from a semantic node and compilation options.
|
|
49
|
-
*
|
|
50
|
-
* The key is based on semantic identity, not syntax — so the same behavior
|
|
51
|
-
* described in English, Japanese, or explicit syntax produces the same key.
|
|
52
|
-
*/
|
|
53
|
-
declare function generateCacheKey(node: unknown, options: {
|
|
54
|
-
optimization?: number;
|
|
55
|
-
target?: string;
|
|
56
|
-
minify?: boolean;
|
|
57
|
-
}): string;
|
|
58
|
-
|
|
59
17
|
/**
|
|
60
18
|
* Operation Extraction
|
|
61
19
|
*
|
|
@@ -147,4 +105,4 @@ declare class SvelteRenderer implements ComponentRenderer {
|
|
|
147
105
|
render(spec: BehaviorSpec, options?: ComponentRenderOptions): GeneratedComponent;
|
|
148
106
|
}
|
|
149
107
|
|
|
150
|
-
export { AbstractOperation, BehaviorSpec,
|
|
108
|
+
export { AbstractOperation, BehaviorSpec, ComponentRenderOptions, ComponentRenderer, GeneratedComponent, GeneratedTest, InputFormat, OperationDiff, PlaywrightRenderer, ReactRenderer, SvelteRenderer, TestRenderOptions, TestRenderer, TriggerDiff, VueRenderer, canonicalizeOp, detectFormat, diffBehaviors, extractOperations };
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,14 @@ import {
|
|
|
2
2
|
CompilationService,
|
|
3
3
|
PlaywrightRenderer,
|
|
4
4
|
ReactRenderer,
|
|
5
|
-
SemanticCache,
|
|
6
5
|
SvelteRenderer,
|
|
7
6
|
VueRenderer,
|
|
8
7
|
canonicalizeOp,
|
|
9
8
|
detectFormat,
|
|
10
9
|
diffBehaviors,
|
|
11
10
|
extractOperations,
|
|
12
|
-
generateCacheKey,
|
|
13
11
|
scoreNodes
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-GBPMR66W.js";
|
|
12
|
+
} from "./chunk-GWYYJAZY.js";
|
|
16
13
|
|
|
17
14
|
// src/input/json-schema.ts
|
|
18
15
|
import {
|
|
@@ -24,14 +21,12 @@ export {
|
|
|
24
21
|
CompilationService,
|
|
25
22
|
PlaywrightRenderer,
|
|
26
23
|
ReactRenderer,
|
|
27
|
-
SemanticCache,
|
|
28
24
|
SvelteRenderer,
|
|
29
25
|
VueRenderer,
|
|
30
26
|
canonicalizeOp,
|
|
31
27
|
detectFormat,
|
|
32
28
|
diffBehaviors,
|
|
33
29
|
extractOperations,
|
|
34
|
-
generateCacheKey,
|
|
35
30
|
jsonToSemanticNode,
|
|
36
31
|
scoreNodes,
|
|
37
32
|
validateSemanticJSON
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/input/json-schema.ts"],"sourcesContent":["/**\n * LLM JSON input validation and conversion.\n *\n * Re-exports from @lokascript/framework/ir — the canonical IR layer.\n */\n\nexport {\n validateSemanticJSON,\n jsonToSemanticNode,\n semanticNodeToJSON,\n} from '@lokascript/framework/ir';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/input/json-schema.ts"],"sourcesContent":["/**\n * LLM JSON input validation and conversion.\n *\n * Re-exports from @lokascript/framework/ir — the canonical IR layer.\n */\n\nexport {\n validateSemanticJSON,\n jsonToSemanticNode,\n semanticNodeToJSON,\n} from '@lokascript/framework/ir';\n"],"mappings":";;;;;;;;;;;;;;AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
@@ -187,14 +187,10 @@ interface TestRenderer {
|
|
|
187
187
|
interface TestRenderOptions {
|
|
188
188
|
/** Override auto-generated test name */
|
|
189
189
|
testName?: string;
|
|
190
|
-
/**
|
|
191
|
-
executionMode?: 'runtime' | 'compiled';
|
|
192
|
-
/** Path to LokaScript bundle (runtime mode) */
|
|
190
|
+
/** Path to the hyperscript bundle (default: @hyperfixi/engine's hyperfixi-hs.js) */
|
|
193
191
|
bundlePath?: string;
|
|
194
192
|
/** Original hyperscript source (for embedding in fixture) */
|
|
195
193
|
hyperscript?: string;
|
|
196
|
-
/** Compiled JS code (for compiled mode) */
|
|
197
|
-
compiledJs?: string;
|
|
198
194
|
}
|
|
199
195
|
/**
|
|
200
196
|
* A generated test file.
|
|
@@ -289,7 +285,7 @@ interface OperationDiff {
|
|
|
289
285
|
*/
|
|
290
286
|
|
|
291
287
|
/** Score request — a candidate scored against a reference. Sides accept the
|
|
292
|
-
* same input formats as diff/
|
|
288
|
+
* same input formats as diff/validate and may be in different languages. */
|
|
293
289
|
interface ScoreRequest {
|
|
294
290
|
reference: DiffInput;
|
|
295
291
|
candidate: DiffInput;
|
|
@@ -312,13 +308,17 @@ interface ScoreResponse extends Partial<FidelityReport> {
|
|
|
312
308
|
/**
|
|
313
309
|
* Types for the Compilation Service.
|
|
314
310
|
*
|
|
315
|
-
* Three input formats converge to
|
|
311
|
+
* Three input formats converge to one semantic node, which the service validates,
|
|
312
|
+
* translates, diffs, scores, and renders as components and tests:
|
|
316
313
|
* - Natural language hyperscript (24 languages)
|
|
317
314
|
* - Explicit syntax: [toggle patient:.active destination:#btn]
|
|
318
315
|
* - LLM JSON: { action: "toggle", roles: { patient: { type: "selector", value: ".active" } } }
|
|
319
316
|
*/
|
|
320
317
|
/**
|
|
321
|
-
*
|
|
318
|
+
* Hyperscript input — provide exactly one of: code, explicit, or semantic.
|
|
319
|
+
*
|
|
320
|
+
* (The name is from when the service also compiled hyperscript to JavaScript,
|
|
321
|
+
* through `@hyperfixi/aot-compiler`; that retired with the AOT compiler in 4.0.)
|
|
322
322
|
*/
|
|
323
323
|
interface CompileRequest {
|
|
324
324
|
/** Natural language hyperscript (requires `language`) */
|
|
@@ -331,12 +331,6 @@ interface CompileRequest {
|
|
|
331
331
|
language?: string;
|
|
332
332
|
/** Minimum confidence for natural language parsing (default 0.7) */
|
|
333
333
|
confidence?: number;
|
|
334
|
-
/** Optimization level: 0=none, 1=basic, 2=full (default 2) */
|
|
335
|
-
optimization?: 0 | 1 | 2;
|
|
336
|
-
/** Output module format (default 'esm') */
|
|
337
|
-
target?: 'esm' | 'iife';
|
|
338
|
-
/** Minify output (default false) */
|
|
339
|
-
minify?: boolean;
|
|
340
334
|
}
|
|
341
335
|
/**
|
|
342
336
|
* Translation request.
|
|
@@ -355,26 +349,7 @@ interface TranslateRequest {
|
|
|
355
349
|
type SemanticJSON = SemanticJSON$1;
|
|
356
350
|
type SemanticJSONValue = SemanticJSONValue$1;
|
|
357
351
|
/**
|
|
358
|
-
*
|
|
359
|
-
*/
|
|
360
|
-
interface CompileResponse {
|
|
361
|
-
/** Whether compilation succeeded */
|
|
362
|
-
ok: boolean;
|
|
363
|
-
/** Compiled JavaScript (on success) */
|
|
364
|
-
js?: string;
|
|
365
|
-
/** Runtime helpers needed by the compiled code */
|
|
366
|
-
helpers?: string[];
|
|
367
|
-
/** Output size in bytes */
|
|
368
|
-
size?: number;
|
|
369
|
-
/** Normalized semantic representation (always present on success) */
|
|
370
|
-
semantic?: SemanticJSON;
|
|
371
|
-
/** Parse confidence (natural language input only) */
|
|
372
|
-
confidence?: number;
|
|
373
|
-
/** Errors, warnings, and info messages */
|
|
374
|
-
diagnostics: Diagnostic[];
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Validation-only response (no compilation).
|
|
352
|
+
* Validation response.
|
|
378
353
|
*/
|
|
379
354
|
interface ValidationResponse {
|
|
380
355
|
/** Whether validation passed */
|
|
@@ -436,11 +411,9 @@ interface TestRequest {
|
|
|
436
411
|
confidence?: number;
|
|
437
412
|
/** Test framework to target (default 'playwright') */
|
|
438
413
|
framework?: string;
|
|
439
|
-
/** How to load hyperscript in the test (default 'runtime') */
|
|
440
|
-
executionMode?: 'runtime' | 'compiled';
|
|
441
414
|
/** Override auto-generated test name */
|
|
442
415
|
testName?: string;
|
|
443
|
-
/** Path to
|
|
416
|
+
/** Path to the hyperscript bundle (default: @hyperfixi/engine's hyperfixi-hs.js) */
|
|
444
417
|
bundlePath?: string;
|
|
445
418
|
}
|
|
446
419
|
/**
|
|
@@ -527,14 +500,14 @@ interface GenerateRequest {
|
|
|
527
500
|
/** LSE attempt — bracket syntax `[command role:value ...]` or protocol JSON string */
|
|
528
501
|
lse: string;
|
|
529
502
|
/**
|
|
530
|
-
* Output target (default 'js'
|
|
531
|
-
*
|
|
503
|
+
* Output target (required since 4.0, when the default, 'js', retired with the
|
|
504
|
+
* AOT compiler):
|
|
532
505
|
* - 'react' — React component
|
|
533
506
|
* - 'vue' — Vue component
|
|
534
507
|
* - 'svelte' — Svelte component
|
|
535
508
|
* - 'intent-element' — HTML snippet with `<lse-intent>` and embedded JSON
|
|
536
509
|
*/
|
|
537
|
-
target
|
|
510
|
+
target: 'react' | 'vue' | 'svelte' | 'intent-element';
|
|
538
511
|
/** Optional task description — included as a comment in intent-element output */
|
|
539
512
|
task?: string;
|
|
540
513
|
}
|
|
@@ -544,7 +517,7 @@ interface GenerateRequest {
|
|
|
544
517
|
interface GenerateResponse {
|
|
545
518
|
/** Whether generation succeeded */
|
|
546
519
|
ok: boolean;
|
|
547
|
-
/** Rendered output (
|
|
520
|
+
/** Rendered output (JSX, Vue SFC, Svelte, or HTML snippet) */
|
|
548
521
|
output?: string;
|
|
549
522
|
/** Normalized protocol JSON (always present on success) */
|
|
550
523
|
protocol?: SemanticJSON;
|
|
@@ -558,8 +531,6 @@ interface GenerateResponse {
|
|
|
558
531
|
interface ServiceOptions {
|
|
559
532
|
/** Default confidence threshold (default 0.7) */
|
|
560
533
|
confidenceThreshold?: number;
|
|
561
|
-
/** Maximum cache entries (default 500, 0 to disable) */
|
|
562
|
-
cacheSize?: number;
|
|
563
534
|
/** Custom test renderers keyed by framework name (default: { playwright: PlaywrightRenderer }) */
|
|
564
535
|
testRenderers?: Record<string, TestRenderer>;
|
|
565
536
|
/** Custom component renderers keyed by framework name (default: { react: ReactRenderer }) */
|
|
@@ -572,14 +543,22 @@ type InputFormat = 'natural' | 'explicit' | 'json';
|
|
|
572
543
|
* CompilationService — the main orchestrator.
|
|
573
544
|
*
|
|
574
545
|
* Accepts hyperscript in three formats (natural language, explicit syntax, LLM JSON),
|
|
575
|
-
* validates through semantic schemas, and
|
|
546
|
+
* validates it through semantic schemas and the engine, and translates, diffs, scores, and
|
|
547
|
+
* renders it as components and tests. (It compiled to JavaScript through
|
|
548
|
+
* `@hyperfixi/aot-compiler` until 4.0, when the AOT compiler retired.)
|
|
576
549
|
*/
|
|
577
550
|
|
|
578
551
|
declare class CompilationService {
|
|
579
|
-
private cache;
|
|
580
552
|
private confidenceThreshold;
|
|
581
553
|
private translateFn;
|
|
582
554
|
private translationCollisionsFn;
|
|
555
|
+
/** semantic's `render`, for the English a translation runs as. */
|
|
556
|
+
private renderFn;
|
|
557
|
+
/**
|
|
558
|
+
* `@hyperfixi/engine`'s first parse error for a source (null: it parses). Set by create()
|
|
559
|
+
* when the engine is installed (an optional peer); without it there is no engine check.
|
|
560
|
+
*/
|
|
561
|
+
private engineError;
|
|
583
562
|
private testRenderers;
|
|
584
563
|
private componentRenderers;
|
|
585
564
|
private constructor();
|
|
@@ -594,23 +573,20 @@ declare class CompilationService {
|
|
|
594
573
|
/**
|
|
595
574
|
* Create a CompilationService by dynamically importing dependencies.
|
|
596
575
|
*
|
|
597
|
-
* This async factory resolves @lokascript/semantic and
|
|
598
|
-
* at runtime
|
|
576
|
+
* This async factory resolves @lokascript/semantic (and, when it is installed,
|
|
577
|
+
* @hyperfixi/engine) at runtime.
|
|
599
578
|
*/
|
|
600
579
|
static create(options?: ServiceOptions): Promise<CompilationService>;
|
|
601
580
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* - `explicit`: Bracket syntax [command role:value ...]
|
|
607
|
-
* - `semantic`: LLM JSON { action, roles, trigger }
|
|
608
|
-
*
|
|
609
|
-
* Returns compiled JS, semantic representation, and diagnostics.
|
|
581
|
+
* The engine's verdict on natural-language input: its parse of the English the page would
|
|
582
|
+
* run — the source as written, or a translation's English render (what
|
|
583
|
+
* `@lokascript/hyperscript-adapter` hands the engine). Null when it parses, or when there is
|
|
584
|
+
* nothing to check (explicit / JSON input, or no engine installed).
|
|
610
585
|
*/
|
|
611
|
-
|
|
586
|
+
private engineDiagnostic;
|
|
612
587
|
/**
|
|
613
|
-
* Validate input
|
|
588
|
+
* Validate input: semantic's parse and schemas, and (for natural-language input) the
|
|
589
|
+
* engine's parse of the English the page would run.
|
|
614
590
|
* Returns semantic representation and diagnostics.
|
|
615
591
|
*/
|
|
616
592
|
validate(request: CompileRequest): ValidationResponse;
|
|
@@ -660,27 +636,13 @@ declare class CompilationService {
|
|
|
660
636
|
* Accepts LSE produced by an LLM (via `lse_generate_with_correction` MCP tool),
|
|
661
637
|
* validates it, and renders to the requested target format.
|
|
662
638
|
*
|
|
663
|
-
* Targets:
|
|
664
|
-
* - 'js' — compiled JavaScript (default)
|
|
639
|
+
* Targets (`target` is required):
|
|
665
640
|
* - 'react' — React component
|
|
666
641
|
* - 'vue' — Vue component
|
|
667
642
|
* - 'svelte' — Svelte component
|
|
668
643
|
* - 'intent-element' — HTML snippet with embedded `<lse-intent>` JSON
|
|
669
644
|
*/
|
|
670
645
|
generate(request: GenerateRequest): Promise<GenerateResponse>;
|
|
671
|
-
/**
|
|
672
|
-
* Get cache statistics.
|
|
673
|
-
*/
|
|
674
|
-
getCacheStats(): {
|
|
675
|
-
size: number;
|
|
676
|
-
hits: number;
|
|
677
|
-
misses: number;
|
|
678
|
-
hitRate: number;
|
|
679
|
-
};
|
|
680
|
-
/**
|
|
681
|
-
* Clear the compilation cache.
|
|
682
|
-
*/
|
|
683
|
-
clearCache(): void;
|
|
684
646
|
}
|
|
685
647
|
|
|
686
|
-
export { type AbstractOperation as A, type BehaviorSpec as B, CompilationService as C, type DecrementOp as D, type
|
|
648
|
+
export { type AbstractOperation as A, type BehaviorSpec as B, CompilationService as C, type DecrementOp as D, type TargetRef as E, type FetchOp as F, type GeneratedTest as G, type HideOp as H, type InputFormat as I, type TestRequest as J, type TestResponse as K, type LogOp as L, type ToggleClassOp as M, type NavigateOp as N, type OperationDiff as O, type TranslateRequest as P, type TranslateResponse as Q, type RemoveClassOp as R, type ScoreRequest as S, type TriggerDiff as T, type TriggerEventOp as U, type ValidationResponse as V, type WaitOp as W, type TestRenderer as a, type TestRenderOptions as b, type ComponentRenderer as c, type ComponentRenderOptions as d, type GeneratedComponent as e, type AddClassOp as f, type AppendContentOp as g, type BlurOp as h, type CompileRequest as i, type ComponentRequest as j, type ComponentResponse as k, type Diagnostic as l, type DiffInput as m, type DiffRequest as n, type DiffResponse as o, type FocusOp as p, type GeneratedTestOutput as q, type IncrementOp as r, type OperationChangeKind as s, type ScoreResponse as t, type SemanticJSON as u, type SemanticJSONValue as v, type ServiceOptions as w, type SetContentOp as x, type SetVariableOp as y, type ShowOp as z };
|
|
@@ -187,14 +187,10 @@ interface TestRenderer {
|
|
|
187
187
|
interface TestRenderOptions {
|
|
188
188
|
/** Override auto-generated test name */
|
|
189
189
|
testName?: string;
|
|
190
|
-
/**
|
|
191
|
-
executionMode?: 'runtime' | 'compiled';
|
|
192
|
-
/** Path to LokaScript bundle (runtime mode) */
|
|
190
|
+
/** Path to the hyperscript bundle (default: @hyperfixi/engine's hyperfixi-hs.js) */
|
|
193
191
|
bundlePath?: string;
|
|
194
192
|
/** Original hyperscript source (for embedding in fixture) */
|
|
195
193
|
hyperscript?: string;
|
|
196
|
-
/** Compiled JS code (for compiled mode) */
|
|
197
|
-
compiledJs?: string;
|
|
198
194
|
}
|
|
199
195
|
/**
|
|
200
196
|
* A generated test file.
|
|
@@ -289,7 +285,7 @@ interface OperationDiff {
|
|
|
289
285
|
*/
|
|
290
286
|
|
|
291
287
|
/** Score request — a candidate scored against a reference. Sides accept the
|
|
292
|
-
* same input formats as diff/
|
|
288
|
+
* same input formats as diff/validate and may be in different languages. */
|
|
293
289
|
interface ScoreRequest {
|
|
294
290
|
reference: DiffInput;
|
|
295
291
|
candidate: DiffInput;
|
|
@@ -312,13 +308,17 @@ interface ScoreResponse extends Partial<FidelityReport> {
|
|
|
312
308
|
/**
|
|
313
309
|
* Types for the Compilation Service.
|
|
314
310
|
*
|
|
315
|
-
* Three input formats converge to
|
|
311
|
+
* Three input formats converge to one semantic node, which the service validates,
|
|
312
|
+
* translates, diffs, scores, and renders as components and tests:
|
|
316
313
|
* - Natural language hyperscript (24 languages)
|
|
317
314
|
* - Explicit syntax: [toggle patient:.active destination:#btn]
|
|
318
315
|
* - LLM JSON: { action: "toggle", roles: { patient: { type: "selector", value: ".active" } } }
|
|
319
316
|
*/
|
|
320
317
|
/**
|
|
321
|
-
*
|
|
318
|
+
* Hyperscript input — provide exactly one of: code, explicit, or semantic.
|
|
319
|
+
*
|
|
320
|
+
* (The name is from when the service also compiled hyperscript to JavaScript,
|
|
321
|
+
* through `@hyperfixi/aot-compiler`; that retired with the AOT compiler in 4.0.)
|
|
322
322
|
*/
|
|
323
323
|
interface CompileRequest {
|
|
324
324
|
/** Natural language hyperscript (requires `language`) */
|
|
@@ -331,12 +331,6 @@ interface CompileRequest {
|
|
|
331
331
|
language?: string;
|
|
332
332
|
/** Minimum confidence for natural language parsing (default 0.7) */
|
|
333
333
|
confidence?: number;
|
|
334
|
-
/** Optimization level: 0=none, 1=basic, 2=full (default 2) */
|
|
335
|
-
optimization?: 0 | 1 | 2;
|
|
336
|
-
/** Output module format (default 'esm') */
|
|
337
|
-
target?: 'esm' | 'iife';
|
|
338
|
-
/** Minify output (default false) */
|
|
339
|
-
minify?: boolean;
|
|
340
334
|
}
|
|
341
335
|
/**
|
|
342
336
|
* Translation request.
|
|
@@ -355,26 +349,7 @@ interface TranslateRequest {
|
|
|
355
349
|
type SemanticJSON = SemanticJSON$1;
|
|
356
350
|
type SemanticJSONValue = SemanticJSONValue$1;
|
|
357
351
|
/**
|
|
358
|
-
*
|
|
359
|
-
*/
|
|
360
|
-
interface CompileResponse {
|
|
361
|
-
/** Whether compilation succeeded */
|
|
362
|
-
ok: boolean;
|
|
363
|
-
/** Compiled JavaScript (on success) */
|
|
364
|
-
js?: string;
|
|
365
|
-
/** Runtime helpers needed by the compiled code */
|
|
366
|
-
helpers?: string[];
|
|
367
|
-
/** Output size in bytes */
|
|
368
|
-
size?: number;
|
|
369
|
-
/** Normalized semantic representation (always present on success) */
|
|
370
|
-
semantic?: SemanticJSON;
|
|
371
|
-
/** Parse confidence (natural language input only) */
|
|
372
|
-
confidence?: number;
|
|
373
|
-
/** Errors, warnings, and info messages */
|
|
374
|
-
diagnostics: Diagnostic[];
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Validation-only response (no compilation).
|
|
352
|
+
* Validation response.
|
|
378
353
|
*/
|
|
379
354
|
interface ValidationResponse {
|
|
380
355
|
/** Whether validation passed */
|
|
@@ -436,11 +411,9 @@ interface TestRequest {
|
|
|
436
411
|
confidence?: number;
|
|
437
412
|
/** Test framework to target (default 'playwright') */
|
|
438
413
|
framework?: string;
|
|
439
|
-
/** How to load hyperscript in the test (default 'runtime') */
|
|
440
|
-
executionMode?: 'runtime' | 'compiled';
|
|
441
414
|
/** Override auto-generated test name */
|
|
442
415
|
testName?: string;
|
|
443
|
-
/** Path to
|
|
416
|
+
/** Path to the hyperscript bundle (default: @hyperfixi/engine's hyperfixi-hs.js) */
|
|
444
417
|
bundlePath?: string;
|
|
445
418
|
}
|
|
446
419
|
/**
|
|
@@ -527,14 +500,14 @@ interface GenerateRequest {
|
|
|
527
500
|
/** LSE attempt — bracket syntax `[command role:value ...]` or protocol JSON string */
|
|
528
501
|
lse: string;
|
|
529
502
|
/**
|
|
530
|
-
* Output target (default 'js'
|
|
531
|
-
*
|
|
503
|
+
* Output target (required since 4.0, when the default, 'js', retired with the
|
|
504
|
+
* AOT compiler):
|
|
532
505
|
* - 'react' — React component
|
|
533
506
|
* - 'vue' — Vue component
|
|
534
507
|
* - 'svelte' — Svelte component
|
|
535
508
|
* - 'intent-element' — HTML snippet with `<lse-intent>` and embedded JSON
|
|
536
509
|
*/
|
|
537
|
-
target
|
|
510
|
+
target: 'react' | 'vue' | 'svelte' | 'intent-element';
|
|
538
511
|
/** Optional task description — included as a comment in intent-element output */
|
|
539
512
|
task?: string;
|
|
540
513
|
}
|
|
@@ -544,7 +517,7 @@ interface GenerateRequest {
|
|
|
544
517
|
interface GenerateResponse {
|
|
545
518
|
/** Whether generation succeeded */
|
|
546
519
|
ok: boolean;
|
|
547
|
-
/** Rendered output (
|
|
520
|
+
/** Rendered output (JSX, Vue SFC, Svelte, or HTML snippet) */
|
|
548
521
|
output?: string;
|
|
549
522
|
/** Normalized protocol JSON (always present on success) */
|
|
550
523
|
protocol?: SemanticJSON;
|
|
@@ -558,8 +531,6 @@ interface GenerateResponse {
|
|
|
558
531
|
interface ServiceOptions {
|
|
559
532
|
/** Default confidence threshold (default 0.7) */
|
|
560
533
|
confidenceThreshold?: number;
|
|
561
|
-
/** Maximum cache entries (default 500, 0 to disable) */
|
|
562
|
-
cacheSize?: number;
|
|
563
534
|
/** Custom test renderers keyed by framework name (default: { playwright: PlaywrightRenderer }) */
|
|
564
535
|
testRenderers?: Record<string, TestRenderer>;
|
|
565
536
|
/** Custom component renderers keyed by framework name (default: { react: ReactRenderer }) */
|
|
@@ -572,14 +543,22 @@ type InputFormat = 'natural' | 'explicit' | 'json';
|
|
|
572
543
|
* CompilationService — the main orchestrator.
|
|
573
544
|
*
|
|
574
545
|
* Accepts hyperscript in three formats (natural language, explicit syntax, LLM JSON),
|
|
575
|
-
* validates through semantic schemas, and
|
|
546
|
+
* validates it through semantic schemas and the engine, and translates, diffs, scores, and
|
|
547
|
+
* renders it as components and tests. (It compiled to JavaScript through
|
|
548
|
+
* `@hyperfixi/aot-compiler` until 4.0, when the AOT compiler retired.)
|
|
576
549
|
*/
|
|
577
550
|
|
|
578
551
|
declare class CompilationService {
|
|
579
|
-
private cache;
|
|
580
552
|
private confidenceThreshold;
|
|
581
553
|
private translateFn;
|
|
582
554
|
private translationCollisionsFn;
|
|
555
|
+
/** semantic's `render`, for the English a translation runs as. */
|
|
556
|
+
private renderFn;
|
|
557
|
+
/**
|
|
558
|
+
* `@hyperfixi/engine`'s first parse error for a source (null: it parses). Set by create()
|
|
559
|
+
* when the engine is installed (an optional peer); without it there is no engine check.
|
|
560
|
+
*/
|
|
561
|
+
private engineError;
|
|
583
562
|
private testRenderers;
|
|
584
563
|
private componentRenderers;
|
|
585
564
|
private constructor();
|
|
@@ -594,23 +573,20 @@ declare class CompilationService {
|
|
|
594
573
|
/**
|
|
595
574
|
* Create a CompilationService by dynamically importing dependencies.
|
|
596
575
|
*
|
|
597
|
-
* This async factory resolves @lokascript/semantic and
|
|
598
|
-
* at runtime
|
|
576
|
+
* This async factory resolves @lokascript/semantic (and, when it is installed,
|
|
577
|
+
* @hyperfixi/engine) at runtime.
|
|
599
578
|
*/
|
|
600
579
|
static create(options?: ServiceOptions): Promise<CompilationService>;
|
|
601
580
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* - `explicit`: Bracket syntax [command role:value ...]
|
|
607
|
-
* - `semantic`: LLM JSON { action, roles, trigger }
|
|
608
|
-
*
|
|
609
|
-
* Returns compiled JS, semantic representation, and diagnostics.
|
|
581
|
+
* The engine's verdict on natural-language input: its parse of the English the page would
|
|
582
|
+
* run — the source as written, or a translation's English render (what
|
|
583
|
+
* `@lokascript/hyperscript-adapter` hands the engine). Null when it parses, or when there is
|
|
584
|
+
* nothing to check (explicit / JSON input, or no engine installed).
|
|
610
585
|
*/
|
|
611
|
-
|
|
586
|
+
private engineDiagnostic;
|
|
612
587
|
/**
|
|
613
|
-
* Validate input
|
|
588
|
+
* Validate input: semantic's parse and schemas, and (for natural-language input) the
|
|
589
|
+
* engine's parse of the English the page would run.
|
|
614
590
|
* Returns semantic representation and diagnostics.
|
|
615
591
|
*/
|
|
616
592
|
validate(request: CompileRequest): ValidationResponse;
|
|
@@ -660,27 +636,13 @@ declare class CompilationService {
|
|
|
660
636
|
* Accepts LSE produced by an LLM (via `lse_generate_with_correction` MCP tool),
|
|
661
637
|
* validates it, and renders to the requested target format.
|
|
662
638
|
*
|
|
663
|
-
* Targets:
|
|
664
|
-
* - 'js' — compiled JavaScript (default)
|
|
639
|
+
* Targets (`target` is required):
|
|
665
640
|
* - 'react' — React component
|
|
666
641
|
* - 'vue' — Vue component
|
|
667
642
|
* - 'svelte' — Svelte component
|
|
668
643
|
* - 'intent-element' — HTML snippet with embedded `<lse-intent>` JSON
|
|
669
644
|
*/
|
|
670
645
|
generate(request: GenerateRequest): Promise<GenerateResponse>;
|
|
671
|
-
/**
|
|
672
|
-
* Get cache statistics.
|
|
673
|
-
*/
|
|
674
|
-
getCacheStats(): {
|
|
675
|
-
size: number;
|
|
676
|
-
hits: number;
|
|
677
|
-
misses: number;
|
|
678
|
-
hitRate: number;
|
|
679
|
-
};
|
|
680
|
-
/**
|
|
681
|
-
* Clear the compilation cache.
|
|
682
|
-
*/
|
|
683
|
-
clearCache(): void;
|
|
684
646
|
}
|
|
685
647
|
|
|
686
|
-
export { type AbstractOperation as A, type BehaviorSpec as B, CompilationService as C, type DecrementOp as D, type
|
|
648
|
+
export { type AbstractOperation as A, type BehaviorSpec as B, CompilationService as C, type DecrementOp as D, type TargetRef as E, type FetchOp as F, type GeneratedTest as G, type HideOp as H, type InputFormat as I, type TestRequest as J, type TestResponse as K, type LogOp as L, type ToggleClassOp as M, type NavigateOp as N, type OperationDiff as O, type TranslateRequest as P, type TranslateResponse as Q, type RemoveClassOp as R, type ScoreRequest as S, type TriggerDiff as T, type TriggerEventOp as U, type ValidationResponse as V, type WaitOp as W, type TestRenderer as a, type TestRenderOptions as b, type ComponentRenderer as c, type ComponentRenderOptions as d, type GeneratedComponent as e, type AddClassOp as f, type AppendContentOp as g, type BlurOp as h, type CompileRequest as i, type ComponentRequest as j, type ComponentResponse as k, type Diagnostic as l, type DiffInput as m, type DiffRequest as n, type DiffResponse as o, type FocusOp as p, type GeneratedTestOutput as q, type IncrementOp as r, type OperationChangeKind as s, type ScoreResponse as t, type SemanticJSON as u, type SemanticJSONValue as v, type ServiceOptions as w, type SetContentOp as x, type SetVariableOp as y, type ShowOp as z };
|