@fractary/faber 0.1.1 → 1.0.1

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 (261) hide show
  1. package/README.md +366 -76
  2. package/dist/cli/commands/logs.d.ts +6 -0
  3. package/dist/cli/commands/logs.d.ts.map +1 -0
  4. package/dist/cli/commands/logs.js +215 -0
  5. package/dist/cli/commands/logs.js.map +1 -0
  6. package/dist/cli/commands/repo.d.ts +6 -0
  7. package/dist/cli/commands/repo.d.ts.map +1 -0
  8. package/dist/cli/commands/repo.js +260 -0
  9. package/dist/cli/commands/repo.js.map +1 -0
  10. package/dist/cli/commands/spec.d.ts +6 -0
  11. package/dist/cli/commands/spec.d.ts.map +1 -0
  12. package/dist/cli/commands/spec.js +184 -0
  13. package/dist/cli/commands/spec.js.map +1 -0
  14. package/dist/cli/commands/work.d.ts +6 -0
  15. package/dist/cli/commands/work.d.ts.map +1 -0
  16. package/dist/cli/commands/work.js +113 -0
  17. package/dist/cli/commands/work.js.map +1 -0
  18. package/dist/cli/commands/workflow.d.ts +6 -0
  19. package/dist/cli/commands/workflow.d.ts.map +1 -0
  20. package/dist/cli/commands/workflow.js +214 -0
  21. package/dist/cli/commands/workflow.js.map +1 -0
  22. package/dist/cli/index.d.ts +8 -0
  23. package/dist/cli/index.d.ts.map +1 -0
  24. package/dist/cli/index.js +27 -0
  25. package/dist/cli/index.js.map +1 -0
  26. package/dist/config.d.ts +814 -0
  27. package/dist/config.d.ts.map +1 -0
  28. package/dist/config.js +438 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/errors.d.ts +264 -0
  31. package/dist/errors.d.ts.map +1 -0
  32. package/dist/errors.js +491 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/index.d.ts +21 -16
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +23 -36
  37. package/dist/index.js.map +1 -1
  38. package/dist/logs/index.d.ts +8 -0
  39. package/dist/logs/index.d.ts.map +1 -0
  40. package/dist/{types → logs}/index.js +7 -11
  41. package/dist/logs/index.js.map +1 -0
  42. package/dist/logs/manager.d.ts +97 -0
  43. package/dist/logs/manager.d.ts.map +1 -0
  44. package/dist/logs/manager.js +581 -0
  45. package/dist/logs/manager.js.map +1 -0
  46. package/dist/logs/types.d.ts +45 -0
  47. package/dist/logs/types.d.ts.map +1 -0
  48. package/dist/logs/types.js +8 -0
  49. package/dist/logs/types.js.map +1 -0
  50. package/dist/repo/git.d.ts +182 -0
  51. package/dist/repo/git.d.ts.map +1 -0
  52. package/dist/repo/git.js +496 -0
  53. package/dist/repo/git.js.map +1 -0
  54. package/dist/repo/index.d.ts +10 -0
  55. package/dist/repo/index.d.ts.map +1 -0
  56. package/dist/repo/index.js +29 -0
  57. package/dist/repo/index.js.map +1 -0
  58. package/dist/repo/manager.d.ts +179 -0
  59. package/dist/repo/manager.d.ts.map +1 -0
  60. package/dist/repo/manager.js +433 -0
  61. package/dist/repo/manager.js.map +1 -0
  62. package/dist/repo/providers/bitbucket.d.ts +38 -0
  63. package/dist/repo/providers/bitbucket.d.ts.map +1 -0
  64. package/dist/repo/providers/bitbucket.js +76 -0
  65. package/dist/repo/providers/bitbucket.js.map +1 -0
  66. package/dist/repo/providers/github.d.ts +30 -0
  67. package/dist/repo/providers/github.d.ts.map +1 -0
  68. package/dist/repo/providers/github.js +311 -0
  69. package/dist/repo/providers/github.js.map +1 -0
  70. package/dist/repo/providers/gitlab.d.ts +37 -0
  71. package/dist/repo/providers/gitlab.d.ts.map +1 -0
  72. package/dist/repo/providers/gitlab.js +74 -0
  73. package/dist/repo/providers/gitlab.js.map +1 -0
  74. package/dist/repo/providers/index.d.ts +9 -0
  75. package/dist/repo/providers/index.d.ts.map +1 -0
  76. package/dist/repo/providers/index.js +15 -0
  77. package/dist/repo/providers/index.js.map +1 -0
  78. package/dist/repo/types.d.ts +47 -0
  79. package/dist/repo/types.d.ts.map +1 -0
  80. package/dist/repo/types.js +8 -0
  81. package/dist/repo/types.js.map +1 -0
  82. package/dist/spec/index.d.ts +9 -0
  83. package/dist/spec/index.d.ts.map +1 -0
  84. package/dist/spec/index.js +30 -0
  85. package/dist/spec/index.js.map +1 -0
  86. package/dist/spec/manager.d.ts +98 -0
  87. package/dist/spec/manager.d.ts.map +1 -0
  88. package/dist/spec/manager.js +650 -0
  89. package/dist/spec/manager.js.map +1 -0
  90. package/dist/spec/templates.d.ts +28 -0
  91. package/dist/spec/templates.d.ts.map +1 -0
  92. package/dist/spec/templates.js +357 -0
  93. package/dist/spec/templates.js.map +1 -0
  94. package/dist/spec/types.d.ts +53 -0
  95. package/dist/spec/types.d.ts.map +1 -0
  96. package/dist/spec/types.js +8 -0
  97. package/dist/spec/types.js.map +1 -0
  98. package/dist/state/index.d.ts +8 -0
  99. package/dist/state/index.d.ts.map +1 -0
  100. package/dist/state/index.js +26 -0
  101. package/dist/state/index.js.map +1 -0
  102. package/dist/state/manager.d.ts +132 -0
  103. package/dist/state/manager.d.ts.map +1 -0
  104. package/dist/state/manager.js +517 -0
  105. package/dist/state/manager.js.map +1 -0
  106. package/dist/state/types.d.ts +46 -0
  107. package/dist/state/types.d.ts.map +1 -0
  108. package/dist/state/types.js +8 -0
  109. package/dist/state/types.js.map +1 -0
  110. package/dist/storage/codex-adapter.d.ts +62 -0
  111. package/dist/storage/codex-adapter.d.ts.map +1 -0
  112. package/dist/storage/codex-adapter.js +177 -0
  113. package/dist/storage/codex-adapter.js.map +1 -0
  114. package/dist/storage/index.d.ts +9 -0
  115. package/dist/storage/index.d.ts.map +1 -0
  116. package/dist/storage/index.js +15 -0
  117. package/dist/storage/index.js.map +1 -0
  118. package/dist/storage/local.d.ts +42 -0
  119. package/dist/storage/local.d.ts.map +1 -0
  120. package/dist/storage/local.js +137 -0
  121. package/dist/storage/local.js.map +1 -0
  122. package/dist/types.d.ts +603 -0
  123. package/dist/types.d.ts.map +1 -0
  124. package/dist/types.js +8 -0
  125. package/dist/types.js.map +1 -0
  126. package/dist/work/index.d.ts +8 -0
  127. package/dist/work/index.d.ts.map +1 -0
  128. package/dist/work/index.js +26 -0
  129. package/dist/work/index.js.map +1 -0
  130. package/dist/work/manager.d.ts +112 -0
  131. package/dist/work/manager.d.ts.map +1 -0
  132. package/dist/work/manager.js +227 -0
  133. package/dist/work/manager.js.map +1 -0
  134. package/dist/work/providers/github.d.ts +40 -0
  135. package/dist/work/providers/github.d.ts.map +1 -0
  136. package/dist/work/providers/github.js +299 -0
  137. package/dist/work/providers/github.js.map +1 -0
  138. package/dist/work/providers/jira.d.ts +50 -0
  139. package/dist/work/providers/jira.d.ts.map +1 -0
  140. package/dist/work/providers/jira.js +99 -0
  141. package/dist/work/providers/jira.js.map +1 -0
  142. package/dist/work/providers/linear.d.ts +47 -0
  143. package/dist/work/providers/linear.d.ts.map +1 -0
  144. package/dist/work/providers/linear.js +93 -0
  145. package/dist/work/providers/linear.js.map +1 -0
  146. package/dist/work/types.d.ts +41 -0
  147. package/dist/work/types.d.ts.map +1 -0
  148. package/dist/work/types.js +8 -0
  149. package/dist/work/types.js.map +1 -0
  150. package/dist/workflow/faber.d.ts +107 -0
  151. package/dist/workflow/faber.d.ts.map +1 -0
  152. package/dist/workflow/faber.js +606 -0
  153. package/dist/workflow/faber.js.map +1 -0
  154. package/dist/workflow/index.d.ts +8 -0
  155. package/dist/workflow/index.d.ts.map +1 -0
  156. package/dist/workflow/index.js +26 -0
  157. package/dist/workflow/index.js.map +1 -0
  158. package/dist/workflow/types.d.ts +54 -0
  159. package/dist/workflow/types.d.ts.map +1 -0
  160. package/dist/workflow/types.js +8 -0
  161. package/dist/workflow/types.js.map +1 -0
  162. package/package.json +42 -28
  163. package/dist/api.d.ts +0 -81
  164. package/dist/api.d.ts.map +0 -1
  165. package/dist/api.js +0 -261
  166. package/dist/api.js.map +0 -1
  167. package/dist/bindings/claude-code/transformer.d.ts +0 -55
  168. package/dist/bindings/claude-code/transformer.d.ts.map +0 -1
  169. package/dist/bindings/claude-code/transformer.js +0 -271
  170. package/dist/bindings/claude-code/transformer.js.map +0 -1
  171. package/dist/bindings/index.d.ts +0 -21
  172. package/dist/bindings/index.d.ts.map +0 -1
  173. package/dist/bindings/index.js +0 -43
  174. package/dist/bindings/index.js.map +0 -1
  175. package/dist/core/concepts/base.d.ts +0 -89
  176. package/dist/core/concepts/base.d.ts.map +0 -1
  177. package/dist/core/concepts/base.js +0 -230
  178. package/dist/core/concepts/base.js.map +0 -1
  179. package/dist/core/concepts/eval.d.ts +0 -90
  180. package/dist/core/concepts/eval.d.ts.map +0 -1
  181. package/dist/core/concepts/eval.js +0 -118
  182. package/dist/core/concepts/eval.js.map +0 -1
  183. package/dist/core/concepts/index.d.ts +0 -9
  184. package/dist/core/concepts/index.d.ts.map +0 -1
  185. package/dist/core/concepts/index.js +0 -36
  186. package/dist/core/concepts/index.js.map +0 -1
  187. package/dist/core/concepts/role.d.ts +0 -19
  188. package/dist/core/concepts/role.d.ts.map +0 -1
  189. package/dist/core/concepts/role.js +0 -227
  190. package/dist/core/concepts/role.js.map +0 -1
  191. package/dist/core/concepts/team.d.ts +0 -57
  192. package/dist/core/concepts/team.d.ts.map +0 -1
  193. package/dist/core/concepts/team.js +0 -106
  194. package/dist/core/concepts/team.js.map +0 -1
  195. package/dist/core/concepts/tool.d.ts +0 -43
  196. package/dist/core/concepts/tool.d.ts.map +0 -1
  197. package/dist/core/concepts/tool.js +0 -104
  198. package/dist/core/concepts/tool.js.map +0 -1
  199. package/dist/core/concepts/workflow.d.ts +0 -87
  200. package/dist/core/concepts/workflow.d.ts.map +0 -1
  201. package/dist/core/concepts/workflow.js +0 -114
  202. package/dist/core/concepts/workflow.js.map +0 -1
  203. package/dist/core/config/index.d.ts +0 -34
  204. package/dist/core/config/index.d.ts.map +0 -1
  205. package/dist/core/config/index.js +0 -80
  206. package/dist/core/config/index.js.map +0 -1
  207. package/dist/core/config/loader.d.ts +0 -53
  208. package/dist/core/config/loader.d.ts.map +0 -1
  209. package/dist/core/config/loader.js +0 -234
  210. package/dist/core/config/loader.js.map +0 -1
  211. package/dist/core/contexts/index.d.ts +0 -36
  212. package/dist/core/contexts/index.d.ts.map +0 -1
  213. package/dist/core/contexts/index.js +0 -75
  214. package/dist/core/contexts/index.js.map +0 -1
  215. package/dist/core/contexts/loader.d.ts +0 -66
  216. package/dist/core/contexts/loader.d.ts.map +0 -1
  217. package/dist/core/contexts/loader.js +0 -261
  218. package/dist/core/contexts/loader.js.map +0 -1
  219. package/dist/core/overlays/index.d.ts +0 -31
  220. package/dist/core/overlays/index.d.ts.map +0 -1
  221. package/dist/core/overlays/index.js +0 -82
  222. package/dist/core/overlays/index.js.map +0 -1
  223. package/dist/core/overlays/resolver.d.ts +0 -65
  224. package/dist/core/overlays/resolver.d.ts.map +0 -1
  225. package/dist/core/overlays/resolver.js +0 -249
  226. package/dist/core/overlays/resolver.js.map +0 -1
  227. package/dist/types/bindings.d.ts +0 -59
  228. package/dist/types/bindings.d.ts.map +0 -1
  229. package/dist/types/bindings.js +0 -6
  230. package/dist/types/bindings.js.map +0 -1
  231. package/dist/types/concepts.d.ts +0 -131
  232. package/dist/types/concepts.d.ts.map +0 -1
  233. package/dist/types/concepts.js +0 -29
  234. package/dist/types/concepts.js.map +0 -1
  235. package/dist/types/config.d.ts +0 -42
  236. package/dist/types/config.d.ts.map +0 -1
  237. package/dist/types/config.js +0 -6
  238. package/dist/types/config.js.map +0 -1
  239. package/dist/types/contexts.d.ts +0 -59
  240. package/dist/types/contexts.d.ts.map +0 -1
  241. package/dist/types/contexts.js +0 -17
  242. package/dist/types/contexts.js.map +0 -1
  243. package/dist/types/index.d.ts +0 -17
  244. package/dist/types/index.d.ts.map +0 -1
  245. package/dist/types/index.js.map +0 -1
  246. package/dist/types/overlays.d.ts +0 -28
  247. package/dist/types/overlays.d.ts.map +0 -1
  248. package/dist/types/overlays.js +0 -15
  249. package/dist/types/overlays.js.map +0 -1
  250. package/dist/utils/file-system.d.ts +0 -40
  251. package/dist/utils/file-system.d.ts.map +0 -1
  252. package/dist/utils/file-system.js +0 -105
  253. package/dist/utils/file-system.js.map +0 -1
  254. package/dist/utils/template.d.ts +0 -28
  255. package/dist/utils/template.d.ts.map +0 -1
  256. package/dist/utils/template.js +0 -107
  257. package/dist/utils/template.js.map +0 -1
  258. package/dist/utils/validation.d.ts +0 -42
  259. package/dist/utils/validation.d.ts.map +0 -1
  260. package/dist/utils/validation.js +0 -94
  261. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @fractary/faber - Git CLI Wrapper
3
+ *
4
+ * Low-level Git operations using the git CLI.
5
+ */
6
+ import { GitStatus, Commit, CommitOptions, Branch, Tag, Worktree } from '../types';
7
+ /**
8
+ * Git CLI wrapper class
9
+ */
10
+ export declare class Git {
11
+ private cwd;
12
+ constructor(cwd?: string);
13
+ /**
14
+ * Execute a raw git command
15
+ */
16
+ exec(args: string): string;
17
+ /**
18
+ * Get repository status
19
+ */
20
+ getStatus(): GitStatus;
21
+ /**
22
+ * Get current branch name
23
+ */
24
+ getCurrentBranch(): string;
25
+ /**
26
+ * Get tracking info (ahead/behind)
27
+ */
28
+ private getTrackingInfo;
29
+ /**
30
+ * Get staged files
31
+ */
32
+ private getStagedFiles;
33
+ /**
34
+ * Get modified files
35
+ */
36
+ private getModifiedFiles;
37
+ /**
38
+ * Get untracked files
39
+ */
40
+ private getUntrackedFiles;
41
+ /**
42
+ * Get files with conflicts
43
+ */
44
+ private getConflictFiles;
45
+ /**
46
+ * Check if working directory has uncommitted changes
47
+ */
48
+ isDirty(): boolean;
49
+ /**
50
+ * Check if working directory is clean
51
+ */
52
+ isClean(): boolean;
53
+ /**
54
+ * Create a new branch
55
+ */
56
+ createBranch(name: string, baseBranch?: string): void;
57
+ /**
58
+ * Switch to a branch
59
+ */
60
+ checkout(branch: string): void;
61
+ /**
62
+ * Delete a branch
63
+ */
64
+ deleteBranch(name: string, force?: boolean): void;
65
+ /**
66
+ * Delete a remote branch
67
+ */
68
+ deleteRemoteBranch(name: string, remote?: string): void;
69
+ /**
70
+ * List local branches
71
+ */
72
+ listBranches(): Branch[];
73
+ /**
74
+ * Get default branch name
75
+ */
76
+ getDefaultBranch(): string;
77
+ /**
78
+ * Check if branch is protected (simple heuristic)
79
+ */
80
+ isProtectedBranch(name: string): boolean;
81
+ /**
82
+ * Check if branch exists
83
+ */
84
+ branchExists(name: string): boolean;
85
+ /**
86
+ * Stage files
87
+ */
88
+ stage(patterns: string[]): void;
89
+ /**
90
+ * Stage all changes
91
+ */
92
+ stageAll(): void;
93
+ /**
94
+ * Unstage files
95
+ */
96
+ unstage(patterns: string[]): void;
97
+ /**
98
+ * Create a commit
99
+ */
100
+ commit(options: CommitOptions): Commit;
101
+ /**
102
+ * Get a commit by ref
103
+ */
104
+ getCommit(ref: string): Commit;
105
+ /**
106
+ * List commits
107
+ */
108
+ listCommits(options?: {
109
+ branch?: string;
110
+ limit?: number;
111
+ since?: string;
112
+ }): Commit[];
113
+ /**
114
+ * Get diff
115
+ */
116
+ getDiff(options?: {
117
+ staged?: boolean;
118
+ base?: string;
119
+ head?: string;
120
+ }): string;
121
+ /**
122
+ * Push to remote
123
+ */
124
+ push(options?: {
125
+ branch?: string;
126
+ remote?: string;
127
+ setUpstream?: boolean;
128
+ force?: boolean;
129
+ forceWithLease?: boolean;
130
+ }): void;
131
+ /**
132
+ * Pull from remote
133
+ */
134
+ pull(options?: {
135
+ branch?: string;
136
+ remote?: string;
137
+ rebase?: boolean;
138
+ }): void;
139
+ /**
140
+ * Fetch from remote
141
+ */
142
+ fetch(remote?: string): void;
143
+ /**
144
+ * Create a tag
145
+ */
146
+ createTag(name: string, options?: {
147
+ message?: string;
148
+ sha?: string;
149
+ }): void;
150
+ /**
151
+ * Delete a tag
152
+ */
153
+ deleteTag(name: string): void;
154
+ /**
155
+ * Push a tag
156
+ */
157
+ pushTag(name: string, remote?: string): void;
158
+ /**
159
+ * List tags
160
+ */
161
+ listTags(options?: {
162
+ pattern?: string;
163
+ limit?: number;
164
+ }): Tag[];
165
+ /**
166
+ * Create a worktree
167
+ */
168
+ createWorktree(path: string, branch: string, baseBranch?: string): void;
169
+ /**
170
+ * List worktrees
171
+ */
172
+ listWorktrees(): Worktree[];
173
+ /**
174
+ * Remove a worktree
175
+ */
176
+ removeWorktree(path: string, force?: boolean): void;
177
+ /**
178
+ * Prune stale worktrees
179
+ */
180
+ pruneWorktrees(): void;
181
+ }
182
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/repo/git.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,496 @@
1
+ "use strict";
2
+ /**
3
+ * @fractary/faber - Git CLI Wrapper
4
+ *
5
+ * Low-level Git operations using the git CLI.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Git = void 0;
9
+ const child_process_1 = require("child_process");
10
+ const errors_1 = require("../errors");
11
+ const config_1 = require("../config");
12
+ /**
13
+ * Execute a git command
14
+ */
15
+ function git(args, cwd) {
16
+ const execOptions = {
17
+ encoding: 'utf-8',
18
+ cwd: cwd || (0, config_1.findProjectRoot)(),
19
+ maxBuffer: 10 * 1024 * 1024,
20
+ };
21
+ try {
22
+ const result = (0, child_process_1.execSync)(`git ${args}`, execOptions);
23
+ return (typeof result === 'string' ? result : result.toString()).trim();
24
+ }
25
+ catch (error) {
26
+ const err = error;
27
+ const exitCode = err.status || 1;
28
+ const stderr = err.stderr?.toString() || '';
29
+ throw new errors_1.CommandExecutionError(`git ${args}`, exitCode, stderr);
30
+ }
31
+ }
32
+ /**
33
+ * Git CLI wrapper class
34
+ */
35
+ class Git {
36
+ cwd;
37
+ constructor(cwd) {
38
+ this.cwd = cwd || (0, config_1.findProjectRoot)();
39
+ }
40
+ /**
41
+ * Execute a raw git command
42
+ */
43
+ exec(args) {
44
+ return git(args, this.cwd);
45
+ }
46
+ // =========================================================================
47
+ // STATUS & INFO
48
+ // =========================================================================
49
+ /**
50
+ * Get repository status
51
+ */
52
+ getStatus() {
53
+ const branch = this.getCurrentBranch();
54
+ const tracking = this.getTrackingInfo();
55
+ const staged = this.getStagedFiles();
56
+ const modified = this.getModifiedFiles();
57
+ const untracked = this.getUntrackedFiles();
58
+ const conflicts = this.getConflictFiles();
59
+ return {
60
+ branch,
61
+ ahead: tracking.ahead,
62
+ behind: tracking.behind,
63
+ staged,
64
+ modified,
65
+ untracked,
66
+ conflicts,
67
+ };
68
+ }
69
+ /**
70
+ * Get current branch name
71
+ */
72
+ getCurrentBranch() {
73
+ return git('rev-parse --abbrev-ref HEAD', this.cwd);
74
+ }
75
+ /**
76
+ * Get tracking info (ahead/behind)
77
+ */
78
+ getTrackingInfo() {
79
+ try {
80
+ const result = git('rev-list --left-right --count HEAD...@{upstream}', this.cwd);
81
+ const [ahead, behind] = result.split('\t').map(n => parseInt(n, 10));
82
+ return { ahead: ahead || 0, behind: behind || 0 };
83
+ }
84
+ catch {
85
+ return { ahead: 0, behind: 0 };
86
+ }
87
+ }
88
+ /**
89
+ * Get staged files
90
+ */
91
+ getStagedFiles() {
92
+ try {
93
+ const result = git('diff --cached --name-only', this.cwd);
94
+ return result ? result.split('\n').filter(f => f) : [];
95
+ }
96
+ catch {
97
+ return [];
98
+ }
99
+ }
100
+ /**
101
+ * Get modified files
102
+ */
103
+ getModifiedFiles() {
104
+ try {
105
+ const result = git('diff --name-only', this.cwd);
106
+ return result ? result.split('\n').filter(f => f) : [];
107
+ }
108
+ catch {
109
+ return [];
110
+ }
111
+ }
112
+ /**
113
+ * Get untracked files
114
+ */
115
+ getUntrackedFiles() {
116
+ try {
117
+ const result = git('ls-files --others --exclude-standard', this.cwd);
118
+ return result ? result.split('\n').filter(f => f) : [];
119
+ }
120
+ catch {
121
+ return [];
122
+ }
123
+ }
124
+ /**
125
+ * Get files with conflicts
126
+ */
127
+ getConflictFiles() {
128
+ try {
129
+ const result = git('diff --name-only --diff-filter=U', this.cwd);
130
+ return result ? result.split('\n').filter(f => f) : [];
131
+ }
132
+ catch {
133
+ return [];
134
+ }
135
+ }
136
+ /**
137
+ * Check if working directory has uncommitted changes
138
+ */
139
+ isDirty() {
140
+ const status = this.getStatus();
141
+ return status.staged.length > 0 ||
142
+ status.modified.length > 0 ||
143
+ status.conflicts.length > 0;
144
+ }
145
+ /**
146
+ * Check if working directory is clean
147
+ */
148
+ isClean() {
149
+ return !this.isDirty();
150
+ }
151
+ // =========================================================================
152
+ // BRANCHES
153
+ // =========================================================================
154
+ /**
155
+ * Create a new branch
156
+ */
157
+ createBranch(name, baseBranch) {
158
+ if (baseBranch) {
159
+ git(`checkout -b ${name} ${baseBranch}`, this.cwd);
160
+ }
161
+ else {
162
+ git(`checkout -b ${name}`, this.cwd);
163
+ }
164
+ }
165
+ /**
166
+ * Switch to a branch
167
+ */
168
+ checkout(branch) {
169
+ git(`checkout ${branch}`, this.cwd);
170
+ }
171
+ /**
172
+ * Delete a branch
173
+ */
174
+ deleteBranch(name, force = false) {
175
+ const flag = force ? '-D' : '-d';
176
+ git(`branch ${flag} ${name}`, this.cwd);
177
+ }
178
+ /**
179
+ * Delete a remote branch
180
+ */
181
+ deleteRemoteBranch(name, remote = 'origin') {
182
+ git(`push ${remote} --delete ${name}`, this.cwd);
183
+ }
184
+ /**
185
+ * List local branches
186
+ */
187
+ listBranches() {
188
+ const result = git('branch --format="%(refname:short)|%(objectname:short)|%(upstream:short)"', this.cwd);
189
+ if (!result)
190
+ return [];
191
+ return result.split('\n').filter(l => l).map(line => {
192
+ const [name, sha, upstream] = line.split('|');
193
+ const defaultBranch = this.getDefaultBranch();
194
+ return {
195
+ name,
196
+ sha,
197
+ isDefault: name === defaultBranch,
198
+ isProtected: this.isProtectedBranch(name),
199
+ upstream: upstream || undefined,
200
+ };
201
+ });
202
+ }
203
+ /**
204
+ * Get default branch name
205
+ */
206
+ getDefaultBranch() {
207
+ try {
208
+ const result = git('symbolic-ref refs/remotes/origin/HEAD', this.cwd);
209
+ return result.replace('refs/remotes/origin/', '');
210
+ }
211
+ catch {
212
+ return 'main';
213
+ }
214
+ }
215
+ /**
216
+ * Check if branch is protected (simple heuristic)
217
+ */
218
+ isProtectedBranch(name) {
219
+ const protectedNames = ['main', 'master', 'develop', 'production', 'staging'];
220
+ return protectedNames.includes(name);
221
+ }
222
+ /**
223
+ * Check if branch exists
224
+ */
225
+ branchExists(name) {
226
+ try {
227
+ git(`rev-parse --verify ${name}`, this.cwd);
228
+ return true;
229
+ }
230
+ catch {
231
+ return false;
232
+ }
233
+ }
234
+ // =========================================================================
235
+ // COMMITS
236
+ // =========================================================================
237
+ /**
238
+ * Stage files
239
+ */
240
+ stage(patterns) {
241
+ git(`add ${patterns.join(' ')}`, this.cwd);
242
+ }
243
+ /**
244
+ * Stage all changes
245
+ */
246
+ stageAll() {
247
+ git('add -A', this.cwd);
248
+ }
249
+ /**
250
+ * Unstage files
251
+ */
252
+ unstage(patterns) {
253
+ git(`reset HEAD ${patterns.join(' ')}`, this.cwd);
254
+ }
255
+ /**
256
+ * Create a commit
257
+ */
258
+ commit(options) {
259
+ // Build commit message
260
+ let message = options.message;
261
+ if (options.type) {
262
+ const scope = options.scope ? `(${options.scope})` : '';
263
+ message = `${options.type}${scope}: ${options.message}`;
264
+ }
265
+ if (options.body) {
266
+ message += `\n\n${options.body}`;
267
+ }
268
+ if (options.workId) {
269
+ message += `\n\nWork-Item: ${options.workId}`;
270
+ }
271
+ if (options.breaking) {
272
+ message += '\n\nBREAKING CHANGE: Breaking changes included';
273
+ }
274
+ if (options.coAuthors && options.coAuthors.length > 0) {
275
+ message += '\n\n' + options.coAuthors.map(a => `Co-Authored-By: ${a}`).join('\n');
276
+ }
277
+ // Execute commit
278
+ const args = options.allowEmpty ? '--allow-empty' : '';
279
+ git(`commit ${args} -m "${message.replace(/"/g, '\\"')}"`, this.cwd);
280
+ // Get the commit we just made
281
+ return this.getCommit('HEAD');
282
+ }
283
+ /**
284
+ * Get a commit by ref
285
+ */
286
+ getCommit(ref) {
287
+ const format = '%H|%s|%an|%ae|%aI|%P';
288
+ const result = git(`log -1 --format="${format}" ${ref}`, this.cwd);
289
+ const [sha, message, author, authorEmail, date, parents] = result.split('|');
290
+ return {
291
+ sha,
292
+ message,
293
+ author,
294
+ authorEmail,
295
+ date,
296
+ parents: parents ? parents.split(' ') : [],
297
+ };
298
+ }
299
+ /**
300
+ * List commits
301
+ */
302
+ listCommits(options) {
303
+ const format = '%H|%s|%an|%ae|%aI|%P';
304
+ const args = [`--format="${format}"`];
305
+ if (options?.limit) {
306
+ args.push(`-n ${options.limit}`);
307
+ }
308
+ if (options?.since) {
309
+ args.push(`--since="${options.since}"`);
310
+ }
311
+ if (options?.branch) {
312
+ args.push(options.branch);
313
+ }
314
+ const result = git(`log ${args.join(' ')}`, this.cwd);
315
+ if (!result)
316
+ return [];
317
+ return result.split('\n').filter(l => l).map(line => {
318
+ const [sha, message, author, authorEmail, date, parents] = line.split('|');
319
+ return {
320
+ sha,
321
+ message,
322
+ author,
323
+ authorEmail,
324
+ date,
325
+ parents: parents ? parents.split(' ') : [],
326
+ };
327
+ });
328
+ }
329
+ /**
330
+ * Get diff
331
+ */
332
+ getDiff(options) {
333
+ const args = [];
334
+ if (options?.staged) {
335
+ args.push('--cached');
336
+ }
337
+ if (options?.base && options?.head) {
338
+ args.push(`${options.base}...${options.head}`);
339
+ }
340
+ else if (options?.base) {
341
+ args.push(options.base);
342
+ }
343
+ return git(`diff ${args.join(' ')}`, this.cwd);
344
+ }
345
+ // =========================================================================
346
+ // PUSH/PULL
347
+ // =========================================================================
348
+ /**
349
+ * Push to remote
350
+ */
351
+ push(options) {
352
+ const args = [];
353
+ const remote = options?.remote || 'origin';
354
+ const branch = options?.branch || this.getCurrentBranch();
355
+ args.push(remote);
356
+ args.push(branch);
357
+ if (options?.setUpstream) {
358
+ args.unshift('-u');
359
+ }
360
+ if (options?.forceWithLease) {
361
+ args.unshift('--force-with-lease');
362
+ }
363
+ else if (options?.force) {
364
+ args.unshift('--force');
365
+ }
366
+ git(`push ${args.join(' ')}`, this.cwd);
367
+ }
368
+ /**
369
+ * Pull from remote
370
+ */
371
+ pull(options) {
372
+ const args = [];
373
+ if (options?.rebase) {
374
+ args.push('--rebase');
375
+ }
376
+ const remote = options?.remote || 'origin';
377
+ const branch = options?.branch || this.getCurrentBranch();
378
+ git(`pull ${args.join(' ')} ${remote} ${branch}`, this.cwd);
379
+ }
380
+ /**
381
+ * Fetch from remote
382
+ */
383
+ fetch(remote = 'origin') {
384
+ git(`fetch ${remote}`, this.cwd);
385
+ }
386
+ // =========================================================================
387
+ // TAGS
388
+ // =========================================================================
389
+ /**
390
+ * Create a tag
391
+ */
392
+ createTag(name, options) {
393
+ const args = [];
394
+ if (options?.message) {
395
+ args.push(`-a -m "${options.message.replace(/"/g, '\\"')}"`);
396
+ }
397
+ args.push(name);
398
+ if (options?.sha) {
399
+ args.push(options.sha);
400
+ }
401
+ git(`tag ${args.join(' ')}`, this.cwd);
402
+ }
403
+ /**
404
+ * Delete a tag
405
+ */
406
+ deleteTag(name) {
407
+ git(`tag -d ${name}`, this.cwd);
408
+ }
409
+ /**
410
+ * Push a tag
411
+ */
412
+ pushTag(name, remote = 'origin') {
413
+ git(`push ${remote} ${name}`, this.cwd);
414
+ }
415
+ /**
416
+ * List tags
417
+ */
418
+ listTags(options) {
419
+ const args = ['--format="%(refname:short)|%(objectname:short)|%(taggerdate:iso)"'];
420
+ if (options?.pattern) {
421
+ args.push(`-l "${options.pattern}"`);
422
+ }
423
+ const result = git(`tag ${args.join(' ')}`, this.cwd);
424
+ if (!result)
425
+ return [];
426
+ let tags = result.split('\n').filter(l => l).map(line => {
427
+ const [name, sha, date] = line.split('|');
428
+ return { name, sha, date };
429
+ });
430
+ if (options?.limit) {
431
+ tags = tags.slice(-options.limit);
432
+ }
433
+ return tags;
434
+ }
435
+ // =========================================================================
436
+ // WORKTREES
437
+ // =========================================================================
438
+ /**
439
+ * Create a worktree
440
+ */
441
+ createWorktree(path, branch, baseBranch) {
442
+ if (baseBranch) {
443
+ git(`worktree add -b ${branch} ${path} ${baseBranch}`, this.cwd);
444
+ }
445
+ else {
446
+ git(`worktree add ${path} ${branch}`, this.cwd);
447
+ }
448
+ }
449
+ /**
450
+ * List worktrees
451
+ */
452
+ listWorktrees() {
453
+ const result = git('worktree list --porcelain', this.cwd);
454
+ if (!result)
455
+ return [];
456
+ const worktrees = [];
457
+ let current = {};
458
+ for (const line of result.split('\n')) {
459
+ if (line.startsWith('worktree ')) {
460
+ if (current.path) {
461
+ worktrees.push(current);
462
+ }
463
+ current = { path: line.substring(9) };
464
+ }
465
+ else if (line.startsWith('HEAD ')) {
466
+ current.sha = line.substring(5);
467
+ }
468
+ else if (line.startsWith('branch ')) {
469
+ current.branch = line.substring(7).replace('refs/heads/', '');
470
+ }
471
+ }
472
+ if (current.path) {
473
+ worktrees.push(current);
474
+ }
475
+ // Mark main worktree
476
+ if (worktrees.length > 0) {
477
+ worktrees[0].isMain = true;
478
+ }
479
+ return worktrees;
480
+ }
481
+ /**
482
+ * Remove a worktree
483
+ */
484
+ removeWorktree(path, force = false) {
485
+ const flag = force ? '--force' : '';
486
+ git(`worktree remove ${flag} ${path}`, this.cwd);
487
+ }
488
+ /**
489
+ * Prune stale worktrees
490
+ */
491
+ pruneWorktrees() {
492
+ git('worktree prune', this.cwd);
493
+ }
494
+ }
495
+ exports.Git = Git;
496
+ //# sourceMappingURL=git.js.map