发动机 · 把一个真实报错修到好The Engine · Take One Real Error to Fixed.
Agent Mode 不是更聪明的补全,是一个会读你终端状态、会多步动手的发动机。这章从头到尾跑通一件事:dev server 起不来,从交办开始,看它读报错、提命令、你审、它跑、出错自己改,直到修复验收。附任务合同模板和喂上下文的方法。Agent Mode is not a smarter autocomplete — it is an engine that reads your terminal state and acts in multiple steps. This chapter runs one thing end to end: a dev server that won't start, from dispatch to watching it read the error, propose commands, you review, it runs, self-corrects, to verified fixed. With a task-contract template and the context-feeding method.
上一章的底座只能到「找回命令」为止。这一章开始是 Warp 真正的发动机:一个会读你终端状态、把活拆成多步、跑命令、读输出、出错自己改的 agent。光讲机制没用,所以这章从头到尾跑通一件真事 —— dev server 起不来,报 EADDRINUSE,从交办开始,到修复验收结束。你盯着看:它每一步干什么,你每一步审什么。Last chapter's base stops at 'recovering commands.' This chapter starts Warp's real engine: an agent that reads your terminal state, breaks work into steps, runs commands, reads output, and fixes its own errors. Mechanism alone teaches nothing, so this chapter runs one real thing end to end — a dev server that won't start, an EADDRINUSE, from dispatch to verified fix. Watch what it does at each step, and what you review at each step.
— I
主线:把 EADDRINUSE 修到好The Main Line: Take EADDRINUSE to Fixed.
场景:npm run dev 起不来,终端里躺着一块报错。传统路径是:复制错误、开浏览器、搜、在三个 Stack Overflow 答案里挑一个、回来试、不行再搜。这次我们把它交办出去,一步一步看。1注 1Note 1Warp Docs · Terminal and Agent modes —— 截至 2026-08-06:Terminal(默认,跑 shell)与 Agent(多轮对话视图)两种模式;auto-detection 新用户默认开,提交前以 magenta 的 (autodetected) 标注分流;⌘↩ 起新 agent 会话,⌘Y 继续上一段,⌥⌘↩ 起云端 agent 会话;⌘I 是语境键(见第三章)。Warp Docs · Terminal and Agent modes — as of 2026-08-06: Terminal (default, runs shell) vs Agent (multi-turn conversation view); auto-detection on by default for new users, marking the route with a magenta (autodetected) label before submit; ⌘↩ starts a new agent conversation, ⌘Y continues the last, ⌥⌘↩ starts a cloud agent conversation; ⌘I is contextual (see chapter 3).The scene: npm run dev won't start and a block of error output sits in your terminal. The traditional path: copy the error, open a browser, search, pick one of three Stack Overflow answers, come back, try, fail, search again. This time we dispatch it, step by step.1注 1Note 1Warp Docs · Terminal and Agent modes —— 截至 2026-08-06:Terminal(默认,跑 shell)与 Agent(多轮对话视图)两种模式;auto-detection 新用户默认开,提交前以 magenta 的 (autodetected) 标注分流;⌘↩ 起新 agent 会话,⌘Y 继续上一段,⌥⌘↩ 起云端 agent 会话;⌘I 是语境键(见第三章)。Warp Docs · Terminal and Agent modes — as of 2026-08-06: Terminal (default, runs shell) vs Agent (multi-turn conversation view); auto-detection on by default for new users, marking the route with a magenta (autodetected) label before submit; ⌘↩ starts a new agent conversation, ⌘Y continues the last, ⌥⌘↩ starts a cloud agent conversation; ⌘I is contextual (see chapter 3).
01
⌘↩ 开会话,@ 指上报错那块⌘↩ to open a conversation, @ the error block
在终端里按 ⌘↩ 起一个新 agent 会话。第一件事不是打字,是喂上下文:用 @ 把刚才那块 EADDRINUSE 输出指进 prompt —— 让它就着真实报错答,而不是凭印象答。然后贴上下面 PromptBox 示例 tab 里那段话。Press ⌘↩ in the terminal to start a new agent conversation. The first move isn't typing — it's feeding context: use @ to point the EADDRINUSE block into the prompt, so it answers against the real error, not from memory. Then paste the sentence from the Example tab of the PromptBox below.
02
审它的计划,不审它的措辞Review its plan, not its prose
它先回一份计划:查谁占了 3000 端口、判断进程身份、给你建议、等你确认再动手、最后重跑验证。你审三件事:方向对不对、第一步是不是只读、它有没有打算跳过你直接 kill。都对,才放行。It answers with a plan first: find what holds port 3000, identify the process, advise you, wait for your confirmation before acting, then re-run to verify. You review three things: is the direction right, is the first step read-only, is it trying to kill something without asking. Only then let it run.
03
每条命令摆出来,逐条放行Every command shown, approved one by one
它要跑 lsof -nP -i :3000 —— 只读,放行。它读完输出,告诉你占端口的是上周那个没关干净的 node 进程,然后提议 kill 41782 —— 这一步是写操作,它会停下来等你。你确认那是自己的残留进程,放行。这就是「交办」的真实手感:方向盘在你手里,油门在它脚上。It proposes lsof -nP -i :3000 — read-only, approve. It reads the output, reports the port is held by a leftover node process from last week, then proposes kill 41782 — a write, so it stops and waits. You confirm it's your own stale process and approve. This is the real feel of dispatching: the steering wheel stays in your hands, the throttle is on its foot.
04
出错它自己改,改完你要复验It self-corrects errors; you re-verify the fix
如果 kill 之后端口仍占着,它会自己读新报错、换 kill -9 或换思路再试 —— 自纠错是发动机的标配。2注 2Note 2Warp Docs · Warp Agents overview —— 本地 agent 嵌在终端里,能写代码、debug、运行命令、自动化开发任务;用户保持控制权;对话可带代码库、Warp Drive、连接工具与上下文。Warp Docs · Warp Agents overview — local agents are embedded in the terminal and can write code, debug, run commands, and automate development tasks; the user stays in control; conversations can draw on codebase, Warp Drive, connected tools, and context.但「它说好了」不算好:最后它重跑 npm run dev,你要亲眼看到 Ready on http://localhost:3000 才算验收通过。验收标准在交办那句话里就写死了。If the port is still held after the kill, it reads the new error itself, switches to kill -9 or another approach and retries — self-correction is standard equipment on this engine.2注 2Note 2Warp Docs · Warp Agents overview —— 本地 agent 嵌在终端里,能写代码、debug、运行命令、自动化开发任务;用户保持控制权;对话可带代码库、Warp Drive、连接工具与上下文。Warp Docs · Warp Agents overview — local agents are embedded in the terminal and can write code, debug, run commands, and automate development tasks; the user stays in control; conversations can draw on codebase, Warp Drive, connected tools, and context. But 'it says it's fixed' isn't fixed: it re-runs npm run dev, and only when you see Ready on http://localhost:3000 with your own eyes does acceptance pass. The acceptance criterion was nailed down in the dispatch sentence.
提示词PromptEADDRINUSE 交办词:只读先行,动手先问EADDRINUSE dispatch: read-only first, ask before acting
@<报错那块输出> dev server 起不来。
1. 只读排查:找出是什么占了端口,它是什么进程;
2. 每条命令先给我看我确认再跑;
3. 杀进程之前必须问我,我说杀才杀;
4. 修好后重跑启动命令,把「起起来了」的证据给我看。@<the error block> the dev server won't start.
1. Read-only diagnosis: find what holds the port and what process it is;
2. Show me every command first and wait for my confirmation;
3. Ask before killing anything — kill only when I say so;
4. When fixed, re-run the start command and show me the evidence it's up.
@上面那块 EADDRINUSE 输出 dev server 起不来。
1. 只读排查:找出是什么占了 3000 端口,它是什么进程;
2. 每条命令先给我看我确认再跑;
3. 杀进程之前必须问我,我说杀才杀;
4. 修好后重跑 npm run dev,把 Ready on localhost:3000 给我看。@the EADDRINUSE block above — the dev server won't start.
1. Read-only diagnosis: find what holds port 3000 and what process it is;
2. Show me every command first and wait for my confirmation;
3. Ask before killing anything — kill only when I say so;
4. When fixed, re-run npm run dev and show me Ready on localhost:3000.
一次真实交办的样子(删节版 transcript —— 注意每条命令前的确认点,和最后那条验收证据):What one real dispatch looks like (abridged transcript — note the confirmation point before each command, and the acceptance evidence at the end):
$ npm run dev> my-app@0.1.0 dev> next devError: listen EADDRINUSE: address already in use :::3000 at Server.setupListenHandle [as _listen2] (node:net:1940:16)─── Agent 会话(⌘↩)────────────────────────────你: @上面的报错输出 dev server 起不来。只读排查,杀进程前问我。Agent: 计划 — 1. lsof 查 3000 端口占用(只读) 2. 判断进程身份 3. 给你建议,等你确认再动手 4. 重跑 npm run dev 验收Agent: 执行 → lsof -nP -i :3000 [你: 放行 ✓] COMMAND PID USER FD TYPE NAME node 41782 you 23u IPv6 TCP *:3000 (LISTEN)Agent: 执行 → ps -p 41782 -o pid,etime,command [你: 放行 ✓] PID ELAPSED COMMAND 41782 6-04:12 node /Users/you/proj/node_modules/.bin/next devAgent: 结论 — 是 6 天前启动的 next dev 残留进程,占着 3000。 建议 kill 41782。这是写操作,等你确认。你: 杀。Agent: 执行 → kill 41782 [你: 已确认 ✓]Agent: 执行 → npm run dev [你: 放行 ✓] > next dev ✓ Ready on http://localhost:3000Agent: 验收 — Ready on http://localhost:3000,端口已释放,服务正常。
EADDRINUSE 从交办到验收的完整对话(删节)EADDRINUSE, dispatch to acceptance, abridged
浏览器路径的同一晚The same evening on the browser path
复制错误、新开标签页、搜「EADDRINUSE 3000」;第一个答案说 killall node —— 差点把你另一个项目的 dev server 也带走;第二个答案给的 lsof 参数在你的系统上报错;四十分钟后服务是起来了,你没搞懂刚才哪一步真正起了作用,下周再犯还是从头搜。Copy the error, open a tab, search 'EADDRINUSE 3000'; the first answer says killall node — which nearly took your other project's dev server with it; the second answer's lsof flags error out on your system; forty minutes later the server is up, you don't know which step actually did it, and next week you search from zero again.
刚才这四分钟The four minutes you just had
它读的是你那块真实报错,查的是你这台机器的端口,杀的是你能确认的进程,验收证据摆在你面前。全程你没有离开终端,并且每一步你都说了「可以」才发生 —— 这就是发动机和补全的区别:补全猜你这一行的下半句,agent 接你整件事的意图。It read your actual error, checked your machine's port, killed a process you confirmed, and laid the acceptance evidence in front of you. You never left the terminal, and every step happened only after you said yes — that's the difference between the engine and autocomplete: autocomplete guesses the rest of your line; the agent picks up the intent of the whole task.
— II
喂上下文,决定它准不准Context Decides Whether It's Accurate.
主线里它一次到位,不是它神,是那块 @ 进去的报错喂得准。它不会自动读你整个会话 —— 你喂多少准上下文,它就回多准。三层上下文要会喂:It landed the main line in one pass not because it's magic, but because the @-attached error block was precise. It doesn't auto-read your whole session — the more accurate the context you feed, the more accurate the answer. Three layers to master:一是当场指:@ 把文件、某块输出、某段选区贴进 prompt,让它就着具体的东西答。二是代码库索引:Warp 索引你 Git 跟踪的代码帮它理解项目,不在 Warp 服务器存你的代码,尊重 .gitignore / .warpindexingignore 等忽略文件;注意它消耗 credits,且 SSH / WSL 会话暂不支持。4注 4Note 4Warp Docs · Codebase Context —— 截至 2026-08-06:索引 Git 跟踪的代码(worktree 算独立仓库),不在 Warp 服务器存代码;尊重 .gitignore / .warpindexingignore / .cursorignore 等忽略文件;所有档每仓库至少索引 5,000 文件;SSH / WSL 会话暂不支持;消耗 credits。Warp Docs · Codebase Context — as of 2026-08-06: indexes Git-tracked code (worktrees count as separate repos), stores no code on Warp servers; respects .gitignore / .warpindexingignore / .cursorignore and similar ignore files; every plan indexes at least 5,000 files per codebase; not yet available in SSH / WSL sessions; consumes credits.三是Rules:项目里放全大写的 AGENTS.md(/init 生成),写清栈、规范、禁区;子目录的 AGENTS.md 自动生效且优先于根目录;已有的 CLAUDE.md / .cursorrules 可以直接链接,不用重写。命中的规则会在对话里标来源,你看得见它遵守了哪条。3注 3Note 3Warp Docs · Rules for agents —— 截至 2026-08-06:项目规则文件是全大写 AGENTS.md(WARP.md 仍支持;两个都存在时 WARP.md 优先);子目录 AGENTS.md 自动生效,优先级:子目录 > 根目录 > 全局;/init 生成 AGENTS.md 并可链接 CLAUDE.md、.cursorrules、GEMINI.md 等;命中的规则会作为对话引用显示来源。Warp Docs · Rules for agents — as of 2026-08-06: the project rules file is an all-caps AGENTS.md (WARP.md still supported; if both exist, WARP.md takes priority); subdirectory AGENTS.md files auto-apply, precedence subdirectory > root > global; /init generates AGENTS.md and can link CLAUDE.md, .cursorrules, GEMINI.md, etc.; applied rules appear as conversation references with their source.One, point at it now: @ drops a file, a block of output, or a selection into the prompt so it answers against the concrete thing. Two, the codebase index: Warp indexes your Git-tracked code to understand the project, stores no code on Warp servers, and respects ignore files like .gitignore / .warpindexingignore; note it consumes credits and isn't yet available in SSH / WSL sessions.4注 4Note 4Warp Docs · Codebase Context —— 截至 2026-08-06:索引 Git 跟踪的代码(worktree 算独立仓库),不在 Warp 服务器存代码;尊重 .gitignore / .warpindexingignore / .cursorignore 等忽略文件;所有档每仓库至少索引 5,000 文件;SSH / WSL 会话暂不支持;消耗 credits。Warp Docs · Codebase Context — as of 2026-08-06: indexes Git-tracked code (worktrees count as separate repos), stores no code on Warp servers; respects .gitignore / .warpindexingignore / .cursorignore and similar ignore files; every plan indexes at least 5,000 files per codebase; not yet available in SSH / WSL sessions; consumes credits. Three, Rules: an all-caps AGENTS.md in the project (generated by /init) stating stack, conventions, no-go zones; subdirectory AGENTS.md files auto-apply and outrank the root; existing CLAUDE.md / .cursorrules can be linked, not rewritten. Applied rules show their source in the conversation, so you see which one it obeyed.3注 3Note 3Warp Docs · Rules for agents —— 截至 2026-08-06:项目规则文件是全大写 AGENTS.md(WARP.md 仍支持;两个都存在时 WARP.md 优先);子目录 AGENTS.md 自动生效,优先级:子目录 > 根目录 > 全局;/init 生成 AGENTS.md 并可链接 CLAUDE.md、.cursorrules、GEMINI.md 等;命中的规则会作为对话引用显示来源。Warp Docs · Rules for agents — as of 2026-08-06: the project rules file is an all-caps AGENTS.md (WARP.md still supported; if both exist, WARP.md takes priority); subdirectory AGENTS.md files auto-apply, precedence subdirectory > root > global; /init generates AGENTS.md and can link CLAUDE.md, .cursorrules, GEMINI.md, etc.; applied rules appear as conversation references with their source.
— III
任务合同:交办大活的模板The Task Contract: A Template for Bigger Jobs.
EADDRINUSE 是小活,一句话够。活一大 —— 要写入、跨目录、有禁区 —— 就把下面这份合同填进去。它把成熟工作流的四个阶段(生成 → 审查 → 执行 → 验收)压成一段 prompt:EADDRINUSE is a small job; one sentence suffices. When the job grows — writes, multiple directories, no-go zones — fill in this contract. It compresses the four stages of a mature workflow (generate → review → execute → verify) into one prompt:
目标:<一句话说清要完成什么>
目录:<只允许在这个目录工作>
上下文:@<文件/Block/日志/截图>
写入边界:<只读 / 可改哪些文件 / 禁止改哪些文件>
禁止命令:rm -rf、sudo、curl | sh、生产数据库写入、deploy、secret 输出
执行方式:先给计划和命令;需要写入、删除、网络、sudo、生产操作时等我确认
验收标准:<测试命令 / 统计结果 / diff 要求 / dry-run 输出>Goal: <one sentence describing the outcome>
Directory: <work only inside this directory>
Context: @<file/block/log/screenshot>
Write boundary: <read-only / files allowed / files forbidden>
Forbidden commands: rm -rf, sudo, curl | sh, production DB writes, deploys, secret output
Execution: show plan and commands first; wait for confirmation before writes, deletes, network, sudo, or production actions
Acceptance: <test command / count result / diff requirement / dry-run output>
目标:把过期 30 天以上的临时上传文件清理掉,释放磁盘
目录:只允许在 ./storage/tmp 里工作
上下文:@scripts/cleanup.sh @df -h 的输出
写入边界:只能删 ./storage/tmp 下的文件,禁止改其他目录、禁止改任何源码
禁止命令:rm -rf、sudo、curl | sh、生产数据库写入、deploy、secret 输出
执行方式:先给计划和命令;需要写入、删除、网络、sudo、生产操作时等我确认
验收标准:先用 find 列出待删清单和总大小,我确认后再删;删完给出释放的空间和 df -h 对比Goal: Clean up temp upload files older than 30 days to free disk space
Directory: work only inside ./storage/tmp
Context: @scripts/cleanup.sh @output of df -h
Write boundary: may delete files under ./storage/tmp only; do not touch other directories, do not change any source
Forbidden commands: rm -rf, sudo, curl | sh, production DB writes, deploys, secret output
Execution: show plan and commands first; wait for confirmation before writes, deletes, network, sudo, or production actions
Acceptance: first list the delete candidates and total size with find, delete only after I confirm; report freed space and a df -h before/after when done
阶段Stage
你要它做What you ask it to do
你审什么What you review
生成Generate
先解释计划与命令,不执行Explain plan and commands first, without execution
目标是否对、目录是否对、会不会写入Goal, directory, write behavior
审查Review
列出风险命令和 dry-run 方式List risky commands and dry-run path
它会自纠错,但也会自信地跑错 —— 意图越模糊、会话越长、动作越不可逆,越容易出事。It self-corrects, but it also runs the wrong thing with confidence — the vaguer the intent, the longer the session, the more irreversible the action, the more likely it bites.
危险信号Danger signal
为什么危险Why risky
默认处理Default handling
rm -rf, find ... -delete
批量删除不可逆Bulk deletion is irreversible
必须人工确认,先列清单Human approval, list targets first
sudo, chmod -R, chown -R
扩大权限或改坏系统状态Escalates or breaks system state
解释影响范围,禁止自动跑Explain scope, no auto-run
`curl ...
sh, wget ...
bash`
生产数据库 UPDATE / DELETE / DROPProduction DB UPDATE / DELETE / DROP
影响真实数据Touches real data
SELECT 样本、事务、备份、人工批准SELECT sample, transaction, backup, human approval
三种情形要收住:意图含糊(「优化一下」它会乱猜方向)、长会话漂移(开太久它会忘了最初要什么)、不可逆操作(批量删、改生产、强推)。「能自己再试」也意味着它会在错误方向上多走几步。2注 2Note 2Warp Docs · Warp Agents overview —— 本地 agent 嵌在终端里,能写代码、debug、运行命令、自动化开发任务;用户保持控制权;对话可带代码库、Warp Drive、连接工具与上下文。Warp Docs · Warp Agents overview — local agents are embedded in the terminal and can write code, debug, run commands, and automate development tasks; the user stays in control; conversations can draw on codebase, Warp Drive, connected tools, and context.对策两层:这一章的 —— 把验收标准写进 prompt、别开漫无目的的长会话;危险动作那层 —— 让它自动跑什么、绝不让它碰什么 —— 在「管住它」那章用 profile、allowlist / denylist 配。什么时候不如自己敲?你已经记得的一行、只读低风险的一步、或者你比 agent 更清楚现场状态时,直接敲比开口快。Three situations to rein in: vague intent ('just optimize it' makes it guess a direction), long-session drift (open too long and it forgets what you first wanted), and irreversible actions (bulk delete, prod changes, force-push). 'Can retry on its own' also means it walks a few more steps in a wrong direction.2注 2Note 2Warp Docs · Warp Agents overview —— 本地 agent 嵌在终端里,能写代码、debug、运行命令、自动化开发任务;用户保持控制权;对话可带代码库、Warp Drive、连接工具与上下文。Warp Docs · Warp Agents overview — local agents are embedded in the terminal and can write code, debug, run commands, and automate development tasks; the user stays in control; conversations can draw on codebase, Warp Drive, connected tools, and context. The fix has two layers: this chapter's — put acceptance criteria in the prompt and don't run aimless long sessions; the dangerous-action layer — what it may auto-run and what it must never touch — is configured with profiles and allowlist / denylist in the Keep It in Check chapter. When is it worse than typing yourself? A one-liner you already remember, a read-only low-risk step, or a situation where you understand the live state better than the agent — typing is faster than asking.验收这一章 —— 主线那四分钟,你自己也要能复现:Accept the chapter — you should be able to reproduce those four minutes of the main line yourself:
我用 ⌘↩ 开会话、@ 指上一块真实报错,交办成功了一次只读排障。I opened a conversation with ⌘↩, @-pointed at a real error block, and completed a read-only diagnosis.
它的每条命令我都先看到再放行,写操作那条我让它停下来等过我。I saw every command before approving, and the write operation waited for my explicit go.
我用自己写的验收标准(不是它说的「好了」)确认了修复。I confirmed the fix against my own acceptance criterion, not its say-so.
我的项目里有一个 AGENTS.md,写清了栈、规范、禁区。My project has an AGENTS.md stating stack, conventions, and no-go zones.
我对比过「光打一句话」和「@ 上下文 + AGENTS.md」两次的结果差。I've compared a bare sentence against '@ context + AGENTS.md' on the same task.
任务合同模板我存下来了,下次大活直接填。I've saved the task-contract template to fill in for the next big job.
你喂的是上下文,
它接的是意图.
What you feed is context,
what it catches is intent.
Aklman Library
— 讨论Discussion
讨论Discussion.
评论区初始化中…Initializing comments…
01 / 01
没有匹配结果No matches.
换个关键词,或按 Esc 回到页面Try another keyword, or press Esc to return