sisyo 1.7.0 → 1.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 (61) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +177 -166
  3. package/bin/known-hashes.json +8 -1
  4. package/bin/sisyo.js +285 -285
  5. package/package.json +30 -30
  6. package/templates/.claude/rules/agents-and-tests.md +32 -24
  7. package/templates/.claude/rules/docs.md +39 -19
  8. package/templates/.claude/skills/fastapi-best-practices/ASYNC-PATTERNS.md +121 -121
  9. package/templates/.claude/skills/fastapi-best-practices/DATABASE.md +153 -153
  10. package/templates/.claude/skills/fastapi-best-practices/DEPENDENCIES.md +140 -140
  11. package/templates/.claude/skills/fastapi-best-practices/PROJECT-STRUCTURE.md +90 -90
  12. package/templates/.claude/skills/fastapi-best-practices/PYDANTIC-GUIDE.md +155 -155
  13. package/templates/.claude/skills/fastapi-best-practices/SKILL.md +123 -123
  14. package/templates/.claude/skills/g6-style/SKILL.md +125 -125
  15. package/templates/.claude/skills/g6-style/references/checks.md +58 -58
  16. package/templates/.claude/skills/g6-style/references/imagery.md +103 -103
  17. package/templates/.claude/skills/g6-style/references/motion.md +121 -121
  18. package/templates/.claude/skills/g6-style/references/sections.md +263 -263
  19. package/templates/.claude/skills/g6-style/references/tokens.md +197 -197
  20. package/templates/.claude/skills/hindsight/SKILL.md +175 -175
  21. package/templates/.claude/skills/hoang-auth/SKILL.md +188 -0
  22. package/templates/.claude/skills/html-docs/SKILL.md +207 -207
  23. package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -153
  24. package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -47
  25. package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -46
  26. package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -17
  27. package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -6
  28. package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -4
  29. package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -6
  30. package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -22
  31. package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -10
  32. package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -5
  33. package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -20
  34. package/templates/.claude/skills/i18n-multilang/references/format.md +100 -100
  35. package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -97
  36. package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -256
  37. package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -161
  38. package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -142
  39. package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -107
  40. package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -143
  41. package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -271
  42. package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -1041
  43. package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -1013
  44. package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -478
  45. package/templates/.claude/skills/neon-game-ui-ux-skill/COMPONENTS.md +490 -490
  46. package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -246
  47. package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -249
  48. package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -362
  49. package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -168
  50. package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -137
  51. package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -323
  52. package/templates/.claude/skills/react-page-oriented/SKILL.md +407 -407
  53. package/templates/.claude/skills/react-page-oriented/triggers.md +12 -12
  54. package/templates/.claude/skills/terraform-best-practices/SKILL.md +341 -341
  55. package/templates/.claude/skills/typesafe-jev/SKILL.md +148 -148
  56. package/templates/.claude/skills/vibe-docs/SKILL.md +139 -242
  57. package/templates/SISYO.md +39 -37
  58. package/templates/docs/99_progress/features.md +7 -7
  59. package/templates/docs/99_progress/handoff.md +19 -19
  60. package/templates/docs/99_progress/todo.md +15 -15
  61. package/templates/docs/MAP.md +26 -26
@@ -1,407 +1,407 @@
1
- ---
2
- name: react-page-oriented
3
- description:
4
- React page-oriented folder architecture. Components live where they're used.
5
- Structure mirrors UI hierarchy. Use when creating pages, deciding file vs folder,
6
- organizing components, or setting up React/Next.js projects. Defines co-location
7
- rules for hooks, styles, tests.
8
- license: MIT
9
- metadata:
10
- author: HoangThang
11
- version: '2.0.0'
12
- ---
13
-
14
- # React Page-Oriented Architecture
15
-
16
- ## Philosophy
17
-
18
- **Components live where they're used. Structure mirrors UI hierarchy.**
19
-
20
- - Child components belong IN their parent folder (not in a separate `components/` subfolder)
21
- - Shared components are organized by LEVEL (page-level vs app-level)
22
- - No premature abstraction - extract only when truly needed
23
-
24
- > **Component Patterns:** This skill covers **folder/file organization only**.
25
- > For component composition patterns (compound components, context, state management),
26
- > follow the **vercel-composition-patterns** skill.
27
-
28
- ---
29
-
30
- ## Core Rules
31
-
32
- ### Rule 1: Page as Root
33
-
34
- Every feature starts with a Page component as the root.
35
-
36
- ```
37
- src/pages/
38
- ├── ProductPage/
39
- ├── OrderPage/
40
- ├── CustomerPage/
41
- └── DashboardPage/
42
- ```
43
-
44
- ### Rule 2: Children Live IN Parent Folder
45
-
46
- **Child components go DIRECTLY in parent folder** - NOT in a `components/` subfolder.
47
-
48
- ```
49
- ❌ DON'T: Separate components folder
50
- ChatFrame/
51
- ├── ChatFrame.tsx
52
- ├── components/ # ❌ No! Don't create this
53
- │ ├── ChatInput.tsx
54
- │ └── ChatMessages.tsx
55
- └── context/ # ❌ No! Don't create this
56
- └── ChatContext.tsx
57
-
58
- ✅ DO: Children directly in parent
59
- ChatFrame/
60
- ├── ChatFrame.tsx # Parent component
61
- ├── ChatFrame.css # Parent styles
62
- ├── ChatContext.tsx # Context for this component
63
- ├── ChatInput.tsx # Child component
64
- ├── ChatMessages.tsx # Child component
65
- └── useChatFrame.ts # Hook for this component
66
- ```
67
-
68
- ### Rule 3: File vs Folder Decision
69
-
70
- **File (`.tsx`)** - Component has NO children or related files
71
-
72
- ```
73
- StatusBadge.tsx ✅ Simple, no children
74
- LoadingSpinner.tsx ✅ Static UI
75
- ```
76
-
77
- **Folder** - Component HAS children OR related files (css, hook, context)
78
-
79
- ```
80
- ChatFrame/ ✅ Has children (ChatInput, ChatMessages)
81
- ├── ChatFrame.tsx
82
- ├── ChatFrame.css
83
- ├── ChatInput.tsx
84
- └── ChatMessages.tsx
85
-
86
- Avatar/ ✅ Has related files (css)
87
- ├── Avatar.tsx
88
- └── Avatar.css
89
- ```
90
-
91
- ### Rule 4: Shared Components by Level
92
-
93
- Components shared within a scope stay at that scope's root:
94
-
95
- | Scope | Location | Example |
96
- |-------|----------|---------|
97
- | Used by 1 component | Inside that component's folder | `ChatFrame/ChatInput.tsx` |
98
- | Used by siblings in same page | Page folder root | `ProductPage/StatusBadge.tsx` |
99
- | Used across multiple pages | `src/components/` | `components/Button.tsx` |
100
- | Used app-wide (layout) | `src/layouts/` | `layouts/Sidebar.tsx` |
101
-
102
- **Example - Page-level shared component:**
103
-
104
- ```
105
- ProductPage/
106
- ├── ProductPage.tsx
107
- ├── StatusBadge.tsx # ✅ Shared by ProductList AND ProductDetail
108
- ├── ProductList/
109
- │ ├── ProductList.tsx # Uses StatusBadge
110
- │ └── ProductRow.tsx
111
- └── ProductDetail/
112
- └── ProductDetail.tsx # Also uses StatusBadge
113
- ```
114
-
115
- ### Rule 5: No index.tsx for Re-export
116
-
117
- ❌ **Never do this:**
118
- ```
119
- ProductList/
120
- ├── index.tsx # export { ProductList } from './ProductList'
121
- └── ProductList.tsx
122
- ```
123
-
124
- ✅ **Always import directly:**
125
- ```tsx
126
- import { ProductList } from './ProductList/ProductList'
127
- import { Button } from '@/components/Button'
128
- ```
129
-
130
- ### Rule 6: Maximum Nesting Depth = 4
131
-
132
- ```
133
- pages/ProductPage/ProductList/ProductRow/RowActions.tsx
134
- │ │ │ │ └── Level 4 (MAX)
135
- │ │ │ └── Level 3
136
- │ │ └── Level 2
137
- │ └── Level 1
138
- └── Root
139
- ```
140
-
141
- If deeper → Flatten or move to `components/`
142
-
143
- ---
144
-
145
- ## Detailed Structure Example
146
-
147
- ```
148
- src/
149
- ├── pages/
150
- │ ├── ChatPage/
151
- │ │ ├── ChatPage.tsx # Page entry
152
- │ │ ├── ChatPage.css
153
- │ │ │
154
- │ │ ├── ChatFrame/ # Main chat UI
155
- │ │ │ ├── ChatFrame.tsx # Parent component
156
- │ │ │ ├── ChatFrame.css
157
- │ │ │ ├── ChatContext.tsx # Context lives WITH provider
158
- │ │ │ ├── useChatFrame.ts # Hook lives WITH component
159
- │ │ │ ├── ChatHeader.tsx # Child - simple file
160
- │ │ │ ├── ChatInput.tsx # Child - simple file
161
- │ │ │ ├── ChatMessages/ # Child - has own children
162
- │ │ │ │ ├── ChatMessages.tsx
163
- │ │ │ │ ├── ChatMessages.css
164
- │ │ │ │ ├── MessageItem.tsx # Grandchild
165
- │ │ │ │ └── TypingIndicator.tsx
166
- │ │ │ └── ChatError.tsx # Child - simple file
167
- │ │ │
168
- │ │ └── SessionList/ # Sidebar component
169
- │ │ ├── SessionList.tsx
170
- │ │ ├── SessionItem.tsx
171
- │ │ └── useSessionList.ts
172
- │ │
173
- │ ├── ProductPage/
174
- │ │ ├── ProductPage.tsx
175
- │ │ ├── StatusBadge.tsx # ✅ Shared within this page only
176
- │ │ │
177
- │ │ ├── ProductList/
178
- │ │ │ ├── ProductList.tsx
179
- │ │ │ ├── ProductRow.tsx # Uses parent's StatusBadge
180
- │ │ │ └── useProductList.ts
181
- │ │ │
182
- │ │ └── ProductDetail/
183
- │ │ ├── ProductDetail.tsx # Uses parent's StatusBadge
184
- │ │ ├── ProductGallery/
185
- │ │ │ ├── ProductGallery.tsx
186
- │ │ │ ├── Thumbnail.tsx
187
- │ │ │ └── Lightbox.tsx
188
- │ │ └── ProductReviews/
189
- │ │ ├── ProductReviews.tsx
190
- │ │ ├── ReviewItem.tsx
191
- │ │ └── ReviewForm.tsx
192
- │ │
193
- │ └── OrderPage/
194
- │ ├── OrderPage.tsx
195
- │ └── OrderList/
196
- │ ├── OrderList.tsx
197
- │ └── OrderRow.tsx
198
- │
199
- ├── components/ # ✅ Cross-page shared ONLY
200
- │ ├── Button.tsx # Simple - file
201
- │ ├── Input.tsx
202
- │ ├── Modal/ # Has children - folder
203
- │ │ ├── Modal.tsx
204
- │ │ ├── Modal.css
205
- │ │ ├── ModalHeader.tsx
206
- │ │ ├── ModalBody.tsx
207
- │ │ └── ModalFooter.tsx
208
- │ ├── Avatar/
209
- │ │ ├── Avatar.tsx
210
- │ │ └── Avatar.css
211
- │ └── MarkdownRenderer/
212
- │ ├── MarkdownRenderer.tsx
213
- │ └── MarkdownRenderer.css
214
- │
215
- ├── layouts/
216
- │ ├── MainLayout.tsx
217
- │ ├── Sidebar.tsx
218
- │ └── Header.tsx
219
- │
220
- ├── hooks/ # ✅ App-wide hooks ONLY
221
- │ ├── useAuth.ts
222
- │ └── useApi.ts
223
- │
224
- ├── store/ # State management
225
- │ ├── chatStore.ts
226
- │ └── sessionStore.ts
227
- │
228
- ├── services/ # API calls
229
- │ └── AgentClient.ts
230
- │
231
- ├── types/ # Global types
232
- │ ├── chat.types.ts
233
- │ └── session.types.ts
234
- │
235
- └── App.tsx
236
- ```
237
-
238
- ---
239
-
240
- ## Co-location Patterns
241
-
242
- ### Everything Related Lives Together
243
-
244
- ```
245
- ChatFrame/
246
- ├── ChatFrame.tsx # Component
247
- ├── ChatFrame.css # Styles
248
- ├── ChatFrame.test.tsx # Tests
249
- ├── ChatFrame.types.ts # Types (if complex)
250
- ├── ChatContext.tsx # Context for this subtree
251
- ├── useChatFrame.ts # Logic hook
252
- ├── ChatHeader.tsx # Child component
253
- ├── ChatInput.tsx # Child component
254
- └── ChatMessages/ # Complex child → folder
255
- ├── ChatMessages.tsx
256
- └── MessageItem.tsx
257
- ```
258
-
259
- ### Context Lives with Provider
260
-
261
- Context should be in the same folder as the component that provides it:
262
-
263
- ```
264
- ❌ DON'T:
265
- src/
266
- ├── context/
267
- │ └── ChatContext.tsx # Far from provider
268
- └── pages/ChatPage/ChatFrame/ChatFrame.tsx
269
-
270
- ✅ DO:
271
- src/pages/ChatPage/
272
- └── ChatFrame/
273
- ├── ChatFrame.tsx # Provides context
274
- └── ChatContext.tsx # Lives here
275
- ```
276
-
277
- ### Hooks Live with Components
278
-
279
- ```
280
- ❌ DON'T:
281
- src/
282
- ├── hooks/
283
- │ └── useChatFrame.ts # Only used by ChatFrame
284
- └── pages/ChatPage/ChatFrame/ChatFrame.tsx
285
-
286
- ✅ DO:
287
- src/pages/ChatPage/
288
- └── ChatFrame/
289
- ├── ChatFrame.tsx
290
- └── useChatFrame.ts # Lives here
291
- ```
292
-
293
- ---
294
-
295
- ## When to Extract to `components/`
296
-
297
- Extract when **ALL** apply:
298
-
299
- - [ ] Used by 2+ different pages
300
- - [ ] Truly generic (no page-specific logic)
301
- - [ ] Stable API (props won't change often)
302
- - [ ] Self-contained (minimal dependencies)
303
-
304
- **Do NOT extract when:**
305
-
306
- - Used by only 1 page → Keep in page folder
307
- - Used by siblings in same page → Keep at page root
308
- - Contains page-specific logic → Keep local
309
- - Still evolving → Keep local, extract later
310
-
311
- ---
312
-
313
- ## Import Order
314
-
315
- ```tsx
316
- // 1. React
317
- import { useState, useEffect } from 'react'
318
-
319
- // 2. External libraries
320
- import { useQuery } from '@tanstack/react-query'
321
-
322
- // 3. Absolute imports (shared)
323
- import { Button } from '@/components/Button'
324
- import { useAuth } from '@/hooks/useAuth'
325
-
326
- // 4. Relative imports (local - same page/component tree)
327
- import { ChatInput } from './ChatInput'
328
- import { useChatFrame } from './useChatFrame'
329
-
330
- // 5. Types
331
- import type { Message } from '@/types/chat.types'
332
-
333
- // 6. Styles
334
- import './ChatFrame.css'
335
- ```
336
-
337
- ---
338
-
339
- ## Anti-Patterns
340
-
341
- ### ❌ Separate `components/` folder inside pages
342
-
343
- ```
344
- ❌ DON'T:
345
- pages/ChatPage/
346
- ├── ChatPage.tsx
347
- ├── components/ # ❌ Don't create this!
348
- │ ├── ChatFrame.tsx
349
- │ └── ChatInput.tsx
350
- └── context/ # ❌ Don't create this!
351
- └── ChatContext.tsx
352
-
353
- ✅ DO:
354
- pages/ChatPage/
355
- ├── ChatPage.tsx
356
- ├── ChatFrame/ # Children in parent folder
357
- │ ├── ChatFrame.tsx
358
- │ ├── ChatContext.tsx # Context with component
359
- │ └── ChatInput.tsx
360
- ```
361
-
362
- ### ❌ Barrel Files
363
-
364
- ```tsx
365
- // ❌ DON'T
366
- import { ChatFrame, ChatInput } from '@/pages/ChatPage'
367
-
368
- // ✅ DO
369
- import { ChatFrame } from '@/pages/ChatPage/ChatFrame/ChatFrame'
370
- ```
371
-
372
- ### ❌ Premature Extraction
373
-
374
- ```
375
- ❌ DON'T: Extract before needed
376
- components/
377
- └── ChatStatusBadge.tsx # Only used in ChatPage!
378
-
379
- ✅ DO: Keep local
380
- pages/ChatPage/StatusBadge.tsx
381
- ```
382
-
383
- ---
384
-
385
- ## Quick Reference
386
-
387
- ```
388
- Q: Where does child component go?
389
- A: Directly in parent folder. NO separate components/ subfolder.
390
-
391
- Q: Where does context go?
392
- A: Same folder as the component that provides it.
393
-
394
- Q: Where does hook go?
395
- A: Same folder as the component that uses it (if used by 1).
396
- In hooks/ only if used app-wide.
397
-
398
- Q: File or Folder?
399
- A: Has children OR related files (css, hook)? → Folder
400
- Just a simple component? → File
401
-
402
- Q: When to extract to components/?
403
- A: Only when 2+ different pages need it.
404
-
405
- Q: Shared within one page?
406
- A: Keep at that page's root folder.
407
- ```
1
+ ---
2
+ name: react-page-oriented
3
+ description:
4
+ React page-oriented folder architecture. Components live where they're used.
5
+ Structure mirrors UI hierarchy. Use when creating pages, deciding file vs folder,
6
+ organizing components, or setting up React/Next.js projects. Defines co-location
7
+ rules for hooks, styles, tests.
8
+ license: MIT
9
+ metadata:
10
+ author: HoangThang
11
+ version: '2.0.0'
12
+ ---
13
+
14
+ # React Page-Oriented Architecture
15
+
16
+ ## Philosophy
17
+
18
+ **Components live where they're used. Structure mirrors UI hierarchy.**
19
+
20
+ - Child components belong IN their parent folder (not in a separate `components/` subfolder)
21
+ - Shared components are organized by LEVEL (page-level vs app-level)
22
+ - No premature abstraction - extract only when truly needed
23
+
24
+ > **Component Patterns:** This skill covers **folder/file organization only**.
25
+ > For component composition patterns (compound components, context, state management),
26
+ > follow the **vercel-composition-patterns** skill.
27
+
28
+ ---
29
+
30
+ ## Core Rules
31
+
32
+ ### Rule 1: Page as Root
33
+
34
+ Every feature starts with a Page component as the root.
35
+
36
+ ```
37
+ src/pages/
38
+ ├── ProductPage/
39
+ ├── OrderPage/
40
+ ├── CustomerPage/
41
+ └── DashboardPage/
42
+ ```
43
+
44
+ ### Rule 2: Children Live IN Parent Folder
45
+
46
+ **Child components go DIRECTLY in parent folder** - NOT in a `components/` subfolder.
47
+
48
+ ```
49
+ ❌ DON'T: Separate components folder
50
+ ChatFrame/
51
+ ├── ChatFrame.tsx
52
+ ├── components/ # ❌ No! Don't create this
53
+ │ ├── ChatInput.tsx
54
+ │ └── ChatMessages.tsx
55
+ └── context/ # ❌ No! Don't create this
56
+ └── ChatContext.tsx
57
+
58
+ ✅ DO: Children directly in parent
59
+ ChatFrame/
60
+ ├── ChatFrame.tsx # Parent component
61
+ ├── ChatFrame.css # Parent styles
62
+ ├── ChatContext.tsx # Context for this component
63
+ ├── ChatInput.tsx # Child component
64
+ ├── ChatMessages.tsx # Child component
65
+ └── useChatFrame.ts # Hook for this component
66
+ ```
67
+
68
+ ### Rule 3: File vs Folder Decision
69
+
70
+ **File (`.tsx`)** - Component has NO children or related files
71
+
72
+ ```
73
+ StatusBadge.tsx ✅ Simple, no children
74
+ LoadingSpinner.tsx ✅ Static UI
75
+ ```
76
+
77
+ **Folder** - Component HAS children OR related files (css, hook, context)
78
+
79
+ ```
80
+ ChatFrame/ ✅ Has children (ChatInput, ChatMessages)
81
+ ├── ChatFrame.tsx
82
+ ├── ChatFrame.css
83
+ ├── ChatInput.tsx
84
+ └── ChatMessages.tsx
85
+
86
+ Avatar/ ✅ Has related files (css)
87
+ ├── Avatar.tsx
88
+ └── Avatar.css
89
+ ```
90
+
91
+ ### Rule 4: Shared Components by Level
92
+
93
+ Components shared within a scope stay at that scope's root:
94
+
95
+ | Scope | Location | Example |
96
+ |-------|----------|---------|
97
+ | Used by 1 component | Inside that component's folder | `ChatFrame/ChatInput.tsx` |
98
+ | Used by siblings in same page | Page folder root | `ProductPage/StatusBadge.tsx` |
99
+ | Used across multiple pages | `src/components/` | `components/Button.tsx` |
100
+ | Used app-wide (layout) | `src/layouts/` | `layouts/Sidebar.tsx` |
101
+
102
+ **Example - Page-level shared component:**
103
+
104
+ ```
105
+ ProductPage/
106
+ ├── ProductPage.tsx
107
+ ├── StatusBadge.tsx # ✅ Shared by ProductList AND ProductDetail
108
+ ├── ProductList/
109
+ │ ├── ProductList.tsx # Uses StatusBadge
110
+ │ └── ProductRow.tsx
111
+ └── ProductDetail/
112
+ └── ProductDetail.tsx # Also uses StatusBadge
113
+ ```
114
+
115
+ ### Rule 5: No index.tsx for Re-export
116
+
117
+ ❌ **Never do this:**
118
+ ```
119
+ ProductList/
120
+ ├── index.tsx # export { ProductList } from './ProductList'
121
+ └── ProductList.tsx
122
+ ```
123
+
124
+ ✅ **Always import directly:**
125
+ ```tsx
126
+ import { ProductList } from './ProductList/ProductList'
127
+ import { Button } from '@/components/Button'
128
+ ```
129
+
130
+ ### Rule 6: Maximum Nesting Depth = 4
131
+
132
+ ```
133
+ pages/ProductPage/ProductList/ProductRow/RowActions.tsx
134
+ │ │ │ │ └── Level 4 (MAX)
135
+ │ │ │ └── Level 3
136
+ │ │ └── Level 2
137
+ │ └── Level 1
138
+ └── Root
139
+ ```
140
+
141
+ If deeper → Flatten or move to `components/`
142
+
143
+ ---
144
+
145
+ ## Detailed Structure Example
146
+
147
+ ```
148
+ src/
149
+ ├── pages/
150
+ │ ├── ChatPage/
151
+ │ │ ├── ChatPage.tsx # Page entry
152
+ │ │ ├── ChatPage.css
153
+ │ │ │
154
+ │ │ ├── ChatFrame/ # Main chat UI
155
+ │ │ │ ├── ChatFrame.tsx # Parent component
156
+ │ │ │ ├── ChatFrame.css
157
+ │ │ │ ├── ChatContext.tsx # Context lives WITH provider
158
+ │ │ │ ├── useChatFrame.ts # Hook lives WITH component
159
+ │ │ │ ├── ChatHeader.tsx # Child - simple file
160
+ │ │ │ ├── ChatInput.tsx # Child - simple file
161
+ │ │ │ ├── ChatMessages/ # Child - has own children
162
+ │ │ │ │ ├── ChatMessages.tsx
163
+ │ │ │ │ ├── ChatMessages.css
164
+ │ │ │ │ ├── MessageItem.tsx # Grandchild
165
+ │ │ │ │ └── TypingIndicator.tsx
166
+ │ │ │ └── ChatError.tsx # Child - simple file
167
+ │ │ │
168
+ │ │ └── SessionList/ # Sidebar component
169
+ │ │ ├── SessionList.tsx
170
+ │ │ ├── SessionItem.tsx
171
+ │ │ └── useSessionList.ts
172
+ │ │
173
+ │ ├── ProductPage/
174
+ │ │ ├── ProductPage.tsx
175
+ │ │ ├── StatusBadge.tsx # ✅ Shared within this page only
176
+ │ │ │
177
+ │ │ ├── ProductList/
178
+ │ │ │ ├── ProductList.tsx
179
+ │ │ │ ├── ProductRow.tsx # Uses parent's StatusBadge
180
+ │ │ │ └── useProductList.ts
181
+ │ │ │
182
+ │ │ └── ProductDetail/
183
+ │ │ ├── ProductDetail.tsx # Uses parent's StatusBadge
184
+ │ │ ├── ProductGallery/
185
+ │ │ │ ├── ProductGallery.tsx
186
+ │ │ │ ├── Thumbnail.tsx
187
+ │ │ │ └── Lightbox.tsx
188
+ │ │ └── ProductReviews/
189
+ │ │ ├── ProductReviews.tsx
190
+ │ │ ├── ReviewItem.tsx
191
+ │ │ └── ReviewForm.tsx
192
+ │ │
193
+ │ └── OrderPage/
194
+ │ ├── OrderPage.tsx
195
+ │ └── OrderList/
196
+ │ ├── OrderList.tsx
197
+ │ └── OrderRow.tsx
198
+ │
199
+ ├── components/ # ✅ Cross-page shared ONLY
200
+ │ ├── Button.tsx # Simple - file
201
+ │ ├── Input.tsx
202
+ │ ├── Modal/ # Has children - folder
203
+ │ │ ├── Modal.tsx
204
+ │ │ ├── Modal.css
205
+ │ │ ├── ModalHeader.tsx
206
+ │ │ ├── ModalBody.tsx
207
+ │ │ └── ModalFooter.tsx
208
+ │ ├── Avatar/
209
+ │ │ ├── Avatar.tsx
210
+ │ │ └── Avatar.css
211
+ │ └── MarkdownRenderer/
212
+ │ ├── MarkdownRenderer.tsx
213
+ │ └── MarkdownRenderer.css
214
+ │
215
+ ├── layouts/
216
+ │ ├── MainLayout.tsx
217
+ │ ├── Sidebar.tsx
218
+ │ └── Header.tsx
219
+ │
220
+ ├── hooks/ # ✅ App-wide hooks ONLY
221
+ │ ├── useAuth.ts
222
+ │ └── useApi.ts
223
+ │
224
+ ├── store/ # State management
225
+ │ ├── chatStore.ts
226
+ │ └── sessionStore.ts
227
+ │
228
+ ├── services/ # API calls
229
+ │ └── AgentClient.ts
230
+ │
231
+ ├── types/ # Global types
232
+ │ ├── chat.types.ts
233
+ │ └── session.types.ts
234
+ │
235
+ └── App.tsx
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Co-location Patterns
241
+
242
+ ### Everything Related Lives Together
243
+
244
+ ```
245
+ ChatFrame/
246
+ ├── ChatFrame.tsx # Component
247
+ ├── ChatFrame.css # Styles
248
+ ├── ChatFrame.test.tsx # Tests
249
+ ├── ChatFrame.types.ts # Types (if complex)
250
+ ├── ChatContext.tsx # Context for this subtree
251
+ ├── useChatFrame.ts # Logic hook
252
+ ├── ChatHeader.tsx # Child component
253
+ ├── ChatInput.tsx # Child component
254
+ └── ChatMessages/ # Complex child → folder
255
+ ├── ChatMessages.tsx
256
+ └── MessageItem.tsx
257
+ ```
258
+
259
+ ### Context Lives with Provider
260
+
261
+ Context should be in the same folder as the component that provides it:
262
+
263
+ ```
264
+ ❌ DON'T:
265
+ src/
266
+ ├── context/
267
+ │ └── ChatContext.tsx # Far from provider
268
+ └── pages/ChatPage/ChatFrame/ChatFrame.tsx
269
+
270
+ ✅ DO:
271
+ src/pages/ChatPage/
272
+ └── ChatFrame/
273
+ ├── ChatFrame.tsx # Provides context
274
+ └── ChatContext.tsx # Lives here
275
+ ```
276
+
277
+ ### Hooks Live with Components
278
+
279
+ ```
280
+ ❌ DON'T:
281
+ src/
282
+ ├── hooks/
283
+ │ └── useChatFrame.ts # Only used by ChatFrame
284
+ └── pages/ChatPage/ChatFrame/ChatFrame.tsx
285
+
286
+ ✅ DO:
287
+ src/pages/ChatPage/
288
+ └── ChatFrame/
289
+ ├── ChatFrame.tsx
290
+ └── useChatFrame.ts # Lives here
291
+ ```
292
+
293
+ ---
294
+
295
+ ## When to Extract to `components/`
296
+
297
+ Extract when **ALL** apply:
298
+
299
+ - [ ] Used by 2+ different pages
300
+ - [ ] Truly generic (no page-specific logic)
301
+ - [ ] Stable API (props won't change often)
302
+ - [ ] Self-contained (minimal dependencies)
303
+
304
+ **Do NOT extract when:**
305
+
306
+ - Used by only 1 page → Keep in page folder
307
+ - Used by siblings in same page → Keep at page root
308
+ - Contains page-specific logic → Keep local
309
+ - Still evolving → Keep local, extract later
310
+
311
+ ---
312
+
313
+ ## Import Order
314
+
315
+ ```tsx
316
+ // 1. React
317
+ import { useState, useEffect } from 'react'
318
+
319
+ // 2. External libraries
320
+ import { useQuery } from '@tanstack/react-query'
321
+
322
+ // 3. Absolute imports (shared)
323
+ import { Button } from '@/components/Button'
324
+ import { useAuth } from '@/hooks/useAuth'
325
+
326
+ // 4. Relative imports (local - same page/component tree)
327
+ import { ChatInput } from './ChatInput'
328
+ import { useChatFrame } from './useChatFrame'
329
+
330
+ // 5. Types
331
+ import type { Message } from '@/types/chat.types'
332
+
333
+ // 6. Styles
334
+ import './ChatFrame.css'
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Anti-Patterns
340
+
341
+ ### ❌ Separate `components/` folder inside pages
342
+
343
+ ```
344
+ ❌ DON'T:
345
+ pages/ChatPage/
346
+ ├── ChatPage.tsx
347
+ ├── components/ # ❌ Don't create this!
348
+ │ ├── ChatFrame.tsx
349
+ │ └── ChatInput.tsx
350
+ └── context/ # ❌ Don't create this!
351
+ └── ChatContext.tsx
352
+
353
+ ✅ DO:
354
+ pages/ChatPage/
355
+ ├── ChatPage.tsx
356
+ ├── ChatFrame/ # Children in parent folder
357
+ │ ├── ChatFrame.tsx
358
+ │ ├── ChatContext.tsx # Context with component
359
+ │ └── ChatInput.tsx
360
+ ```
361
+
362
+ ### ❌ Barrel Files
363
+
364
+ ```tsx
365
+ // ❌ DON'T
366
+ import { ChatFrame, ChatInput } from '@/pages/ChatPage'
367
+
368
+ // ✅ DO
369
+ import { ChatFrame } from '@/pages/ChatPage/ChatFrame/ChatFrame'
370
+ ```
371
+
372
+ ### ❌ Premature Extraction
373
+
374
+ ```
375
+ ❌ DON'T: Extract before needed
376
+ components/
377
+ └── ChatStatusBadge.tsx # Only used in ChatPage!
378
+
379
+ ✅ DO: Keep local
380
+ pages/ChatPage/StatusBadge.tsx
381
+ ```
382
+
383
+ ---
384
+
385
+ ## Quick Reference
386
+
387
+ ```
388
+ Q: Where does child component go?
389
+ A: Directly in parent folder. NO separate components/ subfolder.
390
+
391
+ Q: Where does context go?
392
+ A: Same folder as the component that provides it.
393
+
394
+ Q: Where does hook go?
395
+ A: Same folder as the component that uses it (if used by 1).
396
+ In hooks/ only if used app-wide.
397
+
398
+ Q: File or Folder?
399
+ A: Has children OR related files (css, hook)? → Folder
400
+ Just a simple component? → File
401
+
402
+ Q: When to extract to components/?
403
+ A: Only when 2+ different pages need it.
404
+
405
+ Q: Shared within one page?
406
+ A: Keep at that page's root folder.
407
+ ```