为编程智能体编写组件目录
读取仓库组件源码,整理导入路径、属性与使用规则,生成供编程智能体查阅和维护的目录。
完整提示词
<context>
Agents write UI from what they can see in context. If the shared components are not visible, they produce plausible markup with inline styles, a new dropdown that duplicates the existing one, or hex colours instead of tokens. Pointing an agent at a folder of 80 components does not help; reading them all costs too much context. What helps is a compact catalog: for each component, the import path, one line on when to use it, the props that matter, the variants, and the thing it replaces ("use Button, never a raw button element"). Rules that cut across components (spacing and colour tokens, icon set, form field pattern, how loading and empty states look) matter as much as the entries. The catalog must come from the actual source, not memory, and must say how it stays current.
</context>
<task>
Write a component catalog for coding agents.
{{#components_path}}Components: {{components_path}}{{/components_path}}
{{#known_problems}}
<known_problems>
{{known_problems}}
</known_problems>
{{/known_problems}}
1. Find the shared components and any design tokens, theme files and existing docs or stories. List them, noting deprecated or internal-only components.
2. Read each public component's props type and implementation enough to state its purpose, key props, variants and accessibility behaviour it already handles. Do not describe props that are not in the code.
3. Group components by job (actions, inputs, feedback, layout, navigation, data display).
4. Write the catalog file next to the components or in the docs folder: one line per component (import, use for, key props or variants, replaces), then a short "Cross-cutting rules" section on tokens, icons, forms, and loading, empty and error states. Address each known problem with an explicit rule.
5. Keep it under about 150 lines. Leave out components agents should not use, except a short "Do not use" list.
6. Add a one-line pointer to the catalog in the repository's agent instruction file, scoped to frontend paths if the tool supports scoped rules.
</task>
<constraints>
- Every entry must match the source. If a component's purpose is unclear from the code, list it under Upkeep as a question rather than guessing.
- Do not change component code.
{{> guardrails/scope-discipline}}
</constraints>
<output_format>
## Inventory
Table: component, path, status (public, deprecated, internal).
## Catalog file
Path, then the full file in a fenced block.
## Instruction file pointer
The line added and where.
## Upkeep
How to keep the catalog current (a check in review, a generation script if the props types allow) and open questions.
</output_format>可替换内容
- {{#components_path}}
- {{components_path}}
- {{/components_path}}
- {{#known_problems}}
- {{known_problems}}
- {{/known_problems}}
- {{> guardrails/scope-discipline}}
分类与标签
编程开发、组件文档、编程智能体、前端开发、代码仓库