Add Host-global thinking and reply language controls.

Inject systemPrompt sections from Netx Ops settings so every preset can switch CoT and final-reply language without changing API/alarm lang.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-15 20:15:54 +08:00
parent 53c47fbc6a
commit d52c05e774
14 changed files with 652 additions and 25 deletions

View file

@ -0,0 +1,52 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
import {
languageFromLocale,
normalizeReplyLanguage,
normalizeThinkingLanguage,
replyInstruction,
resolveThinkingLanguage,
thinkingInstruction,
thinkingReminder,
} from '../src/netx/model-language.ts'
test('normalizeThinkingLanguage accepts aliases and defaults to auto', () => {
assert.equal(normalizeThinkingLanguage(undefined), 'auto')
assert.equal(normalizeThinkingLanguage('zh'), 'zh-CN')
assert.equal(normalizeThinkingLanguage('zh-CN'), 'zh-CN')
assert.equal(normalizeThinkingLanguage('en-US'), 'en')
assert.equal(normalizeThinkingLanguage('nope'), 'auto')
})
test('normalizeReplyLanguage accepts aliases and defaults to follow-user', () => {
assert.equal(normalizeReplyLanguage(undefined), 'follow-user')
assert.equal(normalizeReplyLanguage('auto'), 'follow-user')
assert.equal(normalizeReplyLanguage('zh-CN'), 'zh')
assert.equal(normalizeReplyLanguage('english'), 'en')
})
test('resolveThinkingLanguage follows locale when auto', () => {
assert.equal(resolveThinkingLanguage('auto', 'zh-CN'), 'zh-CN')
assert.equal(resolveThinkingLanguage('auto', 'en-US'), 'en')
assert.equal(resolveThinkingLanguage('en', 'zh-CN'), 'en')
assert.equal(resolveThinkingLanguage('auto', 'de-DE'), 'en')
})
test('languageFromLocale covers chinese and english tags', () => {
assert.equal(languageFromLocale('zh-Hans-CN'), 'zh-CN')
assert.equal(languageFromLocale('en'), 'en')
assert.equal(languageFromLocale(''), undefined)
})
test('thinkingInstruction and reminder mention the target language', () => {
const instruction = thinkingInstruction('zh-CN')
assert.match(instruction, /Simplified Chinese/)
assert.match(thinkingReminder('en'), /English/)
})
test('replyInstruction is empty for follow-user and forces otherwise', () => {
assert.equal(replyInstruction('follow-user'), '')
assert.match(replyInstruction('en'), /English/)
assert.match(replyInstruction('zh'), /简体中文/)
})