token2rice: A DSH Plugin That Visualizes Token Consumption as Falling White Rice

Preface

The DeepSeek Harness (DSH) plugin system allows for interface extensions. token2rice is a web interface plugin maintained by user zczgagat. Its core function is to transform abstract Token consumption data into a visualized physical phenomenon: every time a certain quota of tokens is accumulated, a bowl of white rice falls from the top of the DSH window.

Core Features

The plugin is divided into a host side and a browser side.

  • Host Side: Responsible for data statistics. It aggregates the provider usage (input/output/cacheRead/cacheWrite) from assistant/message within session/event across the entire process and atomically writes the data to $DSH_HOME/token2rice/state.json for persistence.
  • Browser Side: Responsible for rendering and interaction. It registers into the window-level overlay shell.overlay and runs 2D physics logic within a requestAnimationFrame loop.
  • Visual Representation: Every time the quota is met, a bowl of white rice is generated at the top of the viewport. The bowl has a random orientation, self-rotation (0~1 r/s, random direction), and initial velocity (downward). After falling, it is affected by gravity (free fall), bounces upon landing, and squashes and rebounds.
  • Interaction Operations:
    • Drag: Grab the bowl with the mouse; the bowl will follow and swing. Upon release, it continues flying based on its current velocity.
    • Vortex Intake: Click the vortex button on the left of the counter board, or drag a bowl onto the button and release; the bowl will be sucked in, shrink, and disappear.
    • Double-click to Delete: Quickly clear bowls from the screen.
  • Counter Board: Displays the number of bowls exchanged and the token count in the bottom right corner. Its position is draggable, and clicking it opens the settings panel.
  • Custom Images: Supports replacing the image with PNG/JPEG/WebP/GIF files (≤4MB).

Installation and Activation

Install the plugin using the following command:

dsh plugin --profile desktop add github:zczgagat/token2rice

Refresh the page after installation to enable it.

Typical Usage

  1. Watch the Fall: As the conversation progresses, when Token consumption reaches the preset threshold, bowls of white rice will start falling from the top of the screen.
  2. Organize the Screen: Use the mouse to drag the falling bowls to adjust their positions, or double-click the bowls to delete them.
  3. Batch Cleanup: Click the vortex button on the counter board in the bottom right corner, or use the “Clear Screen” function in the panel.
  4. Replace Assets: Click “Select Image…” in the panel or drag an image file directly into the panel to replace the default rice image.

Use Cases and Notes

  • Calculation Scope: By default, it calculates four buckets: input, output, cacheRead, and cacheWrite. Cache reads usually account for the majority; heavy usage can reach tens of millions per day, resulting in strong visual feedback. If you prefer to focus on “newly computed tokens,” you can disable “Include Cache Tokens” in the settings.
  • Display Limit: The screen displays a maximum of 24 bowls simultaneously (default, adjustable from 4-80 in the panel). When exceeded, the oldest bowls are pushed off (the count is not affected).
  • Restart Requirement: Changes to the host-side code require a DSH restart to take effect; changes to the browser-side code only require a page refresh.
  • Counting Rules: The count starts from the first time the plugin is enabled and does not retroactively count expenses from before installation.

Summary

By concretizing Token consumption, token2rice provides developers with an intuitive perspective on cost monitoring. Combined with the custom image feature, it serves as both a tool and a visually fun experience.

  • Plugin Directory: https://www.skillhub.cn/plugins/zczgagat/token2rice
  • Source Repository: https://github.com/zczgagat/token2rice
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye