@miravia_test/miravia-publish-skill 0.1.4 → 0.1.5

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/dist/SKILL.md CHANGED
@@ -119,6 +119,7 @@ description: Miravia 商品发布 AI Skill。仅负责商品创建(手动一
119
119
  | `need_images` | 部分图片迁移失败 | 替换图片后重跑 |
120
120
  | `unsupported_format` | 上传了不支持的文件格式(zip/txt/psd 等) | 提示仅支持 PDF/Word/Excel/Image/URL,允许重新上传 |
121
121
  | `file_empty_or_corrupted` | 文件内容为空或损坏(0KB PDF / 乱码 Word) | 提示文件内容为空或损坏,允许重新上传 |
122
+ | `llm_not_configured` | 未配置 LLM API key(OPENAI_API_KEY / DASHSCOPE_API_KEY),AI 抽取不可用 | 提示配置 key 后带 --source 重跑;不要绕过确认流程改走手动模式 |
122
123
  | `invalid_url` | 输入的 URL 无法抓取 | 提示检查 URL 后重试 |
123
124
  | `title_invalid` | 商品标题不符合规范(过短/过长/词数不足) | 提示具体错误 + 标题格式建议(Brand+Category+Model+Features+Scenario),阻断后续流程,禁止转 Draft |
124
125
  | `need_category_permission` | 卖家无该类目发布权限 | 询问是否以 Draft 模式发布(待审批通过后自动激活),提供类目权限申请链接 https://sellercenter.miravia.es/apps/setting/category;或更换类目后重跑 |
package/dist/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -102,6 +102,20 @@ class MiraviaListingSchema:
102
102
  # ---------------------------------------------------------------------------
103
103
 
104
104
 
105
+ class LLMNotConfiguredError(RuntimeError):
106
+ """Raised when AI extraction is requested but no LLM API key is configured.
107
+
108
+ Callers must surface this as a structured "llm_not_configured" status so
109
+ agents prompt for the key instead of silently bypassing the confirm-first
110
+ extraction flow.
111
+ """
112
+
113
+
114
+ LLM_NOT_CONFIGURED_HINT = (
115
+ "No LLM API key configured. Set OPENAI_API_KEY or DASHSCOPE_API_KEY."
116
+ )
117
+
118
+
105
119
  class LLMClient:
106
120
  """Minimal OpenAI-compatible LLM client."""
107
121
 
@@ -181,8 +195,12 @@ class ExtractionEngine:
181
195
 
182
196
  def extract(self, source_text: str) -> MiraviaListingSchema:
183
197
  if not self.client.is_configured():
184
- logger.warning("LLM not configured; running heuristic extraction")
185
- return self._heuristic_extract(source_text)
198
+ # Never silently degrade to heuristic extraction: without LLM the
199
+ # confirm-first flow (ctb → field summary → publish) breaks because
200
+ # agents judge the regex output unreliable and bypass the skill.
201
+ # Fail loudly so the caller returns a structured status instead.
202
+ logger.error("LLM not configured; refusing heuristic fallback")
203
+ raise LLMNotConfiguredError(LLM_NOT_CONFIGURED_HINT)
186
204
 
187
205
  schema_fields = "\n".join(f"- {f.name}" for f in fields(MiraviaListingSchema))
188
206
  messages = [
@@ -172,6 +172,8 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
172
172
  "pub_unsupported_format": "Unsupported file format: {source}. Only PDF, Word, Excel, Image, and URL are supported.",
173
173
  "pub_invalid_url": "Failed to fetch URL: {source}. Please check the URL and try again.",
174
174
  "pub_url_fetch_failed": "Failed to fetch content from {source}: {error}. Please check the URL and try again.",
175
+ "pub_llm_not_configured": "AI extraction is unavailable: no LLM API key is configured (OPENAI_API_KEY or DASHSCOPE_API_KEY).",
176
+ "pub_llm_not_configured_next": "Configure the LLM API key in the environment, then rerun with --source. Do not bypass the confirm-first flow with manual mode.",
175
177
  "pub_create_requires_category": "create_product requires --category-id (leaf category)",
176
178
  "pub_create_requires_name": "create_product requires --product-name",
177
179
  "pub_create_preview_message": "Please review the product creation details below and confirm before I create the product.",
@@ -807,6 +809,8 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
807
809
  "pub_unsupported_format": "不支持的文件格式:{source}。仅支持 PDF、Word、Excel、图片和 URL。",
808
810
  "pub_invalid_url": "无法获取 URL:{source}。请检查 URL 后重试。",
809
811
  "pub_url_fetch_failed": "无法从 {source} 获取内容:{error}。请检查 URL 后重试。",
812
+ "pub_llm_not_configured": "AI 抽取不可用:未配置 LLM API key(OPENAI_API_KEY 或 DASHSCOPE_API_KEY)。",
813
+ "pub_llm_not_configured_next": "请在环境中配置 LLM API key 后,带 --source 重新运行;不要绕过确认流程改走手动模式。",
810
814
  "pub_create_requires_category": "创建商品必须提供 --category-id(叶子类目 ID)",
811
815
  "pub_create_requires_name": "创建商品必须提供 --product-name(商品标题)",
812
816
  "pub_create_preview_message": "请检查以下商品信息,确认无误后我将创建商品。",
@@ -327,6 +327,15 @@ def _print_conversational_result(result: Dict[str, Any]) -> None:
327
327
  print(f"• {action}")
328
328
  return
329
329
 
330
+ # LLM not configured — fail loudly so agents configure the key instead of
331
+ # bypassing the confirm-first flow with manual mode
332
+ if status == "llm_not_configured":
333
+ print(result.get("message", ""))
334
+ print()
335
+ for action in result.get("next_actions", []):
336
+ print(f"• {action}")
337
+ return
338
+
330
339
  # Invalid URL
331
340
  if status == "invalid_url":
332
341
  print(result.get("message", ""))
@@ -33,6 +33,7 @@ from extraction_engine import (
33
33
  CRITICAL_FIELDS,
34
34
  ExtractionEngine,
35
35
  LLMClient,
36
+ LLMNotConfiguredError,
36
37
  MiraviaListingSchema,
37
38
  check_missing,
38
39
  validate_title,
@@ -1134,7 +1135,18 @@ class PublishModule:
1134
1135
 
1135
1136
  source_text = extract_text(content_items)
1136
1137
  engine = ExtractionEngine(LLMClient())
1137
- schema = engine.extract(source_text)
1138
+ try:
1139
+ schema = engine.extract(source_text)
1140
+ except LLMNotConfiguredError:
1141
+ # Fail loudly instead of degrading to regex: without LLM the
1142
+ # confirm-first order (title/brand/category before missing-field
1143
+ # summary) cannot be guaranteed, so agents must configure the key
1144
+ # rather than bypass the skill.
1145
+ return {
1146
+ "status": "llm_not_configured",
1147
+ "message": i18n._("pub_llm_not_configured"),
1148
+ "next_actions": [i18n._("pub_llm_not_configured_next")],
1149
+ }
1138
1150
 
1139
1151
  if getattr(self.args, "output_schema", False):
1140
1152
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miravia_test/miravia-publish-skill",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Miravia Product Publish Skill installer — one command to install the Miravia AI product listing skill into any AI Agent (Qoder / Cursor / Claude Code). Upload materials and let the AI extract data and publish products automatically.",
5
5
  "bin": {
6
6
  "miravia-publish-skill": "bin/cli.js"