@lingjingai/lj-awb-cli 0.3.13 → 0.3.15

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.
@@ -13,6 +13,68 @@ function formatOptionName(value) {
13
13
  return `--${String(value || '').replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
14
14
  }
15
15
 
16
+ const OPTION_SYNONYMS = {
17
+ timeout: ['waitSeconds'],
18
+ deadline: ['waitSeconds'],
19
+ maxWait: ['waitSeconds'],
20
+ wait: ['waitSeconds'],
21
+ parallel: ['concurrency'],
22
+ workers: ['concurrency'],
23
+ jobs: ['concurrency'],
24
+ threads: ['concurrency'],
25
+ output: ['format'],
26
+ json: ['format'],
27
+ input: ['inputFile'],
28
+ in: ['inputFile'],
29
+ dry: ['dryRun'],
30
+ force: ['yes'],
31
+ };
32
+
33
+ function levenshtein(a, b) {
34
+ if (a === b) return 0;
35
+ const m = a.length;
36
+ const n = b.length;
37
+ if (!m) return n;
38
+ if (!n) return m;
39
+ let prev = Array.from({ length: n + 1 }, (_, j) => j);
40
+ let curr = new Array(n + 1);
41
+ for (let i = 1; i <= m; i++) {
42
+ curr[0] = i;
43
+ for (let j = 1; j <= n; j++) {
44
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
45
+ curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
46
+ }
47
+ [prev, curr] = [curr, prev];
48
+ }
49
+ return prev[n];
50
+ }
51
+
52
+ function suggestSimilarOptions(unknownKey, allowedKeys) {
53
+ const scored = new Map();
54
+ const record = (key, score) => {
55
+ if (!scored.has(key) || scored.get(key) > score) scored.set(key, score);
56
+ };
57
+ const synonyms = OPTION_SYNONYMS[unknownKey] || [];
58
+ for (const syn of synonyms) {
59
+ if (allowedKeys.includes(syn)) record(syn, -1);
60
+ }
61
+ for (const allowed of allowedKeys) {
62
+ const a = unknownKey.toLowerCase();
63
+ const b = allowed.toLowerCase();
64
+ if (b.includes(a) || a.includes(b)) {
65
+ record(allowed, 0);
66
+ continue;
67
+ }
68
+ const d = levenshtein(a, b);
69
+ const threshold = Math.max(2, Math.ceil(Math.min(a.length, b.length) / 3));
70
+ if (d <= threshold) record(allowed, d);
71
+ }
72
+ return [...scored.entries()]
73
+ .sort((x, y) => x[1] - y[1])
74
+ .slice(0, 3)
75
+ .map(([key]) => formatOptionName(key));
76
+ }
77
+
16
78
  function commandPrefix() {
17
79
  return process.env.LINGJING_AWB_COMMAND_PREFIX || 'lj-awb';
18
80
  }
@@ -183,18 +245,35 @@ function commandSubcommand(command) {
183
245
  return parts.length === 1 ? parts[0] : parts.slice(1).join(' ');
184
246
  }
185
247
 
248
+ function isCommandGroupName(commandName, commands) {
249
+ return Boolean(commandName && commands.some((command) => commandGroup(command) === commandName));
250
+ }
251
+
252
+ function resolveCommandName(commandName, commands) {
253
+ const exact = commands.find((command) => command.name === commandName);
254
+ if (exact) return commandName;
255
+ const parts = String(commandName || '').split(' ').filter(Boolean);
256
+ if (parts[0] === 'system' && parts.length > 1) {
257
+ const rootCommandName = parts.slice(1).join(' ');
258
+ const rootCommand = commands.find((command) => command.name === rootCommandName && commandGroup(command) === 'system');
259
+ if (rootCommand) return rootCommand.name;
260
+ }
261
+ return commandName;
262
+ }
263
+
186
264
  const GROUP_DESCRIPTIONS = {
187
265
  system: '系统:环境体检和机器可读命令 schema',
188
266
  auth: '认证:登录、查看和清空本地 access key',
189
267
  account: '账号:查看账号和团队',
190
268
  project: '项目:查看、切换、创建和更新项目组',
191
- credits: '积分:查询团队 / 项目组积分和用量统计',
269
+ credits: '积分:查询可扣积分余额、项目组预算和用量统计',
192
270
  model: '模型:查询生图 / 生视频模型、参数约束和创建用法',
193
271
  upload: '上传:把本地文件上传为平台可访问素材',
194
272
  image: '图片:估价、提交、批量提交和查询生图任务',
195
273
  video: '视频:估价、提交、批量提交、查询和去字幕',
196
274
  task: '任务:任务列表、等待和本地任务台账',
197
275
  asset: '资产:素材库匹配、素材组和素材注册',
276
+ artifact: '最终产物:Workbench 剧本、资产、视频 CRUD 与本地 JSON 导入',
198
277
  subject: '主体:发布和查询可复用主体资产',
199
278
  };
200
279
 
@@ -207,6 +286,7 @@ const GROUP_EXAMPLES = {
207
286
  ],
208
287
  auth: [
209
288
  'lj-awb auth status',
289
+ 'lj-awb auth verify',
210
290
  'lj-awb auth login-key --access-key <access-key>',
211
291
  'LINGJING_AWB_ACCESS_KEY=<access-key> lj-awb auth login-key --from-env',
212
292
  'lj-awb auth clear --dry-run',
@@ -229,6 +309,7 @@ const GROUP_EXAMPLES = {
229
309
  model: [
230
310
  'lj-awb model image-models --model Banana',
231
311
  'lj-awb model video-models --model Seedance',
312
+ 'lj-awb model input-guide',
232
313
  'lj-awb model options --model-group-code <code>',
233
314
  'lj-awb model create-spec --model-group-code <code>',
234
315
  ],
@@ -255,6 +336,11 @@ const GROUP_EXAMPLES = {
255
336
  'lj-awb asset match-actor --description "十八岁少女,古风" --tags-json \'{"gender":"女"}\'',
256
337
  'lj-awb asset group-create --name "女主素材组" --dry-run',
257
338
  ],
339
+ artifact: [
340
+ 'lj-awb artifact script import --project-id <projectId> --input-file 1_script/output/script.json --dry-run',
341
+ 'lj-awb artifact asset import --project-id <projectId> --input-dir 2_asset/output --dry-run',
342
+ 'lj-awb artifact video import-storyboard --project-id <projectId> --input-file 3_footage/output/ep001/ep001_storyboard.json --dry-run',
343
+ ],
258
344
  subject: [
259
345
  'lj-awb subject list --name "女主"',
260
346
  'lj-awb subject publish --name 女主 --primary-file ./three-view.png --dry-run',
@@ -282,6 +368,33 @@ const COMMAND_REQUIRED_OPTIONS = {
282
368
  'asset group-create': ['name'],
283
369
  'asset group-update': ['groupId'],
284
370
  'asset register': ['groupId', 'name'],
371
+ 'artifact script row': ['rowKind', 'entityKey'],
372
+ 'artifact script children': ['parentKey'],
373
+ 'artifact script delete-row': ['rowKind', 'entityKey'],
374
+ 'artifact asset actor': ['actorKey'],
375
+ 'artifact asset prop': ['propKey'],
376
+ 'artifact asset location': ['locationKey'],
377
+ 'artifact asset upsert-actor-state': ['actorKey'],
378
+ 'artifact asset upsert-prop-state': ['propKey'],
379
+ 'artifact asset upsert-location-state': ['locationKey'],
380
+ 'artifact asset delete-actor': ['actorKey'],
381
+ 'artifact asset delete-prop': ['propKey'],
382
+ 'artifact asset delete-location': ['locationKey'],
383
+ 'artifact asset delete-actor-state': ['actorKey', 'stateKey'],
384
+ 'artifact asset delete-prop-state': ['propKey', 'stateKey'],
385
+ 'artifact asset delete-location-state': ['locationKey', 'stateKey'],
386
+ 'artifact video episode': ['episodeId'],
387
+ 'artifact video scenes': ['episodeId'],
388
+ 'artifact video scene': ['episodeId', 'sceneId'],
389
+ 'artifact video clips': ['episodeId', 'sceneId'],
390
+ 'artifact video clip': ['episodeId', 'sceneId', 'clipId'],
391
+ 'artifact video upsert-scene': ['episodeId'],
392
+ 'artifact video upsert-clip': ['episodeId', 'sceneId'],
393
+ 'artifact video update-clip-video-urls': ['episodeId', 'sceneId', 'clipId', 'videoUrlsJson'],
394
+ 'artifact video delete-episode': ['episodeId'],
395
+ 'artifact video delete-scene': ['episodeId', 'sceneId'],
396
+ 'artifact video delete-clip': ['episodeId', 'sceneId', 'clipId'],
397
+ 'artifact video import-storyboard': ['inputFile'],
285
398
  'subject publish': ['name'],
286
399
  'subject wait': ['elementId'],
287
400
  'subject publish-batch': ['inputFile'],
@@ -295,9 +408,48 @@ const COMMAND_REQUIRED_ANY_OPTIONS = {
295
408
  'video create': [['prompt', 'resource', 'resourcesJson']],
296
409
  'asset group-update': [['name', 'description', 'projectName']],
297
410
  'asset register': [['file', 'url', 'backendPath']],
411
+ 'artifact script upsert-row': [['bodyJson', 'inputFile']],
412
+ 'artifact asset upsert-actor': [['bodyJson', 'inputFile']],
413
+ 'artifact asset upsert-prop': [['bodyJson', 'inputFile']],
414
+ 'artifact asset upsert-location': [['bodyJson', 'inputFile']],
415
+ 'artifact asset upsert-actor-state': [['bodyJson', 'inputFile']],
416
+ 'artifact asset upsert-prop-state': [['bodyJson', 'inputFile']],
417
+ 'artifact asset upsert-location-state': [['bodyJson', 'inputFile']],
418
+ 'artifact video upsert-episode': [['bodyJson', 'inputFile']],
419
+ 'artifact video upsert-scene': [['bodyJson', 'inputFile']],
420
+ 'artifact video upsert-clip': [['bodyJson', 'inputFile']],
298
421
  'subject publish': [['primaryFile', 'primaryUrl', 'threeViewFile', 'threeViewUrl']],
299
422
  };
300
423
 
424
+ const ARTIFACT_WRITE_COMMANDS = [
425
+ 'artifact script upsert-row',
426
+ 'artifact script delete-row',
427
+ 'artifact script import',
428
+ 'artifact asset upsert-actor',
429
+ 'artifact asset upsert-prop',
430
+ 'artifact asset upsert-location',
431
+ 'artifact asset upsert-actor-state',
432
+ 'artifact asset upsert-prop-state',
433
+ 'artifact asset upsert-location-state',
434
+ 'artifact asset delete-actor',
435
+ 'artifact asset delete-prop',
436
+ 'artifact asset delete-location',
437
+ 'artifact asset delete-actor-state',
438
+ 'artifact asset delete-prop-state',
439
+ 'artifact asset delete-location-state',
440
+ 'artifact asset import',
441
+ 'artifact video upsert-episode',
442
+ 'artifact video upsert-scene',
443
+ 'artifact video upsert-clip',
444
+ 'artifact video update-clip-video-urls',
445
+ 'artifact video delete-episode',
446
+ 'artifact video delete-scene',
447
+ 'artifact video delete-clip',
448
+ 'artifact video import-storyboard',
449
+ ];
450
+
451
+ const ARTIFACT_DELETE_COMMANDS = ARTIFACT_WRITE_COMMANDS.filter((name) => name.includes(' delete-'));
452
+
301
453
  const CONFIRMATION_COMMANDS = new Set([
302
454
  'auth clear',
303
455
  'account switch-team',
@@ -313,6 +465,7 @@ const CONFIRMATION_COMMANDS = new Set([
313
465
  'asset group-create',
314
466
  'asset group-update',
315
467
  'asset register',
468
+ ...ARTIFACT_WRITE_COMMANDS,
316
469
  'subject publish',
317
470
  'subject publish-batch',
318
471
  ]);
@@ -339,6 +492,7 @@ const REMOTE_WRITE_COMMANDS = new Set([
339
492
  'asset group-create',
340
493
  'asset group-update',
341
494
  'asset register',
495
+ ...ARTIFACT_WRITE_COMMANDS,
342
496
  'subject publish',
343
497
  'subject publish-batch',
344
498
  ]);
@@ -351,15 +505,16 @@ const LOCAL_STATE_WRITE_COMMANDS = new Set([
351
505
  'project ensure',
352
506
  ]);
353
507
 
354
- const DESTRUCTIVE_COMMANDS = new Set(['auth clear']);
508
+ const DESTRUCTIVE_COMMANDS = new Set(['auth clear', ...ARTIFACT_DELETE_COMMANDS]);
355
509
  const LONG_RUNNING_COMMANDS = new Set(['task wait', 'task record-poll', 'subject wait']);
356
- const NETWORK_NONE_COMMANDS = new Set(['schema', 'auth status', 'auth clear', 'task records']);
510
+ const NETWORK_NONE_COMMANDS = new Set(['schema', 'auth status', 'auth clear', 'model input-guide', 'task records']);
357
511
  const NETWORK_CONDITIONAL_COMMANDS = new Set(['doctor', 'auth login-key']);
358
512
 
359
513
  const OUTPUT_KIND_BY_COMMAND = {
360
514
  doctor: 'environment_report',
361
515
  schema: 'command_schema',
362
516
  'auth status': 'auth_status',
517
+ 'auth verify': 'auth_status',
363
518
  'auth login-key': 'auth_result',
364
519
  'account info': 'account_summary',
365
520
  'account teams': 'team_list',
@@ -372,6 +527,7 @@ const OUTPUT_KIND_BY_COMMAND = {
372
527
  'model video-models': 'model_list',
373
528
  'model options': 'model_options',
374
529
  'model create-spec': 'model_create_spec',
530
+ 'model input-guide': 'model_input_guide',
375
531
  'upload files': 'upload_result',
376
532
  'image fee': 'fee_estimate',
377
533
  'image create': 'task_submission',
@@ -400,9 +556,9 @@ const OUTPUT_KIND_BY_COMMAND = {
400
556
  };
401
557
 
402
558
  const PREFLIGHTS_BY_COMMAND = {
403
- 'image create': ['doctor --verify', 'model image-models', 'model options', 'model create-spec', 'image fee', 'image create --dry-run'],
559
+ 'image create': ['doctor --verify', 'model image-models', 'model options', 'model create-spec', 'confirm missing key params', 'image fee', 'image create --dry-run'],
404
560
  'image create-batch': ['doctor --verify', 'model image-models', 'model options', 'model create-spec', 'prepare JSONL input', 'image create-batch --dry-run'],
405
- 'video create': ['doctor --verify', 'model video-models', 'model options', 'model create-spec', 'video fee', 'video create --dry-run'],
561
+ 'video create': ['doctor --verify', 'model video-models', 'model options', 'model create-spec', 'confirm missing key params', 'video fee', 'video create --dry-run'],
406
562
  'video create-batch': ['doctor --verify', 'model video-models', 'model options', 'model create-spec', 'prepare JSONL input', 'video create-batch --dry-run'],
407
563
  'subject publish': ['doctor --verify', 'subject publish --dry-run'],
408
564
  'subject publish-batch': ['doctor --verify', 'prepare JSONL input', 'subject publish-batch --dry-run'],
@@ -480,7 +636,7 @@ function buildCommandSafety(command, optionKeys) {
480
636
  }
481
637
 
482
638
  function buildCommandWorkflow(command) {
483
- const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] || 'generic';
639
+ const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] || (commandGroup(command) === 'artifact' ? 'artifact_result' : 'generic');
484
640
  const next = [];
485
641
  if (['image create', 'video create'].includes(command.name)) {
486
642
  next.push('读取 data.taskId 和 data.nextCommand', '运行 task wait 等待结果');
@@ -493,7 +649,7 @@ function buildCommandWorkflow(command) {
493
649
  }
494
650
  return {
495
651
  outputKind,
496
- recommendedPreflight: PREFLIGHTS_BY_COMMAND[command.name] || [],
652
+ recommendedPreflight: PREFLIGHTS_BY_COMMAND[command.name] || (ARTIFACT_WRITE_COMMANDS.includes(command.name) ? [`${command.name} --dry-run`] : []),
497
653
  nextActions: next,
498
654
  };
499
655
  }
@@ -508,7 +664,7 @@ function buildAgentContract() {
508
664
  dryRunPolicy: 'schema.commands[].safety.supportsDryRun=true 的写入 / 扣费命令,正式执行前优先跑 --dry-run。',
509
665
  resourceShortcut: {
510
666
  flag: '--resource',
511
- syntax: 'type:usage[:reference_key]=path|url|asset:<id>',
667
+ syntax: 'type:usage[:reference_key]=path|url|asset:<id>; image create uses image:reference=... without key',
512
668
  examples: [
513
669
  'image:reference=./ref.png',
514
670
  'image:first_frame=./hero.png',
@@ -522,7 +678,7 @@ function buildAgentContract() {
522
678
  {
523
679
  type: 'image|video|audio|subject',
524
680
  usage: 'reference|first_frame|last_frame|keyframe',
525
- reference_key: 'optional key used by prompt placeholders',
681
+ reference_key: 'video reference placeholder key; not used by image create image:reference',
526
682
  source: { kind: 'url|asset_id', value: '<local-file-or-http-url-or-material-backendPath-or-asset-id>' },
527
683
  },
528
684
  ],
@@ -530,17 +686,23 @@ function buildAgentContract() {
530
686
  modelOptions: {
531
687
  command: `${commandPrefix()} model options --model-group-code <code>`,
532
688
  jsonCommand: `${commandPrefix()} model options --model-group-code <code> -f json`,
533
- purpose: '查询指定模型支持的 CLI 参数、枚举值、默认值和素材约束。',
689
+ purpose: '查询指定模型支持的 CLI 参数、枚举值、默认值、素材约束和条件约束。',
534
690
  useBefore: ['model create-spec', 'image fee', 'image create', 'video fee', 'video create'],
535
- keyFields: ['params[].values', 'params[].defaultValue', 'resources[].mediaType', 'resources[].usage', 'resources[].fileTypes', 'resources[].maxFiles', 'resources[].minDurationMs', 'resources[].maxDurationMs'],
691
+ 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'],
536
692
  },
537
693
  modelCreateSpec: {
538
694
  command: `${commandPrefix()} model create-spec --model-group-code <code>`,
539
695
  jsonCommand: `${commandPrefix()} model create-spec --model-group-code <code> -f json`,
540
- purpose: '查看指定模型如何组织 create 命令:输入模式、prompt/key 规则、示例和创建前检查项。',
696
+ purpose: '查看指定模型如何组织 create 命令:输入模式、素材绑定规则、示例和创建前检查项。',
541
697
  useBefore: ['image fee', 'image create', 'video fee', 'video create'],
542
698
  keyFields: ['inputRequirement', 'supportedIntents', 'validationRules', 'agentGuidance', 'preflight', 'examples'],
543
699
  },
700
+ modelInputGuide: {
701
+ command: `${commandPrefix()} model input-guide`,
702
+ jsonCommand: `${commandPrefix()} model input-guide -f json`,
703
+ purpose: '查看跨模型统一创建参数、resources 字段和素材绑定规则。',
704
+ useBefore: ['model options', 'model create-spec'],
705
+ },
544
706
  taskTypes: {
545
707
  image: 'IMAGE_CREATE',
546
708
  video: 'VIDEO_GROUP',
@@ -603,6 +765,7 @@ function buildCommandSchema(commands, kwargs = {}, version = 'unknown') {
603
765
  .sort((a, b) => a.name.localeCompare(b.name)),
604
766
  commands: filteredCommands.map((command) => {
605
767
  const requiredOptions = new Set(COMMAND_REQUIRED_OPTIONS[command.name] || []);
768
+ if (commandGroup(command) === 'artifact') requiredOptions.add('projectId');
606
769
  const requiredAnyOptions = COMMAND_REQUIRED_ANY_OPTIONS[command.name] || [];
607
770
  const optionKeys = new Set((command.args || []).map((arg) => normalizeKey(arg.name)));
608
771
  return {
@@ -659,6 +822,7 @@ function printRootHelp(commands, version) {
659
822
  ` ${commandPrefix()} auth status`,
660
823
  ` ${commandPrefix()} auth login-key --access-key <access-key>`,
661
824
  ` ${commandPrefix()} model image-models --model Banana`,
825
+ ` ${commandPrefix()} model input-guide`,
662
826
  ` ${commandPrefix()} model options --model-group-code <code>`,
663
827
  ` ${commandPrefix()} model create-spec --model-group-code <code>`,
664
828
  ` ${commandPrefix()} image create --model-group-code <code> --prompt "一只小狗" --dry-run`,
@@ -695,6 +859,10 @@ function printGroupHelp(group, commands, version) {
695
859
  'Usage:',
696
860
  group === 'system' ? ` ${commandPrefix()} <command> [options]` : ` ${commandPrefix()} ${group} <command> [options]`,
697
861
  '',
862
+ group === 'system'
863
+ ? `提示:system 是命令组;下面的命令可直接运行,例如 ${commandPrefix()} doctor。`
864
+ : `提示:${group} 是命令组;请选择下面的子命令运行。`,
865
+ '',
698
866
  'Commands:',
699
867
  ];
700
868
  for (const command of items) {
@@ -731,16 +899,28 @@ function printCommandHelp(command) {
731
899
  }
732
900
 
733
901
  function validateCommandOptions(command, kwargs) {
734
- const allowed = new Set((command.args || []).map((arg) => normalizeKey(arg.name)));
902
+ const allowedKeys = (command.args || []).map((arg) => normalizeKey(arg.name));
903
+ const allowed = new Set(allowedKeys);
735
904
  const unknown = Object.keys(kwargs).filter((key) => !allowed.has(key));
736
905
  if (!unknown.length) return;
906
+ const suggestions = {};
907
+ for (const unk of unknown) {
908
+ const matches = suggestSimilarOptions(unk, allowedKeys);
909
+ if (matches.length) suggestions[formatOptionName(unk)] = matches;
910
+ }
911
+ const baseHint = `运行 ${commandPrefix()} ${command.name} -h 查看可用参数。`;
912
+ const suggestionParts = Object.entries(suggestions).map(([opt, matches]) => `${opt} → ${matches.join(' / ')}`);
913
+ const hint = suggestionParts.length
914
+ ? `你是不是想用:${suggestionParts.join(';')}?否则 ${baseHint}`
915
+ : baseHint;
737
916
  throw new LingjingAwbCliError(`未知参数:${unknown.map(formatOptionName).join(', ')}`, {
738
917
  type: 'unknown_option',
739
918
  exitCode: 2,
740
- hint: `运行 ${commandPrefix()} ${command.name} -h 查看可用参数。`,
919
+ hint,
741
920
  details: {
742
921
  command: command.name,
743
922
  unknownOptions: unknown.map(formatOptionName),
923
+ ...(Object.keys(suggestions).length ? { suggestions } : {}),
744
924
  },
745
925
  });
746
926
  }
@@ -774,10 +954,11 @@ export async function runStandaloneCli(argv = process.argv.slice(2)) {
774
954
 
775
955
  if (argv.length === 0 || argv.includes('-h') || argv.includes('--help')) {
776
956
  const parsed = parseArgv(argv.filter((item) => item !== '-h' && item !== '--help'));
777
- const command = commands.find((item) => item.name === parsed.commandName);
957
+ const resolvedCommandName = resolveCommandName(parsed.commandName, commands);
958
+ const command = commands.find((item) => item.name === resolvedCommandName);
778
959
  if (command) {
779
960
  printCommandHelp(command);
780
- } else if (parsed.commandName && commands.some((item) => commandGroup(item) === parsed.commandName)) {
961
+ } else if (isCommandGroupName(parsed.commandName, commands)) {
781
962
  printGroupHelp(parsed.commandName, commands, version);
782
963
  } else {
783
964
  printRootHelp(commands, version);
@@ -791,9 +972,13 @@ export async function runStandaloneCli(argv = process.argv.slice(2)) {
791
972
  }
792
973
 
793
974
  const { commandName: rawCommandName, kwargs, format } = parseArgv(argv);
794
- const commandName = rawCommandName;
975
+ const commandName = resolveCommandName(rawCommandName, commands);
795
976
  const command = commands.find((item) => item.name === commandName);
796
977
  if (!command) {
978
+ if (isCommandGroupName(rawCommandName, commands)) {
979
+ printGroupHelp(rawCommandName, commands, version);
980
+ return;
981
+ }
797
982
  printError(new LingjingAwbCliError(`未知命令: ${rawCommandName || '(empty)'}`, {
798
983
  type: 'unknown_command',
799
984
  exitCode: 2,
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lj-awb
3
- version: 0.3.13
4
- description: "灵境 AWB CLI skill。使用 `lj-awb` 命令调用动漫平台 / AWB 云端能力,覆盖认证、项目组、积分、模型发现、上传、生图、生视频和任务查询。正式生成、切换项目组、清空认证等写入或扣费动作前必须确认。"
3
+ version: 0.3.15
4
+ description: "灵境 AWB CLI skill。使用 `lj-awb` 命令调用动漫平台 / AWB 云端能力,覆盖认证、项目组、积分、模型发现、上传、生图、生视频、任务查询、最终产物 artifact CRUD 与 E2B 输出导入。正式生成、切换项目组、清空认证、artifact 写入等写入或扣费动作前必须确认。"
5
5
  metadata:
6
6
  requires:
7
7
  bins: ["lj-awb"]
@@ -34,7 +34,7 @@ fi
34
34
  | 认证 | access key、登录状态、本地凭据 | [`modules/auth.md`](modules/auth.md) |
35
35
  | 账号 | 用户、团队和登录上下文 | [`modules/account.md`](modules/account.md) |
36
36
  | 项目 | 项目组查询、切换、创建和更新 | [`modules/project.md`](modules/project.md) |
37
- | 积分 | 团队 / 项目组积分、用量估算 | [`modules/credits.md`](modules/credits.md) |
37
+ | 积分 | 可扣积分余额、项目组预算和用量估算 | [`modules/credits.md`](modules/credits.md) |
38
38
  | 模型 | 生图 / 生视频模型、参数约束和创建用法 | [`modules/model.md`](modules/model.md) |
39
39
  | 创作入参 | 任务创建参数含义、素材组织、模型配置映射和校验 | [`modules/create-contract.md`](modules/create-contract.md) |
40
40
  | 任务手册 | 参考图、首帧、首尾帧、音频参考、主体复用等任务选型 | [`modules/task-manual.md`](modules/task-manual.md) |
@@ -43,6 +43,7 @@ fi
43
43
  | 视频 | 生视频估价、提交、等待、批量 | [`modules/video.md`](modules/video.md) |
44
44
  | 任务 | 任务列表、等待、任务台账 | [`modules/task.md`](modules/task.md) |
45
45
  | 资产 | 素材匹配、素材组、素材注册 | [`modules/asset.md`](modules/asset.md) |
46
+ | 最终产物 | Workbench 剧本、资产、视频 CRUD 与 E2B 输出导入 | [`modules/artifact.md`](modules/artifact.md) |
46
47
  | 主体 | 可复用主体资产发布与查询 | [`modules/subject.md`](modules/subject.md) |
47
48
  | 工作流 | Agent 面向任务的标准编排流程 | [`modules/workflows.md`](modules/workflows.md) |
48
49
  | 压测 | 多轮对话 eval 用例和反模式检查 | [`modules/evals.md`](modules/evals.md) |
@@ -59,19 +60,24 @@ fi
59
60
  - Agent 不确定命令参数时,优先运行 `lj-awb schema -f json`,不要从记忆里猜。
60
61
  - 读取 `schema.commands[].requiredOptions` 和 `requiredAnyOptions` 后再组装命令;缺少必填参数时先问用户或用查询命令补齐。
61
62
  - 读取 `schema.commands[].safety` 决定是否能自动执行:`safeToAutoRun=false` 时必须说明影响;`requiresConfirmation=true` 时必须先确认再追加 `--yes`。
62
- - 写入 / 扣费命令如果 `supportsDryRun=true`,先跑 `--dry-run` 给用户确认请求体和关键参数。
63
+ - 只读验证命令可以先执行,包括 `auth verify`、`doctor --verify`、模型列表、`model options`、`model create-spec`、账号和项目组查询;`auth status` 只看本地配置,不代表远端有效;`fee` 和 `create --dry-run` 必须等缺失关键参数确认后再跑。
64
+ - 关键参数是会影响价格或生成效果的枚举:视频 `quality`、`duration`、约束后仍可选的 `ratio`,以及用户明确要输出音效时的 `needAudio`;图片 `quality`、`ratio`、`generateNum`。候选值和默认值来自 `model options.params[]`,不能静默用默认值先估价或 dry-run。
65
+ - 写入 / 扣费命令如果 `supportsDryRun=true`,在关键参数已确认后跑 `--dry-run` 给用户确认请求体。
63
66
  - 进入正式任务前先运行 `lj-awb doctor --verify`,确认认证、API、项目组和 UTF-8 环境。
64
67
  - 所有正式创作前必须确认:账号、团队、项目组、模型组、关键参数、prompt、参考素材、预估积分。
65
- - Prompt 处理的核心是组装可执行请求:把用户创作描述、资源占位符、模型限制和参数选择组织成可提交 prompt。
68
+ - 积分确认必须优先看 `billingPointBalance`,它来自 `/api/anime/member/benefits/queryGroupPoint`,表示实际可扣积分;`projectBudgetBalance` 只是项目组预算 / ROI 约束,不要把项目组预算说成积分余额。
69
+ - Prompt 处理的核心是组装可执行请求:把用户创作描述、素材输入、模型限制和参数选择组织成可提交 prompt。
66
70
  - 用户有明确创作描述或提示词时,以该文本为基底;“使用某模型 / 参考生 / 生成视频 / 用这张图 / 用这个音频”等操作性指令只用于选择模型和资源,不要改写成新的画面描述。
67
71
  - 用户没有比较明确的创作需求或提示词时,先追问关键创作意图,或使用最小中性表达;不要为了让 prompt 好看而主动补风格、镜头、剧情细节。
68
- - 用户要求优化 / 改写 / 创作时可以进行提示词创作,但要展示最终 prompt 并让用户确认;资源占位符、key 对齐、转义清理属于协议级组装,可见文本变化时先说明。
69
- - 参考图已经作为素材输入时,不要从图片内容中推断场景、风格或主体描述并写进 prompt;只保留用户明确说出的动作、要求和必要的 `<<<key>>>` 占位符。
70
- - 不要凭记忆提交模型参数;先查模型,再查 `model options`,再查 `model create-spec`,优先用其中的 `params` / `resources` / `inputRequirement` / `supportedIntents` / `validationRules` 组织任务。
71
- - 音频必须先区分语义:用户上传 / 指定音频文件、音乐、配音、节奏参考时,这是 `resources` 素材输入,通常用 `--resource audio:reference=...`;`--need-audio` 只表示输出视频是否让模型生成 / 携带音频或音效的布尔开关,不接收音频文件。用户强调“音频也要参考 / 显式参考音频”时,可以用 `audio:reference:<key>` 并在 prompt 中插入同名 `<<<key>>>`。
72
- - 只要资源使用了 `reference_key`,prompt 就必须出现同名 `<<<key>>>`。如果用户说“参考生视频 / 引用这张图”,而 prompt 没有占位符,可以把补齐占位符后的 prompt 作为创建前确认项;如果用户明确要求原文不改,必须展示调整前后并确认。
72
+ - 用户要求优化 / 改写 / 创作时可以进行提示词创作,但要展示最终 prompt 并让用户确认;视频素材占位符、key 对齐、转义清理属于协议级组装,可见文本变化时先说明。
73
+ - 图片生图没有 `reference_key` / `<<<key>>>` 概念;参考图只用 `image:reference=...` 传入,prompt 用“图一 / 图二 / 参考图 / 白发女 / 背景图”等自然描述映射素材。
74
+ - 视频参考图已经作为素材输入时,不要从图片内容中推断场景、风格或主体描述并写进 prompt;只保留用户明确说出的动作、要求,以及用户确认过的 `<<<key>>>` 占位符。
75
+ - 不要凭记忆提交模型参数;先查模型,必要时查 `model input-guide` 理解统一入参,再查 `model options` 和 `model create-spec`,优先用其中的 `params` / `resources` / `constraints` / `inputRequirement` / `supportedIntents` / `validationRules` 组织任务。
76
+ - 音频必须先区分语义:用户上传 / 指定音频文件、音乐、配音、节奏参考时,这是 `resources` 素材输入;只有 `model options.resources[]` 存在 `media=AUDIO usage=reference` 时才可用 `--resource audio:reference=...`。向用户说明时说“是否需要输出音效”;命令层对应 `--need-audio true/false`,不接收音频文件。用户明确要在 prompt 中指代音频时,才使用 `audio:reference:<key>` 并让 prompt 出现同名 `<<<key>>>`。
77
+ - `reference_key` 只用于视频 reference / subject 等需要占位绑定的场景。普通视频参考素材不需要 key;如果 prompt 写了 `<<<key>>>`,必须有同名 reference 资源。不要为了引用素材而强行改写用户 prompt。
73
78
  - 不要把模型列表摘要或缺失参数做成负面能力清单。默认只向用户说明支持的创作意图、必需输入和可控参数;只有用户明确问音频、多条数等控制项时,才说明 `model options` 里没有对应参数或资源。
74
- - 创作任务前先用 `model options` 看参数值和资源约束,再用 `model create-spec` 看如何组织创建任务;不要回到旧的原始模型选项入口。
79
+ - 面向用户列模型参数时用自然语言:`needAudio` 说成“音效:是否需要输出音效”,不要用 CLI flag 加技术解释的写法;只有展示最终命令时才出现 `--need-audio true/false`。
80
+ - 创作任务前先用 `model options` 看参数值、资源约束和条件约束,再用 `model create-spec` 看如何组织创建任务;不要回到旧的原始模型选项入口。
75
81
  - 遇到 exit code `10` 且错误类型为 `confirmation_required` 时,向用户明确确认后再追加 `--yes` 重试。
76
82
  - `task wait` 的超时只代表当前轮询窗口结束,不代表远端任务失败。
77
83
  - skill 不直接写 E2B 项目的 `output/`;项目级 skill 应在用户确认后负责写回正式产物。
@@ -1 +1 @@
1
- 0.3.13
1
+ 0.3.15
@@ -1,6 +1,6 @@
1
1
  {
2
- "skillVersion": "0.3.13",
3
- "minCliVersion": "0.3.13",
2
+ "skillVersion": "0.3.15",
3
+ "minCliVersion": "0.3.15",
4
4
  "preferredCommand": "lj-awb",
5
- "updatedAt": "2026-05-11"
5
+ "updatedAt": "2026-05-12"
6
6
  }
@@ -0,0 +1,86 @@
1
+ # Artifact Module
2
+
3
+ artifact 模块用于把 E2B / 本地流水线产出的最终 JSON 写入 Workbench 数据库化产物,也可直接查询或单条 CRUD。写入都是云端动作,必须先 dry-run,再经用户确认后追加 `--yes`。
4
+
5
+ ## 项目 ID
6
+
7
+ 所有 artifact 命令都需要 `--project-id <id>`。在 E2B 沙箱里通常从环境变量读取:
8
+
9
+ ```bash
10
+ PROJECT_ID="${SANDBOX_PROJECT_ID:?missing SANDBOX_PROJECT_ID}"
11
+ ```
12
+
13
+ ## 标准导入
14
+
15
+ ```bash
16
+ lj-awb artifact script import \
17
+ --project-id "$PROJECT_ID" \
18
+ --input-file 1_script/output/script.json \
19
+ --dry-run
20
+
21
+ lj-awb artifact asset import \
22
+ --project-id "$PROJECT_ID" \
23
+ --input-dir 2_asset/output \
24
+ --dry-run
25
+
26
+ lj-awb artifact video import-storyboard \
27
+ --project-id "$PROJECT_ID" \
28
+ --input-file 3_footage/output/ep001/ep001_storyboard.json \
29
+ --dry-run
30
+ ```
31
+
32
+ 用户确认后,把对应命令的 `--dry-run` 替换为 `--yes`。批量 storyboard 需要逐个 episode 文件执行 `artifact video import-storyboard`。
33
+
34
+ ## 查询命令
35
+
36
+ | 命令 | 用途 |
37
+ |------|------|
38
+ | `lj-awb artifact script get --project-id <id>` | 查询完整剧本产物 |
39
+ | `lj-awb artifact script rows --project-id <id> --row-kind scene` | 查询剧本行 |
40
+ | `lj-awb artifact script row --project-id <id> --row-kind action --entity-key "ep_001/scn_001#0"` | 查询单行 |
41
+ | `lj-awb artifact asset actors --project-id <id> --include-states true` | 查询角色资产 |
42
+ | `lj-awb artifact asset props --project-id <id>` | 查询道具资产 |
43
+ | `lj-awb artifact asset locations --project-id <id>` | 查询场景资产 |
44
+ | `lj-awb artifact video episodes --project-id <id>` | 查询视频集 |
45
+ | `lj-awb artifact video clips --project-id <id> --episode-id ep_001 --scene-id scn_001` | 查询某场 clips |
46
+
47
+ ## 单条写入
48
+
49
+ 单条 upsert 可用 `--body-json` 或 `--input-file` 传 camelCase body:
50
+
51
+ ```bash
52
+ lj-awb artifact script upsert-row --project-id <id> --input-file row.json --dry-run
53
+ lj-awb artifact asset upsert-actor --project-id <id> --input-file actor.json --dry-run
54
+ lj-awb artifact asset upsert-actor-state --project-id <id> --actor-key act_001 --input-file state.json --dry-run
55
+ lj-awb artifact video upsert-clip --project-id <id> --episode-id ep_001 --scene-id scn_001 --input-file clip.json --dry-run
56
+ ```
57
+
58
+ 视频生成完成后,只回写 clip 链接:
59
+
60
+ ```bash
61
+ lj-awb artifact video update-clip-video-urls \
62
+ --project-id <id> \
63
+ --episode-id ep_001 \
64
+ --scene-id scn_001 \
65
+ --clip-id clip_001 \
66
+ --video-urls-json '["https://example.com/a.mp4"]' \
67
+ --dry-run
68
+ ```
69
+
70
+ ## 删除
71
+
72
+ 删除命令都是逻辑删除,并且需要确认:
73
+
74
+ ```bash
75
+ lj-awb artifact script delete-row --project-id <id> --row-kind action --entity-key "ep_001/scn_001#0" --dry-run
76
+ lj-awb artifact asset delete-actor --project-id <id> --actor-key act_001 --dry-run
77
+ lj-awb artifact video delete-clip --project-id <id> --episode-id ep_001 --scene-id scn_001 --clip-id clip_001 --dry-run
78
+ ```
79
+
80
+ ## 规则
81
+
82
+ - 不确定命令参数时先读 `lj-awb schema --domain artifact -f json`。
83
+ - `script import` 会把 `script.json` 拆成 `document / asset / state / speaker / episode / scene / action` 行。
84
+ - `asset import` 默认在 `--input-dir` 下查找 `actors/actors.json`、`props/props.json`、`locations/locations.json`,也兼容扁平 `actors.json` 等文件。
85
+ - `video import-storyboard` 会写入 episode、scenes 和 clips;`episodeId` 优先取 JSON 字段,否则从 `ep001_storyboard.json` 文件名推断。
86
+ - 单条 body 使用 Workbench 接口 camelCase 字段,不要传数据库内部 `id`、`projectId`、`createdAt`、`updatedAt`、`isDeleted`。
@@ -7,6 +7,7 @@
7
7
  | 命令 | 用途 |
8
8
  |------|------|
9
9
  | `lj-awb auth status` | 查看本地是否有 access key |
10
+ | `lj-awb auth verify` | 联网校验 access key 是否远端有效 |
10
11
  | `lj-awb account info` | 联网确认 access key 有效,并查看当前用户 / 团队 / 项目组 |
11
12
  | `lj-awb doctor --verify` | 联网体检认证、API、项目组和运行环境 |
12
13
  | `lj-awb auth login-key --access-key <key>` | 校验并保存 access key |
@@ -19,5 +20,5 @@
19
20
 
20
21
  - 自动化环境优先使用 `LINGJING_AWB_ACCESS_KEY`,兼容 `AWB_ACCESS_KEY` / `AWB_CODE` / `ANIME_ACCESS_KEY`。
21
22
  - 不要把 access key 明文写入对话、日志、文档或任务台账。
22
- - `auth status` 只读本地配置;正式创作前用 `account info` 或 `doctor --verify` 确认远端可用。
23
+ - `auth status` 只读本地配置;正式创作前用 `auth verify`、`account info` 或 `doctor --verify` 确认远端可用。
23
24
  - `auth clear` 是本地破坏性动作,必须先确认或 dry-run。