@fern-api/generator-cli 0.9.52 → 0.9.53

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 (2) hide show
  1. package/dist/cli.js +85 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41162,6 +41162,7 @@ var AutoVersioningService = class _AutoVersioningService {
41162
41162
  }
41163
41163
  }
41164
41164
  let processedContent = this.removeGoModulePathSuffixPairs(contentLines);
41165
+ processedContent = this.removeGoExplicitFieldBitConstantPairs(processedContent);
41165
41166
  processedContent = this.removeVersionChangePairs(processedContent, mappedMagicVersion);
41166
41167
  processedContent = this.removeRemainingMagicVersionLines(processedContent, mappedMagicVersion);
41167
41168
  let hasChanges = false;
@@ -41366,6 +41367,90 @@ var AutoVersioningService = class _AutoVersioningService {
41366
41367
  hasSuffix: suffixPattern.test(content)
41367
41368
  };
41368
41369
  }
41370
+ /**
41371
+ * Removes Go `explicitFields` bit-constant reindexing churn from a diff section.
41372
+ *
41373
+ * The Go SDK tracks which optional fields were explicitly set via a per-struct `big.Int`
41374
+ * bitmask. For each struct property it generates a private constant whose value is a single
41375
+ * bit at the property's positional index, e.g.
41376
+ *
41377
+ * var (
41378
+ * entityFieldGeoShape = big.NewInt(1 << 3)
41379
+ * entityFieldGeoDetails = big.NewInt(1 << 4)
41380
+ * )
41381
+ *
41382
+ * Inserting a new field earlier in the struct shifts every following constant's bit index by
41383
+ * one, producing a deletion/addition pair per field that differs only by the integer:
41384
+ *
41385
+ * - entityFieldGeoShape = big.NewInt(1 << 3)
41386
+ * + entityFieldGeoShape = big.NewInt(1 << 4)
41387
+ *
41388
+ * This is a purely mechanical artifact of the field addition: the bit is assigned and read
41389
+ * within the same generated version (the wire format is name-based JSON, not bit position),
41390
+ * so shifting it is not observable to consumers. Left in the diff, the AI analyzer reads the
41391
+ * shifted bit positions as a serialization-compatibility break and misclassifies an additive
41392
+ * change as a spurious MAJOR bump. The genuinely new field, its own new bit constant, and its
41393
+ * setter are all pure additions with no matching deletion, so they survive this pass and the
41394
+ * AI still sees (and correctly classifies) the field addition as MINOR.
41395
+ */
41396
+ removeGoExplicitFieldBitConstantPairs(lines) {
41397
+ const additions = [];
41398
+ for (let index = 0; index < lines.length; index++) {
41399
+ const line = lines[index];
41400
+ if (line == null || !this.isAdditionLine(line)) {
41401
+ continue;
41402
+ }
41403
+ const info = this.analyzeGoBitConstantLine(line);
41404
+ if (info != null) {
41405
+ additions.push({ index, normalized: info.normalized });
41406
+ }
41407
+ }
41408
+ const removed = /* @__PURE__ */ new Set();
41409
+ const usedAdditions = /* @__PURE__ */ new Set();
41410
+ for (let index = 0; index < lines.length; index++) {
41411
+ const line = lines[index];
41412
+ if (line == null || !this.isDeletionLine(line)) {
41413
+ continue;
41414
+ }
41415
+ const info = this.analyzeGoBitConstantLine(line);
41416
+ if (info == null) {
41417
+ continue;
41418
+ }
41419
+ const match2 = additions.find(
41420
+ (addition) => !usedAdditions.has(addition.index) && addition.normalized === info.normalized
41421
+ );
41422
+ if (match2 != null) {
41423
+ usedAdditions.add(match2.index);
41424
+ removed.add(index);
41425
+ removed.add(match2.index);
41426
+ }
41427
+ }
41428
+ if (removed.size === 0) {
41429
+ return lines;
41430
+ }
41431
+ return lines.filter((_2, index) => !removed.has(index));
41432
+ }
41433
+ /**
41434
+ * If a diff line (with its leading +/- stripped) is a generated Go `explicitFields`
41435
+ * bit constant — `<name> = big.NewInt(1 << N)` or the >=63 form
41436
+ * `<name> = big.NewInt(0).Lsh(big.NewInt(1), N)` — returns a normalized key with the bit
41437
+ * index removed so a deletion and its reindexed addition compare equal. Requiring the exact
41438
+ * `big.NewInt` bit-shift shape keeps this from matching ordinary integer assignments.
41439
+ */
41440
+ analyzeGoBitConstantLine(line) {
41441
+ const content = line.substring(1);
41442
+ const shiftMatch = content.match(/^(\s*)([A-Za-z_][A-Za-z0-9_]*)\s*=\s*big\.NewInt\(1\s*<<\s*\d+\)\s*$/);
41443
+ if (shiftMatch?.[2] != null) {
41444
+ return { normalized: `${shiftMatch[2]}=big.NewInt(1<<#)` };
41445
+ }
41446
+ const lshMatch = content.match(
41447
+ /^(\s*)([A-Za-z_][A-Za-z0-9_]*)\s*=\s*big\.NewInt\(0\)\.Lsh\(big\.NewInt\(1\),\s*\d+\)\s*$/
41448
+ );
41449
+ if (lshMatch?.[2] != null) {
41450
+ return { normalized: `${lshMatch[2]}=big.NewInt(0).Lsh(big.NewInt(1),#)` };
41451
+ }
41452
+ return void 0;
41453
+ }
41369
41454
  /**
41370
41455
  * Gets the latest semantic version from git tags in the given repository.
41371
41456
  * Used as a fallback when the magic version is not embedded in any generated file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.9.52",
3
+ "version": "0.9.53",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",