3.3 KiB
3.3 KiB
ADR 0016: JavaScript Tool Verification
Status
Accepted
Date
2026-06-10
Context
The repository now contains tools/mcp-bridge, a TypeScript Node.js tool that sits next to the ComputerCraft Lua code. It has a different build and test lifecycle than TrapOS packages, but it still participates in the same local developer workflow and Git hooks described by ADR-0011.
The bridge also needs future end-to-end coverage that spans both runtimes: a host Node process and a headless CraftOS-PC computer. That is broader and slower than normal unit tests, and it needs the same kind of timeout discipline as the Lua harness in ADR-0007.
Decision
Keep the Node package scripts simple and one-purpose:
npm run buildemits TypeScript intodist/and acts as the type-check gate.npm run testruns the Node unit tests directly from TypeScript withtsx --test test/*.test.ts. No prior build is required.npm run checkruns ESLint. TypeScript compilation is covered bynpm run buildandnpm run test:cito avoid duplicate compiler runs in repository CI.npm run test:cirunsnpm run check && npm run build && npm run test, so type errors and lint failures both surface even thoughtestitself no longer compiles.npm run test-integrationruns the bridge-to-CraftOS integration suite withtsx --test --test-concurrency=1 test-integration/*.test.ts. Each case boots the bridge in-process on fixed loopback ports (127.0.0.1:2000for MCP HTTP,127.0.0.1:2001for the CraftOS link), spawns a CraftOS-PC headless computer that connects back, exercisestools/call probe-computers, and tears everything down.--test-concurrency=1keeps the fixed ports collision-free.
Expose matching repository recipes for the Node lifecycle:
just builddelegates tonpm run buildfor the bridge.just testdepends onjust build, runsnpm run test, then runs the existing CraftOS-PC test suite.just checkincludesnpm run checkalongside Lua and Markdown checks.just ciusesnpm run test:ci, then runs CraftOS-PC tests and the broader integration/harness target.just test-integrationruns the placeholder Node integration target and the Lua timeout harness checks.
Consequences
npm run testno longer needsdist/. Both unit and integration tests load TypeScript directly throughtsx, so test iteration is faster anddist/is only required fornpm start.- TypeScript errors are no longer caught by
npm run test; they are caught bynpm run build, which stays wired intonpm run test:ci,just build,just test, andjust ci. just ciavoids duplicating Node unit tests by callingnpm run test:cidirectly and then invoking only the CraftOS-side test body.- ESLint failures are part of
just check, so they are covered by the same pre-commit and pre-push hooks as Lua and Markdown checks. - Integration tests live in
tools/mcp-bridge/test-integration/, with Lua client fixtures undertest-integration/lua/. Slow end-to-end behavior stays out of the fast unit-test path.
Future Work
- Extend the integration harness with disconnect and reconnect scenarios (computer drops mid-probe; bridge restarts while a computer is connected) once those failure modes need regression coverage.