fix: probe Claude from the GUI app and close integration gaps

- 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
This commit is contained in:
Florian Schmidt
2026-10-14 20:39:53 +02:00
parent 183247bab5
commit 50ac2aad3a
30 changed files with 364 additions and 95 deletions
@@ -190,30 +190,6 @@ public class ReworkTests
Assert.Equal(now.AddMinutes(5), Assert.Single(store.LatestLimits(Provider.Claude)).SampleTime);
}
[Fact]
public async Task LegacyMigrationPreservesTotalsAndDedupeWithoutCodexEventKeys()
{
using var directory = new TestDirectory();
var now = DateTimeOffset.UtcNow;
var usage = TranscriptParser.Parse(Fixtures.Claude(time: now.ToString("O")), new())!;
var hour = new DateTimeOffset(now.UtcTicks - now.UtcTicks % TimeSpan.TicksPerHour, TimeSpan.Zero);
var legacy = new HistoryData
{
Buckets = [new(Provider.Claude, hour, usage.Model, usage.Project, usage.Counts)],
DedupeKeys = [usage.DedupeKey, $"codex:session-1:{now.UtcTicks}:12"],
CodexTotals = new() { ["session-1"] = new(Input: 10, Output: 2, Total: 12) }
};
directory.Write("history.json", System.Text.Json.JsonSerializer.Serialize(legacy, CoreJsonContext.Default.HistoryData));
var store = new HistoryStore(directory.Path, new());
Assert.False(store.Add(usage));
Assert.Equal(19, store.Total(Provider.Claude, now.AddHours(-1), now.AddHours(1)).Total);
await store.CompactAsync(TestContext.Current.CancellationToken);
store = new(directory.Path, new());
Assert.False(store.Add(usage));
var stateJson = File.ReadAllText(Path.Combine(directory.Path, "history.state.json"));
Assert.DoesNotContain("codex:session-1:", stateJson);
Assert.Contains("\"codexTotals\":{\"session-1\":", stateJson);
}
[Fact]
public async Task SharingViolationRetriesUntilReaderReleasesItsHandle()
{
if (!OperatingSystem.IsWindows()) return;