@shanyucoder/flowgrid 0.1.11 → 0.1.13

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 (83) hide show
  1. package/adapters/shared/resolve-hub-id.mjs +5 -1
  2. package/dist/docs/mcp/tools.js +59 -6
  3. package/dist/docs/mcp/tools.js.map +1 -1
  4. package/dist/docs/scan/screen-to-flows.d.ts +3 -0
  5. package/dist/docs/scan/screen-to-flows.js +18 -0
  6. package/dist/docs/scan/screen-to-flows.js.map +1 -0
  7. package/engines/docs/lib/render-bundle-markdown.mjs +19 -0
  8. package/engines/docs/lib/render-design-markdown.mjs +56 -0
  9. package/engines/docs/lib/screen-to-flows-index.mjs +121 -0
  10. package/engines/docs/vitepress/surfaces-nav.mjs +7 -0
  11. package/engines/spec/lib/audit-bundle-gaps.mjs +15 -3
  12. package/engines/spec/lib/audit-interaction-cases.mjs +186 -0
  13. package/engines/spec/lib/bundle-ir.mjs +7 -0
  14. package/engines/spec/lib/bundle-schema.mjs +1 -0
  15. package/engines/spec/lib/interaction-cases.mjs +46 -0
  16. package/engines/spec/split-bundle.mjs +1 -1
  17. package/harness/be/adapters/dotnet-integration/skills/framework-rules-be/SKILL.md +2 -2
  18. package/harness/be/adapters/fastapi/skills/framework-rules-be/SKILL.md +3 -3
  19. package/harness/be/adapters/laravel/skills/framework-rules-be/SKILL.md +3 -3
  20. package/harness/be/skills/api/SKILL.md +4 -4
  21. package/harness/be/skills/api-unit/SKILL.md +4 -4
  22. package/harness/be/skills/audit-api/SKILL.md +3 -3
  23. package/harness/be/skills/grill-api-unit/SKILL.md +2 -2
  24. package/harness/common/rules/artifactgraph.mdc +2 -2
  25. package/harness/common/rules/cross-repo-index.mdc +2 -2
  26. package/harness/common/rules/platform-code-size.mdc +5 -5
  27. package/harness/common/rules/team-flow-harness-state.mdc +4 -4
  28. package/harness/common/skills/business-impact-review/SKILL.md +1 -1
  29. package/harness/common/skills/configure-repo-maps/SKILL.md +1 -1
  30. package/harness/common/skills/docs-mark/SKILL.md +4 -4
  31. package/harness/docs/extracts/agent-design-context.md +136 -0
  32. package/harness/docs/extracts/extract-registry.docs.json +9 -3
  33. package/harness/docs/extracts/ir-read-only.md +42 -0
  34. package/harness/docs/rules/agent-compliance.mdc +5 -1
  35. package/harness/docs/rules/docs-hub.mdc +6 -6
  36. package/harness/docs/rules/flowgrid-process.mdc +5 -5
  37. package/harness/docs/rules/team-flow-grill.mdc +1 -1
  38. package/harness/docs/rules/team-flow-spec.mdc +5 -5
  39. package/harness/docs/skills/adopt/SKILL.md +1 -1
  40. package/harness/docs/skills/api/SKILL.md +2 -2
  41. package/harness/docs/skills/api-spec/SKILL.md +4 -0
  42. package/harness/docs/skills/build-templates/SKILL.md +1 -1
  43. package/harness/docs/skills/call-external/SKILL.md +1 -1
  44. package/harness/docs/skills/cross-entity-service/SKILL.md +1 -1
  45. package/harness/docs/skills/db-erd/SKILL.md +2 -2
  46. package/harness/docs/skills/grill/SKILL.md +1 -1
  47. package/harness/docs/skills/grill-api-spec/SKILL.md +3 -3
  48. package/harness/docs/skills/grill-bqa/SKILL.md +2 -2
  49. package/harness/docs/skills/grill-dev/SKILL.md +31 -13
  50. package/harness/docs/skills/grill-docs/SKILL.md +2 -2
  51. package/harness/docs/skills/grill-hub-prd/SKILL.md +1 -1
  52. package/harness/docs/skills/openapi/SKILL.md +3 -3
  53. package/harness/docs/skills/risk-register/SKILL.md +8 -8
  54. package/harness/docs/skills/spec/SKILL.md +20 -12
  55. package/harness/docs/skills/update-spec/SKILL.md +17 -7
  56. package/harness/docs/skills/user-flow/SKILL.md +4 -2
  57. package/harness/fe/adapters/dotnet-line/skills/framework-rules/SKILL.md +2 -2
  58. package/harness/fe/adapters/nextjs/skills/framework-rules/SKILL.md +2 -2
  59. package/harness/fe/adapters/nuxt4/skills/framework-rules/SKILL.md +2 -2
  60. package/harness/fe/rules/cross-repo-index-routing.mdc +1 -1
  61. package/harness/fe/rules/flowgrid-test-optional-accelerators.mdc +3 -3
  62. package/harness/fe/rules/team-flow-prototype.mdc +13 -13
  63. package/harness/fe/rules/team-flow-unit.mdc +6 -6
  64. package/harness/fe/skills/grill-prototype/SKILL.md +2 -2
  65. package/harness/fe/skills/grill-test/SKILL.md +1 -1
  66. package/harness/fe/skills/grill-unit/SKILL.md +2 -2
  67. package/harness/fe/skills/grill-wire/SKILL.md +1 -1
  68. package/harness/fe/skills/model/SKILL.md +4 -4
  69. package/harness/fe/skills/prototype/SKILL.md +23 -11
  70. package/harness/fe/skills/test/SKILL.md +3 -3
  71. package/harness/fe/skills/unit/SKILL.md +4 -4
  72. package/harness/fe/skills/wire/SKILL.md +5 -5
  73. package/harness/shared/rules/flowgrid-code-optional-integrations.mdc +7 -7
  74. package/harness/tests/rules/cross-repo-index-routing.mdc +1 -1
  75. package/harness/tests/rules/flowgrid-test-optional-accelerators.mdc +3 -3
  76. package/harness/tests/rules/plans-docs-first.mdc +5 -5
  77. package/harness/tests/skills/grill-testcase/SKILL.md +4 -4
  78. package/harness/tests/skills/scenario/SKILL.md +3 -3
  79. package/harness/tests/skills/testcase/SKILL.md +2 -2
  80. package/package.json +1 -1
  81. package/templates/shared/bundle-authoring.md +13 -6
  82. package/templates/shared/default-layout.ejs +47 -2
  83. package/templates/shared/feature.bundle.yaml +29 -1
@@ -1,15 +1,15 @@
1
1
  ---
2
- description: bộ code-owned fallback and telemetry for optional integrations
2
+ description: code repo-owned fallback and telemetry for optional integrations
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- # bộ code optional integrations
6
+ # code repo optional integrations
7
7
 
8
8
  ArtifactGraph and CodeGraph are optional accelerators. Their absence or
9
- unavailability must never abort a bộ code-owned generation, dry-run,
9
+ unavailability must never abort a code repo-owned generation, dry-run,
10
10
  validation, or review.
11
11
 
12
- Full cross-repo routing (architecture → bộ docs, IR → pointer roots, symbols →
12
+ Full cross-repo routing (architecture → docs hub, IR → pointer roots, symbols →
13
13
  per-repo `codegraph-<key>`) lives in `cross-repo-index-routing.mdc`.
14
14
 
15
15
  ## Docs registry hub
@@ -20,11 +20,11 @@ per-repo `codegraph-<key>`) lives in `cross-repo-index-routing.mdc`.
20
20
  - ArtifactGraph in an FE/BE repo indexes that repo only; it does **not** follow
21
21
  `FLOWGRID_DOCS_ROOT` and must not be used as the bridge to docs.
22
22
  - Use ArtifactGraph only for local allowlist/tag hints. Missing local
23
- ArtifactGraph never changes where bộ code reads canonical docs input.
24
- - bộ docs, when installed as a consumer, uses its separate `FLOWGRID_DOCS_ROOT`
23
+ ArtifactGraph never changes where code repo reads canonical docs input.
24
+ - docs hub, when installed as a consumer, uses its separate `FLOWGRID_DOCS_ROOT`
25
25
  pointer for architecture ID/path queries — never CodeGraph for C4.
26
26
  - CodeGraph, when used, must be the Platform DNA-wired `codegraph-<repo-key>`
27
- for that checkout. bộ code never writes those MCP entries itself. Missing
27
+ for that checkout. code repo never writes those MCP entries itself. Missing
28
28
  or unindexed checkouts fall back and emit telemetry; never invent a graph or
29
29
  `codegraph init` a workspace parent.
30
30
 
@@ -5,7 +5,7 @@ alwaysApply: true
5
5
 
6
6
  # Cross-repo index routing
7
7
 
8
- - Architecture IDs and Functions/W-* paths belong to bộ docs through `FLOWGRID_DOCS_ROOT`.
8
+ - Architecture IDs and Functions/W-* paths belong to docs hub through `FLOWGRID_DOCS_ROOT`.
9
9
  Never use CodeGraph as the architecture index.
10
10
  - Test plans use `FLOWGRID_TESTS_DOC`; docs evidence uses
11
11
  `FLOWGRID_DOCS_ROOT`; IR/registry/generation follows its owning pointer such as
@@ -1,9 +1,9 @@
1
1
  ---
2
- description: bộ test optional accelerator fallback and event contract
2
+ description: tests hub optional accelerator fallback and event contract
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- # bộ test optional accelerators
6
+ # tests hub optional accelerators
7
7
 
8
8
  ArtifactGraph accelerates coverage and search but is never required. When it is
9
9
  missing or fails, continue with deterministic local coverage/search. Assign one
@@ -13,7 +13,7 @@ stable `runId` per run and emit exactly one `flowgrid.missing-optional` event pe
13
13
  ArtifactGraph is local-only: in this repo it indexes this repo's own data
14
14
  (taxonomy/coverage hints) and never follows `FLOWGRID_DOCS_ROOT` or
15
15
  `FLOWGRID_TESTS_DOC`. Canonical docs/tests-hub evidence always flows through
16
- those bộ test pointers, never through ArtifactGraph.
16
+ those tests hub pointers, never through ArtifactGraph.
17
17
 
18
18
  Events must conform to
19
19
  `.cursor/schemas/flowgrid-test/missing-optional-event.schema.json`. Metrics count only
@@ -6,8 +6,8 @@ alwaysApply: false
6
6
 
7
7
  # Plans — docs-first
8
8
 
9
- - **Rule / acceptance SSOT = docs hub.** Tests hub chỉ `refs.rule` (id + link). Không copy nội dung rule vào YAML để “sửa cho tiện”.
10
- - Grill thấy **scope hở / rule mơ hồ** → handoff docs (`/update-spec`, grill-docs). **Không** vá bằng testcase.
11
- - Chỉ thêm/sửa `TC-*` khi docs đã rõ và thiếu **bao phủ** (`coverage`).
12
- - YAML = máy (gen Playwright). MD = member đọc đối chiếu docs.
13
- - Chi tiết: `landscape/NOTE-testing-architecture.md`.
9
+ - **Rule / acceptance SSOT = docs hub.** Tests hub only `refs.rule` (id + link). Do not copy rule content into YAML for convenience edits.
10
+ - When grill finds **open scope / vague rules** → hand off to docs (`/update-spec`, grill-docs). Do **not** patch via testcase.
11
+ - Add or edit `TC-*` only when docs are clear and **coverage** is missing.
12
+ - YAML = machine (Playwright gen). MD = member reads against docs.
13
+ - Details: `landscape/NOTE-testing-architecture.md`.
@@ -10,11 +10,11 @@ disable-model-invocation: true
10
10
 
11
11
  # /grill-testcase
12
12
 
13
- **Owner:** bộ test (`--type=tests`)
13
+ **Owner:** tests hub (`--type=tests`)
14
14
 
15
- Audit plans only. Spec holes hand off to docs-hub `/update-spec` or `/grill-bqa` (bộ docs), never invent acceptance. **[MANDATORY]** When handing off, you MUST output a comprehensive gap report in the Chat Thread formatted as a complete, ready-to-use prompt starting with `/docs-hub` (e.g., `/docs-hub /update-spec [details...]`). This prompt must detail exactly what business rules or coverage are missing, enabling the user to copy-paste it directly to run the docs-hub skill.
15
+ Audit plans only. Spec holes hand off to docs-hub `/update-spec` or `/grill-bqa` (docs hub), never invent acceptance. **[MANDATORY]** When handing off, you MUST output a comprehensive gap report in the Chat Thread formatted as a complete, ready-to-use prompt starting with `/docs-hub` (e.g., `/docs-hub /update-spec [details...]`). This prompt must detail exactly what business rules or coverage are missing, enabling the user to copy-paste it directly to run the docs-hub skill.
16
16
 
17
- Route Functions/W-* evidence through bộ docs and symbol/call-graph evidence
17
+ Route Functions/W-* evidence through docs hub and symbol/call-graph evidence
18
18
  for repo X through its Platform DNA-wired `codegraph-<repo-key>` server. Use
19
19
  `FLOWGRID_DOCS_ROOT` / `FLOWGRID_TESTS_DOC` for pointer evidence; never build or
20
20
  query a workspace-parent graph.
@@ -47,7 +47,7 @@ else: local deterministic coverage/search over targeted plan/docs evidence
47
47
  ```
48
48
 
49
49
  ArtifactGraph indexes this tests hub only; spec-hole handoffs go to docs-hub
50
- `/update-spec` (bộ docs), not through ArtifactGraph.
50
+ `/update-spec` (docs hub), not through ArtifactGraph.
51
51
 
52
52
  Use one stable `runId` per run. When ArtifactGraph is missing, finish the local
53
53
  fallback before emitting exactly one `flowgrid.missing-optional` event for that
@@ -9,11 +9,11 @@ disable-model-invocation: true
9
9
 
10
10
  # /scenario
11
11
 
12
- **Owner:** bộ test (`--type=tests`)
12
+ **Owner:** tests hub (`--type=tests`)
13
13
 
14
14
  Author cross-flow scenarios (SC) on the current tests hub. Design rules stay on the docs hub.
15
15
 
16
- Scenarios test a **user flow** (`FLOW-*`) that spans multiple screens (`W-*`) or modules. They mirror the docs FLOW file **after** bộ docs LCA `common/` placement (not a flat `common/` tree).
16
+ Scenarios test a **user flow** (`FLOW-*`) that spans multiple screens (`W-*`) or modules. They mirror the docs FLOW file **after** docs hub LCA `common/` placement (not a flat `common/` tree).
17
17
 
18
18
  ## Output Rules
19
19
 
@@ -29,7 +29,7 @@ Scenarios test a **user flow** (`FLOW-*`) that spans multiple screens (`W-*`) or
29
29
  ## Target / ID Resolution Rule
30
30
 
31
31
  - **[MANDATORY]** Agent MUST locate the **`FLOW-*.md`** file on the docs hub (`FLOWGRID_DOCS_ROOT`) via `flowgrid_docs_route` / `flowgrid_docs_get_element` / glob. Filenames are `FLOW-…md`, not `flow-*`.
32
- - Search in this order (same LCA as bộ docs `common-scope.md`):
32
+ - Search in this order (same LCA as docs hub `common-scope.md`):
33
33
  1. `surfaces/<surface>/<CMP-id>/<NN>/common/user-flows/FLOW-*.md` (cluster)
34
34
  2. `surfaces/<surface>/<CMP-id>/common/user-flows/FLOW-*.md` (module)
35
35
  3. `surfaces/<surface>/common/user-flows/FLOW-*.md` (surface)
@@ -11,7 +11,7 @@ disable-model-invocation: true
11
11
 
12
12
  # /testcase — E2E Test Case Authoring (Tests Hub)
13
13
 
14
- **Owner:** bộ test (`--type=tests`). Design rules stay on docs hub. Playwright generation is FE `/test`.
14
+ **Owner:** tests hub (`--type=tests`). Design rules stay on docs hub. Playwright generation is FE `/test`.
15
15
 
16
16
  ---
17
17
 
@@ -79,7 +79,7 @@ disable-model-invocation: true
79
79
  ## Rule: Route Cross-Repo Evidence
80
80
 
81
81
  - **[MANDATORY]** Route evidence by owner:
82
- - Functions/`W-*` → bộ docs
82
+ - Functions/`W-*` → docs hub
83
83
  - Plan/docs → `FLOWGRID_TESTS_DOC` / `FLOWGRID_DOCS_ROOT`
84
84
  - Symbols for repo X → `codegraph-<repo-key>` (Platform DNA-wired server)
85
85
  - **[STRICTLY FORBIDDEN]** Never query one workspace-wide graph. Never hand-edit MCP config.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shanyucoder/flowgrid",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Unified Local MCP Toolkit (Graph, DNA, Docs, Test, Codegen)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,7 +10,8 @@ Hub: `docs/templates/feature.bundle.yaml` · split: `pnpm spec:split`
10
10
  | `summary` | Phải trình bày dạng bullet. Bắt buộc có các tiêu đề (chuẩn Arc42 business): **mục tiêu nghiệp vụ** (business_goals), **các bên liên quan** (stakeholders), **kịch bản người dùng** (user_journey), **bối cảnh** (description, input liên kết cross-page/module, output) và **cách giải quyết** (tùy chọn). Mục đích để 100% Non-tech Stakeholder hiểu và duyệt. |
11
11
  | `scopeIn` | **Khuyến nghị** — trong phạm vi màn/phase (PRD). Audit `WARN_NO_SCOPE_IN`. |
12
12
  | `nonGoals` | **Khuyến nghị** — ngoài phạm vi màn/phase (PRD). Audit `WARN_NO_NON_GOALS`. |
13
- | `userFlows` | **Khuyến nghị** — link `FLOW-*` (`03-user-flows` / `common/user-flows`) hoặc journey ngắn. Audit `WARN_NO_USER_FLOWS` khi multi-screen. |
13
+ | `userFlows` | **Recommended** — `FLOW-* — role: … — screens: W-* (this leaf)`; agents read linked `FLOW-*.md` §6 before codegen (`agent-design-context.md`). |
14
+ | `interactionCases` | **Optional L2** — `policy` + `items[]` (`IC-*`, `description`, `sequenceDiagram`); split → `spec.md` + `ir/generated/design.md`. Audit `CONFIRM_INTERACTION_CASES_POLICY`. |
14
15
  | `nfr` | **Khuyến nghị** — hiệu năng, bảo mật. Audit `WARN_NO_NFR`. |
15
16
  | _(rủi ro)_ | **Không** khai báo trên bundle. SSOT: `architecture/11-risks/risk-register.md` — `/risk-register`. Key `risks:` → audit `WARN_BUNDLE_RISKS_FORBIDDEN`. |
16
17
  | `userStories` | **Khối User Stories chuyên sâu cho màn hình:** `primary`, `contextAndHandoff` (+ `screenAccess`), `scenarios` (5 kịch bản chuẩn + **scenario thứ 6 “Affordances UX”** khi màn có delete/filter/breadcrumb/disabled/import — xem `feature.bundle.yaml`), `acceptanceCriteria` (kèm checkbox UX khi áp dụng). **Split:** `pnpm spec:split` copy nguyên khối sang `ir/spec.yaml` (business prose); **không** tự sinh từ `design` — Agent phải cập nhật `userStories` khi bổ sung DSL/`#needs-component`/audit `UX_*`. Render → `## User Stories & Screen Journey` trong Markdown. |
@@ -97,7 +98,7 @@ Authoring (`/spec`, grill-*) still **writes** `*.bundle.yaml`, then split.
97
98
 
98
99
  ### UX affordance ↔ `userStories` (before `pnpm spec:split`)
99
100
 
100
- | Design / audit signal | Business layer (`userStories` → `ir/spec.yaml`) |
101
+ | Design / audit signal | `flowgrid audit spec` on **bundle**; `userStories` / `interactionCases` authored on bundle → split copies to `ir/spec.yaml` |
101
102
  |----------------------|--------------------------------------------------|
102
103
  | `design.nav.breadcrumb`, `CONFIRM_UX_BREADCRUMB_*` | Scenario **Initial Load** + scenario **Affordances UX**; AC deep link |
103
104
  | `spec.ui.list.filters`, `CONFIRM_UX_FILTER_*` | Scenario **Initial Load** / **Affordances UX**; AC empty “no results” |
@@ -109,14 +110,20 @@ Authoring (`/spec`, grill-*) still **writes** `*.bundle.yaml`, then split.
109
110
 
110
111
  **Không** chỉ ghi tech vào `design.actions` — stakeholder đọc `ir/spec.yaml` / rendered MD phải thấy cùng hành vi.
111
112
 
113
+ ### SSOT loop (agents + members) — English
114
+
115
+ **Write:** `*.bundle.yaml` only → `flowgrid split` → `flowgrid render`.
116
+ **Read-only:** `ir/spec.yaml`, `ir/design.yaml`, `ir/generated/*` (review **`ir/generated/spec.md`** on VitePress).
117
+ **Fix gaps:** `/update-spec` on bundle — not IR edits, not `spec:merge`. Extract: `ir-read-only.md`.
118
+
112
119
  | Artifact | Đọc bởi | Nội dung |
113
120
  |----------|---------|----------|
114
- | `*.bundle.yaml` | **Ghi** `/spec`, grill-*; **đọc cả file** `/testcase`, `/grill-testcase` | Đầy đủ spec+gen+design+`userStories`; tests hub read-only |
115
- | `ir/design.yaml` | **Đọc cả file** — grill-*, FE `/prototype`, codegen | Tech sau split; `api` chiếu từ 01. |
116
- | `ir/spec.yaml` | VitePress + stakeholder | Business page + requirements/acceptance. Không id/tag/bind. `"Q&A"`. Không stub `legacy` rỗng. |
121
+ | `*.bundle.yaml` | **Ghi** `/spec`, `/update-spec`, grill-*; **đọc cả file** `/testcase`, `/grill-testcase` | Đầy đủ spec+gen+design+`userStories`; tests hub read-only |
122
+ | `ir/design.yaml` | **Chỉ đọc** — grill-*, FE `/prototype`, codegen | Split output; **không sửa file** |
123
+ | `ir/spec.yaml` | **Chỉ đọc** — agent/stakeholder mirror | Business prose sau split; **không sửa file** |
117
124
  | `…/api/<seq>/01-backend-spec.yaml` | BE `/api`, `openapi_gen`, **author API** | Tech BE — SSOT duy nhất cho endpoint |
118
125
  | `ir/generated/data-model.md` | BA/lead/BE review | Bảng/cột theo `schema` (multi-table); sinh từ `ir/design.yaml` |
119
- | `ir/generated/spec.md` · `ir/generated/api.md` | BA/QA/Dev review (VitePress) | Render từ `ir/spec.yaml` + `01`; hướng dẫn API: [tpl-api-contract.md](./tpl-api-contract.md) |
126
+ | `ir/generated/spec.md` · `ir/generated/design.md` · `ir/generated/api.md` | BA/QA/Dev review (VitePress) — **chỉ đọc** | Render từ split; sửa → bundle + `/update-spec` + split + render |
120
127
 
121
128
  Không còn `ir/legacy.yaml`. `legacy:` trên `ir/spec.yaml` chỉ khi có evidence thật.
122
129
 
@@ -7,6 +7,13 @@
7
7
  const hasStories = !!spec.userStories;
8
8
  const hasNfr = spec.nfr && String(spec.nfr).trim();
9
9
  const hasUserFlows = spec.userFlows && String(spec.userFlows).trim();
10
+ const icBlock = spec.interactionCases;
11
+ const icItems = icBlock && Array.isArray(icBlock.items) ? icBlock.items : [];
12
+ const hasInteractionCases =
13
+ icBlock &&
14
+ (icBlock.policy === 'skip' ||
15
+ icItems.length > 0 ||
16
+ (icBlock.policy === 'required' && icItems.length === 0));
10
17
  const qaOpen = spec['Q&A'] && String(spec['Q&A']).trim();
11
18
  const hasEntities = spec.entities && (Array.isArray(spec.entities) ? spec.entities.length : true);
12
19
  const pageSections = spec.sections || spec.design?.sections || [];
@@ -34,8 +41,9 @@
34
41
  if (hasNonGoals) addToc('Out of scope', 'scope-out');
35
42
  if (hasStories) addToc('User stories & requirements', 'user-stories--screen-journey');
36
43
  addToc('Data & integrations / API', 'data-integrations');
37
- if (hasUserFlows) addToc('User flows', 'user-flows');
44
+ if (hasUserFlows) addToc('Linked user flows (FLOW)', 'user-flows');
38
45
  if (hasNfr) addToc('Non-functional (NFR)', 'nfr');
46
+ if (hasInteractionCases) addToc('Interaction cases', 'interaction-cases');
39
47
  if (hasState) addToc('State & permissions matrix', 'state--permission-matrix');
40
48
  if (hasListColumns) addToc('List columns', 'list-columns');
41
49
  if (hasListExtras) addToc('Filters & pagination', 'list-filters-pagination');
@@ -213,7 +221,11 @@ Backend contract: `api/<seq>/01-backend-spec.yaml` on the same function leaf (no
213
221
  <% } %>
214
222
 
215
223
  <% if (hasUserFlows) { %>
216
- ## User flows {#user-flows}
224
+ ## Linked user flows (FLOW) {#user-flows}
225
+
226
+ Use product journey docs (`FLOW-*.md`) — include §6 sequence. Convention per line:
227
+
228
+ `FLOW-<id> — role: entry|step-N-*|exit — screens: W-* … (this leaf)`
217
229
 
218
230
  <%= spec.userFlows %>
219
231
 
@@ -226,6 +238,39 @@ Backend contract: `api/<seq>/01-backend-spec.yaml` on the same function leaf (no
226
238
 
227
239
  <% } %>
228
240
 
241
+ <% if (hasInteractionCases) { %>
242
+ ## Interaction cases {#interaction-cases}
243
+
244
+ <% if (icBlock.policy === 'skip') { %>
245
+ _Screen interaction sequences skipped:_ <%= icBlock.skipReason || '(no reason given)' %>
246
+
247
+ <% } else { %>
248
+ > Sequence diagrams: [design.md](./design.md) (generated). Authoring: `interactionCases` on `*.bundle.yaml`.
249
+
250
+ <% for (const item of icItems) { %>
251
+ ### <%= item.id || 'IC-?' %> {#<%= String(item.id || 'ic').toLowerCase() %>}
252
+
253
+ <% if (item.title) { %>**<%= item.title %>**
254
+
255
+ <% } %>
256
+ <% if (item.description) { %>
257
+ <%= item.description %>
258
+
259
+ <% } %>
260
+ <% if (item.links && typeof item.links === 'object') { %>
261
+ | Link | Value |
262
+ | --- | --- |
263
+ <% for (const [k, v] of Object.entries(item.links)) { %>
264
+ | `<%= k %>` | <%= v %> |
265
+ <% } %>
266
+
267
+ <% } %>
268
+ [View sequence diagram](./design.md#<%= String(item.id || 'ic').toLowerCase() %>)
269
+
270
+ <% } %>
271
+ <% } %>
272
+ <% } %>
273
+
229
274
  <%
230
275
  const page = {
231
276
  nav: spec.nav || spec.design?.nav,
@@ -26,7 +26,35 @@ nonGoals: |
26
26
  - [VD: không export Excel tại màn list — defer QA/debt]
27
27
 
28
28
  userFlows: |
29
- - [Luồng người dùng — link FLOW-* trong architecture/03-user-flows hoặc common/user-flows]
29
+ - FLOW-checkout — role: step-3-ops — screens: W-ADM-ORD-01 (this leaf)
30
+ # Journey SSOT: FLOW-*.md (§6 sequenceDiagram) — read via userFlows before codegen
31
+
32
+ # Optional — màn nhiều state / case trên một W-* (L2). Không thay FLOW-*.md.
33
+ # interactionCases:
34
+ # policy: required
35
+ # items:
36
+ # - id: IC-SUBMIT-HAPPY
37
+ # title: "Lưu từ DRAFT"
38
+ # description: |
39
+ # User bấm Lưu; form hợp lệ; chuyển trạng thái.
40
+ # links:
41
+ # actionId: btn_save_record
42
+ # recordStatus: DRAFT
43
+ # sequenceDiagram: |
44
+ # sequenceDiagram
45
+ # actor U as User
46
+ # participant W as [W-ADM-ORD-01]
47
+ # U->>W: Submit
48
+ # - id: IC-SUBMIT-409
49
+ # title: "Conflict"
50
+ # description: |
51
+ # Optimistic lock conflict — giữ form, reload.
52
+ # links:
53
+ # actionId: btn_save_record
54
+ # sequenceDiagram: |
55
+ # sequenceDiagram
56
+ # U->>W: Submit
57
+ # W-->>U: 409 message
30
58
 
31
59
  nfr: |
32
60
  - **Hiệu năng:** [VD: danh sách < 2s với 10k bản ghi — phân trang server]