@aviaratech/ai-delivery 0.3.35 → 0.3.36

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