@claudetools/tools 0.8.10 → 0.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.
- package/dist/codedna/generators/astro.d.ts +18 -0
- package/dist/codedna/generators/astro.js +91 -0
- package/dist/codedna/generators/authjs.d.ts +18 -0
- package/dist/codedna/generators/authjs.js +68 -0
- package/dist/codedna/generators/better-auth.d.ts +18 -0
- package/dist/codedna/generators/better-auth.js +62 -0
- package/dist/codedna/generators/drizzle-orm.d.ts +18 -0
- package/dist/codedna/generators/drizzle-orm.js +65 -0
- package/dist/codedna/generators/elysia-api.d.ts +12 -0
- package/dist/codedna/generators/elysia-api.js +64 -0
- package/dist/codedna/generators/hono-api.d.ts +12 -0
- package/dist/codedna/generators/hono-api.js +64 -0
- package/dist/codedna/generators/lucia-auth.d.ts +18 -0
- package/dist/codedna/generators/lucia-auth.js +69 -0
- package/dist/codedna/generators/prisma.d.ts +18 -0
- package/dist/codedna/generators/prisma.js +64 -0
- package/dist/codedna/generators/react-router-v7.d.ts +18 -0
- package/dist/codedna/generators/react-router-v7.js +77 -0
- package/dist/codedna/generators/react19-shadcn.d.ts +21 -0
- package/dist/codedna/generators/react19-shadcn.js +367 -0
- package/dist/codedna/generators/sveltekit.d.ts +18 -0
- package/dist/codedna/generators/sveltekit.js +73 -0
- package/dist/codedna/generators/tanstack-start-drizzle.d.ts +92 -0
- package/dist/codedna/generators/tanstack-start-drizzle.js +824 -0
- package/dist/codedna/generators/trpc-api.d.ts +12 -0
- package/dist/codedna/generators/trpc-api.js +64 -0
- package/dist/codedna/index.d.ts +31 -0
- package/dist/codedna/index.js +39 -0
- package/dist/codedna/kappa-api-generator.d.ts +89 -0
- package/dist/codedna/kappa-api-generator.js +493 -0
- package/dist/codedna/kappa-ast.d.ts +552 -0
- package/dist/codedna/kappa-ast.js +141 -0
- package/dist/codedna/kappa-cli.d.ts +2 -0
- package/dist/codedna/kappa-cli.js +302 -0
- package/dist/codedna/kappa-component-generator.d.ts +47 -0
- package/dist/codedna/kappa-component-generator.js +295 -0
- package/dist/codedna/kappa-design-generator.d.ts +52 -0
- package/dist/codedna/kappa-design-generator.js +365 -0
- package/dist/codedna/kappa-drizzle-generator.d.ts +45 -0
- package/dist/codedna/kappa-drizzle-generator.js +355 -0
- package/dist/codedna/kappa-form-generator.d.ts +51 -0
- package/dist/codedna/kappa-form-generator.js +319 -0
- package/dist/codedna/kappa-lexer.d.ts +268 -0
- package/dist/codedna/kappa-lexer.js +757 -0
- package/dist/codedna/kappa-page-generator.d.ts +57 -0
- package/dist/codedna/kappa-page-generator.js +338 -0
- package/dist/codedna/kappa-parser.d.ts +261 -0
- package/dist/codedna/kappa-parser.js +2547 -0
- package/dist/codedna/kappa-provenance.d.ts +101 -0
- package/dist/codedna/kappa-provenance.js +199 -0
- package/dist/codedna/kappa-types-generator.d.ts +37 -0
- package/dist/codedna/kappa-types-generator.js +159 -0
- package/dist/codedna/kappa-validator.d.ts +86 -0
- package/dist/codedna/kappa-validator.js +638 -0
- package/dist/codedna/kappa-zod-generator.d.ts +32 -0
- package/dist/codedna/kappa-zod-generator.js +216 -0
- package/dist/handlers/codedna-handlers.d.ts +1 -1
- package/dist/handlers/kappa-handlers.d.ts +116 -0
- package/dist/handlers/kappa-handlers.js +465 -0
- package/dist/handlers/tool-handlers.js +121 -0
- package/dist/templates/claude-md.d.ts +1 -1
- package/dist/templates/claude-md.js +166 -9
- package/dist/tools.js +199 -0
- package/docs/research/2026-01-02-codedna-il-specification.md +639 -0
- package/docs/research/2026-01-02-codedna-v2-research.md +943 -0
- package/docs/research/2026-01-02-computation-foundations.md +564 -0
- package/docs/research/2026-01-02-hardware-description.md +814 -0
- package/docs/research/2026-01-02-kappa-specification.md +697 -0
- package/docs/research/2026-01-02-kappa-tanstack-example.md +527 -0
- package/docs/research/2026-01-02-kappa-v2-synthesis.md +406 -0
- package/docs/research/2026-01-02-kappa-v2.5-specification.md +1218 -0
- package/docs/research/2026-01-02-kappa-v3-specification.md +1864 -0
- package/docs/research/2026-01-02-kappa-whitepaper.md +662 -0
- package/docs/research/2026-01-02-logic-constraint.md +731 -0
- package/docs/research/2026-01-02-quantum-computation.md +635 -0
- package/package.json +4 -2
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Kappa v2.5 Design Generator
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Generates CSS variables and Tailwind config from Kappa DesignBlock AST.
|
|
6
|
+
// Supports light/dark themes, typography, spacing, borders, shadows, and motion.
|
|
7
|
+
//
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Generator Class
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export class KappaDesignGenerator {
|
|
12
|
+
format;
|
|
13
|
+
provenance;
|
|
14
|
+
prefix;
|
|
15
|
+
hsl;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.format = options.format ?? 'both';
|
|
18
|
+
this.provenance = options.provenance ?? true;
|
|
19
|
+
this.prefix = options.prefix ?? '';
|
|
20
|
+
this.hsl = options.hsl ?? false;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate design files from DesignBlock AST
|
|
24
|
+
*/
|
|
25
|
+
generate(design) {
|
|
26
|
+
const result = {};
|
|
27
|
+
if (this.format === 'css' || this.format === 'both') {
|
|
28
|
+
result.css = this.generateCSS(design);
|
|
29
|
+
}
|
|
30
|
+
if (this.format === 'tailwind' || this.format === 'both') {
|
|
31
|
+
result.tailwind = this.generateTailwind(design);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
// ===========================================================================
|
|
36
|
+
// CSS Generation
|
|
37
|
+
// ===========================================================================
|
|
38
|
+
generateCSS(design) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
// Header
|
|
41
|
+
if (this.provenance) {
|
|
42
|
+
lines.push('/* Generated by Kappa v2.5 CodeDNA */');
|
|
43
|
+
lines.push('/* Design System Variables */');
|
|
44
|
+
lines.push('');
|
|
45
|
+
}
|
|
46
|
+
// Root variables (light mode)
|
|
47
|
+
lines.push(':root {');
|
|
48
|
+
lines.push(this.generateColorVariables(design.colors, 2));
|
|
49
|
+
if (design.typography) {
|
|
50
|
+
lines.push('');
|
|
51
|
+
lines.push(this.generateTypographyVariables(design.typography, 2));
|
|
52
|
+
}
|
|
53
|
+
if (design.spacing) {
|
|
54
|
+
lines.push('');
|
|
55
|
+
lines.push(this.generateSpacingVariables(design.spacing, 2));
|
|
56
|
+
}
|
|
57
|
+
if (design.borders) {
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push(this.generateBorderVariables(design.borders, 2));
|
|
60
|
+
}
|
|
61
|
+
if (design.shadows) {
|
|
62
|
+
lines.push('');
|
|
63
|
+
lines.push(this.generateShadowVariables(design.shadows, 2));
|
|
64
|
+
}
|
|
65
|
+
if (design.motion) {
|
|
66
|
+
lines.push('');
|
|
67
|
+
lines.push(this.generateMotionVariables(design.motion, 2));
|
|
68
|
+
}
|
|
69
|
+
lines.push('}');
|
|
70
|
+
// Dark mode
|
|
71
|
+
if (design.darkColors) {
|
|
72
|
+
lines.push('');
|
|
73
|
+
lines.push('@media (prefers-color-scheme: dark) {');
|
|
74
|
+
lines.push(' :root {');
|
|
75
|
+
lines.push(this.generateColorVariables(design.darkColors, 4));
|
|
76
|
+
lines.push(' }');
|
|
77
|
+
lines.push('}');
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push('.dark {');
|
|
80
|
+
lines.push(this.generateColorVariables(design.darkColors, 2));
|
|
81
|
+
lines.push('}');
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
path: 'styles/design-tokens.css',
|
|
85
|
+
content: lines.join('\n'),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
generateColorVariables(palette, indent) {
|
|
89
|
+
const spaces = ' '.repeat(indent);
|
|
90
|
+
const lines = [];
|
|
91
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
92
|
+
for (const [name, colorValue] of Object.entries(palette.colors)) {
|
|
93
|
+
const value = this.resolveColorValue(colorValue, palette);
|
|
94
|
+
const varName = `--${prefix}color-${this.toKebabCase(name)}`;
|
|
95
|
+
lines.push(`${spaces}${varName}: ${value};`);
|
|
96
|
+
}
|
|
97
|
+
return lines.join('\n');
|
|
98
|
+
}
|
|
99
|
+
resolveColorValue(colorValue, palette) {
|
|
100
|
+
if (!colorValue.isFunction) {
|
|
101
|
+
if (this.hsl) {
|
|
102
|
+
return this.hexToHsl(colorValue.value);
|
|
103
|
+
}
|
|
104
|
+
return colorValue.value;
|
|
105
|
+
}
|
|
106
|
+
// Handle color functions
|
|
107
|
+
const { functionName, functionArgs } = colorValue;
|
|
108
|
+
if (!functionName || !functionArgs) {
|
|
109
|
+
return colorValue.value;
|
|
110
|
+
}
|
|
111
|
+
// Resolve base color reference
|
|
112
|
+
const baseColorRef = functionArgs[0];
|
|
113
|
+
const baseColor = palette.colors[baseColorRef];
|
|
114
|
+
const amount = functionArgs[1];
|
|
115
|
+
if (!baseColor) {
|
|
116
|
+
return colorValue.value;
|
|
117
|
+
}
|
|
118
|
+
const baseHex = baseColor.value;
|
|
119
|
+
switch (functionName) {
|
|
120
|
+
case 'darken':
|
|
121
|
+
return this.adjustColor(baseHex, -amount);
|
|
122
|
+
case 'lighten':
|
|
123
|
+
return this.adjustColor(baseHex, amount);
|
|
124
|
+
case 'alpha':
|
|
125
|
+
return this.addAlpha(baseHex, amount);
|
|
126
|
+
default:
|
|
127
|
+
return colorValue.value;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
generateTypographyVariables(typography, indent) {
|
|
131
|
+
const spaces = ' '.repeat(indent);
|
|
132
|
+
const lines = [];
|
|
133
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
134
|
+
lines.push(`${spaces}/* Typography */`);
|
|
135
|
+
if (typography.fontFamily) {
|
|
136
|
+
lines.push(`${spaces}--${prefix}font-family: ${typography.fontFamily};`);
|
|
137
|
+
}
|
|
138
|
+
if (typography.fontMono) {
|
|
139
|
+
lines.push(`${spaces}--${prefix}font-mono: ${typography.fontMono};`);
|
|
140
|
+
}
|
|
141
|
+
if (typography.scale) {
|
|
142
|
+
for (const [name, size] of Object.entries(typography.scale)) {
|
|
143
|
+
lines.push(`${spaces}--${prefix}font-size-${this.toKebabCase(name)}: ${size};`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (typography.weight) {
|
|
147
|
+
for (const [name, weight] of Object.entries(typography.weight)) {
|
|
148
|
+
lines.push(`${spaces}--${prefix}font-weight-${this.toKebabCase(name)}: ${weight};`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return lines.join('\n');
|
|
152
|
+
}
|
|
153
|
+
generateSpacingVariables(spacing, indent) {
|
|
154
|
+
const spaces = ' '.repeat(indent);
|
|
155
|
+
const lines = [];
|
|
156
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
157
|
+
lines.push(`${spaces}/* Spacing */`);
|
|
158
|
+
if (spacing.unit) {
|
|
159
|
+
lines.push(`${spaces}--${prefix}spacing-unit: ${spacing.unit};`);
|
|
160
|
+
}
|
|
161
|
+
if (spacing.scale) {
|
|
162
|
+
for (let i = 0; i < spacing.scale.length; i++) {
|
|
163
|
+
const value = spacing.scale[i];
|
|
164
|
+
const unit = spacing.unit || 'rem';
|
|
165
|
+
lines.push(`${spaces}--${prefix}spacing-${i}: ${value}${unit};`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return lines.join('\n');
|
|
169
|
+
}
|
|
170
|
+
generateBorderVariables(borders, indent) {
|
|
171
|
+
const spaces = ' '.repeat(indent);
|
|
172
|
+
const lines = [];
|
|
173
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
174
|
+
lines.push(`${spaces}/* Borders */`);
|
|
175
|
+
if (borders.radius) {
|
|
176
|
+
for (const [name, value] of Object.entries(borders.radius)) {
|
|
177
|
+
lines.push(`${spaces}--${prefix}radius-${this.toKebabCase(name)}: ${value};`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return lines.join('\n');
|
|
181
|
+
}
|
|
182
|
+
generateShadowVariables(shadows, indent) {
|
|
183
|
+
const spaces = ' '.repeat(indent);
|
|
184
|
+
const lines = [];
|
|
185
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
186
|
+
lines.push(`${spaces}/* Shadows */`);
|
|
187
|
+
if (shadows.shadows) {
|
|
188
|
+
for (const [name, value] of Object.entries(shadows.shadows)) {
|
|
189
|
+
lines.push(`${spaces}--${prefix}shadow-${this.toKebabCase(name)}: ${value};`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return lines.join('\n');
|
|
193
|
+
}
|
|
194
|
+
generateMotionVariables(motion, indent) {
|
|
195
|
+
const spaces = ' '.repeat(indent);
|
|
196
|
+
const lines = [];
|
|
197
|
+
const prefix = this.prefix ? `${this.prefix}-` : '';
|
|
198
|
+
lines.push(`${spaces}/* Motion */`);
|
|
199
|
+
if (motion.duration) {
|
|
200
|
+
for (const [name, value] of Object.entries(motion.duration)) {
|
|
201
|
+
lines.push(`${spaces}--${prefix}duration-${this.toKebabCase(name)}: ${value};`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (motion.easing) {
|
|
205
|
+
for (const [name, value] of Object.entries(motion.easing)) {
|
|
206
|
+
lines.push(`${spaces}--${prefix}ease-${this.toKebabCase(name)}: ${value};`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return lines.join('\n');
|
|
210
|
+
}
|
|
211
|
+
// ===========================================================================
|
|
212
|
+
// Tailwind Generation
|
|
213
|
+
// ===========================================================================
|
|
214
|
+
generateTailwind(design) {
|
|
215
|
+
const lines = [];
|
|
216
|
+
// Header
|
|
217
|
+
if (this.provenance) {
|
|
218
|
+
lines.push('// Generated by Kappa v2.5 CodeDNA');
|
|
219
|
+
lines.push('// Tailwind Theme Extension');
|
|
220
|
+
lines.push('');
|
|
221
|
+
}
|
|
222
|
+
lines.push("import type { Config } from 'tailwindcss';");
|
|
223
|
+
lines.push('');
|
|
224
|
+
lines.push('const designTokens: Partial<Config["theme"]> = {');
|
|
225
|
+
lines.push(' extend: {');
|
|
226
|
+
// Colors
|
|
227
|
+
lines.push(' colors: {');
|
|
228
|
+
for (const [name, colorValue] of Object.entries(design.colors.colors)) {
|
|
229
|
+
const value = this.resolveColorValue(colorValue, design.colors);
|
|
230
|
+
lines.push(` '${this.toKebabCase(name)}': '${value}',`);
|
|
231
|
+
}
|
|
232
|
+
lines.push(' },');
|
|
233
|
+
// Typography
|
|
234
|
+
if (design.typography) {
|
|
235
|
+
if (design.typography.fontFamily) {
|
|
236
|
+
lines.push(' fontFamily: {');
|
|
237
|
+
lines.push(` sans: ['${design.typography.fontFamily}', 'sans-serif'],`);
|
|
238
|
+
if (design.typography.fontMono) {
|
|
239
|
+
lines.push(` mono: ['${design.typography.fontMono}', 'monospace'],`);
|
|
240
|
+
}
|
|
241
|
+
lines.push(' },');
|
|
242
|
+
}
|
|
243
|
+
if (design.typography.scale) {
|
|
244
|
+
lines.push(' fontSize: {');
|
|
245
|
+
for (const [name, size] of Object.entries(design.typography.scale)) {
|
|
246
|
+
lines.push(` '${this.toKebabCase(name)}': '${size}',`);
|
|
247
|
+
}
|
|
248
|
+
lines.push(' },');
|
|
249
|
+
}
|
|
250
|
+
if (design.typography.weight) {
|
|
251
|
+
lines.push(' fontWeight: {');
|
|
252
|
+
for (const [name, weight] of Object.entries(design.typography.weight)) {
|
|
253
|
+
lines.push(` '${this.toKebabCase(name)}': '${weight}',`);
|
|
254
|
+
}
|
|
255
|
+
lines.push(' },');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Spacing
|
|
259
|
+
if (design.spacing?.scale) {
|
|
260
|
+
lines.push(' spacing: {');
|
|
261
|
+
for (let i = 0; i < design.spacing.scale.length; i++) {
|
|
262
|
+
const value = design.spacing.scale[i];
|
|
263
|
+
const unit = design.spacing.unit || 'rem';
|
|
264
|
+
lines.push(` '${i}': '${value}${unit}',`);
|
|
265
|
+
}
|
|
266
|
+
lines.push(' },');
|
|
267
|
+
}
|
|
268
|
+
// Border radius
|
|
269
|
+
if (design.borders?.radius) {
|
|
270
|
+
lines.push(' borderRadius: {');
|
|
271
|
+
for (const [name, value] of Object.entries(design.borders.radius)) {
|
|
272
|
+
lines.push(` '${this.toKebabCase(name)}': '${value}',`);
|
|
273
|
+
}
|
|
274
|
+
lines.push(' },');
|
|
275
|
+
}
|
|
276
|
+
// Shadows
|
|
277
|
+
if (design.shadows?.shadows) {
|
|
278
|
+
lines.push(' boxShadow: {');
|
|
279
|
+
for (const [name, value] of Object.entries(design.shadows.shadows)) {
|
|
280
|
+
lines.push(` '${this.toKebabCase(name)}': '${value}',`);
|
|
281
|
+
}
|
|
282
|
+
lines.push(' },');
|
|
283
|
+
}
|
|
284
|
+
// Motion/Animation
|
|
285
|
+
if (design.motion) {
|
|
286
|
+
if (design.motion.duration) {
|
|
287
|
+
lines.push(' transitionDuration: {');
|
|
288
|
+
for (const [name, value] of Object.entries(design.motion.duration)) {
|
|
289
|
+
lines.push(` '${this.toKebabCase(name)}': '${value}',`);
|
|
290
|
+
}
|
|
291
|
+
lines.push(' },');
|
|
292
|
+
}
|
|
293
|
+
if (design.motion.easing) {
|
|
294
|
+
lines.push(' transitionTimingFunction: {');
|
|
295
|
+
for (const [name, value] of Object.entries(design.motion.easing)) {
|
|
296
|
+
lines.push(` '${this.toKebabCase(name)}': '${value}',`);
|
|
297
|
+
}
|
|
298
|
+
lines.push(' },');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
lines.push(' },');
|
|
302
|
+
lines.push('};');
|
|
303
|
+
lines.push('');
|
|
304
|
+
lines.push('export default designTokens;');
|
|
305
|
+
return {
|
|
306
|
+
path: 'styles/tailwind-tokens.ts',
|
|
307
|
+
content: lines.join('\n'),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
// ===========================================================================
|
|
311
|
+
// Color Utilities
|
|
312
|
+
// ===========================================================================
|
|
313
|
+
hexToHsl(hex) {
|
|
314
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
315
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
316
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
317
|
+
const max = Math.max(r, g, b);
|
|
318
|
+
const min = Math.min(r, g, b);
|
|
319
|
+
let h = 0;
|
|
320
|
+
let s = 0;
|
|
321
|
+
const l = (max + min) / 2;
|
|
322
|
+
if (max !== min) {
|
|
323
|
+
const d = max - min;
|
|
324
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
325
|
+
switch (max) {
|
|
326
|
+
case r:
|
|
327
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
328
|
+
break;
|
|
329
|
+
case g:
|
|
330
|
+
h = ((b - r) / d + 2) / 6;
|
|
331
|
+
break;
|
|
332
|
+
case b:
|
|
333
|
+
h = ((r - g) / d + 4) / 6;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return `hsl(${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%)`;
|
|
338
|
+
}
|
|
339
|
+
adjustColor(hex, amount) {
|
|
340
|
+
// Simple brightness adjustment
|
|
341
|
+
const r = Math.min(255, Math.max(0, parseInt(hex.slice(1, 3), 16) + amount * 2.55));
|
|
342
|
+
const g = Math.min(255, Math.max(0, parseInt(hex.slice(3, 5), 16) + amount * 2.55));
|
|
343
|
+
const b = Math.min(255, Math.max(0, parseInt(hex.slice(5, 7), 16) + amount * 2.55));
|
|
344
|
+
return `#${Math.round(r).toString(16).padStart(2, '0')}${Math.round(g).toString(16).padStart(2, '0')}${Math.round(b).toString(16).padStart(2, '0')}`;
|
|
345
|
+
}
|
|
346
|
+
addAlpha(hex, alpha) {
|
|
347
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
348
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
349
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
350
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
351
|
+
}
|
|
352
|
+
toKebabCase(str) {
|
|
353
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// =============================================================================
|
|
357
|
+
// Convenience Function
|
|
358
|
+
// =============================================================================
|
|
359
|
+
/**
|
|
360
|
+
* Generate design system files from Kappa DesignBlock
|
|
361
|
+
*/
|
|
362
|
+
export function generateDesign(design, options = {}) {
|
|
363
|
+
const generator = new KappaDesignGenerator(options);
|
|
364
|
+
return generator.generate(design);
|
|
365
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EntityBlock } from './kappa-ast.js';
|
|
2
|
+
export type DrizzleDialect = 'postgresql' | 'mysql' | 'sqlite';
|
|
3
|
+
export interface DrizzleGeneratorOptions {
|
|
4
|
+
/** Database dialect (default: postgresql) */
|
|
5
|
+
dialect?: DrizzleDialect;
|
|
6
|
+
/** Generate relations file (default: true) */
|
|
7
|
+
relations?: boolean;
|
|
8
|
+
/** Add provenance comments (default: true) */
|
|
9
|
+
provenance?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GeneratedSchema {
|
|
12
|
+
/** Main schema file content */
|
|
13
|
+
schema: string;
|
|
14
|
+
/** Relations file content (if enabled) */
|
|
15
|
+
relations?: string;
|
|
16
|
+
/** TypeScript types file content */
|
|
17
|
+
types: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class KappaDrizzleGenerator {
|
|
20
|
+
private dialect;
|
|
21
|
+
private provenance;
|
|
22
|
+
private generateRelations;
|
|
23
|
+
constructor(options?: DrizzleGeneratorOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Generate Drizzle schema from entity blocks
|
|
26
|
+
*/
|
|
27
|
+
generate(entities: EntityBlock[]): GeneratedSchema;
|
|
28
|
+
private generateSchemaFile;
|
|
29
|
+
private generateSchemaImports;
|
|
30
|
+
private getTableFunction;
|
|
31
|
+
private generateTable;
|
|
32
|
+
private generateColumn;
|
|
33
|
+
private generateForeignKeyColumn;
|
|
34
|
+
private getColumnTypeFunction;
|
|
35
|
+
private getColumnTypeCall;
|
|
36
|
+
private generateIndexes;
|
|
37
|
+
private generateRelationsFile;
|
|
38
|
+
private generateEntityRelations;
|
|
39
|
+
private generateTypesFile;
|
|
40
|
+
private toSnakeCase;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate Drizzle schema from Kappa entities
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateDrizzleSchema(entities: EntityBlock[], options?: DrizzleGeneratorOptions): GeneratedSchema;
|