From 9c741b65ff6974757d5c7465324a51b601845a12 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 21 Jul 2026 15:23:13 +0800 Subject: [PATCH] Improve module dropdown --- .mise/config.toml | 20 ++-------------- config/semgrep/module-description-length.yaml | 23 +++++++++++++++++++ services/ws-modules/pyeye1/pyproject.toml | 2 +- services/ws-modules/pywasm1/pyproject.toml | 13 +++++++++++ services/ws-modules/wasi-comm1/Cargo.toml | 2 +- services/ws-modules/wasi-data1/Cargo.toml | 2 +- .../wasi-graphics-info/pyproject.toml | 2 +- services/ws-modules/zig-data1/build.zig.zon | 2 +- services/ws-modules/zig-except1/build.zig.zon | 2 +- services/ws-server/static/app.js | 10 +++++--- 10 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 config/semgrep/module-description-length.yaml create mode 100644 services/ws-modules/pywasm1/pyproject.toml diff --git a/.mise/config.toml b/.mise/config.toml index 9d9f0192..b4c47810 100644 --- a/.mise/config.toml +++ b/.mise/config.toml @@ -454,8 +454,6 @@ gh_http = "--http-url https://github.com --progress --ignore-existing" o2_image = "openobserve/openobserve:v0.70.3" # OpenTelemetry Collector image for the o2-hostmetrics / o2-macmon / o2-nvidia / o2-winmetrics tasks. otelcol_image = "otel/opentelemetry-collector-contrib:0.156.0" -# pywasm1's own module version, templated into the pkg/package.json its build task emits. -pywasm1_pkg_version = "0.1.0" rp_wasm_dir = '''{% if os() == "windows" -%} {%- set base = (env?.LOCALAPPDATA or "") | replace(from="\\", to="/") -%} {{- base -}}/mise/installs/http-rp-wasm/{{- vars.a_rp_wasm_short -}} @@ -1487,6 +1485,7 @@ shell = "bash -euo pipefail -c" # like every other module task -- using the prebuilt tarball from the rp-v release rather than # recompiling RustPython keeps the cost at one ~10 MB download, not a multi-minute upstream wasm-pack build. [tasks.build-ws-pywasm1-module] +depends = ["build-et-cli"] description = "Build the pywasm1 module (fetched rustpython_wasm + main.py)" dir = "services/ws-modules/pywasm1" run = """ @@ -1497,22 +1496,7 @@ coreutils cp "$rp_pkg"/rustpython_wasm.js "$rp_pkg"/rustpython_wasm.d.ts pkg/ coreutils cp "$rp_pkg"/rustpython_wasm_bg.wasm "$rp_pkg"/rustpython_wasm_bg.wasm.d.ts pkg/ coreutils cp -R "$rp_pkg/snippets" pkg/ coreutils cp index.js main.py pkg/ -coreutils cat > pkg/package.json <<'PKG_JSON' -{ - "name": "et-ws-pywasm1", - "type": "module", - "version": "{{ vars.pywasm1_pkg_version }}", - "main": "index.js", - "files": [ - "index.js", - "main.py", - "rustpython_wasm.js", - "rustpython_wasm.d.ts", - "rustpython_wasm_bg.wasm", - "rustpython_wasm_bg.wasm.d.ts" - ] -} -PKG_JSON +{{ vars.et_cli }} module-package-json """ shell = "bash -euo pipefail -c" diff --git a/config/semgrep/module-description-length.yaml b/config/semgrep/module-description-length.yaml new file mode 100644 index 00000000..4e5e2228 --- /dev/null +++ b/config/semgrep/module-description-length.yaml @@ -0,0 +1,23 @@ +rules: + - id: module-description-length + languages: [generic] + paths: + include: + - "services/ws-modules/*/Cargo.toml" + - "services/ws-modules/*/pyproject.toml" + - "services/ws-modules/*/build.zig.zon" + - "services/ws-modules/*/pkg/package.json" + # Enforce ws-module description length at the source manifests, not by trimming labels in the browser. + # A ws-module description is the module-dropdown label on the ws-server index page. Two regex alternatives + # cover the syntaxes the description travels through: `description = "..."` (Cargo.toml / pyproject.toml, + # and build.zig.zon's `.description = "..."` which the same pattern matches) and `"description": "..."` + # (the hand-committed pkg/package.json files of the dart / dotnet / java / R modules). The generated + # pkg/package.json files are gitignored and semgrep scans only tracked files, so the manifest patterns are + # the ones that matter for generated modules. + pattern-either: + - pattern-regex: 'description = "[^"]{41,}"' + - pattern-regex: '"description": "[^"]{41,}"' + message: >- + A ws-module description is the module-dropdown label on the ws-server index page; keep it at most 40 + characters so the dropdown stays readable. + severity: ERROR diff --git a/services/ws-modules/pyeye1/pyproject.toml b/services/ws-modules/pyeye1/pyproject.toml index fc1f3a70..18f3cdbc 100644 --- a/services/ws-modules/pyeye1/pyproject.toml +++ b/services/ws-modules/pyeye1/pyproject.toml @@ -1,6 +1,6 @@ [project] dependencies = ["et-ws"] -description = "Python eye detection (MediaPipe FaceLandmarker -> eye bounding boxes)" +description = "Python eye detection (MediaPipe)" license = "Apache-2.0 OR MIT" name = "et-ws-pyeye1" requires-python = ">=3.10" diff --git a/services/ws-modules/pywasm1/pyproject.toml b/services/ws-modules/pywasm1/pyproject.toml new file mode 100644 index 00000000..fc025ce1 --- /dev/null +++ b/services/ws-modules/pywasm1/pyproject.toml @@ -0,0 +1,13 @@ +[project] +description = "Python smoke test (RustPython WASM)" +license = "Apache-2.0 OR MIT" +name = "et-ws-pywasm1" +requires-python = ">=3.10" +version = "0.1.0" + +# No [build-system]: nothing is wheel-built here. +# The module ships main.py verbatim next to the prebuilt rustpython_wasm artifacts its build task copies into +# pkg/; this manifest exists so `et-cli module-package-json` derives pkg/package.json from statically +# checkable input like every other module. +[tool.ws-module] +main = "index.js" diff --git a/services/ws-modules/wasi-comm1/Cargo.toml b/services/ws-modules/wasi-comm1/Cargo.toml index b365718d..d1d887f6 100644 --- a/services/ws-modules/wasi-comm1/Cargo.toml +++ b/services/ws-modules/wasi-comm1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "et-ws-wasi-comm1" -description = "WASI Preview 2 port of the comm1 module -- list-agents + broadcast + direct message" +description = "WASI Preview 2 port of comm1" version = "0.1.0" edition.workspace = true license.workspace = true diff --git a/services/ws-modules/wasi-data1/Cargo.toml b/services/ws-modules/wasi-data1/Cargo.toml index 29111943..00ad0609 100644 --- a/services/ws-modules/wasi-data1/Cargo.toml +++ b/services/ws-modules/wasi-data1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "et-ws-wasi-data1" -description = "WASI Preview 2 port of the data1 module -- keyvalue store roundtrip" +description = "WASI Preview 2 port of data1" version = "0.1.0" edition.workspace = true license.workspace = true diff --git a/services/ws-modules/wasi-graphics-info/pyproject.toml b/services/ws-modules/wasi-graphics-info/pyproject.toml index 49bbfa23..cf6b8a74 100644 --- a/services/ws-modules/wasi-graphics-info/pyproject.toml +++ b/services/ws-modules/wasi-graphics-info/pyproject.toml @@ -1,6 +1,6 @@ [project] dependencies = [] -description = "Python graphics-info WASI component via componentize-py" +description = "Python WASI graphics-info component" license = "Apache-2.0 OR MIT" name = "et-ws-wasi-graphics-info" requires-python = ">=3.10" diff --git a/services/ws-modules/zig-data1/build.zig.zon b/services/ws-modules/zig-data1/build.zig.zon index f5ebc6a0..f4b7dd39 100644 --- a/services/ws-modules/zig-data1/build.zig.zon +++ b/services/ws-modules/zig-data1/build.zig.zon @@ -1,7 +1,7 @@ .{ .name = .et_ws_zig_data1, .version = "0.1.0", - .description = "zig data 1", + .description = "Zig + C/C++ data 1", .license = "Apache-2.0 or MIT", .main = "et_ws_zig_data1.js", .fingerprint = 0x8c5646f08b8cd4b1, diff --git a/services/ws-modules/zig-except1/build.zig.zon b/services/ws-modules/zig-except1/build.zig.zon index 4b3805ea..df69472d 100644 --- a/services/ws-modules/zig-except1/build.zig.zon +++ b/services/ws-modules/zig-except1/build.zig.zon @@ -1,7 +1,7 @@ .{ .name = .et_ws_zig_except1, .version = "0.1.0", - .description = "zig exception handling demo 1", + .description = "Zig + C++ exception handling demo 1", .license = "Apache-2.0 or MIT", .main = "et_ws_zig_except1.js", .fingerprint = 0x7e0344ac53a4bcec, diff --git a/services/ws-server/static/app.js b/services/ws-server/static/app.js index e3549e8f..3b01559e 100644 --- a/services/ws-server/static/app.js +++ b/services/ws-server/static/app.js @@ -45,11 +45,15 @@ const populateModuleDropdown = async () => { append(`Skipping ${name}: already loaded as the main WASM agent module`); continue; } - if (name === "onnxruntime-web" || name === "pyodide") { - append(`Skipping ${name}: already loaded as a dependency`); + if (!name.startsWith("et-ws-")) { + append(`Skipping ${name}: not an et-ws-* workflow module`); continue; } - const pkgResp = await fetch(`/modules/${name}/package.json`); + if (name.startsWith("et-ws-wasi-")) { + append(`Skipping ${name}: WASI module, runs in et-ws-wasi-runner rather than the browser`); + continue; + } + const pkgResp = await fetch(`/modules/${name}/package.json`, { cache: "no-cache" }); if (!pkgResp.ok) { append(`Skipping ${name}: no package.json (${pkgResp.status})`); continue;