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.
- package/.puppeterrc.cjs +25 -0
- package/binaries/binary-executor.cjs +138 -3
- package/binaries/clean-nodemodule.cjs +138 -3
- package/binaries/clean-nodemodules.cjs +138 -3
- package/binaries/dev.cjs +138 -3
- package/binaries/empty.cjs +138 -3
- package/binaries/git-reduce-size.cjs +138 -3
- package/binaries/javakill.cjs +138 -3
- package/binaries/kill-night-crows.bat +7 -0
- package/binaries/kill-night-crows.ps1 +172 -0
- package/binaries/kill-process.cjs +138 -3
- package/binaries/nodekill.cjs +138 -3
- package/binaries/prod.cjs +138 -3
- package/binaries/py +111 -0
- package/binaries/py.cjs +178 -0
- package/binaries/py.cmd +49 -0
- package/binaries/rmfind.cjs +138 -3
- package/binaries/rmx.cjs +138 -3
- package/binaries/submodule-token.cjs +138 -3
- package/binaries/test-cjs +10 -0
- package/binaries/test-cjs.cjs +178 -0
- package/binaries/test-cjs.cmd +11 -0
- package/binaries/yarn-clean +32 -0
- package/binaries/yarn-clean.cjs +178 -0
- package/binaries/yarn-clean.cmd +30 -0
- package/binaries/yarn-clean.py +148 -0
- package/lib/binary-collections-config.cjs +1 -1
- package/lib/binary-collections-config.mjs +1 -1
- package/lib/binary-collections.cjs +167 -106
- package/lib/binary-collections.mjs +108 -94
- package/lib/changelog.cjs +61 -13
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
- package/lib/chunk-34IQDTLZ.mjs +27 -0
- package/lib/chunk-3HFFECCI.mjs +27 -0
- package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
- package/lib/chunk-7XTEJHOE.mjs +193 -0
- package/lib/chunk-AJDD5DZM.mjs +109 -0
- package/lib/chunk-BZWVHODJ.mjs +62 -0
- package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
- package/lib/chunk-GEYA2USY.mjs +207 -0
- package/lib/chunk-ID2WBTE2.mjs +80 -0
- package/lib/chunk-JXFOHKDM.mjs +239 -0
- package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
- package/lib/chunk-NCXAP7AA.mjs +31 -0
- package/lib/chunk-PDN26I7O.mjs +188 -0
- package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
- package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
- package/lib/chunk-V5SKYJUB.mjs +136 -0
- package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
- package/lib/chunk-XA3SNBPA.mjs +184 -0
- package/lib/chunk-YYLIQQKF.mjs +31 -0
- package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
- package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
- package/lib/clean-github-actions-caches.cjs +63 -15
- package/lib/clean-github-actions-caches.mjs +3 -3
- package/lib/del-gradle.cjs +61 -13
- package/lib/del-gradle.js +1 -0
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.cjs +143 -148
- package/lib/del-node-modules.js +210 -14
- package/lib/del-node-modules.mjs +148 -17
- package/lib/del-ps.cjs +61 -13
- package/lib/del-ps.js +1 -0
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +61 -13
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/find-node-modules-cli.js +1 -0
- package/lib/free-chatgpt.cjs +253 -47
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/gitattributes.cjs +1 -0
- package/lib/git/gitattributes.d.cts +7 -2
- package/lib/git/gitattributes.mjs +1 -1
- package/lib/git/line-endings.cjs +2 -1
- package/lib/git/line-endings.mjs +2 -2
- package/lib/git/undo-commit-cli.cjs +110 -0
- package/lib/git/undo-commit-cli.d.ts +1 -0
- package/lib/git/undo-commit-cli.js +4 -0
- package/lib/git/undo-commit-cli.mjs +14 -0
- package/lib/git/undo-commit.cjs +81 -0
- package/lib/git/undo-commit.d.cts +1 -0
- package/lib/git/undo-commit.mjs +7 -0
- package/lib/git/undo-staged-cli.cjs +110 -0
- package/lib/git/undo-staged-cli.d.ts +1 -0
- package/lib/git/undo-staged-cli.js +4 -0
- package/lib/git/undo-staged-cli.mjs +14 -0
- package/lib/git/undo-staged.cjs +81 -0
- package/lib/git/undo-staged.d.cts +1 -0
- package/lib/git/undo-staged.mjs +7 -0
- package/lib/git/user-config.cjs +61 -14
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +255 -49
- package/lib/git-diff-cli.d.ts +1 -0
- package/lib/git-diff-cli.js +1 -0
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +254 -49
- package/lib/git-diff.mjs +4 -4
- package/lib/git-fix.cjs +64 -16
- package/lib/git-fix.mjs +10 -10
- package/lib/git-purge.cjs +61 -13
- package/lib/git-purge.mjs +1 -1
- package/lib/kill-night-crows.cjs +87 -0
- package/lib/kill-night-crows.d.mts +1 -0
- package/lib/kill-night-crows.mjs +65 -0
- package/lib/npm-run-series.cjs +60 -13
- package/lib/npm-run-series.mjs +1 -1
- package/lib/package-resolutions-updater-cli.cjs +560 -0
- package/lib/package-resolutions-updater-cli.d.mts +1 -0
- package/lib/package-resolutions-updater-cli.mjs +124 -0
- package/lib/package-resolutions-updater.cjs +174 -154
- package/lib/package-resolutions-updater.d.mts +32 -1
- package/lib/package-resolutions-updater.mjs +16 -294
- package/lib/php-cs-fixer-staged.cjs +105 -0
- package/lib/php-cs-fixer-staged.d.cts +2 -0
- package/lib/php-cs-fixer-staged.mjs +117 -0
- package/lib/print-directory-tree.cjs +62 -14
- package/lib/print-directory-tree.mjs +2 -2
- package/lib/ps/connected-domain.d.ts +1 -1
- package/lib/ps/index.js +1 -0
- package/lib/remove-module.cjs +61 -13
- package/lib/remove-module.mjs +1 -1
- package/lib/rmpath.cjs +63 -15
- package/lib/rmpath.mjs +2 -2
- package/lib/submodule-install.cjs +62 -15
- package/lib/submodule-install.mjs +3 -3
- package/lib/submodule-remove-cli.cjs +5 -1
- package/lib/submodule-remove-cli.mjs +1 -1
- package/lib/submodule-remove.cjs +4 -1
- package/lib/submodule-remove.mjs +1 -1
- package/lib/utils/chatgpt.cjs +192 -34
- package/lib/utils/chatgpt.js +210 -43
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +107 -0
- package/lib/utils/findEnvFiles.d.ts +8 -0
- package/lib/utils/findEnvFiles.js +121 -0
- package/lib/utils/findEnvFiles.mjs +8 -0
- package/lib/utils/findWorkspaceRoot.cjs +70 -0
- package/lib/utils/findWorkspaceRoot.d.ts +9 -0
- package/lib/utils/findWorkspaceRoot.js +57 -0
- package/lib/utils/findWorkspaceRoot.mjs +40 -0
- package/lib/utils/index.cjs +60 -13
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.cjs +64 -0
- package/lib/utils/isGithubTokenValid.d.ts +7 -0
- package/lib/utils/isGithubTokenValid.js +48 -0
- package/lib/utils/isGithubTokenValid.mjs +36 -0
- package/lib/yarn-reinstall.cjs +61 -13
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +107 -93
- package/readme.md +33 -34
- package/releases/readme.md +1 -1
- package/requirements.txt +1 -0
- package/lib/chunk-4EWQC6GZ.mjs +0 -382
- package/lib/chunk-4ZI7BQKQ.mjs +0 -381
- package/lib/chunk-5J2BEPY5.mjs +0 -83
- package/lib/chunk-AGZYRDC2.mjs +0 -323
- package/lib/chunk-HN52G2YL.mjs +0 -305
- package/lib/chunk-HO6GHCOB.mjs +0 -385
- package/lib/chunk-LEM5OMRP.mjs +0 -384
- package/lib/chunk-RCP7DHVY.mjs +0 -190
- package/lib/chunk-U6SO4QEV.mjs +0 -320
- package/lib/chunk-XD6BJK6Q.mjs +0 -351
- package/lib/chunk-YXSFGA2D.mjs +0 -383
- package/lib/git/gitattributes.d.ts +0 -33
- package/lib/git/gitattributes.js +0 -223
package/lib/free-chatgpt.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -88,31 +89,78 @@ var require_utils = __commonJS({
|
|
|
88
89
|
}
|
|
89
90
|
module2.exports.getArgs = getArgs2;
|
|
90
91
|
function del(fullPath) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
try {
|
|
93
|
+
if (!fs2.existsSync(fullPath)) return;
|
|
94
|
+
const stat = fs2.lstatSync(fullPath);
|
|
95
|
+
if (stat.isSymbolicLink()) {
|
|
96
|
+
try {
|
|
97
|
+
fs2.unlinkSync(fullPath);
|
|
98
|
+
console.log("deleted symlink", fullPath);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (stat.isDirectory()) {
|
|
105
|
+
const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
106
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
107
|
+
del(subdir[i]);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
fs2.rmdirSync(fullPath);
|
|
111
|
+
console.log("deleted", fullPath);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
try {
|
|
114
|
+
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
115
|
+
console.log("deleted", fullPath);
|
|
116
|
+
} catch (ee) {
|
|
117
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
95
121
|
}
|
|
96
|
-
} else {
|
|
97
122
|
try {
|
|
98
|
-
fs2.
|
|
123
|
+
fs2.unlinkSync(fullPath);
|
|
99
124
|
console.log("deleted", fullPath);
|
|
100
|
-
} catch (
|
|
101
|
-
|
|
125
|
+
} catch (e) {
|
|
126
|
+
try {
|
|
127
|
+
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
128
|
+
console.log("deleted", fullPath);
|
|
129
|
+
} catch (ee) {
|
|
130
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
131
|
+
}
|
|
102
132
|
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.log("failed delete", fullPath, err && err.message);
|
|
103
135
|
}
|
|
104
136
|
}
|
|
105
137
|
module2.exports.del = del;
|
|
106
138
|
function delStream(globStream) {
|
|
107
139
|
globStream.stream().on("data", (result) => {
|
|
108
140
|
const fullPath = path2.resolve(process.cwd(), result);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
141
|
+
try {
|
|
142
|
+
if (fs2.existsSync(fullPath)) {
|
|
143
|
+
const stat = fs2.lstatSync(fullPath);
|
|
144
|
+
if (stat.isSymbolicLink()) {
|
|
145
|
+
try {
|
|
146
|
+
fs2.unlinkSync(fullPath);
|
|
147
|
+
console.log("deleted symlink", fullPath);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (stat.isDirectory()) {
|
|
154
|
+
const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
155
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
156
|
+
del(subdir[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
113
159
|
}
|
|
160
|
+
del(fullPath);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.log("failed processing", fullPath, err && err.message);
|
|
114
163
|
}
|
|
115
|
-
del(fullPath);
|
|
116
164
|
});
|
|
117
165
|
}
|
|
118
166
|
module2.exports.delStream = delStream;
|
|
@@ -169,7 +217,17 @@ var import_puppeteer_extra_plugin_stealth = __toESM(require("puppeteer-extra-plu
|
|
|
169
217
|
var import_upath = __toESM(require("upath"), 1);
|
|
170
218
|
var COOKIE_DIR = import_upath.default.join(process.cwd(), "tmp", "cookies");
|
|
171
219
|
var DEFAULT_COOKIE_PATH = import_upath.default.join(COOKIE_DIR, "cookies.json");
|
|
220
|
+
var NAVIGATION_TIMEOUT_MS = 9e4;
|
|
221
|
+
var NETWORK_IDLE_TIMEOUT_MS = 15e3;
|
|
222
|
+
var MAX_INLINE_QUESTION_FILE_BYTES = 2 * 1024;
|
|
172
223
|
import_fs_extra.default.ensureDirSync(COOKIE_DIR);
|
|
224
|
+
async function gotoWithFallback(page, url) {
|
|
225
|
+
await page.goto(url, { waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
|
|
226
|
+
try {
|
|
227
|
+
await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
}
|
|
173
231
|
async function saveCookies(page, path2 = DEFAULT_COOKIE_PATH) {
|
|
174
232
|
const cookies = await page.cookies();
|
|
175
233
|
import_fs_extra.default.writeFileSync(path2, JSON.stringify(cookies, null, 2));
|
|
@@ -188,7 +246,7 @@ async function navigatePage(page, url) {
|
|
|
188
246
|
if (cookies) {
|
|
189
247
|
await page.setCookie(...cookies);
|
|
190
248
|
}
|
|
191
|
-
await page
|
|
249
|
+
await gotoWithFallback(page, url);
|
|
192
250
|
await page.evaluate(() => {
|
|
193
251
|
window.__domStillUpdating = true;
|
|
194
252
|
if (window.__domObserver) {
|
|
@@ -228,46 +286,151 @@ function loadCookies(cookieFilePath = DEFAULT_COOKIE_PATH) {
|
|
|
228
286
|
return JSON.parse(import_fs_extra.default.readFileSync(cookieFilePath));
|
|
229
287
|
}
|
|
230
288
|
async function writeQuestion(page, question2) {
|
|
231
|
-
const questions = question2.split("\n");
|
|
232
289
|
const promptTextarea = await page.waitForSelector("#prompt-textarea", { timeout: 3e4 });
|
|
233
290
|
if (!promptTextarea) {
|
|
234
291
|
console.log(
|
|
235
292
|
"Cannot find the prompt input on the webpage. Please check whether you have access to chat.openai.com without logging in via your browser."
|
|
236
293
|
);
|
|
237
|
-
}
|
|
238
|
-
await page.evaluate(() => {
|
|
239
|
-
document.querySelector("#prompt-textarea").innerHTML = `<p></p>`;
|
|
240
|
-
});
|
|
241
|
-
if (questions.length === 1) {
|
|
242
|
-
await page.type("#prompt-textarea", questions[0], { delay: 100 });
|
|
243
294
|
return;
|
|
244
295
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
296
|
+
await page.evaluate((text) => {
|
|
297
|
+
const promptEl = document.querySelector("#prompt-textarea");
|
|
298
|
+
if (!promptEl) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
promptEl.focus();
|
|
302
|
+
promptEl.innerHTML = "";
|
|
303
|
+
const lines = String(text).split("\n");
|
|
304
|
+
for (const line of lines) {
|
|
305
|
+
const p = document.createElement("p");
|
|
306
|
+
p.textContent = line;
|
|
307
|
+
promptEl.appendChild(p);
|
|
251
308
|
}
|
|
309
|
+
promptEl.dispatchEvent(new InputEvent("beforeinput", { bubbles: true, inputType: "insertFromPaste", data: text }));
|
|
310
|
+
promptEl.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertFromPaste", data: text }));
|
|
311
|
+
promptEl.dispatchEvent(new Event("change", { bubbles: true }));
|
|
312
|
+
}, question2);
|
|
313
|
+
const hasPromptText = await page.evaluate(() => {
|
|
314
|
+
const promptEl = document.querySelector("#prompt-textarea");
|
|
315
|
+
return Boolean(promptEl && promptEl.textContent && promptEl.textContent.trim().length > 0);
|
|
316
|
+
});
|
|
317
|
+
if (!hasPromptText) {
|
|
318
|
+
console.log("Prompt state not updated by DOM injection. Falling back to keyboard insertText.");
|
|
319
|
+
await promptTextarea.click({ clickCount: 1 });
|
|
320
|
+
await page.keyboard.down("Control");
|
|
321
|
+
await page.keyboard.press("KeyA");
|
|
322
|
+
await page.keyboard.up("Control");
|
|
323
|
+
await page.keyboard.insertText(question2);
|
|
252
324
|
}
|
|
253
325
|
}
|
|
254
326
|
async function clickSubmitButton(page) {
|
|
327
|
+
console.log("Attempting to click the submit button...");
|
|
255
328
|
try {
|
|
256
|
-
const
|
|
257
|
-
|
|
329
|
+
const userMessageCountBefore = await page.$$eval('[data-message-author-role="user"]', (elements) => elements.length);
|
|
330
|
+
const waitForSubmit = async (timeout = 5e3) => {
|
|
331
|
+
try {
|
|
332
|
+
await page.waitForFunction(
|
|
333
|
+
(previousCount) => {
|
|
334
|
+
const currentCount = document.querySelectorAll('[data-message-author-role="user"]').length;
|
|
335
|
+
return currentCount > previousCount;
|
|
336
|
+
},
|
|
337
|
+
{ timeout },
|
|
338
|
+
userMessageCountBefore
|
|
339
|
+
);
|
|
340
|
+
return true;
|
|
341
|
+
} catch {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
await page.waitForFunction(() => {
|
|
346
|
+
const candidates = [
|
|
347
|
+
document.querySelector('[data-testid="fruitjuice-send-button"]'),
|
|
348
|
+
document.querySelector("#composer-submit-button"),
|
|
349
|
+
document.querySelector('[data-testid="send-button"]')
|
|
350
|
+
].filter(Boolean);
|
|
351
|
+
return candidates.some((button) => {
|
|
352
|
+
const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
353
|
+
const isVisible = button.offsetParent !== null;
|
|
354
|
+
return !isDisabled && isVisible;
|
|
355
|
+
});
|
|
356
|
+
}, { timeout: 5e3 }).catch(() => {
|
|
258
357
|
});
|
|
259
|
-
const
|
|
260
|
-
|
|
358
|
+
const buttonDetails = await page.evaluate(() => {
|
|
359
|
+
const selectors = [
|
|
360
|
+
'[data-testid="fruitjuice-send-button"]',
|
|
361
|
+
"#composer-submit-button",
|
|
362
|
+
'[data-testid="send-button"]'
|
|
363
|
+
];
|
|
364
|
+
const details = selectors.map((selector) => {
|
|
365
|
+
const el = document.querySelector(selector);
|
|
366
|
+
const exists = Boolean(el);
|
|
367
|
+
const disabled = exists ? Boolean(el.disabled || el.getAttribute("aria-disabled") === "true") : null;
|
|
368
|
+
const visible = exists ? el.offsetParent !== null : null;
|
|
369
|
+
return { selector, exists, disabled, visible };
|
|
370
|
+
});
|
|
371
|
+
return details;
|
|
372
|
+
});
|
|
373
|
+
console.log(`Submit button details: ${JSON.stringify(buttonDetails)}`);
|
|
374
|
+
const clickable = buttonDetails.find((item) => item.exists && item.visible && item.disabled === false);
|
|
375
|
+
const selectedSelector = clickable ? clickable.selector : null;
|
|
376
|
+
if (selectedSelector) {
|
|
377
|
+
await page.click(selectedSelector);
|
|
378
|
+
console.log(`Clicked submit button selector: ${selectedSelector}`);
|
|
379
|
+
if (await waitForSubmit(5e3)) {
|
|
380
|
+
console.log("Submission detected after selector click.");
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
const forcedClickWorked = await page.evaluate((selector) => {
|
|
384
|
+
const el = document.querySelector(selector);
|
|
385
|
+
if (!el) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
el.click();
|
|
389
|
+
return true;
|
|
390
|
+
}, selectedSelector);
|
|
391
|
+
if (forcedClickWorked) {
|
|
392
|
+
console.log(`Forced DOM click on selector: ${selectedSelector}`);
|
|
393
|
+
if (await waitForSubmit(5e3)) {
|
|
394
|
+
console.log("Submission detected after forced DOM click.");
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
console.log("Submit button path did not submit. Trying Enter key fallback on prompt.");
|
|
400
|
+
await page.focus("#prompt-textarea");
|
|
401
|
+
await page.keyboard.press("Enter");
|
|
402
|
+
if (await waitForSubmit(5e3)) {
|
|
403
|
+
console.log("Submission detected after Enter key fallback.");
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
const didRequestSubmit = await page.evaluate(() => {
|
|
407
|
+
const prompt = document.querySelector("#prompt-textarea");
|
|
408
|
+
if (!prompt) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const form = prompt.closest("form");
|
|
412
|
+
if (!form) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
if (typeof form.requestSubmit === "function") {
|
|
416
|
+
form.requestSubmit();
|
|
417
|
+
} else {
|
|
418
|
+
form.submit();
|
|
419
|
+
}
|
|
420
|
+
return true;
|
|
261
421
|
});
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
422
|
+
if (didRequestSubmit) {
|
|
423
|
+
console.log("Triggered form submit fallback.");
|
|
424
|
+
if (await waitForSubmit(5e3)) {
|
|
425
|
+
console.log("Submission detected after form submit fallback.");
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
268
428
|
}
|
|
429
|
+
console.log("Failed to submit prompt after all strategies.");
|
|
430
|
+
return false;
|
|
269
431
|
} catch (e) {
|
|
270
432
|
console.log(`Failed to click the send button: ${e}`);
|
|
433
|
+
return false;
|
|
271
434
|
}
|
|
272
435
|
}
|
|
273
436
|
var lastMessageId = null;
|
|
@@ -340,11 +503,15 @@ async function isLoggedIn(page) {
|
|
|
340
503
|
return result === true;
|
|
341
504
|
}
|
|
342
505
|
async function createBrowser(browserOptions = {}) {
|
|
506
|
+
const windowsChromeExecutable = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
|
|
507
|
+
const hasWindowsChrome = process.platform === "win32" && import_fs_extra.default.existsSync(windowsChromeExecutable);
|
|
343
508
|
const defaultOptions = {
|
|
344
509
|
headless: false,
|
|
510
|
+
defaultViewport: null,
|
|
345
511
|
userDataDir: import_upath.default.join(process.cwd(), "tmp/puppeteer-profile"),
|
|
346
512
|
// Windows-specific options to handle browser launch issues
|
|
347
513
|
args: [
|
|
514
|
+
"--start-maximized",
|
|
348
515
|
"--no-sandbox",
|
|
349
516
|
"--disable-setuid-sandbox",
|
|
350
517
|
"--disable-dev-shm-usage",
|
|
@@ -357,10 +524,9 @@ async function createBrowser(browserOptions = {}) {
|
|
|
357
524
|
"--disable-renderer-backgrounding"
|
|
358
525
|
],
|
|
359
526
|
ignoreDefaultArgs: ["--disable-extensions"],
|
|
360
|
-
...
|
|
361
|
-
//
|
|
362
|
-
executablePath:
|
|
363
|
-
// Let Puppeteer find Chrome automatically
|
|
527
|
+
...hasWindowsChrome && {
|
|
528
|
+
// Prefer local Chrome installation when present on Windows.
|
|
529
|
+
executablePath: windowsChromeExecutable
|
|
364
530
|
}
|
|
365
531
|
};
|
|
366
532
|
try {
|
|
@@ -370,8 +536,12 @@ async function createBrowser(browserOptions = {}) {
|
|
|
370
536
|
try {
|
|
371
537
|
return await import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)()).launch({
|
|
372
538
|
headless: browserOptions.headless || false,
|
|
373
|
-
|
|
539
|
+
defaultViewport: null,
|
|
540
|
+
args: ["--start-maximized", "--no-sandbox", "--disable-setuid-sandbox"],
|
|
374
541
|
ignoreDefaultArgs: false,
|
|
542
|
+
...hasWindowsChrome && {
|
|
543
|
+
executablePath: windowsChromeExecutable
|
|
544
|
+
},
|
|
375
545
|
...browserOptions
|
|
376
546
|
});
|
|
377
547
|
} catch (fallbackError) {
|
|
@@ -396,7 +566,11 @@ async function loginToChatGpt() {
|
|
|
396
566
|
if (loginButtonExists) {
|
|
397
567
|
console.log("Login button found, clicking to log in...");
|
|
398
568
|
await page.click('[data-testid="login-button"]');
|
|
399
|
-
await page.waitForNavigation({ waitUntil: "
|
|
569
|
+
await page.waitForNavigation({ waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
|
|
570
|
+
try {
|
|
571
|
+
await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
|
|
572
|
+
} catch {
|
|
573
|
+
}
|
|
400
574
|
console.log("Login process completed.");
|
|
401
575
|
} else {
|
|
402
576
|
console.log("No login required - user appears to be already logged in.");
|
|
@@ -406,6 +580,7 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
406
580
|
const headless = chatgptOptions.headless !== void 0 ? chatgptOptions.headless : true;
|
|
407
581
|
const questionFile2 = chatgptOptions.questionFile;
|
|
408
582
|
let question2 = chatgptOptions.question;
|
|
583
|
+
let shouldUploadQuestionFile = Boolean(questionFile2);
|
|
409
584
|
const responseFile = chatgptOptions.responseFile || import_upath.default.join(process.cwd(), "tmp", "response.txt");
|
|
410
585
|
const noInputProvided = !question2 && !questionFile2;
|
|
411
586
|
const questionIsEmpty = question2 && question2.trim().length === 0;
|
|
@@ -413,6 +588,22 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
413
588
|
if (noInputProvided || questionIsEmpty || questionFileIsEmpty) {
|
|
414
589
|
throw new Error("You must provide a question or a question file.");
|
|
415
590
|
}
|
|
591
|
+
if (!question2 && questionFile2) {
|
|
592
|
+
if (!import_fs_extra.default.existsSync(questionFile2)) {
|
|
593
|
+
throw new Error(`Question file does not exist: ${questionFile2}`);
|
|
594
|
+
}
|
|
595
|
+
const questionFileStats = import_fs_extra.default.statSync(questionFile2);
|
|
596
|
+
if (questionFileStats.size <= MAX_INLINE_QUESTION_FILE_BYTES) {
|
|
597
|
+
question2 = import_fs_extra.default.readFileSync(questionFile2, "utf8").trim();
|
|
598
|
+
if (!question2) {
|
|
599
|
+
throw new Error("Question file is empty.");
|
|
600
|
+
}
|
|
601
|
+
shouldUploadQuestionFile = false;
|
|
602
|
+
console.log(
|
|
603
|
+
`Question file is ${questionFileStats.size} bytes (<= ${MAX_INLINE_QUESTION_FILE_BYTES}). Sending as text prompt.`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
416
607
|
let browser;
|
|
417
608
|
try {
|
|
418
609
|
browser = await createBrowser({ headless });
|
|
@@ -425,7 +616,16 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
425
616
|
console.error("4. Close any running Chrome instances and try again");
|
|
426
617
|
throw error;
|
|
427
618
|
}
|
|
428
|
-
const
|
|
619
|
+
const allPages = await browser.pages();
|
|
620
|
+
const page = allPages.length > 0 ? allPages[0] : await browser.newPage();
|
|
621
|
+
await page.bringToFront();
|
|
622
|
+
if (allPages.length > 1) {
|
|
623
|
+
for (const p of allPages) {
|
|
624
|
+
if (p !== page) {
|
|
625
|
+
await p.close();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
429
629
|
try {
|
|
430
630
|
const url = "https://chat.openai.com";
|
|
431
631
|
const navigate = await navigatePage(page, url);
|
|
@@ -444,12 +644,15 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
444
644
|
}
|
|
445
645
|
if (question2) {
|
|
446
646
|
await writeQuestion(page, question2);
|
|
447
|
-
await clickSubmitButton(page);
|
|
647
|
+
const didSubmit = await clickSubmitButton(page);
|
|
648
|
+
if (!didSubmit) {
|
|
649
|
+
throw new Error("Prompt was not submitted. The composer button may be disabled or blocked.");
|
|
650
|
+
}
|
|
448
651
|
await navigate.waitForDomIdle(1e3, 3e4);
|
|
449
652
|
await waitForInitialResponse(page);
|
|
450
653
|
await handleStreamingResponse(page, responseFile);
|
|
451
654
|
await saveCookies(page, getCookiePathForUrl(url));
|
|
452
|
-
} else if (questionFile2) {
|
|
655
|
+
} else if (shouldUploadQuestionFile && questionFile2) {
|
|
453
656
|
await navigate.waitForDomIdle(2e3, 1e4);
|
|
454
657
|
const isUserLoggedIn = await isLoggedIn(page);
|
|
455
658
|
console.log(`Login status: ${isUserLoggedIn ? "Logged in" : "Not logged in"}`);
|
|
@@ -488,7 +691,10 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
488
691
|
await fileInput.uploadFile(questionFile2);
|
|
489
692
|
await navigate.waitForDomIdle(2e3, 15e3);
|
|
490
693
|
console.log("File uploaded successfully");
|
|
491
|
-
await clickSubmitButton(page);
|
|
694
|
+
const didSubmit = await clickSubmitButton(page);
|
|
695
|
+
if (!didSubmit) {
|
|
696
|
+
throw new Error("Prompt was not submitted after file upload.");
|
|
697
|
+
}
|
|
492
698
|
await navigate.waitForDomIdle(1e3, 3e4);
|
|
493
699
|
await waitForInitialResponse(page);
|
|
494
700
|
await handleStreamingResponse(page, responseFile);
|
package/lib/free-chatgpt.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
runChatGpt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N436BNBK.mjs";
|
|
5
5
|
import {
|
|
6
6
|
require_utils
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Z6JLYU2J.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__toESM,
|
|
10
10
|
init_esm_shims
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export default module.exports;
|
|
1
2
|
/**
|
|
2
3
|
* Parse existing .gitattributes file into structured rules
|
|
3
4
|
* @param {string} gitattributesPath - Path to .gitattributes file
|
|
@@ -17,7 +18,7 @@ export function patternsConflict(pattern1: string, pattern2: string): boolean;
|
|
|
17
18
|
* @param {Array} desiredRules - Desired rules to add
|
|
18
19
|
* @returns {Object} Result with mergedRules, conflicts, and changes
|
|
19
20
|
*/
|
|
20
|
-
export function mergeGitAttributeRules(existingRules: any[], desiredRules: any[]):
|
|
21
|
+
export function mergeGitAttributeRules(existingRules: any[], desiredRules: any[]): Object;
|
|
21
22
|
/**
|
|
22
23
|
* Format merged rules back into .gitattributes content
|
|
23
24
|
* @param {Array} rules - Merged rules array
|
|
@@ -30,4 +31,8 @@ export function formatGitAttributes(rules: any[]): string;
|
|
|
30
31
|
* @param {Array} desiredRules - Array of desired rules to add/merge
|
|
31
32
|
* @returns {Object} Result with success status, conflicts, and changes
|
|
32
33
|
*/
|
|
33
|
-
export function updateGitAttributes(gitattributesPath: string, desiredRules: any[]):
|
|
34
|
+
export function updateGitAttributes(gitattributesPath: string, desiredRules: any[]): Object;
|
|
35
|
+
declare namespace exports {
|
|
36
|
+
export { parseGitAttributes, patternsConflict, mergeGitAttributeRules, formatGitAttributes, updateGitAttributes, exports as default };
|
|
37
|
+
}
|
|
38
|
+
declare namespace module { }
|
package/lib/git/line-endings.cjs
CHANGED
|
@@ -242,6 +242,7 @@ var require_gitattributes = __commonJS({
|
|
|
242
242
|
formatGitAttributes,
|
|
243
243
|
updateGitAttributes: updateGitAttributes2
|
|
244
244
|
};
|
|
245
|
+
module2.exports.default = module2.exports;
|
|
245
246
|
}
|
|
246
247
|
});
|
|
247
248
|
|
|
@@ -250,7 +251,7 @@ init_cjs_shims();
|
|
|
250
251
|
var path = require("upath");
|
|
251
252
|
var fs = require("fs");
|
|
252
253
|
var { runGitCommand } = require_utils();
|
|
253
|
-
var { updateGitAttributes } = require_gitattributes()
|
|
254
|
+
var { updateGitAttributes } = require_gitattributes();
|
|
254
255
|
function forceLfLineEndings() {
|
|
255
256
|
console.log("\n=== Configuring LF Line Endings ===");
|
|
256
257
|
runGitCommand(["config", "core.autocrlf", "false"], "Disable automatic CRLF conversion");
|
package/lib/git/line-endings.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_line_endings
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-ZDMWBSYF.mjs";
|
|
5
|
+
import "../chunk-PDN26I7O.mjs";
|
|
6
6
|
import "../chunk-A3VUZEJK.mjs";
|
|
7
7
|
import "../chunk-QQ4A6DLD.mjs";
|
|
8
8
|
export default require_line_endings();
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
31
|
+
var init_cjs_shims = __esm({
|
|
32
|
+
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// src/git/utils.cjs
|
|
37
|
+
var require_utils = __commonJS({
|
|
38
|
+
"src/git/utils.cjs"(exports2, module2) {
|
|
39
|
+
init_cjs_shims();
|
|
40
|
+
var { execSync, spawnSync } = require("child_process");
|
|
41
|
+
function runGitCommand(args, description) {
|
|
42
|
+
try {
|
|
43
|
+
console.log(`[i] ${description}`);
|
|
44
|
+
const result = spawnSync("git", args, { encoding: "utf-8" });
|
|
45
|
+
if (result.status !== 0) {
|
|
46
|
+
console.error(`[\u2717] Failed: ${description}`);
|
|
47
|
+
console.error(`Error: ${result.stderr || result.stdout}`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
console.log(`[\u2713] ${description}`);
|
|
51
|
+
return true;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(`[\u2717] Failed: ${description}`);
|
|
54
|
+
console.error(`Error: ${error.message}`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isGitRepository(cwd) {
|
|
59
|
+
const dir = typeof cwd === "string" ? cwd : process.cwd();
|
|
60
|
+
try {
|
|
61
|
+
execSync("git rev-parse --git-dir", { stdio: "pipe", cwd: dir });
|
|
62
|
+
return true;
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function runGitCommandOutput(args, description) {
|
|
68
|
+
try {
|
|
69
|
+
console.log(`[i] ${description}`);
|
|
70
|
+
const result = spawnSync("git", args, { encoding: "utf-8" });
|
|
71
|
+
if (result.status !== 0) {
|
|
72
|
+
console.error(`[\u2717] Failed: ${description}`);
|
|
73
|
+
console.error(`Error: ${result.stderr || result.stdout}`);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
console.log(`[\u2713] ${description}`);
|
|
77
|
+
return result.stdout.trim();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error(`[\u2717] Failed: ${description}`);
|
|
80
|
+
console.error(`Error: ${error.message}`);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
module2.exports = {
|
|
85
|
+
runGitCommand,
|
|
86
|
+
runGitCommandOutput,
|
|
87
|
+
isGitRepository
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// src/git/undo-commit.cjs
|
|
93
|
+
var require_undo_commit = __commonJS({
|
|
94
|
+
"src/git/undo-commit.cjs"(exports2, module2) {
|
|
95
|
+
init_cjs_shims();
|
|
96
|
+
var { runGitCommand } = require_utils();
|
|
97
|
+
function undoLastCommit2() {
|
|
98
|
+
console.log("\n=== Undoing Last Commit ===");
|
|
99
|
+
runGitCommand(["reset", "--soft", "HEAD~1"], "Undo last commit while keeping changes staged");
|
|
100
|
+
}
|
|
101
|
+
module2.exports = {
|
|
102
|
+
undoLastCommit: undoLastCommit2
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// src/git/undo-commit-cli.js
|
|
108
|
+
init_cjs_shims();
|
|
109
|
+
var import_undo_commit = __toESM(require_undo_commit(), 1);
|
|
110
|
+
(0, import_undo_commit.undoLastCommit)();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_undo_commit
|
|
4
|
+
} from "../chunk-34IQDTLZ.mjs";
|
|
5
|
+
import "../chunk-A3VUZEJK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__toESM,
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "../chunk-QQ4A6DLD.mjs";
|
|
10
|
+
|
|
11
|
+
// src/git/undo-commit-cli.js
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
var import_undo_commit = __toESM(require_undo_commit(), 1);
|
|
14
|
+
(0, import_undo_commit.undoLastCommit)();
|