opencode-translate 1.0.7 → 2.0.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/README.md +77 -6
- package/dist/index.js +634 -2032
- package/index.d.ts +2 -2
- package/package.json +6 -13
package/README.md
CHANGED
|
@@ -22,6 +22,10 @@ This plugin lets you write in your language while the model works in English —
|
|
|
22
22
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
25
|
+
Version 2 of this plugin uses OpenCode's **v2 public plugin API**. The verified release is OpenCode **2.0.3**.
|
|
26
|
+
For OpenCode v1, use `opencode-translate@1`.
|
|
27
|
+
Start a fresh v2 session when upgrading: v1 activation metadata and historical bilingual trailers are not migrated.
|
|
28
|
+
|
|
25
29
|
```bash
|
|
26
30
|
bun add -g opencode-translate
|
|
27
31
|
```
|
|
@@ -32,16 +36,23 @@ Add to `~/.config/opencode/opencode.jsonc`:
|
|
|
32
36
|
|
|
33
37
|
```jsonc
|
|
34
38
|
{
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
39
|
+
"$schema": "https://opencode.ai/config.json",
|
|
40
|
+
"plugins": [
|
|
41
|
+
{
|
|
42
|
+
"package": "opencode-translate",
|
|
43
|
+
"options": {
|
|
44
|
+
"model": "openai/gpt-5.4-mini", // model to use for translation
|
|
45
|
+
"variant": "minimal", // optional model variant / thinking effort
|
|
46
|
+
"lang": "Korean" // language you speak
|
|
47
|
+
}
|
|
48
|
+
}
|
|
41
49
|
]
|
|
42
50
|
}
|
|
43
51
|
```
|
|
44
52
|
|
|
53
|
+
Quit and restart OpenCode after changing the plugin configuration. For a local build, run `bun install && bun run build`
|
|
54
|
+
and set `package` to the absolute **directory** `/path/to/opencode-translate/dist`.
|
|
55
|
+
|
|
45
56
|
## Usage
|
|
46
57
|
|
|
47
58
|
Prefix any message with `$en` to activate translation for that session.
|
|
@@ -52,6 +63,66 @@ $en 프로젝트 루트의 package.json을 읽고 요약해줘
|
|
|
52
63
|
|
|
53
64
|
All subsequent messages in the same session are translated automatically — no need to repeat `$en`.
|
|
54
65
|
|
|
66
|
+
- Your original message and its English translation remain visible in the transcript.
|
|
67
|
+
- English assistant text streams normally; a translated Markdown section is appended when the text segment completes.
|
|
68
|
+
- Both the **terminal and web UI** display the same persisted bilingual assistant text. No UI-specific plugin is needed.
|
|
69
|
+
- Question forms are translated, with selected labels and custom answers converted back to English for the model.
|
|
70
|
+
- Translation activates only in root sessions. Its state survives plugin/server restarts.
|
|
71
|
+
|
|
72
|
+
Before model requests, the plugin removes its recorded display translations from context. It does not remove arbitrary
|
|
73
|
+
Markdown based on its appearance. On inbound translation failure, the original prompt is sent unchanged; on outbound
|
|
74
|
+
failure, the English response is retained with a translation-unavailable notice.
|
|
75
|
+
|
|
76
|
+
## Authentication
|
|
77
|
+
|
|
78
|
+
Connect the translation model's provider in **OpenCode itself**. Translation uses the public `ctx.generate.text()` API,
|
|
79
|
+
so OpenCode owns provider selection, model variants, API keys, SQLite credentials, and OAuth refresh/persistence.
|
|
80
|
+
The plugin does not read `auth.json`/`auth-v2.json`, query the credential database, or maintain separate tokens.
|
|
81
|
+
Provider and OAuth support for the translation model is the support available in your OpenCode installation.
|
|
82
|
+
|
|
83
|
+
## Inline reply support
|
|
84
|
+
|
|
85
|
+
V2 has no `experimental.text.complete` hook or public display-only message append operation. Inline translations use
|
|
86
|
+
`session.hook("http.response", ...)` with adapters for these **main-chat response protocols**:
|
|
87
|
+
|
|
88
|
+
| Protocol | Recognized endpoint | Support |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| OpenAI Responses, including Codex | `…/responses` | SSE text deltas and final snapshots |
|
|
91
|
+
| OpenAI Chat Completions and compatible providers | `…/chat/completions` | SSE text choices |
|
|
92
|
+
| Anthropic Messages | `…/messages` | SSE text blocks |
|
|
93
|
+
| Gemini / Vertex Gemini | `…:streamGenerateContent` | SSE non-thinking text |
|
|
94
|
+
|
|
95
|
+
Unknown endpoints, non-SSE responses, and binary protocols such as Bedrock Converse pass through unchanged with a server
|
|
96
|
+
log message. They still support inbound/question translation when the translation model is available through OpenCode.
|
|
97
|
+
Reasoning, tool calls, images, and other non-text outputs are not translated.
|
|
98
|
+
|
|
99
|
+
**Transport:** OpenCode routes sessions through HTTP when HTTP hooks are registered. Loading this plugin therefore
|
|
100
|
+
disables the session WebSocket fast path in its location, including sessions that have not activated `$en`.
|
|
101
|
+
Translations add latency at text-completion boundaries and use additional model requests. Their usage is separate from
|
|
102
|
+
the primary model's reported token counts.
|
|
103
|
+
|
|
104
|
+
## Development and verification
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
bun install
|
|
108
|
+
bun run check:ci
|
|
109
|
+
bun run typecheck
|
|
110
|
+
bun run knip
|
|
111
|
+
bun test
|
|
112
|
+
bun run build
|
|
113
|
+
bun run test:package
|
|
114
|
+
|
|
115
|
+
# Requires Node 24 and an OpenCode v2 binary; uses an isolated server and fake provider.
|
|
116
|
+
OPENCODE_BINARY=/path/to/opencode bun run test:host
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Tests include OpenCode's actual native protocol parsers. The real-host smoke test loads the built plugin, creates and
|
|
120
|
+
rotates a test credential in an isolated SQLite database, checks bilingual persisted messages and English-only model
|
|
121
|
+
requests, and restarts the server to verify recovery. It does not use your live server, credentials, or paid models.
|
|
122
|
+
|
|
123
|
+
The old `opencode2 v0.0.0-dev-18322` binary does not pass this migration's host smoke test. Use the verified 2.0.3 release
|
|
124
|
+
rather than assuming that any binary named `opencode2` exposes the current plugin API.
|
|
125
|
+
|
|
55
126
|
## Options
|
|
56
127
|
|
|
57
128
|
| Option | Type | Default | Description |
|