@kernlang/core 2.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.
- package/LICENSE +661 -0
- package/dist/codegen-core.d.ts +30 -0
- package/dist/codegen-core.js +751 -0
- package/dist/codegen-core.js.map +1 -0
- package/dist/config.d.ts +69 -0
- package/dist/config.js +78 -0
- package/dist/config.js.map +1 -0
- package/dist/decompiler.d.ts +2 -0
- package/dist/decompiler.js +44 -0
- package/dist/decompiler.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.d.ts +4 -0
- package/dist/parser.js +380 -0
- package/dist/parser.js.map +1 -0
- package/dist/scanner.d.ts +40 -0
- package/dist/scanner.js +380 -0
- package/dist/scanner.js.map +1 -0
- package/dist/spec.d.ts +17 -0
- package/dist/spec.js +101 -0
- package/dist/spec.js.map +1 -0
- package/dist/styles-react.d.ts +3 -0
- package/dist/styles-react.js +20 -0
- package/dist/styles-react.js.map +1 -0
- package/dist/styles-tailwind.d.ts +8 -0
- package/dist/styles-tailwind.js +197 -0
- package/dist/styles-tailwind.js.map +1 -0
- package/dist/template-catalog.d.ts +26 -0
- package/dist/template-catalog.js +228 -0
- package/dist/template-catalog.js.map +1 -0
- package/dist/template-engine.d.ts +33 -0
- package/dist/template-engine.js +196 -0
- package/dist/template-engine.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +62 -0
- package/dist/utils.js.map +1 -0
- package/dist/version-adapters.d.ts +76 -0
- package/dist/version-adapters.js +172 -0
- package/dist/version-adapters.js.map +1 -0
- package/dist/version-detect.d.ts +30 -0
- package/dist/version-detect.js +63 -0
- package/dist/version-detect.js.map +1 -0
- package/package.json +20 -0
package/dist/scanner.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Scanner — detects project conventions and generates kern.config.ts
|
|
3
|
+
*
|
|
4
|
+
* Scans config files (package.json, tsconfig.json, .prettierrc, etc.)
|
|
5
|
+
* to auto-generate a KernConfig that matches the project's setup.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync, existsSync } from 'fs';
|
|
8
|
+
import { resolve } from 'path';
|
|
9
|
+
import { detectVersionsFromPackageJson } from './version-detect.js';
|
|
10
|
+
import { DEFAULT_CONFIG } from './config.js';
|
|
11
|
+
// ── Main Entry ───────────────────────────────────────────────────────────
|
|
12
|
+
export function scanProject(cwd) {
|
|
13
|
+
const config = {};
|
|
14
|
+
const info = {
|
|
15
|
+
packageManager: null,
|
|
16
|
+
typescript: null,
|
|
17
|
+
formatting: null,
|
|
18
|
+
editorConfig: null,
|
|
19
|
+
typeLibraries: [],
|
|
20
|
+
};
|
|
21
|
+
const detections = [];
|
|
22
|
+
detectFromPackageJson(cwd, config, info, detections);
|
|
23
|
+
detectFromTsconfig(cwd, config, info, detections);
|
|
24
|
+
detectFromPrettierrc(cwd, info, detections);
|
|
25
|
+
detectFromEditorConfig(cwd, info, detections);
|
|
26
|
+
detectPackageManager(cwd, info, detections);
|
|
27
|
+
return { config, info, detections };
|
|
28
|
+
}
|
|
29
|
+
// ── Detector: package.json ───────────────────────────────────────────────
|
|
30
|
+
function detectFromPackageJson(cwd, config, info, detections) {
|
|
31
|
+
const pkgPath = resolve(cwd, 'package.json');
|
|
32
|
+
if (!existsSync(pkgPath))
|
|
33
|
+
return;
|
|
34
|
+
let pkg;
|
|
35
|
+
try {
|
|
36
|
+
pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const deps = (pkg.dependencies ?? {});
|
|
42
|
+
const devDeps = (pkg.devDependencies ?? {});
|
|
43
|
+
const allDeps = { ...devDeps, ...deps };
|
|
44
|
+
// ── Target detection (priority order) ──
|
|
45
|
+
const target = detectTarget(allDeps);
|
|
46
|
+
if (target) {
|
|
47
|
+
config.target = target;
|
|
48
|
+
detections.push({ source: 'package.json', field: 'target', value: target, confidence: 'high' });
|
|
49
|
+
}
|
|
50
|
+
// ── Framework versions (reuse core utility) ──
|
|
51
|
+
const versions = detectVersionsFromPackageJson(pkg);
|
|
52
|
+
if (versions.nextjs || versions.tailwind) {
|
|
53
|
+
config.frameworkVersions = versions;
|
|
54
|
+
if (versions.nextjs) {
|
|
55
|
+
detections.push({ source: 'package.json', field: 'frameworkVersions.nextjs', value: versions.nextjs, confidence: 'high' });
|
|
56
|
+
}
|
|
57
|
+
if (versions.tailwind) {
|
|
58
|
+
detections.push({ source: 'package.json', field: 'frameworkVersions.tailwind', value: versions.tailwind, confidence: 'high' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// ── i18n detection ──
|
|
62
|
+
if (allDeps['next-intl']) {
|
|
63
|
+
config.i18n = { enabled: true, hookName: 'useTranslations', importPath: 'next-intl' };
|
|
64
|
+
detections.push({ source: 'package.json', field: 'i18n', value: 'next-intl (useTranslations)', confidence: 'high' });
|
|
65
|
+
}
|
|
66
|
+
else if (allDeps['react-i18next']) {
|
|
67
|
+
config.i18n = { enabled: true, hookName: 'useTranslation', importPath: 'react-i18next' };
|
|
68
|
+
detections.push({ source: 'package.json', field: 'i18n', value: 'react-i18next (useTranslation)', confidence: 'high' });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
config.i18n = { enabled: false };
|
|
72
|
+
detections.push({ source: 'package.json', field: 'i18n', value: 'disabled (no i18n library found)', confidence: 'medium' });
|
|
73
|
+
}
|
|
74
|
+
// ── UI library detection ──
|
|
75
|
+
if (allDeps['@shadcn/ui'] || pkg.name === 'shadcn' || existsSync(resolve(cwd, 'components.json'))) {
|
|
76
|
+
config.components = { ...config.components, uiLibrary: '@/components/ui' };
|
|
77
|
+
detections.push({ source: 'package.json', field: 'components.uiLibrary', value: '@/components/ui (shadcn)', confidence: 'high' });
|
|
78
|
+
}
|
|
79
|
+
else if (allDeps['@mui/material']) {
|
|
80
|
+
config.components = { ...config.components, uiLibrary: '@mui/material' };
|
|
81
|
+
detections.push({ source: 'package.json', field: 'components.uiLibrary', value: '@mui/material', confidence: 'high' });
|
|
82
|
+
}
|
|
83
|
+
else if (allDeps['@chakra-ui/react']) {
|
|
84
|
+
config.components = { ...config.components, uiLibrary: '@chakra-ui/react' };
|
|
85
|
+
detections.push({ source: 'package.json', field: 'components.uiLibrary', value: '@chakra-ui/react', confidence: 'high' });
|
|
86
|
+
}
|
|
87
|
+
// ── Express extras ──
|
|
88
|
+
if (target === 'express') {
|
|
89
|
+
const express = {};
|
|
90
|
+
if (allDeps['helmet']) {
|
|
91
|
+
express.helmet = true;
|
|
92
|
+
detections.push({ source: 'package.json', field: 'express.helmet', value: 'true', confidence: 'high' });
|
|
93
|
+
}
|
|
94
|
+
if (allDeps['compression']) {
|
|
95
|
+
express.compression = true;
|
|
96
|
+
detections.push({ source: 'package.json', field: 'express.compression', value: 'true', confidence: 'high' });
|
|
97
|
+
}
|
|
98
|
+
if (Object.keys(express).length > 0) {
|
|
99
|
+
config.express = express;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ── Type libraries (report only) ──
|
|
103
|
+
const typeLibs = ['zod', 'valibot', 'prisma', '@prisma/client', 'drizzle-orm', 'yup', 'io-ts'];
|
|
104
|
+
for (const lib of typeLibs) {
|
|
105
|
+
if (allDeps[lib]) {
|
|
106
|
+
info.typeLibraries.push(lib);
|
|
107
|
+
detections.push({ source: 'package.json', field: 'info.typeLibraries', value: lib, confidence: 'medium' });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function detectTarget(allDeps) {
|
|
112
|
+
// Priority: most specific framework first
|
|
113
|
+
if (allDeps['next'])
|
|
114
|
+
return 'nextjs';
|
|
115
|
+
if (allDeps['react-native'])
|
|
116
|
+
return 'native';
|
|
117
|
+
if (allDeps['express'])
|
|
118
|
+
return 'express';
|
|
119
|
+
if (allDeps['tailwindcss'] && !allDeps['next'])
|
|
120
|
+
return 'tailwind';
|
|
121
|
+
if (allDeps['react'])
|
|
122
|
+
return 'web';
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
// ── Detector: tsconfig.json ──────────────────────────────────────────────
|
|
126
|
+
function detectFromTsconfig(cwd, config, info, detections) {
|
|
127
|
+
const tsconfigPath = resolve(cwd, 'tsconfig.json');
|
|
128
|
+
if (!existsSync(tsconfigPath))
|
|
129
|
+
return;
|
|
130
|
+
let tsconfig;
|
|
131
|
+
try {
|
|
132
|
+
tsconfig = parseJsonWithComments(readFileSync(tsconfigPath, 'utf-8'));
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// Follow extends one level
|
|
138
|
+
let baseConfig = {};
|
|
139
|
+
const extendsPath = tsconfig.extends;
|
|
140
|
+
if (extendsPath) {
|
|
141
|
+
try {
|
|
142
|
+
const resolvedExtends = resolve(cwd, extendsPath);
|
|
143
|
+
if (existsSync(resolvedExtends)) {
|
|
144
|
+
baseConfig = parseJsonWithComments(readFileSync(resolvedExtends, 'utf-8'));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// ignore
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Merge compiler options (tsconfig overrides base)
|
|
152
|
+
const baseOpts = (baseConfig.compilerOptions ?? {});
|
|
153
|
+
const opts = { ...baseOpts, ...(tsconfig.compilerOptions ?? {}) };
|
|
154
|
+
const strict = opts.strict === true;
|
|
155
|
+
const module = opts.module ?? null;
|
|
156
|
+
const paths = (opts.paths ?? {});
|
|
157
|
+
info.typescript = { strict, pathAliases: paths, module };
|
|
158
|
+
detections.push({ source: 'tsconfig.json', field: 'info.typescript.strict', value: String(strict), confidence: 'high' });
|
|
159
|
+
if (module) {
|
|
160
|
+
detections.push({ source: 'tsconfig.json', field: 'info.typescript.module', value: module, confidence: 'medium' });
|
|
161
|
+
}
|
|
162
|
+
// Extract path aliases → componentRoot
|
|
163
|
+
const aliasKeys = Object.keys(paths);
|
|
164
|
+
const atAlias = aliasKeys.find(k => k.startsWith('@/'));
|
|
165
|
+
if (atAlias) {
|
|
166
|
+
config.components = { ...config.components, componentRoot: '@/components' };
|
|
167
|
+
detections.push({ source: 'tsconfig.json', field: 'components.componentRoot', value: '@/components (from @/* alias)', confidence: 'medium' });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// ── Detector: .prettierrc ────────────────────────────────────────────────
|
|
171
|
+
function detectFromPrettierrc(cwd, info, detections) {
|
|
172
|
+
const candidates = ['.prettierrc', '.prettierrc.json'];
|
|
173
|
+
let raw = null;
|
|
174
|
+
let source = '';
|
|
175
|
+
for (const name of candidates) {
|
|
176
|
+
const p = resolve(cwd, name);
|
|
177
|
+
if (existsSync(p)) {
|
|
178
|
+
try {
|
|
179
|
+
raw = readFileSync(p, 'utf-8');
|
|
180
|
+
source = name;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// continue
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (!raw)
|
|
189
|
+
return;
|
|
190
|
+
let prettier;
|
|
191
|
+
try {
|
|
192
|
+
prettier = JSON.parse(raw);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const semicolons = prettier.semi !== false;
|
|
198
|
+
const singleQuote = prettier.singleQuote === true;
|
|
199
|
+
const tabWidth = typeof prettier.tabWidth === 'number' ? prettier.tabWidth : 2;
|
|
200
|
+
const trailingComma = typeof prettier.trailingComma === 'string' ? prettier.trailingComma : 'es5';
|
|
201
|
+
info.formatting = { semicolons, singleQuote, tabWidth, trailingComma };
|
|
202
|
+
detections.push({ source, field: 'info.formatting', value: `semi=${semicolons} quote=${singleQuote ? 'single' : 'double'} tab=${tabWidth}`, confidence: 'medium' });
|
|
203
|
+
}
|
|
204
|
+
// ── Detector: .editorconfig ──────────────────────────────────────────────
|
|
205
|
+
function detectFromEditorConfig(cwd, info, detections) {
|
|
206
|
+
const ecPath = resolve(cwd, '.editorconfig');
|
|
207
|
+
if (!existsSync(ecPath))
|
|
208
|
+
return;
|
|
209
|
+
let raw;
|
|
210
|
+
try {
|
|
211
|
+
raw = readFileSync(ecPath, 'utf-8');
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Simple line-by-line parse — find [*] section
|
|
217
|
+
const lines = raw.split('\n');
|
|
218
|
+
let inGlobal = false;
|
|
219
|
+
let indentStyle = 'space';
|
|
220
|
+
let indentSize = 2;
|
|
221
|
+
for (const line of lines) {
|
|
222
|
+
const trimmed = line.trim();
|
|
223
|
+
if (trimmed.startsWith('[')) {
|
|
224
|
+
inGlobal = trimmed === '[*]';
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (!inGlobal)
|
|
228
|
+
continue;
|
|
229
|
+
const [key, rawVal] = trimmed.split('=').map(s => s.trim());
|
|
230
|
+
const val = rawVal?.replace(/[#;].*$/, '').trim();
|
|
231
|
+
if (key === 'indent_style' && val)
|
|
232
|
+
indentStyle = val;
|
|
233
|
+
if (key === 'indent_size' && val)
|
|
234
|
+
indentSize = parseInt(val, 10) || 2;
|
|
235
|
+
}
|
|
236
|
+
info.editorConfig = { indentStyle, indentSize };
|
|
237
|
+
detections.push({ source: '.editorconfig', field: 'info.editorConfig', value: `${indentStyle} (${indentSize})`, confidence: 'medium' });
|
|
238
|
+
}
|
|
239
|
+
// ── Detector: package manager (lockfile) ─────────────────────────────────
|
|
240
|
+
function detectPackageManager(cwd, info, detections) {
|
|
241
|
+
const lockfiles = [
|
|
242
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
243
|
+
['yarn.lock', 'yarn'],
|
|
244
|
+
['bun.lockb', 'bun'],
|
|
245
|
+
['package-lock.json', 'npm'],
|
|
246
|
+
];
|
|
247
|
+
for (const [file, manager] of lockfiles) {
|
|
248
|
+
if (existsSync(resolve(cwd, file))) {
|
|
249
|
+
info.packageManager = manager;
|
|
250
|
+
detections.push({ source: file, field: 'info.packageManager', value: manager, confidence: 'high' });
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// ── Config Source Generator ──────────────────────────────────────────────
|
|
256
|
+
export function generateConfigSource(result) {
|
|
257
|
+
const { config } = result;
|
|
258
|
+
const lines = [];
|
|
259
|
+
lines.push("import type { KernConfig } from '@kernlang/core';");
|
|
260
|
+
lines.push('');
|
|
261
|
+
lines.push('const config: KernConfig = {');
|
|
262
|
+
// target — always emit when detected (explicit is better than implicit default)
|
|
263
|
+
if (config.target) {
|
|
264
|
+
lines.push(` target: '${config.target}',`);
|
|
265
|
+
}
|
|
266
|
+
// frameworkVersions
|
|
267
|
+
if (config.frameworkVersions) {
|
|
268
|
+
const fv = config.frameworkVersions;
|
|
269
|
+
const entries = [];
|
|
270
|
+
if (fv.nextjs)
|
|
271
|
+
entries.push(`nextjs: '${fv.nextjs}'`);
|
|
272
|
+
if (fv.tailwind)
|
|
273
|
+
entries.push(`tailwind: '${fv.tailwind}'`);
|
|
274
|
+
if (entries.length > 0) {
|
|
275
|
+
lines.push(` frameworkVersions: { ${entries.join(', ')} },`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// i18n
|
|
279
|
+
if (config.i18n) {
|
|
280
|
+
if (config.i18n.enabled === false) {
|
|
281
|
+
lines.push(' i18n: { enabled: false },');
|
|
282
|
+
}
|
|
283
|
+
else if (config.i18n.hookName && config.i18n.importPath) {
|
|
284
|
+
if (config.i18n.hookName !== DEFAULT_CONFIG.i18n.hookName ||
|
|
285
|
+
config.i18n.importPath !== DEFAULT_CONFIG.i18n.importPath) {
|
|
286
|
+
lines.push(' i18n: {');
|
|
287
|
+
lines.push(' enabled: true,');
|
|
288
|
+
lines.push(` hookName: '${config.i18n.hookName}',`);
|
|
289
|
+
lines.push(` importPath: '${config.i18n.importPath}',`);
|
|
290
|
+
lines.push(' },');
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// components
|
|
295
|
+
if (config.components) {
|
|
296
|
+
const comp = config.components;
|
|
297
|
+
const compEntries = [];
|
|
298
|
+
if (comp.uiLibrary && comp.uiLibrary !== DEFAULT_CONFIG.components.uiLibrary) {
|
|
299
|
+
compEntries.push(`uiLibrary: '${comp.uiLibrary}'`);
|
|
300
|
+
}
|
|
301
|
+
if (comp.componentRoot && comp.componentRoot !== DEFAULT_CONFIG.components.componentRoot) {
|
|
302
|
+
compEntries.push(`componentRoot: '${comp.componentRoot}'`);
|
|
303
|
+
}
|
|
304
|
+
if (compEntries.length > 0) {
|
|
305
|
+
lines.push(` components: { ${compEntries.join(', ')} },`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// express
|
|
309
|
+
if (config.express) {
|
|
310
|
+
const ex = config.express;
|
|
311
|
+
const exEntries = [];
|
|
312
|
+
if (ex.helmet)
|
|
313
|
+
exEntries.push('helmet: true');
|
|
314
|
+
if (ex.compression)
|
|
315
|
+
exEntries.push('compression: true');
|
|
316
|
+
if (exEntries.length > 0) {
|
|
317
|
+
lines.push(` express: { ${exEntries.join(', ')} },`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
lines.push('};');
|
|
321
|
+
lines.push('');
|
|
322
|
+
lines.push('export default config;');
|
|
323
|
+
lines.push('');
|
|
324
|
+
return lines.join('\n');
|
|
325
|
+
}
|
|
326
|
+
// ── Summary Formatter ────────────────────────────────────────────────────
|
|
327
|
+
const ANSI_GREEN = '\x1b[32m';
|
|
328
|
+
const ANSI_YELLOW = '\x1b[33m';
|
|
329
|
+
const ANSI_DIM = '\x1b[2m';
|
|
330
|
+
const ANSI_BOLD = '\x1b[1m';
|
|
331
|
+
const ANSI_RESET = '\x1b[0m';
|
|
332
|
+
const INFO_FIELDS = new Set([
|
|
333
|
+
'info.typescript.strict',
|
|
334
|
+
'info.typescript.module',
|
|
335
|
+
'info.formatting',
|
|
336
|
+
'info.editorConfig',
|
|
337
|
+
'info.typeLibraries',
|
|
338
|
+
'info.packageManager',
|
|
339
|
+
]);
|
|
340
|
+
export function formatScanSummary(result) {
|
|
341
|
+
const lines = [];
|
|
342
|
+
lines.push('');
|
|
343
|
+
lines.push(` ${ANSI_BOLD}KERN scan${ANSI_RESET} — project analysis`);
|
|
344
|
+
lines.push('');
|
|
345
|
+
// Group detections by source
|
|
346
|
+
const bySource = new Map();
|
|
347
|
+
for (const d of result.detections) {
|
|
348
|
+
const existing = bySource.get(d.source) ?? [];
|
|
349
|
+
existing.push(d);
|
|
350
|
+
bySource.set(d.source, existing);
|
|
351
|
+
}
|
|
352
|
+
for (const [source, dets] of bySource) {
|
|
353
|
+
lines.push(` ${ANSI_DIM}${source}${ANSI_RESET}`);
|
|
354
|
+
for (const d of dets) {
|
|
355
|
+
const isInfo = INFO_FIELDS.has(d.field);
|
|
356
|
+
const marker = isInfo ? `${ANSI_YELLOW}-${ANSI_RESET}` : `${ANSI_GREEN}✓${ANSI_RESET}`;
|
|
357
|
+
lines.push(` ${marker} ${d.field}: ${d.value}`);
|
|
358
|
+
}
|
|
359
|
+
lines.push('');
|
|
360
|
+
}
|
|
361
|
+
if (result.detections.length === 0) {
|
|
362
|
+
lines.push(' No project configuration detected.');
|
|
363
|
+
lines.push('');
|
|
364
|
+
}
|
|
365
|
+
return lines.join('\n');
|
|
366
|
+
}
|
|
367
|
+
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
368
|
+
function parseJsonWithComments(raw) {
|
|
369
|
+
// Strip comments while preserving string contents.
|
|
370
|
+
// Matches strings first (to skip them), then comments to remove.
|
|
371
|
+
const stripped = raw
|
|
372
|
+
.replace(/"(?:[^"\\]|\\.)*"|\/\/.*$|\/\*[\s\S]*?\*\//gm, (match) => {
|
|
373
|
+
// Keep strings as-is, remove comments
|
|
374
|
+
return match.startsWith('"') ? match : '';
|
|
375
|
+
})
|
|
376
|
+
// Remove trailing commas before } or ]
|
|
377
|
+
.replace(/,\s*([}\]])/g, '$1');
|
|
378
|
+
return JSON.parse(stripped);
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0B7C,4EAA4E;AAE5E,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,IAAI,GAAa;QACrB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,EAAE;KAClB,CAAC;IACF,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACrD,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5C,sBAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAC9C,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAE5C,O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mD;IACnD,iEAAiE;IACjE,MAAM,QAAQ,GAAG,GAAG;SACjB,OAAO,CAAC,8CAA8C,EAAE,CAAC,KAAK,EAAE,EAAE;QACjE,sCAAsC;QACtC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC,CAAC;QACF,uCAAuC;SACtC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/spec.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kern v2 Specification
|
|
3
|
+
*
|
|
4
|
+
* The LLM-native language. Swiss-engineered.
|
|
5
|
+
* Designed by 3 AIs through forge + tribunal + brainstorm.
|
|
6
|
+
*
|
|
7
|
+
* Foundation: indent-based, semantic names, key=value props
|
|
8
|
+
* Styles: shorthand blocks in {} with CSS escape hatch
|
|
9
|
+
* Meta: theme nodes ($ref), pseudo-selectors (:press, :hover)
|
|
10
|
+
* Targets: Next.js, React+Tailwind, React Native, Express
|
|
11
|
+
*/
|
|
12
|
+
export declare const KERN_VERSION = "2.0.0";
|
|
13
|
+
export declare const IR_GRAMMAR = "\ndocument = node+\nnode = indent type (SP prop)* (SP style)? (SP themeref)* NL child*\nchild = node\nindent = \" \"*\ntype = ident\nprop = ident \"=\" value\nvalue = quoted | bare\nquoted = '\"' [^\"]* '\"'\nbare = [^\\s{$]+\nstyle = \"{\" spair (\",\" spair)* \"}\"\nspair = sident \":\" svalue | \":\" pseudo \":\" sident \":\" svalue\npseudo = \"press\" | \"hover\" | \"active\" | \"focus\"\nsident = shorthand | ident\nsvalue = [^,}]+\nthemeref = \"$\" ident\nident = [A-Za-z_][A-Za-z0-9_-]*\nSP = \" \"+\nNL = \"\\n\" | EOF\n";
|
|
14
|
+
export declare const NODE_TYPES: readonly ["screen", "row", "col", "card", "scroll", "text", "image", "progress", "divider", "button", "input", "modal", "list", "item", "tabs", "tab", "header", "theme", "server", "route", "middleware", "handler", "schema", "stream", "spawn", "timer", "on", "env", "cli", "command", "arg", "flag", "import", "separator", "table", "scoreboard", "metric", "spinner", "progress", "box", "gradient", "state", "repl", "guard", "parallel", "dispatch", "then", "each", "generateMetadata", "notFound", "redirect", "fetch", "type", "interface", "field", "fn", "machine", "transition", "error", "module", "export", "config", "store", "test", "describe", "it", "event", "hook", "provider", "effect", "memo", "callback", "ref", "context", "cleanup", "prop", "returns", "template", "slot", "body"];
|
|
15
|
+
export type IRNodeType = (typeof NODE_TYPES)[number];
|
|
16
|
+
export declare const STYLE_SHORTHANDS: Record<string, string>;
|
|
17
|
+
export declare const VALUE_SHORTHANDS: Record<string, string>;
|
package/dist/spec.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kern v2 Specification
|
|
3
|
+
*
|
|
4
|
+
* The LLM-native language. Swiss-engineered.
|
|
5
|
+
* Designed by 3 AIs through forge + tribunal + brainstorm.
|
|
6
|
+
*
|
|
7
|
+
* Foundation: indent-based, semantic names, key=value props
|
|
8
|
+
* Styles: shorthand blocks in {} with CSS escape hatch
|
|
9
|
+
* Meta: theme nodes ($ref), pseudo-selectors (:press, :hover)
|
|
10
|
+
* Targets: Next.js, React+Tailwind, React Native, Express
|
|
11
|
+
*/
|
|
12
|
+
export const KERN_VERSION = '2.0.0';
|
|
13
|
+
// ── Grammar ─────────────────────────────────────────────────────────────
|
|
14
|
+
export const IR_GRAMMAR = `
|
|
15
|
+
document = node+
|
|
16
|
+
node = indent type (SP prop)* (SP style)? (SP themeref)* NL child*
|
|
17
|
+
child = node
|
|
18
|
+
indent = " "*
|
|
19
|
+
type = ident
|
|
20
|
+
prop = ident "=" value
|
|
21
|
+
value = quoted | bare
|
|
22
|
+
quoted = '"' [^"]* '"'
|
|
23
|
+
bare = [^\\s{$]+
|
|
24
|
+
style = "{" spair ("," spair)* "}"
|
|
25
|
+
spair = sident ":" svalue | ":" pseudo ":" sident ":" svalue
|
|
26
|
+
pseudo = "press" | "hover" | "active" | "focus"
|
|
27
|
+
sident = shorthand | ident
|
|
28
|
+
svalue = [^,}]+
|
|
29
|
+
themeref = "$" ident
|
|
30
|
+
ident = [A-Za-z_][A-Za-z0-9_-]*
|
|
31
|
+
SP = " "+
|
|
32
|
+
NL = "\\n" | EOF
|
|
33
|
+
`;
|
|
34
|
+
// ── Node Types ──────────────────────────────────────────────────────────
|
|
35
|
+
export const NODE_TYPES = [
|
|
36
|
+
// Layout
|
|
37
|
+
'screen', 'row', 'col', 'card', 'scroll',
|
|
38
|
+
// Content
|
|
39
|
+
'text', 'image', 'progress', 'divider',
|
|
40
|
+
// Interactive
|
|
41
|
+
'button', 'input', 'modal',
|
|
42
|
+
// Lists
|
|
43
|
+
'list', 'item',
|
|
44
|
+
// Navigation
|
|
45
|
+
'tabs', 'tab', 'header',
|
|
46
|
+
// Meta
|
|
47
|
+
'theme',
|
|
48
|
+
// Backend
|
|
49
|
+
'server', 'route', 'middleware', 'handler', 'schema',
|
|
50
|
+
'stream', 'spawn', 'timer', 'on', 'env',
|
|
51
|
+
// CLI
|
|
52
|
+
'cli', 'command', 'arg', 'flag', 'import',
|
|
53
|
+
// Terminal
|
|
54
|
+
'separator', 'table', 'scoreboard', 'metric',
|
|
55
|
+
'spinner', 'progress', 'box', 'gradient',
|
|
56
|
+
'state', 'repl', 'guard', 'parallel', 'dispatch', 'then', 'each',
|
|
57
|
+
// Next.js production patterns
|
|
58
|
+
'generateMetadata', 'notFound', 'redirect', 'fetch',
|
|
59
|
+
// Core Language — type system, functions, state machines
|
|
60
|
+
'type', 'interface', 'field', 'fn',
|
|
61
|
+
'machine', 'transition',
|
|
62
|
+
'error', 'module', 'export',
|
|
63
|
+
'config', 'store',
|
|
64
|
+
'test', 'describe', 'it',
|
|
65
|
+
'event',
|
|
66
|
+
// React — hooks, providers, effects
|
|
67
|
+
'hook', 'provider', 'effect',
|
|
68
|
+
'memo', 'callback', 'ref', 'context', 'cleanup',
|
|
69
|
+
'prop', 'returns',
|
|
70
|
+
// Template system
|
|
71
|
+
'template', 'slot', 'body',
|
|
72
|
+
];
|
|
73
|
+
// ── Style Shorthands (FROZEN at v1.0 — 30 entries) ──────────────────────
|
|
74
|
+
// Any CSS property not in this map uses the escape hatch: "property":"value"
|
|
75
|
+
// This map will NOT grow. Use quoted keys for new CSS properties.
|
|
76
|
+
export const STYLE_SHORTHANDS = {
|
|
77
|
+
// Spacing
|
|
78
|
+
p: 'padding', m: 'margin',
|
|
79
|
+
pt: 'paddingTop', pb: 'paddingBottom', pl: 'paddingLeft', pr: 'paddingRight',
|
|
80
|
+
mt: 'marginTop', mb: 'marginBottom', ml: 'marginLeft', mr: 'marginRight',
|
|
81
|
+
// Sizing
|
|
82
|
+
w: 'width', h: 'height', f: 'flex',
|
|
83
|
+
// Colors
|
|
84
|
+
bg: 'backgroundColor', c: 'color', bc: 'borderColor',
|
|
85
|
+
// Typography
|
|
86
|
+
fs: 'fontSize', fw: 'fontWeight', ta: 'textAlign',
|
|
87
|
+
// Borders
|
|
88
|
+
br: 'borderRadius', bw: 'borderWidth',
|
|
89
|
+
// Layout
|
|
90
|
+
jc: 'justifyContent', ai: 'alignItems', fd: 'flexDirection',
|
|
91
|
+
// Effects
|
|
92
|
+
shadow: 'elevation',
|
|
93
|
+
};
|
|
94
|
+
// ── Justify/Align Value Shorthands ──────────────────────────────────────
|
|
95
|
+
export const VALUE_SHORTHANDS = {
|
|
96
|
+
sb: 'space-between', sa: 'space-around', se: 'space-evenly',
|
|
97
|
+
center: 'center', start: 'flex-start', end: 'flex-end',
|
|
98
|
+
stretch: 'stretch', bold: 'bold',
|
|
99
|
+
full: '100%',
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=spec.js.map
|
package/dist/spec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec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AM;CACb,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { STYLE_SHORTHANDS, VALUE_SHORTHANDS } from './spec.js';
|
|
2
|
+
export function expandStyleKey(key) {
|
|
3
|
+
return STYLE_SHORTHANDS[key] || key;
|
|
4
|
+
}
|
|
5
|
+
export function expandStyleValue(value) {
|
|
6
|
+
if (VALUE_SHORTHANDS[value])
|
|
7
|
+
return VALUE_SHORTHANDS[value];
|
|
8
|
+
const num = Number(value);
|
|
9
|
+
if (!isNaN(num) && value !== '')
|
|
10
|
+
return num;
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function expandStyles(styles) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const [k, v] of Object.entries(styles)) {
|
|
16
|
+
result[expandStyleKey(k)] = expandStyleValue(v);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=styles-react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-react.js","sourceRoot":"","sources":["../src/styles-react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,gBAAgB,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA8B;IACzD,MAAM,MAAM,GAAoC,EAAE,CAAC;IACnD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_COLORS: Record<string, string>;
|
|
2
|
+
export declare function stylesToTailwind(styles: Record<string, string>, colors?: Record<string, string>): string;
|
|
3
|
+
export declare function pxToTw(prefix: string, v: string): string;
|
|
4
|
+
export declare function colorToTw(prefix: string, v: string, colors?: Record<string, string>): string;
|
|
5
|
+
export declare function fsTw(v: string): string;
|
|
6
|
+
export declare function fwTw(v: string): string;
|
|
7
|
+
export declare function addPx(v: string): string;
|
|
8
|
+
export declare function cssKebab(s: string): string;
|