@fitlab-ai/agent-infra 0.9.12 → 0.9.13

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 (239) hide show
  1. package/README.md +11 -11
  2. package/README.zh-CN.md +11 -11
  3. package/dist/bin/internal-cli.js +24 -19
  4. package/dist/lib/agent-clients/next-steps.js +6 -1
  5. package/dist/lib/decide.js +3 -3
  6. package/dist/lib/internal/platform-checks.js +3 -3
  7. package/dist/lib/internal/platform-comment.js +9 -9
  8. package/dist/lib/internal/platform-context.js +2 -2
  9. package/dist/lib/internal/platform-issue.js +8 -9
  10. package/dist/lib/internal/platform-pr-review.js +10 -10
  11. package/dist/lib/internal/platform-pr.js +63 -24
  12. package/dist/lib/internal/platform-release-notes.js +3 -3
  13. package/dist/lib/internal/pr-review-grade.js +11 -9
  14. package/dist/lib/internal/release-workflow.js +4 -4
  15. package/dist/lib/internal/sandbox-control.js +30 -4
  16. package/dist/lib/internal/task-activity.js +3 -3
  17. package/dist/lib/internal/task-artifact.js +76 -24
  18. package/dist/lib/internal/task-create.js +2 -2
  19. package/dist/lib/internal/task-event.js +6 -3
  20. package/dist/lib/internal/task-finalization.js +2 -2
  21. package/dist/lib/internal/task-invalidation.js +60 -0
  22. package/dist/lib/internal/task-ledger.js +9 -6
  23. package/dist/lib/internal/task-lifecycle.js +2 -2
  24. package/dist/lib/internal/task-override.js +4 -4
  25. package/dist/lib/internal/task-review.js +3 -3
  26. package/dist/lib/internal/task-verify.js +6 -6
  27. package/dist/lib/internal/task-warning.js +3 -3
  28. package/dist/lib/platform/adapters.js +1 -3
  29. package/dist/lib/platform/change-request-git-evidence.js +27 -7
  30. package/dist/lib/platform/completion-backfill.js +6 -5
  31. package/dist/lib/platform/context.js +70 -130
  32. package/dist/lib/platform/github-client.js +1 -1
  33. package/dist/lib/platform/github-provider.js +903 -0
  34. package/dist/lib/platform/in-label-sync.js +143 -0
  35. package/dist/lib/platform/issue-comments.js +94 -41
  36. package/dist/lib/platform/issues.js +335 -189
  37. package/dist/lib/platform/metadata-labels.js +6 -2
  38. package/dist/lib/platform/none-provider.js +28 -0
  39. package/dist/lib/platform/pr-change-report.js +551 -0
  40. package/dist/lib/platform/pr-checks.js +119 -104
  41. package/dist/lib/platform/pr-review.js +88 -72
  42. package/dist/lib/platform/pr-summary.js +520 -50
  43. package/dist/lib/platform/provider-bridge.js +45 -0
  44. package/dist/lib/platform/provider-contract.d.ts +487 -0
  45. package/dist/lib/platform/provider-contract.js +95 -0
  46. package/dist/lib/platform/provider-loader.js +251 -0
  47. package/dist/lib/platform/provider-validation.js +504 -0
  48. package/dist/lib/platform/pull-request-metadata.js +8 -6
  49. package/dist/lib/platform/pull-requests.js +783 -537
  50. package/dist/lib/platform/release-notes.js +78 -55
  51. package/dist/lib/platform/releases.js +79 -50
  52. package/dist/lib/platform/resource-identity.d.ts +26 -0
  53. package/dist/lib/platform/resource-identity.js +92 -0
  54. package/dist/lib/platform/task-identities.js +31 -0
  55. package/dist/lib/platform/verification-required.js +11 -12
  56. package/dist/lib/platform/verification-sync.js +112 -238
  57. package/dist/lib/pr-review/evidence-grading.js +19 -6
  58. package/dist/lib/run/index.js +63 -23
  59. package/dist/lib/sandbox/control/client.js +96 -15
  60. package/dist/lib/sandbox/control/executor.js +3 -3
  61. package/dist/lib/sandbox/control/protocol.js +77 -0
  62. package/dist/lib/sandbox/control/server.js +398 -25
  63. package/dist/lib/sandbox/control/state.js +204 -1
  64. package/dist/lib/server/protocol.js +38 -1
  65. package/dist/lib/task/activity-log.js +8 -1
  66. package/dist/lib/task/artifact-lifecycle.js +33 -5
  67. package/dist/lib/task/capabilities.js +239 -0
  68. package/dist/lib/task/commands/status.js +32 -0
  69. package/dist/lib/task/commit-operation.js +12 -1
  70. package/dist/lib/task/control-authority.js +8 -5
  71. package/dist/lib/task/create-service.js +8 -8
  72. package/dist/lib/task/current-contract.js +5 -1
  73. package/dist/lib/task/decision-details.js +1 -1
  74. package/dist/lib/task/events.js +297 -17
  75. package/dist/lib/task/finalization.js +37 -13
  76. package/dist/lib/task/human-override.js +58 -36
  77. package/dist/lib/task/invalidation-command.js +86 -0
  78. package/dist/lib/task/invalidation.js +260 -0
  79. package/dist/lib/task/ledger-intents.js +37 -0
  80. package/dist/lib/task/local-artifact-finalization.js +374 -0
  81. package/dist/lib/task/orchestration.js +49 -93
  82. package/dist/lib/task/pr-delivery-fact.js +102 -101
  83. package/dist/lib/task/review-fingerprint.js +24 -2
  84. package/dist/lib/task/rework-intent.js +138 -0
  85. package/dist/lib/task/skill-scope.js +23 -0
  86. package/dist/lib/task/task-execution-lock.js +27 -17
  87. package/dist/lib/task/verification-engine.js +43 -16
  88. package/dist/lib/task/verification.js +3 -3
  89. package/dist/lib/task/workflow-warning-intents.js +1 -1
  90. package/dist/lib/task/write.js +11 -0
  91. package/dist/lib/version.js +11 -1
  92. package/dist/lifecycle-build-manifest.json +3 -3
  93. package/lib/agent-clients/next-steps.ts +6 -1
  94. package/lib/decide.ts +3 -3
  95. package/lib/init.ts +1 -1
  96. package/lib/internal/platform-checks.ts +3 -3
  97. package/lib/internal/platform-comment.ts +8 -8
  98. package/lib/internal/platform-context.ts +2 -2
  99. package/lib/internal/platform-issue.ts +7 -8
  100. package/lib/internal/platform-pr-review.ts +9 -9
  101. package/lib/internal/platform-pr.ts +47 -22
  102. package/lib/internal/platform-release-notes.ts +3 -3
  103. package/lib/internal/pr-review-grade.ts +10 -8
  104. package/lib/internal/release-workflow.ts +4 -4
  105. package/lib/internal/sandbox-control.ts +27 -3
  106. package/lib/internal/task-activity.ts +3 -3
  107. package/lib/internal/task-artifact.ts +65 -22
  108. package/lib/internal/task-create.ts +2 -2
  109. package/lib/internal/task-event.ts +6 -3
  110. package/lib/internal/task-finalization.ts +3 -3
  111. package/lib/internal/task-invalidation.ts +39 -0
  112. package/lib/internal/task-ledger.ts +11 -8
  113. package/lib/internal/task-lifecycle.ts +2 -2
  114. package/lib/internal/task-override.ts +6 -6
  115. package/lib/internal/task-review.ts +3 -3
  116. package/lib/internal/task-verify.ts +6 -6
  117. package/lib/internal/task-warning.ts +3 -3
  118. package/lib/platform/adapters.ts +3 -2
  119. package/lib/platform/change-request-git-evidence.ts +36 -9
  120. package/lib/platform/completion-backfill.ts +9 -8
  121. package/lib/platform/context.ts +97 -134
  122. package/lib/platform/github-client.ts +2 -2
  123. package/lib/platform/github-provider.ts +910 -0
  124. package/lib/platform/in-label-sync.ts +208 -0
  125. package/lib/platform/issue-comments.ts +97 -47
  126. package/lib/platform/issues.ts +344 -174
  127. package/lib/platform/metadata-labels.ts +5 -2
  128. package/lib/platform/none-provider.ts +35 -0
  129. package/lib/platform/pr-change-report.ts +645 -0
  130. package/lib/platform/pr-checks.ts +126 -106
  131. package/lib/platform/pr-review.ts +88 -85
  132. package/lib/platform/pr-summary.ts +560 -53
  133. package/lib/platform/provider-bridge.ts +82 -0
  134. package/lib/platform/provider-contract.ts +536 -0
  135. package/lib/platform/provider-loader.ts +307 -0
  136. package/lib/platform/provider-validation.ts +529 -0
  137. package/lib/platform/pull-request-metadata.ts +10 -7
  138. package/lib/platform/pull-requests.ts +826 -543
  139. package/lib/platform/release-notes.ts +76 -59
  140. package/lib/platform/releases.ts +77 -43
  141. package/lib/platform/resource-identity.ts +121 -0
  142. package/lib/platform/task-identities.ts +40 -0
  143. package/lib/platform/types.ts +4 -2
  144. package/lib/platform/verification-required.ts +11 -13
  145. package/lib/platform/verification-sync.ts +112 -292
  146. package/lib/pr-review/evidence-grading.ts +25 -8
  147. package/lib/run/index.ts +57 -22
  148. package/lib/sandbox/control/client.ts +105 -15
  149. package/lib/sandbox/control/executor.ts +4 -4
  150. package/lib/sandbox/control/protocol.ts +113 -0
  151. package/lib/sandbox/control/server.ts +431 -23
  152. package/lib/sandbox/control/state.ts +251 -1
  153. package/lib/server/protocol.ts +36 -1
  154. package/lib/task/activity-log.ts +8 -0
  155. package/lib/task/artifact-lifecycle.ts +32 -6
  156. package/lib/task/capabilities.ts +262 -0
  157. package/lib/task/commands/status.ts +38 -0
  158. package/lib/task/commit-operation.ts +12 -1
  159. package/lib/task/control-authority.ts +11 -8
  160. package/lib/task/create-service.ts +8 -8
  161. package/lib/task/current-contract.ts +6 -1
  162. package/lib/task/decision-details.ts +6 -2
  163. package/lib/task/events.ts +296 -16
  164. package/lib/task/finalization.ts +50 -14
  165. package/lib/task/human-override.ts +70 -46
  166. package/lib/task/invalidation-command.ts +86 -0
  167. package/lib/task/invalidation.ts +332 -0
  168. package/lib/task/ledger-intents.ts +35 -1
  169. package/lib/task/local-artifact-finalization.ts +563 -0
  170. package/lib/task/orchestration.ts +52 -85
  171. package/lib/task/pr-delivery-fact.ts +131 -148
  172. package/lib/task/review-fingerprint.ts +23 -2
  173. package/lib/task/rework-intent.ts +165 -0
  174. package/lib/task/skill-scope.ts +24 -0
  175. package/lib/task/task-execution-lock.ts +23 -14
  176. package/lib/task/verification-engine.ts +52 -17
  177. package/lib/task/verification.ts +4 -4
  178. package/lib/task/workflow-warning-intents.ts +1 -1
  179. package/lib/task/write.ts +19 -0
  180. package/lib/update.ts +1 -1
  181. package/lib/version.ts +15 -1
  182. package/package.json +7 -1
  183. package/templates/.agents/rules/README.en.md +1 -1
  184. package/templates/.agents/rules/README.zh-CN.md +1 -1
  185. package/templates/.agents/rules/issue-pr-commands.en.md +1 -1
  186. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
  187. package/templates/.agents/rules/issue-sync.en.md +2 -0
  188. package/templates/.agents/rules/issue-sync.zh-CN.md +2 -0
  189. package/templates/.agents/rules/local-artifact-repair.en.md +9 -2
  190. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +9 -2
  191. package/templates/.agents/rules/pr-sync.en.md +10 -4
  192. package/templates/.agents/rules/pr-sync.zh-CN.md +17 -4
  193. package/templates/.agents/rules/task-short-id.en.md +1 -4
  194. package/templates/.agents/rules/task-short-id.zh-CN.md +1 -3
  195. package/templates/.agents/skills/analyze-task/SKILL.en.md +13 -3
  196. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -3
  197. package/templates/.agents/skills/check-task/SKILL.en.md +16 -37
  198. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -37
  199. package/templates/.agents/skills/code-task/SKILL.en.md +27 -8
  200. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +29 -10
  201. package/templates/.agents/skills/code-task/config/verify.en.json +1 -0
  202. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -0
  203. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +2 -0
  204. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +2 -0
  205. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +3 -3
  206. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +3 -3
  207. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +5 -3
  208. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +5 -3
  209. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +4 -3
  210. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +4 -3
  211. package/templates/.agents/skills/complete-task/SKILL.en.md +21 -3
  212. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +20 -3
  213. package/templates/.agents/skills/create-pr/SKILL.en.md +7 -6
  214. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -7
  215. package/templates/.agents/skills/create-pr/config/verify.json +1 -0
  216. package/templates/.agents/skills/create-pr/reference/change-report.en.md +16 -4
  217. package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +16 -4
  218. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +5 -3
  219. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +5 -3
  220. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +1 -1
  221. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +1 -1
  222. package/templates/.agents/skills/create-pr/scripts/change-report.mjs +3 -0
  223. package/templates/.agents/skills/plan-task/SKILL.en.md +13 -3
  224. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +10 -3
  225. package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
  226. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
  227. package/templates/.agents/skills/review-code/SKILL.en.md +4 -4
  228. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +4 -4
  229. package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
  230. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
  231. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +4 -2
  232. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +4 -2
  233. package/templates/.agents/skills/watch-pr/SKILL.en.md +2 -2
  234. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +2 -2
  235. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +6 -0
  236. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +6 -0
  237. package/templates/.agents/templates/task.en.md +18 -1
  238. package/templates/.agents/templates/task.zh-CN.md +18 -1
  239. package/templates/.github/workflows/pr-label.yml +7 -26
@@ -0,0 +1,45 @@
1
+ import path from 'node:path';
2
+ import { identityFromRemoteValue, parseResourceIdentity, parseResourceToken, resourceIdentityNumber } from './resource-identity.js';
3
+ function providerOperationContext(loaded, workingDirectory = loaded.workingDirectory, scopeId = loaded.snapshot.scope.id) {
4
+ return {
5
+ repositoryRoot: loaded.repositoryRoot,
6
+ workingDirectory: path.resolve(workingDirectory),
7
+ scopeId,
8
+ ...(loaded.snapshot.scope.label ? { scopeLabel: loaded.snapshot.scope.label } : {})
9
+ };
10
+ }
11
+ function providerError(error, fallbackCode) {
12
+ return {
13
+ code: error.code || fallbackCode,
14
+ message: error.message || 'Platform provider operation failed',
15
+ retryable: error.retryable
16
+ };
17
+ }
18
+ function providerStatus(error) {
19
+ return error.retryable ? 'blocked' : 'failed';
20
+ }
21
+ function unsupportedProviderOperation(provider, operation) {
22
+ return {
23
+ ok: false,
24
+ error: {
25
+ code: 'PLATFORM_CAPABILITY_UNSUPPORTED',
26
+ message: `Platform '${provider.type}' does not provide ${operation}`,
27
+ retryable: false,
28
+ providerType: provider.type,
29
+ phase: 'operation'
30
+ }
31
+ };
32
+ }
33
+ function resourceIdentity(value) {
34
+ if (typeof value === 'object')
35
+ return parseResourceIdentity(value);
36
+ return parseResourceIdentity(typeof value === 'number' ? { kind: 'number', value } : { kind: 'id', value });
37
+ }
38
+ function providerResourceToken(provider, resourceKind, token) {
39
+ return parseResourceToken(token, resourceKind, provider.identity);
40
+ }
41
+ function providerResourceIdentity(provider, resourceKind, value) {
42
+ return identityFromRemoteValue(value, resourceKind, provider.identity);
43
+ }
44
+ export { providerError, providerOperationContext, providerStatus, providerResourceIdentity, providerResourceToken, resourceIdentity, resourceIdentityNumber, unsupportedProviderOperation };
45
+ //# sourceMappingURL=provider-bridge.js.map
@@ -0,0 +1,487 @@
1
+ import type { ProviderIdentityDeclaration, ResourceIdentity } from './resource-identity.ts';
2
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
3
+ [key: string]: JsonValue;
4
+ };
5
+ type PlatformError = {
6
+ code: string;
7
+ message: string;
8
+ retryable: boolean;
9
+ providerType?: string;
10
+ phase?: string;
11
+ };
12
+ type ProviderResult<T> = {
13
+ ok: true;
14
+ value: T;
15
+ } | {
16
+ ok: false;
17
+ error: PlatformError;
18
+ };
19
+ type ProviderOperationContext = {
20
+ repositoryRoot: string;
21
+ workingDirectory: string;
22
+ scopeId: string;
23
+ scopeLabel?: string;
24
+ };
25
+ type MutationIdentity = {
26
+ idempotencyKey: string;
27
+ target?: ResourceIdentity;
28
+ };
29
+ type PlatformCapabilities = {
30
+ authenticated: boolean;
31
+ comment: boolean;
32
+ triage: boolean;
33
+ push: boolean;
34
+ admin: boolean;
35
+ };
36
+ type PlatformContextSnapshot = {
37
+ type: string;
38
+ scope: {
39
+ id: string;
40
+ label?: string;
41
+ };
42
+ currentUser: {
43
+ id?: string;
44
+ name?: string;
45
+ } | null;
46
+ capabilities: PlatformCapabilities;
47
+ authenticated: boolean;
48
+ metadata?: Readonly<Record<string, JsonValue>>;
49
+ };
50
+ type IssueSnapshot = {
51
+ id: string;
52
+ identity?: ResourceIdentity;
53
+ number?: number;
54
+ title: string;
55
+ body: string;
56
+ state: 'open' | 'closed';
57
+ labels: string[];
58
+ assignees: string[];
59
+ milestone: string | null;
60
+ fields: Record<string, string | number | null>;
61
+ issueType?: {
62
+ identity: ResourceIdentity;
63
+ name: string;
64
+ fields: Array<{
65
+ identity: ResourceIdentity;
66
+ name: string;
67
+ kind: 'single-select' | 'date' | 'text' | 'number';
68
+ options: Array<{
69
+ identity: ResourceIdentity;
70
+ name: string;
71
+ }>;
72
+ }>;
73
+ } | null;
74
+ author?: {
75
+ id?: string;
76
+ name?: string;
77
+ } | null;
78
+ displayUrl?: string;
79
+ };
80
+ type RemoteCommentSnapshot = {
81
+ id: string;
82
+ author: {
83
+ id?: string;
84
+ name?: string;
85
+ } | null;
86
+ body: string;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ };
90
+ type ChangeRequestSnapshot = {
91
+ id: string;
92
+ identity?: ResourceIdentity;
93
+ number?: number;
94
+ state: string;
95
+ title: string;
96
+ body: string;
97
+ baseSha?: string;
98
+ headSha?: string;
99
+ author?: {
100
+ id?: string;
101
+ name?: string;
102
+ } | null;
103
+ mergedAt?: string | null;
104
+ displayUrl?: string;
105
+ draft?: boolean;
106
+ labels?: string[];
107
+ assignees?: string[];
108
+ milestone?: string | null;
109
+ mergeCommitSha?: string | null;
110
+ mergeability?: {
111
+ state: 'mergeable' | 'conflicting' | 'unknown';
112
+ detail: string | null;
113
+ };
114
+ head?: {
115
+ repository: string;
116
+ ref: string;
117
+ sha: string;
118
+ };
119
+ base?: {
120
+ repository: string;
121
+ ref: string;
122
+ sha: string;
123
+ };
124
+ };
125
+ type GitEvidenceSnapshot = {
126
+ remoteUrl: string;
127
+ reviewedHeadRef: string;
128
+ targetHeadRef: string;
129
+ };
130
+ type RequiredCheckSnapshot = {
131
+ name: string;
132
+ status: string;
133
+ conclusion?: string | null;
134
+ detailsUrl?: string | null;
135
+ runId?: string;
136
+ jobId?: string;
137
+ };
138
+ type CheckRunSnapshot = RequiredCheckSnapshot & {
139
+ runId: string;
140
+ };
141
+ type CheckLogSnapshot = {
142
+ runId: string;
143
+ jobId?: string;
144
+ text: string;
145
+ };
146
+ type ReviewSnapshot = {
147
+ id: string;
148
+ author: {
149
+ id?: string;
150
+ name?: string;
151
+ } | null;
152
+ body: string;
153
+ state: string;
154
+ submittedAt: string;
155
+ commitSha?: string;
156
+ displayUrl?: string;
157
+ };
158
+ type ReleaseSnapshot = {
159
+ id: string;
160
+ tag: string;
161
+ title: string;
162
+ body: string;
163
+ draft: boolean;
164
+ prerelease: boolean;
165
+ publishedAt: string | null;
166
+ milestone?: string | null;
167
+ displayUrl?: string;
168
+ workflows?: Array<Record<string, JsonValue>>;
169
+ };
170
+ type MutationReceipt = {
171
+ remoteId: string;
172
+ changed: boolean;
173
+ operationId?: string;
174
+ };
175
+ type RepositoryMetadataSnapshot = {
176
+ repository: {
177
+ identity: ResourceIdentity;
178
+ name: string;
179
+ url: string | null;
180
+ };
181
+ labels: Array<{
182
+ identity: ResourceIdentity;
183
+ name: string;
184
+ }>;
185
+ milestones: Array<{
186
+ identity: ResourceIdentity;
187
+ title: string;
188
+ state: 'open' | 'closed';
189
+ }>;
190
+ issueTypes: Array<{
191
+ identity: ResourceIdentity;
192
+ name: string;
193
+ fields: Array<{
194
+ identity: ResourceIdentity;
195
+ name: string;
196
+ kind: 'single-select' | 'date' | 'text' | 'number';
197
+ options: Array<{
198
+ identity: ResourceIdentity;
199
+ name: string;
200
+ }>;
201
+ }>;
202
+ }>;
203
+ fields: Array<{
204
+ identity: ResourceIdentity;
205
+ name: string;
206
+ kind: 'single-select' | 'date' | 'text' | 'number';
207
+ options: Array<{
208
+ identity: ResourceIdentity;
209
+ name: string;
210
+ }>;
211
+ }>;
212
+ };
213
+ type ReleaseNotesFacts = {
214
+ history: Array<{
215
+ sha: string;
216
+ message: string;
217
+ authoredAt: string;
218
+ author: {
219
+ id?: string;
220
+ name?: string;
221
+ } | null;
222
+ }>;
223
+ mergedPullRequests: Array<ChangeRequestSnapshot>;
224
+ closingIssues: Array<IssueSnapshot>;
225
+ actors: Array<{
226
+ id?: string;
227
+ name?: string;
228
+ }>;
229
+ };
230
+ type MilestoneReconciliation = {
231
+ changed: boolean;
232
+ created: string[];
233
+ closed: string[];
234
+ };
235
+ type VerificationRemoteFacts = {
236
+ issue?: IssueSnapshot | null;
237
+ comments: RemoteCommentSnapshot[];
238
+ changeRequest?: ChangeRequestSnapshot | null;
239
+ commit?: {
240
+ sha: string;
241
+ message?: string;
242
+ } | null;
243
+ fields: Record<string, string | number | null>;
244
+ };
245
+ type PlatformProviderFactoryInput = {
246
+ providerType: string;
247
+ contractVersion: 1;
248
+ repositoryRoot: string;
249
+ config: Readonly<Record<string, JsonValue>>;
250
+ };
251
+ type PlatformProvider = {
252
+ type: string;
253
+ contractVersion: 1;
254
+ identity?: ProviderIdentityDeclaration;
255
+ context: {
256
+ resolve(input: {
257
+ repositoryRoot: string;
258
+ workingDirectory: string;
259
+ scopeId: string;
260
+ scopeLabel?: string;
261
+ gitRemote: string | null;
262
+ }): Promise<ProviderResult<PlatformContextSnapshot>>;
263
+ };
264
+ issues?: {
265
+ listLabels?(input: {
266
+ context: ProviderOperationContext;
267
+ }): Promise<ProviderResult<string[]>>;
268
+ listMilestones?(input: {
269
+ context: ProviderOperationContext;
270
+ }): Promise<ProviderResult<string[]>>;
271
+ describeRepository(input: {
272
+ context: ProviderOperationContext;
273
+ }): Promise<ProviderResult<RepositoryMetadataSnapshot>>;
274
+ inspect(input: {
275
+ context: ProviderOperationContext;
276
+ target: ResourceIdentity;
277
+ }): Promise<ProviderResult<IssueSnapshot>>;
278
+ create(input: {
279
+ context: ProviderOperationContext;
280
+ desired: {
281
+ title: string;
282
+ body: string;
283
+ labels: string[];
284
+ assignees: string[];
285
+ milestone: string | null;
286
+ fields: Record<string, string | number | null>;
287
+ };
288
+ mutation: MutationIdentity;
289
+ }): Promise<ProviderResult<MutationReceipt>>;
290
+ update(input: {
291
+ context: ProviderOperationContext;
292
+ target: ResourceIdentity;
293
+ currentLabels?: string[];
294
+ patch: Partial<{
295
+ title: string;
296
+ body: string;
297
+ labels: string[];
298
+ assignees: string[];
299
+ milestone: string | null;
300
+ state: 'open' | 'closed';
301
+ fields: Record<string, string | number | null>;
302
+ issueType?: string | null;
303
+ }>;
304
+ mutation: MutationIdentity;
305
+ }): Promise<ProviderResult<MutationReceipt>>;
306
+ };
307
+ comments?: {
308
+ list(input: {
309
+ context: ProviderOperationContext;
310
+ parent: ResourceIdentity;
311
+ }): Promise<ProviderResult<RemoteCommentSnapshot[]>>;
312
+ write(input: {
313
+ context: ProviderOperationContext;
314
+ parent: ResourceIdentity;
315
+ body: string;
316
+ existingComment?: ResourceIdentity;
317
+ mutation: MutationIdentity;
318
+ }): Promise<ProviderResult<MutationReceipt>>;
319
+ delete(input: {
320
+ context: ProviderOperationContext;
321
+ parent: ResourceIdentity;
322
+ comment: ResourceIdentity;
323
+ mutation: MutationIdentity;
324
+ }): Promise<ProviderResult<MutationReceipt>>;
325
+ };
326
+ changeRequests?: {
327
+ verifyHead?(input: {
328
+ context: ProviderOperationContext;
329
+ head: string;
330
+ }): Promise<ProviderResult<{
331
+ sha: string;
332
+ }>>;
333
+ inspect(input: {
334
+ context: ProviderOperationContext;
335
+ target: ResourceIdentity;
336
+ }): Promise<ProviderResult<ChangeRequestSnapshot>>;
337
+ listClosing(input: {
338
+ context: ProviderOperationContext;
339
+ issue: ResourceIdentity;
340
+ }): Promise<ProviderResult<ChangeRequestSnapshot[]>>;
341
+ create(input: {
342
+ context: ProviderOperationContext;
343
+ base: string;
344
+ head: string;
345
+ title: string;
346
+ body: string;
347
+ draft: boolean;
348
+ mutation: MutationIdentity;
349
+ }): Promise<ProviderResult<MutationReceipt>>;
350
+ update(input: {
351
+ context: ProviderOperationContext;
352
+ target: ResourceIdentity;
353
+ currentLabels?: string[];
354
+ patch: Partial<{
355
+ title: string;
356
+ body: string;
357
+ base: string;
358
+ state: string;
359
+ labels: string[];
360
+ assignees: string[];
361
+ milestone: string | null;
362
+ }>;
363
+ mutation: MutationIdentity;
364
+ }): Promise<ProviderResult<MutationReceipt>>;
365
+ resolveGitEvidence(input: {
366
+ context: ProviderOperationContext;
367
+ target: ResourceIdentity;
368
+ expected: {
369
+ baseSha?: string;
370
+ headSha?: string;
371
+ targetBranch?: string;
372
+ };
373
+ }): Promise<ProviderResult<GitEvidenceSnapshot>>;
374
+ };
375
+ checks?: {
376
+ inspectRequired(input: {
377
+ context: ProviderOperationContext;
378
+ changeRequest: ResourceIdentity;
379
+ headSha?: string;
380
+ }): Promise<ProviderResult<RequiredCheckSnapshot[]>>;
381
+ resolveRun(input: {
382
+ context: ProviderOperationContext;
383
+ changeRequest: ResourceIdentity;
384
+ checkName: string;
385
+ detailsUrl?: string;
386
+ }): Promise<ProviderResult<CheckRunSnapshot>>;
387
+ fetchLogs(input: {
388
+ context: ProviderOperationContext;
389
+ runId: string;
390
+ jobId?: string;
391
+ }): Promise<ProviderResult<CheckLogSnapshot>>;
392
+ };
393
+ reviews?: {
394
+ list(input: {
395
+ context: ProviderOperationContext;
396
+ changeRequest: ResourceIdentity;
397
+ }): Promise<ProviderResult<ReviewSnapshot[]>>;
398
+ publish(input: {
399
+ context: ProviderOperationContext;
400
+ changeRequest: ResourceIdentity;
401
+ identity: {
402
+ scope: string;
403
+ round: number;
404
+ commitSha: string;
405
+ resource?: ResourceIdentity;
406
+ };
407
+ event: 'COMMENT' | 'APPROVE' | 'REQUEST_CHANGES';
408
+ body: string;
409
+ mutation: MutationIdentity;
410
+ }): Promise<ProviderResult<MutationReceipt>>;
411
+ };
412
+ releases?: {
413
+ inspect(input: {
414
+ context: ProviderOperationContext;
415
+ tag: string;
416
+ }): Promise<ProviderResult<ReleaseSnapshot>>;
417
+ create(input: {
418
+ context: ProviderOperationContext;
419
+ tag: string;
420
+ title: string;
421
+ notes?: {
422
+ text: string;
423
+ sha256: string;
424
+ byteLength: number;
425
+ };
426
+ mutation: MutationIdentity;
427
+ }): Promise<ProviderResult<MutationReceipt>>;
428
+ update(input: {
429
+ context: ProviderOperationContext;
430
+ release: ResourceIdentity;
431
+ patch: Partial<{
432
+ tag: string;
433
+ title: string;
434
+ body: string;
435
+ draft: boolean;
436
+ prerelease: boolean;
437
+ }>;
438
+ mutation: MutationIdentity;
439
+ }): Promise<ProviderResult<MutationReceipt>>;
440
+ reconcileMilestones(input: {
441
+ context: ProviderOperationContext;
442
+ version: string;
443
+ desired: Array<{
444
+ key: string;
445
+ title: string;
446
+ description: string;
447
+ state: 'open' | 'closed';
448
+ }>;
449
+ mutation: MutationIdentity;
450
+ }): Promise<ProviderResult<MilestoneReconciliation>>;
451
+ publishNotes(input: {
452
+ context: ProviderOperationContext;
453
+ release: ResourceIdentity;
454
+ title: string;
455
+ notes: {
456
+ text: string;
457
+ sha256: string;
458
+ byteLength: number;
459
+ };
460
+ mutation: MutationIdentity;
461
+ }): Promise<ProviderResult<MutationReceipt>>;
462
+ collectNotes(input: {
463
+ context: ProviderOperationContext;
464
+ fromTime: string;
465
+ toTime: string;
466
+ commitOids: string[];
467
+ branch: string;
468
+ historyLimit: number;
469
+ }): Promise<ProviderResult<ReleaseNotesFacts>>;
470
+ };
471
+ verification?: {
472
+ fetchRemoteFacts(input: {
473
+ context: ProviderOperationContext;
474
+ taskId: string;
475
+ issue?: ResourceIdentity;
476
+ changeRequest?: ResourceIdentity;
477
+ includeComments: boolean;
478
+ includeFields: boolean;
479
+ }): Promise<ProviderResult<VerificationRemoteFacts>>;
480
+ };
481
+ };
482
+ type PlatformProviderFactory = (input: PlatformProviderFactoryInput) => Promise<PlatformProvider>;
483
+ declare const PLATFORM_PROVIDER_CONTRACT_VERSION: 1;
484
+ declare function isPlatformProviderFactory(value: unknown): value is PlatformProviderFactory;
485
+ declare function validatePlatformProvider(value: unknown, providerType: string): ProviderResult<PlatformProvider>;
486
+ export { PLATFORM_PROVIDER_CONTRACT_VERSION, isPlatformProviderFactory, validatePlatformProvider };
487
+ export type { ChangeRequestSnapshot, CheckLogSnapshot, CheckRunSnapshot, GitEvidenceSnapshot, IssueSnapshot, JsonValue, MilestoneReconciliation, MutationIdentity, MutationReceipt, PlatformCapabilities, PlatformContextSnapshot, PlatformError, PlatformProvider, PlatformProviderFactory, PlatformProviderFactoryInput, ProviderOperationContext, ProviderResult, ReleaseSnapshot, RemoteCommentSnapshot, RequiredCheckSnapshot, RepositoryMetadataSnapshot, ReleaseNotesFacts, ResourceIdentity, ReviewSnapshot, VerificationRemoteFacts };
@@ -0,0 +1,95 @@
1
+ const PLATFORM_PROVIDER_CONTRACT_VERSION = 1;
2
+ function isRecord(value) {
3
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
4
+ }
5
+ function isPlatformProviderFactory(value) {
6
+ return typeof value === 'function';
7
+ }
8
+ function validatePlatformProvider(value, providerType) {
9
+ const operationGroups = {
10
+ issues: { required: ['inspect', 'create', 'update', 'describeRepository'], optional: [] },
11
+ comments: { required: ['list', 'write', 'delete'], optional: [] },
12
+ changeRequests: { required: ['inspect', 'listClosing', 'create', 'update', 'resolveGitEvidence'], optional: ['verifyHead'] },
13
+ checks: { required: ['inspectRequired', 'resolveRun', 'fetchLogs'], optional: [] },
14
+ reviews: { required: ['list', 'publish'], optional: [] },
15
+ releases: { required: ['inspect', 'create', 'update', 'reconcileMilestones', 'publishNotes', 'collectNotes'], optional: [] },
16
+ verification: { required: ['fetchRemoteFacts'], optional: [] }
17
+ };
18
+ const resourceKindsByGroup = {
19
+ issues: ['issue'],
20
+ comments: ['issue', 'pull-request', 'comment'],
21
+ changeRequests: ['issue', 'pull-request'],
22
+ checks: ['pull-request'],
23
+ reviews: ['pull-request'],
24
+ releases: ['release', 'issue', 'pull-request'],
25
+ verification: ['issue', 'pull-request']
26
+ };
27
+ if (!isRecord(value)
28
+ || value.type !== providerType
29
+ || value.contractVersion !== PLATFORM_PROVIDER_CONTRACT_VERSION
30
+ || !isRecord(value.context)
31
+ || typeof value.context.resolve !== 'function') {
32
+ return {
33
+ ok: false,
34
+ error: {
35
+ code: 'PLATFORM_PROVIDER_CONTRACT_INVALID',
36
+ message: 'Provider must expose matching type, contractVersion, and context.resolve',
37
+ retryable: false,
38
+ providerType,
39
+ phase: 'provider-validation'
40
+ }
41
+ };
42
+ }
43
+ if (value.identity !== undefined) {
44
+ if (!isRecord(value.identity) || Object.entries(value.identity).some(([resourceKind, kind]) => !['issue', 'pull-request', 'comment', 'release'].includes(resourceKind)
45
+ || !['id', 'number', 'key'].includes(kind))) {
46
+ return {
47
+ ok: false,
48
+ error: {
49
+ code: 'PLATFORM_PROVIDER_CONTRACT_INVALID',
50
+ message: 'Provider identity declaration is invalid',
51
+ retryable: false,
52
+ providerType,
53
+ phase: 'provider-validation'
54
+ }
55
+ };
56
+ }
57
+ }
58
+ for (const [groupName, groupDefinition] of Object.entries(operationGroups)) {
59
+ const group = value[groupName];
60
+ if (group !== undefined && (!isRecord(group)
61
+ || groupDefinition.required.some((method) => typeof group[method] !== 'function')
62
+ || Object.keys(group).some((method) => ![...groupDefinition.required, ...groupDefinition.optional].includes(method)))) {
63
+ return {
64
+ ok: false,
65
+ error: {
66
+ code: 'PLATFORM_PROVIDER_CONTRACT_INVALID',
67
+ message: `Provider operation group ${groupName} is incomplete`,
68
+ retryable: false,
69
+ providerType,
70
+ phase: 'provider-validation'
71
+ }
72
+ };
73
+ }
74
+ if (group !== undefined) {
75
+ for (const resourceKind of resourceKindsByGroup[groupName] || []) {
76
+ const declaration = isRecord(value.identity) ? value.identity[resourceKind] : undefined;
77
+ if (declaration !== 'id' && declaration !== 'number' && declaration !== 'key') {
78
+ return {
79
+ ok: false,
80
+ error: {
81
+ code: 'PLATFORM_PROVIDER_CONTRACT_INVALID',
82
+ message: `Provider operation group ${groupName} requires an identity declaration for ${resourceKind}`,
83
+ retryable: false,
84
+ providerType,
85
+ phase: 'provider-validation'
86
+ }
87
+ };
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return { ok: true, value: value };
93
+ }
94
+ export { PLATFORM_PROVIDER_CONTRACT_VERSION, isPlatformProviderFactory, validatePlatformProvider };
95
+ //# sourceMappingURL=provider-contract.js.map