@manturhub/cli 0.9.4 → 0.9.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/lib/params.js +18 -7
- package/lib/skill.js +1 -1
- package/package.json +2 -2
package/lib/params.js
CHANGED
|
@@ -4,7 +4,7 @@ function typeName(value) {
|
|
|
4
4
|
return typeof value;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function normalizeTypeToken(type) {
|
|
8
8
|
const t = String(type || "").toLowerCase();
|
|
9
9
|
if (t.endsWith("[]") || t.startsWith("array")) return "array";
|
|
10
10
|
if (t.includes("integer") || t === "int") return "integer";
|
|
@@ -15,8 +15,17 @@ function normalizeType(type) {
|
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
|
|
18
|
+
function normalizeTypes(type) {
|
|
19
|
+
const declared = Array.isArray(type)
|
|
20
|
+
? type
|
|
21
|
+
: String(type || "").split(/\s*\|\s*/);
|
|
22
|
+
return [...new Set(declared.map(normalizeTypeToken).filter(Boolean))];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function coerceValue(value, expectedTypes, name) {
|
|
26
|
+
if (typeof value !== "string" || !expectedTypes.length) return value;
|
|
27
|
+
if (expectedTypes.some((expected) => matchesType(value, expected))) return value;
|
|
28
|
+
const expected = expectedTypes[0];
|
|
20
29
|
if (expected === "boolean") {
|
|
21
30
|
if (value === "true") return true;
|
|
22
31
|
if (value === "false") return false;
|
|
@@ -67,10 +76,12 @@ export function validateParams(body, schema, { coerceStrings = false } = {}) {
|
|
|
67
76
|
const result = { ...body };
|
|
68
77
|
for (const [name, value] of Object.entries(result)) {
|
|
69
78
|
const field = byName.get(name);
|
|
70
|
-
const
|
|
71
|
-
const checked = coerceStrings ? coerceValue(value,
|
|
72
|
-
if (!matchesType(checked, expected)) {
|
|
73
|
-
throw new Error(
|
|
79
|
+
const expectedTypes = normalizeTypes(field.type);
|
|
80
|
+
const checked = coerceStrings ? coerceValue(value, expectedTypes, name) : value;
|
|
81
|
+
if (expectedTypes.length && !expectedTypes.some((expected) => matchesType(checked, expected))) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`参数 ${name} 类型错误:需要 ${expectedTypes.join(" 或 ")},收到 ${typeName(checked)}`
|
|
84
|
+
);
|
|
74
85
|
}
|
|
75
86
|
if (Array.isArray(field.enum) && !field.enum.includes(checked)) {
|
|
76
87
|
throw new Error(`参数 ${name} 只能是: ${field.enum.join(" | ")}`);
|
package/lib/skill.js
CHANGED
|
@@ -67,7 +67,7 @@ description: 调用 ManturHub 算子广场的 AI 能力与行业数据(文生图
|
|
|
67
67
|
- \`manturhub describe <算子ID>\` → 某算子的精确入参字段
|
|
68
68
|
|
|
69
69
|
> 能力大类参考(具体算子 ID 以 \`ls\` 实时为准):图像生成、花字渲染、视频生成 / 合成 / 理解 / 超分 / 擦字幕 / 配字幕、**剧本/分镜/参考图 → 动态提示词 → 无字黑白线稿 → 视频成片**、语音合成 / 克隆 / 音色设计 / 语音转写、电商文案、**Seedance2.0提示词润色(把需求或粗糙提示词+参考图润色成专业视频生成提示词,生成前先用它省重roll的钱)**、短剧拉片 / 改编 / 剧本评估、漫剧·短剧市场洞察(热榜 / 爆量 / 出海投放数据,\`ls --cat data\` 可见)。
|
|
70
|
-
> 例:\`manturhub run
|
|
70
|
+
> 例:\`manturhub run op.image.generate --json '{"prompt":"a red fox in snow","n":1}'\`(异步,run 自动等到出图)。字段拼不准就 \`manturhub describe <算子ID>\`,别凭记忆猜。
|
|
71
71
|
`;
|
|
72
72
|
|
|
73
73
|
// 默认同时安装 Claude Code 和 Codex 用户级 Skill。
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manturhub/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "ManturHub 算子广场 CLI:通过 REST 发现和调用 AI 算子、浏览配方,并安装 Skill 与 Agent 套件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"manturhub": "
|
|
7
|
+
"manturhub": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=18"
|