@fern-api/replay 0.9.1 → 0.10.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.
package/dist/index.d.cts CHANGED
@@ -118,6 +118,9 @@ declare function parseRevertedSha(fullBody: string): string | undefined;
118
118
  /** Extract the original commit message from a revert subject like 'Revert "original message"' */
119
119
  declare function parseRevertedMessage(subject: string): string | undefined;
120
120
 
121
+ declare class LockfileNotFoundError extends Error {
122
+ constructor(path: string);
123
+ }
121
124
  declare class LockfileManager {
122
125
  private outputDir;
123
126
  private lock;
@@ -176,6 +179,27 @@ declare class ReplayDetector {
176
179
  * patch from the aggregate diff — individual revert commits are not distinguishable.
177
180
  */
178
181
  private detectPatchesViaTreeDiff;
182
+ /**
183
+ * Last-resort detection when both generation commit and tree are unreachable.
184
+ * Scans all commits from HEAD, filters against known lockfile patches, and
185
+ * skips creation-only commits (squashed history after force push).
186
+ *
187
+ * Detected patches use the commit's parent as base_generation so the applicator
188
+ * can find base file content from the parent's tree (which IS reachable).
189
+ */
190
+ private detectPatchesViaCommitScan;
191
+ /**
192
+ * Check if a format-patch consists entirely of new-file creations.
193
+ * Used to identify squashed commits after force push, which create all files
194
+ * from scratch (--- /dev/null) rather than modifying existing files.
195
+ */
196
+ private isCreationOnlyPatch;
197
+ /**
198
+ * Resolve the best available diff base for a generation record.
199
+ * Prefers commit_sha, falls back to tree_hash for unreachable commits.
200
+ * When commitKnownMissing is true, skips the redundant commitExists check.
201
+ */
202
+ private resolveDiffBase;
179
203
  private parseGitLog;
180
204
  private getLastGeneration;
181
205
  }
@@ -198,6 +222,12 @@ declare class ReplayApplicator {
198
222
  private treeExistsCache;
199
223
  private fileTheirsAccumulator;
200
224
  constructor(git: GitClient, lockManager: LockfileManager, outputDir: string);
225
+ /**
226
+ * Resolve the GenerationRecord for a patch's base_generation.
227
+ * Falls back to constructing an ad-hoc record from the commit's tree
228
+ * when base_generation isn't a tracked generation (commit-scan patches).
229
+ */
230
+ private resolveBaseGeneration;
201
231
  /** Reset inter-patch accumulator for a new cycle. */
202
232
  private resetAccumulator;
203
233
  /**
@@ -345,6 +375,13 @@ declare class ReplayService {
345
375
  * so only clean content is committed. Keeps the Generated (OURS) side.
346
376
  */
347
377
  private revertConflictingFiles;
378
+ /**
379
+ * Clean up stale conflict markers left by a previous crashed run.
380
+ * Called after commitGeneration() when HEAD is the [fern-generated] commit.
381
+ * Restores files to their clean generated state from HEAD.
382
+ * Skips .fernignore-protected files to prevent overwriting user content.
383
+ */
384
+ private cleanupStaleConflictMarkers;
348
385
  private readFernignorePatterns;
349
386
  private buildReport;
350
387
  }
@@ -551,4 +588,4 @@ interface StatusGeneration {
551
588
  }
552
589
  declare function status(outputDir: string): StatusResult;
553
590
 
554
- export { type BootstrapOptions, type BootstrapResult, type CommitInfo, type CommitOptions, type ConflictDetail, type ConflictMetadata, type ConflictReason, type ConflictRegion, type CustomizationsConfig, type DetectionResult, type DiffStat, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_BOT_NAME, FernignoreMigrator, type FileResult, type ForgetOptions, type ForgetResult, type GenerationLock, type GenerationRecord, GitClient, LockfileManager, type MatchedPatch, type MergeResult, type MigrationAnalysis, type MigrationResult, type MoveDeclaration, ReplayApplicator, ReplayCommitter, type ReplayConfig, ReplayDetector, type ReplayOptions, type ReplayReport, type ReplayResult, ReplayService, type ResetOptions, type ResetResult, type ResolveOptions, type ResolveResult, type StatusGeneration, type StatusPatch, type StatusResult, type StoredPatch, type UnresolvedPatchInfo, bootstrap, forget, isGenerationCommit, isReplayCommit, isRevertCommit, parseRevertedMessage, parseRevertedSha, reset, resolve, status, threeWayMerge };
591
+ export { type BootstrapOptions, type BootstrapResult, type CommitInfo, type CommitOptions, type ConflictDetail, type ConflictMetadata, type ConflictReason, type ConflictRegion, type CustomizationsConfig, type DetectionResult, type DiffStat, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_BOT_NAME, FernignoreMigrator, type FileResult, type ForgetOptions, type ForgetResult, type GenerationLock, type GenerationRecord, GitClient, LockfileManager, LockfileNotFoundError, type MatchedPatch, type MergeResult, type MigrationAnalysis, type MigrationResult, type MoveDeclaration, ReplayApplicator, ReplayCommitter, type ReplayConfig, ReplayDetector, type ReplayOptions, type ReplayReport, type ReplayResult, ReplayService, type ResetOptions, type ResetResult, type ResolveOptions, type ResolveResult, type StatusGeneration, type StatusPatch, type StatusResult, type StoredPatch, type UnresolvedPatchInfo, bootstrap, forget, isGenerationCommit, isReplayCommit, isRevertCommit, parseRevertedMessage, parseRevertedSha, reset, resolve, status, threeWayMerge };
package/dist/index.d.ts CHANGED
@@ -118,6 +118,9 @@ declare function parseRevertedSha(fullBody: string): string | undefined;
118
118
  /** Extract the original commit message from a revert subject like 'Revert "original message"' */
119
119
  declare function parseRevertedMessage(subject: string): string | undefined;
120
120
 
121
+ declare class LockfileNotFoundError extends Error {
122
+ constructor(path: string);
123
+ }
121
124
  declare class LockfileManager {
122
125
  private outputDir;
123
126
  private lock;
@@ -176,6 +179,27 @@ declare class ReplayDetector {
176
179
  * patch from the aggregate diff — individual revert commits are not distinguishable.
177
180
  */
178
181
  private detectPatchesViaTreeDiff;
182
+ /**
183
+ * Last-resort detection when both generation commit and tree are unreachable.
184
+ * Scans all commits from HEAD, filters against known lockfile patches, and
185
+ * skips creation-only commits (squashed history after force push).
186
+ *
187
+ * Detected patches use the commit's parent as base_generation so the applicator
188
+ * can find base file content from the parent's tree (which IS reachable).
189
+ */
190
+ private detectPatchesViaCommitScan;
191
+ /**
192
+ * Check if a format-patch consists entirely of new-file creations.
193
+ * Used to identify squashed commits after force push, which create all files
194
+ * from scratch (--- /dev/null) rather than modifying existing files.
195
+ */
196
+ private isCreationOnlyPatch;
197
+ /**
198
+ * Resolve the best available diff base for a generation record.
199
+ * Prefers commit_sha, falls back to tree_hash for unreachable commits.
200
+ * When commitKnownMissing is true, skips the redundant commitExists check.
201
+ */
202
+ private resolveDiffBase;
179
203
  private parseGitLog;
180
204
  private getLastGeneration;
181
205
  }
@@ -198,6 +222,12 @@ declare class ReplayApplicator {
198
222
  private treeExistsCache;
199
223
  private fileTheirsAccumulator;
200
224
  constructor(git: GitClient, lockManager: LockfileManager, outputDir: string);
225
+ /**
226
+ * Resolve the GenerationRecord for a patch's base_generation.
227
+ * Falls back to constructing an ad-hoc record from the commit's tree
228
+ * when base_generation isn't a tracked generation (commit-scan patches).
229
+ */
230
+ private resolveBaseGeneration;
201
231
  /** Reset inter-patch accumulator for a new cycle. */
202
232
  private resetAccumulator;
203
233
  /**
@@ -345,6 +375,13 @@ declare class ReplayService {
345
375
  * so only clean content is committed. Keeps the Generated (OURS) side.
346
376
  */
347
377
  private revertConflictingFiles;
378
+ /**
379
+ * Clean up stale conflict markers left by a previous crashed run.
380
+ * Called after commitGeneration() when HEAD is the [fern-generated] commit.
381
+ * Restores files to their clean generated state from HEAD.
382
+ * Skips .fernignore-protected files to prevent overwriting user content.
383
+ */
384
+ private cleanupStaleConflictMarkers;
348
385
  private readFernignorePatterns;
349
386
  private buildReport;
350
387
  }
@@ -551,4 +588,4 @@ interface StatusGeneration {
551
588
  }
552
589
  declare function status(outputDir: string): StatusResult;
553
590
 
554
- export { type BootstrapOptions, type BootstrapResult, type CommitInfo, type CommitOptions, type ConflictDetail, type ConflictMetadata, type ConflictReason, type ConflictRegion, type CustomizationsConfig, type DetectionResult, type DiffStat, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_BOT_NAME, FernignoreMigrator, type FileResult, type ForgetOptions, type ForgetResult, type GenerationLock, type GenerationRecord, GitClient, LockfileManager, type MatchedPatch, type MergeResult, type MigrationAnalysis, type MigrationResult, type MoveDeclaration, ReplayApplicator, ReplayCommitter, type ReplayConfig, ReplayDetector, type ReplayOptions, type ReplayReport, type ReplayResult, ReplayService, type ResetOptions, type ResetResult, type ResolveOptions, type ResolveResult, type StatusGeneration, type StatusPatch, type StatusResult, type StoredPatch, type UnresolvedPatchInfo, bootstrap, forget, isGenerationCommit, isReplayCommit, isRevertCommit, parseRevertedMessage, parseRevertedSha, reset, resolve, status, threeWayMerge };
591
+ export { type BootstrapOptions, type BootstrapResult, type CommitInfo, type CommitOptions, type ConflictDetail, type ConflictMetadata, type ConflictReason, type ConflictRegion, type CustomizationsConfig, type DetectionResult, type DiffStat, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_BOT_NAME, FernignoreMigrator, type FileResult, type ForgetOptions, type ForgetResult, type GenerationLock, type GenerationRecord, GitClient, LockfileManager, LockfileNotFoundError, type MatchedPatch, type MergeResult, type MigrationAnalysis, type MigrationResult, type MoveDeclaration, ReplayApplicator, ReplayCommitter, type ReplayConfig, ReplayDetector, type ReplayOptions, type ReplayReport, type ReplayResult, ReplayService, type ResetOptions, type ResetResult, type ResolveOptions, type ResolveResult, type StatusGeneration, type StatusPatch, type StatusResult, type StoredPatch, type UnresolvedPatchInfo, bootstrap, forget, isGenerationCommit, isReplayCommit, isRevertCommit, parseRevertedMessage, parseRevertedSha, reset, resolve, status, threeWayMerge };