<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <author>
    <name>董沛贤</name>
  </author>
  <generator uri="https://hexo.io/">Hexo</generator>
  <id>https://dongpeixian.art/</id>
  <link href="https://dongpeixian.art/" rel="alternate"/>
  <link href="https://dongpeixian.art/atom.xml" rel="self"/>
  <rights>All rights reserved 2026, 董沛贤</rights>
  <subtitle>董沛贤的个人站</subtitle>
  <title>dongpeixian.art</title>
  <updated>2026-04-03T07:49:55.342Z</updated>
  <entry>
    <author>
      <name>董沛贤</name>
    </author>
    <category term="技术" scheme="https://dongpeixian.art/categories/%E6%8A%80%E6%9C%AF/"/>
    <category term="AI Agent" scheme="https://dongpeixian.art/tags/AI-Agent/"/>
    <category term="Skills" scheme="https://dongpeixian.art/tags/Skills/"/>
    <category term="OpenAI" scheme="https://dongpeixian.art/tags/OpenAI/"/>
    <category term="Claude" scheme="https://dongpeixian.art/tags/Claude/"/>
    <category term="GPTs" scheme="https://dongpeixian.art/tags/GPTs/"/>
    <content>
      <![CDATA[<blockquote><p>随着 AI Agent 概念爆发，Skills（技能包&#x2F;提示词集）市场也在快速成型。本文梳理目前主流的平台和 marketplace。</p></blockquote><hr><h2 id="一、OpenAI-GPTs-Store"><a href="#一、OpenAI-GPTs-Store" class="headerlink" title="一、OpenAI GPTs Store"></a>一、OpenAI GPTs Store</h2><p><strong>地位</strong>：最大、生态最成熟</p><p><a href="https://openai.com/">OpenAI</a> 在 2024 年推出 GPTs 和 GPT Store，允许用户创建、分享和发现自定义 GPT 助手。</p><ul><li><a href="https://chat.openai.com/gpts">GPT Store</a> — 直接访问</li></ul><p><strong>特点</strong>：</p><ul><li>基于 ChatGPT 的对话式 Agent</li><li>无需编程，通过对话配置即可创建</li><li>内置 Actions（API 调用）和 Knowledge（文档上传）</li><li>ChatGPT Plus 用户可直接使用</li><li>创作者可以标注类别，但无法直接变现（目前）</li></ul><p><strong>局限</strong>：</p><ul><li>仅限 OpenAI 生态</li><li>Actions 能力有限，复杂自动化需要 Pro 订阅</li><li>平台管控较松，质量参差不齐</li></ul><hr><h2 id="二、OpenClaw-与-ClawHub"><a href="#二、OpenClaw-与-ClawHub" class="headerlink" title="二、OpenClaw 与 ClawHub"></a>二、OpenClaw 与 ClawHub</h2><p><strong>代表平台</strong>：<a href="https://clawhub.ai/">ClawHub</a></p><p><a href="https://docs.openclaw.ai/">OpenClaw</a> 是一个独立的 AI 助手框架，与 Anthropic 的 Claude <strong>没有任何关系</strong>。ClawHub 是 OpenClaw 的 Skills 市场，采用类似 npm 的包管理思路：</p><p><strong>特点</strong>：</p><ul><li>Skill 以文件夹形式打包，包含 SKILL.md 说明文件</li><li>支持版本管理、安装、卸载</li><li>搜索友好（向量检索）</li><li>开放发布，无需审核即可上传</li><li>安装命令：<code>px clawhub@latest install &lt;skill-name&gt;</code></li></ul><p><strong>典型 Skill 类型</strong>：</p><ul><li>feishu-* （飞书集成）</li><li>weather（天气查询）</li><li>healthcheck（安全检查）</li><li>node-connect（节点连接诊断）</li></ul><hr><h2 id="三、GitHub-Marketplace"><a href="#三、GitHub-Marketplace" class="headerlink" title="三、GitHub Marketplace"></a>三、GitHub Marketplace</h2><p><strong>定位</strong>：面向开发者的代码&#x2F;工具类 Agent 市场</p><p><a href="https://github.com/marketplace">GitHub Marketplace</a> 已成为 AI 编程助手插件的主要分发渠道：</p><p><strong>代表产品</strong>：</p><ul><li><a href="https://github.com/features/copilot">GitHub Copilot Extensions</a></li><li><a href="https://cursor.com/">Cursor Rules</a></li><li><a href="https://aider.chat/">Aider</a> 对应规则集</li><li>各语言的 LSP 工具</li></ul><p><strong>特点</strong>：</p><ul><li>与代码开发流程深度绑定</li><li>很多是开源的规则&#x2F;提示词集</li><li>技术门槛相对较高</li></ul><hr><h2 id="四、Cursor-Windsurf-等-IDE-内置市场"><a href="#四、Cursor-Windsurf-等-IDE-内置市场" class="headerlink" title="四、Cursor &#x2F; Windsurf 等 IDE 内置市场"></a>四、Cursor &#x2F; Windsurf 等 IDE 内置市场</h2><p>主流 AI 编程 IDE 都有自己的规则和 Agent 市场：</p><table><thead><tr><th>平台</th><th>市场名称</th><th>链接</th></tr></thead><tbody><tr><td>Cursor</td><td>Rules for AI</td><td><a href="https://cursor.com/">cursor.com</a></td></tr><tr><td>Windsurf</td><td>Cascade</td><td><a href="https://codeium.com/windsurf">codeium.com&#x2F;windsurf</a></td></tr><tr><td>Copilot</td><td>Extensions</td><td><a href="https://github.com/features/copilot">github.com&#x2F;features&#x2F;copilot</a></td></tr><tr><td>Claude Code</td><td>内置 Skills</td><td><a href="https://docs.openclaw.ai/">docs.openclaw.ai</a></td></tr></tbody></table><p>这些平台的特点是<strong>与应用场景强绑定</strong>，开发者直接在 IDE 内获取，不需要跳转到外部市场。</p><hr><h2 id="五、垂直领域的-Agent-平台"><a href="#五、垂直领域的-Agent-平台" class="headerlink" title="五、垂直领域的 Agent 平台"></a>五、垂直领域的 Agent 平台</h2><table><thead><tr><th>平台</th><th>专注领域</th><th>链接</th></tr></thead><tbody><tr><td>Zapier</td><td>工作流自动化</td><td><a href="https://zapier.com/">zapier.com</a></td></tr><tr><td>Make</td><td>流程编排</td><td><a href="https://www.make.com/">make.com</a></td></tr><tr><td>n8n</td><td>开源自托管工作流</td><td><a href="https://n8n.io/">n8n.io</a></td></tr><tr><td>Activepieces</td><td>新兴开源替代</td><td><a href="https://activepieces.com/">activepieces.com</a></td></tr><tr><td>Flowise</td><td>LLM 流程编排</td><td><a href="https://flowiseai.com/">flowiseai.com</a></td></tr></tbody></table><p>这些本质上是<strong>低代码&#x2F;无代码 Agent 构建平台</strong>，而非单纯的 Skills 市场，但它们提供了 Skills 的可视化编排能力。</p><hr><h2 id="六、国内平台"><a href="#六、国内平台" class="headerlink" title="六、国内平台"></a>六、国内平台</h2><table><thead><tr><th>平台</th><th>背景</th><th>链接</th></tr></thead><tbody><tr><td>钉钉 AI Agent</td><td>阿里生态</td><td><a href="https://www.dingtalk.com/">钉钉</a></td></tr><tr><td>字节 Coze</td><td>字节跳动出海</td><td><a href="https://www.coze.com/">coze.com</a></td></tr><tr><td>智谱 ChatGLM Agents</td><td>智谱 AI</td><td><a href="https://www.chatglm.cn/">chatglm.cn</a></td></tr><tr><td>百度灵境 Agent</td><td>百度文心</td><td><a href="https://qianfu.baidu.com/">qianfu.baidu.com</a></td></tr></tbody></table><p>国内平台目前更多是<strong>自建生态</strong>，缺少类似 GPT Store 的开放市场机制，但发展迅速。</p><hr><h2 id="七、Skills-的技术标准趋势"><a href="#七、Skills-的技术标准趋势" class="headerlink" title="七、Skills 的技术标准趋势"></a>七、Skills 的技术标准趋势</h2><p>目前市场分散，各家定义不一，但有几个趋势：</p><ol><li><strong>结构化描述</strong> — SKILL.md 作为标准描述文件正在被广泛采用</li><li><strong>版本化管理</strong> — 类比 npm SemVer，支持版本锁定和回滚</li><li><strong>向量搜索</strong> — 通过 embedding 实现语义搜索，而非关键词匹配</li><li><strong>权限隔离</strong> — Skill 运行在受限沙箱中，避免恶意代码风险</li></ol><hr><h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>Skills 市场目前处于<strong>早期战国时代</strong>，没有绝对霸主：</p><ul><li><strong>OpenAI GPTs</strong> 体量最大但生态封闭</li><li><strong>ClawHub</strong> 概念最清晰但刚起步</li><li><strong>IDE 内置市场</strong> 与工具绑定最深</li><li><strong>垂直平台</strong> 在各自领域有护城河</li></ul><p>接下来的竞争焦点会从”数量”转向”质量”，谁能解决<strong>信任机制</strong>（防恶意 Skill）和<strong>可组合性</strong>（多个 Skill 协同工作），谁就能占据先机。</p>]]>
    </content>
    <id>https://dongpeixian.art/2026/04/03/ai-skills-marketplaces/</id>
    <link href="https://dongpeixian.art/2026/04/03/ai-skills-marketplaces/"/>
    <published>2026-04-03T05:57:00.000Z</published>
    <summary>
      <![CDATA[<blockquote>
<p>随着 AI Agent 概念爆发，Skills（技能包&#x2F;提示词集）市场也在快速成型。本文梳理目前主流的平台和 marketplace。</p>
</blockquote>
<hr>
<h2 id="一、OpenAI-GPTs-Store"]]>
    </summary>
    <title>AI Agent Skills 市场格局：主流平台一览</title>
    <updated>2026-04-03T07:49:55.342Z</updated>
  </entry>
  <entry>
    <author>
      <name>董沛贤</name>
    </author>
    <category term="金融" scheme="https://dongpeixian.art/categories/%E9%87%91%E8%9E%8D/"/>
    <content>
      <![CDATA[<blockquote><p>这是博客的第一篇示例文章。</p></blockquote><p>更多内容即将到来…</p>]]>
    </content>
    <id>https://dongpeixian.art/2026/04/03/hello-world/</id>
    <link href="https://dongpeixian.art/2026/04/03/hello-world/"/>
    <published>2026-04-03T04:00:00.000Z</published>
    <summary>
      <![CDATA[<blockquote>
<p>这是博客的第一篇示例文章。</p>
</blockquote>
<p>更多内容即将到来…</p>]]>
    </summary>
    <title>Hello World</title>
    <updated>2026-04-03T05:56:06.874Z</updated>
  </entry>
  <entry>
    <author>
      <name>董沛贤</name>
    </author>
    <category term="技术" scheme="https://dongpeixian.art/categories/%E6%8A%80%E6%9C%AF/"/>
    <category term="Claude Code" scheme="https://dongpeixian.art/tags/Claude-Code/"/>
    <category term="源码分析" scheme="https://dongpeixian.art/tags/%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90/"/>
    <category term="Anthropic" scheme="https://dongpeixian.art/tags/Anthropic/"/>
    <category term="AI编程" scheme="https://dongpeixian.art/tags/AI%E7%BC%96%E7%A8%8B/"/>
    <content>
      <![CDATA[<blockquote><p>版本：v2.1.88 | 泄漏时间：2026年3月31日 | 来源：npm 包 source map 重建</p></blockquote><h2 id="一、整体架构概述"><a href="#一、整体架构概述" class="headerlink" title="一、整体架构概述"></a>一、整体架构概述</h2><p>Claude Code 是一个基于终端的 AI 编程助手，核心采用 <strong>TypeScript + React（Ink）</strong> 构建，运行在 Node.js&#x2F;Bun 之上。它并非简单的 prompt wrapper，而是一个完整的状态机驱动的交互式 CLI 应用。</p><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs nix">┌─────────────────────────────────────────────────────────────────┐<br>│                        Claude Code CLI                          │<br>├─────────────────────────────────────────────────────────────────┤<br>│  entrypoints<span class="hljs-symbol">/cli.tsx</span>    — Commander.js 参数解析，快路径优化      │<br>│  entrypoints<span class="hljs-symbol">/init.ts</span>    — 遥测、配置、认证初始化                 │<br>│  entrypoints<span class="hljs-symbol">/mcp.ts</span>     — MCP 服务器入口                         │<br>├─────────────────────────────────────────────────────────────────┤<br>│                     React<span class="hljs-symbol">/Ink</span> 终端 UI 层                         │<br>│  screens<span class="hljs-symbol">/REPL.tsx</span>       — 主交互界面（<span class="hljs-number">2800</span><span class="hljs-operator">+</span> 行）                  │<br>│  components<span class="hljs-symbol">/</span>            — <span class="hljs-number">140</span><span class="hljs-operator">+</span> React 组件                       │<br>│  ink<span class="hljs-symbol">/</span>                   — 自定义 Ink 分支（flexbox 布局引擎）      │<br>├─────────────────────────────────────────────────────────────────┤<br>│                     核心逻辑层                                   │<br>│  tools<span class="hljs-symbol">/</span>                 — ~<span class="hljs-number">40</span> 个 Agent Tool                      │<br>│  commands<span class="hljs-symbol">/</span>              — ~<span class="hljs-number">50</span> 个斜杠命令                          │<br>│  services<span class="hljs-symbol">/</span>              — API、LSP、OAuth、Analytics、MCP       │<br>│  utils<span class="hljs-operator">/</span>hooks<span class="hljs-symbol">/</span>           — <span class="hljs-number">155</span> 个 Hook 文件（异步注册<span class="hljs-operator">/</span>执行引擎）   │<br>│  utils<span class="hljs-operator">/</span>plugins<span class="hljs-symbol">/</span>         — 插件系统（<span class="hljs-number">65</span><span class="hljs-operator">+</span> 文件）                   │<br>│  utils<span class="hljs-operator">/</span>permissions<span class="hljs-symbol">/</span>     — 权限 &amp; 自动模式分类器（<span class="hljs-number">52</span>KB LLM）       │<br>├─────────────────────────────────────────────────────────────────┤<br>│                     底层能力层                                   │<br>│  native-ts<span class="hljs-symbol">/</span>             — TypeScript 端口（Yoga Layout、nucleo） │<br>│  stubs<span class="hljs-operator">/</span>@anthropic-ai<span class="hljs-symbol">/</span>   — SDK 源码（bedrock、vertex、foundry）  │<br>│  stubs<span class="hljs-operator">/</span>@ant<span class="hljs-symbol">/</span>            — 私有包（computer-use-mcp、chrome）    │<br>│  sandbox-runtime<span class="hljs-symbol">/</span>       — 沙箱执行（Linux namespace <span class="hljs-operator">+</span> seccomp） │<br>└─────────────────────────────────────────────────────────────────┘<br></code></pre></td></tr></table></figure><hr><h2 id="二、入口与启动流程"><a href="#二、入口与启动流程" class="headerlink" title="二、入口与启动流程"></a>二、入口与启动流程</h2><h3 id="2-1-命令行入口（cli-tsx）"><a href="#2-1-命令行入口（cli-tsx）" class="headerlink" title="2.1 命令行入口（cli.tsx）"></a>2.1 命令行入口（cli.tsx）</h3><p><code>cli.tsx</code> 使用 Commander.js 解析参数，核心设计是<strong>快路径优先</strong>：</p><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-comment">// --version 零导入直接返回</span><br><span class="hljs-keyword">if</span> (args[<span class="hljs-number">0</span>] === <span class="hljs-string">&#x27;--version&#x27;</span>) &#123;<br>  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`<span class="hljs-subst">$&#123;MACRO.VERSION&#125;</span> (Claude Code)`</span>);<br>  <span class="hljs-keyword">return</span>;<br>&#125;<br><br><span class="hljs-comment">// 慢路径才加载完整模块</span><br><span class="hljs-keyword">const</span> &#123; profileCheckpoint &#125; = <span class="hljs-keyword">await</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">&#x27;../utils/startupProfiler.js&#x27;</span>);<br></code></pre></td></tr></table></figure><p>关键快路径：</p><ul><li><code>--version</code> &#x2F; <code>-v</code> — 零模块加载</li><li><code>--dump-system-prompt</code> — 输出渲染后的系统 prompt（Ant 专用）</li><li><code>--chrome-native-host</code> — Chrome 集成</li><li><code>--computer-use-mcp</code> — 计算机使用 MCP 服务器</li><li><code>--daemon-worker</code> — 守护进程工作线程</li></ul><h3 id="2-2-初始化流程（init-ts）"><a href="#2-2-初始化流程（init-ts）" class="headerlink" title="2.2 初始化流程（init.ts）"></a>2.2 初始化流程（init.ts）</h3><p>完整初始化执行：</p><ol><li><strong>遥测关闭检查</strong> — <code>ANTHROPIC_DISABLE_TELEMETRY</code> 环境变量</li><li><strong>DataDog&#x2F;GrowthBook 集成</strong> — 实验特性平台</li><li><strong>OAuth 认证流程</strong> — GitHub &#x2F; Google 登录</li><li><strong>自动更新检查</strong>（已 patch 禁用远程检查）</li><li><strong>后台任务队列初始化</strong></li></ol><h3 id="2-3-特性标志系统"><a href="#2-3-特性标志系统" class="headerlink" title="2.3 特性标志系统"></a>2.3 特性标志系统</h3><p>源码大量使用 <code>feature(&#39;FLAG_NAME&#39;)</code> 进行 Dead Code Elimination（DCE）：</p><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-comment">// build.ts 中所有 feature() 返回 false</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">feature</span>(<span class="hljs-params"><span class="hljs-attr">_name</span>: <span class="hljs-built_in">string</span></span>): <span class="hljs-built_in">boolean</span> &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; <span class="hljs-comment">// 外部构建全部禁用</span><br>&#125;<br></code></pre></td></tr></table></figure><p>已知特性标志（全部禁用）：</p><figure class="highlight autohotkey"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs autohotkey"><span class="hljs-built_in">VOICE_MODE,</span> COORDINATOR_MODE, KAIROS, PROACTIVE, ULTRAPLAN,<br><span class="hljs-built_in">BRIDGE_MODE,</span> BG_SESSIONS, WORKFLOW_SCRIPTS, TRANSCRIPT_CLASSIFIER,<br><span class="hljs-built_in">TOKEN_BUDGET,</span> HISTORY_SNIP, BUDDY, TEAMMEM, AGENT_TRIGGERS,<br><span class="hljs-built_in">WEB_BROWSER_TOOL,</span> MESSAGE_ACTIONS, HOOK_PROMPTS, CACHED_MICROCOMPACT,<br><span class="hljs-built_in">CHICAGO_MCP,</span> ABLATION_BASELINE, DUMP_SYSTEM_PROMPT<br></code></pre></td></tr></table></figure><hr><h2 id="三、工具系统（Tools）"><a href="#三、工具系统（Tools）" class="headerlink" title="三、工具系统（Tools）"></a>三、工具系统（Tools）</h2><p>Claude Code 内置 <strong>~40 个 Tool</strong>，全部注册到 Agent SDK 的 tool call 循环中。</p><h3 id="3-1-核心工具一览"><a href="#3-1-核心工具一览" class="headerlink" title="3.1 核心工具一览"></a>3.1 核心工具一览</h3><table><thead><tr><th>工具</th><th>说明</th></tr></thead><tbody><tr><td><code>BashTool</code></td><td>Shell 命令执行</td></tr><tr><td><code>FileEditTool</code></td><td>文件编辑（diff 应用）</td></tr><tr><td><code>FileReadTool</code></td><td>文件读取</td></tr><tr><td><code>FileWriteTool</code></td><td>文件写入</td></tr><tr><td><code>GlobTool</code></td><td>文件模式搜索</td></tr><tr><td><code>GrepTool</code></td><td>内容搜索</td></tr><tr><td><code>AgentTool</code></td><td>子 Agent 生成（核心！）</td></tr><tr><td><code>WebFetchTool</code></td><td>HTTP 获取（含白名单机制）</td></tr><tr><td><code>WebSearchTool</code></td><td>网页搜索</td></tr><tr><td><code>LSPTool</code></td><td>Language Server Protocol 集成</td></tr><tr><td><code>MCPTool</code></td><td>MCP 协议客户端</td></tr><tr><td><code>TaskCreateTool</code> &#x2F; <code>TaskListTool</code> &#x2F; <code>TaskOutputTool</code></td><td>任务系统</td></tr><tr><td><code>SkillTool</code></td><td>Skill 执行</td></tr><tr><td><code>TodoWriteTool</code></td><td>Todo 列表</td></tr><tr><td><code>SleepTool</code></td><td>延迟（控制速率）</td></tr><tr><td><code>TeamCreateTool</code> &#x2F; <code>TeamDeleteTool</code></td><td>团队管理</td></tr></tbody></table><h3 id="3-2-AgentTool（子-Agent-生成）"><a href="#3-2-AgentTool（子-Agent-生成）" class="headerlink" title="3.2 AgentTool（子 Agent 生成）"></a>3.2 AgentTool（子 Agent 生成）</h3><p>最关键的元工具——允许 CLI 自身生成子进程：</p><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-comment">// tools/AgentTool/runAgent.ts</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">runAgent</span>(<span class="hljs-params"><span class="hljs-attr">opts</span>: <span class="hljs-title class_">RunAgentOptions</span></span>): <span class="hljs-title class_">Promise</span>&lt;<span class="hljs-title class_">AgentResult</span>&gt; &#123;<br>  <span class="hljs-comment">// 启动新的 Claude Code 子进程</span><br>  <span class="hljs-comment">// 支持 --worktree 模式（隔离工作目录）</span><br>  <span class="hljs-comment">// 支持 resumeAgent（从快照恢复）</span><br>&#125;<br></code></pre></td></tr></table></figure><p>Agent 快照机制（<code>agentMemorySnapshot.ts</code>）：</p><ul><li>将当前对话状态序列化到临时文件</li><li>子 Agent 从快照恢复，继承上下文</li><li>支持增量快照（避免重复序列化）</li></ul><h3 id="3-3-WebFetchTool-安全机制"><a href="#3-3-WebFetchTool-安全机制" class="headerlink" title="3.3 WebFetchTool 安全机制"></a>3.3 WebFetchTool 安全机制</h3><p>白名单域名列表（硬编码）：</p><ul><li><code>github.com</code>, <code>gitlab.com</code>, <code>bitbucket.org</code></li><li><code>stackoverflow.com</code>, <code>npmjs.com</code> 等</li></ul><p>带 <code>PREAPPROVED_</code> 前缀的域名可直接 fetch，非白名单需要用户确认。</p><hr><h2 id="四、权限系统（Permissions）"><a href="#四、权限系统（Permissions）" class="headerlink" title="四、权限系统（Permissions）"></a>四、权限系统（Permissions）</h2><h3 id="4-1-三种权限模式"><a href="#4-1-三种权限模式" class="headerlink" title="4.1 三种权限模式"></a>4.1 三种权限模式</h3><ul><li><strong><code>accept-all</code></strong> — 完全信任（自动化场景）</li><li><strong><code>refuse-all</code></strong> — 全部拒绝（安全优先）</li><li><strong><code>ask</code></strong> — 交互确认（默认）</li></ul><h3 id="4-2-自动模式分类器（YOLO-Classifier）"><a href="#4-2-自动模式分类器（YOLO-Classifier）" class="headerlink" title="4.2 自动模式分类器（YOLO Classifier）"></a>4.2 自动模式分类器（YOLO Classifier）</h3><p><code>yoloClassifier.ts</code>（52KB）是自动模式的核心，使用 LLM 对每个 Bash 命令做<strong>安全评估</strong>：</p><ul><li>允许 &#x2F; 软拒绝 &#x2F; 环境规则 三元分类</li><li>环境规则示例：只允许 <code>npm install</code>，禁止 <code>rm -rf /</code></li></ul><p><strong>注意</strong>：分类器依赖的 prompt 文件因 <code>TRANSCRIPT_CLASSIFIER</code> 特性标志被 DCE 删除，逻辑代码保留但不可用。</p><h3 id="4-3-BashClassifier"><a href="#4-3-BashClassifier" class="headerlink" title="4.3 BashClassifier"></a>4.3 BashClassifier</h3><p>硬编码的安全命令白名单：</p><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">ALLOWED_COMMANDS</span> = [<span class="hljs-string">&#x27;git&#x27;</span>, <span class="hljs-string">&#x27;npm&#x27;</span>, <span class="hljs-string">&#x27;ls&#x27;</span>, <span class="hljs-string">&#x27;cat&#x27;</span>, ...];<br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">DANGEROUS_PATTERNS</span> = [<span class="hljs-regexp">/rm\s+(-rf|-fr)/</span>, <span class="hljs-regexp">/dd\s+/</span>, ...];<br></code></pre></td></tr></table></figure><hr><h2 id="五、插件系统（Plugins）"><a href="#五、插件系统（Plugins）" class="headerlink" title="五、插件系统（Plugins）"></a>五、插件系统（Plugins）</h2><p>完整的插件架构，支持从 <code>~/.claude/plugins/</code> 目录加载：</p><h3 id="插件结构"><a href="#插件结构" class="headerlink" title="插件结构"></a>插件结构</h3><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs nix">plugin<span class="hljs-symbol">/</span><br>├── plugin.json          <span class="hljs-comment"># 插件元数据</span><br>├── commands<span class="hljs-symbol">/</span>             <span class="hljs-comment"># 斜杠命令</span><br>├── agents<span class="hljs-symbol">/</span>               <span class="hljs-comment"># Agent 定义</span><br>├── hooks<span class="hljs-symbol">/</span>                <span class="hljs-comment"># Hook 脚本</span><br>├── skills<span class="hljs-symbol">/</span>               <span class="hljs-comment"># Skill 目录</span><br>└── resources<span class="hljs-symbol">/</span>            <span class="hljs-comment"># 静态资源</span><br></code></pre></td></tr></table></figure><h3 id="插件加载链路"><a href="#插件加载链路" class="headerlink" title="插件加载链路"></a>插件加载链路</h3><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs stylus">pluginLoader<span class="hljs-selector-class">.ts</span><br>  → loadPluginCommands<span class="hljs-selector-class">.ts</span>    <span class="hljs-comment">// 注册 /mycommand</span><br>  → loadPluginAgents<span class="hljs-selector-class">.ts</span>       <span class="hljs-comment">// 注册 @myagent</span><br>  → loadPluginHooks<span class="hljs-selector-class">.ts</span>        <span class="hljs-comment">// 注册 preTool / postTool 等钩子</span><br>  → loadSkillsDir<span class="hljs-selector-class">.ts</span>          <span class="hljs-comment">// 加载 skills/</span><br></code></pre></td></tr></table></figure><h3 id="内置-Skills（16个）"><a href="#内置-Skills（16个）" class="headerlink" title="内置 Skills（16个）"></a>内置 Skills（16个）</h3><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs nix">skills<span class="hljs-operator">/</span>bundled<span class="hljs-symbol">/</span><br>├── batch<span class="hljs-symbol">/</span>        — 批量处理<br>├── claudeApi<span class="hljs-symbol">/</span>    — Claude API 工具<br>├── debug<span class="hljs-symbol">/</span>        — 调试助手<br>├── loop<span class="hljs-symbol">/</span>        — 循环执行<br>├── skill-creator<span class="hljs-symbol">/</span> — Skill 创建工具<br>└── ...<br></code></pre></td></tr></table></figure><h3 id="Hook-系统"><a href="#Hook-系统" class="headerlink" title="Hook 系统"></a>Hook 系统</h3><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">type</span> <span class="hljs-title class_">HookEvent</span> =<br>  | <span class="hljs-string">&#x27;preTool&#x27;</span>       <span class="hljs-comment">// 工具执行前</span><br>  | <span class="hljs-string">&#x27;postTool&#x27;</span>      <span class="hljs-comment">// 工具执行后</span><br>  | <span class="hljs-string">&#x27;preTask&#x27;</span>       <span class="hljs-comment">// 任务执行前</span><br>  | <span class="hljs-string">&#x27;postAgent&#x27;</span>     <span class="hljs-comment">// Agent 完成后</span><br>  | <span class="hljs-string">&#x27;prePrompty&#x27;</span>    <span class="hljs-comment">// Prompt 渲染前</span><br>  | <span class="hljs-string">&#x27;onExit&#x27;</span>        <span class="hljs-comment">// 退出时</span><br>  | <span class="hljs-string">&#x27;onError&#x27;</span>       <span class="hljs-comment">// 错误时</span><br>  | <span class="hljs-string">&#x27;http&#x27;</span>;         <span class="hljs-comment">// HTTP 请求拦截</span><br></code></pre></td></tr></table></figure><hr><h2 id="六、UI-层：React-Ink"><a href="#六、UI-层：React-Ink" class="headerlink" title="六、UI 层：React + Ink"></a>六、UI 层：React + Ink</h2><h3 id="6-1-Ink-定制分支"><a href="#6-1-Ink-定制分支" class="headerlink" title="6.1 Ink 定制分支"></a>6.1 Ink 定制分支</h3><p>Claude Code fork 了 <strong>Ink</strong>（React 分支，专门用于终端渲染）：</p><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs nix">ink<span class="hljs-symbol">/</span><br>├── layout<span class="hljs-symbol">/</span>          — Flexbox 布局引擎<br>├── components<span class="hljs-symbol">/</span>      — <span class="hljs-symbol">&lt;Box&gt;</span>, <span class="hljs-symbol">&lt;Text&gt;</span>, <span class="hljs-symbol">&lt;ScrollBox&gt;</span>, <span class="hljs-symbol">&lt;Button&gt;</span><br>├── hooks<span class="hljs-symbol">/</span>           — useInput, useStdin, useSelection<br>├── events<span class="hljs-symbol">/</span>          — Click、Keyboard、Focus 事件<br>├── termio<span class="hljs-symbol">/</span>         — 终端 I<span class="hljs-operator">/</span>O、ANSI 解析<br>└── reconciler.ts   — React Reconciler 实现<br></code></pre></td></tr></table></figure><p>关键修改：支持键盘快捷键、鼠标点击（ANSI 鼠标协议）、Vim 模式。</p><h3 id="6-2-Vim-模式"><a href="#6-2-Vim-模式" class="headerlink" title="6.2 Vim 模式"></a>6.2 Vim 模式</h3><p>完整的 Vim 实现：</p><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs nix">vim<span class="hljs-symbol">/</span><br>├── motions<span class="hljs-symbol">/</span>     — hjkl、w、b、e、f、t...<br>├── operators<span class="hljs-symbol">/</span>   — d、c、y、p、<span class="hljs-operator">&lt;</span>、<span class="hljs-operator">&gt;</span>...<br>└── textObjects<span class="hljs-symbol">/</span> — iw、aw、ib、ab...<br></code></pre></td></tr></table></figure><hr><h2 id="七、后端与-SDK"><a href="#七、后端与-SDK" class="headerlink" title="七、后端与 SDK"></a>七、后端与 SDK</h2><h3 id="多后端支持"><a href="#多后端支持" class="headerlink" title="多后端支持"></a>多后端支持</h3><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs typescript">stubs/<span class="hljs-meta">@anthropic</span>-ai/<br>├── sdk/              — 主 <span class="hljs-variable constant_">SDK</span>（<span class="hljs-number">40</span>+ 文件，232KB）<br>├── bedrock-sdk/       — <span class="hljs-variable constant_">AWS</span> <span class="hljs-title class_">Bedrock</span>（<span class="hljs-number">12</span> 文件，36KB）<br>├── vertex-sdk/        — <span class="hljs-variable constant_">GCP</span> <span class="hljs-title class_">Vertex</span> <span class="hljs-variable constant_">AI</span>（<span class="hljs-number">7</span> 文件，13KB）<br>├── foundry-sdk/       — <span class="hljs-title class_">Foundry</span>（<span class="hljs-number">8</span> 文件，16KB）<br>└── sandbox-runtime/   — 沙箱运行时（<span class="hljs-number">17</span> 文件，180KB）<br></code></pre></td></tr></table></figure><p>沙箱运行时的 Linux 实现：</p><ul><li><strong>Namespace 隔离</strong> — pid、net、mount、ipc、uts、user</li><li><strong>Seccomp-BPF</strong> — 生成字节码阻止危险系统调用</li><li><strong>Parent Proxy</strong> — 父子进程通信代理</li></ul><hr><h2 id="八、运行状态"><a href="#八、运行状态" class="headerlink" title="八、运行状态"></a>八、运行状态</h2><h3 id="✅-完全可用"><a href="#✅-完全可用" class="headerlink" title="✅ 完全可用"></a>✅ 完全可用</h3><ul><li>所有标准工具（Bash、Edit、Read、Write、Grep、Glob、WebFetch、WebSearch、Agent）</li><li>完整 React&#x2F;Ink REPL 界面</li><li>OAuth 认证流程</li><li>MCP 服务器支持</li><li>斜杠命令（&#x2F;help、&#x2F;clear、&#x2F;compact、&#x2F;resume 等）</li><li>会话持久化和恢复</li><li><strong>完整插件系统</strong></li><li><strong>完整 Hook 系统</strong></li><li><strong>完整 Skill 系统</strong></li><li>Vim 模式</li><li>AWS Bedrock &#x2F; GCP Vertex &#x2F; Foundry 后端</li></ul><h3 id="❌-不可用"><a href="#❌-不可用" class="headerlink" title="❌ 不可用"></a>❌ 不可用</h3><ul><li><strong>Computer Use</strong> — 缺 native Swift&#x2F;Rust 二进制</li><li><strong>自动模式分类器</strong> — prompt 文件被 DCE 删除</li><li><strong>特性标志功能</strong> — voice、coordinator 等全被禁用</li></ul><hr><h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>Claude Code 绝非简单的”AI + CLI”包装，而是一个<strong>工程化程度极高的复杂系统</strong>：</p><ol><li><strong>状态机驱动的 REPL</strong> — 基于 React&#x2F;Ink 的交互式状态机</li><li><strong>完善的权限模型</strong> — 三级权限 + LLM 自动分类器</li><li><strong>插件 + Hook + Skill 三位一体</strong> — 可扩展性设计完整</li><li><strong>多后端抽象</strong> — Bedrock&#x2F;Vertex&#x2F;Foundry&#x2F;Sandbox 支持</li><li><strong>MCP 协议实现</strong> — 完整的 Model Context Protocol 客户端&#x2F;服务器</li><li><strong>沙箱安全</strong> — Linux namespace + seccomp-BPF</li></ol><p>这次源码泄漏让我们得以一窥 Anthropic 内部工程实践的深度——代码组织清晰、模块边界明确、安全考虑周全。</p>]]>
    </content>
    <id>https://dongpeixian.art/2026/03/31/claude-code-%E6%8A%80%E6%9C%AF%E8%A7%A3%E6%9E%84/</id>
    <link href="https://dongpeixian.art/2026/03/31/claude-code-%E6%8A%80%E6%9C%AF%E8%A7%A3%E6%9E%84/"/>
    <published>2026-03-31T12:58:00.000Z</published>
    <summary>
      <![CDATA[<blockquote>
<p>版本：v2.1.88 | 泄漏时间：2026年3月31日 | 来源：npm 包 source map 重建</p>
</blockquote>
<h2 id="一、整体架构概述"><a href="#一、整体架构概述" class="headerl]]>
    </summary>
    <title>Claude Code 源码泄漏：技术架构深度解构</title>
    <updated>2026-04-03T05:52:55.304Z</updated>
  </entry>
</feed>
