Repository navigation
feat(personas): 角色默认工作区——新对话开场即挂载 / persona default workspace - #49
Merged
sqfcyily merged 1 commit intoNov 17, 2026
Conversation
…e auto-mounted on new chats
3 tasks
sqfcyily
changed the base branch from
main
to
merge/persona-default-workspace
November 17, 2026 07:58
sqfcyily
added a commit
that referenced
this pull request
Nov 18, 2026
aloasut
added a commit
to aloasut/deva
that referenced
this pull request
Nov 19, 2026
…rt (with knowledge base) - 角色可打包为 zip:persona.md 磁盘原文 + 自定义头像 + 专属技能整目录 + 专属 MCP 配置(含解密密钥)+ 知识库目录(personas/knowledge/<id>/)+ manifest;Rail 角色右键导出(内置角色灰显拒绝)、花名册 + 菜单导入 / bundle a persona into a zip (raw persona.md, avatar, exclusive skill folders, exclusive MCP servers with decrypted secrets, knowledge directory) with export from the Rail context menu (builtins rejected) and import from the roster add-menu - 导入 id 判定序:原 id 安全且空闲则沿用;已被占且 personas.imports 簿记在案(同源包)→ 就地更新;冲突/外来 id → makeId 铸新 id 绝不覆盖;内置 general/xiaomajiang 永不落位 / import keeps a safe free id, updates same-provenance bundles in place via the provenance ledger, mints fresh ids on conflicts, and never lands on builtin ids - persona.md 经 writePersonaMdRaw 原样字节落盘,不做 frontmatter 重组——手改键与未来字段(sqfcyily#65 knowledge、sqfcyily#49 workspace)往返不丢失;删除角色级联清理头像、知识库目录与导入簿记 / persona.md is written verbatim via writePersonaMdRaw (no frontmatter recomposition, so hand-edited and future keys survive); persona deletion cascades avatar, knowledge dir and import bookkeeping - 安全:zip-slip 逐段守卫 + 30MB/500 文件/10MB 单文件限额;目录收集 lstat 跳过符号链接(防环递归与越界拉取);MCP 密钥导出解密进包(开箱即用的明示取舍)、导入重加密回 secrets.json,加密不可用字段跳过并警告 / security: per-segment zip-slip guards with 30MB/500-file/10MB limits, lstat-based symlink skipping against loop recursion and out-of-tree pulls, MCP secrets decrypted into the bundle (explicit trade-off) and re-encrypted into secrets.json on import with warnings for undecryptable fields - atomic-write 支持 Uint8Array 二进制原子写;preload personas 桥新增 exportBundle/importBundle;i18n 中英文案;随包 MCP 导入即启用并收窄为仅该角色,手机端经既有 WebPersona 推送自动可见 / binary-safe writeFileAtomic, exportBundle/importBundle on the preload personas bridge, bilingual i18n; bundled MCP servers import enabled and scoped to the persona, visible on phones via existing WebPersona pushes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
角色(Persona)往往固定处理同一个项目目录的内容(代码助手对一个仓库、文档助手对一个资料库)。现状是每条新对话都要手动「挂载工作区」,不挂时模型一旦用相对路径读写或省略 path 扫描(
list_dir/glob/grep),就命中「需要挂载工作区」卡片、回合挂起等用户处置——带附件的新对话里这几乎必然发生(模型按绝对路径之外的方式去看附件所在目录)。给角色加一个默认工作区后,绑定该角色的新对话开场即挂载,挂载的全部好处自动生效:
read_file/write_file/grep等不再触发挂载卡,回合不再中断;run_command的 cwd 落在项目里,git 等不再「not a git repository」。设计要点(兼容优先)
chat:create-session从自己的 persona 记录解析并trustRoot(目录是用户在编辑器经系统对话框挑选后落盘的),与answerMount/chat:list-sessions的落盘恢复同级信任来源;渲染层传值不采信。chat:list-sessions恢复机制覆盖,无需新代码。workspace是新增 frontmatter 可选字段,旧.md(无此字段)解析为空串;种子改写走 spread 自动带回,幂等不破坏。改动面(8 文件,+102/-1)
main/services/personas.tsPersonaRecord.workspace+ frontmatter parse/serialize(fmScalar 引号化,路径含空格/中文安全)+ upsert 透传main/services/chat.tschat:create-session:缺省 focusRoot 且角色配置了有效目录 → 采用 + trustRoot;失效静默降级preload/index.tsPersonaRecord.workspace/PersonaUpsertInput.workspace?rendererProfileView.tsxrendererstore/extensions.tsxrenderermock/extensions.tsrendereri18n/messages.tsredesign.css.cf-editor__wsrow行样式(复用 cf-field/cf-btn 既有类)验证
tsc两套 tsconfig +electron-vite build干净;