opencode-usage-limits 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.en.md CHANGED
@@ -6,6 +6,34 @@ All notable changes to `usage-limits` are documented here. The format is based o
6
6
 
7
7
  [简体中文](./CHANGELOG.md) · [English](./CHANGELOG.en.md)
8
8
 
9
+ ## 0.3.2 - 2026-11-05
10
+
11
+ ### Fixed
12
+
13
+ - **The plugin failed to load entirely when installed from npm**
14
+ ([#2](https://github.com/GamingNowEdward/opencode-usage-limits/issues/2)): 0.3.1 shipped raw `.tsx`
15
+ source, but OpenCode only runs its own Solid Babel transform on plugin files that live **outside**
16
+ `node_modules`. In an npm-installed plugin directory the source is transpiled by Bun alone, which
17
+ injects an `@opentui/solid/jsx-dev-runtime` import from the `@jsxImportSource` pragma. That injection
18
+ happens *after* the host rewrote the source imports, so it falls back to Bun's native resolution —
19
+ and `@opentui/solid` is an optional peer that npm never installs. The result was a `stage=load`
20
+ failure: no sidebar block and no entry in the plugin list. The package now ships **compiled output**:
21
+ `tui.tsx` is compiled with `babel-preset-solid { generate: "universal", moduleName: "@opentui/solid" }`
22
+ and bundled into `dist/tui.js`, which `exports["./tui"]` points at. The artifact only contains explicit
23
+ `@opentui/solid` / `solid-js` / `@opencode/plugin/tui` imports, which the host rewrites to its own runtime.
24
+
25
+ ### Changed
26
+
27
+ - Added `scripts/build.mjs` (`npm run build`; `npm run dev` watches), run automatically before publishing
28
+ through `prepack`.
29
+ - The published package no longer contains `tui.tsx` / `tui.ts` / `core.ts`, only `dist/tui.js` and
30
+ `index.ts`. The `.tsx` source stays in the repository for local development.
31
+
32
+ ### Thanks
33
+
34
+ - Thanks to [@third774](https://github.com/third774) for reporting the problem, pinpointing the injected
35
+ JSX runtime path, and verifying the compiled-output approach — 0.3.2 adopts that option.
36
+
9
37
  ## 0.3.1 - 2026-10-26
10
38
 
11
39
  ### Fixed
package/CHANGELOG.md CHANGED
@@ -4,6 +4,30 @@
4
4
 
5
5
  [简体中文](./CHANGELOG.md) · [English](./CHANGELOG.en.md)
6
6
 
7
+ ## 0.3.2 - 2026-11-05
8
+
9
+ ### 修复
10
+
11
+ - **npm 安装后插件完全无法加载**([#2](https://github.com/GamingNowEdward/opencode-usage-limits/issues/2)):
12
+ 0.3.1 直接发布 `.tsx` 源码,而 OpenCode 只对 **node_modules 之外**的插件文件运行自带的 Solid
13
+ Babel 转换。npm 安装的插件目录里,源码由 Bun 自行转译,会按 `@jsxImportSource` 注入
14
+ `@opentui/solid/jsx-dev-runtime` 导入;该注入发生在宿主重写 import 之后,于是回到 Bun 原生解析,
15
+ 而 `@opentui/solid` 是可选 peer、npm 不会安装,最终 `stage=load` 失败,侧边栏不出现、插件列表也没有条目。
16
+ 现在改为**发布编译产物**:`tui.tsx` 经 `babel-preset-solid { generate: "universal",
17
+ moduleName: "@opentui/solid" }` 编译并打包为 `dist/tui.js`,`exports["./tui"]` 指向该文件。
18
+ 产物中只有显式的 `@opentui/solid` / `solid-js` / `@opencode/plugin/tui` 导入,宿主可以正常重写到自己的运行时。
19
+
20
+ ### 变更
21
+
22
+ - 新增构建脚本 `scripts/build.mjs`(`npm run build`;`npm run dev` 为监听模式),发布前由 `prepack` 自动执行。
23
+ - 发布包不再包含 `tui.tsx` / `tui.ts` / `core.ts`,仅包含 `dist/tui.js` 与 `index.ts`。
24
+ 仓库内仍保留 `.tsx` 源码,供本地开发使用。
25
+
26
+ ### 致谢
27
+
28
+ - 感谢 [@third774](https://github.com/third774) 报告该问题、定位到 JSX 运行时注入路径,并先行
29
+ 验证了「发布编译产物」这一方案;0.3.2 采用的是该方案。
30
+
7
31
  ## 0.3.1 - 2026-10-26
8
32
 
9
33
  ### 修复
package/README.en.md CHANGED
@@ -17,15 +17,17 @@ the percentage, a progress bar and the reset countdown for three rolling windows
17
17
  ▾ USAGE · OpenCode Go
18
18
  5 hours 0%
19
19
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
20
- ↻ 5h $0.00 / $12.00
20
+ ↻ 5h
21
21
 
22
22
  Weekly 1%
23
23
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
24
- ↻ 6d 4h $0.30 / $30.00
24
+ ↻ 6d 4h
25
25
 
26
26
  Monthly 60%
27
27
  ███████████████████░░░░░░░░░░░░░░░░░
28
- ↻ 7d 14h $36.00 / $60.00
28
+ ↻ 7d 14h
29
+
30
+ deepseek-v4.1-flash $80/$160
29
31
  ```
30
32
 
31
33
  ## Features
@@ -127,14 +129,22 @@ and needs no key at all.
127
129
 
128
130
  | File | Purpose |
129
131
  | --- | --- |
130
- | [`tui.tsx`](./tui.tsx) | The TUI plugin itself |
132
+ | [`tui.tsx`](./tui.tsx) | The TUI plugin itself (JSX source) |
131
133
  | [`core.ts`](./core.ts) | Auth, API client, formatting, thresholds (pure logic, no JSX) |
132
134
  | [`index.ts`](./index.ts) | Server entrypoint (no-op) |
133
- | [`tui.ts`](./tui.ts) | Discovery entrypoint, re-exports `tui.tsx` |
135
+ | [`tui.ts`](./tui.ts) | Local-development discovery entry, re-exports `tui.tsx` |
136
+ | [`dist/tui.js`](./dist/tui.js) | **Published artifact**: `tui.tsx` compiled and bundled (`exports["./tui"]` points here) |
137
+ | [`scripts/build.mjs`](./scripts/build.mjs) | Build script (babel-preset-solid + esbuild) |
134
138
  | [`preview.mjs`](./preview.mjs) | Offline preview script |
135
139
  | [`AGENTS.md`](./AGENTS.md) | Development conventions |
136
140
  | [`CHANGELOG.md`](./CHANGELOG.md) | Changelog |
137
141
 
142
+ > Why the package ships compiled output: OpenCode only applies its Solid JSX transform to plugin files
143
+ > **outside** `node_modules`. Shipping raw `.tsx` meant Bun transpiled the plugin on the user's machine,
144
+ > injecting an unresolvable `@opentui/solid/jsx-dev-runtime` import, so the plugin failed at load time
145
+ > (see [#2](https://github.com/GamingNowEdward/opencode-usage-limits/issues/2)). After editing `tui.tsx`,
146
+ > run `npm run build` and commit `dist/tui.js`.
147
+
138
148
  ## Offline preview
139
149
 
140
150
  Verify the API and layout without starting the TUI (it reads your real local key):
@@ -147,8 +157,12 @@ node preview.mjs cline-pass # a single source
147
157
  ## Troubleshooting
148
158
 
149
159
  1. Make sure the current model belongs to `opencode-go` or `cline-pass`.
150
- 2. Plugin files **hot reload on save** — no restart needed. Only adding or removing an imported file requires restarting the TUI.
160
+ 2. When developing from a local directory, plugin files **hot reload on save**, but the bundle must be
161
+ rebuilt first: run `npm run dev` to watch the source and update `dist/tui.js`. The host loads that
162
+ artifact, not `tui.tsx`.
151
163
  3. Check the log: `~/.local/share/opencode/log/opencode.log`, filter by `role=cli` and `plugin`.
164
+ A `stage=load` failure mentioning `Cannot find package '@opentui/solid'` means you are on 0.3.1 or
165
+ earlier; upgrading to 0.3.2+ fixes it (see the [CHANGELOG](./CHANGELOG.en.md)).
152
166
  4. If the panel shows **API key not found**, check the login first:
153
167
 
154
168
  ```sh
package/README.md CHANGED
@@ -17,15 +17,17 @@
17
17
  ▾ USAGE · OpenCode Go
18
18
  5 hours 0%
19
19
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
20
- ↻ 5h $0.00 / $12.00
20
+ ↻ 5h
21
21
 
22
22
  Weekly 1%
23
23
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
24
- ↻ 6d 4h $0.30 / $30.00
24
+ ↻ 6d 4h
25
25
 
26
26
  Monthly 60%
27
27
  ███████████████████░░░░░░░░░░░░░░░░░
28
- ↻ 7d 14h $36.00 / $60.00
28
+ ↻ 7d 14h
29
+
30
+ deepseek-v4.1-flash $80/$160
29
31
  ```
30
32
 
31
33
  ## 功能
@@ -121,14 +123,21 @@ CLI 插件在本地 TUI 进程内运行,因此可以调用 OpenCode 的凭据
121
123
 
122
124
  | 文件 | 说明 |
123
125
  | --- | --- |
124
- | [`tui.tsx`](./tui.tsx) | TUI 插件主体 |
126
+ | [`tui.tsx`](./tui.tsx) | TUI 插件主体(JSX 源码) |
125
127
  | [`core.ts`](./core.ts) | 鉴权、API 客户端、格式化、阈值(纯逻辑,无 JSX) |
126
128
  | [`index.ts`](./index.ts) | server 入口(no-op) |
127
- | [`tui.ts`](./tui.ts) | 发现入口,re-export `tui.tsx` |
129
+ | [`tui.ts`](./tui.ts) | 本地开发用的发现入口,re-export `tui.tsx` |
130
+ | [`dist/tui.js`](./dist/tui.js) | **发布产物**:`tui.tsx` 编译打包后的入口(`exports["./tui"]` 指向它) |
131
+ | [`scripts/build.mjs`](./scripts/build.mjs) | 构建脚本(babel-preset-solid + esbuild) |
128
132
  | [`preview.mjs`](./preview.mjs) | 离线预览脚本 |
129
133
  | [`AGENTS.md`](./AGENTS.md) | 开发约定 |
130
134
  | [`CHANGELOG.md`](./CHANGELOG.md) | 变更日志 |
131
135
 
136
+ > 为什么发布编译产物:OpenCode 只对 `node_modules` **之外**的插件文件应用自带的 Solid JSX 转换。
137
+ > 若直接发布 `.tsx`,npm 安装后由 Bun 自行转译,会注入无法解析的 `@opentui/solid/jsx-dev-runtime`
138
+ > 导入,插件在加载阶段即失败(见 [#2](https://github.com/GamingNowEdward/opencode-usage-limits/issues/2))。
139
+ > 修改 `tui.tsx` 后请运行 `npm run build` 并提交 `dist/tui.js`。
140
+
132
141
  ## 离线预览
133
142
 
134
143
  无需启动 TUI 即可验证接口与排版(会读取你本机的真实密钥):
@@ -141,8 +150,11 @@ node preview.mjs cline-pass # 只预览一个
141
150
  ## 排障
142
151
 
143
152
  1. 确认当前模型属于 `opencode-go` 或 `cline-pass`。
144
- 2. 插件文件**保存即热重载**,无需重启;只有新增/删除被 import 的文件时才需退出 TUI 重进。
153
+ 2. 从本地目录开发时,插件文件**保存即热重载**,但需要先重建产物:`npm run dev` 监听源码并更新
154
+ `dist/tui.js`;宿主加载的是该产物,不是 `tui.tsx`。
145
155
  3. 查看日志:`~/.local/share/opencode/log/opencode.log`,筛 `role=cli` 与 `plugin`。
156
+ 若出现 `stage=load` 且报 `Cannot find package '@opentui/solid'`,说明装到了 0.3.1 或更早版本,
157
+ 升级到 0.3.2+ 即可(详见 [CHANGELOG](./CHANGELOG.md))。
146
158
  4. 面板显示 **API key not found** 时,先确认登录状态:
147
159
 
148
160
  ```sh