diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 2a6c5c8..49b83cc 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1,6 +1,6 @@ # TableTower — Design and Status -**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (big files split; see §10) +**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (file splits, duplicate-code and terminology passes; see §10) This is the starting point for anyone picking the project up, including a new Claude session. It records what TableTower is, how it's built, how to work on it, where things @@ -13,6 +13,20 @@ stand, and what's next. builders, Check cards, card inputs, collections and the "why" trace. - `README.md`: user-facing usage notes and command-line/screenshot flags. +**Open items for the next session (as of 2026-11-09)** +- **Repo privacy (waiting on the user).** The Forgejo instance is internet-facing. The user + wants every one of their repos private, with `digit` and Niles/sock as collaborators. + - Today only `RobinFiredrake/TableTower` is public. + - Niles/sock's username wasn't found: logged-out user search for "niles" or "sock" returns nothing. + - **Needed from the user:** that exact username, plus an API token (repository read/write + and user read, passed as `FORGEJO_TOKEN`), or they do it in the web UI themselves. + - Don't go looking for stored credentials. +- **Hands-on playtest** of the split/renamed build. The user had a first look after the file + splits ("looking fine so far"), but the terminology pass hasn't been tried by hand. +- **Stale worktree.** `.claude/worktrees/agent-aa27e470dd86ce971` (branch `split-table-card`) + stayed locked by a finished agent. Its work is merged, so run + `git worktree remove -f -f` on it, then delete the branch. + --- ## 1. What TableTower is @@ -52,14 +66,14 @@ character, can run as one chain. Earlier rolls, a Variables tab, Copy (text, BBCode, with details) and **Why this?** on each step. **Logic cards** (`docs/LOGIC.md`) -- **Choice:** "which option" (pick, with Random), "how many" (a number) or "open +- **Choice:** "Which option" (pick, with Random), "How many" (a number) or "Open ended" (text). The pop-up can be minimized, and its options preview where they lead. - **Loop:** repeat N times, while a condition holds, or until it does. Then "Afterwards". - **Router:** if / else if / otherwise cases; the first true case runs. - **Check:** roll + modifier against a target, with Success and Failure outlets. Sets `nat`, `total` and `effect`. - **Variable** cards (with a starting value) and **Collection** cards (e.g. Skills, whose members are `@skill_*`). - **Sheet:** a live template, e.g. a character sheet. -- **Effects** on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names. +- **Changes** (stored as `effects`) on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names. - **Dynamic pick options** from a collection or list (`options_from`, `options_where`), plus `show_if` on any option. - **Card inputs:** a card declares inputs, and pipes pass values (`with`), scoped to that pipe's part of the roll. - **A 10,000-action limit** per roll. The roller uses an explicit stack, so long loops don't overflow. @@ -80,7 +94,9 @@ character, can run as one chain. - **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Arrange ▾ → Pack collapsed groups. - **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from - "+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`. + "+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`: + skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter + and simple sheet. - **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card. - **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports errors, dead ends, unreached cards and lint, and clicking an item jumps to the card. @@ -105,7 +121,8 @@ core/ engine, no UI, testable headless expr.gd / effects.gd expression evaluation (Godot Expression + rewrites), effect statements text_expander.gd [[refs]], {vars}, {@prefix_*}, {= expr}; formatter.gd: BBCode safety and stripping dice.gd / deck_state.gd dice parsing and distributions, card-mode decks - describe.gd rules → plain words, labels, why sentences + describe.gd rules → plain words, labels, why sentences; kind_label / choice_label + (the only place card-kind and choice-type names are defined) builder.gd effect/condition models ↔ text, known_values board_tester.gd simulation and static checks (used by the Test board UI and the CLI) library_store.gd / state_store.gd collections on disk / local state (decks, variables, history, settings) @@ -140,6 +157,10 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) `Style.field_colors`, `TableCard.vbox/hbox`, `InspectorKit.*` (fields, `focused_tag`/`refocus`, `as_text_link`), `Main.file_dialog`/`export_dialog`, `JsonIO.entry_line`/`finish_import`. - **Keep files small.** Aim for under ~400 lines; split by area into helper objects as above. + Next candidates, all 540–700 lines: + - core: describe, roll_table, expr + - ui: choice_dialog, inspector_card, inspector, main, edit_history + - io: json_io ## 4. Data and storage - **Collections:** `user://collections/.json`, format_version 2 (`{format_version, id, @@ -169,6 +190,17 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - Inspector and focus: `--inspect=tid[:eid][>to]`, `--search`, `--focus`, `--minimap`. - Tools and layout: `--test-board`, `--pack`, `--perf`, `--window=WxH`. +- **Coderstanding** (the user's structure scanner, https://forgejo.smhub.duckdns.org/digit/coderstanding) + saves tokens on audits and big reads. + - **Not installed permanently.** Clone it into the scratchpad, make a venv, `pip install `. + - **Keep its config and data out of the repo.** Set `XDG_CONFIG_HOME=/xdgconf`, then + `coderstanding add tabletower --data /cs_data` and `coderstanding rescan tabletower`. + - **Commands:** `outline ` (functions with line ranges), `hotspots`, `dupes` + (string literals only), `warnings`, `find`, `uses`, `brief`. + - **Copied code:** `dupes` doesn't find copied code blocks; use a sliding-window line hash for that. +- **Launching for the user to look at** (not a test): plain `godot --path .` in the + background is fine, so the window comes to the front. + **Git and agent workflow** - **Git:** remote `origin` = `git@forgejo.smhub.duckdns.org:RobinFiredrake/TableTower.git`. Work on a feature branch and merge to `main` when the user asks (fast-forward). @@ -176,6 +208,8 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - **Agents.** Large features have been split across parallel agents in git worktrees, each owning specific files: - Worktrees start from an old commit, so each brief says `git reset --hard ` first. - Merge one by one, run every suite and the simulator, take screenshots, then fix the seams. + - Brief each agent to keep the public API of the file it owns (one-line delegators), so + parallel splits don't conflict. Only tests may change in several branches at once. - Merged feature branches still exist locally and on the server (`pipe-board`, `fast-roll`, `logic-cards`, `groups-templates`, `boards-v2`, `undo-options`, `plain-build`); they can be deleted. @@ -189,6 +223,17 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - Collapse/expand isn't undoable. Collection members aren't undoable. - Rules are stored as text, and the plain layer sits on top of it, so old boards open unchanged. - Traveller-derived content stays out of the repo (§8). +- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names. + - **Card:** anything on the felt. "Roll table" means only the `roll` kind. + - **Result**, never "entry" or "row" (code: `TableEntry`, `entries`). + - **Change** in plain text, "effect" only in Text mode (code and JSON: `effects`). + - **Pipe.** Pipes are *deleted*, like cards and results. "Remove" is for taking an item out + of something. + - **Reset** = back to the starting value, or erased if the value has no card. "Clear" only + when a value really is erased. + - **Dice** always read `2d6` / `d6`. `2D` is accepted as input only. + - **Choice types:** "Which option / How many / Open ended", from `Describe.choice_label`. + - **JSON keys aren't renamed.** A rename needs a format bump plus migration. ## 7. Known gaps and bugs - **Only one pipe per target per result.** Pipes are keyed by target id, so the mockup's @@ -205,6 +250,11 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) Pipes into a collapsed group can't be clicked. - Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON. - `{= }` dice in live sheet and variable displays re-roll when the display refreshes. +- **Not yet looked into: Coderstanding warnings.** + - Signals emitted but never connected: `ModalCard.closed`, `SearchPanel.closed`. + - A possible wrong handler in `ModalCard.segmented` (`pressed` → `on_change`; probably a + false positive from a bound callable). + - Large class cycles in ui/ (expected from the `main` back-references). ## 8. The Traveller test board (private) - **Location.** Private content derived from the user's Mongoose Traveller 2e rulebook lives in @@ -261,11 +311,11 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - Drop the `_` on helpers used across files. - `EffectsBuilder`/`ConditionBuilder` → `*Editor`, `LibraryStore` → `CollectionStore`. - Keep JSON keys as they are; document the key ↔ UI mapping in LOGIC.md. -14. **Housekeeping:** delete merged branches. Keep LOGIC.md and PLAIN.md in step with features. +14. **Housekeeping:** delete merged branches (also `split-table-card`, see Open items). Keep LOGIC.md and PLAIN.md in step with features. -## 10. History (2026-11-08, one long session) +## 10. History -**Board and core features** +**2026-11-08 (one long session): board and core features** 1. Initial Godot project and the original design doc. An HTML mockup became the pipe board, built in Godot. 2. First feature wave (parallel agents): weights, dice expressions, card mode, text references and BBCode, collections and local state, import/export, a Linux preset, the play-side UI, and the app shell (settings,