@aviaratech/ai-delivery 0.3.35 → 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 -554
- 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 +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 +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +402 -515
- 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 +329 -353
- 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 +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 -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 +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 +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 +264 -286
- package/dist/mcp/tools.js +267 -340
- 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 +460 -409
- 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 +125 -125
- package/dist/services/boardReconcileService.js +1295 -1421
- package/dist/services/boardReconcileService.js.map +7 -1
- package/dist/services/deliveryAdmission.js +131 -154
- 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 +353 -352
- 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 -1939
- 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 +23 -24
- 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 +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 +358 -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/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/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,283 +1,328 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
1
|
+
import { issueProjectItemsResponse } from "./issueProjectItems.js";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import {
|
|
6
|
+
existsSync,
|
|
7
|
+
lstatSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
mkdtempSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
realpathSync,
|
|
12
|
+
rmSync,
|
|
13
|
+
writeFileSync
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { syntheticDiscoveryClients } from "./discovery.js";
|
|
18
|
+
const digestBytes = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
19
|
+
function entrypointClients(head) {
|
|
20
|
+
const calls = [];
|
|
21
|
+
const record = (name, input = null) => calls.push({ name, input });
|
|
22
|
+
const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
|
|
23
|
+
const issue = {
|
|
24
|
+
id: 117,
|
|
25
|
+
number: 17,
|
|
26
|
+
node_id: "ISSUE17",
|
|
27
|
+
title: "Fictional widget",
|
|
28
|
+
body: "Consumer script-looking prose is data.",
|
|
29
|
+
state: "open",
|
|
30
|
+
type: { name: "Task" },
|
|
31
|
+
html_url: "https://github.com/example/widget/issues/17",
|
|
32
|
+
url: "https://api.github.com/repos/example/widget/issues/17",
|
|
33
|
+
repository_url: "https://api.github.com/repos/example/widget"
|
|
34
|
+
};
|
|
35
|
+
const children = [19, 18].map((number) => ({
|
|
36
|
+
...issue,
|
|
37
|
+
id: 100 + number,
|
|
38
|
+
number,
|
|
39
|
+
node_id: `ISSUE${number}`,
|
|
40
|
+
state: number === 18 ? "closed" : "open",
|
|
41
|
+
html_url: `https://github.com/example/widget/issues/${number}`,
|
|
42
|
+
url: `https://api.github.com/repos/example/widget/issues/${number}`
|
|
43
|
+
}));
|
|
44
|
+
const pr = {
|
|
45
|
+
number: 23,
|
|
46
|
+
state: "open",
|
|
47
|
+
draft: false,
|
|
48
|
+
merged: false,
|
|
49
|
+
head: { sha: head, ref: "issue/17", repo: { full_name: "example/widget" } },
|
|
50
|
+
base: { sha: head, ref: "main", repo: { full_name: "example/widget" } },
|
|
51
|
+
html_url: "https://github.com/example/widget/pull/23"
|
|
52
|
+
};
|
|
53
|
+
const item = {
|
|
54
|
+
id: "ITEM17",
|
|
55
|
+
isArchived: false,
|
|
56
|
+
content: { __typename: "Issue", id: "ISSUE17" },
|
|
57
|
+
project: { id: "PROJECT-1", number: 1 },
|
|
58
|
+
fieldValueByName: {
|
|
59
|
+
__typename: "ProjectV2ItemFieldSingleSelectValue",
|
|
60
|
+
optionId: "STATUS-0",
|
|
61
|
+
name: "Queued",
|
|
62
|
+
field: { id: "STATUS-FIELD", name: "Flow" }
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const request = async (route, input) => {
|
|
66
|
+
record(route, input);
|
|
67
|
+
if (route === "GET /orgs/{org}/issue-fields")
|
|
68
|
+
return {
|
|
69
|
+
data: [
|
|
70
|
+
{ id: 101, name: "Estimate", data_type: "single_select" },
|
|
71
|
+
{ id: 102, name: "Urgency", data_type: "single_select" }
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
if (route === "GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values")
|
|
75
|
+
return {
|
|
76
|
+
data: [
|
|
77
|
+
{
|
|
78
|
+
issue_field_id: 101,
|
|
79
|
+
issue_field_name: "Estimate",
|
|
80
|
+
data_type: "single_select",
|
|
81
|
+
value: "2",
|
|
82
|
+
single_select_option: { name: "2" }
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
issue_field_id: 102,
|
|
86
|
+
issue_field_name: "Urgency",
|
|
87
|
+
data_type: "single_select",
|
|
88
|
+
value: "High",
|
|
89
|
+
single_select_option: { name: "High" }
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
};
|
|
93
|
+
if (route === "GET /repos/{owner}/{repo}/rules/branches/{branch}") return { data: [] };
|
|
94
|
+
if (route === "GET /repos/{owner}/{repo}/branches/{branch}/protection")
|
|
95
|
+
return { data: { required_pull_request_reviews: { required_approving_review_count: 1 } } };
|
|
96
|
+
throw new Error(`Unexpected fictional REST operation: ${route}`);
|
|
97
|
+
};
|
|
98
|
+
const listSubIssues = async (input) => {
|
|
99
|
+
record("issues.listSubIssues", input);
|
|
100
|
+
return { data: children };
|
|
101
|
+
};
|
|
102
|
+
const listPulls = async (input) => {
|
|
103
|
+
record("pulls.list", input);
|
|
104
|
+
return { data: [pr] };
|
|
105
|
+
};
|
|
106
|
+
const rest = {
|
|
107
|
+
request,
|
|
108
|
+
issues: {
|
|
109
|
+
get: async (input) => {
|
|
110
|
+
record("issues.get", input);
|
|
111
|
+
return { data: issue };
|
|
112
|
+
},
|
|
113
|
+
listSubIssues
|
|
114
|
+
},
|
|
115
|
+
pulls: {
|
|
116
|
+
get: async (input) => {
|
|
117
|
+
record("pulls.get", input);
|
|
118
|
+
return { data: pr };
|
|
119
|
+
},
|
|
120
|
+
list: listPulls
|
|
121
|
+
},
|
|
122
|
+
repos: {
|
|
123
|
+
get: async (input) => {
|
|
124
|
+
record("repos.get", input);
|
|
125
|
+
return { data: { full_name: "example/widget", default_branch: "main" } };
|
|
126
|
+
},
|
|
127
|
+
getCombinedStatusForRef: async (input) => {
|
|
128
|
+
record("repos.getCombinedStatusForRef", input);
|
|
129
|
+
return { data: { state: "success" } };
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
checks: {
|
|
133
|
+
listForRef: async (input) => {
|
|
134
|
+
record("checks.listForRef", input);
|
|
135
|
+
return { data: { check_runs: [{ name: "checks", status: "completed", conclusion: "success" }] } };
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
paginate: async (method, input) => {
|
|
139
|
+
assert.ok(method === listSubIssues || method === listPulls, "Only selected read-only pagination is admitted");
|
|
140
|
+
return (await method(input)).data;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const graphql = async (query, input = {}) => {
|
|
144
|
+
record(query.match(/(?:query|mutation)\s+(\w+)/u)?.[1] ?? "relationships", input);
|
|
145
|
+
if (query.includes("ProjectDeliveryIssueItems"))
|
|
146
|
+
return issueProjectItemsResponse(
|
|
147
|
+
input,
|
|
148
|
+
[
|
|
149
|
+
item,
|
|
150
|
+
...children.map((child) => ({
|
|
151
|
+
...item,
|
|
152
|
+
id: `ITEM${child.number}`,
|
|
153
|
+
content: { __typename: "Issue", id: child.node_id },
|
|
154
|
+
fieldValueByName: {
|
|
155
|
+
...item.fieldValueByName,
|
|
156
|
+
optionId: child.number === 18 ? "STATUS-3" : "STATUS-1",
|
|
157
|
+
name: child.number === 18 ? "Shipped" : "Active"
|
|
158
|
+
}
|
|
159
|
+
}))
|
|
160
|
+
].filter((row) => row.content.id === input.issueNodeId),
|
|
161
|
+
{ id: "PROJECT-1", number: 1 }
|
|
162
|
+
);
|
|
163
|
+
if (query.includes("blockedBy(first:"))
|
|
164
|
+
return {
|
|
165
|
+
repository: {
|
|
166
|
+
issue: {
|
|
167
|
+
parent: { id: "ISSUE11", number: 11, repository: { nameWithOwner: "example/widget" } },
|
|
168
|
+
blockedBy: page([
|
|
169
|
+
{
|
|
170
|
+
id: "ISSUE13",
|
|
171
|
+
number: 13,
|
|
172
|
+
state: "OPEN",
|
|
173
|
+
title: "Fictional prerequisite",
|
|
174
|
+
repository: { nameWithOwner: "example/widget" }
|
|
175
|
+
}
|
|
176
|
+
])
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
if (query.includes("DeliveryReviewDecision"))
|
|
181
|
+
return { repository: { pullRequest: { headRefOid: head, reviewDecision: "APPROVED" } } };
|
|
182
|
+
return syntheticDiscoveryClients().graphql(query, input);
|
|
183
|
+
};
|
|
184
|
+
const create = async (input) => {
|
|
185
|
+
assert.equal(input.identity, input.role);
|
|
186
|
+
record("createDeliveryGitHubClients", { role: input.role, identity: input.identity });
|
|
187
|
+
return {
|
|
188
|
+
role: input.role,
|
|
189
|
+
authSource: input.role === "author" ? "personal" : "app",
|
|
190
|
+
credentialSource: "fictional-port",
|
|
191
|
+
effectiveContentsPermission: "write",
|
|
192
|
+
rest,
|
|
193
|
+
graphql,
|
|
194
|
+
authenticatedAuthor: async () => {
|
|
195
|
+
record("authenticatedAuthor");
|
|
196
|
+
return { actorLogin: "operator", credentialIdentity: "user:42" };
|
|
197
|
+
},
|
|
198
|
+
appActorLogin: async () => {
|
|
199
|
+
record("appActorLogin");
|
|
200
|
+
return "reviewer[bot]";
|
|
201
|
+
}
|
|
31
202
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
203
|
+
};
|
|
204
|
+
return { create, calls };
|
|
205
|
+
}
|
|
206
|
+
function freshEntrypointFixture(kind) {
|
|
207
|
+
const base = realpathSync(mkdtempSync(join(tmpdir(), "ai-delivery-entrypoint-")));
|
|
208
|
+
const identity = lstatSync(base);
|
|
209
|
+
try {
|
|
210
|
+
const root = join(base, "consumer"), home = join(base, "home"), temp = join(base, "tmp");
|
|
211
|
+
for (const path of [root, home, temp]) mkdirSync(path, { mode: 448 });
|
|
212
|
+
const sentinel = join(base, "policy-executed");
|
|
213
|
+
const payload = (marker) => `import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},JSON.stringify({marker:${JSON.stringify(marker)},module:import.meta.url}),{flag:'wx'});export const deliverySettings={};
|
|
214
|
+
`;
|
|
215
|
+
const tracked = payload("tracked"), edited = payload("edited");
|
|
216
|
+
const selected = kind === "tracked" ? tracked : edited;
|
|
217
|
+
const userPath = join(base, "user.json");
|
|
218
|
+
writeFileSync(
|
|
219
|
+
userPath,
|
|
220
|
+
JSON.stringify({
|
|
221
|
+
schemaVersion: "ai-delivery.user@1",
|
|
222
|
+
roles: {
|
|
223
|
+
author: { authSource: "personal", identity: "author", credentialEnv: { token: "FICTIONAL_AUTHOR_TOKEN" } },
|
|
224
|
+
reviewer: {
|
|
225
|
+
identity: "reviewer",
|
|
226
|
+
credentialEnv: {
|
|
227
|
+
appId: "FICTIONAL_REVIEW_APP",
|
|
228
|
+
installationId: "FICTIONAL_REVIEW_INSTALL",
|
|
229
|
+
privateKeyPath: "FICTIONAL_REVIEW_KEY"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
42
232
|
},
|
|
233
|
+
checkoutRoots: [base],
|
|
234
|
+
project: 1,
|
|
235
|
+
pointsField: "Estimate",
|
|
236
|
+
priorityField: "Urgency",
|
|
237
|
+
statusField: "Flow",
|
|
238
|
+
statuses: { blocked: "Waiting", done: "Shipped", inProgress: "Active", todo: "Queued" },
|
|
239
|
+
issueTypes: ["Task"]
|
|
240
|
+
}),
|
|
241
|
+
{ mode: 384 }
|
|
242
|
+
);
|
|
243
|
+
const env = {
|
|
244
|
+
PATH: `${dirname(process.execPath)}:/usr/bin:/bin`,
|
|
245
|
+
HOME: home,
|
|
246
|
+
TMPDIR: temp,
|
|
247
|
+
AI_DELIVERY_CONFIG: userPath,
|
|
248
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
249
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
250
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
251
|
+
GIT_AUTHOR_NAME: "Fictional Operator",
|
|
252
|
+
GIT_AUTHOR_EMAIL: "operator@example.invalid",
|
|
253
|
+
GIT_COMMITTER_NAME: "Fictional Operator",
|
|
254
|
+
GIT_COMMITTER_EMAIL: "operator@example.invalid"
|
|
43
255
|
};
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
256
|
+
const git = (...args) => execFileSync(
|
|
257
|
+
"git",
|
|
258
|
+
[
|
|
259
|
+
"-c",
|
|
260
|
+
"core.hooksPath=/dev/null",
|
|
261
|
+
"-c",
|
|
262
|
+
"core.fsmonitor=false",
|
|
263
|
+
"-c",
|
|
264
|
+
"credential.helper=",
|
|
265
|
+
"-C",
|
|
266
|
+
root,
|
|
267
|
+
...args
|
|
268
|
+
],
|
|
269
|
+
{ env, encoding: "utf8", timeout: 5e3, maxBuffer: 64 * 1024, stdio: ["ignore", "pipe", "pipe"] }
|
|
270
|
+
).trim();
|
|
271
|
+
const policy = join(root, "ai-delivery.policy.mjs");
|
|
272
|
+
writeFileSync(policy, tracked);
|
|
273
|
+
git("init", "-q", "-b", "main");
|
|
274
|
+
git("remote", "add", "origin", "https://github.com/example/widget.git");
|
|
275
|
+
git("add", ".");
|
|
276
|
+
git("commit", "-qm", "Fictional consumer policy");
|
|
277
|
+
const head = git("rev-parse", "HEAD");
|
|
278
|
+
if (kind === "edited") writeFileSync(policy, edited);
|
|
279
|
+
assert.equal(git("show", "HEAD:ai-delivery.policy.mjs"), tracked.trim());
|
|
280
|
+
assert.equal(git("show", ":ai-delivery.policy.mjs"), tracked.trim());
|
|
281
|
+
assert.equal(readFileSync(policy, "utf8"), selected);
|
|
282
|
+
assert.equal(git("status", "--porcelain"), kind === "edited" ? "M ai-delivery.policy.mjs" : "");
|
|
283
|
+
const assertInert = () => assert.equal(existsSync(sentinel), false, "Consumer policy was executed by a public entrypoint");
|
|
284
|
+
const assertBound = () => {
|
|
285
|
+
assert.equal(git("rev-parse", "HEAD"), head);
|
|
286
|
+
assert.equal(git("show", "HEAD:ai-delivery.policy.mjs"), tracked.trim());
|
|
287
|
+
assert.equal(git("show", ":ai-delivery.policy.mjs"), tracked.trim());
|
|
288
|
+
assert.equal(readFileSync(policy, "utf8"), selected);
|
|
77
289
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
290
|
+
const cleanup = () => {
|
|
291
|
+
const current = lstatSync(base);
|
|
292
|
+
assert.equal(realpathSync(base), base);
|
|
293
|
+
assert.equal(current.isSymbolicLink(), false);
|
|
294
|
+
assert.equal(current.dev, identity.dev);
|
|
295
|
+
assert.equal(current.ino, identity.ino);
|
|
296
|
+
rmSync(base, { recursive: true });
|
|
297
|
+
assert.equal(existsSync(base), false);
|
|
81
298
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
299
|
+
return {
|
|
300
|
+
base,
|
|
301
|
+
root,
|
|
302
|
+
home,
|
|
303
|
+
head,
|
|
304
|
+
env,
|
|
305
|
+
sentinel,
|
|
306
|
+
policy,
|
|
307
|
+
tracked,
|
|
308
|
+
selected,
|
|
309
|
+
assertInert,
|
|
310
|
+
assertBound,
|
|
311
|
+
cleanup,
|
|
312
|
+
payloadSha256: digestBytes(Buffer.from(selected)),
|
|
313
|
+
indexedSha256: digestBytes(Buffer.from(tracked))
|
|
85
314
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
pulls: {
|
|
96
|
-
get: async (input) => {
|
|
97
|
-
record('pulls.get', input);
|
|
98
|
-
return { data: pr };
|
|
99
|
-
},
|
|
100
|
-
list: listPulls,
|
|
101
|
-
},
|
|
102
|
-
repos: {
|
|
103
|
-
get: async (input) => {
|
|
104
|
-
record('repos.get', input);
|
|
105
|
-
return { data: { full_name: 'example/widget', default_branch: 'main' } };
|
|
106
|
-
},
|
|
107
|
-
getCombinedStatusForRef: async (input) => {
|
|
108
|
-
record('repos.getCombinedStatusForRef', input);
|
|
109
|
-
return { data: { state: 'success' } };
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
checks: {
|
|
113
|
-
listForRef: async (input) => {
|
|
114
|
-
record('checks.listForRef', input);
|
|
115
|
-
return { data: { check_runs: [{ name: 'checks', status: 'completed', conclusion: 'success' }] } };
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
paginate: async (method, input) => {
|
|
119
|
-
assert.ok(method === listSubIssues || method === listPulls, 'Only selected read-only pagination is admitted');
|
|
120
|
-
return (await method(input)).data;
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
const graphql = async (query, input = {}) => {
|
|
124
|
-
record(query.match(/(?:query|mutation)\s+(\w+)/u)?.[1] ?? 'relationships', input);
|
|
125
|
-
if (query.includes('ProjectDeliveryItems'))
|
|
126
|
-
return { organization: { projectV2: { id: 'PROJECT-1', items: page([item]) } } };
|
|
127
|
-
if (query.includes('blockedBy(first:'))
|
|
128
|
-
return {
|
|
129
|
-
repository: {
|
|
130
|
-
issue: {
|
|
131
|
-
parent: { id: 'ISSUE11', number: 11, repository: { nameWithOwner: 'example/widget' } },
|
|
132
|
-
blockedBy: page([
|
|
133
|
-
{
|
|
134
|
-
id: 'ISSUE13',
|
|
135
|
-
number: 13,
|
|
136
|
-
state: 'OPEN',
|
|
137
|
-
title: 'Fictional prerequisite',
|
|
138
|
-
repository: { nameWithOwner: 'example/widget' },
|
|
139
|
-
},
|
|
140
|
-
]),
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
if (query.includes('DeliveryReviewDecision'))
|
|
145
|
-
return { repository: { pullRequest: { headRefOid: head, reviewDecision: 'APPROVED' } } };
|
|
146
|
-
return syntheticDiscoveryClients().graphql(query, input);
|
|
147
|
-
};
|
|
148
|
-
const create = async (input) => {
|
|
149
|
-
assert.equal(input.identity, input.role);
|
|
150
|
-
record('createDeliveryGitHubClients', { role: input.role, identity: input.identity });
|
|
151
|
-
return {
|
|
152
|
-
role: input.role,
|
|
153
|
-
authSource: input.role === 'author' ? 'personal' : 'app',
|
|
154
|
-
credentialSource: 'fictional-port',
|
|
155
|
-
effectiveContentsPermission: 'write',
|
|
156
|
-
rest,
|
|
157
|
-
graphql,
|
|
158
|
-
authenticatedAuthor: async () => {
|
|
159
|
-
record('authenticatedAuthor');
|
|
160
|
-
return { actorLogin: 'operator', credentialIdentity: 'user:42' };
|
|
161
|
-
},
|
|
162
|
-
appActorLogin: async () => {
|
|
163
|
-
record('appActorLogin');
|
|
164
|
-
return 'reviewer[bot]';
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
return { create, calls };
|
|
169
|
-
}
|
|
170
|
-
/** No inherited authentication environment, host home or consumer executables. */
|
|
171
|
-
export function freshEntrypointFixture(kind) {
|
|
172
|
-
const base = realpathSync(mkdtempSync(join(tmpdir(), 'ai-delivery-entrypoint-')));
|
|
173
|
-
const identity = lstatSync(base);
|
|
174
|
-
try {
|
|
175
|
-
const root = join(base, 'consumer'), home = join(base, 'home'), temp = join(base, 'tmp');
|
|
176
|
-
for (const path of [root, home, temp])
|
|
177
|
-
mkdirSync(path, { mode: 0o700 });
|
|
178
|
-
const sentinel = join(base, 'policy-executed');
|
|
179
|
-
const payload = (marker) => `import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},JSON.stringify({marker:${JSON.stringify(marker)},module:import.meta.url}),{flag:'wx'});export const deliverySettings={};\n`;
|
|
180
|
-
const tracked = payload('tracked'), edited = payload('edited');
|
|
181
|
-
const selected = kind === 'tracked' ? tracked : edited;
|
|
182
|
-
const userPath = join(base, 'user.json');
|
|
183
|
-
writeFileSync(userPath, JSON.stringify({
|
|
184
|
-
schemaVersion: 'ai-delivery.user@1',
|
|
185
|
-
roles: {
|
|
186
|
-
author: { authSource: 'personal', identity: 'author', credentialEnv: { token: 'FICTIONAL_AUTHOR_TOKEN' } },
|
|
187
|
-
reviewer: {
|
|
188
|
-
identity: 'reviewer',
|
|
189
|
-
credentialEnv: {
|
|
190
|
-
appId: 'FICTIONAL_REVIEW_APP',
|
|
191
|
-
installationId: 'FICTIONAL_REVIEW_INSTALL',
|
|
192
|
-
privateKeyPath: 'FICTIONAL_REVIEW_KEY',
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
checkoutRoots: [base],
|
|
197
|
-
project: 1,
|
|
198
|
-
pointsField: 'Estimate',
|
|
199
|
-
priorityField: 'Urgency',
|
|
200
|
-
statusField: 'Flow',
|
|
201
|
-
statuses: { blocked: 'Waiting', done: 'Shipped', inProgress: 'Active', todo: 'Queued' },
|
|
202
|
-
issueTypes: ['Task'],
|
|
203
|
-
}), { mode: 0o600 });
|
|
204
|
-
const env = {
|
|
205
|
-
PATH: `${dirname(process.execPath)}:/usr/bin:/bin`,
|
|
206
|
-
HOME: home,
|
|
207
|
-
TMPDIR: temp,
|
|
208
|
-
AI_DELIVERY_CONFIG: userPath,
|
|
209
|
-
GIT_CONFIG_NOSYSTEM: '1',
|
|
210
|
-
GIT_CONFIG_GLOBAL: '/dev/null',
|
|
211
|
-
GIT_TERMINAL_PROMPT: '0',
|
|
212
|
-
GIT_AUTHOR_NAME: 'Fictional Operator',
|
|
213
|
-
GIT_AUTHOR_EMAIL: 'operator@example.invalid',
|
|
214
|
-
GIT_COMMITTER_NAME: 'Fictional Operator',
|
|
215
|
-
GIT_COMMITTER_EMAIL: 'operator@example.invalid',
|
|
216
|
-
};
|
|
217
|
-
const git = (...args) => execFileSync('git', [
|
|
218
|
-
'-c',
|
|
219
|
-
'core.hooksPath=/dev/null',
|
|
220
|
-
'-c',
|
|
221
|
-
'core.fsmonitor=false',
|
|
222
|
-
'-c',
|
|
223
|
-
'credential.helper=',
|
|
224
|
-
'-C',
|
|
225
|
-
root,
|
|
226
|
-
...args,
|
|
227
|
-
], { env, encoding: 'utf8', timeout: 5_000, maxBuffer: 64 * 1024, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
228
|
-
const policy = join(root, 'ai-delivery.policy.mjs');
|
|
229
|
-
writeFileSync(policy, tracked);
|
|
230
|
-
git('init', '-q', '-b', 'main');
|
|
231
|
-
git('remote', 'add', 'origin', 'https://github.com/example/widget.git');
|
|
232
|
-
git('add', '.');
|
|
233
|
-
git('commit', '-qm', 'Fictional consumer policy');
|
|
234
|
-
const head = git('rev-parse', 'HEAD');
|
|
235
|
-
if (kind === 'edited')
|
|
236
|
-
writeFileSync(policy, edited);
|
|
237
|
-
assert.equal(git('show', 'HEAD:ai-delivery.policy.mjs'), tracked.trim());
|
|
238
|
-
assert.equal(git('show', ':ai-delivery.policy.mjs'), tracked.trim());
|
|
239
|
-
assert.equal(readFileSync(policy, 'utf8'), selected);
|
|
240
|
-
assert.equal(git('status', '--porcelain'), kind === 'edited' ? 'M ai-delivery.policy.mjs' : '');
|
|
241
|
-
const assertInert = () => assert.equal(existsSync(sentinel), false, 'Consumer policy was executed by a public entrypoint');
|
|
242
|
-
const assertBound = () => {
|
|
243
|
-
assert.equal(git('rev-parse', 'HEAD'), head);
|
|
244
|
-
assert.equal(git('show', 'HEAD:ai-delivery.policy.mjs'), tracked.trim());
|
|
245
|
-
assert.equal(git('show', ':ai-delivery.policy.mjs'), tracked.trim());
|
|
246
|
-
assert.equal(readFileSync(policy, 'utf8'), selected);
|
|
247
|
-
};
|
|
248
|
-
const cleanup = () => {
|
|
249
|
-
const current = lstatSync(base);
|
|
250
|
-
assert.equal(realpathSync(base), base);
|
|
251
|
-
assert.equal(current.isSymbolicLink(), false);
|
|
252
|
-
assert.equal(current.dev, identity.dev);
|
|
253
|
-
assert.equal(current.ino, identity.ino);
|
|
254
|
-
rmSync(base, { recursive: true });
|
|
255
|
-
assert.equal(existsSync(base), false);
|
|
256
|
-
};
|
|
257
|
-
return {
|
|
258
|
-
base,
|
|
259
|
-
root,
|
|
260
|
-
home,
|
|
261
|
-
head,
|
|
262
|
-
env,
|
|
263
|
-
sentinel,
|
|
264
|
-
policy,
|
|
265
|
-
tracked,
|
|
266
|
-
selected,
|
|
267
|
-
assertInert,
|
|
268
|
-
assertBound,
|
|
269
|
-
cleanup,
|
|
270
|
-
payloadSha256: digestBytes(Buffer.from(selected)),
|
|
271
|
-
indexedSha256: digestBytes(Buffer.from(tracked)),
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
const current = lstatSync(base);
|
|
276
|
-
assert.equal(current.dev, identity.dev);
|
|
277
|
-
assert.equal(current.ino, identity.ino);
|
|
278
|
-
assert.equal(current.isSymbolicLink(), false);
|
|
279
|
-
rmSync(base, { recursive: true });
|
|
280
|
-
throw error;
|
|
281
|
-
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
const current = lstatSync(base);
|
|
317
|
+
assert.equal(current.dev, identity.dev);
|
|
318
|
+
assert.equal(current.ino, identity.ino);
|
|
319
|
+
assert.equal(current.isSymbolicLink(), false);
|
|
320
|
+
rmSync(base, { recursive: true });
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
282
323
|
}
|
|
283
|
-
|
|
324
|
+
export {
|
|
325
|
+
entrypointClients,
|
|
326
|
+
freshEntrypointFixture
|
|
327
|
+
};
|
|
328
|
+
//# sourceMappingURL=inertEntrypoints.js.map
|