@kitsy/cnos 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/build/index.cjs +333 -117
  2. package/dist/build/index.d.cts +3 -2
  3. package/dist/build/index.d.ts +3 -2
  4. package/dist/build/index.js +13 -8
  5. package/dist/{chunk-HMM76UYZ.js → chunk-BMAD24KC.js} +1 -1
  6. package/dist/{chunk-ZTPSFXWP.js → chunk-JYWQFMW5.js} +1 -1
  7. package/dist/{chunk-FWJC4Y2D.js → chunk-MW4OVAT3.js} +1 -1
  8. package/dist/chunk-QU5CXL47.js +577 -0
  9. package/dist/{chunk-APIU4GTB.js → chunk-S7H2UULC.js} +315 -107
  10. package/dist/{chunk-WCHX2QFY.js → chunk-UJBQS7CJ.js} +1 -1
  11. package/dist/{chunk-RYGSG3GR.js → chunk-UOKVLCFL.js} +10 -10
  12. package/dist/{chunk-T6Y57KTT.js → chunk-UR7CHHNN.js} +1 -1
  13. package/dist/{chunk-J4K4JUJL.js → chunk-VGZREX5D.js} +1 -1
  14. package/dist/{chunk-EQSKV3DP.js → chunk-XSUP7JKH.js} +23 -1
  15. package/dist/configure/index.cjs +332 -122
  16. package/dist/configure/index.d.cts +3 -3
  17. package/dist/configure/index.d.ts +3 -3
  18. package/dist/configure/index.js +8 -8
  19. package/dist/{envNaming-Dvm_LP2D.d.ts → envNaming-B7Mztkcf.d.ts} +1 -1
  20. package/dist/{envNaming-S4B-dHUx.d.cts → envNaming-gMVnPOfe.d.cts} +1 -1
  21. package/dist/index.cjs +754 -143
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/internal.cjs +229 -103
  26. package/dist/internal.d.cts +16 -28
  27. package/dist/internal.d.ts +16 -28
  28. package/dist/internal.js +11 -3
  29. package/dist/plugin/basic-schema.cjs +22 -15
  30. package/dist/plugin/basic-schema.d.cts +1 -1
  31. package/dist/plugin/basic-schema.d.ts +1 -1
  32. package/dist/plugin/basic-schema.js +2 -2
  33. package/dist/plugin/cli-args.cjs +27 -18
  34. package/dist/plugin/cli-args.d.cts +1 -1
  35. package/dist/plugin/cli-args.d.ts +1 -1
  36. package/dist/plugin/cli-args.js +2 -2
  37. package/dist/plugin/dotenv.cjs +35 -26
  38. package/dist/plugin/dotenv.d.cts +2 -2
  39. package/dist/plugin/dotenv.d.ts +2 -2
  40. package/dist/plugin/dotenv.js +2 -2
  41. package/dist/plugin/env-export.cjs +34 -22
  42. package/dist/plugin/env-export.d.cts +2 -2
  43. package/dist/plugin/env-export.d.ts +2 -2
  44. package/dist/plugin/env-export.js +2 -2
  45. package/dist/plugin/filesystem.cjs +42 -33
  46. package/dist/plugin/filesystem.d.cts +1 -1
  47. package/dist/plugin/filesystem.d.ts +1 -1
  48. package/dist/plugin/filesystem.js +2 -2
  49. package/dist/plugin/process-env.cjs +24 -17
  50. package/dist/plugin/process-env.d.cts +2 -2
  51. package/dist/plugin/process-env.d.ts +2 -2
  52. package/dist/plugin/process-env.js +2 -2
  53. package/dist/{plugin-B4xwySxw.d.cts → plugin-CKrBlWGI.d.cts} +52 -3
  54. package/dist/{plugin-B4xwySxw.d.ts → plugin-CKrBlWGI.d.ts} +52 -3
  55. package/dist/runtime/index.cjs +752 -143
  56. package/dist/runtime/index.d.cts +19 -1
  57. package/dist/runtime/index.d.ts +19 -1
  58. package/dist/runtime/index.js +10 -10
  59. package/dist/{toPublicEnv-ggmphZFs.d.cts → toPublicEnv-CmBsy53P.d.cts} +1 -1
  60. package/dist/{toPublicEnv-CvhGAfsB.d.ts → toPublicEnv-q6VwWxXZ.d.ts} +1 -1
  61. package/package.json +1 -1
  62. package/dist/chunk-TO76YYS4.js +0 -189
@@ -53,6 +53,11 @@ var CnosManifestError = class extends CnosError {
53
53
  }
54
54
  manifestPath;
55
55
  };
56
+ var CnosDiscoveryError = class extends CnosError {
57
+ constructor(message) {
58
+ super(message);
59
+ }
60
+ };
56
61
  var CnosSecurityError = class extends CnosError {
57
62
  constructor(message) {
58
63
  super(message);
@@ -178,32 +183,110 @@ async function readKeychain(entry) {
178
183
  }
179
184
 
180
185
  // ../core/src/manifest/loadManifest.ts
186
+ var import_promises3 = require("fs/promises");
187
+ var import_node_path3 = __toESM(require("path"), 1);
188
+
189
+ // ../core/src/utils/path.ts
181
190
  var import_promises2 = require("fs/promises");
191
+ var import_node_os = __toESM(require("os"), 1);
182
192
  var import_node_path2 = __toESM(require("path"), 1);
183
193
 
184
- // ../core/src/utils/path.ts
194
+ // ../core/src/discovery/findCnosrc.ts
185
195
  var import_promises = require("fs/promises");
186
- var import_node_os = __toESM(require("os"), 1);
187
196
  var import_node_path = __toESM(require("path"), 1);
197
+
198
+ // ../core/src/utils/yaml.ts
199
+ var import_yaml = require("yaml");
200
+ function parseYaml(source) {
201
+ return (0, import_yaml.parse)(source);
202
+ }
203
+ function stringifyYaml(value) {
204
+ return (0, import_yaml.stringify)(value);
205
+ }
206
+
207
+ // ../core/src/discovery/findCnosrc.ts
208
+ async function exists(targetPath) {
209
+ try {
210
+ await (0, import_promises.access)(targetPath);
211
+ return true;
212
+ } catch {
213
+ return false;
214
+ }
215
+ }
216
+ function validateCnosrc(value, filePath) {
217
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
218
+ throw new CnosManifestError(".cnosrc.yml must be a YAML object", filePath);
219
+ }
220
+ const root = typeof value.root === "string" ? value.root.trim() : "";
221
+ const workspace = typeof value.workspace === "string" ? value.workspace.trim() : void 0;
222
+ if (!root) {
223
+ throw new CnosManifestError(".cnosrc.yml requires root", filePath);
224
+ }
225
+ return {
226
+ root,
227
+ ...workspace ? { workspace } : {}
228
+ };
229
+ }
230
+ async function findCnosrc(startDir = process.cwd(), maxLevels = 3) {
231
+ let current = import_node_path.default.resolve(startDir);
232
+ for (let depth = 0; depth <= maxLevels; depth += 1) {
233
+ const candidate = import_node_path.default.join(current, ".cnosrc.yml");
234
+ if (await exists(candidate)) {
235
+ return candidate;
236
+ }
237
+ const parent = import_node_path.default.dirname(current);
238
+ if (parent === current) {
239
+ break;
240
+ }
241
+ current = parent;
242
+ }
243
+ return void 0;
244
+ }
245
+ async function discoverCnosAnchor(startDir = process.cwd(), maxLevels = 3) {
246
+ const anchorPath = await findCnosrc(startDir, maxLevels);
247
+ if (!anchorPath) {
248
+ throw new CnosDiscoveryError(
249
+ "No .cnosrc.yml found. Run cnos init or create .cnosrc.yml in your package root."
250
+ );
251
+ }
252
+ const source = await (0, import_promises.readFile)(anchorPath, "utf8");
253
+ const parsed = validateCnosrc(parseYaml(source), anchorPath);
254
+ const consumerRoot = import_node_path.default.dirname(anchorPath);
255
+ const manifestRoot = import_node_path.default.resolve(consumerRoot, parsed.root);
256
+ const manifestPath = import_node_path.default.join(manifestRoot, "cnos.yml");
257
+ if (!await exists(manifestPath)) {
258
+ throw new CnosDiscoveryError(
259
+ `.cnosrc.yml points to ${manifestRoot} but no cnos.yml found there.`
260
+ );
261
+ }
262
+ return {
263
+ anchorPath,
264
+ consumerRoot,
265
+ manifestRoot,
266
+ ...parsed.workspace ? { workspace: parsed.workspace } : {}
267
+ };
268
+ }
269
+
270
+ // ../core/src/utils/path.ts
188
271
  var PRIMARY_CNOS_DIR = ".cnos";
189
272
  var LEGACY_CNOS_DIR = "cnos";
190
- async function exists(filePath) {
273
+ async function exists2(filePath) {
191
274
  try {
192
- await (0, import_promises.access)(filePath);
275
+ await (0, import_promises2.access)(filePath);
193
276
  return true;
194
277
  } catch {
195
278
  return false;
196
279
  }
197
280
  }
198
281
  async function resolveCnosRoot(root = process.cwd()) {
199
- const basePath = import_node_path.default.resolve(root);
282
+ const basePath = import_node_path2.default.resolve(root);
200
283
  const candidates = [
201
- import_node_path.default.join(basePath, PRIMARY_CNOS_DIR),
202
- import_node_path.default.join(basePath, LEGACY_CNOS_DIR),
284
+ import_node_path2.default.join(basePath, PRIMARY_CNOS_DIR),
285
+ import_node_path2.default.join(basePath, LEGACY_CNOS_DIR),
203
286
  basePath
204
287
  ];
205
288
  for (const candidate of candidates) {
206
- if (await exists(import_node_path.default.join(candidate, "cnos.yml"))) {
289
+ if (await exists2(import_node_path2.default.join(candidate, "cnos.yml"))) {
207
290
  return candidate;
208
291
  }
209
292
  }
@@ -211,8 +294,23 @@ async function resolveCnosRoot(root = process.cwd()) {
211
294
  `Could not locate .cnos/cnos.yml or cnos/cnos.yml from root: ${basePath}`
212
295
  );
213
296
  }
214
- async function resolveManifestRoot(root = process.cwd()) {
215
- return resolveCnosRoot(root);
297
+ async function resolveManifestRoot(options = {}) {
298
+ if (options.root) {
299
+ const manifestRoot = await resolveCnosRoot(options.root);
300
+ const resolvedRoot = import_node_path2.default.resolve(options.root);
301
+ const consumerRoot = import_node_path2.default.basename(manifestRoot) === PRIMARY_CNOS_DIR || import_node_path2.default.basename(manifestRoot) === LEGACY_CNOS_DIR ? import_node_path2.default.dirname(manifestRoot) : resolvedRoot;
302
+ return {
303
+ manifestRoot,
304
+ consumerRoot
305
+ };
306
+ }
307
+ const discovered = await discoverCnosAnchor(options.cwd ?? process.cwd());
308
+ return {
309
+ manifestRoot: discovered.manifestRoot,
310
+ consumerRoot: discovered.consumerRoot,
311
+ anchorPath: discovered.anchorPath,
312
+ ...discovered.workspace ? { workspace: discovered.workspace } : {}
313
+ };
216
314
  }
217
315
  function interpolatePathTemplate(template, tokens) {
218
316
  return Object.entries(tokens).reduce(
@@ -225,7 +323,7 @@ function expandHomePath(targetPath) {
225
323
  return import_node_os.default.homedir();
226
324
  }
227
325
  if (targetPath.startsWith("~/") || targetPath.startsWith("~\\")) {
228
- return import_node_path.default.join(import_node_os.default.homedir(), targetPath.slice(2));
326
+ return import_node_path2.default.join(import_node_os.default.homedir(), targetPath.slice(2));
229
327
  }
230
328
  return targetPath;
231
329
  }
@@ -243,7 +341,7 @@ function stripWorkspaceTemplatePrefix(template) {
243
341
  function resolveWorkspaceScopedPath(workspaceRoot, template, tokens) {
244
342
  const relativeTemplate = stripWorkspaceTemplatePrefix(template);
245
343
  const interpolated = interpolatePathTemplate(relativeTemplate, tokens);
246
- return import_node_path.default.resolve(workspaceRoot, interpolated);
344
+ return import_node_path2.default.resolve(workspaceRoot, interpolated);
247
345
  }
248
346
  function toPortablePath(targetPath) {
249
347
  return targetPath.replace(/\\/g, "/");
@@ -258,15 +356,6 @@ function stripNamespace(key) {
258
356
  return key.split(".").slice(1).join(".");
259
357
  }
260
358
 
261
- // ../core/src/utils/yaml.ts
262
- var import_yaml = require("yaml");
263
- function parseYaml(source) {
264
- return (0, import_yaml.parse)(source);
265
- }
266
- function stringifyYaml(value) {
267
- return (0, import_yaml.stringify)(value);
268
- }
269
-
270
359
  // ../core/src/manifest/normalizeManifest.ts
271
360
  var DEFAULT_RESOLVE_FROM = ["cli.profile", "env.CNOS_PROFILE", "default"];
272
361
  var DEFAULT_LOADERS = [
@@ -282,7 +371,8 @@ var DEFAULT_INSPECTORS = ["provenance"];
282
371
  var DEFAULT_FRAMEWORK_PREFIXES = {
283
372
  next: "NEXT_PUBLIC_",
284
373
  vite: "VITE_",
285
- nuxt: "NUXT_PUBLIC_"
374
+ nuxt: "NUXT_PUBLIC_",
375
+ webpack: ""
286
376
  };
287
377
  var DEFAULT_NAMESPACES = {
288
378
  value: {
@@ -535,11 +625,15 @@ function normalizeManifest(manifest) {
535
625
 
536
626
  // ../core/src/manifest/loadManifest.ts
537
627
  async function loadManifest(options = {}) {
538
- const manifestRoot = await resolveManifestRoot(options.root);
539
- const manifestPath = import_node_path2.default.join(manifestRoot, "cnos.yml");
628
+ const resolved = await resolveManifestRoot({
629
+ ...options.root ? { root: options.root } : {},
630
+ ...options.cwd ? { cwd: options.cwd } : {}
631
+ });
632
+ const manifestRoot = resolved.manifestRoot;
633
+ const manifestPath = import_node_path3.default.join(manifestRoot, "cnos.yml");
540
634
  let source;
541
635
  try {
542
- source = await (0, import_promises2.readFile)(manifestPath, "utf8");
636
+ source = await (0, import_promises3.readFile)(manifestPath, "utf8");
543
637
  } catch {
544
638
  throw new CnosManifestError("Unable to read CNOS manifest", manifestPath);
545
639
  }
@@ -549,7 +643,10 @@ async function loadManifest(options = {}) {
549
643
  }
550
644
  return {
551
645
  manifestRoot,
552
- repoRoot: import_node_path2.default.dirname(manifestRoot),
646
+ repoRoot: import_node_path3.default.dirname(manifestRoot),
647
+ consumerRoot: resolved.consumerRoot,
648
+ ...resolved.anchorPath ? { anchorPath: resolved.anchorPath } : {},
649
+ ...resolved.workspace ? { anchoredWorkspace: resolved.workspace } : {},
553
650
  manifestPath,
554
651
  manifest: normalizeManifest(rawManifest),
555
652
  rawManifest
@@ -557,12 +654,12 @@ async function loadManifest(options = {}) {
557
654
  }
558
655
 
559
656
  // ../core/src/manifest/loadWorkspaceFile.ts
560
- var import_promises3 = require("fs/promises");
561
- var import_node_path3 = __toESM(require("path"), 1);
657
+ var import_promises4 = require("fs/promises");
658
+ var import_node_path4 = __toESM(require("path"), 1);
562
659
  async function loadWorkspaceFile(repoRoot) {
563
- const workspaceFilePath = import_node_path3.default.join(repoRoot, ".cnos-workspace.yml");
660
+ const workspaceFilePath = import_node_path4.default.join(repoRoot, ".cnos-workspace.yml");
564
661
  try {
565
- const source = await (0, import_promises3.readFile)(workspaceFilePath, "utf8");
662
+ const source = await (0, import_promises4.readFile)(workspaceFilePath, "utf8");
566
663
  const parsed = parseYaml(source);
567
664
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
568
665
  throw new CnosManifestError(".cnos-workspace.yml must be a YAML object", workspaceFilePath);
@@ -585,11 +682,11 @@ async function loadWorkspaceFile(repoRoot) {
585
682
  }
586
683
 
587
684
  // ../core/src/profiles/expandProfileChain.ts
588
- var import_promises4 = require("fs/promises");
589
- var import_node_path4 = __toESM(require("path"), 1);
685
+ var import_promises5 = require("fs/promises");
686
+ var import_node_path5 = __toESM(require("path"), 1);
590
687
  async function fileExists(targetPath) {
591
688
  try {
592
- await (0, import_promises4.access)(targetPath);
689
+ await (0, import_promises5.access)(targetPath);
593
690
  return true;
594
691
  } catch {
595
692
  return false;
@@ -623,11 +720,11 @@ async function loadProfileDefinition(profileName, options) {
623
720
  return normalizeProfileDefinition(profileName, void 0);
624
721
  }
625
722
  for (const workspaceRoot of [...workspaceRoots].reverse()) {
626
- const profilePath = import_node_path4.default.join(workspaceRoot.path, "profiles", `${profileName}.yml`);
723
+ const profilePath = import_node_path5.default.join(workspaceRoot.path, "profiles", `${profileName}.yml`);
627
724
  if (!await fileExists(profilePath)) {
628
725
  continue;
629
726
  }
630
- const document = await (0, import_promises4.readFile)(profilePath, "utf8");
727
+ const document = await (0, import_promises5.readFile)(profilePath, "utf8");
631
728
  const parsed = parseYaml(document);
632
729
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
633
730
  throw new CnosManifestError("Profile definition must be a YAML object", profilePath);
@@ -635,7 +732,7 @@ async function loadProfileDefinition(profileName, options) {
635
732
  const definition = normalizeProfileDefinition(
636
733
  profileName,
637
734
  parsed,
638
- options.manifestRoot ? toPortablePath(import_node_path4.default.relative(import_node_path4.default.dirname(options.manifestRoot), profilePath)) : toPortablePath(profilePath)
735
+ options.manifestRoot ? toPortablePath(import_node_path5.default.relative(import_node_path5.default.dirname(options.manifestRoot), profilePath)) : toPortablePath(profilePath)
639
736
  );
640
737
  if (definition.name !== profileName) {
641
738
  throw new CnosManifestError(
@@ -917,8 +1014,8 @@ function createProfileAwareResolver() {
917
1014
  }
918
1015
 
919
1016
  // ../core/src/workspaces/resolveWorkspaceContext.ts
920
- var import_promises5 = require("fs/promises");
921
- var import_node_path5 = __toESM(require("path"), 1);
1017
+ var import_promises6 = require("fs/promises");
1018
+ var import_node_path6 = __toESM(require("path"), 1);
922
1019
 
923
1020
  // ../core/src/workspaces/expandWorkspaceChain.ts
924
1021
  function expandWorkspaceChain(workspaceId, items) {
@@ -955,31 +1052,31 @@ function expandWorkspaceChain(workspaceId, items) {
955
1052
  }
956
1053
 
957
1054
  // ../core/src/workspaces/resolveWorkspaceContext.ts
958
- async function exists2(targetPath) {
1055
+ async function exists3(targetPath) {
959
1056
  try {
960
- await (0, import_promises5.access)(targetPath);
1057
+ await (0, import_promises6.access)(targetPath);
961
1058
  return true;
962
1059
  } catch {
963
1060
  return false;
964
1061
  }
965
1062
  }
966
1063
  async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId, manifest) {
967
- const workspaceRoot = import_node_path5.default.join(manifestRoot, "workspaces", workspaceId);
968
- if (await exists2(workspaceRoot)) {
1064
+ const workspaceRoot = import_node_path6.default.join(manifestRoot, "workspaces", workspaceId);
1065
+ if (await exists3(workspaceRoot)) {
969
1066
  return workspaceRoot;
970
1067
  }
971
1068
  const customDataNamespaceRoots = Object.entries(manifest.namespaces).filter(
972
1069
  ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
973
1070
  ).map(([namespace]) => namespace);
974
1071
  const legacyMarkers = ["values", "secrets", "env", "profiles", ...customDataNamespaceRoots].map(
975
- (segment) => import_node_path5.default.join(manifestRoot, segment)
1072
+ (segment) => import_node_path6.default.join(manifestRoot, segment)
976
1073
  );
977
- if ((await Promise.all(legacyMarkers.map((marker) => exists2(marker)))).some(Boolean)) {
1074
+ if ((await Promise.all(legacyMarkers.map((marker) => exists3(marker)))).some(Boolean)) {
978
1075
  return manifestRoot;
979
1076
  }
980
1077
  return workspaceRoot;
981
1078
  }
982
- function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
1079
+ function resolveWorkspaceSelection(manifest, workspaceFile, anchoredWorkspace, workspaceOption) {
983
1080
  if (workspaceOption) {
984
1081
  return {
985
1082
  workspaceId: workspaceOption,
@@ -992,6 +1089,12 @@ function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
992
1089
  source: "workspace-file"
993
1090
  };
994
1091
  }
1092
+ if (anchoredWorkspace) {
1093
+ return {
1094
+ workspaceId: anchoredWorkspace,
1095
+ source: "anchor-file"
1096
+ };
1097
+ }
995
1098
  if (manifest.workspaces.default) {
996
1099
  return {
997
1100
  workspaceId: manifest.workspaces.default,
@@ -1014,33 +1117,38 @@ function resolveGlobalRoot(manifest, workspaceFile, options) {
1014
1117
  }
1015
1118
  if (options.globalRoot) {
1016
1119
  return {
1017
- value: import_node_path5.default.resolve(expandHomePath(options.globalRoot)),
1120
+ value: import_node_path6.default.resolve(expandHomePath(options.globalRoot)),
1018
1121
  source: "cli"
1019
1122
  };
1020
1123
  }
1021
1124
  if (workspaceFile?.globalRoot) {
1022
1125
  return {
1023
- value: import_node_path5.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1126
+ value: import_node_path6.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1024
1127
  source: "workspace-file"
1025
1128
  };
1026
1129
  }
1027
1130
  if (manifest.workspaces.global.root) {
1028
1131
  return {
1029
- value: import_node_path5.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1132
+ value: import_node_path6.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1030
1133
  source: "manifest"
1031
1134
  };
1032
1135
  }
1033
1136
  const cnosHome = options.processEnv?.CNOS_HOME;
1034
1137
  if (cnosHome) {
1035
1138
  return {
1036
- value: import_node_path5.default.resolve(expandHomePath(cnosHome)),
1139
+ value: import_node_path6.default.resolve(expandHomePath(cnosHome)),
1037
1140
  source: "CNOS_HOME"
1038
1141
  };
1039
1142
  }
1040
1143
  return {};
1041
1144
  }
1042
1145
  async function resolveWorkspaceContext(manifest, options) {
1043
- const selectedWorkspace = resolveWorkspaceSelection(manifest, options.workspaceFile, options.workspace);
1146
+ const selectedWorkspace = resolveWorkspaceSelection(
1147
+ manifest,
1148
+ options.workspaceFile,
1149
+ options.anchoredWorkspace,
1150
+ options.workspace
1151
+ );
1044
1152
  const workspaceChain = expandWorkspaceChain(selectedWorkspace.workspaceId, manifest.workspaces.items);
1045
1153
  const globalRoot = resolveGlobalRoot(manifest, options.workspaceFile, options);
1046
1154
  const workspaceRoots = [];
@@ -1050,7 +1158,7 @@ async function resolveWorkspaceContext(manifest, options) {
1050
1158
  workspaceRoots.push({
1051
1159
  scope: "global",
1052
1160
  workspaceId: chainWorkspaceId,
1053
- path: import_node_path5.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1161
+ path: import_node_path6.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1054
1162
  });
1055
1163
  }
1056
1164
  }
@@ -1242,26 +1350,26 @@ async function runPipeline(options) {
1242
1350
  }
1243
1351
 
1244
1352
  // ../core/src/secrets/auditLog.ts
1245
- var import_promises8 = require("fs/promises");
1246
- var import_node_path8 = __toESM(require("path"), 1);
1353
+ var import_promises9 = require("fs/promises");
1354
+ var import_node_path9 = __toESM(require("path"), 1);
1247
1355
 
1248
1356
  // ../core/src/utils/secretStore.ts
1249
1357
  var import_node_crypto = require("crypto");
1250
- var import_promises7 = require("fs/promises");
1251
- var import_node_path7 = __toESM(require("path"), 1);
1358
+ var import_promises8 = require("fs/promises");
1359
+ var import_node_path8 = __toESM(require("path"), 1);
1252
1360
 
1253
1361
  // ../core/src/secrets/sessionStore.ts
1254
- var import_promises6 = require("fs/promises");
1255
- var import_node_path6 = __toESM(require("path"), 1);
1362
+ var import_promises7 = require("fs/promises");
1363
+ var import_node_path7 = __toESM(require("path"), 1);
1256
1364
  function buildSessionRoot(processEnv = process.env) {
1257
- return import_node_path6.default.join(import_node_path6.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets")), "sessions");
1365
+ return import_node_path7.default.join(import_node_path7.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets")), "sessions");
1258
1366
  }
1259
1367
  function buildSessionPath(vault, processEnv) {
1260
- return import_node_path6.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1368
+ return import_node_path7.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1261
1369
  }
1262
1370
  async function readVaultSessionKey(vault, processEnv) {
1263
1371
  try {
1264
- const source = await (0, import_promises6.readFile)(buildSessionPath(vault, processEnv), "utf8");
1372
+ const source = await (0, import_promises7.readFile)(buildSessionPath(vault, processEnv), "utf8");
1265
1373
  const document = JSON.parse(source);
1266
1374
  if (document.version !== 1 || typeof document.derivedKey !== "string") {
1267
1375
  return void 0;
@@ -1290,7 +1398,7 @@ function isSecretReference(value) {
1290
1398
  return isObject(value) && typeof value.provider === "string" && value.provider.trim().length > 0 && typeof value.ref === "string" && value.ref.trim().length > 0 && (value.vault === void 0 && true || typeof value.vault === "string" && value.vault.trim().length > 0) && Object.keys(value).every((key) => ["provider", "ref", "vault"].includes(key));
1291
1399
  }
1292
1400
  function resolveSecretStoreRoot(processEnv = process.env) {
1293
- return import_node_path7.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets"));
1401
+ return import_node_path8.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets"));
1294
1402
  }
1295
1403
  function normalizeVaultToken(vault = "default") {
1296
1404
  return vault.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
@@ -1322,16 +1430,16 @@ function deriveVaultKey(passphrase, salt, iterations = PBKDF2_ITERATIONS) {
1322
1430
  return (0, import_node_crypto.pbkdf2Sync)(passphrase, salt, iterations, KEY_LENGTH, "sha512");
1323
1431
  }
1324
1432
  function buildMetaPath(storeRoot, vault = "default") {
1325
- return import_node_path7.default.join(storeRoot, "vaults", vault, META_FILENAME);
1433
+ return import_node_path8.default.join(storeRoot, "vaults", vault, META_FILENAME);
1326
1434
  }
1327
1435
  function buildKeystorePath(storeRoot, vault = "default") {
1328
- return import_node_path7.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1436
+ return import_node_path8.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1329
1437
  }
1330
1438
  function buildLegacyVaultFile(storeRoot, vault = "default") {
1331
- return import_node_path7.default.join(storeRoot, "vaults", `${vault}.json`);
1439
+ return import_node_path8.default.join(storeRoot, "vaults", `${vault}.json`);
1332
1440
  }
1333
1441
  function buildLegacyVaultStoreRoot(storeRoot, vault = "default") {
1334
- return import_node_path7.default.join(storeRoot, "vaults", vault, "store");
1442
+ return import_node_path8.default.join(storeRoot, "vaults", vault, "store");
1335
1443
  }
1336
1444
  function assertVaultMetadata(value, filePath) {
1337
1445
  if (!isObject(value)) {
@@ -1342,9 +1450,9 @@ function assertVaultMetadata(value, filePath) {
1342
1450
  }
1343
1451
  return value;
1344
1452
  }
1345
- async function exists3(targetPath) {
1453
+ async function exists4(targetPath) {
1346
1454
  try {
1347
- await (0, import_promises7.stat)(targetPath);
1455
+ await (0, import_promises8.stat)(targetPath);
1348
1456
  return true;
1349
1457
  } catch {
1350
1458
  return false;
@@ -1353,10 +1461,10 @@ async function exists3(targetPath) {
1353
1461
  async function detectLegacyVaultFormat(storeRoot, vault = "default") {
1354
1462
  const legacyFile = buildLegacyVaultFile(storeRoot, vault);
1355
1463
  const legacyStore = buildLegacyVaultStoreRoot(storeRoot, vault);
1356
- if (await exists3(legacyFile)) {
1464
+ if (await exists4(legacyFile)) {
1357
1465
  return legacyFile;
1358
1466
  }
1359
- if (await exists3(legacyStore)) {
1467
+ if (await exists4(legacyStore)) {
1360
1468
  return legacyStore;
1361
1469
  }
1362
1470
  return void 0;
@@ -1428,15 +1536,15 @@ function buildInitialPayload() {
1428
1536
  async function writeVaultFiles(storeRoot, vault, meta, payload, key) {
1429
1537
  const metaPath = buildMetaPath(storeRoot, vault);
1430
1538
  const keystorePath = buildKeystorePath(storeRoot, vault);
1431
- await (0, import_promises7.mkdir)(import_node_path7.default.dirname(metaPath), { recursive: true });
1432
- await (0, import_promises7.writeFile)(metaPath, stringifyYaml(meta), "utf8");
1433
- await (0, import_promises7.writeFile)(keystorePath, encryptPayload(payload, key));
1539
+ await (0, import_promises8.mkdir)(import_node_path8.default.dirname(metaPath), { recursive: true });
1540
+ await (0, import_promises8.writeFile)(metaPath, stringifyYaml(meta), "utf8");
1541
+ await (0, import_promises8.writeFile)(keystorePath, encryptPayload(payload, key));
1434
1542
  }
1435
1543
  async function readVaultMetadata(storeRoot, vault = "default") {
1436
1544
  await assertNoLegacyVaultFormat(storeRoot, vault);
1437
1545
  const metaPath = buildMetaPath(storeRoot, vault);
1438
1546
  try {
1439
- const source = await (0, import_promises7.readFile)(metaPath, "utf8");
1547
+ const source = await (0, import_promises8.readFile)(metaPath, "utf8");
1440
1548
  return assertVaultMetadata(parseYaml(source), metaPath);
1441
1549
  } catch (error) {
1442
1550
  if (error.code === "ENOENT") {
@@ -1527,7 +1635,7 @@ async function loadVaultPayload(storeRoot, vault, auth) {
1527
1635
  if (!key) {
1528
1636
  throw new CnosAuthenticationError(`Vault "${vault}" requires authentication before access.`);
1529
1637
  }
1530
- const buffer = await (0, import_promises7.readFile)(buildKeystorePath(storeRoot, vault));
1638
+ const buffer = await (0, import_promises8.readFile)(buildKeystorePath(storeRoot, vault));
1531
1639
  return {
1532
1640
  meta,
1533
1641
  payload: decryptPayload(buffer, key),
@@ -1602,9 +1710,9 @@ function resolveVaultDefinition(vaults, vault = "default") {
1602
1710
 
1603
1711
  // ../core/src/secrets/auditLog.ts
1604
1712
  async function appendAuditEvent(event, processEnv = process.env) {
1605
- const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path8.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
1606
- await (0, import_promises8.mkdir)(import_node_path8.default.dirname(auditFile), { recursive: true });
1607
- await (0, import_promises8.appendFile)(
1713
+ const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path9.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
1714
+ await (0, import_promises9.mkdir)(import_node_path9.default.dirname(auditFile), { recursive: true });
1715
+ await (0, import_promises9.appendFile)(
1608
1716
  auditFile,
1609
1717
  `${JSON.stringify({
1610
1718
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1997,6 +2105,60 @@ function requireValue(graph, key) {
1997
2105
  return value;
1998
2106
  }
1999
2107
 
2108
+ // ../core/src/runtime/toServerProjection.ts
2109
+ var import_node_crypto2 = require("crypto");
2110
+ function stableSortObject(value) {
2111
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)));
2112
+ }
2113
+ function stripValuePrefix(key) {
2114
+ return key.startsWith("value.") ? key.slice("value.".length) : key;
2115
+ }
2116
+ function configHash(values) {
2117
+ const serialized = JSON.stringify(stableSortObject(values));
2118
+ return (0, import_node_crypto2.createHash)("sha256").update(serialized).digest("hex");
2119
+ }
2120
+ function toServerProjection(graph, manifest, cnosVersion = "0.0.0-dev") {
2121
+ const values = {};
2122
+ const secretRefs = {};
2123
+ const namespaces = /* @__PURE__ */ new Set();
2124
+ const publicKeys = Array.from(graph.entries.values()).filter((entry) => entry.namespace === "public").map((entry) => entry.key.slice("public.".length)).sort((left, right) => left.localeCompare(right));
2125
+ for (const [key, entry] of graph.entries) {
2126
+ if (entry.namespace === "secret" && isSecretReference(entry.value)) {
2127
+ secretRefs[key.slice("secret.".length)] = {
2128
+ provider: entry.value.provider,
2129
+ vault: entry.value.vault ?? "default",
2130
+ ref: entry.value.ref
2131
+ };
2132
+ continue;
2133
+ }
2134
+ if (entry.namespace === "value") {
2135
+ values[stripValuePrefix(key)] = entry.value;
2136
+ continue;
2137
+ }
2138
+ const namespaceDefinition = manifest.namespaces[entry.namespace];
2139
+ if (namespaceDefinition && namespaceDefinition.kind === "data" && !namespaceDefinition.sensitive && entry.namespace !== "public") {
2140
+ values[key] = entry.value;
2141
+ namespaces.add(entry.namespace);
2142
+ }
2143
+ }
2144
+ return {
2145
+ version: 1,
2146
+ workspace: graph.workspace.workspaceId,
2147
+ profile: graph.profile,
2148
+ resolvedAt: graph.resolvedAt,
2149
+ configHash: configHash(values),
2150
+ values: stableSortObject(values),
2151
+ secretRefs: stableSortObject(secretRefs),
2152
+ publicKeys,
2153
+ meta: {
2154
+ workspace: graph.workspace.workspaceId,
2155
+ profile: graph.profile,
2156
+ cnos_version: cnosVersion,
2157
+ ...namespaces.size > 0 ? { namespaces: Array.from(namespaces).sort((left, right) => left.localeCompare(right)) } : {}
2158
+ }
2159
+ };
2160
+ }
2161
+
2000
2162
  // ../core/src/runtime/toEnv.ts
2001
2163
  function normalizeEnvValue(value) {
2002
2164
  if (value === void 0 || value === null) {
@@ -2059,11 +2221,14 @@ function resolvePublicPrefix(manifest, options) {
2059
2221
  if (!options.framework) {
2060
2222
  return "";
2061
2223
  }
2062
- const configuredPrefix = manifest.public.frameworks[options.framework];
2063
- if (!configuredPrefix) {
2224
+ const hasConfiguredPrefix = Object.prototype.hasOwnProperty.call(
2225
+ manifest.public.frameworks,
2226
+ options.framework
2227
+ );
2228
+ if (!hasConfiguredPrefix) {
2064
2229
  throw new CnosManifestError(`Unknown public framework prefix: ${options.framework}`);
2065
2230
  }
2066
- return configuredPrefix;
2231
+ return manifest.public.frameworks[options.framework] ?? "";
2067
2232
  }
2068
2233
  function toPublicEnv(graph, manifest, options = {}) {
2069
2234
  const prefix = resolvePublicPrefix(manifest, options);
@@ -2078,7 +2243,37 @@ function toPublicEnv(graph, manifest, options = {}) {
2078
2243
  }
2079
2244
 
2080
2245
  // ../core/src/orchestrator/runtime.ts
2081
- function createRuntime(manifest, graph, plugins = [], secretCache) {
2246
+ function createRuntime(manifest, graph, plugins = [], secretCache, processEnv = process.env, cnosVersion = "0.0.0-dev") {
2247
+ async function refreshSecretEntry(key) {
2248
+ const entry = graph.entries.get(key);
2249
+ if (!entry || entry.namespace !== "secret" || !isSecretReference(entry.value)) {
2250
+ return;
2251
+ }
2252
+ if (!secretCache) {
2253
+ return;
2254
+ }
2255
+ const vaultId = entry.value.vault ?? "default";
2256
+ const definition = manifest.vaults[vaultId] ?? {
2257
+ provider: entry.value.provider,
2258
+ auth: { passphrase: { from: [] } }
2259
+ };
2260
+ const provider = createSecretVaultProvider(vaultId, definition, processEnv);
2261
+ const auth = await resolveVaultAuth(vaultId, definition, processEnv);
2262
+ await provider.authenticate(auth);
2263
+ const value = await provider.get(entry.value.ref);
2264
+ if (value !== void 0) {
2265
+ secretCache.load(vaultId, /* @__PURE__ */ new Map([[entry.value.ref, value]]));
2266
+ }
2267
+ }
2268
+ async function refreshAllSecrets() {
2269
+ if (!secretCache) {
2270
+ return;
2271
+ }
2272
+ const secretKeys = Array.from(graph.entries.values()).filter((entry) => entry.namespace === "secret" && isSecretReference(entry.value)).map((entry) => entry.key);
2273
+ for (const key of secretKeys) {
2274
+ await refreshSecretEntry(key);
2275
+ }
2276
+ }
2082
2277
  function readLogicalKey(key) {
2083
2278
  const entry = graph.entries.get(key);
2084
2279
  if (!entry) {
@@ -2106,14 +2301,14 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2106
2301
  readOr(key, fallback) {
2107
2302
  return readOrValue(graph, key, fallback);
2108
2303
  },
2109
- value(path12) {
2110
- return readLogicalKey(toLogicalKey("value", path12));
2304
+ value(path13) {
2305
+ return readLogicalKey(toLogicalKey("value", path13));
2111
2306
  },
2112
- secret(path12) {
2113
- return readLogicalKey(toLogicalKey("secret", path12));
2307
+ secret(path13) {
2308
+ return readLogicalKey(toLogicalKey("secret", path13));
2114
2309
  },
2115
- meta(path12) {
2116
- return readLogicalKey(toLogicalKey("meta", path12));
2310
+ meta(path13) {
2311
+ return readLogicalKey(toLogicalKey("meta", path13));
2117
2312
  },
2118
2313
  inspect(key) {
2119
2314
  return inspectValue(graph, key);
@@ -2129,6 +2324,15 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2129
2324
  },
2130
2325
  toPublicEnv(options) {
2131
2326
  return toPublicEnv(graph, manifest, options);
2327
+ },
2328
+ toServerProjection() {
2329
+ return toServerProjection(graph, manifest, cnosVersion);
2330
+ },
2331
+ async refreshSecrets() {
2332
+ await refreshAllSecrets();
2333
+ },
2334
+ async refreshSecret(key) {
2335
+ await refreshSecretEntry(key);
2132
2336
  }
2133
2337
  };
2134
2338
  }
@@ -2227,14 +2431,18 @@ function appendMetaEntries(graph, cnosVersion) {
2227
2431
  };
2228
2432
  }
2229
2433
  async function createCnos(options = {}) {
2230
- const loadedManifest = await loadManifest(options.root ? { root: options.root } : {});
2434
+ const loadedManifest = await loadManifest({
2435
+ ...options.root ? { root: options.root } : {},
2436
+ ...options.cwd ? { cwd: options.cwd } : {}
2437
+ });
2231
2438
  for (const key of loadedManifest.manifest.public.promote) {
2232
2439
  ensureProjectionAllowed(loadedManifest.manifest, key, "public");
2233
2440
  }
2234
- const workspaceFile = await loadWorkspaceFile(loadedManifest.repoRoot);
2441
+ const workspaceFile = await loadWorkspaceFile(loadedManifest.consumerRoot);
2235
2442
  const workspace = await resolveWorkspaceContext(loadedManifest.manifest, {
2236
2443
  manifestRoot: loadedManifest.manifestRoot,
2237
2444
  ...workspaceFile ? { workspaceFile: workspaceFile.config } : {},
2445
+ ...loadedManifest.anchoredWorkspace ? { anchoredWorkspace: loadedManifest.anchoredWorkspace } : {},
2238
2446
  ...options.workspace ? { workspace: options.workspace } : {},
2239
2447
  ...options.globalRoot ? { globalRoot: options.globalRoot } : {},
2240
2448
  ...options.processEnv ? { processEnv: options.processEnv } : {}
@@ -2279,28 +2487,30 @@ async function createCnos(options = {}) {
2279
2487
  profileSource: activeProfile.source
2280
2488
  }, options.cnosVersion),
2281
2489
  plugins,
2282
- secretCache
2490
+ secretCache,
2491
+ options.processEnv,
2492
+ options.cnosVersion
2283
2493
  );
2284
2494
  }
2285
2495
 
2286
2496
  // ../core/src/runtime/dump.ts
2287
- var import_promises9 = require("fs/promises");
2288
- var import_node_path9 = __toESM(require("path"), 1);
2497
+ var import_promises10 = require("fs/promises");
2498
+ var import_node_path10 = __toESM(require("path"), 1);
2289
2499
  function buildDumpFiles(graph, options = {}) {
2290
- const basePath = options.flatten ? "" : import_node_path9.default.posix.join("workspaces", graph.workspace.workspaceId);
2500
+ const basePath = options.flatten ? "" : import_node_path10.default.posix.join("workspaces", graph.workspace.workspaceId);
2291
2501
  const values = toNamespaceObject(graph, "value");
2292
2502
  const secrets = toNamespaceObject(graph, "secret");
2293
2503
  const files = [];
2294
2504
  if (Object.keys(values).length > 0) {
2295
2505
  files.push({
2296
- path: import_node_path9.default.posix.join(basePath, "values", graph.profile, "app.yml"),
2506
+ path: import_node_path10.default.posix.join(basePath, "values", graph.profile, "app.yml"),
2297
2507
  namespace: "value",
2298
2508
  content: stringifyYaml(values)
2299
2509
  });
2300
2510
  }
2301
2511
  if (Object.keys(secrets).length > 0) {
2302
2512
  files.push({
2303
- path: import_node_path9.default.posix.join(basePath, "secrets", graph.profile, "app.yml"),
2513
+ path: import_node_path10.default.posix.join(basePath, "secrets", graph.profile, "app.yml"),
2304
2514
  namespace: "secret",
2305
2515
  content: stringifyYaml(secrets)
2306
2516
  });
@@ -2316,12 +2526,12 @@ function planDump(graph, options = {}) {
2316
2526
  };
2317
2527
  }
2318
2528
  async function writeDump(graph, options) {
2319
- const root = import_node_path9.default.resolve(options.to);
2529
+ const root = import_node_path10.default.resolve(options.to);
2320
2530
  const plan = planDump(graph, options);
2321
2531
  for (const file of plan.files) {
2322
- const destination = import_node_path9.default.join(root, file.path);
2323
- await (0, import_promises9.mkdir)(import_node_path9.default.dirname(destination), { recursive: true });
2324
- await (0, import_promises9.writeFile)(destination, file.content, "utf8");
2532
+ const destination = import_node_path10.default.join(root, file.path);
2533
+ await (0, import_promises10.mkdir)(import_node_path10.default.dirname(destination), { recursive: true });
2534
+ await (0, import_promises10.writeFile)(destination, file.content, "utf8");
2325
2535
  }
2326
2536
  return {
2327
2537
  ...plan,
@@ -2336,8 +2546,8 @@ function normalizeMappingConfig(config = {}) {
2336
2546
  explicit: config.explicit ?? {}
2337
2547
  };
2338
2548
  }
2339
- function fromScreamingSnake(path12) {
2340
- return path12.split("_").map((segment) => segment.trim().toLowerCase()).filter(Boolean).join(".");
2549
+ function fromScreamingSnake(path13) {
2550
+ return path13.split("_").map((segment) => segment.trim().toLowerCase()).filter(Boolean).join(".");
2341
2551
  }
2342
2552
  function envVarToLogicalKey(envVar, config = {}) {
2343
2553
  const normalized = normalizeMappingConfig(config);
@@ -2364,7 +2574,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2364
2574
  // package.json
2365
2575
  var package_default = {
2366
2576
  name: "@kitsy/cnos",
2367
- version: "1.5.0",
2577
+ version: "1.6.0",
2368
2578
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2369
2579
  type: "module",
2370
2580
  main: "./dist/index.cjs",
@@ -2563,8 +2773,8 @@ function createCliArgsPlugin() {
2563
2773
  }
2564
2774
 
2565
2775
  // ../../plugins/dotenv/src/index.ts
2566
- var import_promises10 = require("fs/promises");
2567
- var import_node_path10 = __toESM(require("path"), 1);
2776
+ var import_promises11 = require("fs/promises");
2777
+ var import_node_path11 = __toESM(require("path"), 1);
2568
2778
  var DOTENV_PLUGIN_ID = "@kitsy/cnos/plugins/dotenv";
2569
2779
  function parseDoubleQuoted(value) {
2570
2780
  return value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
@@ -2621,7 +2831,7 @@ function dotenvEntriesFromObject(values, mapping = {}, originFile, workspaceId =
2621
2831
  }
2622
2832
  async function readIfPresent(filePath) {
2623
2833
  try {
2624
- return await (0, import_promises10.readFile)(filePath, "utf8");
2834
+ return await (0, import_promises11.readFile)(filePath, "utf8");
2625
2835
  } catch {
2626
2836
  return void 0;
2627
2837
  }
@@ -2640,7 +2850,7 @@ function createDotenvPlugin() {
2640
2850
  workspace: workspaceRoot.workspaceId
2641
2851
  });
2642
2852
  for (const fileName of fileNames) {
2643
- const absolutePath = import_node_path10.default.join(envRoot, fileName);
2853
+ const absolutePath = import_node_path11.default.join(envRoot, fileName);
2644
2854
  const document = await readIfPresent(absolutePath);
2645
2855
  if (!document) {
2646
2856
  continue;
@@ -2649,7 +2859,7 @@ function createDotenvPlugin() {
2649
2859
  ...dotenvEntriesFromObject(
2650
2860
  parseDotenv(document),
2651
2861
  config.envMapping,
2652
- toPortablePath(import_node_path10.default.relative(import_node_path10.default.dirname(context.manifestRoot), absolutePath)),
2862
+ toPortablePath(import_node_path11.default.relative(import_node_path11.default.dirname(context.manifestRoot), absolutePath)),
2653
2863
  workspaceRoot.workspaceId
2654
2864
  )
2655
2865
  );
@@ -2687,16 +2897,16 @@ function createPublicEnvExportPlugin() {
2687
2897
  }
2688
2898
 
2689
2899
  // ../../plugins/filesystem/src/filesystemSecretsReader.ts
2690
- var import_promises12 = require("fs/promises");
2900
+ var import_promises13 = require("fs/promises");
2691
2901
 
2692
2902
  // ../../plugins/filesystem/src/helpers.ts
2693
- var import_promises11 = require("fs/promises");
2694
- var import_node_path11 = __toESM(require("path"), 1);
2903
+ var import_promises12 = require("fs/promises");
2904
+ var import_node_path12 = __toESM(require("path"), 1);
2695
2905
  var YAML_EXTENSIONS = /* @__PURE__ */ new Set([".yml", ".yaml"]);
2696
2906
  var FILESYSTEM_PLUGIN_ID = "@kitsy/cnos/plugins/filesystem";
2697
2907
  async function existsDirectory(targetPath) {
2698
2908
  try {
2699
- const stat2 = await (0, import_promises11.readdir)(targetPath);
2909
+ const stat2 = await (0, import_promises12.readdir)(targetPath);
2700
2910
  void stat2;
2701
2911
  return true;
2702
2912
  } catch {
@@ -2704,15 +2914,15 @@ async function existsDirectory(targetPath) {
2704
2914
  }
2705
2915
  }
2706
2916
  async function collectYamlFiles(root) {
2707
- const entries = await (0, import_promises11.readdir)(root, { withFileTypes: true });
2917
+ const entries = await (0, import_promises12.readdir)(root, { withFileTypes: true });
2708
2918
  const results = [];
2709
2919
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
2710
- const absolutePath = import_node_path11.default.join(root, entry.name);
2920
+ const absolutePath = import_node_path12.default.join(root, entry.name);
2711
2921
  if (entry.isDirectory()) {
2712
2922
  results.push(...await collectYamlFiles(absolutePath));
2713
2923
  continue;
2714
2924
  }
2715
- if (entry.isFile() && YAML_EXTENSIONS.has(import_node_path11.default.extname(entry.name).toLowerCase())) {
2925
+ if (entry.isFile() && YAML_EXTENSIONS.has(import_node_path12.default.extname(entry.name).toLowerCase())) {
2716
2926
  results.push(absolutePath);
2717
2927
  }
2718
2928
  }
@@ -2720,16 +2930,16 @@ async function collectYamlFiles(root) {
2720
2930
  }
2721
2931
  async function collectFilesystemLayerFiles(manifestRoot, workspaceRoots, sourceRoot, activeLayers) {
2722
2932
  const files = [];
2723
- const repoRoot = import_node_path11.default.dirname(manifestRoot);
2933
+ const repoRoot = import_node_path12.default.dirname(manifestRoot);
2724
2934
  for (const workspaceRoot of workspaceRoots) {
2725
- const resolvedRoot = import_node_path11.default.resolve(workspaceRoot.path, sourceRoot);
2935
+ const resolvedRoot = import_node_path12.default.resolve(workspaceRoot.path, sourceRoot);
2726
2936
  for (const layer of activeLayers) {
2727
- const layerRoot = import_node_path11.default.join(resolvedRoot, layer);
2937
+ const layerRoot = import_node_path12.default.join(resolvedRoot, layer);
2728
2938
  if (!await existsDirectory(layerRoot)) {
2729
2939
  continue;
2730
2940
  }
2731
2941
  for (const absolutePath of await collectYamlFiles(layerRoot)) {
2732
- const relativePath = import_node_path11.default.relative(repoRoot, absolutePath);
2942
+ const relativePath = import_node_path12.default.relative(repoRoot, absolutePath);
2733
2943
  files.push({
2734
2944
  absolutePath,
2735
2945
  relativePath: toPortablePath(relativePath.startsWith("..") ? absolutePath : relativePath),
@@ -2806,7 +3016,7 @@ function createFilesystemSecretsPlugin() {
2806
3016
  );
2807
3017
  const entries = [];
2808
3018
  for (const file of files) {
2809
- const document = await (0, import_promises12.readFile)(file.absolutePath, "utf8");
3019
+ const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
2810
3020
  const fileEntries = filesystemSecretsReader(file.relativePath, document, file.workspaceId);
2811
3021
  for (const entry of fileEntries) {
2812
3022
  const metadata = toSecretReferenceMetadata(entry.value);
@@ -2822,7 +3032,7 @@ function createFilesystemSecretsPlugin() {
2822
3032
  }
2823
3033
 
2824
3034
  // ../../plugins/filesystem/src/filesystemValuesReader.ts
2825
- var import_promises13 = require("fs/promises");
3035
+ var import_promises14 = require("fs/promises");
2826
3036
  function filesystemValuesReader(filePath, document, workspaceId = "default") {
2827
3037
  return yamlObjectToEntries(document, filePath, "value", "filesystem-values", workspaceId);
2828
3038
  }
@@ -2843,7 +3053,7 @@ function createFilesystemValuesPlugin() {
2843
3053
  ).map(([namespace]) => namespace);
2844
3054
  const entries = [];
2845
3055
  for (const file of files) {
2846
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3056
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2847
3057
  entries.push(...filesystemValuesReader(file.relativePath, document, file.workspaceId));
2848
3058
  }
2849
3059
  for (const namespace of customNamespaces) {
@@ -2858,7 +3068,7 @@ function createFilesystemValuesPlugin() {
2858
3068
  layers
2859
3069
  );
2860
3070
  for (const file of namespaceFiles) {
2861
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3071
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2862
3072
  entries.push(...yamlObjectToEntries(document, file.relativePath, namespace, "filesystem-values", file.workspaceId));
2863
3073
  }
2864
3074
  }