凌晨两点,整间屋子只剩下一块屏幕还亮着。
终端里的最后一行,孤零零停在这一句前,光标一闪一闪:
Do you want to proceed? (y/n)
没崩,没报错,没超时。它只是在等一个人按回车。而那个人在睡觉。
睡前你给它派了一件挺大的活:重构某个历史老代码模块,顺便把测试补齐。你以为这下能当个“甩手掌柜”,美美睡上一觉,明早起来直接检阅成果。
但现实往往兜头一盆冷水:它跑了不到三分钟,在第一个需要你点头的地方停住了。后面的步骤,一步都没发生。
不是“后面跑完了卡在前面”,是“还没真正开工就直接停摆”。一整夜,几台风扇呼呼吹着,全在给空气交电费。
如果你也经历过这种大清早的窒息感,这篇文章就是为你写的。为了补上这个让无数开发者咬牙切齿的漏洞,我们在终端里做了两件事:一个总管(Supervisor),和一个总控台(Control Room)。
一、明明开了 Auto Mode,它到底在停什么?
很多人第一反应是:“现在 Claude Code 不是都有 Auto Mode(--permission-mode auto)了吗?读文件、写代码、跑命令全都自动过,怎么可能还会停?”
Auto Mode 确实解决了一大半问题。但它本质上是一张**“门禁卡”,而不是“免死金牌”**。它会自动放行常规动作,但只要撞上四堵墙,它还是会老老实实刹车等你:
- 白名单之外的外部命令:稍微冷门或系统级的指令,它不敢自作主张;
- 需要交互式应答的安装流程:某些 npm、pip、apt 在拉包时冷不丁弹出一个 y/n,或者要你输入配置项;
- 带破坏性的敏感操作:比如批量删除文件、覆盖未经暂存的代码;
- 子程序自己在等输入:比如某个脚本跑起来之后自己打出一行 Press any key to continue。这种情况下连 Claude Code 自己都没法替你答,因为提问的不是 AI,是对面那个程序。
这不是偶尔倒霉。在社区公开收集的几十条长任务抱怨里,最刺眼的就是这种:“一个定时任务,按定义就该是无人值守的,结果硬生生被确认框憋死了一夜。”
至于后来有些工具加的“60 秒没人理就自作主张往下走”,更是按下葫芦浮起瓢——你要的是“别卡死”,它给的是“替你盲猜做决定”。真要把删目录的操作盲猜放行了,早上起来恐怕就不是重构代码,而是重构人生了。
判断一:卡在确认框上,是全世界唯一一种“不花钱也不报错”的停摆。它不烧 Token,不写一行 Error 日志,只是安安静静地耗掉你整个通宵。
二、tmux 和系统响铃,为什么全盯错了东西?
有人说:“这还不简单?挂个 tmux,再配个终端响铃(bell)监听脚本不就行了?”
这个路子很多人试过,但实际跑起来有两个致命硬伤:
第一个硬伤很现实:你人都睡着了,响给谁听?
手机静音,微信免打扰,电脑音量开到最低——半夜两点那一声细若游丝的“叮”,根本不可能把你从梦里叫醒。
第二个硬伤更要命:响铃根本分不清现场。
任务跑完了,响一声;卡在确认框了,响一声;程序死循环疯狂刷屏打日志,它还在拼命响。三种完全不同的事,在耳朵里长得一模一样。提示音一多,人会麻木,真出事的那一声你只会当成噪音。
再往底层想一步,就抓到了核心矛盾:
日志在动,不等于它在干活;日志不动,不等于它死了。
屏幕上一行行字飞快往上滚,可能是正在老实编译,也可能掉进了重试死循环;屏幕静止半天没反应,可能是正卡在确认框上干等,也可能只是在跑一个长达 15 分钟的巨型测试集。
外层的监控程序只要不去看屏幕上的文字本身,就永远是一头雾水。
想分清楚,只有两条路:要么你通宵睁着眼自己看;要么,在终端里配一个不用睡觉的值班员替你看。
我们在 Polter 里做的**“总管”**,就是这个值班员。
三、总管:一个不用睡觉的终端值班员
说白了,Polter 是一个自带控制中枢的终端。你在里面开几个标签页,挑出其中一个 Claude Code 会话,指定它当**“总管 (Supervisor)”**。
总管本身并没有接入神仙模型,用的依然是你原本装好的那个 CLI。但 Polter 给了它一组原生的控制工具——相当于给它配了一双能看清其他终端的眼睛,和一双能替它们敲键盘的手。
它是怎么解决半夜停摆的?核心就靠三招。
1. 读的是纯文本,绝不用截图 OCR 识字
总管读别的终端屏幕,走的是内存底层的 terminal_read,拿回来的是纯文本字符,而不是一张屏幕截图。
这里面的技术考量非常实在:如果每隔一会儿截一张图让大模型去肉眼认字,不仅 Token 费用贵得像流水,而且很容易把代码框线、颜色高亮甚至下划线认错。而纯文本就是终端 VT 缓存里的字符本身,Do you want to proceed? (y/n) 这一行字,模型一眼就能认准,绝不会认歪。
总管给其他终端下指令,走的也是纯文本管道(terminal_send 打字,terminal_key 发送特殊按键),就像隔壁工位的老手伸手指在键盘上帮你点了一下。
2. 屏幕静止 3 分钟主动推送,绝不死循环轮询
很多自动化脚本最容易犯的错误,是让总管每隔 10 秒跑去问一次:“你们都还活着吗?”
这等于亲手给自己写了个烧钱死循环——活还没干完,Token 全花在“证明自己还活着”上了。
Polter 的做法极其克制:总管平时彻底休眠,不问也不查。
终端底层自己跑着一个轻量的计时器,它只盯着一件事:“这块屏幕有多久一个字都没变过了?”一旦屏幕连续静止达到了设定阈值(比如默认的 3 分钟),底层会主动给总管推送一条通知,把总管叫醒。
总管醒来之后,才走过去读一眼屏幕,看看究竟是卡住了,还是在思考。
而且这里面设了两个独立的时钟:
- 屏幕静止时钟(多久没变画面,默认 3 分钟);
- 工具调用时钟(多久没调底层工具,默认 15 分钟)。
为什么分开?因为“屏幕不动但正在跑编译”是正常的,而“屏幕疯狂刷屏但 AI 很久没反应”很可能是跑飞了。只有把这两个状态分开算,才不会动不动虚晃一枪乱报警。
3. 能答的自己答,危险的叫醒人
总管被叫醒、读到那行 Do you want to proceed? (y/n) 之后,它会做分级处理:
- 常规、安全、能确定的动作:比如“是否运行测试套件”、“是否安装已知依赖”,总管直接替它按个回车放行,让流水线继续往前冲;
- 拿不准、破坏性、高风险的操作:比如“是否删除整个模块”、“是否强制覆盖未保存文件”,总管立刻停手,向你的系统弹窗报警,并把这个任务推到你的待办清单里。
安全边界还做了逐终端的防护:只有总管自己拉起来的 Worker,才默认开启代答;你自己的主工作终端,除非你在右键菜单里主动放开,否则总管碰都不能碰。如果你想彻底防偷窥,还能一键开启“终端屏蔽”——被屏蔽的终端,没有任何工具能调动,谁也打不开。
这就是 Polter 的底线:哪怕半夜通宵卡死,也绝不能替你胡乱按“是”去删库。
四、总控台:早上睁眼,一屏看完全场
夜里的苦活累活交给了总管,而早上起来的验收,就全交给了总控台(Control Room)。
在 Polter 里打开总控台(或者直接跑 polter +chat),界面被清清爽爽切成了三个核心页签:
- 群聊页签(Chat):各个终端就像在一个工作群里,总管派了什么活、哪个终端接了哪一部分、中途报了什么进度,逐行对齐,再也不用在十几个标签页之间切得眼花缭乱;
- 任务看板(Tasks):像一个全自动的轻量敏捷看板,列着每项任务的负责人和状态——排队中(queued)、施工中(working)、卡住了(blocked)、已搞定(done);
- 统计页签(Stats):一目了然看完全晚的时间流水,谁跑了多久,谁中间发呆了多少分钟。
判断二:早上验收通宵跑完的代码,先看任务面板,别先急着看 diff。
标着 blocked 的,是中途遇到安全红线卡住了,需要你人工拍板;而压根没在面板上出现的任务,是前面的前置条件没成、压根没派出去。先看清这两者的区别,你的思路才不会乱。
五、所有记录留在本地,没有任何云端黑盒
很多人会担心安全问题:“又是多终端监控又是自动敲键盘,我的代码和密钥安全吗?”
答案很简单:Polter 是纯本地的。
所有数据——群聊记录、任务看板、终端逐行日志——全都安安静静落在你本机的 $XDG_STATE_HOME/polter/ 目录里。它不需要你注册账号,不需要接入任何云端服务器,它自己甚至压根不向任何大模型发网络请求。干活的始终是你原本装在 Mac 或 Windows 上的本地 CLI,Polter 只充当底层的终端调度容器。
早上想复盘,随手一条 grep 命令,昨天夜里几点几分发生了什么、打印了什么,全部原汁原味地摆在那里。
六、明早开工前,先做这一个小动作
回顾最开头的那行提示:
Do you want to proceed? (y/n)
AI 之所以在半夜停下来,不是它变笨了,而是它遇到了一个只有人类才能授权的十字路口。而偏偏在这个时候,人类去睡觉了。
让 AI 真正通宵干活,需要的从来不是更玄学的 Prompt,而是一个不用睡觉、能在屏幕静止时被叫醒、并且知道什么该代答什么该报警的值班机制。
今晚睡前,给你的长任务派完活之后,不妨试试换个方式:
明早闹钟响起时,别急着把头埋进乱糟糟的代码 diff 里——先敲开总控台,看看面板上的任务究竟是 done 还是 blocked。那一屏清爽的进度,才是属于工程师真正的睡眠自由。
本文由 AI图鉴自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
At 2 a.m., there was only one screen left in the room.
The last line in the terminal, all alone, stops in front of this sentence, and the cursor flashes:
Do you want to proceed? (y/n)
No crash, no error, no timeout. It's just waiting for someone to press back. And that man is sleeping.
You've given it a big job before you go to bed: to reset some old history code module and complete the test. You think this is going to be a "scrambling table," a good night's sleep, and you get up in the morning and read the results.
But reality tends to go through the first bowl of cold water: it runs in less than three minutes and stops in the first place where you need to nod. The next steps did not take a single step.
It's not "the back end is stuck in the front," it's "the stop before work really starts." Throughout the night, several fans were whistling and paying for the air.
If you've experienced this early suffocation, it's for you. Two things we did in the terminal to make up for this loophole, which caused numerous developers to bite their teeth: a Master and a Controll Room.
First, it's open. Auto Mode, what is it stopping?
Many people's first reaction was, "Now, isn't there Auto Mode? How can you stop reading documents, writing codes, running orders?
Auto Mode did solve half the problem. But it's essentially a “door card”**, not a “gear free”.** It'll automatically release the routine, but if it hits four walls, it'll still wait for you:
- External orders outside the white list: a slightly cold door or system-level order, which does not dare to assert itself;
- Installation processes requiring interactive responses: some npm, pip, apt pops out of a y/n when pulling or requires you to enter a configuration;
- Disruptive and sensitive operations: for example, mass deletion of files, overlaying unsustained codes;
- The sub-program itself waits for input: for example any key to enter. In this case, even Claude Code can't answer for you because it's not AI, it's the right program.
It's not occasionally bad luck. Among the dozens of long missions publicly collected by the community, the most striking is this: “A time-bound mission, by definition, should be unserving, as a result of which the hard-born was held up overnight”.
And later on, some of the tools added, “60 seconds without a reason” to go down, and even more, to float down, and you wanted to “do not get stuck”, and it gave you “decisions for your blind guess”. I'm sure I'm going to let go of the decatalogue operation, so I'm not going to wake up in the morning to recode, but to recreate life.
Judgement one: The box of confirmation is the only “no money, no fault” stop in the world. It doesn't burn Token, doesn't write a line of Error's logs, just squirting you all night.
Two, tmux and the system ring the bell.
Some say, "Isn't it simple? Why don't you hang a tmux and have a bell to listen to the script?"
A lot of people have tried this, but there are two fatal hard wounds:
The first wound is real: who are you all asleep for?
Cell phone silence, WeChat free of interference, computer volume goes down to a minimum — two o'clock in the middle of the night with a little ding-ding, it's impossible to wake you up from a dream.
The second hard wound is even worse: the ringing bell simply does not distinguish the scene.
The mission is over, and it's ringing; it's stuck in the confirmation box, it's ringing; the program's death cycle is scrambling the logs, and it's still scrambling. Three completely different things, identical in their ears. There's more than one tone. People are numb. The sound of a real accident is just noise.
One more step to the bottom, and the core contradiction is caught:
The log is moving, it's not working; it's not moving, it's dead.
On the screen, the line goes up, it's either being compiled honestly, or it's falling into the retry death cycle; the screen is still silent for half a day, it's probably stuck in a confirmation box and waiting, or it's just running a 15-minute megatest set.
The external monitoring program is always a fog as long as it does not look at the text on the screen itself.
There are only two ways: either you look at yourself all night; or you can have a non-slept shift at the terminal.
What we're doing in Polter is this watchman.
III. Managing director: a terminal watchman without sleeping
Frankly, Polter is a terminal with a control hub. You open a couple of tabs in there, pick out one of Claude Code's sessions and designate it as** “Supervisor”**.
The director himself did not access the fairy model, but still used the CLI that you originally installed. But Polter gave it a set of original control tools... - It's a pair of eyes that can see the other terminals and a pair of hands that can knock on their keyboards.
How'd it work out at midnight? Three moves at the core.
1. Read in plain text, never using screenshot OCR
The mains are reading other terminal screens, which go to the bottom of the memory, where the characters are pure text, not a screenshot.
The technical considerations in this are very real: if LLM is to read every second, not only does Token cost as much as running water, but it can easily identify code frames, colours, and even underlined. And the pure text is the character in the terminal VT Z96Z, Do you want to develop? (y/n) The line, the model can be identified at once and never.
The mains give instructions to other terminals and go through the pure text pipe (typing, special buttons sent by the triminal key), just like the old hand-painted finger on the keyboard next door.
2. Screen static 3 minutes of active delivery, never dying in the loop
A lot of automated scripts are the easiest mistake of having the manager run every 10 seconds to ask, "Are you all alive?"
It's like writing yourself a burn-and-kill cycle -- work that's not done yet, Token spent on proving he's alive.
Polter's approach was extremely restrained: the general was completely dormant, without asking or checking.
The bottom of the terminal runs a light-weight timer, and it's just staring at one thing: "How long has this screen not changed a word?" Once the screen has been static continuously to the set threshold (e.g., the default of 3 minutes), the bottom will proactively send a notice to the manager to wake up.
After the manager woke up, he went over to the screen to see if it was stuck or thinking.
And there are two separate clocks:
- A static clock on the screen (for how long, 3 minutes default);
- tool call clock (how long has the bottom tool not been adjusted, default 15 minutes).
Why are you separated? Because "screens don't move but they're running" is normal, and "screens are crazy but AI hasn't responded" is probably running away. It is only by separating the two situations that the police will not be shot and shot.
3. Answer yourself if you can.
Do you want to read?
- Regular, safe and determinable actions: such as " running test packages ", " installing known dependencys ", for which the head of the service will simply follow the wheel and keep the flow of water moving forward;
- Unauthorized, destructive and high-risk operations: “Whether or not to delete the entire module”, “Whether or not to enforce the coverage of unsaved documents”, the manager immediately stops, alerts your system window and puts the task on your to-do list.
Safe borders are also protected by end-to-end protection: only Worker, who pulls himself up, opens the answer by default; your own main working terminal, which cannot be touched unless you release it in the right-key menu. If you want to be completely protected from peeking, you can also open the terminal shield -- the shielded terminal -- without any tools to move, and nobody to open it.
This is the bottom line for Polter: even if you die overnight, you can't just press "yes" to delete the library.
iv. General Console: Open in the morning, full screen Field
The night work was given to the chief, while the morning acceptance check was given to the general control (Controll Room).
Opens the master console in Polter (or runs directly polter +chat), the interface is cleared and cut into three core pages:
- Round-up of pages (Chat): The terminals are like a group of people who have been assigned by the executive, which part of the terminal has been taken up, which progress has been reported in the middle, line-by-line, and no longer have to cut their eyes between a dozen labels;
- Tasks: Like a fully automated lightweight viewer, lists the person responsible for each task and the status of the mission. - Queued, working, stuck, done;
- Statistical Pages Signing (Stats): Looking at how late it is, how long it has run and how many minutes it has been.
Adjudication two: acceptance check's overnight running code, check the task panel first, not diff first.
It's marked with a security red line that's stuck in the middle of the road, and it's a manual board; it's not on the panel, it's a prefix that's not done, it's not sent. Let's see the difference between the two before your thinking gets messy.
V. All records left locally, no cloud black boxes
Many people are worried about security: "Is my code and key secure, again multi-end surveillance and automatic keyboard?
The answer is simple: Polter is purely local.
All data -- group chat records, task boards, terminal-by-line logs -- are settled in your home directory of $XDG STATE HOME/polter. It doesn't need your registration number, it doesn't need access to any cloud server, it doesn't even request any LLM network. You're always working on the local CLI, Polter, which was installed on Mac or Windows.
In the morning, I tried to reset it, with a grep order, what happened at a few points last night, what was printed, and all the juice was there.
Six, before work starts in the morning.
Look at the beginning of the line:
Do you want to proceed? (y/n)
AI stopped in the middle of the night not because it became stupid, but because it met a crossroads that only human beings could authorize. And at this point humans go to sleep.
What is needed for AI to actually work all night is never a more genus Prompt, but a duty-keeping mechanism that does not sleep, that wakes up when the screens are still, and that knows what to answer for.
Before you go to bed tonight, after your long assignment, try something different:
When the alarm rings in the morning, don't rush into the messy code diff -- knock on the main console and see if the task on the panel is done or blocked. That smooth pace is the real freedom of sleep for engineers.
Auto-fetched and translated by AI Atlas. All rights belong to the original author.