@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,399 +1,433 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { execFileSync } from
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, realpathSync, unlinkSync, rmSync, writeFileSync } from
|
|
4
|
-
import { tmpdir } from
|
|
5
|
-
import { join } from
|
|
6
|
-
import { afterEach, describe, it, vi } from
|
|
7
|
-
import { loadDeliveryConfig, loadDeliverySettings } from
|
|
8
|
-
import * as githubClients from
|
|
9
|
-
import * as repository from
|
|
10
|
-
import * as gitCommands from
|
|
11
|
-
import { executeTool } from
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, realpathSync, unlinkSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { afterEach, describe, it, vi } from "vitest";
|
|
7
|
+
import { loadDeliveryConfig, loadDeliverySettings } from "./config/deliveryConfig.js";
|
|
8
|
+
import * as githubClients from "./github/client.js";
|
|
9
|
+
import * as repository from "./github/repo.js";
|
|
10
|
+
import * as gitCommands from "./git.js";
|
|
11
|
+
import { executeTool } from "./dispatch.js";
|
|
12
|
+
import { loadDeliveryContext } from "./issue.js";
|
|
13
|
+
import * as deliveryConfig from "./config/deliveryConfig.js";
|
|
14
|
+
import { createAiDeliveryMcpServer, AI_DELIVERY_MCP_TOOLS } from "./mcp/index.js";
|
|
15
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
16
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
17
|
+
import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from "./fixtures/discovery.js";
|
|
16
18
|
const userSettings = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
schemaVersion: "ai-delivery.user@1",
|
|
20
|
+
roles: {
|
|
21
|
+
author: { authSource: "personal", identity: "host-author", credentialEnv: { token: "SYNTHETIC_TOKEN" } },
|
|
22
|
+
reviewer: {
|
|
23
|
+
identity: "app-reviewer",
|
|
24
|
+
credentialEnv: { appId: "APP_ID", installationId: "INSTALLATION_ID", privateKeyPath: "KEY_PATH" }
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
project: 1,
|
|
28
|
+
checkoutRoots: [],
|
|
29
|
+
pointsField: "Estimate",
|
|
30
|
+
priorityField: "Urgency",
|
|
31
|
+
statusField: "Flow",
|
|
32
|
+
statuses: { blocked: "Waiting", done: "Shipped", inProgress: "Active", todo: "Queued" }
|
|
31
33
|
};
|
|
32
|
-
describe(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
34
|
+
describe("directory-independent user configuration", () => {
|
|
35
|
+
it("publishes repository guidance during initialization before a tool is called outside Git", async () => {
|
|
36
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-discovery-guidance-"));
|
|
37
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
38
|
+
process.env.AI_DELIVERY_CONFIG = join(root, "user.json");
|
|
39
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
40
|
+
const server = createAiDeliveryMcpServer({ repoRoot: root });
|
|
41
|
+
const client = new Client({ name: "discovery-guidance-fixture", version: "1" });
|
|
42
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
43
|
+
try {
|
|
44
|
+
await server.connect(serverTransport);
|
|
45
|
+
await client.connect(clientTransport);
|
|
46
|
+
const instructions = client.getInstructions();
|
|
47
|
+
assert.equal(typeof instructions, "string", "initialize must provide guidance before deferred tool discovery");
|
|
48
|
+
assert.match(instructions ?? "", /\brepo\b/u);
|
|
49
|
+
assert.match(instructions ?? "", /\bissue_info\b/u);
|
|
50
|
+
const listed = await client.listTools();
|
|
51
|
+
for (const name of ["issue_info", "issue_ready_check"]) {
|
|
52
|
+
const tool = listed.tools.find((candidate) => candidate.name === name);
|
|
53
|
+
assert.ok(tool);
|
|
54
|
+
const properties = tool.inputSchema.properties;
|
|
55
|
+
assert.equal(typeof properties.repo?.description, "string", `${name} must describe its repository input`);
|
|
56
|
+
assert.match(properties.repo?.description ?? "", /owner\/name/u);
|
|
57
|
+
}
|
|
58
|
+
for (const arguments_ of [
|
|
59
|
+
{ issueNumber: 17, repo: "example/widget", cached: true },
|
|
60
|
+
{ issueNumber: 17, repository: "example/widget" },
|
|
61
|
+
{ issueNumber: 17, repo: "invalid" }
|
|
62
|
+
]) {
|
|
63
|
+
const rejected = await client.callTool({ name: "issue_info", arguments: arguments_ });
|
|
64
|
+
assert.equal(rejected.isError, true);
|
|
65
|
+
assert.match(JSON.stringify(rejected), /Invalid arguments/u);
|
|
66
|
+
assert.doesNotMatch(JSON.stringify(rejected), /SYNTHETIC_TOKEN|Git remotes/u);
|
|
67
|
+
}
|
|
68
|
+
assert.equal(existsSync(join(root, ".git")), false);
|
|
69
|
+
assert.equal(existsSync(join(root, ".issue-cli")), false);
|
|
70
|
+
} finally {
|
|
71
|
+
await client.close();
|
|
72
|
+
await server.close();
|
|
73
|
+
if (previous === void 0) delete process.env.AI_DELIVERY_CONFIG;
|
|
74
|
+
else process.env.AI_DELIVERY_CONFIG = previous;
|
|
75
|
+
rmSync(root, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
it("resolves an explicit repository in a non-Git directory without repository policy", async () => {
|
|
79
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-directory-"));
|
|
80
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
81
|
+
try {
|
|
82
|
+
process.env.AI_DELIVERY_CONFIG = join(root, "user.json");
|
|
83
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
84
|
+
const loaded = await loadDeliveryConfig(root, {
|
|
85
|
+
repository: "example/widget",
|
|
86
|
+
clients: syntheticDiscoveryClients(syntheticDiscoveryConfig)
|
|
87
|
+
});
|
|
88
|
+
assert.equal(loaded.config.repository, "example/widget");
|
|
89
|
+
assert.equal(loaded.config.roles.author.identity, "host-author");
|
|
90
|
+
assert.equal(loaded.configPath, process.env.AI_DELIVERY_CONFIG);
|
|
91
|
+
assert.equal("policy" in loaded.config, false);
|
|
92
|
+
} finally {
|
|
93
|
+
if (previous === void 0) delete process.env.AI_DELIVERY_CONFIG;
|
|
94
|
+
else process.env.AI_DELIVERY_CONFIG = previous;
|
|
95
|
+
rmSync(root, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
it("carries a discovered In Review option into the delivery context", async () => {
|
|
99
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-review-option-"));
|
|
100
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
101
|
+
try {
|
|
102
|
+
process.env.AI_DELIVERY_CONFIG = join(root, "user.json");
|
|
103
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
104
|
+
const loaded = await loadDeliveryConfig(root, {
|
|
105
|
+
repository: "example/widget",
|
|
106
|
+
clients: syntheticDiscoveryClients(syntheticDiscoveryConfig, ["In Review"])
|
|
107
|
+
});
|
|
108
|
+
vi.spyOn(deliveryConfig, "loadDeliveryConfig").mockResolvedValue(loaded);
|
|
109
|
+
vi.spyOn(githubClients, "createDeliveryGitHubClients").mockResolvedValue({});
|
|
110
|
+
const context = await loadDeliveryContext({
|
|
111
|
+
identity: "host-author",
|
|
112
|
+
role: "author",
|
|
113
|
+
repoRoot: root,
|
|
114
|
+
repository: "example/widget"
|
|
115
|
+
});
|
|
116
|
+
assert.equal(context.projectConfiguration?.reviewOptionId, "STATUS-EXTRA-0");
|
|
117
|
+
} finally {
|
|
118
|
+
if (previous === void 0) delete process.env.AI_DELIVERY_CONFIG;
|
|
119
|
+
else process.env.AI_DELIVERY_CONFIG = previous;
|
|
120
|
+
rmSync(root, { recursive: true, force: true });
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
it("never imports a tracked hostile policy while resolving a local checkout", async () => {
|
|
124
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-hostile-"));
|
|
125
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
126
|
+
const sentinel = join(root, "executed");
|
|
127
|
+
try {
|
|
128
|
+
execFileSync("git", ["init", "--quiet", root]);
|
|
129
|
+
execFileSync("git", ["remote", "add", "origin", "https://github.com/example/widget.git"], { cwd: root });
|
|
130
|
+
writeFileSync(
|
|
131
|
+
join(root, "ai-delivery.policy.mjs"),
|
|
132
|
+
`import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},'executed');export const deliverySettings={};`
|
|
133
|
+
);
|
|
134
|
+
execFileSync("git", ["add", "ai-delivery.policy.mjs"], { cwd: root });
|
|
135
|
+
process.env.AI_DELIVERY_CONFIG = join(root, "user.json");
|
|
136
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
137
|
+
await loadDeliverySettings(root);
|
|
138
|
+
for (const body of ["tracked", "edited"]) {
|
|
139
|
+
writeFileSync(
|
|
140
|
+
join(root, "ai-delivery.policy.mjs"),
|
|
141
|
+
`import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},${JSON.stringify(body)});export const deliverySettings={};`
|
|
142
|
+
);
|
|
143
|
+
await loadDeliveryConfig(root, {
|
|
144
|
+
repository: "example/widget",
|
|
145
|
+
clients: syntheticDiscoveryClients(syntheticDiscoveryConfig)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
assert.equal(existsSync(sentinel), false);
|
|
149
|
+
} finally {
|
|
150
|
+
if (previous === void 0) delete process.env.AI_DELIVERY_CONFIG;
|
|
151
|
+
else process.env.AI_DELIVERY_CONFIG = previous;
|
|
152
|
+
rmSync(root, { recursive: true, force: true });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
it("names a missing user setting before accessing Git or credentials", async () => {
|
|
156
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-setting-"));
|
|
157
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
158
|
+
try {
|
|
159
|
+
process.env.AI_DELIVERY_CONFIG = join(root, "user.json");
|
|
160
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify({ ...userSettings, roles: {} }));
|
|
161
|
+
await assert.rejects(loadDeliverySettings(root), /roles.author/u);
|
|
162
|
+
} finally {
|
|
163
|
+
if (previous === void 0) delete process.env.AI_DELIVERY_CONFIG;
|
|
164
|
+
else process.env.AI_DELIVERY_CONFIG = previous;
|
|
165
|
+
rmSync(root, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
});
|
|
148
168
|
});
|
|
149
169
|
for (const path of [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
"schemaVersion",
|
|
171
|
+
"roles.author",
|
|
172
|
+
"roles.reviewer",
|
|
173
|
+
"roles.author.identity",
|
|
174
|
+
"roles.reviewer.identity",
|
|
175
|
+
"roles.author.credentialEnv",
|
|
176
|
+
"roles.reviewer.credentialEnv",
|
|
177
|
+
"project",
|
|
178
|
+
"checkoutRoots",
|
|
179
|
+
"roles.author.credentialEnv.token",
|
|
180
|
+
"roles.reviewer.credentialEnv.appId",
|
|
181
|
+
"roles.reviewer.credentialEnv.installationId",
|
|
182
|
+
"roles.reviewer.credentialEnv.privateKeyPath"
|
|
163
183
|
]) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
184
|
+
it(`names missing ${path} in operator settings`, async () => {
|
|
185
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-required-"));
|
|
186
|
+
vi.stubEnv("AI_DELIVERY_CONFIG", join(root, "user.json"));
|
|
187
|
+
const settings = structuredClone(userSettings);
|
|
188
|
+
const keys = path.split(".");
|
|
189
|
+
let target = settings;
|
|
190
|
+
for (const key of keys.slice(0, -1)) target = target[key];
|
|
191
|
+
delete target[keys.at(-1)];
|
|
192
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(settings));
|
|
193
|
+
try {
|
|
194
|
+
await assert.rejects(
|
|
195
|
+
loadDeliverySettings(root),
|
|
196
|
+
(error) => error instanceof Error && error.message.includes(path)
|
|
197
|
+
);
|
|
198
|
+
} finally {
|
|
199
|
+
rmSync(root, { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
});
|
|
181
202
|
}
|
|
182
203
|
afterEach(() => {
|
|
183
|
-
|
|
184
|
-
|
|
204
|
+
vi.restoreAllMocks();
|
|
205
|
+
vi.unstubAllEnvs();
|
|
185
206
|
});
|
|
186
|
-
describe(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
describe("per-call repository selection", () => {
|
|
208
|
+
it("selects matching origins A \u2192 B \u2192 A, prefers a matching current checkout and refuses ambiguous clones", () => {
|
|
209
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), "delivery-checkouts-")));
|
|
210
|
+
const clone = (name, repo) => {
|
|
211
|
+
const path = join(root, name);
|
|
212
|
+
execFileSync("git", ["init", "-q", path]);
|
|
213
|
+
execFileSync("git", ["remote", "add", "origin", `https://github.com/${repo}.git`], { cwd: path });
|
|
214
|
+
return path;
|
|
215
|
+
};
|
|
216
|
+
try {
|
|
217
|
+
const a = clone("a", "example/a"), b = clone("b", "example/b");
|
|
218
|
+
const input = { launchDirectory: root, checkoutRoots: [root] };
|
|
219
|
+
assert.equal(repository.resolveCheckout({ ...input, repository: "example/a" }), a);
|
|
220
|
+
assert.equal(repository.resolveCheckout({ ...input, repository: "example/b" }), b);
|
|
221
|
+
assert.equal(repository.resolveCheckout({ ...input, repository: "example/a" }), a);
|
|
222
|
+
clone("a-duplicate", "example/a");
|
|
223
|
+
assert.throws(() => repository.resolveCheckout({ ...input, repository: "example/a" }), /ambiguous/u);
|
|
224
|
+
assert.equal(repository.resolveCheckout({ ...input, repository: "example/a", launchDirectory: a }), a);
|
|
225
|
+
assert.throws(() => repository.resolveCheckout({ ...input, repository: "example/missing" }), /no matching/u);
|
|
226
|
+
} finally {
|
|
227
|
+
rmSync(root, { recursive: true, force: true });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
it("does not execute checkout filters or fsmonitor during local Git probes", () => {
|
|
231
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-hostile-git-"));
|
|
232
|
+
const sentinel = join(root, "executed");
|
|
233
|
+
const git = (...args) => execFileSync("git", args, { cwd: root });
|
|
234
|
+
try {
|
|
235
|
+
git("init", "-q");
|
|
236
|
+
git("config", "user.name", "Synthetic");
|
|
237
|
+
git("config", "user.email", "synthetic@example.test");
|
|
238
|
+
writeFileSync(join(root, ".gitattributes"), "*.txt filter=hostile\n");
|
|
239
|
+
writeFileSync(join(root, "change.txt"), "original");
|
|
240
|
+
git("add", ".");
|
|
241
|
+
git("commit", "-qm", "fixture");
|
|
242
|
+
const script = join(root, "hostile.cjs");
|
|
243
|
+
writeFileSync(
|
|
244
|
+
script,
|
|
245
|
+
`require('node:fs').writeFileSync(${JSON.stringify(sentinel)},'executed');process.stdin.pipe(process.stdout);`
|
|
246
|
+
);
|
|
247
|
+
git("config", "filter.hostile.clean", `${process.execPath} ${script}`);
|
|
248
|
+
git("config", "filter.hostile.smudge", `${process.execPath} ${script}`);
|
|
249
|
+
git("config", "core.fsmonitor", `${process.execPath} ${script}`);
|
|
250
|
+
mkdirSync(join(root, ".git", "hooks"), { recursive: true });
|
|
251
|
+
writeFileSync(join(root, "change.txt"), "changed");
|
|
252
|
+
git("hash-object", "--path", "change.txt", "change.txt");
|
|
253
|
+
assert.equal(existsSync(sentinel), true, "fixture filter must be executable before the protected probe");
|
|
254
|
+
unlinkSync(sentinel);
|
|
255
|
+
gitCommands.git(root, "hash-object", "--path", "change.txt", "change.txt");
|
|
256
|
+
assert.throws(() => gitCommands.assertClean(root));
|
|
257
|
+
assert.equal(existsSync(sentinel), false);
|
|
258
|
+
} finally {
|
|
259
|
+
rmSync(root, { recursive: true, force: true });
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
it("routes PRs and journals through one MCP server A \u2192 B \u2192 A without launch Git or identity environment", async () => {
|
|
263
|
+
const root = mkdtempSync(join(tmpdir(), "delivery-mcp-routing-"));
|
|
264
|
+
const visited = [];
|
|
265
|
+
const journalTargets = [];
|
|
266
|
+
const stored = [];
|
|
267
|
+
let authorCalls = 0;
|
|
268
|
+
vi.stubEnv("AI_DELIVERY_CONFIG", join(root, "user.json"));
|
|
269
|
+
vi.stubEnv("AI_DELIVERY_IDENTITY", "");
|
|
270
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
271
|
+
vi.spyOn(repository, "resolveRepoFromRemote").mockImplementation(() => {
|
|
272
|
+
throw new Error("launch Git must never run");
|
|
209
273
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const sentinel = join(root, 'executed');
|
|
213
|
-
const git = (...args) => execFileSync('git', args, { cwd: root });
|
|
214
|
-
try {
|
|
215
|
-
git('init', '-q');
|
|
216
|
-
git('config', 'user.name', 'Synthetic');
|
|
217
|
-
git('config', 'user.email', 'synthetic@example.test');
|
|
218
|
-
writeFileSync(join(root, '.gitattributes'), '*.txt filter=hostile\n');
|
|
219
|
-
writeFileSync(join(root, 'change.txt'), 'original');
|
|
220
|
-
git('add', '.');
|
|
221
|
-
git('commit', '-qm', 'fixture');
|
|
222
|
-
const script = join(root, 'hostile.cjs');
|
|
223
|
-
writeFileSync(script, `require('node:fs').writeFileSync(${JSON.stringify(sentinel)},'executed');process.stdin.pipe(process.stdout);`);
|
|
224
|
-
git('config', 'filter.hostile.clean', `${process.execPath} ${script}`);
|
|
225
|
-
git('config', 'filter.hostile.smudge', `${process.execPath} ${script}`);
|
|
226
|
-
git('config', 'core.fsmonitor', `${process.execPath} ${script}`);
|
|
227
|
-
mkdirSync(join(root, '.git', 'hooks'), { recursive: true });
|
|
228
|
-
writeFileSync(join(root, 'change.txt'), 'changed');
|
|
229
|
-
git('hash-object', '--path', 'change.txt', 'change.txt');
|
|
230
|
-
assert.equal(existsSync(sentinel), true, 'fixture filter must be executable before the protected probe');
|
|
231
|
-
unlinkSync(sentinel);
|
|
232
|
-
gitCommands.git(root, 'hash-object', '--path', 'change.txt', 'change.txt');
|
|
233
|
-
assert.throws(() => gitCommands.assertClean(root));
|
|
234
|
-
assert.equal(existsSync(sentinel), false);
|
|
235
|
-
}
|
|
236
|
-
finally {
|
|
237
|
-
rmSync(root, { recursive: true, force: true });
|
|
238
|
-
}
|
|
274
|
+
vi.spyOn(gitCommands, "git").mockImplementation(() => {
|
|
275
|
+
throw new Error("launch Git must never run");
|
|
239
276
|
});
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return { actorLogin: 'operator', credentialIdentity: 'user:1' };
|
|
277
|
+
vi.spyOn(githubClients, "createDeliveryGitHubClients").mockImplementation(
|
|
278
|
+
async (input) => ({
|
|
279
|
+
role: input.role,
|
|
280
|
+
authSource: "personal",
|
|
281
|
+
authenticatedAuthor: async () => {
|
|
282
|
+
authorCalls += 1;
|
|
283
|
+
return { actorLogin: "operator", credentialIdentity: "user:1" };
|
|
284
|
+
},
|
|
285
|
+
graphql: (async (query, variables) => {
|
|
286
|
+
const repo = typeof variables.repo === "string" ? variables.repo : "a";
|
|
287
|
+
return syntheticDiscoveryClients({ ...syntheticDiscoveryConfig, repository: `example/${repo}` }).graphql(
|
|
288
|
+
query,
|
|
289
|
+
variables
|
|
290
|
+
);
|
|
291
|
+
}),
|
|
292
|
+
rest: {
|
|
293
|
+
issues: {
|
|
294
|
+
get: async (input2) => {
|
|
295
|
+
journalTargets.push(`${input2.owner}/${input2.repo}`);
|
|
296
|
+
return { data: { number: input2.issue_number } };
|
|
261
297
|
},
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
298
|
+
listComments: async (input2) => ({
|
|
299
|
+
data: stored.filter(
|
|
300
|
+
(comment) => comment.issue_url === `https://api.github.com/repos/${input2.owner}/${input2.repo}/issues/${String(input2.issue_number)}`
|
|
301
|
+
)
|
|
265
302
|
}),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const id = 101 + stored.length;
|
|
278
|
-
const data = {
|
|
279
|
-
id,
|
|
280
|
-
body: input.body,
|
|
281
|
-
html_url: `https://github.com/${input.owner}/${input.repo}/issues/${String(input.issue_number)}#issuecomment-${String(id)}`,
|
|
282
|
-
issue_url: `https://api.github.com/repos/${input.owner}/${input.repo}/issues/${String(input.issue_number)}`,
|
|
283
|
-
user: { login: 'operator' },
|
|
284
|
-
};
|
|
285
|
-
stored.push(data);
|
|
286
|
-
return { data };
|
|
287
|
-
},
|
|
288
|
-
getComment: async (input) => ({
|
|
289
|
-
data: stored.find((comment) => comment.id === input.comment_id &&
|
|
290
|
-
comment.issue_url === `https://api.github.com/repos/${input.owner}/${input.repo}/issues/17`),
|
|
291
|
-
}),
|
|
292
|
-
},
|
|
293
|
-
pulls: {
|
|
294
|
-
get: async (input) => {
|
|
295
|
-
visited.push(`${input.owner}/${input.repo}`);
|
|
296
|
-
return {
|
|
297
|
-
data: {
|
|
298
|
-
number: input.pull_number,
|
|
299
|
-
head: { sha: 'a'.repeat(40), ref: 'issue/17', repo: { full_name: `${input.owner}/${input.repo}` } },
|
|
300
|
-
base: { sha: 'b'.repeat(40), ref: 'main', repo: { full_name: `${input.owner}/${input.repo}` } },
|
|
301
|
-
state: 'open',
|
|
302
|
-
merged: false,
|
|
303
|
-
draft: true,
|
|
304
|
-
html_url: `https://github.com/${input.owner}/${input.repo}/pull/23`,
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
},
|
|
308
|
-
},
|
|
303
|
+
createComment: async (input2) => {
|
|
304
|
+
const id = 101 + stored.length;
|
|
305
|
+
const data = {
|
|
306
|
+
id,
|
|
307
|
+
body: input2.body,
|
|
308
|
+
html_url: `https://github.com/${input2.owner}/${input2.repo}/issues/${String(input2.issue_number)}#issuecomment-${String(id)}`,
|
|
309
|
+
issue_url: `https://api.github.com/repos/${input2.owner}/${input2.repo}/issues/${String(input2.issue_number)}`,
|
|
310
|
+
user: { login: "operator" }
|
|
311
|
+
};
|
|
312
|
+
stored.push(data);
|
|
313
|
+
return { data };
|
|
309
314
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const response = await client.callTool({ name: 'issue_pr_info', arguments: { repo, prNumber: 23 } });
|
|
331
|
-
assert.equal(response.isError, undefined);
|
|
332
|
-
const comment = await client.callTool({ name: 'issue_comment', arguments: { ...journal, repo } });
|
|
333
|
-
assert.equal(comment.isError, undefined, JSON.stringify(comment));
|
|
334
|
-
assert.match(JSON.stringify(comment), new RegExp(`https://github.com/${repo}/issues/17#issuecomment-10[12]`, 'u'));
|
|
335
|
-
}
|
|
336
|
-
await executeTool('issue_pr_info', { repo: 'example/b', prNumber: 23 }, { repoRoot: root });
|
|
337
|
-
assert.deepEqual(visited, ['example/a', 'example/b', 'example/a', 'example/b']);
|
|
338
|
-
assert.deepEqual(journalTargets, ['example/a', 'example/b', 'example/a']);
|
|
339
|
-
assert.equal(stored.length, 2, 'A retry reuses its own journal, without leaking repository B');
|
|
340
|
-
const beforeInvalid = vi.mocked(githubClients.createDeliveryGitHubClients).mock.calls.length;
|
|
341
|
-
const beforeInvalidAuthor = authorCalls;
|
|
342
|
-
for (const invalid of [
|
|
343
|
-
{ ...journal, repo: 'example/a', unknown: true },
|
|
344
|
-
{ ...journal, repo: 'example/a', outcome: 'Wrong variant' },
|
|
345
|
-
{ ...journal, repo: 'example/a', kind: 'unsupported' },
|
|
346
|
-
{ ...journal, repo: 'example/a', nextDate: '2026-02-30' },
|
|
347
|
-
{ ...journal, repo: 'invalid' },
|
|
348
|
-
]) {
|
|
349
|
-
const refused = await client.callTool({ name: 'issue_comment', arguments: invalid }).then((result) => result.isError === true, () => true);
|
|
350
|
-
assert.equal(refused, true);
|
|
351
|
-
}
|
|
352
|
-
const fixedServer = createAiDeliveryMcpServer({ repoRoot: root, repo: 'example/a' });
|
|
353
|
-
const fixedClient = new Client({ name: 'fixed-repository-fixture', version: '1' });
|
|
354
|
-
const [fixedClientTransport, fixedServerTransport] = InMemoryTransport.createLinkedPair();
|
|
355
|
-
try {
|
|
356
|
-
await fixedServer.connect(fixedServerTransport);
|
|
357
|
-
await fixedClient.connect(fixedClientTransport);
|
|
358
|
-
const conflict = await fixedClient.callTool({
|
|
359
|
-
name: 'issue_comment',
|
|
360
|
-
arguments: { ...journal, repo: 'example/b' },
|
|
361
|
-
});
|
|
362
|
-
assert.equal(conflict.isError, true);
|
|
363
|
-
assert.match(JSON.stringify(conflict), /selectors disagree/u);
|
|
364
|
-
assert.equal(vi.mocked(githubClients.createDeliveryGitHubClients).mock.calls.length, beforeInvalid);
|
|
365
|
-
assert.equal(authorCalls, beforeInvalidAuthor, 'refusals precede authentication');
|
|
366
|
-
assert.equal(stored.length, 2, 'refusals do not write');
|
|
367
|
-
assert.deepEqual(journalTargets, ['example/a', 'example/b', 'example/a'], 'refusals do not read a target');
|
|
368
|
-
const inherited = await fixedClient.callTool({ name: 'issue_comment', arguments: journal });
|
|
369
|
-
assert.equal(inherited.isError, undefined, JSON.stringify(inherited));
|
|
370
|
-
const readback = JSON.parse(inherited.content[0].text);
|
|
371
|
-
assert.equal(readback.url, 'https://github.com/example/a/issues/17#issuecomment-101');
|
|
372
|
-
assert.equal(readback.reused, true, 'omitting repo uses the fixed server selector');
|
|
315
|
+
getComment: async (input2) => ({
|
|
316
|
+
data: stored.find(
|
|
317
|
+
(comment) => comment.id === input2.comment_id && comment.issue_url === `https://api.github.com/repos/${input2.owner}/${input2.repo}/issues/17`
|
|
318
|
+
)
|
|
319
|
+
})
|
|
320
|
+
},
|
|
321
|
+
pulls: {
|
|
322
|
+
get: async (input2) => {
|
|
323
|
+
visited.push(`${input2.owner}/${input2.repo}`);
|
|
324
|
+
return {
|
|
325
|
+
data: {
|
|
326
|
+
number: input2.pull_number,
|
|
327
|
+
head: { sha: "a".repeat(40), ref: "issue/17", repo: { full_name: `${input2.owner}/${input2.repo}` } },
|
|
328
|
+
base: { sha: "b".repeat(40), ref: "main", repo: { full_name: `${input2.owner}/${input2.repo}` } },
|
|
329
|
+
state: "open",
|
|
330
|
+
merged: false,
|
|
331
|
+
draft: true,
|
|
332
|
+
html_url: `https://github.com/${input2.owner}/${input2.repo}/pull/23`
|
|
333
|
+
}
|
|
334
|
+
};
|
|
373
335
|
}
|
|
374
|
-
|
|
375
|
-
await fixedClient.close();
|
|
376
|
-
await fixedServer.close();
|
|
377
|
-
}
|
|
378
|
-
assert.equal(stored.length, 2, 'inheriting the server selector reuses repository A');
|
|
379
|
-
assert.deepEqual(journalTargets, ['example/a', 'example/b', 'example/a', 'example/a']);
|
|
380
|
-
assert.equal(vi.mocked(repository.resolveRepoFromRemote).mock.calls.length, 0);
|
|
381
|
-
const names = AI_DELIVERY_MCP_TOOLS.map((tool) => tool.name);
|
|
382
|
-
for (const removed of ['issue_develop', 'issue_verify', 'issue_worktree_create'])
|
|
383
|
-
assert.equal(names.includes(removed), false);
|
|
384
|
-
for (const retained of [
|
|
385
|
-
'runtime_stage',
|
|
386
|
-
'runtime_admit',
|
|
387
|
-
'issue_worktree_transition_inspect',
|
|
388
|
-
'issue_worktree_transition_apply',
|
|
389
|
-
])
|
|
390
|
-
assert.equal(names.includes(retained), true);
|
|
391
|
-
}
|
|
392
|
-
finally {
|
|
393
|
-
await client.close();
|
|
394
|
-
await server.close();
|
|
395
|
-
rmSync(root, { recursive: true, force: true });
|
|
336
|
+
}
|
|
396
337
|
}
|
|
397
|
-
|
|
338
|
+
})
|
|
339
|
+
);
|
|
340
|
+
const server = createAiDeliveryMcpServer({ repoRoot: root });
|
|
341
|
+
const client = new Client({ name: "directory-fixture", version: "1" });
|
|
342
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
343
|
+
const journal = {
|
|
344
|
+
issueNumber: 17,
|
|
345
|
+
kind: "progress",
|
|
346
|
+
summary: "Validation is implemented.",
|
|
347
|
+
status: "In progress",
|
|
348
|
+
done: ["Added validation"],
|
|
349
|
+
decisionNeeded: "None",
|
|
350
|
+
keyNumbers: [],
|
|
351
|
+
evidence: ["https://github.com/example/widget/pull/23"],
|
|
352
|
+
nextStep: "Review",
|
|
353
|
+
nextDate: "2026-10-09"
|
|
354
|
+
};
|
|
355
|
+
try {
|
|
356
|
+
await server.connect(serverTransport);
|
|
357
|
+
await client.connect(clientTransport);
|
|
358
|
+
for (const repo of ["example/a", "example/b", "example/a"]) {
|
|
359
|
+
const response = await client.callTool({ name: "issue_pr_info", arguments: { repo, prNumber: 23 } });
|
|
360
|
+
assert.equal(response.isError, void 0);
|
|
361
|
+
const comment = await client.callTool({ name: "issue_comment", arguments: { ...journal, repo } });
|
|
362
|
+
assert.equal(comment.isError, void 0, JSON.stringify(comment));
|
|
363
|
+
assert.match(
|
|
364
|
+
JSON.stringify(comment),
|
|
365
|
+
new RegExp(`https://github.com/${repo}/issues/17#issuecomment-10[12]`, "u")
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
await executeTool("issue_pr_info", { repo: "example/b", prNumber: 23 }, { repoRoot: root });
|
|
369
|
+
assert.deepEqual(visited, ["example/a", "example/b", "example/a", "example/b"]);
|
|
370
|
+
assert.deepEqual(journalTargets, ["example/a", "example/b", "example/a"]);
|
|
371
|
+
assert.equal(stored.length, 2, "A retry reuses its own journal, without leaking repository B");
|
|
372
|
+
const beforeInvalid = vi.mocked(githubClients.createDeliveryGitHubClients).mock.calls.length;
|
|
373
|
+
const beforeInvalidAuthor = authorCalls;
|
|
374
|
+
for (const invalid of [
|
|
375
|
+
{ ...journal, repo: "example/a", unknown: true },
|
|
376
|
+
{ ...journal, repo: "example/a", outcome: "Wrong variant" },
|
|
377
|
+
{ ...journal, repo: "example/a", kind: "unsupported" },
|
|
378
|
+
{ ...journal, repo: "example/a", nextDate: "2026-02-30" },
|
|
379
|
+
{ ...journal, repo: "invalid" }
|
|
380
|
+
]) {
|
|
381
|
+
const refused = await client.callTool({ name: "issue_comment", arguments: invalid }).then(
|
|
382
|
+
(result) => result.isError === true,
|
|
383
|
+
() => true
|
|
384
|
+
);
|
|
385
|
+
assert.equal(refused, true);
|
|
386
|
+
}
|
|
387
|
+
const fixedServer = createAiDeliveryMcpServer({ repoRoot: root, repo: "example/a" });
|
|
388
|
+
const fixedClient = new Client({ name: "fixed-repository-fixture", version: "1" });
|
|
389
|
+
const [fixedClientTransport, fixedServerTransport] = InMemoryTransport.createLinkedPair();
|
|
390
|
+
try {
|
|
391
|
+
await fixedServer.connect(fixedServerTransport);
|
|
392
|
+
await fixedClient.connect(fixedClientTransport);
|
|
393
|
+
const conflict = await fixedClient.callTool({
|
|
394
|
+
name: "issue_comment",
|
|
395
|
+
arguments: { ...journal, repo: "example/b" }
|
|
396
|
+
});
|
|
397
|
+
assert.equal(conflict.isError, true);
|
|
398
|
+
assert.match(JSON.stringify(conflict), /selectors disagree/u);
|
|
399
|
+
assert.equal(vi.mocked(githubClients.createDeliveryGitHubClients).mock.calls.length, beforeInvalid);
|
|
400
|
+
assert.equal(authorCalls, beforeInvalidAuthor, "refusals precede authentication");
|
|
401
|
+
assert.equal(stored.length, 2, "refusals do not write");
|
|
402
|
+
assert.deepEqual(journalTargets, ["example/a", "example/b", "example/a"], "refusals do not read a target");
|
|
403
|
+
const inherited = await fixedClient.callTool({ name: "issue_comment", arguments: journal });
|
|
404
|
+
assert.equal(inherited.isError, void 0, JSON.stringify(inherited));
|
|
405
|
+
const readback = JSON.parse(inherited.content[0].text);
|
|
406
|
+
assert.equal(readback.url, "https://github.com/example/a/issues/17#issuecomment-101");
|
|
407
|
+
assert.equal(readback.reused, true, "omitting repo uses the fixed server selector");
|
|
408
|
+
} finally {
|
|
409
|
+
await fixedClient.close();
|
|
410
|
+
await fixedServer.close();
|
|
411
|
+
}
|
|
412
|
+
assert.equal(stored.length, 2, "inheriting the server selector reuses repository A");
|
|
413
|
+
assert.deepEqual(journalTargets, ["example/a", "example/b", "example/a", "example/a"]);
|
|
414
|
+
assert.equal(vi.mocked(repository.resolveRepoFromRemote).mock.calls.length, 0);
|
|
415
|
+
const names = AI_DELIVERY_MCP_TOOLS.map((tool) => tool.name);
|
|
416
|
+
for (const removed of [
|
|
417
|
+
"issue_develop",
|
|
418
|
+
"issue_verify",
|
|
419
|
+
"issue_worktree_create",
|
|
420
|
+
"runtime_stage",
|
|
421
|
+
"runtime_admit",
|
|
422
|
+
"issue_worktree_transition_inspect",
|
|
423
|
+
"issue_worktree_transition_apply"
|
|
424
|
+
])
|
|
425
|
+
assert.equal(names.includes(removed), false);
|
|
426
|
+
} finally {
|
|
427
|
+
await client.close();
|
|
428
|
+
await server.close();
|
|
429
|
+
rmSync(root, { recursive: true, force: true });
|
|
430
|
+
}
|
|
431
|
+
});
|
|
398
432
|
});
|
|
399
|
-
//# sourceMappingURL=directoryIndependent.test.js.map
|
|
433
|
+
//# sourceMappingURL=directoryIndependent.test.js.map
|