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:
scan this repository looking for concrete details about agentic development; what makes agentic development even possible on this project when it's scale, lack of type safety, complexity, and single author even possible.
do not concern yourself with ranking; just pure identification of techniques that you see in the project backed by concrete evidence of the technique.
there is no number of techniques that you must uncover, my suspicion is that there are many, some are unique, some are reletively common.
Assistant
I’ll use the repo’s using-entire skill so the scan is grounded in both files and any available project provenance, then I’ll inspect the repository for concrete mechanisms that support agentic work.
Assistant
The skill says to check Entire first; after that I’ll combine repository evidence with checkpoint/history evidence where it exists, and label anything that is only inferred from current files.
Assistant
Entire is enabled and there are many active historical sessions, which is itself evidence: the project records agent work as first-class context. I’m going to gather the concrete scaffolding next: docs, guardrails, tools, tests, architecture ratchets, content patterns, and provenance hooks.
Assistant
The Deno task file already shows a strong pattern: the repo has named guardrails and audits designed for agents to run without reconstructing command lines. I’m expanding from there into the guard implementations and the agent-facing docs.
User
note: using entire will anchor you to recent history, however, entire itself is almost certainly an identified technique.
Assistant
Noted. I’ll treat Entire itself as one of the techniques, but I won’t let recent session history dominate the scan; most of the evidence will come from durable repo files and executable guardrails.
Assistant
A few durable themes are emerging: executable architecture boundaries, deterministic replay, agent-oriented search/audit tools, data-driven content, and deliberate ratchets for known debt. I’m pulling line-numbered evidence now so the final is concrete rather than a broad essay.
Assistant
The repo also makes its anti-pattern history explicit, which matters for agentic development: it gives future agents negative examples and stop conditions, not just positive architecture docs. That reduces the chance that an agent “improves” the wrong thing.
Assistant
I’m also checking implementation patterns, not just docs: whether the code actually uses concrete event classes, extension installers, data definitions, canonical facades, and a central scheduler. That distinction matters because instructions alone are weaker than enforced shape.
Assistant
The content layer is a strong example of scale management without static types: it collapses catalog, palette, and hook registration into validated DSL calls, and then tests the compiler behavior directly. That gives agents one obvious place to add content and immediate failure modes when required fields drift.
Assistant
I’ve got enough evidence for a high-signal inventory. I’ll do one more pass over provenance/session tooling and architecture docs, then summarize the techniques with file-backed examples.
Assistant
Identified Techniques
Agent field manual at repo root
The provided AGENTS.md is not generic. It gives agents hard laws, command recipes, architecture maps, target lookup commands, event-bus commands, and merge checklist items. That reduces exploration cost and prevents agents from inventing local doctrine.
Named guardrail tasksDeno tasks package architecture, event, death-pipeline, tooling, health, and ratchet checks into stable commands. The important bit is that agents do not need to reconstruct “what should I run?” from scratch: guard:architecture, guard:events, guard:tools, ratchet:world-state, etc. are explicit.
Executable architecture health reporttools/agent-health.mjs scans for boundary violations, emitSafe, nondeterminism hazards, system-to-system calls, and system counts, then formats an “agent health” summary. This is custom static analysis aimed exactly at agent failure modes.
Agent tools are testedtests/agentTools.test.mjs tests the event-bus explorer, system-map parser, import-boundary classifier, target search ranking, content-id classifier, and health report formatting. The project does not just ship helper scripts; it protects their behavior.
Event-bus explorertools/event-bus-explorer.mjs extracts literal/dynamic world.emit, world.on, ctx.io.emit, producer/consumer counts, payload keys, orphan producers, and orphan consumers. For a JS ECS project without types, this gives agents a queryable behavioral graph.
System maptools/system-map.mjs parses scheduler imports and registerSystem(...) calls, reports phase placement, unregistered system files, and missing obvious tests. That makes scheduler-scale complexity inspectable.
Targeted search toolstools/agent-target.mjs ranks matches by event, symbol, file, import, and text. follows item/monster/spell/material IDs through definitions, visuals, spawn/loot, events, references, and tests. These are agent-specific navigation aids.
User
dump these into an MD file please; add some additional that I observed.
reflect-js -- a local stdin MCP that using JS reflection tools to examine the project at a very deep level (fill in more detail here)
using CLI tools to gauge project health -- orphaned events, and beyond
MD files are not gaurenteed to be enforced, ratchets and CLIs are essential to the operation.
Assistant
I’ll write this up as a durable doc under docs/, using the evidence from the scan plus your three additions. I’ll keep it as identification, not ranking.
Assistant
I’m going to create docs/AGENTIC_DEVELOPMENT_TECHNIQUES.md. I’ll mark the Reflect-JS entry as an observed/local-tool technique rather than pretending it is evidenced by repo source if the repo itself does not contain its implementation.
Assistant
There is no repo source for Reflect-JS in this checkout, so the doc will call that out as local MCP/tooling rather than code-in-repo. The rest will cite concrete project files and commands.
Assistant
The doc is in place. I’m doing a quick sanity read of the new file header and git status so I can give you the exact path and scope.
Assistant
Created docs/AGENTIC_DEVELOPMENT_TECHNIQUES.md.
It includes the original scan plus your additions on Reflect-JS, CLI-based project health, and the point that Markdown doctrine only works when paired with ratchets/CLIs. I marked Reflect-JS as observed local MCP/tooling since its implementation is not in this repo checkout.
User
is this all the evidence that you could find backing up the agentic development story of this project? I feel like this proect is super uniuqe in terms of it's depth and complexity --- in actuality, it was in part concieved as an agentic development stress test; and so far, the results are reasonable -- far from perfect, it highlights real weaknesses of agentic development;
we have 2307 tests, all passing -- but tests can drag the project backwards based on incentives.
(ie)
is there anything else you want to say>!
Assistant
I don’t think the current document is exhaustive. I’ll check the project’s own narrative docs and the current test summary, because those are probably additional evidence for the “agentic stress test” framing rather than just implementation mechanics.
Assistant
The repo narrative docs add another dimension: they frame this as generated implementation inside human-held architecture, and they also document agent failure modes rather than hiding them. I’m going to verify the current test count locally so I don’t repeat an old README number.
Assistant
The full runtime suite is still running. The output so far shows the kind of thing I’d call additional evidence: not just quantity, but many tests are invariant/contract tests around architecture, content, and behavior rather than simple snapshots.
Assistant
The test output is also surfacing a weakness of the success metric: a lot of tests are valuable architecture contracts, but many also encode current implementation choices. That’s where “all green” can preserve local decisions after the design has moved on.
Assistant
No, I don’t think that MD file is all the evidence. It is a solid first inventory of mechanisms, but it undercounts the project’s own narrative evidence and the failure-mode evidence.
A few things I’d add:
docs/architecture/MANIFESTO.md is major evidence. It explicitly says the agents made the project possible, then names the scale: systems, components, items, deterministic simulation, plain JavaScript, no dependency stack. More importantly, it frames the actual model: human-held architecture, agent-executed detail.
README.md has an explicit agentic development statement: “a human directs the architecture, taste, constraints, and iteration; AI agents do the implementation work.”
LICENSE explicitly permits inference-time use by autonomous/semi-autonomous coding agents while resisting proprietary model ingestion. That is part of the agentic story too: the license distinguishes agent use from institutional extraction.
STORY.md and CHANGELOG.md contain unusually candid evidence about agent weaknesses: agents hallucinating, missing the point, requiring human judgment, test-driven recovery after failed earlier experiments, and the project accumulating correctness by repeated correction rather than magic.
The test suite itself is evidence, but not just because of count. It is a behavioral atlas. Test names cover architecture, content DSL, event doctrine, transition contracts, UI layout, audio wiring, spell mechanics, town economy, proof chains, topology helpers, etc. That is a map agents can navigate.
I also ran the documented full runtime command locally: deno test --allow-read --no-check. In this environment it ended with 2298 passed | 9 failed, all 9 failing from localStorage/database access in transition-related tests, not from gameplay assertions. So I would not personally repeat “2307 all passing” as verified from this run. It may be true in the intended local environment, but the failure itself is useful evidence: even a zero-build, Deno-only repo still has environmental edges that can confuse agents.
The thing I’d most want to say is this: the project’s uniqueness is not “AI wrote a lot of code.” That is becoming common. The unique part is that the project built an operating system for receiving AI code: doctrine, constraints, deterministic replay, search tools, event audits, architecture tests, ratchets, provenance, and a human taste layer strong enough to reject plausible nonsense.
And yes, tests can absolutely drag the project backward. A large green suite creates an incentive gradient: preserve expected behavior, satisfy the harness, avoid semantic judgment. That is why the strongest pattern here is not “more tests.” It is the combination of tests with doctrine like “red tests can be stale,” ratchets that prevent debt growth without freezing old debt forever, and architecture docs that say what direction the project is supposed to move. The hard part is keeping tests as witnesses, not governors.
User
okay -- perfect, say it; we should also reference all external tooling:
we should mention that at least three LLM retail products are being used CODEX, Claude Code, Github CoPilot
Assistant
I’ll add a section that says the stronger thesis plainly, then extend the external-tooling section to cover RTK, Entire, Caveman, and the multi-product workflow: Codex, Claude Code, and GitHub Copilot.
Assistant
I found repo evidence for Copilot in STORY.md, and for Entire in the local skills/commit trailers. RTK and Caveman appear to be external workflow tools, so I’ll label them as surrounding tooling rather than in-repo source.
User
any other tools? list them? ffmpeg, skills, whatever else you can dig up.
Assistant
I’ll scan the repo for tool surfaces beyond the ones already named: Deno tasks, tools/, local skills, shell scripts, packaging/audio utilities, and references to external binaries like ffmpeg.
Assistant
The scan found a bigger ecosystem than the current doc captures: audio processing tools around ffmpeg/ffprobe, Dropbox audio download/sync, NW.js packaging, browser-based editors, headless/perf tooling, visual scenarios, and the local skill set. I’ll add a compact “tool inventory” section rather than over-explaining each one.
Assistant
I’ll fold this into the MD as an “Additional Tool Inventory” so it stays factual: repo tools, external binaries/services, browser authoring tools, local skills, and simulation/perf utilities.
Assistant
Added an “Additional Tool Inventory” section to docs/AGENTIC_DEVELOPMENT_TECHNIQUES.md.
It now covers:
Deno tasks and repo CLIs
headless runtime and profiling tools
browser authoring tools
visual scenario runner
audio pipeline with ffmpeg / ffprobe
Dropbox audio sync
NW.js packaging
neural AI training tool
local .agents/skills
RTK, Entire, Reflect-JS, Caveman
Codex, Claude Code, GitHub Copilot
I kept external/non-repo tools labeled as observed surrounding tooling rather than pretending they are implemented in the checkout.
Hard layer separation, documented and testeddocs/architecture/SEPARATION_MANIFEST.md defines allowed imports between rules, bridge, display, shared, and app. tests/separationBoundaries.test.mjs enforces key import boundaries.
Determinism as an architectural primitive
The separation doc says the same seed and intent sequence should produce identical state/events here. tests/determinismArchitectureGuards.test.mjs bans time/random APIs in deterministic layers. This is crucial for agent debugging because behavior can be replayed.
Central scheduler with explicit phasessrc/main/scheduler.js wires all systems in one composition root, with phases like ai, intents, effects, scripts, and cleanup; it finally composes them at line 320. Agents can reason about order without scanning every system for implicit calls.
Order constraints are local and visible
Scheduler registration uses before/after constraints, for example movement before ranged actions and casting here. This replaces hidden inter-system coupling with inspectable scheduling.
Data-driven content DSLdocs/CONTENT-AUTHORING.md says one defineItem call validates inputs, infers catalog kind, compiles hooks, and registers palette atomically. src/content/define.js implements this for items; line 396 implements monsters.
Import-time validation instead of static typesdefineItem throws for missing id, def, name, or typehere. Tests assert those failures here. That partially substitutes for TypeScript by making bad content fail early.
One content definition registers multiple projectionsdefineItem registers the catalog entry here, palette here, presentations here, and abilities here. This reduces ID drift across systems.
Central duplicate-detecting content registrysrc/content/registry.js rejects duplicate item IDs, and line 29 rejects duplicate monster IDs. That protects agents from silently shadowing content.
Concrete doctrine for avoiding hidden runtime statedocs/architecture/RUNTIME_TOPOLOGY_DOCTRINE.md says runtime things with identity/lifecycle/debug relevance should be entities, not arrays. It also names the compatibility/migration approach here.
Ratchets for known debtratchets/worldStateAttachmentRatchet.test.mjs carries an allowance list for existing world[...] state, then fails if counts grow here. This lets agents improve incrementally without reopening old debt.
Negative-history docsdocs/architecture/TEN_COMMANDMENTS.md records past derailments, then converts them into hard rules: tests before systems line 36, one new system per session line 48, data over hard-coded systems line 66, no second scheduler line 83. This is unusually agent-useful because it captures traps, not just ideals.
Vendored ECS is itself agent-orientedsrc/lib/ecs-js/AGENTS.md explicitly explains why the ECS works for agents: deterministic core, caller-driven ticks, pure logic, composable helpers. It gives a step-and-explain workflow here.
Entire provenance
The repo has .agents/skills/using-entire, which tells agents to read recorded intent instead of guessing here. Git commits also carry Entire-Checkpoint: trailers; the last three commits I inspected all had them. This makes agent work historically searchable and explainable instead of ephemeral.
Task-specific agent skills
The repo has local skills like add-monster, which gives a procedural playbook, required fields, balance tables, callback imports, salt conventions, palette rules, and test commands. That converts repeated single-author knowledge into reusable agent procedure.
The broad answer: agentic development is possible here because the project replaces missing static types and human-only memory with executable guardrails, deterministic replay, query tools, DSL validation, explicit architecture doctrine, debt ratchets, and recorded development provenance.