customizing-agent-native
它能做什么
这项技能规定在应用中自定义 Agent-Native 功能时应遵循的顺序。它先从品牌设置和受支持的组件选项入手,然后才将某项功能复制到应用中。适合希望拥有自己外观或行为的开发者。
适用场景
- ✓当你想更改共享功能的外观,使其符合你的品牌时。
- ✓当你需要用公司的设计系统替换共享组件的时候。
- ✓当共享功能必须在你的应用中表现出不同的行为,而设置又不足以实现的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/customizing-agent-native/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能把智能体聊天面板的外观改成符合我们的品牌颜色和按钮,同时不影响后续更新吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体先设置品牌标记并注册公司组件,然后使用该功能受支持的选项。只有在这些仍不足够时,它才会把最小的功能复制到应用中。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Customizing Agent-Native
Rule
Start with the app's registered design system and local UI adapters, then use
the public feature's props, semantic components, controller, product slots,
and callbacks. If those seams are not enough, use the eject CLI to transfer
the smallest supported feature into the app and make that copy app-owned.
Never edit node_modules, deep-import a private source file at runtime, or
patch an @agent-native/* package.
Use this order:
- Set brand tokens with the build-time theme configuration when tokens are enough.
- Register company components in
app/design-system.tswithdefineDesignSystem, then pass that definition toToolkitProvider. - Configure a public feature through its semantic components, headless controller, and product-level render slots.
- Compose app primitives behind the app's local UI adapter layer.
- Eject the smallest feature into app-owned source.
- Propose a new Toolkit seam when the same override is useful in two apps.
Ejection is for intentional product customization, not for hiding an upgrade failure or replacing Core runtime behavior.
Use A Company Design System
Keep the explicit, typed registration seam in app/design-system.ts:
import { defineDesignSystem } from "@agent-native/toolkit/design-system";
import {
AcmeActionButtonAdapter,
AcmeDialogAdapter,
} from "./design-system/acme-adapter";
export const designSystem = defineDesignSystem({
name: "Acme",
components: {
ActionButton: AcmeActionButtonAdapter,
Dialog: AcmeDialogAdapter,
},
});
Adapters translate the semantic Toolkit contract into company component props.
They are ordinary React components and may use MUI-style providers, React Aria,
CSS modules, CSS-in-JS, or another styling runtime. className and style are
optional interoperability hooks, not Tailwind or CVA requirements.
The contract has nine leaf components (ActionButton, IconButton,
TextField, TextArea, Spinner, Skeleton, Status, Surface, Avatar)
and eight behavior components (Tooltip, Menu, Popover, Dialog,
Picker, Checkbox, Switch, Tabs). Picker covers select and combobox
behavior, not date picking. Behavior adapters own their portal, focus,
keyboard, dismissal, and stacking implementation while honoring the semantic
props and portalContainer interop contract.
App product code imports standard controls from its local adapter path, usually
@/components/ui/*. Do not import @agent-native/toolkit/ui/* directly from
pages, routes, or domain components. That bypasses the app seam and makes a
future design-system replacement incomplete. Toolkit feature packages remain
valid imports; configure their presentation through the registered semantic
components, controller, and product slots.
Run the published conformance kit against a complete adapter in its own CI:
import { assertDesignSystemConformance } from "@agent-native/toolkit/conformance";
import { DESIGN_SYSTEM_CONTRACT_VERSION } from "@agent-native/toolkit/design-system";
await assertDesignSystemConformance({
adapterName: "Acme",
components,
contractVersion: DESIGN_SYSTEM_CONTRACT_VERSION,
});
Customize A Shared Feature
Prefer feature-level headless controllers over rebuilding individual widgets. One controller must power both the Toolkit default view and every custom render path so behavior, actions, analytics, accessibility state, and error handling cannot drift. Use a product-level render slot to replace the view while keeping that controller. Eject only when the controller and slots cannot express the required product behavior.
Eject A Feature
Discover and inspect the ejection units published by installed first-party packages before changing source:
agent-native eject --list
agent-native eject inspect <unit>
agent-native eject <unit> --app <app>
agent-native eject <unit> --app <app> --apply
The command is dry-run by default. It prints the file closure, consumer import
rewrites, protected package contracts, and verification commands before
writing. --apply copies the package-version-matched source into the app and
rewrites only imports covered by the unit manifest.
If a framework feature has no ejection unit, follow its documented configuration, adapter, or extension seam; do not invent a manual package-copy recipe. For an unknown third-party package, use the emitted add-style blueprint as a starting point. Protected runtime behavior is neve
常见问题
我能直接编辑软件包文件吗?
不能。技能说明绝不编辑 node_modules 文件夹,也不修补软件包。
这里的 eject 是什么意思?
它指将最小的受支持功能复制到你的应用中,使你能够拥有并修改该副本。
我的修改在升级后会保留吗?
通过受支持设置所做的自定义与软件包代码分开保存,这使升级更加容易。
详情
作者的原始描述
How to configure, compose, or eject Agent-Native features into app-owned code. Use when overriding shared components or integrations, customizing a template, adding UI to chat or headless apps, or inspecting package source.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13151
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …