- JavaScript 53.5%
- HTML 33.7%
- Python 9%
- CSS 3.3%
- Dockerfile 0.5%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| assets | ||
| docs/superpowers/specs | ||
| saves | ||
| scripts | ||
| src | ||
| tasks | ||
| test | ||
| .dockerignore | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Dark Spire
The spire is dark. Protect the light.
A story-driven minimal idle. You carry a lantern up a dark spire to light a beacon at the top. There are no generators to buy, no upgrades to slot, no synergies to chase — only steps, oil, and what you remember on the way up.
What it feels like
You open the page. A lantern flame flickers. A spire bar fills. A small banner says The spire is dark. Protect the light. No onboarding prompt. No upgrade grid. Just climb.
Every second the lantern advances one step. Every 200 steps you bank +1 oil, which fuels the flame — the more oil you carry, the brighter the lantern, the faster you climb. Every 1000 steps something surfaces — a sentence of prose, a fragment of memory from before you lost your name. The fragments stack across ascensions and each one makes the next climb a little faster.
Somewhere around step 500 the lantern breathes — a 5-second +10% climb boost, a quiet punctuation in the rhythm. Whispers drift through from the first steps: half are echoes of memories you've already collected, half are previews of memories you haven't yet. The spire feels alive.
When steps reach spire height, a Light the Beacon button appears. Pressing it doesn't end the game — it resets steps and oil, makes the next spire 1.05× taller, and grants +3% permanent climb speed ("memory of warmth"). Lore fragments persist forever. The lantern keeps climbing.
Core loop
┌────────────────────────────────────────────────────────────┐
│ Climb (1 step/sec base) │
│ × lightLevel │
│ = (1 + oil × 0.03) │
│ × 1.03 ^ ascensions │
│ × 1.05 ^ loreCount │
└────────────────────────────────────────────────────────────┘
│ every 500 steps
▼
Rest stop: +10% for 5s, lantern breathes
│ every 1000 steps (first time only)
▼
Lore fragment unlocks (+5% permanent)
│ steps ≥ spireHeight
▼
Light the Beacon:
ascensions += 1
spireHeight ×= 1.05
steps ← 0, oil ← 0
lore persists
│ steps ≥ 36000 AND all 35 prebuilt unlocked
▼
APEX — "What do you offer eternity?" overlay
┌─────────────────────────────────────────────┐
│ player types text (or leaves empty) │
│ submits → recordUserOffer → resetForNewCycle│
│ non-empty: traces += 1, offerText stored │
│ empty : traces unchanged, offerText:null│
│ full state reset: steps=0, oil=0, │
│ spireHeight=2000, ascensions=0, lore=[] │
│ traces + userOffers persist across cycles │
└─────────────────────────────────────────────┘
Each trace cycle = climb 60 ascensions of growth (2000 → 4000 → … → 36000) to re-unlock all 35 memories. Traces carry across cycles; lore doesn't.
Tuning constants are frozen in src/climb/ClimbMechanics.js so the formula
above is the literal source of truth. No hidden modifiers.
What you actually do
There is no clicking. The climb is automatic. Your only inputs are:
- Light the Beacon — appears when steps reach spire height. Resets the climb, grows the next spire, locks in your ascension bonus.
- Auto-Ascent toggle (v30+) — once you've lit the beacon at least once, you can opt-in to auto-climbing subsequent spires.
- The Apex Offer (v31+) — when you reach 36000 steps with all 35 prebuilt memories in hand, the Light the Beacon button instead opens the "What do you offer eternity?" overlay. Type a free-text offering (or leave it empty) and submit. The cycle resets; your trace remains.
- Tap the Traces stat (v31+) — opens the Past Traces overlay, showing every offering you have left at the apex, newest first.
Everything else is reading. The numbers tick, the flame shifts tier as oil accumulates (low → mid → high glow colors), whispers drift in and fade out, rest stops punctuate the rhythm, and the memory log at the bottom grows one sentence at a time.
Lore
Thirty-five prebuilt fragments, ordered by step threshold, unlock on
first-time crossing within a trace cycle. They persist across
ascensions within the same cycle but reset to [] on the next trace.
There is also a 36th memory at step 36,000 — the apex lore — which
is supplied by the player at the end of each cycle.
| Step range | Wave | Excerpt |
|---|---|---|
| 1k–12k | The climbing | "The flame is colder than it should be. You do not say this aloud." |
| 13k–24k | The deepening | "The communion is closer now. It does not smell the way you expected." |
| 25k–35k | The apotheosis | "The handle is warm now. It has always been warm. You are the one who was cold." |
| 36k | The offering | The player's own words, saved on the server. |
Each fragment gives +5% permanent climb speed (1.05^loreCount). Full
prose lives in src/climb/LoreFragments.js.
Why lore resets on trace: the trace cycle is the game's only
prestige layer (per Pecorella's idle-design canon — see the deep-dive
report in the research collection on markdownbin). Each trace
increments the Traces stat and persists the user's offering. The
lore is forgotten on cycle end so the next climb has the same
discovery weight as the first. The player's cumulative offering
record is preserved and accessible via the Traces stat.
Architecture (under the hood)
Dark Spire is built on the same module skeleton the parent project uses
for its other idle experiments — vanilla JS, no framework, a single
timer-driven loop (setInterval + watchdog; rAF was dropped in v30.3),
an event bus for cross-system messages, and
break_infinity.js for big-number math. The game-specific mechanics
live in src/climb/; the generic engine lives in src/core/,
src/utils/, src/saves/.
src/
├── main.js — wires everything, runs the climb loop
├── core/
│ ├── EventBus.js — pub/sub for cross-system events
│ ├── GameState.js — single source of truth (steps/oil/spire/asc/lore)
│ └── GameLoop.js — rAF tick → climb → render → save
├── climb/ — Dark Spire–specific mechanics
│ ├── ClimbMechanics.js — TUNING, computeLightLevel, applyClimbTick,
│ │ performAscent, isAtApex, performTrace
│ ├── LoreFragments.js — the 35 prebuilt memory fragments
│ │ + 1 player-supplied apex lore
│ ├── Whispers.js — mid-climb prose flashes (echo + preview)
│ ├── RestStops.js — every 500-step lantern-breath + +10% boost
│ ├── BeaconEchoes.js — personalized "X memories carried" overlay
│ ├── EndgameOffer.js — "What do you offer eternity?" overlay (v31)
│ └── PastTraces.js — Past Traces history overlay (v31)
├── saves/SaveManager.js — localStorage autosave, save-format versioning
├── ui/
│ ├── Renderer.js — DOM render, event wiring
│ ├── PlayerPicker.js — username picker overlay (v30.40)
│ └── OnboardingHint.js — first-time hint banner
└── utils/Decimal.js — break_infinity.js wrapper
scripts/
├── ssr-build.mjs — pre-renders index.html at server start
└── ssr-server.py — serves SSR'd HTML + telemetry beacon endpoint
test/ — node --test smoke + regression suites
Why no framework
Idle UIs update at most every 50–100 ms. A 5 kb renderer is enough.
Migrating to Svelte/React is the wrong move at this scale — you'd add
~50 kb of runtime to update five <span>s.
Event bus over direct calls
Every cross-system update goes through EventBus.emit(). The renderer,
the save manager, the telemetry beacon, and (future) analytics all stay
decoupled from the climb loop. Adding a "play sound on lore unlock" hook
is one bus.on('loreUnlocked', …).
SSR-first HTML
scripts/ssr-server.py runs scripts/ssr-build.mjs at startup, which
imports the engine into a mocked DOM and serializes the resulting HTML
to index.html. The page ships fully rendered — all content is visible
even if JS fails to load, fails to hydrate, or runs on a stale cached
bundle. JS enhances the page with the climb loop and interactivity.
Save format versioning
SaveManager stamps every save with a format version. Older shapes are
migrated on load (see v29.5: gold → oil rename migration; v31
additive v2 → v3 migration adding traces and userOffers). This is
how schema changes ship without losing player progress.
Telemetry beacons
The page fires new Image().src = '/telemetry?event=…' from key moments
(save-restored, hydrate, engine-error, tick). The server logs them.
This is the cheapest way to debug "did the loop actually run on the
iPhone?" without standing up a full analytics pipeline. Both GET (via
new Image()) and POST (via navigator.sendBeacon() for the hydrate
beacon) are accepted by ssr-server.py.
- v30 math is identical to a snapshot of v30.0 behavior
(
test/v30-vs-current.mjs)
Run it
Prerequisites
The dev server is a Python script, but it shells out to
node scripts/ssr-build.mjs at startup to pre-render the page — so you
need both runtimes, plus the npm dependencies:
- Python 3 — serves the SSR'd HTML, save API, and telemetry endpoint
- Node.js 18+ — runs the SSR build (imports the engine into a mocked DOM)
npm install(one-time) — pullsbreak_infinity.js(used by the engine + tests) and pinsesbuild(the SSR bundler) as a devDependency. Without it the SSR build fails withERR_MODULE_NOT_FOUNDand the server exits.
npm install
Local dev
python3 scripts/ssr-server.py . 5175
# open http://localhost:5175
The server runs the SSR build once at startup, then serves the rendered
HTML + the engine module bundle. Restart to pick up changes to
src/main.js or anything it imports. Rebuilds from the same git commit
produce byte-identical index.html — the version stamp is the commit
SHA, not a build timestamp.
For static-only iteration without SSR rebuilds:
python3 -m http.server 5173
# open http://localhost:5173
Tailscale deploy (optional)
Serve over your tailnet so a phone can hit it from anywhere on the LAN:
# expose :5175 as HTTPS with a real cert
tailscale serve https / http://localhost:5175
Plain HTTP over the tailnet mesh works for idle games. iOS Safari balks at WebRTC over plain HTTP — use the HTTPS form for anything beyond static polling.
Tests
npm install # one-time: pulls break_infinity.js + esbuild (devDep)
npm test # runs all five suites (smoke + 4 regression)
You can also run a single suite directly — they're plain node scripts:
node test/smoke.mjs # main suite (140 tests — covers v30.49 regressions + v31 endgame)
node test/investigation-fixes.mjs # v30.49 regressions (52 tests)
node test/applyclimbtick-rate-override.mjs # v30.7 regression
node test/gameloop-headless.mjs # watchdog/stall logic (v30.4)
node test/v30-vs-current.mjs # math snapshot vs v30.0 (needs git)
140/140 passing across smoke + v30.49 regressions. The suites cover:
- Tuning constants match the values in
ClimbMechanics.js(incl.LORE_COUNT_TOTAL=35,APEX_STEP=36000) - Light-level formula at 0/1/5 ascensions × 0/1/3 lore fragments
- Climb rate computation (Decimal precision)
- Oil accumulator: 1 oil per 200 steps, resets on ascent
- Lore unlock on first-time crossing (idempotent on re-check)
- Spire-height growth on ascension (1.05× exactly)
- Step cap at spire height (cannot climb past the beacon)
- Apex trigger (v31):
isAtApextrue at step ≥ 36000 AND 35 prebuilt unlocks; false on either boundary - Trace cycle (v31):
performTraceresets state, preserves traces+userOffers; empty offer keeps traces at 0 - Save v2→v3 migration (v31): additive, no wipe, all existing fields preserved
- Rendered HTML (v31):
header-traces-statpresent,/35counter present,/12counter absent,tracePulseCSS present - SSR template shape: spire-card markup, beacon button, auto-ascend toggle, memory list, whisper overlay
- Climb-rate override accepts
Decimal | function | null(v30.7 regression) - Rest stops fire on boundary crossing, not exact landing (v30.49)
- Lore unlocks clamp at the last authored fragment; numeric save order (v30.49)
- Per-player localStorage cache, server-save re-queue, player-name sanitization matching the server (v30.49)
- v30 math is identical to a snapshot of v30.0 behavior
(
test/v30-vs-current.mjs)
Changelog
The full history is in git log. Highlights since the redesign at
66c0c95:
v31 — the apex / trace cycle
- v31 — Lore expanded 12 → 35 prebuilt fragments in three waves
(the climbing, the deepening, the apotheosis). At step 36000 with all
35 in hand, the Light the Beacon button opens "What do you offer
eternity?" — the player types an offering, the state fully resets
to base, and a trace remains. The
Tracesstat is display-only (no climb-rate effect) and is server-persisted so it can be read by future games in the og_arist0tle mesh. Save format v2 → v3 (additive migration; existing v2 saves preserved losslessly). - v31.0 — removed GoldenCookie spawner (Dark Spire–specific; the
scaffold copy at
idle-scaffold/src/events/GoldenCookie.jsis untouched for other demos).
v30 — climb-the-spire rework
- v30 — fundamental rework from the lantern-buying loop to the
climb-the-spire loop. New state shape:
steps, oil, spireHeight, ascensions, loreUnlocked. Drops generators/upgrades/prestige layers. - v30.2 — whispers (mid-climb prose), rest stops (every 500 steps), beacon echoes (personalized "X memories carried").
- v30.3 — fix climb stalling at step 173 (rAF →
setInterval). - v30.4 — watchdog +
visibilitychangehandling for climb-loop stalls on iOS Safari background-tab pauses. - v30.5 — watchdog-fires + tick telemetry beacons so we can see whether the loop is alive on the iPhone.
- v30.6 — regular-tick catch-up for iOS pauses (climb only advanced 1 step after a long background).
- v30.7 — fix
applyClimbTickclimb-rate override to acceptfunction(state) => Decimal(was aTypeErrorevery tick since v30.2). - v30.49 — investigation sweep: rest stops recur after manual beacon lights and fire on boundary crossing; lore clamps at the 12 authored fragments (no phantom +5% boosts past step 12,000); per-player localStorage cache (no cross-player bleed); overlapping server saves re-queue instead of dropping; player names sanitized to match the server (names with spaces no longer re-prompt the picker every load); lore prose deduplicated (Renderer had a drifted copy); dead pre-v30 modules removed.
For the pre-v30 history (the Lantern Stand economy, Hire Angels →
Eternity prestige, etc.) see git log 4acac95..66c0c95.