Repository navigation
feat(session-stats): add session statistics plugin - #147
huantest2024 wants to merge 13 commits into
Conversation
|
❌ Internal validation failed: Please fix it and push again; the check re-runs automatically. 🤖 Copy this prompt into Claude Code / Codex to fix it |
|
❌ Internal validation failed: Please fix it and push again; the check re-runs automatically. 🤖 Copy this prompt into Claude Code / Codex to fix it |
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
…stent modes, popup self-heal)
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
Plugin type (required) / 插件类型(必填)
ui.surfaces会话侧栏面板)Affected plugin name(s) / 涉及插件:session-stats
What / 改动内容
Adds a new community plugin session-stats (v0.2.7) under
external_plugins/:session statistics for ZCode — turns/steps, model vs tool time, TTFT, TPS (average +
latest-request), token usage, cache hit ratio and per-model breakdown. Components:
MCP tool
get_stats+ MCP Apps side panel (ui.surfaces) +/statscommand +SessionStart hook. Source of truth: https://github.com/huantest2024/zcode-session-stats
Why / 解决什么问题
ZCode 的用量事实已经在本地会话数据库里(
model_usage/turn_usage/tool_usage,含
time_to_first_token_ms与四类 token 计数),缺的只是面向用户的呈现层。本插件零第三方依赖(stdio MCP 服务器为 Python 标准库实现),只读打开数据库,不写任何宿主状态。
How tested / 如何验证
data-session-id+ SessionStart hook,线上实测
session_source=hook链路成立)。scripts/validate.py的规则自检:kebab-case、source 路径约定、manifest↔marketplace版本/描述一致、ui.surfaces 各项(id/server/resourceUri/availability)、i18n en+zh、无符号链接。
Version / 版本与登记
./external_plugins/session-stats(社区插件约定路径)。server/pills.js是面板/输入条统计组件的动态下发副本,随插件版本走。Dependencies & side effects / 依赖与副作用
~/.zcode/cli/db/db.sqlite(mode=ro + busy_timeout,WAL 并发安全)。127.0.0.1:31710:向 ZCode 渲染层(file:// 页面)提供统计 JSON与面板脚本,仅响应无跨域 Origin 的请求,其余 403。
License / 许可
MIT;无第三方代码/资源引入。