Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto eol=lf
*.png binary
*.jpg binary
*.jpeg binary
*.webp binary
5 changes: 5 additions & 0 deletions .github/workflows/skill-eval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ jobs:
python tools/corpus.py --selftest
python tools/fix_stats.py --selftest
python tools/atomize.py --selftest
python tools/mcp_server.py --selftest
python tools/vlm_review.py --selftest
python evals/real_trigger.py --selftest
- name: 插件清单与资源存在性
run: python tools/check_plugin.py
- name: promptfoo 配置结构
run: |
npx --yes promptfoo@$PROMPTFOO_VERSION validate config \
Expand Down
9 changes: 9 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mcpServers": {
"ecom-prompt-studio": {
"command": "python",
"args": ["${CLAUDE_PLUGIN_ROOT}/tools/mcp_server.py"],
"env": {}
}
}
}
17 changes: 17 additions & 0 deletions .zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ecom-prompt-studio",
"version": "2.1.0",
"description": "电商视觉五工作室提示词 SOP:34 个原子库、平台/品类/场景判据引擎、出图后平台机检与语料回流。",
"author": {
"name": "ADC1920"
},
"license": "MIT",
"skills": [
"./ecom-prompt-sop",
"./ecom-main-image-prompts",
"./ecom-detail-page-prompts"
],
"commands": "./commands",
"hooks": "./hooks/hooks.json",
"mcpServers": "./.mcp.json"
}
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 变更记录

本文件记录对外可见的形态变更。内部重构细节见 git log。

## 2.1.0 — 2026-11-12

装上就能用,不再是一半能力。

### 新增

- **ZCode 插件形态**:`.zcode-plugin/plugin.json` 声明三个技能、命令、hooks 与 MCP server,一次装齐。此前三个技能各自拷贝,脚本不随包走。
- **MCP server**(`tools/mcp_server.py`):四个工具,`query_atom` 定位原子、`get_template` 取模板与规则、`validate_prompt` 跑判据校验、`check_output` 平台机检。零依赖,标准库实现 JSON-RPC。
- **出图后自动机检**(`hooks/check_after_image.py`):`PostToolUse` 命中出图调用即跑平台机检,不过则把结果回注给模型。「机检不过不交付」从文档要求变成运行时强制。
- **斜杠命令**:`/ecom:main`、`/ecom:detail`、`/ecom:sku`、`/ecom:reverse` 四条,不用记五工位术语。
- **品牌锁规范**(`references/_brand-lock.md`):十个必锁视觉字段与 prepend 写法,解跨图漂移。
- **AIGC 标注义务库**(`references/_rules/aigc-disclosure.json`):FTC、加州 SB 942、纽约 SB 8420-A、EU AI Act Art.50、国内标识办法五地判据,含图类型四分类与四条红线。
- **视觉复核单生成器**(`tools/vlm_review.py`):产出结构化复核清单,启发式分只提示,结论由人给。

### 修复

- `fix_stats.py` 的提示仍指向已删除的 `--generate` 闭环。改为说明 manifest 需由外部通道产出并给出字段格式。

### 变更

- 出图通道维持不内置(2026-11-10 移除),机检与视觉验收改为对任意通道产出做后置校验。

## 2.0.0 — 2026-10-13

- 产品锁定改为「参考图为主 + 保留/改动清单」,负面词改为输出边界句。
- 新增套图风格锁、证据账本四级、AI 合规节。
- 新增静态检查 `lint_skills.py` 与触发用例。

## 1.0.0 — 2026-10-04

首个公开版本:34 篇 SOP、五个工位、三个技能。
99 changes: 99 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Ecom-Prompt-Studio

Prompt engineering for e-commerce visuals: turning "how to write a prompt" into a searchable, checkable, regression-tested production process.

Models can already write prompts. What's missing is three things — **criteria, examples, feedback** — and this repo is built around exactly those:

- **Criteria**: the whole SOP decomposed into 197 prompt templates, 571 rule clauses, 181 checklist items, and 122 placeholders. Every one is machine-readable.
- **Examples**: a positive-sample corpus, retrieved by similarity, so you can borrow wording that has already produced good images.
- **Feedback**: platform machine checks after generation. What fails doesn't ship; the fix sentence goes back into the prompt and the loop runs again.

Each subdirectory is a complete skill: copy it into your local skills directory and it works.

## Quick start

### As a ZCode plugin (recommended)

The repo root is a plugin. Add the repo directory as a local marketplace, then install:

```bash
git clone https://github.com/ADC1920/Ecom-Prompt-Studio.git
```

In ZCode: **Plugin Marketplace → Add → Add Plugin Marketplace**, paste the cloned directory, then install `ecom-prompt-studio` from **Personal**.

This installs all three skills, four slash commands, the post-generation check hook, and the MCP server in one step.

### As plain skills

```bash
cp -r Ecom-Prompt-Studio/ecom-prompt-sop ~/.agents/skills/
cp -r Ecom-Prompt-Studio/ecom-main-image-prompts ~/.agents/skills/
cp -r Ecom-Prompt-Studio/ecom-detail-page-prompts ~/.agents/skills/
```

Note: copying only a skill directory ships the SOP text but not `tools/`. For machine checks and the MCP server, use the plugin install.

## The five studios

The SOP library is organized by studio. Decide the studio first, then locate exactly one atom.

| Studio | Takes | Produces | Gate |
|---|---|---|---|
| **Main image** | full main-image set, single main image, buyer show, scene shot, white background | main-image plan + per-shot prompts + compliance check | retention list reused in every shot|claims sourced|first-image rules verified|output boundary sentence |
| **Detail page** | full detail page set, long image, page-by-page planning | page plan + per-page prompts | product lock before design|adjacent pages differ|anti-templating self-check |
| **SKU batch & cross-platform** | multi-color/multi-pack batches, multi-product swaps, 3:4 to 1:1, in-image text translation | variant plan + per-image prompts + conversion results | variant ownership stated|only count/color/layout change|no cropping after conversion|text translated not rewritten |
| **Model & video** | model head/clothing swaps, multi-pose shots, e-commerce video generation | model set or video prompts with timeline shots | faces don't drift|garment stays consistent|face-exposure rules met|video has a timeline |
| **Reverse engineering** | competitor images and videos, old-image refresh, SKU layout replication | breakdown table + replaced prompts + do-not-inherit list | brand names replaced|product traits not inherited|own product locked|video always gets a storyboard |

Studio priority: reverse/refresh → reverse studio; batch variants → SKU studio; real people or video → model studio; detail-page output → detail studio; everything else → main-image studio. Buyer shows stay in the main-image studio despite the word "batch".

## Three skills

| Skill | Takes | Size |
|---|---|---|
| `ecom-prompt-sop` | five-studio SOP atom library: main image, detail page, SKU batch, model & video, reverse engineering | 1 `SKILL.md` + atom library |
| `ecom-main-image-prompts` | main-image director: bare main-image requests with no category cue, plans the whole set around the buyer decision path | 1 `SKILL.md` + 2 reference files |
| `ecom-detail-page-prompts` | detail-page director: bare detail-page requests with no category cue, plans page structure and per-page prompts by category | 1 `SKILL.md` + 1 reference file |

The only routing rule: **category, action, or scenario cue present → SOP atom library; bare main image or bare detail page → hand off to the director skill.** This rule lives in `ecom-prompt-sop/SKILL.md` and the eval suite watches it.

## Tooling

| Script | What it does |
|---|---|
| `tools/atomize.py` | decompose SOPs into atoms, keep them self-contained, export readable text |
| `tools/compose_prompt.py` | five-slot prompt assembly, adds platform constraints and checks required fields |
| `tools/slop_check.py` | catches SD-era filler words, absolute claims, fake promotions, efficacy claims, AI tells |
| `tools/rules_engine.py` | validates slots against platform, category, and scenario rule files |
| `tools/check_image.py` | platform machine check after generation: white background, subject occupancy, ratio, resolution, file size, alpha channel, in-image text |
| `tools/visual_audit.py` | consistency and AI-feel heuristics — hints only, never a verdict |
| `tools/vlm_review.py` | generates a structured human review sheet; conclusions are always human |
| `tools/fix_stats.py` | repair-sentence effectiveness from manifests |
| `tools/corpus.py` | positive-sample corpus: add, similarity search, compile few-shot blocks |
| `tools/lint_skills.py` | full static check, the first CI gate |
| `tools/mcp_server.py` | MCP server exposing the atom library and checks as four tools |

Machine checks run against images from **any** channel. This repo deliberately does not bundle an image-generation CLI: bring your own endpoint, then verify the output here.

## MCP tools

| Tool | Input | Output |
|---|---|---|
| `query_atom` | category, output, action | matching atom ids with evidence |
| `get_template` | atom id, optional index | template text plus that atom's rules, checklists, placeholders |
| `validate_prompt` | prompt, optional platform/scenario/category | slop check and rule-engine results |
| `check_output` | image path, platform | platform machine-check results |

## Evals and CI

- `evals/cases.json` — 30 routing cases covering out-of-scope, prompt injection, and same-family disambiguation
- `evals/router.js` — builds the routing prompt from the three live `SKILL.md` files
- `evals/check_cases.py` — keeps the machine-readable cases and the human-readable view in sync
- `.github/workflows/skill-eval.yml` — static checks, eight script self-tests, routing regression on push/PR, weekly quality sampling

Routing regression feeds only the descriptions and routing table to a model and asserts the returned skill and atom. It catches "wrong skill" and "wrong atom" regressions; it does not judge prompt quality — that's what the quality sampling is for.

## License

MIT
62 changes: 53 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@

## 快速开始

两种运行方式,装法相同,都是把技能目录整体复制过去,保持 `<技能目录>/<技能名>/SKILL.md` 的层级:
### 推荐:作为 ZCode 插件安装

仓库根就是插件,三个技能、四条斜杠命令、出图后自动机检、MCP server 一次装齐:

```bash
git clone https://github.com/ADC1920/Ecom-Prompt-Studio.git
```

在 ZCode 里打开 **插件市场 → 添加 → 添加插件市场**,粘贴克隆下来的目录,然后在**个人**里安装 `ecom-prompt-studio`。

只拷单个技能目录也能用,但那会丢掉 `tools/`:机检、规则引擎、语料检索、MCP 工具都不在技能目录里,SKILL.md 提到脚本的地方只能人工代劳。要完整能力就走插件。

### 手动:只拷技能

```bash
git clone https://github.com/ADC1920/Ecom-Prompt-Studio.git
Expand Down Expand Up @@ -104,20 +116,37 @@ atomize compose slop check visual fix_stats
| `tools/visual_audit.py` | 视觉验收:主体一致性(感知哈希 + 颜色直方图)与 AI 感启发式,只提示不判定 |
| `tools/fix_stats.py` | 从 manifest 统计每条修复句的真实生效率,用来判断措辞要不要改 |
| `tools/corpus.py` | 正样本语料:录入、相似度检索、编译成 few-shot 范例段 |
| `tools/vlm_review.py` | 生成视觉复核单:启发式分只提示,结论由人给 |
| `tools/mcp_server.py` | MCP server:把原子库与判据暴露成四个可调用工具 |
| `tools/lint_skills.py` | 静态检查全集,CI 的第一道门 |
| `tools/check_plugin.py` | 插件清单自校验:字段、资源存在性、路径越界、事件名合法性 |

除 `check_image.py`、`visual_audit.py`、`vlm_review.py` 用到 Pillow 外全是标准库;带 `--selftest` 的都能离线验,不依赖密钥与网络。

八个工具带 `--selftest`,离线可验,不依赖密钥与网络。除 `check_image.py` 与 `visual_audit.py` 用到 Pillow 外全是标准库。
## 装机后自带的能力

装成插件之后,下面这些不靠模型自觉,是运行时机制:

| 机制 | 触发 | 效果 |
|---|---|---|
| 出图后自动机检 | 任何工具调用在 `out/` 下落了图,且命令里带 `--platform` | 跑平台机检,不通过就把结果回注给模型,提示修正重出 |
| MCP 四个工具 | 模型自行调用 | `query_atom` 定位原子、`get_template` 取模板、`validate_prompt` 校验、`check_output` 机检 |
| 斜杠命令 | 用户输入 `/ecom:main` 等 | 不用记五工位术语,直接进对应工位流程 |

MCP 工具的意义在于把「读文档 → 判工位 → 读原子 → 挑模板」四步压成一次调用。不接 MCP 时这四步全靠模型自己走。

`check_image.py` 的 OCR 会自己找 tesseract:不在 PATH 时扫常见安装路径,默认语言目录缺中文时去找用户级 tessdata。缺依赖就标 `skipped`,不会假装通过。

## 判据规则与语料

SOP 给的是「方法」,下面两样给的是「判据与范例」:
SOP 给的是「方法」,下面几样给的是「判据与范例」:

- `references/_rules/`:平台(12)、品类(9)、场景(11)三份 JSON,把硬判据变成可校验规则——白底与占比阈值、禁用宣称、必填槽位、画面禁项、AI 标注义务
- `references/_rules/aigc-disclosure.json`:AIGC 标注义务与法律依据,五地法条、图类型四分类、四条红线
- `references/_brand-lock.md`:品牌锁十个必锁字段与 prepend 写法,解跨图漂移
- `references/_corpus/`:验证过并出过好图的提示词样本,按相似度检索、编译成 few-shot

规则管「不能写什么」,语料管「写成什么样才算够」。
规则管「不能写什么」,语料管「写成什么样才算够」,品牌锁管「一套图看着像不像同一家」。

## 出图与授权

Expand All @@ -131,10 +160,12 @@ SOP 给的是「方法」,下面两样给的是「判据与范例」:

技能选错是用户最容易感知的问题,所以触发回归是评测主线。CI 分三层:

1. **静态检查**(每次 push / PR):`lint_skills.py` + `check_cases.py` + `atomize.py check` + 九个工具自检 + promptfoo 配置结构校验,不需要密钥
1. **静态检查**(每次 push / PR):`lint_skills.py` + `check_cases.py` + `atomize.py check` + `check_plugin.py` + 十一个工具自检 + promptfoo 配置结构校验,不需要密钥
2. **触发回归**(每次 push / PR):promptfoo 跑 30 条提示,断言命中的技能名与**原子编号**。评测输入直接读三个 `SKILL.md`,路由表一改立刻生效
3. **文本质量抽检**(每周一 + 手动):按原子编号读 `source_text` 生成提示词,用 `llm-rubric` 按该 SOP 的硬规则评分

三层之外还有一套**真实触发评测**(`evals/real_trigger.py`),只在里程碑手动跑:把技能目录交给真实引擎,看它是否自行加载并走到正确原子。前两层抓不到「装了但不触发」,这一层能,代价是慢且可能计费。

三个技能各带一份 `EVAL.md` 答案键(能力边界题 / 生产决策题 / 应用任务 + 评分口径)。答案键不链接进 `SKILL.md`,`lint_skills.py` 会校验它存在且未被入口引用——避免被评的 agent 直接读到答案。

模型经 DeepSeek 官方 provider 接入,密钥走仓库 Secret `DEEPSEEK_API_KEY`,不落任何文件。未配置时触发回归直接失败并报错,不会出现「没跑测试却全绿」。
Expand All @@ -143,7 +174,9 @@ SOP 给的是「方法」,下面两样给的是「判据与范例」:

```bash
python tools/lint_skills.py
python tools/check_plugin.py
python evals/check_cases.py
python evals/real_trigger.py --dry-run # 看真实评测会跑哪些用例
npx promptfoo@0.124.1 eval -c evals/promptfooconfig.yaml
npx promptfoo@0.124.1 eval -c evals/promptfooconfig.quality.yaml
```
Expand All @@ -154,19 +187,28 @@ npx promptfoo@0.124.1 eval -c evals/promptfooconfig.quality.yaml

```text
.
├─ .zcode-plugin/plugin.json # 插件清单:技能 + 命令 + hooks + MCP
├─ .mcp.json # MCP server 声明(四个工具)
├─ hooks/
│ ├─ hooks.json # PostToolUse 匹配出图调用
│ └─ check_after_image.py # 出图后自动机检并回注结果
├─ commands/ # /ecom:main /detail /sku /reverse
├─ ecom-prompt-sop/
│ ├─ SKILL.md # 五工作室入口:判工位 → 定位原子 → 取模板与规则
│ ├─ EVAL.md # 评测答案键(评测者用,不被 SKILL.md 引用)
│ └─ references/
│ ├─ _atoms/ # 原子库 + 索引 + 语义层 + 机械层
│ ├─ _rules/ # 平台 / 品类 / 场景判据
│ ├─ _rules/ # 平台 / 品类 / 场景判据 + AIGC 标注义务
│ ├─ _corpus/ # 正样本语料
│ ├─ _index.json # 篇目索引(槽位映射)
│ ├─ _brand-lock.md # 品牌锁十个字段
│ └─ _prompt-slots.md # 五槽位规范
├─ ecom-main-image-prompts/
├─ ecom-detail-page-prompts/
├─ tools/ # 拆解、组装、机检、闭环、验收、统计
├─ evals/ # promptfoo 配置、用例与断言脚本
├─ tools/ # 拆解、组装、机检、验收、统计、MCP、插件校验
├─ evals/ # promptfoo 配置、用例、断言脚本、真实触发评测
├─ CHANGELOG.md
├─ README.en.md
└─ .github/workflows/skill-eval.yml # CI(三个 job:静态 / 触发回归 / 质量抽检)
```

Expand All @@ -175,6 +217,8 @@ npx promptfoo@0.124.1 eval -c evals/promptfooconfig.quality.yaml
## 已知限制

- **AI 感阈值是经验值**:`visual_audit.py` 的饱和度、平滑度、死白、边缘密度这些判据,还没用真实的好图 / AI 图批次标定过,当提示用,不当结论
- **语料库只有 2 条种子**:检索质量取决于样本量,现在属于「能用但不够准」
- **语料库只有 2 条种子**:检索质量取决于样本量,现在属于「能用但不够准」。它靠真实出图积累,不能人工编造,所以这一步只能等实际使用
- **VLM 复核不自动判图**:`vlm_review.py` 只生成复核单,不给结论。VLM 在「保留约束是否满足」这类细粒度判断上会失准,把它的分数当通过依据会把错误固化
- **OCR 需要本地装 tesseract**:缺 pytesseract 或 tesseract 时这项走 skipped,不会误报通过;CI 环境没装,所以云端不检查图内文字
- **模板抽取有少量噪声**:少数没有围栏代码块的篇目走裸段落规则,个别片段可能偏宽,未逐篇人工复核
- **真实触发评测需自备引擎**:`evals/real_trigger.py` 只提供框架与判定逻辑,引擎命令与凭据由使用者提供,CI 里只跑它的离线自检
22 changes: 22 additions & 0 deletions commands/ecom-detail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
description: 出一套详情页提示词(详情页台)
---

# /ecom:detail

按五工位详情页台出逐页方案。

参数(都可选,缺了先问,不要猜):`$ARGUMENTS`

执行步骤:

1. 用 `query_atom` 定位原子,产物填详情页。
2. 用 `get_template` 取模板、规则与清单。
3. 先出**页面规划**:每页的关键词与职责,相邻页主题不得重复。
4. 再出**逐页提示词**:每页先写产品锁定约束,再写设计画面。
5. 每页写清构图、景别、镜头、产品位置、信息布局、文字排版、背景材质、光影,不得只写「放标题」。
6. 定稿前用 `validate_prompt` 自查。

防模板化自检:整套关键词与信息模块换个产品也能用,就重写。

没有品类线索的裸详情页方案,转 `ecom-detail-page-prompts` 技能。
Loading
Loading