- A GUI-subsystem host has no console code page, so .NET decoded the probes' UTF-8 output with code page 0 and Claude's /usage separators never matched: Claude showed as unavailable in the app but not in the CLI. Probe output is now decoded as UTF-8 and every probe gets valid standard handles, with stdin closed unless it is the Codex RPC. A GUI-subsystem test host reproduces it. - The /usage parser stops at the contributing section and only reports lines that start like a limit line. - snapshot.json no longer defaults appPath to the reader's own path. The app passes its path to the engine and a CLI refresh keeps it, so a Stream Deck key always starts the app (D9, D10). - The CLI is finaltoken-cli on every platform: FinalToken.exe and finaltoken.exe cannot share a folder on Windows. - Day series follow the local calendar day, as Today does. - The dev-only migration from the first store format is gone. - README.md is a short user guide. Refs #1
139 lines
7.4 KiB
Markdown
139 lines
7.4 KiB
Markdown
# FinalToken
|
|
|
|
A small tray app that tracks Claude Code and Codex usage and limits on Windows 11 and CachyOS. It
|
|
never signs in to a provider and never handles a token: all data comes from the installed CLIs
|
|
and the files they write. A stats panel shows history, small popups warn when usage runs ahead
|
|
of or behind a limit's pace, and a Stream Deck plugin puts stats on keys. Developer:
|
|
schmidt.florian (Gitea user name).
|
|
|
|
## Sources of truth
|
|
|
|
- `docs/requirements.md` holds the requirements, with stable IDs (`R1`).
|
|
- `docs/decisions.md` holds the **recorded decisions** (`D1`), each with why and what it gives
|
|
up. Read the ones for your area before working in it. Cite IDs in code comments, commits and
|
|
PRs rather than restating the text.
|
|
- Each project under `src/` and `tests/` has a short `AGENTS.md`. Read it before changing the
|
|
project.
|
|
|
|
## Recorded decisions are binding
|
|
|
|
Build what the decisions say. When a task conflicts with one, or one looks wrong, stop: comment on
|
|
the issue with the conflict and a proposal, add `status/needs-decision`, and leave the call to the
|
|
developer. A decision changes only through a PR that edits its text in `docs/decisions.md`, keeps
|
|
the decision, why and gives-up format, and carries the `type/decision` label.
|
|
|
|
## Layout
|
|
|
|
| Path | What it is |
|
|
|---|---|
|
|
| `src/FinalToken.Core` | No UI. Domain model, pace (D7), collectors (D3, D4), history store (D5), refresh scheduler (D6), snapshot contract (D9), settings, plugin installer (D11) |
|
|
| `src/FinalToken.App` | Avalonia desktop app (D8): stats panel, tray, settings, popups |
|
|
| `src/FinalToken.Cli` | `finaltoken-cli` console: runs a refresh and prints the snapshot, for scripts and checks |
|
|
| `src/FinalToken.StreamDeck` | Stream Deck plugin executable and its `.sdPlugin` assets (D10) |
|
|
| `tests/*` | One test project per tested project, named `<Project>.Tests` |
|
|
| `tools/` | Repository tools, listed under [Tools](#tools) |
|
|
|
|
## Rules for code
|
|
|
|
- Current C# 14 on .NET 10: file-scoped namespaces, primary constructors, collection expressions,
|
|
`required` and `init`, pattern matching, `System.Threading.Lock`. Nullable reference types on.
|
|
- NativeAOT-safe everywhere (D1): System.Text.Json source generation, Avalonia compiled bindings,
|
|
no reflection-driven serialization, binding or loading, no `dynamic`, no runtime code
|
|
generation. Trim and AOT analyzer warnings are errors; never suppress one without a one-line
|
|
reason at that spot.
|
|
- Never touch credentials (D2): do not open credential files, environment secrets or keychains,
|
|
never log message text, and never call a provider's HTTP API.
|
|
- Child processes (`claude`, `codex`) run without a shell, with arguments as a list, a timeout and
|
|
cancellation, and are killed with their process tree when they overrun (D6).
|
|
- Every file the app writes for itself is written atomically (D5).
|
|
- Paths come from `Environment.GetFolderPath`, `Path.Combine` and the environment overrides named
|
|
in D3 and D4, never from hard-coded drive letters or `/home/<user>`.
|
|
- Parsers of CLI output and files are total: unknown or malformed input becomes a diagnostic,
|
|
never an exception that stops a refresh, and never a guessed value.
|
|
- A new package needs a justification in its PR and must be NativeAOT-compatible. Package
|
|
versions live in `Directory.Packages.props`.
|
|
- New behaviour has tests. Parser tests use small, hand-written fixtures under the test project;
|
|
never copy a real transcript or rollout into the repo.
|
|
|
|
## Workflow
|
|
|
|
1. **Issue first.** Find or create the Gitea issue at
|
|
`https://git.finalfactory.de/FinalFactory/FinalToken` and assign it to schmidt.florian. Put
|
|
the plan on the issue as a checklist and keep it current. Give it a `type/` label. Claim agent
|
|
work with the [active agent labels](#active-agent-labels).
|
|
2. **One branch per issue, in its own worktree:** branch `<issue>-<slug>` from `origin/master`,
|
|
checked out at `../FinalToken-wt/<issue>-<slug>`.
|
|
3. **Commit** with an `area: summary` subject (`docs:`, `tools:`, `core:`, `app:`,
|
|
`streamdeck:`, `cli:`), a body that says why, and `Refs #N`. Push after every commit.
|
|
4. **Open a PR** into `master` with a body that follows `.gitea/pull_request_template.md` and says
|
|
`Closes #N`. The PR title becomes the squash commit subject, so it follows the commit style.
|
|
5. **Review.** After the last push, start a fresh reviewer as described in
|
|
`docs/agents/review.md`. Fix blocking findings, push, and start a new review.
|
|
6. **Merge** with a squash merge once the review passes, then delete the branch and remove the
|
|
worktree.
|
|
|
|
Codex workers use GPT-6.1 Sol, model ID `gpt-6.1-sol`. Never select GPT-6 Sol or `gpt-6-sol`.
|
|
|
|
### Active agent labels
|
|
|
|
| Label | Meaning |
|
|
|---|---|
|
|
| `status/in-progress` | At least one agent works on the issue now |
|
|
| `agent/florian` | The active agents work for schmidt.florian |
|
|
| `model/<exact-model-id>` | An active agent uses this exact model ID |
|
|
|
|
- Add `status/in-progress`, `agent/florian` and each active model's label when work starts, and
|
|
post a claim comment with the models, their roles, the branch and the worktree.
|
|
- The coordinating agent keeps labels and comments current; workers report to it and do not edit
|
|
the issue. Remove a model label when its last agent stops, and all three kinds when none runs.
|
|
- Add and remove single labels. Never replace the issue's label list.
|
|
|
|
### Workers
|
|
|
|
The coordinating agent briefs workers, answers their questions and keeps the commits, pushes,
|
|
issue comments and the PR. Workers leave their changes uncommitted, end with a summary of the
|
|
commands they ran and their results, and list open questions under `QUESTIONS:`. Never let two
|
|
agents edit the same files at once.
|
|
|
|
## When you are stuck
|
|
|
|
- **Stop** when the same problem survives two attempts, or as soon as something proves
|
|
impossible. Comment on the issue with what you tried, what failed and what you need, and set
|
|
`status/blocked` or `status/needs-decision`.
|
|
- **The review loop has a limit:** after a PR's second failed review, the developer decides how
|
|
it goes on (`docs/agents/review.md`).
|
|
|
|
## Building and testing
|
|
|
|
Run every command from the repository root.
|
|
|
|
| Command | What it does |
|
|
|---|---|
|
|
| `dotnet build FinalToken.slnx -c Release` | Builds everything; any warning fails |
|
|
| `dotnet test --solution FinalToken.slnx -c Release` | Runs every test project |
|
|
| `python -B tools/docs/check_docs.py` | Checks that local links and anchors resolve, that each ID is defined once and that every cited ID exists |
|
|
|
|
Every change runs the build, the affected tests and the documentation check. UI changes also need
|
|
a screenshot of each changed view: compiling is not working.
|
|
|
|
## Tools
|
|
|
|
- `tools/docs/check_docs.py`: the documentation check; its tests are
|
|
`python -B tools/docs/test_check_docs.py`.
|
|
- `tools/gitea.sh`: calls the Gitea API with the stored git credential or `GITEA_TOKEN`.
|
|
- `tools/agent-review.sh`: posts an agent review and sets the `agent-review` status; see
|
|
`docs/agents/review.md`.
|
|
- `tools/publish.py`: publishes the app, `finaltoken-cli` and Stream Deck plugin with NativeAOT
|
|
into an empty output directory and creates a ZIP beside it. Run on the target OS.
|
|
|
|
## Writing
|
|
|
|
Docs, commit messages and PR bodies use plain, short sentences in the style of
|
|
`docs/decisions.md`. Link issues as
|
|
`[#1](https://git.finalfactory.de/FinalFactory/FinalToken/issues/1)`.
|
|
|
|
## Shared memory
|
|
|
|
Durable lessons (a gotcha, a convention, a command) go into this file, a project's `AGENTS.md` or
|
|
`.agents/mind/`, through a PR. Session state and handoffs go in issue comments.
|