@aviaratech/ai-delivery 0.3.34 → 0.3.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +12 -206
- package/README.md +57 -506
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1746 -0
- package/dist/boardReconcile.test.js.map +7 -0
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +406 -485
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -25
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +434 -297
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +320 -14
- package/dist/config/deliveryConfig.js +472 -385
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +775 -584
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -477
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.d.ts +1 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +17 -12
- package/dist/dispatch.js +330 -322
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +16 -3
- package/dist/errors.js +104 -82
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +59 -19
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.js +73 -67
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +44 -51
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +3 -0
- package/dist/github/discovery.js +197 -201
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +53 -1
- package/dist/github/projectDelivery.js +623 -460
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.d.ts +5 -2
- package/dist/github/relationships.js +434 -333
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +103 -7
- package/dist/issue.js +2104 -1547
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +1004 -683
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1945 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1088 -593
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -90
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +790 -220
- package/dist/mcp/tools.js +267 -333
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1231
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1822 -1283
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +485 -305
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +1204 -0
- package/dist/services/boardReconcileService.js +1445 -0
- package/dist/services/boardReconcileService.js.map +7 -0
- package/dist/services/deliveryAdmission.d.ts +2 -0
- package/dist/services/deliveryAdmission.js +129 -152
- package/dist/services/deliveryAdmission.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +354 -350
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -19
- package/dist/verification.js +1020 -1929
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.d.ts +6 -0
- package/dist/version.js +24 -10
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +10 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +261 -43
- package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3058
- package/dist/setup.test.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → boardReconcile.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
|
@@ -1,128 +1,159 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { execFileSync } from
|
|
3
|
-
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from
|
|
4
|
-
import { tmpdir } from
|
|
5
|
-
import { join } from
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from
|
|
7
|
-
import { Client } from
|
|
8
|
-
import { StdioClientTransport } from
|
|
9
|
-
import { test } from
|
|
10
|
-
import pkg from
|
|
11
|
-
import { AI_DELIVERY_MCP_TOOLS } from
|
|
12
|
-
import { buildRuntimeAdmission, validateRuntimeAdmission } from
|
|
13
|
-
import { retainedWorktreeTransitionProducerDigest } from
|
|
14
|
-
import { syntheticDiscoveryConfig } from
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
3
|
+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
9
|
+
import { test } from "vitest";
|
|
10
|
+
import pkg from "../package.json" with { type: "json" };
|
|
11
|
+
import { AI_DELIVERY_MCP_TOOLS } from "./mcp/tools.js";
|
|
12
|
+
import { buildRuntimeAdmission, validateRuntimeAdmission } from "./services/deliveryAdmission.js";
|
|
13
|
+
import { retainedWorktreeTransitionProducerDigest } from "./verification.js";
|
|
14
|
+
import { syntheticDiscoveryConfig } from "./fixtures/discovery.js";
|
|
15
|
+
import { BoardReconcilePlanSchema, BoardReconcileResultSchema } from "./services/boardReconcileService.js";
|
|
16
|
+
const packageRoot = fileURLToPath(new URL("../", import.meta.url));
|
|
17
|
+
const pluginRoot = join(packageRoot, "plugins", "ai-delivery");
|
|
18
|
+
const qualificationOwner = await import(new URL("../scripts/current-qualification.mjs", import.meta.url).href);
|
|
19
|
+
test(
|
|
20
|
+
"README and delivery skill CLI examples name supported commands and required options",
|
|
21
|
+
{ tags: ["release"] },
|
|
22
|
+
() => {
|
|
23
|
+
const cli = readFileSync(join(packageRoot, "src", "cli.ts"), "utf8");
|
|
19
24
|
const declarations = [...cli.matchAll(/\.command\('([^']+)'\)/gu)];
|
|
20
|
-
const required = new Map(
|
|
21
|
-
|
|
25
|
+
const required = new Map(
|
|
26
|
+
declarations.map((match) => {
|
|
27
|
+
const next = cli.indexOf(".command(", match.index + match[0].length);
|
|
22
28
|
return [
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
match[1],
|
|
30
|
+
[...cli.slice(match.index, next < 0 ? void 0 : next).matchAll(/\.requiredOption\('--([a-z0-9-]+)/gu)].map(
|
|
31
|
+
(option) => `--${option[1]}`
|
|
32
|
+
)
|
|
25
33
|
];
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
const globals = /* @__PURE__ */ new Set(["--repo", "--repo-root", "--identity"]);
|
|
28
37
|
for (const path of [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
"README.md",
|
|
39
|
+
"plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md",
|
|
40
|
+
"plugins/ai-delivery/skills/pr-handoff/SKILL.md"
|
|
32
41
|
]) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const source = readFileSync(join(packageRoot, path), "utf8").replace(/\\\r?\n\s*/gu, " ");
|
|
43
|
+
for (const match of source.matchAll(/^ai-delivery\s+(.+)$/gmu)) {
|
|
44
|
+
const words = match[1].split(/\s+/u);
|
|
45
|
+
let index = 0;
|
|
46
|
+
while (globals.has(words[index] ?? "")) index += 2;
|
|
47
|
+
const command = words[index];
|
|
48
|
+
const commandPath = command === "merge" ? words.slice(index, index + 3) : command === "plugin" ? words.slice(index, index + 2) : [command];
|
|
49
|
+
const help = execFileSync(process.execPath, [join(packageRoot, "dist", "cli.js"), ...commandPath, "--help"], {
|
|
50
|
+
encoding: "utf8",
|
|
51
|
+
maxBuffer: 65536
|
|
52
|
+
});
|
|
53
|
+
for (const flag of required.get(command) ?? [])
|
|
54
|
+
assert.ok(words.includes(flag), `${path}: ${command} requires ${flag}`);
|
|
55
|
+
for (const flag of words.filter((word) => word.startsWith("--")))
|
|
56
|
+
assert.ok(globals.has(flag) || help.includes(flag), `${path}: ${command} does not support ${flag}`);
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
|
-
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
49
61
|
for (const launchCheckout of [false, true]) {
|
|
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
|
-
cpSync(join(unpacked, 'package', 'plugins', 'ai-delivery'), selectedPluginRoot, { recursive: true });
|
|
75
|
-
discoveryFixture = pathToFileURL(join(unpacked, 'package', 'dist', 'fixtures', 'discovery.js')).href;
|
|
76
|
-
assert.equal(existsSync(join(selectedPluginRoot, 'runtime', 'dist', 'cli.js')), true);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
rmSync(directory, { recursive: true, force: true });
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (launchCheckout) {
|
|
84
|
-
execFileSync('git', ['init', '-q', directory]);
|
|
85
|
-
execFileSync('git', ['remote', 'add', 'origin', 'https://github.com/example/a.git'], { cwd: directory });
|
|
62
|
+
test(
|
|
63
|
+
`the ${launchCheckout ? "bundled" : "packed"} launcher creates, updates and journals repository B from ${launchCheckout ? "checkout A" : "a non-Git directory"} without an identity environment`,
|
|
64
|
+
{ tags: ["release"] },
|
|
65
|
+
async () => {
|
|
66
|
+
const directory = realpathSync(mkdtempSync(join(tmpdir(), "delivery-launch-routing-")));
|
|
67
|
+
let selectedPluginRoot = pluginRoot;
|
|
68
|
+
let discoveryFixture = new URL("./fixtures/discovery.js", import.meta.url).href;
|
|
69
|
+
if (!launchCheckout) {
|
|
70
|
+
try {
|
|
71
|
+
const archive = qualificationOwner.copyReleaseArchive(
|
|
72
|
+
process.env.AI_DELIVERY_RELEASE_CONTRACT ?? "",
|
|
73
|
+
packageRoot,
|
|
74
|
+
join(directory, "qualified.tgz")
|
|
75
|
+
);
|
|
76
|
+
const unpacked = join(directory, "unpacked");
|
|
77
|
+
mkdirSync(unpacked);
|
|
78
|
+
execFileSync("tar", ["-xzf", archive.archivePath, "-C", unpacked]);
|
|
79
|
+
selectedPluginRoot = join(directory, "plugin-cache");
|
|
80
|
+
cpSync(join(unpacked, "package", "plugins", "ai-delivery"), selectedPluginRoot, { recursive: true });
|
|
81
|
+
discoveryFixture = pathToFileURL(join(unpacked, "package", "dist", "fixtures", "discovery.js")).href;
|
|
82
|
+
assert.equal(existsSync(join(selectedPluginRoot, "runtime", "dist", "cli.js")), true);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
rmSync(directory, { recursive: true, force: true });
|
|
85
|
+
throw error;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
87
|
+
}
|
|
88
|
+
if (launchCheckout) {
|
|
89
|
+
execFileSync("git", ["init", "-q", directory]);
|
|
90
|
+
execFileSync("git", ["remote", "add", "origin", "https://github.com/example/a.git"], { cwd: directory });
|
|
91
|
+
}
|
|
92
|
+
const preload = join(directory, "mock-github.mjs");
|
|
93
|
+
const calls = join(directory, "requests.json");
|
|
94
|
+
const settings = join(directory, "user.json");
|
|
95
|
+
const boardStatePath = join(directory, "board-state.json");
|
|
96
|
+
writeFileSync(boardStatePath, JSON.stringify({ member: "ITEM17", status: "Todo", writes: [] }));
|
|
97
|
+
writeFileSync(
|
|
98
|
+
settings,
|
|
99
|
+
JSON.stringify({
|
|
100
|
+
schemaVersion: "ai-delivery.user@1",
|
|
101
|
+
roles: {
|
|
102
|
+
author: { authSource: "personal", identity: "operator", credentialEnv: { token: "SYNTHETIC_TOKEN" } },
|
|
103
|
+
reviewer: {
|
|
104
|
+
identity: "reviewer",
|
|
105
|
+
credentialEnv: { appId: "REVIEW_APP", installationId: "REVIEW_INSTALL", privateKeyPath: "REVIEW_KEY" }
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
project: 1,
|
|
109
|
+
checkoutRoots: [],
|
|
110
|
+
pointsField: "Estimate",
|
|
111
|
+
priorityField: "Urgency",
|
|
112
|
+
statusField: "Flow",
|
|
113
|
+
statuses: syntheticDiscoveryConfig.native.project.statuses
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
writeFileSync(
|
|
117
|
+
preload,
|
|
118
|
+
`
|
|
119
|
+
import {existsSync,readFileSync,writeFileSync} from 'node:fs';
|
|
108
120
|
import {syntheticDiscoveryClients} from ${JSON.stringify(discoveryFixture)};
|
|
109
121
|
const configuration=${JSON.stringify(syntheticDiscoveryConfig)};
|
|
110
|
-
const requests=[];
|
|
111
122
|
const comments=[];
|
|
112
123
|
const fields=[configuration.native.points,configuration.native.priority].map(field=>({id:Number(field.databaseId),name:field.name,data_type:'single_select',options:field.values.map(name=>({name:String(name)}))}));
|
|
113
124
|
let fieldValues=[];
|
|
114
125
|
let issue={id:117,number:17,node_id:'ISSUE17',title:'Widget',body:'',state:'open',labels:[],html_url:'https://github.com/example/b/issues/17'};
|
|
115
126
|
const page=nodes=>({nodes,pageInfo:{hasNextPage:false,endCursor:null}});
|
|
116
127
|
globalThis.fetch=async(url,init)=>{
|
|
128
|
+
const requests=existsSync(${JSON.stringify(calls)})?JSON.parse(readFileSync(${JSON.stringify(calls)},'utf8')):[];
|
|
129
|
+
const boardState=JSON.parse(readFileSync(${JSON.stringify(boardStatePath)},'utf8'));
|
|
130
|
+
const saveBoard=()=>writeFileSync(${JSON.stringify(boardStatePath)},JSON.stringify(boardState));
|
|
117
131
|
const path=new URL(String(url)).pathname;const method=init?.method??'GET';
|
|
118
132
|
requests.push({path,method});writeFileSync(${JSON.stringify(calls)},JSON.stringify(requests));
|
|
119
133
|
const json=init?.body?JSON.parse(init.body):{};
|
|
120
134
|
let data;
|
|
121
135
|
if(path==='/graphql'){
|
|
122
136
|
const query=json.query;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
const item=()=>({id:boardState.member,isArchived:false,project:{id:'PROJECT-1',number:1},content:{__typename:'Issue',id:'ISSUE17',number:17,repository:{nameWithOwner:'example/b'}},fieldValueByName:boardState.status===null?null:{name:'Queued',optionId:'STATUS-0'}});
|
|
138
|
+
if(boardState.failDiscovery==='access'&&query.includes('DeliveryRepository'))return new Response(JSON.stringify({message:'Synthetic access denied'}),{status:403,headers:{'content-type':'application/json'}});
|
|
139
|
+
if(query.includes('AddProjectDeliveryItem')){
|
|
140
|
+
boardState.member='ADDED17';boardState.status='Todo';boardState.writes.push('add');
|
|
141
|
+
const lost=boardState.failAddResponse;boardState.failAddResponse=false;saveBoard();
|
|
142
|
+
if(lost)throw new Error('Synthetic lost add response');
|
|
143
|
+
data={addProjectV2ItemById:{item:{id:boardState.member}}};
|
|
144
|
+
}
|
|
145
|
+
else if(query.includes('ProjectDeliveryIssueItems'))data={node:{id:json.variables.issueNodeId,projectItems:{nodes:boardState.member?[item()]:[],pageInfo:{hasNextPage:false}}}};
|
|
146
|
+
else if(query.includes('ProjectDeliveryItems'))data={organization:{projectV2:{id:'PROJECT-1',number:1,items:page(boardState.member?[item()]:[])}}};
|
|
147
|
+
else if(query.includes('ProjectDeliveryItemReadback'))data={node:boardState.member===json.variables.itemId?item():null};
|
|
148
|
+
else if(query.includes('blockedBy('))data={repository:{issue:{id:'ISSUE17',number:17,repository:{nameWithOwner:'example/b'},parent:null,blockedBy:page([])}}};
|
|
149
|
+
else if(query.includes('DeliveryIssueBranches'))data={repository:{issue:{linkedBranches:page([])}}};
|
|
150
|
+
else {
|
|
151
|
+
data=await syntheticDiscoveryClients({...configuration,repository:'example/'+(json.variables?.repo??'b')}).graphql(query,json.variables);
|
|
152
|
+
if(boardState.failDiscovery==='pages'&&query.includes('ProjectDeliveryConfiguration')){
|
|
153
|
+
if(json.variables.cursor!=null)data.organization.projectV2.fields.nodes=[];
|
|
154
|
+
data.organization.projectV2.fields.pageInfo={hasNextPage:true,endCursor:'next-'+String(json.variables.cursor??'first')};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
126
157
|
return new Response(JSON.stringify({data}),{status:200,headers:{'content-type':'application/json'}});
|
|
127
158
|
}
|
|
128
159
|
if(path==='/user')data={id:1,login:'operator'};
|
|
@@ -135,233 +166,382 @@ globalThis.fetch=async(url,init)=>{
|
|
|
135
166
|
}
|
|
136
167
|
else if(path.includes('/issues/comments/'))data=comments.find(comment=>comment.id===Number(path.split('/').at(-1)));
|
|
137
168
|
else if(path.endsWith('/labels'))data=[{name:'enhancement'},{name:'bug'}];
|
|
169
|
+
else if(path==='/repos/example/b/issues/17/sub_issues'&&method==='GET')data=[];
|
|
138
170
|
else if(path.endsWith('/issue-fields'))data=fields;
|
|
139
171
|
else if(path.endsWith('/issue-field-values')){
|
|
140
172
|
if(method==='POST')fieldValues=json.issue_field_values.map(entry=>({issue_field_id:entry.field_id,issue_field_name:fields.find(field=>field.id===entry.field_id).name,data_type:'single_select',value:entry.value}));
|
|
141
173
|
data=fieldValues;
|
|
142
174
|
}
|
|
143
175
|
else if(path.endsWith('/issues')&&method==='POST'){issue={...issue,...json};data=issue;}
|
|
176
|
+
else if(path.endsWith('/issues')&&method==='GET')data=[issue];
|
|
177
|
+
else if(path.endsWith('/sub_issues'))data=[];
|
|
144
178
|
else if(path.endsWith('/issues/17')){if(method==='PATCH')issue={...issue,...json};data=issue;}
|
|
145
179
|
else throw new Error('Unexpected synthetic request '+method+' '+path);
|
|
146
180
|
return new Response(JSON.stringify(data),{status:200,headers:{'content-type':'application/json'}});
|
|
147
181
|
};
|
|
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
|
-
outOfScope: ['Live authentication and host configuration.'],
|
|
179
|
-
};
|
|
180
|
-
const created = await client.callTool({
|
|
181
|
-
name: 'issue_create',
|
|
182
|
-
arguments: { ...readyInput, labels: ['enhancement'] },
|
|
183
|
-
});
|
|
184
|
-
assert.equal(created.isError, undefined, JSON.stringify(created));
|
|
185
|
-
const updated = await client.callTool({
|
|
186
|
-
name: 'issue_update',
|
|
187
|
-
arguments: { repo: 'example/b', issueNumber: 17, labels: ['bug'] },
|
|
188
|
-
});
|
|
189
|
-
assert.equal(updated.isError, undefined, JSON.stringify(updated));
|
|
190
|
-
const common = {
|
|
191
|
-
repo: 'example/b',
|
|
192
|
-
issueNumber: 17,
|
|
193
|
-
summary: 'Packed journal validation works.',
|
|
194
|
-
status: 'In progress',
|
|
195
|
-
nextStep: 'Independent review',
|
|
196
|
-
nextDate: '2026-10-09',
|
|
197
|
-
keyNumbers: ['5 journal kinds'],
|
|
198
|
-
evidence: ['https://github.com/example/b/issues/17'],
|
|
199
|
-
};
|
|
200
|
-
const journals = [
|
|
201
|
-
{ ...common, kind: 'start', outcome: 'Deliver strict validation' },
|
|
202
|
-
{ ...common, kind: 'progress', done: ['Added regression'], decisionNeeded: 'None' },
|
|
203
|
-
{ ...common, kind: 'decision', decision: 'Keep variants strict', rationale: 'Preserve the contract' },
|
|
204
|
-
{ ...common, kind: 'blocker', blocker: 'Review pending', resolution: 'Independent acceptance' },
|
|
205
|
-
{
|
|
206
|
-
...common,
|
|
207
|
-
kind: 'closeout',
|
|
208
|
-
acceptance: [{ criterion: 'Explicit repo works', evidence: common.evidence[0] }],
|
|
209
|
-
followUps: [],
|
|
210
|
-
},
|
|
211
|
-
];
|
|
212
|
-
const decoded = (response) => JSON.parse(response.content[0].text);
|
|
213
|
-
for (const [index, journal] of journals.entries()) {
|
|
214
|
-
const response = await client.callTool({ name: 'issue_comment', arguments: journal });
|
|
215
|
-
assert.equal(response.isError, undefined, JSON.stringify(response));
|
|
216
|
-
const readback = decoded(response);
|
|
217
|
-
assert.equal(readback.commentId, 91 + index);
|
|
218
|
-
assert.equal(readback.url, `https://github.com/example/b/issues/17#issuecomment-${String(91 + index)}`);
|
|
219
|
-
assert.equal(readback.body.split('\n')[0], common.summary);
|
|
220
|
-
assert.ok(readback.body.includes(`**Kind:** ${journal.kind}.`));
|
|
221
|
-
assert.match(readback.body, /<!-- ai-delivery:journal@1:sha256:[a-f0-9]{64} -->$/u);
|
|
222
|
-
assert.equal(readback.reused, false);
|
|
223
|
-
}
|
|
224
|
-
const retried = await client.callTool({ name: 'issue_comment', arguments: journals[1] });
|
|
225
|
-
assert.equal(retried.isError, undefined, JSON.stringify(retried));
|
|
226
|
-
assert.equal(decoded(retried).commentId, 92);
|
|
227
|
-
assert.equal(decoded(retried).reused, true);
|
|
228
|
-
const beforeInvalidRequests = JSON.parse(readFileSync(calls, 'utf8')).length;
|
|
229
|
-
for (const invalid of [
|
|
230
|
-
{ ...journals[1], unknown: true },
|
|
231
|
-
{ ...journals[1], outcome: 'Wrong variant' },
|
|
232
|
-
{ ...journals[1], kind: 'unsupported' },
|
|
233
|
-
{ ...journals[1], nextDate: '2026-02-30' },
|
|
234
|
-
{ ...journals[1], repo: 'invalid' },
|
|
235
|
-
]) {
|
|
236
|
-
const refused = await client.callTool({ name: 'issue_comment', arguments: invalid }).then((result) => result.isError === true, () => true);
|
|
237
|
-
assert.equal(refused, true);
|
|
182
|
+
`
|
|
183
|
+
);
|
|
184
|
+
const transport = new StdioClientTransport({
|
|
185
|
+
command: process.execPath,
|
|
186
|
+
args: [join(selectedPluginRoot, "dist", "mcp-launcher.js")],
|
|
187
|
+
cwd: directory,
|
|
188
|
+
env: {
|
|
189
|
+
PATH: process.env.PATH ?? "",
|
|
190
|
+
TMPDIR: tmpdir(),
|
|
191
|
+
HOME: directory,
|
|
192
|
+
AI_DELIVERY_CONFIG: settings,
|
|
193
|
+
SYNTHETIC_TOKEN: "inert-personal-token",
|
|
194
|
+
NODE_OPTIONS: `--v8-pool-size=1 --import=${preload}`
|
|
195
|
+
},
|
|
196
|
+
stderr: "pipe"
|
|
197
|
+
});
|
|
198
|
+
const client = new Client({ name: "actual-launch-routing", version: "1" });
|
|
199
|
+
try {
|
|
200
|
+
await client.connect(transport, { timeout: 3e4 });
|
|
201
|
+
const readyInput = {
|
|
202
|
+
repo: "example/b",
|
|
203
|
+
title: "Validate widget launch routing across repositories",
|
|
204
|
+
points: 2,
|
|
205
|
+
problem: "A launcher can bind a widget issue to the checkout repository instead of the explicit caller.",
|
|
206
|
+
outcome: "Create and update the issue only in explicitly selected repository B.",
|
|
207
|
+
acceptanceCriteria: [
|
|
208
|
+
{
|
|
209
|
+
behavior: "Create, update and journal requests address repository B with zero repository A requests.",
|
|
210
|
+
verifiedBy: "Packaged stdio client results and captured REST path assertions."
|
|
238
211
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
212
|
+
],
|
|
213
|
+
outOfScope: ["Live authentication and host configuration."]
|
|
214
|
+
};
|
|
215
|
+
const created = await client.callTool({
|
|
216
|
+
name: "issue_create",
|
|
217
|
+
arguments: { ...readyInput, labels: ["enhancement"] }
|
|
218
|
+
});
|
|
219
|
+
assert.equal(created.isError, void 0, JSON.stringify(created));
|
|
220
|
+
const updated = await client.callTool({
|
|
221
|
+
name: "issue_update",
|
|
222
|
+
arguments: { repo: "example/b", issueNumber: 17, labels: ["bug"] }
|
|
223
|
+
});
|
|
224
|
+
assert.equal(updated.isError, void 0, JSON.stringify(updated));
|
|
225
|
+
const common = {
|
|
226
|
+
repo: "example/b",
|
|
227
|
+
issueNumber: 17,
|
|
228
|
+
summary: "Packed journal validation works.",
|
|
229
|
+
status: "In progress",
|
|
230
|
+
nextStep: "Independent review",
|
|
231
|
+
nextDate: "2026-10-09",
|
|
232
|
+
keyNumbers: ["5 journal kinds"],
|
|
233
|
+
evidence: ["https://github.com/example/b/issues/17"]
|
|
234
|
+
};
|
|
235
|
+
const journals = [
|
|
236
|
+
{ ...common, kind: "start", outcome: "Deliver strict validation" },
|
|
237
|
+
{ ...common, kind: "progress", done: ["Added regression"], decisionNeeded: "None" },
|
|
238
|
+
{ ...common, kind: "decision", decision: "Keep variants strict", rationale: "Preserve the contract" },
|
|
239
|
+
{ ...common, kind: "blocker", blocker: "Review pending", resolution: "Independent acceptance" },
|
|
240
|
+
{
|
|
241
|
+
...common,
|
|
242
|
+
kind: "closeout",
|
|
243
|
+
acceptance: [{ criterion: "Explicit repo works", evidence: common.evidence[0] }],
|
|
244
|
+
followUps: []
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
const decoded = (response) => JSON.parse(response.content[0].text);
|
|
248
|
+
for (const [index, journal] of journals.entries()) {
|
|
249
|
+
const response = await client.callTool({ name: "issue_comment", arguments: { ...journal, verbose: true } });
|
|
250
|
+
assert.equal(response.isError, void 0, JSON.stringify(response));
|
|
251
|
+
const readback = decoded(response);
|
|
252
|
+
assert.equal(readback.commentId, 91 + index);
|
|
253
|
+
assert.equal(readback.url, `https://github.com/example/b/issues/17#issuecomment-${String(91 + index)}`);
|
|
254
|
+
assert.equal(readback.body.split("\n")[2], common.summary);
|
|
255
|
+
assert.ok(readback.body.includes(`**Kind:** ${journal.kind}.`));
|
|
256
|
+
assert.match(readback.body, /<!-- ai-delivery:journal@1:sha256:[a-f0-9]{64} -->$/u);
|
|
257
|
+
assert.equal(readback.reused, false);
|
|
251
258
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
const retried = await client.callTool({ name: "issue_comment", arguments: journals[1] });
|
|
260
|
+
assert.equal(retried.isError, void 0, JSON.stringify(retried));
|
|
261
|
+
assert.equal(decoded(retried).commentId, 92);
|
|
262
|
+
assert.equal(decoded(retried).reused, true);
|
|
263
|
+
const beforeInvalidRequests = JSON.parse(readFileSync(calls, "utf8")).length;
|
|
264
|
+
for (const invalid of [
|
|
265
|
+
{ ...journals[1], unknown: true },
|
|
266
|
+
{ ...journals[1], outcome: "Wrong variant" },
|
|
267
|
+
{ ...journals[1], kind: "unsupported" },
|
|
268
|
+
{ ...journals[1], nextDate: "2026-02-30" },
|
|
269
|
+
{ ...journals[1], repo: "invalid" }
|
|
270
|
+
]) {
|
|
271
|
+
const refused = await client.callTool({ name: "issue_comment", arguments: invalid }).then(
|
|
272
|
+
(result) => result.isError === true,
|
|
273
|
+
() => true
|
|
274
|
+
);
|
|
275
|
+
assert.equal(refused, true);
|
|
256
276
|
}
|
|
257
|
-
|
|
277
|
+
assert.equal(
|
|
278
|
+
JSON.parse(readFileSync(calls, "utf8")).length,
|
|
279
|
+
beforeInvalidRequests,
|
|
280
|
+
"invalid packed journals never reach configuration discovery, author authentication or writes"
|
|
281
|
+
);
|
|
282
|
+
const unknown = await client.callTool({
|
|
283
|
+
name: "issue_create",
|
|
284
|
+
arguments: { ...readyInput, labels: ["missing-label"] }
|
|
285
|
+
});
|
|
286
|
+
assert.equal(unknown.isError, true);
|
|
287
|
+
assert.match(JSON.stringify(unknown), /Unknown repository label.*missing-label/u);
|
|
288
|
+
const boardValue = async (arguments_) => {
|
|
289
|
+
const response = await client.callTool({ name: "board_reconcile", arguments: arguments_ });
|
|
290
|
+
assert.equal(response.isError, void 0, JSON.stringify(response));
|
|
291
|
+
return JSON.parse(response.content[0].text);
|
|
292
|
+
};
|
|
293
|
+
const boardEnv = {
|
|
294
|
+
PATH: process.env.PATH ?? "",
|
|
295
|
+
TMPDIR: tmpdir(),
|
|
296
|
+
HOME: directory,
|
|
297
|
+
AI_DELIVERY_CONFIG: settings,
|
|
298
|
+
SYNTHETIC_TOKEN: "inert-personal-token",
|
|
299
|
+
NODE_OPTIONS: `--v8-pool-size=1 --import=${preload}`
|
|
300
|
+
};
|
|
301
|
+
const activeCli = launchCheckout ? join(packageRoot, "dist", "cli.js") : join(selectedPluginRoot, "runtime", "dist", "cli.js");
|
|
302
|
+
const boardCli = (...args) => spawnSync(process.execPath, [activeCli, "board:reconcile", "--repositories", "example/b", ...args], {
|
|
303
|
+
cwd: directory,
|
|
304
|
+
env: boardEnv,
|
|
305
|
+
encoding: "utf8",
|
|
306
|
+
maxBuffer: 32 * 1024 * 1024
|
|
307
|
+
});
|
|
308
|
+
writeFileSync(
|
|
309
|
+
boardStatePath,
|
|
310
|
+
JSON.stringify({ member: null, status: null, writes: [], failAddResponse: true })
|
|
311
|
+
);
|
|
312
|
+
const plan = BoardReconcilePlanSchema.parse(await boardValue({ repositories: ["example/b"] }));
|
|
313
|
+
assert.equal(plan.scopeComplete, true);
|
|
314
|
+
assert.equal(plan.operations.length, 1);
|
|
315
|
+
assert.equal(plan.operations[0].kind, "add-membership");
|
|
316
|
+
const rootLibrary = spawnSync(
|
|
317
|
+
process.execPath,
|
|
318
|
+
[
|
|
319
|
+
"--input-type=module",
|
|
320
|
+
"-e",
|
|
321
|
+
`import {executeTool} from ${JSON.stringify(pathToFileURL(join(packageRoot, "dist", "agent.js")).href)};console.log(JSON.stringify(await executeTool('board_reconcile',{repositories:['example/b']},{repoRoot:process.cwd()})));`
|
|
322
|
+
],
|
|
323
|
+
{ cwd: directory, env: boardEnv, encoding: "utf8", maxBuffer: 32 * 1024 * 1024 }
|
|
324
|
+
);
|
|
325
|
+
assert.equal(rootLibrary.status, 0, rootLibrary.stderr);
|
|
326
|
+
const rootPlan = BoardReconcilePlanSchema.parse(JSON.parse(rootLibrary.stdout));
|
|
327
|
+
assert.equal(rootPlan.packageIdentity.packageVersion, plan.packageIdentity.packageVersion);
|
|
328
|
+
assert.deepEqual(rootPlan.scope, plan.scope);
|
|
329
|
+
assert.deepEqual(rootPlan.operations, plan.operations);
|
|
330
|
+
if (!launchCheckout) {
|
|
331
|
+
assert.notDeepEqual(rootPlan.packageIdentity, plan.packageIdentity);
|
|
332
|
+
const crossArtifact = BoardReconcileResultSchema.parse(
|
|
333
|
+
await boardValue({ repositories: rootPlan.scope, mode: "apply", plan: rootPlan })
|
|
334
|
+
);
|
|
335
|
+
assert.equal(crossArtifact.summary.applied, 0);
|
|
336
|
+
assert.equal(crossArtifact.summary.refused, 1);
|
|
337
|
+
} else assert.deepEqual(rootPlan.packageIdentity, plan.packageIdentity);
|
|
338
|
+
const interrupted = BoardReconcileResultSchema.parse(
|
|
339
|
+
await boardValue({ repositories: plan.scope, mode: "apply", plan })
|
|
340
|
+
);
|
|
341
|
+
assert.equal(interrupted.summary.unknown, 1);
|
|
342
|
+
assert.equal(interrupted.operations[0].attempted, true);
|
|
343
|
+
const planFile = join(directory, "plan.json"), priorFile = join(directory, "prior-result.json");
|
|
344
|
+
writeFileSync(planFile, JSON.stringify(plan));
|
|
345
|
+
writeFileSync(priorFile, JSON.stringify(interrupted));
|
|
346
|
+
const resumedCli = boardCli("--apply", "--plan-file", planFile, "--prior-result-file", priorFile);
|
|
347
|
+
assert.equal(resumedCli.status, 1, resumedCli.stderr);
|
|
348
|
+
const resumed = BoardReconcileResultSchema.parse(JSON.parse(resumedCli.stdout));
|
|
349
|
+
assert.equal(resumed.summary.applied, 0);
|
|
350
|
+
assert.equal(resumed.summary.satisfied, 1);
|
|
351
|
+
assert.equal(resumed.operations[0].priorEvidence.at(-1).outcome, "unknown");
|
|
352
|
+
assert.equal(resumed.summary.unresolved, 1);
|
|
353
|
+
assert.deepEqual(JSON.parse(readFileSync(boardStatePath, "utf8")).writes, ["add"]);
|
|
354
|
+
writeFileSync(boardStatePath, JSON.stringify({ member: null, status: null, writes: [] }));
|
|
355
|
+
const partialCli = boardCli("--apply", "--plan-file", planFile);
|
|
356
|
+
assert.equal(partialCli.status, 1, partialCli.stderr);
|
|
357
|
+
const applied = BoardReconcileResultSchema.parse(JSON.parse(partialCli.stdout));
|
|
358
|
+
assert.equal(applied.summary.applied, 1);
|
|
359
|
+
assert.equal(applied.operations[0].readback.itemId, "ADDED17");
|
|
360
|
+
const historical = structuredClone(applied);
|
|
361
|
+
historical.operations[0].outcome = "unknown";
|
|
362
|
+
historical.summary.applied = 0;
|
|
363
|
+
historical.summary.unknown = 1;
|
|
364
|
+
writeFileSync(priorFile, JSON.stringify(historical));
|
|
365
|
+
const emptyPlan = BoardReconcilePlanSchema.parse(await boardValue({ repositories: ["example/b"] }));
|
|
366
|
+
assert.equal(emptyPlan.operations.length, 0);
|
|
367
|
+
for (const failure of ["pages", "access"]) {
|
|
368
|
+
writeFileSync(
|
|
369
|
+
boardStatePath,
|
|
370
|
+
JSON.stringify({ member: "ADDED17", status: "Todo", writes: ["add"], failDiscovery: failure })
|
|
371
|
+
);
|
|
372
|
+
for (const value of [
|
|
373
|
+
await boardValue({ repositories: plan.scope, mode: "apply", plan, priorResult: historical }),
|
|
374
|
+
...(() => {
|
|
375
|
+
const result = boardCli("--apply", "--plan-file", planFile, "--prior-result-file", priorFile);
|
|
376
|
+
assert.equal(result.status, 1, result.stderr);
|
|
377
|
+
return [JSON.parse(result.stdout)];
|
|
378
|
+
})()
|
|
379
|
+
]) {
|
|
380
|
+
const result = BoardReconcileResultSchema.parse(value);
|
|
381
|
+
assert.equal(result.scopeComplete, false);
|
|
382
|
+
assert.equal(result.planId, plan.planId);
|
|
383
|
+
assert.equal(result.summary.applied, 0);
|
|
384
|
+
assert.equal(result.summary.satisfied, 0);
|
|
385
|
+
assert.equal(result.operations[0].attempted, false);
|
|
386
|
+
assert.equal(result.operations[0].operationId, plan.operations[0].operationId);
|
|
387
|
+
assert.ok(result.operations[0].knownItemIds.includes("ADDED17"));
|
|
388
|
+
assert.deepEqual(result.operations[0].priorEvidence.at(-1).readback, historical.operations[0].readback);
|
|
389
|
+
if (failure === "pages") assert.equal(result.gaps[0].pagesRequested, 20);
|
|
390
|
+
}
|
|
391
|
+
const dry = boardCli("--dry-run");
|
|
392
|
+
assert.equal(dry.status, 1, dry.stderr);
|
|
393
|
+
assert.equal(BoardReconcilePlanSchema.parse(JSON.parse(dry.stdout)).scopeComplete, false);
|
|
394
|
+
const empty = BoardReconcileResultSchema.parse(
|
|
395
|
+
await boardValue({ repositories: emptyPlan.scope, mode: "apply", plan: emptyPlan })
|
|
396
|
+
);
|
|
397
|
+
assert.equal(empty.scopeComplete, false);
|
|
398
|
+
assert.deepEqual(empty.operations, []);
|
|
399
|
+
}
|
|
400
|
+
writeFileSync(boardStatePath, JSON.stringify({ member: "ADDED17", status: "Todo", writes: ["add"] }));
|
|
401
|
+
const completeDry = boardCli("--dry-run");
|
|
402
|
+
assert.equal(completeDry.status, 0, completeDry.stderr);
|
|
403
|
+
assert.equal(BoardReconcilePlanSchema.parse(JSON.parse(completeDry.stdout)).scopeComplete, true);
|
|
404
|
+
const requests = JSON.parse(readFileSync(calls, "utf8"));
|
|
405
|
+
assert.equal(
|
|
406
|
+
requests.some((call) => call.path.startsWith("/repos/example/a/")),
|
|
407
|
+
false
|
|
408
|
+
);
|
|
409
|
+
assert.equal(requests.filter((call) => call.path.endsWith("/issues") && call.method === "POST").length, 1);
|
|
410
|
+
assert.equal(
|
|
411
|
+
requests.filter((call) => call.path.endsWith("/issues/17/comments") && call.method === "POST").length,
|
|
412
|
+
5,
|
|
413
|
+
"five authored journals read back; retry adds no sixth write"
|
|
414
|
+
);
|
|
415
|
+
assert.equal(existsSync(join(directory, ".issue-cli")), false);
|
|
416
|
+
} finally {
|
|
417
|
+
await client.close();
|
|
418
|
+
await transport.close();
|
|
419
|
+
rmSync(directory, { recursive: true, force: true });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
);
|
|
258
423
|
}
|
|
259
|
-
test(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
424
|
+
test("CLI reports the selected package version", { tags: ["release"] }, () => {
|
|
425
|
+
const displayed = execFileSync(process.execPath, [join(packageRoot, "dist", "cli.js"), "--version"], {
|
|
426
|
+
encoding: "utf8",
|
|
427
|
+
maxBuffer: 65536
|
|
428
|
+
}).trim();
|
|
429
|
+
assert.equal(displayed, pkg.version);
|
|
265
430
|
});
|
|
266
|
-
test(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
431
|
+
test("portable and Claude plugin metadata bind the same package and launcher", () => {
|
|
432
|
+
const portable = JSON.parse(readFileSync(join(pluginRoot, "plugin.json"), "utf8"));
|
|
433
|
+
const claude = JSON.parse(readFileSync(join(pluginRoot, ".claude-plugin", "plugin.json"), "utf8"));
|
|
434
|
+
assert.equal(portable.$schema, "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json");
|
|
435
|
+
assert.equal(portable.name, "ai-delivery");
|
|
436
|
+
assert.equal(portable.version, pkg.version);
|
|
437
|
+
assert.equal(claude.name, portable.name);
|
|
438
|
+
assert.equal(claude.version, pkg.version);
|
|
439
|
+
assert.equal(claude.packageVersion, pkg.version);
|
|
440
|
+
assert.equal(claude.deliveryCapabilityVersion, 2);
|
|
441
|
+
const mcp = JSON.parse(readFileSync(join(pluginRoot, "mcp.json"), "utf8"));
|
|
442
|
+
assert.equal(mcp.$schema, "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json");
|
|
443
|
+
assert.deepEqual(mcp.mcpServers["ai-delivery"], {
|
|
444
|
+
type: "stdio",
|
|
445
|
+
command: "node",
|
|
446
|
+
args: ["${PLUGIN_ROOT}/dist/mcp-launcher.js"]
|
|
447
|
+
});
|
|
283
448
|
});
|
|
284
|
-
test(
|
|
285
|
-
|
|
286
|
-
|
|
449
|
+
test(
|
|
450
|
+
"a copied plugin root starts its exact MCP contract without a parent runtime installation",
|
|
451
|
+
{ tags: ["release"] },
|
|
452
|
+
async () => {
|
|
453
|
+
const directory = mkdtempSync(join(tmpdir(), "ai-delivery-plugin-cache-"));
|
|
454
|
+
const copiedRoot = join(directory, "plugin");
|
|
287
455
|
cpSync(pluginRoot, copiedRoot, { recursive: true });
|
|
288
456
|
const transport = new StdioClientTransport({
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
457
|
+
command: process.execPath,
|
|
458
|
+
args: [join(copiedRoot, "dist", "mcp-launcher.js")],
|
|
459
|
+
cwd: copiedRoot,
|
|
460
|
+
env: { PATH: process.env.PATH ?? "", TMPDIR: tmpdir(), NODE_OPTIONS: "--max-old-space-size=2048" },
|
|
461
|
+
stderr: "pipe",
|
|
462
|
+
maxBufferSize: 1024 * 1024
|
|
295
463
|
});
|
|
296
|
-
const client = new Client({ name:
|
|
464
|
+
const client = new Client({ name: "isolated-plugin-cache-test", version: "1.0.0" });
|
|
297
465
|
let pid = null;
|
|
298
466
|
try {
|
|
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
|
-
|
|
467
|
+
await client.connect(transport, { timeout: 3e4 });
|
|
468
|
+
pid = transport.pid;
|
|
469
|
+
assert.equal(client.getServerVersion()?.version, pkg.version);
|
|
470
|
+
const instructions = client.getInstructions();
|
|
471
|
+
assert.equal(typeof instructions, "string", "the copied native plugin must retain initialize guidance");
|
|
472
|
+
assert.match(instructions ?? "", /\brepo\b/u);
|
|
473
|
+
assert.match(instructions ?? "", /\bissue_info\b/u);
|
|
474
|
+
const result = await client.listTools({}, { timeout: 3e4 });
|
|
475
|
+
const issueInfo = result.tools.find((tool) => tool.name === "issue_info");
|
|
476
|
+
assert.ok(issueInfo);
|
|
477
|
+
const properties = issueInfo.inputSchema.properties;
|
|
478
|
+
assert.equal(typeof properties.repo?.description, "string");
|
|
479
|
+
assert.deepEqual(
|
|
480
|
+
result.tools.map((tool) => tool.name).sort(),
|
|
481
|
+
AI_DELIVERY_MCP_TOOLS.map((tool) => tool.name).sort()
|
|
482
|
+
);
|
|
483
|
+
assert.equal(existsSync(join(copiedRoot, ".issue-cli")), false);
|
|
484
|
+
} finally {
|
|
485
|
+
await client.close();
|
|
486
|
+
await transport.close();
|
|
487
|
+
const ownedPid = pid;
|
|
488
|
+
try {
|
|
489
|
+
if (ownedPid !== null) assert.throws(() => process.kill(ownedPid, 0), { code: "ESRCH" });
|
|
490
|
+
} finally {
|
|
491
|
+
rmSync(directory, { recursive: true, force: true });
|
|
492
|
+
}
|
|
325
493
|
}
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
test("standalone plugin ships application and bundled dependency notices", () => {
|
|
497
|
+
assert.equal(readFileSync(join(pluginRoot, "LICENSE"), "utf8"), readFileSync(join(packageRoot, "LICENSE"), "utf8"));
|
|
498
|
+
const notices = readFileSync(join(pluginRoot, "runtime", "dist", "THIRD-PARTY-NOTICES.md"), "utf8");
|
|
499
|
+
assert.match(notices, /@modelcontextprotocol\/sdk/u);
|
|
500
|
+
assert.match(notices, /commander/u);
|
|
326
501
|
});
|
|
327
|
-
test(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
test('a copied plugin has a real CLI and producer identity that existing admission can bind', () => {
|
|
334
|
-
const directory = realpathSync(mkdtempSync(join(tmpdir(), 'ai-delivery-native-identity-')));
|
|
335
|
-
const copiedRoot = join(directory, 'plugin');
|
|
502
|
+
test(
|
|
503
|
+
"a copied plugin has a real CLI and producer identity that existing admission can bind",
|
|
504
|
+
{ tags: ["release"] },
|
|
505
|
+
() => {
|
|
506
|
+
const directory = realpathSync(mkdtempSync(join(tmpdir(), "ai-delivery-native-identity-")));
|
|
507
|
+
const copiedRoot = join(directory, "plugin");
|
|
336
508
|
cpSync(pluginRoot, copiedRoot, { recursive: true });
|
|
337
|
-
// The validator only reads repository/configDigest. No repository config,
|
|
338
|
-
// credentials, admission publication or lifecycle authority exists here.
|
|
339
509
|
const configuration = {
|
|
340
|
-
|
|
341
|
-
|
|
510
|
+
config: { repository: "example/widget" },
|
|
511
|
+
configDigest: `sha256:${"a".repeat(64)}`
|
|
342
512
|
};
|
|
343
513
|
try {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
514
|
+
const cliPath = join(copiedRoot, "runtime", "dist", "cli.js");
|
|
515
|
+
assert.equal(
|
|
516
|
+
execFileSync(process.execPath, [cliPath, "--version"], { encoding: "utf8", maxBuffer: 65536 }).trim(),
|
|
517
|
+
pkg.version
|
|
518
|
+
);
|
|
519
|
+
const admission = buildRuntimeAdmission({
|
|
520
|
+
cliPath,
|
|
521
|
+
mcpLauncherPath: join(copiedRoot, "dist", "mcp-launcher.js"),
|
|
522
|
+
pluginManifestPath: join(copiedRoot, ".claude-plugin", "plugin.json"),
|
|
523
|
+
packageVersion: pkg.version,
|
|
524
|
+
sourceArchiveSha256: `sha256:${"b".repeat(64)}`,
|
|
525
|
+
sourceCommit: "1".repeat(40),
|
|
526
|
+
configuration
|
|
527
|
+
});
|
|
528
|
+
assert.equal(validateRuntimeAdmission(admission, configuration, cliPath).admissionId, admission.admissionId);
|
|
529
|
+
assert.match(
|
|
530
|
+
retainedWorktreeTransitionProducerDigest(join(copiedRoot, "runtime", "dist")),
|
|
531
|
+
/^sha256:[a-f0-9]{64}$/u
|
|
532
|
+
);
|
|
533
|
+
const otherRoot = join(directory, "other");
|
|
534
|
+
cpSync(copiedRoot, otherRoot, { recursive: true });
|
|
535
|
+
assert.throws(
|
|
536
|
+
() => validateRuntimeAdmission(admission, configuration, join(otherRoot, "runtime", "dist", "cli.js"))
|
|
537
|
+
);
|
|
538
|
+
writeFileSync(cliPath, `${readFileSync(cliPath, "utf8")}
|
|
539
|
+
/* altered runtime */
|
|
540
|
+
`);
|
|
541
|
+
assert.throws(() => validateRuntimeAdmission(admission, configuration, cliPath));
|
|
542
|
+
} finally {
|
|
543
|
+
rmSync(directory, { recursive: true, force: true });
|
|
365
544
|
}
|
|
366
|
-
}
|
|
367
|
-
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
//# sourceMappingURL=pluginPackaging.test.js.map
|