@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,228 +1,430 @@
1
- import assert from 'node:assert/strict';
2
- import { execFileSync } from 'node:child_process';
3
- import { createHash } from 'node:crypto';
4
- import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync, } from 'node:fs';
5
- import { tmpdir } from 'node:os';
6
- import { join, resolve } from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
- import { test } from 'vitest';
9
- const staged = (await import(new URL('../scripts/pre-commit.mjs', import.meta.url).href));
10
- const hash = (bytes) => createHash('sha256').update(bytes).digest('hex');
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import {
5
+ chmodSync,
6
+ copyFileSync,
7
+ existsSync,
8
+ mkdirSync,
9
+ mkdtempSync,
10
+ readFileSync,
11
+ rmSync,
12
+ symlinkSync,
13
+ writeFileSync
14
+ } from "node:fs";
15
+ import { tmpdir } from "node:os";
16
+ import { join, resolve } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+ import { test } from "vitest";
19
+ const staged = await import(new URL("../scripts/pre-commit.mjs", import.meta.url).href);
20
+ const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
11
21
  function fixture(runner) {
12
- const base = mkdtempSync(join(tmpdir(), 'staged-check-fixture-'));
13
- const cwd = join(base, 'repo');
14
- mkdirSync(join(cwd, 'scripts'), { recursive: true });
15
- const git = (...args) => execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();
16
- git('init', '-q');
17
- git('config', 'user.name', 'Synthetic Contributor');
18
- git('config', 'user.email', 'contributor@example.test');
19
- writeFileSync(join(cwd, 'partial.txt'), 'original\n');
20
- writeFileSync(join(cwd, 'delete.txt'), 'tracked deletion\n');
21
- writeFileSync(join(cwd, 'package-lock.json'), '{"synthetic":"original"}\n');
22
- if (runner !== undefined)
23
- writeFileSync(join(cwd, 'scripts/checks.mjs'), runner);
24
- git('add', '.');
25
- git('commit', '-qm', 'Synthetic baseline');
26
- return { cwd, base, git, cleanup: () => rmSync(base, { recursive: true, force: true }) };
22
+ const base = mkdtempSync(join(tmpdir(), "staged-check-fixture-"));
23
+ const cwd = join(base, "repo");
24
+ mkdirSync(join(cwd, "scripts"), { recursive: true });
25
+ const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8" }).trim();
26
+ git("init", "-q");
27
+ git("config", "user.name", "Synthetic Contributor");
28
+ git("config", "user.email", "contributor@example.test");
29
+ writeFileSync(join(cwd, "partial.txt"), "original\n");
30
+ writeFileSync(join(cwd, "delete.txt"), "tracked deletion\n");
31
+ writeFileSync(join(cwd, ".gitignore"), "/node_modules/\n/dist/\n");
32
+ const manifest = { name: "staged-fixture", version: "1.0.0", dependencies: { "fixture-dependency": "1.0.0" } };
33
+ const packages = {
34
+ "": manifest,
35
+ "node_modules/fixture-dependency": { version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } },
36
+ "node_modules/fixture-transitive": { version: "1.0.0" }
37
+ };
38
+ writeFileSync(join(cwd, "package.json"), JSON.stringify(manifest));
39
+ writeFileSync(
40
+ join(cwd, "package-lock.json"),
41
+ JSON.stringify({ lockfileVersion: 3, synthetic: "original", packages })
42
+ );
43
+ mkdirSync(join(cwd, "src"));
44
+ writeFileSync(join(cwd, "src/selected.test.ts"), "// selected synthetic contract\n");
45
+ mkdirSync(join(cwd, "node_modules/fixture-dependency"), { recursive: true });
46
+ writeFileSync(
47
+ join(cwd, "node_modules/fixture-dependency/package.json"),
48
+ JSON.stringify({ name: "fixture-dependency", version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } })
49
+ );
50
+ writeFileSync(
51
+ join(cwd, "node_modules/.package-lock.json"),
52
+ JSON.stringify({
53
+ lockfileVersion: 3,
54
+ packages: {
55
+ "node_modules/fixture-dependency": { version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } },
56
+ "node_modules/fixture-transitive": { version: "1.0.0" }
57
+ }
58
+ })
59
+ );
60
+ mkdirSync(join(cwd, "node_modules/fixture-transitive"));
61
+ writeFileSync(
62
+ join(cwd, "node_modules/fixture-transitive/package.json"),
63
+ JSON.stringify({ name: "fixture-transitive", version: "1.0.0" })
64
+ );
65
+ if (runner !== void 0) writeFileSync(join(cwd, "scripts/checks.mjs"), runner);
66
+ git("add", ".");
67
+ git("commit", "-qm", "Synthetic baseline");
68
+ return { cwd, base, git, cleanup: () => rmSync(base, { recursive: true, force: true }) };
27
69
  }
28
- test('exact staged tree isolates partial edits, additions, deletions and lockfile changes without index/unstaged writes', () => {
70
+ test(
71
+ "exact staged tree isolates partial edits, additions, deletions and lockfile changes without index/unstaged writes",
72
+ { tags: ["release"] },
73
+ () => {
29
74
  const f = fixture();
30
75
  try {
31
- writeFileSync(join(f.cwd, 'partial.txt'), 'staged content\n');
32
- writeFileSync(join(f.cwd, 'added.txt'), 'staged addition\n');
33
- writeFileSync(join(f.cwd, 'package-lock.json'), '{"synthetic":"staged lock"}\n');
34
- f.git('rm', '-q', 'delete.txt');
35
- f.git('add', 'partial.txt', 'added.txt', 'package-lock.json');
36
- writeFileSync(join(f.cwd, 'partial.txt'), 'unstaged content must survive\n');
37
- writeFileSync(join(f.cwd, 'package-lock.json'), '{"synthetic":"unstaged lock"}\n');
38
- writeFileSync(join(f.cwd, 'delete.txt'), 'unstaged recreated file\n');
39
- writeFileSync(join(f.cwd, 'untracked.txt'), 'unrelated local file\n');
40
- const index = join(f.cwd, '.git/index');
41
- const before = hash(readFileSync(index));
42
- const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, 'snapshot-owner'));
43
- assert.equal(readFileSync(join(snapshot.snapshot, 'partial.txt'), 'utf8'), 'staged content\n');
44
- assert.equal(readFileSync(join(snapshot.snapshot, 'added.txt'), 'utf8'), 'staged addition\n');
45
- assert.equal(readFileSync(join(snapshot.snapshot, 'package-lock.json'), 'utf8'), '{"synthetic":"staged lock"}\n');
46
- assert.equal(existsSync(join(snapshot.snapshot, 'delete.txt')), false);
47
- assert.equal(existsSync(join(snapshot.snapshot, 'untracked.txt')), false);
48
- assert.equal(snapshot.originalIndexSha256, before);
49
- assert.equal(hash(readFileSync(index)), before);
50
- assert.equal(readFileSync(join(f.cwd, 'partial.txt'), 'utf8'), 'unstaged content must survive\n');
51
- assert.equal(readFileSync(join(f.cwd, 'package-lock.json'), 'utf8'), '{"synthetic":"unstaged lock"}\n');
52
- assert.equal(readFileSync(join(f.cwd, 'delete.txt'), 'utf8'), 'unstaged recreated file\n');
53
- assert.equal(readFileSync(join(f.cwd, 'untracked.txt'), 'utf8'), 'unrelated local file\n');
54
- assert.match(snapshot.tree, /^[0-9a-f]{40}$/u);
76
+ writeFileSync(join(f.cwd, "partial.txt"), "staged content\n");
77
+ writeFileSync(join(f.cwd, "added.txt"), "staged addition\n");
78
+ writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"staged lock"}\n');
79
+ f.git("rm", "-q", "delete.txt");
80
+ f.git("add", "partial.txt", "added.txt", "package-lock.json");
81
+ writeFileSync(join(f.cwd, "partial.txt"), "unstaged content must survive\n");
82
+ writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"unstaged lock"}\n');
83
+ writeFileSync(join(f.cwd, "delete.txt"), "unstaged recreated file\n");
84
+ writeFileSync(join(f.cwd, "untracked.txt"), "unrelated local file\n");
85
+ const index = join(f.cwd, ".git/index");
86
+ const before = hash(readFileSync(index));
87
+ const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, "snapshot-owner"));
88
+ assert.equal(readFileSync(join(snapshot.snapshot, "partial.txt"), "utf8"), "staged content\n");
89
+ assert.equal(readFileSync(join(snapshot.snapshot, "added.txt"), "utf8"), "staged addition\n");
90
+ assert.equal(readFileSync(join(snapshot.snapshot, "package-lock.json"), "utf8"), '{"synthetic":"staged lock"}\n');
91
+ assert.equal(existsSync(join(snapshot.snapshot, "delete.txt")), false);
92
+ assert.equal(existsSync(join(snapshot.snapshot, "untracked.txt")), false);
93
+ assert.equal(snapshot.originalIndexSha256, before);
94
+ assert.equal(hash(readFileSync(index)), before);
95
+ assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "unstaged content must survive\n");
96
+ assert.equal(readFileSync(join(f.cwd, "package-lock.json"), "utf8"), '{"synthetic":"unstaged lock"}\n');
97
+ assert.equal(readFileSync(join(f.cwd, "delete.txt"), "utf8"), "unstaged recreated file\n");
98
+ assert.equal(readFileSync(join(f.cwd, "untracked.txt"), "utf8"), "unrelated local file\n");
99
+ assert.match(snapshot.tree, /^[0-9a-f]{40}$/u);
100
+ } finally {
101
+ f.cleanup();
55
102
  }
56
- finally {
57
- f.cleanup();
58
- }
59
- });
60
- function syntheticRunner(fullSuccess = true) {
61
- return `import fs from 'node:fs';import path from 'node:path';
103
+ }
104
+ );
105
+ function syntheticRunner(focused = true) {
106
+ return `import fs from 'node:fs';import path from 'node:path';
62
107
  const args=process.argv.slice(2);const tree=args[args.indexOf('--staged-tree')+1],dir=args[args.indexOf('--results-dir')+1];
63
- if(!args.includes('--install'))process.exit(8);
64
- if(fs.readFileSync('package-lock.json','utf8')!=='{"synthetic":"original"}\\n')process.exit(9);
108
+ if(args.includes('--install')||!args.includes('--fast')||!args.includes('--test-file'))process.exit(8);
109
+ if(JSON.parse(fs.readFileSync('package-lock.json','utf8')).synthetic!=='original')process.exit(9);
65
110
  if(process.env.GH_TOKEN||process.env.NODE_OPTIONS||process.env.NODE_PATH)process.exit(10);
66
- fs.mkdirSync(dir,{recursive:true});fs.writeFileSync(path.join(dir,'result.json'),JSON.stringify({fullSuccess:${fullSuccess},tree:{stagedGitTree:tree}}));`;
111
+ fs.mkdirSync('node_modules/.vite',{recursive:true});fs.writeFileSync('node_modules/.vite/owned-cache','synthetic cache');
112
+ fs.mkdirSync(dir,{recursive:true});fs.writeFileSync(path.join(dir,'result.json'),JSON.stringify({scope:'${focused ? "focused" : "fast"}',status:'partial-passed',fullSuccess:false,artifactQualified:false,selectedTestFiles:['dist/selected.test.js'],tests:{files:1,total:1,passed:1},tree:{stagedGitTree:tree}}));`;
67
113
  }
68
- test('tracked entry executes staged runner rather than unstaged code and cleans only owned snapshot', async () => {
114
+ test(
115
+ "missing explicit hook selection refuses before validation without provisioning dependencies",
116
+ { tags: ["release"] },
117
+ async () => {
69
118
  const f = fixture(syntheticRunner());
70
119
  try {
71
- writeFileSync(join(f.cwd, 'scripts/checks.mjs'), "throw Error('Unstaged runner must not execute');\n");
72
- writeFileSync(join(f.cwd, 'package-lock.json'), '{"synthetic":"unstaged must not install"}\n');
73
- const index = hash(readFileSync(join(f.cwd, '.git/index')));
74
- const resultsDir = join(f.base, 'results');
75
- const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir });
76
- assert.equal(result.status, 'passed');
77
- assert.equal(result.fullSuccess, true);
78
- assert.equal(result.sourceIndexUnchanged, true);
79
- assert.equal(result.cleanupConfirmed, true);
80
- assert.equal(existsSync(result.ownedDirectory), false);
81
- assert.equal(existsSync(join(resultsDir, 'full/result.json')), true);
82
- assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), index);
83
- assert.match(readFileSync(join(f.cwd, 'scripts/checks.mjs'), 'utf8'), /Unstaged runner/u);
84
- assert.match(readFileSync(join(f.cwd, 'package-lock.json'), 'utf8'), /unstaged must not install/u);
85
- await assert.rejects(staged.runStagedChecks({ cwd: f.cwd, resultsDir }), /Existing staged result/u);
120
+ const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir: join(f.base, "missing-selection") });
121
+ assert.equal(result.status, "failed");
122
+ assert.match(result.error, /explicit.*selection/iu);
123
+ assert.equal(result.cleanupConfirmed, true);
124
+ } finally {
125
+ f.cleanup();
86
126
  }
87
- finally {
127
+ }
128
+ );
129
+ test(
130
+ "staged dependency incompatibility refuses instead of installing or accepting different package versions",
131
+ { tags: ["release"] },
132
+ async () => {
133
+ for (const scenario of [
134
+ "version",
135
+ "package-version",
136
+ "missing",
137
+ "missing-transitive",
138
+ "missing-metadata-entry",
139
+ "staged-manifest"
140
+ ]) {
141
+ const f = fixture(syntheticRunner());
142
+ try {
143
+ const metadata = join(f.cwd, "node_modules/.package-lock.json");
144
+ if (scenario === "missing") rmSync(join(f.cwd, "node_modules"), { recursive: true });
145
+ else if (scenario === "missing-transitive")
146
+ rmSync(join(f.cwd, "node_modules/fixture-transitive"), { recursive: true });
147
+ else if (scenario === "package-version")
148
+ writeFileSync(
149
+ join(f.cwd, "node_modules/fixture-transitive/package.json"),
150
+ JSON.stringify({ name: "fixture-transitive", version: "2.0.0" })
151
+ );
152
+ else if (scenario === "staged-manifest") {
153
+ writeFileSync(
154
+ join(f.cwd, "package.json"),
155
+ JSON.stringify({
156
+ name: "staged-fixture",
157
+ version: "1.0.0",
158
+ dependencies: { "fixture-dependency": "2.0.0" }
159
+ })
160
+ );
161
+ f.git("add", "package.json");
162
+ } else
163
+ writeFileSync(
164
+ metadata,
165
+ JSON.stringify({
166
+ lockfileVersion: 3,
167
+ packages: { "node_modules/fixture-dependency": { version: scenario === "version" ? "2.0.0" : "1.0.0" } }
168
+ })
169
+ );
170
+ const result = await staged.runStagedChecks({
171
+ cwd: f.cwd,
172
+ resultsDir: join(f.base, "incompatible"),
173
+ testFiles: ["dist/selected.test.js"]
174
+ });
175
+ assert.equal(result.status, "failed");
176
+ assert.match(result.error, /dependenc|compatible|setup/iu);
177
+ assert.equal(result.cleanupConfirmed, true);
178
+ assert.equal(result.sourceIndexUnchanged, true);
179
+ } finally {
88
180
  f.cleanup();
181
+ }
89
182
  }
90
- });
91
- test('fast or missing staged runner cannot become hook full success; unrelated source survives failure', async () => {
92
- for (const runner of [undefined, syntheticRunner(false)]) {
93
- const f = fixture(runner);
94
- try {
95
- const before = hash(readFileSync(join(f.cwd, '.git/index')));
96
- const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir: join(f.base, 'result') });
97
- assert.equal(result.fullSuccess, false);
98
- assert.equal(result.status, 'failed');
99
- assert.equal(result.cleanupConfirmed, true);
100
- assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), before);
101
- assert.equal(readFileSync(join(f.cwd, 'partial.txt'), 'utf8'), 'original\n');
102
- }
103
- finally {
104
- f.cleanup();
105
- }
183
+ }
184
+ );
185
+ test(
186
+ "observable installed dependency metadata drift cannot become successful hook evidence",
187
+ { tags: ["release"] },
188
+ async () => {
189
+ for (const changedMetadata of [".package-lock.json", "fixture-transitive/package.json"]) {
190
+ const f = fixture(syntheticRunner());
191
+ try {
192
+ const result = await staged.runStagedChecks({
193
+ cwd: f.cwd,
194
+ resultsDir: join(f.base, "drift"),
195
+ testFiles: ["dist/selected.test.js"],
196
+ execute: async () => {
197
+ const metadata = join(f.cwd, "node_modules", changedMetadata);
198
+ writeFileSync(metadata, readFileSync(metadata, "utf8") + "\n");
199
+ return { status: "passed", cleanupConfirmed: true };
200
+ }
201
+ });
202
+ assert.equal(result.status, "failed");
203
+ assert.match(result.error, /dependenc.*(changed|drift)/iu);
204
+ assert.equal(result.cleanupConfirmed, true);
205
+ } finally {
206
+ f.cleanup();
207
+ }
106
208
  }
107
- });
108
- test('unsafe staged symlink is refused before commands and cleanup preserves the source index', async () => {
209
+ }
210
+ );
211
+ test(
212
+ "tracked entry reuses transitive dependencies with staged code and cleans only owned snapshot",
213
+ { tags: ["release"] },
214
+ async () => {
109
215
  const f = fixture(syntheticRunner());
110
216
  try {
111
- symlinkSync('../outside', join(f.cwd, 'link'));
112
- f.git('add', 'link');
113
- const before = hash(readFileSync(join(f.cwd, '.git/index')));
114
- const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir: join(f.base, 'result') });
115
- assert.equal(result.status, 'failed');
116
- assert.match(result.error, /symlink index entry/u);
117
- assert.equal(result.cleanupConfirmed, true);
118
- assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), before);
217
+ writeFileSync(join(f.cwd, "scripts/checks.mjs"), "throw Error('Unstaged runner must not execute');\n");
218
+ writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"unstaged must not install"}\n');
219
+ writeFileSync(
220
+ join(f.cwd, "package.json"),
221
+ JSON.stringify({
222
+ name: "staged-fixture",
223
+ version: "1.0.0",
224
+ dependencies: { "fixture-dependency": "1.0.0" },
225
+ description: "unstaged manifest must survive"
226
+ })
227
+ );
228
+ const index = hash(readFileSync(join(f.cwd, ".git/index")));
229
+ const resultsDir = join(f.base, "results");
230
+ const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir, testFiles: ["dist/selected.test.js"] });
231
+ assert.equal(result.status, "partial-passed");
232
+ assert.equal(result.fullSuccess, false);
233
+ assert.equal(result.sourceIndexUnchanged, true);
234
+ assert.equal(result.cleanupConfirmed, true);
235
+ assert.equal(existsSync(result.ownedDirectory), false);
236
+ assert.equal(existsSync(join(resultsDir, "focused/result.json")), true);
237
+ assert.equal(existsSync(join(f.cwd, "node_modules/.vite")), false);
238
+ assert.equal(
239
+ JSON.parse(readFileSync(join(f.cwd, "node_modules/fixture-dependency/package.json"), "utf8")).version,
240
+ "1.0.0"
241
+ );
242
+ assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), index);
243
+ assert.match(readFileSync(join(f.cwd, "scripts/checks.mjs"), "utf8"), /Unstaged runner/u);
244
+ assert.match(readFileSync(join(f.cwd, "package-lock.json"), "utf8"), /unstaged must not install/u);
245
+ assert.match(readFileSync(join(f.cwd, "package.json"), "utf8"), /unstaged manifest must survive/u);
246
+ await assert.rejects(staged.runStagedChecks({ cwd: f.cwd, resultsDir }), /Existing staged result/u);
247
+ } finally {
248
+ f.cleanup();
119
249
  }
120
- finally {
250
+ }
251
+ );
252
+ test(
253
+ "fast-only or missing staged runner cannot become focused hook success; unrelated source survives failure",
254
+ { tags: ["release"] },
255
+ async () => {
256
+ for (const runner of [void 0, syntheticRunner(false)]) {
257
+ const f = fixture(runner);
258
+ try {
259
+ const before = hash(readFileSync(join(f.cwd, ".git/index")));
260
+ const result = await staged.runStagedChecks({
261
+ cwd: f.cwd,
262
+ resultsDir: join(f.base, "result"),
263
+ testFiles: ["dist/selected.test.js"]
264
+ });
265
+ assert.equal(result.fullSuccess, false);
266
+ assert.equal(result.status, "failed");
267
+ assert.equal(result.cleanupConfirmed, true);
268
+ assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
269
+ assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "original\n");
270
+ } finally {
121
271
  f.cleanup();
272
+ }
122
273
  }
123
- });
124
- test('staged graph cancellation preserves source and partial evidence after owned child cleanup', async () => {
274
+ }
275
+ );
276
+ test(
277
+ "unsafe staged symlink is refused before commands and cleanup preserves the source index",
278
+ { tags: ["release"] },
279
+ async () => {
280
+ const f = fixture(syntheticRunner());
281
+ try {
282
+ symlinkSync("../outside", join(f.cwd, "link"));
283
+ f.git("add", "link");
284
+ const before = hash(readFileSync(join(f.cwd, ".git/index")));
285
+ const result = await staged.runStagedChecks({
286
+ cwd: f.cwd,
287
+ resultsDir: join(f.base, "result"),
288
+ testFiles: ["dist/selected.test.js"]
289
+ });
290
+ assert.equal(result.status, "failed");
291
+ assert.match(result.error, /symlink index entry/u);
292
+ assert.equal(result.cleanupConfirmed, true);
293
+ assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
294
+ } finally {
295
+ f.cleanup();
296
+ }
297
+ }
298
+ );
299
+ test(
300
+ "staged graph cancellation preserves source and partial evidence after owned child cleanup",
301
+ { tags: ["release"] },
302
+ async () => {
125
303
  const f = fixture("console.log('synthetic staged graph started');setInterval(()=>{},1000);\n");
126
304
  const controller = new AbortController();
127
305
  const timer = setTimeout(() => controller.abort(), 750);
128
306
  try {
129
- const before = hash(readFileSync(join(f.cwd, '.git/index')));
130
- const resultsDir = join(f.base, 'result');
131
- const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir, signal: controller.signal });
132
- assert.equal(result.status, 'cancelled');
133
- assert.equal(result.exitCode, 130);
134
- assert.equal(result.sourceIndexUnchanged, true);
135
- assert.equal(result.cleanupConfirmed, true);
136
- assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), before);
137
- assert.match(readFileSync(join(resultsDir, 'process/stdout.txt'), 'utf8'), /synthetic staged graph started/u);
138
- }
139
- finally {
140
- clearTimeout(timer);
141
- f.cleanup();
307
+ const before = hash(readFileSync(join(f.cwd, ".git/index")));
308
+ const resultsDir = join(f.base, "result");
309
+ const result = await staged.runStagedChecks({
310
+ cwd: f.cwd,
311
+ resultsDir,
312
+ signal: controller.signal,
313
+ testFiles: ["dist/selected.test.js"]
314
+ });
315
+ assert.equal(result.status, "cancelled");
316
+ assert.equal(result.exitCode, 130);
317
+ assert.equal(result.sourceIndexUnchanged, true);
318
+ assert.equal(result.cleanupConfirmed, true);
319
+ assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
320
+ assert.match(readFileSync(join(resultsDir, "process/stdout.txt"), "utf8"), /synthetic staged graph started/u);
321
+ } finally {
322
+ clearTimeout(timer);
323
+ f.cleanup();
142
324
  }
143
- });
144
- test('unconfirmed child completion preserves the owned snapshot and marks cleanup unproved', async () => {
325
+ }
326
+ );
327
+ test(
328
+ "unconfirmed child completion preserves the owned snapshot and marks cleanup unproved",
329
+ { tags: ["release"] },
330
+ async () => {
145
331
  const f = fixture(syntheticRunner());
146
332
  let ownedDirectory;
147
333
  try {
148
- const before = hash(readFileSync(join(f.cwd, '.git/index')));
149
- const result = await staged.runStagedChecks({
150
- cwd: f.cwd,
151
- resultsDir: join(f.base, 'uncertain'),
152
- execute: async () => ({ status: 'failed', cleanupConfirmed: false }),
153
- });
154
- ownedDirectory = result.ownedDirectory;
155
- assert.equal(result.fullSuccess, false);
156
- assert.equal(result.cleanupConfirmed, false);
157
- assert.equal(existsSync(ownedDirectory), true);
158
- assert.match(result.error, /quiescence is unconfirmed/u);
159
- assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), before);
334
+ const before = hash(readFileSync(join(f.cwd, ".git/index")));
335
+ const result = await staged.runStagedChecks({
336
+ cwd: f.cwd,
337
+ resultsDir: join(f.base, "uncertain"),
338
+ testFiles: ["dist/selected.test.js"],
339
+ execute: async () => ({ status: "failed", cleanupConfirmed: false })
340
+ });
341
+ ownedDirectory = result.ownedDirectory;
342
+ assert.equal(result.fullSuccess, false);
343
+ assert.equal(result.cleanupConfirmed, false);
344
+ assert.equal(existsSync(ownedDirectory), true);
345
+ assert.match(result.error, /quiescence is unconfirmed/u);
346
+ assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
347
+ } finally {
348
+ if (ownedDirectory) rmSync(ownedDirectory, { recursive: true, force: true });
349
+ f.cleanup();
160
350
  }
161
- finally {
162
- // The injected executor launched no process; this fixture owns safe cleanup.
163
- if (ownedDirectory)
164
- rmSync(ownedDirectory, { recursive: true, force: true });
165
- f.cleanup();
166
- }
167
- });
168
- test('caller relative alternate index supplies the exact tree and preserves both indexes and unstaged bytes', () => {
351
+ }
352
+ );
353
+ test(
354
+ "caller relative alternate index supplies the exact tree and preserves both indexes and unstaged bytes",
355
+ { tags: ["release"] },
356
+ () => {
169
357
  const f = fixture();
170
358
  const previous = process.env.GIT_INDEX_FILE;
171
359
  try {
172
- const primary = join(f.cwd, '.git/index');
173
- const alternate = join(f.cwd, '.git/alternate-index');
174
- writeFileSync(join(f.cwd, 'partial.txt'), 'primary staged\n');
175
- f.git('add', 'partial.txt');
176
- copyFileSync(primary, alternate);
177
- writeFileSync(join(f.cwd, 'partial.txt'), 'alternate staged\n');
178
- execFileSync('git', ['add', 'partial.txt'], { cwd: f.cwd, env: { ...process.env, GIT_INDEX_FILE: alternate } });
179
- writeFileSync(join(f.cwd, 'partial.txt'), 'final unstaged bytes\n');
180
- const primaryHash = hash(readFileSync(primary)), alternateHash = hash(readFileSync(alternate));
181
- assert.notEqual(primaryHash, alternateHash);
182
- process.env.GIT_INDEX_FILE = '.git/alternate-index';
183
- const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, 'alternate-snapshot'));
184
- assert.equal(snapshot.index, alternate);
185
- assert.equal(snapshot.originalIndexSha256, alternateHash);
186
- assert.equal(readFileSync(join(snapshot.snapshot, 'partial.txt'), 'utf8'), 'alternate staged\n');
187
- assert.equal(hash(readFileSync(primary)), primaryHash);
188
- assert.equal(hash(readFileSync(alternate)), alternateHash);
189
- assert.equal(readFileSync(join(f.cwd, 'partial.txt'), 'utf8'), 'final unstaged bytes\n');
360
+ const primary = join(f.cwd, ".git/index");
361
+ const alternate = join(f.cwd, ".git/alternate-index");
362
+ writeFileSync(join(f.cwd, "partial.txt"), "primary staged\n");
363
+ f.git("add", "partial.txt");
364
+ copyFileSync(primary, alternate);
365
+ writeFileSync(join(f.cwd, "partial.txt"), "alternate staged\n");
366
+ execFileSync("git", ["add", "partial.txt"], { cwd: f.cwd, env: { ...process.env, GIT_INDEX_FILE: alternate } });
367
+ writeFileSync(join(f.cwd, "partial.txt"), "final unstaged bytes\n");
368
+ const primaryHash = hash(readFileSync(primary)), alternateHash = hash(readFileSync(alternate));
369
+ assert.notEqual(primaryHash, alternateHash);
370
+ process.env.GIT_INDEX_FILE = ".git/alternate-index";
371
+ const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, "alternate-snapshot"));
372
+ assert.equal(snapshot.index, alternate);
373
+ assert.equal(snapshot.originalIndexSha256, alternateHash);
374
+ assert.equal(readFileSync(join(snapshot.snapshot, "partial.txt"), "utf8"), "alternate staged\n");
375
+ assert.equal(hash(readFileSync(primary)), primaryHash);
376
+ assert.equal(hash(readFileSync(alternate)), alternateHash);
377
+ assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "final unstaged bytes\n");
378
+ } finally {
379
+ if (previous === void 0) delete process.env.GIT_INDEX_FILE;
380
+ else process.env.GIT_INDEX_FILE = previous;
381
+ f.cleanup();
190
382
  }
191
- finally {
192
- if (previous === undefined)
193
- delete process.env.GIT_INDEX_FILE;
194
- else
195
- process.env.GIT_INDEX_FILE = previous;
196
- f.cleanup();
197
- }
198
- });
199
- test('synthetic commit -a and path-limited hooks validate the Git-supplied temporary commit index', () => {
200
- const entry = fileURLToPath(new URL('../scripts/pre-commit.mjs', import.meta.url));
383
+ }
384
+ );
385
+ test(
386
+ "synthetic commit -a and path-limited hooks validate the Git-supplied temporary commit index",
387
+ { tags: ["release"] },
388
+ () => {
389
+ const entry = fileURLToPath(new URL("../scripts/pre-commit.mjs", import.meta.url));
201
390
  const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
202
- for (const mode of ['all', 'path']) {
203
- const f = fixture(syntheticRunner());
204
- try {
205
- const resultsDir = join(f.base, 'hook-results');
206
- const hook = join(f.cwd, '.git/hooks/pre-commit');
207
- writeFileSync(hook, `#!/bin/sh\nexec ${quote(process.execPath)} ${quote(entry)} --results-dir ${quote(resultsDir)}\n`);
208
- chmodSync(hook, 0o755); // Only this disposable synthetic repository owns the hook.
209
- writeFileSync(join(f.cwd, 'partial.txt'), `${mode} committed content\n`);
210
- if (mode === 'path')
211
- writeFileSync(join(f.cwd, 'delete.txt'), 'unrelated unstaged content\n');
212
- f.git('commit', '-qm', `Synthetic ${mode} commit`, ...(mode === 'all' ? ['-a'] : ['--', 'partial.txt']));
213
- const result = JSON.parse(readFileSync(join(resultsDir, 'staged.json'), 'utf8'));
214
- assert.equal(result.fullSuccess, true);
215
- assert.equal(result.sourceIndexUnchanged, true);
216
- assert.equal(result.cleanupConfirmed, true);
217
- assert.notEqual(resolve(result.sourceIndexPath), join(f.cwd, '.git/index'));
218
- assert.equal(result.stagedTree, f.git('rev-parse', 'HEAD^{tree}'));
219
- assert.equal(f.git('show', 'HEAD:partial.txt'), `${mode} committed content`);
220
- if (mode === 'path')
221
- assert.equal(readFileSync(join(f.cwd, 'delete.txt'), 'utf8'), 'unrelated unstaged content\n');
222
- }
223
- finally {
224
- f.cleanup();
225
- }
391
+ for (const mode of ["all", "path"]) {
392
+ const f = fixture(syntheticRunner());
393
+ try {
394
+ const resultsDir = join(f.base, "hook-results");
395
+ const hook = join(f.cwd, ".git/hooks/pre-commit");
396
+ writeFileSync(
397
+ hook,
398
+ `#!/bin/sh
399
+ exec ${quote(process.execPath)} ${quote(entry)} --results-dir ${quote(resultsDir)}${mode === "path" ? " --test-file dist/selected.test.js" : ""}
400
+ `
401
+ );
402
+ chmodSync(hook, 493);
403
+ writeFileSync(join(f.cwd, "partial.txt"), `${mode} committed content
404
+ `);
405
+ if (mode === "path") writeFileSync(join(f.cwd, "delete.txt"), "unrelated unstaged content\n");
406
+ execFileSync(
407
+ "git",
408
+ ["commit", "-qm", `Synthetic ${mode} commit`, ...mode === "all" ? ["-a"] : ["--", "partial.txt"]],
409
+ {
410
+ cwd: f.cwd,
411
+ env: { ...process.env, AI_DELIVERY_FOCUSED_TESTS: '["dist/selected.test.js"]' }
412
+ }
413
+ );
414
+ const result = JSON.parse(readFileSync(join(resultsDir, "staged.json"), "utf8"));
415
+ assert.equal(result.fullSuccess, false);
416
+ assert.equal(result.status, "partial-passed");
417
+ assert.equal(result.sourceIndexUnchanged, true);
418
+ assert.equal(result.cleanupConfirmed, true);
419
+ assert.notEqual(resolve(result.sourceIndexPath), join(f.cwd, ".git/index"));
420
+ assert.equal(result.stagedTree, f.git("rev-parse", "HEAD^{tree}"));
421
+ assert.equal(f.git("show", "HEAD:partial.txt"), `${mode} committed content`);
422
+ if (mode === "path")
423
+ assert.equal(readFileSync(join(f.cwd, "delete.txt"), "utf8"), "unrelated unstaged content\n");
424
+ } finally {
425
+ f.cleanup();
426
+ }
226
427
  }
227
- });
228
- //# sourceMappingURL=stagedChecks.test.js.map
428
+ }
429
+ );
430
+ //# sourceMappingURL=stagedChecks.test.js.map