@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
@@ -32,6 +32,7 @@ var build_exports = {};
32
32
  __export(build_exports, {
33
33
  resolveBrowserData: () => resolveBrowserData,
34
34
  resolveFrameworkEnv: () => resolveFrameworkEnv,
35
+ resolveServerProjection: () => resolveServerProjection,
35
36
  toFrameworkEnv: () => toFrameworkEnv
36
37
  });
37
38
  module.exports = __toCommonJS(build_exports);
@@ -50,6 +51,11 @@ var CnosManifestError = class extends CnosError {
50
51
  }
51
52
  manifestPath;
52
53
  };
54
+ var CnosDiscoveryError = class extends CnosError {
55
+ constructor(message) {
56
+ super(message);
57
+ }
58
+ };
53
59
  var CnosSecurityError = class extends CnosError {
54
60
  constructor(message) {
55
61
  super(message);
@@ -175,32 +181,110 @@ async function readKeychain(entry) {
175
181
  }
176
182
 
177
183
  // ../core/src/manifest/loadManifest.ts
184
+ var import_promises3 = require("fs/promises");
185
+ var import_node_path3 = __toESM(require("path"), 1);
186
+
187
+ // ../core/src/utils/path.ts
178
188
  var import_promises2 = require("fs/promises");
189
+ var import_node_os = __toESM(require("os"), 1);
179
190
  var import_node_path2 = __toESM(require("path"), 1);
180
191
 
181
- // ../core/src/utils/path.ts
192
+ // ../core/src/discovery/findCnosrc.ts
182
193
  var import_promises = require("fs/promises");
183
- var import_node_os = __toESM(require("os"), 1);
184
194
  var import_node_path = __toESM(require("path"), 1);
195
+
196
+ // ../core/src/utils/yaml.ts
197
+ var import_yaml = require("yaml");
198
+ function parseYaml(source) {
199
+ return (0, import_yaml.parse)(source);
200
+ }
201
+ function stringifyYaml(value) {
202
+ return (0, import_yaml.stringify)(value);
203
+ }
204
+
205
+ // ../core/src/discovery/findCnosrc.ts
206
+ async function exists(targetPath) {
207
+ try {
208
+ await (0, import_promises.access)(targetPath);
209
+ return true;
210
+ } catch {
211
+ return false;
212
+ }
213
+ }
214
+ function validateCnosrc(value, filePath) {
215
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
216
+ throw new CnosManifestError(".cnosrc.yml must be a YAML object", filePath);
217
+ }
218
+ const root = typeof value.root === "string" ? value.root.trim() : "";
219
+ const workspace = typeof value.workspace === "string" ? value.workspace.trim() : void 0;
220
+ if (!root) {
221
+ throw new CnosManifestError(".cnosrc.yml requires root", filePath);
222
+ }
223
+ return {
224
+ root,
225
+ ...workspace ? { workspace } : {}
226
+ };
227
+ }
228
+ async function findCnosrc(startDir = process.cwd(), maxLevels = 3) {
229
+ let current = import_node_path.default.resolve(startDir);
230
+ for (let depth = 0; depth <= maxLevels; depth += 1) {
231
+ const candidate = import_node_path.default.join(current, ".cnosrc.yml");
232
+ if (await exists(candidate)) {
233
+ return candidate;
234
+ }
235
+ const parent = import_node_path.default.dirname(current);
236
+ if (parent === current) {
237
+ break;
238
+ }
239
+ current = parent;
240
+ }
241
+ return void 0;
242
+ }
243
+ async function discoverCnosAnchor(startDir = process.cwd(), maxLevels = 3) {
244
+ const anchorPath = await findCnosrc(startDir, maxLevels);
245
+ if (!anchorPath) {
246
+ throw new CnosDiscoveryError(
247
+ "No .cnosrc.yml found. Run cnos init or create .cnosrc.yml in your package root."
248
+ );
249
+ }
250
+ const source = await (0, import_promises.readFile)(anchorPath, "utf8");
251
+ const parsed = validateCnosrc(parseYaml(source), anchorPath);
252
+ const consumerRoot = import_node_path.default.dirname(anchorPath);
253
+ const manifestRoot = import_node_path.default.resolve(consumerRoot, parsed.root);
254
+ const manifestPath = import_node_path.default.join(manifestRoot, "cnos.yml");
255
+ if (!await exists(manifestPath)) {
256
+ throw new CnosDiscoveryError(
257
+ `.cnosrc.yml points to ${manifestRoot} but no cnos.yml found there.`
258
+ );
259
+ }
260
+ return {
261
+ anchorPath,
262
+ consumerRoot,
263
+ manifestRoot,
264
+ ...parsed.workspace ? { workspace: parsed.workspace } : {}
265
+ };
266
+ }
267
+
268
+ // ../core/src/utils/path.ts
185
269
  var PRIMARY_CNOS_DIR = ".cnos";
186
270
  var LEGACY_CNOS_DIR = "cnos";
187
- async function exists(filePath) {
271
+ async function exists2(filePath) {
188
272
  try {
189
- await (0, import_promises.access)(filePath);
273
+ await (0, import_promises2.access)(filePath);
190
274
  return true;
191
275
  } catch {
192
276
  return false;
193
277
  }
194
278
  }
195
279
  async function resolveCnosRoot(root = process.cwd()) {
196
- const basePath = import_node_path.default.resolve(root);
280
+ const basePath = import_node_path2.default.resolve(root);
197
281
  const candidates = [
198
- import_node_path.default.join(basePath, PRIMARY_CNOS_DIR),
199
- import_node_path.default.join(basePath, LEGACY_CNOS_DIR),
282
+ import_node_path2.default.join(basePath, PRIMARY_CNOS_DIR),
283
+ import_node_path2.default.join(basePath, LEGACY_CNOS_DIR),
200
284
  basePath
201
285
  ];
202
286
  for (const candidate of candidates) {
203
- if (await exists(import_node_path.default.join(candidate, "cnos.yml"))) {
287
+ if (await exists2(import_node_path2.default.join(candidate, "cnos.yml"))) {
204
288
  return candidate;
205
289
  }
206
290
  }
@@ -208,8 +292,23 @@ async function resolveCnosRoot(root = process.cwd()) {
208
292
  `Could not locate .cnos/cnos.yml or cnos/cnos.yml from root: ${basePath}`
209
293
  );
210
294
  }
211
- async function resolveManifestRoot(root = process.cwd()) {
212
- return resolveCnosRoot(root);
295
+ async function resolveManifestRoot(options = {}) {
296
+ if (options.root) {
297
+ const manifestRoot = await resolveCnosRoot(options.root);
298
+ const resolvedRoot = import_node_path2.default.resolve(options.root);
299
+ 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;
300
+ return {
301
+ manifestRoot,
302
+ consumerRoot
303
+ };
304
+ }
305
+ const discovered = await discoverCnosAnchor(options.cwd ?? process.cwd());
306
+ return {
307
+ manifestRoot: discovered.manifestRoot,
308
+ consumerRoot: discovered.consumerRoot,
309
+ anchorPath: discovered.anchorPath,
310
+ ...discovered.workspace ? { workspace: discovered.workspace } : {}
311
+ };
213
312
  }
214
313
  function interpolatePathTemplate(template, tokens) {
215
314
  return Object.entries(tokens).reduce(
@@ -222,7 +321,7 @@ function expandHomePath(targetPath) {
222
321
  return import_node_os.default.homedir();
223
322
  }
224
323
  if (targetPath.startsWith("~/") || targetPath.startsWith("~\\")) {
225
- return import_node_path.default.join(import_node_os.default.homedir(), targetPath.slice(2));
324
+ return import_node_path2.default.join(import_node_os.default.homedir(), targetPath.slice(2));
226
325
  }
227
326
  return targetPath;
228
327
  }
@@ -240,7 +339,7 @@ function stripWorkspaceTemplatePrefix(template) {
240
339
  function resolveWorkspaceScopedPath(workspaceRoot, template, tokens) {
241
340
  const relativeTemplate = stripWorkspaceTemplatePrefix(template);
242
341
  const interpolated = interpolatePathTemplate(relativeTemplate, tokens);
243
- return import_node_path.default.resolve(workspaceRoot, interpolated);
342
+ return import_node_path2.default.resolve(workspaceRoot, interpolated);
244
343
  }
245
344
  function toPortablePath(targetPath) {
246
345
  return targetPath.replace(/\\/g, "/");
@@ -255,15 +354,6 @@ function stripNamespace(key) {
255
354
  return key.split(".").slice(1).join(".");
256
355
  }
257
356
 
258
- // ../core/src/utils/yaml.ts
259
- var import_yaml = require("yaml");
260
- function parseYaml(source) {
261
- return (0, import_yaml.parse)(source);
262
- }
263
- function stringifyYaml(value) {
264
- return (0, import_yaml.stringify)(value);
265
- }
266
-
267
357
  // ../core/src/manifest/normalizeManifest.ts
268
358
  var DEFAULT_RESOLVE_FROM = ["cli.profile", "env.CNOS_PROFILE", "default"];
269
359
  var DEFAULT_LOADERS = [
@@ -279,7 +369,8 @@ var DEFAULT_INSPECTORS = ["provenance"];
279
369
  var DEFAULT_FRAMEWORK_PREFIXES = {
280
370
  next: "NEXT_PUBLIC_",
281
371
  vite: "VITE_",
282
- nuxt: "NUXT_PUBLIC_"
372
+ nuxt: "NUXT_PUBLIC_",
373
+ webpack: ""
283
374
  };
284
375
  var DEFAULT_NAMESPACES = {
285
376
  value: {
@@ -532,11 +623,15 @@ function normalizeManifest(manifest) {
532
623
 
533
624
  // ../core/src/manifest/loadManifest.ts
534
625
  async function loadManifest(options = {}) {
535
- const manifestRoot = await resolveManifestRoot(options.root);
536
- const manifestPath = import_node_path2.default.join(manifestRoot, "cnos.yml");
626
+ const resolved = await resolveManifestRoot({
627
+ ...options.root ? { root: options.root } : {},
628
+ ...options.cwd ? { cwd: options.cwd } : {}
629
+ });
630
+ const manifestRoot = resolved.manifestRoot;
631
+ const manifestPath = import_node_path3.default.join(manifestRoot, "cnos.yml");
537
632
  let source;
538
633
  try {
539
- source = await (0, import_promises2.readFile)(manifestPath, "utf8");
634
+ source = await (0, import_promises3.readFile)(manifestPath, "utf8");
540
635
  } catch {
541
636
  throw new CnosManifestError("Unable to read CNOS manifest", manifestPath);
542
637
  }
@@ -546,7 +641,10 @@ async function loadManifest(options = {}) {
546
641
  }
547
642
  return {
548
643
  manifestRoot,
549
- repoRoot: import_node_path2.default.dirname(manifestRoot),
644
+ repoRoot: import_node_path3.default.dirname(manifestRoot),
645
+ consumerRoot: resolved.consumerRoot,
646
+ ...resolved.anchorPath ? { anchorPath: resolved.anchorPath } : {},
647
+ ...resolved.workspace ? { anchoredWorkspace: resolved.workspace } : {},
550
648
  manifestPath,
551
649
  manifest: normalizeManifest(rawManifest),
552
650
  rawManifest
@@ -554,12 +652,12 @@ async function loadManifest(options = {}) {
554
652
  }
555
653
 
556
654
  // ../core/src/manifest/loadWorkspaceFile.ts
557
- var import_promises3 = require("fs/promises");
558
- var import_node_path3 = __toESM(require("path"), 1);
655
+ var import_promises4 = require("fs/promises");
656
+ var import_node_path4 = __toESM(require("path"), 1);
559
657
  async function loadWorkspaceFile(repoRoot) {
560
- const workspaceFilePath = import_node_path3.default.join(repoRoot, ".cnos-workspace.yml");
658
+ const workspaceFilePath = import_node_path4.default.join(repoRoot, ".cnos-workspace.yml");
561
659
  try {
562
- const source = await (0, import_promises3.readFile)(workspaceFilePath, "utf8");
660
+ const source = await (0, import_promises4.readFile)(workspaceFilePath, "utf8");
563
661
  const parsed = parseYaml(source);
564
662
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
565
663
  throw new CnosManifestError(".cnos-workspace.yml must be a YAML object", workspaceFilePath);
@@ -582,11 +680,11 @@ async function loadWorkspaceFile(repoRoot) {
582
680
  }
583
681
 
584
682
  // ../core/src/profiles/expandProfileChain.ts
585
- var import_promises4 = require("fs/promises");
586
- var import_node_path4 = __toESM(require("path"), 1);
683
+ var import_promises5 = require("fs/promises");
684
+ var import_node_path5 = __toESM(require("path"), 1);
587
685
  async function fileExists(targetPath) {
588
686
  try {
589
- await (0, import_promises4.access)(targetPath);
687
+ await (0, import_promises5.access)(targetPath);
590
688
  return true;
591
689
  } catch {
592
690
  return false;
@@ -620,11 +718,11 @@ async function loadProfileDefinition(profileName, options) {
620
718
  return normalizeProfileDefinition(profileName, void 0);
621
719
  }
622
720
  for (const workspaceRoot of [...workspaceRoots].reverse()) {
623
- const profilePath = import_node_path4.default.join(workspaceRoot.path, "profiles", `${profileName}.yml`);
721
+ const profilePath = import_node_path5.default.join(workspaceRoot.path, "profiles", `${profileName}.yml`);
624
722
  if (!await fileExists(profilePath)) {
625
723
  continue;
626
724
  }
627
- const document = await (0, import_promises4.readFile)(profilePath, "utf8");
725
+ const document = await (0, import_promises5.readFile)(profilePath, "utf8");
628
726
  const parsed = parseYaml(document);
629
727
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
630
728
  throw new CnosManifestError("Profile definition must be a YAML object", profilePath);
@@ -632,7 +730,7 @@ async function loadProfileDefinition(profileName, options) {
632
730
  const definition = normalizeProfileDefinition(
633
731
  profileName,
634
732
  parsed,
635
- options.manifestRoot ? toPortablePath(import_node_path4.default.relative(import_node_path4.default.dirname(options.manifestRoot), profilePath)) : toPortablePath(profilePath)
733
+ options.manifestRoot ? toPortablePath(import_node_path5.default.relative(import_node_path5.default.dirname(options.manifestRoot), profilePath)) : toPortablePath(profilePath)
636
734
  );
637
735
  if (definition.name !== profileName) {
638
736
  throw new CnosManifestError(
@@ -914,8 +1012,8 @@ function createProfileAwareResolver() {
914
1012
  }
915
1013
 
916
1014
  // ../core/src/workspaces/resolveWorkspaceContext.ts
917
- var import_promises5 = require("fs/promises");
918
- var import_node_path5 = __toESM(require("path"), 1);
1015
+ var import_promises6 = require("fs/promises");
1016
+ var import_node_path6 = __toESM(require("path"), 1);
919
1017
 
920
1018
  // ../core/src/workspaces/expandWorkspaceChain.ts
921
1019
  function expandWorkspaceChain(workspaceId, items) {
@@ -952,31 +1050,31 @@ function expandWorkspaceChain(workspaceId, items) {
952
1050
  }
953
1051
 
954
1052
  // ../core/src/workspaces/resolveWorkspaceContext.ts
955
- async function exists2(targetPath) {
1053
+ async function exists3(targetPath) {
956
1054
  try {
957
- await (0, import_promises5.access)(targetPath);
1055
+ await (0, import_promises6.access)(targetPath);
958
1056
  return true;
959
1057
  } catch {
960
1058
  return false;
961
1059
  }
962
1060
  }
963
1061
  async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId, manifest) {
964
- const workspaceRoot = import_node_path5.default.join(manifestRoot, "workspaces", workspaceId);
965
- if (await exists2(workspaceRoot)) {
1062
+ const workspaceRoot = import_node_path6.default.join(manifestRoot, "workspaces", workspaceId);
1063
+ if (await exists3(workspaceRoot)) {
966
1064
  return workspaceRoot;
967
1065
  }
968
1066
  const customDataNamespaceRoots = Object.entries(manifest.namespaces).filter(
969
1067
  ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
970
1068
  ).map(([namespace]) => namespace);
971
1069
  const legacyMarkers = ["values", "secrets", "env", "profiles", ...customDataNamespaceRoots].map(
972
- (segment) => import_node_path5.default.join(manifestRoot, segment)
1070
+ (segment) => import_node_path6.default.join(manifestRoot, segment)
973
1071
  );
974
- if ((await Promise.all(legacyMarkers.map((marker) => exists2(marker)))).some(Boolean)) {
1072
+ if ((await Promise.all(legacyMarkers.map((marker) => exists3(marker)))).some(Boolean)) {
975
1073
  return manifestRoot;
976
1074
  }
977
1075
  return workspaceRoot;
978
1076
  }
979
- function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
1077
+ function resolveWorkspaceSelection(manifest, workspaceFile, anchoredWorkspace, workspaceOption) {
980
1078
  if (workspaceOption) {
981
1079
  return {
982
1080
  workspaceId: workspaceOption,
@@ -989,6 +1087,12 @@ function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
989
1087
  source: "workspace-file"
990
1088
  };
991
1089
  }
1090
+ if (anchoredWorkspace) {
1091
+ return {
1092
+ workspaceId: anchoredWorkspace,
1093
+ source: "anchor-file"
1094
+ };
1095
+ }
992
1096
  if (manifest.workspaces.default) {
993
1097
  return {
994
1098
  workspaceId: manifest.workspaces.default,
@@ -1011,33 +1115,38 @@ function resolveGlobalRoot(manifest, workspaceFile, options) {
1011
1115
  }
1012
1116
  if (options.globalRoot) {
1013
1117
  return {
1014
- value: import_node_path5.default.resolve(expandHomePath(options.globalRoot)),
1118
+ value: import_node_path6.default.resolve(expandHomePath(options.globalRoot)),
1015
1119
  source: "cli"
1016
1120
  };
1017
1121
  }
1018
1122
  if (workspaceFile?.globalRoot) {
1019
1123
  return {
1020
- value: import_node_path5.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1124
+ value: import_node_path6.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1021
1125
  source: "workspace-file"
1022
1126
  };
1023
1127
  }
1024
1128
  if (manifest.workspaces.global.root) {
1025
1129
  return {
1026
- value: import_node_path5.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1130
+ value: import_node_path6.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1027
1131
  source: "manifest"
1028
1132
  };
1029
1133
  }
1030
1134
  const cnosHome = options.processEnv?.CNOS_HOME;
1031
1135
  if (cnosHome) {
1032
1136
  return {
1033
- value: import_node_path5.default.resolve(expandHomePath(cnosHome)),
1137
+ value: import_node_path6.default.resolve(expandHomePath(cnosHome)),
1034
1138
  source: "CNOS_HOME"
1035
1139
  };
1036
1140
  }
1037
1141
  return {};
1038
1142
  }
1039
1143
  async function resolveWorkspaceContext(manifest, options) {
1040
- const selectedWorkspace = resolveWorkspaceSelection(manifest, options.workspaceFile, options.workspace);
1144
+ const selectedWorkspace = resolveWorkspaceSelection(
1145
+ manifest,
1146
+ options.workspaceFile,
1147
+ options.anchoredWorkspace,
1148
+ options.workspace
1149
+ );
1041
1150
  const workspaceChain = expandWorkspaceChain(selectedWorkspace.workspaceId, manifest.workspaces.items);
1042
1151
  const globalRoot = resolveGlobalRoot(manifest, options.workspaceFile, options);
1043
1152
  const workspaceRoots = [];
@@ -1047,7 +1156,7 @@ async function resolveWorkspaceContext(manifest, options) {
1047
1156
  workspaceRoots.push({
1048
1157
  scope: "global",
1049
1158
  workspaceId: chainWorkspaceId,
1050
- path: import_node_path5.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1159
+ path: import_node_path6.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1051
1160
  });
1052
1161
  }
1053
1162
  }
@@ -1239,26 +1348,26 @@ async function runPipeline(options) {
1239
1348
  }
1240
1349
 
1241
1350
  // ../core/src/secrets/auditLog.ts
1242
- var import_promises8 = require("fs/promises");
1243
- var import_node_path8 = __toESM(require("path"), 1);
1351
+ var import_promises9 = require("fs/promises");
1352
+ var import_node_path9 = __toESM(require("path"), 1);
1244
1353
 
1245
1354
  // ../core/src/utils/secretStore.ts
1246
1355
  var import_node_crypto = require("crypto");
1247
- var import_promises7 = require("fs/promises");
1248
- var import_node_path7 = __toESM(require("path"), 1);
1356
+ var import_promises8 = require("fs/promises");
1357
+ var import_node_path8 = __toESM(require("path"), 1);
1249
1358
 
1250
1359
  // ../core/src/secrets/sessionStore.ts
1251
- var import_promises6 = require("fs/promises");
1252
- var import_node_path6 = __toESM(require("path"), 1);
1360
+ var import_promises7 = require("fs/promises");
1361
+ var import_node_path7 = __toESM(require("path"), 1);
1253
1362
  function buildSessionRoot(processEnv = process.env) {
1254
- return import_node_path6.default.join(import_node_path6.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets")), "sessions");
1363
+ return import_node_path7.default.join(import_node_path7.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets")), "sessions");
1255
1364
  }
1256
1365
  function buildSessionPath(vault, processEnv) {
1257
- return import_node_path6.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1366
+ return import_node_path7.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1258
1367
  }
1259
1368
  async function readVaultSessionKey(vault, processEnv) {
1260
1369
  try {
1261
- const source = await (0, import_promises6.readFile)(buildSessionPath(vault, processEnv), "utf8");
1370
+ const source = await (0, import_promises7.readFile)(buildSessionPath(vault, processEnv), "utf8");
1262
1371
  const document = JSON.parse(source);
1263
1372
  if (document.version !== 1 || typeof document.derivedKey !== "string") {
1264
1373
  return void 0;
@@ -1287,7 +1396,7 @@ function isSecretReference(value) {
1287
1396
  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));
1288
1397
  }
1289
1398
  function resolveSecretStoreRoot(processEnv = process.env) {
1290
- return import_node_path7.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets"));
1399
+ return import_node_path8.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets"));
1291
1400
  }
1292
1401
  function normalizeVaultToken(vault = "default") {
1293
1402
  return vault.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
@@ -1319,16 +1428,16 @@ function deriveVaultKey(passphrase, salt, iterations = PBKDF2_ITERATIONS) {
1319
1428
  return (0, import_node_crypto.pbkdf2Sync)(passphrase, salt, iterations, KEY_LENGTH, "sha512");
1320
1429
  }
1321
1430
  function buildMetaPath(storeRoot, vault = "default") {
1322
- return import_node_path7.default.join(storeRoot, "vaults", vault, META_FILENAME);
1431
+ return import_node_path8.default.join(storeRoot, "vaults", vault, META_FILENAME);
1323
1432
  }
1324
1433
  function buildKeystorePath(storeRoot, vault = "default") {
1325
- return import_node_path7.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1434
+ return import_node_path8.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1326
1435
  }
1327
1436
  function buildLegacyVaultFile(storeRoot, vault = "default") {
1328
- return import_node_path7.default.join(storeRoot, "vaults", `${vault}.json`);
1437
+ return import_node_path8.default.join(storeRoot, "vaults", `${vault}.json`);
1329
1438
  }
1330
1439
  function buildLegacyVaultStoreRoot(storeRoot, vault = "default") {
1331
- return import_node_path7.default.join(storeRoot, "vaults", vault, "store");
1440
+ return import_node_path8.default.join(storeRoot, "vaults", vault, "store");
1332
1441
  }
1333
1442
  function assertVaultMetadata(value, filePath) {
1334
1443
  if (!isObject(value)) {
@@ -1339,9 +1448,9 @@ function assertVaultMetadata(value, filePath) {
1339
1448
  }
1340
1449
  return value;
1341
1450
  }
1342
- async function exists3(targetPath) {
1451
+ async function exists4(targetPath) {
1343
1452
  try {
1344
- await (0, import_promises7.stat)(targetPath);
1453
+ await (0, import_promises8.stat)(targetPath);
1345
1454
  return true;
1346
1455
  } catch {
1347
1456
  return false;
@@ -1350,10 +1459,10 @@ async function exists3(targetPath) {
1350
1459
  async function detectLegacyVaultFormat(storeRoot, vault = "default") {
1351
1460
  const legacyFile = buildLegacyVaultFile(storeRoot, vault);
1352
1461
  const legacyStore = buildLegacyVaultStoreRoot(storeRoot, vault);
1353
- if (await exists3(legacyFile)) {
1462
+ if (await exists4(legacyFile)) {
1354
1463
  return legacyFile;
1355
1464
  }
1356
- if (await exists3(legacyStore)) {
1465
+ if (await exists4(legacyStore)) {
1357
1466
  return legacyStore;
1358
1467
  }
1359
1468
  return void 0;
@@ -1425,15 +1534,15 @@ function buildInitialPayload() {
1425
1534
  async function writeVaultFiles(storeRoot, vault, meta, payload, key) {
1426
1535
  const metaPath = buildMetaPath(storeRoot, vault);
1427
1536
  const keystorePath = buildKeystorePath(storeRoot, vault);
1428
- await (0, import_promises7.mkdir)(import_node_path7.default.dirname(metaPath), { recursive: true });
1429
- await (0, import_promises7.writeFile)(metaPath, stringifyYaml(meta), "utf8");
1430
- await (0, import_promises7.writeFile)(keystorePath, encryptPayload(payload, key));
1537
+ await (0, import_promises8.mkdir)(import_node_path8.default.dirname(metaPath), { recursive: true });
1538
+ await (0, import_promises8.writeFile)(metaPath, stringifyYaml(meta), "utf8");
1539
+ await (0, import_promises8.writeFile)(keystorePath, encryptPayload(payload, key));
1431
1540
  }
1432
1541
  async function readVaultMetadata(storeRoot, vault = "default") {
1433
1542
  await assertNoLegacyVaultFormat(storeRoot, vault);
1434
1543
  const metaPath = buildMetaPath(storeRoot, vault);
1435
1544
  try {
1436
- const source = await (0, import_promises7.readFile)(metaPath, "utf8");
1545
+ const source = await (0, import_promises8.readFile)(metaPath, "utf8");
1437
1546
  return assertVaultMetadata(parseYaml(source), metaPath);
1438
1547
  } catch (error) {
1439
1548
  if (error.code === "ENOENT") {
@@ -1524,7 +1633,7 @@ async function loadVaultPayload(storeRoot, vault, auth) {
1524
1633
  if (!key) {
1525
1634
  throw new CnosAuthenticationError(`Vault "${vault}" requires authentication before access.`);
1526
1635
  }
1527
- const buffer = await (0, import_promises7.readFile)(buildKeystorePath(storeRoot, vault));
1636
+ const buffer = await (0, import_promises8.readFile)(buildKeystorePath(storeRoot, vault));
1528
1637
  return {
1529
1638
  meta,
1530
1639
  payload: decryptPayload(buffer, key),
@@ -1599,9 +1708,9 @@ function resolveVaultDefinition(vaults, vault = "default") {
1599
1708
 
1600
1709
  // ../core/src/secrets/auditLog.ts
1601
1710
  async function appendAuditEvent(event, processEnv = process.env) {
1602
- const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path8.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
1603
- await (0, import_promises8.mkdir)(import_node_path8.default.dirname(auditFile), { recursive: true });
1604
- await (0, import_promises8.appendFile)(
1711
+ const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path9.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
1712
+ await (0, import_promises9.mkdir)(import_node_path9.default.dirname(auditFile), { recursive: true });
1713
+ await (0, import_promises9.appendFile)(
1605
1714
  auditFile,
1606
1715
  `${JSON.stringify({
1607
1716
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1994,6 +2103,60 @@ function requireValue(graph, key) {
1994
2103
  return value;
1995
2104
  }
1996
2105
 
2106
+ // ../core/src/runtime/toServerProjection.ts
2107
+ var import_node_crypto2 = require("crypto");
2108
+ function stableSortObject(value) {
2109
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)));
2110
+ }
2111
+ function stripValuePrefix(key) {
2112
+ return key.startsWith("value.") ? key.slice("value.".length) : key;
2113
+ }
2114
+ function configHash(values) {
2115
+ const serialized = JSON.stringify(stableSortObject(values));
2116
+ return (0, import_node_crypto2.createHash)("sha256").update(serialized).digest("hex");
2117
+ }
2118
+ function toServerProjection(graph, manifest, cnosVersion = "0.0.0-dev") {
2119
+ const values = {};
2120
+ const secretRefs = {};
2121
+ const namespaces = /* @__PURE__ */ new Set();
2122
+ 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));
2123
+ for (const [key, entry] of graph.entries) {
2124
+ if (entry.namespace === "secret" && isSecretReference(entry.value)) {
2125
+ secretRefs[key.slice("secret.".length)] = {
2126
+ provider: entry.value.provider,
2127
+ vault: entry.value.vault ?? "default",
2128
+ ref: entry.value.ref
2129
+ };
2130
+ continue;
2131
+ }
2132
+ if (entry.namespace === "value") {
2133
+ values[stripValuePrefix(key)] = entry.value;
2134
+ continue;
2135
+ }
2136
+ const namespaceDefinition = manifest.namespaces[entry.namespace];
2137
+ if (namespaceDefinition && namespaceDefinition.kind === "data" && !namespaceDefinition.sensitive && entry.namespace !== "public") {
2138
+ values[key] = entry.value;
2139
+ namespaces.add(entry.namespace);
2140
+ }
2141
+ }
2142
+ return {
2143
+ version: 1,
2144
+ workspace: graph.workspace.workspaceId,
2145
+ profile: graph.profile,
2146
+ resolvedAt: graph.resolvedAt,
2147
+ configHash: configHash(values),
2148
+ values: stableSortObject(values),
2149
+ secretRefs: stableSortObject(secretRefs),
2150
+ publicKeys,
2151
+ meta: {
2152
+ workspace: graph.workspace.workspaceId,
2153
+ profile: graph.profile,
2154
+ cnos_version: cnosVersion,
2155
+ ...namespaces.size > 0 ? { namespaces: Array.from(namespaces).sort((left, right) => left.localeCompare(right)) } : {}
2156
+ }
2157
+ };
2158
+ }
2159
+
1997
2160
  // ../core/src/runtime/toEnv.ts
1998
2161
  function normalizeEnvValue(value) {
1999
2162
  if (value === void 0 || value === null) {
@@ -2056,11 +2219,14 @@ function resolvePublicPrefix(manifest, options) {
2056
2219
  if (!options.framework) {
2057
2220
  return "";
2058
2221
  }
2059
- const configuredPrefix = manifest.public.frameworks[options.framework];
2060
- if (!configuredPrefix) {
2222
+ const hasConfiguredPrefix = Object.prototype.hasOwnProperty.call(
2223
+ manifest.public.frameworks,
2224
+ options.framework
2225
+ );
2226
+ if (!hasConfiguredPrefix) {
2061
2227
  throw new CnosManifestError(`Unknown public framework prefix: ${options.framework}`);
2062
2228
  }
2063
- return configuredPrefix;
2229
+ return manifest.public.frameworks[options.framework] ?? "";
2064
2230
  }
2065
2231
  function toPublicEnv(graph, manifest, options = {}) {
2066
2232
  const prefix = resolvePublicPrefix(manifest, options);
@@ -2075,7 +2241,37 @@ function toPublicEnv(graph, manifest, options = {}) {
2075
2241
  }
2076
2242
 
2077
2243
  // ../core/src/orchestrator/runtime.ts
2078
- function createRuntime(manifest, graph, plugins = [], secretCache) {
2244
+ function createRuntime(manifest, graph, plugins = [], secretCache, processEnv = process.env, cnosVersion = "0.0.0-dev") {
2245
+ async function refreshSecretEntry(key) {
2246
+ const entry = graph.entries.get(key);
2247
+ if (!entry || entry.namespace !== "secret" || !isSecretReference(entry.value)) {
2248
+ return;
2249
+ }
2250
+ if (!secretCache) {
2251
+ return;
2252
+ }
2253
+ const vaultId = entry.value.vault ?? "default";
2254
+ const definition = manifest.vaults[vaultId] ?? {
2255
+ provider: entry.value.provider,
2256
+ auth: { passphrase: { from: [] } }
2257
+ };
2258
+ const provider = createSecretVaultProvider(vaultId, definition, processEnv);
2259
+ const auth = await resolveVaultAuth(vaultId, definition, processEnv);
2260
+ await provider.authenticate(auth);
2261
+ const value = await provider.get(entry.value.ref);
2262
+ if (value !== void 0) {
2263
+ secretCache.load(vaultId, /* @__PURE__ */ new Map([[entry.value.ref, value]]));
2264
+ }
2265
+ }
2266
+ async function refreshAllSecrets() {
2267
+ if (!secretCache) {
2268
+ return;
2269
+ }
2270
+ const secretKeys = Array.from(graph.entries.values()).filter((entry) => entry.namespace === "secret" && isSecretReference(entry.value)).map((entry) => entry.key);
2271
+ for (const key of secretKeys) {
2272
+ await refreshSecretEntry(key);
2273
+ }
2274
+ }
2079
2275
  function readLogicalKey(key) {
2080
2276
  const entry = graph.entries.get(key);
2081
2277
  if (!entry) {
@@ -2103,14 +2299,14 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2103
2299
  readOr(key, fallback) {
2104
2300
  return readOrValue(graph, key, fallback);
2105
2301
  },
2106
- value(path12) {
2107
- return readLogicalKey(toLogicalKey("value", path12));
2302
+ value(path13) {
2303
+ return readLogicalKey(toLogicalKey("value", path13));
2108
2304
  },
2109
- secret(path12) {
2110
- return readLogicalKey(toLogicalKey("secret", path12));
2305
+ secret(path13) {
2306
+ return readLogicalKey(toLogicalKey("secret", path13));
2111
2307
  },
2112
- meta(path12) {
2113
- return readLogicalKey(toLogicalKey("meta", path12));
2308
+ meta(path13) {
2309
+ return readLogicalKey(toLogicalKey("meta", path13));
2114
2310
  },
2115
2311
  inspect(key) {
2116
2312
  return inspectValue(graph, key);
@@ -2126,6 +2322,15 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2126
2322
  },
2127
2323
  toPublicEnv(options) {
2128
2324
  return toPublicEnv(graph, manifest, options);
2325
+ },
2326
+ toServerProjection() {
2327
+ return toServerProjection(graph, manifest, cnosVersion);
2328
+ },
2329
+ async refreshSecrets() {
2330
+ await refreshAllSecrets();
2331
+ },
2332
+ async refreshSecret(key) {
2333
+ await refreshSecretEntry(key);
2129
2334
  }
2130
2335
  };
2131
2336
  }
@@ -2224,14 +2429,18 @@ function appendMetaEntries(graph, cnosVersion) {
2224
2429
  };
2225
2430
  }
2226
2431
  async function createCnos(options = {}) {
2227
- const loadedManifest = await loadManifest(options.root ? { root: options.root } : {});
2432
+ const loadedManifest = await loadManifest({
2433
+ ...options.root ? { root: options.root } : {},
2434
+ ...options.cwd ? { cwd: options.cwd } : {}
2435
+ });
2228
2436
  for (const key of loadedManifest.manifest.public.promote) {
2229
2437
  ensureProjectionAllowed(loadedManifest.manifest, key, "public");
2230
2438
  }
2231
- const workspaceFile = await loadWorkspaceFile(loadedManifest.repoRoot);
2439
+ const workspaceFile = await loadWorkspaceFile(loadedManifest.consumerRoot);
2232
2440
  const workspace = await resolveWorkspaceContext(loadedManifest.manifest, {
2233
2441
  manifestRoot: loadedManifest.manifestRoot,
2234
2442
  ...workspaceFile ? { workspaceFile: workspaceFile.config } : {},
2443
+ ...loadedManifest.anchoredWorkspace ? { anchoredWorkspace: loadedManifest.anchoredWorkspace } : {},
2235
2444
  ...options.workspace ? { workspace: options.workspace } : {},
2236
2445
  ...options.globalRoot ? { globalRoot: options.globalRoot } : {},
2237
2446
  ...options.processEnv ? { processEnv: options.processEnv } : {}
@@ -2276,13 +2485,15 @@ async function createCnos(options = {}) {
2276
2485
  profileSource: activeProfile.source
2277
2486
  }, options.cnosVersion),
2278
2487
  plugins,
2279
- secretCache
2488
+ secretCache,
2489
+ options.processEnv,
2490
+ options.cnosVersion
2280
2491
  );
2281
2492
  }
2282
2493
 
2283
2494
  // ../core/src/runtime/dump.ts
2284
- var import_promises9 = require("fs/promises");
2285
- var import_node_path9 = __toESM(require("path"), 1);
2495
+ var import_promises10 = require("fs/promises");
2496
+ var import_node_path10 = __toESM(require("path"), 1);
2286
2497
 
2287
2498
  // ../core/src/utils/envNaming.ts
2288
2499
  function normalizeMappingConfig(config = {}) {
@@ -2291,8 +2502,8 @@ function normalizeMappingConfig(config = {}) {
2291
2502
  explicit: config.explicit ?? {}
2292
2503
  };
2293
2504
  }
2294
- function fromScreamingSnake(path12) {
2295
- return path12.split("_").map((segment) => segment.trim().toLowerCase()).filter(Boolean).join(".");
2505
+ function fromScreamingSnake(path13) {
2506
+ return path13.split("_").map((segment) => segment.trim().toLowerCase()).filter(Boolean).join(".");
2296
2507
  }
2297
2508
  function envVarToLogicalKey(envVar, config = {}) {
2298
2509
  const normalized = normalizeMappingConfig(config);
@@ -2319,7 +2530,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2319
2530
  // package.json
2320
2531
  var package_default = {
2321
2532
  name: "@kitsy/cnos",
2322
- version: "1.5.0",
2533
+ version: "1.6.0",
2323
2534
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2324
2535
  type: "module",
2325
2536
  main: "./dist/index.cjs",
@@ -2518,8 +2729,8 @@ function createCliArgsPlugin() {
2518
2729
  }
2519
2730
 
2520
2731
  // ../../plugins/dotenv/src/index.ts
2521
- var import_promises10 = require("fs/promises");
2522
- var import_node_path10 = __toESM(require("path"), 1);
2732
+ var import_promises11 = require("fs/promises");
2733
+ var import_node_path11 = __toESM(require("path"), 1);
2523
2734
  var DOTENV_PLUGIN_ID = "@kitsy/cnos/plugins/dotenv";
2524
2735
  function parseDoubleQuoted(value) {
2525
2736
  return value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
@@ -2576,7 +2787,7 @@ function dotenvEntriesFromObject(values, mapping = {}, originFile, workspaceId =
2576
2787
  }
2577
2788
  async function readIfPresent(filePath) {
2578
2789
  try {
2579
- return await (0, import_promises10.readFile)(filePath, "utf8");
2790
+ return await (0, import_promises11.readFile)(filePath, "utf8");
2580
2791
  } catch {
2581
2792
  return void 0;
2582
2793
  }
@@ -2595,7 +2806,7 @@ function createDotenvPlugin() {
2595
2806
  workspace: workspaceRoot.workspaceId
2596
2807
  });
2597
2808
  for (const fileName of fileNames) {
2598
- const absolutePath = import_node_path10.default.join(envRoot, fileName);
2809
+ const absolutePath = import_node_path11.default.join(envRoot, fileName);
2599
2810
  const document = await readIfPresent(absolutePath);
2600
2811
  if (!document) {
2601
2812
  continue;
@@ -2604,7 +2815,7 @@ function createDotenvPlugin() {
2604
2815
  ...dotenvEntriesFromObject(
2605
2816
  parseDotenv(document),
2606
2817
  config.envMapping,
2607
- toPortablePath(import_node_path10.default.relative(import_node_path10.default.dirname(context.manifestRoot), absolutePath)),
2818
+ toPortablePath(import_node_path11.default.relative(import_node_path11.default.dirname(context.manifestRoot), absolutePath)),
2608
2819
  workspaceRoot.workspaceId
2609
2820
  )
2610
2821
  );
@@ -2642,16 +2853,16 @@ function createPublicEnvExportPlugin() {
2642
2853
  }
2643
2854
 
2644
2855
  // ../../plugins/filesystem/src/filesystemSecretsReader.ts
2645
- var import_promises12 = require("fs/promises");
2856
+ var import_promises13 = require("fs/promises");
2646
2857
 
2647
2858
  // ../../plugins/filesystem/src/helpers.ts
2648
- var import_promises11 = require("fs/promises");
2649
- var import_node_path11 = __toESM(require("path"), 1);
2859
+ var import_promises12 = require("fs/promises");
2860
+ var import_node_path12 = __toESM(require("path"), 1);
2650
2861
  var YAML_EXTENSIONS = /* @__PURE__ */ new Set([".yml", ".yaml"]);
2651
2862
  var FILESYSTEM_PLUGIN_ID = "@kitsy/cnos/plugins/filesystem";
2652
2863
  async function existsDirectory(targetPath) {
2653
2864
  try {
2654
- const stat2 = await (0, import_promises11.readdir)(targetPath);
2865
+ const stat2 = await (0, import_promises12.readdir)(targetPath);
2655
2866
  void stat2;
2656
2867
  return true;
2657
2868
  } catch {
@@ -2659,15 +2870,15 @@ async function existsDirectory(targetPath) {
2659
2870
  }
2660
2871
  }
2661
2872
  async function collectYamlFiles(root) {
2662
- const entries = await (0, import_promises11.readdir)(root, { withFileTypes: true });
2873
+ const entries = await (0, import_promises12.readdir)(root, { withFileTypes: true });
2663
2874
  const results = [];
2664
2875
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
2665
- const absolutePath = import_node_path11.default.join(root, entry.name);
2876
+ const absolutePath = import_node_path12.default.join(root, entry.name);
2666
2877
  if (entry.isDirectory()) {
2667
2878
  results.push(...await collectYamlFiles(absolutePath));
2668
2879
  continue;
2669
2880
  }
2670
- if (entry.isFile() && YAML_EXTENSIONS.has(import_node_path11.default.extname(entry.name).toLowerCase())) {
2881
+ if (entry.isFile() && YAML_EXTENSIONS.has(import_node_path12.default.extname(entry.name).toLowerCase())) {
2671
2882
  results.push(absolutePath);
2672
2883
  }
2673
2884
  }
@@ -2675,16 +2886,16 @@ async function collectYamlFiles(root) {
2675
2886
  }
2676
2887
  async function collectFilesystemLayerFiles(manifestRoot, workspaceRoots, sourceRoot, activeLayers) {
2677
2888
  const files = [];
2678
- const repoRoot = import_node_path11.default.dirname(manifestRoot);
2889
+ const repoRoot = import_node_path12.default.dirname(manifestRoot);
2679
2890
  for (const workspaceRoot of workspaceRoots) {
2680
- const resolvedRoot = import_node_path11.default.resolve(workspaceRoot.path, sourceRoot);
2891
+ const resolvedRoot = import_node_path12.default.resolve(workspaceRoot.path, sourceRoot);
2681
2892
  for (const layer of activeLayers) {
2682
- const layerRoot = import_node_path11.default.join(resolvedRoot, layer);
2893
+ const layerRoot = import_node_path12.default.join(resolvedRoot, layer);
2683
2894
  if (!await existsDirectory(layerRoot)) {
2684
2895
  continue;
2685
2896
  }
2686
2897
  for (const absolutePath of await collectYamlFiles(layerRoot)) {
2687
- const relativePath = import_node_path11.default.relative(repoRoot, absolutePath);
2898
+ const relativePath = import_node_path12.default.relative(repoRoot, absolutePath);
2688
2899
  files.push({
2689
2900
  absolutePath,
2690
2901
  relativePath: toPortablePath(relativePath.startsWith("..") ? absolutePath : relativePath),
@@ -2761,7 +2972,7 @@ function createFilesystemSecretsPlugin() {
2761
2972
  );
2762
2973
  const entries = [];
2763
2974
  for (const file of files) {
2764
- const document = await (0, import_promises12.readFile)(file.absolutePath, "utf8");
2975
+ const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
2765
2976
  const fileEntries = filesystemSecretsReader(file.relativePath, document, file.workspaceId);
2766
2977
  for (const entry of fileEntries) {
2767
2978
  const metadata = toSecretReferenceMetadata(entry.value);
@@ -2777,7 +2988,7 @@ function createFilesystemSecretsPlugin() {
2777
2988
  }
2778
2989
 
2779
2990
  // ../../plugins/filesystem/src/filesystemValuesReader.ts
2780
- var import_promises13 = require("fs/promises");
2991
+ var import_promises14 = require("fs/promises");
2781
2992
  function filesystemValuesReader(filePath, document, workspaceId = "default") {
2782
2993
  return yamlObjectToEntries(document, filePath, "value", "filesystem-values", workspaceId);
2783
2994
  }
@@ -2798,7 +3009,7 @@ function createFilesystemValuesPlugin() {
2798
3009
  ).map(([namespace]) => namespace);
2799
3010
  const entries = [];
2800
3011
  for (const file of files) {
2801
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3012
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2802
3013
  entries.push(...filesystemValuesReader(file.relativePath, document, file.workspaceId));
2803
3014
  }
2804
3015
  for (const namespace of customNamespaces) {
@@ -2813,7 +3024,7 @@ function createFilesystemValuesPlugin() {
2813
3024
  layers
2814
3025
  );
2815
3026
  for (const file of namespaceFiles) {
2816
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3027
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2817
3028
  entries.push(...yamlObjectToEntries(document, file.relativePath, namespace, "filesystem-values", file.workspaceId));
2818
3029
  }
2819
3030
  }
@@ -2981,8 +3192,8 @@ async function resolveBrowserData(options = {}) {
2981
3192
  function toScreamingSnakeSegment(segment) {
2982
3193
  return segment.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
2983
3194
  }
2984
- function toScreamingSnake(path12) {
2985
- return path12.split(".").map((segment) => toScreamingSnakeSegment(segment)).filter(Boolean).join("_");
3195
+ function toScreamingSnake(path13) {
3196
+ return path13.split(".").map((segment) => toScreamingSnakeSegment(segment)).filter(Boolean).join("_");
2986
3197
  }
2987
3198
  function stripPublicNamespace(key) {
2988
3199
  return key.startsWith("public.") ? key.slice("public.".length) : key;
@@ -3023,9 +3234,14 @@ async function resolveFrameworkEnv(options = {}, framework = "generic", envOptio
3023
3234
  ...envOptions.prefix ? { prefix: envOptions.prefix } : {}
3024
3235
  });
3025
3236
  }
3237
+ async function resolveServerProjection(options = {}) {
3238
+ const runtime = await createCnos2(options);
3239
+ return runtime.toServerProjection();
3240
+ }
3026
3241
  // Annotate the CommonJS export names for ESM import in node:
3027
3242
  0 && (module.exports = {
3028
3243
  resolveBrowserData,
3029
3244
  resolveFrameworkEnv,
3245
+ resolveServerProjection,
3030
3246
  toFrameworkEnv
3031
3247
  });