How hedaas-code/linyi works
LinYi is a tick-driven, multi-agent shelter and society simulator with a web console and REST API. The main workflow is to start or restore a world, advance ticks, let residents respond to survival pressures and make decisions, then inspect telemetry, history, and saved state. The graph preserves documented social, economic, town, and civilization capabilities, as well as optional LLM support. Runtime-to-domain links are based on the loop excerpt or README; unsampled implementation details are not inferred as confirmed calls.
Main entry points: loop.js Tick loop · server.js HTTP server · index.js API routes · observer.js Query and save API
Components 22
Simulation runtime
- Tick loop
src/runtime/orchestrator/loop.js - Simulation clock
src/runtime/clock.js - World state
src/runtime/world-state.js - Snapshot persistence
src/runtime/persistence.js
Residents and AI
- Resident behavior
src/agent/index.js - LLM gateway
src/ai/llm/gateway.js - LLM providers
src/ai/llm/provider.a6api.js
World systems
- Survival pressures
src/survival/index.js - Social systems
src/social/index.js - Economy
src/economy/index.js - Civilization
src/civilization/index.js - Town and facilities
src/town/index.js - World and resident generation
src/genesis/index.js
Observation and storage
- History and experiments
src/observer/index.js - Event and action logs
src/observer/recorder/index.js - Graph store
src/infra/store/graph.js - Bounded log retention
src/infra/store/hot-log.js
API and control
- HTTP server
bin/server.js - API routes
src/api/index.js - Simulation control
src/api/control.js - Query and save API
src/api/observer.js
Other components
- Operator
Connections 22
- Operator → HTTP server: starts service
- HTTP server → API routes: starts routes
bin/server.js - API routes → Simulation control: routes controls
src/api/index.js - API routes → Query and save API: routes queries
src/api/index.js - Simulation control → Tick loop: controls ticks
src/api/control.js - Tick loop → Simulation clock: advances time
src/runtime/orchestrator/loop.js - Tick loop → World state: updates world
src/runtime/orchestrator/loop.js - Tick loop → Resident behavior: runs decisions
src/runtime/orchestrator/loop.js - Tick loop → Survival pressures: reads pressures
src/runtime/orchestrator/loop.js - Tick loop → LLM gateway: generates thoughts
src/runtime/orchestrator/loop.js - Tick loop → Social systems: runs social systems
src/runtime/orchestrator/loop.js - Tick loop → Economy: runs economy
- Tick loop → Civilization: runs civilization
src/runtime/orchestrator/loop.js - Tick loop → Town and facilities: uses town systems
src/runtime/orchestrator/loop.js - Tick loop → World and resident generation: creates residents
src/runtime/orchestrator/loop.js - HTTP server → LLM gateway: configures provider
bin/server.js - LLM gateway → LLM providers: uses adapters
src/ai/llm/gateway.js - Query and save API → History and experiments: queries history
src/api/observer.js - Query and save API → Snapshot persistence: saves snapshots
src/api/observer.js - History and experiments → Event and action logs: exposes logs
src/observer/index.js - Event and action logs → Bounded log retention: uses retention
src/observer/recorder/index.js - Bounded log retention → Graph store: trims log nodes
src/infra/store/hot-log.js