@aviaratech/ai-delivery 0.3.35 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -554
  3. package/dist/agent.d.ts +0 -2
  4. package/dist/agent.js +76 -16
  5. package/dist/agent.js.map +7 -1
  6. package/dist/agentReadiness.test.js +73 -67
  7. package/dist/agentReadiness.test.js.map +7 -1
  8. package/dist/boardReconcile.test.js +1651 -1590
  9. package/dist/boardReconcile.test.js.map +7 -1
  10. package/dist/build.test.js +130 -0
  11. package/dist/build.test.js.map +7 -0
  12. package/dist/callerErrors.test.js +105 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +402 -515
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -45
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +424 -369
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +288 -14
  22. package/dist/config/deliveryConfig.js +472 -390
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +773 -649
  25. package/dist/config/deliveryConfig.test.js.map +7 -1
  26. package/dist/contributorChecks.test.js +1694 -916
  27. package/dist/contributorChecks.test.js.map +7 -1
  28. package/dist/currentConsumer.test.js +819 -737
  29. package/dist/currentConsumer.test.js.map +7 -1
  30. package/dist/currentTrackingScenario.test.js +499 -479
  31. package/dist/currentTrackingScenario.test.js.map +7 -1
  32. package/dist/delivery/common.js +160 -172
  33. package/dist/delivery/common.js.map +7 -1
  34. package/dist/delivery/delivery.test.js +509 -431
  35. package/dist/delivery/delivery.test.js.map +7 -1
  36. package/dist/delivery/evidence.d.ts +2 -2
  37. package/dist/delivery/evidence.js +133 -120
  38. package/dist/delivery/evidence.js.map +7 -1
  39. package/dist/delivery/index.js +7 -2
  40. package/dist/delivery/index.js.map +7 -1
  41. package/dist/delivery/legacy.js +65 -5
  42. package/dist/delivery/legacy.js.map +7 -1
  43. package/dist/delivery/policy.d.ts +10 -10
  44. package/dist/delivery/policy.js +211 -238
  45. package/dist/delivery/policy.js.map +7 -1
  46. package/dist/delivery/stage.d.ts +18 -18
  47. package/dist/delivery/stage.js +220 -235
  48. package/dist/delivery/stage.js.map +7 -1
  49. package/dist/deliveryBoard.d.ts +74 -0
  50. package/dist/deliveryBoard.js +644 -0
  51. package/dist/deliveryBoard.js.map +7 -0
  52. package/dist/deliveryBoard.test.js +649 -0
  53. package/dist/deliveryBoard.test.js.map +7 -0
  54. package/dist/deliveryHealth.test.js +179 -155
  55. package/dist/deliveryHealth.test.js.map +7 -1
  56. package/dist/dependencyCompatibility.test.js +154 -140
  57. package/dist/dependencyCompatibility.test.js.map +7 -1
  58. package/dist/directoryIndependent.test.js +417 -383
  59. package/dist/directoryIndependent.test.js.map +7 -1
  60. package/dist/dispatch.d.ts +16 -11
  61. package/dist/dispatch.js +329 -353
  62. package/dist/dispatch.js.map +7 -1
  63. package/dist/errors.d.ts +3 -3
  64. package/dist/errors.js +103 -96
  65. package/dist/errors.js.map +7 -1
  66. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  67. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  68. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  69. package/dist/fixtures/discovery.d.ts +59 -19
  70. package/dist/fixtures/discovery.js +96 -90
  71. package/dist/fixtures/discovery.js.map +7 -1
  72. package/dist/fixtures/inertEntrypointChild.js +57 -56
  73. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  74. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  75. package/dist/fixtures/inertEntrypoints.js +321 -276
  76. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  77. package/dist/fixtures/inertTarget.d.ts +78 -7
  78. package/dist/fixtures/inertTarget.js +769 -691
  79. package/dist/fixtures/inertTarget.js.map +7 -1
  80. package/dist/fixtures/issue63.d.ts +4 -3
  81. package/dist/fixtures/issue63.js +260 -274
  82. package/dist/fixtures/issue63.js.map +7 -1
  83. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  84. package/dist/fixtures/issueProjectItems.js +15 -0
  85. package/dist/fixtures/issueProjectItems.js.map +7 -0
  86. package/dist/fixtures/readView.d.ts +120 -0
  87. package/dist/fixtures/readView.js +172 -0
  88. package/dist/fixtures/readView.js.map +7 -0
  89. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  90. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  91. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  92. package/dist/genericCompatibility.test.js +64 -55
  93. package/dist/genericCompatibility.test.js.map +7 -1
  94. package/dist/git.js +73 -67
  95. package/dist/git.js.map +7 -1
  96. package/dist/gitProcess.d.ts +1 -1
  97. package/dist/gitProcess.js +58 -53
  98. package/dist/gitProcess.js.map +7 -1
  99. package/dist/github/client.d.ts +2 -2
  100. package/dist/github/client.js +484 -379
  101. package/dist/github/client.js.map +7 -1
  102. package/dist/github/commandIdentityPolicy.js +44 -52
  103. package/dist/github/commandIdentityPolicy.js.map +7 -1
  104. package/dist/github/discovery.d.ts +1 -0
  105. package/dist/github/discovery.js +197 -215
  106. package/dist/github/discovery.js.map +7 -1
  107. package/dist/github/discovery.test.js +223 -177
  108. package/dist/github/discovery.test.js.map +7 -1
  109. package/dist/github/issueHistory.d.ts +2 -2
  110. package/dist/github/issueHistory.js +117 -125
  111. package/dist/github/issueHistory.js.map +7 -1
  112. package/dist/github/machineAuth.d.ts +1 -1
  113. package/dist/github/machineAuth.js +126 -117
  114. package/dist/github/machineAuth.js.map +7 -1
  115. package/dist/github/machineAuth.test.js +755 -639
  116. package/dist/github/machineAuth.test.js.map +7 -1
  117. package/dist/github/nativeIssueMetadata.js +286 -273
  118. package/dist/github/nativeIssueMetadata.js.map +7 -1
  119. package/dist/github/projectDelivery.d.ts +18 -2
  120. package/dist/github/projectDelivery.js +615 -557
  121. package/dist/github/projectDelivery.js.map +7 -1
  122. package/dist/github/relationships.js +433 -389
  123. package/dist/github/relationships.js.map +7 -1
  124. package/dist/github/repo.d.ts +1 -0
  125. package/dist/github/repo.js +123 -96
  126. package/dist/github/repo.js.map +7 -1
  127. package/dist/index.js +3 -3
  128. package/dist/index.js.map +7 -1
  129. package/dist/issue.d.ts +40 -9
  130. package/dist/issue.js +2102 -1742
  131. package/dist/issue.js.map +7 -1
  132. package/dist/issue63History.test.js +40 -42
  133. package/dist/issue63History.test.js.map +7 -1
  134. package/dist/issue63Routes.test.js +154 -143
  135. package/dist/issue63Routes.test.js.map +7 -1
  136. package/dist/issueBatchUpdate.test.js +989 -885
  137. package/dist/issueBatchUpdate.test.js.map +7 -1
  138. package/dist/issueBlockerGuard.test.js +262 -226
  139. package/dist/issueBlockerGuard.test.js.map +7 -1
  140. package/dist/issueContract.d.ts +23 -4
  141. package/dist/issueContract.js +416 -395
  142. package/dist/issueContract.js.map +7 -1
  143. package/dist/issueContract.test.d.ts +4 -3
  144. package/dist/issueContract.test.js +358 -321
  145. package/dist/issueContract.test.js.map +7 -1
  146. package/dist/issueDates.test.js +235 -233
  147. package/dist/issueDates.test.js.map +7 -1
  148. package/dist/issueInfoReadback.test.js +304 -190
  149. package/dist/issueInfoReadback.test.js.map +7 -1
  150. package/dist/issueIntake.test.js +1945 -1732
  151. package/dist/issueIntake.test.js.map +7 -1
  152. package/dist/issueJournal.d.ts +40 -19
  153. package/dist/issueJournal.js +229 -138
  154. package/dist/issueJournal.js.map +7 -1
  155. package/dist/issueJournal.test.js +605 -422
  156. package/dist/issueJournal.test.js.map +7 -1
  157. package/dist/issueRollup.test.d.ts +1 -0
  158. package/dist/issueRollup.test.js +476 -0
  159. package/dist/issueRollup.test.js.map +7 -0
  160. package/dist/issueTracking.test.js +1059 -989
  161. package/dist/issueTracking.test.js.map +7 -1
  162. package/dist/issueWriteRecovery.test.d.ts +1 -0
  163. package/dist/issueWriteRecovery.test.js +260 -0
  164. package/dist/issueWriteRecovery.test.js.map +7 -0
  165. package/dist/lifecycle.test.js +112 -441
  166. package/dist/lifecycle.test.js.map +7 -1
  167. package/dist/logger.js +80 -74
  168. package/dist/logger.js.map +7 -1
  169. package/dist/mcp/index.js +116 -94
  170. package/dist/mcp/index.js.map +7 -1
  171. package/dist/mcp/tools.d.ts +264 -286
  172. package/dist/mcp/tools.js +267 -340
  173. package/dist/mcp/tools.js.map +7 -1
  174. package/dist/pluginAuthProbe.js +63 -52
  175. package/dist/pluginAuthProbe.js.map +7 -1
  176. package/dist/pluginAuthProbe.test.js +85 -62
  177. package/dist/pluginAuthProbe.test.js.map +7 -1
  178. package/dist/pluginCredentials.test.js +282 -259
  179. package/dist/pluginCredentials.test.js.map +7 -1
  180. package/dist/pluginDoctor.test.js +653 -588
  181. package/dist/pluginDoctor.test.js.map +7 -1
  182. package/dist/pluginInstaller.d.ts +7 -5
  183. package/dist/pluginInstaller.js +1173 -1229
  184. package/dist/pluginInstaller.js.map +7 -1
  185. package/dist/pluginInstaller.test.js +1842 -1423
  186. package/dist/pluginInstaller.test.js.map +7 -1
  187. package/dist/pluginPackaging.test.js +460 -409
  188. package/dist/pluginPackaging.test.js.map +7 -1
  189. package/dist/pr.d.ts +132 -94
  190. package/dist/pr.js +1521 -1323
  191. package/dist/pr.js.map +7 -1
  192. package/dist/pr.test.js +1678 -632
  193. package/dist/pr.test.js.map +7 -1
  194. package/dist/prAssociation.test.js +2419 -1788
  195. package/dist/prAssociation.test.js.map +7 -1
  196. package/dist/prDispatch.test.js +150 -89
  197. package/dist/prDispatch.test.js.map +7 -1
  198. package/dist/readView.d.ts +183 -0
  199. package/dist/readView.js +217 -0
  200. package/dist/readView.js.map +7 -0
  201. package/dist/readView.test.d.ts +1 -0
  202. package/dist/readView.test.js +119 -0
  203. package/dist/readView.test.js.map +7 -0
  204. package/dist/releaseReconciliation.test.js +267 -288
  205. package/dist/releaseReconciliation.test.js.map +7 -1
  206. package/dist/releaseWorkflow.test.js +2493 -422
  207. package/dist/releaseWorkflow.test.js.map +7 -1
  208. package/dist/review.d.ts +738 -2
  209. package/dist/review.js +601 -348
  210. package/dist/review.js.map +7 -1
  211. package/dist/review.test.js +1218 -812
  212. package/dist/review.test.js.map +7 -1
  213. package/dist/reviewSubmit.test.d.ts +1 -0
  214. package/dist/reviewSubmit.test.js +747 -0
  215. package/dist/reviewSubmit.test.js.map +7 -0
  216. package/dist/services/agentReadinessService.js +42 -37
  217. package/dist/services/agentReadinessService.js.map +7 -1
  218. package/dist/services/blockerGuardService.js +188 -188
  219. package/dist/services/blockerGuardService.js.map +7 -1
  220. package/dist/services/boardReconcileService.d.ts +125 -125
  221. package/dist/services/boardReconcileService.js +1295 -1421
  222. package/dist/services/boardReconcileService.js.map +7 -1
  223. package/dist/services/deliveryAdmission.js +131 -154
  224. package/dist/services/deliveryAdmission.js.map +7 -1
  225. package/dist/services/deliveryHealthService.js +197 -199
  226. package/dist/services/deliveryHealthService.js.map +7 -1
  227. package/dist/services/legacyIssueMigration.js +263 -277
  228. package/dist/services/legacyIssueMigration.js.map +7 -1
  229. package/dist/services/worktreeRegistry.d.ts +27 -119
  230. package/dist/services/worktreeRegistry.js +765 -1182
  231. package/dist/services/worktreeRegistry.js.map +7 -1
  232. package/dist/stagedChecks.test.js +396 -194
  233. package/dist/stagedChecks.test.js.map +7 -1
  234. package/dist/start.test.js +99 -95
  235. package/dist/start.test.js.map +7 -1
  236. package/dist/stdoutRegression.test.js +353 -352
  237. package/dist/stdoutRegression.test.js.map +7 -1
  238. package/dist/targetPolicyDiscovery.test.js +141 -143
  239. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  240. package/dist/targetPolicyEntrypoints.test.js +308 -269
  241. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  242. package/dist/targetPolicyLocal.test.js +580 -1051
  243. package/dist/targetPolicyLocal.test.js.map +7 -1
  244. package/dist/targetPolicyRoutes.test.js +305 -281
  245. package/dist/targetPolicyRoutes.test.js.map +7 -1
  246. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  247. package/dist/targetRepositoryExecution.test.js +463 -0
  248. package/dist/targetRepositoryExecution.test.js.map +7 -0
  249. package/dist/terminalMessages.js +41 -35
  250. package/dist/terminalMessages.js.map +7 -1
  251. package/dist/toolOutput.d.ts +2 -0
  252. package/dist/toolOutput.js +36 -0
  253. package/dist/toolOutput.js.map +7 -0
  254. package/dist/toolOutput.test.d.ts +1 -0
  255. package/dist/toolOutput.test.js +240 -0
  256. package/dist/toolOutput.test.js.map +7 -0
  257. package/dist/utils/atomicJson.js +84 -76
  258. package/dist/utils/atomicJson.js.map +7 -1
  259. package/dist/utils/filesystem.js +15 -18
  260. package/dist/utils/filesystem.js.map +7 -1
  261. package/dist/utils/lockfile.js +68 -71
  262. package/dist/utils/lockfile.js.map +7 -1
  263. package/dist/verification.d.ts +1 -19
  264. package/dist/verification.js +1020 -1939
  265. package/dist/verification.js.map +7 -1
  266. package/dist/verificationGate.test.js +127 -117
  267. package/dist/verificationGate.test.js.map +7 -1
  268. package/dist/version.js +23 -24
  269. package/dist/version.js.map +7 -1
  270. package/dist/worktree.d.ts +3 -15
  271. package/dist/worktree.js +97 -177
  272. package/dist/worktree.js.map +7 -1
  273. package/package.json +9 -8
  274. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  275. package/plugins/ai-delivery/README.md +47 -156
  276. package/plugins/ai-delivery/plugin.json +1 -1
  277. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
  278. package/plugins/ai-delivery/runtime/dist/cli.js +358 -115
  279. package/plugins/ai-delivery/runtime/package.json +1 -1
  280. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  281. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  282. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  283. package/dist/investigationCompletion.test.js +0 -728
  284. package/dist/investigationCompletion.test.js.map +0 -1
  285. package/dist/setup.d.ts +0 -60
  286. package/dist/setup.js +0 -585
  287. package/dist/setup.js.map +0 -1
  288. package/dist/setup.test.js +0 -3329
  289. package/dist/setup.test.js.map +0 -1
  290. package/dist/worktreeTransition.d.ts +0 -211
  291. package/dist/worktreeTransition.js +0 -1037
  292. package/dist/worktreeTransition.js.map +0 -1
  293. package/dist/worktreeTransition.test.js +0 -1191
  294. package/dist/worktreeTransition.test.js.map +0 -1
  295. /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
  296. /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
  297. /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
@@ -1,341 +1,378 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'vitest';
3
- import { z } from 'zod';
4
- import { DraftIssue, ReadyIssue, IssueFields, IssueWriteSchema, ISSUE_JSON_SCHEMAS, ISSUE_BODY_MARKER, requireIssue, renderIssueBody, parseIssueBody, validateIssue, issueWarnings, } from './issueContract.js';
5
- import { AI_DELIVERY_MCP_TOOLS } from './mcp/index.js';
6
- export const validIssue = () => IssueFields.parse({
7
- title: 'Reject invalid widget identifiers before persistence',
8
- issueType: 'Feature',
9
- points: 2,
10
- problem: 'Malformed identifiers currently reach persistence.',
11
- outcome: 'Widget writes reject malformed identifiers before persistence.',
12
- acceptanceCriteria: [
13
- {
14
- behavior: 'An invalid widget identifier returns an error without a persistence call.',
15
- verifiedBy: 'A mocked persistence regression asserts the error and zero calls.',
16
- },
17
- ],
18
- outOfScope: ['Changing the storage engine.'],
19
- openQuestions: [],
20
- context: {
21
- components: ['widget intake'],
22
- files: ['src/widget.ts'],
23
- evidence: ['A portable synthetic identifier fixture.'],
24
- },
25
- });
26
- test('readable body length excludes embedded issue data and warns strictly above 4000', () => {
27
- for (const [length, warning] of [
28
- [3500, false],
29
- [4000, false],
30
- [4001, true],
31
- [4500, true],
32
- ]) {
33
- const issue = validIssue();
34
- issue.problem = '';
35
- const prefix = () => renderIssueBody(issue).split('<!-- ai-delivery:issue-data@1 ')[0];
36
- issue.problem = '<'.repeat(length - prefix().length);
37
- assert.equal(prefix().length, length);
38
- assert.equal(issueWarnings(issue).some((item) => item.code === 'body.length'), warning, String(length));
1
+ import assert from "node:assert/strict";
2
+ import { test } from "vitest";
3
+ import { z } from "zod";
4
+ import {
5
+ DraftIssue,
6
+ ReadyIssue,
7
+ IssueFields,
8
+ IssueWriteSchema,
9
+ ISSUE_JSON_SCHEMAS,
10
+ ISSUE_BODY_MARKER,
11
+ requireIssue,
12
+ renderIssueBody,
13
+ parseIssueBody,
14
+ validateIssue,
15
+ issueWarnings
16
+ } from "./issueContract.js";
17
+ import { AI_DELIVERY_MCP_TOOLS } from "./mcp/index.js";
18
+ const validIssue = () => IssueFields.parse({
19
+ title: "Reject invalid widget identifiers before persistence",
20
+ issueType: "Feature",
21
+ points: 2,
22
+ problem: "Malformed identifiers currently reach persistence.",
23
+ outcome: "Widget writes reject malformed identifiers before persistence.",
24
+ acceptanceCriteria: [
25
+ {
26
+ behavior: "An invalid widget identifier returns an error without a persistence call.",
27
+ verifiedBy: "A mocked persistence regression asserts the error and zero calls."
39
28
  }
29
+ ],
30
+ outOfScope: ["Changing the storage engine."],
31
+ openQuestions: [],
32
+ context: {
33
+ components: ["widget intake"],
34
+ files: ["src/widget.ts"],
35
+ evidence: ["A portable synthetic identifier fixture."]
36
+ }
40
37
  });
41
- test('multiline criteria keep nested bullets and verification attached to their own checkbox', () => {
38
+ test("readable body length excludes embedded issue data and warns strictly above 4000", () => {
39
+ for (const [length, warning] of [
40
+ [3500, false],
41
+ [4e3, false],
42
+ [4001, true],
43
+ [4500, true]
44
+ ]) {
42
45
  const issue = validIssue();
43
- issue.acceptanceCriteria = [
44
- {
45
- behavior: 'Reject malformed input:\n- Empty input\n - Whitespace only\n- Invalid shape',
46
- verifiedBy: 'Regression cases:\n- Empty and malformed',
47
- },
48
- { behavior: 'A valid input is stored once.', verifiedBy: 'One observed write.' },
49
- ];
50
- const actual = renderIssueBody(issue).split('## Acceptance criteria\n\n')[1].split('\n\n## Out of scope')[0];
51
- assert.equal(actual, '- [ ] Reject malformed input:\n - Empty input\n - Whitespace only\n - Invalid shape\n\n Verified by: Regression cases:\n - Empty and malformed\n- [ ] A valid input is stored once.\n Verified by: One observed write.');
46
+ issue.problem = "";
47
+ const prefix = () => renderIssueBody(issue).split("<!-- ai-delivery:issue-data@1 ")[0];
48
+ issue.problem = "<".repeat(length - prefix().length);
49
+ assert.equal(prefix().length, length);
50
+ assert.equal(
51
+ issueWarnings(issue).some((item) => item.code === "body.length"),
52
+ warning,
53
+ String(length)
54
+ );
55
+ }
52
56
  });
53
- test('MCP create/update fields derive from the canonical schema and patch omissions retain no defaults', () => {
54
- const create = AI_DELIVERY_MCP_TOOLS.find((t) => t.name === 'issue_create');
55
- const update = AI_DELIVERY_MCP_TOOLS.find((t) => t.name === 'issue_update');
56
- const shape = z.toJSONSchema(IssueWriteSchema).properties;
57
- for (const name of [
58
- 'acceptanceCriteria',
59
- 'context',
60
- 'outOfScope',
61
- 'openQuestions',
62
- 'problem',
63
- 'outcome',
64
- 'bug',
65
- 'draft',
66
- ]) {
67
- assert.deepEqual(z.toJSONSchema(create.inputSchema).properties?.[name], shape?.[name]);
68
- assert.deepEqual(z.toJSONSchema(update.inputSchema).properties?.[name], shape?.[name]);
69
- }
70
- assert.deepEqual(update.inputSchema.parse({ issueNumber: 17 }), { issueNumber: 17 });
71
- assert.ok('issueContract' in create);
72
- assert.deepEqual(create.issueContract, ISSUE_JSON_SCHEMAS, 'portable output is reachable through the existing packaged MCP export');
57
+ test("multiline criteria keep nested bullets and verification attached to their own checkbox", () => {
58
+ const issue = validIssue();
59
+ issue.acceptanceCriteria = [
60
+ {
61
+ behavior: "Reject malformed input:\n- Empty input\n - Whitespace only\n- Invalid shape",
62
+ verifiedBy: "Regression cases:\n- Empty and malformed"
63
+ },
64
+ { behavior: "A valid input is stored once.", verifiedBy: "One observed write." }
65
+ ];
66
+ const actual = renderIssueBody(issue).split("## Acceptance criteria\n\n")[1].split("\n\n## Out of scope")[0];
67
+ assert.equal(
68
+ actual,
69
+ "- [ ] Reject malformed input:\n - Empty input\n - Whitespace only\n - Invalid shape\n\n Verified by: Regression cases:\n - Empty and malformed\n- [ ] A valid input is stored once.\n Verified by: One observed write."
70
+ );
73
71
  });
74
- test('portable JSON Schema snapshot carries Ready bounds and distinguishes incomplete drafts', () => {
75
- const ready = ISSUE_JSON_SCHEMAS.ready;
76
- assert.deepEqual({
77
- draft: ready.properties?.draft,
78
- points: ready.properties?.points,
79
- title: ready.properties?.title,
80
- openQuestions: ready.properties?.openQuestions,
81
- }, {
82
- draft: { type: 'boolean', const: false, default: false },
83
- points: { type: 'integer', minimum: 1, maximum: 8 },
84
- title: { type: 'string', minLength: 10, maxLength: 80 },
85
- openQuestions: { default: [], type: 'array', items: { type: 'string' }, maxItems: 0 },
86
- });
87
- assert.ok(ready.required?.includes('points'));
88
- assert.ok(!ISSUE_JSON_SCHEMAS.draft.required?.includes('points'));
72
+ test("MCP create/update fields derive from the canonical schema and patch omissions retain no defaults", () => {
73
+ const create = AI_DELIVERY_MCP_TOOLS.find((t) => t.name === "issue_create");
74
+ const update = AI_DELIVERY_MCP_TOOLS.find((t) => t.name === "issue_update");
75
+ const shape = z.toJSONSchema(IssueWriteSchema).properties;
76
+ for (const name of [
77
+ "acceptanceCriteria",
78
+ "context",
79
+ "outOfScope",
80
+ "openQuestions",
81
+ "problem",
82
+ "outcome",
83
+ "bug",
84
+ "draft"
85
+ ]) {
86
+ assert.deepEqual(z.toJSONSchema(create.inputSchema).properties?.[name], shape?.[name]);
87
+ assert.deepEqual(z.toJSONSchema(update.inputSchema).properties?.[name], shape?.[name]);
88
+ }
89
+ assert.deepEqual(update.inputSchema.parse({ issueNumber: 17 }), { issueNumber: 17 });
90
+ assert.ok("issueContract" in create);
91
+ assert.deepEqual(
92
+ create.issueContract,
93
+ ISSUE_JSON_SCHEMAS,
94
+ "portable output is reachable through the existing packaged MCP export"
95
+ );
89
96
  });
90
- test('concrete domain wording remains Ready while generic completion claims fail', () => {
91
- for (const behavior of [
92
- 'The independently reviewed head SHA is sent as the merge guard.',
93
- 'A failed request leaves the Project Done column unchanged.',
94
- 'A verified token grants access only to its repository.',
95
- 'The adapter works with a missing local checkout and returns the selected repository.',
96
- ]) {
97
- const issue = validIssue();
98
- issue.acceptanceCriteria[0].behavior = behavior;
99
- assert.deepEqual(validateIssue(issue).failures, [], behavior);
100
- }
101
- for (const behavior of [
102
- 'The widget works correctly.',
103
- 'The change is reviewed.',
104
- 'The request is done.',
105
- 'The interface is user friendly.',
106
- ]) {
107
- const issue = validIssue();
108
- issue.acceptanceCriteria[0].behavior = behavior;
109
- assert.ok(validateIssue(issue).failures.some((f) => f.code === 'acceptance-criteria.vague'), behavior);
97
+ test("portable JSON Schema snapshot carries Ready bounds and distinguishes incomplete drafts", () => {
98
+ const ready = ISSUE_JSON_SCHEMAS.ready;
99
+ assert.deepEqual(
100
+ {
101
+ draft: ready.properties?.draft,
102
+ points: ready.properties?.points,
103
+ title: ready.properties?.title,
104
+ openQuestions: ready.properties?.openQuestions
105
+ },
106
+ {
107
+ draft: { type: "boolean", const: false, default: false },
108
+ points: { type: "integer", minimum: 1, maximum: 8 },
109
+ title: { type: "string", minLength: 10, maxLength: 80 },
110
+ openQuestions: { default: [], type: "array", items: { type: "string" }, maxItems: 0 }
110
111
  }
112
+ );
113
+ assert.deepEqual(ready.anyOf, [
114
+ { properties: { epic: { const: true } }, required: ["epic"] },
115
+ { required: ["points"] }
116
+ ]);
117
+ assert.ok(!ISSUE_JSON_SCHEMAS.draft.required?.includes("points"));
111
118
  });
112
- test('canonical bodies round trip every typed field, multiline markup and comment delimiters', () => {
119
+ test("concrete domain wording remains Ready while generic completion claims fail", () => {
120
+ for (const behavior of [
121
+ "The independently reviewed head SHA is sent as the merge guard.",
122
+ "A failed request leaves the Project Done column unchanged.",
123
+ "A verified token grants access only to its repository.",
124
+ "The adapter works with a missing local checkout and returns the selected repository."
125
+ ]) {
113
126
  const issue = validIssue();
114
- issue.context.evidence.push('Observed <!-- text -->\n## nested heading\n`code`');
115
- const body = renderIssueBody(issue);
116
- assert.ok(body.startsWith(ISSUE_BODY_MARKER + '\n\n## Status\n\nReady'));
117
- assert.deepEqual(parseIssueBody(body, { title: issue.title }).issue, issue);
118
- assert.equal(parseIssueBody(body, { title: issue.title }).legacy, false);
119
- assert.throws(() => parseIssueBody(body.replace('## Status\n\nReady', '## Status\n\nDraft'), { title: issue.title }), /body.canonical/u);
120
- assert.throws(() => parseIssueBody(body, { title: 'Different native title' }), /body.canonical/u);
127
+ issue.acceptanceCriteria[0].behavior = behavior;
128
+ assert.deepEqual(validateIssue(issue).failures, [], behavior);
129
+ }
130
+ for (const behavior of [
131
+ "The widget works correctly.",
132
+ "The change is reviewed.",
133
+ "The request is done.",
134
+ "The interface is user friendly."
135
+ ]) {
136
+ const issue = validIssue();
137
+ issue.acceptanceCriteria[0].behavior = behavior;
138
+ assert.ok(
139
+ validateIssue(issue).failures.some((f) => f.code === "acceptance-criteria.vague"),
140
+ behavior
141
+ );
142
+ }
143
+ });
144
+ test("canonical bodies round trip every typed field, multiline markup and comment delimiters", () => {
145
+ const issue = validIssue();
146
+ issue.context.evidence.push("Observed <!-- text -->\n## nested heading\n`code`");
147
+ const body = renderIssueBody(issue);
148
+ assert.ok(body.startsWith(ISSUE_BODY_MARKER + "\n\n## Status\n\nReady"));
149
+ assert.deepEqual(parseIssueBody(body, { title: issue.title }).issue, issue);
150
+ assert.equal(parseIssueBody(body, { title: issue.title }).legacy, false);
151
+ assert.throws(
152
+ () => parseIssueBody(body.replace("## Status\n\nReady", "## Status\n\nDraft"), { title: issue.title }),
153
+ /body.canonical/u
154
+ );
155
+ assert.throws(() => parseIssueBody(body, { title: "Different native title" }), /body.canonical/u);
121
156
  });
122
- test('lenient legacy conversion retains all bytes, portable verification and marker descriptions', () => {
123
- const body = '## Problem\nA literal ' +
124
- ISSUE_BODY_MARKER +
125
- ' is documentation.\n## Outcome\nReject malformed identifiers.\n## Acceptance Criteria\n- [ ] Invalid identifiers return an error before persistence.\n## Verification\nRun the synthetic identifier tests.\n## Out of scope\n- Storage engine changes.\n## Scope\nsrc/missing-in-this-checkout.ts\nUnclassified historical text.\n';
126
- const parsed = parseIssueBody(body, { title: validIssue().title, points: 2, issueType: 'Feature' });
127
- assert.equal(parsed.legacy, true);
128
- assert.equal(parsed.issue.legacyBody, body);
129
- assert.equal(parsed.issue.acceptanceCriteria[0]?.verifiedBy, 'Run the synthetic identifier tests.');
130
- const ready = requireIssue(parsed.issue);
131
- assert.deepEqual(parseIssueBody(renderIssueBody(ready), { title: ready.title }).issue, ready);
157
+ test("lenient legacy conversion retains all bytes, portable verification and marker descriptions", () => {
158
+ const body = "## Problem\nA literal " + ISSUE_BODY_MARKER + " is documentation.\n## Outcome\nReject malformed identifiers.\n## Acceptance Criteria\n- [ ] Invalid identifiers return an error before persistence.\n## Verification\nRun the synthetic identifier tests.\n## Out of scope\n- Storage engine changes.\n## Scope\nsrc/missing-in-this-checkout.ts\nUnclassified historical text.\n";
159
+ const parsed = parseIssueBody(body, { title: validIssue().title, points: 2, issueType: "Feature" });
160
+ assert.equal(parsed.legacy, true);
161
+ assert.equal(parsed.issue.legacyBody, body);
162
+ assert.equal(parsed.issue.acceptanceCriteria[0]?.verifiedBy, "Run the synthetic identifier tests.");
163
+ const ready = requireIssue(parsed.issue);
164
+ assert.deepEqual(parseIssueBody(renderIssueBody(ready), { title: ready.title }).issue, ready);
132
165
  });
133
- test('legacy conversion never fabricates missing verification or bug evidence', () => {
134
- const body = '## Problem\nA failure.\n## Outcome\nReject invalid widgets.\n## Acceptance Criteria\n- [ ] Invalid widgets are rejected before persistence.\n## Out of scope\n- Storage changes.\n';
135
- const parsed = parseIssueBody(body, { title: validIssue().title, points: 2, issueType: 'Bug' });
136
- const codes = validateIssue(parsed.issue).failures.map((f) => f.code);
137
- assert.ok(codes.includes('acceptance-criteria.fields'));
138
- assert.ok(codes.includes('bug.steps'));
139
- assert.ok(codes.includes('bug.environment'));
166
+ test("legacy conversion never fabricates missing verification or bug evidence", () => {
167
+ const body = "## Problem\nA failure.\n## Outcome\nReject invalid widgets.\n## Acceptance Criteria\n- [ ] Invalid widgets are rejected before persistence.\n## Out of scope\n- Storage changes.\n";
168
+ const parsed = parseIssueBody(body, { title: validIssue().title, points: 2, issueType: "Bug" });
169
+ const codes = validateIssue(parsed.issue).failures.map((f) => f.code);
170
+ assert.ok(codes.includes("acceptance-criteria.fields"));
171
+ assert.ok(codes.includes("bug.steps"));
172
+ assert.ok(codes.includes("bug.environment"));
140
173
  });
141
174
  const blockingCases = [
142
- [
143
- 'Points13',
144
- (i) => {
145
- i.points = 13;
146
- },
147
- 'points',
148
- ],
149
- [
150
- 'Points0',
151
- (i) => {
152
- i.points = 0;
153
- },
154
- 'points',
155
- ],
156
- [
157
- 'Points9',
158
- (i) => {
159
- i.points = 9;
160
- },
161
- 'points',
162
- ],
163
- [
164
- 'missing behavior',
165
- (i) => {
166
- i.acceptanceCriteria[0].behavior = '';
167
- },
168
- 'acceptance-criteria.fields',
169
- ],
170
- [
171
- 'missing verifiedBy',
172
- (i) => {
173
- i.acceptanceCriteria[0].verifiedBy = '';
174
- },
175
- 'acceptance-criteria.fields',
176
- ],
177
- [
178
- 'vague AC',
179
- (i) => {
180
- i.acceptanceCriteria[0].behavior = 'The widget works correctly.';
181
- },
182
- 'acceptance-criteria.vague',
183
- ],
184
- [
185
- 'no non-goal',
186
- (i) => {
187
- i.outOfScope = [];
188
- },
189
- 'out-of-scope',
190
- ],
191
- [
192
- 'open question',
193
- (i) => {
194
- i.openQuestions = ['Choose the persistence behavior.'];
195
- },
196
- 'open-questions',
197
- ],
198
- [
199
- 'vague title',
200
- (i) => {
201
- i.title = 'Fix things';
202
- },
203
- 'title.specific',
204
- ],
205
- [
206
- 'long title',
207
- (i) => {
208
- i.title = 'x'.repeat(81);
209
- },
210
- 'title.length',
211
- ],
212
- [
213
- 'type prefix',
214
- (i) => {
215
- i.title = 'Bug: Reject invalid widget identifiers';
216
- },
217
- 'title.prefix',
218
- ],
219
- [
220
- 'bug fields',
221
- (i) => {
222
- i.issueType = 'Bug';
223
- },
224
- 'bug',
225
- ],
226
- [
227
- 'secret',
228
- (i) => {
229
- i.problem = 'A fixture contains ' + ['gh', 'p_'].join('') + 'A'.repeat(24);
230
- },
231
- 'secrets',
232
- ],
175
+ [
176
+ "Points13",
177
+ (i) => {
178
+ i.points = 13;
179
+ },
180
+ "points"
181
+ ],
182
+ [
183
+ "Points0",
184
+ (i) => {
185
+ i.points = 0;
186
+ },
187
+ "points"
188
+ ],
189
+ [
190
+ "Points9",
191
+ (i) => {
192
+ i.points = 9;
193
+ },
194
+ "points"
195
+ ],
196
+ [
197
+ "missing behavior",
198
+ (i) => {
199
+ i.acceptanceCriteria[0].behavior = "";
200
+ },
201
+ "acceptance-criteria.fields"
202
+ ],
203
+ [
204
+ "missing verifiedBy",
205
+ (i) => {
206
+ i.acceptanceCriteria[0].verifiedBy = "";
207
+ },
208
+ "acceptance-criteria.fields"
209
+ ],
210
+ [
211
+ "vague AC",
212
+ (i) => {
213
+ i.acceptanceCriteria[0].behavior = "The widget works correctly.";
214
+ },
215
+ "acceptance-criteria.vague"
216
+ ],
217
+ [
218
+ "no non-goal",
219
+ (i) => {
220
+ i.outOfScope = [];
221
+ },
222
+ "out-of-scope"
223
+ ],
224
+ [
225
+ "open question",
226
+ (i) => {
227
+ i.openQuestions = ["Choose the persistence behavior."];
228
+ },
229
+ "open-questions"
230
+ ],
231
+ [
232
+ "vague title",
233
+ (i) => {
234
+ i.title = "Fix things";
235
+ },
236
+ "title.specific"
237
+ ],
238
+ [
239
+ "long title",
240
+ (i) => {
241
+ i.title = "x".repeat(81);
242
+ },
243
+ "title.length"
244
+ ],
245
+ [
246
+ "type prefix",
247
+ (i) => {
248
+ i.title = "Bug: Reject invalid widget identifiers";
249
+ },
250
+ "title.prefix"
251
+ ],
252
+ [
253
+ "bug fields",
254
+ (i) => {
255
+ i.issueType = "Bug";
256
+ },
257
+ "bug"
258
+ ],
259
+ [
260
+ "secret",
261
+ (i) => {
262
+ i.problem = "A fixture contains " + ["gh", "p_"].join("") + "A".repeat(24);
263
+ },
264
+ "secrets"
265
+ ]
233
266
  ];
234
267
  for (const [name, mutate, code] of blockingCases)
235
- test('Ready blocks ' + name + ' with a field and actionable fix hint', () => {
236
- const issue = validIssue();
237
- mutate(issue);
238
- const failures = validateIssue(issue).failures;
239
- assert.ok(failures.some((f) => f.code === code), JSON.stringify(failures));
240
- assert.ok(failures.every((f) => f.field.length > 0 && f.fixHint.length > 10));
241
- });
242
- for (const field of ['steps', 'expected', 'actual', 'reproducibility', 'environment'])
243
- test('Bug requires ' + field, () => {
244
- const issue = validIssue();
245
- issue.issueType = 'Bug';
246
- issue.bug = {
247
- steps: ['Submit an invalid identifier.'],
248
- expected: 'No write.',
249
- actual: 'A write occurs.',
250
- reproducibility: 'Every invalid input.',
251
- environment: 'Synthetic server, Node24.',
252
- };
253
- if (field === 'steps')
254
- issue.bug.steps = [];
255
- else
256
- issue.bug[field] = '';
257
- assert.ok(validateIssue(issue).failures.some((f) => f.code === 'bug.' + field));
258
- });
259
- test('Ready is the default; explicit drafts park incomplete requirements without permitting secrets', () => {
260
- assert.equal(requireIssue(validIssue()).draft, false);
261
- assert.equal(ReadyIssue.safeParse({ title: 'Investigate invalid widget identifiers', draft: true }).success, false);
262
- const draft = requireIssue({ title: 'Investigate invalid widget identifiers', draft: true });
263
- assert.equal(draft.draft, true);
264
- assert.match(renderIssueBody(draft), /Draft — parked/u);
265
- assert.equal(DraftIssue.safeParse({ ...draft, problem: 'password=' + 'X'.repeat(16) }).success, false);
268
+ test("Ready blocks " + name + " with a field and actionable fix hint", () => {
269
+ const issue = validIssue();
270
+ mutate(issue);
271
+ const failures = validateIssue(issue).failures;
272
+ assert.ok(
273
+ failures.some((f) => f.code === code),
274
+ JSON.stringify(failures)
275
+ );
276
+ assert.ok(failures.every((f) => f.field.length > 0 && f.fixHint.length > 10));
277
+ });
278
+ for (const field of ["steps", "expected", "actual", "reproducibility", "environment"])
279
+ test("Bug requires " + field, () => {
280
+ const issue = validIssue();
281
+ issue.issueType = "Bug";
282
+ issue.bug = {
283
+ steps: ["Submit an invalid identifier."],
284
+ expected: "No write.",
285
+ actual: "A write occurs.",
286
+ reproducibility: "Every invalid input.",
287
+ environment: "Synthetic server, Node24."
288
+ };
289
+ if (field === "steps") issue.bug.steps = [];
290
+ else issue.bug[field] = "";
291
+ assert.ok(validateIssue(issue).failures.some((f) => f.code === "bug." + field));
292
+ });
293
+ test("Ready is the default; explicit drafts park incomplete requirements without permitting secrets", () => {
294
+ assert.equal(requireIssue(validIssue()).draft, false);
295
+ assert.equal(ReadyIssue.safeParse({ title: "Investigate invalid widget identifiers", draft: true }).success, false);
296
+ const draft = requireIssue({ title: "Investigate invalid widget identifiers", draft: true });
297
+ assert.equal(draft.draft, true);
298
+ assert.match(renderIssueBody(draft), /Draft — parked/u);
299
+ assert.equal(DraftIssue.safeParse({ ...draft, problem: "password=" + "X".repeat(16) }).success, false);
266
300
  });
267
- test('independent Ready failures remain actionable together when native Points are missing', () => {
268
- const failures = validateIssue({
269
- title: 'Investigate malformed widget identifiers',
270
- issueType: 'Bug',
271
- problem: 'A malformed identifier reaches storage.',
272
- outcome: 'Reject malformed identifiers.',
273
- acceptanceCriteria: [],
274
- outOfScope: [],
275
- openQuestions: ['Choose the return shape.'],
276
- }).failures;
277
- for (const code of ['points', 'bug', 'acceptance-criteria', 'out-of-scope', 'open-questions'])
278
- assert.ok(failures.some((f) => f.code === code));
279
- assert.equal(new Set(failures.map((f) => f.code + ':' + f.field)).size, failures.length);
301
+ test("independent Ready failures remain actionable together when native Points are missing", () => {
302
+ const failures = validateIssue({
303
+ title: "Investigate malformed widget identifiers",
304
+ issueType: "Bug",
305
+ problem: "A malformed identifier reaches storage.",
306
+ outcome: "Reject malformed identifiers.",
307
+ acceptanceCriteria: [],
308
+ outOfScope: [],
309
+ openQuestions: ["Choose the return shape."]
310
+ }).failures;
311
+ for (const code of ["points", "bug", "acceptance-criteria", "out-of-scope", "open-questions"])
312
+ assert.ok(failures.some((f) => f.code === code));
313
+ assert.equal(new Set(failures.map((f) => f.code + ":" + f.field)).size, failures.length);
280
314
  });
281
315
  const warningCases = [
282
- [
283
- 'many criteria',
284
- (i) => {
285
- i.acceptanceCriteria = Array.from({ length: 8 }, () => ({ ...i.acceptanceCriteria[0] }));
286
- },
287
- 'many-criteria',
288
- ],
289
- [
290
- 'no edge case',
291
- (i) => {
292
- i.acceptanceCriteria[0].behavior = 'A valid identifier produces exactly one persisted widget.';
293
- },
294
- 'edge-case',
295
- ],
296
- [
297
- 'Bug without regression',
298
- (i) => {
299
- i.issueType = 'Bug';
300
- i.bug = {
301
- steps: ['Submit an invalid identifier.'],
302
- expected: 'No write.',
303
- actual: 'A write occurs.',
304
- reproducibility: 'Every input.',
305
- environment: 'Synthetic server.',
306
- };
307
- i.acceptanceCriteria[0].verifiedBy = 'A mock asserts zero persistence calls.';
308
- },
309
- 'bug.regression',
310
- ],
311
- [
312
- 'no context',
313
- (i) => {
314
- i.context = { files: [], components: [], evidence: [] };
315
- },
316
- 'context',
317
- ],
318
- [
319
- 'only local evidence',
320
- (i) => {
321
- i.context.evidence = ['/synthetic/machine/proof.txt'];
322
- i.acceptanceCriteria[0].verifiedBy = '/synthetic/machine/test.ts';
323
- },
324
- 'local-evidence',
325
- ],
326
- [
327
- 'long body',
328
- (i) => {
329
- i.context.evidence.push('A'.repeat(4500));
330
- },
331
- 'body.length',
332
- ],
316
+ [
317
+ "many criteria",
318
+ (i) => {
319
+ i.acceptanceCriteria = Array.from({ length: 8 }, () => ({ ...i.acceptanceCriteria[0] }));
320
+ },
321
+ "many-criteria"
322
+ ],
323
+ [
324
+ "no edge case",
325
+ (i) => {
326
+ i.acceptanceCriteria[0].behavior = "A valid identifier produces exactly one persisted widget.";
327
+ },
328
+ "edge-case"
329
+ ],
330
+ [
331
+ "Bug without regression",
332
+ (i) => {
333
+ i.issueType = "Bug";
334
+ i.bug = {
335
+ steps: ["Submit an invalid identifier."],
336
+ expected: "No write.",
337
+ actual: "A write occurs.",
338
+ reproducibility: "Every input.",
339
+ environment: "Synthetic server."
340
+ };
341
+ i.acceptanceCriteria[0].verifiedBy = "A mock asserts zero persistence calls.";
342
+ },
343
+ "bug.regression"
344
+ ],
345
+ [
346
+ "no context",
347
+ (i) => {
348
+ i.context = { files: [], components: [], evidence: [] };
349
+ },
350
+ "context"
351
+ ],
352
+ [
353
+ "only local evidence",
354
+ (i) => {
355
+ i.context.evidence = ["/synthetic/machine/proof.txt"];
356
+ i.acceptanceCriteria[0].verifiedBy = "/synthetic/machine/test.ts";
357
+ },
358
+ "local-evidence"
359
+ ],
360
+ [
361
+ "long body",
362
+ (i) => {
363
+ i.context.evidence.push("A".repeat(4500));
364
+ },
365
+ "body.length"
366
+ ]
333
367
  ];
334
368
  for (const [name, mutate, code] of warningCases)
335
- test('Warning does not block ' + name, () => {
336
- const issue = validIssue();
337
- mutate(issue);
338
- assert.equal(validateIssue(issue).failures.length, 0);
339
- assert.ok(issueWarnings(issue).some((w) => w.code === code));
340
- });
341
- //# sourceMappingURL=issueContract.test.js.map
369
+ test("Warning does not block " + name, () => {
370
+ const issue = validIssue();
371
+ mutate(issue);
372
+ assert.equal(validateIssue(issue).failures.length, 0);
373
+ assert.ok(issueWarnings(issue).some((w) => w.code === code));
374
+ });
375
+ export {
376
+ validIssue
377
+ };
378
+ //# sourceMappingURL=issueContract.test.js.map