GocciaScript

A drop of JavaScript, built for embedding.
GocciaScript is an ECMAScript engine for embedding, with sensible defaults that
are easy to customize. An application embeds it to add scripting: the host
chooses the runtime surface, grants the capabilities a script may use, and
bounds a run by time, instructions and a memory budget. The budget gates
allocations and does not cap resident memory, so a hard ceiling also needs an
operating-system limit
(Garbage Collector). Beyond the files of its own
project's static module graph, a script reaches no filesystem, network or
process unless the host grants it
(permissions, capability audit events),
and a run can be made deterministic, with a fixed clock and seeded randomness.
Today the host is a FreePascal or Delphi application; see
Embedding the Engine.
- Conformance you can check. test262, the official ECMAScript conformance
suite, runs on every pull request and on main. When the run produces results
and a cached main baseline graded under the same contract is available, a
pull request that turns a passing test into a failure other than a timeout,
compared in the same mode, fails CI. The
compatibility dashboard shows
the current result by area, rendered from the published reports.
- Tested beyond the spec. 17,000+ JavaScript tests run on every pull
request, and on six targets on main, with differential suites
checked against Bun and Vitest.
- Fuzzed and memory-checked. Every night the engine and its heap snapshot
reader are fuzzed,
and the full test suite runs under FreePascal's heap checker and under
Valgrind memcheck. Every week a
GC-stress run
collects garbage every 8 instructions across the whole test suite and the
GC-sensitive part of test262.
- In production. GocciaScript is the engine behind
Shotcup's hosted sandboxes, where every run gets a
fresh engine with hard limits.
- Native, with nothing underneath. Its own compiler, bytecode VM and
garbage collector, built with FreePascal into native binaries: no Node.js,
V8 or other runtime to install beside the binary (HTTPS on Linux uses the
system's OpenSSL). Prebuilt for
macOS and Linux (x64 and arm64) and Windows (x64 and x86), and embeddable
in FreePascal and Delphi applications.
- Modern JavaScript and TypeScript. ES modules, classes with private
fields, async/await, Temporal, Intl, TC39 type annotations run directly, and
a Vitest-compatible test runner. GocciaScript also tracks TC39 proposals,
including stage 1 and 2, and
goccia:ast gives formatters and codemods the
tree GocciaScript's own parser produces.
- Status: pre-1.0. The language follows ECMAScript; the host API and
command-line flags may change between releases, so pin a version and read
the changelog before you upgrade.
curl -fsSL https://www.gocciascript.dev/install | sh
On Windows, irm https://www.gocciascript.dev/install.ps1 | iex; on macOS,
also brew install frostney/tap/gocciascript. Or try it in the
Playground. Building from source
needs the FreePascal compiler; see Getting Started.
GocciaScript provides a Node.js or Web API capability when it fits the vision
and cannot be shimmed in userland, and leaves what userland or npm can shim to
userland; see Node compatibility. What it
provides is a set of runtime extensions a host installs, not a default host
environment.
Embed it
Native hosts can embed GocciaScript to run portable JavaScript with
application-specific globals, modules, capabilities, and limits. A host can
answer fetch through its own transport,
mark sandbox paths read-only, and stop a run from another thread through an
abort handle. A stop
takes effect at the engine's next check, so a native call blocked outside the
engine is not interrupted until it returns; give such calls their own deadlines
or isolate the process. A host can also snapshot the object graphs the snapshot
codecs cover and restore them in a fresh engine. A graph it cannot write is
refused, and the host resumes by replay instead; a run paused at a checkpoint
still holds pending promises with no codec, so its snapshot is refused today
(Heap Snapshots). See
Embedding the Engine.
An engine starts with the recommended language profile and without dynamic code
generation. A host changes that with a few knobs, one by one; there are no
presets:
Engine.Compatibility turns on the ECMAScript forms the recommended profile
leaves out (--compat-* on the command-line hosts);
Engine.FunctionConstructor.Enabled turns on the Function() constructor
(--unsafe-function-constructor);
EnableShadowRealm installs the ShadowRealm global
(--unsafe-shadowrealm);
EnableEval installs eval(); only an embedder can call it, since no
command-line flag or config key turns it on
(ADR 0179).
Embedding — Changing the Defaults
documents each knob.
The host also chooses its runtime extensions: fetch, URL,
TextEncoder/TextDecoder, Blob, AbortController and EventTarget today,
a virtual filesystem, and Node.js compatibility to a degree. The Web APIs React
server rendering relies on, such as MessageChannel, ReadableStream and
crypto, are planned (#1562);
none of them ships yet.
Where it is going
The goals, in the order VISION.md sets them. The stable C ABI and
.gcbundle are planned; neither ships yet.
- Conformance. All of test262 in every mode it requires, strict and
non-strict, Annex B and staging included. Progress is on the
compatibility dashboard.
- Performance. An interpreter faster than QuickJS first, then
.gcbundle
bytecode artifacts, an opt-in baseline JIT and a compiled executable; see
Benchmarks.
- 1.0. A stable C ABI and public API, all of test262, an interpreter faster
than QuickJS, and
.gcbundle.
Reference host: a sandbox for AI agents
GocciaRunner's sandbox mode is a reference host and an example of what an
embedder can build on the capability model, the virtual filesystem and the
runtime extensions: a runtime for code that AI agents generate. It copies
explicit host paths into an in-memory
virtual filesystem, runs an entry script with host-owned limits, and reports
sandbox changes as a diff. Copies are snapshots, not live mounts, and scripts
receive no ambient host filesystem access.
// agent-workspace/main.js
import fs from "fs";
const input = fs.readFileSync("/task.txt", "utf8");
fs.mkdirSync("/out", { recursive: true });
fs.writeFileSync("/out/result.txt", input.toUpperCase());
GocciaRunner agent-workspace/main.js \
--copy agent-workspace/task.txt \
--timeout=5000 \
--diff
(From a source build, the binary is ./build/GocciaRunner after
./build.pas runner.)
The entry file lands at /main.js and the copied input at /task.txt.
Nothing the script writes reaches the host unless the host asks for it: an
input copied with --copy-rw instead of --copy has the files a successful
run changed inside it written back to their host paths, and everything else in
the virtual filesystem is discarded. A program that only reports and a program
that fixes are therefore the same program, and the difference is a word on the
host's command line. See
Permissions — Sandbox mode.
The host can also define globals, virtual modules, network grants
(--allow-net), instruction and memory limits, deterministic time/randomness, and
application-specific APIs. See Build System — GocciaRunner sandbox mode
and Built-ins — Sandbox Modules.
ECMAScript implementation and recommended profile
GocciaScript implements core ECMAScript and runs the official test262 corpus on
every PR and on main. The exact current result is rendered from published
main-branch data on the live
ECMAScript compatibility dashboard;
canonical prose does not freeze a historical percentage.
The recommended language profile is modern by default, so new code stays
explicit, and each core form it disables has a flag a host can turn on. It is
product policy, not the implementation ceiling. Standard core forms disabled by default all have
explicit compatibility paths:
| Form |
Default |
Enablement / exposure |
var |
Disabled |
--compat-var |
traditional function syntax |
Disabled |
--compat-function |
== / != |
Disabled |
--compat-loose-equality |
| ASI |
Disabled |
--compat-asi |
| labels |
Disabled |
--compat-label |
traditional for(;;) |
Disabled |
--compat-traditional-for-loop |
for...in |
Disabled |
--compat-for-in-loop |
while / do...while |
Disabled |
--compat-while-loops |
arguments |
Disabled |
--compat-arguments-object |
non-strict Script semantics and with |
Strict / disabled |
--compat-non-strict-mode |
eval |
Not installed |
engine option EnableEval only (no CLI flag) |
Function() |
Disabled |
--unsafe-function-constructor |
ShadowRealm |
Not installed |
--unsafe-shadowrealm |
Annex B's legacy browser features are part of the test262 conformance target.
The ones that already ship stay as they are, and new ones will go behind a
compatibility flag, added by the 0.18.0 Annex B work, that the test262 runner
turns on; see
ADR 0177.
See Language and Language Tables
for the detailed semantics and feature matrix.
TC39 Type Annotations and --strict-types
GocciaScript implements the official
TC39 Type Annotations proposal and
its types-as-comments runtime model. Supported annotations have no runtime
effect by default. GocciaScript additionally provides the optional
--strict-types extension, which enforces supported annotations and relevant
inferred primitive contracts at runtime.
--strict-types is a runtime contract extension, not a replacement for a static
structural type checker such as tsc. See
Type Annotations for the supported syntax and its
parsing rules.
Node compatibility, to a degree