@round2ai/r2-cli 1.0.12-beta.1 → 1.0.12-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@round2ai/r2-cli",
3
- "version": "1.0.12-beta.1",
3
+ "version": "1.0.12-beta.2",
4
4
  "description": "R2-CLI,向 AI 开放二手潮奢交易全链路能力",
5
5
  "main": "dist/r2-cli.js",
6
6
  "type": "module",
@@ -1,63 +1,20 @@
1
1
  /**
2
- * postinstall: skills/ 复制到 ~/.agents/skills/
2
+ * postinstall: 通过 skills CLI 将本地 skills 安装到所有 Agent 目录
3
+ * 自动适配 Claude Code / Codex / Gemini CLI 等所有 Agent
3
4
  */
4
5
 
5
- import fs from "node:fs";
6
+ import { execSync } from "node:child_process";
6
7
  import path from "node:path";
7
- import os from "node:os";
8
8
  import { fileURLToPath } from "node:url";
9
9
 
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
- const pkgSkillsDir = path.join(__dirname, "..", "skills");
12
- const agentsDir = path.join(os.homedir(), ".agents", "skills");
13
-
14
- if (!fs.existsSync(pkgSkillsDir)) process.exit(0);
15
-
16
- fs.mkdirSync(agentsDir, { recursive: true });
17
-
18
- for (const name of fs.readdirSync(pkgSkillsDir)) {
19
- const rawSrc = path.join(pkgSkillsDir, name);
20
- let src;
21
- try { src = fs.realpathSync(rawSrc); } catch { continue; }
22
- if (!fs.statSync(src).isDirectory()) continue;
23
-
24
- const dest = path.join(agentsDir, name);
25
- if (fs.existsSync(dest)) {
26
- for (const old of fs.readdirSync(dest)) {
27
- const oldPath = path.join(dest, old);
28
- fs.statSync(oldPath).isDirectory()
29
- ? fs.rmSync(oldPath, { recursive: true })
30
- : fs.unlinkSync(oldPath);
31
- }
32
- }
33
- fs.mkdirSync(dest, { recursive: true });
34
-
35
- for (const file of fs.readdirSync(src)) {
36
- const fileSrc = path.join(src, file);
37
- const fileDest = path.join(dest, file);
38
- if (fs.statSync(fileSrc).isDirectory()) {
39
- copyDir(fileSrc, fileDest);
40
- } else {
41
- fs.copyFileSync(fileSrc, fileDest);
42
- }
43
- }
44
- }
45
-
46
- function copyDir(src, dest) {
47
- if (fs.existsSync(dest)) {
48
- for (const old of fs.readdirSync(dest)) {
49
- const oldPath = path.join(dest, old);
50
- fs.statSync(oldPath).isDirectory()
51
- ? fs.rmSync(oldPath, { recursive: true })
52
- : fs.unlinkSync(oldPath);
53
- }
54
- }
55
- fs.mkdirSync(dest, { recursive: true });
56
- for (const file of fs.readdirSync(src)) {
57
- const fileSrc = path.join(src, file);
58
- const fileDest = path.join(dest, file);
59
- fs.statSync(fileSrc).isDirectory()
60
- ? copyDir(fileSrc, fileDest)
61
- : fs.copyFileSync(fileSrc, fileDest);
62
- }
11
+ const skillsDir = path.join(__dirname, "..", "skills");
12
+
13
+ try {
14
+ execSync(`npx skills add "${skillsDir}" --all`, {
15
+ stdio: "inherit",
16
+ timeout: 60_000,
17
+ });
18
+ } catch {
19
+ // 网络不可用或 skills CLI 失败时静默跳过
63
20
  }
@@ -118,7 +118,7 @@ metadata:
118
118
  5. **汇总展示**:自动填充的字段标 ✅,缺失字段标 ❓ 让用户补充
119
119
  6. **提交**:`hang-up submit` — 必填:`shop-id`、`title`、`price`、`category-id`、`channel-cat-id`、`image-ids`、`stuff-status`、`desc`、`out-item-no`
120
120
 
121
- **核心原则**:**图片里能看到的,就别问用户**。只问价格和商家编码,其他全部从图片自动提取。
121
+ **核心原则**:**图片里能看到的,就别问用户**。只问价格和商家编码(优先用户自定义,不填则推荐自动生成),其他全部从图片自动提取。
122
122
 
123
123
  **关键注意事项**:
124
124
  - **品牌必须双传**:`--brand-name` + itemAttrs 中的一项(含 propId/valueId/valueName),缺一不可
@@ -4,13 +4,14 @@
4
4
 
5
5
  挂售模式支持完整商品信息:图片、类目、属性等。与普通上架(`goods up`)是不同流程。
6
6
 
7
- **核心理念**:**图片里能看到的,就别问用户**。Agent 从图片中提取一切可识别的信息,用户只需要提供价格和商家编码。
7
+ **核心理念**:**图片里能看到的,就别问用户**。Agent 从图片中提取一切可识别的信息,用户只需要提供价格。
8
8
 
9
9
  ## 核心原则
10
10
 
11
11
  - **图片优先**:所有字段优先从图片提取,图片无法识别时才问用户
12
- - 必须问用户的只有:**价格、商家编码**
13
- - **必须问用户的条件**:价格(永远无法从图片判断)和商家编码(用户自定义)。其他一切字段都应尝试从图片获取
12
+ - 必须问用户的只有:**价格**
13
+ - 商家编码(`out-item-no`)**优先让用户自定义**,用户不填则推荐自动生成编码(如 `GS20260512-0005`)
14
+ - **必须问用户的条件**:价格(永远无法从图片判断)。其他一切字段都应尝试从图片获取。商家编码优先用户自定义,不填则推荐自动生成
14
15
  - **描述必须自动生成**:基于 AI 识别的品牌+款式+颜色+材质+货号自动组合,不要标记为"需要补充"
15
16
  - **品牌必须双传**:`--brand-name`(文本字段)+ itemAttrs 中的一项(含 propId/valueId/valueName),缺一不可
16
17
  - **季节自动推断**:根据商品类型推断适用季节(夹克/风衣→春秋季,羽绒服→秋冬季,T恤/短裤→夏季),不需要问用户
@@ -69,7 +70,7 @@ r2-cli goods hang-up upload-images --shop-id <shopId> --files /path/img1.jpg,/pa
69
70
  | `--goods-no`(货号) | ⚠️ | 有标签则读取,无则留空 |
70
71
  | 款式/颜色/材质属性 | ⚠️ | 能识别则自动匹配 propsValues,不能则汇总时问 |
71
72
  | `--price`(售价) | ❌ | **必须问用户** |
72
- | `--out-item-no`(商家编码) | | **必须问用户** |
73
+ | `--out-item-no`(商家编码) | ⚠️ | 先问用户自定义编码,不填则推荐自动生成(如 `GS20260512-0005`) |
73
74
  | `--shop-id`(店铺) | ❌ | 只有一个店铺时自动选,多个则问 |
74
75
 
75
76
  **成色判断映射**:
@@ -209,7 +210,7 @@ r2-cli goods hang-up submit \
209
210
  | 缺失字段 | 何时询问 | 询问方式 |
210
211
  |----------|----------|----------|
211
212
  | `--price`(售价) | 上传图片时 | "这个商品上架价格是多少?" |
212
- | `--out-item-no`(商家编码) | 上传图片时 | "商家编码是什么?(同店铺唯一标识)" |
213
+ | `--out-item-no`(商家编码) | 上传图片时 | 先问:"商家编码是什么?"用户不填则推荐自动生成编码 |
213
214
  | `--shop-id`(店铺) | 流程开始时 | 展示店铺列表让用户选择 |
214
215
  | `--title`(标题) | 图片识别无法生成时 | "商品标题用什么?" |
215
216
  | `--desc`(描述) | 图片识别无法生成时 | "商品描述?" |