AGENTS.md instructions for /home/pjensen/Repos/JSHack <INSTRUCTIONS>…
- User
AGENTS.md instructions for /home/pjensen/Repos/JSHack
--- project-doc ---
AGENTS.md - JSHack Field Manual
JSHack is a zero-dependency browser roguelike: pure JavaScript, pure ES modules, ECS architecture, Deno tooling. This file is optimized for coding agents. Prefer the commands below over manual spelunking.
Deeper docs:
- README.md
- SEPARATION_MANIFEST.md
- RUNTIME_TOPOLOGY_DOCTRINE.md
- TEN_COMMANDMENTS.md
- ecs-js/AGENTS.md
Hard Laws
- No build step. Pure ES modules. No webpack, babel, JSX, TypeScript, or bundling.
- Deno, not Node. Tests and tools run with Deno. Default test command:
deno test --allow-read. - JavaScript only. Keep source as
.js/.mjs. - Mobile-first. Touch is primary; desktop keyboard is secondary.
- Separation is law.
rules/never importsdisplay/orbridge/;display/never importsrules/;bridge/projects read-only rule state. - No system-to-system calls. Systems communicate with
world.emit/world.on; scheduler owns ordering. - New events use concrete event classes. Any new event contract must define
a concrete
EcsEventclass and emit an instance withworld.emit(new Event(...)). Do not introduce string-only events or parallel string re-emits for new contracts. - Touched listener installers use canonical extensions. Any new listener
installer, or any existing listener installer touched during a task, must use
defineExtension(...)andworld.install(...)for idempotent installation. Do not add new bespoke symbol-guard installers. - No swallowed event failures. Do not add
emitSafe-style wrappers aroundworld.emit.
- User
<environment_context> /home/pjensen/Repos/JSHack bash <current_date>2026-06-12</current_date> America/New_York <workspace_roots>/home/pjensen/Repos/JSHack</workspace_roots><permission_profile type="managed"><file_system type="restricted">:root/home/pjensen/Repos/JSHack:slash_tmp:tmpdir/home/pjensen/Repos/JSHack/.git/home/pjensen/Repos/JSHack/.agents/home/pjensen/Repos/JSHack/.codex</file_system></permission_profile> </environment_context>
- User
so we have an entire listing of materials in materials.js
I've also added lighting-engine-work.html that shows roughly how to incorporate materials into the lighting syste,
our first objective is to incorporate material lighting interactions.
our second objective is to change the way void lighing works to make it more official.
both are representing in the new HTML file -- your job is to backport them into engine.js
and to make sure it's solid as it can be.
- Assistant
I’ll inspect the lighting demo and current engine path first, then backport the smallest coherent version into
engine.jswith focused verification. - Assistant
I found the relevant files: the demo lives in
tools/lighting-engine-work.html, the target issrc/display/lighting/engine.js, and material definitions are insrc/rules/data/materials.js. I’m reading those side by side to separate demo-only scaffolding from engine behavior. - Assistant
The existing engine already has a negative-light void hack inside
resolveDarknessAlpha; the demo separates void into its own field, which is the main architectural difference. Next I’m locating the demo’s material response and render loops so I can map it onto the production buffers without importing rules data into display. - Assistant
The demo’s material system is callback-driven (
materialAt(tx, ty)) and uses compact material properties at render time. Production already has the same style for opacity and roofing, so I’ll keep display decoupled by accepting material lookup data as render options instead of importing rule catalog data directly. - Assistant
I’ve got enough shape now. I’m going to add three production pieces: material response helpers, a
voidFieldbuffer with first-class absorption, and optional material callbacks through the existingoptsobject so the current render call stays backward-compatible. - Assistant
The bridge does not appear to project tile materials into
WorldView;main.jsalready has access to ECSPositionandMaterial, so I’ll derive a render-time material lookup in app wiring and pass only a callback into the display engine. That keeps the import boundary intact. - Assistant
I’m making the engine changes now. The material lookup will be optional; if no caller supplies it, lighting behaves like the old neutral path except for the new void handling semantics.
- Assistant
A compatibility detail surfaced: existing sources may encode “dark” effects as negative RGB, while the demo uses
kind: "void"/voidStrength. I’m preserving both entry points but normalizing them into the newvoidFieldinstead of letting negative light sums drive darkness implicitly. - Assistant
There is already a
voidLight()source helper that emits negative RGB. I’ll update the engine to translate that source shape into an absorption field, so callers do not need to change immediately. - Assistant
I’m editing
engine.jsnow: adding exported material-response helpers for tests, allocating the void buffer with the other light buffers, and changing accumulation/render to consume materials and void separately. - Assistant
The helper is in place. Next I’m switching
resolveDarknessAlphafrom “negative light means void” to an explicitvoidAmount, while leaving a compatibility bridge for older negative sums. - Assistant
The void buffer now exists. I’m patching the light accumulation loop so normal emitters tint through material albedo/reflectance, material emitters can add a small glow, and void sources only write absorption.
- Assistant
The engine-side backport is wired. I’m now adding the caller-side material map in
main.js, sourced from ECSMaterialcomponents plus the material catalog intrinsics, and passing it through the existing lighting render options. - Assistant
I found a good home for the material collector near the lighting viewport helpers. It will only index entities inside the active lighting viewport, so the callback stays cheap in the sub-cell loop.
- Assistant
The material collector is in place. I’m connecting it to the lighting render call and then I’ll add focused tests for material response and void behavior.
- Assistant
I’m adding regression coverage in the existing lighting test file: one test for material optical fields producing distinct lighting response, and one for void darkness being explicit instead of relying on negative light totals.
- Assistant
The code and focused tests are updated. I’m running the lighting tests first, then the project check/guardrails if those pass.
- Assistant
The focused lighting tests and
deno checkpassed. I’m running the repository guardrail task now to catch boundary/event issues from the new wiring. - Assistant
Guardrails passed. One source helper still describes void as negative RGB, so I’m tightening that up to emit the official
kind: "void"/voidStrengthfields while keeping the engine compatibility path. - Assistant
The void source helper now emits the official shape. I’m rerunning the focused lighting test plus the source file check after that small API cleanup.
- Assistant
Focused verification is still clean. I’m running the full
deno task checkone more time after the source helper change. - Assistant
All guardrails passed again. I’m doing a final diff review now to catch any accidental scope creep or obvious runtime mistakes before I wrap up.
- Assistant
The diff is scoped to lighting plus the caller hook;
.gitignoreand the demo HTML were already present and I’m leaving them untouched. I spotted one unused local in the new helper and am cleaning it before the final response. - Assistant
That cleanup is done. I’m running a final quick verification pass on the changed lighting files.
- Assistant
Implemented the lighting backport.
Changed:
- engine.js: added material optical response from catalog-style fields, first-class
voidFieldabsorption, material emission/voidstone behavior, and explicitvoidAmountdarkness handling. - sources/index.js: updated void lights to emit official
kind: "void"/voidStrengthdata instead of negative RGB. - main.js: builds a viewport-scoped material lookup from ECS
Position + Materialandmaterials.jsintrinsics, then passes it into the lighting engine. - lightingFog.test.mjs: added coverage for material response and explicit void darkness.
Verification passed:
deno test --allow-read tests/lightingFog.test.mjs
- engine.js: added material optical response from catalog-style fields, first-class
- User
it looks really really blocky, like one dungon tile, what did you do?!
- Assistant
You’re right. The bad part is the caller hook I added: it treated any entity with
Materialon a tile as the tile’s lighting material, so items/actors could tint an entire dungeon tile at sub-cell render time. I’m going to narrow that immediately so only opaque/vision-blocking material-bearing tiles can affect the tile lighting path. - Assistant
The safer fix is to back out the entity-to-tile projection entirely. The engine can still consume real tile material data, but the game does not currently project terrain material per tile; using item/actor materials as a substitute was the blocky artifact.
- Assistant
I removed the bad material callback from the live render path. Now I’m checking that
main.jsis clean and that the lighting tests still cover the engine support and void changes. - Assistant
The quick checks pass, and the bad live hook is gone. I’m running the normal guardrail task once more because this touched app wiring.
- Assistant
You were seeing tile-sized material blocks because I incorrectly projected entity
Materialcomponents into the tile lighting callback. That made items/actors on a tile behave like the whole dungeon tile was made of that material.I fixed it by removing that live
main.jsmaterial projection. The engine still has the backported material-response support for a real tile-material callback, and void lighting remains official viakind: "void"/voidStrength, but the current game render path no longer applies entity materials as tile materials.Verification passed:
deno check src/display/lighting/engine.js src/display/lighting/sources/index.js src/main.js tests/lightingFog.test.mjsdeno test --allow-read tests/lightingFog.test.mjsdeno task check
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.