@fern-api/replay 0.6.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 -38
  11. package/dist/FernignoreMigrator.d.ts.map +0 -1
  12. package/dist/FernignoreMigrator.js +0 -210
  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 -30
  19. package/dist/ReplayApplicator.d.ts.map +0 -1
  20. package/dist/ReplayApplicator.js +0 -544
  21. package/dist/ReplayApplicator.js.map +0 -1
  22. package/dist/ReplayCommitter.d.ts +0 -19
  23. package/dist/ReplayCommitter.d.ts.map +0 -1
  24. package/dist/ReplayCommitter.js +0 -64
  25. package/dist/ReplayCommitter.js.map +0 -1
  26. package/dist/ReplayDetector.d.ts +0 -22
  27. package/dist/ReplayDetector.d.ts.map +0 -1
  28. package/dist/ReplayDetector.js +0 -147
  29. package/dist/ReplayDetector.js.map +0 -1
  30. package/dist/ReplayService.d.ts +0 -100
  31. package/dist/ReplayService.d.ts.map +0 -1
  32. package/dist/ReplayService.js +0 -596
  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 -237
  45. package/dist/commands/bootstrap.js.map +0 -1
  46. package/dist/commands/forget.d.ts +0 -16
  47. package/dist/commands/forget.d.ts.map +0 -1
  48. package/dist/commands/forget.js +0 -27
  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 -16
  55. package/dist/commands/reset.d.ts.map +0 -1
  56. package/dist/commands/reset.js +0 -25
  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 -26
  63. package/dist/commands/status.d.ts.map +0 -1
  64. package/dist/commands/status.js +0 -24
  65. package/dist/commands/status.js.map +0 -1
  66. package/dist/git/CommitDetection.d.ts +0 -7
  67. package/dist/git/CommitDetection.d.ts.map +0 -1
  68. package/dist/git/CommitDetection.js +0 -26
  69. package/dist/git/CommitDetection.js.map +0 -1
  70. package/dist/git/GitClient.d.ts +0 -22
  71. package/dist/git/GitClient.d.ts.map +0 -1
  72. package/dist/git/GitClient.js +0 -109
  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 -80
  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 +0,0 @@
1
- {"version":3,"file":"ReplayCommitter.js","sourceRoot":"","sources":["../src/ReplayCommitter.ts"],"names":[],"mappings":"AASA,MAAM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E;YACnC,WAAW,EAAE,OAAO,EAAE,UAAU,IAAI,SAAS;YAC7C,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,IAAI,EAAE;YACpD,gBAAgB,EAAE,OAAO,EAAE,cAAc;SAC5C,CAAC;IACN,CAAC;IAED,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,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,KAAK,CAAC,WAAW,CAAC,SAAiB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;CACJ"}
@@ -1,22 +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
- detectNewPatches(): Promise<StoredPatch[]>;
11
- /**
12
- * Compute content hash for deduplication.
13
- * Removes commit SHA line and index lines before hashing,
14
- * so rebased commits with same content produce the same hash.
15
- */
16
- computeContentHash(patchContent: string): string;
17
- /** Detect patches via tree diff for non-linear history. Returns a composite patch. */
18
- private detectPatchesViaTreeDiff;
19
- private parseGitLog;
20
- private getLastGeneration;
21
- }
22
- //# 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;IAMxE,gBAAgB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAuFhD;;;;OAIG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAShD,sFAAsF;YACxE,wBAAwB;IAyCtC,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,iBAAiB;CAG5B"}
@@ -1,147 +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
- async detectNewPatches() {
17
- const lock = this.lockManager.read();
18
- const lastGen = this.getLastGeneration(lock);
19
- if (!lastGen) {
20
- return [];
21
- }
22
- const exists = await this.git.commitExists(lastGen.commit_sha);
23
- if (!exists) {
24
- this.warnings.push(`Generation commit ${lastGen.commit_sha.slice(0, 7)} not found in git history. ` +
25
- `Skipping new patch detection. Existing lockfile patches will still be applied.`);
26
- return [];
27
- }
28
- // Non-linear history (e.g. squash merge): fall back to tree-diff detection.
29
- const isAncestor = await this.git.isAncestor(lastGen.commit_sha, "HEAD");
30
- if (!isAncestor) {
31
- return this.detectPatchesViaTreeDiff(lastGen);
32
- }
33
- const log = await this.git.exec([
34
- "log",
35
- "--format=%H%x00%an%x00%ae%x00%s",
36
- `${lastGen.commit_sha}..HEAD`,
37
- "--",
38
- this.sdkOutputDir
39
- ]);
40
- if (!log.trim()) {
41
- return [];
42
- }
43
- const commits = this.parseGitLog(log);
44
- const newPatches = [];
45
- for (const commit of commits) {
46
- if (isGenerationCommit(commit)) {
47
- continue;
48
- }
49
- const parents = await this.git.getCommitParents(commit.sha);
50
- if (parents.length > 1) {
51
- continue;
52
- }
53
- if (lock.patches.find((p) => p.original_commit === commit.sha)) {
54
- continue;
55
- }
56
- const patchContent = await this.git.formatPatch(commit.sha);
57
- const contentHash = this.computeContentHash(patchContent);
58
- if (lock.patches.find((p) => p.content_hash === contentHash)) {
59
- continue;
60
- }
61
- const filesOutput = await this.git.exec(["diff-tree", "--no-commit-id", "--name-only", "-r", commit.sha]);
62
- const files = filesOutput
63
- .trim()
64
- .split("\n")
65
- .filter(Boolean)
66
- .filter((f) => !INFRASTRUCTURE_FILES.has(f));
67
- // Skip patches that only touch infrastructure files
68
- if (files.length === 0) {
69
- continue;
70
- }
71
- newPatches.push({
72
- id: `patch-${commit.sha.slice(0, 8)}`,
73
- content_hash: contentHash,
74
- original_commit: commit.sha,
75
- original_message: commit.message,
76
- original_author: `${commit.authorName} <${commit.authorEmail}>`,
77
- base_generation: lastGen.commit_sha,
78
- files,
79
- patch_content: patchContent
80
- });
81
- }
82
- // Reverse so patches apply in chronological order (oldest first)
83
- return newPatches.reverse();
84
- }
85
- /**
86
- * Compute content hash for deduplication.
87
- * Removes commit SHA line and index lines before hashing,
88
- * so rebased commits with same content produce the same hash.
89
- */
90
- computeContentHash(patchContent) {
91
- const normalized = patchContent
92
- .split("\n")
93
- .filter((line) => !line.startsWith("From ") && !line.startsWith("index ") && !line.startsWith("Date: "))
94
- .join("\n");
95
- return `sha256:${createHash("sha256").update(normalized).digest("hex")}`;
96
- }
97
- /** Detect patches via tree diff for non-linear history. Returns a composite patch. */
98
- async detectPatchesViaTreeDiff(lastGen) {
99
- // Get changed files first, then filter before computing the diff
100
- const filesOutput = await this.git.exec(["diff", "--name-only", lastGen.commit_sha, "HEAD"]);
101
- const files = filesOutput
102
- .trim()
103
- .split("\n")
104
- .filter(Boolean)
105
- .filter((f) => !INFRASTRUCTURE_FILES.has(f))
106
- .filter((f) => !f.startsWith(".fern/"));
107
- if (files.length === 0)
108
- return [];
109
- // Compute diff only for the filtered files
110
- const diff = await this.git.exec(["diff", lastGen.commit_sha, "HEAD", "--", ...files]);
111
- if (!diff.trim())
112
- return [];
113
- const contentHash = this.computeContentHash(diff);
114
- // Dedup against existing patches — if an existing patch already captures
115
- // this exact content, don't create a duplicate composite patch.
116
- const lock = this.lockManager.read();
117
- if (lock.patches.some((p) => p.content_hash === contentHash)) {
118
- return [];
119
- }
120
- const headSha = (await this.git.exec(["rev-parse", "HEAD"])).trim();
121
- return [
122
- {
123
- id: `patch-composite-${headSha.slice(0, 8)}`,
124
- content_hash: contentHash,
125
- original_commit: headSha,
126
- original_message: "Customer customizations (composite)",
127
- original_author: "composite",
128
- base_generation: lastGen.commit_sha,
129
- files,
130
- patch_content: diff
131
- }
132
- ];
133
- }
134
- parseGitLog(log) {
135
- return log
136
- .trim()
137
- .split("\n")
138
- .map((line) => {
139
- const [sha, authorName, authorEmail, message] = line.split("\0");
140
- return { sha, authorName, authorEmail, message };
141
- });
142
- }
143
- getLastGeneration(lock) {
144
- return lock.generations.find((g) => g.commit_sha === lock.current_generation);
145
- }
146
- }
147
- //# 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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AAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEpE,OAAO;YACH;gBACI,EAAE,EAAE,mBAAmB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;gBAC5C,YAAY,EAAE,WAAW;gBACzB,eAAe,EAAE,OAAO;gBACxB,gBAAgB,EAAE,qCAAqC;gBACvD,eAAe,EAAE,WAAW;gBAC5B,eAAe,EAAE,OAAO,CAAC,UAAU;gBACnC,KAAK;gBACL,aAAa,EAAE,IAAI;aACtB;SACJ,CAAC;IACN,CAAC;IAEO,WAAW,CAAC,GAAW;QAC3B,OAAO,GAAG;aACL,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,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,100 +0,0 @@
1
- import type { FileResult, ReplayConfig, StoredPatch } 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
- /** SHA of the base branch HEAD before replay runs. Stored in lockfile for squash merge recovery. */
40
- baseBranchHead?: string;
41
- }
42
- export declare class ReplayService {
43
- private git;
44
- private detector;
45
- private applicator;
46
- private committer;
47
- private lockManager;
48
- private outputDir;
49
- constructor(outputDir: string, _config: ReplayConfig);
50
- runReplay(options?: ReplayOptions): Promise<ReplayReport>;
51
- /**
52
- * Sync the lockfile after a divergent PR was squash-merged.
53
- * Call this BEFORE runReplay() when the CLI detects a merged divergent PR.
54
- *
55
- * After updating the generation record, re-detects customer patches via
56
- * tree diff between the generation tag (pure generation tree) and HEAD
57
- * (which includes customer customizations after squash merge). This ensures
58
- * patches survive the squash merge → regenerate cycle even when the lockfile
59
- * was restored from the base branch during conflict PR creation.
60
- */
61
- syncFromDivergentMerge(generationCommitSha: string, options?: {
62
- cliVersion?: string;
63
- generatorVersions?: Record<string, string>;
64
- baseBranchHead?: string;
65
- }): Promise<void>;
66
- private determineFlow;
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
- private handleNoPatchesRegeneration;
75
- private handleNormalRegeneration;
76
- /**
77
- * Rebase cleanly applied patches so they are relative to the current generation.
78
- * This prevents recurring conflicts on subsequent regenerations.
79
- * Returns the number of patches rebased.
80
- */
81
- private rebasePatches;
82
- /**
83
- * For conflict patches with mixed results (some files merged, some conflicted),
84
- * check if the cleanly merged files were absorbed by the generator (empty diff).
85
- * If so, remove them from patch.files so they don't pollute the pre-generation
86
- * rebase conflict marker check (`git grep <<<<<<< -- ...patch.files`).
87
- *
88
- * Non-absorbed clean files stay in patch.files — removing them would lose
89
- * the customization on the next generation.
90
- */
91
- private trimAbsorbedFiles;
92
- /**
93
- * Pre-generation rebase: update patches using the customer's current state.
94
- * Called BEFORE commitGeneration() while HEAD has customer code.
95
- */
96
- private preGenerationRebase;
97
- private readFernignorePatterns;
98
- private buildReport;
99
- }
100
- //# 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,EAAE,UAAU,EAAoB,YAAY,EAAgB,WAAW,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,e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