fix: ui.theme 契约实例 + Windows ui-plugins junction(#28) - #34
Merged
Conversation
问题:makeUiContext 给扩展的 ctx.ui.theme 是空对象强转
({} as ExtensionUIContext["theme"]),而 pi 扩展契约要求带
fg()/bg()/bold() 等方法的 Theme 对象。任何 theme.fg(...) 调用
抛 TypeError——pi-mcp-adapter 的 updateStatusBar 因此崩溃,
其 catch 把异常转成连接失败,所有 MCP 服务器永久 not-connected;
其他用 theme 的扩展(setStatus/setWidget/setFooter/
setWorkingIndicator/registerEntryRenderer)同隐患。
修复:模块级 EXTENSION_THEME = new Theme(...),静态中性暗色盘 +
truecolor。用真实类实例而非手写 pass-through 对象:Theme 有 12+
方法(italic/underline/inverse/getFgAnsi/getThinkingBorderColor…),
漏一个扩展还是会崩;真实实例全量覆盖。桌面端样式输出全落 no-op
sink,不消费 ANSI,故无需跟随 GUI 亮暗主题。色表构造受 TS 约束,
SDK 升级新增必填色时 typecheck 报错提醒。
测试:test/ui-context.test.ts 契约回归(全部样式方法可调用返回
字符串 + 全部 ThemeColor 枚举值 fg() 不缺色)。
Windows 普通用户创建符号链接需要管理员权限或开发者模式 (SeCreateSymbolicLinkPrivilege),seedDocs 的 symlink 每次 启动必抛 EPERM(#28 附报),~/.percho/ui-plugins 永远建不上, agent 按规范路径读 SPEC/_examples 的通道断掉。 修复:Windows 传 "junction" 类型(目录联接不需提权,行为等价 ——目录型链接、realpath 正常解析);其他平台保持真 symlink, lstat/realpath 判定路径两平台一致。链接失败日志带上真实插件 目录路径,便于用户排查。
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.
修复 #28(主要问题)及其附报的 Windows symlink 问题。
1. ui.theme 提供契约 Theme 实例(#28 主问题)
问题:
makeUiContext给扩展的ctx.ui.theme是空对象强转({} as ExtensionUIContext["theme"]),而 pi 扩展契约要求带fg()/bg()/bold()等方法的 Theme 对象。任何theme.fg(...)调用抛TypeError——pi-mcp-adapter 的updateStatusBar()因此崩溃,异常被 adapter 自己的 catch 转成连接失败,所有 MCP 服务器永久 not-connected。其他用 theme 的扩展 API(setStatus/setWidget/setFooter/setWorkingIndicator/registerEntryRenderer)同隐患。修复:模块级
EXTENSION_THEME = new Theme(完整色表, bg表, "truecolor"),用真实类实例而非手写 pass-through 对象——Theme 有 12+ 方法(italic/underline/inverse/getFgAnsi/getThinkingBorderColor…),手写对象漏一个扩展还是会崩。设计取舍:
Theme类直构,而非深路径getThemeByName(包 exports map 封死深路径,且 JSON 读取在 asar 里更脆)2. Windows 下 ui-plugins 稳定路径降级 junction(#28 附报)
问题:Windows 普通用户创建符号链接需要管理员权限或开发者模式,
seedDocs()的symlink每次启动必抛EPERM,~/.percho/ui-plugins永远建不上——agent 按规范路径读 SPEC/_examples的通道断掉。修复:Windows 传
"junction"类型(目录联接不需提权,realpath正常解析,下次启动的 lstat/realpath 判定不受影响);其他平台保持真 symlink。链接失败日志带上真实插件目录路径。测试
test/ui-context.test.ts契约回归:全部样式方法可调用返回字符串 + 全部 45 个 ThemeColor 枚举值fg()不缺色。关联
ui.theme是字符串而非 Theme 对象,导致所有 MCP 服务器永久无法连接 #28