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,79 @@
1
+ import { skills } from "./skills.js";
2
+ import type { Logger } from "@tkeron/tools";
3
+ import { logger as defaultLogger } from "@tkeron/tools";
4
+ import { createInterface } from "readline";
5
+
6
+ const stdinConfirm = async (message: string): Promise<boolean> => {
7
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
8
+ return new Promise<boolean>((resolve) => {
9
+ rl.question(message, (answer) => {
10
+ rl.close();
11
+ const trimmed = answer.trim().toLowerCase();
12
+ resolve(trimmed === "y" || trimmed === "yes");
13
+ });
14
+ });
15
+ };
16
+
17
+ export interface SkillsWrapperOptions {
18
+ target?: string;
19
+ force?: boolean;
20
+ dryRun?: boolean;
21
+ logger?: Logger;
22
+ confirm?: (message: string) => Promise<boolean>;
23
+ [key: string]: any;
24
+ }
25
+
26
+ export const skillsWrapper = async (options: SkillsWrapperOptions = {}) => {
27
+ const log = options?.logger || defaultLogger;
28
+ const confirm = options?.confirm ?? stdinConfirm;
29
+
30
+ try {
31
+ await skills({
32
+ target: options.target,
33
+ force: options.force,
34
+ dryRun: options.dryRun,
35
+ logger: log,
36
+ });
37
+ } catch (error: any) {
38
+ if (error.message === "NO_ENVIRONMENTS_DETECTED") {
39
+ if (options.dryRun) {
40
+ log.log(
41
+ "\n⚠ No known AI environment detected (.cursor/, .github/, .claude/).",
42
+ );
43
+ log.log(" Would create a skills/ directory in the current directory.");
44
+ return;
45
+ }
46
+ log.log(
47
+ "\n⚠ No known AI environment detected (.cursor/, .github/, .claude/).",
48
+ );
49
+ log.log(
50
+ " A skills/ directory will be created in the current directory instead.",
51
+ );
52
+
53
+ const proceed = await confirm(" Continue? (y/N): ");
54
+ if (!proceed) {
55
+ log.log("Aborted.");
56
+ return;
57
+ }
58
+
59
+ try {
60
+ await skills({ target: "skills", force: options.force, logger: log });
61
+ } catch (err: any) {
62
+ log.error(`\n❌ ${err.message}\n`);
63
+ if (/already exist/i.test(err.message)) {
64
+ log.error(
65
+ "💡 Tip: pass --force to overwrite existing skill files.\n",
66
+ );
67
+ }
68
+ process.exit(1);
69
+ }
70
+ return;
71
+ }
72
+
73
+ log.error(`\n❌ ${error.message}\n`);
74
+ if (/already exist/i.test(error.message)) {
75
+ log.error("💡 Tip: pass --force to overwrite existing skill files.\n");
76
+ }
77
+ process.exit(1);
78
+ }
79
+ };
@@ -1,240 +0,0 @@
1
- # MCP Server
2
-
3
- Tkeron includes a Model Context Protocol (MCP) server that exposes comprehensive documentation to AI agents and development tools.
4
-
5
- ## What is MCP?
6
-
7
- The Model Context Protocol is a standard for providing context to AI agents. Tkeron's MCP server allows AI assistants to access up-to-date documentation about how to use Tkeron, its capabilities, and limitations.
8
-
9
- ## Installation
10
-
11
- The MCP server is included when you install Tkeron globally:
12
-
13
- ```bash
14
- bun install -g tkeron
15
- ```
16
-
17
- This installs three commands:
18
-
19
- - `tk` / `tkeron` - The main CLI tool
20
- - `tkeron-mcp` - The MCP server
21
-
22
- ## Configuration
23
-
24
- ### VS Code
25
-
26
- Add to your MCP configuration file (`~/.config/Code/User/mcp.json`):
27
-
28
- ```json
29
- {
30
- "servers": {
31
- "tkeron": {
32
- "command": "tkeron-mcp"
33
- }
34
- }
35
- }
36
- ```
37
-
38
- If the global command is not found, use Bun directly:
39
-
40
- ```json
41
- {
42
- "servers": {
43
- "tkeron": {
44
- "command": "bun",
45
- "args": ["run", "/absolute/path/to/tkeron/mcp-server.ts"]
46
- }
47
- }
48
- }
49
- ```
50
-
51
- **Note:** This is the VS Code format. Other editors (Cursor, Windsurf, etc.) may use different configuration formats.
52
-
53
- ````
54
-
55
- **Find the path:**
56
- ```bash
57
- # If tkeron is installed globally
58
- dirname $(which tk)
59
- # Returns something like: /home/user/.bun/bin
60
-
61
- # The mcp-server.ts is in the same directory
62
- ls $(dirname $(which tk))/mcp-server.ts
63
- ````
64
-
65
- ### Claude Desktop
66
-
67
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or equivalent on other platforms:
68
-
69
- ```json
70
- {
71
- "mcpServers": {
72
- "tkeron": {
73
- "command": "tkeron-mcp"
74
- }
75
- }
76
- }
77
- ```
78
-
79
- ### Other MCP Clients
80
-
81
- Any MCP-compatible client can use the server. Configure it to run:
82
-
83
- ```bash
84
- tkeron-mcp
85
- ```
86
-
87
- The server communicates via stdio transport.
88
-
89
- ## Available Resources
90
-
91
- The MCP server exposes the following documentation resources:
92
-
93
- | URI | Description |
94
- | -------------------------------- | ---------------------------------------------------- |
95
- | `tkeron://overview` | What Tkeron is, what it does, and what it's not |
96
- | `tkeron://getting-started` | Installation, first project, and basic workflow |
97
- | `tkeron://components-html` | Create reusable HTML components with .com.html files |
98
- | `tkeron://components-typescript` | Build dynamic components with .com.ts files |
99
- | `tkeron://pre-rendering` | Transform HTML at build time with .pre.ts files |
100
- | `tkeron://cli-reference` | Complete command-line interface documentation |
101
- | `tkeron://best-practices` | Patterns, anti-patterns, and limitations |
102
- | `tkeron://common-issues` | Troubleshooting guide and common mistakes |
103
- | `tkeron://testing` | How to test tkeron projects with getBuildResult() |
104
-
105
- ## What AI Agents Can Do
106
-
107
- With access to the MCP server, AI agents can:
108
-
109
- - ✅ Understand Tkeron's capabilities and limitations
110
- - ✅ Help users create components correctly
111
- - ✅ Suggest appropriate patterns for different use cases
112
- - ✅ Identify when Tkeron is NOT the right tool
113
- - ✅ Provide accurate CLI commands and options
114
- - ✅ Debug common issues with components and pre-rendering
115
- - ✅ Recommend best practices and avoid anti-patterns
116
- - ✅ **Prevent common mistakes** (script references, component naming, dependencies)
117
- - ✅ **List and explore example projects**
118
- - ✅ **Retrieve example code and structures**
119
- - ✅ **Initialize, build, and develop projects via terminal** (`tk init`, `tk build`, `tk dev`)
120
-
121
- ## Available Tools
122
-
123
- The MCP server provides the following tools for AI agents:
124
-
125
- ### Example Management Tools
126
-
127
- - **`list_examples`**: List all available Tkeron example projects
128
- - No parameters required
129
- - Returns example names, descriptions, and paths
130
- - Helps users discover what's possible with Tkeron
131
-
132
- - **`get_example`**: Get the complete source code of an example
133
- - Parameters: `example` (name of the example project)
134
- - Returns file structure and all source code
135
- - Useful for learning patterns and bootstrapping projects
136
-
137
- > **Note:** The MCP server only provides documentation and examples. It does NOT modify files. The AI agent should use terminal commands (`tk init`, `tk build`, `tk dev`) to manage projects.
138
-
139
- ## Benefits
140
-
141
- ### For Users
142
-
143
- - Get accurate help from AI assistants
144
- - AI understands your project structure
145
- - Contextual suggestions based on Tkeron's docs
146
- - Fewer mistakes and faster development
147
-
148
- ### For AI Agents
149
-
150
- - Access to authoritative, up-to-date documentation
151
- - Clear understanding of limitations and constraints
152
- - Examples and patterns to reference
153
- - Ability to distinguish between what Tkeron can and can't do
154
-
155
- ## Verification
156
-
157
- To verify the MCP server is working:
158
-
159
- 1. Install Tkeron globally
160
- 2. Configure your MCP client
161
- 3. Restart your IDE/editor
162
- 4. Ask your AI assistant: "What is Tkeron?"
163
-
164
- The assistant should be able to provide an accurate description based on the documentation.
165
-
166
- ## Troubleshooting
167
-
168
- ### "Command not found: tkeron-mcp"
169
-
170
- Make sure Tkeron is installed globally:
171
-
172
- ```bash
173
- bun install -g tkeron
174
- which tkeron-mcp
175
- ```
176
-
177
- ### "Cannot find module"
178
-
179
- Ensure all dependencies are installed:
180
-
181
- ```bash
182
- cd $(dirname $(which tkeron-mcp))
183
- bun install
184
- ```
185
-
186
- ### MCP Client Not Connecting
187
-
188
- Check your configuration file syntax:
189
-
190
- - Valid JSON
191
- - Correct command path
192
- - Proper permissions on the executable
193
-
194
- ### Resources Not Loading
195
-
196
- Verify the docs directory exists:
197
-
198
- ```bash
199
- ls $(dirname $(which tkeron-mcp))/docs/
200
- ```
201
-
202
- All markdown files should be present.
203
-
204
- ## For Developers
205
-
206
- ### Adding New Resources
207
-
208
- To add new documentation resources:
209
-
210
- 1. Create a new `.md` file in `docs/`
211
- 2. Add an entry to the `DOCS` array in `mcp-server.ts`:
212
-
213
- ```typescript
214
- {
215
- uri: "tkeron://new-topic",
216
- name: "New Topic",
217
- description: "Description of the topic",
218
- file: "new-topic.md",
219
- }
220
- ```
221
-
222
- 3. Rebuild and publish the package
223
-
224
- ### Testing Locally
225
-
226
- Run the MCP server directly:
227
-
228
- ```bash
229
- bun run mcp-server.ts
230
- ```
231
-
232
- It will wait for stdio input (this is normal for MCP servers).
233
-
234
- Test with an MCP client or use the MCP inspector tool.
235
-
236
- ## Related Documentation
237
-
238
- - [Overview](./overview.md) - Learn what Tkeron is
239
- - [Getting Started](./getting-started.md) - Start using Tkeron
240
- - [Best Practices](./best-practices.md) - Patterns and anti-patterns
@@ -1,98 +0,0 @@
1
- // External API service - can be imported in .pre.ts files
2
- // Demonstrates that pre-rendering can use any TypeScript module
3
-
4
- export interface Quote {
5
- id: number;
6
- quote: string;
7
- author: string;
8
- }
9
-
10
- /**
11
- * Fetches a random quote from a public API
12
- * This runs at build time during pre-rendering
13
- */
14
- export async function getRandomQuote(): Promise<Quote> {
15
- try {
16
- const response = await fetch('https://dummyjson.com/quotes/random');
17
-
18
- if (!response.ok) {
19
- throw new Error(`HTTP error! status: ${response.status}`);
20
- }
21
-
22
- const data = await response.json();
23
- return data as Quote;
24
- } catch (error) {
25
- // Fallback quote if API fails
26
- console.warn('API call failed, using fallback quote');
27
- return {
28
- id: 0,
29
- quote: "The only way to do great work is to love what you do.",
30
- author: "Steve Jobs"
31
- };
32
- }
33
- }
34
-
35
- /**
36
- * Gets build metadata
37
- */
38
- export async function getBuildMetadata() {
39
- return {
40
- timestamp: new Date().toLocaleString(),
41
- runtime: `Bun ${Bun.version}`,
42
- tkeron: process.env.TKERON_VERSION || 'unknown',
43
- platform: process.platform
44
- };
45
- }
46
-
47
- export interface CryptoPrice {
48
- id: string;
49
- symbol: string;
50
- name: string;
51
- current_price: number;
52
- price_change_percentage_24h: number;
53
- }
54
-
55
- /**
56
- * Fetches cryptocurrency prices from CoinGecko API
57
- * This runs at build time during pre-rendering
58
- */
59
- export async function getCryptoPrices(): Promise<CryptoPrice[]> {
60
- try {
61
- const response = await fetch(
62
- 'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,solana&order=market_cap_desc&sparkline=false'
63
- );
64
-
65
- if (!response.ok) {
66
- throw new Error(`HTTP error! status: ${response.status}`);
67
- }
68
-
69
- const data = await response.json();
70
- return data as CryptoPrice[];
71
- } catch (error) {
72
- // Fallback data if API fails
73
- console.warn('Crypto API call failed, using fallback data');
74
- return [
75
- {
76
- id: 'bitcoin',
77
- symbol: 'btc',
78
- name: 'Bitcoin',
79
- current_price: 95000,
80
- price_change_percentage_24h: 2.5
81
- },
82
- {
83
- id: 'ethereum',
84
- symbol: 'eth',
85
- name: 'Ethereum',
86
- current_price: 3500,
87
- price_change_percentage_24h: -1.2
88
- },
89
- {
90
- id: 'solana',
91
- symbol: 'sol',
92
- name: 'Solana',
93
- current_price: 180,
94
- price_change_percentage_24h: 5.8
95
- }
96
- ];
97
- }
98
- }
@@ -1,9 +0,0 @@
1
- <section>
2
- <h2>🎯 Client-side TypeScript</h2>
3
- <p style="margin-bottom: 0.75rem;">Interactive features in the browser:</p>
4
- <div class="counter">
5
- <button id="increment">Click me!</button>
6
- <div class="count">Clicks: <span id="count">0</span></div>
7
- </div>
8
- <p style="font-size: 0.85rem; color: #666; margin-top: 0.75rem;">✓ Event handling & DOM manipulation<br>✓ Regular TypeScript for interactivity</p>
9
- </section>
@@ -1,23 +0,0 @@
1
- <div class="hero">
2
- <div>
3
- <img src="./profile.png" alt="tkeron logo" class="logo">
4
- <h1>tkeron</h1>
5
- <p class="subtitle">Build-time TypeScript for modern web development</p>
6
- </div>
7
- <div class="features">
8
- <ul style="list-style: none;">
9
- <li>⚡ Fast builds with Bun</li>
10
- <li>🎯 Build-time HTML generation</li>
11
- <li>🧩 HTML & TypeScript components</li>
12
- <li>🔧 Pure TypeScript & HTML</li>
13
- </ul>
14
- </div>
15
- <div style="margin-top: 1.5rem; display: flex; gap: 0.75rem; width: 100%;">
16
- <a href="https://www.npmjs.com/package/tkeron" target="_blank" style="flex: 1; padding: 0.65rem; background: rgba(203, 56, 55, 0.9); color: white; text-decoration: none; border-radius: 6px; text-align: center; font-weight: 600; font-size: 0.85rem; transition: background 0.2s;">
17
- 📦 npm
18
- </a>
19
- <a href="https://github.com/tkeron/tkeron" target="_blank" style="flex: 1; padding: 0.65rem; background: rgba(36, 41, 46, 0.9); color: white; text-decoration: none; border-radius: 6px; text-align: center; font-weight: 600; font-size: 0.85rem; transition: background 0.2s;">
20
- ⭐ GitHub
21
- </a>
22
- </div>
23
- </div>
@@ -1,6 +0,0 @@
1
- <section>
2
- <h2>🧩 HTML Components</h2>
3
- <p style="margin-bottom: 0.75rem;">Reusable components with <code>.com.html</code>:</p>
4
- <info-card></info-card>
5
- <p style="font-size: 0.85rem; color: #666; margin-top: 0.75rem;">✓ Nested components support<br>✓ Build-time replacement</p>
6
- </section>
@@ -1,6 +0,0 @@
1
- <section>
2
- <h2>⚡ TypeScript Components</h2>
3
- <p style="margin-bottom: 0.75rem;">Dynamic generation with <code>.com.ts</code>:</p>
4
- <user-badge count="3"></user-badge>
5
- <p style="font-size: 0.85rem; color: #666; margin-top: 0.75rem;">✓ Loops & conditionals<br>✓ Read attributes dynamically<br>✓ Build-time code execution</p>
6
- </section>
@@ -1,17 +0,0 @@
1
- // TypeScript component - runs at build time with logic
2
- const count = com.getAttribute("count") || "3";
3
- const numCount = parseInt(count, 10);
4
-
5
- // Generate list dynamically
6
- const items = [];
7
- for (let i = 1; i <= numCount; i++) {
8
- items.push(`<li>✓ Item ${i}</li>`);
9
- }
10
-
11
- com.innerHTML = `
12
- <div style="background: #f0fdf4; border-left: 3px solid #22c55e; padding: 0.75rem; border-radius: 4px;">
13
- <ul style="list-style: none; padding: 0; margin: 0; font-size: 0.9rem; color: #166534;">
14
- ${items.join("")}
15
- </ul>
16
- </div>
17
- `;