@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,395 +1,450 @@
1
- import assert from 'node:assert/strict';
2
- import { spawnSync } from 'node:child_process';
3
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { test } from 'vitest';
7
- import { pathToFileURL } from 'node:url';
8
- import { DeliveryError, getMachineRequestDiagnostics, setMachineRequestDiagnostics } from './errors.js';
9
- test('actual CLI serializes incomplete native update evidence and exits nonzero', () => {
10
- const cli = pathToFileURL(join(process.cwd(), 'dist', 'cli.js')).href;
11
- const dispatch = pathToFileURL(join(process.cwd(), 'dist', 'dispatch.js')).href;
12
- const owner = pathToFileURL(join(process.cwd(), 'dist', 'issue.js')).href;
13
- const partial = {
14
- status: 'update-incomplete',
15
- native: { status: 'unknown', repository: 'example/widget', issueNumber: 17, readback: null },
16
- project: { status: 'pending', desiredStatus: 'Done' },
17
- recovery: { tool: 'issue_batch_update' },
18
- };
19
- const result = spawnSync(process.execPath, [
20
- '--experimental-test-module-mocks',
21
- '--no-warnings',
22
- '--input-type=module',
23
- '-e',
24
- `import assert from 'node:assert/strict'; import { mock } from 'node:test'; import { IssueUpdateIncompleteError } from ${JSON.stringify(owner)};
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { test } from "vitest";
7
+ import { pathToFileURL } from "node:url";
8
+ import { DeliveryError, getMachineRequestDiagnostics, setMachineRequestDiagnostics } from "./errors.js";
9
+ test("actual CLI serializes incomplete native update evidence and exits nonzero", { tags: ["release"] }, () => {
10
+ const cli = pathToFileURL(join(process.cwd(), "dist", "cli.js")).href;
11
+ const dispatch = pathToFileURL(join(process.cwd(), "dist", "dispatch.js")).href;
12
+ const owner = pathToFileURL(join(process.cwd(), "dist", "issue.js")).href;
13
+ const partial = {
14
+ status: "update-incomplete",
15
+ native: { status: "unknown", repository: "example/widget", issueNumber: 17, readback: null },
16
+ project: { status: "pending", desiredStatus: "Done" },
17
+ recovery: { tool: "issue_batch_update" }
18
+ };
19
+ const result = spawnSync(
20
+ process.execPath,
21
+ [
22
+ "--experimental-test-module-mocks",
23
+ "--no-warnings",
24
+ "--input-type=module",
25
+ "-e",
26
+ `import assert from 'node:assert/strict'; import { mock } from 'node:test'; import { IssueUpdateIncompleteError } from ${JSON.stringify(owner)};
25
27
  mock.module(${JSON.stringify(dispatch)}, { exports: {
26
28
  contextFor: () => { throw new Error('Unexpected configuration access'); },
27
29
  executeTool: async (name, input) => { assert.equal(name, 'issue_update'); assert.equal(input.issueNumber, 17); throw new IssueUpdateIncompleteError(${JSON.stringify(partial)}); }
28
30
  }});
29
31
  process.argv = [process.execPath, ${JSON.stringify(cli)}, '--repo', 'example/widget', 'update', '--issue', '17', '--state', 'closed', '--close-reason', 'completed'];
30
- await import(${JSON.stringify(cli)});`,
31
- ], { encoding: 'utf8' });
32
- assert.equal(result.status, 1);
33
- assert.deepEqual(JSON.parse(result.stdout), partial);
34
- assert.equal(result.stderr, '');
32
+ await import(${JSON.stringify(cli)});`
33
+ ],
34
+ { encoding: "utf8" }
35
+ );
36
+ assert.equal(result.status, 1);
37
+ assert.deepEqual(JSON.parse(result.stdout), partial);
38
+ assert.equal(result.stderr, "");
35
39
  });
36
40
  test.each([
37
- [{ schemaVersion: 'ai-delivery.board-reconcile-plan@1', scopeComplete: true, summary: { unresolved: 4 } }, 0],
38
- [{ schemaVersion: 'ai-delivery.board-reconcile-plan@1', scopeComplete: false }, 1],
39
- ...['failed', 'drifted', 'refused', 'unknown', 'unresolved'].map((key) => [
40
- { schemaVersion: 'ai-delivery.board-reconcile-result@1', scopeComplete: true, summary: { applied: 1, [key]: 1 } },
41
- 1,
42
- ]),
43
- [
44
- {
45
- schemaVersion: 'ai-delivery.board-reconcile-result@1',
46
- scopeComplete: true,
47
- summary: { applied: 2, satisfied: 1, failed: 0, drifted: 0, refused: 0, unknown: 0, unresolved: 0 },
48
- },
49
- 0,
50
- ],
51
- ])('CLI prints the complete reconciliation result before selecting its exit status (%j)', (value, exit) => {
52
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
53
- const result = spawnSync(process.execPath, [
54
- '--input-type=module',
55
- '-e',
56
- `import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('board_reconcile', ${JSON.stringify(value)});`,
57
- ], { encoding: 'utf8' });
41
+ [{ schemaVersion: "ai-delivery.board-reconcile-plan@1", scopeComplete: true, summary: { unresolved: 4 } }, 0],
42
+ [{ schemaVersion: "ai-delivery.board-reconcile-plan@1", scopeComplete: false }, 1],
43
+ ...["failed", "drifted", "refused", "unknown", "unresolved"].map((key) => [
44
+ { schemaVersion: "ai-delivery.board-reconcile-result@1", scopeComplete: true, summary: { applied: 1, [key]: 1 } },
45
+ 1
46
+ ]),
47
+ [
48
+ {
49
+ schemaVersion: "ai-delivery.board-reconcile-result@1",
50
+ scopeComplete: true,
51
+ summary: { applied: 2, satisfied: 1, failed: 0, drifted: 0, refused: 0, unknown: 0, unresolved: 0 }
52
+ },
53
+ 0
54
+ ]
55
+ ])(
56
+ "CLI prints the complete reconciliation result before selecting its exit status (%j)",
57
+ { tags: ["release"] },
58
+ (value, exit) => {
59
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
60
+ const result = spawnSync(
61
+ process.execPath,
62
+ [
63
+ "--input-type=module",
64
+ "-e",
65
+ `import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('board_reconcile', ${JSON.stringify(value)});`
66
+ ],
67
+ { encoding: "utf8" }
68
+ );
58
69
  assert.equal(result.status, exit);
59
70
  assert.deepEqual(JSON.parse(result.stdout), value);
60
- assert.equal(result.stderr, '');
61
- });
62
- test('actual board CLI advertises bounded data-only files and validates them before credentials', () => {
63
- const root = mkdtempSync(join(tmpdir(), 'board-cli-input-'));
64
- const cli = join(process.cwd(), 'dist', 'cli.js');
71
+ assert.equal(result.stderr, "");
72
+ }
73
+ );
74
+ test(
75
+ "actual board CLI advertises bounded data-only files and validates them before credentials",
76
+ { tags: ["release"] },
77
+ () => {
78
+ const root = mkdtempSync(join(tmpdir(), "board-cli-input-"));
79
+ const cli = join(process.cwd(), "dist", "cli.js");
65
80
  try {
66
- const help = spawnSync(process.execPath, [cli, 'board:reconcile', '--help'], { cwd: root, encoding: 'utf8' });
67
- assert.equal(help.status, 0);
68
- for (const option of [
69
- '--repositories',
70
- '--checkouts-file',
71
- '--dry-run',
72
- '--apply',
73
- '--plan-file',
74
- '--prior-result-file',
75
- ])
76
- assert.ok(help.stdout.includes(option));
77
- const huge = join(root, 'huge.json');
78
- writeFileSync(huge, ' '.repeat(16 * 1024 * 1024 + 1));
79
- const invalid = spawnSync(process.execPath, [cli, 'board:reconcile', '--repositories', 'example/widget', '--apply', '--plan-file', huge], { cwd: root, env: { ...process.env, AI_DELIVERY_CONFIG: join(root, 'missing-settings') }, encoding: 'utf8' });
80
- assert.equal(invalid.status, 1);
81
- assert.match(invalid.stderr, /16 MiB/u);
82
- assert.doesNotMatch(invalid.stderr, /missing-settings|credential/u);
83
- const exclusive = spawnSync(process.execPath, [cli, 'board:reconcile', '--repositories', 'example/widget', '--dry-run', '--apply'], { cwd: root, encoding: 'utf8' });
84
- assert.equal(exclusive.status, 1);
85
- assert.match(exclusive.stderr, /dry-run.*apply|apply.*dry-run/u);
86
- }
87
- finally {
88
- rmSync(root, { recursive: true, force: true });
81
+ const help = spawnSync(process.execPath, [cli, "board:reconcile", "--help"], { cwd: root, encoding: "utf8" });
82
+ assert.equal(help.status, 0);
83
+ for (const option of [
84
+ "--repositories",
85
+ "--checkouts-file",
86
+ "--dry-run",
87
+ "--apply",
88
+ "--plan-file",
89
+ "--prior-result-file"
90
+ ])
91
+ assert.ok(help.stdout.includes(option));
92
+ const huge = join(root, "huge.json");
93
+ writeFileSync(huge, " ".repeat(16 * 1024 * 1024 + 1));
94
+ const invalid = spawnSync(
95
+ process.execPath,
96
+ [cli, "board:reconcile", "--repositories", "example/widget", "--apply", "--plan-file", huge],
97
+ { cwd: root, env: { ...process.env, AI_DELIVERY_CONFIG: join(root, "missing-settings") }, encoding: "utf8" }
98
+ );
99
+ assert.equal(invalid.status, 1);
100
+ assert.match(invalid.stderr, /16 MiB/u);
101
+ assert.doesNotMatch(invalid.stderr, /missing-settings|credential/u);
102
+ const exclusive = spawnSync(
103
+ process.execPath,
104
+ [cli, "board:reconcile", "--repositories", "example/widget", "--dry-run", "--apply"],
105
+ { cwd: root, encoding: "utf8" }
106
+ );
107
+ assert.equal(exclusive.status, 1);
108
+ assert.match(exclusive.stderr, /dry-run.*apply|apply.*dry-run/u);
109
+ } finally {
110
+ rmSync(root, { recursive: true, force: true });
89
111
  }
112
+ }
113
+ );
114
+ test("CLI version agrees with its adjacent package independently of caller cwd", { tags: ["release"] }, () => {
115
+ const metadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
116
+ assert.ok(typeof metadata === "object" && metadata !== null && "version" in metadata);
117
+ assert.equal(typeof metadata.version, "string");
118
+ const cli = join(process.cwd(), "dist", "cli.js");
119
+ const caller = mkdtempSync(join(tmpdir(), "ai-delivery-version-caller-"));
120
+ try {
121
+ writeFileSync(join(caller, "package.json"), JSON.stringify({ name: "unrelated-caller", version: "9.9.9" }));
122
+ const result = spawnSync(process.execPath, [cli, "--version"], { cwd: caller, encoding: "utf8" });
123
+ assert.equal(result.status, 0);
124
+ assert.equal(result.stderr, "");
125
+ assert.equal(result.stdout.trim(), metadata.version);
126
+ const versionModule = pathToFileURL(join(process.cwd(), "dist", "version.js")).href;
127
+ const shared = spawnSync(
128
+ process.execPath,
129
+ [
130
+ "--input-type=module",
131
+ "-e",
132
+ `import { PACKAGE_VERSION } from ${JSON.stringify(versionModule)}; console.log(PACKAGE_VERSION);`
133
+ ],
134
+ { cwd: caller, encoding: "utf8" }
135
+ );
136
+ assert.equal(shared.status, 0, shared.stderr);
137
+ assert.equal(shared.stderr, "");
138
+ assert.equal(shared.stdout.trim(), metadata.version);
139
+ } finally {
140
+ rmSync(caller, { recursive: true, force: true });
141
+ }
90
142
  });
91
- test('CLI version agrees with its adjacent package independently of caller cwd', () => {
92
- const metadata = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
93
- assert.ok(typeof metadata === 'object' && metadata !== null && 'version' in metadata);
94
- assert.equal(typeof metadata.version, 'string');
95
- const cli = join(process.cwd(), 'dist', 'cli.js');
96
- const caller = mkdtempSync(join(tmpdir(), 'ai-delivery-version-caller-'));
97
- try {
98
- writeFileSync(join(caller, 'package.json'), JSON.stringify({ name: 'unrelated-caller', version: '9.9.9' }));
99
- const result = spawnSync(process.execPath, [cli, '--version'], { cwd: caller, encoding: 'utf8' });
100
- assert.equal(result.status, 0);
101
- assert.equal(result.stderr, '');
102
- assert.equal(result.stdout.trim(), metadata.version);
103
- const versionModule = pathToFileURL(join(process.cwd(), 'dist', 'version.js')).href;
104
- const shared = spawnSync(process.execPath, [
105
- '--input-type=module',
106
- '-e',
107
- `import { PACKAGE_VERSION } from ${JSON.stringify(versionModule)}; console.log(PACKAGE_VERSION);`,
108
- ], { cwd: caller, encoding: 'utf8' });
109
- assert.equal(shared.status, 0, shared.stderr);
110
- assert.equal(shared.stderr, '');
111
- assert.equal(shared.stdout.trim(), metadata.version);
112
- }
113
- finally {
114
- rmSync(caller, { recursive: true, force: true });
115
- }
143
+ test("CLI preserves recoverable start JSON and exits nonzero after creation failure", { tags: ["release"] }, () => {
144
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
145
+ const failure = {
146
+ schemaVersion: "ai-delivery.issue-start-registration@1",
147
+ status: "created-not-started",
148
+ createdIssue: { number: 17 }
149
+ };
150
+ const code = `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_start', ${JSON.stringify(failure)});`;
151
+ const result = spawnSync(process.execPath, ["--input-type=module", "-e", code], { encoding: "utf8" });
152
+ assert.equal(result.status, 1);
153
+ assert.deepEqual(JSON.parse(result.stdout), failure);
154
+ assert.equal(result.stderr, "");
155
+ const ordinary = spawnSync(
156
+ process.execPath,
157
+ [
158
+ "--input-type=module",
159
+ "-e",
160
+ `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_start', {status:'started'});`
161
+ ],
162
+ { encoding: "utf8" }
163
+ );
164
+ assert.equal(ordinary.status, 0);
165
+ const parsed = JSON.parse(ordinary.stdout);
166
+ assert.ok(parsed !== null && typeof parsed === "object" && "status" in parsed);
167
+ assert.equal(parsed.status, "started");
116
168
  });
117
- test('CLI preserves recoverable start JSON and exits nonzero after creation failure', () => {
118
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
119
- const failure = {
120
- schemaVersion: 'ai-delivery.issue-start-registration@1',
121
- status: 'created-not-started',
122
- createdIssue: { number: 17 },
123
- };
124
- const code = `import { printCommandResult } from ${JSON.stringify(helper)};` +
125
- `printCommandResult('issue_start', ${JSON.stringify(failure)});`;
126
- const result = spawnSync(process.execPath, ['--input-type=module', '-e', code], { encoding: 'utf8' });
127
- assert.equal(result.status, 1);
128
- assert.deepEqual(JSON.parse(result.stdout), failure);
129
- assert.equal(result.stderr, '');
130
- const ordinary = spawnSync(process.execPath, [
131
- '--input-type=module',
132
- '-e',
133
- `import { printCommandResult } from ${JSON.stringify(helper)};` +
134
- `printCommandResult('issue_start', {status:'started'});`,
135
- ], { encoding: 'utf8' });
136
- assert.equal(ordinary.status, 0);
137
- const parsed = JSON.parse(ordinary.stdout);
138
- assert.ok(parsed !== null && typeof parsed === 'object' && 'status' in parsed);
139
- assert.equal(parsed.status, 'started');
169
+ test("CLI known-issue incomplete start preserves recovery JSON and exits nonzero", { tags: ["release"] }, () => {
170
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
171
+ const failure = {
172
+ status: "start-incomplete",
173
+ issueNumber: 17,
174
+ repository: "example/widget",
175
+ failure: { phase: "project-status", message: "Readback failed" },
176
+ safeResume: { tool: "issue_start", arguments: { repo: "example/widget", issueNumber: 17, branch: "issue/17" } }
177
+ };
178
+ const result = spawnSync(
179
+ process.execPath,
180
+ [
181
+ "--input-type=module",
182
+ "-e",
183
+ `import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('issue_start', ${JSON.stringify(failure)});`
184
+ ],
185
+ { encoding: "utf8" }
186
+ );
187
+ assert.equal(result.status, 1);
188
+ assert.deepEqual(JSON.parse(result.stdout), failure);
189
+ assert.equal(result.stderr, "");
140
190
  });
141
- test('CLI known-issue incomplete start preserves recovery JSON and exits nonzero', () => {
142
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
143
- const failure = {
144
- status: 'start-incomplete',
145
- issueNumber: 17,
146
- repository: 'example/widget',
147
- failure: { phase: 'project-status', message: 'Readback failed' },
148
- safeResume: { tool: 'issue_start', arguments: { repo: 'example/widget', issueNumber: 17, branch: 'issue/17' } },
149
- };
150
- const result = spawnSync(process.execPath, [
151
- '--input-type=module',
152
- '-e',
153
- `import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('issue_start', ${JSON.stringify(failure)});`,
154
- ], { encoding: 'utf8' });
155
- assert.equal(result.status, 1);
156
- assert.deepEqual(JSON.parse(result.stdout), failure);
157
- assert.equal(result.stderr, '');
191
+ test("the extracted real CLI error renderer preserves ordinary refusal, exit and stdout", { tags: ["release"] }, () => {
192
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
193
+ const result = spawnSync(
194
+ process.execPath,
195
+ [
196
+ "--input-type=module",
197
+ "-e",
198
+ `import { printCommandError } from ${JSON.stringify(helper)}; printCommandError(new Error('ordinary refusal'));`
199
+ ],
200
+ { encoding: "utf8" }
201
+ );
202
+ assert.equal(result.status, 1);
203
+ assert.equal(result.stdout, "");
204
+ assert.equal(result.stderr, "ai-delivery: ordinary refusal\n");
158
205
  });
159
- test('the extracted real CLI error renderer preserves ordinary refusal, exit and stdout', () => {
160
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
161
- const result = spawnSync(process.execPath, [
162
- '--input-type=module',
163
- '-e',
164
- `import { printCommandError } from ${JSON.stringify(helper)}; printCommandError(new Error('ordinary refusal'));`,
165
- ], { encoding: 'utf8' });
166
- assert.equal(result.status, 1);
167
- assert.equal(result.stdout, '');
168
- assert.equal(result.stderr, 'ai-delivery: ordinary refusal\n');
206
+ test("machine diagnostics are immutable identity-bound data and do not change error serialization", () => {
207
+ const error = new DeliveryError("safe refusal");
208
+ Object.assign(error, { status: 503 });
209
+ const before = JSON.stringify(error);
210
+ const input = {
211
+ phase: "rest.request",
212
+ endpoint: "pulls.merge",
213
+ status: 503,
214
+ code: "ECONNRESET",
215
+ requestId: "ABCD:1234:5678:9ABC:DEF0"
216
+ };
217
+ setMachineRequestDiagnostics(error, input);
218
+ const diagnostic = getMachineRequestDiagnostics(error);
219
+ assert.deepEqual(diagnostic, {
220
+ phase: "rest.request",
221
+ endpoint: "pulls.merge",
222
+ status: 503,
223
+ code: "ECONNRESET",
224
+ requestId: "ABCD:1234:5678:9ABC:DEF0"
225
+ });
226
+ assert.ok(diagnostic && Object.isFrozen(diagnostic));
227
+ input.status = 401;
228
+ assert.equal(Reflect.set(diagnostic, "status", 401), false);
229
+ setMachineRequestDiagnostics(error, input);
230
+ assert.equal(getMachineRequestDiagnostics(error)?.status, 503);
231
+ assert.equal(JSON.stringify(error), before);
232
+ assert.equal(getMachineRequestDiagnostics(new Error("ordinary refusal")), void 0);
233
+ assert.equal(getMachineRequestDiagnostics({ name: "DeliveryError", status: 503, diagnostic }), void 0);
169
234
  });
170
- test('machine diagnostics are immutable identity-bound data and do not change error serialization', () => {
171
- const error = new DeliveryError('safe refusal');
172
- Object.assign(error, { status: 503 });
173
- const before = JSON.stringify(error);
174
- const input = {
175
- phase: 'rest.request',
176
- endpoint: 'pulls.merge',
177
- status: 503,
178
- code: 'ECONNRESET',
179
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
180
- };
181
- setMachineRequestDiagnostics(error, input);
182
- const diagnostic = getMachineRequestDiagnostics(error);
183
- assert.deepEqual(diagnostic, {
184
- phase: 'rest.request',
185
- endpoint: 'pulls.merge',
186
- status: 503,
187
- code: 'ECONNRESET',
188
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
235
+ test("invalid machine metadata remains UNKNOWN without getter or coercion execution", () => {
236
+ const invalidStatuses = [
237
+ void 0,
238
+ null,
239
+ NaN,
240
+ Infinity,
241
+ -Infinity,
242
+ 99,
243
+ 600,
244
+ 401.5,
245
+ "403",
246
+ {},
247
+ [],
248
+ /* @__PURE__ */ Symbol("private")
249
+ ];
250
+ for (const status of invalidStatuses) {
251
+ const error2 = new DeliveryError("safe refusal");
252
+ setMachineRequestDiagnostics(error2, {
253
+ phase: "private-phase",
254
+ endpoint: "https://private.invalid/token",
255
+ status,
256
+ code: "private-code",
257
+ requestId: "ghp_fictional_private_token"
189
258
  });
190
- assert.ok(diagnostic && Object.isFrozen(diagnostic));
191
- input.status = 401;
192
- assert.equal(Reflect.set(diagnostic, 'status', 401), false);
193
- setMachineRequestDiagnostics(error, input);
194
- assert.equal(getMachineRequestDiagnostics(error)?.status, 503);
195
- assert.equal(JSON.stringify(error), before);
196
- assert.equal(getMachineRequestDiagnostics(new Error('ordinary refusal')), undefined);
197
- assert.equal(getMachineRequestDiagnostics({ name: 'DeliveryError', status: 503, diagnostic }), undefined);
198
- });
199
- test('invalid machine metadata remains UNKNOWN without getter or coercion execution', () => {
200
- const invalidStatuses = [
201
- undefined,
202
- null,
203
- NaN,
204
- Infinity,
205
- -Infinity,
206
- 99,
207
- 600,
208
- 401.5,
209
- '403',
210
- {},
211
- [],
212
- Symbol('private'),
213
- ];
214
- for (const status of invalidStatuses) {
215
- const error = new DeliveryError('safe refusal');
216
- setMachineRequestDiagnostics(error, {
217
- phase: 'private-phase',
218
- endpoint: 'https://private.invalid/token',
219
- status,
220
- code: 'private-code',
221
- requestId: 'ghp_fictional_private_token',
222
- });
223
- assert.deepEqual(getMachineRequestDiagnostics(error), {
224
- phase: 'UNKNOWN',
225
- endpoint: 'UNKNOWN',
226
- status: 'UNKNOWN',
227
- code: 'UNKNOWN',
228
- requestId: 'UNKNOWN',
229
- });
230
- assert.equal(JSON.stringify(error).includes('private'), false);
231
- }
232
- let invoked = 0;
233
- const input = {
234
- phase: 'rest.request',
235
- endpoint: 'pulls.merge',
236
- status: 500,
237
- code: 'ECONNRESET',
238
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
239
- };
240
- for (const key of Object.keys(input))
241
- Object.defineProperty(input, key, {
242
- get() {
243
- invoked++;
244
- throw new Error('private getter');
245
- },
246
- });
247
- const error = new DeliveryError('safe refusal');
248
- setMachineRequestDiagnostics(error, input);
249
- assert.equal(invoked, 0);
250
- assert.deepEqual(getMachineRequestDiagnostics(error), {
251
- phase: 'UNKNOWN',
252
- endpoint: 'UNKNOWN',
253
- status: 'UNKNOWN',
254
- code: 'UNKNOWN',
255
- requestId: 'UNKNOWN',
259
+ assert.deepEqual(getMachineRequestDiagnostics(error2), {
260
+ phase: "UNKNOWN",
261
+ endpoint: "UNKNOWN",
262
+ status: "UNKNOWN",
263
+ code: "UNKNOWN",
264
+ requestId: "UNKNOWN"
256
265
  });
257
- const proxy = new Proxy(input, {
258
- getOwnPropertyDescriptor() {
259
- invoked++;
260
- throw new Error('private trap');
261
- },
262
- get() {
263
- invoked++;
264
- throw new Error('private trap');
265
- },
266
+ assert.equal(JSON.stringify(error2).includes("private"), false);
267
+ }
268
+ let invoked = 0;
269
+ const input = {
270
+ phase: "rest.request",
271
+ endpoint: "pulls.merge",
272
+ status: 500,
273
+ code: "ECONNRESET",
274
+ requestId: "ABCD:1234:5678:9ABC:DEF0"
275
+ };
276
+ for (const key of Object.keys(input))
277
+ Object.defineProperty(input, key, {
278
+ get() {
279
+ invoked++;
280
+ throw new Error("private getter");
281
+ }
266
282
  });
267
- const proxyError = new DeliveryError('safe refusal');
268
- setMachineRequestDiagnostics(proxyError, proxy);
269
- assert.deepEqual(getMachineRequestDiagnostics(proxyError), getMachineRequestDiagnostics(error));
270
- assert.equal(getMachineRequestDiagnostics(proxy), undefined);
271
- assert.equal(invoked, 0);
272
- });
273
- test('request identifiers and transport codes reject oversized, control and private-looking values', () => {
274
- const requestIds = [
275
- undefined,
276
- null,
277
- {},
278
- [],
279
- 'ABCD:1234:5678',
280
- 'ABCD:1234:5678:9ABC:DEF0\r\n',
281
- 'ABCD:1234:5678:9ABC:\u001b',
282
- 'ABCD:1234:5678:9ABC:秘密',
283
- '/private/credential.pem',
284
- 'Bearer fictional_private_token',
285
- `ABCD:${'A'.repeat(31)}:${'B'.repeat(30)}:${'C'.repeat(30)}:${'D'.repeat(30)}`,
286
- ];
287
- for (const requestId of requestIds) {
288
- const error = new DeliveryError('safe refusal');
289
- setMachineRequestDiagnostics(error, {
290
- phase: 'rest.request',
291
- endpoint: 'pulls.merge',
292
- status: 500,
293
- code: 'ECONNRESET\n',
294
- requestId,
295
- });
296
- assert.equal(getMachineRequestDiagnostics(error)?.requestId, 'UNKNOWN');
297
- assert.equal(getMachineRequestDiagnostics(error)?.code, 'UNKNOWN');
298
- }
299
- for (const code of [
300
- 'ECONNRESET',
301
- 'ECONNREFUSED',
302
- 'ENOTFOUND',
303
- 'EAI_AGAIN',
304
- 'ETIMEDOUT',
305
- 'ABORT_ERR',
306
- 'UND_ERR_CONNECT_TIMEOUT',
307
- 'UND_ERR_SOCKET',
308
- ]) {
309
- const error = new DeliveryError('safe refusal');
310
- setMachineRequestDiagnostics(error, {
311
- phase: 'graphql.request',
312
- endpoint: 'graphql',
313
- status: undefined,
314
- code,
315
- requestId: undefined,
316
- });
317
- assert.equal(getMachineRequestDiagnostics(error)?.code, code);
318
- assert.equal(getMachineRequestDiagnostics(error)?.status, 'UNKNOWN');
283
+ const error = new DeliveryError("safe refusal");
284
+ setMachineRequestDiagnostics(error, input);
285
+ assert.equal(invoked, 0);
286
+ assert.deepEqual(getMachineRequestDiagnostics(error), {
287
+ phase: "UNKNOWN",
288
+ endpoint: "UNKNOWN",
289
+ status: "UNKNOWN",
290
+ code: "UNKNOWN",
291
+ requestId: "UNKNOWN"
292
+ });
293
+ const proxy = new Proxy(input, {
294
+ getOwnPropertyDescriptor() {
295
+ invoked++;
296
+ throw new Error("private trap");
297
+ },
298
+ get() {
299
+ invoked++;
300
+ throw new Error("private trap");
319
301
  }
302
+ });
303
+ const proxyError = new DeliveryError("safe refusal");
304
+ setMachineRequestDiagnostics(proxyError, proxy);
305
+ assert.deepEqual(getMachineRequestDiagnostics(proxyError), getMachineRequestDiagnostics(error));
306
+ assert.equal(getMachineRequestDiagnostics(proxy), void 0);
307
+ assert.equal(invoked, 0);
320
308
  });
321
- test('the real CLI renderer bounds diagnostics and leaves the unchanged refusal line last', () => {
322
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
323
- const errors = pathToFileURL(join(process.cwd(), 'dist', 'errors.js')).href;
324
- const requestId = `ABCD:${'A'.repeat(30)}:${'B'.repeat(30)}:${'C'.repeat(30)}:${'D'.repeat(30)}`;
309
+ test("request identifiers and transport codes reject oversized, control and private-looking values", () => {
310
+ const requestIds = [
311
+ void 0,
312
+ null,
313
+ {},
314
+ [],
315
+ "ABCD:1234:5678",
316
+ "ABCD:1234:5678:9ABC:DEF0\r\n",
317
+ "ABCD:1234:5678:9ABC:\x1B",
318
+ "ABCD:1234:5678:9ABC:\u79D8\u5BC6",
319
+ "/private/credential.pem",
320
+ "Bearer fictional_private_token",
321
+ `ABCD:${"A".repeat(31)}:${"B".repeat(30)}:${"C".repeat(30)}:${"D".repeat(30)}`
322
+ ];
323
+ for (const requestId of requestIds) {
324
+ const error = new DeliveryError("safe refusal");
325
+ setMachineRequestDiagnostics(error, {
326
+ phase: "rest.request",
327
+ endpoint: "pulls.merge",
328
+ status: 500,
329
+ code: "ECONNRESET\n",
330
+ requestId
331
+ });
332
+ assert.equal(getMachineRequestDiagnostics(error)?.requestId, "UNKNOWN");
333
+ assert.equal(getMachineRequestDiagnostics(error)?.code, "UNKNOWN");
334
+ }
335
+ for (const code of [
336
+ "ECONNRESET",
337
+ "ECONNREFUSED",
338
+ "ENOTFOUND",
339
+ "EAI_AGAIN",
340
+ "ETIMEDOUT",
341
+ "ABORT_ERR",
342
+ "UND_ERR_CONNECT_TIMEOUT",
343
+ "UND_ERR_SOCKET"
344
+ ]) {
345
+ const error = new DeliveryError("safe refusal");
346
+ setMachineRequestDiagnostics(error, {
347
+ phase: "graphql.request",
348
+ endpoint: "graphql",
349
+ status: void 0,
350
+ code,
351
+ requestId: void 0
352
+ });
353
+ assert.equal(getMachineRequestDiagnostics(error)?.code, code);
354
+ assert.equal(getMachineRequestDiagnostics(error)?.status, "UNKNOWN");
355
+ }
356
+ });
357
+ test(
358
+ "the real CLI renderer bounds diagnostics and leaves the unchanged refusal line last",
359
+ { tags: ["release"] },
360
+ () => {
361
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
362
+ const errors = pathToFileURL(join(process.cwd(), "dist", "errors.js")).href;
363
+ const requestId = `ABCD:${"A".repeat(30)}:${"B".repeat(30)}:${"C".repeat(30)}:${"D".repeat(30)}`;
325
364
  assert.equal(requestId.length, 128);
326
- const code = `import { DeliveryError,setMachineRequestDiagnostics } from ${JSON.stringify(errors)}; import { printCommandError } from ${JSON.stringify(helper)}; const error=new DeliveryError('safe refusal','fictional_private_hint'); setMachineRequestDiagnostics(error,${JSON.stringify({ phase: 'rest.request', endpoint: 'pulls.merge', status: 500, code: 'UND_ERR_CONNECT_TIMEOUT', requestId })}); printCommandError(error);`;
327
- const result = spawnSync(process.execPath, ['--input-type=module', '-e', code], { encoding: 'utf8' });
365
+ const code = `import { DeliveryError,setMachineRequestDiagnostics } from ${JSON.stringify(errors)}; import { printCommandError } from ${JSON.stringify(helper)}; const error=new DeliveryError('safe refusal','fictional_private_hint'); setMachineRequestDiagnostics(error,${JSON.stringify({ phase: "rest.request", endpoint: "pulls.merge", status: 500, code: "UND_ERR_CONNECT_TIMEOUT", requestId })}); printCommandError(error);`;
366
+ const result = spawnSync(process.execPath, ["--input-type=module", "-e", code], { encoding: "utf8" });
328
367
  assert.equal(result.status, 1);
329
- assert.equal(result.stdout, '');
330
- assert.equal(result.stderr.includes('fictional_private_hint'), false);
331
- assert.ok(Buffer.byteLength(result.stderr.split('\n')[0] + '\n') <= 512);
332
- assert.equal(result.stderr.trimEnd().split('\n').at(-1), 'ai-delivery: safe refusal');
368
+ assert.equal(result.stdout, "");
369
+ assert.equal(result.stderr.includes("fictional_private_hint"), false);
370
+ assert.ok(Buffer.byteLength(result.stderr.split("\n")[0] + "\n") <= 512);
371
+ assert.equal(result.stderr.trimEnd().split("\n").at(-1), "ai-delivery: safe refusal");
372
+ }
373
+ );
374
+ test("CLI batch partial failure prints every result before returning nonzero", { tags: ["release"] }, () => {
375
+ const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
376
+ const partial = {
377
+ results: [
378
+ { issueNumber: 1, status: "applied" },
379
+ { issueNumber: 2, status: "failed", reason: "Native readback unavailable" }
380
+ ],
381
+ summary: { failed: 1 }
382
+ };
383
+ const result = spawnSync(
384
+ process.execPath,
385
+ [
386
+ "--input-type=module",
387
+ "-e",
388
+ `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',${JSON.stringify(partial)});`
389
+ ],
390
+ { encoding: "utf8" }
391
+ );
392
+ assert.equal(result.status, 1);
393
+ assert.deepEqual(JSON.parse(result.stdout), partial);
394
+ assert.equal(result.stderr, "");
395
+ const success = spawnSync(
396
+ process.execPath,
397
+ [
398
+ "--input-type=module",
399
+ "-e",
400
+ `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',{summary:{failed:0}});`
401
+ ],
402
+ { encoding: "utf8" }
403
+ );
404
+ assert.equal(success.status, 0);
333
405
  });
334
- test('CLI batch partial failure prints every result before returning nonzero', () => {
335
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
336
- const partial = {
337
- results: [
338
- { issueNumber: 1, status: 'applied' },
339
- { issueNumber: 2, status: 'failed', reason: 'Native readback unavailable' },
340
- ],
341
- summary: { failed: 1 },
342
- };
343
- const result = spawnSync(process.execPath, [
344
- '--input-type=module',
345
- '-e',
346
- `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',${JSON.stringify(partial)});`,
347
- ], { encoding: 'utf8' });
406
+ test("actual CLI batch input validates before configuration or native access", { tags: ["release"] }, () => {
407
+ const root = mkdtempSync(join(tmpdir(), "batch-cli-refusal-"));
408
+ try {
409
+ const file = join(root, "items.json");
410
+ writeFileSync(file, "[]");
411
+ const result = spawnSync(
412
+ process.execPath,
413
+ [
414
+ join(process.cwd(), "dist", "cli.js"),
415
+ "--repo",
416
+ "example/widget",
417
+ "batch:update",
418
+ "--items-file",
419
+ file,
420
+ "--dry-run"
421
+ ],
422
+ {
423
+ cwd: root,
424
+ encoding: "utf8",
425
+ env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, "absent-settings.json") }
426
+ }
427
+ );
348
428
  assert.equal(result.status, 1);
349
- assert.deepEqual(JSON.parse(result.stdout), partial);
350
- assert.equal(result.stderr, '');
351
- const success = spawnSync(process.execPath, [
352
- '--input-type=module',
353
- '-e',
354
- `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',{summary:{failed:0}});`,
355
- ], { encoding: 'utf8' });
356
- assert.equal(success.status, 0);
357
- });
358
- test('actual CLI batch input validates before configuration or native access', () => {
359
- const root = mkdtempSync(join(tmpdir(), 'batch-cli-refusal-'));
360
- try {
361
- const file = join(root, 'items.json');
362
- writeFileSync(file, '[]');
363
- const result = spawnSync(process.execPath, [
364
- join(process.cwd(), 'dist', 'cli.js'),
365
- '--repo',
366
- 'example/widget',
367
- 'batch:update',
368
- '--items-file',
369
- file,
370
- '--dry-run',
371
- ], {
372
- cwd: root,
373
- encoding: 'utf8',
374
- env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
375
- });
376
- assert.equal(result.status, 1);
377
- assert.equal(result.stdout, '');
378
- assert.doesNotMatch(result.stderr, /absent-settings|credential|token/iu);
379
- const diagnostic = JSON.parse(result.stderr.replace(/^ai-delivery: /u, '').trim());
380
- assert.equal(diagnostic.failures[0].field, 'items');
381
- assert.equal(diagnostic.failures[0].code, 'field.type');
382
- writeFileSync(file, JSON.stringify([{ issueNumber: 1, PRIVATE_PROPERTY: 'PRIVATE_VALUE' }]));
383
- const privateInput = spawnSync(process.execPath, [join(process.cwd(), 'dist', 'cli.js'), '--repo', 'example/widget', 'batch:update', '--items-file', file], {
384
- cwd: root,
385
- encoding: 'utf8',
386
- env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
387
- });
388
- assert.equal(privateInput.status, 1);
389
- assert.doesNotMatch(privateInput.stderr, /PRIVATE_PROPERTY|PRIVATE_VALUE|absent-settings/u);
390
- }
391
- finally {
392
- rmSync(root, { recursive: true, force: true });
393
- }
429
+ assert.equal(result.stdout, "");
430
+ assert.doesNotMatch(result.stderr, /absent-settings|credential|token/iu);
431
+ const diagnostic = JSON.parse(result.stderr.replace(/^ai-delivery: /u, "").trim());
432
+ assert.equal(diagnostic.failures[0].field, "items");
433
+ assert.equal(diagnostic.failures[0].code, "field.type");
434
+ writeFileSync(file, JSON.stringify([{ issueNumber: 1, PRIVATE_PROPERTY: "PRIVATE_VALUE" }]));
435
+ const privateInput = spawnSync(
436
+ process.execPath,
437
+ [join(process.cwd(), "dist", "cli.js"), "--repo", "example/widget", "batch:update", "--items-file", file],
438
+ {
439
+ cwd: root,
440
+ encoding: "utf8",
441
+ env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, "absent-settings.json") }
442
+ }
443
+ );
444
+ assert.equal(privateInput.status, 1);
445
+ assert.doesNotMatch(privateInput.stderr, /PRIVATE_PROPERTY|PRIVATE_VALUE|absent-settings/u);
446
+ } finally {
447
+ rmSync(root, { recursive: true, force: true });
448
+ }
394
449
  });
395
- //# sourceMappingURL=cliResult.test.js.map
450
+ //# sourceMappingURL=cliResult.test.js.map