type-git 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +33 -4
  2. package/dist/adapters/bun/index.cjs +421 -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 +388 -13
  7. package/dist/adapters/bun/index.js.map +1 -1
  8. package/dist/adapters/deno/index.cjs +472 -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 +439 -13
  13. package/dist/adapters/deno/index.js.map +1 -1
  14. package/dist/adapters/node/index.cjs +6254 -0
  15. package/dist/adapters/node/index.cjs.map +1 -0
  16. package/dist/{core/repo.d.ts → adapters/node/index.d.cts} +1452 -184
  17. package/dist/adapters/node/index.d.ts +4123 -13
  18. package/dist/adapters/node/index.js +6210 -119
  19. package/dist/adapters/node/index.js.map +1 -1
  20. package/dist/{core/types.d.ts → adapters-DehG3CsV.d.cts} +223 -29
  21. package/dist/adapters-DehG3CsV.d.ts +574 -0
  22. package/dist/index.cjs +6383 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +2 -0
  25. package/dist/index.d.ts +2 -9
  26. package/dist/index.js +6320 -13
  27. package/dist/index.js.map +1 -1
  28. package/package.json +13 -7
  29. package/dist/adapters/bun/exec.d.ts +0 -13
  30. package/dist/adapters/bun/exec.d.ts.map +0 -1
  31. package/dist/adapters/bun/exec.js +0 -242
  32. package/dist/adapters/bun/exec.js.map +0 -1
  33. package/dist/adapters/bun/fs.d.ts +0 -20
  34. package/dist/adapters/bun/fs.d.ts.map +0 -1
  35. package/dist/adapters/bun/fs.js +0 -148
  36. package/dist/adapters/bun/fs.js.map +0 -1
  37. package/dist/adapters/bun/index.d.ts.map +0 -1
  38. package/dist/adapters/deno/exec.d.ts +0 -14
  39. package/dist/adapters/deno/exec.d.ts.map +0 -1
  40. package/dist/adapters/deno/exec.js +0 -266
  41. package/dist/adapters/deno/exec.js.map +0 -1
  42. package/dist/adapters/deno/fs.d.ts +0 -21
  43. package/dist/adapters/deno/fs.d.ts.map +0 -1
  44. package/dist/adapters/deno/fs.js +0 -191
  45. package/dist/adapters/deno/fs.js.map +0 -1
  46. package/dist/adapters/deno/index.d.ts.map +0 -1
  47. package/dist/adapters/node/exec.d.ts +0 -11
  48. package/dist/adapters/node/exec.d.ts.map +0 -1
  49. package/dist/adapters/node/exec.js +0 -161
  50. package/dist/adapters/node/exec.js.map +0 -1
  51. package/dist/adapters/node/fs.d.ts +0 -18
  52. package/dist/adapters/node/fs.d.ts.map +0 -1
  53. package/dist/adapters/node/fs.js +0 -164
  54. package/dist/adapters/node/fs.js.map +0 -1
  55. package/dist/adapters/node/index.d.ts.map +0 -1
  56. package/dist/core/adapters.d.ts +0 -192
  57. package/dist/core/adapters.d.ts.map +0 -1
  58. package/dist/core/adapters.js +0 -10
  59. package/dist/core/adapters.js.map +0 -1
  60. package/dist/core/git.d.ts +0 -426
  61. package/dist/core/git.d.ts.map +0 -1
  62. package/dist/core/git.js +0 -5
  63. package/dist/core/git.js.map +0 -1
  64. package/dist/core/index.d.ts +0 -8
  65. package/dist/core/index.d.ts.map +0 -1
  66. package/dist/core/index.js +0 -8
  67. package/dist/core/index.js.map +0 -1
  68. package/dist/core/repo.d.ts.map +0 -1
  69. package/dist/core/repo.js +0 -5
  70. package/dist/core/repo.js.map +0 -1
  71. package/dist/core/types.d.ts.map +0 -1
  72. package/dist/core/types.js +0 -100
  73. package/dist/core/types.js.map +0 -1
  74. package/dist/impl/bare-repo-impl.d.ts +0 -91
  75. package/dist/impl/bare-repo-impl.d.ts.map +0 -1
  76. package/dist/impl/bare-repo-impl.js +0 -446
  77. package/dist/impl/bare-repo-impl.js.map +0 -1
  78. package/dist/impl/git-impl.d.ts +0 -125
  79. package/dist/impl/git-impl.d.ts.map +0 -1
  80. package/dist/impl/git-impl.js +0 -554
  81. package/dist/impl/git-impl.js.map +0 -1
  82. package/dist/impl/index.d.ts +0 -7
  83. package/dist/impl/index.d.ts.map +0 -1
  84. package/dist/impl/index.js +0 -7
  85. package/dist/impl/index.js.map +0 -1
  86. package/dist/impl/worktree-repo-impl.d.ts +0 -226
  87. package/dist/impl/worktree-repo-impl.d.ts.map +0 -1
  88. package/dist/impl/worktree-repo-impl.js +0 -3887
  89. package/dist/impl/worktree-repo-impl.js.map +0 -1
  90. package/dist/index.d.ts.map +0 -1
  91. package/dist/parsers/index.d.ts +0 -230
  92. package/dist/parsers/index.d.ts.map +0 -1
  93. package/dist/parsers/index.js +0 -529
  94. package/dist/parsers/index.js.map +0 -1
  95. package/dist/runner/cli-runner.d.ts +0 -94
  96. package/dist/runner/cli-runner.d.ts.map +0 -1
  97. package/dist/runner/cli-runner.js +0 -315
  98. package/dist/runner/cli-runner.js.map +0 -1
  99. package/dist/runner/index.d.ts +0 -5
  100. package/dist/runner/index.d.ts.map +0 -1
  101. package/dist/runner/index.js +0 -5
  102. package/dist/runner/index.js.map +0 -1
@@ -30,7 +30,7 @@ declare const NonEmptyBrand: unique symbol;
30
30
  * await repo.checkout('main' as NonEmptyString);
31
31
  * ```
32
32
  */
33
- export type NonEmptyString = string & {
33
+ type NonEmptyString = string & {
34
34
  readonly [NonEmptyBrand]: never;
35
35
  };
36
36
  /**
@@ -46,7 +46,7 @@ export type NonEmptyString = string & {
46
46
  * const invalid = nonEmpty(''); // throws GitArgumentError
47
47
  * ```
48
48
  */
49
- export declare function nonEmpty(s: string): NonEmptyString;
49
+ declare function nonEmpty(s: string): NonEmptyString;
50
50
  /**
51
51
  * Type guard to check if a string is non-empty.
52
52
  *
@@ -61,7 +61,7 @@ export declare function nonEmpty(s: string): NonEmptyString;
61
61
  * }
62
62
  * ```
63
63
  */
64
- export declare function isNonEmpty(s: string): s is NonEmptyString;
64
+ declare function isNonEmpty(s: string): s is NonEmptyString;
65
65
  /**
66
66
  * Progress event for Git operations
67
67
  *
@@ -69,7 +69,7 @@ export declare function isNonEmpty(s: string): s is NonEmptyString;
69
69
  * - "Counting objects: 100% (10/10), done."
70
70
  * - "Compressing objects: 100% (8/8), done."
71
71
  */
72
- export type GitProgress = {
72
+ type GitProgress = {
73
73
  /** The phase of the git operation */
74
74
  phase: string;
75
75
  /** Current progress value */
@@ -87,7 +87,7 @@ export type GitProgress = {
87
87
  * Parsed from LFS stderr output when GIT_LFS_FORCE_PROGRESS=1:
88
88
  * "Downloading LFS objects: 50% (1/2), 1.2 MB | 500 KB/s"
89
89
  */
90
- export type LfsProgress = {
90
+ type LfsProgress = {
91
91
  /** Direction of the transfer */
92
92
  direction: 'download' | 'upload' | 'checkout';
93
93
  /** Total bytes transferred so far */
@@ -106,7 +106,7 @@ export type LfsProgress = {
106
106
  /**
107
107
  * Execution options common to all Git operations
108
108
  */
109
- export type ExecOpts = {
109
+ type ExecOpts = {
110
110
  /** AbortSignal for cancellation */
111
111
  signal?: AbortSignal;
112
112
  /** Git progress callback (for operations like fetch, push, clone) */
@@ -117,7 +117,7 @@ export type ExecOpts = {
117
117
  /**
118
118
  * Result from raw Git command execution
119
119
  */
120
- export type RawResult = {
120
+ type RawResult = {
121
121
  /** Standard output */
122
122
  stdout: string;
123
123
  /** Standard error */
@@ -130,7 +130,7 @@ export type RawResult = {
130
130
  /**
131
131
  * Git error kinds
132
132
  */
133
- export type GitErrorKind =
133
+ type GitErrorKind =
134
134
  /** Failed to spawn the git process */
135
135
  'SpawnFailed'
136
136
  /** Git exited with non-zero exit code */
@@ -144,13 +144,15 @@ export type GitErrorKind =
144
144
  /** Expected a worktree repository but found bare repository */
145
145
  | 'NotWorktreeRepo'
146
146
  /** Expected a bare repository but found worktree repository */
147
- | 'NotBareRepo';
147
+ | 'NotBareRepo'
148
+ /** Git version is below minimum supported version */
149
+ | 'UnsupportedGitVersion';
148
150
  /**
149
151
  * Git error category for error handling (§13.2)
150
152
  *
151
153
  * Categorizes errors by their nature to enable appropriate handling strategies.
152
154
  */
153
- export type GitErrorCategory =
155
+ type GitErrorCategory =
154
156
  /** Authentication errors (401, credential related) */
155
157
  'auth'
156
158
  /** Network errors (timeout, DNS resolution failure, etc.) */
@@ -168,10 +170,10 @@ export type GitErrorCategory =
168
170
  /**
169
171
  * Git error with detailed context
170
172
  */
171
- export declare class GitError extends Error {
173
+ declare class GitError extends Error {
172
174
  readonly kind: GitErrorKind;
173
175
  readonly context: {
174
- argv?: Array<string>;
176
+ argv?: string[];
175
177
  workdir?: string;
176
178
  gitDir?: string;
177
179
  exitCode?: number;
@@ -180,7 +182,7 @@ export declare class GitError extends Error {
180
182
  };
181
183
  readonly category: GitErrorCategory;
182
184
  constructor(kind: GitErrorKind, message: string, context?: {
183
- argv?: Array<string>;
185
+ argv?: string[];
184
186
  workdir?: string;
185
187
  gitDir?: string;
186
188
  exitCode?: number;
@@ -215,19 +217,19 @@ export declare class GitError extends Error {
215
217
  * }
216
218
  * ```
217
219
  */
218
- export declare class GitArgumentError extends Error {
220
+ declare class GitArgumentError extends Error {
219
221
  constructor(message: string);
220
222
  }
221
223
  /**
222
224
  * Runtime identifier
223
225
  */
224
- export type Runtime = 'node' | 'deno' | 'bun';
226
+ type Runtime = 'node' | 'deno' | 'bun';
225
227
  /**
226
228
  * Runtime capabilities
227
229
  *
228
230
  * Used to determine what features are available in the current runtime.
229
231
  */
230
- export type Capabilities = {
232
+ type Capabilities = {
231
233
  /** Whether process spawning is available */
232
234
  canSpawnProcess: boolean;
233
235
  /** Whether environment variables can be read */
@@ -248,7 +250,7 @@ export type Capabilities = {
248
250
  /**
249
251
  * LFS mode configuration
250
252
  */
251
- export type LfsMode = 'enabled' | 'disabled' | {
253
+ type LfsMode = 'enabled' | 'disabled' | {
252
254
  /** Skip smudge filter (don't download LFS files on checkout) */
253
255
  skipSmudge?: boolean;
254
256
  /** Skip download (keep pointer files) */
@@ -259,7 +261,7 @@ export type LfsMode = 'enabled' | 'disabled' | {
259
261
  *
260
262
  * Typed API only supports commands with predictable output formats.
261
263
  */
262
- export type OutputContract =
264
+ type OutputContract =
263
265
  /** Raw output - no parsing */
264
266
  {
265
267
  type: 'raw';
@@ -287,13 +289,13 @@ export type OutputContract =
287
289
  /**
288
290
  * Command specification for typed API
289
291
  */
290
- export type CommandSpec<TOptions, TResult> = {
292
+ type CommandSpec<TOptions, TResult> = {
291
293
  /** Command name (e.g., "status", "log") */
292
294
  name: string;
293
295
  /** Subcommands (e.g., ["lfs", "pull"]) */
294
- subcommands?: Array<string>;
296
+ subcommands?: string[];
295
297
  /** Build argv from options */
296
- buildArgs: (options: TOptions) => Array<string>;
298
+ buildArgs: (options: TOptions) => string[];
297
299
  /** Output contract */
298
300
  outputContract: OutputContract;
299
301
  /** Parse stdout/stderr to result */
@@ -306,7 +308,7 @@ export type CommandSpec<TOptions, TResult> = {
306
308
  * - Worktree: `git -C <workdir> <command>`
307
309
  * - Bare: `git --git-dir=<gitDir> <command>`
308
310
  */
309
- export type ExecutionContext = {
311
+ type ExecutionContext = {
310
312
  type: 'global';
311
313
  } | {
312
314
  type: 'worktree';
@@ -320,7 +322,7 @@ export type ExecutionContext = {
320
322
  *
321
323
  * Provides declarative environment configuration for Git operations.
322
324
  */
323
- export type GitOpenOptions = {
325
+ type GitOpenOptions = {
324
326
  /** Custom HOME directory (~/.gitconfig source) */
325
327
  home?: string;
326
328
  /** Ignore system config (--config-env=GIT_CONFIG_GLOBAL=/dev/null equivalent) */
@@ -330,7 +332,7 @@ export type GitOpenOptions = {
330
332
  /** Additional environment variables */
331
333
  env?: Record<string, string>;
332
334
  /** Directories to prepend to PATH */
333
- pathPrefix?: Array<string>;
335
+ pathPrefix?: string[];
334
336
  /** Credential configuration (§6.4) */
335
337
  credential?: CredentialConfig;
336
338
  /** LFS mode configuration */
@@ -339,7 +341,7 @@ export type GitOpenOptions = {
339
341
  /**
340
342
  * Credential request information
341
343
  */
342
- export type CredentialRequest = {
344
+ type CredentialRequest = {
343
345
  protocol: 'https' | 'ssh';
344
346
  host: string;
345
347
  path?: string;
@@ -347,7 +349,7 @@ export type CredentialRequest = {
347
349
  /**
348
350
  * Credential response
349
351
  */
350
- export type Credential = {
352
+ type Credential = {
351
353
  username: string;
352
354
  password: string;
353
355
  };
@@ -360,7 +362,7 @@ export type Credential = {
360
362
  * 3. Programmatic authentication (recommended)
361
363
  * 4. Static credentials (dev/test only)
362
364
  */
363
- export type CredentialConfig = {
365
+ type CredentialConfig = {
364
366
  /** Method 1: Built-in helper name */
365
367
  helper?: 'store' | 'cache' | 'manager-core' | string;
366
368
  /** Method 2: Custom helper binary path */
@@ -376,5 +378,197 @@ export type CredentialConfig = {
376
378
  /** Callback when authentication fails */
377
379
  onAuthFailure?: (error: Error, request: CredentialRequest) => void;
378
380
  };
379
- export {};
380
- //# sourceMappingURL=types.d.ts.map
381
+
382
+ /**
383
+ * Runtime adapter interfaces for cross-platform support (Node/Deno/Bun)
384
+ *
385
+ * This module defines:
386
+ * - ExecAdapter: Process execution abstraction (#15)
387
+ * - FsAdapter: Filesystem operations abstraction (#16)
388
+ * - Related types and options
389
+ */
390
+
391
+ /**
392
+ * Options for spawning a process
393
+ */
394
+ type SpawnOptions = {
395
+ /** Command and arguments (first element is the command) */
396
+ argv: string[];
397
+ /** Additional environment variables */
398
+ env?: Record<string, string>;
399
+ /** Working directory */
400
+ cwd?: string;
401
+ /** AbortSignal for cancellation */
402
+ signal?: AbortSignal;
403
+ /** Kill signal to use when aborting (default: SIGTERM) */
404
+ killSignal?: 'SIGTERM' | 'SIGKILL';
405
+ };
406
+ /**
407
+ * Result from spawning a process
408
+ */
409
+ type SpawnResult = {
410
+ /** Standard output */
411
+ stdout: string;
412
+ /** Standard error */
413
+ stderr: string;
414
+ /** Exit code (-1 if unknown) */
415
+ exitCode: number;
416
+ /** Signal that terminated the process (if any) */
417
+ signal?: string;
418
+ /** Whether the process was aborted via AbortSignal */
419
+ aborted: boolean;
420
+ };
421
+ /**
422
+ * Stream handler for incremental output
423
+ *
424
+ * Used for progress tracking and real-time output processing.
425
+ */
426
+ type StreamHandler = {
427
+ /** Called when stdout data is received */
428
+ onStdout?: (chunk: string) => void;
429
+ /** Called when stderr data is received */
430
+ onStderr?: (chunk: string) => void;
431
+ };
432
+ /**
433
+ * Handle to a spawned process
434
+ *
435
+ * Allows streaming output and waiting for completion.
436
+ */
437
+ interface SpawnHandle {
438
+ /** Async iterator for stdout lines */
439
+ readonly stdout: AsyncIterable<string>;
440
+ /** Async iterator for stderr lines */
441
+ readonly stderr: AsyncIterable<string>;
442
+ /** Wait for process completion */
443
+ wait(): Promise<SpawnResult>;
444
+ /** Kill the process */
445
+ kill(signal?: 'SIGTERM' | 'SIGKILL'): void;
446
+ }
447
+ /**
448
+ * Adapter interface for process execution
449
+ *
450
+ * Abstracts process spawning across Node.js, Deno, and Bun.
451
+ */
452
+ interface ExecAdapter {
453
+ /**
454
+ * Get the capabilities of this runtime
455
+ */
456
+ getCapabilities(): Capabilities;
457
+ /**
458
+ * Spawn a process and wait for completion
459
+ *
460
+ * @param options - Spawn options
461
+ * @param handlers - Optional stream handlers for real-time output
462
+ * @returns Promise resolving to spawn result
463
+ */
464
+ spawn(options: SpawnOptions, handlers?: StreamHandler): Promise<SpawnResult>;
465
+ /**
466
+ * Spawn a process with streaming support
467
+ *
468
+ * @param options - Spawn options
469
+ * @returns Handle to the spawned process
470
+ */
471
+ spawnStreaming?(options: SpawnOptions): SpawnHandle;
472
+ }
473
+ /**
474
+ * Options for tailing a file
475
+ */
476
+ type TailOptions = {
477
+ /** Path to the file to tail */
478
+ filePath: string;
479
+ /** AbortSignal for cancellation */
480
+ signal?: AbortSignal;
481
+ /** Callback for each new line */
482
+ onLine: (line: string) => void;
483
+ /** Start offset in bytes (default: 0) */
484
+ startOffset?: number;
485
+ /** Polling interval in milliseconds (default: 100) */
486
+ pollInterval?: number;
487
+ };
488
+ /**
489
+ * Handle to a tail operation
490
+ */
491
+ interface TailHandle {
492
+ /** Async iterator for new lines */
493
+ readonly lines: AsyncIterable<string>;
494
+ /** Stop tailing */
495
+ stop(): void;
496
+ }
497
+ /**
498
+ * Adapter interface for filesystem operations
499
+ *
500
+ * Used primarily for LFS progress tracking via GIT_LFS_PROGRESS.
501
+ */
502
+ interface FsAdapter {
503
+ /**
504
+ * Create a temporary file and return its path
505
+ *
506
+ * @param prefix - Optional prefix for the temp file name
507
+ * @returns Path to the created temporary file
508
+ */
509
+ createTempFile(prefix?: string): Promise<string>;
510
+ /**
511
+ * Start tailing a file (watching for new lines)
512
+ *
513
+ * @param options - Tail options
514
+ * @returns Promise that resolves when tailing stops
515
+ */
516
+ tail(options: TailOptions): Promise<void>;
517
+ /**
518
+ * Start tailing a file with streaming support
519
+ *
520
+ * @param filePath - Path to the file to tail
521
+ * @param options - Optional tail options
522
+ * @returns Handle to the tail operation
523
+ */
524
+ tailStreaming?(filePath: string, options?: {
525
+ signal?: AbortSignal;
526
+ pollInterval?: number;
527
+ }): TailHandle;
528
+ /**
529
+ * Delete a file
530
+ *
531
+ * @param filePath - Path to the file to delete
532
+ */
533
+ deleteFile(filePath: string): Promise<void>;
534
+ /**
535
+ * Delete a directory recursively
536
+ *
537
+ * @param dirPath - Path to the directory to delete
538
+ */
539
+ deleteDirectory(dirPath: string): Promise<void>;
540
+ /**
541
+ * Check if a file exists
542
+ *
543
+ * @param filePath - Path to check
544
+ * @returns Whether the file exists
545
+ */
546
+ exists(filePath: string): Promise<boolean>;
547
+ /**
548
+ * Read a file's contents
549
+ *
550
+ * @param filePath - Path to the file
551
+ * @returns File contents as string
552
+ */
553
+ readFile?(filePath: string): Promise<string>;
554
+ /**
555
+ * Write contents to a file
556
+ *
557
+ * @param filePath - Path to the file
558
+ * @param contents - Contents to write
559
+ */
560
+ writeFile?(filePath: string, contents: string): Promise<void>;
561
+ }
562
+ /**
563
+ * Combined adapters for a runtime
564
+ */
565
+ interface RuntimeAdapters {
566
+ exec: ExecAdapter;
567
+ fs: FsAdapter;
568
+ }
569
+ /**
570
+ * Factory function type for creating runtime adapters
571
+ */
572
+ type AdapterFactory = () => RuntimeAdapters;
573
+
574
+ export { type AdapterFactory as A, type Capabilities as C, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type ExecutionContext as i, GitError as j, isNonEmpty as k, type LfsProgress as l, type GitErrorKind as m, nonEmpty as n, GitArgumentError as o, type Runtime as p, type CommandSpec as q, type CredentialRequest as r, type Credential as s, type CredentialConfig as t };