feat: 适配 Reasonix 本地用量统计 - #452
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change adds Reasonix as a passive telemetry provider. It discovers and parses Reasonix telemetry, integrates the data with CLI synchronization and status reporting, updates provider branding and supported-tool metadata, and adds parser and synchronization tests. ChangesReasonix integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to This change adds Reasonix local usage tracking and synchronization support; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Reasonix
participant SyncCommand
participant RolloutParser
participant SyncQueue
Reasonix->>SyncCommand: expose telemetry sidecars
SyncCommand->>RolloutParser: parse telemetry incrementally
RolloutParser->>SyncQueue: enqueue reasonix buckets
SyncCommand->>SyncQueue: report parsed files and queued buckets
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
test/sync-background.test.js (1)
366-376: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winExtend the regression to cover the Reasonix parser contract.
This test runs one sync only. It cannot detect duplicate imports from cumulative snapshots. Run the same sync twice and assert that the second run adds no Reasonix tokens. Also assert the normalized token columns and the normalized routed model.
As per coding guidelines: “Verify provider-specific token semantics from raw usage and billing data before mapping fields; cached tokens may be included in a provider's
inputvalue.”Based on learnings: “After changing sync logic or cursor schema, run sync twice consecutively to detect state pollution and migration errors.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/sync-background.test.js` around lines 366 - 376, Extend the test around the all-local background sync to run the command twice, then verify the second run does not increase Reasonix token totals. Assert the queue uses the normalized token fields and normalized routed model, while preserving the existing Reasonix source assertion and raw usage semantics.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@dashboard/index.html`:
- Line 370: Synchronize the supported-tool metadata with the 30-tool count: in
dashboard/index.html at lines 370-370, add Reasonix to the explicit FAQ list; in
README.de.md at lines 217-217, update the German comparison prose from 28 tools
to 30 tools.
In `@dashboard/src/ui/dashboard/components/ProviderIcon.jsx`:
- Line 334: Add REASONIX to the canonical PROVIDER_ICON_MAP using the uppercase
REASONIX key, in addition to its existing PROVIDER_LOGO_MAP entry.
In `@dashboard/src/ui/marketing/agent-logos.js`:
- Line 23: Move the user-facing “Reasonix” label out of the agent metadata in
the logos configuration. Add the corresponding localization entry to copy.csv
and update the rendering path for the Reasonix metadata to resolve its name from
the existing copy source, preserving the provider identifier.
In `@src/commands/init.js`:
- Around line 721-729: Update the Reasonix detection block to import and use the
shared resolveReasonixHome(process.env) resolver instead of manually reading
TOKENTRACKER_REASONIX_HOME, REASONIX_STATE_HOME, and the fallback path. Pass the
resolved home to existsSync so tilde-based overrides match the sync and status
behavior.
In `@src/commands/sync.js`:
- Line 285: Add "reasonix" to the BACKGROUND_AUTO_SYNC_SOURCES collection so
default --auto --background synchronization includes Reasonix telemetry. Extend
the relevant sync test to verify Reasonix is selected for default background
mode, while preserving the existing --all-local-sources coverage.
In `@src/lib/rollout.js`:
- Around line 12828-12830: Update the enqueue condition in the aggregation flow
around addReasonixDelta to also accept delta.requests > 0, so request-only
changes queue a conversation_count before sessionTotals[filePath] advances. Add
a regression test covering an increased requestCount with unchanged token
fields.
---
Nitpick comments:
In `@test/sync-background.test.js`:
- Around line 366-376: Extend the test around the all-local background sync to
run the command twice, then verify the second run does not increase Reasonix
token totals. Assert the queue uses the normalized token fields and normalized
routed model, while preserving the existing Reasonix source assertion and raw
usage semantics.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ae2d3374-5fbd-42a3-8317-5a3d630f232b
⛔ Files ignored due to path filters (1)
dashboard/public/brand-logos/reasonix.pngis excluded by!**/*.png
📒 Files selected for processing (18)
README.de.mdREADME.ja.mdREADME.ko.mdREADME.mdREADME.zh-CN.mddashboard/index.htmldashboard/public/llms.txtdashboard/src/ui/dashboard/components/ProviderIcon.jsxdashboard/src/ui/dashboard/components/ProviderIcon.test.jsxdashboard/src/ui/marketing/agent-logos.jspackage.jsonsrc/commands/init.jssrc/commands/status.jssrc/commands/sync.jssrc/lib/rollout.jstest/discovery-metadata.test.jstest/reasonix-parser.test.jstest/sync-background.test.js
| "PI-COPILOT": "/brand-logos/pi.svg", | ||
| "PI-OPENAI-CODEX": "/brand-logos/pi.svg", | ||
| QODER: "/brand-logos/qoder.svg", | ||
| REASONIX: "/brand-logos/reasonix.png", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Register REASONIX in PROVIDER_ICON_MAP.
Line 334 adds the provider only to PROVIDER_LOGO_MAP. Register the icon through the required canonical map with the uppercase REASONIX key.
As per coding guidelines, “Provider icons must be registered in PROVIDER_ICON_MAP using an uppercase source key.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@dashboard/src/ui/dashboard/components/ProviderIcon.jsx` at line 334, Add
REASONIX to the canonical PROVIDER_ICON_MAP using the uppercase REASONIX key, in
addition to its existing PROVIDER_LOGO_MAP entry.
Sources: Coding guidelines, Learnings
| { id: 27, name: "Qoder", provider: "qoder" }, | ||
| { id: 28, name: "AnythingLLM", provider: "anythingllm" }, | ||
| { id: 29, name: "Claude Science", provider: "claude-science" }, | ||
| { id: 19, name: "Reasonix", provider: "reasonix" }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Move the Reasonix label to copy.csv.
name is tooltip and accessibility text. The new hardcoded "Reasonix" value bypasses the dashboard localization source.
Add the label to dashboard/src/content/copy.csv and resolve it when rendering the logo metadata.
As per coding guidelines, “Never hardcode user-facing text; add it to dashboard/src/content/copy.csv.” As per path instructions, “User-facing strings must come from dashboard/src/content/copy.csv.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@dashboard/src/ui/marketing/agent-logos.js` at line 23, Move the user-facing
“Reasonix” label out of the agent metadata in the logos configuration. Add the
corresponding localization entry to copy.csv and update the rendering path for
the Reasonix metadata to resolve its name from the existing copy source,
preserving the provider identifier.
Sources: Coding guidelines, Path instructions
xiufengsun
left a comment
There was a problem hiding this comment.
NO-MERGE — reviewed exact head 3df1946d4c3b2b9e9a599834a2356f6d030ea738 against current origin/main.
There are two reproducible accounting blockers:
-
normalizeReasonixTotals()ignores ReasonixcacheWriteTokens. In current Reasonix telemetry, cache writes are a subset ofcacheMissTokens; this head assigns the entire miss count toinput_tokensand always emitscache_creation_input_tokens: 0. That misclassifies cache writes and produces the wrong cost for providers with cache-write pricing. Please splitcacheMissTokensinto non-cached input plus cache creation, carry that field through cumulative state/diff, include it intotal_tokens, and add a regression fixture with non-zerocacheWriteTokens. -
parseReasonixIncremental()only callsaddReasonixDelta()whentokenDelta > 0, but advancessessionTotals[filePath]unconditionally. IfrequestCountgrows while token fields do not, that conversation increment is skipped and then permanently absorbed into the cursor. Queue when either token delta or request delta is positive, and add a repeat-sync regression test.
The branch also conflicts with current main at package.json because it is still based on v0.88.4. Please rebase and keep the current release version while preserving the 30-tool description update. Request re-review after pushing a new head.
3df1946 to
fff56c1
Compare
|
已按 review 修复并更新分支:
本地验证:
另外两条建议未做扩大范围的改动:
新 head: @xiufengsun 烦请基于新 head 复审,谢谢。 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/sync-background.test.js`:
- Around line 77-97: Update withTempSyncEnv to save the current values of
TOKENTRACKER_REASONIX_HOME and REASONIX_STATE_HOME, clear both variables while
the test environment is active, and restore their original values during
cleanup, including preserving whether each was previously unset.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8ca03dab-e9a9-4b3a-9f13-190c45acd69d
📒 Files selected for processing (8)
README.de.mddashboard/index.htmlpackage.jsonsrc/commands/init.jssrc/commands/sync.jssrc/lib/rollout.jstest/reasonix-parser.test.jstest/sync-background.test.js
🚧 Files skipped from review as they are similar to previous changes (4)
- package.json
- src/commands/sync.js
- README.de.md
- src/commands/init.js
fff56c1 to
c59dc9e
Compare

背景
Reasonix 是面向 DeepSeek 深度适配的 Harness Agent。当前 TokenTracker 无法识别 Reasonix 产生的本地用量,因此其模型和 Token 消耗不会出现在 Dashboard 中。
改动内容
~/.reasonix/projects/**/sessions/*.jsonl.telemetry.json与~/.reasonix/sessions/**/*.jsonl.telemetry.json.jsonl.meta,不读取提示词、回复或工具输出基元律动-雷/deepseek-v4-flash-0731识别为deepseek-v4-flash-0731init检测和status状态输出隐私边界
Reasonix 适配只读取 Token 计数、模型标识和时间戳。不会读取或上传会话 JSONL 正文、提示词、模型回复、工具调用内容或源代码。
验证
validate:guardrails、validate:copy、validate:ui-hardcode通过说明
Reasonix 来源金额沿用 TokenTracker 现有模型定价引擎估算;第三方 API 站点的实际账单可能因路由商加价、折扣或套餐而不同。
Summary by CodeRabbit