@aviaratech/ai-delivery 0.3.34 → 0.3.36
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 +57 -506
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -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 +1746 -0
- package/dist/boardReconcile.test.js.map +7 -0
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +406 -485
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -25
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +434 -297
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +320 -14
- package/dist/config/deliveryConfig.js +472 -385
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +775 -584
- 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 -477
- 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.d.ts +1 -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 +17 -12
- package/dist/dispatch.js +330 -322
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +16 -3
- package/dist/errors.js +104 -82
- 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 +59 -19
- 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.js +73 -67
- 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 +44 -51
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +3 -0
- package/dist/github/discovery.js +197 -201
- 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 +53 -1
- package/dist/github/projectDelivery.js +623 -460
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.d.ts +5 -2
- package/dist/github/relationships.js +434 -333
- 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 +103 -7
- package/dist/issue.js +2104 -1547
- 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 +1004 -683
- 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 +1945 -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 +1088 -593
- 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 -90
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +790 -220
- package/dist/mcp/tools.js +267 -333
- 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 -1231
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1822 -1283
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +485 -305
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- 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 +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -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 +1204 -0
- package/dist/services/boardReconcileService.js +1445 -0
- package/dist/services/boardReconcileService.js.map +7 -0
- package/dist/services/deliveryAdmission.d.ts +2 -0
- package/dist/services/deliveryAdmission.js +129 -152
- package/dist/services/deliveryAdmission.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/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.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 +354 -350
- 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 +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -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.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- 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 -19
- package/dist/verification.js +1020 -1929
- 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.d.ts +6 -0
- package/dist/version.js +24 -10
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +10 -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 +261 -43
- package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
- 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/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3058
- package/dist/setup.test.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 → boardReconcile.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
package/dist/github/discovery.js
CHANGED
|
@@ -1,226 +1,222 @@
|
|
|
1
|
-
import { DeliveryError } from
|
|
2
|
-
import {
|
|
1
|
+
import { CollectionLimitError, DeliveryError } from "../errors.js";
|
|
2
|
+
import {
|
|
3
|
+
readProjectDeliveryDefinition,
|
|
4
|
+
resolveProjectDeliveryConfiguration
|
|
5
|
+
} from "./projectDelivery.js";
|
|
3
6
|
function record(value, label) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
8
|
+
throw new DeliveryError(`Incomplete GitHub ${label} discovery.`);
|
|
9
|
+
return value;
|
|
7
10
|
}
|
|
8
11
|
function text(value, label) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return value;
|
|
12
|
+
if (typeof value !== "string" || !value.trim()) throw new DeliveryError(`Invalid GitHub ${label}.`);
|
|
13
|
+
return value;
|
|
12
14
|
}
|
|
13
15
|
function positive(value, label) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
17
|
+
throw new DeliveryError(`Invalid GitHub ${label}.`);
|
|
18
|
+
return value;
|
|
17
19
|
}
|
|
18
20
|
function responseRepository(value) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return record(result.repository, 'repository');
|
|
21
|
+
const result = record(value, "repository");
|
|
22
|
+
if ("errors" in result) throw new DeliveryError("Partial GitHub discovery cannot select a delivery destination.");
|
|
23
|
+
return record(result.repository, "repository");
|
|
23
24
|
}
|
|
24
|
-
/** Never turn a failed page, hidden/null node or nonadvancing cursor into a unique candidate. */
|
|
25
25
|
async function repositoryConnection(input) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const nodes = [];
|
|
27
|
+
const ids = /* @__PURE__ */ new Set();
|
|
28
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
29
|
+
let cursor = null;
|
|
30
|
+
let pages = 0;
|
|
31
|
+
for (; ; ) {
|
|
32
|
+
if (input.maxPages !== void 0 && pages >= input.maxPages)
|
|
33
|
+
throw new CollectionLimitError({
|
|
34
|
+
collection: input.field,
|
|
35
|
+
pagesRequested: pages,
|
|
36
|
+
rowsObserved: nodes.length,
|
|
37
|
+
limit: input.maxPages
|
|
38
|
+
});
|
|
39
|
+
pages++;
|
|
40
|
+
const result = await input.clients.graphql(
|
|
41
|
+
`query DeliveryDiscovery($owner: String!, $repo: String!, $cursor: String) {
|
|
32
42
|
repository(owner: $owner, name: $repo) {
|
|
33
43
|
${input.field}(first: 100, after: $cursor) { nodes { ${input.selection} } pageInfo { hasNextPage endCursor } }
|
|
34
44
|
}
|
|
35
|
-
}`,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
const page = record(connection.pageInfo, `${input.field} pagination`);
|
|
48
|
-
if (typeof page.hasNextPage !== 'boolean')
|
|
49
|
-
throw new DeliveryError('Incomplete GitHub discovery pagination.');
|
|
50
|
-
if (!page.hasNextPage)
|
|
51
|
-
return nodes;
|
|
52
|
-
const next = text(page.endCursor, 'discovery cursor');
|
|
53
|
-
if (next === cursor || cursors.has(next))
|
|
54
|
-
throw new DeliveryError('GitHub discovery cursor did not advance.');
|
|
55
|
-
cursors.add(next);
|
|
56
|
-
cursor = next;
|
|
45
|
+
}`,
|
|
46
|
+
{ owner: input.owner, repo: input.repo, cursor }
|
|
47
|
+
);
|
|
48
|
+
const connection = record(responseRepository(result)[input.field], input.field);
|
|
49
|
+
if (!Array.isArray(connection.nodes)) throw new DeliveryError(`Incomplete GitHub ${input.field} nodes.`);
|
|
50
|
+
for (const value of connection.nodes) {
|
|
51
|
+
const node = record(value, input.field);
|
|
52
|
+
const id = text(node.id, `${input.field} node ID`);
|
|
53
|
+
if (ids.has(id)) throw new DeliveryError(`Repeated ${input.field} node during discovery.`);
|
|
54
|
+
ids.add(id);
|
|
55
|
+
nodes.push(node);
|
|
57
56
|
}
|
|
57
|
+
const page = record(connection.pageInfo, `${input.field} pagination`);
|
|
58
|
+
if (typeof page.hasNextPage !== "boolean") throw new DeliveryError("Incomplete GitHub discovery pagination.");
|
|
59
|
+
if (!page.hasNextPage) return nodes;
|
|
60
|
+
const next = text(page.endCursor, "discovery cursor");
|
|
61
|
+
if (next === cursor || cursors.has(next)) throw new DeliveryError("GitHub discovery cursor did not advance.");
|
|
62
|
+
cursors.add(next);
|
|
63
|
+
cursor = next;
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
function nativeField(nodes, name) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return { databaseId, name, values };
|
|
67
|
+
const matches = nodes.filter((node) => node.name === name);
|
|
68
|
+
if (matches.length !== 1) throw new DeliveryError(`Select an unambiguous native single-select field for ${name}.`);
|
|
69
|
+
const field = matches[0];
|
|
70
|
+
if (!field || field.__typename !== "IssueFieldSingleSelect" || !Array.isArray(field.options)) {
|
|
71
|
+
throw new DeliveryError(`Native ${name} must be an organization single-select issue field.`);
|
|
72
|
+
}
|
|
73
|
+
const databaseId = String(field.fullDatabaseId);
|
|
74
|
+
if (!/^[1-9]\d*$/u.test(databaseId) || !Number.isSafeInteger(Number(databaseId))) {
|
|
75
|
+
throw new DeliveryError(`Invalid native ${name} field ID.`);
|
|
76
|
+
}
|
|
77
|
+
const values = field.options.map((value) => text(record(value, `${name} option`).name, `${name} option name`)).sort();
|
|
78
|
+
if (!values.length || new Set(values).size !== values.length)
|
|
79
|
+
throw new DeliveryError(`Ambiguous native ${name} options.`);
|
|
80
|
+
return { databaseId, name, values };
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
async function discoverDeliveryRouting(input) {
|
|
83
|
+
const [owner, repo] = input.repository.split("/");
|
|
84
|
+
if (!owner || !repo) throw new DeliveryError("Invalid delivery repository.");
|
|
85
|
+
const read = (field, selection) => repositoryConnection({ ...input, owner, repo, field, selection });
|
|
86
|
+
const [identityResponse, fields, types, candidates] = await Promise.all([
|
|
87
|
+
input.clients.graphql(
|
|
88
|
+
`query DeliveryRepository($owner: String!, $repo: String!) {
|
|
81
89
|
repository(owner: $owner, name: $repo) { id nameWithOwner isFork owner { __typename login } }
|
|
82
|
-
}`,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (identity.isFork && input.overrides.remote === undefined && input.repositorySelected !== true)
|
|
89
|
-
throw new DeliveryError('A fork requires an explicit remote selection before delivery.');
|
|
90
|
-
const org = record(identity.owner, 'repository owner');
|
|
91
|
-
if (org.__typename !== 'Organization' || text(org.login, 'organization').toLowerCase() !== owner.toLowerCase()) {
|
|
92
|
-
throw new DeliveryError('Native delivery requires a repository owned by its selected GitHub organization.');
|
|
93
|
-
}
|
|
94
|
-
const fields = await repositoryConnection({
|
|
95
|
-
...input,
|
|
96
|
-
owner,
|
|
97
|
-
repo,
|
|
98
|
-
field: 'issueFields',
|
|
99
|
-
selection: `__typename
|
|
90
|
+
}`,
|
|
91
|
+
{ owner, repo }
|
|
92
|
+
),
|
|
93
|
+
read(
|
|
94
|
+
"issueFields",
|
|
95
|
+
`__typename
|
|
100
96
|
... on IssueFieldSingleSelect { id fullDatabaseId name options { id name } }
|
|
101
97
|
... on IssueFieldDate { id }
|
|
102
98
|
... on IssueFieldNumber { id }
|
|
103
99
|
... on IssueFieldText { id }
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
`
|
|
101
|
+
),
|
|
102
|
+
read("issueTypes", "id name isEnabled"),
|
|
103
|
+
input.overrides.project === void 0 ? read(
|
|
104
|
+
"projectsV2",
|
|
105
|
+
"id number title closed viewerCanUpdate owner { __typename ... on Organization { login } ... on User { login } }"
|
|
106
|
+
) : [{ number: input.overrides.project }]
|
|
107
|
+
]);
|
|
108
|
+
const identity = responseRepository(identityResponse);
|
|
109
|
+
const repository = text(identity.nameWithOwner, "repository name");
|
|
110
|
+
if (repository.toLowerCase() !== input.repository.toLowerCase())
|
|
111
|
+
throw new DeliveryError("GitHub repository does not match the selected Git remote.");
|
|
112
|
+
if (typeof identity.isFork !== "boolean") throw new DeliveryError("GitHub omitted repository fork identity.");
|
|
113
|
+
if (identity.isFork && input.overrides.remote === void 0 && input.repositorySelected !== true)
|
|
114
|
+
throw new DeliveryError("A fork requires an explicit remote selection before delivery.");
|
|
115
|
+
const org = record(identity.owner, "repository owner");
|
|
116
|
+
if (org.__typename !== "Organization" || text(org.login, "organization").toLowerCase() !== owner.toLowerCase()) {
|
|
117
|
+
throw new DeliveryError("Native delivery requires a repository owned by its selected GitHub organization.");
|
|
118
|
+
}
|
|
119
|
+
const points = nativeField(fields, input.overrides.pointsField ?? "Points");
|
|
120
|
+
const priority = nativeField(fields, input.overrides.priorityField ?? "Priority");
|
|
121
|
+
const availableTypes = types.filter((type) => {
|
|
122
|
+
if (typeof type.isEnabled !== "boolean") throw new DeliveryError("GitHub omitted issue type availability.");
|
|
123
|
+
return type.isEnabled;
|
|
124
|
+
}).map((type) => text(type.name, "issue type")).sort();
|
|
125
|
+
if (!availableTypes.length || new Set(availableTypes).size !== availableTypes.length)
|
|
126
|
+
throw new DeliveryError("No unambiguous enabled native issue types were discovered.");
|
|
127
|
+
const issueTypes = input.overrides.issueTypes?.slice().sort() ?? availableTypes;
|
|
128
|
+
if (issueTypes.some((type) => !availableTypes.includes(type)))
|
|
129
|
+
throw new DeliveryError("Configured issue type is unavailable in the selected repository.");
|
|
130
|
+
const projectSource = input.overrides.project === void 0 ? "linked" : "explicit";
|
|
131
|
+
const compatible = [];
|
|
132
|
+
for (const candidate of candidates) {
|
|
133
|
+
if (projectSource === "linked") {
|
|
134
|
+
if (typeof candidate.closed !== "boolean" || typeof candidate.viewerCanUpdate !== "boolean")
|
|
135
|
+
throw new DeliveryError("Incomplete linked Project metadata.");
|
|
136
|
+
const projectOwner = record(candidate.owner, "Project owner");
|
|
137
|
+
if (projectOwner.__typename !== "Organization" || text(projectOwner.login, "Project owner").toLowerCase() !== owner.toLowerCase()) {
|
|
138
|
+
throw new DeliveryError("Linked Project owner does not match the selected repository organization.");
|
|
139
|
+
}
|
|
140
|
+
if (candidate.closed) continue;
|
|
141
|
+
}
|
|
142
|
+
const number = positive(candidate.number, "Project number");
|
|
143
|
+
const project = await readProjectDeliveryDefinition({
|
|
144
|
+
graphql: input.clients.graphql,
|
|
145
|
+
org: owner,
|
|
146
|
+
number,
|
|
147
|
+
...input.maxPages === void 0 ? {} : { maxPages: input.maxPages }
|
|
114
148
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.map((type) => text(type.name, 'issue type'))
|
|
122
|
-
.sort();
|
|
123
|
-
if (!availableTypes.length || new Set(availableTypes).size !== availableTypes.length)
|
|
124
|
-
throw new DeliveryError('No unambiguous enabled native issue types were discovered.');
|
|
125
|
-
const issueTypes = input.overrides.issueTypes?.slice().sort() ?? availableTypes;
|
|
126
|
-
if (issueTypes.some((type) => !availableTypes.includes(type)))
|
|
127
|
-
throw new DeliveryError('Configured issue type is unavailable in the selected repository.');
|
|
128
|
-
const projectSource = input.overrides.project === undefined ? 'linked' : 'explicit';
|
|
129
|
-
const candidates = input.overrides.project === undefined
|
|
130
|
-
? await repositoryConnection({
|
|
131
|
-
...input,
|
|
132
|
-
owner,
|
|
133
|
-
repo,
|
|
134
|
-
field: 'projectsV2',
|
|
135
|
-
selection: 'id number title closed viewerCanUpdate owner { __typename ... on Organization { login } ... on User { login } }',
|
|
136
|
-
})
|
|
137
|
-
: [{ number: input.overrides.project }];
|
|
138
|
-
const compatible = [];
|
|
139
|
-
for (const candidate of candidates) {
|
|
140
|
-
if (projectSource === 'linked') {
|
|
141
|
-
if (typeof candidate.closed !== 'boolean' || typeof candidate.viewerCanUpdate !== 'boolean')
|
|
142
|
-
throw new DeliveryError('Incomplete linked Project metadata.');
|
|
143
|
-
const projectOwner = record(candidate.owner, 'Project owner');
|
|
144
|
-
if (projectOwner.__typename !== 'Organization' ||
|
|
145
|
-
text(projectOwner.login, 'Project owner').toLowerCase() !== owner.toLowerCase()) {
|
|
146
|
-
throw new DeliveryError('Linked Project owner does not match the selected repository organization.');
|
|
147
|
-
}
|
|
148
|
-
if (candidate.closed)
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const number = positive(candidate.number, 'Project number');
|
|
152
|
-
// API/permission/partial-read failures propagate; only complete incompatible schemas are excluded.
|
|
153
|
-
const project = await readProjectDeliveryDefinition({ graphql: input.clients.graphql, org: owner, number });
|
|
154
|
-
if (typeof project.viewerCanUpdate !== 'boolean' || project.number !== number)
|
|
155
|
-
throw new DeliveryError('Incomplete or drifting Project identity.');
|
|
156
|
-
if (typeof project.closed !== 'boolean')
|
|
157
|
-
throw new DeliveryError('GitHub omitted Project closed state.');
|
|
158
|
-
if (project.closed) {
|
|
159
|
-
if (projectSource === 'explicit')
|
|
160
|
-
throw new DeliveryError('The explicitly selected Project is closed.');
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if (projectSource === 'linked' && (project.id !== candidate.id || project.title !== candidate.title))
|
|
164
|
-
throw new DeliveryError('Linked Project changed during discovery.');
|
|
165
|
-
const settings = {
|
|
166
|
-
number,
|
|
167
|
-
title: text(project.title, 'Project title'),
|
|
168
|
-
points,
|
|
169
|
-
priority,
|
|
170
|
-
statusField: input.overrides.statusField ?? 'Status',
|
|
171
|
-
statuses: {
|
|
172
|
-
Todo: input.overrides.statuses?.todo ?? 'Todo',
|
|
173
|
-
'In Progress': input.overrides.statuses?.inProgress ?? 'In Progress',
|
|
174
|
-
Blocked: input.overrides.statuses?.blocked ?? 'Blocked',
|
|
175
|
-
Done: input.overrides.statuses?.done ?? 'Done',
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
let configuration;
|
|
179
|
-
try {
|
|
180
|
-
configuration = resolveProjectDeliveryConfiguration(project, { settings, requireWritable: false });
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
if (projectSource === 'explicit' || !(error instanceof DeliveryError))
|
|
184
|
-
throw error;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
if (!configuration.writable)
|
|
188
|
-
throw new DeliveryError('A compatible delivery Project is not writable; refusing destination fallback.');
|
|
189
|
-
compatible.push(configuration);
|
|
149
|
+
if (typeof project.viewerCanUpdate !== "boolean" || project.number !== number)
|
|
150
|
+
throw new DeliveryError("Incomplete or drifting Project identity.");
|
|
151
|
+
if (typeof project.closed !== "boolean") throw new DeliveryError("GitHub omitted Project closed state.");
|
|
152
|
+
if (project.closed) {
|
|
153
|
+
if (projectSource === "explicit") throw new DeliveryError("The explicitly selected Project is closed.");
|
|
154
|
+
continue;
|
|
190
155
|
}
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
native: {
|
|
206
|
-
organization: text(org.login, 'organization'),
|
|
207
|
-
issueTypes,
|
|
208
|
-
points,
|
|
209
|
-
priority,
|
|
210
|
-
milestones: 'repository',
|
|
211
|
-
relationships: { blockedBy: 'native', parent: 'native' },
|
|
212
|
-
project: {
|
|
213
|
-
number: selected.projectNumber,
|
|
214
|
-
title: selected.title,
|
|
215
|
-
statusField: selected.settings.statusField,
|
|
216
|
-
statuses: {
|
|
217
|
-
todo: selected.settings.statuses.Todo,
|
|
218
|
-
inProgress: selected.settings.statuses['In Progress'],
|
|
219
|
-
blocked: selected.settings.statuses.Blocked,
|
|
220
|
-
done: selected.settings.statuses.Done,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
156
|
+
if (projectSource === "linked" && (project.id !== candidate.id || project.title !== candidate.title))
|
|
157
|
+
throw new DeliveryError("Linked Project changed during discovery.");
|
|
158
|
+
const settings = {
|
|
159
|
+
number,
|
|
160
|
+
title: text(project.title, "Project title"),
|
|
161
|
+
points,
|
|
162
|
+
priority,
|
|
163
|
+
statusField: input.overrides.statusField ?? "Status",
|
|
164
|
+
statuses: {
|
|
165
|
+
Todo: input.overrides.statuses?.todo ?? "Todo",
|
|
166
|
+
"In Progress": input.overrides.statuses?.inProgress ?? "In Progress",
|
|
167
|
+
Blocked: input.overrides.statuses?.blocked ?? "Blocked",
|
|
168
|
+
Done: input.overrides.statuses?.done ?? "Done"
|
|
169
|
+
}
|
|
224
170
|
};
|
|
171
|
+
let configuration;
|
|
172
|
+
try {
|
|
173
|
+
configuration = resolveProjectDeliveryConfiguration(project, { settings, requireWritable: false });
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (projectSource === "explicit" || !(error instanceof DeliveryError)) throw error;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!configuration.writable && input.requireWritableProject !== false)
|
|
179
|
+
throw new DeliveryError("A compatible delivery Project is not writable; refusing destination fallback.");
|
|
180
|
+
compatible.push(configuration);
|
|
181
|
+
}
|
|
182
|
+
if (compatible.length !== 1)
|
|
183
|
+
throw new DeliveryError(
|
|
184
|
+
`Discovered ${compatible.length} compatible linked Projects. Select project explicitly in ai-delivery.config.json; no issue was created.`
|
|
185
|
+
);
|
|
186
|
+
const selected = compatible[0];
|
|
187
|
+
if (!selected) throw new DeliveryError("Delivery Project selection is incomplete.");
|
|
188
|
+
return {
|
|
189
|
+
repository,
|
|
190
|
+
repositoryId: text(identity.id, "repository ID"),
|
|
191
|
+
projectId: selected.projectId,
|
|
192
|
+
projectSource,
|
|
193
|
+
statusFieldId: selected.statusFieldId,
|
|
194
|
+
statusOptionIds: selected.statusOptionIds,
|
|
195
|
+
...selected.reviewOptionId ? { reviewOptionId: selected.reviewOptionId } : {},
|
|
196
|
+
pointsFieldId: selected.pointsFieldId,
|
|
197
|
+
priorityFieldId: selected.priorityFieldId,
|
|
198
|
+
native: {
|
|
199
|
+
organization: text(org.login, "organization"),
|
|
200
|
+
issueTypes,
|
|
201
|
+
points,
|
|
202
|
+
priority,
|
|
203
|
+
milestones: "repository",
|
|
204
|
+
relationships: { blockedBy: "native", parent: "native" },
|
|
205
|
+
project: {
|
|
206
|
+
number: selected.projectNumber,
|
|
207
|
+
title: selected.title,
|
|
208
|
+
statusField: selected.settings.statusField,
|
|
209
|
+
statuses: {
|
|
210
|
+
todo: selected.settings.statuses.Todo,
|
|
211
|
+
inProgress: selected.settings.statuses["In Progress"],
|
|
212
|
+
blocked: selected.settings.statuses.Blocked,
|
|
213
|
+
done: selected.settings.statuses.Done
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
225
218
|
}
|
|
226
|
-
|
|
219
|
+
export {
|
|
220
|
+
discoverDeliveryRouting
|
|
221
|
+
};
|
|
222
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/github/discovery.ts"],
|
|
4
|
+
"sourcesContent": ["import type { graphql as GraphQLType } from '@octokit/graphql';\n\nimport type { DeliveryConfig, DeliveryOverrides } from '../config/deliveryConfig.js';\nimport { CollectionLimitError, DeliveryError } from '../errors.js';\nimport {\n readProjectDeliveryDefinition,\n resolveProjectDeliveryConfiguration,\n type ProjectDeliveryConfiguration,\n} from './projectDelivery.js';\n\nexport interface DiscoveryClients {\n graphql: typeof GraphQLType;\n}\nexport interface DeliveryRouting {\n repository: string;\n repositoryId: string;\n projectId: string;\n projectSource: 'explicit' | 'linked';\n statusFieldId: string;\n statusOptionIds: ProjectDeliveryConfiguration['statusOptionIds'];\n reviewOptionId?: string;\n pointsFieldId: string;\n priorityFieldId: string;\n native: DeliveryConfig['native'];\n}\n\nfunction record(value: unknown, label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new DeliveryError(`Incomplete GitHub ${label} discovery.`);\n return value as Record<string, unknown>;\n}\nfunction text(value: unknown, label: string): string {\n if (typeof value !== 'string' || !value.trim()) throw new DeliveryError(`Invalid GitHub ${label}.`);\n return value;\n}\nfunction positive(value: unknown, label: string): number {\n if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0)\n throw new DeliveryError(`Invalid GitHub ${label}.`);\n return value;\n}\nfunction responseRepository(value: unknown): Record<string, unknown> {\n const result = record(value, 'repository');\n if ('errors' in result) throw new DeliveryError('Partial GitHub discovery cannot select a delivery destination.');\n return record(result.repository, 'repository');\n}\n\n/** Never turn a failed page, hidden/null node or nonadvancing cursor into a unique candidate. */\nasync function repositoryConnection(input: {\n clients: DiscoveryClients;\n owner: string;\n repo: string;\n field: 'issueTypes' | 'issueFields' | 'projectsV2';\n selection: string;\n maxPages?: number;\n}): Promise<Record<string, unknown>[]> {\n const nodes: Record<string, unknown>[] = [];\n const ids = new Set<string>();\n const cursors = new Set<string>();\n let cursor: string | null = null;\n let pages = 0;\n for (;;) {\n if (input.maxPages !== undefined && pages >= input.maxPages)\n throw new CollectionLimitError({\n collection: input.field,\n pagesRequested: pages,\n rowsObserved: nodes.length,\n limit: input.maxPages,\n });\n pages++;\n const result: unknown = await input.clients.graphql(\n `query DeliveryDiscovery($owner: String!, $repo: String!, $cursor: String) {\n repository(owner: $owner, name: $repo) {\n ${input.field}(first: 100, after: $cursor) { nodes { ${input.selection} } pageInfo { hasNextPage endCursor } }\n }\n }`,\n { owner: input.owner, repo: input.repo, cursor },\n );\n const connection = record(responseRepository(result)[input.field], input.field);\n if (!Array.isArray(connection.nodes)) throw new DeliveryError(`Incomplete GitHub ${input.field} nodes.`);\n for (const value of connection.nodes) {\n const node = record(value, input.field);\n const id = text(node.id, `${input.field} node ID`);\n if (ids.has(id)) throw new DeliveryError(`Repeated ${input.field} node during discovery.`);\n ids.add(id);\n nodes.push(node);\n }\n const page = record(connection.pageInfo, `${input.field} pagination`);\n if (typeof page.hasNextPage !== 'boolean') throw new DeliveryError('Incomplete GitHub discovery pagination.');\n if (!page.hasNextPage) return nodes;\n const next = text(page.endCursor, 'discovery cursor');\n if (next === cursor || cursors.has(next)) throw new DeliveryError('GitHub discovery cursor did not advance.');\n cursors.add(next);\n cursor = next;\n }\n}\n\nfunction nativeField(nodes: Record<string, unknown>[], name: string): DeliveryConfig['native']['points'] {\n const matches = nodes.filter((node) => node.name === name);\n if (matches.length !== 1) throw new DeliveryError(`Select an unambiguous native single-select field for ${name}.`);\n const field = matches[0];\n if (!field || field.__typename !== 'IssueFieldSingleSelect' || !Array.isArray(field.options)) {\n throw new DeliveryError(`Native ${name} must be an organization single-select issue field.`);\n }\n const databaseId = String(field.fullDatabaseId);\n if (!/^[1-9]\\d*$/u.test(databaseId) || !Number.isSafeInteger(Number(databaseId))) {\n throw new DeliveryError(`Invalid native ${name} field ID.`);\n }\n const values = field.options.map((value) => text(record(value, `${name} option`).name, `${name} option name`)).sort();\n if (!values.length || new Set(values).size !== values.length)\n throw new DeliveryError(`Ambiguous native ${name} options.`);\n return { databaseId, name, values };\n}\n\nexport async function discoverDeliveryRouting(input: {\n clients: DiscoveryClients;\n repository: string;\n overrides: DeliveryOverrides;\n repositorySelected?: boolean;\n maxPages?: number;\n requireWritableProject?: boolean;\n}): Promise<DeliveryRouting> {\n const [owner, repo] = input.repository.split('/');\n if (!owner || !repo) throw new DeliveryError('Invalid delivery repository.');\n // The four repository reads are independent; validation below keeps the original order.\n const read = (field: 'issueTypes' | 'issueFields' | 'projectsV2', selection: string) =>\n repositoryConnection({ ...input, owner, repo, field, selection });\n const [identityResponse, fields, types, candidates] = await Promise.all([\n input.clients.graphql(\n `query DeliveryRepository($owner: String!, $repo: String!) {\n repository(owner: $owner, name: $repo) { id nameWithOwner isFork owner { __typename login } }\n }`,\n { owner, repo },\n ),\n read(\n 'issueFields',\n `__typename\n ... on IssueFieldSingleSelect { id fullDatabaseId name options { id name } }\n ... on IssueFieldDate { id }\n ... on IssueFieldNumber { id }\n ... on IssueFieldText { id }\n `,\n ),\n read('issueTypes', 'id name isEnabled'),\n input.overrides.project === undefined\n ? read(\n 'projectsV2',\n 'id number title closed viewerCanUpdate owner { __typename ... on Organization { login } ... on User { login } }',\n )\n : [{ number: input.overrides.project } as Record<string, unknown>],\n ]);\n const identity = responseRepository(identityResponse);\n const repository = text(identity.nameWithOwner, 'repository name');\n if (repository.toLowerCase() !== input.repository.toLowerCase())\n throw new DeliveryError('GitHub repository does not match the selected Git remote.');\n if (typeof identity.isFork !== 'boolean') throw new DeliveryError('GitHub omitted repository fork identity.');\n if (identity.isFork && input.overrides.remote === undefined && input.repositorySelected !== true)\n throw new DeliveryError('A fork requires an explicit remote selection before delivery.');\n const org = record(identity.owner, 'repository owner');\n if (org.__typename !== 'Organization' || text(org.login, 'organization').toLowerCase() !== owner.toLowerCase()) {\n throw new DeliveryError('Native delivery requires a repository owned by its selected GitHub organization.');\n }\n const points = nativeField(fields, input.overrides.pointsField ?? 'Points');\n const priority = nativeField(fields, input.overrides.priorityField ?? 'Priority');\n const availableTypes = types\n .filter((type) => {\n if (typeof type.isEnabled !== 'boolean') throw new DeliveryError('GitHub omitted issue type availability.');\n return type.isEnabled;\n })\n .map((type) => text(type.name, 'issue type'))\n .sort();\n if (!availableTypes.length || new Set(availableTypes).size !== availableTypes.length)\n throw new DeliveryError('No unambiguous enabled native issue types were discovered.');\n const issueTypes = input.overrides.issueTypes?.slice().sort() ?? availableTypes;\n if (issueTypes.some((type) => !availableTypes.includes(type)))\n throw new DeliveryError('Configured issue type is unavailable in the selected repository.');\n const projectSource = input.overrides.project === undefined ? 'linked' : 'explicit';\n const compatible: ProjectDeliveryConfiguration[] = [];\n for (const candidate of candidates) {\n if (projectSource === 'linked') {\n if (typeof candidate.closed !== 'boolean' || typeof candidate.viewerCanUpdate !== 'boolean')\n throw new DeliveryError('Incomplete linked Project metadata.');\n const projectOwner = record(candidate.owner, 'Project owner');\n if (\n projectOwner.__typename !== 'Organization' ||\n text(projectOwner.login, 'Project owner').toLowerCase() !== owner.toLowerCase()\n ) {\n throw new DeliveryError('Linked Project owner does not match the selected repository organization.');\n }\n if (candidate.closed) continue;\n }\n const number = positive(candidate.number, 'Project number');\n // API/permission/partial-read failures propagate; only complete incompatible schemas are excluded.\n const project = await readProjectDeliveryDefinition({\n graphql: input.clients.graphql,\n org: owner,\n number,\n ...(input.maxPages === undefined ? {} : { maxPages: input.maxPages }),\n });\n if (typeof project.viewerCanUpdate !== 'boolean' || project.number !== number)\n throw new DeliveryError('Incomplete or drifting Project identity.');\n if (typeof project.closed !== 'boolean') throw new DeliveryError('GitHub omitted Project closed state.');\n if (project.closed) {\n if (projectSource === 'explicit') throw new DeliveryError('The explicitly selected Project is closed.');\n continue;\n }\n if (projectSource === 'linked' && (project.id !== candidate.id || project.title !== candidate.title))\n throw new DeliveryError('Linked Project changed during discovery.');\n const settings = {\n number,\n title: text(project.title, 'Project title'),\n points,\n priority,\n statusField: input.overrides.statusField ?? 'Status',\n statuses: {\n Todo: input.overrides.statuses?.todo ?? 'Todo',\n 'In Progress': input.overrides.statuses?.inProgress ?? 'In Progress',\n Blocked: input.overrides.statuses?.blocked ?? 'Blocked',\n Done: input.overrides.statuses?.done ?? 'Done',\n },\n };\n let configuration: ProjectDeliveryConfiguration;\n try {\n configuration = resolveProjectDeliveryConfiguration(project, { settings, requireWritable: false });\n } catch (error) {\n if (projectSource === 'explicit' || !(error instanceof DeliveryError)) throw error;\n continue;\n }\n if (!configuration.writable && input.requireWritableProject !== false)\n throw new DeliveryError('A compatible delivery Project is not writable; refusing destination fallback.');\n compatible.push(configuration);\n }\n if (compatible.length !== 1)\n throw new DeliveryError(\n `Discovered ${compatible.length} compatible linked Projects. Select project explicitly in ai-delivery.config.json; no issue was created.`,\n );\n const selected = compatible[0];\n if (!selected) throw new DeliveryError('Delivery Project selection is incomplete.');\n return {\n repository,\n repositoryId: text(identity.id, 'repository ID'),\n projectId: selected.projectId,\n projectSource,\n statusFieldId: selected.statusFieldId,\n statusOptionIds: selected.statusOptionIds,\n ...(selected.reviewOptionId ? { reviewOptionId: selected.reviewOptionId } : {}),\n pointsFieldId: selected.pointsFieldId,\n priorityFieldId: selected.priorityFieldId,\n native: {\n organization: text(org.login, 'organization'),\n issueTypes,\n points,\n priority,\n milestones: 'repository',\n relationships: { blockedBy: 'native', parent: 'native' },\n project: {\n number: selected.projectNumber,\n title: selected.title,\n statusField: selected.settings.statusField,\n statuses: {\n todo: selected.settings.statuses.Todo,\n inProgress: selected.settings.statuses['In Progress'],\n blocked: selected.settings.statuses.Blocked,\n done: selected.settings.statuses.Done,\n },\n },\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,sBAAsB,qBAAqB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAkBP,SAAS,OAAO,OAAgB,OAAwC;AACtE,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK;AACpE,UAAM,IAAI,cAAc,qBAAqB,KAAK,aAAa;AACjE,SAAO;AACT;AACA,SAAS,KAAK,OAAgB,OAAuB;AACnD,MAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,EAAG,OAAM,IAAI,cAAc,kBAAkB,KAAK,GAAG;AAClG,SAAO;AACT;AACA,SAAS,SAAS,OAAgB,OAAuB;AACvD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS;AACxE,UAAM,IAAI,cAAc,kBAAkB,KAAK,GAAG;AACpD,SAAO;AACT;AACA,SAAS,mBAAmB,OAAyC;AACnE,QAAM,SAAS,OAAO,OAAO,YAAY;AACzC,MAAI,YAAY,OAAQ,OAAM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