wucaishi-generative-react-skill 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.
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: upload-aliyun-oss-zh
3
+ description: 当任务涉及发布组件包、打包发布后的上传、上传发布、上传当前项目 dist 到阿里云 OSS、调用 OSS presign、保存 H5 组件定义或校验组件线上地址时使用。输出和说明使用中文。
4
+ ---
5
+
6
+ # 阿里云 OSS 文件上传 Skill
7
+
8
+ 这个 Skill 用于把当前项目目录下的 `dist/` 所有文件上传到阿里云 OSS,并在上传成功后调用“新增组件”接口保存组件定义。
9
+
10
+ ## 固定接口
11
+
12
+ ### 1. App 测试登录
13
+
14
+ - 请求:`POST https://prism-stone-pre.byering.com/api/web/auth/login`
15
+ - 请求头:`Content-Type: application/json`、`Accept: application/json`
16
+ - 入参:
17
+
18
+ ```json
19
+ {
20
+ "phone": "登录手机号,必填",
21
+ "password": "登录密码,必填"
22
+ }
23
+ ```
24
+
25
+ - 登录账号:由用户提供,不能使用默认账号
26
+ - 登录密码:由用户提供,不能使用默认密码
27
+ - Token 位置:`entity.accessToken`
28
+ - 后续请求头:`Authorization: Bearer {accessToken}`
29
+
30
+ ### 2. 新版固定前缀 OSS presign
31
+
32
+ - 请求:`GET https://prism-stone-pre.byering.com/api/bean/storage/oss/presign`
33
+ - 请求头:`Authorization: Bearer {accessToken}`、`Accept: application/json`
34
+ - 查询参数:
35
+
36
+ ```json
37
+ {
38
+ "fileName": "文件名,必填,例如 index.html、assets/app.js",
39
+ "prefix": "固定 OSS 目录前缀,例如 h5/components/confirm-dialog/1.0.0",
40
+ "expiresInSeconds": 600,
41
+ "contentType": "文件 MIME,可选,例如 text/html"
42
+ }
43
+ ```
44
+
45
+ - 返回字段使用 `entity.accessId`、`entity.policy`、`entity.signature`、`entity.host`、`entity.dir`、`entity.objectKey`、`entity.publicUrl`、`entity.contentType`。
46
+
47
+ ### 3. 新增组件
48
+
49
+ - 请求:`POST https://prism-stone-pre.byering.com/api/admin/deliverable-h5-components/create`
50
+ - 请求头:`Authorization: Bearer {accessToken}`、`Content-Type: application/json`、`Accept: application/json`
51
+ - 请求体来自当前项目根目录下的 `src/manifest.json`
52
+ - 必填字段:`name`、`description`、`version`、`props`
53
+ - `name` 字段必须使用 `<中文场景或模板>_<中文组件名>_<english_component_code>`,例如 `会议总结_一句话看懂_meeting_minutes_summary`,不能只使用纯英文机器名。
54
+ - `source` 字段必须使用 OSS 上传成功后的入口文件公网地址,不能使用带签名参数的临时 URL。
55
+ - `props` 字段来自 `src/manifest.json`;如果某个 prop 的 `default` 是数组或对象,提交平台前必须转换为 JSON 字符串,避免平台保存为空字符串。
56
+ - 每个发布到平台的 prop 都必须显式提供 `default` 字段。缺失 `default` 时不要发布,因为平台可能保存为 `null`,导致远程渲染时组件收到 `null` 后报错。
57
+ - 平台发布用 `props` 只描述业务可配置输入,不应包含 React 运行控制或样式扩展字段,例如 `className`、`open`、`collapsed`、`onOpenChange`、`onCollapsedChange`、任意函数类型 `onXxx`。
58
+
59
+ ## 适用场景
60
+
61
+ 当用户要求:
62
+
63
+ - 上传阿里云 OSS 文件
64
+ - 上传当前项目的 `dist/`
65
+ - 调用 presign 后直传 OSS
66
+ - 发布静态构建产物到 OSS
67
+ - 发布组件包
68
+ - 打包发布后的上传
69
+ - 上传发布
70
+ - 上传成功后新增 H5 组件定义
71
+
72
+ ## 执行规则
73
+
74
+ 1. 默认只处理当前项目根目录的 `dist/`。
75
+ 2. 必须遍历并上传 `dist/` 下所有普通文件,保持相对目录结构。
76
+ 3. 每个文件都要单独调用 presign,`fileName` 使用该文件相对 `dist/` 的路径,例如 `index.html`、`assets/app.js`。
77
+ 4. `prefix` 默认动态生成,格式固定为:`h5/components/{package.json 的 name}/{package.json 的 version}`。
78
+ 5. 使用 presign 返回的 `host` 和表单字段执行阿里云 OSS POST 上传,并设置对象 ACL 为公网可读。
79
+ 6. POST 表单必须包含 `key`、`OSSAccessKeyId`、`policy`、`Signature`、`success_action_status=200`、`Content-Type`、`x-oss-object-acl=public-read` 和文件内容。
80
+ 7. 上传完成后取入口文件公网地址:优先 `index.html`,否则取第一个上传文件;如果 presign 返回的是带签名临时 URL,必须去掉 query/hash,只保存不带签名的公网地址。
81
+ 8. 调用 `POST /admin/deliverable-h5-components/create` 新增组件,参数来自 `src/manifest.json`,其中 `source` 必须覆盖为第 7 步得到的 OSS 地址;发布前必须校验每个 prop 都有 `default`;`props[*].default` 如为数组或对象,必须在请求体中转换为 JSON 字符串,例如 `"default": "[{\"fitDimension\":\"AI 应用\"}]"`。
82
+ 9. 全部完成后输出文件数量、总大小、入口文件地址、所有文件的 objectKey/publicUrl 和新增组件记录。
83
+
84
+ ## 上传前检查
85
+
86
+ - 如果 `dist/` 不存在或为空,先停止并说明原因。
87
+ - 如果 `src/manifest.json` 不存在,先停止并说明原因。
88
+ - `src/manifest.json` 必须具备 `name`、`description`、`version`、`props` 字段。
89
+ - `src/manifest.json` 的 `name` 必须使用 `<中文场景或模板>_<中文组件名>_<english_component_code>`;`english_component_code` 只能包含小写英文、数字和下划线。
90
+ - `props` 必须是非空数组。
91
+ - `props` 中每一项必须有非缺失的 `default` 字段。允许 `default` 为 `""`、`false`、`0`、`[]` 或 `{}`,但不允许省略字段;数组或对象默认值提交平台前必须转换成 JSON 字符串。
92
+ - `props` 中不允许包含 React 运行控制字段或函数回调字段:`className`、`style`、`open`、`collapsed`、`onOpenChange`、`onCollapsedChange`、任何 `onXxx` 函数类型字段。此类字段可以存在于组件 TypeScript Props 中,但不应进入平台配置 manifest。
93
+ - 上传前检查文本文件中是否包含 `file://` 或本机绝对路径;发现后停止上传。
94
+ - 如果 HTML/CSS/JS 中出现 `/assets/...` 这类站点根路径,应提示用户它可能无法在子目录访问,但不强制阻止上传。
95
+ - 如果用户没有提供 `prefix`,必须读取当前项目根目录下的 `package.json`,并使用 `name`、`version` 生成:`h5/components/{name}/{version}`。
96
+ - 如果当前仓库根目录下有多个组件目录,应使用 `--project-root 组件目录` 指定要上传的组件;脚本会读取该目录下的 `package.json` 和 `dist/`。
97
+ - 如果 `package.json` 不存在,或缺少 `name` / `version`,先停止并说明原因,不要编造路径。
98
+ - `src/manifest.json` 中的 `version` 必须与 `package.json` 中的 `version` 一致。
99
+ - `src/manifest.json` 中的 `name` 是组件展示名称,可以与 `package.json` 的机器包名不同;如果 `manifest.json` 显式提供 `packageName`,则 `packageName` 必须与 `package.json` 的 `name` 一致。
100
+ - 上传前如果没有可用的 `COMPONENT_AUTH_TOKEN`,先读取本地已保存的登录账号和密码;如果本地没有,再提示用户输入登录账号和密码。
101
+ - 用户提供账号密码后,先登录获取 Bearer Token;登录成功后把账号和密码保存到本地,供后续相关操作直接使用。
102
+ - 本地凭据保存路径固定为 `~/.wucaishi-component-workflow/auth.json`,文件权限应限制为 `600`。
103
+ - 不要在 skill、脚本或命令示例中写入默认账号、默认密码或个人凭据。
104
+
105
+ ## 推荐命令
106
+
107
+ 在项目根目录执行:
108
+
109
+ ```bash
110
+ node .agents/skills/component-package-workflow-zh/subskills/upload-aliyun-oss-zh/scripts/upload_dist_to_aliyun_oss.mjs \
111
+ --phone "登录账号" \
112
+ --password "登录密码"
113
+ ```
114
+
115
+ 如果本地已经保存过账号密码,后续可直接执行:
116
+
117
+ ```bash
118
+ node .agents/skills/component-package-workflow-zh/subskills/upload-aliyun-oss-zh/scripts/upload_dist_to_aliyun_oss.mjs
119
+ ```
120
+
121
+ 在仓库根目录上传某个组件目录:
122
+
123
+ ```bash
124
+ node .agents/skills/component-package-workflow-zh/subskills/upload-aliyun-oss-zh/scripts/upload_dist_to_aliyun_oss.mjs \
125
+ --project-root ./confirm-dialog \
126
+ --phone "登录账号" \
127
+ --password "登录密码"
128
+ ```
129
+
130
+ 如果确实需要手动覆盖 prefix:
131
+
132
+ ```bash
133
+ node .agents/skills/component-package-workflow-zh/subskills/upload-aliyun-oss-zh/scripts/upload_dist_to_aliyun_oss.mjs \
134
+ --prefix "h5/components/confirm-dialog/1.0.0" \
135
+ --phone "登录账号" \
136
+ --password "登录密码"
137
+ ```
138
+
139
+ ## 输出要求
140
+
141
+ - 全程使用中文说明。
142
+ - 上传前说明登录账号、API 域名、dist 路径和 OSS prefix。
143
+ - 上传失败时打印 HTTP 状态码和响应体。
144
+ - 新增组件接口失败时打印 HTTP 状态码和响应体,不要宣称发布完成。
145
+ - 成功后返回 `index.html` 的公网访问地址;如果没有 `index.html`,返回第一个上传文件的公网访问地址,并返回新增组件记录。
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "阿里云 OSS 上传"
3
+ short_description: "登录预发并上传 dist 全量文件到 OSS"
4
+ brand_color: "#1677FF"
5
+ default_prompt: "Use $upload-aliyun-oss-zh to upload the current project's dist directory to Aliyun OSS."
6
+ policy:
7
+ allow_implicit_invocation: true