@joplo-app/core 0.2.7 → 0.2.9
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/agent-skill.d.ts +2 -2
- package/dist/agent-skill.js +15 -4
- package/dist/catalog.d.ts +21 -5
- package/dist/catalog.js +149 -21
- package/dist/compile.d.ts +9 -1
- package/dist/compile.js +336 -60
- package/dist/diagram/elk.d.ts +6 -0
- package/dist/diagram/elk.js +56 -0
- package/dist/diagram/graph-layout.d.ts +123 -0
- package/dist/diagram/graph-layout.js +620 -0
- package/dist/diagram/index.d.ts +41 -0
- package/dist/diagram/index.js +92 -0
- package/dist/diagram/model.d.ts +217 -0
- package/dist/diagram/model.js +189 -0
- package/dist/diagram/sequence-layout.d.ts +12 -0
- package/dist/diagram/sequence-layout.js +185 -0
- package/dist/focus-check.d.ts +9 -0
- package/dist/focus-check.js +95 -0
- package/dist/focus.d.ts +50 -0
- package/dist/focus.js +274 -0
- package/dist/guide.d.ts +14 -0
- package/dist/guide.js +310 -26
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +2 -0
- package/dist/outline.d.ts +58 -0
- package/dist/outline.js +72 -0
- package/dist/pace.d.ts +33 -0
- package/dist/pace.js +61 -0
- package/dist/player.d.ts +1 -0
- package/dist/player.js +16 -6
- package/dist/schema.d.ts +103 -0
- package/dist/schema.js +55 -0
- package/dist/validate.js +44 -4
- package/package.json +3 -2
package/dist/outline.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 大纲(D67,`joplo outline`):不看看板也能检查一个演示“讲给谁、讲什么、讲多久”。只读现有 IR,不新增作者概念:
|
|
3
|
+
* - 功能:goal(解决什么)、roles(给谁,旧的名字数组也算)、cases(PM 的验收条件:维度、优先级、expected = Then)与每个方案的覆盖;
|
|
4
|
+
* - 方案与场景:步数、估算时长(与自动播放同一份 stepDwell)、是否以过渡卡开场 / 收尾、结局、覆盖的情况。
|
|
5
|
+
* 估算按 1× 速度、用 IR 里的英文字幕兜底,不含鼠标移动与逐字输入,所以只是“约”。
|
|
6
|
+
*/
|
|
7
|
+
import { orderedFeatures } from "./features.js";
|
|
8
|
+
import { holdMsOf } from "./focus.js";
|
|
9
|
+
import { stepDwell } from "./pace.js";
|
|
10
|
+
import { JoploError } from "./result.js";
|
|
11
|
+
/** 一步停留时要读的文字:说明、explain,过渡卡再加副标题与要点(与看板封面的估算同一口径)。 */
|
|
12
|
+
export function stepTexts(step) {
|
|
13
|
+
return [step.caption, step.explain, ...(step.action.type === 'card' ? [step.action.sub, ...(step.action.points ?? [])] : [])];
|
|
14
|
+
}
|
|
15
|
+
/** 一个场景按 1× 自动播放大约多久(毫秒):每一步 stepDwell 之和。 */
|
|
16
|
+
export function scenarioEstimateMs(scenario) {
|
|
17
|
+
return scenario.steps.reduce((sum, step) => sum + Math.max(holdMsOf(step), stepDwell({ texts: stepTexts(step), cameraMoved: step.shots.length > 0 || !!step.directorLayer, streams: step.effects.flatMap((e) => (e.type === 'stream' ? [e.value] : [])) })), 0);
|
|
18
|
+
}
|
|
19
|
+
export function outline(project, opts = {}) {
|
|
20
|
+
if (opts.optionId && !Object.hasOwn(project.options, opts.optionId))
|
|
21
|
+
throw new JoploError('USAGE', `Option does not exist: ${opts.optionId}`);
|
|
22
|
+
const only = opts.optionId ? project.options[opts.optionId].featureId : null;
|
|
23
|
+
const features = [];
|
|
24
|
+
for (const f of orderedFeatures(project)) {
|
|
25
|
+
if (only && f.id !== only)
|
|
26
|
+
continue;
|
|
27
|
+
const optionIds = f.optionIds.filter((id) => project.options[id] && (!opts.optionId || id === opts.optionId));
|
|
28
|
+
const cases = f.caseIds.flatMap((cid) => {
|
|
29
|
+
const c = project.cases[cid];
|
|
30
|
+
if (!c)
|
|
31
|
+
return [];
|
|
32
|
+
const coverage = {};
|
|
33
|
+
for (const oid of optionIds) {
|
|
34
|
+
const cov = project.options[oid].coverage[cid];
|
|
35
|
+
if (cov)
|
|
36
|
+
coverage[oid] = cov.status;
|
|
37
|
+
}
|
|
38
|
+
return [{ id: c.id, key: c.id.slice(f.id.length + 1), title: c.title, dimension: c.dimension, priority: c.priority, expected: c.expected, coverage }];
|
|
39
|
+
});
|
|
40
|
+
const options = optionIds.map((oid) => {
|
|
41
|
+
const o = project.options[oid];
|
|
42
|
+
const scenarios = Object.values(project.scenarios)
|
|
43
|
+
.filter((s) => s.optionId === oid)
|
|
44
|
+
.map((s) => ({
|
|
45
|
+
id: s.id,
|
|
46
|
+
key: s.id.slice(oid.length + 1),
|
|
47
|
+
name: s.name,
|
|
48
|
+
description: s.description,
|
|
49
|
+
steps: s.steps.length,
|
|
50
|
+
ms: scenarioEstimateMs(s),
|
|
51
|
+
cards: s.steps.filter((st) => st.action.type === 'card').length,
|
|
52
|
+
opening: s.steps[0]?.action.type === 'card',
|
|
53
|
+
ending: s.steps.length > 0 && s.steps.at(-1).action.type === 'card',
|
|
54
|
+
outcome: s.mock.outcome,
|
|
55
|
+
caseIds: s.caseIds,
|
|
56
|
+
}));
|
|
57
|
+
const statuses = Object.values(o.coverage).map((c) => c.status);
|
|
58
|
+
return {
|
|
59
|
+
id: oid,
|
|
60
|
+
key: o.key,
|
|
61
|
+
name: o.name,
|
|
62
|
+
picked: f.pick === oid,
|
|
63
|
+
ms: scenarios.reduce((n, s) => n + s.ms, 0),
|
|
64
|
+
missing: statuses.filter((s) => s === 'missing').length,
|
|
65
|
+
undecided: statuses.filter((s) => s === 'undecided').length,
|
|
66
|
+
scenarios,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
features.push({ id: f.id, name: f.name, goal: f.goal, roles: f.roles.map((r) => r.name), pick: f.pick, cases, options });
|
|
70
|
+
}
|
|
71
|
+
return { name: project.name, mode: project.mode, features };
|
|
72
|
+
}
|
package/dist/pace.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自动播放的阅读节奏(T-director2,纯函数):演示页、发布站、视频录制、`joplo outline` 与 check 共用这一份。
|
|
3
|
+
* - 阅读:说明 + 解说,中文每秒 8 字、拉丁文字每秒 15 个非空白字符,3–7 秒,再按速度缩放;
|
|
4
|
+
* - 同时至少等到镜头过渡结束(CAMERA_MS)、本步 active 连线上的小点跑完一圈(dotMs),这两项与速度无关。
|
|
5
|
+
* 2026-11-06(D67)从 web 的 runtime/pace.ts 搬到 core,web 原地 re-export,数值与行为不变。
|
|
6
|
+
*/
|
|
7
|
+
export declare const MS_PER_CHAR = 125;
|
|
8
|
+
export declare const LATIN_MS_PER_CHAR: number;
|
|
9
|
+
export declare const MIN_DWELL = 3000;
|
|
10
|
+
export declare const MAX_READ_MS = 7000;
|
|
11
|
+
/** 镜头过渡时长(web 的 camera.tsx 用同一个值)。 */
|
|
12
|
+
export declare const CAMERA_MS = 700;
|
|
13
|
+
/** 流式输出(D56):每个字的时长(1× 速度);整段至少 STREAM_MIN、至多 STREAM_MAX。 */
|
|
14
|
+
export declare const STREAM_MS_PER_CHAR = 35;
|
|
15
|
+
export declare const STREAM_MIN = 600;
|
|
16
|
+
export declare const STREAM_MAX = 9000;
|
|
17
|
+
/** 一段流式文字逐字出现要多久(毫秒,已按速度缩放)。 */
|
|
18
|
+
export declare function streamMs(text: string, speed?: number): number;
|
|
19
|
+
/** “字数”:去掉空白后的字符数(中文一字一个,英文按字母计,标点也算)。 */
|
|
20
|
+
export declare function readChars(...texts: (string | null | undefined)[]): number;
|
|
21
|
+
/** 保留 readChars 的非空白字符口径,宽字符 125ms、拉丁字符 1000/15ms;先截断阅读时间,再应用倍速。 */
|
|
22
|
+
export declare function readingMs(...texts: (string | null | undefined)[]): number;
|
|
23
|
+
/**
|
|
24
|
+
* 这一步提交之后至少停留多久(毫秒)。
|
|
25
|
+
* text:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点);dotMs:本步 active 连线上小点跑一圈的最长时间(没有为 0)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function stepDwell(o: {
|
|
28
|
+
texts: (string | null | undefined)[];
|
|
29
|
+
speed?: number;
|
|
30
|
+
cameraMoved?: boolean;
|
|
31
|
+
dotMs?: number; /** 本步流式输出的文字(D56):等它们出完再加阅读时间。 */
|
|
32
|
+
streams?: string[];
|
|
33
|
+
}): number;
|
package/dist/pace.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自动播放的阅读节奏(T-director2,纯函数):演示页、发布站、视频录制、`joplo outline` 与 check 共用这一份。
|
|
3
|
+
* - 阅读:说明 + 解说,中文每秒 8 字、拉丁文字每秒 15 个非空白字符,3–7 秒,再按速度缩放;
|
|
4
|
+
* - 同时至少等到镜头过渡结束(CAMERA_MS)、本步 active 连线上的小点跑完一圈(dotMs),这两项与速度无关。
|
|
5
|
+
* 2026-11-06(D67)从 web 的 runtime/pace.ts 搬到 core,web 原地 re-export,数值与行为不变。
|
|
6
|
+
*/
|
|
7
|
+
export const MS_PER_CHAR = 125;
|
|
8
|
+
export const LATIN_MS_PER_CHAR = 1000 / 15;
|
|
9
|
+
export const MIN_DWELL = 3000;
|
|
10
|
+
export const MAX_READ_MS = 7000;
|
|
11
|
+
/** 镜头过渡时长(web 的 camera.tsx 用同一个值)。 */
|
|
12
|
+
export const CAMERA_MS = 700;
|
|
13
|
+
/** 流式输出(D56):每个字的时长(1× 速度);整段至少 STREAM_MIN、至多 STREAM_MAX。 */
|
|
14
|
+
export const STREAM_MS_PER_CHAR = 35;
|
|
15
|
+
export const STREAM_MIN = 600;
|
|
16
|
+
export const STREAM_MAX = 9000;
|
|
17
|
+
/** 一段流式文字逐字出现要多久(毫秒,已按速度缩放)。 */
|
|
18
|
+
export function streamMs(text, speed = 1) {
|
|
19
|
+
const n = [...text].length;
|
|
20
|
+
if (!n)
|
|
21
|
+
return 0;
|
|
22
|
+
return Math.round(Math.min(STREAM_MAX, Math.max(STREAM_MIN, n * STREAM_MS_PER_CHAR)) / (speed > 0 ? speed : 1));
|
|
23
|
+
}
|
|
24
|
+
/** 镜头结束后再留一点余量,避免刚停稳就切走。 */
|
|
25
|
+
const SETTLE = 200;
|
|
26
|
+
/** “字数”:去掉空白后的字符数(中文一字一个,英文按字母计,标点也算)。 */
|
|
27
|
+
export function readChars(...texts) {
|
|
28
|
+
let n = 0;
|
|
29
|
+
for (const t of texts)
|
|
30
|
+
if (t)
|
|
31
|
+
for (const ch of t)
|
|
32
|
+
if (!/\s/.test(ch))
|
|
33
|
+
n++;
|
|
34
|
+
return n;
|
|
35
|
+
}
|
|
36
|
+
/** 保留 readChars 的非空白字符口径,宽字符 125ms、拉丁字符 1000/15ms;先截断阅读时间,再应用倍速。 */
|
|
37
|
+
export function readingMs(...texts) {
|
|
38
|
+
let ms = 0;
|
|
39
|
+
for (const t of texts)
|
|
40
|
+
if (t)
|
|
41
|
+
for (const ch of t) {
|
|
42
|
+
if (/\s/.test(ch))
|
|
43
|
+
continue;
|
|
44
|
+
ms += (ch.codePointAt(0) ?? 0) > 0x2e80 ? MS_PER_CHAR : LATIN_MS_PER_CHAR;
|
|
45
|
+
}
|
|
46
|
+
return Math.min(MAX_READ_MS, Math.max(MIN_DWELL, ms));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 这一步提交之后至少停留多久(毫秒)。
|
|
50
|
+
* text:说明与解说;cameraMoved:这一步镜头有变化(切层或换焦点);dotMs:本步 active 连线上小点跑一圈的最长时间(没有为 0)。
|
|
51
|
+
*/
|
|
52
|
+
export function stepDwell(o) {
|
|
53
|
+
const speed = o.speed && o.speed > 0 ? o.speed : 1;
|
|
54
|
+
const read = readingMs(...o.texts) / speed;
|
|
55
|
+
const cam = o.cameraMoved ? CAMERA_MS + SETTLE : 0;
|
|
56
|
+
const dots = o.dotMs && o.dotMs > 0 ? o.dotMs + SETTLE : 0;
|
|
57
|
+
// 流式输出:先等最长的一段出完,再留出读完它的时间(按出完之后再读一遍的一半计)
|
|
58
|
+
const longest = Math.max(0, ...(o.streams ?? []).map((t) => streamMs(t, speed)));
|
|
59
|
+
const streamed = longest ? longest + Math.max(MIN_DWELL / speed, read / 2) : 0;
|
|
60
|
+
return Math.round(Math.max(read, cam, dots, streamed));
|
|
61
|
+
}
|
package/dist/player.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ export type DiagramStates = Record<string, {
|
|
|
170
170
|
* - trace.fail:路径上的连线与终点节点 error(起点等其余节点 active),保持到之后又被 trace 成功;
|
|
171
171
|
* - trace.skip:路径上的节点与连线 dim(保持到之后又被 trace);
|
|
172
172
|
* - 从未涉及的:idle(不在结果里)。
|
|
173
|
+
* - 分组(D69):路径经过的节点所在的各级分组同样 active → ok;trace.fail 时终点所在的最内层分组 error;trace.skip 不改分组。
|
|
173
174
|
* 节点或连线上显式写的 state 优先于推算结果(由渲染器处理)。
|
|
174
175
|
*/
|
|
175
176
|
export declare function diagramStateAt(project: Project, scenarioId: string | null | undefined, position: number): DiagramStates;
|
package/dist/player.js
CHANGED
|
@@ -196,10 +196,11 @@ export function isNodeVisible(scene, nodeId, state, width = sceneWidth(scene)) {
|
|
|
196
196
|
*/
|
|
197
197
|
export function choicesOf(node, state) {
|
|
198
198
|
const text = (n) => (n.type === '#text' ? String(resolveValue(n.props?.text, state) ?? '') : (n.children ?? []).map(text).join(''));
|
|
199
|
-
|
|
199
|
+
/** 按文档顺序取指定类型的子孙(Radio 与 Radio.Card 混写时保持书写顺序)。 */
|
|
200
|
+
const desc = (types) => {
|
|
200
201
|
const out = [];
|
|
201
202
|
walkNodes(node, (n) => {
|
|
202
|
-
if (n !== node && n.type
|
|
203
|
+
if (n !== node && types.includes(n.type))
|
|
203
204
|
out.push(n);
|
|
204
205
|
});
|
|
205
206
|
return out;
|
|
@@ -208,15 +209,16 @@ export function choicesOf(node, state) {
|
|
|
208
209
|
switch (node.type) {
|
|
209
210
|
case 'Select':
|
|
210
211
|
case 'MultiSelect':
|
|
211
|
-
case 'SegmentedControl':
|
|
212
|
+
case 'SegmentedControl':
|
|
213
|
+
case 'TabBar': {
|
|
212
214
|
const c = choicesFromData(resolveValue(p.data, state));
|
|
213
215
|
return c.length ? c : null;
|
|
214
216
|
}
|
|
215
217
|
case 'Radio.Group':
|
|
216
218
|
case 'Tabs':
|
|
217
219
|
case 'Accordion': {
|
|
218
|
-
const
|
|
219
|
-
const c = desc(
|
|
220
|
+
const items = node.type === 'Radio.Group' ? ['Radio', 'Radio.Card'] : node.type === 'Tabs' ? ['Tabs.Tab'] : ['Accordion.Item'];
|
|
221
|
+
const c = desc(items)
|
|
220
222
|
.filter((n) => n.props?.value !== undefined)
|
|
221
223
|
.map((n) => {
|
|
222
224
|
const value = String(resolveValue(n.props.value, state));
|
|
@@ -382,7 +384,8 @@ export function applyStep(project, scenario, state) {
|
|
|
382
384
|
break;
|
|
383
385
|
case 'navigate': {
|
|
384
386
|
const target = project.scenes[e.sceneId];
|
|
385
|
-
|
|
387
|
+
// 发布 IR 只有发布视图(`@/路径`,optionId 为 null);dev / review 里跳转目标必须属于同一方案(D68 修复:以前发布站一跳转就报错)
|
|
388
|
+
if (!target || (target.optionId !== scenario.optionId && !(project.mode === 'publish' && target.optionId === null)))
|
|
386
389
|
throw new PlaybackError(`Step ${step.id} navigates to a stage that is missing or outside this option: ${e.sceneId}`, {
|
|
387
390
|
severity: 'error',
|
|
388
391
|
code: 'MISSING_SCENE',
|
|
@@ -550,6 +553,7 @@ export function stepTouchesLayer(project, scenarioId, index, layer) {
|
|
|
550
553
|
* - trace.fail:路径上的连线与终点节点 error(起点等其余节点 active),保持到之后又被 trace 成功;
|
|
551
554
|
* - trace.skip:路径上的节点与连线 dim(保持到之后又被 trace);
|
|
552
555
|
* - 从未涉及的:idle(不在结果里)。
|
|
556
|
+
* - 分组(D69):路径经过的节点所在的各级分组同样 active → ok;trace.fail 时终点所在的最内层分组 error;trace.skip 不改分组。
|
|
553
557
|
* 节点或连线上显式写的 state 优先于推算结果(由渲染器处理)。
|
|
554
558
|
*/
|
|
555
559
|
export function diagramStateAt(project, scenarioId, position) {
|
|
@@ -574,12 +578,18 @@ export function diagramStateAt(project, scenarioId, position) {
|
|
|
574
578
|
}
|
|
575
579
|
else if (t.mode === 'fail') {
|
|
576
580
|
const last = t.nodes[t.nodes.length - 1];
|
|
581
|
+
for (const id of t.groups ?? [])
|
|
582
|
+
out[id] = { state: 'active' };
|
|
583
|
+
for (const id of t.errorGroups ?? [])
|
|
584
|
+
out[id] = { state: 'error' };
|
|
577
585
|
for (const id of t.nodes)
|
|
578
586
|
out[id] = { state: id === last ? 'error' : 'active' };
|
|
579
587
|
for (const e of t.edges)
|
|
580
588
|
out[e.id] = { state: 'error' };
|
|
581
589
|
}
|
|
582
590
|
else {
|
|
591
|
+
for (const id of t.groups ?? [])
|
|
592
|
+
out[id] = { state: 'active' };
|
|
583
593
|
for (const id of t.nodes)
|
|
584
594
|
out[id] = { state: 'active' };
|
|
585
595
|
for (const e of t.edges)
|
package/dist/schema.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { COMPONENT_TYPES } from './catalog.js';
|
|
9
|
+
import type { DiagramLayout as DiagramLayoutT } from './diagram/model.js';
|
|
9
10
|
/** 层级标签的预设图标(标签压窄时靠它认出是哪一层)。不写时:手机视口 mobile,其余 window。 */
|
|
10
11
|
export declare const LAYER_ICONS: readonly ["window", "browser", "mobile", "desktop", "terminal", "chat", "agent", "server", "data", "email", "doc", "flow"];
|
|
11
12
|
export type LayerIcon = (typeof LAYER_ICONS)[number];
|
|
@@ -38,6 +39,7 @@ export type Condition = {
|
|
|
38
39
|
not: Condition;
|
|
39
40
|
};
|
|
40
41
|
export declare const Condition: z.ZodType<Condition>;
|
|
42
|
+
export declare const DiagramLayoutSchema: z.ZodType<DiagramLayoutT>;
|
|
41
43
|
export type SceneNode = {
|
|
42
44
|
/** 可操作元素必须由作者给出;其余由编译器按位置生成(以 `_` 开头)。 */
|
|
43
45
|
id: string;
|
|
@@ -50,8 +52,12 @@ export type SceneNode = {
|
|
|
50
52
|
disabledReason?: string;
|
|
51
53
|
unmodeled?: boolean;
|
|
52
54
|
note?: string;
|
|
55
|
+
/** 敏感信息(D70):内容模糊显示;可以是条件(为真时模糊)。演示内容,发布站保留。 */
|
|
56
|
+
redact?: boolean | Condition;
|
|
53
57
|
/** 来自哪个功能方案(堆叠到路径上的元素);页面和布局自身的元素没有此字段。 */
|
|
54
58
|
from?: string;
|
|
59
|
+
/** 图表根节点(Diagram / StateMachine / Sequence)的布局,编译期算好(D69);其他节点没有。 */
|
|
60
|
+
layout?: DiagramLayoutT;
|
|
55
61
|
source?: string;
|
|
56
62
|
};
|
|
57
63
|
export declare const SceneNode: z.ZodType<SceneNode>;
|
|
@@ -145,6 +151,9 @@ export declare const Trace: z.ZodObject<{
|
|
|
145
151
|
id: z.ZodString;
|
|
146
152
|
reverse: z.ZodDefault<z.ZodBoolean>;
|
|
147
153
|
}, z.core.$strict>>;
|
|
154
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
155
|
+
errorGroups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
156
|
+
targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
148
157
|
}, z.core.$strict>;
|
|
149
158
|
/** 镜头(D43):这一步在某个层级里对准哪些元素;targets 为空 = 这一层的整体。 */
|
|
150
159
|
export declare const Shot: z.ZodObject<{
|
|
@@ -166,6 +175,31 @@ export declare const Mark: z.ZodObject<{
|
|
|
166
175
|
}>;
|
|
167
176
|
note: z.ZodOptional<z.ZodString>;
|
|
168
177
|
}, z.core.$strict>;
|
|
178
|
+
/**
|
|
179
|
+
* 焦点提示(D70):这一步的强调形式,只作用于这一步。spotlight = 只照亮这些元素、其余压暗;highlight = 强调框并脉冲一次;
|
|
180
|
+
* number = 按 targets 的顺序标 1、2、3。都不推近镜头(目标不在当前镜头里时,编译器给这一步补一个整层镜头)。
|
|
181
|
+
*/
|
|
182
|
+
export declare const CUE_KINDS: readonly ["spotlight", "highlight", "number"];
|
|
183
|
+
export declare const Cue: z.ZodObject<{
|
|
184
|
+
kind: z.ZodEnum<{
|
|
185
|
+
number: "number";
|
|
186
|
+
spotlight: "spotlight";
|
|
187
|
+
highlight: "highlight";
|
|
188
|
+
}>;
|
|
189
|
+
targets: z.ZodArray<z.ZodString>;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
/** 标注气泡(D70):指向元素的一句话;side 不写时由渲染器选放得下的一侧。 */
|
|
192
|
+
export declare const CALLOUT_SIDES: readonly ["top", "right", "bottom", "left"];
|
|
193
|
+
export declare const Callout: z.ZodObject<{
|
|
194
|
+
target: z.ZodString;
|
|
195
|
+
text: z.ZodString;
|
|
196
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
197
|
+
top: "top";
|
|
198
|
+
right: "right";
|
|
199
|
+
bottom: "bottom";
|
|
200
|
+
left: "left";
|
|
201
|
+
}>>;
|
|
202
|
+
}, z.core.$strict>;
|
|
169
203
|
export declare const Step: z.ZodObject<{
|
|
170
204
|
id: z.ZodString;
|
|
171
205
|
kind: z.ZodEnum<{
|
|
@@ -270,6 +304,9 @@ export declare const Step: z.ZodObject<{
|
|
|
270
304
|
id: z.ZodString;
|
|
271
305
|
reverse: z.ZodDefault<z.ZodBoolean>;
|
|
272
306
|
}, z.core.$strict>>;
|
|
307
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
308
|
+
errorGroups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
309
|
+
targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
273
310
|
}, z.core.$strict>>>;
|
|
274
311
|
forks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
275
312
|
label: z.ZodString;
|
|
@@ -286,6 +323,25 @@ export declare const Step: z.ZodObject<{
|
|
|
286
323
|
}>;
|
|
287
324
|
note: z.ZodOptional<z.ZodString>;
|
|
288
325
|
}, z.core.$strict>>>;
|
|
326
|
+
cues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
327
|
+
kind: z.ZodEnum<{
|
|
328
|
+
number: "number";
|
|
329
|
+
spotlight: "spotlight";
|
|
330
|
+
highlight: "highlight";
|
|
331
|
+
}>;
|
|
332
|
+
targets: z.ZodArray<z.ZodString>;
|
|
333
|
+
}, z.core.$strict>>>;
|
|
334
|
+
callouts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
335
|
+
target: z.ZodString;
|
|
336
|
+
text: z.ZodString;
|
|
337
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
338
|
+
top: "top";
|
|
339
|
+
right: "right";
|
|
340
|
+
bottom: "bottom";
|
|
341
|
+
left: "left";
|
|
342
|
+
}>>;
|
|
343
|
+
}, z.core.$strict>>>;
|
|
344
|
+
hold: z.ZodOptional<z.ZodNumber>;
|
|
289
345
|
source: z.ZodOptional<z.ZodString>;
|
|
290
346
|
}, z.core.$strict>;
|
|
291
347
|
export declare const Scenario: z.ZodObject<{
|
|
@@ -414,6 +470,9 @@ export declare const Scenario: z.ZodObject<{
|
|
|
414
470
|
id: z.ZodString;
|
|
415
471
|
reverse: z.ZodDefault<z.ZodBoolean>;
|
|
416
472
|
}, z.core.$strict>>;
|
|
473
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
474
|
+
errorGroups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
475
|
+
targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
417
476
|
}, z.core.$strict>>>;
|
|
418
477
|
forks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
419
478
|
label: z.ZodString;
|
|
@@ -430,6 +489,25 @@ export declare const Scenario: z.ZodObject<{
|
|
|
430
489
|
}>;
|
|
431
490
|
note: z.ZodOptional<z.ZodString>;
|
|
432
491
|
}, z.core.$strict>>>;
|
|
492
|
+
cues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
493
|
+
kind: z.ZodEnum<{
|
|
494
|
+
number: "number";
|
|
495
|
+
spotlight: "spotlight";
|
|
496
|
+
highlight: "highlight";
|
|
497
|
+
}>;
|
|
498
|
+
targets: z.ZodArray<z.ZodString>;
|
|
499
|
+
}, z.core.$strict>>>;
|
|
500
|
+
callouts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
501
|
+
target: z.ZodString;
|
|
502
|
+
text: z.ZodString;
|
|
503
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
504
|
+
top: "top";
|
|
505
|
+
right: "right";
|
|
506
|
+
bottom: "bottom";
|
|
507
|
+
left: "left";
|
|
508
|
+
}>>;
|
|
509
|
+
}, z.core.$strict>>>;
|
|
510
|
+
hold: z.ZodOptional<z.ZodNumber>;
|
|
433
511
|
source: z.ZodOptional<z.ZodString>;
|
|
434
512
|
}, z.core.$strict>>>;
|
|
435
513
|
expected: z.ZodDefault<z.ZodString>;
|
|
@@ -590,6 +668,7 @@ export declare const Project: z.ZodObject<{
|
|
|
590
668
|
name: z.ZodString;
|
|
591
669
|
description: z.ZodDefault<z.ZodString>;
|
|
592
670
|
theme: z.ZodDefault<z.ZodString>;
|
|
671
|
+
autoFocus: z.ZodOptional<z.ZodBoolean>;
|
|
593
672
|
themes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
594
673
|
mode: z.ZodEnum<{
|
|
595
674
|
publish: "publish";
|
|
@@ -852,6 +931,9 @@ export declare const Project: z.ZodObject<{
|
|
|
852
931
|
id: z.ZodString;
|
|
853
932
|
reverse: z.ZodDefault<z.ZodBoolean>;
|
|
854
933
|
}, z.core.$strict>>;
|
|
934
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
935
|
+
errorGroups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
936
|
+
targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
855
937
|
}, z.core.$strict>>>;
|
|
856
938
|
forks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
857
939
|
label: z.ZodString;
|
|
@@ -868,6 +950,25 @@ export declare const Project: z.ZodObject<{
|
|
|
868
950
|
}>;
|
|
869
951
|
note: z.ZodOptional<z.ZodString>;
|
|
870
952
|
}, z.core.$strict>>>;
|
|
953
|
+
cues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
954
|
+
kind: z.ZodEnum<{
|
|
955
|
+
number: "number";
|
|
956
|
+
spotlight: "spotlight";
|
|
957
|
+
highlight: "highlight";
|
|
958
|
+
}>;
|
|
959
|
+
targets: z.ZodArray<z.ZodString>;
|
|
960
|
+
}, z.core.$strict>>>;
|
|
961
|
+
callouts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
962
|
+
target: z.ZodString;
|
|
963
|
+
text: z.ZodString;
|
|
964
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
965
|
+
top: "top";
|
|
966
|
+
right: "right";
|
|
967
|
+
bottom: "bottom";
|
|
968
|
+
left: "left";
|
|
969
|
+
}>>;
|
|
970
|
+
}, z.core.$strict>>>;
|
|
971
|
+
hold: z.ZodOptional<z.ZodNumber>;
|
|
871
972
|
source: z.ZodOptional<z.ZodString>;
|
|
872
973
|
}, z.core.$strict>>>;
|
|
873
974
|
expected: z.ZodDefault<z.ZodString>;
|
|
@@ -904,3 +1005,5 @@ export type Trace = z.infer<typeof Trace>;
|
|
|
904
1005
|
export type Shot = z.infer<typeof Shot>;
|
|
905
1006
|
export type Fork = z.infer<typeof Fork>;
|
|
906
1007
|
export type Mark = z.infer<typeof Mark>;
|
|
1008
|
+
export type Cue = z.infer<typeof Cue>;
|
|
1009
|
+
export type Callout = z.infer<typeof Callout>;
|
package/dist/schema.js
CHANGED
|
@@ -29,6 +29,37 @@ export const Condition = z.lazy(() => z.union([
|
|
|
29
29
|
z.strictObject({ or: z.array(Condition) }),
|
|
30
30
|
z.strictObject({ not: Condition }),
|
|
31
31
|
]));
|
|
32
|
+
// ---------- 图表布局(D69):编译期算好,渲染器只读 ----------
|
|
33
|
+
const Num = z.number().finite();
|
|
34
|
+
const BoxS = z.strictObject({ x: Num, y: Num, w: Num, h: Num });
|
|
35
|
+
const PointS = z.strictObject({ x: Num, y: Num });
|
|
36
|
+
const Boxes = z.record(z.string(), BoxS);
|
|
37
|
+
export const DiagramLayoutSchema = z.union([
|
|
38
|
+
z.strictObject({
|
|
39
|
+
kind: z.literal('graph'),
|
|
40
|
+
engine: z.enum(['elk', 'grid']),
|
|
41
|
+
direction: z.enum(['right', 'down']).optional(),
|
|
42
|
+
width: Num,
|
|
43
|
+
height: Num,
|
|
44
|
+
nodes: Boxes,
|
|
45
|
+
groups: Boxes,
|
|
46
|
+
titles: Boxes,
|
|
47
|
+
edges: z.record(z.string(), z.strictObject({ points: z.array(PointS), label: BoxS.nullable() })),
|
|
48
|
+
starts: Boxes.optional(),
|
|
49
|
+
}),
|
|
50
|
+
z.strictObject({
|
|
51
|
+
kind: z.literal('sequence'),
|
|
52
|
+
width: Num,
|
|
53
|
+
height: Num,
|
|
54
|
+
actors: Boxes,
|
|
55
|
+
lifelines: z.record(z.string(), z.strictObject({ x: Num, y1: Num, y2: Num })),
|
|
56
|
+
messages: z.record(z.string(), z.strictObject({ points: z.array(PointS), label: BoxS.nullable(), n: z.number().int(), self: z.boolean() })),
|
|
57
|
+
groups: Boxes,
|
|
58
|
+
titles: Boxes,
|
|
59
|
+
blocks: Boxes,
|
|
60
|
+
blockTitles: Boxes,
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
32
63
|
export const SceneNode = z.lazy(() => z.strictObject({
|
|
33
64
|
id: z.string().min(1),
|
|
34
65
|
type: z.enum(COMPONENT_TYPES),
|
|
@@ -39,7 +70,9 @@ export const SceneNode = z.lazy(() => z.strictObject({
|
|
|
39
70
|
disabledReason: z.string().optional(),
|
|
40
71
|
unmodeled: z.boolean().optional(),
|
|
41
72
|
note: z.string().optional(),
|
|
73
|
+
redact: z.union([z.boolean(), Condition]).optional(),
|
|
42
74
|
from: z.string().optional(),
|
|
75
|
+
layout: DiagramLayoutSchema.optional(),
|
|
43
76
|
source: Source,
|
|
44
77
|
}));
|
|
45
78
|
/** 一个画面 = 某个方案上下文中的一个路径:布局 + 页面 + 堆叠进来的功能元素。 */
|
|
@@ -83,11 +116,25 @@ export const Trace = z.strictObject({
|
|
|
83
116
|
mode: z.enum(['ok', 'fail', 'skip']),
|
|
84
117
|
nodes: z.array(z.string().min(1)),
|
|
85
118
|
edges: z.array(z.strictObject({ id: z.string().min(1), reverse: z.boolean().default(false) })),
|
|
119
|
+
/** 路径经过的分组(节点所在的各级分组,D69):fail 时 errorGroups 是终点所在的分组。没有分组时省略(IR 与旧版相同)。 */
|
|
120
|
+
groups: z.array(z.string().min(1)).optional(),
|
|
121
|
+
errorGroups: z.array(z.string().min(1)).optional(),
|
|
122
|
+
/** 镜头目标:架构图 / 状态机是路径上的节点,时序图是消息(一行一行的)。旧 IR 没有,按 nodes 处理。 */
|
|
123
|
+
targets: z.array(z.string().min(1)).optional(),
|
|
86
124
|
});
|
|
87
125
|
/** 镜头(D43):这一步在某个层级里对准哪些元素;targets 为空 = 这一层的整体。 */
|
|
88
126
|
export const Shot = z.strictObject({ layer: z.string().min(1), targets: z.array(z.string().min(1)) });
|
|
89
127
|
export const Fork = z.strictObject({ label: z.string().min(1), scenarioId: Qid, at: z.number().int().nonnegative() });
|
|
90
128
|
export const Mark = z.strictObject({ target: z.string().min(1), kind: z.enum(['circle', 'underline', 'box', 'arrow']), note: z.string().min(1).optional() });
|
|
129
|
+
/**
|
|
130
|
+
* 焦点提示(D70):这一步的强调形式,只作用于这一步。spotlight = 只照亮这些元素、其余压暗;highlight = 强调框并脉冲一次;
|
|
131
|
+
* number = 按 targets 的顺序标 1、2、3。都不推近镜头(目标不在当前镜头里时,编译器给这一步补一个整层镜头)。
|
|
132
|
+
*/
|
|
133
|
+
export const CUE_KINDS = ['spotlight', 'highlight', 'number'];
|
|
134
|
+
export const Cue = z.strictObject({ kind: z.enum(CUE_KINDS), targets: z.array(z.string().min(1)).min(1) });
|
|
135
|
+
/** 标注气泡(D70):指向元素的一句话;side 不写时由渲染器选放得下的一侧。 */
|
|
136
|
+
export const CALLOUT_SIDES = ['top', 'right', 'bottom', 'left'];
|
|
137
|
+
export const Callout = z.strictObject({ target: z.string().min(1), text: z.string().min(1), side: z.enum(CALLOUT_SIDES).optional() });
|
|
91
138
|
export const Step = z.strictObject({
|
|
92
139
|
id: Qid,
|
|
93
140
|
kind: z.enum(['user', 'system', 'card']),
|
|
@@ -114,6 +161,12 @@ export const Step = z.strictObject({
|
|
|
114
161
|
forks: z.array(Fork).default([]),
|
|
115
162
|
/** 本步标注,不累积,不参与状态转换。 */
|
|
116
163
|
marks: z.array(Mark).default([]),
|
|
164
|
+
/** 本步的焦点提示(D70,来自 spotlight / highlight / numbered);没有时省略。演示内容,发布站保留。 */
|
|
165
|
+
cues: z.array(Cue).optional(),
|
|
166
|
+
/** 本步的标注气泡(D70,来自 callout);没有时省略。 */
|
|
167
|
+
callouts: z.array(Callout).optional(),
|
|
168
|
+
/** 自动播放时这一步至少停留的毫秒数(D70,来自 hold;未按速度缩放);没有时省略。 */
|
|
169
|
+
hold: z.number().int().positive().max(30_000).optional(),
|
|
117
170
|
source: Source,
|
|
118
171
|
});
|
|
119
172
|
export const Scenario = z.strictObject({
|
|
@@ -222,6 +275,8 @@ export const Project = z.strictObject({
|
|
|
222
275
|
description: z.string().default(''),
|
|
223
276
|
/** 默认主题名(D51):内置主题或 themes 里的作者主题。 */
|
|
224
277
|
theme: z.string().min(1).default('sketch'),
|
|
278
|
+
/** 默认焦点行为(D70):缺省 = 开启;false = 只按作者写的镜头与提示呈现(config({ autoFocus: false }))。发布站保留。 */
|
|
279
|
+
autoFocus: z.boolean().optional(),
|
|
225
280
|
/** 作者主题(D51):主题名 → CSS 原文(themes/<name>.css);渲染时自动限定在舞台范围内。发布站同样打包。 */
|
|
226
281
|
themes: z.record(z.string(), z.string()).default({}),
|
|
227
282
|
/** dev = 含全部方案(本地看板);publish = 只含选定方案,且去掉创作侧信息(D33);review = 评审版:全部方案,同样去掉创作侧信息(D63)。 */
|
package/dist/validate.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { orderedFeatures } from "./features.js";
|
|
2
2
|
import { Project } from "./schema.js";
|
|
3
|
-
import { CAPTION_MAX, EXPLAIN_MAX, INTERACTIVE_TYPES, captionLength } from "./catalog.js";
|
|
3
|
+
import { CAPTION_MAX, CARD_POINTS_MAX, DESCRIPTION_MAX, EXPLAIN_MAX, INTERACTIVE_TYPES, SCENARIO_MS_MAX, captionLength } from "./catalog.js";
|
|
4
|
+
import { scenarioEstimateMs } from "./outline.js";
|
|
4
5
|
import { walkNodes, findNode, replay } from "./player.js";
|
|
5
6
|
import { JoploError } from "./result.js";
|
|
6
7
|
import { schemaDiagnostics } from "./schema-issues.js";
|
|
8
|
+
import { focusReplayDiagnostics, focusStructureDiagnostics } from "./focus-check.js";
|
|
7
9
|
/** IR v2 的确定性校验。源位置缺失(例如手工构造/发布 IR)时回退到配置文件。 */
|
|
8
10
|
export function validate(project, opts = { mode: 'all' }) {
|
|
9
11
|
if (!['structure', 'replay', 'all'].includes(opts.mode))
|
|
@@ -80,9 +82,16 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
80
82
|
if (['not_applicable', 'excluded'].includes(c.status) && !c.reason?.trim())
|
|
81
83
|
emit('warning', 'COVERAGE_WITHOUT_REASON', `Not applicable or Excluded requires a reason: ${id}`, o.source, r);
|
|
82
84
|
if (c.status === 'missing')
|
|
83
|
-
emit('warning', 'CASE_NOT_COVERED', `Case is not yet Covered: ${id} ${p.cases[id]?.title ?? ''}`, o.source, r);
|
|
85
|
+
emit('warning', 'CASE_NOT_COVERED', `Case is not yet Covered: ${id} ${p.cases[id]?.title ?? ''}${caseHint(p.cases[id])}`, o.source, r);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
88
|
+
// 只有顺利路径(D67,Joplo 要解决的“看不全”):功能只声明了 main 情况,而且参与的方案里每个场景都成功
|
|
89
|
+
for (const f of orderedFeatures(p).filter(f => !opts.optionId || f.optionIds.includes(opts.optionId))) {
|
|
90
|
+
const own = scenarios.filter(s => p.options[s.optionId]?.featureId === f.id);
|
|
91
|
+
const edge = f.caseIds.some(id => p.cases[id] && p.cases[id].dimension !== 'main');
|
|
92
|
+
if (p.mode === 'dev' && own.length && !edge && own.every(s => s.mock.outcome === 'success'))
|
|
93
|
+
emit('info', 'HAPPY_PATH_ONLY', `Feature "${f.name}" only shows the happy path: every case is a main-flow case and every scenario succeeds. Ask the user about input, permission, async, and lifecycle cases (npx joplo skill cases), then add at least one error-and-recovery scenario`, f.source, { kind: 'feature', id: f.id });
|
|
94
|
+
}
|
|
86
95
|
for (const r of Object.values(p.rules).filter(r => included(r.optionId) && (!opts.optionId || r.featureId === p.options[opts.optionId]?.featureId))) {
|
|
87
96
|
ref(p.features[r.featureId], `Rule feature does not exist: ${r.featureId}`, r, 'rule');
|
|
88
97
|
if (r.optionId)
|
|
@@ -138,7 +147,8 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
138
147
|
if (ids.has(n.id))
|
|
139
148
|
emit('error', 'DUPLICATE_ELEMENT', `Duplicate element ID in stage: ${n.id}`, n.source, r, 'reference');
|
|
140
149
|
ids.add(n.id);
|
|
141
|
-
|
|
150
|
+
// Indicator 的 disabled 只是隐藏角标(Mantine 的含义),不是“不能用”,不要求原因
|
|
151
|
+
if (n.disabled !== undefined && n.disabled !== false && !n.disabledReason?.trim() && n.type !== 'Indicator')
|
|
142
152
|
emit('warning', 'DISABLED_WITHOUT_REASON', `Disabled element has no reason: ${n.id}. Add disabledReason="…" (for example disabledReason="Only admins can invite"), or bind it to state like disabled: disabledReason={$.ui.sendHint}`, n.source, r);
|
|
143
153
|
if (INTERACTIVE_TYPES.has(n.type) && !bound.has(identity(n)) && !(n.disabled === true && n.disabledReason?.trim()) && !n.unmodeled)
|
|
144
154
|
emit('warning', 'UNBOUND_INTERACTIVE', `Interactive element has no demo step: ${n.id}; bind a step, disable with a reason, or mark unmodeled`, n.source, r);
|
|
@@ -151,8 +161,16 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
151
161
|
ref(p.scenes[sc.initial.sceneId]?.optionId === sc.optionId, `Scenario initial stage is missing or belongs to another option: ${sc.initial.sceneId}`, sc, 'scenario');
|
|
152
162
|
for (const id of sc.caseIds)
|
|
153
163
|
ref(p.cases[id]?.featureId === o?.featureId, `Scenario case is missing or belongs to another feature: ${id}`, sc, 'scenario');
|
|
164
|
+
const sr = { kind: 'scenario', id: sc.id, optionId: sc.optionId };
|
|
154
165
|
if (!sc.steps.length)
|
|
155
|
-
emit('info', 'EMPTY_SCENARIO', `Scenario has no steps: ${sc.name}`, sc.source,
|
|
166
|
+
emit('info', 'EMPTY_SCENARIO', `Scenario has no steps: ${sc.name}`, sc.source, sr);
|
|
167
|
+
// 叙事(D67):封面说明 30 字以内(D61);一个场景讲一件事,太长时拆开
|
|
168
|
+
const dl = captionLength(sc.description);
|
|
169
|
+
if (dl > DESCRIPTION_MAX)
|
|
170
|
+
emit('warning', 'DESCRIPTION_TOO_LONG', `flow description (the scenario cover text) is ${dl} units (recommended maximum: ${DESCRIPTION_MAX}; CJK characters count as 1 each, all others as 0.5): "${sc.description}". Say in one sentence what this scenario shows; the cover clips longer text`, sc.source, sr);
|
|
171
|
+
const ms = scenarioEstimateMs(sc);
|
|
172
|
+
if (ms > SCENARIO_MS_MAX)
|
|
173
|
+
emit('info', 'SCENARIO_TOO_LONG', `Scenario "${sc.name}" plays about ${Math.round(ms / 1000)} s at 1× (${sc.steps.length} steps; recommended maximum: ${SCENARIO_MS_MAX / 1000} s). One scenario tells one thing: split it into scenarios (for example the happy path and each recovery), or branch with fork(); run npx joplo outline to see the pacing`, sc.source, sr);
|
|
156
174
|
for (const st of sc.steps) {
|
|
157
175
|
const value = { ...st, optionId: sc.optionId };
|
|
158
176
|
ref(!stepIds.has(st.id), `Duplicate step ID: ${st.id}`, value, 'step');
|
|
@@ -170,6 +188,18 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
170
188
|
const cl = captionLength(st.caption);
|
|
171
189
|
if (cl > CAPTION_MAX)
|
|
172
190
|
emit('warning', 'CAPTION_TOO_LONG', `Caption length is ${cl} units (recommended maximum: ${CAPTION_MAX}; CJK characters count as 1 each, all others as 0.5; whitespace is not counted): "${st.caption}". Keep the caption to one point; move details to a separate explanation layer, for example layers: { why: layer('Design rationale', <Why />) }, then use shot('why_xxx') in this step to present it`, at, r);
|
|
191
|
+
if (st.action.type === 'card') {
|
|
192
|
+
const sub = st.action.sub ? captionLength(st.action.sub) : 0;
|
|
193
|
+
const points = st.action.points ?? [];
|
|
194
|
+
const longPoint = points.map(captionLength).find((n) => n > CAPTION_MAX);
|
|
195
|
+
const issues = [
|
|
196
|
+
...(sub > EXPLAIN_MAX ? [`sub is ${sub} units (maximum ${EXPLAIN_MAX})`] : []),
|
|
197
|
+
...(longPoint !== undefined ? [`a point is ${longPoint} units (maximum ${CAPTION_MAX})`] : []),
|
|
198
|
+
...(points.length > CARD_POINTS_MAX ? [`${points.length} points (maximum ${CARD_POINTS_MAX})`] : []),
|
|
199
|
+
];
|
|
200
|
+
if (issues.length)
|
|
201
|
+
emit('info', 'CARD_TEXT_TOO_LONG', `Transition card "${st.action.title}": ${issues.join('; ')}. A card is read in a few seconds: keep one sentence and at most ${CARD_POINTS_MAX} short points, and move details into the scenario steps`, at, r);
|
|
202
|
+
}
|
|
173
203
|
if (st.explain) {
|
|
174
204
|
const el = captionLength(st.explain);
|
|
175
205
|
if (el > EXPLAIN_MAX)
|
|
@@ -177,6 +207,7 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
177
207
|
}
|
|
178
208
|
}
|
|
179
209
|
}
|
|
210
|
+
focusStructureDiagnostics(p, scenarios, emit); // 焦点提示(D70)
|
|
180
211
|
for (const o of options)
|
|
181
212
|
if (!diagnostics.some(d => d.severity === 'error' && (!d.ref?.optionId || d.ref.optionId === o.id)))
|
|
182
213
|
verification[o.id] = 'structure_ok';
|
|
@@ -185,6 +216,8 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
185
216
|
const failed = new Set();
|
|
186
217
|
for (const sc of scenarios) {
|
|
187
218
|
const result = replay(p, sc.id);
|
|
219
|
+
if (!result.diagnostics.length)
|
|
220
|
+
focusReplayDiagnostics(p, sc, emit); // 焦点提示(D70)
|
|
188
221
|
for (const d of result.diagnostics) {
|
|
189
222
|
failed.add(sc.optionId);
|
|
190
223
|
const step = sc.steps.find(st => st.id === (d.ref?.stepId ?? d.ref?.id)) ?? (result.finalState ? sc.steps[result.reached] : undefined);
|
|
@@ -197,3 +230,10 @@ export function validate(project, opts = { mode: 'all' }) {
|
|
|
197
230
|
}
|
|
198
231
|
return report();
|
|
199
232
|
}
|
|
233
|
+
/** CASE_NOT_COVERED 的补充:高优先级与期望结果(PM 的 Then),帮 Agent 知道该补什么场景。 */
|
|
234
|
+
function caseHint(c) {
|
|
235
|
+
if (!c)
|
|
236
|
+
return '';
|
|
237
|
+
const parts = [...(c.priority === 'high' ? ['high priority'] : []), ...(c.expected.trim() ? [`expected: ${c.expected.trim()}`] : [])];
|
|
238
|
+
return parts.length ? ` (${parts.join('; ')})` : '';
|
|
239
|
+
}
|