@fern-api/replay 0.5.0 → 0.6.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.
Files changed (78) hide show
  1. package/dist/cli.cjs +16642 -0
  2. package/dist/cli.cjs.map +1 -0
  3. package/dist/index.cjs +2014 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +463 -0
  6. package/dist/index.d.ts +463 -12
  7. package/dist/index.js +1968 -10
  8. package/dist/index.js.map +1 -1
  9. package/package.json +16 -6
  10. package/dist/FernignoreMigrator.d.ts +0 -65
  11. package/dist/FernignoreMigrator.d.ts.map +0 -1
  12. package/dist/FernignoreMigrator.js +0 -237
  13. package/dist/FernignoreMigrator.js.map +0 -1
  14. package/dist/LockfileManager.d.ts +0 -31
  15. package/dist/LockfileManager.d.ts.map +0 -1
  16. package/dist/LockfileManager.js +0 -124
  17. package/dist/LockfileManager.js.map +0 -1
  18. package/dist/ReplayApplicator.d.ts +0 -62
  19. package/dist/ReplayApplicator.d.ts.map +0 -1
  20. package/dist/ReplayApplicator.js +0 -533
  21. package/dist/ReplayApplicator.js.map +0 -1
  22. package/dist/ReplayCommitter.d.ts +0 -39
  23. package/dist/ReplayCommitter.d.ts.map +0 -1
  24. package/dist/ReplayCommitter.js +0 -84
  25. package/dist/ReplayCommitter.js.map +0 -1
  26. package/dist/ReplayDetector.d.ts +0 -27
  27. package/dist/ReplayDetector.d.ts.map +0 -1
  28. package/dist/ReplayDetector.js +0 -150
  29. package/dist/ReplayDetector.js.map +0 -1
  30. package/dist/ReplayService.d.ts +0 -113
  31. package/dist/ReplayService.d.ts.map +0 -1
  32. package/dist/ReplayService.js +0 -579
  33. package/dist/ReplayService.js.map +0 -1
  34. package/dist/ThreeWayMerge.d.ts +0 -11
  35. package/dist/ThreeWayMerge.d.ts.map +0 -1
  36. package/dist/ThreeWayMerge.js +0 -48
  37. package/dist/ThreeWayMerge.js.map +0 -1
  38. package/dist/cli.d.ts +0 -3
  39. package/dist/cli.d.ts.map +0 -1
  40. package/dist/cli.js +0 -462
  41. package/dist/cli.js.map +0 -1
  42. package/dist/commands/bootstrap.d.ts +0 -46
  43. package/dist/commands/bootstrap.d.ts.map +0 -1
  44. package/dist/commands/bootstrap.js +0 -262
  45. package/dist/commands/bootstrap.js.map +0 -1
  46. package/dist/commands/forget.d.ts +0 -26
  47. package/dist/commands/forget.d.ts.map +0 -1
  48. package/dist/commands/forget.js +0 -37
  49. package/dist/commands/forget.js.map +0 -1
  50. package/dist/commands/index.d.ts +0 -6
  51. package/dist/commands/index.d.ts.map +0 -1
  52. package/dist/commands/index.js +0 -6
  53. package/dist/commands/index.js.map +0 -1
  54. package/dist/commands/reset.d.ts +0 -28
  55. package/dist/commands/reset.d.ts.map +0 -1
  56. package/dist/commands/reset.js +0 -37
  57. package/dist/commands/reset.js.map +0 -1
  58. package/dist/commands/resolve.d.ts +0 -16
  59. package/dist/commands/resolve.d.ts.map +0 -1
  60. package/dist/commands/resolve.js +0 -28
  61. package/dist/commands/resolve.js.map +0 -1
  62. package/dist/commands/status.d.ts +0 -34
  63. package/dist/commands/status.d.ts.map +0 -1
  64. package/dist/commands/status.js +0 -32
  65. package/dist/commands/status.js.map +0 -1
  66. package/dist/git/CommitDetection.d.ts +0 -11
  67. package/dist/git/CommitDetection.d.ts.map +0 -1
  68. package/dist/git/CommitDetection.js +0 -25
  69. package/dist/git/CommitDetection.js.map +0 -1
  70. package/dist/git/GitClient.d.ts +0 -33
  71. package/dist/git/GitClient.d.ts.map +0 -1
  72. package/dist/git/GitClient.js +0 -118
  73. package/dist/git/GitClient.js.map +0 -1
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/types.d.ts +0 -78
  76. package/dist/types.d.ts.map +0 -1
  77. package/dist/types.js +0 -3
  78. package/dist/types.js.map +0 -1
@@ -1,84 +0,0 @@
1
- export class ReplayCommitter {
2
- git;
3
- outputDir;
4
- constructor(git, outputDir) {
5
- this.git = git;
6
- this.outputDir = outputDir;
7
- }
8
- /**
9
- * Commit the generation output (after generator runs, before replay).
10
- * Uses [fern-generated] prefix for detection.
11
- */
12
- async commitGeneration(message, options) {
13
- await this.stageAll();
14
- if (!(await this.hasStagedChanges())) {
15
- return (await this.git.exec(["rev-parse", "HEAD"])).trim();
16
- }
17
- let fullMessage = `[fern-generated] ${message}\n\nGenerated by Fern`;
18
- if (options?.cliVersion) {
19
- fullMessage += `\nCLI Version: ${options.cliVersion}`;
20
- }
21
- if (options?.generatorVersions && Object.keys(options.generatorVersions).length > 0) {
22
- fullMessage += "\nGenerators:";
23
- for (const [name, version] of Object.entries(options.generatorVersions)) {
24
- fullMessage += `\n - ${name}: ${version}`;
25
- }
26
- }
27
- await this.git.exec(["commit", "-m", fullMessage]);
28
- return (await this.git.exec(["rev-parse", "HEAD"])).trim();
29
- }
30
- /**
31
- * Commit the replay result (after patches applied).
32
- * Uses [fern-replay] prefix for detection.
33
- */
34
- async commitReplay(patchCount, patches) {
35
- await this.stageAll();
36
- if (!(await this.hasStagedChanges())) {
37
- return (await this.git.exec(["rev-parse", "HEAD"])).trim();
38
- }
39
- let fullMessage = `[fern-replay] Applied ${patchCount} customization(s)`;
40
- if (patches && patches.length > 0) {
41
- fullMessage += "\n\nPatches replayed:";
42
- for (const patch of patches) {
43
- fullMessage += `\n - ${patch.id}: ${patch.original_message}`;
44
- }
45
- }
46
- await this.git.exec(["commit", "-m", fullMessage]);
47
- return (await this.git.exec(["rev-parse", "HEAD"])).trim();
48
- }
49
- /**
50
- * Create a GenerationRecord for the current state.
51
- * Captures commit SHA and tree hash for future 3-way merges.
52
- */
53
- async createGenerationRecord(options) {
54
- const commitSha = (await this.git.exec(["rev-parse", "HEAD"])).trim();
55
- const treeHash = await this.getTreeHash(commitSha);
56
- return {
57
- commit_sha: commitSha,
58
- tree_hash: treeHash,
59
- timestamp: new Date().toISOString(),
60
- cli_version: options?.cliVersion ?? "unknown",
61
- generator_versions: options?.generatorVersions ?? {},
62
- };
63
- }
64
- /**
65
- * Stage all changes in output directory.
66
- */
67
- async stageAll() {
68
- await this.git.exec(["add", "-A", this.outputDir]);
69
- }
70
- /**
71
- * Check if there are staged changes to commit.
72
- */
73
- async hasStagedChanges() {
74
- const output = await this.git.exec(["diff", "--cached", "--name-only"]);
75
- return output.trim().length > 0;
76
- }
77
- /**
78
- * Get the tree hash for a commit.
79
- */
80
- async getTreeHash(commitSha) {
81
- return this.git.getTreeHash(commitSha);
82
- }
83
- }
84
- //# sourceMappingURL=ReplayCommitter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReplayCommitter.js","sourceRoot":"","sources":["../src/ReplayCommitter.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,eAAe;IAChB,GAAG,CAAY;IACf,SAAS,CAAS;IAE1B,YAAY,GAAc,EAAE,SAAiB;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,OAAe,EAAE,OAAuB;QAC3D,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEtB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/D,CAAC;QAED,IAAI,WAAW,GAAG,oBAAoB,OAAO,uBAAuB,CAAC;QAErE,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACtB,WAAW,IAAI,kBAAkB,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1D,CAAC;QAED,IAAI,OAAO,EAAE,iBAAiB,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClF,WAAW,IAAI,eAAe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AAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,sBAAsB,CAAC,OAAuB;QAChD,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO;YACH,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,WAAW,EAAE,OAAO,EAAE,UAAU,IAAI,SAAS;YAC7C,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,IAAI,EAAE;SACvD,CAAC;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACV,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,SAAiB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;CACJ"}
@@ -1,27 +0,0 @@
1
- import type { GitClient } from "./git/GitClient.js";
2
- import type { LockfileManager } from "./LockfileManager.js";
3
- import type { StoredPatch } from "./types.js";
4
- export declare class ReplayDetector {
5
- private git;
6
- private lockManager;
7
- private sdkOutputDir;
8
- readonly warnings: string[];
9
- constructor(git: GitClient, lockManager: LockfileManager, sdkOutputDir: string);
10
- /**
11
- * Detect new customization patches since last generation.
12
- * Filters out generation/replay commits, merge commits,
13
- * and already-tracked patches (by SHA or content hash).
14
- */
15
- detectNewPatches(): Promise<StoredPatch[]>;
16
- /**
17
- * Compute content hash for deduplication.
18
- * Removes commit SHA line and index lines before hashing,
19
- * so rebased commits with same content produce the same hash.
20
- */
21
- computeContentHash(patchContent: string): string;
22
- /** Detect patches via tree diff for non-linear history. Returns a composite patch. */
23
- private detectPatchesViaTreeDiff;
24
- private parseGitLog;
25
- private getLastGeneration;
26
- }
27
- //# sourceMappingURL=ReplayDetector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReplayDetector.d.ts","sourceRoot":"","sources":["../src/ReplayDetector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAgD,WAAW,EAAE,MAAM,YAAY,CAAC;AAM5F,qBAAa,cAAc;IACvB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,YAAY,CAAS;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;gBAErB,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAM9E;;;;OAIG;IACG,gBAAgB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAuFhD;;;;OAIG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAShD,sFAAsF;YACxE,wBAAwB;IAuCtC,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,iBAAiB;CAG5B"}
@@ -1,150 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { isGenerationCommit } from "./git/CommitDetection.js";
3
- // Infrastructure files managed by the generation pipeline, not user code.
4
- // Changes to these should never be captured as customization patches.
5
- const INFRASTRUCTURE_FILES = new Set([".fernignore"]);
6
- export class ReplayDetector {
7
- git;
8
- lockManager;
9
- sdkOutputDir;
10
- warnings = [];
11
- constructor(git, lockManager, sdkOutputDir) {
12
- this.git = git;
13
- this.lockManager = lockManager;
14
- this.sdkOutputDir = sdkOutputDir;
15
- }
16
- /**
17
- * Detect new customization patches since last generation.
18
- * Filters out generation/replay commits, merge commits,
19
- * and already-tracked patches (by SHA or content hash).
20
- */
21
- async detectNewPatches() {
22
- const lock = this.lockManager.read();
23
- const lastGen = this.getLastGeneration(lock);
24
- if (!lastGen) {
25
- return [];
26
- }
27
- const exists = await this.git.commitExists(lastGen.commit_sha);
28
- if (!exists) {
29
- this.warnings.push(`Generation commit ${lastGen.commit_sha.slice(0, 7)} not found in git history. ` +
30
- `Skipping new patch detection. Existing lockfile patches will still be applied.`);
31
- return [];
32
- }
33
- // Non-linear history (e.g. squash merge): fall back to tree-diff detection.
34
- const isAncestor = await this.git.isAncestor(lastGen.commit_sha, "HEAD");
35
- if (!isAncestor) {
36
- return this.detectPatchesViaTreeDiff(lastGen);
37
- }
38
- const log = await this.git.exec([
39
- "log",
40
- "--format=%H%x00%an%x00%ae%x00%s",
41
- `${lastGen.commit_sha}..HEAD`,
42
- "--",
43
- this.sdkOutputDir
44
- ]);
45
- if (!log.trim()) {
46
- return [];
47
- }
48
- const commits = this.parseGitLog(log);
49
- const newPatches = [];
50
- for (const commit of commits) {
51
- if (isGenerationCommit(commit)) {
52
- continue;
53
- }
54
- const parents = await this.git.getCommitParents(commit.sha);
55
- if (parents.length > 1) {
56
- continue;
57
- }
58
- if (lock.patches.find((p) => p.original_commit === commit.sha)) {
59
- continue;
60
- }
61
- const patchContent = await this.git.formatPatch(commit.sha);
62
- const contentHash = this.computeContentHash(patchContent);
63
- if (lock.patches.find((p) => p.content_hash === contentHash)) {
64
- continue;
65
- }
66
- const filesOutput = await this.git.exec(["diff-tree", "--no-commit-id", "--name-only", "-r", commit.sha]);
67
- const files = filesOutput
68
- .trim()
69
- .split("\n")
70
- .filter(Boolean)
71
- .filter((f) => !INFRASTRUCTURE_FILES.has(f));
72
- // Skip patches that only touch infrastructure files
73
- if (files.length === 0) {
74
- continue;
75
- }
76
- newPatches.push({
77
- id: `patch-${commit.sha.slice(0, 8)}`,
78
- content_hash: contentHash,
79
- original_commit: commit.sha,
80
- original_message: commit.message,
81
- original_author: `${commit.authorName} <${commit.authorEmail}>`,
82
- base_generation: lastGen.commit_sha,
83
- files,
84
- patch_content: patchContent
85
- });
86
- }
87
- // Reverse so patches apply in chronological order (oldest first)
88
- return newPatches.reverse();
89
- }
90
- /**
91
- * Compute content hash for deduplication.
92
- * Removes commit SHA line and index lines before hashing,
93
- * so rebased commits with same content produce the same hash.
94
- */
95
- computeContentHash(patchContent) {
96
- const normalized = patchContent
97
- .split("\n")
98
- .filter((line) => !line.startsWith("From ") && !line.startsWith("index ") && !line.startsWith("Date: "))
99
- .join("\n");
100
- return `sha256:${createHash("sha256").update(normalized).digest("hex")}`;
101
- }
102
- /** Detect patches via tree diff for non-linear history. Returns a composite patch. */
103
- async detectPatchesViaTreeDiff(lastGen) {
104
- // Get changed files first, then filter before computing the diff
105
- const filesOutput = await this.git.exec(["diff", "--name-only", lastGen.commit_sha, "HEAD"]);
106
- const files = filesOutput
107
- .trim()
108
- .split("\n")
109
- .filter(Boolean)
110
- .filter((f) => !INFRASTRUCTURE_FILES.has(f))
111
- .filter((f) => !f.startsWith(".fern/"));
112
- if (files.length === 0)
113
- return [];
114
- // Compute diff only for the filtered files
115
- const diff = await this.git.exec(["diff", lastGen.commit_sha, "HEAD", "--", ...files]);
116
- if (!diff.trim())
117
- return [];
118
- const contentHash = this.computeContentHash(diff);
119
- // Dedup against existing patches — if an existing patch already captures
120
- // this exact content, don't create a duplicate composite patch.
121
- const lock = this.lockManager.read();
122
- if (lock.patches.some((p) => p.content_hash === contentHash)) {
123
- return [];
124
- }
125
- const headSha = (await this.git.exec(["rev-parse", "HEAD"])).trim();
126
- return [{
127
- id: `patch-composite-${headSha.slice(0, 8)}`,
128
- content_hash: contentHash,
129
- original_commit: headSha,
130
- original_message: "Customer customizations (composite)",
131
- original_author: "composite",
132
- base_generation: lastGen.commit_sha,
133
- files,
134
- patch_content: diff,
135
- }];
136
- }
137
- parseGitLog(log) {
138
- return log
139
- .trim()
140
- .split("\n")
141
- .map((line) => {
142
- const [sha, authorName, authorEmail, message] = line.split("\0");
143
- return { sha, authorName, authorEmail, message };
144
- });
145
- }
146
- getLastGeneration(lock) {
147
- return lock.generations.find((g) => g.commit_sha === lock.current_generation);
148
- }
149
- }
150
- //# sourceMappingURL=ReplayDetector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReplayDetector.js","sourceRoot":"","sources":["../src/ReplayDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAK9D,0EAA0E;AAC1E,sEAAsE;AACtE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEtD,MAAM,OAAO,cAAc;IACf,GAAG,CAAY;IACf,WAAW,CAAkB;IAC7B,YAAY,CAAS;IACpB,QAAQ,GAAa,EAAE,CAAC;IAEjC,YAAY,GAAc,EAAE,WAA4B,EAAE,YAAoB;QAC1E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,OAAO,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CAAC,CAAC,IAAI,EAAE,EAAE;YACV,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QACrD,CAAC,CAAC,CAAC;IACX,CAAC;IAEO,iBAAiB,CAAC,IAAoB;QAC1C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClF,CAAC;CACJ"}
@@ -1,113 +0,0 @@
1
- import type { ReplayConfig, StoredPatch, FileResult } from "./types.js";
2
- export interface ConflictDetail {
3
- patchId: string;
4
- patchMessage: string;
5
- reason?: string;
6
- files: FileResult[];
7
- /** Files that applied cleanly in a patch that also had conflicts. */
8
- cleanFiles?: string[];
9
- }
10
- export interface ReplayReport {
11
- flow: "first-generation" | "no-patches" | "normal-regeneration" | "skip-application";
12
- patchesDetected: number;
13
- patchesApplied: number;
14
- patchesWithConflicts: number;
15
- patchesSkipped: number;
16
- patchesAbsorbed?: number;
17
- patchesRepointed?: number;
18
- patchesContentRebased?: number;
19
- patchesKeptAsUserOwned?: number;
20
- patchesPartiallyApplied?: number;
21
- patchesConflictResolved?: number;
22
- patchesRefreshed?: number;
23
- conflicts: FileResult[];
24
- conflictDetails?: ConflictDetail[];
25
- wouldApply?: StoredPatch[];
26
- warnings?: string[];
27
- }
28
- export interface ReplayOptions {
29
- /** Log what would happen but don't modify anything */
30
- dryRun?: boolean;
31
- /** Write files and stage changes, but don't commit */
32
- stageOnly?: boolean;
33
- /** CLI version for commit metadata */
34
- cliVersion?: string;
35
- /** Generator versions for commit metadata */
36
- generatorVersions?: Record<string, string>;
37
- /** Commit generation + update lockfile, skip detection/application */
38
- skipApplication?: boolean;
39
- }
40
- export declare class ReplayService {
41
- private git;
42
- private detector;
43
- private applicator;
44
- private committer;
45
- private lockManager;
46
- private outputDir;
47
- constructor(outputDir: string, _config: ReplayConfig);
48
- /**
49
- * Run the full replay flow.
50
- */
51
- runReplay(options?: ReplayOptions): Promise<ReplayReport>;
52
- /**
53
- * Sync the lockfile after a divergent PR was squash-merged.
54
- * Call this BEFORE runReplay() when the CLI detects a merged divergent PR.
55
- */
56
- syncFromDivergentMerge(generationCommitSha: string, options?: {
57
- cliVersion?: string;
58
- generatorVersions?: Record<string, string>;
59
- }): Promise<void>;
60
- /**
61
- * Determine which flow to use based on lockfile state.
62
- */
63
- private determineFlow;
64
- /**
65
- * First generation - just create lockfile, no patches to apply.
66
- */
67
- private handleFirstGeneration;
68
- /**
69
- * Skip-application mode: commit the generation and update the lockfile
70
- * but don't detect or apply patches. Sets a marker so the next normal
71
- * run skips revert detection in preGenerationRebase().
72
- */
73
- private handleSkipApplication;
74
- /**
75
- * No existing patches - detect new ones and apply if any.
76
- */
77
- private handleNoPatchesRegeneration;
78
- /**
79
- * Normal flow - apply existing patches + detect new ones.
80
- */
81
- private handleNormalRegeneration;
82
- /**
83
- * Rebase cleanly applied patches so they are relative to the current generation.
84
- * This prevents recurring conflicts on subsequent regenerations.
85
- * Returns the number of patches rebased.
86
- */
87
- private rebasePatches;
88
- /**
89
- * For conflict patches with mixed results (some files merged, some conflicted),
90
- * check if the cleanly merged files were absorbed by the generator (empty diff).
91
- * If so, remove them from patch.files so they don't pollute the pre-generation
92
- * rebase conflict marker check (`git grep <<<<<<< -- ...patch.files`).
93
- *
94
- * Non-absorbed clean files stay in patch.files — removing them would lose
95
- * the customization on the next generation.
96
- */
97
- private trimAbsorbedFiles;
98
- /**
99
- * Pre-generation rebase: update patches using the customer's current state.
100
- * Called BEFORE commitGeneration() while HEAD has customer code.
101
- */
102
- private preGenerationRebase;
103
- /**
104
- * Read .fernignore patterns from the output directory.
105
- * Returns an empty array if .fernignore doesn't exist.
106
- */
107
- private readFernignorePatterns;
108
- /**
109
- * Build the final report from results.
110
- */
111
- private buildReport;
112
- }
113
- //# sourceMappingURL=ReplayService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReplayService.d.ts","sourceRoot":"","sources":["../src/ReplayService.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAoB,YAAY,EAAgB,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExG,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,kBAAkB,GAAG,YAAY,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;IACrF,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC1B,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,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