gitx.do 0.0.1 → 0.0.3

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 (237) hide show
  1. package/dist/cli/commands/blame.d.ts +259 -0
  2. package/dist/cli/commands/blame.d.ts.map +1 -0
  3. package/dist/cli/commands/blame.js +609 -0
  4. package/dist/cli/commands/blame.js.map +1 -0
  5. package/dist/cli/commands/branch.d.ts +249 -0
  6. package/dist/cli/commands/branch.d.ts.map +1 -0
  7. package/dist/cli/commands/branch.js +693 -0
  8. package/dist/cli/commands/branch.js.map +1 -0
  9. package/dist/cli/commands/commit.d.ts +182 -0
  10. package/dist/cli/commands/commit.d.ts.map +1 -0
  11. package/dist/cli/commands/commit.js +437 -0
  12. package/dist/cli/commands/commit.js.map +1 -0
  13. package/dist/cli/commands/diff.d.ts +464 -0
  14. package/dist/cli/commands/diff.d.ts.map +1 -0
  15. package/dist/cli/commands/diff.js +958 -0
  16. package/dist/cli/commands/diff.js.map +1 -0
  17. package/dist/cli/commands/log.d.ts +239 -0
  18. package/dist/cli/commands/log.d.ts.map +1 -0
  19. package/dist/cli/commands/log.js +535 -0
  20. package/dist/cli/commands/log.js.map +1 -0
  21. package/dist/cli/commands/review.d.ts +457 -0
  22. package/dist/cli/commands/review.d.ts.map +1 -0
  23. package/dist/cli/commands/review.js +533 -0
  24. package/dist/cli/commands/review.js.map +1 -0
  25. package/dist/cli/commands/status.d.ts +269 -0
  26. package/dist/cli/commands/status.d.ts.map +1 -0
  27. package/dist/cli/commands/status.js +493 -0
  28. package/dist/cli/commands/status.js.map +1 -0
  29. package/dist/cli/commands/web.d.ts +199 -0
  30. package/dist/cli/commands/web.d.ts.map +1 -0
  31. package/dist/cli/commands/web.js +696 -0
  32. package/dist/cli/commands/web.js.map +1 -0
  33. package/dist/cli/fs-adapter.d.ts +656 -0
  34. package/dist/cli/fs-adapter.d.ts.map +1 -0
  35. package/dist/cli/fs-adapter.js +1179 -0
  36. package/dist/cli/fs-adapter.js.map +1 -0
  37. package/dist/cli/index.d.ts +387 -0
  38. package/dist/cli/index.d.ts.map +1 -0
  39. package/dist/cli/index.js +523 -0
  40. package/dist/cli/index.js.map +1 -0
  41. package/dist/cli/ui/components/DiffView.d.ts +7 -0
  42. package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
  43. package/dist/cli/ui/components/DiffView.js +11 -0
  44. package/dist/cli/ui/components/DiffView.js.map +1 -0
  45. package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
  46. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
  47. package/dist/cli/ui/components/ErrorDisplay.js +11 -0
  48. package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
  49. package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
  50. package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
  51. package/dist/cli/ui/components/FuzzySearch.js +12 -0
  52. package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
  53. package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
  54. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
  55. package/dist/cli/ui/components/LoadingSpinner.js +10 -0
  56. package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
  57. package/dist/cli/ui/components/NavigationList.d.ts +9 -0
  58. package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
  59. package/dist/cli/ui/components/NavigationList.js +11 -0
  60. package/dist/cli/ui/components/NavigationList.js.map +1 -0
  61. package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
  62. package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
  63. package/dist/cli/ui/components/ScrollableContent.js +11 -0
  64. package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
  65. package/dist/cli/ui/components/index.d.ts +7 -0
  66. package/dist/cli/ui/components/index.d.ts.map +1 -0
  67. package/dist/cli/ui/components/index.js +9 -0
  68. package/dist/cli/ui/components/index.js.map +1 -0
  69. package/dist/cli/ui/terminal-ui.d.ts +52 -0
  70. package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
  71. package/dist/cli/ui/terminal-ui.js +121 -0
  72. package/dist/cli/ui/terminal-ui.js.map +1 -0
  73. package/dist/durable-object/object-store.d.ts +401 -23
  74. package/dist/durable-object/object-store.d.ts.map +1 -1
  75. package/dist/durable-object/object-store.js +414 -25
  76. package/dist/durable-object/object-store.js.map +1 -1
  77. package/dist/durable-object/schema.d.ts +188 -0
  78. package/dist/durable-object/schema.d.ts.map +1 -1
  79. package/dist/durable-object/schema.js +160 -0
  80. package/dist/durable-object/schema.js.map +1 -1
  81. package/dist/durable-object/wal.d.ts +336 -31
  82. package/dist/durable-object/wal.d.ts.map +1 -1
  83. package/dist/durable-object/wal.js +272 -27
  84. package/dist/durable-object/wal.js.map +1 -1
  85. package/dist/index.d.ts +379 -3
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +379 -7
  88. package/dist/index.js.map +1 -1
  89. package/dist/mcp/adapter.d.ts +579 -38
  90. package/dist/mcp/adapter.d.ts.map +1 -1
  91. package/dist/mcp/adapter.js +426 -33
  92. package/dist/mcp/adapter.js.map +1 -1
  93. package/dist/mcp/sandbox.d.ts +532 -29
  94. package/dist/mcp/sandbox.d.ts.map +1 -1
  95. package/dist/mcp/sandbox.js +389 -22
  96. package/dist/mcp/sandbox.js.map +1 -1
  97. package/dist/mcp/sdk-adapter.d.ts +478 -56
  98. package/dist/mcp/sdk-adapter.d.ts.map +1 -1
  99. package/dist/mcp/sdk-adapter.js +346 -44
  100. package/dist/mcp/sdk-adapter.js.map +1 -1
  101. package/dist/mcp/tools.d.ts +445 -30
  102. package/dist/mcp/tools.d.ts.map +1 -1
  103. package/dist/mcp/tools.js +363 -33
  104. package/dist/mcp/tools.js.map +1 -1
  105. package/dist/ops/blame.d.ts +424 -21
  106. package/dist/ops/blame.d.ts.map +1 -1
  107. package/dist/ops/blame.js +303 -20
  108. package/dist/ops/blame.js.map +1 -1
  109. package/dist/ops/branch.d.ts +583 -32
  110. package/dist/ops/branch.d.ts.map +1 -1
  111. package/dist/ops/branch.js +365 -23
  112. package/dist/ops/branch.js.map +1 -1
  113. package/dist/ops/commit-traversal.d.ts +164 -24
  114. package/dist/ops/commit-traversal.d.ts.map +1 -1
  115. package/dist/ops/commit-traversal.js +68 -2
  116. package/dist/ops/commit-traversal.js.map +1 -1
  117. package/dist/ops/commit.d.ts +387 -53
  118. package/dist/ops/commit.d.ts.map +1 -1
  119. package/dist/ops/commit.js +249 -29
  120. package/dist/ops/commit.js.map +1 -1
  121. package/dist/ops/merge-base.d.ts +195 -21
  122. package/dist/ops/merge-base.d.ts.map +1 -1
  123. package/dist/ops/merge-base.js +122 -12
  124. package/dist/ops/merge-base.js.map +1 -1
  125. package/dist/ops/merge.d.ts +600 -130
  126. package/dist/ops/merge.d.ts.map +1 -1
  127. package/dist/ops/merge.js +408 -60
  128. package/dist/ops/merge.js.map +1 -1
  129. package/dist/ops/tag.d.ts +67 -2
  130. package/dist/ops/tag.d.ts.map +1 -1
  131. package/dist/ops/tag.js +42 -1
  132. package/dist/ops/tag.js.map +1 -1
  133. package/dist/ops/tree-builder.d.ts +102 -6
  134. package/dist/ops/tree-builder.d.ts.map +1 -1
  135. package/dist/ops/tree-builder.js +30 -5
  136. package/dist/ops/tree-builder.js.map +1 -1
  137. package/dist/ops/tree-diff.d.ts +50 -2
  138. package/dist/ops/tree-diff.d.ts.map +1 -1
  139. package/dist/ops/tree-diff.js +50 -2
  140. package/dist/ops/tree-diff.js.map +1 -1
  141. package/dist/pack/delta.d.ts +211 -39
  142. package/dist/pack/delta.d.ts.map +1 -1
  143. package/dist/pack/delta.js +232 -46
  144. package/dist/pack/delta.js.map +1 -1
  145. package/dist/pack/format.d.ts +390 -28
  146. package/dist/pack/format.d.ts.map +1 -1
  147. package/dist/pack/format.js +344 -33
  148. package/dist/pack/format.js.map +1 -1
  149. package/dist/pack/full-generation.d.ts +313 -28
  150. package/dist/pack/full-generation.d.ts.map +1 -1
  151. package/dist/pack/full-generation.js +238 -19
  152. package/dist/pack/full-generation.js.map +1 -1
  153. package/dist/pack/generation.d.ts +346 -23
  154. package/dist/pack/generation.d.ts.map +1 -1
  155. package/dist/pack/generation.js +269 -21
  156. package/dist/pack/generation.js.map +1 -1
  157. package/dist/pack/index.d.ts +407 -86
  158. package/dist/pack/index.d.ts.map +1 -1
  159. package/dist/pack/index.js +351 -70
  160. package/dist/pack/index.js.map +1 -1
  161. package/dist/refs/branch.d.ts +517 -71
  162. package/dist/refs/branch.d.ts.map +1 -1
  163. package/dist/refs/branch.js +410 -26
  164. package/dist/refs/branch.js.map +1 -1
  165. package/dist/refs/storage.d.ts +610 -57
  166. package/dist/refs/storage.d.ts.map +1 -1
  167. package/dist/refs/storage.js +481 -29
  168. package/dist/refs/storage.js.map +1 -1
  169. package/dist/refs/tag.d.ts +677 -67
  170. package/dist/refs/tag.d.ts.map +1 -1
  171. package/dist/refs/tag.js +497 -30
  172. package/dist/refs/tag.js.map +1 -1
  173. package/dist/storage/lru-cache.d.ts +556 -53
  174. package/dist/storage/lru-cache.d.ts.map +1 -1
  175. package/dist/storage/lru-cache.js +439 -36
  176. package/dist/storage/lru-cache.js.map +1 -1
  177. package/dist/storage/object-index.d.ts +483 -38
  178. package/dist/storage/object-index.d.ts.map +1 -1
  179. package/dist/storage/object-index.js +388 -22
  180. package/dist/storage/object-index.js.map +1 -1
  181. package/dist/storage/r2-pack.d.ts +957 -94
  182. package/dist/storage/r2-pack.d.ts.map +1 -1
  183. package/dist/storage/r2-pack.js +756 -48
  184. package/dist/storage/r2-pack.js.map +1 -1
  185. package/dist/tiered/cdc-pipeline.d.ts +1610 -38
  186. package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
  187. package/dist/tiered/cdc-pipeline.js +1131 -22
  188. package/dist/tiered/cdc-pipeline.js.map +1 -1
  189. package/dist/tiered/migration.d.ts +903 -41
  190. package/dist/tiered/migration.d.ts.map +1 -1
  191. package/dist/tiered/migration.js +646 -24
  192. package/dist/tiered/migration.js.map +1 -1
  193. package/dist/tiered/parquet-writer.d.ts +944 -47
  194. package/dist/tiered/parquet-writer.d.ts.map +1 -1
  195. package/dist/tiered/parquet-writer.js +667 -39
  196. package/dist/tiered/parquet-writer.js.map +1 -1
  197. package/dist/tiered/read-path.d.ts +728 -34
  198. package/dist/tiered/read-path.d.ts.map +1 -1
  199. package/dist/tiered/read-path.js +310 -27
  200. package/dist/tiered/read-path.js.map +1 -1
  201. package/dist/types/objects.d.ts +457 -0
  202. package/dist/types/objects.d.ts.map +1 -1
  203. package/dist/types/objects.js +305 -4
  204. package/dist/types/objects.js.map +1 -1
  205. package/dist/types/storage.d.ts +407 -35
  206. package/dist/types/storage.d.ts.map +1 -1
  207. package/dist/types/storage.js +27 -3
  208. package/dist/types/storage.js.map +1 -1
  209. package/dist/utils/hash.d.ts +133 -12
  210. package/dist/utils/hash.d.ts.map +1 -1
  211. package/dist/utils/hash.js +133 -12
  212. package/dist/utils/hash.js.map +1 -1
  213. package/dist/utils/sha1.d.ts +102 -9
  214. package/dist/utils/sha1.d.ts.map +1 -1
  215. package/dist/utils/sha1.js +114 -11
  216. package/dist/utils/sha1.js.map +1 -1
  217. package/dist/wire/capabilities.d.ts +896 -88
  218. package/dist/wire/capabilities.d.ts.map +1 -1
  219. package/dist/wire/capabilities.js +566 -62
  220. package/dist/wire/capabilities.js.map +1 -1
  221. package/dist/wire/pkt-line.d.ts +293 -15
  222. package/dist/wire/pkt-line.d.ts.map +1 -1
  223. package/dist/wire/pkt-line.js +251 -15
  224. package/dist/wire/pkt-line.js.map +1 -1
  225. package/dist/wire/receive-pack.d.ts +814 -64
  226. package/dist/wire/receive-pack.d.ts.map +1 -1
  227. package/dist/wire/receive-pack.js +542 -41
  228. package/dist/wire/receive-pack.js.map +1 -1
  229. package/dist/wire/smart-http.d.ts +575 -97
  230. package/dist/wire/smart-http.d.ts.map +1 -1
  231. package/dist/wire/smart-http.js +337 -46
  232. package/dist/wire/smart-http.js.map +1 -1
  233. package/dist/wire/upload-pack.d.ts +492 -98
  234. package/dist/wire/upload-pack.d.ts.map +1 -1
  235. package/dist/wire/upload-pack.js +347 -59
  236. package/dist/wire/upload-pack.js.map +1 -1
  237. package/package.json +10 -2
@@ -1,224 +1,670 @@
1
1
  /**
2
- * Git Branch Operations
2
+ * @fileoverview Git Branch Operations
3
3
  *
4
- * Handles branch creation, deletion, renaming, listing, and tracking.
5
- * Works with the RefStorage system for underlying ref management.
4
+ * This module provides comprehensive branch management functionality including
5
+ * creation, deletion, renaming, listing, and upstream tracking configuration.
6
+ *
7
+ * Branches in Git are simply refs under `refs/heads/` that point to commits.
8
+ * This module provides a higher-level API that handles the ref manipulation
9
+ * and adds branch-specific features like tracking information.
10
+ *
11
+ * **Key Features**:
12
+ * - Branch CRUD operations (create, read, update, delete)
13
+ * - Upstream tracking configuration
14
+ * - Merge status checking
15
+ * - Branch name validation and normalization
16
+ *
17
+ * @module refs/branch
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { BranchManager, createBranch, listBranches } from './refs/branch'
22
+ *
23
+ * // Using the manager
24
+ * const manager = new BranchManager(refStorage)
25
+ * const branch = await manager.createBranch('feature/new-thing', { startPoint: 'main' })
26
+ *
27
+ * // Or using convenience functions
28
+ * const branches = await listBranches(refStorage)
29
+ * ```
6
30
  */
7
31
  import { RefStorage } from './storage';
8
32
  /**
9
- * Branch tracking information
33
+ * Upstream tracking information for a branch.
34
+ *
35
+ * @description
36
+ * Contains information about the remote branch that a local branch tracks,
37
+ * including ahead/behind counts for synchronization status.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const tracking: BranchTrackingInfo = {
42
+ * remote: 'origin',
43
+ * remoteBranch: 'refs/remotes/origin/main',
44
+ * ahead: 2, // Local has 2 commits not on remote
45
+ * behind: 0, // Remote has 0 commits not on local
46
+ * gone: false // Remote branch still exists
47
+ * }
48
+ * ```
10
49
  */
11
50
  export interface BranchTrackingInfo {
12
- /** Remote name (e.g., 'origin') */
51
+ /** Remote name (e.g., 'origin', 'upstream') */
13
52
  remote: string;
14
- /** Remote branch name (e.g., 'refs/remotes/origin/main') */
53
+ /** Full remote branch ref (e.g., 'refs/remotes/origin/main') */
15
54
  remoteBranch: string;
16
- /** Number of commits ahead of upstream */
55
+ /** Number of local commits not pushed to upstream */
17
56
  ahead: number;
18
- /** Number of commits behind upstream */
57
+ /** Number of upstream commits not pulled locally */
19
58
  behind: number;
20
- /** Whether the branch is gone from remote */
59
+ /** True if the remote branch has been deleted */
21
60
  gone: boolean;
22
61
  }
23
62
  /**
24
- * Branch information
63
+ * Complete branch information.
64
+ *
65
+ * @description
66
+ * Represents a Git branch with all associated metadata including
67
+ * current status, tracking info, and optional commit details.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const branch: Branch = {
72
+ * name: 'feature/auth',
73
+ * ref: 'refs/heads/feature/auth',
74
+ * sha: 'abc123...',
75
+ * isCurrent: true,
76
+ * isRemote: false,
77
+ * tracking: {
78
+ * remote: 'origin',
79
+ * remoteBranch: 'refs/remotes/origin/feature/auth',
80
+ * ahead: 1,
81
+ * behind: 0,
82
+ * gone: false
83
+ * }
84
+ * }
85
+ * ```
25
86
  */
26
87
  export interface Branch {
27
- /** Short branch name (e.g., 'main', 'feature/foo') */
88
+ /** Short branch name without refs/heads/ prefix (e.g., 'main', 'feature/foo') */
28
89
  name: string;
29
90
  /** Full ref name (e.g., 'refs/heads/main') */
30
91
  ref: string;
31
92
  /** SHA-1 of the commit this branch points to */
32
93
  sha: string;
33
- /** Whether this is the current branch (HEAD points to it) */
94
+ /** True if this is the current branch (HEAD points to it) */
34
95
  isCurrent: boolean;
35
- /** Whether this is a remote tracking branch */
96
+ /** True if this is a remote tracking branch (refs/remotes/) */
36
97
  isRemote: boolean;
37
- /** Tracking information if the branch tracks an upstream */
98
+ /** Upstream tracking information (if configured) */
38
99
  tracking?: BranchTrackingInfo;
39
- /** Last commit message (optional) */
100
+ /** Subject line of the last commit (optional, for display) */
40
101
  lastCommitMessage?: string;
41
- /** Last commit author (optional) */
102
+ /** Author name of the last commit (optional, for display) */
42
103
  lastCommitAuthor?: string;
43
- /** Last commit date (optional) */
104
+ /** Date of the last commit (optional, for sorting/display) */
44
105
  lastCommitDate?: Date;
45
106
  }
46
107
  /**
47
- * Options for creating a branch
108
+ * Options for creating a new branch.
109
+ *
110
+ * @description
111
+ * Controls branch creation behavior including start point,
112
+ * force overwrite, and tracking configuration.
48
113
  */
49
114
  export interface CreateBranchOptions {
50
- /** Start point (SHA, branch name, or ref) - defaults to HEAD */
115
+ /**
116
+ * Starting point for the new branch.
117
+ * Can be a SHA, branch name, or ref. Defaults to HEAD.
118
+ */
51
119
  startPoint?: string;
52
- /** Force creation even if branch exists (overwrite) */
120
+ /** If true, overwrite existing branch with same name */
53
121
  force?: boolean;
54
- /** Set up tracking for the new branch */
122
+ /**
123
+ * Configure upstream tracking.
124
+ * - `true`: Track the startPoint if it's a remote branch
125
+ * - `string`: Explicit upstream ref to track
126
+ * - `false`/undefined: No tracking
127
+ */
55
128
  track?: boolean | string;
56
- /** Don't actually create the branch, just validate */
129
+ /** If true, validate but don't actually create */
57
130
  dryRun?: boolean;
58
131
  }
59
132
  /**
60
- * Options for deleting a branch
133
+ * Options for deleting a branch.
61
134
  */
62
135
  export interface DeleteBranchOptions {
63
- /** Force delete even if not fully merged */
136
+ /** If true, delete even if not fully merged */
64
137
  force?: boolean;
65
- /** Remote branch to delete (for remote tracking branches) */
138
+ /** Remote name for deleting remote tracking branches */
66
139
  remote?: string;
67
- /** Don't actually delete, just validate */
140
+ /** If true, validate but don't actually delete */
68
141
  dryRun?: boolean;
69
142
  }
70
143
  /**
71
- * Options for renaming a branch
144
+ * Options for renaming a branch.
72
145
  */
73
146
  export interface RenameBranchOptions {
74
- /** Force rename even if target exists (overwrite) */
147
+ /** If true, overwrite target if it exists */
75
148
  force?: boolean;
76
- /** Don't actually rename, just validate */
149
+ /** If true, validate but don't actually rename */
77
150
  dryRun?: boolean;
78
151
  }
79
152
  /**
80
- * Options for listing branches
153
+ * Options for listing branches.
154
+ *
155
+ * @description
156
+ * Provides extensive filtering, sorting, and inclusion options
157
+ * for branch listing operations.
81
158
  */
82
159
  export interface ListBranchesOptions {
83
- /** Include remote tracking branches */
160
+ /** Include remote tracking branches (refs/remotes/) */
84
161
  includeRemotes?: boolean;
85
162
  /** Only list remote tracking branches */
86
163
  remotesOnly?: boolean;
87
- /** Pattern to filter branches (glob-style) */
164
+ /** Filter pattern (glob-style, e.g., 'feature/*') */
88
165
  pattern?: string;
89
- /** Sort by (name, committerdate, authordate, etc.) */
166
+ /** Sort by field */
90
167
  sortBy?: 'name' | 'committerdate' | 'authordate';
91
- /** Sort order */
168
+ /** Sort direction */
92
169
  sortOrder?: 'asc' | 'desc';
93
- /** Include tracking info (slower) */
170
+ /** Include tracking info (slower - requires extra lookups) */
94
171
  includeTracking?: boolean;
95
- /** Include commit info (slower) */
172
+ /** Include last commit info (slower - requires object access) */
96
173
  includeCommitInfo?: boolean;
97
- /** Merged into this ref (filter only merged branches) */
174
+ /** Only show branches merged into this ref */
98
175
  mergedInto?: string;
99
- /** Not merged into this ref (filter only unmerged branches) */
176
+ /** Only show branches NOT merged into this ref */
100
177
  notMergedInto?: string;
101
- /** Only show branches that contain this commit */
178
+ /** Only show branches containing this commit */
102
179
  contains?: string;
103
- /** Only show branches that don't contain this commit */
180
+ /** Only show branches NOT containing this commit */
104
181
  noContains?: string;
105
182
  }
106
183
  /**
107
- * Options for setting upstream
184
+ * Options for setting upstream tracking.
108
185
  */
109
186
  export interface SetUpstreamOptions {
110
- /** Remote name */
187
+ /** Remote name (e.g., 'origin') */
111
188
  remote?: string;
112
- /** Remote branch name */
189
+ /** Remote branch name (without refs/remotes/ prefix) */
113
190
  remoteBranch?: string;
114
- /** Unset the upstream (remove tracking) */
191
+ /** If true, remove upstream tracking */
115
192
  unset?: boolean;
116
193
  }
117
194
  /**
118
- * Result of branch validation
195
+ * Result of branch name validation.
196
+ *
197
+ * @description
198
+ * Provides detailed validation result including the normalized
199
+ * form of the branch name if valid.
119
200
  */
120
201
  export interface BranchValidationResult {
121
- /** Whether the name is valid */
202
+ /** Whether the name passes validation */
122
203
  valid: boolean;
123
- /** Error message if invalid */
204
+ /** Error message explaining why validation failed */
124
205
  error?: string;
125
- /** Normalized branch name */
206
+ /** Normalized branch name (cleaned up form) */
126
207
  normalized?: string;
127
208
  }
128
209
  /**
129
- * Error thrown when a branch operation fails
210
+ * Error thrown when a branch operation fails.
211
+ *
212
+ * @description
213
+ * Provides structured error information with error code
214
+ * for programmatic error handling.
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * try {
219
+ * await manager.deleteBranch('main')
220
+ * } catch (e) {
221
+ * if (e instanceof BranchError) {
222
+ * if (e.code === 'CANNOT_DELETE_CURRENT') {
223
+ * console.log('Cannot delete the branch you are on')
224
+ * }
225
+ * }
226
+ * }
227
+ * ```
130
228
  */
131
229
  export declare class BranchError extends Error {
132
230
  readonly code: BranchErrorCode;
133
231
  readonly branchName?: string | undefined;
232
+ /**
233
+ * Create a new BranchError.
234
+ *
235
+ * @param message - Human-readable error description
236
+ * @param code - Error code for programmatic handling
237
+ * @param branchName - The branch that caused the error
238
+ */
134
239
  constructor(message: string, code: BranchErrorCode, branchName?: string | undefined);
135
240
  }
241
+ /**
242
+ * Error codes for branch operations.
243
+ *
244
+ * @description
245
+ * - `NOT_FOUND`: Branch doesn't exist
246
+ * - `ALREADY_EXISTS`: Branch already exists (when creating)
247
+ * - `INVALID_NAME`: Branch name fails validation
248
+ * - `NOT_FULLY_MERGED`: Branch has unmerged commits (when deleting)
249
+ * - `CANNOT_DELETE_CURRENT`: Attempting to delete checked-out branch
250
+ * - `CHECKOUT_CONFLICT`: Working tree has uncommitted changes
251
+ * - `INVALID_START_POINT`: Start point doesn't resolve to valid commit
252
+ * - `NO_UPSTREAM`: Branch has no upstream configured
253
+ * - `DETACHED_HEAD`: HEAD is detached (no current branch)
254
+ */
136
255
  export type BranchErrorCode = 'NOT_FOUND' | 'ALREADY_EXISTS' | 'INVALID_NAME' | 'NOT_FULLY_MERGED' | 'CANNOT_DELETE_CURRENT' | 'CHECKOUT_CONFLICT' | 'INVALID_START_POINT' | 'NO_UPSTREAM' | 'DETACHED_HEAD';
137
256
  /**
138
- * Branch manager for performing branch operations
257
+ * Branch manager for performing Git branch operations.
258
+ *
259
+ * @description
260
+ * Provides a comprehensive API for branch management. Uses RefStorage
261
+ * internally for ref manipulation.
262
+ *
263
+ * Note: Many methods are currently stubs (TODO) and will throw 'Not implemented'.
264
+ * These will be implemented in the GREEN phase of TDD development.
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const manager = new BranchManager(refStorage)
269
+ *
270
+ * // Create a feature branch
271
+ * const branch = await manager.createBranch('feature/auth', {
272
+ * startPoint: 'main',
273
+ * track: true
274
+ * })
275
+ *
276
+ * // List all branches
277
+ * const branches = await manager.listBranches({ includeRemotes: true })
278
+ *
279
+ * // Delete a merged branch
280
+ * await manager.deleteBranch('feature/auth')
281
+ * ```
139
282
  */
140
283
  export declare class BranchManager {
284
+ /**
285
+ * Create a new BranchManager.
286
+ *
287
+ * @param storage - RefStorage instance for ref operations
288
+ */
141
289
  constructor(storage: RefStorage);
142
290
  /**
143
- * Create a new branch
291
+ * Create a new branch.
292
+ *
293
+ * @description
294
+ * Creates a new branch pointing to the specified start point.
295
+ * By default, the branch starts at HEAD.
296
+ *
297
+ * @param name - Branch name (without refs/heads/ prefix)
298
+ * @param options - Creation options
299
+ * @returns The created branch
300
+ * @throws BranchError with code 'INVALID_NAME' if name is invalid
301
+ * @throws BranchError with code 'ALREADY_EXISTS' if branch exists and not forcing
302
+ * @throws BranchError with code 'INVALID_START_POINT' if start point is invalid
303
+ *
304
+ * @example
305
+ * ```typescript
306
+ * // Create from HEAD
307
+ * const branch = await manager.createBranch('feature')
308
+ *
309
+ * // Create from specific commit
310
+ * const branch = await manager.createBranch('hotfix', { startPoint: 'abc123' })
311
+ *
312
+ * // Force overwrite existing
313
+ * const branch = await manager.createBranch('main', { force: true, startPoint: 'HEAD' })
314
+ * ```
144
315
  */
145
316
  createBranch(_name: string, _options?: CreateBranchOptions): Promise<Branch>;
146
317
  /**
147
- * Delete a branch
318
+ * Delete a branch.
319
+ *
320
+ * @description
321
+ * Removes a branch ref. By default, refuses to delete unmerged branches.
322
+ *
323
+ * @param name - Branch name to delete
324
+ * @param options - Deletion options
325
+ * @throws BranchError with code 'NOT_FOUND' if branch doesn't exist
326
+ * @throws BranchError with code 'CANNOT_DELETE_CURRENT' if branch is checked out
327
+ * @throws BranchError with code 'NOT_FULLY_MERGED' if branch has unmerged commits
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * // Safe delete (only if merged)
332
+ * await manager.deleteBranch('feature')
333
+ *
334
+ * // Force delete
335
+ * await manager.deleteBranch('experiment', { force: true })
336
+ * ```
148
337
  */
149
338
  deleteBranch(_name: string, _options?: DeleteBranchOptions): Promise<void>;
150
339
  /**
151
- * Rename a branch
340
+ * Rename a branch.
341
+ *
342
+ * @description
343
+ * Renames a branch, updating the ref name. If the branch is the current
344
+ * branch, HEAD is updated accordingly.
345
+ *
346
+ * @param oldName - Current branch name
347
+ * @param newName - New branch name
348
+ * @param options - Rename options
349
+ * @returns The renamed branch
350
+ * @throws BranchError with code 'NOT_FOUND' if old branch doesn't exist
351
+ * @throws BranchError with code 'ALREADY_EXISTS' if new name exists and not forcing
352
+ * @throws BranchError with code 'INVALID_NAME' if new name is invalid
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const branch = await manager.renameBranch('old-name', 'new-name')
357
+ * ```
152
358
  */
153
359
  renameBranch(_oldName: string, _newName: string, _options?: RenameBranchOptions): Promise<Branch>;
154
360
  /**
155
- * List all branches
361
+ * List all branches.
362
+ *
363
+ * @description
364
+ * Returns branches matching the specified criteria.
365
+ * By default, returns only local branches.
366
+ *
367
+ * @param options - Listing options
368
+ * @returns Array of branches matching criteria
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * // List local branches
373
+ * const local = await manager.listBranches()
374
+ *
375
+ * // List all branches including remotes
376
+ * const all = await manager.listBranches({ includeRemotes: true })
377
+ *
378
+ * // List merged branches
379
+ * const merged = await manager.listBranches({ mergedInto: 'main' })
380
+ * ```
156
381
  */
157
382
  listBranches(_options?: ListBranchesOptions): Promise<Branch[]>;
158
383
  /**
159
- * Get the current branch
384
+ * Get the current branch.
385
+ *
386
+ * @description
387
+ * Returns the branch that HEAD points to, or null if HEAD is detached.
388
+ *
389
+ * @returns Current branch or null if detached
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * const current = await manager.getCurrentBranch()
394
+ * if (current) {
395
+ * console.log(`On branch: ${current.name}`)
396
+ * } else {
397
+ * console.log('HEAD is detached')
398
+ * }
399
+ * ```
160
400
  */
161
401
  getCurrentBranch(): Promise<Branch | null>;
162
402
  /**
163
- * Get a specific branch by name
403
+ * Get a specific branch by name.
404
+ *
405
+ * @description
406
+ * Retrieves branch information for a specific branch.
407
+ *
408
+ * @param name - Branch name
409
+ * @returns Branch info or null if not found
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * const branch = await manager.getBranch('main')
414
+ * if (branch) {
415
+ * console.log(`main is at ${branch.sha}`)
416
+ * }
417
+ * ```
164
418
  */
165
419
  getBranch(_name: string): Promise<Branch | null>;
166
420
  /**
167
- * Check if a branch exists
421
+ * Check if a branch exists.
422
+ *
423
+ * @description
424
+ * Quick check for branch existence without fetching full info.
425
+ *
426
+ * @param name - Branch name
427
+ * @returns True if branch exists
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * if (await manager.branchExists('feature')) {
432
+ * console.log('Branch already exists')
433
+ * }
434
+ * ```
168
435
  */
169
436
  branchExists(_name: string): Promise<boolean>;
170
437
  /**
171
- * Set upstream branch for tracking
438
+ * Set upstream branch for tracking.
439
+ *
440
+ * @description
441
+ * Configures or removes upstream tracking for a branch.
442
+ *
443
+ * @param branchName - Local branch to configure
444
+ * @param options - Tracking options
445
+ * @throws BranchError with code 'NOT_FOUND' if branch doesn't exist
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * // Set upstream
450
+ * await manager.setUpstream('feature', {
451
+ * remote: 'origin',
452
+ * remoteBranch: 'feature'
453
+ * })
454
+ *
455
+ * // Remove upstream
456
+ * await manager.setUpstream('feature', { unset: true })
457
+ * ```
172
458
  */
173
459
  setUpstream(_branchName: string, _options: SetUpstreamOptions): Promise<void>;
174
460
  /**
175
- * Get tracking info for a branch
461
+ * Get tracking info for a branch.
462
+ *
463
+ * @description
464
+ * Returns upstream tracking information including ahead/behind counts.
465
+ *
466
+ * @param branchName - Branch to check
467
+ * @returns Tracking info or null if not tracking
468
+ *
469
+ * @example
470
+ * ```typescript
471
+ * const tracking = await manager.getTrackingInfo('main')
472
+ * if (tracking) {
473
+ * console.log(`${tracking.ahead} ahead, ${tracking.behind} behind ${tracking.remoteBranch}`)
474
+ * }
475
+ * ```
176
476
  */
177
477
  getTrackingInfo(_branchName: string): Promise<BranchTrackingInfo | null>;
178
478
  /**
179
- * Check if a branch is fully merged into another branch
479
+ * Check if a branch is fully merged into another branch.
480
+ *
481
+ * @description
482
+ * Determines if all commits on the branch are reachable from the target.
483
+ *
484
+ * @param branchName - Branch to check
485
+ * @param into - Target branch (defaults to current branch)
486
+ * @returns True if fully merged
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * if (await manager.isMerged('feature', 'main')) {
491
+ * console.log('Safe to delete feature branch')
492
+ * }
493
+ * ```
180
494
  */
181
495
  isMerged(_branchName: string, _into?: string): Promise<boolean>;
182
496
  /**
183
- * Force delete an unmerged branch
497
+ * Force delete an unmerged branch.
498
+ *
499
+ * @description
500
+ * Deletes a branch even if it has unmerged commits. Use with caution
501
+ * as this can result in lost commits.
502
+ *
503
+ * @param name - Branch name to delete
504
+ * @throws BranchError with code 'NOT_FOUND' if branch doesn't exist
505
+ * @throws BranchError with code 'CANNOT_DELETE_CURRENT' if branch is checked out
506
+ *
507
+ * @example
508
+ * ```typescript
509
+ * await manager.forceDeleteBranch('abandoned-feature')
510
+ * ```
184
511
  */
185
512
  forceDeleteBranch(_name: string): Promise<void>;
186
513
  }
187
514
  /**
188
- * Validate a branch name according to Git rules
189
- * See: https://git-scm.com/docs/git-check-ref-format
515
+ * Validate a branch name according to Git rules.
516
+ *
517
+ * @description
518
+ * Checks if a branch name is valid and returns detailed validation results
519
+ * including the normalized form of the name.
520
+ *
521
+ * Note: This is a stub implementation. Full validation will be added in GREEN phase.
522
+ *
523
+ * @param name - Branch name to validate
524
+ * @returns Validation result with valid flag, error message, and normalized name
525
+ *
526
+ * @see https://git-scm.com/docs/git-check-ref-format
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * const result = validateBranchName('feature/auth')
531
+ * if (result.valid) {
532
+ * console.log(`Valid: ${result.normalized}`)
533
+ * } else {
534
+ * console.log(`Invalid: ${result.error}`)
535
+ * }
536
+ * ```
190
537
  */
191
538
  export declare function validateBranchName(_name: string): BranchValidationResult;
192
539
  /**
193
- * Check if a string is a valid branch name
540
+ * Check if a string is a valid branch name.
541
+ *
542
+ * @description
543
+ * Simple boolean check for branch name validity.
544
+ *
545
+ * @param name - Branch name to check
546
+ * @returns True if valid
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * if (isValidBranchName('feature/new')) {
551
+ * // Create the branch
552
+ * }
553
+ * ```
194
554
  */
195
555
  export declare function isValidBranchName(_name: string): boolean;
196
556
  /**
197
- * Normalize a branch name (remove refs/heads/ prefix, etc.)
557
+ * Normalize a branch name.
558
+ *
559
+ * @description
560
+ * Removes refs/heads/ prefix if present, cleans up the name.
561
+ *
562
+ * @param name - Branch name or ref
563
+ * @returns Normalized short branch name
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * normalizeBranchName('refs/heads/main') // 'main'
568
+ * normalizeBranchName('main') // 'main'
569
+ * ```
198
570
  */
199
571
  export declare function normalizeBranchName(_name: string): string;
200
572
  /**
201
- * Get the full ref name for a branch
573
+ * Get the full ref name for a branch.
574
+ *
575
+ * @description
576
+ * Adds refs/heads/ prefix if not present.
577
+ *
578
+ * @param name - Short branch name
579
+ * @returns Full ref name
580
+ *
581
+ * @example
582
+ * ```typescript
583
+ * getBranchRefName('main') // 'refs/heads/main'
584
+ * getBranchRefName('refs/heads/main') // 'refs/heads/main'
585
+ * ```
202
586
  */
203
587
  export declare function getBranchRefName(_name: string): string;
204
588
  /**
205
- * Create a new branch (convenience function)
589
+ * Create a new branch.
590
+ *
591
+ * @description
592
+ * Convenience function that creates a BranchManager and calls createBranch.
593
+ *
594
+ * @param storage - RefStorage instance
595
+ * @param name - Branch name
596
+ * @param options - Creation options
597
+ * @returns Created branch
598
+ *
599
+ * @example
600
+ * ```typescript
601
+ * const branch = await createBranch(storage, 'feature', { startPoint: 'main' })
602
+ * ```
206
603
  */
207
604
  export declare function createBranch(_storage: RefStorage, _name: string, _options?: CreateBranchOptions): Promise<Branch>;
208
605
  /**
209
- * Delete a branch (convenience function)
606
+ * Delete a branch.
607
+ *
608
+ * @description
609
+ * Convenience function that creates a BranchManager and calls deleteBranch.
610
+ *
611
+ * @param storage - RefStorage instance
612
+ * @param name - Branch name to delete
613
+ * @param options - Deletion options
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * await deleteBranch(storage, 'feature', { force: true })
618
+ * ```
210
619
  */
211
620
  export declare function deleteBranch(_storage: RefStorage, _name: string, _options?: DeleteBranchOptions): Promise<void>;
212
621
  /**
213
- * Rename a branch (convenience function)
622
+ * Rename a branch.
623
+ *
624
+ * @description
625
+ * Convenience function that creates a BranchManager and calls renameBranch.
626
+ *
627
+ * @param storage - RefStorage instance
628
+ * @param oldName - Current branch name
629
+ * @param newName - New branch name
630
+ * @param options - Rename options
631
+ * @returns Renamed branch
632
+ *
633
+ * @example
634
+ * ```typescript
635
+ * const branch = await renameBranch(storage, 'old', 'new')
636
+ * ```
214
637
  */
215
638
  export declare function renameBranch(_storage: RefStorage, _oldName: string, _newName: string, _options?: RenameBranchOptions): Promise<Branch>;
216
639
  /**
217
- * List all branches (convenience function)
640
+ * List all branches.
641
+ *
642
+ * @description
643
+ * Convenience function that creates a BranchManager and calls listBranches.
644
+ *
645
+ * @param storage - RefStorage instance
646
+ * @param options - Listing options
647
+ * @returns Array of branches
648
+ *
649
+ * @example
650
+ * ```typescript
651
+ * const branches = await listBranches(storage, { includeRemotes: true })
652
+ * ```
218
653
  */
219
654
  export declare function listBranches(_storage: RefStorage, _options?: ListBranchesOptions): Promise<Branch[]>;
220
655
  /**
221
- * Get the current branch (convenience function)
656
+ * Get the current branch.
657
+ *
658
+ * @description
659
+ * Convenience function that creates a BranchManager and calls getCurrentBranch.
660
+ *
661
+ * @param storage - RefStorage instance
662
+ * @returns Current branch or null if detached
663
+ *
664
+ * @example
665
+ * ```typescript
666
+ * const current = await getCurrentBranch(storage)
667
+ * ```
222
668
  */
223
669
  export declare function getCurrentBranch(_storage: RefStorage): Promise<Branch | null>;
224
670
  //# sourceMappingURL=branch.d.ts.map