@bovinphang/frontend-craft 2.8.0 → 2.9.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 (195) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +378 -339
  4. package/CHANGELOG.zh-CN.md +377 -338
  5. package/CONTRIBUTING.md +371 -361
  6. package/CONTRIBUTING.zh-CN.md +371 -361
  7. package/README.md +545 -493
  8. package/README.openclaw.md +359 -320
  9. package/README.openclaw.zh-CN.md +359 -320
  10. package/README.zh-CN.md +545 -493
  11. package/agents/fec-code-reviewer.md +24 -3
  12. package/agents/fec-debugger.md +1 -1
  13. package/agents/fec-doc-updater.md +1 -1
  14. package/agents/fec-e2e-runner.md +1 -1
  15. package/agents/fec-figma-implementer.md +1 -1
  16. package/agents/fec-performance-optimizer.md +1 -1
  17. package/agents/fec-refactor-cleaner.md +4 -1
  18. package/agents/fec-refactoring-expert.md +81 -0
  19. package/agents/fec-security-reviewer.md +17 -1
  20. package/agents/fec-test-planner.md +1 -1
  21. package/agents/fec-typescript-reviewer.md +24 -8
  22. package/agents/fec-ui-checker.md +11 -11
  23. package/commands/fec-debug.md +1 -1
  24. package/commands/fec-refactor-plan.md +17 -0
  25. package/commands/fec-refactor.md +18 -0
  26. package/commands/fec-review.md +40 -10
  27. package/commands/fec-scaffold.md +1 -1
  28. package/commands/fec-smell.md +17 -0
  29. package/commands/fec-tdd.md +6 -2
  30. package/dist/bin/frontend-craft.js +190 -38
  31. package/dist/hooks/fec-run-tests.js +5 -1
  32. package/dist/hooks/fec-session-start.js +1 -1
  33. package/docs/example-prompts.md +157 -140
  34. package/docs/ja-JP/README.md +534 -493
  35. package/docs/ko-KR/README.md +534 -493
  36. package/docs/project-structure.md +151 -131
  37. package/docs/refactoring/README.md +50 -0
  38. package/docs/refactoring/catalog.md +105 -0
  39. package/docs/refactoring/smell-refactoring-matrix.md +41 -0
  40. package/docs/review-and-diagram-workflows.md +39 -0
  41. package/docs/runtimes/antigravity.md +18 -10
  42. package/docs/runtimes/augment.md +18 -10
  43. package/docs/runtimes/claude.md +191 -177
  44. package/docs/runtimes/claude.zh-CN.md +189 -175
  45. package/docs/runtimes/cline.md +18 -10
  46. package/docs/runtimes/codebuddy.md +18 -10
  47. package/docs/runtimes/codex.md +18 -10
  48. package/docs/runtimes/compatibility.md +27 -0
  49. package/docs/runtimes/copilot.md +18 -10
  50. package/docs/runtimes/cursor.md +18 -10
  51. package/docs/runtimes/gemini.md +18 -10
  52. package/docs/runtimes/kilo.md +18 -10
  53. package/docs/runtimes/openclaw.md +18 -10
  54. package/docs/runtimes/opencode.md +18 -10
  55. package/docs/runtimes/qoder.md +18 -19
  56. package/docs/runtimes/trae.md +18 -10
  57. package/docs/runtimes/windsurf.md +18 -10
  58. package/docs/superpowers/plans/2026-09-26-content-integrity.md +145 -0
  59. package/docs/superpowers/plans/2026-09-26-diagram-quality.md +170 -0
  60. package/docs/superpowers/specs/2026-09-26-diagram-quality-design.md +77 -0
  61. package/docs/superpowers/specs/2026-09-26-project-optimization-design.md +95 -0
  62. package/docs/zh-CN/example-prompts.md +157 -140
  63. package/docs/zh-CN/project-structure.md +148 -128
  64. package/docs/zh-CN/review-and-diagram-workflows.md +39 -0
  65. package/docs/zh-TW/README.md +534 -493
  66. package/localized/zh-CN/agents/fec-code-reviewer.md +22 -3
  67. package/localized/zh-CN/agents/fec-refactor-cleaner.md +3 -0
  68. package/localized/zh-CN/agents/fec-refactoring-expert.md +53 -0
  69. package/localized/zh-CN/agents/fec-security-reviewer.md +16 -0
  70. package/localized/zh-CN/agents/fec-typescript-reviewer.md +23 -7
  71. package/localized/zh-CN/commands/fec-refactor-plan.md +15 -0
  72. package/localized/zh-CN/commands/fec-refactor.md +14 -0
  73. package/localized/zh-CN/commands/fec-review.md +40 -9
  74. package/localized/zh-CN/commands/fec-smell.md +13 -0
  75. package/localized/zh-CN/commands/fec-tdd.md +4 -0
  76. package/localized/zh-CN/skills/eval_queries.json +244 -0
  77. package/localized/zh-CN/skills/fec-code-review/SKILL.md +20 -1
  78. package/localized/zh-CN/skills/fec-code-review/references/report-template.md +11 -1
  79. package/localized/zh-CN/skills/fec-code-smells/SKILL.md +33 -0
  80. package/localized/zh-CN/skills/fec-code-smells/references/detection-guide.md +25 -0
  81. package/localized/zh-CN/skills/fec-code-smells/references/smell-catalog.md +817 -0
  82. package/localized/zh-CN/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
  83. package/localized/zh-CN/skills/fec-image-generation/SKILL.md +31 -1
  84. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
  85. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
  86. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
  87. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
  88. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
  89. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
  90. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
  91. package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +10 -3
  92. package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +8 -1
  93. package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
  94. package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
  95. package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
  96. package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +48 -80
  97. package/localized/zh-CN/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
  98. package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
  99. package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +193 -53
  100. package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +3 -0
  101. package/localized/zh-CN/skills/fec-refactoring/SKILL.md +83 -0
  102. package/localized/zh-CN/skills/fec-refactoring/references/principles.md +43 -0
  103. package/localized/zh-CN/skills/fec-refactoring/references/refactoring-vs-feature-change.md +25 -0
  104. package/localized/zh-CN/skills/fec-refactoring/references/when-to-refactor.md +17 -0
  105. package/localized/zh-CN/skills/fec-refactoring/references/workflow.md +59 -0
  106. package/localized/zh-CN/skills/fec-refactoring-api/SKILL.md +25 -0
  107. package/localized/zh-CN/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
  108. package/localized/zh-CN/skills/fec-refactoring-catalog/SKILL.md +21 -0
  109. package/localized/zh-CN/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
  110. package/localized/zh-CN/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
  111. package/localized/zh-CN/skills/fec-refactoring-catalog/references/selection-guide.md +41 -0
  112. package/localized/zh-CN/skills/fec-refactoring-control/SKILL.md +25 -0
  113. package/localized/zh-CN/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
  114. package/localized/zh-CN/skills/fec-refactoring-data/SKILL.md +25 -0
  115. package/localized/zh-CN/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
  116. package/localized/zh-CN/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
  117. package/localized/zh-CN/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
  118. package/localized/zh-CN/skills/fec-refactoring-functions/SKILL.md +25 -0
  119. package/localized/zh-CN/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
  120. package/localized/zh-CN/skills/fec-refactoring-inheritance/SKILL.md +25 -0
  121. package/localized/zh-CN/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
  122. package/localized/zh-CN/skills/fec-refactoring-move-features/SKILL.md +25 -0
  123. package/localized/zh-CN/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
  124. package/localized/zh-CN/skills/fec-refactoring-validation/SKILL.md +52 -0
  125. package/localized/zh-CN/skills/fec-refactoring-validation/references/behavior-preservation.md +15 -0
  126. package/localized/zh-CN/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +25 -0
  127. package/localized/zh-CN/skills/fec-security-review/SKILL.md +16 -0
  128. package/localized/zh-CN/skills/fec-security-review/references/report-template.md +10 -0
  129. package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +3 -0
  130. package/localized/zh-CN/skills/metadata.json +408 -50
  131. package/localized/zh-CN/skills/relations.json +271 -3
  132. package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +1 -0
  133. package/openclaw.plugin.json +2 -3
  134. package/package.json +27 -17
  135. package/skills/eval_queries.json +244 -0
  136. package/skills/fec-code-review/SKILL.md +20 -1
  137. package/skills/fec-code-review/references/report-template.md +11 -1
  138. package/skills/fec-code-smells/SKILL.md +33 -0
  139. package/skills/fec-code-smells/references/detection-guide.md +25 -0
  140. package/skills/fec-code-smells/references/smell-catalog.md +861 -0
  141. package/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
  142. package/skills/fec-data-fetching/SKILL.md +1 -1
  143. package/skills/fec-image-generation/SKILL.md +31 -1
  144. package/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
  145. package/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
  146. package/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
  147. package/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
  148. package/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
  149. package/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
  150. package/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
  151. package/skills/fec-image-generation/references/diagram-workflows.md +10 -3
  152. package/skills/fec-image-generation/references/html-technical-diagrams.md +8 -1
  153. package/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
  154. package/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
  155. package/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
  156. package/skills/fec-image-generation/scripts/export-diagram.mjs +48 -80
  157. package/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
  158. package/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
  159. package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +193 -53
  160. package/skills/fec-legacy-web-standard/SKILL.md +1 -1
  161. package/skills/fec-refactor-clean/SKILL.md +3 -0
  162. package/skills/fec-refactoring/SKILL.md +83 -0
  163. package/skills/fec-refactoring/references/principles.md +60 -0
  164. package/skills/fec-refactoring/references/refactoring-vs-feature-change.md +27 -0
  165. package/skills/fec-refactoring/references/when-to-refactor.md +31 -0
  166. package/skills/fec-refactoring/references/workflow.md +90 -0
  167. package/skills/fec-refactoring-api/SKILL.md +25 -0
  168. package/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
  169. package/skills/fec-refactoring-catalog/SKILL.md +28 -0
  170. package/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
  171. package/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
  172. package/skills/fec-refactoring-catalog/references/selection-guide.md +47 -0
  173. package/skills/fec-refactoring-control/SKILL.md +25 -0
  174. package/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
  175. package/skills/fec-refactoring-data/SKILL.md +25 -0
  176. package/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
  177. package/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
  178. package/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
  179. package/skills/fec-refactoring-functions/SKILL.md +25 -0
  180. package/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
  181. package/skills/fec-refactoring-inheritance/SKILL.md +25 -0
  182. package/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
  183. package/skills/fec-refactoring-move-features/SKILL.md +25 -0
  184. package/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
  185. package/skills/fec-refactoring-validation/SKILL.md +59 -0
  186. package/skills/fec-refactoring-validation/references/behavior-preservation.md +53 -0
  187. package/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +42 -0
  188. package/skills/fec-security-review/SKILL.md +16 -0
  189. package/skills/fec-security-review/references/report-template.md +10 -0
  190. package/skills/fec-tdd-workflow/SKILL.md +5 -1
  191. package/skills/metadata.json +434 -71
  192. package/skills/relations.json +264 -0
  193. package/templates/shared/rules/fec-agent-workflow.md +1 -0
  194. package/docs/superpowers/plans/2026-05-29-fec-debug.md +0 -491
  195. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +0 -340
@@ -0,0 +1,248 @@
1
+ # Data Refactorings
2
+
3
+ These cards transform the supplied standard catalog into concise operational guidance for frontend agents. Standard IDs/names are preserved; examples and framework adaptations are original.
4
+
5
+ ## RF-SPLIT-VARIABLE — Split Variable
6
+
7
+ ### Intent
8
+ Give distinct assignments distinct variables when one variable currently represents more than one thing.
9
+
10
+ ### Typical Signals
11
+ - A local variable is reassigned for unrelated purposes or a parameter is overwritten.
12
+
13
+ ### Avoid When
14
+ - Loop counters or deliberate accumulators are not automatically candidates.
15
+
16
+ ### Preconditions
17
+ - Current observable behavior and affected callers are understood.
18
+ - The target scope is inside a declared diff budget and can be verified after this one primary transformation.
19
+
20
+ ### Mechanics
21
+ 1. Identify each semantic role of the variable.
22
+ 2. Introduce a separate variable for the later role.
23
+ 3. Replace reads belonging to that role.
24
+ 4. Repeat until each variable has one meaning.
25
+
26
+ ### Behavior-Preservation Checkpoints
27
+ - Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
28
+ - For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
29
+
30
+ ### Related Code Smells
31
+ - `SMELL-MUTABLE-DATA`
32
+
33
+ ### Composes Well With
34
+ - Combine only with a separately justified next transformation; no fixed sequence is required.
35
+
36
+ ### JavaScript Notes
37
+ - Preserve equality, identity, mutation timing, serialization, and property access semantics.
38
+
39
+ ### TypeScript Notes
40
+ - Model reference/value intent with `readonly`, narrow domain types, and explicit DTO adapters rather than unsafe casts.
41
+
42
+ ### React Notes
43
+ - Object identity can affect state updates, memoization, dependency arrays, selectors, and reconciliation.
44
+
45
+ ### Vue Notes
46
+ - Proxy/reference identity affects `reactive`, `ref`, `computed`, `watch`, Pinia subscriptions, and template updates.
47
+
48
+ ### Frontend-Craft Adaptation
49
+ - Treat state identity as observable frontend behavior; choose value/reference semantics deliberately.
50
+
51
+ ### Example Transformation
52
+ Before: `result` first stores normalized input and later stores API output. After: use `normalizedDraft` and `response`.
53
+
54
+ ## RF-RENAME-FIELD — Rename Field
55
+
56
+ ### Intent
57
+ Rename a field so the data model uses accurate domain vocabulary.
58
+
59
+ ### Typical Signals
60
+ - A field name is ambiguous, misleading, or no longer matches the concept.
61
+
62
+ ### Avoid When
63
+ - Treat DTO, persisted storage, URL/query, analytics, and backend field names as contracts unless a compatibility mapping exists.
64
+
65
+ ### Preconditions
66
+ - Current observable behavior and affected callers are understood.
67
+ - The target scope is inside a declared diff budget and can be verified after this one primary transformation.
68
+
69
+ ### Mechanics
70
+ 1. Map internal and serialized/external uses.
71
+ 2. Add the new field/accessor or translation at the boundary.
72
+ 3. Migrate internal reads/writes.
73
+ 4. Remove old compatibility only when consumers are migrated.
74
+
75
+ ### Behavior-Preservation Checkpoints
76
+ - Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
77
+ - For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
78
+
79
+ ### Related Code Smells
80
+ - `SMELL-MYSTERIOUS-NAME`
81
+
82
+ ### Composes Well With
83
+ - Combine only with a separately justified next transformation; no fixed sequence is required.
84
+
85
+ ### JavaScript Notes
86
+ - Preserve equality, identity, mutation timing, serialization, and property access semantics.
87
+
88
+ ### TypeScript Notes
89
+ - Model reference/value intent with `readonly`, narrow domain types, and explicit DTO adapters rather than unsafe casts.
90
+
91
+ ### React Notes
92
+ - Object identity can affect state updates, memoization, dependency arrays, selectors, and reconciliation.
93
+
94
+ ### Vue Notes
95
+ - Proxy/reference identity affects `reactive`, `ref`, `computed`, `watch`, Pinia subscriptions, and template updates.
96
+
97
+ ### Frontend-Craft Adaptation
98
+ - Treat state identity as observable frontend behavior; choose value/reference semantics deliberately.
99
+
100
+ ### Example Transformation
101
+ Before: internal `mailId` actually means thread ID. After: rename to `threadId` internally while preserving backend DTO mapping if the API still sends `mailId`.
102
+
103
+ ## RF-REPLACE-DERIVED-VARIABLE-WITH-QUERY — Replace Derived Variable with Query
104
+
105
+ ### Intent
106
+ Compute derived state from its source instead of manually keeping a stored duplicate synchronized.
107
+
108
+ ### Typical Signals
109
+ - A stored field can be deterministically derived and update paths can drift.
110
+
111
+ ### Avoid When
112
+ - Avoid naive recomputation when the calculation is expensive; use memoization only if identity/dependency semantics are understood.
113
+
114
+ ### Preconditions
115
+ - Current observable behavior and affected callers are understood.
116
+ - The target scope is inside a declared diff budget and can be verified after this one primary transformation.
117
+
118
+ ### Mechanics
119
+ 1. Define the derivation as a query/computed value.
120
+ 2. Replace reads of stored derived state.
121
+ 3. Remove synchronization writes.
122
+ 4. Verify recomputation cost, memoization, and reactive dependencies.
123
+
124
+ ### Behavior-Preservation Checkpoints
125
+ - Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
126
+ - For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
127
+
128
+ ### Related Code Smells
129
+ - `SMELL-MUTABLE-DATA`
130
+
131
+ ### Composes Well With
132
+ - Combine only with a separately justified next transformation; no fixed sequence is required.
133
+
134
+ ### JavaScript Notes
135
+ - Preserve equality, identity, mutation timing, serialization, and property access semantics.
136
+
137
+ ### TypeScript Notes
138
+ - Model reference/value intent with `readonly`, narrow domain types, and explicit DTO adapters rather than unsafe casts.
139
+
140
+ ### React Notes
141
+ - Object identity can affect state updates, memoization, dependency arrays, selectors, and reconciliation.
142
+
143
+ ### Vue Notes
144
+ - Proxy/reference identity affects `reactive`, `ref`, `computed`, `watch`, Pinia subscriptions, and template updates.
145
+
146
+ ### Frontend-Craft Adaptation
147
+ - Treat state identity as observable frontend behavior; choose value/reference semantics deliberately.
148
+
149
+ ### Example Transformation
150
+ Before: React state stores both `items` and `totalCount = items.length`. After: derive the count, using memoization only if the real calculation warrants it.
151
+
152
+ ## RF-CHANGE-REFERENCE-TO-VALUE — Change Reference to Value
153
+
154
+ ### Intent
155
+ Use immutable value semantics when objects are defined entirely by their data and shared identity is unnecessary.
156
+
157
+ ### Typical Signals
158
+ - Equivalent values should compare by content and independent replacement is safer than shared mutation.
159
+
160
+ ### Avoid When
161
+ - Avoid when shared identity, lifecycle, caching, subscriptions, or coordinated updates are meaningful.
162
+
163
+ ### Preconditions
164
+ - Current observable behavior and affected callers are understood.
165
+ - The target scope is inside a declared diff budget and can be verified after this one primary transformation.
166
+
167
+ ### Mechanics
168
+ 1. Identify identity-dependent behavior.
169
+ 2. Make the value immutable and define equality/creation semantics.
170
+ 3. Replace mutation with replacement.
171
+ 4. Verify React/Vue equality/reactivity and cache behavior.
172
+
173
+ ### Behavior-Preservation Checkpoints
174
+ - Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
175
+ - For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
176
+
177
+ ### Related Code Smells
178
+ - `SMELL-MUTABLE-DATA`
179
+
180
+ ### Composes Well With
181
+ - Combine only with a separately justified next transformation; no fixed sequence is required.
182
+
183
+ ### JavaScript Notes
184
+ - Preserve equality, identity, mutation timing, serialization, and property access semantics.
185
+
186
+ ### TypeScript Notes
187
+ - Model reference/value intent with `readonly`, narrow domain types, and explicit DTO adapters rather than unsafe casts.
188
+
189
+ ### React Notes
190
+ - Object identity can affect state updates, memoization, dependency arrays, selectors, and reconciliation.
191
+
192
+ ### Vue Notes
193
+ - Proxy/reference identity affects `reactive`, `ref`, `computed`, `watch`, Pinia subscriptions, and template updates.
194
+
195
+ ### Frontend-Craft Adaptation
196
+ - Treat state identity as observable frontend behavior; choose value/reference semantics deliberately.
197
+
198
+ ### Example Transformation
199
+ Before: a mutable `DateRange` object is shared and changed in place. After: immutable ranges are replaced as values when no shared identity is required.
200
+
201
+ ## RF-CHANGE-VALUE-TO-REFERENCE — Change Value to Reference
202
+
203
+ ### Intent
204
+ Use a canonical shared object when identity and coordinated updates matter more than independent copies.
205
+
206
+ ### Typical Signals
207
+ - Multiple copies represent the same entity and must stay synchronized.
208
+
209
+ ### Avoid When
210
+ - Avoid introducing a global identity map when values are naturally independent snapshots.
211
+
212
+ ### Preconditions
213
+ - Current observable behavior and affected callers are understood.
214
+ - The target scope is inside a declared diff budget and can be verified after this one primary transformation.
215
+
216
+ ### Mechanics
217
+ 1. Choose a stable identity key and owner/registry.
218
+ 2. Resolve values to the canonical reference.
219
+ 3. Migrate consumers incrementally.
220
+ 4. Verify update propagation, cache lifetime, and serialization boundaries.
221
+
222
+ ### Behavior-Preservation Checkpoints
223
+ - Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
224
+ - For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
225
+
226
+ ### Related Code Smells
227
+ - No single code smell required; select from concrete structural evidence.
228
+
229
+ ### Composes Well With
230
+ - Combine only with a separately justified next transformation; no fixed sequence is required.
231
+
232
+ ### JavaScript Notes
233
+ - Preserve equality, identity, mutation timing, serialization, and property access semantics.
234
+
235
+ ### TypeScript Notes
236
+ - Model reference/value intent with `readonly`, narrow domain types, and explicit DTO adapters rather than unsafe casts.
237
+
238
+ ### React Notes
239
+ - Object identity can affect state updates, memoization, dependency arrays, selectors, and reconciliation.
240
+
241
+ ### Vue Notes
242
+ - Proxy/reference identity affects `reactive`, `ref`, `computed`, `watch`, Pinia subscriptions, and template updates.
243
+
244
+ ### Frontend-Craft Adaptation
245
+ - Treat state identity as observable frontend behavior; choose value/reference semantics deliberately.
246
+
247
+ ### Example Transformation
248
+ Before: each message stores a copied sender object. After: sender IDs resolve to canonical contact entities when shared updates must propagate.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: fec-refactoring-encapsulation
3
+ description: Use when behavior-preserving frontend refactoring focuses on record, collection, value, responsibility, delegation, or algorithm boundaries, and the selected technique needs family-specific mechanics, risks, and JavaScript/TypeScript/React/Vue adaptation.
4
+ ---
5
+
6
+ # Encapsulation Refactorings
7
+
8
+ ## Overview
9
+ Use this family after evidence identifies a fitting structural transformation. Apply one primary technique at a time and verify immediately.
10
+
11
+ ## Procedure
12
+ 1. Confirm the selected technique and its preconditions in [Encapsulation Refactorings](references/encapsulation-refactorings.md).
13
+ 2. Record affected behavior and a diff budget.
14
+ 3. Apply only the selected technique's smallest viable step.
15
+ 4. Verify the step before composing another transformation.
16
+ 5. Stop and reassess when public contracts, lifecycle, state identity, or actual scope exceed expectations.
17
+
18
+ ## Quick Reference
19
+ The family reference contains 9 canonical techniques with intent, signals, avoid conditions, mechanics, preservation checkpoints, smell links, composition hints, JavaScript/TypeScript notes, React/Vue notes, adaptation guidance, and original frontend examples.
20
+
21
+ ## Common Mistakes
22
+ - Choosing a technique by name without checking its preconditions.
23
+ - Combining several structural intentions in one diff.
24
+ - Assuming a classical class-based form is mandatory in modern frontend code.
25
+ - Treating passing tests as proof when the relevant behavior is not covered.