@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,277 +1,300 @@
1
- import assert from 'node:assert/strict';
2
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { afterEach, beforeEach, describe, it, vi } from 'vitest';
6
- import { loadDeliveryConfig, loadDeliverySettings, resolveDeliveryRoleCredentials, } from './config/deliveryConfig.js';
7
- import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from './fixtures/discovery.js';
8
- import { createDeliveryGitHubClients, withAuthorGitToken } from './github/client.js';
9
- // These are fictional settings/environment contracts. They do not launch a native
10
- // host, contact GitHub, or establish authenticated/native installation readiness.
1
+ import assert from "node:assert/strict";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { afterEach, beforeEach, describe, it, vi } from "vitest";
6
+ import {
7
+ loadDeliveryConfig,
8
+ loadDeliverySettings,
9
+ resolveDeliveryRoleCredentials
10
+ } from "./config/deliveryConfig.js";
11
+ import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from "./fixtures/discovery.js";
12
+ import { createDeliveryGitHubClients, withAuthorGitToken } from "./github/client.js";
11
13
  function settings(root) {
12
- return {
13
- schemaVersion: 'ai-delivery.user@1',
14
- roles: {
15
- author: {
16
- authSource: 'personal',
17
- identity: 'fixture-author',
18
- credentialEnv: { token: 'DELIVERY_AUTHOR_TOKEN' },
19
- },
20
- reviewer: {
21
- identity: 'fixture-reviewer',
22
- credentialEnv: {
23
- appId: 'DELIVERY_REVIEWER_APP_ID',
24
- installationId: 'DELIVERY_REVIEWER_INSTALLATION_ID',
25
- privateKeyPath: 'DELIVERY_REVIEWER_KEY_PATH',
26
- },
27
- },
28
- },
29
- project: syntheticDiscoveryConfig.native.project.number,
30
- checkoutRoots: [join(root, 'clones')],
31
- pointsField: syntheticDiscoveryConfig.native.points.name,
32
- priorityField: syntheticDiscoveryConfig.native.priority.name,
33
- statusField: syntheticDiscoveryConfig.native.project.statusField,
34
- statuses: syntheticDiscoveryConfig.native.project.statuses,
35
- issueTypes: syntheticDiscoveryConfig.native.issueTypes,
36
- };
14
+ return {
15
+ schemaVersion: "ai-delivery.user@1",
16
+ roles: {
17
+ author: {
18
+ authSource: "personal",
19
+ identity: "fixture-author",
20
+ credentialEnv: { token: "DELIVERY_AUTHOR_TOKEN" }
21
+ },
22
+ reviewer: {
23
+ identity: "fixture-reviewer",
24
+ credentialEnv: {
25
+ appId: "DELIVERY_REVIEWER_APP_ID",
26
+ installationId: "DELIVERY_REVIEWER_INSTALLATION_ID",
27
+ privateKeyPath: "DELIVERY_REVIEWER_KEY_PATH"
28
+ }
29
+ }
30
+ },
31
+ project: syntheticDiscoveryConfig.native.project.number,
32
+ checkoutRoots: [join(root, "clones")],
33
+ pointsField: syntheticDiscoveryConfig.native.points.name,
34
+ priorityField: syntheticDiscoveryConfig.native.priority.name,
35
+ statusField: syntheticDiscoveryConfig.native.project.statusField,
36
+ statuses: syntheticDiscoveryConfig.native.project.statuses,
37
+ issueTypes: syntheticDiscoveryConfig.native.issueTypes
38
+ };
37
39
  }
38
- let home = '';
39
- let configPath = '';
40
+ let home = "";
41
+ let configPath = "";
40
42
  beforeEach(() => {
41
- home = mkdtempSync(join(tmpdir(), 'ai-delivery-credential-contract-'));
42
- configPath = join(home, 'operator-settings.json');
43
- vi.stubEnv('AI_DELIVERY_CONFIG', configPath);
44
- // Fail closed if any fixture accidentally reaches a real HTTP client. The
45
- // explicit readback cases replace this with their own in-memory responses.
46
- vi.stubGlobal('fetch', async () => {
47
- throw new Error('Unexpected network request in a synthetic credential fixture.');
48
- });
49
- writeFileSync(configPath, JSON.stringify(settings(home)));
43
+ home = mkdtempSync(join(tmpdir(), "ai-delivery-credential-contract-"));
44
+ configPath = join(home, "operator-settings.json");
45
+ vi.stubEnv("AI_DELIVERY_CONFIG", configPath);
46
+ vi.stubGlobal("fetch", async () => {
47
+ throw new Error("Unexpected network request in a synthetic credential fixture.");
48
+ });
49
+ writeFileSync(configPath, JSON.stringify(settings(home)));
50
50
  });
51
51
  afterEach(() => {
52
- vi.unstubAllEnvs();
53
- vi.unstubAllGlobals();
54
- rmSync(home, { recursive: true, force: true });
52
+ vi.unstubAllEnvs();
53
+ vi.unstubAllGlobals();
54
+ rmSync(home, { recursive: true, force: true });
55
55
  });
56
- describe('synthetic native-plugin credential contract', () => {
57
- it('an absent conventional reference selects machine-session resolution without accepting ambient legacy credentials', async () => {
58
- const fixture = settings(home);
59
- fixture.roles.author = { authSource: 'personal', identity: 'fixture-author', credentialEnv: { token: 'GH_TOKEN' } };
60
- writeFileSync(configPath, JSON.stringify(fixture));
61
- const loaded = await loadDeliverySettings();
62
- await assert.rejects(createDeliveryGitHubClients({
63
- config: loaded,
64
- identity: 'fixture-author',
65
- role: 'author',
66
- env: { HOME: home, PATH: join(home, 'missing-cli'), GITHUB_TOKEN: 'fictional_legacy_token' },
67
- }), /gh is unavailable on this process PATH/u);
68
- });
69
- it.each(['codex', 'claude-code'])('%s fixture uses one operator configuration outside Git and across repositories', async (host) => {
70
- const outsideGit = join(home, host, 'outside-git');
71
- mkdirSync(outsideGit, { recursive: true });
72
- // A launch-directory file must not replace the selected operator settings.
73
- writeFileSync(join(outsideGit, 'ai-delivery.config.json'), '{"roles":"untrusted fixture"}');
74
- const loaded = await loadDeliverySettings(outsideGit);
75
- assert.equal(loaded.configPath, configPath);
76
- assert.equal(loaded.roles.author.identity, 'fixture-author');
77
- assert.equal(loaded.roles.reviewer.identity, 'fixture-reviewer');
78
- for (const repository of ['example/widget', 'example/service', 'example/widget']) {
79
- const fixture = { ...syntheticDiscoveryConfig, repository };
80
- const resolved = await loadDeliveryConfig(outsideGit, {
81
- repository,
82
- clients: syntheticDiscoveryClients(fixture),
83
- });
84
- assert.equal(resolved.config.repository, repository);
85
- assert.deepEqual(resolved.config.roles, loaded.roles);
86
- assert.equal(resolved.configPath, configPath);
87
- }
88
- });
89
- it('valid settings alone do not establish that the named credentials are available', async () => {
90
- const loaded = await loadDeliverySettings();
91
- await assert.rejects(createDeliveryGitHubClients({
92
- config: loaded,
93
- identity: loaded.roles.author.identity,
94
- role: 'author',
95
- env: {},
96
- }), /Missing personal author token in DELIVERY_AUTHOR_TOKEN/u);
97
- });
98
- it('ignores unrelated tokens and reports the selected missing name without their values', async () => {
99
- const loaded = await loadDeliverySettings();
100
- const sentinel = 'fictional-unrelated-value-not-a-credential';
101
- await assert.rejects(createDeliveryGitHubClients({
102
- config: loaded,
103
- identity: loaded.roles.author.identity,
104
- role: 'author',
105
- env: { GH_TOKEN: sentinel, GITHUB_TOKEN: sentinel, UNRELATED_SERVICE_TOKEN: sentinel },
106
- }), (error) => {
107
- assert.ok(error instanceof Error);
108
- assert.match(error.message, /DELIVERY_AUTHOR_TOKEN/u);
109
- assert.ok(!error.message.includes(sentinel));
110
- assert.ok(!error.message.includes('UNRELATED_SERVICE_TOKEN'));
111
- return true;
56
+ describe("synthetic native-plugin credential contract", () => {
57
+ it("an absent conventional reference selects machine-session resolution without accepting ambient legacy credentials", async () => {
58
+ const fixture = settings(home);
59
+ fixture.roles.author = { authSource: "personal", identity: "fixture-author", credentialEnv: { token: "GH_TOKEN" } };
60
+ writeFileSync(configPath, JSON.stringify(fixture));
61
+ const loaded = await loadDeliverySettings();
62
+ await assert.rejects(
63
+ createDeliveryGitHubClients({
64
+ config: loaded,
65
+ identity: "fixture-author",
66
+ role: "author",
67
+ env: { HOME: home, PATH: join(home, "missing-cli"), GITHUB_TOKEN: "fictional_legacy_token" }
68
+ }),
69
+ /gh is unavailable on this process PATH/u
70
+ );
71
+ });
72
+ it.each(["codex", "claude-code"])(
73
+ "%s fixture uses one operator configuration outside Git and across repositories",
74
+ async (host) => {
75
+ const outsideGit = join(home, host, "outside-git");
76
+ mkdirSync(outsideGit, { recursive: true });
77
+ writeFileSync(join(outsideGit, "ai-delivery.config.json"), '{"roles":"untrusted fixture"}');
78
+ const loaded = await loadDeliverySettings(outsideGit);
79
+ assert.equal(loaded.configPath, configPath);
80
+ assert.equal(loaded.roles.author.identity, "fixture-author");
81
+ assert.equal(loaded.roles.reviewer.identity, "fixture-reviewer");
82
+ for (const repository of ["example/widget", "example/service", "example/widget"]) {
83
+ const fixture = { ...syntheticDiscoveryConfig, repository };
84
+ const resolved = await loadDeliveryConfig(outsideGit, {
85
+ repository,
86
+ clients: syntheticDiscoveryClients(fixture)
112
87
  });
88
+ assert.equal(resolved.config.repository, repository);
89
+ assert.deepEqual(resolved.config.roles, loaded.roles);
90
+ assert.equal(resolved.configPath, configPath);
91
+ }
92
+ }
93
+ );
94
+ it("valid settings alone do not establish that the named credentials are available", async () => {
95
+ const loaded = await loadDeliverySettings();
96
+ await assert.rejects(
97
+ createDeliveryGitHubClients({
98
+ config: loaded,
99
+ identity: loaded.roles.author.identity,
100
+ role: "author",
101
+ env: {}
102
+ }),
103
+ /Missing personal author token in DELIVERY_AUTHOR_TOKEN/u
104
+ );
105
+ });
106
+ it("ignores unrelated tokens and reports the selected missing name without their values", async () => {
107
+ const loaded = await loadDeliverySettings();
108
+ const sentinel = "fictional-unrelated-value-not-a-credential";
109
+ await assert.rejects(
110
+ createDeliveryGitHubClients({
111
+ config: loaded,
112
+ identity: loaded.roles.author.identity,
113
+ role: "author",
114
+ env: { GH_TOKEN: sentinel, GITHUB_TOKEN: sentinel, UNRELATED_SERVICE_TOKEN: sentinel }
115
+ }),
116
+ (error) => {
117
+ assert.ok(error instanceof Error);
118
+ assert.match(error.message, /DELIVERY_AUTHOR_TOKEN/u);
119
+ assert.ok(!error.message.includes(sentinel));
120
+ assert.ok(!error.message.includes("UNRELATED_SERVICE_TOKEN"));
121
+ return true;
122
+ }
123
+ );
124
+ });
125
+ it("selects a supplied fictional author token without treating selection as authenticated readback", async () => {
126
+ const loaded = await loadDeliverySettings();
127
+ const token = "fictional-selected-author-value";
128
+ const author = await createDeliveryGitHubClients({
129
+ config: loaded,
130
+ identity: loaded.roles.author.identity,
131
+ role: "author",
132
+ env: { DELIVERY_AUTHOR_TOKEN: token, GH_TOKEN: "fictional-unselected-value" }
113
133
  });
114
- it('selects a supplied fictional author token without treating selection as authenticated readback', async () => {
115
- const loaded = await loadDeliverySettings();
116
- const token = 'fictional-selected-author-value';
117
- const author = await createDeliveryGitHubClients({
118
- config: loaded,
119
- identity: loaded.roles.author.identity,
120
- role: 'author',
121
- env: { DELIVERY_AUTHOR_TOKEN: token, GH_TOKEN: 'fictional-unselected-value' },
122
- });
123
- assert.equal(author.role, 'author');
124
- assert.equal(author.authSource, 'personal');
125
- assert.equal(author.credentialSource, 'env:DELIVERY_AUTHOR_TOKEN');
126
- assert.equal(await withAuthorGitToken(author, (selected) => selected === token), true);
127
- // No authenticatedAuthor/appActorLogin callback is invoked in this fixture.
128
- assert.equal(loaded.roles.reviewer.identity, 'fixture-reviewer');
134
+ assert.equal(author.role, "author");
135
+ assert.equal(author.authSource, "personal");
136
+ assert.equal(author.credentialSource, "env:DELIVERY_AUTHOR_TOKEN");
137
+ assert.equal(await withAuthorGitToken(author, (selected) => selected === token), true);
138
+ assert.equal(loaded.roles.reviewer.identity, "fixture-reviewer");
139
+ });
140
+ it("requires a separate identity readback and uses only a GET in the simulated author probe", async () => {
141
+ const requests = [];
142
+ vi.stubGlobal("fetch", async (input, init) => {
143
+ const url = input instanceof Request ? input.url : String(input);
144
+ assert.equal(url, "https://api.github.com/user");
145
+ assert.equal(init?.method ?? "GET", "GET");
146
+ requests.push(url);
147
+ return new Response(JSON.stringify({ id: 42, login: "fixture-authenticated-author" }), {
148
+ status: 200,
149
+ headers: { "content-type": "application/json" }
150
+ });
129
151
  });
130
- it('requires a separate identity readback and uses only a GET in the simulated author probe', async () => {
131
- const requests = [];
132
- vi.stubGlobal('fetch', async (input, init) => {
133
- const url = input instanceof Request ? input.url : String(input);
134
- assert.equal(url, 'https://api.github.com/user');
135
- assert.equal(init?.method ?? 'GET', 'GET');
136
- requests.push(url);
137
- return new Response(JSON.stringify({ id: 42, login: 'fixture-authenticated-author' }), {
138
- status: 200,
139
- headers: { 'content-type': 'application/json' },
140
- });
141
- });
142
- const loaded = await loadDeliverySettings();
143
- const author = await createDeliveryGitHubClients({
144
- config: loaded,
145
- identity: loaded.roles.author.identity,
146
- role: 'author',
147
- env: { DELIVERY_AUTHOR_TOKEN: 'fictional-author-value' },
148
- });
149
- assert.deepEqual(requests, []);
150
- assert.ok(author.authenticatedAuthor);
151
- assert.deepEqual(await author.authenticatedAuthor(), {
152
- actorLogin: 'fixture-authenticated-author',
153
- credentialIdentity: 'user:42',
154
- });
155
- assert.deepEqual(requests, ['https://api.github.com/user']);
152
+ const loaded = await loadDeliverySettings();
153
+ const author = await createDeliveryGitHubClients({
154
+ config: loaded,
155
+ identity: loaded.roles.author.identity,
156
+ role: "author",
157
+ env: { DELIVERY_AUTHOR_TOKEN: "fictional-author-value" }
156
158
  });
157
- it('redacts a simulated authentication failure even when the upstream body contains fictional credential values', async () => {
158
- const sentinel = 'fictional-value-in-upstream-error';
159
- vi.stubGlobal('fetch', async (input, init) => {
160
- const url = input instanceof Request ? input.url : String(input);
161
- assert.equal(url, 'https://api.github.com/user');
162
- assert.equal(init?.method ?? 'GET', 'GET');
163
- return new Response(JSON.stringify({ message: sentinel }), {
164
- status: 401,
165
- headers: { 'content-type': 'application/json', 'x-fictional-credential': sentinel },
166
- });
167
- });
168
- const loaded = await loadDeliverySettings();
169
- const author = await createDeliveryGitHubClients({
170
- config: loaded,
171
- identity: loaded.roles.author.identity,
172
- role: 'author',
173
- env: { DELIVERY_AUTHOR_TOKEN: sentinel },
174
- });
175
- assert.ok(author.authenticatedAuthor);
176
- await assert.rejects(author.authenticatedAuthor(), (error) => {
177
- assert.ok(error instanceof Error);
178
- assert.match(error.message, /Configured personal author token is invalid or expired/u);
179
- assert.ok(!error.message.includes(sentinel));
180
- return true;
181
- });
159
+ assert.deepEqual(requests, []);
160
+ assert.ok(author.authenticatedAuthor);
161
+ assert.deepEqual(await author.authenticatedAuthor(), {
162
+ actorLogin: "fixture-authenticated-author",
163
+ credentialIdentity: "user:42"
182
164
  });
183
- it('cannot use the configured author identity for the reviewer role', async () => {
184
- const loaded = await loadDeliverySettings();
185
- await assert.rejects(createDeliveryGitHubClients({
186
- config: loaded,
187
- identity: loaded.roles.author.identity,
188
- role: 'reviewer',
189
- env: { DELIVERY_AUTHOR_TOKEN: 'fictional-author-value' },
190
- }), /requires the configured reviewer identity/u);
165
+ assert.deepEqual(requests, ["https://api.github.com/user"]);
166
+ });
167
+ it("redacts a simulated authentication failure even when the upstream body contains fictional credential values", async () => {
168
+ const sentinel = "fictional-value-in-upstream-error";
169
+ vi.stubGlobal("fetch", async (input, init) => {
170
+ const url = input instanceof Request ? input.url : String(input);
171
+ assert.equal(url, "https://api.github.com/user");
172
+ assert.equal(init?.method ?? "GET", "GET");
173
+ return new Response(JSON.stringify({ message: sentinel }), {
174
+ status: 401,
175
+ headers: { "content-type": "application/json", "x-fictional-credential": sentinel }
176
+ });
191
177
  });
192
- it('rejects App credential reuse before reading a key or requesting authentication', async () => {
193
- const fixture = settings(home);
194
- const roles = {
195
- ...fixture.roles,
196
- author: {
197
- authSource: 'app',
198
- identity: 'fixture-app-author',
199
- credentialEnv: {
200
- appId: 'DELIVERY_AUTHOR_APP_ID',
201
- installationId: 'DELIVERY_AUTHOR_INSTALLATION_ID',
202
- privateKeyPath: 'DELIVERY_AUTHOR_KEY_PATH',
203
- },
204
- },
205
- };
206
- const fictionalPath = join(home, 'fictional-shared-key.pem');
207
- await assert.rejects(createDeliveryGitHubClients({
208
- config: { roles },
209
- identity: roles.author.identity,
210
- role: 'author',
211
- env: {
212
- DELIVERY_AUTHOR_APP_ID: '101',
213
- DELIVERY_AUTHOR_INSTALLATION_ID: '201',
214
- DELIVERY_AUTHOR_KEY_PATH: fictionalPath,
215
- DELIVERY_REVIEWER_APP_ID: '102',
216
- DELIVERY_REVIEWER_INSTALLATION_ID: '202',
217
- DELIVERY_REVIEWER_KEY_PATH: fictionalPath,
218
- },
219
- }), /Author and reviewer must use distinct GitHub App credentials/u);
178
+ const loaded = await loadDeliverySettings();
179
+ const author = await createDeliveryGitHubClients({
180
+ config: loaded,
181
+ identity: loaded.roles.author.identity,
182
+ role: "author",
183
+ env: { DELIVERY_AUTHOR_TOKEN: sentinel }
220
184
  });
221
- it('reports missing reviewer references without leaking a supplied key path or unrelated values', async () => {
222
- const loaded = await loadDeliverySettings();
223
- const fictionalPath = join(home, 'fictional-private-key.pem');
224
- assert.throws(() => resolveDeliveryRoleCredentials({
225
- config: loaded,
226
- role: 'reviewer',
227
- env: { DELIVERY_REVIEWER_KEY_PATH: fictionalPath, UNRELATED_SERVICE_TOKEN: 'fictional-unrelated-value' },
228
- }), (error) => {
229
- assert.ok(error instanceof Error);
230
- assert.match(error.message, /DELIVERY_REVIEWER_APP_ID/u);
231
- assert.match(error.message, /DELIVERY_REVIEWER_INSTALLATION_ID/u);
232
- assert.ok(!error.message.includes(fictionalPath));
233
- assert.ok(!error.message.includes('fictional-unrelated-value'));
234
- return true;
235
- });
185
+ assert.ok(author.authenticatedAuthor);
186
+ await assert.rejects(author.authenticatedAuthor(), (error) => {
187
+ assert.ok(error instanceof Error);
188
+ assert.match(error.message, /Configured personal author token is invalid or expired/u);
189
+ assert.ok(!error.message.includes(sentinel));
190
+ return true;
236
191
  });
237
- it('rejects author/reviewer identity and reference collisions during settings validation', async () => {
238
- const fixture = settings(home);
239
- for (const reviewer of [
240
- { ...fixture.roles.reviewer, identity: fixture.roles.author.identity },
241
- {
242
- ...fixture.roles.reviewer,
243
- credentialEnv: { ...fixture.roles.reviewer.credentialEnv, appId: 'DELIVERY_AUTHOR_TOKEN' },
244
- },
245
- ]) {
246
- writeFileSync(configPath, JSON.stringify({ ...fixture, roles: { ...fixture.roles, reviewer } }));
247
- await assert.rejects(loadDeliverySettings(), /distinct/u);
192
+ });
193
+ it("cannot use the configured author identity for the reviewer role", async () => {
194
+ const loaded = await loadDeliverySettings();
195
+ await assert.rejects(
196
+ createDeliveryGitHubClients({
197
+ config: loaded,
198
+ identity: loaded.roles.author.identity,
199
+ role: "reviewer",
200
+ env: { DELIVERY_AUTHOR_TOKEN: "fictional-author-value" }
201
+ }),
202
+ /requires the configured reviewer identity/u
203
+ );
204
+ });
205
+ it("rejects App credential reuse before reading a key or requesting authentication", async () => {
206
+ const fixture = settings(home);
207
+ const roles = {
208
+ ...fixture.roles,
209
+ author: {
210
+ authSource: "app",
211
+ identity: "fixture-app-author",
212
+ credentialEnv: {
213
+ appId: "DELIVERY_AUTHOR_APP_ID",
214
+ installationId: "DELIVERY_AUTHOR_INSTALLATION_ID",
215
+ privateKeyPath: "DELIVERY_AUTHOR_KEY_PATH"
248
216
  }
217
+ }
218
+ };
219
+ const fictionalPath = join(home, "fictional-shared-key.pem");
220
+ await assert.rejects(
221
+ createDeliveryGitHubClients({
222
+ config: { roles },
223
+ identity: roles.author.identity,
224
+ role: "author",
225
+ env: {
226
+ DELIVERY_AUTHOR_APP_ID: "101",
227
+ DELIVERY_AUTHOR_INSTALLATION_ID: "201",
228
+ DELIVERY_AUTHOR_KEY_PATH: fictionalPath,
229
+ DELIVERY_REVIEWER_APP_ID: "102",
230
+ DELIVERY_REVIEWER_INSTALLATION_ID: "202",
231
+ DELIVERY_REVIEWER_KEY_PATH: fictionalPath
232
+ }
233
+ }),
234
+ /Author and reviewer must use distinct GitHub App credentials/u
235
+ );
236
+ });
237
+ it("reports missing reviewer references without leaking a supplied key path or unrelated values", async () => {
238
+ const loaded = await loadDeliverySettings();
239
+ const fictionalPath = join(home, "fictional-private-key.pem");
240
+ assert.throws(
241
+ () => resolveDeliveryRoleCredentials({
242
+ config: loaded,
243
+ role: "reviewer",
244
+ env: { DELIVERY_REVIEWER_KEY_PATH: fictionalPath, UNRELATED_SERVICE_TOKEN: "fictional-unrelated-value" }
245
+ }),
246
+ (error) => {
247
+ assert.ok(error instanceof Error);
248
+ assert.match(error.message, /DELIVERY_REVIEWER_APP_ID/u);
249
+ assert.match(error.message, /DELIVERY_REVIEWER_INSTALLATION_ID/u);
250
+ assert.ok(!error.message.includes(fictionalPath));
251
+ assert.ok(!error.message.includes("fictional-unrelated-value"));
252
+ return true;
253
+ }
254
+ );
255
+ });
256
+ it("rejects author/reviewer identity and reference collisions during settings validation", async () => {
257
+ const fixture = settings(home);
258
+ assert.ok("credentialEnv" in fixture.roles.reviewer);
259
+ for (const reviewer of [
260
+ { ...fixture.roles.reviewer, identity: fixture.roles.author.identity },
261
+ {
262
+ ...fixture.roles.reviewer,
263
+ credentialEnv: { ...fixture.roles.reviewer.credentialEnv, appId: "DELIVERY_AUTHOR_TOKEN" }
264
+ }
265
+ ]) {
266
+ writeFileSync(configPath, JSON.stringify({ ...fixture, roles: { ...fixture.roles, reviewer } }));
267
+ await assert.rejects(loadDeliverySettings(), /distinct/u);
268
+ }
269
+ });
270
+ it("rejects malformed JSON without echoing its fictional contents", async () => {
271
+ const sentinel = "fictional-value-inside-malformed-json";
272
+ writeFileSync(configPath, `{"unexpected":"${sentinel}"`);
273
+ await assert.rejects(loadDeliverySettings(), (error) => {
274
+ assert.ok(error instanceof Error);
275
+ assert.match(error.message, /Invalid user configuration JSON/u);
276
+ assert.ok(!error.message.includes(sentinel));
277
+ return true;
249
278
  });
250
- it('rejects malformed JSON without echoing its fictional contents', async () => {
251
- const sentinel = 'fictional-value-inside-malformed-json';
252
- writeFileSync(configPath, `{"unexpected":"${sentinel}"`);
253
- await assert.rejects(loadDeliverySettings(), (error) => {
254
- assert.ok(error instanceof Error);
255
- assert.match(error.message, /Invalid user configuration JSON/u);
256
- assert.ok(!error.message.includes(sentinel));
257
- return true;
258
- });
259
- });
260
- it('rejects non-reference credential fields and relative checkout roots without echoing values', async () => {
261
- const fixture = settings(home);
262
- const sentinel = 'fictional_value_not_an_env_name';
263
- writeFileSync(configPath, JSON.stringify({
264
- ...fixture,
265
- roles: { ...fixture.roles, author: { ...fixture.roles.author, credentialEnv: { token: sentinel } } },
266
- }));
267
- await assert.rejects(loadDeliverySettings(), (error) => {
268
- assert.ok(error instanceof Error);
269
- assert.match(error.message, /roles.author.credentialEnv.token/u);
270
- assert.ok(!error.message.includes(sentinel));
271
- return true;
272
- });
273
- writeFileSync(configPath, JSON.stringify({ ...fixture, checkoutRoots: ['relative-clones'] }));
274
- await assert.rejects(loadDeliverySettings(), /Checkout roots must be absolute/u);
279
+ });
280
+ it("rejects non-reference credential fields and relative checkout roots without echoing values", async () => {
281
+ const fixture = settings(home);
282
+ const sentinel = "fictional_value_not_an_env_name";
283
+ writeFileSync(
284
+ configPath,
285
+ JSON.stringify({
286
+ ...fixture,
287
+ roles: { ...fixture.roles, author: { ...fixture.roles.author, credentialEnv: { token: sentinel } } }
288
+ })
289
+ );
290
+ await assert.rejects(loadDeliverySettings(), (error) => {
291
+ assert.ok(error instanceof Error);
292
+ assert.match(error.message, /roles.author.credentialEnv.token/u);
293
+ assert.ok(!error.message.includes(sentinel));
294
+ return true;
275
295
  });
296
+ writeFileSync(configPath, JSON.stringify({ ...fixture, checkoutRoots: ["relative-clones"] }));
297
+ await assert.rejects(loadDeliverySettings(), /Checkout roots must be absolute/u);
298
+ });
276
299
  });
277
- //# sourceMappingURL=pluginCredentials.test.js.map
300
+ //# sourceMappingURL=pluginCredentials.test.js.map