Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
docs(statusline): describe the one token-file rule and the published marker
Jack Rudenko88a91a4b3d4c
diff --git a/ai-docs/architecture/context-window.md b/ai-docs/architecture/context-window.mdindex 69087864..b9aaf16e 100644--- a/ai-docs/architecture/context-window.md+++ b/ai-docs/architecture/context-window.md@@ -10,7 +10,7 @@ Claude Code resolves its compaction point as `min(CLAUDE_CODE_AUTO_COMPACT_WINDO**The status line reports the ENFORCED window, not the spec window.** `TokenTracker.writeFile` derives `context_left_percent` from `inputTokens` alone — folding in the session-CUMULATIVE `outputTokens` made the value decay with session AGE and pin at 0 forever once lifetime output passed the window (measured: input 94,018 of a 372,000 window reporting 0% left). Both generated status-line variants then recompute against `min(spec window, CLAUDE_CODE_MAX_CONTEXT_TOKENS ?? 200000, CLAUDE_CODE_AUTO_COMPACT_WINDOW)` and render `18% (164k/200k of 372k)` when those disagree, so a clamp is visible on day one instead of costing days of half-context work.-The status line is a generated **shell one-liner** (and a generated JS file on Windows), so TypeScript cannot catch a typo in it — test the generated artifact by executing it (`status-line-context.test.ts`). `CLAUDISH_TOKEN_FILE` redirects `TokenTracker`'s output path for hermetic tests; do NOT try to move `HOME`, since `homedir()` cannot be re-pointed at runtime in Bun. Bash integer division truncates where JS `Math.round` rounds, so the bash variant uses `((x*200/w)+1)/2` to keep both platforms on the same number.+The status line is a generated **shell one-liner** (and a generated JS file on Windows), so TypeScript cannot catch a typo in it — test the generated artifact by executing it (`status-line-context.test.ts`). The token file's path is ONE rule, `resolveTokenFilePath` in `session/token-file.ts`, used by the tracker that writes it, the status line and the end-of-session summary: an ASSIGNED `CLAUDISH_TOKEN_FILE` (a team slot's or channel session's own path; tests use it too), else `<home>/.claudish/tokens-<port>.json` with `<home>` read `$HOME`-first — Bun's `os.homedir()` ignores a runtime `HOME`, so a tracker that called it wrote a file the summary never read under a redirected HOME. claude-runner publishes the session's file to Claude Code as both `CLAUDISH_TOKEN_FILE` and `CLAUDISH_PUBLISHED_TOKEN_FILE`; when a claudish started from that session's Bash tool sees the two equal, the file is its parent's status-line file, not an assignment, and it keeps its own (sharing one made each status line show the other's model and cost). Bash integer division truncates where JS `Math.round` rounds, so the bash variant uses `((x*200/w)+1)/2` to keep both platforms on the same number.## Context Tracking for Local Models