@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.
@@ -40,15 +40,17 @@ module.exports = __toCommonJS(index_exports);
40
40
 
41
41
  // ../validate/dist/index.js
42
42
  var fs2 = __toESM(require("fs"), 1);
43
- var path3 = __toESM(require("path"), 1);
43
+ var path4 = __toESM(require("path"), 1);
44
44
  var import_ts_morph = require("ts-morph");
45
45
  var path = __toESM(require("path"), 1);
46
46
  var import_ts_morph2 = require("ts-morph");
47
47
  var import_ts_morph3 = require("ts-morph");
48
48
  var fs = __toESM(require("fs"), 1);
49
+ var path3 = __toESM(require("path"), 1);
49
50
  var path2 = __toESM(require("path"), 1);
50
51
  var import_ts_morph4 = require("ts-morph");
51
52
  var import_ts_morph5 = require("ts-morph");
53
+ var import_ts_morph6 = require("ts-morph");
52
54
  function checkFileLimits(sf, options) {
53
55
  const errors = [];
54
56
  const warnings = [];
@@ -375,24 +377,24 @@ function checkTopLevelPurity(sf) {
375
377
  return { errors, warnings };
376
378
  }
377
379
  function checkWorkspaceLayout(projectRoot, errors) {
378
- const krnlDir = path2.join(projectRoot, "krnl");
379
- const srcDir = path2.join(projectRoot, "src");
380
+ const krnlDir = path3.join(projectRoot, "krnl");
381
+ const srcDir = path3.join(projectRoot, "src");
380
382
  const targetDir = fs.existsSync(krnlDir) ? krnlDir : fs.existsSync(srcDir) ? srcDir : null;
381
383
  if (!targetDir) return;
382
- const backendDir = path2.join(targetDir, "backend");
383
- const frontendDir = path2.join(targetDir, "frontend");
384
+ const backendDir = path3.join(targetDir, "backend");
385
+ const frontendDir = path3.join(targetDir, "frontend");
384
386
  if (fs.existsSync(backendDir)) {
385
- const bServices = path2.join(backendDir, "services");
387
+ const bServices = path3.join(backendDir, "services");
386
388
  if (fs.existsSync(bServices)) {
387
389
  for (const sEntry of fs.readdirSync(bServices, { withFileTypes: true })) {
388
390
  if (!sEntry.isDirectory()) continue;
389
- const sDir = path2.join(bServices, sEntry.name);
390
- const sLibs = path2.join(sDir, "libraries");
391
+ const sDir = path3.join(bServices, sEntry.name);
392
+ const sLibs = path3.join(sDir, "libraries");
391
393
  if (fs.existsSync(sLibs)) {
392
394
  for (const entry of fs.readdirSync(sLibs, { withFileTypes: true })) {
393
395
  if (!entry.isDirectory()) continue;
394
- const libPath = path2.join(sLibs, entry.name);
395
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
396
+ const libPath = path3.join(sLibs, entry.name);
397
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
396
398
  errors.push({
397
399
  ruleId: "krnl/concept-manifest-required",
398
400
  filePath: libPath,
@@ -402,12 +404,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
402
404
  }
403
405
  }
404
406
  }
405
- const sFuncs = path2.join(sDir, "functionalities");
407
+ const sFuncs = path3.join(sDir, "functionalities");
406
408
  if (fs.existsSync(sFuncs)) {
407
409
  for (const entry of fs.readdirSync(sFuncs, { withFileTypes: true })) {
408
410
  if (!entry.isDirectory()) continue;
409
- const funcPath = path2.join(sFuncs, entry.name);
410
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
411
+ const funcPath = path3.join(sFuncs, entry.name);
412
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
411
413
  errors.push({
412
414
  ruleId: "krnl/functionality-manifest-required",
413
415
  filePath: funcPath,
@@ -419,12 +421,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
419
421
  }
420
422
  }
421
423
  }
422
- const bLibs = path2.join(backendDir, "libraries");
424
+ const bLibs = path3.join(backendDir, "libraries");
423
425
  if (fs.existsSync(bLibs)) {
424
426
  for (const entry of fs.readdirSync(bLibs, { withFileTypes: true })) {
425
427
  if (!entry.isDirectory()) continue;
426
- const libPath = path2.join(bLibs, entry.name);
427
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
428
+ const libPath = path3.join(bLibs, entry.name);
429
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
428
430
  errors.push({
429
431
  ruleId: "krnl/concept-manifest-required",
430
432
  filePath: libPath,
@@ -434,12 +436,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
434
436
  }
435
437
  }
436
438
  }
437
- const bFuncs = path2.join(backendDir, "functionalities");
439
+ const bFuncs = path3.join(backendDir, "functionalities");
438
440
  if (fs.existsSync(bFuncs)) {
439
441
  for (const entry of fs.readdirSync(bFuncs, { withFileTypes: true })) {
440
442
  if (!entry.isDirectory()) continue;
441
- const funcPath = path2.join(bFuncs, entry.name);
442
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
443
+ const funcPath = path3.join(bFuncs, entry.name);
444
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
443
445
  errors.push({
444
446
  ruleId: "krnl/functionality-manifest-required",
445
447
  filePath: funcPath,
@@ -451,12 +453,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
451
453
  }
452
454
  }
453
455
  if (fs.existsSync(frontendDir)) {
454
- const fLibs = path2.join(frontendDir, "libraries");
456
+ const fLibs = path3.join(frontendDir, "libraries");
455
457
  if (fs.existsSync(fLibs)) {
456
458
  for (const entry of fs.readdirSync(fLibs, { withFileTypes: true })) {
457
459
  if (!entry.isDirectory()) continue;
458
- const libPath = path2.join(fLibs, entry.name);
459
- if (!fs.existsSync(path2.join(libPath, "manifest.json"))) {
460
+ const libPath = path3.join(fLibs, entry.name);
461
+ if (!fs.existsSync(path3.join(libPath, "manifest.json"))) {
460
462
  errors.push({
461
463
  ruleId: "krnl/frontend-concept-manifest-required",
462
464
  filePath: libPath,
@@ -466,12 +468,12 @@ function checkWorkspaceLayout(projectRoot, errors) {
466
468
  }
467
469
  }
468
470
  }
469
- const fFuncs = path2.join(frontendDir, "functionalities");
471
+ const fFuncs = path3.join(frontendDir, "functionalities");
470
472
  if (fs.existsSync(fFuncs)) {
471
473
  for (const entry of fs.readdirSync(fFuncs, { withFileTypes: true })) {
472
474
  if (!entry.isDirectory()) continue;
473
- const funcPath = path2.join(fFuncs, entry.name);
474
- if (!fs.existsSync(path2.join(funcPath, "manifest.json"))) {
475
+ const funcPath = path3.join(fFuncs, entry.name);
476
+ if (!fs.existsSync(path3.join(funcPath, "manifest.json"))) {
475
477
  errors.push({
476
478
  ruleId: "krnl/frontend-functionality-manifest-required",
477
479
  filePath: funcPath,
@@ -562,14 +564,6 @@ var PRIMITIVE_AND_BUILTIN_TYPES = /* @__PURE__ */ new Set([
562
564
  "ReturnType",
563
565
  "InstanceType"
564
566
  ]);
565
- function detectServiceContext(filePath) {
566
- const normalized = filePath.replace(/\\/g, "/");
567
- const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
568
- if (match) {
569
- return { serviceName: match[1], libraryName: match[2] };
570
- }
571
- return null;
572
- }
573
567
  function containsIdentifier(name, target) {
574
568
  return name.toLowerCase().includes(target.toLowerCase());
575
569
  }
@@ -581,7 +575,7 @@ function isCustomContextualType(typeName, serviceName, localTypes) {
581
575
  return false;
582
576
  }
583
577
  function hasContextualTypeReference(node, serviceName, localTypes) {
584
- const typeRefs = node.getDescendantsOfKind(import_ts_morph5.SyntaxKind.TypeReference);
578
+ const typeRefs = node.getDescendantsOfKind(import_ts_morph6.SyntaxKind.TypeReference);
585
579
  for (const ref of typeRefs) {
586
580
  const text = ref.getTypeName().getText().trim();
587
581
  if (isCustomContextualType(text, serviceName, localTypes)) {
@@ -590,6 +584,14 @@ function hasContextualTypeReference(node, serviceName, localTypes) {
590
584
  }
591
585
  return false;
592
586
  }
587
+ function detectServiceContext(filePath) {
588
+ const normalized = filePath.replace(/\\/g, "/");
589
+ const match = normalized.match(/(?:^|\/)services\/([^/]+)\/libraries\/([^/]+)/);
590
+ if (match) {
591
+ return { serviceName: match[1], libraryName: match[2] };
592
+ }
593
+ return null;
594
+ }
593
595
  function checkScopedLibraryRules(sf) {
594
596
  const errors = [];
595
597
  const warnings = [];
@@ -728,13 +730,13 @@ var KrnlValidatorEngine = class {
728
730
  limitOptions;
729
731
  constructor(optionsOrRoot) {
730
732
  const options = typeof optionsOrRoot === "string" ? { projectRoot: optionsOrRoot } : optionsOrRoot;
731
- this.projectRoot = path3.resolve(options.projectRoot || process.cwd());
733
+ this.projectRoot = path4.resolve(options.projectRoot || process.cwd());
732
734
  this.limitOptions = {
733
735
  maxFileLineLimit: options.maxFileLineLimit ?? 200,
734
736
  maxMainLogicLimit: options.maxMainLogicLimit ?? 20,
735
737
  maxHelperLineLimit: options.maxHelperLineLimit ?? 30
736
738
  };
737
- const tsConfigPath = path3.join(this.projectRoot, "tsconfig.json");
739
+ const tsConfigPath = path4.join(this.projectRoot, "tsconfig.json");
738
740
  if (fs2.existsSync(tsConfigPath)) {
739
741
  this.project = new import_ts_morph.Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
740
742
  } else {
@@ -769,7 +771,7 @@ var KrnlValidatorEngine = class {
769
771
  }
770
772
  validateSourceFile(sf) {
771
773
  const filePath = sf.getFilePath();
772
- const baseName = path3.basename(filePath);
774
+ const baseName = path4.basename(filePath);
773
775
  if (baseName.includes("_pb.") || baseName.endsWith(".d.ts")) {
774
776
  return { errors: [], warnings: [], promotableAssets: [] };
775
777
  }
@@ -804,7 +806,7 @@ var KrnlValidatorEngine = class {
804
806
  const entries = fs2.readdirSync(dir, { withFileTypes: true });
805
807
  for (const entry of entries) {
806
808
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
807
- const full = path3.join(dir, entry.name);
809
+ const full = path4.join(dir, entry.name);
808
810
  if (entry.isDirectory()) {
809
811
  this.collectSourceFiles(full, collected);
810
812
  } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js") || entry.name.endsWith(".tsx") || entry.name.endsWith(".jsx"))) {
@@ -852,24 +854,24 @@ async function runValidate(projectRoot = process.cwd()) {
852
854
  }
853
855
 
854
856
  // src/commands/generators/functionalityOrchestrationGenerator.ts
855
- var path5 = __toESM(require("path"), 1);
857
+ var path6 = __toESM(require("path"), 1);
856
858
  var fs4 = __toESM(require("fs"), 1);
857
859
 
858
860
  // src/commands/generators/common.ts
859
861
  var fs3 = __toESM(require("fs"), 1);
860
- var path4 = __toESM(require("path"), 1);
862
+ var path5 = __toESM(require("path"), 1);
861
863
  function getPlaneRoots(projectRoot) {
862
- const krnlRoot = path4.join(projectRoot, "krnl");
864
+ const krnlRoot = path5.join(projectRoot, "krnl");
863
865
  if (fs3.existsSync(krnlRoot)) {
864
866
  return {
865
- backend: path4.join(krnlRoot, "backend"),
866
- frontend: path4.join(krnlRoot, "frontend"),
867
+ backend: path5.join(krnlRoot, "backend"),
868
+ frontend: path5.join(krnlRoot, "frontend"),
867
869
  isKrnlDir: true
868
870
  };
869
871
  }
870
872
  return {
871
- backend: path4.join(projectRoot, "src"),
872
- frontend: path4.join(projectRoot, "src"),
873
+ backend: path5.join(projectRoot, "src"),
874
+ frontend: path5.join(projectRoot, "src"),
873
875
  isKrnlDir: false
874
876
  };
875
877
  }
@@ -877,10 +879,10 @@ function getPlaneRoots(projectRoot) {
877
879
  // src/commands/generators/functionalityOrchestrationGenerator.ts
878
880
  function generateFunctionalityOrchestration(name, projectRoot) {
879
881
  const { backend } = getPlaneRoots(projectRoot);
880
- const orchDir = path5.join(backend, "orchestrations", name);
881
- fs4.mkdirSync(path5.join(orchDir, "tests"), { recursive: true });
882
+ const orchDir = path6.join(backend, "orchestrations", name);
883
+ fs4.mkdirSync(path6.join(orchDir, "tests"), { recursive: true });
882
884
  fs4.writeFileSync(
883
- path5.join(orchDir, `${name}FunctionalityOrchestration.ts`),
885
+ path6.join(orchDir, `${name}FunctionalityOrchestration.ts`),
884
886
  `import { FunctionalityOrchestration } from '@ultrst-armada/krnl-core';
885
887
 
886
888
  /**
@@ -906,7 +908,7 @@ export default ${name}FunctionalityOrchestration;
906
908
  `
907
909
  );
908
910
  fs4.writeFileSync(
909
- path5.join(orchDir, "tests", `${name}FunctionalityOrchestration.test.ts`),
911
+ path6.join(orchDir, "tests", `${name}FunctionalityOrchestration.test.ts`),
910
912
  `import { describe, it, expect } from 'vitest';
911
913
  import { ${name}FunctionalityOrchestration } from '../${name}FunctionalityOrchestration.js';
912
914
 
@@ -925,11 +927,11 @@ describe('${name}FunctionalityOrchestration', () => {
925
927
 
926
928
  // src/commands/generators/functionalityGenerator.ts
927
929
  var fs6 = __toESM(require("fs"), 1);
928
- var path7 = __toESM(require("path"), 1);
930
+ var path8 = __toESM(require("path"), 1);
929
931
 
930
932
  // ../core/dist/index.js
931
933
  var fs5 = __toESM(require("fs"), 1);
932
- var path6 = __toESM(require("path"), 1);
934
+ var path7 = __toESM(require("path"), 1);
933
935
  var import_gutts = require("@dinilmusick/gutts");
934
936
  var gutts = __toESM(require("@dinilmusick/gutts"), 1);
935
937
  var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
@@ -982,7 +984,7 @@ var KrnlPackageReconciler = class {
982
984
  }
983
985
  resolvedDevDeps[pkg] = versions[versions.length - 1];
984
986
  }
985
- const pkgJsonPath = path6.join(projectRoot, "package.json");
987
+ const pkgJsonPath = path7.join(projectRoot, "package.json");
986
988
  let updated = false;
987
989
  if (fs5.existsSync(pkgJsonPath)) {
988
990
  const pkgContent = JSON.parse(fs5.readFileSync(pkgJsonPath, "utf8"));
@@ -1020,15 +1022,15 @@ var KrnlPackageReconciler = class {
1020
1022
  */
1021
1023
  static findManifests(projectRoot) {
1022
1024
  const searchDirs = [
1023
- path6.join(projectRoot, "krnl", "backend", "services"),
1024
- path6.join(projectRoot, "krnl", "backend", "libraries"),
1025
- path6.join(projectRoot, "krnl", "backend", "functionalities"),
1026
- path6.join(projectRoot, "krnl", "frontend", "libraries"),
1027
- path6.join(projectRoot, "krnl", "frontend", "functionalities"),
1028
- path6.join(projectRoot, "src", "backend", "services"),
1029
- path6.join(projectRoot, "src", "services"),
1030
- path6.join(projectRoot, "src", "functionalities"),
1031
- path6.join(projectRoot, "src", "libraries")
1025
+ path7.join(projectRoot, "krnl", "backend", "services"),
1026
+ path7.join(projectRoot, "krnl", "backend", "libraries"),
1027
+ path7.join(projectRoot, "krnl", "backend", "functionalities"),
1028
+ path7.join(projectRoot, "krnl", "frontend", "libraries"),
1029
+ path7.join(projectRoot, "krnl", "frontend", "functionalities"),
1030
+ path7.join(projectRoot, "src", "backend", "services"),
1031
+ path7.join(projectRoot, "src", "services"),
1032
+ path7.join(projectRoot, "src", "functionalities"),
1033
+ path7.join(projectRoot, "src", "libraries")
1032
1034
  ];
1033
1035
  const found = [];
1034
1036
  for (const dir of searchDirs) {
@@ -1043,7 +1045,7 @@ var KrnlPackageReconciler = class {
1043
1045
  const entries = fs5.readdirSync(dir, { withFileTypes: true });
1044
1046
  for (const entry of entries) {
1045
1047
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
1046
- const full = path6.join(dir, entry.name);
1048
+ const full = path7.join(dir, entry.name);
1047
1049
  if (entry.isDirectory()) {
1048
1050
  this.scanRecursive(full, found);
1049
1051
  } else if (entry.isFile() && entry.name === "manifest.json") {
@@ -1061,7 +1063,7 @@ function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
1061
1063
  const options = typeof parentServiceOrOptions === "string" ? { parentService: parentServiceOrOptions } : parentServiceOrOptions || {};
1062
1064
  let targetService = options.parentService;
1063
1065
  if (!targetService) {
1064
- const servicesDir = path7.join(backend, "services");
1066
+ const servicesDir = path8.join(backend, "services");
1065
1067
  if (fs6.existsSync(servicesDir)) {
1066
1068
  const existing = fs6.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
1067
1069
  if (existing.length === 1) {
@@ -1069,15 +1071,15 @@ function generateFunctionality(name, projectRoot, parentServiceOrOptions) {
1069
1071
  }
1070
1072
  }
1071
1073
  }
1072
- const bFuncDir = targetService ? path7.join(backend, "services", targetService, "functionalities", name) : path7.join(backend, "functionalities", name);
1073
- fs6.mkdirSync(path7.join(bFuncDir, "main_function"), { recursive: true });
1074
- fs6.mkdirSync(path7.join(bFuncDir, "helper_functions"), { recursive: true });
1075
- fs6.mkdirSync(path7.join(bFuncDir, "events"), { recursive: true });
1076
- fs6.mkdirSync(path7.join(bFuncDir, "tests"), { recursive: true });
1074
+ const bFuncDir = targetService ? path8.join(backend, "services", targetService, "functionalities", name) : path8.join(backend, "functionalities", name);
1075
+ fs6.mkdirSync(path8.join(bFuncDir, "main_function"), { recursive: true });
1076
+ fs6.mkdirSync(path8.join(bFuncDir, "helper_functions"), { recursive: true });
1077
+ fs6.mkdirSync(path8.join(bFuncDir, "events"), { recursive: true });
1078
+ fs6.mkdirSync(path8.join(bFuncDir, "tests"), { recursive: true });
1077
1079
  if (options.withState) {
1078
- fs6.mkdirSync(path7.join(bFuncDir, "state_data"), { recursive: true });
1080
+ fs6.mkdirSync(path8.join(bFuncDir, "state_data"), { recursive: true });
1079
1081
  fs6.writeFileSync(
1080
- path7.join(bFuncDir, "state_data", "state.ts"),
1082
+ path8.join(bFuncDir, "state_data", "state.ts"),
1081
1083
  `export interface ${name}State {
1082
1084
  executionCount: number;
1083
1085
  }
@@ -1089,7 +1091,7 @@ export const initialState: ${name}State = {
1089
1091
  );
1090
1092
  }
1091
1093
  fs6.writeFileSync(
1092
- path7.join(bFuncDir, `${name}Atom.ts`),
1094
+ path8.join(bFuncDir, `${name}Atom.ts`),
1093
1095
  `export interface ${name}Input {
1094
1096
  payload?: string;
1095
1097
  }
@@ -1101,7 +1103,7 @@ export interface ${name}Output {
1101
1103
  `
1102
1104
  );
1103
1105
  fs6.writeFileSync(
1104
- path7.join(bFuncDir, "manifest.json"),
1106
+ path8.join(bFuncDir, "manifest.json"),
1105
1107
  JSON.stringify(
1106
1108
  {
1107
1109
  name,
@@ -1114,7 +1116,7 @@ export interface ${name}Output {
1114
1116
  )
1115
1117
  );
1116
1118
  fs6.writeFileSync(
1117
- path7.join(bFuncDir, "main_function", "logic.ts"),
1119
+ path8.join(bFuncDir, "main_function", "logic.ts"),
1118
1120
  `import type { ${name}Input, ${name}Output } from "../${name}Atom.js";
1119
1121
 
1120
1122
  export const main = async (input: ${name}Input, context: any): Promise<${name}Output> => {
@@ -1126,13 +1128,13 @@ export const main = async (input: ${name}Input, context: any): Promise<${name}Ou
1126
1128
  `
1127
1129
  );
1128
1130
  fs6.writeFileSync(
1129
- path7.join(bFuncDir, "main_function", "lifecycle.ts"),
1131
+ path8.join(bFuncDir, "main_function", "lifecycle.ts"),
1130
1132
  `export async function onMount() {}
1131
1133
  export async function onTeardown() {}
1132
1134
  `
1133
1135
  );
1134
1136
  fs6.writeFileSync(
1135
- path7.join(bFuncDir, "helper_functions", "helper.ts"),
1137
+ path8.join(bFuncDir, "helper_functions", "helper.ts"),
1136
1138
  `/**
1137
1139
  * @role component
1138
1140
  */
@@ -1142,7 +1144,7 @@ export function exampleHelper(): boolean {
1142
1144
  `
1143
1145
  );
1144
1146
  fs6.writeFileSync(
1145
- path7.join(bFuncDir, "events", "events.ts"),
1147
+ path8.join(bFuncDir, "events", "events.ts"),
1146
1148
  `/**
1147
1149
  * @role component
1148
1150
  */
@@ -1152,7 +1154,7 @@ export interface ${name}CompletedEvent {
1152
1154
  `
1153
1155
  );
1154
1156
  fs6.writeFileSync(
1155
- path7.join(bFuncDir, "tests", `${name}.test.ts`),
1157
+ path8.join(bFuncDir, "tests", `${name}.test.ts`),
1156
1158
  `import { describe, it, expect } from "vitest";
1157
1159
 
1158
1160
  describe("${name} functionality", () => {
@@ -1162,10 +1164,10 @@ describe("${name} functionality", () => {
1162
1164
  });
1163
1165
  `
1164
1166
  );
1165
- const fFuncDir = path7.join(frontend, "functionalities", name);
1166
- fs6.mkdirSync(path7.join(fFuncDir, "tests"), { recursive: true });
1167
+ const fFuncDir = path8.join(frontend, "functionalities", name);
1168
+ fs6.mkdirSync(path8.join(fFuncDir, "tests"), { recursive: true });
1167
1169
  fs6.writeFileSync(
1168
- path7.join(fFuncDir, `${name}0.tsx`),
1170
+ path8.join(fFuncDir, `${name}0.tsx`),
1169
1171
  `import React from "react";
1170
1172
 
1171
1173
  export const ${name}0: React.FC = () => {
@@ -1180,11 +1182,11 @@ export default ${name}0;
1180
1182
  `
1181
1183
  );
1182
1184
  fs6.writeFileSync(
1183
- path7.join(fFuncDir, "manifest.json"),
1185
+ path8.join(fFuncDir, "manifest.json"),
1184
1186
  JSON.stringify({ name: `${name}UI`, dependencies: {} }, null, 2)
1185
1187
  );
1186
1188
  fs6.writeFileSync(
1187
- path7.join(fFuncDir, "tests", `${name}0.test.tsx`),
1189
+ path8.join(fFuncDir, "tests", `${name}0.test.tsx`),
1188
1190
  `import { describe, it, expect } from "vitest";
1189
1191
 
1190
1192
  describe("${name}0 Component", () => {
@@ -1195,19 +1197,19 @@ describe("${name}0 Component", () => {
1195
1197
  `
1196
1198
  );
1197
1199
  KrnlPackageReconciler.reconcile(projectRoot, true);
1198
- console.log(`\u2705 Created Backend Functionality: ${path7.relative(projectRoot, bFuncDir)}/`);
1199
- console.log(`\u2705 Created Frontend Functionality: ${path7.relative(projectRoot, fFuncDir)}/`);
1200
+ console.log(`\u2705 Created Backend Functionality: ${path8.relative(projectRoot, bFuncDir)}/`);
1201
+ console.log(`\u2705 Created Frontend Functionality: ${path8.relative(projectRoot, fFuncDir)}/`);
1200
1202
  }
1201
1203
 
1202
1204
  // src/commands/generators/libraryGenerator.ts
1203
1205
  var fs7 = __toESM(require("fs"), 1);
1204
- var path8 = __toESM(require("path"), 1);
1206
+ var path9 = __toESM(require("path"), 1);
1205
1207
  function generateLibrary(name, projectRoot, parentService) {
1206
1208
  const { backend, frontend } = getPlaneRoots(projectRoot);
1207
1209
  const conceptName = name.endsWith("Concepts") ? name : `${name}Concepts`;
1208
1210
  let targetService = parentService;
1209
1211
  if (!targetService) {
1210
- const servicesDir = path8.join(backend, "services");
1212
+ const servicesDir = path9.join(backend, "services");
1211
1213
  if (fs7.existsSync(servicesDir)) {
1212
1214
  const existing = fs7.readdirSync(servicesDir, { withFileTypes: true }).filter((d) => d.isDirectory());
1213
1215
  if (existing.length === 1) {
@@ -1218,10 +1220,10 @@ function generateLibrary(name, projectRoot, parentService) {
1218
1220
  if (!targetService) {
1219
1221
  targetService = "App";
1220
1222
  }
1221
- const bLibDir = path8.join(backend, "services", targetService, "libraries", conceptName);
1222
- fs7.mkdirSync(path8.join(bLibDir, "tests"), { recursive: true });
1223
+ const bLibDir = path9.join(backend, "services", targetService, "libraries", conceptName);
1224
+ fs7.mkdirSync(path9.join(bLibDir, "tests"), { recursive: true });
1223
1225
  fs7.writeFileSync(
1224
- path8.join(bLibDir, "definitions.ts"),
1226
+ path9.join(bLibDir, "definitions.ts"),
1225
1227
  `/**
1226
1228
  * @file definitions.ts
1227
1229
  * @role component
@@ -1232,7 +1234,7 @@ export interface ${conceptName}Options {
1232
1234
  `
1233
1235
  );
1234
1236
  fs7.writeFileSync(
1235
- path8.join(bLibDir, "functions.ts"),
1237
+ path9.join(bLibDir, "functions.ts"),
1236
1238
  `/**
1237
1239
  * @file functions.ts
1238
1240
  * @role component
@@ -1245,17 +1247,17 @@ export function ${name.toLowerCase()}Transform<T>(data: T, _opts?: ${conceptName
1245
1247
  `
1246
1248
  );
1247
1249
  fs7.writeFileSync(
1248
- path8.join(bLibDir, "index.ts"),
1250
+ path9.join(bLibDir, "index.ts"),
1249
1251
  `export * from "./definitions.js";
1250
1252
  export * from "./functions.js";
1251
1253
  `
1252
1254
  );
1253
1255
  fs7.writeFileSync(
1254
- path8.join(bLibDir, "manifest.json"),
1256
+ path9.join(bLibDir, "manifest.json"),
1255
1257
  JSON.stringify({ name: conceptName, service: targetService, dependencies: {} }, null, 2)
1256
1258
  );
1257
1259
  fs7.writeFileSync(
1258
- path8.join(bLibDir, "tests", `${conceptName}.test.ts`),
1260
+ path9.join(bLibDir, "tests", `${conceptName}.test.ts`),
1259
1261
  `import { describe, it, expect } from "vitest";
1260
1262
  import { ${name.toLowerCase()}Transform } from "../functions.js";
1261
1263
 
@@ -1266,17 +1268,17 @@ describe("${conceptName}", () => {
1266
1268
  });
1267
1269
  `
1268
1270
  );
1269
- const fLibDir = path8.join(frontend, "libraries", conceptName);
1270
- fs7.mkdirSync(path8.join(fLibDir, "tests"), { recursive: true });
1271
+ const fLibDir = path9.join(frontend, "libraries", conceptName);
1272
+ fs7.mkdirSync(path9.join(fLibDir, "tests"), { recursive: true });
1271
1273
  fs7.writeFileSync(
1272
- path8.join(fLibDir, "definitions.ts"),
1274
+ path9.join(fLibDir, "definitions.ts"),
1273
1275
  `export interface ${name}Props {
1274
1276
  label?: string;
1275
1277
  }
1276
1278
  `
1277
1279
  );
1278
1280
  fs7.writeFileSync(
1279
- path8.join(fLibDir, "components.tsx"),
1281
+ path9.join(fLibDir, "components.tsx"),
1280
1282
  `import React from "react";
1281
1283
  import type { ${name}Props } from "./definitions.js";
1282
1284
  import "./styles.css";
@@ -1287,18 +1289,18 @@ export const ${name}: React.FC<${name}Props> = ({ label = "${name}" }) => {
1287
1289
  `
1288
1290
  );
1289
1291
  fs7.writeFileSync(
1290
- path8.join(fLibDir, "styles.css"),
1292
+ path9.join(fLibDir, "styles.css"),
1291
1293
  `.krnl-${name.toLowerCase()} {
1292
1294
  font-family: inherit;
1293
1295
  }
1294
1296
  `
1295
1297
  );
1296
1298
  fs7.writeFileSync(
1297
- path8.join(fLibDir, "manifest.json"),
1299
+ path9.join(fLibDir, "manifest.json"),
1298
1300
  JSON.stringify({ name: `${conceptName}UI`, dependencies: {} }, null, 2)
1299
1301
  );
1300
1302
  fs7.writeFileSync(
1301
- path8.join(fLibDir, "tests", `${name}.test.tsx`),
1303
+ path9.join(fLibDir, "tests", `${name}.test.tsx`),
1302
1304
  `import { describe, it, expect } from "vitest";
1303
1305
 
1304
1306
  describe("${name} UI Concept", () => {
@@ -1309,13 +1311,13 @@ describe("${name} UI Concept", () => {
1309
1311
  `
1310
1312
  );
1311
1313
  KrnlPackageReconciler.reconcile(projectRoot, true);
1312
- console.log(`\u2705 Created Service-Owned Library: ${path8.relative(projectRoot, bLibDir)}/ (Owner: ${targetService})`);
1313
- console.log(`\u2705 Created Frontend Concept Library: ${path8.relative(projectRoot, fLibDir)}/`);
1314
+ console.log(`\u2705 Created Service-Owned Library: ${path9.relative(projectRoot, bLibDir)}/ (Owner: ${targetService})`);
1315
+ console.log(`\u2705 Created Frontend Concept Library: ${path9.relative(projectRoot, fLibDir)}/`);
1314
1316
  }
1315
1317
 
1316
1318
  // src/commands/generators/serviceGenerator.ts
1317
1319
  var fs8 = __toESM(require("fs"), 1);
1318
- var path9 = __toESM(require("path"), 1);
1320
+ var path10 = __toESM(require("path"), 1);
1319
1321
  function generateService(name, projectRoot, defaultFrontend) {
1320
1322
  const frontendReference = defaultFrontend?.component ? {
1321
1323
  component: defaultFrontend.component,
@@ -1325,20 +1327,20 @@ function generateService(name, projectRoot, defaultFrontend) {
1325
1327
  } : void 0;
1326
1328
  const frontendConfig = frontendReference ? JSON.stringify(frontendReference, null, 2).replace(/\n/g, "\n ") : void 0;
1327
1329
  const { backend } = getPlaneRoots(projectRoot);
1328
- const serviceDir = path9.join(backend, "services", name);
1329
- const funcsDir = path9.join(serviceDir, "functionalities");
1330
- const orchsDir = path9.join(serviceDir, "orchestrations");
1331
- const libsDir = path9.join(serviceDir, "libraries");
1332
- const testsDir = path9.join(serviceDir, "tests");
1330
+ const serviceDir = path10.join(backend, "services", name);
1331
+ const funcsDir = path10.join(serviceDir, "functionalities");
1332
+ const orchsDir = path10.join(serviceDir, "orchestrations");
1333
+ const libsDir = path10.join(serviceDir, "libraries");
1334
+ const testsDir = path10.join(serviceDir, "tests");
1333
1335
  fs8.mkdirSync(funcsDir, { recursive: true });
1334
1336
  fs8.mkdirSync(orchsDir, { recursive: true });
1335
1337
  fs8.mkdirSync(libsDir, { recursive: true });
1336
1338
  fs8.mkdirSync(testsDir, { recursive: true });
1337
1339
  const conceptName = `${name}Concepts`;
1338
- const defaultLibDir = path9.join(libsDir, conceptName);
1339
- fs8.mkdirSync(path9.join(defaultLibDir, "tests"), { recursive: true });
1340
+ const defaultLibDir = path10.join(libsDir, conceptName);
1341
+ fs8.mkdirSync(path10.join(defaultLibDir, "tests"), { recursive: true });
1340
1342
  fs8.writeFileSync(
1341
- path9.join(defaultLibDir, "definitions.ts"),
1343
+ path10.join(defaultLibDir, "definitions.ts"),
1342
1344
  `/**
1343
1345
  * @file definitions.ts
1344
1346
  * @role component
@@ -1349,7 +1351,7 @@ export interface ${name}Options {
1349
1351
  `
1350
1352
  );
1351
1353
  fs8.writeFileSync(
1352
- path9.join(defaultLibDir, "functions.ts"),
1354
+ path10.join(defaultLibDir, "functions.ts"),
1353
1355
  `/**
1354
1356
  * @file functions.ts
1355
1357
  * @role component
@@ -1362,17 +1364,17 @@ export function format${name}Name(input: string, _opts?: ${name}Options): string
1362
1364
  `
1363
1365
  );
1364
1366
  fs8.writeFileSync(
1365
- path9.join(defaultLibDir, "index.ts"),
1367
+ path10.join(defaultLibDir, "index.ts"),
1366
1368
  `export * from "./definitions.js";
1367
1369
  export * from "./functions.js";
1368
1370
  `
1369
1371
  );
1370
1372
  fs8.writeFileSync(
1371
- path9.join(defaultLibDir, "manifest.json"),
1373
+ path10.join(defaultLibDir, "manifest.json"),
1372
1374
  JSON.stringify({ name: conceptName, description: `${name} service-owned library`, dependencies: {} }, null, 2)
1373
1375
  );
1374
1376
  fs8.writeFileSync(
1375
- path9.join(defaultLibDir, "tests", `${conceptName}.test.ts`),
1377
+ path10.join(defaultLibDir, "tests", `${conceptName}.test.ts`),
1376
1378
  `import { describe, it, expect } from "vitest";
1377
1379
  import { format${name}Name } from "../functions.js";
1378
1380
 
@@ -1386,7 +1388,7 @@ describe("${conceptName}", () => {
1386
1388
  const frontendProperty = frontendConfig ? ` defaultFrontend: ${frontendConfig},
1387
1389
  ` : "";
1388
1390
  fs8.writeFileSync(
1389
- path9.join(serviceDir, `${name}ServiceFacade.ts`),
1391
+ path10.join(serviceDir, `${name}ServiceFacade.ts`),
1390
1392
  `import { ServiceFacade } from "@ultrst-armada/krnl-core";
1391
1393
  import * as ${name.toLowerCase()}Concepts from "./libraries/${conceptName}/index.js";
1392
1394
 
@@ -1404,7 +1406,7 @@ export default ${name}ServiceFacade;
1404
1406
  `
1405
1407
  );
1406
1408
  fs8.writeFileSync(
1407
- path9.join(testsDir, `${name}ServiceFacade.test.ts`),
1409
+ path10.join(testsDir, `${name}ServiceFacade.test.ts`),
1408
1410
  `import { describe, it, expect } from "vitest";
1409
1411
  import { ${name}ServiceFacade } from "../${name}ServiceFacade.js";
1410
1412
 
@@ -1418,7 +1420,7 @@ describe("${name}ServiceFacade", () => {
1418
1420
  `
1419
1421
  );
1420
1422
  KrnlPackageReconciler.reconcile(projectRoot, true);
1421
- console.log(`\u2705 Created Service: ${path9.relative(projectRoot, serviceDir)}/`);
1423
+ console.log(`\u2705 Created Service: ${path10.relative(projectRoot, serviceDir)}/`);
1422
1424
  }
1423
1425
 
1424
1426
  // src/commands/generate.ts
@@ -1454,7 +1456,7 @@ async function runGenerate(type, name, parentService, projectRoot = process.cwd(
1454
1456
 
1455
1457
  // src/commands/watch.ts
1456
1458
  var fs9 = __toESM(require("fs"), 1);
1457
- var path10 = __toESM(require("path"), 1);
1459
+ var path11 = __toESM(require("path"), 1);
1458
1460
  function generateMagneticDeclarations(projectRoot = process.cwd()) {
1459
1461
  const { results: functionalities, libDirs } = scanDirectory(projectRoot);
1460
1462
  let dtsContent = `// Automatically generated by Krnl Magnetic Watcher. Do not edit manually.
@@ -1465,14 +1467,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
1465
1467
  `;
1466
1468
  const globalDeclarations = [];
1467
1469
  for (const func of functionalities) {
1468
- const helpersDir = path10.join(func.funcPath, "helper_functions");
1470
+ const helpersDir = path11.join(func.funcPath, "helper_functions");
1469
1471
  if (fs9.existsSync(helpersDir)) {
1470
1472
  const files = fs9.readdirSync(helpersDir);
1471
1473
  for (const file of files) {
1472
1474
  if (file.endsWith(".js") || file.endsWith(".ts")) {
1473
- const filePath = path10.join(helpersDir, file);
1474
- const baseName = path10.basename(file, path10.extname(file));
1475
- const importPath = `./${path10.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1475
+ const filePath = path11.join(helpersDir, file);
1476
+ const baseName = path11.basename(file, path11.extname(file));
1477
+ const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1476
1478
  const { named, hasDefault } = parseExports(filePath, baseName);
1477
1479
  if (hasDefault) {
1478
1480
  globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
@@ -1483,14 +1485,14 @@ function generateMagneticDeclarations(projectRoot = process.cwd()) {
1483
1485
  }
1484
1486
  }
1485
1487
  }
1486
- const eventsDir = path10.join(func.funcPath, "events");
1488
+ const eventsDir = path11.join(func.funcPath, "events");
1487
1489
  if (fs9.existsSync(eventsDir)) {
1488
1490
  const files = fs9.readdirSync(eventsDir);
1489
1491
  for (const file of files) {
1490
1492
  if (file.endsWith(".js") || file.endsWith(".ts")) {
1491
- const filePath = path10.join(eventsDir, file);
1492
- const baseName = path10.basename(file, path10.extname(file));
1493
- const importPath = `./${path10.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1493
+ const filePath = path11.join(eventsDir, file);
1494
+ const baseName = path11.basename(file, path11.extname(file));
1495
+ const importPath = `./${path11.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
1494
1496
  const { named, hasDefault } = parseExports(filePath, baseName);
1495
1497
  if (hasDefault) {
1496
1498
  globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
@@ -1511,7 +1513,7 @@ ${Array.from(new Set(globalDeclarations)).join("\n")}
1511
1513
  }
1512
1514
  `;
1513
1515
  }
1514
- const outPath = path10.join(projectRoot, "krnl-magnetic.d.ts");
1516
+ const outPath = path11.join(projectRoot, "krnl-magnetic.d.ts");
1515
1517
  fs9.writeFileSync(outPath, dtsContent);
1516
1518
  console.log(`[Krnl Watch] Updated ambient declarations: ${outPath}`);
1517
1519
  }
@@ -1519,12 +1521,12 @@ function scanLibFiles(dir, projectRoot, decls) {
1519
1521
  if (!fs9.existsSync(dir)) return;
1520
1522
  for (const entry of fs9.readdirSync(dir, { withFileTypes: true })) {
1521
1523
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
1522
- const full = path10.join(dir, entry.name);
1524
+ const full = path11.join(dir, entry.name);
1523
1525
  if (entry.isDirectory()) {
1524
1526
  scanLibFiles(full, projectRoot, decls);
1525
1527
  } else if ((entry.name.endsWith(".ts") || entry.name.endsWith(".js")) && !entry.name.endsWith(".d.ts")) {
1526
- const baseName = path10.basename(entry.name, path10.extname(entry.name));
1527
- const importPath = `./${path10.relative(projectRoot, full).replace(/\\/g, "/")}`;
1528
+ const baseName = path11.basename(entry.name, path11.extname(entry.name));
1529
+ const importPath = `./${path11.relative(projectRoot, full).replace(/\\/g, "/")}`;
1528
1530
  const { named, hasDefault } = parseExports(full, baseName);
1529
1531
  if (hasDefault) decls.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
1530
1532
  for (const n of named) decls.push(` const ${n}: typeof import('${importPath}')['${n}'];`);
@@ -1537,11 +1539,11 @@ function scanDirectory(dir, results = [], libDirs = []) {
1537
1539
  for (const entry of list) {
1538
1540
  if (entry.isDirectory()) {
1539
1541
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
1540
- const fullPath = path10.join(dir, entry.name);
1542
+ const fullPath = path11.join(dir, entry.name);
1541
1543
  if (entry.name === "functionalities") {
1542
1544
  const funcs = fs9.readdirSync(fullPath, { withFileTypes: true });
1543
1545
  for (const f of funcs) {
1544
- if (f.isDirectory()) results.push({ funcPath: path10.join(fullPath, f.name), funcName: f.name });
1546
+ if (f.isDirectory()) results.push({ funcPath: path11.join(fullPath, f.name), funcName: f.name });
1545
1547
  }
1546
1548
  } else if (entry.name === "libraries" || entry.name === "library") {
1547
1549
  libDirs.push(fullPath);
@@ -1568,7 +1570,7 @@ function parseExports(filePath, defaultName) {
1568
1570
  }
1569
1571
 
1570
1572
  // src/commands/build.ts
1571
- var path11 = __toESM(require("path"), 1);
1573
+ var path12 = __toESM(require("path"), 1);
1572
1574
  var fs10 = __toESM(require("fs"), 1);
1573
1575
  var import_child_process = require("child_process");
1574
1576
  async function runBuild(projectRoot = process.cwd(), options = {}) {
@@ -1586,10 +1588,10 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
1586
1588
  return { success: false, error: "Validation failed" };
1587
1589
  }
1588
1590
  generateMagneticDeclarations(projectRoot);
1589
- const tsConfigPath = path11.join(projectRoot, "tsconfig.json");
1591
+ const tsConfigPath = path12.join(projectRoot, "tsconfig.json");
1590
1592
  if (fs10.existsSync(tsConfigPath)) {
1591
1593
  console.log("\u{1F3D7}\uFE0F [Krnl Build] Compiling TypeScript source files to dist/...");
1592
- const localTsc = path11.join(projectRoot, "node_modules", ".bin", "tsc");
1594
+ const localTsc = path12.join(projectRoot, "node_modules", ".bin", "tsc");
1593
1595
  const tscCmd = fs10.existsSync(localTsc) ? localTsc : "tsc";
1594
1596
  try {
1595
1597
  (0, import_child_process.execSync)(`${tscCmd} -p tsconfig.json`, { cwd: projectRoot, stdio: "inherit" });
@@ -1606,7 +1608,7 @@ async function runBuild(projectRoot = process.cwd(), options = {}) {
1606
1608
 
1607
1609
  // src/commands/dev.ts
1608
1610
  var http = __toESM(require("http"), 1);
1609
- var path12 = __toESM(require("path"), 1);
1611
+ var path13 = __toESM(require("path"), 1);
1610
1612
  var fs11 = __toESM(require("fs"), 1);
1611
1613
  async function runDev(projectRoot = process.cwd(), options = {}) {
1612
1614
  const port = options.port ?? 8080;
@@ -1629,7 +1631,7 @@ async function runDev(projectRoot = process.cwd(), options = {}) {
1629
1631
  return;
1630
1632
  }
1631
1633
  if (url.pathname === "/manifest") {
1632
- const pkgPath = path12.join(projectRoot, "package.json");
1634
+ const pkgPath = path13.join(projectRoot, "package.json");
1633
1635
  const pkg = fs11.existsSync(pkgPath) ? JSON.parse(fs11.readFileSync(pkgPath, "utf8")) : {};
1634
1636
  res.writeHead(200);
1635
1637
  res.end(JSON.stringify({ name: pkg.name || "krnl-app", version: pkg.version || "1.0.0" }));