@ant-design/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ant Design
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,326 @@
1
+ # @ant-design/cli
2
+
3
+ <div align="center">
4
+
5
+ [![CI](https://github.com/ant-design/ant-design-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/ant-design/ant-design-cli/actions/workflows/ci.yml)
6
+ [![npm version](https://img.shields.io/npm/v/@ant-design/cli)](https://www.npmjs.com/package/@ant-design/cli)
7
+ [![npm downloads](https://img.shields.io/npm/dm/@ant-design/cli)](https://www.npmjs.com/package/@ant-design/cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
9
+
10
+ **CLI tool for querying antd component knowledge and analyzing antd usage in your projects.**
11
+
12
+ Designed for Code Agents (Claude Code, Cursor, Copilot, etc.) to invoke via shell and parse structured output.
13
+
14
+ [English](./README.md) · [中文](./README.zh-CN.md)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✨ Features
21
+
22
+ | Feature | Description |
23
+ |---|---|
24
+ | **Agent-First** | Structured JSON output designed for Code Agents (Claude Code, Cursor, Copilot) to parse and act on |
25
+ | **Offline-First** | All metadata is fully bundled — no network required at runtime |
26
+ | **Multi-Version** | Full support for antd v4 / v5 / v6, with cross-version API diffing and migration guides |
27
+ | **Bundled Knowledge** | Props, tokens, demos, semantic structure, and changelog — all included |
28
+ | **Project-Aware** | Auto-detects your antd version, scans usage, lints best practices, diagnoses config issues |
29
+ | **Agent Migration** | `antd migrate --apply` outputs a structured migration prompt for Code Agents to execute |
30
+
31
+ ## 📦 Install
32
+
33
+ ```bash
34
+ # npm
35
+ npm install -g @ant-design/cli
36
+
37
+ # pnpm
38
+ pnpm add -g @ant-design/cli
39
+
40
+ # bun
41
+ bun add -g @ant-design/cli
42
+
43
+ # utoo
44
+ utoo install @ant-design/cli
45
+ ```
46
+
47
+ ## 🚀 Quick Start
48
+
49
+ ```bash
50
+ # Query a component's API
51
+ antd info Button
52
+
53
+ # List all components
54
+ antd list
55
+
56
+ # Scan antd usage in your project
57
+ antd usage ./src
58
+
59
+ # Migrate from v4 to v5
60
+ antd migrate 4 5
61
+ ```
62
+
63
+ ## 📖 Commands
64
+
65
+ ### Knowledge Query
66
+
67
+ #### `antd list`
68
+
69
+ List all components with one-line descriptions and categories.
70
+
71
+ ```bash
72
+ antd list
73
+ antd list --format json
74
+ antd list --version 5.0.0
75
+ ```
76
+
77
+ <details>
78
+ <summary>Example output</summary>
79
+
80
+ ```
81
+ Component Category Description
82
+ --------- ------------ -----------------------------------------------------------
83
+ Button General To trigger an operation.
84
+ Table Data Display A table displays rows of data.
85
+ Select Data Entry Select component to select value from options.
86
+ Input Data Entry A basic widget for getting the user input as a text field.
87
+ Form Data Entry High performance Form component with data scope management.
88
+ Modal Feedback Modal dialogs.
89
+ Space Layout Set components spacing.
90
+ Flex Layout Flex layout container.
91
+ Grid Layout 24 Grids System.
92
+ ```
93
+
94
+ </details>
95
+
96
+ ---
97
+
98
+ #### `antd info <Component>`
99
+
100
+ Query component API: props, type definitions, default values.
101
+
102
+ ```bash
103
+ antd info Button
104
+ antd info Button --detail
105
+ antd info Button --version 4.24.0
106
+ antd info Button --format json
107
+ ```
108
+
109
+ <details>
110
+ <summary>Example output</summary>
111
+
112
+ ```
113
+ Button — To trigger an operation.
114
+
115
+ Property Type Default
116
+ ------------ ------------------------------------------------ -------
117
+ block boolean false
118
+ classNames Record<SemanticDOM, string> -
119
+ color default | primary | danger default
120
+ danger boolean false
121
+ disabled boolean false
122
+ ghost boolean false
123
+ href string -
124
+ htmlType submit | reset | button button
125
+ icon ReactNode -
126
+ iconPosition start | end start
127
+ loading boolean | { delay: number } false
128
+ shape default | circle | round default
129
+ size large | middle | small middle
130
+ styles Record<SemanticDOM, CSSProperties> -
131
+ target string -
132
+ type primary | default | dashed | text | link default
133
+ variant outlined | dashed | solid | filled | text | link -
134
+ onClick (event: React.MouseEvent) => void -
135
+ ```
136
+
137
+ </details>
138
+
139
+ ---
140
+
141
+ #### `antd demo <Component> [name]`
142
+
143
+ Get demo source code.
144
+
145
+ ```bash
146
+ antd demo Button # list all demos for Button
147
+ antd demo Button basic # get specific demo code
148
+ antd demo Button basic --format json
149
+ ```
150
+
151
+ ---
152
+
153
+ #### `antd token [component]`
154
+
155
+ Query Design Tokens.
156
+
157
+ ```bash
158
+ antd token # list all global tokens
159
+ antd token Button # component-level tokens
160
+ antd token --version 4.24.0
161
+ ```
162
+
163
+ <details>
164
+ <summary>Example output</summary>
165
+
166
+ ```
167
+ Button Component Tokens:
168
+
169
+ Token Type Default
170
+ ------------------- ------ ----------------
171
+ borderColorDisabled string #d9d9d9
172
+ colorPrimaryHover string #4096ff
173
+ contentFontSize number 14
174
+ defaultBg string #ffffff
175
+ defaultBorderColor string #d9d9d9
176
+ defaultColor string rgba(0,0,0,0.88)
177
+ paddingBlock number 4
178
+ paddingInline number 15
179
+ ```
180
+
181
+ </details>
182
+
183
+ ---
184
+
185
+ #### `antd semantic <Component>`
186
+
187
+ Query the semantic customization structure (`classNames` and `styles` keys).
188
+
189
+ ```bash
190
+ antd semantic Table
191
+ antd semantic Table --format json
192
+ ```
193
+
194
+ <details>
195
+ <summary>Example output</summary>
196
+
197
+ ```
198
+ Table Semantic Structure:
199
+ ├── header # Table header area
200
+ ├── body # Table body area
201
+ ├── footer # Table footer area
202
+ ├── cell # Table cell
203
+ ├── row # Table row
204
+ └── wrapper # Outer wrapper
205
+
206
+ Usage:
207
+ <Table classNames={{ header: 'my-header' }} />
208
+ <Table styles={{ header: { background: '#fff' } }} />
209
+ ```
210
+
211
+ </details>
212
+
213
+ ---
214
+
215
+ #### `antd changelog [version]`
216
+
217
+ Query changelog entries and compare API differences between versions.
218
+
219
+ ```bash
220
+ antd changelog 5.22.0 # exact version
221
+ antd changelog 5.21.0..5.24.0 # version range (both ends inclusive)
222
+ antd changelog --format json
223
+ ```
224
+
225
+ ---
226
+
227
+ ### Project Analysis
228
+
229
+ #### `antd doctor`
230
+
231
+ Diagnose project-level configuration issues.
232
+
233
+ ```bash
234
+ antd doctor
235
+ antd doctor --format json
236
+ ```
237
+
238
+ ---
239
+
240
+ #### `antd usage [dir]`
241
+
242
+ Scan project for antd component/API usage statistics.
243
+
244
+ ```bash
245
+ antd usage # scan current directory
246
+ antd usage ./src # scan specific directory
247
+ antd usage --format json
248
+ ```
249
+
250
+ ---
251
+
252
+ #### `antd lint [file/dir]`
253
+
254
+ Check antd usage against best practices.
255
+
256
+ ```bash
257
+ antd lint ./src
258
+ antd lint ./src/pages/home.tsx
259
+ antd lint --only deprecated # only check deprecated APIs
260
+ antd lint --only a11y # only check accessibility
261
+ antd lint --only performance # only check performance
262
+ antd lint --only best-practice # only check best practices
263
+ antd lint --format json
264
+ ```
265
+
266
+ ---
267
+
268
+ #### `antd migrate <from> <to>`
269
+
270
+ Version migration guide with optional auto-fix.
271
+
272
+ ```bash
273
+ antd migrate 4 5 # full migration checklist
274
+ antd migrate 4 5 --component Select # component-specific migration
275
+ antd migrate 4 5 --apply ./src # output agent migration prompt for ./src
276
+ antd migrate 4 5 --format json # structured output for agents
277
+ ```
278
+
279
+ <details>
280
+ <summary>Example output</summary>
281
+
282
+ ```
283
+ Migration Guide: v4 → v5
284
+
285
+ Select:
286
+ 🔧 [BREAKING] Prop `dropdownClassName` renamed to `popupClassName`
287
+ 🔧 [BREAKING] Prop `dropdownMatchSelectWidth` renamed to `popupMatchSelectWidth`
288
+
289
+ Total: 2 steps (2 auto-fixable, 0 manual)
290
+ ```
291
+
292
+ </details>
293
+
294
+ ---
295
+
296
+ ## ⚙️ Global Flags
297
+
298
+ | Flag | Description | Default |
299
+ |---|---|---|
300
+ | `--format json\|text\|markdown` | Output format | `text` |
301
+ | `--version <v>` | Target antd version | auto-detect |
302
+ | `--lang en\|zh` | Output language | `en` |
303
+ | `--detail` | Full information output | `false` |
304
+ | `-V, --cli-version` | Print CLI version number | — |
305
+
306
+ ## 🤖 Use with AI Agents
307
+
308
+ Add the following to your `CLAUDE.md` (or equivalent agent config) to let your Code Agent automatically invoke the CLI for antd-related queries:
309
+
310
+ ````markdown
311
+ ## Ant Design
312
+
313
+ Use `@ant-design/cli` to query antd component knowledge:
314
+
315
+ - `antd info <Component>` — get props, types, and defaults
316
+ - `antd demo <Component> [name]` — get demo source code
317
+ - `antd token <Component>` — get design tokens
318
+ - `antd migrate 4 5 --apply ./src` — generate migration instructions
319
+ - `antd lint ./src` — check for best practice violations
320
+
321
+ Always prefer `--format json` for programmatic parsing.
322
+ ````
323
+
324
+ ## 📄 License
325
+
326
+ [MIT](./LICENSE) © Ant Design
@@ -0,0 +1,326 @@
1
+ # @ant-design/cli
2
+
3
+ <div align="center">
4
+
5
+ [![CI](https://github.com/ant-design/ant-design-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/ant-design/ant-design-cli/actions/workflows/ci.yml)
6
+ [![npm version](https://img.shields.io/npm/v/@ant-design/cli)](https://www.npmjs.com/package/@ant-design/cli)
7
+ [![npm downloads](https://img.shields.io/npm/dm/@ant-design/cli)](https://www.npmjs.com/package/@ant-design/cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
9
+
10
+ **用于查询 antd 组件知识、分析项目中 antd 用法的命令行工具。**
11
+
12
+ 专为 Code Agent(Claude Code、Cursor、Copilot 等)设计,通过 Shell 调用并解析结构化输出。
13
+
14
+ [English](./README.md) · [中文](./README.zh-CN.md)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✨ 功能特性
21
+
22
+ | 功能 | 说明 |
23
+ |---|---|
24
+ | **Agent 优先** | 结构化 JSON 输出,专为 Code Agent(Claude Code、Cursor、Copilot)解析使用 |
25
+ | **离线优先** | 所有元数据完整打包,运行时无需网络 |
26
+ | **多版本支持** | 完整支持 antd v4 / v5 / v6,支持跨版本 API 对比与迁移指南 |
27
+ | **知识内置** | Props、Token、Demo、语义结构、Changelog 一应俱全 |
28
+ | **项目感知** | 自动识别 antd 版本,扫描用法、检查最佳实践、诊断配置问题 |
29
+ | **Agent 迁移** | `antd migrate --apply` 为 Code Agent 输出结构化迁移提示 |
30
+
31
+ ## 📦 安装
32
+
33
+ ```bash
34
+ # npm
35
+ npm install -g @ant-design/cli
36
+
37
+ # pnpm
38
+ pnpm add -g @ant-design/cli
39
+
40
+ # bun
41
+ bun add -g @ant-design/cli
42
+
43
+ # utoo
44
+ utoo install @ant-design/cli
45
+ ```
46
+
47
+ ## 🚀 快速开始
48
+
49
+ ```bash
50
+ # 查询组件 API
51
+ antd info Button
52
+
53
+ # 列出所有组件
54
+ antd list
55
+
56
+ # 扫描项目中的 antd 用法
57
+ antd usage ./src
58
+
59
+ # 从 v4 迁移到 v5
60
+ antd migrate 4 5
61
+ ```
62
+
63
+ ## 📖 命令
64
+
65
+ ### 知识查询
66
+
67
+ #### `antd list`
68
+
69
+ 列出所有组件及其简介与分类。
70
+
71
+ ```bash
72
+ antd list
73
+ antd list --format json
74
+ antd list --version 5.0.0
75
+ ```
76
+
77
+ <details>
78
+ <summary>示例输出</summary>
79
+
80
+ ```
81
+ Component Category Description
82
+ --------- ------------ -----------------------------------------------------------
83
+ Button General To trigger an operation.
84
+ Table Data Display A table displays rows of data.
85
+ Select Data Entry Select component to select value from options.
86
+ Input Data Entry A basic widget for getting the user input as a text field.
87
+ Form Data Entry High performance Form component with data scope management.
88
+ Modal Feedback Modal dialogs.
89
+ Space Layout Set components spacing.
90
+ Flex Layout Flex layout container.
91
+ Grid Layout 24 Grids System.
92
+ ```
93
+
94
+ </details>
95
+
96
+ ---
97
+
98
+ #### `antd info <Component>`
99
+
100
+ 查询组件 API:Props、类型定义、默认值。
101
+
102
+ ```bash
103
+ antd info Button
104
+ antd info Button --detail
105
+ antd info Button --version 4.24.0
106
+ antd info Button --format json
107
+ ```
108
+
109
+ <details>
110
+ <summary>示例输出</summary>
111
+
112
+ ```
113
+ Button — To trigger an operation.
114
+
115
+ Property Type Default
116
+ ------------ ------------------------------------------------ -------
117
+ block boolean false
118
+ classNames Record<SemanticDOM, string> -
119
+ color default | primary | danger default
120
+ danger boolean false
121
+ disabled boolean false
122
+ ghost boolean false
123
+ href string -
124
+ htmlType submit | reset | button button
125
+ icon ReactNode -
126
+ iconPosition start | end start
127
+ loading boolean | { delay: number } false
128
+ shape default | circle | round default
129
+ size large | middle | small middle
130
+ styles Record<SemanticDOM, CSSProperties> -
131
+ target string -
132
+ type primary | default | dashed | text | link default
133
+ variant outlined | dashed | solid | filled | text | link -
134
+ onClick (event: React.MouseEvent) => void -
135
+ ```
136
+
137
+ </details>
138
+
139
+ ---
140
+
141
+ #### `antd demo <Component> [name]`
142
+
143
+ 获取 Demo 源码。
144
+
145
+ ```bash
146
+ antd demo Button # 列出 Button 的所有 Demo
147
+ antd demo Button basic # 获取指定 Demo 代码
148
+ antd demo Button basic --format json
149
+ ```
150
+
151
+ ---
152
+
153
+ #### `antd token [component]`
154
+
155
+ 查询 Design Token。
156
+
157
+ ```bash
158
+ antd token # 列出所有全局 Token
159
+ antd token Button # 组件级 Token
160
+ antd token --version 4.24.0
161
+ ```
162
+
163
+ <details>
164
+ <summary>示例输出</summary>
165
+
166
+ ```
167
+ Button Component Tokens:
168
+
169
+ Token Type Default
170
+ ------------------- ------ ----------------
171
+ borderColorDisabled string #d9d9d9
172
+ colorPrimaryHover string #4096ff
173
+ contentFontSize number 14
174
+ defaultBg string #ffffff
175
+ defaultBorderColor string #d9d9d9
176
+ defaultColor string rgba(0,0,0,0.88)
177
+ paddingBlock number 4
178
+ paddingInline number 15
179
+ ```
180
+
181
+ </details>
182
+
183
+ ---
184
+
185
+ #### `antd semantic <Component>`
186
+
187
+ 查询语义化定制结构(`classNames` 和 `styles` 的键名)。
188
+
189
+ ```bash
190
+ antd semantic Table
191
+ antd semantic Table --format json
192
+ ```
193
+
194
+ <details>
195
+ <summary>示例输出</summary>
196
+
197
+ ```
198
+ Table Semantic Structure:
199
+ ├── header # 表头区域
200
+ ├── body # 表体区域
201
+ ├── footer # 表尾区域
202
+ ├── cell # 单元格
203
+ ├── row # 行
204
+ └── wrapper # 外层容器
205
+
206
+ Usage:
207
+ <Table classNames={{ header: 'my-header' }} />
208
+ <Table styles={{ header: { background: '#fff' } }} />
209
+ ```
210
+
211
+ </details>
212
+
213
+ ---
214
+
215
+ #### `antd changelog [version]`
216
+
217
+ 查询 Changelog 条目,对比版本间 API 差异。
218
+
219
+ ```bash
220
+ antd changelog 5.22.0 # 精确版本
221
+ antd changelog 5.21.0..5.24.0 # 版本范围(两端均包含)
222
+ antd changelog --format json
223
+ ```
224
+
225
+ ---
226
+
227
+ ### 项目分析
228
+
229
+ #### `antd doctor`
230
+
231
+ 诊断项目级配置问题。
232
+
233
+ ```bash
234
+ antd doctor
235
+ antd doctor --format json
236
+ ```
237
+
238
+ ---
239
+
240
+ #### `antd usage [dir]`
241
+
242
+ 扫描项目中 antd 组件/API 的使用情况统计。
243
+
244
+ ```bash
245
+ antd usage # 扫描当前目录
246
+ antd usage ./src # 扫描指定目录
247
+ antd usage --format json
248
+ ```
249
+
250
+ ---
251
+
252
+ #### `antd lint [file/dir]`
253
+
254
+ 按最佳实践检查 antd 用法。
255
+
256
+ ```bash
257
+ antd lint ./src
258
+ antd lint ./src/pages/home.tsx
259
+ antd lint --only deprecated # 只检查废弃 API
260
+ antd lint --only a11y # 只检查无障碍
261
+ antd lint --only performance # 只检查性能
262
+ antd lint --only best-practice # 只检查最佳实践
263
+ antd lint --format json
264
+ ```
265
+
266
+ ---
267
+
268
+ #### `antd migrate <from> <to>`
269
+
270
+ 版本迁移指南,支持自动修复输出。
271
+
272
+ ```bash
273
+ antd migrate 4 5 # 完整迁移清单
274
+ antd migrate 4 5 --component Select # 指定组件迁移
275
+ antd migrate 4 5 --apply ./src # 为 ./src 输出 Agent 迁移提示
276
+ antd migrate 4 5 --format json # 结构化输出,适合 Agent 解析
277
+ ```
278
+
279
+ <details>
280
+ <summary>示例输出</summary>
281
+
282
+ ```
283
+ Migration Guide: v4 → v5
284
+
285
+ Select:
286
+ 🔧 [BREAKING] Prop `dropdownClassName` renamed to `popupClassName`
287
+ 🔧 [BREAKING] Prop `dropdownMatchSelectWidth` renamed to `popupMatchSelectWidth`
288
+
289
+ Total: 2 steps (2 auto-fixable, 0 manual)
290
+ ```
291
+
292
+ </details>
293
+
294
+ ---
295
+
296
+ ## ⚙️ 全局参数
297
+
298
+ | 参数 | 说明 | 默认值 |
299
+ |---|---|---|
300
+ | `--format json\|text\|markdown` | 输出格式 | `text` |
301
+ | `--version <v>` | 目标 antd 版本 | 自动检测 |
302
+ | `--lang en\|zh` | 输出语言 | `en` |
303
+ | `--detail` | 完整信息输出 | `false` |
304
+ | `-V, --cli-version` | 打印 CLI 版本号 | — |
305
+
306
+ ## 🤖 与 AI Agent 配合使用
307
+
308
+ 将以下内容添加到 `CLAUDE.md`(或其他 Agent 配置文件),让 Code Agent 自动调用 CLI 查询 antd 相关信息:
309
+
310
+ ````markdown
311
+ ## Ant Design
312
+
313
+ 使用 `@ant-design/cli` 查询 antd 组件知识:
314
+
315
+ - `antd info <Component>` — 获取 Props、类型和默认值
316
+ - `antd demo <Component> [name]` — 获取 Demo 源码
317
+ - `antd token <Component>` — 获取 Design Token
318
+ - `antd migrate 4 5 --apply ./src` — 生成迁移指令
319
+ - `antd lint ./src` — 检查最佳实践违规
320
+
321
+ 程序化解析时优先使用 `--format json`。
322
+ ````
323
+
324
+ ## 📄 开源协议
325
+
326
+ [MIT](./LICENSE) © Ant Design