WeKnora
Tencent
Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:ParticleLight/dsh-all-usage
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DeepSeek Harness 全量用量看板:按模型、供应商、工作区和时间范围分析 Token、缓存与账户余额。
all_usage_aliasesdomain/changed 事件自动跟随工作区注册表——注册表一有改动(创建/删除/重命名/重排/归档/成员变化)就重读 workspaceRegistry.list();只对新增/删除的工作区做增量处理,未变化的已有工作区直接复用已计算账本(零重扫)。统计严格限定已注册工作区:未注册 cwd(含存在但未登记目录)一律忽略>=22 <25;CI 会在 Node 22 和 Node 24 上运行测试、语法检查和 npm 包内容检查。package.json 声明 DSH runtime >=0.1.1-rc.1 <0.1.5-0 || >=0.1.5-rc.1 <0.1.6-0,已使用 0.1.5-rc.2、0.1.5-rc.1、0.1.1-rc.2 和 0.1.1-rc.1 的真实 Cordis 服务链验证;0.1.2-rc.1 已通过实际使用验证兼容,但未纳入 CI smoke 矩阵。声明按元组拆成两段而非写成单一区间,是因为 node-semver 只有在范围里存在与目标版本同 major.minor.patch 且自身带预发布标签的比较符时,才会放行该预发布版本。webServer 声明为必需依赖,确保服务晚挂载时由 DSH 等待后再执行插件;该包面向 DSH Web profile,不提供无 WebServer 的 headless 路由。HTTP 守卫还会检查真实 socket peer,反向代理只有在连接本身来自 loopback 时才会被接受。| DSH runtime | Node.js 支持 | 真实 Cordis smoke | 结论 |
|---|---|---|---|
0.1.5-rc.2 |
>=22 <25 |
通过(真实 Cordis 服务链,Node 24) | 已实测通过(尚未纳入 CI 矩阵) |
0.1.5-rc.1 |
>=22 <25,CI 覆盖 22/24 |
通过(真实 Cordis 服务链,Node 24) | 已声明、已验证 |
0.1.2-rc.1 |
>=22 <25 |
通过(实际使用验证,未纳入 CI) | 已实际验证兼容 |
0.1.1-rc.2 |
>=22 <25,CI 覆盖 22/24 |
通过(当前 Node 24) | 已声明、已验证 |
0.1.1-rc.1 |
>=22 <25,CI 覆盖 22/24 |
通过(当前 Node 24) | 已声明、已验证 |
| 其他版本 | >=22 <25 |
未测试 | 不在已验证矩阵内 |
未列出的 DSH 版本不代表一定不兼容;提交问题时请附 DSH、Node.js 和插件版本。
assistant/chunk 的 usage,没有最终 assistant/message;本插件会保留该 chunk 用量。同一 turn / step 后续出现最终 message 时,message 会替换 chunk。若上游完全没有 usage 事件,则无法从响应内容精确恢复 Token。domain/changed 探针自动同步:注册表一有改动就重读并只对新增/删除的工作区做增量处理,未变化的已有工作区直接复用已计算账本,不会全量重扫。会话尚未成功 flush 前删除或损坏的日志无法由独立账本恢复。工作区被删除时历史用量不会丢失:它会被保留并汇总为一行「已删除」。本插件展示的是 DSH 本地事件日志上的可重放统计,不是供应商账单的镜像:
assistant/chunk、最终 assistant/message 和其他会话事件,按同一 turn / step 去重和替换;官方账单可能按供应商自己的请求、分词器、舍入、折扣、免费额度和结算周期计算。下面的事件是脱敏的最小示例;完整可运行数据见 fixtures/usage-events.json。
[
{"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 100, "outputTokens": 20}}}},
{"type": "request/error", "data": {"code": "upstream-failed"}}
]
没有最终 assistant/message 时,chunk 仍计为一个本地调用;这不等于官方一定收费。
{"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 7, "cacheReadTokens": 8}}}}
缺少 request/context 或 request/header 时,Token 仍可统计,但模型身份显示为 Unknown;插件不会从 Provider 名称或展示字符串猜测模型。
{"inputTokens": 100, "outputTokens": 20, "cacheReadTokens": 40, "cacheWriteTokens": 5, "reasoningTokens": 3}
本地 processed total 为 100 + 20 + 40 + 5 + 3 = 168;成本只对 input、output、cacheRead、cacheWrite 四个桶定价,reasoning 不会再次加到 output。
使用仓库中的 fixture 复现:
node scripts/replay-fixture.mjs fixtures/usage-events.json
该命令会加载真实插件 Host、调用兼容 API、校验预期 Token/records,并输出不含敏感信息的摘要。
v1.1.10
sessionPersistence.listSnapshots() 改名为 list(),插件因此拿不到每会话 revision,sessionsSkippedByRevision 恒为 0、每次启动都重读全部会话日志(实测 479 个会话读了 431 个、约 13 分钟)。现在两种写法都支持,未变化的会话重新从账本复用。lastRevision 字段),此后启动走快路径。完整版本记录见 CHANGELOG.md。



本插件是标准的 DSH 社区插件包(声明 dsh.bundle manifest 与 Web Client),数据来自持久化会话日志和独立用量账本,安装后自动回填历史。
dsh plugin --profile web add github:ParticleLight/dsh-all-usage
安装命令会装配 bundle;随后刷新浏览器页面以加载 Client,无需手动修改 profile。若当前 DSH 版本未动态装配新包,请按 DSH 的提示重载包或重启进程。
把本目录放入任意位置,并在 $DSH_HOME/profiles/node_modules/ 下创建指向本目录的符号链接(Windows 用 junction):
New-Item -ItemType Junction -Path (Join-Path $env:DSH_HOME 'profiles/node_modules/dsh-all-usage') -Target '<本目录绝对路径>'
在 $DSH_HOME/profiles/web/cordis.patch.yml 添加一行:
- insert:
- id: all-usage
name: dsh-all-usage
用户 patch 层会被热重载:保存后刷新页面即可。
lib/index.js,组装 lib/plugin.js):按职责拆分为 aggregation.js(聚合与查询)、ledger.js(持久账本)、session-sync.js(历史/实时同步)、pricing-runtime.js(运行时定价)、balance.js(余额)、http.js(安全路由);扫描 turn/end、assistant/chunk usage 和最终 assistant/message.usage,监听 session/event 实时折叠,并通过 webServer 服务注册数据路由:GET /api/all-usage — 兼容统计快照GET /api/all-usage/status — 轻量 revision 与同步健康状态GET /api/all-usage/query — 按 scope 返回聚合、daily/hourly 趋势和 heatmap 数据;单日 scope 填充 hourly,跨日 scope 的 hourly 为空GET /api/all-usage/records — 按 scope 分页返回脱敏 canonical usage rowsGET /api/all-usage/balance?force=1 — 账户余额(复用 llm-deepseek 的 API Key 配置)POST /api/all-usage/alias — 设置工作区别名GET /api/all-usage/pricing — 查看 models.dev 同步状态、已用模型匹配和显式覆盖GET /api/all-usage/pricing/models?q=... — 检索官方模型 ID 与名称匹配结果POST /api/all-usage/pricing — 保存同步、mapping 和显式价格覆盖(含 context tier 档位)POST /api/all-usage/pricing/sync — 手动同步 models.dev 并回填未计价调用src/client.js,npm run build:client 使用固定版本 Terser 生成 window.__ModuleLoader__ 工厂格式的 lib/client.js 浏览器 bundle,并注册侧边栏「用量统计」入口(sidebar.footer.action 槽位)。所有 API 仅接受本机 loopback 请求并拒绝显式跨域请求;余额读取与别名写入还要求插件启动时生成、仅在当前进程有效的令牌(余额 GET 兼容浏览器省略 Origin)。英文模式的日期分桶、范围筛选、连续使用、热力图和导出时间统一按 UTC;中文模式按本地时区。session/flush 只在存在新的相关事件时重建并将派生账本写入异步队列,同一 session 的 pending record 会合并,插件退出时 drain;插件激活时会回填日志与账本历史,插件卸载/重启后已成功持久化的数据不丢turn / step 只保留一份最终 usage;重试或替换消息会替换旧贡献,不重复累计tiered 标志的旧 flat 成本会在加载升级时迁移为 unsupported(tiered-pricing-not-modeled),不再继续显示为当前精确 priced;Token 统计不受影响。identityKey 的 mapping 只对精确路由身份生效;不带身份键的 mapping 才按模型做全局回退;旧配置中的 usageIdentityKey 会在加载时归一化。/user/balance 接口;未配置 API Key 时卡片显示引导文案all_usage_ledger.json 会在首次加载时迁移,异步写失败或退出前未落盘不会丢失内存统计,只会让下次启动重新扫描src/client.js 后先运行 npm run build:client,再让 DSH 重载客户端模块并刷新页面;lib/client.js 是生成产物,不直接编辑。修改 lib/plugin.js 或其他 Host 模块后,需由 DSH 重载该包或重启进程v<package.version> tag 和完整 commit SHA,并在 checkout 后校验 tag、SHA 与包版本一致;Release 事件同样执行 commit 校验。A full usage dashboard for DeepSeek Harness. Analyze tokens, cache behavior, estimated cost, account balance, and activity by model, provider, workspace, and time range.
all_usage_aliasessessionPersistence.listSnapshots()) acts as a per-session change signal — sessions whose log is unchanged are applied from the ledger on restart without reading their events at all; only changed/new sessions are read incrementallydomain/changed event so the workspace registry stays fresh automatically — any durable registry write (create/delete/rename/reorder/archive/membership) triggers a reread of workspaceRegistry.list(), with only added/removed workspaces reprocessed incrementally while unchanged workspaces reuse their computed aggregates and ledger (zero rescan). Usage is strictly limited to registered workspaces: unregistered cwds, including existing directories absent from the registry, are ignored.>=22 <25 is required. CI runs the test suite, syntax checks, and package-content checks on Node 22 and Node 24.package.json declares DSH runtime >=0.1.1-rc.1 <0.1.5-0 || >=0.1.5-rc.1 <0.1.6-0; the real Cordis service chain is verified on 0.1.5-rc.2, 0.1.5-rc.1, 0.1.1-rc.2 and 0.1.1-rc.1. 0.1.2-rc.1 has also been verified compatible through real-world use, but is not covered by the CI smoke matrix. The declaration is split per tuple rather than written as one interval because node-semver only admits a prerelease version when some comparator shares its exact major.minor.patch tuple and itself carries a prerelease tag.webServer as a required dependency, so DSH waits for a late-mounted service before applying the plugin; this package targets the DSH Web profile and does not expose routes without WebServer. The HTTP guard also checks the actual socket peer, so a reverse proxy is accepted only when the connection itself is loopback.| DSH runtime | Node.js support | Real Cordis smoke | Conclusion |
|---|---|---|---|
0.1.5-rc.2 |
>=22 <25 |
Passed (real Cordis service chain, Node 24) | Verified locally (not yet in the CI matrix) |
0.1.5-rc.1 |
>=22 <25, CI covers 22/24 |
Passed (real Cordis service chain, Node 24) | Declared and verified |
0.1.2-rc.1 |
>=22 <25 |
Passed through real-world use (not in CI) | Verified compatible in real-world use |
0.1.1-rc.2 |
>=22 <25, CI covers 22/24 |
Passed (current Node 24) | Declared and verified |
0.1.1-rc.1 |
>=22 <25, CI covers 22/24 |
Passed (current Node 24) | Declared and verified |
| Other versions | >=22 <25 |
Not tested | Outside the verified matrix |
An unlisted DSH version is not necessarily incompatible. Include the DSH, Node.js, and plugin versions when reporting an issue.
assistant/chunk usage and never produce a final assistant/message; that chunk is retained. A later final message for the same turn/step replaces it. If the upstream emits no usage event at all, exact token usage cannot be reconstructed from response text.domain/changed probe: any durable workspace-domain write triggers a reread, and only added/removed workspaces are reprocessed incrementally — unchanged workspaces reuse their computed aggregates and ledger. Data deleted or corrupted before a successful session flush cannot be recovered from the separate ledger.This plugin reports replayable statistics from local DSH event logs; it is not a mirror of a provider invoice:
assistant/chunk, final assistant/message, and related session events, then deduplicate and replace samples by logical turn / step. Official billing may use a provider tokenizer, rounding rules, discounts, free quotas, and billing periods.The following are redacted minimal examples; the complete runnable data is in fixtures/usage-events.json.
[
{"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 100, "outputTokens": 20}}}},
{"type": "request/error", "data": {"code": "upstream-failed"}}
]
Without a final assistant/message, the chunk remains one local call; this does not mean the provider necessarily charged for it.
{"type": "assistant/chunk", "data": {"turn": 1, "step": 1, "chunk": {"type": "usage", "usage": {"inputTokens": 7, "cacheReadTokens": 8}}}}
Without request/context or request/header, tokens are still counted, but the model identity is shown as Unknown; the plugin does not guess a model from a provider name or display string.
{"inputTokens": 100, "outputTokens": 20, "cacheReadTokens": 40, "cacheWriteTokens": 5, "reasoningTokens": 3}
The local processed total is 100 + 20 + 40 + 5 + 3 = 168; cost uses the input, output, cacheRead, and cacheWrite buckets, and reasoning is not added to output again.
Replay the repository fixture:
node scripts/replay-fixture.mjs fixtures/usage-events.json
The command loads the real plugin Host, calls its compatible APIs, checks the documented token/record totals, and prints a non-sensitive summary.
v1.1.10
sessionPersistence.listSnapshots() to list(), so no per-session revision was ever obtained — sessionsSkippedByRevision stayed at 0 and every start re-read every session log (431 reads / ~13 minutes for 479 sessions). Both spellings are accepted now, and unchanged sessions are applied from the ledger again.lastRevision); later starts take the fast path.See CHANGELOG.md for the complete version history.
This is a standard DSH community bundle. It declares a dsh.bundle manifest and a web client, and backfills its data from persisted session logs and the durable usage ledger after installation.
dsh plugin --profile web add github:ParticleLight/dsh-all-usage
The installation command assembles the bundle. Refresh the browser page to load the client; no manual profile edits are required. If your DSH version does not dynamically assemble newly installed packages, use its supported package reload or restart the process.
Place this directory anywhere and create a symlink to it under $DSH_HOME/profiles/node_modules/ (use a junction on Windows):
New-Item -ItemType Junction -Path (Join-Path $env:DSH_HOME 'profiles/node_modules/dsh-all-usage') -Target '<absolute plugin path>'
Add this entry to $DSH_HOME/profiles/web/cordis.patch.yml:
- insert:
- id: all-usage
name: dsh-all-usage
The profile patch layer hot-reloads; save the file and refresh the page.
lib/index.js, assembled by lib/plugin.js): split by responsibility across aggregation.js (aggregation/query), ledger.js (durable ledger), session-sync.js (history/live sync), pricing-runtime.js (runtime pricing), balance.js (balance), and http.js (protected routes); aggregates turn/end, assistant/chunk usage, and final assistant/message.usage, folds live session/event updates, and exposes data routes through webServer:GET /api/all-usage — compatible usage snapshotGET /api/all-usage/status — lightweight revision and sync healthGET /api/all-usage/query — scoped aggregate, daily/hourly trend, and heatmap data; single-day scopes populate hourly, while cross-day scopes return an empty hourly arrayGET /api/all-usage/records — paginated privacy-safe canonical usage rowsGET /api/all-usage/balance?force=1 — account balance using the configured llm-deepseek API keyPOST /api/all-usage/alias — update workspace aliasesGET /api/all-usage/pricing — inspect models.dev sync status, used-model matches, and explicit overridesGET /api/all-usage/pricing/models?q=... — search official model IDs and display-name matchesPOST /api/all-usage/pricing — save sync, mappings, and explicit price overrides, including context-tier bandsPOST /api/all-usage/pricing/sync — sync models.dev and backfill unpriced callssrc/client.js; npm run build:client uses the pinned Terser version to generate the window.__ModuleLoader__ bundle at lib/client.js, which registers the “Usage statistics” sidebar entry through the sidebar.footer.action slot. All API routes accept loopback requests and reject an explicit cross-origin Origin; balance reads and alias writes also require a process-scoped token generated when the plugin starts (the balance GET tolerates browsers omitting Origin).session/flush rebuilds and queues the derived ledger only when related events are dirty, coalescing the latest pending record per session and draining on plugin disposal. Readable logs and ledger history are backfilled when the plugin activates, so successfully persisted data survives reloads or session deletion; deleting a workspace likewise keeps its history, summed into one "Deleted" row together with usage that had not reached the ledger yetturn / step, only the final usage contribution is kept; retries or replaced messages do not double-counttiered are migrated to unsupported (tiered-pricing-not-modeled) on load instead of remaining falsely marked as current flat priced estimates; token statistics are unchanged.identityKey applies only to that exact route identity; a mapping without an identity key is the model-wide fallback. Legacy usageIdentityKey values are normalized when loaded./user/balance endpoint; the card shows guidance when no API key is configuredall_usage_ledger.json is migrated on first load. An async write failure or an unflushed shutdown does not lose in-memory statistics; the next startup simply scans that session againsrc/client.js, run npm run build:client, reload the DSH client module, and refresh the page; lib/client.js is generated and should not be edited directly. After editing lib/plugin.js or another Host module, reload the package through DSH or restart the processv<package.version> tag and full commit SHA; GitHub Actions checks both against the checked-out tag and package version. Release events perform the same commit check.MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: csv-export、token-usage。