From 9af38a8fbe96310093858b1b69115db3796cfbea Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 29 Mar 2026 23:26:19 +0000 Subject: [PATCH] MCP: load signals + render pipeline, add evaluator stubs Co-Authored-By: Claude Opus 4.6 (1M context) --- hosts/ocaml/bin/mcp_tree.ml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hosts/ocaml/bin/mcp_tree.ml b/hosts/ocaml/bin/mcp_tree.ml index 69cb2c43..89dcc143 100644 --- a/hosts/ocaml/bin/mcp_tree.ml +++ b/hosts/ocaml/bin/mcp_tree.ml @@ -245,6 +245,18 @@ let setup_env () = bind "sx-serialize" (fun args -> match args with | [v] -> String (Sx_runtime.value_to_str v) | _ -> String ""); + (* Stubs needed by signals.sx + adapter-html.sx *) + bind "set-render-active!" (fun _args -> Nil); + bind "render-active?" (fun _args -> Bool true); + bind "trampoline" (fun args -> match args with + | [Thunk (expr, e)] -> Sx_ref.eval_expr expr (Env e) + | [v] -> v | _ -> Nil); + bind "eval-expr" (fun args -> match args with + | [expr; Env ue] -> Sx_ref.eval_expr expr (Env ue) + | [expr] -> Sx_ref.eval_expr expr (Env e) + | _ -> Nil); + bind "deftype" (fun _args -> Nil); + bind "defeffect" (fun _args -> Nil); (* Load parser.sx for the SX-level sx-parse/sx-serialize *) let spec_dir = try Sys.getenv "SX_SPEC_DIR" with Not_found -> "spec" in let lib_dir = try Sys.getenv "SX_LIB_DIR" with Not_found -> "lib" in @@ -253,12 +265,30 @@ let setup_env () = (* Load tree-tools *) (try load_sx_file e (Filename.concat lib_dir "tree-tools.sx") with exn -> Printf.eprintf "[mcp] Error: tree-tools.sx load failed: %s\n%!" (Printexc.to_string exn); exit 1); + (* Load signals — reactive signal primitives *) + (try load_sx_file e (Filename.concat spec_dir "signals.sx") + with exn -> Printf.eprintf "[mcp] Warning: signals.sx load failed: %s\n%!" (Printexc.to_string exn)); + (* Load render + adapter-html for render-to-html *) + let web_dir = try Sys.getenv "SX_WEB_DIR" with Not_found -> "web" in + (try load_sx_file e (Filename.concat spec_dir "render.sx") + with exn -> Printf.eprintf "[mcp] Warning: render.sx load failed: %s\n%!" (Printexc.to_string exn)); + (try load_sx_file e (Filename.concat web_dir "adapter-html.sx") + with exn -> Printf.eprintf "[mcp] Warning: adapter-html.sx load failed: %s\n%!" (Printexc.to_string exn)); (* Load harness *) (try load_sx_file e (Filename.concat spec_dir "harness.sx") with exn -> Printf.eprintf "[mcp] Warning: harness.sx load failed: %s\n%!" (Printexc.to_string exn)); (* Load eval-rules *) (try load_sx_file e (Filename.concat spec_dir "eval-rules.sx") with exn -> Printf.eprintf "[mcp] Warning: eval-rules.sx load failed: %s\n%!" (Printexc.to_string exn)); + (* Load signals — reactive signal primitives *) + (try load_sx_file e (Filename.concat spec_dir "signals.sx") + with exn -> Printf.eprintf "[mcp] Warning: signals.sx load failed: %s\n%!" (Printexc.to_string exn)); + (* Load render + adapter-html for render-to-html *) + let web_dir = try Sys.getenv "SX_WEB_DIR" with Not_found -> "web" in + (try load_sx_file e (Filename.concat spec_dir "render.sx") + with exn -> Printf.eprintf "[mcp] Warning: render.sx load failed: %s\n%!" (Printexc.to_string exn)); + (try load_sx_file e (Filename.concat web_dir "adapter-html.sx") + with exn -> Printf.eprintf "[mcp] Warning: adapter-html.sx load failed: %s\n%!" (Printexc.to_string exn)); (* Load render pipeline — native OCaml renderer + HTML tag bindings *) Sx_render.setup_render_env e; List.iter (fun tag ->