Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .zcode/rules/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- 差异化卖点=上下文占比 + 中英双语 + 首屏截图三条守住,不拼竞品功能清单。
- 逐问速率行的标签(`token_rate.py format_turn_line`)不分语言恒中文(硬编码无 locale 分支,英文宣传图里速率行是手写演示文案,已知产品限制);`overlay.js` 自身 `L()` 双语可在布景页 `localStorage.setItem("zusage3.lang","en")` 取真实英文文案,不手写翻译。
- 市场条目保留 `description_i18n`;门面显示名「速度状态栏」与市场 UI 显示的 slug 派生名("ZCode Token Usage Statusbar")不一致**刻意保留**——slug、市场名、命令、配置键、仓库/安装指引里的英文名都不擅改(受插件市场 UI 名约束,真改是破坏性工程)。README 安装指引中的英文名是市场实际显示名,不能翻译。
- **README 安装文案必须自包含**(`tests/test_install_prompt_contract.py` 锁定):宿主不提供单独的 `zcode` 命令,也不给代理任何「怎么装插件」的指引(引擎里没有面向模型的添加市场说明,`SearchPlugins`/`SuggestPluginInstall` 只覆盖官方市场,本插件不在其中),代理只能靠文案本身。只给地址、或只说「执行 /install-overlay」时,代理得自己摸索调用方式(插件刚装好时当前会话里还没有这条命令)。文案须写明:命令行调用方式(`ELECTRON_RUN_AS_NODE=1` + ZCode 可执行文件 + `resources/glm/zcode.cjs`)、两条 `plugins` 子命令及 `--json`、GitHub 失败自动换带 `.git` 的 GitCode 地址、安装器脚本的调用路径(`installPath` 取自安装输出)、完全退出的重启措辞与失败时原样转述。改文案里的命令后跑 `python3 -B tests/install-prompt-smoke.py`(macOS,联网)确认全新环境仍装得上;这三步之外不要塞进与安装无关的内容。
- GitHub 默认仓库搜索只匹配 name+description+topics(README 需 `in:readme`)——辨识度关键词写 Description/Topics 而非正文堆同义词;topics ≤20、仅小写字母数字连字符、≤50 字符、不加竞品名不凑满。远端写入(Description/Topics/README)后 `gh api` 回读确认。

## 3. 宣传图与 tour 截图(docs/promo、docs/tour)
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ python3 sync_plugin.py --check
| 桥/SSH 路由 | `test_renderer_bridge.py`、`test_bridge_pending.py`、`test_remote_targets.py`、`test_serve_stdio.py`、`inject-remote-recovery.test.cjs`、`overlay-remote-scope.test.cjs`;实机身份/重连与认证另验 |
| 安装/更新/锁/解包 | `test_install_discovery.py`、`test_plugin_sudo_install.py`、`test_pending_asar.py`、`test_quiet_monitor.py`、`test_pending_zip_patch.py`、`test_config_transactions.py`、`test_plugin_upgrade.py`、`test_runtime_sync_guard.py`、`test_release*.py` 及 `plugin-*.test.cjs`、`runtime-lock.test.cjs`、`test_runtime_lock_windows.py` |
| 插件命令/hooks/MCP | `test_command_frontmatter.py`、`test_plugin_contract.py`、`test_usage_mcp_stdio.py`(MCP 直启的 stdio 帧契约)、`test_plugin_package.py`、`test_plugin_runtime.py`、`test_session_start_channels.py`、`test_restart_notice.py`、`test_zusage_doctor.py`(体检命令)、`test_test_file_layout.py`(测试文件布局契约,新增测试文件后必跑);共享文件同时同步并检查漂移 |
| 文档/本地化 | 路径、相对链接/锚点、JSON 示例、双语对应与 manifest 一致性;涉及默认值/协议时加对应契约测试 |
| 文档/本地化 | 路径、相对链接/锚点、JSON 示例、双语对应与 manifest 一致性;涉及默认值/协议时加对应契约测试;README 安装文案的自包含契约见 `test_install_prompt_contract.py`(文案里的命令须与 `install-prompt-smoke.py` 实跑的一致) |

宿主真实 CLI 沙箱测试和交互演示见 [测试说明](tests/README.md)。它们使用真实 ZCode、认证和模型,可能联网/消耗 token,不属于默认纯隔离测试;测试对象必须指向自有临时 HOME、插件库存与夹具。
真实桌面安装会改客户端文件;默认回归不得接触个人数据库、配置、真实插件库存或客户端。语法通过、手工 hook 成功、Windows 收尾夹具通过均不能替代自然 SessionStart/重启/多窗口/远端实机证据。
Expand Down
18 changes: 12 additions & 6 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ Promotional image with staged UI and demonstration data; the actual interface va

### Installation

Send this to ZCode to install or update the plugin (when GitHub is unreachable it retries through the mirror on its own, so you do not have to send anything again):
Send this to ZCode to install or update the plugin. The message spells out every command, so ZCode does not have to work out how to install on its own; when GitHub is unreachable it retries through the mirror by itself, so you do not have to send anything again:

```text
Please install or update and enable this ZCode plugin: https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases
If GitHub is unreachable, retry with https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode on your own; do not ask me again.
Then run /install-overlay in the ZCode chat. Once you confirm the status bar installation succeeded, remind me to quit ZCode completely and reopen it (closing the window is not enough); do not restart it automatically.
If installation fails, explain why. If you cannot run the command in the current session, ask me to run it manually; do not skip this step or claim installation succeeded.
Please install or update the ZCode plugin zcode-token-usage-statusbar. Follow the three steps below exactly and do not look for another installation method:

1. Add the marketplace and install the plugin with ZCode's own command line. There is no separate zcode command: set the environment variable ELECTRON_RUN_AS_NODE=1, run the ZCode executable, and pass resources/glm/zcode.cjs from the installation directory as its first argument. On macOS the defaults are /Applications/ZCode.app/Contents/MacOS/ZCode and /Applications/ZCode.app/Contents/Resources/glm/zcode.cjs. On Windows ZCode.exe and resources\glm\zcode.cjs sit in the same installation directory; when it is not in the default location, find the running ZCode.exe with (Get-Process ZCode).Path in PowerShell. Run these two commands in that command line, in order:
plugins marketplace add "https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases" --json
plugins install "zcode-token-usage-statusbar@zusage-marketplace" --scope user --json
If the first one fails (usually because GitHub is unreachable), retry with the address https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode instead; do not ask me again.
2. Run python3 "<installPath from the second command's output in step 1>/overlay_install.py" install (on Windows, if python3 is unavailable, try python and then py -3).
3. Report step 2's output to me: when it asks for a restart, remind me to quit ZCode completely (from the menu or the tray; closing the window is not enough) and reopen it; do not restart it automatically.

If any step fails, relay the error as is; do not skip it and do not claim installation succeeded.
```

Keep `#plugin-releases` and `.git#plugin-releases-gitcode` in the URLs: they select the project's stable release channels. The mirror route needs local [Git](https://git-scm.com/downloads) (the host fetches the channel manifest through git), and the `.git` suffix cannot be dropped: the host treats only URLs ending in `.git` as repository sources and would otherwise download the page as if it were the manifest.
Keep `#plugin-releases` and `.git#plugin-releases-gitcode` in the URLs: they select the project's stable release channels. The mirror route needs local [Git](https://git-scm.com/downloads), and the `.git` suffix cannot be dropped: the host treats only URLs ending in `.git` as repository sources and would otherwise download the page as if it were the manifest.

> **Important:** installing the bar modifies ZCode's program files (`app.asar`), so proceed only if you trust the project. **After the first successful injection, quit ZCode completely and reopen it** (closing the window or reopening a session is not enough), then check that the bar appears. If installation fails or permissions are insufficient, diagnose that first; restarting does not replace installation.

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ A community toolkit for ZCode desktop: generation speed, token usage, context tr

### 安装方法

把下面这段话发给 ZCode,安装或更新插件(GitHub 连不上时,它会自动改用国内源重试,不用你再发一次):
把下面这段话发给 ZCode,安装或更新插件。文案把要执行的命令都写明了,ZCode 不需要自己摸索安装方式;GitHub 连不上时它会自动改用国内源重试,不用你再发一次:

```text
请安装或更新并启用 ZCode 插件:https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases
GitHub 连不上时,自动改用 https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode 重试,不用再问我。
完成后,在 ZCode 对话中执行 /install-overlay;确认状态条安装成功后,提醒我完全退出并重新打开 ZCode(仅关闭窗口不算),不要自动重启。
若安装失败,请说明原因;若当前会话无法执行该命令,请提示我手动执行,不要跳过这一步或声称安装成功。
请安装或更新 ZCode 插件 zcode-token-usage-statusbar,严格按下面三步做,不要另找安装方式:

1. 用 ZCode 自带的命令行添加市场并安装插件。调用方法:先设置环境变量 ELECTRON_RUN_AS_NODE=1,再运行 ZCode 的可执行文件,把安装目录里的 resources/glm/zcode.cjs 作为第一个参数。macOS 默认是 /Applications/ZCode.app/Contents/MacOS/ZCode 和 /Applications/ZCode.app/Contents/Resources/glm/zcode.cjs;Windows 上 ZCode.exe 与 resources\glm\zcode.cjs 在同一个安装目录,位置不固定时用 PowerShell 的 (Get-Process ZCode).Path 查到正在运行的 ZCode.exe。在这个命令行里依次执行:
plugins marketplace add "https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases" --json
plugins install "zcode-token-usage-statusbar@zusage-marketplace" --scope user --json
第一条失败时(多半是 GitHub 连不上),把地址换成 https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode 重试,不用再问我。
2. 运行 python3 "<第 1 步第二条命令输出里的 installPath>/overlay_install.py" install(Windows 上 python3 不可用就依次换 python、py -3)。
3. 按第 2 步的输出提醒我:出现重启提醒时,提醒我完全退出 ZCode(从菜单或托盘退出,只关窗口不算)再重新打开;不要自动重启。

任何一步失败都原样转述错误,不要跳过,也不要声称安装成功。
```

保留地址里的 `#plugin-releases` 与 `.git#plugin-releases-gitcode`,它们选择正式发布的稳定渠道。国内源要求本机装有 [Git](https://git-scm.com/downloads)(宿主通过 git 拉取渠道清单),而且地址里的 `.git` 不能省:宿主只把以 `.git` 结尾的地址当作仓库来源,否则会把它当成清单文件的直链去下载。
两个地址里的 `#plugin-releases` 与 `.git#plugin-releases-gitcode` 选择正式发布的稳定渠道,保持原样。国内源要求本机装有 [Git](https://git-scm.com/downloads),而且地址里的 `.git` 不能省:宿主只把以 `.git` 结尾的地址当作仓库来源,否则会把它当成清单文件的直链去下载。

> **注意**:状态条安装会修改 ZCode 的程序文件(`app.asar`),请先确认信任本项目。**首次注入成功后,须完全退出并重开 ZCode**(仅关闭窗口或重开会话不算),再检查状态条是否出现;安装失败或权限不足时,先排查原因,重启不能替代安装。

Expand Down
18 changes: 12 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ A community toolkit for ZCode desktop: generation speed, token usage, context tr

### 安装方法

把下面这段话发给 ZCode,安装或更新插件(GitHub 连不上时,它会自动改用国内源重试,不用你再发一次):
把下面这段话发给 ZCode,安装或更新插件。文案把要执行的命令都写明了,ZCode 不需要自己摸索安装方式;GitHub 连不上时它会自动改用国内源重试,不用你再发一次:

```text
请安装或更新并启用 ZCode 插件:https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases
GitHub 连不上时,自动改用 https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode 重试,不用再问我。
完成后,在 ZCode 对话中执行 /install-overlay;确认状态条安装成功后,提醒我完全退出并重新打开 ZCode(仅关闭窗口不算),不要自动重启。
若安装失败,请说明原因;若当前会话无法执行该命令,请提示我手动执行,不要跳过这一步或声称安装成功。
请安装或更新 ZCode 插件 zcode-token-usage-statusbar,严格按下面三步做,不要另找安装方式:

1. 用 ZCode 自带的命令行添加市场并安装插件。调用方法:先设置环境变量 ELECTRON_RUN_AS_NODE=1,再运行 ZCode 的可执行文件,把安装目录里的 resources/glm/zcode.cjs 作为第一个参数。macOS 默认是 /Applications/ZCode.app/Contents/MacOS/ZCode 和 /Applications/ZCode.app/Contents/Resources/glm/zcode.cjs;Windows 上 ZCode.exe 与 resources\glm\zcode.cjs 在同一个安装目录,位置不固定时用 PowerShell 的 (Get-Process ZCode).Path 查到正在运行的 ZCode.exe。在这个命令行里依次执行:
plugins marketplace add "https://github.com/ByteRax/zcode-token-usage-statusbar#plugin-releases" --json
plugins install "zcode-token-usage-statusbar@zusage-marketplace" --scope user --json
第一条失败时(多半是 GitHub 连不上),把地址换成 https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gitcode 重试,不用再问我。
2. 运行 python3 "<第 1 步第二条命令输出里的 installPath>/overlay_install.py" install(Windows 上 python3 不可用就依次换 python、py -3)。
3. 按第 2 步的输出提醒我:出现重启提醒时,提醒我完全退出 ZCode(从菜单或托盘退出,只关窗口不算)再重新打开;不要自动重启。

任何一步失败都原样转述错误,不要跳过,也不要声称安装成功。
```

保留地址里的 `#plugin-releases` 与 `.git#plugin-releases-gitcode`,它们选择正式发布的稳定渠道。国内源要求本机装有 [Git](https://git-scm.com/downloads)(宿主通过 git 拉取渠道清单),而且地址里的 `.git` 不能省:宿主只把以 `.git` 结尾的地址当作仓库来源,否则会把它当成清单文件的直链去下载。
两个地址里的 `#plugin-releases` 与 `.git#plugin-releases-gitcode` 选择正式发布的稳定渠道,保持原样。国内源要求本机装有 [Git](https://git-scm.com/downloads),而且地址里的 `.git` 不能省:宿主只把以 `.git` 结尾的地址当作仓库来源,否则会把它当成清单文件的直链去下载。

> **注意**:状态条安装会修改 ZCode 的程序文件(`app.asar`),请先确认信任本项目。**首次注入成功后,须完全退出并重开 ZCode**(仅关闭窗口或重开会话不算),再检查状态条是否出现;安装失败或权限不足时,先排查原因,重启不能替代安装。

Expand Down
10 changes: 10 additions & 0 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ https://gitcode.com/tanranran/zcode-token-usage-statusbar.git#plugin-releases-gi

此渠道从经过校验的正式 Release ZIP 安装插件,不跟随开发分支,也不需要自己下载源码。当前正式版自动安装/修复状态条(始终开启,旧自动安装开关配置只保留不再读取);成功后完全退出并重开;不需要状态条时用 `/uninstall-overlay` 移除并阻止自动重注入。

### 对话安装时实际执行的步骤

README 的安装文案把命令写明了,ZCode 不必自己摸索。想手动走同一条路,或排查看它卡在哪一步时,步骤如下:

1. 添加市场并安装插件:设置环境变量 `ELECTRON_RUN_AS_NODE=1`,运行 ZCode 的可执行文件并把安装目录里的 `resources/glm/zcode.cjs` 作为第一个参数,依次执行 `plugins marketplace add "<渠道地址>" --json` 和 `plugins install "zcode-token-usage-statusbar@zusage-marketplace" --scope user --json`。已装用户重复执行第一条就是刷新市场。
2. 运行 `python3 "<上一步输出里的 installPath>/overlay_install.py" install`。插件刚装好时当前会话里还没有 `/install-overlay` 命令,所以这一步直接运行脚本。
3. 完全退出 ZCode 后重新打开。

国内源地址必须带 `.git`:宿主只把以 `.git` 结尾的地址当作仓库来源,否则会把它当成清单文件的直链去下载。

### 方式二:本地目录安装

从 [ByteRax 仓库](https://github.com/ByteRax/zcode-token-usage-statusbar) 下载或克隆源码后:
Expand Down
10 changes: 10 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ python3 -B tests/plugin-commands-cli-smoke.py

`plugin-commands-cli-smoke.py` 使用真实客户端 CLI 和临时 bundle 副本,验证三个裸名命令的 list/inspect、实际协议命令目录与纯文本参数展开,旧插件前缀名明确 not-found;还验证旧聊天安装/更新子命令只返回 Usage,以及短 MCP 服务键对应的模型工具名。只复制清单、命令和被测分派代码,不复制或运行 hook/安装器;不启动模型、NDJSON 会话或 UI,因此不是界面端到端测试。bundle 结构改变时会明确失败,不退回模拟实现。

## 安装文案冒烟(macOS,联网)

```bash
python3 -B tests/install-prompt-smoke.py github # 或 gitcode
```

需要已安装 `/Applications/ZCode.app`、macOS 自带 `sandbox-exec` 和网络。脚本在临时目录里模拟一台全新机器(独立 HOME;真实 HOME、仓库与任何 asar 不可读,临时目录外不可写,执行前先用探针证明隔离成立),按 README 安装文案里的命令原样走一遍:添加市场、安装插件、运行安装器,最后核对插件登记与状态条注入,并输出每一步的耗时。状态条注入打到临时目录里的假归档上,不触碰真实客户端。不调用模型、不读取凭据;它量的是「代理照做即可」的确定性部分,代理自己摸索的时间不在其中。

文案与脚本的一致性由默认回归 `test_install_prompt_contract.py` 锁定:三份 README 的安装文案必须包含脚本实跑的每一条命令。改动文案里的命令后,先跑本脚本确认在全新环境里仍然装得上。

## 速度格实机量宽探针

```bash
Expand Down
Loading