@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,283 +1,328 @@
1
- import assert from 'node:assert/strict';
2
- import { execFileSync } from 'node:child_process';
3
- import { createHash } from 'node:crypto';
4
- import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync, } from 'node:fs';
5
- import { tmpdir } from 'node:os';
6
- import { dirname, join } from 'node:path';
7
- import { syntheticDiscoveryClients } from './discovery.js';
8
- const digestBytes = (bytes) => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
9
- /** Read-only remote ports; unexpected operations fail rather than touching any service. */
10
- export function entrypointClients(head) {
11
- const calls = [];
12
- const record = (name, input = null) => calls.push({ name, input });
13
- const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
14
- const issue = {
15
- number: 17,
16
- node_id: 'ISSUE17',
17
- title: 'Fictional widget',
18
- body: 'Consumer script-looking prose is data.',
19
- state: 'open',
20
- type: { name: 'Task' },
21
- html_url: 'https://github.com/example/widget/issues/17',
22
- };
23
- const pr = {
24
- number: 23,
25
- state: 'open',
26
- draft: false,
27
- merged: false,
28
- head: { sha: head, ref: 'issue/17', repo: { full_name: 'example/widget' } },
29
- base: { sha: head, ref: 'main', repo: { full_name: 'example/widget' } },
30
- html_url: 'https://github.com/example/widget/pull/23',
1
+ import { issueProjectItemsResponse } from "./issueProjectItems.js";
2
+ import assert from "node:assert/strict";
3
+ import { execFileSync } from "node:child_process";
4
+ import { createHash } from "node:crypto";
5
+ import {
6
+ existsSync,
7
+ lstatSync,
8
+ mkdirSync,
9
+ mkdtempSync,
10
+ readFileSync,
11
+ realpathSync,
12
+ rmSync,
13
+ writeFileSync
14
+ } from "node:fs";
15
+ import { tmpdir } from "node:os";
16
+ import { dirname, join } from "node:path";
17
+ import { syntheticDiscoveryClients } from "./discovery.js";
18
+ const digestBytes = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
19
+ function entrypointClients(head) {
20
+ const calls = [];
21
+ const record = (name, input = null) => calls.push({ name, input });
22
+ const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
23
+ const issue = {
24
+ id: 117,
25
+ number: 17,
26
+ node_id: "ISSUE17",
27
+ title: "Fictional widget",
28
+ body: "Consumer script-looking prose is data.",
29
+ state: "open",
30
+ type: { name: "Task" },
31
+ html_url: "https://github.com/example/widget/issues/17",
32
+ url: "https://api.github.com/repos/example/widget/issues/17",
33
+ repository_url: "https://api.github.com/repos/example/widget"
34
+ };
35
+ const children = [19, 18].map((number) => ({
36
+ ...issue,
37
+ id: 100 + number,
38
+ number,
39
+ node_id: `ISSUE${number}`,
40
+ state: number === 18 ? "closed" : "open",
41
+ html_url: `https://github.com/example/widget/issues/${number}`,
42
+ url: `https://api.github.com/repos/example/widget/issues/${number}`
43
+ }));
44
+ const pr = {
45
+ number: 23,
46
+ state: "open",
47
+ draft: false,
48
+ merged: false,
49
+ head: { sha: head, ref: "issue/17", repo: { full_name: "example/widget" } },
50
+ base: { sha: head, ref: "main", repo: { full_name: "example/widget" } },
51
+ html_url: "https://github.com/example/widget/pull/23"
52
+ };
53
+ const item = {
54
+ id: "ITEM17",
55
+ isArchived: false,
56
+ content: { __typename: "Issue", id: "ISSUE17" },
57
+ project: { id: "PROJECT-1", number: 1 },
58
+ fieldValueByName: {
59
+ __typename: "ProjectV2ItemFieldSingleSelectValue",
60
+ optionId: "STATUS-0",
61
+ name: "Queued",
62
+ field: { id: "STATUS-FIELD", name: "Flow" }
63
+ }
64
+ };
65
+ const request = async (route, input) => {
66
+ record(route, input);
67
+ if (route === "GET /orgs/{org}/issue-fields")
68
+ return {
69
+ data: [
70
+ { id: 101, name: "Estimate", data_type: "single_select" },
71
+ { id: 102, name: "Urgency", data_type: "single_select" }
72
+ ]
73
+ };
74
+ if (route === "GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values")
75
+ return {
76
+ data: [
77
+ {
78
+ issue_field_id: 101,
79
+ issue_field_name: "Estimate",
80
+ data_type: "single_select",
81
+ value: "2",
82
+ single_select_option: { name: "2" }
83
+ },
84
+ {
85
+ issue_field_id: 102,
86
+ issue_field_name: "Urgency",
87
+ data_type: "single_select",
88
+ value: "High",
89
+ single_select_option: { name: "High" }
90
+ }
91
+ ]
92
+ };
93
+ if (route === "GET /repos/{owner}/{repo}/rules/branches/{branch}") return { data: [] };
94
+ if (route === "GET /repos/{owner}/{repo}/branches/{branch}/protection")
95
+ return { data: { required_pull_request_reviews: { required_approving_review_count: 1 } } };
96
+ throw new Error(`Unexpected fictional REST operation: ${route}`);
97
+ };
98
+ const listSubIssues = async (input) => {
99
+ record("issues.listSubIssues", input);
100
+ return { data: children };
101
+ };
102
+ const listPulls = async (input) => {
103
+ record("pulls.list", input);
104
+ return { data: [pr] };
105
+ };
106
+ const rest = {
107
+ request,
108
+ issues: {
109
+ get: async (input) => {
110
+ record("issues.get", input);
111
+ return { data: issue };
112
+ },
113
+ listSubIssues
114
+ },
115
+ pulls: {
116
+ get: async (input) => {
117
+ record("pulls.get", input);
118
+ return { data: pr };
119
+ },
120
+ list: listPulls
121
+ },
122
+ repos: {
123
+ get: async (input) => {
124
+ record("repos.get", input);
125
+ return { data: { full_name: "example/widget", default_branch: "main" } };
126
+ },
127
+ getCombinedStatusForRef: async (input) => {
128
+ record("repos.getCombinedStatusForRef", input);
129
+ return { data: { state: "success" } };
130
+ }
131
+ },
132
+ checks: {
133
+ listForRef: async (input) => {
134
+ record("checks.listForRef", input);
135
+ return { data: { check_runs: [{ name: "checks", status: "completed", conclusion: "success" }] } };
136
+ }
137
+ },
138
+ paginate: async (method, input) => {
139
+ assert.ok(method === listSubIssues || method === listPulls, "Only selected read-only pagination is admitted");
140
+ return (await method(input)).data;
141
+ }
142
+ };
143
+ const graphql = async (query, input = {}) => {
144
+ record(query.match(/(?:query|mutation)\s+(\w+)/u)?.[1] ?? "relationships", input);
145
+ if (query.includes("ProjectDeliveryIssueItems"))
146
+ return issueProjectItemsResponse(
147
+ input,
148
+ [
149
+ item,
150
+ ...children.map((child) => ({
151
+ ...item,
152
+ id: `ITEM${child.number}`,
153
+ content: { __typename: "Issue", id: child.node_id },
154
+ fieldValueByName: {
155
+ ...item.fieldValueByName,
156
+ optionId: child.number === 18 ? "STATUS-3" : "STATUS-1",
157
+ name: child.number === 18 ? "Shipped" : "Active"
158
+ }
159
+ }))
160
+ ].filter((row) => row.content.id === input.issueNodeId),
161
+ { id: "PROJECT-1", number: 1 }
162
+ );
163
+ if (query.includes("blockedBy(first:"))
164
+ return {
165
+ repository: {
166
+ issue: {
167
+ parent: { id: "ISSUE11", number: 11, repository: { nameWithOwner: "example/widget" } },
168
+ blockedBy: page([
169
+ {
170
+ id: "ISSUE13",
171
+ number: 13,
172
+ state: "OPEN",
173
+ title: "Fictional prerequisite",
174
+ repository: { nameWithOwner: "example/widget" }
175
+ }
176
+ ])
177
+ }
178
+ }
179
+ };
180
+ if (query.includes("DeliveryReviewDecision"))
181
+ return { repository: { pullRequest: { headRefOid: head, reviewDecision: "APPROVED" } } };
182
+ return syntheticDiscoveryClients().graphql(query, input);
183
+ };
184
+ const create = async (input) => {
185
+ assert.equal(input.identity, input.role);
186
+ record("createDeliveryGitHubClients", { role: input.role, identity: input.identity });
187
+ return {
188
+ role: input.role,
189
+ authSource: input.role === "author" ? "personal" : "app",
190
+ credentialSource: "fictional-port",
191
+ effectiveContentsPermission: "write",
192
+ rest,
193
+ graphql,
194
+ authenticatedAuthor: async () => {
195
+ record("authenticatedAuthor");
196
+ return { actorLogin: "operator", credentialIdentity: "user:42" };
197
+ },
198
+ appActorLogin: async () => {
199
+ record("appActorLogin");
200
+ return "reviewer[bot]";
201
+ }
31
202
  };
32
- const item = {
33
- id: 'ITEM17',
34
- isArchived: false,
35
- content: { __typename: 'Issue', id: 'ISSUE17' },
36
- project: { id: 'PROJECT-1', number: 1 },
37
- fieldValueByName: {
38
- __typename: 'ProjectV2ItemFieldSingleSelectValue',
39
- optionId: 'STATUS-0',
40
- name: 'Queued',
41
- field: { id: 'STATUS-FIELD', name: 'Flow' },
203
+ };
204
+ return { create, calls };
205
+ }
206
+ function freshEntrypointFixture(kind) {
207
+ const base = realpathSync(mkdtempSync(join(tmpdir(), "ai-delivery-entrypoint-")));
208
+ const identity = lstatSync(base);
209
+ try {
210
+ const root = join(base, "consumer"), home = join(base, "home"), temp = join(base, "tmp");
211
+ for (const path of [root, home, temp]) mkdirSync(path, { mode: 448 });
212
+ const sentinel = join(base, "policy-executed");
213
+ const payload = (marker) => `import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},JSON.stringify({marker:${JSON.stringify(marker)},module:import.meta.url}),{flag:'wx'});export const deliverySettings={};
214
+ `;
215
+ const tracked = payload("tracked"), edited = payload("edited");
216
+ const selected = kind === "tracked" ? tracked : edited;
217
+ const userPath = join(base, "user.json");
218
+ writeFileSync(
219
+ userPath,
220
+ JSON.stringify({
221
+ schemaVersion: "ai-delivery.user@1",
222
+ roles: {
223
+ author: { authSource: "personal", identity: "author", credentialEnv: { token: "FICTIONAL_AUTHOR_TOKEN" } },
224
+ reviewer: {
225
+ identity: "reviewer",
226
+ credentialEnv: {
227
+ appId: "FICTIONAL_REVIEW_APP",
228
+ installationId: "FICTIONAL_REVIEW_INSTALL",
229
+ privateKeyPath: "FICTIONAL_REVIEW_KEY"
230
+ }
231
+ }
42
232
  },
233
+ checkoutRoots: [base],
234
+ project: 1,
235
+ pointsField: "Estimate",
236
+ priorityField: "Urgency",
237
+ statusField: "Flow",
238
+ statuses: { blocked: "Waiting", done: "Shipped", inProgress: "Active", todo: "Queued" },
239
+ issueTypes: ["Task"]
240
+ }),
241
+ { mode: 384 }
242
+ );
243
+ const env = {
244
+ PATH: `${dirname(process.execPath)}:/usr/bin:/bin`,
245
+ HOME: home,
246
+ TMPDIR: temp,
247
+ AI_DELIVERY_CONFIG: userPath,
248
+ GIT_CONFIG_NOSYSTEM: "1",
249
+ GIT_CONFIG_GLOBAL: "/dev/null",
250
+ GIT_TERMINAL_PROMPT: "0",
251
+ GIT_AUTHOR_NAME: "Fictional Operator",
252
+ GIT_AUTHOR_EMAIL: "operator@example.invalid",
253
+ GIT_COMMITTER_NAME: "Fictional Operator",
254
+ GIT_COMMITTER_EMAIL: "operator@example.invalid"
43
255
  };
44
- const request = async (route, input) => {
45
- record(route, input);
46
- if (route === 'GET /orgs/{org}/issue-fields')
47
- return {
48
- data: [
49
- { id: 101, name: 'Estimate', data_type: 'single_select' },
50
- { id: 102, name: 'Urgency', data_type: 'single_select' },
51
- ],
52
- };
53
- if (route === 'GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values')
54
- return {
55
- data: [
56
- {
57
- issue_field_id: 101,
58
- issue_field_name: 'Estimate',
59
- data_type: 'single_select',
60
- value: '2',
61
- single_select_option: { name: '2' },
62
- },
63
- {
64
- issue_field_id: 102,
65
- issue_field_name: 'Urgency',
66
- data_type: 'single_select',
67
- value: 'High',
68
- single_select_option: { name: 'High' },
69
- },
70
- ],
71
- };
72
- if (route === 'GET /repos/{owner}/{repo}/rules/branches/{branch}')
73
- return { data: [] };
74
- if (route === 'GET /repos/{owner}/{repo}/branches/{branch}/protection')
75
- return { data: { required_pull_request_reviews: { required_approving_review_count: 1 } } };
76
- throw new Error(`Unexpected fictional REST operation: ${route}`);
256
+ const git = (...args) => execFileSync(
257
+ "git",
258
+ [
259
+ "-c",
260
+ "core.hooksPath=/dev/null",
261
+ "-c",
262
+ "core.fsmonitor=false",
263
+ "-c",
264
+ "credential.helper=",
265
+ "-C",
266
+ root,
267
+ ...args
268
+ ],
269
+ { env, encoding: "utf8", timeout: 5e3, maxBuffer: 64 * 1024, stdio: ["ignore", "pipe", "pipe"] }
270
+ ).trim();
271
+ const policy = join(root, "ai-delivery.policy.mjs");
272
+ writeFileSync(policy, tracked);
273
+ git("init", "-q", "-b", "main");
274
+ git("remote", "add", "origin", "https://github.com/example/widget.git");
275
+ git("add", ".");
276
+ git("commit", "-qm", "Fictional consumer policy");
277
+ const head = git("rev-parse", "HEAD");
278
+ if (kind === "edited") writeFileSync(policy, edited);
279
+ assert.equal(git("show", "HEAD:ai-delivery.policy.mjs"), tracked.trim());
280
+ assert.equal(git("show", ":ai-delivery.policy.mjs"), tracked.trim());
281
+ assert.equal(readFileSync(policy, "utf8"), selected);
282
+ assert.equal(git("status", "--porcelain"), kind === "edited" ? "M ai-delivery.policy.mjs" : "");
283
+ const assertInert = () => assert.equal(existsSync(sentinel), false, "Consumer policy was executed by a public entrypoint");
284
+ const assertBound = () => {
285
+ assert.equal(git("rev-parse", "HEAD"), head);
286
+ assert.equal(git("show", "HEAD:ai-delivery.policy.mjs"), tracked.trim());
287
+ assert.equal(git("show", ":ai-delivery.policy.mjs"), tracked.trim());
288
+ assert.equal(readFileSync(policy, "utf8"), selected);
77
289
  };
78
- const listSubIssues = async (input) => {
79
- record('issues.listSubIssues', input);
80
- return { data: [{ number: 19 }, { number: 18 }] };
290
+ const cleanup = () => {
291
+ const current = lstatSync(base);
292
+ assert.equal(realpathSync(base), base);
293
+ assert.equal(current.isSymbolicLink(), false);
294
+ assert.equal(current.dev, identity.dev);
295
+ assert.equal(current.ino, identity.ino);
296
+ rmSync(base, { recursive: true });
297
+ assert.equal(existsSync(base), false);
81
298
  };
82
- const listPulls = async (input) => {
83
- record('pulls.list', input);
84
- return { data: [pr] };
299
+ return {
300
+ base,
301
+ root,
302
+ home,
303
+ head,
304
+ env,
305
+ sentinel,
306
+ policy,
307
+ tracked,
308
+ selected,
309
+ assertInert,
310
+ assertBound,
311
+ cleanup,
312
+ payloadSha256: digestBytes(Buffer.from(selected)),
313
+ indexedSha256: digestBytes(Buffer.from(tracked))
85
314
  };
86
- const rest = {
87
- request,
88
- issues: {
89
- get: async (input) => {
90
- record('issues.get', input);
91
- return { data: issue };
92
- },
93
- listSubIssues,
94
- },
95
- pulls: {
96
- get: async (input) => {
97
- record('pulls.get', input);
98
- return { data: pr };
99
- },
100
- list: listPulls,
101
- },
102
- repos: {
103
- get: async (input) => {
104
- record('repos.get', input);
105
- return { data: { full_name: 'example/widget', default_branch: 'main' } };
106
- },
107
- getCombinedStatusForRef: async (input) => {
108
- record('repos.getCombinedStatusForRef', input);
109
- return { data: { state: 'success' } };
110
- },
111
- },
112
- checks: {
113
- listForRef: async (input) => {
114
- record('checks.listForRef', input);
115
- return { data: { check_runs: [{ name: 'checks', status: 'completed', conclusion: 'success' }] } };
116
- },
117
- },
118
- paginate: async (method, input) => {
119
- assert.ok(method === listSubIssues || method === listPulls, 'Only selected read-only pagination is admitted');
120
- return (await method(input)).data;
121
- },
122
- };
123
- const graphql = async (query, input = {}) => {
124
- record(query.match(/(?:query|mutation)\s+(\w+)/u)?.[1] ?? 'relationships', input);
125
- if (query.includes('ProjectDeliveryItems'))
126
- return { organization: { projectV2: { id: 'PROJECT-1', items: page([item]) } } };
127
- if (query.includes('blockedBy(first:'))
128
- return {
129
- repository: {
130
- issue: {
131
- parent: { id: 'ISSUE11', number: 11, repository: { nameWithOwner: 'example/widget' } },
132
- blockedBy: page([
133
- {
134
- id: 'ISSUE13',
135
- number: 13,
136
- state: 'OPEN',
137
- title: 'Fictional prerequisite',
138
- repository: { nameWithOwner: 'example/widget' },
139
- },
140
- ]),
141
- },
142
- },
143
- };
144
- if (query.includes('DeliveryReviewDecision'))
145
- return { repository: { pullRequest: { headRefOid: head, reviewDecision: 'APPROVED' } } };
146
- return syntheticDiscoveryClients().graphql(query, input);
147
- };
148
- const create = async (input) => {
149
- assert.equal(input.identity, input.role);
150
- record('createDeliveryGitHubClients', { role: input.role, identity: input.identity });
151
- return {
152
- role: input.role,
153
- authSource: input.role === 'author' ? 'personal' : 'app',
154
- credentialSource: 'fictional-port',
155
- effectiveContentsPermission: 'write',
156
- rest,
157
- graphql,
158
- authenticatedAuthor: async () => {
159
- record('authenticatedAuthor');
160
- return { actorLogin: 'operator', credentialIdentity: 'user:42' };
161
- },
162
- appActorLogin: async () => {
163
- record('appActorLogin');
164
- return 'reviewer[bot]';
165
- },
166
- };
167
- };
168
- return { create, calls };
169
- }
170
- /** No inherited authentication environment, host home or consumer executables. */
171
- export function freshEntrypointFixture(kind) {
172
- const base = realpathSync(mkdtempSync(join(tmpdir(), 'ai-delivery-entrypoint-')));
173
- const identity = lstatSync(base);
174
- try {
175
- const root = join(base, 'consumer'), home = join(base, 'home'), temp = join(base, 'tmp');
176
- for (const path of [root, home, temp])
177
- mkdirSync(path, { mode: 0o700 });
178
- const sentinel = join(base, 'policy-executed');
179
- const payload = (marker) => `import {writeFileSync} from 'node:fs';writeFileSync(${JSON.stringify(sentinel)},JSON.stringify({marker:${JSON.stringify(marker)},module:import.meta.url}),{flag:'wx'});export const deliverySettings={};\n`;
180
- const tracked = payload('tracked'), edited = payload('edited');
181
- const selected = kind === 'tracked' ? tracked : edited;
182
- const userPath = join(base, 'user.json');
183
- writeFileSync(userPath, JSON.stringify({
184
- schemaVersion: 'ai-delivery.user@1',
185
- roles: {
186
- author: { authSource: 'personal', identity: 'author', credentialEnv: { token: 'FICTIONAL_AUTHOR_TOKEN' } },
187
- reviewer: {
188
- identity: 'reviewer',
189
- credentialEnv: {
190
- appId: 'FICTIONAL_REVIEW_APP',
191
- installationId: 'FICTIONAL_REVIEW_INSTALL',
192
- privateKeyPath: 'FICTIONAL_REVIEW_KEY',
193
- },
194
- },
195
- },
196
- checkoutRoots: [base],
197
- project: 1,
198
- pointsField: 'Estimate',
199
- priorityField: 'Urgency',
200
- statusField: 'Flow',
201
- statuses: { blocked: 'Waiting', done: 'Shipped', inProgress: 'Active', todo: 'Queued' },
202
- issueTypes: ['Task'],
203
- }), { mode: 0o600 });
204
- const env = {
205
- PATH: `${dirname(process.execPath)}:/usr/bin:/bin`,
206
- HOME: home,
207
- TMPDIR: temp,
208
- AI_DELIVERY_CONFIG: userPath,
209
- GIT_CONFIG_NOSYSTEM: '1',
210
- GIT_CONFIG_GLOBAL: '/dev/null',
211
- GIT_TERMINAL_PROMPT: '0',
212
- GIT_AUTHOR_NAME: 'Fictional Operator',
213
- GIT_AUTHOR_EMAIL: 'operator@example.invalid',
214
- GIT_COMMITTER_NAME: 'Fictional Operator',
215
- GIT_COMMITTER_EMAIL: 'operator@example.invalid',
216
- };
217
- const git = (...args) => execFileSync('git', [
218
- '-c',
219
- 'core.hooksPath=/dev/null',
220
- '-c',
221
- 'core.fsmonitor=false',
222
- '-c',
223
- 'credential.helper=',
224
- '-C',
225
- root,
226
- ...args,
227
- ], { env, encoding: 'utf8', timeout: 5_000, maxBuffer: 64 * 1024, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
228
- const policy = join(root, 'ai-delivery.policy.mjs');
229
- writeFileSync(policy, tracked);
230
- git('init', '-q', '-b', 'main');
231
- git('remote', 'add', 'origin', 'https://github.com/example/widget.git');
232
- git('add', '.');
233
- git('commit', '-qm', 'Fictional consumer policy');
234
- const head = git('rev-parse', 'HEAD');
235
- if (kind === 'edited')
236
- writeFileSync(policy, edited);
237
- assert.equal(git('show', 'HEAD:ai-delivery.policy.mjs'), tracked.trim());
238
- assert.equal(git('show', ':ai-delivery.policy.mjs'), tracked.trim());
239
- assert.equal(readFileSync(policy, 'utf8'), selected);
240
- assert.equal(git('status', '--porcelain'), kind === 'edited' ? 'M ai-delivery.policy.mjs' : '');
241
- const assertInert = () => assert.equal(existsSync(sentinel), false, 'Consumer policy was executed by a public entrypoint');
242
- const assertBound = () => {
243
- assert.equal(git('rev-parse', 'HEAD'), head);
244
- assert.equal(git('show', 'HEAD:ai-delivery.policy.mjs'), tracked.trim());
245
- assert.equal(git('show', ':ai-delivery.policy.mjs'), tracked.trim());
246
- assert.equal(readFileSync(policy, 'utf8'), selected);
247
- };
248
- const cleanup = () => {
249
- const current = lstatSync(base);
250
- assert.equal(realpathSync(base), base);
251
- assert.equal(current.isSymbolicLink(), false);
252
- assert.equal(current.dev, identity.dev);
253
- assert.equal(current.ino, identity.ino);
254
- rmSync(base, { recursive: true });
255
- assert.equal(existsSync(base), false);
256
- };
257
- return {
258
- base,
259
- root,
260
- home,
261
- head,
262
- env,
263
- sentinel,
264
- policy,
265
- tracked,
266
- selected,
267
- assertInert,
268
- assertBound,
269
- cleanup,
270
- payloadSha256: digestBytes(Buffer.from(selected)),
271
- indexedSha256: digestBytes(Buffer.from(tracked)),
272
- };
273
- }
274
- catch (error) {
275
- const current = lstatSync(base);
276
- assert.equal(current.dev, identity.dev);
277
- assert.equal(current.ino, identity.ino);
278
- assert.equal(current.isSymbolicLink(), false);
279
- rmSync(base, { recursive: true });
280
- throw error;
281
- }
315
+ } catch (error) {
316
+ const current = lstatSync(base);
317
+ assert.equal(current.dev, identity.dev);
318
+ assert.equal(current.ino, identity.ino);
319
+ assert.equal(current.isSymbolicLink(), false);
320
+ rmSync(base, { recursive: true });
321
+ throw error;
322
+ }
282
323
  }
283
- //# sourceMappingURL=inertEntrypoints.js.map
324
+ export {
325
+ entrypointClients,
326
+ freshEntrypointFixture
327
+ };
328
+ //# sourceMappingURL=inertEntrypoints.js.map