pi2dsh
weijiafu14
Bridge the Pi and DeepSeek Harness ecosystems: one Pi Host ABI runs unmodified Pi extensions as native DSH plugins. 打通 Pi 与 DSH 生态。
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:chencmb2077-ui/dsh-token-monitor
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Real-time token usage and DeepSeek account balance monitor for the DeepSeek Harness (DSH) web shell — a floating widget pinned to the bottom-right corner of the page.
A pure static host plugin: no client bundle, no build step, no Remote/typert surgery. It registers two JSON HTTP routes and injects a small vanilla-JS widget into index.html via tapIndex. Loads automatically with the deployment config and survives restarts.
session/event assistant/message events (durable, deduplicated TokenUsage), accumulated per session plus a global total. llm/stream provides live in-flight call visibility and the active session; tokenMeter.measure() estimates current context pressure.DEEPSEEK_API_KEY through the credentials seam and queries https://api.deepseek.com/user/balance via a node subprocess (OpenSSL TLS, works under the sandbox). 60s cache + manual refresh. The API key never leaves the machine and never reaches the browser.--dsw-alias-*) so it adapts to light/dark themes.This package is a DSH bundle: its package.json declares dsh.bundle.patch, so
installing it into a profile automatically joins it to the profile's bundle layers
(dsh plugin reconciles dsh.profile.bundles for you).
# from a local checkout (pnpm copies the package into the profile):
dsh plugin --profile web add file:/path/to/dsh-token-monitor
# or straight from GitHub (no checkout needed):
dsh plugin --profile web add github:chencmb2077-ui/dsh-token-monitor
dsh web # restart the profile so the bundle layer composes
Requires pnpm on PATH (npm i -g pnpm). To remove:
dsh plugin --profile web remove dsh-token-monitor
After boot:
GET /api/token-monitor/usage — usage JSON (sessions / total / activeSessionId / lastCall / live / context)GET /api/token-monitor/balance — balance JSON (?force=1 forces a refresh)Put the token-monitor directory next to the profile config:
$DSH_HOME/profiles/web/token-monitor/
Append to $DSH_HOME/profiles/web/cordis.patch.yml:
- insert:
- id: token-monitor
name: ./token-monitor/index.js
Note: point
nameat the entry file, not the directory — the DSH loader imports relative entries as ES modules, and Node does not support directory imports (ERR_UNSUPPORTED_DIR_IMPORT).
Restart dsh web.
node resolvable on PATH, a configured DEEPSEEK_API_KEY credential, and the DeepSeek official API (uses the baseURL from the llm-deepseek settings, default https://api.deepseek.com)127.0.0.1) by defaultMIT
session/event 的 assistant/message 事件(持久化、去重后的 provider TokenUsage),按会话分桶 + 全局合计;llm/stream 提供在途调用与活跃会话实时视图;tokenMeter.measure() 提供当前上下文压力估算credentials 解析 DEEPSEEK_API_KEY,用 node 子进程(OpenSSL TLS)请求 https://api.deepseek.com/user/balance,60 秒缓存 + 手动刷新;API key 仅在本机传递,绝不出现在页面或响应中--dsw-alias-*)自动适配明暗主题本包是 DSH bundle:package.json 里声明了 dsh.bundle.patch,安装进 profile 后会自动进入
该 profile 的 bundle 图层(dsh plugin 会自动把 bundle 追加到 dsh.profile.bundles)。
# 本地目录安装(pnpm 会把包复制进 profile):
dsh plugin --profile web add file:D:/path/to/dsh-token-monitor
# 或直接从 GitHub 安装(无需本地检出):
dsh plugin --profile web add github:chencmb2077-ui/dsh-token-monitor
dsh web # 重启 profile 使 bundle 图层生效
需要 PATH 上有 pnpm(npm i -g pnpm)。卸载:
dsh plugin --profile web remove dsh-token-monitor
插件启动后:
GET /api/token-monitor/usage — 用量 JSON(sessions / total / activeSessionId / lastCall / live / context)GET /api/token-monitor/balance — 余额 JSON(?force=1 强制刷新)把 token-monitor 目录放到 profile 目录下:
$DSH_HOME/profiles/web/token-monitor/
在 $DSH_HOME/profiles/web/cordis.patch.yml 追加:
- insert:
- id: token-monitor
name: ./token-monitor/index.js
注意:
name要指向入口文件而不是目录——DSH 加载器把相对路径当 ES 模块导入, Node 不支持目录导入(ERR_UNSUPPORTED_DIR_IMPORT)。
重启 dsh web 即可。
DEEPSEEK_API_KEY、使用 DeepSeek 官方 API(llm-deepseek 设置中的 baseURL,默认 https://api.deepseek.com)127.0.0.1),仅本机可访问MIT
The repo ships its own publish tooling under scripts/ — zero dependencies, plain Node + the GitHub REST API (no git binary needed). Both read the token from DSH_GH_TOKEN in the environment and never print it.
仓库自带发布脚本(scripts/ 目录),零依赖,纯 Node + GitHub REST API,不需要安装 git。token 从环境变量 DSH_GH_TOKEN 读取,脚本从不打印它。
export DSH_GH_TOKEN=ghp_xxx # your GitHub PAT / 你的 GitHub 令牌
node scripts/publish-github.mjs # sync files + topics + release + zip asset(同步文件/话题/发布/zip 资产)
node scripts/upload-github.mjs # create (or reuse) repo and upload files only(仅建仓库 + 传文件)
node scripts/build-zip.mjs # just rebuild dist/dsh-token-monitor-<tag>.zip(仅重建 zip)
DSH_GH_TAG (default v1.0.0) controls the release tag. publish-github.mjs is idempotent — re-running updates files/topics and recreates the tag/release. DSH_GH_TAG(默认 v1.0.0)控制发布标签;publish-github.mjs 可重复执行,重复运行会更新文件/话题并重建 tag 与 release。
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: monitoring、token-monitor。