@lingjingai/lj-awb-cli 0.3.15 → 0.4.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/README.md +28 -27
- package/build/_shared.mjs +130 -0
- package/build/build.mjs +3 -0
- package/build/pre-publish.mjs +57 -0
- package/build/pre.mjs +8 -107
- package/build/prod.mjs +9 -78
- package/install.mjs +1 -0
- package/package.json +8 -3
- package/packages/awb-cli/README.md +0 -3
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +6 -2
- package/packages/awb-core/src/api.js +33 -64
- package/packages/awb-core/src/artifact.js +75 -6
- package/packages/awb-core/src/auth.js +1 -1
- package/packages/awb-core/src/commands.js +279 -118
- package/packages/awb-core/src/common.js +3 -2
- package/packages/awb-core/src/output.js +2310 -106
- package/packages/awb-core/src/services.js +855 -113
- package/packages/awb-core/src/standalone.js +841 -242
- package/skills/lj-awb/SKILL.md +84 -74
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +3 -3
- package/skills/lj-awb/modules/account.md +20 -7
- package/skills/lj-awb/modules/artifact/asset.md +64 -0
- package/skills/lj-awb/modules/artifact/clip.md +65 -0
- package/skills/lj-awb/modules/artifact/script.md +37 -0
- package/skills/lj-awb/modules/artifact/video.md +65 -0
- package/skills/lj-awb/modules/artifact.md +31 -52
- package/skills/lj-awb/modules/asset.md +50 -11
- package/skills/lj-awb/modules/auth.md +10 -4
- package/skills/lj-awb/modules/create-contract.md +21 -12
- package/skills/lj-awb/modules/create.md +37 -0
- package/skills/lj-awb/modules/credits.md +6 -0
- package/skills/lj-awb/modules/driver.md +125 -0
- package/skills/lj-awb/modules/evals.md +84 -36
- package/skills/lj-awb/modules/image.md +19 -12
- package/skills/lj-awb/modules/model.md +31 -31
- package/skills/lj-awb/modules/project.md +7 -0
- package/skills/lj-awb/modules/subject.md +28 -7
- package/skills/lj-awb/modules/task-manual.md +32 -28
- package/skills/lj-awb/modules/task.md +70 -8
- package/skills/lj-awb/modules/upload.md +16 -2
- package/skills/lj-awb/modules/video.md +30 -28
- package/skills/lj-awb/modules/workflows.md +232 -169
- package/skills/lj-awb/references/error-codes.md +109 -0
- package/skills/lj-awb/references/model-options-read.md +19 -12
- package/skills/lj-awb/references/output-fields.md +118 -0
|
@@ -3,7 +3,15 @@ import path from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { LingjingAwbCliError, createEnvelope, toBool, toInt } from './common.js';
|
|
5
5
|
import { registerAwbCommands } from './commands.js';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
formatCsvOutput,
|
|
8
|
+
formatPrettyError,
|
|
9
|
+
formatPrettyOutput,
|
|
10
|
+
formatTextError,
|
|
11
|
+
formatTextOutput,
|
|
12
|
+
formatYamlEnvelope,
|
|
13
|
+
normalizeJsonData,
|
|
14
|
+
} from './output.js';
|
|
7
15
|
|
|
8
16
|
function normalizeKey(value) {
|
|
9
17
|
return String(value || '').replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
@@ -24,10 +32,13 @@ const OPTION_SYNONYMS = {
|
|
|
24
32
|
threads: ['concurrency'],
|
|
25
33
|
output: ['format'],
|
|
26
34
|
json: ['format'],
|
|
35
|
+
keyword: ['model'],
|
|
27
36
|
input: ['inputFile'],
|
|
28
37
|
in: ['inputFile'],
|
|
29
38
|
dry: ['dryRun'],
|
|
30
39
|
force: ['yes'],
|
|
40
|
+
remoteTaskId: ['taskId'],
|
|
41
|
+
publicId: ['taskId'],
|
|
31
42
|
};
|
|
32
43
|
|
|
33
44
|
function levenshtein(a, b) {
|
|
@@ -58,6 +69,16 @@ function suggestSimilarOptions(unknownKey, allowedKeys) {
|
|
|
58
69
|
for (const syn of synonyms) {
|
|
59
70
|
if (allowedKeys.includes(syn)) record(syn, -1);
|
|
60
71
|
}
|
|
72
|
+
if (unknownKey.length === 1) {
|
|
73
|
+
const ch = unknownKey.toLowerCase();
|
|
74
|
+
for (const allowed of allowedKeys) {
|
|
75
|
+
if (allowed.toLowerCase().startsWith(ch)) record(allowed, 1);
|
|
76
|
+
}
|
|
77
|
+
return [...scored.entries()]
|
|
78
|
+
.sort((x, y) => x[1] - y[1])
|
|
79
|
+
.slice(0, 3)
|
|
80
|
+
.map(([key]) => formatOptionName(key));
|
|
81
|
+
}
|
|
61
82
|
for (const allowed of allowedKeys) {
|
|
62
83
|
const a = unknownKey.toLowerCase();
|
|
63
84
|
const b = allowed.toLowerCase();
|
|
@@ -83,6 +104,57 @@ function renderCliText(value) {
|
|
|
83
104
|
return String(value ?? '').replace(/\blj-awb\b/g, commandPrefix());
|
|
84
105
|
}
|
|
85
106
|
|
|
107
|
+
function shouldColorOutput() {
|
|
108
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === '0') return false;
|
|
109
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === 'false') return false;
|
|
110
|
+
if (String(process.env.FORCE_COLOR || '').trim() && process.env.FORCE_COLOR !== '0') return true;
|
|
111
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === '1') return true;
|
|
112
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === 'true') return true;
|
|
113
|
+
if (process.env.NO_COLOR) return false;
|
|
114
|
+
return Boolean(process.stdout.isTTY);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function colorText(value, code) {
|
|
118
|
+
const text = String(value ?? '');
|
|
119
|
+
return shouldColorOutput() && text ? `\u001b[${code}m${text}\u001b[0m` : text;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const HELP_COLOR = {
|
|
123
|
+
title: '1;38;5;39',
|
|
124
|
+
accent: '1;38;5;208',
|
|
125
|
+
heading: '1;38;5;75',
|
|
126
|
+
command: '38;5;82',
|
|
127
|
+
group: '38;5;215',
|
|
128
|
+
muted: '2;38;5;245',
|
|
129
|
+
option: '38;5;111',
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
function helpTitle(value) {
|
|
133
|
+
if (!shouldColorOutput()) return String(value ?? '');
|
|
134
|
+
return `${colorText('◆', HELP_COLOR.accent)} ${colorText(value, HELP_COLOR.title)}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function helpHeading(value) {
|
|
138
|
+
if (!shouldColorOutput()) return String(value ?? '');
|
|
139
|
+
return `${colorText('▸', HELP_COLOR.accent)} ${colorText(value, HELP_COLOR.heading)}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function helpCommand(value) {
|
|
143
|
+
return colorText(value, HELP_COLOR.command);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function helpGroup(value) {
|
|
147
|
+
return colorText(value, HELP_COLOR.group);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function helpMuted(value) {
|
|
151
|
+
return colorText(value, HELP_COLOR.muted);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function helpOption(value) {
|
|
155
|
+
return colorText(value, HELP_COLOR.option);
|
|
156
|
+
}
|
|
157
|
+
|
|
86
158
|
function shellArg(value) {
|
|
87
159
|
const text = String(value ?? '');
|
|
88
160
|
return /^[A-Za-z0-9_./:=@,+-]+$/.test(text) ? text : JSON.stringify(text);
|
|
@@ -116,7 +188,7 @@ function commandInvocation(commandName, kwargs = {}, options = {}) {
|
|
|
116
188
|
|
|
117
189
|
function buildOutputContext(command, kwargs = {}) {
|
|
118
190
|
const optionKeys = new Set((command.args || []).map((arg) => normalizeKey(arg.name)));
|
|
119
|
-
const canSuggestDryRunExecution = command.name !== 'auth login
|
|
191
|
+
const canSuggestDryRunExecution = command.name !== 'auth login';
|
|
120
192
|
const withoutDryRun = { omit: ['dryRun'] };
|
|
121
193
|
const isModelList = command.name === 'model image-models' || command.name === 'model video-models';
|
|
122
194
|
const modelListAll = isModelList && toBool(kwargs.all);
|
|
@@ -128,6 +200,8 @@ function buildOutputContext(command, kwargs = {}) {
|
|
|
128
200
|
: null;
|
|
129
201
|
return {
|
|
130
202
|
jsonCommand: `${commandInvocation(command.name, kwargs)} -f json`,
|
|
203
|
+
textCommand: `${commandInvocation(command.name, kwargs)} -f text`,
|
|
204
|
+
outputKind: buildCommandWorkflow(command).outputKind,
|
|
131
205
|
executeCommand: canSuggestDryRunExecution && toBool(kwargs.dryRun) ? commandInvocation(command.name, kwargs, withoutDryRun) : null,
|
|
132
206
|
confirmCommand: canSuggestDryRunExecution && toBool(kwargs.dryRun) && optionKeys.has('yes')
|
|
133
207
|
? commandInvocation(command.name, kwargs, { omit: ['dryRun'], set: { yes: true } })
|
|
@@ -136,6 +210,28 @@ function buildOutputContext(command, kwargs = {}) {
|
|
|
136
210
|
};
|
|
137
211
|
}
|
|
138
212
|
|
|
213
|
+
const OUTPUT_FORMAT_ALIASES = {
|
|
214
|
+
agent: 'text',
|
|
215
|
+
table: 'pretty',
|
|
216
|
+
human: 'pretty',
|
|
217
|
+
compact: 'text',
|
|
218
|
+
'compact-text': 'text',
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const SUPPORTED_OUTPUT_FORMATS = new Set(['auto', 'pretty', 'text', 'json', 'yaml', 'csv']);
|
|
222
|
+
|
|
223
|
+
function resolveOutputFormat(format) {
|
|
224
|
+
const raw = String(format || 'pretty').trim().toLowerCase();
|
|
225
|
+
const normalized = OUTPUT_FORMAT_ALIASES[raw] || raw;
|
|
226
|
+
if (normalized === 'auto') return process.stdout.isTTY ? 'pretty' : 'text';
|
|
227
|
+
if (SUPPORTED_OUTPUT_FORMATS.has(normalized)) return normalized;
|
|
228
|
+
throw new LingjingAwbCliError(`未知输出格式:${format}`, {
|
|
229
|
+
type: 'argument_error',
|
|
230
|
+
exitCode: 2,
|
|
231
|
+
hint: '可用格式:pretty、text、json、yaml、csv、auto。Agent 建议使用 -f text;严格脚本解析再用 -f json。',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
139
235
|
function assignKwarg(kwargs, key, value) {
|
|
140
236
|
if (kwargs[key] === undefined) {
|
|
141
237
|
kwargs[key] = value;
|
|
@@ -151,7 +247,8 @@ function assignKwarg(kwargs, key, value) {
|
|
|
151
247
|
function parseArgv(argv) {
|
|
152
248
|
const commandParts = [];
|
|
153
249
|
const kwargs = {};
|
|
154
|
-
|
|
250
|
+
const kwargRawFlags = {};
|
|
251
|
+
let format = 'pretty';
|
|
155
252
|
|
|
156
253
|
for (let index = 0; index < argv.length; index += 1) {
|
|
157
254
|
const token = argv[index];
|
|
@@ -180,10 +277,27 @@ function parseArgv(argv) {
|
|
|
180
277
|
}
|
|
181
278
|
continue;
|
|
182
279
|
}
|
|
280
|
+
if (token.length > 1 && token.startsWith('-') && /^-[A-Za-z]/.test(token)) {
|
|
281
|
+
const raw = token.slice(1);
|
|
282
|
+
const eqIndex = raw.indexOf('=');
|
|
283
|
+
const keyPart = eqIndex >= 0 ? raw.slice(0, eqIndex) : raw;
|
|
284
|
+
const inlineValue = eqIndex >= 0 ? raw.slice(eqIndex + 1) : undefined;
|
|
285
|
+
const key = normalizeKey(keyPart);
|
|
286
|
+
if (!(key in kwargRawFlags)) kwargRawFlags[key] = token;
|
|
287
|
+
if (inlineValue !== undefined) {
|
|
288
|
+
assignKwarg(kwargs, key, inlineValue);
|
|
289
|
+
} else if (argv[index + 1] && !argv[index + 1].startsWith('-')) {
|
|
290
|
+
assignKwarg(kwargs, key, argv[index + 1]);
|
|
291
|
+
index += 1;
|
|
292
|
+
} else {
|
|
293
|
+
assignKwarg(kwargs, key, true);
|
|
294
|
+
}
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
183
297
|
commandParts.push(token);
|
|
184
298
|
}
|
|
185
299
|
|
|
186
|
-
return { commandName: commandParts.join(' '), kwargs, format };
|
|
300
|
+
return { commandName: commandParts.join(' '), kwargs, kwargRawFlags, format };
|
|
187
301
|
}
|
|
188
302
|
|
|
189
303
|
async function readVersion() {
|
|
@@ -201,20 +315,49 @@ const VIRTUAL_COMMANDS = [
|
|
|
201
315
|
'输出机器可读命令 schema,供 Agent / 脚本理解命令、参数和示例',
|
|
202
316
|
'',
|
|
203
317
|
'Examples:',
|
|
318
|
+
' lj-awb schema --brief -f json',
|
|
204
319
|
' lj-awb schema -f json',
|
|
205
|
-
' lj-awb schema --domain
|
|
206
|
-
' lj-awb schema --domain
|
|
320
|
+
' lj-awb schema --domain create -f json',
|
|
321
|
+
' lj-awb schema --domain create --command image -f json',
|
|
207
322
|
'',
|
|
208
|
-
'Hint: Agent
|
|
323
|
+
'Hint: Agent 先读 --brief 掌握能力地图;执行具体命令前再读精确 schema。',
|
|
209
324
|
].join('\n'),
|
|
210
325
|
args: [
|
|
211
|
-
{ name: '
|
|
212
|
-
{ name: '
|
|
326
|
+
{ name: 'brief', description: '输出面向 Agent 的轻量能力摘要,不展开每个参数' },
|
|
327
|
+
{ name: 'domain', valueName: 'name', description: '按命令域过滤,如 create / task / artifact / system' },
|
|
328
|
+
{ name: 'command', valueName: 'name', description: '按子命令过滤,如 image / video / wait / doctor' },
|
|
213
329
|
],
|
|
214
330
|
},
|
|
215
331
|
];
|
|
216
332
|
|
|
217
333
|
const RENAMED_COMMAND_HINTS = {
|
|
334
|
+
image: 'create image',
|
|
335
|
+
'image fee': 'create image-fee',
|
|
336
|
+
'image create': 'create image',
|
|
337
|
+
'image create-batch': 'create image-batch',
|
|
338
|
+
'image status': 'task image-status',
|
|
339
|
+
video: 'create video',
|
|
340
|
+
'video fee': 'create video-fee',
|
|
341
|
+
'video create': 'create video',
|
|
342
|
+
'video create-batch': 'create video-batch',
|
|
343
|
+
'video status': 'task video-status',
|
|
344
|
+
'video subtitle-remove': 'create video-subtitle-removal',
|
|
345
|
+
'video subtitle-status': 'task video-subtitle-status',
|
|
346
|
+
asset: 'create asset',
|
|
347
|
+
'asset match-actor': 'create asset-match-actor',
|
|
348
|
+
'asset groups': 'create asset-groups',
|
|
349
|
+
'asset group': 'create asset-group-get',
|
|
350
|
+
'asset group-create': 'create asset-group',
|
|
351
|
+
'asset group-update': 'create asset-group-update',
|
|
352
|
+
'asset register': 'create asset',
|
|
353
|
+
subject: 'create subject',
|
|
354
|
+
'subject list': 'create subject-list',
|
|
355
|
+
'subject publish': 'create subject',
|
|
356
|
+
'subject wait': 'create subject-wait',
|
|
357
|
+
'subject publish-batch': 'create subject-batch',
|
|
358
|
+
'subject voice list': 'create subject-voice-list',
|
|
359
|
+
'subject voice create': 'create subject-voice',
|
|
360
|
+
'subject voice wait': 'create subject-voice-wait',
|
|
218
361
|
'workspace me': 'account info',
|
|
219
362
|
'workspace teams': 'account teams',
|
|
220
363
|
'workspace team-select': 'account switch-team',
|
|
@@ -229,6 +372,16 @@ const RENAMED_COMMAND_HINTS = {
|
|
|
229
372
|
'billing usage-summary': 'credits usage',
|
|
230
373
|
};
|
|
231
374
|
|
|
375
|
+
const MODEL_LIST_GUESS_HINT = `按任务类型分开查询:生图候选用 ${'`'}lj-awb model image-models${'`'},生视频候选用 ${'`'}lj-awb model video-models${'`'}。运行 lj-awb model -h 查看 model 域全部命令。`;
|
|
376
|
+
const COMMAND_GUESS_HINTS = {
|
|
377
|
+
'model list': MODEL_LIST_GUESS_HINT,
|
|
378
|
+
'model models': MODEL_LIST_GUESS_HINT,
|
|
379
|
+
'model ls': MODEL_LIST_GUESS_HINT,
|
|
380
|
+
'model image': MODEL_LIST_GUESS_HINT,
|
|
381
|
+
'model video': MODEL_LIST_GUESS_HINT,
|
|
382
|
+
'models': MODEL_LIST_GUESS_HINT,
|
|
383
|
+
};
|
|
384
|
+
|
|
232
385
|
function buildRegistry() {
|
|
233
386
|
const commands = [];
|
|
234
387
|
registerAwbCommands((spec) => commands.push(spec));
|
|
@@ -249,6 +402,23 @@ function isCommandGroupName(commandName, commands) {
|
|
|
249
402
|
return Boolean(commandName && commands.some((command) => commandGroup(command) === commandName));
|
|
250
403
|
}
|
|
251
404
|
|
|
405
|
+
function commandSubgroupTokens(command) {
|
|
406
|
+
const parts = String(command.name || '').split(' ').filter(Boolean);
|
|
407
|
+
if (parts.length < 3) return null;
|
|
408
|
+
return [parts[0], parts[1]];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function isCommandSubgroupName(commandName, commands) {
|
|
412
|
+
const parts = String(commandName || '').split(' ').filter(Boolean);
|
|
413
|
+
if (parts.length !== 2) return false;
|
|
414
|
+
const [group, subgroup] = parts;
|
|
415
|
+
if (!SUBGROUP_DESCRIPTIONS[group]?.[subgroup]) return false;
|
|
416
|
+
return commands.some((command) => {
|
|
417
|
+
const tokens = commandSubgroupTokens(command);
|
|
418
|
+
return tokens && tokens[0] === group && tokens[1] === subgroup;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
252
422
|
function resolveCommandName(commandName, commands) {
|
|
253
423
|
const exact = commands.find((command) => command.name === commandName);
|
|
254
424
|
if (exact) return commandName;
|
|
@@ -268,27 +438,57 @@ const GROUP_DESCRIPTIONS = {
|
|
|
268
438
|
project: '项目:查看、切换、创建和更新项目组',
|
|
269
439
|
credits: '积分:查询可扣积分余额、项目组预算和用量统计',
|
|
270
440
|
model: '模型:查询生图 / 生视频模型、参数约束和创建用法',
|
|
441
|
+
create: '创建:统一提交图片、视频、主体、音色、素材和视频去字幕任务',
|
|
271
442
|
upload: '上传:把本地文件上传为平台可访问素材',
|
|
272
|
-
image: '图片:估价、提交、批量提交和查询生图任务',
|
|
273
|
-
video: '视频:估价、提交、批量提交、查询和去字幕',
|
|
274
443
|
task: '任务:任务列表、等待和本地任务台账',
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
444
|
+
artifact: '最终产物:剧本、资产、视频、剪辑 CRUD 与本地 JSON 导入',
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const SUBGROUP_DESCRIPTIONS = {
|
|
448
|
+
artifact: {
|
|
449
|
+
script: '剧本:document / asset / state / speaker / episode / scene / action 行 CRUD 与 script.json 批量导入',
|
|
450
|
+
asset: '资产:角色 / 道具 / 场景 及其状态 CRUD,actors/props/locations JSON 批量导入',
|
|
451
|
+
video: '视频:集 / 场 / clip 三级最终产物 CRUD 与 storyboard 批量导入',
|
|
452
|
+
clip: '剪辑:按集组织的剪辑宽表 CRUD 与状态更新',
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const SUBGROUP_EXAMPLES = {
|
|
457
|
+
'artifact script': [
|
|
458
|
+
'lj-awb artifact script import --project-id <projectId> --input-file 1_script/output/script.json --dry-run',
|
|
459
|
+
'lj-awb artifact script get --project-id <projectId>',
|
|
460
|
+
'lj-awb artifact script rows --project-id <projectId> --row-kind scene',
|
|
461
|
+
],
|
|
462
|
+
'artifact asset': [
|
|
463
|
+
'lj-awb artifact asset import --project-id <projectId> --input-dir 2_asset/output --dry-run',
|
|
464
|
+
'lj-awb artifact asset actors --project-id <projectId> --include-states true',
|
|
465
|
+
'lj-awb artifact asset props --project-id <projectId>',
|
|
466
|
+
],
|
|
467
|
+
'artifact video': [
|
|
468
|
+
'lj-awb artifact video import-storyboard --project-id <projectId> --input-file 3_footage/output/ep001/ep001_storyboard.json --dry-run',
|
|
469
|
+
'lj-awb artifact video episodes --project-id <projectId>',
|
|
470
|
+
'lj-awb artifact video clips --project-id <projectId> --episode-id ep_001 --scene-id scn_001',
|
|
471
|
+
],
|
|
472
|
+
'artifact clip': [
|
|
473
|
+
'lj-awb artifact clip upsert-episode --project-id <projectId> --input-file 4_clip/output/ep001_clip_output.json --dry-run',
|
|
474
|
+
'lj-awb artifact clip episodes --project-id <projectId>',
|
|
475
|
+
'lj-awb artifact clip episode-by-id --project-id <projectId> --episode-id ep_001',
|
|
476
|
+
],
|
|
278
477
|
};
|
|
279
478
|
|
|
280
479
|
const GROUP_EXAMPLES = {
|
|
281
480
|
system: [
|
|
282
481
|
'lj-awb doctor',
|
|
283
482
|
'lj-awb doctor --verify',
|
|
483
|
+
'lj-awb schema --brief -f json',
|
|
284
484
|
'lj-awb schema -f json',
|
|
285
|
-
'lj-awb schema --domain
|
|
485
|
+
'lj-awb schema --domain create -f json',
|
|
286
486
|
],
|
|
287
487
|
auth: [
|
|
288
488
|
'lj-awb auth status',
|
|
289
489
|
'lj-awb auth verify',
|
|
290
|
-
'lj-awb auth login
|
|
291
|
-
'LINGJING_AWB_ACCESS_KEY=<access-key> lj-awb auth login
|
|
490
|
+
'lj-awb auth login --access-key <access-key>',
|
|
491
|
+
'LINGJING_AWB_ACCESS_KEY=<access-key> lj-awb auth login',
|
|
292
492
|
'lj-awb auth clear --dry-run',
|
|
293
493
|
],
|
|
294
494
|
account: [
|
|
@@ -309,6 +509,7 @@ const GROUP_EXAMPLES = {
|
|
|
309
509
|
model: [
|
|
310
510
|
'lj-awb model image-models --model Banana',
|
|
311
511
|
'lj-awb model video-models --model Seedance',
|
|
512
|
+
'lj-awb model asset-review-models --platform JIMENG',
|
|
312
513
|
'lj-awb model input-guide',
|
|
313
514
|
'lj-awb model options --model-group-code <code>',
|
|
314
515
|
'lj-awb model create-spec --model-group-code <code>',
|
|
@@ -316,34 +517,29 @@ const GROUP_EXAMPLES = {
|
|
|
316
517
|
upload: [
|
|
317
518
|
'lj-awb upload files --files ./a.png,./b.mp4 --dry-run',
|
|
318
519
|
],
|
|
319
|
-
|
|
320
|
-
'lj-awb image
|
|
321
|
-
'lj-awb image
|
|
322
|
-
'lj-awb
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
'lj-awb
|
|
326
|
-
'lj-awb
|
|
327
|
-
'lj-awb
|
|
328
|
-
'lj-awb video subtitle-status --remote-task-id <id>',
|
|
520
|
+
create: [
|
|
521
|
+
'lj-awb create image --model-group-code <code> --prompt "一只小狗" --dry-run',
|
|
522
|
+
'lj-awb create image-fee --model-group-code <code> --prompt "一只小狗"',
|
|
523
|
+
'lj-awb create video --model-group-code <code> --prompt "镜头推进" --resource image:first_frame=./actor.png --dry-run',
|
|
524
|
+
'lj-awb create video-fee --model-group-code <code> --prompt "雨夜奔跑" --duration 5',
|
|
525
|
+
'lj-awb create subject --model-code tx --name 女主 --resource primary:./three-view.png --dry-run',
|
|
526
|
+
'lj-awb create subject-wait --element-id <elementId> --wait-seconds 300',
|
|
527
|
+
'lj-awb create asset --group-id <id> --platform JIMENG --file ./actor.png --name "女主正面" --dry-run',
|
|
528
|
+
'lj-awb create asset-groups --platform JIMENG --name "女主"',
|
|
329
529
|
],
|
|
330
530
|
task: [
|
|
331
531
|
'lj-awb task list --task-type IMAGE_CREATE --project-group-no <no>',
|
|
532
|
+
'lj-awb task image-status --task-id <imageTaskId>',
|
|
533
|
+
'lj-awb task video-status --task-id <videoTaskId>',
|
|
534
|
+
'lj-awb task video-subtitle-status --task-id <subtitleTaskId>',
|
|
332
535
|
'lj-awb task wait --task-id <id> --task-type IMAGE_CREATE --wait-seconds 180',
|
|
333
536
|
'lj-awb task records --task-record-file .awb/tasks.jsonl',
|
|
334
537
|
],
|
|
335
|
-
asset: [
|
|
336
|
-
'lj-awb asset match-actor --description "十八岁少女,古风" --tags-json \'{"gender":"女"}\'',
|
|
337
|
-
'lj-awb asset group-create --name "女主素材组" --dry-run',
|
|
338
|
-
],
|
|
339
538
|
artifact: [
|
|
340
539
|
'lj-awb artifact script import --project-id <projectId> --input-file 1_script/output/script.json --dry-run',
|
|
341
540
|
'lj-awb artifact asset import --project-id <projectId> --input-dir 2_asset/output --dry-run',
|
|
342
541
|
'lj-awb artifact video import-storyboard --project-id <projectId> --input-file 3_footage/output/ep001/ep001_storyboard.json --dry-run',
|
|
343
|
-
|
|
344
|
-
subject: [
|
|
345
|
-
'lj-awb subject list --name "女主"',
|
|
346
|
-
'lj-awb subject publish --name 女主 --primary-file ./three-view.png --dry-run',
|
|
542
|
+
'lj-awb artifact clip upsert-episode --project-id <projectId> --input-file 4_clip/output/ep001_clip_output.json --dry-run',
|
|
347
543
|
],
|
|
348
544
|
};
|
|
349
545
|
|
|
@@ -353,21 +549,22 @@ const COMMAND_REQUIRED_OPTIONS = {
|
|
|
353
549
|
'project ensure': ['name'],
|
|
354
550
|
'model options': ['modelGroupCode'],
|
|
355
551
|
'model create-spec': ['modelGroupCode'],
|
|
356
|
-
'image
|
|
357
|
-
'image
|
|
358
|
-
'image
|
|
359
|
-
'image
|
|
360
|
-
'video
|
|
361
|
-
'video
|
|
362
|
-
'video
|
|
363
|
-
'video
|
|
364
|
-
'video
|
|
552
|
+
'create image-fee': ['modelGroupCode', 'prompt'],
|
|
553
|
+
'create image': ['modelGroupCode', 'prompt'],
|
|
554
|
+
'create image-batch': ['inputFile', 'modelGroupCode'],
|
|
555
|
+
'task image-status': ['taskId'],
|
|
556
|
+
'create video-fee': ['modelGroupCode'],
|
|
557
|
+
'create video': ['modelGroupCode'],
|
|
558
|
+
'create video-batch': ['inputFile', 'modelGroupCode'],
|
|
559
|
+
'task video-status': ['taskId'],
|
|
560
|
+
'task video-subtitle-status': ['taskId'],
|
|
365
561
|
'task wait': ['taskId', 'taskType'],
|
|
366
|
-
'asset
|
|
367
|
-
'asset
|
|
368
|
-
'asset
|
|
369
|
-
'asset
|
|
370
|
-
'asset
|
|
562
|
+
'create asset-match-actor': ['description'],
|
|
563
|
+
'create asset-groups': ['platform'],
|
|
564
|
+
'create asset-group-get': ['groupId', 'platform'],
|
|
565
|
+
'create asset-group': ['name', 'platform'],
|
|
566
|
+
'create asset-group-update': ['groupId', 'platform'],
|
|
567
|
+
'create asset': ['groupId', 'name', 'platform'],
|
|
371
568
|
'artifact script row': ['rowKind', 'entityKey'],
|
|
372
569
|
'artifact script children': ['parentKey'],
|
|
373
570
|
'artifact script delete-row': ['rowKind', 'entityKey'],
|
|
@@ -390,24 +587,29 @@ const COMMAND_REQUIRED_OPTIONS = {
|
|
|
390
587
|
'artifact video clip': ['episodeId', 'sceneId', 'clipId'],
|
|
391
588
|
'artifact video upsert-scene': ['episodeId'],
|
|
392
589
|
'artifact video upsert-clip': ['episodeId', 'sceneId'],
|
|
393
|
-
'artifact video update-clip-
|
|
590
|
+
'artifact video update-clip-urls': ['episodeId', 'sceneId', 'clipId', 'videoUrlsJson'],
|
|
394
591
|
'artifact video delete-episode': ['episodeId'],
|
|
395
592
|
'artifact video delete-scene': ['episodeId', 'sceneId'],
|
|
396
593
|
'artifact video delete-clip': ['episodeId', 'sceneId', 'clipId'],
|
|
397
594
|
'artifact video import-storyboard': ['inputFile'],
|
|
398
|
-
'
|
|
399
|
-
'
|
|
400
|
-
'
|
|
595
|
+
'artifact clip episode': ['videoEpisodeId'],
|
|
596
|
+
'artifact clip episode-by-id': ['episodeId'],
|
|
597
|
+
'artifact clip update-status': ['videoEpisodeId', 'status'],
|
|
598
|
+
'artifact clip delete-episode': ['videoEpisodeId'],
|
|
599
|
+
'create subject': ['name'],
|
|
600
|
+
'create subject-wait': ['elementId'],
|
|
601
|
+
'create subject-voice': ['name'],
|
|
602
|
+
'create subject-batch': ['inputFile'],
|
|
401
603
|
};
|
|
402
604
|
|
|
403
605
|
const COMMAND_REQUIRED_ANY_OPTIONS = {
|
|
404
|
-
'auth login-key': [['accessKey', 'fromEnv']],
|
|
405
606
|
'project update': [['name', 'point']],
|
|
406
607
|
'upload files': [['file', 'files', 'filesJson']],
|
|
407
|
-
'video
|
|
408
|
-
'video
|
|
409
|
-
'
|
|
410
|
-
'asset
|
|
608
|
+
'create video-fee': [['prompt', 'resource', 'resourcesJson']],
|
|
609
|
+
'create video': [['prompt', 'resource', 'resourcesJson']],
|
|
610
|
+
'create video-subtitle-removal': [['sourceTaskId']],
|
|
611
|
+
'create asset-group-update': [['name', 'description', 'projectName']],
|
|
612
|
+
'create asset': [['file', 'url', 'backendPath']],
|
|
411
613
|
'artifact script upsert-row': [['bodyJson', 'inputFile']],
|
|
412
614
|
'artifact asset upsert-actor': [['bodyJson', 'inputFile']],
|
|
413
615
|
'artifact asset upsert-prop': [['bodyJson', 'inputFile']],
|
|
@@ -418,7 +620,12 @@ const COMMAND_REQUIRED_ANY_OPTIONS = {
|
|
|
418
620
|
'artifact video upsert-episode': [['bodyJson', 'inputFile']],
|
|
419
621
|
'artifact video upsert-scene': [['bodyJson', 'inputFile']],
|
|
420
622
|
'artifact video upsert-clip': [['bodyJson', 'inputFile']],
|
|
421
|
-
'
|
|
623
|
+
'artifact clip upsert-episode': [['bodyJson', 'inputFile']],
|
|
624
|
+
'artifact clip upsert-batch': [['bodyJson', 'inputFile']],
|
|
625
|
+
'create subject': [['resource'], ['modelCode']],
|
|
626
|
+
'create subject-batch': [['modelCode']],
|
|
627
|
+
'create subject-voice': [['file', 'voiceUrl', 'audioUrl', 'videoId']],
|
|
628
|
+
'create subject-voice-wait': [['voiceRecordId', 'reqTaskId']],
|
|
422
629
|
};
|
|
423
630
|
|
|
424
631
|
const ARTIFACT_WRITE_COMMANDS = [
|
|
@@ -441,11 +648,15 @@ const ARTIFACT_WRITE_COMMANDS = [
|
|
|
441
648
|
'artifact video upsert-episode',
|
|
442
649
|
'artifact video upsert-scene',
|
|
443
650
|
'artifact video upsert-clip',
|
|
444
|
-
'artifact video update-clip-
|
|
651
|
+
'artifact video update-clip-urls',
|
|
445
652
|
'artifact video delete-episode',
|
|
446
653
|
'artifact video delete-scene',
|
|
447
654
|
'artifact video delete-clip',
|
|
448
655
|
'artifact video import-storyboard',
|
|
656
|
+
'artifact clip upsert-episode',
|
|
657
|
+
'artifact clip upsert-batch',
|
|
658
|
+
'artifact clip update-status',
|
|
659
|
+
'artifact clip delete-episode',
|
|
449
660
|
];
|
|
450
661
|
|
|
451
662
|
const ARTIFACT_DELETE_COMMANDS = ARTIFACT_WRITE_COMMANDS.filter((name) => name.includes(' delete-'));
|
|
@@ -457,24 +668,26 @@ const CONFIRMATION_COMMANDS = new Set([
|
|
|
457
668
|
'project create',
|
|
458
669
|
'project update',
|
|
459
670
|
'project ensure',
|
|
460
|
-
'image
|
|
461
|
-
'image
|
|
462
|
-
'video
|
|
463
|
-
'video
|
|
464
|
-
'video
|
|
465
|
-
'asset
|
|
466
|
-
'asset
|
|
467
|
-
'asset
|
|
671
|
+
'create image',
|
|
672
|
+
'create image-batch',
|
|
673
|
+
'create video',
|
|
674
|
+
'create video-batch',
|
|
675
|
+
'create video-subtitle-removal',
|
|
676
|
+
'create asset-group',
|
|
677
|
+
'create asset-group-update',
|
|
678
|
+
'create asset',
|
|
468
679
|
...ARTIFACT_WRITE_COMMANDS,
|
|
469
|
-
'subject
|
|
470
|
-
'subject
|
|
680
|
+
'create subject',
|
|
681
|
+
'create subject-voice',
|
|
682
|
+
'create subject-batch',
|
|
471
683
|
]);
|
|
472
684
|
|
|
473
685
|
const COST_COMMANDS = new Set([
|
|
474
|
-
'image
|
|
475
|
-
'image
|
|
476
|
-
'video
|
|
477
|
-
'video
|
|
686
|
+
'create image',
|
|
687
|
+
'create image-batch',
|
|
688
|
+
'create video',
|
|
689
|
+
'create video-batch',
|
|
690
|
+
'create video-subtitle-removal',
|
|
478
691
|
]);
|
|
479
692
|
|
|
480
693
|
const REMOTE_WRITE_COMMANDS = new Set([
|
|
@@ -484,21 +697,22 @@ const REMOTE_WRITE_COMMANDS = new Set([
|
|
|
484
697
|
'project update',
|
|
485
698
|
'project ensure',
|
|
486
699
|
'upload files',
|
|
487
|
-
'image
|
|
488
|
-
'image
|
|
489
|
-
'video
|
|
490
|
-
'video
|
|
491
|
-
'video
|
|
492
|
-
'asset
|
|
493
|
-
'asset
|
|
494
|
-
'asset
|
|
700
|
+
'create image',
|
|
701
|
+
'create image-batch',
|
|
702
|
+
'create video',
|
|
703
|
+
'create video-batch',
|
|
704
|
+
'create video-subtitle-removal',
|
|
705
|
+
'create asset-group',
|
|
706
|
+
'create asset-group-update',
|
|
707
|
+
'create asset',
|
|
495
708
|
...ARTIFACT_WRITE_COMMANDS,
|
|
496
|
-
'subject
|
|
497
|
-
'subject
|
|
709
|
+
'create subject',
|
|
710
|
+
'create subject-voice',
|
|
711
|
+
'create subject-batch',
|
|
498
712
|
]);
|
|
499
713
|
|
|
500
714
|
const LOCAL_STATE_WRITE_COMMANDS = new Set([
|
|
501
|
-
'auth login
|
|
715
|
+
'auth login',
|
|
502
716
|
'auth clear',
|
|
503
717
|
'project use',
|
|
504
718
|
'project create',
|
|
@@ -506,16 +720,16 @@ const LOCAL_STATE_WRITE_COMMANDS = new Set([
|
|
|
506
720
|
]);
|
|
507
721
|
|
|
508
722
|
const DESTRUCTIVE_COMMANDS = new Set(['auth clear', ...ARTIFACT_DELETE_COMMANDS]);
|
|
509
|
-
const LONG_RUNNING_COMMANDS = new Set(['task wait', 'task record-poll', 'subject wait']);
|
|
723
|
+
const LONG_RUNNING_COMMANDS = new Set(['task wait', 'task record-poll', 'create subject-wait', 'create subject-voice-wait']);
|
|
510
724
|
const NETWORK_NONE_COMMANDS = new Set(['schema', 'auth status', 'auth clear', 'model input-guide', 'task records']);
|
|
511
|
-
const NETWORK_CONDITIONAL_COMMANDS = new Set(['doctor', 'auth login
|
|
725
|
+
const NETWORK_CONDITIONAL_COMMANDS = new Set(['doctor', 'auth login']);
|
|
512
726
|
|
|
513
727
|
const OUTPUT_KIND_BY_COMMAND = {
|
|
514
728
|
doctor: 'environment_report',
|
|
515
729
|
schema: 'command_schema',
|
|
516
730
|
'auth status': 'auth_status',
|
|
517
731
|
'auth verify': 'auth_status',
|
|
518
|
-
'auth login
|
|
732
|
+
'auth login': 'auth_result',
|
|
519
733
|
'account info': 'account_summary',
|
|
520
734
|
'account teams': 'team_list',
|
|
521
735
|
'project list': 'project_list',
|
|
@@ -525,47 +739,102 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
525
739
|
'credits usage': 'credits_usage',
|
|
526
740
|
'model image-models': 'model_list',
|
|
527
741
|
'model video-models': 'model_list',
|
|
742
|
+
'model asset-review-models': 'asset_review_model_list',
|
|
528
743
|
'model options': 'model_options',
|
|
529
744
|
'model create-spec': 'model_create_spec',
|
|
530
745
|
'model input-guide': 'model_input_guide',
|
|
531
746
|
'upload files': 'upload_result',
|
|
532
|
-
'image
|
|
533
|
-
'image
|
|
534
|
-
'image
|
|
535
|
-
'image
|
|
536
|
-
'video
|
|
537
|
-
'video
|
|
538
|
-
'video
|
|
539
|
-
'video
|
|
540
|
-
'video
|
|
541
|
-
'video
|
|
747
|
+
'create image-fee': 'fee_estimate',
|
|
748
|
+
'create image': 'task_submission',
|
|
749
|
+
'create image-batch': 'batch_task_submission',
|
|
750
|
+
'task image-status': 'task_status',
|
|
751
|
+
'create video-fee': 'fee_estimate',
|
|
752
|
+
'create video': 'task_submission',
|
|
753
|
+
'create video-batch': 'batch_task_submission',
|
|
754
|
+
'task video-status': 'task_status',
|
|
755
|
+
'create video-subtitle-removal': 'subtitle_task_submission',
|
|
756
|
+
'task video-subtitle-status': 'subtitle_task_status',
|
|
542
757
|
'task list': 'task_list',
|
|
543
758
|
'task wait': 'task_status',
|
|
544
759
|
'task records': 'local_task_records',
|
|
545
760
|
'task record-poll': 'batch_task_status',
|
|
546
|
-
'asset
|
|
547
|
-
'asset
|
|
548
|
-
'asset
|
|
549
|
-
'asset
|
|
550
|
-
'asset
|
|
551
|
-
'asset
|
|
552
|
-
'subject
|
|
553
|
-
'subject
|
|
554
|
-
'subject
|
|
555
|
-
'subject
|
|
761
|
+
'create asset-match-actor': 'asset_match_list',
|
|
762
|
+
'create asset-groups': 'asset_group_list',
|
|
763
|
+
'create asset-group-get': 'asset_group_detail',
|
|
764
|
+
'create asset-group': 'asset_group_write_result',
|
|
765
|
+
'create asset-group-update': 'asset_group_write_result',
|
|
766
|
+
'create asset': 'asset_register_result',
|
|
767
|
+
'create subject-list': 'subject_list',
|
|
768
|
+
'create subject': 'subject_publish_result',
|
|
769
|
+
'create subject-wait': 'subject_status',
|
|
770
|
+
'create subject-voice-list': 'subject_voice_list',
|
|
771
|
+
'create subject-voice': 'subject_voice_create_result',
|
|
772
|
+
'create subject-voice-wait': 'subject_voice_status',
|
|
773
|
+
'create subject-batch': 'batch_subject_publish_result',
|
|
774
|
+
'artifact script get': 'artifact_full',
|
|
775
|
+
'artifact script document': 'artifact_record',
|
|
776
|
+
'artifact script rows': 'artifact_list',
|
|
777
|
+
'artifact script row': 'artifact_record',
|
|
778
|
+
'artifact script children': 'artifact_list',
|
|
779
|
+
'artifact script upsert-row': 'artifact_write_result',
|
|
780
|
+
'artifact script delete-row': 'artifact_delete_result',
|
|
781
|
+
'artifact script import': 'artifact_import_result',
|
|
782
|
+
'artifact asset get': 'artifact_full',
|
|
783
|
+
'artifact asset actors': 'artifact_list',
|
|
784
|
+
'artifact asset actor': 'artifact_record',
|
|
785
|
+
'artifact asset props': 'artifact_list',
|
|
786
|
+
'artifact asset prop': 'artifact_record',
|
|
787
|
+
'artifact asset locations': 'artifact_list',
|
|
788
|
+
'artifact asset location': 'artifact_record',
|
|
789
|
+
'artifact asset upsert-actor': 'artifact_write_result',
|
|
790
|
+
'artifact asset upsert-prop': 'artifact_write_result',
|
|
791
|
+
'artifact asset upsert-location': 'artifact_write_result',
|
|
792
|
+
'artifact asset upsert-actor-state': 'artifact_write_result',
|
|
793
|
+
'artifact asset upsert-prop-state': 'artifact_write_result',
|
|
794
|
+
'artifact asset upsert-location-state': 'artifact_write_result',
|
|
795
|
+
'artifact asset delete-actor': 'artifact_delete_result',
|
|
796
|
+
'artifact asset delete-prop': 'artifact_delete_result',
|
|
797
|
+
'artifact asset delete-location': 'artifact_delete_result',
|
|
798
|
+
'artifact asset delete-actor-state': 'artifact_delete_result',
|
|
799
|
+
'artifact asset delete-prop-state': 'artifact_delete_result',
|
|
800
|
+
'artifact asset delete-location-state': 'artifact_delete_result',
|
|
801
|
+
'artifact asset import': 'artifact_import_result',
|
|
802
|
+
'artifact video get': 'artifact_full',
|
|
803
|
+
'artifact video episodes': 'artifact_list',
|
|
804
|
+
'artifact video episode': 'artifact_record',
|
|
805
|
+
'artifact video scenes': 'artifact_list',
|
|
806
|
+
'artifact video scene': 'artifact_record',
|
|
807
|
+
'artifact video clips': 'artifact_list',
|
|
808
|
+
'artifact video clip': 'artifact_record',
|
|
809
|
+
'artifact video upsert-episode': 'artifact_write_result',
|
|
810
|
+
'artifact video upsert-scene': 'artifact_write_result',
|
|
811
|
+
'artifact video upsert-clip': 'artifact_write_result',
|
|
812
|
+
'artifact video update-clip-urls': 'artifact_write_result',
|
|
813
|
+
'artifact video delete-episode': 'artifact_delete_result',
|
|
814
|
+
'artifact video delete-scene': 'artifact_delete_result',
|
|
815
|
+
'artifact video delete-clip': 'artifact_delete_result',
|
|
816
|
+
'artifact video import-storyboard': 'artifact_import_result',
|
|
817
|
+
'artifact clip get': 'artifact_full',
|
|
818
|
+
'artifact clip episodes': 'artifact_list',
|
|
819
|
+
'artifact clip episode': 'artifact_record',
|
|
820
|
+
'artifact clip episode-by-id': 'artifact_record',
|
|
821
|
+
'artifact clip upsert-episode': 'artifact_write_result',
|
|
822
|
+
'artifact clip upsert-batch': 'artifact_import_result',
|
|
823
|
+
'artifact clip update-status': 'artifact_status_update',
|
|
824
|
+
'artifact clip delete-episode': 'artifact_delete_result',
|
|
556
825
|
};
|
|
557
826
|
|
|
558
827
|
const PREFLIGHTS_BY_COMMAND = {
|
|
559
|
-
'image
|
|
560
|
-
'image
|
|
561
|
-
'video
|
|
562
|
-
'video
|
|
563
|
-
'subject
|
|
564
|
-
'subject
|
|
565
|
-
'video
|
|
566
|
-
'asset
|
|
567
|
-
'asset
|
|
568
|
-
'asset
|
|
828
|
+
'create image': ['doctor --verify', 'model image-models', 'model options', 'model create-spec', 'confirm missing key params', 'create image-fee', 'create image --dry-run'],
|
|
829
|
+
'create image-batch': ['doctor --verify', 'model image-models', 'model options', 'model create-spec', 'prepare JSONL input', 'create image-batch --dry-run'],
|
|
830
|
+
'create video': ['doctor --verify', 'model video-models', 'model options', 'model create-spec', 'confirm missing key params', 'create video-fee', 'create video --dry-run'],
|
|
831
|
+
'create video-batch': ['doctor --verify', 'model video-models', 'model options', 'model create-spec', 'prepare JSONL input', 'create video-batch --dry-run'],
|
|
832
|
+
'create subject': ['doctor --verify', 'create subject --model-code tx|vidu --dry-run'],
|
|
833
|
+
'create subject-batch': ['doctor --verify', 'prepare JSONL input with modelCode', 'create subject-batch --dry-run'],
|
|
834
|
+
'create video-subtitle-removal': ['doctor --verify', 'create video-subtitle-removal --source-task-id <videoTaskId> --dry-run'],
|
|
835
|
+
'create asset-group': ['model asset-review-models', 'create asset-group --platform <platform> --dry-run'],
|
|
836
|
+
'create asset-group-update': ['create asset-group-update --platform <platform> --dry-run'],
|
|
837
|
+
'create asset': ['model asset-review-models', 'create asset --platform <platform> --dry-run'],
|
|
569
838
|
'upload files': ['upload files --dry-run'],
|
|
570
839
|
};
|
|
571
840
|
|
|
@@ -606,6 +875,8 @@ function commandNetworkMode(commandName) {
|
|
|
606
875
|
function unknownCommandHint(commandName) {
|
|
607
876
|
const replacement = RENAMED_COMMAND_HINTS[commandName];
|
|
608
877
|
if (replacement) return `该命令已产品化命名为 ${commandPrefix()} ${replacement}。运行 ${commandPrefix()} ${replacement.split(' ')[0]} -h 查看同组命令。`;
|
|
878
|
+
const guess = COMMAND_GUESS_HINTS[commandName];
|
|
879
|
+
if (guess) return guess;
|
|
609
880
|
const group = String(commandName || '').split(' ').filter(Boolean)[0];
|
|
610
881
|
if (group === 'workspace') return `账号用 ${commandPrefix()} account ...,项目组用 ${commandPrefix()} project ...。运行 ${commandPrefix()} --help 查看可用命令。`;
|
|
611
882
|
if (group === 'billing') return `积分查询用 ${commandPrefix()} credits ...。运行 ${commandPrefix()} credits -h 查看可用命令。`;
|
|
@@ -636,15 +907,44 @@ function buildCommandSafety(command, optionKeys) {
|
|
|
636
907
|
}
|
|
637
908
|
|
|
638
909
|
function buildCommandWorkflow(command) {
|
|
639
|
-
const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] ||
|
|
910
|
+
const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] || 'generic';
|
|
640
911
|
const next = [];
|
|
641
|
-
if (
|
|
642
|
-
next.push('读取 data.taskId 和 data.nextCommand', '
|
|
912
|
+
if (command.name === 'create image') {
|
|
913
|
+
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-type IMAGE_CREATE 等待结果');
|
|
914
|
+
}
|
|
915
|
+
if (command.name === 'create video') {
|
|
916
|
+
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-type VIDEO_GROUP 等待结果');
|
|
917
|
+
}
|
|
918
|
+
if (command.name === 'create video-subtitle-removal') {
|
|
919
|
+
next.push('读取 data.taskId 和 data.nextCommand', '运行 task video-subtitle-status 或响应里的 nextCommand 等待结果');
|
|
643
920
|
}
|
|
644
|
-
if (command.name === 'subject
|
|
645
|
-
next.push('读取 data.elementId', '
|
|
921
|
+
if (command.name === 'create subject') {
|
|
922
|
+
next.push('读取 data.elementId / data.externalId', 'externalId 为空时立刻运行 create subject-wait 获取 nextRefSubject');
|
|
646
923
|
}
|
|
647
|
-
if (
|
|
924
|
+
if (command.name === 'create subject-voice') {
|
|
925
|
+
next.push('读取 data.voiceRecordId / data.externalId', 'externalId 为空时立刻运行 create subject-voice-wait 获取 nextVoiceArg');
|
|
926
|
+
}
|
|
927
|
+
if (command.name === 'create asset') {
|
|
928
|
+
next.push('读取 data.assetPath', '若后端返回审核 taskId,再运行 task wait --task-type ASSET_REGISTER');
|
|
929
|
+
}
|
|
930
|
+
if (command.name === 'model image-models' || command.name === 'model video-models') {
|
|
931
|
+
next.push('读取 data.models[] 得到全部候选;用户给了模型口语名时保留同族全部候选,不只取第一个');
|
|
932
|
+
next.push('对每个候选运行 model options --model-group-code <modelGroupCode> 查看真实参数和素材约束');
|
|
933
|
+
next.push('向用户展示候选模型 + 参数取值 + 资源能力后 STOP;等待用户选择或明确授权默认,未确认不得进入 create-spec/fee/dry-run/create');
|
|
934
|
+
}
|
|
935
|
+
if (command.name === 'model asset-review-models') {
|
|
936
|
+
next.push('读取 data.models[].platform', '用 create asset-groups --platform <platform> 查重或创建素材组');
|
|
937
|
+
}
|
|
938
|
+
if (command.name === 'model options') {
|
|
939
|
+
next.push('读取 params/resources/constraints 确认参数与素材约束', '运行 model create-spec --model-group-code <code> 查看创建写法和示例');
|
|
940
|
+
}
|
|
941
|
+
if (command.name === 'model create-spec') {
|
|
942
|
+
next.push('按 examples / supportedIntents 组装命令', '用户确认关键参数后先运行 create image-fee 或 create video-fee,再 dry-run');
|
|
943
|
+
}
|
|
944
|
+
if (command.name === 'model input-guide') {
|
|
945
|
+
next.push('运行 model image-models 或 model video-models 选择模型', '选定模型后运行 model options --model-group-code <code>');
|
|
946
|
+
}
|
|
947
|
+
if (['create image-batch', 'create video-batch', 'create subject-batch'].includes(command.name)) {
|
|
648
948
|
next.push('读取每项 status / taskId / error', '使用 task record-poll 或对应 wait 命令恢复批量结果');
|
|
649
949
|
}
|
|
650
950
|
return {
|
|
@@ -654,17 +954,209 @@ function buildCommandWorkflow(command) {
|
|
|
654
954
|
};
|
|
655
955
|
}
|
|
656
956
|
|
|
957
|
+
function buildDomainSummaries(commands) {
|
|
958
|
+
const domains = new Map();
|
|
959
|
+
for (const command of commands) {
|
|
960
|
+
const group = commandGroup(command);
|
|
961
|
+
domains.set(group, {
|
|
962
|
+
name: group,
|
|
963
|
+
description: GROUP_DESCRIPTIONS[group] || '',
|
|
964
|
+
commandCount: (domains.get(group)?.commandCount || 0) + 1,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
return Array.from(domains.values()).sort((a, b) => a.name.localeCompare(b.name));
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function requiredOptionsForCommand(command) {
|
|
971
|
+
const requiredOptions = new Set();
|
|
972
|
+
if (commandGroup(command) === 'artifact') requiredOptions.add('projectId');
|
|
973
|
+
for (const key of COMMAND_REQUIRED_OPTIONS[command.name] || []) requiredOptions.add(key);
|
|
974
|
+
return [...requiredOptions];
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function requiredAnyOptionsForCommand(command) {
|
|
978
|
+
return COMMAND_REQUIRED_ANY_OPTIONS[command.name] || [];
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function buildCommandSchemaEntry(command) {
|
|
982
|
+
const requiredOptions = requiredOptionsForCommand(command);
|
|
983
|
+
const requiredAnyOptions = requiredAnyOptionsForCommand(command);
|
|
984
|
+
const optionKeys = new Set((command.args || []).map((arg) => normalizeKey(arg.name)));
|
|
985
|
+
return {
|
|
986
|
+
name: command.name,
|
|
987
|
+
domain: commandGroup(command),
|
|
988
|
+
command: commandSubcommand(command),
|
|
989
|
+
invocation: `${commandPrefix()} ${command.name}`,
|
|
990
|
+
helpCommand: `${commandPrefix()} ${command.name} -h`,
|
|
991
|
+
summary: summaryOf(command),
|
|
992
|
+
description: renderCliText(summaryOf(command)),
|
|
993
|
+
examples: extractExamples(command).map(renderCliText),
|
|
994
|
+
jsonExamples: extractExamples(command).map(asJsonExample),
|
|
995
|
+
requiredOptions,
|
|
996
|
+
requiredAnyOptions,
|
|
997
|
+
safety: buildCommandSafety(command, optionKeys),
|
|
998
|
+
workflow: buildCommandWorkflow(command),
|
|
999
|
+
options: (command.args || []).map((arg) => {
|
|
1000
|
+
const key = normalizeKey(arg.name);
|
|
1001
|
+
return {
|
|
1002
|
+
name: arg.name,
|
|
1003
|
+
key,
|
|
1004
|
+
flag: formatOptionName(arg.name),
|
|
1005
|
+
valueName: arg.valueName || null,
|
|
1006
|
+
required: requiredOptions.includes(key),
|
|
1007
|
+
requiredAnyGroup: requiredAnyOptions.find((group) => group.includes(key)) || null,
|
|
1008
|
+
description: arg.description || '',
|
|
1009
|
+
};
|
|
1010
|
+
}),
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function namesWhere(entries, predicate) {
|
|
1015
|
+
return entries.filter(predicate).map((entry) => entry.name);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function buildAgentBrief(commands, version = 'unknown') {
|
|
1019
|
+
const contract = buildAgentContract();
|
|
1020
|
+
const entries = commands.map(buildCommandSchemaEntry);
|
|
1021
|
+
const domains = buildDomainSummaries(commands).map((domain) => ({
|
|
1022
|
+
...domain,
|
|
1023
|
+
commands: entries
|
|
1024
|
+
.filter((entry) => entry.domain === domain.name)
|
|
1025
|
+
.map((entry) => entry.name),
|
|
1026
|
+
}));
|
|
1027
|
+
return {
|
|
1028
|
+
schemaVersion: 1,
|
|
1029
|
+
kind: 'agent_brief',
|
|
1030
|
+
cli: {
|
|
1031
|
+
name: 'lj-awb',
|
|
1032
|
+
version,
|
|
1033
|
+
commandPrefix: commandPrefix(),
|
|
1034
|
+
},
|
|
1035
|
+
commandCount: entries.length,
|
|
1036
|
+
domains,
|
|
1037
|
+
outputPolicy: {
|
|
1038
|
+
agentRecommendedOutputFormat: contract.agentRecommendedOutputFormat,
|
|
1039
|
+
scriptRecommendedOutputFormat: contract.scriptRecommendedOutputFormat,
|
|
1040
|
+
textFlag: contract.textFlag,
|
|
1041
|
+
jsonFlag: contract.jsonFlag,
|
|
1042
|
+
policy: contract.outputPolicy,
|
|
1043
|
+
},
|
|
1044
|
+
statePolicy: contract.statePolicy,
|
|
1045
|
+
workflowPolicy: contract.workflowPolicy,
|
|
1046
|
+
safetyPolicy: {
|
|
1047
|
+
confirmationPolicy: contract.confirmationPolicy,
|
|
1048
|
+
dryRunPolicy: contract.dryRunPolicy,
|
|
1049
|
+
remoteWriteCount: namesWhere(entries, (entry) => entry.safety.remoteWrite).length,
|
|
1050
|
+
costsPointsCount: namesWhere(entries, (entry) => entry.safety.costsPoints).length,
|
|
1051
|
+
localStateWriteCount: namesWhere(entries, (entry) => entry.safety.localStateWrite).length,
|
|
1052
|
+
destructiveCount: namesWhere(entries, (entry) => entry.safety.destructive).length,
|
|
1053
|
+
longRunningCount: namesWhere(entries, (entry) => entry.safety.longRunning).length,
|
|
1054
|
+
},
|
|
1055
|
+
commandClasses: {
|
|
1056
|
+
costsPoints: namesWhere(entries, (entry) => entry.safety.costsPoints),
|
|
1057
|
+
remoteWrite: namesWhere(entries, (entry) => entry.safety.remoteWrite),
|
|
1058
|
+
localStateWrite: namesWhere(entries, (entry) => entry.safety.localStateWrite),
|
|
1059
|
+
destructive: namesWhere(entries, (entry) => entry.safety.destructive),
|
|
1060
|
+
longRunning: namesWhere(entries, (entry) => entry.safety.longRunning),
|
|
1061
|
+
safeRead: namesWhere(entries, (entry) => entry.safety.safeToAutoRun && entry.safety.network !== 'none'),
|
|
1062
|
+
offlineRead: namesWhere(entries, (entry) => entry.safety.safeToAutoRun && entry.safety.network === 'none'),
|
|
1063
|
+
},
|
|
1064
|
+
routing: [
|
|
1065
|
+
{
|
|
1066
|
+
intent: '环境、认证、账号、团队、项目组、积分',
|
|
1067
|
+
start: ['doctor --verify', 'account info', 'project current', 'credits balance'],
|
|
1068
|
+
rule: '只读查询可自动运行;切换团队、切换/创建/更新项目组和清空认证按 safety dry-run/confirm 处理。',
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
intent: '模型发现和创作任务',
|
|
1072
|
+
start: ['model image-models', 'model video-models', 'model options', 'model create-spec'],
|
|
1073
|
+
rule: '先展示候选模型、真实参数和资源能力并 STOP;用户选择或明确授权默认后,关键参数确认,再只跑一次 fee、dry-run 和最终 --yes。',
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
intent: '上传、主体、音色、素材加白',
|
|
1077
|
+
start: ['upload files', 'create subject-list', 'create subject-voice-list', 'model asset-review-models'],
|
|
1078
|
+
rule: '复用已上传 backendPath、已有主体/音色/素材组;素材加白平台来自 model asset-review-models 或用户明确选择。',
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
intent: '异步任务和批量恢复',
|
|
1082
|
+
start: ['task wait', 'task record-poll', 'task records'],
|
|
1083
|
+
rule: '优先复用 create 返回的 nextCommand;批量任务使用 task-record-file,失败项单独重试。',
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
intent: '最终产物 artifact',
|
|
1087
|
+
start: ['artifact script', 'artifact asset', 'artifact video', 'artifact clip'],
|
|
1088
|
+
rule: 'artifact 使用 project-id,不是 project-group-no;写入/删除/导入先 dry-run,再一次性确认写入面。',
|
|
1089
|
+
},
|
|
1090
|
+
],
|
|
1091
|
+
lookup: {
|
|
1092
|
+
preciseSchema: `${commandPrefix()} schema --domain <domain> --command <command> -f json`,
|
|
1093
|
+
fullSchema: `${commandPrefix()} schema -f json`,
|
|
1094
|
+
commandHelp: `${commandPrefix()} <domain> <command> -h`,
|
|
1095
|
+
modelInputGuide: contract.modelInputGuide.textCommand,
|
|
1096
|
+
schemaPolicy: contract.schemaPolicy,
|
|
1097
|
+
},
|
|
1098
|
+
canonicalFields: contract.canonicalFields,
|
|
1099
|
+
resourceShortcut: contract.resourceShortcut,
|
|
1100
|
+
resourcesJson: contract.resourcesJson,
|
|
1101
|
+
modelCandidatePresentation: contract.modelCandidatePresentation,
|
|
1102
|
+
taskTypes: contract.taskTypes,
|
|
1103
|
+
exitCodes: contract.exitCodes,
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
|
|
657
1107
|
function buildAgentContract() {
|
|
658
1108
|
return {
|
|
659
|
-
defaultOutputFormat: '
|
|
1109
|
+
defaultOutputFormat: 'pretty',
|
|
1110
|
+
humanDefaultOutputFormat: 'pretty',
|
|
1111
|
+
agentRecommendedOutputFormat: 'text',
|
|
1112
|
+
agentCompactOutputFormat: 'text',
|
|
1113
|
+
scriptRecommendedOutputFormat: 'json',
|
|
660
1114
|
jsonFlag: '-f json',
|
|
661
|
-
|
|
662
|
-
|
|
1115
|
+
textFlag: '-f text',
|
|
1116
|
+
outputFormats: ['pretty', 'text', 'json', 'yaml', 'csv', 'auto'],
|
|
1117
|
+
outputPolicy: '默认输出 pretty 人类友好视图,包含标题、摘要表格、列表表格和下一步建议;Agent 推荐显式传 -f text 读取稳定的分区 key=value 输出;脚本严格解析或需要完整嵌套结构时再传 -f json 或 --json。JSON envelope 字段已做归一化,见 canonicalFields。',
|
|
1118
|
+
statePolicy: {
|
|
1119
|
+
purpose: 'Agent 应在同一轮 / 同一项目中维护 AWB 上下文账本,减少重复查询和重复提交。',
|
|
1120
|
+
cacheKeys: [
|
|
1121
|
+
'schema version / domains / commands',
|
|
1122
|
+
'auth / account / team / current projectGroup',
|
|
1123
|
+
'modelCandidates by taskKind + keyword',
|
|
1124
|
+
'assetReviewModels by modelGroupCode / platform',
|
|
1125
|
+
'modelOptions / modelCreateSpec by modelGroupCode',
|
|
1126
|
+
'uploaded backendPath by local file path or remote URL',
|
|
1127
|
+
'taskId -> taskType / projectGroupNo / resultUrls / errorMessage',
|
|
1128
|
+
'subject name + modelCode -> elementId / externalId / nextRefSubject',
|
|
1129
|
+
'subject voice name + source -> voiceRecordId / externalId / nextVoiceArg',
|
|
1130
|
+
'artifact projectId and imported file paths',
|
|
1131
|
+
],
|
|
1132
|
+
invalidation: '用户切换账号、团队、项目组、模型、素材、prompt 或关键参数后,只刷新受影响的缓存;不要重复跑未变化的 model options / create-spec / fee。',
|
|
1133
|
+
},
|
|
1134
|
+
workflowPolicy: [
|
|
1135
|
+
'模型口语名命中后必须先展示候选模型、真实参数取值和资源能力,并在清单后 STOP 等用户选择或明确授权默认;没有完成用户可见候选清单和确认前,不得代选默认模型 / 参数,也不得进入 create-spec、fee、dry-run 或 create。',
|
|
1136
|
+
'模型探索阶段只读 model list / options / create-spec;fee 只在用户确认关键参数后跑一次。',
|
|
1137
|
+
'supportsDryRun=true 的写入 / 扣费命令先 dry-run,确认后 yes;不要把 dry-run 当参数探索工具反复跑。',
|
|
1138
|
+
'用户给出多条同模型同参数任务时优先 batch + task-record-file,不要单条循环 create。',
|
|
1139
|
+
'命令返回 nextCommand / nextRefSubject / nextVoiceArg 时优先复用返回值,不手拼等价命令。',
|
|
1140
|
+
'素材加白平台先通过 model asset-review-models 或用户明确输入确定;create asset-* 必须显式传 --platform,不要依赖默认平台。',
|
|
1141
|
+
'旧根域 image / video / asset / subject 已移除;只使用 create / task / artifact 等 schema 暴露的 domain。',
|
|
1142
|
+
],
|
|
1143
|
+
canonicalFields: {
|
|
1144
|
+
purpose: 'CLI 输出对上游平台多版本字段做了归一化。Agent 只识别 canonical 列,遇到 aliases 列出的旧字段名时说明是上游原始返回,CLI 已在 text / 归一化层做了 fallback。不要把旧名当成独立新字段对外报告。',
|
|
1145
|
+
fields: [
|
|
1146
|
+
{ canonical: 'billingPointBalance', aliases: ['teamPointBalance'], meaning: '实际可扣积分余额(/api/anime/member/benefits/queryGroupPoint)' },
|
|
1147
|
+
{ canonical: 'billingPointRemainingAfter', aliases: ['teamPointRemainingAfter'], meaning: '本次任务后预计可扣积分余额' },
|
|
1148
|
+
{ canonical: 'projectBudgetBalance', aliases: ['projectPointBalance'], meaning: '项目组预算 / ROI 余额(不是积分)' },
|
|
1149
|
+
{ canonical: 'projectBudgetMax', aliases: ['projectPointMax'], meaning: '项目组预算上限' },
|
|
1150
|
+
{ canonical: 'projectBudgetRemainingAfter', aliases: ['projectPointRemainingAfter'], meaning: '本次任务后预计项目组预算余额' },
|
|
1151
|
+
{ canonical: 'pointCost', aliases: ['points', 'point', 'costPoint', 'estimatePoint'], meaning: '本次任务预计 / 实际消耗积分' },
|
|
1152
|
+
],
|
|
1153
|
+
},
|
|
1154
|
+
schemaPolicy: 'Agent 先读 schema --brief 建立能力地图;执行具体命令前再读精确 schema --domain <domain> --command <command>。完整 schema -f json 只用于覆盖校验、脚本生成或调试 schema 本身;查看长帮助用 schema.commands[].helpCommand 或 lj-awb <domain> <command> -h。',
|
|
663
1155
|
confirmationPolicy: 'schema.commands[].safety.requiresConfirmation=true 的命令,Agent 必须先向用户确认,再追加 --yes。',
|
|
664
1156
|
dryRunPolicy: 'schema.commands[].safety.supportsDryRun=true 的写入 / 扣费命令,正式执行前优先跑 --dry-run。',
|
|
665
1157
|
resourceShortcut: {
|
|
666
1158
|
flag: '--resource',
|
|
667
|
-
syntax: 'type:usage[:reference_key]=path|url|asset:<id>; image
|
|
1159
|
+
syntax: 'type:usage[:reference_key]=path|url|asset:<id>; create image uses image:reference=... without key',
|
|
668
1160
|
examples: [
|
|
669
1161
|
'image:reference=./ref.png',
|
|
670
1162
|
'image:first_frame=./hero.png',
|
|
@@ -678,34 +1170,48 @@ function buildAgentContract() {
|
|
|
678
1170
|
{
|
|
679
1171
|
type: 'image|video|audio|subject',
|
|
680
1172
|
usage: 'reference|first_frame|last_frame|keyframe',
|
|
681
|
-
reference_key: 'video reference placeholder key; not used by
|
|
1173
|
+
reference_key: 'video reference placeholder key; not used by create image image:reference',
|
|
682
1174
|
source: { kind: 'url|asset_id', value: '<local-file-or-http-url-or-material-backendPath-or-asset-id>' },
|
|
683
1175
|
},
|
|
684
1176
|
],
|
|
685
1177
|
},
|
|
1178
|
+
modelCandidatePresentation: {
|
|
1179
|
+
purpose: '把 model image-models / video-models 与每个候选的 model options 转成用户可见清单,避免 Agent 内部看完 options 后直接代选。',
|
|
1180
|
+
trigger: '用户问有哪些模型、给出口语名、或模型列表返回候选时都触发;即使只有一个候选也要展示真实可选项。',
|
|
1181
|
+
gateType: 'hard_stop',
|
|
1182
|
+
stopAfterPresentation: true,
|
|
1183
|
+
resumeCondition: '用户选择模型和关键参数,或明确说“按默认 / 你来选”。',
|
|
1184
|
+
requiredVisibleFields: ['displayName', 'modelDesc', 'taskQueueNum', 'quality values/default', 'ratio values/default', 'duration or generateNum values/default', 'resource modes/media/usages', 'channel or fast/pro differences'],
|
|
1185
|
+
blockedBeforePresentation: ['model create-spec', 'create image-fee', 'create video-fee', 'create image-batch --dry-run', 'create video-batch --dry-run', 'create image --dry-run', 'create video --dry-run', 'create image', 'create video', 'default model recommendation', 'default quality/ratio/duration choice'],
|
|
1186
|
+
},
|
|
686
1187
|
modelOptions: {
|
|
687
1188
|
command: `${commandPrefix()} model options --model-group-code <code>`,
|
|
1189
|
+
textCommand: `${commandPrefix()} model options --model-group-code <code> -f text`,
|
|
688
1190
|
jsonCommand: `${commandPrefix()} model options --model-group-code <code> -f json`,
|
|
689
|
-
purpose: '查询指定模型支持的 CLI 参数、枚举值、默认值、素材约束和条件约束。',
|
|
690
|
-
useBefore: ['model create-spec', 'image
|
|
1191
|
+
purpose: '查询指定模型支持的 CLI 参数、枚举值、默认值、素材约束和条件约束。Agent 默认读 textCommand;只有程序化校验完整嵌套结构时读 jsonCommand。',
|
|
1192
|
+
useBefore: ['model create-spec', 'create image-fee', 'create image', 'create video-fee', 'create video'],
|
|
691
1193
|
keyFields: ['params[].values', 'params[].defaultValue', 'resources[].mediaType', 'resources[].usage', 'resources[].fileTypes', 'resources[].maxFiles', 'resources[].supportLastFrameOnly', 'resources[].minDurationMs', 'resources[].maxDurationMs', 'constraints[].target', 'constraints[].conditions', 'constraints[].effect'],
|
|
692
1194
|
},
|
|
693
1195
|
modelCreateSpec: {
|
|
694
1196
|
command: `${commandPrefix()} model create-spec --model-group-code <code>`,
|
|
1197
|
+
textCommand: `${commandPrefix()} model create-spec --model-group-code <code> -f text`,
|
|
695
1198
|
jsonCommand: `${commandPrefix()} model create-spec --model-group-code <code> -f json`,
|
|
696
|
-
purpose: '查看指定模型如何组织 create 命令:输入模式、素材绑定规则、示例和创建前检查项。',
|
|
697
|
-
useBefore: ['image
|
|
1199
|
+
purpose: '查看指定模型如何组织 create 命令:输入模式、素材绑定规则、示例和创建前检查项。Agent 默认读 textCommand;只有程序化校验完整嵌套结构时读 jsonCommand。',
|
|
1200
|
+
useBefore: ['create image-fee', 'create image', 'create video-fee', 'create video'],
|
|
698
1201
|
keyFields: ['inputRequirement', 'supportedIntents', 'validationRules', 'agentGuidance', 'preflight', 'examples'],
|
|
699
1202
|
},
|
|
700
1203
|
modelInputGuide: {
|
|
701
1204
|
command: `${commandPrefix()} model input-guide`,
|
|
1205
|
+
textCommand: `${commandPrefix()} model input-guide -f text`,
|
|
702
1206
|
jsonCommand: `${commandPrefix()} model input-guide -f json`,
|
|
703
|
-
purpose: '查看跨模型统一创建参数、resources 字段和素材绑定规则。',
|
|
1207
|
+
purpose: '查看跨模型统一创建参数、resources 字段和素材绑定规则。Agent 默认读 textCommand;脚本严格解析时读 jsonCommand。',
|
|
704
1208
|
useBefore: ['model options', 'model create-spec'],
|
|
705
1209
|
},
|
|
706
1210
|
taskTypes: {
|
|
707
1211
|
image: 'IMAGE_CREATE',
|
|
708
1212
|
video: 'VIDEO_GROUP',
|
|
1213
|
+
subtitleRemoval: 'VIDEO_SUBTITLE_REMOVAL',
|
|
1214
|
+
assetRegister: 'ASSET_REGISTER',
|
|
709
1215
|
},
|
|
710
1216
|
exitCodes: [
|
|
711
1217
|
{ code: 0, type: 'success', meaning: '命令成功' },
|
|
@@ -713,24 +1219,21 @@ function buildAgentContract() {
|
|
|
713
1219
|
{ code: 2, type: 'argument_error|unknown_command|unknown_option', meaning: '参数或命令错误' },
|
|
714
1220
|
{ code: 3, type: 'auth_required|auth_failed', meaning: '缺少认证或认证失败' },
|
|
715
1221
|
{ code: 10, type: 'confirmation_required', meaning: '需要用户确认后追加 --yes' },
|
|
716
|
-
{ code:
|
|
1222
|
+
{ code: 1, type: 'subject_failed', meaning: '主体创建任务已失败(error.type=subject_failed)。查看 error.details.errorMessage 后调整参考资源或模型重新创建。' },
|
|
1223
|
+
{ code: 1, type: 'subject_voice_failed', meaning: '主体音色创建任务已失败(error.type=subject_voice_failed)。查看 error.details.errorMessage 后调整音频或视频来源重新创建。' },
|
|
1224
|
+
{ code: 20, type: 'task_still_running', meaning: '生图 / 生视频任务仍在运行,本轮等待窗口结束(error.type=task_still_running)。可继续 task wait 或 record-poll 续等。' },
|
|
1225
|
+
{ code: 20, type: 'subject_still_pending', meaning: '主体 externalId 尚未回填,本轮等待窗口结束(error.type=subject_still_pending)。可继续 create subject-wait 续等。' },
|
|
1226
|
+
{ code: 20, type: 'subject_voice_still_pending', meaning: '主体音色 externalId 尚未回填,本轮等待窗口结束(error.type=subject_voice_still_pending)。可继续 create subject-voice-wait 续等。' },
|
|
717
1227
|
{ code: 30, type: 'network_error', meaning: '网络、TLS、HTTP 或外部平台不可用' },
|
|
718
1228
|
],
|
|
719
1229
|
};
|
|
720
1230
|
}
|
|
721
1231
|
|
|
722
1232
|
function buildCommandSchema(commands, kwargs = {}, version = 'unknown') {
|
|
1233
|
+
if (toBool(kwargs.brief)) return buildAgentBrief(commands, version);
|
|
723
1234
|
const domainFilter = String(kwargs.domain ?? '').trim();
|
|
724
1235
|
const commandFilter = String(kwargs.command ?? '').trim();
|
|
725
|
-
const domains =
|
|
726
|
-
for (const command of commands) {
|
|
727
|
-
const group = commandGroup(command);
|
|
728
|
-
domains.set(group, {
|
|
729
|
-
name: group,
|
|
730
|
-
description: GROUP_DESCRIPTIONS[group] || '',
|
|
731
|
-
commandCount: (domains.get(group)?.commandCount || 0) + 1,
|
|
732
|
-
});
|
|
733
|
-
}
|
|
1236
|
+
const domains = buildDomainSummaries(commands);
|
|
734
1237
|
const filteredCommands = commands
|
|
735
1238
|
.filter((command) => !domainFilter || commandGroup(command) === domainFilter)
|
|
736
1239
|
.filter((command) => !commandFilter || command.name === commandFilter || commandSubcommand(command) === commandFilter);
|
|
@@ -754,48 +1257,16 @@ function buildCommandSchema(commands, kwargs = {}, version = 'unknown') {
|
|
|
754
1257
|
`${commandPrefix()} <domain> <command> -h`,
|
|
755
1258
|
],
|
|
756
1259
|
globalOptions: [
|
|
757
|
-
{ flag: '-f, --format
|
|
1260
|
+
{ flag: '-f, --format <format>', key: 'format', description: '输出格式:pretty(默认)、text、json、yaml、csv、auto' },
|
|
758
1261
|
{ flag: '--json', key: 'format', value: 'json', description: '等同于 -f json' },
|
|
759
1262
|
{ flag: '-h, --help', key: 'help', description: '查看帮助' },
|
|
760
1263
|
{ flag: '-v, --version', key: 'version', description: '查看版本' },
|
|
761
1264
|
],
|
|
762
1265
|
agentContract: buildAgentContract(),
|
|
763
|
-
domains:
|
|
1266
|
+
domains: domains
|
|
764
1267
|
.filter((domain) => !shouldFilterDomains || matchedDomains.has(domain.name))
|
|
765
1268
|
.sort((a, b) => a.name.localeCompare(b.name)),
|
|
766
|
-
commands: filteredCommands.map(
|
|
767
|
-
const requiredOptions = new Set(COMMAND_REQUIRED_OPTIONS[command.name] || []);
|
|
768
|
-
if (commandGroup(command) === 'artifact') requiredOptions.add('projectId');
|
|
769
|
-
const requiredAnyOptions = COMMAND_REQUIRED_ANY_OPTIONS[command.name] || [];
|
|
770
|
-
const optionKeys = new Set((command.args || []).map((arg) => normalizeKey(arg.name)));
|
|
771
|
-
return {
|
|
772
|
-
name: command.name,
|
|
773
|
-
domain: commandGroup(command),
|
|
774
|
-
command: commandSubcommand(command),
|
|
775
|
-
invocation: `${commandPrefix()} ${command.name}`,
|
|
776
|
-
helpCommand: `${commandPrefix()} ${command.name} -h`,
|
|
777
|
-
summary: summaryOf(command),
|
|
778
|
-
description: renderCliText(summaryOf(command)),
|
|
779
|
-
examples: extractExamples(command).map(renderCliText),
|
|
780
|
-
jsonExamples: extractExamples(command).map(asJsonExample),
|
|
781
|
-
requiredOptions: [...requiredOptions],
|
|
782
|
-
requiredAnyOptions,
|
|
783
|
-
safety: buildCommandSafety(command, optionKeys),
|
|
784
|
-
workflow: buildCommandWorkflow(command),
|
|
785
|
-
options: (command.args || []).map((arg) => {
|
|
786
|
-
const key = normalizeKey(arg.name);
|
|
787
|
-
return {
|
|
788
|
-
name: arg.name,
|
|
789
|
-
key,
|
|
790
|
-
flag: formatOptionName(arg.name),
|
|
791
|
-
valueName: arg.valueName || null,
|
|
792
|
-
required: requiredOptions.has(key),
|
|
793
|
-
requiredAnyGroup: requiredAnyOptions.find((group) => group.includes(key)) || null,
|
|
794
|
-
description: arg.description || '',
|
|
795
|
-
};
|
|
796
|
-
}),
|
|
797
|
-
};
|
|
798
|
-
}),
|
|
1269
|
+
commands: filteredCommands.map(buildCommandSchemaEntry),
|
|
799
1270
|
};
|
|
800
1271
|
}
|
|
801
1272
|
|
|
@@ -808,140 +1279,252 @@ function printRootHelp(commands, version) {
|
|
|
808
1279
|
}
|
|
809
1280
|
|
|
810
1281
|
const lines = [
|
|
811
|
-
`lj-awb v${version}
|
|
1282
|
+
helpTitle(`lj-awb v${version}`),
|
|
812
1283
|
'',
|
|
813
|
-
'灵境 AWB
|
|
1284
|
+
'灵境 AWB 命令行工具。默认输出人类友好的 pretty 视图;Agent 建议显式传 -f text,脚本严格解析用 -f json。',
|
|
814
1285
|
'',
|
|
815
|
-
'Usage:',
|
|
816
|
-
` ${commandPrefix()} <domain> <command> [options]
|
|
817
|
-
` ${commandPrefix()} <command> [options]
|
|
818
|
-
` ${commandPrefix()} <domain> -h
|
|
819
|
-
` ${commandPrefix()} <domain> <command> -h
|
|
1286
|
+
helpHeading('Usage:'),
|
|
1287
|
+
helpCommand(` ${commandPrefix()} <domain> <command> [options]`),
|
|
1288
|
+
helpCommand(` ${commandPrefix()} <command> [options]`),
|
|
1289
|
+
helpCommand(` ${commandPrefix()} <domain> -h`),
|
|
1290
|
+
helpCommand(` ${commandPrefix()} <domain> <command> -h`),
|
|
820
1291
|
'',
|
|
821
|
-
'Quick start:',
|
|
822
|
-
` ${commandPrefix()} auth status
|
|
823
|
-
` ${commandPrefix()} auth login
|
|
824
|
-
` ${commandPrefix()} model image-models --model Banana
|
|
825
|
-
` ${commandPrefix()} model input-guide
|
|
826
|
-
` ${commandPrefix()} model options --model-group-code <code
|
|
827
|
-
` ${commandPrefix()} model create-spec --model-group-code <code
|
|
828
|
-
` ${commandPrefix()} image
|
|
1292
|
+
helpHeading('Quick start:'),
|
|
1293
|
+
helpCommand(` ${commandPrefix()} auth status`),
|
|
1294
|
+
helpCommand(` ${commandPrefix()} auth login --access-key <access-key>`),
|
|
1295
|
+
helpCommand(` ${commandPrefix()} model image-models --model Banana`),
|
|
1296
|
+
helpCommand(` ${commandPrefix()} model input-guide`),
|
|
1297
|
+
helpCommand(` ${commandPrefix()} model options --model-group-code <code>`),
|
|
1298
|
+
helpCommand(` ${commandPrefix()} model create-spec --model-group-code <code>`),
|
|
1299
|
+
helpCommand(` ${commandPrefix()} create image --model-group-code <code> --prompt "一只小狗" --dry-run`),
|
|
829
1300
|
'',
|
|
830
|
-
'Command groups:',
|
|
1301
|
+
helpHeading('Command groups:'),
|
|
831
1302
|
];
|
|
832
1303
|
for (const [group] of groups.entries()) {
|
|
833
|
-
lines.push(` ${group.padEnd(12)} ${GROUP_DESCRIPTIONS[group] || ''}`);
|
|
1304
|
+
lines.push(` ${helpGroup(group.padEnd(12))} ${GROUP_DESCRIPTIONS[group] || ''}`);
|
|
834
1305
|
}
|
|
835
1306
|
lines.push(
|
|
836
1307
|
'',
|
|
837
|
-
'More help:',
|
|
838
|
-
` ${commandPrefix()} <domain> -h
|
|
839
|
-
` ${commandPrefix()} <domain> <command> -h
|
|
840
|
-
` ${commandPrefix()} schema -f json
|
|
841
|
-
` ${commandPrefix()}
|
|
1308
|
+
helpHeading('More help:'),
|
|
1309
|
+
helpCommand(` ${commandPrefix()} <domain> -h`),
|
|
1310
|
+
helpCommand(` ${commandPrefix()} <domain> <command> -h`),
|
|
1311
|
+
helpCommand(` ${commandPrefix()} schema --brief -f json`),
|
|
1312
|
+
helpCommand(` ${commandPrefix()} schema -f json`),
|
|
1313
|
+
helpCommand(` ${commandPrefix()} doctor -h`),
|
|
842
1314
|
'',
|
|
843
|
-
'Global options:',
|
|
844
|
-
'
|
|
845
|
-
'
|
|
846
|
-
'
|
|
847
|
-
'
|
|
1315
|
+
helpHeading('Global options:'),
|
|
1316
|
+
` ${helpOption('-f, --format <format>')} 输出格式:pretty(默认)、text、json、yaml、csv、auto`,
|
|
1317
|
+
` ${helpOption('--json'.padEnd(22))} 等同于 -f json`,
|
|
1318
|
+
` ${helpOption('-h, --help'.padEnd(22))} 查看帮助`,
|
|
1319
|
+
` ${helpOption('-v, --version'.padEnd(22))} 查看版本`,
|
|
848
1320
|
);
|
|
849
1321
|
process.stdout.write(`${lines.join('\n')}\n`);
|
|
850
1322
|
}
|
|
851
1323
|
|
|
852
1324
|
function printGroupHelp(group, commands, version) {
|
|
853
1325
|
const items = commands.filter((command) => commandGroup(command) === group);
|
|
1326
|
+
const subgroupMap = SUBGROUP_DESCRIPTIONS[group];
|
|
1327
|
+
const hasSubgroups = Boolean(subgroupMap && Object.keys(subgroupMap).length);
|
|
1328
|
+
const directItems = hasSubgroups ? items.filter((command) => !commandSubgroupTokens(command)) : [];
|
|
1329
|
+
|
|
854
1330
|
const lines = [
|
|
855
|
-
`lj-awb v${version}
|
|
1331
|
+
helpTitle(`lj-awb v${version}`),
|
|
856
1332
|
'',
|
|
857
1333
|
GROUP_DESCRIPTIONS[group] || `${group} 命令组`,
|
|
858
1334
|
'',
|
|
859
|
-
'Usage:',
|
|
860
|
-
group === 'system' ? ` ${commandPrefix()} <command> [options]` : ` ${commandPrefix()} ${group} <command> [options]`,
|
|
861
|
-
'',
|
|
862
|
-
group === 'system'
|
|
863
|
-
? `提示:system 是命令组;下面的命令可直接运行,例如 ${commandPrefix()} doctor。`
|
|
864
|
-
: `提示:${group} 是命令组;请选择下面的子命令运行。`,
|
|
865
|
-
'',
|
|
866
|
-
'Commands:',
|
|
1335
|
+
helpHeading('Usage:'),
|
|
867
1336
|
];
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1337
|
+
if (group === 'system') {
|
|
1338
|
+
lines.push(helpCommand(` ${commandPrefix()} <command> [options]`));
|
|
1339
|
+
} else if (hasSubgroups) {
|
|
1340
|
+
if (directItems.length) lines.push(helpCommand(` ${commandPrefix()} ${group} <command> [options]`));
|
|
1341
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} <subdomain> <command> [options]`));
|
|
1342
|
+
} else {
|
|
1343
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} <command> [options]`));
|
|
1344
|
+
}
|
|
1345
|
+
lines.push('');
|
|
1346
|
+
if (group === 'system') {
|
|
1347
|
+
lines.push(helpMuted(`提示:system 是命令组;下面的命令可直接运行,例如 ${commandPrefix()} doctor。`));
|
|
1348
|
+
} else if (hasSubgroups) {
|
|
1349
|
+
lines.push(helpMuted(`提示:${group} 下按子领域分组;先选子领域再看具体命令。`));
|
|
1350
|
+
} else {
|
|
1351
|
+
lines.push(helpMuted(`提示:${group} 是命令组;请选择下面的子命令运行。`));
|
|
1352
|
+
}
|
|
1353
|
+
lines.push('');
|
|
1354
|
+
|
|
1355
|
+
if (hasSubgroups) {
|
|
1356
|
+
const presentSubgroups = new Set(
|
|
1357
|
+
items
|
|
1358
|
+
.map((command) => commandSubgroupTokens(command))
|
|
1359
|
+
.filter(Boolean)
|
|
1360
|
+
.map(([, subgroup]) => subgroup),
|
|
1361
|
+
);
|
|
1362
|
+
lines.push(helpHeading('Subdomains:'));
|
|
1363
|
+
for (const [subgroup, description] of Object.entries(subgroupMap)) {
|
|
1364
|
+
if (!presentSubgroups.has(subgroup)) continue;
|
|
1365
|
+
lines.push(` ${helpGroup(subgroup.padEnd(10))} ${description}`);
|
|
1366
|
+
}
|
|
1367
|
+
if (directItems.length) {
|
|
1368
|
+
lines.push('', helpHeading('Commands:'));
|
|
1369
|
+
for (const command of directItems) {
|
|
1370
|
+
const subcommand = commandSubcommand(command);
|
|
1371
|
+
lines.push(` ${helpCommand(subcommand.padEnd(28))} ${summaryOf(command)}`);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
} else {
|
|
1375
|
+
lines.push(helpHeading('Commands:'));
|
|
1376
|
+
for (const command of items) {
|
|
1377
|
+
const subcommand = commandSubcommand(command);
|
|
1378
|
+
lines.push(` ${helpCommand(subcommand.padEnd(28))} ${summaryOf(command)}`);
|
|
1379
|
+
}
|
|
871
1380
|
}
|
|
1381
|
+
|
|
872
1382
|
if (GROUP_EXAMPLES[group]?.length) {
|
|
873
|
-
lines.push('', 'Examples:');
|
|
1383
|
+
lines.push('', helpHeading('Examples:'));
|
|
874
1384
|
for (const example of GROUP_EXAMPLES[group]) {
|
|
875
|
-
lines.push(` ${renderCliText(example)}`);
|
|
1385
|
+
lines.push(helpCommand(` ${renderCliText(example)}`));
|
|
876
1386
|
}
|
|
877
1387
|
}
|
|
878
|
-
lines.push('', 'More help:');
|
|
1388
|
+
lines.push('', helpHeading('More help:'));
|
|
879
1389
|
if (group === 'system') {
|
|
880
|
-
for (const command of items) lines.push(` ${commandPrefix()} ${command.name} -h`);
|
|
1390
|
+
for (const command of items) lines.push(helpCommand(` ${commandPrefix()} ${command.name} -h`));
|
|
1391
|
+
} else if (hasSubgroups) {
|
|
1392
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} <subdomain> -h`));
|
|
1393
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} <subdomain> <command> -h`));
|
|
881
1394
|
} else {
|
|
882
|
-
lines.push(` ${commandPrefix()} ${group} <command> -h`);
|
|
1395
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} <command> -h`));
|
|
1396
|
+
}
|
|
1397
|
+
process.stdout.write(`${lines.join('\n')}\n`);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
function printSubgroupHelp(group, subgroup, commands, version) {
|
|
1401
|
+
const items = commands.filter((command) => {
|
|
1402
|
+
const tokens = commandSubgroupTokens(command);
|
|
1403
|
+
return tokens && tokens[0] === group && tokens[1] === subgroup;
|
|
1404
|
+
});
|
|
1405
|
+
const description = SUBGROUP_DESCRIPTIONS[group]?.[subgroup] || `${group} ${subgroup} 子领域`;
|
|
1406
|
+
const lines = [
|
|
1407
|
+
helpTitle(`lj-awb v${version}`),
|
|
1408
|
+
'',
|
|
1409
|
+
description,
|
|
1410
|
+
'',
|
|
1411
|
+
helpHeading('Usage:'),
|
|
1412
|
+
helpCommand(` ${commandPrefix()} ${group} ${subgroup} <command> [options]`),
|
|
1413
|
+
'',
|
|
1414
|
+
helpHeading('Commands:'),
|
|
1415
|
+
];
|
|
1416
|
+
for (const command of items) {
|
|
1417
|
+
const parts = String(command.name || '').split(' ').filter(Boolean);
|
|
1418
|
+
const tail = parts.slice(2).join(' ');
|
|
1419
|
+
lines.push(` ${helpCommand(tail.padEnd(28))} ${summaryOf(command)}`);
|
|
1420
|
+
}
|
|
1421
|
+
const examples = SUBGROUP_EXAMPLES[`${group} ${subgroup}`];
|
|
1422
|
+
if (examples?.length) {
|
|
1423
|
+
lines.push('', helpHeading('Examples:'));
|
|
1424
|
+
for (const example of examples) {
|
|
1425
|
+
lines.push(helpCommand(` ${renderCliText(example)}`));
|
|
1426
|
+
}
|
|
883
1427
|
}
|
|
1428
|
+
lines.push('', helpHeading('More help:'));
|
|
1429
|
+
lines.push(helpCommand(` ${commandPrefix()} ${group} ${subgroup} <command> -h`));
|
|
884
1430
|
process.stdout.write(`${lines.join('\n')}\n`);
|
|
885
1431
|
}
|
|
886
1432
|
|
|
887
1433
|
function printCommandHelp(command) {
|
|
888
|
-
const lines = [`Usage: ${commandPrefix()} ${command.name} [options]
|
|
1434
|
+
const lines = [helpHeading(`Usage: ${commandPrefix()} ${command.name} [options]`), '', renderCliText(command.description || '')];
|
|
889
1435
|
if (command.args?.length) {
|
|
890
|
-
lines.push('', 'Options:');
|
|
1436
|
+
lines.push('', helpHeading('Options:'));
|
|
891
1437
|
for (const arg of command.args) {
|
|
892
1438
|
const value = arg.valueName ? ` <${arg.valueName}>` : '';
|
|
893
1439
|
const description = arg.description ? ` ${arg.description}` : '';
|
|
894
|
-
lines.push(`
|
|
1440
|
+
lines.push(` ${helpOption(`--${arg.name}${value}`)}${description}`);
|
|
895
1441
|
}
|
|
896
1442
|
}
|
|
897
|
-
lines.push(
|
|
1443
|
+
lines.push(
|
|
1444
|
+
'',
|
|
1445
|
+
helpHeading('Global options:'),
|
|
1446
|
+
` ${helpOption('-f, --format <format>')} 输出格式:pretty(默认)、text、json、yaml、csv、auto`,
|
|
1447
|
+
` ${helpOption('--json'.padEnd(22))} 等同于 -f json`,
|
|
1448
|
+
);
|
|
898
1449
|
process.stdout.write(`${lines.join('\n')}\n`);
|
|
899
1450
|
}
|
|
900
1451
|
|
|
901
|
-
function validateCommandOptions(command, kwargs) {
|
|
1452
|
+
function validateCommandOptions(command, kwargs, kwargRawFlags = {}) {
|
|
902
1453
|
const allowedKeys = (command.args || []).map((arg) => normalizeKey(arg.name));
|
|
903
1454
|
const allowed = new Set(allowedKeys);
|
|
904
1455
|
const unknown = Object.keys(kwargs).filter((key) => !allowed.has(key));
|
|
905
1456
|
if (!unknown.length) return;
|
|
1457
|
+
const displayFlag = (key) => kwargRawFlags[key] || formatOptionName(key);
|
|
906
1458
|
const suggestions = {};
|
|
907
1459
|
for (const unk of unknown) {
|
|
908
1460
|
const matches = suggestSimilarOptions(unk, allowedKeys);
|
|
909
|
-
if (matches.length) suggestions[
|
|
1461
|
+
if (matches.length) suggestions[displayFlag(unk)] = matches;
|
|
910
1462
|
}
|
|
1463
|
+
const usedShortForm = unknown.some((key) => {
|
|
1464
|
+
const flag = kwargRawFlags[key];
|
|
1465
|
+
return flag && flag.startsWith('-') && !flag.startsWith('--');
|
|
1466
|
+
});
|
|
911
1467
|
const baseHint = `运行 ${commandPrefix()} ${command.name} -h 查看可用参数。`;
|
|
1468
|
+
const shortHint = usedShortForm
|
|
1469
|
+
? `本 CLI 仅支持 -f / -h / -v 等少数短选项,业务参数请使用 --xxx 长形式。`
|
|
1470
|
+
: '';
|
|
912
1471
|
const suggestionParts = Object.entries(suggestions).map(([opt, matches]) => `${opt} → ${matches.join(' / ')}`);
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1472
|
+
const hintParts = [];
|
|
1473
|
+
if (suggestionParts.length) hintParts.push(`你是不是想用:${suggestionParts.join(';')}?`);
|
|
1474
|
+
if (shortHint) hintParts.push(shortHint);
|
|
1475
|
+
hintParts.push(baseHint);
|
|
1476
|
+
throw new LingjingAwbCliError(`未知参数:${unknown.map(displayFlag).join(', ')}`, {
|
|
917
1477
|
type: 'unknown_option',
|
|
918
1478
|
exitCode: 2,
|
|
919
|
-
hint,
|
|
1479
|
+
hint: hintParts.join(' '),
|
|
920
1480
|
details: {
|
|
921
1481
|
command: command.name,
|
|
922
|
-
unknownOptions: unknown.map(
|
|
1482
|
+
unknownOptions: unknown.map(displayFlag),
|
|
923
1483
|
...(Object.keys(suggestions).length ? { suggestions } : {}),
|
|
924
1484
|
},
|
|
925
1485
|
});
|
|
926
1486
|
}
|
|
927
1487
|
|
|
928
1488
|
function printData(data, format, meta = {}, context = {}) {
|
|
929
|
-
|
|
1489
|
+
const outputFormat = resolveOutputFormat(format);
|
|
1490
|
+
if (outputFormat === 'json') {
|
|
930
1491
|
process.stdout.write(`${JSON.stringify(createEnvelope({ status: 'success', data: normalizeJsonData(meta.command, data), meta }), null, 2)}\n`);
|
|
931
1492
|
return;
|
|
932
1493
|
}
|
|
933
|
-
|
|
1494
|
+
if (outputFormat === 'yaml') {
|
|
1495
|
+
process.stdout.write(formatYamlEnvelope(createEnvelope({ status: 'success', data: normalizeJsonData(meta.command, data), meta })));
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
if (outputFormat === 'csv') {
|
|
1499
|
+
process.stdout.write(formatCsvOutput(meta.command, data, context));
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
if (outputFormat === 'text') {
|
|
1503
|
+
process.stdout.write(formatTextOutput(meta.command, data, context));
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
process.stdout.write(formatPrettyOutput(meta.command, data, context));
|
|
934
1507
|
}
|
|
935
1508
|
|
|
936
1509
|
function printError(error, format, meta = {}) {
|
|
1510
|
+
let outputFormat = 'text';
|
|
1511
|
+
try {
|
|
1512
|
+
outputFormat = resolveOutputFormat(format);
|
|
1513
|
+
} catch {
|
|
1514
|
+
outputFormat = 'text';
|
|
1515
|
+
}
|
|
937
1516
|
const payload = {
|
|
938
1517
|
type: error.type || 'error',
|
|
939
1518
|
message: error.message || String(error),
|
|
940
1519
|
...(error.hint ? { hint: error.hint } : {}),
|
|
941
1520
|
...(error.details ? { details: error.details } : {}),
|
|
942
1521
|
};
|
|
943
|
-
if (
|
|
1522
|
+
if (outputFormat === 'json') {
|
|
944
1523
|
process.stderr.write(`${JSON.stringify(createEnvelope({ status: 'error', error: payload, meta }), null, 2)}\n`);
|
|
1524
|
+
} else if (outputFormat === 'yaml') {
|
|
1525
|
+
process.stderr.write(formatYamlEnvelope(createEnvelope({ status: 'error', error: payload, meta })));
|
|
1526
|
+
} else if (outputFormat === 'pretty') {
|
|
1527
|
+
process.stderr.write(formatPrettyError(payload));
|
|
945
1528
|
} else {
|
|
946
1529
|
process.stderr.write(formatTextError(payload));
|
|
947
1530
|
}
|
|
@@ -958,10 +1541,20 @@ export async function runStandaloneCli(argv = process.argv.slice(2)) {
|
|
|
958
1541
|
const command = commands.find((item) => item.name === resolvedCommandName);
|
|
959
1542
|
if (command) {
|
|
960
1543
|
printCommandHelp(command);
|
|
1544
|
+
} else if (isCommandSubgroupName(parsed.commandName, commands)) {
|
|
1545
|
+
const [group, subgroup] = parsed.commandName.split(' ');
|
|
1546
|
+
printSubgroupHelp(group, subgroup, commands, version);
|
|
961
1547
|
} else if (isCommandGroupName(parsed.commandName, commands)) {
|
|
962
1548
|
printGroupHelp(parsed.commandName, commands, version);
|
|
963
|
-
} else {
|
|
1549
|
+
} else if (!parsed.commandName) {
|
|
964
1550
|
printRootHelp(commands, version);
|
|
1551
|
+
} else {
|
|
1552
|
+
printError(new LingjingAwbCliError(`未知命令: ${parsed.commandName}`, {
|
|
1553
|
+
type: 'unknown_command',
|
|
1554
|
+
exitCode: 2,
|
|
1555
|
+
hint: unknownCommandHint(parsed.commandName),
|
|
1556
|
+
}), parsed.format, { command: parsed.commandName });
|
|
1557
|
+
process.exitCode = 2;
|
|
965
1558
|
}
|
|
966
1559
|
return;
|
|
967
1560
|
}
|
|
@@ -971,10 +1564,15 @@ export async function runStandaloneCli(argv = process.argv.slice(2)) {
|
|
|
971
1564
|
return;
|
|
972
1565
|
}
|
|
973
1566
|
|
|
974
|
-
const { commandName: rawCommandName, kwargs, format } = parseArgv(argv);
|
|
1567
|
+
const { commandName: rawCommandName, kwargs, kwargRawFlags, format } = parseArgv(argv);
|
|
975
1568
|
const commandName = resolveCommandName(rawCommandName, commands);
|
|
976
1569
|
const command = commands.find((item) => item.name === commandName);
|
|
977
1570
|
if (!command) {
|
|
1571
|
+
if (isCommandSubgroupName(rawCommandName, commands)) {
|
|
1572
|
+
const [group, subgroup] = rawCommandName.split(' ');
|
|
1573
|
+
printSubgroupHelp(group, subgroup, commands, version);
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
978
1576
|
if (isCommandGroupName(rawCommandName, commands)) {
|
|
979
1577
|
printGroupHelp(rawCommandName, commands, version);
|
|
980
1578
|
return;
|
|
@@ -990,11 +1588,12 @@ export async function runStandaloneCli(argv = process.argv.slice(2)) {
|
|
|
990
1588
|
|
|
991
1589
|
const startedAt = Date.now();
|
|
992
1590
|
try {
|
|
993
|
-
|
|
1591
|
+
const outputFormat = resolveOutputFormat(format);
|
|
1592
|
+
validateCommandOptions(command, kwargs, kwargRawFlags);
|
|
994
1593
|
const data = command.virtual === 'schema'
|
|
995
1594
|
? buildCommandSchema(commands, kwargs, version)
|
|
996
1595
|
: await command.func({ command }, kwargs);
|
|
997
|
-
printData(data,
|
|
1596
|
+
printData(data, outputFormat, { command: command.name, elapsedMs: Date.now() - startedAt }, buildOutputContext(command, kwargs));
|
|
998
1597
|
} catch (error) {
|
|
999
1598
|
const cliError = error instanceof LingjingAwbCliError
|
|
1000
1599
|
? error
|