binary-collections 2.0.11 → 2.0.12

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 (225) hide show
  1. package/.opencode/package.json +5 -0
  2. package/binaries/rmx +15 -1
  3. package/binaries/rmx.cmd +12 -0
  4. package/binaries/test-cjs +9 -1
  5. package/binaries/test-cjs.cmd +16 -1
  6. package/binaries/test-esm +16 -0
  7. package/binaries/test-esm.cjs +178 -0
  8. package/binaries/test-esm.cmd +23 -0
  9. package/binaries/yarn-clean +1 -1
  10. package/binaries/yarn-clean.cmd +1 -1
  11. package/binaries/yarn-clean.py +33 -15
  12. package/binaries/yc +110 -0
  13. package/binaries/yc.cjs +178 -0
  14. package/lib/binary-collections/config.cjs +126 -0
  15. package/lib/binary-collections/config.mjs +7 -0
  16. package/lib/binary-collections/executeScript.cjs +19 -0
  17. package/lib/binary-collections/executeScript.d.cts +12 -0
  18. package/lib/binary-collections/executeScript.mjs +6 -0
  19. package/lib/binary-collections/findScript.cjs +284 -0
  20. package/lib/binary-collections/findScript.d.cts +12 -0
  21. package/lib/binary-collections/findScript.mjs +7 -0
  22. package/lib/binary-collections/listScript.cjs +266 -0
  23. package/lib/binary-collections/listScript.d.cts +19 -0
  24. package/lib/binary-collections/listScript.mjs +7 -0
  25. package/lib/binary-collections.cjs +224 -137
  26. package/lib/binary-collections.mjs +22 -282
  27. package/lib/changelog.cjs +2 -2
  28. package/lib/changelog.mjs +1 -1
  29. package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
  30. package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
  31. package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
  32. package/lib/chunk-6PU7BAHB.mjs +61 -0
  33. package/lib/chunk-C6D2TTYU.mjs +32 -0
  34. package/lib/chunk-FB2WKVJD.mjs +158 -0
  35. package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
  36. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  37. package/lib/chunk-H44UWUFY.mjs +105 -0
  38. package/lib/chunk-NCZPTKDV.mjs +79 -0
  39. package/lib/chunk-NGFK3EYW.mjs +28 -0
  40. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  41. package/lib/chunk-OGXVGBRI.mjs +29 -0
  42. package/lib/chunk-OXV52GD5.mjs +62 -0
  43. package/lib/chunk-PXBMHE7O.mjs +35 -0
  44. package/lib/chunk-R5FJOR63.mjs +47 -0
  45. package/lib/chunk-SPTECFE5.mjs +180 -0
  46. package/lib/chunk-UXCFNAR6.mjs +55 -0
  47. package/lib/chunk-V2IBPCEV.mjs +39 -0
  48. package/lib/chunk-XPJGCDOD.mjs +14 -0
  49. package/lib/chunk-ZOWVMII3.mjs +228 -0
  50. package/lib/clean-github-actions-caches-cli.cjs +465 -0
  51. package/lib/clean-github-actions-caches-cli.d.cts +1 -0
  52. package/lib/clean-github-actions-caches-cli.mjs +56 -0
  53. package/lib/clean-github-actions-caches.cjs +149 -205
  54. package/lib/clean-github-actions-caches.d.cts +15 -1
  55. package/lib/clean-github-actions-caches.mjs +4 -130
  56. package/lib/cross-env/command.cjs +63 -0
  57. package/lib/cross-env/command.d.ts +8 -0
  58. package/lib/cross-env/command.js +45 -0
  59. package/lib/cross-env/command.mjs +9 -0
  60. package/lib/cross-env/index.cjs +178 -0
  61. package/lib/cross-env/index.d.ts +8 -0
  62. package/lib/cross-env/index.js +102 -0
  63. package/lib/cross-env/index.mjs +101 -0
  64. package/lib/cross-env/variable.cjs +60 -0
  65. package/lib/cross-env/variable.d.ts +7 -0
  66. package/lib/cross-env/variable.js +59 -0
  67. package/lib/cross-env/variable.mjs +9 -0
  68. package/lib/del-gradle.cjs +2 -2
  69. package/lib/del-gradle.js +8 -8
  70. package/lib/del-gradle.mjs +1 -1
  71. package/lib/del-node-modules.js +24 -24
  72. package/lib/del-ps.cjs +2 -2
  73. package/lib/del-ps.js +8 -8
  74. package/lib/del-ps.mjs +1 -1
  75. package/lib/del-yarn-caches.cjs +2 -2
  76. package/lib/del-yarn-caches.js +2 -2
  77. package/lib/del-yarn-caches.mjs +1 -1
  78. package/lib/file/copy-cli.cjs +92 -0
  79. package/lib/file/copy-cli.d.mts +1 -0
  80. package/lib/file/copy-cli.mjs +55 -0
  81. package/lib/file/copy.cjs +56 -0
  82. package/lib/file/copy.d.mts +1 -0
  83. package/lib/file/copy.mjs +8 -0
  84. package/lib/file/move-cli.cjs +91 -0
  85. package/lib/file/move-cli.d.mts +1 -0
  86. package/lib/file/move-cli.mjs +55 -0
  87. package/lib/file/move.cjs +55 -0
  88. package/lib/file/move.d.mts +1 -0
  89. package/lib/file/move.mjs +8 -0
  90. package/lib/find-node-modules-cli.js +1 -1
  91. package/lib/free-chatgpt.cjs +21 -15
  92. package/lib/free-chatgpt.js +10 -10
  93. package/lib/free-chatgpt.mjs +2 -2
  94. package/lib/git/user-config.cjs +2 -2
  95. package/lib/git/user-config.mjs +2 -2
  96. package/lib/git-diff-cli.cjs +188 -42
  97. package/lib/git-diff-cli.mjs +5 -4
  98. package/lib/git-diff.cjs +188 -42
  99. package/lib/git-diff.d.ts +2 -1
  100. package/lib/git-diff.js +91 -34
  101. package/lib/git-diff.mjs +5 -4
  102. package/lib/git-fix.cjs +2 -2
  103. package/lib/git-fix.mjs +2 -2
  104. package/lib/git-purge.cjs +2 -2
  105. package/lib/git-purge.mjs +1 -1
  106. package/lib/index.d.ts +1 -1
  107. package/lib/kill-night-crows.cjs +7 -7
  108. package/lib/kill-night-crows.mjs +7 -7
  109. package/lib/node-cache-cleaner/npm.cjs +65 -0
  110. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  111. package/lib/node-cache-cleaner/npm.js +41 -0
  112. package/lib/node-cache-cleaner/npm.mjs +10 -0
  113. package/lib/node-cache-cleaner/npx.cjs +89 -0
  114. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  115. package/lib/node-cache-cleaner/npx.js +82 -0
  116. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  117. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  118. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  119. package/lib/node-cache-cleaner/yarn.js +62 -0
  120. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  121. package/lib/node-cache-cleaner-cli.cjs +182 -0
  122. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  123. package/lib/node-cache-cleaner-cli.js +60 -0
  124. package/lib/node-cache-cleaner-cli.mjs +56 -0
  125. package/lib/node-executor.cjs +91 -0
  126. package/lib/node-executor.d.cts +2 -0
  127. package/lib/node-executor.mjs +103 -0
  128. package/lib/npm-run-series.cjs +21 -28
  129. package/lib/npm-run-series.mjs +20 -6
  130. package/lib/package-resolutions-updater-cli.cjs +213 -128
  131. package/lib/package-resolutions-updater-cli.mjs +17 -39
  132. package/lib/package-resolutions-updater.cjs +204 -98
  133. package/lib/package-resolutions-updater.d.mts +20 -1
  134. package/lib/package-resolutions-updater.mjs +7 -5
  135. package/lib/print-directory-tree.cjs +2 -2
  136. package/lib/print-directory-tree.mjs +1 -1
  137. package/lib/ps/connected-domain.js +10 -10
  138. package/lib/ps/index.cjs +1 -1
  139. package/lib/ps/index.mjs +177 -171
  140. package/lib/ps/isWin.js +1 -1
  141. package/lib/ps/table-parser.js +6 -6
  142. package/lib/remove-module.cjs +2 -2
  143. package/lib/remove-module.mjs +1 -1
  144. package/lib/rm-node-module-cli.cjs +222 -0
  145. package/lib/rm-node-module-cli.d.cts +1 -0
  146. package/lib/rm-node-module-cli.mjs +89 -0
  147. package/lib/rm-node-modules.cjs +127 -0
  148. package/lib/rm-node-modules.d.cts +35 -0
  149. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  150. package/lib/rmpath.cjs +2 -2
  151. package/lib/rmpath.mjs +1 -1
  152. package/lib/submodule-install.cjs +47 -34
  153. package/lib/submodule-install.mjs +46 -33
  154. package/lib/submodule-remove-cli.cjs +1 -2
  155. package/lib/submodule-remove-cli.js +3 -3
  156. package/lib/submodule-remove-cli.mjs +1 -2
  157. package/lib/utils/chatgpt.cjs +19 -13
  158. package/lib/utils/chatgpt.js +94 -94
  159. package/lib/utils/chatgpt.mjs +1 -1
  160. package/lib/utils/findEnvFiles.cjs +28 -46
  161. package/lib/utils/findEnvFiles.d.cts +19 -0
  162. package/lib/utils/findEnvFiles.mjs +3 -5
  163. package/lib/utils/findWorkspaceRoot.js +4 -4
  164. package/lib/utils/index.cjs +2 -2
  165. package/lib/utils/index.mjs +1 -1
  166. package/lib/utils/isGithubTokenValid.js +7 -7
  167. package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
  168. package/lib/utils/isWindows.d.ts +5 -0
  169. package/lib/utils/isWindows.js +10 -0
  170. package/lib/utils/isWindows.mjs +8 -0
  171. package/lib/utils/runBash.cjs +53 -0
  172. package/lib/utils/runBash.d.cts +12 -0
  173. package/lib/utils/runBash.mjs +66 -0
  174. package/lib/yarn-per-branch-lock-installer.cjs +97 -0
  175. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  176. package/lib/yarn-per-branch-lock-installer.mjs +109 -0
  177. package/lib/yarn-reinstall.cjs +2 -2
  178. package/lib/yarn-reinstall.mjs +1 -1
  179. package/package.json +61 -52
  180. package/readme.html +784 -0
  181. package/readme.md +106 -218
  182. package/releases/readme.md +1 -1
  183. package/test/README.md +2 -2
  184. package/test-project/package.json +8 -2
  185. package/test-project/workspaces/workspace-a/package.json +135 -0
  186. package/test-project/workspaces/workspace-a/readme.md +20 -0
  187. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  188. package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
  189. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  190. package/test-project/workspaces/workspace-b/package.json +139 -0
  191. package/test-project/workspaces/workspace-b/readme.md +94 -0
  192. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  193. package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
  194. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
  195. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  196. package/tmp/rm-node-modules-test-project/package.json +17 -0
  197. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
  198. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
  199. package/tmp/test-repo/README.md +2 -35
  200. package/tmp/test-repo/package.json +13 -3
  201. package/docs-src/clean-github-actions-caches.md +0 -26
  202. package/docs-src/free-chatgpt.md +0 -26
  203. package/lib/binary-collections-config.cjs +0 -15
  204. package/lib/chunk-2CBJCW7E.mjs +0 -81
  205. package/lib/chunk-4UHL4WVN.mjs +0 -136
  206. package/lib/chunk-66PAU5PS.mjs +0 -31
  207. package/lib/chunk-6HHJRKFB.mjs +0 -59
  208. package/lib/chunk-7XTEJHOE.mjs +0 -193
  209. package/lib/chunk-FCDQGYBF.mjs +0 -136
  210. package/lib/chunk-GEYA2USY.mjs +0 -207
  211. package/lib/chunk-GJTGHXRA.mjs +0 -356
  212. package/lib/chunk-ID2WBTE2.mjs +0 -80
  213. package/lib/chunk-JXFOHKDM.mjs +0 -239
  214. package/lib/chunk-PDSXF5HY.mjs +0 -187
  215. package/lib/chunk-RWLXRTYP.mjs +0 -109
  216. package/lib/chunk-TOIVAQF7.mjs +0 -136
  217. package/lib/chunk-V5SKYJUB.mjs +0 -136
  218. package/lib/chunk-WSRETQCA.mjs +0 -59
  219. package/lib/chunk-YYLIQQKF.mjs +0 -31
  220. package/lib/ps/index.d.ts +0 -2
  221. package/lib/ps/index.js +0 -254
  222. package/lib/utils/findEnvFiles.d.ts +0 -8
  223. package/lib/utils/findEnvFiles.js +0 -121
  224. package/tmp/typedoc/readme.md +0 -320
  225. /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ move
4
+ } from "../chunk-NGFK3EYW.mjs";
5
+ import "../chunk-QQ4A6DLD.mjs";
6
+ export {
7
+ move
8
+ };
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const findNodeModules = require("./find-node-modules.cjs");
3
+ const findNodeModules = require('./find-node-modules.cjs');
4
4
  findNodeModules(null, console.log);
@@ -109,7 +109,7 @@ var require_utils = __commonJS({
109
109
  try {
110
110
  fs2.rmdirSync(fullPath);
111
111
  console.log("deleted", fullPath);
112
- } catch (e) {
112
+ } catch (_e) {
113
113
  try {
114
114
  fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
115
115
  console.log("deleted", fullPath);
@@ -122,7 +122,7 @@ var require_utils = __commonJS({
122
122
  try {
123
123
  fs2.unlinkSync(fullPath);
124
124
  console.log("deleted", fullPath);
125
- } catch (e) {
125
+ } catch (_e) {
126
126
  try {
127
127
  fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
128
128
  console.log("deleted", fullPath);
@@ -326,7 +326,10 @@ async function writeQuestion(page, question2) {
326
326
  async function clickSubmitButton(page) {
327
327
  console.log("Attempting to click the submit button...");
328
328
  try {
329
- const userMessageCountBefore = await page.$$eval('[data-message-author-role="user"]', (elements) => elements.length);
329
+ const userMessageCountBefore = await page.$$eval(
330
+ '[data-message-author-role="user"]',
331
+ (elements) => elements.length
332
+ );
330
333
  const waitForSubmit = async (timeout = 5e3) => {
331
334
  try {
332
335
  await page.waitForFunction(
@@ -342,18 +345,21 @@ async function clickSubmitButton(page) {
342
345
  return false;
343
346
  }
344
347
  };
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(() => {
348
+ await page.waitForFunction(
349
+ () => {
350
+ const candidates = [
351
+ document.querySelector('[data-testid="fruitjuice-send-button"]'),
352
+ document.querySelector("#composer-submit-button"),
353
+ document.querySelector('[data-testid="send-button"]')
354
+ ].filter(Boolean);
355
+ return candidates.some((button) => {
356
+ const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
357
+ const isVisible = button.offsetParent !== null;
358
+ return !isDisabled && isVisible;
359
+ });
360
+ },
361
+ { timeout: 5e3 }
362
+ ).catch(() => {
357
363
  });
358
364
  const buttonDetails = await page.evaluate(() => {
359
365
  const selectors = [
@@ -14,18 +14,18 @@ const index_cjs_1 = require("./utils/index.cjs");
14
14
  const argv = (0, index_cjs_1.getArgs)();
15
15
  if (argv.help || argv.h) {
16
16
  console.log();
17
- console.log("Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]");
17
+ console.log('Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]');
18
18
  console.log();
19
- console.log("Options:");
19
+ console.log('Options:');
20
20
  console.log(' --question, -q The question to ask ChatGPT (default: "Hello, ChatGPT!")');
21
- console.log(" --qfile, -qf Path to a file containing the question text");
22
- console.log(" --help, -h Show this help message");
21
+ console.log(' --qfile, -qf Path to a file containing the question text');
22
+ console.log(' --help, -h Show this help message');
23
23
  console.log();
24
- console.log("Description:");
25
- console.log(" Automates browser interaction with ChatGPT, including login, question submission, and response retrieval.");
26
- console.log(" - Questions can be provided directly or loaded from a file.");
27
- console.log(" - Cookies are saved to ./tmp/cookies for session persistence.");
28
- console.log(" - Requires browser access to chat.openai.com and chatgpt.com (firewall must allow connection).");
24
+ console.log('Description:');
25
+ console.log(' Automates browser interaction with ChatGPT, including login, question submission, and response retrieval.');
26
+ console.log(' - Questions can be provided directly or loaded from a file.');
27
+ console.log(' - Cookies are saved to ./tmp/cookies for session persistence.');
28
+ console.log(' - Requires browser access to chat.openai.com and chatgpt.com (firewall must allow connection).');
29
29
  console.log();
30
30
  process.exit(0);
31
31
  }
@@ -43,7 +43,7 @@ function main() {
43
43
  });
44
44
  }
45
45
  catch (error) {
46
- console.error("Error running ChatGPT:", error);
46
+ console.error('Error running ChatGPT:', error);
47
47
  process.exit(1);
48
48
  }
49
49
  });
@@ -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-N436BNBK.mjs";
4
+ } from "./chunk-GAGABICI.mjs";
5
5
  import {
6
6
  require_utils
7
- } from "./chunk-Z6JLYU2J.mjs";
7
+ } from "./chunk-5RTXZVCW.mjs";
8
8
  import {
9
9
  __toESM,
10
10
  init_esm_shims
@@ -143,7 +143,7 @@ var require_utils2 = __commonJS({
143
143
  try {
144
144
  fs.rmdirSync(fullPath);
145
145
  console.log("deleted", fullPath);
146
- } catch (e) {
146
+ } catch (_e) {
147
147
  try {
148
148
  fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
149
149
  console.log("deleted", fullPath);
@@ -156,7 +156,7 @@ var require_utils2 = __commonJS({
156
156
  try {
157
157
  fs.unlinkSync(fullPath);
158
158
  console.log("deleted", fullPath);
159
- } catch (e) {
159
+ } catch (_e) {
160
160
  try {
161
161
  fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
162
162
  console.log("deleted", fullPath);
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_user_config
4
- } from "../chunk-AJDD5DZM.mjs";
4
+ } from "../chunk-2LSRSEXF.mjs";
5
5
  import "../chunk-A3VUZEJK.mjs";
6
- import "../chunk-Z6JLYU2J.mjs";
6
+ import "../chunk-5RTXZVCW.mjs";
7
7
  import "../chunk-QQ4A6DLD.mjs";
8
8
  export default require_user_config();
@@ -37,12 +37,108 @@ var init_cjs_shims = __esm({
37
37
  }
38
38
  });
39
39
 
40
- // src/binary-collections-config.cjs
41
- var require_binary_collections_config = __commonJS({
42
- "src/binary-collections-config.cjs"(exports2, module2) {
40
+ // src/utils/findEnvFiles.cjs
41
+ var require_findEnvFiles = __commonJS({
42
+ "src/utils/findEnvFiles.cjs"(exports2, module2) {
43
43
  init_cjs_shims();
44
+ var fs3 = require("fs");
44
45
  var path3 = require("path");
45
- require("dotenv").config({ path: path3.join(process.cwd(), ".env"), quiet: true, override: true });
46
+ var glob = require("glob");
47
+ var DEFAULT_IGNORES = [
48
+ "**/node_modules/**",
49
+ "**/.git/**",
50
+ "**/.yarn/**",
51
+ "**/.pnpm/**",
52
+ "**/dist/**",
53
+ "**/build/**",
54
+ "**/coverage/**",
55
+ "**/vendor/**",
56
+ "**/tmp/**",
57
+ "**/.cache/**",
58
+ "**/assets/**",
59
+ "**/logs/**",
60
+ "**/output/**",
61
+ "**/public/**",
62
+ "**/static/**",
63
+ "**/temp/**",
64
+ "**/backup/**",
65
+ "**/backups/**",
66
+ "**/examples/**",
67
+ "**/docs/**",
68
+ "**/tests/**",
69
+ "**/__tests__/**",
70
+ "**/spec/**",
71
+ "**/__specs__/**",
72
+ "**/scripts/**",
73
+ "**/bin/**",
74
+ "**/hooks/**",
75
+ "**/config/**",
76
+ "**/configs/**",
77
+ "**/settings/**",
78
+ "**/.vscode/**",
79
+ "**/.idea/**"
80
+ ];
81
+ function findEnvFiles(startDir = process.cwd(), filter) {
82
+ const found = /* @__PURE__ */ new Set();
83
+ function addFile(file) {
84
+ const normalized = path3.normalize(file);
85
+ if (typeof filter === "function" && !filter(normalized)) {
86
+ return;
87
+ }
88
+ found.add(normalized);
89
+ }
90
+ let current = path3.resolve(startDir);
91
+ while (true) {
92
+ const envPath = path3.join(current, ".env");
93
+ if (fs3.existsSync(envPath)) {
94
+ addFile(envPath);
95
+ }
96
+ const parent = path3.dirname(current);
97
+ if (parent === current) {
98
+ break;
99
+ }
100
+ current = parent;
101
+ }
102
+ const files = glob.globSync("**/.env*", {
103
+ cwd: startDir,
104
+ absolute: true,
105
+ nodir: true,
106
+ ignore: DEFAULT_IGNORES
107
+ });
108
+ for (const file of files) {
109
+ addFile(file);
110
+ }
111
+ return [...found];
112
+ }
113
+ function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
114
+ const envFiles = findEnvFiles(startDir);
115
+ return envFiles.find((file) => {
116
+ try {
117
+ const content = fs3.readFileSync(file, "utf-8");
118
+ const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
119
+ return regex.test(content);
120
+ } catch (err) {
121
+ console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
122
+ return false;
123
+ }
124
+ });
125
+ }
126
+ module2.exports = {
127
+ DEFAULT_IGNORES,
128
+ findEnvFiles,
129
+ findEnvWithToken,
130
+ default: findEnvFiles
131
+ };
132
+ }
133
+ });
134
+
135
+ // src/binary-collections/config.cjs
136
+ var require_config = __commonJS({
137
+ "src/binary-collections/config.cjs"(exports2, module2) {
138
+ init_cjs_shims();
139
+ var path3 = require("path");
140
+ var { findEnvWithToken } = require_findEnvFiles();
141
+ require("dotenv").config({ path: findEnvWithToken(), quiet: true, overwrite: true });
46
142
  function getTempDir() {
47
143
  return process.env.TEMP_DIR || path3.join(process.cwd(), "tmp");
48
144
  }
@@ -133,7 +229,7 @@ var require_utils = __commonJS({
133
229
  try {
134
230
  fs3.rmdirSync(fullPath);
135
231
  console.log("deleted", fullPath);
136
- } catch (e) {
232
+ } catch (_e) {
137
233
  try {
138
234
  fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
139
235
  console.log("deleted", fullPath);
@@ -146,7 +242,7 @@ var require_utils = __commonJS({
146
242
  try {
147
243
  fs3.unlinkSync(fullPath);
148
244
  console.log("deleted", fullPath);
149
- } catch (e) {
245
+ } catch (_e) {
150
246
  try {
151
247
  fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
152
248
  console.log("deleted", fullPath);
@@ -235,11 +331,13 @@ init_cjs_shims();
235
331
 
236
332
  // src/git-diff.js
237
333
  init_cjs_shims();
334
+ var import_ansi_colors = __toESM(require("ansi-colors"), 1);
238
335
  var import_child_process = require("child_process");
239
336
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
337
+ var import_sbg_utility = require("sbg-utility");
240
338
  var import_upath2 = __toESM(require("upath"), 1);
241
339
  var import_url = require("url");
242
- var import_binary_collections_config = __toESM(require_binary_collections_config(), 1);
340
+ var import_config = __toESM(require_config(), 1);
243
341
 
244
342
  // src/utils/chatgpt.js
245
343
  init_cjs_shims();
@@ -358,7 +456,10 @@ async function writeQuestion(page, question) {
358
456
  async function clickSubmitButton(page) {
359
457
  console.log("Attempting to click the submit button...");
360
458
  try {
361
- const userMessageCountBefore = await page.$$eval('[data-message-author-role="user"]', (elements) => elements.length);
459
+ const userMessageCountBefore = await page.$$eval(
460
+ '[data-message-author-role="user"]',
461
+ (elements) => elements.length
462
+ );
362
463
  const waitForSubmit = async (timeout = 5e3) => {
363
464
  try {
364
465
  await page.waitForFunction(
@@ -374,18 +475,21 @@ async function clickSubmitButton(page) {
374
475
  return false;
375
476
  }
376
477
  };
377
- await page.waitForFunction(() => {
378
- const candidates = [
379
- document.querySelector('[data-testid="fruitjuice-send-button"]'),
380
- document.querySelector("#composer-submit-button"),
381
- document.querySelector('[data-testid="send-button"]')
382
- ].filter(Boolean);
383
- return candidates.some((button) => {
384
- const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
385
- const isVisible = button.offsetParent !== null;
386
- return !isDisabled && isVisible;
387
- });
388
- }, { timeout: 5e3 }).catch(() => {
478
+ await page.waitForFunction(
479
+ () => {
480
+ const candidates = [
481
+ document.querySelector('[data-testid="fruitjuice-send-button"]'),
482
+ document.querySelector("#composer-submit-button"),
483
+ document.querySelector('[data-testid="send-button"]')
484
+ ].filter(Boolean);
485
+ return candidates.some((button) => {
486
+ const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
487
+ const isVisible = button.offsetParent !== null;
488
+ return !isDisabled && isVisible;
489
+ });
490
+ },
491
+ { timeout: 5e3 }
492
+ ).catch(() => {
389
493
  });
390
494
  const buttonDetails = await page.evaluate(() => {
391
495
  const selectors = [
@@ -751,20 +855,24 @@ async function runChatGpt(chatgptOptions = {}) {
751
855
  var import_utils = __toESM(require_utils(), 1);
752
856
  var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
753
857
  var __dirname = import_upath2.default.dirname(__filename2);
754
- var DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("git-diff.txt");
755
- var GPT_DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("gpt-question.txt");
858
+ var args = (0, import_utils.getArgs)();
859
+ var positional = args._ || [];
860
+ var FILENAME = (0, import_sbg_utility.md5)((positional[0] || "default") + JSON.stringify(args));
861
+ var DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/${FILENAME}.txt`);
862
+ var GPT_DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/gpt-${FILENAME}.txt`);
756
863
  var CACHE_DIR = import_upath2.default.dirname(DIFF_OUTPUT);
757
864
  var DIFF_OUTPUT_RELATIVE = import_upath2.default.relative(process.cwd(), DIFF_OUTPUT);
758
865
  var GPT_DIFF_OUTPUT_RELATIVE = import_upath2.default.relative(process.cwd(), GPT_DIFF_OUTPUT);
759
- if (!import_fs_extra2.default.existsSync(CACHE_DIR)) {
760
- import_fs_extra2.default.mkdirSync(CACHE_DIR, { recursive: true });
761
- }
866
+ import_fs_extra2.default.ensureDirSync(CACHE_DIR, { mode: 493 });
762
867
  function showHelp() {
763
868
  console.log("\u{1F4DD} Git Diff Helper");
764
869
  console.log("\u{1F4C4} Usage:");
765
870
  console.log(" \u{1F4C2} git-diff FILE Show staged diff of specified file");
766
871
  console.log(" \u{1F4C2} git-diff --staged-only Show staged diff of all files");
767
872
  console.log(" \u{1F4C2} git-diff -s | -S Same as --staged-only");
873
+ console.log(" \u{1F4C2} git-diff --unstaged FILE Show unstaged diff of specified file");
874
+ console.log(" \u{1F4C2} git-diff --unstaged Show unstaged diff of all files");
875
+ console.log(" \u{1F4C2} git-diff -u Same as --unstaged");
768
876
  console.log(" \u{1F4C2} git-diff --ai Run ChatGPT automation for commit message");
769
877
  console.log(" \u{1F4C2} git-diff --help | -h Show this help message");
770
878
  console.log("");
@@ -781,13 +889,13 @@ function runGitDiff(command, successMessage, errorMessage) {
781
889
  // 10MB buffer to handle large diffs
782
890
  });
783
891
  if (!result || result.trim() === "") {
784
- console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
785
- import_fs_extra2.default.writeFileSync(DIFF_OUTPUT, "# No changes found\n");
892
+ console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
893
+ (0, import_sbg_utility.writefile)(DIFF_OUTPUT, "# No changes found\n");
786
894
  console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
787
- return;
895
+ return false;
788
896
  }
789
- import_fs_extra2.default.writeFileSync(DIFF_OUTPUT, result);
790
- import_fs_extra2.default.writeFileSync(
897
+ (0, import_sbg_utility.writefile)(DIFF_OUTPUT, result);
898
+ (0, import_sbg_utility.writefile)(
791
899
  GPT_DIFF_OUTPUT,
792
900
  `Hello, ChatGPT!
793
901
  Can you create a conventional commit message by diff content below:
@@ -800,7 +908,8 @@ Give me result as codeblock with language "text" only.
800
908
  Thank you!`
801
909
  );
802
910
  console.log(`\u2705 ${successMessage}`);
803
- console.log(`\u{1F4BE} GPT diff prompt saved to "${GPT_DIFF_OUTPUT_RELATIVE}"`);
911
+ console.log(`\u{1F4BE} GPT diff prompt saved to "${import_ansi_colors.default.green(GPT_DIFF_OUTPUT_RELATIVE)}"`);
912
+ return true;
804
913
  } catch (error) {
805
914
  console.error(`\u274C ${errorMessage}`);
806
915
  console.error(`\u{1F4DD} Command: ${command}`);
@@ -811,34 +920,71 @@ Thank you!`
811
920
  process.exit(1);
812
921
  }
813
922
  }
923
+ function fileHasChanges(file, mode) {
924
+ const command = mode === "staged" ? `git diff --cached --quiet -- "${file}"` : `git diff --quiet -- "${file}"`;
925
+ try {
926
+ (0, import_child_process.execSync)(command, { stdio: "ignore" });
927
+ return false;
928
+ } catch (error) {
929
+ if (error.status === 1) {
930
+ return true;
931
+ }
932
+ throw error;
933
+ }
934
+ }
814
935
  async function mainGitDiff() {
815
- const args = (0, import_utils.getArgs)();
816
- const positional = args._ || [];
817
936
  if (args.help || args.h) {
818
937
  showHelp();
819
938
  }
939
+ const useUnstaged = args.unstaged || args.u;
940
+ const fileFromFlag = typeof args.unstaged === "string" ? args.unstaged : typeof args.u === "string" ? args.u : null;
941
+ let hasDiff = false;
820
942
  if (args["staged-only"] || args.s || args.S) {
821
- runGitDiff(
943
+ hasDiff = runGitDiff(
822
944
  "git --no-pager diff --staged",
823
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
945
+ `Full staged diff saved to "${import_ansi_colors.default.green(DIFF_OUTPUT_RELATIVE)}"`,
824
946
  "Failed to save staged diff"
825
947
  );
826
948
  } else {
827
- const file = positional[0];
949
+ const file = positional[0] || fileFromFlag;
828
950
  if (!file) {
829
- runGitDiff(
951
+ const fullDiffModeLabel = useUnstaged ? "unstaged" : "unstaged";
952
+ hasDiff = runGitDiff(
830
953
  "git --no-pager diff",
831
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
954
+ `Full ${fullDiffModeLabel} diff saved to "${import_ansi_colors.default.green(DIFF_OUTPUT_RELATIVE)}"`,
832
955
  "Failed to save all diff's"
833
956
  );
834
957
  } else {
835
- runGitDiff(
836
- `git --no-pager diff --cached -- "${file}"`,
837
- `Staged diff of "${file}" saved to "${DIFF_OUTPUT_RELATIVE}"`,
838
- `Failed to generate diff for "${file}"`
958
+ let fileDiffMode = useUnstaged ? "unstaged" : "staged";
959
+ if (!useUnstaged && !fileHasChanges(file, "staged") && fileHasChanges(file, "unstaged")) {
960
+ fileDiffMode = "unstaged";
961
+ }
962
+ hasDiff = runGitDiff(
963
+ fileDiffMode === "unstaged" ? `git --no-pager diff -- "${file}"` : `git --no-pager diff --cached -- "${file}"`,
964
+ `${fileDiffMode[0].toUpperCase() + fileDiffMode.slice(1)} diff of "${file}" saved to "${import_ansi_colors.default.green(
965
+ DIFF_OUTPUT_RELATIVE
966
+ )}"`,
967
+ `Failed to generate ${fileDiffMode} diff for "${file}"`
839
968
  );
840
969
  }
841
970
  }
971
+ if (hasDiff) {
972
+ const opencodePrompt = [
973
+ "",
974
+ "\u{1F916} OpenCode Prompt Helper",
975
+ "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
976
+ "",
977
+ "\u{1F4C4} App Prompt:",
978
+ ` Generate a conventional commit message from diff file: ${DIFF_OUTPUT}`,
979
+ "",
980
+ "\u{1F4BB} CLI Command:",
981
+ ` opencode run "Generate a conventional commit message from diff file ${DIFF_OUTPUT}"`,
982
+ ""
983
+ ];
984
+ const opencodePromptPath = (0, import_config.getTempPath)(`git-diff/opencode-${FILENAME}.txt`);
985
+ (0, import_sbg_utility.writefile)(opencodePromptPath, opencodePrompt.join("\n"));
986
+ console.log(`\u{1F4A1} OpenCode prompt saved to "${import_ansi_colors.default.green(import_upath2.default.relative(process.cwd(), opencodePromptPath))}"`);
987
+ }
842
988
  if (args.ai) {
843
989
  try {
844
990
  await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
@@ -2,10 +2,11 @@
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
3
  import {
4
4
  mainGitDiff
5
- } from "./chunk-FCDQGYBF.mjs";
6
- import "./chunk-N436BNBK.mjs";
7
- import "./chunk-YYLIQQKF.mjs";
8
- import "./chunk-Z6JLYU2J.mjs";
5
+ } from "./chunk-SPTECFE5.mjs";
6
+ import "./chunk-G5UUEWUO.mjs";
7
+ import "./chunk-GAGABICI.mjs";
8
+ import "./chunk-H44UWUFY.mjs";
9
+ import "./chunk-5RTXZVCW.mjs";
9
10
  import {
10
11
  init_esm_shims
11
12
  } from "./chunk-QQ4A6DLD.mjs";