gitx.do 0.1.0 → 0.1.2

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 (344) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +15 -415
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,1385 +0,0 @@
1
- /**
2
- * @fileoverview GitCapability TypeScript Interfaces
3
- *
4
- * This module defines the comprehensive TypeScript interfaces for the git capability,
5
- * designed for integration with Durable Objects as the $.git proxy. It provides
6
- * type definitions for all core git operations including:
7
- *
8
- * - **Repository operations**: clone, init, fetch, pull, push
9
- * - **Working tree operations**: add, commit, status, log, diff
10
- * - **Branch operations**: branch, checkout, merge
11
- * - **Low-level operations**: resolveRef, readObject
12
- *
13
- * The interfaces follow the existing patterns established in objects.ts and storage.ts,
14
- * using JSDoc comments and consistent naming conventions.
15
- *
16
- * @module types/capability
17
- *
18
- * @example
19
- * ```typescript
20
- * import type { GitCapability, GitStatus, Commit } from 'gitx.do'
21
- *
22
- * // Use in a Durable Object context as $.git
23
- * class MyDO extends DO {
24
- * async handleRequest(request: Request): Promise<Response> {
25
- * const status = await this.$.git.status()
26
- * if (status.staged.length > 0) {
27
- * const commit = await this.$.git.commit({ message: 'Auto-commit' })
28
- * console.log(`Created commit: ${commit.sha}`)
29
- * }
30
- * return new Response('OK')
31
- * }
32
- * }
33
- * ```
34
- */
35
- import type { Author, ObjectType } from './objects';
36
- /**
37
- * 40-character lowercase hexadecimal SHA-1 hash.
38
- *
39
- * @description
40
- * Type alias for SHA-1 hashes used throughout the git system.
41
- * All SHAs should be lowercase hexadecimal strings of exactly 40 characters.
42
- */
43
- export type SHA = string;
44
- /**
45
- * Git reference name.
46
- *
47
- * @description
48
- * Full ref path (e.g., 'refs/heads/main', 'refs/tags/v1.0.0', 'HEAD').
49
- * References are pointers to commits or other objects.
50
- */
51
- export type RefName = string;
52
- /**
53
- * Represents a Git commit with all metadata.
54
- *
55
- * @description
56
- * A complete commit representation including SHA, message, author information,
57
- * parent commits, and the tree SHA representing the project state at this commit.
58
- * This is the primary type returned by log and commit operations.
59
- *
60
- * @see Author - The author/committer identity type
61
- *
62
- * @example
63
- * ```typescript
64
- * const commits = await $.git.log({ maxCount: 10 })
65
- * for (const commit of commits) {
66
- * console.log(`${commit.sha.slice(0, 7)} ${commit.message.split('\n')[0]}`)
67
- * console.log(` Author: ${commit.author.name} <${commit.author.email}>`)
68
- * }
69
- * ```
70
- */
71
- export interface Commit {
72
- /** 40-character SHA-1 hash of the commit */
73
- sha: SHA;
74
- /** 40-character SHA-1 of the root tree object */
75
- tree: SHA;
76
- /** Parent commit SHAs (empty for root commit, multiple for merge commits) */
77
- parents: SHA[];
78
- /** Original author of the changes */
79
- author: Author;
80
- /** Person who created this commit object */
81
- committer: Author;
82
- /** Full commit message including subject and body */
83
- message: string;
84
- }
85
- /**
86
- * Represents a raw Git object with size metadata.
87
- *
88
- * @description
89
- * A low-level representation of any Git object (blob, tree, commit, tag)
90
- * with its type, raw binary data, and size. Used by readObject for accessing
91
- * objects directly. This extends the base GitObject from objects.ts with
92
- * an explicit size field.
93
- *
94
- * @see ObjectType - The four Git object types
95
- *
96
- * @example
97
- * ```typescript
98
- * const obj = await $.git.readObject('abc123...')
99
- * if (obj && obj.type === 'blob') {
100
- * const content = new TextDecoder().decode(obj.data)
101
- * console.log('File content:', content)
102
- * }
103
- * ```
104
- */
105
- export interface RawGitObject {
106
- /** The type of Git object */
107
- type: ObjectType;
108
- /** Raw binary data of the object */
109
- data: Uint8Array;
110
- /** Size of the object in bytes */
111
- size: number;
112
- }
113
- /**
114
- * Represents a Git reference with target and optional metadata.
115
- *
116
- * @description
117
- * A reference pointing to a commit or other object. Includes the full
118
- * ref name, target SHA, and optional symbolic target for HEAD-like refs.
119
- *
120
- * @example
121
- * ```typescript
122
- * const refs = await $.git.listRefs('refs/heads/')
123
- * for (const ref of refs) {
124
- * console.log(`${ref.name} -> ${ref.sha}`)
125
- * }
126
- * ```
127
- */
128
- export interface GitRef {
129
- /** Full ref name (e.g., 'refs/heads/main') */
130
- name: RefName;
131
- /** 40-character SHA-1 the ref points to */
132
- sha: SHA;
133
- /** For symbolic refs, the target ref name */
134
- symbolicTarget?: RefName;
135
- /** For annotated tags, the peeled (dereferenced) SHA */
136
- peeled?: SHA;
137
- }
138
- /**
139
- * Represents a Git branch with tracking information.
140
- *
141
- * @description
142
- * A branch with its current commit SHA and optional upstream tracking
143
- * information showing ahead/behind counts.
144
- *
145
- * @example
146
- * ```typescript
147
- * const branches = await $.git.branch({ all: true })
148
- * for (const branch of branches) {
149
- * let status = branch.name
150
- * if (branch.upstream) {
151
- * status += ` [${branch.upstream}: +${branch.ahead}/-${branch.behind}]`
152
- * }
153
- * console.log(branch.current ? `* ${status}` : ` ${status}`)
154
- * }
155
- * ```
156
- */
157
- export interface Branch {
158
- /** Branch name (without refs/heads/ prefix) */
159
- name: string;
160
- /** 40-character SHA-1 of the branch tip */
161
- sha: SHA;
162
- /** Whether this is the currently checked out branch */
163
- current: boolean;
164
- /** Upstream tracking branch name (e.g., 'origin/main') */
165
- upstream?: string;
166
- /** Commits ahead of upstream */
167
- ahead?: number;
168
- /** Commits behind upstream */
169
- behind?: number;
170
- }
171
- /**
172
- * Represents a Git tag.
173
- *
174
- * @description
175
- * A tag reference pointing to a commit (or other object). For annotated tags,
176
- * includes tagger information and message.
177
- *
178
- * @example
179
- * ```typescript
180
- * const tags = await $.git.listTags()
181
- * for (const tag of tags) {
182
- * console.log(`${tag.name} -> ${tag.sha}`)
183
- * if (tag.message) {
184
- * console.log(` ${tag.message}`)
185
- * }
186
- * }
187
- * ```
188
- */
189
- export interface Tag {
190
- /** Tag name (without refs/tags/ prefix) */
191
- name: string;
192
- /** SHA of the tag object (for annotated) or target (for lightweight) */
193
- sha: SHA;
194
- /** SHA of the tagged object (commit) after dereferencing */
195
- target: SHA;
196
- /** Whether this is an annotated tag */
197
- annotated: boolean;
198
- /** Tagger information (annotated tags only) */
199
- tagger?: Author;
200
- /** Tag message (annotated tags only) */
201
- message?: string;
202
- }
203
- /**
204
- * File status in the working tree or index.
205
- *
206
- * @description
207
- * Represents the status of a single file, including its path and
208
- * status codes for both the index (staged) and working tree.
209
- *
210
- * Status codes:
211
- * - ' ' (space): Unmodified
212
- * - 'M': Modified
213
- * - 'A': Added
214
- * - 'D': Deleted
215
- * - 'R': Renamed
216
- * - 'C': Copied
217
- * - 'U': Updated but unmerged
218
- * - '?': Untracked
219
- * - '!': Ignored
220
- *
221
- * @example
222
- * ```typescript
223
- * const status = await $.git.status()
224
- * for (const file of status.files) {
225
- * console.log(`${file.index}${file.workingTree} ${file.path}`)
226
- * }
227
- * ```
228
- */
229
- export interface FileStatus {
230
- /** File path relative to repository root */
231
- path: string;
232
- /** Status in the index (staged area) */
233
- index: ' ' | 'M' | 'A' | 'D' | 'R' | 'C' | 'U' | '?' | '!';
234
- /** Status in the working tree */
235
- workingTree: ' ' | 'M' | 'A' | 'D' | 'R' | 'C' | 'U' | '?' | '!';
236
- /** Original path for renamed/copied files */
237
- origPath?: string;
238
- }
239
- /**
240
- * Working tree status result.
241
- *
242
- * @description
243
- * Complete status of the repository working tree including current branch,
244
- * HEAD commit, and categorized file lists for staged, modified, and untracked files.
245
- *
246
- * @see FileStatus - Individual file status representation
247
- *
248
- * @example
249
- * ```typescript
250
- * const status = await $.git.status()
251
- * console.log(`On branch ${status.branch}`)
252
- * if (status.staged.length > 0) {
253
- * console.log('Changes to be committed:')
254
- * status.staged.forEach(f => console.log(` ${f.path}`))
255
- * }
256
- * if (status.modified.length > 0) {
257
- * console.log('Changes not staged for commit:')
258
- * status.modified.forEach(f => console.log(` ${f.path}`))
259
- * }
260
- * ```
261
- */
262
- export interface GitStatus {
263
- /** Current branch name (null if detached HEAD) */
264
- branch: string | null;
265
- /** Current HEAD commit SHA */
266
- head: SHA | null;
267
- /** Whether the repository is in a clean state */
268
- clean: boolean;
269
- /** Whether HEAD is detached */
270
- detached: boolean;
271
- /** Upstream tracking branch */
272
- upstream?: string;
273
- /** Commits ahead of upstream */
274
- ahead?: number;
275
- /** Commits behind upstream */
276
- behind?: number;
277
- /** All files with their status codes */
278
- files: FileStatus[];
279
- /** Files staged for commit */
280
- staged: FileStatus[];
281
- /** Modified files not yet staged */
282
- modified: FileStatus[];
283
- /** Untracked files */
284
- untracked: FileStatus[];
285
- /** Files with merge conflicts */
286
- conflicted: FileStatus[];
287
- }
288
- /**
289
- * A single hunk in a diff.
290
- *
291
- * @description
292
- * Represents a contiguous section of changes in a file diff,
293
- * with line numbers and the actual diff lines.
294
- *
295
- * @example
296
- * ```typescript
297
- * for (const hunk of fileDiff.hunks) {
298
- * console.log(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`)
299
- * for (const line of hunk.lines) {
300
- * console.log(line)
301
- * }
302
- * }
303
- * ```
304
- */
305
- export interface DiffHunk {
306
- /** Starting line number in the old file */
307
- oldStart: number;
308
- /** Number of lines in the old file */
309
- oldLines: number;
310
- /** Starting line number in the new file */
311
- newStart: number;
312
- /** Number of lines in the new file */
313
- newLines: number;
314
- /** Diff lines (prefixed with ' ', '+', or '-') */
315
- lines: string[];
316
- }
317
- /**
318
- * Diff result for a single file.
319
- *
320
- * @description
321
- * Complete diff information for a single file including the change type,
322
- * old/new paths, mode changes, and diff hunks.
323
- *
324
- * @see DiffHunk - Individual diff hunk
325
- *
326
- * @example
327
- * ```typescript
328
- * const diff = await $.git.diff({ cached: true })
329
- * for (const file of diff.files) {
330
- * console.log(`${file.status} ${file.newPath || file.oldPath}`)
331
- * console.log(`+${file.additions} -${file.deletions}`)
332
- * }
333
- * ```
334
- */
335
- export interface FileDiff {
336
- /** Type of change */
337
- status: 'added' | 'deleted' | 'modified' | 'renamed' | 'copied';
338
- /** Old file path (null for added files) */
339
- oldPath: string | null;
340
- /** New file path (null for deleted files) */
341
- newPath: string | null;
342
- /** Old file mode */
343
- oldMode?: string;
344
- /** New file mode */
345
- newMode?: string;
346
- /** Old blob SHA */
347
- oldSha?: SHA;
348
- /** New blob SHA */
349
- newSha?: SHA;
350
- /** Whether the file is binary */
351
- binary: boolean;
352
- /** Number of added lines */
353
- additions: number;
354
- /** Number of deleted lines */
355
- deletions: number;
356
- /** Diff hunks (empty for binary files) */
357
- hunks: DiffHunk[];
358
- }
359
- /**
360
- * Complete diff result.
361
- *
362
- * @description
363
- * Result of a diff operation containing all changed files and summary statistics.
364
- *
365
- * @example
366
- * ```typescript
367
- * const diff = await $.git.diff({ from: 'HEAD~3', to: 'HEAD' })
368
- * console.log(`${diff.files.length} files changed`)
369
- * console.log(`+${diff.additions} -${diff.deletions}`)
370
- * ```
371
- */
372
- export interface DiffResult {
373
- /** Individual file diffs */
374
- files: FileDiff[];
375
- /** Total number of files changed */
376
- filesChanged: number;
377
- /** Total lines added */
378
- additions: number;
379
- /** Total lines deleted */
380
- deletions: number;
381
- }
382
- /**
383
- * Options for cloning a repository.
384
- *
385
- * @description
386
- * Configuration for the clone operation including remote URL,
387
- * branch selection, depth limits, and authentication.
388
- *
389
- * @example
390
- * ```typescript
391
- * await $.git.clone({
392
- * url: 'https://github.com/user/repo.git',
393
- * branch: 'develop',
394
- * depth: 1,
395
- * auth: { token: process.env.GITHUB_TOKEN }
396
- * })
397
- * ```
398
- */
399
- export interface CloneOptions {
400
- /** Remote repository URL */
401
- url: string;
402
- /** Branch to clone (defaults to remote default) */
403
- branch?: string;
404
- /** Clone depth (shallow clone if specified) */
405
- depth?: number;
406
- /** Clone single branch only */
407
- singleBranch?: boolean;
408
- /** Skip checkout after clone */
409
- noCheckout?: boolean;
410
- /** Authentication credentials */
411
- auth?: AuthOptions;
412
- /** Progress callback */
413
- onProgress?: ProgressCallback;
414
- }
415
- /**
416
- * Options for initializing a repository.
417
- *
418
- * @description
419
- * Configuration for the init operation including initial branch name
420
- * and whether to create a bare repository.
421
- *
422
- * @example
423
- * ```typescript
424
- * await $.git.init({
425
- * defaultBranch: 'main',
426
- * bare: false
427
- * })
428
- * ```
429
- */
430
- export interface InitOptions {
431
- /** Initial branch name (defaults to 'main') */
432
- defaultBranch?: string;
433
- /** Create a bare repository */
434
- bare?: boolean;
435
- }
436
- /**
437
- * Options for fetching from a remote.
438
- *
439
- * @description
440
- * Configuration for the fetch operation including remote name,
441
- * refspecs, depth, and tag handling.
442
- *
443
- * @example
444
- * ```typescript
445
- * await $.git.fetch({
446
- * remote: 'origin',
447
- * prune: true,
448
- * tags: true
449
- * })
450
- * ```
451
- */
452
- export interface FetchOptions {
453
- /** Remote name (defaults to 'origin') */
454
- remote?: string;
455
- /** Specific refs to fetch */
456
- refspecs?: string[];
457
- /** Fetch depth for shallow repositories */
458
- depth?: number;
459
- /** Remove remote-tracking refs that no longer exist */
460
- prune?: boolean;
461
- /** Fetch tags */
462
- tags?: boolean;
463
- /** Force update of local refs */
464
- force?: boolean;
465
- /** Authentication credentials */
466
- auth?: AuthOptions;
467
- /** Progress callback */
468
- onProgress?: ProgressCallback;
469
- }
470
- /**
471
- * Options for pulling from a remote.
472
- *
473
- * @description
474
- * Configuration for the pull operation (fetch + merge or rebase).
475
- *
476
- * @example
477
- * ```typescript
478
- * await $.git.pull({
479
- * remote: 'origin',
480
- * branch: 'main',
481
- * rebase: true
482
- * })
483
- * ```
484
- */
485
- export interface PullOptions {
486
- /** Remote name (defaults to 'origin') */
487
- remote?: string;
488
- /** Branch to pull (defaults to current upstream) */
489
- branch?: string;
490
- /** Use rebase instead of merge */
491
- rebase?: boolean;
492
- /** Fast-forward only (fail if not possible) */
493
- fastForwardOnly?: boolean;
494
- /** Authentication credentials */
495
- auth?: AuthOptions;
496
- /** Progress callback */
497
- onProgress?: ProgressCallback;
498
- }
499
- /**
500
- * Options for pushing to a remote.
501
- *
502
- * @description
503
- * Configuration for the push operation including remote, branches,
504
- * and force/delete options.
505
- *
506
- * @example
507
- * ```typescript
508
- * await $.git.push({
509
- * remote: 'origin',
510
- * branch: 'feature-branch',
511
- * setUpstream: true
512
- * })
513
- * ```
514
- */
515
- export interface PushOptions {
516
- /** Remote name (defaults to 'origin') */
517
- remote?: string;
518
- /** Branch to push (defaults to current branch) */
519
- branch?: string;
520
- /** Refspecs to push */
521
- refspecs?: string[];
522
- /** Force push (overwrites remote history) */
523
- force?: boolean;
524
- /** Force with lease (safe force push) */
525
- forceWithLease?: boolean;
526
- /** Delete the remote branch */
527
- delete?: boolean;
528
- /** Set upstream tracking */
529
- setUpstream?: boolean;
530
- /** Push tags */
531
- tags?: boolean;
532
- /** Push all branches */
533
- all?: boolean;
534
- /** Authentication credentials */
535
- auth?: AuthOptions;
536
- /** Progress callback */
537
- onProgress?: ProgressCallback;
538
- }
539
- /**
540
- * Options for staging files.
541
- *
542
- * @description
543
- * Configuration for the add operation including file patterns
544
- * and force/update modes.
545
- *
546
- * @example
547
- * ```typescript
548
- * // Stage specific files
549
- * await $.git.add({ paths: ['src/index.ts', 'package.json'] })
550
- *
551
- * // Stage all changes
552
- * await $.git.add({ all: true })
553
- * ```
554
- */
555
- export interface AddOptions {
556
- /** File paths or glob patterns to add */
557
- paths?: string[];
558
- /** Add all changes including untracked files */
559
- all?: boolean;
560
- /** Update tracked files only */
561
- update?: boolean;
562
- /** Force add ignored files */
563
- force?: boolean;
564
- /** Dry run (show what would be added) */
565
- dryRun?: boolean;
566
- }
567
- /**
568
- * Options for creating a commit.
569
- *
570
- * @description
571
- * Configuration for the commit operation including message,
572
- * author information, and amendment options.
573
- *
574
- * @example
575
- * ```typescript
576
- * const commit = await $.git.commit({
577
- * message: 'feat: add new feature\n\nDetailed description here.',
578
- * author: {
579
- * name: 'Alice',
580
- * email: 'alice@example.com',
581
- * timestamp: Date.now() / 1000,
582
- * timezone: '+0000'
583
- * }
584
- * })
585
- * ```
586
- */
587
- export interface CommitOptions {
588
- /** Commit message */
589
- message: string;
590
- /** Author information (defaults to configured user) */
591
- author?: Author;
592
- /** Committer information (defaults to author) */
593
- committer?: Author;
594
- /** Amend the previous commit */
595
- amend?: boolean;
596
- /** Allow empty commits (no changes) */
597
- allowEmpty?: boolean;
598
- /** Sign the commit with GPG */
599
- gpgSign?: boolean;
600
- /** Skip pre-commit and commit-msg hooks */
601
- noVerify?: boolean;
602
- }
603
- /**
604
- * Options for viewing status.
605
- *
606
- * @description
607
- * Configuration for the status operation including ignored files
608
- * and untracked files handling.
609
- *
610
- * @example
611
- * ```typescript
612
- * const status = await $.git.status({
613
- * includeIgnored: true,
614
- * untrackedFiles: 'all'
615
- * })
616
- * ```
617
- */
618
- export interface StatusOptions {
619
- /** Include ignored files in the status */
620
- includeIgnored?: boolean;
621
- /** Untracked files mode: 'no', 'normal', 'all' */
622
- untrackedFiles?: 'no' | 'normal' | 'all';
623
- /** Only check specific paths */
624
- paths?: string[];
625
- }
626
- /**
627
- * Options for viewing commit log.
628
- *
629
- * @description
630
- * Configuration for the log operation including commit range,
631
- * file filtering, and formatting options.
632
- *
633
- * @example
634
- * ```typescript
635
- * // Last 10 commits
636
- * const commits = await $.git.log({ maxCount: 10 })
637
- *
638
- * // Commits affecting a file
639
- * const fileHistory = await $.git.log({
640
- * path: 'src/index.ts',
641
- * follow: true
642
- * })
643
- * ```
644
- */
645
- export interface LogOptions {
646
- /** Starting commit ref (defaults to HEAD) */
647
- ref?: string;
648
- /** Maximum number of commits to return */
649
- maxCount?: number;
650
- /** Skip the first N commits */
651
- skip?: number;
652
- /** Only commits after this date */
653
- since?: Date | string;
654
- /** Only commits before this date */
655
- until?: Date | string;
656
- /** Only commits by this author (pattern match) */
657
- author?: string;
658
- /** Only commits matching this message pattern */
659
- grep?: string;
660
- /** Only commits affecting this path */
661
- path?: string;
662
- /** Follow file renames */
663
- follow?: boolean;
664
- /** First parent only (for merge commits) */
665
- firstParent?: boolean;
666
- /** Show all refs (not just from ref) */
667
- all?: boolean;
668
- }
669
- /**
670
- * Options for generating diffs.
671
- *
672
- * @description
673
- * Configuration for the diff operation including commit range,
674
- * context lines, and output options.
675
- *
676
- * @example
677
- * ```typescript
678
- * // Working tree vs staged
679
- * const diff = await $.git.diff()
680
- *
681
- * // Staged vs HEAD
682
- * const staged = await $.git.diff({ cached: true })
683
- *
684
- * // Between commits
685
- * const compare = await $.git.diff({
686
- * from: 'HEAD~5',
687
- * to: 'HEAD'
688
- * })
689
- * ```
690
- */
691
- export interface DiffOptions {
692
- /** Starting commit/tree (defaults to index) */
693
- from?: string;
694
- /** Ending commit/tree (defaults to working tree) */
695
- to?: string;
696
- /** Diff staged changes vs HEAD */
697
- cached?: boolean;
698
- /** Number of context lines */
699
- contextLines?: number;
700
- /** Detect renames */
701
- detectRenames?: boolean;
702
- /** Detect copies */
703
- detectCopies?: boolean;
704
- /** Only specific paths */
705
- paths?: string[];
706
- /** Ignore whitespace changes */
707
- ignoreWhitespace?: boolean;
708
- /** Show only file names */
709
- nameOnly?: boolean;
710
- /** Show file names with status */
711
- nameStatus?: boolean;
712
- }
713
- /**
714
- * Options for branch operations.
715
- *
716
- * @description
717
- * Configuration for listing, creating, or deleting branches.
718
- *
719
- * @example
720
- * ```typescript
721
- * // List all branches
722
- * const branches = await $.git.branch({ all: true })
723
- *
724
- * // Create a new branch
725
- * await $.git.branch({ create: 'feature/new', startPoint: 'develop' })
726
- *
727
- * // Delete a branch
728
- * await $.git.branch({ delete: 'old-branch' })
729
- * ```
730
- */
731
- export interface BranchOptions {
732
- /** List all branches (local and remote) */
733
- all?: boolean;
734
- /** List only remote branches */
735
- remotes?: boolean;
736
- /** Create a new branch with this name */
737
- create?: string;
738
- /** Delete branch with this name */
739
- delete?: string;
740
- /** Force delete (even if not merged) */
741
- force?: boolean;
742
- /** Starting point for new branch */
743
- startPoint?: string;
744
- /** Set up tracking for new branch */
745
- track?: string;
746
- /** Rename current branch to this name */
747
- rename?: string;
748
- /** Show verbose output (including tracking) */
749
- verbose?: boolean;
750
- }
751
- /**
752
- * Options for checkout operations.
753
- *
754
- * @description
755
- * Configuration for switching branches or restoring files.
756
- *
757
- * @example
758
- * ```typescript
759
- * // Switch to a branch
760
- * await $.git.checkout({ branch: 'develop' })
761
- *
762
- * // Create and switch to new branch
763
- * await $.git.checkout({ branch: 'feature/new', create: true })
764
- *
765
- * // Restore a file from HEAD
766
- * await $.git.checkout({ paths: ['src/index.ts'] })
767
- * ```
768
- */
769
- export interface CheckoutOptions {
770
- /** Branch name to checkout */
771
- branch?: string;
772
- /** Create branch if it doesn't exist */
773
- create?: boolean;
774
- /** Force checkout (discard local changes) */
775
- force?: boolean;
776
- /** Specific paths to checkout/restore */
777
- paths?: string[];
778
- /** Source commit/tree for restoring paths */
779
- source?: string;
780
- /** Detach HEAD at this commit */
781
- detach?: boolean;
782
- }
783
- /**
784
- * Options for merge operations.
785
- *
786
- * @description
787
- * Configuration for merging branches or commits.
788
- *
789
- * @example
790
- * ```typescript
791
- * // Merge a branch
792
- * const result = await $.git.merge({
793
- * branch: 'feature/new',
794
- * message: 'Merge feature/new into main'
795
- * })
796
- *
797
- * // Fast-forward only
798
- * await $.git.merge({ branch: 'develop', fastForwardOnly: true })
799
- * ```
800
- */
801
- export interface MergeOptions {
802
- /** Branch or commit to merge */
803
- branch: string;
804
- /** Merge commit message */
805
- message?: string;
806
- /** Fast-forward only (fail if not possible) */
807
- fastForwardOnly?: boolean;
808
- /** Never fast-forward (always create merge commit) */
809
- noFastForward?: boolean;
810
- /** Merge strategy ('recursive', 'ours', 'theirs') */
811
- strategy?: 'recursive' | 'ours' | 'theirs';
812
- /** Squash commits into single change */
813
- squash?: boolean;
814
- /** Abort if there are conflicts */
815
- abortOnConflict?: boolean;
816
- }
817
- /**
818
- * Authentication options for remote operations.
819
- *
820
- * @description
821
- * Credentials for authenticating with remote repositories.
822
- * Supports token-based, username/password, and SSH authentication.
823
- *
824
- * @example
825
- * ```typescript
826
- * // Token authentication (GitHub)
827
- * const auth: AuthOptions = { token: process.env.GITHUB_TOKEN }
828
- *
829
- * // Username/password
830
- * const auth: AuthOptions = {
831
- * username: 'user',
832
- * password: 'pass'
833
- * }
834
- * ```
835
- */
836
- export interface AuthOptions {
837
- /** Bearer token for authentication */
838
- token?: string;
839
- /** Username for basic auth */
840
- username?: string;
841
- /** Password for basic auth */
842
- password?: string;
843
- /** SSH private key (PEM format) */
844
- privateKey?: string;
845
- /** Passphrase for SSH key */
846
- passphrase?: string;
847
- }
848
- /**
849
- * Progress callback for long-running operations.
850
- *
851
- * @description
852
- * Called during clone, fetch, push, and other network operations
853
- * to report progress.
854
- *
855
- * @param progress - Progress information
856
- *
857
- * @example
858
- * ```typescript
859
- * await $.git.clone({
860
- * url: 'https://github.com/user/repo.git',
861
- * onProgress: (progress) => {
862
- * console.log(`${progress.phase}: ${progress.loaded}/${progress.total}`)
863
- * }
864
- * })
865
- * ```
866
- */
867
- export type ProgressCallback = (progress: ProgressEvent) => void;
868
- /**
869
- * Progress event data.
870
- *
871
- * @description
872
- * Progress information for network operations including phase,
873
- * loaded/total bytes or objects, and human-readable message.
874
- */
875
- export interface ProgressEvent {
876
- /** Current phase of the operation */
877
- phase: 'counting' | 'compressing' | 'receiving' | 'resolving' | 'checking';
878
- /** Number of items/bytes processed */
879
- loaded: number;
880
- /** Total items/bytes (may be 0 if unknown) */
881
- total: number;
882
- /** Human-readable progress message */
883
- message: string;
884
- }
885
- /**
886
- * Result of a merge operation.
887
- *
888
- * @description
889
- * Information about a completed merge including the result type,
890
- * resulting commit, and any conflicts.
891
- *
892
- * @example
893
- * ```typescript
894
- * const result = await $.git.merge({ branch: 'feature' })
895
- * if (result.conflicts) {
896
- * console.log('Merge conflicts:', result.conflicts)
897
- * } else if (result.type === 'fast-forward') {
898
- * console.log('Fast-forwarded to', result.commit)
899
- * }
900
- * ```
901
- */
902
- export interface MergeResult {
903
- /** Type of merge performed */
904
- type: 'fast-forward' | 'merge' | 'already-up-to-date' | 'conflict';
905
- /** Resulting commit SHA (null if conflicts) */
906
- commit: SHA | null;
907
- /** List of conflicted file paths */
908
- conflicts?: string[];
909
- /** Merged commit message */
910
- message?: string;
911
- }
912
- /**
913
- * Result of a push operation.
914
- *
915
- * @description
916
- * Information about a completed push including updated refs
917
- * and any errors.
918
- *
919
- * @example
920
- * ```typescript
921
- * const result = await $.git.push({ remote: 'origin' })
922
- * for (const ref of result.updates) {
923
- * console.log(`${ref.ref}: ${ref.oldSha} -> ${ref.newSha}`)
924
- * }
925
- * ```
926
- */
927
- export interface PushResult {
928
- /** Whether the push succeeded */
929
- ok: boolean;
930
- /** Refs that were updated */
931
- updates: Array<{
932
- ref: RefName;
933
- oldSha: SHA | null;
934
- newSha: SHA;
935
- forced: boolean;
936
- }>;
937
- /** Error messages for failed updates */
938
- errors?: Array<{
939
- ref: RefName;
940
- message: string;
941
- }>;
942
- }
943
- /**
944
- * Result of a fetch operation.
945
- *
946
- * @description
947
- * Information about a completed fetch including updated refs
948
- * and pruned refs.
949
- *
950
- * @example
951
- * ```typescript
952
- * const result = await $.git.fetch({ prune: true })
953
- * console.log(`Updated ${result.updates.length} refs`)
954
- * console.log(`Pruned ${result.pruned.length} refs`)
955
- * ```
956
- */
957
- export interface FetchResult {
958
- /** Refs that were updated */
959
- updates: Array<{
960
- ref: RefName;
961
- oldSha: SHA | null;
962
- newSha: SHA;
963
- }>;
964
- /** Refs that were pruned */
965
- pruned: RefName[];
966
- }
967
- /**
968
- * Main interface for the git capability proxy.
969
- *
970
- * @description
971
- * The comprehensive interface for all git operations, designed to be used
972
- * as the $.git proxy in a Durable Object context. Provides methods for:
973
- *
974
- * - **Repository operations**: clone, init, fetch, pull, push
975
- * - **Working tree operations**: add, commit, status, log, diff
976
- * - **Branch operations**: branch, checkout, merge
977
- * - **Low-level operations**: resolveRef, readObject
978
- *
979
- * All methods return Promises and support cancellation through AbortSignal
980
- * where applicable.
981
- *
982
- * @example
983
- * ```typescript
984
- * // Full example workflow
985
- * class MyDO extends DO {
986
- * git: GitCapability = this.$.git
987
- *
988
- * async createFeature(name: string): Promise<Commit> {
989
- * // Create and checkout new branch
990
- * await this.git.checkout({ branch: `feature/${name}`, create: true })
991
- *
992
- * // Make changes...
993
- *
994
- * // Stage and commit
995
- * await this.git.add({ all: true })
996
- * const commit = await this.git.commit({
997
- * message: `feat: ${name}`
998
- * })
999
- *
1000
- * // Push to remote
1001
- * await this.git.push({ setUpstream: true })
1002
- *
1003
- * return commit
1004
- * }
1005
- * }
1006
- * ```
1007
- */
1008
- export interface GitCapability {
1009
- /**
1010
- * Clone a repository from a remote URL.
1011
- *
1012
- * @description
1013
- * Clones a remote repository, downloading all objects and refs.
1014
- * Supports shallow clones, single-branch, and authentication.
1015
- *
1016
- * @param options - Clone configuration
1017
- * @returns Void on success
1018
- * @throws Error if clone fails
1019
- *
1020
- * @example
1021
- * ```typescript
1022
- * await $.git.clone({
1023
- * url: 'https://github.com/user/repo.git',
1024
- * branch: 'main',
1025
- * depth: 1
1026
- * })
1027
- * ```
1028
- */
1029
- clone(options: CloneOptions): Promise<void>;
1030
- /**
1031
- * Initialize a new repository.
1032
- *
1033
- * @description
1034
- * Creates a new Git repository in the current location.
1035
- * Can create either a normal or bare repository.
1036
- *
1037
- * @param options - Initialization configuration
1038
- * @returns Void on success
1039
- *
1040
- * @example
1041
- * ```typescript
1042
- * await $.git.init({ defaultBranch: 'main' })
1043
- * ```
1044
- */
1045
- init(options?: InitOptions): Promise<void>;
1046
- /**
1047
- * Fetch refs and objects from a remote.
1048
- *
1049
- * @description
1050
- * Downloads objects and refs from a remote repository.
1051
- * Does not modify the working tree or current branch.
1052
- *
1053
- * @param options - Fetch configuration
1054
- * @returns Fetch result with updated and pruned refs
1055
- *
1056
- * @example
1057
- * ```typescript
1058
- * const result = await $.git.fetch({ prune: true, tags: true })
1059
- * console.log(`Fetched ${result.updates.length} refs`)
1060
- * ```
1061
- */
1062
- fetch(options?: FetchOptions): Promise<FetchResult>;
1063
- /**
1064
- * Pull changes from a remote (fetch + merge).
1065
- *
1066
- * @description
1067
- * Fetches from a remote and integrates changes into the current branch.
1068
- * Can use either merge or rebase strategy.
1069
- *
1070
- * @param options - Pull configuration
1071
- * @returns Merge result
1072
- *
1073
- * @example
1074
- * ```typescript
1075
- * const result = await $.git.pull({ rebase: true })
1076
- * if (result.type === 'conflict') {
1077
- * console.log('Conflicts detected')
1078
- * }
1079
- * ```
1080
- */
1081
- pull(options?: PullOptions): Promise<MergeResult>;
1082
- /**
1083
- * Push commits to a remote repository.
1084
- *
1085
- * @description
1086
- * Uploads local commits to a remote repository.
1087
- * Supports force push, delete, and upstream tracking.
1088
- *
1089
- * @param options - Push configuration
1090
- * @returns Push result with updated refs
1091
- *
1092
- * @example
1093
- * ```typescript
1094
- * await $.git.push({
1095
- * remote: 'origin',
1096
- * branch: 'main',
1097
- * setUpstream: true
1098
- * })
1099
- * ```
1100
- */
1101
- push(options?: PushOptions): Promise<PushResult>;
1102
- /**
1103
- * Add files to the staging area.
1104
- *
1105
- * @description
1106
- * Stages file changes for the next commit. Can add specific files,
1107
- * all changes, or only updates to tracked files.
1108
- *
1109
- * @param options - Add configuration
1110
- * @returns List of staged file paths
1111
- *
1112
- * @example
1113
- * ```typescript
1114
- * // Stage specific files
1115
- * await $.git.add({ paths: ['src/index.ts'] })
1116
- *
1117
- * // Stage all changes
1118
- * await $.git.add({ all: true })
1119
- * ```
1120
- */
1121
- add(options?: AddOptions): Promise<string[]>;
1122
- /**
1123
- * Create a new commit.
1124
- *
1125
- * @description
1126
- * Records changes to the repository by creating a new commit
1127
- * with the currently staged changes.
1128
- *
1129
- * @param options - Commit configuration
1130
- * @returns The created commit
1131
- *
1132
- * @example
1133
- * ```typescript
1134
- * const commit = await $.git.commit({
1135
- * message: 'feat: add new feature'
1136
- * })
1137
- * console.log(`Created commit: ${commit.sha}`)
1138
- * ```
1139
- */
1140
- commit(options: CommitOptions): Promise<Commit>;
1141
- /**
1142
- * Get the working tree status.
1143
- *
1144
- * @description
1145
- * Shows the state of the working tree and staging area,
1146
- * including modified, staged, and untracked files.
1147
- *
1148
- * @param options - Status configuration
1149
- * @returns Complete status information
1150
- *
1151
- * @example
1152
- * ```typescript
1153
- * const status = await $.git.status()
1154
- * console.log(`On branch ${status.branch}`)
1155
- * console.log(`${status.staged.length} files staged`)
1156
- * ```
1157
- */
1158
- status(options?: StatusOptions): Promise<GitStatus>;
1159
- /**
1160
- * View commit history.
1161
- *
1162
- * @description
1163
- * Returns a list of commits matching the specified criteria.
1164
- * Supports filtering by date, author, path, and message.
1165
- *
1166
- * @param options - Log configuration
1167
- * @returns Array of commits
1168
- *
1169
- * @example
1170
- * ```typescript
1171
- * const commits = await $.git.log({ maxCount: 10 })
1172
- * for (const commit of commits) {
1173
- * console.log(`${commit.sha.slice(0, 7)} ${commit.message}`)
1174
- * }
1175
- * ```
1176
- */
1177
- log(options?: LogOptions): Promise<Commit[]>;
1178
- /**
1179
- * Show changes between commits, working tree, and staging area.
1180
- *
1181
- * @description
1182
- * Generates diffs between commits, trees, or the working tree.
1183
- * Returns detailed file-by-file diff information.
1184
- *
1185
- * @param options - Diff configuration
1186
- * @returns Complete diff result
1187
- *
1188
- * @example
1189
- * ```typescript
1190
- * // Show unstaged changes
1191
- * const diff = await $.git.diff()
1192
- *
1193
- * // Show staged changes
1194
- * const staged = await $.git.diff({ cached: true })
1195
- * ```
1196
- */
1197
- diff(options?: DiffOptions): Promise<DiffResult>;
1198
- /**
1199
- * List, create, or delete branches.
1200
- *
1201
- * @description
1202
- * Manages branches in the repository. Without options, lists local branches.
1203
- * Can also create new branches or delete existing ones.
1204
- *
1205
- * @param options - Branch configuration
1206
- * @returns Array of branches (for list operations)
1207
- *
1208
- * @example
1209
- * ```typescript
1210
- * // List all branches
1211
- * const branches = await $.git.branch({ all: true })
1212
- *
1213
- * // Create a new branch
1214
- * await $.git.branch({ create: 'feature/new' })
1215
- * ```
1216
- */
1217
- branch(options?: BranchOptions): Promise<Branch[]>;
1218
- /**
1219
- * Switch branches or restore files.
1220
- *
1221
- * @description
1222
- * Changes the current branch or restores files from a commit.
1223
- * Can also create new branches during checkout.
1224
- *
1225
- * @param options - Checkout configuration
1226
- * @returns Void on success
1227
- *
1228
- * @example
1229
- * ```typescript
1230
- * // Switch to existing branch
1231
- * await $.git.checkout({ branch: 'develop' })
1232
- *
1233
- * // Create and switch to new branch
1234
- * await $.git.checkout({ branch: 'feature/new', create: true })
1235
- * ```
1236
- */
1237
- checkout(options: CheckoutOptions): Promise<void>;
1238
- /**
1239
- * Merge branches or commits.
1240
- *
1241
- * @description
1242
- * Joins two or more development histories together.
1243
- * Supports fast-forward, merge commit, and squash strategies.
1244
- *
1245
- * @param options - Merge configuration
1246
- * @returns Merge result
1247
- *
1248
- * @example
1249
- * ```typescript
1250
- * const result = await $.git.merge({
1251
- * branch: 'feature/complete',
1252
- * noFastForward: true
1253
- * })
1254
- * ```
1255
- */
1256
- merge(options: MergeOptions): Promise<MergeResult>;
1257
- /**
1258
- * Resolve a ref to its SHA.
1259
- *
1260
- * @description
1261
- * Resolves a symbolic reference, branch name, tag, or partial SHA
1262
- * to its full 40-character SHA-1 hash.
1263
- *
1264
- * @param ref - Reference to resolve (e.g., 'HEAD', 'main', 'v1.0.0')
1265
- * @returns The resolved SHA, or null if not found
1266
- *
1267
- * @example
1268
- * ```typescript
1269
- * const sha = await $.git.resolveRef('HEAD')
1270
- * const mainSha = await $.git.resolveRef('refs/heads/main')
1271
- * const tagSha = await $.git.resolveRef('v1.0.0')
1272
- * ```
1273
- */
1274
- resolveRef(ref: string): Promise<SHA | null>;
1275
- /**
1276
- * Read a raw Git object.
1277
- *
1278
- * @description
1279
- * Retrieves the raw object data for a given SHA.
1280
- * Returns the object type, data, and size.
1281
- *
1282
- * @param sha - 40-character SHA-1 hash
1283
- * @returns The raw object, or null if not found
1284
- *
1285
- * @example
1286
- * ```typescript
1287
- * const obj = await $.git.readObject(sha)
1288
- * if (obj?.type === 'blob') {
1289
- * const content = new TextDecoder().decode(obj.data)
1290
- * }
1291
- * ```
1292
- */
1293
- readObject(sha: SHA): Promise<RawGitObject | null>;
1294
- /**
1295
- * List refs matching a prefix.
1296
- *
1297
- * @description
1298
- * Returns all refs that start with the given prefix.
1299
- * Useful for listing branches, tags, or remote refs.
1300
- *
1301
- * @param prefix - Ref prefix (e.g., 'refs/heads/', 'refs/tags/')
1302
- * @returns Array of matching refs
1303
- *
1304
- * @example
1305
- * ```typescript
1306
- * const branches = await $.git.listRefs('refs/heads/')
1307
- * const tags = await $.git.listRefs('refs/tags/')
1308
- * ```
1309
- */
1310
- listRefs(prefix?: string): Promise<GitRef[]>;
1311
- /**
1312
- * List all tags.
1313
- *
1314
- * @description
1315
- * Returns all tags in the repository with their metadata.
1316
- * Includes both lightweight and annotated tags.
1317
- *
1318
- * @returns Array of tags
1319
- *
1320
- * @example
1321
- * ```typescript
1322
- * const tags = await $.git.listTags()
1323
- * for (const tag of tags) {
1324
- * console.log(`${tag.name}: ${tag.target}`)
1325
- * }
1326
- * ```
1327
- */
1328
- listTags(): Promise<Tag[]>;
1329
- /**
1330
- * Get the current HEAD reference.
1331
- *
1332
- * @description
1333
- * Returns information about the current HEAD, including whether
1334
- * it's detached and what it points to.
1335
- *
1336
- * @returns HEAD reference information
1337
- *
1338
- * @example
1339
- * ```typescript
1340
- * const head = await $.git.head()
1341
- * if (head.symbolicTarget) {
1342
- * console.log(`On branch ${head.symbolicTarget}`)
1343
- * } else {
1344
- * console.log(`HEAD detached at ${head.sha}`)
1345
- * }
1346
- * ```
1347
- */
1348
- head(): Promise<GitRef>;
1349
- }
1350
- /**
1351
- * Result of resolving a tree path.
1352
- *
1353
- * @description
1354
- * Information about an entry at a specific path within a tree,
1355
- * including the mode, name, and SHA.
1356
- */
1357
- export interface TreePathResult {
1358
- /** Entry mode (file type) */
1359
- mode: string;
1360
- /** Entry name */
1361
- name: string;
1362
- /** Entry SHA */
1363
- sha: SHA;
1364
- /** Object type at this path */
1365
- type: 'blob' | 'tree' | 'commit';
1366
- }
1367
- /**
1368
- * Remote configuration.
1369
- *
1370
- * @description
1371
- * Configuration for a remote repository including URL and refspecs.
1372
- */
1373
- export interface Remote {
1374
- /** Remote name */
1375
- name: string;
1376
- /** Fetch URL */
1377
- url: string;
1378
- /** Push URL (if different from fetch) */
1379
- pushUrl?: string;
1380
- /** Fetch refspecs */
1381
- fetchRefspecs: string[];
1382
- /** Push refspecs */
1383
- pushRefspecs: string[];
1384
- }
1385
- //# sourceMappingURL=capability.d.ts.map