@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,645 +1,710 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { createHash, generateKeyPairSync } from
|
|
3
|
-
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from
|
|
4
|
-
import { tmpdir } from
|
|
5
|
-
import { dirname, join } from
|
|
6
|
-
import { afterEach, beforeEach, test, vi } from
|
|
7
|
-
import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from
|
|
8
|
-
// Native selections, keys and HTTP responses below are fictional. This tests
|
|
9
|
-
// the selected-process contract, not a GUI or an authenticated live service.
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { createHash, generateKeyPairSync } from "node:crypto";
|
|
3
|
+
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { afterEach, beforeEach, test, vi } from "vitest";
|
|
7
|
+
import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from "./fixtures/discovery.js";
|
|
10
8
|
const fixture = vi.hoisted(() => ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
home: "",
|
|
10
|
+
config: "",
|
|
11
|
+
root: "",
|
|
12
|
+
host: "codex",
|
|
13
|
+
enabled: true,
|
|
14
|
+
mode: "success",
|
|
15
|
+
authCalls: 0,
|
|
16
|
+
machine: false,
|
|
17
|
+
ghCalls: [],
|
|
18
|
+
keyReads: 0,
|
|
19
|
+
settingsReads: 0,
|
|
20
|
+
requestErrorLogs: [],
|
|
21
|
+
childStderrLines: [],
|
|
22
|
+
commands: [],
|
|
23
|
+
requests: [],
|
|
24
|
+
startupEnvironments: []
|
|
27
25
|
}));
|
|
28
|
-
vi.mock(
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
vi.mock("node:os", async (original) => ({
|
|
27
|
+
...await original(),
|
|
28
|
+
homedir: () => fixture.home
|
|
31
29
|
}));
|
|
32
|
-
vi.mock(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
// Octokit binds console.error at module import. Capture its real request-log
|
|
46
|
-
// hook through a logger sink instead of a later console spy, as subprocess
|
|
47
|
-
// stderr would do. Requests, authentication and error owners remain real.
|
|
48
|
-
vi.mock('@octokit/rest', async (original) => {
|
|
49
|
-
const actual = await original();
|
|
50
|
-
return {
|
|
51
|
-
...actual,
|
|
52
|
-
Octokit: actual.Octokit.defaults({
|
|
53
|
-
log: {
|
|
54
|
-
debug: () => { },
|
|
55
|
-
info: () => { },
|
|
56
|
-
warn: () => { },
|
|
57
|
-
error: (...values) => {
|
|
58
|
-
const line = values.filter((value) => typeof value === 'string').join(' ');
|
|
59
|
-
fixture.childStderrLines.push(line);
|
|
60
|
-
fixture.requestErrorLogs.push(line);
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
};
|
|
30
|
+
vi.mock("node:fs", async (original) => {
|
|
31
|
+
const actual = await original();
|
|
32
|
+
return {
|
|
33
|
+
...actual,
|
|
34
|
+
readFileSync: (...args) => {
|
|
35
|
+
if (String(args[0]) === fixture.config) fixture.settingsReads++;
|
|
36
|
+
if (String(args[0]).endsWith(".pem")) fixture.keyReads++;
|
|
37
|
+
return actual.readFileSync(...args);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
65
40
|
});
|
|
66
|
-
vi.mock(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return { version: '0.3.24' };
|
|
83
|
-
}
|
|
84
|
-
listTools() {
|
|
85
|
-
return { tools: [] };
|
|
41
|
+
vi.mock("@octokit/rest", async (original) => {
|
|
42
|
+
const actual = await original();
|
|
43
|
+
return {
|
|
44
|
+
...actual,
|
|
45
|
+
Octokit: actual.Octokit.defaults({
|
|
46
|
+
log: {
|
|
47
|
+
debug: () => {
|
|
48
|
+
},
|
|
49
|
+
info: () => {
|
|
50
|
+
},
|
|
51
|
+
warn: () => {
|
|
52
|
+
},
|
|
53
|
+
error: (...values) => {
|
|
54
|
+
const line = values.filter((value) => typeof value === "string").join(" ");
|
|
55
|
+
fixture.childStderrLines.push(line);
|
|
56
|
+
fixture.requestErrorLogs.push(line);
|
|
86
57
|
}
|
|
87
|
-
|
|
88
|
-
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
vi.mock("@modelcontextprotocol/sdk/client/stdio.js", async (original) => ({
|
|
63
|
+
...await original(),
|
|
64
|
+
StdioClientTransport: class {
|
|
65
|
+
constructor(options) {
|
|
66
|
+
fixture.startupEnvironments.push(options.env);
|
|
67
|
+
}
|
|
68
|
+
close() {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
89
71
|
}));
|
|
90
|
-
vi.mock(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
options.failedOutput?.(Buffer.from(stdout + stderr));
|
|
105
|
-
reject(new Error('Synthetic selected CLI failed; output withheld.'));
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
resolve(Buffer.from(stdout));
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
fixture.commands.push({ args, environment: options.environment });
|
|
113
|
-
assert.deepEqual(args, fixture.host === 'codex' && args.includes('--marketplace')
|
|
114
|
-
? ['codex', 'plugin', 'list', '--marketplace', 'ai-delivery-user', '--available', '--json']
|
|
115
|
-
: fixture.host === 'codex'
|
|
116
|
-
? ['codex', 'plugin', 'list', '--json']
|
|
117
|
-
: ['claude', 'plugin', 'list', '--json']);
|
|
118
|
-
const catalog = join(fixture.home, '.cache/ai-delivery/plugins', fixture.host, 'user/marketplace');
|
|
119
|
-
const entry = { version: '0.3.24', enabled: fixture.enabled };
|
|
120
|
-
return Buffer.from(JSON.stringify(fixture.host === 'codex'
|
|
121
|
-
? {
|
|
122
|
-
installed: [
|
|
123
|
-
{
|
|
124
|
-
...entry,
|
|
125
|
-
pluginId: 'ai-delivery@ai-delivery-user',
|
|
126
|
-
marketplaceName: 'ai-delivery-user',
|
|
127
|
-
source: { source: 'local', path: join(catalog, 'versions/0.3.24/plugins/ai-delivery') },
|
|
128
|
-
marketplaceSource: { sourceType: 'local', source: catalog },
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
available: [],
|
|
132
|
-
}
|
|
133
|
-
: [
|
|
134
|
-
{
|
|
135
|
-
...entry,
|
|
136
|
-
id: 'ai-delivery@ai-delivery-user',
|
|
137
|
-
scope: 'user',
|
|
138
|
-
installPath: fixture.root,
|
|
139
|
-
mcpServers: {
|
|
140
|
-
'ai-delivery': { command: 'node', args: ['${CLAUDE_PLUGIN_ROOT}/dist/mcp-launcher.js'] },
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
]));
|
|
144
|
-
},
|
|
72
|
+
vi.mock("@modelcontextprotocol/sdk/client/index.js", () => ({
|
|
73
|
+
Client: class {
|
|
74
|
+
connect() {
|
|
75
|
+
if (fixture.mode === "startup_failed") throw new Error("fictional-upstream-secret");
|
|
76
|
+
}
|
|
77
|
+
getServerVersion() {
|
|
78
|
+
return { version: "0.3.24" };
|
|
79
|
+
}
|
|
80
|
+
listTools() {
|
|
81
|
+
return { tools: [] };
|
|
82
|
+
}
|
|
83
|
+
close() {
|
|
84
|
+
}
|
|
85
|
+
}
|
|
145
86
|
}));
|
|
146
|
-
vi.mock(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
'DISABLE_AUTOUPDATER',
|
|
189
|
-
'HOME',
|
|
190
|
-
'LANG',
|
|
191
|
-
'LC_ALL',
|
|
192
|
-
'NODE_OPTIONS',
|
|
193
|
-
'PATH',
|
|
194
|
-
]
|
|
195
|
-
: [
|
|
196
|
-
'AI_DELIVERY_CONFIG',
|
|
197
|
-
'DELIVERY_AUTHOR_TOKEN',
|
|
198
|
-
'DELIVERY_REVIEW_APP_ID',
|
|
199
|
-
'DELIVERY_REVIEW_INSTALLATION_ID',
|
|
200
|
-
'DELIVERY_REVIEW_KEY_PATH',
|
|
201
|
-
'DISABLE_AUTOUPDATER',
|
|
202
|
-
'NODE_OPTIONS',
|
|
203
|
-
'PATH',
|
|
204
|
-
]).sort());
|
|
205
|
-
fixture.authCalls++;
|
|
206
|
-
const run = async () => {
|
|
207
|
-
if (fixture.mode === 'raw_failure') {
|
|
208
|
-
callback(new Error('fictional-value-header'), 'fictional-value-body', 'fictional-value-key-path');
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const ambient = process.env;
|
|
212
|
-
process.env = { ...options.env };
|
|
213
|
-
fixture.childStderrLines = [];
|
|
214
|
-
try {
|
|
215
|
-
const { contextFor } = await import('./dispatch.js');
|
|
216
|
-
const { preflightReviewRoute } = await import('./pr.js');
|
|
217
|
-
const context = await contextFor({ repoRoot: options.cwd, repo: args[2] }, 'config:resolve');
|
|
218
|
-
const data = {
|
|
219
|
-
routing: context.configuration.routing,
|
|
220
|
-
reviewRoute: await preflightReviewRoute(context, undefined, undefined, 'development'),
|
|
221
|
-
};
|
|
222
|
-
if (fixture.mode === 'wrong_repo')
|
|
223
|
-
data.routing.repository = 'example/unselected';
|
|
224
|
-
if (fixture.mode === 'same_actor')
|
|
225
|
-
data.reviewRoute.reviewer.actorLogin = data.reviewRoute.author.actorLogin;
|
|
226
|
-
if (fixture.mode === 'secret_actor')
|
|
227
|
-
data.reviewRoute.author.actorLogin = options.env.DELIVERY_AUTHOR_TOKEN;
|
|
228
|
-
callback(null, JSON.stringify({
|
|
229
|
-
...data,
|
|
230
|
-
untrustedBody: 'fictional-value-body',
|
|
231
|
-
untrustedHeaders: 'fictional-value-header',
|
|
232
|
-
}), 'fictional-value-key-path');
|
|
87
|
+
vi.mock("./verification.js", async (original) => ({
|
|
88
|
+
...await original(),
|
|
89
|
+
runStageCommand: async (_root, args, _signal, _a, _b, _c, _d, writer, options) => {
|
|
90
|
+
if (args[0] === process.execPath) {
|
|
91
|
+
const { execFile } = await import("node:child_process");
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
execFile(
|
|
94
|
+
process.execPath,
|
|
95
|
+
args.slice(1),
|
|
96
|
+
{
|
|
97
|
+
env: options.environment,
|
|
98
|
+
cwd: options.cwd ?? _root,
|
|
99
|
+
maxBuffer: options.maxCapturedOutputBytes ?? 1024 * 1024,
|
|
100
|
+
encoding: "utf8"
|
|
101
|
+
},
|
|
102
|
+
(error, stdout, stderr) => {
|
|
103
|
+
writer?.idle();
|
|
104
|
+
if (error) {
|
|
105
|
+
options.failedOutput?.(Buffer.from(stdout + stderr));
|
|
106
|
+
reject(new Error("Synthetic selected CLI failed; output withheld."));
|
|
107
|
+
} else resolve(Buffer.from(stdout));
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
fixture.commands.push({ args, environment: options.environment });
|
|
113
|
+
assert.deepEqual(
|
|
114
|
+
args,
|
|
115
|
+
fixture.host === "codex" && args.includes("--marketplace") ? ["codex", "plugin", "list", "--marketplace", "ai-delivery-user", "--available", "--json"] : fixture.host === "codex" ? ["codex", "plugin", "list", "--json"] : ["claude", "plugin", "list", "--json"]
|
|
116
|
+
);
|
|
117
|
+
const catalog = join(fixture.home, ".cache/ai-delivery/plugins", fixture.host, "user/marketplace");
|
|
118
|
+
const entry = { version: "0.3.24", enabled: fixture.enabled };
|
|
119
|
+
return Buffer.from(
|
|
120
|
+
JSON.stringify(
|
|
121
|
+
fixture.host === "codex" ? {
|
|
122
|
+
installed: [
|
|
123
|
+
{
|
|
124
|
+
...entry,
|
|
125
|
+
pluginId: "ai-delivery@ai-delivery-user",
|
|
126
|
+
marketplaceName: "ai-delivery-user",
|
|
127
|
+
source: { source: "local", path: join(catalog, "versions/0.3.24/plugins/ai-delivery") },
|
|
128
|
+
marketplaceSource: { sourceType: "local", source: catalog }
|
|
233
129
|
}
|
|
234
|
-
|
|
235
|
-
|
|
130
|
+
],
|
|
131
|
+
available: []
|
|
132
|
+
} : [
|
|
133
|
+
{
|
|
134
|
+
...entry,
|
|
135
|
+
id: "ai-delivery@ai-delivery-user",
|
|
136
|
+
scope: "user",
|
|
137
|
+
installPath: fixture.root,
|
|
138
|
+
mcpServers: {
|
|
139
|
+
"ai-delivery": { command: "node", args: ["${CLAUDE_PLUGIN_ROOT}/dist/mcp-launcher.js"] }
|
|
236
140
|
}
|
|
237
|
-
|
|
238
|
-
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}));
|
|
147
|
+
vi.mock("node:child_process", async (original) => ({
|
|
148
|
+
...await original(),
|
|
149
|
+
execFile: (binary, args, options, callback) => {
|
|
150
|
+
if (args[0] === "auth") {
|
|
151
|
+
assert.equal(fixture.machine, true);
|
|
152
|
+
assert.equal(binary, realpathSync(join(fixture.home, "bin", "gh")));
|
|
153
|
+
assert.equal(options.maxBuffer, 64 * 1024);
|
|
154
|
+
for (const name of [
|
|
155
|
+
"GH_TOKEN",
|
|
156
|
+
"GITHUB_TOKEN",
|
|
157
|
+
"DELIVERY_REVIEW_APP_ID",
|
|
158
|
+
"DELIVERY_REVIEW_INSTALLATION_ID",
|
|
159
|
+
"DELIVERY_REVIEW_KEY_PATH",
|
|
160
|
+
"NODE_OPTIONS",
|
|
161
|
+
"GH_DEBUG",
|
|
162
|
+
"UNRELATED_SERVICE_TOKEN"
|
|
163
|
+
])
|
|
164
|
+
assert.equal(options.env[name], void 0);
|
|
165
|
+
fixture.ghCalls.push(args);
|
|
166
|
+
if (args[1] === "status")
|
|
167
|
+
callback(
|
|
168
|
+
null,
|
|
169
|
+
JSON.stringify({
|
|
170
|
+
hosts: {
|
|
171
|
+
"github.com": [{ active: true, host: "github.com", login: "fixture-author-login", state: "success" }]
|
|
239
172
|
}
|
|
173
|
+
}),
|
|
174
|
+
"fictional-opaque-stderr"
|
|
175
|
+
);
|
|
176
|
+
else {
|
|
177
|
+
assert.deepEqual(args, ["auth", "token", "--hostname", "github.com", "--user", "fixture-author-login"]);
|
|
178
|
+
callback(null, "fictional_machine_author_value", "fictional-opaque-stderr");
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
assert.equal(binary, process.execPath);
|
|
183
|
+
assert.deepEqual(args, [join(fixture.root, "runtime/dist/cli.js"), "--repo", args[2], "config:resolve"]);
|
|
184
|
+
assert.equal(options.timeout, void 0);
|
|
185
|
+
assert.equal(options.maxBuffer, 1024 * 1024);
|
|
186
|
+
const forwarded = Object.keys(options.env).sort();
|
|
187
|
+
assert.deepEqual(
|
|
188
|
+
forwarded,
|
|
189
|
+
(fixture.machine ? [
|
|
190
|
+
"AI_DELIVERY_CONFIG",
|
|
191
|
+
"DELIVERY_REVIEW_APP_ID",
|
|
192
|
+
"DELIVERY_REVIEW_INSTALLATION_ID",
|
|
193
|
+
"DELIVERY_REVIEW_KEY_PATH",
|
|
194
|
+
"DISABLE_AUTOUPDATER",
|
|
195
|
+
"HOME",
|
|
196
|
+
"LANG",
|
|
197
|
+
"LC_ALL",
|
|
198
|
+
"NODE_OPTIONS",
|
|
199
|
+
"PATH"
|
|
200
|
+
] : [
|
|
201
|
+
"AI_DELIVERY_CONFIG",
|
|
202
|
+
"DELIVERY_AUTHOR_TOKEN",
|
|
203
|
+
"DELIVERY_REVIEW_APP_ID",
|
|
204
|
+
"DELIVERY_REVIEW_INSTALLATION_ID",
|
|
205
|
+
"DELIVERY_REVIEW_KEY_PATH",
|
|
206
|
+
"DISABLE_AUTOUPDATER",
|
|
207
|
+
"NODE_OPTIONS",
|
|
208
|
+
"PATH"
|
|
209
|
+
]).sort()
|
|
210
|
+
);
|
|
211
|
+
fixture.authCalls++;
|
|
212
|
+
const run = async () => {
|
|
213
|
+
if (fixture.mode === "raw_failure") {
|
|
214
|
+
callback(new Error("fictional-value-header"), "fictional-value-body", "fictional-value-key-path");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const ambient = process.env;
|
|
218
|
+
process.env = { ...options.env };
|
|
219
|
+
fixture.childStderrLines = [];
|
|
220
|
+
try {
|
|
221
|
+
const { contextFor } = await import("./dispatch.js");
|
|
222
|
+
const { preflightReviewRoute } = await import("./pr.js");
|
|
223
|
+
const context = await contextFor({ repoRoot: options.cwd, repo: args[2] }, "config:resolve");
|
|
224
|
+
const data = {
|
|
225
|
+
routing: context.configuration.routing,
|
|
226
|
+
reviewRoute: await preflightReviewRoute(context, void 0, void 0, "development")
|
|
240
227
|
};
|
|
241
|
-
|
|
242
|
-
|
|
228
|
+
if (fixture.mode === "wrong_repo") data.routing.repository = "example/unselected";
|
|
229
|
+
if (fixture.mode === "same_actor") data.reviewRoute.reviewer.actorLogin = data.reviewRoute.author.actorLogin;
|
|
230
|
+
if (fixture.mode === "secret_actor") data.reviewRoute.author.actorLogin = options.env.DELIVERY_AUTHOR_TOKEN;
|
|
231
|
+
callback(
|
|
232
|
+
null,
|
|
233
|
+
JSON.stringify({
|
|
234
|
+
...data,
|
|
235
|
+
untrustedBody: "fictional-value-body",
|
|
236
|
+
untrustedHeaders: "fictional-value-header"
|
|
237
|
+
}),
|
|
238
|
+
"fictional-value-key-path"
|
|
239
|
+
);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
callback(
|
|
242
|
+
new Error("Selected CLI failed"),
|
|
243
|
+
"",
|
|
244
|
+
[...fixture.childStderrLines, `ai-delivery: ${error instanceof Error ? error.message : "unknown"}`].join(
|
|
245
|
+
"\n"
|
|
246
|
+
) + "\n"
|
|
247
|
+
);
|
|
248
|
+
} finally {
|
|
249
|
+
process.env = ambient;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
void run();
|
|
253
|
+
}
|
|
243
254
|
}));
|
|
244
|
-
const { managePlugin } = await import(
|
|
255
|
+
const { managePlugin } = await import("./pluginInstaller.js");
|
|
245
256
|
let settings;
|
|
246
257
|
function file(path, bytes) {
|
|
247
|
-
|
|
248
|
-
|
|
258
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
259
|
+
writeFileSync(path, bytes, { mode: 384 });
|
|
249
260
|
}
|
|
250
|
-
function native(host =
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
261
|
+
function native(host = "codex") {
|
|
262
|
+
fixture.host = host;
|
|
263
|
+
const directory = join(fixture.home, ".cache/ai-delivery/plugins", host, "user");
|
|
264
|
+
const catalog = join(directory, "marketplace");
|
|
265
|
+
const unit = join(catalog, "versions/0.3.24");
|
|
266
|
+
const source = join(unit, "plugins/ai-delivery");
|
|
267
|
+
const nativeHome = join(fixture.home, host === "codex" ? ".codex" : ".claude");
|
|
268
|
+
const cache = join(nativeHome, "plugins/cache/ai-delivery-user/ai-delivery/0.3.24");
|
|
269
|
+
fixture.root = cache;
|
|
270
|
+
const files = {
|
|
271
|
+
"runtime/dist/cli.js": "fictional selected CLI; execution simulated",
|
|
272
|
+
"dist/mcp-launcher.js": "fictional launcher",
|
|
273
|
+
"skills/intake/SKILL.md": "fictional skill"
|
|
274
|
+
};
|
|
275
|
+
for (const root of [source, cache]) for (const [name, bytes] of Object.entries(files)) file(join(root, name), bytes);
|
|
276
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
277
|
+
file(join(unit, "archive.tgz"), "fictional archive");
|
|
278
|
+
file(
|
|
279
|
+
join(unit, "version.json"),
|
|
280
|
+
JSON.stringify({
|
|
281
|
+
owner: "@aviaratech/ai-delivery.plugin-version@1",
|
|
282
|
+
version: "0.3.24",
|
|
283
|
+
archiveSha256: hash("fictional archive"),
|
|
284
|
+
files: Object.fromEntries(
|
|
285
|
+
Object.entries(files).sort(([a], [b]) => a.localeCompare(b)).map(([name, bytes]) => [name, hash(bytes)])
|
|
286
|
+
)
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
file(
|
|
290
|
+
join(directory, "state.json"),
|
|
291
|
+
JSON.stringify({
|
|
292
|
+
owner: "@aviaratech/ai-delivery.plugin@1",
|
|
293
|
+
host,
|
|
294
|
+
scope: "user",
|
|
295
|
+
projectRoot: null,
|
|
296
|
+
nativeHome,
|
|
297
|
+
marketplace: "ai-delivery-user",
|
|
298
|
+
currentVersion: "0.3.24",
|
|
299
|
+
previousVersion: null,
|
|
300
|
+
installedPath: cache
|
|
301
|
+
})
|
|
302
|
+
);
|
|
303
|
+
if (host === "claude-code") {
|
|
304
|
+
file(
|
|
305
|
+
join(nativeHome, "plugins/known_marketplaces.json"),
|
|
306
|
+
JSON.stringify({
|
|
307
|
+
"ai-delivery-user": { source: { source: "directory", path: catalog }, installLocation: catalog }
|
|
308
|
+
})
|
|
309
|
+
);
|
|
310
|
+
file(
|
|
311
|
+
join(catalog, ".claude-plugin/marketplace.json"),
|
|
312
|
+
JSON.stringify({
|
|
313
|
+
name: "ai-delivery-user",
|
|
314
|
+
plugins: [{ name: "ai-delivery", version: "0.3.24", source: "./versions/0.3.24/plugins/ai-delivery" }]
|
|
315
|
+
})
|
|
316
|
+
);
|
|
317
|
+
}
|
|
297
318
|
}
|
|
298
319
|
beforeEach(() => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
320
|
+
fixture.home = mkdtempSync(join(tmpdir(), "ai-delivery-doctor-"));
|
|
321
|
+
fixture.config = join(fixture.home, "settings.json");
|
|
322
|
+
fixture.enabled = true;
|
|
323
|
+
fixture.mode = "success";
|
|
324
|
+
fixture.authCalls = 0;
|
|
325
|
+
fixture.machine = false;
|
|
326
|
+
fixture.ghCalls = [];
|
|
327
|
+
fixture.keyReads = 0;
|
|
328
|
+
fixture.settingsReads = 0;
|
|
329
|
+
fixture.requestErrorLogs = [];
|
|
330
|
+
fixture.childStderrLines = [];
|
|
331
|
+
fixture.commands = [];
|
|
332
|
+
fixture.requests = [];
|
|
333
|
+
fixture.startupEnvironments = [];
|
|
334
|
+
vi.stubEnv("CODEX_HOME", join(fixture.home, ".codex"));
|
|
335
|
+
vi.stubEnv("CLAUDE_CONFIG_DIR", join(fixture.home, ".claude"));
|
|
336
|
+
vi.stubEnv("AI_DELIVERY_CONFIG", fixture.config);
|
|
337
|
+
settings = {
|
|
338
|
+
schemaVersion: "ai-delivery.user@1",
|
|
339
|
+
roles: {
|
|
340
|
+
author: { authSource: "personal", identity: "fixture-author", credentialEnv: { token: "DELIVERY_AUTHOR_TOKEN" } },
|
|
341
|
+
reviewer: {
|
|
342
|
+
identity: "fixture-reviewer",
|
|
343
|
+
credentialEnv: {
|
|
344
|
+
appId: "DELIVERY_REVIEW_APP_ID",
|
|
345
|
+
installationId: "DELIVERY_REVIEW_INSTALLATION_ID",
|
|
346
|
+
privateKeyPath: "DELIVERY_REVIEW_KEY_PATH"
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
project: 1,
|
|
351
|
+
checkoutRoots: [],
|
|
352
|
+
pointsField: "Estimate",
|
|
353
|
+
priorityField: "Urgency",
|
|
354
|
+
statusField: "Flow",
|
|
355
|
+
statuses: syntheticDiscoveryConfig.native.project.statuses
|
|
356
|
+
};
|
|
357
|
+
file(fixture.config, JSON.stringify(settings));
|
|
358
|
+
vi.stubEnv("DELIVERY_AUTHOR_TOKEN", "fictional-author-value");
|
|
359
|
+
vi.stubEnv("DELIVERY_REVIEW_APP_ID", "654321");
|
|
360
|
+
vi.stubEnv("DELIVERY_REVIEW_INSTALLATION_ID", "765432");
|
|
361
|
+
const key = join(fixture.home, "fictional-reviewer.pem");
|
|
362
|
+
file(
|
|
363
|
+
key,
|
|
364
|
+
generateKeyPairSync("rsa", {
|
|
365
|
+
modulusLength: 2048,
|
|
366
|
+
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
367
|
+
publicKeyEncoding: { type: "spki", format: "pem" }
|
|
368
|
+
}).privateKey
|
|
369
|
+
);
|
|
370
|
+
vi.stubEnv("DELIVERY_REVIEW_KEY_PATH", key);
|
|
371
|
+
for (const name of ["GH_TOKEN", "GITHUB_TOKEN", "UNRELATED_SERVICE_TOKEN", "AI_DELIVERY_IDENTITY"])
|
|
372
|
+
vi.stubEnv(name, "fictional-unrelated-value");
|
|
373
|
+
vi.stubGlobal("fetch", () => {
|
|
374
|
+
throw new Error("Unexpected HTTP in a synthetic doctor fixture");
|
|
375
|
+
});
|
|
376
|
+
native();
|
|
353
377
|
});
|
|
354
378
|
afterEach(() => {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
379
|
+
vi.unstubAllEnvs();
|
|
380
|
+
vi.unstubAllGlobals();
|
|
381
|
+
vi.restoreAllMocks();
|
|
382
|
+
rmSync(fixture.home, { recursive: true, force: true });
|
|
359
383
|
});
|
|
360
384
|
function http() {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
});
|
|
370
|
-
if (path === '/graphql' && method === 'POST') {
|
|
371
|
-
assert.equal(typeof init?.body, 'string');
|
|
372
|
-
const body = JSON.parse(init.body);
|
|
373
|
-
assert.ok(!body.query.includes('mutation'));
|
|
374
|
-
const config = { ...syntheticDiscoveryConfig, repository: `${body.variables.owner}/${body.variables.repo}` };
|
|
375
|
-
return json({ data: await syntheticDiscoveryClients(config).graphql(body.query) });
|
|
376
|
-
}
|
|
377
|
-
if (method === 'POST' && path === '/app/installations/765432/access_tokens')
|
|
378
|
-
return json({
|
|
379
|
-
token: 'ghs_fictional_installation',
|
|
380
|
-
expires_at: '2099-01-01T00:00:00Z',
|
|
381
|
-
permissions: { contents: 'read', pull_requests: 'write' },
|
|
382
|
-
});
|
|
383
|
-
assert.equal(method, 'GET');
|
|
384
|
-
if (path === '/user')
|
|
385
|
-
return fixture.mode === 'expired'
|
|
386
|
-
? json({ message: 'fictional-author-value' }, 401)
|
|
387
|
-
: json({ id: 42, login: 'fixture-author-login', type: 'User' });
|
|
388
|
-
if (path === '/app')
|
|
389
|
-
return json({ id: 654321, slug: 'fixture-reviewer' });
|
|
390
|
-
if (/^\/repos\/example\/(widget|service)$/u.test(path)) {
|
|
391
|
-
if (fixture.mode === 'denied' && new Headers(init?.headers).get('authorization')?.includes('ghs_'))
|
|
392
|
-
return json({ message: 'fictional-value-body' }, 403);
|
|
393
|
-
return json({ full_name: path.slice(7), default_branch: 'main' });
|
|
394
|
-
}
|
|
395
|
-
if (path.endsWith('/rules/branches/main'))
|
|
396
|
-
return fixture.mode === 'unknown_rules' ? json({ message: 'fictional-value-body' }, 403) : json([]);
|
|
397
|
-
if (path.endsWith('/branches/main/protection'))
|
|
398
|
-
return fixture.mode === 'unknown_rules' ? json({ message: 'fictional-value-body' }, 403) : json({});
|
|
399
|
-
throw new Error('Unapproved endpoint in simulated doctor readback');
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
function doctor(repo = 'example/widget', checkAuth = true) {
|
|
403
|
-
return managePlugin({
|
|
404
|
-
action: 'doctor',
|
|
405
|
-
host: fixture.host,
|
|
406
|
-
scope: 'user',
|
|
407
|
-
repoRoot: fixture.home,
|
|
408
|
-
...(checkAuth ? { checkAuth, repo } : {}),
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
test('default doctor has no settings, reference, key or authentication access; native inventory/startup exclude credentials', async () => {
|
|
412
|
-
file(fixture.config, '{invalid fictional settings');
|
|
413
|
-
const result = await doctor('example/widget', false);
|
|
414
|
-
assert.equal(result.mcp?.startup, 'ready');
|
|
415
|
-
assert.equal(result.authProbe, undefined);
|
|
416
|
-
assert.equal(fixture.settingsReads, 0);
|
|
417
|
-
assert.equal(fixture.keyReads, 0);
|
|
418
|
-
assert.equal(fixture.authCalls, 0);
|
|
419
|
-
assert.deepEqual(fixture.requests, []);
|
|
420
|
-
for (const env of [...fixture.commands.map((c) => c.environment), ...fixture.startupEnvironments]) {
|
|
421
|
-
assert.equal(env.GH_TOKEN, undefined);
|
|
422
|
-
assert.equal(env.DELIVERY_AUTHOR_TOKEN, undefined);
|
|
423
|
-
assert.equal(env.AI_DELIVERY_IDENTITY, undefined);
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
test('the actual SDK startup subprocess receives no inherited-name credential sentinels', async () => {
|
|
427
|
-
const sdk = await vi.importActual('@modelcontextprotocol/sdk/client/stdio.js');
|
|
428
|
-
settings.roles.author.credentialEnv = { token: 'LOGNAME' };
|
|
429
|
-
file(fixture.config, JSON.stringify(settings));
|
|
430
|
-
for (const name of sdk.DEFAULT_INHERITED_ENV_VARS)
|
|
431
|
-
vi.stubEnv(name, `fictional-inherited-${name}`);
|
|
432
|
-
await doctor('example/widget', false);
|
|
433
|
-
const transport = new sdk.StdioClientTransport({
|
|
434
|
-
command: process.execPath,
|
|
435
|
-
args: [
|
|
436
|
-
'--input-type=module',
|
|
437
|
-
'-e',
|
|
438
|
-
"process.stdout.write(JSON.stringify({jsonrpc:'2.0',method:'fixture.environment',params:Object.fromEntries(['HOME','LOGNAME','PATH','SHELL','TERM','USER'].map(name=>[name,process.env[name]]))})+'\\n');process.stdin.resume();",
|
|
439
|
-
],
|
|
440
|
-
cwd: fixture.home,
|
|
441
|
-
env: fixture.startupEnvironments[0],
|
|
442
|
-
stderr: 'pipe',
|
|
385
|
+
vi.stubGlobal("fetch", async (input, init) => {
|
|
386
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
387
|
+
const path = new URL(url).pathname;
|
|
388
|
+
const method = init?.method ?? "GET";
|
|
389
|
+
fixture.requests.push(`${method} ${path}`);
|
|
390
|
+
const json = (data, status = 200) => new Response(JSON.stringify(data), {
|
|
391
|
+
status,
|
|
392
|
+
headers: { "content-type": "application/json", "x-fixture-secret": "fictional-value-header" }
|
|
443
393
|
});
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const message = (await readback);
|
|
451
|
-
assert.deepEqual(message.params, Object.fromEntries(sdk.DEFAULT_INHERITED_ENV_VARS.map((name) => [name, ''])));
|
|
452
|
-
assert.equal(fixture.settingsReads, 0);
|
|
453
|
-
assert.equal(fixture.authCalls, 0);
|
|
454
|
-
assert.equal(fixture.keyReads, 0);
|
|
394
|
+
if (path === "/graphql" && method === "POST") {
|
|
395
|
+
assert.equal(typeof init?.body, "string");
|
|
396
|
+
const body = JSON.parse(init.body);
|
|
397
|
+
assert.ok(!body.query.includes("mutation"));
|
|
398
|
+
const config = { ...syntheticDiscoveryConfig, repository: `${body.variables.owner}/${body.variables.repo}` };
|
|
399
|
+
return json({ data: await syntheticDiscoveryClients(config).graphql(body.query) });
|
|
455
400
|
}
|
|
456
|
-
|
|
457
|
-
|
|
401
|
+
if (method === "POST" && path === "/app/installations/765432/access_tokens")
|
|
402
|
+
return json({
|
|
403
|
+
token: "ghs_fictional_installation",
|
|
404
|
+
expires_at: "2099-01-01T00:00:00Z",
|
|
405
|
+
permissions: { contents: "read", pull_requests: "write" }
|
|
406
|
+
});
|
|
407
|
+
assert.equal(method, "GET");
|
|
408
|
+
if (path === "/user")
|
|
409
|
+
return fixture.mode === "expired" ? json({ message: "fictional-author-value" }, 401) : json({ id: 42, login: "fixture-author-login", type: "User" });
|
|
410
|
+
if (path === "/app") return json({ id: 654321, slug: "fixture-reviewer" });
|
|
411
|
+
if (/^\/repos\/example\/(widget|service)$/u.test(path)) {
|
|
412
|
+
if (fixture.mode === "denied" && new Headers(init?.headers).get("authorization")?.includes("ghs_"))
|
|
413
|
+
return json({ message: "fictional-value-body" }, 403);
|
|
414
|
+
return json({ full_name: path.slice(7), default_branch: "main" });
|
|
458
415
|
}
|
|
416
|
+
if (path.endsWith("/rules/branches/main"))
|
|
417
|
+
return fixture.mode === "unknown_rules" ? json({ message: "fictional-value-body" }, 403) : json([]);
|
|
418
|
+
if (path.endsWith("/branches/main/protection"))
|
|
419
|
+
return fixture.mode === "unknown_rules" ? json({ message: "fictional-value-body" }, 403) : json({});
|
|
420
|
+
throw new Error("Unapproved endpoint in simulated doctor readback");
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function doctor(repo = "example/widget", checkAuth = true) {
|
|
424
|
+
return managePlugin({
|
|
425
|
+
action: "doctor",
|
|
426
|
+
host: fixture.host,
|
|
427
|
+
scope: "user",
|
|
428
|
+
repoRoot: fixture.home,
|
|
429
|
+
...checkAuth ? { checkAuth, repo } : {}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
test("default doctor has no settings, reference, key or authentication access; native inventory/startup exclude credentials", async () => {
|
|
433
|
+
file(fixture.config, "{invalid fictional settings");
|
|
434
|
+
const result = await doctor("example/widget", false);
|
|
435
|
+
assert.equal(result.mcp?.startup, "ready");
|
|
436
|
+
assert.equal(result.authProbe, void 0);
|
|
437
|
+
assert.equal(fixture.settingsReads, 0);
|
|
438
|
+
assert.equal(fixture.keyReads, 0);
|
|
439
|
+
assert.equal(fixture.authCalls, 0);
|
|
440
|
+
assert.deepEqual(fixture.requests, []);
|
|
441
|
+
for (const env of [...fixture.commands.map((c) => c.environment), ...fixture.startupEnvironments]) {
|
|
442
|
+
assert.equal(env.GH_TOKEN, void 0);
|
|
443
|
+
assert.equal(env.DELIVERY_AUTHOR_TOKEN, void 0);
|
|
444
|
+
assert.equal(env.AI_DELIVERY_IDENTITY, void 0);
|
|
445
|
+
}
|
|
459
446
|
});
|
|
460
|
-
test(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
447
|
+
test("the actual SDK startup subprocess receives no inherited-name credential sentinels", async () => {
|
|
448
|
+
const sdk = await vi.importActual(
|
|
449
|
+
"@modelcontextprotocol/sdk/client/stdio.js"
|
|
450
|
+
);
|
|
451
|
+
settings.roles.author = {
|
|
452
|
+
authSource: "personal",
|
|
453
|
+
identity: settings.roles.author.identity,
|
|
454
|
+
credentialEnv: { token: "LOGNAME" }
|
|
455
|
+
};
|
|
456
|
+
file(fixture.config, JSON.stringify(settings));
|
|
457
|
+
for (const name of sdk.DEFAULT_INHERITED_ENV_VARS) vi.stubEnv(name, `fictional-inherited-${name}`);
|
|
458
|
+
await doctor("example/widget", false);
|
|
459
|
+
const transport = new sdk.StdioClientTransport({
|
|
460
|
+
command: process.execPath,
|
|
461
|
+
args: [
|
|
462
|
+
"--input-type=module",
|
|
463
|
+
"-e",
|
|
464
|
+
"process.stdout.write(JSON.stringify({jsonrpc:'2.0',method:'fixture.environment',params:Object.fromEntries(['HOME','LOGNAME','PATH','SHELL','TERM','USER'].map(name=>[name,process.env[name]]))})+'\\n');process.stdin.resume();"
|
|
465
|
+
],
|
|
466
|
+
cwd: fixture.home,
|
|
467
|
+
env: fixture.startupEnvironments[0],
|
|
468
|
+
stderr: "pipe"
|
|
469
|
+
});
|
|
470
|
+
try {
|
|
471
|
+
const readback = new Promise((resolve, reject) => {
|
|
472
|
+
transport.onmessage = resolve;
|
|
473
|
+
transport.onerror = reject;
|
|
472
474
|
});
|
|
473
|
-
|
|
475
|
+
await transport.start();
|
|
476
|
+
const message = await readback;
|
|
477
|
+
assert.deepEqual(message.params, Object.fromEntries(sdk.DEFAULT_INHERITED_ENV_VARS.map((name) => [name, ""])));
|
|
474
478
|
assert.equal(fixture.settingsReads, 0);
|
|
475
|
-
});
|
|
476
|
-
test('invalid settings stop before reading a key or executing the authenticated child', async () => {
|
|
477
|
-
file(fixture.config, JSON.stringify({
|
|
478
|
-
...settings,
|
|
479
|
-
roles: { ...settings.roles, reviewer: { ...settings.roles.reviewer, identity: settings.roles.author.identity } },
|
|
480
|
-
}));
|
|
481
|
-
const result = await doctor();
|
|
482
|
-
assert.equal(result.authProbe?.settings, 'unavailable_or_invalid');
|
|
483
|
-
assert.equal(fixture.keyReads, 0);
|
|
484
479
|
assert.equal(fixture.authCalls, 0);
|
|
485
|
-
assert.ok(!JSON.stringify(result.authProbe).includes(fixture.config));
|
|
486
|
-
});
|
|
487
|
-
test('all missing selected references gate both roles; unrelated legacy credentials cannot satisfy them', async () => {
|
|
488
|
-
vi.stubEnv('DELIVERY_AUTHOR_TOKEN', '');
|
|
489
|
-
vi.stubEnv('DELIVERY_REVIEW_APP_ID', '');
|
|
490
|
-
const result = await doctor();
|
|
491
|
-
assert.deepEqual(result.authProbe?.processReferences.missingNames, [
|
|
492
|
-
'DELIVERY_AUTHOR_TOKEN',
|
|
493
|
-
'DELIVERY_REVIEW_APP_ID',
|
|
494
|
-
]);
|
|
495
|
-
assert.equal(result.authProbe?.authentication.status, 'not_checked');
|
|
496
480
|
assert.equal(fixture.keyReads, 0);
|
|
497
|
-
|
|
498
|
-
|
|
481
|
+
} finally {
|
|
482
|
+
await transport.close();
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
test("auth opt-in requires an explicit valid repository, even outside Git or in dry-run", async () => {
|
|
486
|
+
await assert.rejects(
|
|
487
|
+
managePlugin({ action: "doctor", host: "codex", scope: "user", repoRoot: fixture.home, checkAuth: true }),
|
|
488
|
+
/requires explicit --repo/u
|
|
489
|
+
);
|
|
490
|
+
await assert.rejects(doctor("invalid"), /Invalid string/u);
|
|
491
|
+
assert.equal(fixture.commands.length, 0);
|
|
492
|
+
const result = await managePlugin({
|
|
493
|
+
action: "doctor",
|
|
494
|
+
host: "codex",
|
|
495
|
+
scope: "user",
|
|
496
|
+
repoRoot: fixture.home,
|
|
497
|
+
checkAuth: true,
|
|
498
|
+
repo: "example/widget",
|
|
499
|
+
dryRun: true
|
|
500
|
+
});
|
|
501
|
+
assert.equal(result.authProbe?.reason, "dry_run");
|
|
502
|
+
assert.equal(fixture.settingsReads, 0);
|
|
503
|
+
});
|
|
504
|
+
test("invalid settings stop before reading a key or executing the authenticated child", async () => {
|
|
505
|
+
file(
|
|
506
|
+
fixture.config,
|
|
507
|
+
JSON.stringify({
|
|
508
|
+
...settings,
|
|
509
|
+
roles: { ...settings.roles, reviewer: { ...settings.roles.reviewer, identity: settings.roles.author.identity } }
|
|
510
|
+
})
|
|
511
|
+
);
|
|
512
|
+
const result = await doctor();
|
|
513
|
+
assert.equal(result.authProbe?.settings, "unavailable_or_invalid");
|
|
514
|
+
assert.equal(fixture.keyReads, 0);
|
|
515
|
+
assert.equal(fixture.authCalls, 0);
|
|
516
|
+
assert.ok(!JSON.stringify(result.authProbe).includes(fixture.config));
|
|
499
517
|
});
|
|
500
|
-
test
|
|
518
|
+
test("all missing selected references gate both roles; unrelated legacy credentials cannot satisfy them", async () => {
|
|
519
|
+
vi.stubEnv("DELIVERY_AUTHOR_TOKEN", "");
|
|
520
|
+
vi.stubEnv("DELIVERY_REVIEW_APP_ID", "");
|
|
521
|
+
const result = await doctor();
|
|
522
|
+
assert.deepEqual(result.authProbe?.processReferences.missingNames, [
|
|
523
|
+
"DELIVERY_AUTHOR_TOKEN",
|
|
524
|
+
"DELIVERY_REVIEW_APP_ID"
|
|
525
|
+
]);
|
|
526
|
+
assert.equal(result.authProbe?.authentication.status, "not_checked");
|
|
527
|
+
assert.equal(fixture.keyReads, 0);
|
|
528
|
+
assert.equal(fixture.authCalls, 0);
|
|
529
|
+
assert.ok(!JSON.stringify(result.authProbe).includes("fictional-unrelated-value"));
|
|
530
|
+
});
|
|
531
|
+
test.each(["codex", "claude-code"])(
|
|
532
|
+
"%s doctor may explicitly resolve an absent default reference through the selected machine session",
|
|
533
|
+
async (host) => {
|
|
501
534
|
native(host);
|
|
502
535
|
fixture.machine = true;
|
|
503
|
-
settings.roles.author
|
|
536
|
+
settings.roles.author = {
|
|
537
|
+
authSource: "personal",
|
|
538
|
+
identity: settings.roles.author.identity,
|
|
539
|
+
credentialEnv: { token: "GH_TOKEN" }
|
|
540
|
+
};
|
|
504
541
|
file(fixture.config, JSON.stringify(settings));
|
|
505
|
-
vi.stubEnv(
|
|
506
|
-
vi.stubEnv(
|
|
507
|
-
|
|
508
|
-
vi.stubEnv(
|
|
509
|
-
vi.stubEnv(
|
|
510
|
-
vi.stubEnv(
|
|
511
|
-
|
|
512
|
-
const bin = join(fixture.home, 'bin');
|
|
542
|
+
vi.stubEnv("GH_TOKEN", void 0);
|
|
543
|
+
vi.stubEnv("HOME", fixture.home);
|
|
544
|
+
vi.stubEnv("LANG", "C");
|
|
545
|
+
vi.stubEnv("LC_ALL", "C");
|
|
546
|
+
vi.stubEnv("USER", void 0);
|
|
547
|
+
vi.stubEnv("LOGNAME", void 0);
|
|
548
|
+
const bin = join(fixture.home, "bin");
|
|
513
549
|
mkdirSync(bin);
|
|
514
|
-
file(join(bin,
|
|
515
|
-
chmodSync(join(bin,
|
|
516
|
-
vi.stubEnv(
|
|
550
|
+
file(join(bin, "gh"), "fictional CLI; execution simulated");
|
|
551
|
+
chmodSync(join(bin, "gh"), 493);
|
|
552
|
+
vi.stubEnv("PATH", bin);
|
|
517
553
|
http();
|
|
518
|
-
for (const repo of [
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
554
|
+
for (const repo of ["example/widget", "example/service", "example/widget"]) {
|
|
555
|
+
const result = await doctor(repo);
|
|
556
|
+
assert.equal(result.authProbe?.outcome, "readback_complete");
|
|
557
|
+
assert.equal(result.authProbe?.processReferences.status, "complete");
|
|
558
|
+
assert.ok(!result.authProbe?.processReferences.requiredNames.includes("GH_TOKEN"));
|
|
559
|
+
assert.equal(
|
|
560
|
+
result.authProbe?.authentication.author?.credentialSource,
|
|
561
|
+
`gh:github.com:${realpathSync(join(bin, "gh"))}`
|
|
562
|
+
);
|
|
563
|
+
assert.equal(result.authProbe?.nativeGuiPropagation, "unverified");
|
|
564
|
+
assert.ok(!JSON.stringify(result).includes("fictional_machine_author_value"));
|
|
526
565
|
}
|
|
527
|
-
assert.equal(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
566
|
+
assert.equal(
|
|
567
|
+
fixture.ghCalls.length,
|
|
568
|
+
6,
|
|
569
|
+
"One status/token selection per command, retained across routing and operation"
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
test("absent default author input still gates missing reviewer references before machine/session/key access", async () => {
|
|
574
|
+
settings.roles.author = {
|
|
575
|
+
authSource: "personal",
|
|
576
|
+
identity: settings.roles.author.identity,
|
|
577
|
+
credentialEnv: { token: "GH_TOKEN" }
|
|
578
|
+
};
|
|
579
|
+
file(fixture.config, JSON.stringify(settings));
|
|
580
|
+
vi.stubEnv("GH_TOKEN", void 0);
|
|
581
|
+
vi.stubEnv("DELIVERY_REVIEW_APP_ID", void 0);
|
|
582
|
+
const result = await doctor();
|
|
583
|
+
assert.deepEqual(result.authProbe?.processReferences.missingNames, ["DELIVERY_REVIEW_APP_ID"]);
|
|
584
|
+
assert.equal(fixture.authCalls, 0);
|
|
585
|
+
assert.equal(fixture.ghCalls.length, 0);
|
|
586
|
+
assert.equal(fixture.keyReads, 0);
|
|
539
587
|
});
|
|
540
|
-
test(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
588
|
+
test("invalid App references and reserved runtime credential names stop before key/network access", async () => {
|
|
589
|
+
vi.stubEnv("DELIVERY_REVIEW_INSTALLATION_ID", "not-an-id");
|
|
590
|
+
assert.equal((await doctor()).authProbe?.reason, "invalid_references");
|
|
591
|
+
vi.stubEnv("DELIVERY_REVIEW_INSTALLATION_ID", "765432");
|
|
592
|
+
settings.roles.author = {
|
|
593
|
+
authSource: "personal",
|
|
594
|
+
identity: settings.roles.author.identity,
|
|
595
|
+
credentialEnv: { token: "NODE_OPTIONS" }
|
|
596
|
+
};
|
|
597
|
+
file(fixture.config, JSON.stringify(settings));
|
|
598
|
+
vi.stubEnv("NODE_OPTIONS", "fictional-runtime-value");
|
|
599
|
+
assert.equal((await doctor()).authProbe?.reason, "invalid_references");
|
|
600
|
+
assert.equal(fixture.keyReads, 0);
|
|
601
|
+
assert.equal(fixture.authCalls, 0);
|
|
550
602
|
});
|
|
551
|
-
test.each([
|
|
603
|
+
test.each(["codex", "claude-code"])(
|
|
604
|
+
"%s synthetic selection outside Git probes A \u2192 B \u2192 A through existing read-only auth owners",
|
|
605
|
+
async (host) => {
|
|
552
606
|
native(host);
|
|
553
607
|
http();
|
|
554
|
-
for (const repo of [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
608
|
+
for (const repo of ["example/widget", "example/service", "example/widget"]) {
|
|
609
|
+
const result = await doctor(repo);
|
|
610
|
+
assert.equal(result.authProbe?.outcome, "readback_complete");
|
|
611
|
+
assert.deepEqual(result.authProbe?.authentication, {
|
|
612
|
+
status: "verified",
|
|
613
|
+
author: { actorLogin: "fixture-author-login", authSource: "personal" },
|
|
614
|
+
reviewer: { actorLogin: "fixture-reviewer[bot]", authSource: "app" }
|
|
615
|
+
});
|
|
616
|
+
assert.deepEqual(result.authProbe?.repositoryAccess, { repository: repo, status: "verified" });
|
|
617
|
+
assert.equal(result.authProbe?.nativeGuiPropagation, "unverified");
|
|
618
|
+
assert.equal(result.authProbe?.reviewRules?.approvalEligibility, "unknown");
|
|
619
|
+
assert.ok(!JSON.stringify(result).includes("fictional-author-value"));
|
|
620
|
+
assert.ok(!JSON.stringify(result.authProbe).includes("fictional-reviewer.pem"));
|
|
567
621
|
}
|
|
568
622
|
assert.equal(fixture.authCalls, 3);
|
|
569
|
-
assert.ok(fixture.requests.includes(
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (mode ===
|
|
577
|
-
|
|
623
|
+
assert.ok(fixture.requests.includes("POST /app/installations/765432/access_tokens"));
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
test.each(["changed", "disabled", "startup_failed"])(
|
|
627
|
+
"auth probe refuses %s selected native bytes/startup",
|
|
628
|
+
async (mode) => {
|
|
629
|
+
if (mode === "changed") file(join(fixture.root, "skills/intake/SKILL.md"), "modified skill");
|
|
630
|
+
if (mode === "disabled") fixture.enabled = false;
|
|
631
|
+
if (mode === "startup_failed") fixture.mode = mode;
|
|
578
632
|
const result = await doctor();
|
|
579
|
-
assert.equal(result.authProbe?.reason,
|
|
633
|
+
assert.equal(result.authProbe?.reason, "native_plugin_not_ready");
|
|
580
634
|
assert.equal(fixture.authCalls, 0);
|
|
581
635
|
assert.equal(fixture.keyReads, 0);
|
|
582
636
|
assert.equal(fixture.settingsReads, 0);
|
|
583
|
-
assert.ok(!JSON.stringify(result).includes(
|
|
584
|
-
}
|
|
585
|
-
|
|
637
|
+
assert.ok(!JSON.stringify(result).includes("fictional-upstream-secret"));
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
test.each(["expired", "denied", "raw_failure"])(
|
|
641
|
+
"safe labelled %s failure does not reveal body/header/key-path sentinels or claim verified access",
|
|
642
|
+
async (mode) => {
|
|
586
643
|
fixture.mode = mode;
|
|
587
644
|
http();
|
|
588
645
|
const result = await doctor();
|
|
589
|
-
assert.equal(result.authProbe?.outcome,
|
|
590
|
-
assert.equal(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
646
|
+
assert.equal(result.authProbe?.outcome, "failed");
|
|
647
|
+
assert.equal(
|
|
648
|
+
result.authProbe?.reason,
|
|
649
|
+
mode === "expired" ? "authentication_failed" : mode === "denied" ? "repository_denied" : "probe_failed"
|
|
650
|
+
);
|
|
651
|
+
if (mode !== "raw_failure")
|
|
652
|
+
assert.ok(
|
|
653
|
+
fixture.requestErrorLogs.some((line) => line.startsWith("GET ")),
|
|
654
|
+
"Installed Octokit REST logger must precede the final diagnostic"
|
|
655
|
+
);
|
|
656
|
+
assert.notEqual(result.authProbe?.authentication.status, "verified");
|
|
657
|
+
assert.notEqual(result.authProbe?.repositoryAccess.status, "verified");
|
|
595
658
|
for (const sentinel of [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
659
|
+
"fictional-author-value",
|
|
660
|
+
"fictional-value-body",
|
|
661
|
+
"fictional-value-header",
|
|
662
|
+
"fictional-value-key-path"
|
|
600
663
|
])
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
664
|
+
assert.ok(!JSON.stringify(result).includes(sentinel));
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
test("hidden rules remain unknown after authenticated identity/repository reads; no counted approval is inferred", async () => {
|
|
668
|
+
fixture.mode = "unknown_rules";
|
|
669
|
+
http();
|
|
670
|
+
const result = await doctor();
|
|
671
|
+
assert.equal(result.authProbe?.outcome, "readback_complete");
|
|
672
|
+
assert.deepEqual(result.authProbe?.reviewRules, {
|
|
673
|
+
visibility: "unknown",
|
|
674
|
+
observedRequiredApprovals: null,
|
|
675
|
+
approvalEligibility: "unknown"
|
|
676
|
+
});
|
|
613
677
|
});
|
|
614
|
-
test.each([
|
|
678
|
+
test.each(["wrong_repo", "same_actor", "secret_actor"])(
|
|
679
|
+
"rejects %s readback without reflecting unsafe identity data",
|
|
680
|
+
async (mode) => {
|
|
615
681
|
fixture.mode = mode;
|
|
616
682
|
http();
|
|
617
683
|
const result = await doctor();
|
|
618
|
-
assert.equal(result.authProbe?.reason,
|
|
619
|
-
assert.equal(result.authProbe?.authentication.status,
|
|
620
|
-
assert.ok(!JSON.stringify(result).includes(
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
684
|
+
assert.equal(result.authProbe?.reason, "invalid_readback");
|
|
685
|
+
assert.equal(result.authProbe?.authentication.status, "unverified");
|
|
686
|
+
assert.ok(!JSON.stringify(result).includes("fictional-author-value"));
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
test("synthetic doctor reads never change managed state or settings", async () => {
|
|
690
|
+
http();
|
|
691
|
+
const state = join(fixture.home, ".cache/ai-delivery/plugins/codex/user/state.json");
|
|
692
|
+
const before = [readFileSync(state), readFileSync(fixture.config)];
|
|
693
|
+
await doctor();
|
|
694
|
+
assert.deepEqual([readFileSync(state), readFileSync(fixture.config)], before);
|
|
628
695
|
});
|
|
629
|
-
test.each([true, false])(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
assert.equal(fixture.authCalls, 0);
|
|
643
|
-
assert.equal(fixture.keyReads, 0);
|
|
696
|
+
test.each([true, false])("doctor preserves a present or absent native tool preference (%s)", async (present) => {
|
|
697
|
+
const nativeConfig = join(fixture.home, ".codex", "config.toml");
|
|
698
|
+
const bytes = present ? '[plugins."ai-delivery".mcp_servers.ai-delivery.tools.issue_info]\napproval_mode="approve"\n' : "# no explicit issue_info approval preference\n";
|
|
699
|
+
file(nativeConfig, bytes);
|
|
700
|
+
const result = await doctor("example/widget", false);
|
|
701
|
+
assert.equal(result.mcp?.startup, "ready");
|
|
702
|
+
assert.equal(result.activation?.installedVersion, "0.3.24");
|
|
703
|
+
assert.equal(result.activation?.startupVersion, "0.3.24");
|
|
704
|
+
assert.equal(result.activation?.loadedVersion, null);
|
|
705
|
+
assert.equal(result.diagnostics?.migration, "refused");
|
|
706
|
+
assert.equal(readFileSync(nativeConfig, "utf8"), bytes);
|
|
707
|
+
assert.equal(fixture.authCalls, 0);
|
|
708
|
+
assert.equal(fixture.keyReads, 0);
|
|
644
709
|
});
|
|
645
|
-
//# sourceMappingURL=pluginDoctor.test.js.map
|
|
710
|
+
//# sourceMappingURL=pluginDoctor.test.js.map
|