@rsaglobaltech/specgate 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/CHANGELOG.md +1016 -0
  2. package/README.md +148 -0
  3. package/bin/specgate.js +2 -0
  4. package/bin/specgate.ts +383 -0
  5. package/dist/bin/specgate.js +342 -0
  6. package/dist/bin/specgate.js.map +1 -0
  7. package/dist/packages/core/src/application/AddRequirementUseCase.js +24 -0
  8. package/dist/packages/core/src/application/AddRequirementUseCase.js.map +1 -0
  9. package/dist/packages/core/src/application/ArchiveChangeUseCase.js +185 -0
  10. package/dist/packages/core/src/application/ArchiveChangeUseCase.js.map +1 -0
  11. package/dist/packages/core/src/application/CheckAgainstLockUseCase.js +134 -0
  12. package/dist/packages/core/src/application/CheckAgainstLockUseCase.js.map +1 -0
  13. package/dist/packages/core/src/application/GenerateAgentPromptUseCase.js +25 -0
  14. package/dist/packages/core/src/application/GenerateAgentPromptUseCase.js.map +1 -0
  15. package/dist/packages/core/src/application/GeneratePlanUseCase.js +135 -0
  16. package/dist/packages/core/src/application/GeneratePlanUseCase.js.map +1 -0
  17. package/dist/packages/core/src/application/LinkRequirementUseCase.js +25 -0
  18. package/dist/packages/core/src/application/LinkRequirementUseCase.js.map +1 -0
  19. package/dist/packages/core/src/application/RemovePackUseCase.js +28 -0
  20. package/dist/packages/core/src/application/RemovePackUseCase.js.map +1 -0
  21. package/dist/packages/core/src/application/UpdateRequirementStatusUseCase.js +37 -0
  22. package/dist/packages/core/src/application/UpdateRequirementStatusUseCase.js.map +1 -0
  23. package/dist/packages/core/src/application/ValidateChangeUseCase.js +86 -0
  24. package/dist/packages/core/src/application/ValidateChangeUseCase.js.map +1 -0
  25. package/dist/packages/core/src/application/ValidateProjectUseCase.js +101 -0
  26. package/dist/packages/core/src/application/ValidateProjectUseCase.js.map +1 -0
  27. package/dist/packages/core/src/application/ports/IDomainPackRepository.js +3 -0
  28. package/dist/packages/core/src/application/ports/IDomainPackRepository.js.map +1 -0
  29. package/dist/packages/core/src/application/ports/IHarnessConfigRepository.js +3 -0
  30. package/dist/packages/core/src/application/ports/IHarnessConfigRepository.js.map +1 -0
  31. package/dist/packages/core/src/application/ports/ILockfileRepository.js +3 -0
  32. package/dist/packages/core/src/application/ports/ILockfileRepository.js.map +1 -0
  33. package/dist/packages/core/src/application/ports/IManifestRepository.js +3 -0
  34. package/dist/packages/core/src/application/ports/IManifestRepository.js.map +1 -0
  35. package/dist/packages/core/src/application/ports/IProjectRepository.js +3 -0
  36. package/dist/packages/core/src/application/ports/IProjectRepository.js.map +1 -0
  37. package/dist/packages/core/src/application/ports/IRequirementGraphRepository.js +3 -0
  38. package/dist/packages/core/src/application/ports/IRequirementGraphRepository.js.map +1 -0
  39. package/dist/packages/core/src/application/ports/ITraceabilityRepository.js +3 -0
  40. package/dist/packages/core/src/application/ports/ITraceabilityRepository.js.map +1 -0
  41. package/dist/packages/core/src/domain/AgentPrompt.js +79 -0
  42. package/dist/packages/core/src/domain/AgentPrompt.js.map +1 -0
  43. package/dist/packages/core/src/domain/ArchivePlan.js +26 -0
  44. package/dist/packages/core/src/domain/ArchivePlan.js.map +1 -0
  45. package/dist/packages/core/src/domain/AuthoringScope.js +48 -0
  46. package/dist/packages/core/src/domain/AuthoringScope.js.map +1 -0
  47. package/dist/packages/core/src/domain/ChangeTemplates.js +133 -0
  48. package/dist/packages/core/src/domain/ChangeTemplates.js.map +1 -0
  49. package/dist/packages/core/src/domain/CucumberMessages.js +256 -0
  50. package/dist/packages/core/src/domain/CucumberMessages.js.map +1 -0
  51. package/dist/packages/core/src/domain/DeclaredArtifacts.js +117 -0
  52. package/dist/packages/core/src/domain/DeclaredArtifacts.js.map +1 -0
  53. package/dist/packages/core/src/domain/DeltaSpec.js +219 -0
  54. package/dist/packages/core/src/domain/DeltaSpec.js.map +1 -0
  55. package/dist/packages/core/src/domain/Diagnostic.js +75 -0
  56. package/dist/packages/core/src/domain/Diagnostic.js.map +1 -0
  57. package/dist/packages/core/src/domain/DomainPack.js +62 -0
  58. package/dist/packages/core/src/domain/DomainPack.js.map +1 -0
  59. package/dist/packages/core/src/domain/EmptyAttempt.js +60 -0
  60. package/dist/packages/core/src/domain/EmptyAttempt.js.map +1 -0
  61. package/dist/packages/core/src/domain/FileChangeSet.js +37 -0
  62. package/dist/packages/core/src/domain/FileChangeSet.js.map +1 -0
  63. package/dist/packages/core/src/domain/Gherkin.js +272 -0
  64. package/dist/packages/core/src/domain/Gherkin.js.map +1 -0
  65. package/dist/packages/core/src/domain/GherkinDialects.js +97 -0
  66. package/dist/packages/core/src/domain/GherkinDialects.js.map +1 -0
  67. package/dist/packages/core/src/domain/GherkinQuality.js +160 -0
  68. package/dist/packages/core/src/domain/GherkinQuality.js.map +1 -0
  69. package/dist/packages/core/src/domain/GherkinTags.js +119 -0
  70. package/dist/packages/core/src/domain/GherkinTags.js.map +1 -0
  71. package/dist/packages/core/src/domain/GitSafety.js +77 -0
  72. package/dist/packages/core/src/domain/GitSafety.js.map +1 -0
  73. package/dist/packages/core/src/domain/HarnessConfig.js +58 -0
  74. package/dist/packages/core/src/domain/HarnessConfig.js.map +1 -0
  75. package/dist/packages/core/src/domain/HarnessReport.js +162 -0
  76. package/dist/packages/core/src/domain/HarnessReport.js.map +1 -0
  77. package/dist/packages/core/src/domain/HarnessRun.js +154 -0
  78. package/dist/packages/core/src/domain/HarnessRun.js.map +1 -0
  79. package/dist/packages/core/src/domain/InboundChange.js +127 -0
  80. package/dist/packages/core/src/domain/InboundChange.js.map +1 -0
  81. package/dist/packages/core/src/domain/Language.js +112 -0
  82. package/dist/packages/core/src/domain/Language.js.map +1 -0
  83. package/dist/packages/core/src/domain/Lockfile.js +64 -0
  84. package/dist/packages/core/src/domain/Lockfile.js.map +1 -0
  85. package/dist/packages/core/src/domain/PackContribution.js +106 -0
  86. package/dist/packages/core/src/domain/PackContribution.js.map +1 -0
  87. package/dist/packages/core/src/domain/PackDelta.js +298 -0
  88. package/dist/packages/core/src/domain/PackDelta.js.map +1 -0
  89. package/dist/packages/core/src/domain/PackSpec.js +481 -0
  90. package/dist/packages/core/src/domain/PackSpec.js.map +1 -0
  91. package/dist/packages/core/src/domain/ProfileMatch.js +87 -0
  92. package/dist/packages/core/src/domain/ProfileMatch.js.map +1 -0
  93. package/dist/packages/core/src/domain/Reconciliation.js +72 -0
  94. package/dist/packages/core/src/domain/Reconciliation.js.map +1 -0
  95. package/dist/packages/core/src/domain/RequirementGraph.js +197 -0
  96. package/dist/packages/core/src/domain/RequirementGraph.js.map +1 -0
  97. package/dist/packages/core/src/domain/RequirementPlan.js +85 -0
  98. package/dist/packages/core/src/domain/RequirementPlan.js.map +1 -0
  99. package/dist/packages/core/src/domain/RequirementReadiness.js +115 -0
  100. package/dist/packages/core/src/domain/RequirementReadiness.js.map +1 -0
  101. package/dist/packages/core/src/domain/RequirementSyntax.js +91 -0
  102. package/dist/packages/core/src/domain/RequirementSyntax.js.map +1 -0
  103. package/dist/packages/core/src/domain/ResumeState.js +115 -0
  104. package/dist/packages/core/src/domain/ResumeState.js.map +1 -0
  105. package/dist/packages/core/src/domain/RunBudget.js +103 -0
  106. package/dist/packages/core/src/domain/RunBudget.js.map +1 -0
  107. package/dist/packages/core/src/domain/SpecDiff.js +48 -0
  108. package/dist/packages/core/src/domain/SpecDiff.js.map +1 -0
  109. package/dist/packages/core/src/domain/SpecParser.js +406 -0
  110. package/dist/packages/core/src/domain/SpecParser.js.map +1 -0
  111. package/dist/packages/core/src/domain/SpecopsManifest.js +90 -0
  112. package/dist/packages/core/src/domain/SpecopsManifest.js.map +1 -0
  113. package/dist/packages/core/src/domain/TraceabilityFormat.js +317 -0
  114. package/dist/packages/core/src/domain/TraceabilityFormat.js.map +1 -0
  115. package/dist/packages/core/src/domain/TraceabilityMatrix.js +200 -0
  116. package/dist/packages/core/src/domain/TraceabilityMatrix.js.map +1 -0
  117. package/dist/packages/core/src/domain/TraceabilityMerge.js +180 -0
  118. package/dist/packages/core/src/domain/TraceabilityMerge.js.map +1 -0
  119. package/dist/packages/core/src/domain/ValidationReport.js +53 -0
  120. package/dist/packages/core/src/domain/ValidationReport.js.map +1 -0
  121. package/dist/packages/core/src/domain/ValueAnnotations.js +138 -0
  122. package/dist/packages/core/src/domain/ValueAnnotations.js.map +1 -0
  123. package/dist/packages/core/src/domain/WriteScope.js +155 -0
  124. package/dist/packages/core/src/domain/WriteScope.js.map +1 -0
  125. package/dist/packages/core/src/domain/YamlLite.js +226 -0
  126. package/dist/packages/core/src/domain/YamlLite.js.map +1 -0
  127. package/dist/packages/core/src/index.js +120 -0
  128. package/dist/packages/core/src/index.js.map +1 -0
  129. package/dist/packages/core/src/infrastructure/ChangeWorkspace.js +276 -0
  130. package/dist/packages/core/src/infrastructure/ChangeWorkspace.js.map +1 -0
  131. package/dist/packages/core/src/infrastructure/ConsoleReporter.js +19 -0
  132. package/dist/packages/core/src/infrastructure/ConsoleReporter.js.map +1 -0
  133. package/dist/packages/core/src/infrastructure/DirectorySnapshot.js +106 -0
  134. package/dist/packages/core/src/infrastructure/DirectorySnapshot.js.map +1 -0
  135. package/dist/packages/core/src/infrastructure/DiskDomainPackRepository.js +57 -0
  136. package/dist/packages/core/src/infrastructure/DiskDomainPackRepository.js.map +1 -0
  137. package/dist/packages/core/src/infrastructure/DiskHarnessConfigRepository.js +58 -0
  138. package/dist/packages/core/src/infrastructure/DiskHarnessConfigRepository.js.map +1 -0
  139. package/dist/packages/core/src/infrastructure/DiskLanguageRepository.js +69 -0
  140. package/dist/packages/core/src/infrastructure/DiskLanguageRepository.js.map +1 -0
  141. package/dist/packages/core/src/infrastructure/DiskLockfileRepository.js +64 -0
  142. package/dist/packages/core/src/infrastructure/DiskLockfileRepository.js.map +1 -0
  143. package/dist/packages/core/src/infrastructure/DiskManifestRepository.js +88 -0
  144. package/dist/packages/core/src/infrastructure/DiskManifestRepository.js.map +1 -0
  145. package/dist/packages/core/src/infrastructure/DiskPackDeltaRepository.js +138 -0
  146. package/dist/packages/core/src/infrastructure/DiskPackDeltaRepository.js.map +1 -0
  147. package/dist/packages/core/src/infrastructure/DiskPackRepository.js +130 -0
  148. package/dist/packages/core/src/infrastructure/DiskPackRepository.js.map +1 -0
  149. package/dist/packages/core/src/infrastructure/DiskProjectRepository.js +127 -0
  150. package/dist/packages/core/src/infrastructure/DiskProjectRepository.js.map +1 -0
  151. package/dist/packages/core/src/infrastructure/DiskRequirementGraphRepository.js +124 -0
  152. package/dist/packages/core/src/infrastructure/DiskRequirementGraphRepository.js.map +1 -0
  153. package/dist/packages/core/src/infrastructure/DiskTraceabilityRepository.js +53 -0
  154. package/dist/packages/core/src/infrastructure/DiskTraceabilityRepository.js.map +1 -0
  155. package/dist/packages/core/src/infrastructure/GitContributionStager.js +99 -0
  156. package/dist/packages/core/src/infrastructure/GitContributionStager.js.map +1 -0
  157. package/dist/packages/core/src/infrastructure/GitMergeDriver.js +103 -0
  158. package/dist/packages/core/src/infrastructure/GitMergeDriver.js.map +1 -0
  159. package/dist/packages/core/src/infrastructure/HarnessConfigFile.js +348 -0
  160. package/dist/packages/core/src/infrastructure/HarnessConfigFile.js.map +1 -0
  161. package/dist/packages/core/src/infrastructure/PackChangeDeposit.js +106 -0
  162. package/dist/packages/core/src/infrastructure/PackChangeDeposit.js.map +1 -0
  163. package/dist/packages/core/src/infrastructure/RemotePackResolver.js +181 -0
  164. package/dist/packages/core/src/infrastructure/RemotePackResolver.js.map +1 -0
  165. package/dist/packages/core/src/infrastructure/SpecopsConfigFile.js +94 -0
  166. package/dist/packages/core/src/infrastructure/SpecopsConfigFile.js.map +1 -0
  167. package/dist/packages/core/test/unit/authoring-scope.test.js +102 -0
  168. package/dist/packages/core/test/unit/authoring-scope.test.js.map +1 -0
  169. package/dist/packages/core/test/unit/change-templates.test.js +96 -0
  170. package/dist/packages/core/test/unit/change-templates.test.js.map +1 -0
  171. package/dist/packages/core/test/unit/cucumber-messages.test.js +232 -0
  172. package/dist/packages/core/test/unit/cucumber-messages.test.js.map +1 -0
  173. package/dist/packages/core/test/unit/declared-artifacts.test.js +124 -0
  174. package/dist/packages/core/test/unit/declared-artifacts.test.js.map +1 -0
  175. package/dist/packages/core/test/unit/empty-attempt.test.js +79 -0
  176. package/dist/packages/core/test/unit/empty-attempt.test.js.map +1 -0
  177. package/dist/packages/core/test/unit/gherkin-dialects.test.js +115 -0
  178. package/dist/packages/core/test/unit/gherkin-dialects.test.js.map +1 -0
  179. package/dist/packages/core/test/unit/gherkin-keyword-case.test.js +110 -0
  180. package/dist/packages/core/test/unit/gherkin-keyword-case.test.js.map +1 -0
  181. package/dist/packages/core/test/unit/gherkin-quality.test.js +151 -0
  182. package/dist/packages/core/test/unit/gherkin-quality.test.js.map +1 -0
  183. package/dist/packages/core/test/unit/gherkin-tags.test.js +127 -0
  184. package/dist/packages/core/test/unit/gherkin-tags.test.js.map +1 -0
  185. package/dist/packages/core/test/unit/git-safety.test.js +104 -0
  186. package/dist/packages/core/test/unit/git-safety.test.js.map +1 -0
  187. package/dist/packages/core/test/unit/harness-report.test.js +192 -0
  188. package/dist/packages/core/test/unit/harness-report.test.js.map +1 -0
  189. package/dist/packages/core/test/unit/harness-roles.test.js +86 -0
  190. package/dist/packages/core/test/unit/harness-roles.test.js.map +1 -0
  191. package/dist/packages/core/test/unit/inbound-change.test.js +145 -0
  192. package/dist/packages/core/test/unit/inbound-change.test.js.map +1 -0
  193. package/dist/packages/core/test/unit/matrix-dependencies.test.js +100 -0
  194. package/dist/packages/core/test/unit/matrix-dependencies.test.js.map +1 -0
  195. package/dist/packages/core/test/unit/profile-match.test.js +115 -0
  196. package/dist/packages/core/test/unit/profile-match.test.js.map +1 -0
  197. package/dist/packages/core/test/unit/reconciliation.test.js +112 -0
  198. package/dist/packages/core/test/unit/reconciliation.test.js.map +1 -0
  199. package/dist/packages/core/test/unit/requirement-readiness.test.js +161 -0
  200. package/dist/packages/core/test/unit/requirement-readiness.test.js.map +1 -0
  201. package/dist/packages/core/test/unit/resume-state.test.js +124 -0
  202. package/dist/packages/core/test/unit/resume-state.test.js.map +1 -0
  203. package/dist/packages/core/test/unit/run-budget.test.js +113 -0
  204. package/dist/packages/core/test/unit/run-budget.test.js.map +1 -0
  205. package/dist/packages/core/test/unit/traceability-merge.test.js +159 -0
  206. package/dist/packages/core/test/unit/traceability-merge.test.js.map +1 -0
  207. package/dist/packages/core/test/unit/validate-project.test.js +156 -0
  208. package/dist/packages/core/test/unit/validate-project.test.js.map +1 -0
  209. package/dist/packages/core/test/unit/value-annotations.test.js +149 -0
  210. package/dist/packages/core/test/unit/value-annotations.test.js.map +1 -0
  211. package/dist/packages/core/test/unit/write-scope.test.js +165 -0
  212. package/dist/packages/core/test/unit/write-scope.test.js.map +1 -0
  213. package/dist/packages/core/test/unit/yaml-lite.test.js +78 -0
  214. package/dist/packages/core/test/unit/yaml-lite.test.js.map +1 -0
  215. package/dist/scripts/adopt_project.js +11 -0
  216. package/dist/scripts/adopt_project.js.map +1 -0
  217. package/dist/scripts/agents/commands.js +100 -0
  218. package/dist/scripts/agents/commands.js.map +1 -0
  219. package/dist/scripts/agents/init.js +482 -0
  220. package/dist/scripts/agents/init.js.map +1 -0
  221. package/dist/scripts/alm/cli.js +154 -0
  222. package/dist/scripts/alm/cli.js.map +1 -0
  223. package/dist/scripts/alm/clients.js +30 -0
  224. package/dist/scripts/alm/clients.js.map +1 -0
  225. package/dist/scripts/alm/core.js +258 -0
  226. package/dist/scripts/alm/core.js.map +1 -0
  227. package/dist/scripts/alm/port.js +116 -0
  228. package/dist/scripts/alm/port.js.map +1 -0
  229. package/dist/scripts/alm/providers/azure.js +79 -0
  230. package/dist/scripts/alm/providers/azure.js.map +1 -0
  231. package/dist/scripts/alm/providers/github.js +124 -0
  232. package/dist/scripts/alm/providers/github.js.map +1 -0
  233. package/dist/scripts/alm/providers/http-client.js +47 -0
  234. package/dist/scripts/alm/providers/http-client.js.map +1 -0
  235. package/dist/scripts/alm/providers/index.js +107 -0
  236. package/dist/scripts/alm/providers/index.js.map +1 -0
  237. package/dist/scripts/alm/providers/jira.js +129 -0
  238. package/dist/scripts/alm/providers/jira.js.map +1 -0
  239. package/dist/scripts/bundle_pack.js +10 -0
  240. package/dist/scripts/bundle_pack.js.map +1 -0
  241. package/dist/scripts/change/archive.js +68 -0
  242. package/dist/scripts/change/archive.js.map +1 -0
  243. package/dist/scripts/change/artifacts.js +143 -0
  244. package/dist/scripts/change/artifacts.js.map +1 -0
  245. package/dist/scripts/change/cli.js +39 -0
  246. package/dist/scripts/change/cli.js.map +1 -0
  247. package/dist/scripts/change/delta.js +20 -0
  248. package/dist/scripts/change/delta.js.map +1 -0
  249. package/dist/scripts/change/instructions.js +339 -0
  250. package/dist/scripts/change/instructions.js.map +1 -0
  251. package/dist/scripts/ci_init.js +12 -0
  252. package/dist/scripts/ci_init.js.map +1 -0
  253. package/dist/scripts/cli/commands/alm/PullCommand.js +238 -0
  254. package/dist/scripts/cli/commands/alm/PullCommand.js.map +1 -0
  255. package/dist/scripts/cli/commands/change/ChangeCommand.js +867 -0
  256. package/dist/scripts/cli/commands/change/ChangeCommand.js.map +1 -0
  257. package/dist/scripts/cli/commands/config/CiInitCommand.js +144 -0
  258. package/dist/scripts/cli/commands/config/CiInitCommand.js.map +1 -0
  259. package/dist/scripts/cli/commands/config/CompletionCommand.js +160 -0
  260. package/dist/scripts/cli/commands/config/CompletionCommand.js.map +1 -0
  261. package/dist/scripts/cli/commands/config/ConfigInitCommand.js +108 -0
  262. package/dist/scripts/cli/commands/config/ConfigInitCommand.js.map +1 -0
  263. package/dist/scripts/cli/commands/config/ConfigSetCommand.js +166 -0
  264. package/dist/scripts/cli/commands/config/ConfigSetCommand.js.map +1 -0
  265. package/dist/scripts/cli/commands/config/GenAgentContractCommand.js +212 -0
  266. package/dist/scripts/cli/commands/config/GenAgentContractCommand.js.map +1 -0
  267. package/dist/scripts/cli/commands/harness/RunCommand.js +1922 -0
  268. package/dist/scripts/cli/commands/harness/RunCommand.js.map +1 -0
  269. package/dist/scripts/cli/commands/mcp/McpInstallCommand.js +114 -0
  270. package/dist/scripts/cli/commands/mcp/McpInstallCommand.js.map +1 -0
  271. package/dist/scripts/cli/commands/mcp/index.js +29 -0
  272. package/dist/scripts/cli/commands/mcp/index.js.map +1 -0
  273. package/dist/scripts/cli/commands/pack/BundlePackCommand.js +59 -0
  274. package/dist/scripts/cli/commands/pack/BundlePackCommand.js.map +1 -0
  275. package/dist/scripts/cli/commands/pack/ExpandDomainPackCommand.js +559 -0
  276. package/dist/scripts/cli/commands/pack/ExpandDomainPackCommand.js.map +1 -0
  277. package/dist/scripts/cli/commands/pack/InferPackCommand.js +304 -0
  278. package/dist/scripts/cli/commands/pack/InferPackCommand.js.map +1 -0
  279. package/dist/scripts/cli/commands/pack/InitPackCommand.js +368 -0
  280. package/dist/scripts/cli/commands/pack/InitPackCommand.js.map +1 -0
  281. package/dist/scripts/cli/commands/pack/LintPackCommand.js +631 -0
  282. package/dist/scripts/cli/commands/pack/LintPackCommand.js.map +1 -0
  283. package/dist/scripts/cli/commands/pack/pack-args.js +83 -0
  284. package/dist/scripts/cli/commands/pack/pack-args.js.map +1 -0
  285. package/dist/scripts/cli/commands/project/AdoptCommand.js +414 -0
  286. package/dist/scripts/cli/commands/project/AdoptCommand.js.map +1 -0
  287. package/dist/scripts/cli/commands/project/InitFromPackCommand.js +188 -0
  288. package/dist/scripts/cli/commands/project/InitFromPackCommand.js.map +1 -0
  289. package/dist/scripts/cli/commands/project/InitProjectCommand.js +791 -0
  290. package/dist/scripts/cli/commands/project/InitProjectCommand.js.map +1 -0
  291. package/dist/scripts/cli/commands/project/OnboardCommand.js +655 -0
  292. package/dist/scripts/cli/commands/project/OnboardCommand.js.map +1 -0
  293. package/dist/scripts/cli/commands/project/UpdateCommand.js +206 -0
  294. package/dist/scripts/cli/commands/project/UpdateCommand.js.map +1 -0
  295. package/dist/scripts/cli/commands/project/WizardCommand.js +166 -0
  296. package/dist/scripts/cli/commands/project/WizardCommand.js.map +1 -0
  297. package/dist/scripts/cli/commands/quality/DoctorCommand.js +553 -0
  298. package/dist/scripts/cli/commands/quality/DoctorCommand.js.map +1 -0
  299. package/dist/scripts/cli/commands/quality/FixCommand.js +201 -0
  300. package/dist/scripts/cli/commands/quality/FixCommand.js.map +1 -0
  301. package/dist/scripts/cli/commands/quality/LicenseCheckCommand.js +187 -0
  302. package/dist/scripts/cli/commands/quality/LicenseCheckCommand.js.map +1 -0
  303. package/dist/scripts/cli/commands/quality/ReportCommand.js +557 -0
  304. package/dist/scripts/cli/commands/quality/ReportCommand.js.map +1 -0
  305. package/dist/scripts/cli/commands/quality/ValidateSpecsCommand.js +764 -0
  306. package/dist/scripts/cli/commands/quality/ValidateSpecsCommand.js.map +1 -0
  307. package/dist/scripts/cli/commands/spec/DoneCommand.js +116 -0
  308. package/dist/scripts/cli/commands/spec/DoneCommand.js.map +1 -0
  309. package/dist/scripts/cli/commands/spec/PlanCommand.js +397 -0
  310. package/dist/scripts/cli/commands/spec/PlanCommand.js.map +1 -0
  311. package/dist/scripts/cli/commands/spec/ReqCommand.js +303 -0
  312. package/dist/scripts/cli/commands/spec/ReqCommand.js.map +1 -0
  313. package/dist/scripts/cli/commands/spec/StatusCommand.js +206 -0
  314. package/dist/scripts/cli/commands/spec/StatusCommand.js.map +1 -0
  315. package/dist/scripts/cli/commands/spec/StudioCommand.js +241 -0
  316. package/dist/scripts/cli/commands/spec/StudioCommand.js.map +1 -0
  317. package/dist/scripts/cli/commands/specops/ContributeCommand.js +313 -0
  318. package/dist/scripts/cli/commands/specops/ContributeCommand.js.map +1 -0
  319. package/dist/scripts/cli/commands/specops/DiffCommand.js +394 -0
  320. package/dist/scripts/cli/commands/specops/DiffCommand.js.map +1 -0
  321. package/dist/scripts/cli/commands/specops/SyncCommand.js +380 -0
  322. package/dist/scripts/cli/commands/specops/SyncCommand.js.map +1 -0
  323. package/dist/scripts/completion.js +24 -0
  324. package/dist/scripts/completion.js.map +1 -0
  325. package/dist/scripts/config_init.js +12 -0
  326. package/dist/scripts/config_init.js.map +1 -0
  327. package/dist/scripts/config_set.js +20 -0
  328. package/dist/scripts/config_set.js.map +1 -0
  329. package/dist/scripts/docs/blocks.js +137 -0
  330. package/dist/scripts/docs/blocks.js.map +1 -0
  331. package/dist/scripts/docs/build-site.js +425 -0
  332. package/dist/scripts/docs/build-site.js.map +1 -0
  333. package/dist/scripts/docs/nav.js +198 -0
  334. package/dist/scripts/docs/nav.js.map +1 -0
  335. package/dist/scripts/docs/record-terminal.js +477 -0
  336. package/dist/scripts/docs/record-terminal.js.map +1 -0
  337. package/dist/scripts/docs/terminal-storyboard.js +121 -0
  338. package/dist/scripts/docs/terminal-storyboard.js.map +1 -0
  339. package/dist/scripts/doctor.js +14 -0
  340. package/dist/scripts/doctor.js.map +1 -0
  341. package/dist/scripts/done.js +17 -0
  342. package/dist/scripts/done.js.map +1 -0
  343. package/dist/scripts/expand_domain_pack.js +18 -0
  344. package/dist/scripts/expand_domain_pack.js.map +1 -0
  345. package/dist/scripts/fix.js +12 -0
  346. package/dist/scripts/fix.js.map +1 -0
  347. package/dist/scripts/gen_agent_contract.js +14 -0
  348. package/dist/scripts/gen_agent_contract.js.map +1 -0
  349. package/dist/scripts/gen_mcp_tools.js +264 -0
  350. package/dist/scripts/gen_mcp_tools.js.map +1 -0
  351. package/dist/scripts/harness/init.js +358 -0
  352. package/dist/scripts/harness/init.js.map +1 -0
  353. package/dist/scripts/harness/prompt.js +18 -0
  354. package/dist/scripts/harness/prompt.js.map +1 -0
  355. package/dist/scripts/harness/report.js +323 -0
  356. package/dist/scripts/harness/report.js.map +1 -0
  357. package/dist/scripts/harness/run.js +33 -0
  358. package/dist/scripts/harness/run.js.map +1 -0
  359. package/dist/scripts/infer_pack.js +17 -0
  360. package/dist/scripts/infer_pack.js.map +1 -0
  361. package/dist/scripts/init_from_pack.js +16 -0
  362. package/dist/scripts/init_from_pack.js.map +1 -0
  363. package/dist/scripts/init_pack.js +16 -0
  364. package/dist/scripts/init_pack.js.map +1 -0
  365. package/dist/scripts/init_project.js +17 -0
  366. package/dist/scripts/init_project.js.map +1 -0
  367. package/dist/scripts/lib/agent.js +99 -0
  368. package/dist/scripts/lib/agent.js.map +1 -0
  369. package/dist/scripts/lib/capability-specs.js +80 -0
  370. package/dist/scripts/lib/capability-specs.js.map +1 -0
  371. package/dist/scripts/lib/command.js +17 -0
  372. package/dist/scripts/lib/command.js.map +1 -0
  373. package/dist/scripts/lib/diagnostics.js +62 -0
  374. package/dist/scripts/lib/diagnostics.js.map +1 -0
  375. package/dist/scripts/lib/monorepo-fanout.js +118 -0
  376. package/dist/scripts/lib/monorepo-fanout.js.map +1 -0
  377. package/dist/scripts/lib/placeholders.js +190 -0
  378. package/dist/scripts/lib/placeholders.js.map +1 -0
  379. package/dist/scripts/lib/project-root.js +124 -0
  380. package/dist/scripts/lib/project-root.js.map +1 -0
  381. package/dist/scripts/lib/requirement-graph.js +31 -0
  382. package/dist/scripts/lib/requirement-graph.js.map +1 -0
  383. package/dist/scripts/lib/surface.js +609 -0
  384. package/dist/scripts/lib/surface.js.map +1 -0
  385. package/dist/scripts/license_check.js +15 -0
  386. package/dist/scripts/license_check.js.map +1 -0
  387. package/dist/scripts/lint_pack.js +18 -0
  388. package/dist/scripts/lint_pack.js.map +1 -0
  389. package/dist/scripts/merge-traceability.js +106 -0
  390. package/dist/scripts/merge-traceability.js.map +1 -0
  391. package/dist/scripts/onboard.js +22 -0
  392. package/dist/scripts/onboard.js.map +1 -0
  393. package/dist/scripts/plan.js +17 -0
  394. package/dist/scripts/plan.js.map +1 -0
  395. package/dist/scripts/plugin/gate-hook.js +171 -0
  396. package/dist/scripts/plugin/gate-hook.js.map +1 -0
  397. package/dist/scripts/report.js +17 -0
  398. package/dist/scripts/report.js.map +1 -0
  399. package/dist/scripts/req.js +22 -0
  400. package/dist/scripts/req.js.map +1 -0
  401. package/dist/scripts/schema/cli.js +215 -0
  402. package/dist/scripts/schema/cli.js.map +1 -0
  403. package/dist/scripts/schema/registry.js +264 -0
  404. package/dist/scripts/schema/registry.js.map +1 -0
  405. package/dist/scripts/specops/add.js +180 -0
  406. package/dist/scripts/specops/add.js.map +1 -0
  407. package/dist/scripts/specops/against_lock.js +100 -0
  408. package/dist/scripts/specops/against_lock.js.map +1 -0
  409. package/dist/scripts/specops/as_change.js +49 -0
  410. package/dist/scripts/specops/as_change.js.map +1 -0
  411. package/dist/scripts/specops/contribute.js +24 -0
  412. package/dist/scripts/specops/contribute.js.map +1 -0
  413. package/dist/scripts/specops/diff.js +32 -0
  414. package/dist/scripts/specops/diff.js.map +1 -0
  415. package/dist/scripts/specops/lock.js +39 -0
  416. package/dist/scripts/specops/lock.js.map +1 -0
  417. package/dist/scripts/specops/manifest.js +90 -0
  418. package/dist/scripts/specops/manifest.js.map +1 -0
  419. package/dist/scripts/specops/remove.js +102 -0
  420. package/dist/scripts/specops/remove.js.map +1 -0
  421. package/dist/scripts/specops/sync.js +27 -0
  422. package/dist/scripts/specops/sync.js.map +1 -0
  423. package/dist/scripts/specops/verify.js +149 -0
  424. package/dist/scripts/specops/verify.js.map +1 -0
  425. package/dist/scripts/status.js +17 -0
  426. package/dist/scripts/status.js.map +1 -0
  427. package/dist/scripts/studio.js +14 -0
  428. package/dist/scripts/studio.js.map +1 -0
  429. package/dist/scripts/update.js +17 -0
  430. package/dist/scripts/update.js.map +1 -0
  431. package/dist/scripts/validate_specs.js +10 -0
  432. package/dist/scripts/validate_specs.js.map +1 -0
  433. package/examples/project.config.example +19 -0
  434. package/examples/project.yaml.example +17 -0
  435. package/package.json +105 -0
  436. package/templates/adopt/AI_RULES.md.tpl +27 -0
  437. package/templates/adopt/adr-readme.md.tpl +5 -0
  438. package/templates/adopt/baseline.feature.tpl +9 -0
  439. package/templates/adopt/spec.md.tpl +25 -0
  440. package/templates/adopt/traceability.md.tpl +11 -0
  441. package/templates/backend/AI_RULES.md.tpl +35 -0
  442. package/templates/backend/features/core/health.feature.tpl +7 -0
  443. package/templates/base/.devcontainer/devcontainer.json.tpl +18 -0
  444. package/templates/base/.dockerignore.tpl +11 -0
  445. package/templates/base/.env.dev.app.tpl +13 -0
  446. package/templates/base/.env.dev.infra.tpl +6 -0
  447. package/templates/base/.env.dev.tpl +16 -0
  448. package/templates/base/.env.example.tpl +17 -0
  449. package/templates/base/.env.feature.app.tpl +11 -0
  450. package/templates/base/.env.feature.infra.tpl +4 -0
  451. package/templates/base/.env.feature.tpl +16 -0
  452. package/templates/base/.env.prod.app.tpl +13 -0
  453. package/templates/base/.env.prod.infra.tpl +6 -0
  454. package/templates/base/.env.prod.tpl +16 -0
  455. package/templates/base/.github/workflows/specs.yml.tpl +26 -0
  456. package/templates/base/.gitignore.tpl +9 -0
  457. package/templates/base/.pre-commit-config.yaml.tpl +10 -0
  458. package/templates/base/AGENTS.md.tpl +32 -0
  459. package/templates/base/README.md.tpl +32 -0
  460. package/templates/base/docker-compose.yml.tpl +13 -0
  461. package/templates/base/docs/specs/adr/README.md.tpl +10 -0
  462. package/templates/base/docs/specs/aggregates.md.tpl +5 -0
  463. package/templates/base/docs/specs/commands.md.tpl +13 -0
  464. package/templates/base/docs/specs/domain-model.md.tpl +30 -0
  465. package/templates/base/docs/specs/events.md.tpl +5 -0
  466. package/templates/base/docs/specs/review-checklist.md.tpl +18 -0
  467. package/templates/base/docs/specs/runtime-environments.md.tpl +26 -0
  468. package/templates/base/docs/specs/status-model.md.tpl +16 -0
  469. package/templates/base/docs/specs/traceability.md.tpl +7 -0
  470. package/templates/base/docs/specs/use-cases.md.tpl +5 -0
  471. package/templates/base/spec.md.tpl +63 -0
  472. package/templates/ci/azure.yml.tpl +40 -0
  473. package/templates/ci/github.yml.tpl +40 -0
  474. package/templates/ci/gitlab.yml.tpl +21 -0
  475. package/templates/ci/jenkins.tpl +35 -0
  476. package/templates/contracts/AI_RULES.md.tpl +55 -0
  477. package/templates/contracts/asyncapi-stub.yaml.tpl +24 -0
  478. package/templates/contracts/contract-traceability.md.tpl +10 -0
  479. package/templates/contracts/openapi-stub.yaml.tpl +29 -0
  480. package/templates/contracts/pacts-gitkeep.tpl +0 -0
  481. package/templates/contracts/test-strategy.md.tpl +94 -0
  482. package/templates/frontend/AI_RULES.md.tpl +34 -0
  483. package/templates/frontend/features/core/health.feature.tpl +6 -0
  484. package/templates/harness/harness.config.yaml.tpl +74 -0
  485. package/templates/harness/prompt-prefix.md.tpl +60 -0
  486. package/templates/mobile/AI_RULES.md.tpl +56 -0
  487. package/templates/mobile/features/core/health.feature.tpl +7 -0
  488. package/templates/modules/auth/backend/registration_and_login.feature.tpl +10 -0
  489. package/templates/modules/auth/frontend/login.feature.tpl +5 -0
  490. package/templates/modules/billing/backend/billing_settlement.feature.tpl +5 -0
  491. package/templates/modules/billing/frontend/billing_summary.feature.tpl +5 -0
  492. package/templates/modules/dashboard/backend/dashboard_kpi.feature.tpl +5 -0
  493. package/templates/modules/dashboard/frontend/dashboard.feature.tpl +5 -0
  494. package/vendor/mermaid.min.js +3636 -0
@@ -0,0 +1,655 @@
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.OnboardCommand = exports.BUILD_OUTPUT = exports.NOT_DOMAIN = void 0;
37
+ exports.descendThroughWrappers = descendThroughWrappers;
38
+ exports.findDeclaredModules = findDeclaredModules;
39
+ exports.looksLayered = looksLayered;
40
+ exports.titleCase = titleCase;
41
+ exports.proposeCapabilities = proposeCapabilities;
42
+ exports.findAdoptedAncestor = findAdoptedAncestor;
43
+ const fs = __importStar(require("node:fs"));
44
+ const path = __importStar(require("node:path"));
45
+ const diagnostics_1 = require("../../../lib/diagnostics");
46
+ const agent_1 = require("../../../lib/agent");
47
+ const AdoptCommand_1 = require("./AdoptCommand");
48
+ const command_1 = require("../../../lib/command");
49
+ const COLOR = process.stdout.isTTY && process.env.NO_COLOR === undefined && process.env.TERM !== "dumb";
50
+ const c = {
51
+ reset: COLOR ? "\x1b[0m" : "",
52
+ bold: COLOR ? "\x1b[1m" : "",
53
+ dim: COLOR ? "\x1b[2m" : "",
54
+ green: COLOR ? "\x1b[32m" : "",
55
+ cyan: COLOR ? "\x1b[36m" : "",
56
+ };
57
+ exports.NOT_DOMAIN = new Set([
58
+ "node_modules",
59
+ "dist",
60
+ "build",
61
+ "out",
62
+ "target",
63
+ "coverage",
64
+ "vendor",
65
+ ".git",
66
+ ".github",
67
+ ".idea",
68
+ ".vscode",
69
+ ".next",
70
+ ".gradle",
71
+ ".csda",
72
+ ".specops",
73
+ "test",
74
+ "tests",
75
+ "spec",
76
+ "specs",
77
+ "docs",
78
+ "doc",
79
+ "scripts",
80
+ "tools",
81
+ "bin",
82
+ "config",
83
+ "assets",
84
+ "public",
85
+ "static",
86
+ "resources",
87
+ "fixtures",
88
+ "examples",
89
+ "src",
90
+ "main",
91
+ "java",
92
+ "lib",
93
+ "app",
94
+ "internal",
95
+ "pkg",
96
+ "cmd",
97
+ "features",
98
+ "com",
99
+ "org",
100
+ "net",
101
+ "io",
102
+ "migrations",
103
+ "templates",
104
+ "packages",
105
+ ]);
106
+ const DOMAIN_ROOTS = [
107
+ "src/main/java",
108
+ "src/main/kotlin",
109
+ "src/domain",
110
+ "src/modules",
111
+ "src/features",
112
+ "src/contexts",
113
+ "src/app",
114
+ "src/packages",
115
+ "app/domain",
116
+ "domain",
117
+ "modules",
118
+ "contexts",
119
+ "services",
120
+ "internal",
121
+ "pkg",
122
+ "src",
123
+ "app",
124
+ "lib",
125
+ ];
126
+ exports.BUILD_OUTPUT = new Set([
127
+ "node_modules",
128
+ "dist",
129
+ "build",
130
+ "out",
131
+ "target",
132
+ "coverage",
133
+ "vendor",
134
+ ".gradle",
135
+ ".next",
136
+ ".git",
137
+ ]);
138
+ /** The wrapper a JVM project puts between the module root and its packages. */
139
+ const JVM_SOURCE_ROOTS = ["src/main/java", "src/main/kotlin", "src/main/scala", "src/main/groovy"];
140
+ const CODE_EXT = new Set([
141
+ ".java",
142
+ ".kt",
143
+ ".kts",
144
+ ".scala",
145
+ ".groovy",
146
+ ".ts",
147
+ ".tsx",
148
+ ".js",
149
+ ".jsx",
150
+ ".mjs",
151
+ ".cjs",
152
+ ".vue",
153
+ ".svelte",
154
+ ".py",
155
+ ".go",
156
+ ".rs",
157
+ ".rb",
158
+ ".php",
159
+ ".cs",
160
+ ".fs",
161
+ ".vb",
162
+ ".swift",
163
+ ".dart",
164
+ ".c",
165
+ ".h",
166
+ ".cc",
167
+ ".cpp",
168
+ ".hpp",
169
+ ".m",
170
+ ".mm",
171
+ ".ex",
172
+ ".exs",
173
+ ".erl",
174
+ ".clj",
175
+ ".sql",
176
+ ]);
177
+ /**
178
+ * Files that mark a directory as a project of its own.
179
+ *
180
+ * This is the single most useful signal on disk and the one this command used
181
+ * to ignore: a monorepo almost always *declares* its modules, and a directory
182
+ * carrying its own build manifest is a module by the team's own definition —
183
+ * no guessing, no per-ecosystem parser. It covers Maven and Gradle modules,
184
+ * npm/pnpm workspaces, Cargo workspace members, Go modules, Ruby gems, .NET
185
+ * projects and Composer packages with one rule.
186
+ */
187
+ const MODULE_MANIFESTS = [
188
+ "pom.xml",
189
+ "build.gradle",
190
+ "build.gradle.kts",
191
+ "package.json",
192
+ "Cargo.toml",
193
+ "go.mod",
194
+ "pyproject.toml",
195
+ "setup.py",
196
+ "composer.json",
197
+ "build.sbt",
198
+ "mix.exs",
199
+ ];
200
+ const MODULE_MANIFEST_GLOBS = [/\.gemspec$/, /\.csproj$/, /\.fsproj$/];
201
+ /**
202
+ * Architectural layer names. A repository whose modules are mostly these has
203
+ * declared its *layering*, not its capabilities — `domain`, `application`,
204
+ * `infrastructure`, `bootstrap` are four views of one product. Proposing them
205
+ * as capabilities would be technically accurate and useless, so a layered
206
+ * project is descended into instead.
207
+ */
208
+ const LAYER_NAMES = new Set([
209
+ "domain",
210
+ "application",
211
+ "infrastructure",
212
+ "infra",
213
+ "bootstrap",
214
+ "adapters",
215
+ "adapter",
216
+ "ports",
217
+ "api",
218
+ "rest",
219
+ "web",
220
+ "http",
221
+ "ui",
222
+ "persistence",
223
+ "repository",
224
+ "core",
225
+ "common",
226
+ "commons",
227
+ "shared",
228
+ "util",
229
+ "utils",
230
+ "config",
231
+ "client",
232
+ "server",
233
+ ]);
234
+ /**
235
+ * Modules and directories that exist to test, document or demo the real ones.
236
+ *
237
+ * Matched as a whole name, as a prefix (`tests-integration`) and as a suffix
238
+ * (`Serilog.ApprovalTests`), because each ecosystem picks a different one.
239
+ */
240
+ const NOT_A_MODULE = /^(tests?|testing|it|e2e|integration|benchmarks?|benches|examples?|samples?|demos?|docs?|website|site|fixtures?|testdata|testutil|scripts|tools|buildsrc|build-logic|gradle|third_party|vendor)$|^(tests?|benchmarks?|benches|examples?|samples?|e2e|it)[-_.]|[-_.](tests?|benchmarks?|benches|examples?|samples?|it|approvaltests|testdummies)$/i;
241
+ function subdirectories(dir) {
242
+ try {
243
+ return fs
244
+ .readdirSync(dir, { withFileTypes: true })
245
+ .filter((e) => e.isDirectory() && !e.name.startsWith("."))
246
+ .map((e) => e.name);
247
+ }
248
+ catch {
249
+ return [];
250
+ }
251
+ }
252
+ /**
253
+ * Walk down through single-child directories. A Java package root is
254
+ * `src/main/java/com/acme/`, and stopping at `com` would propose `com` as a
255
+ * capability.
256
+ */
257
+ function descendThroughWrappers(root) {
258
+ let current = root;
259
+ // A Maven/Gradle module is `<module>/src/{main,test}/java/...`. The `main` and
260
+ // `test` split means the single-child descent below stops dead at `src`, and
261
+ // both names are in NOT_DOMAIN, so the module reads as empty. Jumping the
262
+ // whole known wrapper is the only way past it. Found on `lixy-api`, where a
263
+ // 299-file hexagonal project proposed nothing at all (H17).
264
+ for (const wrapper of JVM_SOURCE_ROOTS) {
265
+ const candidate = path.join(current, ...wrapper.split("/"));
266
+ if (fs.existsSync(candidate)) {
267
+ current = candidate;
268
+ break;
269
+ }
270
+ }
271
+ // Descend while there is exactly one child: a directory with a single
272
+ // subdirectory is a wrapper, not a choice. Stopping at the first *meaningful*
273
+ // name instead proposed the organisation — `com/acme` yields `acme`, not the
274
+ // packages under it.
275
+ //
276
+ // Build output does not count as a child: whether `build/` exists depends on
277
+ // whether someone compiled, and the proposal must not.
278
+ for (let depth = 0; depth < 8; depth++) {
279
+ const children = subdirectories(current).filter((n) => !exports.BUILD_OUTPUT.has(n.toLowerCase()));
280
+ if (children.length !== 1)
281
+ return current;
282
+ current = path.join(current, children[0]);
283
+ }
284
+ return current;
285
+ }
286
+ /**
287
+ * How much code sits under a capability. Only build output is skipped.
288
+ *
289
+ * It used to skip everything in NOT_DOMAIN, which is the right list for *naming*
290
+ * a capability and the wrong one for measuring it: `src`, `main` and `java` are
291
+ * on it, so no JVM layout was ever descended into and every module counted as
292
+ * near zero. Measured on `lakebase-platform`, a 38-file module reported 1 — and
293
+ * since the proposals are sorted by this number, the ranking came out inverted
294
+ * (H14).
295
+ */
296
+ function countFiles(dir) {
297
+ let total = 0;
298
+ const stack = [dir];
299
+ while (stack.length > 0 && total < 5000) {
300
+ const next = stack.pop();
301
+ let entries;
302
+ try {
303
+ entries = fs.readdirSync(next, { withFileTypes: true });
304
+ }
305
+ catch {
306
+ continue;
307
+ }
308
+ for (const entry of entries) {
309
+ if (entry.isDirectory()) {
310
+ const name = entry.name.toLowerCase();
311
+ // Tests, samples and benchmarks are code, but they are not the product.
312
+ // Counting them made Nest's dozens of sample apps outweigh the packages
313
+ // they demonstrate.
314
+ if (!exports.BUILD_OUTPUT.has(name) && !name.startsWith(".") && !NOT_A_MODULE.test(entry.name)) {
315
+ stack.push(path.join(next, entry.name));
316
+ }
317
+ }
318
+ else if (CODE_EXT.has(path.extname(entry.name).toLowerCase()))
319
+ total++;
320
+ }
321
+ }
322
+ return total;
323
+ }
324
+ function hasManifest(dir) {
325
+ let entries;
326
+ try {
327
+ entries = fs.readdirSync(dir, { withFileTypes: true });
328
+ }
329
+ catch {
330
+ return false;
331
+ }
332
+ for (const e of entries) {
333
+ if (!e.isFile())
334
+ continue;
335
+ if (MODULE_MANIFESTS.includes(e.name))
336
+ return true;
337
+ if (MODULE_MANIFEST_GLOBS.some((re) => re.test(e.name)))
338
+ return true;
339
+ }
340
+ return false;
341
+ }
342
+ /**
343
+ * Sibling projects the repository declares by giving each its own build
344
+ * manifest. Looked for one and two levels down, because half of these layouts
345
+ * put them under a container directory (`packages/`, `services/`, `crates/`).
346
+ */
347
+ function findDeclaredModules(projectDir) {
348
+ const found = [];
349
+ for (const first of subdirectories(projectDir)) {
350
+ if (exports.BUILD_OUTPUT.has(first.toLowerCase()))
351
+ continue;
352
+ // `test/`, `examples/` and `sample/` hold real projects with real manifests.
353
+ // Reading them as modules is how Serilog was told its capabilities were its
354
+ // four test assemblies, and Flask that it was three example apps.
355
+ if (NOT_A_MODULE.test(first))
356
+ continue;
357
+ const firstPath = path.join(projectDir, first);
358
+ if (hasManifest(firstPath)) {
359
+ found.push({ name: first, dir: firstPath });
360
+ continue;
361
+ }
362
+ // A container like `packages/` carries no manifest of its own; its children do.
363
+ const nested = subdirectories(firstPath)
364
+ .filter((n) => !exports.BUILD_OUTPUT.has(n.toLowerCase()) && !NOT_A_MODULE.test(n))
365
+ .map((n) => ({ name: n, dir: path.join(firstPath, n) }))
366
+ .filter((m) => hasManifest(m.dir));
367
+ found.push(...nested);
368
+ }
369
+ return found.filter((m) => !NOT_A_MODULE.test(m.name) && countFiles(m.dir) > 0);
370
+ }
371
+ /** True when the modules describe layers of one product rather than areas of it. */
372
+ function looksLayered(modules) {
373
+ const layerish = modules.filter((m) => LAYER_NAMES.has(m.name.toLowerCase())).length;
374
+ return layerish >= 2 && layerish / modules.length >= 0.5;
375
+ }
376
+ /**
377
+ * The top-level Python package — `src/flask/`, `django/` — which is the level a
378
+ * Python project draws its lines at. Nothing else on disk marks it, so the
379
+ * `__init__.py` is the evidence.
380
+ */
381
+ function pythonPackageRoots(projectDir) {
382
+ const roots = [];
383
+ for (const container of [projectDir, path.join(projectDir, "src")]) {
384
+ for (const name of subdirectories(container)) {
385
+ if (exports.BUILD_OUTPUT.has(name.toLowerCase()) || NOT_A_MODULE.test(name))
386
+ continue;
387
+ if (fs.existsSync(path.join(container, name, "__init__.py"))) {
388
+ roots.push(path.relative(projectDir, path.join(container, name)));
389
+ }
390
+ }
391
+ }
392
+ return roots;
393
+ }
394
+ function titleCase(name) {
395
+ return name
396
+ .replace(/[-_]+/g, " ")
397
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
398
+ .split(" ")
399
+ .filter(Boolean)
400
+ .map((w) => w[0].toUpperCase() + w.slice(1))
401
+ .join(" ");
402
+ }
403
+ function toCapability(projectDir, dir, name) {
404
+ return {
405
+ id: name
406
+ .toLowerCase()
407
+ .replace(/[^a-z0-9]+/g, "-")
408
+ .replace(/^-|-$/g, ""),
409
+ title: titleCase(name),
410
+ evidence: path.relative(projectDir, dir).split(path.sep).join("/") || ".",
411
+ files: countFiles(dir),
412
+ };
413
+ }
414
+ /**
415
+ * Split one directory into the capabilities its children imply, or null when
416
+ * its children imply nothing.
417
+ */
418
+ function splitIntoCapabilities(projectDir, root, depth = 0) {
419
+ const base = descendThroughWrappers(root);
420
+ const children = subdirectories(base)
421
+ .filter((n) => !exports.NOT_DOMAIN.has(n.toLowerCase()) && !NOT_A_MODULE.test(n))
422
+ .map((n) => ({ dir: path.join(base, n), cap: toCapability(projectDir, path.join(base, n), n) }))
423
+ .filter((child) => child.cap.files > 0);
424
+ if (children.length < 2)
425
+ return null;
426
+ // A "split" where one child holds nearly everything is not a split — it is a
427
+ // wrapper with debris beside it. Django's repository root looks exactly like
428
+ // this: `django/` plus `js_tests/`, which reads as two capabilities of 929 and
429
+ // 11 files. The lines that matter are drawn one level further in.
430
+ const total = children.reduce((sum, child) => sum + child.cap.files, 0);
431
+ const largest = children.reduce((a, b) => (a.cap.files >= b.cap.files ? a : b));
432
+ if (depth < 3 && largest.cap.files / total >= 0.8) {
433
+ const deeper = splitIntoCapabilities(projectDir, largest.dir, depth + 1);
434
+ if (deeper)
435
+ return deeper;
436
+ }
437
+ return children.map((child) => child.cap);
438
+ }
439
+ /**
440
+ * Capabilities proposed from how the code is already organised.
441
+ *
442
+ * Three sources, in order of how much they are actually *evidence*:
443
+ *
444
+ * 1. **Modules the repository declares** by giving each its own build
445
+ * manifest. Not a heuristic — it is the team's own answer.
446
+ * 2. **The layer where the code divides**, scored across every plausible
447
+ * root rather than taken from the first entry of a list.
448
+ * 3. Nothing. Silence beats a confident wrong answer, and a flat library
449
+ * genuinely has no capability structure to read.
450
+ *
451
+ * Measured over sixteen well-known repositories (Maven and Gradle multi-module,
452
+ * npm and pnpm workspaces, Cargo workspaces, Ruby gems, Go, Django, Laravel,
453
+ * .NET), the previous list-order approach answered for five of them and named
454
+ * packaging directories in two more.
455
+ */
456
+ function proposeCapabilities(projectDir) {
457
+ let modules = findDeclaredModules(projectDir);
458
+ // A repository can hold sub-projects and still *be* a project: Loki keeps a
459
+ // Kubernetes operator and a tiny `pkg/push` module beside the ~4000 files that
460
+ // are Loki itself. Reading those two as the capability list buries the product
461
+ // behind its own accessories, so when the root outweighs everything it
462
+ // declares, the root is the project.
463
+ if (modules.length > 0) {
464
+ const inModules = modules.reduce((sum, m) => sum + countFiles(m.dir), 0);
465
+ if (countFiles(projectDir) - inModules > inModules)
466
+ modules = [];
467
+ }
468
+ // A layered project (domain / application / infrastructure / bootstrap) has
469
+ // declared how it is built, not what it does. Read its domain layer instead.
470
+ if (modules.length >= 2 && looksLayered(modules)) {
471
+ const layers = modules.slice().sort((a, b) => countFiles(b.dir) - countFiles(a.dir));
472
+ const preferred = layers.find((m) => m.name.toLowerCase() === "domain") ||
473
+ layers.find((m) => m.name.toLowerCase() === "core") ||
474
+ layers[0];
475
+ const split = splitIntoCapabilities(projectDir, preferred.dir);
476
+ if (split)
477
+ return split.sort((a, b) => b.files - a.files).slice(0, 8);
478
+ }
479
+ if (modules.length >= 2) {
480
+ return modules
481
+ .map((m) => toCapability(projectDir, m.dir, m.name))
482
+ .sort((a, b) => b.files - a.files)
483
+ .slice(0, 8);
484
+ }
485
+ // One declared module (a `src/` project, a single .csproj) is the project
486
+ // itself — its own children are where the lines are drawn.
487
+ const searchRoots = modules.length === 1 ? [path.relative(projectDir, modules[0].dir)] : [];
488
+ searchRoots.push(...pythonPackageRoots(projectDir), ...DOMAIN_ROOTS);
489
+ let best = null;
490
+ const seen = new Set();
491
+ for (const candidate of searchRoots) {
492
+ const root = path.join(projectDir, candidate);
493
+ const key = path.resolve(root);
494
+ if (seen.has(key) || !fs.existsSync(root))
495
+ continue;
496
+ seen.add(key);
497
+ const split = splitIntoCapabilities(projectDir, root);
498
+ if (!split)
499
+ continue;
500
+ // Weight by the code the split actually accounts for: a packaging folder
501
+ // with two shell scripts must never outrank the crate tree beside it.
502
+ const weight = split.reduce((sum, cap) => sum + cap.files, 0);
503
+ if (!best || weight > best.weight)
504
+ best = { weight, split };
505
+ }
506
+ if (!best)
507
+ return [];
508
+ return best.split.sort((a, b) => b.files - a.files).slice(0, 8);
509
+ }
510
+ function isAdopted(projectDir) {
511
+ return fs.existsSync(path.join(projectDir, "spec.md"));
512
+ }
513
+ /**
514
+ * Resolve symlinks so paths compare equal downstream — macOS `/tmp` is
515
+ * `/private/tmp`, and the JSON contract should not leak that difference.
516
+ * `resolveProjectDir` did this before H16 removed it from onboard's path.
517
+ */
518
+ function canonical(p) {
519
+ try {
520
+ return fs.realpathSync(path.resolve(p));
521
+ }
522
+ catch {
523
+ return path.resolve(p);
524
+ }
525
+ }
526
+ /**
527
+ * The nearest *ancestor* that is already spec-driven, or null.
528
+ *
529
+ * Reported, never substituted: standing in one project and being told about
530
+ * another is how H16 hid an entire Java backend behind its parent repository.
531
+ */
532
+ function findAdoptedAncestor(projectDir) {
533
+ let dir = path.dirname(canonical(projectDir));
534
+ const { root } = path.parse(dir);
535
+ for (;;) {
536
+ if (isAdopted(dir))
537
+ return dir;
538
+ if (dir === root)
539
+ return null;
540
+ dir = path.dirname(dir);
541
+ }
542
+ }
543
+ function usage() {
544
+ process.stdout.write(`\n ${c.bold}${c.cyan}🧭 onboard${c.reset} ${c.dim}— the guided tour for an existing repository${c.reset}\n\n` +
545
+ " USAGE\n specgate onboard [--project-dir <path>] [--json]\n\n" +
546
+ " Reads the repository, proposes the capabilities its code already implies,\n" +
547
+ " and tells you the one command to run next. Writes nothing.\n\n");
548
+ }
549
+ function renderHuman({ projectDir, adopted, adoptedAncestor, stack, capabilities, nextCommand, }) {
550
+ const out = [];
551
+ out.push(`\n ${c.bold}${c.cyan}🧭 onboarding${c.reset} ${c.dim}${projectDir}${c.reset}\n`);
552
+ if (adoptedAncestor && !adopted) {
553
+ out.push(` ${c.dim}inside a spec-driven project at ${adoptedAncestor} — reading this directory, not that one${c.reset}\n`);
554
+ }
555
+ out.push(` ${c.bold}1. What this is${c.reset}`);
556
+ out.push(` stack: ${stack.STACK}`);
557
+ if (stack.TEST_CMD)
558
+ out.push(` tests: ${stack.TEST_CMD}`);
559
+ out.push(` ${stack.detected ? `${c.dim}detected from ${stack.detected}${c.reset}` : `${c.dim}no manifest found — say so with --var STACK="…"${c.reset}`}`);
560
+ out.push("");
561
+ out.push(` ${c.bold}2. Specs${c.reset}`);
562
+ out.push(adopted
563
+ ? ` ${c.green}✔${c.reset} already adopted — spec.md is here`
564
+ : ` ${c.dim}· not adopted yet — \`specgate adopt\` writes the skeleton without touching code${c.reset}`);
565
+ out.push("");
566
+ out.push(` ${c.bold}3. Capabilities this codebase already implies${c.reset}`);
567
+ if (capabilities.length === 0) {
568
+ out.push(` ${c.dim}Nothing obvious from the layout. Name them yourself — one per`);
569
+ out.push(` area of behaviour a user would recognise.${c.reset}`);
570
+ }
571
+ else {
572
+ for (const cap of capabilities) {
573
+ out.push(` ${c.green}·${c.reset} ${cap.title.padEnd(20)} ${c.dim}${cap.evidence} (${cap.files} files)${c.reset}`);
574
+ }
575
+ out.push("");
576
+ out.push(` ${c.dim}A proposal, not a verdict. Merge, split or rename them.${c.reset}`);
577
+ }
578
+ out.push("");
579
+ out.push(` ${c.bold}Next${c.reset}`);
580
+ out.push(` ${c.green}${nextCommand}${c.reset}\n`);
581
+ process.stdout.write(`${out.join("\n")}\n`);
582
+ }
583
+ class OnboardCommand extends command_1.BaseCommand {
584
+ execute() {
585
+ const argv = this.args;
586
+ const io = (0, agent_1.agentIo)((0, agent_1.wantsJson)(argv));
587
+ const NULL_SHAPE = { onboarding: null };
588
+ if (argv.includes("--help") || argv.includes("-h")) {
589
+ usage();
590
+ process.exit(agent_1.EXIT.OK);
591
+ }
592
+ const dirFlag = argv.indexOf("--project-dir");
593
+ const requested = dirFlag !== -1 ? argv[dirFlag + 1] : ".";
594
+ // Unlike every other command, onboard runs on repositories that are not
595
+ // spec-driven yet — that is the whole point — so the usual "walk up until
596
+ // you find spec.md" resolution is actively wrong here: from an un-adopted
597
+ // sub-project it lands on the adopted ancestor and silently reports a
598
+ // *different* codebase. On `lixi-platform/lixy-api` it answered with the
599
+ // parent's dead TypeScript, stack and all (H16). Take the directory asked
600
+ // for, and mention the ancestor rather than substituting it.
601
+ const projectDir = canonical(requested);
602
+ const adoptedAncestor = findAdoptedAncestor(projectDir);
603
+ if (!fs.existsSync(projectDir)) {
604
+ io.usage(NULL_SHAPE, [
605
+ (0, diagnostics_1.error)("project_dir_not_found", `Directory not found: ${projectDir}`, {
606
+ fix: "Point --project-dir at the repository you want to onboard.",
607
+ }),
608
+ ]);
609
+ }
610
+ const adopted = isAdopted(projectDir);
611
+ const stack = (0, AdoptCommand_1.detectStack)(projectDir);
612
+ const capabilities = proposeCapabilities(projectDir);
613
+ const nextCommand = !adopted
614
+ ? "specgate adopt"
615
+ : capabilities.length > 0
616
+ ? `specgate change new describe-${capabilities[0].id}`
617
+ : 'specgate req add "<the first behaviour you rely on>"';
618
+ const diagnostics = [];
619
+ if (!stack.detected) {
620
+ diagnostics.push((0, diagnostics_1.info)("stack_undetected", "Could not detect the stack from a manifest file.", {
621
+ fix: 'Pass it explicitly: specgate adopt --var STACK="…" --var TEST_CMD="…"',
622
+ }));
623
+ }
624
+ if (capabilities.length === 0) {
625
+ diagnostics.push((0, diagnostics_1.info)("capabilities_undetected", "No capability structure was obvious from the layout.", {
626
+ fix: "Name them yourself — one per area of behaviour a user would recognise. `specgate change new <id>` opens the first.",
627
+ }));
628
+ }
629
+ if (adoptedAncestor && !adopted) {
630
+ diagnostics.push((0, diagnostics_1.info)("adopted_ancestor", `This directory sits inside a spec-driven project at ${adoptedAncestor}, which was NOT onboarded.`, {
631
+ target: adoptedAncestor,
632
+ fix: `Onboarding ${projectDir}. To read the parent instead: specgate onboard --project-dir ${adoptedAncestor}`,
633
+ }));
634
+ }
635
+ io.emit({
636
+ onboarding: {
637
+ projectDir,
638
+ adopted,
639
+ adoptedAncestor,
640
+ stack: {
641
+ name: stack.STACK,
642
+ testing: stack.TESTING,
643
+ testCommand: stack.TEST_CMD,
644
+ detectedFrom: stack.detected || null,
645
+ },
646
+ capabilities,
647
+ nextCommand,
648
+ },
649
+ status: diagnostics,
650
+ }, () => renderHuman({ projectDir, adopted, adoptedAncestor, stack, capabilities, nextCommand }));
651
+ process.exit(agent_1.EXIT.OK);
652
+ }
653
+ }
654
+ exports.OnboardCommand = OnboardCommand;
655
+ //# sourceMappingURL=OnboardCommand.js.map