repomind 0.1.3 → 0.2.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 +1686 -179
  2. package/package.json +4 -11
package/dist/index.js CHANGED
@@ -9638,14 +9638,14 @@ var require_react_reconciler_production = __commonJS({
9638
9638
  }
9639
9639
  var exports2 = {};
9640
9640
  "use strict";
9641
- var React19 = require_react(), Scheduler2 = require_scheduler(), assign = Object.assign, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy");
9641
+ var React20 = require_react(), Scheduler2 = require_scheduler(), assign = Object.assign, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy");
9642
9642
  Symbol.for("react.scope");
9643
9643
  var REACT_ACTIVITY_TYPE = Symbol.for("react.activity");
9644
9644
  Symbol.for("react.legacy_hidden");
9645
9645
  Symbol.for("react.tracing_marker");
9646
9646
  var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel");
9647
9647
  Symbol.for("react.view_transition");
9648
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), isArrayImpl = Array.isArray, ReactSharedInternals = React19.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, rendererVersion = $$$config.rendererVersion, rendererPackageName = $$$config.rendererPackageName, extraDevToolsConfig = $$$config.extraDevToolsConfig, getPublicInstance = $$$config.getPublicInstance, getRootHostContext = $$$config.getRootHostContext, getChildHostContext = $$$config.getChildHostContext, prepareForCommit = $$$config.prepareForCommit, resetAfterCommit = $$$config.resetAfterCommit, createInstance = $$$config.createInstance;
9648
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), isArrayImpl = Array.isArray, ReactSharedInternals = React20.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, rendererVersion = $$$config.rendererVersion, rendererPackageName = $$$config.rendererPackageName, extraDevToolsConfig = $$$config.extraDevToolsConfig, getPublicInstance = $$$config.getPublicInstance, getRootHostContext = $$$config.getRootHostContext, getChildHostContext = $$$config.getChildHostContext, prepareForCommit = $$$config.prepareForCommit, resetAfterCommit = $$$config.resetAfterCommit, createInstance = $$$config.createInstance;
9649
9649
  $$$config.cloneMutableInstance;
9650
9650
  var appendInitialChild = $$$config.appendInitialChild, finalizeInitialChildren = $$$config.finalizeInitialChildren, shouldSetTextContent = $$$config.shouldSetTextContent, createTextInstance = $$$config.createTextInstance;
9651
9651
  $$$config.cloneMutableTextInstance;
@@ -15286,13 +15286,13 @@ var require_react_reconciler_development = __commonJS({
15286
15286
  }
15287
15287
  }
15288
15288
  function dispatchReducerAction(fiber, queue, action) {
15289
- var args = arguments;
15290
- "function" === typeof args[3] && console.error(
15289
+ var args2 = arguments;
15290
+ "function" === typeof args2[3] && console.error(
15291
15291
  "State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect()."
15292
15292
  );
15293
- args = requestUpdateLane(fiber);
15293
+ args2 = requestUpdateLane(fiber);
15294
15294
  var update = {
15295
- lane: args,
15295
+ lane: args2,
15296
15296
  revertLane: 0,
15297
15297
  gesture: null,
15298
15298
  action,
@@ -15300,15 +15300,15 @@ var require_react_reconciler_development = __commonJS({
15300
15300
  eagerState: null,
15301
15301
  next: null
15302
15302
  };
15303
- isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, update) : (update = enqueueConcurrentHookUpdate(fiber, queue, update, args), null !== update && (startUpdateTimerByLane(args, "dispatch()", fiber), scheduleUpdateOnFiber(update, fiber, args), entangleTransitionUpdate(update, queue, args)));
15303
+ isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, update) : (update = enqueueConcurrentHookUpdate(fiber, queue, update, args2), null !== update && (startUpdateTimerByLane(args2, "dispatch()", fiber), scheduleUpdateOnFiber(update, fiber, args2), entangleTransitionUpdate(update, queue, args2)));
15304
15304
  }
15305
15305
  function dispatchSetState(fiber, queue, action) {
15306
- var args = arguments;
15307
- "function" === typeof args[3] && console.error(
15306
+ var args2 = arguments;
15307
+ "function" === typeof args2[3] && console.error(
15308
15308
  "State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect()."
15309
15309
  );
15310
- args = requestUpdateLane(fiber);
15311
- dispatchSetStateInternal(fiber, queue, action, args) && startUpdateTimerByLane(args, "setState()", fiber);
15310
+ args2 = requestUpdateLane(fiber);
15311
+ dispatchSetStateInternal(fiber, queue, action, args2) && startUpdateTimerByLane(args2, "setState()", fiber);
15312
15312
  }
15313
15313
  function dispatchSetStateInternal(fiber, queue, action, lane) {
15314
15314
  var update = {
@@ -22238,14 +22238,14 @@ var require_react_reconciler_development = __commonJS({
22238
22238
  }
22239
22239
  var exports2 = {};
22240
22240
  "use strict";
22241
- var React19 = require_react(), Scheduler2 = require_scheduler(), assign = Object.assign, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy");
22241
+ var React20 = require_react(), Scheduler2 = require_scheduler(), assign = Object.assign, REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy");
22242
22242
  Symbol.for("react.scope");
22243
22243
  var REACT_ACTIVITY_TYPE = Symbol.for("react.activity");
22244
22244
  Symbol.for("react.legacy_hidden");
22245
22245
  Symbol.for("react.tracing_marker");
22246
22246
  var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel");
22247
22247
  Symbol.for("react.view_transition");
22248
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), isArrayImpl = Array.isArray, ReactSharedInternals = React19.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, rendererVersion = $$$config.rendererVersion, rendererPackageName = $$$config.rendererPackageName, extraDevToolsConfig = $$$config.extraDevToolsConfig, getPublicInstance = $$$config.getPublicInstance, getRootHostContext = $$$config.getRootHostContext, getChildHostContext = $$$config.getChildHostContext, prepareForCommit = $$$config.prepareForCommit, resetAfterCommit = $$$config.resetAfterCommit, createInstance = $$$config.createInstance;
22248
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), isArrayImpl = Array.isArray, ReactSharedInternals = React20.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, rendererVersion = $$$config.rendererVersion, rendererPackageName = $$$config.rendererPackageName, extraDevToolsConfig = $$$config.extraDevToolsConfig, getPublicInstance = $$$config.getPublicInstance, getRootHostContext = $$$config.getRootHostContext, getChildHostContext = $$$config.getChildHostContext, prepareForCommit = $$$config.prepareForCommit, resetAfterCommit = $$$config.resetAfterCommit, createInstance = $$$config.createInstance;
22249
22249
  $$$config.cloneMutableInstance;
22250
22250
  var appendInitialChild = $$$config.appendInitialChild, finalizeInitialChildren = $$$config.finalizeInitialChildren, shouldSetTextContent = $$$config.shouldSetTextContent, createTextInstance = $$$config.createTextInstance;
22251
22251
  $$$config.cloneMutableTextInstance;
@@ -24210,9 +24210,9 @@ var require_react_reconciler = __commonJS({
24210
24210
  }
24211
24211
  });
24212
24212
 
24213
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/constants.js
24213
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/constants.js
24214
24214
  var require_constants2 = __commonJS({
24215
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/constants.js"(exports, module) {
24215
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/constants.js"(exports, module) {
24216
24216
  "use strict";
24217
24217
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
24218
24218
  var hasBlob = typeof Blob !== "undefined";
@@ -24233,9 +24233,9 @@ var require_constants2 = __commonJS({
24233
24233
  }
24234
24234
  });
24235
24235
 
24236
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/buffer-util.js
24236
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/buffer-util.js
24237
24237
  var require_buffer_util = __commonJS({
24238
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/buffer-util.js"(exports, module) {
24238
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/buffer-util.js"(exports, module) {
24239
24239
  "use strict";
24240
24240
  var { EMPTY_BUFFER } = require_constants2();
24241
24241
  var FastBuffer = Buffer[Symbol.species];
@@ -24308,9 +24308,9 @@ var require_buffer_util = __commonJS({
24308
24308
  }
24309
24309
  });
24310
24310
 
24311
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/limiter.js
24311
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/limiter.js
24312
24312
  var require_limiter = __commonJS({
24313
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/limiter.js"(exports, module) {
24313
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/limiter.js"(exports, module) {
24314
24314
  "use strict";
24315
24315
  var kDone = Symbol("kDone");
24316
24316
  var kRun = Symbol("kRun");
@@ -24358,9 +24358,9 @@ var require_limiter = __commonJS({
24358
24358
  }
24359
24359
  });
24360
24360
 
24361
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/permessage-deflate.js
24361
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js
24362
24362
  var require_permessage_deflate = __commonJS({
24363
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
24363
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
24364
24364
  "use strict";
24365
24365
  var zlib = __require("zlib");
24366
24366
  var bufferUtil = require_buffer_util();
@@ -24374,7 +24374,7 @@ var require_permessage_deflate = __commonJS({
24374
24374
  var kBuffers = Symbol("buffers");
24375
24375
  var kError = Symbol("error");
24376
24376
  var zlibLimiter;
24377
- var PerMessageDeflate = class {
24377
+ var PerMessageDeflate2 = class {
24378
24378
  /**
24379
24379
  * Creates a PerMessageDeflate instance.
24380
24380
  *
@@ -24385,6 +24385,9 @@ var require_permessage_deflate = __commonJS({
24385
24385
  * acknowledge disabling of client context takeover
24386
24386
  * @param {Number} [options.concurrencyLimit=10] The number of concurrent
24387
24387
  * calls to zlib
24388
+ * @param {Boolean} [options.isServer=false] Create the instance in either
24389
+ * server or client mode
24390
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
24388
24391
  * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
24389
24392
  * use of a custom server window size
24390
24393
  * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
@@ -24395,15 +24398,12 @@ var require_permessage_deflate = __commonJS({
24395
24398
  * deflate
24396
24399
  * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
24397
24400
  * inflate
24398
- * @param {Boolean} [isServer=false] Create the instance in either server or
24399
- * client mode
24400
- * @param {Number} [maxPayload=0] The maximum allowed message length
24401
24401
  */
24402
- constructor(options, isServer, maxPayload) {
24403
- this._maxPayload = maxPayload | 0;
24402
+ constructor(options) {
24404
24403
  this._options = options || {};
24405
24404
  this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
24406
- this._isServer = !!isServer;
24405
+ this._maxPayload = this._options.maxPayload | 0;
24406
+ this._isServer = !!this._options.isServer;
24407
24407
  this._deflate = null;
24408
24408
  this._inflate = null;
24409
24409
  this.params = null;
@@ -24712,7 +24712,7 @@ var require_permessage_deflate = __commonJS({
24712
24712
  });
24713
24713
  }
24714
24714
  };
24715
- module.exports = PerMessageDeflate;
24715
+ module.exports = PerMessageDeflate2;
24716
24716
  function deflateOnData(chunk) {
24717
24717
  this[kBuffers].push(chunk);
24718
24718
  this[kTotalLength] += chunk.length;
@@ -24741,9 +24741,9 @@ var require_permessage_deflate = __commonJS({
24741
24741
  }
24742
24742
  });
24743
24743
 
24744
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/validation.js
24744
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/validation.js
24745
24745
  var require_validation = __commonJS({
24746
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/validation.js"(exports, module) {
24746
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/validation.js"(exports, module) {
24747
24747
  "use strict";
24748
24748
  var { isUtf8 } = __require("buffer");
24749
24749
  var { hasBlob } = require_constants2();
@@ -24942,12 +24942,12 @@ var require_validation = __commonJS({
24942
24942
  }
24943
24943
  });
24944
24944
 
24945
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/receiver.js
24945
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/receiver.js
24946
24946
  var require_receiver = __commonJS({
24947
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/receiver.js"(exports, module) {
24947
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/receiver.js"(exports, module) {
24948
24948
  "use strict";
24949
24949
  var { Writable } = __require("stream");
24950
- var PerMessageDeflate = require_permessage_deflate();
24950
+ var PerMessageDeflate2 = require_permessage_deflate();
24951
24951
  var {
24952
24952
  BINARY_TYPES,
24953
24953
  EMPTY_BUFFER,
@@ -25114,7 +25114,7 @@ var require_receiver = __commonJS({
25114
25114
  return;
25115
25115
  }
25116
25116
  const compressed = (buf[0] & 64) === 64;
25117
- if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
25117
+ if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
25118
25118
  const error = this.createError(
25119
25119
  RangeError,
25120
25120
  "RSV1 must be clear",
@@ -25358,7 +25358,7 @@ var require_receiver = __commonJS({
25358
25358
  * @private
25359
25359
  */
25360
25360
  decompress(data, cb) {
25361
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
25361
+ const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
25362
25362
  perMessageDeflate.decompress(data, this._fin, (err, buf) => {
25363
25363
  if (err) return cb(err);
25364
25364
  if (buf.length) {
@@ -25534,13 +25534,13 @@ var require_receiver = __commonJS({
25534
25534
  }
25535
25535
  });
25536
25536
 
25537
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/sender.js
25537
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/sender.js
25538
25538
  var require_sender = __commonJS({
25539
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/sender.js"(exports, module) {
25539
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/sender.js"(exports, module) {
25540
25540
  "use strict";
25541
25541
  var { Duplex } = __require("stream");
25542
25542
  var { randomFillSync } = __require("crypto");
25543
- var PerMessageDeflate = require_permessage_deflate();
25543
+ var PerMessageDeflate2 = require_permessage_deflate();
25544
25544
  var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants2();
25545
25545
  var { isBlob, isValidStatusCode } = require_validation();
25546
25546
  var { mask: applyMask, toBuffer } = require_buffer_util();
@@ -25824,7 +25824,7 @@ var require_sender = __commonJS({
25824
25824
  * @public
25825
25825
  */
25826
25826
  send(data, options, cb) {
25827
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
25827
+ const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
25828
25828
  let opcode = options.binary ? 2 : 1;
25829
25829
  let rsv1 = options.compress;
25830
25830
  let byteLength;
@@ -25948,7 +25948,7 @@ var require_sender = __commonJS({
25948
25948
  this.sendFrame(_Sender.frame(data, options), cb);
25949
25949
  return;
25950
25950
  }
25951
- const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
25951
+ const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
25952
25952
  this._bufferedBytes += options[kByteLength];
25953
25953
  this._state = DEFLATING;
25954
25954
  perMessageDeflate.compress(data, options.fin, (_, buf) => {
@@ -26022,9 +26022,9 @@ var require_sender = __commonJS({
26022
26022
  }
26023
26023
  });
26024
26024
 
26025
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/event-target.js
26025
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/event-target.js
26026
26026
  var require_event_target = __commonJS({
26027
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/event-target.js"(exports, module) {
26027
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/event-target.js"(exports, module) {
26028
26028
  "use strict";
26029
26029
  var { kForOnEventAttribute, kListener } = require_constants2();
26030
26030
  var kCode = Symbol("kCode");
@@ -26251,9 +26251,9 @@ var require_event_target = __commonJS({
26251
26251
  }
26252
26252
  });
26253
26253
 
26254
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/extension.js
26254
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/extension.js
26255
26255
  var require_extension = __commonJS({
26256
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/extension.js"(exports, module) {
26256
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/extension.js"(exports, module) {
26257
26257
  "use strict";
26258
26258
  var { tokenChars } = require_validation();
26259
26259
  function push(dest, name, elem) {
@@ -26386,11 +26386,11 @@ var require_extension = __commonJS({
26386
26386
  return offers;
26387
26387
  }
26388
26388
  function format(extensions) {
26389
- return Object.keys(extensions).map((extension) => {
26390
- let configurations = extensions[extension];
26389
+ return Object.keys(extensions).map((extension2) => {
26390
+ let configurations = extensions[extension2];
26391
26391
  if (!Array.isArray(configurations)) configurations = [configurations];
26392
26392
  return configurations.map((params) => {
26393
- return [extension].concat(
26393
+ return [extension2].concat(
26394
26394
  Object.keys(params).map((k) => {
26395
26395
  let values = params[k];
26396
26396
  if (!Array.isArray(values)) values = [values];
@@ -26404,9 +26404,9 @@ var require_extension = __commonJS({
26404
26404
  }
26405
26405
  });
26406
26406
 
26407
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/websocket.js
26407
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/websocket.js
26408
26408
  var require_websocket = __commonJS({
26409
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/websocket.js"(exports, module) {
26409
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/websocket.js"(exports, module) {
26410
26410
  "use strict";
26411
26411
  var EventEmitter3 = __require("events");
26412
26412
  var https = __require("https");
@@ -26416,7 +26416,7 @@ var require_websocket = __commonJS({
26416
26416
  var { randomBytes, createHash } = __require("crypto");
26417
26417
  var { Duplex, Readable } = __require("stream");
26418
26418
  var { URL: URL2 } = __require("url");
26419
- var PerMessageDeflate = require_permessage_deflate();
26419
+ var PerMessageDeflate2 = require_permessage_deflate();
26420
26420
  var Receiver2 = require_receiver();
26421
26421
  var Sender2 = require_sender();
26422
26422
  var { isBlob } = require_validation();
@@ -26624,8 +26624,8 @@ var require_websocket = __commonJS({
26624
26624
  this.emit("close", this._closeCode, this._closeMessage);
26625
26625
  return;
26626
26626
  }
26627
- if (this._extensions[PerMessageDeflate.extensionName]) {
26628
- this._extensions[PerMessageDeflate.extensionName].cleanup();
26627
+ if (this._extensions[PerMessageDeflate2.extensionName]) {
26628
+ this._extensions[PerMessageDeflate2.extensionName].cleanup();
26629
26629
  }
26630
26630
  this._receiver.removeAllListeners();
26631
26631
  this._readyState = _WebSocket.CLOSED;
@@ -26787,7 +26787,7 @@ var require_websocket = __commonJS({
26787
26787
  fin: true,
26788
26788
  ...options
26789
26789
  };
26790
- if (!this._extensions[PerMessageDeflate.extensionName]) {
26790
+ if (!this._extensions[PerMessageDeflate2.extensionName]) {
26791
26791
  opts.compress = false;
26792
26792
  }
26793
26793
  this._sender.send(data || EMPTY_BUFFER, opts, cb);
@@ -26913,7 +26913,7 @@ var require_websocket = __commonJS({
26913
26913
  } else {
26914
26914
  try {
26915
26915
  parsedUrl = new URL2(address);
26916
- } catch (e) {
26916
+ } catch {
26917
26917
  throw new SyntaxError(`Invalid URL: ${address}`);
26918
26918
  }
26919
26919
  }
@@ -26961,13 +26961,13 @@ var require_websocket = __commonJS({
26961
26961
  opts.path = parsedUrl.pathname + parsedUrl.search;
26962
26962
  opts.timeout = opts.handshakeTimeout;
26963
26963
  if (opts.perMessageDeflate) {
26964
- perMessageDeflate = new PerMessageDeflate(
26965
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
26966
- false,
26967
- opts.maxPayload
26968
- );
26964
+ perMessageDeflate = new PerMessageDeflate2({
26965
+ ...opts.perMessageDeflate,
26966
+ isServer: false,
26967
+ maxPayload: opts.maxPayload
26968
+ });
26969
26969
  opts.headers["Sec-WebSocket-Extensions"] = format({
26970
- [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
26970
+ [PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
26971
26971
  });
26972
26972
  }
26973
26973
  if (protocols.length) {
@@ -27110,19 +27110,19 @@ var require_websocket = __commonJS({
27110
27110
  return;
27111
27111
  }
27112
27112
  const extensionNames = Object.keys(extensions);
27113
- if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
27113
+ if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
27114
27114
  const message = "Server indicated an extension that was not requested";
27115
27115
  abortHandshake(websocket, socket, message);
27116
27116
  return;
27117
27117
  }
27118
27118
  try {
27119
- perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
27119
+ perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
27120
27120
  } catch (err) {
27121
27121
  const message = "Invalid Sec-WebSocket-Extensions header";
27122
27122
  abortHandshake(websocket, socket, message);
27123
27123
  return;
27124
27124
  }
27125
- websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
27125
+ websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
27126
27126
  }
27127
27127
  websocket.setSocket(socket, head, {
27128
27128
  allowSynchronousEvents: opts.allowSynchronousEvents,
@@ -27290,9 +27290,9 @@ var require_websocket = __commonJS({
27290
27290
  }
27291
27291
  });
27292
27292
 
27293
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/stream.js
27293
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/stream.js
27294
27294
  var require_stream = __commonJS({
27295
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/stream.js"(exports, module) {
27295
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/stream.js"(exports, module) {
27296
27296
  "use strict";
27297
27297
  var WebSocket2 = require_websocket();
27298
27298
  var { Duplex } = __require("stream");
@@ -27388,9 +27388,9 @@ var require_stream = __commonJS({
27388
27388
  }
27389
27389
  });
27390
27390
 
27391
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/subprotocol.js
27391
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/subprotocol.js
27392
27392
  var require_subprotocol = __commonJS({
27393
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
27393
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
27394
27394
  "use strict";
27395
27395
  var { tokenChars } = require_validation();
27396
27396
  function parse(header) {
@@ -27433,17 +27433,17 @@ var require_subprotocol = __commonJS({
27433
27433
  }
27434
27434
  });
27435
27435
 
27436
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/websocket-server.js
27436
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/websocket-server.js
27437
27437
  var require_websocket_server = __commonJS({
27438
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
27438
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
27439
27439
  "use strict";
27440
27440
  var EventEmitter3 = __require("events");
27441
27441
  var http = __require("http");
27442
27442
  var { Duplex } = __require("stream");
27443
27443
  var { createHash } = __require("crypto");
27444
- var extension = require_extension();
27445
- var PerMessageDeflate = require_permessage_deflate();
27446
- var subprotocol = require_subprotocol();
27444
+ var extension2 = require_extension();
27445
+ var PerMessageDeflate2 = require_permessage_deflate();
27446
+ var subprotocol2 = require_subprotocol();
27447
27447
  var WebSocket2 = require_websocket();
27448
27448
  var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants2();
27449
27449
  var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
@@ -27666,7 +27666,7 @@ var require_websocket_server = __commonJS({
27666
27666
  let protocols = /* @__PURE__ */ new Set();
27667
27667
  if (secWebSocketProtocol !== void 0) {
27668
27668
  try {
27669
- protocols = subprotocol.parse(secWebSocketProtocol);
27669
+ protocols = subprotocol2.parse(secWebSocketProtocol);
27670
27670
  } catch (err) {
27671
27671
  const message = "Invalid Sec-WebSocket-Protocol header";
27672
27672
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
@@ -27676,16 +27676,16 @@ var require_websocket_server = __commonJS({
27676
27676
  const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
27677
27677
  const extensions = {};
27678
27678
  if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
27679
- const perMessageDeflate = new PerMessageDeflate(
27680
- this.options.perMessageDeflate,
27681
- true,
27682
- this.options.maxPayload
27683
- );
27679
+ const perMessageDeflate = new PerMessageDeflate2({
27680
+ ...this.options.perMessageDeflate,
27681
+ isServer: true,
27682
+ maxPayload: this.options.maxPayload
27683
+ });
27684
27684
  try {
27685
- const offers = extension.parse(secWebSocketExtensions);
27686
- if (offers[PerMessageDeflate.extensionName]) {
27687
- perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
27688
- extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
27685
+ const offers = extension2.parse(secWebSocketExtensions);
27686
+ if (offers[PerMessageDeflate2.extensionName]) {
27687
+ perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
27688
+ extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
27689
27689
  }
27690
27690
  } catch (err) {
27691
27691
  const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
@@ -27756,10 +27756,10 @@ var require_websocket_server = __commonJS({
27756
27756
  ws._protocol = protocol;
27757
27757
  }
27758
27758
  }
27759
- if (extensions[PerMessageDeflate.extensionName]) {
27760
- const params = extensions[PerMessageDeflate.extensionName].params;
27761
- const value = extension.format({
27762
- [PerMessageDeflate.extensionName]: [params]
27759
+ if (extensions[PerMessageDeflate2.extensionName]) {
27760
+ const params = extensions[PerMessageDeflate2.extensionName].params;
27761
+ const value = extension2.format({
27762
+ [PerMessageDeflate2.extensionName]: [params]
27763
27763
  });
27764
27764
  headers.push(`Sec-WebSocket-Extensions: ${value}`);
27765
27765
  ws._extensions = extensions;
@@ -27826,13 +27826,16 @@ var require_websocket_server = __commonJS({
27826
27826
  }
27827
27827
  });
27828
27828
 
27829
- // ../../node_modules/.bun/ws@8.19.0/node_modules/ws/wrapper.mjs
27830
- var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
27829
+ // ../../node_modules/.bun/ws@8.20.0/node_modules/ws/wrapper.mjs
27830
+ var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
27831
27831
  var init_wrapper = __esm({
27832
- "../../node_modules/.bun/ws@8.19.0/node_modules/ws/wrapper.mjs"() {
27832
+ "../../node_modules/.bun/ws@8.20.0/node_modules/ws/wrapper.mjs"() {
27833
27833
  import_stream = __toESM(require_stream(), 1);
27834
+ import_extension = __toESM(require_extension(), 1);
27835
+ import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
27834
27836
  import_receiver = __toESM(require_receiver(), 1);
27835
27837
  import_sender = __toESM(require_sender(), 1);
27838
+ import_subprotocol = __toESM(require_subprotocol(), 1);
27836
27839
  import_websocket = __toESM(require_websocket(), 1);
27837
27840
  import_websocket_server = __toESM(require_websocket_server(), 1);
27838
27841
  wrapper_default = import_websocket.default;
@@ -30231,18 +30234,18 @@ var require_react_jsx_runtime_development = __commonJS({
30231
30234
  function isValidElement(object) {
30232
30235
  return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
30233
30236
  }
30234
- var React19 = require_react(), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React19.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
30237
+ var React20 = require_react(), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React20.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
30235
30238
  return null;
30236
30239
  };
30237
- React19 = {
30240
+ React20 = {
30238
30241
  react_stack_bottom_frame: function(callStackForError) {
30239
30242
  return callStackForError();
30240
30243
  }
30241
30244
  };
30242
30245
  var specialPropKeyWarningShown;
30243
30246
  var didWarnAboutElementRef = {};
30244
- var unknownOwnerDebugStack = React19.react_stack_bottom_frame.bind(
30245
- React19,
30247
+ var unknownOwnerDebugStack = React20.react_stack_bottom_frame.bind(
30248
+ React20,
30246
30249
  UnknownOwner
30247
30250
  )();
30248
30251
  var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
@@ -30337,12 +30340,12 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
30337
30340
  const flush = () => {
30338
30341
  invoke();
30339
30342
  };
30340
- const debounced = function(...args) {
30343
+ const debounced = function(...args2) {
30341
30344
  if (signal?.aborted) {
30342
30345
  return;
30343
30346
  }
30344
30347
  pendingThis = this;
30345
- pendingArgs = args;
30348
+ pendingArgs = args2;
30346
30349
  const isFirstCall = timeoutId == null;
30347
30350
  schedule();
30348
30351
  if (leading && isFirstCall) {
@@ -30371,24 +30374,24 @@ function debounce2(func, debounceMs = 0, options = {}) {
30371
30374
  }
30372
30375
  let result = void 0;
30373
30376
  let pendingAt = null;
30374
- const _debounced = debounce(function(...args) {
30375
- result = func.apply(this, args);
30377
+ const _debounced = debounce(function(...args2) {
30378
+ result = func.apply(this, args2);
30376
30379
  pendingAt = null;
30377
30380
  }, debounceMs, { edges });
30378
- const debounced = function(...args) {
30381
+ const debounced = function(...args2) {
30379
30382
  if (maxWait != null) {
30380
30383
  if (pendingAt === null) {
30381
30384
  pendingAt = Date.now();
30382
30385
  }
30383
30386
  if (Date.now() - pendingAt >= maxWait) {
30384
- result = func.apply(this, args);
30387
+ result = func.apply(this, args2);
30385
30388
  pendingAt = Date.now();
30386
30389
  _debounced.cancel();
30387
30390
  _debounced.schedule();
30388
30391
  return result;
30389
30392
  }
30390
30393
  }
30391
- _debounced.apply(this, args);
30394
+ _debounced.apply(this, args2);
30392
30395
  return result;
30393
30396
  };
30394
30397
  const flush = () => {
@@ -32142,10 +32145,10 @@ function wrapAssembly(lib) {
32142
32145
  function patch(prototype, name, fn) {
32143
32146
  const original = prototype[name];
32144
32147
  prototype[name] = function() {
32145
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32146
- args[_key] = arguments[_key];
32148
+ for (var _len = arguments.length, args2 = new Array(_len), _key = 0; _key < _len; _key++) {
32149
+ args2[_key] = arguments[_key];
32147
32150
  }
32148
- return fn.call(this, original, ...args);
32151
+ return fn.call(this, original, ...args2);
32149
32152
  };
32150
32153
  }
32151
32154
  for (const fnName of ["setPosition", "setMargin", "setFlexBasis", "setWidth", "setHeight", "setMinWidth", "setMinHeight", "setMaxWidth", "setMaxHeight", "setPadding", "setGap"]) {
@@ -32155,10 +32158,10 @@ function wrapAssembly(lib) {
32155
32158
  [Unit.Auto]: lib.Node.prototype[`${fnName}Auto`]
32156
32159
  };
32157
32160
  patch(lib.Node.prototype, fnName, function(original) {
32158
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
32159
- args[_key2 - 1] = arguments[_key2];
32161
+ for (var _len2 = arguments.length, args2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
32162
+ args2[_key2 - 1] = arguments[_key2];
32160
32163
  }
32161
- const value = args.pop();
32164
+ const value = args2.pop();
32162
32165
  let unit, asNumber;
32163
32166
  if (value === "auto") {
32164
32167
  unit = Unit.Auto;
@@ -32175,9 +32178,9 @@ function wrapAssembly(lib) {
32175
32178
  }
32176
32179
  if (!methods[unit]) throw new Error(`Failed to execute "${fnName}": Unsupported unit '${value}'`);
32177
32180
  if (asNumber !== void 0) {
32178
- return methods[unit].call(this, ...args, asNumber);
32181
+ return methods[unit].call(this, ...args2, asNumber);
32179
32182
  } else {
32180
- return methods[unit].call(this, ...args);
32183
+ return methods[unit].call(this, ...args2);
32181
32184
  }
32182
32185
  });
32183
32186
  }
@@ -38469,6 +38472,7 @@ var import_react30 = __toESM(require_react(), 1);
38469
38472
  // src/lib/api-client.ts
38470
38473
  var FETCH_TIMEOUT_MS = 3e4;
38471
38474
  var DEFAULT_BASE_URL = process.env.REPOMIND_API_URL ?? "https://api.repomind.dev";
38475
+ var DEBUG = process.argv.includes("--verbose") || process.argv.includes("-v") || !!process.env.REPOMIND_DEBUG;
38472
38476
  var ApiError = class extends Error {
38473
38477
  constructor(status, message) {
38474
38478
  super(message);
@@ -38499,6 +38503,7 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL, fetchFn = fetch) {
38499
38503
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
38500
38504
  });
38501
38505
  } catch (err) {
38506
+ if (DEBUG) console.error("[api-client] network error:", err);
38502
38507
  throw new ApiError(
38503
38508
  0,
38504
38509
  err instanceof Error ? err.message : "network error"
@@ -38506,6 +38511,11 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL, fetchFn = fetch) {
38506
38511
  }
38507
38512
  if (!res.ok) {
38508
38513
  const errBody = await res.json().catch(() => ({}));
38514
+ if (DEBUG)
38515
+ console.error(
38516
+ `[api-client] ${method} ${path} \u2192 ${res.status}`,
38517
+ errBody
38518
+ );
38509
38519
  if (res.status === 402 && errBody.error === "plan_limit_reached") {
38510
38520
  throw new PlanLimitError(
38511
38521
  String(errBody.plan ?? "free"),
@@ -38513,7 +38523,8 @@ function createApiClient(baseUrl = DEFAULT_BASE_URL, fetchFn = fetch) {
38513
38523
  Number(errBody.limit ?? 0)
38514
38524
  );
38515
38525
  }
38516
- throw new ApiError(res.status, String(errBody.error ?? "request failed"));
38526
+ const msg = errBody.detail ? `${errBody.error}: ${errBody.detail}` : String(errBody.error ?? "request failed");
38527
+ throw new ApiError(res.status, msg);
38517
38528
  }
38518
38529
  return res.json();
38519
38530
  }
@@ -38599,6 +38610,56 @@ async function getDefaultBranch() {
38599
38610
  return (await new Response(proc.stdout).text()).trim() || "main";
38600
38611
  }
38601
38612
  var MAX_FILE_BYTES = 900 * 1024;
38613
+ var SKIP_EXTENSIONS = /* @__PURE__ */ new Set([
38614
+ ".lcov",
38615
+ ".tmp",
38616
+ ".lock",
38617
+ ".map",
38618
+ ".svg",
38619
+ ".png",
38620
+ ".jpg",
38621
+ ".jpeg",
38622
+ ".gif",
38623
+ ".ico",
38624
+ ".woff",
38625
+ ".woff2",
38626
+ ".ttf",
38627
+ ".eot",
38628
+ ".min.js",
38629
+ ".min.css",
38630
+ ".d.ts",
38631
+ ".snap",
38632
+ ".patch"
38633
+ ]);
38634
+ var SKIP_DIRS = [
38635
+ "node_modules/",
38636
+ "vendor/",
38637
+ ".next/",
38638
+ "build/",
38639
+ "__pycache__/",
38640
+ ".turbo/",
38641
+ "coverage/",
38642
+ "dist/",
38643
+ ".firebase/"
38644
+ ];
38645
+ var SKIP_FILES = /* @__PURE__ */ new Set([
38646
+ "package-lock.json",
38647
+ "yarn.lock",
38648
+ "bun.lockb",
38649
+ "pnpm-lock.yaml"
38650
+ ]);
38651
+ function shouldIncludeFile(path) {
38652
+ const lower = path.toLowerCase();
38653
+ for (const ext of SKIP_EXTENSIONS) {
38654
+ if (lower.endsWith(ext)) return false;
38655
+ }
38656
+ for (const dir of SKIP_DIRS) {
38657
+ if (lower.startsWith(dir)) return false;
38658
+ }
38659
+ const fileName = lower.split("/").pop() ?? "";
38660
+ if (SKIP_FILES.has(fileName)) return false;
38661
+ return true;
38662
+ }
38602
38663
  async function readFilesWithContents(paths) {
38603
38664
  const rootProc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
38604
38665
  stdout: "pipe",
@@ -38614,9 +38675,12 @@ async function readFilesWithContents(paths) {
38614
38675
  if (Buffer.byteLength(content, "utf8") > MAX_FILE_BYTES) {
38615
38676
  content = Buffer.from(content, "utf8").slice(0, MAX_FILE_BYTES).toString("utf8");
38616
38677
  }
38617
- return { path, content };
38678
+ const hasher = new Bun.CryptoHasher("sha256");
38679
+ hasher.update(content);
38680
+ const contentHash = hasher.digest("hex");
38681
+ return { path, content, contentHash };
38618
38682
  } catch {
38619
- return { path, content: "" };
38683
+ return { path, content: "", contentHash: "" };
38620
38684
  }
38621
38685
  })
38622
38686
  );
@@ -38707,7 +38771,9 @@ function AnalyzeApp({ onExit }) {
38707
38771
  setPhase("error-no-repo");
38708
38772
  return;
38709
38773
  }
38710
- let paths = await getTrackedFiles().catch(() => []);
38774
+ let paths = (await getTrackedFiles().catch(() => [])).filter(
38775
+ shouldIncludeFile
38776
+ );
38711
38777
  if (paths.length > MAX_FILES) paths = paths.slice(0, MAX_FILES);
38712
38778
  setFileCount(paths.length);
38713
38779
  setPhase("scheduling");
@@ -38845,6 +38911,77 @@ function parseNumstat(line) {
38845
38911
  deletions: delStr === "-" ? 0 : Number.parseInt(delStr, 10)
38846
38912
  };
38847
38913
  }
38914
+ var HUNK_HEADER_RE = /^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@\s*(.*)/;
38915
+ function parseHunks(patch) {
38916
+ if (!patch.trim()) return [];
38917
+ const hunks = [];
38918
+ const lines = patch.split("\n");
38919
+ let currentHunk = null;
38920
+ let hunkIndex = 0;
38921
+ let oldLineNo = 0;
38922
+ let newLineNo = 0;
38923
+ let hunkLines = [];
38924
+ for (const line of lines) {
38925
+ const headerMatch = line.match(HUNK_HEADER_RE);
38926
+ if (headerMatch) {
38927
+ if (currentHunk) {
38928
+ currentHunk.content = hunkLines.join("\n");
38929
+ hunks.push(currentHunk);
38930
+ }
38931
+ const startLineOld = Number.parseInt(headerMatch[1], 10);
38932
+ const countOld = headerMatch[2] !== void 0 ? Number.parseInt(headerMatch[2], 10) : 1;
38933
+ const startLineNew = Number.parseInt(headerMatch[3], 10);
38934
+ const countNew = headerMatch[4] !== void 0 ? Number.parseInt(headerMatch[4], 10) : 1;
38935
+ const contextFunction = headerMatch[5] || void 0;
38936
+ oldLineNo = startLineOld;
38937
+ newLineNo = startLineNew;
38938
+ currentHunk = {
38939
+ index: hunkIndex++,
38940
+ header: line,
38941
+ startLineOld,
38942
+ countOld,
38943
+ startLineNew,
38944
+ countNew,
38945
+ contextFunction,
38946
+ lines: [],
38947
+ content: ""
38948
+ };
38949
+ hunkLines = [line];
38950
+ continue;
38951
+ }
38952
+ if (!currentHunk) continue;
38953
+ hunkLines.push(line);
38954
+ if (line.startsWith("+")) {
38955
+ currentHunk.lines.push({
38956
+ type: "addition",
38957
+ content: line.slice(1),
38958
+ newLineNo
38959
+ });
38960
+ newLineNo++;
38961
+ } else if (line.startsWith("-")) {
38962
+ currentHunk.lines.push({
38963
+ type: "deletion",
38964
+ content: line.slice(1),
38965
+ oldLineNo
38966
+ });
38967
+ oldLineNo++;
38968
+ } else if (line.startsWith(" ") || line === "" && currentHunk) {
38969
+ currentHunk.lines.push({
38970
+ type: "context",
38971
+ content: line.startsWith(" ") ? line.slice(1) : line,
38972
+ oldLineNo,
38973
+ newLineNo
38974
+ });
38975
+ oldLineNo++;
38976
+ newLineNo++;
38977
+ }
38978
+ }
38979
+ if (currentHunk) {
38980
+ currentHunk.content = hunkLines.join("\n");
38981
+ hunks.push(currentHunk);
38982
+ }
38983
+ return hunks;
38984
+ }
38848
38985
  function extractFilePatches(rawDiff) {
38849
38986
  const result = /* @__PURE__ */ new Map();
38850
38987
  if (!rawDiff.trim()) return result;
@@ -38862,9 +38999,48 @@ function extractFilePatches(rawDiff) {
38862
38999
  return result;
38863
39000
  }
38864
39001
 
39002
+ // ../../packages/git/src/manifest.ts
39003
+ function buildSplitManifest(files, hunksMap) {
39004
+ let totalAdditions = 0;
39005
+ let totalDeletions = 0;
39006
+ const splitFiles = files.map((file) => {
39007
+ const hunks = hunksMap.get(file.path) ?? [];
39008
+ const hunkSummaries = hunks.map((hunk) => {
39009
+ let additions = 0;
39010
+ let deletions = 0;
39011
+ for (const line of hunk.lines) {
39012
+ if (line.type === "addition") additions++;
39013
+ else if (line.type === "deletion") deletions++;
39014
+ }
39015
+ return {
39016
+ index: hunk.index,
39017
+ header: hunk.header,
39018
+ additions,
39019
+ deletions,
39020
+ lines: hunk.lines
39021
+ };
39022
+ });
39023
+ totalAdditions += file.additions;
39024
+ totalDeletions += file.deletions;
39025
+ return {
39026
+ path: file.path,
39027
+ status: file.status,
39028
+ additions: file.additions,
39029
+ deletions: file.deletions,
39030
+ isBinary: file.isBinary,
39031
+ hunks: hunkSummaries
39032
+ };
39033
+ });
39034
+ return {
39035
+ files: splitFiles,
39036
+ totalAdditions,
39037
+ totalDeletions
39038
+ };
39039
+ }
39040
+
38865
39041
  // ../../packages/git/src/process.ts
38866
- async function runGit(args) {
38867
- const proc = Bun.spawn(["git", ...args], {
39042
+ async function runGit(args2) {
39043
+ const proc = Bun.spawn(["git", ...args2], {
38868
39044
  stdout: "pipe",
38869
39045
  stderr: "pipe"
38870
39046
  });
@@ -38885,7 +39061,358 @@ async function runGit(args) {
38885
39061
  return stdout;
38886
39062
  }
38887
39063
 
39064
+ // ../../node_modules/.bun/git-patch@0.1.4/node_modules/git-patch/lib/diff-parser.js
39065
+ var hunkIdCounter = 0;
39066
+ function resetHunkIds() {
39067
+ hunkIdCounter = 0;
39068
+ }
39069
+ function nextHunkId() {
39070
+ return ++hunkIdCounter;
39071
+ }
39072
+ function parseHunkHeader(line) {
39073
+ let match = line.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/);
39074
+ if (!match) return null;
39075
+ return {
39076
+ oldStart: parseInt(match[1], 10),
39077
+ oldCount: match[2] != null ? parseInt(match[2], 10) : 1,
39078
+ newStart: parseInt(match[3], 10),
39079
+ newCount: match[4] != null ? parseInt(match[4], 10) : 1,
39080
+ context: match[5].trim() || null,
39081
+ raw: line
39082
+ };
39083
+ }
39084
+ function classifyLine(raw) {
39085
+ if (raw.startsWith("+")) return "added";
39086
+ if (raw.startsWith("-")) return "removed";
39087
+ if (raw.startsWith("\\")) return "no-newline";
39088
+ return "context";
39089
+ }
39090
+ function parseFileDiff(chunk) {
39091
+ let lines = chunk.split("\n");
39092
+ let file = null;
39093
+ let diffOldFile = null;
39094
+ let diffNewFile = null;
39095
+ let oldFile = null;
39096
+ let newFile = null;
39097
+ let metadataLines = [];
39098
+ let hunks = [];
39099
+ let i = 0;
39100
+ while (i < lines.length) {
39101
+ let line = lines[i];
39102
+ if (line.startsWith("diff --git")) {
39103
+ let match = line.match(/^diff --git a\/(.+) b\/(.+)$/);
39104
+ if (match) {
39105
+ diffOldFile = `a/${match[1]}`;
39106
+ diffNewFile = `b/${match[2]}`;
39107
+ oldFile = diffOldFile;
39108
+ newFile = diffNewFile;
39109
+ file = match[2];
39110
+ }
39111
+ i++;
39112
+ continue;
39113
+ }
39114
+ if (line.startsWith("index ") || line.startsWith("old mode") || line.startsWith("new mode") || line.startsWith("new file") || line.startsWith("deleted file") || line.startsWith("similarity index") || line.startsWith("rename from") || line.startsWith("rename to") || line.startsWith("copy from") || line.startsWith("copy to") || line.startsWith("Binary files")) {
39115
+ metadataLines.push(line);
39116
+ i++;
39117
+ continue;
39118
+ }
39119
+ if (line.startsWith("--- ")) {
39120
+ oldFile = line.slice(4);
39121
+ i++;
39122
+ continue;
39123
+ }
39124
+ if (line.startsWith("+++ ")) {
39125
+ newFile = line.slice(4);
39126
+ if (newFile.startsWith("b/")) {
39127
+ file = newFile.slice(2);
39128
+ }
39129
+ i++;
39130
+ continue;
39131
+ }
39132
+ if (line.startsWith("@@")) {
39133
+ break;
39134
+ }
39135
+ i++;
39136
+ }
39137
+ while (i < lines.length) {
39138
+ let line = lines[i];
39139
+ if (!line.startsWith("@@")) {
39140
+ i++;
39141
+ continue;
39142
+ }
39143
+ let header = parseHunkHeader(line);
39144
+ if (!header) {
39145
+ i++;
39146
+ continue;
39147
+ }
39148
+ let hunkLines = [];
39149
+ let oldLine = header.oldStart;
39150
+ let newLine = header.newStart;
39151
+ let addedCount = 0;
39152
+ let removedCount = 0;
39153
+ i++;
39154
+ while (i < lines.length && !lines[i].startsWith("@@")) {
39155
+ let raw = lines[i];
39156
+ if (raw === "" && i === lines.length - 1) {
39157
+ i++;
39158
+ continue;
39159
+ }
39160
+ let type = classifyLine(raw);
39161
+ if (type === "no-newline") {
39162
+ hunkLines.push({ type, content: raw, oldLine: null, newLine: null });
39163
+ i++;
39164
+ continue;
39165
+ }
39166
+ let entry = {
39167
+ type,
39168
+ content: raw,
39169
+ oldLine: null,
39170
+ newLine: null
39171
+ };
39172
+ if (type === "context") {
39173
+ entry.oldLine = oldLine++;
39174
+ entry.newLine = newLine++;
39175
+ } else if (type === "removed") {
39176
+ entry.oldLine = oldLine++;
39177
+ removedCount++;
39178
+ } else if (type === "added") {
39179
+ entry.newLine = newLine++;
39180
+ addedCount++;
39181
+ }
39182
+ hunkLines.push(entry);
39183
+ i++;
39184
+ }
39185
+ hunks.push({
39186
+ id: nextHunkId(),
39187
+ header: header.raw,
39188
+ oldStart: header.oldStart,
39189
+ oldCount: header.oldCount,
39190
+ newStart: header.newStart,
39191
+ newCount: header.newCount,
39192
+ context: header.context,
39193
+ lines: hunkLines,
39194
+ addedCount,
39195
+ removedCount
39196
+ });
39197
+ }
39198
+ return { file, diffOldFile, diffNewFile, oldFile, newFile, metadataLines, hunks };
39199
+ }
39200
+ function parseDiff(raw) {
39201
+ if (!raw || !raw.trim()) return [];
39202
+ resetHunkIds();
39203
+ let chunks = raw.split(/^(?=diff --git )/m).filter((c) => c.trim());
39204
+ return chunks.map(parseFileDiff).filter((f) => f.file && f.hunks.length > 0);
39205
+ }
39206
+
39207
+ // ../../node_modules/.bun/git-patch@0.1.4/node_modules/git-patch/lib/patch-builder.js
39208
+ function buildPatchFromHunks(fileDiffs, hunkIds) {
39209
+ let idSet = new Set(hunkIds);
39210
+ let patches = [];
39211
+ for (let file of fileDiffs) {
39212
+ let selectedHunks = file.hunks.filter((h) => idSet.has(h.id));
39213
+ if (selectedHunks.length === 0) continue;
39214
+ let header = buildFileHeader(file);
39215
+ let body = selectedHunks.map((h) => formatHunk(h)).join("\n");
39216
+ patches.push(`${header}
39217
+ ${body}`);
39218
+ }
39219
+ return `${patches.join("\n")}
39220
+ `;
39221
+ }
39222
+ function buildPatchFromLines(fileDiffs, hunkId, changeLineIndices, _mode = "stage") {
39223
+ let selectedSet = new Set(changeLineIndices);
39224
+ let hunk = null;
39225
+ let parentFile = null;
39226
+ for (let file of fileDiffs) {
39227
+ for (let h of file.hunks) {
39228
+ if (h.id === hunkId) {
39229
+ hunk = h;
39230
+ parentFile = file;
39231
+ break;
39232
+ }
39233
+ }
39234
+ if (hunk) break;
39235
+ }
39236
+ if (!hunk) throw new Error(`Hunk ${hunkId} not found`);
39237
+ let changeIndex = 0;
39238
+ let newLines = [];
39239
+ for (let line of hunk.lines) {
39240
+ if (line.type === "context" || line.type === "no-newline") {
39241
+ newLines.push(line);
39242
+ continue;
39243
+ }
39244
+ changeIndex++;
39245
+ let isSelected = selectedSet.has(changeIndex);
39246
+ if (isSelected) {
39247
+ newLines.push(line);
39248
+ } else {
39249
+ if (line.type === "removed") {
39250
+ newLines.push({
39251
+ ...line,
39252
+ type: "context",
39253
+ content: ` ${line.content.slice(1)}`
39254
+ });
39255
+ }
39256
+ }
39257
+ }
39258
+ let oldCount = 0;
39259
+ let newCount = 0;
39260
+ for (let line of newLines) {
39261
+ if (line.type === "context") {
39262
+ oldCount++;
39263
+ newCount++;
39264
+ } else if (line.type === "removed") {
39265
+ oldCount++;
39266
+ } else if (line.type === "added") {
39267
+ newCount++;
39268
+ }
39269
+ }
39270
+ let newHeader = `@@ -${hunk.oldStart},${oldCount} +${hunk.newStart},${newCount} @@`;
39271
+ if (hunk.context) newHeader += ` ${hunk.context}`;
39272
+ let header = buildFileHeader(parentFile);
39273
+ let body = `${newHeader}
39274
+ ${newLines.map((l) => l.content).join("\n")}`;
39275
+ return `${header}
39276
+ ${body}
39277
+ `;
39278
+ }
39279
+ function buildFileHeader(file) {
39280
+ let diffOldFile = file.diffOldFile || `a/${file.file}`;
39281
+ let diffNewFile = file.diffNewFile || `b/${file.file}`;
39282
+ let oldFile = file.oldFile || diffOldFile;
39283
+ let newFile = file.newFile || diffNewFile;
39284
+ let headerLines = [`diff --git ${diffOldFile} ${diffNewFile}`];
39285
+ if (Array.isArray(file.metadataLines) && file.metadataLines.length > 0) {
39286
+ headerLines.push(...file.metadataLines);
39287
+ }
39288
+ headerLines.push(`--- ${oldFile}`, `+++ ${newFile}`);
39289
+ return headerLines.join("\n");
39290
+ }
39291
+ function formatHunk(hunk) {
39292
+ let lines = hunk.lines.map((l) => l.content).join("\n");
39293
+ return `${hunk.header}
39294
+ ${lines}`;
39295
+ }
39296
+
39297
+ // ../../packages/git/src/staging.ts
39298
+ async function stageFile(path) {
39299
+ await runGit(["add", path]);
39300
+ }
39301
+ async function resetStaging() {
39302
+ await runGit(["reset", "HEAD"]);
39303
+ }
39304
+ async function validatePatch(patch) {
39305
+ const proc = Bun.spawn(["git", "apply", "--cached", "--check"], {
39306
+ stdin: "pipe",
39307
+ stdout: "pipe",
39308
+ stderr: "pipe"
39309
+ });
39310
+ proc.stdin.write(patch);
39311
+ proc.stdin.end();
39312
+ const code = await proc.exited;
39313
+ return code === 0;
39314
+ }
39315
+ async function applyPatch(patch) {
39316
+ const proc = Bun.spawn(["git", "apply", "--cached"], {
39317
+ stdin: "pipe",
39318
+ stdout: "pipe",
39319
+ stderr: "pipe"
39320
+ });
39321
+ proc.stdin.write(patch);
39322
+ proc.stdin.end();
39323
+ const stderr = await new Response(proc.stderr).text();
39324
+ const code = await proc.exited;
39325
+ if (code !== 0) {
39326
+ throw new GitError(`Failed to apply patch: ${stderr.trim()}`);
39327
+ }
39328
+ }
39329
+ function buildSelectivePatch(fullPatch, lineSelections) {
39330
+ const selectionMap = /* @__PURE__ */ new Map();
39331
+ for (const sel of lineSelections) {
39332
+ const existing = selectionMap.get(sel.hunkIndex);
39333
+ if (existing) {
39334
+ for (const idx of sel.lineIndices) existing.add(idx);
39335
+ } else {
39336
+ selectionMap.set(sel.hunkIndex, new Set(sel.lineIndices));
39337
+ }
39338
+ }
39339
+ const fileDiffs = parseDiff(fullPatch);
39340
+ if (fileDiffs.length === 0) return "";
39341
+ const fullHunkIds = [];
39342
+ const linePatches = [];
39343
+ for (const file of fileDiffs) {
39344
+ for (let i = 0; i < file.hunks.length; i++) {
39345
+ const hunk = file.hunks[i];
39346
+ const selectedIndices = selectionMap.get(i);
39347
+ if (!selectedIndices) continue;
39348
+ const changeLineIndices = [];
39349
+ let changeIdx = 0;
39350
+ for (let li = 0; li < hunk.lines.length; li++) {
39351
+ const line = hunk.lines[li];
39352
+ if (line.type === "added" || line.type === "removed") {
39353
+ changeIdx++;
39354
+ if (selectedIndices.has(li)) {
39355
+ changeLineIndices.push(changeIdx);
39356
+ }
39357
+ }
39358
+ }
39359
+ const totalChangeLines = hunk.lines.filter(
39360
+ (l) => l.type === "added" || l.type === "removed"
39361
+ ).length;
39362
+ if (changeLineIndices.length === totalChangeLines) {
39363
+ fullHunkIds.push(hunk.id);
39364
+ } else if (changeLineIndices.length > 0) {
39365
+ const patch = buildPatchFromLines(
39366
+ fileDiffs,
39367
+ hunk.id,
39368
+ changeLineIndices
39369
+ );
39370
+ linePatches.push(patch);
39371
+ }
39372
+ }
39373
+ }
39374
+ let result = "";
39375
+ if (fullHunkIds.length > 0) {
39376
+ result += buildPatchFromHunks(fileDiffs, fullHunkIds);
39377
+ }
39378
+ for (const p of linePatches) {
39379
+ result += p;
39380
+ }
39381
+ return result;
39382
+ }
39383
+ async function stageHunks(fullPatch, hunkIndices) {
39384
+ const fileDiffs = parseDiff(fullPatch);
39385
+ if (fileDiffs.length === 0) return;
39386
+ const hunkIds = [];
39387
+ for (const file of fileDiffs) {
39388
+ for (let i = 0; i < file.hunks.length; i++) {
39389
+ if (hunkIndices.includes(i)) {
39390
+ hunkIds.push(file.hunks[i].id);
39391
+ }
39392
+ }
39393
+ }
39394
+ if (hunkIds.length === 0) return;
39395
+ const patch = buildPatchFromHunks(fileDiffs, hunkIds);
39396
+ if (!patch.trim()) return;
39397
+ const valid = await validatePatch(patch);
39398
+ if (!valid) {
39399
+ throw new GitError("Generated patch is invalid");
39400
+ }
39401
+ await applyPatch(patch);
39402
+ }
39403
+ async function stageLines(fullPatch, lineSelections) {
39404
+ const patch = buildSelectivePatch(fullPatch, lineSelections);
39405
+ if (!patch) return;
39406
+ const valid = await validatePatch(patch);
39407
+ if (!valid) {
39408
+ throw new GitError("Generated patch is invalid");
39409
+ }
39410
+ await applyPatch(patch);
39411
+ }
39412
+
38888
39413
  // ../../packages/git/src/index.ts
39414
+ var MAX_FILE_CONTENT_CHARS = 1e4;
39415
+ var MAX_FILES_TO_INCLUDE = 8;
38889
39416
  async function getStagedChanges() {
38890
39417
  const rawDiff = await runGit(["diff", "--staged"]);
38891
39418
  if (!rawDiff.trim()) {
@@ -38915,6 +39442,88 @@ async function getStagedChanges() {
38915
39442
  });
38916
39443
  return { rawDiff, files, isEmpty: false };
38917
39444
  }
39445
+ var BINARY_CHECK_BYTES = 8e3;
39446
+ function isBinaryContent(content) {
39447
+ const sample = content.slice(0, BINARY_CHECK_BYTES);
39448
+ return sample.includes("\0");
39449
+ }
39450
+ async function getAllChanges() {
39451
+ const rawDiff = await runGit(["diff"]);
39452
+ const untrackedOutput = await runGit([
39453
+ "ls-files",
39454
+ "--others",
39455
+ "--exclude-standard"
39456
+ ]);
39457
+ const untrackedPaths = untrackedOutput.trim().split("\n").filter(Boolean);
39458
+ if (!rawDiff.trim() && untrackedPaths.length === 0) {
39459
+ return { rawDiff: "", trackedFiles: [], untrackedFiles: [], isEmpty: true };
39460
+ }
39461
+ let trackedFiles = [];
39462
+ if (rawDiff.trim()) {
39463
+ const numstatOutput = await runGit(["diff", "--numstat"]);
39464
+ const nameStatusOutput = await runGit(["diff", "--name-status"]);
39465
+ const numstats = numstatOutput.trim().split("\n").filter(Boolean).map(parseNumstat);
39466
+ const nameStatuses = nameStatusOutput.trim().split("\n").filter(Boolean).map(parseNameStatus);
39467
+ const numstatByPath = new Map(numstats.map((n) => [n.path, n]));
39468
+ const patchByPath = extractFilePatches(rawDiff);
39469
+ trackedFiles = nameStatuses.map((ns) => {
39470
+ const nums = numstatByPath.get(ns.path) ?? {
39471
+ additions: 0,
39472
+ deletions: 0
39473
+ };
39474
+ const patchEntry = patchByPath.get(ns.path) ?? {
39475
+ patch: "",
39476
+ isBinary: false
39477
+ };
39478
+ return {
39479
+ path: ns.path,
39480
+ previousPath: ns.previousPath,
39481
+ status: ns.status,
39482
+ additions: nums.additions,
39483
+ deletions: nums.deletions,
39484
+ patch: patchEntry.patch,
39485
+ isBinary: patchEntry.isBinary
39486
+ };
39487
+ });
39488
+ }
39489
+ const untrackedFiles = await Promise.all(
39490
+ untrackedPaths.map(async (filePath) => {
39491
+ try {
39492
+ const content = await Bun.file(filePath).text();
39493
+ const binary = isBinaryContent(content);
39494
+ return {
39495
+ path: filePath,
39496
+ content: binary ? "" : content.slice(0, MAX_FILE_CONTENT_CHARS),
39497
+ isBinary: binary
39498
+ };
39499
+ } catch {
39500
+ return { path: filePath, content: "", isBinary: false };
39501
+ }
39502
+ })
39503
+ );
39504
+ return {
39505
+ rawDiff,
39506
+ trackedFiles,
39507
+ untrackedFiles,
39508
+ isEmpty: false
39509
+ };
39510
+ }
39511
+ async function getFileDiff(path) {
39512
+ return runGit(["diff", "--", path]);
39513
+ }
39514
+ async function readStagedFiles(files) {
39515
+ const eligible = files.filter((f) => f.status !== "deleted" && !f.isBinary).slice(0, MAX_FILES_TO_INCLUDE);
39516
+ const results = await Promise.all(
39517
+ eligible.map(async (f) => {
39518
+ const content = await runGit(["show", `:${f.path}`]).catch(() => "");
39519
+ return {
39520
+ path: f.path,
39521
+ content: content.slice(0, MAX_FILE_CONTENT_CHARS)
39522
+ };
39523
+ })
39524
+ );
39525
+ return results.filter((f) => f.content.length > 0);
39526
+ }
38918
39527
 
38919
39528
  // src/commands/commit.ts
38920
39529
  var import_react32 = __toESM(require_react(), 1);
@@ -38989,8 +39598,11 @@ function CommitApp({
38989
39598
  }
38990
39599
  setPhase("generating");
38991
39600
  try {
38992
- const repoId = deps.repoId ?? readRepoId();
38993
- const body = { diff: changes.rawDiff, repoId };
39601
+ const stagedFiles = await deps.readStagedFiles(changes.files);
39602
+ const body = {
39603
+ diff: changes.rawDiff,
39604
+ files: stagedFiles
39605
+ };
38994
39606
  if (deps.fileConfig && Object.keys(deps.fileConfig).length > 0) {
38995
39607
  body.config = deps.fileConfig;
38996
39608
  }
@@ -39012,7 +39624,14 @@ function CommitApp({
39012
39624
  setErrorMsg("Sess\xE3o expirada. Execute repomind login novamente.");
39013
39625
  setPhase("error-api");
39014
39626
  } else {
39015
- setErrorMsg("Falha ao gerar mensagem. Tente novamente.");
39627
+ const detail = e instanceof Error ? e.message : "Erro desconhecido";
39628
+ const verbose2 = process.argv.includes("--verbose") || process.argv.includes("-v") || !!process.env.REPOMIND_DEBUG;
39629
+ setErrorMsg(
39630
+ verbose2 ? `Falha ao gerar mensagem: ${detail}` : "Falha ao gerar mensagem. Tente novamente."
39631
+ );
39632
+ if (verbose2 && e instanceof Error && e.stack) {
39633
+ console.error(e.stack);
39634
+ }
39016
39635
  setPhase("error-api");
39017
39636
  }
39018
39637
  }
@@ -39140,42 +39759,7 @@ async function runGitCommit(message) {
39140
39759
  });
39141
39760
  return proc.exited;
39142
39761
  }
39143
- async function ensureRepoRegistered(token) {
39144
- try {
39145
- const remoteUrl = await getRemoteUrl();
39146
- const defaultBranch = await getDefaultBranch().catch(() => "main");
39147
- const name = deriveRepoName(remoteUrl);
39148
- const result = await apiClient.post(
39149
- "/repo/register",
39150
- { name, remoteUrl, defaultBranch },
39151
- token
39152
- );
39153
- saveRepoId(result.repoId);
39154
- return result.repoId;
39155
- } catch (e) {
39156
- if (e instanceof PlanLimitError) throw e;
39157
- return readRepoId();
39158
- }
39159
- }
39160
39762
  async function commitCommand() {
39161
- const token = readToken();
39162
- let repoId;
39163
- if (token) {
39164
- try {
39165
- repoId = await ensureRepoRegistered(token);
39166
- } catch (e) {
39167
- if (e instanceof PlanLimitError) {
39168
- console.error(
39169
- `\u25B2 Limite do plano ${e.plan === "free" ? "Free" : "Pro"} atingido (${e.used}/${e.limit} reposit\xF3rios)
39170
- \u2192 Fa\xE7a upgrade em https://app.repomind.dev/pricing`
39171
- );
39172
- process.exit(1);
39173
- }
39174
- throw e;
39175
- }
39176
- } else {
39177
- repoId = readRepoId();
39178
- }
39179
39763
  const fileConfig = await readRepoConfig();
39180
39764
  let exitCode = 0;
39181
39765
  const { waitUntilExit } = render_default(
@@ -39183,9 +39767,9 @@ async function commitCommand() {
39183
39767
  deps: {
39184
39768
  readToken,
39185
39769
  getStagedChanges,
39770
+ readStagedFiles,
39186
39771
  apiPost: (path, body, tkn) => apiClient.post(path, body, tkn),
39187
39772
  runGitCommit,
39188
- repoId,
39189
39773
  fileConfig
39190
39774
  },
39191
39775
  onExit: (code) => {
@@ -39463,18 +40047,18 @@ function startCallbackServer(port) {
39463
40047
  // src/lib/open-browser.ts
39464
40048
  async function openBrowser(url) {
39465
40049
  const platform2 = process.platform;
39466
- let args;
40050
+ let args2;
39467
40051
  if (platform2 === "darwin") {
39468
- args = ["open", url];
40052
+ args2 = ["open", url];
39469
40053
  } else if (platform2 === "linux") {
39470
- args = ["xdg-open", url];
40054
+ args2 = ["xdg-open", url];
39471
40055
  } else if (platform2 === "win32") {
39472
- args = ["cmd", "/c", "start", url];
40056
+ args2 = ["cmd", "/c", "start", url];
39473
40057
  } else {
39474
40058
  return;
39475
40059
  }
39476
40060
  try {
39477
- Bun.spawn(args, { stdio: ["ignore", "ignore", "ignore"] });
40061
+ Bun.spawn(args2, { stdio: ["ignore", "ignore", "ignore"] });
39478
40062
  } catch {
39479
40063
  }
39480
40064
  }
@@ -39528,7 +40112,8 @@ function LoginApp({
39528
40112
  setErrorMsg("Timeout. Execute repomind login novamente.");
39529
40113
  setPhase("error-timeout");
39530
40114
  } else {
39531
- setErrorMsg("Falha ao autenticar. Tente novamente.");
40115
+ const detail = err instanceof Error ? err.message : "unknown";
40116
+ setErrorMsg(`Falha no callback do browser: ${detail}`);
39532
40117
  setPhase("error-auth");
39533
40118
  }
39534
40119
  return;
@@ -39539,8 +40124,9 @@ function LoginApp({
39539
40124
  deps.saveToken(response.token, response.expiresAt);
39540
40125
  setEmail(response.email);
39541
40126
  setPhase("done");
39542
- } catch {
39543
- setErrorMsg("Falha ao autenticar. Tente novamente.");
40127
+ } catch (err) {
40128
+ const detail = err instanceof Error ? err.message : "unknown";
40129
+ setErrorMsg(`Falha na API: ${detail}`);
39544
40130
  setPhase("error-api");
39545
40131
  }
39546
40132
  }
@@ -39637,13 +40223,928 @@ async function logoutCommand() {
39637
40223
  process.exit(exitCode);
39638
40224
  }
39639
40225
 
39640
- // src/commands/whoami.tsx
39641
- var import_react38 = __toESM(require_react(), 1);
40226
+ // src/commands/split.ts
40227
+ var import_react40 = __toESM(require_react(), 1);
40228
+
40229
+ // src/ui/split-app.tsx
40230
+ var import_react39 = __toESM(require_react(), 1);
40231
+
40232
+ // src/ui/components/diff-stats.tsx
39642
40233
  var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
40234
+ function DiffStats({
40235
+ additions,
40236
+ deletions,
40237
+ showBar = false
40238
+ }) {
40239
+ if (!showBar) {
40240
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { gap: 0, children: [
40241
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "green", bold: true, children: [
40242
+ "+",
40243
+ additions
40244
+ ] }),
40245
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { dimColor: true, children: " / " }),
40246
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "red", bold: true, children: [
40247
+ "-",
40248
+ deletions
40249
+ ] })
40250
+ ] });
40251
+ }
40252
+ const total = additions + deletions;
40253
+ const barWidth = Math.min(total, 20);
40254
+ const addBar = total > 0 ? Math.max(1, Math.round(additions / total * barWidth)) : 0;
40255
+ const delBar = Math.max(0, barWidth - addBar);
40256
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { gap: 1, children: [
40257
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "green", bold: true, children: [
40258
+ "+",
40259
+ additions
40260
+ ] }),
40261
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "red", bold: true, children: [
40262
+ "-",
40263
+ deletions
40264
+ ] }),
40265
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { gap: 0, children: [
40266
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "green", children: "\u2588".repeat(addBar) }),
40267
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "red", children: "\u2588".repeat(delBar) })
40268
+ ] })
40269
+ ] });
40270
+ }
40271
+
40272
+ // src/ui/components/type-badge.tsx
40273
+ var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
40274
+ var TYPE_STYLES = {
40275
+ feat: { bg: "cyan", fg: "black" },
40276
+ fix: { bg: "red", fg: "white" },
40277
+ refactor: { bg: "yellow", fg: "black" },
40278
+ docs: { bg: "blue", fg: "white" },
40279
+ test: { bg: "magenta", fg: "white" },
40280
+ chore: { bg: "gray", fg: "white" },
40281
+ style: { bg: "green", fg: "black" },
40282
+ ci: { bg: "blue", fg: "white" },
40283
+ perf: { bg: "yellow", fg: "black" },
40284
+ build: { bg: "gray", fg: "white" },
40285
+ revert: { bg: "red", fg: "white" }
40286
+ };
40287
+ function TypeBadge({ type }) {
40288
+ const style = TYPE_STYLES[type] ?? { bg: "gray", fg: "white" };
40289
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { backgroundColor: style.bg, color: style.fg, bold: true, children: ` ${type} ` });
40290
+ }
40291
+
40292
+ // src/ui/components/commit-card.tsx
40293
+ var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
40294
+ function formatSelection(f) {
40295
+ if (f.selection === "all") return "all";
40296
+ return f.selection.map((h) => `h${h.hunkIndex}`).join(",");
40297
+ }
40298
+ function CommitCard(props) {
40299
+ const borderColor = props.isSkipped ? "yellow" : "cyan";
40300
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
40301
+ Box_default,
40302
+ {
40303
+ flexDirection: "column",
40304
+ borderStyle: "bold",
40305
+ borderColor,
40306
+ paddingX: 2,
40307
+ paddingY: 1,
40308
+ marginBottom: 0,
40309
+ children: [
40310
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box_default, { gap: 1, alignItems: "center", children: [
40311
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text, { dimColor: true, bold: true, children: [
40312
+ String(props.index).padStart(String(props.total).length),
40313
+ "/",
40314
+ props.total
40315
+ ] }),
40316
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TypeBadge, { type: props.type }),
40317
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { bold: true, color: "white", children: props.description })
40318
+ ] }),
40319
+ props.scope && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box_default, { marginLeft: 5, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text, { dimColor: true, italic: true, children: [
40320
+ "scope: ",
40321
+ props.scope
40322
+ ] }) }),
40323
+ props.isSkipped && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text, { backgroundColor: "yellow", color: "black", bold: true, children: [
40324
+ " ",
40325
+ "PULADO",
40326
+ " "
40327
+ ] }) }),
40328
+ !props.isSkipped && props.body && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box_default, { marginTop: 1, marginLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color: "white", children: props.body }) }),
40329
+ !props.isSkipped && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box_default, { flexDirection: "column", marginTop: 1, children: props.files.map((f) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box_default, { gap: 1, marginLeft: 1, children: [
40330
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color: "cyan", bold: true, children: "\u25B8" }),
40331
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { children: f.path }),
40332
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text, { dimColor: true, children: [
40333
+ "[",
40334
+ formatSelection(f),
40335
+ "]"
40336
+ ] })
40337
+ ] }, f.path)) }),
40338
+ !props.isSkipped && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box_default, { marginTop: 1, marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
40339
+ DiffStats,
40340
+ {
40341
+ additions: props.additions,
40342
+ deletions: props.deletions,
40343
+ showBar: true
40344
+ }
40345
+ ) })
40346
+ ]
40347
+ }
40348
+ );
40349
+ }
40350
+
40351
+ // src/ui/components/commit-row.tsx
40352
+ var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
40353
+ function CommitRow(props) {
40354
+ const pad = String(props.total).length;
40355
+ const num = `${String(props.index).padStart(pad)}/${props.total}`;
40356
+ if (props.isSkipped) {
40357
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { gap: 1, marginLeft: 2, children: [
40358
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, children: num }),
40359
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, strikethrough: true, children: props.description }),
40360
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Text, { backgroundColor: "yellow", color: "black", children: [
40361
+ " ",
40362
+ "skip",
40363
+ " "
40364
+ ] })
40365
+ ] });
40366
+ }
40367
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { gap: 1, marginLeft: 2, children: [
40368
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, children: num }),
40369
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TypeBadge, { type: props.type }),
40370
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { dimColor: true, children: props.description }),
40371
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DiffStats, { additions: props.additions, deletions: props.deletions })
40372
+ ] });
40373
+ }
40374
+
40375
+ // src/ui/components/diff-viewer.tsx
40376
+ var import_react38 = __toESM(require_react(), 1);
40377
+ var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
40378
+ function DiffViewer({ filePath, patch, onClose }) {
40379
+ const [scrollOffset, setScrollOffset] = (0, import_react38.useState)(0);
40380
+ const termHeight = process.stdout.rows || 24;
40381
+ use_input_default((input, key) => {
40382
+ if (input === "q" || input === "d" || key.escape) {
40383
+ onClose();
40384
+ return;
40385
+ }
40386
+ if (key.upArrow || input === "k") {
40387
+ setScrollOffset((prev) => Math.max(0, prev - 1));
40388
+ }
40389
+ if (key.downArrow || input === "j") {
40390
+ setScrollOffset((prev) => prev + 1);
40391
+ }
40392
+ if (input === " " || key.pageDown) {
40393
+ setScrollOffset((prev) => prev + (termHeight - 5));
40394
+ }
40395
+ if (input === "u" || key.pageUp) {
40396
+ setScrollOffset((prev) => Math.max(0, prev - (termHeight - 5)));
40397
+ }
40398
+ if (input === "g") {
40399
+ setScrollOffset(0);
40400
+ }
40401
+ });
40402
+ const allLines = patch.split("\n");
40403
+ const contentLines = [];
40404
+ for (const line of allLines) {
40405
+ if (line.startsWith("diff --git")) {
40406
+ const match = line.match(/^diff --git a\/.+ b\/(.+)$/);
40407
+ const file = match?.[1] ?? line;
40408
+ contentLines.push(`__FILE__${file}`);
40409
+ } else if (line.startsWith("index ") || line.startsWith("--- ") || line.startsWith("+++ ") || line.startsWith("old mode") || line.startsWith("new mode") || line.startsWith("new file") || line.startsWith("deleted file") || line.startsWith("similarity")) {
40410
+ } else {
40411
+ contentLines.push(line);
40412
+ }
40413
+ }
40414
+ const totalLines = contentLines.length;
40415
+ const viewportHeight = Math.max(1, termHeight - 5);
40416
+ const maxScroll = Math.max(0, totalLines - viewportHeight);
40417
+ const clamped = Math.min(scrollOffset, maxScroll);
40418
+ const visibleLines = contentLines.slice(clamped, clamped + viewportHeight);
40419
+ const scrollPercent = maxScroll > 0 ? Math.round(clamped / maxScroll * 100) : 100;
40420
+ const termWidth = process.stdout.columns || 80;
40421
+ const fileCount = contentLines.filter((l) => l.startsWith("__FILE__")).length;
40422
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { flexDirection: "column", children: [
40423
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { children: [
40424
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "cyan", color: "black", bold: true, children: [
40425
+ " ",
40426
+ "DIFF",
40427
+ " "
40428
+ ] }),
40429
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { bold: true, children: [
40430
+ " ",
40431
+ filePath,
40432
+ " "
40433
+ ] }),
40434
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { dimColor: true, children: [
40435
+ "\xB7 ",
40436
+ fileCount > 1 ? `${fileCount} arquivos \xB7 ` : "",
40437
+ totalLines,
40438
+ " linhas \xB7 ",
40439
+ scrollPercent,
40440
+ "%"
40441
+ ] })
40442
+ ] }),
40443
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "\u2500".repeat(Math.min(termWidth, 80)) }),
40444
+ visibleLines.map((line, i) => {
40445
+ const key = `dl-${clamped + i}`;
40446
+ if (line.startsWith("__FILE__")) {
40447
+ const file = line.slice(8);
40448
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { flexDirection: "column", marginTop: i > 0 ? 1 : 0, children: [
40449
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "\u2500".repeat(Math.min(termWidth, 80)) }),
40450
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { gap: 1, children: [
40451
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "blue", color: "white", bold: true, children: [
40452
+ " ",
40453
+ "FILE",
40454
+ " "
40455
+ ] }),
40456
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { bold: true, color: "white", children: file })
40457
+ ] }),
40458
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "\u2500".repeat(Math.min(termWidth, 80)) })
40459
+ ] }, key);
40460
+ }
40461
+ const num = String(clamped + i + 1).padStart(4);
40462
+ if (line.startsWith("@@")) {
40463
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { color: "cyan", dimColor: true, children: [
40464
+ " ",
40465
+ " ",
40466
+ line
40467
+ ] }, key);
40468
+ }
40469
+ if (line.startsWith("+")) {
40470
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { color: "green", children: [
40471
+ num,
40472
+ " ",
40473
+ line
40474
+ ] }, key);
40475
+ }
40476
+ if (line.startsWith("-")) {
40477
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { color: "red", children: [
40478
+ num,
40479
+ " ",
40480
+ line
40481
+ ] }, key);
40482
+ }
40483
+ if (line.startsWith("\\")) {
40484
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { dimColor: true, children: [
40485
+ " ",
40486
+ line
40487
+ ] }, key);
40488
+ }
40489
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { dimColor: true, children: [
40490
+ num,
40491
+ " ",
40492
+ line
40493
+ ] }, key);
40494
+ }),
40495
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "\u2500".repeat(Math.min(termWidth, 80)) }),
40496
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { gap: 1, children: [
40497
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "gray", color: "white", bold: true, children: [
40498
+ " ",
40499
+ "\u2191\u2193",
40500
+ " "
40501
+ ] }),
40502
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "rolar" }),
40503
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "gray", color: "white", bold: true, children: [
40504
+ " ",
40505
+ "space",
40506
+ " "
40507
+ ] }),
40508
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "p\xE1gina" }),
40509
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "gray", color: "white", bold: true, children: [
40510
+ " ",
40511
+ "g",
40512
+ " "
40513
+ ] }),
40514
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "topo" }),
40515
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { backgroundColor: "gray", color: "white", bold: true, children: [
40516
+ " ",
40517
+ "q",
40518
+ " "
40519
+ ] }),
40520
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { dimColor: true, children: "sair" }),
40521
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { dimColor: true, children: [
40522
+ " ",
40523
+ "\u2502 ",
40524
+ clamped + 1,
40525
+ "-",
40526
+ Math.min(clamped + viewportHeight, totalLines),
40527
+ "/",
40528
+ totalLines
40529
+ ] })
40530
+ ] })
40531
+ ] });
40532
+ }
40533
+
40534
+ // src/ui/components/header.tsx
40535
+ var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
40536
+ function Header({ title = "RepoMind Split" }) {
40537
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Box_default, { flexDirection: "column", marginBottom: 1, children: [
40538
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box_default, { gap: 1, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { backgroundColor: "cyan", color: "black", bold: true, children: [
40539
+ " ",
40540
+ "\u26A1 ",
40541
+ title,
40542
+ " "
40543
+ ] }) }),
40544
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { dimColor: true, children: "\u2500".repeat(40) })
40545
+ ] });
40546
+ }
40547
+
40548
+ // src/ui/components/key-hints.tsx
40549
+ var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
40550
+ function KeyHints({ hints }) {
40551
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Box_default, { marginTop: 1, gap: 0, flexWrap: "wrap", children: [
40552
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text, { dimColor: true, children: "\u2500".repeat(40) }),
40553
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box_default, { gap: 1, marginTop: 0, children: hints.map((hint) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Box_default, { gap: 0, children: [
40554
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text, { backgroundColor: "gray", color: "white", bold: true, children: ` ${hint.key} ` }),
40555
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Text, { dimColor: true, children: [
40556
+ " ",
40557
+ hint.label,
40558
+ " "
40559
+ ] })
40560
+ ] }, hint.key)) })
40561
+ ] });
40562
+ }
40563
+
40564
+ // src/ui/components/progress-bar.tsx
40565
+ var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
40566
+ function ProgressBar({ current, total, width = 24 }) {
40567
+ const ratio = total > 0 ? current / total : 0;
40568
+ const filled = Math.round(ratio * width);
40569
+ const empty = width - filled;
40570
+ const percent = Math.round(ratio * 100);
40571
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Box_default, { gap: 1, children: [
40572
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: "cyan", bold: true, children: "\u2501".repeat(filled) }),
40573
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { dimColor: true, children: "\u2500".repeat(empty) }),
40574
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Text, { bold: true, color: ratio >= 1 ? "green" : "cyan", children: [
40575
+ percent,
40576
+ "%"
40577
+ ] }),
40578
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Text, { dimColor: true, children: [
40579
+ "(",
40580
+ current,
40581
+ "/",
40582
+ total,
40583
+ ")"
40584
+ ] })
40585
+ ] });
40586
+ }
40587
+
40588
+ // src/ui/components/step-list.tsx
40589
+ var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
40590
+ var STATUS_ICONS = {
40591
+ done: "\u25CF",
40592
+ active: "",
40593
+ pending: "\u25CB",
40594
+ error: "\u2717"
40595
+ };
40596
+ var STATUS_COLORS = {
40597
+ done: "green",
40598
+ active: "cyan",
40599
+ pending: void 0,
40600
+ error: "red"
40601
+ };
40602
+ function StepList({ steps }) {
40603
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box_default, { flexDirection: "column", gap: 0, marginLeft: 1, children: steps.map((step, idx) => {
40604
+ const isLast = idx === steps.length - 1;
40605
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Box_default, { flexDirection: "column", children: [
40606
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Box_default, { gap: 1, children: [
40607
+ step.status === "active" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text, { color: "cyan", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(build_default, { type: "dots" }) }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
40608
+ Text,
40609
+ {
40610
+ color: STATUS_COLORS[step.status],
40611
+ dimColor: step.status === "pending",
40612
+ children: STATUS_ICONS[step.status]
40613
+ }
40614
+ ),
40615
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
40616
+ Text,
40617
+ {
40618
+ color: STATUS_COLORS[step.status],
40619
+ dimColor: step.status === "pending",
40620
+ bold: step.status === "active",
40621
+ children: step.label
40622
+ }
40623
+ ),
40624
+ step.detail && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text, { dimColor: true, children: [
40625
+ "\xB7 ",
40626
+ step.detail
40627
+ ] })
40628
+ ] }),
40629
+ !isLast && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box_default, { marginLeft: 0, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text, { dimColor: true, children: "\u2502" }) })
40630
+ ] }, step.label);
40631
+ }) });
40632
+ }
40633
+
40634
+ // src/ui/split-app.tsx
40635
+ var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
40636
+ var TERMINAL_PHASES5 = [
40637
+ "done",
40638
+ "aborted",
40639
+ "error-auth",
40640
+ "error-empty",
40641
+ "error-git",
40642
+ "error-api",
40643
+ "error-plan",
40644
+ "error-commit"
40645
+ ];
40646
+ function getAllLineIndices(hunksMap, path, hunkIndex) {
40647
+ const hunks = hunksMap.get(path);
40648
+ if (!hunks) return [];
40649
+ const hunk = hunks.find(
40650
+ (h) => h.startLineOld === hunkIndex || hunks.indexOf(h) === hunkIndex
40651
+ );
40652
+ if (!hunk) return [];
40653
+ const indices = [];
40654
+ for (let i = 0; i < hunk.lines.length; i++) {
40655
+ const line = hunk.lines[i];
40656
+ if (line.type === "addition" || line.type === "deletion") {
40657
+ indices.push(i);
40658
+ }
40659
+ }
40660
+ return indices;
40661
+ }
40662
+ function computeGroupStats(files, originalFiles) {
40663
+ let additions = 0;
40664
+ let deletions = 0;
40665
+ for (const ref of files) {
40666
+ const orig = originalFiles.find((f) => f.path === ref.path);
40667
+ if (!orig) continue;
40668
+ if (ref.selection === "all") {
40669
+ additions += orig.additions;
40670
+ deletions += orig.deletions;
40671
+ } else {
40672
+ additions += orig.additions;
40673
+ deletions += orig.deletions;
40674
+ }
40675
+ }
40676
+ return { additions, deletions };
40677
+ }
40678
+ function SplitApp({
40679
+ deps,
40680
+ onExit
40681
+ }) {
40682
+ const { exit } = use_app_default();
40683
+ const [phase, setPhase] = (0, import_react39.useState)("collecting");
40684
+ const [groups, setGroups] = (0, import_react39.useState)([]);
40685
+ const [selectedIndex, setSelectedIndex] = (0, import_react39.useState)(0);
40686
+ const [skippedGroups, setSkippedGroups] = (0, import_react39.useState)(/* @__PURE__ */ new Set());
40687
+ const [commitProgress, setCommitProgress] = (0, import_react39.useState)(0);
40688
+ const [errorMsg, setErrorMsg] = (0, import_react39.useState)("");
40689
+ const [originalFiles, setOriginalFiles] = (0, import_react39.useState)([]);
40690
+ const [hunksMap, setHunksMap] = (0, import_react39.useState)(/* @__PURE__ */ new Map());
40691
+ const [patchMap, setPatchMap] = (0, import_react39.useState)(/* @__PURE__ */ new Map());
40692
+ const [authToken, setAuthToken] = (0, import_react39.useState)("");
40693
+ (0, import_react39.useEffect)(() => {
40694
+ if (!TERMINAL_PHASES5.includes(phase)) return;
40695
+ const code = phase === "done" || phase === "aborted" ? 0 : 1;
40696
+ exit();
40697
+ onExit(code);
40698
+ }, [phase]);
40699
+ (0, import_react39.useEffect)(() => {
40700
+ async function run2() {
40701
+ const token = deps.readToken();
40702
+ if (!token) {
40703
+ setErrorMsg("N\xE3o autenticado. Execute repomind login primeiro.");
40704
+ setPhase("error-auth");
40705
+ return;
40706
+ }
40707
+ setAuthToken(token);
40708
+ let files;
40709
+ try {
40710
+ if (deps.useStaged) {
40711
+ const changes = await deps.getStagedChanges();
40712
+ if (changes.isEmpty) {
40713
+ setErrorMsg(
40714
+ "Nenhuma altera\xE7\xE3o encontrada. Use git add ou remova --staged."
40715
+ );
40716
+ setPhase("error-empty");
40717
+ return;
40718
+ }
40719
+ files = changes.files;
40720
+ } else {
40721
+ const changes = await deps.getAllChanges();
40722
+ if (changes.isEmpty) {
40723
+ setErrorMsg("Nenhuma altera\xE7\xE3o encontrada no reposit\xF3rio.");
40724
+ setPhase("error-empty");
40725
+ return;
40726
+ }
40727
+ files = [
40728
+ ...changes.trackedFiles,
40729
+ ...changes.untrackedFiles.map((uf) => ({
40730
+ path: uf.path,
40731
+ status: "added",
40732
+ additions: uf.content.split("\n").length,
40733
+ deletions: 0,
40734
+ patch: "",
40735
+ isBinary: uf.isBinary
40736
+ }))
40737
+ ];
40738
+ }
40739
+ } catch (e) {
40740
+ setErrorMsg(
40741
+ e instanceof GitError ? e.message : "Erro ao ler o reposit\xF3rio."
40742
+ );
40743
+ setPhase("error-git");
40744
+ return;
40745
+ }
40746
+ if (files.length === 0) {
40747
+ setErrorMsg("Nenhum arquivo com altera\xE7\xF5es encontrado.");
40748
+ setPhase("error-empty");
40749
+ return;
40750
+ }
40751
+ const hMap = /* @__PURE__ */ new Map();
40752
+ const pMap = /* @__PURE__ */ new Map();
40753
+ for (const file of files) {
40754
+ if (file.patch) {
40755
+ const hunks = deps.parseHunks(file.patch);
40756
+ hMap.set(file.path, hunks);
40757
+ pMap.set(file.path, file.patch);
40758
+ }
40759
+ }
40760
+ setOriginalFiles(files);
40761
+ setHunksMap(hMap);
40762
+ setPatchMap(pMap);
40763
+ const manifest = deps.buildSplitManifest(files, hMap);
40764
+ setPhase("analyzing");
40765
+ try {
40766
+ const body = { manifest };
40767
+ if (deps.fileConfig && Object.keys(deps.fileConfig).length > 0) {
40768
+ body.config = deps.fileConfig;
40769
+ }
40770
+ const result = await deps.apiPost(
40771
+ "/split/analyze",
40772
+ body,
40773
+ token
40774
+ );
40775
+ const sortedGroups = result.groups.sort((a, b) => a.order - b.order);
40776
+ setGroups(sortedGroups);
40777
+ setPhase("review");
40778
+ } catch (e) {
40779
+ if (e instanceof PlanLimitError) {
40780
+ setErrorMsg(
40781
+ `Limite do plano ${e.plan === "free" ? "Free" : "Pro"} atingido (${e.used}/${e.limit} commits este m\xEAs)
40782
+ \u2192 Fa\xE7a upgrade em https://app.repomind.dev/pricing`
40783
+ );
40784
+ setPhase("error-plan");
40785
+ } else if (e instanceof ApiError && e.status === 401) {
40786
+ setErrorMsg("Sess\xE3o expirada. Execute repomind login novamente.");
40787
+ setPhase("error-api");
40788
+ } else {
40789
+ const detail = e instanceof Error ? e.message : "Erro desconhecido";
40790
+ const verbose2 = process.argv.includes("--verbose") || process.argv.includes("-v") || !!process.env.REPOMIND_DEBUG;
40791
+ setErrorMsg(
40792
+ verbose2 ? `Falha ao analisar altera\xE7\xF5es: ${detail}` : "Falha ao analisar altera\xE7\xF5es. Tente novamente."
40793
+ );
40794
+ if (verbose2 && e instanceof Error && e.stack) {
40795
+ console.error(e.stack);
40796
+ }
40797
+ setPhase("error-api");
40798
+ }
40799
+ }
40800
+ }
40801
+ run2();
40802
+ }, []);
40803
+ use_input_default(
40804
+ (input, key) => {
40805
+ if (phase !== "review") return;
40806
+ if (key.upArrow || input === "k") {
40807
+ setSelectedIndex((prev) => Math.max(0, prev - 1));
40808
+ return;
40809
+ }
40810
+ if (key.downArrow || input === "j") {
40811
+ setSelectedIndex((prev) => Math.min(groups.length - 1, prev + 1));
40812
+ return;
40813
+ }
40814
+ if (input === "d") {
40815
+ setPhase("viewing-diff");
40816
+ return;
40817
+ }
40818
+ if (input === "s") {
40819
+ const groupId = groups[selectedIndex]?.groupId;
40820
+ if (groupId) {
40821
+ setSkippedGroups((prev) => {
40822
+ const next = new Set(prev);
40823
+ if (next.has(groupId)) {
40824
+ next.delete(groupId);
40825
+ } else {
40826
+ next.add(groupId);
40827
+ }
40828
+ return next;
40829
+ });
40830
+ }
40831
+ return;
40832
+ }
40833
+ if (key.return || input === "a") {
40834
+ startCommitting();
40835
+ return;
40836
+ }
40837
+ if (input === "q") {
40838
+ setPhase("aborted");
40839
+ }
40840
+ },
40841
+ { isActive: phase === "review" }
40842
+ );
40843
+ async function startCommitting() {
40844
+ setPhase("committing");
40845
+ setCommitProgress(0);
40846
+ const activeGroups2 = groups.filter((g) => !skippedGroups.has(g.groupId));
40847
+ if (activeGroups2.length === 0) {
40848
+ setPhase("aborted");
40849
+ return;
40850
+ }
40851
+ for (let i = 0; i < activeGroups2.length; i++) {
40852
+ const group = activeGroups2[i];
40853
+ try {
40854
+ await deps.resetStaging();
40855
+ for (const fileRef of group.files) {
40856
+ if (fileRef.selection === "all") {
40857
+ await deps.stageFile(fileRef.path);
40858
+ } else {
40859
+ const currentDiff = await deps.getFileDiff(fileRef.path);
40860
+ if (!currentDiff.trim()) {
40861
+ continue;
40862
+ }
40863
+ const currentHunks = deps.parseHunks(currentDiff);
40864
+ const originalHunks = hunksMap.get(fileRef.path) ?? [];
40865
+ const lineSelections = [];
40866
+ for (const hs of fileRef.selection) {
40867
+ const origHunk = originalHunks.find(
40868
+ (h) => h.index === hs.hunkIndex
40869
+ );
40870
+ if (!origHunk) continue;
40871
+ const wantedIndices = hs.lines === "all" ? getAllLineIndices(hunksMap, fileRef.path, hs.hunkIndex) : hs.lines;
40872
+ const wantedLines = wantedIndices.map((idx) => origHunk.lines[idx]).filter(Boolean);
40873
+ for (const curHunk of currentHunks) {
40874
+ const matchedIndices = [];
40875
+ for (const wanted of wantedLines) {
40876
+ for (let ci = 0; ci < curHunk.lines.length; ci++) {
40877
+ const curLine = curHunk.lines[ci];
40878
+ if (curLine.type === wanted.type && curLine.content === wanted.content && !matchedIndices.includes(ci)) {
40879
+ matchedIndices.push(ci);
40880
+ break;
40881
+ }
40882
+ }
40883
+ }
40884
+ if (matchedIndices.length > 0) {
40885
+ lineSelections.push({
40886
+ hunkIndex: curHunk.index,
40887
+ lineIndices: matchedIndices
40888
+ });
40889
+ }
40890
+ }
40891
+ }
40892
+ if (lineSelections.length > 0) {
40893
+ await deps.stageLines(currentDiff, lineSelections);
40894
+ }
40895
+ }
40896
+ }
40897
+ const code = await deps.runGitCommit(group.message);
40898
+ if (code !== 0) {
40899
+ setErrorMsg(
40900
+ `git commit falhou no grupo ${i + 1}/${activeGroups2.length}: "${group.message}"`
40901
+ );
40902
+ setPhase("error-commit");
40903
+ return;
40904
+ }
40905
+ if (authToken) {
40906
+ deps.apiPost("/split/confirm", { group }, authToken).catch(() => {
40907
+ });
40908
+ }
40909
+ setCommitProgress(i + 1);
40910
+ } catch (e) {
40911
+ const detail = e instanceof Error ? e.message : "Erro desconhecido";
40912
+ setErrorMsg(`Erro no grupo ${i + 1}/${activeGroups2.length}: ${detail}`);
40913
+ setPhase("error-commit");
40914
+ return;
40915
+ }
40916
+ }
40917
+ setPhase("done");
40918
+ }
40919
+ const activeGroups = groups.filter((g) => !skippedGroups.has(g.groupId));
40920
+ const activeGroupCount = activeGroups.length;
40921
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { flexDirection: "column", gap: 0, paddingTop: 1, children: [
40922
+ phase === "collecting" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
40923
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
40924
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
40925
+ StepList,
40926
+ {
40927
+ steps: [{ label: "Coletando altera\xE7\xF5es", status: "active" }]
40928
+ }
40929
+ )
40930
+ ] }),
40931
+ phase === "analyzing" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
40932
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
40933
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
40934
+ StepList,
40935
+ {
40936
+ steps: [
40937
+ {
40938
+ label: "Altera\xE7\xF5es coletadas",
40939
+ status: "done",
40940
+ detail: `${originalFiles.length} arquivos`
40941
+ },
40942
+ { label: "Analisando com IA", status: "active" }
40943
+ ]
40944
+ }
40945
+ )
40946
+ ] }),
40947
+ phase === "review" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
40948
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
40949
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Box_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Text, { bold: true, children: [
40950
+ groups.length,
40951
+ " commits sugeridos"
40952
+ ] }) }),
40953
+ groups.map((group, idx) => {
40954
+ const isSelected = idx === selectedIndex;
40955
+ const isSkipped = skippedGroups.has(group.groupId);
40956
+ const stats = computeGroupStats(group.files, originalFiles);
40957
+ if (isSelected) {
40958
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
40959
+ CommitCard,
40960
+ {
40961
+ index: idx + 1,
40962
+ total: groups.length,
40963
+ type: group.type,
40964
+ scope: group.scope,
40965
+ description: group.description,
40966
+ body: group.body,
40967
+ files: group.files,
40968
+ additions: stats.additions,
40969
+ deletions: stats.deletions,
40970
+ isSkipped
40971
+ },
40972
+ group.groupId
40973
+ );
40974
+ }
40975
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
40976
+ CommitRow,
40977
+ {
40978
+ index: idx + 1,
40979
+ total: groups.length,
40980
+ type: group.type,
40981
+ description: group.description,
40982
+ additions: stats.additions,
40983
+ deletions: stats.deletions,
40984
+ isSkipped,
40985
+ isSelected: false
40986
+ },
40987
+ group.groupId
40988
+ );
40989
+ }),
40990
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
40991
+ KeyHints,
40992
+ {
40993
+ hints: [
40994
+ { key: "\u2191\u2193", label: "navegar" },
40995
+ { key: "d", label: "diff" },
40996
+ { key: "enter", label: "confirmar" },
40997
+ { key: "s", label: "pular" },
40998
+ { key: "q", label: "abortar" }
40999
+ ]
41000
+ }
41001
+ )
41002
+ ] }),
41003
+ phase === "viewing-diff" && (() => {
41004
+ const group = groups[selectedIndex];
41005
+ if (!group) return null;
41006
+ const combinedPatch = group.files.map((f) => patchMap.get(f.path) ?? "").filter(Boolean).join("\n");
41007
+ const mainFile = group.files[0]?.path ?? "diff";
41008
+ const label = group.files.length > 1 ? `${mainFile} (+${group.files.length - 1} arquivos)` : mainFile;
41009
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
41010
+ DiffViewer,
41011
+ {
41012
+ filePath: label,
41013
+ patch: combinedPatch,
41014
+ onClose: () => setPhase("review")
41015
+ }
41016
+ );
41017
+ })(),
41018
+ phase === "committing" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
41019
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
41020
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
41021
+ StepList,
41022
+ {
41023
+ steps: activeGroups.map((g, i) => ({
41024
+ label: g.message,
41025
+ status: i < commitProgress ? "done" : i === commitProgress ? "active" : "pending"
41026
+ }))
41027
+ }
41028
+ ),
41029
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Box_default, { marginTop: 1, marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ProgressBar, { current: commitProgress, total: activeGroupCount }) })
41030
+ ] }),
41031
+ phase === "done" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
41032
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
41033
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
41034
+ StepList,
41035
+ {
41036
+ steps: activeGroups.map((g) => ({
41037
+ label: g.message,
41038
+ status: "done"
41039
+ }))
41040
+ }
41041
+ ),
41042
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { marginTop: 1, gap: 1, children: [
41043
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "green", children: "\u2728" }),
41044
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Text, { bold: true, color: "green", children: [
41045
+ activeGroupCount,
41046
+ " commit",
41047
+ activeGroupCount !== 1 ? "s" : "",
41048
+ " ",
41049
+ "realizado",
41050
+ activeGroupCount !== 1 ? "s" : "",
41051
+ " com sucesso"
41052
+ ] })
41053
+ ] })
41054
+ ] }),
41055
+ phase === "aborted" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
41056
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
41057
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { gap: 1, children: [
41058
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "yellow", children: "\u25C6" }),
41059
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { dimColor: true, children: "Abortado. Nenhum commit foi feito." })
41060
+ ] })
41061
+ ] }),
41062
+ phase === "error-commit" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
41063
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
41064
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
41065
+ StepList,
41066
+ {
41067
+ steps: activeGroups.map((g, i) => ({
41068
+ label: g.message,
41069
+ status: i < commitProgress ? "done" : i === commitProgress ? "error" : "pending"
41070
+ }))
41071
+ }
41072
+ ),
41073
+ commitProgress > 0 && commitProgress < activeGroupCount && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { marginTop: 1, gap: 1, children: [
41074
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "yellow", children: "\u25B2" }),
41075
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Text, { color: "yellow", children: [
41076
+ commitProgress,
41077
+ "/",
41078
+ activeGroupCount,
41079
+ " commits realizados antes do erro"
41080
+ ] })
41081
+ ] }),
41082
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { gap: 1, marginTop: commitProgress > 0 ? 0 : 1, children: [
41083
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "red", children: "\u2717" }),
41084
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "red", children: errorMsg })
41085
+ ] })
41086
+ ] }),
41087
+ (phase === "error-auth" || phase === "error-empty" || phase === "error-git" || phase === "error-api" || phase === "error-plan") && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
41088
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header, {}),
41089
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Box_default, { gap: 1, children: [
41090
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "red", children: "\u2717" }),
41091
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { color: "red", children: errorMsg })
41092
+ ] })
41093
+ ] }),
41094
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Box_default, { marginTop: 1 })
41095
+ ] });
41096
+ }
41097
+
41098
+ // src/commands/split.ts
41099
+ async function runGitCommit2(message) {
41100
+ const proc = Bun.spawn(["git", "commit", "-m", message], {
41101
+ stdout: "inherit",
41102
+ stderr: "inherit"
41103
+ });
41104
+ return proc.exited;
41105
+ }
41106
+ async function splitCommand() {
41107
+ const fileConfig = await readRepoConfig();
41108
+ const useStaged = process.argv.includes("--staged");
41109
+ let exitCode = 0;
41110
+ const { waitUntilExit } = render_default(
41111
+ import_react40.default.createElement(SplitApp, {
41112
+ deps: {
41113
+ readToken,
41114
+ getAllChanges,
41115
+ getStagedChanges,
41116
+ parseHunks,
41117
+ buildSplitManifest,
41118
+ extractFilePatches,
41119
+ stageFile,
41120
+ stageLines,
41121
+ stageHunks,
41122
+ resetStaging,
41123
+ buildSelectivePatch,
41124
+ applyPatch,
41125
+ validatePatch,
41126
+ getFileDiff,
41127
+ apiPost: (path, body, tkn) => apiClient.post(path, body, tkn),
41128
+ runGitCommit: runGitCommit2,
41129
+ fileConfig,
41130
+ useStaged
41131
+ },
41132
+ onExit: (code) => {
41133
+ exitCode = code;
41134
+ }
41135
+ })
41136
+ );
41137
+ await waitUntilExit();
41138
+ process.exit(exitCode);
41139
+ }
41140
+
41141
+ // src/commands/whoami.tsx
41142
+ var import_react41 = __toESM(require_react(), 1);
41143
+ var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
39643
41144
  function WhoamiApp({ onExit }) {
39644
41145
  const token = readToken();
39645
41146
  const payload = token ? decodeTokenPayload(token) : null;
39646
- (0, import_react38.useEffect)(() => {
41147
+ (0, import_react41.useEffect)(() => {
39647
41148
  onExit(payload ? 0 : 1);
39648
41149
  }, [onExit, payload]);
39649
41150
  const expiresDate = payload ? new Date(payload.exp * 1e3).toLocaleDateString("pt-BR", {
@@ -39651,26 +41152,26 @@ function WhoamiApp({ onExit }) {
39651
41152
  month: "2-digit",
39652
41153
  year: "numeric"
39653
41154
  }) : null;
39654
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", paddingTop: 1, marginBottom: 1, children: [
39655
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: "cyan", children: "RepoMind" }) }),
39656
- payload ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", gap: 0, children: [
39657
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { gap: 1, children: [
39658
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "green", children: "\u2713" }),
39659
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { children: [
41155
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Box_default, { flexDirection: "column", paddingTop: 1, marginBottom: 1, children: [
41156
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Box_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { bold: true, color: "cyan", children: "RepoMind" }) }),
41157
+ payload ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Box_default, { flexDirection: "column", gap: 0, children: [
41158
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Box_default, { gap: 1, children: [
41159
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { color: "green", children: "\u2713" }),
41160
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Text, { children: [
39660
41161
  "Autenticado como",
39661
41162
  " ",
39662
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: "white", children: payload.email })
41163
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { bold: true, color: "white", children: payload.email })
39663
41164
  ] })
39664
41165
  ] }),
39665
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { gap: 1, paddingLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { dimColor: true, children: [
41166
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Box_default, { gap: 1, paddingLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Text, { dimColor: true, children: [
39666
41167
  "Sess\xE3o v\xE1lida at\xE9 ",
39667
41168
  expiresDate
39668
41169
  ] }) })
39669
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { gap: 1, children: [
39670
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "yellow", children: "\u25C6" }),
39671
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { dimColor: true, children: [
41170
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Box_default, { gap: 1, children: [
41171
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { color: "yellow", children: "\u25C6" }),
41172
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Text, { dimColor: true, children: [
39672
41173
  "N\xE3o autenticado. Execute ",
39673
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: "white", children: "repomind login" }),
41174
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { color: "white", children: "repomind login" }),
39674
41175
  "."
39675
41176
  ] })
39676
41177
  ] })
@@ -39679,7 +41180,7 @@ function WhoamiApp({ onExit }) {
39679
41180
  async function whoamiCommand() {
39680
41181
  let exitCode = 0;
39681
41182
  const { waitUntilExit } = render_default(
39682
- import_react38.default.createElement(WhoamiApp, {
41183
+ import_react41.default.createElement(WhoamiApp, {
39683
41184
  onExit: (code) => {
39684
41185
  exitCode = code;
39685
41186
  }
@@ -39690,10 +41191,13 @@ async function whoamiCommand() {
39690
41191
  }
39691
41192
 
39692
41193
  // src/index.ts
39693
- var [, , command] = process.argv;
41194
+ var args = process.argv.slice(2);
41195
+ var verbose = args.includes("--verbose") || args.includes("-v") || !!process.env.REPOMIND_DEBUG;
41196
+ var command = args.find((a) => !a.startsWith("-"));
39694
41197
  function run(cmd) {
39695
41198
  cmd().catch((err) => {
39696
41199
  console.error("\u2717 Erro inesperado:", err.message);
41200
+ if (verbose) console.error(err);
39697
41201
  process.exit(1);
39698
41202
  });
39699
41203
  }
@@ -39719,6 +41223,9 @@ switch (command) {
39719
41223
  case "explain":
39720
41224
  run(explainCommand);
39721
41225
  break;
41226
+ case "split":
41227
+ run(splitCommand);
41228
+ break;
39722
41229
  default:
39723
41230
  run(helpCommand);
39724
41231
  break;