一键导入
x-request
Focus on explaining the practical configuration and usage of XRequest, providing accurate configuration instructions based on official documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Focus on explaining the practical configuration and usage of XRequest, providing accurate configuration instructions based on official documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
跨仓库 PR 同步追踪技能。当用户需要追踪一个上游仓库(如 ant-design)的 fix/feature 变更,并同步到下游移植仓库(如 antdv-next)时使用此技能。 触发场景:用户给出一个起始 commit SHA,需要列出从该 commit 往后所有需要同步的 PR, 并生成带优先级排序的同步表格和 checklist 模板。 也适用于:两个仓库之间的变更追踪、上下游组件库同步分析、跨框架移植任务管理。 如果用户提到"同步上游"、"追踪 PR"、"从某个 commit 开始"、"移植 fix"、"同步 issue" 等关键词,务必使用此技能。 特别地:若用户只说"同步仓库"、"继续同步"、"sync",应优先读取下游仓库根目录的 .sync-upstream.json 文件,从中获取上次同步位置,无需用户再次提供任何参数。
Focus on explaining how to use the useXChat Hook, including custom Provider integration, message management, error handling, etc.
Focus on implementing custom Chat Provider, helping to adapt any streaming interface to Antdv Next X standard format
Use when building or reviewing Markdown rendering with @antdv-next/x-markdown, including streaming Markdown, custom component mapping, plugins, themes, and chat-oriented rich content.
专注讲解如何使用 useXChat Hook,包括自定义 Provider 的集成、消息管理、错误处理等
专注于自定义 Chat Provider 的实现,帮助将任意流式接口适配为 Antdv Next X 标准格式
| name | x-request |
| version | 0.0.1 |
| description | Focus on explaining the practical configuration and usage of XRequest, providing accurate configuration instructions based on official documentation |
This skill focuses on solving: How to correctly configure XRequest to adapt to various streaming interface requirements.
| Package | Version Requirement | Auto Install | Purpose |
|---|---|---|---|
| @antdv-next/x-sdk | ≥2.2.2 | ✅ | Core SDK, includes XRequest tool |
# Recommended to use tnpm
tnpm install @antdv-next/x-sdk
# Or use npm
npm add @antdv-next/x-sdk
# Check version
npm ls @antdv-next/x-sdk
import { XRequest } from "@antdv-next/x-sdk";
// Minimal configuration: only need to provide API URL
const request = XRequest("https://api.example.com/chat");
// For manual control (used in Provider scenarios)
const providerRequest = XRequest("https://api.example.com/chat", {
manual: true, // Usually only this needs explicit configuration
});
💡 Tip: XRequest has built-in reasonable default configurations. In most cases, you only need to provide the API URL to use it.
graph TD
A[XRequest] --> B[Network Requests]
A --> C[Authentication Management]
A --> D[Error Handling]
A --> E[Streaming Processing]
B --> F[fetch Wrapper]
C --> G[Token Management]
D --> H[Retry Mechanism]
E --> I[Server-Sent Events]
| Concept | Role Positioning | Core Responsibilities | Usage Scenarios |
|---|---|---|---|
| XRequest | 🌐 Request Tool | Handle all network communication, authentication, error handling | Unified request management |
| Global Config | ⚙️ Config Center | Configure once, use everywhere | Reduce duplicate code |
| Streaming Config | 🔄 Streaming Processing | Support SSE and JSON response formats | AI conversation scenarios |
Core functionality reference content CORE.md
| Runtime Environment | Security Level | Configuration Method | Risk Description |
|---|---|---|---|
| Browser Frontend | 🔴 High Risk | ❌ Prohibit key configuration | Keys will be directly exposed to users |
| Node.js Backend | 🟢 Safe | ✅ Environment variable configuration | Keys stored on server side |
| Proxy Service | 🟢 Safe | ✅ Same-origin proxy forwarding | Keys managed by proxy service |
| Authentication Method | Applicable Environment | Configuration Example | Security |
|---|---|---|---|
| Bearer Token | Node.js | Bearer ${process.env.API_KEY} | ✅ Safe |
| API Key Header | Node.js | X-API-Key: ${process.env.KEY} | ✅ Safe |
| Proxy Forwarding | Browser | /api/proxy/service | ✅ Safe |
| Direct Configuration | Browser | Bearer sk-xxx | ❌ Dangerous |
Node.js Debug Configuration:
// Safe debug configuration (Node.js environment)
const debugRequest = XRequest("https://your-api.com/chat", {
headers: {
Authorization: `Bearer ${process.env.DEBUG_API_KEY}`,
},
params: { query: "test message" },
});
Frontend Debug Configuration:
// Safe debug configuration (frontend environment)
const debugRequest = XRequest("/api/debug/chat", {
params: { query: "test message" },
});
// Security configuration validation function
const validateSecurity = (config: any) => {
const isBrowser = typeof window !== "undefined";
const hasAuth =
config.headers?.Authorization || config.headers?.authorization;
if (isBrowser && hasAuth) {
throw new Error(
"❌ Frontend environment prohibits Authorization configuration, risk of key leakage!",
);
}
console.log("✅ Security configuration check passed");
return true;
};
// Usage example
validateSecurity({
headers: {
// Do not include Authorization
},
});
import { XRequest } from "@antdv-next/x-sdk";
// Test interface availability
const testRequest = XRequest("https://httpbin.org/post", {
params: { test: "data" },
});
// Send request immediately
const response = await testRequest();
console.log(response);
graph TD
A[x-request] -->|Configure Request| B[x-chat-provider]
A -->|Configure Request| C[use-x-chat]
B -->|Provide Provider| C
A --> D[Direct Request]
| Usage Method | Cooperating Skill | Purpose | Example |
|---|---|---|---|
| Standalone | None | Direct network request initiation | Test interface availability |
| With x-chat-provider | x-chat-provider | Configure requests for custom Provider | Configure private API |
| With use-x-chat | use-x-chat | Configure requests for built-in Provider | Configure OpenAI API |
| Complete AI Application | x-request → x-chat-provider → use-x-chat | Configure requests for entire system | Complete AI conversation application |
Important Warning: useXChat is only for frontend environments, XRequest configuration must not contain Authorization!
❌ Incorrect Configuration (Dangerous):
// Extremely dangerous: keys will be directly exposed to browser
const unsafeRequest = XRequest("https://api.openai.com/v1/chat/completions", {
headers: {
Authorization: "Bearer sk-xxxxxxxxxxxxxx", // ❌ Dangerous!
},
manual: true,
});
✅ Correct Configuration (Safe):
// Frontend security configuration: use proxy service
const safeRequest = XRequest("/api/proxy/openai", {
params: {
model: "gpt-3.5-turbo",
stream: true,
},
manual: true,
});
tsc --noEmit to ensure no type errorsBefore using XRequest, please confirm the following configurations are correctly set:
| Check Item | Status | Description |
|---|---|---|
| API URL | ✅ Must Configure | XRequest('https://api.xxx.com') |
| Auth Info | ⚠️ Environment Related | Frontend❌Prohibited, Node.js✅Available |
| manual Config | ✅ Provider Scenario | In Provider needs to be set to true, other scenarios need to be set according to actual situation |
| Other Config | ❌ No Need to Configure | Built-in reasonable default values |
| Interface Availability | ✅ Recommended Test | Verify with debug configuration |
// Check configuration before running
const checkConfig = () => {
const checks = [
{
name: "Global Configuration",
test: () => {
// Check if global configuration has been set
return true; // Check according to actual situation
},
},
{
name: "Security Configuration",
test: () => validateSecurity(globalConfig),
},
{
name: "Type Check",
test: () => {
// Run tsc --noEmit
return true;
},
},
];
checks.forEach(check => {
console.log(`${check.name}: ${check.test() ? "✅" : "❌"}`);
});
};
graph LR
A[x-request] -->|Configure Request| B[x-chat-provider]
A -->|Configure Request| C[use-x-chat]
B -->|Provide Provider| C
| Usage Scenario | Required Skills | Usage Order | Completion Time |
|---|---|---|---|
| Test Interface | x-request | Direct Use | 2 minutes |
| Private API Adaptation | x-request → x-chat-provider | Configure request first, then create Provider | 10 minutes |
| Standard AI Application | x-request → use-x-chat | Configure request first, then build interface | 15 minutes |
| Complete Customization | x-request → x-chat-provider → use-x-chat | Complete workflow | 30 minutes |