@yutaura/live-spec 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +12 -2
- package/dist/cli.js +49 -10
- package/dist/diff.d.ts +92 -2
- package/dist/diff.js +101 -64
- package/dist/ensure-scope.d.ts +9 -0
- package/dist/ensure-scope.js +81 -0
- package/dist/ensure.d.ts +4 -0
- package/dist/ensure.js +27 -2
- package/dist/explore.d.ts +20 -1
- package/dist/explore.js +34 -12
- package/dist/generate.d.ts +6 -0
- package/dist/generate.js +16 -4
- package/dist/load.d.ts +7 -1
- package/dist/load.js +5 -0
- package/dist/model.d.ts +85 -0
- package/dist/model.js +34 -0
- package/dist/mutation.d.ts +3 -0
- package/dist/mutation.js +51 -0
- package/dist/omission.d.ts +6 -0
- package/dist/omission.js +177 -0
- package/dist/project-diff.d.ts +24 -0
- package/dist/project-diff.js +76 -0
- package/dist/render/diff-html.d.ts +2 -0
- package/dist/render/diff-html.js +148 -0
- package/dist/render/diff-markdown.d.ts +11 -0
- package/dist/render/diff-markdown.js +70 -0
- package/dist/render/ensures.d.ts +2 -0
- package/dist/render/ensures.js +21 -0
- package/dist/render/html.d.ts +1 -0
- package/dist/render/html.js +42 -10
- package/dist/render/layout.d.ts +2 -0
- package/dist/render/layout.js +1 -1
- package/dist/render/markdown.js +24 -3
- package/dist/render/review.d.ts +17 -0
- package/dist/render/review.js +17 -0
- package/dist/render/union.d.ts +23 -0
- package/dist/render/union.js +43 -0
- package/dist/spec-loader.d.ts +2 -0
- package/dist/spec-loader.js +24 -0
- package/dist/static.d.ts +5 -0
- package/dist/static.js +34 -0
- package/package.json +7 -1
- package/skills/live-spec-authoring/SKILL.md +32 -2
- package/skills/live-spec-review/SKILL.md +16 -10
package/dist/omission.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { runAction } from "./explore.js";
|
|
2
|
+
const groupBy = (rows, keyOf) => {
|
|
3
|
+
const groups = new Map();
|
|
4
|
+
for (const r of rows) {
|
|
5
|
+
const key = JSON.stringify(keyOf(r));
|
|
6
|
+
groups.set(key, [...(groups.get(key) ?? []), r]);
|
|
7
|
+
}
|
|
8
|
+
return [...groups.values()];
|
|
9
|
+
};
|
|
10
|
+
const enabledOf = (r) => String(r.enabled);
|
|
11
|
+
// 行き先まで含める理由: 入力や登場人物によって行き先が変わる操作は、可否が同じでも、その入力・登場人物を見ている。
|
|
12
|
+
const outcomeOf = (r) => (r.enabled ? `ok:${r.to}` : "no");
|
|
13
|
+
const invariantAcross = (rows, rest, result) => groupBy(rows, rest).every((g) => new Set(g.map(result)).size === 1);
|
|
14
|
+
const signatures = (rows, valueOf, rest) => {
|
|
15
|
+
const byValue = new Map();
|
|
16
|
+
for (const r of rows)
|
|
17
|
+
byValue.set(valueOf(r), [...(byValue.get(valueOf(r)) ?? []), r]);
|
|
18
|
+
return new Map([...byValue].map(([value, rs]) => [
|
|
19
|
+
value,
|
|
20
|
+
JSON.stringify(rs.map((r) => [JSON.stringify(rest(r)), outcomeOf(r)]).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),
|
|
21
|
+
]));
|
|
22
|
+
};
|
|
23
|
+
const sameGroups = (sigs) => {
|
|
24
|
+
const bySig = new Map();
|
|
25
|
+
for (const [value, sig] of sigs)
|
|
26
|
+
bySig.set(sig, [...(bySig.get(sig) ?? []), value]);
|
|
27
|
+
return [...bySig.values()].filter((g) => g.length > 1);
|
|
28
|
+
};
|
|
29
|
+
const isPlainObject = (u) => typeof u === "object" && u !== null && !Array.isArray(u);
|
|
30
|
+
// 1 つの属性だけが違う 2 人の組。「別の著者bob」と「著者alice」のように id だけが違う組は、
|
|
31
|
+
// 「自分の〜だけ」の条件があるかどうかで扱いが分かれるはずの組なので、区別の有無を比べる対象にする。
|
|
32
|
+
const similarPairs = (spec) => {
|
|
33
|
+
const pairs = [];
|
|
34
|
+
for (const [i, [p, pv]] of spec.actors.entries()) {
|
|
35
|
+
for (const [q, qv] of spec.actors.slice(i + 1)) {
|
|
36
|
+
if (!isPlainObject(pv) || !isPlainObject(qv))
|
|
37
|
+
continue;
|
|
38
|
+
const keys = [...new Set([...Object.keys(pv), ...Object.keys(qv)])];
|
|
39
|
+
const differing = keys.filter((k) => JSON.stringify(pv[k]) !== JSON.stringify(qv[k]));
|
|
40
|
+
if (differing.length === 1)
|
|
41
|
+
pairs.push({ p, q, key: differing[0] });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return pairs;
|
|
45
|
+
};
|
|
46
|
+
const distinguishes = (rows, p, q) => groupBy(rows.filter((r) => r.actor === p || r.actor === q), (r) => [r.state, r.input]).some((g) => new Set(g.map((r) => r.enabled)).size > 1);
|
|
47
|
+
export const findOmissionHints = (spec, graph, options = {}) => {
|
|
48
|
+
const hints = [];
|
|
49
|
+
const rowsOf = (action) => graph.availability.filter((r) => r.action === action);
|
|
50
|
+
const distinctActors = new Set(spec.actors.map(([, v]) => JSON.stringify(v))).size;
|
|
51
|
+
const pairs = similarPairs(spec);
|
|
52
|
+
for (const [action] of spec.actions) {
|
|
53
|
+
const rows = rowsOf(action);
|
|
54
|
+
if (!rows.some((r) => r.enabled))
|
|
55
|
+
continue;
|
|
56
|
+
if (distinctActors > 1 && invariantAcross(rows, (r) => [r.state, r.input], outcomeOf)) {
|
|
57
|
+
hints.push({
|
|
58
|
+
id: `anyone-can:${action}`,
|
|
59
|
+
kind: "anyone-can",
|
|
60
|
+
action,
|
|
61
|
+
field: null,
|
|
62
|
+
message: `${action} は、誰が実行しても可否が変わらない(誰でもできる)。「〜だけ」の条件を書き忘れていないか`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (graph.states.length > 1 && invariantAcross(rows, (r) => [r.actor, r.input], enabledOf)) {
|
|
66
|
+
hints.push({
|
|
67
|
+
id: `anytime:${action}`,
|
|
68
|
+
kind: "anytime",
|
|
69
|
+
action,
|
|
70
|
+
field: null,
|
|
71
|
+
message: `${action} は、どの状態でも可否が変わらない(いつでもできる)。状態の条件を書き忘れていないか`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const inputCount = spec.inputs[action]?.length ?? 0;
|
|
75
|
+
const ignoresInput = inputCount > 1 && invariantAcross(rows, (r) => [r.state, r.actor], outcomeOf);
|
|
76
|
+
if (ignoresInput) {
|
|
77
|
+
hints.push({
|
|
78
|
+
id: `ignores-input:${action}`,
|
|
79
|
+
kind: "ignores-input",
|
|
80
|
+
action,
|
|
81
|
+
field: null,
|
|
82
|
+
message: `${action} は、入力の例を変えても結果が変わらない。入力の検証を書き忘れていないか`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// 断られる例同士が同じ結果なのは、境目の値を確かめる書き方なので候補にしない。
|
|
86
|
+
// 実行できる例同士が同じ結果なのは、違う結果を期待して選んだ例が、条件の書き忘れで同じになった可能性がある。
|
|
87
|
+
if (inputCount > 2 && !ignoresInput) {
|
|
88
|
+
const accepted = new Set(rows.filter((r) => r.enabled).map((r) => r.input ?? ""));
|
|
89
|
+
for (const group of sameGroups(signatures(rows, (r) => r.input ?? "", (r) => [r.state, r.actor]))) {
|
|
90
|
+
if (!group.every((g) => accepted.has(g)))
|
|
91
|
+
continue;
|
|
92
|
+
hints.push({
|
|
93
|
+
id: `indistinguishable-example:${action}:${group.join(",")}`,
|
|
94
|
+
kind: "indistinguishable-example",
|
|
95
|
+
action,
|
|
96
|
+
field: null,
|
|
97
|
+
message: `${action} の入力の例「${group.join("」「")}」は、結果がまったく同じ。違う結果を期待していなかったか(条件の書き忘れ)`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const blind = pairs.filter(({ p, q }) => rows.some((r) => r.enabled && (r.actor === p || r.actor === q)) && !distinguishes(rows, p, q));
|
|
102
|
+
const reported = blind
|
|
103
|
+
.map(({ p, q, key }) => ({ p, q, key, others: spec.actions.map(([n]) => n).filter((n) => n !== action && distinguishes(rowsOf(n), p, q)) }))
|
|
104
|
+
.filter((b) => b.others.length > 0);
|
|
105
|
+
if (reported.length > 0) {
|
|
106
|
+
const others = [...new Set(reported.flatMap((b) => b.others))];
|
|
107
|
+
hints.push({
|
|
108
|
+
id: `same-for-similar-actors:${action}`,
|
|
109
|
+
kind: "same-for-similar-actors",
|
|
110
|
+
action,
|
|
111
|
+
field: null,
|
|
112
|
+
message: `${action} は、${reported.map((b) => `${b.p} と ${b.q}(${b.key} だけが違う)`).join("、")}を区別しない。${others.join(", ")} は区別している。「自分の〜だけ」の条件を書き忘れていないか`,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// 登場人物は、違う振る舞いを確かめるために書き手が選んだもの。すべての操作で結果が同じ 2 人は、
|
|
117
|
+
// 2 人を分けるはずの条件が書き忘れられている可能性がある。
|
|
118
|
+
for (const group of sameGroups(signatures(graph.availability, (r) => r.actor, (r) => [r.state, r.action, r.input]))) {
|
|
119
|
+
if (!graph.availability.some((r) => r.enabled && group.includes(r.actor)))
|
|
120
|
+
continue;
|
|
121
|
+
hints.push({
|
|
122
|
+
id: `indistinguishable-actor:${group.join(",")}`,
|
|
123
|
+
kind: "indistinguishable-actor",
|
|
124
|
+
action: null,
|
|
125
|
+
field: null,
|
|
126
|
+
message: `登場人物「${group.join("」「")}」は、どの状態・操作でも結果がまったく同じ。2 人を分けるはずの条件を書き忘れていないか`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
hints.push(...unusedFields(spec, graph, options));
|
|
130
|
+
return hints;
|
|
131
|
+
};
|
|
132
|
+
const MAX_PERTURBED_STATES = 50;
|
|
133
|
+
// 項目の値を 1 つだけ差し替えた状態で操作を実行し直し、可否が変わるかを見る(Leveson の入力の完全性)。
|
|
134
|
+
// 差し替えた状態は到達できないこともあるが、ここで知りたいのは「条件がその項目を見ているか」なので構わない。
|
|
135
|
+
const unusedFields = (spec, graph, options) => {
|
|
136
|
+
const states = graph.states.slice(0, MAX_PERTURBED_STATES);
|
|
137
|
+
const fields = [...new Set(states.flatMap((s) => Object.keys(s.values)))];
|
|
138
|
+
// 文字列の項目には、登場人物の属性の値も候補に入れる。authorId のように登場人物と比べる項目は、
|
|
139
|
+
// 到達できる状態では 1 つの値("alice")しかとらないことがあり、それだけでは差し替えられないため。
|
|
140
|
+
const actorStrings = spec.actors.flatMap(([, v]) => (isPlainObject(v) ? Object.values(v).filter((x) => typeof x === "string") : []));
|
|
141
|
+
const enabledAt = new Map(graph.availability.map((r) => [JSON.stringify([r.state, r.action, r.actor, r.input]), r.enabled]));
|
|
142
|
+
const bypassFor = (action) => (options.bypassEnsure?.action === action ? options.bypassEnsure.reason : null);
|
|
143
|
+
const NO_INPUT = [[null, []]];
|
|
144
|
+
const used = (field) => {
|
|
145
|
+
const seen = states.map((s) => s.values[field]);
|
|
146
|
+
const domain = [...new Set([...seen, ...(spec.fields[field] ?? []), ...(seen.some((v) => typeof v === "string") ? actorStrings : [])].map((v) => JSON.stringify(v)))].map((v) => JSON.parse(v));
|
|
147
|
+
for (const s of states) {
|
|
148
|
+
for (const value of domain) {
|
|
149
|
+
if (JSON.stringify(value) === JSON.stringify(s.values[field]))
|
|
150
|
+
continue;
|
|
151
|
+
const perturbed = { ...s.values, [field]: value };
|
|
152
|
+
for (const [action, fn] of spec.actions) {
|
|
153
|
+
for (const [actor, actorValue] of spec.actors) {
|
|
154
|
+
for (const [input, args] of spec.inputs[action] ?? NO_INPUT) {
|
|
155
|
+
const before = enabledAt.get(JSON.stringify([s.id, action, actor, input]));
|
|
156
|
+
if (before === undefined)
|
|
157
|
+
continue;
|
|
158
|
+
const after = runAction(fn, perturbed, actorValue, args, bypassFor(action)).kind === "ok";
|
|
159
|
+
if (before !== after)
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
};
|
|
168
|
+
return fields
|
|
169
|
+
.filter((f) => !used(f))
|
|
170
|
+
.map((field) => ({
|
|
171
|
+
id: `unused-field:${field}`,
|
|
172
|
+
kind: "unused-field",
|
|
173
|
+
action: null,
|
|
174
|
+
field,
|
|
175
|
+
message: `状態の項目 ${field} は、値を変えても、どの操作の可否も変わらない。この項目を使う条件を書き忘れていないか`,
|
|
176
|
+
}));
|
|
177
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ModelDiff } from "./diff.js";
|
|
2
|
+
import type { DomainObject } from "./render/html.js";
|
|
3
|
+
export interface ProjectDiffOptions {
|
|
4
|
+
readonly cwd?: string;
|
|
5
|
+
readonly paths: ReadonlyArray<string>;
|
|
6
|
+
readonly base: string;
|
|
7
|
+
/** 省くと作業ツリーと比べる */
|
|
8
|
+
readonly head?: string;
|
|
9
|
+
}
|
|
10
|
+
export type ObjectStatus = "added" | "removed" | "changed" | "unchanged";
|
|
11
|
+
export interface ObjectDiff {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly status: ObjectStatus;
|
|
14
|
+
readonly before: DomainObject | null;
|
|
15
|
+
readonly after: DomainObject | null;
|
|
16
|
+
readonly diff: ModelDiff;
|
|
17
|
+
}
|
|
18
|
+
export interface ProjectDiff {
|
|
19
|
+
readonly base: string;
|
|
20
|
+
readonly head: string;
|
|
21
|
+
readonly objects: ReadonlyArray<ObjectDiff>;
|
|
22
|
+
}
|
|
23
|
+
export declare const WORKING_TREE = "\u4F5C\u696D\u30C4\u30EA\u30FC";
|
|
24
|
+
export declare const diffProject: (options: ProjectDiffOptions) => Promise<ProjectDiff>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { diffModels, EMPTY_MODEL, isEmptyDiff } from "./diff.js";
|
|
5
|
+
import { expandSpecPaths, loadObject, specNameOf } from "./generate.js";
|
|
6
|
+
import { normalize } from "./model.js";
|
|
7
|
+
export const WORKING_TREE = "作業ツリー";
|
|
8
|
+
const git = (root, args) => execFileSync("git", ["-C", root, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
9
|
+
const isSpec = (path) => path.endsWith(".spec.ts") && !basename(path).startsWith(".");
|
|
10
|
+
// git のリビジョンから取り出した spec を、元の spec と同じディレクトリの一時ファイルに書いて読み込む理由:
|
|
11
|
+
// spec が import する live-spec を、利用者のプロジェクトの node_modules から解決させるため。
|
|
12
|
+
// そのため spec が相対パスで import している別ファイルは、作業ツリーの版が使われる(git から取り出さない)。
|
|
13
|
+
const loadAtRevision = async (root, rel, ref, tag) => {
|
|
14
|
+
const source = git(root, ["show", `${ref}:${rel}`]);
|
|
15
|
+
const target = join(root, rel);
|
|
16
|
+
let created = null;
|
|
17
|
+
for (let dir = dirname(target); !existsSync(dir); dir = dirname(dir))
|
|
18
|
+
created = dir;
|
|
19
|
+
if (created !== null)
|
|
20
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
21
|
+
const tmp = join(dirname(target), `.${basename(rel).replace(/\.ts$/, "")}.live-spec-${tag}.ts`);
|
|
22
|
+
writeFileSync(tmp, source);
|
|
23
|
+
try {
|
|
24
|
+
return await loadObject(tmp, { name: specNameOf(rel), source });
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
rmSync(tmp, { force: true });
|
|
28
|
+
if (created !== null)
|
|
29
|
+
rmSync(created, { recursive: true, force: true });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const diffProject = async (options) => {
|
|
33
|
+
const cwd = resolve(options.cwd ?? ".");
|
|
34
|
+
const root = git(cwd, ["rev-parse", "--show-toplevel"]).trim();
|
|
35
|
+
for (const ref of [options.base, options.head]) {
|
|
36
|
+
if (ref === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
try {
|
|
39
|
+
git(cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new Error(`リビジョン ${ref} が見つかりません`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// パスを git に cwd から相対で解釈させ、--full-name でリポジトリのルートからのパスを受け取る理由:
|
|
46
|
+
// 自分で relative(root, path) を計算すると、macOS の /var → /private/var のようなシンボリックリンクで
|
|
47
|
+
// パスがリポジトリの外に見えてしまうため。
|
|
48
|
+
const listAt = (ref) => git(cwd, ["ls-tree", "-r", "--name-only", "--full-name", ref, "--", ...options.paths])
|
|
49
|
+
.split("\n")
|
|
50
|
+
.filter(isSpec);
|
|
51
|
+
const baseFiles = listAt(options.base);
|
|
52
|
+
const headFiles = options.head === undefined
|
|
53
|
+
? expandSpecPaths(options.paths.map((p) => resolve(cwd, p)))
|
|
54
|
+
.map((p) => relative(root, realpathSync(p)))
|
|
55
|
+
.filter(isSpec)
|
|
56
|
+
: listAt(options.head);
|
|
57
|
+
const load = async (files, ref, tag) => {
|
|
58
|
+
const objects = new Map();
|
|
59
|
+
for (const rel of files) {
|
|
60
|
+
const o = ref === undefined ? await loadObject(join(root, rel)) : await loadAtRevision(root, rel, ref, tag);
|
|
61
|
+
objects.set(o.spec.name, o);
|
|
62
|
+
}
|
|
63
|
+
return objects;
|
|
64
|
+
};
|
|
65
|
+
const before = await load(baseFiles, options.base, "base");
|
|
66
|
+
const after = await load(headFiles, options.head, "head");
|
|
67
|
+
const names = [...new Set([...before.keys(), ...after.keys()])].sort();
|
|
68
|
+
const objects = names.map((name) => {
|
|
69
|
+
const b = before.get(name) ?? null;
|
|
70
|
+
const a = after.get(name) ?? null;
|
|
71
|
+
const diff = diffModels(b === null ? EMPTY_MODEL : normalize(b.spec, b.graph), a === null ? EMPTY_MODEL : normalize(a.spec, a.graph));
|
|
72
|
+
const status = b === null ? "added" : a === null ? "removed" : isEmptyDiff(diff) ? "unchanged" : "changed";
|
|
73
|
+
return { name, status, before: b, after: a, diff };
|
|
74
|
+
});
|
|
75
|
+
return { base: options.base, head: options.head ?? WORKING_TREE, objects };
|
|
76
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { describeFinding, groupAvailability, whoOf } from "../diff.js";
|
|
2
|
+
import { STATUS_LABEL, summaryOf } from "./diff-markdown.js";
|
|
3
|
+
import { esc } from "./escape.js";
|
|
4
|
+
import { CSS } from "./html.js";
|
|
5
|
+
import { layout } from "./layout.js";
|
|
6
|
+
import { edgeLabel, unionGraph } from "./union.js";
|
|
7
|
+
import { surfaceToHtml } from "./wireframe.js";
|
|
8
|
+
export const renderDiffHtml = async (p) => {
|
|
9
|
+
const changed = p.objects.filter((o) => o.status !== "unchanged");
|
|
10
|
+
const unchanged = p.objects.filter((o) => o.status === "unchanged");
|
|
11
|
+
const sections = await Promise.all(changed.map((o, i) => objectSection(o, i)));
|
|
12
|
+
return `<!doctype html>
|
|
13
|
+
<html lang="ja">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="utf-8">
|
|
16
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
17
|
+
<title>仕様の差分 — ${esc(p.base)} → ${esc(p.head)}</title>
|
|
18
|
+
<style>${CSS}${DIFF_CSS}</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<header class="top">
|
|
22
|
+
<div>
|
|
23
|
+
<p class="eyebrow">仕様の差分</p>
|
|
24
|
+
<h1><code>${esc(p.base)}</code> → <code>${esc(p.head)}</code></h1>
|
|
25
|
+
<p class="lead">${changed.length === 0 ? "仕様の変化はありません。" : `${changed.length} 個のドメインオブジェクトが変わりました。`}${unchanged.length === 0 ? "" : `変化なし: ${esc(unchanged.map((o) => o.name).join(", "))}`}</p>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
<main>
|
|
29
|
+
${changed.length === 0
|
|
30
|
+
? ""
|
|
31
|
+
: `<table class="decision summary"><thead><tr><th>ドメインオブジェクト</th><th>変化</th><th>操作</th><th>状態</th><th>遷移</th><th>できる/できない</th><th>検査結果</th></tr></thead><tbody>${changed
|
|
32
|
+
.map((o) => {
|
|
33
|
+
const s = summaryOf(o.diff);
|
|
34
|
+
return `<tr><td><a href="#obj-${esc(o.name)}">${esc(o.name)}</a></td><td><span class="badge ${o.status}">${STATUS_LABEL[o.status]}</span></td><td>${s.actions}</td><td>${s.states}</td><td>${s.transitions}</td><td>${s.availability}</td><td>${s.findings}</td></tr>`;
|
|
35
|
+
})
|
|
36
|
+
.join("")}</tbody></table>`}
|
|
37
|
+
${sections.join("\n")}
|
|
38
|
+
</main>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
41
|
+
`;
|
|
42
|
+
};
|
|
43
|
+
const objectSection = async (o, index) => {
|
|
44
|
+
const { nodes, edges } = unionGraph(o.before?.graph ?? null, o.after?.graph ?? null);
|
|
45
|
+
// 「どの状態からでも」にはまとめない。まとめると、一部の状態からだけ消えた遷移が見えなくなるため。
|
|
46
|
+
const l = await layout({
|
|
47
|
+
states: nodes.map((n) => ({ id: n.id, label: n.label, values: {}, initial: n.initial, terminal: false })),
|
|
48
|
+
transitions: edges.map((e) => ({ from: e.from, to: e.to, action: edgeLabel(e), actors: [] })),
|
|
49
|
+
availability: [],
|
|
50
|
+
findings: [],
|
|
51
|
+
surfaces: [],
|
|
52
|
+
decisions: [],
|
|
53
|
+
links: [],
|
|
54
|
+
questions: [],
|
|
55
|
+
scenarios: [],
|
|
56
|
+
}, { collapse: false });
|
|
57
|
+
const statusOfNode = new Map(nodes.map((n) => [n.id, n.status]));
|
|
58
|
+
const marker = `arrow-diff-${index}`;
|
|
59
|
+
const edgeSvg = l.edges
|
|
60
|
+
.map((e, i) => {
|
|
61
|
+
const d = e.points.map((pt, j) => `${j === 0 ? "M" : "L"}${pt.x},${pt.y}`).join(" ");
|
|
62
|
+
const lb = e.label;
|
|
63
|
+
return `<g class="edge diff-${edges[i].status}"><path d="${d}" marker-end="url(#${marker})"/><g class="edge-label"><rect x="${lb.x}" y="${lb.y}" width="${lb.width}" height="${lb.height}" rx="4"/><text x="${lb.x + lb.width / 2}" y="${lb.y + lb.height / 2}">${esc(e.action)}</text></g></g>`;
|
|
64
|
+
})
|
|
65
|
+
.join("");
|
|
66
|
+
const nodeSvg = l.nodes
|
|
67
|
+
.map((n) => `<g class="node diff-${statusOfNode.get(n.id)}"><rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" rx="10"/><text x="${n.x + n.width / 2}" y="${n.y + n.height / 2}">${esc(n.label)}</text></g>`)
|
|
68
|
+
.join("");
|
|
69
|
+
return `<section class="diff-object" id="obj-${esc(o.name)}">
|
|
70
|
+
<h2>${esc(o.name)} <span class="badge ${o.status}">${STATUS_LABEL[o.status]}</span></h2>
|
|
71
|
+
${nodes.length === 0
|
|
72
|
+
? ""
|
|
73
|
+
: `<div class="diagram"><svg viewBox="0 0 ${l.width} ${l.height}" width="${l.width}" height="${l.height}" role="img" aria-label="${esc(o.name)} の状態遷移図の差分"><defs><marker id="${marker}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"/></marker></defs>${edgeSvg}${nodeSvg}</svg></div>
|
|
74
|
+
<p class="legend"><span class="sw added"></span>増えた <span class="sw removed"></span>消えた <span class="sw changed"></span>通れる人が変わった <span class="sw kept"></span>変わらない</p>`}
|
|
75
|
+
${diffBody(o.diff)}
|
|
76
|
+
${screens(o)}
|
|
77
|
+
</section>`;
|
|
78
|
+
};
|
|
79
|
+
const list = (title, items) => items.length === 0 ? "" : `<h3>${title}</h3><ul class="diff-list">${items.join("")}</ul>`;
|
|
80
|
+
const plus = (s) => `<li class="added">+ ${esc(s)}</li>`;
|
|
81
|
+
const minus = (s) => `<li class="removed">- ${esc(s)}</li>`;
|
|
82
|
+
const diffBody = (d) => {
|
|
83
|
+
const g = groupAvailability(d.availability);
|
|
84
|
+
return [
|
|
85
|
+
list("操作", [...d.actions.added.map(plus), ...d.actions.removed.map(minus)]),
|
|
86
|
+
list("状態", [...d.states.added.map(plus), ...d.states.removed.map(minus)]),
|
|
87
|
+
list("遷移", [...d.transitions.added.map(plus), ...d.transitions.removed.map(minus)]),
|
|
88
|
+
g.flipped.length === 0
|
|
89
|
+
? ""
|
|
90
|
+
: `<h3>できる/できないの変化</h3><table class="decision"><thead><tr><th>状態</th><th>操作</th><th>登場人物</th><th>変更前</th><th>変更後</th></tr></thead><tbody>${g.flipped
|
|
91
|
+
.map((a) => `<tr><td>${esc(a.state)}</td><td>${esc(a.action)}</td><td>${esc(whoOf(a))}</td><td class="removed">${esc(a.before)}</td><td class="added">${esc(a.after)}</td></tr>`)
|
|
92
|
+
.join("")}</tbody></table>`,
|
|
93
|
+
g.reasonOnly.length === 0
|
|
94
|
+
? ""
|
|
95
|
+
: `<details class="reason-only"><summary>できない理由の言い方だけが変わったもの(${g.reasonOnly.reduce((n, r) => n + r.count, 0)} 件)</summary><table class="decision"><thead><tr><th>操作</th><th>変更前</th><th>変更後</th><th>どの状態・誰</th></tr></thead><tbody>${g.reasonOnly
|
|
96
|
+
.map((r) => `<tr><td>${esc(r.action)}</td><td>${esc(r.before)}</td><td>${esc(r.after)}</td><td class="muted">${esc(r.cases.map((c) => `${c.state}・${whoOf(c)}`).join("、"))}</td></tr>`)
|
|
97
|
+
.join("")}</tbody></table></details>`,
|
|
98
|
+
list("シナリオ", [
|
|
99
|
+
...d.scenarios.added.map(plus),
|
|
100
|
+
...d.scenarios.removed.map(minus),
|
|
101
|
+
...d.scenarios.changed.map((c) => `<li>${esc(c.name)}: ${c.before ? "通る" : "止まる"} → ${c.after ? "通る" : "止まる"}</li>`),
|
|
102
|
+
]),
|
|
103
|
+
list("未決事項", [...d.questions.added.map(plus), ...d.questions.removed.map((q) => minus(`${q}(解決したか、取り下げた)`))]),
|
|
104
|
+
list("検査結果", [...d.findings.added.map((f) => plus(describeFinding(f))), ...d.findings.removed.map((f) => minus(describeFinding(f)))]),
|
|
105
|
+
].join("");
|
|
106
|
+
};
|
|
107
|
+
// 画面が変わった「状態 × 見る人」ごとに、変更前と変更後を左右に並べる(文章の差分より、見比べるほうが早いため)。
|
|
108
|
+
const screens = (o) => {
|
|
109
|
+
if (o.diff.surfaces.length === 0)
|
|
110
|
+
return "";
|
|
111
|
+
const surfaceOf = (side, stateLabel, actor) => {
|
|
112
|
+
if (side === null)
|
|
113
|
+
return null;
|
|
114
|
+
const state = side.graph.states.find((s) => s.label === stateLabel);
|
|
115
|
+
const found = state === undefined ? undefined : side.graph.surfaces.find((x) => x.state === state.id && x.actor === actor);
|
|
116
|
+
return found === undefined ? null : surfaceToHtml(found.surface, []);
|
|
117
|
+
};
|
|
118
|
+
return `<h3>画面の変化</h3>${o.diff.surfaces
|
|
119
|
+
.map((s) => {
|
|
120
|
+
const b = surfaceOf(o.before, s.state, s.actor);
|
|
121
|
+
const a = surfaceOf(o.after, s.state, s.actor);
|
|
122
|
+
return `<h4>${esc(s.state)}(${esc(s.actor)} が見る画面)</h4><div class="before-after"><div><p class="eyebrow">変更前</p>${b ?? '<p class="muted">(画面なし)</p>'}</div><div><p class="eyebrow">変更後</p>${a ?? '<p class="muted">(画面なし)</p>'}</div></div>`;
|
|
123
|
+
})
|
|
124
|
+
.join("")}`;
|
|
125
|
+
};
|
|
126
|
+
const DIFF_CSS = `
|
|
127
|
+
.diff-object{margin:40px 0;padding-top:12px;border-top:1px solid var(--line)}
|
|
128
|
+
.diff-object h2{display:flex;align-items:center;gap:10px}
|
|
129
|
+
.diff-object h3{font-size:15px;margin:20px 0 6px}
|
|
130
|
+
.diff-object h4{font-size:14px;margin:14px 0 6px;color:var(--muted)}
|
|
131
|
+
.badge{font-size:12px;font-weight:600;padding:2px 10px;border-radius:999px;background:var(--chip)}
|
|
132
|
+
.badge.added{background:#1d7f48;color:#fff}.badge.removed{background:#b3261e;color:#fff}.badge.changed{background:var(--accent);color:#fff}
|
|
133
|
+
.node.diff-added rect{stroke:#1d7f48;stroke-width:2.2;fill:rgba(29,127,72,.15)}
|
|
134
|
+
.node.diff-removed rect{stroke:#b3261e;stroke-width:2;stroke-dasharray:5 3;fill:rgba(179,38,30,.10)}
|
|
135
|
+
.node.diff-removed text{text-decoration:line-through}
|
|
136
|
+
.edge.diff-added path{stroke:#1d7f48;stroke-width:2.2}.edge.diff-added .edge-label text{fill:#1d7f48;font-weight:600}
|
|
137
|
+
.edge.diff-changed path{stroke:#c58a00;stroke-width:2.2}.edge.diff-changed .edge-label text{fill:#c58a00;font-weight:600}
|
|
138
|
+
.sw.changed{border-color:#c58a00;background:rgba(197,138,0,.25)}
|
|
139
|
+
details.reason-only{margin:14px 0}details.reason-only summary{cursor:pointer;color:var(--muted);font-size:13.5px}
|
|
140
|
+
.edge.diff-removed path{stroke:#b3261e;stroke-width:1.8;stroke-dasharray:5 3}.edge.diff-removed .edge-label text{fill:#b3261e;text-decoration:line-through}
|
|
141
|
+
.legend{font-size:12.5px;color:var(--muted);display:flex;gap:6px;align-items:center}
|
|
142
|
+
.sw{display:inline-block;width:14px;height:10px;border-radius:3px;margin-left:10px;border:1.5px solid var(--fg)}
|
|
143
|
+
.sw.added{border-color:#1d7f48;background:rgba(29,127,72,.25)}.sw.removed{border-color:#b3261e;border-style:dashed}
|
|
144
|
+
.diff-list{list-style:none;padding:0;margin:0}.diff-list li{padding:3px 0}
|
|
145
|
+
.diff-list li.added,td.added{color:#1d7f48}.diff-list li.removed,td.removed{color:#b3261e}
|
|
146
|
+
.before-after{display:grid;grid-template-columns:1fr 1fr;gap:16px;max-width:900px}
|
|
147
|
+
table.summary a{color:var(--accent)}
|
|
148
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ModelDiff } from "../diff.js";
|
|
2
|
+
import type { ObjectStatus, ProjectDiff } from "../project-diff.js";
|
|
3
|
+
export declare const STATUS_LABEL: Readonly<Record<ObjectStatus, string>>;
|
|
4
|
+
export declare const summaryOf: (d: ModelDiff) => {
|
|
5
|
+
actions: string;
|
|
6
|
+
states: string;
|
|
7
|
+
transitions: string;
|
|
8
|
+
availability: string;
|
|
9
|
+
findings: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const renderDiffMarkdown: (p: ProjectDiff) => string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { groupAvailability, renderDiff } from "../diff.js";
|
|
2
|
+
import { edgeLabel, unionGraph } from "./union.js";
|
|
3
|
+
export const STATUS_LABEL = {
|
|
4
|
+
added: "追加",
|
|
5
|
+
removed: "削除",
|
|
6
|
+
changed: "変更",
|
|
7
|
+
unchanged: "変化なし",
|
|
8
|
+
};
|
|
9
|
+
const plusMinus = (d) => {
|
|
10
|
+
const parts = [d.added.length > 0 ? `+${d.added.length}` : "", d.removed.length > 0 ? `-${d.removed.length}` : ""].filter(Boolean);
|
|
11
|
+
return parts.length === 0 ? "" : parts.join(" ");
|
|
12
|
+
};
|
|
13
|
+
export const summaryOf = (d) => ({
|
|
14
|
+
actions: plusMinus(d.actions),
|
|
15
|
+
states: plusMinus(d.states),
|
|
16
|
+
transitions: plusMinus(d.transitions),
|
|
17
|
+
availability: (() => {
|
|
18
|
+
const g = groupAvailability(d.availability);
|
|
19
|
+
const reasons = g.reasonOnly.reduce((n, r) => n + r.count, 0);
|
|
20
|
+
return [g.flipped.length > 0 ? `${g.flipped.length} 件` : "", reasons > 0 ? `(理由の言い方 ${reasons} 件)` : ""].join("");
|
|
21
|
+
})(),
|
|
22
|
+
findings: plusMinus(d.findings),
|
|
23
|
+
});
|
|
24
|
+
// 図の線(遷移)は Mermaid の状態遷移図では色を変えられないので、ラベルに + / - を付けて示す。
|
|
25
|
+
const mermaidOf = (o) => {
|
|
26
|
+
const { nodes, edges } = unionGraph(o.before?.graph ?? null, o.after?.graph ?? null);
|
|
27
|
+
if (nodes.length === 0)
|
|
28
|
+
return [];
|
|
29
|
+
const mark = { added: " +", removed: " -", kept: "", changed: "" };
|
|
30
|
+
return [
|
|
31
|
+
"```mermaid",
|
|
32
|
+
"stateDiagram-v2",
|
|
33
|
+
" classDef added fill:#d9f7e5,stroke:#1d7f48,color:#0b3d22",
|
|
34
|
+
" classDef removed fill:#fde2e2,stroke:#b3261e,color:#5c1111,stroke-dasharray:4 3",
|
|
35
|
+
...nodes.map((n) => ` state "${n.label}" as ${n.id}`),
|
|
36
|
+
...nodes.filter((n) => n.initial).map((n) => ` [*] --> ${n.id}`),
|
|
37
|
+
...edges.map((e) => ` ${e.from} --> ${e.to}: ${edgeLabel(e)}${mark[e.status]}`),
|
|
38
|
+
...nodes.filter((n) => n.status !== "kept").map((n) => ` class ${n.id} ${n.status}`),
|
|
39
|
+
"```",
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
export const renderDiffMarkdown = (p) => {
|
|
43
|
+
const changed = p.objects.filter((o) => o.status !== "unchanged");
|
|
44
|
+
const unchanged = p.objects.filter((o) => o.status === "unchanged");
|
|
45
|
+
return [
|
|
46
|
+
"# 仕様の差分",
|
|
47
|
+
"",
|
|
48
|
+
`\`${p.base}\` → \`${p.head}\``,
|
|
49
|
+
"",
|
|
50
|
+
...(changed.length === 0
|
|
51
|
+
? ["仕様の変化はありません。", ""]
|
|
52
|
+
: [
|
|
53
|
+
"| ドメインオブジェクト | 変化 | 操作 | 状態 | 遷移 | できる/できない | 検査結果 |",
|
|
54
|
+
"|---|---|---|---|---|---|---|",
|
|
55
|
+
...changed.map((o) => {
|
|
56
|
+
const s = summaryOf(o.diff);
|
|
57
|
+
return `| [${o.name}](#${o.name}) | ${STATUS_LABEL[o.status]} | ${s.actions} | ${s.states} | ${s.transitions} | ${s.availability} | ${s.findings} |`;
|
|
58
|
+
}),
|
|
59
|
+
"",
|
|
60
|
+
]),
|
|
61
|
+
...(unchanged.length === 0 ? [] : [`変化なし: ${unchanged.map((o) => o.name).join(", ")}`, ""]),
|
|
62
|
+
...changed.flatMap((o) => [
|
|
63
|
+
`## ${o.name}(${STATUS_LABEL[o.status]})`,
|
|
64
|
+
"",
|
|
65
|
+
...mermaidOf(o),
|
|
66
|
+
"",
|
|
67
|
+
renderDiff(o.diff, { heading: false }),
|
|
68
|
+
]),
|
|
69
|
+
].join("\n");
|
|
70
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const effectText = (e) => {
|
|
2
|
+
const first = e.effects[0];
|
|
3
|
+
if (first === undefined)
|
|
4
|
+
return `状態「${e.newStates.join("」「")}」に入れるようになる`;
|
|
5
|
+
const who = first.input === null ? first.actor : `${first.actor}(${first.input})`;
|
|
6
|
+
const rest = e.effects.length > 1 ? ` ほか ${e.effects.length - 1} 件` : "";
|
|
7
|
+
return `${who} が ${first.state} で実行できるようになる(${first.after.replace(/^✅ /, "")})${rest}`;
|
|
8
|
+
};
|
|
9
|
+
const effectOf = (e, acknowledged) => {
|
|
10
|
+
switch (e.verdict) {
|
|
11
|
+
case "caught":
|
|
12
|
+
return `外すと、${e.caughtBy.join("・")}が気づく`;
|
|
13
|
+
case "unguarded":
|
|
14
|
+
return `外すと、${effectText(e)}。気づくものがない${acknowledged ? "(確認済み)" : ""}`;
|
|
15
|
+
case "no-effect":
|
|
16
|
+
return "外しても振る舞いが変わらない(ほかの条件と重なっている)";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// 理由の文と「実際に通るとき」を並べる理由: 理由の文は書き手の意図をもう一度書いたものなので、
|
|
20
|
+
// 実行して求めた事実と見比べると、状態の取り違えのような書き間違いが見える。
|
|
21
|
+
export const describeEnsure = (e, acknowledged = false) => `${e.verdict === "unguarded" && !acknowledged ? "⚠ " : ""}「${e.reason}」— 通るのは ${e.passes}。${effectOf(e, acknowledged)}`;
|
package/dist/render/html.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export interface ProjectOptions {
|
|
|
10
10
|
export declare const renderHtml: (spec: Spec, graph: Graph) => Promise<string>;
|
|
11
11
|
export declare const renderProjectHtml: (objects: ReadonlyArray<DomainObject>, options: ProjectOptions) => Promise<string>;
|
|
12
12
|
export declare const renderErrorHtml: (name: string, error: unknown) => string;
|
|
13
|
+
export declare const CSS = "\n:root{--bg:#f6f5f1;--fg:#1c1c1e;--muted:#6e6d72;--line:#d9d6cd;--card:#fff;--node:#fff;--accent:#2b59e0;--accent-weak:#e5ebfc;--ok:#1d7f48;--warn:#b3501a;--chip:#efeee9}\n@media (prefers-color-scheme:dark){:root{--bg:#141416;--fg:#ececee;--muted:#9a99a0;--line:#34343a;--card:#1c1c20;--node:#1f1f24;--accent:#7f9dff;--accent-weak:#232b45;--ok:#5cc98b;--warn:#f0a46b;--chip:#2a2a30}}\n*{box-sizing:border-box}\nbody{margin:0;background:var(--bg);color:var(--fg);font:15px/1.65 system-ui,-apple-system,\"Hiragino Sans\",\"Noto Sans JP\",sans-serif}\ncode{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--chip);padding:1px 6px;border-radius:5px}\n.top{display:flex;justify-content:space-between;align-items:flex-end;gap:24px;padding:40px 40px 24px;border-bottom:1px solid var(--line)}\n.eyebrow{margin:0 0 4px;font-size:12px;letter-spacing:.08em;color:var(--muted)}\nh1{margin:0;font-size:32px;letter-spacing:-.01em}\n.lead{margin:8px 0 0;color:var(--muted);max-width:60ch}\n.stats{display:flex;gap:28px;margin:0}\n.stats div{text-align:right}.stats dt{font-size:12px;color:var(--muted)}.stats dd{margin:0;font-size:24px;font-weight:600}\n.stats .ok{color:var(--ok)}.stats .warn{color:var(--warn)}\nmain{padding:24px 40px 64px}\nh2{font-size:18px;margin:40px 0 16px}\n.board .hint{margin:0 0 10px}\n.diagram{background:var(--card);border:1px solid var(--line);border-radius:14px;overflow:auto;padding:8px}\n.diagram svg{display:block;max-width:100%;height:auto;margin:0 auto}\n.panel{position:fixed;top:16px;right:16px;width:400px;max-height:calc(100vh - 32px);overflow:auto;background:var(--card);border:1px solid var(--line);border-radius:14px;padding:20px;box-shadow:0 12px 40px rgba(0,0,0,.25);z-index:10}\n.panel[hidden]{display:none}\n.panel h2{margin:0 0 12px;font-size:20px}\n.panel h3{font-size:13px;color:var(--muted);margin:18px 0 6px;font-weight:600}\n.panel ul{list-style:none;margin:0;padding:0}\n.panel li{padding:6px 0;border-top:1px solid var(--line)}\n.panel li:first-child{border-top:0}\n.panel .sub{display:block;font-size:12px;color:var(--muted)}\n.panel .tag{display:inline-block;font-size:11px;padding:1px 8px;border-radius:999px;background:var(--chip);margin-right:6px}\n.panel button{margin-top:16px;font:inherit;font-size:13px;background:none;border:1px solid var(--line);color:var(--fg);border-radius:8px;padding:4px 12px;cursor:pointer}\n.hint{font-size:12px;color:var(--muted)}\n.site{position:sticky;top:0;z-index:5;display:flex;gap:24px;align-items:center;padding:10px 40px;background:var(--bg);border-bottom:1px solid var(--line)}\n.site-title{font-weight:700;color:var(--fg);text-decoration:none}\n.tabs{display:flex;gap:4px;flex-wrap:wrap}\n.tabs a{color:var(--muted);text-decoration:none;padding:4px 12px;border-radius:8px;font-size:14px}\n.tabs a:hover{color:var(--fg)}\n.tabs a[aria-current=\"page\"]{background:var(--accent-weak);color:var(--accent);font-weight:600}\n.page[hidden]{display:none}\n.object-card{display:block;color:var(--fg);text-decoration:none}\n.object-card h3{font-size:18px}\n.object-doc{color:var(--muted);margin:0 0 12px}\n.card .object-stats{display:flex;gap:20px;margin:0}\n.object-stats dt{font-size:12px;color:var(--muted)}.object-stats dd{margin:0;font-weight:600;font-size:18px}\n.object-stats .ok{color:var(--ok)}.object-stats .warn{color:var(--warn)}\n.toolbar{display:flex;gap:16px;align-items:center;margin:0 0 10px;font-size:13px}\n.modes{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden}\n.modes button{font:inherit;font-size:13px;background:none;border:0;color:var(--muted);padding:4px 12px;cursor:pointer}\n.modes button[aria-pressed=\"true\"]{background:var(--accent-weak);color:var(--accent);font-weight:600}\n.viewpoint{color:var(--muted)}.viewpoint select{font:inherit;font-size:13px;margin-left:4px}\n.board[data-mode=\"states\"] .diagram-wireflow,.board[data-mode=\"wireflow\"] .diagram-states{display:none}\n.board:not([data-mode=\"wireflow\"]) .viewpoint{display:none}\nsvg text.wf-node-label{text-anchor:start;font-weight:600;font-size:13px}\n.thumb-frame{width:100%;height:100%;overflow:hidden;pointer-events:none}\n.thumb-inner{transform:scale(0.6);transform-origin:0 0}\n.wf-group{margin:10px 0 16px}\n.wf-screen{border:1.5px solid var(--fg);border-radius:8px;background:var(--node);font-size:13px;overflow:hidden}\n.wf-title{border-bottom:1.5px solid var(--fg);padding:6px 10px;font-weight:600;display:flex;gap:6px;align-items:center}\n.wf-title::before{content:\"\";width:28px;height:6px;border-radius:3px;background:repeating-linear-gradient(90deg,var(--muted) 0 6px,transparent 6px 11px)}\n.wf-body{padding:10px;display:flex;flex-direction:column;gap:8px;align-items:flex-start}\n.wf-section{border:1px dashed var(--muted);border-radius:6px;padding:8px;align-self:stretch;display:flex;flex-direction:column;gap:6px;align-items:flex-start}\n.wf-section > .wf-label{font-size:11.5px;color:var(--muted)}\n.wf-heading{font-weight:600;font-size:14px}\n.wf-text{margin:0}\n.wf-field{display:flex;flex-direction:column;gap:2px;align-self:stretch;font-size:11.5px;color:var(--muted)}\n.wf-input{border:1.2px solid var(--muted);border-radius:4px;min-height:24px;padding:2px 6px;color:var(--fg);font-size:12.5px}\n.wf-button{border:1.5px solid var(--fg);border-radius:6px;padding:2px 12px;font-size:12.5px;font-weight:600}\n.wf-button.is-disabled{opacity:.4;border-style:dashed}\n.wf-button.is-invalid{border-color:var(--warn);color:var(--warn)}\n.wf-button.is-invalid::after{content:\" \u26A0\"}\n.wf-badge{border:1px solid var(--muted);border-radius:999px;padding:0 8px;font-size:11px;color:var(--muted)}\n.wf-list{margin:0;padding-left:18px;align-self:stretch}\n.wf-code{margin:0;align-self:stretch;background:var(--chip);border-radius:6px;padding:8px;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap}\n.wf-code[data-language=\"terminal\"]{background:#111;color:#e6e6e6}\nsvg text{font-size:13px;fill:var(--fg);text-anchor:middle;dominant-baseline:central}\nmarker path{fill:var(--muted)}\n.node{cursor:pointer;outline:none}\n.node rect{fill:var(--node);stroke:var(--fg);stroke-width:1.4}\n.node rect.inner{fill:none;stroke-width:1}\n.node:hover rect,.node:focus-visible rect{stroke:var(--accent)}\n.node.violation rect{stroke:var(--warn);stroke-width:2;stroke-dasharray:5 3}\n.panel .tag.warn{background:var(--warn);color:var(--bg)}\n.panel .violation{color:var(--warn);font-size:13px;margin:10px 0 0}\n.start{fill:var(--fg)}.start-line{stroke:var(--fg);stroke-width:1.4}\n.edge{cursor:pointer}\n.edge path{fill:none;stroke:var(--muted);stroke-width:1.3}\n.edge-label rect{fill:var(--card)}\n.edge-label text{font-size:11.5px;fill:var(--muted)}\n.edge:hover path{stroke:var(--accent)}.edge:hover .edge-label text{fill:var(--accent)}\n.is-dim{opacity:.18;transition:opacity .15s}\n.node.is-selected rect{stroke:var(--accent);stroke-width:2.2;fill:var(--accent-weak)}\n.edge.is-active path{stroke:var(--accent);stroke-width:2.2}\n.edge.is-active .edge-label text{fill:var(--accent);font-weight:600}\n.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:16px}\n.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:18px 20px;cursor:pointer;outline:none;min-width:0}\n.card:hover,.card:focus-visible{border-color:var(--accent)}\n.card.is-selected{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-weak)}\n.card h3{margin:0 0 12px;font-size:16px}\n.card dl{display:grid;grid-template-columns:5.5em minmax(0,1fr);gap:8px 12px;margin:0;font-size:14px}\n.card dt{color:var(--muted);font-size:12.5px;padding-top:2px}\n.card dd{margin:0;min-width:0;overflow-wrap:anywhere}\n.card ul{margin:0;padding:0;list-style:none}\n.card li+li{margin-top:6px}\n.chip,.state,.flow{display:inline-block;max-width:100%;font-size:12.5px;border-radius:6px;padding:0 7px;margin:0 4px 4px 0;background:var(--chip)}\n.flow{background:var(--accent-weak)}\n.questions{border:1px solid var(--warn);border-radius:14px;padding:4px 20px 12px;margin:0 0 20px;background:var(--card)}\n.questions h2{margin:14px 0 8px;color:var(--warn);font-size:16px}\n.questions ol{margin:0;padding-left:20px}\n.questions li{margin:6px 0}\n.questions .ask{font-weight:600}\n.questions .target{color:var(--muted);font-size:13px;margin-left:4px}\n.questions .note{display:block;color:var(--muted);font-size:13px}\n.questions.review.done{border-color:var(--line)}.questions.review.done h2{color:var(--muted)}.ensure.unguarded.acknowledged{color:var(--muted);font-weight:400;font-size:12.5px}\n.review-id{font-size:11.5px;color:var(--muted);margin-left:4px}.acknowledged{margin:8px 0 4px;font-size:13px}.acknowledged summary{cursor:pointer;color:var(--muted)}\n.ensure{font-size:12.5px;margin:2px 0;color:var(--muted)}.ensure.unguarded{color:var(--warn);font-weight:600;font-size:13px}\n.q-badge{display:inline-block;font-size:11px;font-weight:600;padding:1px 8px;border-radius:999px;background:var(--warn);color:var(--bg);vertical-align:middle}\n.card .ask{color:var(--warn);font-size:13px}\n.q-mark circle{fill:var(--warn)}\n.q-mark text{fill:var(--bg);font-size:11px;font-weight:700}\n.stats .warn,.object-stats .warn{color:var(--warn)}\n.links-section{margin:0 0 8px}\n.link-list{list-style:none;padding:0;margin:8px 0 0}\n.link-list li{padding:6px 0;border-top:1px solid var(--line)}\n.link-list li:first-child{border-top:0}\n.link-list .sub{display:block;color:var(--muted);font-size:13px}\n.link-list a,.card .flow a{color:var(--accent)}\n.relations{margin-bottom:12px}\n.rel-node rect{fill:var(--node);stroke:var(--fg);stroke-width:1.4}\n.rel-node:hover rect{stroke:var(--accent)}\n.any-node rect{fill:none;stroke:var(--muted);stroke-width:1.2;stroke-dasharray:4 3}\n.any-node text{fill:var(--muted);font-size:12px}\n.glossary dl{display:grid;grid-template-columns:max-content 1fr;gap:6px 16px;margin:0}\n.glossary dt{font-weight:600}\n.glossary .kind{font-size:11px;color:var(--muted);font-weight:400;margin-left:4px}\n.glossary .sub{display:block;color:var(--muted);font-size:13px}\n.ev{display:block;font-size:13px}\ncode.evidence{font-size:12px}\ntable.decision{border-collapse:collapse;margin:8px 0 20px;background:var(--card);border:1px solid var(--line);border-radius:10px;overflow:hidden;font-size:14px}\ntable.decision th,table.decision td{padding:6px 14px;border-bottom:1px solid var(--line);text-align:left}\ntable.decision th{color:var(--muted);font-weight:600;font-size:12.5px}\ntable.decision td.result{font-weight:600}\ntable.decision tr.ng td.result{color:var(--warn)}\n.decisions h3{font-size:15px;margin:16px 0 4px}\n.scenario-card{margin-bottom:16px}\n.storyboard{display:flex;gap:14px;overflow-x:auto;list-style:none;margin:0;padding:0 0 6px;counter-reset:step}\n.storyboard li{flex:0 0 220px;counter-increment:step}\n.storyboard li::before{content:counter(step);display:inline-block;width:20px;height:20px;border-radius:50%;background:var(--accent-weak);color:var(--accent);font-size:12px;font-weight:700;text-align:center;line-height:20px;margin-bottom:4px}\n.storyboard li.failed::before{background:var(--warn);color:var(--bg)}\n.storyboard .step{margin:0 0 4px;font-size:13px;font-weight:600}\n.storyboard .flow{margin:0 0 8px;font-size:12px;display:inline-block}\n.storyboard .reason{margin:0;color:var(--warn);font-size:12.5px}\n.storyboard .frame{height:200px;overflow:hidden;border-radius:8px}\n.storyboard .frame-inner{width:366px;transform:scale(.6);transform-origin:0 0;pointer-events:none}\n.state.rest{background:none;border:1px dashed var(--line)}\n.reason{font-weight:600;margin-right:4px}\n.muted{color:var(--muted);font-size:13px;display:block}\n.findings ul{padding-left:20px}.findings li{color:var(--warn)}\n.ok-line{color:var(--ok)}\n@media (max-width:960px){.top{flex-direction:column;align-items:flex-start;padding:28px 20px 20px}main{padding:16px 20px 48px}.panel{left:16px;right:16px;width:auto;top:auto;bottom:16px;max-height:60vh}}\n@media print{.panel,.board .hint{display:none}.card{break-inside:avoid}}\n";
|