feat(pi-tui): port PLAN_MODE_BLOCKED + Windows step wrapper - #114
Open
Zi-Yi-Ming wants to merge 2 commits into
Open
feat(pi-tui): port PLAN_MODE_BLOCKED + Windows step wrapper#114Zi-Yi-Ming wants to merge 2 commits into
Zi-Yi-Ming wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a structured errorCode to tool-deny/tool-result pathways so the pi-tui frontend can distinguish “plan mode blocked” from other failures, and introduces a pnpm step wrapper script intended to make Windows startup easier.
Changes:
- Add optional
errorCodetoAuthorization,ToolResult,AgentEvent(tool_end), andDisplayItem(kind:'tool'), and propagate it throughrunTurn→tool_end→ pi-tui transcript. - In pi-tui plan mode, deny write/exec tools with
errorCode: 'PLAN_MODE_BLOCKED'(instead of only a text reason). - Add
scripts/run-step.mjspluspackage.jsonscripts (step,step:fresh) and tests covering the new behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/agent/runTurnParallel.test.ts | Adds coverage asserting denied authorization can propagate errorCode into tool_end. |
| tests/agent/permission.test.ts | Tightens expectations for plan-mode deny messaging guidance. |
| src/tui-pi/PiChat.ts | Emits PLAN_MODE_BLOCKED on plan-mode deny and stores errorCode into tool display items on tool_end. |
| src/tools/types.ts | Extends ToolResult with optional errorCode. |
| src/chat/types.ts | Extends tool DisplayItem with optional errorCode. |
| src/agent/runTurn.ts | Propagates errorCode from authorization deny → preset tool result and from tool result → tool_end event. |
| src/agent/hooks.ts | Extends Authorization deny shape to include optional errorCode. |
| src/agent/events.ts | Extends tool_end event shape to include optional errorCode. |
| scripts/run-step.mjs | Adds Bun/Node detection wrapper for running src/main.ts. |
| package.json | Adds step / step:fresh scripts and ships the wrapper script. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+67
to
+72
| return runCommand(process.execPath, [ | ||
| "--import", | ||
| pathToFileURL(require.resolve("tsx")).href, | ||
| entrypoint, | ||
| ...scriptArgs, | ||
| ]); |
Comment on lines
40
to
+42
| "start": "node dist/main.js", | ||
| "step": "node scripts/run-step.mjs", | ||
| "step:fresh": "node scripts/run-step.mjs --full", |
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.
关联 Issue
Closes #113
变更类型
影响范围
packages/protocol/(跨边界协议,需要同步 SDK)packages/core/的公开 APIsrc/gateway/(session authority 行为变更)AGENTS.md与.dependency-cruiser.cjs)变更说明(why,而非 what)
当前 pi-tui 前端在 plan mode 下拦截写/执行工具时,只返回纯文本拒绝原因,前端无法区分「工具不存在」和「当前模式不允许」。本 PR 在 pi-tui 的 deny 路径增加结构化
errorCode: 'PLAN_MODE_BLOCKED',并补上 Windows 上pnpm step的 Bun/Node 自动检测 wrapper,降低 step-code 风格终端渲染的启动门槛。关键点:
Authorization/ToolResult/AgentEvent/DisplayItem增加errorCode可选字段PiChat.authorizeToolCall在 plan mode 下返回PLAN_MODE_BLOCKEDrunTurn将errorCode透传进 preset 与tool_end事件scripts/run-step.mjs:Windows 自动检测 Bun/Node,支持pnpm steppackage.json:补充step/step:fresh脚本测试计划
pnpm vitest run tests/agent/permission.test.ts tests/agent/runTurnParallel.test.tspnpm step --help可正常启动errorCode的拒绝结果自检清单
--no-verify绕过钩子