refactor(tui): 删除 & <command> 工作区命令旁路#421
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| func defaultBaseDir() string { | ||
| home, err := os.UserHomeDir() | ||
| if err != nil { | ||
| home := strings.TrimSpace(os.Getenv("HOME")) |
There was a problem hiding this comment.
defaultBaseDir now prefers raw HOME over os.UserHomeDir(). If HOME is set but relative (for example . in some shells/CI wrappers), the default path becomes relative (./.neocode) and silently drifts from the documented home-directory behavior. Consider accepting HOME only when absolute (or normalize and validate), otherwise fall back to os.UserHomeDir().
| func defaultBaseDir() string { | ||
| home, err := os.UserHomeDir() | ||
| if err != nil || strings.TrimSpace(home) == "" { | ||
| home := strings.TrimSpace(os.Getenv("HOME")) |
There was a problem hiding this comment.
Same default-base-dir regression risk as runtime config loader: using raw HOME without absolute-path validation can redirect migration target to a relative directory unexpectedly. Keeping script behavior aligned with loader is good, but both should validate HOME (absolute + non-empty) before trusting it.
|
@xgopilot 批判性review整个PR,分析所有潜在风险点,找出所有漏洞,确保每个地方的修改不是退步的,方案上的设计也不能碎片化,更不能妥协式兼容或兜底旧代码,不许输出正向表扬 |
Findings
Open Questions
|
@xgopilot 修复 |
|
已按本线程 4 条 findings 完成修复并推送到当前 PR 分支 修复内容
验证结果
未做项
|
- enforce absolute HOME for default config base dir resolution - add ampersand plain-text send regression test in TUI - add branch coverage for session permission fallback and atomic fsync Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
Summary
本 PR 删除 TUI 中
& <command>的工作区命令执行能力,不再允许通过聊天输入框直接触发本地 shell 执行。删除后,
& ...不再被识别为特殊命令入口,而是按普通文本输入处理。NeoCode 内部不再保留这条绕过主链的 TUI shell 旁路,用户如需自由执行命令,应使用外部真实终端。Background
当前
& <command>走的是一条独立执行链路:这条链路与现有 TUI / Runtime / ToolManager 主链完全分叉,带来几个问题:
本次改动选择直接删除该能力,而不是继续保留中间态。
Changes
Removed command entry
& <command>的输入识别与解析逻辑Removed execution path
RunWorkspaceCommandCmdWorkspaceCommandResultMsgDefaultWorkspaceCommandExecutorinternal/tui/infra/workspace_exec.goRemoved UI and documentation residue
& <command>建议项& <command>使用说明Removed obsolete tests
Behavior Change
Before
会被 TUI 当作本地工作区命令执行。
After
会被当作普通文本输入处理,不再触发本地命令执行。
Validation
已确认:
& <command>相关旧符号、旧文案、旧测试残留已清理go test -run '^$' ./...通过,说明当前改动下全仓编译通过RunWorkspaceCommandCmd、WorkspaceCommandResultMsg、DefaultWorkspaceCommandExecutor、& <command>等残留引用说明:
go test ./...目前仍存在仓库既有的 Windows 权限问题,错误集中为:config: write config file: sync target directory: ... Access is denied& <command>无直接关系,本 PR 未引入新的测试失败类型Risk
这是一个显式行为变更:
& <command>的用户工作流会失效Notes
本 PR 不尝试:
& <command>迁移到 ToolManager!模式或兼容提示若后续仍需要“用户在 NeoCode 内直接运行命令”的能力,应以独立产品语义重新设计,而不是恢复这条旧旁路。