powercode-py adds approval-gated Plan Mode for coding agents
The Juejin AI article describes powercode-py, a Python reimplementation of Teernage/powercode created to help developers study agent internals without learning Node/TS. Its Plan Mode uses a state machine and code-level tool restrictions so the agent can inspect files and submit a plan, but cannot edit files or run commands until the user approves it. The article also documents approval, revision, cancellation, and plan-file handling flows.
The report presents a concrete implementation of enforceable planning boundaries, including hiding write and shell tools during planning and pausing the agent loop for approval rather than relying only on prompt wording.
为什么会有本系列
本系列【手搓 AI Agent · Python 版】是手搓 Agent 教学项目 Teernage/powercode 的 Python 重实现版本;为什么要做这个系列呢?是因为当我在掘金社区刷到 @不一样的少年_ 大佬的【不用框架,手搓 AI Agent】系列时,感觉写得很好,但是想深入学习时,发现代码都是 Node/TS 实现。想掌握技术细节,但看得似懂非懂,如果先学习 Node/TS,又感觉成本太高。于是就想着实现一个 Python 版本的手搓 Agent 系列,以便让自己能更深入学习 Agent 的相关技术细节。整理成博客,以便那些熟悉 Python 但不熟 Node/TS 的小伙伴能一起进步成长;当然如果你已有 Node/TS 基础,强烈建议去学习 【不用框架,手搓 AI Agent】系列,真的很棒。再次感谢 Teernage 大佬的开源分享。
本系列的源码 powercode-py,本篇对应 commit ea3be10;如果你觉得对你有帮助,请点个 star ⭐。
上篇回顾:上一篇给 AI 发了本账(Session),一次启动能连续追问,聊长了还会自动把旧账折叠成摘要。 本篇目标:让它别"一问就动手"——先只读着摸清项目,交出一份计划等你点头,批准了才恢复改文件、跑命令。