# djs in Code Mode

nanocode embeds a modified djs JavaScript engine for Code Mode, where model-written programs call tools and process their results. This page separates upstream work, local changes, and historical measurements.

## Upstream Credit

[djs](https://github.com/earendil-works/djs) originates at Earendil. Its [initial commit](https://github.com/earendil-works/djs/commit/80b129885bf2deb59fef7d190ab54ec471e753f3) names Armin Ronacher as author. Credit belongs to Earendil and its contributors, not nanocode.

The [vendor commit](https://github.com/nanocodexyz/nanocode/commit/3a668d9949baaaaedaa18ac6bc3e4a191cb422f2) imports [upstream `0e58f62`](https://github.com/earendil-works/djs/commit/0e58f62c80252fc3f4156ab7a3744746434ed860). The modified copy lives [inside nanocode](https://github.com/nanocodexyz/nanocode/tree/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/djs), not a separate djs repository.

The source retains Earendil Inc.'s [MIT](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/djs/LICENSE-MIT) or [Apache](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/djs/LICENSE-APACHE) license choice. The [math module](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/djs/crates/djs-libm/src/lib.rs) also credits rust-lang libm, musl, and FreeBSD. Its separate notices remain in the source and [license inventory](/experiments/evidence/fork-djs.json).

## Measured Change

The [escaped-JSON change](https://github.com/nanocodexyz/nanocode/commit/a525631653ea9b99640845aae0dfb41f9be3ddf1) reuses a decoding buffer and a lookup table. It removes repeated buffer-length updates and escape dispatch from tool-result parsing.

The table reproduces the [historical run](/experiments/evidence/fork-djs.json), not a new benchmark. The [public measurement record](https://github.com/nanocodexyz/nanocode/blob/a525631653ea9b99640845aae0dfb41f9be3ddf1/DECISIONS.md#L3) identifies `output/cellbench --vary`, user-mode CPU instructions, and best-of-three runs. It compares [baseline `29b3e79`](https://github.com/nanocodexyz/nanocode/commit/29b3e79456e40ba13363a7ae3ac6d0d5fd5dc1a5) with the escaped-JSON commit.

| Workload             | Before Instructions | After Instructions | Evidence                                               |
| -------------------- | ------------------: | -----------------: | ------------------------------------------------------ |
| Typical-cell suite   |           6,168,073 |          6,095,030 | [Run and commits](/experiments/evidence/fork-djs.json) |
| Sequential-tool cell |             884,510 |            851,061 | [Run and commits](/experiments/evidence/fork-djs.json) |
| JSON cell            |           1,327,852 |          1,308,157 | [Run and commits](/experiments/evidence/fork-djs.json) |
| Edit cell            |             962,373 |            949,223 | [Run and commits](/experiments/evidence/fork-djs.json) |
| Shell-output cell    |           1,401,376 |          1,394,640 | [Run and commits](/experiments/evidence/fork-djs.json) |

## Checks and Limits

The same [record](https://github.com/nanocodexyz/nanocode/blob/a525631653ea9b99640845aae0dfb41f9be3ddf1/DECISIONS.md#L3) reports identical cell outputs, unchanged fuel checks, and the same passing test262 subset. This subset does not establish full JavaScript conformance.

Raw per-run samples and a confidence interval are unavailable here. The record does not identify the CPU model. Instruction counts are not wall-clock latency, and this result does not establish an end-to-end agent speedup.

## What Remains

The [later local history](https://github.com/nanocodexyz/nanocode/commits/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/djs) includes generator execution, array callbacks, and generational collection changes. They are separate changes, not components of the measured JSON delta.

The next useful comparison is the same cell corpus across pinned engines with fresh raw samples and memory measurements. No unmeasured improvement is included in the table.
