repomind 0.12.0 → 0.13.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 (2) hide show
  1. package/dist/index.js +128 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77415,16 +77415,45 @@ var PlanLimitError = class extends Error {
77415
77415
  this.name = "PlanLimitError";
77416
77416
  }
77417
77417
  };
77418
- function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77418
+ var OutdatedCliError = class extends Error {
77419
+ constructor(currentVersion, minVersion, latestVersion) {
77420
+ super(`CLI desatualizado: ${currentVersion} < ${minVersion}`);
77421
+ this.currentVersion = currentVersion;
77422
+ this.minVersion = minVersion;
77423
+ this.latestVersion = latestVersion;
77424
+ this.name = "OutdatedCliError";
77425
+ }
77426
+ };
77427
+ var CLI_VERSION_HEADER = "X-RepoMind-CLI-Version";
77428
+ var CLI_LATEST_HEADER = "X-RepoMind-CLI-Latest";
77429
+ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch, cliVersion = "0.13.1") {
77430
+ let latestCliVersion = null;
77431
+ function baseHeaders(token) {
77432
+ return {
77433
+ "Content-Type": "application/json",
77434
+ [CLI_VERSION_HEADER]: cliVersion,
77435
+ ...token ? { Authorization: `Bearer ${token}` } : {}
77436
+ };
77437
+ }
77438
+ function captureLatest(res) {
77439
+ const latest = res.headers.get(CLI_LATEST_HEADER);
77440
+ if (latest) latestCliVersion = latest;
77441
+ }
77442
+ function throwIfOutdated(status, errBody) {
77443
+ if (status === 426 && errBody.error === "cli_outdated") {
77444
+ throw new OutdatedCliError(
77445
+ cliVersion,
77446
+ String(errBody.minVersion ?? ""),
77447
+ String(errBody.latestVersion ?? "")
77448
+ );
77449
+ }
77450
+ }
77419
77451
  async function request2(method, path2, token, body, timeoutMs) {
77420
77452
  let res;
77421
77453
  try {
77422
77454
  res = await fetchFn(`${baseUrl}${path2}`, {
77423
77455
  method,
77424
- headers: {
77425
- "Content-Type": "application/json",
77426
- ...token ? { Authorization: `Bearer ${token}` } : {}
77427
- },
77456
+ headers: baseHeaders(token),
77428
77457
  ...body !== void 0 ? { body: JSON.stringify(body) } : {},
77429
77458
  signal: AbortSignal.timeout(timeoutMs ?? FETCH_TIMEOUT_MS)
77430
77459
  });
@@ -77435,6 +77464,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77435
77464
  err instanceof Error ? err.message : "network error"
77436
77465
  );
77437
77466
  }
77467
+ captureLatest(res);
77438
77468
  if (!res.ok) {
77439
77469
  const errBody = await res.json().catch(() => ({}));
77440
77470
  if (DEBUG)
@@ -77452,6 +77482,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77452
77482
  Number(errBody.limit ?? 0)
77453
77483
  );
77454
77484
  }
77485
+ throwIfOutdated(res.status, errBody);
77455
77486
  const msg = errBody.detail ? `${errBody.error}: ${errBody.detail}` : String(errBody.error ?? "request failed");
77456
77487
  throw new ApiError(res.status, msg);
77457
77488
  }
@@ -77463,9 +77494,8 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77463
77494
  res = await fetchFn(`${baseUrl}${path2}`, {
77464
77495
  method: "POST",
77465
77496
  headers: {
77466
- "Content-Type": "application/json",
77467
- Accept: "text/event-stream",
77468
- ...token ? { Authorization: `Bearer ${token}` } : {}
77497
+ ...baseHeaders(token),
77498
+ Accept: "text/event-stream"
77469
77499
  },
77470
77500
  body: JSON.stringify(body),
77471
77501
  signal: AbortSignal.timeout(timeoutMs ?? STREAM_TIMEOUT_MS)
@@ -77477,6 +77507,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77477
77507
  err instanceof Error ? err.message : "network error"
77478
77508
  );
77479
77509
  }
77510
+ captureLatest(res);
77480
77511
  if (!res.ok) {
77481
77512
  const errBody = await res.json().catch(() => ({}));
77482
77513
  if (DEBUG)
@@ -77488,6 +77519,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77488
77519
  Number(errBody.limit ?? 0)
77489
77520
  );
77490
77521
  }
77522
+ throwIfOutdated(res.status, errBody);
77491
77523
  const msg = errBody.detail ? `${errBody.error}: ${errBody.detail}` : String(errBody.error ?? "request failed");
77492
77524
  throw new ApiError(res.status, msg);
77493
77525
  }
@@ -77500,7 +77532,10 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch) {
77500
77532
  get(path2, token) {
77501
77533
  return request2("GET", path2, token);
77502
77534
  },
77503
- postStream
77535
+ postStream,
77536
+ getLatestCliVersion() {
77537
+ return latestCliVersion;
77538
+ }
77504
77539
  };
77505
77540
  }
77506
77541
  var apiClient = createApiClient();
@@ -86148,6 +86183,17 @@ async function readRepoConfig(cwd2 = process.cwd()) {
86148
86183
  }
86149
86184
  }
86150
86185
 
86186
+ // src/lib/update-check.ts
86187
+ function getUpdateInfo() {
86188
+ const latest = apiClient.getLatestCliVersion();
86189
+ if (!latest) return void 0;
86190
+ const current = "0.13.1";
86191
+ return { current, latest };
86192
+ }
86193
+
86194
+ // src/lib/update-hint.ts
86195
+ var UPDATE_COMMAND = "npm i -g repomind (ou bun add -g repomind)";
86196
+
86151
86197
  // ../../node_modules/.bun/@inkjs+ui@2.0.0+4d0808a67a30d5ab/node_modules/@inkjs/ui/build/components/badge/badge.js
86152
86198
  var import_react32 = __toESM(require_react(), 1);
86153
86199
 
@@ -89408,7 +89454,13 @@ function CommitApp({
89408
89454
  }
89409
89455
  if (stream.error) {
89410
89456
  const e = stream.errorRaw;
89411
- if (e instanceof PlanLimitError) {
89457
+ if (e instanceof OutdatedCliError) {
89458
+ setErrorMsg(
89459
+ `Sua vers\xE3o do CLI (${e.currentVersion}) \xE9 antiga demais.
89460
+ \u2192 Atualize com: ${UPDATE_COMMAND}`
89461
+ );
89462
+ setPhase("error-api");
89463
+ } else if (e instanceof PlanLimitError) {
89412
89464
  setErrorMsg(
89413
89465
  `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
89414
89466
  \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
@@ -89502,7 +89554,13 @@ ${hookResult.output}` : "";
89502
89554
  setStreamPayload({ path: "/commit/generate", body, token });
89503
89555
  setPhase("streaming");
89504
89556
  } catch (e) {
89505
- if (e instanceof PlanLimitError) {
89557
+ if (e instanceof OutdatedCliError) {
89558
+ setErrorMsg(
89559
+ `Sua vers\xE3o do CLI (${e.currentVersion}) \xE9 antiga demais.
89560
+ \u2192 Atualize com: ${UPDATE_COMMAND}`
89561
+ );
89562
+ setPhase("error-api");
89563
+ } else if (e instanceof PlanLimitError) {
89506
89564
  setErrorMsg(
89507
89565
  `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
89508
89566
  \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
@@ -89833,10 +89891,23 @@ function parseType(msg) {
89833
89891
  const match = msg.match(/^(\w+)(?:\([^)]+\))?!?:\s*(.+)/);
89834
89892
  return { type: match?.[1] ?? "chore", description: match?.[2] ?? msg };
89835
89893
  }
89894
+ function UpdateBanner({ update }) {
89895
+ if (!update) return null;
89896
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { marginTop: 1, paddingLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { color: C.dim, children: [
89897
+ "Nova vers\xE3o dispon\xEDvel: ",
89898
+ update.current,
89899
+ " \u2192 ",
89900
+ update.latest,
89901
+ " \xB7",
89902
+ " ",
89903
+ UPDATE_COMMAND
89904
+ ] }) });
89905
+ }
89836
89906
  function SplitDoneSummary({
89837
89907
  commits,
89838
89908
  durationMs,
89839
- totalFiles
89909
+ totalFiles,
89910
+ updateAvailable
89840
89911
  }) {
89841
89912
  const { exit } = use_app_default();
89842
89913
  (0, import_react65.useEffect)(() => {
@@ -89865,27 +89936,32 @@ function SplitDoneSummary({
89865
89936
  durationMs != null ? ` em ${(durationMs / 1e3).toFixed(1)}s` : "",
89866
89937
  totalFiles != null ? ` \xB7 ${totalFiles} arquivo${totalFiles !== 1 ? "s" : ""}` : ""
89867
89938
  ] })
89868
- ] })
89939
+ ] }),
89940
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UpdateBanner, { update: updateAvailable })
89869
89941
  ] });
89870
89942
  }
89871
89943
  function CommitDoneSummary({
89872
89944
  message,
89873
- durationMs
89945
+ durationMs,
89946
+ updateAvailable
89874
89947
  }) {
89875
89948
  const { exit } = use_app_default();
89876
89949
  (0, import_react65.useEffect)(() => {
89877
89950
  exit();
89878
89951
  }, []);
89879
89952
  const { type, description } = parseType(message);
89880
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { paddingLeft: 1, gap: 1, alignItems: "center", children: [
89881
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: C.green, children: "\u2713" }),
89882
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TypeBadge, { type }),
89883
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: C.green, children: description }),
89884
- durationMs != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { color: C.dim, children: [
89885
- "\xB7 ",
89886
- (durationMs / 1e3).toFixed(1),
89887
- "s"
89888
- ] })
89953
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { flexDirection: "column", children: [
89954
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { paddingLeft: 1, gap: 1, alignItems: "center", children: [
89955
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: C.green, children: "\u2713" }),
89956
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TypeBadge, { type }),
89957
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: C.green, children: description }),
89958
+ durationMs != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { color: C.dim, children: [
89959
+ "\xB7 ",
89960
+ (durationMs / 1e3).toFixed(1),
89961
+ "s"
89962
+ ] })
89963
+ ] }),
89964
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UpdateBanner, { update: updateAvailable })
89889
89965
  ] });
89890
89966
  }
89891
89967
 
@@ -89924,6 +90000,12 @@ async function commitCommand() {
89924
90000
  console.log(`\u2713 ${result.message}`);
89925
90001
  console.log(" Onboarding concluido! Volte ao dashboard.");
89926
90002
  } catch (e) {
90003
+ if (e instanceof OutdatedCliError) {
90004
+ console.error(
90005
+ `\u2717 Sua vers\xE3o do CLI (${e.currentVersion}) \xE9 antiga demais. Atualize: ${UPDATE_COMMAND}`
90006
+ );
90007
+ process.exit(1);
90008
+ }
89927
90009
  const detail = e instanceof Error ? e.message : "";
89928
90010
  console.error(
89929
90011
  `\u2717 Falha ao criar commit demo.${detail ? ` ${detail}` : ""}`
@@ -89971,7 +90053,10 @@ async function commitCommand() {
89971
90053
  }
89972
90054
  if (completedMessage) {
89973
90055
  const { waitUntilExit: waitUntilExit2 } = render_default(
89974
- import_react66.default.createElement(CommitDoneSummary, { message: completedMessage })
90056
+ import_react66.default.createElement(CommitDoneSummary, {
90057
+ message: completedMessage,
90058
+ updateAvailable: getUpdateInfo()
90059
+ })
89975
90060
  );
89976
90061
  await waitUntilExit2();
89977
90062
  }
@@ -90767,7 +90852,13 @@ function PrApp({
90767
90852
  setPrBody(result.body);
90768
90853
  setPhase("result");
90769
90854
  } catch (e) {
90770
- if (e instanceof PlanLimitError) {
90855
+ if (e instanceof OutdatedCliError) {
90856
+ setErrorMsg(
90857
+ `Sua vers\xE3o do CLI (${e.currentVersion}) \xE9 antiga demais.
90858
+ \u2192 Atualize com: ${UPDATE_COMMAND}`
90859
+ );
90860
+ setPhase("error-api");
90861
+ } else if (e instanceof PlanLimitError) {
90771
90862
  setErrorMsg(
90772
90863
  `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
90773
90864
  \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
@@ -91262,7 +91353,13 @@ function SplitApp({
91262
91353
  }
91263
91354
  if (stream.error) {
91264
91355
  const e = stream.errorRaw;
91265
- if (e instanceof PlanLimitError) {
91356
+ if (e instanceof OutdatedCliError) {
91357
+ setErrorMsg(
91358
+ `Sua versao do CLI (${e.currentVersion}) e antiga demais.
91359
+ \u2192 Atualize com: ${UPDATE_COMMAND}`
91360
+ );
91361
+ setPhase("error-api");
91362
+ } else if (e instanceof PlanLimitError) {
91266
91363
  setErrorMsg(
91267
91364
  `Limite do plano atingido (${e.used}/${e.limit} commits este mes)`
91268
91365
  );
@@ -91966,7 +92063,10 @@ async function splitCommand() {
91966
92063
  exitImmersive();
91967
92064
  if (completedCommits.length > 0) {
91968
92065
  const { waitUntilExit: waitUntilExit2 } = render_default(
91969
- import_react77.default.createElement(SplitDoneSummary, { commits: completedCommits })
92066
+ import_react77.default.createElement(SplitDoneSummary, {
92067
+ commits: completedCommits,
92068
+ updateAvailable: getUpdateInfo()
92069
+ })
91970
92070
  );
91971
92071
  await waitUntilExit2();
91972
92072
  }
@@ -92105,6 +92205,7 @@ function CommandHelp({
92105
92205
 
92106
92206
  // src/index.ts
92107
92207
  function getVersion() {
92208
+ if ("0.13.1") return "0.13.1";
92108
92209
  try {
92109
92210
  const require2 = createRequire(import.meta.url);
92110
92211
  const pkg = require2("../package.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repomind",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "AI-powered git commit messages and repository insights",
6
6
  "keywords": [