chore: merge dev into v2 (#35962)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: James Long <longster@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Dustin Deus <deusdustin@gmail.com>
Co-authored-by: starptech <starptech@starptechs-MBP.fritz.box>
Co-authored-by: Frank <frank@anoma.ly>
Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <little-frank@opencord.local>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Dax <mail@thdxr.com>
Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com>
Co-authored-by: Jay <53023+jayair@users.noreply.github.com>
Co-authored-by: Brendan Allan <git@brendonovich.dev>
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
Co-authored-by: runvip <164729189+runvip@users.noreply.github.com>
Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
Co-authored-by: Jack <jack@anoma.ly>
Co-authored-by: opencode <opencode@sst.dev>
Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com>
Co-authored-by: Julian Coy <julian@ex-machina.co>
Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com>
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
Co-authored-by: Kit Langton <kit.langton@gmail.com>
Co-authored-by: Simon Klee <hello@simonklee.dk>
Co-authored-by: Jay <air@live.ca>
Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com>
Co-authored-by: James Long <jlongster@users.noreply.github.com>
Co-authored-by: 冯基魁 <56265583+fengjikui@users.noreply.github.com>
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-07-08 17:58:55 -05:00
committed by GitHub
co-authored by opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> James Long Aiden Cline Dustin Deus starptech Frank Luke Parker opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 Aiden Cline Dax usrnk1 Jay Brendan Allan Brendan Allan runvip Shoubhit Dash Jack opencode Aarav Sareen Julian Coy Vladimir Glafirov Adam Kit Langton Simon Klee Jay David Hill James Long 冯基魁 Aiden Cline
parent 2347f4d7b4
commit 687dbba6a3
150 changed files with 8943 additions and 728 deletions
+168
View File
@@ -0,0 +1,168 @@
import { describe, expect, test } from "bun:test"
import {
findDrift,
glossaryFile,
modelVariants,
parseTranslationArgs,
runPool,
sessionIDFromEvents,
sessionModels,
targetFiles,
textFromEvents,
translationConfig,
unexpectedChanges,
} from "./translate-app"
describe("translate app", () => {
test("parses one locale with the public model defaults", () => {
expect(parseTranslationArgs(["fr"])).toEqual({
target: "fr",
concurrency: 1,
model: "opencode/gpt-5.5",
variant: "xhigh",
dryRun: false,
check: false,
help: false,
})
})
test("parses all locales with bounded concurrency overrides", () => {
expect(
parseTranslationArgs([
"all",
"--concurrency",
"7",
"--model",
"opencode/gpt-5.4",
"--variant",
"high",
"--dry-run",
]),
).toEqual({
target: "all",
concurrency: 7,
model: "opencode/gpt-5.4",
variant: "high",
dryRun: true,
check: false,
help: false,
})
})
test("rejects unsupported targets and invalid concurrency", () => {
expect(() => parseTranslationArgs(["en"])).toThrow("Unknown locale")
expect(() => parseTranslationArgs(["fr", "de"])).toThrow("one locale")
expect(() => parseTranslationArgs(["all", "--concurrency", "0"])).toThrow("positive integer")
})
test("parses fresh-process parity checks without requesting translation", () => {
expect(parseTranslationArgs(["fr", "--check"]).check).toBe(true)
})
test("limits each locale to its app surfaces", () => {
expect(targetFiles("fr")).toEqual([
"packages/app/src/i18n/fr.ts",
"packages/ui/src/i18n/fr.ts",
"packages/desktop/src/renderer/i18n/fr.ts",
])
expect(targetFiles("tr")).toEqual(["packages/app/src/i18n/tr.ts", "packages/ui/src/i18n/tr.ts"])
})
test("maps product locale codes to their glossaries", () => {
expect(glossaryFile("fr")).toBe(".opencode/glossary/fr.md")
expect(glossaryFile("zh")).toBe(".opencode/glossary/zh-cn.md")
expect(glossaryFile("zht")).toBe(".opencode/glossary/zh-tw.md")
})
test("finds key and placeholder drift", () => {
expect(
findDrift(
{ keep: "Hello {{name}}", missing: "Missing", changed: "{{one}} {{two}}" },
{ keep: "Bonjour {{name}}", extra: "Extra", changed: "{{one}}" },
),
).toEqual({ missing: ["missing"], extra: ["extra"], placeholders: ["changed"] })
})
test("runs work with the requested maximum concurrency", async () => {
const active = new Set<number>()
const peaks: number[] = []
const result = await runPool([1, 2, 3, 4, 5], 2, async (item) => {
active.add(item)
peaks.push(active.size)
await Bun.sleep(5)
active.delete(item)
return item * 2
})
expect(result).toEqual([2, 4, 6, 8, 10])
expect(Math.max(...peaks)).toBe(2)
})
test("reads the actual model and variant from the completed session", () => {
expect(sessionIDFromEvents('shared: https://example.test\n{"type":"step_start","sessionID":"ses_test"}\n')).toBe(
"ses_test",
)
expect(
sessionModels({
messages: [
{ info: { role: "user" } },
{
info: {
role: "assistant",
providerID: "opencode",
modelID: "gpt-5.5",
variant: "xhigh",
},
},
],
}),
).toEqual([{ model: "opencode/gpt-5.5", variant: "xhigh" }])
expect(
textFromEvents(
'shared: https://example.test\n{"type":"text","sessionID":"ses_test","part":{"text":"finished"}}\n',
),
).toBe("finished")
})
test("resolves variants from verbose model output", () => {
const output = `opencode/other
{"variants":{}}
opencode/gpt-5.5
{"variants":{"high":{"reasoningEffort":"high"},"xhigh":{"reasoningEffort":"xhigh"}}}
opencode/next
{"variants":{}}
`
expect(modelVariants(output, "opencode/gpt-5.5")).toEqual({
high: { reasoningEffort: "high" },
xhigh: { reasoningEffort: "xhigh" },
})
})
test("disables side effects and scopes edits for the translation agent", () => {
const config = translationConfig("translate-app-fr", "opencode/gpt-5.5", ["packages/app/src/i18n/fr.ts"])
expect(config.share).toBe("disabled")
expect(config.formatter).toBe(false)
expect(config.lsp).toBe(false)
expect(config.agent["translate-app-fr"].permission.edit).toEqual({
"*": "deny",
"packages/app/src/i18n/fr.ts": "allow",
})
})
test("detects edits outside the locale targets", () => {
expect(
unexpectedChanges(
{ "script/translate-app.ts": "before" },
{
"script/translate-app.ts": "before",
"packages/app/src/i18n/fr.ts": "translated",
"packages/app/src/app.tsx": "unexpected",
},
["packages/app/src/i18n/fr.ts"],
),
).toEqual(["packages/app/src/app.tsx"])
expect(unexpectedChanges({ "already-dirty.ts": "before" }, { "already-dirty.ts": "after" }, [])).toEqual([
"already-dirty.ts",
])
})
})