@aviaratech/ai-delivery 0.3.35 → 0.3.37

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