@ai-primitives-hub/app 0.2.1 → 0.2.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/README.md +5 -1
  2. package/dist/collection/affected-collections.d.ts +11 -0
  3. package/dist/collection/affected-collections.d.ts.map +1 -0
  4. package/dist/collection/affected-collections.js +90 -0
  5. package/dist/collection/affected-collections.js.map +1 -0
  6. package/dist/collection/create-plugin.d.ts +35 -0
  7. package/dist/collection/create-plugin.d.ts.map +1 -0
  8. package/dist/collection/create-plugin.js +118 -0
  9. package/dist/collection/create-plugin.js.map +1 -0
  10. package/dist/collection/index.d.ts +4 -2
  11. package/dist/collection/index.d.ts.map +1 -1
  12. package/dist/collection/index.js +8 -4
  13. package/dist/collection/index.js.map +1 -1
  14. package/dist/collection/kind-route-warning.d.ts +13 -0
  15. package/dist/collection/kind-route-warning.d.ts.map +1 -0
  16. package/dist/collection/kind-route-warning.js +40 -0
  17. package/dist/collection/kind-route-warning.js.map +1 -0
  18. package/dist/collection/plugin-item-issues.d.ts +36 -0
  19. package/dist/collection/plugin-item-issues.d.ts.map +1 -0
  20. package/dist/collection/plugin-item-issues.js +31 -0
  21. package/dist/collection/plugin-item-issues.js.map +1 -0
  22. package/dist/collection/read-collection.d.ts +1 -1
  23. package/dist/collection/read-collection.d.ts.map +1 -1
  24. package/dist/collection/read-collection.js +14 -15
  25. package/dist/collection/read-collection.js.map +1 -1
  26. package/dist/collection-editor/collection-contribution-workflow.d.ts +96 -0
  27. package/dist/collection-editor/collection-contribution-workflow.d.ts.map +1 -0
  28. package/dist/collection-editor/collection-contribution-workflow.js +479 -0
  29. package/dist/collection-editor/collection-contribution-workflow.js.map +1 -0
  30. package/dist/collection-editor/collection-editor-service.d.ts +232 -0
  31. package/dist/collection-editor/collection-editor-service.d.ts.map +1 -0
  32. package/dist/collection-editor/collection-editor-service.js +868 -0
  33. package/dist/collection-editor/collection-editor-service.js.map +1 -0
  34. package/dist/collection-editor/index.d.ts +7 -0
  35. package/dist/collection-editor/index.d.ts.map +1 -0
  36. package/dist/collection-editor/index.js +12 -0
  37. package/dist/collection-editor/index.js.map +1 -0
  38. package/dist/diagnostics/find-ancestor-file.d.ts +13 -0
  39. package/dist/diagnostics/find-ancestor-file.d.ts.map +1 -0
  40. package/dist/diagnostics/find-ancestor-file.js +85 -0
  41. package/dist/diagnostics/find-ancestor-file.js.map +1 -0
  42. package/dist/diagnostics/index.d.ts +10 -0
  43. package/dist/diagnostics/index.d.ts.map +1 -0
  44. package/dist/diagnostics/index.js +26 -0
  45. package/dist/diagnostics/index.js.map +1 -0
  46. package/dist/diagnostics/run-primitive-diagnostics.d.ts +43 -0
  47. package/dist/diagnostics/run-primitive-diagnostics.d.ts.map +1 -0
  48. package/dist/diagnostics/run-primitive-diagnostics.js +413 -0
  49. package/dist/diagnostics/run-primitive-diagnostics.js.map +1 -0
  50. package/dist/diagnostics/sandbox-snapshot.d.ts +20 -0
  51. package/dist/diagnostics/sandbox-snapshot.d.ts.map +1 -0
  52. package/dist/diagnostics/sandbox-snapshot.js +117 -0
  53. package/dist/diagnostics/sandbox-snapshot.js.map +1 -0
  54. package/dist/governance/generate-catalogue.d.ts +16 -0
  55. package/dist/governance/generate-catalogue.d.ts.map +1 -0
  56. package/dist/governance/generate-catalogue.js +67 -0
  57. package/dist/governance/generate-catalogue.js.map +1 -0
  58. package/dist/governance/hub-scoped-governance.d.ts +37 -0
  59. package/dist/governance/hub-scoped-governance.d.ts.map +1 -0
  60. package/dist/governance/hub-scoped-governance.js +110 -0
  61. package/dist/governance/hub-scoped-governance.js.map +1 -0
  62. package/dist/governance/index.d.ts +10 -0
  63. package/dist/governance/index.d.ts.map +1 -0
  64. package/dist/governance/index.js +26 -0
  65. package/dist/governance/index.js.map +1 -0
  66. package/dist/governance/load-config.d.ts +45 -0
  67. package/dist/governance/load-config.d.ts.map +1 -0
  68. package/dist/governance/load-config.js +137 -0
  69. package/dist/governance/load-config.js.map +1 -0
  70. package/dist/governance/pr-scope.d.ts +23 -0
  71. package/dist/governance/pr-scope.d.ts.map +1 -0
  72. package/dist/governance/pr-scope.js +22 -0
  73. package/dist/governance/pr-scope.js.map +1 -0
  74. package/dist/governance/report.d.ts +23 -0
  75. package/dist/governance/report.d.ts.map +1 -0
  76. package/dist/governance/report.js +177 -0
  77. package/dist/governance/report.js.map +1 -0
  78. package/dist/governance/run-governance.d.ts +22 -0
  79. package/dist/governance/run-governance.d.ts.map +1 -0
  80. package/dist/governance/run-governance.js +78 -0
  81. package/dist/governance/run-governance.js.map +1 -0
  82. package/dist/governance/source-checks.d.ts +29 -0
  83. package/dist/governance/source-checks.d.ts.map +1 -0
  84. package/dist/governance/source-checks.js +80 -0
  85. package/dist/governance/source-checks.js.map +1 -0
  86. package/dist/governance/validate-collection-governance.d.ts +46 -0
  87. package/dist/governance/validate-collection-governance.d.ts.map +1 -0
  88. package/dist/governance/validate-collection-governance.js +291 -0
  89. package/dist/governance/validate-collection-governance.js.map +1 -0
  90. package/dist/hub-editor/hub-config-editor-service.d.ts +94 -0
  91. package/dist/hub-editor/hub-config-editor-service.d.ts.map +1 -0
  92. package/dist/hub-editor/hub-config-editor-service.js +289 -0
  93. package/dist/hub-editor/hub-config-editor-service.js.map +1 -0
  94. package/dist/hub-editor/hub-contribution-workflow.d.ts +99 -0
  95. package/dist/hub-editor/hub-contribution-workflow.d.ts.map +1 -0
  96. package/dist/hub-editor/hub-contribution-workflow.js +385 -0
  97. package/dist/hub-editor/hub-contribution-workflow.js.map +1 -0
  98. package/dist/hub-editor/index.d.ts +7 -0
  99. package/dist/hub-editor/index.d.ts.map +1 -0
  100. package/dist/hub-editor/index.js +23 -0
  101. package/dist/hub-editor/index.js.map +1 -0
  102. package/dist/index.d.ts +6 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +6 -0
  105. package/dist/index.js.map +1 -1
  106. package/dist/install/index.d.ts +2 -0
  107. package/dist/install/index.d.ts.map +1 -1
  108. package/dist/install/index.js +3 -1
  109. package/dist/install/index.js.map +1 -1
  110. package/dist/install/partial-target-write.d.ts +63 -0
  111. package/dist/install/partial-target-write.d.ts.map +1 -0
  112. package/dist/install/partial-target-write.js +128 -0
  113. package/dist/install/partial-target-write.js.map +1 -0
  114. package/dist/install/pipeline.d.ts +2 -1
  115. package/dist/install/pipeline.d.ts.map +1 -1
  116. package/dist/install/pipeline.js +4 -3
  117. package/dist/install/pipeline.js.map +1 -1
  118. package/dist/install/target-write.d.ts +10 -0
  119. package/dist/install/target-write.d.ts.map +1 -1
  120. package/dist/install/target-write.js +3 -2
  121. package/dist/install/target-write.js.map +1 -1
  122. package/dist/install/uninstall-pipeline.d.ts +11 -10
  123. package/dist/install/uninstall-pipeline.d.ts.map +1 -1
  124. package/dist/install/uninstall-pipeline.js +10 -11
  125. package/dist/install/uninstall-pipeline.js.map +1 -1
  126. package/dist/records/atomic-write.d.ts +11 -0
  127. package/dist/records/atomic-write.d.ts.map +1 -0
  128. package/dist/records/atomic-write.js +66 -0
  129. package/dist/records/atomic-write.js.map +1 -0
  130. package/dist/records/confine-path.d.ts +35 -0
  131. package/dist/records/confine-path.d.ts.map +1 -0
  132. package/dist/records/confine-path.js +140 -0
  133. package/dist/records/confine-path.js.map +1 -0
  134. package/dist/records/git-root.d.ts +66 -0
  135. package/dist/records/git-root.d.ts.map +1 -0
  136. package/dist/records/git-root.js +208 -0
  137. package/dist/records/git-root.js.map +1 -0
  138. package/dist/records/index.d.ts +30 -0
  139. package/dist/records/index.d.ts.map +1 -0
  140. package/dist/records/index.js +46 -0
  141. package/dist/records/index.js.map +1 -0
  142. package/dist/records/install-record-service.d.ts +496 -0
  143. package/dist/records/install-record-service.d.ts.map +1 -0
  144. package/dist/records/install-record-service.js +1365 -0
  145. package/dist/records/install-record-service.js.map +1 -0
  146. package/dist/records/install-record-services.d.ts +29 -0
  147. package/dist/records/install-record-services.d.ts.map +1 -0
  148. package/dist/records/install-record-services.js +17 -0
  149. package/dist/records/install-record-services.js.map +1 -0
  150. package/dist/records/legacy-shapes.d.ts +18 -0
  151. package/dist/records/legacy-shapes.d.ts.map +1 -0
  152. package/dist/records/legacy-shapes.js +30 -0
  153. package/dist/records/legacy-shapes.js.map +1 -0
  154. package/dist/records/map-tool-to-target.d.ts +33 -0
  155. package/dist/records/map-tool-to-target.d.ts.map +1 -0
  156. package/dist/records/map-tool-to-target.js +98 -0
  157. package/dist/records/map-tool-to-target.js.map +1 -0
  158. package/dist/records/mcp-servers.d.ts +116 -0
  159. package/dist/records/mcp-servers.d.ts.map +1 -0
  160. package/dist/records/mcp-servers.js +268 -0
  161. package/dist/records/mcp-servers.js.map +1 -0
  162. package/dist/records/modified-files.d.ts +32 -0
  163. package/dist/records/modified-files.d.ts.map +1 -0
  164. package/dist/records/modified-files.js +146 -0
  165. package/dist/records/modified-files.js.map +1 -0
  166. package/dist/records/plan-record-entries.d.ts +76 -0
  167. package/dist/records/plan-record-entries.d.ts.map +1 -0
  168. package/dist/records/plan-record-entries.js +84 -0
  169. package/dist/records/plan-record-entries.js.map +1 -0
  170. package/dist/records/read-record-text.d.ts +15 -0
  171. package/dist/records/read-record-text.d.ts.map +1 -0
  172. package/dist/records/read-record-text.js +36 -0
  173. package/dist/records/read-record-text.js.map +1 -0
  174. package/dist/records/record-entry.d.ts +31 -0
  175. package/dist/records/record-entry.d.ts.map +1 -0
  176. package/dist/records/record-entry.js +81 -0
  177. package/dist/records/record-entry.js.map +1 -0
  178. package/dist/records/record-file-shape.d.ts +90 -0
  179. package/dist/records/record-file-shape.d.ts.map +1 -0
  180. package/dist/records/record-file-shape.js +288 -0
  181. package/dist/records/record-file-shape.js.map +1 -0
  182. package/dist/records/record-hub.d.ts +42 -0
  183. package/dist/records/record-hub.d.ts.map +1 -0
  184. package/dist/records/record-hub.js +85 -0
  185. package/dist/records/record-hub.js.map +1 -0
  186. package/dist/records/record-identity.d.ts +14 -0
  187. package/dist/records/record-identity.d.ts.map +1 -0
  188. package/dist/records/record-identity.js +41 -0
  189. package/dist/records/record-identity.js.map +1 -0
  190. package/dist/records/record-migration.d.ts +118 -0
  191. package/dist/records/record-migration.d.ts.map +1 -0
  192. package/dist/records/record-migration.js +454 -0
  193. package/dist/records/record-migration.js.map +1 -0
  194. package/dist/records/record-store.d.ts +123 -0
  195. package/dist/records/record-store.d.ts.map +1 -0
  196. package/dist/records/record-store.js +291 -0
  197. package/dist/records/record-store.js.map +1 -0
  198. package/dist/records/resolve-record-source.d.ts +64 -0
  199. package/dist/records/resolve-record-source.d.ts.map +1 -0
  200. package/dist/records/resolve-record-source.js +160 -0
  201. package/dist/records/resolve-record-source.js.map +1 -0
  202. package/dist/records/sanitize-source.d.ts +18 -0
  203. package/dist/records/sanitize-source.d.ts.map +1 -0
  204. package/dist/records/sanitize-source.js +90 -0
  205. package/dist/records/sanitize-source.js.map +1 -0
  206. package/dist/records/select-record.d.ts +54 -0
  207. package/dist/records/select-record.d.ts.map +1 -0
  208. package/dist/records/select-record.js +180 -0
  209. package/dist/records/select-record.js.map +1 -0
  210. package/dist/records/serialize-record.d.ts +20 -0
  211. package/dist/records/serialize-record.d.ts.map +1 -0
  212. package/dist/records/serialize-record.js +100 -0
  213. package/dist/records/serialize-record.js.map +1 -0
  214. package/dist/records/source-fields.d.ts +21 -0
  215. package/dist/records/source-fields.d.ts.map +1 -0
  216. package/dist/records/source-fields.js +28 -0
  217. package/dist/records/source-fields.js.map +1 -0
  218. package/dist/records/to-record-source.d.ts +23 -0
  219. package/dist/records/to-record-source.d.ts.map +1 -0
  220. package/dist/records/to-record-source.js +39 -0
  221. package/dist/records/to-record-source.js.map +1 -0
  222. package/dist/records/user-home.d.ts +16 -0
  223. package/dist/records/user-home.d.ts.map +1 -0
  224. package/dist/records/user-home.js +84 -0
  225. package/dist/records/user-home.js.map +1 -0
  226. package/dist/records/writer-group.d.ts +7 -0
  227. package/dist/records/writer-group.d.ts.map +1 -0
  228. package/dist/records/writer-group.js +31 -0
  229. package/dist/records/writer-group.js.map +1 -0
  230. package/dist/registry/activate-registry-profile.d.ts.map +1 -1
  231. package/dist/registry/activate-registry-profile.js +4 -1
  232. package/dist/registry/activate-registry-profile.js.map +1 -1
  233. package/dist/registry/batch-install-profile.d.ts +76 -0
  234. package/dist/registry/batch-install-profile.d.ts.map +1 -0
  235. package/dist/registry/batch-install-profile.js +67 -0
  236. package/dist/registry/batch-install-profile.js.map +1 -0
  237. package/dist/registry/create-source-adapter.d.ts +16 -1
  238. package/dist/registry/create-source-adapter.d.ts.map +1 -1
  239. package/dist/registry/create-source-adapter.js +76 -3
  240. package/dist/registry/create-source-adapter.js.map +1 -1
  241. package/dist/registry/hub-manager.d.ts +41 -0
  242. package/dist/registry/hub-manager.d.ts.map +1 -1
  243. package/dist/registry/hub-manager.js +82 -4
  244. package/dist/registry/hub-manager.js.map +1 -1
  245. package/dist/registry/index.d.ts +1 -0
  246. package/dist/registry/index.d.ts.map +1 -1
  247. package/dist/registry/index.js +1 -0
  248. package/dist/registry/index.js.map +1 -1
  249. package/dist/registry/install-registry-bundle.js +4 -3
  250. package/dist/registry/install-registry-bundle.js.map +1 -1
  251. package/dist/registry/list-installed-bundles.d.ts +2 -3
  252. package/dist/registry/list-installed-bundles.d.ts.map +1 -1
  253. package/dist/registry/list-installed-bundles.js.map +1 -1
  254. package/dist/registry/load-hub-sources.d.ts +8 -0
  255. package/dist/registry/load-hub-sources.d.ts.map +1 -1
  256. package/dist/registry/load-hub-sources.js +70 -3
  257. package/dist/registry/load-hub-sources.js.map +1 -1
  258. package/dist/registry/profile-lifecycle.d.ts +7 -2
  259. package/dist/registry/profile-lifecycle.d.ts.map +1 -1
  260. package/dist/registry/profile-lifecycle.js +82 -11
  261. package/dist/registry/profile-lifecycle.js.map +1 -1
  262. package/dist/registry/uninstall-installed-bundle.d.ts +2 -3
  263. package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -1
  264. package/dist/registry/uninstall-installed-bundle.js.map +1 -1
  265. package/dist/registry/update-registry-bundle.d.ts +2 -2
  266. package/dist/registry/update-registry-bundle.js +2 -2
  267. package/dist/registry/update-registry-bundle.js.map +1 -1
  268. package/dist/registry/validate-hub-config-file.d.ts +14 -1
  269. package/dist/registry/validate-hub-config-file.d.ts.map +1 -1
  270. package/dist/registry/validate-hub-config-file.js +81 -44
  271. package/dist/registry/validate-hub-config-file.js.map +1 -1
  272. package/dist/release/plan-bundle-release.d.ts +6 -12
  273. package/dist/release/plan-bundle-release.d.ts.map +1 -1
  274. package/dist/release/plan-bundle-release.js +178 -7
  275. package/dist/release/plan-bundle-release.js.map +1 -1
  276. package/dist/replicate/replicate.d.ts +5 -2
  277. package/dist/replicate/replicate.d.ts.map +1 -1
  278. package/dist/replicate/replicate.js +121 -17
  279. package/dist/replicate/replicate.js.map +1 -1
  280. package/dist/security/index.d.ts +4 -0
  281. package/dist/security/index.d.ts.map +1 -0
  282. package/dist/security/index.js +22 -0
  283. package/dist/security/index.js.map +1 -0
  284. package/dist/security/rating/bundle-discovery.d.ts +19 -0
  285. package/dist/security/rating/bundle-discovery.d.ts.map +1 -0
  286. package/dist/security/rating/bundle-discovery.js +244 -0
  287. package/dist/security/rating/bundle-discovery.js.map +1 -0
  288. package/dist/security/rating/index.d.ts +5 -0
  289. package/dist/security/rating/index.d.ts.map +1 -0
  290. package/dist/security/rating/index.js +21 -0
  291. package/dist/security/rating/index.js.map +1 -0
  292. package/dist/security/rating/security-rating-markdown.d.ts +17 -0
  293. package/dist/security/rating/security-rating-markdown.d.ts.map +1 -0
  294. package/dist/security/rating/security-rating-markdown.js +131 -0
  295. package/dist/security/rating/security-rating-markdown.js.map +1 -0
  296. package/dist/security/rating/security-rating-scan.d.ts +23 -0
  297. package/dist/security/rating/security-rating-scan.d.ts.map +1 -0
  298. package/dist/security/rating/security-rating-scan.js +40 -0
  299. package/dist/security/rating/security-rating-scan.js.map +1 -0
  300. package/dist/security/rating/security-rating-templates.d.ts +40 -0
  301. package/dist/security/rating/security-rating-templates.d.ts.map +1 -0
  302. package/dist/security/rating/security-rating-templates.js +83 -0
  303. package/dist/security/rating/security-rating-templates.js.map +1 -0
  304. package/dist/security/rating/security-rating.d.ts +32 -0
  305. package/dist/security/rating/security-rating.d.ts.map +1 -0
  306. package/dist/security/rating/security-rating.js +94 -0
  307. package/dist/security/rating/security-rating.js.map +1 -0
  308. package/dist/security/security-scan-use-case.d.ts +101 -0
  309. package/dist/security/security-scan-use-case.d.ts.map +1 -0
  310. package/dist/security/security-scan-use-case.js +185 -0
  311. package/dist/security/security-scan-use-case.js.map +1 -0
  312. package/dist/stores/json-lockfile-store.d.ts.map +1 -1
  313. package/dist/stores/json-lockfile-store.js +6 -32
  314. package/dist/stores/json-lockfile-store.js.map +1 -1
  315. package/dist/transform/transformer-registry.d.ts.map +1 -1
  316. package/dist/transform/transformer-registry.js +3 -0
  317. package/dist/transform/transformer-registry.js.map +1 -1
  318. package/dist/transform/transformers/windsurf-transformer.d.ts +5 -0
  319. package/dist/transform/transformers/windsurf-transformer.d.ts.map +1 -1
  320. package/dist/transform/transformers/windsurf-transformer.js.map +1 -1
  321. package/dist/writers/file-tree-writer.d.ts +14 -1
  322. package/dist/writers/file-tree-writer.d.ts.map +1 -1
  323. package/dist/writers/file-tree-writer.js +23 -71
  324. package/dist/writers/file-tree-writer.js.map +1 -1
  325. package/package.json +5 -4
@@ -0,0 +1,96 @@
1
+ import { type Clock, type CollectionContributionEligibility, type CollectionContributionSession, type FileSystem, type GitHubAccountResolution, type GitHubCollaborationPort, type GitWorkspacePort, type HubPullRequestInfo, type RegistrySource } from '@ai-primitives-hub/core';
2
+ export interface CollectionContributionWorkflowDeps {
3
+ fs: FileSystem;
4
+ clock: Clock;
5
+ github: GitHubCollaborationPort;
6
+ git: GitWorkspacePort;
7
+ /** File path where active collection contribution sessions are persisted. */
8
+ sessionStorePath: string;
9
+ }
10
+ export interface BootstrapCollectionContributionInput {
11
+ source: Pick<RegistrySource, 'id' | 'name' | 'type' | 'url' | 'config'>;
12
+ bundleId?: string;
13
+ targetDir: string;
14
+ branchName?: string;
15
+ preferredGitHubLogin?: string;
16
+ }
17
+ export interface SubmitCollectionPullRequestInput {
18
+ workspaceDir: string;
19
+ collectionsPath?: string;
20
+ commitMessage?: string;
21
+ prTitle?: string;
22
+ prBody?: string;
23
+ draft?: boolean;
24
+ }
25
+ export interface CollectionWorkspaceContributionContext {
26
+ isCollectionWorkspace: boolean;
27
+ workspaceDir: string;
28
+ collectionsPath: string;
29
+ collectionFiles: string[];
30
+ upstreamSlug?: string;
31
+ forkSlug?: string;
32
+ currentBranch?: string;
33
+ defaultBranch: string;
34
+ modifiedFiles: string[];
35
+ hasUncommittedChanges: boolean;
36
+ session?: CollectionContributionSession;
37
+ }
38
+ export declare class CollectionContributionWorkflowService {
39
+ private readonly deps;
40
+ constructor(deps: CollectionContributionWorkflowDeps);
41
+ private normalizeDirKey;
42
+ private readAllSessions;
43
+ private loadSession;
44
+ private saveSession;
45
+ private listWorkspaceCollectionRelFiles;
46
+ /**
47
+ * Determine whether a registry source (and optional bundle ID) is eligible
48
+ * for collection contribution and visual editing.
49
+ * @param source Registry source descriptor.
50
+ * @param bundleId Optional Marketplace/Explorer bundle ID.
51
+ */
52
+ evaluateSourceForContribution(source: Pick<RegistrySource, 'type' | 'url' | 'config'>, bundleId?: string): Promise<CollectionContributionEligibility & {
53
+ targetCollectionId?: string;
54
+ targetCollectionFilePath?: string;
55
+ }>;
56
+ /**
57
+ * Probe available `gh auth` accounts against a target `owner/repo` and
58
+ * optionally switch the active `gh` account to one with verified access.
59
+ * @param repositorySlug Target `owner/repo` slug.
60
+ * @param options Account resolution options.
61
+ * @param options.switchActive
62
+ * @param options.preferredLogin
63
+ */
64
+ resolveCollectionGitHubAccount(repositorySlug: string, options?: {
65
+ switchActive?: boolean;
66
+ preferredLogin?: string;
67
+ }): Promise<GitHubAccountResolution | undefined>;
68
+ /**
69
+ * Execute the `Fork -> Clone -> Branch -> Resolve Target Collection` pipeline
70
+ * and persist the contribution session.
71
+ * @param input Bootstrap parameters.
72
+ */
73
+ bootstrapContributionWorkspace(input: BootstrapCollectionContributionInput): Promise<CollectionContributionSession & {
74
+ accountResolution?: GitHubAccountResolution;
75
+ }>;
76
+ /**
77
+ * Inspect a local workspace directory to determine its collection contribution state.
78
+ * @param workspaceDir Local workspace root directory.
79
+ * @param collectionsPath Optional relative collections folder.
80
+ */
81
+ getWorkspaceContributionContext(workspaceDir: string, collectionsPath?: string): Promise<CollectionWorkspaceContributionContext>;
82
+ /**
83
+ * Validate all collections in the workspace, stage all modified/created
84
+ * `.collection.yml` manifests and primitive files, commit, push to the fork
85
+ * remote, and create a Pull Request against the upstream collection repo.
86
+ * @param input Submission options.
87
+ */
88
+ submitPullRequest(input: SubmitCollectionPullRequestInput): Promise<HubPullRequestInfo>;
89
+ /**
90
+ * Refresh the Pull Request and CI check-run status for a local collection workspace.
91
+ * Only open Pull Requests are tracked; closed/merged PRs are cleared from active state.
92
+ * @param workspaceDir Local workspace root directory.
93
+ */
94
+ refreshPullRequestStatus(workspaceDir: string): Promise<HubPullRequestInfo | undefined>;
95
+ }
96
+ //# sourceMappingURL=collection-contribution-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-contribution-workflow.d.ts","sourceRoot":"","sources":["../../src/collection-editor/collection-contribution-workflow.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,iCAAiC,EACtC,KAAK,6BAA6B,EAClC,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AAOjC,MAAM,WAAW,kCAAkC;IACjD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,uBAAuB,CAAC;IAChC,GAAG,EAAE,gBAAgB,CAAC;IACtB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;C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,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,iCAAiC,GAAG;QAAE,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAAC,wBAAwB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBlH;;;;;;;OAOG;IACU,8BAA8B,CACzC,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC;IAW/C;;;;OAIG;IACU,8BAA8B,CACzC,KAAK,EAAE,oCAAoC,GAC1C,OAAO,CAAC,6BAA6B,GAAG;QAAE,iBAAiB,CAAC,EAAE,uBAAuB,CAAA;KAAE,CAAC;IA8F3F;;;;OAIG;IACU,+BAA+B,CAC1C,YAAY,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,sCAAsC,CAAC;IAgClD;;;;;OAKG;IACU,iBAAiB,CAC5B,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,kBAAkB,CAAC;IAoM9B;;;;OAIG;IACU,wBAAwB,CACnC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CA8E3C"}
@@ -0,0 +1,479 @@
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.CollectionContributionWorkflowService = void 0;
37
+ /**
38
+ * Orchestrates the end-to-end Collection Contributor Workflow:
39
+ * - Enforces GitHub-connected collection source eligibility (rejecting
40
+ * Artifactory sources as read-only replicas populated by promotion)
41
+ * - Resolves the target `<collectionId>` and `.collection.yml` path from a
42
+ * Marketplace tile or Registry Explorer item
43
+ * - Forks the upstream GitHub collection repository
44
+ * - Clones or attaches to a local repository checkout
45
+ * - Configures `origin` (fork) and `upstream` remotes and checks out a branch
46
+ * - Validates collections, stages multi-file changes (`.collection.yml` +
47
+ * referenced primitives), commits, pushes, creates a Pull Request, and tracks
48
+ * open PR/CI check status
49
+ * @module collection-editor/collection-contribution-workflow
50
+ */
51
+ const path = __importStar(require("node:path"));
52
+ const core_1 = require("@ai-primitives-hub/core");
53
+ const infra_1 = require("@ai-primitives-hub/infra");
54
+ class CollectionContributionWorkflowService {
55
+ deps;
56
+ constructor(deps) {
57
+ this.deps = deps;
58
+ }
59
+ normalizeDirKey(dir) {
60
+ return path.resolve(dir).replaceAll('\\', '/');
61
+ }
62
+ async readAllSessions() {
63
+ try {
64
+ if (!(await this.deps.fs.exists(this.deps.sessionStorePath))) {
65
+ return {};
66
+ }
67
+ const raw = await this.deps.fs.readFile(this.deps.sessionStorePath);
68
+ const parsed = JSON.parse(raw);
69
+ return parsed.sessions && typeof parsed.sessions === 'object' ? parsed.sessions : {};
70
+ }
71
+ catch {
72
+ return {};
73
+ }
74
+ }
75
+ async loadSession(workspaceDir) {
76
+ const all = await this.readAllSessions();
77
+ return all[this.normalizeDirKey(workspaceDir)];
78
+ }
79
+ async saveSession(session) {
80
+ const all = await this.readAllSessions();
81
+ all[this.normalizeDirKey(session.workspaceDir)] = session;
82
+ await this.deps.fs.mkdir(path.dirname(this.deps.sessionStorePath), { recursive: true });
83
+ await this.deps.fs.writeFile(this.deps.sessionStorePath, JSON.stringify({ sessions: all }, null, 2));
84
+ }
85
+ async listWorkspaceCollectionRelFiles(workspaceDir, collectionsPath = 'collections') {
86
+ const absDir = path.join(workspaceDir, collectionsPath);
87
+ if (!(await this.deps.fs.exists(absDir))) {
88
+ return [];
89
+ }
90
+ try {
91
+ const entries = await this.deps.fs.readDir(absDir);
92
+ return entries
93
+ .filter((f) => /\.collection\.ya?ml$/i.test(f))
94
+ .toSorted()
95
+ .map((f) => `${collectionsPath}/${f}`.replaceAll('\\', '/'));
96
+ }
97
+ catch {
98
+ return [];
99
+ }
100
+ }
101
+ /**
102
+ * Determine whether a registry source (and optional bundle ID) is eligible
103
+ * for collection contribution and visual editing.
104
+ * @param source Registry source descriptor.
105
+ * @param bundleId Optional Marketplace/Explorer bundle ID.
106
+ */
107
+ async evaluateSourceForContribution(source, bundleId) {
108
+ let remoteSlug;
109
+ if ((source.type === 'local' || source.type === 'local-awesome-copilot') && source.url) {
110
+ const remotes = await this.deps.git.getRemotes(source.url);
111
+ const remoteUrl = remotes.upstream ?? remotes.origin;
112
+ remoteSlug = remoteUrl ? (0, infra_1.extractGitHubSlugFromRemoteUrl)(remoteUrl) : undefined;
113
+ }
114
+ const eligibility = (0, core_1.isContributableCollectionSource)(source, remoteSlug);
115
+ const resolvedTarget = bundleId ? (0, core_1.resolveCollectionIdFromBundle)(bundleId, source) : null;
116
+ return {
117
+ ...eligibility,
118
+ targetCollectionId: resolvedTarget?.collectionId,
119
+ targetCollectionFilePath: resolvedTarget?.collectionFilePath
120
+ };
121
+ }
122
+ /**
123
+ * Probe available `gh auth` accounts against a target `owner/repo` and
124
+ * optionally switch the active `gh` account to one with verified access.
125
+ * @param repositorySlug Target `owner/repo` slug.
126
+ * @param options Account resolution options.
127
+ * @param options.switchActive
128
+ * @param options.preferredLogin
129
+ */
130
+ async resolveCollectionGitHubAccount(repositorySlug, options) {
131
+ if (!this.deps.github.resolveAccessibleAccount) {
132
+ return undefined;
133
+ }
134
+ const [owner, repo] = repositorySlug.split('/');
135
+ if (!owner || !repo) {
136
+ return undefined;
137
+ }
138
+ return this.deps.github.resolveAccessibleAccount(owner, repo, options);
139
+ }
140
+ /**
141
+ * Execute the `Fork -> Clone -> Branch -> Resolve Target Collection` pipeline
142
+ * and persist the contribution session.
143
+ * @param input Bootstrap parameters.
144
+ */
145
+ async bootstrapContributionWorkspace(input) {
146
+ const eligibility = await this.evaluateSourceForContribution(input.source, input.bundleId);
147
+ if (!eligibility.contributable || !eligibility.repositorySlug) {
148
+ throw new Error(eligibility.reason
149
+ ?? 'Only GitHub-connected collection sources support contribution.');
150
+ }
151
+ const [upstreamOwner, upstreamRepo] = eligibility.repositorySlug.split('/');
152
+ const accountResolution = await this.resolveCollectionGitHubAccount(eligibility.repositorySlug, {
153
+ switchActive: true,
154
+ preferredLogin: input.preferredGitHubLogin
155
+ });
156
+ if (accountResolution && accountResolution.accounts.length > 0 && !accountResolution.selectedAccount) {
157
+ throw new Error(accountResolution.message
158
+ ?? `No GitHub CLI account has access to ${eligibility.repositorySlug}.`);
159
+ }
160
+ const fork = await this.deps.github.ensureFork(upstreamOwner, upstreamRepo);
161
+ const upstreamCloneUrl = `https://github.com/${eligibility.repositorySlug}.git`;
162
+ const isAlreadyGit = await this.deps.git.isGitRepository(input.targetDir);
163
+ if (!isAlreadyGit) {
164
+ await this.deps.git.cloneRepository(fork.cloneUrl, input.targetDir);
165
+ }
166
+ const existingRemotes = await this.deps.git.getRemotes(input.targetDir);
167
+ const sameRepo = (url, slug) => url !== undefined && (0, infra_1.extractGitHubSlugFromRemoteUrl)(url)?.toLowerCase() === slug.toLowerCase();
168
+ if (!sameRepo(existingRemotes.origin, fork.fullName)) {
169
+ await this.deps.git.ensureRemote(input.targetDir, 'origin', fork.cloneUrl);
170
+ }
171
+ if (!sameRepo(existingRemotes.upstream, eligibility.repositorySlug)) {
172
+ await this.deps.git.ensureRemote(input.targetDir, 'upstream', upstreamCloneUrl);
173
+ }
174
+ const upstreamRepoMeta = await this.deps.github.getRepository(upstreamOwner, upstreamRepo)
175
+ .catch(() => ({ defaultBranch: fork.defaultBranch }));
176
+ const requestedBranch = eligibility.branch;
177
+ const baseBranch = requestedBranch && !/^[0-9a-f]{7,40}$/i.test(requestedBranch)
178
+ ? requestedBranch
179
+ : upstreamRepoMeta.defaultBranch;
180
+ await this.deps.git.fetchRemote(input.targetDir, 'upstream', baseBranch);
181
+ const defaultFeatureBranch = eligibility.targetCollectionId
182
+ ? `feat/collection-${eligibility.targetCollectionId}`
183
+ : 'feat/update-collections';
184
+ const branchName = input.branchName?.trim() || defaultFeatureBranch;
185
+ await this.deps.git.checkoutBranch(input.targetDir, branchName, {
186
+ create: true,
187
+ startPoint: `upstream/${baseBranch}`
188
+ });
189
+ const detectedFiles = await this.listWorkspaceCollectionRelFiles(input.targetDir, eligibility.collectionsPath);
190
+ let targetCollectionPath;
191
+ if (eligibility.targetCollectionFilePath) {
192
+ const candidateAbs = path.join(input.targetDir, eligibility.targetCollectionFilePath);
193
+ if (await this.deps.fs.exists(candidateAbs)) {
194
+ targetCollectionPath = candidateAbs;
195
+ }
196
+ }
197
+ if (!targetCollectionPath && detectedFiles.length > 0) {
198
+ targetCollectionPath = path.join(input.targetDir, detectedFiles[0]);
199
+ }
200
+ const session = {
201
+ sourceId: input.source.id,
202
+ sourceName: input.source.name,
203
+ sourceType: input.source.type,
204
+ collectionId: eligibility.targetCollectionId,
205
+ collectionsPath: eligibility.collectionsPath,
206
+ upstreamSlug: eligibility.repositorySlug,
207
+ forkSlug: fork.fullName,
208
+ defaultBranch: baseBranch,
209
+ branchName,
210
+ workspaceDir: input.targetDir,
211
+ targetCollectionPath,
212
+ updatedAt: this.deps.clock.nowIso()
213
+ };
214
+ await this.saveSession(session);
215
+ return {
216
+ ...session,
217
+ accountResolution
218
+ };
219
+ }
220
+ /**
221
+ * Inspect a local workspace directory to determine its collection contribution state.
222
+ * @param workspaceDir Local workspace root directory.
223
+ * @param collectionsPath Optional relative collections folder.
224
+ */
225
+ async getWorkspaceContributionContext(workspaceDir, collectionsPath) {
226
+ const savedSession = await this.loadSession(workspaceDir);
227
+ const effectiveCollectionsPath = collectionsPath ?? savedSession?.collectionsPath ?? 'collections';
228
+ const collectionFiles = await this.listWorkspaceCollectionRelFiles(workspaceDir, effectiveCollectionsPath);
229
+ const status = await this.deps.git.getStatus(workspaceDir);
230
+ const originSlug = status.remotes.origin
231
+ ? (0, infra_1.extractGitHubSlugFromRemoteUrl)(status.remotes.origin)
232
+ : savedSession?.forkSlug;
233
+ const upstreamSlug = status.remotes.upstream
234
+ ? (0, infra_1.extractGitHubSlugFromRemoteUrl)(status.remotes.upstream)
235
+ : (savedSession?.upstreamSlug ?? originSlug);
236
+ const activeSession = savedSession?.pullRequest && savedSession.pullRequest.state !== 'open'
237
+ ? { ...savedSession, pullRequest: undefined }
238
+ : savedSession;
239
+ return {
240
+ isCollectionWorkspace: collectionFiles.length > 0,
241
+ workspaceDir,
242
+ collectionsPath: effectiveCollectionsPath,
243
+ collectionFiles,
244
+ upstreamSlug,
245
+ forkSlug: originSlug,
246
+ currentBranch: status.currentBranch ?? savedSession?.branchName,
247
+ defaultBranch: savedSession?.defaultBranch ?? 'main',
248
+ modifiedFiles: status.modifiedFiles,
249
+ hasUncommittedChanges: status.hasUncommittedChanges,
250
+ session: activeSession
251
+ };
252
+ }
253
+ /**
254
+ * Validate all collections in the workspace, stage all modified/created
255
+ * `.collection.yml` manifests and primitive files, commit, push to the fork
256
+ * remote, and create a Pull Request against the upstream collection repo.
257
+ * @param input Submission options.
258
+ */
259
+ async submitPullRequest(input) {
260
+ const context = await this.getWorkspaceContributionContext(input.workspaceDir, input.collectionsPath);
261
+ if (!context.upstreamSlug) {
262
+ throw new Error('Workspace does not have a GitHub upstream or origin remote.');
263
+ }
264
+ const [upstreamOwner, upstreamRepo] = context.upstreamSlug.split('/');
265
+ const defaultBranch = context.session?.defaultBranch
266
+ ?? (await this.deps.github.getRepository(upstreamOwner, upstreamRepo).catch(() => undefined))?.defaultBranch
267
+ ?? context.defaultBranch;
268
+ const branchName = context.currentBranch ?? 'feat/update-collections';
269
+ if (branchName === defaultBranch || branchName === 'HEAD') {
270
+ throw new Error(`Refusing to commit directly to '${branchName}'. Check out a feature branch before submitting a Pull Request.`);
271
+ }
272
+ if (context.collectionFiles.length === 0) {
273
+ throw new Error(`No collection files (*.collection.yml) found in '${context.collectionsPath}/'.`);
274
+ }
275
+ // Validate all collection files in the workspace (including duplicate ID/name checks)
276
+ const contentsByRel = new Map();
277
+ const siblingSummaries = [];
278
+ for (const relFile of context.collectionFiles) {
279
+ const raw = await this.deps.fs.readFile(path.join(input.workspaceDir, relFile));
280
+ contentsByRel.set(relFile, raw);
281
+ const quickVal = (0, infra_1.validateCollectionYaml)(raw, { fileLabel: relFile });
282
+ siblingSummaries.push({
283
+ file: relFile,
284
+ id: quickVal.manifest?.id,
285
+ name: quickVal.manifest?.name
286
+ });
287
+ }
288
+ const allErrors = [];
289
+ for (const [relFile, raw] of contentsByRel.entries()) {
290
+ const res = (0, infra_1.validateCollectionYaml)(raw, {
291
+ fileLabel: relFile,
292
+ siblingCollections: siblingSummaries
293
+ });
294
+ if (!res.valid) {
295
+ allErrors.push(...res.errors);
296
+ }
297
+ }
298
+ if (allErrors.length > 0) {
299
+ throw new Error(`Cannot submit Pull Request because collection validation failed:\n- ${allErrors.join('\n- ')}`);
300
+ }
301
+ await this.resolveCollectionGitHubAccount(context.upstreamSlug, { switchActive: true });
302
+ // Restrict staged files to collection manifests and paths referenced by them
303
+ // (items, skill/plugin/power directories, and readme.path) so unrelated or
304
+ // sensitive untracked files in the workspace are never staged automatically.
305
+ const referencedFiles = new Set(context.collectionFiles);
306
+ const referencedDirPrefixes = [];
307
+ for (const raw of contentsByRel.values()) {
308
+ const manifest = (0, infra_1.validateCollectionYaml)(raw).manifest;
309
+ for (const item of manifest?.items ?? []) {
310
+ if (item?.path) {
311
+ const normalizedItemPath = item.path.replaceAll('\\', '/').replace(/^\/+/, '');
312
+ referencedFiles.add(normalizedItemPath);
313
+ if (item.kind === 'skill' || item.kind === 'plugin' || item.kind === 'power') {
314
+ const dirPrefix = path.posix.dirname(normalizedItemPath);
315
+ if (dirPrefix && dirPrefix !== '.') {
316
+ referencedDirPrefixes.push(`${dirPrefix}/`);
317
+ }
318
+ }
319
+ }
320
+ }
321
+ if (manifest?.readme?.path) {
322
+ referencedFiles.add(manifest.readme.path.replaceAll('\\', '/').replace(/^\/+/, ''));
323
+ }
324
+ }
325
+ const filesToStage = context.modifiedFiles.filter((file) => {
326
+ const normalized = file.replaceAll('\\', '/').replace(/^\/+/, '');
327
+ return /\.collection\.ya?ml$/i.test(normalized)
328
+ || referencedFiles.has(normalized)
329
+ || referencedDirPrefixes.some((prefix) => normalized.startsWith(prefix));
330
+ });
331
+ // Summarize changes across modified collection files
332
+ const modifiedCollectionFiles = filesToStage.filter((f) => /\.collection\.ya?ml$/i.test(f));
333
+ const targetCollectionFilesForSummary = modifiedCollectionFiles.length > 0
334
+ ? modifiedCollectionFiles
335
+ : [context.collectionFiles[0]];
336
+ const summaries = [];
337
+ for (const relFile of targetCollectionFilesForSummary) {
338
+ const currentYaml = contentsByRel.get(relFile)
339
+ ?? await this.deps.fs.readFile(path.join(input.workspaceDir, relFile)).catch(() => '');
340
+ const baseYaml = await this.deps.git.getFileAtRef(input.workspaceDir, `upstream/${defaultBranch}`, relFile);
341
+ if (currentYaml) {
342
+ summaries.push((0, infra_1.summarizeCollectionYamlChanges)(baseYaml, currentYaml));
343
+ }
344
+ }
345
+ const primarySummary = summaries[0];
346
+ const primitiveFilesChanged = filesToStage.filter((f) => !/\.collection\.ya?ml$/i.test(f));
347
+ const defaultCommitMessage = primarySummary
348
+ ? primarySummary.suggestedCommitMessage
349
+ : `feat(collection): update collections (${filesToStage.length} file(s))`;
350
+ const defaultPrTitle = primarySummary
351
+ ? primarySummary.suggestedPrTitle
352
+ : `feat(collection): update collections`;
353
+ const bodySections = [];
354
+ if (summaries.length > 0) {
355
+ bodySections.push(summaries.map((s) => s.suggestedPrBody).join('\n\n'));
356
+ }
357
+ else {
358
+ bodySections.push('## Summary\n\n- Updated collection files');
359
+ }
360
+ if (primitiveFilesChanged.length > 0) {
361
+ bodySections.push(`### Modified Primitive & Documentation Files\n\n${primitiveFilesChanged.map((f) => `- \`${f}\``).join('\n')}`);
362
+ }
363
+ const commitMessage = input.commitMessage?.trim() || defaultCommitMessage;
364
+ const prTitle = input.prTitle?.trim() || defaultPrTitle;
365
+ const prBody = input.prBody?.trim() || bodySections.join('\n\n');
366
+ await this.deps.git.commitAndPush(input.workspaceDir, filesToStage, commitMessage, 'origin', branchName);
367
+ const forkOwner = context.forkSlug ? context.forkSlug.split('/')[0] : upstreamOwner;
368
+ const headRef = forkOwner.toLowerCase() === upstreamOwner.toLowerCase()
369
+ ? branchName
370
+ : `${forkOwner}:${branchName}`;
371
+ const existingPrs = await this.deps.github.findPullRequestsForBranch(upstreamOwner, upstreamRepo, `${forkOwner}:${branchName}`);
372
+ const existingOpenPr = existingPrs.find((item) => item.state === 'open')
373
+ ?? (context.session?.pullRequest?.state === 'open' && context.session.pullRequest.headRef === branchName
374
+ ? context.session.pullRequest
375
+ : undefined);
376
+ const pr = existingOpenPr
377
+ ? await this.deps.github.getPullRequestStatus(upstreamOwner, upstreamRepo, existingOpenPr.number)
378
+ : await this.deps.github.createPullRequest({
379
+ upstreamOwner,
380
+ upstreamRepo,
381
+ head: headRef,
382
+ base: defaultBranch,
383
+ title: prTitle,
384
+ body: prBody,
385
+ draft: input.draft
386
+ });
387
+ const sessionToSave = context.session
388
+ ? {
389
+ ...context.session,
390
+ branchName,
391
+ pullRequest: pr,
392
+ updatedAt: this.deps.clock.nowIso()
393
+ }
394
+ : {
395
+ sourceId: context.upstreamSlug.replaceAll('/', '-').toLowerCase(),
396
+ sourceName: context.upstreamSlug,
397
+ sourceType: 'github',
398
+ collectionId: primarySummary?.collectionId,
399
+ collectionsPath: context.collectionsPath,
400
+ upstreamSlug: context.upstreamSlug,
401
+ forkSlug: context.forkSlug ?? context.upstreamSlug,
402
+ defaultBranch,
403
+ branchName,
404
+ workspaceDir: input.workspaceDir,
405
+ targetCollectionPath: context.collectionFiles[0]
406
+ ? path.join(input.workspaceDir, context.collectionFiles[0])
407
+ : undefined,
408
+ pullRequest: pr,
409
+ updatedAt: this.deps.clock.nowIso()
410
+ };
411
+ await this.saveSession(sessionToSave);
412
+ return pr;
413
+ }
414
+ /**
415
+ * Refresh the Pull Request and CI check-run status for a local collection workspace.
416
+ * Only open Pull Requests are tracked; closed/merged PRs are cleared from active state.
417
+ * @param workspaceDir Local workspace root directory.
418
+ */
419
+ async refreshPullRequestStatus(workspaceDir) {
420
+ const context = await this.getWorkspaceContributionContext(workspaceDir);
421
+ if (!context.upstreamSlug) {
422
+ return undefined;
423
+ }
424
+ const [upstreamOwner, upstreamRepo] = context.upstreamSlug.split('/');
425
+ const storedSession = await this.loadSession(workspaceDir);
426
+ const findOpenPrNumberForBranch = async () => {
427
+ if (!context.currentBranch) {
428
+ return undefined;
429
+ }
430
+ const forkOwner = context.forkSlug ? context.forkSlug.split('/')[0] : upstreamOwner;
431
+ const headFilter = `${forkOwner}:${context.currentBranch}`;
432
+ const found = await this.deps.github.findPullRequestsForBranch(upstreamOwner, upstreamRepo, headFilter);
433
+ return found.find((item) => item.state === 'open')?.number;
434
+ };
435
+ let prNumber = storedSession?.pullRequest?.state === 'open'
436
+ ? storedSession.pullRequest.number
437
+ : undefined;
438
+ if (!prNumber) {
439
+ prNumber = await findOpenPrNumberForBranch();
440
+ }
441
+ if (!prNumber) {
442
+ if (storedSession?.pullRequest) {
443
+ await this.saveSession({
444
+ ...storedSession,
445
+ pullRequest: undefined,
446
+ updatedAt: this.deps.clock.nowIso()
447
+ });
448
+ }
449
+ return undefined;
450
+ }
451
+ let status = await this.deps.github.getPullRequestStatus(upstreamOwner, upstreamRepo, prNumber);
452
+ if (status.state !== 'open') {
453
+ const replacementOpenNumber = await findOpenPrNumberForBranch();
454
+ if (replacementOpenNumber && replacementOpenNumber !== prNumber) {
455
+ status = await this.deps.github.getPullRequestStatus(upstreamOwner, upstreamRepo, replacementOpenNumber);
456
+ }
457
+ }
458
+ if (status.state !== 'open') {
459
+ if (storedSession) {
460
+ await this.saveSession({
461
+ ...storedSession,
462
+ pullRequest: undefined,
463
+ updatedAt: this.deps.clock.nowIso()
464
+ });
465
+ }
466
+ return undefined;
467
+ }
468
+ if (storedSession) {
469
+ await this.saveSession({
470
+ ...storedSession,
471
+ pullRequest: status,
472
+ updatedAt: this.deps.clock.nowIso()
473
+ });
474
+ }
475
+ return status;
476
+ }
477
+ }
478
+ exports.CollectionContributionWorkflowService = CollectionContributionWorkflowService;
479
+ //# sourceMappingURL=collection-contribution-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-contribution-workflow.js","sourceRoot":"","sources":["../../src/collection-editor/collection-contribution-workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;GAaG;AACH,gDAAkC;AAClC,kDAYiC;AACjC,oDAIkC;AA8ClC,MAAa,qCAAqC;IACZ;IAApC,YAAoC,IAAwC;QAAxC,SAAI,GAAJ,IAAI,CAAoC;IAAG,CAAC;IAExE,eAAe,CAAC,GAAW;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UA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