@sea-ecommerce/admin-mcp-server 0.2.3 → 0.3.1
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/README.md +17 -2
- package/dist/derlux-admin-mcp.js +189 -37
- package/package.json +3 -1
- package/skill/SKILL.md +67 -7
- package/skill//345/267/245/345/205/267/345/217/202/346/225/260/345/217/202/350/200/203.md +24 -9
- package/skill//350/277/220/350/220/245/344/272/272/345/221/230/346/211/213/345/206/214/03-/345/225/206/345/223/201/347/256/241/347/220/206.md +16 -1
- package/skill//350/277/220/350/220/245/345/217/202/350/200/203.md +4 -2
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
| 「把这 5 款新品一次性录进后台,价格按 MYR / IDR 两列、四语齐全,先给我整批预览」 | 走批量通道:一份每款一行的预览 + `confirm_token`,一次确认整批写入(`batch_import_products`) |
|
|
56
56
|
| 「把 DR.CYJ Hair Filler 在马来西亚站的价格改成 RM 399,印尼站价格别动」 | 预览多币种价格变更(`update_product_prices`),金额按主单位,不写成分 |
|
|
57
57
|
| 「给 `summer-serum` 补上马来语、印尼语的标题描述,再补一份中文详情页图文」 | 补翻译与详情页富内容块(`set_translations` / `create_product_content`) |
|
|
58
|
+
| 「这款商品的英文详情页我录好了,按原版式翻成中文、马来文、印尼文(大图、规格、图集都带上)」 | 读源语言 `blocks[]` → 只翻文案、块结构与图片 URL 原样保留 → 逐语言预览(已有稿会标出 `existing`/`diff`,覆盖需你确认)再写入;旧稿覆盖前自动备份 |
|
|
59
|
+
| 「规格名和规格取值也翻一下」 | 写选项名/取值的多语言译文(`product_option.title` / `product_option_value.value`),字段写错会直接报错 |
|
|
58
60
|
| 「给默认仓的 DR.CYJ Hair Filler 补 50 件库存」 | 预览库存调整,幂等可重放,确认后生效(`set_product_stock`) |
|
|
59
61
|
| 「handle 是 `summer-serum` 的商品先下架」 | 预览下架(置为 `archived`),不影响历史订单(`deactivate_product`) |
|
|
60
62
|
| 「DR.CYJ Hair Filler 准备正式上架,按上线清单帮我逐项核对:四语翻译、四语详情页、库存、销售渠道、图片,全绿再告诉我」 | 逐项只读核对;只有你明确确认后才切「已发布」(`update_product`) |
|
|
@@ -107,11 +109,11 @@
|
|
|
107
109
|
| `create_product_category` / `update_product_category` / `delete_product_category` | 增 / 改 / 删产品分类(含父级、启用状态、metadata 合并、多语言) | 写(dry_run 默认) |
|
|
108
110
|
| `get_collection` | 读系列详情(列表用 `list_collections`) | 读 |
|
|
109
111
|
| `create_collection` / `update_collection` / `delete_collection` | 增 / 改 / 删产品系列(含 metadata 合并、多语言) | 写(dry_run 默认) |
|
|
110
|
-
| `get_translations` |
|
|
112
|
+
| `get_translations` | 查多语言翻译(商品 title/subtitle/description,选项与取值按实体字段原样返回,默认不截断) | 读 |
|
|
111
113
|
| `create_product` / `update_product` / `deactivate_product` | 增 / 改 / 下线商品(含图片、SKU、渠道、物理/海关字段、metadata 合并) | 写(dry_run 默认) |
|
|
112
114
|
| `update_product_prices` | 替换变体价格(多币种) | 写(dry_run 默认) |
|
|
113
115
|
| `upload_product_image` / `add_product_to_sales_channel` | 追加图片 / 挂渠道 | 写(dry_run 默认) |
|
|
114
|
-
| `create_product_content` / `get_product_content` | 详情页富内容块(hero/richtext/specs/图集/faq/video
|
|
116
|
+
| `create_product_content` / `get_product_content` | 详情页富内容块(hero/richtext/specs/图集/faq/video);整块替换,目标语言已有内容须显式 `overwrite=true` 并自动备份旧稿 | 写 / 读 |
|
|
115
117
|
| `set_product_stock` | 给商品建仓/改库存(自动建库存条目 + 关联变体,幂等) | 写(dry_run 默认) |
|
|
116
118
|
| `list_stock_locations` / `create_stock_location` | 列 / 增仓库 | 写(dry_run 默认) |
|
|
117
119
|
| `get_inventory_levels` / `update_inventory_level` | 查 / 改库存水平 | 写(dry_run 默认) |
|
|
@@ -220,6 +222,19 @@ npx -y github:<org>/<repo> # 精简 git 仓库
|
|
|
220
222
|
- **审计**:每次调用写入 `~/.derlux/mcp-audit.log`。
|
|
221
223
|
- **最小权限**:用受限的 `csr` 账号即可,敏感动作由后端 RBAC 拦截。
|
|
222
224
|
|
|
225
|
+
## 更新日志
|
|
226
|
+
|
|
227
|
+
### 0.3.0(行为变更,升级后请先看这条)
|
|
228
|
+
|
|
229
|
+
- **`create_product_content` 增加覆盖门禁**:该接口本就是整块替换。现在目标语言已有内容时,`confirm=true` 必须显式带 `overwrite=true` 才写入,否则报错并回传 `existing` / `diff`;覆盖前自动备份旧块到 `~/.derlux/content-backups/`(`backup=false` 可关)。dry_run 也会返回 `existing` 与块类型差异。
|
|
230
|
+
- **`set_translations` 字段按实体校验**:product→`title/subtitle/description`、product_option→`title`、**product_option_value→`value`**、product_category→`name/description`、product_collection→`title`、shipping_option→`name`。写错字段现在直接报错(旧版会被静默丢弃,可能落一条空译文)。
|
|
231
|
+
- **`get_translations` 返回完整字段**:不再只给 title + 截断的 description,改为 `{ locale_code, field_keys, ...原样字段 }`;新增 `max_chars`(默认 0 = 不截断)。
|
|
232
|
+
- **新增「多语言同步」SOP**:把已录入的英文详情页稿按原版式翻成 zh/ms/id(含大图、规格、图集),含翻译边界与规格(选项/取值)多语言写法,见 `skill/SKILL.md`。
|
|
233
|
+
|
|
234
|
+
### 0.2.3 及更早
|
|
235
|
+
|
|
236
|
+
见 npm 版本历史与 `skill/SKILL.md` 工具速查表。
|
|
237
|
+
|
|
223
238
|
## 注意事项 / 待核对
|
|
224
239
|
|
|
225
240
|
- 本包**不改动任何数据库 schema**,仅复用现有 `/admin/*` 接口;运营动作本身会按既有逻辑写库。
|
package/dist/derlux-admin-mcp.js
CHANGED
|
@@ -21841,6 +21841,13 @@ function buildQuery(params) {
|
|
|
21841
21841
|
const sp = new URLSearchParams();
|
|
21842
21842
|
for (const [k, v] of Object.entries(params)) {
|
|
21843
21843
|
if (v === void 0 || v === null || v === "") continue;
|
|
21844
|
+
if (Array.isArray(v)) {
|
|
21845
|
+
for (const item of v) {
|
|
21846
|
+
if (item === void 0 || item === null || item === "") continue;
|
|
21847
|
+
sp.append(`${k}[]`, String(item));
|
|
21848
|
+
}
|
|
21849
|
+
continue;
|
|
21850
|
+
}
|
|
21844
21851
|
sp.set(k, String(v));
|
|
21845
21852
|
}
|
|
21846
21853
|
const s = sp.toString();
|
|
@@ -22495,6 +22502,11 @@ var contextTools = [
|
|
|
22495
22502
|
}
|
|
22496
22503
|
];
|
|
22497
22504
|
|
|
22505
|
+
// src/tools/products.ts
|
|
22506
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
22507
|
+
import { homedir as homedir2 } from "node:os";
|
|
22508
|
+
import { join as join2 } from "node:path";
|
|
22509
|
+
|
|
22498
22510
|
// src/tools/stock.ts
|
|
22499
22511
|
async function applyProductStock(ctx2, opts) {
|
|
22500
22512
|
const { client: client2 } = ctx2;
|
|
@@ -22700,6 +22712,18 @@ location_id \u53EF\u9009\uFF1A\u4F20\u4E86\u5219\u53EA\u56DE\u8BE5\u4ED3\u5E93\u
|
|
|
22700
22712
|
];
|
|
22701
22713
|
|
|
22702
22714
|
// src/tools/translations.ts
|
|
22715
|
+
var TRANSLATION_FIELDS = {
|
|
22716
|
+
product: ["title", "subtitle", "description"],
|
|
22717
|
+
product_option: ["title"],
|
|
22718
|
+
product_option_value: ["value"],
|
|
22719
|
+
product_category: ["name", "description"],
|
|
22720
|
+
product_collection: ["title"],
|
|
22721
|
+
shipping_option: ["name"]
|
|
22722
|
+
};
|
|
22723
|
+
var DEFAULT_TRANSLATION_FIELDS = ["title", "subtitle", "description"];
|
|
22724
|
+
function allowedTranslationFields(reference) {
|
|
22725
|
+
return TRANSLATION_FIELDS[reference] ?? DEFAULT_TRANSLATION_FIELDS;
|
|
22726
|
+
}
|
|
22703
22727
|
function canonLocaleKey(locale) {
|
|
22704
22728
|
return normalizeLocale(locale) ?? locale;
|
|
22705
22729
|
}
|
|
@@ -22743,23 +22767,37 @@ async function upsertTranslations(client2, reference, referenceId, entries) {
|
|
|
22743
22767
|
var translationTools = [
|
|
22744
22768
|
{
|
|
22745
22769
|
name: "set_translations",
|
|
22746
|
-
description: `\u4E3A\u5B9E\u4F53\uFF08\u5546\u54C1\
|
|
22770
|
+
description: `\u4E3A\u5B9E\u4F53\uFF08\u5546\u54C1\u3001\u9009\u9879\u540D\u3001\u9009\u9879\u53D6\u503C\u3001\u5206\u7C7B\u3001\u7CFB\u5217\u3001\u914D\u9001\u65B9\u5F0F\uFF09**\u521B\u5EFA\u6216\u66F4\u65B0\uFF08upsert\uFF09**\u591A\u8BED\u8A00\u7FFB\u8BD1\uFF0C\u8D70 /admin/translations/batch\u3002
|
|
22747
22771
|
upsert \u8BED\u4E49\uFF1A\u540C\u8BED\u8A00\u5DF2\u6709\u7FFB\u8BD1 \u2192 \u66F4\u65B0\uFF08\u5B57\u6BB5\u5408\u5E76\uFF0C\u672A\u7ED9\u7684\u65E7\u5B57\u6BB5\u4FDD\u7559\uFF0C\u7EDD\u4E0D\u4EA7\u751F\u91CD\u590D\u884C\uFF09\uFF1B\u6CA1\u6709 \u2192 \u65B0\u5EFA\u3002
|
|
22772
|
+
\u26A0\uFE0F \u5199\u5165\u5B57\u6BB5\u6309 reference \u767D\u540D\u5355\u6821\u9A8C\uFF0C\u5199\u9519\u5B57\u6BB5\u4F1A**\u76F4\u63A5\u62A5\u9519**\u800C\u4E0D\u662F\u9759\u9ED8\u5B58\u6210\u65E0\u4EBA\u8BFB\u53D6\u7684\u952E\uFF1A
|
|
22773
|
+
- product \u2192 title / subtitle / description\uFF1B
|
|
22774
|
+
- product_option\uFF08\u9009\u9879\u540D\uFF09\u2192 title\uFF1B
|
|
22775
|
+
- product_option_value\uFF08\u9009\u9879\u53D6\u503C\uFF0C\u5982 ALC / Penhold\uFF09\u2192 **value**\uFF08\u4E0D\u662F title\uFF01\uFF09\uFF1B
|
|
22776
|
+
- product_category \u2192 name / description\uFF1Bproduct_collection \u2192 title\uFF1Bshipping_option \u2192 name\u3002
|
|
22748
22777
|
\u26A0\uFE0F locale \u952E\u63A5\u53D7\u77ED\u7801\uFF08en/zh/ms/id\uFF09\u6216 BCP-47 \u533A\u57DF\u7801\uFF08en-US/zh-CN/ms-MY/id-ID\uFF09\uFF0C\u5DE5\u5177\u7EDF\u4E00\u5F52\u4E00\u5316\u4E3A BCP-47 \u843D\u5E93\u2014\u2014
|
|
22749
22778
|
storefront \u5BF9\u7FFB\u8BD1\u63A5\u53E3\u4E00\u5F8B\u8BF7\u6C42 BCP-47\u3001\u4E0E\u5E93\u4E2D locale_code \u7CBE\u786E\u5339\u914D\uFF1B\u5386\u53F2\u6309\u77ED\u7801\u843D\u5E93\u7684\u884C\u4F1A\u88AB\u672C\u6B21\u8C03\u7528**\u6539\u7801\u4FEE\u590D**\u3002
|
|
22750
|
-
\
|
|
22779
|
+
\u5B57\u6BB5\u503C\u4F20\u7A7A\u5B57\u7B26\u4E32 = \u628A\u8BE5\u5B57\u6BB5\u8BD1\u6587\u7F6E\u7A7A\uFF08\u5199\u5165\u540E\u8BF7\u7528 get_translations \u56DE\u8BFB\u786E\u8BA4\uFF0C\u5220\u9664\u6574\u6761\u8BD1\u6587\u8BF7\u5230\u540E\u53F0\u64CD\u4F5C\uFF09\u3002
|
|
22780
|
+
\u7528\u9014\uFF1A\u5546\u54C1\u521B\u5EFA\u540E\u8865\u7FFB\u8BD1/\u6539\u7FFB\u8BD1/\u4FEE\u590D\u591A\u8BED\u8A00\uFF1B\u628A\u82F1\u6587\u7A3F\u7FFB\u597D\u540E\u540C\u6B65\u5230\u5176\u4ED6\u8BED\u8A00\u3002
|
|
22781
|
+
\u9ED8\u8BA4 dry_run\uFF08confirm=false\uFF09\u9884\u89C8\u5C06\u521B\u5EFA/\u66F4\u65B0\u54EA\u4E9B\u884C\u3002`,
|
|
22751
22782
|
schema: {
|
|
22752
|
-
reference: external_exports.string().default("product").describe("\u5B9E\u4F53\u7C7B\u578B\
|
|
22753
|
-
reference_id: external_exports.string().describe("\u5B9E\u4F53 id\uFF1B\u5546\u54C1\u53EF\u4F20 handle\uFF08\u81EA\u52A8\u89E3\u6790\u4E3A id\uFF09"),
|
|
22754
|
-
translations: external_exports.record(external_exports.string(), external_exports.
|
|
22755
|
-
title: external_exports.string().optional(),
|
|
22756
|
-
subtitle: external_exports.string().optional(),
|
|
22757
|
-
description: external_exports.string().optional()
|
|
22758
|
-
})).describe('locale \u2192 \u7FFB\u8BD1\u5B57\u6BB5\uFF0C\u5982 {"zh-CN":{"title":"...","description":"..."}}\uFF1B\u77ED\u7801/\u533A\u57DF\u7801\u5747\u53EF'),
|
|
22783
|
+
reference: external_exports.string().default("product").describe("\u5B9E\u4F53\u7C7B\u578B\uFF1Aproduct / product_option / product_option_value / product_category / product_collection / shipping_option"),
|
|
22784
|
+
reference_id: external_exports.string().describe("\u5B9E\u4F53 id\uFF1B\u5546\u54C1\u53EF\u4F20 handle\uFF08\u81EA\u52A8\u89E3\u6790\u4E3A id\uFF09\uFF1B\u9009\u9879\u4E0E\u9009\u9879\u53D6\u503C\u987B\u4F20\u771F\u5B9E id"),
|
|
22785
|
+
translations: external_exports.record(external_exports.string(), external_exports.record(external_exports.string(), external_exports.string())).describe('locale \u2192 \u7FFB\u8BD1\u5B57\u6BB5\uFF0C\u5982 {"zh-CN":{"title":"...","description":"..."}}\uFF1B\u5B57\u6BB5\u540D\u987B\u5339\u914D reference\uFF08\u9009\u9879\u53D6\u503C\u7528 value\uFF09\u3002\u77ED\u7801/\u533A\u57DF\u7801\u5747\u53EF'),
|
|
22759
22786
|
confirm: external_exports.boolean().default(false)
|
|
22760
22787
|
},
|
|
22761
22788
|
async run(input, { client: client2 }) {
|
|
22762
22789
|
let refId = String(input.reference_id).trim();
|
|
22790
|
+
const allowed = allowedTranslationFields(input.reference);
|
|
22791
|
+
const badFields = Array.from(
|
|
22792
|
+
new Set(
|
|
22793
|
+
Object.values(input.translations ?? {}).flatMap(
|
|
22794
|
+
(t) => Object.keys(t ?? {}).filter((k) => !allowed.includes(k))
|
|
22795
|
+
)
|
|
22796
|
+
)
|
|
22797
|
+
);
|
|
22798
|
+
if (badFields.length) {
|
|
22799
|
+
return `\u9519\u8BEF\uFF1Areference "${input.reference}" \u4E0D\u652F\u6301\u7FFB\u8BD1\u5B57\u6BB5 ${badFields.join(" / ")}\uFF1B\u5141\u8BB8\u7684\u5B57\u6BB5\u662F ${allowed.join(" / ")}\u3002${input.reference === "product_option_value" ? "\u9009\u9879\u53D6\u503C\uFF08\u5982 ALC / Penhold\uFF09\u7684\u8BD1\u6587\u5217\u540D\u662F value \u800C\u4E0D\u662F title\u3002" : ""}`;
|
|
22800
|
+
}
|
|
22763
22801
|
if (input.reference === "product" && !/^prod_[a-z0-9]+$/i.test(refId)) {
|
|
22764
22802
|
const id = await client2.resolveProductId(refId);
|
|
22765
22803
|
if (!id) return `\u9519\u8BEF\uFF1A\u627E\u4E0D\u5230\u5546\u54C1 "${refId}"\uFF08\u8BF7\u4F20\u5546\u54C1 id \u6216\u6709\u6548 handle\uFF09`;
|
|
@@ -22772,6 +22810,10 @@ storefront \u5BF9\u7FFB\u8BD1\u63A5\u53E3\u4E00\u5F8B\u8BF7\u6C42 BCP-47\u3001\u
|
|
|
22772
22810
|
)
|
|
22773
22811
|
}));
|
|
22774
22812
|
if (!entries.length) return "\u9519\u8BEF\uFF1Atranslations \u4E3A\u7A7A\uFF0C\u65E0\u4E8B\u53EF\u505A\u3002";
|
|
22813
|
+
const emptyLocales = entries.filter((e) => Object.keys(e.translations).length === 0).map((e) => e.locale_code);
|
|
22814
|
+
if (emptyLocales.length) {
|
|
22815
|
+
return `\u9519\u8BEF\uFF1Alocale ${emptyLocales.join(" / ")} \u6CA1\u6709\u4EFB\u4F55\u7FFB\u8BD1\u5B57\u6BB5\uFF08\u53EF\u80FD\u5B57\u6BB5\u540D\u5199\u9519\u88AB\u8FC7\u6EE4\uFF09\uFF0C\u5DF2\u4E2D\u6B62\u4EE5\u514D\u5199\u5165\u7A7A\u8BD1\u6587\u884C\u3002\u5141\u8BB8\u7684\u5B57\u6BB5\uFF1A${allowed.join(" / ")}\u3002`;
|
|
22816
|
+
}
|
|
22775
22817
|
const plan = await planTranslationUpsert(client2, input.reference, refId, entries);
|
|
22776
22818
|
if (!input.confirm) {
|
|
22777
22819
|
return {
|
|
@@ -22813,22 +22855,68 @@ var translationShape = external_exports.object({
|
|
|
22813
22855
|
title: external_exports.string().optional(),
|
|
22814
22856
|
description: external_exports.string().optional()
|
|
22815
22857
|
});
|
|
22858
|
+
function summarizeBlocks(blocks) {
|
|
22859
|
+
return { count: blocks.length, types: blocks.map((b) => String(b?.type ?? "unknown")) };
|
|
22860
|
+
}
|
|
22861
|
+
function diffBlockStructure(prev, next) {
|
|
22862
|
+
const tally = (arr) => arr.reduce((m, t) => (m[t] = (m[t] || 0) + 1, m), {});
|
|
22863
|
+
const a = tally(prev);
|
|
22864
|
+
const b = tally(next);
|
|
22865
|
+
const added = [];
|
|
22866
|
+
const removed = [];
|
|
22867
|
+
for (const k of Object.keys(b)) {
|
|
22868
|
+
const d = (b[k] || 0) - (a[k] || 0);
|
|
22869
|
+
if (d > 0) added.push(d > 1 ? `${k}\xD7${d}` : k);
|
|
22870
|
+
}
|
|
22871
|
+
for (const k of Object.keys(a)) {
|
|
22872
|
+
const d = (a[k] || 0) - (b[k] || 0);
|
|
22873
|
+
if (d > 0) removed.push(d > 1 ? `${k}\xD7${d}` : k);
|
|
22874
|
+
}
|
|
22875
|
+
return {
|
|
22876
|
+
types_added: added,
|
|
22877
|
+
types_removed: removed,
|
|
22878
|
+
same_structure: JSON.stringify(prev) === JSON.stringify(next)
|
|
22879
|
+
};
|
|
22880
|
+
}
|
|
22881
|
+
function backupProductContent(productId, locale, status, blocks) {
|
|
22882
|
+
try {
|
|
22883
|
+
const dir = join2(homedir2(), ".derlux", "content-backups");
|
|
22884
|
+
mkdirSync2(dir, { recursive: true });
|
|
22885
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
22886
|
+
const file = join2(dir, `${productId}-${locale}-${status}-${stamp}.json`);
|
|
22887
|
+
writeFileSync2(
|
|
22888
|
+
file,
|
|
22889
|
+
JSON.stringify(
|
|
22890
|
+
{ product_id: productId, locale, status, saved_at: (/* @__PURE__ */ new Date()).toISOString(), blocks },
|
|
22891
|
+
null,
|
|
22892
|
+
2
|
|
22893
|
+
),
|
|
22894
|
+
"utf8"
|
|
22895
|
+
);
|
|
22896
|
+
return file;
|
|
22897
|
+
} catch {
|
|
22898
|
+
return null;
|
|
22899
|
+
}
|
|
22900
|
+
}
|
|
22816
22901
|
var productTools = [
|
|
22817
22902
|
{
|
|
22818
22903
|
name: "list_products",
|
|
22819
|
-
description:
|
|
22904
|
+
description: '\u67E5\u8BE2\u540E\u53F0\u5546\u54C1\u5217\u8868\uFF0C\u652F\u6301\u6309\u5173\u952E\u8BCD q\u3001\u72B6\u6001 status\u3001handle \u8FC7\u6EE4\u3002\u8FD4\u56DE\u4F53\u542B count\uFF08\u6EE1\u8DB3\u6761\u4EF6\u7684\u603B\u6570\uFF0C\u4E0D\u53D7 limit \u5F71\u54CD\uFF09\u3002status \u53EF\u4F20\u5355\u503C\uFF08"published"\uFF09\u6216\u591A\u4E2A\u503C\u7684\u6570\u7EC4\uFF08["published","draft"]\uFF09\u3002',
|
|
22820
22905
|
schema: {
|
|
22821
22906
|
q: external_exports.string().optional(),
|
|
22822
|
-
status: external_exports.enum(PRODUCT_STATUS).optional(),
|
|
22907
|
+
status: external_exports.union([external_exports.enum(PRODUCT_STATUS), external_exports.array(external_exports.enum(PRODUCT_STATUS)).min(1)]).optional(),
|
|
22823
22908
|
handle: external_exports.string().optional(),
|
|
22824
|
-
limit: external_exports.number().int().positive().max(100).default(20)
|
|
22909
|
+
limit: external_exports.number().int().positive().max(100).default(20),
|
|
22910
|
+
offset: external_exports.number().int().nonnegative().optional()
|
|
22825
22911
|
},
|
|
22826
22912
|
async run(input, { client: client2 }) {
|
|
22913
|
+
const status = input.status === void 0 ? void 0 : Array.isArray(input.status) ? input.status : [input.status];
|
|
22827
22914
|
return client2.listProducts({
|
|
22828
22915
|
q: input.q,
|
|
22829
|
-
status
|
|
22916
|
+
status,
|
|
22830
22917
|
handle: input.handle,
|
|
22831
|
-
limit: input.limit
|
|
22918
|
+
limit: input.limit,
|
|
22919
|
+
offset: input.offset
|
|
22832
22920
|
});
|
|
22833
22921
|
}
|
|
22834
22922
|
},
|
|
@@ -22866,11 +22954,14 @@ var productTools = [
|
|
|
22866
22954
|
name: "get_translations",
|
|
22867
22955
|
description: `\u8BFB\u53D6\u67D0\u5B9E\u4F53\u7684\u591A\u8BED\u8A00\u7FFB\u8BD1\uFF08GET /admin/translations\uFF09\u2014\u2014\u6838\u5BF9\u5546\u54C1\u56DB\u8BED\u8A00\u662F\u5426\u5199\u5165\u6210\u529F\u7684\u552F\u4E00\u53EF\u9760\u9014\u5F84
|
|
22868
22956
|
\uFF08get_product \u9ED8\u8BA4\u5B57\u6BB5\u4E0D\u542B translations\uFF09\u3002reference \u4E00\u822C\u4E3A product\uFF0Creference_id \u4F20\u5546\u54C1 id \u6216 handle\u3002
|
|
22869
|
-
\
|
|
22957
|
+
\u4E5F\u652F\u6301 product_option\uFF08\u9009\u9879\u540D\uFF09/ product_option_value\uFF08\u9009\u9879\u53D6\u503C\uFF09/ product_category / product_collection / shipping_option\u3002
|
|
22958
|
+
\u8FD4\u56DE\u6BCF\u6761 { locale_code, field_keys, ...\u539F\u6837\u5B57\u6BB5 }\uFF1A\u5546\u54C1\u662F title/subtitle/description\uFF0C\u9009\u9879\u53D6\u503C\u662F value\uFF0C
|
|
22959
|
+
**\u9ED8\u8BA4\u4E0D\u622A\u65AD**\uFF08\u9700\u8981\u63A7\u5236\u4E0A\u4E0B\u6587\u65F6\u7528 max_chars\uFF0C\u907F\u514D"\u770B\u4E0D\u5230\u5168\u6587\u5C31\u6CA1\u6CD5\u6838\u5BF9"\uFF09\u3002`,
|
|
22870
22960
|
schema: {
|
|
22871
22961
|
reference: external_exports.string().default("product"),
|
|
22872
|
-
reference_id: external_exports.string().describe("\u5546\u54C1 id \u6216 handle"),
|
|
22962
|
+
reference_id: external_exports.string().describe("\u5546\u54C1 id \u6216 handle\uFF1B\u5176\u5B83\u5B9E\u4F53\u4F20\u771F\u5B9E id"),
|
|
22873
22963
|
locale_code: external_exports.string().optional().describe("\u53EA\u53D6\u67D0\u4E00\u8BED\u8A00\uFF0C\u5982 zh"),
|
|
22964
|
+
max_chars: external_exports.number().int().nonnegative().default(0).describe("\u5355\u5B57\u6BB5\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u5B57\uFF0C0=\u4E0D\u622A\u65AD\uFF08\u9ED8\u8BA4\uFF09\u3002\u8D85\u957F\u65F6\u5C3E\u90E8\u6807\u51FA\u539F\u59CB\u5B57\u6570"),
|
|
22874
22965
|
limit: external_exports.number().int().positive().max(100).default(50)
|
|
22875
22966
|
},
|
|
22876
22967
|
async run(input, { client: client2 }) {
|
|
@@ -22888,14 +22979,12 @@ var productTools = [
|
|
|
22888
22979
|
};
|
|
22889
22980
|
if (input.locale_code) params.locale_code = input.locale_code;
|
|
22890
22981
|
const data = await client2.listTranslations(params);
|
|
22982
|
+
const maxChars = input.max_chars ?? 0;
|
|
22983
|
+
const clip = (v) => typeof v === "string" && maxChars > 0 && v.length > maxChars ? `${v.slice(0, maxChars)}\u2026[\u5171 ${v.length} \u5B57]` : v;
|
|
22891
22984
|
const rows = (data?.translations || []).map((t) => {
|
|
22892
22985
|
const tr = t.translations || {};
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
title: tr.title ?? null,
|
|
22896
|
-
description: tr.description ? tr.description.slice(0, 120) + "\u2026" : null,
|
|
22897
|
-
has_full_description: Boolean(tr.description)
|
|
22898
|
-
};
|
|
22986
|
+
const fields = Object.fromEntries(Object.entries(tr).map(([k, v]) => [k, clip(v)]));
|
|
22987
|
+
return { locale_code: t.locale_code, field_keys: Object.keys(tr), ...fields };
|
|
22899
22988
|
});
|
|
22900
22989
|
return { reference: input.reference, reference_id: input.reference_id, translations: rows, count: rows.length };
|
|
22901
22990
|
}
|
|
@@ -23327,12 +23416,16 @@ storefront \u8BE6\u60C5\u9875\u300C\u5BCC\u5185\u5BB9\u300D\u533A\u7531\u8FD9\u4
|
|
|
23327
23416
|
- video: data.{ url, poster? }\uFF08\u652F\u6301 YouTube\uFF09
|
|
23328
23417
|
- faq: data.{ items: {question,answer}[] }
|
|
23329
23418
|
- specs: data.{ rows: {label,value}[] }
|
|
23419
|
+
\u26A0\uFE0F \u8BE5\u63A5\u53E3\u662F**\u6574\u5757\u66FF\u6362**\uFF08\u4E0D\u5408\u5E76\uFF09\uFF1A\u76EE\u6807\u8BED\u8A00\u5DF2\u6709\u5185\u5BB9\u65F6\u4F1A\u88AB\u6574\u7EC4\u8986\u76D6\uFF0C\u540E\u7AEF\u65E0\u7248\u672C\u5386\u53F2\u3002
|
|
23420
|
+
\u56E0\u6B64\u672C\u5DE5\u5177\u9ED8\u8BA4\u62E6\u4E00\u9053\uFF1A\u76EE\u6807\u8BED\u8A00\u5DF2\u6709\u5757 \u2192 dry_run \u8FD4\u56DE existing + diff\uFF0Cconfirm \u5FC5\u987B\u663E\u5F0F\u5E26 overwrite=true\uFF0C
|
|
23421
|
+
\u5E76\u5728\u8986\u76D6\u524D\u628A\u65E7\u5757\u5907\u4EFD\u5230 ~/.derlux/content-backups/\uFF08\u54CD\u5E94\u91CC\u7684 backup_path\uFF09\u3002
|
|
23422
|
+
\u53EA\u60F3\u6539\u4E2A\u522B\u5757 \u2192 \u5148 get_product_content \u53D6\u56DE\u65E7\u5757\uFF0C\u5728\u65E7\u5757\u4E0A\u6539\u5199\u540E\u6574\u7EC4\u63D0\u4EA4\uFF0C\u4E0D\u8981\u51ED\u8BB0\u5FC6\u91CD\u5EFA\uFF08\u4F1A\u4E22\u5757/\u4E22\u56FE\uFF09\u3002
|
|
23330
23423
|
\u26A0\uFE0F locale \u7528\u533A\u57DF\u7801 en-US / zh-CN / ms-MY / id-ID\uFF08\u4E0E\u524D\u7AEF\u4E00\u81F4\uFF0C\u63A8\u8350\uFF09\uFF1B\u4E5F\u63A5\u53D7\u77ED\u7801 en/zh/ms/id\uFF08\u81EA\u52A8\u5F52\u4E00\u5316\u4E3A\u533A\u57DF\u7801\uFF09\u3002\u5546\u54C1\u6807\u9898/\u63CF\u8FF0\u7684\u7FFB\u8BD1\u7528\u77ED\u7801\uFF0C\u4E8C\u8005\u4E0D\u540C\u3002
|
|
23331
23424
|
\u9ED8\u8BA4 dry_run\uFF08confirm=false\uFF09\u4EC5\u9884\u89C8\u3002`,
|
|
23332
23425
|
schema: {
|
|
23333
23426
|
product_id: external_exports.string(),
|
|
23334
23427
|
locale: external_exports.string().default("en-US").describe("\u533A\u57DF\u7801 en-US/zh-CN/ms-MY/id-ID\uFF0C\u6216\u77ED\u7801 en/zh/ms/id"),
|
|
23335
|
-
status: external_exports.enum(["draft", "published"]).default("published"),
|
|
23428
|
+
status: external_exports.enum(["draft", "published"]).default("published").describe("\u5199\u54EA\u4E00\u7248\uFF1Adraft=\u8349\u7A3F\uFF08\u540E\u53F0\u9884\u89C8\u7528\uFF09\uFF0Cpublished=\u987E\u5BA2\u53EF\u89C1\uFF1B\u4E24\u7248\u72EC\u7ACB\u5B58\u50A8"),
|
|
23336
23429
|
blocks: external_exports.array(
|
|
23337
23430
|
external_exports.object({
|
|
23338
23431
|
id: external_exports.string().optional(),
|
|
@@ -23340,6 +23433,8 @@ storefront \u8BE6\u60C5\u9875\u300C\u5BCC\u5185\u5BB9\u300D\u533A\u7531\u8FD9\u4
|
|
|
23340
23433
|
data: external_exports.record(external_exports.string(), external_exports.any())
|
|
23341
23434
|
})
|
|
23342
23435
|
).describe("ContentBlock[] \u6570\u7EC4"),
|
|
23436
|
+
overwrite: external_exports.boolean().default(false).describe("\u76EE\u6807\u8BED\u8A00\u5DF2\u6709\u5185\u5BB9\u65F6\uFF0C\u5FC5\u987B\u663E\u5F0F\u8BBE true \u624D\u5141\u8BB8\u6574\u5757\u8986\u76D6\uFF08\u9632\u9759\u9ED8\u4E22\u7A3F\uFF09"),
|
|
23437
|
+
backup: external_exports.boolean().default(true).describe("\u8986\u76D6\u524D\u662F\u5426\u628A\u65E7\u5757\u5907\u4EFD\u5230 ~/.derlux/content-backups/\uFF08\u9ED8\u8BA4\u5F00\u542F\uFF09"),
|
|
23343
23438
|
confirm: external_exports.boolean().default(false)
|
|
23344
23439
|
},
|
|
23345
23440
|
async run(input, { client: client2 }) {
|
|
@@ -23347,6 +23442,32 @@ storefront \u8BE6\u60C5\u9875\u300C\u5BCC\u5185\u5BB9\u300D\u533A\u7531\u8FD9\u4
|
|
|
23347
23442
|
if (!locale) {
|
|
23348
23443
|
return `\u9519\u8BEF\uFF1Alocale "${input.locale}" \u4E0D\u53D7\u652F\u6301\uFF0C\u8BF7\u7528 en-US / zh-CN / ms-MY / id-ID\uFF08\u6216\u77ED\u7801 en/zh/ms/id\uFF09\u3002`;
|
|
23349
23444
|
}
|
|
23445
|
+
let existing = null;
|
|
23446
|
+
try {
|
|
23447
|
+
const data2 = await client2.getProductContent(input.product_id, locale, input.status);
|
|
23448
|
+
const pc = data2?.product_content;
|
|
23449
|
+
if (pc) {
|
|
23450
|
+
let blocks = [];
|
|
23451
|
+
try {
|
|
23452
|
+
blocks = pc.blocks ? JSON.parse(pc.blocks) : [];
|
|
23453
|
+
} catch {
|
|
23454
|
+
blocks = [];
|
|
23455
|
+
}
|
|
23456
|
+
existing = { id: pc.id, blocks };
|
|
23457
|
+
}
|
|
23458
|
+
} catch (err) {
|
|
23459
|
+
const status = err instanceof MedusaAdminError ? err.status : 0;
|
|
23460
|
+
if (status !== 404 && status !== 400) {
|
|
23461
|
+
return {
|
|
23462
|
+
error: `\u65E0\u6CD5\u786E\u8BA4\u76EE\u6807\u8BED\u8A00\u662F\u5426\u5DF2\u6709\u5185\u5BB9\uFF08${locale}/${input.status}\uFF09${err instanceof Error ? `\uFF1A${err.message}` : ""}\u3002\u4E3A\u907F\u514D\u9759\u9ED8\u8986\u76D6\u8FD0\u8425\u7A3F\u4EF6\u5DF2\u4E2D\u6B62\uFF0C\u8BF7\u91CD\u8BD5\u6216\u5148\u624B\u52A8\u6838\u5BF9\u3002`
|
|
23463
|
+
};
|
|
23464
|
+
}
|
|
23465
|
+
}
|
|
23466
|
+
const prevBlocks = existing?.blocks ?? [];
|
|
23467
|
+
const hasPrev = prevBlocks.length > 0;
|
|
23468
|
+
const prevSummary = summarizeBlocks(prevBlocks);
|
|
23469
|
+
const nextSummary = summarizeBlocks(input.blocks);
|
|
23470
|
+
const diff = hasPrev ? diffBlockStructure(prevSummary.types, nextSummary.types) : { types_added: nextSummary.types, types_removed: [], same_structure: false };
|
|
23350
23471
|
if (!input.confirm) {
|
|
23351
23472
|
return {
|
|
23352
23473
|
dry_run: true,
|
|
@@ -23354,18 +23475,41 @@ storefront \u8BE6\u60C5\u9875\u300C\u5BCC\u5185\u5BB9\u300D\u533A\u7531\u8FD9\u4
|
|
|
23354
23475
|
product_id: input.product_id,
|
|
23355
23476
|
locale,
|
|
23356
23477
|
status: input.status,
|
|
23357
|
-
block_count:
|
|
23358
|
-
types:
|
|
23359
|
-
}
|
|
23478
|
+
block_count: nextSummary.count,
|
|
23479
|
+
types: nextSummary.types
|
|
23480
|
+
},
|
|
23481
|
+
existing: hasPrev ? { id: existing.id, ...prevSummary } : null,
|
|
23482
|
+
will_replace: hasPrev,
|
|
23483
|
+
overwrite_required: hasPrev,
|
|
23484
|
+
diff,
|
|
23485
|
+
note: hasPrev ? `\u76EE\u6807\u8BED\u8A00 ${locale}\uFF08${input.status}\uFF09\u5DF2\u6709 ${prevSummary.count} \u4E2A\u5757\uFF0Cconfirm \u65F6\u5FC5\u987B\u5E26 overwrite=true\uFF1B\u8986\u76D6\u524D\u4F1A\u81EA\u52A8\u5907\u4EFD\u65E7\u5757\u3002` : "\u76EE\u6807\u8BED\u8A00\u6682\u65E0\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5 confirm \u5199\u5165\u3002"
|
|
23486
|
+
};
|
|
23487
|
+
}
|
|
23488
|
+
if (hasPrev && !input.overwrite) {
|
|
23489
|
+
return {
|
|
23490
|
+
error: `\u76EE\u6807\u8BED\u8A00 ${locale}\uFF08${input.status}\uFF09\u5DF2\u6709 ${prevSummary.count} \u4E2A\u5185\u5BB9\u5757\uFF08${prevSummary.types.join(" / ")}\uFF09\uFF0C\u672C\u6B21\u63D0\u4EA4\u4F1A\u6574\u5757\u8986\u76D6\u3002`,
|
|
23491
|
+
overwrite_required: true,
|
|
23492
|
+
existing: { id: existing.id, ...prevSummary },
|
|
23493
|
+
diff,
|
|
23494
|
+
hint: `\u786E\u8BA4\u66FF\u6362\u8BF7\u5E26 overwrite=true \u91CD\u8DD1\uFF1B\u53EA\u60F3\u6539\u4E2A\u522B\u5757\u8BF7\u5148 get_product_content \u53D6\u56DE\u65E7\u5757\uFF0C\u5728\u65E7\u5757\u4E0A\u6539\u5199\u540E\u6574\u7EC4\u63D0\u4EA4\uFF08\u76F4\u63A5\u91CD\u5EFA\u4F1A\u4E22\u5757\uFF09\u3002\u4E5F\u8981\u786E\u8BA4 status\uFF1Adraft \u4E0E published \u662F\u4E24\u4EFD\u72EC\u7ACB\u5185\u5BB9\uFF0C\u5F53\u524D\u5199\u7684\u662F ${input.status}\u3002`
|
|
23360
23495
|
};
|
|
23361
23496
|
}
|
|
23497
|
+
const backupPath = hasPrev && input.backup !== false ? backupProductContent(input.product_id, locale, input.status, prevBlocks) : null;
|
|
23362
23498
|
const data = await client2.createProductContent({
|
|
23363
23499
|
product_id: input.product_id,
|
|
23364
23500
|
locale,
|
|
23365
23501
|
status: input.status,
|
|
23366
23502
|
blocks: input.blocks
|
|
23367
23503
|
});
|
|
23368
|
-
return {
|
|
23504
|
+
return {
|
|
23505
|
+
created: data,
|
|
23506
|
+
locale,
|
|
23507
|
+
status: input.status,
|
|
23508
|
+
block_count: nextSummary.count,
|
|
23509
|
+
replaced: hasPrev,
|
|
23510
|
+
diff,
|
|
23511
|
+
backup_path: hasPrev ? backupPath ?? "\u5907\u4EFD\u5931\u8D25\uFF08\u672A\u963B\u65AD\u5199\u5165\uFF09\u2014\u2014\u65E7\u7A3F\u5DF2\u4E22\u5931\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u8BEF\u8986\u76D6" : null
|
|
23512
|
+
};
|
|
23369
23513
|
}
|
|
23370
23514
|
}
|
|
23371
23515
|
];
|
|
@@ -23734,14 +23878,22 @@ translations \u4E3A upsert\uFF08\u540C\u8BED\u8A00\u5408\u5E76\u66F4\u65B0\uFF0C
|
|
|
23734
23878
|
var opsTools = [
|
|
23735
23879
|
{
|
|
23736
23880
|
name: "list_orders",
|
|
23737
|
-
description:
|
|
23881
|
+
description: '\u67E5\u8BE2\u540E\u53F0\u8BA2\u5355\u5217\u8868\uFF0C\u652F\u6301\u5173\u952E\u8BCD q\u3001\u72B6\u6001 status \u8FC7\u6EE4\u3002\u8FD4\u56DE\u4F53\u542B count\uFF08\u6EE1\u8DB3\u6761\u4EF6\u7684\u603B\u6570\uFF0C\u4E0D\u53D7 limit \u5F71\u54CD\uFF09\u3002status \u53EF\u4F20\u5355\u503C\uFF08"pending"\uFF09\u6216\u591A\u4E2A\u503C\u7684\u6570\u7EC4\uFF08["pending","canceled"]\uFF09\u3002',
|
|
23738
23882
|
schema: {
|
|
23739
23883
|
q: external_exports.string().optional(),
|
|
23740
|
-
|
|
23741
|
-
|
|
23884
|
+
// 不写死枚举:后端订单状态集合可能随版本扩展,这里只约束形态(单值 / 非空数组)。
|
|
23885
|
+
status: external_exports.union([external_exports.string(), external_exports.array(external_exports.string()).min(1)]).optional(),
|
|
23886
|
+
limit: external_exports.number().int().positive().max(100).default(20),
|
|
23887
|
+
offset: external_exports.number().int().nonnegative().optional()
|
|
23742
23888
|
},
|
|
23743
23889
|
async run(input, { client: client2 }) {
|
|
23744
|
-
|
|
23890
|
+
const status = input.status === void 0 ? void 0 : Array.isArray(input.status) ? input.status : [input.status];
|
|
23891
|
+
return client2.listOrders({
|
|
23892
|
+
q: input.q,
|
|
23893
|
+
status,
|
|
23894
|
+
limit: input.limit,
|
|
23895
|
+
offset: input.offset
|
|
23896
|
+
});
|
|
23745
23897
|
}
|
|
23746
23898
|
},
|
|
23747
23899
|
{
|
|
@@ -23783,12 +23935,12 @@ var opsTools = [
|
|
|
23783
23935
|
|
|
23784
23936
|
// src/resources/docs.ts
|
|
23785
23937
|
import { readdirSync, readFileSync as readFileSync3, existsSync as existsSync3, statSync } from "node:fs";
|
|
23786
|
-
import { join as
|
|
23938
|
+
import { join as join3 } from "node:path";
|
|
23787
23939
|
var cache = null;
|
|
23788
23940
|
function walk(dir, out = []) {
|
|
23789
23941
|
if (!existsSync3(dir)) return out;
|
|
23790
23942
|
for (const entry of readdirSync(dir)) {
|
|
23791
|
-
const full =
|
|
23943
|
+
const full = join3(dir, entry);
|
|
23792
23944
|
try {
|
|
23793
23945
|
if (statSync(full).isDirectory()) walk(full, out);
|
|
23794
23946
|
else if (full.endsWith(".md")) out.push(full);
|
|
@@ -24836,11 +24988,11 @@ var toolDefs = [
|
|
|
24836
24988
|
];
|
|
24837
24989
|
|
|
24838
24990
|
// src/audit.ts
|
|
24839
|
-
import { appendFileSync, mkdirSync as
|
|
24991
|
+
import { appendFileSync, mkdirSync as mkdirSync3 } from "node:fs";
|
|
24840
24992
|
import { dirname as dirname2 } from "node:path";
|
|
24841
24993
|
function audit(auditFile, name, args, ok) {
|
|
24842
24994
|
try {
|
|
24843
|
-
|
|
24995
|
+
mkdirSync3(dirname2(auditFile), { recursive: true });
|
|
24844
24996
|
const line = `${(/* @__PURE__ */ new Date()).toISOString()} | tool=${name} | ok=${ok} | args=${JSON.stringify(args)}
|
|
24845
24997
|
`;
|
|
24846
24998
|
appendFileSync(auditFile, line);
|
|
@@ -24968,10 +25120,10 @@ if (isCliInvocation(argv)) {
|
|
|
24968
25120
|
process.exit(code);
|
|
24969
25121
|
}
|
|
24970
25122
|
process.stderr.write(
|
|
24971
|
-
`[derlux-admin] v0.
|
|
25123
|
+
`[derlux-admin] v0.3.0 backend=${config2.backendUrl} account=${config2.adminEmail || "(\u672A\u914D\u7F6E)"} session_scope=${config2.sessionScope} tools=${toolDefs.length}
|
|
24972
25124
|
`
|
|
24973
25125
|
);
|
|
24974
|
-
var server = new McpServer({ name: "derlux-admin", version: "0.
|
|
25126
|
+
var server = new McpServer({ name: "derlux-admin", version: "0.3.0" });
|
|
24975
25127
|
function isToolSuccess(result) {
|
|
24976
25128
|
if (!result || typeof result !== "object") return true;
|
|
24977
25129
|
const r = result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sea-ecommerce/admin-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "让运营同学用本地 AI agent(Codex / Workbuddy / Claude / Cursor / CodeBuddy)运营 Medusa 后台的 MCP server。",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"build": "node scripts/bundle.mjs",
|
|
18
18
|
"start": "node dist/derlux-admin-mcp.js",
|
|
19
19
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
20
22
|
"gen:skill": "node scripts/gen-skill.mjs",
|
|
21
23
|
"check:skill-drift": "node scripts/gen-skill.mjs --check",
|
|
22
24
|
"prepublishOnly": "node scripts/bundle.mjs && node scripts/gen-skill.mjs --check",
|
package/skill/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: derlux-admin-mcp-ops
|
|
3
|
-
description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERLUX Store
|
|
3
|
+
description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERLUX Store 后台的指南,并附随包发布的《运营人员手册》。覆盖商品创建/修改/下架、批量导入、商品详情页富内容与多语言同步(把已录入的英文稿按原版式翻成中/马/印尼文,含大图、规格、图集)、仓库与库存调整、订单/退货/仓库作业查询,以及本系统使用类问题的手册检索问答。当用户要让 agent 创建、修改或下架商品、批量录入商品、翻译商品详情页内容/规格/图片文案到其他语言、调整某仓库库存、查询订单或退货,或咨询「后台怎么操作某功能」「某状态是什么意思」「某规则如何口径」「为什么不生效」「在哪设置/怎么验收」等使用问题时使用;使用类问题应先检索随包手册再回答。新建商品一律默认草稿态(draft),确认无误并走完上线核对后再显式上架(published),避免一创建就被线上用户看到。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# DERLUX 运营后台 MCP 操作指南(derlux-admin)
|
|
@@ -34,8 +34,10 @@ description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERL
|
|
|
34
34
|
- `get_translations` 返回的 `locale_code` 是区域码;`set_translations` 还会把历史短码行自动改码修正。不要手工在两套码之间转换。
|
|
35
35
|
8. **详情页「富内容」靠 `create_product_content`,不是 `description`**:storefront 下方大块内容由 `product_content` 模块渲染。四语言要各建一份,缺任一语言该语言详情页空白。
|
|
36
36
|
- 区块字段名易错:`richtext` → `data.html`、`specs` → `data.rows`、`image_gallery` → `data.images`。
|
|
37
|
+
- **该接口是整块替换**:目标语言已有内容会被整组覆盖,后端无版本历史。工具默认拦一道——`confirm=true` 时若目标语言已有块,必须显式带 `overwrite=true`,否则报错并回传现状;覆盖前自动把旧块备份到 `~/.derlux/content-backups/`(响应 `backup_path`)。**禁止为了让报错消失就无脑加 `overwrite=true`**,先看清 `existing` 是不是运营的手工稿。
|
|
38
|
+
- `status` 默认 `published`(顾客可见);只想让运营先审就先写 `draft`。`draft` 与 `published` 是两份独立内容。
|
|
37
39
|
9. **不建库存 = 前端缺货**:变体 `manage_inventory` 默认 `true` 但新商品 0 库存。创建时给 `initial_stock`,或事后 `set_product_stock`。
|
|
38
|
-
10. **多语言核对用 `get_translations`**:`get_product` 默认字段不含 translations
|
|
40
|
+
10. **多语言核对用 `get_translations`**:`get_product` 默认字段不含 translations,不要凭它为空判断没翻译。该工具现在返回 `{ locale_code, field_keys, ...原样字段 }`(默认不截断,量大时用 `max_chars`),商品看 `title/subtitle/description`,**选项取值看 `value`**——只挑 title 核对会误判「没写上」。
|
|
39
41
|
11. **创建前先查重**:handle 归一化后不同写法可能落到不同 handle(`DR CYJ X`→`dr-cyj-x`、`DR.CYJ X`→`drcyj-x`),静默建出重复空商品。批量导入会自动按 handle + SKU 查重;单款手动创建前也要 `list_products` 搜一遍。
|
|
40
42
|
12. **新建商品默认草稿态 `draft`,绝不「创建即上线」**:草稿即使挂了渠道也不对客可见。正式 `published` 必须由运营**显式确认**且走完上线核对(见 SOP),再用 `update_product` 单独切状态。
|
|
41
43
|
13. **开工先 `get_context`,批量先 `import-spec`**(新增):任何任务第一个工具调用必须是 `get_context`,确认 `backend_url` / `actor_type=user` / `roles` / 渠道 / 仓库 / 币种。**由 MCP 代做录入时,≥2 款商品一律用 `batch_import_products` + import-spec 一次性声明所有业务选项并让运营一次确认**,不要逐款 `create_product`,也不要中途逐个补问。例外:运营明确选择「后台原生 CSV 模板」时,按下方「批量导入」的通道 A 生成 CSV,并用 `trigger_native_csv_import`(默认 `confirm=false`,只上传+lint 校验、零写入)先做预检;只有运营明确确认后才用 `confirm=true` 真正导入(或由运营自己在后台 Products → Import 上传)。
|
|
@@ -43,6 +45,14 @@ description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERL
|
|
|
43
45
|
|
|
44
46
|
15. **商品图片必须落「应用的 S3 存储」,禁止外部直链**:无论图片来自本地文件还是网络 URL,都必须经「应用的图片接口」`POST /admin/image-assets` 落盘(本地路径直接读、网络 URL 先下载),再把返回的受信任 `file_url` 写进商品。绝不可把外部 CDN 域名(如 `cdn.budgetpixel.com`)的 URL 直接写进商品 `images`——storefront 用 `next/image` 渲染,只信任 `NEXT_PUBLIC_ASSETS_HOST` / `*.amazonaws.com` / `localhost:9000`,外部直链会直接报 `hostname is not configured` 导致页面崩溃。`create_product` / `batch_import_products` 的 `images` 与 `upload_product_image` 已内置此逻辑(`upload_product_image` 支持 `replace=true` 整组替换),agent 不要绕过(例如手动把外链塞进 `metadata` 或富内容 `image_gallery` 的 `images`)。
|
|
45
47
|
|
|
48
|
+
16. **多语言同步以「已录入的源语言稿」为唯一事实来源**(运营说「把英文详情页翻成其他语言」时按「多语言同步」一节执行,不要另起一套结构):
|
|
49
|
+
- 源稿用 `get_product_content` 读出 `blocks[]`,只翻文案,块的 `type`/顺序/数量原样保留;
|
|
50
|
+
- **允许翻译有源文的内容**;硬规则里禁止的是「无源文时凭想象编造四语译文」(如从 Excel 批量建新品,表格里没有译文时须运营提供或明确授权);
|
|
51
|
+
- **不译项逐字保留**:图片 URL、`video.url`、HTML 标签与属性、SKU/条码/型号/容量数字与单位(`420ml`、`SPF50+`)、品牌名、`{brand}`/`{company}` 占位符;
|
|
52
|
+
- 图片原样复用源稿已有 URL(已在应用 S3),禁止重新上传生成新 key、禁止换外部直链;
|
|
53
|
+
- 目标语言已有内容时,先把 `existing` + `diff` 给运营看过再 `overwrite=true`,**绝不「报错就加 overwrite」**;
|
|
54
|
+
- 商品标题/描述用 `set_translations`(`title/subtitle/description`);选项名用 `reference=product_option` + `title`;选项取值用 `reference=product_option_value` + **`value`**。
|
|
55
|
+
|
|
46
56
|
## 工具速查表
|
|
47
57
|
|
|
48
58
|
> 由 `scripts/gen-skill.mjs` 从 `src/tools/*.ts` 自动生成;`pnpm check:skill-drift` 校验一致性。不要手工编辑标记之间的内容。
|
|
@@ -56,7 +66,7 @@ description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERL
|
|
|
56
66
|
| `create_collection` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 新建一个产品系列 / 集合(如活动集合、首页精选集合 featured)。 |
|
|
57
67
|
| `create_product` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 在后台增加一个商品。 |
|
|
58
68
|
| `create_product_category` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 新建一个产品分类。 |
|
|
59
|
-
| `create_product_content` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 创建/更新商品详情页富内容块(POST /admin/product-contents,… |
|
|
69
|
+
| `create_product_content` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 整块替换:目标语言已有内容须 overwrite=true,覆盖前自动备份 · 创建/更新商品详情页富内容块(POST /admin/product-contents,… |
|
|
60
70
|
| `create_stock_location` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 增加一个仓库(StockLocation)。 |
|
|
61
71
|
| `deactivate_product` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 下线商品(将 status 置为 archived,从商城下架)。 |
|
|
62
72
|
| `delete_collection` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 删除一个产品系列 / 集合(DELETE /admin/collections/:id)… |
|
|
@@ -70,16 +80,16 @@ description: 运营使用本地 AI agent(derlux-admin MCP server)操作 DERL
|
|
|
70
80
|
| `get_product_content` | 读 | 否 | 直接返回 · 读取商品详情页富内容块(GET /admin/product-contents)。 |
|
|
71
81
|
| `get_translations` | 读 | 否 | 直接返回 · 读取某实体的多语言翻译(GET /admin/translations)——核对商品四语… |
|
|
72
82
|
| `list_collections` | 读 | 否 | 直接返回 · 列出集合(GET /admin/collections),… |
|
|
73
|
-
| `list_orders` | 读 | 否 | 直接返回 ·
|
|
83
|
+
| `list_orders` | 读 | 否 | 直接返回 · 查询后台订单列表,支持关键词 q、状态 status 过滤。 |
|
|
74
84
|
| `list_product_categories` | 读 | 否 | 直接返回 · 查询后台产品分类列表(GET /admin/product-categories)。 |
|
|
75
|
-
| `list_products` | 读 | 否 | 直接返回 ·
|
|
85
|
+
| `list_products` | 读 | 否 | 直接返回 · 查询后台商品列表,支持按关键词 q、状态 status、handle 过滤。 |
|
|
76
86
|
| `list_return_requests` | 读 | 否 | 直接返回 · 查询退货/售后请求列表(自定义端点 /admin/return-requests)。 |
|
|
77
87
|
| `list_sales_channels` | 读 | 否 | 直接返回 · 列出销售渠道(GET /admin/sales-channels)。 |
|
|
78
88
|
| `list_stock_locations` | 读 | 否 | 直接返回 · 列出仓库(Medusa StockLocation)。 |
|
|
79
89
|
| `list_warehouse_tasks` | 读 | 否 | 直接返回 · 查询仓库作业任务列表(自定义端点 /admin/warehouse-tasks),… |
|
|
80
90
|
| `search_docs` | 读 | 否 | 直接返回 · 在 docs/ 中文文档中检索与查询相关的段落,… |
|
|
81
91
|
| `set_product_stock` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 给商品建仓/改库存(幂等):确保变体对应的库存条目存在(缺失则按变体 SKU 自动创建)… |
|
|
82
|
-
| `set_translations` | 写 | 是(confirm=true 才写) | upsert 翻译,字段合并不重复行,自动修正历史短码 ·
|
|
92
|
+
| `set_translations` | 写 | 是(confirm=true 才写) | upsert 翻译,字段合并不重复行,自动修正历史短码 · 为实体(商品、选项名、选项取值、分类、系列、配送方式)创建或更新(upsert)多语言翻… |
|
|
83
93
|
| `trigger_native_csv_import` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 【原生 CSV 导入自动化】把后台 Products → Import 的 CSV 通道… |
|
|
84
94
|
| `update_collection` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 修改产品系列字段(标题/handle/external_id/metadata/多语言)… |
|
|
85
95
|
| `update_inventory_level` | 写 | 是(confirm=true 才写) | confirm=false 仅预览 · 修改某库存条目在指定仓库的库存数量(绝对值,… |
|
|
@@ -159,6 +169,56 @@ derlux-admin-mcp import --spec ./import-spec.json --commit --token 'v1:xxxxxxxx'
|
|
|
159
169
|
- 复跑安全:update 命中已有商品时**不改现有 status**、也不拿 `default_initial_stock` 覆盖库存;要改状态/补库存须在对应商品上显式写 `status` / `initial_stock`。
|
|
160
170
|
- 批量工具已内建:查重、图片上传、多币种价格、四语言翻译、库存、渠道、各语言富内容、摘要回读。
|
|
161
171
|
|
|
172
|
+
## 多语言同步:把已录入的源语言稿翻成其他语言
|
|
173
|
+
|
|
174
|
+
**适用**:运营已在后台(或经本工具)录好某一语言的详情页内容,要求按**同一套版式**同步到其他语言。
|
|
175
|
+
这不是「新建四语」——源稿是唯一事实来源,禁止另起一套结构、禁止重排区块。
|
|
176
|
+
|
|
177
|
+
**开工先确认三件事**(不清楚就问,不要猜):
|
|
178
|
+
|
|
179
|
+
| 项 | 说明 |
|
|
180
|
+
|---|---|
|
|
181
|
+
| 源语言 → 目标语言 | 默认 `en-US` → `zh-CN` / `ms-MY` / `id-ID` |
|
|
182
|
+
| 源稿版本 | `draft` 还是 `published`(两版独立存储;`get_product_content` 默认读 `published`,运营刚录完通常还在 `draft`,读不到就说明版本选错) |
|
|
183
|
+
| 目标语言写入版本 | 先写 `draft` 给运营审(推荐),还是直接 `published` 上线 |
|
|
184
|
+
|
|
185
|
+
**步骤**:
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
1. get_product_content(product_id, 源locale, status) → blocks[](hero / image_gallery / specs / richtext / faq / video)
|
|
189
|
+
2. 逐块翻译(只翻文案,结构原样)
|
|
190
|
+
3. create_product_content(product_id, 目标locale, blocks, status, confirm=false) → 看 existing / diff
|
|
191
|
+
4. 无 existing → confirm=true;有 existing → 给运营看块数+类型差异,确认后 confirm=true, overwrite=true
|
|
192
|
+
5. get_product_content 逐语言回读:块数、类型序列、抽样文案
|
|
193
|
+
6. 标题/描述另走 set_translations;选项名/选项取值见下方「规格多语言」
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**翻译边界**(必须遵守):
|
|
197
|
+
|
|
198
|
+
| 翻 | 不翻(逐字保留) |
|
|
199
|
+
|---|---|
|
|
200
|
+
| `hero.title` / `hero.subtitle` | `hero.data.image`、`image_gallery.data.images` 等所有图片 URL |
|
|
201
|
+
| `richtext.data.html` 里的可见文字 | HTML 标签名与属性(`class`、`style`、`href`) |
|
|
202
|
+
| `specs.data.rows[].label`,以及 `value` 里的自然语言 | SKU / 条码 / 型号 / 容量与数字单位(`420ml`、`SPF50+`、`MYR`) |
|
|
203
|
+
| `faq.items[].question` / `.answer` | 品牌名 `dermsupermarket`、`{brand}` / `{company}` 占位符 |
|
|
204
|
+
| `image_gallery.caption` | `video.url`、YouTube ID |
|
|
205
|
+
|
|
206
|
+
- 块 `id` 可沿用源块,也可整组省略(工具会自动补稳定唯一 id);不要手工编造跨语言重复 id。
|
|
207
|
+
- 图片**原样复用源稿 URL**(已在应用 S3):重新上传会生成新 key,换外链会让前台 `next/image` 破图。
|
|
208
|
+
- 目标语言已有运营手工稿时,`existing`/`diff` 必须展示给运营确认;覆盖会自动备份到 `~/.derlux/content-backups/`,但备份不是「可以先覆盖」的理由。
|
|
209
|
+
|
|
210
|
+
**规格多语言**(商品变体/选项,不是详情页 `specs` 区块):
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
set_translations(reference="product_option", reference_id="opt_xxx", translations={"zh-CN":{"title":"纤维类型"}})
|
|
214
|
+
set_translations(reference="product_option_value", reference_id="optval_xxx", translations={"zh-CN":{"value":"芳碳"}})
|
|
215
|
+
get_translations(reference="product_option_value", reference_id="optval_xxx") → 回读看 value
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
- 字段名按实体走白名单,写错会直接报错(**选项取值是 `value`,不是 `title`**)。
|
|
219
|
+
- 选项 id / 取值 id 从 `get_product` 的 `options[].id` 与 `options[].values[].id` 取。
|
|
220
|
+
- 现状提醒:选项取值译文目前仅后台可维护,storefront 尚未消费该译文;把它当「后台资料齐备」而不是「前台立即显示」向运营承诺。
|
|
221
|
+
|
|
162
222
|
## 推荐操作流程(SOP)
|
|
163
223
|
|
|
164
224
|
**单款创建**:`get_context` → `list_products` 查重 → `create_product(confirm=false)` 预览 → 运营确认后 `confirm=true`(带 `sales_channels` / `initial_stock` / 保持 `draft`)→ `create_product_content` 逐语言四份 → `get_translations` + `get_product_content` 核对。
|
|
@@ -169,7 +229,7 @@ derlux-admin-mcp import --spec ./import-spec.json --commit --token 'v1:xxxxxxxx'
|
|
|
169
229
|
|
|
170
230
|
**修改 / 下架**:`get_product` 确认 id → `update_product` / `deactivate_product`(预览 → 确认)。改价格用 `update_product_prices`,改库存用 `set_product_stock`,补翻译用 `set_translations`。
|
|
171
231
|
|
|
172
|
-
**查询类**:直接调读工具,无需 `confirm
|
|
232
|
+
**查询类**:直接调读工具,无需 `confirm`。统计「有多少 X」时看返回体的 `count`(满足条件的总数,**不受 `limit` 影响**),不要去数 `products.length` / `orders.length`;结果超过 `limit`(上限 100)时用 `offset` 继续翻页,只有 `count` 才是全量口径。`list_products` / `list_orders` 的 `status` 既可传单值(`"published"`)也可传数组(`["published","draft"]`)。
|
|
173
233
|
|
|
174
234
|
## 系统使用问答:检索《运营人员手册》
|
|
175
235
|
|
|
@@ -90,7 +90,7 @@ parent_category_id 可传父分类 id 或其名称/handle(自动解析)。is
|
|
|
90
90
|
## `create_product_content`
|
|
91
91
|
|
|
92
92
|
- 类型:写 | 源文件:`src/tools/products.ts`
|
|
93
|
-
- 参数:`product_id` / `locale` / `status` / `blocks` / `confirm`
|
|
93
|
+
- 参数:`product_id` / `locale` / `status` / `blocks` / `overwrite` / `backup` / `confirm`
|
|
94
94
|
|
|
95
95
|
```text
|
|
96
96
|
创建/更新商品详情页富内容块(POST /admin/product-contents,按 product_id+locale upsert)。
|
|
@@ -102,6 +102,10 @@ storefront 详情页「富内容」区由这些块渲染——仅填 product.des
|
|
|
102
102
|
- video: data.{ url, poster? }(支持 YouTube)
|
|
103
103
|
- faq: data.{ items: {question,answer}[] }
|
|
104
104
|
- specs: data.{ rows: {label,value}[] }
|
|
105
|
+
⚠️ 该接口是**整块替换**(不合并):目标语言已有内容时会被整组覆盖,后端无版本历史。
|
|
106
|
+
因此本工具默认拦一道:目标语言已有块 → dry_run 返回 existing + diff,confirm 必须显式带 overwrite=true,
|
|
107
|
+
并在覆盖前把旧块备份到 ~/.derlux/content-backups/(响应里的 backup_path)。
|
|
108
|
+
只想改个别块 → 先 get_product_content 取回旧块,在旧块上改写后整组提交,不要凭记忆重建(会丢块/丢图)。
|
|
105
109
|
⚠️ locale 用区域码 en-US / zh-CN / ms-MY / id-ID(与前端一致,推荐);也接受短码 en/zh/ms/id(自动归一化为区域码)。商品标题/描述的翻译用短码,二者不同。
|
|
106
110
|
默认 dry_run(confirm=false)仅预览。
|
|
107
111
|
```
|
|
@@ -213,12 +217,14 @@ locale 接受区域码 en-US / zh-CN / ms-MY / id-ID(推荐,与前端一致
|
|
|
213
217
|
## `get_translations`
|
|
214
218
|
|
|
215
219
|
- 类型:读 | 源文件:`src/tools/products.ts`
|
|
216
|
-
- 参数:`reference` / `reference_id` / `locale_code` / `limit`
|
|
220
|
+
- 参数:`reference` / `reference_id` / `locale_code` / `max_chars` / `limit`
|
|
217
221
|
|
|
218
222
|
```text
|
|
219
223
|
读取某实体的多语言翻译(GET /admin/translations)——核对商品四语言是否写入成功的唯一可靠途径
|
|
220
224
|
(get_product 默认字段不含 translations)。reference 一般为 product,reference_id 传商品 id 或 handle。
|
|
221
|
-
|
|
225
|
+
也支持 product_option(选项名)/ product_option_value(选项取值)/ product_category / product_collection / shipping_option。
|
|
226
|
+
返回每条 { locale_code, field_keys, ...原样字段 }:商品是 title/subtitle/description,选项取值是 value,
|
|
227
|
+
**默认不截断**(需要控制上下文时用 max_chars,避免"看不到全文就没法核对")。
|
|
222
228
|
```
|
|
223
229
|
|
|
224
230
|
## `list_collections`
|
|
@@ -233,10 +239,11 @@ locale 接受区域码 en-US / zh-CN / ms-MY / id-ID(推荐,与前端一致
|
|
|
233
239
|
## `list_orders`
|
|
234
240
|
|
|
235
241
|
- 类型:读 | 源文件:`src/tools/ops.ts`
|
|
236
|
-
- 参数:`q` / `status` / `limit`
|
|
242
|
+
- 参数:`q` / `status` / `limit` / `offset`
|
|
237
243
|
|
|
238
244
|
```text
|
|
239
|
-
查询后台订单列表,支持关键词 q、状态 status
|
|
245
|
+
查询后台订单列表,支持关键词 q、状态 status 过滤。返回体含 count(满足条件的总数,不受 limit 影响)。' +
|
|
246
|
+
'status 可传单值("pending")或多个值的数组(["pending","canceled"])。
|
|
240
247
|
```
|
|
241
248
|
|
|
242
249
|
## `list_product_categories`
|
|
@@ -251,10 +258,11 @@ locale 接受区域码 en-US / zh-CN / ms-MY / id-ID(推荐,与前端一致
|
|
|
251
258
|
## `list_products`
|
|
252
259
|
|
|
253
260
|
- 类型:读 | 源文件:`src/tools/products.ts`
|
|
254
|
-
- 参数:`q` / `status` / `handle` / `limit`
|
|
261
|
+
- 参数:`q` / `status` / `handle` / `limit` / `offset`
|
|
255
262
|
|
|
256
263
|
```text
|
|
257
|
-
查询后台商品列表,支持按关键词 q、状态 status、handle
|
|
264
|
+
查询后台商品列表,支持按关键词 q、状态 status、handle 过滤。返回体含 count(满足条件的总数,不受 limit 影响)。' +
|
|
265
|
+
'status 可传单值("published")或多个值的数组(["published","draft"])。
|
|
258
266
|
```
|
|
259
267
|
|
|
260
268
|
## `list_return_requests`
|
|
@@ -321,11 +329,18 @@ locale 接受区域码 en-US / zh-CN / ms-MY / id-ID(推荐,与前端一致
|
|
|
321
329
|
- 参数:`reference` / `reference_id` / `translations` / `confirm`
|
|
322
330
|
|
|
323
331
|
```text
|
|
324
|
-
|
|
332
|
+
为实体(商品、选项名、选项取值、分类、系列、配送方式)**创建或更新(upsert)**多语言翻译,走 /admin/translations/batch。
|
|
325
333
|
upsert 语义:同语言已有翻译 → 更新(字段合并,未给的旧字段保留,绝不产生重复行);没有 → 新建。
|
|
334
|
+
⚠️ 写入字段按 reference 白名单校验,写错字段会**直接报错**而不是静默存成无人读取的键:
|
|
335
|
+
- product → title / subtitle / description;
|
|
336
|
+
- product_option(选项名)→ title;
|
|
337
|
+
- product_option_value(选项取值,如 ALC / Penhold)→ **value**(不是 title!);
|
|
338
|
+
- product_category → name / description;product_collection → title;shipping_option → name。
|
|
326
339
|
⚠️ locale 键接受短码(en/zh/ms/id)或 BCP-47 区域码(en-US/zh-CN/ms-MY/id-ID),工具统一归一化为 BCP-47 落库——
|
|
327
340
|
storefront 对翻译接口一律请求 BCP-47、与库中 locale_code 精确匹配;历史按短码落库的行会被本次调用**改码修复**。
|
|
328
|
-
|
|
341
|
+
字段值传空字符串 = 把该字段译文置空(写入后请用 get_translations 回读确认,删除整条译文请到后台操作)。
|
|
342
|
+
用途:商品创建后补翻译/改翻译/修复多语言;把英文稿翻好后同步到其他语言。
|
|
343
|
+
默认 dry_run(confirm=false)预览将创建/更新哪些行。
|
|
329
344
|
```
|
|
330
345
|
|
|
331
346
|
## `trigger_native_csv_import`
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
| 功能 | 入口 |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| 商品列表与新建 | 侧边栏「产品(Products)」 |
|
|
10
|
+
| 按币种快速改价 | 商品详情页右侧「快捷价格管理」卡片 |
|
|
10
11
|
| 系列、分类、标签 | 「产品」下的系列、分类、产品标签 |
|
|
11
12
|
| 页头展示开关 | 目标系列详情页**最下方**的「页头展示」卡片 |
|
|
12
13
|
| 销售渠道 | 「设置」→「销售渠道」 |
|
|
@@ -107,12 +108,26 @@
|
|
|
107
108
|
|
|
108
109
|
| 目的 | 操作 |
|
|
109
110
|
| --- | --- |
|
|
110
|
-
| 改价 |
|
|
111
|
+
| 改价 | 快捷:「快捷价格管理」卡片直接改各币种金额 → 保存调整;精细:「变体」→ 点击变体 → 价格列表按币种修改 → 保存 |
|
|
111
112
|
| 补货 / 减库存 | 点击变体 → 库存页调整数量 → 保存 |
|
|
112
113
|
| 上架 / 下架 | 「属性」→ 编辑 → 状态改为「已发布」或「草稿」→ 保存 |
|
|
113
114
|
|
|
114
115
|
> 下架后前台立即不可见,不影响历史订单;已发布商品的修改即时反映到前台,未见变化可刷新页面。
|
|
115
116
|
|
|
117
|
+
## 操作:按币种快速改价(快捷价格管理)
|
|
118
|
+
|
|
119
|
+
商品详情页右侧「快捷价格管理」卡片按变体列出**已设置价格的币种**,改完金额点「保存调整」即生效。
|
|
120
|
+
|
|
121
|
+
| 规则 | 说明 |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| 只显示已有价格的币种 | 某变体缺某币种价格时,该行不显示(不做空行占位)。需要**新增**币种价格、维护促销价或区域价,仍走「变体」卡片 |
|
|
124
|
+
| 金额 = 主货币单位 | MYR 899.00 填 `899`,IDR 3200000 填 `3200000`,**不要乘 100** |
|
|
125
|
+
| 小数位随币种 | IDR / VND / JPY / KRW 为 0 位(填小数会报错拦下);MYR / SGD / PHP / THB / USD / EUR 为 2 位 |
|
|
126
|
+
| 只影响改动的行 | 同一变体一次性整体提交,未改动币种的价格保持原值 |
|
|
127
|
+
| 状态提示 | 行内「未保存」= 有改动未提交;保存成功后按钮左侧显示「价格已保存成功。」 |
|
|
128
|
+
|
|
129
|
+
> 同一商品有多个变体时,每个变体各自一张小卡,可分别展开 / 折叠;卡片底部统计「有 N 处修改待保存」。
|
|
130
|
+
|
|
116
131
|
## 操作:调整可售国家
|
|
117
132
|
|
|
118
133
|
1. 打开该商品 →「销售渠道」卡片 → 编辑。
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
- 「给 A 商品补 100 件库存」→ `set_product_stock`(product_id, quantity=100, 预览 → 确认;默认 Main Warehouse,指定仓传 location_id)。
|
|
10
10
|
- 「查一下最近 10 个待发货订单」→ `list_orders`(status=`pending`, limit=10)。
|
|
11
11
|
- 「后台怎么上架商品 / 退货审批在哪 / 促销为什么不生效」→ 检索随包《运营人员手册》(见 `SKILL.md`「系统使用问答」),按领域定位分册后引用原文回答。
|
|
12
|
-
- 「核对某商品多语言是否齐全」→ `get_translations`(reference_id=商品 id 或 handle),看 4 条区域码 locale
|
|
12
|
+
- 「核对某商品多语言是否齐全」→ `get_translations`(reference_id=商品 id 或 handle),看 4 条区域码 locale 的 `field_keys` 是否含 `title`/`description`(返回已按原样字段透出、默认不截断;只看 title 会漏判 subtitle)。
|
|
13
13
|
- 「给某商品补全中·马来·印尼语标题描述」→ `set_translations`(reference_id, `translations={"zh-CN":{...},"ms-MY":{...},"id-ID":{...}}`, 预览 → 确认)。同语言已存在则合并更新、不重复行。
|
|
14
14
|
- 「让这个商品在前端能搜到」→ `get_product` 取 id → `add_product_to_sales_channel`(`product_ids=[id]`, confirm=true)。
|
|
15
|
-
- 「补全某商品中文详情页内容」→ `create_product_content`(`locale=zh-CN`, `blocks=[{type:'richtext',data:{html:'...'}},{type:'specs',data:{rows:[...]}}]`, confirm=true)
|
|
15
|
+
- 「补全某商品中文详情页内容」→ `create_product_content`(`locale=zh-CN`, `blocks=[{type:'richtext',data:{html:'...'}},{type:'specs',data:{rows:[...]}}]`, confirm=true)。目标语言已有内容时必须带 `overwrite=true`(否则报错并回传 `existing`/`diff`),覆盖前自动备份到 `~/.derlux/content-backups/`。
|
|
16
|
+
- 「这款商品的英文详情页录好了,翻成中文/马来文/印尼文,版式别变」→ `get_product_content`(源 locale, 先确认 draft 还是 published) 取 `blocks[]` → 只翻文案、块结构与图片 URL 原样保留 → 逐语言 `create_product_content`(confirm=false 看 `existing`/`diff` → 有稿给运营确认后 `overwrite=true`) → 回读核对。完整步骤见 SKILL.md「多语言同步」。
|
|
17
|
+
- 「规格名和规格取值也翻一下」→ `set_translations(reference="product_option", reference_id=选项id, translations={"zh-CN":{"title":"..."}})`;选项取值用 `reference="product_option_value"` + 字段 **`value`**(写 `title` 会直接报错)。
|
|
16
18
|
- 「把这 5 款商品录入线上」→ `get_context()` → 填 `import-spec.template.json`(7 项声明齐全)→ 运营一次确认 → `batch_import_products` dry-run → commit,见 SKILL.md「批量导入」。
|
|
17
19
|
- 「读我本地文件夹里的 Excel,按批量导入模板整理好,我先看看」→ **通道 A**:读表后按 `product-import-template.csv` 列名生成填好的 CSV 文件交给运营核对;确认后可用 `trigger_native_csv_import` 上传预检(默认 `confirm=false`,零写入),运营明确同意后再 `confirm=true` 真正导入(也可由运营自己在后台 Products → Import 上传)。
|
|
18
20
|
- 「读我本地文件夹里的 Excel,整理成批量导入格式,先给我整批预览,确认后导入」→ **通道 B**:读表映射为 import-spec(推断不出的 7 项一次问清,不编造四语与汇率),写成 spec 文件用 `spec_path` 提交 → dry-run 预览 → 确认后 commit。两条通道见 SKILL.md「批量导入」。
|