Repository navigation
Conversation
- publisher/name/version/urls 全部切到 huanglune - LICENSE 雙署名保留原作者 - 6 份 README 加社群分支橫幅與新的 Marketplace + Open VSX 連結
…il + IO 層) 含 18 個單元測試覆蓋三個純函數: - validateModelPricing:schema + 價格 sanity bound - filterClaudeModels:只保留 claude- / anthropic/claude- / anthropic.claude- - sanityCheckAgainstPrevious:10x 跳變 + 旧模型消失檢測
- 提升 fetch 超时到 30 秒(LiteLLM 大 JSON 本地拉取需要 11 秒左右) - 加 HTTP(S)_PROXY 环境变量支持(本地走公司代理场景) - 新增 undici devDep(Node 内置但需显式 import) - _meta.source_commit: 26fcbc93
- 启动时从 src/pricing-data.json(bundle)同步加载,零延迟 - initPricing(context) 叠加 globalStorage 里上次 fetch 的 overlay - 背景 fetch LiteLLM 刷新缓存供下次启动用;pricingOfflineMode 可关 - tiered 计费支持 200k 阈值(Claude 4+ 的 1M context 分档) - 家族 fallback:opus/haiku/sonnet 未知变体走最新版 - vscode 改为动态 import,测试可在纯 Node 下跑 - 新增 src/pricing.test.ts 共 10 个测试
- activate() 变 async,await initPricing(context) 后再 new ClaudeCodeUsageExtension - 新增 claudeCodeUsage.pricingOfflineMode 配置项(默认 false) 打开后跳过运行时 LiteLLM fetch,只用打包的 snapshot
- ci.yml:PR/main push 跑 tsc --noEmit + npm test + vsce package 验证 - update-pricing.yml:每周一 03:00 UTC 同步 LiteLLM;guardrail 过就 auto-commit+push - release.yml:push tag v* 触发,发 VS Marketplace + Open VSX + GitHub release - README-en.md 加 Maintainer Setup 说明两个所需 secret(VSCE_PAT / OVSX_PAT)
CI 用 Node 20.20.2,但 npm 默认装的 undici@7 要求 Node 22+ 的
webidl.util.markAsUncloneable。CI 没 proxy 根本不需要 undici,
所以:
- 静态 import 改成 proxy 路径里的 await import('undici')
- 版本 pin 到 ^6(Node 20 兼容线)双保险
- CI 测试启动时不再加载 undici,彻底避开该 API 差异
There was a problem hiding this comment.
Pull request overview
This PR modernizes the extension’s pricing system by moving to a bundled pricing snapshot (auto-refreshed from LiteLLM) with optional runtime refresh, and adds CI/release automation plus documentation updates for the community-maintained fork.
Changes:
- Replace hardcoded model pricing with a bundled
pricing-data.jsonsnapshot, runtime cache overlay, and optional background refresh. - Add build/test tooling and GitHub Actions workflows for CI, scheduled pricing snapshot updates, and tagged releases.
- Update extension/package metadata and READMEs to reflect the community fork and new distribution links.
Reviewed changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Excludes tests/scripts from extension compilation output. |
| src/types.ts | Extends pricing types (tiered pricing + context limits) and adds PricingSnapshot. |
| src/pricing.ts | New snapshot-backed pricing loader, runtime cache, background refresh, tiered cost calc, and fallback logic. |
| src/pricing.test.ts | Adds unit tests for pricing lookup and tiered cost calculations. |
| src/pricing-data.json | Adds the bundled LiteLLM-derived pricing snapshot. |
| src/extension.ts | Awaits initPricing() during activation to load pricing before cost computation. |
| scripts/update-pricing.ts | Adds build-time snapshot fetch/validate/guardrail script. |
| scripts/update-pricing.test.ts | Adds unit tests for snapshot validation/filtering/guardrails. |
| scripts/post-compile.mjs | Copies src/pricing-data.json into out/ after tsc for runtime bundling. |
| package.json | Renames/rebrands fork, adds offline pricing config, adds test/update scripts and new dev deps. |
| package-lock.json | Locks new dev dependencies (tsx/undici/etc.). |
| .vscodeignore | Excludes scripts/docs/.github from the packaged extension. |
| .gitignore | Ignores local docs/ drafts. |
| README.md | Adds fork attribution + updates Marketplace/Open VSX links. |
| README-en.md | Adds fork attribution, links, and maintainer/release/pricing-update notes. |
| README-zh-TW.md | Adds fork attribution + updates Marketplace/Open VSX links. |
| README-zh-CN.md | Adds fork attribution + updates Marketplace/Open VSX links. |
| README-ja.md | Adds fork attribution + updates Marketplace/Open VSX links. |
| README-ko.md | Adds fork attribution + updates Marketplace/Open VSX links. |
| LICENSE | Preserves original copyright and adds fork copyright. |
| .github/workflows/ci.yml | Adds CI: typecheck, unit tests, packaging verification, and snapshot bundling check. |
| .github/workflows/update-pricing.yml | Adds scheduled/manual workflow to refresh and commit pricing snapshot. |
| .github/workflows/release.yml | Adds tag-based release workflow publishing to VS Marketplace/Open VSX and attaching the VSIX. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+95
to
+100
| const filtered: Record<string, ModelPricing> = {}; | ||
| for (const [key, value] of Object.entries(raw)) { | ||
| if (!isClaudeKey(key)) continue; | ||
| if (value == null || typeof value !== 'object') continue; | ||
| filtered[key] = value as ModelPricing; | ||
| } |
Comment on lines
+90
to
+91
| const res = await fetch(LITELLM_URL, { signal: controller.signal }); | ||
| clearTimeout(timer); |
Comment on lines
+238
to
+240
| }; | ||
|
|
||
| writeFileSync(SNAPSHOT_PATH, JSON.stringify(snapshot, null, 2) + '\n', 'utf-8'); |
| "typescript": "^5.8.3" | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.8.3", | ||
| "undici": "^6.25.0" |
Maintainer 还未注册 VSCE_PAT / OVSX_PAT。tag 触发的 workflow 目前: compile → vsce package → 附加到 GitHub Release。 README-en 更新:当前流程说明 + 未来启用的指引(加 secret + 改 workflow)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.