type-git 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 (105) hide show
  1. package/README.md +3 -6
  2. package/dist/adapters/bun/index.cjs +395 -0
  3. package/dist/adapters/bun/index.cjs.map +1 -0
  4. package/dist/adapters/bun/index.d.cts +44 -0
  5. package/dist/adapters/bun/index.d.ts +38 -5
  6. package/dist/adapters/bun/index.js +362 -13
  7. package/dist/adapters/bun/index.js.map +1 -1
  8. package/dist/adapters/deno/index.cjs +443 -0
  9. package/dist/adapters/deno/index.cjs.map +1 -0
  10. package/dist/adapters/deno/index.d.cts +46 -0
  11. package/dist/adapters/deno/index.d.ts +40 -5
  12. package/dist/adapters/deno/index.js +410 -13
  13. package/dist/adapters/deno/index.js.map +1 -1
  14. package/dist/adapters/node/index.cjs +5625 -0
  15. package/dist/adapters/node/index.cjs.map +1 -0
  16. package/dist/adapters/node/index.d.cts +2 -0
  17. package/dist/adapters/node/index.d.ts +2 -61
  18. package/dist/adapters/node/index.js +5577 -68
  19. package/dist/adapters/node/index.js.map +1 -1
  20. package/dist/{core/types.d.ts → adapters-w9tZ_Qbd.d.cts} +225 -29
  21. package/dist/adapters-w9tZ_Qbd.d.ts +572 -0
  22. package/dist/index-D9acU30I.d.ts +3649 -0
  23. package/dist/index-DRd85eN5.d.cts +3649 -0
  24. package/dist/index.cjs +5744 -0
  25. package/dist/index.cjs.map +1 -0
  26. package/dist/index.d.cts +208 -0
  27. package/dist/index.d.ts +206 -7
  28. package/dist/index.js +5685 -13
  29. package/dist/index.js.map +1 -1
  30. package/package.json +19 -8
  31. package/dist/adapters/bun/exec.d.ts +0 -13
  32. package/dist/adapters/bun/exec.d.ts.map +0 -1
  33. package/dist/adapters/bun/exec.js +0 -242
  34. package/dist/adapters/bun/exec.js.map +0 -1
  35. package/dist/adapters/bun/fs.d.ts +0 -20
  36. package/dist/adapters/bun/fs.d.ts.map +0 -1
  37. package/dist/adapters/bun/fs.js +0 -148
  38. package/dist/adapters/bun/fs.js.map +0 -1
  39. package/dist/adapters/bun/index.d.ts.map +0 -1
  40. package/dist/adapters/deno/exec.d.ts +0 -14
  41. package/dist/adapters/deno/exec.d.ts.map +0 -1
  42. package/dist/adapters/deno/exec.js +0 -266
  43. package/dist/adapters/deno/exec.js.map +0 -1
  44. package/dist/adapters/deno/fs.d.ts +0 -21
  45. package/dist/adapters/deno/fs.d.ts.map +0 -1
  46. package/dist/adapters/deno/fs.js +0 -191
  47. package/dist/adapters/deno/fs.js.map +0 -1
  48. package/dist/adapters/deno/index.d.ts.map +0 -1
  49. package/dist/adapters/node/exec.d.ts +0 -11
  50. package/dist/adapters/node/exec.d.ts.map +0 -1
  51. package/dist/adapters/node/exec.js +0 -161
  52. package/dist/adapters/node/exec.js.map +0 -1
  53. package/dist/adapters/node/fs.d.ts +0 -18
  54. package/dist/adapters/node/fs.d.ts.map +0 -1
  55. package/dist/adapters/node/fs.js +0 -164
  56. package/dist/adapters/node/fs.js.map +0 -1
  57. package/dist/adapters/node/index.d.ts.map +0 -1
  58. package/dist/core/adapters.d.ts +0 -192
  59. package/dist/core/adapters.d.ts.map +0 -1
  60. package/dist/core/adapters.js +0 -10
  61. package/dist/core/adapters.js.map +0 -1
  62. package/dist/core/git.d.ts +0 -160
  63. package/dist/core/git.d.ts.map +0 -1
  64. package/dist/core/git.js +0 -5
  65. package/dist/core/git.js.map +0 -1
  66. package/dist/core/index.d.ts +0 -8
  67. package/dist/core/index.d.ts.map +0 -1
  68. package/dist/core/index.js +0 -8
  69. package/dist/core/index.js.map +0 -1
  70. package/dist/core/repo.d.ts +0 -1275
  71. package/dist/core/repo.d.ts.map +0 -1
  72. package/dist/core/repo.js +0 -5
  73. package/dist/core/repo.js.map +0 -1
  74. package/dist/core/types.d.ts.map +0 -1
  75. package/dist/core/types.js +0 -100
  76. package/dist/core/types.js.map +0 -1
  77. package/dist/impl/bare-repo-impl.d.ts +0 -72
  78. package/dist/impl/bare-repo-impl.d.ts.map +0 -1
  79. package/dist/impl/bare-repo-impl.js +0 -328
  80. package/dist/impl/bare-repo-impl.js.map +0 -1
  81. package/dist/impl/git-impl.d.ts +0 -92
  82. package/dist/impl/git-impl.d.ts.map +0 -1
  83. package/dist/impl/git-impl.js +0 -350
  84. package/dist/impl/git-impl.js.map +0 -1
  85. package/dist/impl/index.d.ts +0 -7
  86. package/dist/impl/index.d.ts.map +0 -1
  87. package/dist/impl/index.js +0 -7
  88. package/dist/impl/index.js.map +0 -1
  89. package/dist/impl/worktree-repo-impl.d.ts +0 -180
  90. package/dist/impl/worktree-repo-impl.d.ts.map +0 -1
  91. package/dist/impl/worktree-repo-impl.js +0 -1931
  92. package/dist/impl/worktree-repo-impl.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/parsers/index.d.ts +0 -230
  95. package/dist/parsers/index.d.ts.map +0 -1
  96. package/dist/parsers/index.js +0 -529
  97. package/dist/parsers/index.js.map +0 -1
  98. package/dist/runner/cli-runner.d.ts +0 -94
  99. package/dist/runner/cli-runner.d.ts.map +0 -1
  100. package/dist/runner/cli-runner.js +0 -315
  101. package/dist/runner/cli-runner.js.map +0 -1
  102. package/dist/runner/index.d.ts +0 -5
  103. package/dist/runner/index.d.ts.map +0 -1
  104. package/dist/runner/index.js +0 -5
  105. package/dist/runner/index.js.map +0 -1
@@ -0,0 +1,208 @@
1
+ export { A as AddOpts, b7 as BareRepo, t as BranchCreateOpts, u as BranchDeleteOpts, B as BranchInfo, aO as BranchOperations, s as BranchOpts, v as CheckoutBranchOpts, x as CheckoutOpts, w as CheckoutPathOpts, $ as CherryPickOpts, a0 as CleanOpts, a as CliRunner, b as CliRunnerOptions, g as CloneOpts, p as Commit, y as CommitOpts, z as CommitResult, a_ as ConfigEntry, a$ as ConfigGetOpts, b3 as ConfigKey, b1 as ConfigListOpts, b4 as ConfigOperations, b2 as ConfigSchema, b0 as ConfigSetOpts, C as CreateGitOptions, E as DiffEntry, D as DiffOpts, H as DiffResult, F as FetchOpts, r as ForceWithLeaseOpts, m as Git, k as GlobalConfigListOpts, l as GlobalConfigOperations, G as GlobalLfsInstallOpts, j as GlobalLfsOperations, i as GlobalLfsUninstallOpts, I as InitOpts, av as LfsCheckoutOpts, az as LfsEnvInfo, aN as LfsExtraOperations, ak as LfsFetchOpts, an as LfsFileEntry, ar as LfsLockEntry, as as LfsLockOpts, au as LfsLocksOpts, ao as LfsLsFilesOpts, ay as LfsMigrateExportOpts, ax as LfsMigrateImportOpts, aw as LfsMigrateInfoOpts, aM as LfsOperations, aC as LfsPreDownloadOpts, aD as LfsPreDownloadResult, aA as LfsPreUploadOpts, aB as LfsPreUploadResult, aj as LfsPruneOpts, ag as LfsPullOpts, ah as LfsPushOpts, af as LfsStatus, ai as LfsStatusOpts, ap as LfsTrackEntry, aq as LfsTrackOpts, at as LfsUnlockOpts, q as LogOpts, L as LsRemoteOpts, h as LsRemoteResult, M as MergeOpts, J as MergeResult, a1 as MvOpts, N as NodeExecAdapter, f as NodeFsAdapter, K as PullOpts, P as PushOpts, a2 as RebaseOpts, aS as RemoteAddOpts, aR as RemoteInfo, aZ as RemoteOperations, aV as RemotePruneOpts, aX as RemoteSetBranchesOpts, aT as RemoteSetHeadOpts, aU as RemoteShowOpts, aW as RemoteUpdateOpts, aY as RemoteUrlOpts, R as RepoBase, al as RepoLfsInstallOpts, am as RepoLfsUninstallOpts, O as ResetOpts, a3 as RestoreOpts, a4 as RevertOpts, Q as RmOpts, a5 as ShowOpts, W as StashApplyOpts, U as StashEntry, aP as StashOperations, V as StashPushOpts, S as StatusEntry, o as StatusOpts, n as StatusPorcelain, a7 as SubmoduleAddOpts, a8 as SubmoduleDeinitOpts, ab as SubmoduleForeachOpts, ae as SubmoduleInfo, b5 as SubmoduleOperations, a6 as SubmoduleOpts, ad as SubmoduleSetBranchOpts, a9 as SubmoduleStatusOpts, aa as SubmoduleSummaryOpts, ac as SubmoduleSyncOpts, X as SwitchOpts, _ as TagCreateOpts, Y as TagInfo, Z as TagListOpts, aQ as TagOperations, e as TypeGit, T as TypeGitOptions, aE as Worktree, aF as WorktreeAddOpts, aK as WorktreeLockOpts, aI as WorktreeMoveOpts, aL as WorktreeOperations, aH as WorktreePruneOpts, aG as WorktreeRemoveOpts, aJ as WorktreeRepairOpts, b6 as WorktreeRepo, c as createGit, d as createNodeAdapters } from './index-DRd85eN5.cjs';
2
+ import { G as GitErrorCategory } from './adapters-w9tZ_Qbd.cjs';
3
+ export { A as AdapterFactory, C as Capabilities, o as CommandSpec, s as Credential, t as CredentialConfig, r as CredentialRequest, E as ExecAdapter, f as ExecOpts, p as ExecutionContext, F as FsAdapter, k as GitArgumentError, j as GitError, h as GitErrorKind, q as GitOpenOptions, e as GitProgress, m as LfsMode, L as LfsProgress, N as NonEmptyString, O as OutputContract, g as RawResult, l as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, a as SpawnResult, b as StreamHandler, d as TailHandle, T as TailOptions, i as isNonEmpty, n as nonEmpty } from './adapters-w9tZ_Qbd.cjs';
4
+
5
+ /**
6
+ * stdout parsing utilities for Git output
7
+ *
8
+ * This module provides:
9
+ * - parseLines: Parse newline-separated output
10
+ * - parseRecords: Parse delimited records (NUL-terminated or custom)
11
+ * - parseJson: Parse JSON output
12
+ * - parseKeyValue: Parse key-value pairs
13
+ */
14
+ /**
15
+ * Parse newline-separated output into lines
16
+ *
17
+ * @param stdout - Raw stdout string
18
+ * @param options - Parse options
19
+ * @returns Array of non-empty lines
20
+ */
21
+ declare function parseLines(stdout: string, options?: {
22
+ /** Keep empty lines (default: false) */
23
+ keepEmpty?: boolean;
24
+ /** Trim each line (default: true) */
25
+ trim?: boolean;
26
+ }): string[];
27
+ /**
28
+ * Parse delimited records (e.g., NUL-terminated for --format with %x00)
29
+ *
30
+ * @param stdout - Raw stdout string
31
+ * @param delimiter - Record delimiter (default: '\0')
32
+ * @returns Array of records
33
+ */
34
+ declare function parseRecords(stdout: string, delimiter?: string): string[];
35
+ /**
36
+ * Parse JSON output from git commands
37
+ *
38
+ * @param stdout - Raw stdout string (single JSON object or NDJSON)
39
+ * @param options - Parse options
40
+ * @returns Parsed JSON value(s)
41
+ */
42
+ declare function parseJson<T = unknown>(stdout: string, options?: {
43
+ /** Parse as newline-delimited JSON (NDJSON) */
44
+ ndjson?: boolean;
45
+ }): T | T[];
46
+ /**
47
+ * Parse key-value pairs from git output
48
+ *
49
+ * Used for parsing config output, show --format output, etc.
50
+ *
51
+ * @param stdout - Raw stdout string
52
+ * @param options - Parse options
53
+ * @returns Map of key-value pairs
54
+ */
55
+ declare function parseKeyValue(stdout: string, options?: {
56
+ /** Key-value separator (default: '=') */
57
+ separator?: string;
58
+ /** Record delimiter (default: '\n') */
59
+ delimiter?: string;
60
+ }): Map<string, string>;
61
+ /**
62
+ * Parse porcelain v2 status output
63
+ *
64
+ * @param stdout - Raw stdout from `git status --porcelain=v2`
65
+ * @returns Parsed status entries
66
+ */
67
+ type PorcelainV2Entry = {
68
+ type: 'changed';
69
+ xy: string;
70
+ sub: string;
71
+ mH: string;
72
+ mI: string;
73
+ mW: string;
74
+ hH: string;
75
+ hI: string;
76
+ path: string;
77
+ origPath?: string;
78
+ } | {
79
+ type: 'untracked';
80
+ path: string;
81
+ } | {
82
+ type: 'ignored';
83
+ path: string;
84
+ } | {
85
+ type: 'unmerged';
86
+ xy: string;
87
+ sub: string;
88
+ m1: string;
89
+ m2: string;
90
+ m3: string;
91
+ mW: string;
92
+ h1: string;
93
+ h2: string;
94
+ h3: string;
95
+ path: string;
96
+ };
97
+ declare function parsePorcelainV2(stdout: string): PorcelainV2Entry[];
98
+ /**
99
+ * Parse git progress output from stderr
100
+ *
101
+ * Parses lines like:
102
+ * - "Counting objects: 100% (10/10), done."
103
+ * - "Compressing objects: 50% (4/8)"
104
+ * - "Receiving objects: 10% (1/10)"
105
+ *
106
+ * @param line - Single line from stderr
107
+ * @returns Parsed progress or null if not a progress line
108
+ */
109
+ type GitProgressInfo = {
110
+ phase: string;
111
+ current: number;
112
+ total: number | null;
113
+ percent: number | null;
114
+ done: boolean;
115
+ };
116
+ declare function parseGitProgress(line: string): GitProgressInfo | null;
117
+ /**
118
+ * Parse LFS progress file line
119
+ *
120
+ * Format: <direction> <oid> <bytes_so_far>/<bytes_total> <bytes_transferred>
121
+ *
122
+ * @param line - Single line from GIT_LFS_PROGRESS file
123
+ * @returns Parsed LFS progress or null if invalid
124
+ */
125
+ type LfsProgressInfo = {
126
+ direction: 'download' | 'upload' | 'checkout';
127
+ oid: string;
128
+ bytesSoFar: number;
129
+ bytesTotal: number;
130
+ bytesTransferred: number;
131
+ };
132
+ declare function parseLfsProgress(line: string): LfsProgressInfo | null;
133
+ /**
134
+ * Parse git ls-remote output
135
+ *
136
+ * Format: <hash>\t<refname>
137
+ *
138
+ * @param stdout - Raw stdout from `git ls-remote`
139
+ * @returns Parsed refs
140
+ */
141
+ type LsRemoteRef = {
142
+ hash: string;
143
+ name: string;
144
+ };
145
+ declare function parseLsRemote(stdout: string): LsRemoteRef[];
146
+ /**
147
+ * Commit information from git log
148
+ */
149
+ type ParsedCommit = {
150
+ hash: string;
151
+ abbrevHash: string;
152
+ parents: string[];
153
+ authorName: string;
154
+ authorEmail: string;
155
+ authorTimestamp: number;
156
+ committerName: string;
157
+ committerEmail: string;
158
+ committerTimestamp: number;
159
+ subject: string;
160
+ body: string;
161
+ };
162
+ /**
163
+ * The format string used for git log parsing
164
+ *
165
+ * Uses %x00 (NUL) as field separator and %x01 as record separator
166
+ */
167
+ declare const GIT_LOG_FORMAT = "%H%x00%h%x00%P%x00%an%x00%ae%x00%at%x00%cn%x00%ce%x00%ct%x00%s%x00%b%x01";
168
+ /**
169
+ * Parse git log output with our custom format
170
+ *
171
+ * @param stdout - Raw stdout from `git log --format=<GIT_LOG_FORMAT>`
172
+ * @returns Parsed commits
173
+ */
174
+ declare function parseGitLog(stdout: string): ParsedCommit[];
175
+ /**
176
+ * Worktree information from git worktree list --porcelain
177
+ */
178
+ type ParsedWorktree = {
179
+ path: string;
180
+ head: string;
181
+ branch?: string;
182
+ locked: boolean;
183
+ prunable: boolean;
184
+ };
185
+ /**
186
+ * Parse git worktree list --porcelain output
187
+ *
188
+ * Format:
189
+ * worktree /path/to/worktree
190
+ * HEAD <sha>
191
+ * branch refs/heads/main
192
+ * [locked [reason]]
193
+ * [prunable]
194
+ *
195
+ * @param stdout - Raw stdout from `git worktree list --porcelain`
196
+ * @returns Parsed worktrees
197
+ */
198
+ declare function parseWorktreeList(stdout: string): ParsedWorktree[];
199
+
200
+ /**
201
+ * Detect error category from stderr content (§13.3)
202
+ *
203
+ * @param stderr - stderr content from git command
204
+ * @returns Detected error category
205
+ */
206
+ declare function detectErrorCategory(stderr: string): GitErrorCategory;
207
+
208
+ export { GIT_LOG_FORMAT, GitErrorCategory, type GitProgressInfo, type LfsProgressInfo, type LsRemoteRef, type ParsedCommit, type ParsedWorktree, type PorcelainV2Entry, detectErrorCategory, parseGitLog, parseGitProgress, parseJson, parseKeyValue, parseLfsProgress, parseLines, parseLsRemote, parsePorcelainV2, parseRecords, parseWorktreeList };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,208 @@
1
+ export { A as AddOpts, b7 as BareRepo, t as BranchCreateOpts, u as BranchDeleteOpts, B as BranchInfo, aO as BranchOperations, s as BranchOpts, v as CheckoutBranchOpts, x as CheckoutOpts, w as CheckoutPathOpts, $ as CherryPickOpts, a0 as CleanOpts, a as CliRunner, b as CliRunnerOptions, g as CloneOpts, p as Commit, y as CommitOpts, z as CommitResult, a_ as ConfigEntry, a$ as ConfigGetOpts, b3 as ConfigKey, b1 as ConfigListOpts, b4 as ConfigOperations, b2 as ConfigSchema, b0 as ConfigSetOpts, C as CreateGitOptions, E as DiffEntry, D as DiffOpts, H as DiffResult, F as FetchOpts, r as ForceWithLeaseOpts, m as Git, k as GlobalConfigListOpts, l as GlobalConfigOperations, G as GlobalLfsInstallOpts, j as GlobalLfsOperations, i as GlobalLfsUninstallOpts, I as InitOpts, av as LfsCheckoutOpts, az as LfsEnvInfo, aN as LfsExtraOperations, ak as LfsFetchOpts, an as LfsFileEntry, ar as LfsLockEntry, as as LfsLockOpts, au as LfsLocksOpts, ao as LfsLsFilesOpts, ay as LfsMigrateExportOpts, ax as LfsMigrateImportOpts, aw as LfsMigrateInfoOpts, aM as LfsOperations, aC as LfsPreDownloadOpts, aD as LfsPreDownloadResult, aA as LfsPreUploadOpts, aB as LfsPreUploadResult, aj as LfsPruneOpts, ag as LfsPullOpts, ah as LfsPushOpts, af as LfsStatus, ai as LfsStatusOpts, ap as LfsTrackEntry, aq as LfsTrackOpts, at as LfsUnlockOpts, q as LogOpts, L as LsRemoteOpts, h as LsRemoteResult, M as MergeOpts, J as MergeResult, a1 as MvOpts, N as NodeExecAdapter, f as NodeFsAdapter, K as PullOpts, P as PushOpts, a2 as RebaseOpts, aS as RemoteAddOpts, aR as RemoteInfo, aZ as RemoteOperations, aV as RemotePruneOpts, aX as RemoteSetBranchesOpts, aT as RemoteSetHeadOpts, aU as RemoteShowOpts, aW as RemoteUpdateOpts, aY as RemoteUrlOpts, R as RepoBase, al as RepoLfsInstallOpts, am as RepoLfsUninstallOpts, O as ResetOpts, a3 as RestoreOpts, a4 as RevertOpts, Q as RmOpts, a5 as ShowOpts, W as StashApplyOpts, U as StashEntry, aP as StashOperations, V as StashPushOpts, S as StatusEntry, o as StatusOpts, n as StatusPorcelain, a7 as SubmoduleAddOpts, a8 as SubmoduleDeinitOpts, ab as SubmoduleForeachOpts, ae as SubmoduleInfo, b5 as SubmoduleOperations, a6 as SubmoduleOpts, ad as SubmoduleSetBranchOpts, a9 as SubmoduleStatusOpts, aa as SubmoduleSummaryOpts, ac as SubmoduleSyncOpts, X as SwitchOpts, _ as TagCreateOpts, Y as TagInfo, Z as TagListOpts, aQ as TagOperations, e as TypeGit, T as TypeGitOptions, aE as Worktree, aF as WorktreeAddOpts, aK as WorktreeLockOpts, aI as WorktreeMoveOpts, aL as WorktreeOperations, aH as WorktreePruneOpts, aG as WorktreeRemoveOpts, aJ as WorktreeRepairOpts, b6 as WorktreeRepo, c as createGit, d as createNodeAdapters } from './index-D9acU30I.js';
2
+ import { G as GitErrorCategory } from './adapters-w9tZ_Qbd.js';
3
+ export { A as AdapterFactory, C as Capabilities, o as CommandSpec, s as Credential, t as CredentialConfig, r as CredentialRequest, E as ExecAdapter, f as ExecOpts, p as ExecutionContext, F as FsAdapter, k as GitArgumentError, j as GitError, h as GitErrorKind, q as GitOpenOptions, e as GitProgress, m as LfsMode, L as LfsProgress, N as NonEmptyString, O as OutputContract, g as RawResult, l as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, a as SpawnResult, b as StreamHandler, d as TailHandle, T as TailOptions, i as isNonEmpty, n as nonEmpty } from './adapters-w9tZ_Qbd.js';
4
+
1
5
  /**
2
- * type-git - Type-safe Git wrapper library with LFS support
6
+ * stdout parsing utilities for Git output
7
+ *
8
+ * This module provides:
9
+ * - parseLines: Parse newline-separated output
10
+ * - parseRecords: Parse delimited records (NUL-terminated or custom)
11
+ * - parseJson: Parse JSON output
12
+ * - parseKeyValue: Parse key-value pairs
3
13
  */
4
- export * from './adapters/node/index.js';
5
- export * from './core/index.js';
6
- export { type CreateGitOptions, createGit } from './impl/index.js';
7
- export { detectErrorCategory, GIT_LOG_FORMAT, type GitProgressInfo, type LfsProgressInfo, type LsRemoteRef, type ParsedCommit, type ParsedWorktree, type PorcelainV2Entry, parseGitLog, parseGitProgress, parseJson, parseKeyValue, parseLfsProgress, parseLines, parseLsRemote, parsePorcelainV2, parseRecords, parseWorktreeList, } from './parsers/index.js';
8
- export { CliRunner, type CliRunnerOptions } from './runner/index.js';
9
- //# sourceMappingURL=index.d.ts.map
14
+ /**
15
+ * Parse newline-separated output into lines
16
+ *
17
+ * @param stdout - Raw stdout string
18
+ * @param options - Parse options
19
+ * @returns Array of non-empty lines
20
+ */
21
+ declare function parseLines(stdout: string, options?: {
22
+ /** Keep empty lines (default: false) */
23
+ keepEmpty?: boolean;
24
+ /** Trim each line (default: true) */
25
+ trim?: boolean;
26
+ }): string[];
27
+ /**
28
+ * Parse delimited records (e.g., NUL-terminated for --format with %x00)
29
+ *
30
+ * @param stdout - Raw stdout string
31
+ * @param delimiter - Record delimiter (default: '\0')
32
+ * @returns Array of records
33
+ */
34
+ declare function parseRecords(stdout: string, delimiter?: string): string[];
35
+ /**
36
+ * Parse JSON output from git commands
37
+ *
38
+ * @param stdout - Raw stdout string (single JSON object or NDJSON)
39
+ * @param options - Parse options
40
+ * @returns Parsed JSON value(s)
41
+ */
42
+ declare function parseJson<T = unknown>(stdout: string, options?: {
43
+ /** Parse as newline-delimited JSON (NDJSON) */
44
+ ndjson?: boolean;
45
+ }): T | T[];
46
+ /**
47
+ * Parse key-value pairs from git output
48
+ *
49
+ * Used for parsing config output, show --format output, etc.
50
+ *
51
+ * @param stdout - Raw stdout string
52
+ * @param options - Parse options
53
+ * @returns Map of key-value pairs
54
+ */
55
+ declare function parseKeyValue(stdout: string, options?: {
56
+ /** Key-value separator (default: '=') */
57
+ separator?: string;
58
+ /** Record delimiter (default: '\n') */
59
+ delimiter?: string;
60
+ }): Map<string, string>;
61
+ /**
62
+ * Parse porcelain v2 status output
63
+ *
64
+ * @param stdout - Raw stdout from `git status --porcelain=v2`
65
+ * @returns Parsed status entries
66
+ */
67
+ type PorcelainV2Entry = {
68
+ type: 'changed';
69
+ xy: string;
70
+ sub: string;
71
+ mH: string;
72
+ mI: string;
73
+ mW: string;
74
+ hH: string;
75
+ hI: string;
76
+ path: string;
77
+ origPath?: string;
78
+ } | {
79
+ type: 'untracked';
80
+ path: string;
81
+ } | {
82
+ type: 'ignored';
83
+ path: string;
84
+ } | {
85
+ type: 'unmerged';
86
+ xy: string;
87
+ sub: string;
88
+ m1: string;
89
+ m2: string;
90
+ m3: string;
91
+ mW: string;
92
+ h1: string;
93
+ h2: string;
94
+ h3: string;
95
+ path: string;
96
+ };
97
+ declare function parsePorcelainV2(stdout: string): PorcelainV2Entry[];
98
+ /**
99
+ * Parse git progress output from stderr
100
+ *
101
+ * Parses lines like:
102
+ * - "Counting objects: 100% (10/10), done."
103
+ * - "Compressing objects: 50% (4/8)"
104
+ * - "Receiving objects: 10% (1/10)"
105
+ *
106
+ * @param line - Single line from stderr
107
+ * @returns Parsed progress or null if not a progress line
108
+ */
109
+ type GitProgressInfo = {
110
+ phase: string;
111
+ current: number;
112
+ total: number | null;
113
+ percent: number | null;
114
+ done: boolean;
115
+ };
116
+ declare function parseGitProgress(line: string): GitProgressInfo | null;
117
+ /**
118
+ * Parse LFS progress file line
119
+ *
120
+ * Format: <direction> <oid> <bytes_so_far>/<bytes_total> <bytes_transferred>
121
+ *
122
+ * @param line - Single line from GIT_LFS_PROGRESS file
123
+ * @returns Parsed LFS progress or null if invalid
124
+ */
125
+ type LfsProgressInfo = {
126
+ direction: 'download' | 'upload' | 'checkout';
127
+ oid: string;
128
+ bytesSoFar: number;
129
+ bytesTotal: number;
130
+ bytesTransferred: number;
131
+ };
132
+ declare function parseLfsProgress(line: string): LfsProgressInfo | null;
133
+ /**
134
+ * Parse git ls-remote output
135
+ *
136
+ * Format: <hash>\t<refname>
137
+ *
138
+ * @param stdout - Raw stdout from `git ls-remote`
139
+ * @returns Parsed refs
140
+ */
141
+ type LsRemoteRef = {
142
+ hash: string;
143
+ name: string;
144
+ };
145
+ declare function parseLsRemote(stdout: string): LsRemoteRef[];
146
+ /**
147
+ * Commit information from git log
148
+ */
149
+ type ParsedCommit = {
150
+ hash: string;
151
+ abbrevHash: string;
152
+ parents: string[];
153
+ authorName: string;
154
+ authorEmail: string;
155
+ authorTimestamp: number;
156
+ committerName: string;
157
+ committerEmail: string;
158
+ committerTimestamp: number;
159
+ subject: string;
160
+ body: string;
161
+ };
162
+ /**
163
+ * The format string used for git log parsing
164
+ *
165
+ * Uses %x00 (NUL) as field separator and %x01 as record separator
166
+ */
167
+ declare const GIT_LOG_FORMAT = "%H%x00%h%x00%P%x00%an%x00%ae%x00%at%x00%cn%x00%ce%x00%ct%x00%s%x00%b%x01";
168
+ /**
169
+ * Parse git log output with our custom format
170
+ *
171
+ * @param stdout - Raw stdout from `git log --format=<GIT_LOG_FORMAT>`
172
+ * @returns Parsed commits
173
+ */
174
+ declare function parseGitLog(stdout: string): ParsedCommit[];
175
+ /**
176
+ * Worktree information from git worktree list --porcelain
177
+ */
178
+ type ParsedWorktree = {
179
+ path: string;
180
+ head: string;
181
+ branch?: string;
182
+ locked: boolean;
183
+ prunable: boolean;
184
+ };
185
+ /**
186
+ * Parse git worktree list --porcelain output
187
+ *
188
+ * Format:
189
+ * worktree /path/to/worktree
190
+ * HEAD <sha>
191
+ * branch refs/heads/main
192
+ * [locked [reason]]
193
+ * [prunable]
194
+ *
195
+ * @param stdout - Raw stdout from `git worktree list --porcelain`
196
+ * @returns Parsed worktrees
197
+ */
198
+ declare function parseWorktreeList(stdout: string): ParsedWorktree[];
199
+
200
+ /**
201
+ * Detect error category from stderr content (§13.3)
202
+ *
203
+ * @param stderr - stderr content from git command
204
+ * @returns Detected error category
205
+ */
206
+ declare function detectErrorCategory(stderr: string): GitErrorCategory;
207
+
208
+ export { GIT_LOG_FORMAT, GitErrorCategory, type GitProgressInfo, type LfsProgressInfo, type LsRemoteRef, type ParsedCommit, type ParsedWorktree, type PorcelainV2Entry, detectErrorCategory, parseGitLog, parseGitProgress, parseJson, parseKeyValue, parseLfsProgress, parseLines, parseLsRemote, parsePorcelainV2, parseRecords, parseWorktreeList };