docs: record parser scope, local days, child handles and appPath
D3 says which /usage lines are limit lines, D5 that days follow the local calendar, D6 that probes get their own UTF-8 pipes because a GUI host has no console, and D9 who supplies the app path in the snapshot. Refs #1
This commit is contained in:
+17
-9
@@ -48,8 +48,10 @@ working.
|
||||
`result` text holds lines such as
|
||||
`Current session: 28% used · resets Oct 14, 7:30pm (Europe/Berlin)` and
|
||||
`Current week (all models): 66% used · resets Oct 18, 8pm (Europe/Berlin)`. Each becomes a
|
||||
limit window: the session window is 5 h, a week window 7 d. A line that does not parse is
|
||||
reported as a diagnostic and skipped; the parser never guesses a value.
|
||||
limit window: the session window is 5 h, a week window 7 d. Only lines that start with
|
||||
`Current ` are limit lines; other prose is ignored and parsing stops at the "What's
|
||||
contributing to your limits usage?" section. A limit line that does not parse is reported as a
|
||||
diagnostic and skipped; the parser never guesses a value.
|
||||
|
||||
**Why.** Claude Code has no machine-readable limit command, and `/usage` is the CLI's own view.
|
||||
Claude Code deletes transcripts after `cleanupPeriodDays` (30 days by default), so history
|
||||
@@ -86,8 +88,10 @@ when it changes.
|
||||
`Environment.SpecialFolder.LocalApplicationData/FinalToken` (`%LOCALAPPDATA%\FinalToken` on
|
||||
Windows, `~/.local/share/FinalToken` on Linux). It holds hourly token buckets per provider, model
|
||||
and project, and limit samples (time, provider, window, used percent, reset). A sample is kept
|
||||
when it differs from the window's previous one, and otherwise at most once an hour. All files are
|
||||
JSON or JSON lines through System.Text.Json source generation. There is no database dependency.
|
||||
when it differs from the window's previous one, and otherwise at most once an hour. Hours are
|
||||
stored in UTC; day series, today and the week follow the local calendar day, including days of 23
|
||||
and 25 hours at daylight-saving changes. All files are JSON or JSON lines through
|
||||
System.Text.Json source generation. There is no database dependency.
|
||||
|
||||
- **Writing.** Each refresh that found something new appends one newline-terminated transaction
|
||||
to a journal. A torn last line is ignored on load and cut off before the next append. When the
|
||||
@@ -95,9 +99,9 @@ JSON or JSON lines through System.Text.Json source generation. There is no datab
|
||||
written atomically (a temporary file in the same directory, then a replace), and the journal
|
||||
starts empty. Transactions hold absolute values, so replaying them after an interrupted
|
||||
compaction gives the same result. A refresh that found nothing new writes no history.
|
||||
- **Reading.** Files that are replaced atomically (`snapshot.json`, settings, the month files, the checkpoint, the
|
||||
activation request) are opened with read, write and delete sharing, and the replace retries
|
||||
briefly, so a reader never makes a write fail on Windows.
|
||||
- **Reading.** Files that are replaced atomically (`snapshot.json`, settings, the month files,
|
||||
the checkpoint, the activation request) are opened with read, write and delete sharing, and the
|
||||
replace retries briefly, so a reader never makes a write fail on Windows.
|
||||
- **Scanning.** For each source file the store remembers its length, its last write time and how
|
||||
far it read. An unchanged file is not opened; otherwise only appended bytes are read. A file
|
||||
that shrank or was replaced is read again from the start.
|
||||
@@ -127,7 +131,9 @@ run every 5 min by default (configurable from 1 to 60 min), and also after new t
|
||||
but at most once a minute per provider. Probes run one at a time per provider with a 60 s
|
||||
timeout; a probe that times out has its process tree killed and counts as failed. A failed probe
|
||||
keeps the last good sample and marks it with its age. Shutting down cancels the running work
|
||||
and waits for it.
|
||||
and waits for it. Every child process gets its own standard input, output and error pipes, decoded
|
||||
as UTF-8, because a GUI host has no console and no console code page; stdin is closed at once
|
||||
unless the probe is the Codex RPC.
|
||||
|
||||
**Why.** Limits change only when tokens are spent, and a probe starts a CLI process, so probing
|
||||
follows token activity instead of a tight timer.
|
||||
@@ -190,7 +196,9 @@ and reason, its limit windows (used percent, reset, length, pace state, delta an
|
||||
and its token totals for today, the current session window and the current week. The DTOs and
|
||||
their source-generated JSON context live in `FinalToken.Core`, shared by the app, the CLI and the
|
||||
Stream Deck plugin. Nothing listens on a socket or runs an HTTP server. A reader treats a
|
||||
snapshot older than three refresh intervals as stale.
|
||||
snapshot older than three refresh intervals as stale. The app gives the engine its own path; a
|
||||
CLI refresh keeps the path already in the snapshot, and a snapshot without one has none, so a
|
||||
reader never mistakes its own path for the app's.
|
||||
|
||||
**Why.** R6 needs the stats outside the app. A file has no network surface, and it survives a
|
||||
restart of either side.
|
||||
|
||||
Reference in New Issue
Block a user