@fern-api/fern-api-dev 5.23.3-633-g7c238cb2767 → 5.23.3-634-g7ab8b708d86

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/cli.cjs +72 -13
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -422248,15 +422248,19 @@ var require_AutoVersionStep = __commonJS({
422248
422248
  analysis: { versionBump: "PATCH", message: this.brandMessage("SDK regeneration") }
422249
422249
  });
422250
422250
  }
422251
- const chunks = service.chunkDiff(cleanedDiff, index_1.MAX_AI_DIFF_BYTES);
422252
- const cappedChunks = chunks.slice(0, index_1.MAX_CHUNKS);
422253
- const skippedChunks = chunks.length - cappedChunks.length;
422254
- if (chunks.length > 1) {
422255
- this.logger.info(`AutoVersionStep: split diff into ${chunks.length} chunks` + (skippedChunks > 0 ? ` (capped at ${index_1.MAX_CHUNKS}, skipping ${skippedChunks})` : ""));
422256
- }
422257
422251
  let analysis;
422258
422252
  try {
422259
- analysis = cappedChunks.length <= 1 ? await this.analyzeSingle(cleanedDiff, language, previousVersion) : await this.analyzeChunks(cappedChunks, language, previousVersion);
422253
+ if (this.config.ai == null && this.config.fernToken != null) {
422254
+ analysis = await this.analyzeViaFaiService(cleanedDiff, language, previousVersion);
422255
+ } else {
422256
+ const chunks = service.chunkDiff(cleanedDiff, index_1.MAX_AI_DIFF_BYTES);
422257
+ const cappedChunks = chunks.slice(0, index_1.MAX_CHUNKS);
422258
+ const skippedChunks = chunks.length - cappedChunks.length;
422259
+ if (chunks.length > 1) {
422260
+ this.logger.info(`AutoVersionStep: split diff into ${chunks.length} chunks` + (skippedChunks > 0 ? ` (capped at ${index_1.MAX_CHUNKS}, skipping ${skippedChunks})` : ""));
422261
+ }
422262
+ analysis = cappedChunks.length <= 1 ? await this.analyzeSingle(cleanedDiff, language, previousVersion) : await this.analyzeChunks(cappedChunks, language, previousVersion);
422263
+ }
422260
422264
  } catch (error50) {
422261
422265
  this.logger.warn(`AutoVersionStep: FAI analysis failed (${String(error50)}); falling back to PATCH bump.`);
422262
422266
  analysis = { versionBump: "PATCH", message: this.brandMessage("SDK regeneration") };
@@ -422518,6 +422522,47 @@ ${newBlock}${remainder}`;
422518
422522
  };
422519
422523
  }
422520
422524
  }
422525
+ /**
422526
+ * Calls the hosted FAI service (`/sdks/analyze-commit-diff`) with the fern token.
422527
+ * Used when no BAML `ai` config is supplied (remote generation via fiddle). FAI
422528
+ * handles chunking, parallelism, and retries server-side. Returns null on
422529
+ * NO_CHANGE; throws on transport/HTTP errors so the caller's PATCH fallback applies.
422530
+ */
422531
+ async analyzeViaFaiService(cleanedDiff, language, previousVersion) {
422532
+ const baseUrl = this.config.faiBaseUrl ?? "https://fai.buildwithfern.com";
422533
+ const response = await fetch(`${baseUrl}/sdks/analyze-commit-diff`, {
422534
+ method: "POST",
422535
+ headers: {
422536
+ Authorization: `Bearer ${this.config.fernToken}`,
422537
+ "Content-Type": "application/json"
422538
+ },
422539
+ body: JSON.stringify({
422540
+ diff: cleanedDiff,
422541
+ language,
422542
+ previous_version: previousVersion,
422543
+ prior_changelog: this.config.priorChangelog ?? void 0,
422544
+ spec_commit_message: this.config.specCommitMessage ?? void 0
422545
+ })
422546
+ });
422547
+ if (!response.ok) {
422548
+ const body = await response.text().catch(() => "");
422549
+ throw new Error(`FAI analyze-commit-diff failed with status ${response.status}: ${body.slice(0, 500)}`);
422550
+ }
422551
+ const parsed = await response.json();
422552
+ if (!isFaiAnalyzeResponse(parsed)) {
422553
+ throw new Error("FAI analyze-commit-diff returned an unexpected response shape");
422554
+ }
422555
+ if (parsed.version_bump === "NO_CHANGE") {
422556
+ return null;
422557
+ }
422558
+ return {
422559
+ versionBump: parsed.version_bump,
422560
+ message: this.brandMessage(parsed.message),
422561
+ changelogEntry: nonEmpty2(parsed.changelog_entry),
422562
+ prDescription: nonEmpty2(parsed.pr_description),
422563
+ versionBumpReason: nonEmpty2(parsed.version_bump_reason)
422564
+ };
422565
+ }
422521
422566
  /**
422522
422567
  * Dynamically imports @fern-api/cli-ai only when autoversion actually needs to
422523
422568
  * call FAI. The package is ESM-only with extensionless internal imports, so
@@ -422560,6 +422605,20 @@ ${newBlock}${remainder}`;
422560
422605
  }
422561
422606
  };
422562
422607
  exports2.AutoVersionStep = AutoVersionStep;
422608
+ var FAI_VERSION_BUMPS = ["MAJOR", "MINOR", "PATCH", "NO_CHANGE"];
422609
+ function isFaiAnalyzeResponse(value2) {
422610
+ if (typeof value2 !== "object" || value2 == null) {
422611
+ return false;
422612
+ }
422613
+ const candidate = value2;
422614
+ return typeof candidate.message === "string" && typeof candidate.version_bump === "string" && FAI_VERSION_BUMPS.includes(candidate.version_bump) && isStringOrAbsent(candidate.changelog_entry) && isStringOrAbsent(candidate.pr_description) && isStringOrAbsent(candidate.version_bump_reason);
422615
+ }
422616
+ function isStringOrAbsent(value2) {
422617
+ return value2 == null || typeof value2 === "string";
422618
+ }
422619
+ function nonEmpty2(value2) {
422620
+ return value2 != null && value2.trim().length > 0 ? value2 : void 0;
422621
+ }
422563
422622
  }
422564
422623
  });
422565
422624
 
@@ -669211,7 +669270,7 @@ var AccessTokenPosthogManager = class {
669211
669270
  properties: {
669212
669271
  ...event,
669213
669272
  ...event.properties,
669214
- version: "5.23.3-633-g7c238cb2767",
669273
+ version: "5.23.3-634-g7ab8b708d86",
669215
669274
  usingAccessToken: true,
669216
669275
  ...getRunIdProperties()
669217
669276
  }
@@ -669275,7 +669334,7 @@ var UserPosthogManager = class {
669275
669334
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
669276
669335
  event: "CLI",
669277
669336
  properties: {
669278
- version: "5.23.3-633-g7c238cb2767",
669337
+ version: "5.23.3-634-g7ab8b708d86",
669279
669338
  ...event,
669280
669339
  ...event.properties,
669281
669340
  usingAccessToken: false,
@@ -861013,7 +861072,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
861013
861072
  var LOGS_FOLDER_NAME = "logs";
861014
861073
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
861015
861074
  function getCliSource() {
861016
- const version7 = "5.23.3-633-g7c238cb2767";
861075
+ const version7 = "5.23.3-634-g7ab8b708d86";
861017
861076
  return `cli@${version7}`;
861018
861077
  }
861019
861078
  var DebugLogger = class {
@@ -892105,7 +892164,7 @@ var LegacyDocsPublisher = class {
892105
892164
  previewId,
892106
892165
  disableTemplates: void 0,
892107
892166
  skipUpload,
892108
- cliVersion: "5.23.3-633-g7c238cb2767",
892167
+ cliVersion: "5.23.3-634-g7ab8b708d86",
892109
892168
  loginCommand: "fern auth login"
892110
892169
  });
892111
892170
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -957246,7 +957305,7 @@ function getAutomationContextFromEnv() {
957246
957305
  config_branch: process.env.FERN_CONFIG_BRANCH,
957247
957306
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
957248
957307
  trigger: process.env.GITHUB_EVENT_NAME,
957249
- cli_version: "5.23.3-633-g7c238cb2767"
957308
+ cli_version: "5.23.3-634-g7ab8b708d86"
957250
957309
  };
957251
957310
  }
957252
957311
  function isAutomationMode() {
@@ -958072,7 +958131,7 @@ var CliContext = class _CliContext {
958072
958131
  if (false) {
958073
958132
  this.logger.error("CLI_VERSION is not defined");
958074
958133
  }
958075
- return "5.23.3-633-g7c238cb2767";
958134
+ return "5.23.3-634-g7ab8b708d86";
958076
958135
  }
958077
958136
  getCliName() {
958078
958137
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-633-g7c238cb2767",
2
+ "version": "5.23.3-634-g7ab8b708d86",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",