feat: add FinalToken v1 for Claude and Codex usage (#2)

FinalToken v1: a NativeAOT tray app for Windows 11 and CachyOS that tracks
Claude Code and Codex usage and limits through their CLIs only, with no
provider sign-in and no tokens (R1-R7, D1-D11).

- Core: incremental collectors for Claude transcripts and Codex
  rollouts, limit probes through `claude -p /usage` and
  `codex app-server`, a journaled history store, the refresh engine,
  pace and popup decisions, and the snapshot.json contract.
- App (Avalonia): stats panel with limit bars, pace, projections, token
  totals, charts, limit history and breakdowns; tray, settings,
  non-activating pace popups, single-instance activation, start with
  the OS, and the Off/Ask/Automatic Stream Deck plugin install.
- Stream Deck plugin (SDK v2, NativeAOT) for Elgato and OpenDeck.
- finaltoken-cli, tools/publish.py, the documentation check and the
  agent review workflow.

Closes #1
This commit was merged in pull request #2.
This commit is contained in:
2026-10-14 22:11:19 +02:00
parent 6d67f157a5
commit f8afd11679
106 changed files with 6583 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
"""Run with python -B tools/docs/test_check_docs.py."""
from pathlib import Path
import tempfile
import unittest
from check_docs import check
class DocumentationCheck(unittest.TestCase):
def setUp(self):
self.scratch = tempfile.TemporaryDirectory(prefix="finaltoken-doc-check-")
self.root = Path(self.scratch.name)
self.write("docs/requirements.md", "# Requirements\n- **R1** A goal.\n")
self.write("docs/decisions.md", "# Decisions\n## D1 — A choice\nServes R1.\n")
self.write("README.md", "[Choice](docs/decisions.md#d1--a-choice), R1 and D1.\n")
def tearDown(self):
self.scratch.cleanup()
def write(self, relative, text):
path = self.root / relative
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")
def test_clean_tree(self):
self.assertEqual([], check(self.root))
def test_broken_file_link(self):
self.write("notes.md", "[Gone](gone.md)\n")
self.assertEqual(["notes.md:1: broken link: gone.md"], check(self.root))
def test_broken_anchor(self):
self.write("notes.md", "[Gone](docs/decisions.md#gone)\n")
self.assertEqual(["notes.md:1: missing anchor: docs/decisions.md#gone"], check(self.root))
def test_repeated_heading_anchors(self):
self.write("notes.md", "# Step!\n## Step!\n## Step!\n[First](#step) [Second](#step-1) [Third](#step-2)\n")
self.assertEqual([], check(self.root))
def test_duplicate_requirement(self):
self.write("docs/requirements.md", "- **R1** First.\n- **R1** Again.\n")
errors = check(self.root)
self.assertEqual(2, len(errors))
self.assertTrue(all("identifier R1 is defined more than once" in error for error in errors))
def test_duplicate_decision(self):
self.write("docs/decisions.md", "## D1 — A choice\n## D1 — Again\n")
self.assertEqual(2, len(check(self.root)))
def test_undefined_citation(self):
self.write("notes.md", "See R99 and D99. D3D12, x64 and RD8 are unrelated.\n")
self.assertEqual(["notes.md:1: undefined identifier R99", "notes.md:1: undefined identifier D99"], check(self.root))
def test_only_canonical_files_define_ids(self):
self.write("notes.md", "- **R99** A citation here.\n## D99 — A citation here\n")
self.assertEqual(2, len(check(self.root)))
def test_fenced_code_ignored(self):
self.write("notes.md", "````python\n[Gone](gone.md) R99\n```\nD99\n````\n~~~\nR98\n~~~\n")
self.assertEqual([], check(self.root))
def test_explicit_anchors(self):
self.write("notes.md", '<a class="target" id="one"></a>\n<a name=\'two\'></a>\n[One](#one) [Two](#two)\n')
self.assertEqual([], check(self.root))
def test_code_does_not_define_anchor(self):
self.write("notes.md", '```html\n<a id="hidden">\n```\n[Hidden](#hidden)\n')
self.assertEqual(["notes.md:4: missing anchor: #hidden"], check(self.root))
def test_excluded_trees(self):
for directory in (".git", "bin", "obj", ".artifacts", "node_modules"):
self.write(f"{directory}/notes.md", "R99 [Gone](gone.md)\n")
self.write("nested/.git", "gitdir: elsewhere\n")
self.write("nested/notes.md", "R99\n")
self.assertEqual([], check(self.root))
def test_directory_encoded_path_and_external_links(self):
self.write("docs/with space.md", "# Title\n")
self.write("notes.md", "[Dir](docs) [Title](docs/with%20space.md#title) [Web](https://example.org) [Mail](mailto:[email protected])\n")
self.assertEqual([], check(self.root))
def test_reference_link(self):
self.write("notes.md", "[Gone][target]\n[target]: gone.md\n")
self.assertEqual(["notes.md:2: broken link: gone.md"], check(self.root))
def test_link_followed_by_parenthesis(self):
self.write("notes.md", "([Choice](docs/decisions.md#d1--a-choice)).\n")
self.assertEqual([], check(self.root))
if __name__ == "__main__":
unittest.main()