@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
package/dist/worktree.js CHANGED
@@ -1,188 +1,108 @@
1
- import { existsSync, lstatSync, realpathSync } from 'node:fs';
2
- import { isAbsolute, join, relative, resolve, sep } from 'node:path';
3
- import { resolveGitRemoteName } from './github/repo.js';
4
- import { DeliveryError } from './errors.js';
5
- import { assertClean, defaultBaseRef, git, gitCommonDir, gitExitCode, gitRoot, primaryGitRoot } from './git.js';
6
- import { assertIssueWorktreeTransitionAdmission, } from './services/worktreeRegistry.js';
1
+ import { existsSync, lstatSync, realpathSync } from "node:fs";
2
+ import { isAbsolute, join, relative, sep } from "node:path";
3
+ import { resolveGitRemoteName } from "./github/repo.js";
4
+ import { DeliveryError } from "./errors.js";
5
+ import { assertClean, defaultBaseRef, git, gitCommonDir, gitExitCode, gitRoot, primaryGitRoot } from "./git.js";
7
6
  function assertSafePath(root, target) {
8
- const rel = relative(join(root, '.worktrees'), target);
9
- if (rel === '' || rel.startsWith('..') || rel.startsWith('/')) {
10
- throw new DeliveryError('Worktree path must be inside the repository .worktrees directory.');
11
- }
7
+ const rel = relative(join(root, ".worktrees"), target);
8
+ if (rel === "" || rel.startsWith("..") || rel.startsWith("/")) {
9
+ throw new DeliveryError("Worktree path must be inside the repository .worktrees directory.");
10
+ }
12
11
  }
13
12
  function assertIssueNumber(issueNumber) {
14
- if (!Number.isSafeInteger(issueNumber) || issueNumber <= 0)
15
- throw new DeliveryError('Issue number must be positive.');
16
- }
17
- /** @internal Shared physical custody check for preparation and same-owner continuation. */
18
- export function assertIssueWorktreeLocation(row, root) {
19
- assertIssueNumber(row.issueNumber ?? 0);
20
- const branch = `issue/${String(row.issueNumber)}`;
21
- const target = join(root, '.worktrees', `issue-${String(row.issueNumber)}`);
22
- if (row.type !== 'issue' ||
23
- row.path !== target ||
24
- row.branch !== branch ||
25
- !existsSync(target) ||
26
- gitRoot(target) !== realpathSync(target) ||
27
- gitCommonDir(target) !== gitCommonDir(root)) {
28
- throw new DeliveryError('Registered worktree disagrees with its exact repository, path or branch.');
29
- }
30
- if (git(target, 'branch', '--show-current') !== branch)
31
- throw new DeliveryError('Registered branch drifted.');
32
- }
33
- /** @internal Preservation-only refusal for callers of the removed issue-worktree API. */
34
- export async function prepareIssueWorktree(input) {
35
- assertIssueNumber(input.issueNumber);
36
- assertIssueWorktreeTransitionAdmission(input.issueNumber, primaryGitRoot(input.repoRoot));
37
- throw new DeliveryError('Issue worktree preparation was removed; prepare a host-owned worktree from the GitHub-linked branch.');
38
- }
39
- function investigationGitRows(root) {
40
- return git(root, 'worktree', 'list', '--porcelain')
41
- .split('\n\n')
42
- .filter(Boolean)
43
- .map((block) => block.split('\n'));
44
- }
45
- function investigationPathPresent(path) {
46
- try {
47
- lstatSync(path);
48
- return true;
49
- }
50
- catch (error) {
51
- if (error.code === 'ENOENT')
52
- return false;
53
- throw error;
54
- }
13
+ if (!Number.isSafeInteger(issueNumber) || issueNumber <= 0) throw new DeliveryError("Issue number must be positive.");
55
14
  }
56
- /** Observe a host-created, restricted worktree; registration never creates or adopts legacy source. */
57
- export function investigationSourceIdentity(root, issueNumber) {
58
- assertIssueNumber(issueNumber);
59
- const target = join(root, '.worktrees', `issue-${String(issueNumber)}`);
60
- const branch = `issue/${String(issueNumber)}`;
61
- assertIssueWorktreeLocation({ path: target, branch, issueNumber, type: 'issue', status: 'active', createdAt: '', updatedAt: '' }, root);
62
- // Lowercase tags hide assume-unchanged entries; S/s hides skip-worktree entries.
63
- // Do not let Git's own cleanliness checks turn hidden working bytes into removal authority.
64
- if (git(target, 'ls-files', '-v', '-z')
65
- .split('\0')
66
- .some((entry) => /^(?:[a-z]|S) /u.test(entry)))
67
- throw new DeliveryError('Investigation source has assume-unchanged or skip-worktree index entries; preserve hidden local data.');
68
- assertClean(target);
69
- if (git(target, 'ls-files', '--others', '--ignored', '--exclude-standard', '-z') !== '')
70
- throw new DeliveryError('Investigation source contains ignored files; preserve them before completion.');
71
- const rows = investigationGitRows(root).filter((row) => row.includes(`worktree ${target}`) || row.includes(`branch refs/heads/${branch}`));
72
- if (rows.length !== 1 || rows[0].some((line) => /^(?:locked|prunable)(?: |$)/u.test(line)))
73
- throw new DeliveryError('Investigation Git worktree custody is ambiguous or locked.');
74
- const directory = realpathSync(resolve(target, git(target, 'rev-parse', '--git-dir')));
75
- const metadata = lstatSync(target);
76
- const administration = lstatSync(directory);
77
- return {
78
- head: { sha: git(target, 'rev-parse', 'HEAD'), tree: git(target, 'rev-parse', 'HEAD^{tree}') },
79
- physical: {
80
- device: metadata.dev,
81
- inode: metadata.ino,
82
- gitDirectory: directory,
83
- gitDevice: administration.dev,
84
- gitInode: administration.ino,
85
- },
86
- };
15
+ function assertIssueWorktreeLocation(row, root) {
16
+ assertIssueNumber(row.issueNumber ?? 0);
17
+ const branch = `issue/${String(row.issueNumber)}`;
18
+ const target = join(root, ".worktrees", `issue-${String(row.issueNumber)}`);
19
+ if (row.type !== "issue" || row.path !== target || row.branch !== branch || !existsSync(target) || gitRoot(target) !== realpathSync(target) || gitCommonDir(target) !== gitCommonDir(root)) {
20
+ throw new DeliveryError("Registered worktree disagrees with its exact repository, path or branch.");
21
+ }
22
+ if (git(target, "branch", "--show-current") !== branch) throw new DeliveryError("Registered branch drifted.");
87
23
  }
88
- /** Commit equality refuses new same-tree commits as well as source changes and unpushed history. */
89
- export function assertInvestigationSource(preparation, launchDirectory, allowAbsent = false) {
90
- const { repoRoot: root, row, head } = preparation;
91
- assertSafePath(root, row.path);
92
- if (row.path !== join(root, '.worktrees', `issue-${String(row.issueNumber)}`) ||
93
- row.branch !== `issue/${String(row.issueNumber)}`)
94
- throw new DeliveryError('Investigation path or branch disagrees.');
95
- if (row.path === primaryGitRoot(root) || row.path === gitRoot(launchDirectory))
96
- throw new DeliveryError('Investigation completion refuses the primary or current worktree.');
97
- // --repo-root must not hide an invocation launched inside the removable worktree.
98
- const currentRelative = relative(row.path, realpathSync(process.cwd()));
99
- const currentOutside = currentRelative === '..' || currentRelative.startsWith(`..${sep}`) || isAbsolute(currentRelative);
100
- if (!currentOutside)
101
- throw new DeliveryError('Investigation completion refuses the current worktree.');
102
- if (git(root, 'rev-parse', `refs/heads/${row.branch}`) !== head.sha)
103
- throw new DeliveryError('Investigation retaining branch has new or unpushed commits.');
104
- const rows = investigationGitRows(root).filter((candidate) => candidate.includes(`worktree ${row.path}`) || candidate.includes(`branch refs/heads/${row.branch}`));
105
- if (!investigationPathPresent(row.path)) {
106
- // Git removal must have completed both disk and administration before row retirement.
107
- if (!allowAbsent || rows.length !== 0 || investigationPathPresent(preparation.physical.gitDirectory))
108
- throw new DeliveryError('Investigation source is missing without exact completed Git removal.');
109
- return;
110
- }
111
- const observed = investigationSourceIdentity(root, row.issueNumber);
112
- if (JSON.stringify(observed.head) !== JSON.stringify(head) ||
113
- JSON.stringify(observed.physical) !== JSON.stringify(preparation.physical))
114
- throw new DeliveryError('Investigation source commit, tree or physical identity changed.');
24
+ function gitWorktreeRows(root) {
25
+ return git(root, "worktree", "list", "--porcelain").split("\n\n").filter(Boolean).map((block) => block.split("\n"));
115
26
  }
116
- export function removeInvestigationSource(preparation, launchDirectory) {
117
- assertInvestigationSource(preparation, launchDirectory, true);
118
- if (investigationPathPresent(preparation.row.path))
119
- git(preparation.repoRoot, 'worktree', 'remove', preparation.row.path);
120
- if (investigationPathPresent(preparation.row.path) ||
121
- investigationPathPresent(preparation.physical.gitDirectory) ||
122
- investigationGitRows(preparation.repoRoot).some((row) => row.includes(`worktree ${preparation.row.path}`)))
123
- throw new DeliveryError('Investigation removal disk/Git readback is incomplete.');
124
- assertInvestigationSource(preparation, launchDirectory, true);
27
+ function pathPresent(path) {
28
+ try {
29
+ lstatSync(path);
30
+ return true;
31
+ } catch (error) {
32
+ if (error.code === "ENOENT") return false;
33
+ throw error;
34
+ }
125
35
  }
126
36
  function removeMergedIssueSource(row, root, remote, attestation, allowAbsent) {
127
- assertSafePath(root, row.path);
128
- if (row.status !== 'merged' || row.path !== join(root, '.worktrees', `issue-${String(row.issueNumber)}`)) {
129
- throw new DeliveryError('Only the exact registered merged issue worktree can be cleaned.');
130
- }
131
- const present = existsSync(row.path);
132
- if (present && gitRoot(row.path) !== realpathSync(row.path)) {
133
- throw new DeliveryError('Registered worktree points elsewhere.');
134
- }
135
- if (!present && !allowAbsent) {
136
- throw new DeliveryError('Registered worktree is missing.');
137
- }
138
- if (present)
139
- assertClean(row.path);
140
- const base = defaultBaseRef(root, remote);
141
- const branchIncluded = gitExitCode(root, 'merge-base', '--is-ancestor', row.branch, base) === 0;
142
- if (attestation) {
143
- if (attestation.headBranch !== row.branch ||
144
- attestation.headSha !== git(present ? row.path : root, 'rev-parse', present ? 'HEAD' : row.branch) ||
145
- (attestation.remoteHeadSha !== null && attestation.remoteHeadSha !== attestation.headSha) ||
146
- attestation.baseBranch !== base.slice(`refs/remotes/${resolveGitRemoteName(root, remote)}/`.length) ||
147
- attestation.remoteBaseSha !== git(root, 'rev-parse', base) ||
148
- gitExitCode(root, 'merge-base', '--is-ancestor', attestation.baseSha, attestation.mergeSha) !== 0 ||
149
- gitExitCode(root, 'merge-base', '--is-ancestor', attestation.mergeSha, base) !== 0 ||
150
- git(root, 'rev-parse', `${attestation.mergeSha}^{tree}`) !== attestation.mergeTree ||
151
- (!branchIncluded && attestation.strategy === 'merge')) {
152
- throw new DeliveryError('Exact merged-result cleanup attestation disagrees with Git or remote readback.');
153
- }
37
+ assertSafePath(root, row.path);
38
+ if (row.status !== "merged" || row.path !== join(root, ".worktrees", `issue-${String(row.issueNumber)}`)) {
39
+ throw new DeliveryError("Only the exact registered merged issue worktree can be cleaned.");
40
+ }
41
+ const present = existsSync(row.path);
42
+ if (present && gitRoot(row.path) !== realpathSync(row.path)) {
43
+ throw new DeliveryError("Registered worktree points elsewhere.");
44
+ }
45
+ if (!present && !allowAbsent) {
46
+ throw new DeliveryError("Registered worktree is missing.");
47
+ }
48
+ if (present) assertClean(row.path);
49
+ const base = defaultBaseRef(root, remote);
50
+ const branchIncluded = gitExitCode(root, "merge-base", "--is-ancestor", row.branch, base) === 0;
51
+ if (attestation) {
52
+ if (attestation.headBranch !== row.branch || attestation.headSha !== git(present ? row.path : root, "rev-parse", present ? "HEAD" : row.branch) || attestation.remoteHeadSha !== null && attestation.remoteHeadSha !== attestation.headSha || attestation.baseBranch !== base.slice(`refs/remotes/${resolveGitRemoteName(root, remote)}/`.length) || attestation.remoteBaseSha !== git(root, "rev-parse", base) || gitExitCode(root, "merge-base", "--is-ancestor", attestation.baseSha, attestation.mergeSha) !== 0 || gitExitCode(root, "merge-base", "--is-ancestor", attestation.mergeSha, base) !== 0 || git(root, "rev-parse", `${attestation.mergeSha}^{tree}`) !== attestation.mergeTree || !branchIncluded && attestation.strategy === "merge") {
53
+ throw new DeliveryError("Exact merged-result cleanup attestation disagrees with Git or remote readback.");
154
54
  }
155
- else if (!branchIncluded) {
156
- throw new DeliveryError('Branch is not included in the current base and exact merged-result attestation is absent.');
157
- }
158
- if (present)
159
- git(root, 'worktree', 'remove', row.path);
55
+ } else if (!branchIncluded) {
56
+ throw new DeliveryError(
57
+ "Branch is not included in the current base and exact merged-result attestation is absent."
58
+ );
59
+ }
60
+ if (present) git(root, "worktree", "remove", row.path);
160
61
  }
161
- /** @internal Exact terminal transition uses the existing non-force removal and retaining-ref proof. */
162
- export function removeMergedSourceForTransition(plan, remote) {
163
- if (plan.purpose !== 'merged-cleanup' || plan.disposition !== 'remove' || plan.retainedHoldCommentIds.length !== 0)
164
- throw new DeliveryError('Transition cannot remove held or nonterminal source.');
165
- const terminal = plan.lineage.find((pr) => pr.prNumber === plan.terminalPrNumber);
166
- if (!terminal?.merged || !terminal.mergeSha)
167
- throw new DeliveryError('Transition lacks exact native terminal merge lineage.');
168
- const mergeTree = git(plan.repoRoot, 'rev-parse', `${terminal.mergeSha}^{tree}`);
169
- const strategy = gitExitCode(plan.repoRoot, 'merge-base', '--is-ancestor', plan.head.sha, terminal.mergeSha) === 0
170
- ? 'merge'
171
- : 'squash';
172
- if (strategy === 'squash' && mergeTree !== plan.head.tree)
173
- throw new DeliveryError('Transition lacks exact retained tree proof for non-merge source removal.');
174
- if (!plan.remoteRefs || (plan.remoteRefs.headSha !== null && plan.remoteRefs.headSha !== plan.head.sha))
175
- throw new DeliveryError('Transition lacks exact authenticated remote branch readback.');
176
- removeMergedIssueSource({ ...plan.row, status: 'merged', prNumber: terminal.prNumber }, plan.repoRoot, remote, {
177
- baseBranch: terminal.baseBranch,
178
- baseSha: terminal.baseSha,
179
- headBranch: plan.row.branch,
180
- headSha: plan.head.sha,
181
- mergeSha: terminal.mergeSha,
182
- mergeTree,
183
- remoteBaseSha: plan.remoteRefs.baseSha,
184
- remoteHeadSha: plan.remoteRefs.headSha,
185
- strategy,
186
- }, true);
62
+ function removeFinishedIssueSource(row, root, headSha, attestation) {
63
+ assertIssueNumber(row.issueNumber ?? 0);
64
+ if (row.branch !== `issue/${String(row.issueNumber)}` || row.path !== join(root, ".worktrees", `issue-${String(row.issueNumber)}`))
65
+ throw new DeliveryError("Registered path or branch differs from the finished issue; preserve the source.");
66
+ if (gitExitCode(root, "symbolic-ref", "--quiet", `refs/heads/${row.branch}`) === 0)
67
+ throw new DeliveryError("Registered branch is symbolic; preserve its target and restore direct branch ownership.");
68
+ if (pathPresent(row.path) && realpathSync(row.path) !== row.path)
69
+ throw new DeliveryError("Registered source has a symlinked path; preserve its physical worktree.");
70
+ const current = relative(row.path, realpathSync(process.cwd()));
71
+ if (row.path === primaryGitRoot(root) || !(current === ".." || current.startsWith(`..${sep}`) || isAbsolute(current)))
72
+ throw new DeliveryError("Cleanup targets the current or primary worktree; run finish from outside that worktree.");
73
+ const rows = gitWorktreeRows(root).filter(
74
+ (lines) => lines.includes(`worktree ${row.path}`) || lines.includes(`branch refs/heads/${row.branch}`)
75
+ );
76
+ if (pathPresent(row.path)) {
77
+ if (lstatSync(row.path).isSymbolicLink())
78
+ throw new DeliveryError("Registered source is a symlink; preserve the source.");
79
+ assertIssueWorktreeLocation(row, root);
80
+ try {
81
+ assertClean(row.path);
82
+ } catch {
83
+ throw new DeliveryError("Worktree contains local changes; preserve them before cleanup.");
84
+ }
85
+ if (rows.length !== 1 || rows[0].some((line) => /^(?:locked|prunable)(?: |$)/u.test(line)))
86
+ throw new DeliveryError("Worktree custody is ambiguous or locked; preserve the source.");
87
+ if (git(row.path, "ls-files", "-v", "-z").split("\0").some((entry) => /^(?:[a-z]|S) /u.test(entry)))
88
+ throw new DeliveryError("Worktree has hidden index entries; preserve local data before cleanup.");
89
+ if (git(row.path, "ls-files", "--others", "--ignored", "--exclude-standard", "-z") !== "")
90
+ throw new DeliveryError("Worktree contains ignored files; preserve local data before cleanup.");
91
+ } else if (rows.length !== 0)
92
+ throw new DeliveryError("Missing worktree still has Git custody; reconcile it without forced cleanup.");
93
+ if (gitExitCode(root, "show-ref", "--verify", "--quiet", `refs/heads/${row.branch}`) !== 0) {
94
+ if (!pathPresent(row.path)) return;
95
+ throw new DeliveryError("Registered branch is absent; preserve the source.");
96
+ }
97
+ if (git(root, "rev-parse", `refs/heads/${row.branch}`) !== headSha)
98
+ throw new DeliveryError("Local branch differs from the finished PR head; preserve its commits.");
99
+ removeMergedIssueSource(row, root, void 0, attestation, true);
100
+ git(root, "update-ref", "--no-deref", "-d", `refs/heads/${row.branch}`, headSha);
101
+ if (pathPresent(row.path) || gitExitCode(root, "show-ref", "--verify", "--quiet", `refs/heads/${row.branch}`) === 0)
102
+ throw new DeliveryError("Cleanup readback is incomplete; inspect the retained source without retrying removal.");
187
103
  }
188
- //# sourceMappingURL=worktree.js.map
104
+ export {
105
+ assertIssueWorktreeLocation,
106
+ removeFinishedIssueSource
107
+ };
108
+ //# sourceMappingURL=worktree.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"worktree.js","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChH,OAAO,EACL,sCAAsC,GAGvC,MAAM,gCAAgC,CAAC;AAExC,SAAS,cAAc,CAAC,IAAY,EAAE,MAAc;IAClD,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;IACvD,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,aAAa,CAAC,mEAAmE,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAmB;IAC5C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I,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACrG,MAAM,IAAI,aAAa,CAAC,8DAA8D,CAAC,CAAC;IAC1F,uBAAuB,CACrB,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAmB,EAC/E,IAAI,CAAC,QAAQ,EACb,MAAM,EACN;QACE,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM;QAC3B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;QACtB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,SAAS;QACT,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO;QACtC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO;QACtC,QAAQ;KACT,EACD,IAAI,CACL,CAAC;AACJ,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/worktree.ts"],
4
+ "sourcesContent": ["import { existsSync, lstatSync, realpathSync } from 'node:fs';\nimport { isAbsolute, join, relative, sep } from 'node:path';\n\nimport { resolveGitRemoteName } from './github/repo.js';\n\nimport { DeliveryError } from './errors.js';\nimport { assertClean, defaultBaseRef, git, gitCommonDir, gitExitCode, gitRoot, primaryGitRoot } from './git.js';\nimport type { WorktreeEntry } from './services/worktreeRegistry.js';\n\nfunction assertSafePath(root: string, target: string): void {\n const rel = relative(join(root, '.worktrees'), target);\n if (rel === '' || rel.startsWith('..') || rel.startsWith('/')) {\n throw new DeliveryError('Worktree path must be inside the repository .worktrees directory.');\n }\n}\n\nfunction assertIssueNumber(issueNumber: number): void {\n if (!Number.isSafeInteger(issueNumber) || issueNumber <= 0) throw new DeliveryError('Issue number must be positive.');\n}\n\n/** @internal Shared physical custody check for preparation and same-owner continuation. */\nexport function assertIssueWorktreeLocation(row: WorktreeEntry, root: string): void {\n assertIssueNumber(row.issueNumber ?? 0);\n const branch = `issue/${String(row.issueNumber)}`;\n const target = join(root, '.worktrees', `issue-${String(row.issueNumber)}`);\n if (\n row.type !== 'issue' ||\n row.path !== target ||\n row.branch !== branch ||\n !existsSync(target) ||\n gitRoot(target) !== realpathSync(target) ||\n gitCommonDir(target) !== gitCommonDir(root)\n ) {\n throw new DeliveryError('Registered worktree disagrees with its exact repository, path or branch.');\n }\n if (git(target, 'branch', '--show-current') !== branch) throw new DeliveryError('Registered branch drifted.');\n}\n\nfunction gitWorktreeRows(root: string): string[][] {\n return git(root, 'worktree', 'list', '--porcelain')\n .split('\\n\\n')\n .filter(Boolean)\n .map((block) => block.split('\\n'));\n}\nfunction pathPresent(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false;\n throw error;\n }\n}\n\nexport interface MergeCleanupAttestation {\n baseBranch: string;\n baseSha: string;\n headBranch: string;\n headSha: string;\n mergeSha: string;\n mergeTree: string;\n remoteBaseSha: string;\n remoteHeadSha: string | null;\n strategy: 'merge' | 'squash' | 'rebase';\n}\n\nfunction removeMergedIssueSource(\n row: WorktreeEntry,\n root: string,\n remote: string | undefined,\n attestation: MergeCleanupAttestation | undefined,\n allowAbsent: boolean,\n): void {\n assertSafePath(root, row.path);\n if (row.status !== 'merged' || row.path !== join(root, '.worktrees', `issue-${String(row.issueNumber)}`)) {\n throw new DeliveryError('Only the exact registered merged issue worktree can be cleaned.');\n }\n const present = existsSync(row.path);\n if (present && gitRoot(row.path) !== realpathSync(row.path)) {\n throw new DeliveryError('Registered worktree points elsewhere.');\n }\n if (!present && !allowAbsent) {\n throw new DeliveryError('Registered worktree is missing.');\n }\n if (present) assertClean(row.path);\n const base = defaultBaseRef(root, remote);\n const branchIncluded = gitExitCode(root, 'merge-base', '--is-ancestor', row.branch, base) === 0;\n if (attestation) {\n if (\n attestation.headBranch !== row.branch ||\n attestation.headSha !== git(present ? row.path : root, 'rev-parse', present ? 'HEAD' : row.branch) ||\n (attestation.remoteHeadSha !== null && attestation.remoteHeadSha !== attestation.headSha) ||\n attestation.baseBranch !== base.slice(`refs/remotes/${resolveGitRemoteName(root, remote)}/`.length) ||\n attestation.remoteBaseSha !== git(root, 'rev-parse', base) ||\n gitExitCode(root, 'merge-base', '--is-ancestor', attestation.baseSha, attestation.mergeSha) !== 0 ||\n gitExitCode(root, 'merge-base', '--is-ancestor', attestation.mergeSha, base) !== 0 ||\n git(root, 'rev-parse', `${attestation.mergeSha}^{tree}`) !== attestation.mergeTree ||\n (!branchIncluded && attestation.strategy === 'merge')\n ) {\n throw new DeliveryError('Exact merged-result cleanup attestation disagrees with Git or remote readback.');\n }\n } else if (!branchIncluded) {\n throw new DeliveryError(\n 'Branch is not included in the current base and exact merged-result attestation is absent.',\n );\n }\n if (present) git(root, 'worktree', 'remove', row.path);\n}\n\n/** Remove only a finished, retained source and its exact local branch; never force Git removal. */\nexport function removeFinishedIssueSource(\n row: WorktreeEntry,\n root: string,\n headSha: string,\n attestation?: MergeCleanupAttestation,\n): void {\n assertIssueNumber(row.issueNumber ?? 0);\n if (\n row.branch !== `issue/${String(row.issueNumber)}` ||\n row.path !== join(root, '.worktrees', `issue-${String(row.issueNumber)}`)\n )\n throw new DeliveryError('Registered path or branch differs from the finished issue; preserve the source.');\n if (gitExitCode(root, 'symbolic-ref', '--quiet', `refs/heads/${row.branch}`) === 0)\n throw new DeliveryError('Registered branch is symbolic; preserve its target and restore direct branch ownership.');\n if (pathPresent(row.path) && realpathSync(row.path) !== row.path)\n throw new DeliveryError('Registered source has a symlinked path; preserve its physical worktree.');\n const current = relative(row.path, realpathSync(process.cwd()));\n if (row.path === primaryGitRoot(root) || !(current === '..' || current.startsWith(`..${sep}`) || isAbsolute(current)))\n throw new DeliveryError('Cleanup targets the current or primary worktree; run finish from outside that worktree.');\n const rows = gitWorktreeRows(root).filter(\n (lines) => lines.includes(`worktree ${row.path}`) || lines.includes(`branch refs/heads/${row.branch}`),\n );\n if (pathPresent(row.path)) {\n if (lstatSync(row.path).isSymbolicLink())\n throw new DeliveryError('Registered source is a symlink; preserve the source.');\n assertIssueWorktreeLocation(row, root);\n try {\n assertClean(row.path);\n } catch {\n throw new DeliveryError('Worktree contains local changes; preserve them before cleanup.');\n }\n if (rows.length !== 1 || rows[0]!.some((line) => /^(?:locked|prunable)(?: |$)/u.test(line)))\n throw new DeliveryError('Worktree custody is ambiguous or locked; preserve the source.');\n if (\n git(row.path, 'ls-files', '-v', '-z')\n .split('\\0')\n .some((entry) => /^(?:[a-z]|S) /u.test(entry))\n )\n throw new DeliveryError('Worktree has hidden index entries; preserve local data before cleanup.');\n if (git(row.path, 'ls-files', '--others', '--ignored', '--exclude-standard', '-z') !== '')\n throw new DeliveryError('Worktree contains ignored files; preserve local data before cleanup.');\n } else if (rows.length !== 0)\n throw new DeliveryError('Missing worktree still has Git custody; reconcile it without forced cleanup.');\n if (gitExitCode(root, 'show-ref', '--verify', '--quiet', `refs/heads/${row.branch}`) !== 0) {\n if (!pathPresent(row.path)) return;\n throw new DeliveryError('Registered branch is absent; preserve the source.');\n }\n if (git(root, 'rev-parse', `refs/heads/${row.branch}`) !== headSha)\n throw new DeliveryError('Local branch differs from the finished PR head; preserve its commits.');\n removeMergedIssueSource(row, root, undefined, attestation, true);\n git(root, 'update-ref', '--no-deref', '-d', `refs/heads/${row.branch}`, headSha);\n if (pathPresent(row.path) || gitExitCode(root, 'show-ref', '--verify', '--quiet', `refs/heads/${row.branch}`) === 0)\n throw new DeliveryError('Cleanup readback is incomplete; inspect the retained source without retrying removal.');\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,WAAW,oBAAoB;AACpD,SAAS,YAAY,MAAM,UAAU,WAAW;AAEhD,SAAS,4BAA4B;AAErC,SAAS,qBAAqB;AAC9B,SAAS,aAAa,gBAAgB,KAAK,cAAc,aAAa,SAAS,sB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AAE/C,YAAM,IAAI,cAAc,wEAAwE;AAClG,QAAI,IAAI,IAAI,MAAM,YAAY,YAAY,aAAa,sBAAsB,IAAI,MAAM;AACrF,YAAM,IAAI,cAAc,sEAAsE;AAAA,EAClG,WAAW,KAAK,WAAW;AACzB,UAAM,IAAI,cAAc,8EAA8E;AACxG,MAAI,YAAY,MAAM,YAAY,YAAY,WAAW,cAAc,IAAI,MAAM,EAAE,MAAM,GAAG;AAC1F,QAAI,CAAC,YAAY,IAAI,IAAI,EAAG;AAC5B,UAAM,IAAI,cAAc,mDAAmD;AAAA,EAC7E;AACA,MAAI,IAAI,MAAM,aAAa,cAAc,IAAI,MAAM,EAAE,MAAM;AACzD,UAAM,IAAI,cAAc,uEAAuE;AACjG,0BAAwB,KAAK,MAAM,QAAW,aAAa,IAAI;AAC/D,MAAI,MAAM,cAAc,cAAc,MAAM,cAAc,IAAI,MAAM,IAAI,OAAO;AAC/E,MAAI,YAAY,IAAI,IAAI,KAAK,YAAY,MAAM,YAAY,YAAY,WAAW,cAAc,IAAI,MAAM,EAAE,MAAM;AAChH,UAAM,IAAI,cAAc,uFAAuF;AACnH;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaratech/ai-delivery",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "private": false,
5
5
  "description": "Generic GitHub issue and pull request delivery CLI and MCP server",
6
6
  "homepage": "https://github.com/aviaratech/ai-delivery#readme",
@@ -46,19 +46,20 @@
46
46
  "access": "public"
47
47
  },
48
48
  "scripts": {
49
- "format": "oxfmt --threads=1 src scripts package.json tsconfig.json tsconfig.build.json vitest.config.ts .oxlintrc.json .oxfmtrc.json",
50
- "format:check": "oxfmt --threads=1 --check src scripts package.json tsconfig.json tsconfig.build.json vitest.config.ts .oxlintrc.json .oxfmtrc.json",
51
- "lint": "oxlint --threads=1",
49
+ "format": "oxfmt src scripts package.json tsconfig.json tsconfig.build.json vitest.config.ts .oxlintrc.json .oxfmtrc.json",
50
+ "format:check": "oxfmt --check src scripts package.json tsconfig.json tsconfig.build.json vitest.config.ts .oxlintrc.json .oxfmtrc.json",
51
+ "lint": "oxlint",
52
52
  "typecheck": "tsc -p tsconfig.json",
53
- "build": "tsc -p tsconfig.build.json && node scripts/build-plugin.mjs",
54
- "postbuild": "node -e \"require('node:fs').chmodSync('dist/cli.js', 0o755)\"",
53
+ "build": "node scripts/build.mjs --clean --declarations --plugin",
55
54
  "test": "npm run build && vitest run",
56
- "checks": "node scripts/current-qualification.mjs",
55
+ "checks": "node scripts/checks.mjs",
56
+ "checks:release": "node scripts/current-qualification.mjs",
57
57
  "checks:fast": "node scripts/checks.mjs --fast",
58
58
  "checks:producer": "node scripts/current-qualification.mjs --producer-only",
59
59
  "checks:resume": "node scripts/current-qualification.mjs"
60
60
  },
61
61
  "dependencies": {
62
+ "@aviaratech/ai-plugin-tools": "0.1.0",
62
63
  "@modelcontextprotocol/sdk": "^1.31.0",
63
64
  "@octokit/auth-app": "^8.2.0",
64
65
  "@octokit/graphql": "^9.0.3",
@@ -71,10 +72,11 @@
71
72
  "devDependencies": {
72
73
  "@types/node": "^25.9.1",
73
74
  "@types/proper-lockfile": "^4.1.4",
75
+ "esbuild": "0.28.2",
74
76
  "oxfmt": "0.70.0",
75
77
  "oxlint": "1.85.0",
76
78
  "oxlint-tsgolint": "7.0.2003",
77
- "typescript": "6.0.2",
79
+ "typescript": "7.0.2",
78
80
  "vitest": "5.0.1"
79
81
  },
80
82
  "engines": {
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "ai-delivery",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "description": "GitHub issue and pull request delivery tools for prepared worktrees and evidence-based handoff.",
5
5
  "author": { "name": "AviaraTech", "url": "https://github.com/aviaratech" },
6
6
  "homepage": "https://github.com/aviaratech/ai-delivery#readme",
7
7
  "repository": "https://github.com/aviaratech/ai-delivery",
8
8
  "license": "MIT",
9
9
  "deliveryCapabilityVersion": 2,
10
- "packageVersion": "0.3.34"
10
+ "packageVersion": "0.3.36"
11
11
  }