@kitsy/cnos 1.5.1 → 1.6.1

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