@kitsy/cnos 1.5.1 → 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 +325 -113
  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-UWFE4JE2.js → chunk-BMAD24KC.js} +1 -1
  6. package/dist/{chunk-7EI3RFUE.js → chunk-JYWQFMW5.js} +1 -1
  7. package/dist/{chunk-F2ZAIZNH.js → chunk-MW4OVAT3.js} +1 -1
  8. package/dist/chunk-QU5CXL47.js +577 -0
  9. package/dist/{chunk-BS33AW4Y.js → chunk-S7H2UULC.js} +307 -103
  10. package/dist/{chunk-H53ZRQLX.js → chunk-UJBQS7CJ.js} +1 -1
  11. package/dist/{chunk-CMQK2AEF.js → chunk-UOKVLCFL.js} +10 -10
  12. package/dist/{chunk-EJAXWFNT.js → chunk-UR7CHHNN.js} +1 -1
  13. package/dist/{chunk-SZKQVA2M.js → chunk-VGZREX5D.js} +1 -1
  14. package/dist/{chunk-5F2OFKND.js → chunk-XSUP7JKH.js} +23 -1
  15. package/dist/configure/index.cjs +324 -118
  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 +698 -136
  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 +227 -102
  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 +28 -19
  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 +696 -136
  56. package/dist/runtime/index.d.cts +7 -1
  57. package/dist/runtime/index.d.ts +7 -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-TUMR7JA3.js +0 -234
@@ -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 = [
@@ -533,11 +623,15 @@ function normalizeManifest(manifest) {
533
623
 
534
624
  // ../core/src/manifest/loadManifest.ts
535
625
  async function loadManifest(options = {}) {
536
- const manifestRoot = await resolveManifestRoot(options.root);
537
- 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");
538
632
  let source;
539
633
  try {
540
- source = await (0, import_promises2.readFile)(manifestPath, "utf8");
634
+ source = await (0, import_promises3.readFile)(manifestPath, "utf8");
541
635
  } catch {
542
636
  throw new CnosManifestError("Unable to read CNOS manifest", manifestPath);
543
637
  }
@@ -547,7 +641,10 @@ async function loadManifest(options = {}) {
547
641
  }
548
642
  return {
549
643
  manifestRoot,
550
- 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 } : {},
551
648
  manifestPath,
552
649
  manifest: normalizeManifest(rawManifest),
553
650
  rawManifest
@@ -555,12 +652,12 @@ async function loadManifest(options = {}) {
555
652
  }
556
653
 
557
654
  // ../core/src/manifest/loadWorkspaceFile.ts
558
- var import_promises3 = require("fs/promises");
559
- var import_node_path3 = __toESM(require("path"), 1);
655
+ var import_promises4 = require("fs/promises");
656
+ var import_node_path4 = __toESM(require("path"), 1);
560
657
  async function loadWorkspaceFile(repoRoot) {
561
- const workspaceFilePath = import_node_path3.default.join(repoRoot, ".cnos-workspace.yml");
658
+ const workspaceFilePath = import_node_path4.default.join(repoRoot, ".cnos-workspace.yml");
562
659
  try {
563
- const source = await (0, import_promises3.readFile)(workspaceFilePath, "utf8");
660
+ const source = await (0, import_promises4.readFile)(workspaceFilePath, "utf8");
564
661
  const parsed = parseYaml(source);
565
662
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
566
663
  throw new CnosManifestError(".cnos-workspace.yml must be a YAML object", workspaceFilePath);
@@ -583,11 +680,11 @@ async function loadWorkspaceFile(repoRoot) {
583
680
  }
584
681
 
585
682
  // ../core/src/profiles/expandProfileChain.ts
586
- var import_promises4 = require("fs/promises");
587
- var import_node_path4 = __toESM(require("path"), 1);
683
+ var import_promises5 = require("fs/promises");
684
+ var import_node_path5 = __toESM(require("path"), 1);
588
685
  async function fileExists(targetPath) {
589
686
  try {
590
- await (0, import_promises4.access)(targetPath);
687
+ await (0, import_promises5.access)(targetPath);
591
688
  return true;
592
689
  } catch {
593
690
  return false;
@@ -621,11 +718,11 @@ async function loadProfileDefinition(profileName, options) {
621
718
  return normalizeProfileDefinition(profileName, void 0);
622
719
  }
623
720
  for (const workspaceRoot of [...workspaceRoots].reverse()) {
624
- 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`);
625
722
  if (!await fileExists(profilePath)) {
626
723
  continue;
627
724
  }
628
- const document = await (0, import_promises4.readFile)(profilePath, "utf8");
725
+ const document = await (0, import_promises5.readFile)(profilePath, "utf8");
629
726
  const parsed = parseYaml(document);
630
727
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
631
728
  throw new CnosManifestError("Profile definition must be a YAML object", profilePath);
@@ -633,7 +730,7 @@ async function loadProfileDefinition(profileName, options) {
633
730
  const definition = normalizeProfileDefinition(
634
731
  profileName,
635
732
  parsed,
636
- 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)
637
734
  );
638
735
  if (definition.name !== profileName) {
639
736
  throw new CnosManifestError(
@@ -915,8 +1012,8 @@ function createProfileAwareResolver() {
915
1012
  }
916
1013
 
917
1014
  // ../core/src/workspaces/resolveWorkspaceContext.ts
918
- var import_promises5 = require("fs/promises");
919
- var import_node_path5 = __toESM(require("path"), 1);
1015
+ var import_promises6 = require("fs/promises");
1016
+ var import_node_path6 = __toESM(require("path"), 1);
920
1017
 
921
1018
  // ../core/src/workspaces/expandWorkspaceChain.ts
922
1019
  function expandWorkspaceChain(workspaceId, items) {
@@ -953,31 +1050,31 @@ function expandWorkspaceChain(workspaceId, items) {
953
1050
  }
954
1051
 
955
1052
  // ../core/src/workspaces/resolveWorkspaceContext.ts
956
- async function exists2(targetPath) {
1053
+ async function exists3(targetPath) {
957
1054
  try {
958
- await (0, import_promises5.access)(targetPath);
1055
+ await (0, import_promises6.access)(targetPath);
959
1056
  return true;
960
1057
  } catch {
961
1058
  return false;
962
1059
  }
963
1060
  }
964
1061
  async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId, manifest) {
965
- const workspaceRoot = import_node_path5.default.join(manifestRoot, "workspaces", workspaceId);
966
- if (await exists2(workspaceRoot)) {
1062
+ const workspaceRoot = import_node_path6.default.join(manifestRoot, "workspaces", workspaceId);
1063
+ if (await exists3(workspaceRoot)) {
967
1064
  return workspaceRoot;
968
1065
  }
969
1066
  const customDataNamespaceRoots = Object.entries(manifest.namespaces).filter(
970
1067
  ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
971
1068
  ).map(([namespace]) => namespace);
972
1069
  const legacyMarkers = ["values", "secrets", "env", "profiles", ...customDataNamespaceRoots].map(
973
- (segment) => import_node_path5.default.join(manifestRoot, segment)
1070
+ (segment) => import_node_path6.default.join(manifestRoot, segment)
974
1071
  );
975
- if ((await Promise.all(legacyMarkers.map((marker) => exists2(marker)))).some(Boolean)) {
1072
+ if ((await Promise.all(legacyMarkers.map((marker) => exists3(marker)))).some(Boolean)) {
976
1073
  return manifestRoot;
977
1074
  }
978
1075
  return workspaceRoot;
979
1076
  }
980
- function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
1077
+ function resolveWorkspaceSelection(manifest, workspaceFile, anchoredWorkspace, workspaceOption) {
981
1078
  if (workspaceOption) {
982
1079
  return {
983
1080
  workspaceId: workspaceOption,
@@ -990,6 +1087,12 @@ function resolveWorkspaceSelection(manifest, workspaceFile, workspaceOption) {
990
1087
  source: "workspace-file"
991
1088
  };
992
1089
  }
1090
+ if (anchoredWorkspace) {
1091
+ return {
1092
+ workspaceId: anchoredWorkspace,
1093
+ source: "anchor-file"
1094
+ };
1095
+ }
993
1096
  if (manifest.workspaces.default) {
994
1097
  return {
995
1098
  workspaceId: manifest.workspaces.default,
@@ -1012,33 +1115,38 @@ function resolveGlobalRoot(manifest, workspaceFile, options) {
1012
1115
  }
1013
1116
  if (options.globalRoot) {
1014
1117
  return {
1015
- value: import_node_path5.default.resolve(expandHomePath(options.globalRoot)),
1118
+ value: import_node_path6.default.resolve(expandHomePath(options.globalRoot)),
1016
1119
  source: "cli"
1017
1120
  };
1018
1121
  }
1019
1122
  if (workspaceFile?.globalRoot) {
1020
1123
  return {
1021
- value: import_node_path5.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1124
+ value: import_node_path6.default.resolve(expandHomePath(workspaceFile.globalRoot)),
1022
1125
  source: "workspace-file"
1023
1126
  };
1024
1127
  }
1025
1128
  if (manifest.workspaces.global.root) {
1026
1129
  return {
1027
- value: import_node_path5.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1130
+ value: import_node_path6.default.resolve(expandHomePath(manifest.workspaces.global.root)),
1028
1131
  source: "manifest"
1029
1132
  };
1030
1133
  }
1031
1134
  const cnosHome = options.processEnv?.CNOS_HOME;
1032
1135
  if (cnosHome) {
1033
1136
  return {
1034
- value: import_node_path5.default.resolve(expandHomePath(cnosHome)),
1137
+ value: import_node_path6.default.resolve(expandHomePath(cnosHome)),
1035
1138
  source: "CNOS_HOME"
1036
1139
  };
1037
1140
  }
1038
1141
  return {};
1039
1142
  }
1040
1143
  async function resolveWorkspaceContext(manifest, options) {
1041
- const selectedWorkspace = resolveWorkspaceSelection(manifest, options.workspaceFile, options.workspace);
1144
+ const selectedWorkspace = resolveWorkspaceSelection(
1145
+ manifest,
1146
+ options.workspaceFile,
1147
+ options.anchoredWorkspace,
1148
+ options.workspace
1149
+ );
1042
1150
  const workspaceChain = expandWorkspaceChain(selectedWorkspace.workspaceId, manifest.workspaces.items);
1043
1151
  const globalRoot = resolveGlobalRoot(manifest, options.workspaceFile, options);
1044
1152
  const workspaceRoots = [];
@@ -1048,7 +1156,7 @@ async function resolveWorkspaceContext(manifest, options) {
1048
1156
  workspaceRoots.push({
1049
1157
  scope: "global",
1050
1158
  workspaceId: chainWorkspaceId,
1051
- path: import_node_path5.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1159
+ path: import_node_path6.default.join(globalRoot.value, "workspaces", globalWorkspaceId)
1052
1160
  });
1053
1161
  }
1054
1162
  }
@@ -1240,26 +1348,26 @@ async function runPipeline(options) {
1240
1348
  }
1241
1349
 
1242
1350
  // ../core/src/secrets/auditLog.ts
1243
- var import_promises8 = require("fs/promises");
1244
- var import_node_path8 = __toESM(require("path"), 1);
1351
+ var import_promises9 = require("fs/promises");
1352
+ var import_node_path9 = __toESM(require("path"), 1);
1245
1353
 
1246
1354
  // ../core/src/utils/secretStore.ts
1247
1355
  var import_node_crypto = require("crypto");
1248
- var import_promises7 = require("fs/promises");
1249
- var import_node_path7 = __toESM(require("path"), 1);
1356
+ var import_promises8 = require("fs/promises");
1357
+ var import_node_path8 = __toESM(require("path"), 1);
1250
1358
 
1251
1359
  // ../core/src/secrets/sessionStore.ts
1252
- var import_promises6 = require("fs/promises");
1253
- var import_node_path6 = __toESM(require("path"), 1);
1360
+ var import_promises7 = require("fs/promises");
1361
+ var import_node_path7 = __toESM(require("path"), 1);
1254
1362
  function buildSessionRoot(processEnv = process.env) {
1255
- 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");
1256
1364
  }
1257
1365
  function buildSessionPath(vault, processEnv) {
1258
- return import_node_path6.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1366
+ return import_node_path7.default.join(buildSessionRoot(processEnv), `${vault}.json`);
1259
1367
  }
1260
1368
  async function readVaultSessionKey(vault, processEnv) {
1261
1369
  try {
1262
- const source = await (0, import_promises6.readFile)(buildSessionPath(vault, processEnv), "utf8");
1370
+ const source = await (0, import_promises7.readFile)(buildSessionPath(vault, processEnv), "utf8");
1263
1371
  const document = JSON.parse(source);
1264
1372
  if (document.version !== 1 || typeof document.derivedKey !== "string") {
1265
1373
  return void 0;
@@ -1288,7 +1396,7 @@ function isSecretReference(value) {
1288
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));
1289
1397
  }
1290
1398
  function resolveSecretStoreRoot(processEnv = process.env) {
1291
- 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"));
1292
1400
  }
1293
1401
  function normalizeVaultToken(vault = "default") {
1294
1402
  return vault.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
@@ -1320,16 +1428,16 @@ function deriveVaultKey(passphrase, salt, iterations = PBKDF2_ITERATIONS) {
1320
1428
  return (0, import_node_crypto.pbkdf2Sync)(passphrase, salt, iterations, KEY_LENGTH, "sha512");
1321
1429
  }
1322
1430
  function buildMetaPath(storeRoot, vault = "default") {
1323
- return import_node_path7.default.join(storeRoot, "vaults", vault, META_FILENAME);
1431
+ return import_node_path8.default.join(storeRoot, "vaults", vault, META_FILENAME);
1324
1432
  }
1325
1433
  function buildKeystorePath(storeRoot, vault = "default") {
1326
- return import_node_path7.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1434
+ return import_node_path8.default.join(storeRoot, "vaults", vault, KEYSTORE_FILENAME);
1327
1435
  }
1328
1436
  function buildLegacyVaultFile(storeRoot, vault = "default") {
1329
- return import_node_path7.default.join(storeRoot, "vaults", `${vault}.json`);
1437
+ return import_node_path8.default.join(storeRoot, "vaults", `${vault}.json`);
1330
1438
  }
1331
1439
  function buildLegacyVaultStoreRoot(storeRoot, vault = "default") {
1332
- return import_node_path7.default.join(storeRoot, "vaults", vault, "store");
1440
+ return import_node_path8.default.join(storeRoot, "vaults", vault, "store");
1333
1441
  }
1334
1442
  function assertVaultMetadata(value, filePath) {
1335
1443
  if (!isObject(value)) {
@@ -1340,9 +1448,9 @@ function assertVaultMetadata(value, filePath) {
1340
1448
  }
1341
1449
  return value;
1342
1450
  }
1343
- async function exists3(targetPath) {
1451
+ async function exists4(targetPath) {
1344
1452
  try {
1345
- await (0, import_promises7.stat)(targetPath);
1453
+ await (0, import_promises8.stat)(targetPath);
1346
1454
  return true;
1347
1455
  } catch {
1348
1456
  return false;
@@ -1351,10 +1459,10 @@ async function exists3(targetPath) {
1351
1459
  async function detectLegacyVaultFormat(storeRoot, vault = "default") {
1352
1460
  const legacyFile = buildLegacyVaultFile(storeRoot, vault);
1353
1461
  const legacyStore = buildLegacyVaultStoreRoot(storeRoot, vault);
1354
- if (await exists3(legacyFile)) {
1462
+ if (await exists4(legacyFile)) {
1355
1463
  return legacyFile;
1356
1464
  }
1357
- if (await exists3(legacyStore)) {
1465
+ if (await exists4(legacyStore)) {
1358
1466
  return legacyStore;
1359
1467
  }
1360
1468
  return void 0;
@@ -1426,15 +1534,15 @@ function buildInitialPayload() {
1426
1534
  async function writeVaultFiles(storeRoot, vault, meta, payload, key) {
1427
1535
  const metaPath = buildMetaPath(storeRoot, vault);
1428
1536
  const keystorePath = buildKeystorePath(storeRoot, vault);
1429
- await (0, import_promises7.mkdir)(import_node_path7.default.dirname(metaPath), { recursive: true });
1430
- await (0, import_promises7.writeFile)(metaPath, stringifyYaml(meta), "utf8");
1431
- 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));
1432
1540
  }
1433
1541
  async function readVaultMetadata(storeRoot, vault = "default") {
1434
1542
  await assertNoLegacyVaultFormat(storeRoot, vault);
1435
1543
  const metaPath = buildMetaPath(storeRoot, vault);
1436
1544
  try {
1437
- const source = await (0, import_promises7.readFile)(metaPath, "utf8");
1545
+ const source = await (0, import_promises8.readFile)(metaPath, "utf8");
1438
1546
  return assertVaultMetadata(parseYaml(source), metaPath);
1439
1547
  } catch (error) {
1440
1548
  if (error.code === "ENOENT") {
@@ -1525,7 +1633,7 @@ async function loadVaultPayload(storeRoot, vault, auth) {
1525
1633
  if (!key) {
1526
1634
  throw new CnosAuthenticationError(`Vault "${vault}" requires authentication before access.`);
1527
1635
  }
1528
- const buffer = await (0, import_promises7.readFile)(buildKeystorePath(storeRoot, vault));
1636
+ const buffer = await (0, import_promises8.readFile)(buildKeystorePath(storeRoot, vault));
1529
1637
  return {
1530
1638
  meta,
1531
1639
  payload: decryptPayload(buffer, key),
@@ -1600,9 +1708,9 @@ function resolveVaultDefinition(vaults, vault = "default") {
1600
1708
 
1601
1709
  // ../core/src/secrets/auditLog.ts
1602
1710
  async function appendAuditEvent(event, processEnv = process.env) {
1603
- const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path8.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
1604
- await (0, import_promises8.mkdir)(import_node_path8.default.dirname(auditFile), { recursive: true });
1605
- 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)(
1606
1714
  auditFile,
1607
1715
  `${JSON.stringify({
1608
1716
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1995,6 +2103,60 @@ function requireValue(graph, key) {
1995
2103
  return value;
1996
2104
  }
1997
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
+
1998
2160
  // ../core/src/runtime/toEnv.ts
1999
2161
  function normalizeEnvValue(value) {
2000
2162
  if (value === void 0 || value === null) {
@@ -2079,7 +2241,37 @@ function toPublicEnv(graph, manifest, options = {}) {
2079
2241
  }
2080
2242
 
2081
2243
  // ../core/src/orchestrator/runtime.ts
2082
- 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
+ }
2083
2275
  function readLogicalKey(key) {
2084
2276
  const entry = graph.entries.get(key);
2085
2277
  if (!entry) {
@@ -2107,14 +2299,14 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2107
2299
  readOr(key, fallback) {
2108
2300
  return readOrValue(graph, key, fallback);
2109
2301
  },
2110
- value(path12) {
2111
- return readLogicalKey(toLogicalKey("value", path12));
2302
+ value(path13) {
2303
+ return readLogicalKey(toLogicalKey("value", path13));
2112
2304
  },
2113
- secret(path12) {
2114
- return readLogicalKey(toLogicalKey("secret", path12));
2305
+ secret(path13) {
2306
+ return readLogicalKey(toLogicalKey("secret", path13));
2115
2307
  },
2116
- meta(path12) {
2117
- return readLogicalKey(toLogicalKey("meta", path12));
2308
+ meta(path13) {
2309
+ return readLogicalKey(toLogicalKey("meta", path13));
2118
2310
  },
2119
2311
  inspect(key) {
2120
2312
  return inspectValue(graph, key);
@@ -2130,6 +2322,15 @@ function createRuntime(manifest, graph, plugins = [], secretCache) {
2130
2322
  },
2131
2323
  toPublicEnv(options) {
2132
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);
2133
2334
  }
2134
2335
  };
2135
2336
  }
@@ -2228,14 +2429,18 @@ function appendMetaEntries(graph, cnosVersion) {
2228
2429
  };
2229
2430
  }
2230
2431
  async function createCnos(options = {}) {
2231
- 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
+ });
2232
2436
  for (const key of loadedManifest.manifest.public.promote) {
2233
2437
  ensureProjectionAllowed(loadedManifest.manifest, key, "public");
2234
2438
  }
2235
- const workspaceFile = await loadWorkspaceFile(loadedManifest.repoRoot);
2439
+ const workspaceFile = await loadWorkspaceFile(loadedManifest.consumerRoot);
2236
2440
  const workspace = await resolveWorkspaceContext(loadedManifest.manifest, {
2237
2441
  manifestRoot: loadedManifest.manifestRoot,
2238
2442
  ...workspaceFile ? { workspaceFile: workspaceFile.config } : {},
2443
+ ...loadedManifest.anchoredWorkspace ? { anchoredWorkspace: loadedManifest.anchoredWorkspace } : {},
2239
2444
  ...options.workspace ? { workspace: options.workspace } : {},
2240
2445
  ...options.globalRoot ? { globalRoot: options.globalRoot } : {},
2241
2446
  ...options.processEnv ? { processEnv: options.processEnv } : {}
@@ -2280,13 +2485,15 @@ async function createCnos(options = {}) {
2280
2485
  profileSource: activeProfile.source
2281
2486
  }, options.cnosVersion),
2282
2487
  plugins,
2283
- secretCache
2488
+ secretCache,
2489
+ options.processEnv,
2490
+ options.cnosVersion
2284
2491
  );
2285
2492
  }
2286
2493
 
2287
2494
  // ../core/src/runtime/dump.ts
2288
- var import_promises9 = require("fs/promises");
2289
- var import_node_path9 = __toESM(require("path"), 1);
2495
+ var import_promises10 = require("fs/promises");
2496
+ var import_node_path10 = __toESM(require("path"), 1);
2290
2497
 
2291
2498
  // ../core/src/utils/envNaming.ts
2292
2499
  function normalizeMappingConfig(config = {}) {
@@ -2295,8 +2502,8 @@ function normalizeMappingConfig(config = {}) {
2295
2502
  explicit: config.explicit ?? {}
2296
2503
  };
2297
2504
  }
2298
- function fromScreamingSnake(path12) {
2299
- 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(".");
2300
2507
  }
2301
2508
  function envVarToLogicalKey(envVar, config = {}) {
2302
2509
  const normalized = normalizeMappingConfig(config);
@@ -2323,7 +2530,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2323
2530
  // package.json
2324
2531
  var package_default = {
2325
2532
  name: "@kitsy/cnos",
2326
- version: "1.5.1",
2533
+ version: "1.6.0",
2327
2534
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2328
2535
  type: "module",
2329
2536
  main: "./dist/index.cjs",
@@ -2522,8 +2729,8 @@ function createCliArgsPlugin() {
2522
2729
  }
2523
2730
 
2524
2731
  // ../../plugins/dotenv/src/index.ts
2525
- var import_promises10 = require("fs/promises");
2526
- var import_node_path10 = __toESM(require("path"), 1);
2732
+ var import_promises11 = require("fs/promises");
2733
+ var import_node_path11 = __toESM(require("path"), 1);
2527
2734
  var DOTENV_PLUGIN_ID = "@kitsy/cnos/plugins/dotenv";
2528
2735
  function parseDoubleQuoted(value) {
2529
2736
  return value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
@@ -2580,7 +2787,7 @@ function dotenvEntriesFromObject(values, mapping = {}, originFile, workspaceId =
2580
2787
  }
2581
2788
  async function readIfPresent(filePath) {
2582
2789
  try {
2583
- return await (0, import_promises10.readFile)(filePath, "utf8");
2790
+ return await (0, import_promises11.readFile)(filePath, "utf8");
2584
2791
  } catch {
2585
2792
  return void 0;
2586
2793
  }
@@ -2599,7 +2806,7 @@ function createDotenvPlugin() {
2599
2806
  workspace: workspaceRoot.workspaceId
2600
2807
  });
2601
2808
  for (const fileName of fileNames) {
2602
- const absolutePath = import_node_path10.default.join(envRoot, fileName);
2809
+ const absolutePath = import_node_path11.default.join(envRoot, fileName);
2603
2810
  const document = await readIfPresent(absolutePath);
2604
2811
  if (!document) {
2605
2812
  continue;
@@ -2608,7 +2815,7 @@ function createDotenvPlugin() {
2608
2815
  ...dotenvEntriesFromObject(
2609
2816
  parseDotenv(document),
2610
2817
  config.envMapping,
2611
- 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)),
2612
2819
  workspaceRoot.workspaceId
2613
2820
  )
2614
2821
  );
@@ -2646,16 +2853,16 @@ function createPublicEnvExportPlugin() {
2646
2853
  }
2647
2854
 
2648
2855
  // ../../plugins/filesystem/src/filesystemSecretsReader.ts
2649
- var import_promises12 = require("fs/promises");
2856
+ var import_promises13 = require("fs/promises");
2650
2857
 
2651
2858
  // ../../plugins/filesystem/src/helpers.ts
2652
- var import_promises11 = require("fs/promises");
2653
- var import_node_path11 = __toESM(require("path"), 1);
2859
+ var import_promises12 = require("fs/promises");
2860
+ var import_node_path12 = __toESM(require("path"), 1);
2654
2861
  var YAML_EXTENSIONS = /* @__PURE__ */ new Set([".yml", ".yaml"]);
2655
2862
  var FILESYSTEM_PLUGIN_ID = "@kitsy/cnos/plugins/filesystem";
2656
2863
  async function existsDirectory(targetPath) {
2657
2864
  try {
2658
- const stat2 = await (0, import_promises11.readdir)(targetPath);
2865
+ const stat2 = await (0, import_promises12.readdir)(targetPath);
2659
2866
  void stat2;
2660
2867
  return true;
2661
2868
  } catch {
@@ -2663,15 +2870,15 @@ async function existsDirectory(targetPath) {
2663
2870
  }
2664
2871
  }
2665
2872
  async function collectYamlFiles(root) {
2666
- const entries = await (0, import_promises11.readdir)(root, { withFileTypes: true });
2873
+ const entries = await (0, import_promises12.readdir)(root, { withFileTypes: true });
2667
2874
  const results = [];
2668
2875
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
2669
- const absolutePath = import_node_path11.default.join(root, entry.name);
2876
+ const absolutePath = import_node_path12.default.join(root, entry.name);
2670
2877
  if (entry.isDirectory()) {
2671
2878
  results.push(...await collectYamlFiles(absolutePath));
2672
2879
  continue;
2673
2880
  }
2674
- 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())) {
2675
2882
  results.push(absolutePath);
2676
2883
  }
2677
2884
  }
@@ -2679,16 +2886,16 @@ async function collectYamlFiles(root) {
2679
2886
  }
2680
2887
  async function collectFilesystemLayerFiles(manifestRoot, workspaceRoots, sourceRoot, activeLayers) {
2681
2888
  const files = [];
2682
- const repoRoot = import_node_path11.default.dirname(manifestRoot);
2889
+ const repoRoot = import_node_path12.default.dirname(manifestRoot);
2683
2890
  for (const workspaceRoot of workspaceRoots) {
2684
- const resolvedRoot = import_node_path11.default.resolve(workspaceRoot.path, sourceRoot);
2891
+ const resolvedRoot = import_node_path12.default.resolve(workspaceRoot.path, sourceRoot);
2685
2892
  for (const layer of activeLayers) {
2686
- const layerRoot = import_node_path11.default.join(resolvedRoot, layer);
2893
+ const layerRoot = import_node_path12.default.join(resolvedRoot, layer);
2687
2894
  if (!await existsDirectory(layerRoot)) {
2688
2895
  continue;
2689
2896
  }
2690
2897
  for (const absolutePath of await collectYamlFiles(layerRoot)) {
2691
- const relativePath = import_node_path11.default.relative(repoRoot, absolutePath);
2898
+ const relativePath = import_node_path12.default.relative(repoRoot, absolutePath);
2692
2899
  files.push({
2693
2900
  absolutePath,
2694
2901
  relativePath: toPortablePath(relativePath.startsWith("..") ? absolutePath : relativePath),
@@ -2765,7 +2972,7 @@ function createFilesystemSecretsPlugin() {
2765
2972
  );
2766
2973
  const entries = [];
2767
2974
  for (const file of files) {
2768
- const document = await (0, import_promises12.readFile)(file.absolutePath, "utf8");
2975
+ const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
2769
2976
  const fileEntries = filesystemSecretsReader(file.relativePath, document, file.workspaceId);
2770
2977
  for (const entry of fileEntries) {
2771
2978
  const metadata = toSecretReferenceMetadata(entry.value);
@@ -2781,7 +2988,7 @@ function createFilesystemSecretsPlugin() {
2781
2988
  }
2782
2989
 
2783
2990
  // ../../plugins/filesystem/src/filesystemValuesReader.ts
2784
- var import_promises13 = require("fs/promises");
2991
+ var import_promises14 = require("fs/promises");
2785
2992
  function filesystemValuesReader(filePath, document, workspaceId = "default") {
2786
2993
  return yamlObjectToEntries(document, filePath, "value", "filesystem-values", workspaceId);
2787
2994
  }
@@ -2802,7 +3009,7 @@ function createFilesystemValuesPlugin() {
2802
3009
  ).map(([namespace]) => namespace);
2803
3010
  const entries = [];
2804
3011
  for (const file of files) {
2805
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3012
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2806
3013
  entries.push(...filesystemValuesReader(file.relativePath, document, file.workspaceId));
2807
3014
  }
2808
3015
  for (const namespace of customNamespaces) {
@@ -2817,7 +3024,7 @@ function createFilesystemValuesPlugin() {
2817
3024
  layers
2818
3025
  );
2819
3026
  for (const file of namespaceFiles) {
2820
- const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
3027
+ const document = await (0, import_promises14.readFile)(file.absolutePath, "utf8");
2821
3028
  entries.push(...yamlObjectToEntries(document, file.relativePath, namespace, "filesystem-values", file.workspaceId));
2822
3029
  }
2823
3030
  }
@@ -2985,8 +3192,8 @@ async function resolveBrowserData(options = {}) {
2985
3192
  function toScreamingSnakeSegment(segment) {
2986
3193
  return segment.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
2987
3194
  }
2988
- function toScreamingSnake(path12) {
2989
- 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("_");
2990
3197
  }
2991
3198
  function stripPublicNamespace(key) {
2992
3199
  return key.startsWith("public.") ? key.slice("public.".length) : key;
@@ -3027,9 +3234,14 @@ async function resolveFrameworkEnv(options = {}, framework = "generic", envOptio
3027
3234
  ...envOptions.prefix ? { prefix: envOptions.prefix } : {}
3028
3235
  });
3029
3236
  }
3237
+ async function resolveServerProjection(options = {}) {
3238
+ const runtime = await createCnos2(options);
3239
+ return runtime.toServerProjection();
3240
+ }
3030
3241
  // Annotate the CommonJS export names for ESM import in node:
3031
3242
  0 && (module.exports = {
3032
3243
  resolveBrowserData,
3033
3244
  resolveFrameworkEnv,
3245
+ resolveServerProjection,
3034
3246
  toFrameworkEnv
3035
3247
  });