opencode-translate 2.0.3 → 2.0.4
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 +7 -0
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,6 +93,11 @@ If replies translate but your own prompt still looks untranslated in the **Web U
|
|
|
93
93
|
composer input even when `text` contained the English translation. The prompt hook now synchronizes that presentation
|
|
94
94
|
field. This applies to newly admitted prompts; it does not rewrite presentation metadata on older messages.
|
|
95
95
|
|
|
96
|
+
For the Question tool, OpenCode can freeze the provider-owned question arrays. Versions up to 2.0.3 tried to mutate
|
|
97
|
+
those arrays and fell back to English even after obtaining a valid translation. The before-tool hook now translates a
|
|
98
|
+
copy and replaces `event.input`, preserving the original provider data. Already pending questions need a new tool
|
|
99
|
+
invocation to pick up this fix.
|
|
100
|
+
|
|
96
101
|
OpenCode 2.0.3 also normalizes the legacy `"plugin": [["package", { ...options }]]` tuple syntax; that syntax alone
|
|
97
102
|
does not prevent this plugin from loading. The `plugins` object form shown above is the recommended v2 format.
|
|
98
103
|
Make sure the configuration is a complete JSON/JSONC object, including its opening `{`.
|
|
@@ -188,6 +193,8 @@ OPENCODE_BINARY=/path/to/opencode OPENCODE_TRANSLATE_REQUIRE_SESSION=0 bun run t
|
|
|
188
193
|
Tests include OpenCode's actual native protocol parsers. The real-host smoke test loads the built plugin, creates and
|
|
189
194
|
rotates a test credential in an isolated SQLite database, checks bilingual persisted messages and English-only model
|
|
190
195
|
requests, and restarts the server to verify recovery. It does not use your live server, credentials, or paid models.
|
|
196
|
+
It also executes the real Question tool, checks translated form fields, submits selected options and a Korean custom
|
|
197
|
+
answer, and verifies that the next model request contains the original English questions and English answers.
|
|
191
198
|
CI covers both configuration formats and both generation paths. The publish workflow tests the candidate before
|
|
192
199
|
publishing, then installs the exact version from npm in OpenCode before creating its GitHub release.
|
|
193
200
|
|
package/dist/index.js
CHANGED
|
@@ -300,13 +300,16 @@ async function registerQuestionHooks(ctx, state, translator) {
|
|
|
300
300
|
const lang = await state.language(event.sessionID);
|
|
301
301
|
if (!lang)
|
|
302
302
|
return;
|
|
303
|
-
const
|
|
303
|
+
const args = event.input;
|
|
304
|
+
const original = snapshotQuestions(args);
|
|
305
|
+
const translated = { ...args, questions: snapshotQuestions(args) };
|
|
304
306
|
try {
|
|
305
307
|
await ctx.storage.set(`questions/${event.sessionID}/${event.id}`, JSON.stringify({ questions: original }));
|
|
306
|
-
await translateQuestionArgs(
|
|
308
|
+
await translateQuestionArgs(translated, (texts) => translator.texts(texts, LLM_LANGUAGE, lang));
|
|
309
|
+
event.input = translated;
|
|
307
310
|
snapshots.set(`${event.sessionID}/${event.id}`, {
|
|
308
311
|
original,
|
|
309
|
-
translated: snapshotQuestions(
|
|
312
|
+
translated: snapshotQuestions(translated),
|
|
310
313
|
userLanguage: lang
|
|
311
314
|
});
|
|
312
315
|
if (snapshots.size > 1000)
|
package/package.json
CHANGED