@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 @@
1
+ {"version":3,"file":"GitMergeDriver.js","sourceRoot":"","sources":["../../../../../packages/core/src/infrastructure/GitMergeDriver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBH,sCA4CC;AA1DD,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAClC,2DAA+C;AAElC,QAAA,cAAc,GAAG;IAC5B,KAAK,EAAE,oBAAoB;IAC3B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,6BAA6B;CACxC,CAAC;AAEF;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE;IAC9D,MAAM,GAAG,GAAG,EAAE,GAAG,sBAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,g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CAAC,MAAM;SACzB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
@@ -0,0 +1,348 @@
1
+ "use strict";
2
+ /**
3
+ * Reader for `harness.config.yaml` — optional per-project defaults for
4
+ * `specgate harness run`, so the test command and agent invocation do not have
5
+ * to be retyped on every run.
6
+ *
7
+ * Format:
8
+ * harness_version: 1
9
+ * agent: "opencode run \"$(cat {prompt_file})\""
10
+ * test_cmd: "mvn -B test"
11
+ * max_attempts: 3
12
+ * concurrency: 1
13
+ * prompt_prefix: "Role: Lead Architect. Hexagonal arch is non-negotiable."
14
+ * # or, for a multi-line prefix (parseYamlLite has no block scalar support):
15
+ * prompt_prefix_file: ./.harness/prompt-prefix.md
16
+ *
17
+ * `prompt_prefix` is prepended to every per-requirement prompt the harness
18
+ * hands the agent. It is the natural home for your universal Role / Active
19
+ * Project Boundary / Execution Policy directives — the bits a hand-crafted
20
+ * "base prompt" used to carry — so they ride along on every REQ without
21
+ * being duplicated.
22
+ *
23
+ * Every key is optional. CLI flags always override the file.
24
+ *
25
+ * Pure-ish module: reads `prompt_prefix_file` when present. No logging, no
26
+ * process.exit. Throws on malformed YAML or a missing prefix file.
27
+ */
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || (function () {
45
+ var ownKeys = function(o) {
46
+ ownKeys = Object.getOwnPropertyNames || function (o) {
47
+ var ar = [];
48
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
49
+ return ar;
50
+ };
51
+ return ownKeys(o);
52
+ };
53
+ return function (mod) {
54
+ if (mod && mod.__esModule) return mod;
55
+ var result = {};
56
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
57
+ __setModuleDefault(result, mod);
58
+ return result;
59
+ };
60
+ })();
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.HARNESS_CONFIG_FILE = void 0;
63
+ exports.readHarnessConfig = readHarnessConfig;
64
+ exports.resolveProfileAgent = resolveProfileAgent;
65
+ exports.resolveHarnessSettings = resolveHarnessSettings;
66
+ exports.readProfileRules = readProfileRules;
67
+ exports.readCostHints = readCostHints;
68
+ const fs = __importStar(require("node:fs"));
69
+ const path = __importStar(require("node:path"));
70
+ const YamlLite_1 = require("../domain/YamlLite");
71
+ exports.HARNESS_CONFIG_FILE = "harness.config.yaml";
72
+ /** Every key this reader understands. Anything else is rejected, not ignored. */
73
+ const KNOWN_KEYS = new Set([
74
+ "harness_version",
75
+ "agent",
76
+ "agent_profile",
77
+ "test_cmd",
78
+ "max_attempts",
79
+ "concurrency",
80
+ "push",
81
+ "remote",
82
+ "pr_cmd",
83
+ "prompt_prefix",
84
+ "prompt_prefix_file",
85
+ "attempt_profiles",
86
+ "review_profile",
87
+ "protected_paths",
88
+ "allow_paths",
89
+ "message_report",
90
+ ]);
91
+ function readHarnessConfig(projectDir) {
92
+ const filePath = path.join(projectDir, exports.HARNESS_CONFIG_FILE);
93
+ if (!fs.existsSync(filePath))
94
+ return null;
95
+ const parsed = (0, YamlLite_1.parseYamlLite)(fs.readFileSync(filePath, "utf8"));
96
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
97
+ throw new Error(`Invalid ${exports.HARNESS_CONFIG_FILE}: root must be a mapping`);
98
+ }
99
+ const config = {};
100
+ if (parsed.agent !== undefined)
101
+ config.agent = String(parsed.agent);
102
+ if (parsed.test_cmd !== undefined)
103
+ config.testCmd = String(parsed.test_cmd);
104
+ if (parsed.max_attempts !== undefined) {
105
+ const n = Number(parsed.max_attempts);
106
+ if (!Number.isInteger(n) || n < 1) {
107
+ throw new Error(`Invalid ${exports.HARNESS_CONFIG_FILE}: max_attempts must be a positive integer`);
108
+ }
109
+ config.maxAttempts = n;
110
+ }
111
+ // How many requirements may be in flight at once. 1 keeps the loop exactly
112
+ // as it has always been — see the comment on `runLevels` in run.ts for why
113
+ // that default is deliberate rather than timid.
114
+ if (parsed.concurrency !== undefined) {
115
+ const n = Number(parsed.concurrency);
116
+ if (!Number.isInteger(n) || n < 1) {
117
+ throw new Error(`Invalid ${exports.HARNESS_CONFIG_FILE}: concurrency must be a positive integer`);
118
+ }
119
+ config.concurrency = n;
120
+ }
121
+ if (parsed.push !== undefined)
122
+ config.push = parsed.push === true || parsed.push === "true";
123
+ if (parsed.remote !== undefined)
124
+ config.remote = String(parsed.remote);
125
+ if (parsed.pr_cmd !== undefined)
126
+ config.prCmd = String(parsed.pr_cmd);
127
+ // prompt_prefix_file wins over inline prompt_prefix when both are set —
128
+ // file is the realistic source for the multi-line bootstrap directives.
129
+ if (parsed.prompt_prefix_file !== undefined) {
130
+ const rel = String(parsed.prompt_prefix_file);
131
+ const abs = path.resolve(projectDir, rel);
132
+ if (!fs.existsSync(abs)) {
133
+ throw new Error(`${exports.HARNESS_CONFIG_FILE}: prompt_prefix_file not found at ${rel} (resolved to ${abs})`);
134
+ }
135
+ config.promptPrefix = fs.readFileSync(abs, "utf8");
136
+ }
137
+ else if (parsed.prompt_prefix !== undefined) {
138
+ config.promptPrefix = String(parsed.prompt_prefix);
139
+ }
140
+ // `agent_profile` names an entry in .harness/profiles.yaml. It exists so a
141
+ // team can commit the agent commands it uses — local, CI, a different vendor
142
+ // — and pick one by name, instead of committing a single default that
143
+ // somebody eventually pays for by accident.
144
+ //
145
+ // An explicit `agent:` wins: the narrower statement beats the indirection.
146
+ // A1: which paths the agent may not modify, and the explicit exceptions.
147
+ // Both are lists of globs; a malformed value is rejected rather than ignored,
148
+ // because a guard that silently protects nothing is worse than no guard.
149
+ if (parsed.protected_paths !== undefined) {
150
+ config.protectedPaths = asStringList(parsed.protected_paths, "protected_paths");
151
+ }
152
+ if (parsed.allow_paths !== undefined) {
153
+ config.allowPaths = asStringList(parsed.allow_paths, "allow_paths");
154
+ }
155
+ // F5: where the runner writes its `--format message` stream, for projects
156
+ // whose test command the harness cannot safely rewrite (`npm test` may well
157
+ // run Cucumber, and there is no way to know from here).
158
+ if (parsed.message_report !== undefined) {
159
+ config.messageReport = String(parsed.message_report);
160
+ }
161
+ if (config.agent === undefined && parsed.agent_profile !== undefined) {
162
+ config.agent = resolveProfileAgent(projectDir, String(parsed.agent_profile));
163
+ }
164
+ // The roles ladder: a profile per attempt, and an advisory reviewer that runs
165
+ // before each retry. Resolved to commands here, once, so a worker process
166
+ // cannot resolve a profile differently from the parent that dispatched it.
167
+ if (parsed.attempt_profiles !== undefined) {
168
+ const names = asStringList(parsed.attempt_profiles, "attempt_profiles");
169
+ config.attemptProfiles = names;
170
+ config.profileAgents = { ...(config.profileAgents || {}) };
171
+ for (const name of names) {
172
+ config.profileAgents[name] = resolveProfileAgent(projectDir, name);
173
+ }
174
+ }
175
+ if (parsed.review_profile !== undefined) {
176
+ const name = String(parsed.review_profile);
177
+ const agent = resolveProfileAgent(projectDir, name);
178
+ if (!isAdvisoryProfile(projectDir, name)) {
179
+ throw new Error(`.harness/profiles.yaml: profile '${name}' is used as review_profile but does not ` +
180
+ "declare `advisory: true`.\n" +
181
+ "Fix: add `advisory: true` to it. A reviewer that is not marked advisory would have " +
182
+ "its work gated and committed, which is not what a reviewer is for.");
183
+ }
184
+ config.reviewProfile = name;
185
+ config.profileAgents = { ...(config.profileAgents || {}), [name]: agent };
186
+ }
187
+ // C1: what each profile says a run of it costs. Read once, from the same
188
+ // file the agents come from.
189
+ const hints = readCostHints(projectDir);
190
+ if (Object.keys(hints).length > 0)
191
+ config.costPerRunHint = hints;
192
+ // D1: a profile selected by `match:` still needs its command resolved, and
193
+ // nothing names it in `harness.config.yaml` — that is the point of matching.
194
+ const rules = readProfileRules(projectDir);
195
+ if (rules.length > 0) {
196
+ config.profileRules = rules;
197
+ config.profileAgents = { ...(config.profileAgents || {}) };
198
+ for (const rule of rules) {
199
+ if (!config.profileAgents[rule.name]) {
200
+ config.profileAgents[rule.name] = resolveProfileAgent(projectDir, rule.name);
201
+ }
202
+ }
203
+ }
204
+ // Anything left is a key nobody reads. Silently ignoring it is how the HIE
205
+ // pilot ended up configured against a feature that did not exist: the file
206
+ // named a profile, the CLI never looked, and `harness run` reported no agent
207
+ // configured while the config plainly declared one.
208
+ const unknown = Object.keys(parsed).filter((k) => !KNOWN_KEYS.has(k));
209
+ if (unknown.length > 0) {
210
+ throw new Error(`${exports.HARNESS_CONFIG_FILE}: unknown key(s): ${unknown.join(", ")}.\n` +
211
+ `Known keys: ${[...KNOWN_KEYS].sort().join(", ")}.\n` +
212
+ "Fix: remove the key, or correct the spelling. A key nobody reads is worse " +
213
+ "than a missing one, because the file looks configured.");
214
+ }
215
+ return config;
216
+ }
217
+ /**
218
+ * Resolve a named profile from `.harness/profiles.yaml` to its agent command.
219
+ */
220
+ function resolveProfileAgent(projectDir, profileName) {
221
+ const profilesPath = path.join(projectDir, ".harness", "profiles.yaml");
222
+ if (!fs.existsSync(profilesPath)) {
223
+ throw new Error(`${exports.HARNESS_CONFIG_FILE}: agent_profile '${profileName}' needs .harness/profiles.yaml, ` +
224
+ `which does not exist.\n` +
225
+ "Fix: create it, or set `agent:` directly in harness.config.yaml.");
226
+ }
227
+ const doc = (0, YamlLite_1.parseYamlLite)(fs.readFileSync(profilesPath, "utf8")) || {};
228
+ const profiles = doc.profiles || {};
229
+ const profile = profiles[profileName];
230
+ if (!profile || !profile.agent) {
231
+ const available = Object.keys(profiles);
232
+ throw new Error(`.harness/profiles.yaml: no profile '${profileName}' with an \`agent\`.\n` +
233
+ (available.length
234
+ ? `Available: ${available.join(", ")}.`
235
+ : "The file declares no profiles.") +
236
+ "\nFix: add the profile, or point agent_profile at one that exists.");
237
+ }
238
+ return String(profile.agent);
239
+ }
240
+ /**
241
+ * Merge file config with CLI args. CLI wins on every key; the file fills gaps.
242
+ */
243
+ function resolveHarnessSettings(fileConfig, cliArgs) {
244
+ const file = fileConfig || {};
245
+ return {
246
+ agent: cliArgs.agent || file.agent || "",
247
+ testCmd: cliArgs.testCmd || file.testCmd || "",
248
+ maxAttempts: cliArgs.maxAttempts || file.maxAttempts || 3,
249
+ concurrency: cliArgs.concurrency || file.concurrency || 1,
250
+ promptPrefix: cliArgs.promptPrefix || file.promptPrefix || "",
251
+ push: cliArgs.push || file.push || false,
252
+ remote: cliArgs.remote || file.remote || "origin",
253
+ prCmd: cliArgs.prCmd || file.prCmd || "",
254
+ // Roles come from the file only: a ladder is a team decision that belongs
255
+ // in the repository, not a flag somebody types differently each run.
256
+ attemptProfiles: file.attemptProfiles || [],
257
+ reviewProfile: file.reviewProfile || "",
258
+ profileAgents: file.profileAgents || {},
259
+ // From the file only, for the same reason as the role ladder: a flag that
260
+ // widens what the agent may edit is a flag somebody types to go green.
261
+ protectedPaths: file.protectedPaths || [],
262
+ allowPaths: file.allowPaths || [],
263
+ messageReport: file.messageReport || "",
264
+ costPerRunHint: file.costPerRunHint || {},
265
+ profileRules: file.profileRules || [],
266
+ };
267
+ }
268
+ /** A YAML value that must be a list of names. */
269
+ function asStringList(value, key) {
270
+ if (!Array.isArray(value)) {
271
+ throw new Error(`${exports.HARNESS_CONFIG_FILE}: ${key} must be a list of profile names.\n` +
272
+ "Fix: write it as a YAML sequence, one profile per line.");
273
+ }
274
+ return value.map((v) => String(v));
275
+ }
276
+ /** Does this profile declare itself advisory? */
277
+ /**
278
+ * `cost_per_run_hint` for every profile that declares one (C1).
279
+ *
280
+ * Optional and per profile, so a team can say "this ladder costs about this
281
+ * much" without the harness pretending to measure tokens it cannot see. A
282
+ * hint that is not a finite number is ignored rather than fatal — a wrong
283
+ * estimate must not stop a run.
284
+ *
285
+ * Exported and independent of `harness.config.yaml`: the hints live in
286
+ * `profiles.yaml`, and `harness report` needs them in projects that never wrote
287
+ * a harness config at all. Reaching them through the config reader made the
288
+ * estimate silently absent there.
289
+ */
290
+ /**
291
+ * The `match:` rules profiles declare, in file order (D1).
292
+ *
293
+ * Order is the priority — first match wins — so the file's order is preserved
294
+ * rather than sorted. A profile with no `match:` is not a rule and does not
295
+ * appear here: it is selected by name through `agent_profile`, and treating an
296
+ * absent `match:` as "matches everything" would make the first profile in the
297
+ * file swallow every requirement the moment somebody adds a rule to another.
298
+ */
299
+ function readProfileRules(projectDir) {
300
+ const profilesPath = path.join(projectDir, ".harness", "profiles.yaml");
301
+ if (!fs.existsSync(profilesPath))
302
+ return [];
303
+ let doc;
304
+ try {
305
+ doc = (0, YamlLite_1.parseYamlLite)(fs.readFileSync(profilesPath, "utf8")) || {};
306
+ }
307
+ catch {
308
+ return [];
309
+ }
310
+ const rules = [];
311
+ for (const [name, profile] of Object.entries((doc.profiles || {}))) {
312
+ const match = profile && profile.match;
313
+ if (!match || typeof match !== "object" || Array.isArray(match))
314
+ continue;
315
+ const criteria = {};
316
+ for (const [key, value] of Object.entries(match))
317
+ criteria[key] = String(value);
318
+ if (Object.keys(criteria).length > 0)
319
+ rules.push({ name, match: criteria });
320
+ }
321
+ return rules;
322
+ }
323
+ function readCostHints(projectDir) {
324
+ const profilesPath = path.join(projectDir, ".harness", "profiles.yaml");
325
+ if (!fs.existsSync(profilesPath))
326
+ return {};
327
+ let doc;
328
+ try {
329
+ doc = (0, YamlLite_1.parseYamlLite)(fs.readFileSync(profilesPath, "utf8")) || {};
330
+ }
331
+ catch {
332
+ return {};
333
+ }
334
+ const hints = {};
335
+ for (const [name, profile] of Object.entries((doc.profiles || {}))) {
336
+ const value = Number(profile && profile.cost_per_run_hint);
337
+ if (Number.isFinite(value) && value >= 0)
338
+ hints[name] = value;
339
+ }
340
+ return hints;
341
+ }
342
+ function isAdvisoryProfile(projectDir, profileName) {
343
+ const profilesPath = path.join(projectDir, ".harness", "profiles.yaml");
344
+ const doc = (0, YamlLite_1.parseYamlLite)(fs.readFileSync(profilesPath, "utf8")) || {};
345
+ const profile = (doc.profiles || {})[profileName];
346
+ return Boolean(profile && profile.advisory === true);
347
+ }
348
+ //# sourceMappingURL=HarnessConfigFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HarnessConfigFile.js","sourceRoot":"","sources":["../../../../../packages/core/src/infrastructure/HarnessConfigFile.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,8CAyIC;AAKD,kDAuBC;AAKD,wDA2BC;AAoCD,4CAqBC;AAED,sCAeC;AA/SD,4CAA8B;AAC9B,gDAAkC;AAClC,iDAAmD;AAGtC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAOzD,iFAAiF;AACjF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,iBAAiB;IACjB,OAAO;IACP,eAAe;IACf,UAAU;IACV,cAAc;IACd,aAAa;IACb,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,oBAAoB;IACpB,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;CACjB,CAAC,CAAC;AAEH,SAAgB,iBAAiB,CAAC,UAAU;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,2BAAmB,CAAC,CAAC;IAC5D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CA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KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAU,EAAE,WAAW;IAChD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;IACxE,MAAM,GAAG,GAAG,IAAA,wBAAa,EAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,MAAM,OAAO,GAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAyB,CAAC,WAAW,CAAC,CAAC;IAC3E,OAAO,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ /**
3
+ * Packs that distribute changes.
4
+ *
5
+ * A pack can ship a `changes/` directory alongside its templates. On `sync`
6
+ * those land in the project as **proposed** changes — never applied, never
7
+ * archived. The consuming team reviews and archives them like any other
8
+ * change, which is what keeps the pack from silently rewriting a project's
9
+ * specification.
10
+ *
11
+ * It also gives the pack a semantic changelog: `changes/archive/` upstream is
12
+ * the record of what each version actually decided, in requirements rather
13
+ * than in commit messages.
14
+ *
15
+ * Deliberately additive and non-destructive: an existing change folder in the
16
+ * project is never touched. A pack cannot clobber local work in flight.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || (function () {
35
+ var ownKeys = function(o) {
36
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37
+ var ar = [];
38
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
39
+ return ar;
40
+ };
41
+ return ownKeys(o);
42
+ };
43
+ return function (mod) {
44
+ if (mod && mod.__esModule) return mod;
45
+ var result = {};
46
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47
+ __setModuleDefault(result, mod);
48
+ return result;
49
+ };
50
+ })();
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.depositPackChanges = depositPackChanges;
53
+ const fs = __importStar(require("node:fs"));
54
+ const path = __importStar(require("node:path"));
55
+ const ChangeWorkspace_1 = require("./ChangeWorkspace");
56
+ function copyTree(from, to) {
57
+ const written = [];
58
+ const walk = (src, dest) => {
59
+ fs.mkdirSync(dest, { recursive: true });
60
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
61
+ const s = path.join(src, entry.name);
62
+ const d = path.join(dest, entry.name);
63
+ if (entry.isDirectory())
64
+ walk(s, d);
65
+ else if (entry.isFile()) {
66
+ fs.copyFileSync(s, d);
67
+ written.push(d);
68
+ }
69
+ }
70
+ };
71
+ walk(from, to);
72
+ return written;
73
+ }
74
+ /**
75
+ * Deposit a pack's `changes/` into the project as proposed changes.
76
+ *
77
+ * @param packRoot the resolved pack repository root
78
+ * @param packId e.g. `parking-management/backend`
79
+ * @returns { deposited, skipped } — change ids, not file paths
80
+ */
81
+ function depositPackChanges(projectDir, packRoot, packId, opts) {
82
+ const o = opts || {};
83
+ const source = path.join(packRoot, packId, "changes");
84
+ const deposited = [];
85
+ const skipped = [];
86
+ if (!fs.existsSync(source) || !fs.statSync(source).isDirectory()) {
87
+ return { deposited, skipped };
88
+ }
89
+ const p = (0, ChangeWorkspace_1.paths)(projectDir);
90
+ for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
91
+ // A pack's own archive is history, not a proposal — never deposited.
92
+ if (!entry.isDirectory() || entry.name === "archive")
93
+ continue;
94
+ const target = p.change(entry.name);
95
+ if (fs.existsSync(target)) {
96
+ // Local work in flight under the same id always wins.
97
+ skipped.push(entry.name);
98
+ continue;
99
+ }
100
+ if (!o.dryRun)
101
+ copyTree(path.join(source, entry.name), target);
102
+ deposited.push(entry.name);
103
+ }
104
+ return { deposited, skipped };
105
+ }
106
+ //# sourceMappingURL=PackChangeDeposit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackChangeDeposit.js","sourceRoot":"","sources":["../../../../../packages/core/src/infrastructure/PackChangeDeposit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCH,gDA2BC;AAzDD,4CAA8B;AAC9B,gDAAkC;AAElC,uDAA0C;AAE1C,SAAS,QAAQ,CAAC,IAAI,EAAE,EAAE;IACxB,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,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CAAC,IAAI,KAAK,SAAS;YAAE,SAAS;QAE/D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,sDAAsD;YACtD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,CAAC,CAAC,MAAM;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/D,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ /**
3
+ * Resolves a remote pack repository to a local on-disk path.
4
+ *
5
+ * Behaviour:
6
+ * resolveRemotePack({ repo, version, cacheDir? })
7
+ * → { packRoot: <local-dir>, commit: <sha>, version: <ref-as-provided> }
8
+ *
9
+ * Caching:
10
+ * ~/.cache/csda/packs/<repo-hash>/<version>/
11
+ * The cache key is sha256(repo) so different repos with the same tag
12
+ * never collide. `cacheDir` can be overridden (used by tests).
13
+ *
14
+ * Side effects: spawns `git` and writes inside the cache directory.
15
+ * Throws on any failure with a contextual message.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.DEFAULT_CACHE_DIR = void 0;
52
+ exports.repoHash = repoHash;
53
+ exports.safeVersionDir = safeVersionDir;
54
+ exports.gitAvailable = gitAvailable;
55
+ exports.resolveRemotePack = resolveRemotePack;
56
+ exports.createPackBundle = createPackBundle;
57
+ const fs = __importStar(require("node:fs"));
58
+ const GitSafety_1 = require("../domain/GitSafety");
59
+ const os = __importStar(require("node:os"));
60
+ const path = __importStar(require("node:path"));
61
+ const crypto = __importStar(require("node:crypto"));
62
+ const node_child_process_1 = require("node:child_process");
63
+ exports.DEFAULT_CACHE_DIR = path.join(os.homedir(), ".cache", "csda", "packs");
64
+ const GIT_TIMEOUT_MS = 60_000;
65
+ function repoHash(repo) {
66
+ return crypto.createHash("sha256").update(String(repo)).digest("hex").slice(0, 16);
67
+ }
68
+ function safeVersionDir(version) {
69
+ return String(version).replace(/[^a-zA-Z0-9._-]/g, "_");
70
+ }
71
+ function runGit(args, options = {}) {
72
+ const result = (0, node_child_process_1.spawnSync)("git", args, {
73
+ encoding: "utf8",
74
+ timeout: options.timeout || GIT_TIMEOUT_MS,
75
+ cwd: options.cwd,
76
+ });
77
+ if (result.error) {
78
+ throw new Error(`git ${args[0]} failed: ${result.error.message}`);
79
+ }
80
+ if (result.status !== 0) {
81
+ const stderr = (result.stderr || "").trim();
82
+ throw new Error(`git ${args[0]} exited ${result.status}: ${stderr || "unknown error"}`);
83
+ }
84
+ return (result.stdout || "").trim();
85
+ }
86
+ function gitAvailable() {
87
+ const result = (0, node_child_process_1.spawnSync)("git", ["--version"], { encoding: "utf8" });
88
+ return result.status === 0;
89
+ }
90
+ /** Offline mode: opt-in via option or the CSDA_OFFLINE env var (CI-friendly). */
91
+ function isOffline(opts) {
92
+ if (typeof opts.offline === "boolean")
93
+ return opts.offline;
94
+ const env = process.env.CSDA_OFFLINE;
95
+ return env === "1" || env === "true";
96
+ }
97
+ /**
98
+ * @param {{ repo: string, version: string, cacheDir?: string, force?: boolean, offline?: boolean }} options
99
+ * @returns {{ packRoot: string, commit: string, version: string, cached: boolean }}
100
+ */
101
+ function resolveRemotePack(options) {
102
+ const opts = options || {};
103
+ if (!opts.repo)
104
+ throw new Error("resolveRemotePack: 'repo' is required");
105
+ if (!opts.version)
106
+ throw new Error("resolveRemotePack: 'version' is required");
107
+ if (!gitAvailable())
108
+ throw new Error("resolveRemotePack: 'git' is not available on PATH");
109
+ const cacheRoot = opts.cacheDir || exports.DEFAULT_CACHE_DIR;
110
+ const targetDir = path.join(cacheRoot, repoHash(opts.repo), safeVersionDir(opts.version));
111
+ const cached = fs.existsSync(path.join(targetDir, ".git"));
112
+ if (cached && !opts.force) {
113
+ const commit = runGit(["rev-parse", "HEAD"], { cwd: targetDir });
114
+ return { packRoot: targetDir, commit, version: opts.version, cached: true };
115
+ }
116
+ if (isOffline(opts)) {
117
+ throw new Error(`Offline mode: pack ${opts.repo}@${opts.version} is not in the local cache (${targetDir}).\n` +
118
+ "Fix: on a connected machine run `specgate pack bundle --repo <url> --out pack.bundle`,\n" +
119
+ "copy the bundle across, and use it as --pack-repo /path/to/pack.bundle.");
120
+ }
121
+ if (cached && opts.force) {
122
+ fs.rmSync(targetDir, { recursive: true, force: true });
123
+ }
124
+ // Checked before git sees it: a value starting with `-` is an option to git,
125
+ // and `--upload-pack=<cmd>` runs a command. `--` below stops the parsing; this
126
+ // stops what `--` cannot (js/second-order-command-line-injection).
127
+ const repo = (0, GitSafety_1.assertSafeGitRepo)(opts.repo, "pack repository");
128
+ const version = (0, GitSafety_1.assertSafeGitRef)(opts.version, "pack version");
129
+ fs.mkdirSync(path.dirname(targetDir), { recursive: true });
130
+ // Shallow clone with the specific ref. Works for tags and branches.
131
+ // Falls back to a full clone + checkout when --branch fails (e.g. for SHAs).
132
+ try {
133
+ runGit(["clone", "--depth", "1", "--branch", version, "--", repo, targetDir]);
134
+ }
135
+ catch {
136
+ // Either the ref is a SHA or shallow-with-branch isn't supported.
137
+ fs.rmSync(targetDir, { recursive: true, force: true });
138
+ runGit(["clone", "--", repo, targetDir]);
139
+ runGit(["checkout", "--detach", version, "--"], { cwd: targetDir });
140
+ }
141
+ const commit = runGit(["rev-parse", "HEAD"], { cwd: targetDir });
142
+ return { packRoot: targetDir, commit, version: opts.version, cached: false };
143
+ }
144
+ /**
145
+ * Create a single-file git bundle of a pack repository (all refs and tags),
146
+ * transportable into air-gapped environments. The bundle is a valid clone
147
+ * source, so `--pack-repo /path/to/pack.bundle` works everywhere a URL does.
148
+ *
149
+ * @param {{ repo: string, out: string, tmpDir?: string }} options
150
+ * @returns {{ out: string, refs: string[] }}
151
+ */
152
+ function createPackBundle(options) {
153
+ const opts = options || {};
154
+ if (!opts.repo)
155
+ throw new Error("createPackBundle: 'repo' is required");
156
+ if (!opts.out)
157
+ throw new Error("createPackBundle: 'out' is required");
158
+ if (!gitAvailable())
159
+ throw new Error("createPackBundle: 'git' is not available on PATH");
160
+ const tmpRoot = opts.tmpDir || fs.mkdtempSync(path.join(os.tmpdir(), "csda-bundle-"));
161
+ const mirrorDir = path.join(tmpRoot, "mirror.git");
162
+ try {
163
+ // A mirror clone carries every branch and tag — bundles from shallow
164
+ // clones are rejected by git, so this must be a full mirror.
165
+ runGit(["clone", "--mirror", "--", (0, GitSafety_1.assertSafeGitRepo)(opts.repo, "pack repository"), mirrorDir], {
166
+ timeout: 300_000,
167
+ });
168
+ const outAbs = path.resolve(opts.out);
169
+ fs.mkdirSync(path.dirname(outAbs), { recursive: true });
170
+ runGit(["bundle", "create", outAbs, "--all"], { cwd: mirrorDir });
171
+ const refs = runGit(["bundle", "list-heads", outAbs])
172
+ .split("\n")
173
+ .filter(Boolean)
174
+ .map((line) => line.split(" ").slice(1).join(" "));
175
+ return { out: outAbs, refs };
176
+ }
177
+ finally {
178
+ fs.rmSync(tmpRoot, { recursive: true, force: true });
179
+ }
180
+ }
181
+ //# sourceMappingURL=RemotePackResolver.js.map