@qin-ui/element-plus-pro 1.1.2 → 1.1.4
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/AI-CONTEXT.md +119 -189
- package/README.md +311 -84
- package/api.json +95 -1
- package/bin/init-ai.mjs +224 -113
- package/package.json +5 -5
package/api.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-
|
|
2
|
+
"generatedAt": "2026-08-05T02:00:08.347Z",
|
|
3
3
|
"name": "@qin-ui/element-plus-pro",
|
|
4
4
|
"api": [
|
|
5
5
|
{
|
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
"package": "@qin-ui/element-plus-pro",
|
|
9
9
|
"signature": "<ProComponentProvider>",
|
|
10
10
|
"description": "@qin-ui/element-plus-pro 全局配置提供者组件\n用于在组件树的顶层配置所有子组件的全局默认属性。",
|
|
11
|
+
"params": [
|
|
12
|
+
{
|
|
13
|
+
"name": "componentVars",
|
|
14
|
+
"type": "ComponentVars",
|
|
15
|
+
"optional": true,
|
|
16
|
+
"description": "组件全局配置变量"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "componentMap",
|
|
20
|
+
"type": "Record<ComponentName, any>",
|
|
21
|
+
"optional": true,
|
|
22
|
+
"description": "自定义组件映射"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
11
25
|
"examples": [
|
|
12
26
|
"```vue\n<ProComponentProvider\n:componentVars=\"{ 'input': { placeholder: '请输入' } }\"\n>\n<ProForm :form=\"form\" />\n</ProComponentProvider>\n```"
|
|
13
27
|
]
|
|
@@ -25,6 +39,20 @@
|
|
|
25
39
|
"package": "@qin-ui/element-plus-pro",
|
|
26
40
|
"signature": "<ProForm>",
|
|
27
41
|
"description": "@qin-ui/element-plus-pro 配置驱动表单组件\n架构设计说明 (Architecture Overview)\n[ 数据层 (Core) ] => [ 绑定层 (ProForm) ] => [ 渲染层 (BaseFormItem / BaseField) ]\n1. 数据隔离:ProForm 本身不负责存储和管理表单状态,所有核心状态(formData, fields, 校验规则)\n均交由底层的 `useForm`(@qin-ui/pro-components-core)驱动。\n2. 上下文透传:通过 `provide` 将核心状态下发给子组件,避免了深层嵌套的 Props 传递。\n3. 递归渲染:网格布局和具体字段的解析交由 `<BaseFormItem>` 递归完成,实现了 UI 布局与表单逻辑的解耦。\n通过配置驱动的方式快速构建表单,支持:\n- 字段联动、嵌套字段、自定义组件、网格布局",
|
|
42
|
+
"params": [
|
|
43
|
+
{
|
|
44
|
+
"name": "form",
|
|
45
|
+
"type": "F",
|
|
46
|
+
"optional": true,
|
|
47
|
+
"description": "useForm 返回的表单实例"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "grid",
|
|
51
|
+
"type": "boolean | GridProps",
|
|
52
|
+
"optional": true,
|
|
53
|
+
"description": "是否启用网格布局 (默认 false)"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
28
56
|
"typeParams": [
|
|
29
57
|
{
|
|
30
58
|
"name": "F"
|
|
@@ -61,6 +89,14 @@
|
|
|
61
89
|
"package": "@qin-ui/element-plus-pro",
|
|
62
90
|
"signature": "export const useFormData = <D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>\n): UseFormDataReturn<D> =>",
|
|
63
91
|
"description": "表单数据处理 Hook\n提供响应式表单数据的管理能力,支持:\n- 响应式数据存储(基于 Vue reactive)\n- 深层路径读写(支持点号分隔,如 'address.city')\n- 类型安全的路径提示(传入泛型 D 后,path 参数可获得类型推导)\n- 父子表单自动注入(非根表单会从注入中获取数据)",
|
|
92
|
+
"params": [
|
|
93
|
+
{
|
|
94
|
+
"name": "initFormData",
|
|
95
|
+
"type": "ExtendWithAny<DeepPartial<D>>",
|
|
96
|
+
"optional": true,
|
|
97
|
+
"description": "初始表单数据"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
64
100
|
"returns": "{UseFormDataReturn<D>} 表单数据操作对象",
|
|
65
101
|
"typeParams": [
|
|
66
102
|
{
|
|
@@ -77,6 +113,14 @@
|
|
|
77
113
|
"package": "@qin-ui/element-plus-pro",
|
|
78
114
|
"signature": "export function useFields<D extends Data = Data>(\n initFields?: Fields<D>\n): UseFieldsReturn<D, Field<ComponentName, D>, FormItemInstance>;",
|
|
79
115
|
"description": "字段配置管理 Hook\n基于 `@qin-ui/pro-components-core` 的 `useFields`,将泛型参数绑定为 Element Plus 的本地类型:\n- 字段类型 F -> `Field<ComponentName, D>`(支持 Element Plus 组件类型推导)\n- FormItem 实例 -> Element Plus 的 `FormItemInstance`\n提供对字段配置数组的增删改查操作,支持:\n- 通过路径字符串或查找函数定位字段\n- 深层嵌套字段的遍历和匹配\n- 字段配置的合并/覆盖更新\n- 字段的添加、插入、删除\n- 父级字段查找\n- `fields` - 字段配置数组(响应式 Ref\\<F[]\\>)\n- `getField(path)` - 获取字段配置,支持路径字符串或查找函数\n- `setField(path, field, options?)` - 更新字段配置,默认合并模式\n- `deleteField(path, options?)` - 删除字段配置\n- `appendField(path, field, options?)` - 在指定字段后追加\n- `prependField(path, field, options?)` - 在指定字段前插入\n- `getParentField(path, options?)` - 获取父级字段配置",
|
|
116
|
+
"params": [
|
|
117
|
+
{
|
|
118
|
+
"name": "initFields",
|
|
119
|
+
"type": "Fields<D>",
|
|
120
|
+
"optional": true,
|
|
121
|
+
"description": "初始字段配置数组"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
80
124
|
"returns": "字段操作对象,包含以下属性:",
|
|
81
125
|
"typeParams": [
|
|
82
126
|
{
|
|
@@ -118,6 +162,26 @@
|
|
|
118
162
|
"package": "@qin-ui/element-plus-pro",
|
|
119
163
|
"signature": "export function useForm<D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>,\n initFields?: Field<ComponentName, D>[],\n root?: boolean\n): Form<D, Field<ComponentName, D>>;",
|
|
120
164
|
"description": "创建表单实例的 Hook\n基于 `@qin-ui/pro-components-core` 的 `useForm`,将泛型参数绑定为 Element Plus 的本地类型:\n- 字段类型 F -> `Field<ComponentName, D>`(支持 Element Plus 所有内置组件类型推导)\n- 表单实例 -> Element Plus 的 `FormInstance`(使 formRef 获得完整的类型提示)\n表单实例组合了三个子模块的能力:\n- **useFormData**:表单数据管理(响应式数据、读写、批量更新)\n- **useFields**:字段配置管理(增删改查字段配置,支持嵌套)\n- **useFormRef**:底层 Form 组件实例引用",
|
|
165
|
+
"params": [
|
|
166
|
+
{
|
|
167
|
+
"name": "initFormData",
|
|
168
|
+
"type": "ExtendWithAny<DeepPartial<D>>",
|
|
169
|
+
"optional": true,
|
|
170
|
+
"description": "初始表单数据"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "initFields",
|
|
174
|
+
"type": "Field<ComponentName, D>[]",
|
|
175
|
+
"optional": true,
|
|
176
|
+
"description": "初始字段配置数组"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "root",
|
|
180
|
+
"type": "boolean",
|
|
181
|
+
"optional": true,
|
|
182
|
+
"description": "是否为根表单。设为 `false` 时尝试从父组件注入获取表单实例 (默认 true)"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
121
185
|
"returns": "{Form<D>} 表单实例,包含数据操作、字段操作和 ref 操作",
|
|
122
186
|
"typeParams": [
|
|
123
187
|
{
|
|
@@ -220,6 +284,36 @@
|
|
|
220
284
|
"type": "object",
|
|
221
285
|
"optional": false,
|
|
222
286
|
"description": "表格配置参数"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"name": "params.columns",
|
|
290
|
+
"type": "Columns<T>",
|
|
291
|
+
"optional": true,
|
|
292
|
+
"description": "初始列配置数组"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"name": "params.data",
|
|
296
|
+
"type": "T[]",
|
|
297
|
+
"optional": true,
|
|
298
|
+
"description": "初始数据源(Element Plus 风格)"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"name": "params.pageParam",
|
|
302
|
+
"type": "PageParam",
|
|
303
|
+
"optional": true,
|
|
304
|
+
"description": "初始分页参数,默认 `{ current: 1, pageSize: 10, total: 0 }`"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "params.searchParam",
|
|
308
|
+
"type": "ExtendWithAny<DeepPartial<D>>",
|
|
309
|
+
"optional": true,
|
|
310
|
+
"description": "初始搜索参数"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "params.searchFields",
|
|
314
|
+
"type": "Fields<D>",
|
|
315
|
+
"optional": true,
|
|
316
|
+
"description": "搜索表单字段配置"
|
|
223
317
|
}
|
|
224
318
|
],
|
|
225
319
|
"returns": "{Table<D, T>} 表格实例",
|
package/bin/init-ai.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* global process -- Node.js CLI 脚本 */
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @qin-ui/element-plus-pro AI 上下文初始化 CLI 工具
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* 1.
|
|
8
|
-
* 2.
|
|
9
|
-
* 3. 快速获取完整 API 参考
|
|
7
|
+
* 在消费方项目中生成双载体 AI 上下文:
|
|
8
|
+
* 1. 根目录 AGENTS.md -- 核心使用规则,跨工具自动注入(主载体)
|
|
9
|
+
* 2. .agents/skills/{pkg}/SKILL.md + references/ -- 分层参考文档,支持 skills 发现的工具按需逐层调取(参考载体)
|
|
10
10
|
*
|
|
11
11
|
* 用法:
|
|
12
12
|
* npx @qin-ui/element-plus-pro init-ai
|
|
@@ -28,6 +28,10 @@ const PKG_JSON = JSON.parse(
|
|
|
28
28
|
const PKG_NAME = PKG_JSON.name;
|
|
29
29
|
const PKG_SHORT = PKG_NAME.replace(/^@qin-ui\//, '');
|
|
30
30
|
|
|
31
|
+
// AGENTS.md 智能合并区块标记(支持多库共存,幂等更新)
|
|
32
|
+
const BEGIN_MARKER = `<!-- BEGIN ${PKG_NAME} -->`;
|
|
33
|
+
const END_MARKER = `<!-- END ${PKG_NAME} -->`;
|
|
34
|
+
|
|
31
35
|
// ==================== 终端颜色 ====================
|
|
32
36
|
|
|
33
37
|
const green = s => `\x1b[32m${s}\x1b[0m`;
|
|
@@ -47,7 +51,10 @@ function readPackageFile(filename) {
|
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
function getAiContextContent() {
|
|
50
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
readPackageFile('AI-CONTEXT.md') ||
|
|
56
|
+
`# ${PKG_NAME}\n\n> 基于 Vue 3 的配置驱动组件库。`
|
|
57
|
+
);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
function getReadmeContent() {
|
|
@@ -64,79 +71,157 @@ function getApiJsonContent() {
|
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
// ====================
|
|
74
|
+
// ==================== 工具函数 ====================
|
|
75
|
+
|
|
76
|
+
function escapeRegExp(s) {
|
|
77
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ensureDir(dirPath) {
|
|
81
|
+
if (!fs.existsSync(dirPath)) {
|
|
82
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function writeFileWithLog(filePath, content, label) {
|
|
87
|
+
const dir = path.dirname(filePath);
|
|
88
|
+
ensureDir(dir);
|
|
89
|
+
const existed = fs.existsSync(filePath);
|
|
90
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
91
|
+
const status = existed ? yellow('[更新]') : green('[创建]');
|
|
92
|
+
console.log(` ${status} ${cyan(label)}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ==================== AGENTS.md(主载体,自动注入)====================
|
|
68
96
|
|
|
69
97
|
/**
|
|
70
|
-
* 生成
|
|
71
|
-
*
|
|
98
|
+
* 生成 AGENTS.md 区块内容
|
|
99
|
+
* = AI-CONTEXT.md 全文(核心使用规则,AI 必然读到)
|
|
72
100
|
*/
|
|
73
|
-
function
|
|
101
|
+
function getAgentsBlock() {
|
|
102
|
+
return getAiContextContent();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 智能合并 AGENTS.md:
|
|
107
|
+
* - 文件不存在 -> 创建,内容 = 标记区块
|
|
108
|
+
* - 已有本库区块 -> 幂等替换区块内容(支持升级后更新)
|
|
109
|
+
* - 已有其他内容但无本库区块 -> 末尾追加区块(多库共存不冲突)
|
|
110
|
+
*/
|
|
111
|
+
function writeAgentsMd(cwd) {
|
|
112
|
+
const agentsPath = path.join(cwd, 'AGENTS.md');
|
|
113
|
+
const blockContent = getAgentsBlock();
|
|
114
|
+
const newBlock = `${BEGIN_MARKER}\n${blockContent}\n${END_MARKER}`;
|
|
115
|
+
|
|
116
|
+
let existing = '';
|
|
117
|
+
if (fs.existsSync(agentsPath)) {
|
|
118
|
+
existing = fs.readFileSync(agentsPath, 'utf-8');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let result;
|
|
122
|
+
const hasBlock =
|
|
123
|
+
existing.includes(BEGIN_MARKER) && existing.includes(END_MARKER);
|
|
124
|
+
|
|
125
|
+
if (hasBlock) {
|
|
126
|
+
// 幂等替换已有区块
|
|
127
|
+
const blockRegex = new RegExp(
|
|
128
|
+
`${escapeRegExp(BEGIN_MARKER)}[\\s\\S]*?${escapeRegExp(END_MARKER)}`,
|
|
129
|
+
'g'
|
|
130
|
+
);
|
|
131
|
+
result = existing.replace(blockRegex, newBlock);
|
|
132
|
+
} else if (existing.trim()) {
|
|
133
|
+
// 已有其他内容,追加区块
|
|
134
|
+
result = `${existing.trimEnd()}\n\n${newBlock}\n`;
|
|
135
|
+
} else {
|
|
136
|
+
// 文件不存在或空
|
|
137
|
+
result = `${newBlock}\n`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const existed = fs.existsSync(agentsPath);
|
|
141
|
+
fs.writeFileSync(agentsPath, result, 'utf-8');
|
|
142
|
+
const status = existed ? yellow('[更新]') : green('[创建]');
|
|
143
|
+
console.log(` ${status} ${cyan('AGENTS.md')}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ==================== Skills(参考载体,按需调取)====================
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 生成 SKILL.md 内容
|
|
150
|
+
* = skill frontmatter + AI-CONTEXT.md 速查内容 + references 导航
|
|
151
|
+
* 供支持 skills 发现的工具按需调取,精准定位后查阅 references
|
|
152
|
+
*/
|
|
153
|
+
function getSkillMainContent() {
|
|
74
154
|
const aiContext = getAiContextContent();
|
|
155
|
+
const sections = [];
|
|
156
|
+
|
|
157
|
+
// skill frontmatter
|
|
158
|
+
sections.push('---');
|
|
159
|
+
sections.push(`name: ${PKG_SHORT}`);
|
|
160
|
+
sections.push(
|
|
161
|
+
`description: ${PKG_NAME} 使用指南 - 组件、Hooks、类型、Field/Column 配置。Schema 驱动的配置式组件库。当需要组件映射、默认预设、属性透传规则或完整用法时按需调取。`
|
|
162
|
+
);
|
|
163
|
+
sections.push('---');
|
|
164
|
+
sections.push('');
|
|
165
|
+
|
|
166
|
+
// AI-CONTEXT.md 速查内容(与 AGENTS.md 主载体同源,确保一致)
|
|
167
|
+
sections.push(aiContext);
|
|
168
|
+
sections.push('');
|
|
169
|
+
|
|
170
|
+
// references 导航
|
|
171
|
+
sections.push('---');
|
|
172
|
+
sections.push('');
|
|
173
|
+
sections.push('## 参考文档');
|
|
174
|
+
sections.push('');
|
|
175
|
+
sections.push(
|
|
176
|
+
`以下文件位于 \`.agents/skills/${PKG_SHORT}/references/\`,可在需要精确细节时进一步查阅:`
|
|
177
|
+
);
|
|
178
|
+
sections.push('');
|
|
179
|
+
sections.push(
|
|
180
|
+
`- [references/README.md](references/README.md) — 完整使用文档与进阶示例`
|
|
181
|
+
);
|
|
182
|
+
sections.push(
|
|
183
|
+
`- [references/api.md](references/api.md) — 结构化 API 元数据(函数签名、参数类型、返回值,提取自源码 JSDoc)`
|
|
184
|
+
);
|
|
185
|
+
sections.push(`- 底层组件属性查阅 element-plus 官方文档:https://element-plus.org`);
|
|
186
|
+
sections.push('');
|
|
75
187
|
|
|
76
|
-
return
|
|
77
|
-
'---',
|
|
78
|
-
`description: "${PKG_NAME} 组件库使用规范 — Schema 驱动、属性透传规则"`,
|
|
79
|
-
'globs: ["**/*.vue", "**/*.ts", "**/*.tsx"]',
|
|
80
|
-
'alwaysApply: false',
|
|
81
|
-
'---',
|
|
82
|
-
'',
|
|
83
|
-
aiContext,
|
|
84
|
-
'',
|
|
85
|
-
'---',
|
|
86
|
-
'',
|
|
87
|
-
'## 本地参考文件',
|
|
88
|
-
'',
|
|
89
|
-
'本规则文件提供了核心架构和用法指南。需要完整 API 参考时,请阅读以下文件:',
|
|
90
|
-
'',
|
|
91
|
-
`- **\`.agents/docs/${PKG_SHORT}-api.md\`** — 完整 API 文档(组件、Hooks、类型、Field 配置参考)`,
|
|
92
|
-
`- **\`node_modules/${PKG_NAME}/api.json\`** — 结构化 API 元数据(函数签名、类型定义)`,
|
|
93
|
-
'',
|
|
94
|
-
'## element-plus 文档资源',
|
|
95
|
-
'',
|
|
96
|
-
'所有在 Field 配置中编写的非保留属性,最终会透传给 element-plus 组件。编写前务必查阅文档确认属性名:',
|
|
97
|
-
'',
|
|
98
|
-
'| 资源 | URL | 说明 |',
|
|
99
|
-
'|:--|:--|:--|',
|
|
100
|
-
'| element-plus 官网 | https://element-plus.org/ | 官方文档首页(中文/英文) |',
|
|
101
|
-
'| 组件文档 | https://element-plus.org/zh-CN/component/button | 组件 API 参考入口(中文) |',
|
|
102
|
-
'',
|
|
103
|
-
].join('\n');
|
|
188
|
+
return sections.join('\n');
|
|
104
189
|
}
|
|
105
190
|
|
|
106
191
|
/**
|
|
107
|
-
* 生成 API
|
|
108
|
-
* 从
|
|
192
|
+
* 生成 references/api.md 内容(结构化 API 元数据 + skill frontmatter)
|
|
193
|
+
* 从 api.json 提取 @public 标记的 JSDoc,含签名、参数、返回值、示例
|
|
109
194
|
*/
|
|
110
|
-
function
|
|
111
|
-
const readme = getReadmeContent();
|
|
195
|
+
function getSkillApiContent() {
|
|
112
196
|
const apiJson = getApiJsonContent();
|
|
113
|
-
|
|
114
197
|
const sections = [];
|
|
115
198
|
|
|
116
|
-
|
|
117
|
-
sections.push(
|
|
199
|
+
// skill frontmatter
|
|
200
|
+
sections.push('---');
|
|
201
|
+
sections.push(`name: ${PKG_SHORT}-api`);
|
|
202
|
+
sections.push(
|
|
203
|
+
`description: ${PKG_NAME} 结构化 API 元数据 - 函数签名、参数类型、返回值、示例。从源码 JSDoc(@public 标记)自动提取。`
|
|
204
|
+
);
|
|
205
|
+
sections.push('---');
|
|
206
|
+
sections.push('');
|
|
118
207
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
208
|
+
sections.push(`# ${PKG_NAME} - 结构化 API 元数据`, '');
|
|
209
|
+
sections.push(
|
|
210
|
+
`> 自动提取自源码 JSDoc(\`@public\` 标记)。版本: ${PKG_JSON.version}`,
|
|
211
|
+
''
|
|
212
|
+
);
|
|
124
213
|
|
|
125
214
|
// 结构化 API 元数据
|
|
126
215
|
if (apiJson && apiJson.api && apiJson.api.length > 0) {
|
|
127
|
-
sections.push('---');
|
|
128
|
-
sections.push('');
|
|
129
|
-
sections.push('## 结构化 API 元数据(自动提取自源码 JSDoc)');
|
|
130
|
-
sections.push('');
|
|
131
|
-
|
|
132
216
|
for (const item of apiJson.api) {
|
|
133
|
-
const typeLabel =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
217
|
+
const typeLabel =
|
|
218
|
+
{
|
|
219
|
+
component: '组件',
|
|
220
|
+
function: '函数/Hook',
|
|
221
|
+
type: '类型',
|
|
222
|
+
interface: '接口',
|
|
223
|
+
constant: '常量',
|
|
224
|
+
}[item.type] || '';
|
|
140
225
|
|
|
141
226
|
sections.push(`### ${typeLabel} \`${item.name}\``);
|
|
142
227
|
sections.push('');
|
|
@@ -171,7 +256,9 @@ function getApiDocContent() {
|
|
|
171
256
|
sections.push('| 参数名 | 类型 | 可选 | 描述 |');
|
|
172
257
|
sections.push('| :--- | :--- | :--- | :--- |');
|
|
173
258
|
for (const p of item.params) {
|
|
174
|
-
sections.push(
|
|
259
|
+
sections.push(
|
|
260
|
+
`| \`${p.name}\` | \`${p.type}\` | ${p.optional ? '是' : '否'} | ${p.description} |`
|
|
261
|
+
);
|
|
175
262
|
}
|
|
176
263
|
}
|
|
177
264
|
|
|
@@ -198,41 +285,30 @@ function getApiDocContent() {
|
|
|
198
285
|
return sections.join('\n');
|
|
199
286
|
}
|
|
200
287
|
|
|
201
|
-
// ==================== 文件写入 ====================
|
|
202
|
-
|
|
203
|
-
function ensureDir(dirPath) {
|
|
204
|
-
if (!fs.existsSync(dirPath)) {
|
|
205
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function writeFileWithLog(filePath, content, label) {
|
|
210
|
-
const dir = path.dirname(filePath);
|
|
211
|
-
ensureDir(dir);
|
|
212
|
-
const existed = fs.existsSync(filePath);
|
|
213
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
214
|
-
const status = existed ? yellow('[更新]') : green('[创建]');
|
|
215
|
-
console.log(` ${status} ${cyan(label)}`);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
288
|
// ==================== CLI 入口 ====================
|
|
219
289
|
|
|
220
290
|
function printHelp() {
|
|
221
291
|
console.log(`
|
|
222
|
-
${bold(`${PKG_NAME} CLI
|
|
292
|
+
${bold(`${PKG_NAME} CLI - AI 上下文初始化`)}
|
|
223
293
|
|
|
224
294
|
${bold('用法:')}
|
|
225
295
|
npx ${PKG_NAME} init-ai
|
|
226
296
|
|
|
227
297
|
${bold('说明:')}
|
|
228
|
-
|
|
298
|
+
在项目中生成双载体 AI 上下文,使 AI 工具能够深度理解和规范使用 ${PKG_NAME}。
|
|
229
299
|
|
|
230
300
|
生成的文件结构:
|
|
301
|
+
AGENTS.md 核心使用规则(跨工具自动注入)
|
|
231
302
|
.agents/
|
|
232
|
-
|
|
233
|
-
${PKG_SHORT}
|
|
234
|
-
|
|
235
|
-
|
|
303
|
+
skills/
|
|
304
|
+
${PKG_SHORT}/
|
|
305
|
+
SKILL.md skills 入口(速查 + 导航)
|
|
306
|
+
references/
|
|
307
|
+
README.md 完整使用文档
|
|
308
|
+
api.md 结构化 API 元数据
|
|
309
|
+
|
|
310
|
+
${dim('AGENTS.md 是跨工具开放约定,Codex / Claude Code / Cursor 等会话时自动注入。')}
|
|
311
|
+
${dim('.agents/skills/ 供支持 skills 发现的工具按需逐层调取。')}
|
|
236
312
|
|
|
237
313
|
${bold('选项:')}
|
|
238
314
|
--help 显示帮助信息
|
|
@@ -256,48 +332,83 @@ function main() {
|
|
|
256
332
|
}
|
|
257
333
|
|
|
258
334
|
console.log('');
|
|
259
|
-
console.log(bold(`📦 ${PKG_NAME}
|
|
335
|
+
console.log(bold(`📦 ${PKG_NAME} - AI 上下文初始化 v${PKG_JSON.version}`));
|
|
260
336
|
console.log(dim(` 基于 element-plus 的 Schema 驱动组件库`));
|
|
261
337
|
console.log('');
|
|
262
338
|
|
|
263
|
-
// 1. 生成
|
|
264
|
-
console.log(bold('📋
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
rulesContent,
|
|
269
|
-
`.agents/rules/${PKG_SHORT}.md`
|
|
339
|
+
// 1. 生成 AGENTS.md(主载体)
|
|
340
|
+
console.log(bold('📋 主载体:AGENTS.md(自动注入)'));
|
|
341
|
+
writeAgentsMd(process.cwd());
|
|
342
|
+
console.log(
|
|
343
|
+
dim(' -> 核心使用规则,Codex/Claude Code/Cursor 等会话自动加载')
|
|
270
344
|
);
|
|
271
|
-
console.log(dim(' → 架构概览、属性透传决策树、渐进用法、反模式'));
|
|
272
345
|
console.log('');
|
|
273
346
|
|
|
274
|
-
// 2. 生成
|
|
275
|
-
console.log(bold('📖
|
|
276
|
-
const
|
|
347
|
+
// 2. 生成 Skills(标准结构:SKILL.md + references/)
|
|
348
|
+
console.log(bold('📖 参考载体:.agents/skills/(按需调取)'));
|
|
349
|
+
const skillDir = path.join(process.cwd(), '.agents/skills', PKG_SHORT);
|
|
350
|
+
const skillRefsDir = path.join(skillDir, 'references');
|
|
351
|
+
|
|
352
|
+
// SKILL.md(入口:frontmatter + 速查内容 + 参考导航)
|
|
277
353
|
writeFileWithLog(
|
|
278
|
-
path.join(
|
|
279
|
-
|
|
280
|
-
`.agents/
|
|
354
|
+
path.join(skillDir, 'SKILL.md'),
|
|
355
|
+
getSkillMainContent(),
|
|
356
|
+
`.agents/skills/${PKG_SHORT}/SKILL.md`
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
// references/README.md(完整使用文档)
|
|
360
|
+
const readme = getReadmeContent();
|
|
361
|
+
if (readme) {
|
|
362
|
+
writeFileWithLog(
|
|
363
|
+
path.join(skillRefsDir, 'README.md'),
|
|
364
|
+
readme,
|
|
365
|
+
`.agents/skills/${PKG_SHORT}/references/README.md`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// references/api.md(结构化 API 元数据)
|
|
370
|
+
const apiJson = getApiJsonContent();
|
|
371
|
+
if (apiJson && apiJson.api && apiJson.api.length > 0) {
|
|
372
|
+
writeFileWithLog(
|
|
373
|
+
path.join(skillRefsDir, 'api.md'),
|
|
374
|
+
getSkillApiContent(),
|
|
375
|
+
`.agents/skills/${PKG_SHORT}/references/api.md`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
console.log(
|
|
380
|
+
dim(' -> SKILL.md 入口 + references/ 完整文档,skills 工具按需逐层调取')
|
|
281
381
|
);
|
|
282
|
-
console.log(dim(' → 完整 README 文档 + 结构化 API 元数据'));
|
|
283
382
|
console.log('');
|
|
284
383
|
|
|
285
384
|
// 3. 完成提示
|
|
286
|
-
console.log(green('✅
|
|
385
|
+
console.log(green('✅ 完成!已生成双载体 AI 上下文文件。'));
|
|
287
386
|
console.log('');
|
|
288
387
|
console.log(`${bold('📂 生成的文件:')}`);
|
|
289
|
-
console.log(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
console.log(`
|
|
293
|
-
console.log(
|
|
388
|
+
console.log(
|
|
389
|
+
` ${cyan('AGENTS.md')} ${dim('← 核心规则(AI 自动读取)')}`
|
|
390
|
+
);
|
|
391
|
+
console.log(` ${cyan('.agents/skills/' + PKG_SHORT + '/')}`);
|
|
392
|
+
console.log(
|
|
393
|
+
` ├── ${cyan('SKILL.md')} ${dim('← skills 入口(速查 + 导航)')}`
|
|
394
|
+
);
|
|
395
|
+
console.log(` └── ${cyan('references/')}`);
|
|
396
|
+
console.log(
|
|
397
|
+
` ├── ${cyan('README.md')} ${dim('← 完整使用文档')}`
|
|
398
|
+
);
|
|
399
|
+
if (apiJson && apiJson.api && apiJson.api.length > 0) {
|
|
400
|
+
console.log(
|
|
401
|
+
` └── ${cyan('api.md')} ${dim('← 结构化 API 元数据')}`
|
|
402
|
+
);
|
|
403
|
+
}
|
|
294
404
|
console.log('');
|
|
295
|
-
|
|
296
|
-
console.log(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
console.log(
|
|
300
|
-
|
|
405
|
+
console.log(`${bold('🔄 说明:')}`);
|
|
406
|
+
console.log(
|
|
407
|
+
` - AGENTS.md 已用标记区块写入,重复执行 init-ai 可安全更新(不破坏其他库的指令)`
|
|
408
|
+
);
|
|
409
|
+
console.log(
|
|
410
|
+
` - 编写 Field 中输入控件属性前,查阅 element-plus 官方文档:${cyan('https://element-plus.org')}`
|
|
411
|
+
);
|
|
301
412
|
console.log('');
|
|
302
413
|
}
|
|
303
414
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qin-ui/element-plus-pro",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "基于 element-plus 的二次封装组件",
|
|
5
5
|
"bin": {
|
|
6
6
|
"element-plus-pro": "./bin/init-ai.mjs"
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"vue": "^3.5.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"
|
|
41
|
+
"vue-component-type-helpers": "^3.2.5",
|
|
42
|
+
"@qin-ui/pro-components-core": "^1.0.4"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"element-plus": "^2.13.6"
|
|
45
|
-
"vue-component-type-helpers": "^3.2.5"
|
|
45
|
+
"element-plus": "^2.13.6"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": [
|
|
48
48
|
"**/*.css",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"node": ">=18"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"prebuild": "tsx ../../scripts/generate-api-json.ts element-plus-pro",
|
|
59
|
+
"prebuild": "tsx ../../scripts/generate-api-json.ts element-plus-pro && tsx ../../scripts/generate-init-ai.ts element-plus-pro",
|
|
60
60
|
"build": "vue-tsc --noEmit && vite build"
|
|
61
61
|
}
|
|
62
62
|
}
|