@ultrst-armada/krnl 1.0.17 → 1.0.19

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.
@@ -1,13 +1,15 @@
1
1
  // ../validate/dist/index.js
2
2
  import * as fs2 from "fs";
3
- import * as path3 from "path";
3
+ import * as path4 from "path";
4
4
  import { Project } from "ts-morph";
5
5
  import * as path from "path";
6
6
  import { SyntaxKind } from "ts-morph";
7
7
  import { SyntaxKind as SyntaxKind2, Node } from "ts-morph";
8
8
  import * as fs from "fs";
9
+ import * as path3 from "path";
9
10
  import * as path2 from "path";
10
11
  import { SyntaxKind as SyntaxKind3 } from "ts-morph";
12
+ import { SyntaxKind as SyntaxKind5 } from "ts-morph";
11
13
  import { SyntaxKind as SyntaxKind4 } from "ts-morph";
12
14
  function checkFileLimits(sf, options) {
13
15
  const errors = [];
@@ -335,24 +337,24 @@ function checkTopLevelPurity(sf) {
335
337
  return { errors, warnings };
336
338
  }
337
339
  function checkWorkspaceLayout(projectRoot, errors) {
338
- const krnlDir = path2.join(projectRoot, "krnl");
339
- const srcDir = path2.join(projectRoot, "src");
340
+ const krnlDir = path3.join(projectRoot, "krnl");
341
+ const srcDir = path3.join(projectRoot, "src");
340
342
  const targetDir = fs.existsSync(krnlDir) ? krnlDir : fs.existsSync(srcDir) ? srcDir : null;
341
343
  if (!targetDir) return;
342
- const backendDir = path2.join(targetDir, "backend");
343
- const frontendDir = path2.join(targetDir, "frontend");
344
+ const backendDir = path3.join(targetDir, "backend");
345
+ const frontendDir = path3.join(targetDir, "frontend");
344
346
  if (fs.existsSync(backendDir)) {
345
- const bServices = path2.join(backendDir, "services");
347
+ const bServices = path3.join(backendDir, "services");
346
348
  if (fs.existsSync(bServices)) {
347
349
  for (const sEntry of fs.readdirSync(bServices, { withFileTypes: true })) {
348
350
  if (!sEntry.isDirectory()) continue;
349
- const sDir = path2.join(bServices, sEntry.name);
350
- const sLibs = path2.join(sDir, "libraries");
351
+ const sDir = path3.join(bServices, sEntry.name);
352
+ const sLibs = path3.join(sDir, "libraries");
351
353
  if (fs.existsSync(sLibs)) {
352
354
  for (const entry of fs.readdirSync(sLibs, { withFileTypes: true })) {
353
355
  if (!entry.isDirectory()) continue;
354
- const libPath = path2.join(sLibs, entry.name);
355
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
356
+ const libPath = path3.join(sLibs, entry.name);
357
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
356
358
  errors.push({
357
359
  ruleId: "krnl/concept-manifest-required",
358
360
  filePath: libPath,
@@ -362,12 +364,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
362
364
  }
363
365
  }
364
366
  }
365
- const sFuncs = path2.join(sDir, "functionalities");
367
+ const sFuncs = path3.join(sDir, "functionalities");
366
368
  if (fs.existsSync(sFuncs)) {
367
369
  for (const entry of fs.readdirSync(sFuncs, { withFileTypes: true })) {
368
370
  if (!entry.isDirectory()) continue;
369
- const funcPath = path2.join(sFuncs, entry.name);
370
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
371
+ const funcPath = path3.join(sFuncs, entry.name);
372
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
371
373
  errors.push({
372
374
  ruleId: "krnl/functionality-manifest-required",
373
375
  filePath: funcPath,
@@ -379,12 +381,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
379
381
  }
380
382
  }
381
383
  }
382
- const bLibs = path2.join(backendDir, "libraries");
384
+ const bLibs = path3.join(backendDir, "libraries");
383
385
  if (fs.existsSync(bLibs)) {
384
386
  for (const entry of fs.readdirSync(bLibs, { withFileTypes: true })) {
385
387
  if (!entry.isDirectory()) continue;
386
- const libPath = path2.join(bLibs, entry.name);
387
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
388
+ const libPath = path3.join(bLibs, entry.name);
389
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
388
390
  errors.push({
389
391
  ruleId: "krnl/concept-manifest-required",
390
392
  filePath: libPath,
@@ -394,12 +396,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
394
396
  }
395
397
  }
396
398
  }
397
- const bFuncs = path2.join(backendDir, "functionalities");
399
+ const bFuncs = path3.join(backendDir, "functionalities");
398
400
  if (fs.existsSync(bFuncs)) {
399
401
  for (const entry of fs.readdirSync(bFuncs, { withFileTypes: true })) {
400
402
  if (!entry.isDirectory()) continue;
401
- const funcPath = path2.join(bFuncs, entry.name);
402
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
403
+ const funcPath = path3.join(bFuncs, entry.name);
404
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
403
405
  errors.push({
404
406
  ruleId: "krnl/functionality-manifest-required",
405
407
  filePath: funcPath,
@@ -411,12 +413,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
411
413
  }
412
414
  }
413
415
  if (fs.existsSync(frontendDir)) {
414
- const fLibs = path2.join(frontendDir, "libraries");
416
+ const fLibs = path3.join(frontendDir, "libraries");
415
417
  if (fs.existsSync(fLibs)) {
416
418
  for (const entry of fs.readdirSync(fLibs, { withFileTypes: true })) {
417
419
  if (!entry.isDirectory()) continue;
418
- const libPath = path2.join(fLibs, entry.name);
419
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
420
+ const libPath = path3.join(fLibs, entry.name);
421
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
420
422
  errors.push({
421
423
  ruleId: "krnl/frontend-concept-manifest-required",
422
424
  filePath: libPath,
@@ -426,12 +428,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
426
428
  }
427
429
  }
428
430
  }
429
- const fFuncs = path2.join(frontendDir, "functionalities");
431
+ const fFuncs = path3.join(frontendDir, "functionalities");
430
432
  if (fs.existsSync(fFuncs)) {
431
433
  for (const entry of fs.readdirSync(fFuncs, { withFileTypes: true })) {
432
434
  if (!entry.isDirectory()) continue;
433
- const funcPath = path2.join(fFuncs, entry.name);
434
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
435
+ const funcPath = path3.join(fFuncs, entry.name);
436
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
435
437
  errors.push({
436
438
  ruleId: "krnl/frontend-functionality-manifest-required",
437
439
  filePath: funcPath,
@@ -522,14 +524,6 @@ var PRIMITIVE_AND_BUILTIN_TYPES = /* @__PURE__ */ new Set([
522
524
  "ReturnType",
523
525
  "InstanceType"
524
526
  ]);
525
- function detectServiceContext(filePath) {
526
- const normalized = filePath.replace(/\\/g, "/");
527
- const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
528
- if (match) {
529
- return { serviceName: match[1], libraryName: match[2] };
530
- }
531
- return null;
532
- }
533
527
  function containsIdentifier(name, target) {
534
528
  return name.toLowerCase().includes(target.toLowerCase());
535
529
  }
@@ -550,6 +544,14 @@ function hasContextualTypeReference(node, serviceName, localTypes) {
550
544
  }
551
545
  return false;
552
546
  }
547
+ function detectServiceContext(filePath) {
548
+ const normalized = filePath.replace(/\\/g, "/");
549
+ const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
550
+ if (match) {
551
+ return { serviceName: match[1], libraryName: match[2] };
552
+ }
553
+ return null;
554
+ }
553
555
  function checkScopedLibraryRules(sf) {
554
556
  const errors = [];
555
557
  const warnings = [];
@@ -599,7 +601,7 @@ function checkScopedLibraryRules(sf) {
599
601
  for (const decl of stmt.getDeclarations()) {
600
602
  const varName = decl.getName();
601
603
  const init = decl.getInitializer();
602
- const isFunction = init && (init.getKind() === SyntaxKind4.ArrowFunction || init.getKind() === SyntaxKind4.FunctionExpression);
604
+ const isFunction = init && (init.getKind() === SyntaxKind5.ArrowFunction || init.getKind() === SyntaxKind5.FunctionExpression);
603
605
  if (isFunction) {
604
606
  const isContextual = hasContextualTypeReference(decl, serviceName, localTypes);
605
607
  const hasServiceName = containsIdentifier(varName, serviceName);
@@ -688,13 +690,13 @@ var KrnlValidatorEngine = class {
688
690
  limitOptions;
689
691
  constructor(optionsOrRoot) {
690
692
  const options = typeof optionsOrRoot === "string" ? { projectRoot: optionsOrRoot } : optionsOrRoot;
691
- this.projectRoot = path3.resolve(options.projectRoot || process.cwd());
693
+ this.projectRoot = path4.resolve(options.projectRoot || process.cwd());
692
694
  this.limitOptions = {
693
695
  maxFileLineLimit: options.maxFileLineLimit ?? 200,
694
696
  maxMainLogicLimit: options.maxMainLogicLimit ?? 20,
695
697
  maxHelperLineLimit: options.maxHelperLineLimit ?? 30
696
698
  };
697
- const tsConfigPath = path3.join(this.projectRoot, "tsconfig.json");
699
+ const tsConfigPath = path4.join(this.projectRoot, "tsconfig.json");
698
700
  if (fs2.existsSync(tsConfigPath)) {
699
701
  this.project = new Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
700
702
  } else {
@@ -729,7 +731,7 @@ var KrnlValidatorEngine = class {
729
731
  }
730
732
  validateSourceFile(sf) {
731
733
  const filePath = sf.getFilePath();
732
- const baseName = path3.basename(filePath);
734
+ const baseName = path4.basename(filePath);
733
735
  if (baseName.includes("_pb.") || baseName.endsWith(".d.ts")) {
734
736
  return { errors: [], warnings: [], promotableAssets: [] };
735
737
  }
@@ -764,7 +766,7 @@ var KrnlValidatorEngine = class {
764
766
  const entries = fs2.readdirSync(dir, { withFileTypes: true });
765
767
  for (const entry of entries) {
766
768
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
767
- const full = path3.join(dir, entry.name);
769
+ const full = path4.join(dir, entry.name);
768
770
  if (entry.isDirectory()) {
769
771
  this.collectSourceFiles(full, collected);
770
772
  } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js") || entry.name.endsWith(".tsx") || entry.name.endsWith(".jsx"))) {
@@ -813,7 +815,7 @@ async function runValidate(projectRoot = process.cwd()) {
813
815
 
814
816
  // ../core/dist/index.js
815
817
  import * as fs3 from "fs";
816
- import * as path4 from "path";
818
+ import * as path5 from "path";
817
819
  import { tryParseJson } from "@dinilmusick/gutts";
818
820
  import * as gutts from "@dinilmusick/gutts";
819
821
  var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
@@ -866,7 +868,7 @@ var KrnlPackageReconciler = class {
866
868
  }
867
869
  resolvedDevDeps[pkg] = versions[versions.length - 1];
868
870
  }
869
- const pkgJsonPath = path4.join(projectRoot, "package.json");
871
+ const pkgJsonPath = path5.join(projectRoot, "package.json");
870
872
  let updated = false;
871
873
  if (fs3.existsSync(pkgJsonPath)) {
872
874
  const pkgContent = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf8"));
@@ -904,15 +906,15 @@ var KrnlPackageReconciler = class {
904
906
  */
905
907
  static findManifests(projectRoot) {
906
908
  const searchDirs = [
907
- path4.join(projectRoot, "krnl", "backend", "services"),
908
- path4.join(projectRoot, "krnl", "backend", "libraries"),
909
- path4.join(projectRoot, "krnl", "backend", "functionalities"),
910
- path4.join(projectRoot, "krnl", "frontend", "libraries"),
911
- path4.join(projectRoot, "krnl", "frontend", "functionalities"),
912
- path4.join(projectRoot, "src", "backend", "services"),
913
- path4.join(projectRoot, "src", "services"),
914
- path4.join(projectRoot, "src", "functionalities"),
915
- path4.join(projectRoot, "src", "libraries")
909
+ path5.join(projectRoot, "krnl", "backend", "services"),
910
+ path5.join(projectRoot, "krnl", "backend", "libraries"),
911
+ path5.join(projectRoot, "krnl", "backend", "functionalities"),
912
+ path5.join(projectRoot, "krnl", "frontend", "libraries"),
913
+ path5.join(projectRoot, "krnl", "frontend", "functionalities"),
914
+ path5.join(projectRoot, "src", "backend", "services"),
915
+ path5.join(projectRoot, "src", "services"),
916
+ path5.join(projectRoot, "src", "functionalities"),
917
+ path5.join(projectRoot, "src", "libraries")
916
918
  ];
917
919
  const found = [];
918
920
  for (const dir of searchDirs) {
@@ -927,7 +929,7 @@ var KrnlPackageReconciler = class {
927
929
  const entries = fs3.readdirSync(dir, { withFileTypes: true });
928
930
  for (const entry of entries) {
929
931
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
930
- const full = path4.join(dir, entry.name);
932
+ const full = path5.join(dir, entry.name);
931
933
  if (entry.isDirectory()) {
932
934
  this.scanRecursive(full, found);
933
935
  } else if (entry.isFile() && entry.name === "manifest.json") {
@@ -940,24 +942,24 @@ var KrnlPackageReconciler = class {
940
942
  };
941
943
 
942
944
  // src/commands/generators/functionalityOrchestrationGenerator.ts
943
- import * as path6 from "path";
945
+ import * as path7 from "path";
944
946
  import * as fs5 from "fs";
945
947
 
946
948
  // src/commands/generators/common.ts
947
949
  import * as fs4 from "fs";
948
- import * as path5 from "path";
950
+ import * as path6 from "path";
949
951
  function getPlaneRoots(projectRoot) {
950
- const krnlRoot = path5.join(projectRoot, "krnl");
952
+ const krnlRoot = path6.join(projectRoot, "krnl");
951
953
  if (fs4.existsSync(krnlRoot)) {
952
954
  return {
953
- backend: path5.join(krnlRoot, "backend"),
954
- frontend: path5.join(krnlRoot, "frontend"),
955
+ backend: path6.join(krnlRoot, "backend"),
956
+ frontend: path6.join(krnlRoot, "frontend"),
955
957
  isKrnlDir: true
956
958
  };
957
959
  }
958
960
  return {
959
- backend: path5.join(projectRoot, "src"),
960
- frontend: path5.join(projectRoot, "src"),
961
+ backend: path6.join(projectRoot, "src"),
962
+ frontend: path6.join(projectRoot, "src"),
961
963
  isKrnlDir: false
962
964
  };
963
965
  }
@@ -965,10 +967,10 @@ function getPlaneRoots(projectRoot) {
965
967
  // src/commands/generators/functionalityOrchestrationGenerator.ts
966
968
  function generateFunctionalityOrchestration(name, projectRoot) {
967
969
  const { backend } = getPlaneRoots(projectRoot);
968
- const orchDir = path6.join(backend, "orchestrations", name);
969
- fs5.mkdirSync(path6.join(orchDir, "tests"), { recursive: true });
970
+ const orchDir = path7.join(backend, "orchestrations", name);
971
+ fs5.mkdirSync(path7.join(orchDir, "tests"), { recursive: true });
970
972
  fs5.writeFileSync(
971
- path6.join(orchDir, `${name}FunctionalityOrchestration.ts`),
973
+ path7.join(orchDir, `${name}FunctionalityOrchestration.ts`),
972
974
  `import { FunctionalityOrchestration } from '@ultrst-armada/krnl-core';
973
975
 
974
976
  /**
@@ -994,7 +996,7 @@ export default ${name}FunctionalityOrchestration;
994
996
  `
995
997
  );
996
998
  fs5.writeFileSync(
997
- path6.join(orchDir, "tests", `${name}FunctionalityOrchestration.test.ts`),
999
+ path7.join(orchDir, "tests", `${name}FunctionalityOrchestration.test.ts`),
998
1000
  `import { describe, it, expect } from 'vitest';
999
1001
  import { ${name}FunctionalityOrchestration } from '../${name}FunctionalityOrchestration.js';
1000
1002
 
@@ -1013,13 +1015,13 @@ describe('${name}FunctionalityOrchestration', () => {
1013
1015
 
1014
1016
  // src/commands/generators/functionalityGenerator.ts
1015
1017
  import * as fs6 from "fs";
1016
- import * as path7 from "path";
1018
+ import * as path8 from "path";
1017
1019
  function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
1018
1020
  const { backend, frontend } = getPlaneRoots(projectRoot);
1019
1021
  const options = typeof parentServiceOrOptions === "string" ? { parentService: parentServiceOrOptions } : parentServiceOrOptions || {};
1020
1022
  let targetService = options.parentService;
1021
1023
  if (!targetService) {
1022
- const servicesDir = path7.join(backend, "services");
1024
+ const servicesDir = path8.join(backend, "services");
1023
1025
  if (fs6.existsSync(servicesDir)) {
1024
1026
  const existing = fs6.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
1025
1027
  if (existing.length === 1) {
@@ -1027,15 +1029,15 @@ function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
1027
1029
  }
1028
1030
  }
1029
1031
  }
1030
- const bFuncDir = targetService ? path7.join(backend, "services", targetService, "functionalities", name) : path7.join(backend, "functionalities", name);
1031
- fs6.mkdirSync(path7.join(bFuncDir, "main_function"), { recursive: true });
1032
- fs6.mkdirSync(path7.join(bFuncDir, "helper_functions"), { recursive: true });
1033
- fs6.mkdirSync(path7.join(bFuncDir, "events"), { recursive: true });
1034
- fs6.mkdirSync(path7.join(bFuncDir, "tests"), { recursive: true });
1032
+ const bFuncDir = targetService ? path8.join(backend, "services", targetService, "functionalities", name) : path8.join(backend, "functionalities", name);
1033
+ fs6.mkdirSync(path8.join(bFuncDir, "main_function"), { recursive: true });
1034
+ fs6.mkdirSync(path8.join(bFuncDir, "helper_functions"), { recursive: true });
1035
+ fs6.mkdirSync(path8.join(bFuncDir, "events"), { recursive: true });
1036
+ fs6.mkdirSync(path8.join(bFuncDir, "tests"), { recursive: true });
1035
1037
  if (options.withState) {
1036
- fs6.mkdirSync(path7.join(bFuncDir, "state_data"), { recursive: true });
1038
+ fs6.mkdirSync(path8.join(bFuncDir, "state_data"), { recursive: true });
1037
1039
  fs6.writeFileSync(
1038
- path7.join(bFuncDir, "state_data", "state.ts"),
1040
+ path8.join(bFuncDir, "state_data", "state.ts"),
1039
1041
  `export interface ${name}State {
1040
1042
  executionCount: number;
1041
1043
  }
@@ -1047,7 +1049,7 @@ export const initialState: ${name}State = {
1047
1049
  );
1048
1050
  }
1049
1051
  fs6.writeFileSync(
1050
- path7.join(bFuncDir, `${name}Atom.ts`),
1052
+ path8.join(bFuncDir, `${name}Atom.ts`),
1051
1053
  `export interface ${name}Input {
1052
1054
  payload?: string;
1053
1055
  }
@@ -1059,7 +1061,7 @@ export interface ${name}Output {
1059
1061
  `
1060
1062
  );
1061
1063
  fs6.writeFileSync(
1062
- path7.join(bFuncDir, "manifest.json"),
1064
+ path8.join(bFuncDir, "manifest.json"),
1063
1065
  JSON.stringify(
1064
1066
  {
1065
1067
  name,
@@ -1072,7 +1074,7 @@ export interface ${name}Output {
1072
1074
  )
1073
1075
  );
1074
1076
  fs6.writeFileSync(
1075
- path7.join(bFuncDir, "main_function", "logic.ts"),
1077
+ path8.join(bFuncDir, "main_function", "logic.ts"),
1076
1078
  `import type { ${name}Input, ${name}Output } from "../${name}Atom.js";
1077
1079
 
1078
1080
  export const main = async (input: ${name}Input, context: any): Promise<${name}Output> => {
@@ -1084,13 +1086,13 @@ export const main = async (input: ${name}Input, context: any): Promise<${name}Ou
1084
1086
  `
1085
1087
  );
1086
1088
  fs6.writeFileSync(
1087
- path7.join(bFuncDir, "main_function", "lifecycle.ts"),
1089
+ path8.join(bFuncDir, "main_function", "lifecycle.ts"),
1088
1090
  `export async function onMount() {}
1089
1091
  export async function onTeardown() {}
1090
1092
  `
1091
1093
  );
1092
1094
  fs6.writeFileSync(
1093
- path7.join(bFuncDir, "helper_functions", "helper.ts"),
1095
+ path8.join(bFuncDir, "helper_functions", "helper.ts"),
1094
1096
  `/**
1095
1097
  * @role component
1096
1098
  */
@@ -1100,7 +1102,7 @@ export function exampleHelper(): boolean {
1100
1102
  `
1101
1103
  );
1102
1104
  fs6.writeFileSync(
1103
- path7.join(bFuncDir, "events", "events.ts"),
1105
+ path8.join(bFuncDir, "events", "events.ts"),
1104
1106
  `/**
1105
1107
  * @role component
1106
1108
  */
@@ -1110,7 +1112,7 @@ export interface ${name}CompletedEvent {
1110
1112
  `
1111
1113
  );
1112
1114
  fs6.writeFileSync(
1113
- path7.join(bFuncDir, "tests", `${name}.test.ts`),
1115
+ path8.join(bFuncDir, "tests", `${name}.test.ts`),
1114
1116
  `import { describe, it, expect } from "vitest";
1115
1117
 
1116
1118
  describe("${name} functionality", () => {
@@ -1120,10 +1122,10 @@ describe("${name} functionality", () => {
1120
1122
  });
1121
1123
  `
1122
1124
  );
1123
- const fFuncDir = path7.join(frontend, "functionalities", name);
1124
- fs6.mkdirSync(path7.join(fFuncDir, "tests"), { recursive: true });
1125
+ const fFuncDir = path8.join(frontend, "functionalities", name);
1126
+ fs6.mkdirSync(path8.join(fFuncDir, "tests"), { recursive: true });
1125
1127
  fs6.writeFileSync(
1126
- path7.join(fFuncDir, `${name}0.tsx`),
1128
+ path8.join(fFuncDir, `${name}0.tsx`),
1127
1129
  `import React from "react";
1128
1130
 
1129
1131
  export const ${name}0: React.FC = () => {
@@ -1138,11 +1140,11 @@ export default ${name}0;
1138
1140
  `
1139
1141
  );
1140
1142
  fs6.writeFileSync(
1141
- path7.join(fFuncDir, "manifest.json"),
1143
+ path8.join(fFuncDir, "manifest.json"),
1142
1144
  JSON.stringify({ name: `${name}UI`, dependencies: {} }, null, 2)
1143
1145
  );
1144
1146
  fs6.writeFileSync(
1145
- path7.join(fFuncDir, "tests", `${name}0.test.tsx`),
1147
+ path8.join(fFuncDir, "tests", `${name}0.test.tsx`),
1146
1148
  `import { describe, it, expect } from "vitest";
1147
1149
 
1148
1150
  describe("${name}0 Component", () => {
@@ -1153,19 +1155,19 @@ describe("${name}0 Component", () => {
1153
1155
  `
1154
1156
  );
1155
1157
  KrnlPackageReconciler.reconcile(projectRoot, true);
1156
- console.log(`\u2705 Created Backend Functionality: ${path7.relative(projectRoot, bFuncDir)}/`);
1157
- console.log(`\u2705 Created Frontend Functionality: ${path7.relative(projectRoot, fFuncDir)}/`);
1158
+ console.log(`\u2705 Created Backend Functionality: ${path8.relative(projectRoot, bFuncDir)}/`);
1159
+ console.log(`\u2705 Created Frontend Functionality: ${path8.relative(projectRoot, fFuncDir)}/`);
1158
1160
  }
1159
1161
 
1160
1162
  // src/commands/generators/libraryGenerator.ts
1161
1163
  import * as fs7 from "fs";
1162
- import * as path8 from "path";
1164
+ import * as path9 from "path";
1163
1165
  function generateLibrary(name, projectRoot, parentService) {
1164
1166
  const { backend, frontend } = getPlaneRoots(projectRoot);
1165
1167
  const conceptName = name.endsWith("Concepts") ? name : `${name}Concepts`;
1166
1168
  let targetService = parentService;
1167
1169
  if (!targetService) {
1168
- const servicesDir = path8.join(backend, "services");
1170
+ const servicesDir = path9.join(backend, "services");
1169
1171
  if (fs7.existsSync(servicesDir)) {
1170
1172
  const existing = fs7.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
1171
1173
  if (existing.length === 1) {
@@ -1176,10 +1178,10 @@ function generateLibrary(name, projectRoot, parentService) {
1176
1178
  if (!targetService) {
1177
1179
  targetService = "App";
1178
1180
  }
1179
- const bLibDir = path8.join(backend, "services", targetService, "libraries", conceptName);
1180
- fs7.mkdirSync(path8.join(bLibDir, "tests"), { recursive: true });
1181
+ const bLibDir = path9.join(backend, "services", targetService, "libraries", conceptName);
1182
+ fs7.mkdirSync(path9.join(bLibDir, "tests"), { recursive: true });
1181
1183
  fs7.writeFileSync(
1182
- path8.join(bLibDir, "definitions.ts"),
1184
+ path9.join(bLibDir, "definitions.ts"),
1183
1185
  `/**
1184
1186
  * @file definitions.ts
1185
1187
  * @role component
@@ -1190,7 +1192,7 @@ export interface ${conceptName}Options {
1190
1192
  `
1191
1193
  );
1192
1194
  fs7.writeFileSync(
1193
- path8.join(bLibDir, "functions.ts"),
1195
+ path9.join(bLibDir, "functions.ts"),
1194
1196
  `/**
1195
1197
  * @file functions.ts
1196
1198
  * @role component
@@ -1203,17 +1205,17 @@ export function ${name.toLowerCase()}Transform<T>(data: T, _opts?: ${conceptName
1203
1205
  `
1204
1206
  );
1205
1207
  fs7.writeFileSync(
1206
- path8.join(bLibDir, "index.ts"),
1208
+ path9.join(bLibDir, "index.ts"),
1207
1209
  `export * from "./definitions.js";
1208
1210
  export * from "./functions.js";
1209
1211
  `
1210
1212
  );
1211
1213
  fs7.writeFileSync(
1212
- path8.join(bLibDir, "manifest.json"),
1214
+ path9.join(bLibDir, "manifest.json"),
1213
1215
  JSON.stringify({ name: conceptName, service: targetService, dependencies: {} }, null, 2)
1214
1216
  );
1215
1217
  fs7.writeFileSync(
1216
- path8.join(bLibDir, "tests", `${conceptName}.test.ts`),
1218
+ path9.join(bLibDir, "tests", `${conceptName}.test.ts`),
1217
1219
  `import { describe, it, expect } from "vitest";
1218
1220
  import { ${name.toLowerCase()}Transform } from "../functions.js";
1219
1221
 
@@ -1224,17 +1226,17 @@ describe("${conceptName}", () => {
1224
1226
  });
1225
1227
  `
1226
1228
  );
1227
- const fLibDir = path8.join(frontend, "libraries", conceptName);
1228
- fs7.mkdirSync(path8.join(fLibDir, "tests"), { recursive: true });
1229
+ const fLibDir = path9.join(frontend, "libraries", conceptName);
1230
+ fs7.mkdirSync(path9.join(fLibDir, "tests"), { recursive: true });
1229
1231
  fs7.writeFileSync(
1230
- path8.join(fLibDir, "definitions.ts"),
1232
+ path9.join(fLibDir, "definitions.ts"),
1231
1233
  `export interface ${name}Props {
1232
1234
  label?: string;
1233
1235
  }
1234
1236
  `
1235
1237
  );
1236
1238
  fs7.writeFileSync(
1237
- path8.join(fLibDir, "components.tsx"),
1239
+ path9.join(fLibDir, "components.tsx"),
1238
1240
  `import React from "react";
1239
1241
  import type { ${name}Props } from "./definitions.js";
1240
1242
  import "./styles.css";
@@ -1245,18 +1247,18 @@ export const ${name}: React.FC<${name}Props> = ({ label = "${name}" }) => {
1245
1247
  `
1246
1248
  );
1247
1249
  fs7.writeFileSync(
1248
- path8.join(fLibDir, "styles.css"),
1250
+ path9.join(fLibDir, "styles.css"),
1249
1251
  `.krnl-${name.toLowerCase()} {
1250
1252
  font-family: inherit;
1251
1253
  }
1252
1254
  `
1253
1255
  );
1254
1256
  fs7.writeFileSync(
1255
- path8.join(fLibDir, "manifest.json"),
1257
+ path9.join(fLibDir, "manifest.json"),
1256
1258
  JSON.stringify({ name: `${conceptName}UI`, dependencies: {} }, null, 2)
1257
1259
  );
1258
1260
  fs7.writeFileSync(
1259
- path8.join(fLibDir, "tests", `${name}.test.tsx`),
1261
+ path9.join(fLibDir, "tests", `${name}.test.tsx`),
1260
1262
  `import { describe, it, expect } from "vitest";
1261
1263
 
1262
1264
  describe("${name} UI Concept", () => {
@@ -1267,13 +1269,13 @@ describe("${name} UI Concept", () => {
1267
1269
  `
1268
1270
  );
1269
1271
  KrnlPackageReconciler.reconcile(projectRoot, true);
1270
- console.log(`\u2705 Created Service-Owned Library: ${path8.relative(projectRoot, bLibDir)}/ (Owner: ${targetService})`);
1271
- console.log(`\u2705 Created Frontend Concept Library: ${path8.relative(projectRoot, fLibDir)}/`);
1272
+ console.log(`\u2705 Created Service-Owned Library: ${path9.relative(projectRoot, bLibDir)}/ (Owner: ${targetService})`);
1273
+ console.log(`\u2705 Created Frontend Concept Library: ${path9.relative(projectRoot, fLibDir)}/`);
1272
1274
  }
1273
1275
 
1274
1276
  // src/commands/generators/serviceGenerator.ts
1275
1277
  import * as fs8 from "fs";
1276
- import * as path9 from "path";
1278
+ import * as path10 from "path";
1277
1279
  function generateService(name, projectRoot, defaultFrontend) {
1278
1280
  const frontendReference = defaultFrontend?.component ? {
1279
1281
  component: defaultFrontend.component,
@@ -1283,20 +1285,20 @@ function generateService(name, projectRoot, defaultFrontend) {
1283
1285
  } : void 0;
1284
1286
  const frontendConfig = frontendReference ? JSON.stringify(frontendReference, null, 2).replace(/\n/g, "\n ") : void 0;
1285
1287
  const { backend } = getPlaneRoots(projectRoot);
1286
- const serviceDir = path9.join(backend, "services", name);
1287
- const funcsDir = path9.join(serviceDir, "functionalities");
1288
- const orchsDir = path9.join(serviceDir, "orchestrations");
1289
- const libsDir = path9.join(serviceDir, "libraries");
1290
- const testsDir = path9.join(serviceDir, "tests");
1288
+ const serviceDir = path10.join(backend, "services", name);
1289
+ const funcsDir = path10.join(serviceDir, "functionalities");
1290
+ const orchsDir = path10.join(serviceDir, "orchestrations");
1291
+ const libsDir = path10.join(serviceDir, "libraries");
1292
+ const testsDir = path10.join(serviceDir, "tests");
1291
1293
  fs8.mkdirSync(funcsDir, { recursive: true });
1292
1294
  fs8.mkdirSync(orchsDir, { recursive: true });
1293
1295
  fs8.mkdirSync(libsDir, { recursive: true });
1294
1296
  fs8.mkdirSync(testsDir, { recursive: true });
1295
1297
  const conceptName = `${name}Concepts`;
1296
- const defaultLibDir = path9.join(libsDir, conceptName);
1297
- fs8.mkdirSync(path9.join(defaultLibDir, "tests"), { recursive: true });
1298
+ const defaultLibDir = path10.join(libsDir, conceptName);
1299
+ fs8.mkdirSync(path10.join(defaultLibDir, "tests"), { recursive: true });
1298
1300
  fs8.writeFileSync(
1299
- path9.join(defaultLibDir, "definitions.ts"),
1301
+ path10.join(defaultLibDir, "definitions.ts"),
1300
1302
  `/**
1301
1303
  * @file definitions.ts
1302
1304
  * @role component
@@ -1307,7 +1309,7 @@ export interface ${name}Options {
1307
1309
  `
1308
1310
  );
1309
1311
  fs8.writeFileSync(
1310
- path9.join(defaultLibDir, "functions.ts"),
1312
+ path10.join(defaultLibDir, "functions.ts"),
1311
1313
  `/**
1312
1314
  * @file functions.ts
1313
1315
  * @role component
@@ -1320,17 +1322,17 @@ export function format${name}Name(input: string, _opts?: ${name}Options): string
1320
1322
  `
1321
1323
  );
1322
1324
  fs8.writeFileSync(
1323
- path9.join(defaultLibDir, "index.ts"),
1325
+ path10.join(defaultLibDir, "index.ts"),
1324
1326
  `export * from "./definitions.js";
1325
1327
  export * from "./functions.js";
1326
1328
  `
1327
1329
  );
1328
1330
  fs8.writeFileSync(
1329
- path9.join(defaultLibDir, "manifest.json"),
1331
+ path10.join(defaultLibDir, "manifest.json"),
1330
1332
  JSON.stringify({ name: conceptName, description: `${name} service-owned library`, dependencies: {} }, null, 2)
1331
1333
  );
1332
1334
  fs8.writeFileSync(
1333
- path9.join(defaultLibDir, "tests", `${conceptName}.test.ts`),
1335
+ path10.join(defaultLibDir, "tests", `${conceptName}.test.ts`),
1334
1336
  `import { describe, it, expect } from "vitest";
1335
1337
  import { format${name}Name } from "../functions.js";
1336
1338
 
@@ -1344,7 +1346,7 @@ describe("${conceptName}", () => {
1344
1346
  const frontendProperty = frontendConfig ? ` defaultFrontend: ${frontendConfig},
1345
1347
  ` : "";
1346
1348
  fs8.writeFileSync(
1347
- path9.join(serviceDir, `${name}ServiceFacade.ts`),
1349
+ path10.join(serviceDir, `${name}ServiceFacade.ts`),
1348
1350
  `import { ServiceFacade } from "@ultrst-armada/krnl-core";
1349
1351
  import * as ${name.toLowerCase()}Concepts from "./libraries/${conceptName}/index.js";
1350
1352
 
@@ -1362,7 +1364,7 @@ export default ${name}ServiceFacade;
1362
1364
  `
1363
1365
  );
1364
1366
  fs8.writeFileSync(
1365
- path9.join(testsDir, `${name}ServiceFacade.test.ts`),
1367
+ path10.join(testsDir, `${name}ServiceFacade.test.ts`),
1366
1368
  `import { describe, it, expect } from "vitest";
1367
1369
  import { ${name}ServiceFacade } from "../${name}ServiceFacade.js";
1368
1370
 
@@ -1376,7 +1378,7 @@ describe("${name}ServiceFacade", () => {
1376
1378
  `
1377
1379
  );
1378
1380
  KrnlPackageReconciler.reconcile(projectRoot, true);
1379
- console.log(`\u2705 Created Service: ${path9.relative(projectRoot, serviceDir)}/`);
1381
+ console.log(`\u2705 Created Service: ${path10.relative(projectRoot, serviceDir)}/`);
1380
1382
  }
1381
1383
 
1382
1384
  // src/commands/generate.ts
@@ -1412,7 +1414,7 @@ async function runGenerate(type, name, parentService, projectRoot = process.cwd(
1412
1414
 
1413
1415
  // src/commands/watch.ts
1414
1416
  import * as fs9 from "fs";
1415
- import * as path10 from "path";
1417
+ import * as path11 from "path";
1416
1418
  function generateMagneticDeclarations(projectRoot = process.cwd()) {
1417
1419
  const { results: functionalities, libDirs } = scanDirectory(projectRoot);
1418
1420
  let dtsContent = `// Automatically generated by Krnl Magnetic Watcher. Do not edit manually.
@@ -1423,14 +1425,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
1423
1425
  `;
1424
1426
  const globalDeclarations = [];
1425
1427
  for (const func of functionalities) {
1426
- const helpersDir = path10.join(func.funcPath, "helper_functions");
1428
+ const helpersDir = path11.join(func.funcPath, "helper_functions");
1427
1429
  if (fs9.existsSync(helpersDir)) {
1428
1430
  const files = fs9.readdirSync(helpersDir);
1429
1431
  for (const file of files) {
1430
1432
  if (file.endsWith(".js") || file.endsWith(".ts")) {
1431
- const filePath = path10.join(helpersDir, file);
1432
- const baseName = path10.basename(file, path10.extname(file));
1433
- const importPath = `./${path10.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1433
+ const filePath = path11.join(helpersDir, file);
1434
+ const baseName = path11.basename(file, path11.extname(file));
1435
+ const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1434
1436
  const { named, hasDefault } = parseExports(filePath, baseName);
1435
1437
  if (hasDefault) {
1436
1438
  globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
@@ -1441,14 +1443,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
1441
1443
  }
1442
1444
  }
1443
1445
  }
1444
- const eventsDir = path10.join(func.funcPath, "events");
1446
+ const eventsDir = path11.join(func.funcPath, "events");
1445
1447
  if (fs9.existsSync(eventsDir)) {
1446
1448
  const files = fs9.readdirSync(eventsDir);
1447
1449
  for (const file of files) {
1448
1450
  if (file.endsWith(".js") || file.endsWith(".ts")) {
1449
- const filePath = path10.join(eventsDir, file);
1450
- const baseName = path10.basename(file, path10.extname(file));
1451
- const importPath = `./${path10.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1451
+ const filePath = path11.join(eventsDir, file);
1452
+ const baseName = path11.basename(file, path11.extname(file));
1453
+ const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1452
1454
  const { named, hasDefault } = parseExports(filePath, baseName);
1453
1455
  if (hasDefault) {
1454
1456
  globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
@@ -1469,7 +1471,7 @@ ${Array.from(new Set(globalDeclarations)).join("\n")}
1469
1471
  }
1470
1472
  `;
1471
1473
  }
1472
- const outPath = path10.join(projectRoot, "krnl-magnetic.d.ts");
1474
+ const outPath = path11.join(projectRoot, "krnl-magnetic.d.ts");
1473
1475
  fs9.writeFileSync(outPath, dtsContent);
1474
1476
  console.log(`[Krnl Watch] Updated ambient declarations: ${outPath}`);
1475
1477
  }
@@ -1477,12 +1479,12 @@ function scanLibFiles(dir, projectRoot, decls) {
1477
1479
  if (!fs9.existsSync(dir)) return;
1478
1480
  for (const entry of fs9.readdirSync(dir, { withFileTypes: true })) {
1479
1481
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
1480
- const full = path10.join(dir, entry.name);
1482
+ const full = path11.join(dir, entry.name);
1481
1483
  if (entry.isDirectory()) {
1482
1484
  scanLibFiles(full, projectRoot, decls);
1483
1485
  } else if ((entry.name.endsWith(".ts") || entry.name.endsWith(".js")) && !entry.name.endsWith(".d.ts")) {
1484
- const baseName = path10.basename(entry.name, path10.extname(entry.name));
1485
- const importPath = `./${path10.relative(projectRoot, full).replace(/\\/g, "/")}`;
1486
+ const baseName = path11.basename(entry.name, path11.extname(entry.name));
1487
+ const importPath = `./${path11.relative(projectRoot, full).replace(/\\/g, "/")}`;
1486
1488
  const { named, hasDefault } = parseExports(full, baseName);
1487
1489
  if (hasDefault) decls.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
1488
1490
  for (const n of named) decls.push(` const ${n}: typeof import('${importPath}')['${n}'];`);
@@ -1495,11 +1497,11 @@ function scanDirectory(dir, results = [], libDirs = []) {
1495
1497
  for (const entry of list) {
1496
1498
  if (entry.isDirectory()) {
1497
1499
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
1498
- const fullPath = path10.join(dir, entry.name);
1500
+ const fullPath = path11.join(dir, entry.name);
1499
1501
  if (entry.name === "functionalities") {
1500
1502
  const funcs = fs9.readdirSync(fullPath, { withFileTypes: true });
1501
1503
  for (const f of funcs) {
1502
- if (f.isDirectory()) results.push({ funcPath: path10.join(fullPath, f.name), funcName: f.name });
1504
+ if (f.isDirectory()) results.push({ funcPath: path11.join(fullPath, f.name), funcName: f.name });
1503
1505
  }
1504
1506
  } else if (entry.name === "libraries" || entry.name === "library") {
1505
1507
  libDirs.push(fullPath);
@@ -1526,7 +1528,7 @@ function parseExports(filePath, defaultName) {
1526
1528
  }
1527
1529
 
1528
1530
  // src/commands/build.ts
1529
- import * as path11 from "path";
1531
+ import * as path12 from "path";
1530
1532
  import * as fs10 from "fs";
1531
1533
  import { execSync } from "child_process";
1532
1534
  async function runBuild(projectRoot = process.cwd(), options = {}) {
@@ -1544,10 +1546,10 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
1544
1546
  return { success: false, error: "Validation failed" };
1545
1547
  }
1546
1548
  generateMagneticDeclarations(projectRoot);
1547
- const tsConfigPath = path11.join(projectRoot, "tsconfig.json");
1549
+ const tsConfigPath = path12.join(projectRoot, "tsconfig.json");
1548
1550
  if (fs10.existsSync(tsConfigPath)) {
1549
1551
  console.log("\u{1F3D7}\uFE0F [Krnl Build] Compiling TypeScript source files to dist/...");
1550
- const localTsc = path11.join(projectRoot, "node_modules", ".bin", "tsc");
1552
+ const localTsc = path12.join(projectRoot, "node_modules", ".bin", "tsc");
1551
1553
  const tscCmd = fs10.existsSync(localTsc) ? localTsc : "tsc";
1552
1554
  try {
1553
1555
  execSync(`${tscCmd} -p tsconfig.json`, { cwd: projectRoot, stdio: "inherit" });
@@ -1564,7 +1566,7 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
1564
1566
 
1565
1567
  // src/commands/dev.ts
1566
1568
  import * as http from "http";
1567
- import * as path12 from "path";
1569
+ import * as path13 from "path";
1568
1570
  import * as fs11 from "fs";
1569
1571
  async function runDev(projectRoot = process.cwd(), options = {}) {
1570
1572
  const port = options.port ?? 8080;
@@ -1587,7 +1589,7 @@ async function runDev(projectRoot = process.cwd(), options = {}) {
1587
1589
  return;
1588
1590
  }
1589
1591
  if (url.pathname === "/manifest") {
1590
- const pkgPath = path12.join(projectRoot, "package.json");
1592
+ const pkgPath = path13.join(projectRoot, "package.json");
1591
1593
  const pkg = fs11.existsSync(pkgPath) ? JSON.parse(fs11.readFileSync(pkgPath, "utf8")) : {};
1592
1594
  res.writeHead(200);
1593
1595
  res.end(JSON.stringify({ name: pkg.name || "krnl-app", version: pkg.version || "1.0.0" }));