M Mozhi v3.7.0 code

Error reference

AI Diagnosis

Mozhi can attach a free AI explanation under the local error diagnostics — the feature is named exactly AI Diagnosis. It requires no API key, no account, no registration and no payment: the default service is an anonymous, keyless HTTPS endpoint that was verified reachable before this release.

How it works

  1. The interpreter first prints its local diagnosis (codes, spans, suggested fixes) — that part is deterministic and authoritative.
  2. When errors occurred and output is interactive, it collects a minimal context: up to 4 error entries (code, message, reason, position) plus at most ~1.2 KB of the offending source lines. The whole project is never uploaded; no other files are read.
  3. The context is sent over HTTPS with a bounded timeout (20 s by default) and the reply is size-capped and validated before display.
  4. The suggestion is shown in an AI Diagnosis block with a disclaimer: AI-generated suggestion — may be wrong; the local diagnosis above is authoritative. Suggestions are never executed and never modify files.

When it is off

AI Diagnosis is off for non-interactive runs (piped output, CI) unless you pass --ai or set MOZHI_AI=1, and always off with --no-ai or MOZHI_NO_AI=1. If the service is unreachable, rate-limited, slow, or returns garbage, you see one line (AI Diagnosis unavailable: …) with a link to the error index — the exit code and the local diagnosis are completely unaffected.

Privacy

Configuration

$ mozhi run app.mz                # interactive: AI Diagnosis attaches automatically
$ mozhi --no-ai run app.mz        # skip it entirely
$ MOZHI_NO_AI=1 mozhi run app.mz  # same via environment
$ mozhi --ai --json run app.mz    # force in scripts; emits {"ai": ...} on stderr
VariableMeaningDefault
MOZHI_NO_AI=1disable AI Diagnosisunset (enabled)
MOZHI_AI=1force-enable, also in scripts/JSON modeunset
MOZHI_AI_TIMEOUT_MSrequest timeout (500–60000)20000
MOZHI_AI_ENDPOINTreplace the service (maintenance/testing)built-in default
MOZHI_AI_MODELoverride the model id sent to the servicebuilt-in default
MOZHI_AI_MAX_CONTEXTmax source-context bytes (200–8000)1200

Honest limits