{"slug":"ai-agent","title":"AI Agent 二三事","description":"从实战角度对比 AI IDE 与 AI Agent，并演示如何用 ZCF 快速安装和配置 Codex。","coverImage":"https://b.acofork.com/img/ai-agent-ai-agent.webp","coverWidth":1200,"coverHeight":900,"date":"2026-03-05","tags":["AI"],"pinned":false,"wordCount":1261,"html":"<h2 id=\"引言\">引言</h2><p>了解我的人通常都知道，我平时写代码主要用 AI IDE，比如 Trae、Cursor 等。</p>\n<p>AI IDE 的优势很明显：在保留 Git、代码高亮等高效手动工具的同时，把最耗时的代码编写交给 AI，我们只需要用自然语言描述目标即可。<em>图为 Trae</em></p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-1.webp\" alt=\"\" width=\"2560\" height=\"1368\" loading=\"eager\" decoding=\"async\" /></p>\n<h2 id=\"ai-agent-是什么\">AI Agent 是什么？</h2><p>简单来说，AI Agent 一般提供的是一个“偏终端化”的工作环境。和 AI IDE 一样，它也能通过自然语言完成开发任务。</p>\n<p>看起来好像和 AI IDE 没区别？其实差别很大。</p>\n<p>如果你是先用 AI IDE，再切到 AI Agent，通常会感受到明显落差：界面更朴素，交互更直接。</p>\n<p>AI Agent 往往只给你一个输入框。你描述目标后，它不仅能写代码，还能借助外部能力给自己“加特技”。</p>\n<p>比如接入 <strong>Playwright MCP</strong>，它就可以自动改前端代码并执行自动化调试。</p>\n<p>换句话说，AI Agent 的上手门槛看起来更低：你不一定要先理解完整代码结构，也不需要手动管理每一步流程。当然，对熟手来说，这种模式有时会降低精细控制的效率，但确实能省下不少精力。</p>\n<p>例如，我们可以把 Git 推送远程仓库这类流程交给 AI：自动生成 commit、自动配置代理、自动 push，并把本次规则和约束持久化，下次就不用重复说明。<em>图为 Codex</em></p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-2.webp\" alt=\"\" width=\"692\" height=\"1368\" loading=\"lazy\" decoding=\"async\" /></p>\n<h2 id=\"各-ai-agent-的区别\">各 AI Agent 的区别</h2><h4 id=\"opencode-开源-ai-编程代理\"><a href=\"https://opencode.ai/zh\" target=\"_blank\" rel=\"noopener noreferrer\">OpenCode | 开源 AI 编程代理</a></h4><p>游客可以直接使用免费的公益模型，不需要付费。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-Image_1772724238045_770.webp\" alt=\"\" width=\"1750\" height=\"1252\" loading=\"lazy\" decoding=\"async\" /></p>\n<h4 id=\"claude-code-by-anthropic-ai-coding-agent-terminal-ide\"><a href=\"https://claude.com/product/claude-code\" target=\"_blank\" rel=\"noopener noreferrer\">Claude Code by Anthropic | AI Coding Agent, Terminal, IDE</a></h4><p>它需要一个 <strong>POSIX Terminal</strong>（比如 <strong>Git Bash</strong>）。否则很多终端命令无法正常执行，因为它的工作流高度依赖 Bash 命令（如 <code>cat</code>、<code>ls</code>）。</p>\n<p>想要完整发挥体验，通常需要使用 <strong>Claude</strong> 系列模型。在一次会话中，它可能会让不同模型分工处理理解、规划、执行、测试等环节。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-Image_1772724294856_373.webp\" alt=\"\" width=\"1280\" height=\"1368\" loading=\"lazy\" decoding=\"async\" /></p>\n<h4 id=\"codex\"><a href=\"https://chatgpt.com/codex\" target=\"_blank\" rel=\"noopener noreferrer\">Codex</a></h4><blockquote>\n<p>目前我本人在用</p>\n</blockquote>\n<p>限制相对少，在 Windows Terminal（PowerShell）里也能跑得很好。</p>\n<p>只需要提供可用的模型 API 即可。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-3.webp\" alt=\"\" width=\"689\" height=\"1368\" loading=\"lazy\" decoding=\"async\" /></p>\n<h2 id=\"如何优雅地使用-ai-agent\">如何优雅地使用 AI Agent</h2><p>当然，你也可以手动配置各种 Agent，其实并不难。</p>\n<p>通常只要看文档、找到配置文件（一般是 <code>.json</code>），然后手写一份配置，或者让 AI 帮你生成一份。</p>\n<p>但目前已经有不少图形化、一键化工具，我更推荐先用这些工具快速上手。</p>\n<h4 id=\"cc-switch\"><a href=\"https://github.com/farion1231/cc-switch\" target=\"_blank\" rel=\"noopener noreferrer\">CC-Switch</a></h4><p>它可以用图形界面为不同 Agent 配置模型。你只需要像填表一样填入 API Endpoint、API Key、模型名，它会自动生成并应用对应 Agent 的 JSON 配置。</p>\n<p>同时也支持图形化配置 MCP 和 Skill。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-4.webp\" alt=\"\" width=\"1429\" height=\"947\" loading=\"lazy\" decoding=\"async\" /></p>\n<h4 id=\"zcf\"><a href=\"https://github.com/UfoMiao/zcf\" target=\"_blank\" rel=\"noopener noreferrer\">ZCF</a></h4><p>这个工具可以自动帮你安装 Agent，并一键部署一些主流 MCP，还能设置模型系统提示词预设，并提供基础工作流。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-5.webp\" alt=\"\" width=\"1284\" height=\"1368\" loading=\"lazy\" decoding=\"async\" /></p>\n<h2 id=\"从零安装并配置一个-agent\">从零安装并配置一个 Agent</h2><blockquote>\n<p>你需要事先准备一个模型 API</p>\n</blockquote>\n<p>先设置 NPM 镜像源：<a href=\"https://npmmirror.com/\" target=\"_blank\" rel=\"noopener noreferrer\">npmmirror 镜像站</a></p>\n<p>全局安装 zcf（Node 20.x+）：</p>\n<div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\">npm install -g zcf</code></pre></div><p>运行 zcf：</p>\n<div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\">npx zcf</code></pre></div><p>接着把目标 Agent 从 <strong>Claude Code</strong> 切换为 <strong>Codex</strong>。输入 <code>S</code> 切换到 Codex。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-6.webp\" alt=\"\" width=\"1125\" height=\"819\" loading=\"lazy\" decoding=\"async\" /></p>\n<p>然后输入 <code>1</code> 执行完整初始化，按需勾选即可。</p>\n<p>默认情况下，AI Agent 会先在沙盒里执行命令；如果某条指令在沙盒中失败，才会询问你是否允许在正常环境执行。</p>\n<p>你也可以使用一个高风险启动参数，让 Codex 进入“无人值守、默认放行”的模式：</p>\n<aside class=\"markdown-alert markdown-alert--caution\"><div class=\"markdown-alert-title\"><svg class=\"markdown-alert-icon\" aria-hidden=\"true\" width=\"18\" height=\"18\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 16h.01\"></path><path d=\"M12 8v4\"></path><path d=\"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z\"></path></svg><span>注意</span></div><div class=\"markdown-alert-body\"><p>使用该参数启动 Codex 后，指令可能被 <strong>默认执行</strong>，并且默认在 <strong>正常环境</strong> 下运行。这非常危险，请务必谨慎。</p>\n</div></aside><div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\">codex --dangerously-bypass-approvals-and-sandbox</code></pre></div><p>这个命令很长，可以做成别名。</p>\n<ul>\n<li>Bash：</li>\n</ul>\n<div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\"><span class=\"hljs-built_in\">alias</span> codexfull=<span class=\"hljs-string\">'codex --dangerously-bypass-approvals-and-sandbox'</span></code></pre></div><ul>\n<li>PowerShell：</li>\n</ul>\n<div class=\"markdown-code\" data-language=\"powershell\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>powershell</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-powershell\"><span class=\"hljs-comment\"># 创建 PS 配置文件</span>\n<span class=\"hljs-built_in\">New-Item</span> <span class=\"hljs-literal\">-Type</span> File <span class=\"hljs-literal\">-Force</span> <span class=\"hljs-variable\">$PROFILE</span>\n\n<span class=\"hljs-comment\"># 用记事本打开 PS 配置文件</span>\nnotepad <span class=\"hljs-variable\">$PROFILE</span></code></pre></div><p>加入这一段：</p>\n<div class=\"markdown-code\" data-language=\"powershell\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>powershell</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-powershell\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function</span> <span class=\"hljs-title\">codexfull</span></span> {\n    codex <span class=\"hljs-literal\">--dangerously-bypass-approvals-and-sandbox</span> <span class=\"hljs-variable\">$args</span>\n}</code></pre></div><p>之后在你的项目目录直接输入 <code>codexfull</code>，即可启动一个高权限执行模式的 Agent。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-7.webp\" alt=\"\" width=\"1771\" height=\"1156\" loading=\"lazy\" decoding=\"async\" /></p>\n<p>接下来你就可以让它做你要做的事：删文件、写文章、修 Bug，甚至从零搭建项目。</p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-8.webp\" alt=\"\" width=\"1767\" height=\"1252\" loading=\"lazy\" decoding=\"async\" /></p>\n<p><img src=\"https://b.acofork.com/img/ai-agent-ai-agent-9.webp\" alt=\"\" width=\"729\" height=\"1101\" loading=\"lazy\" decoding=\"async\" /></p>\n","toc":[{"id":"引言","text":"引言","depth":2},{"id":"ai-agent-是什么","text":"AI Agent 是什么？","depth":2},{"id":"各-ai-agent-的区别","text":"各 AI Agent 的区别","depth":2},{"id":"opencode-开源-ai-编程代理","text":"OpenCode | 开源 AI 编程代理","depth":4},{"id":"claude-code-by-anthropic-ai-coding-agent-terminal-ide","text":"Claude Code by Anthropic | AI Coding Agent, Terminal, IDE","depth":4},{"id":"codex","text":"Codex","depth":4},{"id":"如何优雅地使用-ai-agent","text":"如何优雅地使用 AI Agent","depth":2},{"id":"cc-switch","text":"CC-Switch","depth":4},{"id":"zcf","text":"ZCF","depth":4},{"id":"从零安装并配置一个-agent","text":"从零安装并配置一个 Agent","depth":2}]}