@maverickcer/env-cap 0.5.3 → 0.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 (256) hide show
  1. package/README.md +11 -5
  2. package/dist/.dts/build/assemble-project.d.ts +1 -1
  3. package/dist/.dts/build/assemble-project.d.ts.map +1 -1
  4. package/dist/.dts/build/change-model.d.ts.map +1 -1
  5. package/dist/.dts/build/check-artifacts.d.ts.map +1 -1
  6. package/dist/.dts/build/citation-verification.d.ts.map +1 -1
  7. package/dist/.dts/build/compatibility.d.ts.map +1 -1
  8. package/dist/.dts/build/compiler-api.d.ts +15 -0
  9. package/dist/.dts/build/compiler-api.d.ts.map +1 -0
  10. package/dist/.dts/build/dependency-graph.d.ts +3 -1
  11. package/dist/.dts/build/dependency-graph.d.ts.map +1 -1
  12. package/dist/.dts/build/dependency-model.d.ts.map +1 -1
  13. package/dist/.dts/build/discover.d.ts.map +1 -1
  14. package/dist/.dts/build/docs.d.ts +1 -1
  15. package/dist/.dts/build/docs.d.ts.map +1 -1
  16. package/dist/.dts/build/env-example.d.ts.map +1 -1
  17. package/dist/.dts/build/evidence-cache.d.ts +1 -1
  18. package/dist/.dts/build/evidence-cache.d.ts.map +1 -1
  19. package/dist/.dts/build/evidence-model.d.ts +2 -2
  20. package/dist/.dts/build/evidence-snapshot.d.ts +25 -0
  21. package/dist/.dts/build/evidence-snapshot.d.ts.map +1 -1
  22. package/dist/.dts/build/finding-model.d.ts +1 -1
  23. package/dist/.dts/build/finding-model.d.ts.map +1 -1
  24. package/dist/.dts/build/generate-documentation.d.ts.map +1 -1
  25. package/dist/.dts/build/generate-env-artifacts.d.ts +23 -8
  26. package/dist/.dts/build/generate-env-artifacts.d.ts.map +1 -1
  27. package/dist/.dts/build/generate-evidence.d.ts.map +1 -1
  28. package/dist/.dts/build/generate-manifest.d.ts +1 -1
  29. package/dist/.dts/build/generate-manifest.d.ts.map +1 -1
  30. package/dist/.dts/build/generate-usage.d.ts +3 -3
  31. package/dist/.dts/build/generate-usage.d.ts.map +1 -1
  32. package/dist/.dts/build/generated-banner.d.ts +15 -3
  33. package/dist/.dts/build/generated-banner.d.ts.map +1 -1
  34. package/dist/.dts/build/glob.d.ts.map +1 -1
  35. package/dist/.dts/build/index.d.ts +2 -2
  36. package/dist/.dts/build/lifecycle-model.d.ts.map +1 -1
  37. package/dist/.dts/build/link.d.ts.map +1 -1
  38. package/dist/.dts/build/literal-eval.d.ts +4 -3
  39. package/dist/.dts/build/literal-eval.d.ts.map +1 -1
  40. package/dist/.dts/build/live-expirations.d.ts.map +1 -1
  41. package/dist/.dts/build/manifest.d.ts.map +1 -1
  42. package/dist/.dts/build/parse.d.ts +12 -12
  43. package/dist/.dts/build/parse.d.ts.map +1 -1
  44. package/dist/.dts/build/reference-projections.d.ts +17 -3
  45. package/dist/.dts/build/reference-projections.d.ts.map +1 -1
  46. package/dist/.dts/build/resolution/resolve-import.d.ts +5 -0
  47. package/dist/.dts/build/resolution/resolve-import.d.ts.map +1 -1
  48. package/dist/.dts/build/resolution/resolve-package-schema.d.ts +1 -1
  49. package/dist/.dts/build/resolution/resolve-package-schema.d.ts.map +1 -1
  50. package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts +20 -2
  51. package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -1
  52. package/dist/.dts/build/sarif.d.ts.map +1 -1
  53. package/dist/.dts/build/scan-dependencies.d.ts +23 -0
  54. package/dist/.dts/build/scan-dependencies.d.ts.map +1 -1
  55. package/dist/.dts/build/types.d.ts +1 -1
  56. package/dist/.dts/build/typescript.d.ts +20 -0
  57. package/dist/.dts/build/typescript.d.ts.map +1 -0
  58. package/dist/.dts/build/usage-report.d.ts.map +1 -1
  59. package/dist/.dts/cli/filesystem.d.ts +4 -0
  60. package/dist/.dts/cli/filesystem.d.ts.map +1 -1
  61. package/dist/.dts/eslint-plugin/glob.d.ts.map +1 -1
  62. package/dist/.dts/eslint-plugin/index.d.ts +2 -2
  63. package/dist/.dts/eslint-plugin/no-node-fs.d.ts.map +1 -1
  64. package/dist/.dts/eslint-plugin/no-raw-process-env.d.ts.map +1 -1
  65. package/dist/.dts/evidence/index.d.ts +2 -2
  66. package/dist/.dts/helpers/index.d.ts +2 -2
  67. package/dist/.dts/helpers/processors.d.ts.map +1 -1
  68. package/dist/.dts/helpers/validators.d.ts.map +1 -1
  69. package/dist/.dts/runtime/cache.d.ts +0 -3
  70. package/dist/.dts/runtime/cache.d.ts.map +1 -1
  71. package/dist/.dts/runtime/create.d.ts.map +1 -1
  72. package/dist/.dts/runtime/document.d.ts.map +1 -1
  73. package/dist/.dts/runtime/index.d.ts +2 -2
  74. package/dist/.dts/runtime/registry.d.ts.map +1 -1
  75. package/dist/.dts/runtime/validate.d.ts.map +1 -1
  76. package/dist/{build-U326PI5A.js → build-H4KFV44Z.js} +501 -599
  77. package/dist/build-H4KFV44Z.js.map +1 -0
  78. package/dist/build.cjs +516 -607
  79. package/dist/build.cjs.map +1 -1
  80. package/dist/build.js +513 -605
  81. package/dist/build.js.map +1 -1
  82. package/dist/{chunk-BSTLSR2R.js → chunk-7GVPOHDU.js} +2 -2
  83. package/dist/chunk-7GVPOHDU.js.map +1 -0
  84. package/dist/cli/index.js +35 -41
  85. package/dist/cli/index.js.map +1 -1
  86. package/dist/eslint-plugin/index.cjs +15 -576
  87. package/dist/eslint-plugin/index.cjs.map +1 -1
  88. package/dist/eslint-plugin/index.js +15 -576
  89. package/dist/eslint-plugin/index.js.map +1 -1
  90. package/dist/evidence.cjs.map +1 -1
  91. package/dist/evidence.js.map +1 -1
  92. package/dist/helpers.cjs +4 -9
  93. package/dist/helpers.cjs.map +1 -1
  94. package/dist/helpers.js +4 -9
  95. package/dist/helpers.js.map +1 -1
  96. package/dist/index.cjs +11 -25
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.js +11 -25
  99. package/dist/index.js.map +1 -1
  100. package/dist/node.cjs +10 -8
  101. package/dist/node.cjs.map +1 -1
  102. package/dist/node.js +10 -8
  103. package/dist/node.js.map +1 -1
  104. package/node_modules/@typescript/old/LICENSE.txt +55 -0
  105. package/node_modules/@typescript/old/README.md +50 -0
  106. package/node_modules/@typescript/old/SECURITY.md +39 -0
  107. package/node_modules/@typescript/old/ThirdPartyNoticeText.txt +193 -0
  108. package/node_modules/@typescript/old/bin/tsc +2 -0
  109. package/node_modules/@typescript/old/bin/tsserver +2 -0
  110. package/node_modules/@typescript/old/lib/_tsc.js +134465 -0
  111. package/node_modules/@typescript/old/lib/_tsserver.js +659 -0
  112. package/node_modules/@typescript/old/lib/_typingsInstaller.js +222 -0
  113. package/node_modules/@typescript/old/lib/cs/diagnosticMessages.generated.json +2129 -0
  114. package/node_modules/@typescript/old/lib/de/diagnosticMessages.generated.json +2125 -0
  115. package/node_modules/@typescript/old/lib/es/diagnosticMessages.generated.json +2129 -0
  116. package/node_modules/@typescript/old/lib/fr/diagnosticMessages.generated.json +2129 -0
  117. package/node_modules/@typescript/old/lib/it/diagnosticMessages.generated.json +2125 -0
  118. package/node_modules/@typescript/old/lib/ja/diagnosticMessages.generated.json +2129 -0
  119. package/node_modules/@typescript/old/lib/ko/diagnosticMessages.generated.json +2129 -0
  120. package/node_modules/@typescript/old/lib/lib.d.ts +20 -0
  121. package/node_modules/@typescript/old/lib/lib.decorators.d.ts +382 -0
  122. package/node_modules/@typescript/old/lib/lib.decorators.legacy.d.ts +20 -0
  123. package/node_modules/@typescript/old/lib/lib.dom.asynciterable.d.ts +18 -0
  124. package/node_modules/@typescript/old/lib/lib.dom.d.ts +45125 -0
  125. package/node_modules/@typescript/old/lib/lib.dom.iterable.d.ts +18 -0
  126. package/node_modules/@typescript/old/lib/lib.es2015.collection.d.ts +150 -0
  127. package/node_modules/@typescript/old/lib/lib.es2015.core.d.ts +595 -0
  128. package/node_modules/@typescript/old/lib/lib.es2015.d.ts +26 -0
  129. package/node_modules/@typescript/old/lib/lib.es2015.generator.d.ts +75 -0
  130. package/node_modules/@typescript/old/lib/lib.es2015.iterable.d.ts +603 -0
  131. package/node_modules/@typescript/old/lib/lib.es2015.promise.d.ts +79 -0
  132. package/node_modules/@typescript/old/lib/lib.es2015.proxy.d.ts +126 -0
  133. package/node_modules/@typescript/old/lib/lib.es2015.reflect.d.ts +142 -0
  134. package/node_modules/@typescript/old/lib/lib.es2015.symbol.d.ts +44 -0
  135. package/node_modules/@typescript/old/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  136. package/node_modules/@typescript/old/lib/lib.es2016.array.include.d.ts +114 -0
  137. package/node_modules/@typescript/old/lib/lib.es2016.d.ts +19 -0
  138. package/node_modules/@typescript/old/lib/lib.es2016.full.d.ts +21 -0
  139. package/node_modules/@typescript/old/lib/lib.es2016.intl.d.ts +29 -0
  140. package/node_modules/@typescript/old/lib/lib.es2017.arraybuffer.d.ts +19 -0
  141. package/node_modules/@typescript/old/lib/lib.es2017.d.ts +24 -0
  142. package/node_modules/@typescript/old/lib/lib.es2017.date.d.ts +29 -0
  143. package/node_modules/@typescript/old/lib/lib.es2017.full.d.ts +21 -0
  144. package/node_modules/@typescript/old/lib/lib.es2017.intl.d.ts +42 -0
  145. package/node_modules/@typescript/old/lib/lib.es2017.object.d.ts +47 -0
  146. package/node_modules/@typescript/old/lib/lib.es2017.sharedmemory.d.ts +133 -0
  147. package/node_modules/@typescript/old/lib/lib.es2017.string.d.ts +43 -0
  148. package/node_modules/@typescript/old/lib/lib.es2017.typedarrays.d.ts +51 -0
  149. package/node_modules/@typescript/old/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  150. package/node_modules/@typescript/old/lib/lib.es2018.asynciterable.d.ts +51 -0
  151. package/node_modules/@typescript/old/lib/lib.es2018.d.ts +22 -0
  152. package/node_modules/@typescript/old/lib/lib.es2018.full.d.ts +22 -0
  153. package/node_modules/@typescript/old/lib/lib.es2018.intl.d.ts +81 -0
  154. package/node_modules/@typescript/old/lib/lib.es2018.promise.d.ts +28 -0
  155. package/node_modules/@typescript/old/lib/lib.es2018.regexp.d.ts +35 -0
  156. package/node_modules/@typescript/old/lib/lib.es2019.array.d.ts +77 -0
  157. package/node_modules/@typescript/old/lib/lib.es2019.d.ts +22 -0
  158. package/node_modules/@typescript/old/lib/lib.es2019.full.d.ts +22 -0
  159. package/node_modules/@typescript/old/lib/lib.es2019.intl.d.ts +21 -0
  160. package/node_modules/@typescript/old/lib/lib.es2019.object.d.ts +31 -0
  161. package/node_modules/@typescript/old/lib/lib.es2019.string.d.ts +35 -0
  162. package/node_modules/@typescript/old/lib/lib.es2019.symbol.d.ts +22 -0
  163. package/node_modules/@typescript/old/lib/lib.es2020.bigint.d.ts +763 -0
  164. package/node_modules/@typescript/old/lib/lib.es2020.d.ts +25 -0
  165. package/node_modules/@typescript/old/lib/lib.es2020.date.d.ts +40 -0
  166. package/node_modules/@typescript/old/lib/lib.es2020.full.d.ts +22 -0
  167. package/node_modules/@typescript/old/lib/lib.es2020.intl.d.ts +472 -0
  168. package/node_modules/@typescript/old/lib/lib.es2020.number.d.ts +26 -0
  169. package/node_modules/@typescript/old/lib/lib.es2020.promise.d.ts +45 -0
  170. package/node_modules/@typescript/old/lib/lib.es2020.sharedmemory.d.ts +97 -0
  171. package/node_modules/@typescript/old/lib/lib.es2020.string.d.ts +42 -0
  172. package/node_modules/@typescript/old/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  173. package/node_modules/@typescript/old/lib/lib.es2021.d.ts +21 -0
  174. package/node_modules/@typescript/old/lib/lib.es2021.full.d.ts +22 -0
  175. package/node_modules/@typescript/old/lib/lib.es2021.intl.d.ts +164 -0
  176. package/node_modules/@typescript/old/lib/lib.es2021.promise.d.ts +46 -0
  177. package/node_modules/@typescript/old/lib/lib.es2021.string.d.ts +31 -0
  178. package/node_modules/@typescript/old/lib/lib.es2021.weakref.d.ts +76 -0
  179. package/node_modules/@typescript/old/lib/lib.es2022.array.d.ts +119 -0
  180. package/node_modules/@typescript/old/lib/lib.es2022.d.ts +23 -0
  181. package/node_modules/@typescript/old/lib/lib.es2022.error.d.ts +73 -0
  182. package/node_modules/@typescript/old/lib/lib.es2022.full.d.ts +22 -0
  183. package/node_modules/@typescript/old/lib/lib.es2022.intl.d.ts +143 -0
  184. package/node_modules/@typescript/old/lib/lib.es2022.object.d.ts +24 -0
  185. package/node_modules/@typescript/old/lib/lib.es2022.regexp.d.ts +37 -0
  186. package/node_modules/@typescript/old/lib/lib.es2022.string.d.ts +23 -0
  187. package/node_modules/@typescript/old/lib/lib.es2023.array.d.ts +922 -0
  188. package/node_modules/@typescript/old/lib/lib.es2023.collection.d.ts +19 -0
  189. package/node_modules/@typescript/old/lib/lib.es2023.d.ts +20 -0
  190. package/node_modules/@typescript/old/lib/lib.es2023.full.d.ts +22 -0
  191. package/node_modules/@typescript/old/lib/lib.es2023.intl.d.ts +62 -0
  192. package/node_modules/@typescript/old/lib/lib.es2024.arraybuffer.d.ts +63 -0
  193. package/node_modules/@typescript/old/lib/lib.es2024.collection.d.ts +27 -0
  194. package/node_modules/@typescript/old/lib/lib.es2024.d.ts +24 -0
  195. package/node_modules/@typescript/old/lib/lib.es2024.full.d.ts +22 -0
  196. package/node_modules/@typescript/old/lib/lib.es2024.object.d.ts +27 -0
  197. package/node_modules/@typescript/old/lib/lib.es2024.promise.d.ts +33 -0
  198. package/node_modules/@typescript/old/lib/lib.es2024.regexp.d.ts +23 -0
  199. package/node_modules/@typescript/old/lib/lib.es2024.sharedmemory.d.ts +66 -0
  200. package/node_modules/@typescript/old/lib/lib.es2024.string.d.ts +27 -0
  201. package/node_modules/@typescript/old/lib/lib.es2025.collection.d.ts +94 -0
  202. package/node_modules/@typescript/old/lib/lib.es2025.d.ts +23 -0
  203. package/node_modules/@typescript/old/lib/lib.es2025.float16.d.ts +443 -0
  204. package/node_modules/@typescript/old/lib/lib.es2025.full.d.ts +22 -0
  205. package/node_modules/@typescript/old/lib/lib.es2025.intl.d.ts +200 -0
  206. package/node_modules/@typescript/old/lib/lib.es2025.iterator.d.ts +146 -0
  207. package/node_modules/@typescript/old/lib/lib.es2025.promise.d.ts +32 -0
  208. package/node_modules/@typescript/old/lib/lib.es2025.regexp.d.ts +30 -0
  209. package/node_modules/@typescript/old/lib/lib.es5.d.ts +4599 -0
  210. package/node_modules/@typescript/old/lib/lib.es6.d.ts +21 -0
  211. package/node_modules/@typescript/old/lib/lib.esnext.array.d.ts +33 -0
  212. package/node_modules/@typescript/old/lib/lib.esnext.collection.d.ts +47 -0
  213. package/node_modules/@typescript/old/lib/lib.esnext.d.ts +27 -0
  214. package/node_modules/@typescript/old/lib/lib.esnext.date.d.ts +21 -0
  215. package/node_modules/@typescript/old/lib/lib.esnext.decorators.d.ts +26 -0
  216. package/node_modules/@typescript/old/lib/lib.esnext.disposable.d.ts +191 -0
  217. package/node_modules/@typescript/old/lib/lib.esnext.error.d.ts +22 -0
  218. package/node_modules/@typescript/old/lib/lib.esnext.full.d.ts +22 -0
  219. package/node_modules/@typescript/old/lib/lib.esnext.intl.d.ts +107 -0
  220. package/node_modules/@typescript/old/lib/lib.esnext.sharedmemory.d.ts +23 -0
  221. package/node_modules/@typescript/old/lib/lib.esnext.temporal.d.ts +485 -0
  222. package/node_modules/@typescript/old/lib/lib.esnext.typedarrays.d.ts +90 -0
  223. package/node_modules/@typescript/old/lib/lib.scripthost.d.ts +320 -0
  224. package/node_modules/@typescript/old/lib/lib.webworker.asynciterable.d.ts +18 -0
  225. package/node_modules/@typescript/old/lib/lib.webworker.d.ts +15606 -0
  226. package/node_modules/@typescript/old/lib/lib.webworker.importscripts.d.ts +21 -0
  227. package/node_modules/@typescript/old/lib/lib.webworker.iterable.d.ts +18 -0
  228. package/node_modules/@typescript/old/lib/pl/diagnosticMessages.generated.json +2129 -0
  229. package/node_modules/@typescript/old/lib/pt-br/diagnosticMessages.generated.json +2129 -0
  230. package/node_modules/@typescript/old/lib/ru/diagnosticMessages.generated.json +2125 -0
  231. package/node_modules/@typescript/old/lib/tr/diagnosticMessages.generated.json +2129 -0
  232. package/node_modules/@typescript/old/lib/tsc.js +8 -0
  233. package/node_modules/@typescript/old/lib/tsserver.js +8 -0
  234. package/node_modules/@typescript/old/lib/tsserverlibrary.d.ts +17 -0
  235. package/node_modules/@typescript/old/lib/tsserverlibrary.js +21 -0
  236. package/node_modules/@typescript/old/lib/typesMap.json +497 -0
  237. package/node_modules/@typescript/old/lib/typescript.d.ts +11448 -0
  238. package/node_modules/@typescript/old/lib/typescript.js +201039 -0
  239. package/node_modules/@typescript/old/lib/typingsInstaller.js +8 -0
  240. package/node_modules/@typescript/old/lib/watchGuard.js +53 -0
  241. package/node_modules/@typescript/old/lib/zh-cn/diagnosticMessages.generated.json +2129 -0
  242. package/node_modules/@typescript/old/lib/zh-tw/diagnosticMessages.generated.json +2125 -0
  243. package/node_modules/@typescript/old/package.json +118 -0
  244. package/node_modules/@typescript/typescript6/LICENSE.txt +55 -0
  245. package/node_modules/@typescript/typescript6/README.md +9 -0
  246. package/node_modules/@typescript/typescript6/bin/tsc6 +2 -0
  247. package/node_modules/@typescript/typescript6/lib/tsc.js +1 -0
  248. package/node_modules/@typescript/typescript6/lib/tsserverlibrary.d.ts +2 -0
  249. package/node_modules/@typescript/typescript6/lib/tsserverlibrary.js +1 -0
  250. package/node_modules/@typescript/typescript6/lib/typescript.d.ts +2 -0
  251. package/node_modules/@typescript/typescript6/lib/typescript.js +1 -0
  252. package/node_modules/@typescript/typescript6/package.json +39 -0
  253. package/package.json +32 -14
  254. package/schemas/env-cap-report.schema.json +1 -1
  255. package/dist/build-U326PI5A.js.map +0 -1
  256. package/dist/chunk-BSTLSR2R.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readToolVersion
4
- } from "./chunk-BSTLSR2R.js";
4
+ } from "./chunk-7GVPOHDU.js";
5
5
 
6
6
  // src/build/evidence-snapshot.ts
7
7
  import path3 from "path";
@@ -45,7 +45,6 @@ function previousContentHashes(previous) {
45
45
  for (const contract of previous?.dependency.contracts ?? []) {
46
46
  for (const variable of contract.variables) {
47
47
  for (const assertion of variable.dynamicAccessAssertions) {
48
- if (assertion.contentHash === void 0) continue;
49
48
  const identity = dynamicAccessVariableIdentity(
50
49
  contract.file,
51
50
  contract.exportName,
@@ -66,8 +65,8 @@ async function buildCitationSnapshots(activeContracts, previous, root, readFile)
66
65
  for (const contract of activeContracts) {
67
66
  const file = displayPath(root, contract.file);
68
67
  for (const variable of contract.variables) {
69
- const citations = variable.evidence?.dynamicAccess ?? [];
70
- if (citations.length === 0) continue;
68
+ const citations = variable.evidence?.dynamicAccess;
69
+ if (citations === void 0) continue;
71
70
  const identity = dynamicAccessVariableIdentity(file, contract.exportName, variable.key);
72
71
  const assertions = [];
73
72
  for (const citation of citations) {
@@ -145,9 +144,7 @@ function toVariableRef(contract, variable) {
145
144
  return { file: contract.file, exportName: contract.exportName, key: variable.key };
146
145
  }
147
146
  function toComparable(value) {
148
- if (value === void 0) return void 0;
149
- if (typeof value === "string") return value;
150
- return JSON.stringify(value);
147
+ return typeof value === "string" ? value : JSON.stringify(value);
151
148
  }
152
149
  function genericFieldChanges(previous, current, skipKeys) {
153
150
  const keys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(current)]);
@@ -190,17 +187,7 @@ function recordFieldChanges(previous, current) {
190
187
  return changes;
191
188
  }
192
189
  function byIdentity(a, b) {
193
- return a.file.localeCompare(b.file) || a.exportName.localeCompare(b.exportName) || // The `?? ""` fallbacks themselves are unreachable through any real
194
- // array this function ever sorts: a `ManifestContractRef` never carries
195
- // a `key` at all, but its own array can never hold two entries sharing
196
- // both file+exportName (contracts are unique by that pair) so the key
197
- // term is never reached for them either way; a `ManifestVariableRef`'s
198
- // `key` is always a real, non-empty string, never `undefined`. Hand-
199
- // verified: mutating both fallbacks to a distinguishing sentinel and
200
- // running the real suite (this file plus
201
- // check-artifacts.test.ts/generate-evidence.test.ts) passes unchanged.
202
- // Stryker disable next-line StringLiteral
203
- (a.key ?? "").localeCompare(b.key ?? "");
190
+ return a.file.localeCompare(b.file) || a.exportName.localeCompare(b.exportName) || String(a.key).localeCompare(String(b.key));
204
191
  }
205
192
  function diffContracts(previous, current) {
206
193
  const previousContracts = new Map((previous ?? []).map((c) => [contractIdentity(c), c]));
@@ -219,25 +206,12 @@ function diffContracts(previous, current) {
219
206
  const changes = genericFieldChanges(
220
207
  previousContract,
221
208
  currentContract,
222
- /* @__PURE__ */ new Set([
223
- // "file"/"exportName" can never actually differ here: both
224
- // contracts of a matched pair share the same Map key
225
- // (`contractIdentity()`), itself derived from file+exportName, so
226
- // they're always structurally equal for two contracts matched
227
- // into one updatedContracts entry. Hand-verified equivalent via
228
- // direct mutation + a real suite run.
229
- // Stryker disable next-line StringLiteral
230
- "file",
231
- // Stryker disable next-line StringLiteral
232
- "exportName",
233
- // Genuinely skipped AND real-tested -- see "does not report the
234
- // whole variables array as a changed field" below.
235
- "variables"
236
- ])
209
+ // `file` and `exportName` cannot differ for a matched pair (they make up its identity).
210
+ /* @__PURE__ */ new Set(["variables"])
237
211
  );
238
212
  if (changes.length > 0) updatedContracts.push({ ...toContractRef(currentContract), changes });
239
213
  }
240
- const previousVariables = new Map((previousContract?.variables ?? []).map((v) => [v.key, v]));
214
+ const previousVariables = new Map(previousContract?.variables.map((v) => [v.key, v]));
241
215
  const currentVariables = new Map(currentContract.variables.map((v) => [v.key, v]));
242
216
  for (const [key, currentVariable] of currentVariables) {
243
217
  const previousVariable = previousVariables.get(key);
@@ -248,16 +222,14 @@ function diffContracts(previous, current) {
248
222
  const changes = genericFieldChanges(
249
223
  previousVariable,
250
224
  currentVariable,
251
- /* @__PURE__ */ new Set(["key"])
225
+ /* @__PURE__ */ new Set()
252
226
  );
253
227
  if (changes.length > 0)
254
228
  updatedVariables.push({ ...toVariableRef(currentContract, currentVariable), changes });
255
229
  }
256
- if (previousContract) {
257
- for (const [key, previousVariable] of previousVariables) {
258
- if (!currentVariables.has(key))
259
- removedVariables.push(toVariableRef(previousContract, previousVariable));
260
- }
230
+ for (const [key, previousVariable] of previousVariables) {
231
+ if (!currentVariables.has(key))
232
+ removedVariables.push(toVariableRef(currentContract, previousVariable));
261
233
  }
262
234
  }
263
235
  for (const [identity, previousContract] of previousContracts) {
@@ -301,7 +273,6 @@ async function writeEvidenceSnapshot(snapshotPath, snapshot, fs) {
301
273
  await fs.writeFile(snapshotPath, `${JSON.stringify(snapshot, null, 2)}
302
274
  `, "utf8");
303
275
  }
304
- var EXPIRY_DAY_COUNT = /\b\d+ day\(s\)/g;
305
276
  function normalizeEvidenceSnapshotForComparison(snapshot) {
306
277
  return {
307
278
  ...snapshot,
@@ -325,7 +296,7 @@ function normalizeEvidenceSnapshotForComparison(snapshot) {
325
296
  finding: {
326
297
  ...snapshot.finding,
327
298
  findings: snapshot.finding.findings.map(
328
- (f) => f.code === "EXPIRED" || f.code === "EXPIRING_SOON" ? { ...f, message: f.message.replace(EXPIRY_DAY_COUNT, "N day(s)") } : f
299
+ (f) => f.code === "EXPIRED" || f.code === "EXPIRING_SOON" ? { ...f, message: f.message.replace(/\b\d+ day\(s\)/g, "N day(s)") } : f
329
300
  )
330
301
  }
331
302
  };
@@ -334,19 +305,22 @@ async function computeEvidenceChanges(root, snapshotPath, activeContracts, curre
334
305
  const read = await readEvidenceSnapshot(snapshotPath, fs);
335
306
  let previous;
336
307
  let readWarning;
337
- if (read.status === "invalid-json") {
338
- readWarning = {
339
- file: snapshotPath,
340
- message: `Evidence snapshot could not be parsed as JSON (${read.detail}); treating this run as if no previous snapshot existed.`
341
- };
342
- } else if (read.status === "unsupported-version") {
343
- readWarning = {
344
- file: snapshotPath,
345
- message: `Evidence snapshot has schemaVersion ${JSON.stringify(read.foundVersion)}, which this version of env-cap does not understand (expected ${EVIDENCE_MODEL_SCHEMA_VERSION}); treating this run as if no previous snapshot existed.`
346
- };
347
- }
348
- if (read.status === "ok") {
349
- previous = read.snapshot;
308
+ switch (read.status) {
309
+ case "ok":
310
+ previous = read.snapshot;
311
+ break;
312
+ case "invalid-json":
313
+ readWarning = {
314
+ file: snapshotPath,
315
+ message: `Evidence snapshot could not be parsed as JSON (${read.detail}); treating this run as if no previous snapshot existed.`
316
+ };
317
+ break;
318
+ case "unsupported-version":
319
+ readWarning = {
320
+ file: snapshotPath,
321
+ message: `Evidence snapshot has schemaVersion ${JSON.stringify(read.foundVersion)}, which this version of env-cap does not understand (expected ${EVIDENCE_MODEL_SCHEMA_VERSION}); treating this run as if no previous snapshot existed.`
322
+ };
323
+ break;
350
324
  }
351
325
  const dynamicAccessAcknowledgments = await buildCitationSnapshots(
352
326
  activeContracts,
@@ -375,27 +349,18 @@ import path4 from "path";
375
349
  // src/build/glob.ts
376
350
  function globToRegExp(pattern) {
377
351
  let out = "";
378
- let passes = 0;
379
- const maxPasses = pattern.length * 2 + 4;
380
- for (let i = 0; i < pattern.length; i++) {
381
- passes++;
382
- if (passes > maxPasses) {
383
- throw new Error(
384
- // Stryker disable next-line StringLiteral
385
- `globToRegExp: exceeded ${String(maxPasses)} iterations parsing pattern ${JSON.stringify(pattern)} -- this should never happen for any real pattern and indicates an internal parsing bug.`
386
- );
387
- }
388
- const char = pattern[i];
389
- if (char === void 0) continue;
352
+ let resume = 0;
353
+ for (const [i, char] of pattern.split("").entries()) {
354
+ if (i < resume) continue;
390
355
  if (char === "*" && pattern[i + 1] === "*") {
391
356
  const precededBySlashOrStart = i === 0 || pattern[i - 1] === "/";
392
357
  const followedBySlash = pattern[i + 2] === "/";
393
358
  if (precededBySlashOrStart && followedBySlash) {
394
359
  out += "(?:.*/)?";
395
- i += 2;
360
+ resume = i + 3;
396
361
  } else {
397
362
  out += ".*";
398
- i += 1;
363
+ resume = i + 2;
399
364
  }
400
365
  } else if (char === "*") {
401
366
  out += "[^/]*";
@@ -426,7 +391,7 @@ async function discoverSchemaFiles(options) {
426
391
  `discoverSchemaFiles: found ${String(included.length)} files matching "include" under ${options.root} -- more than the ${String(MAX_DISCOVERED_SCHEMA_FILES)}-file sanity limit. This almost always means "root" (or "include"/"exclude") resolved more broadly than intended -- e.g. an omitted "root" falling back to an unexpectedly large process.cwd() -- rather than a real project genuinely declaring this many contracts. Narrow "root"/"include"/"exclude" to the intended project boundary.`
427
392
  );
428
393
  }
429
- return included.map((file) => path4.normalize(file)).sort((a, b) => a < b ? -1 : 1);
394
+ return included.map((file) => path4.normalize(file)).sort();
430
395
  }
431
396
  async function walkDirectory(directory, root, exclude, fs) {
432
397
  const entries = await fs.readdir(directory, { withFileTypes: true });
@@ -456,11 +421,42 @@ function matchesAnyPattern(filePath, patterns) {
456
421
  // src/build/link.ts
457
422
  import path9 from "path";
458
423
 
459
- // src/build/parse.ts
460
- import ts2 from "typescript";
424
+ // src/build/typescript.ts
425
+ import { createRequire } from "module";
426
+ function hasClassicApi(candidate) {
427
+ return typeof candidate?.createSourceFile === "function";
428
+ }
429
+ function isModuleNotFound(error, id) {
430
+ const { code, message } = error ?? {};
431
+ if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") return false;
432
+ return typeof message === "string" && (message.startsWith(`Cannot find module '${id}'`) || message.startsWith(`Cannot find package '${id}'`));
433
+ }
434
+ function tryLoad(load, id) {
435
+ try {
436
+ return load(id);
437
+ } catch (error) {
438
+ if (isModuleNotFound(error, id)) return void 0;
439
+ throw error;
440
+ }
441
+ }
442
+ function pickCompiler(load) {
443
+ const consumer = tryLoad(load, "typescript");
444
+ if (hasClassicApi(consumer)) return consumer;
445
+ const bundled = tryLoad(load, "@typescript/typescript6");
446
+ if (hasClassicApi(bundled)) return bundled;
447
+ return consumer ?? {};
448
+ }
449
+ var ts = pickCompiler(createRequire(import.meta.url));
450
+
451
+ // src/build/compiler-api.ts
452
+ function assertCompilerApi(compiler) {
453
+ if (typeof compiler.createSourceFile === "function") return;
454
+ throw new Error(
455
+ `env-cap's build-time scanner needs TypeScript's classic compiler API (typescript ^5 || ^6), but the installed typescript${compiler.version === void 0 ? "" : ` ${compiler.version}`} does not expose it and the bundled @typescript/typescript6 could not be loaded. Reinstall env-cap with its dependencies, or provide a TypeScript 6 compiler: npm install --save-dev typescript@npm:@typescript/typescript6 (this swaps your \`tsc\` for \`tsc6\`; to keep TypeScript 7's \`tsc\`, also add @typescript/native@npm:typescript@^7). See VERSIONING.md, 'Supported toolchain'.`
456
+ );
457
+ }
461
458
 
462
459
  // src/build/literal-eval.ts
463
- import ts from "typescript";
464
460
  function evaluateLiteral(node) {
465
461
  if (ts.isStringLiteralLike(node)) return { ok: true, value: node.text };
466
462
  if (ts.isNumericLiteral(node)) return { ok: true, value: Number(node.text) };
@@ -504,12 +500,13 @@ function getStaticPropertyName(name) {
504
500
 
505
501
  // src/build/parse.ts
506
502
  function parseSchemaFile(filePath, sourceText) {
507
- const sourceFile = ts2.createSourceFile(
503
+ assertCompilerApi(ts);
504
+ const sourceFile = ts.createSourceFile(
508
505
  filePath,
509
506
  sourceText,
510
- ts2.ScriptTarget.Latest,
507
+ ts.ScriptTarget.Latest,
511
508
  true,
512
- ts2.ScriptKind.TS
509
+ ts.ScriptKind.TS
513
510
  );
514
511
  const warnings = [];
515
512
  const localConsts = /* @__PURE__ */ new Map();
@@ -518,21 +515,21 @@ function parseSchemaFile(filePath, sourceText) {
518
515
  const createEnvCalls = [];
519
516
  const documentEnvCalls = [];
520
517
  for (const statement of sourceFile.statements) {
521
- if (ts2.isImportDeclaration(statement)) {
518
+ if (ts.isImportDeclaration(statement)) {
522
519
  collectImportBindings(statement, imports);
523
520
  continue;
524
521
  }
525
- if (!ts2.isVariableStatement(statement)) continue;
526
- const isExported = statement.modifiers?.some((m) => m.kind === ts2.SyntaxKind.ExportKeyword) ?? false;
522
+ if (!ts.isVariableStatement(statement)) continue;
523
+ const isExported = statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
527
524
  for (const decl of statement.declarationList.declarations) {
528
- if (!ts2.isIdentifier(decl.name) || !decl.initializer) continue;
525
+ if (!ts.isIdentifier(decl.name) || !decl.initializer) continue;
529
526
  const bindingName = decl.name.text;
530
- if (ts2.isObjectLiteralExpression(decl.initializer)) {
527
+ if (ts.isObjectLiteralExpression(decl.initializer)) {
531
528
  localConsts.set(bindingName, decl.initializer);
532
529
  if (isExported) exportedConstNames.add(bindingName);
533
530
  continue;
534
531
  }
535
- if (ts2.isCallExpression(decl.initializer)) {
532
+ if (ts.isCallExpression(decl.initializer)) {
536
533
  if (isCallToName(decl.initializer, "createEnv")) {
537
534
  if (!isExported) {
538
535
  warnings.push({
@@ -560,9 +557,9 @@ function parseSchemaFile(filePath, sourceText) {
560
557
  }
561
558
  }
562
559
  for (const statement of sourceFile.statements) {
563
- if (!ts2.isExpressionStatement(statement)) continue;
560
+ if (!ts.isExpressionStatement(statement)) continue;
564
561
  const expr = statement.expression;
565
- if (!ts2.isCallExpression(expr) || !isCallToName(expr, "documentEnv")) continue;
562
+ if (!ts.isCallExpression(expr) || !isCallToName(expr, "documentEnv")) continue;
566
563
  const [schemaArg, docsArg] = expr.arguments;
567
564
  documentEnvCalls.push({ schemaRef: resolveSchemaRef(schemaArg), docsArg, node: expr });
568
565
  }
@@ -579,15 +576,15 @@ function parseSchemaFile(filePath, sourceText) {
579
576
  }
580
577
  function resolveSchemaRef(node) {
581
578
  if (!node) return { kind: "unresolvable" };
582
- if (ts2.isObjectLiteralExpression(node)) return { kind: "literal", node };
583
- if (ts2.isIdentifier(node)) return { kind: "identifier", name: node.text };
579
+ if (ts.isObjectLiteralExpression(node)) return { kind: "literal", node };
580
+ if (ts.isIdentifier(node)) return { kind: "identifier", name: node.text };
584
581
  return { kind: "unresolvable" };
585
582
  }
586
583
  function collectImportBindings(statement, imports) {
587
- if (!ts2.isStringLiteralLike(statement.moduleSpecifier)) return;
584
+ if (!ts.isStringLiteralLike(statement.moduleSpecifier)) return;
588
585
  const specifier = statement.moduleSpecifier.text;
589
586
  const namedBindings = statement.importClause?.namedBindings;
590
- if (!namedBindings || !ts2.isNamedImports(namedBindings)) return;
587
+ if (!namedBindings || !ts.isNamedImports(namedBindings)) return;
591
588
  for (const element of namedBindings.elements) {
592
589
  const localName = element.name.text;
593
590
  const importedName = element.propertyName?.text ?? localName;
@@ -596,8 +593,8 @@ function collectImportBindings(statement, imports) {
596
593
  }
597
594
  function isCallToName(call, name) {
598
595
  const expr = call.expression;
599
- if (ts2.isIdentifier(expr)) return expr.text === name;
600
- if (ts2.isPropertyAccessExpression(expr)) return expr.name.text === name;
596
+ if (ts.isIdentifier(expr)) return expr.text === name;
597
+ if (ts.isPropertyAccessExpression(expr)) return expr.name.text === name;
601
598
  return false;
602
599
  }
603
600
  function isValidEnvKey(key) {
@@ -606,7 +603,7 @@ function isValidEnvKey(key) {
606
603
  function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings, sourceFile) {
607
604
  const variables = [];
608
605
  for (const prop of schemaLiteral.properties) {
609
- if (!ts2.isPropertyAssignment(prop)) {
606
+ if (!ts.isPropertyAssignment(prop)) {
610
607
  warnings.push({
611
608
  file: filePath,
612
609
  message: `Skipped a non-static schema entry in "${contextLabel}" (spread or computed key are not statically analyzable).`
@@ -622,7 +619,7 @@ function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings,
622
619
  });
623
620
  continue;
624
621
  }
625
- if (!ts2.isObjectLiteralExpression(prop.initializer)) {
622
+ if (!ts.isObjectLiteralExpression(prop.initializer)) {
626
623
  warnings.push({
627
624
  file: filePath,
628
625
  message: `Definition for "${key}" in "${contextLabel}" is not an inline object literal; skipping static analysis for this variable.`
@@ -646,7 +643,7 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
646
643
  let validatorSource;
647
644
  let context;
648
645
  for (const prop of definition.properties) {
649
- if (!ts2.isPropertyAssignment(prop)) continue;
646
+ if (!ts.isPropertyAssignment(prop)) continue;
650
647
  const name = getStaticPropertyName(prop.name);
651
648
  if (name === "default") {
652
649
  hasDefault = true;
@@ -684,13 +681,13 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
684
681
  };
685
682
  }
686
683
  function extractReturnType(node) {
687
- if ((ts2.isArrowFunction(node) || ts2.isFunctionExpression(node)) && node.type) {
688
- return node.type.getText().replace(/\s+/g, "");
684
+ if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.type) {
685
+ return node.type.getText().replace(/\s/g, "");
689
686
  }
690
687
  return void 0;
691
688
  }
692
689
  function normalizeSource(text) {
693
- return text.replace(/\s+/g, " ").trim();
690
+ return text.replace(/\s+/g, " ");
694
691
  }
695
692
  function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
696
693
  let name;
@@ -709,7 +706,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
709
706
  let auditRequired;
710
707
  let metadata;
711
708
  const variables = /* @__PURE__ */ new Map();
712
- if (!docsArg || !ts2.isObjectLiteralExpression(docsArg)) {
709
+ if (!docsArg || !ts.isObjectLiteralExpression(docsArg)) {
713
710
  if (docsArg) {
714
711
  warnings.push({
715
712
  file: filePath,
@@ -736,7 +733,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
736
733
  };
737
734
  }
738
735
  for (const prop of docsArg.properties) {
739
- if (!ts2.isPropertyAssignment(prop)) continue;
736
+ if (!ts.isPropertyAssignment(prop)) continue;
740
737
  const propName = getStaticPropertyName(prop.name);
741
738
  if (propName === "name") {
742
739
  const evaluated = evaluateLiteral(prop.initializer);
@@ -840,7 +837,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
840
837
  });
841
838
  }
842
839
  } else if (propName === "variables") {
843
- if (ts2.isObjectLiteralExpression(prop.initializer)) {
840
+ if (ts.isObjectLiteralExpression(prop.initializer)) {
844
841
  extractVariableDocsMap(prop.initializer, filePath, contextLabel, warnings, variables);
845
842
  } else {
846
843
  warnings.push({
@@ -871,10 +868,10 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
871
868
  }
872
869
  function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnings, out) {
873
870
  for (const prop of variablesLiteral.properties) {
874
- if (!ts2.isPropertyAssignment(prop)) continue;
871
+ if (!ts.isPropertyAssignment(prop)) continue;
875
872
  const key = getStaticPropertyName(prop.name);
876
873
  if (key === void 0) continue;
877
- if (!ts2.isObjectLiteralExpression(prop.initializer)) {
874
+ if (!ts.isObjectLiteralExpression(prop.initializer)) {
878
875
  warnings.push({
879
876
  file: filePath,
880
877
  message: `documentEnv() variable docs for "${key}" in "${contextLabel}" is not an inline object literal; skipped.`
@@ -904,11 +901,9 @@ function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnin
904
901
  let metadata;
905
902
  let evidence;
906
903
  for (const field of prop.initializer.properties) {
907
- if (!ts2.isPropertyAssignment(field)) continue;
904
+ if (!ts.isPropertyAssignment(field)) continue;
908
905
  const fieldName = getStaticPropertyName(field.name);
909
- if (fieldName === void 0) continue;
910
906
  const evaluated = evaluateLiteral(field.initializer);
911
- if (!evaluated.ok) continue;
912
907
  if (fieldName === "description" && typeof evaluated.value === "string")
913
908
  description = evaluated.value;
914
909
  else if (fieldName === "owner" && typeof evaluated.value === "string") owner = evaluated.value;
@@ -1004,9 +999,9 @@ function extractDynamicAccessCitations(value, filePath, key, contextLabel, warni
1004
999
  return citations;
1005
1000
  }
1006
1001
  function extractCreateEnvOptionsName(optionsArg) {
1007
- if (!optionsArg || !ts2.isObjectLiteralExpression(optionsArg)) return void 0;
1002
+ if (!optionsArg || !ts.isObjectLiteralExpression(optionsArg)) return void 0;
1008
1003
  for (const prop of optionsArg.properties) {
1009
- if (!ts2.isPropertyAssignment(prop)) continue;
1004
+ if (!ts.isPropertyAssignment(prop)) continue;
1010
1005
  if (getStaticPropertyName(prop.name) !== "name") continue;
1011
1006
  const evaluated = evaluateLiteral(prop.initializer);
1012
1007
  if (evaluated.ok && typeof evaluated.value === "string") return evaluated.value;
@@ -1036,7 +1031,7 @@ function mustGet(map, key) {
1036
1031
  import path8 from "path";
1037
1032
 
1038
1033
  // src/build/resolution/resolve-package-schema.ts
1039
- import { createRequire } from "module";
1034
+ import { createRequire as createRequire2 } from "module";
1040
1035
  import path6 from "path";
1041
1036
 
1042
1037
  // src/build/resolution/resolve-within-root.ts
@@ -1069,7 +1064,7 @@ function isRecord2(value) {
1069
1064
  return typeof value === "object" && value !== null;
1070
1065
  }
1071
1066
  async function locatePackageManifest(packageName, root, fs) {
1072
- const req = createRequire(path6.join(root, "package.json"));
1067
+ const req = createRequire2(path6.join(root, "package.json"));
1073
1068
  try {
1074
1069
  const packageJsonPath = req.resolve(`${packageName}/package.json`);
1075
1070
  return { packageJsonPath, packageDir: path6.dirname(packageJsonPath) };
@@ -1251,7 +1246,6 @@ async function mergeLocalAndPackageFiles(localFiles, packageFiles, fs) {
1251
1246
  }
1252
1247
  async function resolvePackageImport(specifier, allowedPackages, root, cache, fs) {
1253
1248
  const matched = allowedPackages.find(
1254
- // Stryker disable next-line ConditionalExpression
1255
1249
  (pkg) => specifier === pkg || specifier.startsWith(`${pkg}/`)
1256
1250
  );
1257
1251
  if (!matched) return void 0;
@@ -1261,7 +1255,9 @@ async function resolvePackageImport(specifier, allowedPackages, root, cache, fs)
1261
1255
 
1262
1256
  // src/build/resolution/resolve-tsconfig-paths.ts
1263
1257
  import path7 from "path";
1264
- import ts3 from "typescript";
1258
+ function pathMappingOptions(options) {
1259
+ return options;
1260
+ }
1265
1261
  function createAliasResolutionCache() {
1266
1262
  return { resolutions: /* @__PURE__ */ new Map() };
1267
1263
  }
@@ -1286,9 +1282,10 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1286
1282
  }
1287
1283
  };
1288
1284
  }
1289
- const readResult = ts3.readConfigFile(configFile, (p) => ts3.sys.readFile(p));
1285
+ assertCompilerApi(ts);
1286
+ const readResult = ts.readConfigFile(configFile, (p) => ts.sys.readFile(p));
1290
1287
  if (readResult.error) {
1291
- const detail = ts3.flattenDiagnosticMessageText(readResult.error.messageText, "\n");
1288
+ const detail = ts.flattenDiagnosticMessageText(readResult.error.messageText, ts.sys.newLine);
1292
1289
  return {
1293
1290
  resolution: void 0,
1294
1291
  warning: {
@@ -1297,8 +1294,8 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1297
1294
  }
1298
1295
  };
1299
1296
  }
1300
- const parsed = ts3.parseJsonConfigFileContent(readResult.config, ts3.sys, path7.dirname(configFile));
1301
- const { paths, baseUrl } = parsed.options;
1297
+ const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys, path7.dirname(configFile));
1298
+ const { paths, baseUrl } = pathMappingOptions(parsed.options);
1302
1299
  const hasPaths = paths !== void 0 && Object.keys(paths).length > 0;
1303
1300
  if (!hasPaths && baseUrl === void 0) {
1304
1301
  return { resolution: void 0, warning: void 0 };
@@ -1308,7 +1305,7 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1308
1305
  function resolveAliasImport(specifier, importingFile, resolution, cache) {
1309
1306
  const cacheKey = `${importingFile}\0${specifier}`;
1310
1307
  if (cache.resolutions.has(cacheKey)) return cache.resolutions.get(cacheKey);
1311
- const result = ts3.resolveModuleName(specifier, importingFile, resolution.compilerOptions, ts3.sys);
1308
+ const result = ts.resolveModuleName(specifier, importingFile, resolution.compilerOptions, ts.sys);
1312
1309
  const resolvedFileName = result.resolvedModule?.resolvedFileName;
1313
1310
  let resolved;
1314
1311
  if (resolvedFileName) {
@@ -1336,13 +1333,11 @@ async function resolveRelativeImport(importingFile, specifier, fs) {
1336
1333
  }
1337
1334
  return void 0;
1338
1335
  }
1339
- async function fileExists2(filePath, fs) {
1340
- try {
1341
- const stat = await fs.stat(filePath);
1342
- return stat.isFile();
1343
- } catch {
1344
- return false;
1345
- }
1336
+ function fileExists2(filePath, fs) {
1337
+ return fs.stat(filePath).then(
1338
+ (stat) => stat.isFile(),
1339
+ () => false
1340
+ );
1346
1341
  }
1347
1342
  async function resolveImportSpecifier(importingFile, specifier, context) {
1348
1343
  const relative = await resolveRelativeImport(importingFile, specifier, context.fs);
@@ -1381,24 +1376,29 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
1381
1376
  const warnings = [];
1382
1377
  const unresolvedLinks = [];
1383
1378
  async function resolveSchema(ref, inFile, contextLabel) {
1384
- if (ref.kind === "unresolvable") return void 0;
1385
1379
  const inFileAnalysis = mustGet(analysisCache, inFile);
1386
- if (ref.kind === "literal") {
1387
- return {
1388
- identity: `${inFile}#<inline:${ref.node.pos}>`,
1389
- variables: extractSchemaVariables(
1390
- ref.node,
1391
- inFile,
1392
- contextLabel,
1393
- warnings,
1394
- inFileAnalysis.sourceFile
1395
- )
1396
- };
1380
+ switch (ref.kind) {
1381
+ case "literal":
1382
+ return {
1383
+ identity: `${inFile}#<inline:${ref.node.pos}>`,
1384
+ variables: extractSchemaVariables(
1385
+ ref.node,
1386
+ inFile,
1387
+ contextLabel,
1388
+ warnings,
1389
+ inFileAnalysis.sourceFile
1390
+ )
1391
+ };
1392
+ case "identifier":
1393
+ return resolveNamedSchema(ref.name, inFile, inFileAnalysis, contextLabel);
1397
1394
  }
1398
- const local = inFileAnalysis.localConsts.get(ref.name);
1395
+ return void 0;
1396
+ }
1397
+ async function resolveNamedSchema(name, inFile, inFileAnalysis, contextLabel) {
1398
+ const local = inFileAnalysis.localConsts.get(name);
1399
1399
  if (local) {
1400
1400
  return {
1401
- identity: `${inFile}#${ref.name}`,
1401
+ identity: `${inFile}#${name}`,
1402
1402
  variables: extractSchemaVariables(
1403
1403
  local,
1404
1404
  inFile,
@@ -1408,7 +1408,7 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
1408
1408
  )
1409
1409
  };
1410
1410
  }
1411
- const imported = inFileAnalysis.imports.get(ref.name);
1411
+ const imported = inFileAnalysis.imports.get(name);
1412
1412
  if (!imported) return void 0;
1413
1413
  const targetFile = await resolveImportSpecifier(inFile, imported.specifier, context);
1414
1414
  if (!targetFile) return void 0;
@@ -1594,7 +1594,7 @@ function effectiveAuditRequired(contract, variable) {
1594
1594
 
1595
1595
  // src/build/assemble-project.ts
1596
1596
  async function assembleProject(options) {
1597
- const { fs, root, include, exclude, packages, tsconfig } = options;
1597
+ const { fs, root, include, exclude, packages = [], tsconfig } = options;
1598
1598
  const fileCache = /* @__PURE__ */ new Map();
1599
1599
  const readFileCached = (filePath) => {
1600
1600
  let cached = fileCache.get(filePath);
@@ -1651,7 +1651,6 @@ function buildChangeModel(manifest, currentContracts, root) {
1651
1651
  const relativeFile = displayPath(root, contract.file);
1652
1652
  const cIdentity = contractIdentity2(relativeFile, contract.exportName);
1653
1653
  for (const variable of contract.variables) {
1654
- if (!variable.renamedFrom) continue;
1655
1654
  const addedRef = findByContractAndKey(
1656
1655
  manifest.addedVariables,
1657
1656
  relativeFile,
@@ -1777,8 +1776,7 @@ function variableShape(variable) {
1777
1776
  };
1778
1777
  }
1779
1778
  function shapesMatch(a, b) {
1780
- if (a.valueType === "unknown" || b.valueType === "unknown") return false;
1781
- return a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
1779
+ return a.valueType !== "unknown" && a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
1782
1780
  }
1783
1781
  function detectDuplicateVariableShapes(contracts) {
1784
1782
  const candidates = contracts.filter((c) => c.active && !c.exclusiveGroup);
@@ -1919,61 +1917,53 @@ function isPlainObject(value) {
1919
1917
  }
1920
1918
 
1921
1919
  // src/build/scan-dependencies.ts
1922
- import ts4 from "typescript";
1923
1920
  function unwrapParens(node) {
1924
1921
  let current = node;
1925
- while (ts4.isParenthesizedExpression(current)) current = current.expression;
1922
+ while (ts.isParenthesizedExpression(current)) current = current.expression;
1926
1923
  return current;
1927
1924
  }
1928
1925
  function staticElementKey(node) {
1929
- return ts4.isStringLiteralLike(node) ? node.text : void 0;
1926
+ return ts.isStringLiteralLike(node) ? node.text : void 0;
1930
1927
  }
1931
1928
  function forEachBindingName(name, record) {
1932
- if (ts4.isIdentifier(name)) {
1929
+ if (ts.isIdentifier(name)) {
1933
1930
  record(name.text);
1934
1931
  return;
1935
1932
  }
1936
1933
  for (const element of name.elements) {
1937
- if (ts4.isOmittedExpression(element)) continue;
1934
+ if (ts.isOmittedExpression(element)) continue;
1938
1935
  forEachBindingName(element.name, record);
1939
1936
  }
1940
1937
  }
1941
1938
  function isAssignmentToken(token) {
1942
- return token >= ts4.SyntaxKind.FirstAssignment && token <= ts4.SyntaxKind.LastAssignment;
1939
+ return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment;
1943
1940
  }
1944
1941
  function recordIfIdentifierTarget(expression, assignedNames) {
1945
1942
  const target = unwrapParens(expression);
1946
- if (ts4.isIdentifier(target)) assignedNames.add(target.text);
1943
+ if (ts.isIdentifier(target)) assignedNames.add(target.text);
1947
1944
  }
1948
1945
  function recordAssignmentTargets(node, assignedNames) {
1949
- if (ts4.isBinaryExpression(node) && isAssignmentToken(node.operatorToken.kind)) {
1946
+ if (ts.isBinaryExpression(node) && isAssignmentToken(node.operatorToken.kind)) {
1950
1947
  recordIfIdentifierTarget(node.left, assignedNames);
1951
1948
  return;
1952
1949
  }
1953
- if (
1954
- // Widening this to `true` is behaviorally equivalent, not a real gap:
1955
- // only a prefix/postfix unary node carries an `.operator` at all, so on
1956
- // any other node the two `=== PlusPlus/MinusMinus` checks below both
1957
- // read `undefined` and fail. Hand-verified: mutating this compound to
1958
- // `if (true)` and running the real suite passes unchanged.
1959
- // Stryker disable next-line ConditionalExpression
1960
- (ts4.isPrefixUnaryExpression(node) || ts4.isPostfixUnaryExpression(node)) && (node.operator === ts4.SyntaxKind.PlusPlusToken || node.operator === ts4.SyntaxKind.MinusMinusToken)
1961
- ) {
1962
- recordIfIdentifierTarget(node.operand, assignedNames);
1950
+ const { operator, operand } = node;
1951
+ if (operator === ts.SyntaxKind.PlusPlusToken || operator === ts.SyntaxKind.MinusMinusToken) {
1952
+ recordIfIdentifierTarget(operand, assignedNames);
1963
1953
  return;
1964
1954
  }
1965
- if ((ts4.isForOfStatement(node) || ts4.isForInStatement(node)) && !ts4.isVariableDeclarationList(node.initializer)) {
1955
+ if ((ts.isForOfStatement(node) || ts.isForInStatement(node)) && !ts.isVariableDeclarationList(node.initializer)) {
1966
1956
  recordIfIdentifierTarget(node.initializer, assignedNames);
1967
1957
  }
1968
1958
  }
1969
1959
  function recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates) {
1970
- if (ts4.isVariableDeclaration(node) || ts4.isParameter(node)) {
1960
+ if (ts.isVariableDeclaration(node) || ts.isParameter(node)) {
1971
1961
  forEachBindingName(node.name, countDeclaration);
1972
- if (!ts4.isVariableDeclaration(node) || !ts4.isIdentifier(node.name)) return;
1962
+ if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name)) return;
1973
1963
  if (node.initializer === void 0) return;
1974
1964
  const initializer = unwrapParens(node.initializer);
1975
- const isConst = (ts4.getCombinedNodeFlags(node) & ts4.NodeFlags.Const) !== 0;
1976
- if (isConst && ts4.isIdentifier(initializer)) {
1965
+ const isConst = (ts.getCombinedNodeFlags(node) & ts.NodeFlags.Const) !== 0;
1966
+ if (isConst && ts.isIdentifier(initializer)) {
1977
1967
  constAliasCandidates.push({
1978
1968
  aliasName: node.name.text,
1979
1969
  baseName: initializer.text,
@@ -1982,7 +1972,7 @@ function recordDeclarationIntroduction(node, countDeclaration, constAliasCandida
1982
1972
  }
1983
1973
  return;
1984
1974
  }
1985
- if ((ts4.isFunctionDeclaration(node) || ts4.isClassDeclaration(node)) && node.name) {
1975
+ if ((ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) && node.name) {
1986
1976
  countDeclaration(node.name.text);
1987
1977
  }
1988
1978
  }
@@ -1996,9 +1986,9 @@ function collectDeclarationFacts(sourceFile) {
1996
1986
  function walk(node) {
1997
1987
  recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates);
1998
1988
  recordAssignmentTargets(node, assignedNames);
1999
- ts4.forEachChild(node, walk);
1989
+ ts.forEachChild(node, walk);
2000
1990
  }
2001
- ts4.forEachChild(sourceFile, walk);
1991
+ ts.forEachChild(sourceFile, walk);
2002
1992
  return { declarationCounts, assignedNames, constAliasCandidates };
2003
1993
  }
2004
1994
  function resolveAliasTargets(candidates, declarationCounts, assignedNames, imports) {
@@ -2023,21 +2013,22 @@ function bindingElementKey(element) {
2023
2013
  if (element.propertyName === void 0) {
2024
2014
  return element.name.text;
2025
2015
  }
2026
- if (ts4.isIdentifier(element.propertyName) || ts4.isStringLiteral(element.propertyName)) {
2016
+ if (ts.isIdentifier(element.propertyName) || ts.isStringLiteral(element.propertyName)) {
2027
2017
  return element.propertyName.text;
2028
2018
  }
2029
- if (ts4.isComputedPropertyName(element.propertyName)) {
2019
+ if (ts.isComputedPropertyName(element.propertyName)) {
2030
2020
  const inner = element.propertyName.expression;
2031
- return ts4.isStringLiteralLike(inner) ? inner.text : inner;
2021
+ return ts.isStringLiteralLike(inner) ? inner.text : inner;
2032
2022
  }
2033
2023
  return element.propertyName;
2034
2024
  }
2035
2025
  function scanFileForDependencies(filePath, sourceText) {
2036
- const scriptKind = filePath.endsWith(".tsx") ? ts4.ScriptKind.TSX : ts4.ScriptKind.TS;
2037
- const sourceFile = ts4.createSourceFile(
2026
+ assertCompilerApi(ts);
2027
+ const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
2028
+ const sourceFile = ts.createSourceFile(
2038
2029
  filePath,
2039
2030
  sourceText,
2040
- ts4.ScriptTarget.Latest,
2031
+ ts.ScriptTarget.Latest,
2041
2032
  // Load-bearing, unlike before: `ts.getCombinedNodeFlags()` (used to tell
2042
2033
  // a `const` declaration apart from `let`/`var` when resolving alias
2043
2034
  // candidates) walks parent pointers internally. Flipping this to `false`
@@ -2049,9 +2040,9 @@ function scanFileForDependencies(filePath, sourceText) {
2049
2040
  const imports = /* @__PURE__ */ new Map();
2050
2041
  let hasWildcardReExport = false;
2051
2042
  for (const statement of sourceFile.statements) {
2052
- if (ts4.isImportDeclaration(statement)) {
2043
+ if (ts.isImportDeclaration(statement)) {
2053
2044
  collectImportBindings(statement, imports);
2054
- } else if (ts4.isExportDeclaration(statement) && !statement.exportClause && statement.moduleSpecifier) {
2045
+ } else if (ts.isExportDeclaration(statement) && !statement.exportClause && statement.moduleSpecifier) {
2055
2046
  hasWildcardReExport = true;
2056
2047
  }
2057
2048
  }
@@ -2082,7 +2073,7 @@ function scanFileForDependencies(filePath, sourceText) {
2082
2073
  for (const element of pattern.elements) {
2083
2074
  if (element.dotDotDotToken) {
2084
2075
  record(localName, { kind: "escape", via: "rest", ...positionOf(sourceFile, element) });
2085
- } else if (!ts4.isIdentifier(element.name)) {
2076
+ } else if (!ts.isIdentifier(element.name)) {
2086
2077
  record(localName, {
2087
2078
  kind: "escape",
2088
2079
  via: "nested-pattern",
@@ -2098,17 +2089,17 @@ function scanFileForDependencies(filePath, sourceText) {
2098
2089
  via: "computed-key",
2099
2090
  ...positionOf(sourceFile, element)
2100
2091
  });
2101
- ts4.forEachChild(key, visit);
2092
+ ts.forEachChild(key, visit);
2102
2093
  }
2103
2094
  }
2104
- if (element.initializer) ts4.forEachChild(element.initializer, visit);
2095
+ ts.forEachChild(element.initializer, visit);
2105
2096
  }
2106
2097
  }
2107
2098
  function tryRecordPropertyOrElementAccess(node) {
2108
- const isProperty = ts4.isPropertyAccessExpression(node);
2109
- if (!isProperty && !ts4.isElementAccessExpression(node)) return false;
2099
+ const isProperty = ts.isPropertyAccessExpression(node);
2100
+ if (!isProperty && !ts.isElementAccessExpression(node)) return false;
2110
2101
  const base = unwrapParens(node.expression);
2111
- if (!ts4.isIdentifier(base) || !imports.has(base.text)) return false;
2102
+ if (!ts.isIdentifier(base) || !imports.has(base.text)) return false;
2112
2103
  if (isProperty) {
2113
2104
  record(base.text, { kind: "member", member: node.name.text, ...positionOf(sourceFile, node) });
2114
2105
  return true;
@@ -2118,28 +2109,28 @@ function scanFileForDependencies(filePath, sourceText) {
2118
2109
  base.text,
2119
2110
  key !== void 0 ? { kind: "member", member: key, ...positionOf(sourceFile, node) } : { kind: "dynamic", ...positionOf(sourceFile, node) }
2120
2111
  );
2121
- ts4.forEachChild(node.argumentExpression, visit);
2112
+ ts.forEachChild(node.argumentExpression, visit);
2122
2113
  return true;
2123
2114
  }
2124
2115
  function visit(node) {
2125
- if (ts4.isImportDeclaration(node) || ts4.isExportDeclaration(node) || ts4.isVariableDeclaration(node) && handledDeclarations.has(node)) {
2116
+ if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node) || ts.isVariableDeclaration(node) && handledDeclarations.has(node)) {
2126
2117
  return;
2127
2118
  }
2128
- if (ts4.isVariableDeclaration(node) && ts4.isObjectBindingPattern(node.name) && node.initializer) {
2119
+ if (ts.isVariableDeclaration(node) && ts.isObjectBindingPattern(node.name) && node.initializer) {
2129
2120
  const base = unwrapParens(node.initializer);
2130
- if (ts4.isIdentifier(base) && imports.has(base.text)) {
2121
+ if (ts.isIdentifier(base) && imports.has(base.text)) {
2131
2122
  recordObjectBindingAccesses(node.name, base.text);
2132
2123
  return;
2133
2124
  }
2134
2125
  }
2135
2126
  if (tryRecordPropertyOrElementAccess(node)) return;
2136
- if (ts4.isIdentifier(node) && imports.has(node.text)) {
2127
+ if (ts.isIdentifier(node) && imports.has(node.text)) {
2137
2128
  record(node.text, { kind: "reference", ...positionOf(sourceFile, node) });
2138
2129
  return;
2139
2130
  }
2140
- ts4.forEachChild(node, visit);
2131
+ ts.forEachChild(node, visit);
2141
2132
  }
2142
- ts4.forEachChild(sourceFile, visit);
2133
+ ts.forEachChild(sourceFile, visit);
2143
2134
  return { file: filePath, imports, accessesByLocalName: accesses, hasWildcardReExport };
2144
2135
  }
2145
2136
 
@@ -2147,8 +2138,11 @@ function scanFileForDependencies(filePath, sourceText) {
2147
2138
  function generatedFileMarker() {
2148
2139
  return "GENERATED FILE";
2149
2140
  }
2150
- function generatedBanner(format = "ts") {
2151
- const text = `${generatedFileMarker()} -- do not edit by hand. Run \`npx env-cap\` to regenerate.`;
2141
+ function reportRegenerateHint() {
2142
+ return "Regenerate it by re-running the script that calls `generateDocumentation()` / `generateUsageReport()` from `@maverickcer/env-cap/build`.";
2143
+ }
2144
+ function generatedBanner(format = "ts", regenerate = "Run `npx env-cap` to regenerate.") {
2145
+ const text = `${generatedFileMarker()} -- do not edit by hand. ${regenerate}`;
2152
2146
  return { ts: `// ${text}`, markdown: `<!-- ${text} -->` }[format];
2153
2147
  }
2154
2148
  function isGeneratedFile(content) {
@@ -2159,7 +2153,7 @@ function evidenceDisclaimer() {
2159
2153
  return "Machine-generated engineering artifact assembled from statically-provable code facts and author-declared documentation. It can support a security, privacy, or compliance review. It does not itself establish compliance with any standard.";
2160
2154
  }
2161
2155
  function evidenceProjectionNote(evidencePath) {
2162
- const concept = "Projected from env-cap's Evidence Model (ADR 0031/0038), the same source every other generated artifact draws from.";
2156
+ const concept = "Projected from env-cap's Evidence Model (https://github.com/MaverickCER/env-cap/blob/main/GUIDE.md), the same source every other generated artifact draws from.";
2163
2157
  return evidencePath === void 0 ? concept : `${concept} This run also wrote it to \`${evidencePath}\`.`;
2164
2158
  }
2165
2159
 
@@ -2270,8 +2264,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
2270
2264
  for (const scan of scanResults) {
2271
2265
  for (const [localName, binding] of scan.imports) {
2272
2266
  const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
2273
- if (!resolvedFile) continue;
2274
- const building = byIdentity2.get(`${resolvedFile}#${binding.importedName}`);
2267
+ const building = byIdentity2.get(`${String(resolvedFile)}#${binding.importedName}`);
2275
2268
  if (!building) continue;
2276
2269
  building.imported = true;
2277
2270
  building.consumingFiles.add(scan.file);
@@ -2281,8 +2274,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
2281
2274
  for (const scan of scanResults) {
2282
2275
  for (const [, binding] of scan.imports) {
2283
2276
  const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
2284
- if (!resolvedFile) continue;
2285
- const targetScan = scanByFile.get(resolvedFile);
2277
+ const targetScan = scanByFile.get(String(resolvedFile));
2286
2278
  if (!targetScan?.hasWildcardReExport) continue;
2287
2279
  for (const building of byIdentity2.values()) {
2288
2280
  if (building.imported) continue;
@@ -2385,20 +2377,9 @@ async function buildDependencyModel(contracts, scanFiles, readFile, context, roo
2385
2377
  positions: info.positions.map((p) => relativizePosition2(root, p)),
2386
2378
  dynamicAccessAssertions: info.dynamicAccessAssertions
2387
2379
  })).sort((a, b) => a.key.localeCompare(b.key)),
2388
- // `.sort()` here (and the whole `.map(...).sort()` chain as one
2389
- // `MethodExpression` unit) is a defensive no-op, not a real gap:
2390
- // dependency-graph.ts's own `consumingFiles` is already
2391
- // `[...building.consumingFiles].sort()` before this projection ever
2392
- // sees it (see that file's own comment). Hand-verified: dropping this
2393
- // `.sort()` and running the real suite passes unchanged -- confirmed
2394
- // again 2026-09-18 against CI's own diagnostic mutation report, which
2395
- // flagged this exact `MethodExpression` mutant as Survived.
2396
- // Stryker disable next-line MethodExpression
2380
+ // Sorted after mapping to display paths: a file outside `root` (a package surface) shows as
2381
+ // `../...`, which can order differently from its absolute path.
2397
2382
  consumingFiles: [...contract.consumingFiles].map((f) => displayPath(root, f)).sort(),
2398
- // Same reasoning as `consumingFiles` just above -- the whole
2399
- // `.map(...).sort()` chain is a coarser-grained `MethodExpression`
2400
- // mutant target than the next-line one on `.sort()` alone just below.
2401
- // Stryker disable next-line MethodExpression
2402
2383
  ambiguousBarrelFiles: [...contract.ambiguousBarrelFiles].map((f) => displayPath(root, f)).sort(),
2403
2384
  dynamicAccessSites: contract.dynamicAccessSites.map((p) => relativizePosition2(root, p))
2404
2385
  }));
@@ -2562,30 +2543,11 @@ function renderManifest(contracts, outputFile) {
2562
2543
  for (const contract of sorted) {
2563
2544
  let localName = contract.exportName;
2564
2545
  if (usedNames.has(localName)) {
2565
- const maxSuffix = sorted.length + 16;
2566
- let found;
2567
- let passes = 0;
2568
- for (let suffix = 1; suffix <= maxSuffix; suffix++) {
2569
- passes++;
2570
- if (passes > maxSuffix) {
2571
- throw new Error(
2572
- // Stryker disable next-line StringLiteral
2573
- `renderManifest: exceeded ${String(maxSuffix)} attempts choosing a unique local import name for "${contract.exportName}" -- this should never happen and indicates an internal naming bug.`
2574
- );
2575
- }
2576
- const candidate = `${contract.exportName}_${suffix}`;
2577
- if (!usedNames.has(candidate)) {
2578
- found = candidate;
2579
- break;
2580
- }
2581
- }
2582
- if (found === void 0) {
2583
- throw new Error(
2584
- // Stryker disable next-line StringLiteral
2585
- `renderManifest: could not find a unique local import name for "${contract.exportName}" within ${String(maxSuffix)} attempts -- this should never happen and indicates an internal naming bug.`
2586
- );
2587
- }
2588
- localName = found;
2546
+ const candidates = Array.from(
2547
+ { length: usedNames.size + 1 },
2548
+ (_, index) => `${contract.exportName}_${index + 1}`
2549
+ );
2550
+ localName = String(candidates.find((candidate) => !usedNames.has(candidate)));
2589
2551
  }
2590
2552
  usedNames.add(localName);
2591
2553
  referenceNames.push(localName);
@@ -2634,10 +2596,8 @@ function defaultExclude() {
2634
2596
  // inspect `exclude` directly, and as defense if that hardcoding ever
2635
2597
  // changes) -- hand-verified: emptying both and running the full
2636
2598
  // `vitest run` leaves all 1243 tests passing.
2637
- // Stryker disable next-line StringLiteral
2638
2599
  "**/node_modules/**",
2639
2600
  "**/dist/**",
2640
- // Stryker disable next-line StringLiteral
2641
2601
  "**/.git/**"
2642
2602
  ];
2643
2603
  }
@@ -2667,8 +2627,6 @@ async function generateEnvManifest(options) {
2667
2627
  const root = path11.resolve(options.root ?? process.cwd());
2668
2628
  const include = options.include ?? defaultInclude();
2669
2629
  const exclude = options.exclude ?? defaultExclude();
2670
- const packages = options.packages ?? [];
2671
- const onIncompatibility = options.onIncompatibility ?? "warn";
2672
2630
  const locationResult = resolveWithinRoot(
2673
2631
  root,
2674
2632
  options.location,
@@ -2682,10 +2640,10 @@ async function generateEnvManifest(options) {
2682
2640
  root,
2683
2641
  include,
2684
2642
  exclude,
2685
- packages,
2643
+ packages: options.packages,
2686
2644
  tsconfig: options.tsconfig
2687
2645
  });
2688
- const computed = computeManifest(root, linkResult, onIncompatibility);
2646
+ const computed = computeManifest(root, linkResult, options.onIncompatibility);
2689
2647
  if (computed.blocking.length > 0) throw new EnvManifestGenerationError(computed.blocking);
2690
2648
  await writeManifest(outputPath, computed.activeContracts, options.fs);
2691
2649
  return {
@@ -2828,7 +2786,7 @@ function renderParseWarnings(warnings) {
2828
2786
  }
2829
2787
  function renderUsageReport(computed) {
2830
2788
  const lines = [
2831
- generatedBanner("markdown"),
2789
+ generatedBanner("markdown", reportRegenerateHint()),
2832
2790
  "",
2833
2791
  `> ${evidenceDisclaimer()}`,
2834
2792
  "",
@@ -2836,7 +2794,7 @@ function renderUsageReport(computed) {
2836
2794
  "",
2837
2795
  "# Dependency & Ownership Report",
2838
2796
  "",
2839
- "_Produced by `env-cap --ownership`._",
2797
+ "_Produced by `generateUsageReport()` from `@maverickcer/env-cap/build`._",
2840
2798
  "",
2841
2799
  "Which feature owns each variable, which features consume that contract, and what the blast radius is if it changes.",
2842
2800
  "",
@@ -2848,7 +2806,7 @@ function renderUsageReport(computed) {
2848
2806
  ...renderAsserted(computed.asserted),
2849
2807
  ...renderParseWarnings(computed.parseWarnings)
2850
2808
  ];
2851
- return lines.join("\n").replace(/\n{3,}/g, "\n\n");
2809
+ return lines.join("\n");
2852
2810
  }
2853
2811
 
2854
2812
  // src/build/generate-usage.ts
@@ -2879,7 +2837,7 @@ async function computeScanSurface(root, exclude, origins, fs) {
2879
2837
  }
2880
2838
  return { scanFiles, scannedSurfaces };
2881
2839
  }
2882
- async function computeUsage(root, contracts, scanFiles, readFile, context, parseWarnings, scannedSurfaces, dynamicAccessAcknowledgments) {
2840
+ async function computeUsage(root, contracts, scanFiles, readFile, context, scannedSurfaces, dynamicAccessAcknowledgments) {
2883
2841
  const graph = await buildDependencyGraph(
2884
2842
  contracts,
2885
2843
  scanFiles,
@@ -2892,13 +2850,9 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2892
2850
  const contractByIdentity = /* @__PURE__ */ new Map();
2893
2851
  for (const contract of contracts)
2894
2852
  contractByIdentity.set(`${contract.file}#${contract.exportName}`, contract);
2895
- const ownerFor = (file, exportName) => (
2896
- // Stryker disable next-line OptionalChaining
2897
- contractByIdentity.get(`${file}#${exportName}`)?.owner
2898
- );
2853
+ const ownerFor = (file, exportName) => mustGet(contractByIdentity, `${file}#${exportName}`).owner;
2899
2854
  const effectiveOwnerFor = (file, exportName, key) => {
2900
- const contract = contractByIdentity.get(`${file}#${exportName}`);
2901
- if (!contract) return void 0;
2855
+ const contract = mustGet(contractByIdentity, `${file}#${exportName}`);
2902
2856
  const variable = contract.variables.find((v) => v.key === key);
2903
2857
  return variable ? effectiveOwner(contract, variable) : contract.owner;
2904
2858
  };
@@ -2924,19 +2878,16 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2924
2878
  const staleOrMissingCitationsFor = (contractName, file, exportName, key) => {
2925
2879
  const relativeFile = displayPath(root, file);
2926
2880
  const identity = dynamicAccessVariableIdentity(relativeFile, exportName, key);
2927
- const problems = [];
2928
- for (const a of dynamicAccessAcknowledgments?.get(identity) ?? []) {
2929
- if (a.acknowledgment === "fresh") continue;
2930
- problems.push({
2881
+ return (dynamicAccessAcknowledgments?.get(identity) ?? []).map(
2882
+ (a) => ({
2931
2883
  contractName,
2932
2884
  file: relativeFile,
2933
2885
  exportName,
2934
2886
  key,
2935
2887
  position: { file: a.file, line: a.line, column: a.column },
2936
2888
  acknowledgment: a.acknowledgment
2937
- });
2938
- }
2939
- return problems;
2889
+ })
2890
+ );
2940
2891
  };
2941
2892
  const unconsumedOwnedVariables = findings.unconsumedOwned.map(
2942
2893
  (f) => ({
@@ -2981,7 +2932,6 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2981
2932
  unconsumedOwnedVariables,
2982
2933
  indeterminate,
2983
2934
  asserted,
2984
- parseWarnings,
2985
2935
  scannedSurfaces: graph.scannedSurfaces
2986
2936
  }
2987
2937
  };
@@ -2995,24 +2945,23 @@ async function generateUsageReport(options) {
2995
2945
  const root = path12.resolve(options.root ?? process.cwd());
2996
2946
  const include = options.include ?? defaultInclude();
2997
2947
  const exclude = options.exclude ?? defaultExclude();
2998
- const packages = options.packages ?? [];
2999
2948
  let reportPath;
3000
2949
  if (options.report) {
3001
- const result = resolveWithinRoot(
2950
+ const result2 = resolveWithinRoot(
3002
2951
  root,
3003
2952
  options.report.location,
3004
2953
  "report.location",
3005
2954
  "generateUsageReport"
3006
2955
  );
3007
- if (!result.ok) throw new EnvUsageAnalysisError([result.issue]);
3008
- reportPath = result.resolved;
2956
+ if (!result2.ok) throw new EnvUsageAnalysisError([result2.issue]);
2957
+ reportPath = result2.resolved;
3009
2958
  }
3010
2959
  const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
3011
2960
  fs: options.fs,
3012
2961
  root,
3013
2962
  include,
3014
2963
  exclude,
3015
- packages,
2964
+ packages: options.packages,
3016
2965
  tsconfig: options.tsconfig
3017
2966
  });
3018
2967
  const { scanFiles, scannedSurfaces } = await computeScanSurface(
@@ -3027,11 +2976,14 @@ async function generateUsageReport(options) {
3027
2976
  scanFiles,
3028
2977
  readFileCached,
3029
2978
  context,
3030
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
3031
2979
  scannedSurfaces
3032
2980
  );
3033
- if (reportPath) await writeUsageReport(reportPath, computed.result, options.fs);
3034
- return { reportPath, ...computed.result };
2981
+ const result = {
2982
+ ...computed.result,
2983
+ parseWarnings: [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings]
2984
+ };
2985
+ if (reportPath) await writeUsageReport(reportPath, result, options.fs);
2986
+ return { reportPath, ...result };
3035
2987
  }
3036
2988
 
3037
2989
  // src/build/generate-evidence.ts
@@ -3351,107 +3303,132 @@ function groupVariablesByOwner(contracts, ownerOf) {
3351
3303
  }
3352
3304
  return byOwner;
3353
3305
  }
3354
- var configurationReference = defineEvidenceProjection({
3355
- // Stryker disable next-line ArrowFunction
3356
- disclaimer: () => evidenceDisclaimer(),
3357
- entries: (evidence) => {
3358
- const entries = [];
3359
- for (const contract of evidence.contract.contracts) {
3360
- for (const variable of contract.variables) {
3361
- entries.push({
3362
- file: contract.file,
3363
- exportName: contract.exportName,
3364
- contractName: contract.contractName,
3365
- key: variable.key,
3366
- description: variable.description,
3367
- owner: variable.owner ?? contract.owner,
3368
- sensitivity: variable.sensitivity ?? contract.sensitivity,
3369
- required: variable.required,
3370
- hasDefault: variable.hasDefault,
3371
- hasProcessor: variable.hasProcessor,
3372
- hasValidator: variable.hasValidator,
3373
- expiresAt: variable.expiresAt,
3374
- active: contract.active
3375
- });
3306
+ function configurationReference(evidence) {
3307
+ return projectConfigurationReference(evidence).value;
3308
+ }
3309
+ configurationReference.project = projectConfigurationReference;
3310
+ function projectConfigurationReference(evidence) {
3311
+ return defineEvidenceProjection(configurationReferenceSchema()).project(evidence);
3312
+ }
3313
+ function configurationReferenceSchema() {
3314
+ return {
3315
+ disclaimer: evidenceDisclaimer,
3316
+ entries: (evidence) => {
3317
+ const entries = [];
3318
+ for (const contract of evidence.contract.contracts) {
3319
+ for (const variable of contract.variables) {
3320
+ entries.push({
3321
+ file: contract.file,
3322
+ exportName: contract.exportName,
3323
+ contractName: contract.contractName,
3324
+ key: variable.key,
3325
+ description: variable.description,
3326
+ owner: variable.owner ?? contract.owner,
3327
+ sensitivity: variable.sensitivity ?? contract.sensitivity,
3328
+ required: variable.required,
3329
+ hasDefault: variable.hasDefault,
3330
+ hasProcessor: variable.hasProcessor,
3331
+ hasValidator: variable.hasValidator,
3332
+ expiresAt: variable.expiresAt,
3333
+ active: contract.active
3334
+ });
3335
+ }
3376
3336
  }
3337
+ return entries.sort(byContractThenKey);
3377
3338
  }
3378
- return entries.sort(byContractThenKey);
3379
- }
3380
- });
3381
- var ownershipSummary = defineEvidenceProjection({
3382
- // Stryker disable next-line ArrowFunction
3383
- disclaimer: () => evidenceDisclaimer(),
3384
- owners: (evidence) => {
3385
- const contracts = contractIndex(evidence.contract.contracts);
3386
- const nameOf = (file, exportName) => contracts.get(`${file}#${exportName}`)?.contractName ?? exportName;
3387
- const variablesByOwner = groupVariablesByOwner(
3388
- evidence.ownership.contracts,
3389
- (_contract, variable) => variable.owner
3390
- );
3391
- const contractsByOwner = /* @__PURE__ */ new Map();
3392
- for (const contract of evidence.ownership.contracts) {
3393
- if (contract.owner === void 0) continue;
3394
- const list = contractsByOwner.get(contract.owner) ?? [];
3395
- list.push(nameOf(contract.file, contract.exportName));
3396
- contractsByOwner.set(contract.owner, list);
3339
+ };
3340
+ }
3341
+ function ownershipSummary(evidence) {
3342
+ return projectOwnershipSummary(evidence).value;
3343
+ }
3344
+ ownershipSummary.project = projectOwnershipSummary;
3345
+ function projectOwnershipSummary(evidence) {
3346
+ return defineEvidenceProjection(ownershipSummarySchema()).project(evidence);
3347
+ }
3348
+ function ownershipSummarySchema() {
3349
+ return {
3350
+ disclaimer: evidenceDisclaimer,
3351
+ owners: (evidence) => {
3352
+ const contracts = contractIndex(evidence.contract.contracts);
3353
+ const nameOf = (file, exportName) => contracts.get(`${file}#${exportName}`)?.contractName ?? exportName;
3354
+ const variablesByOwner = groupVariablesByOwner(
3355
+ evidence.ownership.contracts,
3356
+ (_contract, variable) => variable.owner
3357
+ );
3358
+ const contractsByOwner = /* @__PURE__ */ new Map();
3359
+ for (const contract of evidence.ownership.contracts) {
3360
+ if (contract.owner === void 0) continue;
3361
+ const list = contractsByOwner.get(contract.owner) ?? [];
3362
+ list.push(nameOf(contract.file, contract.exportName));
3363
+ contractsByOwner.set(contract.owner, list);
3364
+ }
3365
+ const owners = /* @__PURE__ */ new Set([...variablesByOwner.keys(), ...contractsByOwner.keys()]);
3366
+ return [...owners].sort().map((owner) => ({
3367
+ owner,
3368
+ variables: (variablesByOwner.get(owner) ?? []).map(
3369
+ ({ contract, variable }) => `${nameOf(contract.file, contract.exportName)}.${variable.key}`
3370
+ ).sort(),
3371
+ contracts: (contractsByOwner.get(owner) ?? []).sort()
3372
+ }));
3373
+ },
3374
+ unowned: (evidence) => {
3375
+ const contracts = contractIndex(evidence.contract.contracts);
3376
+ return evidence.ownership.unownedVariables.map((ref) => {
3377
+ const contractName = contracts.get(`${ref.file}#${ref.exportName}`)?.contractName ?? ref.exportName;
3378
+ return `${contractName}.${ref.key}`;
3379
+ }).sort();
3397
3380
  }
3398
- const owners = /* @__PURE__ */ new Set([...variablesByOwner.keys(), ...contractsByOwner.keys()]);
3399
- return [...owners].sort().map((owner) => ({
3400
- owner,
3401
- variables: (variablesByOwner.get(owner) ?? []).map(
3402
- ({ contract, variable }) => `${nameOf(contract.file, contract.exportName)}.${variable.key}`
3403
- ).sort(),
3404
- contracts: (contractsByOwner.get(owner) ?? []).sort()
3405
- }));
3406
- },
3407
- unowned: (evidence) => {
3408
- const contracts = contractIndex(evidence.contract.contracts);
3409
- return evidence.ownership.unownedVariables.map((ref) => {
3410
- const contractName = contracts.get(`${ref.file}#${ref.exportName}`)?.contractName ?? ref.exportName;
3411
- return `${contractName}.${ref.key}`;
3412
- }).sort();
3413
- }
3414
- });
3415
- var expiringSoonReport = defineEvidenceProjection({
3416
- // Stryker disable next-line ArrowFunction
3417
- disclaimer: () => evidenceDisclaimer(),
3418
- entries: (evidence) => {
3419
- const contracts = contractIndex(evidence.contract.contracts);
3420
- const ownerByVariable = /* @__PURE__ */ new Map();
3421
- for (const contract of evidence.ownership.contracts)
3422
- for (const variable of contract.variables)
3423
- ownerByVariable.set(
3424
- `${contract.file}#${contract.exportName}#${variable.key}`,
3425
- variable.owner
3426
- );
3427
- return evidence.lifecycle.expiring.map((entry) => {
3428
- const contract = contracts.get(`${entry.file}#${entry.exportName}`);
3429
- const variable = entry.key === void 0 ? void 0 : contract?.variables.find((v) => v.key === entry.key);
3430
- return {
3431
- file: entry.file,
3432
- exportName: entry.exportName,
3433
- contractName: contract?.contractName ?? entry.exportName,
3434
- key: entry.key,
3435
- expiresAt: entry.expiresAt,
3436
- daysRemaining: entry.daysRemaining,
3437
- expired: entry.daysRemaining < 0,
3438
- refreshInstructions: variable?.refreshInstructions,
3439
- owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
3440
- };
3441
- });
3442
- },
3443
- // Same static covered-mutant false-Survivor as the `disclaimer` arrows
3444
- // above -- hand-verified killed (mutating this whole arrow to `() =>
3445
- // undefined` fails the "expiredCount" assertions in every test above).
3446
- // Stryker disable next-line ArrowFunction
3447
- expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
3448
- });
3381
+ };
3382
+ }
3383
+ function expiringSoonReport(evidence) {
3384
+ return projectExpiringSoonReport(evidence).value;
3385
+ }
3386
+ expiringSoonReport.project = projectExpiringSoonReport;
3387
+ function projectExpiringSoonReport(evidence) {
3388
+ return defineEvidenceProjection(expiringSoonReportSchema()).project(evidence);
3389
+ }
3390
+ function expiringSoonReportSchema() {
3391
+ return {
3392
+ disclaimer: evidenceDisclaimer,
3393
+ entries: (evidence) => {
3394
+ const contracts = contractIndex(evidence.contract.contracts);
3395
+ const ownerByVariable = /* @__PURE__ */ new Map();
3396
+ for (const contract of evidence.ownership.contracts)
3397
+ for (const variable of contract.variables)
3398
+ ownerByVariable.set(
3399
+ `${contract.file}#${contract.exportName}#${variable.key}`,
3400
+ variable.owner
3401
+ );
3402
+ return evidence.lifecycle.expiring.map((entry) => {
3403
+ const contract = contracts.get(`${entry.file}#${entry.exportName}`);
3404
+ const variable = contract?.variables.find((v) => v.key === entry.key);
3405
+ return {
3406
+ file: entry.file,
3407
+ exportName: entry.exportName,
3408
+ contractName: contract?.contractName ?? entry.exportName,
3409
+ key: entry.key,
3410
+ expiresAt: entry.expiresAt,
3411
+ daysRemaining: entry.daysRemaining,
3412
+ expired: entry.daysRemaining < 0,
3413
+ refreshInstructions: variable?.refreshInstructions,
3414
+ owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
3415
+ };
3416
+ });
3417
+ },
3418
+ expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
3419
+ };
3420
+ }
3449
3421
 
3450
3422
  // src/build/docs.ts
3451
3423
  function parseIsoDate(value) {
3452
3424
  const date = new Date(value);
3453
3425
  return Number.isNaN(date.getTime()) ? void 0 : date;
3454
3426
  }
3427
+ function parseExpiry(expiresAt) {
3428
+ const raw = String(expiresAt);
3429
+ const date = parseIsoDate(raw);
3430
+ return date && { raw, date };
3431
+ }
3455
3432
  var MS_PER_DAY = 864e5;
3456
3433
  function daysRemainingFrom(date, now) {
3457
3434
  return Math.ceil((date.getTime() - now.getTime()) / MS_PER_DAY);
@@ -3459,32 +3436,29 @@ function daysRemainingFrom(date, now) {
3459
3436
  function computeExpiringEntries(contracts, expiringWithinDays, now) {
3460
3437
  const entries = [];
3461
3438
  for (const contract of contracts) {
3462
- if (contract.expiresAt) {
3463
- const date = parseIsoDate(contract.expiresAt);
3464
- if (date) {
3465
- const daysRemaining = daysRemainingFrom(date, now);
3466
- if (daysRemaining <= expiringWithinDays) {
3467
- entries.push({
3468
- file: contract.file,
3469
- exportName: contract.exportName,
3470
- key: void 0,
3471
- expiresAt: contract.expiresAt,
3472
- daysRemaining
3473
- });
3474
- }
3439
+ const contractExpiry = parseExpiry(contract.expiresAt);
3440
+ if (contractExpiry) {
3441
+ const daysRemaining = daysRemainingFrom(contractExpiry.date, now);
3442
+ if (daysRemaining <= expiringWithinDays) {
3443
+ entries.push({
3444
+ file: contract.file,
3445
+ exportName: contract.exportName,
3446
+ key: void 0,
3447
+ expiresAt: contractExpiry.raw,
3448
+ daysRemaining
3449
+ });
3475
3450
  }
3476
3451
  }
3477
3452
  for (const variable of contract.variables) {
3478
- if (!variable.expiresAt) continue;
3479
- const date = parseIsoDate(variable.expiresAt);
3480
- if (!date) continue;
3481
- const daysRemaining = daysRemainingFrom(date, now);
3453
+ const expiry = parseExpiry(variable.expiresAt);
3454
+ if (!expiry) continue;
3455
+ const daysRemaining = daysRemainingFrom(expiry.date, now);
3482
3456
  if (daysRemaining <= expiringWithinDays) {
3483
3457
  entries.push({
3484
3458
  file: contract.file,
3485
3459
  exportName: contract.exportName,
3486
3460
  key: variable.key,
3487
- expiresAt: variable.expiresAt,
3461
+ expiresAt: expiry.raw,
3488
3462
  daysRemaining
3489
3463
  });
3490
3464
  }
@@ -3535,7 +3509,7 @@ function buildCatalog(contracts) {
3535
3509
  function extractPreviouslyDocumentedKeys(previousContent) {
3536
3510
  const keys = /* @__PURE__ */ new Set();
3537
3511
  for (const match of previousContent.matchAll(/^### `([A-Za-z_][A-Za-z0-9_]*)`$/gm)) {
3538
- if (match[1]) keys.add(match[1]);
3512
+ keys.add(String(match[1]));
3539
3513
  }
3540
3514
  return keys;
3541
3515
  }
@@ -3575,7 +3549,7 @@ function computeChangeSummary(contracts, previousContent) {
3575
3549
  };
3576
3550
  }
3577
3551
  function slugify(text) {
3578
- return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(/^-+|-+$/g, "") || "section";
3552
+ return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(/^-|-$/g, "") || "section";
3579
3553
  }
3580
3554
  var AnchorRegistry = class {
3581
3555
  constructor() {
@@ -3592,16 +3566,24 @@ var AnchorRegistry = class {
3592
3566
  this.assigned.set(target, anchor);
3593
3567
  return anchor;
3594
3568
  }
3569
+ /** The anchor an earlier {@link anchorFor} call assigned to `target`; throws if there was none. */
3570
+ anchorOf(target) {
3571
+ return mustGet(this.assigned, target);
3572
+ }
3595
3573
  };
3596
3574
  function mdLink(text, anchor) {
3597
3575
  return `[${text}](#${anchor})`;
3598
3576
  }
3577
+ function sortedByKey(items) {
3578
+ const byKey = new Map(items.map((item) => [item.key, item]));
3579
+ return [...byKey.keys()].sort().map((key) => mustGet(byKey, key));
3580
+ }
3599
3581
  function sortedContracts(contracts) {
3600
3582
  return [...contracts].sort((a, b) => a.contractName.localeCompare(b.contractName));
3601
3583
  }
3602
3584
  function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates, hasLifecycle) {
3603
3585
  const lines = [
3604
- generatedBanner("markdown"),
3586
+ generatedBanner("markdown", reportRegenerateHint()),
3605
3587
  "",
3606
3588
  `> ${evidenceDisclaimer()}`,
3607
3589
  "",
@@ -3609,7 +3591,7 @@ function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates,
3609
3591
  "",
3610
3592
  "# Environment Variables",
3611
3593
  "",
3612
- "_Produced by `env-cap --docs`._",
3594
+ "_Produced by `generateDocumentation()` from `@maverickcer/env-cap/build`._",
3613
3595
  "",
3614
3596
  `_Generated ${options.generatedAt.toISOString()}_`,
3615
3597
  ""
@@ -3652,7 +3634,7 @@ function renderCatalog(contracts, anchors, undocumented) {
3652
3634
  );
3653
3635
  }
3654
3636
  for (const contract of sortedContracts(contracts)) {
3655
- lines.push(`<a id="${anchors.anchorFor(contract, `contract-${contract.contractName}`)}"></a>`);
3637
+ lines.push(`<a id="${anchors.anchorOf(contract)}"></a>`);
3656
3638
  lines.push(`## ${contract.contractName}`, "", `Source: \`${contract.file}\``);
3657
3639
  if (undocumentedByIdentity.has(`${contract.file}#${contract.exportName}`)) {
3658
3640
  lines.push("", "> \u26A0\uFE0F **Undocumented.** No `documentEnv()` call is linked to this contract.");
@@ -3677,10 +3659,8 @@ function renderCatalog(contracts, anchors, undocumented) {
3677
3659
  }
3678
3660
  }
3679
3661
  lines.push("");
3680
- for (const variable of [...contract.variables].sort((a, b) => a.key < b.key ? -1 : 1)) {
3681
- lines.push(
3682
- `<a id="${anchors.anchorFor(variable, `${contract.contractName}-${variable.key}`)}"></a>`
3683
- );
3662
+ for (const variable of sortedByKey(contract.variables)) {
3663
+ lines.push(`<a id="${anchors.anchorOf(variable)}"></a>`);
3684
3664
  lines.push(`### \`${variable.key}\``, "");
3685
3665
  if (variable.description) lines.push(variable.description, "");
3686
3666
  if (!variable.documented) lines.push("> \u26A0\uFE0F **Undocumented.**", "");
@@ -3793,18 +3773,17 @@ function renderLifecycleReport(contracts, anchors, expiringWithinDays, now) {
3793
3773
  const owner = effectiveOwner(contract, variable);
3794
3774
  if (variable.expiresAt === void 0 && owner === void 0 && variable.refreshInstructions === void 0)
3795
3775
  continue;
3796
- const expiresAt = variable.expiresAt;
3797
- const expiry = expiresAt ? parseIsoDate(expiresAt) : void 0;
3798
- let expiresCell = expiresAt ?? "--";
3799
- if (expiry && expiresAt) {
3800
- const daysRemaining = daysRemainingFrom(expiry, now);
3776
+ const expiry = parseExpiry(variable.expiresAt);
3777
+ let expiresCell = variable.expiresAt ?? "--";
3778
+ if (expiry) {
3779
+ const daysRemaining = daysRemainingFrom(expiry.date, now);
3801
3780
  if (daysRemaining < 0)
3802
- expiresCell = `${expiresAt} (**expired ${Math.abs(daysRemaining)}d ago**)`;
3781
+ expiresCell = `${expiry.raw} (**expired ${Math.abs(daysRemaining)}d ago**)`;
3803
3782
  else if (daysRemaining <= expiringWithinDays)
3804
- expiresCell = `${expiresAt} (**${daysRemaining}d remaining**)`;
3783
+ expiresCell = `${expiry.raw} (**${daysRemaining}d remaining**)`;
3805
3784
  }
3806
3785
  rows.push(
3807
- `| ${mdLink(`\`${variable.key}\``, anchors.anchorFor(variable, `${contract.contractName}-${variable.key}`))} | ${owner ?? "--"} | ${expiresCell} | ${variable.refreshInstructions ?? "--"} |`
3786
+ `| ${mdLink(`\`${variable.key}\``, anchors.anchorOf(variable))} | ${owner ?? "--"} | ${expiresCell} | ${variable.refreshInstructions ?? "--"} |`
3808
3787
  );
3809
3788
  }
3810
3789
  }
@@ -3920,7 +3899,14 @@ function renderDocs(contracts, options) {
3920
3899
  );
3921
3900
  const catalog = renderCatalog(sorted, anchors, options.undocumentedContracts);
3922
3901
  const security = renderSecurityReview(sorted, options, options.generatedAt);
3923
- return [...header, ...catalog, ...ownership, ...dependencyLines, ...lifecycleLines, ...security].join("\n").replace(/\n{3,}/g, "\n\n");
3902
+ return [
3903
+ ...header,
3904
+ ...catalog,
3905
+ ...ownership,
3906
+ ...dependencyLines,
3907
+ ...lifecycleLines,
3908
+ ...security
3909
+ ].join("\n");
3924
3910
  }
3925
3911
  function normalizeDocsForComparison(content) {
3926
3912
  return content.replace(/^_Generated .+_$/m, "_Generated <normalized-for-comparison>_").replace(/\(\*\*\d+d remaining\*\*\)/g, "(**Nd remaining**)").replace(/\(\*\*expired \d+d ago\*\*\)/g, "(**expired Nd ago**)").replace(/^(- Already expired:) \d+$/gm, "$1 N").replace(/^(- Expiring within \d+ days:) \d+$/gm, "$1 N");
@@ -3962,9 +3948,9 @@ function groupByKey(contracts) {
3962
3948
  const byKey = /* @__PURE__ */ new Map();
3963
3949
  for (const contract of contracts) {
3964
3950
  for (const variable of contract.variables) {
3965
- const list = byKey.get(variable.key) ?? [];
3966
- list.push({ contract, variable });
3967
- byKey.set(variable.key, list);
3951
+ const existing = byKey.get(variable.key);
3952
+ if (existing === void 0) byKey.set(variable.key, [{ contract, variable }]);
3953
+ else existing.push({ contract, variable });
3968
3954
  }
3969
3955
  }
3970
3956
  return byKey;
@@ -3972,7 +3958,6 @@ function groupByKey(contracts) {
3972
3958
  function renderEnvExample(contracts, reconciliationHeader = []) {
3973
3959
  const sorted = [...contracts].sort((a, b) => a.file.localeCompare(b.file));
3974
3960
  const active = sorted.filter((c) => c.active);
3975
- const inactive = sorted.filter((c) => !c.active);
3976
3961
  const lines = [
3977
3962
  "# AUTO-GENERATED EXAMPLE FILE.",
3978
3963
  "# Copy to .env and fill in real values. Do not commit .env."
@@ -3984,12 +3969,11 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
3984
3969
  "# still written to this file regardless of its context."
3985
3970
  );
3986
3971
  }
3987
- if (reconciliationHeader.length > 0) lines.push(...reconciliationHeader);
3972
+ lines.push(...reconciliationHeader);
3988
3973
  lines.push("");
3989
3974
  const activeByKey = groupByKey(active);
3990
3975
  for (const key of [...activeByKey.keys()].sort()) {
3991
3976
  const [first, ...rest] = mustGet(activeByKey, key);
3992
- if (first === void 0) continue;
3993
3977
  lines.push(...renderVariableLines(first.variable));
3994
3978
  for (const dup of rest) {
3995
3979
  lines.push(
@@ -4000,11 +3984,10 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
4000
3984
  );
4001
3985
  }
4002
3986
  }
4003
- const inactiveByKey = groupByKey(inactive);
3987
+ const inactiveByKey = groupByKey(sorted);
4004
3988
  for (const key of [...inactiveByKey.keys()].sort()) {
4005
3989
  if (activeByKey.has(key)) continue;
4006
3990
  const [first] = mustGet(inactiveByKey, key);
4007
- if (first === void 0) continue;
4008
3991
  lines.push(
4009
3992
  ...renderVariableLines(first.variable, {
4010
3993
  commented: true,
@@ -4012,13 +3995,12 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
4012
3995
  })
4013
3996
  );
4014
3997
  }
4015
- return lines.join("\n").replace(/\n+$/, "\n");
3998
+ return lines.join("\n");
4016
3999
  }
4017
4000
  function extractDeclaredVariables(source) {
4018
4001
  const names = [];
4019
4002
  for (const line of source.split("\n")) {
4020
4003
  const trimmed = line.trim();
4021
- if (!trimmed || trimmed.startsWith("#")) continue;
4022
4004
  const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
4023
4005
  if (match?.[1]) names.push(match[1]);
4024
4006
  }
@@ -4028,9 +4010,7 @@ function extractCommentedVariables(source) {
4028
4010
  const names = [];
4029
4011
  for (const line of source.split("\n")) {
4030
4012
  const trimmed = line.trim();
4031
- if (!trimmed.startsWith("#")) continue;
4032
- const withoutHash = trimmed.replace(/^#+\s*/, "");
4033
- const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(withoutHash);
4013
+ const match = /^#+\s*([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
4034
4014
  if (match?.[1]) names.push(match[1]);
4035
4015
  }
4036
4016
  return names;
@@ -4112,7 +4092,7 @@ function collectVariableNames(contracts) {
4112
4092
  }
4113
4093
  function overrideVariable(variable, overrides) {
4114
4094
  const override = overrides[variable.key];
4115
- const date = override === void 0 ? void 0 : parseIsoDate(override);
4095
+ const date = parseIsoDate(String(override));
4116
4096
  return {
4117
4097
  ...variable,
4118
4098
  expiresAt: date ? override : variable.expiresAt,
@@ -4134,16 +4114,14 @@ async function resolveLiveExpirationDates(contracts, liveExpirationDates) {
4134
4114
 
4135
4115
  // src/build/generate-documentation.ts
4136
4116
  var DEFAULT_EXPIRING_WITHIN_DAYS = 30;
4137
- var STANDARD_SENSITIVITY_LEVELS = /* @__PURE__ */ new Set([
4138
- "secret",
4139
- "credential",
4140
- "pii",
4141
- "config"
4142
- ]);
4117
+ function standardSensitivityLevels() {
4118
+ return ["secret", "credential", "pii", "config"];
4119
+ }
4120
+ var STANDARD_SENSITIVITY_LEVELS = new Set(standardSensitivityLevels());
4143
4121
  function findNonstandardSensitivityLevels(contracts) {
4144
4122
  const entries = [];
4145
4123
  for (const contract of contracts) {
4146
- if (contract.sensitivity !== void 0 && !STANDARD_SENSITIVITY_LEVELS.has(contract.sensitivity))
4124
+ if (contract.sensitivity !== void 0 && !standardSensitivityLevels().includes(contract.sensitivity))
4147
4125
  entries.push({
4148
4126
  file: contract.file,
4149
4127
  exportName: contract.exportName,
@@ -4152,7 +4130,7 @@ function findNonstandardSensitivityLevels(contracts) {
4152
4130
  });
4153
4131
  for (const variable of [...contract.variables].sort((a, b) => a.key.localeCompare(b.key))) {
4154
4132
  if (variable.sensitivity === void 0) continue;
4155
- if (STANDARD_SENSITIVITY_LEVELS.has(variable.sensitivity)) continue;
4133
+ if (standardSensitivityLevels().includes(variable.sensitivity)) continue;
4156
4134
  entries.push({
4157
4135
  file: contract.file,
4158
4136
  exportName: contract.exportName,
@@ -4193,36 +4171,20 @@ async function writeDocumentation(docsPath, envExamplePath, root, contracts, con
4193
4171
  undocumentedContracts: documentation.undocumentedContracts.map(
4194
4172
  (ref) => relativizeRef(root, ref)
4195
4173
  ),
4196
- // `RenderDocsOptions.undocumentedVariables` is consumed by `renderDocs()`
4197
- // ONLY via `.length` (the security-review counter) -- never by content
4198
- // or identity, unlike its `undocumentedContracts` sibling above (matched
4199
- // by identity against the catalog for the "Undocumented." marker).
4200
- // `.map()` always preserves length regardless of what each element
4201
- // transforms to, so this specific `relativizeRef()` call's own output is
4202
- // unobservable through this call site. Hand-verified: mapping every
4203
- // entry to `undefined` instead and running the full `vitest run` leaves
4204
- // all tests passing.
4205
- // Stryker disable next-line ArrowFunction
4206
- undocumentedVariables: documentation.undocumentedVariables.map(
4207
- (ref) => relativizeRef(root, ref)
4208
- ),
4174
+ undocumentedVariables: documentation.undocumentedVariables,
4209
4175
  generatedAt,
4210
4176
  previousContent
4211
4177
  });
4212
4178
  await fs.mkdir(path14.dirname(docsPath), { recursive: true });
4213
4179
  await fs.writeFile(docsPath, docsSource, "utf8");
4214
4180
  const envExample = envExamplePath ? (
4215
- // exactOptionalPropertyTypes: omit the key rather than set it to
4216
- // `undefined` when the caller didn't supply one. writeEnvExample
4217
- // itself does `options.onExisting ?? "keep-sibling"`, so passing
4218
- // `onExisting: undefined` explicitly (what always-spreading here
4219
- // would do) is behaviorally identical to omitting the key.
4220
- // Hand-verified: forcing this guard to `true` and running the real
4221
- // suite passes unchanged.
4222
- await writeEnvExample(contracts, envExamplePath, fs, {
4223
- // Stryker disable next-line ConditionalExpression
4224
- ...envExampleOnExisting === void 0 ? {} : { onExisting: envExampleOnExisting }
4225
- })
4181
+ // `exactOptionalPropertyTypes` rejects an explicit `undefined`, so the key is omitted when unset.
4182
+ await writeEnvExample(
4183
+ contracts,
4184
+ envExamplePath,
4185
+ fs,
4186
+ envExampleOnExisting && { onExisting: envExampleOnExisting }
4187
+ )
4226
4188
  ) : void 0;
4227
4189
  return { envExample };
4228
4190
  }
@@ -4230,7 +4192,6 @@ async function generateDocumentation(options) {
4230
4192
  const root = path14.resolve(options.root ?? process.cwd());
4231
4193
  const include = options.include ?? defaultInclude();
4232
4194
  const exclude = options.exclude ?? defaultExclude();
4233
- const packages = options.packages ?? [];
4234
4195
  const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
4235
4196
  const docsLocationResult = resolveWithinRoot(
4236
4197
  root,
@@ -4256,7 +4217,7 @@ async function generateDocumentation(options) {
4256
4217
  root,
4257
4218
  include,
4258
4219
  exclude,
4259
- packages,
4220
+ packages: options.packages,
4260
4221
  tsconfig: options.tsconfig
4261
4222
  });
4262
4223
  const docsContracts = await resolveLiveExpirationDates(
@@ -4310,7 +4271,7 @@ function parseRotationPeriodDays(value) {
4310
4271
  if (plain) {
4311
4272
  const amount = Number(plain[1]);
4312
4273
  if (amount > 0) {
4313
- const unit = (plain[2] ?? "").toLowerCase();
4274
+ const unit = String(plain[2]).toLowerCase();
4314
4275
  switch (unit) {
4315
4276
  case "day":
4316
4277
  case "days":
@@ -4343,18 +4304,14 @@ function parseRotationPeriodDays(value) {
4343
4304
  }
4344
4305
  function computeRotationStatus(variable, now) {
4345
4306
  if (!hasRotationData(variable)) return "undeclared";
4346
- if (variable.expiresAt !== void 0) {
4347
- const expiry = parseIsoDate(variable.expiresAt);
4348
- if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
4349
- }
4307
+ const expiry = parseIsoDate(String(variable.expiresAt));
4308
+ if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
4350
4309
  if (variable.rotationPeriod !== void 0) {
4351
- if (variable.lastRotatedAt !== void 0) {
4352
- const lastRotated = parseIsoDate(variable.lastRotatedAt);
4353
- const periodDays = parseRotationPeriodDays(variable.rotationPeriod);
4354
- if (lastRotated !== void 0 && lastRotated.getTime() <= now.getTime() && periodDays !== void 0) {
4355
- const dueDate = lastRotated.getTime() + periodDays * MS_PER_DAY2;
4356
- return dueDate < now.getTime() ? "overdue" : "compliant";
4357
- }
4310
+ const lastRotated = parseIsoDate(String(variable.lastRotatedAt));
4311
+ const periodDays = parseRotationPeriodDays(variable.rotationPeriod);
4312
+ if (lastRotated !== void 0 && lastRotated.getTime() <= now.getTime() && periodDays !== void 0) {
4313
+ const dueDate = lastRotated.getTime() + periodDays * MS_PER_DAY2;
4314
+ return dueDate < now.getTime() ? "overdue" : "compliant";
4358
4315
  }
4359
4316
  return "overdue";
4360
4317
  }
@@ -4439,7 +4396,6 @@ async function generateEvidenceModel(options) {
4439
4396
  const root = path15.resolve(options.root ?? process.cwd());
4440
4397
  const include = options.include ?? defaultInclude();
4441
4398
  const exclude = options.exclude ?? defaultExclude();
4442
- const packages = options.packages ?? [];
4443
4399
  const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
4444
4400
  let snapshotPath;
4445
4401
  if (options.previousSnapshotLocation !== void 0) {
@@ -4457,10 +4413,10 @@ async function generateEvidenceModel(options) {
4457
4413
  root,
4458
4414
  include,
4459
4415
  exclude,
4460
- packages,
4416
+ packages: options.packages,
4461
4417
  tsconfig: options.tsconfig
4462
4418
  });
4463
- const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = assembled;
4419
+ const { readFileCached, linkResult, context, origins } = assembled;
4464
4420
  const generatedAt = /* @__PURE__ */ new Date();
4465
4421
  const activeContracts = linkResult.contracts.filter((c) => c.active);
4466
4422
  const lifecycleContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
@@ -4514,8 +4470,6 @@ async function generateEvidenceModel(options) {
4514
4470
  scanFiles,
4515
4471
  readFileCached,
4516
4472
  context,
4517
- // Stryker disable next-line ArrayDeclaration
4518
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
4519
4473
  scannedSurfaces,
4520
4474
  evidenceChanges?.dynamicAccessAcknowledgments
4521
4475
  );
@@ -4528,12 +4482,7 @@ async function generateEvidenceModel(options) {
4528
4482
  unresolvedConsumers: usageComputed.result.unresolvedConsumers,
4529
4483
  unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
4530
4484
  indeterminateOwnership: usageComputed.result.indeterminate,
4531
- // `buildFindingModel` (finding-model.ts) has its own `?? []` fallback
4532
- // on this exact same field, so even an `undefined` that slipped past
4533
- // this one (e.g. `??`-vs-`&&` on `evidenceChanges?.…`) is caught there
4534
- // identically -- belt-and-suspenders, not independently observable.
4535
- // Stryker disable next-line LogicalOperator
4536
- dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems ?? []
4485
+ dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
4537
4486
  });
4538
4487
  const commit = options.commit ? await options.commit() : void 0;
4539
4488
  return deepFreeze({
@@ -4589,7 +4538,6 @@ async function getEvidenceModel(options) {
4589
4538
  const root = path16.resolve(options.root ?? process.cwd());
4590
4539
  const include = options.include ?? defaultInclude();
4591
4540
  const exclude = options.exclude ?? defaultExclude();
4592
- const packages = options.packages ?? [];
4593
4541
  const evidencePath = path16.resolve(root, options.location);
4594
4542
  const fingerprintPath = fingerprintPathFor(evidencePath);
4595
4543
  const recompute = async (missReason) => ({
@@ -4604,7 +4552,7 @@ async function getEvidenceModel(options) {
4604
4552
  root,
4605
4553
  include,
4606
4554
  exclude,
4607
- packages
4555
+ packages: options.packages
4608
4556
  });
4609
4557
  } catch (error) {
4610
4558
  return recompute(
@@ -4652,91 +4600,61 @@ function findingFiles(finding) {
4652
4600
  if (location.model === "change") return [location.path];
4653
4601
  return location.file === void 0 ? [] : [location.file];
4654
4602
  }
4603
+ function requestedPass(option) {
4604
+ return option === false ? void 0 : option;
4605
+ }
4655
4606
  async function computeArtifacts(options) {
4656
4607
  const root = path17.resolve(options.root ?? process.cwd());
4657
4608
  const include = options.include ?? defaultInclude();
4658
4609
  const exclude = options.exclude ?? defaultExclude();
4659
- const packages = options.packages ?? [];
4660
- const manifestOptions = options.manifest === false ? void 0 : options.manifest;
4661
- const docsOptions = options.docs === false ? void 0 : options.docs;
4662
- const usageOptions = options.usage === false ? void 0 : options.usage;
4663
- const evidenceOptions = options.evidence === false ? void 0 : options.evidence;
4610
+ const manifestOptions = requestedPass(options.manifest);
4611
+ const docsOptions = requestedPass(options.docs);
4612
+ const usageOptions = requestedPass(options.usage);
4613
+ const evidenceOptions = requestedPass(options.evidence);
4664
4614
  const pathIssues = [];
4665
- let manifestOutputPath;
4666
- if (manifestOptions) {
4667
- const result = resolveWithinRoot(
4668
- root,
4669
- manifestOptions.location,
4670
- "manifest.location",
4671
- "generateEnvArtifacts"
4672
- );
4673
- if (result.ok) manifestOutputPath = result.resolved;
4674
- else pathIssues.push(result.issue);
4675
- }
4676
- let docsPath;
4677
- let envExamplePath;
4678
- if (docsOptions) {
4679
- const result = resolveWithinRoot(
4680
- root,
4681
- docsOptions.location,
4682
- "docs.location",
4683
- "generateEnvArtifacts"
4684
- );
4685
- if (result.ok) docsPath = result.resolved;
4686
- else pathIssues.push(result.issue);
4687
- if (docsOptions.envExample) {
4688
- const exampleResult = resolveWithinRoot(
4689
- root,
4690
- docsOptions.envExample.location,
4691
- "docs.envExample.location",
4692
- "generateEnvArtifacts"
4693
- );
4694
- if (exampleResult.ok) envExamplePath = exampleResult.resolved;
4695
- else pathIssues.push(exampleResult.issue);
4696
- }
4697
- }
4698
- let usageReportPath;
4699
- if (usageOptions?.report) {
4700
- const result = resolveWithinRoot(
4701
- root,
4702
- usageOptions.report.location,
4703
- "usage.report.location",
4704
- "generateEnvArtifacts"
4705
- );
4706
- if (result.ok) usageReportPath = result.resolved;
4707
- else pathIssues.push(result.issue);
4708
- }
4709
- let evidencePath;
4710
- if (evidenceOptions) {
4711
- const result = resolveWithinRoot(
4712
- root,
4713
- evidenceOptions.location,
4714
- "evidence.location",
4715
- "generateEnvArtifacts"
4716
- );
4717
- if (result.ok) evidencePath = result.resolved;
4718
- else pathIssues.push(result.issue);
4719
- }
4615
+ const resolveOutput = (location, label) => {
4616
+ const result = resolveWithinRoot(root, location, label, "generateEnvArtifacts");
4617
+ if (result.ok) return result.resolved;
4618
+ pathIssues.push(result.issue);
4619
+ return location;
4620
+ };
4621
+ const manifestTarget = manifestOptions && {
4622
+ options: manifestOptions,
4623
+ outputPath: resolveOutput(manifestOptions.location, "manifest.location")
4624
+ };
4625
+ const docsTarget = docsOptions && {
4626
+ options: docsOptions,
4627
+ path: resolveOutput(docsOptions.location, "docs.location"),
4628
+ envExamplePath: docsOptions.envExample ? resolveOutput(docsOptions.envExample.location, "docs.envExample.location") : void 0
4629
+ };
4630
+ const usageTarget = usageOptions && {
4631
+ options: usageOptions,
4632
+ reportPath: usageOptions.report ? resolveOutput(usageOptions.report.location, "usage.report.location") : void 0
4633
+ };
4634
+ const evidencePath = evidenceOptions ? resolveOutput(evidenceOptions.location, "evidence.location") : void 0;
4720
4635
  if (pathIssues.length > 0) throw new EnvProjectGenerationError(pathIssues);
4721
4636
  const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
4722
4637
  fs: options.fs,
4723
4638
  root,
4724
4639
  include,
4725
4640
  exclude,
4726
- packages,
4641
+ packages: options.packages,
4727
4642
  tsconfig: options.tsconfig
4728
4643
  });
4729
4644
  const generatedAt = /* @__PURE__ */ new Date();
4730
4645
  const activeContracts = linkResult.contracts.filter((c) => c.active);
4731
4646
  const liveExpirationContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
4732
- const docsContracts = docsOptions ? liveExpirationContracts : linkResult.contracts;
4647
+ const docsContracts = docsTarget ? liveExpirationContracts : linkResult.contracts;
4733
4648
  const blocking = [];
4734
- const manifestComputed = manifestOptions ? computeManifest(root, linkResult, manifestOptions.onIncompatibility ?? "warn") : void 0;
4735
- if (manifestComputed) blocking.push(...manifestComputed.blocking);
4649
+ const manifest = manifestTarget && {
4650
+ ...manifestTarget,
4651
+ computed: computeManifest(root, linkResult, manifestTarget.options.onIncompatibility)
4652
+ };
4653
+ if (manifest) blocking.push(...manifest.computed.blocking);
4736
4654
  const docsComputed = computeDocumentation(
4737
4655
  root,
4738
4656
  { ...linkResult, contracts: liveExpirationContracts },
4739
- docsOptions?.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4657
+ docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4740
4658
  generatedAt
4741
4659
  );
4742
4660
  const { scanFiles, scannedSurfaces } = await computeScanSurface(
@@ -4760,14 +4678,13 @@ async function computeArtifacts(options) {
4760
4678
  scanFiles,
4761
4679
  readFileCached,
4762
4680
  context,
4763
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
4764
4681
  scannedSurfaces,
4765
4682
  evidenceChanges?.dynamicAccessAcknowledgments
4766
4683
  );
4767
4684
  const ownership = buildOwnershipModel(linkResult.contracts, root);
4768
4685
  const lifecycle = buildLifecycleModel(
4769
4686
  liveExpirationContracts,
4770
- docsOptions?.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4687
+ docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4771
4688
  generatedAt,
4772
4689
  root
4773
4690
  );
@@ -4804,7 +4721,7 @@ async function computeArtifacts(options) {
4804
4721
  unresolvedConsumers: usageComputed.result.unresolvedConsumers,
4805
4722
  unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
4806
4723
  indeterminateOwnership: usageComputed.result.indeterminate,
4807
- dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems ?? []
4724
+ dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
4808
4725
  });
4809
4726
  if (options.onUndocumented === "throw")
4810
4727
  blocking.push(...escalatedFindings(finding.findings, "documentation"));
@@ -4826,16 +4743,11 @@ async function computeArtifacts(options) {
4826
4743
  });
4827
4744
  return {
4828
4745
  root,
4829
- manifestOptions,
4830
- manifestOutputPath,
4831
- manifestComputed,
4832
- docsOptions,
4833
- docsPath,
4834
- envExamplePath,
4746
+ manifest,
4747
+ docs: docsTarget,
4835
4748
  docsComputed,
4836
4749
  docsContracts,
4837
- usageOptions,
4838
- usageReportPath,
4750
+ usage: usageTarget,
4839
4751
  usageComputed,
4840
4752
  evidencePath,
4841
4753
  evidence,
@@ -4848,16 +4760,11 @@ async function computeArtifacts(options) {
4848
4760
  async function generateEnvArtifacts(options) {
4849
4761
  const computed = await computeArtifacts(options);
4850
4762
  const {
4851
- manifestOptions,
4852
- manifestOutputPath,
4853
- manifestComputed,
4854
- docsOptions,
4855
- docsPath,
4856
- envExamplePath,
4763
+ manifest,
4764
+ docs,
4857
4765
  docsComputed,
4858
4766
  docsContracts,
4859
- usageOptions,
4860
- usageReportPath,
4767
+ usage,
4861
4768
  usageComputed,
4862
4769
  evidencePath,
4863
4770
  evidence,
@@ -4868,43 +4775,47 @@ async function generateEnvArtifacts(options) {
4868
4775
  generatedAt
4869
4776
  } = computed;
4870
4777
  if (blocking.length > 0) throw new EnvProjectGenerationError(blocking);
4778
+ const parseWarnings = [...packageWarnings, ...linkWarnings];
4871
4779
  let manifestResult;
4872
- if (manifestOptions && manifestComputed && manifestOutputPath) {
4873
- await writeManifest(manifestOutputPath, manifestComputed.activeContracts, options.fs);
4780
+ if (manifest) {
4781
+ await writeManifest(manifest.outputPath, manifest.computed.activeContracts, options.fs);
4874
4782
  manifestResult = {
4875
- outputPath: manifestOutputPath,
4876
- contracts: manifestComputed.contractSummaries,
4877
- warnings: manifestComputed.warnings,
4878
- parseWarnings: [...packageWarnings, ...linkWarnings]
4783
+ outputPath: manifest.outputPath,
4784
+ contracts: manifest.computed.contractSummaries,
4785
+ warnings: manifest.computed.warnings,
4786
+ parseWarnings
4879
4787
  };
4880
4788
  }
4881
4789
  let docsResult;
4882
- if (docsOptions && docsPath) {
4790
+ if (docs) {
4883
4791
  const { envExample } = await writeDocumentation(
4884
- docsPath,
4885
- envExamplePath,
4792
+ docs.path,
4793
+ docs.envExamplePath,
4886
4794
  root,
4887
4795
  docsContracts,
4888
4796
  docsComputed.contractModelContracts,
4889
4797
  docsComputed.documentation,
4890
- docsOptions.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4798
+ docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4891
4799
  generatedAt,
4892
4800
  options.fs,
4893
- docsOptions.envExample?.onExisting
4801
+ docs.options.envExample?.onExisting
4894
4802
  );
4895
4803
  docsResult = {
4896
- docsPath,
4804
+ docsPath: docs.path,
4897
4805
  envExample,
4898
4806
  contracts: docsComputed.contractSummaries,
4899
4807
  catalog: docsComputed.catalog,
4900
- parseWarnings: [...packageWarnings, ...linkWarnings],
4808
+ parseWarnings,
4901
4809
  documentation: docsComputed.documentation
4902
4810
  };
4903
4811
  }
4904
4812
  let usageResult;
4905
- if (usageOptions) {
4906
- if (usageReportPath) await writeUsageReport(usageReportPath, usageComputed.result, options.fs);
4907
- usageResult = { reportPath: usageReportPath, ...usageComputed.result };
4813
+ if (usage) {
4814
+ const usageReport = { ...usageComputed.result, parseWarnings };
4815
+ if (usage.reportPath !== void 0) {
4816
+ await writeUsageReport(usage.reportPath, usageReport, options.fs);
4817
+ }
4818
+ usageResult = { reportPath: usage.reportPath, ...usageReport };
4908
4819
  }
4909
4820
  if (evidencePath) {
4910
4821
  await writeEvidenceSnapshot(evidencePath, evidence, options.fs);
@@ -4913,7 +4824,7 @@ async function generateEnvArtifacts(options) {
4913
4824
  root,
4914
4825
  include: options.include ?? defaultInclude(),
4915
4826
  exclude: options.exclude ?? defaultExclude(),
4916
- packages: options.packages ?? []
4827
+ packages: options.packages
4917
4828
  });
4918
4829
  await writeEvidenceFingerprint(evidencePath, fingerprint, options.fs);
4919
4830
  }
@@ -4921,12 +4832,8 @@ async function generateEnvArtifacts(options) {
4921
4832
  }
4922
4833
 
4923
4834
  // src/build/check-artifacts.ts
4924
- async function readIfExists(filePath, fs) {
4925
- try {
4926
- return await fs.readFile(filePath, "utf8");
4927
- } catch {
4928
- return void 0;
4929
- }
4835
+ function readIfExists(filePath, fs) {
4836
+ return fs.readFile(filePath, "utf8").catch(() => void 0);
4930
4837
  }
4931
4838
  function normalizeEvidenceJsonForComparison(text) {
4932
4839
  try {
@@ -4952,46 +4859,38 @@ async function checkEnvArtifacts(options) {
4952
4859
  const c = await computeArtifacts(options);
4953
4860
  if (c.blocking.length > 0) throw new EnvProjectGenerationError(c.blocking);
4954
4861
  const findings = [];
4955
- if (c.manifestOptions && c.manifestComputed && c.manifestOutputPath) {
4956
- const expected = renderManifest(c.manifestComputed.activeContracts, c.manifestOutputPath);
4957
- findings.push(await compareTextArtifact("manifest", c.manifestOutputPath, expected, options.fs));
4862
+ if (c.manifest) {
4863
+ const expected = renderManifest(c.manifest.computed.activeContracts, c.manifest.outputPath);
4864
+ findings.push(
4865
+ await compareTextArtifact("manifest", c.manifest.outputPath, expected, options.fs)
4866
+ );
4958
4867
  }
4959
- if (c.docsOptions && c.docsPath) {
4960
- const previousContent = await readIfExists(c.docsPath, options.fs);
4868
+ if (c.docs) {
4869
+ const previousContent = await readIfExists(c.docs.path, options.fs);
4961
4870
  const expected = renderDocs(c.docsComputed.contractModelContracts, {
4962
- expiringWithinDays: c.docsOptions.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4871
+ expiringWithinDays: c.docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4963
4872
  undocumentedContracts: c.docsComputed.documentation.undocumentedContracts.map(
4964
4873
  (ref) => relativizeRef(c.root, ref)
4965
4874
  ),
4966
- // `RenderDocsOptions.undocumentedVariables` is consumed by `renderDocs()`
4967
- // ONLY via `.length` (the security-review counter), never by content
4968
- // or identity -- same equivalence already established for
4969
- // `generate-documentation.ts`'s identical call site. Hand-verified:
4970
- // mapping every entry to `undefined` instead and running the full
4971
- // `vitest run` leaves every test passing.
4972
- // Stryker disable ArrowFunction
4973
- undocumentedVariables: c.docsComputed.documentation.undocumentedVariables.map(
4974
- (ref) => relativizeRef(c.root, ref)
4975
- ),
4976
- // Stryker restore ArrowFunction
4875
+ undocumentedVariables: c.docsComputed.documentation.undocumentedVariables,
4977
4876
  generatedAt: c.generatedAt,
4978
4877
  previousContent
4979
4878
  });
4980
4879
  findings.push(
4981
4880
  await compareTextArtifact(
4982
4881
  "docs",
4983
- c.docsPath,
4882
+ c.docs.path,
4984
4883
  expected,
4985
4884
  options.fs,
4986
4885
  normalizeDocsForComparison
4987
4886
  )
4988
4887
  );
4989
- if (c.docsOptions.envExample && c.envExamplePath) {
4990
- const existing = await readIfExists(c.envExamplePath, options.fs);
4888
+ if (c.docs.envExamplePath !== void 0) {
4889
+ const existing = await readIfExists(c.docs.envExamplePath, options.fs);
4991
4890
  if (existing === void 0) {
4992
4891
  findings.push({
4993
4892
  artifact: "envExample",
4994
- path: c.envExamplePath,
4893
+ path: c.docs.envExamplePath,
4995
4894
  status: "missing",
4996
4895
  detail: "not yet generated"
4997
4896
  });
@@ -5003,7 +4902,7 @@ async function checkEnvArtifacts(options) {
5003
4902
  const driftCount = staleVariables.length + variablesToComment.length + variablesToAdd.length;
5004
4903
  findings.push({
5005
4904
  artifact: "envExample",
5006
- path: c.envExamplePath,
4905
+ path: c.docs.envExamplePath,
5007
4906
  status: driftCount > 0 ? "stale" : "ok",
5008
4907
  // exactOptionalPropertyTypes: omit the key entirely rather than
5009
4908
  // set it to `undefined` -- `detail` is absent when there's
@@ -5015,9 +4914,12 @@ async function checkEnvArtifacts(options) {
5015
4914
  }
5016
4915
  }
5017
4916
  }
5018
- if (c.usageOptions && c.usageReportPath) {
5019
- const expected = renderUsageReport(c.usageComputed.result);
5020
- findings.push(await compareTextArtifact("usage", c.usageReportPath, expected, options.fs));
4917
+ if (c.usage?.reportPath !== void 0) {
4918
+ const expected = renderUsageReport({
4919
+ ...c.usageComputed.result,
4920
+ parseWarnings: [...c.packageWarnings, ...c.linkWarnings]
4921
+ });
4922
+ findings.push(await compareTextArtifact("usage", c.usage.reportPath, expected, options.fs));
5021
4923
  }
5022
4924
  if (c.evidencePath) {
5023
4925
  const expected = JSON.stringify(c.evidence, null, 2);
@@ -5042,7 +4944,7 @@ function sarifLocations(finding) {
5042
4944
  const location = finding.location;
5043
4945
  const uri = location.model === "change" ? location.path : location.file;
5044
4946
  if (uri === void 0) return void 0;
5045
- const position = location.model === "change" ? void 0 : location.position;
4947
+ const { position } = location;
5046
4948
  return [
5047
4949
  {
5048
4950
  physicalLocation: {
@@ -5145,4 +5047,4 @@ export {
5145
5047
  resolveRelativeImport,
5146
5048
  writeEnvExample
5147
5049
  };
5148
- //# sourceMappingURL=build-U326PI5A.js.map
5050
+ //# sourceMappingURL=build-H4KFV44Z.js.map