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 imports display/ or bridge/;
display/ never imports rules/; 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 EcsEvent class and emit an instance with
world.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(...) and world.install(...) for idempotent installation.
Do not add new bespoke symbol-guard installers.
No swallowed event failures. Do not add emitSafe-style wrappers around
world.emit.
No new world-attached state. Do not attach simulation state to world
with symbol or property keys (world[...], ctx.world[...]). Use ECS
components for state; when the state is genuinely world-scoped, model it as an
explicit singleton entity/component and document the allowance. Existing
world-attached state is a ratcheted architecture debt tracked by
ratchets/worldStateAttachmentRatchet.test.mjs.
Determinism is sacred. In rules simulation use world.rand(), never
Math.random(). No timers/fetch/promises/async in systems.
Integer grid only. World coords may be negative. Do not clamp to >= 0;
normalize with Number.isFinite(v) ? (v | 0) : fallback.
One canonical path. Spawn, damage, spell cast, status application,
inventory transfer, and materialization paths must delegate to the canonical
implementation.
Runtime multiplicity is child entities. Runtime
effects/procs/sockets/enchantments are child topology, not arrays on parent
components.
ECS-js is vendored. Do not edit src/lib/ecs-js/ unless fixing the ECS
library itself.
Authoring discipline. Do not touch unrelated code. Do not make changes
that do nothing. Always match the formatting preferences that already exist;
be a chameleon.
Search before writing. Extend existing patterns. Do exactly what was
asked; no opportunistic content wiring or unrelated cleanup.
Agent Commands
Run these before guessing.
Guardrail Tasks
Prefer these Deno tasks over hand-assembled command strings:
deno run --allow-read tools/agent-health.mjs
deno run --allow-read tools/import-boundary-report.mjs
deno run --allow-read tools/system-map.mjs
agent-health summarizes boundary violations, remaining emitSafe refs,
nondeterminism hazards, generation-time async allowances, system counts, and
possible system-to-system calls. Classified allowances are context for agents;
headline hazards are the things to investigate first.
Event Bus
bash
deno run --allow-read tools/event-bus-explorer.mjs --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --format csv --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --format mermaid --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --producer-only --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --consumer-only --format summary --top 40
Use producer-only events to find emitted behavior with no consumer. Use
consumer-only events to find stale listeners, dynamic producers, or missing
producers.
System Map
bash
deno run --allow-read tools/system-map.mjs --format summary
deno run --allow-read tools/system-map.mjs --format csv
deno run --allow-read tools/system-map.mjs --phase effects
deno run --allow-read tools/system-map.mjs --unregistered
deno run --allow-read tools/system-map.mjs --missing-tests
Scheduler truth lives in src/main/scheduler.js. Some
imported-not-registered files are listener installers, not phase systems; audit
before deleting.
Target Lookup
bash
deno run --allow-read tools/agent-target.mjs damaged --limit 80
deno run --allow-read tools/content-id-audit.mjs goblin --limit 80
deno run --allow-read tools/content-id-audit.mjs potion_water --limit 80
agent-target is a ranked code search for events/functions/files/tests.
content-id-audit follows item, monster, spell, material, loot, visual, and
test references by ID.
Focused Tests
bash
deno test --allow-read tests/separationBoundaries.test.mjs
deno test --allow-read tests/determinismArchitectureGuards.test.mjs
deno test --allow-read tests/schedulerArchitectureGuards.test.mjs
deno test --allow-read tests/dealDamage.test.mjs
deno test --allow-read tests/castSpell.test.mjs
deno test --allow-read tests/interaction.test.mjs
deno test --allow-read tests/movementRefactored.test.mjs
deno test --allow-read tests/contentCatalogCanonical.test.mjs
Full runtime suite:
bash
deno test --allow-read --no-check
Plain deno test --allow-read may fail during type-check on non-game packaging
scripts before tests run. Use --no-check when you need runtime coverage.
rules/ deterministic simulation; no DOM, display, timers, async systems
bridge/ read-only projection from rules state to WorldView DTOs
display/ presentation only; reads WorldView and main-provided contracts
main/ wiring, lifecycle, input dispatch, scheduler setup
shared/ pure math/grid utilities; no ECS or DOM
lib/ vendored ecs-js and deity-js
content/ DSL-authored content definitions and content helpers
Five scheduler phases are declared in
src/main/scheduler.js:
text
ai intent producers
intents movement/combat/use/cast/interaction consumers
effects per-turn derived effects and world simulation
scripts content DSL tick hooks
cleanup entity removal, lifespan, spatial sync
The bridge contract is
src/bridge/schema/worldView.js. Display must
not push tags onto entity records; tag projection belongs in the bridge.
Install listeners with world.install(featureListeners) from configureWorld()
unless the feature is display/main wiring.
New Systems
Add src/rules/systems/mySystem.js.
Register it in src/main/scheduler.js in the right
phase.
Add a focused test in tests/.
Run deno test --allow-read tests/mySystem.test.mjs.
Spatial Queries
Use forEachInRadius, forEachInRect, or tile query helpers. Do not full-scan
world.query() for proximity-sensitive behavior.
Spawning
Route through canonical archetypes/materialization helpers. Debug spawns,
dungeon population, and spawner children must have parity tests if they differ.
Events
New event contracts must be concrete EcsEvent classes:
want to incorporate a lock-picking ux modal based on the following.
two constructor args
number of pins
difficulty
You should see the extension points already.
NOTE: this is almost certainly an overlay
NOTE: as regards triggering the overlay, a debug command would be sufficient to start instead of adding rules side components etc.
so this will be focused on the UX portion, what extensibility it offers, constructor injection details, etc.
User
<turn_aborted>
The user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.
</turn_aborted>
User
good? you workin?
Assistant
I’m here. The previous turn was interrupted, so I’m going to re-establish context: first I’ll read the pasted spec and the existing UI/debug extension points, then I’ll implement the lock-picking overlay without touching rules-side gameplay state unless the codebase already has a UX hook for it.
Assistant
The pasted reference is a self-contained browser prototype with a canvas lock face, tension pad, pin rules, and clear “extend here” points. I’m checking the existing overlay and debug-console APIs now so the implementation fits the project’s current UI wiring instead of creating a parallel path.
Assistant
One important fit point: the debug console can already dispatch browser UI events cleanly, and initOverlays() owns modal panels. I’m going to add this as a display UI overlay module, wire it through ui:openLockPicking, and add a lockpick [pins] [difficulty] debug command that injects those two constructor args.
Assistant
I found the panel stack and modal helpers. The lock UI will be self-contained enough to be reusable, but the overlay entry point will stay in overlay.js with the rest of the display-only panels.
Assistant
I’m going to split the lock picker into a reusable display module with a small game-state class plus a renderer. The constructor surface will be new LockPickingMiniGame(pinCount, difficulty), while ui:openLockPicking and the debug command are just adapters into that constructor.
Assistant
I’m applying the UI now. The implementation keeps the minigame logic deterministic per seed inside the display module, exposes named difficulty profiles plus object overrides, and emits a completion event so future rules/main wiring can listen without changing the picker internals.
Assistant
The overlay module is in place. I’m wiring the open/close event and debug command next, then I’ll add focused tests for the injected constructor values and command parsing.
Assistant
The overlay is now part of the existing modal stack and hides alongside other mutually exclusive panels. I’m adding the debug trigger as a browser UI event adapter, so it does not introduce rules components or simulation state.
Assistant
The command is added as lockpick [pins] [difficulty]. I noticed the first pass only sent a cancel result on Escape, so I’m tightening that before tests so close button/backdrop cancellation has the same completion behavior.
Assistant
I’m adding narrow tests now: one verifies the debug command dispatches ui:openLockPicking with the requested pin count and difficulty, and one verifies the minigame constructor normalizes those injected values.
Assistant
The tests are in place. I’m running the focused suite now, then I’ll run the project guardrails that are relevant for a display/debug-only change.
Assistant
Focused tests pass. I’m running deno task check next because this touched display wiring and debug command registration, and the repo has architecture/event guardrails for that.
Assistant
The project check passed. I’m doing a quick diff review now for accidental scope creep and then I’ll start the local static server if the repo has a standard serve task.
Assistant
The standard deno.json has no serve task, so this is just a static app. I’m checking the new module directly now because the diff summary only showed tracked files and skipped the newly added file content.
Assistant
The code review caught a rendering detail: the canvas was sized while the panel was still hidden, so the first real frame needed to refit after the panel is visible. I’m patching that and preventing duplicate completion events after success/cancel.
Assistant
That sizing/duplicate-event patch is in. I’m rerunning the focused tests and the guard task once more to make sure the final state is clean.
Assistant
Focused tests are still green. I’m running the full check task one more time after the last UI patch.
Assistant
Final checks are green. Since this app uses browser modules and there is no serve task, I’m starting a simple static server from the repo root so you can try the overlay in-browser.
Assistant
The sandbox blocked binding the local HTTP port. I’m requesting approval to start the same static server outside the sandbox.
Assistant
The server approval was declined, so I’m leaving the repo changes verified but without a running local URL. I’m grabbing line references for the final summary now.
User
I've got it from here.
Assistant
Implemented the lock-picking UX overlay and debug trigger.
Key points:
Added LockPickingMiniGame(pinCount, difficulty) in lockPickingOverlay.js.
Added reusable difficulty profiles and numeric difficulty ratings in lockPickingOverlay.js.
Wired ui:openLockPicking / ui:closeLockPicking into the existing overlay stack in overlay.js.
Added debug command lockpick [pins] [difficulty] in consoleCommands.js.
Overlay emits ui:lockPickingFinished with { success, reason, pins, difficulty }.
Verified:
deno test --allow-read tests/lockPickingOverlay.test.mjs
deno test --allow-read tests/consoleCommands.test.mjs
deno task check
I tried starting a local static server, but port binding needed approval and was declined, so no server is running.
User
I wonder, how the heck will we do this with keyboard, without haptics (which I've yet to see work on mobile) how the heck will we do any feedback?
screenshake (seems viable, this overlay only)
audio (this is a big todo sourcing this audio)
Assistant
Keyboard can work if we stop thinking “two thumbs” and make it a two-axis hold problem:
A/D or Left/Right: rotate pick around the lock.
W/S or Up/Down: adjust torque.
Space or Enter: hold pick contact / attempt setting.
Esc: cancel.
Optional: R: reset.
For feedback without haptics, I’d use layered local feedback inside the overlay:
Screen shake, scoped to the lock card/canvas
Light jitter when torque is too high near a pin.
Sharper pulse when a pin slips.
No global camera shake. The modal itself should feel like it is resisting.
Visual tension feedback
Torque bar color shifts green/yellow/red.
Pick tip flickers or bends when grinding.
Candidate pin gets a subtle charge glow only when angle is close.
Charge ring fills while holding the correct angle + torque.
False feedback can be reserved for higher difficulty later.
Audio, eventually
Tiny “tick” when near a pin.
Clean “set” click.
Dry scrape/grind loop or repeated tick when over-torqued.
Slip/clack when losing progress.
Unlock thunk.
This can be wired later through the display/audio layer once assets exist.
Text/status, but minimal
“Ease off.”
“Hold.”
“Clean set.”
Good as accessibility backup, not the primary feel.
The keyboard model I’d favor: continuous controls, not discrete steps. Holding Left/Right changes pick angle at a fixed rate; holding Up/Down changes torque. That lets keyboard players develop the same “feel” as touch users. For mouse, probably drag pick on canvas and use wheel or vertical drag on the torque rail.
The extensibility point should probably be a feedback adapter on the lock picker, something like:
Default implementation can do local shake + visuals now, and audio can plug into the same hooks later without rewriting lock logic.
User
most people have trackpads so I would not assume mouse is an easy thing, but I can agree with continuous -- yes yes and mostly yes
Assistant
Agreed. Trackpad should be first-class, not treated like a mouse-with-wheels.
I’d make the non-touch desktop control scheme:
Left/Right or A/D: continuous pick rotation.
Up/Down or W/S: continuous torque adjustment.
Space: engage pick pressure / “listen” for set.
R: reset.
Esc: cancel.
For trackpad/pointer:
Drag anywhere on the lock face: rotate pick continuously.
Drag the torque rail: adjust torque.
Avoid relying on wheel/scroll gestures.
Maybe allow one-finger vertical drag on the left third of the modal for torque and drag elsewhere for pick angle, so trackpad users do not need precision-target the rail.
Feedback stack should be:
local modal shake for grind/slip,
pin glow/charge for near-correct alignment,
torque color warning,
scrape/set/unlock audio later,
terse status text as fallback.
So the UX target is: touch and trackpad both use drag surfaces; keyboard uses continuous axes; no core interaction depends on haptics, mouse wheel, or hover.
User
I got an idea, the magnitude of the drag vector from the lock center is the force; this allows for clever mouse/trackpad play; maybe even mobile can adopt this too.
you see my point right?
it combines both axis into one simple interaction surface.
as regards feedback, agreed on all counts.
Assistant
Yes, that’s a better interaction model.
One drag surface can encode both controls:
Angle = direction from lock center to pointer.
Torque/force = distance from lock center.
Inner dead zone = no meaningful torque.
Outer clamp ring = max torque.
Pin set condition = angle near pin angle and radius/force near pin tension.
That maps cleanly across touch, trackpad, and mouse because the player is “feeling” for the correct polar coordinate instead of coordinating two separate controls.
I’d still keep keyboard as continuous fallback:
Left/Right: angle
Up/Down: force radius
Space: active pick contact, or maybe keyboard is always active while modal focused
For feedback, this model gives us stronger visuals:
draw a radial force ring / ghost target band,
pick shaft length grows with force,
too much force near a pin shakes the lock locally,
correct angle but wrong force can show scrape/strain,
correct force and angle charges the pin.
Implementation-wise, it simplifies the constructor logic too: each pin already has { angle, tension }, so pointer input becomes:
That’s a much cleaner UX spine than split pick + torque rail.
User
do it
Assistant
I’ll convert the lock picker from split pick/tension controls to a single polar drag surface: pointer angle controls pick angle, distance from center controls force. I’ll keep keyboard support as the continuous fallback and leave the existing feedback hooks/visuals intact where they still fit.
Assistant
I’m going to make the polar input explicit and testable: a small helper will convert center-relative drag coordinates into { angle, force, active }, and both pointer and keyboard paths will feed the same pickAngle/tension state.
Assistant
The core polar helper is in. Next I’m replacing the torque rail with lock-face drag behavior and updating the visuals so force reads as pick length/radial rings instead of a separate slider.
User
kill keyboard support -- waste of time.
Assistant
Got it. I won’t add keyboard movement/force controls. I’ll keep only the existing Escape-to-cancel behavior unless you want even that gone; the lock interaction itself will be pointer/touch polar drag only.
Assistant
The split torque rail is gone; the canvas/lock face is now the single interaction surface. I’m adding a small regression test for the polar conversion so the drag-distance mapping does not drift.
Assistant
I’m also removing the Escape key listener so there is no keyboard path at all. Close/backdrop remains pointer-driven.
Assistant
The keyboard path is gone. I’m updating tests for the polar drag mapping and then I’ll run the focused test set.
Assistant
The polar mapping test is added. I’m running the focused tests and checking for leftover keyboard/tension-rail references.
Assistant
Focused tests pass and there are no leftover keyboard or rail handlers. I’m changing the remaining “torque” wording to match the new force model, then running the repo check.
Assistant
The guard task is green. I’m doing a final diff/status check so I can summarize exactly what changed.
User
<turn_aborted>
The user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.
</turn_aborted>
User
when getting the lock to "open", clicking "open" should close the modal and return success condition to the caller, "successPickedListener" or some simular shape, that is propagated into rules via a turn consuming intent.
NOTE: failing the lockpick also consume the intent
NOTE: success or fail consumes the lockpick (see below)
next we're going to work to incorporate this into the rules
we can create a simple "Lockbox" almost variant of a chest.
when engaging with a lockbox, provided you do not have the key, and you have at least one [Lockpick] item in inventory -- open the lockpicking modal
A lockpick is a simple consumable item.
I have some open questions as to weather a lockbox may be picked up, and a lockpick subsequently "used" on it -- but honestly, I'm strongly leaning away from this at least on the first iteration.
you feel me?
ecs-js for the win.
Assistant
I feel you. The modal should not auto-report success the moment the pins solve; it should enter an “open” state, then the explicit Open action closes the overlay and returns success to the caller. I’ll make that callback shape display-side now, while keeping the later rules turn-consumption path as a clean caller concern.
Assistant
I’m updating the overlay contract now: solving the pins will only enable an open action, and the result will be delivered through listener callbacks plus the existing ui:lockPickingFinished event. Cancel/backdrop stays a failure result for the future turn-consuming path.
Assistant
The result callback shape is now in the overlay module. I’m adding tests for the success/failure listener routing so the later rules bridge can rely on it.
Assistant
Tests for listener routing are in. I’m running focused tests first, then the project check.
Assistant
Focused tests pass. One subtle point: reset after solve currently allows a later result again, which is useful while this is debug-only, but rules integration may want to hide reset or treat every modal close as terminal. I’m leaving reset as a debug UX affordance for now and running guardrails.
Assistant
Yes. I updated the modal side to match that flow.
What changed:
Solving the pins no longer auto-finishes the modal.
Solve now enables an explicit open button.
Clicking open closes the modal and returns success.
Cancel/close/backdrop returns failure.
Added callback hooks:
finishedPickedListener(result)
successPickedListener(result)
failedPickedListener(result)
The existing ui:lockPickingFinished event still fires with the same result payload.
Implemented in lockPickingOverlay.js, with tests in lockPickingOverlay.test.mjs.
Verified:
deno test --allow-read tests/lockPickingOverlay.test.mjs tests/consoleCommands.test.mjs
deno task check
And yes, the rules shape you described makes sense: lockbox interaction opens the modal from main/display wiring, modal result emits a turn-consuming lockpick intent, and both success/fail consume one lockpick item.
User
okay, time to nail down a first locked component, one "easy" vantage point is to allow lock picking the gem dealers door after they leave and lock up.
it's an easy strategy that short circuits new component creation.
except
we'd need "lockpick"x5 item in all classes inventory at start
Assistant
I’ll wire this through the existing door/interaction path if possible: first find how the gem dealer door locks, how starter inventories are assigned, and where item definitions live. Then I’ll add lockpick starter stacks and connect the locked-door interaction to the modal result without introducing a new lock component unless the existing door state forces it.
Assistant
The existing door system already has DoorState.locked, DoorLock.lockId, key checks, and shopkeeper AI locks doors when leaving. I’m reading the bump/interaction and inventory facade now so the lockpick result can become a normal rules intent that consumes a turn and a stack item.
Assistant
There’s a clean no-new-lock-component route: DoorState.locked + DoorLock.lockId stays the first “locked” surface. I’ll add a lockpick consumable item, have locked-keyless doors emit a lockpick prompt when the actor has one, and process the modal result through InteractIntent with a lockpick result mode so the actual success/fail consumes a rules turn.
Assistant
I’m using the repo’s add-item skill for the lockpick item so it lands in the canonical catalog/palette/test pattern. For the locked door path, I’ll reuse InteractIntent rather than adding a new intent component.
Assistant
The content DSL is the current item path, not the old direct catalog edit. I’m going to add lockpick in the economy tools area, give it a palette glyph, and then add a small rules utility for finding/consuming one stack item by identity so the door interaction stays concise.
Assistant
The rules interaction runner already passes the InteractIntent through as ctx.intent, so this can be a mode on toggleDoor: mode: "lockpickResult", success: true|false. That keeps the scheduler and ECS component set unchanged.
Assistant
I’ll add a small lockPickingWiring module in main/wiring: it listens for lockpick:prompt, opens the overlay with the door’s pins/difficulty, then dispatches rules.lockpickDoorResult on success or failure. The rules payload will consume one lockpick and only unlock/open the door on success.
Assistant
Starter item creation already handles stack counts, so adding { itemId: "lockpick", count: 5 } per class is straightforward. For consumption I’ll use the existing consumeFromStack path and destroy the detached consumed entity so the lockpick is actually spent.
Assistant
One architecture constraint matters here: new rules events need concrete EcsEvent classes. I’m going to define LockpickPrompted / LockpickResolved event classes instead of adding new string-only rules events, then wire main to the typed prompt event.
Assistant
I’ve got the shape now. I’m applying the changes in a narrow set: typed events, lockpick item/catalog/palette, starter inventory, toggle-door lockpick modes, rules dispatcher result action, and main wiring.
Assistant
I’m going to finish the rules-side path now: starter lockpicks, gem-vendor-door prompt/result intents, and main/display wiring from the typed prompt event into the existing overlay callbacks. After that I’ll run the focused tests plus the project guard.
Assistant
The existing door path is exactly the narrow hook we need: locked doors already carry a DoorLock.lockId, and the gem dealer door can be identified by that lock id. I’m keeping the new rules contract typed (LockpickPrompted / LockpickResolved) and using the existing interact intent as the turn consumer.
Assistant
I found one small architectural wrinkle in the existing wiring pattern: some older main wiring uses a symbol on world as an install guard. For this new overlay wiring I’m using a module WeakSet instead, so we don’t add any new world-attached state.
Assistant
I’m applying the first complete slice now: item/catalog/palette, class loadouts, door interaction logic, dispatcher action, and the main wiring file. Then I’ll add tests around prompt/success/failure so regressions are caught at the rules boundary.
Assistant
The implementation slice is in place. I’m adding focused tests now for the locked gem-dealer door: prompt when carrying picks, success consumes and opens, failure consumes and stays locked.
Assistant
The tests are now covering the intended behavior at the interaction layer. I’m running the focused suites first so failures point at the change instead of getting buried in the full guard output.
Assistant
Focused tests passed. I’m running the project guard now; that will catch event doctrine, import boundaries, and architecture ratchets around the new typed events and wiring.
Assistant
The architecture/event guard passed. I’m doing one broader runtime pass and a diff review now; if anything shakes out it should be either a stale test expectation or a small integration mismatch.
Assistant
The broad runtime suite is still running; no failures so far. While that runs, the diff looks scoped: no new component, no scheduler work, just a typed event bridge from door interaction into the overlay and back through a rules intent.
Assistant
Runtime pass is still clean as it moves through the larger suite. I’m letting it complete rather than stopping at the focused coverage, since this touched starter inventory and shared interaction handling.
Assistant
Still running, currently past the interaction and inventory-heavy tests with no failures. I’ll report the final status once the suite exits and I’ve checked the worktree for any untracked files from the new events/wiring.
Assistant
The full suite is taking the expected long path through overworld generation and projection tests. No failures have surfaced.
Assistant
Still passing. The long generators are done now; the remaining suite is mostly runtime systems and UI contracts.
Assistant
The full suite hit existing-looking transition/cache failures late in the run, while the lockpick-related tests stayed green. I’m waiting for the final failure report so I can verify whether those failures are unrelated baseline issues or caused by this change.
Assistant
The full suite failure is isolated to Deno localStorage opening its backing DB inside transition cache tests (unable to open database file). That doesn’t touch this feature path, and the focused lockpick/interaction/class/dispatcher checks all passed. I’m doing a final worktree check now so I can give you the exact file list.
Assistant
Worktree is as expected: the two new event files and new main wiring are untracked additions, with scoped modifications to item data, starter classes, door interaction, dispatcher, and tests. I’m grabbing line references for the final summary.
Assistant
Implemented the first locked-door integration.
Added:
lockpick item data and palette entry: economy.js
lockpick x5 to every class starter inventory: classes.js
Gem-vendor-door lockpick prompt/result handling in toggleDoor: interactPayloads.js
Turn-consuming result intent: rulesDispatch.js
Main wiring from LockpickPrompted to the overlay callbacks: lockPickingWiring.js
Behavior:
Locked gem vendor door + no key + at least one lockpick opens the lockpicking overlay.
Success callback dispatches a rules intent, consumes one lockpick, unlocks and opens the door.
Failure callback dispatches a rules intent, consumes one lockpick, leaves the door locked.
Existing locked-door behavior remains for non-pickable doors or no lockpick.
Verification:
Passed focused tests: deno test --allow-read tests/interaction.test.mjs tests/classes.test.mjs tests/lockPickingOverlay.test.mjs tests/consoleCommands.test.mjs
Passed dispatcher tests: deno test --allow-read tests/rulesDispatch.test.mjs tests/rulesDispatchQuickInteract.test.mjs tests/rulesDispatchWorldTap.test.mjs
Passed deno task check
Full deno test --allow-read --no-check ran 2327 passing tests, then failed 9 existing transition/cache tests due localStorage backing DB: unable to open database file, unrelated to this feature path.
User
one easy strategy, is to show a "I need a lockpick" message if you have none, otherwise, to open the modal supposiing you had lockpicks in inventory.
helper method:
hasItem(entityId, itemId)->bool
otherwise good -- love the diretion!
what the HECK is installedWorlds weakSet? why are we not using a proper extension
what was wrong with original lockpick glyph?
why do you have a base.js entry? and an economy.js entry?
Assistant
I’m going to tighten those points directly: use a real defineExtension for the main lockpick wiring, add a hasItem(entityId, itemId)-style helper around inventory count, and make gem-vendor locked doors say the no-lockpick reason instead of falling through to generic locked. I’ll also verify whether the explicit base.js palette entry is redundant with the content DSL palette registration before deciding whether to remove it.
Assistant
Two answers from the code: defineItem() already registers the palette entry, so the base.js addition is redundant and I’m removing it. The WeakSet was me avoiding new world[...] state for an install guard, but you’re right that this should be a proper ECS extension and installed with world.install(...); I’m converting it.
Assistant
For the no-lockpick message, I’m keeping it in rules as a concrete interaction outcome rather than main/display special casing. The display message wiring already listens to interaction events for doors, so I’ll add a distinct result there instead of inventing another UI event.
Assistant
On the glyph: nothing was wrong with it. I changed ¬ to ASCII out of habit from the editing rules, but glyphs are exactly the place where Unicode is intentional in this repo. I’m restoring it in the content definition and relying on the DSL palette registration.
Assistant
The code now has the cleaner branch: lockpickable door with picks opens the modal; lockpickable door without picks emits need_lockpick for the message layer. I’m adding focused assertions for that exact case and for the displayed message.
Assistant
The missing-lockpick behavior is now tested in both rules and messages. I’m running the focused suites plus the architecture/event guard again.
Assistant
Focused coverage is green. I’m running deno task check again now that the wiring is a real extension and the message path changed.
Assistant
Guardrails are green. I’m doing the final diff/status pass now so I can answer your questions cleanly and note exactly what changed.
Assistant
One last alignment pass: since you explicitly called out hasItem(...), I’m moving that helper to inventoryFacade instead of leaving it as a one-off local function. The call still takes world because that’s the project’s utility shape.
Assistant
I’m applying that helper export and updating the interaction path to consume it.
Assistant
The helper is now in inventoryFacade and covered by its existing stack-count test. I’m rerunning the focused set plus the guard after that move.
Assistant
Focused tests are green after moving hasItem into the facade. I’m rerunning the guard once more, then I’ll wrap this up.
Assistant
Handled the cleanup.
Changes made:
Added hasItem(world, ownerId, identity) to inventoryFacade and switched lockpicking to use it.
Gem vendor locked door now says You need a lockpick. when the player has none, instead of opening the modal.
Replaced installedWorlds with a proper defineExtension(...) and world.install(...) path in lockPickingWiring.
Restored the original ¬ lockpick glyph.
Removed the redundant base.js palette entry. economy.js is enough because defineItem() registers catalog + palette.
Answers:
installedWorlds was an install guard. It worked, but it was not the project’s preferred extension pattern. Fixed.
Nothing was wrong with ¬; I overcorrected for ASCII. Restored.
economy.js defines the item and its DSL palette metadata. base.js was redundant here. Removed.
Verification:
deno test --allow-read tests/interaction.test.mjs tests/messageWiring.test.mjs tests/inventoryFacade.test.mjs tests/classes.test.mjs tests/lockPickingOverlay.test.mjs tests/consoleCommands.test.mjs
deno test --allow-read tests/rulesDispatch.test.mjs tests/rulesDispatchQuickInteract.test.mjs tests/rulesDispatchWorldTap.test.mjs