@archpilotlabs/archpilot 0.2.2 → 0.2.4

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 (298) hide show
  1. package/CHANGELOG.md +538 -0
  2. package/README.md +1 -0
  3. package/dist/archpilot-cli.js +850 -159
  4. package/dist/cli/src/archpilot-cli.js +5523 -0
  5. package/dist/cli/src/archpilot-cli.js.map +1 -0
  6. package/dist/core/src/adr/adrLoader.js +97 -0
  7. package/dist/core/src/adr/adrLoader.js.map +1 -0
  8. package/dist/core/src/adr/adrParser.js +77 -0
  9. package/dist/core/src/adr/adrParser.js.map +1 -0
  10. package/dist/core/src/adr/adrTemplate.js +45 -0
  11. package/dist/core/src/adr/adrTemplate.js.map +1 -0
  12. package/dist/core/src/adr/adrTypes.js +3 -0
  13. package/dist/core/src/adr/adrTypes.js.map +1 -0
  14. package/dist/core/src/adr/adrValidation.js +160 -0
  15. package/dist/core/src/adr/adrValidation.js.map +1 -0
  16. package/dist/core/src/adr/index.js +9 -0
  17. package/dist/core/src/adr/index.js.map +1 -0
  18. package/dist/core/src/adrManagement.js +174 -0
  19. package/dist/core/src/adrManagement.js.map +1 -0
  20. package/dist/core/src/adrRequirementStatus.js +62 -0
  21. package/dist/core/src/adrRequirementStatus.js.map +1 -0
  22. package/dist/core/src/adrScaffoldGeneration.js +325 -0
  23. package/dist/core/src/adrScaffoldGeneration.js.map +1 -0
  24. package/dist/core/src/apiDesignAnalysis.js +869 -0
  25. package/dist/core/src/apiDesignAnalysis.js.map +1 -0
  26. package/dist/core/src/applicationLayeringAnalysis.js +920 -0
  27. package/dist/core/src/applicationLayeringAnalysis.js.map +1 -0
  28. package/dist/core/src/applyRulePack.js +117 -0
  29. package/dist/core/src/applyRulePack.js.map +1 -0
  30. package/dist/core/src/architectureBaseline.js +271 -0
  31. package/dist/core/src/architectureBaseline.js.map +1 -0
  32. package/dist/core/src/architectureComponentDiscoveryDefaults.js +139 -0
  33. package/dist/core/src/architectureComponentDiscoveryDefaults.js.map +1 -0
  34. package/dist/core/src/architectureDependencyContext.js +316 -0
  35. package/dist/core/src/architectureDependencyContext.js.map +1 -0
  36. package/dist/core/src/architectureDriftDetection.js +96 -0
  37. package/dist/core/src/architectureDriftDetection.js.map +1 -0
  38. package/dist/core/src/architectureDriftTimeline.js +221 -0
  39. package/dist/core/src/architectureDriftTimeline.js.map +1 -0
  40. package/dist/core/src/architectureGovernanceBaseline.js +469 -0
  41. package/dist/core/src/architectureGovernanceBaseline.js.map +1 -0
  42. package/dist/core/src/architectureHealthHistory.js +208 -0
  43. package/dist/core/src/architectureHealthHistory.js.map +1 -0
  44. package/dist/core/src/architectureHealthScore.js +657 -0
  45. package/dist/core/src/architectureHealthScore.js.map +1 -0
  46. package/dist/core/src/architectureInit.js +826 -0
  47. package/dist/core/src/architectureInit.js.map +1 -0
  48. package/dist/core/src/architectureMap.js +727 -0
  49. package/dist/core/src/architectureMap.js.map +1 -0
  50. package/dist/core/src/architectureMigrationPreview.js +467 -0
  51. package/dist/core/src/architectureMigrationPreview.js.map +1 -0
  52. package/dist/core/src/architectureModelRefresh.js +209 -0
  53. package/dist/core/src/architectureModelRefresh.js.map +1 -0
  54. package/dist/core/src/architectureReportWorkflow.js +139 -0
  55. package/dist/core/src/architectureReportWorkflow.js.map +1 -0
  56. package/dist/core/src/architectureValidation.js +3879 -0
  57. package/dist/core/src/architectureValidation.js.map +1 -0
  58. package/dist/core/src/architectureWorkspaceModel.js +166 -0
  59. package/dist/core/src/architectureWorkspaceModel.js.map +1 -0
  60. package/dist/core/src/authorizationTenantAnalysis.js +652 -0
  61. package/dist/core/src/authorizationTenantAnalysis.js.map +1 -0
  62. package/dist/core/src/bootstrapArchitectureConfig.js +150 -0
  63. package/dist/core/src/bootstrapArchitectureConfig.js.map +1 -0
  64. package/dist/core/src/changeRisk/changeRiskAssessment.js +251 -0
  65. package/dist/core/src/changeRisk/changeRiskAssessment.js.map +1 -0
  66. package/dist/core/src/changeRisk/changeRiskTypes.js +3 -0
  67. package/dist/core/src/changeRisk/changeRiskTypes.js.map +1 -0
  68. package/dist/core/src/changeRisk/index.js +6 -0
  69. package/dist/core/src/changeRisk/index.js.map +1 -0
  70. package/dist/core/src/ci/githubInlineAnnotations.js +245 -0
  71. package/dist/core/src/ci/githubInlineAnnotations.js.map +1 -0
  72. package/dist/core/src/ci/githubPrCommentAdapter.js +232 -0
  73. package/dist/core/src/ci/githubPrCommentAdapter.js.map +1 -0
  74. package/dist/core/src/ciWorkflowTemplates.js +1042 -0
  75. package/dist/core/src/ciWorkflowTemplates.js.map +1 -0
  76. package/dist/core/src/compliance/complianceExportBuilder.js +122 -0
  77. package/dist/core/src/compliance/complianceExportBuilder.js.map +1 -0
  78. package/dist/core/src/compliance/complianceExportTypes.js +3 -0
  79. package/dist/core/src/compliance/complianceExportTypes.js.map +1 -0
  80. package/dist/core/src/compliance/complianceExportWriter.js +48 -0
  81. package/dist/core/src/compliance/complianceExportWriter.js.map +1 -0
  82. package/dist/core/src/compliance/complianceRulePackResolver.js +62 -0
  83. package/dist/core/src/compliance/complianceRulePackResolver.js.map +1 -0
  84. package/dist/core/src/config/index.js +17 -0
  85. package/dist/core/src/config/index.js.map +1 -0
  86. package/dist/core/src/config/projectConfig.js +224 -0
  87. package/dist/core/src/config/projectConfig.js.map +1 -0
  88. package/dist/core/src/config/projectIdentity.js +160 -0
  89. package/dist/core/src/config/projectIdentity.js.map +1 -0
  90. package/dist/core/src/dataQueryRiskDetection.js +1203 -0
  91. package/dist/core/src/dataQueryRiskDetection.js.map +1 -0
  92. package/dist/core/src/dependencyValidation.js +2557 -0
  93. package/dist/core/src/dependencyValidation.js.map +1 -0
  94. package/dist/core/src/discoverAdrs.js +15 -0
  95. package/dist/core/src/discoverAdrs.js.map +1 -0
  96. package/dist/core/src/drift/driftComparator.js +49 -0
  97. package/dist/core/src/drift/driftComparator.js.map +1 -0
  98. package/dist/core/src/drift/driftSnapshotLoader.js +136 -0
  99. package/dist/core/src/drift/driftSnapshotLoader.js.map +1 -0
  100. package/dist/core/src/drift/driftSnapshotTypes.js +3 -0
  101. package/dist/core/src/drift/driftSnapshotTypes.js.map +1 -0
  102. package/dist/core/src/drift/driftSnapshotWriter.js +48 -0
  103. package/dist/core/src/drift/driftSnapshotWriter.js.map +1 -0
  104. package/dist/core/src/drift/index.js +6 -0
  105. package/dist/core/src/drift/index.js.map +1 -0
  106. package/dist/core/src/eventArchitectureAnalysis.js +925 -0
  107. package/dist/core/src/eventArchitectureAnalysis.js.map +1 -0
  108. package/dist/core/src/findingTargetResolution.js +117 -0
  109. package/dist/core/src/findingTargetResolution.js.map +1 -0
  110. package/dist/core/src/generateArchitectureDiagrams.js +57 -0
  111. package/dist/core/src/generateArchitectureDiagrams.js.map +1 -0
  112. package/dist/core/src/generateImpactAnalysis.js +366 -0
  113. package/dist/core/src/generateImpactAnalysis.js.map +1 -0
  114. package/dist/core/src/generateOnboardingDocs.js +262 -0
  115. package/dist/core/src/generateOnboardingDocs.js.map +1 -0
  116. package/dist/core/src/governance/cloudConnection.js +203 -0
  117. package/dist/core/src/governance/cloudConnection.js.map +1 -0
  118. package/dist/core/src/governance/governanceContracts.js +129 -0
  119. package/dist/core/src/governance/governanceContracts.js.map +1 -0
  120. package/dist/core/src/governance/governanceGitMetadata.js +78 -0
  121. package/dist/core/src/governance/governanceGitMetadata.js.map +1 -0
  122. package/dist/core/src/governance/governanceUploadClient.js +119 -0
  123. package/dist/core/src/governance/governanceUploadClient.js.map +1 -0
  124. package/dist/core/src/governance/governanceUploadLimitErrorFormatting.js +155 -0
  125. package/dist/core/src/governance/governanceUploadLimitErrorFormatting.js.map +1 -0
  126. package/dist/core/src/governance/governanceUploadPayload.js +439 -0
  127. package/dist/core/src/governance/governanceUploadPayload.js.map +1 -0
  128. package/dist/core/src/governance/runGovernanceUpload.js +103 -0
  129. package/dist/core/src/governance/runGovernanceUpload.js.map +1 -0
  130. package/dist/core/src/impactAnalysisEngine.js +376 -0
  131. package/dist/core/src/impactAnalysisEngine.js.map +1 -0
  132. package/dist/core/src/initializationState.js +99 -0
  133. package/dist/core/src/initializationState.js.map +1 -0
  134. package/dist/core/src/managedArtifacts.js +151 -0
  135. package/dist/core/src/managedArtifacts.js.map +1 -0
  136. package/dist/core/src/moduleContractValidation.js +266 -0
  137. package/dist/core/src/moduleContractValidation.js.map +1 -0
  138. package/dist/core/src/moduleContractsGenerator.js +337 -0
  139. package/dist/core/src/moduleContractsGenerator.js.map +1 -0
  140. package/dist/core/src/moduleDiscovery.js +416 -0
  141. package/dist/core/src/moduleDiscovery.js.map +1 -0
  142. package/dist/core/src/moduleScope.js +426 -0
  143. package/dist/core/src/moduleScope.js.map +1 -0
  144. package/dist/core/src/onboardingGuidance.js +74 -0
  145. package/dist/core/src/onboardingGuidance.js.map +1 -0
  146. package/dist/core/src/operationalLogging.js +7 -0
  147. package/dist/core/src/operationalLogging.js.map +1 -0
  148. package/dist/core/src/packageVersion.js +52 -0
  149. package/dist/core/src/packageVersion.js.map +1 -0
  150. package/dist/core/src/policy/effectivePolicyResolver.js +91 -0
  151. package/dist/core/src/policy/effectivePolicyResolver.js.map +1 -0
  152. package/dist/core/src/policy/exceptionLoader.js +285 -0
  153. package/dist/core/src/policy/exceptionLoader.js.map +1 -0
  154. package/dist/core/src/policy/remotePolicyLoader.js +227 -0
  155. package/dist/core/src/policy/remotePolicyLoader.js.map +1 -0
  156. package/dist/core/src/policy/remotePolicyTypes.js +3 -0
  157. package/dist/core/src/policy/remotePolicyTypes.js.map +1 -0
  158. package/dist/core/src/policy/riskPolicyConfig.js +206 -0
  159. package/dist/core/src/policy/riskPolicyConfig.js.map +1 -0
  160. package/dist/core/src/policy/riskPolicyEnforcement.js +203 -0
  161. package/dist/core/src/policy/riskPolicyEnforcement.js.map +1 -0
  162. package/dist/core/src/policy/riskPolicyExitCode.js +16 -0
  163. package/dist/core/src/policy/riskPolicyExitCode.js.map +1 -0
  164. package/dist/core/src/policy/riskPolicyInitializer.js +90 -0
  165. package/dist/core/src/policy/riskPolicyInitializer.js.map +1 -0
  166. package/dist/core/src/quickFix/quickFixEngine.js +132 -0
  167. package/dist/core/src/quickFix/quickFixEngine.js.map +1 -0
  168. package/dist/core/src/quickFix/quickFixMessaging.js +15 -0
  169. package/dist/core/src/quickFix/quickFixMessaging.js.map +1 -0
  170. package/dist/core/src/quickFix/quickFixProviders.js +87 -0
  171. package/dist/core/src/quickFix/quickFixProviders.js.map +1 -0
  172. package/dist/core/src/quickFix/quickFixTypes.js +3 -0
  173. package/dist/core/src/quickFix/quickFixTypes.js.map +1 -0
  174. package/dist/core/src/remediation/fileHelpers.js +86 -0
  175. package/dist/core/src/remediation/fileHelpers.js.map +1 -0
  176. package/dist/core/src/remediation/fixRegistry.js +645 -0
  177. package/dist/core/src/remediation/fixRegistry.js.map +1 -0
  178. package/dist/core/src/remediation/index.js +8 -0
  179. package/dist/core/src/remediation/index.js.map +1 -0
  180. package/dist/core/src/remediation/remediationEngine.js +207 -0
  181. package/dist/core/src/remediation/remediationEngine.js.map +1 -0
  182. package/dist/core/src/reporting/adrReporter.js +59 -0
  183. package/dist/core/src/reporting/adrReporter.js.map +1 -0
  184. package/dist/core/src/reporting/architectureBaselineReporter.js +64 -0
  185. package/dist/core/src/reporting/architectureBaselineReporter.js.map +1 -0
  186. package/dist/core/src/reporting/architectureDiagramReporter.js +148 -0
  187. package/dist/core/src/reporting/architectureDiagramReporter.js.map +1 -0
  188. package/dist/core/src/reporting/architectureDriftTimelineReporter.js +44 -0
  189. package/dist/core/src/reporting/architectureDriftTimelineReporter.js.map +1 -0
  190. package/dist/core/src/reporting/architectureHealthHistoryReporter.js +51 -0
  191. package/dist/core/src/reporting/architectureHealthHistoryReporter.js.map +1 -0
  192. package/dist/core/src/reporting/architectureMapReporter.js +228 -0
  193. package/dist/core/src/reporting/architectureMapReporter.js.map +1 -0
  194. package/dist/core/src/reporting/architecturePrCommentReporter.js +324 -0
  195. package/dist/core/src/reporting/architecturePrCommentReporter.js.map +1 -0
  196. package/dist/core/src/reporting/architecturePrReviewReporter.js +389 -0
  197. package/dist/core/src/reporting/architecturePrReviewReporter.js.map +1 -0
  198. package/dist/core/src/reporting/architectureReportArtifacts.js +166 -0
  199. package/dist/core/src/reporting/architectureReportArtifacts.js.map +1 -0
  200. package/dist/core/src/reporting/architectureReviewReportGenerator.js +382 -0
  201. package/dist/core/src/reporting/architectureReviewReportGenerator.js.map +1 -0
  202. package/dist/core/src/reporting/architectureReviewReporter.js +1633 -0
  203. package/dist/core/src/reporting/architectureReviewReporter.js.map +1 -0
  204. package/dist/core/src/reporting/architectureRiskAssessment.js +101 -0
  205. package/dist/core/src/reporting/architectureRiskAssessment.js.map +1 -0
  206. package/dist/core/src/reporting/architectureScoreBadge.js +177 -0
  207. package/dist/core/src/reporting/architectureScoreBadge.js.map +1 -0
  208. package/dist/core/src/reporting/architectureSupplementalReporters.js +124 -0
  209. package/dist/core/src/reporting/architectureSupplementalReporters.js.map +1 -0
  210. package/dist/core/src/reporting/changeRiskAssessment.js +6 -0
  211. package/dist/core/src/reporting/changeRiskAssessment.js.map +1 -0
  212. package/dist/core/src/reporting/changeRiskTypes.js +3 -0
  213. package/dist/core/src/reporting/changeRiskTypes.js.map +1 -0
  214. package/dist/core/src/reporting/impactAnalysisReporter.js +111 -0
  215. package/dist/core/src/reporting/impactAnalysisReporter.js.map +1 -0
  216. package/dist/core/src/reporting/onboardingDocsReporter.js +113 -0
  217. package/dist/core/src/reporting/onboardingDocsReporter.js.map +1 -0
  218. package/dist/core/src/reporting/rulePackReporter.js +61 -0
  219. package/dist/core/src/reporting/rulePackReporter.js.map +1 -0
  220. package/dist/core/src/reporting/safetyControlsDetection.js +343 -0
  221. package/dist/core/src/reporting/safetyControlsDetection.js.map +1 -0
  222. package/dist/core/src/resolveRuleAdrs.js +31 -0
  223. package/dist/core/src/resolveRuleAdrs.js.map +1 -0
  224. package/dist/core/src/reviewGenerationWorkflow.js +220 -0
  225. package/dist/core/src/reviewGenerationWorkflow.js.map +1 -0
  226. package/dist/core/src/rulePacks/index.js +17 -0
  227. package/dist/core/src/rulePacks/index.js.map +1 -0
  228. package/dist/core/src/rulePacks/layeredMonolithRulePack.js +45 -0
  229. package/dist/core/src/rulePacks/layeredMonolithRulePack.js.map +1 -0
  230. package/dist/core/src/rulePacks/modularMonolithRulePack.js +41 -0
  231. package/dist/core/src/rulePacks/modularMonolithRulePack.js.map +1 -0
  232. package/dist/core/src/rulePacks/types.js +3 -0
  233. package/dist/core/src/rulePacks/types.js.map +1 -0
  234. package/dist/core/src/setupNextSteps.js +939 -0
  235. package/dist/core/src/setupNextSteps.js.map +1 -0
  236. package/dist/core/src/setupRefresh.js +152 -0
  237. package/dist/core/src/setupRefresh.js.map +1 -0
  238. package/dist/core/src/smartInit/apiDbHintDetection.js +836 -0
  239. package/dist/core/src/smartInit/apiDbHintDetection.js.map +1 -0
  240. package/dist/core/src/smartInit/architectureProposalBuilder.js +1215 -0
  241. package/dist/core/src/smartInit/architectureProposalBuilder.js.map +1 -0
  242. package/dist/core/src/smartInit/architectureStyleDetection.js +472 -0
  243. package/dist/core/src/smartInit/architectureStyleDetection.js.map +1 -0
  244. package/dist/core/src/smartInit/archpilotIgnore.js +139 -0
  245. package/dist/core/src/smartInit/archpilotIgnore.js.map +1 -0
  246. package/dist/core/src/smartInit/componentDetection.js +1084 -0
  247. package/dist/core/src/smartInit/componentDetection.js.map +1 -0
  248. package/dist/core/src/smartInit/implementationProfileResolution.js +53 -0
  249. package/dist/core/src/smartInit/implementationProfileResolution.js.map +1 -0
  250. package/dist/core/src/smartInit/index.js +31 -0
  251. package/dist/core/src/smartInit/index.js.map +1 -0
  252. package/dist/core/src/smartInit/moduleDetection.js +982 -0
  253. package/dist/core/src/smartInit/moduleDetection.js.map +1 -0
  254. package/dist/core/src/smartInit/projectKindDetection.js +437 -0
  255. package/dist/core/src/smartInit/projectKindDetection.js.map +1 -0
  256. package/dist/core/src/smartInit/repoTopologyDetection.js +470 -0
  257. package/dist/core/src/smartInit/repoTopologyDetection.js.map +1 -0
  258. package/dist/core/src/smartInit/runContext.js +112 -0
  259. package/dist/core/src/smartInit/runContext.js.map +1 -0
  260. package/dist/core/src/smartInit/smartInitEngine.js +94 -0
  261. package/dist/core/src/smartInit/smartInitEngine.js.map +1 -0
  262. package/dist/core/src/smartInit/stackDetection.js +503 -0
  263. package/dist/core/src/smartInit/stackDetection.js.map +1 -0
  264. package/dist/core/src/smartInit/toolingHintDetection.js +345 -0
  265. package/dist/core/src/smartInit/toolingHintDetection.js.map +1 -0
  266. package/dist/core/src/sourceScopeClassification.js +83 -0
  267. package/dist/core/src/sourceScopeClassification.js.map +1 -0
  268. package/dist/core/src/stackAdapters.js +2475 -0
  269. package/dist/core/src/stackAdapters.js.map +1 -0
  270. package/dist/core/src/stackMetadata.js +157 -0
  271. package/dist/core/src/stackMetadata.js.map +1 -0
  272. package/dist/core/src/suppressions/index.js +3 -0
  273. package/dist/core/src/suppressions/index.js.map +1 -0
  274. package/dist/core/src/suppressions/suppressionReporter.js +38 -0
  275. package/dist/core/src/suppressions/suppressionReporter.js.map +1 -0
  276. package/dist/core/src/suppressions/suppressionTypes.js +3 -0
  277. package/dist/core/src/suppressions/suppressionTypes.js.map +1 -0
  278. package/dist/core/src/suppressions/suppressionValidator.js +119 -0
  279. package/dist/core/src/suppressions/suppressionValidator.js.map +1 -0
  280. package/dist/core/src/transactionDomainAnalysis.js +1416 -0
  281. package/dist/core/src/transactionDomainAnalysis.js.map +1 -0
  282. package/dist/core/src/validation/changedFilesResolver.js +165 -0
  283. package/dist/core/src/validation/changedFilesResolver.js.map +1 -0
  284. package/dist/core/src/validationProfiling.js +33 -0
  285. package/dist/core/src/validationProfiling.js.map +1 -0
  286. package/dist/core/src/validationRuleExplanations.js +69 -0
  287. package/dist/core/src/validationRuleExplanations.js.map +1 -0
  288. package/dist/core/src/validationSourceInventory.js +200 -0
  289. package/dist/core/src/validationSourceInventory.js.map +1 -0
  290. package/dist/core/src/validationSuppressions.js +231 -0
  291. package/dist/core/src/validationSuppressions.js.map +1 -0
  292. package/dist/core/src/validationTypeScriptAstCache.js +82 -0
  293. package/dist/core/src/validationTypeScriptAstCache.js.map +1 -0
  294. package/dist/core/src/validationWorkflow.js +222 -0
  295. package/dist/core/src/validationWorkflow.js.map +1 -0
  296. package/dist/core/src/workspaceRoot.js +68 -0
  297. package/dist/core/src/workspaceRoot.js.map +1 -0
  298. package/package.json +3 -2
@@ -0,0 +1,939 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.setupNextStepsReportPointerLine = exports.setupNextStepsReportRelativePath = void 0;
37
+ exports.buildSetupNextStepsModel = buildSetupNextStepsModel;
38
+ exports.renderSetupNextStepsMarkdown = renderSetupNextStepsMarkdown;
39
+ exports.renderSetupNextStepsConsole = renderSetupNextStepsConsole;
40
+ exports.writeSetupNextStepsReport = writeSetupNextStepsReport;
41
+ exports.refreshSetupNextStepsForWorkspace = refreshSetupNextStepsForWorkspace;
42
+ const path = __importStar(require("node:path"));
43
+ const node_fs_1 = require("node:fs");
44
+ const ciWorkflowTemplates_1 = require("./ciWorkflowTemplates");
45
+ const adrScaffoldGeneration_1 = require("./adrScaffoldGeneration");
46
+ exports.setupNextStepsReportRelativePath = '.archpilot/reports/setup-next-steps.md';
47
+ exports.setupNextStepsReportPointerLine = 'Next steps updated: .archpilot/reports/setup-next-steps.md';
48
+ function ensureScore(value, min = 0, max = 100) {
49
+ if (!Number.isFinite(value)) {
50
+ return min;
51
+ }
52
+ return Math.min(max, Math.max(min, Math.round(value)));
53
+ }
54
+ async function pathExists(targetPath) {
55
+ try {
56
+ await node_fs_1.promises.access(targetPath);
57
+ return true;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ async function countContractFiles(contractsDir) {
64
+ try {
65
+ const entries = await node_fs_1.promises.readdir(contractsDir, { withFileTypes: true });
66
+ let count = 0;
67
+ for (const entry of entries) {
68
+ if (entry.isFile() && entry.name.toLowerCase().endsWith('.contract.json')) {
69
+ count += 1;
70
+ continue;
71
+ }
72
+ if (entry.isDirectory()) {
73
+ count += await countContractFiles(path.join(contractsDir, entry.name));
74
+ }
75
+ }
76
+ return count;
77
+ }
78
+ catch {
79
+ return 0;
80
+ }
81
+ }
82
+ function countGovernedModulesFromConfig(value) {
83
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
84
+ return 0;
85
+ }
86
+ const typed = value;
87
+ const modules = typed.modules;
88
+ if (Array.isArray(modules)) {
89
+ return modules.filter((entry) => typeof entry === 'string' && entry.trim().length > 0).length;
90
+ }
91
+ if (modules && typeof modules === 'object' && !Array.isArray(modules)) {
92
+ const moduleCount = Object.keys(modules).filter((key) => key.trim().length > 0).length;
93
+ if (moduleCount > 0) {
94
+ return moduleCount;
95
+ }
96
+ }
97
+ const components = typed.components;
98
+ if (Array.isArray(components)) {
99
+ return components.filter((entry) => {
100
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
101
+ return false;
102
+ }
103
+ const component = entry;
104
+ return (typeof component.id === 'string' &&
105
+ component.id.trim().length > 0 &&
106
+ typeof component.path === 'string' &&
107
+ component.path.trim().length > 0 &&
108
+ component.path.trim() !== '.');
109
+ }).length;
110
+ }
111
+ if (components && typeof components === 'object' && !Array.isArray(components)) {
112
+ return Object.entries(components).filter(([key, value]) => {
113
+ if (key.trim().length === 0 || !value || typeof value !== 'object' || Array.isArray(value)) {
114
+ return false;
115
+ }
116
+ const component = value;
117
+ return (typeof component.path === 'string' &&
118
+ component.path.trim().length > 0 &&
119
+ component.path.trim() !== '.');
120
+ }).length;
121
+ }
122
+ return 0;
123
+ }
124
+ async function readGovernedModuleCount(workspaceRoot) {
125
+ const architecturePath = path.join(workspaceRoot, '.archpilot', 'architecture.json');
126
+ try {
127
+ const raw = await node_fs_1.promises.readFile(architecturePath, { encoding: 'utf8' });
128
+ return countGovernedModulesFromConfig(JSON.parse(raw));
129
+ }
130
+ catch {
131
+ return 0;
132
+ }
133
+ }
134
+ async function readValidationStatusFromWorkspace(workspaceRoot) {
135
+ const validationStatusPath = path.join(workspaceRoot, '.archpilot', 'validation-status.json');
136
+ let raw;
137
+ try {
138
+ raw = await node_fs_1.promises.readFile(validationStatusPath, { encoding: 'utf8' });
139
+ }
140
+ catch {
141
+ return undefined;
142
+ }
143
+ try {
144
+ const parsed = JSON.parse(raw);
145
+ if (!parsed || typeof parsed !== 'object') {
146
+ return undefined;
147
+ }
148
+ return parsed;
149
+ }
150
+ catch {
151
+ return undefined;
152
+ }
153
+ }
154
+ async function buildSetupSnapshot(workspaceRoot, validationStatus, options) {
155
+ const archpilotDir = path.join(workspaceRoot, '.archpilot');
156
+ const contractsDir = path.join(archpilotDir, 'contracts');
157
+ const [hasArchitectureConfig, governedModuleCount, hasDependencyRules, hasLayerRules, hasContractsFolder, hasGithubCiWorkflow, detectedBaselineSnapshot, detectedDriftReport, detectedReviewReport] = await Promise.all([
158
+ pathExists(path.join(archpilotDir, 'architecture.json')),
159
+ readGovernedModuleCount(workspaceRoot),
160
+ pathExists(path.join(archpilotDir, 'dependency-rules.json')),
161
+ pathExists(path.join(archpilotDir, 'layer-rules.json')),
162
+ pathExists(contractsDir),
163
+ pathExists(path.join(workspaceRoot, ...ciWorkflowTemplates_1.githubCiWorkflowRelativePath.split('/'))),
164
+ pathExists(path.join(archpilotDir, 'baseline', 'architecture-baseline.json')),
165
+ pathExists(path.join(archpilotDir, 'reports', 'architecture-drift.json')),
166
+ pathExists(path.join(archpilotDir, 'reports', 'architecture-review-report.md')),
167
+ ]);
168
+ const contractFileCount = hasContractsFolder ? await countContractFiles(contractsDir) : 0;
169
+ const hasAdrRelatedFindings = (validationStatus?.results ?? []).some((result) => {
170
+ if (result.passed !== false) {
171
+ return false;
172
+ }
173
+ return typeof result === 'object' && result !== null && typeof result.id === 'string'
174
+ ? (result.id.startsWith('AP-ADR-') || result.id === 'AP-SAFE-001')
175
+ : false;
176
+ });
177
+ const requiredAdrScaffolds = await (0, adrScaffoldGeneration_1.buildRequiredAdrScaffoldSuggestions)(workspaceRoot, {
178
+ ...(validationStatus ? { validationStatus } : {}),
179
+ });
180
+ return {
181
+ hasArchitectureConfig,
182
+ governedModuleCount,
183
+ hasDependencyRules,
184
+ hasLayerRules,
185
+ hasContractsFolder,
186
+ contractFileCount,
187
+ hasGithubCiWorkflow,
188
+ hasBaselineSnapshot: options?.hasBaselineSnapshot ?? detectedBaselineSnapshot,
189
+ hasDriftReport: options?.hasDriftReport ?? detectedDriftReport,
190
+ hasCloudConnection: options?.hasCloudConnection ?? false,
191
+ hasReviewReport: options?.hasReviewReport ?? detectedReviewReport,
192
+ hasAdrRelatedFindings,
193
+ requiredAdrScaffoldCount: requiredAdrScaffolds.length,
194
+ ...(validationStatus ? { validationStatus } : {}),
195
+ };
196
+ }
197
+ function uniqueActions(actions) {
198
+ const seen = new Set();
199
+ const deduped = [];
200
+ for (const action of actions) {
201
+ const key = `${action.command}::${action.inspectorActionId ?? ''}`;
202
+ if (seen.has(key)) {
203
+ continue;
204
+ }
205
+ seen.add(key);
206
+ deduped.push(action);
207
+ }
208
+ return deduped;
209
+ }
210
+ function buildModelFromSnapshot(snapshot, generatedAtUtc, renderContext) {
211
+ const summary = snapshot.validationStatus?.summary;
212
+ const hasValidationStatus = !!snapshot.validationStatus;
213
+ const firstSuccessfulValidationCompleted = hasValidationStatus;
214
+ const failedResults = snapshot.validationStatus?.results?.filter((result) => !result.passed) ?? [];
215
+ const hasFailedFindings = failedResults.length > 0;
216
+ const setupGapCountFromStatus = summary?.setupGaps;
217
+ const hasMissingDependencyRules = !snapshot.hasDependencyRules;
218
+ const hasMissingLayerRules = !snapshot.hasLayerRules;
219
+ const hasMissingContracts = snapshot.contractFileCount === 0;
220
+ const hasGovernedModules = snapshot.governedModuleCount > 0;
221
+ const hasMissingInitialSetupArtifacts = hasMissingDependencyRules || hasMissingLayerRules || (hasGovernedModules && hasMissingContracts);
222
+ const missingGithubCiWorkflow = firstSuccessfulValidationCompleted && !snapshot.hasGithubCiWorkflow;
223
+ const missingAdrScaffolds = firstSuccessfulValidationCompleted &&
224
+ snapshot.hasAdrRelatedFindings &&
225
+ snapshot.requiredAdrScaffoldCount > 0;
226
+ const setupGapCountFromFiles = (hasMissingDependencyRules ? 1 : 0) +
227
+ (hasMissingLayerRules ? 1 : 0) +
228
+ (hasGovernedModules && hasMissingContracts ? 1 : 0);
229
+ const setupGapCount = typeof setupGapCountFromStatus === 'number'
230
+ ? ensureScore(setupGapCountFromStatus, 0, 1000)
231
+ : setupGapCountFromFiles;
232
+ const readinessScore = typeof summary?.readinessScore === 'number'
233
+ ? ensureScore(summary.readinessScore)
234
+ : snapshot.hasArchitectureConfig
235
+ ? ensureScore(100 - setupGapCountFromFiles * 20)
236
+ : 0;
237
+ const architectureHealthScore = typeof summary?.healthScore === 'number' ? ensureScore(summary.healthScore) : undefined;
238
+ const errors = ensureScore(summary?.errors ?? 0, 0, 100000);
239
+ const warnings = ensureScore(summary?.warnings ?? 0, 0, 100000);
240
+ const info = ensureScore(summary?.info ?? 0, 0, 100000);
241
+ const cleanValidation = firstSuccessfulValidationCompleted && !hasFailedFindings && setupGapCount === 0;
242
+ const onboardingState = snapshot.hasArchitectureConfig && firstSuccessfulValidationCompleted && setupGapCount === 0
243
+ ? 'setup-complete'
244
+ : 'setup-incomplete';
245
+ const checklistItems = [
246
+ {
247
+ id: 'initialized',
248
+ label: 'Architecture initialized',
249
+ completed: snapshot.hasArchitectureConfig,
250
+ description: '.archpilot/architecture.json exists.',
251
+ },
252
+ {
253
+ id: 'validated',
254
+ label: 'Validation has run at least once',
255
+ completed: firstSuccessfulValidationCompleted,
256
+ description: 'Validation status is available for setup/readiness guidance.',
257
+ },
258
+ {
259
+ id: 'dependency-rules',
260
+ label: 'Dependency rules config present',
261
+ completed: snapshot.hasDependencyRules,
262
+ description: '.archpilot/dependency-rules.json',
263
+ },
264
+ {
265
+ id: 'layer-rules',
266
+ label: 'Layer rules config present',
267
+ completed: snapshot.hasLayerRules,
268
+ description: '.archpilot/layer-rules.json',
269
+ },
270
+ {
271
+ id: 'contracts',
272
+ label: 'Module contracts generated',
273
+ completed: !hasGovernedModules || snapshot.contractFileCount > 0,
274
+ description: !hasGovernedModules
275
+ ? 'No governed modules configured.'
276
+ : snapshot.contractFileCount > 0
277
+ ? `${snapshot.contractFileCount} contract file(s) found.`
278
+ : 'No .archpilot/contracts/*.contract.json files found.',
279
+ },
280
+ {
281
+ id: 'github-ci-governance',
282
+ label: 'GitHub CI governance workflow present',
283
+ completed: snapshot.hasGithubCiWorkflow,
284
+ description: snapshot.hasGithubCiWorkflow
285
+ ? `${ciWorkflowTemplates_1.githubCiWorkflowRelativePath} exists.`
286
+ : `${ciWorkflowTemplates_1.githubCiWorkflowRelativePath} is missing.`,
287
+ },
288
+ ];
289
+ const setupGithubCiAction = {
290
+ label: 'Setup GitHub CI',
291
+ command: 'ArchPilot: Setup GitHub CI Validation + Upload',
292
+ inspectorActionId: 'setup-github-ci-governance',
293
+ description: 'Run ArchPilot validation on pull requests and validation plus governance upload on main.',
294
+ };
295
+ const generateAdrScaffoldsAction = {
296
+ label: 'Generate ADR Scaffolds',
297
+ command: 'ArchPilot: Generate Required ADR Scaffolds',
298
+ inspectorActionId: 'generate-required-adr-scaffolds',
299
+ description: 'Create ADR templates for missing architecture decisions based on current validation findings.',
300
+ };
301
+ const runValidationAction = {
302
+ label: 'Run Validation',
303
+ command: 'archpilot validate',
304
+ inspectorActionId: 'run-validation',
305
+ runValidation: true,
306
+ description: 'Validate the current architecture and refresh findings, drift inputs, and governance artifacts.',
307
+ };
308
+ const reviewFindingsAction = {
309
+ label: 'Review Findings',
310
+ command: 'Open Findings tab',
311
+ inspectorTab: 'findings',
312
+ description: 'Open Findings to review architecture validation issues and structural problems.',
313
+ };
314
+ const reviewDriftAction = {
315
+ label: 'Review Drift',
316
+ command: 'Open Drift tab',
317
+ inspectorTab: 'drift',
318
+ description: 'Open Drift to compare the current architecture against a saved baseline.',
319
+ };
320
+ const createBaselineAction = {
321
+ label: 'Create Drift Baseline',
322
+ command: 'Create baseline from current architecture',
323
+ driftWorkflowAction: 'create-baseline',
324
+ description: 'Save the current architecture as the reference snapshot for future drift checks.',
325
+ };
326
+ const runDriftCheckAction = {
327
+ label: 'Run Drift Check',
328
+ command: 'Run drift check against baseline',
329
+ driftWorkflowAction: 'run-check',
330
+ description: 'Compare the current architecture against the saved baseline snapshot.',
331
+ };
332
+ const manageCloudAction = {
333
+ label: 'Manage Cloud Connection',
334
+ command: 'ArchPilot: Manage Cloud Connection',
335
+ inspectorActionId: 'manage-cloud-config',
336
+ description: 'Save or update the ArchPilot Cloud API token and upload preference for this repository.',
337
+ };
338
+ const uploadGovernanceAction = {
339
+ label: 'Upload Governance Snapshot Now',
340
+ command: 'ArchPilot: Upload Governance Snapshot Now',
341
+ inspectorActionId: 'upload-governance-snapshot',
342
+ description: 'Upload the latest validated governance snapshot to ArchPilot Cloud.',
343
+ };
344
+ const manageExceptionsAction = {
345
+ label: 'Create Exceptions',
346
+ command: 'ArchPilot: Manage Exceptions',
347
+ inspectorActionId: 'manage-exceptions',
348
+ description: 'Record approved architecture exceptions for acceptable temporary violations.',
349
+ };
350
+ const generateReviewReportAction = {
351
+ label: 'Generate Architecture Review Report',
352
+ command: 'ArchPilot: Generate Review Report',
353
+ inspectorActionId: 'generate-architecture-review-report',
354
+ description: 'Generate a current architecture review report for sharing and governance review.',
355
+ };
356
+ const stages = [];
357
+ let stagedStepCount = 0;
358
+ const pushStage = (stage) => {
359
+ if (stage.steps.length > 0 && stages.length < 4 && stagedStepCount < 6) {
360
+ const availableSlots = Math.max(0, 6 - stagedStepCount);
361
+ const maxStageSteps = stages.length === 0 ? Math.min(4, availableSlots) : Math.min(2, availableSlots);
362
+ const trimmedSteps = stage.steps
363
+ .map((step, index) => ({ step, index }))
364
+ .sort((left, right) => {
365
+ const priorityCompare = (left.step.priority ?? left.index) - (right.step.priority ?? right.index);
366
+ if (priorityCompare !== 0) {
367
+ return priorityCompare;
368
+ }
369
+ return left.index - right.index;
370
+ })
371
+ .slice(0, maxStageSteps)
372
+ .sort((left, right) => left.index - right.index)
373
+ .map((entry) => entry.step);
374
+ if (trimmedSteps.length === 0) {
375
+ return;
376
+ }
377
+ stages.push({
378
+ ...stage,
379
+ steps: trimmedSteps,
380
+ });
381
+ stagedStepCount += trimmedSteps.length;
382
+ }
383
+ };
384
+ if (!snapshot.hasArchitectureConfig) {
385
+ pushStage({
386
+ id: 'setup',
387
+ title: 'Setup',
388
+ description: 'Initialize ArchPilot before validation and governance workflows can guide this repository.',
389
+ steps: [
390
+ {
391
+ id: 'smart-init',
392
+ title: 'Run Smart Init',
393
+ description: 'Detect a deterministic starting architecture proposal for this repository.',
394
+ priority: 1,
395
+ action: {
396
+ label: 'Run Smart Init',
397
+ command: 'archpilot smart-init-proposal',
398
+ description: 'Run ArchPilot Smart Init and review the proposed architecture setup.',
399
+ },
400
+ },
401
+ {
402
+ id: 'review-generated-config',
403
+ title: 'Review generated architecture.json',
404
+ description: 'Confirm project shape, module boundaries, and governance defaults before applying them.',
405
+ priority: 2,
406
+ },
407
+ {
408
+ id: 'define-modules-contracts',
409
+ title: 'Define modules and contracts',
410
+ description: 'Lock in clear architecture boundaries and contract expectations before validation starts.',
411
+ priority: 3,
412
+ },
413
+ ],
414
+ });
415
+ }
416
+ else if (!firstSuccessfulValidationCompleted) {
417
+ pushStage({
418
+ id: hasGovernedModules && hasMissingInitialSetupArtifacts ? 'setup' : 'validate',
419
+ title: hasGovernedModules && hasMissingInitialSetupArtifacts ? 'Setup' : 'Validate',
420
+ description: hasGovernedModules && hasMissingInitialSetupArtifacts
421
+ ? 'Generate missing setup artifacts before the first validation pass.'
422
+ : 'Run the first validation pass to establish findings, readiness, and architecture health.',
423
+ steps: [
424
+ ...(hasGovernedModules && hasMissingInitialSetupArtifacts
425
+ ? [
426
+ {
427
+ id: 'generate-missing-config-contracts',
428
+ title: 'Generate Missing Config & Contracts',
429
+ description: 'Create dependency/layer config and module contracts before first validation.',
430
+ priority: 1,
431
+ action: {
432
+ label: 'Generate Missing Config & Contracts',
433
+ command: 'archpilot bootstrap --with-contracts',
434
+ inspectorActionId: 'bootstrap-config-and-contracts',
435
+ description: 'Create missing setup config and module contracts in one deterministic pass.',
436
+ },
437
+ },
438
+ {
439
+ id: 'run-validation',
440
+ title: 'Run Architecture Validation',
441
+ description: 'Validate after setup artifacts exist to reduce first-run setup noise.',
442
+ priority: 2,
443
+ action: runValidationAction,
444
+ },
445
+ ]
446
+ : [
447
+ {
448
+ id: 'run-validation',
449
+ title: 'Run Architecture Validation',
450
+ description: 'Validate the current architecture and generate findings for the Inspector.',
451
+ priority: 1,
452
+ action: runValidationAction,
453
+ },
454
+ ]),
455
+ {
456
+ id: 'review-findings',
457
+ title: 'Review Findings',
458
+ description: 'Use Findings to inspect architecture violations, policy issues, and structural problems.',
459
+ priority: hasGovernedModules && hasMissingInitialSetupArtifacts ? 3 : 2,
460
+ action: reviewFindingsAction,
461
+ },
462
+ {
463
+ id: 'fix-structural-issues',
464
+ title: 'Fix structural issues',
465
+ description: 'Address the most important module boundary and dependency problems first.',
466
+ priority: hasGovernedModules && hasMissingInitialSetupArtifacts ? 4 : 3,
467
+ },
468
+ ],
469
+ });
470
+ }
471
+ else if (hasFailedFindings) {
472
+ pushStage({
473
+ id: 'validate',
474
+ title: 'Validate',
475
+ description: 'Use the latest findings to drive the next architecture fixes instead of broad generic cleanup.',
476
+ steps: [
477
+ {
478
+ id: 'review-current-findings',
479
+ title: 'Review Findings',
480
+ description: 'Inspect the current architecture findings and identify the highest-impact fixes.',
481
+ priority: 1,
482
+ action: reviewFindingsAction,
483
+ },
484
+ {
485
+ id: 'fix-high-severity',
486
+ title: 'Fix high-severity issues',
487
+ description: 'Resolve error-level findings first to improve architecture health and reduce risk.',
488
+ priority: 2,
489
+ },
490
+ {
491
+ id: 'exceptions',
492
+ title: 'Create Exceptions for acceptable violations',
493
+ description: 'Record approved exceptions only for findings that are intentionally temporary or acceptable.',
494
+ priority: 3,
495
+ action: manageExceptionsAction,
496
+ },
497
+ {
498
+ id: 'rerun-validation',
499
+ title: 'Re-run validation',
500
+ description: 'Refresh findings after fixes or exception updates.',
501
+ priority: 4,
502
+ action: runValidationAction,
503
+ },
504
+ ],
505
+ });
506
+ }
507
+ if (snapshot.hasArchitectureConfig && firstSuccessfulValidationCompleted && !snapshot.hasBaselineSnapshot) {
508
+ pushStage({
509
+ id: 'stabilize',
510
+ title: 'Stabilize',
511
+ description: 'Capture a baseline so drift becomes an explicit part of the architecture workflow.',
512
+ steps: [
513
+ {
514
+ id: 'create-baseline',
515
+ title: 'Create Drift Baseline',
516
+ description: 'Save the current architecture as the reference point for future drift checks.',
517
+ action: createBaselineAction,
518
+ },
519
+ {
520
+ id: 'commit-baseline',
521
+ title: 'Commit baseline snapshot',
522
+ description: 'Commit the generated baseline artifact so future comparisons use a stable reference.',
523
+ },
524
+ ],
525
+ });
526
+ }
527
+ else if (snapshot.hasBaselineSnapshot && !snapshot.hasDriftReport) {
528
+ pushStage({
529
+ id: 'stabilize',
530
+ title: 'Stabilize',
531
+ description: 'Use drift checks to compare the current architecture against the saved baseline.',
532
+ steps: [
533
+ {
534
+ id: 'run-drift-check',
535
+ title: 'Run Drift Check',
536
+ description: 'Compare the current architecture against the baseline snapshot.',
537
+ action: runDriftCheckAction,
538
+ },
539
+ {
540
+ id: 'review-drift-changes',
541
+ title: 'Review Drift Changes',
542
+ description: 'Inspect module and dependency changes surfaced by the drift workflow.',
543
+ action: reviewDriftAction,
544
+ },
545
+ ],
546
+ });
547
+ }
548
+ if (firstSuccessfulValidationCompleted && hasFailedFindings) {
549
+ pushStage({
550
+ id: 'govern',
551
+ title: 'Govern',
552
+ description: 'Use findings to drive governance workflows once the current architecture state is understood.',
553
+ steps: snapshot.hasCloudConnection
554
+ ? [
555
+ {
556
+ id: 'upload-findings',
557
+ title: 'Upload Governance Snapshot to ArchPilot Cloud',
558
+ description: 'Send the latest validated governance snapshot to ArchPilot Cloud for policy and compliance review.',
559
+ action: uploadGovernanceAction,
560
+ },
561
+ {
562
+ id: 'review-governance',
563
+ title: 'Review governance policies',
564
+ description: 'Check how findings align with policy enforcement and governance expectations.',
565
+ action: {
566
+ label: 'Configure Policy Enforcement',
567
+ command: 'ArchPilot: Configure Policy Enforcement',
568
+ inspectorActionId: 'create-policy-file',
569
+ description: 'Review or create local policy enforcement settings.',
570
+ },
571
+ },
572
+ ]
573
+ : [
574
+ {
575
+ id: 'configure-cloud',
576
+ title: 'Connect ArchPilot Cloud',
577
+ description: 'Save the repository Cloud connection before uploading findings and governance snapshots.',
578
+ action: manageCloudAction,
579
+ },
580
+ {
581
+ id: 'track-compliance',
582
+ title: 'Track architecture compliance',
583
+ description: 'Once Cloud is configured, upload governance snapshots to track compliance over time.',
584
+ },
585
+ ],
586
+ });
587
+ }
588
+ if (cleanValidation) {
589
+ pushStage({
590
+ id: 'maintain',
591
+ title: 'Maintain',
592
+ description: 'With setup, validation, and findings in a healthy state, move into repeatable governance workflows.',
593
+ steps: [
594
+ {
595
+ id: 'review-report',
596
+ title: 'Generate Architecture Review Report',
597
+ description: snapshot.hasReviewReport
598
+ ? 'Refresh the architecture review report with the latest healthy validation state.'
599
+ : 'Generate a shareable architecture review report for the current repository state.',
600
+ action: generateReviewReportAction,
601
+ },
602
+ {
603
+ id: 'ci-validation',
604
+ title: 'Set up CI validation',
605
+ description: 'Keep architecture checks running automatically in pull requests and on the main branch.',
606
+ action: setupGithubCiAction,
607
+ },
608
+ {
609
+ id: 'governance-collaboration',
610
+ title: 'Configure governance and team workflows',
611
+ description: 'Connect Cloud, review policies, and share reports so the team can track architecture health together.',
612
+ action: snapshot.hasCloudConnection ? uploadGovernanceAction : manageCloudAction,
613
+ },
614
+ ],
615
+ });
616
+ }
617
+ if (stages.length === 0) {
618
+ pushStage({
619
+ id: 'maintain',
620
+ title: 'Maintain',
621
+ description: 'Keep the architecture workflow active with periodic validation and report refreshes.',
622
+ steps: [
623
+ {
624
+ id: 'rerun-validation-maintenance',
625
+ title: 'Re-run validation',
626
+ description: 'Refresh findings after changes to keep the architecture picture current.',
627
+ action: runValidationAction,
628
+ },
629
+ {
630
+ id: 'review-drift-maintenance',
631
+ title: 'Review drift and history',
632
+ description: 'Use Drift and History together to understand how architecture changes over time.',
633
+ action: reviewDriftAction,
634
+ },
635
+ ],
636
+ });
637
+ }
638
+ const recommendedPrimaryActionBase = !snapshot.hasArchitectureConfig
639
+ ? {
640
+ label: 'Run Smart Init',
641
+ command: 'archpilot smart-init-proposal',
642
+ description: 'Detect and review a deterministic architecture proposal for this repository.',
643
+ }
644
+ : !firstSuccessfulValidationCompleted && hasGovernedModules && hasMissingInitialSetupArtifacts
645
+ ? {
646
+ label: 'Generate Missing Config & Contracts',
647
+ command: 'archpilot bootstrap --with-contracts',
648
+ inspectorActionId: 'bootstrap-config-and-contracts',
649
+ description: 'Create missing setup config and module contracts before the first validation run.',
650
+ }
651
+ : !firstSuccessfulValidationCompleted
652
+ ? runValidationAction
653
+ : setupGapCount > 0
654
+ ? hasMissingDependencyRules || hasMissingLayerRules
655
+ ? {
656
+ label: 'Bootstrap Missing Config',
657
+ command: 'archpilot bootstrap --with-contracts',
658
+ inspectorActionId: 'bootstrap-config-and-contracts',
659
+ description: 'Create missing setup config and contracts in one deterministic pass.',
660
+ }
661
+ : hasGovernedModules && hasMissingContracts
662
+ ? {
663
+ label: 'Generate Contracts',
664
+ command: 'archpilot contracts generate',
665
+ inspectorActionId: 'generate-module-contracts',
666
+ description: 'Generate missing module contracts for discovered modules.',
667
+ }
668
+ : runValidationAction
669
+ : hasFailedFindings
670
+ ? reviewFindingsAction
671
+ : !snapshot.hasBaselineSnapshot
672
+ ? createBaselineAction
673
+ : snapshot.hasBaselineSnapshot && !snapshot.hasDriftReport
674
+ ? runDriftCheckAction
675
+ : missingAdrScaffolds
676
+ ? generateAdrScaffoldsAction
677
+ : missingGithubCiWorkflow
678
+ ? {
679
+ label: 'Set up GitHub CI validation + upload',
680
+ command: 'ArchPilot: Setup GitHub CI Validation + Upload',
681
+ inspectorActionId: 'setup-github-ci-governance',
682
+ description: 'Run ArchPilot validation on pull requests and validation plus governance upload on main.',
683
+ }
684
+ : {
685
+ label: 'Publish Badge',
686
+ command: 'archpilot badges publish',
687
+ inspectorActionId: 'publish-badges',
688
+ description: 'Publish the latest ArchPilot Score badge for repository visibility.',
689
+ };
690
+ const recommendedCommandsBase = uniqueActions(onboardingState === 'setup-incomplete'
691
+ ? [
692
+ recommendedPrimaryActionBase,
693
+ runValidationAction,
694
+ {
695
+ label: 'Bootstrap Missing Config',
696
+ command: 'archpilot bootstrap --with-contracts',
697
+ inspectorActionId: 'bootstrap-config-and-contracts',
698
+ description: 'Generate missing setup config and contracts.',
699
+ },
700
+ {
701
+ label: 'Generate Contracts',
702
+ command: 'archpilot contracts generate',
703
+ inspectorActionId: 'generate-module-contracts',
704
+ description: 'Create missing module contracts from discovered modules.',
705
+ },
706
+ {
707
+ label: 'Review Findings',
708
+ command: 'Open Findings tab',
709
+ inspectorTab: 'findings',
710
+ description: 'Inspect current findings before choosing follow-up fixes or governance steps.',
711
+ },
712
+ createBaselineAction,
713
+ runDriftCheckAction,
714
+ ...(missingAdrScaffolds ? [generateAdrScaffoldsAction] : []),
715
+ ...(snapshot.hasCloudConnection ? [uploadGovernanceAction] : [manageCloudAction]),
716
+ ...(missingGithubCiWorkflow ? [setupGithubCiAction] : []),
717
+ ]
718
+ : [
719
+ recommendedPrimaryActionBase,
720
+ reviewFindingsAction,
721
+ reviewDriftAction,
722
+ ...(missingAdrScaffolds ? [generateAdrScaffoldsAction] : []),
723
+ ...(snapshot.hasCloudConnection ? [uploadGovernanceAction] : [manageCloudAction]),
724
+ ...(missingGithubCiWorkflow ? [setupGithubCiAction] : []),
725
+ {
726
+ label: 'Run CI Validation',
727
+ command: 'archpilot validate --ci',
728
+ description: 'Use CI mode to enforce architecture health in pipelines.',
729
+ },
730
+ {
731
+ label: 'Publish Badge',
732
+ command: 'archpilot badges publish',
733
+ inspectorActionId: 'publish-badges',
734
+ description: 'Refresh the ArchPilot Score badge for README and visibility.',
735
+ },
736
+ {
737
+ label: 'Open Inspector',
738
+ command: 'ArchPilot: Open Architecture Inspector',
739
+ inspectorActionId: 'refresh-inspector',
740
+ description: 'Explore architecture map, drift, findings, and trends.',
741
+ },
742
+ ]);
743
+ const recommendedCommands = recommendedCommandsBase
744
+ .filter((action) => renderContext === 'inspector'
745
+ ? action.command !== 'ArchPilot: Open Architecture Inspector'
746
+ : true)
747
+ .slice(0, onboardingState === 'setup-incomplete' ? 5 : 4);
748
+ const recommendedPrimaryAction = recommendedCommands.find((action) => action.command === recommendedPrimaryActionBase.command) ??
749
+ recommendedPrimaryActionBase;
750
+ const summaryItems = onboardingState === 'setup-incomplete'
751
+ ? [
752
+ !snapshot.hasArchitectureConfig
753
+ ? 'No architecture.json is present yet.'
754
+ : firstSuccessfulValidationCompleted
755
+ ? `Readiness ${readinessScore}/100 with ${setupGapCount} setup gap(s).`
756
+ : 'Architecture config exists, but validation has not run yet.',
757
+ ...(hasFailedFindings
758
+ ? [`Current findings: ${errors} error(s), ${warnings} warning(s), ${info} info.`]
759
+ : []),
760
+ ...(!snapshot.hasBaselineSnapshot
761
+ ? ['No drift baseline exists yet.']
762
+ : snapshot.hasBaselineSnapshot && !snapshot.hasDriftReport
763
+ ? ['Baseline exists, but drift has not been checked yet.']
764
+ : []),
765
+ ...(snapshot.hasCloudConnection
766
+ ? hasFailedFindings
767
+ ? ['ArchPilot Cloud is configured and ready for governance snapshot uploads.']
768
+ : []
769
+ : ['ArchPilot Cloud is not configured yet.']),
770
+ ...(missingAdrScaffolds ? ['Required ADR scaffolds are still missing for current architecture findings.'] : []),
771
+ ...(missingGithubCiWorkflow ? ['GitHub CI governance is not configured yet.'] : []),
772
+ ...(architectureHealthScore !== undefined
773
+ ? [`Architecture health score is ${architectureHealthScore}/100.`]
774
+ : []),
775
+ ]
776
+ : [
777
+ `Readiness ${readinessScore}/100 with no setup gaps.`,
778
+ ...(missingAdrScaffolds ? ['Required ADR scaffolds are still missing for current architecture findings.'] : []),
779
+ ...(missingGithubCiWorkflow ? ['GitHub CI governance is not configured yet.'] : []),
780
+ ...(!snapshot.hasBaselineSnapshot
781
+ ? ['No drift baseline exists yet.']
782
+ : snapshot.hasBaselineSnapshot && !snapshot.hasDriftReport
783
+ ? ['Baseline exists, but drift has not been checked yet.']
784
+ : []),
785
+ ...(architectureHealthScore !== undefined
786
+ ? [`Architecture health score is ${architectureHealthScore}/100.`]
787
+ : []),
788
+ hasFailedFindings
789
+ ? 'Setup is healthy; focus on remaining findings.'
790
+ : 'Setup is healthy; continue normal operating workflows.',
791
+ ];
792
+ const fastestPathToGreen = onboardingState === 'setup-incomplete'
793
+ ? [
794
+ 'Run validation to classify current setup gaps and quality findings.',
795
+ 'Apply deterministic safe fixes when available.',
796
+ 'Bootstrap missing setup artifacts and contracts.',
797
+ ...(missingAdrScaffolds
798
+ ? ['Generate ADR scaffolds for missing architecture decisions before finalizing governance documentation.']
799
+ : []),
800
+ ...(missingGithubCiWorkflow
801
+ ? ['Set up GitHub CI validation + upload so pull requests run `archpilot validate --ci` and main runs validation plus `archpilot governance upload`.']
802
+ : []),
803
+ 'Re-run validation until setup gaps reach zero.',
804
+ ]
805
+ : [
806
+ ...(missingAdrScaffolds
807
+ ? ['Generate ADR scaffolds for missing architecture decisions before finalizing governance documentation.']
808
+ : []),
809
+ ...(missingGithubCiWorkflow
810
+ ? ['Set up GitHub CI validation + upload so pull requests run `archpilot validate --ci` and main runs validation plus `archpilot governance upload`.']
811
+ : []),
812
+ 'Keep validation running in CI (`archpilot validate --ci`).',
813
+ 'Use Inspector for drift/findings exploration.',
814
+ 'Track architecture score trends over time.',
815
+ ];
816
+ return {
817
+ version: 1,
818
+ generatedAtUtc,
819
+ onboardingState,
820
+ autoFocusNextSteps: onboardingState === 'setup-incomplete',
821
+ ...(architectureHealthScore !== undefined ? { architectureHealthScore } : {}),
822
+ setupReadinessScore: readinessScore,
823
+ setupGapCount,
824
+ firstSuccessfulValidationCompleted,
825
+ statusMessage: onboardingState === 'setup-incomplete'
826
+ ? firstSuccessfulValidationCompleted
827
+ ? 'Setup incomplete'
828
+ : 'Onboarding in progress'
829
+ : 'Onboarding complete',
830
+ summaryItems,
831
+ recommendedPrimaryAction,
832
+ recommendedCommands,
833
+ workflowHeading: onboardingState === 'setup-incomplete'
834
+ ? 'Fastest Path To Green'
835
+ : 'Next Recommended Workflows',
836
+ fastestPathToGreen,
837
+ checklistItems,
838
+ stages,
839
+ };
840
+ }
841
+ async function buildSetupNextStepsModel(input) {
842
+ const validationStatus = input.validationStatus ?? (await readValidationStatusFromWorkspace(input.workspaceRoot));
843
+ const snapshot = await buildSetupSnapshot(input.workspaceRoot, validationStatus, {
844
+ ...(typeof input.hasCloudConnection === 'boolean'
845
+ ? { hasCloudConnection: input.hasCloudConnection }
846
+ : {}),
847
+ ...(typeof input.hasBaselineSnapshot === 'boolean'
848
+ ? { hasBaselineSnapshot: input.hasBaselineSnapshot }
849
+ : {}),
850
+ ...(typeof input.hasDriftReport === 'boolean'
851
+ ? { hasDriftReport: input.hasDriftReport }
852
+ : {}),
853
+ ...(typeof input.hasReviewReport === 'boolean'
854
+ ? { hasReviewReport: input.hasReviewReport }
855
+ : {}),
856
+ });
857
+ return buildModelFromSnapshot(snapshot, input.generatedAtUtc ?? new Date().toISOString(), input.renderContext ?? 'report');
858
+ }
859
+ function renderSetupNextStepsMarkdown(model) {
860
+ const lines = [];
861
+ lines.push('<!-- archpilot:managed generated-by=setup-refresh -->');
862
+ lines.push('# ArchPilot Setup Next Steps');
863
+ lines.push('');
864
+ lines.push(`- Generated at: ${model.generatedAtUtc}`);
865
+ lines.push(`- Onboarding state: ${model.onboardingState}`);
866
+ lines.push(`- Setup Readiness Score: ${model.setupReadinessScore} / 100`);
867
+ lines.push(`- Setup Gaps: ${model.setupGapCount}`);
868
+ if (typeof model.architectureHealthScore === 'number') {
869
+ lines.push(`- Architecture Health Score: ${model.architectureHealthScore} / 100`);
870
+ }
871
+ lines.push(`- First successful validation completed: ${model.firstSuccessfulValidationCompleted ? 'yes' : 'no'}`);
872
+ lines.push('');
873
+ lines.push('## Status');
874
+ lines.push(model.statusMessage);
875
+ lines.push('');
876
+ lines.push('## Summary');
877
+ for (const item of model.summaryItems) {
878
+ lines.push(`- ${item}`);
879
+ }
880
+ lines.push('');
881
+ lines.push('## Recommended Primary Action');
882
+ lines.push(`- ${model.recommendedPrimaryAction.label}: \`${model.recommendedPrimaryAction.command}\``);
883
+ if (model.recommendedPrimaryAction.description) {
884
+ lines.push(`- Why: ${model.recommendedPrimaryAction.description}`);
885
+ }
886
+ lines.push('');
887
+ lines.push(`## ${model.workflowHeading}`);
888
+ for (const step of model.fastestPathToGreen) {
889
+ lines.push(`- ${step}`);
890
+ }
891
+ lines.push('');
892
+ lines.push('## Useful Commands');
893
+ for (const action of model.recommendedCommands) {
894
+ const description = action.description ? ` - ${action.description}` : '';
895
+ lines.push(`- \`${action.command}\`${description}`);
896
+ }
897
+ lines.push('');
898
+ lines.push('## Setup Checklist');
899
+ for (const item of model.checklistItems) {
900
+ lines.push(`- [${item.completed ? 'x' : ' '}] ${item.label}`);
901
+ if (item.description) {
902
+ lines.push(` - ${item.description}`);
903
+ }
904
+ }
905
+ lines.push('');
906
+ return `${lines.join('\n')}\n`;
907
+ }
908
+ function renderSetupNextStepsConsole(model) {
909
+ const lines = [];
910
+ lines.push('Suggested Next Steps');
911
+ lines.push(`State: ${model.onboardingState}`);
912
+ lines.push(`Readiness: ${model.setupReadinessScore} / 100`);
913
+ lines.push(`Setup gaps: ${model.setupGapCount}`);
914
+ lines.push('');
915
+ lines.push(`1. ${model.recommendedPrimaryAction.label}: \`${model.recommendedPrimaryAction.command}\``);
916
+ const remaining = model.recommendedCommands
917
+ .filter((action) => action.command !== model.recommendedPrimaryAction.command)
918
+ .slice(0, 3);
919
+ for (const [index, action] of remaining.entries()) {
920
+ lines.push(`${index + 2}. ${action.label}: \`${action.command}\``);
921
+ }
922
+ return `${lines.join('\n')}\n`;
923
+ }
924
+ async function writeSetupNextStepsReport(workspaceRoot, model) {
925
+ const reportPath = path.join(workspaceRoot, exports.setupNextStepsReportRelativePath);
926
+ await node_fs_1.promises.mkdir(path.dirname(reportPath), { recursive: true });
927
+ await node_fs_1.promises.writeFile(reportPath, renderSetupNextStepsMarkdown(model), { encoding: 'utf8' });
928
+ return reportPath;
929
+ }
930
+ async function refreshSetupNextStepsForWorkspace(input) {
931
+ const model = await buildSetupNextStepsModel({
932
+ workspaceRoot: input.workspaceRoot,
933
+ ...(input.validationStatus ? { validationStatus: input.validationStatus } : {}),
934
+ ...(input.generatedAtUtc ? { generatedAtUtc: input.generatedAtUtc } : {}),
935
+ });
936
+ await writeSetupNextStepsReport(input.workspaceRoot, model);
937
+ return model;
938
+ }
939
+ //# sourceMappingURL=setupNextSteps.js.map