From 45458eff25bb24fe55c9593c5033322903199c96 Mon Sep 17 00:00:00 2001 From: Arlo Kharod <42082766+firegiant9000@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:55:09 -0600 Subject: [PATCH 1/2] Docs: contributor start-here page (4.11) --- CONTRIBUTING.md | 2 + README.md | 2 +- docs/CHANGELOG.md | 1 + docs/contributing/start-here.md | 50 +++++++++++++ .../AppService.Tests/ContributorDocsTests.cs | 73 +++++++++++++++++++ 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 docs/contributing/start-here.md create mode 100644 tests/AppService.Tests/ContributorDocsTests.cs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9312f42e..c94782be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,8 @@ TomeStack is a local-first Windows desktop app: a WPF + WebView2 shell, a React/TypeScript UI, a .NET 10 service and SQLite. Setup and the everyday build are in the [README](README.md#build-and-test). +New here? [Start here](docs/contributing/start-here.md): reporting bugs, writing homebrew, or a first UI fix. + The specs in [`docs/`](docs/) are authoritative: [SPEC](docs/SPEC.md) is behavior, [MVP](docs/MVP.md) is the release boundary and [ROADMAP](docs/ROADMAP.md) is the milestones. Changes follow [LIVING_SPECS](docs/LIVING_SPECS.md#change-workflow): update the specs or ADRs and [CHANGELOG](docs/CHANGELOG.md) in the same change as the code. ## The gate diff --git a/README.md b/README.md index d1e43a39..0d03d85c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Every calculated value on the sheet expands into its trace: each step, the amoun - **Experimental:** reading a PDF's text and proposing candidates (M4). Nothing becomes a rule until you review and publish it, and it has not yet been proven on a real third-party book. - **Evidence:** checks are either fixture-verified (automated tests), Windows-install verified (the CI desktop smoke, or an owner check on an installed build), or accepted in real play. Nothing is accepted in real play yet (that is the M3 gate). See [features/m2-acceptance.md](docs/features/m2-acceptance.md#evidence-levels-m21-2026-09-28). -New to TomeStack? Start with the [getting started guide](docs/guides/getting-started.md); what it does not do yet is in [known gaps](docs/guides/known-gaps.md). +New to TomeStack? Start with the [getting started guide](docs/guides/getting-started.md); what it does not do yet is in [known gaps](docs/guides/known-gaps.md). Want to help? See [start here](docs/contributing/start-here.md). The bundled content is a small, attributed slice of both SRDs (CC-BY-4.0; see [ATTRIBUTION.md](ATTRIBUTION.md)). You can also build from source (below). Milestone evidence is in [ROADMAP](docs/ROADMAP.md) and [`docs/features/*-acceptance.md`](docs/features/). diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index feb6dfa5..f51fe358 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased ### Added +- **Docs only, contributor onboarding (Wave 4 item 4.11):** [contributing/start-here.md](contributing/start-here.md) gives three ways in: play and report, write homebrew, or a first UI fix. CONTRIBUTING.md and the README link to it. No app change. - **Development only, test load caps and a gate script:** local test runs no longer use every core. Vitest runs at most 8 workers (override with `TOMESTACK_TEST_WORKERS`), and xUnit runs at most 8 threads per test project on machines with more than 8 cores; CI keeps its defaults. `scripts/gate.ps1` runs gate steps 1–8 in order, with per-step logs, a summary, a watchdog for a hung e2e or a11y run, DevHost cleanup, an optional lower priority and a CPU check. No app change. - **Accessibility check in CI, two contrast fixes:** `npm run test:a11y` runs axe, colour contrast included, in the installed Edge against the DevHost, in light and dark, over home, each builder step and each sheet tab, plus home in each named theme. Serious and critical violations fail it, and it now runs in CI. It found two low-contrast spots, both fixed without changing any colour: the "Offline" tag in the header now sits on the page colour, and in the dark theme the sheet's status-bar buttons (Hit points, Armor Class, Initiative, Speed) now sit on the page colour instead of the browser's grey button face. - **Tests only:** the UI flow tests in `src/Ui/e2e/` are split by feature (the 69 tests of `flow.e2e.tsx` into eight files, the 13 of `forms.e2e.tsx` into two, shared helpers in `helpers.tsx`); no test changed and no file is over 800 lines. The e2e files now run one after another against the shared DevHost. No app change. diff --git a/docs/contributing/start-here.md b/docs/contributing/start-here.md new file mode 100644 index 00000000..426db444 --- /dev/null +++ b/docs/contributing/start-here.md @@ -0,0 +1,50 @@ +# Start here + +TomeStack is a Windows character sheet for 5E-compatible play where every number explains itself: tap a value and "Why?" shows the rule, the source page and the choice behind it. It is free, offline and open source. + +There are three ways to help, and only the last one needs a build: + +- [Play and report](#play-and-report): use it at the table and tell us what was wrong or missing. +- [Write homebrew](#write-homebrew): author your own content in the app and tell us where the guides fall short. +- [Fix the UI](#fix-the-ui): a small change to the React interface. + +## Play and report + +1. Install the latest release from the [Releases page](https://github.com/firegiant9000/TomeStack/releases). The installer is not signed yet, so Windows asks you to confirm the first run. The [getting started guide](../guides/getting-started.md) walks through your first character. +2. Play with it. What it does not do yet is in [known gaps](../guides/known-gaps.md), so you can skip reporting those. +3. When something is off, [open a bug](https://github.com/firegiant9000/TomeStack/issues/new/choose): + - **A number is wrong:** open its "Why?" and say which step of the trace is wrong and what it should be. The trace is the most useful thing you can send. + - **A rule or feature is missing:** add a gap note on that field or feature in the app ([gap notes](../features/gap-notes.md)), then use the note's "Copy as issue text" and paste it into the bug. + - **It crashed or misbehaved:** Settings > Copy diagnostics, and paste it into the bug. Check it for anything personal first. + +The bug form asks for your TomeStack version (Settings > About), your Windows version, the steps, and what you expected. Never paste text from a book you do not own the rights to share. + +## Write homebrew + +TomeStack has a homebrew studio: you write classes, subclasses, species, backgrounds, items and spells in the app, try them in a sandbox on an unsaved copy of a character, and publish them when they are ready. + +- The [authoring guides](../authoring/README.md) cover a [class](../authoring/class.md), a [source pack](../authoring/source-pack.md) you can share, and an [extension](../authoring/extension.md). +- **Original content only.** Write your own words and numbers. Do not copy rules text from published books; the repository only carries the attributed SRD text that is already bundled, and adding more needs a licence review. +- To share what you made, or to tell us where a guide was unclear, [open an issue](https://github.com/firegiant9000/TomeStack/issues/new/choose) and attach the source pack file. + +## Fix the UI + +The interface is React and TypeScript in [`src/Ui`](../../src/Ui). A first change there needs Node and the .NET SDK (see [Prerequisites](../../README.md#prerequisites-windows-1011)), then, in `src/Ui`: + +``` +npm ci +npm run lint +npm test +``` + +The UI flow tests (`npm run test:e2e`) also need the .NET build; [Build and test](../../README.md#build-and-test) in the README has the order. + +A few rules the checks enforce: + +- Components talk to the app only through [`src/Ui/src/api/client.ts`](../../src/Ui/src/api/client.ts); lint rejects `fetch` anywhere else. +- Each change adds a line to the [CHANGELOG](../CHANGELOG.md) under Unreleased. +- Keep the change small and add or update a test for it. + +You do not need to run the Windows desktop checks yourself: CI runs the desktop smoke, the two-instance check and the accessibility check in Edge on every pull request. Issues labelled [good first issue](https://github.com/firegiant9000/TomeStack/labels/good%20first%20issue) are a good place to start. + +The full gate and the project's rules are in [CONTRIBUTING.md](../../CONTRIBUTING.md). diff --git a/tests/AppService.Tests/ContributorDocsTests.cs b/tests/AppService.Tests/ContributorDocsTests.cs new file mode 100644 index 00000000..55f6e2e5 --- /dev/null +++ b/tests/AppService.Tests/ContributorDocsTests.cs @@ -0,0 +1,73 @@ +using System.Text.RegularExpressions; + +namespace TomeStack.AppService.Tests; + +/// +/// Pins the contributor start-here page (Wave 4 item 4.11): its three paths, its relative links, the links to it from +/// CONTRIBUTING.md and the README, and that the tester path asks for no build. +/// +public sealed partial class ContributorDocsTests +{ + private static string RepoRoot + { + get + { + var directory = new DirectoryInfo(AppContext.BaseDirectory); + while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "TomeStack.slnx"))) + directory = directory.Parent; + return directory?.FullName ?? throw new InvalidOperationException("TomeStack.slnx not found above the test output folder."); + } + } + + private static string StartHerePath => Path.Combine(RepoRoot, "docs", "contributing", "start-here.md"); + + [GeneratedRegex(@"\]\(([^)#\s]+)(#[^)]*)?\)", RegexOptions.None, 1000)] + private static partial Regex MarkdownLink(); + + [Fact] + public void StartHere_exists_with_three_paths() + { + Assert.True(File.Exists(StartHerePath), "docs/contributing/start-here.md is missing."); + var lines = File.ReadAllLines(StartHerePath); + Assert.Contains("## Play and report", lines); + Assert.Contains("## Write homebrew", lines); + Assert.Contains("## Fix the UI", lines); + } + + [Fact] + public void StartHere_relative_links_resolve() + { + var folder = Path.GetDirectoryName(StartHerePath)!; + var targets = MarkdownLink().Matches(File.ReadAllText(StartHerePath)) + .Select(m => m.Groups[1].Value) + .Where(t => !t.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !t.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase)) + .ToList(); + Assert.NotEmpty(targets); + var broken = targets.Where(t => + { + var full = Path.GetFullPath(Path.Combine(folder, t.Replace('/', Path.DirectorySeparatorChar))); + return !File.Exists(full) && !Directory.Exists(full); + }).ToList(); + Assert.Empty(broken); + } + + [Theory] + [InlineData("CONTRIBUTING.md")] + [InlineData("README.md")] + public void Contributing_and_readme_link_to_start_here(string file) + { + Assert.Contains("](docs/contributing/start-here.md)", File.ReadAllText(Path.Combine(RepoRoot, file)), StringComparison.Ordinal); + } + + [Fact] + public void Play_and_report_needs_no_build() + { + var text = File.ReadAllText(StartHerePath); + var start = text.IndexOf("## Play and report", StringComparison.Ordinal); + Assert.True(start >= 0, "The Play and report section is missing."); + var next = text.IndexOf("\n## ", start + 1, StringComparison.Ordinal); + var section = next < 0 ? text[start..] : text[start..next]; + foreach (var forbidden in new[] { "npm ", "dotnet ", "scripts/" }) + Assert.DoesNotContain(forbidden, section, StringComparison.Ordinal); + } +} From fc379dd44994b0ebfb5566d144aba5c8c8a299e4 Mon Sep 17 00:00:00 2001 From: Arlo Kharod <42082766+firegiant9000@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:06:51 -0600 Subject: [PATCH 2/2] Docs test: case-sensitive links and anchors; UI rules wording (review fixes) --- docs/contributing/start-here.md | 4 +- .../AppService.Tests/ContributorDocsTests.cs | 79 ++++++++++++++++--- 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/docs/contributing/start-here.md b/docs/contributing/start-here.md index 426db444..13502a29 100644 --- a/docs/contributing/start-here.md +++ b/docs/contributing/start-here.md @@ -39,9 +39,9 @@ npm test The UI flow tests (`npm run test:e2e`) also need the .NET build; [Build and test](../../README.md#build-and-test) in the README has the order. -A few rules the checks enforce: +Rules for UI changes: -- Components talk to the app only through [`src/Ui/src/api/client.ts`](../../src/Ui/src/api/client.ts); lint rejects `fetch` anywhere else. +- Components talk to the app only through [`src/Ui/src/api/client.ts`](../../src/Ui/src/api/client.ts). Lint rejects `fetch` and other network calls outside `src/Ui/src/api/transport.ts`. - Each change adds a line to the [CHANGELOG](../CHANGELOG.md) under Unreleased. - Keep the change small and add or update a test for it. diff --git a/tests/AppService.Tests/ContributorDocsTests.cs b/tests/AppService.Tests/ContributorDocsTests.cs index 55f6e2e5..a7e30e43 100644 --- a/tests/AppService.Tests/ContributorDocsTests.cs +++ b/tests/AppService.Tests/ContributorDocsTests.cs @@ -21,7 +21,7 @@ private static string RepoRoot private static string StartHerePath => Path.Combine(RepoRoot, "docs", "contributing", "start-here.md"); - [GeneratedRegex(@"\]\(([^)#\s]+)(#[^)]*)?\)", RegexOptions.None, 1000)] + [GeneratedRegex(@"\]\(([^)#\s]+)(#[^)]*)?\)", RegexOptions.CultureInvariant, 1000)] private static partial Regex MarkdownLink(); [Fact] @@ -37,20 +37,75 @@ public void StartHere_exists_with_three_paths() [Fact] public void StartHere_relative_links_resolve() { - var folder = Path.GetDirectoryName(StartHerePath)!; - var targets = MarkdownLink().Matches(File.ReadAllText(StartHerePath)) - .Select(m => m.Groups[1].Value) - .Where(t => !t.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !t.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase)) - .ToList(); - Assert.NotEmpty(targets); - var broken = targets.Where(t => - { - var full = Path.GetFullPath(Path.Combine(folder, t.Replace('/', Path.DirectorySeparatorChar))); - return !File.Exists(full) && !Directory.Exists(full); - }).ToList(); + var (checkedCount, broken) = BrokenLinks(StartHerePath); + Assert.True(checkedCount > 0, "No relative links were found to check."); Assert.Empty(broken); } + [Fact] + public void BrokenLinks_catches_wrong_case_missing_anchor_and_missing_file() + { + var folder = Path.Combine(Path.GetTempPath(), "ts-docs-" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(folder); + try + { + File.WriteAllText(Path.Combine(folder, "Real.md"), "# Real\n\n## Some Heading (x/y)\n"); + var page = Path.Combine(folder, "page.md"); + File.WriteAllText(page, "[a](real.md) [b](Real.md#missing) [c](Real.md#some-heading-xy) [d](httpd.md) [e](https://example.com/x) [f](#local)\n"); + var (checkedCount, broken) = BrokenLinks(page); + Assert.Equal(4, checkedCount); + Assert.Equal(["real.md", "Real.md#missing", "httpd.md"], broken); + } + finally + { + Directory.Delete(folder, recursive: true); + } + } + + /// + /// The relative links in that would 404 on GitHub: a missing file or folder, a name whose case differs from + /// the file on disk (GitHub paths are case-sensitive, Windows is not), or an #anchor that matches no heading of a Markdown target. + /// Skips http://, https://, mailto: and same-page #anchor links. + /// + internal static (int Checked, List Broken) BrokenLinks(string markdownPath) + { + var folder = Path.GetDirectoryName(markdownPath)!; + var count = 0; + var broken = new List(); + foreach (Match match in MarkdownLink().Matches(File.ReadAllText(markdownPath))) + { + var target = match.Groups[1].Value; + if (target.StartsWith("http://", StringComparison.Ordinal) || target.StartsWith("https://", StringComparison.Ordinal) || target.StartsWith("mailto:", StringComparison.Ordinal)) + continue; + count++; + var anchor = match.Groups[2].Success ? match.Groups[2].Value[1..] : null; + var full = Path.GetFullPath(Path.Combine(folder, target.Replace('/', Path.DirectorySeparatorChar))); + var ok = ExistsWithExactCase(full) + && (anchor is null || !File.Exists(full) || !full.EndsWith(".md", StringComparison.OrdinalIgnoreCase) || HeadingSlugs(full).Contains(anchor)); + if (!ok) broken.Add(match.Groups[1].Value + match.Groups[2].Value); + } + return (count, broken); + } + + private static bool ExistsWithExactCase(string fullPath) + { + var trimmed = fullPath.TrimEnd(Path.DirectorySeparatorChar); + var parent = Path.GetDirectoryName(trimmed); + if (parent is null) return Directory.Exists(trimmed); + if (!Directory.Exists(parent)) return false; + var name = Path.GetFileName(trimmed); + return Directory.EnumerateFileSystemEntries(parent).Any(e => string.Equals(Path.GetFileName(e), name, StringComparison.Ordinal)) + && ExistsWithExactCase(parent); + } + + /// GitHub's heading anchors: lower case, punctuation other than hyphens and underscores dropped, spaces to hyphens. + private static HashSet HeadingSlugs(string markdownFile) => + File.ReadLines(markdownFile) + .Where(l => l.StartsWith('#')) + .Select(l => l.TrimStart('#').Trim().ToLowerInvariant()) + .Select(h => new string(h.Where(c => char.IsLetterOrDigit(c) || c is ' ' or '-' or '_').ToArray()).Replace(' ', '-')) + .ToHashSet(StringComparer.Ordinal); + [Theory] [InlineData("CONTRIBUTING.md")] [InlineData("README.md")]