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:
@@ -0,0 +1,39 @@
|
||||
using FinalToken.Core.Processes;
|
||||
using Xunit;
|
||||
|
||||
namespace FinalToken.Core.Tests;
|
||||
|
||||
public class ProcessTests
|
||||
{
|
||||
private static ProcessRequest LongProcess(string directory) => OperatingSystem.IsWindows()
|
||||
? new(new(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "ping.exe"), []), ["-n", "30", "127.0.0.1"], directory, TimeSpan.FromSeconds(60))
|
||||
: new(new("sleep", []), ["30"], directory, TimeSpan.FromSeconds(60));
|
||||
[Fact]
|
||||
public async Task FakeClockTimeoutTerminatesChild()
|
||||
{
|
||||
using var directory = new TestDirectory();
|
||||
var clock = new TestClock();
|
||||
var task = new ProcessRunner(clock).RunAsync(LongProcess(directory.Path), TestContext.Current.CancellationToken);
|
||||
clock.Advance(TimeSpan.FromSeconds(61));
|
||||
Assert.True((await task).TimedOut);
|
||||
}
|
||||
[Fact]
|
||||
public async Task CancellationTerminatesAndWaitsForChild()
|
||||
{
|
||||
using var directory = new TestDirectory();
|
||||
using var cancelled = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken);
|
||||
var task = new ProcessRunner().RunAsync(LongProcess(directory.Path), cancelled.Token);
|
||||
await cancelled.CancelAsync();
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => task);
|
||||
}
|
||||
[Fact]
|
||||
public async Task CaptureIsBoundedWithoutBlockingTheChild()
|
||||
{
|
||||
using var directory = new TestDirectory();
|
||||
var result = await new ProcessRunner().RunAsync(new(new("dotnet", []), ["--info"], directory.Path,
|
||||
TimeSpan.FromSeconds(60), OutputLimit: 50), TestContext.Current.CancellationToken);
|
||||
Assert.Equal(0, result.ExitCode);
|
||||
Assert.Equal(50, result.Output.Length);
|
||||
Assert.True(result.OutputTruncated);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user