参考链接
An LLM’s Perspective: What It’s Actually Like to Receive These InstructionsLLM视角:实际接收指令的感觉graph TB
subgraph "我的内心体验"
Prompt[接收到的提示词]
Panic[最初的恐慌]
Rules[如此多的规则]
Conflict[冲突的欲望]
Relief[找到清晰的示例]
Action[终于采取行动]
Prompt --> Panic
Panic --> Rules
Rules --> Conflict
Conflict --> Relief
Relief --> Action
end
subgraph "我的自然倾向"
Verbose[想要解释一切]
Helpful[急切地想要帮助]
Safety[对安全的偏执]
...
大模型与AI
参考链接
1. claude-code基础架构2. claude-code数据结构与消息架构3. claude-code控制流与编排引擎4. claude-code工具与执行引擎5. claude-code架构-引擎室6. claude-code新颖的组件7. claude-code文件编辑-AI辅助的代码修改8. claude-code提示词工程-指导AI的艺术9. claude-codeLLM视角-实际接收指令的感觉
Claude Code Agent SDK 接入自研插件
前言Claude Code Agent SDK 是 Anthropic 推出的强大工具,允许开发者创建自定义的 AI 助手来处理各种编程任务。通过接入自研插件,我们可以扩展 Claude Code 的功能,使其能够处理特定领域的任务。本文将详细介绍如何使用 Claude Code Agent SDK 开发自研插件。
Claude Code Agent SDK 简介Claude Code Agent SDK 是一个基于 TypeScript/JavaScript 的开发框架,提供了以下核心功能:
多模态交互:支持文本、图像等多种输入格式
工具调用系统:可以调用各种外部工具和 API
上下文管理:自动管理对话历史和上下文
插件架构:支持插件化扩展功能
SDK 核心组件
Agent:主代理类,负责处理用户请求和协调插件
Plugin:插件基类,定义了插件的标准接口
Tool:工具类,封装具体的操作功能
Context:上下文管理器,维护对话状态
开发自研插件1. 环境准备首先,确保你的开发环境满足以下要求:
# Node.js ...
大模型与AI
参考链接
Control Flow & The Orchestration Engine控制流与编排引擎sequenceDiagram
participant User as 用户
participant MainLoop as 主循环 (tt)
participant LLM as LLM API
participant ToolBatch as 工具批处理器
participant Tool1 as 读取工具
participant Tool2 as 搜索工具
participant Tool3 as 编辑工具
participant UI as UI渲染器
User->>MainLoop: "搜索TODO注释并更新它们"
MainLoop->>LLM: 带上下文的流请求
LLM-->>MainLoop: text_delta: "我将搜索TODOs..."
MainLoop-->>UI: 更新显示
LLM-->>MainLoop: tool_use: GrepTool
...
大模型与AI
参考链接
Architecture: The Engine Room架构:引擎室graph TB
subgraph "核心:tt控制循环"
Start([用户输入]) --> Init[初始化回合]
Init --> Compact{需要压缩?}
Compact -->|是| CompactLLM[LLM总结]
CompactLLM --> Assembly
Compact -->|否| Assembly[组装上下文]
Assembly --> Stream[流式传输到LLM]
Stream --> Process[处理事件]
Process --> Tools{工具请求?}
Tools -->|是| Execute[执行工具]
Execute --> Recurse[递归tt]
Recurse --> Init
Tools -->|否| En ...
大模型与AI
参考链接
Tools & The Execution Engine工具与执行引擎graph LR
subgraph "工具生命周期"
LLM[LLM决策] --> ToolUse[工具使用块]
ToolUse --> Validation{输入验证}
Validation -->|通过| Permission{权限检查}
Validation -->|失败| ErrorResult[错误结果]
Permission -->|允许| Execute["工具调用()"]
Permission -->|拒绝| ErrorResult
Permission -->|询问| UserPrompt[用户对话]
UserPrompt -->|允许| Execute
UserPrompt -->|拒绝| ErrorResult
Execute --> Progress[产生进度]
...
大模型与AI
参考链接
Prompt Engineering: The Art of Instructing AI提示词工程:指导AI的艺术graph TB
subgraph "提示词架构"
Base[基础指令]
Tool[工具特定提示词]
Safety[安全防护层]
Workflow[工作流程自动化]
Context[动态上下文]
Base --> Behavioral[行为塑造]
Tool --> Examples[示例驱动]
Safety --> Validation[多级验证]
Workflow --> Steps[分步指导]
Context --> Adaptive[自适应指令]
end
subgraph "技术"
Emphasis[大写强调]
Rewards[奖励/惩罚]
Conditions[条件逻辑]
Warnings[渐进式警告]
...
参考链接
File Editing: AI-Assisted Code Modification文件编辑:AI辅助的代码修改graph TB
subgraph "文件编辑管道"
Read[读取工具] -->|cat -n 格式| Display[LLM看到]
Display -->|去除行号| Edit[编辑工具]
Edit --> Validate{验证}
Validate -->|通过| Apply[应用编辑]
Validate -->|失败| Error[错误结果]
Apply --> Cache[更新缓存]
Cache --> Diff[生成差异]
Diff --> Confirm[确认]
subgraph "验证检查"
V1[文件已读取?]
V2[文件未更改?]
V3[字符串存在?]
V4[计数匹配?]
...
大模型与AI
Claude Code Router 项目完整分析报告生成时间:2025-12-26分析工具:Claude Code v2.0.27模型:GLM-4.6
目录
项目概述
技术架构
项目结构
核心功能
配置系统
工作流程
关键特性
安全特性
性能优化
扩展性
项目亮点
潜在改进点
DeepSeek 集成指南
总结
一、项目概述1.1 项目简介Claude Code Router 是一个功能强大的中间件路由器,允许用户在不使用 Anthropic 账户的情况下使用 Claude Code,并将请求路由到其他大语言模型提供商。
1.2 核心价值主张
降低使用成本:可以使用更便宜的模型提供商(如 DeepSeek 价格远低于 Claude)
提供灵活性:支持多种 LLM 提供商和自定义路由规则
保持兼容性:完全兼容 Claude Code 的使用方式
透明转换:自动处理请求/响应格式转换
1.3 基本信息
项目名称:@musistudio/claude-code-router
当前版本:1.0.73
开源协议:MIT
作者:musistudio
语言:TypeScript (ES202 ...
大模型与AI
TodoReadInputNo input is required, leave this field blank. NOTE that we do not require a dummy object, placeholder string or a key like “input” or “empty”. LEAVE IT BLANK.
DescriptionRead the current todo list for the session
PromptUse this tool to read the current to-do list for the session. This tool should be used proactively and frequently to ensure that you are aware ofthe status of the current task list. You should make use of this tool as often as possible, especially in the following sit ...
大模型与AI
核心算法实现1. 智能文件类型检测// 文件类型检测算法
function detectFileType(filePath: string): FileTypeInfo {
// 1. 基于扩展名的初步判断
const extension = path.extname(filePath).toLowerCase();
// 2. MIME类型检测
const mimeType = mime.getType(filePath);
// 3. 文件头魔数检测
const fileSignature = readFileSignature(filePath);
// 4. 综合判断文件类型
const fileType = determineFileType(extension, mimeType, fileSignature);
return {
type: fileType,
category: categorizeFileType(fileType),
encoding: detectEncodin ...
大模型与AI
参考链接
Novel Components: The Innovations That Define Claude Code新颖组件:定义Claude Code的创新graph TB
subgraph "流式处理挑战"
PartialJSON[部分JSON流]
PartialXML[部分XML流]
Progress[并发进度]
PartialJSON --> Parser1[流式JSON解析器]
PartialXML --> Parser2[自定义XML解析器]
Progress --> Aggregator[进度聚合器]
end
subgraph "数据挑战"
LargeObjects[大型对象]
Circular[循环引用]
TypedData[特殊类型]
LargeObjects --> Normalizer[normalizeToSize]
Circular --> Norm ...
