@hyperfixi/engine 7.2.0 → 7.4.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,90 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.4.0] - 2026-10-21
11
+
12
+ Content htmx or fixi swaps in runs its hyperscript, as it does on upstream `_hyperscript`: the
13
+ engine has upstream's htmx integration in every bundle, and loading the engine twice no longer
14
+ binds every handler twice. A minor: new behavior and a deprecated option, nothing removed.
15
+
16
+ ### Fixed
17
+
18
+ - **`@hyperfixi/engine`: content htmx or fixi swaps in runs its hyperscript, and htmx content a
19
+ script puts in issues its requests.** Upstream `_hyperscript` has this integration in its core
20
+ runtime and the engine had none: a `_="on click …"` that htmx swapped in did nothing, and an
21
+ `hx-get` that a script `put` into the page was never wired. The engine now has upstream's
22
+ integration (0.9.93's `htmx-compat.js`), installed by `boot()` in every bundle, the Vite
23
+ plugin's included: `htmx:load` (htmx 2) and `htmx:after:process` (htmx 4) process the content,
24
+ an after-process hook hands what a script inserts to `htmx.process`, and on htmx 4 it
25
+ registers upstream's `hs-include` extension (`hs-include=":id"` sends element-scoped variables
26
+ with the request; `htmx.config.extensions = "hs-include"` enables it). Two additions upstream
27
+ lacks: fixi (`fx:swapped` processes the swapped content), and pages with their own hooks
28
+ between the two (`htmx.onLoad(el => _hyperscript.process(el))`,
29
+ `_hyperscript.addAfterProcessHook(el => htmx.process(el))`, the workarounds until now) no longer
30
+ recurse, where upstream recurses until the stack runs out. The workarounds can be removed. The
31
+ first vendoring of upstream's suite left out its htmx tests (`integration/htmx.js`,
32
+ `ext/hs-include.js`), which is how the gap shipped; the gate now runs them and passes all 19
33
+ (1422/1486). `hyperfixi-hs.js` grows 0.7 KB gzipped, to 34.9 KB.
34
+ - **`@hyperfixi/engine`: loading the engine twice no longer binds every handler twice.** Element
35
+ state was private to each copy of the engine, so the second copy initialised every element
36
+ again and one click ran its handler twice. htmx 4's boosted swaps run body scripts again, so
37
+ boost, then back, did it on a page that loads the engine at the end of its body. The state is
38
+ now `elt._hyperscript`, where upstream keeps it and a second copy finds it (two more of
39
+ upstream's tests pass).
40
+ - **Examples: sortable-list's Add Task added a blank task and threw.** Its script read the input
41
+ with `first #new-item-input`, which is null (`first` of one element), and now reads the element
42
+ itself. tell-command's code sample shows its `on click`.
43
+
44
+ ### Deprecated
45
+
46
+ - **`@hyperfixi/vite-plugin`'s `htmx` option does nothing.** It added a listener for htmx 2's
47
+ event names, which htmx 4 does not fire; the engine's integration covers every bundle. The
48
+ option is still accepted, so existing configs build.
49
+
50
+ ## [7.3.0] - 2026-10-21
51
+
52
+ `@hyperfixi/mcp-server` lists its 14 core tools by default and keeps the other 70 in toolsets
53
+ that `LOKASCRIPT_MCP_TOOLSETS` lists, and five of its tools that were broken work. A minor, as
54
+ when the sampling tools went opt-in (2.11.0): every tool still answers a call by name, and the
55
+ variable lists any of them again.
56
+
57
+ ### Changed
58
+
59
+ - **`@hyperfixi/mcp-server` lists 14 core tools by default; the other 70 are in opt-in
60
+ toolsets.** A connection listed all 84: about 13k tokens of definitions in each client that
61
+ loads them all, and a month of sessions called 7 of them. The default list is the agent loop
62
+ and what it leans on (`validate_and_compile`, `get_diagnostics`, `get_code_fixes`,
63
+ `get_command_docs`, `get_expression_docs`, `search_patterns`), translation (`translate_code`,
64
+ `translate_to_english`, `get_keyword_translations`, `list_supported_languages`), proof that
65
+ a change kept its meaning (`score_fidelity`, `diff_behaviors`), and `detect_domain` /
66
+ `compile_auto`: about 2.5k tokens. Set `LOKASCRIPT_MCP_TOOLSETS` to list more: `domains`
67
+ (26), `lse` (13), `grail` (5), `debug` (4), `editor` (3), `analysis` (9), `profiles` (5),
68
+ `project` (5), comma-separated, or `all`. Only the list changes: every tool still answers a
69
+ call by name. A client that picks tools from the list (Claude Code, Claude Desktop) needs
70
+ the variable to see a tool outside the core; the README lists each toolset's tools (#1607).
71
+
72
+ ### Fixed
73
+
74
+ - **`lse_from_hyperscript` returned `[get patient:null]` for every input**, with `ok: true` and
75
+ confidence 1: it read the semantic parse as the AST builder's tree. It now renders the parse,
76
+ and refuses (`ok: false`, the rendered LSE under `partial`) a parse that left input unread or
77
+ a shape whose LSE does not parse back, such as a `then` chain inside a handler (#1607).
78
+ - **`extract_routes` and `generate_server_routes` threw on every input** ("Cannot read
79
+ properties of undefined"), from the day they were added: they read `.routes` from the array
80
+ `scanRoutes` returns. They report server-bridge's route conflicts where they promised an
81
+ `errors` field it never had. The import that hid this from the typecheck (an untyped ambient
82
+ module) is gone (#1607).
83
+ - **`get_code_fixes` had no fixes for the codes `validate_and_compile` emits**
84
+ (`ENGINE_PARSE_ERROR`, `UNCONSUMED_INPUT`, …), though the server's instructions send an agent
85
+ there from its diagnostics; `get_diagnostics`' `parse-error` and `low-confidence` mapped to
86
+ keys that did not exist. Every code compilation-service emits now has fixes, and a test holds
87
+ that (#1607).
88
+ - **`explain_code` listed commands by kind, not in the order they run** (toggle → wait → add
89
+ came out "toggles … adds … waits") and dropped their targets. It explains the parse now: each
90
+ step rendered back to English with what it does, a block's body and an `if`'s two branches (#1607).
91
+ - **`get_diagnostics`' typo fix was titled `Fix typo: ${suggestion}`**, unfilled, with no edit.
92
+ It now reads "Fix typo: toggle" with an edit that replaces the misspelled word (#1607).
93
+
10
94
  ## [7.2.0] - 2026-10-20
11
95
 
12
96
  `@hyperfixi/mcp-server` moves to `@lokascript/domains` 7.1.0: learn left the domains for
package/README.md CHANGED
@@ -11,7 +11,7 @@ core's `dist/hyperfixi.js` is this package's `hyperfixi-hs.js`. It is also publi
11
11
 
12
12
  ## Install
13
13
 
14
- The script-tag bundle, hyperscript and nothing else (34.1 KB gzipped). It installs as
14
+ The script-tag bundle, hyperscript and nothing else (34.9 KB gzipped). It installs as
15
15
  `window._hyperscript` and `window.hyperfixi`, and reads the document when it is ready:
16
16
 
17
17
  ```html
@@ -57,6 +57,20 @@ A script is rewritten as it is read. The element keeps the text its author wrote
57
57
  error in the rewritten script carries that text (`error.written`). `@lokascript/hyperscript-adapter`
58
58
  uses the hook when the host has it.
59
59
 
60
+ ### htmx and fixi
61
+
62
+ Load htmx (2 or 4) or fixi beside any bundle and nothing else is needed: once the engine has
63
+ processed the document it processes content they swap in, and hands htmx the content a script
64
+ puts in, so its `hx-*` attributes work. On htmx 4 it registers upstream's `hs-include`
65
+ extension (`hs-include=":userId"` sends an element-scoped variable with the request; enable it
66
+ with `htmx.config.extensions = "hs-include"`). This is upstream's integration
67
+ (`src/htmx-compat.ts`), with two additions: fixi (on `fx:swapped`), and a hand-off to htmx that
68
+ does not recurse when a page also hands htmx's content to the engine itself
69
+ (`htmx.onLoad(el => _hyperscript.process(el))`), as it does on upstream. As on upstream, the
70
+ engine looks for htmx once, when it has processed the document: load htmx with a script tag
71
+ (plain or `defer`, not `async`) for the hand-off and `hs-include`; swapped-in content is processed
72
+ whenever htmx loads.
73
+
60
74
  ## Layout
61
75
 
62
76
  | File | What it holds |
@@ -153,7 +167,7 @@ commands) 18.4 KB, `full` 34.1 KB, `core` (no commands) 13.8 KB.
153
167
 
154
168
  ## The script-tag bundle: `hyperfixi-hs.js`
155
169
 
156
- `dist/hyperfixi-hs.js` (minified, 34.1 KB gzipped; `hyperfixi-hs.dev.js` is the readable build) is the first product on this engine:
170
+ `dist/hyperfixi-hs.js` (minified, 34.9 KB gzipped; `hyperfixi-hs.dev.js` is the readable build) is the first product on this engine:
157
171
  hyperscript and nothing else, every module, no htmx attributes, English only. It installs
158
172
  `window._hyperscript`, as upstream does, and the same object as `window.hyperfixi`. The name
159
173
  paired with core's `hyperfixi-hx.js` (hyperscript plus htmx, retired in Phase C3). Since C-R4b
@@ -185,8 +199,12 @@ gallery for `packages/core/test-pages/`. One behavior of core's is not in this e
185
199
  engine want `increment #count's textContent`. The examples write the second, which every
186
200
  bundle runs to the same count (the bundle matrix's Counter row).
187
201
 
188
- The 66 known failures: upstream's internal-API surface (`internals.tokenizer`,
189
- `evalStatically`, source info, error collection: 47), sockets and workers (17, upstream
202
+ Since 2026-10-21 the gate also runs upstream's htmx tests (`integration/htmx.js` and
203
+ `ext/hs-include.js`, 19), which the first vendoring left out, so the whole suite is 1,486. The
204
+ engine failed 10 of them until it had upstream's htmx integration; it passes all 19.
205
+
206
+ The 64 known failures: upstream's internal-API surface (`internals.tokenizer`,
207
+ `evalStatically`, source info, error collection: 45), sockets and workers (17, upstream
190
208
  extensions that are not built), and two collection-expression tests that need upstream's
191
209
  component extension. Upstream's one failure is a test that expects its worker extension to be
192
210
  absent.
package/dist/common.js CHANGED
@@ -37,13 +37,22 @@
37
37
  enter(_elt) {
38
38
  }
39
39
  };
40
- var store = /* @__PURE__ */ new WeakMap();
41
- var peekData = (elt) => store.get(elt);
42
- var dropData = (elt) => store.delete(elt);
40
+ var windowHolders = /* @__PURE__ */ new WeakMap();
41
+ function holder(elt) {
42
+ if (elt.window !== elt) return elt;
43
+ let h = windowHolders.get(elt);
44
+ if (!h) windowHolders.set(elt, h = {});
45
+ return h;
46
+ }
47
+ var peekData = (elt) => holder(elt)._hyperscript;
48
+ function dropData(elt) {
49
+ const h = holder(elt);
50
+ const had = h._hyperscript !== void 0;
51
+ delete h._hyperscript;
52
+ return had;
53
+ }
43
54
  function dataOf(elt) {
44
- let d = store.get(elt);
45
- if (!d) store.set(elt, d = {});
46
- return d;
55
+ return holder(elt)._hyperscript ??= {};
47
56
  }
48
57
  var rx = {
49
58
  /** True while an effect is evaluating: reads are then recorded as its dependencies. */
@@ -2400,6 +2409,108 @@
2400
2409
  };
2401
2410
  }
2402
2411
 
2412
+ // src/htmx-compat.ts
2413
+ var installed = /* @__PURE__ */ new WeakSet();
2414
+ function installHtmxCompat(hs) {
2415
+ if (installed.has(hs)) return;
2416
+ installed.add(hs);
2417
+ let fromHtmx = false;
2418
+ const asHtmx = (f) => {
2419
+ const was = fromHtmx;
2420
+ fromHtmx = true;
2421
+ try {
2422
+ f();
2423
+ } finally {
2424
+ fromHtmx = was;
2425
+ }
2426
+ };
2427
+ document.addEventListener(
2428
+ "htmx:load",
2429
+ (evt) => asHtmx(() => hs.process(evt.detail?.elt))
2430
+ );
2431
+ document.addEventListener("htmx:after:process", (evt) => asHtmx(() => hs.process(evt.target)));
2432
+ document.addEventListener("fx:swapped", (evt) => {
2433
+ const target = evt.detail?.cfg?.target;
2434
+ hs.process(
2435
+ target instanceof Element && target.isConnected ? target.parentElement ?? target : document.body
2436
+ );
2437
+ });
2438
+ const htmx = Reflect.get(globalThis, "htmx");
2439
+ if (typeof htmx?.process !== "function") return;
2440
+ hs.addAfterProcessHook((elt) => {
2441
+ if (!fromHtmx) asHtmx(() => htmx.process(elt));
2442
+ });
2443
+ if (htmx.version?.startsWith("4")) {
2444
+ htmx.registerExtension?.("hs-include", {
2445
+ htmx_config_request(elt, detail) {
2446
+ const ctx = detail?.ctx;
2447
+ if (!ctx) return;
2448
+ const found = findHsInclude(ctx.sourceElement || elt);
2449
+ if (!found) return;
2450
+ const vars = resolveSpecifiers(found.value, found.scopeElt);
2451
+ const body = ctx.request?.body;
2452
+ if (body instanceof FormData) for (const k in vars) body.set(k, vars[k]);
2453
+ }
2454
+ });
2455
+ }
2456
+ }
2457
+ function findHsInclude(sourceElt) {
2458
+ const attr = sourceElt.getAttribute("hs-include");
2459
+ if (attr !== null) return { value: attr, scopeElt: sourceElt };
2460
+ for (let elt = sourceElt.parentElement; elt; elt = elt.parentElement) {
2461
+ const inherited2 = elt.getAttribute("hs-include:inherited");
2462
+ if (inherited2 !== null) return { value: inherited2, scopeElt: elt };
2463
+ }
2464
+ return null;
2465
+ }
2466
+ var readScope = (elt) => elt && peekData(elt)?.scopes?.elementScope || {};
2467
+ function serialize(value) {
2468
+ if (value == null) return "";
2469
+ if (typeof value === "object") {
2470
+ try {
2471
+ return JSON.stringify(value);
2472
+ } catch {
2473
+ return "";
2474
+ }
2475
+ }
2476
+ return String(value);
2477
+ }
2478
+ function resolveInherited(scopeKey, startElt) {
2479
+ for (let elt = startElt; elt; elt = elt.parentElement) {
2480
+ const scope = readScope(elt);
2481
+ if (scopeKey in scope) return scope[scopeKey];
2482
+ }
2483
+ return void 0;
2484
+ }
2485
+ function resolveSpecifiers(attrValue, scopeElt) {
2486
+ const result = {};
2487
+ const raw = attrValue.trim();
2488
+ if (raw === "*") {
2489
+ const scope = readScope(scopeElt);
2490
+ for (const k of Object.keys(scope)) result[k[0] === ":" ? k.slice(1) : k] = serialize(scope[k]);
2491
+ return result;
2492
+ }
2493
+ for (let part of raw.split(",")) {
2494
+ part = part.trim();
2495
+ if (!part) continue;
2496
+ if (part[0] === ":") {
2497
+ const scope = readScope(scopeElt);
2498
+ if (part in scope) result[part.slice(1)] = serialize(scope[part]);
2499
+ } else if (part[0] === "^") {
2500
+ const value = resolveInherited(":" + part.slice(1), scopeElt);
2501
+ if (value !== void 0) result[part.slice(1)] = serialize(value);
2502
+ } else if (part[0] === "#") {
2503
+ const colon = part.lastIndexOf(":");
2504
+ if (colon > 0) {
2505
+ const scope = readScope(document.querySelector(part.slice(0, colon)));
2506
+ const name = part.slice(colon + 1);
2507
+ if (":" + name in scope) result[name] = serialize(scope[":" + name]);
2508
+ }
2509
+ }
2510
+ }
2511
+ return result;
2512
+ }
2513
+
2403
2514
  // src/parser.ts
2404
2515
  var ParseError = class extends Error {
2405
2516
  constructor(message, token, source, expected) {
@@ -2681,14 +2792,21 @@
2681
2792
  }
2682
2793
  var beforeProcess = [];
2683
2794
  var afterProcess = [];
2795
+ var processing = /* @__PURE__ */ new Set();
2684
2796
  function processNode(node) {
2685
2797
  if (!(node instanceof Element || node instanceof Document || node instanceof DocumentFragment))
2686
2798
  return;
2687
- for (const hook of beforeProcess) hook(node);
2688
- const selector = attributes().map((a) => `[${a}]`).join(", ") + ", [type='text/hyperscript']";
2689
- if (node instanceof Element && node.matches(selector)) initElement(node);
2690
- node.querySelectorAll(selector).forEach(initElement);
2691
- for (const hook of afterProcess) hook(node);
2799
+ if (processing.has(node)) return;
2800
+ processing.add(node);
2801
+ try {
2802
+ for (const hook of beforeProcess) hook(node);
2803
+ const selector = attributes().map((a) => `[${a}]`).join(", ") + ", [type='text/hyperscript']";
2804
+ if (node instanceof Element && node.matches(selector)) initElement(node);
2805
+ node.querySelectorAll(selector).forEach(initElement);
2806
+ for (const hook of afterProcess) hook(node);
2807
+ } finally {
2808
+ processing.delete(node);
2809
+ }
2692
2810
  }
2693
2811
  function cleanup(elt) {
2694
2812
  const data = peekData(elt);
@@ -2734,7 +2852,7 @@
2734
2852
  cleanup,
2735
2853
  /** The part of upstream's `internals` that pages and tests reach for. */
2736
2854
  internals: { runtime: { cleanup, processNode } },
2737
- version: false ? "dev" : "7.2.0"
2855
+ version: false ? "dev" : "7.4.0"
2738
2856
  });
2739
2857
  function boot() {
2740
2858
  Object.assign(globalThis, { _hyperscript: api });
@@ -2742,6 +2860,7 @@
2742
2860
  const start = () => {
2743
2861
  processNode(document.documentElement);
2744
2862
  document.dispatchEvent(new Event("hyperscript:ready"));
2863
+ installHtmxCompat(api);
2745
2864
  };
2746
2865
  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start);
2747
2866
  else setTimeout(start);