Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down
50 changes: 50 additions & 0 deletions docs/contributing/start-here.md
Original file line number Diff line number Diff line change
@@ -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.

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` 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.

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).
128 changes: 128 additions & 0 deletions tests/AppService.Tests/ContributorDocsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System.Text.RegularExpressions;

namespace TomeStack.AppService.Tests;

/// <summary>
/// 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.
/// </summary>
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.CultureInvariant, 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 (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);
}
}

/// <summary>
/// The relative links in <paramref name="markdownPath"/> 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 <c>#anchor</c> that matches no heading of a Markdown target.
/// Skips <c>http://</c>, <c>https://</c>, <c>mailto:</c> and same-page <c>#anchor</c> links.
/// </summary>
internal static (int Checked, List<string> Broken) BrokenLinks(string markdownPath)
{
var folder = Path.GetDirectoryName(markdownPath)!;
var count = 0;
var broken = new List<string>();
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);
}

/// <summary>GitHub's heading anchors: lower case, punctuation other than hyphens and underscores dropped, spaces to hyphens.</summary>
private static HashSet<string> 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")]
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);
}
}