dsh-ai-credits 2.4.2 → 2.4.6
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/README.md +20 -4
- package/client.js +380 -55
- package/codingplan.js +397 -0
- package/docs/DETAIL.md +36 -1
- package/index.js +357 -28
- package/official-usage.js +262 -66
- package/package.json +3 -1
package/codingplan.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ai-credits · codingplan.fyi 聚合源
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* 订阅价目表的主数据源。codingplan.fyi 把各家订阅套餐(197 个 / 52 个平台)
|
|
5
|
+
* 汇总成三个静态 JSON,我们直接读,不再逐个去各家官网抄。
|
|
6
|
+
*
|
|
7
|
+
* plans.json 套餐本体:价格(首月 / 月 / 季 / 年)、请求额度、支持模型、备注
|
|
8
|
+
* platforms.json 平台信息:名称、状态(open / restricted / delisted)、是否国内
|
|
9
|
+
* config.json 全站配置:汇率、更新日期、说明
|
|
10
|
+
*
|
|
11
|
+
* 为什么要它:原先报价靠人工抄 65 条、每天还得把 65 个官网页面挨个探一遍。
|
|
12
|
+
* 换成聚合源以后,网络请求降到 3 条(另有官网备用,见 index.js 的 plan 巡检),
|
|
13
|
+
* 数据也从 65 条涨到 147 条(剔除 50 个已下架的)。
|
|
14
|
+
*
|
|
15
|
+
* 边界:
|
|
16
|
+
* - 只取订阅套餐,不取按量 API 单价(那个仍在 prices.js + 官网实时价核对里)
|
|
17
|
+
* - `action` 字段是聚合站的推广跳转链接,**不采用**,卡片一律链到聚合站首页
|
|
18
|
+
* - 已下架(delisted)的套餐默认丢弃,不计入条目
|
|
19
|
+
* - 拿不到就用 plans.js 里的本地快照,界面会标「快照」
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
23
|
+
import { join } from 'node:path'
|
|
24
|
+
|
|
25
|
+
export const AGGREGATOR_ID = 'codingplan-fyi'
|
|
26
|
+
export const AGGREGATOR_LABEL = 'codingplan.fyi'
|
|
27
|
+
export const AGGREGATOR_HOME = 'https://codingplan.fyi/'
|
|
28
|
+
export const AGGREGATOR_ENDPOINTS = [
|
|
29
|
+
{ key: 'plans', url: 'https://codingplan.fyi/plans.json' },
|
|
30
|
+
{ key: 'platforms', url: 'https://codingplan.fyi/platforms.json' },
|
|
31
|
+
{ key: 'config', url: 'https://codingplan.fyi/config.json' },
|
|
32
|
+
]
|
|
33
|
+
export const AGGREGATOR_TTL_MS = 6 * 60 * 60 * 1000
|
|
34
|
+
|
|
35
|
+
const CACHE_VERSION = 1
|
|
36
|
+
const CACHE_NAME = 'codingplan-cache.json'
|
|
37
|
+
const UA =
|
|
38
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36'
|
|
39
|
+
|
|
40
|
+
/** 纯编程工具订阅:只能在自家客户端里用,不共享 API Key */
|
|
41
|
+
const CODING_TOOL_SLUGS = new Set([
|
|
42
|
+
'qoder-cn',
|
|
43
|
+
'qoder-intl',
|
|
44
|
+
'workbuddy',
|
|
45
|
+
'trae-cn',
|
|
46
|
+
'trae-intl',
|
|
47
|
+
'github',
|
|
48
|
+
'cursor',
|
|
49
|
+
'command-code',
|
|
50
|
+
'codex',
|
|
51
|
+
'claude',
|
|
52
|
+
'opencode',
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
let memory = null
|
|
56
|
+
|
|
57
|
+
function cacheFile(home) {
|
|
58
|
+
return join(home, 'ai-credits', CACHE_NAME)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function readDisk(home) {
|
|
62
|
+
try {
|
|
63
|
+
const raw = JSON.parse(readFileSync(cacheFile(home), 'utf8'))
|
|
64
|
+
if (!raw || raw.v !== CACHE_VERSION || !Array.isArray(raw.plans)) return null
|
|
65
|
+
return raw
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function writeDisk(home, payload) {
|
|
72
|
+
try {
|
|
73
|
+
mkdirSync(join(home, 'ai-credits'), { recursive: true })
|
|
74
|
+
const file = cacheFile(home)
|
|
75
|
+
const tmp = file + '.' + process.pid + '.' + Date.now() + '.tmp'
|
|
76
|
+
writeFileSync(tmp, JSON.stringify(payload), 'utf8')
|
|
77
|
+
renameSync(tmp, file)
|
|
78
|
+
} catch (error) {}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 同步拿最近一次结果,不发请求。publicPlans() 用它决定走聚合还是走快照。 */
|
|
82
|
+
export function cachedAggregator(home) {
|
|
83
|
+
if (memory && memory.plans && memory.plans.length > 0) return memory
|
|
84
|
+
const disk = readDisk(home)
|
|
85
|
+
if (disk) {
|
|
86
|
+
memory = disk
|
|
87
|
+
return disk
|
|
88
|
+
}
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------- 映射
|
|
93
|
+
|
|
94
|
+
function num(value) {
|
|
95
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function currencyOf(plan, platform) {
|
|
99
|
+
if (plan.currency === '¥') return 'CNY'
|
|
100
|
+
if (plan.currency === '$') return 'USD'
|
|
101
|
+
if (plan.currency === '₹') return 'INR'
|
|
102
|
+
// 聚合站多数套餐 currency 为 null,按平台是否国内推断
|
|
103
|
+
return platform && platform.supportsDomestic === true ? 'CNY' : 'USD'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 地区跟币种走:人民币套餐归国内,美元归国际。比按 supportsDomestic 猜准。 */
|
|
107
|
+
function regionOf(currency) {
|
|
108
|
+
return currency === 'CNY' ? '国内' : '国际'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function categoryOf(platformSlug) {
|
|
112
|
+
return CODING_TOOL_SLUGS.has(platformSlug) ? 'coding' : 'general'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 月额度:优先请求数,其次取各模型里最大的月 token 数 */
|
|
116
|
+
function quotaOf(plan) {
|
|
117
|
+
const q = plan.requestQuota
|
|
118
|
+
if (q && typeof q === 'object') {
|
|
119
|
+
const parts = []
|
|
120
|
+
if (num(q.fiveHours) !== null) parts.push('5 小时 ' + q.fiveHours.toLocaleString('en-US') + ' 次')
|
|
121
|
+
if (num(q.weekly) !== null) parts.push('周 ' + q.weekly.toLocaleString('en-US') + ' 次')
|
|
122
|
+
if (num(q.monthly) !== null) parts.push('月 ' + q.monthly.toLocaleString('en-US') + ' 次')
|
|
123
|
+
if (parts.length > 0) return parts.join(' / ')
|
|
124
|
+
}
|
|
125
|
+
let best = null
|
|
126
|
+
let bestModel = null
|
|
127
|
+
for (const m of Array.isArray(plan.planModels) ? plan.planModels : []) {
|
|
128
|
+
const usage = m && m.usage
|
|
129
|
+
if (!usage || typeof usage !== 'object') continue
|
|
130
|
+
const value = num(usage.monthlyTokenInM)
|
|
131
|
+
if (value === null) continue
|
|
132
|
+
if (best === null || value > best) {
|
|
133
|
+
best = value
|
|
134
|
+
bestModel = m.modelSlug || null
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (best === null) return ''
|
|
138
|
+
const text = best >= 1000 ? (best / 1000).toFixed(1) + 'B' : Math.round(best) + 'M'
|
|
139
|
+
return '约 ' + text + ' tokens / 月' + (bestModel ? '(' + bestModel + ')' : '')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** 权益只用聚合站自己列的 benefits,不把备注再拆一遍 —— 备注会单独显示,免得卡片重复 */
|
|
143
|
+
function benefitsOf(plan) {
|
|
144
|
+
const list = []
|
|
145
|
+
for (const item of Array.isArray(plan.benefits) ? plan.benefits : []) {
|
|
146
|
+
const text = String(item || '').trim()
|
|
147
|
+
if (text && !list.includes(text)) list.push(text)
|
|
148
|
+
}
|
|
149
|
+
return list.slice(0, 6)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function trimNote(plan) {
|
|
153
|
+
const note = typeof plan.note === 'string' ? plan.note.replace(/^[•\-·]\s*/gm, '').trim() : ''
|
|
154
|
+
return note.length > 420 ? note.slice(0, 420) + '…' : note
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function sourceDateOf(config) {
|
|
158
|
+
const raw = config && config.header && config.header.updateDate
|
|
159
|
+
const match = typeof raw === 'string' ? raw.match(/(\d{4})\.(\d{1,2})\.(\d{1,2})/) : null
|
|
160
|
+
if (!match) return null
|
|
161
|
+
return match[1] + '-' + match[2].padStart(2, '0') + '-' + match[3].padStart(2, '0')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function mapPlan(plan, platform, sourceDate) {
|
|
165
|
+
const monthly = num(plan.monthlyPrice)
|
|
166
|
+
const first = num(plan.firstMonthPrice)
|
|
167
|
+
const price = monthly !== null ? monthly : first
|
|
168
|
+
if (price === null) return null
|
|
169
|
+
|
|
170
|
+
const slug = typeof plan.platformSlug === 'string' ? plan.platformSlug : ''
|
|
171
|
+
const platformName =
|
|
172
|
+
(platform && typeof platform.name === 'string' && platform.name) || slug || AGGREGATOR_LABEL
|
|
173
|
+
const currency = currencyOf(plan, platform)
|
|
174
|
+
const symbol = currency === 'CNY' ? '¥' : currency === 'USD' ? '$' : ''
|
|
175
|
+
|
|
176
|
+
const priceNoteParts = []
|
|
177
|
+
if (first !== null && monthly !== null && first !== monthly) {
|
|
178
|
+
priceNoteParts.push('首月 ' + symbol + first)
|
|
179
|
+
}
|
|
180
|
+
if (num(plan.quarterlyPrice) !== null) priceNoteParts.push('季付 ' + symbol + plan.quarterlyPrice)
|
|
181
|
+
if (num(plan.yearlyPrice) !== null) priceNoteParts.push('年付 ' + symbol + plan.yearlyPrice)
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
id: 'cp:' + (plan.slug || slug + '-' + plan.name),
|
|
185
|
+
title: platformName + ' ' + String(plan.name || '').trim(),
|
|
186
|
+
provider: platformName,
|
|
187
|
+
region: regionOf(currency),
|
|
188
|
+
category: categoryOf(slug),
|
|
189
|
+
kind: /agent/i.test(String(plan.name || '') + ' ' + slug) ? 'agent' : 'plan',
|
|
190
|
+
currency,
|
|
191
|
+
price,
|
|
192
|
+
period: 'monthly',
|
|
193
|
+
priceNote: priceNoteParts.join(' · '),
|
|
194
|
+
quota: quotaOf(plan),
|
|
195
|
+
benefits: benefitsOf(plan),
|
|
196
|
+
url: AGGREGATOR_HOME,
|
|
197
|
+
checkUrl: AGGREGATOR_HOME,
|
|
198
|
+
sourceDate,
|
|
199
|
+
source: 'aggregator',
|
|
200
|
+
sourceLabel: AGGREGATOR_LABEL,
|
|
201
|
+
planStatus: plan.planStatus === 'restricted' ? 'restricted' : 'open',
|
|
202
|
+
note: trimNote(plan),
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function mapAll(raw, { keepDelisted = false } = {}) {
|
|
207
|
+
const plans = Array.isArray(raw.plans) ? raw.plans : []
|
|
208
|
+
const platforms = Array.isArray(raw.platforms) ? raw.platforms : []
|
|
209
|
+
const bySlug = new Map()
|
|
210
|
+
for (const item of platforms) {
|
|
211
|
+
if (item && typeof item.slug === 'string') bySlug.set(item.slug, item)
|
|
212
|
+
}
|
|
213
|
+
const sourceDate = sourceDateOf(raw.config)
|
|
214
|
+
|
|
215
|
+
const out = []
|
|
216
|
+
const seen = new Set()
|
|
217
|
+
let skippedDelisted = 0
|
|
218
|
+
let skippedBroken = 0
|
|
219
|
+
|
|
220
|
+
for (const plan of plans) {
|
|
221
|
+
if (!plan || typeof plan !== 'object') continue
|
|
222
|
+
if (plan.billingMode && plan.billingMode !== 'subscription') {
|
|
223
|
+
skippedBroken += 1
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
if (plan.planStatus === 'delisted') {
|
|
227
|
+
skippedDelisted += 1
|
|
228
|
+
if (!keepDelisted) continue
|
|
229
|
+
}
|
|
230
|
+
const mapped = mapPlan(plan, bySlug.get(plan.platformSlug), sourceDate)
|
|
231
|
+
if (mapped === null) {
|
|
232
|
+
skippedBroken += 1
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
235
|
+
if (seen.has(mapped.id)) continue
|
|
236
|
+
seen.add(mapped.id)
|
|
237
|
+
out.push(mapped)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
plans: out,
|
|
242
|
+
stats: {
|
|
243
|
+
total: plans.length,
|
|
244
|
+
kept: out.length,
|
|
245
|
+
skippedDelisted,
|
|
246
|
+
skippedBroken,
|
|
247
|
+
platforms: new Set(out.map((item) => item.provider)).size,
|
|
248
|
+
coding: out.filter((item) => item.category === 'coding').length,
|
|
249
|
+
general: out.filter((item) => item.category === 'general').length,
|
|
250
|
+
},
|
|
251
|
+
sourceDate,
|
|
252
|
+
usdToCnyRate: num(raw.config && raw.config.usdToCnyRate),
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ---------------------------------------------------------------- 抓取
|
|
257
|
+
|
|
258
|
+
async function getJson(url, timeoutMs) {
|
|
259
|
+
const started = Date.now()
|
|
260
|
+
try {
|
|
261
|
+
const response = await fetch(url, {
|
|
262
|
+
redirect: 'follow',
|
|
263
|
+
headers: { 'user-agent': UA, accept: 'application/json,*/*;q=0.8' },
|
|
264
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
265
|
+
})
|
|
266
|
+
const status = response.status
|
|
267
|
+
const text = await response.text()
|
|
268
|
+
if (status < 200 || status >= 300) {
|
|
269
|
+
return { ok: false, url, httpStatus: status, bytes: text.length, ms: Date.now() - started, error: 'HTTP ' + status }
|
|
270
|
+
}
|
|
271
|
+
let value = null
|
|
272
|
+
try {
|
|
273
|
+
value = JSON.parse(text)
|
|
274
|
+
} catch (error) {
|
|
275
|
+
return { ok: false, url, httpStatus: status, bytes: text.length, ms: Date.now() - started, error: '不是合法 JSON' }
|
|
276
|
+
}
|
|
277
|
+
return { ok: true, url, httpStatus: status, bytes: text.length, ms: Date.now() - started, value }
|
|
278
|
+
} catch (error) {
|
|
279
|
+
return {
|
|
280
|
+
ok: false,
|
|
281
|
+
url,
|
|
282
|
+
httpStatus: 0,
|
|
283
|
+
bytes: 0,
|
|
284
|
+
ms: Date.now() - started,
|
|
285
|
+
error: String((error && error.message) || error).slice(0, 140),
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 拉一次聚合数据并落盘。拿不到就返回 ok:false,调用方回退本地快照。
|
|
292
|
+
* 缓存 6 小时:聚合站自己也只一天更新一次,没必要更勤。
|
|
293
|
+
*/
|
|
294
|
+
export async function collectAggregatorPlans(home, { force = false, timeoutMs = 20000 } = {}) {
|
|
295
|
+
const disk = readDisk(home)
|
|
296
|
+
if (!force && disk && Date.now() - Date.parse(disk.at) < AGGREGATOR_TTL_MS) {
|
|
297
|
+
memory = disk
|
|
298
|
+
return { ...disk, cached: true }
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const results = await Promise.all(
|
|
302
|
+
AGGREGATOR_ENDPOINTS.map(async (endpoint) => {
|
|
303
|
+
const hit = await getJson(endpoint.url, timeoutMs)
|
|
304
|
+
return { key: endpoint.key, ...hit }
|
|
305
|
+
}),
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
const byKey = new Map(results.map((item) => [item.key, item]))
|
|
309
|
+
const endpoints = results.map((item) => ({
|
|
310
|
+
key: item.key,
|
|
311
|
+
url: item.url,
|
|
312
|
+
ok: item.ok === true,
|
|
313
|
+
httpStatus: item.httpStatus,
|
|
314
|
+
bytes: item.bytes,
|
|
315
|
+
ms: item.ms,
|
|
316
|
+
error: item.error || null,
|
|
317
|
+
}))
|
|
318
|
+
|
|
319
|
+
const plansHit = byKey.get('plans')
|
|
320
|
+
const platformsHit = byKey.get('platforms')
|
|
321
|
+
if (!plansHit || plansHit.ok !== true || !plansHit.value) {
|
|
322
|
+
// 主表拿不到就整体算失败,不拿旧数据冒充新数据
|
|
323
|
+
const failure = {
|
|
324
|
+
v: CACHE_VERSION,
|
|
325
|
+
at: new Date().toISOString(),
|
|
326
|
+
ok: false,
|
|
327
|
+
label: AGGREGATOR_LABEL,
|
|
328
|
+
home: AGGREGATOR_HOME,
|
|
329
|
+
endpoints,
|
|
330
|
+
error: (plansHit && plansHit.error) || 'plans.json 不可用',
|
|
331
|
+
plans: [],
|
|
332
|
+
stats: null,
|
|
333
|
+
sourceDate: null,
|
|
334
|
+
usdToCnyRate: null,
|
|
335
|
+
}
|
|
336
|
+
// 失败不覆盖已有缓存
|
|
337
|
+
return { ...failure, cached: false }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const raw = {
|
|
341
|
+
plans: plansHit.value.plans || [],
|
|
342
|
+
platforms: platformsHit && platformsHit.ok ? platformsHit.value.platforms || [] : [],
|
|
343
|
+
config: (byKey.get('config') && byKey.get('config').ok && byKey.get('config').value) || null,
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const mapped = mapAll(raw)
|
|
347
|
+
if (mapped.plans.length < 10) {
|
|
348
|
+
return {
|
|
349
|
+
v: CACHE_VERSION,
|
|
350
|
+
at: new Date().toISOString(),
|
|
351
|
+
ok: false,
|
|
352
|
+
label: AGGREGATOR_LABEL,
|
|
353
|
+
home: AGGREGATOR_HOME,
|
|
354
|
+
endpoints,
|
|
355
|
+
error: '解析出来的套餐太少(' + mapped.plans.length + ' 条),当作不可用',
|
|
356
|
+
plans: [],
|
|
357
|
+
stats: mapped.stats,
|
|
358
|
+
sourceDate: mapped.sourceDate,
|
|
359
|
+
usdToCnyRate: mapped.usdToCnyRate,
|
|
360
|
+
cached: false,
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const payload = {
|
|
365
|
+
v: CACHE_VERSION,
|
|
366
|
+
at: new Date().toISOString(),
|
|
367
|
+
ok: true,
|
|
368
|
+
label: AGGREGATOR_LABEL,
|
|
369
|
+
home: AGGREGATOR_HOME,
|
|
370
|
+
endpoints,
|
|
371
|
+
error: null,
|
|
372
|
+
plans: mapped.plans,
|
|
373
|
+
stats: mapped.stats,
|
|
374
|
+
sourceDate: mapped.sourceDate,
|
|
375
|
+
usdToCnyRate: mapped.usdToCnyRate,
|
|
376
|
+
}
|
|
377
|
+
writeDisk(home, payload)
|
|
378
|
+
memory = payload
|
|
379
|
+
return { ...payload, cached: false }
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** 巡检用:只探三个端点,不解析。返回数组(顺序同 AGGREGATOR_ENDPOINTS) */
|
|
383
|
+
export async function probeAggregator(probeFn, timeoutMs) {
|
|
384
|
+
return Promise.all(
|
|
385
|
+
AGGREGATOR_ENDPOINTS.map(async (endpoint) => {
|
|
386
|
+
const result = await probeFn(endpoint.url, timeoutMs)
|
|
387
|
+
return {
|
|
388
|
+
key: endpoint.key,
|
|
389
|
+
url: endpoint.url,
|
|
390
|
+
checkedAt: result.checkedAt,
|
|
391
|
+
httpStatus: result.httpStatus,
|
|
392
|
+
reachable: result.reachable,
|
|
393
|
+
note: result.note,
|
|
394
|
+
}
|
|
395
|
+
}),
|
|
396
|
+
)
|
|
397
|
+
}
|
package/docs/DETAIL.md
CHANGED
|
@@ -6,13 +6,47 @@
|
|
|
6
6
|
|
|
7
7
|
| 栏目 | 内容 |
|
|
8
8
|
|:--|:--|
|
|
9
|
-
| **领取入口** | 各家的免费额度 / 代金券 /
|
|
9
|
+
| **领取入口** | 各家的免费额度 / 代金券 / 学生包入口,每天自动巡检一遍,记下能不能打开;**每一栏按「能打开 / 打不开 / 待检查」分三栏**,点不开的可以一键删掉 |
|
|
10
10
|
| **各家价格** | API 官方标价(每百万 tokens,输入 / 输出分列),按币种和地区分组 |
|
|
11
11
|
| **通用订阅** | 各家的 Token Plan / 会员 / Coding Plan,同一厂商的档位排在一列 |
|
|
12
12
|
| **编程工具订阅** | **限定本家编程软件使用**的订阅(WorkBuddy / CodeBuddy / Qoder / Trae / Cursor / Copilot 等) |
|
|
13
13
|
| **本机接入** | 这台机器的 DSH 接了哪几条线路、每条有哪些模型、密钥配没配、新会话默认用哪个 |
|
|
14
14
|
| **用量花费** | 各线路 token 用量与金额;点开任一渠道可展开**按会话分段的 token 时间轴** |
|
|
15
15
|
|
|
16
|
+
## 订阅价从哪来(2.4.3 起)
|
|
17
|
+
|
|
18
|
+
订阅那两个栏目(通用订阅 / 编程工具订阅)**主数据源换成聚合站 codingplan.fyi**:
|
|
19
|
+
|
|
20
|
+
| 项 | 以前 | 现在 |
|
|
21
|
+
|:--|:--|:--|
|
|
22
|
+
| 数据来源 | `plans.js` 人工抄的 65 条 | codingplan.fyi 的 `plans.json`(197 条,剔除 50 个已下架 → 145 条) |
|
|
23
|
+
| 覆盖平台 | 15 家 | 40 家 |
|
|
24
|
+
| 每天网络请求 | 65 个官网页面逐个探 | 3 个聚合端点 + 15 个厂商代表页(备用) |
|
|
25
|
+
| 刷新节奏 | 20 小时 | 聚合数据 6 小时缓存,页面巡检 20 小时 |
|
|
26
|
+
|
|
27
|
+
聚合站拿不到时**自动回退**到 `plans.js` 的本地快照,卡片标「聚合」/ 顶部提示「这次没取到,显示本地快照」——不会拿旧数字冒充新的。
|
|
28
|
+
|
|
29
|
+
三个端点:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
https://codingplan.fyi/plans.json 套餐:价格 / 额度 / 支持模型 / 备注
|
|
33
|
+
https://codingplan.fyi/platforms.json 平台:名称 / 状态(open / restricted / delisted)
|
|
34
|
+
https://codingplan.fyi/config.json 汇率 / 更新日期
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**没有采用**聚合站的 `action` 字段(那是它的推广跳转链接),卡片一律链到 `codingplan.fyi` 首页,让人自己看详情。
|
|
38
|
+
|
|
39
|
+
## 删掉点不开的入口
|
|
40
|
+
|
|
41
|
+
每个入口卡片右上角有个 **✕**。删掉以后:
|
|
42
|
+
|
|
43
|
+
1. **留档**:URL、标题、分类、当时的 HTTP 状态、删除时间都记进 `catalog.json` 的 `removed`
|
|
44
|
+
2. **种子不会复活**:内置清单每次启动都会并回状态里,但删过的会被跳过 —— 否则「删了又回来」等于没删
|
|
45
|
+
3. **再搜到只标存疑**:联网发现撞上已删除的链接,**不会**把它加回清单,只把那条留档的 `hits +1` 并标 `suspect`,底部「已删除的入口」里显示「存疑 ×N」
|
|
46
|
+
4. **能恢复**:底部面板展开,每条后面一个「恢复」按钮;种子会按内置清单补回,联网发现的直接放回「每日新发现」
|
|
47
|
+
|
|
48
|
+
`removed` 只在 `$DSH_HOME/ai-credits/catalog.json` 里,不上传。
|
|
49
|
+
|
|
16
50
|
## 用量花费怎么算
|
|
17
51
|
|
|
18
52
|
分三类,因为不是所有线路都在花现金:
|
|
@@ -68,3 +102,4 @@ DeepSeek 没有用量查询 API,但开放平台能导出 CSV。「用量花费
|
|
|
68
102
|
- **fork / 分支会话的重复事件已自动去重**:DSH 会把父会话的历史事件原样复制到分叉会话里(时间戳和 usage 都相同),插件按「时间戳+渠道+模型+四类 token」八字段指纹判重并剔除,条数显示在用量栏顶部。
|
|
69
103
|
- **折算金额不等于官方账单**:日志统计的是 DSH 这一侧的调用,官方账单是整个账号。差额主要来自「搜索 / 标题生成」这两类不产生 `assistant/message` 的调用,以及别处使用同一账号的消费。
|
|
70
104
|
- 价格数字里,DeepSeek 自动跟官网;**其他厂商是人工核对的快照**,改价后需要更新 `prices.js` / `plans.js`。
|
|
105
|
+
- **订阅价依赖第三方聚合站**:codingplan.fyi 挂了或改了结构,订阅栏目会回退本地快照(`plans.js`),数字可能过期。聚合站自己也标注「价格以平台官方公布为准」,下单前请看官网。
|