<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>老吴搭建教程</title><link>https://www.lw50.com/</link><description>LW50</description><item><title>AIKE智能PHP在线客服系统</title><link>https://www.lw50.com/post/4216586a.html</link><description>&lt;p&gt;AIKE 智能客服系统是一款面向全行业的企业级在线客服平台，系统由PHP Web 应用、实时推送、知识库与可选向量检索组成，支持 Nginx 反代与 HTTPS/WSS。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Microsoft YaHei&amp;quot;, Helvetica, &amp;quot;Meiryo UI&amp;quot;, &amp;quot;Malgun Gothic&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;Droid Sans&amp;quot;, &amp;quot;wenquanyi micro hei&amp;quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #F7F7F7; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #FFFFFF; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607281785228593854223.jpg&quot; title=&quot;AIKE智能PHP在线客服系统  第1张&quot; alt=&quot;AIKE智能PHP在线客服系统  第1张&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 id=&quot;doc-一产品定位-2&quot; style=&quot;box-sizing: border-box; margin: 36px 0px 16px; padding: 0px; font-size: 22px; color: rgb(23, 93, 255); scroll-margin-top: 108px; font-family: &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;一、产品定位&lt;/h2&gt;&lt;p&gt;AIKE 是面向全行业的企业级 AI 在线客服平台，融合大模型、知识库与实时通讯，支持私有化部署与 SaaS 多商户、多客服模式，支持售前意向咨询、售后工单及插件市场功能扩展。&lt;/p&gt;&lt;p&gt;适用对象：&lt;/p&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;适合所有行业，独立部署对服务器要求不高，尤其适合预算有限小微企业及超级个体&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;需要 7x24 智能接待、及要求多语言自动翻译聊天信息的海外独立站团队&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;需要PHP开源客服系统做二次开发的技术个人及工作室&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h2 id=&quot;doc-三核心能力-10&quot; style=&quot;box-sizing: border-box; margin: 36px 0px 16px; padding: 0px; font-size: 22px; color: rgb(23, 93, 255); scroll-margin-top: 108px; font-family: &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;二、核心能力&lt;/h2&gt;&lt;h3&gt;基础能力：&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;AI 智能回复 - 7*24小时在线&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;可接入第三方Agent智能体&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;多语言自动翻译&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;自动进化&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;支持后台多语言&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;可嵌入任意网站&amp;nbsp;-&amp;nbsp;同时支持桌面与移动端&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;系统支持私有化部署与多商户模式&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;多行业AI预设包 - 开箱即用&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Microsoft YaHei&amp;quot;, Helvetica, &amp;quot;Meiryo UI&amp;quot;, &amp;quot;Malgun Gothic&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;Droid Sans&amp;quot;, &amp;quot;wenquanyi micro hei&amp;quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #F7F7F7; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3&gt;能力扩展：&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;插件市场-能力扩展，可定制功能插件&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607291785324020537824.jpg&quot; title=&quot;AIKE智能PHP在线客服系统  第2张&quot; alt=&quot;AIKE智能PHP在线客服系统  第2张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;box-sizing: border-box; margin: 36px 0px 16px; padding: 0px; font-size: 22px; color: rgb(23, 93, 255); scroll-margin-top: 108px; font-family: &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;三、源码地址&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;附件为标准版（单域名），演示地址：&lt;a href=&quot;https://aike.lw50.com/docs/whitepaper.html&quot; target=&quot;_self&quot;&gt;AIKE 智能客服 — 产品白皮书&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 28 Jul 2026 16:38:46 +0800</pubDate></item><item><title>AIKE智能PHP在线客服系统安装教程</title><link>https://www.lw50.com/post/aike3.html</link><description>&lt;p style=&quot;text-align: left;&quot;&gt;本AIKE智能PHP在线客服系统安装教程从零部署本系统所需的**环境要求**、**Web 安装向导**、**安装后必改配置文件**、**相关服务启动**及**验收检查**。演示地址：&lt;a href=&quot;https://aike.lw50.com&quot; target=&quot;_self&quot;&gt;AIKE智能PHP在线客服系统&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607241784822643162201.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第1张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第1张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;## 一、系统组成&lt;/h2&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;PHP Web 应用：public/` 为网站根目录&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;实时推送服务：`aike_pusher/`（Workerman，WebSocket + HTTP API）&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;数据库结构：install/data.sql`（安装向导自动导入）&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;向量检索（可选）：知识库导入插件依赖 Qdrant；**一键安装：`bash install_qdrant.sh`**&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;## 二、环境要求&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 2.1 服务器&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;- **操作系统**：&lt;em&gt;Linux（推荐）&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;- **PHP**：推荐 7.3+&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;- **MySQL**：5.6+，字符集 **utf8mb4**&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;em&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784801021386333.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第2张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第2张&quot;&gt;&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 2.2 PHP 扩展（安装向导会检测）&lt;/em&gt;&lt;/h3&gt;&lt;div style=&quot;--container-height: 229px; text-align: left;&quot;&gt;&lt;div style=&quot;--container-height: 229px; position: sticky; top: 0px; left: 0px; right: 0px; width: 100%; height: 0px;&quot;&gt;&lt;div style=&quot;left: 0px; right: 0px; display: block; top: calc(var(--container-height) - 14px); height: 8px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;扩展名&lt;/span&gt;&lt;/em&gt;&lt;/th&gt;&lt;th&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;主要用途&lt;/span&gt;&lt;/em&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;mbstring&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;多字节字符串&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;gd&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;图片处理&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;curl&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;HTTP 请求、AI 接口&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;pdo_mysql&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot;&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;数据库&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;建议额外启用：`json`、`openssl`、`fileinfo`、`zip`。&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 2.3 目录写权限&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;以下目录需对 Web 运行用户可写：&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;br style=&quot;text-align: left;&quot;/&gt;```&lt;br style=&quot;text-align: left;&quot;/&gt;config/&lt;br style=&quot;text-align: left;&quot;/&gt;application/extra/&lt;br style=&quot;text-align: left;&quot;/&gt;public/&lt;br style=&quot;text-align: left;&quot;/&gt;public/upload/&lt;br style=&quot;text-align: left;&quot;/&gt;runtime/&lt;br style=&quot;text-align: left;&quot;/&gt;public/assets/front/&lt;br style=&quot;text-align: left;&quot;/&gt;public/assets/layer/&lt;br style=&quot;text-align: left;&quot;/&gt;```&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 2.4 端口规划&lt;/em&gt;&lt;/h3&gt;&lt;div style=&quot;--container-height: 274px; text-align: left;&quot;&gt;&lt;div style=&quot;--container-height: 274px; position: sticky; top: 0px; left: 0px; right: 0px; width: 100%; height: 0px;&quot;&gt;&lt;div style=&quot;left: 0px; right: 0px; display: block; top: calc(var(--container-height) - 14px); height: 8px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;端口&lt;/span&gt;&lt;/em&gt;&lt;/th&gt;&lt;th&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;默认值&lt;/span&gt;&lt;/em&gt;&lt;/th&gt;&lt;th&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;说明&lt;/span&gt;&lt;/em&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;HTTP/HTTPS&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;80 / 443&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;网站访问&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;WebSocket（&lt;/span&gt;&lt;code&gt;wport&lt;/code&gt;&lt;span class=&quot;&quot;&gt;）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;456&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;访客端 / 客服端实时消息（&lt;/span&gt;&lt;code&gt;aike_pusher&lt;/code&gt;&lt;span class=&quot;&quot;&gt; 监听）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;Pusher API（&lt;/span&gt;&lt;code&gt;aport&lt;/code&gt;&lt;span class=&quot;&quot;&gt;）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;2080&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;PHP 后端与推送服务通讯（建议仅本机或内网）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;Qdrant HTTP&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;6333&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;向量检索（可选）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;Qdrant gRPC&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;6334&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot;&gt;&lt;em&gt;&lt;span class=&quot;&quot;&gt;向量检索（可选，SDK 直连时用）&lt;/span&gt;&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;&amp;gt; **HTTPS 站点**：`whost` 建议填 `wss://你的域名`，由 Nginx 反代到本机 `456`；`wport` 填 **443**（对外）或 **456**（直连），须与 Nginx / 防火墙配置一致。&lt;/em&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;## 三、部署教程&lt;/em&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 3.1 上传代码&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;将项目上传到服务器，例如：&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;/www/wwwroot/your-domain.com/&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;网站根目录指向 **`public`**，不要将整个项目根目录直接暴露给外网。&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 3.2 创建数据库&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;宝塔创建数据库&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;安装向导也可自动创建数据库。&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 3.3 开始安装&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;- 若 `public/index.php` **已存在**，安装向导会提示「已经安装成功」。&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;重新安装：https://你的域名/install.php&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784805663485343.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第3张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第3张&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;修改数据库参数和管理账号即可，其它不懂的建议默认。&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 3.4&amp;nbsp;&lt;/em&gt;&lt;em&gt;安装成功：&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;em&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784810626774999.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第4张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第4张&quot;&gt;&lt;/em&gt;&lt;/p&gt;&lt;h3&gt;&lt;em&gt;### 3.5&lt;em&gt;总后台&lt;/em&gt;&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;https://你的域名/platform/passport/login.html&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;账号：安装时创建&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;密码：&lt;em&gt;安装&lt;em&gt;时&lt;/em&gt;创建&lt;/em&gt;&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;em&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784810867380747.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第5张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第5张&quot;&gt;&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;### 3.6&lt;/em&gt;&lt;em&gt;&amp;nbsp;客服后台&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;总后台创建客服账号：&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784811962754970.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第6张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第6张&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;登陆客服后台：&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://你的域名/admin/login/index/business_id/1.html&quot; _src=&quot;https://你的域名/admin/login/index/business_id/1.html&quot;&gt;https://你的域名/admin/login/index/business_id/1.html&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784812081165336.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第7张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第7张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;## 四、Web 服务器配置&lt;/em&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;#&lt;em&gt;#&lt;/em&gt;&lt;em&gt;#&amp;nbsp;&lt;/em&gt;Nginx配置&lt;/em&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;站点配置文件后面加上：&lt;/em&gt;&lt;/p&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;access_log&amp;nbsp;&amp;nbsp;/dev/null;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error_log&amp;nbsp;&amp;nbsp;/www/wwwlogs/ai.lw50.com.error.log;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;location&amp;nbsp;/app&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_pass&amp;nbsp;http://127.0.0.1:456;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_http_version&amp;nbsp;1.1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_set_header&amp;nbsp;Upgrade&amp;nbsp;$http_upgrade;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_set_header&amp;nbsp;Connection&amp;nbsp;&amp;quot;Upgrade&amp;quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_set_header&amp;nbsp;X-Real-IP&amp;nbsp;$remote_addr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;proxy_read_timeout&amp;nbsp;3600s;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/pre&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;em&gt;若前端直连 `ws://IP:456`，需在安全组放行 **456** 端口。&lt;/em&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;em&gt;#&lt;em&gt;#&lt;/em&gt;&lt;em&gt;# &lt;/em&gt;Linux伪静态&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/em&gt;&lt;/h3&gt;&lt;pre&gt;#&amp;nbsp;==========&amp;nbsp;ThinkPHP&amp;nbsp;5&amp;nbsp;短期加固&amp;nbsp;+&amp;nbsp;原有静态规则&amp;nbsp;==========

#&amp;nbsp;1.&amp;nbsp;禁止访问敏感目录（在原&amp;nbsp;runtime|application&amp;nbsp;基础上扩展）
location&amp;nbsp;~*&amp;nbsp;^/(runtime|application|config|thinkphp|vendor|extend)/&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}

#&amp;nbsp;2.&amp;nbsp;禁止访问示例/调试目录
location&amp;nbsp;~*&amp;nbsp;^/assets/libs/myeditor/examples/&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}

#&amp;nbsp;3.&amp;nbsp;禁止&amp;nbsp;uploads、assets&amp;nbsp;下直接执行&amp;nbsp;PHP
location&amp;nbsp;~*&amp;nbsp;^/upload/.*\.php$&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}
location&amp;nbsp;~*&amp;nbsp;^/assets/.*\.php$&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}

#&amp;nbsp;4.&amp;nbsp;拦截&amp;nbsp;ThinkPHP&amp;nbsp;5&amp;nbsp;常见&amp;nbsp;exploit&amp;nbsp;查询串
#&amp;nbsp;只拦截&amp;nbsp;s=&amp;nbsp;路由参数中的&amp;nbsp;exploit，勿扫描整段&amp;nbsp;query_string（会误伤&amp;nbsp;?code=&amp;nbsp;token）
if&amp;nbsp;($arg_s&amp;nbsp;~*&amp;nbsp;&amp;quot;(invokefunction|call_user_func|call_user_func_array|pearcmd|config-create)&amp;quot;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}
if&amp;nbsp;($arg_s&amp;nbsp;~*&amp;nbsp;&amp;quot;think(%2f|%5c|/)&amp;quot;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}
if&amp;nbsp;($arg_s&amp;nbsp;~*&amp;nbsp;&amp;quot;(php://|phar://)&amp;quot;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}
if&amp;nbsp;($arg_s&amp;nbsp;~*&amp;nbsp;&amp;quot;(\.\.|%2e%2e)&amp;quot;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;403;
}

#&amp;nbsp;5.&amp;nbsp;原有伪静态（保持不变）
location&amp;nbsp;/&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(!-e&amp;nbsp;$request_filename)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rewrite&amp;nbsp;^(.*)$&amp;nbsp;/index.php?s=$1&amp;nbsp;last;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;## 五、服务启动说明&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;###&amp;nbsp;禁用函数&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;在宝塔：软件商店 →&amp;nbsp;PHP 7.3&amp;nbsp;→&amp;nbsp;禁用函数，删掉与进程控制相关的项，至少包括：&lt;/p&gt;&lt;pre&gt;pcntl_fork、pcntl_waitpid、pcntl_wait、pcntl_signal、pcntl_signal_dispatch、pcntl_alarm、pcntl_exec&amp;nbsp;以及列表里其它&amp;nbsp;pcntl_*&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;###&amp;nbsp; 修改app_secrets.php&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;看图修改WSS、http、端口&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784816828348220.png&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第8张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第8张&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 实时推送 `aike_pusher`（必须）&lt;/h3&gt;&lt;pre&gt;cd&amp;nbsp;/www/wwwroot/你的目录/aike_pusher

php&amp;nbsp;start.php&amp;nbsp;restart&amp;nbsp;-d&lt;/pre&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784813806776257.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第9张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第9张&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;常用指令：&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;php start.php start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 前台调试&lt;br style=&quot;text-align: left;&quot;/&gt;php start.php start -d&amp;nbsp; &amp;nbsp; &amp;nbsp;# 后台守护&lt;br style=&quot;text-align: left;&quot;/&gt;php start.php stop&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 停止&lt;br style=&quot;text-align: left;&quot;/&gt;php start.php reload&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 平滑重启&lt;br style=&quot;text-align: left;&quot;/&gt;php start.php status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 状态&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 进程守护&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;`run.sh` 每分钟检测 Workerman，未运行则启动：&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;cd&amp;nbsp;/www/wwwroot/你的目录/
sudo&amp;nbsp;bash&amp;nbsp;run.sh&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;###添加计划任务&lt;/h3&gt;&lt;pre&gt;cd&amp;nbsp;/www/wwwroot/你的目录/
sudo&amp;nbsp;bash&amp;nbsp;init.sh&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 前端验证&lt;/h3&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784819176455935.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第10张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第10张&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 安装 Qdrant 向量数据库&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;启用知识库**语义检索 / 向量化**时需要。项目已提供**一键安装脚本**，请在**项目根目录**执行（与 `public/` 同级）：&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;cd&amp;nbsp;/www/wwwroot/你的目录
sudo&amp;nbsp;bash&amp;nbsp;install_qdrant.sh&lt;/pre&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;gt; 若系统尚未安装 Docker，脚本会先自动安装 Docker，再部署 Qdrant；Docker 已就绪则直接进入 Qdrant 安装。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 前置条件&lt;/h3&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;**Linux** 服务器（脚本不支持 Windows 直接运行）&lt;br style=&quot;text-align: left;&quot;/&gt;2. 未安装 Docker 时，脚本会**自动安装并启动 Docker**（需 **root**：`sudo bash install_qdrant.sh`）&lt;br style=&quot;text-align: left;&quot;/&gt;3. 已安装且 Docker 服务正常时，**跳过 Docker 步骤**，直接安装 Qdrant&lt;br style=&quot;text-align: left;&quot;/&gt;4. 本机可访问 `curl`（健康检查用；安装 Docker 时脚本会尝试自动安装 curl）&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 安装后验证&lt;/h3&gt;&lt;pre&gt;bash&amp;nbsp;scripts/qdrant/status.sh&lt;/pre&gt;&lt;p style=&quot;text-align: left;&quot;&gt;或手动检查：&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;curl&amp;nbsp;http://127.0.0.1:6333/
curl&amp;nbsp;http://127.0.0.1:6333/readyz
docker&amp;nbsp;ps&amp;nbsp;|&amp;nbsp;grep&amp;nbsp;wolive-qdrant&lt;/pre&gt;&lt;p style=&quot;text-align: left;&quot;&gt;输出 `Qdrant installed successfully` 且 REST API 为 `http://127.0.0.1:6333` 即表示就绪：&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607231784821070184657.jpg&quot; title=&quot;AIKE智能PHP在线客服系统安装教程  第11张&quot; alt=&quot;AIKE智能PHP在线客服系统安装教程  第11张&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 安装失败：Docker iptables 问题&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;部分云服务器 / CentOS 会出现端口映射失败，脚本会自动尝试 **host 网络模式**。若仍失败，以 root 执行修复后重试：&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;```bash&lt;br style=&quot;text-align: left;&quot;/&gt;bash scripts/qdrant/fix_docker_iptables.sh&lt;br style=&quot;text-align: left;&quot;/&gt;bash install_qdrant.sh&lt;br style=&quot;text-align: left;&quot;/&gt;```&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 在系统中启用向量检索&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;确认 `bash scripts/qdrant/status.sh` 显示 **Health : OK**&lt;br style=&quot;text-align: left;&quot;/&gt;1. 登录商户后台 → **知识库导入 / 向量设置**：&lt;br style=&quot;text-align: left;&quot;/&gt;&amp;nbsp; &amp;nbsp;- 开启 **向量检索**&lt;br style=&quot;text-align: left;&quot;/&gt;&amp;nbsp; &amp;nbsp;- `qdrant_url`：`http://127.0.0.1:6333`&lt;br style=&quot;text-align: left;&quot;/&gt;&amp;nbsp; &amp;nbsp;- 填写 Embedding API（URL、Key、模型）&lt;br style=&quot;text-align: left;&quot;/&gt;2. 导入 FAQ 或页面后执行向量化&lt;br style=&quot;text-align: left;&quot;/&gt;3. 在 **AI 智能回复设置** 中确认已启用知识库召回&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Qdrant 常见问题&lt;/h3&gt;&lt;div style=&quot;--container-height: 349px; text-align: left;&quot;&gt;&lt;div style=&quot;--container-height: 349px; position: sticky; top: 0px; left: 0px; right: 0px; width: 100%; height: 0px;&quot;&gt;&lt;div style=&quot;left: 0px; right: 0px; display: block; top: calc(var(--container-height) - 14px); height: 8px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;现象&lt;/span&gt;&lt;/th&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;处理&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;Docker not found&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;使用 &lt;/span&gt;&lt;code&gt;sudo bash install_qdrant.sh&lt;/code&gt;&lt;span class=&quot;&quot;&gt; 以自动安装 Docker&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;Docker auto-install requires root&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;加 &lt;/span&gt;&lt;code&gt;sudo&lt;/code&gt;&lt;span class=&quot;&quot;&gt; 后重试&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;Docker daemon not running&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;脚本会尝试 &lt;/span&gt;&lt;code&gt;systemctl start docker&lt;/code&gt;&lt;span class=&quot;&quot;&gt;；失败则手动检查 Docker 服务&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;健康检查超时&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;docker logs wolive-qdrant&lt;/code&gt;&lt;span class=&quot;&quot;&gt;，或执行 &lt;/span&gt;&lt;code&gt;fix_docker_iptables.sh&lt;/code&gt;&lt;span class=&quot;&quot;&gt; 后重装&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;向量化失败&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;检查后台 Embedding API Key，与 Qdrant 无关时先排除 API 问题&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 手动执行（调试）&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;```bash&lt;br style=&quot;text-align: left;&quot;/&gt;cd /www/wwwroot/your-domain.com&lt;br style=&quot;text-align: left;&quot;/&gt;# 指定商户 business_id=1；-f 忽略后台「蒸馏开关=关」&lt;br style=&quot;text-align: left;&quot;/&gt;php think ai:distill-human -b 1&lt;br style=&quot;text-align: left;&quot;/&gt;php think ai:distill-human -b 1 -f&lt;br style=&quot;text-align: left;&quot;/&gt;# 增量同步（页面 QA + 向量）&lt;br style=&quot;text-align: left;&quot;/&gt;php think ai:auto-sync -b 1&lt;br style=&quot;text-align: left;&quot;/&gt;php think ai:auto-sync -b 1 -f&lt;br style=&quot;text-align: left;&quot;/&gt;```&lt;br style=&quot;text-align: left;&quot;/&gt;成功时终端会输出 `scanned` / `pairs` / `inserted` 等统计。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### 后台开关（必配）&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Cron 只负责**按时触发**；各商户是否在任务内真正执行，由后台 **AI 智能回复设置 → 知识进化与定时任务** 控制：&lt;/p&gt;&lt;div style=&quot;--container-height: 274px; text-align: left;&quot;&gt;&lt;div style=&quot;--container-height: 274px; position: sticky; top: 0px; left: 0px; right: 0px; width: 100%; height: 0px;&quot;&gt;&lt;div style=&quot;left: 0px; right: 0px; display: block; top: calc(var(--container-height) - 14px); height: 8px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;开关&lt;/span&gt;&lt;/th&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;建议&lt;/span&gt;&lt;/th&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;作用&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;人工聊天蒸馏&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;开&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;写入「AI进化池 → 人工聊天学习候选」&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;仅人工回复&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;开&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;排除 AI 自动回复与常见问题预设&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;定时增量同步&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;按需&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;从已同步页面抽 QA、维护向量&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;同步向量库&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;开（若已装 Qdrant）&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;FAQ 增量写入 Qdrant&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;同步含蒸馏&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;关&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;auto-sync 内再跑蒸馏（与 hourly 重复，一般关）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;阈值（质量分、出现次数、更新 FAQ 次数等）也在同一区块配置，保存后写入 `wolive_ai_config.distill_config_json` / `auto_sync_json`。&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;br style=&quot;text-align: left;&quot;/&gt;&amp;gt; **注意：** 仅注册 cron、未在后台开启对应开关时，任务会跳过该商户。向量 FAQ 直答依赖 **7.2 Qdrant** 与后台 Embedding 配置。&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;## 六、自动化说明&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;&quot;&gt;“自动 vs 人工”环节：&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;--container-height: 320px; text-align: left;&quot;&gt;&lt;div style=&quot;--container-height: 320px; position: sticky; top: 0px; left: 0px; right: 0px; width: 100%; height: 0px;&quot;&gt;&lt;div style=&quot;left: 0px; right: 0px; display: block; top: calc(var(--container-height) - 14px); height: 8px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;环节&lt;/span&gt;&lt;/th&gt;&lt;th&gt;&lt;span class=&quot;&quot;&gt;是否自动&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;cron 扫描聊天、写候选&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;✅&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;cron 页面 QA、向量同步&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;✅（需开开关）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;高质量&lt;/span&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;新问题&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;&quot;&gt;自动入 FAQ&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;✅（进化池开关 + 阈值）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span class=&quot;&quot;&gt;同问不同答&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;&quot;&gt;更新已有 FAQ&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;❌ 需人工点「更新 FAQ」&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;意图关键词应用&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;❌ 需人工勾选并选意图&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;&quot;&gt;未命中 → 加 FAQ&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot;&gt;&lt;span class=&quot;&quot;&gt;❌ 需人工确认&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;## 七、常见问题&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q1：SQL 导入失败？&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;检查 MySQL 版本、账号权限、`install/data.sql` 是否完整，查看安装页报错详情。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q2：消息不实时？&lt;/h3&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;`php start.php status` 确认 pusher 运行&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;2. `app_secrets.php` 中 `app_key` / `app_secret` / `aport` / `websocket_port` 正确（改完需重启 pusher）&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;3. `whost`、`wport`（对外）与 `websocket_port`（监听，默认 456）与 Nginx / 防火墙一致&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;4. 浏览器控制台查看 WebSocket 连接&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;###Q3：`Missing application/extra/app_secrets.php`？&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;重新安装，或从 `app_secrets.example.php` 复制并填写（含 `websocket_port`、`aport`）。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q4：HTTPS 下 WebSocket 失败？&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;`whost` 用 `wss://域名`，Nginx `/app` 反代到 `127.0.0.1:456`，或配置 **6.4** SSL 直连&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q5：向量检索无结果？&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;确认已执行 `bash install_qdrant.sh` 且 `status.sh` 正常，后台 `qdrant_url` 为 `http://127.0.0.1:6333`，Embedding API 可用并已执行向量化。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q6：AI 进化 cron 不跑？&lt;/h3&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;`crontab -l` 是否含 `ai:distill-human`、`ai:auto-sync`（无则 `sudo bash init.sh`）&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;2. 后台 **知识进化与定时任务** 对应开关是否开启&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;3. 查看 `runtime/log/ai_distill_cron.log`、`ai_auto_sync.log` 是否有 PHP 报错&amp;nbsp;&amp;nbsp;&lt;br style=&quot;text-align: left;&quot;/&gt;4. 手动 `php think ai:distill-human -b 商户ID -f` 验证 CLI 是否正常&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;### Q7：蒸馏有候选但不会自动进 FAQ？&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;自动入库仅针对 **FAQ 中尚不存在的新问题**，且需同时满足：进化池开启 **高质量自动入 FAQ**、质量分 ≥ 阈值、出现次数 ≥ 阈值。同问不同答只会标「可更新 FAQ」，须人工确认。&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;END！！！&lt;/p&gt;</description><pubDate>Thu, 23 Jul 2026 17:27:15 +0800</pubDate></item><item><title>12条规则能将AI编程错误率降至3%</title><link>https://www.lw50.com/post/andrej-karpathy-skills2.html</link><description>&lt;p dir=&quot;auto&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607141784041554512659.jpg&quot; title=&quot;12条规则能将AI编程错误率降至3%  第1张&quot; alt=&quot;12条规则能将AI编程错误率降至3%  第1张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;h2 dir=&quot;auto&quot;&gt;四大原则&lt;/h2&gt;&lt;p dir=&quot;auto&quot;&gt;四大原则说是能将AI编程错误率从41%降至11%。原文地址：&lt;a href=&quot;https://www.lw50.com/post/andrej-karpathy-skills.html&quot; title=&quot;链接到 AI 编程的“紧箍咒”：CLAUDE.md 霸榜 GitHub，7万程序员疯抄作业&quot; rel=&quot;bookmark&quot; style=&quot;font-size: 20px; text-decoration: underline;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;AI 编程的“紧箍咒”：CLAUDE.md 霸榜 GitHub，7万程序员疯抄作业&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;hr style=&quot;box-sizing: border-box; height: 0.25em; overflow: hidden; border: 0px; background: 0px 0px rgb(209, 217, 224); margin: 24px 0px; padding: 0px; font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;/&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px !important; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;减少LLM编码常见错误的行为准则。根据需要与项目特定说明合并。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;权衡：&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;这些指导原则倾向于谨慎而非速度。对于琐碎的任务，请自行判断。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;markdown-heading&quot; dir=&quot;auto&quot; style=&quot;box-sizing: border-box; position: relative; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;h3 dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.5em; font-weight: 600; line-height: 1.25; border-bottom: 0.8px solid rgba(209, 217, 224, 0.7); padding-bottom: 0.3em;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;1. 编码前先思考&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;a id=&quot;user-content-1-think-before-coding&quot; class=&quot;anchor&quot; aria-label=&quot;永久链接：1. 编码前先思考&quot; href=&quot;https://github.com/multica-ai/andrej-karpathy-skills/blob/main/CLAUDE.md#1-think-before-coding&quot; style=&quot;box-sizing: border-box; background-color: rgba(0, 0, 0, 0); color: rgb(9, 105, 218); text-decoration: underline; float: left; padding-right: 4px; margin: auto; line-height: 1; text-underline-offset: 0.2rem; border-radius: 6px; opacity: 0; justify-content: center; align-items: center; width: 28px; height: 28px; display: flex; position: absolute; top: 19px; left: -28px; transform: translateY(calc(-50% - 0.3rem));&quot;&gt;&lt;svg data-component=&quot;Octicon&quot; class=&quot;octicon octicon-link&quot; viewbox=&quot;0 0 16 16&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;不要妄下断言。不要掩饰困惑。坦诚地权衡利弊。&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;实施前：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;请明确陈述您的假设。如有疑问，请提出。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果存在多种解释，请将它们提出来——不要默默地做出选择。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果存在更简单的方法，请提出来。必要时要坚持己见。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果有什么不清楚的地方，停下来。说出让你困惑的地方。然后提问。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;markdown-heading&quot; dir=&quot;auto&quot; style=&quot;box-sizing: border-box; position: relative; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;h3 dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.5em; font-weight: 600; line-height: 1.25; border-bottom: 0.8px solid rgba(209, 217, 224, 0.7); padding-bottom: 0.3em;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;2. 简单至上&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;a id=&quot;user-content-2-simplicity-first&quot; class=&quot;anchor&quot; aria-label=&quot;永久链接：2. 简约至上&quot; href=&quot;https://github.com/multica-ai/andrej-karpathy-skills/blob/main/CLAUDE.md#2-simplicity-first&quot; style=&quot;box-sizing: border-box; background-color: rgba(0, 0, 0, 0); color: rgb(9, 105, 218); text-decoration: underline; float: left; padding-right: 4px; margin: auto; line-height: 1; text-underline-offset: 0.2rem; border-radius: 6px; opacity: 0; justify-content: center; align-items: center; width: 28px; height: 28px; display: flex; position: absolute; top: 19px; left: -28px; transform: translateY(calc(-50% - 0.3rem));&quot;&gt;&lt;svg data-component=&quot;Octicon&quot; class=&quot;octicon octicon-link&quot; viewbox=&quot;0 0 16 16&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;用最少的代码解决问题。不要进行任何推测。&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;没有超出要求的功能。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;不为一次性代码进行抽象。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;没有提供任何未要求的“灵活性”或“可配置性”。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;对于不可能出现的情况，不进行错误处理。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果你写了 200 行，而 50 行就可以写完，那就重写。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;问问自己：“一位资深工程师会认为这过于复杂吗？” 如果答案是肯定的，那就简化它。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;markdown-heading&quot; dir=&quot;auto&quot; style=&quot;box-sizing: border-box; position: relative; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;h3 dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.5em; font-weight: 600; line-height: 1.25; border-bottom: 0.8px solid rgba(209, 217, 224, 0.7); padding-bottom: 0.3em;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;3. 手术改变&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;a id=&quot;user-content-3-surgical-changes&quot; class=&quot;anchor&quot; aria-label=&quot;永久链接：3. 手术改变&quot; href=&quot;https://github.com/multica-ai/andrej-karpathy-skills/blob/main/CLAUDE.md#3-surgical-changes&quot; style=&quot;box-sizing: border-box; background-color: rgba(0, 0, 0, 0); color: rgb(9, 105, 218); text-decoration: underline; float: left; padding-right: 4px; margin: auto; line-height: 1; text-underline-offset: 0.2rem; border-radius: 6px; opacity: 0; justify-content: center; align-items: center; width: 28px; height: 28px; display: flex; position: absolute; top: 19px; left: -28px; transform: translateY(calc(-50% - 0.3rem));&quot;&gt;&lt;svg data-component=&quot;Octicon&quot; class=&quot;octicon octicon-link&quot; viewbox=&quot;0 0 16 16&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;只碰你必须碰的东西。只收拾你自己的烂摊子。&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;编辑现有代码时：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;不要“改进”相邻的代码、注释或格式。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;不要重构没有损坏的代码。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;即使你的做法不同，也要保持与现有风格一致。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果你发现无关的死代码，请指出来——不要删除它。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;当你的更改创建了孤立文件时：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;删除因您的修改而不再使用的导入项/变量/函数。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;除非被要求，否则不要删除已有的无效代码。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;测试要求：每一行修改后的代码都应该直接追溯到用户的请求。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;markdown-heading&quot; dir=&quot;auto&quot; style=&quot;box-sizing: border-box; position: relative; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;h3 dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.5em; font-weight: 600; line-height: 1.25; border-bottom: 0.8px solid rgba(209, 217, 224, 0.7); padding-bottom: 0.3em;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;4. 目标驱动型执行&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;a id=&quot;user-content-4-goal-driven-execution&quot; class=&quot;anchor&quot; aria-label=&quot;永久链接：4. 目标驱动的执行&quot; href=&quot;https://github.com/multica-ai/andrej-karpathy-skills/blob/main/CLAUDE.md#4-goal-driven-execution&quot; style=&quot;box-sizing: border-box; background-color: rgba(0, 0, 0, 0); color: rgb(9, 105, 218); text-decoration: underline; float: left; padding-right: 4px; margin: auto; line-height: 1; text-underline-offset: 0.2rem; border-radius: 6px; opacity: 0; justify-content: center; align-items: center; width: 28px; height: 28px; display: flex; position: absolute; top: 19px; left: -28px; transform: translateY(calc(-50% - 0.3rem));&quot;&gt;&lt;svg data-component=&quot;Octicon&quot; class=&quot;octicon octicon-link&quot; viewbox=&quot;0 0 16 16&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;定义成功标准。循环直至验证通过。&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;将任务转化为可验证的目标：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;“添加验证”→“编写针对无效输入的测试，并确保它们都能通过”&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;“修复漏洞”→“编写一个能够重现该漏洞的测试，然后使其通过”。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;“重构 X” → “确保重构前后测试均通过”&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;对于多步骤任务，请简要说明计划：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;snippet-clipboard-content notranslate position-relative overflow-auto&quot; style=&quot;box-sizing: border-box; overflow: auto !important; position: relative !important; margin-bottom: 16px; background-color: rgb(246, 248, 250); justify-content: space-between; display: flex; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Monaspace Neon&amp;quot;, ui-monospace, SFMono-Regular, &amp;quot;SF Mono&amp;quot;, Menlo, Consolas, &amp;quot;Liberation Mono&amp;quot;, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; tab-size: 4; overflow-wrap: normal; padding: 16px; color: rgb(31, 35, 40); background-color: rgb(246, 248, 250); border-radius: 6px; line-height: 1.45; overflow: auto;&quot;&gt;1.&amp;nbsp;[Step]&amp;nbsp;→&amp;nbsp;verify:&amp;nbsp;[check]
2.&amp;nbsp;[Step]&amp;nbsp;→&amp;nbsp;verify:&amp;nbsp;[check]
3.&amp;nbsp;[Step]&amp;nbsp;→&amp;nbsp;verify:&amp;nbsp;[check]&lt;/pre&gt;&lt;div class=&quot;zeroclipboard-container&quot; style=&quot;box-sizing: border-box; animation: auto ease 0s 1 normal none running none; display: block;&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; data-component=&quot;Octicon&quot; height=&quot;16&quot; viewbox=&quot;0 0 16 16&quot; width=&quot;16&quot; data-view-component=&quot;true&quot; class=&quot;octicon octicon-copy js-clipboard-copy-icon&quot;&gt;&lt;/svg&gt;&lt;/div&gt;&lt;/div&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;明确的成功标准能让你独立循环迭代。而模糊的标准（“只要能行就行”）则需要不断澄清。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;hr style=&quot;box-sizing: border-box; height: 0.25em; overflow: hidden; border: 0px; background: 0px 0px rgb(209, 217, 224); margin: 24px 0px; padding: 0px; font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;/&gt;&lt;p dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px !important; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: 600;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;如果以下情况发生，则这些指导原则是有效的：&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; vertical-align: inherit;&quot;&gt;差异中不必要的更改减少，由于过于复杂而导致的重写减少，并且在实施之前而不是在出错之后提出澄清问题。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-download-wrap&quot; style=&quot;margin-top: 2em; padding-top: 1.2em; border-top: 1px solid rgb(232, 232, 232); text-align: center;&quot;&gt;&lt;a href=&quot;https://www.lw50.com/zb_users/plugin/lwskills/download.php?id=1943&quot; class=&quot;lwskills-download-btn&quot; style=&quot;display:inline-block;padding:10px 28px;background:#3a6ea5;color:#fff;text-decoration:none;border-radius:4px;font-size:14px;&quot;&gt;下载原文档&lt;/a&gt;&lt;/p&gt;&lt;h2&gt;8条进阶规则&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;在4条核心法则的基础上，开发者通过实测又增加了8条进阶规则，进一步提升了AI编程可靠性，号称能&lt;strong&gt;将错误率降至3%&lt;/strong&gt;。&lt;/span&gt;&lt;/p&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: 20px; background-color: #FFFFFF;&quot;&gt;法则：&lt;/span&gt;&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;&lt;span style=&quot;font-size: 20px; background-color: #FFFFFF;&quot;&gt;核心要求：&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;只做判断，不写死逻辑&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;避免硬编码，保持代码灵活性。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;严格控制Token消耗&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;用最精炼的方式完成任务。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;代码冲突时不妥协&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;遇到冲突应提示，而非擅自修改。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;先读懂源码再动手&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;确保理解现有代码结构&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;拒绝假测试&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;测试用例必须能真正验证功能。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;分步设置检查点&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;将大任务分解，逐步验证。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;严格遵守代码风格&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;保持与现有代码风格一致。&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;遇到问题绝不隐瞒&lt;/td&gt;&lt;td width=&quot;713&quot; valign=&quot;top&quot; style=&quot;word-break: break-all;&quot;&gt;发现无法解决的问题时必须报告。&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;...&lt;/p&gt;</description><pubDate>Tue, 14 Jul 2026 22:49:01 +0800</pubDate></item><item><title>本地pdf、Word、ppt文档转MarkItDown格式工具：MarkItDown</title><link>https://www.lw50.com/post/MarkItDown.html</link><description>&lt;p style=&quot;text-align: left;&quot;&gt;MarkItDown 原是微软官方的一个轻量级的 Python 工具，用于将各种本地文档转换为 Markdown 格式，以便在 LLM 和结构化知识提取中使用，侧重于保留文档的重要结构和内容（包括标题、列表、表格、链接等）。主要用于方便文本分析工具，主流语言学习模型（LLM），如 OpenAI、deepseek，能够很好原生“理解”Markdown这种格式。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607081783472556924430.png&quot; title=&quot;本地pdf、Word、ppt文档转MarkItDown格式工具：MarkItDown  第1张&quot; alt=&quot;本地pdf、Word、ppt文档转MarkItDown格式工具：MarkItDown  第1张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;支持格式：&lt;/h2&gt;&lt;ul dir=&quot;auto&quot; style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: rgb(31, 35, 40); font-family: &amp;quot;Mona Sans VF&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Noto Sans&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;PDF&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;PowerPoint&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Word&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Excel&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Images (EXIF metadata and OCR)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Audio (EXIF metadata and speech transcription)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;HTML&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Text-based formats (CSV, JSON, XML)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;ZIP files (iterates over contents)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Youtube URLs&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;EPubs&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;工具说明&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;本MarkItDown工具是老吴站修改过的版本，并增加了图形操作面板，看下图，可以手动选择要转换的文档及选择保存目录，对新手友好！&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/07/202607081783472753384868.png&quot; title=&quot;本地pdf、Word、ppt文档转MarkItDown格式工具：MarkItDown  第2张&quot; alt=&quot;本地pdf、Word、ppt文档转MarkItDown格式工具：MarkItDown  第2张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;本地安装方法&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;1、进入项目目录&lt;/h3&gt;&lt;p data-path-to-node=&quot;4,1,0&quot; style=&quot;text-align: left;&quot;&gt;文章附件获取源码，解压后打开CMD窗口，CD到文件根目录。&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;2、可编辑模式（Editable Mode）安装&lt;/h3&gt;&lt;pre _ngcontent-ng-c337567516=&quot;&quot;&gt;pip&amp;nbsp;install&amp;nbsp;-e&amp;nbsp;&amp;#39;packages/markitdown[all]&amp;#39;&lt;/pre&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-indent: 0em; text-align: left;&quot;&gt;&lt;code data-path-to-node=&quot;4,2,2,0,0&quot; data-index-in-node=&quot;0&quot;&gt;-e&lt;/code&gt; 参数表示以“可编辑模式”安装，这意味着你在源码中所做的任何修改都会立即反映到你的环境中，非常适合开发调试。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p data-path-to-node=&quot;4,2,2,1,0&quot; style=&quot;text-align: left;&quot;&gt;&lt;code data-path-to-node=&quot;4,2,2,1,0&quot; data-index-in-node=&quot;0&quot;&gt;[all]&lt;/code&gt; 表示安装所有处理格式（如 PDF、Word、PPT 等）所需的完整依赖。如：pip install &amp;#39;markitdown[pdf, docx, pptx]&amp;#39;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;使用方法&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;安装好后，双击启动转换器.bat即可。&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;工具地址&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;[CommShow]&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;原版本地址：&lt;a href=&quot;https://github.com/microsoft/markitdown&quot; _src=&quot;https://github.com/microsoft/markitdown&quot;&gt;https://github.com/microsoft/markitdown&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;老吴站版本：https://pan.baidu.com/s/1ZfKrsBUgcOprEv7nCWG1RQ?pwd=vsc4&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;[/CommShow]&lt;/p&gt;</description><pubDate>Wed, 08 Jul 2026 08:46:03 +0800</pubDate></item><item><title>MySQL 8.0.46部署工具</title><link>https://www.lw50.com/post/ddf7e284.html</link><description>&lt;p style=&quot;text-align: left;&quot;&gt;windows下单独安装MySQL到新手可能不太友好，有了这个MySQL 8.0.46安装工具就方便多了。MySQL 8.0.46是8.0 系列的最后一个维护版本(于 2026 年 4 月 21 日发布)，所以这个版本应该是比较稳定的。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606251782369881325380.jpg&quot; title=&quot;MySQL 8.0.46部署工具  第1张&quot; alt=&quot;MySQL 8.0.46部署工具  第1张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;工具功能：&lt;/h2&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;调整配置文件my. ini&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;初始化MySQL(会清空数据)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;安装系统服务(默认类型自动)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;系统服务：启动、停止、卸载&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;text-align: left;&quot;&gt;该程序需要以管理员身份执行。&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span id=&quot;stdcata14&quot;&gt;&lt;span id=&quot;stdcata3&quot;&gt;&lt;span id=&quot;stdcata14&quot;&gt;&lt;span id=&quot;stdcata2&quot;&gt;工具参数：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;651&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;工具名称：&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;651&quot; valign=&quot;top&quot;&gt;MySQL 8.0.46部署工具&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot; colspan=&quot;1&quot; rowspan=&quot;1&quot; style=&quot;word-break: break-all;&quot;&gt;&lt;strong&gt;运行系统：&lt;/strong&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot; colspan=&quot;1&quot; rowspan=&quot;1&quot; style=&quot;word-break: break-all;&quot;&gt;windows&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;651&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;文件格式：&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;651&quot; valign=&quot;top&quot;&gt;exe&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;667&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;文件大小:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;667&quot; valign=&quot;top&quot;&gt;1M&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;667&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;工具截图:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;667&quot; valign=&quot;top&quot;&gt;有&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h2&gt;&lt;span id=&quot;stdcata3&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span id=&quot;stdcata15&quot;&gt;&lt;span id=&quot;stdcata4&quot;&gt;&lt;span id=&quot;stdcata15&quot;&gt;工具&lt;span id=&quot;stdcata3&quot;&gt;地址：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;[CommShow]&lt;/p&gt;&lt;p&gt;MySQL8.0.46官方下载链接：https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.46-winx64.zip&lt;br/&gt;MySQL自制部署工具下载：https://liyitong.lanzout.com/i46C23sx3yuh&lt;/p&gt;&lt;p&gt;[/CommShow]&lt;/p&gt;</description><pubDate>Thu, 25 Jun 2026 14:40:52 +0800</pubDate></item><item><title>Graphify：如何将代码库与文档一键转化为可查询的知识图谱？</title><link>https://www.lw50.com/post/Graphify.html</link><description>&lt;p style=&quot;text-align: left;&quot;&gt;这是一个代码知识图谱生成工具（AI 编程助手）。该工具在GitHub上有70+K星标，这玩意能将项目中任何包含代码、SQL模式、R脚本、shell脚本、文档、论文、图像或视频的文件夹转换为可查询的知识图谱，自动发现模块间的依赖关系和隐藏连接。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606221782089375297019.jpg&quot; title=&quot;Graphify：如何将代码库与文档一键转化为可查询的知识图谱？  第1张&quot; alt=&quot;Graphify：如何将代码库与文档一键转化为可查询的知识图谱？  第1张&quot; width=&quot;900&quot; height=&quot;419&quot; border=&quot;0&quot; vspace=&quot;0&quot; style=&quot;width: 900px; height: 419px;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;如何让 AI 更好地阅读我的项目？&lt;/h2&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;它能把你项目里的代码整成一份能点能拽的知识图谱。并且自动扒拉出模块之间的依赖关系、隐藏连接。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;它不光告诉你这段代码是“干哈的”，还能给你解释“为啥非得这么设计”。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;这基本就相当于给AI装了个“项目大脑”，属于是降维打击了。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;让AI理解项目的时候，不再跟没头苍蝇似的瞎翻文件。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;只要瞅一眼那个图谱，整个项目的结构立马就门儿清。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;同时它跟Claude Code、Codex这些主流工具都能搭上线，兼容性挺到位。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606221782089383609239.jpg&quot; title=&quot;Graphify：如何将代码库与文档一键转化为可查询的知识图谱？  第2张&quot; alt=&quot;Graphify：如何将代码库与文档一键转化为可查询的知识图谱？  第2张&quot; width=&quot;900&quot; height=&quot;415&quot; border=&quot;0&quot; vspace=&quot;0&quot; style=&quot;width: 900px; height: 415px;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;总结&amp;nbsp;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;对程序员来说，不管是刚接手一个陌生项目，还是想快速摸清老项目的底细，Graphify能帮助 AI 更好地理解复杂代码中的逻辑关系，这玩意儿都贼拉实用。&lt;/p&gt;&lt;h2&gt;项目地址&lt;/h2&gt;&lt;p&gt;Github项目：&lt;a href=&quot;https://github.com/safishamsi/graphify&quot; _src=&quot;https://github.com/safishamsi/graphify&quot;&gt;graphify&lt;/a&gt;&lt;/p&gt;</description><pubDate>Mon, 22 Jun 2026 08:44:12 +0800</pubDate></item><item><title>728电玩全套源码</title><link>https://www.lw50.com/post/b1d58aaa.html</link><description>&lt;p style=&quot;text-align: left;&quot;&gt;728全套源码的后端好像跟电玩63游戏源码后端一样的，前端UI不一样，&lt;strong&gt;用Cocos简单看了一下源码，这一套是仿官方的728&lt;/strong&gt;。内含多种玩法，支持Cocoscreator开发，完整前端代码一键部署，适合有二开需求的用户。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606141781369847396694.jpg&quot; title=&quot;728电玩全套源码  第1张&quot; alt=&quot;728电玩全套源码  第1张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;搭建环境&lt;/h2&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;运行环境：linux&amp;nbsp;CentOS7X&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;源码后端：mysql+php&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;前端：cocos dashboard 2.4.5&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-indent: 0em; text-align: left;&quot;&gt;&lt;span id=&quot;stdcata3&quot;&gt;服务器要求&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;/h3&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;硬件&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;测试要求&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;运营要求&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;CPU&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;CPU4核&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;CPU8核&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;内存&lt;br style=&quot;text-align: left;&quot;/&gt;&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;内存8G&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;内存16G&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;带宽&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;5Mbp以上&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;20Mbp以上&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;硬盘&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;D盘50G以上&lt;/td&gt;&lt;td style=&quot;word-break: break-all;&quot; width=&quot;438&quot; valign=&quot;top&quot;&gt;D盘100G以上&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span id=&quot;stdcata10&quot;&gt;附件截图&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606141781369884657571.jpg&quot; title=&quot;728电玩全套源码  第2张&quot; alt=&quot;728电玩全套源码  第2张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span id=&quot;stdcata12&quot;&gt;附件地址&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;附件为源码，无教程！&lt;/p&gt;</description><pubDate>Sun, 14 Jun 2026 00:41:58 +0800</pubDate></item><item><title>MCP 原理及 Java 开发指南</title><link>https://www.lw50.com/post/1327ffbc.html</link><description>&lt;blockquote&gt;&lt;p&gt;目的：帮助 Java / Spring Boot 开发者快速理解 MCP 的设计动机、协议细节、以及 如何在 Spring AI 中落地。&lt;/p&gt;&lt;/blockquote&gt;&lt;h2&gt;为什么需要 MCP？&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;MCP 助力开发者在 LLM 之上构建智能体和复杂工作流。由于 LLM 需要频繁与外部数据和工具集成，MCP 提供了以下核心价值：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;开箱即用的集成能力&lt;/strong&gt;：提供丰富的预置集成方案，LLM 可直接接入使用&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;灵活的供应商切换&lt;/strong&gt;：支持在不同 LLM 服务商之间无缝迁移&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;安全最佳实践&lt;/strong&gt;：内置数据安全防护机制，确保基础设施安全可控&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;MCP 用 &lt;strong&gt;JSON‑RPC 2.0 + 能力发现&lt;/strong&gt; 的模式，把「模型 ↔ 应用 ↔ 工具」之间的交互标准化，实现 &lt;em&gt;一次接入，多处复用&lt;/em&gt;。&lt;/p&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;MCP 协议就好比 USB 接口，USB 设备可以通过 USB Hub 连接到不同的计算机上，而不需要重新设计接口。&lt;br/&gt;- 我们在电脑上可以同时使用多个 USB 设备（鼠标、键盘、硬盘、游戏手柄），这些 USB 设备有不同的功能，只要实现了标准的 USB 接口协议即可。&lt;br/&gt;- 电脑可以类比成 LLM，USB Hub 可以类比成 MCP Server，USB 设备可以类比成 Tool、Resource、Prompt 等。&lt;br/&gt;- 通过 MCP 协议，LLM 可以通过 USB Hub 访问不同的 USB 设备，从而扩展出各种各样的能力（发邮件、打电话、地图旅行规划、订票）。&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;从某种程度上说，MCP 就像是设计模式中的命令（Command）模式 + 外观（Facade）模式。&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;基本概念&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;关键术语&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/20260608152843178090372314058.png&quot; title=&quot;MCP 原理及 Java 开发指南  第1张&quot; alt=&quot;MCP 原理及 Java 开发指南  第1张&quot; loading=&quot;lazy&quot; style=&quot;max-width:100%;height:auto;vertical-align:middle;&quot;&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 主机&lt;/strong&gt;：需要通过 MCP 访问数据的程序，如 Claude Desktop、IDE 或 AI 工具&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 客户端&lt;/strong&gt;：与服务器保持 1:1 连接的协议客户端&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 服务器&lt;/strong&gt;：通过标准化的模型上下文协议暴露特定能力的轻量级程序&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;本地数据源&lt;/strong&gt;：MCP 服务器可以安全访问的计算机文件、数据库和服务&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;远程服务&lt;/strong&gt;：MCP 服务器可以通过互联网连接的外部系统（例如通过 API）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;分层架构&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;┌────────────────────────────┐

│&amp;nbsp;&amp;nbsp;Client&amp;nbsp;/&amp;nbsp;Server&amp;nbsp;API&amp;nbsp;层&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;←&amp;nbsp;McpClient&amp;nbsp;/&amp;nbsp;McpServer

├────────────────────────────┤

│&amp;nbsp;&amp;nbsp;Session&amp;nbsp;会话层&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;←&amp;nbsp;会话&amp;nbsp;&amp;amp;&amp;nbsp;状态管理

├────────────────────────────┤

│&amp;nbsp;&amp;nbsp;Transport&amp;nbsp;传输层&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;←&amp;nbsp;Stdio&amp;nbsp;/&amp;nbsp;SSE&amp;nbsp;/&amp;nbsp;WebSocket&amp;nbsp;/&amp;nbsp;gRPC

└────────────────────────────┘&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;MCP 采用分层架构设计，每一层都有其特定的职责：&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;Client / Server API 层&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;提供 McpClient 和 McpServer 接口&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;处理高层业务逻辑和协议交互&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;负责能力发现和工具调用&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;Session 会话层&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;管理客户端和服务器之间的会话状态&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;处理会话的生命周期（初始化、运行、关闭）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;维护会话上下文和状态信息&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;3. &lt;strong&gt;Transport 传输层&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;提供多种传输机制支持：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Stdio：标准输入输出，适合本地进程间通信&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;SSE (Server-Sent Events)：单向服务器推送&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;WebSocket：全双工通信&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;gRPC：高性能 RPC 框架&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;处理底层通信细节和协议转换&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;这种分层设计使得 MCP 具有：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;良好的可扩展性：可以轻松添加新的传输机制&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;清晰的职责分离：各层专注于自己的功能&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;灵活的部署方式：支持多种通信场景&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;传输机制&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;| 传输 | 场景 | 特点 |&lt;br/&gt;|------|------|------|&lt;br/&gt;| &lt;strong&gt;Stdio&lt;/strong&gt; | 本地 CLI / 子进程 | 零网络开销，启动快 |&lt;br/&gt;| &lt;strong&gt;HTTP + SSE&lt;/strong&gt; | 微服务 / Web 应用 | POST 请求 + SSE 推流，部署友好 |&lt;br/&gt;| &lt;strong&gt;自定义&lt;/strong&gt; | WebSocket / gRPC | 只需实现 Transport 接口即可 |&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;Java Spring AI 集成实践&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;使用 Spring AI 开发，详细说明可以参考官网文档。&lt;/p&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;MCP 分为 Stdio 和 SSE 两种传输方式，下面的例子使用 SSE 方式，最简化开发一个发票助手 MCP，并展示如何通过模型自动调用这个 MCP。&lt;/p&gt;&lt;/blockquote&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;POM 依赖&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;&amp;lt;dependency&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;groupId&amp;gt;org.springframework.ai&amp;lt;/groupId&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;artifactId&amp;gt;spring-ai-starter-mcp-server-webflux&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;配置示例 `application.properties`&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;spring.main.banner-mode=off
#&amp;nbsp;logging.pattern.console=
spring.ai.mcp.server.name=my-invoice-server
spring.ai.mcp.server.version=0.0.1&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;详细的配置参数及默认值可以参考官方文档：Spring AI / Model Context Protocol (MCP) / MCP Server Boot Starters)。&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;暴露 Tool&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;这里就模拟一个非常简单的功能，仅拼装对应参数，返回发票链接。&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;InvoiceService&amp;nbsp;{

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;获取发票链接&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;String&amp;nbsp;getInvoiceUrl(@ToolParam(required&amp;nbsp;=&amp;nbsp;true,&amp;nbsp;description&amp;nbsp;=&amp;nbsp;&amp;quot;发票&amp;nbsp;id&amp;quot;)&amp;nbsp;String&amp;nbsp;invoiceId)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;&amp;quot;https://www.example.com/invoice/&amp;quot;&amp;nbsp;+&amp;nbsp;invoiceId;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@SpringBootApplication
public&amp;nbsp;class&amp;nbsp;McpServerApplication&amp;nbsp;{

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String[]&amp;nbsp;args)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SpringApplication.run(McpServerApplication.class,&amp;nbsp;args);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Bean
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ToolCallbackProvider&amp;nbsp;invoiceTools(InvoiceService&amp;nbsp;invoiceService)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;MethodToolCallbackProvider.builder().toolObjects(invoiceService).build();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;启动服务&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;执行 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;java -jar mcp-server.jar&lt;/code&gt; 启动服务，默认监听 8080 端口。&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;在 MCP client 中配置 mcp.setting&lt;/h3&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;cursor、VS code 中的 cline 插件都算是 MCP client。本文展示 cline 插件如何配置。&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/20260608152843178090372318137.png&quot; title=&quot;MCP 原理及 Java 开发指南  第2张&quot; alt=&quot;MCP 原理及 Java 开发指南  第2张&quot; loading=&quot;lazy&quot; style=&quot;max-width:100%;height:auto;vertical-align:middle;&quot;&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;cline_mcp_setting.json 增加如下配置：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;{
&amp;nbsp;&amp;nbsp;&amp;quot;mcpServers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;invoice-local&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;url&amp;quot;:&amp;nbsp;&amp;quot;http://localhost:8080/sse&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;autoApprove&amp;quot;:&amp;nbsp;[
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;getInvoiceUrl&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;我们可以看到对应的 getInvoiceUrl 方法已经被自动注册到 MCP Server 中。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/20260608152844178090372486027.png&quot; title=&quot;MCP 原理及 Java 开发指南  第3张&quot; alt=&quot;MCP 原理及 Java 开发指南  第3张&quot; loading=&quot;lazy&quot; style=&quot;max-width:100%;height:auto;vertical-align:middle;&quot;&gt;&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;使用 MCP！&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 cline 中输入问题：“我有一个发票 id 是 123456，发票链接是多少？”，可以看到模型会自动判断是否需要调用 MCP Server 中的 getInvoiceUrl 方法，并拼装参数，获取结果。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/20260608152844178090372491834.png&quot; title=&quot;MCP 原理及 Java 开发指南  第4张&quot; alt=&quot;MCP 原理及 Java 开发指南  第4张&quot; loading=&quot;lazy&quot; style=&quot;max-width:100%;height:auto;vertical-align:middle;&quot;&gt;&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;说明&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. JDK 版本必须 &amp;gt;= 17&lt;br/&gt;2. Spring Boot 版本必须 &amp;gt;= 3.2&lt;br/&gt;3. Spring AI 底层使用 modelcontextprotocol / java-sdk)&lt;br/&gt;4. MCP 协议等都在快速发展中，上面的代码示例仅供参考，具体实现可能会有所不同&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;完整配置示例&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Application.java：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;package&amp;nbsp;com.example.mcp;

import&amp;nbsp;org.springframework.ai.mcp.server.tool.ToolCallbackProvider;
import&amp;nbsp;org.springframework.ai.mcp.server.tool.MethodToolCallbackProvider;
import&amp;nbsp;org.springframework.boot.SpringApplication;
import&amp;nbsp;org.springframework.boot.autoconfigure.SpringBootApplication;
import&amp;nbsp;org.springframework.context.annotation.Bean;
import&amp;nbsp;org.springframework.web.reactive.function.client.WebClient;

@SpringBootApplication
public&amp;nbsp;class&amp;nbsp;McpServerApplication&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String[]&amp;nbsp;args)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SpringApplication.run(McpServerApplication.class,&amp;nbsp;args);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;注册所有&amp;nbsp;Tools
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Bean
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ToolCallbackProvider&amp;nbsp;toolCallbackProvider(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DatabaseTools&amp;nbsp;databaseTools,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileTools&amp;nbsp;fileTools,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HttpTools&amp;nbsp;httpTools
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;MethodToolCallbackProvider.builder()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.toolObjects(databaseTools,&amp;nbsp;fileTools,&amp;nbsp;httpTools)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.build();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;WebClient&amp;nbsp;for&amp;nbsp;HTTP&amp;nbsp;tools
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Bean
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;WebClient&amp;nbsp;webClient()&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;WebClient.builder()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.defaultHeader(&amp;quot;User-Agent&amp;quot;,&amp;nbsp;&amp;quot;MCP-Server/1.0&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.build();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;application.yml：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;spring:
&amp;nbsp;&amp;nbsp;application:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name:&amp;nbsp;mcp-server-demo
&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;ai:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mcp:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;server:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name:&amp;nbsp;&amp;quot;Enterprise&amp;nbsp;MCP&amp;nbsp;Server&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;version:&amp;nbsp;&amp;quot;1.0.0&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;description:&amp;nbsp;&amp;quot;Comprehensive&amp;nbsp;MCP&amp;nbsp;server&amp;nbsp;with&amp;nbsp;database,&amp;nbsp;file,&amp;nbsp;and&amp;nbsp;HTTP&amp;nbsp;capabilities&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
server:
&amp;nbsp;&amp;nbsp;port:&amp;nbsp;8080
&amp;nbsp;&amp;nbsp;
logging:
&amp;nbsp;&amp;nbsp;level:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;org.springframework.ai.mcp:&amp;nbsp;DEBUG
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;com.example.mcp:&amp;nbsp;DEBUG&lt;/pre&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;MCP Client 配置与使用&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;Claude Desktop 配置&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;Claude Desktop 是最早支持 MCP 的应用之一。配置文件位置：&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;macOS：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;~/Library/Application\&amp;nbsp;Support/Claude/claude_desktop_config.json&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Windows：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;%APPDATA%\Claude\claude_desktop_config.json&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;配置示例：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;{
&amp;nbsp;&amp;nbsp;&amp;quot;mcpServers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;enterprise-server&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;command&amp;quot;:&amp;nbsp;&amp;quot;java&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;args&amp;quot;:&amp;nbsp;[
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;-jar&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;/path/to/mcp-server.jar&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;env&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;SERVER_PORT&amp;quot;:&amp;nbsp;&amp;quot;8080&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;database-server&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;url&amp;quot;:&amp;nbsp;&amp;quot;http://localhost:8080/sse&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;headers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;Authorization&amp;quot;:&amp;nbsp;&amp;quot;Bearer&amp;nbsp;YOUR_TOKEN&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;Cursor IDE 配置&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;Cursor 通过 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/mcp.json&lt;/code&gt; 文件配置 MCP 服务器：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;{
&amp;nbsp;&amp;nbsp;&amp;quot;mcpServers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;local-dev&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;command&amp;quot;:&amp;nbsp;&amp;quot;java&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;args&amp;quot;:&amp;nbsp;[&amp;quot;-jar&amp;quot;,&amp;nbsp;&amp;quot;mcp-server.jar&amp;quot;],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;env&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;WORKSPACE_ROOT&amp;quot;:&amp;nbsp;&amp;quot;${workspaceFolder}&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;remote-api&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;url&amp;quot;:&amp;nbsp;&amp;quot;https://api.example.com/mcp/sse&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;autoApprove&amp;quot;:&amp;nbsp;[&amp;quot;read_file&amp;quot;,&amp;nbsp;&amp;quot;list_directory&amp;quot;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;Cline/Continue 配置&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;VS Code 插件 Cline 的配置文件：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;~/.cline/mcp_settings.json&lt;/code&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;{
&amp;nbsp;&amp;nbsp;&amp;quot;mcpServers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;development&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;url&amp;quot;:&amp;nbsp;&amp;quot;http://localhost:8080/sse&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;autoApprove&amp;quot;:&amp;nbsp;[
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;query_database&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;read_file&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;list_directory&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;alwaysAllow&amp;quot;:&amp;nbsp;[&amp;quot;get_table_schema&amp;quot;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;实际使用示例&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;场景 1：数据库查询&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;用户:&amp;nbsp;查询用户表中所有活跃用户的数量

AI:&amp;nbsp;我会帮你查询数据库。
[调用&amp;nbsp;query_database]
参数:&amp;nbsp;sql&amp;nbsp;=&amp;nbsp;&amp;quot;SELECT&amp;nbsp;COUNT(*)&amp;nbsp;as&amp;nbsp;count&amp;nbsp;FROM&amp;nbsp;users&amp;nbsp;WHERE&amp;nbsp;status&amp;nbsp;=&amp;nbsp;&amp;#39;active&amp;#39;&amp;quot;

结果:&amp;nbsp;{&amp;quot;rowCount&amp;quot;:&amp;nbsp;1,&amp;nbsp;&amp;quot;rows&amp;quot;:&amp;nbsp;[{&amp;quot;count&amp;quot;:&amp;nbsp;1234}]}

AI:&amp;nbsp;当前有&amp;nbsp;1,234&amp;nbsp;个活跃用户。&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;场景 2：文件操作&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;用户:&amp;nbsp;帮我创建一个&amp;nbsp;README.md&amp;nbsp;文件,包含项目介绍

AI:&amp;nbsp;好的,我会创建&amp;nbsp;README&amp;nbsp;文件。
[调用&amp;nbsp;write_file]
参数:
&amp;nbsp;&amp;nbsp;path&amp;nbsp;=&amp;nbsp;&amp;quot;README.md&amp;quot;
&amp;nbsp;&amp;nbsp;content&amp;nbsp;=&amp;nbsp;&amp;quot;#&amp;nbsp;Project&amp;nbsp;Name\n\nThis&amp;nbsp;is&amp;nbsp;a&amp;nbsp;comprehensive&amp;nbsp;guide...&amp;quot;
&amp;nbsp;&amp;nbsp;create_dirs&amp;nbsp;=&amp;nbsp;true

AI:&amp;nbsp;README.md&amp;nbsp;文件已创建成功!&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;场景 3：代码审查&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;用户:&amp;nbsp;使用&amp;nbsp;code-review&amp;nbsp;prompt&amp;nbsp;审查这段代码

AI:&amp;nbsp;我会使用专业的代码审查模板。
[调用&amp;nbsp;code-review&amp;nbsp;prompt]
参数:
&amp;nbsp;&amp;nbsp;language&amp;nbsp;=&amp;nbsp;&amp;quot;Java&amp;quot;
&amp;nbsp;&amp;nbsp;code&amp;nbsp;=&amp;nbsp;&amp;quot;public&amp;nbsp;class&amp;nbsp;User&amp;nbsp;{&amp;nbsp;...&amp;nbsp;}&amp;quot;
&amp;nbsp;&amp;nbsp;focus_areas&amp;nbsp;=&amp;nbsp;&amp;quot;安全性和性能&amp;quot;

AI:&amp;nbsp;[提供详细的代码审查反馈...]&lt;/pre&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;最佳实践&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;安全考虑&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;输入验证&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;public&amp;nbsp;class&amp;nbsp;SecurityValidator&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;validateSqlQuery(String&amp;nbsp;sql)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;防止&amp;nbsp;SQL&amp;nbsp;注入
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String&amp;nbsp;lowerSql&amp;nbsp;=&amp;nbsp;sql.toLowerCase();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String[]&amp;nbsp;dangerousKeywords&amp;nbsp;=&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;drop&amp;quot;,&amp;nbsp;&amp;quot;delete&amp;quot;,&amp;nbsp;&amp;quot;update&amp;quot;,&amp;nbsp;&amp;quot;insert&amp;quot;,&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;truncate&amp;quot;,&amp;nbsp;&amp;quot;alter&amp;quot;,&amp;nbsp;&amp;quot;create&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&amp;nbsp;(String&amp;nbsp;keyword&amp;nbsp;:&amp;nbsp;dangerousKeywords)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(lowerSql.contains(keyword))&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&amp;nbsp;new&amp;nbsp;SecurityException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;不允许的&amp;nbsp;SQL&amp;nbsp;操作:&amp;nbsp;&amp;quot;&amp;nbsp;+&amp;nbsp;keyword
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;Path&amp;nbsp;validatePath(Path&amp;nbsp;basePath,&amp;nbsp;String&amp;nbsp;userPath)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Path&amp;nbsp;resolved&amp;nbsp;=&amp;nbsp;basePath.resolve(userPath).normalize();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;防止路径遍历攻击
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(!resolved.startsWith(basePath))&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&amp;nbsp;new&amp;nbsp;SecurityException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;路径超出允许范围:&amp;nbsp;&amp;quot;&amp;nbsp;+&amp;nbsp;userPath
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;resolved;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;权限控制&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Configuration
public&amp;nbsp;class&amp;nbsp;McpSecurityConfig&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Bean
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;McpAuthorizationManager&amp;nbsp;authorizationManager()&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;new&amp;nbsp;McpAuthorizationManager()&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Override
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;boolean&amp;nbsp;canExecuteTool(String&amp;nbsp;toolName,&amp;nbsp;Principal&amp;nbsp;user)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;基于用户角色的权限控制
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;switch&amp;nbsp;(toolName)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;query_database&amp;quot;&amp;nbsp;-&amp;gt;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;user.hasRole(&amp;quot;DATA_ANALYST&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;write_file&amp;quot;&amp;nbsp;-&amp;gt;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;user.hasRole(&amp;quot;DEVELOPER&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;default&amp;nbsp;-&amp;gt;&amp;nbsp;true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;3. &lt;strong&gt;API 速率限制&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Aspect
@Component
public&amp;nbsp;class&amp;nbsp;RateLimitAspect&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;nbsp;final&amp;nbsp;RateLimiter&amp;nbsp;rateLimiter&amp;nbsp;=&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RateLimiter.create(10.0);&amp;nbsp;//&amp;nbsp;每秒&amp;nbsp;10&amp;nbsp;个请求
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Around(&amp;quot;@annotation(Tool)&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;Object&amp;nbsp;rateLimit(ProceedingJoinPoint&amp;nbsp;joinPoint)&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throws&amp;nbsp;Throwable&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(!rateLimiter.tryAcquire())&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&amp;nbsp;new&amp;nbsp;RateLimitException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;请求过于频繁,请稍后再试&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;joinPoint.proceed();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;性能优化&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;结果缓存&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;CachedDatabaseTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Cacheable(value&amp;nbsp;=&amp;nbsp;&amp;quot;tableSchema&amp;quot;,&amp;nbsp;key&amp;nbsp;=&amp;nbsp;&amp;quot;#tableName&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;TableSchema&amp;nbsp;getTableSchema(String&amp;nbsp;tableName)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;缓存表结构,避免重复查询
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;databaseService.getSchema(tableName);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Cacheable(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value&amp;nbsp;=&amp;nbsp;&amp;quot;queryResults&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;key&amp;nbsp;=&amp;nbsp;&amp;quot;#sql&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;condition&amp;nbsp;=&amp;nbsp;&amp;quot;#sql.toLowerCase().startsWith(&amp;#39;select&amp;#39;)&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;QueryResult&amp;nbsp;executeQuery(String&amp;nbsp;sql)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;databaseService.execute(sql);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;异步处理&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;AsyncFileTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;异步搜索文件&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;CompletableFuture&amp;lt;List&amp;lt;String&amp;gt;&amp;gt;&amp;nbsp;searchFilesAsync(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;pattern&amp;quot;)&amp;nbsp;String&amp;nbsp;pattern
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;CompletableFuture.supplyAsync(()&amp;nbsp;-&amp;gt;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;耗时的文件搜索操作
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;fileService.search(pattern);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;3. &lt;strong&gt;连接池管理&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Configuration
public&amp;nbsp;class&amp;nbsp;DatabaseConfig&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Bean
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;DataSource&amp;nbsp;dataSource()&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HikariConfig&amp;nbsp;config&amp;nbsp;=&amp;nbsp;new&amp;nbsp;HikariConfig();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setJdbcUrl(jdbcUrl);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setUsername(username);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setPassword(password);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;优化连接池配置
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setMaximumPoolSize(20);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setMinimumIdle(5);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setConnectionTimeout(30000);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config.setIdleTimeout(600000);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;new&amp;nbsp;HikariDataSource(config);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;错误处理&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;统一异常处理：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@ControllerAdvice
public&amp;nbsp;class&amp;nbsp;McpExceptionHandler&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ExceptionHandler(SecurityException.class)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ResponseEntity&amp;lt;ErrorResponse&amp;gt;&amp;nbsp;handleSecurityException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SecurityException&amp;nbsp;ex
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;ResponseEntity
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.status(HttpStatus.FORBIDDEN)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.body(new&amp;nbsp;ErrorResponse(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;SECURITY_ERROR&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ex.getMessage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ExceptionHandler(IllegalArgumentException.class)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ResponseEntity&amp;lt;ErrorResponse&amp;gt;&amp;nbsp;handleValidationException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IllegalArgumentException&amp;nbsp;ex
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;ResponseEntity
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.status(HttpStatus.BAD_REQUEST)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.body(new&amp;nbsp;ErrorResponse(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;VALIDATION_ERROR&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ex.getMessage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ExceptionHandler(Exception.class)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ResponseEntity&amp;lt;ErrorResponse&amp;gt;&amp;nbsp;handleGenericException(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exception&amp;nbsp;ex
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log.error(&amp;quot;Unexpected&amp;nbsp;error&amp;quot;,&amp;nbsp;ex);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;ResponseEntity
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.status(HttpStatus.INTERNAL_SERVER_ERROR)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.body(new&amp;nbsp;ErrorResponse(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;INTERNAL_ERROR&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;服务暂时不可用,请稍后重试&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}

record&amp;nbsp;ErrorResponse(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String&amp;nbsp;code,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String&amp;nbsp;message
)&amp;nbsp;{}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;监控与日志&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Aspect
@Component
public&amp;nbsp;class&amp;nbsp;McpMonitoringAspect&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Around(&amp;quot;@annotation(tool)&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;Object&amp;nbsp;monitorToolExecution(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ProceedingJoinPoint&amp;nbsp;joinPoint,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Tool&amp;nbsp;tool
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;throws&amp;nbsp;Throwable&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String&amp;nbsp;toolName&amp;nbsp;=&amp;nbsp;tool.name();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long&amp;nbsp;startTime&amp;nbsp;=&amp;nbsp;System.currentTimeMillis();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Object&amp;nbsp;result&amp;nbsp;=&amp;nbsp;joinPoint.proceed();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long&amp;nbsp;duration&amp;nbsp;=&amp;nbsp;System.currentTimeMillis()&amp;nbsp;-&amp;nbsp;startTime;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;记录成功的工具调用
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log.info(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;Tool&amp;nbsp;executed:&amp;nbsp;{}&amp;nbsp;|&amp;nbsp;Duration:&amp;nbsp;{}ms&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;toolName,&amp;nbsp;duration
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;发送指标到监控系统
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;metricsService.recordToolExecution(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;toolName,&amp;nbsp;duration,&amp;nbsp;&amp;quot;success&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;result;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;catch&amp;nbsp;(Exception&amp;nbsp;ex)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long&amp;nbsp;duration&amp;nbsp;=&amp;nbsp;System.currentTimeMillis()&amp;nbsp;-&amp;nbsp;startTime;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;记录失败的工具调用
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log.error(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;Tool&amp;nbsp;failed:&amp;nbsp;{}&amp;nbsp;|&amp;nbsp;Duration:&amp;nbsp;{}ms&amp;nbsp;|&amp;nbsp;Error:&amp;nbsp;{}&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;toolName,&amp;nbsp;duration,&amp;nbsp;ex.getMessage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;metricsService.recordToolExecution(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;toolName,&amp;nbsp;duration,&amp;nbsp;&amp;quot;failure&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&amp;nbsp;ex;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;典型应用场景&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;1. IDE 智能助手&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;功能描述：&lt;/strong&gt; 在 IDE 中提供代码生成、重构、调试等智能辅助功能。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;实现示例：&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;IdeTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;生成单元测试&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;String&amp;nbsp;generateUnitTest(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;source_code&amp;quot;)&amp;nbsp;String&amp;nbsp;sourceCode,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;test_framework&amp;quot;)&amp;nbsp;String&amp;nbsp;framework
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;分析源代码
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CodeAnalysis&amp;nbsp;analysis&amp;nbsp;=&amp;nbsp;codeAnalyzer.analyze(sourceCode);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;生成测试代码
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;testGenerator.generate(analysis,&amp;nbsp;framework);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;代码重构建议&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;List&amp;lt;RefactoringSuggestion&amp;gt;&amp;nbsp;suggestRefactoring(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;code&amp;quot;)&amp;nbsp;String&amp;nbsp;code
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;refactoringService.analyzePotentialImprovements(code);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;2. 企业数据分析&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;功能描述：&lt;/strong&gt; 提供自然语言到 SQL 的转换,支持数据可视化。&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;DataAnalyticsTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;自然语言查询&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;QueryResult&amp;nbsp;nlQuery(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;question&amp;quot;)&amp;nbsp;String&amp;nbsp;question
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;将自然语言转换为&amp;nbsp;SQL
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String&amp;nbsp;sql&amp;nbsp;=&amp;nbsp;nlToSqlConverter.convert(question);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;log.info(&amp;quot;Generated&amp;nbsp;SQL:&amp;nbsp;{}&amp;quot;,&amp;nbsp;sql);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;执行查询
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;databaseService.executeQuery(sql);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;生成数据可视化&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;ChartConfig&amp;nbsp;generateChart(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;data&amp;quot;)&amp;nbsp;List&amp;lt;Map&amp;lt;String,&amp;nbsp;Object&amp;gt;&amp;gt;&amp;nbsp;data,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;chart_type&amp;quot;)&amp;nbsp;String&amp;nbsp;chartType
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;chartGenerator.generate(data,&amp;nbsp;chartType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;3. 文档生成与管理&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;DocumentationTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;生成&amp;nbsp;API&amp;nbsp;文档&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;String&amp;nbsp;generateApiDocs(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;swagger_spec&amp;quot;)&amp;nbsp;String&amp;nbsp;swaggerSpec
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;apiDocGenerator.generate(swaggerSpec);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;更新用户手册&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;UpdateResult&amp;nbsp;updateUserManual(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;section&amp;quot;)&amp;nbsp;String&amp;nbsp;section,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;content&amp;quot;)&amp;nbsp;String&amp;nbsp;content
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Path&amp;nbsp;manualPath&amp;nbsp;=&amp;nbsp;docsPath.resolve(&amp;quot;user-manual.md&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;documentService.updateSection(manualPath,&amp;nbsp;section,&amp;nbsp;content);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;4. DevOps 自动化&lt;/h3&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Service
public&amp;nbsp;class&amp;nbsp;DevOpsTools&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;部署应用&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;DeploymentResult&amp;nbsp;deploy(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;environment&amp;quot;)&amp;nbsp;String&amp;nbsp;environment,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;version&amp;quot;)&amp;nbsp;String&amp;nbsp;version
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;deploymentService.deploy(environment,&amp;nbsp;version);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;查看日志&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;List&amp;lt;LogEntry&amp;gt;&amp;nbsp;getLogs(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;service&amp;quot;)&amp;nbsp;String&amp;nbsp;service,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;lines&amp;quot;)&amp;nbsp;int&amp;nbsp;lines
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;logService.getTailLogs(service,&amp;nbsp;lines);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;检查服务健康状态&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;HealthStatus&amp;nbsp;checkHealth(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;service&amp;quot;)&amp;nbsp;String&amp;nbsp;service
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;healthCheckService.check(service);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;生态系统与工具&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;官方工具&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;MCP Inspector&lt;/strong&gt; - 调试和测试 MCP 服务器&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;网址: &lt;a href=&quot;https://github.com/modelcontextprotocol/inspector&quot; target=&quot;_self&quot;&gt;inspector&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;功能: 实时查看工具调用、测试 prompts、监控资源&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;MCP CLI&lt;/strong&gt; - 命令行工具&lt;br/&gt;``&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;bash&lt;br/&gt;npm install -g @modelcontextprotocol/cli&lt;br/&gt;mcp test http://localhost:8080/sse&lt;br/&gt;&lt;/code&gt;``&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;社区服务器&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;访问 mcp.so 浏览 1000+ 社区 MCP 服务器:&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;数据库&lt;/strong&gt;: PostgreSQL, MySQL, MongoDB, Redis&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;云服务&lt;/strong&gt;: AWS, Azure, GCP&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;开发工具&lt;/strong&gt;: GitHub, GitLab, Jira&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;通信&lt;/strong&gt;: Slack, Discord, Email&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;数据处理&lt;/strong&gt;: Pandas, NumPy, Excel&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;客户端支持&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;| 客户端 | 支持程度 | 配置方式 |&lt;br/&gt;|--------|---------|----------|&lt;br/&gt;| &lt;strong&gt;Claude Desktop&lt;/strong&gt; | ✅ 完整支持 | JSON 配置文件 |&lt;br/&gt;| &lt;strong&gt;Cursor&lt;/strong&gt; | ✅ 完整支持 | .cursor/mcp.json |&lt;br/&gt;| &lt;strong&gt;Cline (VS Code)&lt;/strong&gt; | ✅ 完整支持 | 插件配置 |&lt;br/&gt;| &lt;strong&gt;Continue&lt;/strong&gt; | ✅ 完整支持 | config.json |&lt;br/&gt;| &lt;strong&gt;Zed&lt;/strong&gt; | ✅ 实验性支持 | 内置配置 |&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;常见问题&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Q: MCP 与 OpenAI Function Calling 有什么区别？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;A: MCP 是一个开放协议,不绑定特定 AI 提供商。Function Calling 是 OpenAI 特定的实现。MCP 支持更丰富的能力(Tools, Resources, Prompts),而 Function Calling 主要聚焦于函数调用。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Q: stdio 和 SSE 传输方式如何选择？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;A:&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;stdio&lt;/strong&gt;: 适合本地命令行工具,零网络开销,启动快&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;SSE&lt;/strong&gt;: 适合 Web 服务,支持远程访问,易于部署和扩展&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Q: MCP 服务器如何处理长时间运行的任务？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;A: 建议使用异步模式:&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;异步任务&amp;quot;)
public&amp;nbsp;TaskId&amp;nbsp;startAsyncTask(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;input&amp;quot;)&amp;nbsp;String&amp;nbsp;input
)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;返回任务&amp;nbsp;ID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;taskService.submit(input);
}

@Tool(description&amp;nbsp;=&amp;nbsp;&amp;quot;查询任务状态&amp;quot;)
public&amp;nbsp;TaskStatus&amp;nbsp;getTaskStatus(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@ToolParam(name&amp;nbsp;=&amp;nbsp;&amp;quot;task_id&amp;quot;)&amp;nbsp;String&amp;nbsp;taskId
)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;taskService.getStatus(taskId);
}&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Q: 如何调试 MCP 服务器？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;A:&lt;br/&gt;1. 使用 MCP Inspector 工具&lt;br/&gt;2. 启用详细日志: &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;logging.level.org.springframework.ai.mcp=DEBUG&lt;/code&gt;&lt;br/&gt;3. 使用 Postman 测试 SSE 端点&lt;br/&gt;4. 添加监控和追踪&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Q: MCP 服务器的性能瓶颈在哪里？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;A: 常见瓶颈:&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;数据库连接池不足&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;未使用缓存&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;同步阻塞操作&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;大数据传输&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;优化建议见&amp;quot;性能优化&amp;quot;章节。&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;未来展望&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;即将到来的特性&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;细粒度权限控制&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;基于工具的 ACL&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;资源级别的访问控制&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;审计日志&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;多模态支持&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;图像分析工具&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;音频处理&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;视频内容理解&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;3. &lt;strong&gt;增强的上下文管理&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;会话状态持久化&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;跨工具上下文共享&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;智能缓存策略&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;4. &lt;strong&gt;更好的可观测性&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;内置追踪和指标&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;性能分析工具&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;实时监控面板&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;技术演进方向&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;协议版本 2.0&lt;/strong&gt;: 更高效的二进制传输&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;边缘计算&lt;/strong&gt;: 在浏览器中运行 MCP 服务器&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;联邦学习&lt;/strong&gt;: 跨服务器的知识共享&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;AI Agent 框架&lt;/strong&gt;: 与 LangChain, AutoGPT 等深度集成&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;生态发展&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;企业采用&lt;/strong&gt;: 更多企业级 MCP 服务器&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;标准化&lt;/strong&gt;: 行业标准和最佳实践&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;认证体系&lt;/strong&gt;: MCP 服务器质量认证&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;市场生态&lt;/strong&gt;: MCP 服务器市场和交易平台&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;参考资源&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;官方资源&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 官方网站&lt;/strong&gt;: &lt;a href=&quot;https://modelcontextprotocol.io&quot; _src=&quot;https://modelcontextprotocol.io&quot;&gt;modelcontextprotocol&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 规范&lt;/strong&gt;: &lt;a href=&quot;https://spec.modelcontextprotocol.io&quot; _src=&quot;https://spec.modelcontextprotocol.io&quot;&gt;modelcontextprotocol&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP GitHub&lt;/strong&gt;: &lt;a href=&quot;https://github.com/modelcontextprotocol&quot; _src=&quot;https://github.com/modelcontextprotocol&quot;&gt;modelcontextprotocol&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 服务器目录&lt;/strong&gt;: &lt;a href=&quot;https://mcp.so/servers&quot; _src=&quot;https://mcp.so/servers&quot;&gt;mcp&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;Spring AI 相关&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Spring AI 文档&lt;/strong&gt;: &lt;a href=&quot;https://docs.spring.io/spring-ai/reference/&quot; _src=&quot;https://docs.spring.io/spring-ai/reference/&quot;&gt;reference&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP 集成指南&lt;/strong&gt;: &lt;a href=&quot;https://docs.spring.io/spring-ai/reference/api/mcp/&quot; _src=&quot;https://docs.spring.io/spring-ai/reference/api/mcp/&quot;&gt;mcp&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;示例仓库&lt;/strong&gt;: &lt;a href=&quot;https://github.com/spring-projects/spring-ai-examples&quot; _src=&quot;https://github.com/spring-projects/spring-ai-examples&quot;&gt;spring-ai-examples&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Spring AI MCP Server Starter&lt;/strong&gt;: &lt;a href=&quot;https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html&quot; _src=&quot;https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html&quot;&gt;mcp-server-boot-starter-docs.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;技术规范&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;JSON-RPC 2.0&lt;/strong&gt;: &lt;a href=&quot;https://www.jsonrpc.org/specification&quot; _src=&quot;https://www.jsonrpc.org/specification&quot;&gt;specification&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-Sent Events&lt;/strong&gt;: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events&quot; _src=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events&quot;&gt;Server-sent_events&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;OpenAPI 3.0&lt;/strong&gt;: &lt;a href=&quot;https://swagger.io/specification/&quot; _src=&quot;https://swagger.io/specification/&quot;&gt;specification&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;社区资源&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP Discord&lt;/strong&gt;: &lt;a href=&quot;https://discord.gg/modelcontextprotocol&quot; _src=&quot;https://discord.gg/modelcontextprotocol&quot;&gt;modelcontextprotocol&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP Reddit&lt;/strong&gt;: &lt;a href=&quot;https://reddit.com/r/mcp&quot; _src=&quot;https://reddit.com/r/mcp&quot;&gt;reddit&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stack Overflow&lt;/strong&gt;: 标签 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;model-context-protocol&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;YouTube 教程&lt;/strong&gt;: 搜索 &amp;quot;MCP Tutorial&amp;quot;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;相关项目&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Java SDK&lt;/strong&gt;: &lt;a href=&quot;https://github.com/modelcontextprotocol/java-sdk&quot; _src=&quot;https://github.com/modelcontextprotocol/java-sdk&quot;&gt;java-sdk&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;TypeScript SDK&lt;/strong&gt;:&amp;nbsp;&lt;a href=&quot;https://github.com/modelcontextprotocol/typescript-sdk&quot; _src=&quot;https://github.com/modelcontextprotocol/typescript-sdk&quot;&gt;typescript-sdk&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Python SDK&lt;/strong&gt;: &lt;a href=&quot;https://github.com/modelcontextprotocol/python-sdk&quot; _src=&quot;https://github.com/modelcontextprotocol/python-sdk&quot;&gt;python-sdk&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCP Inspector&lt;/strong&gt;: &lt;a href=&quot;https://github.com/modelcontextprotocol/inspector&quot; _src=&quot;https://github.com/modelcontextprotocol/inspector&quot;&gt;inspector&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-download-wrap&quot; style=&quot;margin-top: 2em; padding-top: 1.2em; border-top: 1px solid rgb(232, 232, 232); text-align: center;&quot;&gt;&lt;a href=&quot;https://www.lw50.com/zb_users/plugin/lwskills/download.php?id=1937&quot; class=&quot;lwskills-download-btn&quot; style=&quot;display:inline-block;padding:10px 28px;background:#3a6ea5;color:#fff;text-decoration:none;border-radius:4px;font-size:14px;&quot;&gt;下载文档&lt;/a&gt;&lt;/p&gt;</description><pubDate>Wed, 10 Jun 2026 13:25:52 +0800</pubDate></item><item><title>Agent 原理</title><link>https://www.lw50.com/post/Agent-原理.html</link><description>&lt;h2&gt;引言：从 ChatGPT 到 Agent&lt;/h2&gt;&lt;blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;近几年，大模型（如 ChatGPT）已经很好用了：能聊天、能写代码、能总结资料。&lt;br/&gt;但如果你仔细观察，会发现它仍然更像一个「超强的函数」而不是一个真正的「智能体」：&lt;/p&gt;&lt;/blockquote&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;你给它一个&lt;strong&gt;提示（prompt）&lt;/strong&gt;，它给你&lt;strong&gt;一次性输出&lt;/strong&gt;；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;它&lt;strong&gt;不会主动拆解长任务&lt;/strong&gt;，也不会自己决定「先查资料再算账、最后再写总结」；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;它&lt;strong&gt;不会持久记住你的目标&lt;/strong&gt;，也不会自行规划步骤或调用外部系统。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;Agent（智能体）&lt;/strong&gt;，就是在大模型的基础上，加上&lt;strong&gt;目标、记忆、工具调用、环境交互和长期规划能力&lt;/strong&gt;，让它从一个「问答机器」进化为一个能在复杂环境中&lt;strong&gt;自主完成任务的执行者&lt;/strong&gt;。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 项目，就是一个用来演示各种 Agent 范式的&lt;strong&gt;教学/实验仓库&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;ReAct 范式&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Plan-and-Execute 范式&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Supervisor Multi-Agent 范式&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Reflection 范式&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;下面这篇文章，会围绕这几个问题展开：&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;strong&gt;Agent 是什么？&lt;/strong&gt;&lt;/span&gt;&lt;br/&gt;1. &lt;strong&gt;为什么需要 Agent？&lt;/strong&gt;&lt;br/&gt;2. &lt;strong&gt;Agent 的通用架构和运行循环是什么样？&lt;/strong&gt;&lt;br/&gt;3. &lt;strong&gt;Agent 都有哪些典型范式？&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中各自对应什么实现？&lt;/strong&gt;&lt;br/&gt;4. &lt;strong&gt;Agent 相关有哪些经典论文/代表性工作值得一看？&lt;/strong&gt;&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: center;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606091780986539663385.jpg&quot; title=&quot;Agent 原理  第1张&quot; alt=&quot;Agent 原理  第1张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;一、什么是 Agent？&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;先给一个&lt;strong&gt;工程视角&lt;/strong&gt;的定义：&lt;/p&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;&lt;strong&gt;Agent 是一个能够围绕给定目标，持续感知环境、做出决策、调用工具并更新自身状态的智能程序。&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;拆开看，一个典型的 LLM Agent 至少包含几个关键要素：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;目标（Goal）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;例如：「帮我规划 7 天日本旅行」「写一篇技术博客」「做一轮代码 Review」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;目标可以是一次性的，也可以被长期持有、拆解为子目标。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;感知（Perception / Observation）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Agent 需要感知外部世界：搜索结果、数据库查询、API 响应、用户的追加指令等。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 里，这就是&lt;strong&gt;工具返回值（Observation）&lt;/strong&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;记忆（Memory）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;短期：本轮对话历史、当前任务上下文。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;长期：过往项目、用户偏好、历史工具调用结果等（更高级的系统才有）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;推理与决策（Reasoning &amp;amp; Decision Making）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;决定「下一步该干什么」：是继续问用户、调用搜索工具、还是直接给出答案？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;ReAct、Plan-and-Execute、Reflection 等范式，本质上都是在设计&lt;strong&gt;不同的决策流程&lt;/strong&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;行动（Action / Tool Use）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;调用工具：搜索引擎、计算器、数据库、HTTP API、本地代码执行环境等。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中，对应 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;search&lt;/code&gt;、&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;calculator&lt;/code&gt;、&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;get_current_time&lt;/code&gt; 等工具。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;环境（Environment）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;包括互联网、文件系统、业务系统、游戏世界（如 Minecraft）、机器人控制系统等。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Agent 通过工具与环境交互，从环境中获得新的 Observation。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;用一个简单的框图来表示：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;LR
&amp;nbsp;&amp;nbsp;U[用户&amp;nbsp;/&amp;nbsp;上层系统]&amp;nbsp;--&amp;gt;|任务/指令|&amp;nbsp;A[Agent]
&amp;nbsp;&amp;nbsp;A&amp;nbsp;--&amp;gt;|调用|&amp;nbsp;T[工具&amp;nbsp;/&amp;nbsp;API&amp;nbsp;/&amp;nbsp;子系统]
&amp;nbsp;&amp;nbsp;T&amp;nbsp;--&amp;gt;|结果|&amp;nbsp;A
&amp;nbsp;&amp;nbsp;A&amp;nbsp;--&amp;gt;|中间结果&amp;nbsp;/&amp;nbsp;最终答案|&amp;nbsp;U
&amp;nbsp;&amp;nbsp;A&amp;nbsp;--&amp;gt;|读写|&amp;nbsp;M[记忆&amp;nbsp;/&amp;nbsp;状态]&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 里，&lt;strong&gt;Agent 本身往往被实现为一个「图（Graph）」&lt;/strong&gt;，其中每个节点代表一个步骤（如 Planner、Executor、Supervisor、Worker、Reflector 等），这些节点一起实现了上图中的「感知 → 决策 → 行动 → 更新状态」循环。&lt;/p&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;二、为什么需要 Agent？&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;如果我们只用「普通 ChatGPT 模式」，会遇到几个典型问题：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;无法可靠完成复杂多步骤任务&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;示例：「帮我调研 3 篇最新的 LangGraph 相关技术文章，提取要点，做一个对比表格」&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;这背后其实需要：搜索 → 逐篇阅读 → 提取关键信息 → 汇总成结构化结果 → 写总结。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;单轮大模型回答，很容易「跳步骤」「幻觉」或遗漏细节。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;缺乏与真实世界系统的连接&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;例如：「帮我查当前汇率，并按今天价格估个机票预算」&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;大模型本身看不到实时数据，一定要通过「工具」连接真实世界。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;缺少可观测、可调试的执行流程&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;单次回答你很难知道：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;它有没有去查资料？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;它是怎么做中间推理的？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Agent + 流程图（如 LangGraph）让整个过程变得&lt;strong&gt;可视化、可调试&lt;/strong&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;无法持续执行长任务&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;比如「帮我持续监控某股票的新闻，重要消息发通知」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;这类任务需要长期运行的 Loop，而不仅仅是一次性输出。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;因此，Agent 的价值可以概括为：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;从「大模型 = 强函数」升级到「大模型 = 可编排的智能子系统」&lt;/strong&gt;；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;让大模型&lt;strong&gt;能主动拆解任务、选择工具、调用环境，并在过程中自我修正&lt;/strong&gt;；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;让开发者可以像搭积木一样，将 ReAct / Plan-and-Execute / Multi-Agent / Reflection 等模式组合起来。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;三、通用 Agent 架构与运行循环&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;无论是哪种范式（ReAct / Plan-and-Execute / 等），背后都有一个类似的「总循环」：&lt;/p&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;接收任务 → 解析任务 → 规划/决策下一步 → 行动（调用工具/子 Agent）→ 观察结果 → 更新状态与计划 → 判断是否结束。&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;可以用一个伪代码式的循环来描述：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;while&amp;nbsp;not&amp;nbsp;done:
&amp;nbsp;&amp;nbsp;1.&amp;nbsp;读取当前目标&amp;nbsp;+&amp;nbsp;状态&amp;nbsp;+&amp;nbsp;观察结果
&amp;nbsp;&amp;nbsp;2.&amp;nbsp;大模型做推理（思考）：下一步该干什么？
&amp;nbsp;&amp;nbsp;3.&amp;nbsp;得到决策：
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;直接给出最终回答？&amp;nbsp;-&amp;gt;&amp;nbsp;done&amp;nbsp;=&amp;nbsp;True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;调用某个工具？&amp;nbsp;-&amp;gt;&amp;nbsp;调用工具，获取新&amp;nbsp;Observation
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;拆分为子任务？&amp;nbsp;-&amp;gt;&amp;nbsp;生成子计划&amp;nbsp;or&amp;nbsp;分配给其他&amp;nbsp;Agent
&amp;nbsp;&amp;nbsp;4.&amp;nbsp;更新内部状态&amp;nbsp;/&amp;nbsp;记忆&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;简单的流程图示意：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TD
&amp;nbsp;&amp;nbsp;S[开始:&amp;nbsp;接收用户任务]&amp;nbsp;--&amp;gt;&amp;nbsp;P[解析任务&amp;nbsp;/&amp;nbsp;理解意图]
&amp;nbsp;&amp;nbsp;P&amp;nbsp;--&amp;gt;&amp;nbsp;D[决策:&amp;nbsp;下一步做什么?]
&amp;nbsp;&amp;nbsp;D&amp;nbsp;--&amp;gt;|调用工具|&amp;nbsp;A1[执行&amp;nbsp;Action&amp;nbsp;工具调用]
&amp;nbsp;&amp;nbsp;A1&amp;nbsp;--&amp;gt;&amp;nbsp;O[观察&amp;nbsp;Observation]
&amp;nbsp;&amp;nbsp;D&amp;nbsp;--&amp;gt;|直接回答|&amp;nbsp;R[生成最终回答]
&amp;nbsp;&amp;nbsp;O&amp;nbsp;--&amp;gt;&amp;nbsp;U[更新状态&amp;nbsp;/&amp;nbsp;记忆]
&amp;nbsp;&amp;nbsp;U&amp;nbsp;--&amp;gt;&amp;nbsp;D
&amp;nbsp;&amp;nbsp;R&amp;nbsp;--&amp;gt;&amp;nbsp;E[结束]&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中，这个循环被用&lt;strong&gt;不同方式具体化&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/agent.py&lt;/code&gt;：在&lt;strong&gt;思考（Thought）— 行动（Action）— 观察（Observation）&lt;/strong&gt;的循环中实现；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/&lt;/code&gt;：把「规划」「执行」拆到不同节点（Planner / Executor）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;multi_agent/graph.py&lt;/code&gt;：通过 Supervisor 调度不同 Worker，在图结构中走不同路径；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;reflection_agent/&lt;/code&gt;：在 Generator ↔ Reflector 之间形成一个「改写—评价—再改写」的闭环。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;四、Agent 常见范式总览&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;围绕 LLM 构造 Agent，目前比较常见的几类范式是：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ReAct 范式&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Thought（思考） + Action（行动） + Observation（观察）循环。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;适合&lt;strong&gt;工具有限、任务较短&lt;/strong&gt;的场景。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Plan-and-Execute 范式&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;先由 Planner 生成一个&lt;strong&gt;完整计划/任务分解&lt;/strong&gt;，再由 Executor 逐步执行。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;适合&lt;strong&gt;复杂、多步骤、可清晰拆解&lt;/strong&gt;的任务。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supervisor Multi-Agent 范式&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;有一个负责「任务分配」的 Supervisor，底下挂多个专长不同的 Worker。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;适合&lt;strong&gt;需要多技能并行协作&lt;/strong&gt;的场景，如「搜索 + 计算 + 写作」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reflection 范式&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Agent 会「审视自己之前的输出」，根据评审反馈做迭代改写。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;适合&lt;strong&gt;对输出质量要求极高&lt;/strong&gt;的任务，如技术文章、复杂分析报告。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 恰好分别实现了这四种范式，对应目录为：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;multi_agent/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;reflection_agent/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;五、`agent-all-in-one` 中的四种典型 Agent 范式&lt;/h2&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;5.1 ReAct 范式：推理 + 行动&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;strong&gt;核心思想：&lt;/strong&gt;&lt;br/&gt;把大模型的&lt;strong&gt;自然语言推理能力（Reasoning）&lt;/strong&gt;和&lt;strong&gt;工具调用能力（Acting）&lt;/strong&gt;交替结合起来，在「思考—行动—观察」的循环中逐步解决问题。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;一个典型的 ReAct 交互日志大概是这样的（简化版）：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;Question:&amp;nbsp;计算&amp;nbsp;123&amp;nbsp;*&amp;nbsp;456&amp;nbsp;等于多少？

Thought:&amp;nbsp;这是一个乘法计算，我应该调用计算器工具。
Action:&amp;nbsp;calculator(&amp;quot;123&amp;nbsp;*&amp;nbsp;456&amp;quot;)
Observation:&amp;nbsp;56088

Thought:&amp;nbsp;已经得到结果，可以回答用户了。
Final&amp;nbsp;Answer:&amp;nbsp;123&amp;nbsp;*&amp;nbsp;456&amp;nbsp;=&amp;nbsp;56088。&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;ReAct 的通用流程图：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;sequenceDiagram
&amp;nbsp;&amp;nbsp;participant&amp;nbsp;U&amp;nbsp;as&amp;nbsp;用户
&amp;nbsp;&amp;nbsp;participant&amp;nbsp;A&amp;nbsp;as&amp;nbsp;Agent&amp;nbsp;(ReAct)
&amp;nbsp;&amp;nbsp;participant&amp;nbsp;T&amp;nbsp;as&amp;nbsp;工具

&amp;nbsp;&amp;nbsp;U-&amp;gt;&amp;gt;A:&amp;nbsp;问题/任务
&amp;nbsp;&amp;nbsp;loop&amp;nbsp;Thought-Action-Observation
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A-&amp;gt;&amp;gt;A:&amp;nbsp;Thought:&amp;nbsp;推理下一步
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A-&amp;gt;&amp;gt;T:&amp;nbsp;Action:&amp;nbsp;调用工具
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T--&amp;gt;&amp;gt;A:&amp;nbsp;Observation:&amp;nbsp;工具结果
&amp;nbsp;&amp;nbsp;end
&amp;nbsp;&amp;nbsp;A--&amp;gt;&amp;gt;U:&amp;nbsp;Final&amp;nbsp;Answer&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;实现位置&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/agent.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;工具定义&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/tools.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;特点&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;实现简单、灵活；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;把&lt;strong&gt;中间推理过程暴露为可观察的「Thought」文本&lt;/strong&gt;，很好调试；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;更适合「一次性问题」或「工具数量不太多」的场景。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;5.2 Plan-and-Execute 范式：先规划，再执行&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;当任务很复杂时，直接用 ReAct 可能会「想到哪做到哪」，缺乏全局视角。&lt;br/&gt;Plan-and-Execute 范式把整个过程拆为两层：&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;Planner（规划器）&lt;/strong&gt;：一次性生成一个&lt;strong&gt;较完整的任务计划&lt;/strong&gt;；&lt;br/&gt;2. &lt;strong&gt;Executor（执行器）&lt;/strong&gt;：顺着计划一步步执行，每一步内部可以再用 ReAct/工具等。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;示意流程：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TD
&amp;nbsp;&amp;nbsp;U[用户任务]&amp;nbsp;--&amp;gt;&amp;nbsp;P[Planner:&amp;nbsp;生成计划&amp;nbsp;Step&amp;nbsp;1..N]
&amp;nbsp;&amp;nbsp;P&amp;nbsp;--&amp;gt;&amp;nbsp;E[Executor:&amp;nbsp;逐步执行每个&amp;nbsp;Step]
&amp;nbsp;&amp;nbsp;E&amp;nbsp;--&amp;gt;&amp;nbsp;R[执行结果&amp;nbsp;&amp;amp;&amp;nbsp;总结]
&amp;nbsp;&amp;nbsp;R&amp;nbsp;--&amp;gt;&amp;nbsp;U2[返回给用户]&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;一个典型例子：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;用户任务：帮我规划一次去日本的&amp;nbsp;7&amp;nbsp;天旅行，包括：
&amp;nbsp;&amp;nbsp;-&amp;nbsp;机票预估预算
&amp;nbsp;&amp;nbsp;-&amp;nbsp;每天的城市安排
&amp;nbsp;&amp;nbsp;-&amp;nbsp;必去景点和大致价格区间

Planner&amp;nbsp;可能生成类似的计划：
&amp;nbsp;&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;通过搜索获取从用户城市飞往东京/大阪的往返机票平均价格
&amp;nbsp;&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;估算&amp;nbsp;7&amp;nbsp;天的住宿预算，按中档酒店标准
&amp;nbsp;&amp;nbsp;Step&amp;nbsp;3:&amp;nbsp;设计&amp;nbsp;Day&amp;nbsp;1-7&amp;nbsp;的城市和景点安排
&amp;nbsp;&amp;nbsp;Step&amp;nbsp;4:&amp;nbsp;输出包含预算和行程表的总结文档

Executor&amp;nbsp;按&amp;nbsp;Step&amp;nbsp;1&amp;nbsp;-&amp;gt;&amp;nbsp;2&amp;nbsp;-&amp;gt;&amp;nbsp;3&amp;nbsp;-&amp;gt;&amp;nbsp;4&amp;nbsp;顺序执行，每一步都可以用工具/子&amp;nbsp;Agent。&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;规划相关代码&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/planner.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;执行相关代码&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/executor.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Agent 入口&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/agent.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;适用场景&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;长任务、结构比较清晰的任务（旅行规划、项目 Roadmap 设计、调研报告等）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;需要&lt;strong&gt;先看整体再细化&lt;/strong&gt;的情况；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;便于在 LangGraph Studio 中可视化：你能看到 Planner 节点出一个计划，Executor 节点按计划一步步跑。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;5.3 Supervisor Multi-Agent 范式：多智能体协作&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;有些任务「内含多种技能」，比如：&lt;/p&gt;&lt;blockquote class=&quot;lwskills-quote&quot; style=&quot;margin:1.2em 0;padding:0.9em 1.2em;border-left:4px solid #3a6ea5;background:#f6f8fa;color:#444;line-height:1.75;&quot;&gt;&lt;p style=&quot;margin:0;&quot;&gt;「搜索今天的天气，计算 256 * 789，然后写一份总结。」&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;如果全部交给一个 Agent 来做，它当然也能完成，但会变得「又要查资料，又要算，又要写」，逻辑混杂。&lt;br/&gt;多智能体范式把不同职责拆开，让&lt;strong&gt;多个专长不同的 Agent 协同工作&lt;/strong&gt;，由一个上层 Supervisor 负责调度。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中，多智能体结构大致是：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supervisor（主管）&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;multi_agent/supervisor.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;负责理解全局任务，决定「什么时候让哪个 Worker 出场」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Workers（工作者）&lt;/strong&gt;：在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;multi_agent/workers.py&lt;/code&gt; 中定义，例如：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Researcher&lt;/code&gt;：使用搜索工具获取信息；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Calculator&lt;/code&gt;：负责准确计算（数学/逻辑计算）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Writer&lt;/code&gt;：负责用自然语言输出总结/报告。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;可以画成这样的结构：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TD
&amp;nbsp;&amp;nbsp;U[用户任务]&amp;nbsp;--&amp;gt;&amp;nbsp;S[Supervisor]
&amp;nbsp;&amp;nbsp;S&amp;nbsp;--&amp;gt;&amp;nbsp;R[Worker:&amp;nbsp;Researcher]
&amp;nbsp;&amp;nbsp;S&amp;nbsp;--&amp;gt;&amp;nbsp;C[Worker:&amp;nbsp;Calculator]
&amp;nbsp;&amp;nbsp;S&amp;nbsp;--&amp;gt;&amp;nbsp;W[Worker:&amp;nbsp;Writer]
&amp;nbsp;&amp;nbsp;R&amp;nbsp;--&amp;gt;&amp;nbsp;S
&amp;nbsp;&amp;nbsp;C&amp;nbsp;--&amp;gt;&amp;nbsp;S
&amp;nbsp;&amp;nbsp;W&amp;nbsp;--&amp;gt;&amp;nbsp;S
&amp;nbsp;&amp;nbsp;S&amp;nbsp;--&amp;gt;&amp;nbsp;U2[最终回答]&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;一个典型的执行流程可能是：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;1.&amp;nbsp;用户给出复合任务（搜索&amp;nbsp;+&amp;nbsp;计算&amp;nbsp;+&amp;nbsp;写作）
2.&amp;nbsp;Supervisor&amp;nbsp;分析任务，先调用&amp;nbsp;Researcher&amp;nbsp;搜集事实
3.&amp;nbsp;Researcher&amp;nbsp;用&amp;nbsp;search&amp;nbsp;工具查资料，返回&amp;nbsp;Observation
4.&amp;nbsp;Supervisor&amp;nbsp;根据&amp;nbsp;Observation&amp;nbsp;调用&amp;nbsp;Calculator&amp;nbsp;完成数值计算
5.&amp;nbsp;最后&amp;nbsp;Supervisor&amp;nbsp;把数据交给&amp;nbsp;Writer&amp;nbsp;生成自然语言总结
6.&amp;nbsp;返回综合结果给用户&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;这种范式的优点：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;职责清晰&lt;/strong&gt;：每个 Worker 专精一类任务，更易于调试和扩展；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;容易并行化&lt;/strong&gt;：多个 Worker 可以并行执行子任务；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;贴合现实团队协作&lt;/strong&gt;：Supervisor 就像项目经理，Workers 像不同专业的工程师。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;5.4 Reflection 范式：反思与自我改进&lt;/h3&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;当你希望 Agent 产出&lt;strong&gt;高质量内容&lt;/strong&gt;（比如技术文章、方案设计、代码优化建议），一次性输出往往不够。&lt;br/&gt;Reflection 范式的核心，是让 Agent 拥有「自我审阅、反思并改写」的能力。&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中，典型角色和流程：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generator（生成器）&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;reflection_agent/generator.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;根据任务和历史反馈，生成当前版本的答案。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reflector（反思器）&lt;/strong&gt;：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;reflection_agent/reflector.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;给当前答案做 Review：指出问题、不足、改进方向。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;反馈可以从多个维度考虑：准确性、完整性、清晰度、结构等。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;迭代闭环&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TD
&amp;nbsp;&amp;nbsp;U[任务说明]&amp;nbsp;--&amp;gt;&amp;nbsp;G[Generator:&amp;nbsp;生成答案&amp;nbsp;V1]
&amp;nbsp;&amp;nbsp;G&amp;nbsp;--&amp;gt;&amp;nbsp;R[Reflector:&amp;nbsp;评审&amp;nbsp;V1,&amp;nbsp;给出改进建议]
&amp;nbsp;&amp;nbsp;R&amp;nbsp;--&amp;gt;&amp;nbsp;G2[Generator:&amp;nbsp;生成答案&amp;nbsp;V2]
&amp;nbsp;&amp;nbsp;G2&amp;nbsp;--&amp;gt;&amp;nbsp;R2[Reflector:&amp;nbsp;再次评审]
&amp;nbsp;&amp;nbsp;R2&amp;nbsp;--&amp;gt;|直到质量合格或达到最大轮数|&amp;nbsp;F[最终答案]&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;一个简单例子（写技术文章）：&lt;/p&gt;&lt;pre class=&quot;lwskills-code&quot; style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;Round&amp;nbsp;1:
&amp;nbsp;&amp;nbsp;Generator&amp;nbsp;输出一篇「LangGraph&amp;nbsp;简介」文章
&amp;nbsp;&amp;nbsp;Reflector&amp;nbsp;评审：指出缺少使用示例、对比传统流程编排方式、没有提到可视化调试

Round&amp;nbsp;2:
&amp;nbsp;&amp;nbsp;Generator&amp;nbsp;根据反馈扩展：加入代码示例、小项目&amp;nbsp;demo、图示
&amp;nbsp;&amp;nbsp;Reflector&amp;nbsp;再次评审：结构有点松散，可以重构为「概念&amp;nbsp;-&amp;gt;&amp;nbsp;使用&amp;nbsp;-&amp;gt;&amp;nbsp;示例&amp;nbsp;-&amp;gt;&amp;nbsp;总结」

Round&amp;nbsp;3:
&amp;nbsp;&amp;nbsp;Generator&amp;nbsp;重构结构，增加小结和实践建议
&amp;nbsp;&amp;nbsp;Reflector&amp;nbsp;认为已达到质量要求&amp;nbsp;-&amp;gt;&amp;nbsp;输出最终稿&lt;/pre&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;优点：&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;易于反复打磨输出质量&lt;/strong&gt;，尤其适合：技术博客、API 文档、系统设计说明；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;天然适配「人类在回路中」的场景：Reflector 也可以是人，而不是模型；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 LangGraph Studio 中，你能看到每一轮 Generator / Reflector 的中间版本，非常利于调试。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;p style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: center;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606091780986575740297.jpg&quot; title=&quot;Agent 原理  第2张&quot; alt=&quot;Agent 原理  第2张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;六、Agent 相关经典论文 / 代表性工作&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;下面按主题列出一些与 Agent、工具增强 LLM、多智能体协作相关的&lt;strong&gt;经典或代表性工作&lt;/strong&gt;，你可以根据兴趣和需要选择阅读。&lt;/p&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;6.1 工具增强与推理（Tool-augmented Reasoning）&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ReAct: Synergizing Reasoning and Acting in Language Models&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Yao et al., 2022&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;提出了 ReAct 范式：将「自然语言推理（Thought）」与「行动（Action）」交替结合，用于工具调用和环境交互。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;对应 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/&lt;/code&gt; 实现。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Toolformer: Language Models Can Teach Themselves to Use Tools&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Schick et al., 2023&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;研究如何让大模型通过自监督方式，在预训练阶段就「学会插入合适的工具调用」，而不是只在推理阶段硬编码；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;更偏向「模型训练策略」，但对实际 Agent 设计有启发：&lt;strong&gt;工具调用可以是训练出来的模式，而不是完全手工 Prompt&lt;/strong&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;PAL: Program-Aided Language Models&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Chen et al., 2022&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;提出让模型&lt;strong&gt;生成可执行代码片段（如 Python）&lt;/strong&gt;来完成复杂推理任务，再执行代码获得结果；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 Agent 语境下，可以看作是「把工具 = 代码执行环境」，通过代码而不是纯文本进行严谨推理。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Chain-of-Thought Prompting Elicits Reasoning in Large Language Models&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Wei et al., 2022&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;不直接讲 Agent，但给出了让模型显式写出中间推理步骤（思维链）的技巧；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;ReAct 可以看作是在 CoT 基础上，再接了一层「工具行动」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;6.2 反思与自我改进（Reflection / Self-Refine）&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reflexion: Language Agents with Verbal Reinforcement Learning&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Shinn et al., 2023&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;倡导让 Agent 对自己的行为结果做「语言化反思」，并利用反思来改进后续策略；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;与 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中的 &lt;strong&gt;Reflection 范式&lt;/strong&gt;高度契合：Generator + Reflector 的闭环。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Self-Refine: Iterative Refinement with Self-Feedback&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Madaan et al., 2023&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;让模型对自己的回答生成反馈（例如指出模糊、不准确之处），再根据反馈改写答案；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;对写作、代码生成、翻译等任务非常实用，是很多 Reflection 型 Agent 的灵感来源。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;6.3 规划、搜索与决策（Planning / Search）&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree of Thoughts: Deliberate Problem Solving with Large Language Models&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Yao et al., 2023&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;把大模型的推理过程看作在「思维树」上进行搜索，而不是一条线性的思维链；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;为更复杂的规划型 Agent 提供了搜索框架：可以保留多条候选思路，做回溯和评估。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Plan-and-Solve Prompting&lt;/strong&gt;（可查阅相关工作）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;思想与 Plan-and-Execute 很接近：&lt;strong&gt;先让模型显式写出计划，再按计划解决任务&lt;/strong&gt;；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 中，&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/&lt;/code&gt; 其实就是这种思想的工程化实现。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 class=&quot;lwskills-h3&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.25em;color:#222;font-weight:600;&quot;&gt;6.4 多智能体与长期任务（Multi-Agent / Long-horizon Agents）&lt;/h3&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Voyager: An Open-Ended Embodied Agent with Large Language Models&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;&lt;em&gt;Wang et al., 2023&lt;/em&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 Minecraft 环境中构建了一个「会自己探索、记忆、学习技能」的长期 Agent；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;关键点在于：&lt;strong&gt;技能库（技能程序的记忆）、长期目标、与环境的持续交互&lt;/strong&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;对于理解「真正意义上的 Agent（不仅是 QA 机器人）」非常有启发。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Auto-GPT / BabyAGI 等开源项目（虽然不都是论文）&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;把 LLM 装上「目标管理、任务分解、任务队列、执行器、记忆」等模块，形成较完整的 Agent 系统；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;是许多工程实践中「多轮自动执行、反复调用工具」范式的早期样板。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;七、如何选择和实践这些 Agent 范式？&lt;/h2&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;结合 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt;，可以给出一个简单的「&lt;strong&gt;学习和实践路径&lt;/strong&gt;」：&lt;/p&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;1. &lt;strong&gt;从 ReAct 入门&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;先理解 Thought / Action / Observation 循环；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;react_agent/&lt;/code&gt; 中观察：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;模型是如何决定「该用哪个工具」的？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;工具输入/输出是如何以文本形式被包装起来的？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;2. &lt;strong&gt;向 Plan-and-Execute 过渡&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;plan_execute_agent/&lt;/code&gt; 里理解 Planner / Executor 拆分后的好处：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Planner 只考虑「做什么」和「顺序」；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Executor 只负责「一步步把事情做完」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 LangGraph Studio 中查看这两类节点的执行路径。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;3. &lt;strong&gt;尝试 Multi-Agent 协作&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;打开 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;multi_agent/graph.py&lt;/code&gt; 和 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;workers.py&lt;/code&gt;，看看：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Supervisor 是根据什么信息决定调用哪个 Worker？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;Worker 之间有没有共享状态 / 记忆？&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;尝试给系统增加一个新 Worker（比如「翻译专家」），体会可扩展性。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-p&quot; style=&quot;margin:0 0 1em;line-height:1.75;color:#333;&quot;&gt;4. &lt;strong&gt;最后玩转 Reflection 范式&lt;/strong&gt;&lt;/p&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;reflection_agent/&lt;/code&gt; 中观察 Generator 和 Reflector 的反复交互；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;尝试调高/调低「迭代轮数」，看看输出质量和时间的权衡；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;把你正在写的技术文章交给这个 Agent 打磨试试。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr class=&quot;lwskills-hr&quot; style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 class=&quot;lwskills-h2&quot; style=&quot;margin:1.2em 0 0.6em;font-size:1.5em;color:#222;font-weight:600;&quot;&gt;小结&lt;/h2&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Agent 是什么&lt;/strong&gt;：在大模型之上，加入目标、记忆、工具和环境交互的「智能执行体」。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;为什么需要 Agent&lt;/strong&gt;：为了解决复杂任务、多工具协同、长时运行以及可观测调试的问题。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;常见范式&lt;/strong&gt;：ReAct、Plan-and-Execute、Supervisor Multi-Agent、Reflection 等，各有适用场景。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul class=&quot;lwskills-ul list-paddingleft-2&quot; style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-all-in-one&lt;/code&gt; 的价值&lt;/strong&gt;：它把这些范式都做了一个&lt;strong&gt;最小但完整的工程实现&lt;/strong&gt;，配合 LangGraph Studio，可以清楚看到 Agent 的内部思考和工具调用链路，非常适合作为你在笔记库《Agent 原理》中的「理论 + 实战」桥梁。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;lwskills-download-wrap&quot; style=&quot;margin-top: 2em; padding-top: 1.2em; border-top: 1px solid rgb(232, 232, 232); text-align: center;&quot;&gt;&lt;a href=&quot;https://www.lw50.com/zb_users/plugin/lwskills/download.php?id=1935&quot; class=&quot;lwskills-download-btn&quot; style=&quot;display:inline-block;padding:10px 28px;background:#3a6ea5;color:#fff;text-decoration:none;border-radius:4px;font-size:14px;&quot;&gt;下载文档&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 09 Jun 2026 14:30:34 +0800</pubDate></item><item><title>Skill：让 Agent 变得可复用、可控、可演进</title><link>https://www.lw50.com/post/3578e58e.html</link><description>&lt;h2 style=&quot;text-align: left;&quot;&gt;为什么要把“提示词经验”升级成 `Skill`&lt;/h2&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果你只是偶尔问问 ChatGPT，一个“写得不错的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Prompt&lt;/code&gt;”已经足够。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;但只要你开始用 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 做事（写代码、跑脚本、查资料、写文档、对接系统），很快会撞上三个工程层面的老问题：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;不稳定&lt;/strong&gt;：同一个任务，今天能做对，明天换点上下文就跑偏。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;不可控&lt;/strong&gt;：你知道它“可能会做”，但你说不清它“应该怎么做”，更别提调试。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;难复用&lt;/strong&gt;：每次都要靠“临场发挥”去改提示词，经验沉淀不下来。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;我倾向于把这类问题归因到一句话：&lt;strong&gt;你把一段“工作方法”塞进了对话上下文，但它并不是一个“可调用的能力单元”。&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;而 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的目标很朴素：把“会做”变成“可调用”，把“经验”变成“资产”。&lt;/p&gt;&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606081780904502566399.jpg&quot; title=&quot;Skill：让 Agent 变得可复用、可控、可演进  第1张&quot; alt=&quot;Skill：让 Agent 变得可复用、可控、可演进  第1张&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;一、`Skill` 是什么&lt;/h2&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;1.1 一句话定义：`Skill` 解决了什么问题&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;&lt;strong&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 是对某类任务的“稳定做法”的封装&lt;/strong&gt;：它把你希望 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 遵循的步骤、校验点、输入输出规范、以及可用工具边界，做成一个可以复用的能力单元。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;你可以把它理解成：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;在软件工程里，它更像一个“模块 / 函数”，而不是“临时写在控制台里的命令”；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;在团队协作里，它更像一份“可执行的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;SOP&lt;/code&gt;”，而不是“某个人脑子里的诀窍”。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;1.2 `Skill` 的组成：说明、契约、边界、失败处理&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一个最小可用的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;，建议至少回答四个问题：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;它能做什么&lt;/strong&gt;：适用场景与目标（以及 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Non-Goals&lt;/code&gt;：明确“不做什么”）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;怎么用它&lt;/strong&gt;：输入是什么、输出长什么样（可被下游消费）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;它怎么做&lt;/strong&gt;：步骤、关键决策点、每步的校验标准。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;它在什么边界里做&lt;/strong&gt;：能调用哪些工具，能读写哪些资源，遇到失败怎么处理（重试/降级/请求用户补充信息）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这里面最“反直觉”的，是 &lt;strong&gt;输入输出契约&lt;/strong&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;很多人写提示词只关注“你要做什么”，但忽略“你要输出什么结构”。结果就是：看起来像在执行，但产物不可用、不可组合、不可验证。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;1.3 一张图看懂：`Skill` 的“可验收执行链”&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果只看文字，&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 很容易被误解成“更长的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Prompt&lt;/code&gt;”。其实它更像一条&lt;strong&gt;可中断、可回退、可验收&lt;/strong&gt;的执行链：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TB
&amp;nbsp;&amp;nbsp;A[Inputs&amp;nbsp;输入&amp;lt;br/&amp;gt;必填/选填]&amp;nbsp;--&amp;gt;&amp;nbsp;B[Steps&amp;nbsp;执行步骤&amp;lt;br/&amp;gt;可拆分/可复用]
&amp;nbsp;&amp;nbsp;B&amp;nbsp;--&amp;gt;&amp;nbsp;C[Checks&amp;nbsp;校验点&amp;lt;br/&amp;gt;格式/范围/关键字段]
&amp;nbsp;&amp;nbsp;C&amp;nbsp;--&amp;gt;|通过|&amp;nbsp;D[Outputs&amp;nbsp;产物&amp;lt;br/&amp;gt;结构固定/可被下游消费]
&amp;nbsp;&amp;nbsp;C&amp;nbsp;--&amp;gt;|失败|&amp;nbsp;E[Failure&amp;nbsp;Modes&amp;nbsp;失败处理&amp;lt;br/&amp;gt;补信息/重试/降级/停止]
&amp;nbsp;&amp;nbsp;E&amp;nbsp;--&amp;gt;&amp;nbsp;B&lt;/pre&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;1.4 `Skill` 的颗粒度：什么时候拆，什么时候合&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;我的经验是：把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的颗粒度控制在“&lt;strong&gt;一次对话里可以讲清楚、一次执行里可以验收&lt;/strong&gt;”。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一个粗糙但好用的判断方式：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;该拆的信号&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 里出现了多种完全不同的决策路径；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;产物形态差异很大（时而写报告、时而写代码、时而查数据）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;你发现自己想给它加越来越多的“如果……就……否则……”。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;该合的信号&lt;/strong&gt;：&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;拆开后每个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 都依赖前一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的半成品；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;你需要用户频繁“手动串联”多个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 才能完成一个最小任务。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;二、为什么需要 `Skill`&lt;/h2&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;2.1 复用：把个人经验变成团队资产&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;在没有 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的世界里，经验往往以三种形式存在：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;某个“写得不错”的聊天记录；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;某个人脑子里的“手感”；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;一个越写越长、越改越乱的系统提示词。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的价值在于：&lt;strong&gt;它让经验具备可复制性&lt;/strong&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;| 维度 | 普通 Prompt | Skill (能力单元) |&lt;br style=&quot;text-align: left;&quot;/&gt;| :--- | :--- | :--- |&lt;br style=&quot;text-align: left;&quot;/&gt;| &lt;strong&gt;主要载体&lt;/strong&gt; | 一段聊天记录 / 临时指令 | 独立文件 (.md / .mdc) |&lt;br style=&quot;text-align: left;&quot;/&gt;| &lt;strong&gt;复用性&lt;/strong&gt; | 依赖复制粘贴 | 可被路由、可被导入 |&lt;br style=&quot;text-align: left;&quot;/&gt;| &lt;strong&gt;关注点&lt;/strong&gt; | &amp;quot;帮我把这个做了&amp;quot; | &amp;quot;按这个标准流程做&amp;quot; |&lt;br style=&quot;text-align: left;&quot;/&gt;| &lt;strong&gt;稳定性&lt;/strong&gt; | 随机性强，依赖模型心情 | 有校验点，输出结构固定 |&lt;br style=&quot;text-align: left;&quot;/&gt;| &lt;strong&gt;维护方式&lt;/strong&gt; | 每次重写 | 版本管理 (Git) |&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一旦你把能力写成 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;，它就可以：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;被别的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 复用；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;被同一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 在不同项目复用；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;被团队评审、迭代、版本化。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;2.2 可控：让结果稳定，过程可解释&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;“可控”不是指让模型不犯错，而是指：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;你能明确它“应该按哪些步骤做”；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;你能定位它“在哪一步偏了”；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;你能以最小代价修复（改 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的某个步骤/校验点），而不是重写整段提示词。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这其实就是把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 从“玄学”拉回“工程”的核心手段。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;2.3 降低上下文膨胀：按需注入，而不是永久塞进系统提示词&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;当你把所有经验都塞进系统提示词时，你会得到一个“看起来无所不能”的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt;，但代价是：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;上下文越来越大，模型注意力被稀释；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;规则之间开始互相打架；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;修改任何一处都可能引入连锁反应。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的思路是：&lt;strong&gt;默认轻装上阵，需要某项能力时再加载该能力的说明与约束&lt;/strong&gt;。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;2.4 团队协作视角：写 `Skill` 像写 `SOP`，用 `Skill` 像调用函数&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;当你把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 当成团队资产后，很多工程问题会自然出现一套“正确做法”：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;需要 review（否则每个人都会写出一套不兼容的输出格式）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;需要版本号（否则你不知道线上用的是哪一版）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;需要验收标准（否则你只是在写“更长的文字”）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;三、`Skill` 和 `MCP` 的区别&lt;/h2&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一句话概括：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 解决“怎么做”&lt;/strong&gt;：方法、流程、校验、产物。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt; 解决“能做什么”&lt;/strong&gt;：把外部工具/资源用标准协议接进来，让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 可调用。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;你可以把它理解成两层：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;工具层（&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt;）&lt;/strong&gt;：提供可调用的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Tool&lt;/code&gt; / 可读取的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Resource&lt;/code&gt; / 可复用的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Prompt&lt;/code&gt;。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;方法层（&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;）&lt;/strong&gt;：把工具按某种可靠流程组织起来，形成稳定产物。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;graph&amp;nbsp;TD
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;User[用户&amp;nbsp;User]&amp;nbsp;--&amp;gt;|自然语言指令|&amp;nbsp;Agent
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subgraph&amp;nbsp;Agent&amp;nbsp;Runtime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SystemPrompt[System&amp;nbsp;Prompt&amp;lt;br/&amp;gt;(人设、基础约束)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Router[决策/路由层]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Agent&amp;nbsp;--&amp;gt;&amp;nbsp;SystemPrompt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SystemPrompt&amp;nbsp;--&amp;gt;&amp;nbsp;Router
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subgraph&amp;nbsp;Skill&amp;nbsp;Layer&amp;nbsp;[Skill&amp;nbsp;层&amp;nbsp;(怎么做)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Write[写作&amp;nbsp;Skill&amp;lt;br/&amp;gt;(SOP、校验、格式)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Code[代码&amp;nbsp;Skill&amp;lt;br/&amp;gt;(重构、测试、Review)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Search[搜索&amp;nbsp;Skill&amp;lt;br/&amp;gt;(关键词优化、总结)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Router&amp;nbsp;--&amp;gt;|匹配场景|&amp;nbsp;S_Write
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Router&amp;nbsp;--&amp;gt;|匹配场景|&amp;nbsp;S_Code
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subgraph&amp;nbsp;MCP&amp;nbsp;Layer&amp;nbsp;[MCP&amp;nbsp;工具层&amp;nbsp;(能做什么)]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T_File[文件读写&amp;nbsp;Tool]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T_DB[数据库&amp;nbsp;Tool]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T_Web[联网搜索&amp;nbsp;Tool]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Write&amp;nbsp;--&amp;gt;|调用|&amp;nbsp;T_File
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Code&amp;nbsp;--&amp;gt;|调用|&amp;nbsp;T_File
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S_Search&amp;nbsp;--&amp;gt;|调用|&amp;nbsp;T_Web&lt;/pre&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;3.1 典型误区：把 `Skill` 当 `Tool`，或把 `MCP` 当工作流引擎&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;常见的两个走偏方式：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 当 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Tool&lt;/code&gt;&lt;/strong&gt;：把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 写成“调用某个接口的说明书”，最后得到的是一个脆弱的、只在某个项目里能跑通的流程。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt; 当工作流引擎&lt;/strong&gt;：以为“把工具接进来”就等于“事情能做好”，但缺少 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的校验点与产物标准，最后输出仍然不可控。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;真正的组合方式通常是：&lt;strong&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 调用 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP Tool&lt;/code&gt;&lt;/strong&gt;。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;3.2 一个直观类比：`Skill` 是“代码结构”，`MCP` 是“依赖注入”&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 当作一个软件系统：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt; 更像依赖注入：我把数据库、文件系统、内网 API 这些能力“接进来”；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 更像业务代码：我规定“什么时候查库”“什么时候读文件”“什么时候让用户确认”，并把产物结构固定下来。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;再用一张图表达“谁依赖谁”会更直观：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;TB
&amp;nbsp;&amp;nbsp;subgraph&amp;nbsp;L2[方法层：`Skill`]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S1[Workflow&amp;nbsp;/&amp;nbsp;SOP&amp;lt;br/&amp;gt;步骤编排]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S2[Contracts&amp;lt;br/&amp;gt;输入输出契约]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S3[Checks&amp;lt;br/&amp;gt;验收与中断点]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S2&amp;nbsp;--&amp;gt;&amp;nbsp;S1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;S3&amp;nbsp;--&amp;gt;&amp;nbsp;S1
&amp;nbsp;&amp;nbsp;end

&amp;nbsp;&amp;nbsp;subgraph&amp;nbsp;L1[工具层：`MCP`]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T1[Tool&amp;lt;br/&amp;gt;File/DB/API]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T2[Resource&amp;lt;br/&amp;gt;Docs/KB]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T3[Prompt&amp;lt;br/&amp;gt;模板/片段]
&amp;nbsp;&amp;nbsp;end

&amp;nbsp;&amp;nbsp;S1&amp;nbsp;--&amp;gt;&amp;nbsp;T1
&amp;nbsp;&amp;nbsp;S1&amp;nbsp;--&amp;gt;&amp;nbsp;T2
&amp;nbsp;&amp;nbsp;S1&amp;nbsp;--&amp;gt;&amp;nbsp;T3&lt;/pre&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://www.lw50.com/zb_users/upload/2026/06/202606081780904704779875.jpg&quot; title=&quot;Skill：让 Agent 变得可复用、可控、可演进  第2张&quot; alt=&quot;Skill：让 Agent 变得可复用、可控、可演进  第2张&quot; class=&quot;ue-image&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;四、如何设计一个“好用”的 `Skill`&lt;/h2&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这一节更偏方法论：你不需要任何框架，也不需要先写代码，只要把它当成“写给未来自己的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;SOP&lt;/code&gt;”。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;4.1 先写 `Non-Goals`：不做什么，比做什么更重要&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 最容易失控的地方是“贪多”。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;建议在开头直接写清楚：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;这个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; &lt;strong&gt;不处理&lt;/strong&gt;哪些情况；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;这些情况应该交给哪个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; / 交给用户补充什么信息；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;失败时允许的降级方案是什么。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这会显著减少 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 的“自作主张”。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;4.2 再写校验点：每一步都可验证、可中断、可回退&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;好 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的关键不是“步骤多”，而是“每步可验收”：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;可验证&lt;/strong&gt;：每一步输出都能用简单规则检查（格式、范围、关键字段齐全）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;可中断&lt;/strong&gt;：发现不满足前置条件时，立即停下来问用户，而不是硬编。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;可回退&lt;/strong&gt;：如果某一步失败，有明确的替代路径（例如改用另一种数据源，或先输出 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;TODO&lt;/code&gt; 列表）。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这类“校验点”越明确，&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 越像工程系统，而不是聊天机器人。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;把 4.1～4.2 合起来，其实就是一个“从目标到验收”的设计流：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;flowchart&amp;nbsp;LR
&amp;nbsp;&amp;nbsp;A[Goal&amp;nbsp;目标]&amp;nbsp;--&amp;gt;&amp;nbsp;B[Non-Goals&amp;nbsp;不做什么]
&amp;nbsp;&amp;nbsp;B&amp;nbsp;--&amp;gt;&amp;nbsp;C[Inputs/Outputs&amp;nbsp;输入输出契约]
&amp;nbsp;&amp;nbsp;C&amp;nbsp;--&amp;gt;&amp;nbsp;D[Steps&amp;nbsp;步骤编排]
&amp;nbsp;&amp;nbsp;D&amp;nbsp;--&amp;gt;&amp;nbsp;E[Checks&amp;nbsp;校验点]
&amp;nbsp;&amp;nbsp;E&amp;nbsp;--&amp;gt;&amp;nbsp;F[Failure&amp;nbsp;Modes&amp;nbsp;失败处理]
&amp;nbsp;&amp;nbsp;F&amp;nbsp;--&amp;gt;&amp;nbsp;G[Examples&amp;nbsp;&amp;amp;&amp;nbsp;Version&amp;nbsp;示例与版本化]&lt;/pre&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;4.3 最后写触发条件：什么时候该用这个 `Skill`&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 如果没有“触发条件”，最终会变成“每次都想用，但每次都要解释一遍”。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;建议写成三段：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;适用场景&lt;/strong&gt;：满足哪些条件时，优先使用它。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;不适用场景&lt;/strong&gt;：哪些情况不要用。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;快速自检&lt;/strong&gt;：用户只要回答 2～3 个问题，你就能判断该不该启用。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;4.4 一个可复用的 `Skill` 模板（推荐）&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;你可以把下面这个模板当成写 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的骨架（放在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;SKILL.md&lt;/code&gt; 里也好，放在内部文档里也好）：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;Skill&amp;nbsp;名称：

目标（Goal）：

不做什么（Non-Goals）：

输入（Inputs）：
-&amp;nbsp;必填：
-&amp;nbsp;选填：

输出（Outputs）：
-&amp;nbsp;产物格式：
-&amp;nbsp;验收标准：

工具边界（Tooling&amp;nbsp;Boundaries）：
-&amp;nbsp;允许调用：
-&amp;nbsp;禁止调用：
-&amp;nbsp;权限与安全要求：

执行步骤（Steps）：
1)
2)
3)

校验点（Checks）：
-&amp;nbsp;Step&amp;nbsp;1&amp;nbsp;校验：
-&amp;nbsp;Step&amp;nbsp;2&amp;nbsp;校验：

失败处理（Failure&amp;nbsp;Modes）：
-&amp;nbsp;缺信息：
-&amp;nbsp;工具失败：
-&amp;nbsp;结果不可信：&lt;/pre&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;4.5 实战案例：Java 代码审查 Skill&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这是一个真实的 Skill 定义示例，你可以直接存为 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/rules/java-review.mdc&lt;/code&gt;：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;---
description:&amp;nbsp;当用户要求&amp;nbsp;Review&amp;nbsp;Java&amp;nbsp;代码时触发
globs:&amp;nbsp;*.java
---

#&amp;nbsp;Java&amp;nbsp;Code&amp;nbsp;Review&amp;nbsp;Skill

##&amp;nbsp;目标
找出代码中的&amp;nbsp;NPE&amp;nbsp;风险、并发问题及不符合阿里巴巴规范的命名。

##&amp;nbsp;Non-Goals
-&amp;nbsp;不负责重写整个架构
-&amp;nbsp;不关注缩进和空格（交给&amp;nbsp;Formatter）

##&amp;nbsp;审查步骤&amp;nbsp;(Steps)
1.&amp;nbsp;**安全性检查**：扫描所有入参，检查是否有&amp;nbsp;`@Nullable`&amp;nbsp;或未判空的使用。
2.&amp;nbsp;**性能检查**：检查循环中是否有数据库调用或&amp;nbsp;RPC。
3.&amp;nbsp;**规范检查**：对比变量命名是否符合驼峰，常量是否大写。

##&amp;nbsp;校验点&amp;nbsp;(Checkpoints)
-&amp;nbsp;[&amp;nbsp;]&amp;nbsp;每一个指出的问题必须引用具体行号。
-&amp;nbsp;[&amp;nbsp;]&amp;nbsp;每一个修改建议必须提供&amp;nbsp;`Before`&amp;nbsp;和&amp;nbsp;`After`&amp;nbsp;代码对比。

##&amp;nbsp;失败处理
-&amp;nbsp;如果代码依赖缺失导致无法判断类型，请输出&amp;nbsp;&amp;quot;⚠️&amp;nbsp;缺少上下文，假设为...&amp;quot;&lt;/pre&gt;&lt;hr style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;五、在 `Claude Code` 和 `Cursor` 上落地 `Skill`&lt;/h2&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;这一节我会尽量给你“可操作”的路径，但不同产品对 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的实现细节会随版本变化：&lt;strong&gt;文件放哪里、如何 reload，以你当前环境为准&lt;/strong&gt;。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;5.1 `Claude Code`：把 `Skill` 当成“可发现的能力包”&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;概念上，你可以把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Claude Code&lt;/code&gt; 的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 当成一个目录（一个能力包）：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;目录名：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;skill&lt;/code&gt; 的名字（也是它被发现/调用时的标识）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;SKILL.md&lt;/code&gt;：这项能力的说明与执行规范（建议按上面的模板写）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;其他文件：脚本、示例输入输出、测试用例（可选）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;一个推荐的组织方式是把它们放进项目内的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;skills/&lt;/code&gt; 目录，形如：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;your-repo/
&amp;nbsp;&amp;nbsp;skills/
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;blog-writer/
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SKILL.md
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;examples/
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input.md
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output.md&lt;/pre&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;当你需要启用某个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 时，核心不是“神秘指令”，而是两件事：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 知道这个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 存在&lt;/strong&gt;（可发现）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 按 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;SKILL.md&lt;/code&gt; 的契约输出&lt;/strong&gt;（可验收）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果你用的是 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Claude Code&lt;/code&gt; 自带的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 管理/重载能力（有的版本会提供类似 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;/reload&lt;/code&gt; 的命令），建议把它当成“开发态便利功能”，而不是系统设计的前提：真正重要的是目录结构与契约文本本身。&lt;/p&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;5.2 `Cursor`：用 `.cursor/rules/*.mdc` 组织“类 `Skill`”&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Cursor&lt;/code&gt; 当前更偏“&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Rules&lt;/code&gt; 驱动”：你把一套稳定做法写进 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/rules/*.mdc&lt;/code&gt;，它就能在对话/改代码时持续遵循这套约束。&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;你仓库里已经有一个规则文件：&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/rules/yano-blog-writer.mdc&lt;/code&gt;，它本质上就是一个非常标准的“写作类 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;”：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;明确流程&lt;/strong&gt;：先大纲，再正文（强制交互确认）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;明确风格&lt;/strong&gt;：中文与 English 空格、术语用反引号&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;明确自检清单&lt;/strong&gt;：输出前过一遍&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果你要在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Cursor&lt;/code&gt; 里继续扩展 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;，我建议的做法是：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 一个 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.mdc&lt;/code&gt; 文件&lt;/strong&gt;：命名体现用途（例如 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;agent-skill-design.mdc&lt;/code&gt;）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;默认 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;alwaysApply: false&lt;/code&gt;&lt;/strong&gt;：避免所有对话都被“规则污染”&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;需要长期生效时再开启&lt;/strong&gt;：把 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;alwaysApply&lt;/code&gt; 改为 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;true&lt;/code&gt;，或把关键规则复制到当前任务上下文里&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;5.3 与 `MCP` 的配合：用 `.cursor/mcp.json` 把工具接入作为能力底座&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果你的 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 需要“调用外部能力”（读文件、查数据库、访问内网 API），那就让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt; 来解决“接入工具”。示例：&lt;/p&gt;&lt;pre style=&quot;margin:1.2em 0;padding:1em;background:#282c34;color:#abb2bf;border-radius:6px;overflow:auto;&quot;&gt;{
&amp;nbsp;&amp;nbsp;&amp;quot;mcpServers&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;local-dev&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;command&amp;quot;:&amp;nbsp;&amp;quot;java&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;args&amp;quot;:&amp;nbsp;[&amp;quot;-jar&amp;quot;,&amp;nbsp;&amp;quot;mcp-server.jar&amp;quot;],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;env&amp;quot;:&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;WORKSPACE_ROOT&amp;quot;:&amp;nbsp;&amp;quot;${workspaceFolder}&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;我更推荐的组合方式是：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt;（规则/流程）写在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/rules/&lt;em&gt;.mdc&lt;/em&gt;&lt;/code&gt; 或 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;skills//SKILL.md&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;能力（工具/资源）通过 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;.cursor/mcp.json&lt;/code&gt; 接入&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 去“调用工具并验收产物”&lt;/strong&gt;，而不是让工具去“替你决定做法”&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.25em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;5.4 `Skill` 的测试与调试&lt;/h3&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;&lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 既然是工程化的，就必须可测试。建议的测试策略：&lt;/p&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;黄金数据集&lt;/strong&gt;：保留一组 Input 和 期望的 Output。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;回归测试&lt;/strong&gt;：当你修改 Skill 的步骤时，用上面的 Input 跑一遍，看 Output 格式是否崩坏。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;margin:0 0 1em 1.5em;padding:0;line-height:1.75;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;调试技巧&lt;/strong&gt;：在 Skill 中显式要求 Agent 输出 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;&amp;lt;thinking&amp;gt;&lt;/code&gt; 标签，打印它执行每一步时的决策过程。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;border:none;border-top:1px solid #e0e0e0;margin:2em 0;&quot;/&gt;&lt;h2 style=&quot;margin: 1.2em 0px 0.6em; font-size: 1.5em; color: rgb(34, 34, 34); font-weight: 600; text-align: left;&quot;&gt;六、结尾：`Skill` 的本质，是把“工作方法”产品化&lt;/h2&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;我对 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的最短总结是：&lt;/p&gt;&lt;blockquote style=&quot;margin: 1.2em 0px; padding: 0.9em 1.2em; border-left: 4px solid rgb(58, 110, 165); background: rgb(246, 248, 250); color: rgb(68, 68, 68); line-height: 1.75; text-align: left;&quot;&gt;&lt;p style=&quot;margin: 0px; text-align: left;&quot;&gt;&lt;strong&gt;把“工作方法”写成可复用的能力单元，让 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Agent&lt;/code&gt; 从“会聊”走向“会做”，从“能做”走向“稳定地做”。&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 0px 0px 1em; line-height: 1.75; color: rgb(51, 51, 51); text-align: left;&quot;&gt;如果你已经在写 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Prompt&lt;/code&gt;、写 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Rules&lt;/code&gt;、接 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;MCP&lt;/code&gt; 工具，那你其实已经走在 &lt;code style=&quot;padding:2px 6px;background:#f0f0f0;border-radius:3px;font-size:0.9em;&quot;&gt;Skill&lt;/code&gt; 的路上了：接下来只差把它们“模块化、契约化、可验收化”。&lt;/p&gt;&lt;p style=&quot;margin-top: 2em; padding-top: 1.2em; border-top: 1px solid rgb(232, 232, 232); text-align: center;&quot;&gt;&lt;a href=&quot;https://www.lw50.com/zb_users/plugin/lwskills/download.php?id=1938&quot; style=&quot;display:inline-block;padding:10px 28px;background:#3a6ea5;color:#fff;text-decoration:none;border-radius:4px;font-size:14px;&quot;&gt;下载文档&lt;/a&gt;&lt;/p&gt;</description><pubDate>Mon, 08 Jun 2026 15:36:24 +0800</pubDate></item></channel></rss>