Phase 3: Move host files to hosts/python/ and hosts/javascript/

Python: bootstrap.py, platform.py, transpiler.sx, boundary_parser.py, tests/
JavaScript: bootstrap.py, cli.py, platform.py, transpiler.sx
Both bootstrappers verified — build from new locations, output to shared/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 02:18:56 +00:00
parent 05f7b10864
commit 7036621be8
15 changed files with 14 additions and 2097 deletions

View File

@@ -16,13 +16,13 @@ import os
import sys
_HERE = os.path.dirname(os.path.abspath(__file__))
_PROJECT = os.path.abspath(os.path.join(_HERE, "..", "..", ".."))
_PROJECT = os.path.abspath(os.path.join(_HERE, "..", ".."))
if _PROJECT not in sys.path:
sys.path.insert(0, _PROJECT)
from shared.sx.parser import parse_all
from shared.sx.types import Symbol
from shared.sx.ref.platform_js import (
from hosts.javascript.platform import (
extract_defines,
ADAPTER_FILES, ADAPTER_DEPS, SPEC_MODULES, SPEC_MODULE_ORDER, EXTENSION_NAMES,
PREAMBLE, PLATFORM_JS_PRE, PLATFORM_JS_POST,
@@ -44,7 +44,7 @@ def load_js_sx() -> dict:
if _js_sx_env is not None:
return _js_sx_env
js_sx_path = os.path.join(_HERE, "js.sx")
js_sx_path = os.path.join(_HERE, "transpiler.sx")
with open(js_sx_path) as f:
source = f.read()
@@ -77,8 +77,7 @@ def compile_ref_to_js(
from datetime import datetime, timezone
from shared.sx.ref.sx_ref import evaluate
ref_dir = _HERE
_PROJECT = os.path.abspath(os.path.join(_HERE, "..", "..", ".."))
ref_dir = os.path.join(_PROJECT, "shared", "sx", "ref")
# Source directories: core spec, web framework, and legacy ref (for bootstrapper tools)
_source_dirs = [
os.path.join(_PROJECT, "spec"), # Core spec

View File

@@ -20,8 +20,10 @@ if _PROJECT not in sys.path:
# Re-export everything that consumers import from this module.
# Canonical source is now run_js_sx.py (self-hosting via js.sx) and platform_js.py.
from shared.sx.ref.run_js_sx import compile_ref_to_js, load_js_sx # noqa: F401
from shared.sx.ref.platform_js import ( # noqa: F401
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from hosts.javascript.bootstrap import compile_ref_to_js, load_js_sx # noqa: F401
from hosts.javascript.platform import ( # noqa: F401
extract_defines,
ADAPTER_FILES, ADAPTER_DEPS, SPEC_MODULES, EXTENSION_NAMES,
PREAMBLE, PLATFORM_JS_PRE, PLATFORM_JS_POST,
@@ -44,7 +46,7 @@ if __name__ == "__main__":
help="Comma-separated extensions (continuations). Default: none.")
p.add_argument("--spec-modules",
help="Comma-separated spec modules (deps). Default: none.")
default_output = os.path.join(_HERE, "..", "..", "static", "scripts", "sx-browser.js")
default_output = os.path.join(_HERE, "..", "..", "shared", "static", "scripts", "sx-browser.js")
p.add_argument("--output", "-o", default=default_output,
help="Output file (default: shared/static/scripts/sx-browser.js)")
args = p.parse_args()

View File

@@ -20,7 +20,7 @@ import sys
# Add project root to path for imports
_HERE = os.path.dirname(os.path.abspath(__file__))
_PROJECT = os.path.abspath(os.path.join(_HERE, "..", "..", ".."))
_PROJECT = os.path.abspath(os.path.join(_HERE, "..", ".."))
sys.path.insert(0, _PROJECT)
from shared.sx.parser import parse_all
@@ -1313,7 +1313,7 @@ try:
EXTENSION_NAMES, EXTENSION_FORMS,
)
except ImportError:
from shared.sx.ref.platform_py import (
from hosts.python.platform import (
PREAMBLE, PLATFORM_PY, PRIMITIVES_PY_PRE, PRIMITIVES_PY_POST,
PRIMITIVES_PY_MODULES, _ALL_PY_MODULES,
PLATFORM_PARSER_PY,
@@ -1439,8 +1439,8 @@ def compile_ref_to_py(
raise ValueError(f"Unknown module: {m!r}. Valid: {', '.join(PRIMITIVES_PY_MODULES)}")
prim_modules.append(m)
ref_dir = os.path.dirname(os.path.abspath(__file__))
_project = os.path.abspath(os.path.join(ref_dir, "..", "..", ".."))
ref_dir = os.path.join(os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")), "shared", "sx", "ref")
_project = os.path.abspath(os.path.join(ref_dir, "..", ".."))
_source_dirs = [
os.path.join(_project, "spec"),
os.path.join(_project, "web"),

View File

@@ -14,7 +14,7 @@
// =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
var SX_VERSION = "2026-03-15T02:11:58Z";
var SX_VERSION = "2026-03-15T02:18:33Z";
function isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); }

File diff suppressed because it is too large Load Diff