tkeron 5.3.0 → 6.0.1

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 (59) hide show
  1. package/README.md +17 -16
  2. package/bun.lock +13 -196
  3. package/changelog.md +55 -0
  4. package/examples/init_sample/websrc/about.html +19 -0
  5. package/examples/init_sample/websrc/components/content/about-intro.com.md +7 -0
  6. package/examples/init_sample/websrc/components/layout/hero-section.com.html +88 -0
  7. package/examples/init_sample/websrc/components/layout/site-footer.com.html +20 -0
  8. package/examples/init_sample/websrc/components/layout/site-header.com.html +44 -0
  9. package/examples/init_sample/websrc/components/ui/counter-button.com.html +48 -0
  10. package/examples/init_sample/websrc/components/ui/crypto-prices-card.com.html +52 -0
  11. package/examples/init_sample/websrc/components/ui/html-components-card.com.html +10 -0
  12. package/examples/init_sample/websrc/{info-card.com.html → components/ui/info-card.com.html} +10 -6
  13. package/examples/init_sample/websrc/components/ui/markdown-card.com.html +21 -0
  14. package/examples/init_sample/websrc/{pre-render-card.com.html → components/ui/pre-render-card.com.html} +6 -3
  15. package/examples/init_sample/websrc/components/ui/quote-card.com.html +32 -0
  16. package/examples/init_sample/websrc/components/ui/styles-injector.com.ts +5 -0
  17. package/examples/init_sample/websrc/components/ui/ts-components-card.com.html +11 -0
  18. package/examples/init_sample/websrc/components/ui/user-badge.com.ts +30 -0
  19. package/examples/init_sample/websrc/docs.html +33 -0
  20. package/examples/init_sample/websrc/index.html +10 -209
  21. package/examples/init_sample/websrc/index.post.ts +70 -0
  22. package/examples/init_sample/websrc/index.pre.ts +10 -61
  23. package/examples/init_sample/websrc/index.ts +9 -7
  24. package/examples/init_sample/websrc/styles/global-styles.com.ts +5 -0
  25. package/examples/init_sample/websrc/styles/main.css +112 -0
  26. package/examples/init_sample/websrc/utils/api-service.ts +93 -0
  27. package/examples/with_global_styles/websrc/bad.html +23 -0
  28. package/examples/with_global_styles/websrc/global-styles.com.ts +5 -0
  29. package/examples/with_global_styles/websrc/good.html +22 -0
  30. package/examples/with_global_styles/websrc/index.html +25 -0
  31. package/examples/with_global_styles/websrc/styles.css +24 -0
  32. package/examples/with_style_dedup/websrc/tag-chip.com.html +15 -0
  33. package/examples/with_style_dedup/websrc/tag-chip.com.ts +2 -18
  34. package/index.ts +15 -0
  35. package/package.json +9 -13
  36. package/skills/tkeron/SKILL.md +287 -0
  37. package/skills/tkeron-components/SKILL.md +785 -0
  38. package/skills/tkeron-organization/SKILL.md +231 -0
  39. package/skills/tkeron-patterns/SKILL.md +587 -0
  40. package/skills/tkeron-testing/SKILL.md +194 -0
  41. package/skills/tkeron-troubleshooting/SKILL.md +263 -0
  42. package/src/build.ts +4 -6
  43. package/src/develop.ts +1 -2
  44. package/src/init.ts +1 -2
  45. package/src/skills.ts +139 -0
  46. package/src/skillsWrapper.ts +79 -0
  47. package/docs/mcp-server.md +0 -240
  48. package/examples/init_sample/websrc/api-service.ts +0 -98
  49. package/examples/init_sample/websrc/counter-card.com.html +0 -9
  50. package/examples/init_sample/websrc/favicon.ico +0 -0
  51. package/examples/init_sample/websrc/hero-section.com.html +0 -23
  52. package/examples/init_sample/websrc/html-components-card.com.html +0 -6
  53. package/examples/init_sample/websrc/ts-components-card.com.html +0 -6
  54. package/examples/init_sample/websrc/user-badge.com.ts +0 -17
  55. package/mcp-server.ts +0 -272
  56. package/src/cleanupOrphanedTempDirs.ts +0 -31
  57. package/src/promptUser.ts +0 -15
  58. package/src/setupSigintHandler.ts +0 -6
  59. /package/examples/init_sample/websrc/{profile.png → assets/profile.png} +0 -0
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: tkeron
3
+ description: "Tkeron core overview: what it is, full CLI reference (build, dev, init, skills), file-type summary, build lifecycle, IDE support files, environment variables, build-time vs runtime. Load this skill first when starting any tkeron task — it is the entry point that points to the other tkeron-* skills."
4
+ ---
5
+
6
+ # Tkeron — Core
7
+
8
+ ## What It Is
9
+
10
+ CLI build tool for vanilla web development. Compiles TypeScript, processes HTML/TS/Markdown components, runs pre-/post-rendering scripts, generates static files ready to deploy. Powered by **Bun**. Zero frameworks. Zero runtime. Zero external bundlers.
11
+
12
+ ## The tkeron skill set
13
+
14
+ | Skill | When to load it |
15
+ | ------------------------ | -------------------------------------------------------------------------- |
16
+ | `tkeron` (this one) | Always first. CLI, lifecycle, file-type overview. |
17
+ | `tkeron-components` | Creating/editing `.com.html`, `.com.ts`, `.com.md`, `.pre.ts`, `.post.ts`. |
18
+ | `tkeron-organization` | Designing project structure, deciding when to componentize, naming. |
19
+ | `tkeron-patterns` | Implementing features — best patterns, anti-patterns, max-pre-render rule. |
20
+ | `tkeron-testing` | Writing tests with `getBuildResult` from `tkeron`. |
21
+ | `tkeron-troubleshooting` | Build fails, dev server crashes, component is not replaced, common errors. |
22
+
23
+ ---
24
+
25
+ ## Input and Output
26
+
27
+ ```
28
+ project/
29
+ ├── tkeron.d.ts # IDE types (com, document globals)
30
+ ├── tsconfig.json # TS config for IDE
31
+ ├── websrc/ # ← INPUT (all source files live here)
32
+ │ ├── index.html # Pages (root = sitemap)
33
+ │ ├── index.ts # Browser TypeScript (compiled to .js)
34
+ │ ├── index.pre.ts # Pre-rendering (build time, before components)
35
+ │ ├── index.post.ts # Post-processing (build time, after components)
36
+ │ ├── about.html # More pages at root = more routes
37
+ │ ├── docs/ # Subdirectories = sub-routes
38
+ │ │ └── *.html
39
+ │ ├── components/ # Components (NOT routes) — see tkeron-organization
40
+ │ ├── styles/ # CSS, assets
41
+ │ └── utils/ # Helpers imported by .com.ts or .pre.ts
42
+ └── web/ # ← OUTPUT (generated by tk build)
43
+ ├── index.html # Processed HTML (components inlined)
44
+ ├── index.js # TS compiled
45
+ └── styles/ # CSS copied
46
+ ```
47
+
48
+ **Fixed directories**: `websrc/` is input, `web/` is output. No configuration. Convention over configuration.
49
+
50
+ > **IMPORTANT**: `web/` is generated by `tk build` and `tk dev`. It MUST be in `.gitignore`. **Never edit or commit its contents** — any manual change is overwritten on the next build.
51
+
52
+ **Files NOT copied to output**: `*.com.html`, `*.com.ts`, `*.com.md`, `*.pre.ts`, `*.post.ts`.
53
+
54
+ ---
55
+
56
+ ## CLI Reference
57
+
58
+ ```bash
59
+ tk # Banner + version
60
+ tk init <name> # New project in <name>/
61
+ tk init . # Initialize in current directory
62
+ tk init <name> --force # Overwrite existing
63
+ tk build # Compile websrc/ → web/
64
+ tk b # Alias for build
65
+ tk dev # Dev server on localhost:3000 + hot reload
66
+ tk dev 8080 # Custom port
67
+ tk dev 8080 0.0.0.0 # Custom port + host
68
+ tk skills # Install AI agent skills (auto-detect env)
69
+ tk skills <dir> # Install into a custom directory
70
+ tk skills --force # Overwrite existing skill files
71
+ ```
72
+
73
+ | Command | Aliases | What it does |
74
+ | ------------ | ---------------- | ------------------------------------------- |
75
+ | `tk build` | `tk b` | Full build of `websrc/` → `web/` |
76
+ | `tk develop` | `tk dev`, `tk d` | Dev server + watch + hot reload (singleton) |
77
+ | `tk init` | `tk i` | Create project from template |
78
+ | `tk skills` | — | Install AI agent skills |
79
+
80
+ ### `tk dev` — important
81
+
82
+ - Defaults: port `3000`, host `localhost`. Positional args: `tk dev <port> <host>`.
83
+ - **Singleton per port**: only one instance at a time. Check `fuser 3000/tcp 2>/dev/null` before launching.
84
+ - Watches `websrc/`, rebuilds on save, broadcasts via SSE on `/dev-reload`, injects the reload script before `</body>`.
85
+ - Clean URLs: `/about` serves `about.html`, `/blog/` serves `blog/index.html`.
86
+ - **In agent sessions**: ALWAYS run `tk dev` in background (it blocks indefinitely). NEVER run it synchronously.
87
+ - If it crashes after a `websrc/` edit → see `tkeron-troubleshooting`.
88
+
89
+ ### `tk build` — required after editing `websrc/`
90
+
91
+ > **RULE**: After any change in `websrc/`, run `tk build` and then read the relevant files in `web/` (`web/*.html`, `web/*.js`) to verify components were inlined and TS compiled as expected.
92
+
93
+ If output is wrong → fix in `websrc/` and rebuild. **NEVER edit `web/` directly.**
94
+
95
+ ### `tk init` — what it creates
96
+
97
+ ```
98
+ project/
99
+ ├── websrc/
100
+ │ ├── index.html # Sample home page
101
+ │ ├── index.ts # Sample browser TS
102
+ │ ├── index.pre.ts # Sample pre-render
103
+ │ ├── api-service.ts # Sample service
104
+ │ ├── *.com.html # Sample HTML components
105
+ │ └── user-badge.com.ts # Sample TS component
106
+ ├── tkeron.d.ts # IDE types
107
+ └── tsconfig.json # TS config for IDE
108
+ ```
109
+
110
+ Behavior:
111
+
112
+ - In an empty/new directory: creates the full template.
113
+ - In a directory with an existing `websrc/` or `tkeron.d.ts`: prompts before overwriting (use `--force` to skip the prompt).
114
+ - Always preserves any pre-existing fields in your `tsconfig.json` and merges the tkeron defaults.
115
+
116
+ ### `tk skills` — environment auto-detection
117
+
118
+ `tk skills` (no argument) detects the AI environment from the current directory and installs into the matching folder:
119
+
120
+ | Detected marker | Environment | Install target | Special transform |
121
+ | ------------------------- | ----------- | ----------------- | ---------------------------------------- |
122
+ | `.cursor/` | cursor | `.cursor/rules/` | adds `alwaysApply: false` to frontmatter |
123
+ | `.github/` | copilot | `.github/skills/` | none |
124
+ | `.claude/` or `CLAUDE.md` | claude | `.claude/rules/` | none |
125
+
126
+ - Multiple environments detected → installs into all of them.
127
+ - None detected → prompts to create `./skills/`.
128
+ - Explicit target (`tk skills my-skills-dir`) → installs there, no env detection, no transform.
129
+ - Conflicts (skill file already exists) → fails with a clear message; use `--force` to overwrite.
130
+
131
+ ---
132
+
133
+ ## Build Lifecycle — Exact Order
134
+
135
+ ```
136
+ websrc/ ─────────────────────────────────────────────────→ web/
137
+
138
+ [1] .pre.ts Run pre-render scripts (Bun runtime)
139
+ Each .pre.ts modifies its paired .html
140
+ — runs BEFORE components, can inject custom elements
141
+
142
+ [2] Iterative loop (max 10 iterations, until no more changes):
143
+ ├─ .com.ts Execute TypeScript components
144
+ ├─ .com.html Inline HTML components
145
+ └─ .com.md Render Markdown components
146
+
147
+ [3] .post.ts Run post-render scripts (Bun runtime)
148
+ Each .post.ts mutates its paired .html with the
149
+ components ALREADY resolved — final DOM walk
150
+
151
+ [4] .ts → .js Compile TypeScript (Bun.build)
152
+
153
+ [5] Asset copy Copy everything else to the output
154
+ ```
155
+
156
+ **Key order**: `.pre.ts` runs FIRST (can inject custom elements that the component loop then processes). `.post.ts` runs LAST (sees the fully-resolved DOM — perfect for `loading="lazy"`, `rel="noopener"`, TOCs, heading `id`s).
157
+
158
+ Limits: max **10 iterations**, max **50 nesting levels**, no circular dependencies.
159
+
160
+ ---
161
+
162
+ ## File Types — Summary
163
+
164
+ | Extension | When it runs | Runtime | Special variable | Copied to web/ |
165
+ | ----------- | ------------------------ | ---------- | -------------------- | -------------- |
166
+ | `.html` | — | — | — | ✅ (processed) |
167
+ | `.ts` | Browser | V8/Browser | `window`, `document` | ✅ (→ .js) |
168
+ | `.com.html` | Build time | — | — | ❌ |
169
+ | `.com.ts` | Build time | Bun | `com` | ❌ |
170
+ | `.com.md` | Build time | — | — | ❌ |
171
+ | `.pre.ts` | Build time (BEFORE coms) | Bun | `document` | ❌ |
172
+ | `.post.ts` | Build time (AFTER coms) | Bun | `document` | ❌ |
173
+
174
+ > Full reference (the `com` API, attribute reading, nesting, examples) lives in `tkeron-components`.
175
+
176
+ ### `.html` — Page essentials
177
+
178
+ ```html
179
+ <!DOCTYPE html>
180
+ <html lang="en">
181
+ <head>
182
+ <meta charset="UTF-8" />
183
+ <title>My Site</title>
184
+ <global-styles></global-styles>
185
+ </head>
186
+ <body>
187
+ <site-header></site-header>
188
+ <main>Content</main>
189
+ <script type="module" src="./index.ts"></script>
190
+ </body>
191
+ </html>
192
+ ```
193
+
194
+ **Three non-negotiable rules**:
195
+
196
+ 1. **`src="index.ts"` with `type="module"`**, NEVER `.js`. Tkeron compiles and rewrites the reference.
197
+ 2. **Relative paths only** (`./`, `../`). NEVER absolute (`/file.ext`) — Bun cannot resolve them at build time. Applies to `.html`, `.com.html`, and `url()` in CSS.
198
+ 3. **CSS via components, never `<link rel="stylesheet">`**. A `<global-styles>` component reads the `.css` file at build time and inlines it as `<style>` — no extra request, dedup-friendly. See `tkeron-patterns` → "CSS via components".
199
+
200
+ ---
201
+
202
+ ## IDE — Support Files
203
+
204
+ Generated by `tk init`. For the IDE only, do not affect the build.
205
+
206
+ ### `tkeron.d.ts`
207
+
208
+ ```typescript
209
+ declare module "*.com.ts" {
210
+ global {
211
+ const com: HTMLElement;
212
+ }
213
+ }
214
+
215
+ declare module "*.pre.ts" {
216
+ global {
217
+ const document: Document;
218
+ }
219
+ }
220
+
221
+ declare module "*.post.ts" {
222
+ global {
223
+ const document: Document;
224
+ }
225
+ }
226
+ ```
227
+
228
+ ### `tsconfig.json`
229
+
230
+ ```json
231
+ {
232
+ "compilerOptions": {
233
+ "target": "ESNext",
234
+ "module": "ESNext",
235
+ "lib": ["ESNext", "DOM"],
236
+ "moduleResolution": "bundler",
237
+ "strict": true,
238
+ "skipLibCheck": true
239
+ },
240
+ "include": ["websrc/**/*", "tkeron.d.ts"]
241
+ }
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Environment Variables
247
+
248
+ ```typescript
249
+ // In .pre.ts, .post.ts or .com.ts (build time)
250
+ process.env.TKERON_VERSION; // tkeron version (injected automatically)
251
+ process.env.NODE_ENV; // development / production
252
+ process.env.MY_VAR; // any custom variable
253
+ ```
254
+
255
+ ```bash
256
+ NODE_ENV=production MY_VAR=value tk build
257
+ ```
258
+
259
+ Browser `.ts` files do **not** see `process.env` — `process` does not exist in the browser. To pass build-time values to the runtime, write them into the DOM from a `.pre.ts` (e.g. `<meta name="config" content="...">`) and read them from `.ts`.
260
+
261
+ ---
262
+
263
+ ## Type Checking
264
+
265
+ Tkeron does NOT type-check, it only compiles. To check types:
266
+
267
+ ```bash
268
+ bun x tsc --noEmit && tk build
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Build Time vs Runtime — Quick Reference
274
+
275
+ | Aspect | Build (`.pre.ts`, `.com.ts`, `.post.ts`) | Runtime (`.ts` → `.js`) |
276
+ | -------------- | ---------------------------------------- | ----------------------- |
277
+ | When it runs | `tk build` | User's browser |
278
+ | Runtime | Bun | V8/Browser |
279
+ | `fetch()` | ✅ | ✅ |
280
+ | `window` | ❌ | ✅ |
281
+ | `localStorage` | ❌ | ✅ |
282
+ | DOM events | ❌ (lost in output) | ✅ |
283
+ | npm packages | ✅ | ❌ (not bundled) |
284
+ | Bun APIs | ✅ | ❌ |
285
+ | `process.env` | ✅ | ❌ |
286
+
287
+ For full do/don't rules and the **maximum pre-render** rule, load `tkeron-patterns`.