Commit Graph

7 Commits

Author SHA1 Message Date
Chris
378820a7fe feat(i18n): add Simplified 文言 edition and classical reply styles
- New locale zh-Hans-x-lzh, generated from the Traditional edition (copy kept
  verbatim from zh-TW takes the zh-CN value; the rest goes through OpenCC tw2sp).
  Falls back to zh-CN, then en; never chosen from the OS language.
- The language menu has a single 文言 entry. Choosing it adds a row to the same
  card for script (简体 / 繁體) and AI reply style: classical prose (default),
  Tang poetry, Song ci, Yuan qu, Chu ci, parallel prose, pre-Qin masters,
  historian, Ming–Qing essays, or plain replies with the classical interface.
- Styles live in @cindy/maker-shared/classical-reply, grouped by literary
  family so Japanese / Korean classical editions can add their own later.
- The style rides the per-turn [UI language] note next to uiLanguage; the
  cached system prompt is unchanged. Desktop mirrors its choice to main over
  IPC; Mobile sends its own with each turn; IM channels keep the error-language
  note only.
- QA previews, glossary, docs and the installer message check cover the new
  edition.

Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
2026-10-31 13:18:15 +08:00
Chris
3019820b8f feat(i18n): add Classical Chinese (文言) UI edition with classical AI replies
Add a hand-selectable Classical Chinese locale (zh-Hant-x-lzh) across
Desktop, Mobile and native copy, written in Traditional characters with
Cindy's playful ancient-style voice, verse on welcome and milestone
screens, and plain wording for deletion, permission, credential and
payment prompts.

- The private-use tag keeps Intl dates, numbers and plurals on zh-Hant;
  missing keys fall back to zh-TW, then English. OS languages never
  resolve to it, and an app locale passed back through the main-process
  resolver keeps its identity instead of folding into zh-TW.
- With this interface the per-turn UI language note also asks the model
  to reply in Classical Chinese; switching languages replaces the note
  and ends the style. IM channels keep the error-language-only note.
  The cached system prompt is unchanged.
- Server-facing locales stay on existing values (zh-TW / zh-CN).
- Record the style guide and glossary terms; refresh login QA previews.

Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
2026-10-31 13:18:14 +08:00
Chris
2b771422a2 feat(i18n): add Spanish, French, German and regional Portuguese UI
Complete desktop and mobile catalogs and native copy for ten UI locales.
Keep Portugal and Brazil Portuguese separate, preserve service locale
contracts, and verify real desktop/iOS/Android language switching.

French catalog based on community contribution #7739 with updates
for the current source and terminology.

Co-authored-by: Digital Air Media <contact@digitalairmedia.eu>
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
2026-10-31 03:46:43 +08:00
Dash
658c5083b6 fix(desktop): 优化登录成功回调页自动关闭 (#3807)
* fix(desktop): 优化登录成功回调页自动关闭

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* docs(desktop): 同步登录回调成功态设计契约

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

---------

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
2026-09-02 20:20:03 +08:00
Dash
e78f44ae56 feat(i18n): 支持繁体中文语言 (#2148)
* feat(i18n): add Traditional Chinese locale support

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): align Traditional Chinese catalog keys

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): align mobile language order and release fallback

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese keys with main

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): polish Traditional Chinese copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese stream copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese resume copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese help copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): unify Traditional Chinese plugin terminology

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): localize session notifications

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(plugin): preserve manifest locale compatibility

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): close Traditional Chinese review gaps

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(plugin): clamp app-context locale values

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): localize presets and secure login preview

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): scope nested dialog dismissal

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): make dismissal and title formatting deterministic

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): unify Traditional Chinese privacy policy term

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(docs): align login QA locale coverage

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(docs): derive locale QA from supported languages

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese with latest main

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-10 03:25:41 +08:00
Dash
275aca7a4b feat(desktop): 登录回调改走自有域名,不再向用户暴露 127.0.0.1 (#549)
* feat(desktop): 登录回调改走自有域名,不再向用户暴露 127.0.0.1

系统浏览器登录走 RFC 8252 loopback,用户会在地址栏看到
127.0.0.1:<port>/auth/callback?code=...,点「回到 Cindy」时的系统弹框也显示该
IP,授权码还一并留在了浏览历史里。

新增可选的托管回调链路:redirect_uri 指向 auth-server 自有域名下的固定地址,
服务端按 client_state 暂存授权码、客户端轮询取回,浏览器全程停在自有域名上。

没有走「回调页 fetch 投递回本地端口」那条路:WebKit 至今不把 loopback 当作
potentially trustworthy origin(https://bugs.webkit.org/show_bug.cgi?id=171934),
https 页面 fetch http://127.0.0.1 会被按 mixed content 拦掉,而 Safari 是 macOS
默认浏览器。把方向翻转成客户端主动拉取即可绕开,顺带免掉 CORS 与本地端口占用。

- 端点清单新增 authDesktopCallbackUrl,兼作灰度与回滚开关:空(当前值)即走原
  loopback,行为与今天完全一致;服务端就绪后填值切换,客户端不必发版
- auth-client 新增 pollDesktopAuthorization;request 支持外部 AbortSignal,
  取消登录时立即断开在途请求
- 轮询节奏、结果映射与失败预算抽进 authHostedCallback.ts 纯逻辑并单测,另加源码
  守卫钉住「清单为空必须回落 loopback」这一对现网用户的核心承诺
- 新增 export:login-callback-template,从生产同一个渲染器导出结果页模板交付服务
  端,避免品牌卡在两个仓库各写一份、改文案就漂移
- 跨仓契约见 docs/desktop-login-hosted-callback.md

服务端尚未实现,本改动默认关闭。

Signed-off-by: Dash <dashhuang@gmail.com>

* docs(auth): 按服务端实现修正托管回调契约

服务端实现完成后回填三处与最初设想不同的事实:

- redirect_uri 不是 provider 的回调地址,而是「auth-server 完事后往哪跳」;
  provider 回调路由与 callbackShared 收尾逻辑都不需要改
- 放行不新增环境变量,比照 console/callback 先例同源恒放行
- poll 按 IP 限流而非 clientState(请求体里的客户端可控值不得参与限流 key),
  deviceId 服务端无从比对故不校验

另补两条实现约束:结果页语言跟随浏览器 Accept-Language(app 的 ui_locale 冻结在
登录事务里,到托管回调这步已被消费),以及 CSP 必须按 sha256 放行那段布局必需的
内联脚本——早期版本禁掉全部脚本导致卡片贴左、窄窗口裁掉 CTA,HTTP 层看不出异常。

验收清单改为已完成/待部署后确认两段。

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): 轮询取回凭据与浏览器可见的 state 分离

review 指出:托管链路把 OAuth state 直接当成了取回授权码的凭据,而它会作为
client_state 进入系统浏览器的地址栏与导航历史。任何能读到浏览历史的扩展或同机
进程都可以抢先调用那个未鉴权的 poll 接口把一次性结果消费掉——授权码本身有 PKCE
兜底换不到 token,但真实客户端会拿到 expired,登录被打断。

改为客户端另生成 pollSecret(256 bit),只把 base64url(sha256(pollSecret)) 作为
client_state 交给 authorize;轮询时出示原像。浏览器侧只看得到哈希值。loopback
链路的 state 生成方式未动,存量路径行为不变。

同时修 review 指出的另外三处:

- auth-client 的取消转发与超时过早清理:原来在 fetch 返回后就摘掉了监听器,
  响应头已到而 body 仍在传输或卡住时,调用方再点取消就断不掉请求,轮询会一直
  挂着。改为覆盖到响应体解析完成为止,并把传输失败归类抽成 describeTransportFailure
- 导出模板 manifest 里"语言用 ui_locale"与契约文档冲突:该值在托管回调阶段已随
  登录事务被消费,结果页实际按 Accept-Language 选择,按契约改正
- 删除 authHostedCallback.test.ts 里重复了一遍的失败计数用例

契约文档同步更新为 pollSecret 模型,并补上授权码 60s TTL 与寄存记录的关系。

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): 取消错误码并入既有 inventory,script hash 改由导出方计算

回应第二轮 review:

- 新增的 REQUEST_ABORTED 不在登录错误码 inventory(fixtures/loginScenarios.ts、
  LoginPage 具名码表、五语 i18n)里,任何把它直接展示的调用方都会落到 fallback。
  外部 signal 取消复用既有的 USER_CANCELLED:语义完全吻合,renderer 已特意把它
  映射成「不展示错误」,错误码集合保持稳定
- sleepUnlessAborted 的 finish 改为幂等,并在注册监听器后补一次 aborted 检查。
  当前 executor 全程同步、abort 插不进来,这层防御是为了「将来有人在中间加了
  await」不会静默退化成「取消要等满一个轮询间隔」
- 导出脚本改为在生成时算好每页的 CSP script hash 写进 manifest.pages[].scriptHashes。
  服务端此前用正则从 HTML 里抠 script 标签,既容易与浏览器真实解析行为出入,也被
  CodeQL js/bad-tag-filter 反复判为不完整的标签过滤;边界由拼出 HTML 的一方掌握
  最可靠。hash 值与服务端原先算出的完全一致,已重新导出模板同步到服务端仓

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): 布局脚本抽成导出常量,CSP hash 直接对源文本取值

CodeQL 把导出脚本里"对 renderOAuthResultPage 的返回值算 sha256"判成了
「密码哈希强度不足」(js/insufficient-password-hash)。这是误报——哈希对象是页面
HTML、用途是 CSP script-src——但它指向的做法本身也不好:从渲染完成的 HTML 里
反向抠那段脚本,依赖 HTML 解析细节。

改为在 oauthResultPage.ts 里把那段布局脚本抽成导出常量
LOGIN_CALLBACK_LAYOUT_SCRIPT,模板引用它,导出脚本直接对常量算 hash。渲染产物
与 hash 值都逐字节未变(重新导出后服务端 assets 无 diff),污点链也断开了。

另修 review 指出的注释过时:authManager 里生成 state 处仍写着"state 兼作取回
凭据",而托管链路早已改为另生成 pollSecret。注释改成明确区分两条链路各自用的值。

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): 唤起浏览器与取消/超时竞速

review 指出:托管链路里 shell.openExternal 是裸 await,而这一步发生在轮询开始之前。
系统默认浏览器冷启动、handler 注册异常等情况下它可能长时间不返回,此时取消信号与
五分钟预算都够不着——cancel-browser 会一直等在同一个未 settle 的登录动作上。
loopback 分支没有这个问题(它先起 timer 再 openExternal)。

改为用既有的 raceAuthBrowserCancellation 让唤起与 AbortSignal.any([signal, 超时])
竞速,取消与超时都收敛成 USER_CANCELLED;并引入单一 deadline,轮询预算扣掉唤起已
花的时间,整次尝试仍只有一个五分钟。补了源码守卫钉住这两点。

契约文档同步服务端的幂等读取语义(cindy-server 侧 dd33b12)。

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-07-27 08:22:43 +08:00
Lizi
bb3f71d084 chore: Cindy 首次开源提交 / initial open-source release
Cindy 是心动网络 (X.D. Network Inc.) 的跨端 AI Agent 客户端。
本次提交包含 Desktop(Electron)、Mobile(Expo)及全部共享 packages
的完整源码,以 Apache-2.0 协议开源。

This is the first public release of Cindy, X.D. Network's cross-platform
AI agent client: the Electron desktop app, the Expo mobile app, and all
shared workspace packages, licensed under Apache-2.0.

- 许可与合规:根 LICENSE(Apache-2.0)+ NOTICE;第三方组件归属声明与
  SPDX SBOM 收口在 docs/legal/notices/,由 pnpm licenses:generate 生成。
- 社区文件:README / CONTRIBUTING / CODE_OF_CONDUCT / SECURITY / SUPPORT
  中英双语;issue / PR 模板与 CI workflow 在 .github/。
- 协议层以公开 submodule 引入:github.com/makecindy/cindy-protocol。
- 提交前已通过仓库门禁:全量 pnpm test:unit 与涉及 package 的 typecheck。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 08:30:44 +08:00