binary-collections 2.0.14 → 2.0.15

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 (145) hide show
  1. package/.opencode/plugins/opencode-request-logger/README.md +44 -0
  2. package/.venv/Lib/site-packages/pyarrow/tests/data/orc/README.md +22 -0
  3. package/docs-src/install-opencode-plugins.md +86 -0
  4. package/docs-src/opencode-cli.md +38 -10
  5. package/lib/binary-collections/config-types.cjs +17 -0
  6. package/lib/binary-collections/config-types.d.ts +12 -0
  7. package/lib/binary-collections/config-types.js +2 -0
  8. package/lib/binary-collections/config-types.mjs +7 -0
  9. package/lib/binary-collections/config.cjs +16 -8
  10. package/lib/binary-collections/config.d.cts +18 -10
  11. package/lib/binary-collections/config.mjs +1 -1
  12. package/lib/binary-collections/findScript.cjs +8 -6
  13. package/lib/binary-collections/findScript.mjs +2 -2
  14. package/lib/binary-collections/listScript.cjs +8 -6
  15. package/lib/binary-collections/listScript.mjs +2 -2
  16. package/lib/binary-collections.cjs +8 -6
  17. package/lib/binary-collections.mjs +3 -3
  18. package/lib/changelog.cjs +142 -4
  19. package/lib/changelog.mjs +9 -5
  20. package/lib/{chunk-SARIXFHP.mjs → chunk-3T6AMFI3.mjs} +16 -8
  21. package/lib/{chunk-3F6EIHYG.mjs → chunk-3ZF2QMDK.mjs} +3 -3
  22. package/lib/chunk-B77D3SR4.mjs +28 -0
  23. package/lib/chunk-BPED62FN.mjs +115 -0
  24. package/lib/{chunk-XI67TI46.mjs → chunk-DHFRWM2W.mjs} +1 -1
  25. package/lib/{chunk-2SJKVOTN.mjs → chunk-DPEE3FBB.mjs} +1 -1
  26. package/lib/{chunk-UYNBNLV5.mjs → chunk-H7AE4IO3.mjs} +1 -1
  27. package/lib/{chunk-YWSLMAQ7.mjs → chunk-KCJYREA2.mjs} +14 -12
  28. package/lib/{chunk-JK3MG2KF.mjs → chunk-NHD4HLSU.mjs} +1 -1
  29. package/lib/{chunk-I3O5ZRYU.mjs → chunk-OWNVMKAA.mjs} +1 -1
  30. package/lib/chunk-SKVF4TMD.mjs +59 -0
  31. package/lib/{chunk-SJYP66BO.mjs → chunk-TDUUOAQD.mjs} +1 -1
  32. package/lib/{chunk-D42YBRZW.mjs → chunk-UAEKSLAX.mjs} +1 -1
  33. package/lib/chunk-V6PTSDW5.mjs +82 -0
  34. package/lib/{chunk-AJ3OIYYP.mjs → chunk-WNUEY6VJ.mjs} +8 -6
  35. package/lib/{chunk-YLV4QATP.mjs → chunk-Z53IUBUN.mjs} +6 -5
  36. package/lib/{chunk-JMUFQSPE.mjs → chunk-Z7RM46Q4.mjs} +1 -1
  37. package/lib/cross-env/index.mjs +3 -3
  38. package/lib/git/git-diff-cli.cjs +16 -8
  39. package/lib/git/git-diff-cli.mjs +3 -3
  40. package/lib/git/git-diff.cjs +16 -8
  41. package/lib/git/git-diff.mjs +3 -3
  42. package/lib/git/git-fix.cjs +16 -8
  43. package/lib/git/git-fix.mjs +2 -2
  44. package/lib/git/user-config.cjs +16 -8
  45. package/lib/git/user-config.mjs +2 -2
  46. package/lib/github-workflows/clean-github-actions-caches-cli.cjs +16 -8
  47. package/lib/github-workflows/clean-github-actions-caches-cli.mjs +2 -2
  48. package/lib/github-workflows/clean-github-actions-caches.cjs +16 -8
  49. package/lib/github-workflows/clean-github-actions-caches.mjs +2 -2
  50. package/lib/github-workflows/get-latest-workflow-status-cli.cjs +16 -8
  51. package/lib/github-workflows/get-latest-workflow-status-cli.mjs +2 -2
  52. package/lib/github-workflows/utils.cjs +16 -8
  53. package/lib/github-workflows/utils.mjs +2 -2
  54. package/lib/github-workflows/workflow-badge-cli.cjs +16 -8
  55. package/lib/github-workflows/workflow-badge-cli.mjs +4 -4
  56. package/lib/node-cache-cleaner-cli.mjs +3 -3
  57. package/lib/opencode/cli/auth-rotate.cjs +343 -28
  58. package/lib/opencode/cli/auth-rotate.d.ts +3 -1
  59. package/lib/opencode/cli/auth-rotate.js +10 -15
  60. package/lib/opencode/cli/auth-rotate.mjs +6 -2
  61. package/lib/opencode/cli/auth-rotate.runner.cjs +454 -0
  62. package/lib/opencode/cli/auth-rotate.runner.d.ts +1 -0
  63. package/lib/opencode/cli/auth-rotate.runner.js +8 -0
  64. package/lib/opencode/cli/auth-rotate.runner.mjs +21 -0
  65. package/lib/opencode/install-opencode-plugins-cli.cjs +82 -0
  66. package/lib/opencode/install-opencode-plugins-cli.d.ts +1 -0
  67. package/lib/opencode/install-opencode-plugins-cli.js +78 -0
  68. package/lib/opencode/install-opencode-plugins-cli.mjs +65 -0
  69. package/lib/opencode/utils/check-api.cjs +332 -18
  70. package/lib/opencode/utils/check-api.d.ts +5 -1
  71. package/lib/opencode/utils/check-api.js +101 -15
  72. package/lib/opencode/utils/check-api.mjs +5 -1
  73. package/lib/opencode/utils/check-api.runner.cjs +0 -0
  74. package/lib/opencode/utils/check-api.runner.d.ts +0 -0
  75. package/lib/opencode/utils/check-api.runner.js +1 -0
  76. package/lib/opencode/utils/check-api.runner.mjs +7 -0
  77. package/lib/opencode-cli.cjs +352 -29
  78. package/lib/opencode-cli.js +3 -2
  79. package/lib/opencode-cli.mjs +11 -6
  80. package/lib/package-resolutions-updater-cli.cjs +16 -8
  81. package/lib/package-resolutions-updater-cli.mjs +2 -2
  82. package/lib/package-resolutions-updater.cjs +16 -8
  83. package/lib/package-resolutions-updater.mjs +2 -2
  84. package/lib/print-directory-tree.cjs +16 -8
  85. package/lib/print-directory-tree.mjs +1 -1
  86. package/lib/print-tarball-tree-cli.cjs +305 -0
  87. package/lib/print-tarball-tree-cli.d.mts +2 -0
  88. package/lib/print-tarball-tree-cli.mjs +54 -0
  89. package/lib/print-tarball-tree.cjs +43 -216
  90. package/lib/print-tarball-tree.d.mts +4 -1
  91. package/lib/print-tarball-tree.mjs +12 -66
  92. package/lib/rmpath-cli.cjs +16 -8
  93. package/lib/rmpath-cli.mjs +2 -2
  94. package/lib/rmpath.cjs +16 -8
  95. package/lib/rmpath.mjs +2 -2
  96. package/lib/run-by-checksum/hash.cjs +45 -67
  97. package/lib/run-by-checksum/{hash.d.ts → hash.d.cts} +9 -2
  98. package/lib/run-by-checksum/hash.mjs +3 -7
  99. package/lib/run-by-checksum/run.cjs +95 -58
  100. package/lib/run-by-checksum/run.js +3 -3
  101. package/lib/run-by-checksum/run.mjs +2 -2
  102. package/lib/run-by-checksum-cli.cjs +96 -74
  103. package/lib/run-by-checksum-cli.mjs +2 -2
  104. package/lib/submodule-install.cjs +16 -8
  105. package/lib/submodule-install.mjs +1 -1
  106. package/lib/submodule-remove-cli.cjs +16 -8
  107. package/lib/submodule-remove-cli.mjs +2 -2
  108. package/lib/submodule-remove.cjs +16 -8
  109. package/lib/submodule-remove.mjs +2 -2
  110. package/lib/utils/isDebug.cjs +13 -0
  111. package/lib/utils/isDebug.d.cts +9 -0
  112. package/lib/utils/isDebug.mjs +6 -0
  113. package/package.json +9 -7
  114. package/readme.md +63 -0
  115. package/releases/readme.md +1 -1
  116. package/lib/chunk-546KAIYT.mjs +0 -113
  117. package/lib/chunk-5WAOOOGZ.mjs +0 -77
  118. package/lib/chunk-72XTQ3CK.mjs +0 -45
  119. package/lib/chunk-7Q6YEUQF.mjs +0 -246
  120. package/lib/chunk-AQZ7LMFS.mjs +0 -100
  121. package/lib/chunk-BDCMTOZI.mjs +0 -246
  122. package/lib/chunk-BEUM4LH4.mjs +0 -184
  123. package/lib/chunk-BO4TZS4Q.mjs +0 -246
  124. package/lib/chunk-BZWVHODJ.mjs +0 -62
  125. package/lib/chunk-CM3IC5YC.mjs +0 -226
  126. package/lib/chunk-FR3DMHJC.mjs +0 -146
  127. package/lib/chunk-H44UWUFY.mjs +0 -105
  128. package/lib/chunk-JVMLKHD2.mjs +0 -62
  129. package/lib/chunk-KAT2JNLZ.mjs +0 -146
  130. package/lib/chunk-KRCPFWIF.mjs +0 -193
  131. package/lib/chunk-LVSPEFU2.mjs +0 -86
  132. package/lib/chunk-MCCMMZSM.mjs +0 -60
  133. package/lib/chunk-MGPYPKIE.mjs +0 -109
  134. package/lib/chunk-OA2RKEY3.mjs +0 -162
  135. package/lib/chunk-PAZH45HS.mjs +0 -41
  136. package/lib/chunk-QZMGBDSA.mjs +0 -32
  137. package/lib/chunk-RDGDLSPD.mjs +0 -76
  138. package/lib/chunk-RKPIBGKE.mjs +0 -61
  139. package/lib/chunk-SWUAEY4H.mjs +0 -44
  140. package/lib/chunk-UAIF5VIA.mjs +0 -89
  141. package/lib/chunk-UHPFLJXH.mjs +0 -227
  142. package/lib/chunk-WOC4FZ6F.mjs +0 -164
  143. package/lib/chunk-WSHVPGNM.mjs +0 -44
  144. package/lib/run-by-checksum/hash.js +0 -119
  145. package/readme.html +0 -784
package/lib/changelog.cjs CHANGED
@@ -180,12 +180,150 @@ var require_utils = __commonJS({
180
180
  }
181
181
  });
182
182
 
183
+ // src/utils/findEnvFiles.cjs
184
+ var require_findEnvFiles = __commonJS({
185
+ "src/utils/findEnvFiles.cjs"(exports2, module2) {
186
+ init_cjs_shims();
187
+ var fs2 = require("fs");
188
+ var path2 = require("path");
189
+ var glob = require("glob");
190
+ var DEFAULT_IGNORES = [
191
+ "**/node_modules/**",
192
+ "**/.git/**",
193
+ "**/.yarn/**",
194
+ "**/.pnpm/**",
195
+ "**/dist/**",
196
+ "**/build/**",
197
+ "**/coverage/**",
198
+ "**/vendor/**",
199
+ "**/tmp/**",
200
+ "**/.cache/**",
201
+ "**/assets/**",
202
+ "**/logs/**",
203
+ "**/output/**",
204
+ "**/public/**",
205
+ "**/static/**",
206
+ "**/temp/**",
207
+ "**/backup/**",
208
+ "**/backups/**",
209
+ "**/examples/**",
210
+ "**/docs/**",
211
+ "**/tests/**",
212
+ "**/__tests__/**",
213
+ "**/spec/**",
214
+ "**/__specs__/**",
215
+ "**/scripts/**",
216
+ "**/bin/**",
217
+ "**/hooks/**",
218
+ "**/config/**",
219
+ "**/configs/**",
220
+ "**/settings/**",
221
+ "**/.vscode/**",
222
+ "**/.idea/**"
223
+ ];
224
+ function findEnvFiles(startDir = process.cwd(), filter) {
225
+ const found = /* @__PURE__ */ new Set();
226
+ function addFile(file) {
227
+ const normalized = path2.normalize(file);
228
+ if (typeof filter === "function" && !filter(normalized)) {
229
+ return;
230
+ }
231
+ found.add(normalized);
232
+ }
233
+ let current = path2.resolve(startDir);
234
+ while (true) {
235
+ const envPath = path2.join(current, ".env");
236
+ if (fs2.existsSync(envPath)) {
237
+ addFile(envPath);
238
+ }
239
+ const parent = path2.dirname(current);
240
+ if (parent === current) {
241
+ break;
242
+ }
243
+ current = parent;
244
+ }
245
+ const files = glob.globSync("**/.env*", {
246
+ cwd: startDir,
247
+ absolute: true,
248
+ nodir: true,
249
+ ignore: DEFAULT_IGNORES
250
+ });
251
+ for (const file of files) {
252
+ addFile(file);
253
+ }
254
+ return [...found];
255
+ }
256
+ function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
257
+ const envFiles = findEnvFiles(startDir);
258
+ return envFiles.find((file) => {
259
+ try {
260
+ const content = fs2.readFileSync(file, "utf-8");
261
+ if (tokenName instanceof RegExp) {
262
+ return tokenName.test(content);
263
+ }
264
+ const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
265
+ return regex.test(content);
266
+ } catch (err) {
267
+ console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
268
+ return false;
269
+ }
270
+ });
271
+ }
272
+ module2.exports = {
273
+ DEFAULT_IGNORES,
274
+ findEnvFiles,
275
+ findEnvWithToken,
276
+ default: findEnvFiles
277
+ };
278
+ }
279
+ });
280
+
281
+ // src/binary-collections/config.cjs
282
+ var require_config = __commonJS({
283
+ "src/binary-collections/config.cjs"(exports2, module2) {
284
+ init_cjs_shims();
285
+ var path2 = require("upath");
286
+ var minimistLib = require("minimist");
287
+ var { findEnvWithToken } = require_findEnvFiles();
288
+ var dotenv = require("dotenv");
289
+ var { cosmiconfig } = require("cosmiconfig");
290
+ var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
291
+ loadDotenv();
292
+ var cliArgv = minimistLib(process.argv.slice(2), {
293
+ string: ["token"]
294
+ });
295
+ var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
296
+ function getTempPath2(...segments) {
297
+ return path2.join(process.env.TEMP_DIR || path2.join(process.cwd(), "tmp"), ...segments);
298
+ }
299
+ async function getConfig(options = {}) {
300
+ const explorer = cosmiconfig("binary-collections", {
301
+ searchStrategy: "project",
302
+ stopDir: options.stopDir
303
+ });
304
+ try {
305
+ const result = await explorer.search(options.searchFrom);
306
+ return result ? result.config : null;
307
+ } catch {
308
+ return null;
309
+ }
310
+ }
311
+ module2.exports = {
312
+ getTempPath: getTempPath2,
313
+ GITHUB_ACCESS_TOKEN,
314
+ loadDotenv,
315
+ getConfig
316
+ };
317
+ }
318
+ });
319
+
183
320
  // src/changelog.cjs
184
321
  init_cjs_shims();
185
322
  var fs = require("fs");
186
323
  var path = require("upath");
187
324
  var { EOL } = require("os");
188
325
  var { getArgs } = require_utils();
326
+ var { getTempPath } = require_config();
189
327
  var spawn = require("child_process").spawn;
190
328
  var pkgPath = path.join(process.cwd(), "package.json");
191
329
  if (!fs.existsSync(pkgPath)) {
@@ -363,9 +501,9 @@ function extractVersions(str) {
363
501
  `;
364
502
  }
365
503
  }
366
- fs.mkdirSync(path.join(__dirname, "tmp"), { recursive: true });
367
- fs.writeFileSync(path.join(__dirname, "tmp/original.md"), log);
368
- fs.writeFileSync(path.join(__dirname, "CHANGELOG.md"), markdown);
369
- console.log(`Original log written to tmp/original.md`);
504
+ const originalLogPath = getTempPath("original.md");
505
+ fs.mkdirSync(getTempPath(), { recursive: true });
506
+ fs.writeFileSync(originalLogPath, log);
507
+ console.log(`Original log written to ${originalLogPath}`);
370
508
  console.log(`Changelog updated successfully. You can find it at CHANGELOG.md`);
371
509
  })();
package/lib/changelog.mjs CHANGED
@@ -1,10 +1,13 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_config
4
+ } from "./chunk-3T6AMFI3.mjs";
5
+ import "./chunk-J4M5EL5P.mjs";
2
6
  import {
3
7
  require_utils
4
8
  } from "./chunk-6RK5UCTP.mjs";
5
9
  import {
6
10
  __commonJS,
7
- __dirname,
8
11
  __require,
9
12
  init_esm_shims
10
13
  } from "./chunk-QQ4A6DLD.mjs";
@@ -17,6 +20,7 @@ var require_changelog = __commonJS({
17
20
  var path = __require("upath");
18
21
  var { EOL } = __require("os");
19
22
  var { getArgs } = require_utils();
23
+ var { getTempPath } = require_config();
20
24
  var spawn = __require("child_process").spawn;
21
25
  var pkgPath = path.join(process.cwd(), "package.json");
22
26
  if (!fs.existsSync(pkgPath)) {
@@ -194,10 +198,10 @@ Example:`);
194
198
  `;
195
199
  }
196
200
  }
197
- fs.mkdirSync(path.join(__dirname, "tmp"), { recursive: true });
198
- fs.writeFileSync(path.join(__dirname, "tmp/original.md"), log);
199
- fs.writeFileSync(path.join(__dirname, "CHANGELOG.md"), markdown);
200
- console.log(`Original log written to tmp/original.md`);
201
+ const originalLogPath = getTempPath("original.md");
202
+ fs.mkdirSync(getTempPath(), { recursive: true });
203
+ fs.writeFileSync(originalLogPath, log);
204
+ console.log(`Original log written to ${originalLogPath}`);
201
205
  console.log(`Changelog updated successfully. You can find it at CHANGELOG.md`);
202
206
  })();
203
207
  }
@@ -16,25 +16,33 @@ var require_config = __commonJS({
16
16
  var minimistLib = __require("minimist");
17
17
  var { findEnvWithToken } = require_findEnvFiles();
18
18
  var dotenv = __require("dotenv");
19
+ var { cosmiconfig } = __require("cosmiconfig");
19
20
  var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
20
21
  loadDotenv();
21
22
  var cliArgv = minimistLib(process.argv.slice(2), {
22
23
  string: ["token"]
23
24
  });
24
25
  var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
25
- function getTempDir() {
26
- return process.env.TEMP_DIR || path.join(process.cwd(), "tmp");
27
- }
28
26
  function getTempPath(...segments) {
29
- return path.join(getTempDir(), ...segments);
27
+ return path.join(process.env.TEMP_DIR || path.join(process.cwd(), "tmp"), ...segments);
28
+ }
29
+ async function getConfig(options = {}) {
30
+ const explorer = cosmiconfig("binary-collections", {
31
+ searchStrategy: "project",
32
+ stopDir: options.stopDir
33
+ });
34
+ try {
35
+ const result = await explorer.search(options.searchFrom);
36
+ return result ? result.config : null;
37
+ } catch {
38
+ return null;
39
+ }
30
40
  }
31
- var TEMP_BASE_DIR = getTempDir();
32
41
  module.exports = {
33
- getTempDir,
34
42
  getTempPath,
35
- TEMP_BASE_DIR,
36
43
  GITHUB_ACCESS_TOKEN,
37
- loadDotenv
44
+ loadDotenv,
45
+ getConfig
38
46
  };
39
47
  }
40
48
  });
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_config
4
- } from "./chunk-SARIXFHP.mjs";
5
2
  import {
6
3
  runChatGpt
7
4
  } from "./chunk-GAGABICI.mjs";
5
+ import {
6
+ require_config
7
+ } from "./chunk-3T6AMFI3.mjs";
8
8
  import {
9
9
  require_utils
10
10
  } from "./chunk-6RK5UCTP.mjs";
@@ -0,0 +1,28 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ __commonJS,
4
+ init_esm_shims
5
+ } from "./chunk-QQ4A6DLD.mjs";
6
+
7
+ // src/utils/isDebug.cjs
8
+ var require_isDebug = __commonJS({
9
+ "src/utils/isDebug.cjs"(exports, module) {
10
+ init_esm_shims();
11
+ function isDebug() {
12
+ if (globalThis.DEBUG !== void 0) {
13
+ if (typeof globalThis.DEBUG === "boolean") {
14
+ return globalThis.DEBUG;
15
+ }
16
+ return globalThis.DEBUG === "true" || globalThis.DEBUG === "1";
17
+ }
18
+ return process.env.DEBUG === "true" || process.env.NODE_ENV === "development" || process.env.DEBUG === "1";
19
+ }
20
+ module.exports = isDebug;
21
+ module.exports.default = isDebug;
22
+ module.exports.isDebug = isDebug;
23
+ }
24
+ });
25
+
26
+ export {
27
+ require_isDebug
28
+ };
@@ -0,0 +1,115 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_isDebug
4
+ } from "./chunk-B77D3SR4.mjs";
5
+ import {
6
+ require_hash
7
+ } from "./chunk-V6PTSDW5.mjs";
8
+ import {
9
+ require_config
10
+ } from "./chunk-3T6AMFI3.mjs";
11
+ import {
12
+ __toESM,
13
+ init_esm_shims
14
+ } from "./chunk-QQ4A6DLD.mjs";
15
+
16
+ // src/opencode/utils/check-api.ts
17
+ init_esm_shims();
18
+ var import_config = __toESM(require_config(), 1);
19
+ var import_isDebug = __toESM(require_isDebug(), 1);
20
+ var import_hash = __toESM(require_hash(), 1);
21
+ import axios from "axios";
22
+ import { writefile } from "sbg-utility";
23
+ import { ProxyAgent } from "proxy-agent";
24
+ function getProxyUrl(proxyUrl) {
25
+ return proxyUrl || process.env.OPENCODE_PROXY || process.env.ALL_PROXY || process.env.all_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
26
+ }
27
+ function maskProxyUrl(proxyUrl) {
28
+ try {
29
+ const url = new URL(proxyUrl);
30
+ if (url.username || url.password) {
31
+ url.username = "***";
32
+ url.password = "***";
33
+ }
34
+ return url.toString();
35
+ } catch {
36
+ return proxyUrl.replace(/:\/\/.*@/, "://***@");
37
+ }
38
+ }
39
+ async function checkOpenCodeApi(prompt, apiKey, model = "deepseek-v4-flash-free", proxyUrl) {
40
+ var _a, _b, _c, _d, _e, _f, _g;
41
+ const debug = (0, import_isDebug.isDebug)();
42
+ const resolvedProxyUrl = getProxyUrl(proxyUrl);
43
+ let proxyAgent;
44
+ if (resolvedProxyUrl) {
45
+ const proxyUrlValue = resolvedProxyUrl;
46
+ proxyAgent = new ProxyAgent({
47
+ getProxyForUrl: () => proxyUrlValue
48
+ });
49
+ }
50
+ try {
51
+ if (debug && resolvedProxyUrl) {
52
+ console.log(`Using proxy: ${maskProxyUrl(resolvedProxyUrl)}`);
53
+ }
54
+ const res = await axios.post(
55
+ "https://opencode.ai/zen/v1/chat/completions",
56
+ {
57
+ model,
58
+ messages: [{ role: "user", content: prompt }],
59
+ max_tokens: 512
60
+ },
61
+ {
62
+ headers: {
63
+ Authorization: `Bearer ${apiKey}`,
64
+ "Content-Type": "application/json"
65
+ },
66
+ validateStatus: () => true,
67
+ timeout: 3e4,
68
+ proxy: false,
69
+ httpAgent: proxyAgent,
70
+ httpsAgent: proxyAgent
71
+ }
72
+ );
73
+ if (debug) {
74
+ console.log("OpenCode status:", res.status);
75
+ }
76
+ const filePath = (0, import_config.getTempPath)("logs", `opencode-api-check-${(0, import_hash.sha256)(apiKey)}.json`);
77
+ if (debug) {
78
+ writefile(filePath, JSON.stringify(res.data, null, 2));
79
+ console.log(`OpenCode API check response dumped to: ${filePath}`);
80
+ }
81
+ const errorType = (_b = (_a = res.data) == null ? void 0 : _a.error) == null ? void 0 : _b.type;
82
+ if (res.status === 429 && errorType === "FreeUsageLimitError") {
83
+ if (debug) {
84
+ console.warn("OpenCode API rate limit exceeded. Skipping this key.");
85
+ }
86
+ return false;
87
+ }
88
+ if (res.status < 200 || res.status >= 300) {
89
+ if (debug) {
90
+ console.error("OpenCode API returned non-2xx response:", res.data);
91
+ }
92
+ return false;
93
+ }
94
+ const message = (_e = (_d = (_c = res.data) == null ? void 0 : _c.choices) == null ? void 0 : _d[0]) == null ? void 0 : _e.message;
95
+ const output = (message == null ? void 0 : message.content) || (message == null ? void 0 : message.reasoning_content);
96
+ return Boolean(output && output.trim().length > 0);
97
+ } catch (err) {
98
+ if (debug) {
99
+ console.error("OpenCode API check failed");
100
+ if (axios.isAxiosError(err)) {
101
+ console.error("Message:", err.message);
102
+ console.error("Code:", err.code);
103
+ console.error("Status:", (_f = err.response) == null ? void 0 : _f.status);
104
+ console.error("Response:", (_g = err.response) == null ? void 0 : _g.data);
105
+ } else {
106
+ console.error(err);
107
+ }
108
+ }
109
+ return false;
110
+ }
111
+ }
112
+
113
+ export {
114
+ checkOpenCodeApi
115
+ };
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_package
4
- } from "./chunk-AJ3OIYYP.mjs";
4
+ } from "./chunk-WNUEY6VJ.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __dirname,
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_config
4
- } from "./chunk-SWUAEY4H.mjs";
4
+ } from "./chunk-3T6AMFI3.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-A3VUZEJK.mjs";
5
5
  import {
6
6
  require_config
7
- } from "./chunk-SWUAEY4H.mjs";
7
+ } from "./chunk-3T6AMFI3.mjs";
8
8
  import {
9
9
  require_utils
10
10
  } from "./chunk-6RK5UCTP.mjs";
@@ -1,28 +1,30 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  checkOpenCodeApi
4
- } from "./chunk-QZMGBDSA.mjs";
4
+ } from "./chunk-BPED62FN.mjs";
5
5
  import {
6
6
  getOpenCodeAuth,
7
- readJson,
8
7
  saveOpenCodeAuth
9
8
  } from "./chunk-XW5NZAKI.mjs";
10
9
  import {
10
+ require_config
11
+ } from "./chunk-3T6AMFI3.mjs";
12
+ import {
13
+ __toESM,
11
14
  init_esm_shims
12
15
  } from "./chunk-QQ4A6DLD.mjs";
13
16
 
14
17
  // src/opencode/cli/auth-rotate.ts
15
18
  init_esm_shims();
16
- import path from "upath";
17
- async function handleAuthRotate() {
18
- let keysFile = path.join(process.cwd(), ".opencode.keys.jsonc");
19
- let keys = await readJson(keysFile);
20
- if (!keys) {
21
- keysFile = path.join(process.cwd(), ".opencode.keys.json");
22
- keys = await readJson(keysFile);
23
- }
19
+ var import_config = __toESM(require_config(), 1);
20
+ async function handleAuthRotate(options) {
21
+ var _a;
22
+ const config = await (0, import_config.getConfig)();
23
+ const keys = (_a = config == null ? void 0 : config.opencode) == null ? void 0 : _a.keys;
24
24
  if (!keys || !Array.isArray(keys) || keys.length === 0) {
25
- console.error("No valid .opencode.keys.json or .opencode.keys.jsonc found in current directory");
25
+ console.error(
26
+ 'No opencode.keys found in project config. Add an "opencode" section with a "keys" array to your binary-collections.config.{js,cjs,mjs} file.'
27
+ );
26
28
  process.exit(1);
27
29
  }
28
30
  const auth = await getOpenCodeAuth();
@@ -43,7 +45,7 @@ async function handleAuthRotate() {
43
45
  let chosen = null;
44
46
  for (const candidate of candidates) {
45
47
  try {
46
- const ok = await checkOpenCodeApi("Hello", candidate.key);
48
+ const ok = await checkOpenCodeApi("Hello", candidate.key, "deepseek-v4-flash-free", options == null ? void 0 : options.proxy);
47
49
  if (ok) {
48
50
  chosen = candidate;
49
51
  break;
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-KLKAIFKI.mjs";
5
5
  import {
6
6
  require_config
7
- } from "./chunk-SARIXFHP.mjs";
7
+ } from "./chunk-3T6AMFI3.mjs";
8
8
  import {
9
9
  require_utils
10
10
  } from "./chunk-6RK5UCTP.mjs";
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_config
4
- } from "./chunk-SARIXFHP.mjs";
4
+ } from "./chunk-3T6AMFI3.mjs";
5
5
  import {
6
6
  __toESM,
7
7
  init_esm_shims
@@ -0,0 +1,59 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ init_esm_shims
4
+ } from "./chunk-QQ4A6DLD.mjs";
5
+
6
+ // src/print-tarball-tree.mjs
7
+ init_esm_shims();
8
+ import fs from "fs";
9
+ import * as zlib from "zlib";
10
+ import { pipeline } from "stream/promises";
11
+ import tar from "tar-stream";
12
+ function addToTree(tree, parts) {
13
+ let node = tree;
14
+ for (const part of parts) {
15
+ if (!node[part]) node[part] = {};
16
+ node = node[part];
17
+ }
18
+ return tree;
19
+ }
20
+ function formatTree(node, prefix = "") {
21
+ const lines = [];
22
+ const entries = Object.keys(node).sort();
23
+ entries.forEach(function(key, index) {
24
+ const isLast = index === entries.length - 1;
25
+ const child = node[key];
26
+ const line = prefix + (isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + key;
27
+ const newPrefix = prefix + (isLast ? " " : "\u2502 ");
28
+ lines.push(line);
29
+ lines.push(...formatTree(child, newPrefix));
30
+ });
31
+ return lines;
32
+ }
33
+ function printTree(node, prefix = "", logger = console.log) {
34
+ for (const line of formatTree(node, prefix)) {
35
+ logger(line);
36
+ }
37
+ }
38
+ async function printTgzTree(filePath, options = {}) {
39
+ const logger = options.logger || console.log;
40
+ const extract = tar.extract();
41
+ const tree = {};
42
+ extract.on("entry", function(header, stream, next) {
43
+ const parts = header.name.split("/").filter(Boolean);
44
+ if (parts.length) addToTree(tree, parts);
45
+ stream.once("end", next);
46
+ stream.once("error", next);
47
+ stream.resume();
48
+ });
49
+ await pipeline(fs.createReadStream(filePath), zlib.createGunzip(), extract);
50
+ printTree(tree, "", logger);
51
+ return tree;
52
+ }
53
+
54
+ export {
55
+ addToTree,
56
+ formatTree,
57
+ printTree,
58
+ printTgzTree
59
+ };
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_config
4
- } from "./chunk-SWUAEY4H.mjs";
4
+ } from "./chunk-3T6AMFI3.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_package
4
- } from "./chunk-AJ3OIYYP.mjs";
4
+ } from "./chunk-WNUEY6VJ.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __dirname,
@@ -0,0 +1,82 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ __commonJS,
4
+ __require,
5
+ init_esm_shims
6
+ } from "./chunk-QQ4A6DLD.mjs";
7
+
8
+ // src/run-by-checksum/hash.cjs
9
+ var require_hash = __commonJS({
10
+ "src/run-by-checksum/hash.cjs"(exports, module) {
11
+ init_esm_shims();
12
+ var fs = __require("fs-extra");
13
+ var glob = __require("glob");
14
+ var path = __require("upath");
15
+ var CryptoJS = __require("crypto-js");
16
+ var globSync = typeof glob.sync === "function" ? glob.sync : glob.globSync;
17
+ function getAllFiles({ patterns = [], ignore = [], cwd } = {}) {
18
+ const files = /* @__PURE__ */ new Set();
19
+ const root = path.resolve(cwd || process.cwd());
20
+ for (const pattern of patterns) {
21
+ const matched = globSync(pattern, {
22
+ cwd: root,
23
+ nodir: true,
24
+ ignore,
25
+ absolute: false
26
+ });
27
+ for (const f of matched) {
28
+ files.add(path.normalize(path.resolve(root, f)));
29
+ }
30
+ }
31
+ return Array.from(files).sort();
32
+ }
33
+ function isBinaryFile(filePath, bytesToCheck = 8e3) {
34
+ const size = Math.max(0, Number(bytesToCheck) || 0);
35
+ if (size === 0) {
36
+ return false;
37
+ }
38
+ const fd = fs.openSync(filePath, "r");
39
+ try {
40
+ const buffer = Buffer.allocUnsafe(size);
41
+ const bytesRead = fs.readSync(fd, buffer, 0, size, 0);
42
+ for (let i = 0; i < bytesRead; i++) {
43
+ if (buffer[i] === 0) {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
48
+ } finally {
49
+ fs.closeSync(fd);
50
+ }
51
+ }
52
+ function hashFile(file) {
53
+ if (!isBinaryFile(file)) {
54
+ const content = fs.readFileSync(file, "utf8");
55
+ const normalized = content.replace(/\s+/g, " ").trim();
56
+ return CryptoJS.SHA256(normalized).toString(CryptoJS.enc.Hex);
57
+ }
58
+ const stats = fs.statSync(file);
59
+ const binHash = CryptoJS.algo.SHA256.create();
60
+ binHash.update(file);
61
+ binHash.update(String(stats.size));
62
+ return binHash.finalize().toString(CryptoJS.enc.Hex);
63
+ }
64
+ function buildChecksum(files = []) {
65
+ const hash = CryptoJS.algo.SHA256.create();
66
+ for (const file of files) {
67
+ hash.update(file);
68
+ hash.update(hashFile(file));
69
+ }
70
+ return hash.finalize().toString(CryptoJS.enc.Hex);
71
+ }
72
+ function sha256(data, trim = 128) {
73
+ const hash = CryptoJS.SHA256(String(data)).toString(CryptoJS.enc.Hex);
74
+ return trim ? hash.substring(0, trim) : hash;
75
+ }
76
+ module.exports = { getAllFiles, buildChecksum, sha256 };
77
+ }
78
+ });
79
+
80
+ export {
81
+ require_hash
82
+ };