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-10</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
In the settings overlay, lets add a couple things.
- export save data JSON button / link
- nuke the existing game button / link
- move "give" and "spawn" to top
- move "input" section to bottom (track bar is in way)
- Assistant
I’ll trace the settings overlay implementation first, then make the UI changes in the existing style and run the focused checks I can find for that area.
- Assistant
The overlay wiring appears to be split between display UI and
src/main/ui/inventoryDataProvider.jsfor debug actions. I also picked up the local RTK instruction, so I’ll usertkfor the remaining shell commands. - Assistant
I found the settings renderer in src/display/ui/overlayRenders.js and the main-side settings actions in src/main/ui/inventoryDataProvider.js. Next I’m checking how saves are currently persisted so the export/delete actions use the existing save path.
- Assistant
The save key is
jshack:savegame:v1, with autosave insavegameWiringand load/remove controls already inindex.html. I’m going to add display-side export/delete helpers around that key, and keep the destructive action behind a confirm. - Assistant
The requested order is straightforward: I’ll put Give/Spawn immediately under the tabs, keep gameplay/debugging after that, add a Save Data section, and move Input to the end of the scroll content above the version row. The delete action will remove the saved game payload and reload so the boot flow starts fresh.
- Assistant
I’m about to edit only the settings renderer. The save export can be fully display-local because the payload already lives in localStorage as JSON.
- Assistant
The renderer is patched. I’m checking the surrounding save storage now because “nuke existing game” may need to clear floor snapshots as well as the root save payload, depending on how this repo names those keys.
- Assistant
clearFloorCache()removesjshack:floor:*as part of a true new-game reset, so I’m mirroring that behavior in the button rather than only deleting the root save. The first syntax/module check passed. - Assistant
The nuke action now removes the save payload plus persisted floor caches before reload. I’m running the repo guardrail check and the closest existing tests for settings/input/save behavior.
- Assistant
One behavior tweak: I’m leaving Export disabled when there is no autosave JSON, but making Nuke Game available regardless so it can reset the current in-memory run too. That better matches “existing game” from inside the overlay.
- Assistant
The final UI behavior is in place. I’m rerunning the module check and the touched-area tests after that last adjustment.
- Assistant
Checks are clean. I’m doing one last diff read for ordering and accidental scope before I wrap this up.
- Assistant
Implemented in src/display/ui/overlayRenders.js:
- Moved
GiveandSpawnto the top of Settings. - Added
Save Datacontrols:Export JSONdownloadsjshack:savegame:v1.Nuke Gameconfirms, clears saved game plusjshack:floor:*cached floor data, then reloads.
- Moved the whole
Inputsection to the bottom, above version/subscribe.
Verified with:
deno check src/display/ui/overlayRenders.jsdeno test --allow-read tests/inputSettings.test.mjs tests/inventoryDataProvider.test.mjs tests/savegameWiring.test.mjsdeno task checkgit diff --check
- Moved
- User
export JSON cannot be clicked double check resurrect pet (I dont think it works)
- Assistant
I’ll re-open the settings renderer and pet resurrection path, then adjust the buttons based on actual behavior rather than assuming the prior wiring is enough.
- Assistant
I see the export button is explicitly disabled when there is no autosave payload, which explains the dead click. I’m also checking whether dead pets keep their entity or get destroyed; that decides whether “resurrect” can work as written.
- Assistant
The pet issue is real. When a pet dies, cleanup destroys the creature and creates a corpse item tagged
Pet; the settings code sees that corpse as “alive” because it hasPosition, disables the button, and the resurrect handler skips it. I’m going to make the settings action recognize pet corpses and turn them back into a live pet entity. - Assistant
There’s already resurrection-like pet recreation code in deity handling, and starter pet creation in runtime. I’ll keep this scoped in the settings provider: detect a pet corpse item, remove it, and create a fresh pet at the player with the corpse’s name/identity.
- Assistant
For export, the better fix is to export the live world through the existing main-side provider, not depend on whether the autosave key happens to exist. I’m adding a
ui:requestSaveDataExportevent that returns JSON, then the settings button will always be clickable. - Assistant
I’m going to touch two files: the settings renderer for the export request/download flow, and
inventoryDataProviderfor live export plus real pet-corpse resurrection. - Assistant
I’ve added the event path for live export. Next I’m adding small local helpers in the provider so settings can tell live pets from pet corpses and recreate the companion correctly.
- Assistant
I’m also adjusting the settings data calculation:
Pet + Positionwas too broad because pet corpses are floor items withPosition. It should report alive only when there is a pet creature withVitality > 0. - Assistant
The first pass is in. I noticed one small state detail while reading it back:
lastPlayerX/Yshould track the player, not the corpse tile, so I’m correcting that before tests. - Assistant
Now I’m adding focused tests for both regressions: export responds with JSON from the live world, and a pet corpse enables the button state and resurrects into a live pet.
- Assistant
The tests will use the same UI events as the overlay, so they’ll catch the broken integration rather than only the helper internals.
- Assistant
The focused tests are added. I’m running them now; if the ECS destroy semantics or serializer shape differ from the assumptions, I’ll adjust against the real output.
- Assistant
The resurrect code did create the pet, but the ECS reused the corpse entity id after destroy, so the test excluded the valid result. I’m fixing the test to assert the entity’s components instead of assuming a new id.
- Assistant
The assumption mismatch is fixed. I’m rerunning the focused suite and then I’ll run the broader checks.
- Assistant
The focused provider tests now pass. I’m running the settings-adjacent tests plus project guardrails once more after these fixes.
- Assistant
One more robustness fix: the live game usually leaves a corpse item, but tests and edge states can have a dead pet creature with
Vitality <= 0still on the map. I’m updating the fallback branch so that resurrects too instead of skipping it just because it hasPosition. - Assistant
That fallback is now covered by the same handler path. I’m rerunning the checks after the final change.
- Assistant
The rerun is clean. I’m checking the final diff now to make sure the export renderer changes and provider changes are both present and scoped.
- Assistant
There are already staged changes from the earlier settings work (
M/MMstatus), so the plain diff only showed my latest unstaged delta. I’m reading the staged diff too so I can summarize the full current state accurately without altering staging. - Assistant
The staged view is older than the working tree because the last cleanup removed a test import and tightened the fallback. I’m doing one final guardrail run so the final answer reflects the actual working tree, staged plus unstaged.
- Assistant
Fixed both.
Export JSONis now always clickable and requests a live save export frominventoryDataProvider, instead of depending onlocalStoragehaving an autosave key.Resurrect Petwas broken: dead pets become corpse items taggedPet, so settings thought the corpse was an alive pet and disabled/skipped resurrection. I changed the pet status check to require a live creature withVitality > 0, and resurrection now turns a pet corpse back into a live pet.Changed:
- overlayRenders.js
- inventoryDataProvider.js
- inventoryDataProvider.test.mjs
Verified:
deno check src/display/ui/overlayRenders.js src/main/ui/inventoryDataProvider.js tests/inventoryDataProvider.test.mjsdeno test --allow-read tests/inputSettings.test.mjs tests/inventoryDataProvider.test.mjs tests/savegameWiring.test.mjs
- User
why make a new save-game key variable instead of using the canonical one?
- Assistant
You’re right to call that out. I used a local constant because the existing
SAVEGAME_KEYlives inmain/wiring/savegameLoad.js, and importing that fromdisplay/ui/overlayRenders.jswould drag main/rules restore code across the display boundary. The cleaner fix is to move the key itself into a tiny shared constant module and re-export it from the old location. I’ll do that now. - Assistant
I confirmed the only browser-display duplicate is the one I added. I’m moving the constant to
src/sharedso display can depend on it without importing main restore logic. - Assistant
The key now has a shared canonical home, and
savegameLoad.jsstill re-exports it so existing imports keep working. I’m running the focused checks. - Assistant
Because importing the existing
SAVEGAME_KEYfromsrc/main/wiring/savegameLoad.jsinto display UI would violate the layer boundary: that module also imports restore/serialization/rules utilities. So I duplicated the string locally to avoid that import, but you’re right: that’s still worse than having a canonical shared constant.I fixed it by adding src/shared/savegameKeys.js, importing it from the settings overlay, and re-exporting it from savegameLoad.js so existing callers keep working.
Verified with:
deno check ...deno test --allow-read tests/savegameLoad.test.mjs tests/savegameWiring.test.mjs tests/inventoryDataProvider.test.mjsgit diff --check
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.