@shanyucoder/flowgrid 0.1.10 → 0.1.12

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 (76) hide show
  1. package/adapters/nextjs/codegen/runners/lib/resolve-hub-id.mjs +7 -4
  2. package/adapters/nextjs/unitgen/runners/README.md +4 -4
  3. package/adapters/nextjs/unitgen/runners/generate.mjs +1 -1
  4. package/adapters/nuxt4/codegen/runners/lib/resolve-hub-id.mjs +7 -4
  5. package/adapters/nuxt4/unitgen/runners/README.md +4 -4
  6. package/adapters/nuxt4/unitgen/runners/generate.mjs +1 -1
  7. package/adapters/shared/common-gen.mjs +1 -1
  8. package/adapters/shared/resolve-hub-id.mjs +12 -5
  9. package/dist/docs/mcp/tools.js +59 -6
  10. package/dist/docs/mcp/tools.js.map +1 -1
  11. package/dist/docs/scan/ids.js +3 -2
  12. package/dist/docs/scan/ids.js.map +1 -1
  13. package/dist/docs/scan/screen-to-flows.d.ts +3 -0
  14. package/dist/docs/scan/screen-to-flows.js +18 -0
  15. package/dist/docs/scan/screen-to-flows.js.map +1 -0
  16. package/dist/graph/mcp/tools.js +1 -1
  17. package/dist/graph/mcp/tools.js.map +1 -1
  18. package/engines/cases/render-cases.mjs +1 -1
  19. package/engines/docs/lib/render-bundle-markdown.mjs +19 -0
  20. package/engines/docs/lib/render-design-markdown.mjs +56 -0
  21. package/engines/docs/lib/screen-to-flows-index.mjs +121 -0
  22. package/engines/docs/vitepress/surfaces-nav.mjs +7 -0
  23. package/engines/spec/lib/audit-bundle-gaps.mjs +15 -3
  24. package/engines/spec/lib/audit-interaction-cases.mjs +185 -0
  25. package/engines/spec/lib/audit-legacy-gaps.mjs +10 -0
  26. package/engines/spec/lib/bundle-ir.mjs +7 -0
  27. package/engines/spec/lib/bundle-schema.mjs +1 -0
  28. package/engines/spec/lib/interaction-cases.mjs +46 -0
  29. package/engines/spec/split-bundle.mjs +1 -1
  30. package/engines/testcase/_staging-from-portal/runners/README.md +3 -3
  31. package/engines/testcase/_staging-from-portal/runners/generate.mjs +2 -2
  32. package/engines/testcase/_staging-from-portal/runners/lib/read-testcase.mjs +1 -1
  33. package/engines/testcase/runners/README.md +3 -3
  34. package/engines/testcase/runners/generate.mjs +2 -2
  35. package/engines/testcase/runners/lib/read-testcase.mjs +1 -1
  36. package/engines/testcase/runners/lib/resolve-hub-id.mjs +3 -3
  37. package/harness/be/skills/audit-api/SKILL.md +1 -1
  38. package/harness/be/skills/grill-api-unit/SKILL.md +1 -1
  39. package/harness/docs/extracts/agent-design-context.md +124 -0
  40. package/harness/docs/extracts/architecture-core.md +2 -0
  41. package/harness/docs/extracts/extract-registry.docs.json +11 -4
  42. package/harness/docs/extracts/product-id-convention.md +58 -0
  43. package/harness/docs/extracts/spec-requirement.md +1 -1
  44. package/harness/docs/extracts/tpl-adoption-inventory.md +32 -0
  45. package/harness/docs/extracts/tpl-module.md +1 -1
  46. package/harness/docs/rules/agent-compliance.mdc +1 -1
  47. package/harness/docs/skills/adopt/SKILL.md +42 -10
  48. package/harness/docs/skills/api-spec/SKILL.md +4 -0
  49. package/harness/docs/skills/api-update/SKILL.md +1 -1
  50. package/harness/docs/skills/grill-dev/SKILL.md +22 -9
  51. package/harness/docs/skills/module/SKILL.md +1 -1
  52. package/harness/docs/skills/spec/SKILL.md +10 -6
  53. package/harness/docs/skills/surfaces/SKILL.md +1 -0
  54. package/harness/docs/skills/user-flow/SKILL.md +4 -2
  55. package/harness/fe/skills/grill-prototype/SKILL.md +1 -1
  56. package/harness/fe/skills/prototype/SKILL.md +28 -16
  57. package/harness/fe/skills/unit/SKILL.md +4 -4
  58. package/harness/shared/SSOT_AGENT_PROTOCOL.md +1 -1
  59. package/harness/tests/skills/grill-testcase/SKILL.md +1 -1
  60. package/harness/tests/skills/scenario/SKILL.md +2 -2
  61. package/harness/tests/skills/testcase/SKILL.md +1 -1
  62. package/harness/tests/templates/SC.example.md +11 -11
  63. package/harness/tests/templates/TC.example.yaml +3 -3
  64. package/package.json +1 -1
  65. package/templates/project-skeleton/architecture/03-user-flows/FLOW-login.md +10 -10
  66. package/templates/project-skeleton/architecture/04-solution-strategy/index.md +1 -1
  67. package/templates/project-skeleton/architecture/08-cross-cutting/security.md +1 -1
  68. package/templates/project-skeleton/architecture/12-glossary/index.md +3 -2
  69. package/templates/project-skeleton/architecture/model/workspace.dsl +7 -7
  70. package/templates/project-skeleton/surfaces/_module-index.template.md +2 -2
  71. package/templates/project-skeleton/surfaces/_surface-index.template.md +1 -0
  72. package/templates/shared/bundle-authoring.md +3 -2
  73. package/templates/shared/default-layout.ejs +47 -2
  74. package/templates/shared/feature.bundle.yaml +29 -1
  75. package/templates/shared/tpl-runtime-sequence.md +56 -0
  76. package/templates/tests-skeleton/cases/README.md +1 -1
@@ -0,0 +1,124 @@
1
+ # Agent design context (L1 FLOW · L2 interactionCases · NFR · ACP)
2
+
3
+ **Status:** Implemented — `interactionCases`, split/render, audit, ACP skills, `screenToFlows`, MCP `linkedFlows` / `flowgrid_docs_user_flows?id=`.
4
+
5
+ **See also:** `product-id-convention.md`. BE runtime-sequence diagram layer is a future phase (not L1/L2).
6
+
7
+ ---
8
+
9
+ ## Problem
10
+
11
+ Agents often read only `*.bundle.yaml` + `ir/design.yaml` and miss three independent axes:
12
+
13
+ | Axis | SSOT | Agent gap |
14
+ | --- | --- | --- |
15
+ | **L1 Journey (cross-screen)** | `FLOW-*.md` (Markdown only) | No enforced read before codegen on `W-*` |
16
+ | **L2 Interaction (one screen)** | `interactionCases` on bundle + `stateMatrix` / `actions` | No timeline diagram per branch (409, double-submit, …) |
17
+ | **NFR overlay** | `bundle.nfr` + `architecture/08-*` links | NFR treated as appendix, not constraint |
18
+
19
+ **Sequence diagrams at the right layer materially improve codegen quality.**
20
+
21
+ ---
22
+
23
+ ## Layer model
24
+
25
+ | Layer | SSOT | Format | Question answered |
26
+ | --- | --- | --- | --- |
27
+ | **L1** | `FLOW-*` · `common/user-flows/` | MD + **§6 `sequenceDiagram`** | Where the user goes across screens |
28
+ | **L2** | `interactionCases` on bundle (optional) | YAML → split | One `W-*`: cases + per-case sequence |
29
+ | **L3** | `design.stateMatrix` | YAML | Machine state/button matrix |
30
+ | **L4** | bundle + `ir/design.yaml` + `01` | YAML | Fields, actions, apiRef, outcomes |
31
+ | **NFR** | `bundle.nfr` | MD bullets | Constraints on all cases |
32
+
33
+ **Do not** put L2 single-screen branches into FLOW MD. **Do not** require L2 on trivial list-only GET screens.
34
+
35
+ ---
36
+
37
+ ## L1 ↔ leaf link: `userFlows` on bundle
38
+
39
+ ```yaml
40
+ userFlows: |
41
+ - FLOW-checkout — role: step-3-ops — screens: W-ADM-ORD-01 (this leaf)
42
+ ```
43
+
44
+ | Token | Agent use |
45
+ | --- | --- |
46
+ | `FLOW-*` | Open FLOW MD SSOT |
47
+ | `role` | Focus §4 stage |
48
+ | `screens` + `(this leaf)` | Filter journey to current screen |
49
+
50
+ Resolve FLOW paths: `architecture/03-user-flows/<FLOW>.md`, `surfaces/**/common/user-flows/<FLOW>.md`.
51
+
52
+ **Discovery:** `flowgrid_docs_route("W-…")` → `linkedFlows[]`; index `registries/docs-index.json` → `screenToFlows`.
53
+
54
+ ---
55
+
56
+ ## L2: `interactionCases` on bundle
57
+
58
+ Authoring SSOT: `feature.bundle.yaml` (not separate FLOW files).
59
+
60
+ ```yaml
61
+ interactionCases:
62
+ policy: required | skip
63
+ skipReason: "" # required when policy: skip
64
+ items:
65
+ - id: IC-SUBMIT-409
66
+ title: ...
67
+ description: ...
68
+ sequenceDiagram: |
69
+ sequenceDiagram
70
+ ...
71
+ ```
72
+
73
+ **Split:** prose → `ir/spec.yaml` → `ir/generated/spec.md` (§ Interaction cases); diagrams only → `ir/design.yaml` → `ir/generated/design.md`.
74
+
75
+ **Codegen read order for L2:** `spec.md` prose + `design.md` mermaid + `stateMatrix` / `actions` — not FLOW.
76
+
77
+ ---
78
+
79
+ ## Agent context package (ACP) — read before codegen
80
+
81
+ For target leaf `W-*`:
82
+
83
+ 1. **`userFlows`** → each **`FLOW-*.md`** (§3–§4 for this screen, **§6 sequence**).
84
+ 2. **`bundle.nfr`** (+ linked `architecture/08-cross-cutting/*` when cited).
85
+ 3. **`ir/generated/design.md`** when `interactionCases.policy: required` (after split + render).
86
+ 4. **`ir/design.yaml`** + **`01-backend-spec.yaml`**.
87
+ 5. Then patch `bundle.gen` / run gen.
88
+
89
+ **Chat checklist:** FLOW ids read · NFR read · L2 design.md yes/no.
90
+
91
+ **Skills:** `/spec` (declare `userFlows` when cross-screen); `/grill-dev`, `/prototype`, `/api-spec` (ACP); `/user-flow` (author FLOW + §6, trace `W-*` in §5).
92
+
93
+ ---
94
+
95
+ ## Audit (`flowgrid audit spec`)
96
+
97
+ **Step 1 — policy confirm** when screen is complex and `interactionCases` missing:
98
+
99
+ - Emit `CONFIRM_INTERACTION_CASES_POLICY` in `confirms[]`.
100
+ - Options: **(Recommended) required** — set `policy: required` + `items[]`; **skip** — `policy: skip` + `skipReason`; **Other** (free text).
101
+
102
+ **Step 2 — item validation** when `policy: required` or `items.length > 0`:
103
+
104
+ - Each item needs `id`, `title`, `description`, `sequenceDiagram`.
105
+ - Optional `links.actionId`, `links.recordStatus`, `links.scenario`.
106
+
107
+ Skip step 1 when `interactionCases.policy: skip` is already declared.
108
+
109
+ ---
110
+
111
+ ## VitePress (member review)
112
+
113
+ | Page | Source |
114
+ | --- | --- |
115
+ | Spec | `ir/generated/spec.md` |
116
+ | Linked flows | Rendered from `userFlows` |
117
+ | Design sequences | `ir/generated/design.md` |
118
+ | API | `ir/generated/api.md` |
119
+
120
+ ---
121
+
122
+ ## One-line summary
123
+
124
+ **L1:** `/user-flow` → `FLOW-*.md` + §6; leaf links via **`userFlows`**. **NFR:** mandatory read before design/API. **L2:** **`interactionCases`** on bundle → `spec.md` + `design.md`; never in FLOW.
@@ -36,6 +36,8 @@ No **dynamics** wording on new trees — use **flow** / `FLOW-*` / `/journey`.
36
36
 
37
37
  ## ID rules
38
38
 
39
+ **Product IDs (global):** `product-id-convention.md` — `surfaceCode` on each surface; `CMP-{SURF}-{DOMAIN}-{NN}`, `W-{SURF}-{DOMAIN}-{NN}`, `API-{SURF}-{DOMAIN}-{NN}`.
40
+
39
41
  | Prefix | Path | Notes |
40
42
  |--------|------|-------|
41
43
  | `LND-*` `CTX-*` | `architecture/03-context/` | Overview / landscape + context |
@@ -10,7 +10,9 @@
10
10
  ".cursor/extracts/tpl-deployment.md",
11
11
  ".cursor/extracts/tpl-adr.md",
12
12
  ".cursor/extracts/tpl-cross-cutting.md",
13
- ".cursor/extracts/common-scope.md"
13
+ ".cursor/extracts/common-scope.md",
14
+ ".cursor/extracts/tpl-adoption-inventory.md",
15
+ ".cursor/extracts/product-id-convention.md"
14
16
  ],
15
17
  "docs-hub": [
16
18
  ".cursor/extracts/docs-phase-hooks.md",
@@ -25,11 +27,15 @@
25
27
  ".cursor/extracts/design-leaf-signoff.md",
26
28
  ".cursor/extracts/db-audit-wizard.md",
27
29
  ".cursor/extracts/agent-execution-protocol.md",
28
- ".cursor/extracts/common-scope.md"
30
+ ".cursor/extracts/common-scope.md",
31
+ ".cursor/extracts/product-id-convention.md",
32
+ ".cursor/extracts/agent-design-context.md"
29
33
  ],
30
34
  "spec-core": [
31
35
  ".cursor/extracts/spec-core.md",
32
- ".cursor/extracts/common-scope.md"
36
+ ".cursor/extracts/common-scope.md",
37
+ ".cursor/extracts/product-id-convention.md",
38
+ ".cursor/extracts/agent-design-context.md"
33
39
  ],
34
40
  "bqa-grill": [
35
41
  ".cursor/extracts/grill/validation.md",
@@ -39,7 +45,8 @@
39
45
  "dev-grill": [
40
46
  ".cursor/extracts/codegen/readiness.md",
41
47
  ".cursor/extracts/docs-mark-detect.md",
42
- ".cursor/extracts/db-audit-wizard.md"
48
+ ".cursor/extracts/db-audit-wizard.md",
49
+ ".cursor/extracts/agent-design-context.md"
43
50
  ],
44
51
  "grill-docs": [
45
52
  ".cursor/extracts/grill-docs-reconcile.md",
@@ -0,0 +1,58 @@
1
+ # Product ID convention (global SSOT)
2
+
3
+ English **structure**; prose locale is separate (`contentLocale`).
4
+
5
+ ## Why surface code is mandatory
6
+
7
+ IDs are **globally unique** across the docs hub (CLI `--id`, registries, tests mirror). The same capability on two channels (e.g. Login on admin vs customer) MUST be two IDs. Path `surfaces/<slug>/` alone is not enough when referencing without a path.
8
+
9
+ ## Surface code (`surfaceCode`)
10
+
11
+ - Declare on every `surfaces/<slug>/index.md` frontmatter: `surfaceCode: ADM` (2–4 uppercase letters).
12
+ - Register once per channel; reuse the **same token** in every `CMP-*` / `W-*` / `API-*` / `UI-*` on that surface.
13
+ - Folder slug stays human (`admin`, `customer-web`); **IDs embed `surfaceCode`**, not the slug.
14
+
15
+ | Surface folder | Example `surfaceCode` |
16
+ | --- | --- |
17
+ | `surfaces/admin` | `ADM` |
18
+ | `surfaces/customer-web` | `CUS` |
19
+ | `surfaces/workforce-app` | `WRK` |
20
+
21
+ ## Patterns
22
+
23
+ | Kind | Pattern | Example |
24
+ | --- | --- | --- |
25
+ | Module (folder name) | `CMP-{SURF}-{DOMAIN}-{NN}` | `CMP-ADM-AUTH-01` |
26
+ | Screen | `W-{SURF}-{DOMAIN}-{NN}` | `W-ADM-AUTH-01` |
27
+ | API | `API-{SURF}-{DOMAIN}-{NN}` | `API-ADM-AUTH-01` |
28
+ | UI code leaf | `UI-{SURF}-{DOMAIN}-{NN}` | `UI-ADM-EMPTY-01` |
29
+ | User flow | `FLOW-{slug}` | `FLOW-checkout` (no surface — scope in doc body) |
30
+ | Common | `CMN-UI-*` / `CMN-API-*` / `CMN-DTO-*` | No surface prefix |
31
+
32
+ - `{SURF}` = `surfaceCode` (2–4 chars).
33
+ - `{DOMAIN}` = short capability token (`AUTH`, `ORD`, `CART`, `USR`, …).
34
+ - `{NN}` = two digits `01`–`99` per domain on that surface (pad with zero).
35
+
36
+ ## Module folder = global module ID
37
+
38
+ `surfaces/<slug>/CMP-ADM-AUTH-01/` — folder name **equals** global `CMP-*` id (tooling SSOT).
39
+
40
+ ## Bundle / path slug (lowercase)
41
+
42
+ `CMP-ADM-ORD-01` + draft `02-01-02` → `page-id: cmp-adm-ord-01-02-01-02` (lowercase, same tokens).
43
+
44
+ ## Hierarchical CLI alias
45
+
46
+ Lowercase path encoding: `cmp-adm-auth-01-01-01-01` (= module + numeric segments under `CMP-*`).
47
+
48
+ ## Same business name, two surfaces
49
+
50
+ - Admin login: `W-ADM-AUTH-01`
51
+ - Customer login: `W-CUS-AUTH-01`
52
+ Shared spec → `CMN-*` or explicit cross-reference; **never** one `W-*` for both.
53
+
54
+ ## Forbidden
55
+
56
+ - `W-AUTH-01` without `{SURF}` (collision risk).
57
+ - Mixed tokens on one surface (`W-AD-*` vs `W-ADM-*`) — pick one `surfaceCode` and stick to it.
58
+ - Renaming IDs for arc42-only refactors (see `architecture/02-constraints`).
@@ -6,4 +6,4 @@ Required business keys when info exists: `summary`, `userStories` (+ `screenAcce
6
6
 
7
7
  After patch: `flowgrid split` → `flowgrid render` → BA reads `ir/generated/spec.md` (not hand-written `.md`).
8
8
 
9
- Path SSOT: `surfaces/<surface>/CMP-*/<NN…>/` — resolve IDs with `flowgrid_docs_route` on consumer repo.
9
+ Path SSOT: `surfaces/<surface>/CMP-*/<NN…>/` — resolve IDs with `flowgrid_docs_route` on consumer repo. ID shape: `product-id-convention.md`.
@@ -0,0 +1,32 @@
1
+ # Adoption inventory — section template (`adoption-inventory.md`)
2
+
3
+ Workspace root SSOT after `/adopt`. English **IDs**; prose may follow hub `contentLocale` later. ID shape: `product-id-convention.md` (`surfaceCode`, `CMP|W|API-{SURF}-{DOMAIN}-{NN}`).
4
+
5
+ ## Required sections
6
+
7
+ 1. **Surfaces** — channel / app → legacy repo path
8
+ 2. **Modules (`CMP-*`)** — feature groups → legacy module folder
9
+ 3. **Screens & APIs (`W-*`, `API-*`)** — leaf functions → legacy file paths
10
+ 4. **User flows (`FLOW-*`)** — see placement tiers below (mandatory when scan finds multi-step / cross-app journeys)
11
+ 5. **Common catalog (`CMN-*`)** — only if Common Analysis mode
12
+ 6. **Handoff** — `/legacy /spec`, `/legacy /user-flow`
13
+
14
+ ## User flow placement (maps to new docs hub)
15
+
16
+ | Tier | When to list | Target path after `/legacy /user-flow` |
17
+ | --- | --- | --- |
18
+ | **A — Cross-surface / org** | Same journey touches **≥2 surfaces** or **≥2 CMP owners** (checkout admin→customer, ops→partner API, SSO handoff) | `architecture/03-user-flows/FLOW-*.md` |
19
+ | **B — Surface shared** | Journey shared by **≥2 modules** on **one** surface | `surfaces/<surface>/common/user-flows/FLOW-*.md` |
20
+ | **C — Module / cluster** | Journey stays inside **one CMP** (or one cluster `CMP-*/NN/`) | `surfaces/<surface>/<CMP>/common/user-flows/FLOW-*.md` or `…/<CMP>/<NN>/common/user-flows/` |
21
+ | **D — Not a FLOW** | Single screen CRUD, one API call | Document only `W-*` / `API-*` — **do not** invent `FLOW-*` |
22
+
23
+ Each `FLOW-*` line MUST include:
24
+
25
+ - **Surfaces / CMPs involved** (e.g. `admin`, `CMP-ADM-ORD-01`, `customer-web`, `CMP-CUS-CART-01`)
26
+ - **Screen/API steps** (ordered `W-*` / `API-*` refs or legacy route names)
27
+ - **Legacy evidence** (router guards, saga classes, shared session keys, event names — file paths)
28
+ - **Suggested tier** (A / B / C)
29
+
30
+ ## Legacy scan hints (cross-surface)
31
+
32
+ Look for: redirect chains across subdomains/apps, shared `orderId`/`session` in multiple repos, BPM/orchestrator, “checkout” spanning cart (FE) + payment (API) + notification (worker), duplicate route names in 2+ legacy apps for one business journey.
@@ -1,6 +1,6 @@
1
1
  # Module index template
2
2
 
3
- Path: `surfaces/<surface>/CMP-{NN}-{slug}/index.md` — **MD only**.
3
+ Path: `surfaces/<surface>/CMP-{SURF}-{DOMAIN}-{NN}/index.md` — **MD only** (`product-id-convention.md`).
4
4
 
5
5
  Copy from: `templates/project-skeleton/surfaces/_module-index.template.md`
6
6
 
@@ -23,4 +23,4 @@ When executing any skill (`/spec`, `/grill`, `/grill-bqa`, etc.):
23
23
  6. **DSL / COMMON:** Human lead decides common promotions. The agent only executes `/common` (Markdown patterns), `/docs-mark`, custom-base handoff, or confirmation post-grill. `/spec` consumes patterns + FE base via `flowgrid-ux-common.mdc`. **[STRICTLY FORBIDDEN]** `common/yaml`, `/common-spec`, `/gen-common`.
24
24
  7. **ISOLATION:** Execute strictly within the invoked skill scope. **[STRICTLY FORBIDDEN]** to merge sibling features or output fake Markdown reports when YAML contracts are required.
25
25
 
26
- **Path SSOT:** `surfaces/<surface>/CMP-*/<slug>/` (NO `modules/` segment).
26
+ **Path SSOT:** `surfaces/<surface>/CMP-*/<slug>/` (NO `modules/` segment). **IDs:** `product-id-convention.md` (`surfaceCode` + `CMP|W|API-{SURF}-{DOMAIN}-{NN}`).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: adopt
3
- description: "/adopt — Scan legacy repositories and generate a high-level index mapping catalog & common candidates at root."
3
+ description: "/adopt — Scan legacy repositories and generate a high-level index mapping catalog, user flows (incl. cross-surface), and common candidates at root."
4
4
  disable-model-invocation: true
5
5
  extractBundle: architecture-core
6
6
  ---
@@ -14,6 +14,8 @@ extractBundle: architecture-core
14
14
 
15
15
  **Handoff SSOT spec:** Sau adopt, member drill [spec-ssot-prep.md](../../../docs/workflows/spec-ssot-prep.md) — Phase 0 → `/legacy /spec` per `W-*` (không nhảy thẳng bundle không có ID trong inventory).
16
16
 
17
+ **Inventory template:** `.cursor/extracts/tpl-adoption-inventory.md` — section layout + **user-flow placement tiers** (cross-surface → `architecture/03-user-flows/`).
18
+
17
19
  ---
18
20
 
19
21
  ## Rule: Pre-Scan Mode Selection (AskQuestion Wizard)
@@ -71,16 +73,35 @@ extractBundle: architecture-core
71
73
  - **Surfaces**: Application and channel names (Admin Portal, Customer Web, Gateway…)
72
74
  - **Modules (`CMP-*`)**: Primary feature groups (Auth, Orders, Profile…)
73
75
  - **Screens (`W-*`) & APIs (`API-*`)**: UI screens + API endpoints with legacy file paths (`ID → Legacy File Path`)
74
- - **Cross-Flow Candidates (`FLOW-*`)**: Business flows spanning multiple screens or services
76
+ - **User flows (`FLOW-*`)**: Multi-step business journeys — **classify every candidate** (see Rule: User flow discovery)
75
77
  - **Common Candidates (`CMN-UI-*`, `CMN-API-*`, `CMN-DTO-*`)**: (If Common Analysis mode selected)
76
78
 
77
79
  ---
78
80
 
81
+ ## Rule: User flow discovery (incl. cross-surface)
82
+
83
+ - **[MANDATORY]** Section **4. User flows (`FLOW-*`)** in `adoption-inventory.md` is **not optional** when the legacy scan finds any journey that spans **more than one screen** or **more than one deployable app/repo** in one business outcome.
84
+ - **[MANDATORY]** For each `FLOW-*`, assign a **placement tier** (target path in the **new** docs hub after `/legacy /user-flow`):
85
+
86
+ | Tier | Label | List under inventory subsection | New hub path |
87
+ | --- | --- | --- | --- |
88
+ | **A** | Cross-surface / org catalog | `### A — Cross-surface (org catalog)` | `architecture/03-user-flows/FLOW-*.md` |
89
+ | **B** | Surface-shared | `### B — Shared on one surface` | `surfaces/<surface>/common/user-flows/FLOW-*.md` |
90
+ | **C** | Module / cluster | `### C — Module or cluster scope` | `surfaces/.../CMP-*/common/user-flows/` (or `…/<NN>/common/user-flows/`) |
91
+ | **D** | (omit) | — | Single `W-*` only — **no** `FLOW-*` |
92
+
93
+ - **[MANDATORY]** Each `FLOW-*` bullet MUST state: **surfaces + CMPs involved**, **ordered steps** (`W-*` / `API-*` or legacy route names), **legacy evidence paths** (routers, orchestrators, saga/worker, shared tokens), **tier A/B/C**.
94
+ - **[MANDATORY]** **Cross-surface (tier A)** examples: checkout/payment across customer web + admin ops; partner webhook + internal portal; SSO/login handoff across two SPAs in different legacy repos; order fulfillment touching warehouse API + customer notification app.
95
+ - **[STRICTLY FORBIDDEN]** Listing only `W-*`/`API-*` while ignoring obvious multi-app journeys (tier A/B/C) — Tier 2 audit (`/legacy /user-flow`) depends on this index.
96
+
97
+ ---
98
+
79
99
  ## Rule: ID Standardization
80
100
 
101
+ - **[MANDATORY]** Follow `.cursor/extracts/product-id-convention.md` — declare `surfaceCode` per surface; `CMP-{SURF}-{DOMAIN}-{NN}`, `W-{SURF}-{DOMAIN}-{NN}`, `API-{SURF}-{DOMAIN}-{NN}` (duplicate capability across surfaces ⇒ distinct IDs).
81
102
  - **[MANDATORY]** All items MUST use standardized IDs: `CMP-*`, `W-*`, `API-*`, `FLOW-*`, `CMN-UI-*`, `CMN-API-*`, `CMN-DTO-*`.
82
103
  - **[MANDATORY]** Every ID MUST map to its corresponding legacy file or directory path.
83
- - ✅ `W-AD-AUTH-001: Login → admin-fe/src/pages/Login.tsx`
104
+ - ✅ `W-ADM-AUTH-01: Login → admin-fe/src/pages/Login.tsx`
84
105
  - ✅ `CMN-UI-001: Filter Toolbar → duplicated in admin-fe/src/pages/Orders.tsx, Users.tsx`
85
106
 
86
107
  ---
@@ -96,15 +117,25 @@ extractBundle: architecture-core
96
117
  - **Admin Portal** (`surfaces/admin`) → Legacy repo: `admin-fe`
97
118
 
98
119
  ## 2. Modules Catalog (`CMP-*`)
99
- - **CMP-ADM-001**: Auth & Identity Management → Legacy: `admin-fe/src/modules/auth/`
120
+ - **CMP-ADM-AUTH-01**: Auth & Identity Management → Legacy: `admin-fe/src/modules/auth/`
100
121
 
101
122
  ## 3. Screens & API Function Inventory (`W-*`, `API-*`)
102
- ### Admin Portal (`surfaces/admin/CMP-ADM-001`)
103
- - **W-AD-AUTH-001**: Login → Legacy: `admin-fe/src/pages/Login.tsx`
123
+ ### Admin Portal (`surfaces/admin/CMP-ADM-AUTH-01`)
124
+ - **W-ADM-AUTH-01**: Login → Legacy: `admin-fe/src/pages/Login.tsx`
104
125
  - **API-ADM-AUTH-01**: Auth Services → Legacy: `auth-service/src/controllers/AuthController.java`
105
126
 
106
- ## 4. Cross-Flow Candidates (`FLOW-*`)
107
- - **FLOW-checkout**: Checkout & Payment Flow → across `CMP-ADM-002` & `CMP-CUS-001`
127
+ ## 4. User flows (`FLOW-*`)
128
+
129
+ ### A — Cross-surface (org catalog) → `architecture/03-user-flows/`
130
+ - **FLOW-checkout**: Checkout & payment — Surfaces: `customer-web` (`CMP-CUS-CART-01`), `admin` (`CMP-ADM-ORD-01`) — Steps: cart `W-CUS-CART-01` → pay `API-CUS-PAY-01` → ops `W-ADM-ORD-01` — Legacy: `customer-fe/src/routes/checkout/*`, `admin-fe/src/pages/Orders.tsx`, `payment-svc/...` — Tier: **A**
131
+
132
+ ### B — Shared on one surface → `surfaces/<surface>/common/user-flows/`
133
+ - **FLOW-onboard-admin**: Admin onboarding — Surface: `admin` only — CMPs: `CMP-ADM-AUTH-01`, `CMP-ADM-USR-01` — Steps: … — Legacy: … — Tier: **B**
134
+
135
+ ### C — Module / cluster scope → `…/CMP-*/common/user-flows/`
136
+ - **FLOW-password-reset**: Reset password — Surface: `admin` — CMP: `CMP-ADM-AUTH-01` — Steps: … — Legacy: … — Tier: **C**
137
+
138
+ > If no multi-step journeys found, write: `_(none detected — screen-only inventory in §3)_`
108
139
 
109
140
  ## 5. Common Catalog Candidates (Anti-Copy-Paste Guard)
110
141
  > **Purpose**: Reuse for specs and code of new features / spec updates.
@@ -122,11 +153,11 @@ extractBundle: architecture-core
122
153
 
123
154
  ### ⚠️ Whole Page Duplication Warnings
124
155
  > **Note**: Do not create `CMN-*` for full pages. Recommend consolidating into a single polymorphic spec (`mode: create | edit`).
125
- - **W-AD-USER-001 (Create User)** & **W-AD-USER-002 (Edit User)**: 95% identical → *Recommendation: Consolidate into single Form Spec `CMP-ADM-USER-FORM`*
156
+ - **W-ADM-USR-01 (Create User)** & **W-ADM-USR-02 (Edit User)**: 95% identical → *Recommendation: Consolidate into single Form Spec `CMP-ADM-USR-FORM`*
126
157
 
127
158
  ---
128
159
  ## 6. Handoff Usage Guide
129
- - `/legacy /spec W-AD-AUTH-001` — spec a legacy screen (MUST reuse CMN-* if applicable)
160
+ - `/legacy /spec W-ADM-AUTH-01` — spec a legacy screen (MUST reuse CMN-* if applicable)
130
161
  - `/legacy /user-flow FLOW-checkout` — map a legacy flow
131
162
  ```
132
163
 
@@ -138,5 +169,6 @@ extractBundle: architecture-core
138
169
  - [ ] Audit script run; index checked or gaps reported.
139
170
  - [ ] `adoption-inventory.md` created directly at workspace root.
140
171
  - [ ] All items use standardized `CMP-*`, `W-*`, `API-*`, `FLOW-*`, `CMN-*` IDs.
172
+ - [ ] Section 4 lists user flows with tier **A/B/C** when multi-step/cross-app journeys exist; tier **A** cross-surface rows are explicit.
141
173
  - [ ] Common Catalog Candidates listed with source files if Common mode selected.
142
174
  - [ ] Anti-Copy-Paste Guard enforced for new spec/code.
@@ -18,6 +18,10 @@ Shared extracts: `spec-evolution.md`, `api-spec-sync.md`, `entity-relationship.m
18
18
 
19
19
  Hashtag extracts: `#call-external` → `call-external.md`; `#cross-entity-service` → `cross-entity-service.md`.
20
20
 
21
+ ## Agent context (ACP) before `01`
22
+
23
+ Per **`agent-design-context.md`**: (1) `userFlows` → `FLOW-*.md` §6 (`flowgrid_docs_user_flows` / `flowgrid_docs_route`); (2) `bundle.nfr`; (3) `ir/generated/design.md` if `interactionCases.policy: required`; (4) `ir/design.yaml` + `01`. Print checklist: FLOW · NFR · L2.
24
+
21
25
  ---
22
26
 
23
27
  ## Rule: Audit Interlock
@@ -28,7 +28,7 @@ Shared extracts: `api-spec-sync.md`, `spec-evolution.md`, `entity-relationship.m
28
28
 
29
29
  ## Rule: ID Resolution & Folder Location
30
30
 
31
- - **[MANDATORY]** If an ID is provided (e.g. `CMP-ADM-000-001`, `W-AD-AUTH-001`) → use `flowgrid_docs_route` or glob to resolve to `…/api/<seq>/01-backend-spec.yaml`. Do NOT force user to provide full filesystem path.
31
+ - **[MANDATORY]** If an ID is provided (e.g. `CMP-ADM-AUTH-01-001`, `W-ADM-AUTH-01`) → use `flowgrid_docs_route` or glob to resolve to `…/api/<seq>/01-backend-spec.yaml`. Do NOT force user to provide full filesystem path.
32
32
  - **[MANDATORY]** Trio lives under `api/<seq>/` — never adjacent to `*.bundle.yaml`.
33
33
  - Common APIs: `…/common/yaml/<slug>/01-backend-spec.yaml` (one trio per API).
34
34
 
@@ -28,25 +28,38 @@ disable-model-invocation: true
28
28
 
29
29
  ---
30
30
 
31
+ ## Rule: Agent context (ACP) before codegen
32
+
33
+ Per **`agent-design-context.md`** — read **before** patching `bundle.gen` / codegen:
34
+
35
+ 1. **`userFlows`** → each linked **`FLOW-*.md`** (§3–§4 for this `W-*`, **§6 sequence**).
36
+ 2. **`bundle.nfr`** (+ linked `architecture/08` if cited).
37
+ 3. **`ir/generated/design.md`** when `interactionCases.policy: required` (after `split` + `render`).
38
+ 4. Then **`ir/design.yaml`** + **`01`**.
39
+
40
+ Print checklist in chat: FLOW ids read · NFR read · L2 design.md yes/no.
41
+
42
+ ---
43
+
31
44
  ## Rule: Audit Interlock with Page Type
32
45
 
33
46
  - **[MANDATORY]** Before grilling, run: `flowgrid audit spec <bundle> --type <profile>`. Treat `warnings[]` as non-blocking; nudge BQA via handoff if summary still has `[placeholder]` brackets.
34
47
  - **[MANDATORY]** After `bundle.gen` patch: `flowgrid split` + `flowgrid render` (FE uses `ir/design.yaml`; BA PDF path uses `ir/generated/spec.md`).
35
- - `<profile>` lấy từ `gen.codegen.profile` đã xác nhận (list | create | detail | admin-crud | auth | ...).
36
- - Nếu profile chưa set → hỏi member xác định profile trước, KHÔNG chạy audit với `--type unknown`.
48
+ - `<profile>` comes from confirmed `gen.codegen.profile` (list | create | detail | admin-crud | auth | ...).
49
+ - If profile is unset → ask the member to confirm profile first; do **not** run audit with `--type unknown`.
37
50
  - Script output `gaps[]` + `confirms[]` (`CONFIRM_UX_*`, **`CONFIRM_DB_*`** — `db-audit-wizard.md`).
38
51
  - Agent patches structural `gaps[]`; UX/DB confirms → wizard; BE drift → `/api-update` then re-audit.
39
52
 
40
53
  ---
41
54
 
42
- ## Rule: Zone-Based Grill (chống Lost-in-Middle)
55
+ ## Rule: Zone-Based Grill (avoid lost-in-the-middle)
43
56
 
44
- - **[MANDATORY]** Grill theo zone, KHÔNG grill toàn bộ bundle 1 lần.
45
- - **[MANDATORY]** Chia bundle thành zones linh động theo nội dung thực:
46
- - Mỗi turn grill 1 zone: đọc zone data → phân tích chất (logic, consistency, cross-field gaps) → bổ sung/sửa.
47
- - Nếu zone quá lớn → chia nhỏ tiếp.
48
- - **[MANDATORY]** Script check **lượng** (field có/không). Agent check **chất** (nội dung chuẩn, hợp logic, gaps giữa fields).
49
- - **[STRICTLY FORBIDDEN]** Gửi all-in-one rồi bỏ sót giữa.
57
+ - **[MANDATORY]** Grill by zone; do **not** grill the entire bundle in one pass.
58
+ - **[MANDATORY]** Split the bundle into zones based on actual content:
59
+ - One zone per turn: read zone data → analyze quality (logic, consistency, cross-field gaps) → patch.
60
+ - If a zone is too large → subdivide further.
61
+ - **[MANDATORY]** Script checks **quantity** (field present or not). Agent checks **quality** (correct content, logic, cross-field gaps).
62
+ - **[STRICTLY FORBIDDEN]** Single all-in-one pass that drops items in the middle.
50
63
 
51
64
  ## Rule: Missing Information / Hard Gate & Workload Threshold (Law 2)
52
65
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: module
3
- description: EXCLUSIVE /module — Handles business modules (CMP-*). DO NOT output fake Markdown reports.
3
+ description: EXCLUSIVE /module — Handles business modules (CMP-{SURF}-{DOMAIN}-{NN}). DO NOT output fake Markdown reports.
4
4
  disable-model-invocation: true
5
5
  extractBundle: architecture-core
6
6
  ---
@@ -9,7 +9,7 @@ disable-model-invocation: true
9
9
  > **[MANDATORY]** Re-read this entire `SKILL.md` via file-read tool. **STRICTLY FORBIDDEN** to rely on memory.
10
10
  > **[MANDATORY]** Read `.flowgrid/templates/feature.bundle.yaml` + `.flowgrid/templates/bundle-authoring.md` BEFORE generating any YAML. **Do NOT** use `design-spec.yaml` (deprecated).
11
11
  > If templates are missing → STOP: *"Template missing. Run `flowgrid init` to generate templates."*
12
- > **Extract:** `spec-ssot-prep.md`, `spec-prd-lite.md`, `db-audit-wizard.md`, `design-leaf-signoff.md`.
12
+ > **Extract:** `spec-ssot-prep.md`, `spec-prd-lite.md`, `db-audit-wizard.md`, `design-leaf-signoff.md`, `agent-design-context.md`.
13
13
  > Physical interlocks: `AGENTS.md` + `SSOT_AGENT_PROTOCOL.md` (Laws 1–7). Chat-only done = **FAILED**.
14
14
 
15
15
  # /spec — Function detail (design)
@@ -62,7 +62,7 @@ Hub: [spec-ssot-prep.md](../../../docs/workflows/spec-ssot-prep.md) · extract `
62
62
  - `<pageType>` = page type đã xác định ở bước trên (list | create | detail | admin-crud | auth | ...).
63
63
  - Script output:
64
64
  - `gaps[]` → required fields missing → Agent patches bundle directly.
65
- - `warnings[]` → **quality hints** (`scopeIn`, `nonGoals`, `nfr`, `userFlows`, placeholders) — fix when info exists; **does not** block split. Rủi ro → `/risk-register` only (`WARN_BUNDLE_RISKS_FORBIDDEN` if `risks:` on bundle).
65
+ - `warnings[]` → **quality hints** (`scopeIn`, `nonGoals`, `nfr`, `userFlows`, placeholders) — fix when info exists; **does not** block split. Risks → `/risk-register` only (`WARN_BUNDLE_RISKS_FORBIDDEN` if `risks:` on bundle).
66
66
  - `confirms[]` → AskQuestion wizard (one question at a time, ≥3 options):
67
67
  - UX: `category: ux`, `UX_*`, `CONFIRM_UX_*` — `flowgrid-ux-common.mdc`
68
68
  - **DB:** `category: db`, `CONFIRM_DB_*` — `.cursor/extracts/db-audit-wizard.md` (entities, multi-table, `db` vs `01`, `#derived-data`)
@@ -85,9 +85,10 @@ Hub: [spec-ssot-prep.md](../../../docs/workflows/spec-ssot-prep.md) · extract `
85
85
 
86
86
  ## Rule: Target / ID Resolution
87
87
 
88
+ - **[MANDATORY]** Product IDs per `product-id-convention.md` (`surfaceCode`, `CMP-{SURF}-{DOMAIN}-{NN}`, `W-{SURF}-{DOMAIN}-{NN}`).
88
89
  - **[MANDATORY]** Resolve screen ID, module ID, slug, or Draft ID before generating any file.
89
90
  - Draft ID `1-1-2` → pad each segment → `01/01/02/`
90
- - Bundle ID: module prefix + padded segments, e.g. `CMP-ADM-002` + `02-01-02` → `page-id: cmp-adm-002-02-01-02`
91
+ - Bundle ID: module prefix + padded segments, e.g. `CMP-ADM-ORD-01` + `02-01-02` → `page-id: cmp-adm-ord-01-02-01-02`
91
92
  - **[MANDATORY]** Search for input `.md` file at resolved path. If found, read it as primary requirement source — do NOT say "I cannot hallucinate" or ask user for input that is already present.
92
93
  - **[STRICTLY FORBIDDEN]** Do NOT demand full filesystem path from user when ID or slug is given.
93
94
 
@@ -148,11 +149,14 @@ Each zone turn — **in order**:
148
149
  - **[MANDATORY]** List columns: `key` consistent with `bind.field`; computed-only columns → document `#derived-data` (see `common/data-model/derived-data.md`), no fake `db`.
149
150
  - **[STRICTLY FORBIDDEN]** Empty `entities: []` while form/list has multiple persisted `db.field` without QA defer.
150
151
  - **Authoring detail:** [bundle-authoring.md § Data model](../../../templates/shared/bundle-authoring.md#data-model--phase-0-erd-vs-screen-detail) · [tpl-screen-data-model.md](../../../templates/shared/tpl-screen-data-model.md) (multi-table).
151
- - **Sau split:** `ir/generated/data-model.md` cho review. **Audit:** `CONFIRM_DB_*` → member wizard; sau chốt → re-audit. BE SSOT: `01` khớp `db` (drift → `/api-update`).
152
+ - **After split:** `ir/generated/data-model.md` for review. **Audit:** `CONFIRM_DB_*` → member wizard; re-audit after confirm. BE SSOT: `01` must match `db` (drift → `/api-update`).
152
153
 
153
154
  ### Rule: Summary extensions (PRD lite)
154
155
  - **[MANDATORY]** `summary` bullets: business_goals, stakeholders, user_journey, context (input/output), optional solution.
155
- - **[RECOMMENDED]** Fill `scopeIn`, `nonGoals`, `userFlows`, `nfr` when PO/BA có thông tin. Rủi ro dự án → **`/risk-register`** (`architecture/11-risks/risk-register.md`), never `risks:` on bundle.
156
+ - **[RECOMMENDED]** Fill `scopeIn`, `nonGoals`, `userFlows`, `nfr` when PO/BA provide facts. Complex single-screen flows → `interactionCases` (L2) or resolve audit `CONFIRM_INTERACTION_CASES_POLICY`. Project risks → **`/risk-register`**, never `risks:` on bundle.
157
+ - **[MANDATORY]** `userFlows:` bullets link **`FLOW-*`** (`FLOW-id — role: … — screens: W-* (this leaf)`). Journey sequence lives in **`FLOW-*.md` §6** — not in bundle.
158
+ - **[RECOMMENDED]** Multi-state / multi-case on **one screen:** optional top-level **`interactionCases`** (`policy`, `items[]` with `IC-*`, `description`, `sequenceDiagram`) — see `agent-design-context.md`. After split: prose → `spec.md`, diagrams → `design.md`.
159
+ - **[MANDATORY]** Consume `confirms[]` **`CONFIRM_INTERACTION_CASES_POLICY`** from audit — set `policy: required` or `policy: skip` + `skipReason`.
156
160
  - **[MANDATORY]** Replace template `[placeholder]` brackets in `summary` / metrics / non-goals before handoff grill.
157
161
 
158
162
  ### Rule: User Stories (`userStories`)
@@ -268,6 +272,6 @@ Each zone turn — **in order**:
268
272
  - [ ] UX gap questions used checklist-backed `(Recommended)` options (`flowgrid-ux-common.mdc`), not open brainstorming.
269
273
  - [ ] `userStories` scenarios/AC reflect UX affordances patched in `design` (incl. audit `suggestedStoryPatch`).
270
274
  - [ ] YAML strings with `:` or `[]` are double-quoted. No `.md` written by hand.
271
- - [ ] PRD fields (`scopeIn`, `nonGoals`, `userFlows`, `nfr`) filled or deferred via `qa/` (no template brackets). Rủi ro không trên bundle.
275
+ - [ ] PRD fields (`scopeIn`, `nonGoals`, `userFlows`, `nfr`) filled or deferred via `qa/` (no template brackets). No project risks on bundle (`/risk-register` only).
272
276
  - [ ] `pnpm docs:split` + `pnpm docs:render` run with zero errors; `ir/generated/spec.md` has TOC + overview sections.
273
277
  - [ ] Handoff → `/testcase` created.
@@ -16,6 +16,7 @@ extractBundle: architecture-core
16
16
 
17
17
  ## Rule: Target Resolution
18
18
 
19
+ - **[MANDATORY]** On create: set `surfaceCode` (2–4 uppercase letters) in `surfaces/<slug>/index.md` frontmatter — SSOT for all `CMP-*` / `W-*` / `API-*` on this channel (`product-id-convention.md`).
19
20
  - **[MANDATORY]** Use `flowgrid_docs_route` or `flowgrid_docs_get_element` (or glob) to resolve the target surface directory under `surfaces/[Surface Name]/`.
20
21
  - **[STRICTLY FORBIDDEN]** Do NOT confuse an API with a surface. APIs belong to architecture containers or function-level API contracts.
21
22
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: user-flow
3
- description: /user-flow — Luồng người dùng (FLOW-*) trên surfaces.
3
+ description: /user-flow — Author cross-surface user journeys (FLOW-*.md) on the docs hub.
4
4
  disable-model-invocation: true
5
5
  extractBundle: architecture-core
6
6
  ---
@@ -12,7 +12,9 @@ extractBundle: architecture-core
12
12
 
13
13
  **Mindset:** Model the process by **business actions on surfaces**, not by repository or service topology.
14
14
 
15
- **Template:** `architecture/03-user-flows/FLOW-template.md` (or `**/common/user-flows/FLOW-*.md`) — **Non-goals** in §1 when information exists (KPI ngoài hub).
15
+ **Template:** `architecture/03-user-flows/FLOW-template.md` (or `**/common/user-flows/FLOW-*.md`) — **Non-goals** in §1 when information exists (out-of-hub KPIs).
16
+
17
+ **Leaf link:** Bundles reference this file via `userFlows:` (`FLOW-* — role — screens`). Agents read FLOW **before** codegen (`agent-design-context.md`). **Do not** put single-screen multi-state cases here — use bundle `interactionCases` (L2).
16
18
 
17
19
  ---
18
20
 
@@ -14,7 +14,7 @@ disable-model-invocation: true
14
14
 
15
15
  ## Target / ID Resolution Rule
16
16
 
17
- - User prompt MAY specify screen ID, function ID, or slug (e.g. `W-AD-AUTH-001`, `login`).
17
+ - User prompt MAY specify screen ID, function ID, or slug (e.g. `W-ADM-AUTH-01`, `login`).
18
18
  - **Read the entire `ir/design.yaml`** on the screen leaf (`…/CMP-*/<NN…>/ir/design.yaml`). Do **not** use `01-backend-spec.yaml` as FE input.
19
19
  - Docs hub is **read-only**. Do not patch `*.bundle.yaml` or `ir/*`.
20
20
  - Compare route + rendered UI to `ir/design.yaml` (actions, validation copy, states, testIds).