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
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
8
14
  var __copyProps = (to, from, except, desc) => {
9
15
  if (from && typeof from === "object" || typeof from === "function") {
10
16
  for (let key of __getOwnPropNames(from))
@@ -22,10 +28,249 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
28
  mod
23
29
  ));
24
30
 
31
+ // node_modules/tsup/assets/cjs_shims.js
32
+ var init_cjs_shims = __esm({
33
+ "node_modules/tsup/assets/cjs_shims.js"() {
34
+ }
35
+ });
36
+
37
+ // src/utils/findEnvFiles.cjs
38
+ var require_findEnvFiles = __commonJS({
39
+ "src/utils/findEnvFiles.cjs"(exports2, module2) {
40
+ init_cjs_shims();
41
+ var fs4 = require("fs");
42
+ var path3 = require("path");
43
+ var glob = require("glob");
44
+ var DEFAULT_IGNORES = [
45
+ "**/node_modules/**",
46
+ "**/.git/**",
47
+ "**/.yarn/**",
48
+ "**/.pnpm/**",
49
+ "**/dist/**",
50
+ "**/build/**",
51
+ "**/coverage/**",
52
+ "**/vendor/**",
53
+ "**/tmp/**",
54
+ "**/.cache/**",
55
+ "**/assets/**",
56
+ "**/logs/**",
57
+ "**/output/**",
58
+ "**/public/**",
59
+ "**/static/**",
60
+ "**/temp/**",
61
+ "**/backup/**",
62
+ "**/backups/**",
63
+ "**/examples/**",
64
+ "**/docs/**",
65
+ "**/tests/**",
66
+ "**/__tests__/**",
67
+ "**/spec/**",
68
+ "**/__specs__/**",
69
+ "**/scripts/**",
70
+ "**/bin/**",
71
+ "**/hooks/**",
72
+ "**/config/**",
73
+ "**/configs/**",
74
+ "**/settings/**",
75
+ "**/.vscode/**",
76
+ "**/.idea/**"
77
+ ];
78
+ function findEnvFiles(startDir = process.cwd(), filter) {
79
+ const found = /* @__PURE__ */ new Set();
80
+ function addFile(file) {
81
+ const normalized = path3.normalize(file);
82
+ if (typeof filter === "function" && !filter(normalized)) {
83
+ return;
84
+ }
85
+ found.add(normalized);
86
+ }
87
+ let current = path3.resolve(startDir);
88
+ while (true) {
89
+ const envPath = path3.join(current, ".env");
90
+ if (fs4.existsSync(envPath)) {
91
+ addFile(envPath);
92
+ }
93
+ const parent = path3.dirname(current);
94
+ if (parent === current) {
95
+ break;
96
+ }
97
+ current = parent;
98
+ }
99
+ const files = glob.globSync("**/.env*", {
100
+ cwd: startDir,
101
+ absolute: true,
102
+ nodir: true,
103
+ ignore: DEFAULT_IGNORES
104
+ });
105
+ for (const file of files) {
106
+ addFile(file);
107
+ }
108
+ return [...found];
109
+ }
110
+ function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
111
+ const envFiles = findEnvFiles(startDir);
112
+ return envFiles.find((file) => {
113
+ try {
114
+ const content = fs4.readFileSync(file, "utf-8");
115
+ if (tokenName instanceof RegExp) {
116
+ return tokenName.test(content);
117
+ }
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("upath");
140
+ var minimistLib = require("minimist");
141
+ var { findEnvWithToken } = require_findEnvFiles();
142
+ var dotenv = require("dotenv");
143
+ var { cosmiconfig } = require("cosmiconfig");
144
+ var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
145
+ loadDotenv();
146
+ var cliArgv = minimistLib(process.argv.slice(2), {
147
+ string: ["token"]
148
+ });
149
+ var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
150
+ function getTempPath2(...segments) {
151
+ return path3.join(process.env.TEMP_DIR || path3.join(process.cwd(), "tmp"), ...segments);
152
+ }
153
+ async function getConfig2(options = {}) {
154
+ const explorer = cosmiconfig("binary-collections", {
155
+ searchStrategy: "project",
156
+ stopDir: options.stopDir
157
+ });
158
+ try {
159
+ const result = await explorer.search(options.searchFrom);
160
+ return result ? result.config : null;
161
+ } catch {
162
+ return null;
163
+ }
164
+ }
165
+ module2.exports = {
166
+ getTempPath: getTempPath2,
167
+ GITHUB_ACCESS_TOKEN,
168
+ loadDotenv,
169
+ getConfig: getConfig2
170
+ };
171
+ }
172
+ });
173
+
174
+ // src/utils/isDebug.cjs
175
+ var require_isDebug = __commonJS({
176
+ "src/utils/isDebug.cjs"(exports2, module2) {
177
+ init_cjs_shims();
178
+ function isDebug2() {
179
+ if (globalThis.DEBUG !== void 0) {
180
+ if (typeof globalThis.DEBUG === "boolean") {
181
+ return globalThis.DEBUG;
182
+ }
183
+ return globalThis.DEBUG === "true" || globalThis.DEBUG === "1";
184
+ }
185
+ return process.env.DEBUG === "true" || process.env.NODE_ENV === "development" || process.env.DEBUG === "1";
186
+ }
187
+ module2.exports = isDebug2;
188
+ module2.exports.default = isDebug2;
189
+ module2.exports.isDebug = isDebug2;
190
+ }
191
+ });
192
+
193
+ // src/run-by-checksum/hash.cjs
194
+ var require_hash = __commonJS({
195
+ "src/run-by-checksum/hash.cjs"(exports2, module2) {
196
+ init_cjs_shims();
197
+ var fs4 = require("fs-extra");
198
+ var glob = require("glob");
199
+ var path3 = require("upath");
200
+ var CryptoJS = require("crypto-js");
201
+ var globSync = typeof glob.sync === "function" ? glob.sync : glob.globSync;
202
+ function getAllFiles({ patterns = [], ignore = [], cwd } = {}) {
203
+ const files = /* @__PURE__ */ new Set();
204
+ const root = path3.resolve(cwd || process.cwd());
205
+ for (const pattern of patterns) {
206
+ const matched = globSync(pattern, {
207
+ cwd: root,
208
+ nodir: true,
209
+ ignore,
210
+ absolute: false
211
+ });
212
+ for (const f of matched) {
213
+ files.add(path3.normalize(path3.resolve(root, f)));
214
+ }
215
+ }
216
+ return Array.from(files).sort();
217
+ }
218
+ function isBinaryFile(filePath, bytesToCheck = 8e3) {
219
+ const size = Math.max(0, Number(bytesToCheck) || 0);
220
+ if (size === 0) {
221
+ return false;
222
+ }
223
+ const fd = fs4.openSync(filePath, "r");
224
+ try {
225
+ const buffer = Buffer.allocUnsafe(size);
226
+ const bytesRead = fs4.readSync(fd, buffer, 0, size, 0);
227
+ for (let i = 0; i < bytesRead; i++) {
228
+ if (buffer[i] === 0) {
229
+ return true;
230
+ }
231
+ }
232
+ return false;
233
+ } finally {
234
+ fs4.closeSync(fd);
235
+ }
236
+ }
237
+ function hashFile(file) {
238
+ if (!isBinaryFile(file)) {
239
+ const content = fs4.readFileSync(file, "utf8");
240
+ const normalized = content.replace(/\s+/g, " ").trim();
241
+ return CryptoJS.SHA256(normalized).toString(CryptoJS.enc.Hex);
242
+ }
243
+ const stats = fs4.statSync(file);
244
+ const binHash = CryptoJS.algo.SHA256.create();
245
+ binHash.update(file);
246
+ binHash.update(String(stats.size));
247
+ return binHash.finalize().toString(CryptoJS.enc.Hex);
248
+ }
249
+ function buildChecksum(files = []) {
250
+ const hash = CryptoJS.algo.SHA256.create();
251
+ for (const file of files) {
252
+ hash.update(file);
253
+ hash.update(hashFile(file));
254
+ }
255
+ return hash.finalize().toString(CryptoJS.enc.Hex);
256
+ }
257
+ function sha2562(data, trim = 128) {
258
+ const hash = CryptoJS.SHA256(String(data)).toString(CryptoJS.enc.Hex);
259
+ return trim ? hash.substring(0, trim) : hash;
260
+ }
261
+ module2.exports = { getAllFiles, buildChecksum, sha256: sha2562 };
262
+ }
263
+ });
264
+
25
265
  // src/opencode-cli.ts
266
+ init_cjs_shims();
26
267
  var import_minimist = __toESM(require("minimist"), 1);
27
268
 
269
+ // src/opencode/database.ts
270
+ init_cjs_shims();
271
+
28
272
  // src/opencode/storage.ts
273
+ init_cjs_shims();
29
274
  var import_upath = __toESM(require("upath"), 1);
30
275
  var import_os = __toESM(require("os"), 1);
31
276
  var import_fs_extra = __toESM(require("fs-extra"), 1);
@@ -60,6 +305,7 @@ async function saveOpenCodeAuth(auth) {
60
305
  }
61
306
 
62
307
  // src/opencode/sqlite.ts
308
+ init_cjs_shims();
63
309
  var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
64
310
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
65
311
  var import_upath2 = __toESM(require("upath"), 1);
@@ -260,41 +506,115 @@ function escapeSql(value) {
260
506
  }
261
507
 
262
508
  // src/opencode/cli/auth-rotate.ts
263
- var import_upath3 = __toESM(require("upath"), 1);
509
+ init_cjs_shims();
264
510
 
265
511
  // src/opencode/utils/check-api.ts
512
+ init_cjs_shims();
266
513
  var import_axios = __toESM(require("axios"), 1);
267
514
  var import_sbg_utility = require("sbg-utility");
268
- async function checkOpenCodeApi(prompt, apiKey, model = "deepseek-v4-flash-free") {
269
- const res = await import_axios.default.post(
270
- "https://opencode.ai/zen/v1/chat/completions",
271
- {
272
- model,
273
- messages: [{ role: "user", content: prompt }],
274
- max_tokens: 512
275
- },
276
- {
277
- headers: { Authorization: `Bearer ${apiKey}` }
515
+ var import_config = __toESM(require_config(), 1);
516
+ var import_isDebug = __toESM(require_isDebug(), 1);
517
+ var import_hash = __toESM(require_hash(), 1);
518
+ var import_proxy_agent = require("proxy-agent");
519
+ function getProxyUrl(proxyUrl) {
520
+ 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;
521
+ }
522
+ function maskProxyUrl(proxyUrl) {
523
+ try {
524
+ const url = new URL(proxyUrl);
525
+ if (url.username || url.password) {
526
+ url.username = "***";
527
+ url.password = "***";
278
528
  }
279
- );
280
- const filePath = `tmp/logs/opencode-api-check-${Date.now()}.json`;
281
- (0, import_sbg_utility.writefile)(filePath, JSON.stringify(res.data, null, 2));
282
- const message = res.data.choices[0].message;
283
- const output = message.content || message.reasoning_content;
284
- const notEmptyOutput = output && output.trim().length > 0;
285
- return notEmptyOutput;
529
+ return url.toString();
530
+ } catch {
531
+ return proxyUrl.replace(/:\/\/.*@/, "://***@");
532
+ }
533
+ }
534
+ async function checkOpenCodeApi(prompt, apiKey, model = "deepseek-v4-flash-free", proxyUrl) {
535
+ var _a, _b, _c, _d, _e, _f, _g;
536
+ const debug = (0, import_isDebug.isDebug)();
537
+ const resolvedProxyUrl = getProxyUrl(proxyUrl);
538
+ let proxyAgent;
539
+ if (resolvedProxyUrl) {
540
+ const proxyUrlValue = resolvedProxyUrl;
541
+ proxyAgent = new import_proxy_agent.ProxyAgent({
542
+ getProxyForUrl: () => proxyUrlValue
543
+ });
544
+ }
545
+ try {
546
+ if (debug && resolvedProxyUrl) {
547
+ console.log(`Using proxy: ${maskProxyUrl(resolvedProxyUrl)}`);
548
+ }
549
+ const res = await import_axios.default.post(
550
+ "https://opencode.ai/zen/v1/chat/completions",
551
+ {
552
+ model,
553
+ messages: [{ role: "user", content: prompt }],
554
+ max_tokens: 512
555
+ },
556
+ {
557
+ headers: {
558
+ Authorization: `Bearer ${apiKey}`,
559
+ "Content-Type": "application/json"
560
+ },
561
+ validateStatus: () => true,
562
+ timeout: 3e4,
563
+ proxy: false,
564
+ httpAgent: proxyAgent,
565
+ httpsAgent: proxyAgent
566
+ }
567
+ );
568
+ if (debug) {
569
+ console.log("OpenCode status:", res.status);
570
+ }
571
+ const filePath = (0, import_config.getTempPath)("logs", `opencode-api-check-${(0, import_hash.sha256)(apiKey)}.json`);
572
+ if (debug) {
573
+ (0, import_sbg_utility.writefile)(filePath, JSON.stringify(res.data, null, 2));
574
+ console.log(`OpenCode API check response dumped to: ${filePath}`);
575
+ }
576
+ const errorType = (_b = (_a = res.data) == null ? void 0 : _a.error) == null ? void 0 : _b.type;
577
+ if (res.status === 429 && errorType === "FreeUsageLimitError") {
578
+ if (debug) {
579
+ console.warn("OpenCode API rate limit exceeded. Skipping this key.");
580
+ }
581
+ return false;
582
+ }
583
+ if (res.status < 200 || res.status >= 300) {
584
+ if (debug) {
585
+ console.error("OpenCode API returned non-2xx response:", res.data);
586
+ }
587
+ return false;
588
+ }
589
+ const message = (_e = (_d = (_c = res.data) == null ? void 0 : _c.choices) == null ? void 0 : _d[0]) == null ? void 0 : _e.message;
590
+ const output = (message == null ? void 0 : message.content) || (message == null ? void 0 : message.reasoning_content);
591
+ return Boolean(output && output.trim().length > 0);
592
+ } catch (err) {
593
+ if (debug) {
594
+ console.error("OpenCode API check failed");
595
+ if (import_axios.default.isAxiosError(err)) {
596
+ console.error("Message:", err.message);
597
+ console.error("Code:", err.code);
598
+ console.error("Status:", (_f = err.response) == null ? void 0 : _f.status);
599
+ console.error("Response:", (_g = err.response) == null ? void 0 : _g.data);
600
+ } else {
601
+ console.error(err);
602
+ }
603
+ }
604
+ return false;
605
+ }
286
606
  }
287
607
 
288
608
  // src/opencode/cli/auth-rotate.ts
289
- async function handleAuthRotate() {
290
- let keysFile = import_upath3.default.join(process.cwd(), ".opencode.keys.jsonc");
291
- let keys = await readJson(keysFile);
292
- if (!keys) {
293
- keysFile = import_upath3.default.join(process.cwd(), ".opencode.keys.json");
294
- keys = await readJson(keysFile);
295
- }
609
+ var import_config2 = __toESM(require_config(), 1);
610
+ async function handleAuthRotate(options) {
611
+ var _a;
612
+ const config = await (0, import_config2.getConfig)();
613
+ const keys = (_a = config == null ? void 0 : config.opencode) == null ? void 0 : _a.keys;
296
614
  if (!keys || !Array.isArray(keys) || keys.length === 0) {
297
- console.error("No valid .opencode.keys.json or .opencode.keys.jsonc found in current directory");
615
+ console.error(
616
+ 'No opencode.keys found in project config. Add an "opencode" section with a "keys" array to your binary-collections.config.{js,cjs,mjs} file.'
617
+ );
298
618
  process.exit(1);
299
619
  }
300
620
  const auth = await getOpenCodeAuth();
@@ -315,7 +635,7 @@ async function handleAuthRotate() {
315
635
  let chosen = null;
316
636
  for (const candidate of candidates) {
317
637
  try {
318
- const ok = await checkOpenCodeApi("Hello", candidate.key);
638
+ const ok = await checkOpenCodeApi("Hello", candidate.key, "deepseek-v4-flash-free", options == null ? void 0 : options.proxy);
319
639
  if (ok) {
320
640
  chosen = candidate;
321
641
  break;
@@ -333,6 +653,7 @@ async function handleAuthRotate() {
333
653
  }
334
654
 
335
655
  // src/opencode/cli/list-projects.ts
656
+ init_cjs_shims();
336
657
  async function handleListProjects() {
337
658
  const projects = await loadProjects();
338
659
  console.log(`Projects (${projects.length}):
@@ -353,6 +674,7 @@ async function handleListProjects() {
353
674
  }
354
675
 
355
676
  // src/opencode/cli/list-sessions.ts
677
+ init_cjs_shims();
356
678
  var import_moment = __toESM(require("moment"), 1);
357
679
  async function handleListSessions() {
358
680
  const sessions = await loadSessions();
@@ -388,7 +710,7 @@ async function handleListSessions() {
388
710
 
389
711
  // src/opencode-cli.ts
390
712
  var argv = (0, import_minimist.default)(process.argv.slice(2), {
391
- alias: { h: "help" }
713
+ alias: { h: "help", p: "proxy" }
392
714
  });
393
715
  function printHelp() {
394
716
  console.log(`
@@ -404,6 +726,7 @@ Commands:
404
726
 
405
727
  Options:
406
728
  -h, --help Show this help message
729
+ -p, --proxy <url> Proxy URL for API requests (format: protocol://ip:port or protocol://user:pass@ip:port)
407
730
  `);
408
731
  }
409
732
  async function main() {
@@ -458,7 +781,7 @@ async function main() {
458
781
  } else if (command === "auth") {
459
782
  const sub = argv._[1];
460
783
  if (sub === "rotate") {
461
- await handleAuthRotate();
784
+ await handleAuthRotate({ proxy: argv.proxy });
462
785
  } else {
463
786
  console.error(`Unknown subcommand: auth ${sub || ""}`);
464
787
  printHelp();
@@ -19,7 +19,7 @@ const auth_rotate_js_1 = require("./opencode/cli/auth-rotate.js");
19
19
  const list_projects_js_1 = require("./opencode/cli/list-projects.js");
20
20
  const list_sessions_js_1 = require("./opencode/cli/list-sessions.js");
21
21
  const argv = (0, minimist_1.default)(process.argv.slice(2), {
22
- alias: { h: 'help' }
22
+ alias: { h: 'help', p: 'proxy' }
23
23
  });
24
24
  function printHelp() {
25
25
  console.log(`
@@ -35,6 +35,7 @@ Commands:
35
35
 
36
36
  Options:
37
37
  -h, --help Show this help message
38
+ -p, --proxy <url> Proxy URL for API requests (format: protocol://ip:port or protocol://user:pass@ip:port)
38
39
  `);
39
40
  }
40
41
  function main() {
@@ -97,7 +98,7 @@ function main() {
97
98
  else if (command === 'auth') {
98
99
  const sub = argv._[1];
99
100
  if (sub === 'rotate') {
100
- yield (0, auth_rotate_js_1.handleAuthRotate)();
101
+ yield (0, auth_rotate_js_1.handleAuthRotate)({ proxy: argv.proxy });
101
102
  }
102
103
  else {
103
104
  console.error(`Unknown subcommand: auth ${sub || ''}`);
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
- import {
4
- handleAuthRotate
5
- } from "./chunk-YWSLMAQ7.mjs";
6
- import "./chunk-QZMGBDSA.mjs";
7
3
  import {
8
4
  handleListProjects
9
5
  } from "./chunk-UEOWRYAN.mjs";
10
6
  import {
11
7
  handleListSessions
12
8
  } from "./chunk-ZB4IQ6VJ.mjs";
9
+ import {
10
+ handleAuthRotate
11
+ } from "./chunk-KCJYREA2.mjs";
12
+ import "./chunk-BPED62FN.mjs";
13
+ import "./chunk-B77D3SR4.mjs";
13
14
  import {
14
15
  checkDatabase,
15
16
  deleteAllProjectSessions,
@@ -18,6 +19,9 @@ import {
18
19
  } from "./chunk-LACQTD5V.mjs";
19
20
  import "./chunk-56BVU63B.mjs";
20
21
  import "./chunk-XW5NZAKI.mjs";
22
+ import "./chunk-V6PTSDW5.mjs";
23
+ import "./chunk-3T6AMFI3.mjs";
24
+ import "./chunk-J4M5EL5P.mjs";
21
25
  import {
22
26
  init_esm_shims
23
27
  } from "./chunk-QQ4A6DLD.mjs";
@@ -26,7 +30,7 @@ import {
26
30
  init_esm_shims();
27
31
  import minimist from "minimist";
28
32
  var argv = minimist(process.argv.slice(2), {
29
- alias: { h: "help" }
33
+ alias: { h: "help", p: "proxy" }
30
34
  });
31
35
  function printHelp() {
32
36
  console.log(`
@@ -42,6 +46,7 @@ Commands:
42
46
 
43
47
  Options:
44
48
  -h, --help Show this help message
49
+ -p, --proxy <url> Proxy URL for API requests (format: protocol://ip:port or protocol://user:pass@ip:port)
45
50
  `);
46
51
  }
47
52
  async function main() {
@@ -96,7 +101,7 @@ async function main() {
96
101
  } else if (command === "auth") {
97
102
  const sub = argv._[1];
98
103
  if (sub === "rotate") {
99
- await handleAuthRotate();
104
+ await handleAuthRotate({ proxy: argv.proxy });
100
105
  } else {
101
106
  console.error(`Unknown subcommand: auth ${sub || ""}`);
102
107
  printHelp();
@@ -140,25 +140,33 @@ var require_config = __commonJS({
140
140
  var minimistLib = require("minimist");
141
141
  var { findEnvWithToken } = require_findEnvFiles();
142
142
  var dotenv = require("dotenv");
143
+ var { cosmiconfig } = require("cosmiconfig");
143
144
  var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
144
145
  loadDotenv();
145
146
  var cliArgv = minimistLib(process.argv.slice(2), {
146
147
  string: ["token"]
147
148
  });
148
149
  var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
149
- function getTempDir() {
150
- return process.env.TEMP_DIR || path3.join(process.cwd(), "tmp");
151
- }
152
150
  function getTempPath(...segments) {
153
- return path3.join(getTempDir(), ...segments);
151
+ return path3.join(process.env.TEMP_DIR || path3.join(process.cwd(), "tmp"), ...segments);
152
+ }
153
+ async function getConfig(options = {}) {
154
+ const explorer = cosmiconfig("binary-collections", {
155
+ searchStrategy: "project",
156
+ stopDir: options.stopDir
157
+ });
158
+ try {
159
+ const result = await explorer.search(options.searchFrom);
160
+ return result ? result.config : null;
161
+ } catch {
162
+ return null;
163
+ }
154
164
  }
155
- var TEMP_BASE_DIR = getTempDir();
156
165
  module2.exports = {
157
- getTempDir,
158
166
  getTempPath,
159
- TEMP_BASE_DIR,
160
167
  GITHUB_ACCESS_TOKEN,
161
- loadDotenv
168
+ loadDotenv,
169
+ getConfig
162
170
  };
163
171
  }
164
172
  });
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  resolvePackageResolutionUpdates
4
- } from "./chunk-JK3MG2KF.mjs";
4
+ } from "./chunk-NHD4HLSU.mjs";
5
5
  import "./chunk-KLKAIFKI.mjs";
6
- import "./chunk-SARIXFHP.mjs";
6
+ import "./chunk-3T6AMFI3.mjs";
7
7
  import "./chunk-J4M5EL5P.mjs";
8
8
  import "./chunk-6RK5UCTP.mjs";
9
9
  import {
@@ -144,25 +144,33 @@ var require_config = __commonJS({
144
144
  var minimistLib = require("minimist");
145
145
  var { findEnvWithToken } = require_findEnvFiles();
146
146
  var dotenv = require("dotenv");
147
+ var { cosmiconfig } = require("cosmiconfig");
147
148
  var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
148
149
  loadDotenv();
149
150
  var cliArgv = minimistLib(process.argv.slice(2), {
150
151
  string: ["token"]
151
152
  });
152
153
  var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
153
- function getTempDir() {
154
- return process.env.TEMP_DIR || path2.join(process.cwd(), "tmp");
155
- }
156
154
  function getTempPath(...segments) {
157
- return path2.join(getTempDir(), ...segments);
155
+ return path2.join(process.env.TEMP_DIR || path2.join(process.cwd(), "tmp"), ...segments);
156
+ }
157
+ async function getConfig(options = {}) {
158
+ const explorer = cosmiconfig("binary-collections", {
159
+ searchStrategy: "project",
160
+ stopDir: options.stopDir
161
+ });
162
+ try {
163
+ const result = await explorer.search(options.searchFrom);
164
+ return result ? result.config : null;
165
+ } catch {
166
+ return null;
167
+ }
158
168
  }
159
- var TEMP_BASE_DIR = getTempDir();
160
169
  module2.exports = {
161
- getTempDir,
162
170
  getTempPath,
163
- TEMP_BASE_DIR,
164
171
  GITHUB_ACCESS_TOKEN,
165
- loadDotenv
172
+ loadDotenv,
173
+ getConfig
166
174
  };
167
175
  }
168
176
  });
@@ -6,9 +6,9 @@ import {
6
6
  parseGitHubUrl,
7
7
  replaceRawWithLatestHash,
8
8
  resolvePackageResolutionUpdates
9
- } from "./chunk-JK3MG2KF.mjs";
9
+ } from "./chunk-NHD4HLSU.mjs";
10
10
  import "./chunk-KLKAIFKI.mjs";
11
- import "./chunk-SARIXFHP.mjs";
11
+ import "./chunk-3T6AMFI3.mjs";
12
12
  import "./chunk-J4M5EL5P.mjs";
13
13
  import "./chunk-6RK5UCTP.mjs";
14
14
  import "./chunk-QQ4A6DLD.mjs";