loreweaver AGENTS.md

Contributor instructions for Loreweaver, a self-hosted AI game master for tabletop role-playing games with structured worlds, rules and saved game state.

In plain words
What is it for?
Use them when developing, testing or running Loreweaver, or when changing its game rules, clients, protocol or extensions.
Why use it?
They explain the project's architecture, strict design rules, development workflow and testing expectations to coding agents.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/1a7432/loreweaver/agents-md
Clone the repo
git clone --depth 1 https://github.com/1A7432/loreweaver

Made for: Codex, OpenCode.

Per session 4,279 This file is loaded in full into every session.
When invoked 4,279 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04279 $0.04279
Opus 5 $0.02139 $0.02139
Sonnet 5 $0.00856 $0.00856
Haiku 4.5 $0.00428 $0.00428

Measured 2d ago against content hash 19d3fb5920d1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

loreweaver AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 52 lines

How it starts

The opening of the file, as written. The whole thing — 52 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — contributor & AI-agent guide

Loreweaver is a self-hosted AI Game Master / Keeper for tabletop RPGs: a world/story-first engine (structured world + module + rules + persistent state), not a persona-chat frontend. Terminal-first over Iroh p2p, system-agnostic (D&D 5e SRD + CoC 7e), English-first with runtime en/zh i18n, MIT. This file orients humans and AI coding agents working in the repo — it is the single source of truth (CLAUDE.md just imports it). User-facing docs live in README.md; the open client protocol in docs/protocol.md; the extensibility contract in docs/plugins.md.

Architecture (layers, each with one job)

  • core/deterministic engine (never AI-generated), rule-AGNOSTIC since M16: dice, resolution (pack-compiled check ladders + the QuickJS rules_script lane), sheets (pack-declared sheet shapes: canonical-name bridges, derived DAG — derived values are NEVER persisted — vitals, wire resources), character_rules (pack-constraint validation on every stat write path), clock, rulepacks (data-driven rule systems: resolution/sheet/subsystems/commands/expertise all pack data; tests/architecture/ pins agent/ to zero system tokens), skills (SKILL.md loader), deterministic relationship tracks, modvars (deterministic module-variable trackers), worldbook, charcard (SillyTavern-card parser), table_habits — the M20 E procedural-memory type (how THIS table plays; keeper-side only, player projection returns None, index-only residency), chronicle — the M18 campaign-history types (chronicle/campaign_summary/thread: projections keep keeper annotations out of every player-grade view) plus the deterministic fold policy (0.60 trigger / 0.40 floor / 0.85 emergency, 4-turn no-future lag window), and documents — the M17 meta-type: ALL room content (lore/NPCs/sheets/pregens/modvars/MVU tree/notes/pools) is a Document in one table, and every type's project(doc, viewer) is THE single wire chokepoint for iron rule #3.
  • infra/ — plumbing: SQLite store (documents + room_state + kv tables — content documents, room-scoped runtime state, non-room leftovers), pydantic-settings config + hot runtime overrides/credential book, i18n, llm/embeddings (each with a Fake* offline double), vector, providers (multi-vendor LLM factory).
  • agent/ — the AI-KP brain: AgentCtx, tools (@tool schema-gen + gating), kp_tools* (the Keeper tools), forge (self-extension generators: skill/rulepack/module from a description), prompt_builder, loop (function-calling loop), services (the wiring bundle), chronicle (the M18 fold flow: batch-fold old chronicle records into the rolling campaign_summary when the usage meter crosses the trigger; folded records join the embedding index for topical recall — records themselves are AUTO-WRITTEN since M21 by the Scribe, one player-grade line per material turn at zero extra model calls, so durable memory and the history trim that rides on it never depend on the Keeper remembering record_chronicle; the keeper spoiler margin stays exclusive to that voluntary tool), knowledge-scoped npc/companion actors, and the three model-driven prep lanes that used to sit in core/ — module_initializer (full-text module analysis into the keeper/player pools), document_manager (chunking + RAG answers), char_from_persona (persona → rule-legal sheet; the validation half stays in core.character_rules).
  • gateway/ — platform-independent: session/events/turn/member/room state, commands/ (dual-dialect + slash — a package: router owns the spec table and dispatch, each domain is a mixin module checks/sheet/rules/rooms/cast/world/panels/media/llm; a new command lands in its domain module plus one spec row, never in the turn pipeline), ops (rate-limit/censor/permissions), hub (the cross-transport RoomHub), director.
  • net/session (transport-agnostic SessionCore), iroh_server (p2p QUIC, the DEFAULT carrier), tui_server (WebSocket, offline-test/loopback only), keystore, admin, room_backup.
  • adapters/cli only (the local operator REPL). The five chat-platform adapters (Discord/QQ/Telegram/Feishu/OneBot) were REMOVED 2026-07-30: the UI direction is protocol clients with a deeply customizable UI extension layer (ui frames, panels), which text-chat platforms structurally cannot render. Don't re-add platform adapters; build against docs/protocol.md instead.
  • clients/ — TypeScript: protocol (shared types + WsClient; published to npm as loreweaver-protocol, whose major.minor tracks the wire-protocol version), tui (OpenTUI terminal client; IrohClient and the one-click host live here). Both speak docs/protocol.md. The DESKTOP client — Loreweaver Studio, Tauri (Rust transport + React UI), play mode with tier-1/tier-2 panels and the keeper screens plus the card/pack studio — lives in the separate loreweaver-studio repo and is the recommended player client; it consumes loreweaver-protocol from npm and pins itself to the engine with a cross-repo round-trip gate (bun run roundtrip there). Changing the protocol or a pack format here means that gate must be rerun there. Bumping the protocol means bumping it in all five places at once — net/session.py (the authority), protocol/src/types.ts, the npm manifest's version + description, protocol/README.md, docs/protocol.md — pinned by tests/architecture/test_protocol_version_sync.py.

Read the full file on GitHub · 52 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 52 lines · 4,279 tokens per session scan A 19d3fb5920d1

Subscribe to this mod's changes

loreweaver AGENTS.md is an instructions file published in the GitHub repository 1A7432/loreweaver (45 stars, last pushed 7d ago), licensed MIT. It adds 4,279 tokens to every session, about $0.0214 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.