Use the operator's HTTPS proxy with a private backend on port 5187. Limit the Proxmox host script to container creation and install a self-updating command inside the LXC. Preserve keys/history during legacy proxy migration and keep root updater code isolated from unprivileged build output. Closes #21
157 lines
9.1 KiB
Markdown
157 lines
9.1 KiB
Markdown
# FinalToken
|
|
|
|
A small tray app that tracks Claude Code and Codex usage and limits on Windows 11 and CachyOS. It
|
|
keeps provider credentials owned by the installed CLIs. The optional web dashboard coordinates
|
|
official CLI login with transient authorization-code relay (D14). 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) |
|
|
| `src/FinalToken.Fleet` | Account/machine metadata, shared analysis and pending official CLI logins (D14) |
|
|
| `src/FinalToken.Web` | Authenticated self-hosted dashboard and outbound-worker API (D14) |
|
|
| `src/FinalToken.Worker` | Per-OS-user collector and official CLI login process host (D14) |
|
|
| `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 provider credentials (D2): do not open credential files, provider environment secrets or keychains,
|
|
never log message text, and never call a provider's HTTP API. D14 permits authenticated,
|
|
transient authorization-response relay to the pending official CLI login. Dashboard/worker
|
|
access keys authenticate FinalToken transport; they are not provider credentials.
|
|
- 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
|
|
|
|
Releasing: bump `<Version>` in `Directory.Build.props`, then publish; the tool stamps the plugin manifest.
|
|
|
|
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/icon/make_icon.py`: renders the shared app icon with development-only Pillow 11.3.0.
|
|
Run `python -B tools/icon/make_icon.py`; test with `python -B tools/icon/test_make_icon.py`.
|
|
- `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. It stamps
|
|
the plugin manifest's `Version` from `<Version>`; its test is `python -B tools/test_publish.py`.
|
|
- `tools/test_web_dashboard.py`: provider-free HTTP/worker/process integration; build Release first.
|
|
`--serve-fixture` runs a temporary synthetic dashboard for screenshots. See `docs/web-dashboard.md`.
|
|
- `tools/proxmox.sh`: creates a managed Debian 13 LXC from the Proxmox host. Its Python
|
|
helpers live in `tools/proxmox/`; test with `python -B tools/proxmox/test_installer.py`. See `docs/proxmox.md`.
|
|
- `tools/lxc_update.py`: installed as `finaltoken-update` inside the CT. Fetches/builds/activates
|
|
locally without Proxmox host commands; test with `python -B tools/proxmox/test_update.py`.
|
|
- `tools/check_public.py --history`: read-only publication pattern check. It reports paths/pattern
|
|
names, never matching values; tests are `python -B tools/test_check_public.py`. See `docs/publication.md`.
|
|
|
|
## 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.
|