kern-lang 1.0.0 → 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/dist/index.d.ts +14 -25
- package/dist/index.js +15 -28
- package/dist/index.js.map +1 -1
- package/package.json +17 -36
- package/README.md +0 -304
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -244
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -46
- package/dist/config.js +0 -54
- package/dist/config.js.map +0 -1
- package/dist/context-export.d.ts +0 -11
- package/dist/context-export.js +0 -121
- package/dist/context-export.js.map +0 -1
- package/dist/decompiler.d.ts +0 -2
- package/dist/decompiler.js +0 -44
- package/dist/decompiler.js.map +0 -1
- package/dist/draft-protocol.d.ts +0 -27
- package/dist/draft-protocol.js +0 -135
- package/dist/draft-protocol.js.map +0 -1
- package/dist/errors.d.ts +0 -12
- package/dist/errors.js +0 -40
- package/dist/errors.js.map +0 -1
- package/dist/metrics.d.ts +0 -30
- package/dist/metrics.js +0 -182
- package/dist/metrics.js.map +0 -1
- package/dist/parser.d.ts +0 -4
- package/dist/parser.js +0 -361
- package/dist/parser.js.map +0 -1
- package/dist/spec.d.ts +0 -17
- package/dist/spec.js +0 -86
- package/dist/spec.js.map +0 -1
- package/dist/styles-react.d.ts +0 -3
- package/dist/styles-react.js +0 -20
- package/dist/styles-react.js.map +0 -1
- package/dist/styles-tailwind.d.ts +0 -8
- package/dist/styles-tailwind.js +0 -197
- package/dist/styles-tailwind.js.map +0 -1
- package/dist/transpiler-cli.d.ts +0 -3
- package/dist/transpiler-cli.js +0 -279
- package/dist/transpiler-cli.js.map +0 -1
- package/dist/transpiler-express.d.ts +0 -3
- package/dist/transpiler-express.js +0 -612
- package/dist/transpiler-express.js.map +0 -1
- package/dist/transpiler-nextjs.d.ts +0 -21
- package/dist/transpiler-nextjs.js +0 -400
- package/dist/transpiler-nextjs.js.map +0 -1
- package/dist/transpiler-tailwind.d.ts +0 -3
- package/dist/transpiler-tailwind.js +0 -594
- package/dist/transpiler-tailwind.js.map +0 -1
- package/dist/transpiler-terminal.d.ts +0 -3
- package/dist/transpiler-terminal.js +0 -522
- package/dist/transpiler-terminal.js.map +0 -1
- package/dist/transpiler-web.d.ts +0 -3
- package/dist/transpiler-web.js +0 -218
- package/dist/transpiler-web.js.map +0 -1
- package/dist/transpiler.d.ts +0 -3
- package/dist/transpiler.js +0 -218
- package/dist/transpiler.js.map +0 -1
- package/dist/types.d.ts +0 -76
- package/dist/types.js +0 -11
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +0 -36
- package/dist/utils.js.map +0 -1
- package/kern.config.ts +0 -61
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* kern-lang v2.0.0 — compatibility wrapper
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Re-exports all @kernlang/* packages for backwards compatibility.
|
|
5
|
+
* For new projects, import from @kernlang/core + @kernlang/<target> directly.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export { transpileTerminal } from './transpiler-terminal.js';
|
|
19
|
-
export { collectLanguageMetrics, mergeMetrics, isEscapedStyleKey } from './metrics.js';
|
|
20
|
-
export type { LanguageMetrics, StyleMetrics, NodeTypeMetrics } from './metrics.js';
|
|
21
|
-
export { scanKernProject, projectToKern } from './context-export.js';
|
|
22
|
-
export type { ProjectSummary } from './context-export.js';
|
|
23
|
-
export { buildKernDraftPrompt, parseKernDraft, buildKernRankPrompt } from './draft-protocol.js';
|
|
24
|
-
export type { KernDraft } from './draft-protocol.js';
|
|
25
|
-
export { KERN_VERSION, NODE_TYPES, STYLE_SHORTHANDS, VALUE_SHORTHANDS } from './spec.js';
|
|
26
|
-
export { stylesToTailwind, colorToTw, pxToTw, DEFAULT_COLORS } from './styles-tailwind.js';
|
|
27
|
-
export { expandStyles, expandStyleKey, expandStyleValue } from './styles-react.js';
|
|
28
|
-
export { countTokens, serializeIR, camelKey, escapeJsx } from './utils.js';
|
|
7
|
+
export * from '@kernlang/core';
|
|
8
|
+
export * from '@kernlang/protocol';
|
|
9
|
+
export { transpileTailwind, transpileNextjs, transpileWeb } from '@kernlang/react';
|
|
10
|
+
export { transpile } from '@kernlang/native';
|
|
11
|
+
export { transpileExpress } from '@kernlang/express';
|
|
12
|
+
export { transpileCliApp } from '@kernlang/cli';
|
|
13
|
+
export { transpileTerminal } from '@kernlang/terminal';
|
|
14
|
+
export { collectLanguageMetrics, mergeMetrics, isEscapedStyleKey } from '@kernlang/metrics';
|
|
15
|
+
export type { LanguageMetrics, StyleMetrics, NodeTypeMetrics } from '@kernlang/metrics';
|
|
16
|
+
export { scanKernProject, projectToKern } from '@kernlang/metrics';
|
|
17
|
+
export type { ProjectSummary } from '@kernlang/metrics';
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* kern-lang v2.0.0 — compatibility wrapper
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Re-exports all @kernlang/* packages for backwards compatibility.
|
|
5
|
+
* For new projects, import from @kernlang/core + @kernlang/<target> directly.
|
|
6
6
|
*/
|
|
7
|
-
// Core
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export { resolveConfig, mergeConfig, DEFAULT_CONFIG, VALID_TARGETS } from './config.js';
|
|
7
|
+
// Core (parser, types, config, spec, styles, codegen, utils)
|
|
8
|
+
export * from '@kernlang/core';
|
|
9
|
+
// Protocol (draft protocol for AI engines)
|
|
10
|
+
export * from '@kernlang/protocol';
|
|
12
11
|
// Transpilers
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
export { collectLanguageMetrics, mergeMetrics, isEscapedStyleKey } from './metrics.js';
|
|
22
|
-
// Context export (for Agon integration)
|
|
23
|
-
export { scanKernProject, projectToKern } from './context-export.js';
|
|
24
|
-
// Draft protocol (for Agon forge/brainstorm/tribunal)
|
|
25
|
-
export { buildKernDraftPrompt, parseKernDraft, buildKernRankPrompt } from './draft-protocol.js';
|
|
26
|
-
// Spec
|
|
27
|
-
export { KERN_VERSION, NODE_TYPES, STYLE_SHORTHANDS, VALUE_SHORTHANDS } from './spec.js';
|
|
28
|
-
// Shared style engines
|
|
29
|
-
export { stylesToTailwind, colorToTw, pxToTw, DEFAULT_COLORS } from './styles-tailwind.js';
|
|
30
|
-
export { expandStyles, expandStyleKey, expandStyleValue } from './styles-react.js';
|
|
31
|
-
// Utilities
|
|
32
|
-
export { countTokens, serializeIR, camelKey, escapeJsx } from './utils.js';
|
|
12
|
+
export { transpileTailwind, transpileNextjs, transpileWeb } from '@kernlang/react';
|
|
13
|
+
export { transpile } from '@kernlang/native';
|
|
14
|
+
export { transpileExpress } from '@kernlang/express';
|
|
15
|
+
export { transpileCliApp } from '@kernlang/cli';
|
|
16
|
+
export { transpileTerminal } from '@kernlang/terminal';
|
|
17
|
+
// Metrics + context export
|
|
18
|
+
export { collectLanguageMetrics, mergeMetrics, isEscapedStyleKey } from '@kernlang/metrics';
|
|
19
|
+
export { scanKernProject, projectToKern } from '@kernlang/metrics';
|
|
33
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,6DAA6D;AAC7D,cAAc,gBAAgB,CAAC;AAE/B,2CAA2C;AAC3C,cAAc,oBAAoB,CAAC;AAEnC,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,2BAA2B;AAC3B,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kern-lang",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "The language LLMs think in. Write one .kern file, ship 7 targets. 70% fewer tokens.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"kern": "./dist/cli.js"
|
|
8
|
-
},
|
|
9
6
|
"main": "./dist/index.js",
|
|
10
7
|
"types": "./dist/index.d.ts",
|
|
11
8
|
"exports": {
|
|
12
|
-
".": "./dist/index.js"
|
|
13
|
-
"./parser": "./dist/parser.js",
|
|
14
|
-
"./config": "./dist/config.js",
|
|
15
|
-
"./metrics": "./dist/metrics.js",
|
|
16
|
-
"./context-export": "./dist/context-export.js",
|
|
17
|
-
"./transpiler": "./dist/transpiler.js",
|
|
18
|
-
"./transpiler-web": "./dist/transpiler-web.js",
|
|
19
|
-
"./transpiler-tailwind": "./dist/transpiler-tailwind.js",
|
|
20
|
-
"./transpiler-nextjs": "./dist/transpiler-nextjs.js",
|
|
21
|
-
"./transpiler-express": "./dist/transpiler-express.js",
|
|
22
|
-
"./transpiler-cli": "./dist/transpiler-cli.js",
|
|
23
|
-
"./transpiler-terminal": "./dist/transpiler-terminal.js",
|
|
24
|
-
"./draft-protocol": "./dist/draft-protocol.js"
|
|
9
|
+
".": "./dist/index.js"
|
|
25
10
|
},
|
|
26
11
|
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
"kern.config.ts"
|
|
12
|
+
"dist"
|
|
29
13
|
],
|
|
30
14
|
"keywords": [
|
|
31
15
|
"kern",
|
|
@@ -44,21 +28,18 @@
|
|
|
44
28
|
"url": "git+https://github.com/cukas/KERNlang.git"
|
|
45
29
|
},
|
|
46
30
|
"homepage": "https://github.com/cukas/KERNlang#readme",
|
|
47
|
-
"license": "AGPL-3.0
|
|
48
|
-
"scripts": {
|
|
49
|
-
"build": "tsc",
|
|
50
|
-
"prepublishOnly": "npm run build",
|
|
51
|
-
"test": "node --experimental-vm-modules node_modules/.bin/jest --forceExit",
|
|
52
|
-
"fitness": "npm test"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@types/jest": "^29.5.0",
|
|
56
|
-
"@types/node": "^22.0.0",
|
|
57
|
-
"jest": "^29.7.0",
|
|
58
|
-
"ts-jest": "^29.3.0",
|
|
59
|
-
"typescript": "^5.7.0"
|
|
60
|
-
},
|
|
31
|
+
"license": "AGPL-3.0",
|
|
61
32
|
"dependencies": {
|
|
62
|
-
"
|
|
33
|
+
"@kernlang/protocol": "2.0.0",
|
|
34
|
+
"@kernlang/react": "2.0.0",
|
|
35
|
+
"@kernlang/native": "2.0.0",
|
|
36
|
+
"@kernlang/express": "2.0.0",
|
|
37
|
+
"@kernlang/core": "2.0.0",
|
|
38
|
+
"@kernlang/terminal": "2.0.0",
|
|
39
|
+
"@kernlang/cli": "2.0.0",
|
|
40
|
+
"@kernlang/metrics": "2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -b"
|
|
63
44
|
}
|
|
64
|
-
}
|
|
45
|
+
}
|
package/README.md
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
# Kern
|
|
2
|
-
|
|
3
|
-
**Write one `.kern` file. Ship 7 targets. Save 70% tokens.**
|
|
4
|
-
|
|
5
|
-
Kern is the language LLMs think in. A high-leverage authoring language that transpiles to production stacks you already use — and cuts AI token costs by 70% when used as a communication protocol between competing AI engines.
|
|
6
|
-
|
|
7
|
-
### Why Kern exists
|
|
8
|
-
|
|
9
|
-
LLMs are expensive. Every token costs money. When an AI generates a React component, it outputs 500+ tokens of boilerplate — imports, StyleSheet, JSX, types. When two AIs discuss an implementation, they burn thousands of tokens on verbose natural language.
|
|
10
|
-
|
|
11
|
-
Kern solves both problems:
|
|
12
|
-
|
|
13
|
-
| Use case | Without Kern | With Kern | Savings |
|
|
14
|
-
|---|---|---|---|
|
|
15
|
-
| Generate a dashboard UI | 500+ tokens (React/TS) | 40 tokens (.kern) | **92%** |
|
|
16
|
-
| AI proposes an approach | 800+ tokens (natural language) | 80 tokens (draft block) | **90%** |
|
|
17
|
-
| 3 AIs brainstorm | 2,400+ tokens | 320 tokens | **87%** |
|
|
18
|
-
| Express API with 4 routes | 400+ tokens | 40 tokens | **90%** |
|
|
19
|
-
|
|
20
|
-
**For developers:** Write less, ship to more targets.
|
|
21
|
-
**For AI systems:** Communicate in structured blocks instead of verbose prose.
|
|
22
|
-
**For your wallet:** 70-90% fewer tokens = 70-90% lower API costs.
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
screen name=Dashboard {bg:#F8F9FA}
|
|
26
|
-
row {p:16,jc:sb,ai:center}
|
|
27
|
-
text value=FITVT {fs:24,fw:bold}
|
|
28
|
-
image src=avatar {w:40,h:40,br:20}
|
|
29
|
-
card {p:16,br:12,bg:#FFF,m:16}
|
|
30
|
-
progress label=Calories current=1840 target=2200 color=#FF6B6B
|
|
31
|
-
progress label=Protein current=96 target=140 color=#4ECDC4
|
|
32
|
-
button text="Log Meal" {w:full,br:8,bg:#007AFF,p:16}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
That's 10 lines. Kern turns it into a complete React component with Tailwind classes, source maps, and token efficiency metrics. Or a Next.js page. Or a React Native screen. Or an Express API. Or a CLI. Or a terminal UI. Same source, 7 targets.
|
|
36
|
-
|
|
37
|
-
## Targets
|
|
38
|
-
|
|
39
|
-
| Target | Command | Generates |
|
|
40
|
-
|---|---|---|
|
|
41
|
-
| **Next.js** | `kern file.kern --target=nextjs` | App Router pages with metadata, `next/link`, `next/image` |
|
|
42
|
-
| **Tailwind** | `kern file.kern --target=tailwind` | React + Tailwind CSS with `useState`, `useTranslation` |
|
|
43
|
-
| **Web** | `kern file.kern --target=web` | React with inline CSS styles |
|
|
44
|
-
| **React Native** | `kern file.kern --target=native` | React Native with `StyleSheet.create()` |
|
|
45
|
-
| **Express** | `kern file.kern --target=express` | Typed Express routes with SSE streaming, child process spawn, timeouts |
|
|
46
|
-
| **CLI** | `kern file.kern --target=cli` | Commander.js with typed args, flags, `parseAsync()` |
|
|
47
|
-
| **Terminal** | `kern file.kern --target=terminal` | ANSI terminal UI — tables, spinners, progress bars, gradients |
|
|
48
|
-
|
|
49
|
-
## Install
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install kern-lang
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Global install for CLI usage:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npm install -g kern-lang
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Quick Start
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# Transpile to Next.js
|
|
65
|
-
kern dashboard.kern --target=nextjs
|
|
66
|
-
|
|
67
|
-
# Transpile to Express API
|
|
68
|
-
kern api.kern --target=express
|
|
69
|
-
|
|
70
|
-
# Transpile to CLI app
|
|
71
|
-
kern mycli.kern --target=cli
|
|
72
|
-
|
|
73
|
-
# Transpile to terminal UI
|
|
74
|
-
kern ui.kern --target=terminal
|
|
75
|
-
|
|
76
|
-
# Show language metrics
|
|
77
|
-
kern dashboard.kern --metrics
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Or without global install:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npx kern dashboard.kern --target=nextjs
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Express Backend Example
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
server name=API port=3001
|
|
90
|
-
middleware name=cors
|
|
91
|
-
middleware name=json
|
|
92
|
-
|
|
93
|
-
route method=post path=/api/review
|
|
94
|
-
schema body="{diff: string}"
|
|
95
|
-
stream
|
|
96
|
-
handler <<<
|
|
97
|
-
const results = await analyze(req.body.diff);
|
|
98
|
-
for (const r of results) emit(r);
|
|
99
|
-
>>>
|
|
100
|
-
|
|
101
|
-
route method=get path=/health
|
|
102
|
-
handler <<<
|
|
103
|
-
res.json({ ok: true });
|
|
104
|
-
>>>
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Generates typed Express routes with SSE streaming, `AbortController` lifecycle, heartbeat keep-alive, and schema validation. Multi-file output via `GeneratedArtifact[]`.
|
|
108
|
-
|
|
109
|
-
## CLI Example
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
cli name=mytool version=1.0.0 description="My CLI tool"
|
|
113
|
-
command name=build
|
|
114
|
-
arg name=target type=string required=true
|
|
115
|
-
flag name=watch alias=w type=boolean description="Watch mode"
|
|
116
|
-
flag name=timeout type=number default=30
|
|
117
|
-
import from="./build.js" names=runBuild
|
|
118
|
-
handler <<<
|
|
119
|
-
await runBuild(target, opts);
|
|
120
|
-
>>>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Generates Commander.js with `parseAsync()`, `parseFloat` coercion for number flags, `requiredOption()` for required flags, per-command files.
|
|
124
|
-
|
|
125
|
-
## Terminal UI Example
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
screen name=Dashboard
|
|
129
|
-
gradient text="MY APP" colors=[208,214,220,226,228]
|
|
130
|
-
separator width=48
|
|
131
|
-
scoreboard title="Results" winner="engine-1"
|
|
132
|
-
metric name=Score values=["89","74","71"]
|
|
133
|
-
metric name=Time values=["45s","52s","38s"]
|
|
134
|
-
spinner message="Processing..." color=214
|
|
135
|
-
progress value=75 max=100 color=214
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Generates pure Node.js ANSI escape codes — no dependencies. Tables, spinners, progress bars, gradients, boxes.
|
|
139
|
-
|
|
140
|
-
## Metrics
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
npx kern examples/dashboard.kern --metrics
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
Metrics: examples/dashboard.kern
|
|
148
|
-
Nodes: 23 (10 types)
|
|
149
|
-
Styles: 18 declarations
|
|
150
|
-
Mapped: 18 (100%)
|
|
151
|
-
Escaped: 0 (0%)
|
|
152
|
-
Shorthand: 94% coverage
|
|
153
|
-
Theme refs: 4
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
The metrics engine tells you exactly how much of your design system Kern handles natively vs. needs escape hatches.
|
|
157
|
-
|
|
158
|
-
## Configuration
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
// kern.config.ts
|
|
162
|
-
const config: KernConfig = {
|
|
163
|
-
target: 'nextjs',
|
|
164
|
-
i18n: { enabled: true, hookName: 'useTranslation' },
|
|
165
|
-
components: { uiLibrary: '@components/ui' },
|
|
166
|
-
colors: {
|
|
167
|
-
'#18181b': 'zinc-900',
|
|
168
|
-
'#f97316': 'orange-500',
|
|
169
|
-
// your design system colors
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Config loaded via `jiti` (same as Tailwind CSS, Nuxt). CLI flags override config values.
|
|
175
|
-
|
|
176
|
-
## API
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
import {
|
|
180
|
-
parse,
|
|
181
|
-
transpileTailwind,
|
|
182
|
-
transpileNextjs,
|
|
183
|
-
transpileExpress,
|
|
184
|
-
transpileCliApp,
|
|
185
|
-
transpileTerminal,
|
|
186
|
-
collectLanguageMetrics,
|
|
187
|
-
resolveConfig,
|
|
188
|
-
} from 'kern-lang';
|
|
189
|
-
|
|
190
|
-
const ast = parse(kernSource);
|
|
191
|
-
const result = transpileTailwind(ast, resolveConfig({ colors: myColors }));
|
|
192
|
-
console.log(result.code);
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## How It Was Built
|
|
196
|
-
|
|
197
|
-
Kern was designed by three AI architectures — Claude (Anthropic), Codex (OpenAI), and Gemini (Google) — through competitive forge, brainstorm, and tribunal processes. Each feature was:
|
|
198
|
-
|
|
199
|
-
1. **Brainstormed** — all 3 AIs propose approaches in Kern draft format
|
|
200
|
-
2. **Forged** — all 3 implement independently, scored by automated fitness tests
|
|
201
|
-
3. **Reviewed** — losing AIs critique the winner, bugs are fixed
|
|
202
|
-
|
|
203
|
-
The Express target was forged in a 3-way competition. Codex won with typed generics and schema validation. Claude and Gemini's review caught 5 additional bugs. Every review found real issues — 9 review passes, 9 bugs caught and fixed.
|
|
204
|
-
|
|
205
|
-
94 tests across 6 test suites. Zero type errors. Every commit verified.
|
|
206
|
-
|
|
207
|
-
## Draft Protocol
|
|
208
|
-
|
|
209
|
-
Kern isn't just a transpiler — it's a communication protocol between AI engines. The Draft Protocol lets competing AIs exchange structured proposals:
|
|
210
|
-
|
|
211
|
-
```
|
|
212
|
-
draft {
|
|
213
|
-
approach: "Use middleware chain with JWT validation"
|
|
214
|
-
reasoning: "Standard pattern, battle-tested"
|
|
215
|
-
tradeoffs: "adds latency", "requires secret management"
|
|
216
|
-
confidence: 82
|
|
217
|
-
keyFiles: "src/auth.ts", "src/middleware.ts"
|
|
218
|
-
steps {
|
|
219
|
-
1: "Add jsonwebtoken dependency"
|
|
220
|
-
2: "Create verifyToken middleware"
|
|
221
|
-
3: "Wire into Express app.use()"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
70% fewer tokens than natural language. Structured. Rankable. Engines speak Kern.
|
|
227
|
-
|
|
228
|
-
## Token Savings — The Real Story
|
|
229
|
-
|
|
230
|
-
Kern was born from a real problem: running 3 AI engines in parallel is expensive. Every brainstorm session, every forge competition, every code review burns tokens. At scale, this is the #1 cost driver for multi-AI systems.
|
|
231
|
-
|
|
232
|
-
**Before Kern (natural language):**
|
|
233
|
-
```
|
|
234
|
-
I think we should implement this using a middleware chain pattern with JWT
|
|
235
|
-
validation. The reasoning is that this is a standard, battle-tested approach
|
|
236
|
-
that works well with Express. The main tradeoffs are that it adds latency
|
|
237
|
-
per request and requires proper secret management. I'm about 82% confident
|
|
238
|
-
this is the right approach. The key files we'd need to modify are
|
|
239
|
-
src/auth.ts and src/middleware.ts. Here are the steps: first, add the
|
|
240
|
-
jsonwebtoken dependency, then create a verifyToken middleware function,
|
|
241
|
-
and finally wire it into the Express app.use() chain.
|
|
242
|
-
```
|
|
243
|
-
**~120 tokens**
|
|
244
|
-
|
|
245
|
-
**After Kern (draft block):**
|
|
246
|
-
```
|
|
247
|
-
draft {
|
|
248
|
-
approach: "Use middleware chain with JWT validation"
|
|
249
|
-
reasoning: "Standard pattern, battle-tested"
|
|
250
|
-
tradeoffs: "adds latency", "requires secret management"
|
|
251
|
-
confidence: 82
|
|
252
|
-
keyFiles: "src/auth.ts", "src/middleware.ts"
|
|
253
|
-
steps {
|
|
254
|
-
1: "Add jsonwebtoken dependency"
|
|
255
|
-
2: "Create verifyToken middleware"
|
|
256
|
-
3: "Wire into Express app.use()"
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
**~40 tokens** — same information, structured, parseable, rankable.
|
|
261
|
-
|
|
262
|
-
**Real-world numbers from Agon (competitive AI orchestration):**
|
|
263
|
-
|
|
264
|
-
| Operation | Old (natural language) | New (Kern) | Saved |
|
|
265
|
-
|---|---|---|---|
|
|
266
|
-
| 3-engine brainstorm | 2,400 tokens | 320 tokens | $0.02/call |
|
|
267
|
-
| Forge plan review | 1,600 tokens | 240 tokens | $0.01/call |
|
|
268
|
-
| Context injection | 800 tokens | 200 tokens | $0.005/call |
|
|
269
|
-
| **Daily (50 operations)** | **~240K tokens** | **~38K tokens** | **~$2/day** |
|
|
270
|
-
| **Monthly** | **~7.2M tokens** | **~1.1M tokens** | **~$60/month** |
|
|
271
|
-
|
|
272
|
-
For a solo dev running multi-AI tools, that's the difference between affordable and not. For a company running thousands of operations, it's the difference between viable and bankrupt.
|
|
273
|
-
|
|
274
|
-
Kern isn't just a language. It's a compression algorithm for AI communication.
|
|
275
|
-
|
|
276
|
-
## License
|
|
277
|
-
|
|
278
|
-
**AGPL-3.0-or-later** — You are free to use, modify, and distribute Kern under the terms of the [GNU Affero General Public License v3.0](LICENSE). This means:
|
|
279
|
-
|
|
280
|
-
- If you modify Kern or build software that incorporates it, and you distribute that software or make it available over a network, you must release your source code under the same AGPL-3.0 terms.
|
|
281
|
-
- This applies equally to individuals, companies, and organizations.
|
|
282
|
-
|
|
283
|
-
**Commercial license:** If you want to use Kern in proprietary/closed-source software without the AGPL's source-sharing requirements, a commercial license is available. Contact [cukas](https://github.com/cukas) for details.
|
|
284
|
-
|
|
285
|
-
**In practice:** Solo developers, students, and open-source projects can use Kern freely. Companies building closed-source products need a commercial license — or they can open-source their code.
|
|
286
|
-
|
|
287
|
-
See [LICENSE](LICENSE) for the full text.
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## Contributors
|
|
292
|
-
|
|
293
|
-
| Role | Who |
|
|
294
|
-
|---|---|
|
|
295
|
-
| **Creator & Director** | [cukas](https://github.com/cukas) |
|
|
296
|
-
| **Co-Architect** | Claude (Anthropic) — Opus 4.6 |
|
|
297
|
-
| **Co-Architect** | Codex (OpenAI) — GPT-5.4 |
|
|
298
|
-
| **Co-Architect** | Gemini (Google) |
|
|
299
|
-
|
|
300
|
-
Every feature was brainstormed by all 3 AIs, forged competitively, and cross-reviewed. 9 review passes, 9 bugs caught. The Express target was won by Codex in a 3-way forge. Engines speak Kern.
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
**Swiss-engineered. AI-designed. Human-directed.**
|
package/dist/cli.d.ts
DELETED