binary-collections 2.0.10 → 2.0.11

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 (165) hide show
  1. package/.puppeterrc.cjs +25 -0
  2. package/binaries/binary-executor.cjs +138 -3
  3. package/binaries/clean-nodemodule.cjs +138 -3
  4. package/binaries/clean-nodemodules.cjs +138 -3
  5. package/binaries/dev.cjs +138 -3
  6. package/binaries/empty.cjs +138 -3
  7. package/binaries/git-reduce-size.cjs +138 -3
  8. package/binaries/javakill.cjs +138 -3
  9. package/binaries/kill-night-crows.bat +7 -0
  10. package/binaries/kill-night-crows.ps1 +172 -0
  11. package/binaries/kill-process.cjs +138 -3
  12. package/binaries/nodekill.cjs +138 -3
  13. package/binaries/prod.cjs +138 -3
  14. package/binaries/py +111 -0
  15. package/binaries/py.cjs +178 -0
  16. package/binaries/py.cmd +49 -0
  17. package/binaries/rmfind.cjs +138 -3
  18. package/binaries/rmx.cjs +138 -3
  19. package/binaries/submodule-token.cjs +138 -3
  20. package/binaries/test-cjs +10 -0
  21. package/binaries/test-cjs.cjs +178 -0
  22. package/binaries/test-cjs.cmd +11 -0
  23. package/binaries/yarn-clean +32 -0
  24. package/binaries/yarn-clean.cjs +178 -0
  25. package/binaries/yarn-clean.cmd +30 -0
  26. package/binaries/yarn-clean.py +148 -0
  27. package/lib/binary-collections-config.cjs +1 -1
  28. package/lib/binary-collections-config.mjs +1 -1
  29. package/lib/binary-collections.cjs +167 -106
  30. package/lib/binary-collections.mjs +108 -94
  31. package/lib/changelog.cjs +61 -13
  32. package/lib/changelog.mjs +1 -1
  33. package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
  34. package/lib/chunk-34IQDTLZ.mjs +27 -0
  35. package/lib/chunk-3HFFECCI.mjs +27 -0
  36. package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
  37. package/lib/chunk-7XTEJHOE.mjs +193 -0
  38. package/lib/chunk-AJDD5DZM.mjs +109 -0
  39. package/lib/chunk-BZWVHODJ.mjs +62 -0
  40. package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
  41. package/lib/chunk-GEYA2USY.mjs +207 -0
  42. package/lib/chunk-ID2WBTE2.mjs +80 -0
  43. package/lib/chunk-JXFOHKDM.mjs +239 -0
  44. package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
  45. package/lib/chunk-NCXAP7AA.mjs +31 -0
  46. package/lib/chunk-PDN26I7O.mjs +188 -0
  47. package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
  48. package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
  49. package/lib/chunk-V5SKYJUB.mjs +136 -0
  50. package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
  51. package/lib/chunk-XA3SNBPA.mjs +184 -0
  52. package/lib/chunk-YYLIQQKF.mjs +31 -0
  53. package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
  54. package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
  55. package/lib/clean-github-actions-caches.cjs +63 -15
  56. package/lib/clean-github-actions-caches.mjs +3 -3
  57. package/lib/del-gradle.cjs +61 -13
  58. package/lib/del-gradle.js +1 -0
  59. package/lib/del-gradle.mjs +1 -1
  60. package/lib/del-node-modules.cjs +143 -148
  61. package/lib/del-node-modules.js +210 -14
  62. package/lib/del-node-modules.mjs +148 -17
  63. package/lib/del-ps.cjs +61 -13
  64. package/lib/del-ps.js +1 -0
  65. package/lib/del-ps.mjs +1 -1
  66. package/lib/del-yarn-caches.cjs +61 -13
  67. package/lib/del-yarn-caches.mjs +1 -1
  68. package/lib/find-node-modules-cli.js +1 -0
  69. package/lib/free-chatgpt.cjs +253 -47
  70. package/lib/free-chatgpt.mjs +2 -2
  71. package/lib/git/gitattributes.cjs +1 -0
  72. package/lib/git/gitattributes.d.cts +7 -2
  73. package/lib/git/gitattributes.mjs +1 -1
  74. package/lib/git/line-endings.cjs +2 -1
  75. package/lib/git/line-endings.mjs +2 -2
  76. package/lib/git/undo-commit-cli.cjs +110 -0
  77. package/lib/git/undo-commit-cli.d.ts +1 -0
  78. package/lib/git/undo-commit-cli.js +4 -0
  79. package/lib/git/undo-commit-cli.mjs +14 -0
  80. package/lib/git/undo-commit.cjs +81 -0
  81. package/lib/git/undo-commit.d.cts +1 -0
  82. package/lib/git/undo-commit.mjs +7 -0
  83. package/lib/git/undo-staged-cli.cjs +110 -0
  84. package/lib/git/undo-staged-cli.d.ts +1 -0
  85. package/lib/git/undo-staged-cli.js +4 -0
  86. package/lib/git/undo-staged-cli.mjs +14 -0
  87. package/lib/git/undo-staged.cjs +81 -0
  88. package/lib/git/undo-staged.d.cts +1 -0
  89. package/lib/git/undo-staged.mjs +7 -0
  90. package/lib/git/user-config.cjs +61 -14
  91. package/lib/git/user-config.mjs +2 -2
  92. package/lib/git-diff-cli.cjs +255 -49
  93. package/lib/git-diff-cli.d.ts +1 -0
  94. package/lib/git-diff-cli.js +1 -0
  95. package/lib/git-diff-cli.mjs +5 -4
  96. package/lib/git-diff.cjs +254 -49
  97. package/lib/git-diff.mjs +4 -4
  98. package/lib/git-fix.cjs +64 -16
  99. package/lib/git-fix.mjs +10 -10
  100. package/lib/git-purge.cjs +61 -13
  101. package/lib/git-purge.mjs +1 -1
  102. package/lib/kill-night-crows.cjs +87 -0
  103. package/lib/kill-night-crows.d.mts +1 -0
  104. package/lib/kill-night-crows.mjs +65 -0
  105. package/lib/npm-run-series.cjs +60 -13
  106. package/lib/npm-run-series.mjs +1 -1
  107. package/lib/package-resolutions-updater-cli.cjs +560 -0
  108. package/lib/package-resolutions-updater-cli.d.mts +1 -0
  109. package/lib/package-resolutions-updater-cli.mjs +124 -0
  110. package/lib/package-resolutions-updater.cjs +174 -154
  111. package/lib/package-resolutions-updater.d.mts +32 -1
  112. package/lib/package-resolutions-updater.mjs +16 -294
  113. package/lib/php-cs-fixer-staged.cjs +105 -0
  114. package/lib/php-cs-fixer-staged.d.cts +2 -0
  115. package/lib/php-cs-fixer-staged.mjs +117 -0
  116. package/lib/print-directory-tree.cjs +62 -14
  117. package/lib/print-directory-tree.mjs +2 -2
  118. package/lib/ps/connected-domain.d.ts +1 -1
  119. package/lib/ps/index.js +1 -0
  120. package/lib/remove-module.cjs +61 -13
  121. package/lib/remove-module.mjs +1 -1
  122. package/lib/rmpath.cjs +63 -15
  123. package/lib/rmpath.mjs +2 -2
  124. package/lib/submodule-install.cjs +62 -15
  125. package/lib/submodule-install.mjs +3 -3
  126. package/lib/submodule-remove-cli.cjs +5 -1
  127. package/lib/submodule-remove-cli.mjs +1 -1
  128. package/lib/submodule-remove.cjs +4 -1
  129. package/lib/submodule-remove.mjs +1 -1
  130. package/lib/utils/chatgpt.cjs +192 -34
  131. package/lib/utils/chatgpt.js +210 -43
  132. package/lib/utils/chatgpt.mjs +1 -1
  133. package/lib/utils/findEnvFiles.cjs +107 -0
  134. package/lib/utils/findEnvFiles.d.ts +8 -0
  135. package/lib/utils/findEnvFiles.js +121 -0
  136. package/lib/utils/findEnvFiles.mjs +8 -0
  137. package/lib/utils/findWorkspaceRoot.cjs +70 -0
  138. package/lib/utils/findWorkspaceRoot.d.ts +9 -0
  139. package/lib/utils/findWorkspaceRoot.js +57 -0
  140. package/lib/utils/findWorkspaceRoot.mjs +40 -0
  141. package/lib/utils/index.cjs +60 -13
  142. package/lib/utils/index.mjs +1 -1
  143. package/lib/utils/isGithubTokenValid.cjs +64 -0
  144. package/lib/utils/isGithubTokenValid.d.ts +7 -0
  145. package/lib/utils/isGithubTokenValid.js +48 -0
  146. package/lib/utils/isGithubTokenValid.mjs +36 -0
  147. package/lib/yarn-reinstall.cjs +61 -13
  148. package/lib/yarn-reinstall.mjs +1 -1
  149. package/package.json +107 -93
  150. package/readme.md +33 -34
  151. package/releases/readme.md +1 -1
  152. package/requirements.txt +1 -0
  153. package/lib/chunk-4EWQC6GZ.mjs +0 -382
  154. package/lib/chunk-4ZI7BQKQ.mjs +0 -381
  155. package/lib/chunk-5J2BEPY5.mjs +0 -83
  156. package/lib/chunk-AGZYRDC2.mjs +0 -323
  157. package/lib/chunk-HN52G2YL.mjs +0 -305
  158. package/lib/chunk-HO6GHCOB.mjs +0 -385
  159. package/lib/chunk-LEM5OMRP.mjs +0 -384
  160. package/lib/chunk-RCP7DHVY.mjs +0 -190
  161. package/lib/chunk-U6SO4QEV.mjs +0 -320
  162. package/lib/chunk-XD6BJK6Q.mjs +0 -351
  163. package/lib/chunk-YXSFGA2D.mjs +0 -383
  164. package/lib/git/gitattributes.d.ts +0 -33
  165. package/lib/git/gitattributes.js +0 -223
package/lib/git-diff.cjs CHANGED
@@ -37,7 +37,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
39
  "node_modules/tsup/assets/cjs_shims.js"() {
40
- getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
40
+ getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
41
41
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
42
42
  }
43
43
  });
@@ -47,7 +47,7 @@ var require_binary_collections_config = __commonJS({
47
47
  "src/binary-collections-config.cjs"(exports2, module2) {
48
48
  init_cjs_shims();
49
49
  var path3 = require("path");
50
- require("dotenv").config({ path: path3.join(process.cwd(), ".env") });
50
+ require("dotenv").config({ path: path3.join(process.cwd(), ".env"), quiet: true, override: true });
51
51
  function getTempDir() {
52
52
  return process.env.TEMP_DIR || path3.join(process.cwd(), "tmp");
53
53
  }
@@ -118,31 +118,78 @@ var require_utils = __commonJS({
118
118
  }
119
119
  module2.exports.getArgs = getArgs2;
120
120
  function del(fullPath) {
121
- if (fs3.statSync(fullPath).isDirectory()) {
122
- const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
123
- for (let i = 0; i < subdir.length; i++) {
124
- del(subdir[i]);
121
+ try {
122
+ if (!fs3.existsSync(fullPath)) return;
123
+ const stat = fs3.lstatSync(fullPath);
124
+ if (stat.isSymbolicLink()) {
125
+ try {
126
+ fs3.unlinkSync(fullPath);
127
+ console.log("deleted symlink", fullPath);
128
+ } catch (e) {
129
+ console.log("failed delete symlink", fullPath, e && e.message);
130
+ }
131
+ return;
132
+ }
133
+ if (stat.isDirectory()) {
134
+ const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
135
+ for (let i = 0; i < subdir.length; i++) {
136
+ del(subdir[i]);
137
+ }
138
+ try {
139
+ fs3.rmdirSync(fullPath);
140
+ console.log("deleted", fullPath);
141
+ } catch (e) {
142
+ try {
143
+ fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
144
+ console.log("deleted", fullPath);
145
+ } catch (ee) {
146
+ console.log("failed delete", fullPath, ee && ee.message);
147
+ }
148
+ }
149
+ return;
125
150
  }
126
- } else {
127
151
  try {
128
- fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
152
+ fs3.unlinkSync(fullPath);
129
153
  console.log("deleted", fullPath);
130
- } catch (_) {
131
- console.log("failed delete", fullPath);
154
+ } catch (e) {
155
+ try {
156
+ fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
157
+ console.log("deleted", fullPath);
158
+ } catch (ee) {
159
+ console.log("failed delete", fullPath, ee && ee.message);
160
+ }
132
161
  }
162
+ } catch (err) {
163
+ console.log("failed delete", fullPath, err && err.message);
133
164
  }
134
165
  }
135
166
  module2.exports.del = del;
136
167
  function delStream(globStream) {
137
168
  globStream.stream().on("data", (result) => {
138
169
  const fullPath = path3.resolve(process.cwd(), result);
139
- if (fs3.statSync(fullPath).isDirectory()) {
140
- const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
141
- for (let i = 0; i < subdir.length; i++) {
142
- del(subdir[i]);
170
+ try {
171
+ if (fs3.existsSync(fullPath)) {
172
+ const stat = fs3.lstatSync(fullPath);
173
+ if (stat.isSymbolicLink()) {
174
+ try {
175
+ fs3.unlinkSync(fullPath);
176
+ console.log("deleted symlink", fullPath);
177
+ } catch (e) {
178
+ console.log("failed delete symlink", fullPath, e && e.message);
179
+ }
180
+ return;
181
+ }
182
+ if (stat.isDirectory()) {
183
+ const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
184
+ for (let i = 0; i < subdir.length; i++) {
185
+ del(subdir[i]);
186
+ }
187
+ }
143
188
  }
189
+ del(fullPath);
190
+ } catch (err) {
191
+ console.log("failed processing", fullPath, err && err.message);
144
192
  }
145
- del(fullPath);
146
193
  });
147
194
  }
148
195
  module2.exports.delStream = delStream;
@@ -216,7 +263,17 @@ var import_puppeteer_extra_plugin_stealth = __toESM(require("puppeteer-extra-plu
216
263
  var import_upath = __toESM(require("upath"), 1);
217
264
  var COOKIE_DIR = import_upath.default.join(process.cwd(), "tmp", "cookies");
218
265
  var DEFAULT_COOKIE_PATH = import_upath.default.join(COOKIE_DIR, "cookies.json");
266
+ var NAVIGATION_TIMEOUT_MS = 9e4;
267
+ var NETWORK_IDLE_TIMEOUT_MS = 15e3;
268
+ var MAX_INLINE_QUESTION_FILE_BYTES = 2 * 1024;
219
269
  import_fs_extra.default.ensureDirSync(COOKIE_DIR);
270
+ async function gotoWithFallback(page, url) {
271
+ await page.goto(url, { waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
272
+ try {
273
+ await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
274
+ } catch {
275
+ }
276
+ }
220
277
  async function saveCookies(page, path3 = DEFAULT_COOKIE_PATH) {
221
278
  const cookies = await page.cookies();
222
279
  import_fs_extra.default.writeFileSync(path3, JSON.stringify(cookies, null, 2));
@@ -235,7 +292,7 @@ async function navigatePage(page, url) {
235
292
  if (cookies) {
236
293
  await page.setCookie(...cookies);
237
294
  }
238
- await page.goto(url, { waitUntil: "networkidle0" });
295
+ await gotoWithFallback(page, url);
239
296
  await page.evaluate(() => {
240
297
  window.__domStillUpdating = true;
241
298
  if (window.__domObserver) {
@@ -275,46 +332,151 @@ function loadCookies(cookieFilePath = DEFAULT_COOKIE_PATH) {
275
332
  return JSON.parse(import_fs_extra.default.readFileSync(cookieFilePath));
276
333
  }
277
334
  async function writeQuestion(page, question) {
278
- const questions = question.split("\n");
279
335
  const promptTextarea = await page.waitForSelector("#prompt-textarea", { timeout: 3e4 });
280
336
  if (!promptTextarea) {
281
337
  console.log(
282
338
  "Cannot find the prompt input on the webpage. Please check whether you have access to chat.openai.com without logging in via your browser."
283
339
  );
284
- }
285
- await page.evaluate(() => {
286
- document.querySelector("#prompt-textarea").innerHTML = `<p></p>`;
287
- });
288
- if (questions.length === 1) {
289
- await page.type("#prompt-textarea", questions[0], { delay: 100 });
290
340
  return;
291
341
  }
292
- for (const q of questions) {
293
- await page.type("#prompt-textarea", q, { delay: 100 });
294
- if (q !== questions[questions.length - 1]) {
295
- await page.keyboard.down("Shift");
296
- await page.keyboard.press("Enter");
297
- await page.keyboard.up("Shift");
342
+ await page.evaluate((text) => {
343
+ const promptEl = document.querySelector("#prompt-textarea");
344
+ if (!promptEl) {
345
+ return;
298
346
  }
347
+ promptEl.focus();
348
+ promptEl.innerHTML = "";
349
+ const lines = String(text).split("\n");
350
+ for (const line of lines) {
351
+ const p = document.createElement("p");
352
+ p.textContent = line;
353
+ promptEl.appendChild(p);
354
+ }
355
+ promptEl.dispatchEvent(new InputEvent("beforeinput", { bubbles: true, inputType: "insertFromPaste", data: text }));
356
+ promptEl.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertFromPaste", data: text }));
357
+ promptEl.dispatchEvent(new Event("change", { bubbles: true }));
358
+ }, question);
359
+ const hasPromptText = await page.evaluate(() => {
360
+ const promptEl = document.querySelector("#prompt-textarea");
361
+ return Boolean(promptEl && promptEl.textContent && promptEl.textContent.trim().length > 0);
362
+ });
363
+ if (!hasPromptText) {
364
+ console.log("Prompt state not updated by DOM injection. Falling back to keyboard insertText.");
365
+ await promptTextarea.click({ clickCount: 1 });
366
+ await page.keyboard.down("Control");
367
+ await page.keyboard.press("KeyA");
368
+ await page.keyboard.up("Control");
369
+ await page.keyboard.insertText(question);
299
370
  }
300
371
  }
301
372
  async function clickSubmitButton(page) {
373
+ console.log("Attempting to click the submit button...");
302
374
  try {
303
- const fruitjuiceSendButton = await page.evaluate(() => {
304
- return document.querySelector('[data-testid="fruitjuice-send-button"]') !== null;
375
+ const userMessageCountBefore = await page.$$eval('[data-message-author-role="user"]', (elements) => elements.length);
376
+ const waitForSubmit = async (timeout = 5e3) => {
377
+ try {
378
+ await page.waitForFunction(
379
+ (previousCount) => {
380
+ const currentCount = document.querySelectorAll('[data-message-author-role="user"]').length;
381
+ return currentCount > previousCount;
382
+ },
383
+ { timeout },
384
+ userMessageCountBefore
385
+ );
386
+ return true;
387
+ } catch {
388
+ return false;
389
+ }
390
+ };
391
+ await page.waitForFunction(() => {
392
+ const candidates = [
393
+ document.querySelector('[data-testid="fruitjuice-send-button"]'),
394
+ document.querySelector("#composer-submit-button"),
395
+ document.querySelector('[data-testid="send-button"]')
396
+ ].filter(Boolean);
397
+ return candidates.some((button) => {
398
+ const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
399
+ const isVisible = button.offsetParent !== null;
400
+ return !isDisabled && isVisible;
401
+ });
402
+ }, { timeout: 5e3 }).catch(() => {
305
403
  });
306
- const sendButton = await page.evaluate(() => {
307
- return document.querySelector('[data-testid="send-button"]') !== null;
404
+ const buttonDetails = await page.evaluate(() => {
405
+ const selectors = [
406
+ '[data-testid="fruitjuice-send-button"]',
407
+ "#composer-submit-button",
408
+ '[data-testid="send-button"]'
409
+ ];
410
+ const details = selectors.map((selector) => {
411
+ const el = document.querySelector(selector);
412
+ const exists = Boolean(el);
413
+ const disabled = exists ? Boolean(el.disabled || el.getAttribute("aria-disabled") === "true") : null;
414
+ const visible = exists ? el.offsetParent !== null : null;
415
+ return { selector, exists, disabled, visible };
416
+ });
417
+ return details;
308
418
  });
309
- if (fruitjuiceSendButton) {
310
- await page.click('[data-testid="fruitjuice-send-button"]');
311
- } else if (sendButton) {
312
- await page.click('[data-testid="send-button"]');
313
- } else {
314
- console.log("Neither send button is present");
419
+ console.log(`Submit button details: ${JSON.stringify(buttonDetails)}`);
420
+ const clickable = buttonDetails.find((item) => item.exists && item.visible && item.disabled === false);
421
+ const selectedSelector = clickable ? clickable.selector : null;
422
+ if (selectedSelector) {
423
+ await page.click(selectedSelector);
424
+ console.log(`Clicked submit button selector: ${selectedSelector}`);
425
+ if (await waitForSubmit(5e3)) {
426
+ console.log("Submission detected after selector click.");
427
+ return true;
428
+ }
429
+ const forcedClickWorked = await page.evaluate((selector) => {
430
+ const el = document.querySelector(selector);
431
+ if (!el) {
432
+ return false;
433
+ }
434
+ el.click();
435
+ return true;
436
+ }, selectedSelector);
437
+ if (forcedClickWorked) {
438
+ console.log(`Forced DOM click on selector: ${selectedSelector}`);
439
+ if (await waitForSubmit(5e3)) {
440
+ console.log("Submission detected after forced DOM click.");
441
+ return true;
442
+ }
443
+ }
444
+ }
445
+ console.log("Submit button path did not submit. Trying Enter key fallback on prompt.");
446
+ await page.focus("#prompt-textarea");
447
+ await page.keyboard.press("Enter");
448
+ if (await waitForSubmit(5e3)) {
449
+ console.log("Submission detected after Enter key fallback.");
450
+ return true;
451
+ }
452
+ const didRequestSubmit = await page.evaluate(() => {
453
+ const prompt = document.querySelector("#prompt-textarea");
454
+ if (!prompt) {
455
+ return false;
456
+ }
457
+ const form = prompt.closest("form");
458
+ if (!form) {
459
+ return false;
460
+ }
461
+ if (typeof form.requestSubmit === "function") {
462
+ form.requestSubmit();
463
+ } else {
464
+ form.submit();
465
+ }
466
+ return true;
467
+ });
468
+ if (didRequestSubmit) {
469
+ console.log("Triggered form submit fallback.");
470
+ if (await waitForSubmit(5e3)) {
471
+ console.log("Submission detected after form submit fallback.");
472
+ return true;
473
+ }
315
474
  }
475
+ console.log("Failed to submit prompt after all strategies.");
476
+ return false;
316
477
  } catch (e) {
317
478
  console.log(`Failed to click the send button: ${e}`);
479
+ return false;
318
480
  }
319
481
  }
320
482
  var lastMessageId = null;
@@ -387,11 +549,15 @@ async function isLoggedIn(page) {
387
549
  return result === true;
388
550
  }
389
551
  async function createBrowser(browserOptions = {}) {
552
+ const windowsChromeExecutable = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
553
+ const hasWindowsChrome = process.platform === "win32" && import_fs_extra.default.existsSync(windowsChromeExecutable);
390
554
  const defaultOptions = {
391
555
  headless: false,
556
+ defaultViewport: null,
392
557
  userDataDir: import_upath.default.join(process.cwd(), "tmp/puppeteer-profile"),
393
558
  // Windows-specific options to handle browser launch issues
394
559
  args: [
560
+ "--start-maximized",
395
561
  "--no-sandbox",
396
562
  "--disable-setuid-sandbox",
397
563
  "--disable-dev-shm-usage",
@@ -404,10 +570,9 @@ async function createBrowser(browserOptions = {}) {
404
570
  "--disable-renderer-backgrounding"
405
571
  ],
406
572
  ignoreDefaultArgs: ["--disable-extensions"],
407
- ...process.platform === "win32" && {
408
- // Additional Windows-specific options
409
- executablePath: void 0
410
- // Let Puppeteer find Chrome automatically
573
+ ...hasWindowsChrome && {
574
+ // Prefer local Chrome installation when present on Windows.
575
+ executablePath: windowsChromeExecutable
411
576
  }
412
577
  };
413
578
  try {
@@ -417,8 +582,12 @@ async function createBrowser(browserOptions = {}) {
417
582
  try {
418
583
  return await import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)()).launch({
419
584
  headless: browserOptions.headless || false,
420
- args: ["--no-sandbox", "--disable-setuid-sandbox"],
585
+ defaultViewport: null,
586
+ args: ["--start-maximized", "--no-sandbox", "--disable-setuid-sandbox"],
421
587
  ignoreDefaultArgs: false,
588
+ ...hasWindowsChrome && {
589
+ executablePath: windowsChromeExecutable
590
+ },
422
591
  ...browserOptions
423
592
  });
424
593
  } catch (fallbackError) {
@@ -443,7 +612,11 @@ async function loginToChatGpt() {
443
612
  if (loginButtonExists) {
444
613
  console.log("Login button found, clicking to log in...");
445
614
  await page.click('[data-testid="login-button"]');
446
- await page.waitForNavigation({ waitUntil: "networkidle0" });
615
+ await page.waitForNavigation({ waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
616
+ try {
617
+ await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
618
+ } catch {
619
+ }
447
620
  console.log("Login process completed.");
448
621
  } else {
449
622
  console.log("No login required - user appears to be already logged in.");
@@ -453,6 +626,7 @@ async function runChatGpt(chatgptOptions = {}) {
453
626
  const headless = chatgptOptions.headless !== void 0 ? chatgptOptions.headless : true;
454
627
  const questionFile = chatgptOptions.questionFile;
455
628
  let question = chatgptOptions.question;
629
+ let shouldUploadQuestionFile = Boolean(questionFile);
456
630
  const responseFile = chatgptOptions.responseFile || import_upath.default.join(process.cwd(), "tmp", "response.txt");
457
631
  const noInputProvided = !question && !questionFile;
458
632
  const questionIsEmpty = question && question.trim().length === 0;
@@ -460,6 +634,22 @@ async function runChatGpt(chatgptOptions = {}) {
460
634
  if (noInputProvided || questionIsEmpty || questionFileIsEmpty) {
461
635
  throw new Error("You must provide a question or a question file.");
462
636
  }
637
+ if (!question && questionFile) {
638
+ if (!import_fs_extra.default.existsSync(questionFile)) {
639
+ throw new Error(`Question file does not exist: ${questionFile}`);
640
+ }
641
+ const questionFileStats = import_fs_extra.default.statSync(questionFile);
642
+ if (questionFileStats.size <= MAX_INLINE_QUESTION_FILE_BYTES) {
643
+ question = import_fs_extra.default.readFileSync(questionFile, "utf8").trim();
644
+ if (!question) {
645
+ throw new Error("Question file is empty.");
646
+ }
647
+ shouldUploadQuestionFile = false;
648
+ console.log(
649
+ `Question file is ${questionFileStats.size} bytes (<= ${MAX_INLINE_QUESTION_FILE_BYTES}). Sending as text prompt.`
650
+ );
651
+ }
652
+ }
463
653
  let browser;
464
654
  try {
465
655
  browser = await createBrowser({ headless });
@@ -472,7 +662,16 @@ async function runChatGpt(chatgptOptions = {}) {
472
662
  console.error("4. Close any running Chrome instances and try again");
473
663
  throw error;
474
664
  }
475
- const page = (await browser.pages()).length > 0 ? (await browser.pages())[0] : await browser.newPage();
665
+ const allPages = await browser.pages();
666
+ const page = allPages.length > 0 ? allPages[0] : await browser.newPage();
667
+ await page.bringToFront();
668
+ if (allPages.length > 1) {
669
+ for (const p of allPages) {
670
+ if (p !== page) {
671
+ await p.close();
672
+ }
673
+ }
674
+ }
476
675
  try {
477
676
  const url = "https://chat.openai.com";
478
677
  const navigate = await navigatePage(page, url);
@@ -491,12 +690,15 @@ async function runChatGpt(chatgptOptions = {}) {
491
690
  }
492
691
  if (question) {
493
692
  await writeQuestion(page, question);
494
- await clickSubmitButton(page);
693
+ const didSubmit = await clickSubmitButton(page);
694
+ if (!didSubmit) {
695
+ throw new Error("Prompt was not submitted. The composer button may be disabled or blocked.");
696
+ }
495
697
  await navigate.waitForDomIdle(1e3, 3e4);
496
698
  await waitForInitialResponse(page);
497
699
  await handleStreamingResponse(page, responseFile);
498
700
  await saveCookies(page, getCookiePathForUrl(url));
499
- } else if (questionFile) {
701
+ } else if (shouldUploadQuestionFile && questionFile) {
500
702
  await navigate.waitForDomIdle(2e3, 1e4);
501
703
  const isUserLoggedIn = await isLoggedIn(page);
502
704
  console.log(`Login status: ${isUserLoggedIn ? "Logged in" : "Not logged in"}`);
@@ -535,7 +737,10 @@ async function runChatGpt(chatgptOptions = {}) {
535
737
  await fileInput.uploadFile(questionFile);
536
738
  await navigate.waitForDomIdle(2e3, 15e3);
537
739
  console.log("File uploaded successfully");
538
- await clickSubmitButton(page);
740
+ const didSubmit = await clickSubmitButton(page);
741
+ if (!didSubmit) {
742
+ throw new Error("Prompt was not submitted after file upload.");
743
+ }
539
744
  await navigate.waitForDomIdle(1e3, 3e4);
540
745
  await waitForInitialResponse(page);
541
746
  await handleStreamingResponse(page, responseFile);
package/lib/git-diff.mjs CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  git_diff_default,
10
10
  mainGitDiff,
11
11
  runGitDiff
12
- } from "./chunk-SBNDSKG5.mjs";
13
- import "./chunk-GJTGHXRA.mjs";
14
- import "./chunk-66PAU5PS.mjs";
15
- import "./chunk-V3N3JEUF.mjs";
12
+ } from "./chunk-FCDQGYBF.mjs";
13
+ import "./chunk-N436BNBK.mjs";
14
+ import "./chunk-YYLIQQKF.mjs";
15
+ import "./chunk-Z6JLYU2J.mjs";
16
16
  import "./chunk-QQ4A6DLD.mjs";
17
17
  export {
18
18
  CACHE_DIR,
package/lib/git-fix.cjs CHANGED
@@ -243,6 +243,7 @@ var require_gitattributes = __commonJS({
243
243
  formatGitAttributes,
244
244
  updateGitAttributes
245
245
  };
246
+ module2.exports.default = module2.exports;
246
247
  }
247
248
  });
248
249
 
@@ -253,7 +254,7 @@ var require_line_endings = __commonJS({
253
254
  var path2 = require("upath");
254
255
  var fs = require("fs");
255
256
  var { runGitCommand } = require_utils();
256
- var { updateGitAttributes } = require_gitattributes().default;
257
+ var { updateGitAttributes } = require_gitattributes();
257
258
  function forceLfLineEndings2() {
258
259
  console.log("\n=== Configuring LF Line Endings ===");
259
260
  runGitCommand(["config", "core.autocrlf", "false"], "Disable automatic CRLF conversion");
@@ -397,31 +398,78 @@ var require_utils2 = __commonJS({
397
398
  }
398
399
  module2.exports.getArgs = getArgs2;
399
400
  function del(fullPath) {
400
- if (fs.statSync(fullPath).isDirectory()) {
401
- const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
402
- for (let i = 0; i < subdir.length; i++) {
403
- del(subdir[i]);
401
+ try {
402
+ if (!fs.existsSync(fullPath)) return;
403
+ const stat = fs.lstatSync(fullPath);
404
+ if (stat.isSymbolicLink()) {
405
+ try {
406
+ fs.unlinkSync(fullPath);
407
+ console.log("deleted symlink", fullPath);
408
+ } catch (e) {
409
+ console.log("failed delete symlink", fullPath, e && e.message);
410
+ }
411
+ return;
412
+ }
413
+ if (stat.isDirectory()) {
414
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
415
+ for (let i = 0; i < subdir.length; i++) {
416
+ del(subdir[i]);
417
+ }
418
+ try {
419
+ fs.rmdirSync(fullPath);
420
+ console.log("deleted", fullPath);
421
+ } catch (e) {
422
+ try {
423
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
424
+ console.log("deleted", fullPath);
425
+ } catch (ee) {
426
+ console.log("failed delete", fullPath, ee && ee.message);
427
+ }
428
+ }
429
+ return;
404
430
  }
405
- } else {
406
431
  try {
407
- fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
432
+ fs.unlinkSync(fullPath);
408
433
  console.log("deleted", fullPath);
409
- } catch (_) {
410
- console.log("failed delete", fullPath);
434
+ } catch (e) {
435
+ try {
436
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
437
+ console.log("deleted", fullPath);
438
+ } catch (ee) {
439
+ console.log("failed delete", fullPath, ee && ee.message);
440
+ }
411
441
  }
442
+ } catch (err) {
443
+ console.log("failed delete", fullPath, err && err.message);
412
444
  }
413
445
  }
414
446
  module2.exports.del = del;
415
447
  function delStream(globStream) {
416
448
  globStream.stream().on("data", (result) => {
417
449
  const fullPath = path2.resolve(process.cwd(), result);
418
- if (fs.statSync(fullPath).isDirectory()) {
419
- const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
420
- for (let i = 0; i < subdir.length; i++) {
421
- del(subdir[i]);
450
+ try {
451
+ if (fs.existsSync(fullPath)) {
452
+ const stat = fs.lstatSync(fullPath);
453
+ if (stat.isSymbolicLink()) {
454
+ try {
455
+ fs.unlinkSync(fullPath);
456
+ console.log("deleted symlink", fullPath);
457
+ } catch (e) {
458
+ console.log("failed delete symlink", fullPath, e && e.message);
459
+ }
460
+ return;
461
+ }
462
+ if (stat.isDirectory()) {
463
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
464
+ for (let i = 0; i < subdir.length; i++) {
465
+ del(subdir[i]);
466
+ }
467
+ }
422
468
  }
469
+ del(fullPath);
470
+ } catch (err) {
471
+ console.log("failed processing", fullPath, err && err.message);
423
472
  }
424
- del(fullPath);
425
473
  });
426
474
  }
427
475
  module2.exports.delStream = delStream;
@@ -474,7 +522,7 @@ var require_user_config = __commonJS({
474
522
  var gch = require("git-command-helper");
475
523
  var { runGitCommand, runGitCommandOutput } = require_utils();
476
524
  var { getArgs: getArgs2 } = require_utils2();
477
- require("dotenv").config({ path: require("path").join(process.cwd(), ".env") });
525
+ require("dotenv").config({ path: require("path").join(process.cwd(), ".env"), quiet: true });
478
526
  function configureGitUser2(cliUser = null, cliEmail = null, options2 = {}) {
479
527
  console.log("\n=== Configuring Git User ===");
480
528
  let username, email;
@@ -608,7 +656,7 @@ var { configureGitUser } = require_user_config();
608
656
  var { normalizeLineEndings } = require_normalize();
609
657
  var { getArgs } = require_utils2();
610
658
  var path = require("upath");
611
- require("dotenv").config({ path: path.join(process.cwd(), ".env") });
659
+ require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true, override: true });
612
660
  function showHelp() {
613
661
  console.log("Git Fix Utility");
614
662
  console.log("----------------------------");
package/lib/git-fix.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
+ import {
4
+ require_pull_strategy
5
+ } from "./chunk-A2JQXI5Z.mjs";
6
+ import {
7
+ require_user_config
8
+ } from "./chunk-AJDD5DZM.mjs";
3
9
  import {
4
10
  require_line_endings
5
- } from "./chunk-O6SWBEOQ.mjs";
6
- import "./chunk-PDSXF5HY.mjs";
11
+ } from "./chunk-ZDMWBSYF.mjs";
12
+ import "./chunk-PDN26I7O.mjs";
7
13
  import {
8
14
  require_normalize
9
15
  } from "./chunk-HLGOWBEO.mjs";
10
16
  import {
11
17
  require_permissions
12
18
  } from "./chunk-7YD7IPFF.mjs";
13
- import {
14
- require_pull_strategy
15
- } from "./chunk-A2JQXI5Z.mjs";
16
- import {
17
- require_user_config
18
- } from "./chunk-E6FDDAOO.mjs";
19
19
  import {
20
20
  require_utils as require_utils2
21
21
  } from "./chunk-A3VUZEJK.mjs";
22
22
  import {
23
23
  require_utils
24
- } from "./chunk-V3N3JEUF.mjs";
24
+ } from "./chunk-Z6JLYU2J.mjs";
25
25
  import {
26
26
  __commonJS,
27
27
  __require,
@@ -40,7 +40,7 @@ var require_git_fix = __commonJS({
40
40
  var { normalizeLineEndings } = require_normalize();
41
41
  var { getArgs } = require_utils();
42
42
  var path = __require("upath");
43
- __require("dotenv").config({ path: path.join(process.cwd(), ".env") });
43
+ __require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true, override: true });
44
44
  function showHelp() {
45
45
  console.log("Git Fix Utility");
46
46
  console.log("----------------------------");