@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,277 +1,300 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from
|
|
3
|
-
import { tmpdir } from
|
|
4
|
-
import { join } from
|
|
5
|
-
import { afterEach, beforeEach, describe, it, vi } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { afterEach, beforeEach, describe, it, vi } from "vitest";
|
|
6
|
+
import {
|
|
7
|
+
loadDeliveryConfig,
|
|
8
|
+
loadDeliverySettings,
|
|
9
|
+
resolveDeliveryRoleCredentials
|
|
10
|
+
} from "./config/deliveryConfig.js";
|
|
11
|
+
import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from "./fixtures/discovery.js";
|
|
12
|
+
import { createDeliveryGitHubClients, withAuthorGitToken } from "./github/client.js";
|
|
11
13
|
function settings(root) {
|
|
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
|
-
|
|
14
|
+
return {
|
|
15
|
+
schemaVersion: "ai-delivery.user@1",
|
|
16
|
+
roles: {
|
|
17
|
+
author: {
|
|
18
|
+
authSource: "personal",
|
|
19
|
+
identity: "fixture-author",
|
|
20
|
+
credentialEnv: { token: "DELIVERY_AUTHOR_TOKEN" }
|
|
21
|
+
},
|
|
22
|
+
reviewer: {
|
|
23
|
+
identity: "fixture-reviewer",
|
|
24
|
+
credentialEnv: {
|
|
25
|
+
appId: "DELIVERY_REVIEWER_APP_ID",
|
|
26
|
+
installationId: "DELIVERY_REVIEWER_INSTALLATION_ID",
|
|
27
|
+
privateKeyPath: "DELIVERY_REVIEWER_KEY_PATH"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
project: syntheticDiscoveryConfig.native.project.number,
|
|
32
|
+
checkoutRoots: [join(root, "clones")],
|
|
33
|
+
pointsField: syntheticDiscoveryConfig.native.points.name,
|
|
34
|
+
priorityField: syntheticDiscoveryConfig.native.priority.name,
|
|
35
|
+
statusField: syntheticDiscoveryConfig.native.project.statusField,
|
|
36
|
+
statuses: syntheticDiscoveryConfig.native.project.statuses,
|
|
37
|
+
issueTypes: syntheticDiscoveryConfig.native.issueTypes
|
|
38
|
+
};
|
|
37
39
|
}
|
|
38
|
-
let home =
|
|
39
|
-
let configPath =
|
|
40
|
+
let home = "";
|
|
41
|
+
let configPath = "";
|
|
40
42
|
beforeEach(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
writeFileSync(configPath, JSON.stringify(settings(home)));
|
|
43
|
+
home = mkdtempSync(join(tmpdir(), "ai-delivery-credential-contract-"));
|
|
44
|
+
configPath = join(home, "operator-settings.json");
|
|
45
|
+
vi.stubEnv("AI_DELIVERY_CONFIG", configPath);
|
|
46
|
+
vi.stubGlobal("fetch", async () => {
|
|
47
|
+
throw new Error("Unexpected network request in a synthetic credential fixture.");
|
|
48
|
+
});
|
|
49
|
+
writeFileSync(configPath, JSON.stringify(settings(home)));
|
|
50
50
|
});
|
|
51
51
|
afterEach(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
vi.unstubAllEnvs();
|
|
53
|
+
vi.unstubAllGlobals();
|
|
54
|
+
rmSync(home, { recursive: true, force: true });
|
|
55
55
|
});
|
|
56
|
-
describe(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
it('valid settings alone do not establish that the named credentials are available', async () => {
|
|
90
|
-
const loaded = await loadDeliverySettings();
|
|
91
|
-
await assert.rejects(createDeliveryGitHubClients({
|
|
92
|
-
config: loaded,
|
|
93
|
-
identity: loaded.roles.author.identity,
|
|
94
|
-
role: 'author',
|
|
95
|
-
env: {},
|
|
96
|
-
}), /Missing personal author token in DELIVERY_AUTHOR_TOKEN/u);
|
|
97
|
-
});
|
|
98
|
-
it('ignores unrelated tokens and reports the selected missing name without their values', async () => {
|
|
99
|
-
const loaded = await loadDeliverySettings();
|
|
100
|
-
const sentinel = 'fictional-unrelated-value-not-a-credential';
|
|
101
|
-
await assert.rejects(createDeliveryGitHubClients({
|
|
102
|
-
config: loaded,
|
|
103
|
-
identity: loaded.roles.author.identity,
|
|
104
|
-
role: 'author',
|
|
105
|
-
env: { GH_TOKEN: sentinel, GITHUB_TOKEN: sentinel, UNRELATED_SERVICE_TOKEN: sentinel },
|
|
106
|
-
}), (error) => {
|
|
107
|
-
assert.ok(error instanceof Error);
|
|
108
|
-
assert.match(error.message, /DELIVERY_AUTHOR_TOKEN/u);
|
|
109
|
-
assert.ok(!error.message.includes(sentinel));
|
|
110
|
-
assert.ok(!error.message.includes('UNRELATED_SERVICE_TOKEN'));
|
|
111
|
-
return true;
|
|
56
|
+
describe("synthetic native-plugin credential contract", () => {
|
|
57
|
+
it("an absent conventional reference selects machine-session resolution without accepting ambient legacy credentials", async () => {
|
|
58
|
+
const fixture = settings(home);
|
|
59
|
+
fixture.roles.author = { authSource: "personal", identity: "fixture-author", credentialEnv: { token: "GH_TOKEN" } };
|
|
60
|
+
writeFileSync(configPath, JSON.stringify(fixture));
|
|
61
|
+
const loaded = await loadDeliverySettings();
|
|
62
|
+
await assert.rejects(
|
|
63
|
+
createDeliveryGitHubClients({
|
|
64
|
+
config: loaded,
|
|
65
|
+
identity: "fixture-author",
|
|
66
|
+
role: "author",
|
|
67
|
+
env: { HOME: home, PATH: join(home, "missing-cli"), GITHUB_TOKEN: "fictional_legacy_token" }
|
|
68
|
+
}),
|
|
69
|
+
/gh is unavailable on this process PATH/u
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
it.each(["codex", "claude-code"])(
|
|
73
|
+
"%s fixture uses one operator configuration outside Git and across repositories",
|
|
74
|
+
async (host) => {
|
|
75
|
+
const outsideGit = join(home, host, "outside-git");
|
|
76
|
+
mkdirSync(outsideGit, { recursive: true });
|
|
77
|
+
writeFileSync(join(outsideGit, "ai-delivery.config.json"), '{"roles":"untrusted fixture"}');
|
|
78
|
+
const loaded = await loadDeliverySettings(outsideGit);
|
|
79
|
+
assert.equal(loaded.configPath, configPath);
|
|
80
|
+
assert.equal(loaded.roles.author.identity, "fixture-author");
|
|
81
|
+
assert.equal(loaded.roles.reviewer.identity, "fixture-reviewer");
|
|
82
|
+
for (const repository of ["example/widget", "example/service", "example/widget"]) {
|
|
83
|
+
const fixture = { ...syntheticDiscoveryConfig, repository };
|
|
84
|
+
const resolved = await loadDeliveryConfig(outsideGit, {
|
|
85
|
+
repository,
|
|
86
|
+
clients: syntheticDiscoveryClients(fixture)
|
|
112
87
|
});
|
|
88
|
+
assert.equal(resolved.config.repository, repository);
|
|
89
|
+
assert.deepEqual(resolved.config.roles, loaded.roles);
|
|
90
|
+
assert.equal(resolved.configPath, configPath);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
it("valid settings alone do not establish that the named credentials are available", async () => {
|
|
95
|
+
const loaded = await loadDeliverySettings();
|
|
96
|
+
await assert.rejects(
|
|
97
|
+
createDeliveryGitHubClients({
|
|
98
|
+
config: loaded,
|
|
99
|
+
identity: loaded.roles.author.identity,
|
|
100
|
+
role: "author",
|
|
101
|
+
env: {}
|
|
102
|
+
}),
|
|
103
|
+
/Missing personal author token in DELIVERY_AUTHOR_TOKEN/u
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
it("ignores unrelated tokens and reports the selected missing name without their values", async () => {
|
|
107
|
+
const loaded = await loadDeliverySettings();
|
|
108
|
+
const sentinel = "fictional-unrelated-value-not-a-credential";
|
|
109
|
+
await assert.rejects(
|
|
110
|
+
createDeliveryGitHubClients({
|
|
111
|
+
config: loaded,
|
|
112
|
+
identity: loaded.roles.author.identity,
|
|
113
|
+
role: "author",
|
|
114
|
+
env: { GH_TOKEN: sentinel, GITHUB_TOKEN: sentinel, UNRELATED_SERVICE_TOKEN: sentinel }
|
|
115
|
+
}),
|
|
116
|
+
(error) => {
|
|
117
|
+
assert.ok(error instanceof Error);
|
|
118
|
+
assert.match(error.message, /DELIVERY_AUTHOR_TOKEN/u);
|
|
119
|
+
assert.ok(!error.message.includes(sentinel));
|
|
120
|
+
assert.ok(!error.message.includes("UNRELATED_SERVICE_TOKEN"));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
it("selects a supplied fictional author token without treating selection as authenticated readback", async () => {
|
|
126
|
+
const loaded = await loadDeliverySettings();
|
|
127
|
+
const token = "fictional-selected-author-value";
|
|
128
|
+
const author = await createDeliveryGitHubClients({
|
|
129
|
+
config: loaded,
|
|
130
|
+
identity: loaded.roles.author.identity,
|
|
131
|
+
role: "author",
|
|
132
|
+
env: { DELIVERY_AUTHOR_TOKEN: token, GH_TOKEN: "fictional-unselected-value" }
|
|
113
133
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
assert.equal(author.role, "author");
|
|
135
|
+
assert.equal(author.authSource, "personal");
|
|
136
|
+
assert.equal(author.credentialSource, "env:DELIVERY_AUTHOR_TOKEN");
|
|
137
|
+
assert.equal(await withAuthorGitToken(author, (selected) => selected === token), true);
|
|
138
|
+
assert.equal(loaded.roles.reviewer.identity, "fixture-reviewer");
|
|
139
|
+
});
|
|
140
|
+
it("requires a separate identity readback and uses only a GET in the simulated author probe", async () => {
|
|
141
|
+
const requests = [];
|
|
142
|
+
vi.stubGlobal("fetch", async (input, init) => {
|
|
143
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
144
|
+
assert.equal(url, "https://api.github.com/user");
|
|
145
|
+
assert.equal(init?.method ?? "GET", "GET");
|
|
146
|
+
requests.push(url);
|
|
147
|
+
return new Response(JSON.stringify({ id: 42, login: "fixture-authenticated-author" }), {
|
|
148
|
+
status: 200,
|
|
149
|
+
headers: { "content-type": "application/json" }
|
|
150
|
+
});
|
|
129
151
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
requests.push(url);
|
|
137
|
-
return new Response(JSON.stringify({ id: 42, login: 'fixture-authenticated-author' }), {
|
|
138
|
-
status: 200,
|
|
139
|
-
headers: { 'content-type': 'application/json' },
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
const loaded = await loadDeliverySettings();
|
|
143
|
-
const author = await createDeliveryGitHubClients({
|
|
144
|
-
config: loaded,
|
|
145
|
-
identity: loaded.roles.author.identity,
|
|
146
|
-
role: 'author',
|
|
147
|
-
env: { DELIVERY_AUTHOR_TOKEN: 'fictional-author-value' },
|
|
148
|
-
});
|
|
149
|
-
assert.deepEqual(requests, []);
|
|
150
|
-
assert.ok(author.authenticatedAuthor);
|
|
151
|
-
assert.deepEqual(await author.authenticatedAuthor(), {
|
|
152
|
-
actorLogin: 'fixture-authenticated-author',
|
|
153
|
-
credentialIdentity: 'user:42',
|
|
154
|
-
});
|
|
155
|
-
assert.deepEqual(requests, ['https://api.github.com/user']);
|
|
152
|
+
const loaded = await loadDeliverySettings();
|
|
153
|
+
const author = await createDeliveryGitHubClients({
|
|
154
|
+
config: loaded,
|
|
155
|
+
identity: loaded.roles.author.identity,
|
|
156
|
+
role: "author",
|
|
157
|
+
env: { DELIVERY_AUTHOR_TOKEN: "fictional-author-value" }
|
|
156
158
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
assert.equal(init?.method ?? 'GET', 'GET');
|
|
163
|
-
return new Response(JSON.stringify({ message: sentinel }), {
|
|
164
|
-
status: 401,
|
|
165
|
-
headers: { 'content-type': 'application/json', 'x-fictional-credential': sentinel },
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
const loaded = await loadDeliverySettings();
|
|
169
|
-
const author = await createDeliveryGitHubClients({
|
|
170
|
-
config: loaded,
|
|
171
|
-
identity: loaded.roles.author.identity,
|
|
172
|
-
role: 'author',
|
|
173
|
-
env: { DELIVERY_AUTHOR_TOKEN: sentinel },
|
|
174
|
-
});
|
|
175
|
-
assert.ok(author.authenticatedAuthor);
|
|
176
|
-
await assert.rejects(author.authenticatedAuthor(), (error) => {
|
|
177
|
-
assert.ok(error instanceof Error);
|
|
178
|
-
assert.match(error.message, /Configured personal author token is invalid or expired/u);
|
|
179
|
-
assert.ok(!error.message.includes(sentinel));
|
|
180
|
-
return true;
|
|
181
|
-
});
|
|
159
|
+
assert.deepEqual(requests, []);
|
|
160
|
+
assert.ok(author.authenticatedAuthor);
|
|
161
|
+
assert.deepEqual(await author.authenticatedAuthor(), {
|
|
162
|
+
actorLogin: "fixture-authenticated-author",
|
|
163
|
+
credentialIdentity: "user:42"
|
|
182
164
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
165
|
+
assert.deepEqual(requests, ["https://api.github.com/user"]);
|
|
166
|
+
});
|
|
167
|
+
it("redacts a simulated authentication failure even when the upstream body contains fictional credential values", async () => {
|
|
168
|
+
const sentinel = "fictional-value-in-upstream-error";
|
|
169
|
+
vi.stubGlobal("fetch", async (input, init) => {
|
|
170
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
171
|
+
assert.equal(url, "https://api.github.com/user");
|
|
172
|
+
assert.equal(init?.method ?? "GET", "GET");
|
|
173
|
+
return new Response(JSON.stringify({ message: sentinel }), {
|
|
174
|
+
status: 401,
|
|
175
|
+
headers: { "content-type": "application/json", "x-fictional-credential": sentinel }
|
|
176
|
+
});
|
|
191
177
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
identity: 'fixture-app-author',
|
|
199
|
-
credentialEnv: {
|
|
200
|
-
appId: 'DELIVERY_AUTHOR_APP_ID',
|
|
201
|
-
installationId: 'DELIVERY_AUTHOR_INSTALLATION_ID',
|
|
202
|
-
privateKeyPath: 'DELIVERY_AUTHOR_KEY_PATH',
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
const fictionalPath = join(home, 'fictional-shared-key.pem');
|
|
207
|
-
await assert.rejects(createDeliveryGitHubClients({
|
|
208
|
-
config: { roles },
|
|
209
|
-
identity: roles.author.identity,
|
|
210
|
-
role: 'author',
|
|
211
|
-
env: {
|
|
212
|
-
DELIVERY_AUTHOR_APP_ID: '101',
|
|
213
|
-
DELIVERY_AUTHOR_INSTALLATION_ID: '201',
|
|
214
|
-
DELIVERY_AUTHOR_KEY_PATH: fictionalPath,
|
|
215
|
-
DELIVERY_REVIEWER_APP_ID: '102',
|
|
216
|
-
DELIVERY_REVIEWER_INSTALLATION_ID: '202',
|
|
217
|
-
DELIVERY_REVIEWER_KEY_PATH: fictionalPath,
|
|
218
|
-
},
|
|
219
|
-
}), /Author and reviewer must use distinct GitHub App credentials/u);
|
|
178
|
+
const loaded = await loadDeliverySettings();
|
|
179
|
+
const author = await createDeliveryGitHubClients({
|
|
180
|
+
config: loaded,
|
|
181
|
+
identity: loaded.roles.author.identity,
|
|
182
|
+
role: "author",
|
|
183
|
+
env: { DELIVERY_AUTHOR_TOKEN: sentinel }
|
|
220
184
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
env: { DELIVERY_REVIEWER_KEY_PATH: fictionalPath, UNRELATED_SERVICE_TOKEN: 'fictional-unrelated-value' },
|
|
228
|
-
}), (error) => {
|
|
229
|
-
assert.ok(error instanceof Error);
|
|
230
|
-
assert.match(error.message, /DELIVERY_REVIEWER_APP_ID/u);
|
|
231
|
-
assert.match(error.message, /DELIVERY_REVIEWER_INSTALLATION_ID/u);
|
|
232
|
-
assert.ok(!error.message.includes(fictionalPath));
|
|
233
|
-
assert.ok(!error.message.includes('fictional-unrelated-value'));
|
|
234
|
-
return true;
|
|
235
|
-
});
|
|
185
|
+
assert.ok(author.authenticatedAuthor);
|
|
186
|
+
await assert.rejects(author.authenticatedAuthor(), (error) => {
|
|
187
|
+
assert.ok(error instanceof Error);
|
|
188
|
+
assert.match(error.message, /Configured personal author token is invalid or expired/u);
|
|
189
|
+
assert.ok(!error.message.includes(sentinel));
|
|
190
|
+
return true;
|
|
236
191
|
});
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
192
|
+
});
|
|
193
|
+
it("cannot use the configured author identity for the reviewer role", async () => {
|
|
194
|
+
const loaded = await loadDeliverySettings();
|
|
195
|
+
await assert.rejects(
|
|
196
|
+
createDeliveryGitHubClients({
|
|
197
|
+
config: loaded,
|
|
198
|
+
identity: loaded.roles.author.identity,
|
|
199
|
+
role: "reviewer",
|
|
200
|
+
env: { DELIVERY_AUTHOR_TOKEN: "fictional-author-value" }
|
|
201
|
+
}),
|
|
202
|
+
/requires the configured reviewer identity/u
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
it("rejects App credential reuse before reading a key or requesting authentication", async () => {
|
|
206
|
+
const fixture = settings(home);
|
|
207
|
+
const roles = {
|
|
208
|
+
...fixture.roles,
|
|
209
|
+
author: {
|
|
210
|
+
authSource: "app",
|
|
211
|
+
identity: "fixture-app-author",
|
|
212
|
+
credentialEnv: {
|
|
213
|
+
appId: "DELIVERY_AUTHOR_APP_ID",
|
|
214
|
+
installationId: "DELIVERY_AUTHOR_INSTALLATION_ID",
|
|
215
|
+
privateKeyPath: "DELIVERY_AUTHOR_KEY_PATH"
|
|
248
216
|
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const fictionalPath = join(home, "fictional-shared-key.pem");
|
|
220
|
+
await assert.rejects(
|
|
221
|
+
createDeliveryGitHubClients({
|
|
222
|
+
config: { roles },
|
|
223
|
+
identity: roles.author.identity,
|
|
224
|
+
role: "author",
|
|
225
|
+
env: {
|
|
226
|
+
DELIVERY_AUTHOR_APP_ID: "101",
|
|
227
|
+
DELIVERY_AUTHOR_INSTALLATION_ID: "201",
|
|
228
|
+
DELIVERY_AUTHOR_KEY_PATH: fictionalPath,
|
|
229
|
+
DELIVERY_REVIEWER_APP_ID: "102",
|
|
230
|
+
DELIVERY_REVIEWER_INSTALLATION_ID: "202",
|
|
231
|
+
DELIVERY_REVIEWER_KEY_PATH: fictionalPath
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
/Author and reviewer must use distinct GitHub App credentials/u
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
it("reports missing reviewer references without leaking a supplied key path or unrelated values", async () => {
|
|
238
|
+
const loaded = await loadDeliverySettings();
|
|
239
|
+
const fictionalPath = join(home, "fictional-private-key.pem");
|
|
240
|
+
assert.throws(
|
|
241
|
+
() => resolveDeliveryRoleCredentials({
|
|
242
|
+
config: loaded,
|
|
243
|
+
role: "reviewer",
|
|
244
|
+
env: { DELIVERY_REVIEWER_KEY_PATH: fictionalPath, UNRELATED_SERVICE_TOKEN: "fictional-unrelated-value" }
|
|
245
|
+
}),
|
|
246
|
+
(error) => {
|
|
247
|
+
assert.ok(error instanceof Error);
|
|
248
|
+
assert.match(error.message, /DELIVERY_REVIEWER_APP_ID/u);
|
|
249
|
+
assert.match(error.message, /DELIVERY_REVIEWER_INSTALLATION_ID/u);
|
|
250
|
+
assert.ok(!error.message.includes(fictionalPath));
|
|
251
|
+
assert.ok(!error.message.includes("fictional-unrelated-value"));
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
it("rejects author/reviewer identity and reference collisions during settings validation", async () => {
|
|
257
|
+
const fixture = settings(home);
|
|
258
|
+
assert.ok("credentialEnv" in fixture.roles.reviewer);
|
|
259
|
+
for (const reviewer of [
|
|
260
|
+
{ ...fixture.roles.reviewer, identity: fixture.roles.author.identity },
|
|
261
|
+
{
|
|
262
|
+
...fixture.roles.reviewer,
|
|
263
|
+
credentialEnv: { ...fixture.roles.reviewer.credentialEnv, appId: "DELIVERY_AUTHOR_TOKEN" }
|
|
264
|
+
}
|
|
265
|
+
]) {
|
|
266
|
+
writeFileSync(configPath, JSON.stringify({ ...fixture, roles: { ...fixture.roles, reviewer } }));
|
|
267
|
+
await assert.rejects(loadDeliverySettings(), /distinct/u);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
it("rejects malformed JSON without echoing its fictional contents", async () => {
|
|
271
|
+
const sentinel = "fictional-value-inside-malformed-json";
|
|
272
|
+
writeFileSync(configPath, `{"unexpected":"${sentinel}"`);
|
|
273
|
+
await assert.rejects(loadDeliverySettings(), (error) => {
|
|
274
|
+
assert.ok(error instanceof Error);
|
|
275
|
+
assert.match(error.message, /Invalid user configuration JSON/u);
|
|
276
|
+
assert.ok(!error.message.includes(sentinel));
|
|
277
|
+
return true;
|
|
249
278
|
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}));
|
|
267
|
-
await assert.rejects(loadDeliverySettings(), (error) => {
|
|
268
|
-
assert.ok(error instanceof Error);
|
|
269
|
-
assert.match(error.message, /roles.author.credentialEnv.token/u);
|
|
270
|
-
assert.ok(!error.message.includes(sentinel));
|
|
271
|
-
return true;
|
|
272
|
-
});
|
|
273
|
-
writeFileSync(configPath, JSON.stringify({ ...fixture, checkoutRoots: ['relative-clones'] }));
|
|
274
|
-
await assert.rejects(loadDeliverySettings(), /Checkout roots must be absolute/u);
|
|
279
|
+
});
|
|
280
|
+
it("rejects non-reference credential fields and relative checkout roots without echoing values", async () => {
|
|
281
|
+
const fixture = settings(home);
|
|
282
|
+
const sentinel = "fictional_value_not_an_env_name";
|
|
283
|
+
writeFileSync(
|
|
284
|
+
configPath,
|
|
285
|
+
JSON.stringify({
|
|
286
|
+
...fixture,
|
|
287
|
+
roles: { ...fixture.roles, author: { ...fixture.roles.author, credentialEnv: { token: sentinel } } }
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
await assert.rejects(loadDeliverySettings(), (error) => {
|
|
291
|
+
assert.ok(error instanceof Error);
|
|
292
|
+
assert.match(error.message, /roles.author.credentialEnv.token/u);
|
|
293
|
+
assert.ok(!error.message.includes(sentinel));
|
|
294
|
+
return true;
|
|
275
295
|
});
|
|
296
|
+
writeFileSync(configPath, JSON.stringify({ ...fixture, checkoutRoots: ["relative-clones"] }));
|
|
297
|
+
await assert.rejects(loadDeliverySettings(), /Checkout roots must be absolute/u);
|
|
298
|
+
});
|
|
276
299
|
});
|
|
277
|
-
//# sourceMappingURL=pluginCredentials.test.js.map
|
|
300
|
+
//# sourceMappingURL=pluginCredentials.test.js.map
|