markstream-custom-components – skill Lập trình cho agent AI
Ghi đè node renderer của Markstream và thêm thẻ tùy chỉnh đáng tin cậy trên Vue, React, Svelte và Angular bằng ánh xạ có phạm vi (scoped) hoặc cục bộ theo renderer.
Cài skill markstream-custom-components bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/markstream-custom-components-467be.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /markstream-custom-components – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/markstream-custom-components-467be.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $markstream-custom-components – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/markstream-custom-components-467be.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /markstream-custom-components – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/markstream-custom-components-467be.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /markstream-custom-components – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Markstream Custom Components
Overview
Customize specific Markstream nodes or trusted custom tags without replacing the parser or leaking global renderer state. Read [references/patterns.md](references/patterns.md) first.
When to Use
Use to replace built-ins such as image, link, code_block, mermaid, or inline_code; render trusted tags such as thinking; or scope overrides to one renderer or app. Use parser transforms only when token or AST reshaping is required.
Workflow
Before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval.
1. Classify the change as a built-in override, trusted tag, or parser transform.
2. Prefer scoped mappings. Vue, Vue 2, Svelte, and Angular can use setCustomComponents(customId, mapping); Svelte and Angular can also pass renderer-local maps.
3. In React, prefer streamingComponents for parser-backed nodes and htmlComponents for sanitized attributes plus children.
4. Start with leaf nodes before containers that must preserve children.
5. For trusted tag bodies containing Markdown, use a nested renderer with the same allowlist. Do not add a second smooth-streaming loop.
6. Preserve node/loading props, identity keys, scope IDs, theme state, and preview-height estimates for async diagrams.
7. Remove temporary scoped registrations on cleanup and validate repeated and nested tags.
Example
import MarkdownRender, {
type NodeComponentProps,
setCustomComponents,
} from 'markstream-react'
import 'markstream-react/index.css'
function ThinkingNode({ node }: NodeComponentProps<any>) {
return <details><summary>Thinking</summary>{node.content}</details>
}
setCustomComponents('assistant-panel', { thinking: ThinkingNode })
export function Answer({ markdown }: { markdown: string }) {
return (
<MarkdownRender
content={markdown}
customId="assistant-panel"
customHtmlTags={['thinking']}
htmlPolicy="safe"
/>
)
}Limitations
- Component overrides cannot reproduce arbitrary remark/rehype transforms.
- Container overrides require careful child rendering and accessibility review.
- Framework registration APIs are not interchangeable.
Security & Safety Notes
Treat custom HTML-like tags as trusted input only. Keep safe HTML enabled and do not pass unsanitized attributes into host components.
Skill liên quan
- markstream-react – Tích hợp renderer markstream-react (beta) vào React 18+ hoặc Next.js với entrypoint…
- markstream-vue – Tích hợp markstream-vue vào Vue 3 thuần với các chế độ renderer, lựa chọn code và DOM…
- markstream-vue2-cli – Tích hợp markstream-vue2 vào Vue CLI hoặc Webpack 4 với CSS tương thích export-map, dự…
- mason – Tạo mã sạch, hoạt động đúng, khớp với kiến trúc và danh sách kiểm tra.
- matematico-tao – Phân tích độ phức tạp của mã, đồ thị phụ thuộc, đồng thời và bất biến dựa trên các giả…
- matplotlib – Matplotlib là thư viện trực quan hóa nền tảng của Python, dùng để tạo biểu đồ tĩnh, động…
- mcp-tool-developer – Xây dựng máy chủ và công cụ Model Context Protocol (MCP) từ đầu. Phát triển MCP toàn…
- mmx-cli – Dùng mmx để tạo văn bản, ảnh, video, giọng nói và nhạc qua nền tảng AI MiniMax. Dùng khi…