@crossberryweb/mozhi 0.0.0-stage → 3.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 crossberry-in
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,73 @@
1
- # Temporary Holding Version
1
+ # @crossberryweb/mozhi — official npm distribution
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The [Mozhi](https://crossberry-in.github.io/mozhi-doc/) programming language,
4
+ delivered as pre-built native binaries through npm.
5
+
6
+ Installing this package gives you **two equivalent commands**:
7
+
8
+ ```bash
9
+ mozhi run app.mz # canonical command
10
+ mz run app.mz # short alias — same binary, identical behavior
11
+ ```
12
+
13
+ Both are installed by npm from the same launcher, so `mz` and `mozhi` are
14
+ always in sync: same version, same flags, same exit codes.
15
+
16
+ ## What you get (v3.2.0)
17
+
18
+ - **Precise error diagnostics**: every error carries a stable code
19
+ (`LEX001`, `PARSE002`, `NAME001`, ...), a caret span under the exact
20
+ token, a suggested fix, and a link to its documentation page.
21
+ - **Free AI Diagnosis** (opt-in for scripts, automatic in interactive
22
+ terminals): an anonymous, keyless service explains the error — no API
23
+ key, no account, no payment. Disable with `--no-ai` or `MOZHI_NO_AI=1`.
24
+ Failure of the service never affects the local diagnosis or exit code.
25
+ - **Machine-readable output**: `mozhi --json run app.mz` emits
26
+ `mozhi.diagnostics.v1` JSON to stderr (codes, spans, docs URLs).
27
+ - Native modules: `web` (HTTP server), `json`, `fs` (sandboxed),
28
+ `db` (SQLite), `math`, `template`, `http` client.
29
+
30
+ ## Usage
31
+
32
+ ```bash
33
+ mozhi run app.mz # run a script (plain: mozhi app.mz)
34
+ mz run app.mz # identical
35
+ mozhi new myapp # scaffold a project (web | minimal)
36
+ mozhi dev # auto-reload dev server
37
+ mozhi test tests/ # run *.test.mz suites
38
+ mozhi lint src/ # parse checks with error codes
39
+ ```
40
+
41
+ ## Platform support
42
+
43
+ Bundled binaries (fully static musl builds, SQLite vendored — work on
44
+ glibc distros, Alpine, Termux/Noxs):
45
+
46
+ - `linux-x86_64`
47
+ - `linux-arm64`
48
+
49
+ macOS / Windows: use the installer
50
+ `curl -fsSL https://github.com/crossberry-in/mozhi-doc/raw/main/install.sh | bash`
51
+ (it installs `mozhi` and the `mz` alias too).
52
+
53
+ ## Diagnostics & AI Diagnosis
54
+
55
+ ```text
56
+ error[LEX001]: illegal character in source
57
+ --> app.mz:1:14
58
+ 1 | echo(string(5 ^ 3))
59
+ | ^
60
+ reason: the character '^' is not part of the Mozhi language
61
+ help: exponentiation is written with '**' in Mozhi, e.g. 5 ** 3
62
+ docs: https://crossberry-in.github.io/mozhi-doc/errors/LEX001
63
+ ```
64
+
65
+ Every `docs:` URL is a real page in the official error reference.
66
+ See `mozhi help` for all output flags (`--json`, `--no-color`,
67
+ `--verbose`, `--no-ai`, `--ai`).
68
+
69
+ ## Links
70
+
71
+ - Documentation: https://crossberry-in.github.io/mozhi-doc/
72
+ - Error code reference: https://crossberry-in.github.io/mozhi-doc/errors/
73
+ - Source/issues: https://github.com/crossberry-in/mozhi
Binary file
Binary file
package/bin/mozhi.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Mozhi interpreter launcher (npm distribution).
4
+ *
5
+ * The official prebuilt interpreter binaries ship inside this package
6
+ * under bin/. This launcher picks the right one for the current
7
+ * platform and hands over the process — arguments, stdio, exit codes
8
+ * and signals all pass through, so `mozhi` behaves exactly like a
9
+ * native binary.
10
+ *
11
+ * npm installs TWO commands from this same launcher:
12
+ * mozhi — the canonical command
13
+ * mz — the short alias (identical behavior, same binary)
14
+ *
15
+ * Bundled (v3.2.0, fully static musl builds with SQLite vendored):
16
+ * bin/mozhi-linux-x86_64
17
+ * bin/mozhi-linux-arm64
18
+ *
19
+ * macOS / Windows / other platforms:
20
+ * see https://github.com/crossberry-in/mozhi-doc#installation
21
+ */
22
+ 'use strict';
23
+
24
+ const { spawn } = require('child_process');
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+
28
+ // npm's process.arch uses "x64"; our asset naming uses "x86_64".
29
+ const arch = process.arch === 'x64' ? 'x86_64' : process.arch;
30
+ const bin = path.join(__dirname, 'mozhi-' + process.platform + '-' + arch);
31
+
32
+ if (!fs.existsSync(bin)) {
33
+ console.error('[mozhi] No bundled interpreter for ' + process.platform + '-' + process.arch + '.');
34
+ console.error('[mozhi] This package ships official v3.2.0 binaries for:');
35
+ console.error('[mozhi] linux-x86_64, linux-arm64 (fully static — works on glibc, Alpine, Termux)');
36
+ console.error('[mozhi] For macOS, Windows and other platforms use the installer:');
37
+ console.error('[mozhi] curl -fsSL https://github.com/crossberry-in/mozhi-doc/raw/main/install.sh | bash');
38
+ process.exit(1);
39
+ }
40
+
41
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
42
+
43
+ child.on('error', (err) => {
44
+ console.error('[mozhi] Failed to start interpreter: ' + err.message);
45
+ process.exit(1);
46
+ });
47
+
48
+ child.on('exit', (code, signal) => {
49
+ if (signal) {
50
+ // propagate fatal signals (SIGINT/SIGTERM...) with the correct exit status
51
+ process.kill(process.pid, signal);
52
+ } else {
53
+ process.exit(code === null ? 0 : code);
54
+ }
55
+ });
@@ -0,0 +1,6 @@
1
+ 0ab8ae3b6094946810d86aef30dc69e113ee1dc0398b2da51b53724e955eef47 mozhi-interpreter-alpine-arm64
2
+ c3ffe6667a0eb2bdea773419afc1b0819079a35476728e5d6af2522d41f8b1e1 mozhi-interpreter-alpine-x86_64
3
+ 3ae60653e5bf2c5503e4a9da077317b548a8ff7f383ba1b455d0035459cba25d mozhi-interpreter-linux-arm64
4
+ 93c86b5ccdc2096064a7aedfaeb7e6f7f8b8e81a0b46ebe4f61bc2e8e42e6ed1 mozhi-interpreter-linux-x86_64
5
+ 3e0db55954e74a5052e37de5d19ec6f9a4bd9256159a05a50f9f7b9ced639c40 mozhi-interpreter-macos-arm64
6
+ 0d308353ca9e1e475a014ed771e2361b396562541517e4a7c764349ce64d9478 mozhi-interpreter-macos-x86_64
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@crossberryweb/mozhi",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.2.0",
4
+ "description": "Mozhi programming language interpreter — native web, JSON, fs, math, SQLite, templates. Install once, get both commands: `mozhi` and the short alias `mz` (identical behavior).",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/crossberry-in/mozhi.git"
9
+ },
10
+ "homepage": "https://crossberry-in.github.io/mozhi-doc/",
11
+ "keywords": [
12
+ "mozhi",
13
+ "language",
14
+ "interpreter",
15
+ "web",
16
+ "fullstack"
17
+ ],
18
+ "bin": {
19
+ "mozhi": "bin/mozhi.js",
20
+ "mz": "bin/mozhi.js"
21
+ },
22
+ "files": [
23
+ "bin/",
24
+ "checksums-sha256.txt",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "engines": {
29
+ "node": ">=14"
30
+ }
31
+ }