@yutaura/live-spec 0.1.0 → 0.3.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.
Files changed (50) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +15 -2
  3. package/dist/check.d.ts +5 -0
  4. package/dist/check.js +40 -0
  5. package/dist/cli.js +116 -10
  6. package/dist/diff.d.ts +92 -2
  7. package/dist/diff.js +101 -64
  8. package/dist/ensure-scope.d.ts +9 -0
  9. package/dist/ensure-scope.js +81 -0
  10. package/dist/ensure.d.ts +4 -0
  11. package/dist/ensure.js +27 -2
  12. package/dist/evidence.d.ts +3 -0
  13. package/dist/evidence.js +46 -0
  14. package/dist/explore.d.ts +20 -1
  15. package/dist/explore.js +38 -12
  16. package/dist/generate.d.ts +7 -0
  17. package/dist/generate.js +18 -5
  18. package/dist/load.d.ts +11 -1
  19. package/dist/load.js +9 -0
  20. package/dist/model.d.ts +127 -0
  21. package/dist/model.js +40 -0
  22. package/dist/mutation.d.ts +3 -0
  23. package/dist/mutation.js +51 -0
  24. package/dist/omission.d.ts +6 -0
  25. package/dist/omission.js +235 -0
  26. package/dist/project-diff.d.ts +24 -0
  27. package/dist/project-diff.js +76 -0
  28. package/dist/render/diff-html.d.ts +2 -0
  29. package/dist/render/diff-html.js +148 -0
  30. package/dist/render/diff-markdown.d.ts +11 -0
  31. package/dist/render/diff-markdown.js +70 -0
  32. package/dist/render/ensures.d.ts +2 -0
  33. package/dist/render/ensures.js +21 -0
  34. package/dist/render/html.d.ts +1 -0
  35. package/dist/render/html.js +42 -10
  36. package/dist/render/layout.d.ts +2 -0
  37. package/dist/render/layout.js +1 -1
  38. package/dist/render/markdown.js +30 -3
  39. package/dist/render/review.d.ts +17 -0
  40. package/dist/render/review.js +17 -0
  41. package/dist/render/union.d.ts +23 -0
  42. package/dist/render/union.js +43 -0
  43. package/dist/spec-loader.d.ts +2 -0
  44. package/dist/spec-loader.js +24 -0
  45. package/dist/static.d.ts +7 -0
  46. package/dist/static.js +74 -0
  47. package/package.json +7 -1
  48. package/skills/live-spec-authoring/SKILL.md +59 -7
  49. package/skills/live-spec-from-code/SKILL.md +2 -0
  50. package/skills/live-spec-review/SKILL.md +16 -10
@@ -0,0 +1,24 @@
1
+ import { registerHooks } from "node:module";
2
+ // ファイル名に .spec. を含む .ts。差分やミューテーションで書き出す一時ファイル(.order.spec.live-spec-base.ts など)も含む。
3
+ export const isSpecModuleUrl = (url) => {
4
+ if (!url.startsWith("file:"))
5
+ return false;
6
+ const path = new URL(url).pathname;
7
+ const base = path.slice(path.lastIndexOf("/") + 1);
8
+ return base.endsWith(".ts") && base.includes(".spec.");
9
+ };
10
+ let registered = false;
11
+ // spec を TypeScript の ES module として読むよう Node に伝える。
12
+ // 伝えないと、package.json に "type": "module" が無いプロジェクト(pnpm workspace のルートなど)では、
13
+ // Node が CommonJS として読もうとして失敗し、spec ごとに MODULE_TYPELESS_PACKAGE_JSON の警告を出す。
14
+ // 利用者に package.json を足してもらう回避策にしない理由: ルートに "type" を足すと、既存の CommonJS の設定ファイルを壊しうる。
15
+ export const registerSpecLoader = () => {
16
+ if (registered)
17
+ return;
18
+ registered = true;
19
+ registerHooks({
20
+ load(url, context, nextLoad) {
21
+ return nextLoad(url, isSpecModuleUrl(url) ? { ...context, format: "module-typescript" } : context);
22
+ },
23
+ });
24
+ };
package/dist/static.d.ts CHANGED
@@ -6,5 +6,12 @@ export interface StaticInfo {
6
6
  readonly stateDoc: string | null;
7
7
  readonly fieldDocs: Readonly<Record<string, string>>;
8
8
  readonly evidence: Readonly<Record<string, ReadonlyArray<string>>>;
9
+ readonly ensures: Readonly<Record<string, ReadonlyArray<EnsureCall>>>;
10
+ }
11
+ export interface EnsureCall {
12
+ readonly reason: string;
13
+ readonly line: number;
14
+ /** 後ろの条件のために型を絞る ensure(判別の項目を比べ、後ろで同じ値の別の項目を読む) */
15
+ readonly narrowing?: true;
9
16
  }
10
17
  export declare const analyze: (source: string) => StaticInfo;
package/dist/static.js CHANGED
@@ -9,6 +9,7 @@ export const analyze = (source) => {
9
9
  const body = file.program.body;
10
10
  const comments = file.comments ?? [];
11
11
  const evidence = {};
12
+ const ensures = {};
12
13
  const order = [];
13
14
  const docs = {};
14
15
  const types = new Map();
@@ -41,6 +42,9 @@ export const analyze = (source) => {
41
42
  });
42
43
  if (found.length > 0)
43
44
  evidence[name] = found;
45
+ const calls = ensureCallsIn(decl);
46
+ if (calls.length > 0)
47
+ ensures[name] = calls;
44
48
  }
45
49
  }
46
50
  const stateType = initialType === null ? undefined : types.get(initialType);
@@ -51,8 +55,78 @@ export const analyze = (source) => {
51
55
  stateDoc: stateType?.doc ?? null,
52
56
  fieldDocs: stateType === undefined ? {} : fieldDocsOf(stateType.members),
53
57
  evidence,
58
+ ensures,
54
59
  };
55
60
  };
61
+ // 理由が文字列リテラル(または式を含まないテンプレート)の ensure だけを集める。
62
+ // 理由を式で組み立てている ensure は、どの理由のときに外せばよいかを実行前に決められないため。
63
+ const ensureCallsIn = (root) => {
64
+ const calls = [];
65
+ const visit = (node) => {
66
+ if (Array.isArray(node))
67
+ return node.forEach(visit);
68
+ if (typeof node !== "object" || node === null || !("type" in node))
69
+ return;
70
+ const n = node;
71
+ if (n.type === "CallExpression" && n.callee.type === "Identifier" && n.callee.name === "ensure") {
72
+ const arg = n.arguments[1];
73
+ const reason = arg?.type === "StringLiteral"
74
+ ? arg.value
75
+ : arg?.type === "TemplateLiteral" && arg.expressions.length === 0
76
+ ? arg.quasis.map((q) => q.value.cooked ?? "").join("")
77
+ : null;
78
+ if (reason !== null && n.loc != null) {
79
+ calls.push({ reason, line: n.loc.start.line, ...(narrowsType(root, n) ? { narrowing: true } : {}) });
80
+ }
81
+ }
82
+ for (const [key, value] of Object.entries(n)) {
83
+ if (key === "loc" || key.endsWith("Comments"))
84
+ continue;
85
+ visit(value);
86
+ }
87
+ };
88
+ visit(root);
89
+ return calls;
90
+ };
91
+ // 判別 union の登場人物({ kind: "human"; via: … } | { kind: "worker" })では、via を読むために先に kind で型を絞る。
92
+ // この ensure は外しても振る舞いが変わらないことが多いが、消すと型が通らないので「重なり」とは別に扱う。
93
+ // 型チェッカーを使わず構文で見分けるので、比べた値と同じ名前の値の、別の項目を後ろで読んでいるかだけを見る。
94
+ const narrowsType = (root, call) => {
95
+ const cond = call.arguments[0];
96
+ if (cond?.type !== "BinaryExpression" || (cond.operator !== "===" && cond.operator !== "!=="))
97
+ return false;
98
+ const member = cond.right.type === "StringLiteral" ? cond.left : cond.left.type === "StringLiteral" ? cond.right : null;
99
+ if (member?.type !== "MemberExpression" || member.object.type !== "Identifier" || member.property.type !== "Identifier")
100
+ return false;
101
+ const object = member.object.name;
102
+ const discriminant = member.property.name;
103
+ let found = false;
104
+ const visit = (node) => {
105
+ if (found)
106
+ return;
107
+ if (Array.isArray(node))
108
+ return node.forEach(visit);
109
+ if (typeof node !== "object" || node === null || !("type" in node))
110
+ return;
111
+ const n = node;
112
+ if (n.type === "MemberExpression" &&
113
+ n.start > call.end &&
114
+ n.object.type === "Identifier" &&
115
+ n.object.name === object &&
116
+ n.property.type === "Identifier" &&
117
+ n.property.name !== discriminant) {
118
+ found = true;
119
+ return;
120
+ }
121
+ for (const [key, value] of Object.entries(n)) {
122
+ if (key === "loc" || key.endsWith("Comments"))
123
+ continue;
124
+ visit(value);
125
+ }
126
+ };
127
+ visit(root);
128
+ return found;
129
+ };
56
130
  const valueNamesOf = (decl) => {
57
131
  if (decl.type === "FunctionDeclaration" && decl.id != null)
58
132
  return [[decl.id.name, null]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yutaura/live-spec",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "AI が書き、人が見て理解できる「生きた仕様書」を作るツール。素の TypeScript で書いた仕様を実行し、状態遷移図・画面・できる/できない理由・検査結果をまとめた仕様書を生成する",
@@ -11,6 +11,12 @@
11
11
  "spec-driven-development",
12
12
  "wireframe"
13
13
  ],
14
+ "homepage": "https://github.com/yutaura-dev/live-spec#readme",
15
+ "bugs": "https://github.com/yutaura-dev/live-spec/issues",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/yutaura-dev/live-spec.git"
19
+ },
14
20
  "exports": {
15
21
  ".": {
16
22
  "types": "./dist/index.d.ts",
@@ -16,7 +16,8 @@ live-spec は npm パッケージ `@yutaura/live-spec`(`npm i -D @yutaura/live
16
16
  | Markdown を見る | `npx live-spec specs/`(spec が 1 つなら標準出力、複数なら `--out <ディレクトリ>`) |
17
17
  | HTML を書き出す | `npx live-spec specs/ --html --out spec.html` |
18
18
  | ブラウザで見ながら書く | `npx live-spec specs/ --serve` |
19
- | 変更前と比べる | `npx live-spec diff <file.spec.ts> [--base <リビジョン>]` |
19
+ | 変更前と比べる | `npx live-spec diff specs/ [--base <リビジョン>] [--head <リビジョン>] [--html --out <file>]` |
20
+ | 型チェックと検査(CI 向け) | `npx live-spec check specs/`(型の誤り・検査結果・未確認の確かめてほしい点があれば終了コード 1) |
20
21
 
21
22
  (live-spec リポジトリ自身の中では `pnpm spec ...`)
22
23
 
@@ -27,11 +28,7 @@ live-spec は npm パッケージ `@yutaura/live-spec`(`npm i -D @yutaura/live
27
28
 
28
29
  spec からは `import { ensure, ui, api, cli } from "@yutaura/live-spec"` で読み込む(live-spec リポジトリ自身の `specs/` と `examples/` だけは `../src/index.ts` から読み込む)。
29
30
 
30
- 型チェックは live-spec の実行とは別に行う(live-spec は型を消して実行するだけなので、型の誤りでは止まらない):
31
-
32
- ```sh
33
- npx tsc --noEmit --ignoreConfig --strict --module nodenext --moduleResolution nodenext --target es2024 --skipLibCheck <file.spec.ts>
34
- ```
31
+ 仕様書の生成(`live-spec specs/`)は型を消して実行するだけなので、型の誤りでは止まらない。書き終えたら `npx live-spec check specs/` で型チェックと検査をまとめて行う。型チェックには、実行したディレクトリから見える typescript を使う(monorepo で typescript が別の package にあるなら `--cwd <その package>`)。
35
32
 
36
33
  ## spec の形
37
34
 
@@ -43,7 +40,7 @@ npx tsc --noEmit --ignoreConfig --strict --module nodenext --moduleResolution no
43
40
  | `invariants` | | 不変条件。`{ 説明: (状態) => boolean }` |
44
41
  | `inputs` | | 3 つ目以降の引数の例。`{ 操作名: { 例の名前: [引数...] } }` |
45
42
  | `surface` | | `(状態, 登場人物) => 画面 \| null` |
46
- | `scenarios` | | `{ 名前: [{ do: 操作, by: "登場人物", input?: "例の名前", expect?: { 項目: 値 } }] }` |
43
+ | `scenarios` | | `{ 名前: [{ do: 操作, by: "登場人物", input?: "例の名前", expect?: { 項目: 値 }, denied?: "理由" }] }`。`denied` は「この手順は断られるはず」 |
47
44
  | `questions` | | `[{ ask, about?: 操作 \| { 項目: 値 }, note? }]` |
48
45
  | `links` | | `[{ from?: 操作, to: "相手の名前", action?: "相手の操作名", label }]` |
49
46
  | `decisions` | | `{ 名前: { decide: (入力) => 結果, cases: [{ input, expect? }] } }` |
@@ -60,6 +57,7 @@ npx tsc --noEmit --ignoreConfig --strict --module nodenext --moduleResolution no
60
57
  - 独立した項目(例: サーバの状態 × ブラウザのタブの状態 × 生成の結果)を 1 つの状態にまとめると、状態が組み合わせの数だけ増え、名前も `none · placeholder · listening · stale` のような読めないものになる。項目ごとに、それを持つドメインオブジェクトへ分ける
61
58
  - 分けたオブジェクトどうしの関係(「サーバが止まるとタブは古いまま残る」など)は、それぞれの spec の操作・条件・JSDoc に書く。1 つの状態機械にまとめ直さない
62
59
  - 状態の名前(ラベル)は、文字列の項目の値がそのまま使われる。`status: "受付待ち"` のように、読み手の言葉で値を付ける
60
+ - 名前に並ぶ項目は、`initial` に書いた順になる。読み手に最初に見せたい項目(ふつうは `status`)を先に書く
63
61
 
64
62
  ### 1. 状態には「振る舞いを変える値」だけを入れる
65
63
 
@@ -115,10 +113,36 @@ export const actors = {
115
113
 
116
114
  送料・割引・料金区分のように「入力の組み合わせ → 結果」で決まるルールは、状態遷移ではなく `decisions` に書く。判断の関数(`decide`)と入力の例(`cases`)を書くと、live-spec が実行して表にする。境界の値(4999 円と 5000 円など)を例に入れ、`expect` を付けておくと、期待と違うときに検査結果に出る。
117
115
 
116
+ ### 6.5 上限つきの回数は、振る舞いに効く区分だけを持つ
117
+
118
+ 再試行の上限(既定 3 回)のような回数を `attempt: 0 | 1 | 2 | 3` のまま状態に入れると、ほかの項目と掛け合わさって状態が増え、図が読めなくなる。振る舞いに効くのが「まだ残っている/いまが最後/使い切った」だけなら、その区分だけを状態に持ち、「次が最後になるか」は入力で与える。
119
+
120
+ ```ts
121
+ export type Run = {
122
+ status: "queued" | "running" | "failure";
123
+ /** 試行の残り。回数そのものではなく、振る舞いに効く区分だけを持つ */
124
+ retries: "残りあり" | "最後" | "使い切った";
125
+ };
126
+
127
+ export const inputs = { reserve: { まだ残る: [false], 次が最後: [true] } };
128
+
129
+ /** 試行を 1 回分予約する */
130
+ export function reserve(run: Run, worker: Worker, nextIsLast: boolean): Run {
131
+ ensure(run.retries !== "使い切った", "試行が残っているときだけ");
132
+ return { ...run, retries: run.retries === "最後" ? "使い切った" : nextIsLast ? "最後" : "残りあり" };
133
+ }
134
+ ```
135
+
136
+ この形では「まだ残る」を何度でも選べるので、spec は実際より多くの道筋を探索する(4 回目も「まだ残る」を選べる)。実際にありうる道筋は取りこぼさない、安全側の近似なので、袋小路や不変条件の違反を見落とすことはない。ただ、実際には起きない道筋も図に出る。上限に届くまでの流れを見せたいときは、シナリオに入力を明示して書く(「まだ残る」→「次が最後」→ 失敗)。
137
+
138
+ 回数そのものが振る舞いを変える(3 回目だけ人に知らせる、など)なら、回数を状態に入れる。そのときは、ほかの関心を別のドメインオブジェクトに分けて、状態の掛け合わせを減らす。
139
+
118
140
  ### 7. シナリオで業務の流れを書く
119
141
 
120
142
  状態の一覧だけでは業務の流れが読めない。代表的な流れ(正常系 1〜2 本と、差し戻し・やり直しのような分岐 1〜2 本)を `scenarios` に書く。各段階には操作の**関数**を渡し、要所に `expect` を書く。シナリオは初期状態から実行され、止まったり期待と違ったりすると検査結果に出るので、受け入れテストを兼ねる。シナリオ名は業務の言葉で(「書いて公開するまで」)。
121
143
 
144
+ 「できない」ことも、大事なものはシナリオに書く。手順に `denied: "理由"` を付けると「この手順は、この理由で断られるはず」という意味になり、実行できてしまうとシナリオが失敗する(`{ do: reject, by: "編集者eve", input: "理由が空", denied: "差し戻し理由が必要" }`)。入力の検証(「--html と --json は同時に指定できない」)や「誰が」の条件は、状態についての条件ではないので不変条件では書けない。こうした条件の意図は `denied` で書く。
145
+
122
146
  ### 8. 判断できないことは未決事項にする
123
147
 
124
148
  要件やコードから決められないこと(「アーカイブした記事を戻せるか?」)は、推測で spec に書かずに `questions` に書く。対象の操作(関数)か状態(`{ status: "archived" }`)を `about` に付けると、仕様書の図とカードに印が出る。人は未決事項だけを見れば判断すべき点が分かる。
@@ -150,6 +174,34 @@ export const actors = {
150
174
  | ボタンが見えるが実行できない/実行できるがボタンがない | 画面と操作の食い違い | 表示条件を ensure にそろえる。意図的なら `disabled` |
151
175
  | 状態数の上限で打ち切り | 値が増え続ける項目がある | その項目を状態から外すか、有限の値に抽象化する |
152
176
 
177
+ ## 「確かめてほしい点」の直し方
178
+
179
+ live-spec は spec を実行した結果から、条件の書き忘れ・書き間違いの候補を、仕様書の上部の「確かめてほしい点」に ID つきで出す。AI が書いた spec の漏れを見つける主な手がかりなので、1 件ずつ次の順で判断する。
180
+
181
+ | 候補 | 疑うこと |
182
+ |---|---|
183
+ | 誰でもできる(`anyone-can`) | 「〜だけ」の書き忘れ |
184
+ | いつでもできる(`anytime`) | 状態の条件の書き忘れ |
185
+ | 入力を見ていない(`ignores-input`) | 入力の検証の書き忘れ |
186
+ | 本人と別人を区別しない(`same-for-similar-actors`) | 「自分の〜だけ」の書き忘れ |
187
+ | 結果がまったく同じ入力の例・登場人物(`indistinguishable-*`) | 例や人を分けるはずの条件の書き忘れ。または、違いを状態として表していない |
188
+ | 目指す状態にたどり着けない(`cannot-reach-goal`) | 終端ではないのに抜け出せない袋小路。`export const goals = { 成功: (s) => s.status === "success" }` を書いたときだけ出る。書き起こしの spec では、実装が気づいていない袋小路であることが多い |
189
+ | どの可否にも影響しない項目(`unused-field`) | その項目を使う条件の書き忘れ。または、振る舞いに関係しない値を状態に入れている |
190
+ | 意図がほかに書かれていない条件(`unguarded`) | 外すと振る舞いが変わるのに、不変条件・シナリオ・画面のボタンのどれも気づかない条件 |
191
+
192
+ 1. **要件・コードと照らして、本当に漏れか**を確かめる。漏れなら spec を直す
193
+ 2. 意図どおりなら、**その意図をもう 1 か所に書けないか**を考える。状態についての性質なら不変条件、入力や「誰が」についてなら `denied` の手順を持つシナリオ(`unguarded` はこれで消える)
194
+ 3. それでも意図どおりで、書き足す意味のある性質がないなら、`export const reviewed = { "ID": "理由" }` に理由を書く。仕様書では「確認済み」として理由つきで残る
195
+ 4. 判断できないなら、未決事項(`questions`)にする
196
+
197
+ 候補を消すためだけに、中身のない不変条件やシナリオを書かない。`reviewed` の理由も「意図どおり」だけで済ませず、なぜそれでよいかを要件の言葉で書く(「カードはどの列からでも動かせる。アーカイブも API では動かせる(未決事項 6)」)。`reviewed` の ID が候補のどれにも当たらなくなると検査結果に出るので、そのときは消す。
198
+
199
+ ## 条件の理由と「通るのは」を突き合わせる
200
+
201
+ 操作の節の「条件」には、`ensure` ごとに「理由の文 — 通るのは〜のとき」が並ぶ。「通るのは」は、その `ensure` だけを効かせて実行して求めた事実。理由の文と食い違っていれば、条件か理由のどちらかが間違っている(「実行中のときだけ」— 通るのは status が queued のとき)。書き終えたら全部の条件について読み比べる。状態の取り違えのような書き間違いは、ほかの検査ではほとんど見つからない。
202
+
203
+ 「外しても振る舞いが変わらない(ほかの条件と重なっている)」条件は、できない理由の文言を分けたくて重ねているなら残してよい。そうでなければ消す。「(後の条件のために型を絞る条件)」と出るもの(判別 union の `actor.kind === "human"` のあとで `actor.via` を読む、など)は、消すと型が通らないので残す。
204
+
153
205
  ## 人への渡し方
154
206
 
155
207
  生成物(HTML)と一緒に、次を短く伝える。人は spec のコードを読まない前提で書く。
@@ -32,6 +32,8 @@ spec の書き方の規約は [live-spec-authoring](../live-spec-authoring/SKILL
32
32
 
33
33
  spec の各操作と ensure に、根拠となるコードの場所を `// 根拠: path:line(補足)` の形のコメントで残す。レビューする人が spec とコードを突き合わせられるようにするため。操作の関数の中に書いた根拠は、仕様書の操作カードにも「根拠」として表示される(絶対パスは書かない。共有したときに手元の環境が漏れるため)。
34
34
 
35
+ 根拠のパスは、spec のある git リポジトリのルートからの相対で書く。spec を対象のリポジトリの外(別のリポジトリなど)に置くときは、`export const evidenceRoot = "../my-app"`(spec のファイルからの相対)で起点を指定する。live-spec は根拠のファイルが無いとき・行がファイルの範囲の外にあるときに検査結果に出すので、コードが移動したり行がずれたりしたら、根拠を直す。
36
+
35
37
  ```ts
36
38
  /** 注文を確定する */
37
39
  export function confirm(order: Order, user: User): Order {
@@ -8,25 +8,29 @@ description: live-spec の spec(*.spec.ts)の変更を、コードの差分
8
8
  spec の差分(TypeScript の diff)をそのまま読ませても、人には振る舞いの変化が分からない。`ensure` の 1 行の変更が「閲覧者が公開できるようになった」という重大な変化だったりする。この skill では、変更前と変更後の spec をそれぞれ live-spec で**実行**し、結果を比べて「振る舞いの変化」として報告する。
9
9
 
10
10
  ## 差分を取る
11
-
12
- `live-spec diff` を使う。変更前の spec(git のリビジョン時点)と作業ツリーの spec を、どちらも実行して比べる。
11
+ `live-spec diff` を使う。変更前と変更後の spec を、どちらも実行して比べる。ディレクトリを渡せば、ドメインオブジェクトごとに「追加・削除・変更・変化なし」を判定する。
13
12
 
14
13
  ```sh
15
14
  # 作業ツリーの spec と HEAD を比べる
16
- npx live-spec diff specs/order.spec.ts
15
+ npx live-spec diff specs/
16
+
17
+ # PR のように、ブランチ同士を比べる(--head を省くと作業ツリー)
18
+ npx live-spec diff specs/ --base origin/main --head HEAD
17
19
 
18
- # PR のように、分岐元と比べる
19
- npx live-spec diff specs/order.spec.ts --base "$(git merge-base origin/main HEAD)"
20
+ # 人に見せるなら HTML(重ね合わせた状態遷移図と、画面の変更前・変更後が並ぶ)
21
+ npx live-spec diff specs/ --base origin/main --html --out spec-diff.html
20
22
  ```
21
23
 
22
- 出力には次が含まれる。状態はラベルで比べる(ID は探索順で振り直されるため)。
24
+ 出力には次が含まれる。状態は値で比べる(ID は探索順で振り直され、名前は `initial` の書き順で変わるため)。
23
25
 
26
+ - ドメインオブジェクトごとのまとめの表
27
+ - 変更前と変更後を重ねた状態遷移図(増えた・消えた・通れる人が変わった遷移)
24
28
  - 操作・状態・遷移の増減
25
- - 同じ「状態 × 操作 × 登場人物(× 入力)」で、できる/できない、または理由が変わったもの
26
- - 検査結果の増減
29
+ - できる/できないが入れ替わったもの。できない理由の言い方だけが変わったものは、別にまとめて件数を出す
30
+ - シナリオ・未決事項・検査結果の増減(検査結果は、最短の手順だけが変わったものは差分にしない)
27
31
  - 画面が変わった状態と登場人物
28
32
 
29
- spec が複数あるときは、変わった spec ごとに実行する(`git diff --name-only <base> -- '*.spec.ts'` で一覧を出す)。
33
+ spec が相対パスで import している別ファイル(共通の型など)は、変更前の側でも作業ツリーの版が使われる。そのファイルを変えた PR では、差分を割り引いて読む。
30
34
 
31
35
  ## 読み方
32
36
 
@@ -35,7 +39,9 @@ spec が複数あるときは、変わった spec ごとに実行する(`git d
35
39
  1. **権限が広がった変化**: ❌ から ✅ に変わった行。特に「誰が」の理由(「編集者だけ」など)が消えたもの。意図しない権限の拡大はバグになりやすい
36
40
  2. **消えた状態・遷移**: それまでできた業務ができなくなっていないか
37
41
  3. **新しい検査結果**: 不変条件の違反、画面と操作の食い違いなど
38
- 4. **画面の変化**: 状態と見る人を挙げ、HTML で確認してもらう(`npx live-spec <dir> --serve` で開き、`#/<名前>/<状態>` で直接開ける)
42
+ 4. **確かめてほしい点**: 仕様書の上部の一覧(誰でもできる・いつでもできる・本人と別人を区別しない、意図がほかに書かれていない条件、など)。変更で増えたものは、条件の書き忘れの候補として必ず挙げる。`reviewed` に足された理由も、要件として妥当かを確かめる
43
+ 5. **理由と「通るのは」の食い違い**: 変更した操作の「条件」の各行で、理由の文と「通るのは〜のとき」を読み比べる。食い違う行は、条件か理由の書き間違いとして必ず挙げる
44
+ 6. **画面の変化**: 状態と見る人を挙げ、HTML で確認してもらう(`npx live-spec <dir> --serve` で開き、`#/<名前>/<状態>` で直接開ける)
39
45
 
40
46
  spec のコードの差分(`git diff`)は、変化の理由を説明するときの補足として読む。
41
47