@aviaratech/ai-delivery 0.3.35 → 0.3.37
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/CONTRIBUTING.md +12 -206
- package/README.md +56 -554
- package/dist/agent.d.ts +1 -3
- package/dist/agent.js +74 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1651 -1590
- package/dist/boardReconcile.test.js.map +7 -1
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +91 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +389 -517
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -45
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +424 -369
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +288 -14
- package/dist/config/deliveryConfig.js +472 -390
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +773 -649
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -479
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +16 -11
- package/dist/dispatch.js +316 -354
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +103 -96
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +63 -23
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.d.ts +0 -3
- package/dist/git.js +59 -76
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +42 -52
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +1 -0
- package/dist/github/discovery.js +197 -215
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +18 -2
- package/dist/github/projectDelivery.js +615 -557
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.js +433 -389
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +40 -9
- package/dist/issue.js +2102 -1742
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +989 -885
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1938 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1059 -989
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -94
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +252 -310
- package/dist/mcp/tools.js +235 -342
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1229
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1842 -1423
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +417 -413
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +114 -131
- package/dist/pr.js +1314 -1327
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +967 -653
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +123 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +184 -0
- package/dist/readView.js +218 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +146 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +125 -125
- package/dist/services/boardReconcileService.js +1295 -1421
- package/dist/services/boardReconcileService.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +321 -358
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +274 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +451 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.d.ts +0 -2
- package/dist/utils/atomicJson.js +81 -77
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.d.ts +0 -8
- package/dist/utils/filesystem.js +5 -19
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -54
- package/dist/verification.js +976 -1941
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.js +45 -24
- package/dist/version.js.map +7 -1
- package/package.json +9 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
- package/plugins/ai-delivery/runtime/dist/cli.js +351 -115
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/services/deliveryAdmission.d.ts +0 -49
- package/dist/services/deliveryAdmission.js +0 -165
- package/dist/services/deliveryAdmission.js.map +0 -1
- package/dist/services/worktreeRegistry.d.ts +0 -434
- package/dist/services/worktreeRegistry.js +0 -1248
- package/dist/services/worktreeRegistry.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3329
- package/dist/setup.test.js.map +0 -1
- package/dist/worktree.d.ts +0 -28
- package/dist/worktree.js +0 -188
- package/dist/worktree.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
|
@@ -1,101 +1,88 @@
|
|
|
1
|
-
import * as z from
|
|
2
|
-
import { CLIError, formatError, logInfo } from
|
|
3
|
-
import { CollectionLimitError } from
|
|
4
|
-
const NativeBlockerPageSchema = z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
blocking: z
|
|
53
|
-
.object({
|
|
54
|
-
nodes: z.array(z
|
|
55
|
-
.object({
|
|
56
|
-
id: z.string(),
|
|
57
|
-
number: z.number().int().positive(),
|
|
58
|
-
state: z.enum(['OPEN', 'CLOSED']),
|
|
59
|
-
title: z.string(),
|
|
60
|
-
})
|
|
61
|
-
.strict()),
|
|
62
|
-
pageInfo: z.object({ endCursor: z.string().nullable(), hasNextPage: z.boolean() }).strict(),
|
|
63
|
-
})
|
|
64
|
-
.strict(),
|
|
65
|
-
})
|
|
66
|
-
.strict(),
|
|
67
|
-
})
|
|
68
|
-
.strict(),
|
|
69
|
-
})
|
|
70
|
-
.strict();
|
|
71
|
-
export async function getNativeBlockerNumbers(params) {
|
|
72
|
-
return (await getNativeBlockerRelationships(params)).blockers.map((blocker) => blocker.number);
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { CLIError, formatError, logInfo } from "../logger.js";
|
|
3
|
+
import { CollectionLimitError } from "../errors.js";
|
|
4
|
+
const NativeBlockerPageSchema = z.object({
|
|
5
|
+
repository: z.object({
|
|
6
|
+
issue: z.object({
|
|
7
|
+
id: z.string().min(1).optional(),
|
|
8
|
+
number: z.number().int().positive().optional(),
|
|
9
|
+
repository: z.object({ nameWithOwner: z.string() }).strict().optional(),
|
|
10
|
+
blockedBy: z.object({
|
|
11
|
+
nodes: z.array(
|
|
12
|
+
z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
number: z.number().int().positive(),
|
|
15
|
+
state: z.enum(["OPEN", "CLOSED"]),
|
|
16
|
+
title: z.string(),
|
|
17
|
+
repository: z.object({ nameWithOwner: z.string() }).strict().optional()
|
|
18
|
+
}).strict()
|
|
19
|
+
),
|
|
20
|
+
pageInfo: z.object({
|
|
21
|
+
endCursor: z.string().nullable(),
|
|
22
|
+
hasNextPage: z.boolean()
|
|
23
|
+
}).strict()
|
|
24
|
+
}).strict(),
|
|
25
|
+
parent: z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
number: z.number().int().positive().optional(),
|
|
28
|
+
repository: z.object({ nameWithOwner: z.string() }).strict().optional()
|
|
29
|
+
}).strict().nullable()
|
|
30
|
+
}).strict()
|
|
31
|
+
}).strict()
|
|
32
|
+
}).strict();
|
|
33
|
+
const NativeBlockingPageSchema = z.object({
|
|
34
|
+
repository: z.object({
|
|
35
|
+
issue: z.object({
|
|
36
|
+
blocking: z.object({
|
|
37
|
+
nodes: z.array(
|
|
38
|
+
z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
number: z.number().int().positive(),
|
|
41
|
+
state: z.enum(["OPEN", "CLOSED"]),
|
|
42
|
+
title: z.string()
|
|
43
|
+
}).strict()
|
|
44
|
+
),
|
|
45
|
+
pageInfo: z.object({ endCursor: z.string().nullable(), hasNextPage: z.boolean() }).strict()
|
|
46
|
+
}).strict()
|
|
47
|
+
}).strict()
|
|
48
|
+
}).strict()
|
|
49
|
+
}).strict();
|
|
50
|
+
async function getNativeBlockerNumbers(params) {
|
|
51
|
+
return (await getNativeBlockerRelationships(params)).blockers.map((blocker) => blocker.number);
|
|
73
52
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
async function getNativeBlockerRelationships({
|
|
54
|
+
graphql,
|
|
55
|
+
issueNumber,
|
|
56
|
+
repo,
|
|
57
|
+
requireRepositoryIdentity = false,
|
|
58
|
+
maxPages,
|
|
59
|
+
issueNodeId
|
|
60
|
+
}) {
|
|
61
|
+
const blockers = /* @__PURE__ */ new Map();
|
|
62
|
+
let cursor = null;
|
|
63
|
+
let hasNextPage = true;
|
|
64
|
+
let parentId = null;
|
|
65
|
+
let parentRepository = null;
|
|
66
|
+
let parentNumber = null;
|
|
67
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
68
|
+
let pages = 0;
|
|
69
|
+
let observedSubject;
|
|
70
|
+
let observedParent;
|
|
71
|
+
while (hasNextPage) {
|
|
72
|
+
if (maxPages !== void 0 && pages >= maxPages)
|
|
73
|
+
throw new CollectionLimitError({
|
|
74
|
+
collection: "native-blockers",
|
|
75
|
+
pagesRequested: pages,
|
|
76
|
+
rowsObserved: blockers.size,
|
|
77
|
+
limit: maxPages
|
|
78
|
+
});
|
|
79
|
+
pages++;
|
|
80
|
+
const response = await graphql(
|
|
81
|
+
`
|
|
95
82
|
query ($owner: String!, $name: String!, $number: Int!, $cursor: String) {
|
|
96
83
|
repository(owner: $owner, name: $name) {
|
|
97
84
|
issue(number: $number) {
|
|
98
|
-
${maxPages ===
|
|
85
|
+
${maxPages === void 0 ? "" : "id number repository { nameWithOwner }"}
|
|
99
86
|
parent {
|
|
100
87
|
id
|
|
101
88
|
number
|
|
@@ -121,71 +108,71 @@ export async function getNativeBlockerRelationships({ graphql, issueNumber, repo
|
|
|
121
108
|
}
|
|
122
109
|
}
|
|
123
110
|
}
|
|
124
|
-
`,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
throw new CLIError('Native parent identity changed while reading blocker pages.');
|
|
141
|
-
observedParent = parent;
|
|
142
|
-
observedSubject = issue.id;
|
|
143
|
-
}
|
|
144
|
-
for (const blocker of issue.blockedBy.nodes) {
|
|
145
|
-
if (maxPages !== undefined && blockers.has(blocker.id))
|
|
146
|
-
throw new CLIError('Native blocker pagination repeats an identity.');
|
|
147
|
-
if (requireRepositoryIdentity && !blocker.repository?.nameWithOwner.match(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u))
|
|
148
|
-
throw new CLIError('Native blocker omitted its repository identity.');
|
|
149
|
-
const { repository, ...identity } = blocker;
|
|
150
|
-
blockers.set(blocker.id, {
|
|
151
|
-
...identity,
|
|
152
|
-
...(requireRepositoryIdentity ? { repository: repository.nameWithOwner } : {}),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (requireRepositoryIdentity &&
|
|
156
|
-
issue.parent &&
|
|
157
|
-
(!issue.parent.number || !issue.parent.repository?.nameWithOwner.match(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u)))
|
|
158
|
-
throw new CLIError('Native parent omitted its repository identity.');
|
|
159
|
-
parentRepository = issue.parent?.repository?.nameWithOwner ?? null;
|
|
160
|
-
parentId = issue.parent?.id ?? null;
|
|
161
|
-
parentNumber = issue.parent?.number ?? null;
|
|
162
|
-
hasNextPage = issue.blockedBy.pageInfo.hasNextPage;
|
|
163
|
-
const nextCursor = issue.blockedBy.pageInfo.endCursor;
|
|
164
|
-
if (hasNextPage && nextCursor === null) {
|
|
165
|
-
throw new CLIError(`Native blocked-by pagination for issue #${String(issueNumber)} omitted its next cursor.`);
|
|
166
|
-
}
|
|
167
|
-
if (hasNextPage && nextCursor !== null && (nextCursor === cursor || seenCursors.has(nextCursor))) {
|
|
168
|
-
throw new CLIError(`Native blocked-by pagination for issue #${String(issueNumber)} repeated a non-advancing cursor.`);
|
|
169
|
-
}
|
|
170
|
-
if (nextCursor !== null)
|
|
171
|
-
seenCursors.add(nextCursor);
|
|
172
|
-
cursor = nextCursor;
|
|
111
|
+
`,
|
|
112
|
+
{ cursor, name: repo.repo, number: issueNumber, owner: repo.owner }
|
|
113
|
+
);
|
|
114
|
+
const parsed = NativeBlockerPageSchema.safeParse(response);
|
|
115
|
+
if (!parsed.success) {
|
|
116
|
+
throw new CLIError(`GitHub returned invalid blocked-by relationship evidence for issue #${String(issueNumber)}.`);
|
|
117
|
+
}
|
|
118
|
+
const issue = parsed.data.repository.issue;
|
|
119
|
+
if (maxPages !== void 0 && (!issue.id || issueNodeId !== void 0 && issue.id !== issueNodeId || observedSubject !== void 0 && issue.id !== observedSubject || issue.number !== issueNumber || issue.repository?.nameWithOwner.toLowerCase() !== `${repo.owner}/${repo.repo}`.toLowerCase()))
|
|
120
|
+
throw new CLIError("Native blocker evidence does not identify its exact selected source issue.");
|
|
121
|
+
if (maxPages !== void 0) {
|
|
122
|
+
const parent = JSON.stringify(issue.parent);
|
|
123
|
+
if (observedParent !== void 0 && observedParent !== parent)
|
|
124
|
+
throw new CLIError("Native parent identity changed while reading blocker pages.");
|
|
125
|
+
observedParent = parent;
|
|
126
|
+
observedSubject = issue.id;
|
|
173
127
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
128
|
+
for (const blocker of issue.blockedBy.nodes) {
|
|
129
|
+
if (maxPages !== void 0 && blockers.has(blocker.id))
|
|
130
|
+
throw new CLIError("Native blocker pagination repeats an identity.");
|
|
131
|
+
if (requireRepositoryIdentity && !blocker.repository?.nameWithOwner.match(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u))
|
|
132
|
+
throw new CLIError("Native blocker omitted its repository identity.");
|
|
133
|
+
const { repository, ...identity } = blocker;
|
|
134
|
+
blockers.set(blocker.id, {
|
|
135
|
+
...identity,
|
|
136
|
+
...requireRepositoryIdentity ? { repository: repository.nameWithOwner } : {}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (requireRepositoryIdentity && issue.parent && (!issue.parent.number || !issue.parent.repository?.nameWithOwner.match(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u)))
|
|
140
|
+
throw new CLIError("Native parent omitted its repository identity.");
|
|
141
|
+
parentRepository = issue.parent?.repository?.nameWithOwner ?? null;
|
|
142
|
+
parentId = issue.parent?.id ?? null;
|
|
143
|
+
parentNumber = issue.parent?.number ?? null;
|
|
144
|
+
hasNextPage = issue.blockedBy.pageInfo.hasNextPage;
|
|
145
|
+
const nextCursor = issue.blockedBy.pageInfo.endCursor;
|
|
146
|
+
if (hasNextPage && nextCursor === null) {
|
|
147
|
+
throw new CLIError(`Native blocked-by pagination for issue #${String(issueNumber)} omitted its next cursor.`);
|
|
148
|
+
}
|
|
149
|
+
if (hasNextPage && nextCursor !== null && (nextCursor === cursor || seenCursors.has(nextCursor))) {
|
|
150
|
+
throw new CLIError(
|
|
151
|
+
`Native blocked-by pagination for issue #${String(issueNumber)} repeated a non-advancing cursor.`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (nextCursor !== null) seenCursors.add(nextCursor);
|
|
155
|
+
cursor = nextCursor;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
blockers: [...blockers.values()].sort((left, right) => left.number - right.number),
|
|
159
|
+
parentId,
|
|
160
|
+
parentNumber,
|
|
161
|
+
...requireRepositoryIdentity ? { parentRepository } : {}
|
|
162
|
+
};
|
|
180
163
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
164
|
+
async function getNativeBlockingRelationships({
|
|
165
|
+
graphql,
|
|
166
|
+
issueNumber,
|
|
167
|
+
repo
|
|
168
|
+
}) {
|
|
169
|
+
const dependents = /* @__PURE__ */ new Map();
|
|
170
|
+
let cursor = null;
|
|
171
|
+
let hasNextPage = true;
|
|
172
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
173
|
+
while (hasNextPage) {
|
|
174
|
+
const response = await graphql(
|
|
175
|
+
`
|
|
189
176
|
query ($owner: String!, $name: String!, $number: Int!, $cursor: String) {
|
|
190
177
|
repository(owner: $owner, name: $name) {
|
|
191
178
|
issue(number: $number) {
|
|
@@ -204,77 +191,83 @@ export async function getNativeBlockingRelationships({ graphql, issueNumber, rep
|
|
|
204
191
|
}
|
|
205
192
|
}
|
|
206
193
|
}
|
|
207
|
-
`,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
for (const dependent of page.nodes)
|
|
214
|
-
dependents.set(dependent.number, dependent);
|
|
215
|
-
hasNextPage = page.pageInfo.hasNextPage;
|
|
216
|
-
const nextCursor = page.pageInfo.endCursor;
|
|
217
|
-
if (hasNextPage && nextCursor === null) {
|
|
218
|
-
throw new CLIError(`Native blocking pagination for issue #${String(issueNumber)} omitted its next cursor.`);
|
|
219
|
-
}
|
|
220
|
-
if (hasNextPage && nextCursor !== null && (nextCursor === cursor || seenCursors.has(nextCursor))) {
|
|
221
|
-
throw new CLIError(`Native blocking pagination for issue #${String(issueNumber)} repeated a non-advancing cursor.`);
|
|
222
|
-
}
|
|
223
|
-
if (nextCursor !== null)
|
|
224
|
-
seenCursors.add(nextCursor);
|
|
225
|
-
cursor = nextCursor;
|
|
194
|
+
`,
|
|
195
|
+
{ cursor, name: repo.repo, number: issueNumber, owner: repo.owner }
|
|
196
|
+
);
|
|
197
|
+
const parsed = NativeBlockingPageSchema.safeParse(response);
|
|
198
|
+
if (!parsed.success) {
|
|
199
|
+
throw new CLIError(`GitHub returned invalid blocking relationship evidence for issue #${String(issueNumber)}.`);
|
|
226
200
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
owner: repo.owner,
|
|
234
|
-
per_page: 1,
|
|
235
|
-
repo: repo.repo,
|
|
236
|
-
});
|
|
237
|
-
if (requireComplete) {
|
|
238
|
-
if (!Array.isArray(response.data) ||
|
|
239
|
-
response.data.length > 1 ||
|
|
240
|
-
(response.data.length === 0 && response.headers?.link))
|
|
241
|
-
throw new CLIError('Native child existence evidence is incomplete.');
|
|
242
|
-
for (const child of response.data) {
|
|
243
|
-
const parsed = z
|
|
244
|
-
.object({
|
|
245
|
-
number: z.number().int().positive().safe(),
|
|
246
|
-
node_id: z.string().min(1),
|
|
247
|
-
id: z.number().int().positive().safe(),
|
|
248
|
-
html_url: z.string().url(),
|
|
249
|
-
})
|
|
250
|
-
.safeParse(child);
|
|
251
|
-
if (!parsed.success || 'pull_request' in child)
|
|
252
|
-
throw new CLIError('Native child identity is unreadable.');
|
|
253
|
-
const url = new URL(parsed.data.html_url);
|
|
254
|
-
if (url.protocol !== 'https:' ||
|
|
255
|
-
url.hostname !== 'github.com' ||
|
|
256
|
-
url.search ||
|
|
257
|
-
url.hash ||
|
|
258
|
-
!new RegExp(`^/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/issues/${String(parsed.data.number)}$`, 'u').test(url.pathname))
|
|
259
|
-
throw new CLIError('Native child identity is unreadable.');
|
|
260
|
-
}
|
|
201
|
+
const page = parsed.data.repository.issue.blocking;
|
|
202
|
+
for (const dependent of page.nodes) dependents.set(dependent.number, dependent);
|
|
203
|
+
hasNextPage = page.pageInfo.hasNextPage;
|
|
204
|
+
const nextCursor = page.pageInfo.endCursor;
|
|
205
|
+
if (hasNextPage && nextCursor === null) {
|
|
206
|
+
throw new CLIError(`Native blocking pagination for issue #${String(issueNumber)} omitted its next cursor.`);
|
|
261
207
|
}
|
|
262
|
-
|
|
208
|
+
if (hasNextPage && nextCursor !== null && (nextCursor === cursor || seenCursors.has(nextCursor))) {
|
|
209
|
+
throw new CLIError(
|
|
210
|
+
`Native blocking pagination for issue #${String(issueNumber)} repeated a non-advancing cursor.`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (nextCursor !== null) seenCursors.add(nextCursor);
|
|
214
|
+
cursor = nextCursor;
|
|
215
|
+
}
|
|
216
|
+
return [...dependents.values()].sort((left, right) => left.number - right.number);
|
|
263
217
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
218
|
+
async function hasNativeSubIssues({
|
|
219
|
+
issueNumber,
|
|
220
|
+
repo,
|
|
221
|
+
rest,
|
|
222
|
+
requireComplete = false
|
|
223
|
+
}) {
|
|
224
|
+
const response = await rest.issues.listSubIssues({
|
|
225
|
+
issue_number: issueNumber,
|
|
226
|
+
owner: repo.owner,
|
|
227
|
+
per_page: 1,
|
|
228
|
+
repo: repo.repo
|
|
229
|
+
});
|
|
230
|
+
if (requireComplete) {
|
|
231
|
+
if (!Array.isArray(response.data) || response.data.length > 1 || response.data.length === 0 && response.headers?.link)
|
|
232
|
+
throw new CLIError("Native child existence evidence is incomplete.");
|
|
233
|
+
for (const child of response.data) {
|
|
234
|
+
const parsed = z.object({
|
|
235
|
+
number: z.number().int().positive().safe(),
|
|
236
|
+
node_id: z.string().min(1),
|
|
237
|
+
id: z.number().int().positive().safe(),
|
|
238
|
+
html_url: z.string().url()
|
|
239
|
+
}).safeParse(child);
|
|
240
|
+
if (!parsed.success || "pull_request" in child) throw new CLIError("Native child identity is unreadable.");
|
|
241
|
+
const url = new URL(parsed.data.html_url);
|
|
242
|
+
if (url.protocol !== "https:" || url.hostname !== "github.com" || url.search || url.hash || !new RegExp(`^/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/issues/${String(parsed.data.number)}$`, "u").test(url.pathname))
|
|
243
|
+
throw new CLIError("Native child identity is unreadable.");
|
|
267
244
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
245
|
+
}
|
|
246
|
+
return response.data.length > 0;
|
|
247
|
+
}
|
|
248
|
+
async function linkBlockedBy({
|
|
249
|
+
beforeAdd,
|
|
250
|
+
blockerNodeIds,
|
|
251
|
+
blockers,
|
|
252
|
+
existingBlockers = [],
|
|
253
|
+
graphql,
|
|
254
|
+
issueNumber,
|
|
255
|
+
repo,
|
|
256
|
+
rest
|
|
257
|
+
}) {
|
|
258
|
+
if (blockers.length === 0) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const requestedBlockers = [...new Set(blockers)];
|
|
262
|
+
const existing = /* @__PURE__ */ new Set([...existingBlockers, ...await getNativeBlockerNumbers({ graphql, issueNumber, repo })]);
|
|
263
|
+
const blockersToAdd = requestedBlockers.filter((blocker) => !existing.has(blocker));
|
|
264
|
+
if (blockersToAdd.length > 0) {
|
|
265
|
+
const issueNodeId = await issueNumberToNode({ issueNumber, repo, rest });
|
|
266
|
+
for (const blocker of blockersToAdd) {
|
|
267
|
+
const blockerNodeId = blockerNodeIds?.get(blocker) ?? await issueNumberToNode({ issueNumber: blocker, repo, rest });
|
|
268
|
+
if (await beforeAdd?.({ issueNumber, issueNodeId, blocker, blockerNodeId }) === false) continue;
|
|
269
|
+
await graphql(
|
|
270
|
+
`
|
|
278
271
|
mutation ($issue: ID!, $blocking: ID!) {
|
|
279
272
|
addBlockedBy(input: { issueId: $issue, blockingIssueId: $blocking }) {
|
|
280
273
|
issue {
|
|
@@ -282,51 +275,66 @@ export async function linkBlockedBy({ beforeAdd, blockerNodeIds, blockers, exist
|
|
|
282
275
|
}
|
|
283
276
|
}
|
|
284
277
|
}
|
|
285
|
-
`,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
logInfo(`Linked issue #${String(issueNumber)} as blocked by issue #${String(blocker)}.`);
|
|
278
|
+
`,
|
|
279
|
+
{
|
|
280
|
+
blocking: blockerNodeId,
|
|
281
|
+
issue: issueNodeId
|
|
290
282
|
}
|
|
283
|
+
);
|
|
284
|
+
logInfo(`Linked issue #${String(issueNumber)} as blocked by issue #${String(blocker)}.`);
|
|
291
285
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
286
|
+
}
|
|
287
|
+
const observed = new Set(await getNativeBlockerNumbers({ graphql, issueNumber, repo }));
|
|
288
|
+
const missing = requestedBlockers.filter((blocker) => !observed.has(blocker));
|
|
289
|
+
if (missing.length > 0) {
|
|
290
|
+
throw new CLIError(
|
|
291
|
+
`Native blocked-by readback for issue #${String(issueNumber)} omitted requested blocker(s): ${missing.map((blocker) => `#${String(blocker)}`).join(", ")}.`
|
|
292
|
+
);
|
|
293
|
+
}
|
|
299
294
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
295
|
+
async function linkSubIssue({
|
|
296
|
+
parentIssueNumber,
|
|
297
|
+
repo,
|
|
298
|
+
rest,
|
|
299
|
+
subIssueId,
|
|
300
|
+
subIssueNumber
|
|
301
|
+
}) {
|
|
302
|
+
if (parentIssueNumber === subIssueNumber) {
|
|
303
|
+
throw new CLIError(`Issue #${String(subIssueNumber)} cannot be its own parent.`);
|
|
304
|
+
}
|
|
305
|
+
const resolvedSubIssueId = typeof subIssueId === "number" && Number.isFinite(subIssueId) ? subIssueId : await issueNumberToId({ issueNumber: subIssueNumber, repo, rest });
|
|
306
|
+
if (await parentContainsSubIssue({ parentIssueNumber, repo, rest, subIssueNumber })) {
|
|
307
|
+
logInfo(`Issue #${String(subIssueNumber)} is already a sub-issue of issue #${String(parentIssueNumber)}.`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
await rest.issues.addSubIssue({
|
|
311
|
+
issue_number: parentIssueNumber,
|
|
312
|
+
owner: repo.owner,
|
|
313
|
+
repo: repo.repo,
|
|
314
|
+
sub_issue_id: resolvedSubIssueId
|
|
315
|
+
});
|
|
316
|
+
if (!await parentContainsSubIssue({ parentIssueNumber, repo, rest, subIssueNumber })) {
|
|
317
|
+
throw new CLIError(
|
|
318
|
+
`Native sub-issue readback for parent #${String(parentIssueNumber)} omitted requested issue #${String(subIssueNumber)}.`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
logInfo(`Linked issue #${String(subIssueNumber)} as sub-issue of issue #${String(parentIssueNumber)}.`);
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
async function replaceBlockedBy({
|
|
324
|
+
beforeAdd,
|
|
325
|
+
blockers,
|
|
326
|
+
graphql,
|
|
327
|
+
issueNumber,
|
|
328
|
+
repo,
|
|
329
|
+
rest
|
|
330
|
+
}) {
|
|
331
|
+
const requested = [...new Set(blockers)].sort((left, right) => left - right);
|
|
332
|
+
const before = await getNativeBlockerRelationships({ graphql, issueNumber, repo });
|
|
333
|
+
const requestedSet = new Set(requested);
|
|
334
|
+
const issueNodeId = await issueNumberToNode({ issueNumber, repo, rest });
|
|
335
|
+
for (const blocker of before.blockers.filter((candidate) => !requestedSet.has(candidate.number))) {
|
|
336
|
+
await graphql(
|
|
337
|
+
`
|
|
330
338
|
mutation ($issue: ID!, $blocking: ID!) {
|
|
331
339
|
removeBlockedBy(input: { issueId: $issue, blockingIssueId: $blocking }) {
|
|
332
340
|
issue {
|
|
@@ -334,14 +342,16 @@ export async function replaceBlockedBy({ beforeAdd, blockers, graphql, issueNumb
|
|
|
334
342
|
}
|
|
335
343
|
}
|
|
336
344
|
}
|
|
337
|
-
`,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
`,
|
|
346
|
+
{ blocking: blocker.id, issue: issueNodeId }
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
const existing = new Set(before.blockers.map((blocker) => blocker.number));
|
|
350
|
+
for (const blocker of requested.filter((candidate) => !existing.has(candidate))) {
|
|
351
|
+
const blockerNodeId = await issueNumberToNode({ issueNumber: blocker, repo, rest });
|
|
352
|
+
if (await beforeAdd?.({ issueNumber, issueNodeId, blocker, blockerNodeId }) === false) continue;
|
|
353
|
+
await graphql(
|
|
354
|
+
`
|
|
345
355
|
mutation ($issue: ID!, $blocking: ID!) {
|
|
346
356
|
addBlockedBy(input: { issueId: $issue, blockingIssueId: $blocking }) {
|
|
347
357
|
issue {
|
|
@@ -349,135 +359,169 @@ export async function replaceBlockedBy({ beforeAdd, blockers, graphql, issueNumb
|
|
|
349
359
|
}
|
|
350
360
|
}
|
|
351
361
|
}
|
|
352
|
-
`,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
362
|
+
`,
|
|
363
|
+
{ blocking: blockerNodeId, issue: issueNodeId }
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
const observed = (await getNativeBlockerNumbers({ graphql, issueNumber, repo })).sort((left, right) => left - right);
|
|
367
|
+
if (observed.join(",") !== requested.join(",")) {
|
|
368
|
+
throw new CLIError(
|
|
369
|
+
`Native blocked-by replacement readback mismatch for issue #${String(issueNumber)}: expected ${requested.join(",") || "(none)"}, found ${observed.join(",") || "(none)"}.`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
358
372
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
373
|
+
async function replaceParentIssue({
|
|
374
|
+
graphql,
|
|
375
|
+
issueNumber,
|
|
376
|
+
parentIssueNumber,
|
|
377
|
+
repo,
|
|
378
|
+
rest
|
|
379
|
+
}) {
|
|
380
|
+
if (parentIssueNumber === issueNumber) {
|
|
381
|
+
throw new CLIError(`Issue #${String(issueNumber)} cannot be its own parent.`);
|
|
382
|
+
}
|
|
383
|
+
const before = await getNativeBlockerRelationships({ graphql, issueNumber, repo });
|
|
384
|
+
if (before.parentNumber === parentIssueNumber) return;
|
|
385
|
+
const subIssueId = await issueNumberToId({ issueNumber, repo, rest });
|
|
386
|
+
if (before.parentNumber !== null) {
|
|
387
|
+
await rest.issues.removeSubIssue({
|
|
388
|
+
issue_number: before.parentNumber,
|
|
389
|
+
owner: repo.owner,
|
|
390
|
+
repo: repo.repo,
|
|
391
|
+
sub_issue_id: subIssueId
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (parentIssueNumber !== null) {
|
|
395
|
+
await linkSubIssue({ parentIssueNumber, repo, rest, subIssueId, subIssueNumber: issueNumber });
|
|
396
|
+
}
|
|
397
|
+
const after = await getNativeBlockerRelationships({ graphql, issueNumber, repo });
|
|
398
|
+
if (after.parentNumber !== parentIssueNumber) {
|
|
399
|
+
const expectedParent = parentIssueNumber === null ? "(none)" : `#${String(parentIssueNumber)}`;
|
|
400
|
+
const observedParent = after.parentNumber === null ? "(none)" : `#${String(after.parentNumber)}`;
|
|
401
|
+
throw new CLIError(
|
|
402
|
+
`Native parent replacement readback mismatch for issue #${String(issueNumber)}: expected ${expectedParent}, found ${observedParent}.`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
385
405
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
406
|
+
async function resolveNativeRelationshipTargets({
|
|
407
|
+
blockers,
|
|
408
|
+
parentIssueNumber,
|
|
409
|
+
repo,
|
|
410
|
+
rest
|
|
411
|
+
}) {
|
|
412
|
+
const blockerNodeIds = /* @__PURE__ */ new Map();
|
|
413
|
+
const unresolvedBlockers = [];
|
|
414
|
+
for (const blocker of new Set(blockers)) {
|
|
415
|
+
const target = await resolveBlockerTarget({ issueNumber: blocker, repo, rest });
|
|
416
|
+
blockerNodeIds.set(blocker, target.nodeId);
|
|
417
|
+
if (target.state === "OPEN") unresolvedBlockers.push(blocker);
|
|
418
|
+
}
|
|
419
|
+
if (parentIssueNumber !== void 0) {
|
|
420
|
+
await requireIssueTarget({ issueNumber: parentIssueNumber, relationship: "parent", repo, rest });
|
|
421
|
+
}
|
|
422
|
+
return { blockerNodeIds, unresolvedBlockers };
|
|
400
423
|
}
|
|
401
424
|
async function issueNumberToId({ issueNumber, repo, rest }) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
return issueId;
|
|
425
|
+
try {
|
|
426
|
+
const issue = await rest.issues.get({
|
|
427
|
+
issue_number: issueNumber,
|
|
428
|
+
owner: repo.owner,
|
|
429
|
+
repo: repo.repo
|
|
430
|
+
});
|
|
431
|
+
const issueId = issue.data.id;
|
|
432
|
+
if (typeof issueId !== "number") {
|
|
433
|
+
throw new CLIError(`GitHub omitted the numeric issue id for issue #${String(issueNumber)}.`);
|
|
413
434
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
throw new CLIError(`Unable to resolve sub-issue id for issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
435
|
+
return issueId;
|
|
436
|
+
} catch (error) {
|
|
437
|
+
if (error instanceof CLIError) {
|
|
438
|
+
throw error;
|
|
419
439
|
}
|
|
440
|
+
throw new CLIError(`Unable to resolve sub-issue id for issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
441
|
+
}
|
|
420
442
|
}
|
|
421
443
|
async function issueNumberToNode({ issueNumber, repo, rest }) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
return nodeId;
|
|
444
|
+
try {
|
|
445
|
+
const issue = await rest.issues.get({
|
|
446
|
+
issue_number: issueNumber,
|
|
447
|
+
owner: repo.owner,
|
|
448
|
+
repo: repo.repo
|
|
449
|
+
});
|
|
450
|
+
const nodeId = issue.data.node_id;
|
|
451
|
+
if (typeof nodeId !== "string") {
|
|
452
|
+
throw new CLIError(`GitHub omitted the node id for issue #${String(issueNumber)}.`);
|
|
433
453
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
throw new CLIError(`Unable to resolve blocker issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
454
|
+
return nodeId;
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (error instanceof CLIError) {
|
|
457
|
+
throw error;
|
|
439
458
|
}
|
|
459
|
+
throw new CLIError(`Unable to resolve blocker issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
460
|
+
}
|
|
440
461
|
}
|
|
441
|
-
async function parentContainsSubIssue({
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
462
|
+
async function parentContainsSubIssue({
|
|
463
|
+
parentIssueNumber,
|
|
464
|
+
repo,
|
|
465
|
+
rest,
|
|
466
|
+
subIssueNumber
|
|
467
|
+
}) {
|
|
468
|
+
const observed = await rest.paginate(rest.issues.listSubIssues, {
|
|
469
|
+
issue_number: parentIssueNumber,
|
|
470
|
+
owner: repo.owner,
|
|
471
|
+
per_page: 100,
|
|
472
|
+
repo: repo.repo
|
|
473
|
+
});
|
|
474
|
+
return observed.some((issue) => issue.number === subIssueNumber);
|
|
449
475
|
}
|
|
450
|
-
async function requireIssueTarget({
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
476
|
+
async function requireIssueTarget({
|
|
477
|
+
issueNumber,
|
|
478
|
+
relationship,
|
|
479
|
+
repo,
|
|
480
|
+
rest
|
|
481
|
+
}) {
|
|
482
|
+
try {
|
|
483
|
+
await rest.issues.get({
|
|
484
|
+
issue_number: issueNumber,
|
|
485
|
+
owner: repo.owner,
|
|
486
|
+
repo: repo.repo
|
|
487
|
+
});
|
|
488
|
+
} catch (error) {
|
|
489
|
+
throw new CLIError(`Unable to resolve ${relationship} issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
490
|
+
}
|
|
461
491
|
}
|
|
462
|
-
async function resolveBlockerTarget({
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
492
|
+
async function resolveBlockerTarget({
|
|
493
|
+
issueNumber,
|
|
494
|
+
repo,
|
|
495
|
+
rest
|
|
496
|
+
}) {
|
|
497
|
+
try {
|
|
498
|
+
const issue = await rest.issues.get({
|
|
499
|
+
issue_number: issueNumber,
|
|
500
|
+
owner: repo.owner,
|
|
501
|
+
repo: repo.repo
|
|
502
|
+
});
|
|
503
|
+
const nodeId = issue.data.node_id;
|
|
504
|
+
const state = issue.data.state;
|
|
505
|
+
if (typeof nodeId !== "string" || state !== "open" && state !== "closed") {
|
|
506
|
+
throw new CLIError(`GitHub omitted the node id or state for blocker issue #${String(issueNumber)}.`);
|
|
475
507
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
throw new CLIError(`Unable to resolve blocker issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
508
|
+
return { nodeId, state: state === "open" ? "OPEN" : "CLOSED" };
|
|
509
|
+
} catch (error) {
|
|
510
|
+
if (error instanceof CLIError) {
|
|
511
|
+
throw error;
|
|
481
512
|
}
|
|
513
|
+
throw new CLIError(`Unable to resolve blocker issue #${String(issueNumber)}: ${formatError(error)}.`);
|
|
514
|
+
}
|
|
482
515
|
}
|
|
483
|
-
|
|
516
|
+
export {
|
|
517
|
+
getNativeBlockerNumbers,
|
|
518
|
+
getNativeBlockerRelationships,
|
|
519
|
+
getNativeBlockingRelationships,
|
|
520
|
+
hasNativeSubIssues,
|
|
521
|
+
linkBlockedBy,
|
|
522
|
+
linkSubIssue,
|
|
523
|
+
replaceBlockedBy,
|
|
524
|
+
replaceParentIssue,
|
|
525
|
+
resolveNativeRelationshipTargets
|
|
526
|
+
};
|
|
527
|
+
//# sourceMappingURL=relationships.js.map
|