Skip to content

Fix/i18n add tools v2 v2 errors keys#2092

Open
7723qqq wants to merge 324 commits into
MoonshotAI:mainfrom
7723qqq:fix/i18n-add-toolsV2-v2Errors-keys
Open

Fix/i18n add tools v2 v2 errors keys#2092
7723qqq wants to merge 324 commits into
MoonshotAI:mainfrom
7723qqq:fix/i18n-add-toolsV2-v2Errors-keys

Conversation

@7723qqq

@7723qqq 7723qqq commented Jul 23, 2026

Copy link
Copy Markdown

Related Issue

Resolve #(issue_number)

Problem

What changed

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

wbxl2000 and others added 30 commits July 10, 2026 04:12
…otAI#1494)

* feat(tui): add Kimi WebBridge install entry to /plugins panel

Surface a hardcoded Kimi WebBridge entry at the top of the Official tab in the /plugins panel. Selecting it opens the WebBridge install page in the user's browser instead of going through the plugin install flow, since WebBridge is a browser extension plus local daemon rather than an installable plugin package.

* fix(tui): restrict WebBridge open-url shortcut to the pinned row

Match the hardcoded pinned WebBridge entry by object reference instead of by id. A curated or custom marketplace entry on the Third-party tab can legitimately reuse the kimi-webbridge id; routing by id hijacked Enter on those rows and opened the WebBridge page instead of installing. The Official tab still dedupes a same-id official catalog entry so the pinned row is not duplicated.

* fix(tui): label WebBridge plugins row as "open in browser"

The previous "webpage" status did not make it clear that selecting this row opens an external page rather than installing in-app. "open in browser" states the action directly and contrasts with the install label on regular plugin rows.

* test(tui): navigate past pinned WebBridge row in marketplace install tests

Two message-flow tests pressed Enter on the Official tab assuming index 0 was the Kimi Datasource entry. The hardcoded Kimi WebBridge row now leads that tab, so move down one row before installing.
Git Bash does not recognize .bat/.cmd extension. detect_shell_for() routes .bat/.cmd to cmd.exe /c, keeps Git Bash for other commands. Also adds chars_written=0 assertion for over-budget marker in output_truncate tests.
…shotAI#1521)

Merges upstream image-limits scoping with local Rust native image compression. Strategy: Rust handles pixel compute, TS handles policy (edge limits, byte budgets, env overrides). Resolved conflicts in core-impl.ts, read-media.ts, image-compress.ts by keeping native loader + adding upstream ImageLimits integration.
…oonshotAI#1508)

Integrate upstream image request-size-limits with the local Rust native
module architecture. Rust handles compute (pixel compression/crop), TS
handles policy (image size limits via ImageLimits + global config setters).

Key changes:
- Add @jsquash/webp wasm decoder for WebP format support
- Wire global config setters in KimiCore constructor and setRuntimeConfig
- ImageLimits falls back to global config layer when no per-instance config
- Native compress/crop fall through to TS path for unsupported formats (WebP)
…ry stack

Ensure all error types retry at least 5 times:
- DEFAULT_MAX_RETRY_ATTEMPTS: 3 -> 5 (main loop chatWithRetry)
- FAILED_RESUME_MAX_RETRIES: 3 -> 5 (subagent batch auto-recovery)
- Cap rate-limit individual backoff at 60s (was unbounded Infinity)
- Unify ±25% jitter on all backoff paths (generic, rate-limit, overload,
  compaction) via shared applyJitter; previously generic path used
  randomize:true (0-100% variance) which was inconsistent
This release includes:
1. 新增MCP模块支持,添加kimi-native-tools的Rust模块
2. 修复多个依赖项的安全漏洞,更新pnpm工作区依赖白名单
3. 优化会话存储和权限检查,添加会话ID安全校验
4. 改进错误处理和日志记录,防止回调崩溃影响主流程
5. 优化文件编辑和写入的符号链接逃逸防护
6. 新增图片格式错误处理和媒体剥离重传机制
7. 重构令牌估算逻辑,避免代码重复
8. 改进OAuth和MCP服务的错误处理和超时控制
9. 修复Windows平台的原生模块构建脚本
10. 优化CLI编辑器启动命令,避免shell注入风险
1. 将 kimi-web 的所有非首屏组件改为异步组件加载,减少初始打包体积
2. 对代码高亮依赖 cli-highlight 做动态引入并预加载,同时保留降级方案
3. 调整打包配置,启用代码分割并设置产物命名规则
1.  提取重试策略公共代码到独立模块,统一重试配置与退避算法
2.  修复代码高亮语言判断逻辑错误
3.  移除冗余的providerHandlesRetry配置项并更新相关测试
4.  补充多语言文案:任务复制相关、审批模块中文文案、任务停止按钮文案
5.  新增默认重试次数为5次并补充重试测试用例
1. 移除providerHandlesRetry配置,统一使用代理级重试
2. 新增i18n国际化支持,替换CLI硬编码文本
3. 重构重试策略常量与工具函数
4. 优化子代理批量调度的重试逻辑
1. 为CLI命令和选项添加i18n多语言支持,替换硬编码字符串为翻译函数
2. 修复环境变量访问的引号问题,避免特殊字符解析错误
3. 重构subagent重试逻辑,统一重试类型和错误提示文案
4. 优化测试用例的定时器处理逻辑,提升测试稳定性
1. 新增#/i18n导入别名,全局引入i18n国际化能力
2. 替换所有硬编码文本为多语言key,支持中英切换
3. 调整单步重试默认次数从3改为5
4. 修复subagent重试事件抑制逻辑
5. 配置测试环境默认语言为英文
6. 补充中文语言包完整翻译内容
将所有CLI子命令的选项、参数描述从硬编码字符串替换为多语言翻译函数调用,新增并补全了zh.ts和en.ts中的对应国际化词条
- 在AppState中新增locale字段存储当前语言设置
- 添加语言选择器对话框,支持英文/中文切换
- 将所有硬编码文本替换为i18n翻译函数调用
- 重构常量文件,将静态文本改为动态翻译函数
- 更新配置系统,支持读取和保存locale配置
- 适配所有测试用例,新增默认locale配置项
1.  新增了所有Slash命令的多语言文案
2.  将Agent Swarm进度组件、插件状态面板的硬编码文本替换为i18n调用
3.  实现根据TUI配置自动切换界面语言
1. 重构命令注册模块,将内置斜杠命令的描述改为多语言支持
2. 为多个TUI组件添加国际化翻译支持,包括弹窗、面板、帮助文档等
3. 优化导入路径,简化迁移命令的导入语句
4. 修复重复导入i18n的问题
将所有界面硬编码字符串替换为i18n翻译函数调用,统一管理多语言文案,包括对话框、面板、提示信息、状态文本等多处内容,提升应用的可本地化能力。
…I, TUI, and web UI

- Fix ZH locale key parity (1149/983 → 1375/1375, zero missing)
- Fix slashCommands path mismatch (tui.chrome.slashCommands → tui.slashCommands)
- Replace ~150 hardcoded English strings in ~35 CLI/TUI source files with t() calls
- Replace hardcoded strings in 5 web UI components (ServerAuthDialog, GoalStrip, CommandBar, Sheet, Dialog)
- Add datasource page to VitePress sidebar (EN + ZH)
- Fix i18n-related test failures (doctor, chalk guard, goal-completion, message-replay, kimi-tui-message-flow)
- goal-prompt.ts: replace 'Goal: no goal found.' with t() call
- run-prompt.ts: replace session not found and no model errors with t()
- run-shell.ts: replace hardcoded 'open' in URL hint with t()
- sub/server/run.ts: replace hardcoded banner labels (off/use --host/etc)
- sub/plugin-run-node.ts: replace KIMI_PLUGIN_ROOT error messages with t()
- sub/acp.ts: replace acp fatal error with t()
- en.ts/zh.ts: add 11 new i18n keys for CLI messages
…d config

- chip.ts: replace 'no matches'/'no files'/'no results'/'web result'/pluralize with t()
- truncated.ts: replace truncation hints with t()
- btw-panel.ts: replace 3 hardcoded English sentences with t()
- subagent-event-handler.ts: replace agent description fallback with t()
- kimi-tui.ts: replace session not found error with t()
- config.ts: replace INVALID_TUI_CONFIG_MESSAGE with t()
- en.ts/zh.ts: add 14 new i18n keys for TUI messages
… labels

- ChatPane.vue: replace 'User'/'Assistant' in copy output with t()
- ConversationPane.vue: replace tocUser/tocAssistant/tocTools with t()
- OpenInMenu.vue: replace 'No directory' with t()
- en/zh conversation.ts: add 6 new i18n keys
- Add getCronTasks method to KimiCore class (core-impl.ts) to satisfy CoreAPI interface
- Fix log.warn argument order in session/index.ts (message first, payload second)
- Add @chenglou/pretext dependency for kimi-web build
- Misc: i18n additions, vis web i18n, build config updates
7723qqq and others added 28 commits July 21, 2026 10:41
… apply code quality fixes

- Require concrete completionCriterion (min 10 chars) when creating goals via
  the model-facing CreateGoal tool; reject vague objectives that lack a
  verifiable check. The tool description now mirrors the v1 engine's stricter
  wording, and the goal service validates both max and min length.
- Fix parseVerdict to handle non-empty but unmarked verifier output without
  silently passing, wrap verifier subagent spawn in try/catch, and add the
  missing 'created' GoalChangeKind.
- Fix syntax error in miniDbQueryStore.test.ts (stray closing brace).
- Replace JSON.parse/stringify with structuredClone in config cloneRecord.
- Add workspace path traversal guard in transcript readColdRoster.
- Clean up plugin managed directory on remove.
- Route hook failures through EventBus instead of console.error.
- Move WebSocket registry removal into onClose to close the stale-entry window.
- Add dispose() to TranscriptService and deprecation notes to v1 goal files.
- Fix botched dispose merge in KimiWebviewProvider.
…breakdown

- Replace 120+ hardcoded English strings in agent-core-v2 tool output
  with t() calls (toolsV2.* namespace)
- Add inputTokensUsed / outputTokensUsed to goal budget tracking
  (was output-only, now counts all tokens with separate breakdown)
- Update goal injection and outcome-prompts display
- Files: 21 source files across i18n, agent-core-v2, and goal domain
# fix: i18n key path errors, locale drift, and TUI/CLI correctness fixes

## Summary

Static analysis of the fork found a cluster of user-facing bugs: several TUI
screens render raw i18n key paths instead of text, the Astron settings panel
is completely untranslated (and gets wiped by unrelated config saves), the
`/workflow` help prints `undefined`, and an 80 ms footer timer runs forever
once thinking effort is enabled.

All fixes are minimal, behavior-preserving except where the current behavior
is objectively wrong. Every `t()` key used in the touched files was
machine-verified to resolve in **both** `en` and `zh` runtime locales
(`locales/*.ts`), with placeholder parity.

## Bugs fixed

### 1. i18n key paths pointing at non-existent locations (raw keys shown in UI)

| File | Wrong prefix | Correct prefix | Count |
|---|---|---|---|
| `tui/commands/config.ts` | `tui.dialogs.config.configXxx` | `tui.messages.configXxx` | 41 |
| `migration/migration-screen.ts`, `migration/badge.ts` | `migration.X` | `tui.migration.X` | 34 |
| `tui/components/dialogs/coding-plan-config.ts` | `codingPlan.X` | `tui.codingPlan.X` | 12 |

The Rust translation engine falls back to returning the key itself, so the
config/migration/coding-plan screens currently display strings like
`tui.dialogs.config.configThemeSet` to users.

### 2. Astron settings panel untranslated + locale drift

`astron-settings.ts` references 14 keys under `tui.dialogs.astronSettings.*`
that exist in `locales/*.json` but were never synced into the runtime
`locales/*.ts` sources — the whole panel renders raw key paths. Also missing
in `*.ts`: `settingsSelector.astron/astronDesc` and
`messages.configAstronSaveFailed` (17 keys total, EN+ZH). Reverse drift:
`tui.chrome.footer.swarmPlan` existed only in `*.ts`; added to `*.json`.
`en.json/zh.json` ↔ `en.ts/zh.ts` are now fully in sync.

### 3. Malformed placeholder in zh locale

`zh unsupportedEffort` contained `{{arg}` (missing closing `}}`) — the value
would render literally. Fixed in both `zh.ts` and `zh.json`.

### 4. `/workflow` usage prints `undefined`

`workflow.ts` did `t('tui.slashCommands.workflowHelp') as Record<string,
string>` — `t()` returns a string, so every `wf.*` access was `undefined`.
Replaced with individual leaf-key calls (`workflowHelp.usage`, `.list`, ...).

### 5. `/discuss` prompt-structure injection

User-supplied roles/stances were interpolated into the quoted
`roleDescription`/`assignedStance` strings unescaped, so a `"` in a role name
corrupts the generated prompt. Now escapes `\` and `"` (and removes the dead
`safeName` variable that was computed but never used).

### 6. Changing theme/locale/editor wipes Astron settings

`currentTuiConfig()` hardcoded `astron: DEFAULT_TUI_CONFIG.astron`, so every
`saveTuiConfig` from the theme/locale/editor/update-preference flows reset
the user's Astron parameters to defaults. It is now async and seeds `astron`
from the persisted `tui.toml` (matching how `AstronSettingsComponent` itself
does load-modify-save).

### 7. `createI18n` ignores `initialLocale` when `noDetect` is set

`options.noDetect ? 'en' : (options.initialLocale ?? detectLocaleNode())`
made an explicit `initialLocale` lose to `noDetect`. Priority is now
`initialLocale ?? (noDetect ? 'en' : detectLocaleNode())`. Also exports the
previously instance-only `getMessages`/`translateBatch` at module level, and
fixes a JSDoc example referencing a non-existent key.

### 8. Footer pulse timer runs 12.5×/s forever

`syncPulseTimer(state.thinkingEffort !== 'off')` kept an 80 ms interval alive
permanently once thinking effort was enabled — constant re-renders while
idle. Now tied to actual activity: `thinkingEffort !== 'off' &&
streamingPhase !== 'idle'`.

### 9. Coding-plan editor accepts control keys as text

The input handler appended any non-Enter/Escape data to the field value, so
arrow keys / Tab / Ctrl combos leaked escape bytes (e.g. `\x1b[C`) into
config values. Now uses the codebase-standard `printableCha
fix: i18n key path errors, locale drift, and TUI/CLI correctness fixes
Route the remaining `kimi web` option descriptions (--port, --host,
--allowed-host, --allow-remote-shutdown, --allow-remote-terminals,
--dangerous-bypass-auth, --log-level, --debug-endpoints) through the
existing i18n keys so --help follows the configured locale. Port, host,
and log-level values are injected via interpolation from constants
instead of hardcoded literals.

Also centralize the Web Bridge URL in the app constants module, localize
the kimi-inspect debug-surface error screen title and buttons, and
translate two stray Chinese code comments in the VS Code app to English.
…nput validation

- Deduplicate ASTRON_MODEL_DEFS / ASTRON_PLATFORM_MODELS into single source
- Add astronThinking/astronSettings/astronReasoningEffortModelIds to
  OpenAILegacyOptions interface and implement enable_thinking +
  search_disable wire encoding in OpenAILegacyChatProvider.generate()
- Add temperature [0,2] and maxTokens bounds validation in TUI
  AstronSettingsComponent with error display
- Add pre-save validation in saveAstronSettings
- Add hourly system CA certificate refresh for xfyun.cn
- Add runTurnOverride to KimiCoreOptions (fix pre-existing TS error)
- Fix 3 pre-existing syntax errors (missing closing braces) in
  agent-core-v2 test files
- Add i18n keys for validation error messages (zh/en)
- Add 5 unit tests for astron thinking encoding
These thin bridges re-export the kosong contract types so that
v2 domain modules (goal judge, compaction) can import them
through the #/app package-import path used by Node.js subpath
imports resolution.
The i18n singleton was initialized via detectLocaleNode() (env vars only)
before tui.toml was loaded. The loaded locale was never propagated back,
causing tips and commands to always show in English regardless of the
locale setting in tui.toml.
The i18n singleton was initialized via detectLocaleNode() (env vars only)
before tui.toml was loaded. The loaded locale was never propagated back,
causing tips and commands to always show in English.
Module-level t() calls capture the English default before tui.toml
locale is loaded. Replace NO_ACTIVE_SESSION_MESSAGE and
LLM_NOT_SET_MESSAGE with getNoActiveSessionMessage() and
getLlmNotSetMessage() that call t() lazily.
Module-top-level t() calls were evaluated at import time, before the
tui.toml locale is applied at startup, freezing those strings to the
English default. Convert the remaining module-level translations
(selector markers, dialog copy, footer tips, prompts, feedback status)
to lazy getters, and memoize the footer/working tip rotation per locale.

Add a guard test that forbids evaluating t()/translateBatch() in
module-top-level declarations so the regression cannot return.
The embedded Astron (iFlytek Coding Plan) model list hardcoded
supportEfforts to undefined for every model, so the TUI effort picker
only offered thinking on/off. The runtime already sends reasoning_effort
(high/max) for GLM-5.2 and DeepSeek-V4-Pro/Flash, so declare those levels
for exactly those models; all other Astron models stay on/off only.
A missing zh key silently falls back to English at runtime, and nothing
caught it: zh was a free object literal, not constrained to en's shape.
Add a LocaleMessages type derived from en and apply it to zh via
`satisfies`, plus a locale-parity test that lists any missing/stale keys.
zh currently matches en exactly, so both pass with no translation changes.
These were full vendored dumps of upstream projects (kimi-code 0.19.0,
MiMo-Code, opencode, codex) totaling ~16.6k files. They are not part of
this repo and their nested .oxlintrc.json broke `pnpm run lint` config
parsing. Drop them and gitignore the path.
- i18n-shared: cast the type-safe key to string when forwarding to the
  string-typed engine functions, avoiding TS2589 (excessively deep
  instantiation of the recursive TranslationKey path type) inside the
  generic createI18n factories; drop the type argument on the any-typed
  React useState (TS2347).
- kimi-code i18n: alias the imported generic TranslationKey so the local
  applied re-export no longer clashes with it (TS2440/TS2314).
background-install.ts was a refactor leftover — imported nowhere and
partially duplicating preflight.ts helpers. Its stale imports of
non-exported preflight members were contributing typecheck errors.
Merge upstream/main bringing in the official v0.29.0 release changes:
- ACP thinking effort levels
- Custom agent files with sub-agent restrictions
- Global tool gating
- Host fs:content endpoint
- Video prompt attachment without extra round trip
- System prompt override
- Agent lifecycle events
- Model thinking effort fixes
- Provider catalog import improvements
- Config env override persistence fixes
- Various bug fixes and improvements

Re-applied local fixes:
- Kimi provider 128k completion budget ceiling
- Slash commands i18n translation
…ound

These keys are consumed by background/index.ts and session/index.ts
in agent-core, but were missing from en.ts / zh.ts. Without them the
t() fallback in packages/i18n-shared/src/core.ts returned the raw key
string (e.g. 'toolsV2.abort.abortedByUser') to users.

en: 'Interrupted by user' / 'Main agent was not found'
zh: '被用户中断' / '未找到主 Agent'

Corresponding .json files regenerated via pnpm generate:locale-json.
@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25bac24

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@moonshot-ai/kimi-code Minor
@moonshot-ai/agent-core Minor
@moonshot-ai/kimi-code-sdk Patch
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/i18n-shared Minor
@moonshot-ai/kap-server Patch
@moonshot-ai/kimi-web Patch
kimi-code Patch
@moonshot-ai/minidb Minor
@moonshot-ai/acp-adapter Patch
@moonshot-ai/migration-legacy Patch
@moonshot-ai/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25bac24b47

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (nativeModule) return nativeModule;
// eslint-disable-next-line @typescript-eslint/no-require-imports
try {
const mod = require('@moonshot-ai/kimi-native-tools') as NativeModule;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Load the native translator with createRequire

In the ESM CLI (dist/main.mjs / tsx dev), there is no global require, so the first translation call catches a ReferenceError here instead of loading the installed @moonshot-ai/kimi-native-tools; the fallback path then either reports the native package as unavailable or hits the same unbound require again. Because t() is used while constructing the top-level Commander program, normal CLI startup/help can fail before any command runs even when the optional native dependency is present.

Useful? React with 👍 / 👎.

Comment thread flake.nix
@@ -65,8 +65,10 @@
./packages/acp-adapter
./packages/agent-core
./packages/agent-core-v2
./packages/i18n

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the omitted workspaces to flake.nix

This update adds new root workspaces via the packages/* glob, but flake.nix still omits packages/i18n-shared and packages/kimi-agent from workspacePaths/workspaceNames even though apps/kimi-code depends on both with workspace:^. Nix builds therefore drop their sources and cannot fetch those workspace dependencies through pnpmConfigHook; add both paths and package names to the flake lists.

AGENTS.md reference: AGENTS.md:L40-L44

Useful? React with 👍 / 👎.

Comment on lines +8 to +9
import { loadRuntimeConfigSafe, resolveConfigPath, resolveKimiHome } from '@moonshot-ai/agent-core';
import type { RunTurnOverride } from '@moonshot-ai/agent-core';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Rust engine config behind the SDK boundary

This new CLI module reaches directly into @moonshot-ai/agent-core to read runtime config, which couples apps/kimi-code back to the core package instead of using the SDK-facing surface. That breaks the app/core layering boundary and makes future SDK or v2 engine changes harder to contain; move this behind @moonshot-ai/kimi-code-sdk or an app-local config abstraction.

AGENTS.md reference: apps/kimi-code/AGENTS.md:L45-L45

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants