Skip to content

Add Text Editor MiniApp (text-editor) - #25

Open
TrentChou wants to merge 1 commit into
MiniMax-AI:mainfrom
TrentChou:add-text-editor
Open

TrentChou wants to merge 1 commit into
MiniMax-AI:mainfrom
TrentChou:add-text-editor

Conversation

@TrentChou

@TrentChou TrentChou commented Oct 16, 2026 •

Copy link
Copy Markdown

A Sublime-style local text editor shared live with the Agent: MCP tools read, edit, create and save the same buffers the user sees, and review highlights (lines, character ranges or exact snippets, with notes) overlay code without touching files. Highlight lifetime is a user switch: gone once the code is edited or the file closed, or kept until cleared (also across restarts).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

A Sublime-style local text editor shared live with the Agent: MCP tools read,
edit, create and save the same buffers the user sees, and review highlights
(lines, character ranges or exact snippets, with notes) overlay code without
touching files. Highlight lifetime is a user switch: gone once the code is
edited or the file closed, or kept until cleared (also across restarts).

@MyPrototypeWhat MyPrototypeWhat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

感谢贡献这个编辑器!整体完成度很高:我在本地用 Node 22 跑了 npm run check,结果通过;也启动了服务,用无头 Chrome 和 MCP 调用实际测试了一遍。Agent 的修改能实时显示,高亮注释卡片正常,外部修改冲突时 save_file 会拒绝覆盖,二进制文件会被拒绝打开,Host/Origin 检查有效,反复刷新页面也没有 SSE 连接累积。另外我确认了这个 PR 和仓库里正在进行的检查规则更新(#24)合并后没有冲突,检查也能通过。

需要修改

  1. Agent 工具可以借助符号链接绕过“只能访问侧边栏文件夹”和“拒绝凭据文件”这两条限制,而且能写入。resolvePath() 和 isSensitivePath() 只检查字面路径,之后的读写会跟随链接。我在本地只把 proj/ 加进侧边栏,然后测试:
    • proj/src/notes.txt -> ~/.ssh/id_rsa:read_file 能读到私钥内容,write_file(save: true)会改写 ~/.ssh/id_rsa;
    • proj/linkdir -> ~:create_file proj/linkdir/.ssh/authorized_keys 能在侧边栏之外创建文件;
    • 另外 create_file 和 save_file 没有做凭据文件检查,create_file proj/.env.local 和 save_file proj/.env 都能成功。
      这和 README 里“只能访问侧边栏文件夹内的文件、拒绝读写凭据类文件”的说法不一致。建议先对路径(或者最近的已存在父目录)做 realpath,再判断它是否在侧边栏文件夹内、是否属于凭据文件,并在 create/save 也加上同样的检查。

建议(可选)

  1. editor-service.mjs:257 通过 dataDir 的上两级目录去找 hook 写的 active-workspace,这依赖宿主的目录结构。可以在 README 里说明一下,或者读取失败时记一条日志,免得以后宿主调整目录时这个功能悄悄失效。
  2. README 提到的隔离运行时测试如果方便,可以一起放进 tests/,方便以后回归测试。

if (!relativeToPrimary || !this.folders.length) throw new EditorError('INVALID_PATH', '需要绝对路径');
p = resolve(this.folders[0], p);
}
p = resolve(p);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里只做了字面上的 resolve()。侧边栏文件夹里的符号链接如果指向外部(比如 ~/.ssh/id_rsa),后面的 inFolders 和 isSensitivePath 检查都能通过,读写会跟着链接走。我本地已经用 read_file/write_file 复现。建议在这里对已存在的路径(或最近的已存在父目录)先做 realpath,再做这两项检查。

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.

2 participants