@aswless_854771076/ai_short_studio_cli 0.1.163 → 0.1.164
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/dist/domain/canvas-document-check.d.ts +26 -0
- package/dist/domain/canvas-document-check.js +36 -0
- package/dist/domain/canvas-document-contract.d.ts +2 -22
- package/dist/domain/canvas-document-contract.js +15 -36
- package/package.json +1 -1
- package/skills/using-vvicat-ai-short-studio-cli/references/commands/canvas.md +1 -1
- package/skills/using-vvicat-ai-short-studio-cli/references/short-drama/module-map.json +37 -0
- package/skills/using-vvicat-ai-short-studio-cli/references/short-drama/pipeline.md +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type CanvasDocumentContract = {
|
|
2
|
+
module: string;
|
|
3
|
+
template_stem: string;
|
|
4
|
+
stage?: string;
|
|
5
|
+
required_fields: string[];
|
|
6
|
+
non_empty_fields?: string[];
|
|
7
|
+
array_fields?: string[];
|
|
8
|
+
aliases?: string[];
|
|
9
|
+
};
|
|
10
|
+
type DocumentContractMap = Record<string, CanvasDocumentContract>;
|
|
11
|
+
/**
|
|
12
|
+
* 按服务端同一套规则解析文档键:先精确匹配登记键,再匹配 `ep-001.script` 这类带分集前缀的键。
|
|
13
|
+
* 与 `documentForModule` 保持一致,避免 CLI 放行、阶段却始终 missing。
|
|
14
|
+
*/
|
|
15
|
+
export declare function matchDocumentContract(map: DocumentContractMap, documentKey: string): CanvasDocumentContract | null;
|
|
16
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
17
|
+
export type DocumentContentCheck = {
|
|
18
|
+
contract: null;
|
|
19
|
+
} | {
|
|
20
|
+
contract: CanvasDocumentContract;
|
|
21
|
+
missing: string[];
|
|
22
|
+
empty: string[];
|
|
23
|
+
invalid: string[];
|
|
24
|
+
};
|
|
25
|
+
export declare function checkDocumentContent(map: DocumentContractMap, documentKey: string, content: unknown): DocumentContentCheck;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按服务端同一套规则解析文档键:先精确匹配登记键,再匹配 `ep-001.script` 这类带分集前缀的键。
|
|
3
|
+
* 与 `documentForModule` 保持一致,避免 CLI 放行、阶段却始终 missing。
|
|
4
|
+
*/
|
|
5
|
+
export function matchDocumentContract(map, documentKey) {
|
|
6
|
+
const entries = Object.entries(map);
|
|
7
|
+
const matches = (key) => key === documentKey || documentKey.endsWith(`.${key}`);
|
|
8
|
+
return entries.find(([key]) => key === documentKey)?.[1]
|
|
9
|
+
?? entries.find(([key, contract]) => [key, ...(contract.aliases ?? [])].some(matches))?.[1] ?? null;
|
|
10
|
+
}
|
|
11
|
+
export function isPlainObject(value) {
|
|
12
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function isPresent(value) {
|
|
15
|
+
return value !== undefined && value !== null;
|
|
16
|
+
}
|
|
17
|
+
function isEmptyValue(value) {
|
|
18
|
+
if (Array.isArray(value))
|
|
19
|
+
return value.length === 0;
|
|
20
|
+
if (typeof value === 'string')
|
|
21
|
+
return value.trim().length === 0;
|
|
22
|
+
if (isPlainObject(value))
|
|
23
|
+
return Object.keys(value).length === 0;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
export function checkDocumentContent(map, documentKey, content) {
|
|
27
|
+
const contract = matchDocumentContract(map, documentKey);
|
|
28
|
+
if (!contract)
|
|
29
|
+
return { contract: null };
|
|
30
|
+
if (!isPlainObject(content))
|
|
31
|
+
return { contract, missing: [...contract.required_fields], empty: [], invalid: [] };
|
|
32
|
+
const missing = contract.required_fields.filter((field) => !isPresent(content[field]));
|
|
33
|
+
const empty = (contract.non_empty_fields ?? []).filter((field) => isPresent(content[field]) && isEmptyValue(content[field]));
|
|
34
|
+
const invalid = (contract.array_fields ?? []).filter((field) => isPresent(content[field]) && !Array.isArray(content[field]));
|
|
35
|
+
return { contract, missing, empty, invalid };
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CanvasDocumentContract } from './canvas-document-check.js';
|
|
1
2
|
/**
|
|
2
3
|
* 画布文档的内容合同。
|
|
3
4
|
*
|
|
@@ -9,28 +10,8 @@
|
|
|
9
10
|
* 在发出保存请求前本地核对。字段清单只从该文件读取一次;读取失败时放行并给出警告,避免
|
|
10
11
|
* Skill 目录被用户改动后阻塞与内容无关的保存流程。
|
|
11
12
|
*/
|
|
12
|
-
export type CanvasDocumentContract
|
|
13
|
-
module: string;
|
|
14
|
-
template_stem: string;
|
|
15
|
-
stage?: string;
|
|
16
|
-
required_fields: string[];
|
|
17
|
-
non_empty_fields?: string[];
|
|
18
|
-
};
|
|
19
|
-
type DocumentContractMap = Record<string, CanvasDocumentContract>;
|
|
20
|
-
/**
|
|
21
|
-
* 按服务端同一套规则解析文档键:先精确匹配登记键,再匹配 `ep-001.script` 这类带分集前缀的键。
|
|
22
|
-
* 与 `documentForModule` 保持一致,避免 CLI 放行、阶段却始终 missing。
|
|
23
|
-
*/
|
|
24
|
-
export declare function matchDocumentContract(map: DocumentContractMap, documentKey: string): CanvasDocumentContract | null;
|
|
13
|
+
export { checkDocumentContent, matchDocumentContract, type CanvasDocumentContract } from './canvas-document-check.js';
|
|
25
14
|
export declare function templatePathOf(contract: CanvasDocumentContract): string;
|
|
26
|
-
export type DocumentContentCheck = {
|
|
27
|
-
contract: null;
|
|
28
|
-
} | {
|
|
29
|
-
contract: CanvasDocumentContract;
|
|
30
|
-
missing: string[];
|
|
31
|
-
empty: string[];
|
|
32
|
-
};
|
|
33
|
-
export declare function checkDocumentContent(map: DocumentContractMap, documentKey: string, content: unknown): DocumentContentCheck;
|
|
34
15
|
/**
|
|
35
16
|
* 文档键的 schema-key 约定:`canvas.<document-key 末段>.v1`;审核记录统一用 `canvas.review.v1`。
|
|
36
17
|
* 服务端只校验 `canvas.*` 形状,写错不会报错,所以这里给出可修正的提示。
|
|
@@ -47,4 +28,3 @@ export declare function validateCanvasDocumentContent(input: {
|
|
|
47
28
|
allowPartial?: boolean;
|
|
48
29
|
inputCount?: number;
|
|
49
30
|
}): Promise<DocumentContentValidation>;
|
|
50
|
-
export {};
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { bundledSkillPath } from '../skill/skill-manager.js';
|
|
4
|
+
import { checkDocumentContent, isPlainObject } from './canvas-document-check.js';
|
|
5
|
+
/**
|
|
6
|
+
* 画布文档的内容合同。
|
|
7
|
+
*
|
|
8
|
+
* `canvas workflow status` 只按 `document-key` 找到已保存版本,并核对 `--input` 快照是否
|
|
9
|
+
* 过期;服务端也按同一登记合同检查正文结构。历史问题里
|
|
10
|
+
* Agent 曾先存只有 summary 的占位文档再继续生成资产,因此本地提前给出可修正的错误。
|
|
11
|
+
*
|
|
12
|
+
* 因此把"哪些文档必须包含哪些顶层字段"登记在随包 `module-map.json` 的 `documents`,由 CLI
|
|
13
|
+
* 在发出保存请求前本地核对。字段清单只从该文件读取一次;读取失败时放行并给出警告,避免
|
|
14
|
+
* Skill 目录被用户改动后阻塞与内容无关的保存流程。
|
|
15
|
+
*/
|
|
16
|
+
export { checkDocumentContent, matchDocumentContract } from './canvas-document-check.js';
|
|
4
17
|
const MODULE_MAP_PATH = join(bundledSkillPath(), 'references', 'short-drama', 'module-map.json');
|
|
5
18
|
let contractsPromise = null;
|
|
6
19
|
async function loadContracts() {
|
|
@@ -18,44 +31,9 @@ function contracts() {
|
|
|
18
31
|
contractsPromise ??= loadContracts();
|
|
19
32
|
return contractsPromise;
|
|
20
33
|
}
|
|
21
|
-
/**
|
|
22
|
-
* 按服务端同一套规则解析文档键:先精确匹配登记键,再匹配 `ep-001.script` 这类带分集前缀的键。
|
|
23
|
-
* 与 `documentForModule` 保持一致,避免 CLI 放行、阶段却始终 missing。
|
|
24
|
-
*/
|
|
25
|
-
export function matchDocumentContract(map, documentKey) {
|
|
26
|
-
if (map[documentKey])
|
|
27
|
-
return map[documentKey];
|
|
28
|
-
const key = Object.keys(map).find((candidate) => documentKey.endsWith(`.${candidate}`));
|
|
29
|
-
return key ? map[key] : null;
|
|
30
|
-
}
|
|
31
|
-
function isPlainObject(value) {
|
|
32
|
-
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
33
|
-
}
|
|
34
|
-
function isPresent(value) {
|
|
35
|
-
return value !== undefined && value !== null;
|
|
36
|
-
}
|
|
37
|
-
function isEmptyValue(value) {
|
|
38
|
-
if (Array.isArray(value))
|
|
39
|
-
return value.length === 0;
|
|
40
|
-
if (typeof value === 'string')
|
|
41
|
-
return value.trim().length === 0;
|
|
42
|
-
if (isPlainObject(value))
|
|
43
|
-
return Object.keys(value).length === 0;
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
34
|
export function templatePathOf(contract) {
|
|
47
35
|
return `references/short-drama/assets/modules/${contract.module}/prompts/${contract.template_stem}.zh.txt`;
|
|
48
36
|
}
|
|
49
|
-
export function checkDocumentContent(map, documentKey, content) {
|
|
50
|
-
const contract = matchDocumentContract(map, documentKey);
|
|
51
|
-
if (!contract)
|
|
52
|
-
return { contract: null };
|
|
53
|
-
if (!isPlainObject(content))
|
|
54
|
-
return { contract, missing: [...contract.required_fields], empty: [] };
|
|
55
|
-
const missing = contract.required_fields.filter((field) => !isPresent(content[field]));
|
|
56
|
-
const empty = (contract.non_empty_fields ?? []).filter((field) => isPresent(content[field]) && isEmptyValue(content[field]));
|
|
57
|
-
return { contract, missing, empty };
|
|
58
|
-
}
|
|
59
37
|
/**
|
|
60
38
|
* 文档键的 schema-key 约定:`canvas.<document-key 末段>.v1`;审核记录统一用 `canvas.review.v1`。
|
|
61
39
|
* 服务端只校验 `canvas.*` 形状,写错不会报错,所以这里给出可修正的提示。
|
|
@@ -91,11 +69,12 @@ export async function validateCanvasDocumentContent(input) {
|
|
|
91
69
|
if (input.schemaKey !== expected && input.schemaKey !== 'canvas.review.v1') {
|
|
92
70
|
warnings.push(`--schema-key ${input.schemaKey} 与文档键 ${input.documentKey} 不一致,建议使用 ${expected}。`);
|
|
93
71
|
}
|
|
94
|
-
if (!check.missing.length && !check.empty.length)
|
|
72
|
+
if (!check.missing.length && !check.empty.length && !check.invalid.length)
|
|
95
73
|
return { contract: check.contract, warnings };
|
|
96
74
|
const problems = [
|
|
97
75
|
check.missing.length ? `缺少顶层字段:${check.missing.join('、')}` : '',
|
|
98
76
|
check.empty.length ? `以下字段为空:${check.empty.join('、')}` : '',
|
|
77
|
+
check.invalid.length ? `以下字段必须为数组:${check.invalid.join('、')}` : '',
|
|
99
78
|
].filter(Boolean).join(';');
|
|
100
79
|
const message = `文档 ${input.documentKey} 不符合 ${templatePathOf(check.contract)} 的输出合同:${problems}。`
|
|
101
80
|
+ `先完整读取该模板,按它声明的顶层字段生成正文;只写摘要的占位文档会让后续阶段建立在空分析上。`;
|
package/package.json
CHANGED
|
@@ -136,6 +136,6 @@ handle 来自实时节点目录。只删除精确 edge ID;`--apply-ready` 只
|
|
|
136
136
|
|
|
137
137
|
`canvas workflow status` 每个检查项的 `documentKeys` 列出可接受的稳定键。`missing` 时先读 `canvas documents`,按这些键修复已有文档;同一问题不通过循环试探键、重复创建空节点或反复执行生成节点处理。文档已就绪但同键阶段仍缺失时,记录 `moduleId/documentKey/nodeId/versionId` 并报告合同不一致,保留现有产物,不绕过阶段门禁。
|
|
138
138
|
|
|
139
|
-
阶段检查会同时核对随包 `module-map.json`
|
|
139
|
+
阶段检查会同时核对随包 `module-map.json` 已登记文档的必需字段、非空字段和登记的数组类型。`incomplete-content` 表示当前版本只是草稿,读取正文后补齐并追加版本;下游引用此草稿也会失效。`duplicate-key` 表示同模块出现多份裸键、分集键或历史别名产物,先核对现有节点并保留明确的唯一依据,不通过继续创建测试节点修复。人物档案兼容历史 `generate-character-profiles` 键,新文档统一用 `character-profiles`;声音设计阶段识别 `audio-plan`。
|
|
140
140
|
|
|
141
141
|
网页初始化使用 `GET /api/projects/:projectId/canvas?view=bootstrap` 聚合快照;CLI 保持精简画布 GET,并通过现有 inspect/documents/asset 命令按需读取。助手重连保留会话和累计预算,不会重放制作指令;工具或活跃时间预算耗尽时应拆分任务,不能靠反复重连恢复额度。
|
|
@@ -455,6 +455,9 @@
|
|
|
455
455
|
],
|
|
456
456
|
"non_empty_fields": [
|
|
457
457
|
"episodes"
|
|
458
|
+
],
|
|
459
|
+
"array_fields": [
|
|
460
|
+
"episodes"
|
|
458
461
|
]
|
|
459
462
|
},
|
|
460
463
|
"script": {
|
|
@@ -469,6 +472,13 @@
|
|
|
469
472
|
],
|
|
470
473
|
"non_empty_fields": [
|
|
471
474
|
"scenes"
|
|
475
|
+
],
|
|
476
|
+
"array_fields": [
|
|
477
|
+
"scenes",
|
|
478
|
+
"unresolved"
|
|
479
|
+
],
|
|
480
|
+
"aliases": [
|
|
481
|
+
"episode"
|
|
472
482
|
]
|
|
473
483
|
},
|
|
474
484
|
"director-book": {
|
|
@@ -484,6 +494,11 @@
|
|
|
484
494
|
],
|
|
485
495
|
"non_empty_fields": [
|
|
486
496
|
"scenes"
|
|
497
|
+
],
|
|
498
|
+
"array_fields": [
|
|
499
|
+
"scenes",
|
|
500
|
+
"continuity_ledger",
|
|
501
|
+
"open_questions"
|
|
487
502
|
]
|
|
488
503
|
},
|
|
489
504
|
"asset-plan": {
|
|
@@ -496,6 +511,12 @@
|
|
|
496
511
|
"scenes",
|
|
497
512
|
"props",
|
|
498
513
|
"unresolved"
|
|
514
|
+
],
|
|
515
|
+
"array_fields": [
|
|
516
|
+
"characters",
|
|
517
|
+
"scenes",
|
|
518
|
+
"props",
|
|
519
|
+
"unresolved"
|
|
499
520
|
]
|
|
500
521
|
},
|
|
501
522
|
"production-plan": {
|
|
@@ -512,6 +533,10 @@
|
|
|
512
533
|
],
|
|
513
534
|
"non_empty_fields": [
|
|
514
535
|
"shots"
|
|
536
|
+
],
|
|
537
|
+
"array_fields": [
|
|
538
|
+
"shots",
|
|
539
|
+
"unresolved"
|
|
515
540
|
]
|
|
516
541
|
},
|
|
517
542
|
"continuity-plan": {
|
|
@@ -528,6 +553,11 @@
|
|
|
528
553
|
],
|
|
529
554
|
"non_empty_fields": [
|
|
530
555
|
"shots"
|
|
556
|
+
],
|
|
557
|
+
"array_fields": [
|
|
558
|
+
"scenes",
|
|
559
|
+
"shots",
|
|
560
|
+
"unresolved"
|
|
531
561
|
]
|
|
532
562
|
},
|
|
533
563
|
"character-profiles": {
|
|
@@ -537,6 +567,13 @@
|
|
|
537
567
|
"required_fields": [
|
|
538
568
|
"new_characters",
|
|
539
569
|
"updated_characters"
|
|
570
|
+
],
|
|
571
|
+
"array_fields": [
|
|
572
|
+
"new_characters",
|
|
573
|
+
"updated_characters"
|
|
574
|
+
],
|
|
575
|
+
"aliases": [
|
|
576
|
+
"generate-character-profiles"
|
|
540
577
|
]
|
|
541
578
|
}
|
|
542
579
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
## 文档键与内容合同
|
|
27
27
|
|
|
28
|
-
阶段状态按 `document-key`
|
|
28
|
+
阶段状态按 `document-key` 匹配文档,并核对登记合同的必需字段、非空字段、登记的数组类型及来源快照:不按节点标题、`schema-key` 或创建顺序判断,键写错时该阶段会一直显示 `missing`。以下键与必需顶层字段以 `module-map.json` 的 `documents` 为唯一机器事实;`canvas document save` 在发出请求前按同一合同核对正文,缺字段或非空字段为空时直接失败并指出要读的模板路径。
|
|
29
29
|
|
|
30
30
|
| 文档键 | 模块 | 说明 |
|
|
31
31
|
| --- | --- | --- |
|