mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-07-29 02:45:13 +00:00
Claude Code routed through a GitHub-Copilot-backed proxy (ANTHROPIC_BASE_URL -> claude-code-over-github-copilot / claudegate) costs ~$0 marginal but was priced at full Anthropic API rates, producing a misleading cost figure. The JSONL records only the model name and no endpoint, so proxying cannot be auto-detected; the user declares it. Add a `proxyPaths` config (managed via a new `codeburn proxy-path` subcommand) listing project directories served through a subscription proxy. Sessions whose canonical path is under one keep their full API-rate totalCostUSD (the billable would-be figure is never destroyed) and additionally report totalProxiedCostUSD, so the JSON report overview exposes cost / proxiedCost / netCost (netCost = cost - proxiedCost). With no proxyPaths configured the new fields are 0 and every existing consumer is unchanged. Design: "full cost, flagged" was chosen over zeroing cost so a misconfigured or since-changed path can never silently erase real Anthropic spend. Attribution is project-level (one canonical path per project), computed in a single helper (summarizeProject) that all ProjectSummary builders route through, including the cross-provider merge in parseAllSessions (re-derived from the merged total so a repo used with both Claude and Codex stays correct). The in-memory session-cache key folds in a proxy-config hash so toggling proxyPaths in a long-lived process cannot serve stale attribution. Path matching is segment-boundary anchored (/foo does not match /foobar), trailing-slash and backslash tolerant, leading- slash agnostic (so a non-Claude provider's slash-stripped path matches the same way Claude's absolute path does), and case-folded only on case-insensitive filesystems (macOS/Windows, not Linux). The proxy-path CLI sanitizes a hand-edited config.json (non-array / non-string entries) rather than crashing. Tested: isProxiedPath matching matrix (boundary, case, Windows, empty, root, multi-path, leading-slash form); config-hash distinctness/order-independence; end-to-end attribution through parseAllSessions incl. the critical negative cases (real spend must not be zeroed); cross-provider Claude+Codex merge; Codex-only project under a proxy path; date-range-filtered attribution; cache-staleness after a config change; and the proxy-path CLI add/list/remove, malformed-config robustness, and the report --format json overview. Scope note: proxiedCost/netCost currently surface in `report --format json` only; wiring them into the TUI dashboard and menubar payload is a follow-up. |
||
|---|---|---|
| .. | ||
| fixtures/security | ||
| providers | ||
| security | ||
| antigravity-statusline.test.ts | ||
| bash-commands.test.ts | ||
| blob-to-text.test.ts | ||
| classifier.test.ts | ||
| cli-date.test.ts | ||
| cli-deepseek-v4-pricing.test.ts | ||
| cli-export-date-range.test.ts | ||
| cli-json-daily.test.ts | ||
| cli-model-savings.test.ts | ||
| cli-plan.test.ts | ||
| cli-proxy-path.test.ts | ||
| cli-status-menubar.test.ts | ||
| compare-stats.test.ts | ||
| content-utils.test.ts | ||
| currency-rounding.test.ts | ||
| daily-cache.test.ts | ||
| dashboard.test.ts | ||
| date-range-filter.test.ts | ||
| day-aggregator-savings.test.ts | ||
| day-aggregator.test.ts | ||
| export.test.ts | ||
| fetch-utils.test.ts | ||
| fs-utils.test.ts | ||
| local-model-savings.test.ts | ||
| mcp-coverage.test.ts | ||
| mcp-redact.test.ts | ||
| mcp-server.test.ts | ||
| mcp-tables.test.ts | ||
| menubar-installer.test.ts | ||
| menubar-json.test.ts | ||
| menubar-savings.test.ts | ||
| minimax.test.ts | ||
| model-efficiency.test.ts | ||
| models-hoist.test.ts | ||
| models-report.test.ts | ||
| models.test.ts | ||
| optimize-fs.test.ts | ||
| optimize.test.ts | ||
| parser-claude-cwd.test.ts | ||
| parser-compact-entry.test.ts | ||
| parser-filter.test.ts | ||
| parser-gemini-cache.test.ts | ||
| parser-large-json-scanner.test.ts | ||
| parser-large-session.test.ts | ||
| parser-local-savings.test.ts | ||
| parser-mcp-inventory.test.ts | ||
| parser-proxy-codex-only.test.ts | ||
| parser-proxy-merge.test.ts | ||
| parser-proxy-pricing.test.ts | ||
| parser-skip-line.test.ts | ||
| plan-usage.test.ts | ||
| plans.test.ts | ||
| pricing-fallback-data.test.ts | ||
| provider-registry.test.ts | ||
| provider-turn-grouping.test.ts | ||
| session-cache.test.ts | ||
| usage-aggregator.test.ts | ||