@manturhub/cli 0.2.0 → 0.3.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.
package/bin/cli.js CHANGED
@@ -37,6 +37,7 @@ const HELP = `manturhub — ManturHub 算子广场 CLI v${VERSION}
37
37
  用法:
38
38
  manturhub login --key sk-xxx 配置 API Key(存 ~/.manturhub/config.json)
39
39
  manturhub ls [--cat <分类>] 列出上线算子(分类: text/image/video/audio/data)
40
+ manturhub describe <算子ID> 查看算子入参字段(喂参数前先看)
40
41
  manturhub run <算子ID> --json '{}' 调用算子(异步算子自动轮询到出结果;--no-wait 只拿 job_id)
41
42
  manturhub upload <本地文件> 上传图片/音频/视频 → 公网 URL(喂算子前先转换本地文件)
42
43
  manturhub status <poll_url> 查异步任务状态(配合 run --no-wait)
@@ -109,7 +110,38 @@ async function main() {
109
110
  for (const o of ops) {
110
111
  console.log(` ${o.id.padEnd(26)} ${o.name} [${o.cat}]`);
111
112
  }
112
- console.log(`\n用 \`manturhub run <算子ID> --json '{...}'\` 调用,参数见 ${"https://hub.mantur.cn"}/marketplace/<算子ID>`);
113
+ console.log(`\n用 \`manturhub describe <算子ID>\` 查入参,\`manturhub run <算子ID> --json '{...}'\` 调用`);
114
+ break;
115
+ }
116
+
117
+ case "describe":
118
+ case "show": {
119
+ const op = args[1];
120
+ if (!op || op.startsWith("--")) {
121
+ console.error("用法: manturhub describe <算子ID> (查看入参字段)");
122
+ process.exit(1);
123
+ }
124
+ const r = await apiFetch(`/api/v1/operators/${encodeURIComponent(op)}`);
125
+ if (!r.ok) {
126
+ console.error(`获取失败(HTTP ${r.status}): ${op}`);
127
+ process.exit(1);
128
+ }
129
+ const o = r.json.operator || r.json;
130
+ console.log(`\n${o.id} ${o.name || ""} [${o.cat || "-"}] · ${o.status || "-"}`);
131
+ if (o.description) console.log(o.description);
132
+ const ps = o.params_schema || (o.meta && o.meta.params_schema);
133
+ if (ps && Array.isArray(ps.fields) && ps.fields.length) {
134
+ console.log(`\n入参:`);
135
+ for (const f of ps.fields) {
136
+ const req = f.required ? "必填" : "可选";
137
+ const en = f.enum ? ` {${f.enum.join("|")}}` : "";
138
+ console.log(` ${String(f.name).padEnd(14)} ${String(f.type || "").padEnd(7)} ${req}${en} ${f.desc || ""}`);
139
+ }
140
+ if (ps.async) console.log(`\n异步算子:run 默认自动轮询到出结果(--no-wait 只拿 task_id)`);
141
+ } else {
142
+ console.log(`\n(该算子未声明入参 schema,详见 https://hub.mantur.cn/marketplace/${o.id})`);
143
+ }
144
+ console.log(`\n调用: manturhub run ${o.id} --json '{...}'`);
113
145
  break;
114
146
  }
115
147
 
package/lib/setup.js CHANGED
@@ -48,7 +48,7 @@ export function runInit() {
48
48
  // 1) 装全局「ManturHub 使用 skill」(Claude Code 用,让 agent 会用算子、少踩坑)
49
49
  const skillFile = installSkill();
50
50
  console.log(`✓ 已装 ManturHub 使用 skill:${skillFile}`);
51
- console.log(` (教 agent:先 manturhub ls 查字段、本地文件先 upload、异步 run 自动等结果、别重复调用)\n`);
51
+ console.log(` (教 agent:先 manturhub ls 找算子、describe 查字段、本地文件先 upload、异步 run 自动等结果、别重复调用)\n`);
52
52
  // 2) 写项目级 agent 引导
53
53
  const targets = ["AGENTS.md", "CLAUDE.md", ".cursorrules"];
54
54
  console.log("写入项目 agent 引导(幂等,可重复运行):");
package/lib/skill.js CHANGED
@@ -19,6 +19,7 @@ description: 调用 ManturHub 算子广场的 AI 能力(文生图/视频生成/
19
19
  | 命令 | 用途 |
20
20
  |---|---|
21
21
  | \`manturhub ls [--cat image\\|video\\|audio\\|text\\|data]\` | 列出全部算子(ID / 名称 / 分类)——不确定用哪个,先跑它 |
22
+ | \`manturhub describe <算子ID>\` | 查算子精确入参字段(必填/可选/枚举/说明)——**填参数前先跑它,别猜字段名** |
22
23
  | \`manturhub run <算子ID> --json '{...}'\` | 调用算子。**异步算子(图 / 视频 / 语音)会自动轮询到出结果**,直接拿最终 JSON |
23
24
  | \`manturhub upload <本地文件>\` | 本地图片 / 音频 / 视频 → 公网 URL(喂算子前必做;输出就是那个 URL) |
24
25
  | \`manturhub status <poll_url>\` | 查异步任务(仅当你用了 \`run --no-wait\`) |
@@ -26,7 +27,7 @@ description: 调用 ManturHub 算子广场的 AI 能力(文生图/视频生成/
26
27
 
27
28
  ## 五条铁律(不照做就会踩坑)
28
29
 
29
- 1. **先 \`manturhub ls\` 摸清能力** —— 某算子的精确入参字段见 https://hub.mantur.cn/marketplace/<算子ID> 。**字段名必须精确,拼错会被静默忽略、结果就不对。**
30
+ 1. **先 \`manturhub ls\` 摸清能力,再 \`manturhub describe <算子ID>\` 查精确入参** —— **字段名必须精确,拼错会被静默忽略、结果就不对**,所以填参数前一定先 describe 看字段,别凭记忆猜。
30
31
  2. **本地文件先 \`manturhub upload <文件>\`** 换成公网 URL,再把 URL 填进 run 的参数。算子不接受本地路径,只接受公网 URL。
31
32
  3. **异步算子直接等 \`run\` 返回** —— \`run\` 已自动轮询到 succeeded 才返回最终结果,**不要重复 run(会重复扣费 + 重复出活)**。视频可能要几分钟,耐心等。真想后台拿 \`job_id\` 用 \`--no-wait\`,之后 \`manturhub status <poll_url>\` 查。
32
33
  4. **花钱心里有数** —— 每次 run 扣馒头;余额不足报 \`INSUFFICIENT_BALANCE\`(去 https://hub.mantur.cn 充值);异步任务失败平台自动退费,无需自己处理退费。先 \`manturhub balance\` 看余额。
@@ -34,11 +35,11 @@ description: 调用 ManturHub 算子广场的 AI 能力(文生图/视频生成/
34
35
 
35
36
  ## 典型流程
36
37
 
37
- 1. \`manturhub ls\`(或 \`--cat image\`)找到算子 → marketplace 页确认入参字段
38
+ 1. \`manturhub ls\`(或 \`--cat image\`)找到算子 → \`manturhub describe <算子ID>\` 确认入参字段
38
39
  2. 有本地图片 / 视频 / 音频 → \`manturhub upload 文件\` 拿到公网 URL
39
40
  3. \`manturhub run <算子ID> --json '{...}'\` → 异步会自动等到出结果 → 从返回 JSON 取结果 URL
40
41
 
41
- ## 19 个算子(按域速查;入参以 \`manturhub ls\` / marketplace 为准)
42
+ ## 19 个算子(按域速查;入参以 \`manturhub describe <算子ID>\` 为准)
42
43
 
43
44
  - **图像**:\`image2\`(文生图 / 图生图)
44
45
  - **视频**:\`op.video.generate\`(生成)· \`op.video.compose\`(合成拼接)· \`op.video.understand-v2\`(视频理解)· \`op.video.upscale\`(超分)· \`op.video.subtitle-remover\`(擦字幕)
@@ -47,7 +48,7 @@ description: 调用 ManturHub 算子广场的 AI 能力(文生图/视频生成/
47
48
  - **短剧 / 拉片**:\`op.drama.search / episodes / download / adapt / insight\` · \`op.distill.list / shotscript / get-script\`
48
49
 
49
50
  > 例:\`manturhub run image2 --json '{"prompt":"a red fox in snow","n":1}'\`(异步,run 自动等到出图)。
50
- > 字段拼不准就 \`manturhub ls\` 或看 marketplace 页,别凭记忆猜。
51
+ > 字段拼不准就 \`manturhub describe <算子ID>\`,别凭记忆猜。
51
52
  `;
52
53
 
53
54
  // 装到用户级 ~/.claude/skills/manturhub/SKILL.md —— 装一次,所有 Claude Code 项目可用。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manturhub/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "ManturHub 算子广场 CLI:命令行直调 AI 算子 + 给 Claude Code / Codex / Cursor 等当 stdio MCP server",
5
5
  "type": "module",
6
6
  "bin": {