@ultrst-armada/krnl 1.0.0 → 1.0.2
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/README.md +35 -24
- package/package.json +12 -12
- package/packages/cli/dist/bin/krnl.cjs +1026 -9462
- package/packages/cli/dist/bin/krnl.js +14 -1859
- package/packages/cli/dist/chunk-ESTKOQ7T.js +1146 -0
- package/packages/cli/dist/chunk-FZ6X7PHR.js +1146 -0
- package/packages/cli/dist/index.cjs +735 -7348
- package/packages/cli/dist/index.js +1 -20
- package/packages/cli/package.json +2 -2
- package/packages/core/dist/index.cjs +140 -5
- package/packages/core/dist/index.d.cts +24 -2
- package/packages/core/dist/index.d.ts +24 -2
- package/packages/core/dist/index.js +137 -3
- package/packages/core/package.json +2 -2
- package/packages/create-krnl/dist/index.cjs +277 -308
- package/packages/create-krnl/dist/index.js +277 -308
- package/packages/create-krnl/package.json +2 -2
- package/packages/eslint-plugin/package.json +2 -2
- package/packages/validate/dist/index.cjs +407 -369
- package/packages/validate/dist/index.d.cts +1 -13
- package/packages/validate/dist/index.d.ts +1 -13
- package/packages/validate/dist/index.js +408 -370
- package/packages/validate/package.json +2 -2
|
@@ -24,94 +24,79 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var fs3 = __toESM(require("fs"), 1);
|
|
28
|
+
var path3 = __toESM(require("path"), 1);
|
|
29
29
|
var import_krnl_core = require("@dinilmusick/krnl-core");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
|
|
31
|
+
// src/templates/configTemplates.ts
|
|
32
|
+
function getBasePackageJson(projectName2) {
|
|
33
|
+
return JSON.stringify(
|
|
34
|
+
{
|
|
35
|
+
name: projectName2,
|
|
36
|
+
version: "1.0.0",
|
|
37
|
+
description: "Full-stack application powered by Krnl symmetric architecture",
|
|
38
|
+
type: "module",
|
|
39
|
+
main: "dist/index.js",
|
|
40
|
+
scripts: {
|
|
41
|
+
dev: "krnl dev",
|
|
42
|
+
build: "krnl build",
|
|
43
|
+
validate: "krnl validate",
|
|
44
|
+
test: "vitest run",
|
|
45
|
+
sync: "krnl sync"
|
|
46
|
+
},
|
|
47
|
+
dependencies: {
|
|
48
|
+
"@dinilmusick/krnl": "^1.0.0",
|
|
49
|
+
"@dinilmusick/krnl-core": "^1.0.0",
|
|
50
|
+
"@dinilmusick/krnl-ui": "^1.0.0"
|
|
51
|
+
},
|
|
52
|
+
devDependencies: {
|
|
53
|
+
"@dinilmusick/krnl-cli": "^1.0.0",
|
|
54
|
+
"@dinilmusick/krnl-validate": "^1.0.0",
|
|
55
|
+
"@dinilmusick/eslint-plugin-krnl": "^1.0.0",
|
|
56
|
+
typescript: "^5.7.3",
|
|
57
|
+
vitest: "^1.6.0"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
null,
|
|
61
|
+
2
|
|
62
|
+
);
|
|
39
63
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
scripts: {
|
|
67
|
-
dev: "krnl dev",
|
|
68
|
-
build: "krnl build",
|
|
69
|
-
validate: "krnl validate",
|
|
70
|
-
test: "vitest run",
|
|
71
|
-
sync: "krnl sync"
|
|
72
|
-
},
|
|
73
|
-
dependencies: {
|
|
74
|
-
"@dinilmusick/krnl": "^1.0.0",
|
|
75
|
-
"@dinilmusick/krnl-core": "^1.0.0",
|
|
76
|
-
"@dinilmusick/krnl-ui": "^1.0.0"
|
|
77
|
-
},
|
|
78
|
-
devDependencies: {
|
|
79
|
-
"@dinilmusick/krnl-cli": "^1.0.0",
|
|
80
|
-
"@dinilmusick/krnl-validate": "^1.0.0",
|
|
81
|
-
"@dinilmusick/eslint-plugin-krnl": "^1.0.0",
|
|
82
|
-
"typescript": "^5.7.3",
|
|
83
|
-
"vitest": "^1.6.0"
|
|
84
|
-
}
|
|
85
|
-
}, null, 2));
|
|
86
|
-
fs.writeFileSync(path.join(targetDir, "tsconfig.json"), JSON.stringify({
|
|
87
|
-
compilerOptions: {
|
|
88
|
-
target: "ESNext",
|
|
89
|
-
module: "NodeNext",
|
|
90
|
-
moduleResolution: "NodeNext",
|
|
91
|
-
lib: ["ESNext", "DOM"],
|
|
92
|
-
jsx: "react-jsx",
|
|
93
|
-
strict: true,
|
|
94
|
-
outDir: "./dist",
|
|
95
|
-
skipLibCheck: true,
|
|
96
|
-
resolveJsonModule: true,
|
|
97
|
-
paths: {
|
|
98
|
-
"@/*": ["./krnl/*"]
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
include: ["krnl/**/*", `${projectName}.ts`, "krnl-magnetic.d.ts"],
|
|
102
|
-
exclude: ["node_modules", "dist"]
|
|
103
|
-
}, null, 2));
|
|
104
|
-
fs.writeFileSync(path.join(targetDir, `${projectName}.ts`), `import { defineApp, Protocols } from "@dinilmusick/krnl-core";
|
|
64
|
+
function getTsConfig(projectName2) {
|
|
65
|
+
return JSON.stringify(
|
|
66
|
+
{
|
|
67
|
+
compilerOptions: {
|
|
68
|
+
target: "ESNext",
|
|
69
|
+
module: "NodeNext",
|
|
70
|
+
moduleResolution: "NodeNext",
|
|
71
|
+
lib: ["ESNext", "DOM"],
|
|
72
|
+
jsx: "react-jsx",
|
|
73
|
+
strict: true,
|
|
74
|
+
outDir: "./dist",
|
|
75
|
+
skipLibCheck: true,
|
|
76
|
+
resolveJsonModule: true,
|
|
77
|
+
paths: {
|
|
78
|
+
"@/*": ["./krnl/*"]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
include: ["krnl/**/*", `${projectName2}.ts`, "krnl-magnetic.d.ts"],
|
|
82
|
+
exclude: ["node_modules", "dist"]
|
|
83
|
+
},
|
|
84
|
+
null,
|
|
85
|
+
2
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function getAppEntrypoint(projectName2) {
|
|
89
|
+
return `import { defineApp, Protocols } from "@dinilmusick/krnl-core";
|
|
105
90
|
import { App } from "./krnl/backend/entities/App/App.js";
|
|
106
91
|
|
|
107
92
|
export default defineApp({
|
|
108
|
-
name: "${
|
|
93
|
+
name: "${projectName2}",
|
|
109
94
|
version: "1.0.0",
|
|
110
|
-
description: "${
|
|
95
|
+
description: "${projectName2} application entrypoint",
|
|
111
96
|
protocols: [
|
|
112
97
|
Protocols.HTTP({ port: 8080, prefix: "/api" }),
|
|
113
98
|
Protocols.WebSocket({ port: 8081 }),
|
|
114
|
-
Protocols.MCP({ name: "${
|
|
99
|
+
Protocols.MCP({ name: "${projectName2}-agent-tools" })
|
|
115
100
|
],
|
|
116
101
|
entities: [
|
|
117
102
|
App
|
|
@@ -121,199 +106,170 @@ export default defineApp({
|
|
|
121
106
|
variant: 0
|
|
122
107
|
}
|
|
123
108
|
});
|
|
124
|
-
|
|
125
|
-
fs.writeFileSync(path.join(bLibDir, "definitions.ts"), `/**
|
|
126
|
-
* @file definitions.ts
|
|
127
|
-
* @role component
|
|
128
|
-
* @description Types, interfaces, and contracts for AppConcepts.
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
export interface AppTransformOptions {
|
|
132
|
-
normalize?: boolean;
|
|
109
|
+
`;
|
|
133
110
|
}
|
|
134
|
-
`);
|
|
135
|
-
fs.writeFileSync(path.join(bLibDir, "functions.ts"), `/**
|
|
136
|
-
* @file functions.ts
|
|
137
|
-
* @role component
|
|
138
|
-
* @description Pure functions (Layer 0A) for AppConcepts.
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
import type { AppTransformOptions } from "./definitions.js";
|
|
142
111
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
fs.
|
|
112
|
+
// src/templates/backendTemplates.ts
|
|
113
|
+
var fs = __toESM(require("fs"), 1);
|
|
114
|
+
var path = __toESM(require("path"), 1);
|
|
115
|
+
function scaffoldBackend(targetDir2) {
|
|
116
|
+
const bLibDir = path.join(targetDir2, "krnl", "backend", "libraries", "AppConcepts");
|
|
117
|
+
const bEntityDir = path.join(targetDir2, "krnl", "backend", "entities", "App");
|
|
118
|
+
const bFuncDir = path.join(targetDir2, "krnl", "backend", "functionalities", "Hello");
|
|
119
|
+
fs.mkdirSync(path.join(bLibDir, "tests"), { recursive: true });
|
|
120
|
+
fs.mkdirSync(path.join(bEntityDir, "orchestrations"), { recursive: true });
|
|
121
|
+
fs.mkdirSync(path.join(bEntityDir, "tests"), { recursive: true });
|
|
122
|
+
fs.mkdirSync(path.join(bFuncDir, "main_function"), { recursive: true });
|
|
123
|
+
fs.mkdirSync(path.join(bFuncDir, "state_data"), { recursive: true });
|
|
124
|
+
fs.mkdirSync(path.join(bFuncDir, "helper_functions"), { recursive: true });
|
|
125
|
+
fs.mkdirSync(path.join(bFuncDir, "events"), { recursive: true });
|
|
126
|
+
fs.mkdirSync(path.join(bFuncDir, "tests"), { recursive: true });
|
|
127
|
+
fs.writeFileSync(
|
|
128
|
+
path.join(bLibDir, "definitions.ts"),
|
|
129
|
+
`export interface AppTransformOptions { normalize?: boolean; }
|
|
130
|
+
`
|
|
131
|
+
);
|
|
132
|
+
fs.writeFileSync(
|
|
133
|
+
path.join(bLibDir, "functions.ts"),
|
|
134
|
+
`import type { AppTransformOptions } from "./definitions.js";
|
|
135
|
+
export function pureTransform<T>(data: T, _options?: AppTransformOptions): T { return data; }
|
|
136
|
+
`
|
|
137
|
+
);
|
|
138
|
+
fs.writeFileSync(
|
|
139
|
+
path.join(bLibDir, "manifest.json"),
|
|
140
|
+
JSON.stringify({ name: "AppConcepts", description: "Core utility concept library for App", dependencies: {} }, null, 2)
|
|
141
|
+
);
|
|
142
|
+
fs.writeFileSync(
|
|
143
|
+
path.join(bLibDir, "tests", "AppConcepts.test.ts"),
|
|
144
|
+
`import { describe, it, expect } from "vitest";
|
|
153
145
|
import { pureTransform } from "../functions.js";
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
`);
|
|
161
|
-
fs.writeFileSync(path.join(bEntityDir, "App.ts"), `import { Entity, KrnlMagneticLoader } from "@dinilmusick/krnl-core";
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @role skeleton
|
|
165
|
-
*/
|
|
146
|
+
describe("AppConcepts", () => { it("transforms data", () => { expect(pureTransform(42)).toBe(42); }); });
|
|
147
|
+
`
|
|
148
|
+
);
|
|
149
|
+
fs.writeFileSync(
|
|
150
|
+
path.join(bEntityDir, "App.ts"),
|
|
151
|
+
`import { Entity, KrnlMagneticLoader } from "@dinilmusick/krnl-core";
|
|
166
152
|
export class App extends Entity {
|
|
167
|
-
constructor() {
|
|
168
|
-
|
|
169
|
-
id: "App",
|
|
170
|
-
version: "1.0.0",
|
|
171
|
-
description: "Root application entity"
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async boot(): Promise<void> {
|
|
176
|
-
await KrnlMagneticLoader.loadAll(this, import.meta.url);
|
|
177
|
-
}
|
|
153
|
+
constructor() { super({ id: "App", version: "1.0.0", description: "Root application entity" }); }
|
|
154
|
+
async boot(): Promise<void> { await KrnlMagneticLoader.loadAll(this, import.meta.url); }
|
|
178
155
|
}
|
|
179
|
-
|
|
180
156
|
export default App;
|
|
181
|
-
`
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
.register({ visibility: "public" });
|
|
157
|
+
`
|
|
158
|
+
);
|
|
159
|
+
fs.writeFileSync(
|
|
160
|
+
path.join(bEntityDir, "orchestrations", "BootFlow.ts"),
|
|
161
|
+
`export function configureBootFlow(entity: any) {
|
|
162
|
+
return entity.flow("bootSequence").thenFunctionality("Hello").register({ visibility: "public" });
|
|
188
163
|
}
|
|
189
|
-
`
|
|
190
|
-
|
|
164
|
+
`
|
|
165
|
+
);
|
|
166
|
+
fs.writeFileSync(
|
|
167
|
+
path.join(bEntityDir, "tests", "App.test.ts"),
|
|
168
|
+
`import { describe, it, expect } from "vitest";
|
|
191
169
|
import { App } from "../App.js";
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
`
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
`);
|
|
209
|
-
fs.writeFileSync(path.join(bFuncDir, "manifest.json"), JSON.stringify({
|
|
210
|
-
name: "Hello",
|
|
211
|
-
description: "Greeting quad-unit functionality",
|
|
212
|
-
dependencies: {}
|
|
213
|
-
}, null, 2));
|
|
214
|
-
fs.writeFileSync(path.join(bFuncDir, "main_function", "logic.ts"), `import type { HelloInput, HelloOutput } from "../HelloAtom.js";
|
|
170
|
+
describe("App Entity", () => { it("initializes with id App", () => { expect(new App().id).toBe("App"); }); });
|
|
171
|
+
`
|
|
172
|
+
);
|
|
173
|
+
fs.writeFileSync(
|
|
174
|
+
path.join(bFuncDir, "HelloAtom.ts"),
|
|
175
|
+
`export interface HelloInput { name?: string; }
|
|
176
|
+
export interface HelloOutput { greeting: string; timestamp: number; }
|
|
177
|
+
`
|
|
178
|
+
);
|
|
179
|
+
fs.writeFileSync(
|
|
180
|
+
path.join(bFuncDir, "manifest.json"),
|
|
181
|
+
JSON.stringify({ name: "Hello", description: "Greeting quad-unit functionality", dependencies: {} }, null, 2)
|
|
182
|
+
);
|
|
183
|
+
fs.writeFileSync(
|
|
184
|
+
path.join(bFuncDir, "main_function", "logic.ts"),
|
|
185
|
+
`import type { HelloInput, HelloOutput } from "../HelloAtom.js";
|
|
215
186
|
import { formatGreeting } from "../helper_functions/formatGreeting.js";
|
|
216
|
-
|
|
217
187
|
export const main = async (input: HelloInput, { state }: any): Promise<HelloOutput> => {
|
|
218
188
|
const greeting = formatGreeting(input.name || "World");
|
|
219
189
|
if (state) state.callCount = (state.callCount || 0) + 1;
|
|
220
|
-
return {
|
|
221
|
-
greeting,
|
|
222
|
-
timestamp: Date.now()
|
|
223
|
-
};
|
|
190
|
+
return { greeting, timestamp: Date.now() };
|
|
224
191
|
};
|
|
225
|
-
`
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
export async function onTeardown() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
`);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
fs.writeFileSync(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
export interface HelloGreetedEvent {
|
|
253
|
-
name: string;
|
|
254
|
-
timestamp: number;
|
|
255
|
-
}
|
|
256
|
-
`);
|
|
257
|
-
fs.writeFileSync(path.join(bFuncDir, "tests", "Hello.test.ts"), `import { describe, it, expect } from "vitest";
|
|
192
|
+
`
|
|
193
|
+
);
|
|
194
|
+
fs.writeFileSync(
|
|
195
|
+
path.join(bFuncDir, "main_function", "lifecycle.ts"),
|
|
196
|
+
`export async function onMount() {}
|
|
197
|
+
export async function onTeardown() {}
|
|
198
|
+
`
|
|
199
|
+
);
|
|
200
|
+
fs.writeFileSync(
|
|
201
|
+
path.join(bFuncDir, "state_data", "state.ts"),
|
|
202
|
+
`export interface HelloState { callCount: number; }
|
|
203
|
+
export const initialState: HelloState = { callCount: 0 };
|
|
204
|
+
`
|
|
205
|
+
);
|
|
206
|
+
fs.writeFileSync(
|
|
207
|
+
path.join(bFuncDir, "helper_functions", "formatGreeting.ts"),
|
|
208
|
+
`export function formatGreeting(name: string): string { return "Hello, " + name + "! Welcome to Krnl."; }
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
fs.writeFileSync(
|
|
212
|
+
path.join(bFuncDir, "events", "helloEvents.ts"),
|
|
213
|
+
`export interface HelloGreetedEvent { name: string; timestamp: number; }
|
|
214
|
+
`
|
|
215
|
+
);
|
|
216
|
+
fs.writeFileSync(
|
|
217
|
+
path.join(bFuncDir, "tests", "Hello.test.ts"),
|
|
218
|
+
`import { describe, it, expect } from "vitest";
|
|
258
219
|
import { formatGreeting } from "../helper_functions/formatGreeting.js";
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
expect(formatGreeting("Alice")).toContain("Alice");
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
`);
|
|
266
|
-
fs.writeFileSync(path.join(fLibDir, "definitions.ts"), `export type ButtonVariant = "primary" | "secondary" | "danger" | "ghost";
|
|
267
|
-
|
|
268
|
-
export interface ButtonProps {
|
|
269
|
-
label: string;
|
|
270
|
-
variant?: ButtonVariant;
|
|
271
|
-
disabled?: boolean;
|
|
272
|
-
onClick?: () => void;
|
|
220
|
+
describe("Hello functionality", () => { it("formats greeting", () => { expect(formatGreeting("Alice")).toContain("Alice"); }); });
|
|
221
|
+
`
|
|
222
|
+
);
|
|
273
223
|
}
|
|
274
|
-
|
|
275
|
-
|
|
224
|
+
|
|
225
|
+
// src/templates/frontendTemplates.ts
|
|
226
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
227
|
+
var path2 = __toESM(require("path"), 1);
|
|
228
|
+
function scaffoldFrontend(targetDir2, projectName2) {
|
|
229
|
+
const fLibDir = path2.join(targetDir2, "krnl", "frontend", "libraries", "ButtonConcepts");
|
|
230
|
+
const fEntityDir = path2.join(targetDir2, "krnl", "frontend", "entities", "App");
|
|
231
|
+
const fFuncDir = path2.join(targetDir2, "krnl", "frontend", "functionalities", "Hello");
|
|
232
|
+
fs2.mkdirSync(path2.join(fLibDir, "tests"), { recursive: true });
|
|
233
|
+
fs2.mkdirSync(path2.join(fEntityDir, "tests"), { recursive: true });
|
|
234
|
+
fs2.mkdirSync(path2.join(fFuncDir, "tests"), { recursive: true });
|
|
235
|
+
fs2.mkdirSync(path2.join(targetDir2, "docs"), { recursive: true });
|
|
236
|
+
fs2.mkdirSync(path2.join(targetDir2, ".skipo"), { recursive: true });
|
|
237
|
+
fs2.writeFileSync(
|
|
238
|
+
path2.join(fLibDir, "definitions.ts"),
|
|
239
|
+
`export type ButtonVariant = "primary" | "secondary";
|
|
240
|
+
export interface ButtonProps { label: string; variant?: ButtonVariant; disabled?: boolean; onClick?: () => void; }
|
|
241
|
+
`
|
|
242
|
+
);
|
|
243
|
+
fs2.writeFileSync(
|
|
244
|
+
path2.join(fLibDir, "components.tsx"),
|
|
245
|
+
`import React from "react";
|
|
276
246
|
import type { ButtonProps } from "./definitions.js";
|
|
277
247
|
import "./styles.css";
|
|
278
|
-
|
|
279
248
|
export const Button: React.FC<ButtonProps> = ({ label, variant = "primary", disabled, onClick }) => {
|
|
280
|
-
return
|
|
281
|
-
<button className={"krnl-btn krnl-btn--" + variant} disabled={disabled} onClick={onClick}>
|
|
282
|
-
{label}
|
|
283
|
-
</button>
|
|
284
|
-
);
|
|
249
|
+
return <button className={"krnl-btn krnl-btn--" + variant} disabled={disabled} onClick={onClick}>{label}</button>;
|
|
285
250
|
};
|
|
286
|
-
`
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
describe("Button component", () => {
|
|
309
|
-
it("defined correctly", () => {
|
|
310
|
-
expect(true).toBe(true);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
`);
|
|
314
|
-
fs.writeFileSync(path.join(fEntityDir, "App0.tsx"), `import React from "react";
|
|
251
|
+
`
|
|
252
|
+
);
|
|
253
|
+
fs2.writeFileSync(
|
|
254
|
+
path2.join(fLibDir, "styles.css"),
|
|
255
|
+
`.krnl-btn { padding: 8px 16px; border-radius: 4px; font-weight: 600; cursor: pointer; }
|
|
256
|
+
.krnl-btn--primary { background: #38bdf8; color: #0f172a; }
|
|
257
|
+
`
|
|
258
|
+
);
|
|
259
|
+
fs2.writeFileSync(
|
|
260
|
+
path2.join(fLibDir, "manifest.json"),
|
|
261
|
+
JSON.stringify({ name: "ButtonConcepts", dependencies: { react: "^18.3.1" } }, null, 2)
|
|
262
|
+
);
|
|
263
|
+
fs2.writeFileSync(
|
|
264
|
+
path2.join(fLibDir, "tests", "Button.test.tsx"),
|
|
265
|
+
`import { describe, it, expect } from "vitest";
|
|
266
|
+
describe("Button component", () => { it("defined correctly", () => { expect(true).toBe(true); }); });
|
|
267
|
+
`
|
|
268
|
+
);
|
|
269
|
+
fs2.writeFileSync(
|
|
270
|
+
path2.join(fEntityDir, "App0.tsx"),
|
|
271
|
+
`import React from "react";
|
|
315
272
|
import { Button } from "../../libraries/ButtonConcepts/components.js";
|
|
316
|
-
|
|
317
273
|
export const App0: React.FC = () => {
|
|
318
274
|
return (
|
|
319
275
|
<div className="krnl-entity-app">
|
|
@@ -322,69 +278,82 @@ export const App0: React.FC = () => {
|
|
|
322
278
|
</div>
|
|
323
279
|
);
|
|
324
280
|
};
|
|
325
|
-
|
|
326
281
|
export default App0;
|
|
327
|
-
`
|
|
328
|
-
fs.writeFileSync(path.join(fEntityDir, "tests", "App0.test.tsx"), `import { describe, it, expect } from "vitest";
|
|
329
|
-
|
|
330
|
-
describe("App0 Component", () => {
|
|
331
|
-
it("mounts variant 0", () => {
|
|
332
|
-
expect(true).toBe(true);
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
`);
|
|
336
|
-
fs.writeFileSync(path.join(fFuncDir, "Hello0.tsx"), `import React from "react";
|
|
337
|
-
|
|
338
|
-
export interface HelloProps {
|
|
339
|
-
greeting?: string;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
export const Hello0: React.FC<HelloProps> = ({ greeting = "Hello World!" }) => {
|
|
343
|
-
return (
|
|
344
|
-
<div className="krnl-func-hello">
|
|
345
|
-
<p>{greeting}</p>
|
|
346
|
-
</div>
|
|
282
|
+
`
|
|
347
283
|
);
|
|
284
|
+
fs2.writeFileSync(
|
|
285
|
+
path2.join(fEntityDir, "tests", "App0.test.tsx"),
|
|
286
|
+
`import { describe, it, expect } from "vitest";
|
|
287
|
+
describe("App0 Component", () => { it("mounts variant 0", () => { expect(true).toBe(true); }); });
|
|
288
|
+
`
|
|
289
|
+
);
|
|
290
|
+
fs2.writeFileSync(
|
|
291
|
+
path2.join(fFuncDir, "Hello0.tsx"),
|
|
292
|
+
`import React from "react";
|
|
293
|
+
export interface HelloProps { greeting?: string; }
|
|
294
|
+
export const Hello0: React.FC<HelloProps> = ({ greeting = "Hello World!" }) => {
|
|
295
|
+
return <div className="krnl-func-hello"><p>{greeting}</p></div>;
|
|
348
296
|
};
|
|
349
|
-
|
|
350
297
|
export default Hello0;
|
|
351
|
-
`
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
"
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
298
|
+
`
|
|
299
|
+
);
|
|
300
|
+
fs2.writeFileSync(
|
|
301
|
+
path2.join(fFuncDir, "manifest.json"),
|
|
302
|
+
JSON.stringify({ name: "HelloUI", dependencies: { react: "^18.3.1" } }, null, 2)
|
|
303
|
+
);
|
|
304
|
+
fs2.writeFileSync(
|
|
305
|
+
path2.join(fFuncDir, "tests", "Hello0.test.tsx"),
|
|
306
|
+
`import { describe, it, expect } from "vitest";
|
|
307
|
+
describe("Hello0 Component", () => { it("renders correctly", () => { expect(true).toBe(true); }); });
|
|
308
|
+
`
|
|
309
|
+
);
|
|
310
|
+
fs2.writeFileSync(
|
|
311
|
+
path2.join(targetDir2, "docs", "HISTORY.md"),
|
|
312
|
+
`# ${projectName2} - Project History
|
|
359
313
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
314
|
+
Initialized Krnl symmetric architecture.
|
|
315
|
+
`
|
|
316
|
+
);
|
|
317
|
+
fs2.writeFileSync(
|
|
318
|
+
path2.join(targetDir2, ".skipo", "agent-state.json"),
|
|
319
|
+
JSON.stringify(
|
|
320
|
+
{
|
|
321
|
+
schemaVersion: "1.0.0",
|
|
322
|
+
turnsSinceLastAudit: 0,
|
|
323
|
+
auditCadenceThreshold: 5,
|
|
324
|
+
totalTurns: 0,
|
|
325
|
+
lastAudit: {
|
|
326
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
327
|
+
status: "INITIALIZED",
|
|
328
|
+
refactorsPerformed: [],
|
|
329
|
+
checksPassed: ["symmetric_planes", "concept_folders", "manifest_reconciliation"]
|
|
330
|
+
},
|
|
331
|
+
history: []
|
|
332
|
+
},
|
|
333
|
+
null,
|
|
334
|
+
2
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
368
338
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
339
|
+
// src/index.ts
|
|
340
|
+
var rawArg = process.argv[2] || "my-krnl-app";
|
|
341
|
+
var targetDir = path3.resolve(process.cwd(), rawArg);
|
|
342
|
+
var projectName = path3.basename(targetDir);
|
|
343
|
+
console.log(`
|
|
344
|
+
\u{1F680} [create-krnl] Scaffolding new Krnl project in: ${targetDir}
|
|
374
345
|
`);
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
history: []
|
|
387
|
-
}, null, 2));
|
|
346
|
+
if (fs3.existsSync(targetDir)) {
|
|
347
|
+
console.error(`\u274C Directory "${projectName}" already exists.`);
|
|
348
|
+
process.exit(1);
|
|
349
|
+
}
|
|
350
|
+
fs3.mkdirSync(targetDir, { recursive: true });
|
|
351
|
+
fs3.writeFileSync(path3.join(targetDir, "package.json"), getBasePackageJson(projectName));
|
|
352
|
+
fs3.writeFileSync(path3.join(targetDir, "tsconfig.json"), getTsConfig(projectName));
|
|
353
|
+
fs3.writeFileSync(path3.join(targetDir, `${projectName}.ts`), getAppEntrypoint(projectName));
|
|
354
|
+
scaffoldBackend(targetDir);
|
|
355
|
+
scaffoldFrontend(targetDir, projectName);
|
|
356
|
+
import_krnl_core.KrnlPackageReconciler.reconcile(targetDir, true);
|
|
388
357
|
console.log(`
|
|
389
358
|
\u{1F389} Project successfully scaffolded at: ${targetDir}`);
|
|
390
359
|
console.log(`
|