Files
tiny-worlds/AGENTS.md
T

353 lines
21 KiB
Markdown
Raw Normal View History

# AGENTS.md -- the agent's own notes
Working notes for the agent working this repo. Not project
documentation -- the project's homes are README (architecture, protocol,
observables), ROADMAP (decisions, steal list, substrate plan),
QUESTIONS (the decision queue), DICTIONARY (the terms of art),
HANDOFF (working state). This file is
memory the agent owes itself across sessions.
## Working with the GM
- **Their LLM tokens are free (2026-11-14): never economise on usage.**
Run live tests freely; don't hesitate over spend or trim prompts,
manifests, or transcripts to save tokens.
- The GM drafts creative content; the agent drafts mechanical content.
"I draft, you cut" runs both directions. They edit files directly and
say "check it out" -- always re-read before reviewing or editing; the
last read never still holds.
- They think across several lines at once and answer in batches;
silence on a proposal usually means "not persuaded, moving on."
Discuss in prose -- question dialogs have been dismissed twice.
- **Commit discipline: they commit when pieces are in place. Never
propose, nudge, or ask about committing.** (Learned 2026-11-13,
after being told four-plus times.)
- Reviewing their creative work: check coherence against the rest of
the system, flag ripples, name what works and why -- the verdict on
creative content is theirs. GM-private files (gm.md) are never edited
and only flagged.
- Standing agreements (folded from the handoff's working-agreements
section when it slimmed, 2026-11-15): character and world work is
done together, unhurried ("we'll get there together"); the GM runs
on organic memory and takes no notes -- the system is the prosthesis,
their lever is narrative, never mechanical; they answer point-by-point
and expect pushback in both directions; gm.md is GM-private, never
pasted to any model; rolls (`pick`) are legitimate at drafting time --
rolled values are proposals with the alternates listed for easy
swaps; hard limits in `system.md` are absolute.
## Writing prompt-bound text
- **Plainness over subtlety.** Learned 2026-11-13: my content-stance
prose was aphoristic ("the weather is hers", "the camera keeps to
her side") and the GM -- the co-designer -- could not decode most of
it. Their rewrite named the thing (erotica), stated rules as
behavior (strike down unwanted advances; don't play anticipated
leads to please the GM), and stated the thesis outright (nothing
lives in a special bucket). Match that register.
- Metaphor survives only when cashed out in the same breath -- "tense
is the camera: present while the scene plays -- example -- past to
summarise -- example" passed their red pen. A metaphor left uncashed
is a riddle.
- **No HTML comments in prose or prompt files** (2026-11-14): purpose
descriptions live in README (layout), AGENTS, or as comments in the
substrate code. Generated views carry their do-not-edit warning in
the clerk, not in the output. The views are pure memory: run state
(records availability) rides the phase-3 housekeeping invocation,
not the ring headers.
- Output-style counterexamples prime what they prohibit (far context
can't suppress, only prime). State tests and positives instead.
Input-side counterexamples (routing examples, "Refuse" cases) are
safe and stay.
## Environment gotchas
- Shell command strings: plain ASCII only -- em-dashes and fancy quotes
get rejected.
- The edit tool matches bytes, and the console renders dashes
unreliably. When an edit fails on text that "looks right," dump char
codes via PowerShell before retrying; or transcribe from a fresh
read, never from memory. **The three-space trap (bitten 2026-11-13
and 2026-11-14):** the read tool prefixes each line with `N: `, so
continuation-line indentation LOOKS one space deeper than it is --
eyeballing a " the package" was really " the package". Never
count indentation from the rendered display: dump the exact line
with `node -e` + JSON.stringify and transcribe from that when an
edit keeps failing on text that reads right.
- `node:sqlite` prints an ExperimentalWarning on every clerk call --
harmless, filtered in bridge context.
- Session logs, dumps, and views are generated; never hand-edit them.
- `server.json` (gitignored) holds the real key; it mirrors opencode's
`dv` provider (config at `~/.config/opencode/opencode.jsonc`, auth at
`~/.local/share/opencode/auth.json`).
- The repo lives at `C:\data\opencode\tiny-worlds` (renamed from
`rp-test` with the project name, 2026-11-15). The rename could not
happen in place -- the running app held the old dir -- so the move
was robocopy + session repoint, plus a one-time sqlite edit of
opencode's own db (`~/.local/share/opencode/opencode.db`) to
repoint the project record and drop the stale duplicate project
the desktop UI cannot delete (anomalyco/opencode#28030). The old
dir and the db backup are gone; the rename is complete. Always
launch from the new path.
- The test scripts: `smoke.mjs` expects a CLEAN state/ plus a running
`--mock` server, prints its run ids, and leaves a temp token file
for `restart-check.mjs`; `check-reminder.mjs` takes a run id;
`check-repo.mjs` needs no server. Clean up state/ and the smoke
runs afterwards -- only the real runs stay. The type gate:
`npm.cmd run typecheck` (plain `npx.cmd tsc -p tsconfig.json`)
runs tsc as a no-emit checker over the JSDoc annotations --
dev-only tooling (typescript + @types/node in devDependencies,
node_modules gitignored); the runtime stays zero-dependency
(QUESTIONS #4 amended 2026-11-15). Server core is typed under
strict; the clerk (tool/memory.mjs) and web/ are phases to come --
widen tsconfig include as they land.
## State pointers
- **The multiuser server is built and mock-proven (2026-11-14).**
Design: ROADMAP "The multiuser server" + QUESTIONS #22-31 (all
resolved). Identity = bearer token, no usernames/passwords/IDPs;
invites single-use with a permanent spent record; bootstrap invite
auto-mints on fresh deployment to state/bootstrap-invite.txt; op
mints/revokes invites and users; revocation destroys identity (new
invite = new person). Ownership is RESOLVED, never maintained --
run.json keeps dead owner ids, the API reads them as ownerless (GM
overruled my file-sweep; resolution won). Fork = atomic copy, owner
replaced, `forked: unixtime` stamped, no lineage. Packages split
system (repo) / user (state/packages, published). Spectators read
everything incl. gm.md (the boundary is the model boundary), mutate
nothing. Dates/times always UTC -- house rule. Model selection:
per-run `models: {player, housekeeper}` over server.json defaults
(#16 narrowed to the default choice only). Signing in is permanent
and per-browser -- no sign-out (lifecycle is a ROADMAP extension
point). The agenda (QUESTIONS #32): the player's second block, `<add>`/
`<drop>` deltas, cap-5 recency queue; Irene's events journal
migrated (CHECK widened) -- her db is agenda-ready. The per-turn
reminder (QUESTIONS #34, steal #11 done): reminder.md is repo-shared,
rides after every GM turn as its own system chunk, one live copy
(older elide); its CONTENT is the GM's -- my draft is a proposal,
the handbook duplicate-cut is their red pen.
- Substrate design round complete (2026-11-13); rulings live in ROADMAP
("The harness") and HANDOFF. Bridge retired before ever going live;
REST + SPA is the MVP; runs are per-deployment instances copied from
packages at creation; zero-dependency runtime (dev tooling exempt,
QUESTIONS #4 amended 2026-11-15: typescript rides devDependencies,
nothing imports it). Doc set updated to match.
- Build order: ALL FOUR PHASES DONE (2026-11-13/14) -- clerk paper
migration, preset/run split, prompt split, server, housekeeping
job, SPA. The MVP substrate is complete and live-proven end to end
(two real wraps, one full UI-driven session). Remaining roadmap
surface is the "Later" list (turn surgery, memory browser, context
inspector, book export, service step) plus whatever the first real
story surfaces.
Server entry: `node server/main.mjs [--mock]`; SPA at
http://127.0.0.1:7350/; POST bodies from PowerShell need
Invoke-RestMethod (curl.exe mangles quotes); background start/stop
via Start-Process -PassThru with a PID file in $env:TEMP.
- Gotcha (2026-11-14): before starting the server, check
`Get-NetTCPConnection -LocalPort 7350` -- a forgotten instance holds
the port and silently answers with OLD code while the new one dies
on bind (bit me once; two accidental live turns resulted).
- Gotcha (2026-11-14, GM): **never call browser.screenshot** -- the
image return breaks the session (glm-5.3 is not multimodal; the GM
had to rewind once). Verify UI text-safely: browser.snapshot
(accessibility tree), browser.console, browser.network. If real
vision is ever needed, the endpoint carries multimodal
deepseek-v4.1 -- but prefer never needing it.
- Gotcha (2026-11-14, GM): **no JS alert()/confirm()/prompt() in the
SPA** -- they block the embedded browser pane (the GM sat locked out
of their input once while a test confirm hung on my dialog-tool
fumbling). In-page UI only: the banner for notices, two-click arm
for confirms.
- Browser-tool gotchas (2026-11-14, UI testing): evaluate takes a raw
expression, not an arrow function (an arrow returns the function
uninvoked -- its .value serializes to {} and silently corrupts
whatever you build from it); wait's text matches RENDERED text
(moot for letter case since the all-caps CSS ban, 2026-11-15 --
waits match source text now) and PLACEHOLDERS never match a wait at
all (probe the
textarea via evaluate instead); clickable divs are invisible to the
a11y tree and the keyboard -- clickable things are buttons. Added
2026-11-14 (multiuser round): the a11y snapshot races async renders
-- waiting for static skeleton text ("RUNS", the aside headings)
snapshots BEFORE the fetches land and looks like a rendering bug;
wait for text that only exists post-render (a card name, the
session-info line) or probe the DOM via evaluate.
- Test-state discipline (2026-11-14): the deployment's state/ is real
-- never leave test users or invites in it. Smoke against --mock,
then Remove-Item state/ and every test run (all but the GM's real
ones) before calling it done. A stale bootstrap file is harmless
(dead once a superuser exists), but test users make the deployment
NOT fresh and block the real bootstrap.
- Naming gotcha (2026-11-14, SPA round): static files under web/ must
not have names starting with "api" -- the server's route guard
matches the /api PREFIX, so web/api.mjs 404'd as a bogus API route
and the app died at module load with an empty <main>. The REST
client module is client.mjs. Any future web file name gets this
check.
- Gotcha (2026-11-14, rewind aftermath): a session rewind erases my
memory of tool calls but NOT their effects -- the server, files, and
databases keep them. After any rewind, external state is the truth:
re-read it, and never assume authorship of found content (I once
credited the GM with a GM-turn that pre-rewind me had written).
- Open tails (handoff, 2026-11-14, evening): **housekeeper.md review
is still the next creative step** -- the GM's dry-run verdict was
"works, but not as expected; I never saw the prompt"; iterate with
the replay button (nothing applied). **Status discipline: RESOLVED**
by the agenda (QUESTIONS #32/#33). **Verbosity**: completions
lengthened 103 -> 668 chars across session one; the per-turn reminder
is the countermeasure now built -- the next live session is the test.
The first real housekeeping pass (Irene's session) is the memory
test's start, and the op's one-time act (bootstrap claim +
hand-stamping Irene's owner) rides before it (HANDOFF step 2).
**Replay-after-housekeeping is dead** (found in the SPA round) --
RESOLVED BY PLAN (2026-11-15): the dormant-session rework kills
the autorestart, and during dormancy the latest log IS the
just-closed session; the replay default never needed to move.
- Active work: the entity round, the variant round, and the
dormant-session rework are BUILT (2026-11-15, uncommitted, awaiting
the GM's eye). **The rework is now SMOKE-PROVEN end to end
(2026-11-15, evening): smoke 105/105, restart-check, check-reminder,
check-repo, and a full browser pass, all green; test state cleaned.
The Irene hand-migration is DONE the same sitting (fork proven end
to end, then real her mutated identically, reads green, zero writes
to her log -- see HANDOFF "Where we are"). Next: the op's one-time
first start under multiuser (HANDOFF step 2), then the first real
housekeeping pass (step 3).** Plan of record:
HANDOFF ("The dormant-session rework"); status: HANDOFF ("Where we
are"). En-route fix flagged to the GM: the roll retirement had
missed bundle.mjs's tool list;
removed. Working lessons from the build: the mock model's script
keys on assistant replies counted CUMULATIVELY across the log
(gated: turns before the first exchange don't count; the conflict
heal is a reply like any other) -- the first build reset the count
on every GM turn, so every direct reply landed on script position 0;
a carried history shifts a session's first script position, and the
smoke knows the exact tail (a hand-driven browser run with a
different tail lands elsewhere in the script -- that is the script,
not a bug). The clerk's --json now means stdout is JSON only
(renderAll used to print view paths under --json; create started
applying memory.json in-process and the route's JSON.parse choked);
every server->clerk spawn passes --quiet. The lint
(check-repo) reads the git INDEX, so a renamed tracked file must be
staged or the lint dies on the ghost; the README layout section
lives inside a code fence with its own deeper indent -- byte-dump,
the read display lies about depth there too. Deferred to ROADMAP:
GM-input expansion, save-as-package beyond drafts, the carryover
editor. The lint's blind side (bitten 2026-11-15, commit round): it
reads the git INDEX, so UNTRACKED files are invisible to it -- "ALL
CLEAN" before a commit does not cover never-staged files, and the
moment git add -A runs they enter scope (variants.mjs shipped
em-dashes through three green lint runs that way). Lint again after
staging. The checker exempts its own source from the rules that
name what they ban (text-transform, toLocale -- the patterns
themselves). The variant round: roll
retired as a model tool, chance in play is variant literature
(four ruled turn shapes), the loop picks one candidate at random
on reception (crypto, pre-append strict parse, 422 on malformed),
the pick note is the metric, every model-facing surface renders
the picked variant only, thinking never crosses the story wire,
boot resolves a crash between message and pick note. The entity
round: /story = the whole deliverable (literature only, all
sessions, no doubles -- the reading surface the observables
promised); /table = the play view's session projection (the
renamed old /story); the carry = the slidwin (contiguous
raw tail, whole exchanges, smart cutoff counting only prose the
model sees vs 96KB; the housekeeper reads session-minus-tail, so
an event files exactly when it drops out of the carry; the
boundary is invisible to the model, dimmed behind a divider for
the GM). Working lessons: a scripted mock keys its branches on
the count of assistant MESSAGES, not turns (the roll->variants
renumber bit once); README layout lines wrap at 17 spaces of
indent for continuations -- byte-dump before editing, the read
display lies about depth. Smoke 79/79, restart + reminder +
repo checks green. Unexercised live: the pick, the carry at a
real session boundary, the story as reading surface, coin-flip
personality. (Prior rounds, committed: SPA module refactor +
terminology through c51d310; multiuser + agenda + reminder through
89a2c16 -- abf8ef3 is its dead pre-amend twin.)
- Format house rules, same sitting (2026-11-15, GM, from their
operator's queue): ASCII bytes in every tracked file (the ENCODING
is the problem, never the visual -- rendered glyphs travel
ASCII-safe: the middle dot is \u00b7 in JS strings, entities in
HTML; em dash is --, ellipsis is ...) and no text-mutating CSS:
rendered text must match authored text (no text-transform, no
generated content: incl. ::before/::after, no caps font variants --
inline styles included). Both enforced by
test/check-repo.mjs; the repo swept clean (43 files), style.css
de-capped (source-case labels now -- waits match source text), the
setup editor's dirty marker authored into the DOM. The audit pass
(same day, GM-ordered) grew the check to NINE rules -- read its
header for the list; the found-and-fixed: four html comments in
prose files (la-caramba's backdrop rode one into every bundle),
README's "256K-class window", ROADMAP's "rides the prelude". The
lint's carve-outs are rulings, not sloppiness: historical records
keep their day's words, gm.md is GM-private, contwin glosses may
name the context window, and the clerk's paper->status migration
code is the ruled one-time
exception (which is why the term check scopes to living prose, not
code).
gm.md note: the sweep once touched packages/boutique/gm.md's
typography; moot since the GM emptied the package.
- Working lessons (prior builds): the newest GM
turn must keep its <status>/<agenda> blocks (that ride is the
status/agenda blocks' only channel from session two on); any new path that reads a
run file for sending goes through expandVars (turn0() initially
didn't); the transcript must surface failed session-open notes
(ingest), not print success unconditionally; after changing a
default, re-run the primary path (the start button broke for the GM
because post-redesign tests never pressed it); ownership is resolved
against the users table, never swept on disk; same-verb delta blocks
combine into one apply, never execute in sequence. Rename-mechanics
lesson (2026-11-14): scripted renames with split/join replace EVERY
occurrence -- renaming the clerk's `paper` case to `status` and then
`status` to `report` ate both, leaving no `status` dispatch; the
smoke caught it on the next run. Order rename pairs so a new name
is never a later pair's old name, and grep dispatch tables after.
CLI note: the run summary is `report` now; `status` is the tier
verb.
- Postulates (GM, 2026-11-14): female PCs only (names are gendered;
QUESTIONS #2 closed by it). Boutique: the GM emptied it wholesale
(2026-11-15 -- it kept being a noisy problem); placeholder files
only, no content anywhere. Still do not fix or design it
unprompted -- its design round is where content returns. The
skip-it carve-outs are retired with the content: the lint covers
packages/ like any living prose, and the clerk's completeness
check now requires non-empty files (an emptied package lists
honestly as MISSING, never "ok").
- Identity model (2026-11-14): @PC/@Package are identity sigils
(settings pc/name); $TOKENs are prompt-declared template vars
(setup inputs -> settings vars). Run ids are anonymous hex --
display is always "Package / PC". Any new prompt-side file reader
goes through expandVars.
- Exposure rule (GM, 2026-11-14): everything that enters the bundle
is inspectable read-only in the SPA (system.md, invariants.md, the
assembled system message in the bundle card); anything that prompts
an internal agent (housekeeper.md) is never exposed. Don't hide
bundle parts, don't surface agent prompts.
- Dates principle (revised 2026-11-14, GM): **no model-facing surface
renders a date** -- ring views, search results, everything the
player-model sees. Memory doesn't timestamp; when something happened
lives in the entry prose. Internal stamps (created/last_touched) are
real, mechanical (LRU/overflow/sinking), never rendered; GM-facing
CLI keeps them. The manifest and seed carry no date keys at all --
the housekeeper's date duty is gone (it couldn't ask, and the touch
stamp was rewriting story time). Supersedes the story-date ruling
below.
- Watch: the "never open with world narration" rule was cut as
superfluous by the GM -- reinstate only if testing shows drift.
- Defaults taken without asking (2026-11-13): #21 session-open refuses
over an unhousekept session with explicit override; #16 housekeeper
defaults to the player's model; #10 tool-call pairing validation goes
into the server loop.
- Open decisions live in QUESTIONS.md -- read it first. Remaining: #19c
(seed voice, GM may revisit -- non-blocking, seed editable until first
session-open) and #16 (which model the housekeeper defaults to).
Resolved lately: #19a keep "Rell"; #20 system.md split (substrate
facts / per-project guards / per-run craft, hard limits in the craft
copy); #21 unhousekept-session guard (refuse with override).
- The tree is usually dirty by design; git status is not an alarm.
- Edit-tool lesson repeated (2026-11-13): nested-list indentation in
HANDOFF failed twice from memory -- always transcribe oldString from a
fresh read, counting spaces.