@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
package/dist/build.cjs CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  var path6 = require('path');
4
4
  var crypto = require('crypto');
5
- var ts4 = require('typescript');
6
5
  var module$1 = require('module');
7
6
 
8
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
8
 
10
9
  var path6__default = /*#__PURE__*/_interopDefault(path6);
11
10
  var crypto__default = /*#__PURE__*/_interopDefault(crypto);
12
- var ts4__default = /*#__PURE__*/_interopDefault(ts4);
13
11
 
14
- // src/build/evidence-snapshot.ts
12
+ // node_modules/tsup/assets/cjs_shims.js
13
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
14
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
15
15
  function displayPath(root, absolutePath) {
16
16
  const relative = path6__default.default.relative(root, absolutePath);
17
17
  if (relative.startsWith("..") || path6__default.default.isAbsolute(relative)) return absolutePath;
@@ -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,
@@ -369,27 +343,18 @@ async function computeEvidenceChanges(root, snapshotPath, activeContracts, curre
369
343
  // src/build/glob.ts
370
344
  function globToRegExp(pattern) {
371
345
  let out = "";
372
- let passes = 0;
373
- const maxPasses = pattern.length * 2 + 4;
374
- for (let i = 0; i < pattern.length; i++) {
375
- passes++;
376
- if (passes > maxPasses) {
377
- throw new Error(
378
- // Stryker disable next-line StringLiteral
379
- `globToRegExp: exceeded ${String(maxPasses)} iterations parsing pattern ${JSON.stringify(pattern)} -- this should never happen for any real pattern and indicates an internal parsing bug.`
380
- );
381
- }
382
- const char = pattern[i];
383
- if (char === void 0) continue;
346
+ let resume = 0;
347
+ for (const [i, char] of pattern.split("").entries()) {
348
+ if (i < resume) continue;
384
349
  if (char === "*" && pattern[i + 1] === "*") {
385
350
  const precededBySlashOrStart = i === 0 || pattern[i - 1] === "/";
386
351
  const followedBySlash = pattern[i + 2] === "/";
387
352
  if (precededBySlashOrStart && followedBySlash) {
388
353
  out += "(?:.*/)?";
389
- i += 2;
354
+ resume = i + 3;
390
355
  } else {
391
356
  out += ".*";
392
- i += 1;
357
+ resume = i + 2;
393
358
  }
394
359
  } else if (char === "*") {
395
360
  out += "[^/]*";
@@ -420,7 +385,7 @@ async function discoverSchemaFiles(options) {
420
385
  `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.`
421
386
  );
422
387
  }
423
- return included.map((file) => path6__default.default.normalize(file)).sort((a, b) => a < b ? -1 : 1);
388
+ return included.map((file) => path6__default.default.normalize(file)).sort();
424
389
  }
425
390
  async function walkDirectory(directory, root, exclude, fs) {
426
391
  const entries = await fs.readdir(directory, { withFileTypes: true });
@@ -446,18 +411,52 @@ function toPosixRelative(root, target) {
446
411
  function matchesAnyPattern(filePath, patterns) {
447
412
  return patterns.some((pattern) => globToRegExp(pattern).test(filePath));
448
413
  }
414
+ function hasClassicApi(candidate) {
415
+ return typeof candidate?.createSourceFile === "function";
416
+ }
417
+ function isModuleNotFound(error, id) {
418
+ const { code, message } = error ?? {};
419
+ if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") return false;
420
+ return typeof message === "string" && (message.startsWith(`Cannot find module '${id}'`) || message.startsWith(`Cannot find package '${id}'`));
421
+ }
422
+ function tryLoad(load, id) {
423
+ try {
424
+ return load(id);
425
+ } catch (error) {
426
+ if (isModuleNotFound(error, id)) return void 0;
427
+ throw error;
428
+ }
429
+ }
430
+ function pickCompiler(load) {
431
+ const consumer = tryLoad(load, "typescript");
432
+ if (hasClassicApi(consumer)) return consumer;
433
+ const bundled = tryLoad(load, "@typescript/typescript6");
434
+ if (hasClassicApi(bundled)) return bundled;
435
+ return consumer ?? {};
436
+ }
437
+ var ts = pickCompiler(module$1.createRequire(importMetaUrl));
438
+
439
+ // src/build/compiler-api.ts
440
+ function assertCompilerApi(compiler) {
441
+ if (typeof compiler.createSourceFile === "function") return;
442
+ throw new Error(
443
+ `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'.`
444
+ );
445
+ }
446
+
447
+ // src/build/literal-eval.ts
449
448
  function evaluateLiteral(node) {
450
- if (ts4__default.default.isStringLiteralLike(node)) return { ok: true, value: node.text };
451
- if (ts4__default.default.isNumericLiteral(node)) return { ok: true, value: Number(node.text) };
452
- if (node.kind === ts4__default.default.SyntaxKind.TrueKeyword) return { ok: true, value: true };
453
- if (node.kind === ts4__default.default.SyntaxKind.FalseKeyword) return { ok: true, value: false };
454
- if (node.kind === ts4__default.default.SyntaxKind.NullKeyword) return { ok: true, value: null };
455
- if (ts4__default.default.isParenthesizedExpression(node)) return evaluateLiteral(node.expression);
456
- if (ts4__default.default.isPrefixUnaryExpression(node) && node.operator === ts4__default.default.SyntaxKind.MinusToken) {
449
+ if (ts.isStringLiteralLike(node)) return { ok: true, value: node.text };
450
+ if (ts.isNumericLiteral(node)) return { ok: true, value: Number(node.text) };
451
+ if (node.kind === ts.SyntaxKind.TrueKeyword) return { ok: true, value: true };
452
+ if (node.kind === ts.SyntaxKind.FalseKeyword) return { ok: true, value: false };
453
+ if (node.kind === ts.SyntaxKind.NullKeyword) return { ok: true, value: null };
454
+ if (ts.isParenthesizedExpression(node)) return evaluateLiteral(node.expression);
455
+ if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.MinusToken) {
457
456
  const operand = evaluateLiteral(node.operand);
458
457
  return operand.ok && typeof operand.value === "number" ? { ok: true, value: -operand.value } : { ok: false };
459
458
  }
460
- if (ts4__default.default.isArrayLiteralExpression(node)) {
459
+ if (ts.isArrayLiteralExpression(node)) {
461
460
  const values = [];
462
461
  for (const element of node.elements) {
463
462
  const result = evaluateLiteral(element);
@@ -466,10 +465,10 @@ function evaluateLiteral(node) {
466
465
  }
467
466
  return { ok: true, value: values };
468
467
  }
469
- if (ts4__default.default.isObjectLiteralExpression(node)) {
468
+ if (ts.isObjectLiteralExpression(node)) {
470
469
  const record = {};
471
470
  for (const prop of node.properties) {
472
- if (!ts4__default.default.isPropertyAssignment(prop)) return { ok: false };
471
+ if (!ts.isPropertyAssignment(prop)) return { ok: false };
473
472
  const key = getStaticPropertyName(prop.name);
474
473
  if (key === void 0) return { ok: false };
475
474
  const result = evaluateLiteral(prop.initializer);
@@ -481,20 +480,21 @@ function evaluateLiteral(node) {
481
480
  return { ok: false };
482
481
  }
483
482
  function getStaticPropertyName(name) {
484
- if (ts4__default.default.isIdentifier(name)) return name.text;
485
- if (ts4__default.default.isStringLiteralLike(name)) return name.text;
486
- if (ts4__default.default.isNumericLiteral(name)) return name.text;
483
+ if (ts.isIdentifier(name)) return name.text;
484
+ if (ts.isStringLiteralLike(name)) return name.text;
485
+ if (ts.isNumericLiteral(name)) return name.text;
487
486
  return void 0;
488
487
  }
489
488
 
490
489
  // src/build/parse.ts
491
490
  function parseSchemaFile(filePath, sourceText) {
492
- const sourceFile = ts4__default.default.createSourceFile(
491
+ assertCompilerApi(ts);
492
+ const sourceFile = ts.createSourceFile(
493
493
  filePath,
494
494
  sourceText,
495
- ts4__default.default.ScriptTarget.Latest,
495
+ ts.ScriptTarget.Latest,
496
496
  true,
497
- ts4__default.default.ScriptKind.TS
497
+ ts.ScriptKind.TS
498
498
  );
499
499
  const warnings = [];
500
500
  const localConsts = /* @__PURE__ */ new Map();
@@ -503,21 +503,21 @@ function parseSchemaFile(filePath, sourceText) {
503
503
  const createEnvCalls = [];
504
504
  const documentEnvCalls = [];
505
505
  for (const statement of sourceFile.statements) {
506
- if (ts4__default.default.isImportDeclaration(statement)) {
506
+ if (ts.isImportDeclaration(statement)) {
507
507
  collectImportBindings(statement, imports);
508
508
  continue;
509
509
  }
510
- if (!ts4__default.default.isVariableStatement(statement)) continue;
511
- const isExported = statement.modifiers?.some((m) => m.kind === ts4__default.default.SyntaxKind.ExportKeyword) ?? false;
510
+ if (!ts.isVariableStatement(statement)) continue;
511
+ const isExported = statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
512
512
  for (const decl of statement.declarationList.declarations) {
513
- if (!ts4__default.default.isIdentifier(decl.name) || !decl.initializer) continue;
513
+ if (!ts.isIdentifier(decl.name) || !decl.initializer) continue;
514
514
  const bindingName = decl.name.text;
515
- if (ts4__default.default.isObjectLiteralExpression(decl.initializer)) {
515
+ if (ts.isObjectLiteralExpression(decl.initializer)) {
516
516
  localConsts.set(bindingName, decl.initializer);
517
517
  if (isExported) exportedConstNames.add(bindingName);
518
518
  continue;
519
519
  }
520
- if (ts4__default.default.isCallExpression(decl.initializer)) {
520
+ if (ts.isCallExpression(decl.initializer)) {
521
521
  if (isCallToName(decl.initializer, "createEnv")) {
522
522
  if (!isExported) {
523
523
  warnings.push({
@@ -545,9 +545,9 @@ function parseSchemaFile(filePath, sourceText) {
545
545
  }
546
546
  }
547
547
  for (const statement of sourceFile.statements) {
548
- if (!ts4__default.default.isExpressionStatement(statement)) continue;
548
+ if (!ts.isExpressionStatement(statement)) continue;
549
549
  const expr = statement.expression;
550
- if (!ts4__default.default.isCallExpression(expr) || !isCallToName(expr, "documentEnv")) continue;
550
+ if (!ts.isCallExpression(expr) || !isCallToName(expr, "documentEnv")) continue;
551
551
  const [schemaArg, docsArg] = expr.arguments;
552
552
  documentEnvCalls.push({ schemaRef: resolveSchemaRef(schemaArg), docsArg, node: expr });
553
553
  }
@@ -564,15 +564,15 @@ function parseSchemaFile(filePath, sourceText) {
564
564
  }
565
565
  function resolveSchemaRef(node) {
566
566
  if (!node) return { kind: "unresolvable" };
567
- if (ts4__default.default.isObjectLiteralExpression(node)) return { kind: "literal", node };
568
- if (ts4__default.default.isIdentifier(node)) return { kind: "identifier", name: node.text };
567
+ if (ts.isObjectLiteralExpression(node)) return { kind: "literal", node };
568
+ if (ts.isIdentifier(node)) return { kind: "identifier", name: node.text };
569
569
  return { kind: "unresolvable" };
570
570
  }
571
571
  function collectImportBindings(statement, imports) {
572
- if (!ts4__default.default.isStringLiteralLike(statement.moduleSpecifier)) return;
572
+ if (!ts.isStringLiteralLike(statement.moduleSpecifier)) return;
573
573
  const specifier = statement.moduleSpecifier.text;
574
574
  const namedBindings = statement.importClause?.namedBindings;
575
- if (!namedBindings || !ts4__default.default.isNamedImports(namedBindings)) return;
575
+ if (!namedBindings || !ts.isNamedImports(namedBindings)) return;
576
576
  for (const element of namedBindings.elements) {
577
577
  const localName = element.name.text;
578
578
  const importedName = element.propertyName?.text ?? localName;
@@ -581,8 +581,8 @@ function collectImportBindings(statement, imports) {
581
581
  }
582
582
  function isCallToName(call, name) {
583
583
  const expr = call.expression;
584
- if (ts4__default.default.isIdentifier(expr)) return expr.text === name;
585
- if (ts4__default.default.isPropertyAccessExpression(expr)) return expr.name.text === name;
584
+ if (ts.isIdentifier(expr)) return expr.text === name;
585
+ if (ts.isPropertyAccessExpression(expr)) return expr.name.text === name;
586
586
  return false;
587
587
  }
588
588
  function isValidEnvKey(key) {
@@ -591,7 +591,7 @@ function isValidEnvKey(key) {
591
591
  function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings, sourceFile) {
592
592
  const variables = [];
593
593
  for (const prop of schemaLiteral.properties) {
594
- if (!ts4__default.default.isPropertyAssignment(prop)) {
594
+ if (!ts.isPropertyAssignment(prop)) {
595
595
  warnings.push({
596
596
  file: filePath,
597
597
  message: `Skipped a non-static schema entry in "${contextLabel}" (spread or computed key are not statically analyzable).`
@@ -607,7 +607,7 @@ function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings,
607
607
  });
608
608
  continue;
609
609
  }
610
- if (!ts4__default.default.isObjectLiteralExpression(prop.initializer)) {
610
+ if (!ts.isObjectLiteralExpression(prop.initializer)) {
611
611
  warnings.push({
612
612
  file: filePath,
613
613
  message: `Definition for "${key}" in "${contextLabel}" is not an inline object literal; skipping static analysis for this variable.`
@@ -631,7 +631,7 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
631
631
  let validatorSource;
632
632
  let context;
633
633
  for (const prop of definition.properties) {
634
- if (!ts4__default.default.isPropertyAssignment(prop)) continue;
634
+ if (!ts.isPropertyAssignment(prop)) continue;
635
635
  const name = getStaticPropertyName(prop.name);
636
636
  if (name === "default") {
637
637
  hasDefault = true;
@@ -669,13 +669,13 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
669
669
  };
670
670
  }
671
671
  function extractReturnType(node) {
672
- if ((ts4__default.default.isArrowFunction(node) || ts4__default.default.isFunctionExpression(node)) && node.type) {
673
- return node.type.getText().replace(/\s+/g, "");
672
+ if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.type) {
673
+ return node.type.getText().replace(/\s/g, "");
674
674
  }
675
675
  return void 0;
676
676
  }
677
677
  function normalizeSource(text) {
678
- return text.replace(/\s+/g, " ").trim();
678
+ return text.replace(/\s+/g, " ");
679
679
  }
680
680
  function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
681
681
  let name;
@@ -694,7 +694,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
694
694
  let auditRequired;
695
695
  let metadata;
696
696
  const variables = /* @__PURE__ */ new Map();
697
- if (!docsArg || !ts4__default.default.isObjectLiteralExpression(docsArg)) {
697
+ if (!docsArg || !ts.isObjectLiteralExpression(docsArg)) {
698
698
  if (docsArg) {
699
699
  warnings.push({
700
700
  file: filePath,
@@ -721,7 +721,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
721
721
  };
722
722
  }
723
723
  for (const prop of docsArg.properties) {
724
- if (!ts4__default.default.isPropertyAssignment(prop)) continue;
724
+ if (!ts.isPropertyAssignment(prop)) continue;
725
725
  const propName = getStaticPropertyName(prop.name);
726
726
  if (propName === "name") {
727
727
  const evaluated = evaluateLiteral(prop.initializer);
@@ -825,7 +825,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
825
825
  });
826
826
  }
827
827
  } else if (propName === "variables") {
828
- if (ts4__default.default.isObjectLiteralExpression(prop.initializer)) {
828
+ if (ts.isObjectLiteralExpression(prop.initializer)) {
829
829
  extractVariableDocsMap(prop.initializer, filePath, contextLabel, warnings, variables);
830
830
  } else {
831
831
  warnings.push({
@@ -856,10 +856,10 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
856
856
  }
857
857
  function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnings, out) {
858
858
  for (const prop of variablesLiteral.properties) {
859
- if (!ts4__default.default.isPropertyAssignment(prop)) continue;
859
+ if (!ts.isPropertyAssignment(prop)) continue;
860
860
  const key = getStaticPropertyName(prop.name);
861
861
  if (key === void 0) continue;
862
- if (!ts4__default.default.isObjectLiteralExpression(prop.initializer)) {
862
+ if (!ts.isObjectLiteralExpression(prop.initializer)) {
863
863
  warnings.push({
864
864
  file: filePath,
865
865
  message: `documentEnv() variable docs for "${key}" in "${contextLabel}" is not an inline object literal; skipped.`
@@ -889,11 +889,9 @@ function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnin
889
889
  let metadata;
890
890
  let evidence;
891
891
  for (const field of prop.initializer.properties) {
892
- if (!ts4__default.default.isPropertyAssignment(field)) continue;
892
+ if (!ts.isPropertyAssignment(field)) continue;
893
893
  const fieldName = getStaticPropertyName(field.name);
894
- if (fieldName === void 0) continue;
895
894
  const evaluated = evaluateLiteral(field.initializer);
896
- if (!evaluated.ok) continue;
897
895
  if (fieldName === "description" && typeof evaluated.value === "string")
898
896
  description = evaluated.value;
899
897
  else if (fieldName === "owner" && typeof evaluated.value === "string") owner = evaluated.value;
@@ -989,9 +987,9 @@ function extractDynamicAccessCitations(value, filePath, key, contextLabel, warni
989
987
  return citations;
990
988
  }
991
989
  function extractCreateEnvOptionsName(optionsArg) {
992
- if (!optionsArg || !ts4__default.default.isObjectLiteralExpression(optionsArg)) return void 0;
990
+ if (!optionsArg || !ts.isObjectLiteralExpression(optionsArg)) return void 0;
993
991
  for (const prop of optionsArg.properties) {
994
- if (!ts4__default.default.isPropertyAssignment(prop)) continue;
992
+ if (!ts.isPropertyAssignment(prop)) continue;
995
993
  if (getStaticPropertyName(prop.name) !== "name") continue;
996
994
  const evaluated = evaluateLiteral(prop.initializer);
997
995
  if (evaluated.ok && typeof evaluated.value === "string") return evaluated.value;
@@ -1226,13 +1224,15 @@ async function mergeLocalAndPackageFiles(localFiles, packageFiles, fs) {
1226
1224
  }
1227
1225
  async function resolvePackageImport(specifier, allowedPackages, root, cache, fs) {
1228
1226
  const matched = allowedPackages.find(
1229
- // Stryker disable next-line ConditionalExpression
1230
1227
  (pkg) => specifier === pkg || specifier.startsWith(`${pkg}/`)
1231
1228
  );
1232
1229
  if (!matched) return void 0;
1233
1230
  const result = await resolvePackageSchemaFile(matched, root, cache, fs);
1234
1231
  return result.ok ? result.origin.resolvedFile : void 0;
1235
1232
  }
1233
+ function pathMappingOptions(options) {
1234
+ return options;
1235
+ }
1236
1236
  function createAliasResolutionCache() {
1237
1237
  return { resolutions: /* @__PURE__ */ new Map() };
1238
1238
  }
@@ -1257,9 +1257,10 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1257
1257
  }
1258
1258
  };
1259
1259
  }
1260
- const readResult = ts4__default.default.readConfigFile(configFile, (p) => ts4__default.default.sys.readFile(p));
1260
+ assertCompilerApi(ts);
1261
+ const readResult = ts.readConfigFile(configFile, (p) => ts.sys.readFile(p));
1261
1262
  if (readResult.error) {
1262
- const detail = ts4__default.default.flattenDiagnosticMessageText(readResult.error.messageText, "\n");
1263
+ const detail = ts.flattenDiagnosticMessageText(readResult.error.messageText, ts.sys.newLine);
1263
1264
  return {
1264
1265
  resolution: void 0,
1265
1266
  warning: {
@@ -1268,8 +1269,8 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1268
1269
  }
1269
1270
  };
1270
1271
  }
1271
- const parsed = ts4__default.default.parseJsonConfigFileContent(readResult.config, ts4__default.default.sys, path6__default.default.dirname(configFile));
1272
- const { paths, baseUrl } = parsed.options;
1272
+ const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys, path6__default.default.dirname(configFile));
1273
+ const { paths, baseUrl } = pathMappingOptions(parsed.options);
1273
1274
  const hasPaths = paths !== void 0 && Object.keys(paths).length > 0;
1274
1275
  if (!hasPaths && baseUrl === void 0) {
1275
1276
  return { resolution: void 0, warning: void 0 };
@@ -1279,7 +1280,7 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
1279
1280
  function resolveAliasImport(specifier, importingFile, resolution, cache) {
1280
1281
  const cacheKey = `${importingFile}\0${specifier}`;
1281
1282
  if (cache.resolutions.has(cacheKey)) return cache.resolutions.get(cacheKey);
1282
- const result = ts4__default.default.resolveModuleName(specifier, importingFile, resolution.compilerOptions, ts4__default.default.sys);
1283
+ const result = ts.resolveModuleName(specifier, importingFile, resolution.compilerOptions, ts.sys);
1283
1284
  const resolvedFileName = result.resolvedModule?.resolvedFileName;
1284
1285
  let resolved;
1285
1286
  if (resolvedFileName) {
@@ -1307,13 +1308,11 @@ async function resolveRelativeImport(importingFile, specifier, fs) {
1307
1308
  }
1308
1309
  return void 0;
1309
1310
  }
1310
- async function fileExists2(filePath, fs) {
1311
- try {
1312
- const stat = await fs.stat(filePath);
1313
- return stat.isFile();
1314
- } catch {
1315
- return false;
1316
- }
1311
+ function fileExists2(filePath, fs) {
1312
+ return fs.stat(filePath).then(
1313
+ (stat) => stat.isFile(),
1314
+ () => false
1315
+ );
1317
1316
  }
1318
1317
  async function resolveImportSpecifier(importingFile, specifier, context) {
1319
1318
  const relative = await resolveRelativeImport(importingFile, specifier, context.fs);
@@ -1352,24 +1351,29 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
1352
1351
  const warnings = [];
1353
1352
  const unresolvedLinks = [];
1354
1353
  async function resolveSchema(ref, inFile, contextLabel) {
1355
- if (ref.kind === "unresolvable") return void 0;
1356
1354
  const inFileAnalysis = mustGet(analysisCache, inFile);
1357
- if (ref.kind === "literal") {
1358
- return {
1359
- identity: `${inFile}#<inline:${ref.node.pos}>`,
1360
- variables: extractSchemaVariables(
1361
- ref.node,
1362
- inFile,
1363
- contextLabel,
1364
- warnings,
1365
- inFileAnalysis.sourceFile
1366
- )
1367
- };
1355
+ switch (ref.kind) {
1356
+ case "literal":
1357
+ return {
1358
+ identity: `${inFile}#<inline:${ref.node.pos}>`,
1359
+ variables: extractSchemaVariables(
1360
+ ref.node,
1361
+ inFile,
1362
+ contextLabel,
1363
+ warnings,
1364
+ inFileAnalysis.sourceFile
1365
+ )
1366
+ };
1367
+ case "identifier":
1368
+ return resolveNamedSchema(ref.name, inFile, inFileAnalysis, contextLabel);
1368
1369
  }
1369
- const local = inFileAnalysis.localConsts.get(ref.name);
1370
+ return void 0;
1371
+ }
1372
+ async function resolveNamedSchema(name, inFile, inFileAnalysis, contextLabel) {
1373
+ const local = inFileAnalysis.localConsts.get(name);
1370
1374
  if (local) {
1371
1375
  return {
1372
- identity: `${inFile}#${ref.name}`,
1376
+ identity: `${inFile}#${name}`,
1373
1377
  variables: extractSchemaVariables(
1374
1378
  local,
1375
1379
  inFile,
@@ -1379,7 +1383,7 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
1379
1383
  )
1380
1384
  };
1381
1385
  }
1382
- const imported = inFileAnalysis.imports.get(ref.name);
1386
+ const imported = inFileAnalysis.imports.get(name);
1383
1387
  if (!imported) return void 0;
1384
1388
  const targetFile = await resolveImportSpecifier(inFile, imported.specifier, context);
1385
1389
  if (!targetFile) return void 0;
@@ -1565,7 +1569,7 @@ function effectiveAuditRequired(contract, variable) {
1565
1569
 
1566
1570
  // src/build/assemble-project.ts
1567
1571
  async function assembleProject(options) {
1568
- const { fs, root, include, exclude, packages, tsconfig } = options;
1572
+ const { fs, root, include, exclude, packages = [], tsconfig } = options;
1569
1573
  const fileCache = /* @__PURE__ */ new Map();
1570
1574
  const readFileCached = (filePath) => {
1571
1575
  let cached = fileCache.get(filePath);
@@ -1622,7 +1626,6 @@ function buildChangeModel(manifest, currentContracts, root) {
1622
1626
  const relativeFile = displayPath(root, contract.file);
1623
1627
  const cIdentity = contractIdentity2(relativeFile, contract.exportName);
1624
1628
  for (const variable of contract.variables) {
1625
- if (!variable.renamedFrom) continue;
1626
1629
  const addedRef = findByContractAndKey(
1627
1630
  manifest.addedVariables,
1628
1631
  relativeFile,
@@ -1748,8 +1751,7 @@ function variableShape(variable) {
1748
1751
  };
1749
1752
  }
1750
1753
  function shapesMatch(a, b) {
1751
- if (a.valueType === "unknown" || b.valueType === "unknown") return false;
1752
- return a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
1754
+ return a.valueType !== "unknown" && a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
1753
1755
  }
1754
1756
  function detectDuplicateVariableShapes(contracts) {
1755
1757
  const candidates = contracts.filter((c) => c.active && !c.exclusiveGroup);
@@ -1888,60 +1890,55 @@ function isPlainObject(value) {
1888
1890
  const proto = Object.getPrototypeOf(value);
1889
1891
  return proto === Object.prototype || proto === null;
1890
1892
  }
1893
+
1894
+ // src/build/scan-dependencies.ts
1891
1895
  function unwrapParens(node) {
1892
1896
  let current = node;
1893
- while (ts4__default.default.isParenthesizedExpression(current)) current = current.expression;
1897
+ while (ts.isParenthesizedExpression(current)) current = current.expression;
1894
1898
  return current;
1895
1899
  }
1896
1900
  function staticElementKey(node) {
1897
- return ts4__default.default.isStringLiteralLike(node) ? node.text : void 0;
1901
+ return ts.isStringLiteralLike(node) ? node.text : void 0;
1898
1902
  }
1899
1903
  function forEachBindingName(name, record) {
1900
- if (ts4__default.default.isIdentifier(name)) {
1904
+ if (ts.isIdentifier(name)) {
1901
1905
  record(name.text);
1902
1906
  return;
1903
1907
  }
1904
1908
  for (const element of name.elements) {
1905
- if (ts4__default.default.isOmittedExpression(element)) continue;
1909
+ if (ts.isOmittedExpression(element)) continue;
1906
1910
  forEachBindingName(element.name, record);
1907
1911
  }
1908
1912
  }
1909
1913
  function isAssignmentToken(token) {
1910
- return token >= ts4__default.default.SyntaxKind.FirstAssignment && token <= ts4__default.default.SyntaxKind.LastAssignment;
1914
+ return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment;
1911
1915
  }
1912
1916
  function recordIfIdentifierTarget(expression, assignedNames) {
1913
1917
  const target = unwrapParens(expression);
1914
- if (ts4__default.default.isIdentifier(target)) assignedNames.add(target.text);
1918
+ if (ts.isIdentifier(target)) assignedNames.add(target.text);
1915
1919
  }
1916
1920
  function recordAssignmentTargets(node, assignedNames) {
1917
- if (ts4__default.default.isBinaryExpression(node) && isAssignmentToken(node.operatorToken.kind)) {
1921
+ if (ts.isBinaryExpression(node) && isAssignmentToken(node.operatorToken.kind)) {
1918
1922
  recordIfIdentifierTarget(node.left, assignedNames);
1919
1923
  return;
1920
1924
  }
1921
- if (
1922
- // Widening this to `true` is behaviorally equivalent, not a real gap:
1923
- // only a prefix/postfix unary node carries an `.operator` at all, so on
1924
- // any other node the two `=== PlusPlus/MinusMinus` checks below both
1925
- // read `undefined` and fail. Hand-verified: mutating this compound to
1926
- // `if (true)` and running the real suite passes unchanged.
1927
- // Stryker disable next-line ConditionalExpression
1928
- (ts4__default.default.isPrefixUnaryExpression(node) || ts4__default.default.isPostfixUnaryExpression(node)) && (node.operator === ts4__default.default.SyntaxKind.PlusPlusToken || node.operator === ts4__default.default.SyntaxKind.MinusMinusToken)
1929
- ) {
1930
- recordIfIdentifierTarget(node.operand, assignedNames);
1925
+ const { operator, operand } = node;
1926
+ if (operator === ts.SyntaxKind.PlusPlusToken || operator === ts.SyntaxKind.MinusMinusToken) {
1927
+ recordIfIdentifierTarget(operand, assignedNames);
1931
1928
  return;
1932
1929
  }
1933
- if ((ts4__default.default.isForOfStatement(node) || ts4__default.default.isForInStatement(node)) && !ts4__default.default.isVariableDeclarationList(node.initializer)) {
1930
+ if ((ts.isForOfStatement(node) || ts.isForInStatement(node)) && !ts.isVariableDeclarationList(node.initializer)) {
1934
1931
  recordIfIdentifierTarget(node.initializer, assignedNames);
1935
1932
  }
1936
1933
  }
1937
1934
  function recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates) {
1938
- if (ts4__default.default.isVariableDeclaration(node) || ts4__default.default.isParameter(node)) {
1935
+ if (ts.isVariableDeclaration(node) || ts.isParameter(node)) {
1939
1936
  forEachBindingName(node.name, countDeclaration);
1940
- if (!ts4__default.default.isVariableDeclaration(node) || !ts4__default.default.isIdentifier(node.name)) return;
1937
+ if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name)) return;
1941
1938
  if (node.initializer === void 0) return;
1942
1939
  const initializer = unwrapParens(node.initializer);
1943
- const isConst = (ts4__default.default.getCombinedNodeFlags(node) & ts4__default.default.NodeFlags.Const) !== 0;
1944
- if (isConst && ts4__default.default.isIdentifier(initializer)) {
1940
+ const isConst = (ts.getCombinedNodeFlags(node) & ts.NodeFlags.Const) !== 0;
1941
+ if (isConst && ts.isIdentifier(initializer)) {
1945
1942
  constAliasCandidates.push({
1946
1943
  aliasName: node.name.text,
1947
1944
  baseName: initializer.text,
@@ -1950,7 +1947,7 @@ function recordDeclarationIntroduction(node, countDeclaration, constAliasCandida
1950
1947
  }
1951
1948
  return;
1952
1949
  }
1953
- if ((ts4__default.default.isFunctionDeclaration(node) || ts4__default.default.isClassDeclaration(node)) && node.name) {
1950
+ if ((ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) && node.name) {
1954
1951
  countDeclaration(node.name.text);
1955
1952
  }
1956
1953
  }
@@ -1964,9 +1961,9 @@ function collectDeclarationFacts(sourceFile) {
1964
1961
  function walk(node) {
1965
1962
  recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates);
1966
1963
  recordAssignmentTargets(node, assignedNames);
1967
- ts4__default.default.forEachChild(node, walk);
1964
+ ts.forEachChild(node, walk);
1968
1965
  }
1969
- ts4__default.default.forEachChild(sourceFile, walk);
1966
+ ts.forEachChild(sourceFile, walk);
1970
1967
  return { declarationCounts, assignedNames, constAliasCandidates };
1971
1968
  }
1972
1969
  function resolveAliasTargets(candidates, declarationCounts, assignedNames, imports) {
@@ -1991,21 +1988,22 @@ function bindingElementKey(element) {
1991
1988
  if (element.propertyName === void 0) {
1992
1989
  return element.name.text;
1993
1990
  }
1994
- if (ts4__default.default.isIdentifier(element.propertyName) || ts4__default.default.isStringLiteral(element.propertyName)) {
1991
+ if (ts.isIdentifier(element.propertyName) || ts.isStringLiteral(element.propertyName)) {
1995
1992
  return element.propertyName.text;
1996
1993
  }
1997
- if (ts4__default.default.isComputedPropertyName(element.propertyName)) {
1994
+ if (ts.isComputedPropertyName(element.propertyName)) {
1998
1995
  const inner = element.propertyName.expression;
1999
- return ts4__default.default.isStringLiteralLike(inner) ? inner.text : inner;
1996
+ return ts.isStringLiteralLike(inner) ? inner.text : inner;
2000
1997
  }
2001
1998
  return element.propertyName;
2002
1999
  }
2003
2000
  function scanFileForDependencies(filePath, sourceText) {
2004
- const scriptKind = filePath.endsWith(".tsx") ? ts4__default.default.ScriptKind.TSX : ts4__default.default.ScriptKind.TS;
2005
- const sourceFile = ts4__default.default.createSourceFile(
2001
+ assertCompilerApi(ts);
2002
+ const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
2003
+ const sourceFile = ts.createSourceFile(
2006
2004
  filePath,
2007
2005
  sourceText,
2008
- ts4__default.default.ScriptTarget.Latest,
2006
+ ts.ScriptTarget.Latest,
2009
2007
  // Load-bearing, unlike before: `ts.getCombinedNodeFlags()` (used to tell
2010
2008
  // a `const` declaration apart from `let`/`var` when resolving alias
2011
2009
  // candidates) walks parent pointers internally. Flipping this to `false`
@@ -2017,9 +2015,9 @@ function scanFileForDependencies(filePath, sourceText) {
2017
2015
  const imports = /* @__PURE__ */ new Map();
2018
2016
  let hasWildcardReExport = false;
2019
2017
  for (const statement of sourceFile.statements) {
2020
- if (ts4__default.default.isImportDeclaration(statement)) {
2018
+ if (ts.isImportDeclaration(statement)) {
2021
2019
  collectImportBindings(statement, imports);
2022
- } else if (ts4__default.default.isExportDeclaration(statement) && !statement.exportClause && statement.moduleSpecifier) {
2020
+ } else if (ts.isExportDeclaration(statement) && !statement.exportClause && statement.moduleSpecifier) {
2023
2021
  hasWildcardReExport = true;
2024
2022
  }
2025
2023
  }
@@ -2050,7 +2048,7 @@ function scanFileForDependencies(filePath, sourceText) {
2050
2048
  for (const element of pattern.elements) {
2051
2049
  if (element.dotDotDotToken) {
2052
2050
  record(localName, { kind: "escape", via: "rest", ...positionOf(sourceFile, element) });
2053
- } else if (!ts4__default.default.isIdentifier(element.name)) {
2051
+ } else if (!ts.isIdentifier(element.name)) {
2054
2052
  record(localName, {
2055
2053
  kind: "escape",
2056
2054
  via: "nested-pattern",
@@ -2066,17 +2064,17 @@ function scanFileForDependencies(filePath, sourceText) {
2066
2064
  via: "computed-key",
2067
2065
  ...positionOf(sourceFile, element)
2068
2066
  });
2069
- ts4__default.default.forEachChild(key, visit);
2067
+ ts.forEachChild(key, visit);
2070
2068
  }
2071
2069
  }
2072
- if (element.initializer) ts4__default.default.forEachChild(element.initializer, visit);
2070
+ ts.forEachChild(element.initializer, visit);
2073
2071
  }
2074
2072
  }
2075
2073
  function tryRecordPropertyOrElementAccess(node) {
2076
- const isProperty = ts4__default.default.isPropertyAccessExpression(node);
2077
- if (!isProperty && !ts4__default.default.isElementAccessExpression(node)) return false;
2074
+ const isProperty = ts.isPropertyAccessExpression(node);
2075
+ if (!isProperty && !ts.isElementAccessExpression(node)) return false;
2078
2076
  const base = unwrapParens(node.expression);
2079
- if (!ts4__default.default.isIdentifier(base) || !imports.has(base.text)) return false;
2077
+ if (!ts.isIdentifier(base) || !imports.has(base.text)) return false;
2080
2078
  if (isProperty) {
2081
2079
  record(base.text, { kind: "member", member: node.name.text, ...positionOf(sourceFile, node) });
2082
2080
  return true;
@@ -2086,28 +2084,28 @@ function scanFileForDependencies(filePath, sourceText) {
2086
2084
  base.text,
2087
2085
  key !== void 0 ? { kind: "member", member: key, ...positionOf(sourceFile, node) } : { kind: "dynamic", ...positionOf(sourceFile, node) }
2088
2086
  );
2089
- ts4__default.default.forEachChild(node.argumentExpression, visit);
2087
+ ts.forEachChild(node.argumentExpression, visit);
2090
2088
  return true;
2091
2089
  }
2092
2090
  function visit(node) {
2093
- if (ts4__default.default.isImportDeclaration(node) || ts4__default.default.isExportDeclaration(node) || ts4__default.default.isVariableDeclaration(node) && handledDeclarations.has(node)) {
2091
+ if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node) || ts.isVariableDeclaration(node) && handledDeclarations.has(node)) {
2094
2092
  return;
2095
2093
  }
2096
- if (ts4__default.default.isVariableDeclaration(node) && ts4__default.default.isObjectBindingPattern(node.name) && node.initializer) {
2094
+ if (ts.isVariableDeclaration(node) && ts.isObjectBindingPattern(node.name) && node.initializer) {
2097
2095
  const base = unwrapParens(node.initializer);
2098
- if (ts4__default.default.isIdentifier(base) && imports.has(base.text)) {
2096
+ if (ts.isIdentifier(base) && imports.has(base.text)) {
2099
2097
  recordObjectBindingAccesses(node.name, base.text);
2100
2098
  return;
2101
2099
  }
2102
2100
  }
2103
2101
  if (tryRecordPropertyOrElementAccess(node)) return;
2104
- if (ts4__default.default.isIdentifier(node) && imports.has(node.text)) {
2102
+ if (ts.isIdentifier(node) && imports.has(node.text)) {
2105
2103
  record(node.text, { kind: "reference", ...positionOf(sourceFile, node) });
2106
2104
  return;
2107
2105
  }
2108
- ts4__default.default.forEachChild(node, visit);
2106
+ ts.forEachChild(node, visit);
2109
2107
  }
2110
- ts4__default.default.forEachChild(sourceFile, visit);
2108
+ ts.forEachChild(sourceFile, visit);
2111
2109
  return { file: filePath, imports, accessesByLocalName: accesses, hasWildcardReExport };
2112
2110
  }
2113
2111
 
@@ -2115,8 +2113,11 @@ function scanFileForDependencies(filePath, sourceText) {
2115
2113
  function generatedFileMarker() {
2116
2114
  return "GENERATED FILE";
2117
2115
  }
2118
- function generatedBanner(format = "ts") {
2119
- const text = `${generatedFileMarker()} -- do not edit by hand. Run \`npx env-cap\` to regenerate.`;
2116
+ function reportRegenerateHint() {
2117
+ return "Regenerate it by re-running the script that calls `generateDocumentation()` / `generateUsageReport()` from `@maverickcer/env-cap/build`.";
2118
+ }
2119
+ function generatedBanner(format = "ts", regenerate = "Run `npx env-cap` to regenerate.") {
2120
+ const text = `${generatedFileMarker()} -- do not edit by hand. ${regenerate}`;
2120
2121
  return { ts: `// ${text}`, markdown: `<!-- ${text} -->` }[format];
2121
2122
  }
2122
2123
  function isGeneratedFile(content) {
@@ -2127,7 +2128,7 @@ function evidenceDisclaimer() {
2127
2128
  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.";
2128
2129
  }
2129
2130
  function evidenceProjectionNote(evidencePath) {
2130
- const concept = "Projected from env-cap's Evidence Model (ADR 0031/0038), the same source every other generated artifact draws from.";
2131
+ 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.";
2131
2132
  return evidencePath === void 0 ? concept : `${concept} This run also wrote it to \`${evidencePath}\`.`;
2132
2133
  }
2133
2134
 
@@ -2238,8 +2239,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
2238
2239
  for (const scan of scanResults) {
2239
2240
  for (const [localName, binding] of scan.imports) {
2240
2241
  const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
2241
- if (!resolvedFile) continue;
2242
- const building = byIdentity2.get(`${resolvedFile}#${binding.importedName}`);
2242
+ const building = byIdentity2.get(`${String(resolvedFile)}#${binding.importedName}`);
2243
2243
  if (!building) continue;
2244
2244
  building.imported = true;
2245
2245
  building.consumingFiles.add(scan.file);
@@ -2249,8 +2249,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
2249
2249
  for (const scan of scanResults) {
2250
2250
  for (const [, binding] of scan.imports) {
2251
2251
  const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
2252
- if (!resolvedFile) continue;
2253
- const targetScan = scanByFile.get(resolvedFile);
2252
+ const targetScan = scanByFile.get(String(resolvedFile));
2254
2253
  if (!targetScan?.hasWildcardReExport) continue;
2255
2254
  for (const building of byIdentity2.values()) {
2256
2255
  if (building.imported) continue;
@@ -2353,20 +2352,9 @@ async function buildDependencyModel(contracts, scanFiles, readFile, context, roo
2353
2352
  positions: info.positions.map((p) => relativizePosition2(root, p)),
2354
2353
  dynamicAccessAssertions: info.dynamicAccessAssertions
2355
2354
  })).sort((a, b) => a.key.localeCompare(b.key)),
2356
- // `.sort()` here (and the whole `.map(...).sort()` chain as one
2357
- // `MethodExpression` unit) is a defensive no-op, not a real gap:
2358
- // dependency-graph.ts's own `consumingFiles` is already
2359
- // `[...building.consumingFiles].sort()` before this projection ever
2360
- // sees it (see that file's own comment). Hand-verified: dropping this
2361
- // `.sort()` and running the real suite passes unchanged -- confirmed
2362
- // again 2026-09-18 against CI's own diagnostic mutation report, which
2363
- // flagged this exact `MethodExpression` mutant as Survived.
2364
- // Stryker disable next-line MethodExpression
2355
+ // Sorted after mapping to display paths: a file outside `root` (a package surface) shows as
2356
+ // `../...`, which can order differently from its absolute path.
2365
2357
  consumingFiles: [...contract.consumingFiles].map((f) => displayPath(root, f)).sort(),
2366
- // Same reasoning as `consumingFiles` just above -- the whole
2367
- // `.map(...).sort()` chain is a coarser-grained `MethodExpression`
2368
- // mutant target than the next-line one on `.sort()` alone just below.
2369
- // Stryker disable next-line MethodExpression
2370
2358
  ambiguousBarrelFiles: [...contract.ambiguousBarrelFiles].map((f) => displayPath(root, f)).sort(),
2371
2359
  dynamicAccessSites: contract.dynamicAccessSites.map((p) => relativizePosition2(root, p))
2372
2360
  }));
@@ -2520,30 +2508,11 @@ function renderManifest(contracts, outputFile) {
2520
2508
  for (const contract of sorted) {
2521
2509
  let localName = contract.exportName;
2522
2510
  if (usedNames.has(localName)) {
2523
- const maxSuffix = sorted.length + 16;
2524
- let found;
2525
- let passes = 0;
2526
- for (let suffix = 1; suffix <= maxSuffix; suffix++) {
2527
- passes++;
2528
- if (passes > maxSuffix) {
2529
- throw new Error(
2530
- // Stryker disable next-line StringLiteral
2531
- `renderManifest: exceeded ${String(maxSuffix)} attempts choosing a unique local import name for "${contract.exportName}" -- this should never happen and indicates an internal naming bug.`
2532
- );
2533
- }
2534
- const candidate = `${contract.exportName}_${suffix}`;
2535
- if (!usedNames.has(candidate)) {
2536
- found = candidate;
2537
- break;
2538
- }
2539
- }
2540
- if (found === void 0) {
2541
- throw new Error(
2542
- // Stryker disable next-line StringLiteral
2543
- `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.`
2544
- );
2545
- }
2546
- localName = found;
2511
+ const candidates = Array.from(
2512
+ { length: usedNames.size + 1 },
2513
+ (_, index) => `${contract.exportName}_${index + 1}`
2514
+ );
2515
+ localName = String(candidates.find((candidate) => !usedNames.has(candidate)));
2547
2516
  }
2548
2517
  usedNames.add(localName);
2549
2518
  referenceNames.push(localName);
@@ -2592,10 +2561,8 @@ function defaultExclude() {
2592
2561
  // inspect `exclude` directly, and as defense if that hardcoding ever
2593
2562
  // changes) -- hand-verified: emptying both and running the full
2594
2563
  // `vitest run` leaves all 1243 tests passing.
2595
- // Stryker disable next-line StringLiteral
2596
2564
  "**/node_modules/**",
2597
2565
  "**/dist/**",
2598
- // Stryker disable next-line StringLiteral
2599
2566
  "**/.git/**"
2600
2567
  ];
2601
2568
  }
@@ -2625,8 +2592,6 @@ async function generateEnvManifest(options) {
2625
2592
  const root = path6__default.default.resolve(options.root ?? process.cwd());
2626
2593
  const include = options.include ?? defaultInclude();
2627
2594
  const exclude = options.exclude ?? defaultExclude();
2628
- const packages = options.packages ?? [];
2629
- const onIncompatibility = options.onIncompatibility ?? "warn";
2630
2595
  const locationResult = resolveWithinRoot(
2631
2596
  root,
2632
2597
  options.location,
@@ -2640,10 +2605,10 @@ async function generateEnvManifest(options) {
2640
2605
  root,
2641
2606
  include,
2642
2607
  exclude,
2643
- packages,
2608
+ packages: options.packages,
2644
2609
  tsconfig: options.tsconfig
2645
2610
  });
2646
- const computed = computeManifest(root, linkResult, onIncompatibility);
2611
+ const computed = computeManifest(root, linkResult, options.onIncompatibility);
2647
2612
  if (computed.blocking.length > 0) throw new EnvManifestGenerationError(computed.blocking);
2648
2613
  await writeManifest(outputPath, computed.activeContracts, options.fs);
2649
2614
  return {
@@ -2783,7 +2748,7 @@ function renderParseWarnings(warnings) {
2783
2748
  }
2784
2749
  function renderUsageReport(computed) {
2785
2750
  const lines = [
2786
- generatedBanner("markdown"),
2751
+ generatedBanner("markdown", reportRegenerateHint()),
2787
2752
  "",
2788
2753
  `> ${evidenceDisclaimer()}`,
2789
2754
  "",
@@ -2791,7 +2756,7 @@ function renderUsageReport(computed) {
2791
2756
  "",
2792
2757
  "# Dependency & Ownership Report",
2793
2758
  "",
2794
- "_Produced by `env-cap --ownership`._",
2759
+ "_Produced by `generateUsageReport()` from `@maverickcer/env-cap/build`._",
2795
2760
  "",
2796
2761
  "Which feature owns each variable, which features consume that contract, and what the blast radius is if it changes.",
2797
2762
  "",
@@ -2803,7 +2768,7 @@ function renderUsageReport(computed) {
2803
2768
  ...renderAsserted(computed.asserted),
2804
2769
  ...renderParseWarnings(computed.parseWarnings)
2805
2770
  ];
2806
- return lines.join("\n").replace(/\n{3,}/g, "\n\n");
2771
+ return lines.join("\n");
2807
2772
  }
2808
2773
 
2809
2774
  // src/build/generate-usage.ts
@@ -2834,7 +2799,7 @@ async function computeScanSurface(root, exclude, origins, fs) {
2834
2799
  }
2835
2800
  return { scanFiles, scannedSurfaces };
2836
2801
  }
2837
- async function computeUsage(root, contracts, scanFiles, readFile, context, parseWarnings, scannedSurfaces, dynamicAccessAcknowledgments) {
2802
+ async function computeUsage(root, contracts, scanFiles, readFile, context, scannedSurfaces, dynamicAccessAcknowledgments) {
2838
2803
  const graph = await buildDependencyGraph(
2839
2804
  contracts,
2840
2805
  scanFiles,
@@ -2847,13 +2812,9 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2847
2812
  const contractByIdentity = /* @__PURE__ */ new Map();
2848
2813
  for (const contract of contracts)
2849
2814
  contractByIdentity.set(`${contract.file}#${contract.exportName}`, contract);
2850
- const ownerFor = (file, exportName) => (
2851
- // Stryker disable next-line OptionalChaining
2852
- contractByIdentity.get(`${file}#${exportName}`)?.owner
2853
- );
2815
+ const ownerFor = (file, exportName) => mustGet(contractByIdentity, `${file}#${exportName}`).owner;
2854
2816
  const effectiveOwnerFor = (file, exportName, key) => {
2855
- const contract = contractByIdentity.get(`${file}#${exportName}`);
2856
- if (!contract) return void 0;
2817
+ const contract = mustGet(contractByIdentity, `${file}#${exportName}`);
2857
2818
  const variable = contract.variables.find((v) => v.key === key);
2858
2819
  return variable ? effectiveOwner(contract, variable) : contract.owner;
2859
2820
  };
@@ -2879,19 +2840,16 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2879
2840
  const staleOrMissingCitationsFor = (contractName, file, exportName, key) => {
2880
2841
  const relativeFile = displayPath(root, file);
2881
2842
  const identity = dynamicAccessVariableIdentity(relativeFile, exportName, key);
2882
- const problems = [];
2883
- for (const a of dynamicAccessAcknowledgments?.get(identity) ?? []) {
2884
- if (a.acknowledgment === "fresh") continue;
2885
- problems.push({
2843
+ return (dynamicAccessAcknowledgments?.get(identity) ?? []).map(
2844
+ (a) => ({
2886
2845
  contractName,
2887
2846
  file: relativeFile,
2888
2847
  exportName,
2889
2848
  key,
2890
2849
  position: { file: a.file, line: a.line, column: a.column },
2891
2850
  acknowledgment: a.acknowledgment
2892
- });
2893
- }
2894
- return problems;
2851
+ })
2852
+ );
2895
2853
  };
2896
2854
  const unconsumedOwnedVariables = findings.unconsumedOwned.map(
2897
2855
  (f) => ({
@@ -2936,7 +2894,6 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
2936
2894
  unconsumedOwnedVariables,
2937
2895
  indeterminate,
2938
2896
  asserted,
2939
- parseWarnings,
2940
2897
  scannedSurfaces: graph.scannedSurfaces
2941
2898
  }
2942
2899
  };
@@ -2950,24 +2907,23 @@ async function generateUsageReport(options) {
2950
2907
  const root = path6__default.default.resolve(options.root ?? process.cwd());
2951
2908
  const include = options.include ?? defaultInclude();
2952
2909
  const exclude = options.exclude ?? defaultExclude();
2953
- const packages = options.packages ?? [];
2954
2910
  let reportPath;
2955
2911
  if (options.report) {
2956
- const result = resolveWithinRoot(
2912
+ const result2 = resolveWithinRoot(
2957
2913
  root,
2958
2914
  options.report.location,
2959
2915
  "report.location",
2960
2916
  "generateUsageReport"
2961
2917
  );
2962
- if (!result.ok) throw new EnvUsageAnalysisError([result.issue]);
2963
- reportPath = result.resolved;
2918
+ if (!result2.ok) throw new EnvUsageAnalysisError([result2.issue]);
2919
+ reportPath = result2.resolved;
2964
2920
  }
2965
2921
  const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
2966
2922
  fs: options.fs,
2967
2923
  root,
2968
2924
  include,
2969
2925
  exclude,
2970
- packages,
2926
+ packages: options.packages,
2971
2927
  tsconfig: options.tsconfig
2972
2928
  });
2973
2929
  const { scanFiles, scannedSurfaces } = await computeScanSurface(
@@ -2982,11 +2938,14 @@ async function generateUsageReport(options) {
2982
2938
  scanFiles,
2983
2939
  readFileCached,
2984
2940
  context,
2985
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
2986
2941
  scannedSurfaces
2987
2942
  );
2988
- if (reportPath) await writeUsageReport(reportPath, computed.result, options.fs);
2989
- return { reportPath, ...computed.result };
2943
+ const result = {
2944
+ ...computed.result,
2945
+ parseWarnings: [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings]
2946
+ };
2947
+ if (reportPath) await writeUsageReport(reportPath, result, options.fs);
2948
+ return { reportPath, ...result };
2990
2949
  }
2991
2950
 
2992
2951
  // src/build/finding-model.ts
@@ -3300,107 +3259,132 @@ function groupVariablesByOwner(contracts, ownerOf) {
3300
3259
  }
3301
3260
  return byOwner;
3302
3261
  }
3303
- var configurationReference = defineEvidenceProjection({
3304
- // Stryker disable next-line ArrowFunction
3305
- disclaimer: () => evidenceDisclaimer(),
3306
- entries: (evidence) => {
3307
- const entries = [];
3308
- for (const contract of evidence.contract.contracts) {
3309
- for (const variable of contract.variables) {
3310
- entries.push({
3311
- file: contract.file,
3312
- exportName: contract.exportName,
3313
- contractName: contract.contractName,
3314
- key: variable.key,
3315
- description: variable.description,
3316
- owner: variable.owner ?? contract.owner,
3317
- sensitivity: variable.sensitivity ?? contract.sensitivity,
3318
- required: variable.required,
3319
- hasDefault: variable.hasDefault,
3320
- hasProcessor: variable.hasProcessor,
3321
- hasValidator: variable.hasValidator,
3322
- expiresAt: variable.expiresAt,
3323
- active: contract.active
3324
- });
3262
+ function configurationReference(evidence) {
3263
+ return projectConfigurationReference(evidence).value;
3264
+ }
3265
+ configurationReference.project = projectConfigurationReference;
3266
+ function projectConfigurationReference(evidence) {
3267
+ return defineEvidenceProjection(configurationReferenceSchema()).project(evidence);
3268
+ }
3269
+ function configurationReferenceSchema() {
3270
+ return {
3271
+ disclaimer: evidenceDisclaimer,
3272
+ entries: (evidence) => {
3273
+ const entries = [];
3274
+ for (const contract of evidence.contract.contracts) {
3275
+ for (const variable of contract.variables) {
3276
+ entries.push({
3277
+ file: contract.file,
3278
+ exportName: contract.exportName,
3279
+ contractName: contract.contractName,
3280
+ key: variable.key,
3281
+ description: variable.description,
3282
+ owner: variable.owner ?? contract.owner,
3283
+ sensitivity: variable.sensitivity ?? contract.sensitivity,
3284
+ required: variable.required,
3285
+ hasDefault: variable.hasDefault,
3286
+ hasProcessor: variable.hasProcessor,
3287
+ hasValidator: variable.hasValidator,
3288
+ expiresAt: variable.expiresAt,
3289
+ active: contract.active
3290
+ });
3291
+ }
3325
3292
  }
3293
+ return entries.sort(byContractThenKey);
3326
3294
  }
3327
- return entries.sort(byContractThenKey);
3328
- }
3329
- });
3330
- var ownershipSummary = defineEvidenceProjection({
3331
- // Stryker disable next-line ArrowFunction
3332
- disclaimer: () => evidenceDisclaimer(),
3333
- owners: (evidence) => {
3334
- const contracts = contractIndex(evidence.contract.contracts);
3335
- const nameOf = (file, exportName) => contracts.get(`${file}#${exportName}`)?.contractName ?? exportName;
3336
- const variablesByOwner = groupVariablesByOwner(
3337
- evidence.ownership.contracts,
3338
- (_contract, variable) => variable.owner
3339
- );
3340
- const contractsByOwner = /* @__PURE__ */ new Map();
3341
- for (const contract of evidence.ownership.contracts) {
3342
- if (contract.owner === void 0) continue;
3343
- const list = contractsByOwner.get(contract.owner) ?? [];
3344
- list.push(nameOf(contract.file, contract.exportName));
3345
- contractsByOwner.set(contract.owner, list);
3295
+ };
3296
+ }
3297
+ function ownershipSummary(evidence) {
3298
+ return projectOwnershipSummary(evidence).value;
3299
+ }
3300
+ ownershipSummary.project = projectOwnershipSummary;
3301
+ function projectOwnershipSummary(evidence) {
3302
+ return defineEvidenceProjection(ownershipSummarySchema()).project(evidence);
3303
+ }
3304
+ function ownershipSummarySchema() {
3305
+ return {
3306
+ disclaimer: evidenceDisclaimer,
3307
+ owners: (evidence) => {
3308
+ const contracts = contractIndex(evidence.contract.contracts);
3309
+ const nameOf = (file, exportName) => contracts.get(`${file}#${exportName}`)?.contractName ?? exportName;
3310
+ const variablesByOwner = groupVariablesByOwner(
3311
+ evidence.ownership.contracts,
3312
+ (_contract, variable) => variable.owner
3313
+ );
3314
+ const contractsByOwner = /* @__PURE__ */ new Map();
3315
+ for (const contract of evidence.ownership.contracts) {
3316
+ if (contract.owner === void 0) continue;
3317
+ const list = contractsByOwner.get(contract.owner) ?? [];
3318
+ list.push(nameOf(contract.file, contract.exportName));
3319
+ contractsByOwner.set(contract.owner, list);
3320
+ }
3321
+ const owners = /* @__PURE__ */ new Set([...variablesByOwner.keys(), ...contractsByOwner.keys()]);
3322
+ return [...owners].sort().map((owner) => ({
3323
+ owner,
3324
+ variables: (variablesByOwner.get(owner) ?? []).map(
3325
+ ({ contract, variable }) => `${nameOf(contract.file, contract.exportName)}.${variable.key}`
3326
+ ).sort(),
3327
+ contracts: (contractsByOwner.get(owner) ?? []).sort()
3328
+ }));
3329
+ },
3330
+ unowned: (evidence) => {
3331
+ const contracts = contractIndex(evidence.contract.contracts);
3332
+ return evidence.ownership.unownedVariables.map((ref) => {
3333
+ const contractName = contracts.get(`${ref.file}#${ref.exportName}`)?.contractName ?? ref.exportName;
3334
+ return `${contractName}.${ref.key}`;
3335
+ }).sort();
3346
3336
  }
3347
- const owners = /* @__PURE__ */ new Set([...variablesByOwner.keys(), ...contractsByOwner.keys()]);
3348
- return [...owners].sort().map((owner) => ({
3349
- owner,
3350
- variables: (variablesByOwner.get(owner) ?? []).map(
3351
- ({ contract, variable }) => `${nameOf(contract.file, contract.exportName)}.${variable.key}`
3352
- ).sort(),
3353
- contracts: (contractsByOwner.get(owner) ?? []).sort()
3354
- }));
3355
- },
3356
- unowned: (evidence) => {
3357
- const contracts = contractIndex(evidence.contract.contracts);
3358
- return evidence.ownership.unownedVariables.map((ref) => {
3359
- const contractName = contracts.get(`${ref.file}#${ref.exportName}`)?.contractName ?? ref.exportName;
3360
- return `${contractName}.${ref.key}`;
3361
- }).sort();
3362
- }
3363
- });
3364
- var expiringSoonReport = defineEvidenceProjection({
3365
- // Stryker disable next-line ArrowFunction
3366
- disclaimer: () => evidenceDisclaimer(),
3367
- entries: (evidence) => {
3368
- const contracts = contractIndex(evidence.contract.contracts);
3369
- const ownerByVariable = /* @__PURE__ */ new Map();
3370
- for (const contract of evidence.ownership.contracts)
3371
- for (const variable of contract.variables)
3372
- ownerByVariable.set(
3373
- `${contract.file}#${contract.exportName}#${variable.key}`,
3374
- variable.owner
3375
- );
3376
- return evidence.lifecycle.expiring.map((entry) => {
3377
- const contract = contracts.get(`${entry.file}#${entry.exportName}`);
3378
- const variable = entry.key === void 0 ? void 0 : contract?.variables.find((v) => v.key === entry.key);
3379
- return {
3380
- file: entry.file,
3381
- exportName: entry.exportName,
3382
- contractName: contract?.contractName ?? entry.exportName,
3383
- key: entry.key,
3384
- expiresAt: entry.expiresAt,
3385
- daysRemaining: entry.daysRemaining,
3386
- expired: entry.daysRemaining < 0,
3387
- refreshInstructions: variable?.refreshInstructions,
3388
- owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
3389
- };
3390
- });
3391
- },
3392
- // Same static covered-mutant false-Survivor as the `disclaimer` arrows
3393
- // above -- hand-verified killed (mutating this whole arrow to `() =>
3394
- // undefined` fails the "expiredCount" assertions in every test above).
3395
- // Stryker disable next-line ArrowFunction
3396
- expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
3397
- });
3337
+ };
3338
+ }
3339
+ function expiringSoonReport(evidence) {
3340
+ return projectExpiringSoonReport(evidence).value;
3341
+ }
3342
+ expiringSoonReport.project = projectExpiringSoonReport;
3343
+ function projectExpiringSoonReport(evidence) {
3344
+ return defineEvidenceProjection(expiringSoonReportSchema()).project(evidence);
3345
+ }
3346
+ function expiringSoonReportSchema() {
3347
+ return {
3348
+ disclaimer: evidenceDisclaimer,
3349
+ entries: (evidence) => {
3350
+ const contracts = contractIndex(evidence.contract.contracts);
3351
+ const ownerByVariable = /* @__PURE__ */ new Map();
3352
+ for (const contract of evidence.ownership.contracts)
3353
+ for (const variable of contract.variables)
3354
+ ownerByVariable.set(
3355
+ `${contract.file}#${contract.exportName}#${variable.key}`,
3356
+ variable.owner
3357
+ );
3358
+ return evidence.lifecycle.expiring.map((entry) => {
3359
+ const contract = contracts.get(`${entry.file}#${entry.exportName}`);
3360
+ const variable = contract?.variables.find((v) => v.key === entry.key);
3361
+ return {
3362
+ file: entry.file,
3363
+ exportName: entry.exportName,
3364
+ contractName: contract?.contractName ?? entry.exportName,
3365
+ key: entry.key,
3366
+ expiresAt: entry.expiresAt,
3367
+ daysRemaining: entry.daysRemaining,
3368
+ expired: entry.daysRemaining < 0,
3369
+ refreshInstructions: variable?.refreshInstructions,
3370
+ owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
3371
+ };
3372
+ });
3373
+ },
3374
+ expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
3375
+ };
3376
+ }
3398
3377
 
3399
3378
  // src/build/docs.ts
3400
3379
  function parseIsoDate(value) {
3401
3380
  const date = new Date(value);
3402
3381
  return Number.isNaN(date.getTime()) ? void 0 : date;
3403
3382
  }
3383
+ function parseExpiry(expiresAt) {
3384
+ const raw = String(expiresAt);
3385
+ const date = parseIsoDate(raw);
3386
+ return date && { raw, date };
3387
+ }
3404
3388
  var MS_PER_DAY = 864e5;
3405
3389
  function daysRemainingFrom(date, now) {
3406
3390
  return Math.ceil((date.getTime() - now.getTime()) / MS_PER_DAY);
@@ -3408,32 +3392,29 @@ function daysRemainingFrom(date, now) {
3408
3392
  function computeExpiringEntries(contracts, expiringWithinDays, now) {
3409
3393
  const entries = [];
3410
3394
  for (const contract of contracts) {
3411
- if (contract.expiresAt) {
3412
- const date = parseIsoDate(contract.expiresAt);
3413
- if (date) {
3414
- const daysRemaining = daysRemainingFrom(date, now);
3415
- if (daysRemaining <= expiringWithinDays) {
3416
- entries.push({
3417
- file: contract.file,
3418
- exportName: contract.exportName,
3419
- key: void 0,
3420
- expiresAt: contract.expiresAt,
3421
- daysRemaining
3422
- });
3423
- }
3395
+ const contractExpiry = parseExpiry(contract.expiresAt);
3396
+ if (contractExpiry) {
3397
+ const daysRemaining = daysRemainingFrom(contractExpiry.date, now);
3398
+ if (daysRemaining <= expiringWithinDays) {
3399
+ entries.push({
3400
+ file: contract.file,
3401
+ exportName: contract.exportName,
3402
+ key: void 0,
3403
+ expiresAt: contractExpiry.raw,
3404
+ daysRemaining
3405
+ });
3424
3406
  }
3425
3407
  }
3426
3408
  for (const variable of contract.variables) {
3427
- if (!variable.expiresAt) continue;
3428
- const date = parseIsoDate(variable.expiresAt);
3429
- if (!date) continue;
3430
- const daysRemaining = daysRemainingFrom(date, now);
3409
+ const expiry = parseExpiry(variable.expiresAt);
3410
+ if (!expiry) continue;
3411
+ const daysRemaining = daysRemainingFrom(expiry.date, now);
3431
3412
  if (daysRemaining <= expiringWithinDays) {
3432
3413
  entries.push({
3433
3414
  file: contract.file,
3434
3415
  exportName: contract.exportName,
3435
3416
  key: variable.key,
3436
- expiresAt: variable.expiresAt,
3417
+ expiresAt: expiry.raw,
3437
3418
  daysRemaining
3438
3419
  });
3439
3420
  }
@@ -3484,7 +3465,7 @@ function buildCatalog(contracts) {
3484
3465
  function extractPreviouslyDocumentedKeys(previousContent) {
3485
3466
  const keys = /* @__PURE__ */ new Set();
3486
3467
  for (const match of previousContent.matchAll(/^### `([A-Za-z_][A-Za-z0-9_]*)`$/gm)) {
3487
- if (match[1]) keys.add(match[1]);
3468
+ keys.add(String(match[1]));
3488
3469
  }
3489
3470
  return keys;
3490
3471
  }
@@ -3524,7 +3505,7 @@ function computeChangeSummary(contracts, previousContent) {
3524
3505
  };
3525
3506
  }
3526
3507
  function slugify(text) {
3527
- return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(/^-+|-+$/g, "") || "section";
3508
+ return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(/^-|-$/g, "") || "section";
3528
3509
  }
3529
3510
  var AnchorRegistry = class {
3530
3511
  constructor() {
@@ -3541,16 +3522,24 @@ var AnchorRegistry = class {
3541
3522
  this.assigned.set(target, anchor);
3542
3523
  return anchor;
3543
3524
  }
3525
+ /** The anchor an earlier {@link anchorFor} call assigned to `target`; throws if there was none. */
3526
+ anchorOf(target) {
3527
+ return mustGet(this.assigned, target);
3528
+ }
3544
3529
  };
3545
3530
  function mdLink(text, anchor) {
3546
3531
  return `[${text}](#${anchor})`;
3547
3532
  }
3533
+ function sortedByKey(items) {
3534
+ const byKey = new Map(items.map((item) => [item.key, item]));
3535
+ return [...byKey.keys()].sort().map((key) => mustGet(byKey, key));
3536
+ }
3548
3537
  function sortedContracts(contracts) {
3549
3538
  return [...contracts].sort((a, b) => a.contractName.localeCompare(b.contractName));
3550
3539
  }
3551
3540
  function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates, hasLifecycle) {
3552
3541
  const lines = [
3553
- generatedBanner("markdown"),
3542
+ generatedBanner("markdown", reportRegenerateHint()),
3554
3543
  "",
3555
3544
  `> ${evidenceDisclaimer()}`,
3556
3545
  "",
@@ -3558,7 +3547,7 @@ function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates,
3558
3547
  "",
3559
3548
  "# Environment Variables",
3560
3549
  "",
3561
- "_Produced by `env-cap --docs`._",
3550
+ "_Produced by `generateDocumentation()` from `@maverickcer/env-cap/build`._",
3562
3551
  "",
3563
3552
  `_Generated ${options.generatedAt.toISOString()}_`,
3564
3553
  ""
@@ -3601,7 +3590,7 @@ function renderCatalog(contracts, anchors, undocumented) {
3601
3590
  );
3602
3591
  }
3603
3592
  for (const contract of sortedContracts(contracts)) {
3604
- lines.push(`<a id="${anchors.anchorFor(contract, `contract-${contract.contractName}`)}"></a>`);
3593
+ lines.push(`<a id="${anchors.anchorOf(contract)}"></a>`);
3605
3594
  lines.push(`## ${contract.contractName}`, "", `Source: \`${contract.file}\``);
3606
3595
  if (undocumentedByIdentity.has(`${contract.file}#${contract.exportName}`)) {
3607
3596
  lines.push("", "> \u26A0\uFE0F **Undocumented.** No `documentEnv()` call is linked to this contract.");
@@ -3626,10 +3615,8 @@ function renderCatalog(contracts, anchors, undocumented) {
3626
3615
  }
3627
3616
  }
3628
3617
  lines.push("");
3629
- for (const variable of [...contract.variables].sort((a, b) => a.key < b.key ? -1 : 1)) {
3630
- lines.push(
3631
- `<a id="${anchors.anchorFor(variable, `${contract.contractName}-${variable.key}`)}"></a>`
3632
- );
3618
+ for (const variable of sortedByKey(contract.variables)) {
3619
+ lines.push(`<a id="${anchors.anchorOf(variable)}"></a>`);
3633
3620
  lines.push(`### \`${variable.key}\``, "");
3634
3621
  if (variable.description) lines.push(variable.description, "");
3635
3622
  if (!variable.documented) lines.push("> \u26A0\uFE0F **Undocumented.**", "");
@@ -3742,18 +3729,17 @@ function renderLifecycleReport(contracts, anchors, expiringWithinDays, now) {
3742
3729
  const owner = effectiveOwner(contract, variable);
3743
3730
  if (variable.expiresAt === void 0 && owner === void 0 && variable.refreshInstructions === void 0)
3744
3731
  continue;
3745
- const expiresAt = variable.expiresAt;
3746
- const expiry = expiresAt ? parseIsoDate(expiresAt) : void 0;
3747
- let expiresCell = expiresAt ?? "--";
3748
- if (expiry && expiresAt) {
3749
- const daysRemaining = daysRemainingFrom(expiry, now);
3732
+ const expiry = parseExpiry(variable.expiresAt);
3733
+ let expiresCell = variable.expiresAt ?? "--";
3734
+ if (expiry) {
3735
+ const daysRemaining = daysRemainingFrom(expiry.date, now);
3750
3736
  if (daysRemaining < 0)
3751
- expiresCell = `${expiresAt} (**expired ${Math.abs(daysRemaining)}d ago**)`;
3737
+ expiresCell = `${expiry.raw} (**expired ${Math.abs(daysRemaining)}d ago**)`;
3752
3738
  else if (daysRemaining <= expiringWithinDays)
3753
- expiresCell = `${expiresAt} (**${daysRemaining}d remaining**)`;
3739
+ expiresCell = `${expiry.raw} (**${daysRemaining}d remaining**)`;
3754
3740
  }
3755
3741
  rows.push(
3756
- `| ${mdLink(`\`${variable.key}\``, anchors.anchorFor(variable, `${contract.contractName}-${variable.key}`))} | ${owner ?? "--"} | ${expiresCell} | ${variable.refreshInstructions ?? "--"} |`
3742
+ `| ${mdLink(`\`${variable.key}\``, anchors.anchorOf(variable))} | ${owner ?? "--"} | ${expiresCell} | ${variable.refreshInstructions ?? "--"} |`
3757
3743
  );
3758
3744
  }
3759
3745
  }
@@ -3869,7 +3855,14 @@ function renderDocs(contracts, options) {
3869
3855
  );
3870
3856
  const catalog = renderCatalog(sorted, anchors, options.undocumentedContracts);
3871
3857
  const security = renderSecurityReview(sorted, options, options.generatedAt);
3872
- return [...header, ...catalog, ...ownership, ...dependencyLines, ...lifecycleLines, ...security].join("\n").replace(/\n{3,}/g, "\n\n");
3858
+ return [
3859
+ ...header,
3860
+ ...catalog,
3861
+ ...ownership,
3862
+ ...dependencyLines,
3863
+ ...lifecycleLines,
3864
+ ...security
3865
+ ].join("\n");
3873
3866
  }
3874
3867
  function normalizeDocsForComparison(content) {
3875
3868
  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");
@@ -3908,9 +3901,9 @@ function groupByKey(contracts) {
3908
3901
  const byKey = /* @__PURE__ */ new Map();
3909
3902
  for (const contract of contracts) {
3910
3903
  for (const variable of contract.variables) {
3911
- const list = byKey.get(variable.key) ?? [];
3912
- list.push({ contract, variable });
3913
- byKey.set(variable.key, list);
3904
+ const existing = byKey.get(variable.key);
3905
+ if (existing === void 0) byKey.set(variable.key, [{ contract, variable }]);
3906
+ else existing.push({ contract, variable });
3914
3907
  }
3915
3908
  }
3916
3909
  return byKey;
@@ -3918,7 +3911,6 @@ function groupByKey(contracts) {
3918
3911
  function renderEnvExample(contracts, reconciliationHeader = []) {
3919
3912
  const sorted = [...contracts].sort((a, b) => a.file.localeCompare(b.file));
3920
3913
  const active = sorted.filter((c) => c.active);
3921
- const inactive = sorted.filter((c) => !c.active);
3922
3914
  const lines = [
3923
3915
  "# AUTO-GENERATED EXAMPLE FILE.",
3924
3916
  "# Copy to .env and fill in real values. Do not commit .env."
@@ -3930,12 +3922,11 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
3930
3922
  "# still written to this file regardless of its context."
3931
3923
  );
3932
3924
  }
3933
- if (reconciliationHeader.length > 0) lines.push(...reconciliationHeader);
3925
+ lines.push(...reconciliationHeader);
3934
3926
  lines.push("");
3935
3927
  const activeByKey = groupByKey(active);
3936
3928
  for (const key of [...activeByKey.keys()].sort()) {
3937
3929
  const [first, ...rest] = mustGet(activeByKey, key);
3938
- if (first === void 0) continue;
3939
3930
  lines.push(...renderVariableLines(first.variable));
3940
3931
  for (const dup of rest) {
3941
3932
  lines.push(
@@ -3946,11 +3937,10 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
3946
3937
  );
3947
3938
  }
3948
3939
  }
3949
- const inactiveByKey = groupByKey(inactive);
3940
+ const inactiveByKey = groupByKey(sorted);
3950
3941
  for (const key of [...inactiveByKey.keys()].sort()) {
3951
3942
  if (activeByKey.has(key)) continue;
3952
3943
  const [first] = mustGet(inactiveByKey, key);
3953
- if (first === void 0) continue;
3954
3944
  lines.push(
3955
3945
  ...renderVariableLines(first.variable, {
3956
3946
  commented: true,
@@ -3958,13 +3948,12 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
3958
3948
  })
3959
3949
  );
3960
3950
  }
3961
- return lines.join("\n").replace(/\n+$/, "\n");
3951
+ return lines.join("\n");
3962
3952
  }
3963
3953
  function extractDeclaredVariables(source) {
3964
3954
  const names = [];
3965
3955
  for (const line of source.split("\n")) {
3966
3956
  const trimmed = line.trim();
3967
- if (!trimmed || trimmed.startsWith("#")) continue;
3968
3957
  const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
3969
3958
  if (match?.[1]) names.push(match[1]);
3970
3959
  }
@@ -3974,9 +3963,7 @@ function extractCommentedVariables(source) {
3974
3963
  const names = [];
3975
3964
  for (const line of source.split("\n")) {
3976
3965
  const trimmed = line.trim();
3977
- if (!trimmed.startsWith("#")) continue;
3978
- const withoutHash = trimmed.replace(/^#+\s*/, "");
3979
- const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(withoutHash);
3966
+ const match = /^#+\s*([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
3980
3967
  if (match?.[1]) names.push(match[1]);
3981
3968
  }
3982
3969
  return names;
@@ -4058,7 +4045,7 @@ function collectVariableNames(contracts) {
4058
4045
  }
4059
4046
  function overrideVariable(variable, overrides) {
4060
4047
  const override = overrides[variable.key];
4061
- const date = override === void 0 ? void 0 : parseIsoDate(override);
4048
+ const date = parseIsoDate(String(override));
4062
4049
  return {
4063
4050
  ...variable,
4064
4051
  expiresAt: date ? override : variable.expiresAt,
@@ -4080,16 +4067,14 @@ async function resolveLiveExpirationDates(contracts, liveExpirationDates) {
4080
4067
 
4081
4068
  // src/build/generate-documentation.ts
4082
4069
  var DEFAULT_EXPIRING_WITHIN_DAYS = 30;
4083
- var STANDARD_SENSITIVITY_LEVELS = /* @__PURE__ */ new Set([
4084
- "secret",
4085
- "credential",
4086
- "pii",
4087
- "config"
4088
- ]);
4070
+ function standardSensitivityLevels() {
4071
+ return ["secret", "credential", "pii", "config"];
4072
+ }
4073
+ var STANDARD_SENSITIVITY_LEVELS = new Set(standardSensitivityLevels());
4089
4074
  function findNonstandardSensitivityLevels(contracts) {
4090
4075
  const entries = [];
4091
4076
  for (const contract of contracts) {
4092
- if (contract.sensitivity !== void 0 && !STANDARD_SENSITIVITY_LEVELS.has(contract.sensitivity))
4077
+ if (contract.sensitivity !== void 0 && !standardSensitivityLevels().includes(contract.sensitivity))
4093
4078
  entries.push({
4094
4079
  file: contract.file,
4095
4080
  exportName: contract.exportName,
@@ -4098,7 +4083,7 @@ function findNonstandardSensitivityLevels(contracts) {
4098
4083
  });
4099
4084
  for (const variable of [...contract.variables].sort((a, b) => a.key.localeCompare(b.key))) {
4100
4085
  if (variable.sensitivity === void 0) continue;
4101
- if (STANDARD_SENSITIVITY_LEVELS.has(variable.sensitivity)) continue;
4086
+ if (standardSensitivityLevels().includes(variable.sensitivity)) continue;
4102
4087
  entries.push({
4103
4088
  file: contract.file,
4104
4089
  exportName: contract.exportName,
@@ -4139,36 +4124,20 @@ async function writeDocumentation(docsPath, envExamplePath, root, contracts, con
4139
4124
  undocumentedContracts: documentation.undocumentedContracts.map(
4140
4125
  (ref) => relativizeRef(root, ref)
4141
4126
  ),
4142
- // `RenderDocsOptions.undocumentedVariables` is consumed by `renderDocs()`
4143
- // ONLY via `.length` (the security-review counter) -- never by content
4144
- // or identity, unlike its `undocumentedContracts` sibling above (matched
4145
- // by identity against the catalog for the "Undocumented." marker).
4146
- // `.map()` always preserves length regardless of what each element
4147
- // transforms to, so this specific `relativizeRef()` call's own output is
4148
- // unobservable through this call site. Hand-verified: mapping every
4149
- // entry to `undefined` instead and running the full `vitest run` leaves
4150
- // all tests passing.
4151
- // Stryker disable next-line ArrowFunction
4152
- undocumentedVariables: documentation.undocumentedVariables.map(
4153
- (ref) => relativizeRef(root, ref)
4154
- ),
4127
+ undocumentedVariables: documentation.undocumentedVariables,
4155
4128
  generatedAt,
4156
4129
  previousContent
4157
4130
  });
4158
4131
  await fs.mkdir(path6__default.default.dirname(docsPath), { recursive: true });
4159
4132
  await fs.writeFile(docsPath, docsSource, "utf8");
4160
4133
  const envExample = envExamplePath ? (
4161
- // exactOptionalPropertyTypes: omit the key rather than set it to
4162
- // `undefined` when the caller didn't supply one. writeEnvExample
4163
- // itself does `options.onExisting ?? "keep-sibling"`, so passing
4164
- // `onExisting: undefined` explicitly (what always-spreading here
4165
- // would do) is behaviorally identical to omitting the key.
4166
- // Hand-verified: forcing this guard to `true` and running the real
4167
- // suite passes unchanged.
4168
- await writeEnvExample(contracts, envExamplePath, fs, {
4169
- // Stryker disable next-line ConditionalExpression
4170
- ...envExampleOnExisting === void 0 ? {} : { onExisting: envExampleOnExisting }
4171
- })
4134
+ // `exactOptionalPropertyTypes` rejects an explicit `undefined`, so the key is omitted when unset.
4135
+ await writeEnvExample(
4136
+ contracts,
4137
+ envExamplePath,
4138
+ fs,
4139
+ envExampleOnExisting && { onExisting: envExampleOnExisting }
4140
+ )
4172
4141
  ) : void 0;
4173
4142
  return { envExample };
4174
4143
  }
@@ -4176,7 +4145,6 @@ async function generateDocumentation(options) {
4176
4145
  const root = path6__default.default.resolve(options.root ?? process.cwd());
4177
4146
  const include = options.include ?? defaultInclude();
4178
4147
  const exclude = options.exclude ?? defaultExclude();
4179
- const packages = options.packages ?? [];
4180
4148
  const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
4181
4149
  const docsLocationResult = resolveWithinRoot(
4182
4150
  root,
@@ -4202,7 +4170,7 @@ async function generateDocumentation(options) {
4202
4170
  root,
4203
4171
  include,
4204
4172
  exclude,
4205
- packages,
4173
+ packages: options.packages,
4206
4174
  tsconfig: options.tsconfig
4207
4175
  });
4208
4176
  const docsContracts = await resolveLiveExpirationDates(
@@ -4256,7 +4224,7 @@ function parseRotationPeriodDays(value) {
4256
4224
  if (plain) {
4257
4225
  const amount = Number(plain[1]);
4258
4226
  if (amount > 0) {
4259
- const unit = (plain[2] ?? "").toLowerCase();
4227
+ const unit = String(plain[2]).toLowerCase();
4260
4228
  switch (unit) {
4261
4229
  case "day":
4262
4230
  case "days":
@@ -4289,18 +4257,14 @@ function parseRotationPeriodDays(value) {
4289
4257
  }
4290
4258
  function computeRotationStatus(variable, now) {
4291
4259
  if (!hasRotationData(variable)) return "undeclared";
4292
- if (variable.expiresAt !== void 0) {
4293
- const expiry = parseIsoDate(variable.expiresAt);
4294
- if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
4295
- }
4260
+ const expiry = parseIsoDate(String(variable.expiresAt));
4261
+ if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
4296
4262
  if (variable.rotationPeriod !== void 0) {
4297
- if (variable.lastRotatedAt !== void 0) {
4298
- const lastRotated = parseIsoDate(variable.lastRotatedAt);
4299
- const periodDays = parseRotationPeriodDays(variable.rotationPeriod);
4300
- if (lastRotated !== void 0 && lastRotated.getTime() <= now.getTime() && periodDays !== void 0) {
4301
- const dueDate = lastRotated.getTime() + periodDays * MS_PER_DAY2;
4302
- return dueDate < now.getTime() ? "overdue" : "compliant";
4303
- }
4263
+ const lastRotated = parseIsoDate(String(variable.lastRotatedAt));
4264
+ const periodDays = parseRotationPeriodDays(variable.rotationPeriod);
4265
+ if (lastRotated !== void 0 && lastRotated.getTime() <= now.getTime() && periodDays !== void 0) {
4266
+ const dueDate = lastRotated.getTime() + periodDays * MS_PER_DAY2;
4267
+ return dueDate < now.getTime() ? "overdue" : "compliant";
4304
4268
  }
4305
4269
  return "overdue";
4306
4270
  }
@@ -4382,7 +4346,7 @@ function buildOwnershipModel(contracts, root) {
4382
4346
 
4383
4347
  // src/build/tool-version.ts
4384
4348
  function readToolVersion() {
4385
- return "0.5.3";
4349
+ return "0.6.0";
4386
4350
  }
4387
4351
 
4388
4352
  // src/build/generate-evidence.ts
@@ -4390,7 +4354,6 @@ async function generateEvidenceModel(options) {
4390
4354
  const root = path6__default.default.resolve(options.root ?? process.cwd());
4391
4355
  const include = options.include ?? defaultInclude();
4392
4356
  const exclude = options.exclude ?? defaultExclude();
4393
- const packages = options.packages ?? [];
4394
4357
  const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
4395
4358
  let snapshotPath;
4396
4359
  if (options.previousSnapshotLocation !== void 0) {
@@ -4408,10 +4371,10 @@ async function generateEvidenceModel(options) {
4408
4371
  root,
4409
4372
  include,
4410
4373
  exclude,
4411
- packages,
4374
+ packages: options.packages,
4412
4375
  tsconfig: options.tsconfig
4413
4376
  });
4414
- const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = assembled;
4377
+ const { readFileCached, linkResult, context, origins } = assembled;
4415
4378
  const generatedAt = /* @__PURE__ */ new Date();
4416
4379
  const activeContracts = linkResult.contracts.filter((c) => c.active);
4417
4380
  const lifecycleContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
@@ -4465,8 +4428,6 @@ async function generateEvidenceModel(options) {
4465
4428
  scanFiles,
4466
4429
  readFileCached,
4467
4430
  context,
4468
- // Stryker disable next-line ArrayDeclaration
4469
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
4470
4431
  scannedSurfaces,
4471
4432
  evidenceChanges?.dynamicAccessAcknowledgments
4472
4433
  );
@@ -4479,12 +4440,7 @@ async function generateEvidenceModel(options) {
4479
4440
  unresolvedConsumers: usageComputed.result.unresolvedConsumers,
4480
4441
  unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
4481
4442
  indeterminateOwnership: usageComputed.result.indeterminate,
4482
- // `buildFindingModel` (finding-model.ts) has its own `?? []` fallback
4483
- // on this exact same field, so even an `undefined` that slipped past
4484
- // this one (e.g. `??`-vs-`&&` on `evidenceChanges?.…`) is caught there
4485
- // identically -- belt-and-suspenders, not independently observable.
4486
- // Stryker disable next-line LogicalOperator
4487
- dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems ?? []
4443
+ dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
4488
4444
  });
4489
4445
  const commit = options.commit ? await options.commit() : void 0;
4490
4446
  return deepFreeze({
@@ -4540,7 +4496,6 @@ async function getEvidenceModel(options) {
4540
4496
  const root = path6__default.default.resolve(options.root ?? process.cwd());
4541
4497
  const include = options.include ?? defaultInclude();
4542
4498
  const exclude = options.exclude ?? defaultExclude();
4543
- const packages = options.packages ?? [];
4544
4499
  const evidencePath = path6__default.default.resolve(root, options.location);
4545
4500
  const fingerprintPath = fingerprintPathFor(evidencePath);
4546
4501
  const recompute = async (missReason) => ({
@@ -4555,7 +4510,7 @@ async function getEvidenceModel(options) {
4555
4510
  root,
4556
4511
  include,
4557
4512
  exclude,
4558
- packages
4513
+ packages: options.packages
4559
4514
  });
4560
4515
  } catch (error) {
4561
4516
  return recompute(
@@ -4603,91 +4558,61 @@ function findingFiles(finding) {
4603
4558
  if (location.model === "change") return [location.path];
4604
4559
  return location.file === void 0 ? [] : [location.file];
4605
4560
  }
4561
+ function requestedPass(option) {
4562
+ return option === false ? void 0 : option;
4563
+ }
4606
4564
  async function computeArtifacts(options) {
4607
4565
  const root = path6__default.default.resolve(options.root ?? process.cwd());
4608
4566
  const include = options.include ?? defaultInclude();
4609
4567
  const exclude = options.exclude ?? defaultExclude();
4610
- const packages = options.packages ?? [];
4611
- const manifestOptions = options.manifest === false ? void 0 : options.manifest;
4612
- const docsOptions = options.docs === false ? void 0 : options.docs;
4613
- const usageOptions = options.usage === false ? void 0 : options.usage;
4614
- const evidenceOptions = options.evidence === false ? void 0 : options.evidence;
4568
+ const manifestOptions = requestedPass(options.manifest);
4569
+ const docsOptions = requestedPass(options.docs);
4570
+ const usageOptions = requestedPass(options.usage);
4571
+ const evidenceOptions = requestedPass(options.evidence);
4615
4572
  const pathIssues = [];
4616
- let manifestOutputPath;
4617
- if (manifestOptions) {
4618
- const result = resolveWithinRoot(
4619
- root,
4620
- manifestOptions.location,
4621
- "manifest.location",
4622
- "generateEnvArtifacts"
4623
- );
4624
- if (result.ok) manifestOutputPath = result.resolved;
4625
- else pathIssues.push(result.issue);
4626
- }
4627
- let docsPath;
4628
- let envExamplePath;
4629
- if (docsOptions) {
4630
- const result = resolveWithinRoot(
4631
- root,
4632
- docsOptions.location,
4633
- "docs.location",
4634
- "generateEnvArtifacts"
4635
- );
4636
- if (result.ok) docsPath = result.resolved;
4637
- else pathIssues.push(result.issue);
4638
- if (docsOptions.envExample) {
4639
- const exampleResult = resolveWithinRoot(
4640
- root,
4641
- docsOptions.envExample.location,
4642
- "docs.envExample.location",
4643
- "generateEnvArtifacts"
4644
- );
4645
- if (exampleResult.ok) envExamplePath = exampleResult.resolved;
4646
- else pathIssues.push(exampleResult.issue);
4647
- }
4648
- }
4649
- let usageReportPath;
4650
- if (usageOptions?.report) {
4651
- const result = resolveWithinRoot(
4652
- root,
4653
- usageOptions.report.location,
4654
- "usage.report.location",
4655
- "generateEnvArtifacts"
4656
- );
4657
- if (result.ok) usageReportPath = result.resolved;
4658
- else pathIssues.push(result.issue);
4659
- }
4660
- let evidencePath;
4661
- if (evidenceOptions) {
4662
- const result = resolveWithinRoot(
4663
- root,
4664
- evidenceOptions.location,
4665
- "evidence.location",
4666
- "generateEnvArtifacts"
4667
- );
4668
- if (result.ok) evidencePath = result.resolved;
4669
- else pathIssues.push(result.issue);
4670
- }
4573
+ const resolveOutput = (location, label) => {
4574
+ const result = resolveWithinRoot(root, location, label, "generateEnvArtifacts");
4575
+ if (result.ok) return result.resolved;
4576
+ pathIssues.push(result.issue);
4577
+ return location;
4578
+ };
4579
+ const manifestTarget = manifestOptions && {
4580
+ options: manifestOptions,
4581
+ outputPath: resolveOutput(manifestOptions.location, "manifest.location")
4582
+ };
4583
+ const docsTarget = docsOptions && {
4584
+ options: docsOptions,
4585
+ path: resolveOutput(docsOptions.location, "docs.location"),
4586
+ envExamplePath: docsOptions.envExample ? resolveOutput(docsOptions.envExample.location, "docs.envExample.location") : void 0
4587
+ };
4588
+ const usageTarget = usageOptions && {
4589
+ options: usageOptions,
4590
+ reportPath: usageOptions.report ? resolveOutput(usageOptions.report.location, "usage.report.location") : void 0
4591
+ };
4592
+ const evidencePath = evidenceOptions ? resolveOutput(evidenceOptions.location, "evidence.location") : void 0;
4671
4593
  if (pathIssues.length > 0) throw new EnvProjectGenerationError(pathIssues);
4672
4594
  const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
4673
4595
  fs: options.fs,
4674
4596
  root,
4675
4597
  include,
4676
4598
  exclude,
4677
- packages,
4599
+ packages: options.packages,
4678
4600
  tsconfig: options.tsconfig
4679
4601
  });
4680
4602
  const generatedAt = /* @__PURE__ */ new Date();
4681
4603
  const activeContracts = linkResult.contracts.filter((c) => c.active);
4682
4604
  const liveExpirationContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
4683
- const docsContracts = docsOptions ? liveExpirationContracts : linkResult.contracts;
4605
+ const docsContracts = docsTarget ? liveExpirationContracts : linkResult.contracts;
4684
4606
  const blocking = [];
4685
- const manifestComputed = manifestOptions ? computeManifest(root, linkResult, manifestOptions.onIncompatibility ?? "warn") : void 0;
4686
- if (manifestComputed) blocking.push(...manifestComputed.blocking);
4607
+ const manifest = manifestTarget && {
4608
+ ...manifestTarget,
4609
+ computed: computeManifest(root, linkResult, manifestTarget.options.onIncompatibility)
4610
+ };
4611
+ if (manifest) blocking.push(...manifest.computed.blocking);
4687
4612
  const docsComputed = computeDocumentation(
4688
4613
  root,
4689
4614
  { ...linkResult, contracts: liveExpirationContracts },
4690
- docsOptions?.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4615
+ docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4691
4616
  generatedAt
4692
4617
  );
4693
4618
  const { scanFiles, scannedSurfaces } = await computeScanSurface(
@@ -4711,14 +4636,13 @@ async function computeArtifacts(options) {
4711
4636
  scanFiles,
4712
4637
  readFileCached,
4713
4638
  context,
4714
- [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
4715
4639
  scannedSurfaces,
4716
4640
  evidenceChanges?.dynamicAccessAcknowledgments
4717
4641
  );
4718
4642
  const ownership = buildOwnershipModel(linkResult.contracts, root);
4719
4643
  const lifecycle = buildLifecycleModel(
4720
4644
  liveExpirationContracts,
4721
- docsOptions?.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4645
+ docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4722
4646
  generatedAt,
4723
4647
  root
4724
4648
  );
@@ -4755,7 +4679,7 @@ async function computeArtifacts(options) {
4755
4679
  unresolvedConsumers: usageComputed.result.unresolvedConsumers,
4756
4680
  unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
4757
4681
  indeterminateOwnership: usageComputed.result.indeterminate,
4758
- dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems ?? []
4682
+ dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
4759
4683
  });
4760
4684
  if (options.onUndocumented === "throw")
4761
4685
  blocking.push(...escalatedFindings(finding.findings, "documentation"));
@@ -4777,16 +4701,11 @@ async function computeArtifacts(options) {
4777
4701
  });
4778
4702
  return {
4779
4703
  root,
4780
- manifestOptions,
4781
- manifestOutputPath,
4782
- manifestComputed,
4783
- docsOptions,
4784
- docsPath,
4785
- envExamplePath,
4704
+ manifest,
4705
+ docs: docsTarget,
4786
4706
  docsComputed,
4787
4707
  docsContracts,
4788
- usageOptions,
4789
- usageReportPath,
4708
+ usage: usageTarget,
4790
4709
  usageComputed,
4791
4710
  evidencePath,
4792
4711
  evidence,
@@ -4799,16 +4718,11 @@ async function computeArtifacts(options) {
4799
4718
  async function generateEnvArtifacts(options) {
4800
4719
  const computed = await computeArtifacts(options);
4801
4720
  const {
4802
- manifestOptions,
4803
- manifestOutputPath,
4804
- manifestComputed,
4805
- docsOptions,
4806
- docsPath,
4807
- envExamplePath,
4721
+ manifest,
4722
+ docs,
4808
4723
  docsComputed,
4809
4724
  docsContracts,
4810
- usageOptions,
4811
- usageReportPath,
4725
+ usage,
4812
4726
  usageComputed,
4813
4727
  evidencePath,
4814
4728
  evidence,
@@ -4819,43 +4733,47 @@ async function generateEnvArtifacts(options) {
4819
4733
  generatedAt
4820
4734
  } = computed;
4821
4735
  if (blocking.length > 0) throw new EnvProjectGenerationError(blocking);
4736
+ const parseWarnings = [...packageWarnings, ...linkWarnings];
4822
4737
  let manifestResult;
4823
- if (manifestOptions && manifestComputed && manifestOutputPath) {
4824
- await writeManifest(manifestOutputPath, manifestComputed.activeContracts, options.fs);
4738
+ if (manifest) {
4739
+ await writeManifest(manifest.outputPath, manifest.computed.activeContracts, options.fs);
4825
4740
  manifestResult = {
4826
- outputPath: manifestOutputPath,
4827
- contracts: manifestComputed.contractSummaries,
4828
- warnings: manifestComputed.warnings,
4829
- parseWarnings: [...packageWarnings, ...linkWarnings]
4741
+ outputPath: manifest.outputPath,
4742
+ contracts: manifest.computed.contractSummaries,
4743
+ warnings: manifest.computed.warnings,
4744
+ parseWarnings
4830
4745
  };
4831
4746
  }
4832
4747
  let docsResult;
4833
- if (docsOptions && docsPath) {
4748
+ if (docs) {
4834
4749
  const { envExample } = await writeDocumentation(
4835
- docsPath,
4836
- envExamplePath,
4750
+ docs.path,
4751
+ docs.envExamplePath,
4837
4752
  root,
4838
4753
  docsContracts,
4839
4754
  docsComputed.contractModelContracts,
4840
4755
  docsComputed.documentation,
4841
- docsOptions.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4756
+ docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4842
4757
  generatedAt,
4843
4758
  options.fs,
4844
- docsOptions.envExample?.onExisting
4759
+ docs.options.envExample?.onExisting
4845
4760
  );
4846
4761
  docsResult = {
4847
- docsPath,
4762
+ docsPath: docs.path,
4848
4763
  envExample,
4849
4764
  contracts: docsComputed.contractSummaries,
4850
4765
  catalog: docsComputed.catalog,
4851
- parseWarnings: [...packageWarnings, ...linkWarnings],
4766
+ parseWarnings,
4852
4767
  documentation: docsComputed.documentation
4853
4768
  };
4854
4769
  }
4855
4770
  let usageResult;
4856
- if (usageOptions) {
4857
- if (usageReportPath) await writeUsageReport(usageReportPath, usageComputed.result, options.fs);
4858
- usageResult = { reportPath: usageReportPath, ...usageComputed.result };
4771
+ if (usage) {
4772
+ const usageReport = { ...usageComputed.result, parseWarnings };
4773
+ if (usage.reportPath !== void 0) {
4774
+ await writeUsageReport(usage.reportPath, usageReport, options.fs);
4775
+ }
4776
+ usageResult = { reportPath: usage.reportPath, ...usageReport };
4859
4777
  }
4860
4778
  if (evidencePath) {
4861
4779
  await writeEvidenceSnapshot(evidencePath, evidence, options.fs);
@@ -4864,7 +4782,7 @@ async function generateEnvArtifacts(options) {
4864
4782
  root,
4865
4783
  include: options.include ?? defaultInclude(),
4866
4784
  exclude: options.exclude ?? defaultExclude(),
4867
- packages: options.packages ?? []
4785
+ packages: options.packages
4868
4786
  });
4869
4787
  await writeEvidenceFingerprint(evidencePath, fingerprint, options.fs);
4870
4788
  }
@@ -4872,12 +4790,8 @@ async function generateEnvArtifacts(options) {
4872
4790
  }
4873
4791
 
4874
4792
  // src/build/check-artifacts.ts
4875
- async function readIfExists(filePath, fs) {
4876
- try {
4877
- return await fs.readFile(filePath, "utf8");
4878
- } catch {
4879
- return void 0;
4880
- }
4793
+ function readIfExists(filePath, fs) {
4794
+ return fs.readFile(filePath, "utf8").catch(() => void 0);
4881
4795
  }
4882
4796
  function normalizeEvidenceJsonForComparison(text) {
4883
4797
  try {
@@ -4903,46 +4817,38 @@ async function checkEnvArtifacts(options) {
4903
4817
  const c = await computeArtifacts(options);
4904
4818
  if (c.blocking.length > 0) throw new EnvProjectGenerationError(c.blocking);
4905
4819
  const findings = [];
4906
- if (c.manifestOptions && c.manifestComputed && c.manifestOutputPath) {
4907
- const expected = renderManifest(c.manifestComputed.activeContracts, c.manifestOutputPath);
4908
- findings.push(await compareTextArtifact("manifest", c.manifestOutputPath, expected, options.fs));
4820
+ if (c.manifest) {
4821
+ const expected = renderManifest(c.manifest.computed.activeContracts, c.manifest.outputPath);
4822
+ findings.push(
4823
+ await compareTextArtifact("manifest", c.manifest.outputPath, expected, options.fs)
4824
+ );
4909
4825
  }
4910
- if (c.docsOptions && c.docsPath) {
4911
- const previousContent = await readIfExists(c.docsPath, options.fs);
4826
+ if (c.docs) {
4827
+ const previousContent = await readIfExists(c.docs.path, options.fs);
4912
4828
  const expected = renderDocs(c.docsComputed.contractModelContracts, {
4913
- expiringWithinDays: c.docsOptions.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4829
+ expiringWithinDays: c.docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
4914
4830
  undocumentedContracts: c.docsComputed.documentation.undocumentedContracts.map(
4915
4831
  (ref) => relativizeRef(c.root, ref)
4916
4832
  ),
4917
- // `RenderDocsOptions.undocumentedVariables` is consumed by `renderDocs()`
4918
- // ONLY via `.length` (the security-review counter), never by content
4919
- // or identity -- same equivalence already established for
4920
- // `generate-documentation.ts`'s identical call site. Hand-verified:
4921
- // mapping every entry to `undefined` instead and running the full
4922
- // `vitest run` leaves every test passing.
4923
- // Stryker disable ArrowFunction
4924
- undocumentedVariables: c.docsComputed.documentation.undocumentedVariables.map(
4925
- (ref) => relativizeRef(c.root, ref)
4926
- ),
4927
- // Stryker restore ArrowFunction
4833
+ undocumentedVariables: c.docsComputed.documentation.undocumentedVariables,
4928
4834
  generatedAt: c.generatedAt,
4929
4835
  previousContent
4930
4836
  });
4931
4837
  findings.push(
4932
4838
  await compareTextArtifact(
4933
4839
  "docs",
4934
- c.docsPath,
4840
+ c.docs.path,
4935
4841
  expected,
4936
4842
  options.fs,
4937
4843
  normalizeDocsForComparison
4938
4844
  )
4939
4845
  );
4940
- if (c.docsOptions.envExample && c.envExamplePath) {
4941
- const existing = await readIfExists(c.envExamplePath, options.fs);
4846
+ if (c.docs.envExamplePath !== void 0) {
4847
+ const existing = await readIfExists(c.docs.envExamplePath, options.fs);
4942
4848
  if (existing === void 0) {
4943
4849
  findings.push({
4944
4850
  artifact: "envExample",
4945
- path: c.envExamplePath,
4851
+ path: c.docs.envExamplePath,
4946
4852
  status: "missing",
4947
4853
  detail: "not yet generated"
4948
4854
  });
@@ -4954,7 +4860,7 @@ async function checkEnvArtifacts(options) {
4954
4860
  const driftCount = staleVariables.length + variablesToComment.length + variablesToAdd.length;
4955
4861
  findings.push({
4956
4862
  artifact: "envExample",
4957
- path: c.envExamplePath,
4863
+ path: c.docs.envExamplePath,
4958
4864
  status: driftCount > 0 ? "stale" : "ok",
4959
4865
  // exactOptionalPropertyTypes: omit the key entirely rather than
4960
4866
  // set it to `undefined` -- `detail` is absent when there's
@@ -4966,9 +4872,12 @@ async function checkEnvArtifacts(options) {
4966
4872
  }
4967
4873
  }
4968
4874
  }
4969
- if (c.usageOptions && c.usageReportPath) {
4970
- const expected = renderUsageReport(c.usageComputed.result);
4971
- findings.push(await compareTextArtifact("usage", c.usageReportPath, expected, options.fs));
4875
+ if (c.usage?.reportPath !== void 0) {
4876
+ const expected = renderUsageReport({
4877
+ ...c.usageComputed.result,
4878
+ parseWarnings: [...c.packageWarnings, ...c.linkWarnings]
4879
+ });
4880
+ findings.push(await compareTextArtifact("usage", c.usage.reportPath, expected, options.fs));
4972
4881
  }
4973
4882
  if (c.evidencePath) {
4974
4883
  const expected = JSON.stringify(c.evidence, null, 2);
@@ -4993,7 +4902,7 @@ function sarifLocations(finding) {
4993
4902
  const location = finding.location;
4994
4903
  const uri = location.model === "change" ? location.path : location.file;
4995
4904
  if (uri === void 0) return void 0;
4996
- const position = location.model === "change" ? void 0 : location.position;
4905
+ const { position } = location;
4997
4906
  return [
4998
4907
  {
4999
4908
  physicalLocation: {