@gitkraken/core-gitlens 0.2.0 → 0.3.0

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 (361) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/dist/git/cache.d.ts +28 -4
  3. package/dist/git/cache.d.ts.map +1 -1
  4. package/dist/git/cache.js +82 -18
  5. package/dist/git/cache.js.map +1 -1
  6. package/dist/git/models/commit.d.ts.map +1 -1
  7. package/dist/git/models/commit.js.map +1 -1
  8. package/dist/git/models/reference.d.ts +31 -0
  9. package/dist/git/models/reference.d.ts.map +1 -1
  10. package/dist/git/models/remote.d.ts.map +1 -1
  11. package/dist/git/models/remote.js.map +1 -1
  12. package/dist/git/models/repository.d.ts +9 -1
  13. package/dist/git/models/repository.d.ts.map +1 -1
  14. package/dist/git/models/repository.js +19 -3
  15. package/dist/git/models/repository.js.map +1 -1
  16. package/dist/git/models/search.d.ts +2 -2
  17. package/dist/git/models/search.d.ts.map +1 -1
  18. package/dist/git/models/worktree.d.ts +4 -1
  19. package/dist/git/models/worktree.d.ts.map +1 -1
  20. package/dist/git/models/worktree.js +2 -2
  21. package/dist/git/models/worktree.js.map +1 -1
  22. package/dist/git/parsers/diffParser.d.ts.map +1 -1
  23. package/dist/git/parsers/diffParser.js.map +1 -1
  24. package/dist/git/providers/branches.d.ts +15 -4
  25. package/dist/git/providers/branches.d.ts.map +1 -1
  26. package/dist/git/providers/config.d.ts +4 -1
  27. package/dist/git/providers/config.d.ts.map +1 -1
  28. package/dist/git/providers/operations.d.ts +33 -10
  29. package/dist/git/providers/operations.d.ts.map +1 -1
  30. package/dist/git/providers/pausedOperations.d.ts +3 -1
  31. package/dist/git/providers/pausedOperations.d.ts.map +1 -1
  32. package/dist/git/providers/refs.d.ts +23 -2
  33. package/dist/git/providers/refs.d.ts.map +1 -1
  34. package/dist/git/providers/staging.d.ts +16 -0
  35. package/dist/git/providers/staging.d.ts.map +1 -1
  36. package/dist/git/providers/status.d.ts +4 -1
  37. package/dist/git/providers/status.d.ts.map +1 -1
  38. package/dist/git/remotes/azure-devops.d.ts.map +1 -1
  39. package/dist/git/remotes/azure-devops.js.map +1 -1
  40. package/dist/git/{exec.types.d.ts → run.types.d.ts} +22 -3
  41. package/dist/git/run.types.d.ts.map +1 -0
  42. package/dist/git/run.types.js +2 -0
  43. package/dist/git/run.types.js.map +1 -0
  44. package/dist/git/service.d.ts.map +1 -1
  45. package/dist/git/service.js.map +1 -1
  46. package/dist/git/utils/autolink.utils.d.ts.map +1 -1
  47. package/dist/git/utils/autolink.utils.js.map +1 -1
  48. package/dist/git/utils/blame.utils.d.ts.map +1 -1
  49. package/dist/git/utils/blame.utils.js.map +1 -1
  50. package/dist/git/utils/conflictResolution.utils.d.ts +6 -0
  51. package/dist/git/utils/conflictResolution.utils.d.ts.map +1 -0
  52. package/dist/git/utils/conflictResolution.utils.js +25 -0
  53. package/dist/git/utils/conflictResolution.utils.js.map +1 -0
  54. package/dist/git/utils/fileStatus.utils.d.ts +2 -1
  55. package/dist/git/utils/fileStatus.utils.d.ts.map +1 -1
  56. package/dist/git/utils/fileStatus.utils.js +4 -0
  57. package/dist/git/utils/fileStatus.utils.js.map +1 -1
  58. package/dist/git/utils/search.utils.d.ts.map +1 -1
  59. package/dist/git/utils/search.utils.js +3 -0
  60. package/dist/git/utils/search.utils.js.map +1 -1
  61. package/dist/git/utils/sorting.d.ts +8 -0
  62. package/dist/git/utils/sorting.d.ts.map +1 -1
  63. package/dist/git/utils/sorting.js +15 -0
  64. package/dist/git/utils/sorting.js.map +1 -1
  65. package/dist/git/utils/status.utils.d.ts.map +1 -1
  66. package/dist/git/utils/status.utils.js.map +1 -1
  67. package/dist/git/watching/classifyChange.d.ts.map +1 -1
  68. package/dist/git/watching/classifyChange.js +8 -0
  69. package/dist/git/watching/classifyChange.js.map +1 -1
  70. package/dist/git/watching/gitIgnoreFilter.js +1 -1
  71. package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
  72. package/dist/git/watching/initWatcher.d.ts.map +1 -1
  73. package/dist/git/watching/initWatcher.js.map +1 -1
  74. package/dist/git/watching/watchGroup.d.ts.map +1 -1
  75. package/dist/git/watching/watchGroup.js.map +1 -1
  76. package/dist/git/watching/watchService.d.ts.map +1 -1
  77. package/dist/git/watching/watchService.js +24 -4
  78. package/dist/git/watching/watchService.js.map +1 -1
  79. package/dist/git/watching/watchSession.d.ts.map +1 -1
  80. package/dist/git/watching/watchSession.js.map +1 -1
  81. package/dist/git-cli/exec/exec.types.d.ts +1 -1
  82. package/dist/git-cli/exec/exec.types.d.ts.map +1 -1
  83. package/dist/git-cli/exec/git.d.ts +3 -3
  84. package/dist/git-cli/exec/git.d.ts.map +1 -1
  85. package/dist/git-cli/exec/git.js.map +1 -1
  86. package/dist/git-cli/exec/gitQueue.d.ts +10 -2
  87. package/dist/git-cli/exec/gitQueue.d.ts.map +1 -1
  88. package/dist/git-cli/exec/gitQueue.js +39 -12
  89. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  90. package/dist/git-cli/parsers/blameParser.d.ts.map +1 -1
  91. package/dist/git-cli/parsers/blameParser.js.map +1 -1
  92. package/dist/git-cli/parsers/logParser.js.map +1 -1
  93. package/dist/git-cli/parsers/refParser.d.ts +3 -30
  94. package/dist/git-cli/parsers/refParser.d.ts.map +1 -1
  95. package/dist/git-cli/parsers/refParser.js +30 -30
  96. package/dist/git-cli/parsers/refParser.js.map +1 -1
  97. package/dist/git-cli/providers/blame.d.ts.map +1 -1
  98. package/dist/git-cli/providers/blame.js.map +1 -1
  99. package/dist/git-cli/providers/branches.d.ts +15 -5
  100. package/dist/git-cli/providers/branches.d.ts.map +1 -1
  101. package/dist/git-cli/providers/branches.js +98 -68
  102. package/dist/git-cli/providers/branches.js.map +1 -1
  103. package/dist/git-cli/providers/commits.d.ts.map +1 -1
  104. package/dist/git-cli/providers/commits.js +74 -30
  105. package/dist/git-cli/providers/commits.js.map +1 -1
  106. package/dist/git-cli/providers/config.d.ts +11 -2
  107. package/dist/git-cli/providers/config.d.ts.map +1 -1
  108. package/dist/git-cli/providers/config.js +27 -2
  109. package/dist/git-cli/providers/config.js.map +1 -1
  110. package/dist/git-cli/providers/diff.d.ts.map +1 -1
  111. package/dist/git-cli/providers/diff.js +4 -2
  112. package/dist/git-cli/providers/diff.js.map +1 -1
  113. package/dist/git-cli/providers/graph.d.ts.map +1 -1
  114. package/dist/git-cli/providers/graph.js +7 -2
  115. package/dist/git-cli/providers/graph.js.map +1 -1
  116. package/dist/git-cli/providers/operations.d.ts +13 -11
  117. package/dist/git-cli/providers/operations.d.ts.map +1 -1
  118. package/dist/git-cli/providers/operations.js +108 -38
  119. package/dist/git-cli/providers/operations.js.map +1 -1
  120. package/dist/git-cli/providers/patch.d.ts.map +1 -1
  121. package/dist/git-cli/providers/patch.js.map +1 -1
  122. package/dist/git-cli/providers/pausedOperations.d.ts +3 -1
  123. package/dist/git-cli/providers/pausedOperations.d.ts.map +1 -1
  124. package/dist/git-cli/providers/pausedOperations.js +7 -1
  125. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  126. package/dist/git-cli/providers/refs.d.ts +19 -2
  127. package/dist/git-cli/providers/refs.d.ts.map +1 -1
  128. package/dist/git-cli/providers/refs.js +286 -2
  129. package/dist/git-cli/providers/refs.js.map +1 -1
  130. package/dist/git-cli/providers/revision.js.map +1 -1
  131. package/dist/git-cli/providers/staging.d.ts +6 -0
  132. package/dist/git-cli/providers/staging.d.ts.map +1 -1
  133. package/dist/git-cli/providers/staging.js +32 -0
  134. package/dist/git-cli/providers/staging.js.map +1 -1
  135. package/dist/git-cli/providers/status.d.ts +4 -1
  136. package/dist/git-cli/providers/status.d.ts.map +1 -1
  137. package/dist/git-cli/providers/status.js +4 -3
  138. package/dist/git-cli/providers/status.js.map +1 -1
  139. package/dist/git-cli/providers/tags.d.ts.map +1 -1
  140. package/dist/git-cli/providers/tags.js +10 -6
  141. package/dist/git-cli/providers/tags.js.map +1 -1
  142. package/dist/ipc/discovery.d.ts +27 -0
  143. package/dist/ipc/discovery.d.ts.map +1 -0
  144. package/dist/ipc/discovery.js +38 -0
  145. package/dist/ipc/discovery.js.map +1 -0
  146. package/dist/ipc/ipcServer.d.ts +20 -0
  147. package/dist/ipc/ipcServer.d.ts.map +1 -0
  148. package/dist/ipc/ipcServer.js +162 -0
  149. package/dist/ipc/ipcServer.js.map +1 -0
  150. package/dist/plus/agents/providers/claudeCodeProvider.d.ts +114 -0
  151. package/dist/plus/agents/providers/claudeCodeProvider.d.ts.map +1 -0
  152. package/dist/plus/agents/providers/claudeCodeProvider.js +1480 -0
  153. package/dist/plus/agents/providers/claudeCodeProvider.js.map +1 -0
  154. package/dist/plus/agents/providers/claudeCodeTranscript.d.ts +36 -0
  155. package/dist/plus/agents/providers/claudeCodeTranscript.d.ts.map +1 -0
  156. package/dist/plus/agents/providers/claudeCodeTranscript.js +171 -0
  157. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -0
  158. package/dist/plus/agents/sanitizePrompt.d.ts +15 -0
  159. package/dist/plus/agents/sanitizePrompt.d.ts.map +1 -0
  160. package/dist/plus/agents/sanitizePrompt.js +103 -0
  161. package/dist/plus/agents/sanitizePrompt.js.map +1 -0
  162. package/dist/plus/agents/stateMachine.d.ts +32 -0
  163. package/dist/plus/agents/stateMachine.d.ts.map +1 -0
  164. package/dist/plus/agents/stateMachine.js +180 -0
  165. package/dist/plus/agents/stateMachine.js.map +1 -0
  166. package/dist/plus/agents/types.d.ts +203 -0
  167. package/dist/plus/agents/types.d.ts.map +1 -0
  168. package/dist/plus/agents/types.js +49 -0
  169. package/dist/plus/agents/types.js.map +1 -0
  170. package/dist/plus/ai/errors.d.ts +4 -1
  171. package/dist/plus/ai/errors.d.ts.map +1 -1
  172. package/dist/plus/ai/errors.js +38 -0
  173. package/dist/plus/ai/errors.js.map +1 -1
  174. package/dist/plus/ai/models/promptTemplates.d.ts +11 -2
  175. package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -1
  176. package/dist/plus/ai/prompts.d.ts +1 -0
  177. package/dist/plus/ai/prompts.d.ts.map +1 -1
  178. package/dist/plus/ai/prompts.js +48 -8
  179. package/dist/plus/ai/prompts.js.map +1 -1
  180. package/dist/plus/ai/utils/results.utils.d.ts.map +1 -1
  181. package/dist/plus/ai/utils/results.utils.js.map +1 -1
  182. package/dist/plus/git-github/api/github.d.ts +10 -1
  183. package/dist/plus/git-github/api/github.d.ts.map +1 -1
  184. package/dist/plus/git-github/api/github.js +156 -49
  185. package/dist/plus/git-github/api/github.js.map +1 -1
  186. package/dist/plus/git-github/api/types.d.ts +8 -0
  187. package/dist/plus/git-github/api/types.d.ts.map +1 -1
  188. package/dist/plus/git-github/models.d.ts +1 -1
  189. package/dist/plus/git-github/models.d.ts.map +1 -1
  190. package/dist/plus/git-github/models.js.map +1 -1
  191. package/dist/plus/git-github/providers/github/blame.d.ts.map +1 -1
  192. package/dist/plus/git-github/providers/github/blame.js.map +1 -1
  193. package/dist/plus/git-github/providers/github/branches.d.ts +5 -1
  194. package/dist/plus/git-github/providers/github/branches.d.ts.map +1 -1
  195. package/dist/plus/git-github/providers/github/branches.js +47 -24
  196. package/dist/plus/git-github/providers/github/branches.js.map +1 -1
  197. package/dist/plus/git-github/providers/github/commits.d.ts.map +1 -1
  198. package/dist/plus/git-github/providers/github/commits.js +144 -92
  199. package/dist/plus/git-github/providers/github/commits.js.map +1 -1
  200. package/dist/plus/git-github/providers/github/diff.d.ts +1 -1
  201. package/dist/plus/git-github/providers/github/diff.d.ts.map +1 -1
  202. package/dist/plus/git-github/providers/github/diff.js +23 -9
  203. package/dist/plus/git-github/providers/github/diff.js.map +1 -1
  204. package/dist/plus/git-github/providers/github/refs.d.ts +9 -1
  205. package/dist/plus/git-github/providers/github/refs.d.ts.map +1 -1
  206. package/dist/plus/git-github/providers/github/refs.js +38 -13
  207. package/dist/plus/git-github/providers/github/refs.js.map +1 -1
  208. package/dist/plus/git-github/providers/github/revision.d.ts.map +1 -1
  209. package/dist/plus/git-github/providers/github/revision.js +1 -2
  210. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  211. package/dist/plus/git-github/providers/github/status.d.ts +4 -1
  212. package/dist/plus/git-github/providers/github/status.d.ts.map +1 -1
  213. package/dist/plus/git-github/providers/github/status.js +1 -1
  214. package/dist/plus/git-github/providers/github/status.js.map +1 -1
  215. package/dist/plus/git-github/providers/github/tags.d.ts.map +1 -1
  216. package/dist/plus/git-github/providers/github/tags.js +35 -36
  217. package/dist/plus/git-github/providers/github/tags.js.map +1 -1
  218. package/dist/plus/git-github/providers/githubGitProvider.d.ts.map +1 -1
  219. package/dist/plus/git-github/providers/githubGitProvider.js.map +1 -1
  220. package/dist/utils/color.d.ts.map +1 -1
  221. package/dist/utils/color.js.map +1 -1
  222. package/dist/utils/decorators/serializable.d.ts.map +1 -1
  223. package/dist/utils/decorators/serializable.js.map +1 -1
  224. package/dist/utils/dedupedAsyncCache.d.ts +37 -0
  225. package/dist/utils/dedupedAsyncCache.d.ts.map +1 -0
  226. package/dist/utils/dedupedAsyncCache.js +68 -0
  227. package/dist/utils/dedupedAsyncCache.js.map +1 -0
  228. package/dist/utils/diff.d.ts +2 -0
  229. package/dist/utils/diff.d.ts.map +1 -0
  230. package/dist/utils/diff.js +53 -0
  231. package/dist/utils/diff.js.map +1 -0
  232. package/dist/utils/disposable.d.ts.map +1 -1
  233. package/dist/utils/disposable.js.map +1 -1
  234. package/dist/utils/env/node/exec.d.ts.map +1 -1
  235. package/dist/utils/env/node/exec.js.map +1 -1
  236. package/dist/utils/error.d.ts.map +1 -1
  237. package/dist/utils/error.js.map +1 -1
  238. package/dist/utils/iterable.d.ts.map +1 -1
  239. package/dist/utils/iterable.js.map +1 -1
  240. package/dist/utils/logger.d.ts.map +1 -1
  241. package/dist/utils/logger.js.map +1 -1
  242. package/dist/utils/lruMap.d.ts +9 -0
  243. package/dist/utils/lruMap.d.ts.map +1 -1
  244. package/dist/utils/lruMap.js +26 -4
  245. package/dist/utils/lruMap.js.map +1 -1
  246. package/dist/utils/markdown.d.ts.map +1 -1
  247. package/dist/utils/markdown.js.map +1 -1
  248. package/dist/utils/mru.d.ts.map +1 -1
  249. package/dist/utils/mru.js.map +1 -1
  250. package/dist/utils/path.d.ts.map +1 -1
  251. package/dist/utils/path.js.map +1 -1
  252. package/dist/utils/promise.d.ts +1 -0
  253. package/dist/utils/promise.d.ts.map +1 -1
  254. package/dist/utils/promise.js +17 -0
  255. package/dist/utils/promise.js.map +1 -1
  256. package/dist/utils/promiseCache.d.ts +10 -0
  257. package/dist/utils/promiseCache.d.ts.map +1 -1
  258. package/dist/utils/promiseCache.js +22 -0
  259. package/dist/utils/promiseCache.js.map +1 -1
  260. package/dist/utils/string.d.ts.map +1 -1
  261. package/dist/utils/string.js.map +1 -1
  262. package/dist/utils/uri.d.ts.map +1 -1
  263. package/dist/utils/uri.js.map +1 -1
  264. package/dist/utils/version.d.ts.map +1 -1
  265. package/dist/utils/version.js.map +1 -1
  266. package/package.json +13 -1
  267. package/src/git/cache.ts +142 -28
  268. package/src/git/models/commit.ts +1 -0
  269. package/src/git/models/reference.ts +33 -0
  270. package/src/git/models/remote.ts +1 -0
  271. package/src/git/models/repository.ts +21 -3
  272. package/src/git/models/search.ts +2 -2
  273. package/src/git/models/worktree.ts +10 -2
  274. package/src/git/parsers/diffParser.ts +2 -0
  275. package/src/git/providers/branches.ts +22 -4
  276. package/src/git/providers/config.ts +2 -0
  277. package/src/git/providers/operations.ts +44 -0
  278. package/src/git/providers/pausedOperations.ts +1 -0
  279. package/src/git/providers/refs.ts +32 -3
  280. package/src/git/providers/staging.ts +12 -0
  281. package/src/git/providers/status.ts +6 -1
  282. package/src/git/remotes/azure-devops.ts +2 -0
  283. package/src/git/{exec.types.ts → run.types.ts} +22 -2
  284. package/src/git/service.ts +1 -0
  285. package/src/git/utils/autolink.utils.ts +1 -0
  286. package/src/git/utils/blame.utils.ts +2 -0
  287. package/src/git/utils/conflictResolution.utils.ts +31 -0
  288. package/src/git/utils/fileStatus.utils.ts +7 -1
  289. package/src/git/utils/search.utils.ts +2 -0
  290. package/src/git/utils/sorting.ts +17 -0
  291. package/src/git/utils/status.utils.ts +1 -0
  292. package/src/git/watching/classifyChange.ts +9 -0
  293. package/src/git/watching/gitIgnoreFilter.ts +2 -2
  294. package/src/git/watching/initWatcher.ts +2 -0
  295. package/src/git/watching/watchGroup.ts +3 -0
  296. package/src/git/watching/watchService.ts +38 -5
  297. package/src/git/watching/watchSession.ts +10 -0
  298. package/src/git-cli/exec/exec.types.ts +2 -2
  299. package/src/git-cli/exec/git.ts +6 -5
  300. package/src/git-cli/exec/gitQueue.ts +41 -12
  301. package/src/git-cli/parsers/blameParser.ts +1 -0
  302. package/src/git-cli/parsers/logParser.ts +1 -0
  303. package/src/git-cli/parsers/refParser.ts +33 -34
  304. package/src/git-cli/providers/blame.ts +1 -0
  305. package/src/git-cli/providers/branches.ts +164 -93
  306. package/src/git-cli/providers/commits.ts +83 -37
  307. package/src/git-cli/providers/config.ts +41 -2
  308. package/src/git-cli/providers/diff.ts +8 -2
  309. package/src/git-cli/providers/graph.ts +11 -2
  310. package/src/git-cli/providers/operations.ts +186 -49
  311. package/src/git-cli/providers/patch.ts +1 -0
  312. package/src/git-cli/providers/pausedOperations.ts +8 -0
  313. package/src/git-cli/providers/refs.ts +247 -3
  314. package/src/git-cli/providers/revision.ts +2 -2
  315. package/src/git-cli/providers/staging.ts +33 -0
  316. package/src/git-cli/providers/status.ts +15 -4
  317. package/src/git-cli/providers/tags.ts +15 -16
  318. package/src/ipc/discovery.ts +56 -0
  319. package/src/ipc/ipcServer.ts +171 -0
  320. package/src/plus/agents/providers/claudeCodeProvider.ts +1782 -0
  321. package/src/plus/agents/providers/claudeCodeTranscript.ts +214 -0
  322. package/src/plus/agents/sanitizePrompt.ts +109 -0
  323. package/src/plus/agents/stateMachine.ts +197 -0
  324. package/src/plus/agents/types.ts +277 -0
  325. package/src/plus/ai/errors.ts +40 -0
  326. package/src/plus/ai/models/promptTemplates.ts +13 -0
  327. package/src/plus/ai/prompts.ts +49 -8
  328. package/src/plus/ai/utils/results.utils.ts +2 -0
  329. package/src/plus/git-github/api/github.ts +199 -53
  330. package/src/plus/git-github/api/types.ts +15 -0
  331. package/src/plus/git-github/models.ts +1 -1
  332. package/src/plus/git-github/providers/github/blame.ts +2 -0
  333. package/src/plus/git-github/providers/github/branches.ts +61 -31
  334. package/src/plus/git-github/providers/github/commits.ts +231 -160
  335. package/src/plus/git-github/providers/github/diff.ts +27 -19
  336. package/src/plus/git-github/providers/github/refs.ts +57 -22
  337. package/src/plus/git-github/providers/github/revision.ts +1 -2
  338. package/src/plus/git-github/providers/github/status.ts +6 -1
  339. package/src/plus/git-github/providers/github/tags.ts +61 -62
  340. package/src/plus/git-github/providers/githubGitProvider.ts +1 -0
  341. package/src/utils/color.ts +2 -0
  342. package/src/utils/decorators/serializable.ts +1 -0
  343. package/src/utils/dedupedAsyncCache.ts +74 -0
  344. package/src/utils/diff.ts +61 -0
  345. package/src/utils/disposable.ts +2 -0
  346. package/src/utils/env/node/exec.ts +2 -0
  347. package/src/utils/error.ts +1 -0
  348. package/src/utils/iterable.ts +3 -0
  349. package/src/utils/logger.ts +1 -0
  350. package/src/utils/lruMap.ts +29 -4
  351. package/src/utils/markdown.ts +1 -0
  352. package/src/utils/mru.ts +2 -0
  353. package/src/utils/path.ts +1 -0
  354. package/src/utils/promise.ts +22 -0
  355. package/src/utils/promiseCache.ts +24 -0
  356. package/src/utils/string.ts +2 -0
  357. package/src/utils/uri.ts +1 -0
  358. package/src/utils/version.ts +1 -0
  359. package/dist/git/exec.types.d.ts.map +0 -1
  360. package/dist/git/exec.types.js +0 -2
  361. package/dist/git/exec.types.js.map +0 -1
@@ -1,19 +1,27 @@
1
1
  import type { Cache } from '../../git/cache.js';
2
2
  import type { GitServiceContext } from '../../git/context.js';
3
3
  import type { GitBranch } from '../../git/models/branch.js';
4
- import type { GitReference } from '../../git/models/reference.js';
4
+ import type { GitReference, GitRefTip, RefRecord } from '../../git/models/reference.js';
5
5
  import { deletedOrMissing } from '../../git/models/revision.js';
6
6
  import type { GitTag } from '../../git/models/tag.js';
7
7
  import type { GitRefsSubProvider } from '../../git/providers/refs.js';
8
+ import type { GitCommandPriority } from '../../git/run.types.js';
9
+ import { isRemoteHEAD } from '../../git/utils/branch.utils.js';
8
10
  import { createReference } from '../../git/utils/reference.utils.js';
9
11
  import { isSha, isShaWithOptionalRevisionSuffix, isUncommitted } from '../../git/utils/revision.utils.js';
10
- import { isCancellationError } from '../../utils/cancellation.js';
12
+ import { compareRefTips } from '../../git/utils/sorting.js';
13
+ import { CancellationError, isCancellationError } from '../../utils/cancellation.js';
11
14
  import { debug, trace } from '../../utils/decorators/log.js';
15
+ import { createDisposable } from '../../utils/disposable.js';
12
16
  import { getScopedLogger } from '../../utils/logger.scoped.js';
17
+ import { maybeStopWatch } from '../../utils/stopwatch.js';
18
+ import { iterateAsyncByDelimiter } from '../../utils/string.js';
13
19
  import type { Uri } from '../../utils/uri.js';
14
20
  import { toFsPath } from '../../utils/uri.js';
15
21
  import type { CliGitProviderInternal } from '../cliGitProvider.js';
16
22
  import type { Git } from '../exec/git.js';
23
+ import { gitConfigsBranch } from '../exec/git.js';
24
+ import { getRefParser } from '../parsers/refParser.js';
17
25
 
18
26
  export class RefsGitSubProvider implements GitRefsSubProvider {
19
27
  constructor(
@@ -33,12 +41,245 @@ export class RefsGitSubProvider implements GitRefsSubProvider {
33
41
  }
34
42
  }
35
43
 
44
+ /**
45
+ * Raw `git for-each-ref` records covering branches, remotes, and tags in a single pass.
46
+ * CLI-internal — siblings call via `this.provider.refs.getRefs(...)`. The `RefRecord` shape
47
+ * is `for-each-ref`-specific and intentionally absent from the public `GitRefsSubProvider`
48
+ * interface.
49
+ */
50
+ @debug()
51
+ async getRefs(repoPath: string, cancellation?: AbortSignal): Promise<RefRecord[]> {
52
+ if (!repoPath) return [];
53
+
54
+ const scope = getScopedLogger();
55
+
56
+ return this.cache.getRefs(
57
+ repoPath,
58
+ async (commonPath, cacheable, signal) => {
59
+ try {
60
+ const supported = await this.git.supported('git:for-each-ref');
61
+ const parser = getRefParser(supported);
62
+ const result = await this.git.run(
63
+ { cwd: commonPath, cancellation: signal, configs: gitConfigsBranch, errors: 'ignore' },
64
+ 'for-each-ref',
65
+ ...parser.arguments,
66
+ 'refs/heads/',
67
+ 'refs/remotes/',
68
+ 'refs/tags/',
69
+ );
70
+ if (!result?.stdout) return [];
71
+
72
+ using sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });
73
+
74
+ const records = [...parser.parse(result.stdout)];
75
+
76
+ sw?.stop({ suffix: ` parsed ${records.length} ref records` });
77
+
78
+ return records;
79
+ } catch (ex) {
80
+ cacheable?.invalidate();
81
+ if (isCancellationError(ex)) throw ex;
82
+
83
+ scope?.error(ex);
84
+ return [];
85
+ }
86
+ },
87
+ cancellation,
88
+ );
89
+ }
90
+
91
+ @debug()
92
+ async getRefTips(
93
+ repoPath: string,
94
+ options?: { include?: ReadonlyArray<'heads' | 'remotes' | 'tags'> },
95
+ cancellation?: AbortSignal,
96
+ ): Promise<GitRefTip[]> {
97
+ if (!repoPath) return [];
98
+
99
+ const scope = getScopedLogger();
100
+
101
+ // Cache always holds the full set; subset filtering is applied on read so callers asking
102
+ // for different subsets share one cache entry.
103
+ const all = await this.cache.getRefTips(
104
+ repoPath,
105
+ async (_commonPath, _cacheable, signal) => {
106
+ const records = await this.getRefs(repoPath, signal);
107
+
108
+ using sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });
109
+
110
+ const tips: GitRefTip[] = [];
111
+ for (const record of records) {
112
+ const fullName = record.name;
113
+ if (!fullName) continue;
114
+ // Skip refs/remotes/<remote>/HEAD — symbolic, not a real tip.
115
+ if (isRemoteHEAD(fullName)) continue;
116
+
117
+ let type: GitRefTip['type'];
118
+ let name: string;
119
+ if (fullName.startsWith('refs/heads/')) {
120
+ type = 'branch';
121
+ name = fullName.substring(11);
122
+ } else if (fullName.startsWith('refs/remotes/')) {
123
+ type = 'remote';
124
+ name = fullName.substring(13);
125
+ } else if (fullName.startsWith('refs/tags/')) {
126
+ type = 'tag';
127
+ name = fullName.substring(10);
128
+ } else {
129
+ continue;
130
+ }
131
+
132
+ // Annotated tags: peeledObjectname is the commit SHA; objectname is the tag-object SHA.
133
+ // Lightweight tags / branches: peeledObjectname is empty; objectname is already the commit SHA.
134
+ const sha = record.peeledObjectname || record.objectname;
135
+
136
+ tips.push({ type: type, name: name, fullName: fullName, sha: sha });
137
+ }
138
+
139
+ sw?.stop({ suffix: ` projected ${tips.length} ref tips` });
140
+
141
+ return tips;
142
+ },
143
+ cancellation,
144
+ );
145
+
146
+ const include = options?.include;
147
+ if (include == null || (include.includes('heads') && include.includes('remotes') && include.includes('tags'))) {
148
+ return all;
149
+ }
150
+
151
+ return all.filter(r => {
152
+ switch (r.type) {
153
+ case 'branch':
154
+ return include.includes('heads');
155
+ case 'remote':
156
+ return include.includes('remotes');
157
+ case 'tag':
158
+ return include.includes('tags');
159
+ }
160
+ });
161
+ }
162
+
163
+ @debug()
164
+ async getRefsContainingShas(
165
+ repoPath: string,
166
+ shas: ReadonlySet<string> | readonly string[],
167
+ oldestSha: string,
168
+ options?: { include?: ReadonlyArray<'heads' | 'remotes' | 'tags'> },
169
+ cancellation?: AbortSignal,
170
+ ): Promise<Map<string, GitRefTip[]>> {
171
+ const targetShas = shas instanceof Set ? shas : new Set(shas);
172
+ if (!targetShas.size || !oldestSha) return new Map();
173
+
174
+ const scope = getScopedLogger();
175
+
176
+ const tips = await this.getRefTips(repoPath, options, cancellation);
177
+ if (cancellation?.aborted) throw new CancellationError();
178
+ if (!tips.length) return new Map();
179
+
180
+ // Index tips by full ref name (for projection back to GitRefTip later) and seed the
181
+ // propagation map by tip SHA. Multiple refs sharing a tip (e.g. local + remote-tracking)
182
+ // collapse into one Set entry whose union covers all of them.
183
+ const tipsByName = new Map<string, GitRefTip>();
184
+ const propMap = new Map<string, Set<string>>();
185
+ for (const tip of tips) {
186
+ tipsByName.set(tip.fullName, tip);
187
+ let names = propMap.get(tip.sha);
188
+ if (names == null) {
189
+ names = new Set();
190
+ propMap.set(tip.sha, names);
191
+ }
192
+ names.add(tip.fullName);
193
+ }
194
+
195
+ using sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });
196
+
197
+ // `^<oldestSha>^@` excludes the parents of <oldestSha> and everything older. When <oldestSha>
198
+ // is a root commit, `^@` resolves to nothing and the walk is naturally unbounded — git
199
+ // doesn't error in that case (no negative refs to apply).
200
+ const stream = this.git.stream(
201
+ { cwd: repoPath, cancellation: cancellation, configs: gitConfigsBranch },
202
+ 'rev-list',
203
+ '--topo-order',
204
+ '--parents',
205
+ '--all',
206
+ `^${oldestSha}^@`,
207
+ );
208
+ using _streamDisposer = createDisposable(() => void stream.return?.(undefined));
209
+
210
+ // Topological propagation: `--topo-order` emits all children of X before X's own line, so
211
+ // by the time we process "X P1 P2..." every child has already merged its set into X. We
212
+ // then forward X's accumulated set to each parent — one-pass and correct.
213
+ try {
214
+ for await (const line of iterateAsyncByDelimiter(stream, '\n')) {
215
+ if (cancellation?.aborted) throw new CancellationError();
216
+ if (!line) continue;
217
+
218
+ const firstSpace = line.indexOf(' ');
219
+ const sha = firstSpace === -1 ? line : line.substring(0, firstSpace);
220
+ if (!sha) continue;
221
+
222
+ const refs = propMap.get(sha);
223
+ if (!refs?.size) continue;
224
+
225
+ if (firstSpace === -1) continue; // No parents — nothing to propagate to
226
+
227
+ // Walk parent SHAs by index without splitting the whole line.
228
+ let start = firstSpace + 1;
229
+ while (start < line.length) {
230
+ const next = line.indexOf(' ', start);
231
+ const parentSha = next === -1 ? line.substring(start) : line.substring(start, next);
232
+ if (parentSha) {
233
+ let parentRefs = propMap.get(parentSha);
234
+ if (parentRefs == null) {
235
+ parentRefs = new Set(refs);
236
+ propMap.set(parentSha, parentRefs);
237
+ } else {
238
+ for (const name of refs) {
239
+ parentRefs.add(name);
240
+ }
241
+ }
242
+ }
243
+ if (next === -1) break;
244
+
245
+ start = next + 1;
246
+ }
247
+ }
248
+ } catch (ex) {
249
+ if (isCancellationError(ex)) throw ex;
250
+
251
+ scope?.error(ex);
252
+ return new Map();
253
+ }
254
+
255
+ // Project to targets, materialize GitRefTip[], sort.
256
+ const result = new Map<string, GitRefTip[]>();
257
+ for (const sha of targetShas) {
258
+ const names = propMap.get(sha);
259
+ if (!names?.size) continue;
260
+
261
+ const refs: GitRefTip[] = [];
262
+ for (const name of names) {
263
+ const tip = tipsByName.get(name);
264
+ if (tip != null) {
265
+ refs.push(tip);
266
+ }
267
+ }
268
+ refs.sort(compareRefTips);
269
+ result.set(sha, refs);
270
+ }
271
+
272
+ sw?.stop({ suffix: ` resolved ${result.size}/${targetShas.size} target shas` });
273
+
274
+ return result;
275
+ }
276
+
36
277
  @debug()
37
278
  async getMergeBase(
38
279
  repoPath: string,
39
280
  ref1: string,
40
281
  ref2: string,
41
- options?: { forkPoint?: boolean },
282
+ options?: { forkPoint?: boolean; priority?: GitCommandPriority },
42
283
  cancellation?: AbortSignal,
43
284
  ): Promise<string | undefined> {
44
285
  const scope = getScopedLogger();
@@ -52,6 +293,7 @@ export class RefsGitSubProvider implements GitRefsSubProvider {
52
293
  // cleared on 'heads'/'remotes' events when refs move. Web (no fs watcher) sees up to
53
294
  // `accessTTL` of staleness — acceptable trade-off for the perf win on graph/branch reads.
54
295
  caching: { cache: this.cache.gitResults, options: { accessTTL: 5 * 60 * 1000 } },
296
+ ...(options?.priority != null ? { priority: options.priority } : undefined),
55
297
  },
56
298
  'merge-base',
57
299
  options?.forkPoint ? '--fork-point' : undefined,
@@ -104,6 +346,7 @@ export class RefsGitSubProvider implements GitRefsSubProvider {
104
346
  async getSymbolicReferenceName(
105
347
  repoPath: string,
106
348
  ref: string,
349
+ options?: { priority?: GitCommandPriority },
107
350
  cancellation?: AbortSignal,
108
351
  ): Promise<string | undefined> {
109
352
  const supportsEndOfOptions = await this.git.supports('git:rev-parse:end-of-options');
@@ -117,6 +360,7 @@ export class RefsGitSubProvider implements GitRefsSubProvider {
117
360
  // gitResults cache is cleared on 'head' events. 60s TTL is the failsafe for watcher
118
361
  // latency / web — matches the other "resolve symbolic state" calls in commits.ts.
119
362
  caching: { cache: this.cache.gitResults, options: { accessTTL: 60 * 1000 } },
363
+ ...(options?.priority != null ? { priority: options.priority } : undefined),
120
364
  },
121
365
  'rev-parse',
122
366
  '--verify',
@@ -19,7 +19,7 @@ import { splitPath } from '../../utils/path.js';
19
19
  import type { Uri } from '../../utils/uri.js';
20
20
  import { toFsPath } from '../../utils/uri.js';
21
21
  import type { CliGitProviderInternal } from '../cliGitProvider.js';
22
- import type { GitErrorHandling, GitExecOptions } from '../exec/exec.types.js';
22
+ import type { GitErrorHandling, GitRunOptions } from '../exec/exec.types.js';
23
23
  import type { Git } from '../exec/git.js';
24
24
  import { defaultExceptionHandler, getGitCommandError, gitConfigsLog, GitErrors } from '../exec/git.js';
25
25
  import { parseGitLsFilesStaged } from '../parsers/indexParser.js';
@@ -165,7 +165,7 @@ export class RevisionGitSubProvider implements GitRevisionSubProvider {
165
165
  }
166
166
  if (isUncommitted(rev)) throw new Error(`ref=${rev} is uncommitted`);
167
167
 
168
- const opts: GitExecOptions = {
168
+ const opts: GitRunOptions = {
169
169
  configs: gitConfigsLog,
170
170
  cwd: root,
171
171
  encoding: options?.encoding ?? 'utf8',
@@ -56,6 +56,7 @@ export class StagingGitSubProvider implements GitStagingSubProvider {
56
56
  // Copy the current index to preserve staged state
57
57
  const gitDir = await this.provider.config.getGitDir?.(repoPath);
58
58
  if (gitDir == null) throw new Error(`Unable to determine git directory for ${repoPath}`);
59
+
59
60
  const currentIndex = joinPaths(gitDir.uri.fsPath, 'index');
60
61
  await fs.copyFile(currentIndex, tempIndex);
61
62
  break;
@@ -158,6 +159,38 @@ export class StagingGitSubProvider implements GitStagingSubProvider {
158
159
  await this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(directoryOrUri));
159
160
  }
160
161
 
162
+ @debug()
163
+ async removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {
164
+ const args = ['rm'];
165
+ if (options?.force) {
166
+ args.push('-f');
167
+ }
168
+ args.push('--', toFsPath(pathOrUri));
169
+ await this.git.run({ cwd: repoPath }, ...args);
170
+ }
171
+
172
+ @debug()
173
+ async removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {
174
+ const paths = pathsOrUris.map(toFsPath);
175
+ if (!paths.length) return;
176
+
177
+ const args: string[] = ['rm'];
178
+ if (options?.force) {
179
+ args.push('-f');
180
+ }
181
+ args.push('--');
182
+
183
+ // Calculate a safe batch size based on average path length
184
+ const avgPathLength = countStringLength(paths) / paths.length;
185
+ const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
186
+
187
+ // Process files in batches (will be a single batch if under the limit)
188
+ const batches = chunk(paths, batchSize);
189
+ for (const batch of batches) {
190
+ await this.git.run({ cwd: repoPath }, ...args, ...batch);
191
+ }
192
+ }
193
+
161
194
  @debug()
162
195
  async stageAll(repoPath: string): Promise<void> {
163
196
  await this.git.run({ cwd: repoPath }, 'add', '-A');
@@ -6,6 +6,7 @@ import type { GitConflictFile } from '../../git/models/staging.js';
6
6
  import { GitStatus } from '../../git/models/status.js';
7
7
  import type { GitStatusFile } from '../../git/models/statusFile.js';
8
8
  import type { GitStatusSubProvider, GitWorkingChangesState } from '../../git/providers/status.js';
9
+ import type { GitCommandPriority } from '../../git/run.types.js';
9
10
  import { isCancellationError } from '../../utils/cancellation.js';
10
11
  import { gate } from '../../utils/decorators/gate.js';
11
12
  import { debug } from '../../utils/decorators/log.js';
@@ -33,19 +34,27 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
33
34
 
34
35
  @gate(rp => rp ?? '')
35
36
  @debug()
36
- async getStatus(repoPath: string | undefined, cancellation?: AbortSignal): Promise<GitStatus | undefined> {
37
+ async getStatus(
38
+ repoPath: string | undefined,
39
+ options?: { priority?: GitCommandPriority },
40
+ cancellation?: AbortSignal,
41
+ ): Promise<GitStatus | undefined> {
37
42
  if (repoPath == null) return undefined;
38
43
 
39
44
  const porcelainVersion = (await this.git.supports('git:status:porcelain-v2')) ? 2 : 1;
40
45
 
41
- const result = await this.statusCore(repoPath, porcelainVersion, {}, cancellation);
46
+ const result = await this.statusCore(repoPath, porcelainVersion, { priority: options?.priority }, cancellation);
42
47
  const repoUri = fileUri(normalizePath(repoPath));
43
48
  const status = parseGitStatus(result.stdout, repoPath, porcelainVersion, p =>
44
49
  joinUriPath(repoUri, normalizePath(p)),
45
50
  );
46
51
 
47
52
  if (status?.detached) {
48
- const pausedOpStatus = await this.provider.pausedOps?.getPausedOperationStatus?.(repoPath, cancellation);
53
+ const pausedOpStatus = await this.provider.pausedOps?.getPausedOperationStatus?.(
54
+ repoPath,
55
+ undefined,
56
+ cancellation,
57
+ );
49
58
  if (pausedOpStatus?.type === 'rebase') {
50
59
  return new GitStatus(
51
60
  repoPath,
@@ -126,7 +135,7 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
126
135
  private async statusCore(
127
136
  repoPath: string,
128
137
  porcelainVersion: number = 1,
129
- options?: { similarityThreshold?: number },
138
+ options?: { similarityThreshold?: number; priority?: GitCommandPriority },
130
139
  cancellation?: AbortSignal,
131
140
  ...pathspecs: string[]
132
141
  ): Promise<GitResult> {
@@ -148,6 +157,7 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
148
157
  cancellation: cancellation,
149
158
  configs: gitConfigsStatus,
150
159
  env: { GIT_OPTIONAL_LOCKS: '0' },
160
+ ...(options?.priority != null ? { priority: options.priority } : undefined),
151
161
  },
152
162
  ...params,
153
163
  '--',
@@ -247,6 +257,7 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
247
257
  return result;
248
258
  } catch (ex) {
249
259
  if (isCancellationError(ex)) throw ex;
260
+
250
261
  scope?.error(ex);
251
262
  scope?.addExitInfo('error checking for changes');
252
263
  // Return all false on error for graceful degradation
@@ -16,7 +16,6 @@ import type { CliGitProviderInternal } from '../cliGitProvider.js';
16
16
  import type { GitResult } from '../exec/exec.types.js';
17
17
  import type { Git, GitError } from '../exec/git.js';
18
18
  import { getGitCommandError, gitConfigsBranch } from '../exec/git.js';
19
- import { getTagParser } from '../parsers/refParser.js';
20
19
 
21
20
  export class TagsGitSubProvider implements GitTagsSubProvider {
22
21
  constructor(
@@ -54,29 +53,29 @@ export class TagsGitSubProvider implements GitTagsSubProvider {
54
53
  // Prefer the aggregate signal from the cache; fall back to the caller's cancellation.
55
54
  signal ??= cancellation;
56
55
  try {
57
- const parser = getTagParser();
58
-
59
- const result = await this.git.run(
60
- { cwd: repoPath, cancellation: signal },
61
- 'for-each-ref',
62
- ...parser.arguments,
63
- 'refs/tags/',
64
- );
65
- if (!result.stdout) return emptyPagedResult;
56
+ const records = await this.provider.refs.getRefs(commonPath, signal);
57
+ if (!records.length) return emptyPagedResult;
66
58
 
67
59
  using sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });
68
60
 
69
61
  const tags: GitTag[] = [];
70
62
 
71
- for (const entry of parser.parse(result.stdout)) {
63
+ for (const record of records) {
64
+ const fullName = record.name;
65
+ if (!fullName.startsWith('refs/tags/')) continue;
66
+
67
+ // Annotated tags: peeledObjectname is the commit SHA; objectname is the tag-object SHA.
68
+ // Lightweight tags: peeledObjectname is empty; objectname is already the commit SHA.
69
+ const sha = record.peeledObjectname || record.objectname;
70
+
72
71
  tags.push(
73
72
  new GitTag(
74
73
  commonPath,
75
- entry.name,
76
- entry.sha || entry.tagSha,
77
- entry.message,
78
- entry.date ? new Date(entry.date) : undefined,
79
- entry.commitDate ? new Date(entry.commitDate) : undefined,
74
+ fullName,
75
+ sha,
76
+ record.subject,
77
+ record.creatorDate ? new Date(record.creatorDate) : undefined,
78
+ record.authorDate ? new Date(record.authorDate) : undefined,
80
79
  ),
81
80
  );
82
81
  }
@@ -0,0 +1,56 @@
1
+ import { mkdir, unlink, writeFile } from 'fs/promises';
2
+ import { tmpdir } from 'os';
3
+ import { join } from 'path';
4
+ import { ppid } from 'process';
5
+
6
+ /**
7
+ * Directory scanned by `gk` binaries (and `@gitkraken/core-gitlens` consumers) for the
8
+ * extension's CLI-capable IPC server discovery file. Anything written here is assumed
9
+ * by older `gk` versions to be a CLI server — do NOT write agent-only files here.
10
+ */
11
+ export const cliDiscoveryDir = join(tmpdir(), 'gitkraken', 'gitlens');
12
+
13
+ /**
14
+ * Directory scanned by peer GitLens windows for agent-session-capable IPC servers.
15
+ * Stable across GitLens versions; older windows still scan it, so don't move it.
16
+ */
17
+ export const agentDiscoveryDir = join(tmpdir(), 'gitkraken', 'gitlens', 'agents');
18
+
19
+ export interface IpcDiscoveryData {
20
+ token: string;
21
+ address: string;
22
+ port: number;
23
+ workspacePaths: string[];
24
+ // Optional fields — present when the writing capability needs them.
25
+ // Old gk binaries ignore unknown fields, so this stays back-compat.
26
+ ideName?: string;
27
+ ideDisplayName?: string;
28
+ scheme?: string;
29
+ pid?: number;
30
+ createdAt: string;
31
+ }
32
+
33
+ export function getDiscoveryFileName(port: number): string {
34
+ return `gitlens-ipc-server-${ppid}-${port}.json`;
35
+ }
36
+
37
+ export function getDiscoveryFilePath(dir: string, port: number): string {
38
+ return join(dir, getDiscoveryFileName(port));
39
+ }
40
+
41
+ export async function writeDiscoveryFile(dir: string, data: IpcDiscoveryData): Promise<string> {
42
+ const filePath = getDiscoveryFilePath(dir, data.port);
43
+ await mkdir(dir, { recursive: true, mode: 0o700 });
44
+ await writeFile(filePath, JSON.stringify(data, null, 2), { mode: 0o600 });
45
+ return filePath;
46
+ }
47
+
48
+ export async function cleanupDiscoveryFile(filePath: string | undefined): Promise<void> {
49
+ if (filePath == null) return;
50
+
51
+ try {
52
+ await unlink(filePath);
53
+ } catch {
54
+ // Ignore cleanup errors
55
+ }
56
+ }