@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/gui/panel.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { JSX } from "solid-js"
|
|
4
4
|
import { For, Show, createMemo, onCleanup, onMount } from "solid-js"
|
|
5
5
|
import { usePlugin } from "@opencode/plugin/gui"
|
|
6
|
+
import { t, type Key } from "../i18n/index.ts"
|
|
6
7
|
import type { SearchStatus } from "../rpc.ts"
|
|
7
8
|
import { sidebarRows, type SidebarRows } from "../status-view.ts"
|
|
8
9
|
|
|
@@ -28,9 +29,9 @@ const INK = {
|
|
|
28
29
|
light: { on: "#1e7a4c", warn: "#8a5f08", error: "#b03931", off: "#6b7076", idle: "#6b7076", rule: "rgba(0,0,0,0.13)" },
|
|
29
30
|
} as const
|
|
30
31
|
|
|
31
|
-
const
|
|
32
|
-
on: "
|
|
33
|
-
warn: "
|
|
32
|
+
const LABEL_KEY: Readonly<Record<Tone, Key>> = {
|
|
33
|
+
on: "panel.label.on", off: "panel.label.off",
|
|
34
|
+
warn: "panel.label.warn", error: "panel.label.error", idle: "panel.label.idle",
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const ICON = { on: "arrow-undo-down", off: "globe", warn: "arrow-undo-down", error: "refresh", idle: "refresh" } as const
|
|
@@ -68,7 +69,11 @@ function help(action: string, mono: string): JSX.Element {
|
|
|
68
69
|
|
|
69
70
|
export function DeepSeekPanel(props: DeepSeekPanelProps): JSX.Element {
|
|
70
71
|
const ctx = usePlugin()
|
|
71
|
-
|
|
72
|
+
// The desktop plugin has no forced locale: the server resolves one and carries
|
|
73
|
+
// it in `status`. The first frame has no status and renders the loader, so the
|
|
74
|
+
// fallback only ever shows that.
|
|
75
|
+
const language = () => props.status?.language ?? "en"
|
|
76
|
+
const rows = createMemo(() => sidebarRows({ status: props.status, error: props.error, maxColumns: Infinity, language: language() }))
|
|
72
77
|
const ink = createMemo(() => INK[ctx.appearance.mode()])
|
|
73
78
|
const mono = () => ctx.appearance.font("mono")
|
|
74
79
|
|
|
@@ -95,8 +100,8 @@ export function DeepSeekPanel(props: DeepSeekPanelProps): JSX.Element {
|
|
|
95
100
|
<h2 aria-live="polite" style={{ flex: 1, "min-width": 0, margin: 0, "font-size": "13px", "font-weight": 600, "line-height": "20px", "overflow-wrap": "anywhere" }}>
|
|
96
101
|
{headline(rows().title, ink()[rows().tone])}
|
|
97
102
|
</h2>
|
|
98
|
-
<ctx.ui.Tooltip value="
|
|
99
|
-
<ctx.ui.IconButton icon="refresh" label="
|
|
103
|
+
<ctx.ui.Tooltip value={t(language(), "panel.tooltip.refresh")} placement="bottom">
|
|
104
|
+
<ctx.ui.IconButton icon="refresh" label={t(language(), "panel.tooltip.refresh")} size="small" onClick={props.onRefresh} />
|
|
100
105
|
</ctx.ui.Tooltip>
|
|
101
106
|
</header>
|
|
102
107
|
|
|
@@ -106,7 +111,7 @@ export function DeepSeekPanel(props: DeepSeekPanelProps): JSX.Element {
|
|
|
106
111
|
) : (
|
|
107
112
|
<div style={{ display: "flex", "align-items": "center", gap: "8px", "margin-top": "14px", opacity: 0.7 }}>
|
|
108
113
|
<ctx.ui.Loader size="small" />
|
|
109
|
-
<span style={{ "font-size": "12px" }}
|
|
114
|
+
<span style={{ "font-size": "12px" }}>{t(language(), "panel.loading")}</span>
|
|
110
115
|
</div>
|
|
111
116
|
)
|
|
112
117
|
) : (
|
|
@@ -145,7 +150,7 @@ export function DeepSeekPanel(props: DeepSeekPanelProps): JSX.Element {
|
|
|
145
150
|
<Show when={rows().clickable && rows().tone !== "idle"}>
|
|
146
151
|
<div style={{ "margin-top": "18px" }}>
|
|
147
152
|
<ctx.ui.Button variant={rows().tone === "off" || rows().tone === "error" ? "contrast" : "neutral"} icon={ICON[rows().tone]} disabled={props.busy} busy={props.busy} onClick={props.onToggle}>
|
|
148
|
-
{
|
|
153
|
+
{t(language(), LABEL_KEY[rows().tone])}
|
|
149
154
|
</ctx.ui.Button>
|
|
150
155
|
</div>
|
|
151
156
|
</Show>
|
package/src/i18n/en.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// English copy: the source language and the fallback for every key.
|
|
2
|
+
//
|
|
3
|
+
// Every other locale is typed against `Key` (the keys of this table), so a
|
|
4
|
+
// missing translation is a compile error rather than a silent English string.
|
|
5
|
+
// Templates interpolate `{name}` through `format()` in ./index.ts; a brace group
|
|
6
|
+
// that is not a known parameter (e.g. `{env:DEEPSEEK_API_KEY}`) is left alone.
|
|
7
|
+
|
|
8
|
+
export const en = {
|
|
9
|
+
// ---------- sidebar states: full wording, then the short form used when the
|
|
10
|
+
// row cannot hold the full one ----------
|
|
11
|
+
"state.loading": "Loading…",
|
|
12
|
+
"state.loadingShort": "Loading…",
|
|
13
|
+
"state.failed": "Read failed",
|
|
14
|
+
"state.failedShort": "Failed",
|
|
15
|
+
"state.enabled": "Enabled",
|
|
16
|
+
"state.enabledShort": "On",
|
|
17
|
+
"state.disabled": "Disabled",
|
|
18
|
+
"state.disabledShort": "Off",
|
|
19
|
+
"state.unpatched": "websearch not taken over",
|
|
20
|
+
"state.unpatchedShort": "Not taken over",
|
|
21
|
+
"state.missingKey": "API key missing",
|
|
22
|
+
"state.missingKeyShort": "No API key",
|
|
23
|
+
|
|
24
|
+
// ---------- the clickable action on the card ----------
|
|
25
|
+
"action.disable": "Disable",
|
|
26
|
+
"action.enable": "Enable",
|
|
27
|
+
"action.release": "Release",
|
|
28
|
+
"action.retry": "Retry",
|
|
29
|
+
|
|
30
|
+
// ---------- desktop panel ----------
|
|
31
|
+
"panel.tooltip.refresh": "Refresh usage",
|
|
32
|
+
"panel.loading": "Reading usage…",
|
|
33
|
+
"panel.label.on": "Disable (release to native search)",
|
|
34
|
+
"panel.label.off": "Enable (take over with DeepSeek)",
|
|
35
|
+
"panel.label.warn": "Release to native search",
|
|
36
|
+
"panel.label.error": "Retry",
|
|
37
|
+
"panel.label.idle": "Retry",
|
|
38
|
+
|
|
39
|
+
// ---------- host chrome: commands, menus, toasts, dialogs ----------
|
|
40
|
+
"command.open": "DeepSeek: Open usage panel",
|
|
41
|
+
"command.toggle": "DeepSeek: Enable/disable search takeover",
|
|
42
|
+
"menu.description": "Search usage and the takeover switch",
|
|
43
|
+
"toast.openSessionFirst": "Open a session first",
|
|
44
|
+
"toast.statusMalformed": "Status payload has the wrong shape",
|
|
45
|
+
"toast.modeMalformed": "Mode switch result has the wrong shape",
|
|
46
|
+
"dialog.title": "DeepSeek search",
|
|
47
|
+
"dialog.enable": "Enable",
|
|
48
|
+
"dialog.enableDesc": "Take over the built-in websearch",
|
|
49
|
+
"dialog.disable": "Disable",
|
|
50
|
+
"dialog.disableDesc": "Return the built-in websearch to the host",
|
|
51
|
+
"dialog.refresh": "Refresh",
|
|
52
|
+
"dialog.refreshDesc": "Re-read status and usage",
|
|
53
|
+
|
|
54
|
+
// ---------- deepseek_mode output ----------
|
|
55
|
+
"mode.report": "Current search backend: {mode} (source: {source}){suffix}",
|
|
56
|
+
"mode.source.override": "deepseek_mode switch, persisted",
|
|
57
|
+
"mode.source.config": "config file options.mode",
|
|
58
|
+
"mode.suffix.patched": " · built-in websearch is served by DeepSeek",
|
|
59
|
+
"mode.suffix.notPatched": " · built-in websearch was not found, so nothing is taken over",
|
|
60
|
+
"mode.suffix.native": " · built-in websearch stays native",
|
|
61
|
+
"mode.notFound":
|
|
62
|
+
"Built-in {tool} tool not found; it cannot be switched at runtime. " +
|
|
63
|
+
'Set options.mode to "{mode}" in the config file instead.',
|
|
64
|
+
"mode.configCleared": "Persisted switch cleared; back to the config file ({mode}).",
|
|
65
|
+
"mode.persisted":
|
|
66
|
+
"Persisted: still {mode} after restarting OpenCode. " +
|
|
67
|
+
'To return to the config file, call deepseek_mode with mode: "config".',
|
|
68
|
+
"mode.statusOnly": "status only reports the current mode; it does not switch.",
|
|
69
|
+
"mode.invalid": "mode must be status / deepseek / native / config, got: {raw}",
|
|
70
|
+
|
|
71
|
+
// ---------- tool progress / bookkeeping ----------
|
|
72
|
+
"progress.fetch": "DeepSeek Fetch: fetching {url}",
|
|
73
|
+
"fetch.source": "Source: {url}",
|
|
74
|
+
"usage.reset": "Local stats cleared.",
|
|
75
|
+
|
|
76
|
+
// ---------- deepseek_usage report ----------
|
|
77
|
+
"usage.report.title":
|
|
78
|
+
"DeepSeek usage (local counts, estimated per successful request; current mode {mode}; ¥{price}/1000 requests)",
|
|
79
|
+
"usage.report.line":
|
|
80
|
+
"{label}: searches {search} · fetches {fetch} · empty/failed {skipped} (empty {empty} / failed {failed}) · est. {cost}",
|
|
81
|
+
"usage.report.note":
|
|
82
|
+
"Note: empty and failed requests are not billed; DeepSeek's account-side bill is authoritative, and these counts exclude other machines or tools.",
|
|
83
|
+
"usage.label.today": "Today",
|
|
84
|
+
"usage.label.month": "Month",
|
|
85
|
+
"usage.label.total": "Total",
|
|
86
|
+
"usage.summary.line": "Search {search} · Fetch {fetch} · empty/failed {skipped} · {cost}",
|
|
87
|
+
|
|
88
|
+
// ---------- errors ----------
|
|
89
|
+
"error.missingKey":
|
|
90
|
+
"DeepSeek API key is not configured. Set the DEEPSEEK_API_KEY environment variable " +
|
|
91
|
+
'(PowerShell: [Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY","sk-...","User")), ' +
|
|
92
|
+
'or write "apiKey": "{env:DEEPSEEK_API_KEY}" in the plugin options, then restart opencode.',
|
|
93
|
+
"error.http.400":
|
|
94
|
+
"Invalid DeepSeek request parameters (400){upstream}. Queries must be 1–128 characters; " +
|
|
95
|
+
"Fetch URLs must be valid absolute http(s) URLs.",
|
|
96
|
+
"error.http.401":
|
|
97
|
+
"Invalid DeepSeek API key (401){upstream}. Check the DEEPSEEK_API_KEY environment variable or options.apiKey.",
|
|
98
|
+
"error.http.402": "Insufficient DeepSeek account balance (402); failed requests are not billed. Top up and try again.",
|
|
99
|
+
"error.http.403": "DeepSeek Fetch was blocked by the target site's security policy (403){upstream}.{hint}",
|
|
100
|
+
"error.http.404": "DeepSeek could not extract the page body (404){upstream}. Check that the link is reachable.{hint}",
|
|
101
|
+
"error.http.408": "DeepSeek request timed out (408); one backoff retry also failed. Try again later.",
|
|
102
|
+
"error.http.413": "DeepSeek request body too large (413). Shorten the input.",
|
|
103
|
+
"error.http.429":
|
|
104
|
+
"DeepSeek rate limit hit (429; account limits: Search 100 QPS / Fetch 25 QPS); " +
|
|
105
|
+
"one backoff retry also failed. Try again later.",
|
|
106
|
+
"error.http.5xx":
|
|
107
|
+
"DeepSeek server error ({status}); one backoff retry also failed. " +
|
|
108
|
+
'You can set options.mode to "native" to use native search for now.',
|
|
109
|
+
"error.http.other": "DeepSeek request failed (HTTP {status}){upstream}",
|
|
110
|
+
"error.http.fetchHint": " You can use the built-in webfetch tool for this page.",
|
|
111
|
+
"error.parse": "DeepSeek returned an unparseable response (HTTP {status}). Try again later.",
|
|
112
|
+
"error.aborted": "DeepSeek request cancelled.",
|
|
113
|
+
"error.timeout": "DeepSeek request timed out ({seconds}s). Try again.",
|
|
114
|
+
"error.network": "Cannot reach {base} (network error: {message}). Check your network or proxy settings.",
|
|
115
|
+
"error.validate.queryEmpty": "Empty query: DeepSeek Search needs a non-empty query (1–128 characters).",
|
|
116
|
+
"error.validate.queryLong": "Query too long ({length} characters, limit {max}); shorten it and retry.",
|
|
117
|
+
"error.validate.urlScheme": 'Invalid URL: "{url}". DeepSeek Fetch only supports absolute http/https URLs.',
|
|
118
|
+
"error.validate.urlLong": "URL too long ({length} > {max} characters).",
|
|
119
|
+
"error.validate.urlHost": 'URL has no host: "{url}".',
|
|
120
|
+
"error.validate.urlUserinfo": "URL must not contain a username/password (userinfo).",
|
|
121
|
+
"error.validate.urlParse": 'Cannot parse URL: "{url}".',
|
|
122
|
+
"error.fetch.truncated":
|
|
123
|
+
"[DeepSeek Fetch truncated] The page is {raw} characters; the limit is {max}, so only the first {max} characters are kept.",
|
|
124
|
+
} as const
|
|
125
|
+
|
|
126
|
+
export type Key = keyof typeof en
|
|
127
|
+
/** One locale's complete table: every key, no extras. */
|
|
128
|
+
export type Messages = Record<Key, string>
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Usage-row ladder, richest first. Each entry is a complete row, so nothing is
|
|
132
|
+
* ever left dangling and no number is ever cut from its unit. `{label}` is the
|
|
133
|
+
* localized period label; `Search`/`Fetch` stay English in every language.
|
|
134
|
+
*/
|
|
135
|
+
export const enUsageForms: readonly string[] = [
|
|
136
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
137
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
138
|
+
"{label} Search {search} Fetch {fetch}",
|
|
139
|
+
"{label} Search {search} Fetch {fetch}",
|
|
140
|
+
"{label} {search}S {fetch}F {cost}",
|
|
141
|
+
"{label} {search}S {fetch}F",
|
|
142
|
+
"{label} {search}S",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
/** Missing-key hint ladder, richest first. The env var name is always present. */
|
|
146
|
+
export const enHintForms: readonly string[] = [
|
|
147
|
+
"Set DEEPSEEK_API_KEY and restart",
|
|
148
|
+
"Set DEEPSEEK_API_KEY",
|
|
149
|
+
"Set API KEY",
|
|
150
|
+
"Set KEY",
|
|
151
|
+
]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// The plugin's only copy source and the language resolver.
|
|
2
|
+
//
|
|
3
|
+
// The server resolves one `Language` at setup, puts it in the RPC `status`
|
|
4
|
+
// payload, and the tools and both sidebars render with it — so the chat output
|
|
5
|
+
// and the two sidebars can never disagree. Pure data and pure functions: no
|
|
6
|
+
// plugin or host imports, so every runtime can load this module.
|
|
7
|
+
|
|
8
|
+
import { isLanguage, type Language } from "../rpc.ts"
|
|
9
|
+
import { en, enHintForms, enUsageForms, type Key, type Messages } from "./en.ts"
|
|
10
|
+
import { ja, jaHintForms, jaUsageForms } from "./ja.ts"
|
|
11
|
+
import { zh, zhHintForms, zhUsageForms } from "./zh.ts"
|
|
12
|
+
|
|
13
|
+
export type { Key, Messages }
|
|
14
|
+
|
|
15
|
+
/** One language's complete copy: strings plus the ladders that take widths. */
|
|
16
|
+
export interface LocalePack {
|
|
17
|
+
readonly messages: Messages
|
|
18
|
+
/** Usage-row ladder, richest first; see `en.ts`. */
|
|
19
|
+
readonly usageForms: readonly string[]
|
|
20
|
+
/** Missing-key hint ladder, richest first. */
|
|
21
|
+
readonly hintForms: readonly string[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const PACKS: Readonly<Record<Language, LocalePack>> = {
|
|
25
|
+
en: { messages: en, usageForms: enUsageForms, hintForms: enHintForms },
|
|
26
|
+
ja: { messages: ja, usageForms: jaUsageForms, hintForms: jaHintForms },
|
|
27
|
+
"zh-CN": { messages: zh, usageForms: zhUsageForms, hintForms: zhHintForms },
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function pack(language: Language): LocalePack {
|
|
31
|
+
return PACKS[language]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function messages(language: Language): Messages {
|
|
35
|
+
return PACKS[language].messages
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Params = Readonly<Record<string, string | number>>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fill `{name}` placeholders. A brace group that is not a supplied parameter is
|
|
42
|
+
* left verbatim, which keeps literals such as `{env:DEEPSEEK_API_KEY}` intact.
|
|
43
|
+
*/
|
|
44
|
+
export function format(template: string, params: Params = {}): string {
|
|
45
|
+
return template.replace(/\{(\w+)\}/g, (match, name: string) => (name in params ? String(params[name]) : match))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** One message. An unknown key falls back to the key itself, never to a crash. */
|
|
49
|
+
export function t(language: Language, key: Key, params?: Params): string {
|
|
50
|
+
const table: Readonly<Record<string, string>> = messages(language)
|
|
51
|
+
const template = table[key]
|
|
52
|
+
return template === undefined ? key : format(template, params)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ---------- language resolution ----------
|
|
56
|
+
|
|
57
|
+
/** The only environment the resolver looks at; both are POSIX locale names. */
|
|
58
|
+
export interface LanguageEnv {
|
|
59
|
+
readonly LC_ALL?: string
|
|
60
|
+
readonly LANG?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface LanguagePick {
|
|
64
|
+
readonly language: Language
|
|
65
|
+
/** The raw option value when it was not a known language; the caller warns. */
|
|
66
|
+
readonly problem?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* `options.language` wins; otherwise `LC_ALL` (which overrides `LANG` per
|
|
71
|
+
* POSIX), then `LANG`, then English. Prefix matching keeps `ja_JP.UTF-8` and
|
|
72
|
+
* `zh_CN.UTF-8` working without an alias table; anything else is English.
|
|
73
|
+
*/
|
|
74
|
+
export function resolveLanguage(option: unknown, env: LanguageEnv = {}): LanguagePick {
|
|
75
|
+
if (option !== undefined && option !== null && option !== "") {
|
|
76
|
+
if (isLanguage(option)) return { language: option }
|
|
77
|
+
return { language: fromEnv(env), problem: String(option) }
|
|
78
|
+
}
|
|
79
|
+
return { language: fromEnv(env) }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function fromEnv(env: LanguageEnv): Language {
|
|
83
|
+
const raw = (env.LC_ALL?.trim() || env.LANG?.trim() || "").toLowerCase()
|
|
84
|
+
if (raw.startsWith("ja")) return "ja"
|
|
85
|
+
if (raw.startsWith("zh")) return "zh-CN"
|
|
86
|
+
return "en"
|
|
87
|
+
}
|
package/src/i18n/ja.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// 日本語の文言。状態語は体言止め、文はです・ます調で短く。
|
|
2
|
+
//
|
|
3
|
+
// キー集合は ./en.ts の `Key` で型付けされており、欠けても増えてもコンパイル
|
|
4
|
+
// エラーになる。製品名・Search / Fetch は英語のまま使う。
|
|
5
|
+
|
|
6
|
+
import type { Messages } from "./en.ts"
|
|
7
|
+
|
|
8
|
+
export const ja = {
|
|
9
|
+
// ---------- サイドバーの状態:完全な語と、幅が足りないときの短縮語 ----------
|
|
10
|
+
"state.loading": "読み込み中…",
|
|
11
|
+
"state.loadingShort": "読み込み中…",
|
|
12
|
+
"state.failed": "読み込み失敗",
|
|
13
|
+
"state.failedShort": "失敗",
|
|
14
|
+
"state.enabled": "有効",
|
|
15
|
+
"state.enabledShort": "有効",
|
|
16
|
+
"state.disabled": "無効",
|
|
17
|
+
"state.disabledShort": "無効",
|
|
18
|
+
"state.unpatched": "websearch 未引き継ぎ",
|
|
19
|
+
"state.unpatchedShort": "未引き継ぎ",
|
|
20
|
+
"state.missingKey": "APIキー未設定",
|
|
21
|
+
"state.missingKeyShort": "キー未設定",
|
|
22
|
+
|
|
23
|
+
// ---------- カード上の操作 ----------
|
|
24
|
+
"action.disable": "停止",
|
|
25
|
+
"action.enable": "有効化",
|
|
26
|
+
"action.release": "返上",
|
|
27
|
+
"action.retry": "再試行",
|
|
28
|
+
|
|
29
|
+
// ---------- デスクトップパネル ----------
|
|
30
|
+
"panel.tooltip.refresh": "使用量を更新",
|
|
31
|
+
"panel.loading": "使用量を読み込み中…",
|
|
32
|
+
"panel.label.on": "停止(ネイティブ検索に返上)",
|
|
33
|
+
"panel.label.off": "有効化(DeepSeek が引き継ぐ)",
|
|
34
|
+
"panel.label.warn": "ネイティブ検索に返上",
|
|
35
|
+
"panel.label.error": "再試行",
|
|
36
|
+
"panel.label.idle": "再試行",
|
|
37
|
+
|
|
38
|
+
// ---------- ホスト側の表示:コマンド、メニュー、トースト、ダイアログ ----------
|
|
39
|
+
"command.open": "DeepSeek: 使用量パネルを開く",
|
|
40
|
+
"command.toggle": "DeepSeek: 検索の引き継ぎを切り替え",
|
|
41
|
+
"menu.description": "検索使用量と引き継ぎスイッチ",
|
|
42
|
+
"toast.openSessionFirst": "先にセッションを開いてください",
|
|
43
|
+
"toast.statusMalformed": "状態データの形式が不正です",
|
|
44
|
+
"toast.modeMalformed": "モード切り替え結果の形式が不正です",
|
|
45
|
+
"dialog.title": "DeepSeek 検索",
|
|
46
|
+
"dialog.enable": "有効化",
|
|
47
|
+
"dialog.enableDesc": "組み込み websearch を引き継ぐ",
|
|
48
|
+
"dialog.disable": "停止",
|
|
49
|
+
"dialog.disableDesc": "組み込み websearch をホストに返上",
|
|
50
|
+
"dialog.refresh": "更新",
|
|
51
|
+
"dialog.refreshDesc": "状態と使用量を再読み込み",
|
|
52
|
+
|
|
53
|
+
// ---------- deepseek_mode の出力 ----------
|
|
54
|
+
"mode.report": "現在の検索バックエンド: {mode}(ソース: {source}){suffix}",
|
|
55
|
+
"mode.source.override": "deepseek_mode スイッチ(永続化済み)",
|
|
56
|
+
"mode.source.config": "設定ファイルの options.mode",
|
|
57
|
+
"mode.suffix.patched": " · 組み込み websearch は DeepSeek が処理",
|
|
58
|
+
"mode.suffix.notPatched": " · 組み込み websearch が見つからず、引き継げませんでした",
|
|
59
|
+
"mode.suffix.native": " · 組み込み websearch はネイティブのまま",
|
|
60
|
+
"mode.notFound":
|
|
61
|
+
"組み込み {tool} ツールが見つからないため、実行中は切り替えできません。" +
|
|
62
|
+
"設定ファイルで options.mode を「{mode}」にしてください。",
|
|
63
|
+
"mode.configCleared": "永続化スイッチを削除し、設定ファイルの値({mode})に戻しました。",
|
|
64
|
+
"mode.persisted":
|
|
65
|
+
"永続化しました: OpenCode を再起動しても {mode} のままです。" +
|
|
66
|
+
"設定ファイルの値に戻すには、deepseek_mode に mode: \"config\" を渡してください。",
|
|
67
|
+
"mode.statusOnly": "status は現在のモードを読むだけで、切り替えは行いません。",
|
|
68
|
+
"mode.invalid": "mode は status / deepseek / native / config のいずれかです。受信値: {raw}",
|
|
69
|
+
|
|
70
|
+
// ---------- 進捗と記録の通知 ----------
|
|
71
|
+
"progress.fetch": "DeepSeek Fetch 取得中: {url}",
|
|
72
|
+
"fetch.source": "出典: {url}",
|
|
73
|
+
"usage.reset": "ローカル統計をクリアしました。",
|
|
74
|
+
|
|
75
|
+
// ---------- deepseek_usage のレポート ----------
|
|
76
|
+
"usage.report.title": "DeepSeek 使用量(ローカル集計・成功リクエストで概算。現在のモード {mode}、単価 ¥{price}/1000回)",
|
|
77
|
+
"usage.report.line":
|
|
78
|
+
"{label}: 検索 {search} · 取得 {fetch} · 空/失敗 {skipped}(空結果 {empty} / 失敗 {failed})· 推定 {cost}",
|
|
79
|
+
"usage.report.note":
|
|
80
|
+
"注: 空結果と失敗は課金されません。請求は DeepSeek のアカウント側が正で、この集計は他のマシンや他ツールの呼び出しを含みません。",
|
|
81
|
+
"usage.label.today": "今日",
|
|
82
|
+
"usage.label.month": "今月",
|
|
83
|
+
"usage.label.total": "合計",
|
|
84
|
+
"usage.summary.line": "検索 {search} · 取得 {fetch} · 空/失敗 {skipped} · {cost}",
|
|
85
|
+
|
|
86
|
+
// ---------- エラー ----------
|
|
87
|
+
"error.missingKey":
|
|
88
|
+
"DeepSeek APIキーが未設定です。環境変数 DEEPSEEK_API_KEY を設定してください" +
|
|
89
|
+
"(PowerShell: [Environment]::SetEnvironmentVariable(\"DEEPSEEK_API_KEY\",\"sk-...\",\"User\"))。" +
|
|
90
|
+
"またはプラグイン options に \"apiKey\": \"{env:DEEPSEEK_API_KEY}\" を書き、opencode を再起動してください。",
|
|
91
|
+
"error.http.400":
|
|
92
|
+
"DeepSeek のリクエストパラメータが不正です(400){upstream}。検索語は 1〜128 文字、Fetch の URL は有効な http(s) 絶対 URL が必要です。",
|
|
93
|
+
"error.http.401": "DeepSeek APIキーが無効です(401){upstream}。DEEPSEEK_API_KEY 環境変数か options.apiKey を確認してください。",
|
|
94
|
+
"error.http.402": "DeepSeek アカウントの残高が不足しています(402)。失敗したリクエストは課金されません。チャージ後に再試行してください。",
|
|
95
|
+
"error.http.403": "DeepSeek Fetch は対象サイトのセキュリティポリシーに拒否されました(403){upstream}。{hint}",
|
|
96
|
+
"error.http.404": "DeepSeek はこのリンクの本文を抽出できませんでした(404){upstream}。リンクにアクセスできるか確認してください。{hint}",
|
|
97
|
+
"error.http.408": "DeepSeek リクエストがタイムアウトしました(408)。バックオフ再試行も失敗しました。しばらくしてから再試行してください。",
|
|
98
|
+
"error.http.413": "DeepSeek リクエストの本文が大きすぎます(413)。入力を短くしてください。",
|
|
99
|
+
"error.http.429":
|
|
100
|
+
"DeepSeek のレート制限に達しました(429。アカウント上限: Search 100 QPS / Fetch 25 QPS)。" +
|
|
101
|
+
"バックオフ再試行も失敗しました。しばらくしてから再試行してください。",
|
|
102
|
+
"error.http.5xx":
|
|
103
|
+
"DeepSeek のサーバーエラーです({status})。バックオフ再試行も失敗しました。" +
|
|
104
|
+
"一時的に options.mode を \"native\" にするとネイティブ検索を使えます。",
|
|
105
|
+
"error.http.other": "DeepSeek リクエストが失敗しました(HTTP {status}){upstream}",
|
|
106
|
+
"error.http.fetchHint": " このページには組み込み webfetch ツールを使えます。",
|
|
107
|
+
"error.parse": "DeepSeek が解析できないレスポンスを返しました(HTTP {status})。しばらくしてから再試行してください。",
|
|
108
|
+
"error.aborted": "DeepSeek リクエストはキャンセルされました。",
|
|
109
|
+
"error.timeout": "DeepSeek リクエストがタイムアウトしました({seconds} 秒)。再試行してください。",
|
|
110
|
+
"error.network": "{base} に接続できません(ネットワークエラー: {message})。ネットワークかプロキシの設定を確認してください。",
|
|
111
|
+
"error.validate.queryEmpty": "検索語が空です。DeepSeek Search には空でない query(1〜128 文字)が必要です。",
|
|
112
|
+
"error.validate.queryLong": "検索語が長すぎます({length} 文字、上限 {max})。短くして再試行してください。",
|
|
113
|
+
"error.validate.urlScheme": "無効な URL:「{url}」。DeepSeek Fetch は http/https の絶対 URL のみ対応します。",
|
|
114
|
+
"error.validate.urlLong": "URL が長すぎます({length} > {max} 文字)。",
|
|
115
|
+
"error.validate.urlHost": "URL にホスト名がありません:「{url}」。",
|
|
116
|
+
"error.validate.urlUserinfo": "URL にユーザー名/パスワード(userinfo)を含められません。",
|
|
117
|
+
"error.validate.urlParse": "URL を解析できません:「{url}」。",
|
|
118
|
+
"error.fetch.truncated": "[DeepSeek Fetch 切り詰め] 元の本文は {raw} 文字で、上限 {max} 文字を超えています。先頭 {max} 文字のみ保持しました。",
|
|
119
|
+
} satisfies Messages
|
|
120
|
+
|
|
121
|
+
/** 使用量行の階段:完全な行から最も短い行まで。各段は単体で完結する。 */
|
|
122
|
+
export const jaUsageForms: readonly string[] = [
|
|
123
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
124
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
125
|
+
"{label} Search {search} Fetch {fetch}",
|
|
126
|
+
"{label} Search {search} Fetch {fetch}",
|
|
127
|
+
"{label} {search}S {fetch}F {cost}",
|
|
128
|
+
"{label} {search}S {fetch}F",
|
|
129
|
+
"{label} {search}S",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
/** APIキー未設定のヒント階段:最後の段でも何を設定するかは残る。 */
|
|
133
|
+
export const jaHintForms: readonly string[] = [
|
|
134
|
+
"DEEPSEEK_API_KEY を設定して再起動",
|
|
135
|
+
"DEEPSEEK_API_KEY を設定",
|
|
136
|
+
"API KEY を設定",
|
|
137
|
+
"KEY 設定",
|
|
138
|
+
]
|
package/src/i18n/zh.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// 简体中文文案(现有界面文案的升格版,措辞尽量保持原样)。
|
|
2
|
+
//
|
|
3
|
+
// 键集合由 ./en.ts 的 `Key` 约束:缺键或多键都会编译失败。
|
|
4
|
+
|
|
5
|
+
import type { Messages } from "./en.ts"
|
|
6
|
+
|
|
7
|
+
export const zh = {
|
|
8
|
+
// ---------- 侧边栏状态:完整措辞与窄宽度下的短式 ----------
|
|
9
|
+
"state.loading": "正在读取…",
|
|
10
|
+
"state.loadingShort": "正在读取…",
|
|
11
|
+
"state.failed": "读取失败",
|
|
12
|
+
"state.failedShort": "读取失败",
|
|
13
|
+
"state.enabled": "已启用",
|
|
14
|
+
"state.enabledShort": "已启用",
|
|
15
|
+
"state.disabled": "已停用",
|
|
16
|
+
"state.disabledShort": "已停用",
|
|
17
|
+
"state.unpatched": "未接管内置 websearch",
|
|
18
|
+
"state.unpatchedShort": "未接管",
|
|
19
|
+
"state.missingKey": "未配置 API Key",
|
|
20
|
+
"state.missingKeyShort": "缺 API Key",
|
|
21
|
+
|
|
22
|
+
// ---------- 卡片上的可点击动作 ----------
|
|
23
|
+
"action.disable": "停用",
|
|
24
|
+
"action.enable": "启用",
|
|
25
|
+
"action.release": "交还",
|
|
26
|
+
"action.retry": "重试",
|
|
27
|
+
|
|
28
|
+
// ---------- 桌面面板 ----------
|
|
29
|
+
"panel.tooltip.refresh": "刷新用量",
|
|
30
|
+
"panel.loading": "正在读取用量…",
|
|
31
|
+
"panel.label.on": "停用(交还原生搜索)",
|
|
32
|
+
"panel.label.off": "启用(由 DeepSeek 接管)",
|
|
33
|
+
"panel.label.warn": "交还原生搜索",
|
|
34
|
+
"panel.label.error": "重试",
|
|
35
|
+
"panel.label.idle": "重试",
|
|
36
|
+
|
|
37
|
+
// ---------- 宿主 chrome:命令、菜单、toast、对话框 ----------
|
|
38
|
+
"command.open": "DeepSeek: 打开统计面板",
|
|
39
|
+
"command.toggle": "DeepSeek: 启用/停用搜索接管",
|
|
40
|
+
"menu.description": "搜索用量与接管开关",
|
|
41
|
+
"toast.openSessionFirst": "请先打开一个会话",
|
|
42
|
+
"toast.statusMalformed": "状态数据格式不符",
|
|
43
|
+
"toast.modeMalformed": "模式切换结果格式不符",
|
|
44
|
+
"dialog.title": "DeepSeek 搜索",
|
|
45
|
+
"dialog.enable": "启用",
|
|
46
|
+
"dialog.enableDesc": "接管内置 websearch",
|
|
47
|
+
"dialog.disable": "停用",
|
|
48
|
+
"dialog.disableDesc": "把内置 websearch 交还宿主",
|
|
49
|
+
"dialog.refresh": "刷新",
|
|
50
|
+
"dialog.refreshDesc": "重新读取状态与统计",
|
|
51
|
+
|
|
52
|
+
// ---------- deepseek_mode 输出 ----------
|
|
53
|
+
"mode.report": "当前搜索后端: {mode}(来源: {source}){suffix}",
|
|
54
|
+
"mode.source.override": "deepseek_mode 开关,已持久化",
|
|
55
|
+
"mode.source.config": "配置文件 options.mode",
|
|
56
|
+
"mode.suffix.patched": " · 内置 websearch 已由 DeepSeek 接管",
|
|
57
|
+
"mode.suffix.notPatched": " · 未找到内置 websearch 工具,实际未能接管",
|
|
58
|
+
"mode.suffix.native": " · 内置 websearch 保持原生",
|
|
59
|
+
"mode.notFound":
|
|
60
|
+
"未找到内置 {tool} 工具,无法在运行时切换。" +
|
|
61
|
+
'请改用配置文件把 options.mode 设为 "{mode}"。',
|
|
62
|
+
"mode.configCleared": "已清除持久化开关,回到配置文件设置({mode})。",
|
|
63
|
+
"mode.persisted":
|
|
64
|
+
"已持久化:重启 OpenCode 后仍为 {mode}。" +
|
|
65
|
+
'要恢复配置文件设置,调用 deepseek_mode 并传 mode: "config"。',
|
|
66
|
+
"mode.statusOnly": "status 只读取当前模式,不做切换。",
|
|
67
|
+
"mode.invalid": "mode 只能是 status / deepseek / native / config,收到:{raw}",
|
|
68
|
+
|
|
69
|
+
// ---------- 工具进度与记账提示 ----------
|
|
70
|
+
"progress.fetch": "DeepSeek Fetch 抓取中: {url}",
|
|
71
|
+
"fetch.source": "来源: {url}",
|
|
72
|
+
"usage.reset": "已清零本地统计。",
|
|
73
|
+
|
|
74
|
+
// ---------- deepseek_usage 报告 ----------
|
|
75
|
+
"usage.report.title": "DeepSeek 用量(本地统计,按成功请求估算;当前模式 {mode};单价 ¥{price}/1000 次)",
|
|
76
|
+
"usage.report.line":
|
|
77
|
+
"{label}: 搜索 {search} · 抓取 {fetch} · 空/失 {skipped}(空结果 {empty} / 失败 {failed})· 估算 {cost}",
|
|
78
|
+
"usage.report.note": "说明:空结果与失败请求不计费;DeepSeek 以账号侧账单为准,本统计不含其他机器或其他工具的调用。",
|
|
79
|
+
"usage.label.today": "今日",
|
|
80
|
+
"usage.label.month": "本月",
|
|
81
|
+
"usage.label.total": "累计",
|
|
82
|
+
"usage.summary.line": "搜索 {search} · 抓取 {fetch} · 空/失 {skipped} · {cost}",
|
|
83
|
+
|
|
84
|
+
// ---------- 错误信息 ----------
|
|
85
|
+
"error.missingKey":
|
|
86
|
+
"未配置 DeepSeek API Key:请设置环境变量 DEEPSEEK_API_KEY" +
|
|
87
|
+
'(PowerShell: [Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY","sk-...","User")),' +
|
|
88
|
+
'或在插件 options 中写 "apiKey": "{env:DEEPSEEK_API_KEY}",然后重启 opencode。',
|
|
89
|
+
"error.http.400":
|
|
90
|
+
"DeepSeek 请求参数无效(400){upstream}。搜索词需 1~128 字符;Fetch 的 URL 需为合法的 http(s) 绝对地址。",
|
|
91
|
+
"error.http.401": "DeepSeek API Key 无效(401){upstream}。请检查 DEEPSEEK_API_KEY 环境变量或 options.apiKey。",
|
|
92
|
+
"error.http.402": "DeepSeek 账户余额不足(402),失败请求不计费。请充值后重试。",
|
|
93
|
+
"error.http.403": "DeepSeek Fetch 被目标站点安全策略拒绝(403){upstream}。{hint}",
|
|
94
|
+
"error.http.404": "DeepSeek 无法提取该链接的正文(404){upstream}。请确认链接可访问。{hint}",
|
|
95
|
+
"error.http.408": "DeepSeek 请求超时(408),已退避重试一次仍失败。请稍后重试。",
|
|
96
|
+
"error.http.413": "DeepSeek 请求体过大(413)。请缩短输入。",
|
|
97
|
+
"error.http.429": "DeepSeek 触发限速(429,账号级 Search 100 QPS / Fetch 25 QPS),已退避重试一次仍失败。请稍后再试。",
|
|
98
|
+
"error.http.5xx":
|
|
99
|
+
"DeepSeek 服务端错误({status}),已退避重试一次仍失败。可把插件 options.mode 改为 \"native\" 暂用原生搜索。",
|
|
100
|
+
"error.http.other": "DeepSeek 请求失败(HTTP {status}){upstream}",
|
|
101
|
+
"error.http.fetchHint": " 可改用内置 webfetch 工具抓取该页面。",
|
|
102
|
+
"error.parse": "DeepSeek 返回了无法解析的响应(HTTP {status})。请稍后重试。",
|
|
103
|
+
"error.aborted": "DeepSeek 请求已取消。",
|
|
104
|
+
"error.timeout": "DeepSeek 请求超时({seconds} 秒),请重试。",
|
|
105
|
+
"error.network": "无法连接 {base}(网络错误:{message})。请检查网络或代理设置。",
|
|
106
|
+
"error.validate.queryEmpty": "搜索词为空:DeepSeek Search 需要非空 query(1~128 字符)。",
|
|
107
|
+
"error.validate.queryLong": "搜索词过长({length} 字符,上限 {max}),请精简后重试。",
|
|
108
|
+
"error.validate.urlScheme": "无效 URL:「{url}」。DeepSeek Fetch 仅支持 http/https 绝对地址。",
|
|
109
|
+
"error.validate.urlLong": "URL 过长({length} > {max} 字符)。",
|
|
110
|
+
"error.validate.urlHost": "URL 缺少主机名:「{url}」。",
|
|
111
|
+
"error.validate.urlUserinfo": "URL 不能包含用户名/密码(userinfo)。",
|
|
112
|
+
"error.validate.urlParse": "无法解析 URL:「{url}」。",
|
|
113
|
+
"error.fetch.truncated": "[DeepSeek Fetch 截断提示] 原文共 {raw} 字符,超出上限 {max},此处仅保留前 {max} 字符。",
|
|
114
|
+
} satisfies Messages
|
|
115
|
+
|
|
116
|
+
/** 用量行阶梯:从最完整到最紧凑;每一条都是完整的一行。 */
|
|
117
|
+
export const zhUsageForms: readonly string[] = [
|
|
118
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
119
|
+
"{label} Search {search} Fetch {fetch} {cost}",
|
|
120
|
+
"{label} Search {search} Fetch {fetch}",
|
|
121
|
+
"{label} Search {search} Fetch {fetch}",
|
|
122
|
+
"{label} {search}S {fetch}F {cost}",
|
|
123
|
+
"{label} {search}S {fetch}F",
|
|
124
|
+
"{label} {search}S",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
/** 缺 key 提示阶梯:最后一档仍然指明要设置什么。 */
|
|
128
|
+
export const zhHintForms: readonly string[] = [
|
|
129
|
+
"设置 DEEPSEEK_API_KEY 后重启",
|
|
130
|
+
"设置 API KEY 后重启",
|
|
131
|
+
"设置 API KEY",
|
|
132
|
+
"设置 KEY",
|
|
133
|
+
]
|