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