repopo 0.12.0 → 0.14.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 (345) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +57 -90
  3. package/THIRD-PARTY-LICENSES.txt +169 -11
  4. package/bin/dev.js +0 -0
  5. package/esm/adapters/fluidFramework.d.ts +13 -9
  6. package/esm/adapters/fluidFramework.d.ts.map +1 -1
  7. package/esm/adapters/fluidFramework.js +20 -43
  8. package/esm/adapters/fluidFramework.js.map +1 -1
  9. package/esm/api.d.ts +66 -1
  10. package/esm/api.d.ts.map +1 -1
  11. package/esm/api.js +18 -1
  12. package/esm/api.js.map +1 -1
  13. package/esm/baseCommand.d.ts.map +1 -1
  14. package/esm/baseCommand.js +2 -2
  15. package/esm/baseCommand.js.map +1 -1
  16. package/esm/commands/check-native.d.ts +5 -3
  17. package/esm/commands/check-native.d.ts.map +1 -1
  18. package/esm/commands/check-native.js +35 -7
  19. package/esm/commands/check-native.js.map +1 -1
  20. package/esm/commands/check.d.ts +8 -21
  21. package/esm/commands/check.d.ts.map +1 -1
  22. package/esm/commands/check.js +98 -154
  23. package/esm/commands/check.js.map +1 -1
  24. package/esm/commands/list.d.ts.map +1 -1
  25. package/esm/commands/list.js +1 -0
  26. package/esm/commands/list.js.map +1 -1
  27. package/esm/concurrency.d.ts +3 -0
  28. package/esm/concurrency.d.ts.map +1 -0
  29. package/esm/concurrency.js +8 -0
  30. package/esm/concurrency.js.map +1 -0
  31. package/esm/config.d.ts +10 -39
  32. package/esm/config.d.ts.map +1 -1
  33. package/esm/config.js +3 -7
  34. package/esm/config.js.map +1 -1
  35. package/esm/context.d.ts +10 -1
  36. package/esm/context.d.ts.map +1 -1
  37. package/esm/context.js +19 -1
  38. package/esm/context.js.map +1 -1
  39. package/esm/executionContractError.d.ts +4 -0
  40. package/esm/executionContractError.d.ts.map +1 -0
  41. package/esm/executionContractError.js +4 -0
  42. package/esm/executionContractError.js.map +1 -0
  43. package/esm/fileCache.d.ts +12 -0
  44. package/esm/fileCache.d.ts.map +1 -0
  45. package/esm/fileCache.js +37 -0
  46. package/esm/fileCache.js.map +1 -0
  47. package/esm/filePaths.d.ts +2 -0
  48. package/esm/filePaths.d.ts.map +1 -0
  49. package/esm/filePaths.js +9 -0
  50. package/esm/filePaths.js.map +1 -0
  51. package/esm/generators.d.ts +0 -20
  52. package/esm/generators.d.ts.map +1 -1
  53. package/esm/generators.js.map +1 -1
  54. package/esm/index.d.ts +3 -16
  55. package/esm/index.d.ts.map +1 -1
  56. package/esm/index.js +3 -17
  57. package/esm/index.js.map +1 -1
  58. package/esm/makePolicy.d.ts +20 -100
  59. package/esm/makePolicy.d.ts.map +1 -1
  60. package/esm/makePolicy.js +46 -132
  61. package/esm/makePolicy.js.map +1 -1
  62. package/esm/perf.d.ts +5 -2
  63. package/esm/perf.d.ts.map +1 -1
  64. package/esm/perf.js +10 -9
  65. package/esm/perf.js.map +1 -1
  66. package/esm/policies/CargoLicenceValidated.d.ts +4 -4
  67. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -1
  68. package/esm/policies/CargoLicenceValidated.js +9 -7
  69. package/esm/policies/CargoLicenceValidated.js.map +1 -1
  70. package/esm/policies/CargoLintsConfigured.d.ts +4 -4
  71. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -1
  72. package/esm/policies/CargoLintsConfigured.js +19 -15
  73. package/esm/policies/CargoLintsConfigured.js.map +1 -1
  74. package/esm/policies/CargoLockPolicy.d.ts +4 -4
  75. package/esm/policies/CargoLockPolicy.d.ts.map +1 -1
  76. package/esm/policies/CargoLockPolicy.js +15 -11
  77. package/esm/policies/CargoLockPolicy.js.map +1 -1
  78. package/esm/policies/CargoTomlRequired.d.ts +5 -5
  79. package/esm/policies/CargoTomlRequired.d.ts.map +1 -1
  80. package/esm/policies/CargoTomlRequired.js +7 -7
  81. package/esm/policies/CargoTomlRequired.js.map +1 -1
  82. package/esm/policies/CargoTomlSorted.d.ts +4 -4
  83. package/esm/policies/CargoTomlSorted.d.ts.map +1 -1
  84. package/esm/policies/CargoTomlSorted.js +21 -17
  85. package/esm/policies/CargoTomlSorted.js.map +1 -1
  86. package/esm/policies/ConditionalScripts.d.ts +10 -8
  87. package/esm/policies/ConditionalScripts.d.ts.map +1 -1
  88. package/esm/policies/ConditionalScripts.js +24 -22
  89. package/esm/policies/ConditionalScripts.js.map +1 -1
  90. package/esm/policies/ExactScripts.d.ts +8 -6
  91. package/esm/policies/ExactScripts.d.ts.map +1 -1
  92. package/esm/policies/ExactScripts.js +15 -18
  93. package/esm/policies/ExactScripts.js.map +1 -1
  94. package/esm/policies/GleamDepVersions.d.ts +5 -5
  95. package/esm/policies/GleamDepVersions.d.ts.map +1 -1
  96. package/esm/policies/GleamDepVersions.js +5 -5
  97. package/esm/policies/GleamDepVersions.js.map +1 -1
  98. package/esm/policies/GleamDocExists.d.ts +4 -4
  99. package/esm/policies/GleamDocExists.d.ts.map +1 -1
  100. package/esm/policies/GleamDocExists.js +6 -6
  101. package/esm/policies/GleamDocExists.js.map +1 -1
  102. package/esm/policies/GleamInternalModulesConfigured.d.ts +4 -4
  103. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -1
  104. package/esm/policies/GleamInternalModulesConfigured.js +8 -6
  105. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -1
  106. package/esm/policies/GleamLicenceConfigured.d.ts +4 -4
  107. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -1
  108. package/esm/policies/GleamLicenceConfigured.js +8 -6
  109. package/esm/policies/GleamLicenceConfigured.js.map +1 -1
  110. package/esm/policies/GleamManifestCommitted.d.ts +10 -3
  111. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -1
  112. package/esm/policies/GleamManifestCommitted.js +10 -9
  113. package/esm/policies/GleamManifestCommitted.js.map +1 -1
  114. package/esm/policies/GleamMonorepoConsistency.d.ts +13 -5
  115. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -1
  116. package/esm/policies/GleamMonorepoConsistency.js +10 -10
  117. package/esm/policies/GleamMonorepoConsistency.js.map +1 -1
  118. package/esm/policies/GleamNameRestrictions.d.ts +4 -4
  119. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -1
  120. package/esm/policies/GleamNameRestrictions.js +6 -6
  121. package/esm/policies/GleamNameRestrictions.js.map +1 -1
  122. package/esm/policies/GleamNoPathDepsInPublished.d.ts +4 -4
  123. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -1
  124. package/esm/policies/GleamNoPathDepsInPublished.js +6 -6
  125. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -1
  126. package/esm/policies/GleamPathDepsValid.d.ts +3 -3
  127. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -1
  128. package/esm/policies/GleamPathDepsValid.js +5 -5
  129. package/esm/policies/GleamPathDepsValid.js.map +1 -1
  130. package/esm/policies/GleamProjectStructure.d.ts +11 -4
  131. package/esm/policies/GleamProjectStructure.d.ts.map +1 -1
  132. package/esm/policies/GleamProjectStructure.js +7 -8
  133. package/esm/policies/GleamProjectStructure.js.map +1 -1
  134. package/esm/policies/GleamSharedDependencyVersions.d.ts +12 -4
  135. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -1
  136. package/esm/policies/GleamSharedDependencyVersions.js +10 -10
  137. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -1
  138. package/esm/policies/GleamTomlRequired.d.ts +4 -4
  139. package/esm/policies/GleamTomlRequired.d.ts.map +1 -1
  140. package/esm/policies/GleamTomlRequired.js +5 -5
  141. package/esm/policies/GleamTomlRequired.js.map +1 -1
  142. package/esm/policies/GleamTomlSorted.d.ts +4 -4
  143. package/esm/policies/GleamTomlSorted.d.ts.map +1 -1
  144. package/esm/policies/GleamTomlSorted.js +21 -17
  145. package/esm/policies/GleamTomlSorted.js.map +1 -1
  146. package/esm/policies/GleamVersionConstraint.d.ts +4 -4
  147. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -1
  148. package/esm/policies/GleamVersionConstraint.js +14 -10
  149. package/esm/policies/GleamVersionConstraint.js.map +1 -1
  150. package/esm/policies/HtmlFileHeaders.d.ts +4 -2
  151. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
  152. package/esm/policies/HtmlFileHeaders.js +1 -1
  153. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  154. package/esm/policies/JsTsFileHeaders.d.ts +4 -2
  155. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
  156. package/esm/policies/JsTsFileHeaders.js +1 -1
  157. package/esm/policies/JsTsFileHeaders.js.map +1 -1
  158. package/esm/policies/LicenseFileExists.d.ts +10 -4
  159. package/esm/policies/LicenseFileExists.d.ts.map +1 -1
  160. package/esm/policies/LicenseFileExists.js +27 -20
  161. package/esm/policies/LicenseFileExists.js.map +1 -1
  162. package/esm/policies/MaxChangedFiles.d.ts +17 -0
  163. package/esm/policies/MaxChangedFiles.d.ts.map +1 -0
  164. package/esm/policies/MaxChangedFiles.js +22 -0
  165. package/esm/policies/MaxChangedFiles.js.map +1 -0
  166. package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
  167. package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
  168. package/esm/policies/MutuallyExclusiveScripts.js +9 -13
  169. package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
  170. package/esm/policies/NoBuildDirectory.d.ts +9 -3
  171. package/esm/policies/NoBuildDirectory.d.ts.map +1 -1
  172. package/esm/policies/NoBuildDirectory.js +8 -13
  173. package/esm/policies/NoBuildDirectory.js.map +1 -1
  174. package/esm/policies/NoJsFileExtensions.d.ts +9 -3
  175. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  176. package/esm/policies/NoJsFileExtensions.js +9 -14
  177. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  178. package/esm/policies/NoLargeBinaryFiles.d.ts +9 -4
  179. package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
  180. package/esm/policies/NoLargeBinaryFiles.js +10 -16
  181. package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
  182. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +10 -6
  183. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
  184. package/esm/policies/NoPrivateWorkspaceDependencies.js +12 -14
  185. package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
  186. package/esm/policies/NoTargetArtifacts.d.ts +9 -3
  187. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -1
  188. package/esm/policies/NoTargetArtifacts.js +9 -14
  189. package/esm/policies/NoTargetArtifacts.js.map +1 -1
  190. package/esm/policies/NoUnsafeWithoutJustification.d.ts +11 -4
  191. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -1
  192. package/esm/policies/NoUnsafeWithoutJustification.js +8 -9
  193. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -1
  194. package/esm/policies/NoWildcardDependencies.d.ts +5 -5
  195. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -1
  196. package/esm/policies/NoWildcardDependencies.js +6 -6
  197. package/esm/policies/NoWildcardDependencies.js.map +1 -1
  198. package/esm/policies/PackageAllowedScopes.d.ts +9 -5
  199. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
  200. package/esm/policies/PackageAllowedScopes.js +15 -16
  201. package/esm/policies/PackageAllowedScopes.js.map +1 -1
  202. package/esm/policies/PackageEsmType.d.ts +7 -5
  203. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  204. package/esm/policies/PackageEsmType.js +31 -31
  205. package/esm/policies/PackageEsmType.js.map +1 -1
  206. package/esm/policies/PackageFolderName.d.ts +8 -6
  207. package/esm/policies/PackageFolderName.d.ts.map +1 -1
  208. package/esm/policies/PackageFolderName.js +13 -16
  209. package/esm/policies/PackageFolderName.js.map +1 -1
  210. package/esm/policies/PackageJsonProperties.d.ts +5 -3
  211. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  212. package/esm/policies/PackageJsonProperties.js +6 -17
  213. package/esm/policies/PackageJsonProperties.js.map +1 -1
  214. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +2 -7
  215. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  216. package/esm/policies/PackageJsonRepoDirectoryProperty.js +28 -42
  217. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  218. package/esm/policies/PackageJsonSorted.d.ts +2 -2
  219. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  220. package/esm/policies/PackageJsonSorted.js +15 -30
  221. package/esm/policies/PackageJsonSorted.js.map +1 -1
  222. package/esm/policies/PackageLicense.d.ts +4 -4
  223. package/esm/policies/PackageLicense.d.ts.map +1 -1
  224. package/esm/policies/PackageLicense.js +31 -52
  225. package/esm/policies/PackageLicense.js.map +1 -1
  226. package/esm/policies/PackagePrivateField.d.ts +12 -8
  227. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  228. package/esm/policies/PackagePrivateField.js +31 -23
  229. package/esm/policies/PackagePrivateField.js.map +1 -1
  230. package/esm/policies/PackageReadme.d.ts +6 -5
  231. package/esm/policies/PackageReadme.d.ts.map +1 -1
  232. package/esm/policies/PackageReadme.js +22 -59
  233. package/esm/policies/PackageReadme.js.map +1 -1
  234. package/esm/policies/PackageScripts.d.ts +26 -22
  235. package/esm/policies/PackageScripts.d.ts.map +1 -1
  236. package/esm/policies/PackageScripts.js +39 -36
  237. package/esm/policies/PackageScripts.js.map +1 -1
  238. package/esm/policies/PackageTestScripts.d.ts +10 -6
  239. package/esm/policies/PackageTestScripts.d.ts.map +1 -1
  240. package/esm/policies/PackageTestScripts.js +14 -16
  241. package/esm/policies/PackageTestScripts.js.map +1 -1
  242. package/esm/policies/PublicApiDocumented.d.ts +4 -4
  243. package/esm/policies/PublicApiDocumented.d.ts.map +1 -1
  244. package/esm/policies/PublicApiDocumented.js +10 -8
  245. package/esm/policies/PublicApiDocumented.js.map +1 -1
  246. package/esm/policies/RequireCompanionChanges.d.ts +16 -0
  247. package/esm/policies/RequireCompanionChanges.d.ts.map +1 -0
  248. package/esm/policies/RequireCompanionChanges.js +42 -0
  249. package/esm/policies/RequireCompanionChanges.js.map +1 -0
  250. package/esm/policies/RequiredGitignorePatterns.d.ts +11 -4
  251. package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
  252. package/esm/policies/RequiredGitignorePatterns.js +29 -36
  253. package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
  254. package/esm/policies/RequiredScripts.d.ts +9 -7
  255. package/esm/policies/RequiredScripts.d.ts.map +1 -1
  256. package/esm/policies/RequiredScripts.js +24 -24
  257. package/esm/policies/RequiredScripts.js.map +1 -1
  258. package/esm/policies/RustDocExists.d.ts +4 -4
  259. package/esm/policies/RustDocExists.d.ts.map +1 -1
  260. package/esm/policies/RustDocExists.js +6 -6
  261. package/esm/policies/RustDocExists.js.map +1 -1
  262. package/esm/policies/RustToolchainExists.d.ts +11 -4
  263. package/esm/policies/RustToolchainExists.d.ts.map +1 -1
  264. package/esm/policies/RustToolchainExists.js +10 -9
  265. package/esm/policies/RustToolchainExists.js.map +1 -1
  266. package/esm/policies/RustfmtConfigExists.d.ts +11 -4
  267. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -1
  268. package/esm/policies/RustfmtConfigExists.js +10 -9
  269. package/esm/policies/RustfmtConfigExists.js.map +1 -1
  270. package/esm/policies/ScriptContains.d.ts +9 -7
  271. package/esm/policies/ScriptContains.d.ts.map +1 -1
  272. package/esm/policies/ScriptContains.js +9 -13
  273. package/esm/policies/ScriptContains.js.map +1 -1
  274. package/esm/policies/SharedDependencyVersions.d.ts +9 -4
  275. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -1
  276. package/esm/policies/SharedDependencyVersions.js +28 -20
  277. package/esm/policies/SharedDependencyVersions.js.map +1 -1
  278. package/esm/policies/WorkspaceInheritance.d.ts +11 -4
  279. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -1
  280. package/esm/policies/WorkspaceInheritance.js +10 -11
  281. package/esm/policies/WorkspaceInheritance.js.map +1 -1
  282. package/esm/policies/WorkspaceMembersValid.d.ts +11 -4
  283. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -1
  284. package/esm/policies/WorkspaceMembersValid.js +10 -11
  285. package/esm/policies/WorkspaceMembersValid.js.map +1 -1
  286. package/esm/policies/constants.d.ts.map +1 -1
  287. package/esm/policies/constants.js +1 -1
  288. package/esm/policies/constants.js.map +1 -1
  289. package/esm/policies.d.ts +15 -5
  290. package/esm/policies.d.ts.map +1 -1
  291. package/esm/policies.js +14 -5
  292. package/esm/policies.js.map +1 -1
  293. package/esm/policy.d.ts +67 -289
  294. package/esm/policy.d.ts.map +1 -1
  295. package/esm/policy.js +1 -122
  296. package/esm/policy.js.map +1 -1
  297. package/esm/policyDefiners/defineCargoPolicy.d.ts +25 -9
  298. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -1
  299. package/esm/policyDefiners/defineCargoPolicy.js +10 -28
  300. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -1
  301. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
  302. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  303. package/esm/policyDefiners/defineFileHeaderPolicy.js +16 -35
  304. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  305. package/esm/policyDefiners/defineGleamPolicy.d.ts +25 -9
  306. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -1
  307. package/esm/policyDefiners/defineGleamPolicy.js +10 -27
  308. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -1
  309. package/esm/policyDefiners/definePackagePolicy.d.ts +24 -13
  310. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  311. package/esm/policyDefiners/definePackagePolicy.js +9 -32
  312. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  313. package/esm/policyDefiners/spdxValidator.d.ts +4 -12
  314. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -1
  315. package/esm/policyDefiners/spdxValidator.js +26 -14
  316. package/esm/policyDefiners/spdxValidator.js.map +1 -1
  317. package/esm/policyExecution.d.ts +20 -0
  318. package/esm/policyExecution.d.ts.map +1 -0
  319. package/esm/policyExecution.js +234 -0
  320. package/esm/policyExecution.js.map +1 -0
  321. package/esm/repositoryChanges.d.ts +26 -0
  322. package/esm/repositoryChanges.d.ts.map +1 -0
  323. package/esm/repositoryChanges.js +172 -0
  324. package/esm/repositoryChanges.js.map +1 -0
  325. package/esm/repositoryFiles.d.ts +6 -0
  326. package/esm/repositoryFiles.d.ts.map +1 -0
  327. package/esm/repositoryFiles.js +11 -0
  328. package/esm/repositoryFiles.js.map +1 -0
  329. package/esm/runner.d.ts +73 -47
  330. package/esm/runner.d.ts.map +1 -1
  331. package/esm/runner.js +158 -144
  332. package/esm/runner.js.map +1 -1
  333. package/esm/settlePolicyPromise.d.ts +4 -0
  334. package/esm/settlePolicyPromise.d.ts.map +1 -0
  335. package/esm/settlePolicyPromise.js +10 -0
  336. package/esm/settlePolicyPromise.js.map +1 -0
  337. package/esm/tsdoc-metadata.json +1 -1
  338. package/esm/utils/safePaths.d.ts +9 -0
  339. package/esm/utils/safePaths.d.ts.map +1 -0
  340. package/esm/utils/safePaths.js +40 -0
  341. package/esm/utils/safePaths.js.map +1 -0
  342. package/oclif.manifest.json +57 -2
  343. package/package.json +42 -27
  344. package/scripts/benchmark.mjs +341 -0
  345. package/sidecar/sidecar.mjs +388 -417
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyExecution.js","sourceRoot":"","sources":["../src/policyExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;A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AAS,CAAC,KAAK,CAAC;gBACtB,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;gBAChC,KAAK;aACL,CAAC,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;YACnB,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACxB,OAAO,GAAG,EAAE,CAAC;YACd,CAAC;QACF,CAAC;QACD,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACpB,GAAG,OAAO;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI;gBACJ,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,QAAQ,EAAE,MAAM,CAAC,UAAU;aAC3B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["import { types } from \"node:util\";\nimport type { Operation } from \"effection\";\nimport { matchesPath } from \"./context.js\";\nimport { ExecutionContractError } from \"./executionContractError.js\";\nimport { fileCache, type ParsedFileCache } from \"./fileCache.js\";\nimport { runWithPerf } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyResult } from \"./policy.js\";\nimport { inventoryPaths, type RepositoryFile } from \"./repositoryChanges.js\";\nimport type { PolicyRunResults } from \"./runner.js\";\nimport { settlePolicyPromise } from \"./settlePolicyPromise.js\";\n\nconst windowsAbsolutePath = /^[A-Za-z]:/;\n\nfunction* execute<T>(handler: () => Promise<T> | Operation<T>): Operation<T> {\n\tconst execution = handler();\n\tif (execution instanceof Promise) {\n\t\treturn yield* settlePolicyPromise(execution);\n\t}\n\tif (\n\t\ttypeof execution === \"object\" &&\n\t\texecution !== null &&\n\t\tSymbol.iterator in execution &&\n\t\t!Array.isArray(execution)\n\t) {\n\t\treturn yield* execution;\n\t}\n\tthrow new ExecutionContractError(\n\t\t\"Handlers and resolvers must be async functions or Effection generators.\",\n\t);\n}\n\nfunction validPath(path: unknown): path is string {\n\treturn (\n\t\ttypeof path === \"string\" &&\n\t\tpath.length > 0 &&\n\t\t!path.includes(\"\\\\\") &&\n\t\t!path.includes(\"\\0\") &&\n\t\t!path.startsWith(\"/\") &&\n\t\t!windowsAbsolutePath.test(path) &&\n\t\tpath\n\t\t\t.split(\"/\")\n\t\t\t.every((part) => part !== \"\" && part !== \".\" && part !== \"..\")\n\t);\n}\n\nfunction validateResult(\n\tresult: unknown,\n\trepository: boolean,\n\tfix: boolean,\n): asserts result is PolicyResult {\n\tconst invalid = () =>\n\t\tnew ExecutionContractError(\n\t\t\t\"Policy handlers and resolvers must return readonly PolicyFinding[] with message, optional manualFix, fixStatus and repository-only files; legacy results are not supported.\",\n\t\t);\n\tif (!Array.isArray(result)) {\n\t\tthrow invalid();\n\t}\n\tfor (const finding of result) {\n\t\tif (\n\t\t\ttypeof finding !== \"object\" ||\n\t\t\tfinding === null ||\n\t\t\tArray.isArray(finding) ||\n\t\t\tReflect.ownKeys(finding).some(\n\t\t\t\t(key) =>\n\t\t\t\t\ttypeof key !== \"string\" ||\n\t\t\t\t\t![\"message\", \"manualFix\", \"fixStatus\", \"files\"].includes(key),\n\t\t\t) ||\n\t\t\t!(\"message\" in finding) ||\n\t\t\ttypeof finding.message !== \"string\" ||\n\t\t\tfinding.message.length === 0 ||\n\t\t\t(\"manualFix\" in finding &&\n\t\t\t\tfinding.manualFix !== undefined &&\n\t\t\t\ttypeof finding.manualFix !== \"string\") ||\n\t\t\t(\"fixStatus\" in finding &&\n\t\t\t\tfinding.fixStatus !== undefined &&\n\t\t\t\t![\"available\", \"fixed\", \"failed\"].includes(finding.fixStatus)) ||\n\t\t\t(!fix &&\n\t\t\t\t(finding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\")) ||\n\t\t\t(\"files\" in finding &&\n\t\t\t\t!(\n\t\t\t\t\trepository &&\n\t\t\t\t\t(finding.files === undefined ||\n\t\t\t\t\t\t(Array.isArray(finding.files) && finding.files.every(validPath)))\n\t\t\t\t))\n\t\t) {\n\t\t\tthrow invalid();\n\t\t}\n\t}\n}\n\nfunction mergeFindings(\n\tchecked: PolicyResult,\n\tresolved: PolicyResult,\n): PolicyResult {\n\t// Omission is not resolution; messages identify independent findings.\n\tconst merged = [...checked];\n\tconst used = new Set<number>();\n\tfor (const finding of resolved) {\n\t\tconst index = checked.findIndex(\n\t\t\t(previous, candidateIndex) =>\n\t\t\t\t!used.has(candidateIndex) && previous.message === finding.message,\n\t\t);\n\t\tif (index === -1) {\n\t\t\tmerged.push(finding);\n\t\t} else if (merged[index]?.fixStatus !== \"fixed\") {\n\t\t\tmerged[index] = { ...merged[index], ...finding };\n\t\t\tused.add(index);\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction nativeErrorMessage(cause: object): string | undefined {\n\tlet current: object | null = cause;\n\twhile (current && !types.isProxy(current)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(current, \"message\");\n\t\tif (descriptor) {\n\t\t\treturn \"value\" in descriptor && typeof descriptor.value === \"string\"\n\t\t\t\t? descriptor.value\n\t\t\t\t: undefined;\n\t\t}\n\t\tcurrent = Object.getPrototypeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** Describe thrown values without allowing hostile coercion to discard a run. */\nexport function executionMessage(cause: unknown): string {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn String(cause);\n\t\t}\n\t\tconst message =\n\t\t\t!types.isProxy(cause) && types.isNativeError(cause)\n\t\t\t\t? nativeErrorMessage(cause)\n\t\t\t\t: undefined;\n\t\treturn message ?? \"Policy threw a non-Error or uninspectable value.\";\n\t} catch {\n\t\treturn \"Policy threw a value that cannot be inspected.\";\n\t}\n}\n\nfunction errorKind(cause: unknown): \"contract\" | \"exception\" {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn \"exception\";\n\t\t}\n\t\tlet current: object | null = cause;\n\t\twhile (current && !types.isProxy(current)) {\n\t\t\tif (current === ExecutionContractError.prototype) {\n\t\t\t\treturn \"contract\";\n\t\t\t}\n\t\t\tcurrent = Object.getPrototypeOf(current);\n\t\t}\n\t\treturn \"exception\";\n\t} catch {\n\t\treturn \"exception\";\n\t}\n}\n\n/** Internal single-policy execution; engines own matching and scheduling. */\nexport class PolicyExecutor {\n\tpublic constructor(\n\t\tprivate readonly root: string,\n\t\tprivate readonly fix: boolean,\n\t) {}\n\n\tpublic *repository(\n\t\tpolicy: Extract<IdentifiedPolicy, { scope: \"repository\" | \"changes\" }>,\n\t\tentries: readonly RepositoryFile[],\n\t\toutput: PolicyRunResults,\n\t): Operation<boolean> {\n\t\tconst { match } = policy;\n\t\tconst matching = match\n\t\t\t? entries.filter(\n\t\t\t\t\t(entry) =>\n\t\t\t\t\t\tmatchesPath(match, entry.path) ||\n\t\t\t\t\t\t(entry.status === \"renamed\" &&\n\t\t\t\t\t\t\tmatchesPath(match, entry.previousPath)),\n\t\t\t\t)\n\t\t\t: entries;\n\t\tconst eligible = inventoryPaths(matching);\n\t\ttry {\n\t\t\tconst findings = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() =>\n\t\t\t\t\texecute(() =>\n\t\t\t\t\t\tpolicy.handler({\n\t\t\t\t\t\t\tfiles: eligible,\n\t\t\t\t\t\t\tentries: matching,\n\t\t\t\t\t\t\troot: this.root,\n\t\t\t\t\t\t\tresolve: this.fix,\n\t\t\t\t\t\t\tconfig: policy.config,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tvalidateResult(findings, true, this.fix);\n\t\t\tfor (const finding of findings) {\n\t\t\t\toutput.findings.push({\n\t\t\t\t\t...finding,\n\t\t\t\t\tscope: policy.scope,\n\t\t\t\t\tpolicy: policy.name,\n\t\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: policy.scope,\n\t\t\t\tfiles: eligible,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase: \"handle\",\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\treturn this.fix;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic *file(\n\t\tfile: string,\n\t\tpolicy: Exclude<IdentifiedPolicy, { scope: \"repository\" | \"changes\" }>,\n\t\toutput: PolicyRunResults,\n\t\tcache: ParsedFileCache | undefined,\n\t): Operation<boolean> {\n\t\tlet stopped = false;\n\t\tlet phase: \"handle\" | \"resolve\" = \"handle\";\n\t\tlet checked: PolicyResult = [];\n\t\ttry {\n\t\t\tconst args = {\n\t\t\t\tfile,\n\t\t\t\troot: this.root,\n\t\t\t\tresolve: this.fix,\n\t\t\t\tconfig: policy.config,\n\t\t\t\t[fileCache]: cache,\n\t\t\t};\n\t\t\tchecked = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() => execute(() => policy.handler(args)),\n\t\t\t);\n\t\t\tvalidateResult(checked, false, this.fix);\n\t\t\tif (\n\t\t\t\tthis.fix &&\n\t\t\t\tchecked.length > 0 &&\n\t\t\t\tpolicy.resolver &&\n\t\t\t\t!checked.some(\n\t\t\t\t\t(finding) =>\n\t\t\t\t\t\tfinding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\",\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tphase = \"resolve\";\n\t\t\t\tconst resolver = policy.resolver;\n\t\t\t\tconst resolved = yield* runWithPerf(\n\t\t\t\t\tpolicy.instanceId,\n\t\t\t\t\t\"resolve\",\n\t\t\t\t\toutput.perfStats,\n\t\t\t\t\t() =>\n\t\t\t\t\t\texecute(() =>\n\t\t\t\t\t\t\tresolver({\n\t\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\t\troot: args.root,\n\t\t\t\t\t\t\t\tconfig: args.config,\n\t\t\t\t\t\t\t\tfindings: checked.map((finding) => ({ ...finding })),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tvalidateResult(resolved, false, true);\n\t\t\t\tchecked = mergeFindings(checked, resolved);\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase,\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\tstopped = this.fix;\n\t\t\tif (phase === \"handle\") {\n\t\t\t\tchecked = [];\n\t\t\t}\n\t\t}\n\t\tfor (const { files: _files, ...finding } of checked) {\n\t\t\toutput.findings.push({\n\t\t\t\t...finding,\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t});\n\t\t}\n\t\treturn stopped;\n\t}\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { RepopoConfig } from "./config.js";
2
+ type ChangeOptions = NonNullable<RepopoConfig["changes"]>;
3
+ /** Repo-relative Git paths; renames retain both endpoints. @public */
4
+ export type RepositoryFile = ({
5
+ readonly status: "unchanged" | "added" | "modified" | "deleted" | "type-changed";
6
+ readonly path: string;
7
+ } | {
8
+ readonly status: "renamed";
9
+ readonly path: string;
10
+ readonly previousPath: string;
11
+ }) & {
12
+ /** Working-tree presence when it differs from status (for example an unstaged deletion in PR mode). */
13
+ readonly exists?: boolean | undefined;
14
+ };
15
+ /** Validate options independently of whether a policy requests changes. @internal */
16
+ export declare function validateChangeOptions(options: ChangeOptions): void;
17
+ /** Normalize legacy paths and copy records before policies can observe them. @internal */
18
+ export declare function snapshotInventory(files: readonly (string | RepositoryFile)[]): readonly RepositoryFile[];
19
+ /** Derive the legacy working-tree inventory, excluding absent paths. @internal */
20
+ export declare function inventoryPaths(entries: readonly RepositoryFile[]): string[];
21
+ /** Refresh live paths without changing the statuses captured before fixes. @internal */
22
+ export declare function annotateInventory(files: readonly string[], snapshot: readonly RepositoryFile[]): readonly RepositoryFile[];
23
+ /** Collect the full inventory with Git statuses; does not fetch or require an actual pull request. @public */
24
+ export declare function collectRepositoryInventory(root: string, options?: NonNullable<RepopoConfig["changes"]>): Promise<readonly RepositoryFile[]>;
25
+ export {};
26
+ //# sourceMappingURL=repositoryChanges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositoryChanges.d.ts","sourceRoot":"","sources":["../src/repositoryChanges.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,KAAK,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAE1D,sEAAsE;AACtE,MAAM,MAAM,cAAc,GAAG,CAC1B;IACA,QAAQ,CAAC,MAAM,EACZ,WAAW,GACX,OAAO,GACP,UAAU,GACV,SAAS,GACT,cAAc,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACrB,GACD;IACA,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC7B,CACH,GAAG;IACH,uGAAuG;IACvG,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAgBlE;AA2CD,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GACzC,SAAS,cAAc,EAAE,CAU3B;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,EAAE,CAQ3E;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,SAAS,cAAc,EAAE,GACjC,SAAS,cAAc,EAAE,CAa3B;AAED,8GAA8G;AAC9G,wBAAsB,0BAA0B,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAM,GAChD,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CA2BpC"}
@@ -0,0 +1,172 @@
1
+ import { env } from "node:process";
2
+ import { simpleGit } from "simple-git";
3
+ import { readRepositoryFiles, splitGitPaths } from "./repositoryFiles.js";
4
+ /** Validate options independently of whether a policy requests changes. @internal */
5
+ export function validateChangeOptions(options) {
6
+ if (options.mode !== undefined &&
7
+ !["pr", "local", "staged"].includes(options.mode)) {
8
+ throw new TypeError("Change mode must be pr, local, or staged.");
9
+ }
10
+ if (options.base !== undefined && (options.mode ?? "pr") !== "pr") {
11
+ throw new TypeError("A change base is only valid in pr mode.");
12
+ }
13
+ if (options.base !== undefined &&
14
+ (typeof options.base !== "string" || options.base.trim() === "")) {
15
+ throw new TypeError("Change branch references must be nonempty strings.");
16
+ }
17
+ }
18
+ function parseChanges(output) {
19
+ const tokens = splitGitPaths(output);
20
+ const entries = [];
21
+ for (let index = 0; index < tokens.length;) {
22
+ const status = tokens[index++];
23
+ const path = tokens[index++];
24
+ if (!path) {
25
+ throw new Error("Invalid Git name-status output: missing path.");
26
+ }
27
+ if (status?.startsWith("R")) {
28
+ const destination = tokens[index++];
29
+ if (!destination) {
30
+ throw new Error("Invalid Git rename output: missing destination.");
31
+ }
32
+ entries.push({
33
+ status: "renamed",
34
+ previousPath: path,
35
+ path: destination,
36
+ });
37
+ }
38
+ else {
39
+ switch (status) {
40
+ case "A":
41
+ entries.push({ status: "added", path });
42
+ break;
43
+ case "M":
44
+ entries.push({ status: "modified", path });
45
+ break;
46
+ case "D":
47
+ entries.push({ status: "deleted", path });
48
+ break;
49
+ case "T":
50
+ entries.push({ status: "type-changed", path });
51
+ break;
52
+ default:
53
+ throw new Error(`Unsupported Git change status: ${status}`);
54
+ }
55
+ }
56
+ }
57
+ return entries;
58
+ }
59
+ /** Normalize legacy paths and copy records before policies can observe them. @internal */
60
+ export function snapshotInventory(files) {
61
+ return Object.freeze(files.map((file) => Object.freeze(typeof file === "string"
62
+ ? { path: file, status: "unchanged" }
63
+ : { ...file })));
64
+ }
65
+ /** Derive the legacy working-tree inventory, excluding absent paths. @internal */
66
+ export function inventoryPaths(entries) {
67
+ return [
68
+ ...new Set(entries
69
+ .filter((entry) => entry.exists ?? entry.status !== "deleted")
70
+ .map((entry) => entry.path)),
71
+ ];
72
+ }
73
+ /** Refresh live paths without changing the statuses captured before fixes. @internal */
74
+ export function annotateInventory(files, snapshot) {
75
+ const present = new Set(files);
76
+ const changed = snapshot.filter((entry) => entry.status !== "unchanged");
77
+ const changedPaths = new Set(changed.map((entry) => entry.path));
78
+ return snapshotInventory([
79
+ ...files
80
+ .filter((path) => !changedPaths.has(path))
81
+ .map((path) => ({ path, status: "unchanged" })),
82
+ ...changed.map((entry) => ({
83
+ ...entry,
84
+ exists: present.has(entry.path),
85
+ })),
86
+ ]);
87
+ }
88
+ /** Collect the full inventory with Git statuses; does not fetch or require an actual pull request. @public */
89
+ export async function collectRepositoryInventory(root, options = {}) {
90
+ validateChangeOptions(options);
91
+ const mode = options.mode ?? "pr";
92
+ const git = simpleGit({ baseDir: root });
93
+ if (await git.raw(["ls-files", "--unmerged", "-z"])) {
94
+ throw new Error("Cannot collect repository changes with unresolved Git conflicts.");
95
+ }
96
+ // symbolic HEAD exists before the first commit, but no HEAD object does.
97
+ const unborn = !(await git.raw(["rev-parse", "--revs-only", "HEAD"])).trim();
98
+ const head = unborn
99
+ ? undefined
100
+ : (await git.revparse(["--verify", "HEAD^{commit}"])).trim();
101
+ if (mode === "pr") {
102
+ if (!head) {
103
+ throw new Error("PR changes require a HEAD commit. Use staged/local mode for an unborn repository.");
104
+ }
105
+ return annotateInventory(await readRepositoryFiles(git), await collectPrChanges(git, head, options));
106
+ }
107
+ const entries = await collectWorkingChanges(git, mode, head);
108
+ return annotateInventory(await readRepositoryFiles(git), entries);
109
+ }
110
+ async function resolveTarget(git, options) {
111
+ const target = options.base ??
112
+ (env.GITHUB_BASE_REF || env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME);
113
+ if (!target) {
114
+ throw new Error("Cannot determine PR target. Set changes.base or --change-base.");
115
+ }
116
+ // Enumerate refs rather than masking errors from failed Git subprocesses.
117
+ const refs = (await git.raw(["for-each-ref", "--format=%(refname)"]))
118
+ .trim()
119
+ .split("\n");
120
+ if (target.startsWith("refs/")) {
121
+ return target;
122
+ }
123
+ const candidates = [`refs/heads/${target}`, `refs/remotes/origin/${target}`];
124
+ return candidates.find((candidate) => refs.includes(candidate)) ?? target;
125
+ }
126
+ async function collectPrChanges(git, head, options) {
127
+ const target = await resolveTarget(git, options);
128
+ let output;
129
+ try {
130
+ output = await git.raw([
131
+ "diff",
132
+ "--merge-base",
133
+ "--name-status",
134
+ "-z",
135
+ "--find-renames",
136
+ "--no-ext-diff",
137
+ "--end-of-options",
138
+ target,
139
+ head,
140
+ "--",
141
+ ]);
142
+ }
143
+ catch (cause) {
144
+ throw new Error(`Cannot resolve PR base '${target}' and its merge base with HEAD. Set --change-base or fetch the missing branch/history.`, { cause });
145
+ }
146
+ return parseChanges(output);
147
+ }
148
+ async function collectWorkingChanges(git, mode, head) {
149
+ if (!head && mode === "local") {
150
+ return (await readRepositoryFiles(git)).map((path) => ({
151
+ status: "added",
152
+ path,
153
+ }));
154
+ }
155
+ const entries = parseChanges(await git.raw([
156
+ "diff",
157
+ "--name-status",
158
+ "-z",
159
+ "--find-renames",
160
+ "--no-ext-diff",
161
+ ...(mode === "staged" ? ["--cached"] : []),
162
+ ...(head ? [head] : []),
163
+ "--",
164
+ ]));
165
+ if (mode === "local") {
166
+ for (const path of splitGitPaths(await git.raw(["ls-files", "--others", "--exclude-standard", "-z"]))) {
167
+ entries.push({ status: "added", path });
168
+ }
169
+ }
170
+ return entries;
171
+ }
172
+ //# sourceMappingURL=repositoryChanges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositoryChanges.js","sourceRoot":"","sources":["../src/repositoryChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA2B1E,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC3D,IACC,OAAO,CAAC,IAAI,KAAK,SAAS;QAC1B,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAChD,CAAC;QACF,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACnE,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;IAChE,CAAC;IACD,IACC,OAAO,CAAC,IAAI,KAAK,SAAS;QAC1B,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAC/D,CAAC;QACF,MAAM,IAAI,SAAS,CAAC,o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AI,KAAK,OAAO,EAAE,CAAC;QACtB,KAAK,MAAM,IAAI,IAAI,aAAa,CAC/B,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC,CACnE,EAAE,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { env } from \"node:process\";\nimport { simpleGit } from \"simple-git\";\nimport type { RepopoConfig } from \"./config.js\";\nimport { readRepositoryFiles, splitGitPaths } from \"./repositoryFiles.js\";\n\ntype Git = ReturnType<typeof simpleGit>;\n\ntype ChangeOptions = NonNullable<RepopoConfig[\"changes\"]>;\n\n/** Repo-relative Git paths; renames retain both endpoints. @public */\nexport type RepositoryFile = (\n\t| {\n\t\t\treadonly status:\n\t\t\t\t| \"unchanged\"\n\t\t\t\t| \"added\"\n\t\t\t\t| \"modified\"\n\t\t\t\t| \"deleted\"\n\t\t\t\t| \"type-changed\";\n\t\t\treadonly path: string;\n\t }\n\t| {\n\t\t\treadonly status: \"renamed\";\n\t\t\treadonly path: string;\n\t\t\treadonly previousPath: string;\n\t }\n) & {\n\t/** Working-tree presence when it differs from status (for example an unstaged deletion in PR mode). */\n\treadonly exists?: boolean | undefined;\n};\n\n/** Validate options independently of whether a policy requests changes. @internal */\nexport function validateChangeOptions(options: ChangeOptions): void {\n\tif (\n\t\toptions.mode !== undefined &&\n\t\t![\"pr\", \"local\", \"staged\"].includes(options.mode)\n\t) {\n\t\tthrow new TypeError(\"Change mode must be pr, local, or staged.\");\n\t}\n\tif (options.base !== undefined && (options.mode ?? \"pr\") !== \"pr\") {\n\t\tthrow new TypeError(\"A change base is only valid in pr mode.\");\n\t}\n\tif (\n\t\toptions.base !== undefined &&\n\t\t(typeof options.base !== \"string\" || options.base.trim() === \"\")\n\t) {\n\t\tthrow new TypeError(\"Change branch references must be nonempty strings.\");\n\t}\n}\n\nfunction parseChanges(output: string): RepositoryFile[] {\n\tconst tokens = splitGitPaths(output);\n\tconst entries: RepositoryFile[] = [];\n\tfor (let index = 0; index < tokens.length; ) {\n\t\tconst status = tokens[index++];\n\t\tconst path = tokens[index++];\n\t\tif (!path) {\n\t\t\tthrow new Error(\"Invalid Git name-status output: missing path.\");\n\t\t}\n\t\tif (status?.startsWith(\"R\")) {\n\t\t\tconst destination = tokens[index++];\n\t\t\tif (!destination) {\n\t\t\t\tthrow new Error(\"Invalid Git rename output: missing destination.\");\n\t\t\t}\n\t\t\tentries.push({\n\t\t\t\tstatus: \"renamed\",\n\t\t\t\tpreviousPath: path,\n\t\t\t\tpath: destination,\n\t\t\t});\n\t\t} else {\n\t\t\tswitch (status) {\n\t\t\t\tcase \"A\":\n\t\t\t\t\tentries.push({ status: \"added\", path });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"M\":\n\t\t\t\t\tentries.push({ status: \"modified\", path });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"D\":\n\t\t\t\t\tentries.push({ status: \"deleted\", path });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"T\":\n\t\t\t\t\tentries.push({ status: \"type-changed\", path });\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unsupported Git change status: ${status}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn entries;\n}\n\n/** Normalize legacy paths and copy records before policies can observe them. @internal */\nexport function snapshotInventory(\n\tfiles: readonly (string | RepositoryFile)[],\n): readonly RepositoryFile[] {\n\treturn Object.freeze(\n\t\tfiles.map((file) =>\n\t\t\tObject.freeze(\n\t\t\t\ttypeof file === \"string\"\n\t\t\t\t\t? { path: file, status: \"unchanged\" as const }\n\t\t\t\t\t: { ...file },\n\t\t\t),\n\t\t),\n\t);\n}\n\n/** Derive the legacy working-tree inventory, excluding absent paths. @internal */\nexport function inventoryPaths(entries: readonly RepositoryFile[]): string[] {\n\treturn [\n\t\t...new Set(\n\t\t\tentries\n\t\t\t\t.filter((entry) => entry.exists ?? entry.status !== \"deleted\")\n\t\t\t\t.map((entry) => entry.path),\n\t\t),\n\t];\n}\n\n/** Refresh live paths without changing the statuses captured before fixes. @internal */\nexport function annotateInventory(\n\tfiles: readonly string[],\n\tsnapshot: readonly RepositoryFile[],\n): readonly RepositoryFile[] {\n\tconst present = new Set(files);\n\tconst changed = snapshot.filter((entry) => entry.status !== \"unchanged\");\n\tconst changedPaths = new Set(changed.map((entry) => entry.path));\n\treturn snapshotInventory([\n\t\t...files\n\t\t\t.filter((path) => !changedPaths.has(path))\n\t\t\t.map((path) => ({ path, status: \"unchanged\" as const })),\n\t\t...changed.map((entry) => ({\n\t\t\t...entry,\n\t\t\texists: present.has(entry.path),\n\t\t})),\n\t]);\n}\n\n/** Collect the full inventory with Git statuses; does not fetch or require an actual pull request. @public */\nexport async function collectRepositoryInventory(\n\troot: string,\n\toptions: NonNullable<RepopoConfig[\"changes\"]> = {},\n): Promise<readonly RepositoryFile[]> {\n\tvalidateChangeOptions(options);\n\tconst mode = options.mode ?? \"pr\";\n\tconst git = simpleGit({ baseDir: root });\n\tif (await git.raw([\"ls-files\", \"--unmerged\", \"-z\"])) {\n\t\tthrow new Error(\n\t\t\t\"Cannot collect repository changes with unresolved Git conflicts.\",\n\t\t);\n\t}\n\t// symbolic HEAD exists before the first commit, but no HEAD object does.\n\tconst unborn = !(await git.raw([\"rev-parse\", \"--revs-only\", \"HEAD\"])).trim();\n\tconst head = unborn\n\t\t? undefined\n\t\t: (await git.revparse([\"--verify\", \"HEAD^{commit}\"])).trim();\n\tif (mode === \"pr\") {\n\t\tif (!head) {\n\t\t\tthrow new Error(\n\t\t\t\t\"PR changes require a HEAD commit. Use staged/local mode for an unborn repository.\",\n\t\t\t);\n\t\t}\n\t\treturn annotateInventory(\n\t\t\tawait readRepositoryFiles(git),\n\t\t\tawait collectPrChanges(git, head, options),\n\t\t);\n\t}\n\tconst entries = await collectWorkingChanges(git, mode, head);\n\treturn annotateInventory(await readRepositoryFiles(git), entries);\n}\n\nasync function resolveTarget(\n\tgit: Git,\n\toptions: ChangeOptions,\n): Promise<string> {\n\tconst target =\n\t\toptions.base ??\n\t\t(env.GITHUB_BASE_REF || env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME);\n\tif (!target) {\n\t\tthrow new Error(\n\t\t\t\"Cannot determine PR target. Set changes.base or --change-base.\",\n\t\t);\n\t}\n\t// Enumerate refs rather than masking errors from failed Git subprocesses.\n\tconst refs = (await git.raw([\"for-each-ref\", \"--format=%(refname)\"]))\n\t\t.trim()\n\t\t.split(\"\\n\");\n\tif (target.startsWith(\"refs/\")) {\n\t\treturn target;\n\t}\n\tconst candidates = [`refs/heads/${target}`, `refs/remotes/origin/${target}`];\n\treturn candidates.find((candidate) => refs.includes(candidate)) ?? target;\n}\n\nasync function collectPrChanges(\n\tgit: Git,\n\thead: string,\n\toptions: ChangeOptions,\n): Promise<RepositoryFile[]> {\n\tconst target = await resolveTarget(git, options);\n\tlet output: string;\n\ttry {\n\t\toutput = await git.raw([\n\t\t\t\"diff\",\n\t\t\t\"--merge-base\",\n\t\t\t\"--name-status\",\n\t\t\t\"-z\",\n\t\t\t\"--find-renames\",\n\t\t\t\"--no-ext-diff\",\n\t\t\t\"--end-of-options\",\n\t\t\ttarget,\n\t\t\thead,\n\t\t\t\"--\",\n\t\t]);\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve PR base '${target}' and its merge base with HEAD. Set --change-base or fetch the missing branch/history.`,\n\t\t\t{ cause },\n\t\t);\n\t}\n\treturn parseChanges(output);\n}\n\nasync function collectWorkingChanges(\n\tgit: Git,\n\tmode: \"local\" | \"staged\",\n\thead: string | undefined,\n): Promise<RepositoryFile[]> {\n\tif (!head && mode === \"local\") {\n\t\treturn (await readRepositoryFiles(git)).map((path) => ({\n\t\t\tstatus: \"added\",\n\t\t\tpath,\n\t\t}));\n\t}\n\tconst entries = parseChanges(\n\t\tawait git.raw([\n\t\t\t\"diff\",\n\t\t\t\"--name-status\",\n\t\t\t\"-z\",\n\t\t\t\"--find-renames\",\n\t\t\t\"--no-ext-diff\",\n\t\t\t...(mode === \"staged\" ? [\"--cached\"] : []),\n\t\t\t...(head ? [head] : []),\n\t\t\t\"--\",\n\t\t]),\n\t);\n\tif (mode === \"local\") {\n\t\tfor (const path of splitGitPaths(\n\t\t\tawait git.raw([\"ls-files\", \"--others\", \"--exclude-standard\", \"-z\"]),\n\t\t)) {\n\t\t\tentries.push({ status: \"added\", path });\n\t\t}\n\t}\n\treturn entries;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { SimpleGit } from "simple-git";
2
+ /** Split Git's NUL-delimited paths without changing literal filename characters. @internal */
3
+ export declare function splitGitPaths(output: string): string[];
4
+ /** Git's cached inventory includes unstaged deletions; those are not live files. */
5
+ export declare function readRepositoryFiles(git: SimpleGit): Promise<string[]>;
6
+ //# sourceMappingURL=repositoryFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositoryFiles.d.ts","sourceRoot":"","sources":["../src/repositoryFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD;AAED,oFAAoF;AACpF,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ3E"}
@@ -0,0 +1,11 @@
1
+ /** Split Git's NUL-delimited paths without changing literal filename characters. @internal */
2
+ export function splitGitPaths(output) {
3
+ return output.split("\0").filter((path) => path !== "");
4
+ }
5
+ /** Git's cached inventory includes unstaged deletions; those are not live files. */
6
+ export async function readRepositoryFiles(git) {
7
+ const files = splitGitPaths(await git.raw("ls-files", "-co", "-z", "--exclude-standard", "--full-name"));
8
+ const deleted = new Set(splitGitPaths(await git.raw("ls-files", "--deleted", "-z", "--full-name")));
9
+ return files.filter((file) => !deleted.has(file));
10
+ }
11
+ //# sourceMappingURL=repositoryFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositoryFiles.js","sourceRoot":"","sources":["../src/repositoryFiles.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,MAAM,UAAU,aAAa,CAAC,MAAc;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAc;IACvD,MAAM,KAAK,GAAG,aAAa,CAC1B,MAAM,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,aAAa,CAAC,CAC3E,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,GAAG,CACtB,aAAa,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAC1E,CAAC;IACF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { SimpleGit } from \"simple-git\";\n\n/** Split Git's NUL-delimited paths without changing literal filename characters. @internal */\nexport function splitGitPaths(output: string): string[] {\n\treturn output.split(\"\\0\").filter((path) => path !== \"\");\n}\n\n/** Git's cached inventory includes unstaged deletions; those are not live files. */\nexport async function readRepositoryFiles(git: SimpleGit): Promise<string[]> {\n\tconst files = splitGitPaths(\n\t\tawait git.raw(\"ls-files\", \"-co\", \"-z\", \"--exclude-standard\", \"--full-name\"),\n\t);\n\tconst deleted = new Set(\n\t\tsplitGitPaths(await git.raw(\"ls-files\", \"--deleted\", \"-z\", \"--full-name\")),\n\t);\n\treturn files.filter((file) => !deleted.has(file));\n}\n"]}
package/esm/runner.d.ts CHANGED
@@ -1,60 +1,86 @@
1
- import type { Logger } from "@tylerbu/cli-api";
2
1
  import { type Operation } from "effection";
3
- import { type ExcludedPolicyFileMap } from "./context.js";
4
2
  import { type PolicyHandlerPerfStats } from "./perf.js";
5
- import type { PolicyFixResult, PolicyHandlerResult, PolicyInstance, PolicyInstanceId, PolicyName } from "./policy.js";
6
- /**
7
- * Result of running a single policy on a single file.
8
- * @alpha
9
- */
10
- export interface PolicyFileResult {
3
+ import type { ConfiguredPolicy, PolicyFinding } from "./policy.js";
4
+ import { type RepositoryFile } from "./repositoryChanges.js";
5
+ /** A finding with runner-owned identity and scope-safe location. @public */
6
+ export type PolicyRunFinding = (Omit<PolicyFinding, "files"> & {
7
+ scope: "file";
11
8
  file: string;
12
- policy: PolicyName;
13
- /** Stable identity of the configured policy instance */
14
- policyId: PolicyInstanceId;
15
- /** The raw result from the policy handler */
16
- outcome: PolicyHandlerResult;
17
- /** Set when a standalone resolver was attempted (legacy resolver path) */
18
- resolution?: PolicyFixResult;
19
- }
20
- /**
21
- * Aggregated results from a full policy run.
22
- * @alpha
23
- */
9
+ files?: never;
10
+ policy: string;
11
+ policyId: string;
12
+ }) | (PolicyFinding & {
13
+ scope: "repository" | "changes";
14
+ file?: never;
15
+ policy: string;
16
+ policyId: string;
17
+ });
18
+ /** An execution failure, separate from ordinary policy findings. @public */
19
+ export type PolicyExecutionError = {
20
+ policy: string;
21
+ policyId: string;
22
+ phase: "handle" | "resolve";
23
+ kind: "contract" | "exception";
24
+ message: string;
25
+ cause: unknown;
26
+ } & ({
27
+ scope: "file";
28
+ file: string;
29
+ files?: never;
30
+ } | {
31
+ scope: "repository" | "changes";
32
+ files: readonly string[];
33
+ file?: never;
34
+ });
35
+ /** A unit that was not executed. @public */
36
+ export type PolicySkippedWork = {
37
+ policy: string;
38
+ policyId: string;
39
+ reason: "excluded" | "file-fix-error" | "repository-fix-error";
40
+ } & ({
41
+ scope: "file";
42
+ file: string;
43
+ } | {
44
+ scope: "repository" | "changes";
45
+ file?: never;
46
+ });
47
+ /** Findings, failures, skipped units, and file/per-instance timing statistics. @public */
24
48
  export interface PolicyRunResults {
25
- results: PolicyFileResult[];
49
+ findings: PolicyRunFinding[];
50
+ errors: PolicyExecutionError[];
51
+ skipped: PolicySkippedWork[];
26
52
  perfStats: PolicyHandlerPerfStats;
27
53
  }
28
- /**
29
- * Options for configuring a {@link PolicyRunner}.
30
- * @alpha
31
- */
54
+ /** Full repository inventory, never inferred from a file selection. @public */
55
+ export type RepositoryInventory = readonly (string | RepositoryFile)[] | (() => Promise<readonly (string | RepositoryFile)[]>);
56
+ /** Shared Promise and Effection runner options. @public */
32
57
  export interface PolicyRunnerOptions {
33
- policies: PolicyInstance[];
34
- excludeFromAll: RegExp[];
35
- excludePoliciesForFiles: ExcludedPolicyFileMap;
36
- gitRoot: string;
37
- resolve: boolean;
38
- logger?: Pick<Logger, "verbose">;
58
+ policies: readonly ConfiguredPolicy[];
59
+ root: string;
60
+ inventory?: RepositoryInventory | undefined;
61
+ /** Selection limits only file policies. Defaults to inventory when supplied. */
62
+ files?: readonly string[] | undefined;
63
+ exclude?: readonly (string | RegExp)[] | undefined;
64
+ fix?: boolean | undefined;
65
+ concurrency?: number | undefined;
66
+ signal?: AbortSignal | undefined;
39
67
  }
40
- /**
41
- * Runs configured policies against files and collects results.
42
- * @alpha
43
- */
68
+ /** Effection runner; cancellation unwinds active generator handlers and resolvers. @public */
44
69
  export declare class PolicyRunner {
70
+ private readonly options;
45
71
  private readonly policies;
46
- private readonly excludeFromAll;
47
- private readonly excludePoliciesForFiles;
48
- private readonly gitRoot;
49
- private readonly resolve;
50
- private readonly logger;
72
+ private readonly exclusions;
73
+ private readonly policyExclusions;
74
+ private readonly concurrency;
51
75
  constructor(options: PolicyRunnerOptions);
52
- run(filePaths: string[]): Operation<PolicyRunResults>;
53
- private checkOrExcludeFile;
54
- private routeToPolicies;
55
- private runPolicyOnFile;
56
- private isPolicyExcluded;
57
- private executePolicyHandler;
58
- private attemptResolution;
76
+ run(): Operation<PolicyRunResults>;
77
+ private runInternal;
78
+ private runReadOnlyFiles;
79
+ private runRepositories;
80
+ private loadInventory;
81
+ private excluded;
82
+ private runFile;
59
83
  }
84
+ /** Promise entry point sharing the Effection runner's contracts and cancellation. @public */
85
+ export declare function runPolicies(options: PolicyRunnerOptions): Promise<PolicyRunResults>;
60
86
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEN,KAAK,sBAAsB,EAE3B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAEX,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,UAAU,EAEV,MAAM,aAAa,CAAC;AA0BrB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,wDAAwD;IACxD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,6CAA6C;IAC7C,OAAO,EAAE,mBAAmB,CAAC;IAC7B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,SAAS,EAAE,sBAAsB,CAAC;CAClC;AAOD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,cAAc,EAAE,CAAC;I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