Skip to content

feat(pi-tui): port PLAN_MODE_BLOCKED + Windows step wrapper - #114

Open
Zi-Yi-Ming wants to merge 2 commits into
stepfun-ai:step-code-explore-pifrom
Zi-Yi-Ming:work/step-code-pi
Open

feat(pi-tui): port PLAN_MODE_BLOCKED + Windows step wrapper#114
Zi-Yi-Ming wants to merge 2 commits into
stepfun-ai:step-code-explore-pifrom
Zi-Yi-Ming:work/step-code-pi

Conversation

@Zi-Yi-Ming

@Zi-Yi-Ming Zi-Yi-Ming commented Aug 31, 2026

Copy link
Copy Markdown

关联 Issue

Closes #113

变更类型

  • [√] feat 新功能
  • fix bug 修复
  • docs 文档
  • refactor 重构(无行为变更)
  • test 仅测试
  • chore 构建 / 脚手架 / CI
  • perf 性能优化

影响范围

  • 改动了 packages/protocol/(跨边界协议,需要同步 SDK)
  • 改动了 packages/core/ 的公开 API
  • 改动了 src/gateway/(session authority 行为变更)
  • 改动了分层依赖(同步更新了 AGENTS.md.dependency-cruiser.cjs
  • [√] 仅 docs / 注释 / 测试

变更说明(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_BLOCKED
  • runTurnerrorCode 透传进 preset 与 tool_end 事件
  • scripts/run-step.mjs:Windows 自动检测 Bun/Node,支持 pnpm step
  • package.json:补充 step / step:fresh 脚本

测试计划

  • 单测:pnpm vitest run tests/agent/permission.test.ts tests/agent/runTurnParallel.test.ts
  • 手工验证:
    • pnpm step --help 可正常启动
    • plan mode 下调用写/执行工具时,前端收到带 errorCode 的拒绝结果

自检清单

  • [√] 本地相关单测通过
  • [√] 新行为有测试覆盖(permission + runTurnParallel)
  • [√] 未包含二进制、构建产物、密钥
  • 未使用 --no-verify 绕过钩子

Copilot AI lite review requested due to automatic review settings August 31, 2026 12:03
@github-actions github-actions Bot added the area/build scripts, .github, package.json, tsconfig, lockfile label Aug 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 errorCode to Authorization, ToolResult, AgentEvent(tool_end), and DisplayItem(kind:'tool'), and propagate it through runTurntool_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.mjs plus package.json scripts (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 thread scripts/run-step.mjs
Comment on lines +67 to +72
return runCommand(process.execPath, [
"--import",
pathToFileURL(require.resolve("tsx")).href,
entrypoint,
...scriptArgs,
]);
Comment thread package.json
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",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build scripts, .github, package.json, tsconfig, lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants