@aviaratech/ai-delivery 0.3.34 → 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 (301) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -506
  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 +1746 -0
  9. package/dist/boardReconcile.test.js.map +7 -0
  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 +406 -485
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -25
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +434 -297
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +320 -14
  22. package/dist/config/deliveryConfig.js +472 -385
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +775 -584
  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 -477
  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.d.ts +1 -0
  53. package/dist/deliveryBoard.test.js +649 -0
  54. package/dist/deliveryBoard.test.js.map +7 -0
  55. package/dist/deliveryHealth.test.js +179 -155
  56. package/dist/deliveryHealth.test.js.map +7 -1
  57. package/dist/dependencyCompatibility.test.js +154 -140
  58. package/dist/dependencyCompatibility.test.js.map +7 -1
  59. package/dist/directoryIndependent.test.js +417 -383
  60. package/dist/directoryIndependent.test.js.map +7 -1
  61. package/dist/dispatch.d.ts +17 -12
  62. package/dist/dispatch.js +330 -322
  63. package/dist/dispatch.js.map +7 -1
  64. package/dist/errors.d.ts +16 -3
  65. package/dist/errors.js +104 -82
  66. package/dist/errors.js.map +7 -1
  67. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  68. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  69. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  70. package/dist/fixtures/discovery.d.ts +59 -19
  71. package/dist/fixtures/discovery.js +96 -90
  72. package/dist/fixtures/discovery.js.map +7 -1
  73. package/dist/fixtures/inertEntrypointChild.js +57 -56
  74. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  75. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  76. package/dist/fixtures/inertEntrypoints.js +321 -276
  77. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  78. package/dist/fixtures/inertTarget.d.ts +78 -7
  79. package/dist/fixtures/inertTarget.js +769 -691
  80. package/dist/fixtures/inertTarget.js.map +7 -1
  81. package/dist/fixtures/issue63.d.ts +4 -3
  82. package/dist/fixtures/issue63.js +260 -274
  83. package/dist/fixtures/issue63.js.map +7 -1
  84. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  85. package/dist/fixtures/issueProjectItems.js +15 -0
  86. package/dist/fixtures/issueProjectItems.js.map +7 -0
  87. package/dist/fixtures/readView.d.ts +120 -0
  88. package/dist/fixtures/readView.js +172 -0
  89. package/dist/fixtures/readView.js.map +7 -0
  90. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  91. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  92. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  93. package/dist/genericCompatibility.test.js +64 -55
  94. package/dist/genericCompatibility.test.js.map +7 -1
  95. package/dist/git.js +73 -67
  96. package/dist/git.js.map +7 -1
  97. package/dist/gitProcess.d.ts +1 -1
  98. package/dist/gitProcess.js +58 -53
  99. package/dist/gitProcess.js.map +7 -1
  100. package/dist/github/client.d.ts +2 -2
  101. package/dist/github/client.js +484 -379
  102. package/dist/github/client.js.map +7 -1
  103. package/dist/github/commandIdentityPolicy.js +44 -51
  104. package/dist/github/commandIdentityPolicy.js.map +7 -1
  105. package/dist/github/discovery.d.ts +3 -0
  106. package/dist/github/discovery.js +197 -201
  107. package/dist/github/discovery.js.map +7 -1
  108. package/dist/github/discovery.test.js +223 -177
  109. package/dist/github/discovery.test.js.map +7 -1
  110. package/dist/github/issueHistory.d.ts +2 -2
  111. package/dist/github/issueHistory.js +117 -125
  112. package/dist/github/issueHistory.js.map +7 -1
  113. package/dist/github/machineAuth.d.ts +1 -1
  114. package/dist/github/machineAuth.js +126 -117
  115. package/dist/github/machineAuth.js.map +7 -1
  116. package/dist/github/machineAuth.test.js +755 -639
  117. package/dist/github/machineAuth.test.js.map +7 -1
  118. package/dist/github/nativeIssueMetadata.js +286 -273
  119. package/dist/github/nativeIssueMetadata.js.map +7 -1
  120. package/dist/github/projectDelivery.d.ts +53 -1
  121. package/dist/github/projectDelivery.js +623 -460
  122. package/dist/github/projectDelivery.js.map +7 -1
  123. package/dist/github/relationships.d.ts +5 -2
  124. package/dist/github/relationships.js +434 -333
  125. package/dist/github/relationships.js.map +7 -1
  126. package/dist/github/repo.d.ts +1 -0
  127. package/dist/github/repo.js +123 -96
  128. package/dist/github/repo.js.map +7 -1
  129. package/dist/index.js +3 -3
  130. package/dist/index.js.map +7 -1
  131. package/dist/issue.d.ts +103 -7
  132. package/dist/issue.js +2104 -1547
  133. package/dist/issue.js.map +7 -1
  134. package/dist/issue63History.test.js +40 -42
  135. package/dist/issue63History.test.js.map +7 -1
  136. package/dist/issue63Routes.test.js +154 -143
  137. package/dist/issue63Routes.test.js.map +7 -1
  138. package/dist/issueBatchUpdate.test.js +1004 -683
  139. package/dist/issueBatchUpdate.test.js.map +7 -1
  140. package/dist/issueBlockerGuard.test.js +262 -226
  141. package/dist/issueBlockerGuard.test.js.map +7 -1
  142. package/dist/issueContract.d.ts +23 -4
  143. package/dist/issueContract.js +416 -395
  144. package/dist/issueContract.js.map +7 -1
  145. package/dist/issueContract.test.d.ts +4 -3
  146. package/dist/issueContract.test.js +358 -321
  147. package/dist/issueContract.test.js.map +7 -1
  148. package/dist/issueDates.test.js +235 -233
  149. package/dist/issueDates.test.js.map +7 -1
  150. package/dist/issueInfoReadback.test.js +304 -190
  151. package/dist/issueInfoReadback.test.js.map +7 -1
  152. package/dist/issueIntake.test.js +1945 -1732
  153. package/dist/issueIntake.test.js.map +7 -1
  154. package/dist/issueJournal.d.ts +40 -19
  155. package/dist/issueJournal.js +229 -138
  156. package/dist/issueJournal.js.map +7 -1
  157. package/dist/issueJournal.test.js +605 -422
  158. package/dist/issueJournal.test.js.map +7 -1
  159. package/dist/issueRollup.test.d.ts +1 -0
  160. package/dist/issueRollup.test.js +476 -0
  161. package/dist/issueRollup.test.js.map +7 -0
  162. package/dist/issueTracking.test.js +1088 -593
  163. package/dist/issueTracking.test.js.map +7 -1
  164. package/dist/issueWriteRecovery.test.d.ts +1 -0
  165. package/dist/issueWriteRecovery.test.js +260 -0
  166. package/dist/issueWriteRecovery.test.js.map +7 -0
  167. package/dist/lifecycle.test.js +112 -441
  168. package/dist/lifecycle.test.js.map +7 -1
  169. package/dist/logger.js +80 -74
  170. package/dist/logger.js.map +7 -1
  171. package/dist/mcp/index.js +116 -90
  172. package/dist/mcp/index.js.map +7 -1
  173. package/dist/mcp/tools.d.ts +790 -220
  174. package/dist/mcp/tools.js +267 -333
  175. package/dist/mcp/tools.js.map +7 -1
  176. package/dist/pluginAuthProbe.js +63 -52
  177. package/dist/pluginAuthProbe.js.map +7 -1
  178. package/dist/pluginAuthProbe.test.js +85 -62
  179. package/dist/pluginAuthProbe.test.js.map +7 -1
  180. package/dist/pluginCredentials.test.js +282 -259
  181. package/dist/pluginCredentials.test.js.map +7 -1
  182. package/dist/pluginDoctor.test.js +653 -588
  183. package/dist/pluginDoctor.test.js.map +7 -1
  184. package/dist/pluginInstaller.d.ts +7 -5
  185. package/dist/pluginInstaller.js +1173 -1231
  186. package/dist/pluginInstaller.js.map +7 -1
  187. package/dist/pluginInstaller.test.js +1822 -1283
  188. package/dist/pluginInstaller.test.js.map +7 -1
  189. package/dist/pluginPackaging.test.js +485 -305
  190. package/dist/pluginPackaging.test.js.map +7 -1
  191. package/dist/pr.d.ts +132 -94
  192. package/dist/pr.js +1521 -1323
  193. package/dist/pr.js.map +7 -1
  194. package/dist/pr.test.js +1678 -632
  195. package/dist/pr.test.js.map +7 -1
  196. package/dist/prAssociation.test.js +2419 -1788
  197. package/dist/prAssociation.test.js.map +7 -1
  198. package/dist/prDispatch.test.js +150 -89
  199. package/dist/prDispatch.test.js.map +7 -1
  200. package/dist/readView.d.ts +183 -0
  201. package/dist/readView.js +217 -0
  202. package/dist/readView.js.map +7 -0
  203. package/dist/readView.test.d.ts +1 -0
  204. package/dist/readView.test.js +119 -0
  205. package/dist/readView.test.js.map +7 -0
  206. package/dist/releaseReconciliation.test.js +267 -288
  207. package/dist/releaseReconciliation.test.js.map +7 -1
  208. package/dist/releaseWorkflow.test.js +2493 -422
  209. package/dist/releaseWorkflow.test.js.map +7 -1
  210. package/dist/review.d.ts +738 -2
  211. package/dist/review.js +601 -348
  212. package/dist/review.js.map +7 -1
  213. package/dist/review.test.js +1218 -812
  214. package/dist/review.test.js.map +7 -1
  215. package/dist/reviewSubmit.test.d.ts +1 -0
  216. package/dist/reviewSubmit.test.js +747 -0
  217. package/dist/reviewSubmit.test.js.map +7 -0
  218. package/dist/services/agentReadinessService.js +42 -37
  219. package/dist/services/agentReadinessService.js.map +7 -1
  220. package/dist/services/blockerGuardService.js +188 -188
  221. package/dist/services/blockerGuardService.js.map +7 -1
  222. package/dist/services/boardReconcileService.d.ts +1204 -0
  223. package/dist/services/boardReconcileService.js +1445 -0
  224. package/dist/services/boardReconcileService.js.map +7 -0
  225. package/dist/services/deliveryAdmission.d.ts +2 -0
  226. package/dist/services/deliveryAdmission.js +129 -152
  227. package/dist/services/deliveryAdmission.js.map +7 -1
  228. package/dist/services/deliveryHealthService.js +197 -199
  229. package/dist/services/deliveryHealthService.js.map +7 -1
  230. package/dist/services/legacyIssueMigration.js +263 -277
  231. package/dist/services/legacyIssueMigration.js.map +7 -1
  232. package/dist/services/worktreeRegistry.d.ts +27 -119
  233. package/dist/services/worktreeRegistry.js +765 -1182
  234. package/dist/services/worktreeRegistry.js.map +7 -1
  235. package/dist/stagedChecks.test.js +396 -194
  236. package/dist/stagedChecks.test.js.map +7 -1
  237. package/dist/start.test.js +99 -95
  238. package/dist/start.test.js.map +7 -1
  239. package/dist/stdoutRegression.test.js +354 -350
  240. package/dist/stdoutRegression.test.js.map +7 -1
  241. package/dist/targetPolicyDiscovery.test.js +141 -143
  242. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  243. package/dist/targetPolicyEntrypoints.test.js +308 -269
  244. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  245. package/dist/targetPolicyLocal.test.js +580 -1051
  246. package/dist/targetPolicyLocal.test.js.map +7 -1
  247. package/dist/targetPolicyRoutes.test.js +305 -281
  248. package/dist/targetPolicyRoutes.test.js.map +7 -1
  249. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  250. package/dist/targetRepositoryExecution.test.js +463 -0
  251. package/dist/targetRepositoryExecution.test.js.map +7 -0
  252. package/dist/terminalMessages.js +41 -35
  253. package/dist/terminalMessages.js.map +7 -1
  254. package/dist/toolOutput.d.ts +2 -0
  255. package/dist/toolOutput.js +36 -0
  256. package/dist/toolOutput.js.map +7 -0
  257. package/dist/toolOutput.test.d.ts +1 -0
  258. package/dist/toolOutput.test.js +240 -0
  259. package/dist/toolOutput.test.js.map +7 -0
  260. package/dist/utils/atomicJson.js +84 -76
  261. package/dist/utils/atomicJson.js.map +7 -1
  262. package/dist/utils/filesystem.js +15 -18
  263. package/dist/utils/filesystem.js.map +7 -1
  264. package/dist/utils/lockfile.js +68 -71
  265. package/dist/utils/lockfile.js.map +7 -1
  266. package/dist/verification.d.ts +1 -19
  267. package/dist/verification.js +1020 -1929
  268. package/dist/verification.js.map +7 -1
  269. package/dist/verificationGate.test.js +127 -117
  270. package/dist/verificationGate.test.js.map +7 -1
  271. package/dist/version.d.ts +6 -0
  272. package/dist/version.js +24 -10
  273. package/dist/version.js.map +7 -1
  274. package/dist/worktree.d.ts +3 -15
  275. package/dist/worktree.js +97 -177
  276. package/dist/worktree.js.map +7 -1
  277. package/package.json +10 -8
  278. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  279. package/plugins/ai-delivery/README.md +47 -156
  280. package/plugins/ai-delivery/plugin.json +1 -1
  281. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +261 -43
  282. package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
  283. package/plugins/ai-delivery/runtime/package.json +1 -1
  284. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  285. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  286. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  287. package/dist/investigationCompletion.test.js +0 -728
  288. package/dist/investigationCompletion.test.js.map +0 -1
  289. package/dist/setup.d.ts +0 -60
  290. package/dist/setup.js +0 -585
  291. package/dist/setup.js.map +0 -1
  292. package/dist/setup.test.js +0 -3058
  293. package/dist/setup.test.js.map +0 -1
  294. package/dist/worktreeTransition.d.ts +0 -211
  295. package/dist/worktreeTransition.js +0 -1037
  296. package/dist/worktreeTransition.js.map +0 -1
  297. package/dist/worktreeTransition.test.js +0 -1191
  298. package/dist/worktreeTransition.test.js.map +0 -1
  299. /package/dist/{investigationCompletion.test.d.ts → boardReconcile.test.d.ts} +0 -0
  300. /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
  301. /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
@@ -1,313 +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('CLI version agrees with its adjacent package independently of caller cwd', () => {
10
- const metadata = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
11
- assert.ok(typeof metadata === 'object' && metadata !== null && 'version' in metadata);
12
- assert.equal(typeof metadata.version, 'string');
13
- const cli = join(process.cwd(), 'dist', 'cli.js');
14
- const caller = mkdtempSync(join(tmpdir(), 'ai-delivery-version-caller-'));
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)};
27
+ mock.module(${JSON.stringify(dispatch)}, { exports: {
28
+ contextFor: () => { throw new Error('Unexpected configuration access'); },
29
+ executeTool: async (name, input) => { assert.equal(name, 'issue_update'); assert.equal(input.issueNumber, 17); throw new IssueUpdateIncompleteError(${JSON.stringify(partial)}); }
30
+ }});
31
+ process.argv = [process.execPath, ${JSON.stringify(cli)}, '--repo', 'example/widget', 'update', '--issue', '17', '--state', 'closed', '--close-reason', 'completed'];
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, "");
39
+ });
40
+ test.each([
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
+ );
69
+ assert.equal(result.status, exit);
70
+ assert.deepEqual(JSON.parse(result.stdout), value);
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");
15
80
  try {
16
- writeFileSync(join(caller, 'package.json'), JSON.stringify({ name: 'unrelated-caller', version: '9.9.9' }));
17
- const result = spawnSync(process.execPath, [cli, '--version'], { cwd: caller, encoding: 'utf8' });
18
- assert.equal(result.status, 0);
19
- assert.equal(result.stderr, '');
20
- assert.equal(result.stdout.trim(), metadata.version);
21
- const versionModule = pathToFileURL(join(process.cwd(), 'dist', 'version.js')).href;
22
- const shared = spawnSync(process.execPath, [
23
- '--input-type=module',
24
- '-e',
25
- `import { PACKAGE_VERSION } from ${JSON.stringify(versionModule)}; console.log(PACKAGE_VERSION);`,
26
- ], { cwd: caller, encoding: 'utf8' });
27
- assert.equal(shared.status, 0, shared.stderr);
28
- assert.equal(shared.stderr, '');
29
- assert.equal(shared.stdout.trim(), metadata.version);
30
- }
31
- finally {
32
- rmSync(caller, { 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 });
33
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
+ }
34
142
  });
35
- test('CLI preserves recoverable start JSON and exits nonzero after creation failure', () => {
36
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
37
- const failure = {
38
- schemaVersion: 'ai-delivery.issue-start-registration@1',
39
- status: 'created-not-started',
40
- createdIssue: { number: 17 },
41
- };
42
- const code = `import { printCommandResult } from ${JSON.stringify(helper)};` +
43
- `printCommandResult('issue_start', ${JSON.stringify(failure)});`;
44
- const result = spawnSync(process.execPath, ['--input-type=module', '-e', code], { encoding: 'utf8' });
45
- assert.equal(result.status, 1);
46
- assert.deepEqual(JSON.parse(result.stdout), failure);
47
- assert.equal(result.stderr, '');
48
- const ordinary = spawnSync(process.execPath, [
49
- '--input-type=module',
50
- '-e',
51
- `import { printCommandResult } from ${JSON.stringify(helper)};` +
52
- `printCommandResult('issue_start', {status:'started'});`,
53
- ], { encoding: 'utf8' });
54
- assert.equal(ordinary.status, 0);
55
- const parsed = JSON.parse(ordinary.stdout);
56
- assert.ok(parsed !== null && typeof parsed === 'object' && 'status' in parsed);
57
- assert.equal(parsed.status, 'started');
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");
58
168
  });
59
- test('CLI known-issue incomplete start preserves recovery JSON and exits nonzero', () => {
60
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
61
- const failure = {
62
- status: 'start-incomplete',
63
- issueNumber: 17,
64
- repository: 'example/widget',
65
- failure: { phase: 'project-status', message: 'Readback failed' },
66
- safeResume: { tool: 'issue_start', arguments: { repo: 'example/widget', issueNumber: 17, branch: 'issue/17' } },
67
- };
68
- const result = spawnSync(process.execPath, [
69
- '--input-type=module',
70
- '-e',
71
- `import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('issue_start', ${JSON.stringify(failure)});`,
72
- ], { encoding: 'utf8' });
73
- assert.equal(result.status, 1);
74
- assert.deepEqual(JSON.parse(result.stdout), failure);
75
- assert.equal(result.stderr, '');
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, "");
76
190
  });
77
- test('the extracted real CLI error renderer preserves ordinary refusal, exit and stdout', () => {
78
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
79
- const result = spawnSync(process.execPath, [
80
- '--input-type=module',
81
- '-e',
82
- `import { printCommandError } from ${JSON.stringify(helper)}; printCommandError(new Error('ordinary refusal'));`,
83
- ], { encoding: 'utf8' });
84
- assert.equal(result.status, 1);
85
- assert.equal(result.stdout, '');
86
- assert.equal(result.stderr, 'ai-delivery: ordinary refusal\n');
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");
87
205
  });
88
- test('machine diagnostics are immutable identity-bound data and do not change error serialization', () => {
89
- const error = new DeliveryError('safe refusal');
90
- Object.assign(error, { status: 503 });
91
- const before = JSON.stringify(error);
92
- const input = {
93
- phase: 'rest.request',
94
- endpoint: 'pulls.merge',
95
- status: 503,
96
- code: 'ECONNRESET',
97
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
98
- };
99
- setMachineRequestDiagnostics(error, input);
100
- const diagnostic = getMachineRequestDiagnostics(error);
101
- assert.deepEqual(diagnostic, {
102
- phase: 'rest.request',
103
- endpoint: 'pulls.merge',
104
- status: 503,
105
- code: 'ECONNRESET',
106
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
107
- });
108
- assert.ok(diagnostic && Object.isFrozen(diagnostic));
109
- input.status = 401;
110
- assert.equal(Reflect.set(diagnostic, 'status', 401), false);
111
- setMachineRequestDiagnostics(error, input);
112
- assert.equal(getMachineRequestDiagnostics(error)?.status, 503);
113
- assert.equal(JSON.stringify(error), before);
114
- assert.equal(getMachineRequestDiagnostics(new Error('ordinary refusal')), undefined);
115
- assert.equal(getMachineRequestDiagnostics({ name: 'DeliveryError', status: 503, diagnostic }), undefined);
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);
116
234
  });
117
- test('invalid machine metadata remains UNKNOWN without getter or coercion execution', () => {
118
- const invalidStatuses = [
119
- undefined,
120
- null,
121
- NaN,
122
- Infinity,
123
- -Infinity,
124
- 99,
125
- 600,
126
- 401.5,
127
- '403',
128
- {},
129
- [],
130
- Symbol('private'),
131
- ];
132
- for (const status of invalidStatuses) {
133
- const error = new DeliveryError('safe refusal');
134
- setMachineRequestDiagnostics(error, {
135
- phase: 'private-phase',
136
- endpoint: 'https://private.invalid/token',
137
- status,
138
- code: 'private-code',
139
- requestId: 'ghp_fictional_private_token',
140
- });
141
- assert.deepEqual(getMachineRequestDiagnostics(error), {
142
- phase: 'UNKNOWN',
143
- endpoint: 'UNKNOWN',
144
- status: 'UNKNOWN',
145
- code: 'UNKNOWN',
146
- requestId: 'UNKNOWN',
147
- });
148
- assert.equal(JSON.stringify(error).includes('private'), false);
149
- }
150
- let invoked = 0;
151
- const input = {
152
- phase: 'rest.request',
153
- endpoint: 'pulls.merge',
154
- status: 500,
155
- code: 'ECONNRESET',
156
- requestId: 'ABCD:1234:5678:9ABC:DEF0',
157
- };
158
- for (const key of Object.keys(input))
159
- Object.defineProperty(input, key, {
160
- get() {
161
- invoked++;
162
- throw new Error('private getter');
163
- },
164
- });
165
- const error = new DeliveryError('safe refusal');
166
- setMachineRequestDiagnostics(error, input);
167
- assert.equal(invoked, 0);
168
- assert.deepEqual(getMachineRequestDiagnostics(error), {
169
- phase: 'UNKNOWN',
170
- endpoint: 'UNKNOWN',
171
- status: 'UNKNOWN',
172
- code: 'UNKNOWN',
173
- requestId: 'UNKNOWN',
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"
174
258
  });
175
- const proxy = new Proxy(input, {
176
- getOwnPropertyDescriptor() {
177
- invoked++;
178
- throw new Error('private trap');
179
- },
180
- get() {
181
- invoked++;
182
- throw new Error('private trap');
183
- },
259
+ assert.deepEqual(getMachineRequestDiagnostics(error2), {
260
+ phase: "UNKNOWN",
261
+ endpoint: "UNKNOWN",
262
+ status: "UNKNOWN",
263
+ code: "UNKNOWN",
264
+ requestId: "UNKNOWN"
184
265
  });
185
- const proxyError = new DeliveryError('safe refusal');
186
- setMachineRequestDiagnostics(proxyError, proxy);
187
- assert.deepEqual(getMachineRequestDiagnostics(proxyError), getMachineRequestDiagnostics(error));
188
- assert.equal(getMachineRequestDiagnostics(proxy), undefined);
189
- assert.equal(invoked, 0);
190
- });
191
- test('request identifiers and transport codes reject oversized, control and private-looking values', () => {
192
- const requestIds = [
193
- undefined,
194
- null,
195
- {},
196
- [],
197
- 'ABCD:1234:5678',
198
- 'ABCD:1234:5678:9ABC:DEF0\r\n',
199
- 'ABCD:1234:5678:9ABC:\u001b',
200
- 'ABCD:1234:5678:9ABC:秘密',
201
- '/private/credential.pem',
202
- 'Bearer fictional_private_token',
203
- `ABCD:${'A'.repeat(31)}:${'B'.repeat(30)}:${'C'.repeat(30)}:${'D'.repeat(30)}`,
204
- ];
205
- for (const requestId of requestIds) {
206
- const error = new DeliveryError('safe refusal');
207
- setMachineRequestDiagnostics(error, {
208
- phase: 'rest.request',
209
- endpoint: 'pulls.merge',
210
- status: 500,
211
- code: 'ECONNRESET\n',
212
- requestId,
213
- });
214
- assert.equal(getMachineRequestDiagnostics(error)?.requestId, 'UNKNOWN');
215
- assert.equal(getMachineRequestDiagnostics(error)?.code, 'UNKNOWN');
216
- }
217
- for (const code of [
218
- 'ECONNRESET',
219
- 'ECONNREFUSED',
220
- 'ENOTFOUND',
221
- 'EAI_AGAIN',
222
- 'ETIMEDOUT',
223
- 'ABORT_ERR',
224
- 'UND_ERR_CONNECT_TIMEOUT',
225
- 'UND_ERR_SOCKET',
226
- ]) {
227
- const error = new DeliveryError('safe refusal');
228
- setMachineRequestDiagnostics(error, {
229
- phase: 'graphql.request',
230
- endpoint: 'graphql',
231
- status: undefined,
232
- code,
233
- requestId: undefined,
234
- });
235
- assert.equal(getMachineRequestDiagnostics(error)?.code, code);
236
- assert.equal(getMachineRequestDiagnostics(error)?.status, 'UNKNOWN');
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
+ }
282
+ });
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");
237
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);
308
+ });
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
+ }
238
356
  });
239
- test('the real CLI renderer bounds diagnostics and leaves the unchanged refusal line last', () => {
240
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
241
- const errors = pathToFileURL(join(process.cwd(), 'dist', 'errors.js')).href;
242
- const requestId = `ABCD:${'A'.repeat(30)}:${'B'.repeat(30)}:${'C'.repeat(30)}:${'D'.repeat(30)}`;
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)}`;
243
364
  assert.equal(requestId.length, 128);
244
- 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);`;
245
- 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" });
246
367
  assert.equal(result.status, 1);
247
- assert.equal(result.stdout, '');
248
- assert.equal(result.stderr.includes('fictional_private_hint'), false);
249
- assert.ok(Buffer.byteLength(result.stderr.split('\n')[0] + '\n') <= 512);
250
- 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);
251
405
  });
252
- test('CLI batch partial failure prints every result before returning nonzero', () => {
253
- const helper = pathToFileURL(join(process.cwd(), 'dist', 'cliResult.js')).href;
254
- const partial = {
255
- results: [
256
- { issueNumber: 1, status: 'applied' },
257
- { issueNumber: 2, status: 'failed', reason: 'Native readback unavailable' },
258
- ],
259
- summary: { failed: 1 },
260
- };
261
- const result = spawnSync(process.execPath, [
262
- '--input-type=module',
263
- '-e',
264
- `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',${JSON.stringify(partial)});`,
265
- ], { 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
+ );
266
428
  assert.equal(result.status, 1);
267
- assert.deepEqual(JSON.parse(result.stdout), partial);
268
- assert.equal(result.stderr, '');
269
- const success = spawnSync(process.execPath, [
270
- '--input-type=module',
271
- '-e',
272
- `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',{summary:{failed:0}});`,
273
- ], { encoding: 'utf8' });
274
- assert.equal(success.status, 0);
275
- });
276
- test('actual CLI batch input validates before configuration or native access', () => {
277
- const root = mkdtempSync(join(tmpdir(), 'batch-cli-refusal-'));
278
- try {
279
- const file = join(root, 'items.json');
280
- writeFileSync(file, '[]');
281
- const result = spawnSync(process.execPath, [
282
- join(process.cwd(), 'dist', 'cli.js'),
283
- '--repo',
284
- 'example/widget',
285
- 'batch:update',
286
- '--items-file',
287
- file,
288
- '--dry-run',
289
- ], {
290
- cwd: root,
291
- encoding: 'utf8',
292
- env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
293
- });
294
- assert.equal(result.status, 1);
295
- assert.equal(result.stdout, '');
296
- assert.doesNotMatch(result.stderr, /absent-settings|credential|token/iu);
297
- const diagnostic = JSON.parse(result.stderr.replace(/^ai-delivery: /u, '').trim());
298
- assert.equal(diagnostic.failures[0].field, 'items');
299
- assert.equal(diagnostic.failures[0].code, 'field.type');
300
- writeFileSync(file, JSON.stringify([{ issueNumber: 1, PRIVATE_PROPERTY: 'PRIVATE_VALUE' }]));
301
- const privateInput = spawnSync(process.execPath, [join(process.cwd(), 'dist', 'cli.js'), '--repo', 'example/widget', 'batch:update', '--items-file', file], {
302
- cwd: root,
303
- encoding: 'utf8',
304
- env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
305
- });
306
- assert.equal(privateInput.status, 1);
307
- assert.doesNotMatch(privateInput.stderr, /PRIVATE_PROPERTY|PRIVATE_VALUE|absent-settings/u);
308
- }
309
- finally {
310
- rmSync(root, { recursive: true, force: true });
311
- }
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
+ }
312
449
  });
313
- //# sourceMappingURL=cliResult.test.js.map
450
+ //# sourceMappingURL=cliResult.test.js.map