Files
mute 0ddb9a218d the package-authoring round: fork is the verb, the scaffold flag is the ready-to-run gate, the package editor is the owner's surface, and /packages is the launchpad
The design conversation settled the verb question (developer, 2026-11-19): a "create new package" with a base selector is fork under another name, so the SPA gains one list at /packages with three acts per card -- start (the run-create flow, unchanged), fork (any package, system or user, by anyone: the copy lands in state/packages owned by the forker, pc stripped, display name asked inline, the fork landing straight in the editor -- nobody forks to immediately start), and edit (the owner's own user packages only). /new retires to a redirect onto /packages; the source link (code.fleshless.org/hackmaster/tiny-worlds) rides the header.

The template's unplayability became machinery instead of a naming special-case: settings.json carries the "scaffold" flag (the records-bool precedent -- authored content carries the marker, machinery reads it). Create refuses a scaffold loudly on both ends ("fork it to author, then flip scaffold off in the editor"), the listing marks it, the SPA disables its start. The developer's ruling over my clear-the-flag draft: the flag RIDES FORKS UNTOUCHED -- a scaffold fork stays a scaffold until its author flips it off, so the flag is the package's doneness state, and publishing your own scaffold for others to fork is free. The settings editor is raw JSON for now (native UI later, the developer's "ready to run" toggle its eventual shape), with a hint teaching the keys.

The package editor (/packages/:name): every file of a user package is authoring material -- settings included -- with the cheap save lints (memory.json and settings.json must parse as JSON objects; the carryover passes the authored lint, the run surface's exact gate), the deep checks staying at the start gate where they already lived. The gates mirror the run precedent: system packages are repo-side and refuse ("fork to edit"); an ownerless user package is readable, forkable, never editable -- and an ownerless package IS forkable, the copy is yours.

The refactor the editor forced: the setup view's file-editor machinery (nav, textarea + the sigil/var highlight overlay, drafts, dirty marks, the save flow) extracted into widgets.mjs's fileEditor factory, parameterized over DOM ids and a PUT call -- setup keeps its run-side couplings (the phase-gated rw, the addressed session), the package editor is the simpler parameterization, and the editor CSS generalized from id selectors to classes so both surfaces share it.

En-route bug found and fixed: cmdCreate always copied the REPO's handbook.md into the run, so a user package's handbook -- which save-package faithfully copies out -- was silently ignored on re-create; the author's craft edit died in the round-trip. Create now prefers the package's own handbook when it carries one, else the repo's shared copy. The smoke proves the round-trip: a handbook marker authored through the package editor surfaces in the created run's files.

Browser-pass find: the pkgedit header state span and the editor's save-state span shared the id pkgedit-state, so the widget's select() wiped the header line -- the editor's span renamed (pkgedit-edit-state), verified rendering.

Verified: typecheck green both programs; smoke ALL PASS (+20 -- the fork battery: the template fork owner-stamped scaffold-preserved pc-stripped, create refusing the scaffold on both ends, the playable fork carrying no scaffold, fork validation, the editor gates owner-200/non-owner-403/system-repo-side-403/unknown-404, the raw-JSON and carryover save lints, the ready-to-run flip, create from the flipped fork, the handbook round-trip; and the ownerless pair: the editor refuses, the fork succeeds); restart + reminder checks green (6 runs); a browser pass on --mock --debug end to end -- the paste token re-landing after the state wipe, /new redirecting with the URL honest, the template card disabled with the scaffold note, boutique disabled as incomplete, the fork form prefill and submit landing in the editor, the scaffold state line, the settings flip and save making the card startable, the start-form flow intact, zero console errors; check-repo clean; the debug server back on the real state. Docs: README's packages passage (fork, scaffold, the editor, the gates), the booting flow, the layout tree (the clerk's fork-package verb, the view list, widgets.mjs); DICTIONARY's package, scaffold, and fork entries. The developer's queue line ('"create new package" in SPA') is struck by them in the same round. packages/detention stays untracked WIP, untouched.
2026-11-19 11:11:23 +00:00

244 lines
8.8 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tiny Worlds</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header>
<a id="home-link" href="/">Tiny Worlds</a>
<span id="who"></span>
<div id="session-info"></div>
<div id="context-meter" title="context usage of the last call">
<div id="context-bar"><div id="context-fill"></div></div>
<span id="context-label"></span>
</div>
<button id="diag-btn" title="diagnostics log">log</button>
<a id="source-link" href="https://code.fleshless.org/hackmaster/tiny-worlds" target="_blank" rel="noreferrer">source</a>
</header>
<main>
<section id="view-claim" hidden>
<h1>claim an invite</h1>
<p class="hint" id="claim-hint"></p>
<form id="claim-form">
<label class="field">invite code <input id="claim-code" autocomplete="off"></label>
<label class="field">display name <input id="claim-name" autocomplete="off"></label>
<div class="form-actions">
<button type="submit" class="primary">claim</button>
</div>
</form>
<form id="token-form">
<label class="field">or paste a token <input id="token-paste" autocomplete="off"></label>
<div class="form-actions">
<button type="submit">sign in</button>
</div>
</form>
</section>
<section id="view-home" hidden>
<h1>runs</h1>
<div id="run-list"></div>
<button id="new-run-btn" class="primary">new run</button>
<section id="admin" hidden>
<h2>admin</h2>
<div class="form-actions">
<button id="invite-mint">mint invite</button>
<span id="invite-code"></span>
</div>
<div id="invite-list"></div>
<div id="user-list"></div>
<div id="providers-admin">
<h3>providers</h3>
<div id="providers-banner" class="hint" hidden></div>
<div id="provider-list"></div>
<div class="form-actions">
<button id="provider-add-of">add opencode/free</button>
<button id="provider-add-custom">add custom provider</button>
</div>
<form id="provider-form" hidden>
<label class="field">slug <input id="provider-slug" autocomplete="off" placeholder="my-shop"></label>
<label class="field">baseUrl <input id="provider-base" autocomplete="off" placeholder="https://api.example.com/v1"></label>
<label class="field" id="provider-key-field" hidden>API key <input id="provider-key" type="password" autocomplete="off"></label>
<div class="form-actions">
<button type="button" id="provider-add-go">add and discover</button>
<button type="button" id="provider-add-cancel">cancel</button>
</div>
</form>
</div>
</section>
</section>
<section id="view-packages" hidden>
<h1>packages</h1>
<div id="package-pick">
<p class="hint">a run is a copy of the package -- everything stays editable until the session opens. Fork copies any package to author; scaffolds refuse to start.</p>
<div id="package-list"></div>
</div>
<form id="create-form" hidden>
<h2 id="create-title"></h2>
<label class="field">package name <input id="create-name" autocomplete="off"></label>
<label class="field">main character name <input id="create-pc" autocomplete="off"></label>
<div class="form-actions">
<button type="button" id="create-back">back</button>
<button type="submit" class="primary">create</button>
</div>
</form>
</section>
<section id="view-pkgedit" hidden>
<div class="setup-head">
<h1 id="pkgedit-title"></h1>
<span id="pkgedit-state"></span>
<button id="pkgedit-back">back to packages</button>
</div>
<div class="setup-body">
<nav id="pkgedit-files" class="files-nav"></nav>
<div class="edit-col">
<div class="edit-stack">
<pre id="pkgedit-hl" class="edit-hl" aria-hidden="true"></pre>
<textarea id="pkgedit-edit" class="edit-area" spellcheck="false"></textarea>
</div>
<div id="pkgedit-hint" class="edit-hint" hidden></div>
<div class="edit-bar">
<button id="pkgedit-save">save</button>
<span id="pkgedit-edit-state" class="edit-state"></span>
</div>
</div>
</div>
</section>
<section id="view-setup" hidden>
<div class="setup-head">
<h1 id="setup-title"></h1>
<span id="setup-state"></span>
<button id="setup-delete">delete draft</button>
<button id="setup-start" class="primary">start</button>
</div>
<div id="setup-vars" hidden>
<h2>prompt variables -- declared by the prompts, filled per run</h2>
<div id="setup-vars-list"></div>
<div class="form-actions">
<button id="setup-vars-save">save variables</button>
<span id="setup-vars-state"></span>
</div>
</div>
<div id="setup-models"></div>
<div id="setup-savepkg">
<input id="savepkg-name" placeholder="new package display name" autocomplete="off">
<button id="savepkg-btn">save as package</button>
<span id="savepkg-state"></span>
</div>
<div class="setup-body">
<nav id="setup-files" class="files-nav"></nav>
<div id="setup-editor" class="edit-col">
<div id="edit-stack" class="edit-stack">
<pre id="edit-hl" class="edit-hl" aria-hidden="true"></pre>
<textarea id="setup-edit" class="edit-area" spellcheck="false"></textarea>
</div>
<div id="edit-hint" class="edit-hint" hidden></div>
<div id="setup-edit-bar" class="edit-bar">
<button id="setup-save">save</button>
<span id="setup-edit-state" class="edit-state"></span>
</div>
</div>
</div>
</section>
<section id="view-play" hidden>
<nav id="table-tabs" hidden>
<button id="tab-table" class="tab">table</button>
<button id="tab-raw" class="tab">raw</button>
</nav>
<div id="transcript" aria-live="polite"></div>
</section>
<section id="view-story" hidden>
<div class="story-head">
<h1 id="story-title"></h1>
<button id="story-fork">fork this run</button>
<button id="story-back">back to the table</button>
</div>
<div id="story"></div>
</section>
</main>
<aside id="play-aside">
<section id="status-pane">
<div class="pane-head">
<h2>her status</h2>
</div>
<div id="status"></div>
<div id="conflict" hidden></div>
</section>
<section id="agenda-pane">
<div class="pane-head">
<h2>her agenda</h2>
</div>
<div id="agenda"></div>
</section>
<section id="sheet-pane">
<div class="pane-head">
<h2>the sheet</h2>
</div>
<div id="sheet"></div>
</section>
<section id="notes-pane">
<div class="pane-head">
<h2>gm notes</h2>
<span id="notes-state"></span>
</div>
<textarea id="gm-notes" placeholder="yours alone -- never sent to the model"></textarea>
</section>
<section id="housekeeping">
<h2>housekeeping</h2>
<div id="hk-state"></div>
<button id="hk-run" hidden>stop session</button>
<label id="hk-override-row" hidden><input type="checkbox" id="hk-override"> override: skip the unhousekept check</label>
<button id="session-open" hidden>start session</button>
<button id="hk-rerun" hidden title="a fresh pass over the finished predecessor -- the dormant session's rings are replaced">re-run housekeeping</button>
<button id="hk-replay" hidden title="run the housekeeper over a session log -- nothing applied">dry-run housekeeping</button>
<details id="hk-log" hidden><summary>session log</summary><pre id="hk-log-content"></pre></details>
<details id="hk-replay-log" hidden><summary>replay manifest</summary><pre id="hk-replay-content"></pre></details>
</section>
<section id="story-pane">
<h2>the story</h2>
<button id="story-link">read the story so far</button>
</section>
<section id="fork-pane">
<h2>fork</h2>
<p class="hint">a copy of this run -- yours to continue</p>
<button id="fork-btn">fork this run</button>
</section>
<section id="models-pane" hidden></section>
</aside>
<footer>
<div id="rewind-note" hidden>
<span id="rewind-note-text"></span>
<button id="rewind-cancel">cancel rewind</button>
</div>
<div id="gm-stack">
<pre id="gm-hl" aria-hidden="true"></pre>
<textarea id="gm-input" rows="6" placeholder="GM turn -- Enter newlines, Ctrl+Space sends" disabled></textarea>
</div>
<span id="busy" hidden>her turn...</span>
<button id="gm-send" disabled>send</button>
</footer>
<div id="banner" hidden></div>
<pre id="diag" hidden></pre>
<dialog id="ask-modal">
<h2>the player asks</h2>
<p id="ask-question"></p>
<textarea id="ask-answer" rows="3" placeholder="your ruling -- Enter sends"></textarea>
<button id="ask-send">answer</button>
</dialog>
<script type="module" src="/app.mjs"></script>
</body>
</html>