@qthinker/opencode-deepseek-search 0.2.1 → 0.3.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.
- package/CHANGELOG.md +18 -0
- package/README.md +26 -10
- package/gui-experimental.cjs +1 -1
- package/package.json +3 -2
- package/src/deepseek.ts +65 -47
- package/src/gui/index.tsx +14 -7
- package/src/gui/panel.tsx +13 -8
- package/src/i18n/en.ts +151 -0
- package/src/i18n/index.ts +87 -0
- package/src/i18n/ja.ts +138 -0
- package/src/i18n/zh.ts +133 -0
- package/src/index.ts +58 -41
- package/src/rpc.ts +34 -2
- package/src/status-view.ts +59 -51
- package/src/tui/card.ts +4 -1
- package/src/tui/main.ts +16 -8
- package/src/usage.ts +32 -9
package/src/usage.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
//
|
|
7
7
|
// Everything here is pure; persistence is the caller's job (ctx.storage).
|
|
8
8
|
|
|
9
|
+
import { t } from "./i18n/index.ts"
|
|
10
|
+
import type { Language } from "./rpc.ts"
|
|
11
|
+
|
|
9
12
|
export const USAGE_KEY = "usage/v1"
|
|
10
13
|
export const KEEP_DAYS = 60
|
|
11
14
|
export const MICRO = 1_000_000
|
|
@@ -102,31 +105,51 @@ export function formatYuan(costMicro: number): string {
|
|
|
102
105
|
return `¥${(costMicro / MICRO).toFixed(4)}`
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
export function formatUsage(
|
|
108
|
+
export function formatUsage(
|
|
109
|
+
ledger: UsageLedger,
|
|
110
|
+
pricePerThousand: number,
|
|
111
|
+
mode: string,
|
|
112
|
+
language: Language,
|
|
113
|
+
today = dayKey(),
|
|
114
|
+
): string {
|
|
106
115
|
const month = today.slice(0, 7)
|
|
107
116
|
const line = (label: string, d: UsageDay) =>
|
|
108
|
-
|
|
117
|
+
t(language, "usage.report.line", {
|
|
118
|
+
label,
|
|
119
|
+
search: d.search,
|
|
120
|
+
fetch: d.fetch,
|
|
121
|
+
skipped: d.empty + d.failed,
|
|
122
|
+
empty: d.empty,
|
|
123
|
+
failed: d.failed,
|
|
124
|
+
cost: formatYuan(d.costMicro),
|
|
125
|
+
})
|
|
109
126
|
return [
|
|
110
|
-
|
|
111
|
-
line(
|
|
112
|
-
line(
|
|
113
|
-
line("
|
|
114
|
-
|
|
127
|
+
t(language, "usage.report.title", { mode, price: pricePerThousand }),
|
|
128
|
+
line(`${t(language, "usage.label.today")} ${today}`, sumDays(ledger, (k) => k === today)),
|
|
129
|
+
line(`${t(language, "usage.label.month")} ${month}`, sumDays(ledger, (k) => k.startsWith(month))),
|
|
130
|
+
line(t(language, "usage.label.total"), sumDays(ledger, () => true)),
|
|
131
|
+
t(language, "usage.report.note"),
|
|
115
132
|
].join("\n")
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
/**
|
|
119
136
|
* Compact one-line summaries for a status display, keyed by period. Callers add
|
|
120
|
-
* the
|
|
137
|
+
* the localized period label themselves. Costs are read from the ledger, which
|
|
121
138
|
* already accumulated them at tally time.
|
|
122
139
|
*/
|
|
123
140
|
export function usageSummaryLines(
|
|
124
141
|
ledger: UsageLedger,
|
|
142
|
+
language: Language,
|
|
125
143
|
today = dayKey(),
|
|
126
144
|
): { today: string; month: string; total: string } {
|
|
127
145
|
const month = today.slice(0, 7)
|
|
128
146
|
const line = (d: UsageDay) =>
|
|
129
|
-
|
|
147
|
+
t(language, "usage.summary.line", {
|
|
148
|
+
search: d.search,
|
|
149
|
+
fetch: d.fetch,
|
|
150
|
+
skipped: d.empty + d.failed,
|
|
151
|
+
cost: formatYuan(d.costMicro),
|
|
152
|
+
})
|
|
130
153
|
return {
|
|
131
154
|
today: line(sumDays(ledger, (k) => k === today)),
|
|
132
155
|
month: line(sumDays(ledger, (k) => k.startsWith(month))),
|