Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(i18n): 补三处扫描盲区,修 URL/邮箱/拉丁词边界与 baseline severity 盲点

Dash8ecdbd699e23
diff --git a/apps/desktop/src/main/__tests__/applicationMenuLabels.test.ts b/apps/desktop/src/main/__tests__/applicationMenuLabels.test.ts
new file mode 100644
index 0000000000..bed52aef05
--- /dev/null
+++ b/apps/desktop/src/main/__tests__/applicationMenuLabels.test.ts
@@ -0,0 +1,132 @@
+/**
+ * 原生应用菜单四语标签的术语门禁。
+ *
+ * 为什么需要单独一个测试:`scripts/check-i18n-glossary.mjs` 只读 renderer 的 locale
+ * JSON,扫不到这份手写 TS catalog。引入术语表那轮它就整个漏掉了——zh-CN 的 `issues`
+ * 还写着「议题」(Issue 的禁用译法),三语的 `settings` / `checkForUpdates` 还带着
+ * ASCII 三点省略号,而这是 macOS 上常驻屏幕顶端的菜单栏,比大多数界面文案更显眼。
+ *
+ * 判定逻辑复用 scripts/shared/glossary-rules.mjs,与根门禁、mobile 影子 catalog 同一套,
+ * 避免三处各写一份规则后悄悄漂移。
+ */
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+import { describe, expect, it } from 'vitest';
+
+import {
+ ELLIPSIS_LOCALES,
+ HALFWIDTH_PUNCT_LOCALES,
+ findCaseMismatch,
+ findHalfWidthPunct,
+ hasAsciiEllipsis,
+ makeExemptChecker,
+ normalizeForPunctuation,
+ occursIn,
+ stripNonProse,
+ WORD_BOUNDARY,
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore -- 共享规则是 .mjs,没有类型声明;这里只用它做断言
+} from '../../../../../scripts/shared/glossary-rules.mjs';
+
+import { APPLICATION_MENU_LABELS } from '../applicationMenuLabels';
+
+const REPO_ROOT = resolve(__dirname, '../../../../..');
+
+interface GlossaryTerm {
+ id: string;
+ status: 'decided' | 'proposed';
+ en: string;
+ translations?: Record<string, string>;
+ forbidden?: Record<string, (string | { text: string; whenEn: string })[]>;
+ exempt?: string[];
+ checkCase?: boolean;
+}
+
+const glossary = JSON.parse(
+ readFileSync(resolve(REPO_ROOT, 'i18n/glossary.json'), 'utf8'),
+) as { locales: string[]; sourceLocale: string; terms: GlossaryTerm[] };
+
+/** 摊平成 (locale, key, value)。key 形态与根门禁一致,便于 exempt 复用同一套写法。 */
+const entries = Object.entries(APPLICATION_MENU_LABELS).flatMap(([locale, labels]) =>
+ Object.entries(labels).map(([key, value]) => ({
+ locale,
+ key: `desktop-menu:${key}`,
+ value: value as string,
+ })),
+);
+
+/** key → 英文源文案,供条件禁用按英文源判断。 */
+const sourceByKey = new Map(
+ entries.filter((e) => e.locale === glossary.sourceLocale).map((e) => [e.key, e.value]),
+);
+
+describe('原生应用菜单标签符合术语表', () => {
+ it('摊平后覆盖四种语言', () => {
+ const locales = new Set(entries.map((e) => e.locale));
+ expect([...locales].sort()).toEqual([...glossary.locales].sort());
+ expect(entries.length).toBeGreaterThan(0);
+ });
+
+ it('不使用术语表的禁用译法', () => {
+ const violations: string[] = [];
+ const notes: string[] = [];
+ for (const term of glossary.terms) {
+ const isExempt = makeExemptChecker(term.exempt);
+ for (const { locale, key, value } of entries) {
+ if (isExempt(key)) continue;
+ for (const entry of term.forbidden?.[locale] ?? []) {
+ const bad = typeof entry === 'string' ? entry : entry.text;
+ const whenEn = typeof entry === 'string' ? null : entry.whenEn;
+ if (!occursIn(stripNonProse(value), bad)) continue;
+ if (whenEn) {
+ const source = sourceByKey.get(key);
+ const re = new RegExp(
+ `(?<![${WORD_BOUNDARY}])${whenEn.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}s?(?![${WORD_BOUNDARY}])`,
+ 'i',
+ );
+ if (!source || !re.test(stripNonProse(source))) continue;
+ }
+ const line = `${locale} ${key}: 「${bad}」(${term.en})— ${value}`;
+ // proposed 只提示不阻断,与根门禁的分级一致:那些术语还没拍板,
+ // 但它们在本 catalog 的命中数同样该出现在讨论材料里。
+ if (term.status === 'decided') violations.push(line);
+ else notes.push(line);
+ }
+ }
+ }
+ if (notes.length > 0) console.warn(`[menu-glossary] 待裁决术语命中:\n${notes.join('\n')}`);
+ expect(violations, `原生菜单命中禁用译法:\n${violations.join('\n')}`).toEqual([]);
+ });
+
+ it('保留英文的术语大小写形态统一', () => {
+ const violations: string[] = [];
+ for (const term of glossary.terms) {
+ if (term.status !== 'decided' || term.checkCase === false) continue;
+ const isExempt = makeExemptChecker(term.exempt);
+ for (const { locale, key, value } of entries) {
+ if (isExempt(key)) continue;
+ const standard = term.translations?.[locale];
+ if (!standard || standard !== term.en) continue;
+ const hit = findCaseMismatch(stripNonProse(value), standard);
+ if (hit) violations.push(`${locale} ${key}: 「${hit}」应为「${standard}」`);
+ }
+ }
+ expect(violations, `原生菜单大小写不统一:\n${violations.join('\n')}`).toEqual([]);
+ });
+
+ it('标点风格符合各语言规则', () => {
+ const violations: string[] = [];
+ for (const { locale, key, value } of entries) {
+ const prose = normalizeForPunctuation(value);
+ if (HALFWIDTH_PUNCT_LOCALES.has(locale)) {
+ const mark = findHalfWidthPunct(prose);
+ if (mark) violations.push(`${locale} ${key}: 中文后半角「${mark}」— ${value}`);
+ }
+ if (ELLIPSIS_LOCALES.has(locale) && hasAsciiEllipsis(prose)) {
+ violations.push(`${locale} ${key}: 应使用「…」而非三个半角点 — ${value}`);
+ }
+ }
+ expect(violations, `原生菜单标点不符:\n${violations.join('\n')}`).toEqual([]);
+ });
+});
diff --git a/apps/desktop/src/main/applicationMenuLabels.ts b/apps/desktop/src/main/applicationMenuLabels.ts
new file mode 100644
index 0000000000..935db4bc6e
--- /dev/null
+++ b/apps/desktop/src/main/applicationMenuLabels.ts
@@ -0,0 +1,100 @@
+/**
+ * macOS 原生应用菜单的四语标签。
+ *
+ * 单独成模块是为了**能被术语门禁扫到**。它和 i18next 的 locale JSON 一样是用户可见
+ * 文案,但不走 i18next,check-i18n-glossary.mjs 只读 locale JSON 扫不到它——引入术语表
+ * 时这里就漏掉了「议题」(Issue 的禁用译法)和三处 ASCII 省略号,而这是 macOS 上一直
+ * 挂在屏幕顶端的菜单栏。
+ *
+ * 覆盖它的是 __tests__/applicationMenuLabels.test.ts,与 mobile 影子 catalog 同一套路子:
+ * vitest 直接 import 运行时对象,复用 scripts/shared/glossary-rules.mjs 的判定。
+ * 之所以要抽出来,是因为原先它嵌在 bootstrap-electron.ts 里,测试一 import 就会拉起
+ * 整个 Electron 主进程模块。
+ */
+import type { SupportedLocale } from '../shared/locale.js';
+
+export type ApplicationMenuLocale = SupportedLocale;
+
+export interface ApplicationMenuLabels {
+ about: string;
+ hide: string;
+ quit: string;
+ settings: string;
+ checkForUpdates: string;
+ fileMenu: string;
+ newMaker: string;
+ viewMenu: string;
+ toggleSidebar: string;
+ windowMenu: string;
+ helpMenu: string;
+ help: string;
+ releaseNotes: string;
+ issues: string;
+}
+
+export const APPLICATION_MENU_LABELS: Record<ApplicationMenuLocale, ApplicationMenuLabels> = {
+ 'zh-CN': {
+ about: '关于 {{appName}}',
+ hide: '隐藏 {{appName}}',
+ quit: '退出 {{appName}}',
+ settings: '设置…',
+ checkForUpdates: '检查更新…',
+ fileMenu: '文件',
+ newMaker: '新建 Maker',
+ viewMenu: '显示',
+ toggleSidebar: '切换侧边栏',
+ windowMenu: '窗口',
+ helpMenu: '帮助',
+ help: '帮助',
+ releaseNotes: '最新更新介绍',
+ issues: 'Issue',
+ },
+ en: {
+ about: 'About {{appName}}',
+ hide: 'Hide {{appName}}',
+ quit: 'Quit {{appName}}',
+ settings: 'Settings...',
+ checkForUpdates: 'Check for Updates...',
+ fileMenu: 'File',
+ newMaker: 'New Maker',
+ viewMenu: 'View',
+ toggleSidebar: 'Toggle Sidebar',
+ windowMenu: 'Window',
+ helpMenu: 'Help',
+ help: 'Help',
+ releaseNotes: "What's New",
+ issues: 'Issues',
+ },
+ ja: {
+ about: '{{appName}} について',
+ hide: '{{appName}}を隠す',
+ quit: '{{appName}}を終了',
+ settings: '設定…',
+ checkForUpdates: 'アップデートを確認…',
+ fileMenu: 'ファイル',
+ newMaker: '新規 Maker',
+ viewMenu: '表示',
+ toggleSidebar: 'サイドバーを切り替え',
+ windowMenu: 'ウインドウ',
+ helpMenu: 'ヘルプ',
+ help: 'ヘルプ',
+ releaseNotes: '最新情報',
+ issues: 'Issue',
+ },
+ ko: {
+ about: '{{appName}} 정보',
+ hide: '{{appName}} 가리기',
+ quit: '{{appName}} 종료',
+ settings: '설정…',
+ checkForUpdates: '업데이트 확인…',
+ fileMenu: '파일',
+ newMaker: '새 Maker',
+ viewMenu: '보기',
+ toggleSidebar: '사이드바 토글',
+ windowMenu: '윈도우',
+ helpMenu: '도움말',
+ help: '도움말',
+ releaseNotes: '최신 업데이트',
+ issues: '이슈',
+ },
+};
diff --git a/apps/desktop/src/main/bootstrap-electron.ts b/apps/desktop/src/main/bootstrap-electron.ts
index 4e92e9550c..0b0592e917 100644
--- a/apps/desktop/src/main/bootstrap-electron.ts
+++ b/apps/desktop/src/main/bootstrap-electron.ts
@@ -1134,6 +1134,11 @@ protocol.registerSchemesAsPrivileged([
import started from 'electron-squirrel-startup';
+import {
+ APPLICATION_MENU_LABELS,
+ type ApplicationMenuLocale,
+} from './applicationMenuLabels.js';
+
if (started) {
app.quit();
}
@@ -1184,91 +1189,7 @@ if (started) {
const SYSTEM_PATH_BLOCKLIST: string[] = buildSystemPathBlocklist();
// ApplicationMenuCommand 从 ../shared/applicationMenuCommands 单点导入。
-type ApplicationMenuLocale = SupportedLocale;
-
-interface ApplicationMenuLabels {
- about: string;
- hide: string;
- quit: string;
- settings: string;
- checkForUpdates: string;
- fileMenu: string;
- newMaker: string;
- viewMenu: string;
- toggleSidebar: string;
- windowMenu: string;
- helpMenu: string;
- help: string;
- releaseNotes: string;
- issues: string;
-}
-
-const APPLICATION_MENU_LABELS: Record<ApplicationMenuLocale, ApplicationMenuLabels> = {
- 'zh-CN': {
- about: '关于 {{appName}}',
- hide: '隐藏 {{appName}}',
- quit: '退出 {{appName}}',
- settings: '设置...',
- checkForUpdates: '检查更新...',
- fileMenu: '文件',
- newMaker: '新建 Maker',
- viewMenu: '显示',
- toggleSidebar: '切换侧边栏',
- windowMenu: '窗口',
- helpMenu: '帮助',
- help: '帮助',
- releaseNotes: '最新更新介绍',
- issues: '议题',
- },
- en: {
- about: 'About {{appName}}',
- hide: 'Hide {{appName}}',
- quit: 'Quit {{appName}}',
- settings: 'Settings...',
- checkForUpdates: 'Check for Updates...',
- fileMenu: 'File',
- newMaker: 'New Maker',
- viewMenu: 'View',
- toggleSidebar: 'Toggle Sidebar',
- windowMenu: 'Window',
- helpMenu: 'Help',
- help: 'Help',
- releaseNotes: "What's New",
- issues: 'Issues',
- },
- ja: {
- about: '{{appName}} について',
- hide: '{{appName}}を隠す',
- quit: '{{appName}}を終了',
- settings: '設定...',
- checkForUpdates: 'アップデートを確認...',
- fileMenu: 'ファイル',
- newMaker: '新規 Maker',
- viewMenu: '表示',
- toggleSidebar: 'サイドバーを切り替え',
- windowMenu: 'ウインドウ',
- helpMenu: 'ヘルプ',
- help: 'ヘルプ',
- releaseNotes: '最新情報',
- issues: '問題',
- },
- ko: {
- about: '{{appName}} 정보',
- hide: '{{appName}} 가리기',
- quit: '{{appName}} 종료',
- settings: '설정...',
- checkForUpdates: '업데이트 확인...',
- fileMenu: '파일',
- newMaker: '새 Maker',
- viewMenu: '보기',
- toggleSidebar: '사이드바 토글',
- windowMenu: '윈도우',
- helpMenu: '도움말',
- help: '도움말',
- releaseNotes: '최신 업데이트',
- issues: '이슈',
- },
-};
+// 应用菜单四语标签抽到 ./applicationMenuLabels,使术语门禁能直接 import 扫描(见该文件注释)。
function resolveApplicationMenuLocale(raw: string | null | undefined): ApplicationMenuLocale {
return resolveSystemLocale(raw);
diff --git a/apps/desktop/src/main/hook-control/__tests__/interactions.test.ts b/apps/desktop/src/main/hook-control/__tests__/interactions.test.ts
index 50ee6b2300..3e2e7404b1 100644
--- a/apps/desktop/src/main/hook-control/__tests__/interactions.test.ts
+++ b/apps/desktop/src/main/hook-control/__tests__/interactions.test.ts
@@ -85,7 +85,7 @@ describe('composeInteractionCard', () => {
});
});
- it('permission: 三按钮卡(允许一次/本会话总是允许/拒绝), 超时默认拒绝', () => {
+ it('permission: 三按钮卡(允许一次/本对话总是允许/拒绝), 超时默认拒绝', () => {
const composed = composeInteractionCard({
kind: 'permission',
requestId: 'int-6',
@@ -99,11 +99,13 @@ describe('composeInteractionCard', () => {
expect(composed.card.body).toContain('rm -rf dist');
expect(composed.card.buttons).toEqual([
{ id: 'perm:allow', label: '允许一次', style: 'primary' },
- { id: 'perm:always', label: '本会话总是允许', style: 'default' },
+ { id: 'perm:always', label: '本对话总是允许', style: 'default' },
{ id: 'perm:deny', label: '拒绝', style: 'danger' },
]);
expect(composed.decisions.get('perm:allow')).toEqual({ kind: 'permission', behavior: 'allow' });
- // 「本会话总是允许」带会话级 addRules(claude 直接消费, codex 非空即会话放行)
+ // 「本对话总是允许」带会话级 addRules(claude 直接消费, codex 非空即会话放行)
+ // 注:按钮文案用「对话」(产品术语,与应用内 permissions.alwaysAllowForSession 一致),
+ // 但 addRules 的作用域仍是技术意义上的 agent session,两者刻意不同名。
expect(composed.decisions.get('perm:always')).toEqual({
kind: 'permission',
behavior: 'allow',
diff --git a/apps/desktop/src/main/hook-control/dispatcher.ts b/apps/desktop/src/main/hook-control/dispatcher.ts
index 190f9ba385..b807cd515f 100644
--- a/apps/desktop/src/main/hook-control/dispatcher.ts
+++ b/apps/desktop/src/main/hook-control/dispatcher.ts
@@ -22,7 +22,7 @@
* runner 校验其属于目标 agent 的能力档位, 合法即用, 非法/缺省落
* bypassPermissions(hook 无人值守的历史默认); 复用/接管以 session meta 为
* 权威, options 不覆盖。非 bypass 档下 agent 的权限请求经 interaction.request
- * 以 Slack 卡片呈现(允许一次/本会话总是允许/拒绝), 超时安全默认拒绝。
+ * 以 Slack 卡片呈现(允许一次/本对话总是允许/拒绝), 超时安全默认拒绝。
*/
import path from 'node:path';
diff --git a/apps/desktop/src/main/hook-control/interactions.ts b/apps/desktop/src/main/hook-control/interactions.ts
index fbe2f58549..a71e78a4ba 100644
--- a/apps/desktop/src/main/hook-control/interactions.ts
+++ b/apps/desktop/src/main/hook-control/interactions.ts
@@ -71,7 +71,7 @@ export interface ComposedInteractionCard {
* InteractionRequest -> 卡片 + 决策映射。
* 返回 null 表示该 kind 不出卡(未来未知 kind), 由调用方按 kind 安全默认
* 就地自决。permission 自 Slack 按目录权限偏好上线起出卡: 非 bypass 会话的
- * 权限请求渲染成「允许一次 / 本会话总是允许 / 拒绝」三按钮卡, 超时安全默认
+ * 权限请求渲染成「允许一次 / 本对话总是允许 / 拒绝」三按钮卡, 超时安全默认
* **拒绝**(用户显式选了收紧档, 放行才是意外)。
*/
export function composeInteractionCard(req: InteractionRequest): ComposedInteractionCard | null {
@@ -180,7 +180,7 @@ export function composeInteractionCard(req: InteractionRequest): ComposedInterac
body,
buttons: [
{ id: 'perm:allow', label: '允许一次', style: 'primary' },
- { id: 'perm:always', label: '本会话总是允许', style: 'default' },
+ { id: 'perm:always', label: '本对话总是允许', style: 'default' },
{ id: 'perm:deny', label: '拒绝', style: 'danger' },
],
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 7c4cd19cef..89c1397ca6 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -186,7 +186,7 @@
"notInAgent": "未加载到 agent",
"notInAgentTip": "这把密钥在磁盘上,但没加载到 ssh-agent。点\"解锁\"加载(加密的会让你输 passphrase)。",
"unlockButton": "解锁",
- "unlockTip": "把这把密钥加载到 ssh-agent,后续 SSH 连接就不用每次再输 passphrase。",
+ "unlockTip": "把这把密钥加载到 ssh-agent,后续 SSH 连接就不用每次再输 passphrase。",
"unlockTitle": "解锁 {{name}}",
"unlockHint": "输入 passphrase 把这把密钥加载到 ssh-agent。我们把它直接喂给 `ssh-add` 后立刻丢弃,不保存。",
"unlockSubmit": "解锁",
@@ -194,7 +194,7 @@
"nameLabel": "名字(可选)",
"nameHint": "保存为 ~/.ssh/<名字>。默认 \"cindy\",有重名时自动加 -1 / -2 …",
"encryptLabel": "用 passphrase 加密(推荐)",
- "encryptHint": "passphrase 现在输入一次,然后 ssh-add 会把解密后的密钥缓存在系统 ssh-agent 里。macOS 还会把 passphrase 存到 Keychain,重启后自动恢复。",
+ "encryptHint": "passphrase 现在输入一次,然后 ssh-add 会把解密后的密钥缓存在系统 ssh-agent 里。macOS 还会把 passphrase 存到 Keychain,重启后自动恢复。",
"passLabel": "Passphrase",
"passConfirmLabel": "再输一次 Passphrase",
"passMismatch": "两次 passphrase 不一致",
@@ -205,7 +205,7 @@
"pubkeyTitle": "公钥内容",
"runFromTerminal": "在你的终端里运行:",
"runFromPowerShell": "在 PowerShell 里运行:",
- "win32InstallNote": "Windows 自带的 OpenSSH 没有 ssh-copy-id,这条命令通过 Git Bash 调用它自带的版本。需要装 Git for Windows(默认安装路径)。如果你没装 Git,请改用下方的手动粘贴方式。",
+ "win32InstallNote": "Windows 自带的 OpenSSH 没有 ssh-copy-id,这条命令通过 Git Bash 调用它自带的版本。需要装 Git for Windows(默认安装路径)。如果你没装 Git,请改用下方的手动粘贴方式。",
"orPasteManually": "或手动把这段公钥追加到远端的 ~/.ssh/authorized_keys:",
"pubkeyContent": "公钥内容",
"copyButton": "复制",
@@ -229,7 +229,7 @@
"tryThis": "在你的终端里试一下这些命令",
"close": "关闭",
"fallbackTitle": "或者干脆不走 agent",
- "fallbackBody": "你可以在添加 host 时改用「Identity file」方式,{{appName}} 会把密钥文件直接交给 ssh,每次连接时由你输入密码。完全不依赖 agent。安全权衡:每次连接都要输密码,但内存里也不会留任何密钥缓存,安全自负。",
+ "fallbackBody": "你可以在添加 host 时改用「Identity file」方式,{{appName}} 会把密钥文件直接交给 ssh,每次连接时由你输入密码。完全不依赖 agent。安全权衡:每次连接都要输密码,但内存里也不会留任何密钥缓存,安全自负。",
"reason": {
"agent_unavailable": "ssh-add 找不到可用的 ssh-agent(可能是 ssh-add 没装、agent 没启动,或 SSH_AUTH_SOCK 没设置)。",
"bad_passphrase": "ssh-add 拒绝了这个密码。",
@@ -261,7 +261,7 @@
"pinnedKeyChange": "更换",
"pinnedKeyClear": "取消钉选",
"pinnedKeyHintSet": "agent 只会向服务器 offer 这一把 key —— 避免 agent 里 key 太多时撞到 'Too many authentication failures'。",
- "pinnedKeyHintUnset": "不钉的话 agent 会把已加载的所有密钥挨个 offer;服务端有重试上限(MaxAuthTries,默认 6),agent 里密钥多了可能没到对的那把就被踢了。",
+ "pinnedKeyHintUnset": "不钉的话 agent 会把已加载的所有密钥挨个 offer;服务端有重试上限(MaxAuthTries,默认 6),agent 里密钥多了可能没到对的那把就被踢了。",
"key": "私钥文件",
"keyHint": "直接读私钥文件。为了不存密码,不支持加密的密钥 —— 仅在 ssh-agent 不可用时使用。"
},
@@ -310,7 +310,7 @@
"descFirstPush": "这会把本机的 Codex 凭证装到 {{hostId}} 的 ~/.codex/auth.json。",
"descOverwrite": "这会覆盖 {{hostId}} 上已有的 Codex 登录态。",
"descOverwriteWithAge": "这会覆盖 {{hostId}} 上已有的 Codex 登录态(上次更新于 {{when}})。",
- "warnOverwrite": "远端原有的登录会被替换。如果当下有人正在那台机器上用 Codex,他们会被踢下线。",
+ "warnOverwrite": "远端原有的登录会被替换。如果当下有人正在那台机器上用 Codex,他们会被踢下线。",
"warnShared": "任何能 SSH 进 {{hostId}} 的人都可以读这个文件,用你的 OpenAI 账号。",
"daysAgo": "{{n}} 天前",
"hoursAgo": "{{n}} 小时前",
@@ -1108,7 +1108,7 @@
"billingLabel": "按 token 计费",
"disconnectConfirm": {
"title": "断开 Cindy AI?",
- "description": "断开后将清除本地保存的 Cindy AI Key,需要重新连接才能继续使用 Cindy AI 提供的模型。"
+ "description": "断开后将清除本地保存的 Cindy AI Key,需要重新连接才能继续使用 Cindy AI 提供的模型。"
},
"sync": {
"syncing": "获取凭据中…",
@@ -1554,7 +1554,7 @@
"unavailable": "{{shell}} (不可用)",
"card": {
"label": "默认 shell",
- "description": "修改默认只影响新建的终端 tab,已有 tab 不受影响。",
+ "description": "修改默认只影响新建的终端 tab,已有 tab 不受影响。",
"selectAria": "选择默认终端 shell"
}
},
@@ -2121,7 +2121,7 @@
},
"tips": {
"cindy": "Cindy 是官方提供的共享机器人:无需申请任何凭证,连接 Slack 后 @Cindy 即可直接派活。",
- "personal": "个人机器人用你自己申请的凭证接入飞书 / Discord:机器人完全归你,需要自行创建应用并填写配置。",
+ "personal": "个人机器人用你自己申请的凭证接入飞书 / Discord:机器人完全归你,需要自行创建应用并填写配置。",
"personalFeishuOnly": "个人机器人用你自己申请的凭证接入飞书:机器人完全归你,需要自行创建应用并填写配置。"
},
"defaults": {
@@ -3183,7 +3183,7 @@
"filterClear": "清除筛选",
"filterIndexing": "正在索引项目文件…",
"filterNoMatch": "未匹配到文件",
- "filterRgUnavailable": "远端机器未安装 ripgrep,文件名筛选不可用",
+ "filterRgUnavailable": "远端机器未安装 ripgrep,文件名筛选不可用",
"filterIndexFailed": "文件索引失败",
"filterTruncated": "结果过多,仅显示前 {{limit}} 条;请缩小关键词",
"deviceTooOld": "对方设备的 {{appName}} 版本过旧,不支持远程文件浏览,请升级后重试",
@@ -5166,7 +5166,7 @@
"empty": "输入文字开始搜索",
"searching": "搜索中…",
"failed": "搜索失败",
- "rgUnavailable": "远端机器未安装 ripgrep,搜索不可用",
+ "rgUnavailable": "远端机器未安装 ripgrep,搜索不可用",
"truncated": "{{max}}+ 命中,{{files}} 个文件,缩短查询",
"noResults": "没有匹配结果",
"summary_one": "{{count}} 条结果",
@@ -6052,7 +6052,7 @@
},
"issueAgent": {
"command": {
- "instruction": "我想给 {{appName}} 提交一条反馈。请协助我整理成一个高质量的 GitHub issue:先和我确认反馈类型(bug 还是功能建议),并追问必要细节(现象、复现步骤或使用场景、期望行为);信息足够后用 cindy_helper 的 call_tool 调用 submit_github_issue 工具提交(category=feedback,可先 list_tools 查看参数要求;提交前系统会弹确认卡片给我看)。如果提交失败,如实告诉我原因。{{details}}",
+ "instruction": "我想给 {{appName}} 提交一条反馈。请协助我整理成一个高质量的 GitHub issue:先和我确认反馈类型(bug 还是功能建议),并追问必要细节(现象、复现步骤或使用场景、期望行为);信息足够后用 cindy_helper 的 call_tool 调用 submit_github_issue 工具提交(category=feedback,可先 list_tools 查看参数要求;提交前系统会弹确认卡片给我看)。如果提交失败,如实告诉我原因。{{details}}",
"detailsPrefix": "\n我的初始描述:{{details}}"
},
"confirm": {
diff --git a/apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts b/apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts
index 9d3dae0185..c348e236dd 100644
--- a/apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts
+++ b/apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts
@@ -15,6 +15,7 @@ import { resolve } from 'node:path';
import { authErrorMessages, loginMessages } from '@/auth/loginMessages';
import { newSessionMessages } from '@/session/newSessionMessages';
+import { FULL_ACCESS_CONFIRMATION_COPY } from '@/session/fullAccessConfirmationCopy';
import {
ELLIPSIS_LOCALES,
HALFWIDTH_PUNCT_LOCALES,
@@ -73,6 +74,19 @@ function collectEntries(): { locale: string; key: string; value: string }[] {
}
}
+ // fullAccessConfirmation: locale → key → string。
+ // 它的 locale 键用 'zh' 而非 'zh-CN'(那份 catalog 按语言前缀而非完整 tag 分支),
+ // 这里映射成术语表的 locale 形态,否则 zh 分支会因为语言键对不上而整段扫不到。
+ for (const [locale, table] of Object.entries(FULL_ACCESS_CONFIRMATION_COPY)) {
+ for (const [key, value] of Object.entries(table)) {
+ out.push({
+ locale: locale === 'zh' ? 'zh-CN' : locale,
+ key: `mobile/fullAccessConfirmation:${key}`,
+ value,
+ });
+ }
+ }
+
return out;
}
@@ -94,8 +108,11 @@ describe('影子 catalog 术语一致性', () => {
it('不使用术语表的禁用译法', () => {
const violations: string[] = [];
+ // proposed 术语不能整个跳过:根脚本扫不到这些 TS catalog,一跳过,它们在这份语料里的
+ // 命中数就从「待裁决术语现在有多少处」的统计里彻底消失——而那个数字正是裁决讨论的依据。
+ // 与根门禁同一分级:decided 阻断,proposed 只提示。
+ const notes: string[] = [];
for (const term of glossary.terms) {
- if (term.status !== 'decided') continue;
const isExempt = makeExemptChecker(term.exempt);
for (const { locale, key, value } of entries) {
if (isExempt(key)) continue;
@@ -113,27 +130,45 @@ describe('影子 catalog 术语一致性', () => {
);
if (!source || !re.test(stripNonProse(source))) continue;
}
- const expected = term.translations?.[locale] || term.en;
- violations.push(`${locale} ${key}: 「${bad}」应为「${expected}」— ${value.slice(0, 40)}`);
+ // 与根门禁一致:只报事实与英文源,不给替换目标。术语表是参考不是替换表——
+ // 该换成什么取决于英文源与这个 key 的用途,得读了语境再定。
+ const source = sourceByKey.get(key);
+ const line =
+ `${locale} ${key}: 「${bad}」是 ${term.en} 条目下的禁用译法` +
+ `\n 译文: ${value.slice(0, 60)}` +
+ (source ? `\n 英文源: ${source.slice(0, 60)}` : '');
+ if (term.status === 'decided') violations.push(line);
+ else notes.push(line);
}
}
}
+ if (notes.length > 0) {
+ console.warn(`[shadow-glossary] 待裁决术语命中:\n${notes.join('\n')}`);
+ }
expect(violations, `影子 catalog 命中禁用译法:\n${violations.join('\n')}`).toEqual([]);
});
it('保留英文的术语大小写形态统一', () => {
const violations: string[] = [];
+ const notes: string[] = [];
for (const term of glossary.terms) {
- if (term.status !== 'decided' || term.checkCase === false) continue;
+ if (term.checkCase === false) continue;
const isExempt = makeExemptChecker(term.exempt);
for (const { locale, key, value } of entries) {
if (isExempt(key)) continue;
const standard = term.translations?.[locale];
if (!standard || standard !== term.en) continue;
const hit = findCaseMismatch(stripNonProse(value), standard);
- if (hit) violations.push(`${locale} ${key}: 「${hit}」应为「${standard}」`);
+ // 大小写的正确目标与语境无关、唯一确定,这里给目标是帮忙不是误导(同根门禁)。
+ if (!hit) continue;
+ const line = `${locale} ${key}: 「${hit}」应为「${standard}」`;
+ if (term.status === 'decided') violations.push(line);
+ else notes.push(line);
}
}
+ if (notes.length > 0) {
+ console.warn(`[shadow-glossary] 待裁决术语大小写:\n${notes.join('\n')}`);
+ }
expect(violations, `影子 catalog 大小写不统一:\n${violations.join('\n')}`).toEqual([]);
});
diff --git a/apps/mobile/src/i18n/locales/zh-CN/composer.json b/apps/mobile/src/i18n/locales/zh-CN/composer.json
index 0d531810ba..4ff2df2bb0 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/composer.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/composer.json
@@ -60,7 +60,7 @@
"noImageRead": "没有读取到可上传的图片。",
"emptyImage": "这个图片为空,不能作为附件发送。",
"imageTooLarge": "图片超过 {{size}} MB,暂不能作为附件发送。",
- "imageTooLargeSend": "图片超过 {{size}} MB,暂不能发送。",
+ "imageTooLargeSend": "图片超过 {{size}} MB,暂不能发送。",
"sessionExpiredImage": "登录已过期,请重新登录后再上传图片。",
"sessionExpiredFile": "登录已过期,请重新登录后再上传附件。",
"pasteTimeout": "粘贴图片处理超时,请重试。",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/files.json b/apps/mobile/src/i18n/locales/zh-CN/files.json
index 2383dff076..89849f1528 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/files.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/files.json
@@ -64,7 +64,7 @@
"oversizeUnknown": "过大",
"binaryFile": "二进制文件,无法以文本预览",
"readFailed": "读取失败",
- "truncated2mb": "文件超过 2 MB,仅显示前 2 MB 内容",
+ "truncated2mb": "文件超过 2 MB,仅显示前 2 MB 内容",
"truncatedLines": "仅显示前 {{lines}} 行",
"mdRendered": "渲染",
"mdSource": "源码",
diff --git a/apps/mobile/src/session/fullAccessConfirmation.ts b/apps/mobile/src/session/fullAccessConfirmation.ts
index 8575a089b4..fbae74ab73 100644
--- a/apps/mobile/src/session/fullAccessConfirmation.ts
+++ b/apps/mobile/src/session/fullAccessConfirmation.ts
@@ -3,40 +3,12 @@ import { getLocales } from 'expo-localization';
import { requiresFullAccessConfirmation } from '@cindy/maker-shared/permission-mode';
import { getManualLocaleOverride } from '@/i18n/appLanguage';
+import {
+ FULL_ACCESS_CONFIRMATION_COPY,
+ type FullAccessConfirmationCopy,
+} from './fullAccessConfirmationCopy';
-export type FullAccessConfirmationCopy = Readonly<{
- title: string;
- description: string;
- confirm: string;
- cancel: string;
-}>;
-const FULL_ACCESS_CONFIRMATION_COPY: Record<'en' | 'ja' | 'ko' | 'zh', FullAccessConfirmationCopy> = {
- en: {
- title: 'Enable Full access?',
- description: 'Full access disables the workspace sandbox and skips routine approvals. Cindy can modify files outside the workspace and run network commands without asking; built-in high-risk operations will still require confirmation.',
- confirm: 'Enable Full access',
- cancel: 'Keep current permissions',
- },
- ja: {
- title: 'Full access を有効にしますか?',
- description: 'Full access はワークスペースのサンドボックスを無効にし、通常の承認を省略します。Cindy はワークスペース外のファイル変更やネットワークコマンドを確認なしで実行できます。組み込みの高リスク操作では引き続き確認が必要です。',
- confirm: 'Full access を有効にする',
- cancel: '現在の権限を維持',
- },
- ko: {
- title: 'Full access를 활성화할까요?',
- description: 'Full access는 작업 공간 샌드박스를 비활성화하고 일반 승인을 건너뜁니다. Cindy가 작업 공간 밖의 파일을 수정하고 네트워크 명령을 묻지 않고 실행할 수 있습니다. 기본 제공 고위험 작업은 계속 확인을 요청합니다.',
- confirm: 'Full access 활성화',
- cancel: '현재 권한 유지',
- },
- zh: {
- title: '开启 Full access?',
- description: 'Full access 会关闭工作区沙箱并跳过常规审批。Cindy 可以修改工作区外的文件、执行联网命令且不再询问;内置高风险操作仍会要求确认。',
- confirm: '开启 Full access',
- cancel: '保留当前权限',
- },
-};
/** 生效语言(手动选择优先,否则系统语言)选择手机端 Full access 确认文案;未覆盖的语言使用英文。 */
export function getFullAccessConfirmationCopy(
diff --git a/apps/mobile/src/session/fullAccessConfirmationCopy.ts b/apps/mobile/src/session/fullAccessConfirmationCopy.ts
new file mode 100644
index 0000000000..8747059a40
--- /dev/null
+++ b/apps/mobile/src/session/fullAccessConfirmationCopy.ts
@@ -0,0 +1,46 @@
+/**
+ * Full access 确认弹窗的四语文案。
+ *
+ * 单独成模块是为了**能被术语门禁扫到**:这是不走 i18next 的手写四语 catalog,
+ * check-i18n-glossary.mjs 只读 locale JSON 扫不到它。而它恰恰是全 App 风险最高的一处
+ * 提示——用户在这里决定是否关掉工作区沙箱、跳过逐条批准,措辞含糊的代价很实在。
+ *
+ * 之所以不能留在 fullAccessConfirmation.ts 里被测试直接 import:那个文件 import 了
+ * react-native,vitest 解析不了 RN 的 Flow 源码。
+ *
+ * 覆盖它的是 src/__tests__/shadowCatalogGlossary.test.ts。
+ */
+
+export type FullAccessConfirmationCopy = Readonly<{
+ title: string;
+ description: string;
+ confirm: string;
+ cancel: string;
+}>;
+
+export const FULL_ACCESS_CONFIRMATION_COPY: Record<'en' | 'ja' | 'ko' | 'zh', FullAccessConfirmationCopy> = {
+ en: {
+ title: 'Enable Full access?',
+ description: 'Full access disables the workspace sandbox and skips routine approvals. Cindy can modify files outside the workspace and run network commands without asking; built-in high-risk operations will still require confirmation.',
+ confirm: 'Enable Full access',
+ cancel: 'Keep current permissions',
+ },
+ ja: {
+ title: 'Full access を有効にしますか?',
+ description: 'Full access はワークスペースのサンドボックスを無効にし、通常の承認を省略します。Cindy はワークスペース外のファイル変更やネットワークコマンドを確認なしで実行できます。組み込みの高リスク操作では引き続き確認が必要です。',
+ confirm: 'Full access を有効にする',
+ cancel: '現在の権限を維持',
+ },
+ ko: {
+ title: 'Full access를 활성화할까요?',
+ description: 'Full access는 작업 공간 샌드박스를 비활성화하고 일반 승인을 건너뜁니다. Cindy가 작업 공간 밖의 파일을 수정하고 네트워크 명령을 묻지 않고 실행할 수 있습니다. 기본 제공 고위험 작업은 계속 확인을 요청합니다.',
+ confirm: 'Full access 활성화',
+ cancel: '현재 권한 유지',
+ },
+ zh: {
+ title: '开启 Full access?',
+ description: 'Full access 会关闭工作区沙箱并跳过常规审批。Cindy 可以修改工作区外的文件、执行联网命令且不再询问;内置高风险操作仍会要求确认。',
+ confirm: '开启 Full access',
+ cancel: '保留当前权限',
+ },
+};
diff --git a/docs/dev-rules/engineering-conventions.md b/docs/dev-rules/engineering-conventions.md
index 0aca9f0561..829e204ca4 100644
--- a/docs/dev-rules/engineering-conventions.md
+++ b/docs/dev-rules/engineering-conventions.md
@@ -120,11 +120,22 @@ UI 文案的语气与措辞另见 [`DESIGN.md`](../design-rules/DESIGN.md) 的 V
- `pnpm check:i18n-glossary` 校验译文术语与标点,并检查 `GLOSSARY.md` 是否与术语表同步。
- 两者互补:前者管「key 齐不齐」,后者管「词译得一不一致」,谁也替代不了谁。改
i18n 后两个都要跑(CI 已强制)。
-- **影子 catalog**:mobile 有一批不走 i18next 的手写四语 catalog(`src/auth/loginMessages.ts`、
- `src/session/newSessionMessages.ts`),根脚本只扫 locale JSON、扫不到这些 `.ts`。它们由
- `apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts` 覆盖——走 vitest 直接 import 运行时
- 对象,复用 `scripts/shared/glossary-rules.mjs` 的同一套判定,随 `test:unit` 阻断。新增同类
- 手写 catalog 时记得加进那个测试的 `collectEntries()`。
+- **影子 catalog**:有几批不走 i18next 的手写四语 catalog,根脚本只扫 locale JSON、扫不到
+ 这些 `.ts`。它们由 vitest 直接 import 运行时对象覆盖,复用
+ `scripts/shared/glossary-rules.mjs` 的同一套判定,随 `test:unit` 阻断:
+ - mobile:`src/auth/loginMessages.ts`、`src/session/newSessionMessages.ts`、
+ `src/session/fullAccessConfirmationCopy.ts`(Full access 高风险权限提示)→
+ `apps/mobile/src/__tests__/shadowCatalogGlossary.test.ts`
+ - desktop:`src/main/applicationMenuLabels.ts`(macOS 原生菜单栏)→
+ `apps/desktop/src/main/__tests__/applicationMenuLabels.test.ts`
+
+ 新增同类手写 catalog 时记得加进对应测试的 `collectEntries()`。**catalog 要单独成模块**:
+ 原先这两份分别嵌在 `bootstrap-electron.ts` 与 `fullAccessConfirmation.ts` 里,测试一 import
+ 就会拉起整个 Electron 主进程 / react-native,根本跑不起来——这也是它们长期是盲区的原因。
+- **Slack / IM 侧的文案不在任何 locale 文件里**:`src/main/hook-control/interactions.ts` 的
+ 权限卡片按钮是硬编码中文,与应用内 `permissions.alwaysAllowForSession` 是同一个动作。
+ 改产品术语时这类「同一动作、两处独立文案」要一起找出来,否则用户在 Slack 和 App 里
+ 看到两种说法。
- **批量改术语时必须跑全量 `pnpm test:unit`**:仓库里有若干测试直接断言中文文案
(`automationGeneratedSessions.test.ts`、`builtinToolsCollabDescriptionI18n.test.ts`、
mobile 的 `sessionMenu.test.ts` 等)。它们是有意的文案锁,改词后要同步更新期望值,
diff --git a/scripts/check-i18n-glossary.mjs b/scripts/check-i18n-glossary.mjs
index 8515e0b7d2..c4a39b59e9 100644
--- a/scripts/check-i18n-glossary.mjs
+++ b/scripts/check-i18n-glossary.mjs
@@ -397,13 +397,24 @@ if (UPDATE_BASELINE) {
const baseline = fs.existsSync(BASELINE_PATH) ? readJson(BASELINE_PATH) : { entries: [] };
const baselineSet = new Set(baseline.entries ?? []);
-const current = new Set(violations.map((v) => v.fingerprint));
-const stale = [...baselineSet].filter((fp) => !current.has(fp)).sort();
-const fresh = violations.filter((v) => !baselineSet.has(v.fingerprint));
+// baseline **只屏蔽 error 级违规**,不看 fingerprint 就一律放过。
+//
+// baseline 里存的全是当初 decided 术语的违规。若某个术语后来退回 proposed 重新讨论,
+// 它的违规会降级成 warn,但 fingerprint 不变——按 fingerprint 无差别屏蔽的话,这些
+// 违规既不会作为待裁决告警出现(被当成已知存量),也不会被判为 stale(现状里确实还在),
+// 于是「正在讨论的术语现在有多少处」这个数字凭空消失,而讨论恰恰需要它。
+//
+// 改为只用 error 级违规参与 baseline 比对:warn 永远直接呈现;某条 baseline 条目对应的
+// 术语退回 proposed 后,该条目会被判为 stale,提示把它从账上摘掉——这也正确,因为
+// baseline 的语义就是「已冻结的阻断项」。
+const currentBlocking = new Set(blockingAll.map((v) => v.fingerprint));
+const stale = [...baselineSet].filter((fp) => !currentBlocking.has(fp)).sort();
+const isMasked = (v) => v.severity === 'error' && baselineSet.has(v.fingerprint);
+const fresh = violations.filter((v) => !isMasked(v));
const blocking = fresh.filter((v) => v.severity === 'error');
const warnings = fresh.filter((v) => v.severity === 'warn');
-const known = violations.filter((v) => baselineSet.has(v.fingerprint));
+const known = violations.filter(isMasked);
// ---------------------------------------------------------------------------
// 输出
diff --git a/scripts/shared/glossary-rules.mjs b/scripts/shared/glossary-rules.mjs
index f8a9ea8b61..450fb26ea8 100644
--- a/scripts/shared/glossary-rules.mjs
+++ b/scripts/shared/glossary-rules.mjs
@@ -14,15 +14,32 @@
*/
export const WORD_BOUNDARY = 'A-Za-z0-9_-';
+/** CJK 全角句读与括号。出现即说明 URL / 邮箱已经结束、后面是正文。 */
+const CJK_PUNCT = ',。;:!?、()「」【】《》“”‘’…';
+/** 汉字 + 假名 + 谚文。用于「半角分隔符后面是不是中文正文」的判定。 */
+const CJK_CHAR = '\\u4e00-\\u9fff\\u3040-\\u30ff\\uac00-\\ud7af';
+
/**
- * URL 片段。
+ * URL / 邮箱这类「不参与术语匹配的 token」的收尾规则。
+ *
+ * **不能**用 \S+ 收尾:中文正文常紧跟在它们后面且中间没有空格,\S+ 会把标点连同后面
+ * 整句正文一起吞掉,于是之后的禁用词、大小写、标点问题全部检测不到,门禁静默放行。
*
- * 关键是**不能**用 \S+ 收尾:中文正文常紧跟在 URL 后面且中间没有空格
- * (「请访问 https://x.test,返回对话列表」),\S+ 会把全角标点连同后面整句正文一起吞掉,
- * 于是 URL 之后的禁用词、大小写问题全部检测不到,门禁静默放行。
- * 按 CJK 句读与括号截断,只吃掉 URL 本身。
+ * 两级截断:
+ * - 全角句读:一律截断——URL 里不会出现全角标点;
+ * - 半角 , ; : ! ?:**仅当其后紧跟 CJK 字符时**截断。不能无条件截,否则会切坏合法的
+ * query string(`?a=1&ids=1,2`)与端口号(`:8080`);而 `https://x.test,返回…`
+ * 这种半角逗号后直接接中文的写法,逗号显然是正文标点而非 URL 的一部分。
+ */
+const TOKEN_TAIL = `(?:(?![${CJK_PUNCT}])(?![,;:!?](?=[${CJK_CHAR}]))\\S)+`;
+
+const URL_TOKEN = new RegExp(`\\b[a-z][\\w-]*://${TOKEN_TAIL}`, 'gi');
+
+/**
+ * 邮箱片段。收尾规则同 URL——原先的 `\S+@\S+\.\S+` 连全角标点都不截,
+ * 「联系 [email protected],返回worker操作」会被整段剥成「联系 」。
*/
-const URL_TOKEN = /\b[a-z][\w-]*:\/\/[^\s,。;:!?、()「」【】《》“”‘’…]+/gi;
+const EMAIL_TOKEN = new RegExp(`[^\\s${CJK_PUNCT}]+@${TOKEN_TAIL}`, 'g');
/**
* 文件名片段。
@@ -51,7 +68,7 @@ export function stripNonProse(text) {
.replace(/<\/?\d+>/g, ' ')
.replace(/\$t\([^)]*\)/g, ' ')
.replace(URL_TOKEN, ' ')
- .replace(/\S+@\S+\.\S+/g, ' ')
+ .replace(EMAIL_TOKEN, ' ')
.replace(FILENAME_TOKEN, ' ');
}
@@ -117,12 +134,17 @@ export const HALFWIDTH_PUNCT_LOCALES = new Set(['zh-CN']);
export const ELLIPSIS_LOCALES = new Set(['zh-CN', 'ja', 'ko']);
/**
- * 中文正文的「左边界」:汉字,以及各类右闭合符号。
+ * 中文正文里的半角标点。两种形态:
*
- * 只认汉字的话,`(直接替换,不留原文),或…` 这种会漏——半角逗号前面是右括号而非汉字。
- * 右括号 / 右引号 / 右书名号后面接的仍是中文正文,标点该跟中文规则走。
+ * 1. 汉字 / 右闭合符号 + 半角标点。只认汉字的话 `(直接替换,不留原文),或…` 会漏——
+ * 逗号前面是右括号。右括号 / 右引号 / 右书名号后面接的仍是中文正文。
+ * 2. 拉丁字母或数字 + 半角标点 + **紧跟 CJK**。`Keychain,重启` 这类漏了整整一类:
+ * 中文句子里夹的英文产品名、技术词后面同样该用全角。这一支必须要求右边是 CJK,
+ * 否则 `a=1,b=2`、`GPT-4,Claude` 这种纯 ASCII 片段会被误判。
*/
-const HALF_WIDTH_AFTER_HAN = /[一-鿿))」』】》〉”’][,:;!?]/;
+const HALF_WIDTH_AFTER_HAN = new RegExp(
+ `[一-鿿))」』】》〉”’][,:;!?]|[A-Za-z0-9][,:;!?](?=[${CJK_CHAR}])`,
+);
const ASCII_ELLIPSIS = /\.\.\./;
/**
@@ -165,7 +187,7 @@ export function normalizeForPunctuation(text) {
.replace(/<\/?\d+>/g, PROSE_PLACEHOLDER)
.replace(/\$t\([^)]*\)/g, PROSE_PLACEHOLDER)
.replace(URL_TOKEN, ' ')
- .replace(/\S+@\S+\.\S+/g, ' ')
+ .replace(EMAIL_TOKEN, ' ')
.replace(FILENAME_TOKEN, ' ');
}