@lokascript/compilation-service 2.9.4 → 2.11.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 CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.10.0] - 2026-08-01
11
+
12
+ Full notes: [GitHub Releases](https://github.com/codetalcott/hyperfixi/releases/tag/v2.10.0).
13
+
14
+ Highlights: `swap`/`process`/`morph … using view transition` across all 24
15
+ languages (#870, #873, #875), typed command registration (#869, #871),
16
+ `tell`/`process` parser fixes (#861, #872), the R1 role-fidelity burn-down
17
+ (#864, #867, #868, #874, #878), and guards for the remaining hand-maintained
18
+ CI package lists (#862, #865).
19
+
20
+ ## [2.9.0] - 2026-07-25
21
+
22
+ > **Gap note:** 2.9.1 through 2.9.4 shipped without entries in this file; their
23
+ > details live in [GitHub Releases](https://github.com/codetalcott/hyperfixi/releases).
24
+
10
25
  ### ⚠ BREAKING (types)
11
26
 
12
27
  - **Domain renderers return `string | null`.** `renderSQL`, `renderJSX`, `renderTodo`,
@@ -379,7 +394,12 @@ _Synchronized version release. See git history for details._
379
394
  - npm access token stored in GitHub Secrets
380
395
  - 2FA recommended for npm organization
381
396
 
382
- [Unreleased]: https://github.com/codetalcott/hyperfixi/compare/v2.4.0...HEAD
397
+ [Unreleased]: https://github.com/codetalcott/hyperfixi/compare/v2.10.0...HEAD
398
+ [2.10.0]: https://github.com/codetalcott/hyperfixi/compare/v2.9.0...v2.10.0
399
+ [2.9.0]: https://github.com/codetalcott/hyperfixi/compare/v2.8.0...v2.9.0
400
+ [2.8.0]: https://github.com/codetalcott/hyperfixi/compare/v2.5.1...v2.8.0
401
+ [2.5.1]: https://github.com/codetalcott/hyperfixi/compare/v2.5.0...v2.5.1
402
+ [2.5.0]: https://github.com/codetalcott/hyperfixi/compare/v2.4.0...v2.5.0
383
403
  [2.4.0]: https://github.com/codetalcott/hyperfixi/compare/v2.3.1...v2.4.0
384
404
  [2.3.1]: https://github.com/codetalcott/hyperfixi/compare/v2.3.0...v2.3.1
385
405
  [2.3.0]: https://github.com/codetalcott/hyperfixi/compare/v2.2.1...v2.3.0
@@ -250,6 +250,9 @@ function generateSummary(trigger, opDiffs) {
250
250
  return parts.join(". ");
251
251
  }
252
252
 
253
+ // src/scoring/score.ts
254
+ import { scoreNodes } from "@lokascript/semantic/fidelity";
255
+
253
256
  // src/input/detect.ts
254
257
  function detectFormat(input) {
255
258
  const trimmed = input.trim();
@@ -2504,6 +2507,23 @@ function normalize(request) {
2504
2507
  return normalizeNatural(input, request.language ?? "en");
2505
2508
  }
2506
2509
  }
2510
+ function liftNodeDiagnostics(node, diagnostics) {
2511
+ const nodeDiags = node.diagnostics;
2512
+ if (!Array.isArray(nodeDiags)) return;
2513
+ for (const d of nodeDiags) {
2514
+ if (d.severity !== "warning" && d.severity !== "error") continue;
2515
+ const diag = {
2516
+ severity: d.severity,
2517
+ // Parser codes are kebab-case; this surface uses UPPER_SNAKE (PARSE_ERROR &c).
2518
+ code: (d.code ?? "PARSE_DIAGNOSTIC").replace(/-/g, "_").toUpperCase(),
2519
+ message: d.message ?? "parser diagnostic"
2520
+ };
2521
+ if (d.code === "unconsumed-input") {
2522
+ diag.suggestion = "Dropped tokens were parsed but bound to no role \u2014 usually a missing role marker (e.g. 'to'/'on'/'from' before the target), so the role fell back to a default like `me`. Compare the returned roles against your intent.";
2523
+ }
2524
+ diagnostics.push(diag);
2525
+ }
2526
+ }
2507
2527
  function normalizeNatural(code, language) {
2508
2528
  const diagnostics = [];
2509
2529
  try {
@@ -2524,6 +2544,7 @@ function normalizeNatural(code, language) {
2524
2544
  });
2525
2545
  return { node: null, confidence: result.confidence, format: "natural", diagnostics };
2526
2546
  }
2547
+ liftNodeDiagnostics(result.node, diagnostics);
2527
2548
  return {
2528
2549
  node: result.node,
2529
2550
  confidence: result.confidence,
@@ -2581,6 +2602,66 @@ function normalizeJSON(input) {
2581
2602
  };
2582
2603
  }
2583
2604
 
2605
+ // src/validation/inert-shapes.ts
2606
+ var QUANTIFIER = /^(all|every|each)\.(\S+)$/;
2607
+ var PREDICATE_AS_CLASS = /(^|\s)\.(has|is|contains|matches|includes)(\s|$)/;
2608
+ function valueString(v) {
2609
+ return String(v.value ?? v.raw ?? "");
2610
+ }
2611
+ function checkInertShapes(node) {
2612
+ const out = [];
2613
+ walk(node, out);
2614
+ return out;
2615
+ }
2616
+ function walk(node, out) {
2617
+ if (!node || typeof node !== "object") return;
2618
+ const n = node;
2619
+ if (n.roles && typeof n.roles.entries === "function") {
2620
+ for (const [role, raw] of n.roles.entries()) {
2621
+ const v = raw ?? {};
2622
+ const s = valueString(v);
2623
+ const q = v.type === "expression" ? QUANTIFIER.exec(s) : null;
2624
+ if (q && (role === "destination" || role === "source")) {
2625
+ out.push({
2626
+ severity: "warning",
2627
+ code: "INERT_QUANTIFIER_TARGET",
2628
+ message: `${role} parsed as property access "${s}" \u2014 "${q[1]}" is an undefined identifier at runtime, so this ${role} will not resolve.`,
2629
+ suggestion: `Selectors already address every match: write the bare selector (e.g. ".${q[2]}") without "${q[1]}".`
2630
+ });
2631
+ continue;
2632
+ }
2633
+ if (role === "condition" && v.type === "expression" && PREDICATE_AS_CLASS.test(s)) {
2634
+ const word = PREDICATE_AS_CLASS.exec(s)?.[2];
2635
+ out.push({
2636
+ severity: "warning",
2637
+ code: "HALF_PARSED_CONDITION",
2638
+ message: `condition parsed ".${word}" as a class selector (full condition: "${s}") \u2014 it will evaluate falsy and the body will never run.`,
2639
+ suggestion: "For class tests use `matches`: `if #box matches .danger`."
2640
+ });
2641
+ continue;
2642
+ }
2643
+ if (v.type === "selector" && s.startsWith("<")) {
2644
+ out.push({
2645
+ severity: "warning",
2646
+ code: "UNSUPPORTED_QUERY_LITERAL",
2647
+ message: `${role} selector "${s}" uses query-literal syntax, which this parser does not support \u2014 at runtime it is an invalid CSS selector and matches nothing.`,
2648
+ suggestion: `Use a plain CSS selector instead (e.g. "${s.replace(/^<|\/?>$/g, "")}").`
2649
+ });
2650
+ continue;
2651
+ }
2652
+ if (n.action === "set" && v.type === "property-path" && v.property === "text") {
2653
+ out.push({
2654
+ severity: "warning",
2655
+ code: "INERT_PROPERTY_WRITE",
2656
+ message: `set targets property "text" \u2014 on most elements this is not a DOM property, so the write usually changes nothing visible.`,
2657
+ suggestion: 'Use `textContent` (`set the textContent of #el to \u2026`) or `put "\u2026" into #el`.'
2658
+ });
2659
+ }
2660
+ }
2661
+ }
2662
+ if (Array.isArray(n.body)) for (const child of n.body) walk(child, out);
2663
+ }
2664
+
2584
2665
  // src/validation/gates.ts
2585
2666
  var _validators = null;
2586
2667
  function initValidation(validators) {
@@ -2637,6 +2718,7 @@ function runValidationGates(node, confidence, confidenceThreshold) {
2637
2718
  }
2638
2719
  }
2639
2720
  }
2721
+ diagnostics.push(...checkInertShapes(node));
2640
2722
  return { pass: true, diagnostics, adjustedConfidence };
2641
2723
  }
2642
2724
  function nodeToParseResult(node) {
@@ -2768,7 +2850,7 @@ var CompilationService = class _CompilationService {
2768
2850
  initValidation({
2769
2851
  validateSemanticResult: semantic.validateSemanticResult
2770
2852
  });
2771
- const aot = await import("./dist-FWHBOI2B.js");
2853
+ const aot = await import("./dist-XER75XZI.js");
2772
2854
  const compiler = aot.createCompiler();
2773
2855
  initBridge(
2774
2856
  {
@@ -2891,9 +2973,17 @@ var CompilationService = class _CompilationService {
2891
2973
  }
2892
2974
  try {
2893
2975
  const result = this.translateFn(request.code, request.from, request.to);
2976
+ let verification;
2977
+ if (request.verify !== false) {
2978
+ verification = this.scoreFidelity({
2979
+ reference: { code: request.code, language: request.from },
2980
+ candidate: { code: result, language: request.to }
2981
+ });
2982
+ }
2894
2983
  return {
2895
2984
  ok: true,
2896
2985
  code: result,
2986
+ ...verification !== void 0 ? { verification } : {},
2897
2987
  diagnostics: []
2898
2988
  };
2899
2989
  } catch (error) {
@@ -3117,6 +3207,41 @@ var CompilationService = class _CompilationService {
3117
3207
  diagnostics
3118
3208
  };
3119
3209
  }
3210
+ /**
3211
+ * Score a candidate against a reference for structural fidelity — the
3212
+ * multilingual ratchet's scorers (docs/FIDELITY.md) applied to one pair of
3213
+ * inputs. Sides accept any input format and may be in different languages;
3214
+ * see src/scoring/score.ts for signal semantics. Complementary to diff():
3215
+ * diff answers "identical, and where not?", this answers "how faithful, and
3216
+ * what exactly is missing or hallucinated?".
3217
+ */
3218
+ scoreFidelity(request) {
3219
+ const diagnostics = [];
3220
+ const threshold = request.confidence ?? this.confidenceThreshold;
3221
+ const normRef = normalize({ ...request.reference, confidence: request.confidence });
3222
+ diagnostics.push(
3223
+ ...normRef.diagnostics.map((d) => ({ ...d, message: `[reference] ${d.message}` }))
3224
+ );
3225
+ const normCand = normalize({ ...request.candidate, confidence: request.confidence });
3226
+ diagnostics.push(
3227
+ ...normCand.diagnostics.map((d) => ({ ...d, message: `[candidate] ${d.message}` }))
3228
+ );
3229
+ if (!normRef.node || !normCand.node) {
3230
+ return { ok: false, diagnostics };
3231
+ }
3232
+ const gateRef = runValidationGates(normRef.node, normRef.confidence, threshold);
3233
+ const gateCand = runValidationGates(normCand.node, normCand.confidence, threshold);
3234
+ diagnostics.push(
3235
+ ...gateRef.diagnostics.map((d) => ({ ...d, message: `[reference] ${d.message}` }))
3236
+ );
3237
+ diagnostics.push(
3238
+ ...gateCand.diagnostics.map((d) => ({ ...d, message: `[candidate] ${d.message}` }))
3239
+ );
3240
+ if (!gateRef.pass || !gateCand.pass) {
3241
+ return { ok: false, diagnostics };
3242
+ }
3243
+ return { ok: true, diagnostics, ...scoreNodes(normRef.node, normCand.node) };
3244
+ }
3120
3245
  /**
3121
3246
  * Generate a target-specific output from LSE (bracket syntax or protocol JSON).
3122
3247
  *
@@ -3316,6 +3441,7 @@ function nodeToSemanticJSON(node) {
3316
3441
  export {
3317
3442
  diffBehaviors,
3318
3443
  canonicalizeOp,
3444
+ scoreNodes,
3319
3445
  detectFormat,
3320
3446
  SemanticCache,
3321
3447
  generateCacheKey,
@@ -3326,4 +3452,4 @@ export {
3326
3452
  SvelteRenderer,
3327
3453
  CompilationService
3328
3454
  };
3329
- //# sourceMappingURL=chunk-MWUZGAKM.js.map
3455
+ //# sourceMappingURL=chunk-KWRIGXXK.js.map