repomind 0.13.1 → 0.14.0

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 +59 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77407,14 +77407,41 @@ var TokenExpiredError = class extends Error {
77407
77407
  }
77408
77408
  };
77409
77409
  var PlanLimitError = class extends Error {
77410
- constructor(plan, used, limit) {
77411
- super(`Plan limit reached: ${used}/${limit}`);
77412
- this.plan = plan;
77413
- this.used = used;
77414
- this.limit = limit;
77410
+ plan;
77411
+ used;
77412
+ limit;
77413
+ // Codigo de maquina do motivo (no_plan/past_due/canceled/quota_exceeded), quando
77414
+ // a API o envia. Permite UX propria sem fazer parse de string.
77415
+ reason;
77416
+ // Mensagem pronta para exibir. Preferir esta a montar cópia no cliente.
77417
+ displayMessage;
77418
+ action;
77419
+ constructor(info3) {
77420
+ super(`Plan limit reached: ${info3.used}/${info3.limit}`);
77415
77421
  this.name = "PlanLimitError";
77422
+ this.plan = info3.plan;
77423
+ this.used = info3.used;
77424
+ this.limit = info3.limit;
77425
+ this.reason = info3.reason;
77426
+ this.displayMessage = info3.displayMessage;
77427
+ this.action = info3.action;
77416
77428
  }
77417
77429
  };
77430
+ function planLimitErrorFromBody(errBody) {
77431
+ const used = Number(errBody.used ?? 0);
77432
+ const limit = Number(errBody.limit ?? 0);
77433
+ const rawAction = errBody.action;
77434
+ const action = rawAction && typeof rawAction.label === "string" && typeof rawAction.url === "string" ? { label: rawAction.label, url: rawAction.url } : { label: "Fa\xE7a upgrade", url: `${WEB_BASE_URL}/dashboard/plano` };
77435
+ const displayMessage = typeof errBody.message === "string" && errBody.message.length > 0 ? errBody.message : `Limite do plano atingido (${used}/${limit} commits este m\xEAs)`;
77436
+ return new PlanLimitError({
77437
+ plan: String(errBody.plan ?? "unknown"),
77438
+ used,
77439
+ limit,
77440
+ reason: typeof errBody.reason === "string" ? errBody.reason : void 0,
77441
+ displayMessage,
77442
+ action
77443
+ });
77444
+ }
77418
77445
  var OutdatedCliError = class extends Error {
77419
77446
  constructor(currentVersion, minVersion, latestVersion) {
77420
77447
  super(`CLI desatualizado: ${currentVersion} < ${minVersion}`);
@@ -77426,7 +77453,7 @@ var OutdatedCliError = class extends Error {
77426
77453
  };
77427
77454
  var CLI_VERSION_HEADER = "X-RepoMind-CLI-Version";
77428
77455
  var CLI_LATEST_HEADER = "X-RepoMind-CLI-Latest";
77429
- function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch, cliVersion = "0.13.1") {
77456
+ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch, cliVersion = "0.14.0") {
77430
77457
  let latestCliVersion = null;
77431
77458
  function baseHeaders(token) {
77432
77459
  return {
@@ -77476,11 +77503,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch, cliVersio
77476
77503
  throw new TokenExpiredError();
77477
77504
  }
77478
77505
  if (res.status === 402 && errBody.error === "plan_limit_reached") {
77479
- throw new PlanLimitError(
77480
- String(errBody.plan ?? "unknown"),
77481
- Number(errBody.used ?? 0),
77482
- Number(errBody.limit ?? 0)
77483
- );
77506
+ throw planLimitErrorFromBody(errBody);
77484
77507
  }
77485
77508
  throwIfOutdated(res.status, errBody);
77486
77509
  const msg = errBody.detail ? `${errBody.error}: ${errBody.detail}` : String(errBody.error ?? "request failed");
@@ -77513,11 +77536,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL2, fetchFn = fetch, cliVersio
77513
77536
  if (DEBUG)
77514
77537
  console.error(`[api-client] POST ${path2} \u2192 ${res.status}`, errBody);
77515
77538
  if (res.status === 402 && errBody.error === "plan_limit_reached") {
77516
- throw new PlanLimitError(
77517
- String(errBody.plan ?? "unknown"),
77518
- Number(errBody.used ?? 0),
77519
- Number(errBody.limit ?? 0)
77520
- );
77539
+ throw planLimitErrorFromBody(errBody);
77521
77540
  }
77522
77541
  throwIfOutdated(res.status, errBody);
77523
77542
  const msg = errBody.detail ? `${errBody.error}: ${errBody.detail}` : String(errBody.error ?? "request failed");
@@ -86187,7 +86206,7 @@ async function readRepoConfig(cwd2 = process.cwd()) {
86187
86206
  function getUpdateInfo() {
86188
86207
  const latest = apiClient.getLatestCliVersion();
86189
86208
  if (!latest) return void 0;
86190
- const current = "0.13.1";
86209
+ const current = "0.14.0";
86191
86210
  return { current, latest };
86192
86211
  }
86193
86212
 
@@ -88917,6 +88936,14 @@ async function* parseSSEStream(stream) {
88917
88936
  }
88918
88937
 
88919
88938
  // src/hooks/use-pipeline-stream.ts
88939
+ function tryParsePlanLimitBody(message) {
88940
+ try {
88941
+ const parsed = JSON.parse(message);
88942
+ return parsed.error === "plan_limit_reached" ? parsed : null;
88943
+ } catch {
88944
+ return null;
88945
+ }
88946
+ }
88920
88947
  function usePipelineStream(options) {
88921
88948
  const [steps, setSteps] = (0, import_react62.useState)([]);
88922
88949
  const [resultBundle, setResultBundle] = (0, import_react62.useState)(null);
@@ -89057,9 +89084,14 @@ function usePipelineStream(options) {
89057
89084
  (s) => s.status === "active" ? { ...s, status: "error" } : s
89058
89085
  )
89059
89086
  );
89087
+ const planLimitBody = tryParsePlanLimitBody(event.message);
89088
+ const raw = planLimitBody ? planLimitErrorFromBody(planLimitBody) : null;
89060
89089
  setErrorBundle({
89061
89090
  key: currentKey,
89062
- value: { message: event.message, raw: null }
89091
+ value: {
89092
+ message: raw ? raw.displayMessage : event.message,
89093
+ raw
89094
+ }
89063
89095
  });
89064
89096
  setIsStreaming(false);
89065
89097
  }
@@ -89462,8 +89494,8 @@ function CommitApp({
89462
89494
  setPhase("error-api");
89463
89495
  } else if (e instanceof PlanLimitError) {
89464
89496
  setErrorMsg(
89465
- `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
89466
- \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
89497
+ `${e.displayMessage}
89498
+ \u2192 ${terminalLink(e.action.label, e.action.url)}`
89467
89499
  );
89468
89500
  setPhase("error-plan");
89469
89501
  } else if (e instanceof ApiError && e.status === 403) {
@@ -89562,8 +89594,8 @@ ${hookResult.output}` : "";
89562
89594
  setPhase("error-api");
89563
89595
  } else if (e instanceof PlanLimitError) {
89564
89596
  setErrorMsg(
89565
- `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
89566
- \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
89597
+ `${e.displayMessage}
89598
+ \u2192 ${terminalLink(e.action.label, e.action.url)}`
89567
89599
  );
89568
89600
  setPhase("error-plan");
89569
89601
  } else if (e instanceof ApiError && e.status === 403) {
@@ -90860,8 +90892,8 @@ function PrApp({
90860
90892
  setPhase("error-api");
90861
90893
  } else if (e instanceof PlanLimitError) {
90862
90894
  setErrorMsg(
90863
- `Limite do plano atingido (${e.used}/${e.limit} commits este m\xEAs)
90864
- \u2192 ${terminalLink("Fa\xE7a upgrade", `${WEB_BASE_URL}/dashboard/plano`)}`
90895
+ `${e.displayMessage}
90896
+ \u2192 ${terminalLink(e.action.label, e.action.url)}`
90865
90897
  );
90866
90898
  setPhase("error-plan");
90867
90899
  } else if (e instanceof ApiError && e.status === 403) {
@@ -91361,7 +91393,8 @@ function SplitApp({
91361
91393
  setPhase("error-api");
91362
91394
  } else if (e instanceof PlanLimitError) {
91363
91395
  setErrorMsg(
91364
- `Limite do plano atingido (${e.used}/${e.limit} commits este mes)`
91396
+ `${e.displayMessage}
91397
+ \u2192 ${terminalLink(e.action.label, e.action.url)}`
91365
91398
  );
91366
91399
  setPhase("error-plan");
91367
91400
  } else if (e instanceof ApiError && e.status === 403) {
@@ -92205,7 +92238,7 @@ function CommandHelp({
92205
92238
 
92206
92239
  // src/index.ts
92207
92240
  function getVersion() {
92208
- if ("0.13.1") return "0.13.1";
92241
+ if ("0.14.0") return "0.14.0";
92209
92242
  try {
92210
92243
  const require2 = createRequire(import.meta.url);
92211
92244
  const pkg = require2("../package.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repomind",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "description": "AI-powered git commit messages and repository insights",
6
6
  "keywords": [