@fitlab-ai/agent-infra 0.9.11 → 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.
- package/README.md +13 -13
- package/README.zh-CN.md +13 -13
- package/dist/bin/internal-cli.js +29 -19
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +71 -10
- package/dist/lib/agent-clients/next-steps.js +6 -1
- package/dist/lib/decide.js +3 -3
- package/dist/lib/defaults.json +4 -0
- package/dist/lib/git/workflow.js +43 -1
- package/dist/lib/init.js +1 -0
- package/dist/lib/internal/git-workflow.js +8 -1
- package/dist/lib/internal/platform-checks.js +3 -3
- package/dist/lib/internal/platform-comment.js +9 -9
- package/dist/lib/internal/platform-context.js +2 -2
- package/dist/lib/internal/platform-issue.js +8 -9
- package/dist/lib/internal/platform-pr-review.js +10 -10
- package/dist/lib/internal/platform-pr.js +68 -23
- package/dist/lib/internal/platform-release-notes.js +3 -3
- package/dist/lib/internal/pr-review-grade.js +11 -9
- package/dist/lib/internal/release-workflow.js +4 -4
- package/dist/lib/internal/sandbox-control.js +30 -4
- package/dist/lib/internal/task-activity.js +3 -3
- package/dist/lib/internal/task-artifact.js +76 -24
- package/dist/lib/internal/task-create.js +2 -2
- package/dist/lib/internal/task-delivery.js +59 -0
- package/dist/lib/internal/task-event.js +6 -3
- package/dist/lib/internal/task-finalization.js +2 -2
- package/dist/lib/internal/task-invalidation.js +60 -0
- package/dist/lib/internal/task-ledger.js +9 -6
- package/dist/lib/internal/task-lifecycle.js +2 -2
- package/dist/lib/internal/task-override.js +4 -4
- package/dist/lib/internal/task-review.js +3 -3
- package/dist/lib/internal/task-verify.js +6 -6
- package/dist/lib/internal/task-warning.js +3 -3
- package/dist/lib/platform/adapters.js +1 -3
- package/dist/lib/platform/change-request-git-evidence.js +27 -7
- package/dist/lib/platform/completion-backfill.js +6 -5
- package/dist/lib/platform/context.js +70 -130
- package/dist/lib/platform/github-client.js +8 -2
- package/dist/lib/platform/github-provider.js +903 -0
- package/dist/lib/platform/in-label-sync.js +143 -0
- package/dist/lib/platform/issue-comments.js +94 -41
- package/dist/lib/platform/issues.js +335 -189
- package/dist/lib/platform/metadata-labels.js +6 -2
- package/dist/lib/platform/none-provider.js +28 -0
- package/dist/lib/platform/pr-change-report.js +551 -0
- package/dist/lib/platform/pr-checks.js +124 -106
- package/dist/lib/platform/pr-review.js +88 -72
- package/dist/lib/platform/pr-summary.js +523 -49
- package/dist/lib/platform/provider-bridge.js +45 -0
- package/dist/lib/platform/provider-contract.d.ts +487 -0
- package/dist/lib/platform/provider-contract.js +95 -0
- package/dist/lib/platform/provider-loader.js +251 -0
- package/dist/lib/platform/provider-validation.js +504 -0
- package/dist/lib/platform/pull-request-metadata.js +8 -6
- package/dist/lib/platform/pull-requests.js +1050 -502
- package/dist/lib/platform/release-notes.js +78 -55
- package/dist/lib/platform/releases.js +79 -50
- package/dist/lib/platform/resource-identity.d.ts +26 -0
- package/dist/lib/platform/resource-identity.js +92 -0
- package/dist/lib/platform/task-identities.js +31 -0
- package/dist/lib/platform/verification-required.js +22 -12
- package/dist/lib/platform/verification-sync.js +118 -239
- package/dist/lib/pr-review/evidence-grading.js +30 -9
- package/dist/lib/run/index.js +63 -23
- package/dist/lib/sandbox/config.js +5 -0
- package/dist/lib/sandbox/control/client.js +96 -15
- package/dist/lib/sandbox/control/executor.js +3 -3
- package/dist/lib/sandbox/control/lifecycle.js +29 -7
- package/dist/lib/sandbox/control/protocol.js +77 -0
- package/dist/lib/sandbox/control/server.js +398 -25
- package/dist/lib/sandbox/control/state.js +204 -1
- package/dist/lib/server/process-state.js +2 -2
- package/dist/lib/server/protocol.js +38 -1
- package/dist/lib/task/activity-log.js +8 -1
- package/dist/lib/task/artifact-lifecycle.js +35 -7
- package/dist/lib/task/capabilities.js +239 -0
- package/dist/lib/task/commands/status.js +32 -0
- package/dist/lib/task/commit-intent.js +100 -0
- package/dist/lib/task/commit-operation.js +207 -102
- package/dist/lib/task/control-authority.js +8 -5
- package/dist/lib/task/create-service.js +8 -8
- package/dist/lib/task/create.js +33 -7
- package/dist/lib/task/current-contract.js +5 -1
- package/dist/lib/task/decision-details.js +3 -48
- package/dist/lib/task/delivery-target.js +97 -0
- package/dist/lib/task/delivery.js +153 -0
- package/dist/lib/task/events.js +297 -17
- package/dist/lib/task/finalization.js +37 -13
- package/dist/lib/task/human-override.js +61 -36
- package/dist/lib/task/invalidation-command.js +86 -0
- package/dist/lib/task/invalidation.js +260 -0
- package/dist/lib/task/ledger-intents.js +37 -0
- package/dist/lib/task/lifecycle.js +106 -9
- package/dist/lib/task/local-artifact-finalization.js +374 -0
- package/dist/lib/task/orchestration.js +100 -151
- package/dist/lib/task/pr-delivery-fact.js +183 -0
- package/dist/lib/task/review-finalization.js +4 -8
- package/dist/lib/task/review-fingerprint.js +32 -2
- package/dist/lib/task/rework-intent.js +138 -0
- package/dist/lib/task/skill-scope.js +23 -0
- package/dist/lib/task/task-execution-lock.js +27 -17
- package/dist/lib/task/verification-engine.js +89 -38
- package/dist/lib/task/verification-review.js +1 -1
- package/dist/lib/task/verification.js +3 -3
- package/dist/lib/task/workflow-warning-intents.js +1 -1
- package/dist/lib/task/write.js +11 -0
- package/dist/lib/update.js +9 -0
- package/dist/lib/version.js +11 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +105 -10
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +12 -1
- package/lib/agent-clients/next-steps.ts +6 -1
- package/lib/decide.ts +3 -3
- package/lib/defaults.json +4 -0
- package/lib/git/workflow.ts +38 -1
- package/lib/init.ts +4 -1
- package/lib/internal/git-workflow.ts +7 -1
- package/lib/internal/platform-checks.ts +3 -3
- package/lib/internal/platform-comment.ts +8 -8
- package/lib/internal/platform-context.ts +2 -2
- package/lib/internal/platform-issue.ts +7 -8
- package/lib/internal/platform-pr-review.ts +9 -9
- package/lib/internal/platform-pr.ts +53 -21
- package/lib/internal/platform-release-notes.ts +3 -3
- package/lib/internal/pr-review-grade.ts +10 -8
- package/lib/internal/release-workflow.ts +4 -4
- package/lib/internal/sandbox-control.ts +27 -3
- package/lib/internal/task-activity.ts +3 -3
- package/lib/internal/task-artifact.ts +65 -22
- package/lib/internal/task-create.ts +2 -2
- package/lib/internal/task-delivery.ts +53 -0
- package/lib/internal/task-event.ts +6 -3
- package/lib/internal/task-finalization.ts +3 -3
- package/lib/internal/task-invalidation.ts +39 -0
- package/lib/internal/task-ledger.ts +11 -8
- package/lib/internal/task-lifecycle.ts +2 -2
- package/lib/internal/task-override.ts +6 -6
- package/lib/internal/task-review.ts +3 -3
- package/lib/internal/task-verify.ts +6 -6
- package/lib/internal/task-warning.ts +3 -3
- package/lib/platform/adapters.ts +3 -2
- package/lib/platform/change-request-git-evidence.ts +36 -9
- package/lib/platform/completion-backfill.ts +9 -8
- package/lib/platform/context.ts +97 -134
- package/lib/platform/github-client.ts +10 -3
- package/lib/platform/github-provider.ts +910 -0
- package/lib/platform/in-label-sync.ts +208 -0
- package/lib/platform/issue-comments.ts +97 -47
- package/lib/platform/issues.ts +344 -174
- package/lib/platform/metadata-labels.ts +5 -2
- package/lib/platform/none-provider.ts +35 -0
- package/lib/platform/pr-change-report.ts +645 -0
- package/lib/platform/pr-checks.ts +129 -107
- package/lib/platform/pr-review.ts +88 -85
- package/lib/platform/pr-summary.ts +562 -52
- package/lib/platform/provider-bridge.ts +82 -0
- package/lib/platform/provider-contract.ts +536 -0
- package/lib/platform/provider-loader.ts +307 -0
- package/lib/platform/provider-validation.ts +529 -0
- package/lib/platform/pull-request-metadata.ts +10 -7
- package/lib/platform/pull-requests.ts +1126 -505
- package/lib/platform/release-notes.ts +76 -59
- package/lib/platform/releases.ts +77 -43
- package/lib/platform/resource-identity.ts +121 -0
- package/lib/platform/task-identities.ts +40 -0
- package/lib/platform/types.ts +4 -2
- package/lib/platform/verification-required.ts +21 -13
- package/lib/platform/verification-sync.ts +118 -293
- package/lib/pr-review/evidence-grading.ts +31 -11
- package/lib/run/index.ts +57 -22
- package/lib/sandbox/config.ts +7 -0
- package/lib/sandbox/control/client.ts +105 -15
- package/lib/sandbox/control/executor.ts +4 -4
- package/lib/sandbox/control/lifecycle.ts +30 -8
- package/lib/sandbox/control/protocol.ts +113 -0
- package/lib/sandbox/control/server.ts +431 -23
- package/lib/sandbox/control/state.ts +251 -1
- package/lib/server/process-state.ts +2 -2
- package/lib/server/protocol.ts +36 -1
- package/lib/task/activity-log.ts +8 -0
- package/lib/task/artifact-lifecycle.ts +34 -8
- package/lib/task/capabilities.ts +262 -0
- package/lib/task/commands/status.ts +38 -0
- package/lib/task/commit-intent.ts +137 -0
- package/lib/task/commit-operation.ts +186 -88
- package/lib/task/control-authority.ts +11 -8
- package/lib/task/create-service.ts +8 -8
- package/lib/task/create.ts +34 -9
- package/lib/task/current-contract.ts +6 -1
- package/lib/task/decision-details.ts +8 -64
- package/lib/task/delivery-target.ts +130 -0
- package/lib/task/delivery.ts +160 -0
- package/lib/task/events.ts +296 -16
- package/lib/task/finalization.ts +50 -14
- package/lib/task/human-override.ts +73 -46
- package/lib/task/invalidation-command.ts +86 -0
- package/lib/task/invalidation.ts +332 -0
- package/lib/task/ledger-intents.ts +35 -1
- package/lib/task/lifecycle.ts +93 -4
- package/lib/task/local-artifact-finalization.ts +563 -0
- package/lib/task/orchestration.ts +110 -146
- package/lib/task/pr-delivery-fact.ts +237 -0
- package/lib/task/review-finalization.ts +4 -14
- package/lib/task/review-fingerprint.ts +33 -2
- package/lib/task/rework-intent.ts +165 -0
- package/lib/task/skill-scope.ts +24 -0
- package/lib/task/task-execution-lock.ts +23 -14
- package/lib/task/verification-engine.ts +95 -43
- package/lib/task/verification-review.ts +2 -0
- package/lib/task/verification.ts +4 -4
- package/lib/task/workflow-warning-intents.ts +1 -1
- package/lib/task/write.ts +19 -0
- package/lib/update.ts +11 -1
- package/lib/version.ts +15 -1
- package/package.json +7 -1
- package/templates/.agents/rules/README.en.md +4 -2
- package/templates/.agents/rules/README.zh-CN.md +4 -2
- package/templates/.agents/rules/create-issue.en.md +11 -2
- package/templates/.agents/rules/create-issue.zh-CN.md +24 -2
- package/templates/.agents/rules/issue-pr-commands.en.md +4 -17
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +28 -5
- package/templates/.agents/rules/issue-sync.zh-CN.md +64 -5
- package/templates/.agents/rules/label-milestone-setup.en.md +15 -2
- package/templates/.agents/rules/label-milestone-setup.zh-CN.md +15 -2
- package/templates/.agents/rules/local-artifact-repair.en.md +53 -0
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +53 -0
- package/templates/.agents/rules/milestone-inference.en.md +12 -2
- package/templates/.agents/rules/milestone-inference.zh-CN.md +25 -3
- package/templates/.agents/rules/pr-sync.en.md +28 -13
- package/templates/.agents/rules/pr-sync.zh-CN.md +39 -5
- package/templates/.agents/rules/release-commands.en.md +42 -3
- package/templates/.agents/rules/release-commands.zh-CN.md +42 -3
- package/templates/.agents/rules/security-alerts.en.md +17 -2
- package/templates/.agents/rules/security-alerts.zh-CN.md +17 -2
- package/templates/.agents/rules/sync-content-generation.en.md +8 -0
- package/templates/.agents/rules/sync-content-generation.zh-CN.md +8 -0
- package/templates/.agents/rules/task-management.en.md +1 -1
- package/templates/.agents/rules/task-management.zh-CN.md +1 -1
- package/templates/.agents/rules/task-short-id.en.md +1 -4
- package/templates/.agents/rules/task-short-id.zh-CN.md +1 -3
- package/templates/.agents/scripts/security-alerts.github.sh +151 -0
- package/templates/.agents/scripts/security-alerts.sh +31 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +14 -3
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +11 -3
- package/templates/.agents/skills/check-task/SKILL.en.md +16 -37
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -37
- package/templates/.agents/skills/close-codescan/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +32 -10
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +35 -13
- package/templates/.agents/skills/code-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/commit/SKILL.en.md +3 -3
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/commit/config/verify.json +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +3 -3
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +3 -3
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +2 -0
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +2 -0
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +4 -4
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +4 -4
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -2
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -2
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +7 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +7 -4
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +5 -4
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +5 -4
- package/templates/.agents/skills/complete-task/SKILL.en.md +31 -13
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +30 -13
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +2 -2
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +2 -2
- package/templates/.agents/skills/create-pr/SKILL.en.md +11 -10
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +11 -11
- package/templates/.agents/skills/create-pr/config/verify.json +1 -0
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +16 -4
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +16 -4
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +5 -3
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +5 -3
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/scripts/change-report.mjs +3 -0
- package/templates/.agents/skills/create-task/SKILL.en.md +1 -0
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/init-labels/SKILL.en.md +9 -10
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +9 -10
- package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +57 -1
- package/templates/.agents/skills/init-labels/scripts/init-labels.sh +27 -1
- package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -5
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -5
- package/templates/.agents/skills/plan-task/SKILL.en.md +14 -3
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +11 -3
- package/templates/.agents/skills/review-analysis/SKILL.en.md +6 -5
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +6 -5
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +10 -9
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +10 -9
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +19 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +19 -1
- package/templates/.agents/skills/review-code/reference/report-template.en.md +4 -2
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +4 -2
- package/templates/.agents/skills/review-plan/SKILL.en.md +6 -5
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +6 -5
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/SKILL.en.md +1 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +2 -2
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +2 -2
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +5 -2
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +5 -2
- package/templates/.agents/skills/run-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +4 -0
- package/templates/.agents/skills/watch-pr/SKILL.en.md +6 -6
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +6 -6
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +6 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +6 -0
- package/templates/.agents/templates/task.en.md +23 -2
- package/templates/.agents/templates/task.zh-CN.md +23 -2
- package/templates/.agents/workflows/bug-fix.en.yaml +9 -8
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/feature-development.en.yaml +9 -8
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/refactoring.en.yaml +9 -8
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +9 -8
- package/templates/.github/workflows/pr-label.yml +7 -26
- package/templates/.agents/rules/create-issue.github.en.md +0 -14
- package/templates/.agents/rules/create-issue.github.zh-CN.md +0 -27
- package/templates/.agents/rules/issue-pr-commands.github.en.md +0 -34
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +0 -49
- package/templates/.agents/rules/issue-sync.github.en.md +0 -40
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +0 -76
- package/templates/.agents/rules/label-milestone-setup.github.en.md +0 -60
- package/templates/.agents/rules/label-milestone-setup.github.zh-CN.md +0 -60
- package/templates/.agents/rules/milestone-inference.github.en.md +0 -15
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +0 -27
- package/templates/.agents/rules/pr-checks-commands.github.en.md +0 -18
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +0 -34
- package/templates/.agents/rules/pr-sync.github.en.md +0 -43
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +0 -69
- package/templates/.agents/rules/release-commands.github.en.md +0 -44
- package/templates/.agents/rules/release-commands.github.zh-CN.md +0 -44
- package/templates/.agents/rules/security-alerts.github.en.md +0 -43
- package/templates/.agents/rules/security-alerts.github.zh-CN.md +0 -43
- /package/templates/.agents/rules/{issue-fields.github.en.md → issue-fields.en.md} +0 -0
- /package/templates/.agents/rules/{issue-fields.github.zh-CN.md → issue-fields.zh-CN.md} +0 -0
|
@@ -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
|