@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.
Files changed (301) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -506
  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 +1746 -0
  9. package/dist/boardReconcile.test.js.map +7 -0
  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 +406 -485
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -25
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +434 -297
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +320 -14
  22. package/dist/config/deliveryConfig.js +472 -385
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +775 -584
  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 -477
  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.d.ts +1 -0
  53. package/dist/deliveryBoard.test.js +649 -0
  54. package/dist/deliveryBoard.test.js.map +7 -0
  55. package/dist/deliveryHealth.test.js +179 -155
  56. package/dist/deliveryHealth.test.js.map +7 -1
  57. package/dist/dependencyCompatibility.test.js +154 -140
  58. package/dist/dependencyCompatibility.test.js.map +7 -1
  59. package/dist/directoryIndependent.test.js +417 -383
  60. package/dist/directoryIndependent.test.js.map +7 -1
  61. package/dist/dispatch.d.ts +17 -12
  62. package/dist/dispatch.js +330 -322
  63. package/dist/dispatch.js.map +7 -1
  64. package/dist/errors.d.ts +16 -3
  65. package/dist/errors.js +104 -82
  66. package/dist/errors.js.map +7 -1
  67. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  68. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  69. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  70. package/dist/fixtures/discovery.d.ts +59 -19
  71. package/dist/fixtures/discovery.js +96 -90
  72. package/dist/fixtures/discovery.js.map +7 -1
  73. package/dist/fixtures/inertEntrypointChild.js +57 -56
  74. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  75. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  76. package/dist/fixtures/inertEntrypoints.js +321 -276
  77. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  78. package/dist/fixtures/inertTarget.d.ts +78 -7
  79. package/dist/fixtures/inertTarget.js +769 -691
  80. package/dist/fixtures/inertTarget.js.map +7 -1
  81. package/dist/fixtures/issue63.d.ts +4 -3
  82. package/dist/fixtures/issue63.js +260 -274
  83. package/dist/fixtures/issue63.js.map +7 -1
  84. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  85. package/dist/fixtures/issueProjectItems.js +15 -0
  86. package/dist/fixtures/issueProjectItems.js.map +7 -0
  87. package/dist/fixtures/readView.d.ts +120 -0
  88. package/dist/fixtures/readView.js +172 -0
  89. package/dist/fixtures/readView.js.map +7 -0
  90. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  91. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  92. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  93. package/dist/genericCompatibility.test.js +64 -55
  94. package/dist/genericCompatibility.test.js.map +7 -1
  95. package/dist/git.js +73 -67
  96. package/dist/git.js.map +7 -1
  97. package/dist/gitProcess.d.ts +1 -1
  98. package/dist/gitProcess.js +58 -53
  99. package/dist/gitProcess.js.map +7 -1
  100. package/dist/github/client.d.ts +2 -2
  101. package/dist/github/client.js +484 -379
  102. package/dist/github/client.js.map +7 -1
  103. package/dist/github/commandIdentityPolicy.js +44 -51
  104. package/dist/github/commandIdentityPolicy.js.map +7 -1
  105. package/dist/github/discovery.d.ts +3 -0
  106. package/dist/github/discovery.js +197 -201
  107. package/dist/github/discovery.js.map +7 -1
  108. package/dist/github/discovery.test.js +223 -177
  109. package/dist/github/discovery.test.js.map +7 -1
  110. package/dist/github/issueHistory.d.ts +2 -2
  111. package/dist/github/issueHistory.js +117 -125
  112. package/dist/github/issueHistory.js.map +7 -1
  113. package/dist/github/machineAuth.d.ts +1 -1
  114. package/dist/github/machineAuth.js +126 -117
  115. package/dist/github/machineAuth.js.map +7 -1
  116. package/dist/github/machineAuth.test.js +755 -639
  117. package/dist/github/machineAuth.test.js.map +7 -1
  118. package/dist/github/nativeIssueMetadata.js +286 -273
  119. package/dist/github/nativeIssueMetadata.js.map +7 -1
  120. package/dist/github/projectDelivery.d.ts +53 -1
  121. package/dist/github/projectDelivery.js +623 -460
  122. package/dist/github/projectDelivery.js.map +7 -1
  123. package/dist/github/relationships.d.ts +5 -2
  124. package/dist/github/relationships.js +434 -333
  125. package/dist/github/relationships.js.map +7 -1
  126. package/dist/github/repo.d.ts +1 -0
  127. package/dist/github/repo.js +123 -96
  128. package/dist/github/repo.js.map +7 -1
  129. package/dist/index.js +3 -3
  130. package/dist/index.js.map +7 -1
  131. package/dist/issue.d.ts +103 -7
  132. package/dist/issue.js +2104 -1547
  133. package/dist/issue.js.map +7 -1
  134. package/dist/issue63History.test.js +40 -42
  135. package/dist/issue63History.test.js.map +7 -1
  136. package/dist/issue63Routes.test.js +154 -143
  137. package/dist/issue63Routes.test.js.map +7 -1
  138. package/dist/issueBatchUpdate.test.js +1004 -683
  139. package/dist/issueBatchUpdate.test.js.map +7 -1
  140. package/dist/issueBlockerGuard.test.js +262 -226
  141. package/dist/issueBlockerGuard.test.js.map +7 -1
  142. package/dist/issueContract.d.ts +23 -4
  143. package/dist/issueContract.js +416 -395
  144. package/dist/issueContract.js.map +7 -1
  145. package/dist/issueContract.test.d.ts +4 -3
  146. package/dist/issueContract.test.js +358 -321
  147. package/dist/issueContract.test.js.map +7 -1
  148. package/dist/issueDates.test.js +235 -233
  149. package/dist/issueDates.test.js.map +7 -1
  150. package/dist/issueInfoReadback.test.js +304 -190
  151. package/dist/issueInfoReadback.test.js.map +7 -1
  152. package/dist/issueIntake.test.js +1945 -1732
  153. package/dist/issueIntake.test.js.map +7 -1
  154. package/dist/issueJournal.d.ts +40 -19
  155. package/dist/issueJournal.js +229 -138
  156. package/dist/issueJournal.js.map +7 -1
  157. package/dist/issueJournal.test.js +605 -422
  158. package/dist/issueJournal.test.js.map +7 -1
  159. package/dist/issueRollup.test.d.ts +1 -0
  160. package/dist/issueRollup.test.js +476 -0
  161. package/dist/issueRollup.test.js.map +7 -0
  162. package/dist/issueTracking.test.js +1088 -593
  163. package/dist/issueTracking.test.js.map +7 -1
  164. package/dist/issueWriteRecovery.test.d.ts +1 -0
  165. package/dist/issueWriteRecovery.test.js +260 -0
  166. package/dist/issueWriteRecovery.test.js.map +7 -0
  167. package/dist/lifecycle.test.js +112 -441
  168. package/dist/lifecycle.test.js.map +7 -1
  169. package/dist/logger.js +80 -74
  170. package/dist/logger.js.map +7 -1
  171. package/dist/mcp/index.js +116 -90
  172. package/dist/mcp/index.js.map +7 -1
  173. package/dist/mcp/tools.d.ts +790 -220
  174. package/dist/mcp/tools.js +267 -333
  175. package/dist/mcp/tools.js.map +7 -1
  176. package/dist/pluginAuthProbe.js +63 -52
  177. package/dist/pluginAuthProbe.js.map +7 -1
  178. package/dist/pluginAuthProbe.test.js +85 -62
  179. package/dist/pluginAuthProbe.test.js.map +7 -1
  180. package/dist/pluginCredentials.test.js +282 -259
  181. package/dist/pluginCredentials.test.js.map +7 -1
  182. package/dist/pluginDoctor.test.js +653 -588
  183. package/dist/pluginDoctor.test.js.map +7 -1
  184. package/dist/pluginInstaller.d.ts +7 -5
  185. package/dist/pluginInstaller.js +1173 -1231
  186. package/dist/pluginInstaller.js.map +7 -1
  187. package/dist/pluginInstaller.test.js +1822 -1283
  188. package/dist/pluginInstaller.test.js.map +7 -1
  189. package/dist/pluginPackaging.test.js +485 -305
  190. package/dist/pluginPackaging.test.js.map +7 -1
  191. package/dist/pr.d.ts +132 -94
  192. package/dist/pr.js +1521 -1323
  193. package/dist/pr.js.map +7 -1
  194. package/dist/pr.test.js +1678 -632
  195. package/dist/pr.test.js.map +7 -1
  196. package/dist/prAssociation.test.js +2419 -1788
  197. package/dist/prAssociation.test.js.map +7 -1
  198. package/dist/prDispatch.test.js +150 -89
  199. package/dist/prDispatch.test.js.map +7 -1
  200. package/dist/readView.d.ts +183 -0
  201. package/dist/readView.js +217 -0
  202. package/dist/readView.js.map +7 -0
  203. package/dist/readView.test.d.ts +1 -0
  204. package/dist/readView.test.js +119 -0
  205. package/dist/readView.test.js.map +7 -0
  206. package/dist/releaseReconciliation.test.js +267 -288
  207. package/dist/releaseReconciliation.test.js.map +7 -1
  208. package/dist/releaseWorkflow.test.js +2493 -422
  209. package/dist/releaseWorkflow.test.js.map +7 -1
  210. package/dist/review.d.ts +738 -2
  211. package/dist/review.js +601 -348
  212. package/dist/review.js.map +7 -1
  213. package/dist/review.test.js +1218 -812
  214. package/dist/review.test.js.map +7 -1
  215. package/dist/reviewSubmit.test.d.ts +1 -0
  216. package/dist/reviewSubmit.test.js +747 -0
  217. package/dist/reviewSubmit.test.js.map +7 -0
  218. package/dist/services/agentReadinessService.js +42 -37
  219. package/dist/services/agentReadinessService.js.map +7 -1
  220. package/dist/services/blockerGuardService.js +188 -188
  221. package/dist/services/blockerGuardService.js.map +7 -1
  222. package/dist/services/boardReconcileService.d.ts +1204 -0
  223. package/dist/services/boardReconcileService.js +1445 -0
  224. package/dist/services/boardReconcileService.js.map +7 -0
  225. package/dist/services/deliveryAdmission.d.ts +2 -0
  226. package/dist/services/deliveryAdmission.js +129 -152
  227. package/dist/services/deliveryAdmission.js.map +7 -1
  228. package/dist/services/deliveryHealthService.js +197 -199
  229. package/dist/services/deliveryHealthService.js.map +7 -1
  230. package/dist/services/legacyIssueMigration.js +263 -277
  231. package/dist/services/legacyIssueMigration.js.map +7 -1
  232. package/dist/services/worktreeRegistry.d.ts +27 -119
  233. package/dist/services/worktreeRegistry.js +765 -1182
  234. package/dist/services/worktreeRegistry.js.map +7 -1
  235. package/dist/stagedChecks.test.js +396 -194
  236. package/dist/stagedChecks.test.js.map +7 -1
  237. package/dist/start.test.js +99 -95
  238. package/dist/start.test.js.map +7 -1
  239. package/dist/stdoutRegression.test.js +354 -350
  240. package/dist/stdoutRegression.test.js.map +7 -1
  241. package/dist/targetPolicyDiscovery.test.js +141 -143
  242. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  243. package/dist/targetPolicyEntrypoints.test.js +308 -269
  244. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  245. package/dist/targetPolicyLocal.test.js +580 -1051
  246. package/dist/targetPolicyLocal.test.js.map +7 -1
  247. package/dist/targetPolicyRoutes.test.js +305 -281
  248. package/dist/targetPolicyRoutes.test.js.map +7 -1
  249. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  250. package/dist/targetRepositoryExecution.test.js +463 -0
  251. package/dist/targetRepositoryExecution.test.js.map +7 -0
  252. package/dist/terminalMessages.js +41 -35
  253. package/dist/terminalMessages.js.map +7 -1
  254. package/dist/toolOutput.d.ts +2 -0
  255. package/dist/toolOutput.js +36 -0
  256. package/dist/toolOutput.js.map +7 -0
  257. package/dist/toolOutput.test.d.ts +1 -0
  258. package/dist/toolOutput.test.js +240 -0
  259. package/dist/toolOutput.test.js.map +7 -0
  260. package/dist/utils/atomicJson.js +84 -76
  261. package/dist/utils/atomicJson.js.map +7 -1
  262. package/dist/utils/filesystem.js +15 -18
  263. package/dist/utils/filesystem.js.map +7 -1
  264. package/dist/utils/lockfile.js +68 -71
  265. package/dist/utils/lockfile.js.map +7 -1
  266. package/dist/verification.d.ts +1 -19
  267. package/dist/verification.js +1020 -1929
  268. package/dist/verification.js.map +7 -1
  269. package/dist/verificationGate.test.js +127 -117
  270. package/dist/verificationGate.test.js.map +7 -1
  271. package/dist/version.d.ts +6 -0
  272. package/dist/version.js +24 -10
  273. package/dist/version.js.map +7 -1
  274. package/dist/worktree.d.ts +3 -15
  275. package/dist/worktree.js +97 -177
  276. package/dist/worktree.js.map +7 -1
  277. package/package.json +10 -8
  278. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  279. package/plugins/ai-delivery/README.md +47 -156
  280. package/plugins/ai-delivery/plugin.json +1 -1
  281. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +261 -43
  282. package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
  283. package/plugins/ai-delivery/runtime/package.json +1 -1
  284. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  285. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  286. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  287. package/dist/investigationCompletion.test.js +0 -728
  288. package/dist/investigationCompletion.test.js.map +0 -1
  289. package/dist/setup.d.ts +0 -60
  290. package/dist/setup.js +0 -585
  291. package/dist/setup.js.map +0 -1
  292. package/dist/setup.test.js +0 -3058
  293. package/dist/setup.test.js.map +0 -1
  294. package/dist/worktreeTransition.d.ts +0 -211
  295. package/dist/worktreeTransition.js +0 -1037
  296. package/dist/worktreeTransition.js.map +0 -1
  297. package/dist/worktreeTransition.test.js +0 -1191
  298. package/dist/worktreeTransition.test.js.map +0 -1
  299. /package/dist/{investigationCompletion.test.d.ts → boardReconcile.test.d.ts} +0 -0
  300. /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
  301. /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
@@ -1,128 +1,159 @@
1
- import assert from 'node:assert/strict';
2
- import { execFileSync } 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
- const packageRoot = fileURLToPath(new URL('../', import.meta.url));
16
- const pluginRoot = join(packageRoot, 'plugins', 'ai-delivery');
17
- test('README and delivery skill CLI examples name supported commands and required options', () => {
18
- 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");
19
24
  const declarations = [...cli.matchAll(/\.command\('([^']+)'\)/gu)];
20
- const required = new Map(declarations.map((match) => {
21
- 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);
22
28
  return [
23
- match[1],
24
- [...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
+ )
25
33
  ];
26
- }));
27
- const globals = new Set(['--repo', '--repo-root', '--identity']);
34
+ })
35
+ );
36
+ const globals = /* @__PURE__ */ new Set(["--repo", "--repo-root", "--identity"]);
28
37
  for (const path of [
29
- 'README.md',
30
- 'plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md',
31
- '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"
32
41
  ]) {
33
- const source = readFileSync(join(packageRoot, path), 'utf8').replace(/\\\r?\n\s*/gu, ' ');
34
- for (const match of source.matchAll(/^ai-delivery\s+(.+)$/gmu)) {
35
- const words = match[1].split(/\s+/u);
36
- let index = 0;
37
- while (globals.has(words[index] ?? ''))
38
- index += 2;
39
- const command = words[index];
40
- const subcommand = command === 'plugin' ? words[index + 1] : undefined;
41
- const help = execFileSync(process.execPath, [join(packageRoot, 'dist', 'cli.js'), command, ...(subcommand === undefined ? [] : [subcommand]), '--help'], { encoding: 'utf8', maxBuffer: 65536 });
42
- for (const flag of required.get(command) ?? [])
43
- assert.ok(words.includes(flag), `${path}: ${command} requires ${flag}`);
44
- for (const flag of words.filter((word) => word.startsWith('--')))
45
- assert.ok(globals.has(flag) || help.includes(flag), `${path}: ${command} does not support ${flag}`);
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
- 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 () => {
51
- const directory = realpathSync(mkdtempSync(join(tmpdir(), 'delivery-launch-routing-')));
52
- let selectedPluginRoot = pluginRoot;
53
- let discoveryFixture = new URL('./fixtures/discovery.js', import.meta.url).href;
54
- if (!launchCheckout) {
55
- try {
56
- const packed = JSON.parse(execFileSync('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', directory], {
57
- cwd: packageRoot,
58
- encoding: 'utf8',
59
- maxBuffer: 1024 * 1024,
60
- env: {
61
- PATH: process.env.PATH ?? '',
62
- TMPDIR: tmpdir(),
63
- HOME: directory,
64
- npm_config_cache: join(directory, 'npm-cache'),
65
- },
66
- }));
67
- assert.equal(packed.length, 1);
68
- const unpacked = join(directory, 'unpacked');
69
- mkdirSync(unpacked);
70
- execFileSync('tar', ['-xzf', join(directory, packed[0].filename), '-C', unpacked]);
71
- selectedPluginRoot = join(directory, 'plugin-cache');
72
- // Detach the packed native plugin so the launcher uses its bundled runtime,
73
- // rather than the package-local CLI whose npm dependencies are not installed here.
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
- const preload = join(directory, 'mock-github.mjs');
88
- const calls = join(directory, 'requests.json');
89
- const settings = join(directory, 'user.json');
90
- writeFileSync(settings, JSON.stringify({
91
- schemaVersion: 'ai-delivery.user@1',
92
- roles: {
93
- author: { authSource: 'personal', identity: 'operator', credentialEnv: { token: 'SYNTHETIC_TOKEN' } },
94
- reviewer: {
95
- identity: 'reviewer',
96
- credentialEnv: { appId: 'REVIEW_APP', installationId: 'REVIEW_INSTALL', privateKeyPath: 'REVIEW_KEY' },
97
- },
98
- },
99
- project: 1,
100
- checkoutRoots: [],
101
- pointsField: 'Estimate',
102
- priorityField: 'Urgency',
103
- statusField: 'Flow',
104
- statuses: syntheticDiscoveryConfig.native.project.statuses,
105
- }));
106
- writeFileSync(preload, `
107
- import {writeFileSync} from 'node:fs';
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
- if(query.includes('ProjectDeliveryItems'))data={organization:{projectV2:{items:page([{id:'ITEM17',isArchived:false,content:{id:'ISSUE17'},fieldValueByName:{name:'Queued',optionId:'STATUS-0'}}])}}};
124
- else if(query.includes('blockedBy('))data={repository:{issue:{parent:null,blockedBy:page([])}}};
125
- else data=await syntheticDiscoveryClients({...configuration,repository:'example/'+(json.variables?.repo??'b')}).graphql(query,json.variables);
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
- const transport = new StdioClientTransport({
150
- command: process.execPath,
151
- args: [join(selectedPluginRoot, 'dist', 'mcp-launcher.js')],
152
- cwd: directory,
153
- env: {
154
- PATH: process.env.PATH ?? '',
155
- TMPDIR: tmpdir(),
156
- HOME: directory,
157
- AI_DELIVERY_CONFIG: settings,
158
- SYNTHETIC_TOKEN: 'inert-personal-token',
159
- NODE_OPTIONS: `--v8-pool-size=1 --import=${preload}`,
160
- },
161
- stderr: 'pipe',
162
- });
163
- const client = new Client({ name: 'actual-launch-routing', version: '1' });
164
- try {
165
- await client.connect(transport, { timeout: 30000 });
166
- const readyInput = {
167
- repo: 'example/b',
168
- title: 'Validate widget launch routing across repositories',
169
- points: 2,
170
- problem: 'A launcher can bind a widget issue to the checkout repository instead of the explicit caller.',
171
- outcome: 'Create and update the issue only in explicitly selected repository B.',
172
- acceptanceCriteria: [
173
- {
174
- behavior: 'Create, update and journal requests address repository B with zero repository A requests.',
175
- verifiedBy: 'Packaged stdio client results and captured REST path assertions.',
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
- assert.equal(JSON.parse(readFileSync(calls, 'utf8')).length, beforeInvalidRequests, 'invalid packed journals never reach configuration discovery, author authentication or writes');
240
- const unknown = await client.callTool({
241
- name: 'issue_create',
242
- arguments: { ...readyInput, labels: ['missing-label'] },
243
- });
244
- assert.equal(unknown.isError, true);
245
- assert.match(JSON.stringify(unknown), /Unknown repository label.*missing-label/u);
246
- const requests = JSON.parse(readFileSync(calls, 'utf8'));
247
- assert.equal(requests.some((call) => call.path.startsWith('/repos/example/a/')), false);
248
- assert.equal(requests.filter((call) => call.path.endsWith('/issues') && call.method === 'POST').length, 1);
249
- 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');
250
- 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);
251
258
  }
252
- finally {
253
- await client.close();
254
- await transport.close();
255
- 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);
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('CLI reports the selected package version', () => {
260
- const displayed = execFileSync(process.execPath, [join(packageRoot, 'dist', 'cli.js'), '--version'], {
261
- encoding: 'utf8',
262
- maxBuffer: 65536,
263
- }).trim();
264
- 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);
265
430
  });
266
- test('portable and Claude plugin metadata bind the same package and launcher', () => {
267
- const portable = JSON.parse(readFileSync(join(pluginRoot, 'plugin.json'), 'utf8'));
268
- const claude = JSON.parse(readFileSync(join(pluginRoot, '.claude-plugin', 'plugin.json'), 'utf8'));
269
- assert.equal(portable.$schema, 'https://agent-plugins.org/schemas/1.0.0/plugin.schema.json');
270
- assert.equal(portable.name, 'ai-delivery');
271
- assert.equal(portable.version, pkg.version);
272
- assert.equal(claude.name, portable.name);
273
- assert.equal(claude.version, pkg.version);
274
- assert.equal(claude.packageVersion, pkg.version);
275
- assert.equal(claude.deliveryCapabilityVersion, 2);
276
- const mcp = JSON.parse(readFileSync(join(pluginRoot, 'mcp.json'), 'utf8'));
277
- assert.equal(mcp.$schema, 'https://agent-plugins.org/schemas/1.0.0/mcp.schema.json');
278
- assert.deepEqual(mcp.mcpServers['ai-delivery'], {
279
- type: 'stdio',
280
- command: 'node',
281
- args: ['${PLUGIN_ROOT}/dist/mcp-launcher.js'],
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('a copied plugin root starts its exact MCP contract without a parent runtime installation', async () => {
285
- const directory = mkdtempSync(join(tmpdir(), 'ai-delivery-plugin-cache-'));
286
- 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");
287
455
  cpSync(pluginRoot, copiedRoot, { recursive: true });
288
456
  const transport = new StdioClientTransport({
289
- command: process.execPath,
290
- args: [join(copiedRoot, 'dist', 'mcp-launcher.js')],
291
- cwd: copiedRoot,
292
- env: { PATH: process.env.PATH ?? '', TMPDIR: tmpdir(), NODE_OPTIONS: '--max-old-space-size=2048' },
293
- stderr: 'pipe',
294
- 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
295
463
  });
296
- 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" });
297
465
  let pid = null;
298
466
  try {
299
- await client.connect(transport, { timeout: 30000 });
300
- pid = transport.pid;
301
- assert.equal(client.getServerVersion()?.version, pkg.version);
302
- const instructions = client.getInstructions();
303
- assert.equal(typeof instructions, 'string', 'the copied native plugin must retain initialize guidance');
304
- assert.match(instructions ?? '', /\brepo\b/u);
305
- assert.match(instructions ?? '', /\bissue_info\b/u);
306
- const result = await client.listTools({}, { timeout: 30000 });
307
- const issueInfo = result.tools.find((tool) => tool.name === 'issue_info');
308
- assert.ok(issueInfo);
309
- const properties = issueInfo.inputSchema.properties;
310
- assert.equal(typeof properties.repo?.description, 'string');
311
- assert.deepEqual(result.tools.map((tool) => tool.name).sort(), AI_DELIVERY_MCP_TOOLS.map((tool) => tool.name).sort());
312
- assert.equal(existsSync(join(copiedRoot, '.issue-cli')), false);
313
- }
314
- finally {
315
- await client.close();
316
- await transport.close();
317
- const ownedPid = pid;
318
- try {
319
- if (ownedPid !== null)
320
- assert.throws(() => process.kill(ownedPid, 0), { code: 'ESRCH' });
321
- }
322
- finally {
323
- rmSync(directory, { recursive: true, force: true });
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('standalone plugin ships application and bundled dependency notices', () => {
328
- assert.equal(readFileSync(join(pluginRoot, 'LICENSE'), 'utf8'), readFileSync(join(packageRoot, 'LICENSE'), 'utf8'));
329
- const notices = readFileSync(join(pluginRoot, 'runtime', 'dist', 'THIRD-PARTY-NOTICES.md'), 'utf8');
330
- assert.match(notices, /@modelcontextprotocol\/sdk/u);
331
- assert.match(notices, /commander/u);
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
- config: { repository: 'example/widget' },
341
- configDigest: `sha256:${'a'.repeat(64)}`,
510
+ config: { repository: "example/widget" },
511
+ configDigest: `sha256:${"a".repeat(64)}`
342
512
  };
343
513
  try {
344
- const cliPath = join(copiedRoot, 'runtime', 'dist', 'cli.js');
345
- assert.equal(execFileSync(process.execPath, [cliPath, '--version'], { encoding: 'utf8', maxBuffer: 65536 }).trim(), pkg.version);
346
- const admission = buildRuntimeAdmission({
347
- cliPath,
348
- mcpLauncherPath: join(copiedRoot, 'dist', 'mcp-launcher.js'),
349
- pluginManifestPath: join(copiedRoot, '.claude-plugin', 'plugin.json'),
350
- packageVersion: pkg.version,
351
- sourceArchiveSha256: `sha256:${'b'.repeat(64)}`,
352
- sourceCommit: '1'.repeat(40),
353
- configuration,
354
- });
355
- assert.equal(validateRuntimeAdmission(admission, configuration, cliPath).admissionId, admission.admissionId);
356
- assert.match(retainedWorktreeTransitionProducerDigest(join(copiedRoot, 'runtime', 'dist')), /^sha256:[a-f0-9]{64}$/u);
357
- const otherRoot = join(directory, 'other');
358
- cpSync(copiedRoot, otherRoot, { recursive: true });
359
- assert.throws(() => validateRuntimeAdmission(admission, configuration, join(otherRoot, 'runtime', 'dist', 'cli.js')));
360
- writeFileSync(cliPath, `${readFileSync(cliPath, 'utf8')}\n/* altered runtime */\n`);
361
- assert.throws(() => validateRuntimeAdmission(admission, configuration, cliPath));
362
- }
363
- finally {
364
- 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 });
365
544
  }
366
- });
367
- //# sourceMappingURL=pluginPackaging.test.js.map
545
+ }
546
+ );
547
+ //# sourceMappingURL=pluginPackaging.test.js.map