@lingjingai/lj-awb-cli 0.3.14 → 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.
package/README.md CHANGED
@@ -26,6 +26,7 @@ CLI 本身只负责平台调用、参数校验、精简输出和安全确认;
26
26
  | 视频 | `video` | 生视频估价、提交、批量提交、状态查询、去字幕 |
27
27
  | 任务 | `task` | 任务列表、等待、任务台账和台账轮询 |
28
28
  | 资产 | `asset` | 素材库匹配、素材组、素材注册 |
29
+ | 最终产物 | `artifact` | Workbench 剧本、资产、视频最终产物 CRUD 与本地 JSON 导入 |
29
30
  | 主体 | `subject` | 可复用主体资产发布与查询 |
30
31
 
31
32
  ## 环境要求
@@ -51,6 +52,7 @@ export LINGJING_AWB_ACCESS_KEY=<access_key>
51
52
  npm install -g @lingjingai/lj-awb-cli
52
53
  lj-awb --help
53
54
  lj-awb auth status
55
+ lj-awb auth verify
54
56
  ```
55
57
 
56
58
  安装包的 `postinstall` 会默认把随包分发的 `lj-awb` skill 安装到:
@@ -114,6 +116,7 @@ lj-awb doctor --verify
114
116
  lj-awb schema -f json
115
117
  lj-awb schema --domain video -f json
116
118
  lj-awb auth status
119
+ lj-awb auth verify
117
120
  lj-awb account info
118
121
  lj-awb account teams
119
122
  lj-awb project list
@@ -125,6 +128,9 @@ lj-awb model video-models --model Seedance
125
128
  lj-awb model input-guide
126
129
  lj-awb model options --model-group-code <modelGroupCode>
127
130
  lj-awb model create-spec --model-group-code <modelGroupCode>
131
+ lj-awb artifact script import --project-id <projectId> --input-file 1_script/output/script.json --dry-run
132
+ lj-awb artifact asset import --project-id <projectId> --input-dir 2_asset/output --dry-run
133
+ lj-awb artifact video import-storyboard --project-id <projectId> --input-file 3_footage/output/ep001/ep001_storyboard.json --dry-run
128
134
  ```
129
135
 
130
136
  正式写入、切换上下文、批量和扣费命令都支持安全确认:
@@ -152,7 +158,7 @@ lj-awb schema --domain video --command create -f json
152
158
  lj-awb doctor --verify
153
159
  ```
154
160
 
155
- `doctor` 默认只做本地检查;追加 `--verify` 后会联网校验 access key、当前用户和项目组。`schema` 返回每个命令的 `options[].key`,Agent 应使用这些 key 生成 CLI 参数,而不是解析自然语言 help。
161
+ `auth status` 只检查本地是否配置 access key;`auth verify` 会联网校验 key 是否远端有效。`doctor` 默认只做本地检查;追加 `--verify` 后会联网校验 access key、当前用户和项目组。`schema` 返回每个命令的 `options[].key`,Agent 应使用这些 key 生成 CLI 参数,而不是解析自然语言 help。
156
162
 
157
163
  `schema` 还包含面向 Agent 的执行约束:
158
164
 
@@ -309,12 +315,13 @@ anime-cli/
309
315
  ## 开发命令
310
316
 
311
317
  ```bash
318
+ npm run check:local
312
319
  npm run check
313
320
  npm run smoke
314
321
  npm run version:sync -- 0.3.5
315
322
  ```
316
323
 
317
- `npm run check` 会做 Node 语法检查、shell wrapper 检查和 skill 元数据校验。`npm run smoke` 会运行帮助命令和无网络写入风险的认证状态检查。
324
+ `npm run check:local` 会做 Node 语法检查、shell wrapper 检查、skill 元数据和 schema 校验,不需要 access key。`npm run check` 会额外执行真实平台契约校验,需要本地或环境变量中有可用 access key。`npm run build:pre` / `npm run build:prod` 发布构建只自动执行 `check:local`,避免被本机过期平台凭据阻断;需要真实平台回归时单独运行 `npm run check:real`。`npm run smoke` 会运行帮助命令和无网络写入风险的认证状态检查。
318
325
 
319
326
  ## 文档索引
320
327
 
package/build/pre.mjs CHANGED
@@ -1,21 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'node:child_process';
3
- import { mkdtempSync, rmSync } from 'node:fs';
3
+ import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
 
8
8
  const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
9
+ const PRE_API_ORIGIN = 'https://animeworkbench-pre.lingjingai.cn';
9
10
  const dryRun = process.env.NPM_INSTALL_DRY_RUN === '1' || process.argv.slice(2).includes('--dry-run');
10
11
  const forceInstall = process.env.NPM_INSTALL_FORCE === '1' || process.argv.slice(2).includes('--force');
11
12
 
13
+ function commandEnv(overrides = {}) {
14
+ return {
15
+ ...process.env,
16
+ LINGJING_AWB_API_ORIGIN: PRE_API_ORIGIN,
17
+ ...overrides,
18
+ };
19
+ }
20
+
12
21
  function run(command, args, options = {}) {
13
22
  process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
14
23
  const result = spawnSync(command, args, {
15
- cwd: repoRoot,
16
- env: process.env,
24
+ cwd: options.cwd || repoRoot,
25
+ env: commandEnv(options.env),
17
26
  stdio: 'inherit',
18
- ...options,
19
27
  });
20
28
 
21
29
  if (result.error) {
@@ -27,11 +35,61 @@ function run(command, args, options = {}) {
27
35
  }
28
36
  }
29
37
 
30
- function packToTempDir(packDir) {
38
+ function capture(command, args, options = {}) {
39
+ return spawnSync(command, args, {
40
+ cwd: options.cwd || repoRoot,
41
+ env: commandEnv(options.env),
42
+ encoding: 'utf8',
43
+ stdio: ['inherit', 'pipe', 'inherit'],
44
+ });
45
+ }
46
+
47
+ function packageFilePaths() {
48
+ const result = capture('npm', ['pack', '--dry-run', '--json']);
49
+ if (result.error) {
50
+ process.stderr.write(`${result.error.message}\n`);
51
+ process.exit(1);
52
+ }
53
+ if (result.status !== 0) {
54
+ process.exit(result.status || 1);
55
+ }
56
+ const packPlan = JSON.parse(result.stdout || '[]');
57
+ const files = packPlan[0]?.files?.map((item) => item.path).filter(Boolean) || [];
58
+ if (!files.length) {
59
+ process.stderr.write('npm pack --dry-run did not return package files.\n');
60
+ process.exit(1);
61
+ }
62
+ return files;
63
+ }
64
+
65
+ function copyPackageFiles(stageDir) {
66
+ for (const relativePath of packageFilePaths()) {
67
+ const sourcePath = path.join(repoRoot, relativePath);
68
+ const targetPath = path.join(stageDir, relativePath);
69
+ mkdirSync(path.dirname(targetPath), { recursive: true });
70
+ cpSync(sourcePath, targetPath, { recursive: true });
71
+ }
72
+ }
73
+
74
+ function patchDefaultApiOrigin(stageDir, apiOrigin) {
75
+ const commonPath = path.join(stageDir, 'packages/awb-core/src/common.js');
76
+ const source = readFileSync(commonPath, 'utf8');
77
+ const next = source.replace(
78
+ /export const DEFAULT_API_ORIGIN = '[^']+';/,
79
+ `export const DEFAULT_API_ORIGIN = '${apiOrigin}';`,
80
+ );
81
+ if (next === source) {
82
+ process.stderr.write(`Could not patch DEFAULT_API_ORIGIN in ${commonPath}.\n`);
83
+ process.exit(1);
84
+ }
85
+ writeFileSync(commonPath, next, 'utf8');
86
+ }
87
+
88
+ function packToTempDir(packDir, cwd = repoRoot) {
31
89
  process.stderr.write(`$ npm pack --pack-destination ${packDir} --silent\n`);
32
90
  const result = spawnSync('npm', ['pack', '--pack-destination', packDir, '--silent'], {
33
- cwd: repoRoot,
34
- env: process.env,
91
+ cwd,
92
+ env: commandEnv(),
35
93
  encoding: 'utf8',
36
94
  stdio: ['inherit', 'pipe', 'inherit'],
37
95
  });
@@ -53,12 +111,16 @@ function packToTempDir(packDir) {
53
111
  }
54
112
 
55
113
  if (process.env.SKIP_CHECK !== '1') {
56
- run('npm', ['run', 'check']);
114
+ run('npm', ['run', 'check:local']);
57
115
  }
58
116
 
59
117
  const packDir = mkdtempSync(path.join(tmpdir(), 'lj-awb-pack-'));
118
+ const stageDir = mkdtempSync(path.join(tmpdir(), 'lj-awb-pre-src-'));
60
119
  try {
61
- const tarballPath = packToTempDir(packDir);
120
+ process.stderr.write(`Preparing local pre build with default API origin ${PRE_API_ORIGIN}.\n`);
121
+ copyPackageFiles(stageDir);
122
+ patchDefaultApiOrigin(stageDir, PRE_API_ORIGIN);
123
+ const tarballPath = packToTempDir(packDir, stageDir);
62
124
  run('npm', [
63
125
  'install',
64
126
  '-g',
@@ -75,4 +137,5 @@ try {
75
137
  }
76
138
  } finally {
77
139
  rmSync(packDir, { recursive: true, force: true });
140
+ rmSync(stageDir, { recursive: true, force: true });
78
141
  }
package/build/prod.mjs CHANGED
@@ -9,6 +9,15 @@ const pkg = JSON.parse(readFileSync(path.join(repoRoot, 'package.json'), 'utf8')
9
9
  const passthroughArgs = process.argv.slice(2);
10
10
  const registry = findArgValue(passthroughArgs, '--registry') || process.env.NPM_CONFIG_REGISTRY || 'https://registry.npmjs.org/';
11
11
  const dryRun = process.env.NPM_PUBLISH_DRY_RUN === '1' || passthroughArgs.includes('--dry-run');
12
+ const PROD_API_ORIGIN = 'https://animeworkbench.lingjingai.cn';
13
+
14
+ function commandEnv(overrides = {}) {
15
+ return {
16
+ ...process.env,
17
+ LINGJING_AWB_API_ORIGIN: PROD_API_ORIGIN,
18
+ ...overrides,
19
+ };
20
+ }
12
21
 
13
22
  function findArgValue(args, name) {
14
23
  for (let index = 0; index < args.length; index += 1) {
@@ -23,7 +32,7 @@ function run(command, args, options = {}) {
23
32
  process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
24
33
  const result = spawnSync(command, args, {
25
34
  cwd: repoRoot,
26
- env: process.env,
35
+ env: commandEnv(options.env),
27
36
  stdio: 'inherit',
28
37
  ...options,
29
38
  });
@@ -40,12 +49,27 @@ function run(command, args, options = {}) {
40
49
  function capture(command, args) {
41
50
  return spawnSync(command, args, {
42
51
  cwd: repoRoot,
43
- env: process.env,
52
+ env: commandEnv(),
44
53
  encoding: 'utf8',
45
54
  stdio: ['inherit', 'pipe', 'pipe'],
46
55
  });
47
56
  }
48
57
 
58
+ function ensureProductionDefaultApiOrigin() {
59
+ const commonPath = path.join(repoRoot, 'packages/awb-core/src/common.js');
60
+ const source = readFileSync(commonPath, 'utf8');
61
+ const match = source.match(/export const DEFAULT_API_ORIGIN = '([^']+)';/);
62
+ const actual = match?.[1] || null;
63
+ if (actual !== PROD_API_ORIGIN) {
64
+ process.stderr.write([
65
+ `Refusing to publish prod build with DEFAULT_API_ORIGIN=${actual || '(missing)'}.`,
66
+ `Expected ${PROD_API_ORIGIN}.`,
67
+ '',
68
+ ].join('\n'));
69
+ process.exit(1);
70
+ }
71
+ }
72
+
49
73
  function ensureLoggedIn() {
50
74
  const result = capture('npm', ['whoami', `--registry=${registry}`]);
51
75
  if (result.status === 0) {
@@ -75,10 +99,12 @@ function ensureVersionNotPublished() {
75
99
  }
76
100
  }
77
101
 
78
- process.stderr.write(`Preparing ${pkg.name}@${pkg.version} for npm ${dryRun ? 'dry-run' : 'publish'}.\n`);
102
+ ensureProductionDefaultApiOrigin();
103
+
104
+ process.stderr.write(`Preparing ${pkg.name}@${pkg.version} for npm ${dryRun ? 'dry-run' : 'publish'} with default API origin ${PROD_API_ORIGIN}.\n`);
79
105
 
80
106
  if (process.env.SKIP_CHECK !== '1') {
81
- run('npm', ['run', 'check']);
107
+ run('npm', ['run', 'check:local']);
82
108
  }
83
109
 
84
110
  ensureVersionNotPublished();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/lj-awb-cli",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "Lingjing AWB CLI monorepo with shared core, standalone CLI, and agent skills",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,9 @@
17
17
  "build": "node build/build.mjs",
18
18
  "build:pre": "node build/pre.mjs",
19
19
  "build:prod": "node build/prod.mjs",
20
- "check": "node --check install.mjs && node --check packages/awb-core/src/common.js && node --check packages/awb-core/src/api.js && node --check packages/awb-core/src/auth.js && node --check packages/awb-core/src/output.js && node --check packages/awb-core/src/services.js && node --check packages/awb-core/src/commands.js && node --check packages/awb-core/src/standalone.js && sh -n packages/awb-cli/bin/lj-awb && node --check packages/awb-cli/bin/lj-awb.js && node --check build/build.mjs && node --check build/pre.mjs && node --check build/prod.mjs && node --check scripts/run-openapi-cli-examples-real.mjs && node --check scripts/validate-cli-schema.mjs && node --check scripts/validate-cli-output-contract.mjs && node scripts/validate-skill-meta.mjs && node scripts/validate-cli-schema.mjs && node scripts/validate-cli-output-contract.mjs && node scripts/validate-openapi-cli-examples.mjs",
20
+ "check": "npm run check:local && npm run check:real",
21
+ "check:local": "node --check install.mjs && node --check packages/awb-core/src/common.js && node --check packages/awb-core/src/api.js && node --check packages/awb-core/src/artifact.js && node --check packages/awb-core/src/auth.js && node --check packages/awb-core/src/output.js && node --check packages/awb-core/src/services.js && node --check packages/awb-core/src/commands.js && node --check packages/awb-core/src/standalone.js && sh -n packages/awb-cli/bin/lj-awb && node --check packages/awb-cli/bin/lj-awb.js && node --check build/build.mjs && node --check build/pre.mjs && node --check build/prod.mjs && node --check scripts/run-openapi-cli-examples-real.mjs && node --check scripts/validate-cli-schema.mjs && node --check scripts/validate-cli-output-contract.mjs && node scripts/validate-skill-meta.mjs && node scripts/validate-cli-schema.mjs",
22
+ "check:real": "node scripts/validate-cli-output-contract.mjs && node scripts/validate-openapi-cli-examples.mjs",
21
23
  "test:openapi-real": "node scripts/run-openapi-cli-examples-real.mjs",
22
24
  "smoke": "packages/awb-cli/bin/lj-awb --help && packages/awb-cli/bin/lj-awb auth status -f json",
23
25
  "postinstall": "node install.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-cli-bin",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "Standalone CLI for Lingjing AWB",
5
5
  "private": true,
6
6
  "license": "MIT",
@@ -13,6 +13,6 @@
13
13
  "README.md"
14
14
  ],
15
15
  "dependencies": {
16
- "@lingjingai/awb-core": "0.3.14"
16
+ "@lingjingai/awb-core": "0.3.15"
17
17
  }
18
18
  }
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-core",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "Shared core runtime for Lingjing AWB CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./common.js": "./src/common.js",
9
9
  "./api.js": "./src/api.js",
10
+ "./artifact.js": "./src/artifact.js",
10
11
  "./auth.js": "./src/auth.js",
11
12
  "./output.js": "./src/output.js",
12
13
  "./services.js": "./src/services.js",