opencode-magpie-plugin 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,36 @@
1
+ //#region src/model-pricing.d.ts
2
+ /**
3
+ * Model pricing utilities
4
+ *
5
+ * 模型价格统一以美元 / 百万 tokens 表示。Provider 使用的模型 key 可能不同,
6
+ * 调用 getModelPricing 时会先归一化到规范 key,避免同一模型在多个插件中维护多份价格。
7
+ */
8
+ interface ModelPricing {
9
+ input: number;
10
+ output: number;
11
+ cache?: {
12
+ read?: number;
13
+ write?: number;
14
+ };
15
+ }
16
+ type ModelPricingProvider = 'astra' | 'boxai' | 'codebuddy' | 'cursor' | 'imate' | 'kalm';
17
+ /**
18
+ * 将 Provider 特有模型 ID 归一化为共享价格 key。
19
+ *
20
+ * 优先级:精确 key → 显式别名 → 去 Provider 后缀 → 同家族同主版本的最近已知版本。
21
+ * 未知 SKU 不会跨主版本猜测价格。
22
+ *
23
+ * 能力后缀(`-fast`)先摘掉再归一化基础 key,否则 `<base>-<context>-fast`
24
+ * 里的 context 位于中间,既剥不掉也命不中别名,整个 SKU 会拿不到价格。
25
+ */
26
+ declare const resolveModelPricingKey: (key: string) => string | undefined;
27
+ /**
28
+ * 获取模型的统一价格;未知模型返回 undefined,调用方保留自己的 fallback。
29
+ */
30
+ declare const getModelPricing: (key: string, provider?: ModelPricingProvider) => ModelPricing | undefined;
31
+ /** 获取模型价格;用于内置模型表,缺失价格属于注册表错误。 */
32
+ declare const getRequiredModelPricing: (key: string, provider?: ModelPricingProvider) => ModelPricing;
33
+ /** 获取已注册的规范模型默认价格,返回副本以避免外部修改共享注册表。 */
34
+ declare const getAllModelPricings: () => Readonly<Record<string, ModelPricing>>;
35
+ //#endregion
36
+ export { ModelPricing, ModelPricingProvider, getAllModelPricings, getModelPricing, getRequiredModelPricing, resolveModelPricingKey };
@@ -0,0 +1,3 @@
1
+ import { i as resolveModelPricingKey, n as getModelPricing, r as getRequiredModelPricing, t as getAllModelPricings } from "./model-pricing--x7wwPba.mjs";
2
+
3
+ export { getAllModelPricings, getModelPricing, getRequiredModelPricing, resolveModelPricingKey };
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "opencode-magpie-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Discover Magpie providers and models in OpenCode V2 with built-in pricing and automatic local gateway startup",
5
+ "type": "module",
6
+ "main": "./dist/index.mjs",
7
+ "types": "./dist/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.mts",
11
+ "import": "./dist/index.mjs",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "./server": {
15
+ "types": "./dist/index.d.mts",
16
+ "import": "./dist/index.mjs",
17
+ "default": "./dist/index.mjs"
18
+ },
19
+ "./pricing": {
20
+ "types": "./dist/model-pricing.d.mts",
21
+ "import": "./dist/model-pricing.mjs",
22
+ "default": "./dist/model-pricing.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "LICENSE"
28
+ ],
29
+ "sideEffects": false,
30
+ "engines": {
31
+ "node": ">=22"
32
+ },
33
+ "packageManager": "pnpm@9.15.0",
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "type-check": "tsc --noEmit",
37
+ "test": "vitest run",
38
+ "lint": "biome check src tests tsdown.config.ts package.json",
39
+ "check": "pnpm type-check && pnpm lint && pnpm test && pnpm build",
40
+ "prepublishOnly": "pnpm check"
41
+ },
42
+ "devDependencies": {
43
+ "@biomejs/biome": "2.5.1",
44
+ "@types/node": "^22.0.0",
45
+ "tsdown": "^0.17.4",
46
+ "typescript": "^5.9.3",
47
+ "vitest": "^4.0.18"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public",
51
+ "registry": "https://registry.npmjs.org/"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/yee94/opencode-magpie-plugin.git"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/yee94/opencode-magpie-plugin/issues"
59
+ },
60
+ "homepage": "https://github.com/yee94/opencode-magpie-plugin#readme",
61
+ "author": "yee94",
62
+ "keywords": [
63
+ "opencode",
64
+ "magpie",
65
+ "plugin",
66
+ "cursor",
67
+ "workbuddy",
68
+ "llm",
69
+ "gateway"
70
+ ],
71
+ "license": "MIT"
72
+ }