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
@@ -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 */
@@ -140,13 +140,17 @@ export type GitErrorKind =
140
140
  /** Command was aborted via AbortSignal */
141
141
  | 'Aborted'
142
142
  /** Required capability is missing (e.g., Deno permissions) */
143
- | 'CapabilityMissing';
143
+ | 'CapabilityMissing'
144
+ /** Expected a worktree repository but found bare repository */
145
+ | 'NotWorktreeRepo'
146
+ /** Expected a bare repository but found worktree repository */
147
+ | 'NotBareRepo';
144
148
  /**
145
149
  * Git error category for error handling (§13.2)
146
150
  *
147
151
  * Categorizes errors by their nature to enable appropriate handling strategies.
148
152
  */
149
- export type GitErrorCategory =
153
+ type GitErrorCategory =
150
154
  /** Authentication errors (401, credential related) */
151
155
  'auth'
152
156
  /** Network errors (timeout, DNS resolution failure, etc.) */
@@ -164,10 +168,10 @@ export type GitErrorCategory =
164
168
  /**
165
169
  * Git error with detailed context
166
170
  */
167
- export declare class GitError extends Error {
171
+ declare class GitError extends Error {
168
172
  readonly kind: GitErrorKind;
169
173
  readonly context: {
170
- argv?: Array<string>;
174
+ argv?: string[];
171
175
  workdir?: string;
172
176
  gitDir?: string;
173
177
  exitCode?: number;
@@ -176,7 +180,7 @@ export declare class GitError extends Error {
176
180
  };
177
181
  readonly category: GitErrorCategory;
178
182
  constructor(kind: GitErrorKind, message: string, context?: {
179
- argv?: Array<string>;
183
+ argv?: string[];
180
184
  workdir?: string;
181
185
  gitDir?: string;
182
186
  exitCode?: number;
@@ -211,19 +215,19 @@ export declare class GitError extends Error {
211
215
  * }
212
216
  * ```
213
217
  */
214
- export declare class GitArgumentError extends Error {
218
+ declare class GitArgumentError extends Error {
215
219
  constructor(message: string);
216
220
  }
217
221
  /**
218
222
  * Runtime identifier
219
223
  */
220
- export type Runtime = 'node' | 'deno' | 'bun';
224
+ type Runtime = 'node' | 'deno' | 'bun';
221
225
  /**
222
226
  * Runtime capabilities
223
227
  *
224
228
  * Used to determine what features are available in the current runtime.
225
229
  */
226
- export type Capabilities = {
230
+ type Capabilities = {
227
231
  /** Whether process spawning is available */
228
232
  canSpawnProcess: boolean;
229
233
  /** Whether environment variables can be read */
@@ -244,7 +248,7 @@ export type Capabilities = {
244
248
  /**
245
249
  * LFS mode configuration
246
250
  */
247
- export type LfsMode = 'enabled' | 'disabled' | {
251
+ type LfsMode = 'enabled' | 'disabled' | {
248
252
  /** Skip smudge filter (don't download LFS files on checkout) */
249
253
  skipSmudge?: boolean;
250
254
  /** Skip download (keep pointer files) */
@@ -255,7 +259,7 @@ export type LfsMode = 'enabled' | 'disabled' | {
255
259
  *
256
260
  * Typed API only supports commands with predictable output formats.
257
261
  */
258
- export type OutputContract =
262
+ type OutputContract =
259
263
  /** Raw output - no parsing */
260
264
  {
261
265
  type: 'raw';
@@ -283,13 +287,13 @@ export type OutputContract =
283
287
  /**
284
288
  * Command specification for typed API
285
289
  */
286
- export type CommandSpec<TOptions, TResult> = {
290
+ type CommandSpec<TOptions, TResult> = {
287
291
  /** Command name (e.g., "status", "log") */
288
292
  name: string;
289
293
  /** Subcommands (e.g., ["lfs", "pull"]) */
290
- subcommands?: Array<string>;
294
+ subcommands?: string[];
291
295
  /** Build argv from options */
292
- buildArgs: (options: TOptions) => Array<string>;
296
+ buildArgs: (options: TOptions) => string[];
293
297
  /** Output contract */
294
298
  outputContract: OutputContract;
295
299
  /** Parse stdout/stderr to result */
@@ -302,7 +306,7 @@ export type CommandSpec<TOptions, TResult> = {
302
306
  * - Worktree: `git -C <workdir> <command>`
303
307
  * - Bare: `git --git-dir=<gitDir> <command>`
304
308
  */
305
- export type ExecutionContext = {
309
+ type ExecutionContext = {
306
310
  type: 'global';
307
311
  } | {
308
312
  type: 'worktree';
@@ -316,7 +320,7 @@ export type ExecutionContext = {
316
320
  *
317
321
  * Provides declarative environment configuration for Git operations.
318
322
  */
319
- export type GitOpenOptions = {
323
+ type GitOpenOptions = {
320
324
  /** Custom HOME directory (~/.gitconfig source) */
321
325
  home?: string;
322
326
  /** Ignore system config (--config-env=GIT_CONFIG_GLOBAL=/dev/null equivalent) */
@@ -326,7 +330,7 @@ export type GitOpenOptions = {
326
330
  /** Additional environment variables */
327
331
  env?: Record<string, string>;
328
332
  /** Directories to prepend to PATH */
329
- pathPrefix?: Array<string>;
333
+ pathPrefix?: string[];
330
334
  /** Credential configuration (§6.4) */
331
335
  credential?: CredentialConfig;
332
336
  /** LFS mode configuration */
@@ -335,7 +339,7 @@ export type GitOpenOptions = {
335
339
  /**
336
340
  * Credential request information
337
341
  */
338
- export type CredentialRequest = {
342
+ type CredentialRequest = {
339
343
  protocol: 'https' | 'ssh';
340
344
  host: string;
341
345
  path?: string;
@@ -343,7 +347,7 @@ export type CredentialRequest = {
343
347
  /**
344
348
  * Credential response
345
349
  */
346
- export type Credential = {
350
+ type Credential = {
347
351
  username: string;
348
352
  password: string;
349
353
  };
@@ -356,7 +360,7 @@ export type Credential = {
356
360
  * 3. Programmatic authentication (recommended)
357
361
  * 4. Static credentials (dev/test only)
358
362
  */
359
- export type CredentialConfig = {
363
+ type CredentialConfig = {
360
364
  /** Method 1: Built-in helper name */
361
365
  helper?: 'store' | 'cache' | 'manager-core' | string;
362
366
  /** Method 2: Custom helper binary path */
@@ -372,5 +376,197 @@ export type CredentialConfig = {
372
376
  /** Callback when authentication fails */
373
377
  onAuthFailure?: (error: Error, request: CredentialRequest) => void;
374
378
  };
375
- export {};
376
- //# 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 };