Skip to content

Enhance pricing features and CI workflows with documentation updates - #12

Closed
huanglune wants to merge 14 commits into
ClaudeCodeUsage:mainfrom
huanglune:dev
Closed

huanglune wants to merge 14 commits into
ClaudeCodeUsage:mainfrom
huanglune:dev

Conversation

@huanglune

Copy link
Copy Markdown

No description provided.

- 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)
Copilot AI review requested due to automatic review settings April 20, 2026 09:14
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 差异

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json snapshot, 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 thread src/pricing.ts
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 thread src/pricing.ts
Comment on lines +90 to +91
const res = await fetch(LITELLM_URL, { signal: controller.signal });
clearTimeout(timer);
Comment thread scripts/update-pricing.ts
Comment on lines +238 to +240
};

writeFileSync(SNAPSHOT_PATH, JSON.stringify(snapshot, null, 2) + '\n', 'utf-8');
Comment thread package.json
"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)。
@huanglune huanglune closed this Apr 20, 2026
@huanglune
huanglune deleted the dev branch April 20, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants