tkeron 5.3.0 → 6.0.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.
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: tkeron-organization
3
+ description: "Tkeron project organization: root=sitemap principle, directory layout, where components live, naming conventions for files and components, and the discipline of when to componentize vs leave inline. Use this skill when starting a new tkeron project, restructuring an existing one, naming new files, or deciding whether to extract markup into a component."
4
+ ---
5
+
6
+ # Tkeron — Project Organization
7
+
8
+ ## Fundamental Principle: root = sitemap
9
+
10
+ The root of `websrc/` must be a **faithful image of the final sitemap**. Every `.html` at root or inside a subdirectory maps directly to a route. Components, utils and styles live in dedicated directories that are NOT routes.
11
+
12
+ ```
13
+ websrc/
14
+ ├── index.html # → /
15
+ ├── index.ts # Browser JS for /
16
+ ├── index.pre.ts # Pre-render for /
17
+ ├── about.html # → /about
18
+ ├── pricing.html # → /pricing
19
+
20
+ ├── blog/
21
+ │ ├── index.html # → /blog/
22
+ │ └── post-template.html # → /blog/post-template
23
+
24
+ ├── docs/
25
+ │ ├── index.html # → /docs/
26
+ │ ├── getting-started.html # → /docs/getting-started
27
+ │ └── cli-reference.html # → /docs/cli-reference
28
+
29
+ ├── components/ # ← NOT a route, only stores components
30
+ │ ├── layout/
31
+ │ │ ├── site-header.com.html
32
+ │ │ ├── site-footer.com.html
33
+ │ │ └── page-sidebar.com.html
34
+ │ ├── ui/
35
+ │ │ ├── info-card.com.html
36
+ │ │ ├── user-badge.com.ts
37
+ │ │ └── alert-box.com.ts
38
+ │ └── content/
39
+ │ ├── hero-text.com.md
40
+ │ └── about-section.com.md
41
+
42
+ ├── styles/
43
+ │ ├── main.css # Global styles
44
+ │ └── components.css # Component styles
45
+
46
+ └── utils/
47
+ ├── format.ts # Helpers (imported by .com.ts or .pre.ts)
48
+ └── api-service.ts # API functions
49
+ ```
50
+
51
+ ### Principles
52
+
53
+ - **Root = sitemap**: scanning the root of `websrc/` reveals the URL structure of the site.
54
+ - **Components outside root**: ALWAYS in `components/` with subfolders by domain (`layout/`, `ui/`, `content/`).
55
+ - Related files for a page stay together (`page.html` + `page.ts` + `page.pre.ts` + `page.post.ts` in the same directory).
56
+ - Flat when there are few files, subfolders when it grows.
57
+ - Local override components live next to the page that uses them (resolution priority — see `tkeron-components`).
58
+
59
+ ### Why NOT a `pages/` subdirectory
60
+
61
+ Putting pages inside `pages/` breaks the root = sitemap principle. The routes `/about` and `/contact` must appear as `about.html` and `contact.html` directly at root, not hidden inside `pages/about/about.html`. The root **is** the sitemap.
62
+
63
+ ---
64
+
65
+ ## When to Componentize (and When Not)
66
+
67
+ Tkeron gives a lot of freedom: you can have no components or turn everything into a component. That freedom requires discipline.
68
+
69
+ ### Golden rule
70
+
71
+ > A component justifies its existence if it **eliminates real duplication** (2+ uses) or **encapsulates logic** (`.com.ts` with attributes). If it does neither, it is gratuitous indirection.
72
+
73
+ ### ✅ Create a component WHEN
74
+
75
+ | Situation | Recommended type |
76
+ | ---------------------------------------------------- | ----------------------- |
77
+ | Markup shared between 2+ pages (header, footer, nav) | `.com.html` |
78
+ | Dynamic block whose attributes vary per instance | `.com.ts` |
79
+ | Markdown content referenced from several pages | `.com.md` |
80
+ | Template + complex logic worth isolating | `.com.html` + `.com.ts` |
81
+
82
+ ### ❌ Do NOT create a component WHEN
83
+
84
+ | Situation | Why not |
85
+ | -------------------------------------------------- | ------------------------------------------------------- |
86
+ | Used only once, no logic | Indirection with no benefit — reading inline is clearer |
87
+ | HTML is trivial (2–5 lines) | Not worth a file for `<div class="divider"></div>` |
88
+ | "For visual organization" because the page is long | Use sections + comments + indentation inside the HTML |
89
+ | "Might be reused someday" | YAGNI — extract when actually needed, not before |
90
+
91
+ ### The freedom problem — both extremes
92
+
93
+ ```
94
+ ❌ Bad: bloated HTML, no components
95
+ websrc/
96
+ ├── index.html ← 400 lines, header/footer/cards duplicated
97
+ ├── about.html ← 300 lines, same header/footer/cards copy-paste
98
+ └── contact.html ← 200 lines, same header/footer copy-paste
99
+
100
+ ✅ Fix: extract what is shared
101
+ websrc/
102
+ ├── index.html ← <site-header>, <info-card>, <site-footer>
103
+ ├── about.html ← <site-header>, <info-card>, <site-footer>
104
+ ├── contact.html ← <site-header>, <site-footer>
105
+ └── components/
106
+ └── layout/
107
+ ├── site-header.com.html
108
+ ├── site-footer.com.html
109
+ └── info-card.com.html
110
+ ```
111
+
112
+ ```
113
+ ❌ Bad: over-componentization
114
+ websrc/
115
+ ├── index.html ← only 8 custom elements, empty HTML
116
+ ├── hero-section.com.html ← used 1 time
117
+ ├── intro-text.com.html ← used 1 time
118
+ ├── feature-list.com.html ← used 1 time
119
+ ├── cta-block.com.html ← used 1 time
120
+ └── ...
121
+ To understand index.html you must open 8 files.
122
+
123
+ ✅ Fix: leave inline what is used once
124
+ websrc/
125
+ ├── index.html ← full HTML, readable top to bottom
126
+ ├── components/
127
+ │ └── layout/
128
+ │ ├── site-header.com.html ← shared with about.html
129
+ │ └── site-footer.com.html ← shared with about.html
130
+ └── about.html
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Naming
136
+
137
+ ### Components — mandatory hyphen
138
+
139
+ Every component file MUST produce a tag with a hyphen (HTML custom-elements standard) and MUST NOT collide with a standard HTML tag.
140
+
141
+ ```
142
+ ✅ GOOD:
143
+ user-profile-card.com.html → <user-profile-card>
144
+ nav-menu-item.com.html → <nav-menu-item>
145
+ blog-post-card.com.ts → <blog-post-card>
146
+ social-share-button.com.ts → <social-share-button>
147
+ hero-section.com.md → <hero-section>
148
+
149
+ ❌ BAD:
150
+ card.com.html → No hyphen (invalid custom element)
151
+ header.com.html → Standard HTML tag (collision)
152
+ button.com.html → Standard HTML tag (collision)
153
+ UserProfile.com.html → Works but not idiomatic
154
+ component1.com.html → No meaning
155
+ btn.com.html → Too abbreviated
156
+ thing.com.html → No clear purpose
157
+ ```
158
+
159
+ **Format**: kebab-case, lowercase with hyphens.
160
+
161
+ ### Pages and general files
162
+
163
+ ```
164
+ ✅ GOOD:
165
+ index.html, about.html, blog-post.html
166
+ api-service.ts, format-utils.ts
167
+ main.css, components.css
168
+
169
+ ❌ BAD:
170
+ Index.html → Always lowercase
171
+ About Page.html → No spaces (tkeron does not handle them)
172
+ blog_post.html → Hyphens, not underscores
173
+ temp.html, test123.html → No meaning
174
+ ```
175
+
176
+ ### Assets — no spaces
177
+
178
+ Tkeron does not handle file names with spaces correctly — the build may fail silently or not copy the asset to the output. Applies to ALL files in `websrc/` (assets, components, scripts).
179
+
180
+ ```
181
+ ❌ BAD
182
+ websrc/assets/my logo.webp
183
+ websrc/assets/hero image.png
184
+
185
+ ✅ GOOD — hyphen or underscore
186
+ websrc/assets/my-logo.webp
187
+ websrc/assets/hero-image.png
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Where Each File Type Lives
193
+
194
+ | File | Location |
195
+ | ----------------------------- | -------------------------------------------------------------- |
196
+ | Pages (`*.html`) | Root of `websrc/` or sub-route directories — never in `pages/` |
197
+ | Per-page scripts (`*.ts`) | Same directory as the paired `.html` |
198
+ | Per-page `.pre.ts`/`.post.ts` | Same directory as the paired `.html` |
199
+ | Shared components | `websrc/components/<domain>/` (`layout/`, `ui/`, `content/`) |
200
+ | Local-override components | Same directory as the page that uses them (wins by priority) |
201
+ | Global styles | `websrc/styles/` |
202
+ | Build-time utils (Bun) | `websrc/utils/` — imported by `.pre.ts`, `.post.ts`, `.com.ts` |
203
+ | Static assets | `websrc/assets/` (or wherever — they are copied as-is) |
204
+ | Output | `web/` — **NEVER edit, always in `.gitignore`** |
205
+
206
+ ---
207
+
208
+ ## Excessive Nesting
209
+
210
+ Components can use other components (Tkeron processes up to 10 iterations), but deep chains are hard to debug.
211
+
212
+ ```
213
+ ❌ BAD (hard to debug):
214
+ page → layout → section → card → header → icon → svg (7 levels)
215
+
216
+ ✅ GOOD (2–3 levels max):
217
+ page.html → site-header.com.html → nav-logo.com.html
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Quick Checklist Before Committing Structure
223
+
224
+ 1. ✅ Every `.html` at root corresponds to an actual route
225
+ 2. ✅ Every component lives under `components/<domain>/`, never loose at root
226
+ 3. ✅ Every component name has a hyphen and is not a standard HTML tag
227
+ 4. ✅ No file names with spaces, capitals, or underscores (use kebab-case)
228
+ 5. ✅ Local overrides (same-directory components) are intentional, not accidental
229
+ 6. ✅ No component is extracted "just in case" — only with 2+ uses or logic
230
+ 7. ✅ Component chains are ≤ 3 levels deep when possible