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
@@ -0,0 +1,454 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // node_modules/tsup/assets/cjs_shims.js
31
+ var init_cjs_shims = __esm({
32
+ "node_modules/tsup/assets/cjs_shims.js"() {
33
+ }
34
+ });
35
+
36
+ // src/utils/findEnvFiles.cjs
37
+ var require_findEnvFiles = __commonJS({
38
+ "src/utils/findEnvFiles.cjs"(exports2, module2) {
39
+ init_cjs_shims();
40
+ var fs2 = require("fs");
41
+ var path2 = require("path");
42
+ var glob = require("glob");
43
+ var DEFAULT_IGNORES = [
44
+ "**/node_modules/**",
45
+ "**/.git/**",
46
+ "**/.yarn/**",
47
+ "**/.pnpm/**",
48
+ "**/dist/**",
49
+ "**/build/**",
50
+ "**/coverage/**",
51
+ "**/vendor/**",
52
+ "**/tmp/**",
53
+ "**/.cache/**",
54
+ "**/assets/**",
55
+ "**/logs/**",
56
+ "**/output/**",
57
+ "**/public/**",
58
+ "**/static/**",
59
+ "**/temp/**",
60
+ "**/backup/**",
61
+ "**/backups/**",
62
+ "**/examples/**",
63
+ "**/docs/**",
64
+ "**/tests/**",
65
+ "**/__tests__/**",
66
+ "**/spec/**",
67
+ "**/__specs__/**",
68
+ "**/scripts/**",
69
+ "**/bin/**",
70
+ "**/hooks/**",
71
+ "**/config/**",
72
+ "**/configs/**",
73
+ "**/settings/**",
74
+ "**/.vscode/**",
75
+ "**/.idea/**"
76
+ ];
77
+ function findEnvFiles(startDir = process.cwd(), filter) {
78
+ const found = /* @__PURE__ */ new Set();
79
+ function addFile(file) {
80
+ const normalized = path2.normalize(file);
81
+ if (typeof filter === "function" && !filter(normalized)) {
82
+ return;
83
+ }
84
+ found.add(normalized);
85
+ }
86
+ let current = path2.resolve(startDir);
87
+ while (true) {
88
+ const envPath = path2.join(current, ".env");
89
+ if (fs2.existsSync(envPath)) {
90
+ addFile(envPath);
91
+ }
92
+ const parent = path2.dirname(current);
93
+ if (parent === current) {
94
+ break;
95
+ }
96
+ current = parent;
97
+ }
98
+ const files = glob.globSync("**/.env*", {
99
+ cwd: startDir,
100
+ absolute: true,
101
+ nodir: true,
102
+ ignore: DEFAULT_IGNORES
103
+ });
104
+ for (const file of files) {
105
+ addFile(file);
106
+ }
107
+ return [...found];
108
+ }
109
+ function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
110
+ const envFiles = findEnvFiles(startDir);
111
+ return envFiles.find((file) => {
112
+ try {
113
+ const content = fs2.readFileSync(file, "utf-8");
114
+ if (tokenName instanceof RegExp) {
115
+ return tokenName.test(content);
116
+ }
117
+ const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
118
+ return regex.test(content);
119
+ } catch (err) {
120
+ console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
121
+ return false;
122
+ }
123
+ });
124
+ }
125
+ module2.exports = {
126
+ DEFAULT_IGNORES,
127
+ findEnvFiles,
128
+ findEnvWithToken,
129
+ default: findEnvFiles
130
+ };
131
+ }
132
+ });
133
+
134
+ // src/binary-collections/config.cjs
135
+ var require_config = __commonJS({
136
+ "src/binary-collections/config.cjs"(exports2, module2) {
137
+ init_cjs_shims();
138
+ var path2 = require("upath");
139
+ var minimistLib = require("minimist");
140
+ var { findEnvWithToken } = require_findEnvFiles();
141
+ var dotenv = require("dotenv");
142
+ var { cosmiconfig } = require("cosmiconfig");
143
+ var loadDotenv = (tokenKey = /ACCESS_TOKEN|GITHUB_TOKEN/) => dotenv.config({ path: findEnvWithToken(void 0, tokenKey), quiet: true, overwrite: true });
144
+ loadDotenv();
145
+ var cliArgv = minimistLib(process.argv.slice(2), {
146
+ string: ["token"]
147
+ });
148
+ var GITHUB_ACCESS_TOKEN = cliArgv.token || process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
149
+ function getTempPath2(...segments) {
150
+ return path2.join(process.env.TEMP_DIR || path2.join(process.cwd(), "tmp"), ...segments);
151
+ }
152
+ async function getConfig2(options = {}) {
153
+ const explorer = cosmiconfig("binary-collections", {
154
+ searchStrategy: "project",
155
+ stopDir: options.stopDir
156
+ });
157
+ try {
158
+ const result = await explorer.search(options.searchFrom);
159
+ return result ? result.config : null;
160
+ } catch {
161
+ return null;
162
+ }
163
+ }
164
+ module2.exports = {
165
+ getTempPath: getTempPath2,
166
+ GITHUB_ACCESS_TOKEN,
167
+ loadDotenv,
168
+ getConfig: getConfig2
169
+ };
170
+ }
171
+ });
172
+
173
+ // src/utils/isDebug.cjs
174
+ var require_isDebug = __commonJS({
175
+ "src/utils/isDebug.cjs"(exports2, module2) {
176
+ init_cjs_shims();
177
+ function isDebug2() {
178
+ if (globalThis.DEBUG !== void 0) {
179
+ if (typeof globalThis.DEBUG === "boolean") {
180
+ return globalThis.DEBUG;
181
+ }
182
+ return globalThis.DEBUG === "true" || globalThis.DEBUG === "1";
183
+ }
184
+ return process.env.DEBUG === "true" || process.env.NODE_ENV === "development" || process.env.DEBUG === "1";
185
+ }
186
+ module2.exports = isDebug2;
187
+ module2.exports.default = isDebug2;
188
+ module2.exports.isDebug = isDebug2;
189
+ }
190
+ });
191
+
192
+ // src/run-by-checksum/hash.cjs
193
+ var require_hash = __commonJS({
194
+ "src/run-by-checksum/hash.cjs"(exports2, module2) {
195
+ init_cjs_shims();
196
+ var fs2 = require("fs-extra");
197
+ var glob = require("glob");
198
+ var path2 = require("upath");
199
+ var CryptoJS = require("crypto-js");
200
+ var globSync = typeof glob.sync === "function" ? glob.sync : glob.globSync;
201
+ function getAllFiles({ patterns = [], ignore = [], cwd } = {}) {
202
+ const files = /* @__PURE__ */ new Set();
203
+ const root = path2.resolve(cwd || process.cwd());
204
+ for (const pattern of patterns) {
205
+ const matched = globSync(pattern, {
206
+ cwd: root,
207
+ nodir: true,
208
+ ignore,
209
+ absolute: false
210
+ });
211
+ for (const f of matched) {
212
+ files.add(path2.normalize(path2.resolve(root, f)));
213
+ }
214
+ }
215
+ return Array.from(files).sort();
216
+ }
217
+ function isBinaryFile(filePath, bytesToCheck = 8e3) {
218
+ const size = Math.max(0, Number(bytesToCheck) || 0);
219
+ if (size === 0) {
220
+ return false;
221
+ }
222
+ const fd = fs2.openSync(filePath, "r");
223
+ try {
224
+ const buffer = Buffer.allocUnsafe(size);
225
+ const bytesRead = fs2.readSync(fd, buffer, 0, size, 0);
226
+ for (let i = 0; i < bytesRead; i++) {
227
+ if (buffer[i] === 0) {
228
+ return true;
229
+ }
230
+ }
231
+ return false;
232
+ } finally {
233
+ fs2.closeSync(fd);
234
+ }
235
+ }
236
+ function hashFile(file) {
237
+ if (!isBinaryFile(file)) {
238
+ const content = fs2.readFileSync(file, "utf8");
239
+ const normalized = content.replace(/\s+/g, " ").trim();
240
+ return CryptoJS.SHA256(normalized).toString(CryptoJS.enc.Hex);
241
+ }
242
+ const stats = fs2.statSync(file);
243
+ const binHash = CryptoJS.algo.SHA256.create();
244
+ binHash.update(file);
245
+ binHash.update(String(stats.size));
246
+ return binHash.finalize().toString(CryptoJS.enc.Hex);
247
+ }
248
+ function buildChecksum(files = []) {
249
+ const hash = CryptoJS.algo.SHA256.create();
250
+ for (const file of files) {
251
+ hash.update(file);
252
+ hash.update(hashFile(file));
253
+ }
254
+ return hash.finalize().toString(CryptoJS.enc.Hex);
255
+ }
256
+ function sha2562(data, trim = 128) {
257
+ const hash = CryptoJS.SHA256(String(data)).toString(CryptoJS.enc.Hex);
258
+ return trim ? hash.substring(0, trim) : hash;
259
+ }
260
+ module2.exports = { getAllFiles, buildChecksum, sha256: sha2562 };
261
+ }
262
+ });
263
+
264
+ // src/opencode/cli/auth-rotate.runner.ts
265
+ init_cjs_shims();
266
+
267
+ // src/opencode/cli/auth-rotate.ts
268
+ init_cjs_shims();
269
+
270
+ // src/opencode/storage.ts
271
+ init_cjs_shims();
272
+ var import_upath = __toESM(require("upath"), 1);
273
+ var import_os = __toESM(require("os"), 1);
274
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
275
+ var import_jsonc_parser = require("jsonc-parser");
276
+ var OPCODE_DIR = import_upath.default.join(import_os.default.homedir(), ".local/share/opencode");
277
+ var CONFIG_DIR = import_upath.default.join(import_os.default.homedir(), ".config/opencode");
278
+ var CACHE_DIR = import_upath.default.join(import_os.default.homedir(), ".cache/opencode");
279
+ var LOG_DIR = import_upath.default.join(OPCODE_DIR, "log");
280
+ var AUTH_PATH = import_upath.default.join(OPCODE_DIR, "auth.json");
281
+ var PROJECT_DIR = import_upath.default.join(OPCODE_DIR, "project");
282
+ var STORAGE_PATH = import_upath.default.join(OPCODE_DIR, "storage");
283
+ var SESSION_PATH = import_upath.default.join(STORAGE_PATH, "session");
284
+ var SESSION_DIFF_DIR = import_upath.default.join(STORAGE_PATH, "session_diff");
285
+ var DATABASE_PATH = import_upath.default.join(OPCODE_DIR, "opencode.db");
286
+ async function readJson(filePath) {
287
+ try {
288
+ const content = await import_fs_extra.default.readFile(filePath, "utf-8");
289
+ return (0, import_jsonc_parser.parse)(content);
290
+ } catch {
291
+ return null;
292
+ }
293
+ }
294
+ function getOpenCodeAuth() {
295
+ const file = import_upath.default.join(OPCODE_DIR, "auth.json");
296
+ if (!import_fs_extra.default.existsSync(file)) return null;
297
+ return readJson(file);
298
+ }
299
+ async function saveOpenCodeAuth(auth) {
300
+ const file = import_upath.default.join(OPCODE_DIR, "auth.json");
301
+ await import_fs_extra.default.ensureFile(file);
302
+ await import_fs_extra.default.writeFile(file, JSON.stringify(auth, null, 2), "utf-8");
303
+ }
304
+
305
+ // src/opencode/utils/check-api.ts
306
+ init_cjs_shims();
307
+ var import_axios = __toESM(require("axios"), 1);
308
+ var import_sbg_utility = require("sbg-utility");
309
+ var import_config = __toESM(require_config(), 1);
310
+ var import_isDebug = __toESM(require_isDebug(), 1);
311
+ var import_hash = __toESM(require_hash(), 1);
312
+ var import_proxy_agent = require("proxy-agent");
313
+ function getProxyUrl(proxyUrl) {
314
+ 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;
315
+ }
316
+ function maskProxyUrl(proxyUrl) {
317
+ try {
318
+ const url = new URL(proxyUrl);
319
+ if (url.username || url.password) {
320
+ url.username = "***";
321
+ url.password = "***";
322
+ }
323
+ return url.toString();
324
+ } catch {
325
+ return proxyUrl.replace(/:\/\/.*@/, "://***@");
326
+ }
327
+ }
328
+ async function checkOpenCodeApi(prompt, apiKey, model = "deepseek-v4-flash-free", proxyUrl) {
329
+ var _a, _b, _c, _d, _e, _f, _g;
330
+ const debug = (0, import_isDebug.isDebug)();
331
+ const resolvedProxyUrl = getProxyUrl(proxyUrl);
332
+ let proxyAgent;
333
+ if (resolvedProxyUrl) {
334
+ const proxyUrlValue = resolvedProxyUrl;
335
+ proxyAgent = new import_proxy_agent.ProxyAgent({
336
+ getProxyForUrl: () => proxyUrlValue
337
+ });
338
+ }
339
+ try {
340
+ if (debug && resolvedProxyUrl) {
341
+ console.log(`Using proxy: ${maskProxyUrl(resolvedProxyUrl)}`);
342
+ }
343
+ const res = await import_axios.default.post(
344
+ "https://opencode.ai/zen/v1/chat/completions",
345
+ {
346
+ model,
347
+ messages: [{ role: "user", content: prompt }],
348
+ max_tokens: 512
349
+ },
350
+ {
351
+ headers: {
352
+ Authorization: `Bearer ${apiKey}`,
353
+ "Content-Type": "application/json"
354
+ },
355
+ validateStatus: () => true,
356
+ timeout: 3e4,
357
+ proxy: false,
358
+ httpAgent: proxyAgent,
359
+ httpsAgent: proxyAgent
360
+ }
361
+ );
362
+ if (debug) {
363
+ console.log("OpenCode status:", res.status);
364
+ }
365
+ const filePath = (0, import_config.getTempPath)("logs", `opencode-api-check-${(0, import_hash.sha256)(apiKey)}.json`);
366
+ if (debug) {
367
+ (0, import_sbg_utility.writefile)(filePath, JSON.stringify(res.data, null, 2));
368
+ console.log(`OpenCode API check response dumped to: ${filePath}`);
369
+ }
370
+ const errorType = (_b = (_a = res.data) == null ? void 0 : _a.error) == null ? void 0 : _b.type;
371
+ if (res.status === 429 && errorType === "FreeUsageLimitError") {
372
+ if (debug) {
373
+ console.warn("OpenCode API rate limit exceeded. Skipping this key.");
374
+ }
375
+ return false;
376
+ }
377
+ if (res.status < 200 || res.status >= 300) {
378
+ if (debug) {
379
+ console.error("OpenCode API returned non-2xx response:", res.data);
380
+ }
381
+ return false;
382
+ }
383
+ const message = (_e = (_d = (_c = res.data) == null ? void 0 : _c.choices) == null ? void 0 : _d[0]) == null ? void 0 : _e.message;
384
+ const output = (message == null ? void 0 : message.content) || (message == null ? void 0 : message.reasoning_content);
385
+ return Boolean(output && output.trim().length > 0);
386
+ } catch (err) {
387
+ if (debug) {
388
+ console.error("OpenCode API check failed");
389
+ if (import_axios.default.isAxiosError(err)) {
390
+ console.error("Message:", err.message);
391
+ console.error("Code:", err.code);
392
+ console.error("Status:", (_f = err.response) == null ? void 0 : _f.status);
393
+ console.error("Response:", (_g = err.response) == null ? void 0 : _g.data);
394
+ } else {
395
+ console.error(err);
396
+ }
397
+ }
398
+ return false;
399
+ }
400
+ }
401
+
402
+ // src/opencode/cli/auth-rotate.ts
403
+ var import_config2 = __toESM(require_config(), 1);
404
+ async function handleAuthRotate(options) {
405
+ var _a;
406
+ const config = await (0, import_config2.getConfig)();
407
+ const keys = (_a = config == null ? void 0 : config.opencode) == null ? void 0 : _a.keys;
408
+ if (!keys || !Array.isArray(keys) || keys.length === 0) {
409
+ console.error(
410
+ 'No opencode.keys found in project config. Add an "opencode" section with a "keys" array to your binary-collections.config.{js,cjs,mjs} file.'
411
+ );
412
+ process.exit(1);
413
+ }
414
+ const auth = await getOpenCodeAuth();
415
+ if (!auth) {
416
+ console.error("No auth file found. Run configure first.");
417
+ process.exit(1);
418
+ }
419
+ const currentKey = auth.opencode.key;
420
+ const candidates = keys.filter((k) => k.key !== currentKey);
421
+ if (candidates.length === 0) {
422
+ console.error("No other keys available to rotate to");
423
+ process.exit(1);
424
+ }
425
+ for (let i = candidates.length - 1; i > 0; i--) {
426
+ const j = Math.floor(Math.random() * (i + 1));
427
+ [candidates[i], candidates[j]] = [candidates[j], candidates[i]];
428
+ }
429
+ let chosen = null;
430
+ for (const candidate of candidates) {
431
+ try {
432
+ const ok = await checkOpenCodeApi("Hello", candidate.key, "deepseek-v4-flash-free", options == null ? void 0 : options.proxy);
433
+ if (ok) {
434
+ chosen = candidate;
435
+ break;
436
+ }
437
+ } catch {
438
+ }
439
+ }
440
+ if (!chosen) {
441
+ console.error("No working key found among available keys");
442
+ process.exit(1);
443
+ }
444
+ auth.opencode.key = chosen.key;
445
+ await saveOpenCodeAuth(auth);
446
+ console.log(`Rotated OpenCode API key to: ${chosen.name}`);
447
+ }
448
+
449
+ // src/opencode/cli/auth-rotate.runner.ts
450
+ process.env.DEBUG = "true";
451
+ handleAuthRotate({ proxy: "socks5://47.79.79.35:10808" }).catch((err) => {
452
+ console.error("Error during auth rotation:", err);
453
+ process.exit(1);
454
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_rotate_js_1 = require("./auth-rotate.js");
4
+ process.env.DEBUG = 'true';
5
+ (0, auth_rotate_js_1.handleAuthRotate)({ proxy: 'socks5://47.79.79.35:10808' }).catch((err) => {
6
+ console.error('Error during auth rotation:', err);
7
+ process.exit(1);
8
+ });
@@ -0,0 +1,21 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ handleAuthRotate
4
+ } from "../../chunk-KCJYREA2.mjs";
5
+ import "../../chunk-BPED62FN.mjs";
6
+ import "../../chunk-B77D3SR4.mjs";
7
+ import "../../chunk-XW5NZAKI.mjs";
8
+ import "../../chunk-V6PTSDW5.mjs";
9
+ import "../../chunk-3T6AMFI3.mjs";
10
+ import "../../chunk-J4M5EL5P.mjs";
11
+ import {
12
+ init_esm_shims
13
+ } from "../../chunk-QQ4A6DLD.mjs";
14
+
15
+ // src/opencode/cli/auth-rotate.runner.ts
16
+ init_esm_shims();
17
+ process.env.DEBUG = "true";
18
+ handleAuthRotate({ proxy: "socks5://47.79.79.35:10808" }).catch((err) => {
19
+ console.error("Error during auth rotation:", err);
20
+ process.exit(1);
21
+ });
@@ -0,0 +1,82 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/opencode/install-opencode-plugins-cli.ts
25
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
26
+ var import_upath = __toESM(require("upath"), 1);
27
+ var import_cross_spawn = __toESM(require("cross-spawn"), 1);
28
+ var gitCloneDest = ".opencode/plugins/opencode-request-logger";
29
+ var commands = [
30
+ {
31
+ cmd: "git",
32
+ args: ["clone", "https://github.com/Opencode-DCP/opencode-request-logger.git", gitCloneDest],
33
+ skipIfExists: gitCloneDest
34
+ },
35
+ {
36
+ // Run after clone (or if folder already exists) to register the local plugin
37
+ cmd: "opencode",
38
+ args: ["plugin", ".opencode/plugins/opencode-request-logger"]
39
+ },
40
+ {
41
+ cmd: "opencode",
42
+ args: [
43
+ "plugin",
44
+ "opencode-agent-memory@https://github.com/dimaslanjaka/opencode-file-memory/raw/refs/heads/main/release/opencode-agent-memory.tgz"
45
+ ]
46
+ },
47
+ { cmd: "opencode", args: ["plugin", "@tarquinen/opencode-smart-title@latest"] },
48
+ { cmd: "opencode", args: ["plugin", "oh-my-opencode-slim@latest"] },
49
+ { cmd: "opencode", args: ["plugin", "@tarquinen/opencode-dcp@latest"] },
50
+ { cmd: "opencode", args: ["plugin", "envsitter-guard@latest"] }
51
+ ];
52
+ async function runCommand({ cmd, args, skipIfExists }) {
53
+ if (skipIfExists) {
54
+ const folderPath = import_upath.default.resolve(skipIfExists);
55
+ if (await import_fs_extra.default.pathExists(folderPath)) {
56
+ console.log(`
57
+ Skipping: ${cmd} ${args.join(" ")} (folder exists: ${folderPath})`);
58
+ return;
59
+ }
60
+ }
61
+ console.log(`
62
+ Running: ${cmd} ${args.join(" ")}`);
63
+ await new Promise((resolve, reject) => {
64
+ const child = (0, import_cross_spawn.default)(cmd, args, { stdio: "inherit", shell: true });
65
+ child.on("close", (code) => {
66
+ if (code === 0) resolve();
67
+ else reject(new Error(`${cmd} exited with code ${code}`));
68
+ });
69
+ });
70
+ }
71
+ async function main() {
72
+ try {
73
+ for (const command of commands) {
74
+ await runCommand(command);
75
+ }
76
+ console.log("\nAll commands executed successfully!");
77
+ } catch (err) {
78
+ console.error("\nError executing commands:", err);
79
+ process.exit(1);
80
+ }
81
+ }
82
+ main();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs_extra_1 = __importDefault(require("fs-extra"));
16
+ const upath_1 = __importDefault(require("upath"));
17
+ const cross_spawn_1 = __importDefault(require("cross-spawn"));
18
+ // Paths relative to current working directory
19
+ const gitCloneDest = '.opencode/plugins/opencode-request-logger';
20
+ const commands = [
21
+ {
22
+ cmd: 'git',
23
+ args: ['clone', 'https://github.com/Opencode-DCP/opencode-request-logger.git', gitCloneDest],
24
+ skipIfExists: gitCloneDest
25
+ },
26
+ {
27
+ // Run after clone (or if folder already exists) to register the local plugin
28
+ cmd: 'opencode',
29
+ args: ['plugin', '.opencode/plugins/opencode-request-logger']
30
+ },
31
+ {
32
+ cmd: 'opencode',
33
+ args: [
34
+ 'plugin',
35
+ 'opencode-agent-memory@https://github.com/dimaslanjaka/opencode-file-memory/raw/refs/heads/main/release/opencode-agent-memory.tgz'
36
+ ]
37
+ },
38
+ { cmd: 'opencode', args: ['plugin', '@tarquinen/opencode-smart-title@latest'] },
39
+ { cmd: 'opencode', args: ['plugin', 'oh-my-opencode-slim@latest'] },
40
+ { cmd: 'opencode', args: ['plugin', '@tarquinen/opencode-dcp@latest'] },
41
+ { cmd: 'opencode', args: ['plugin', 'envsitter-guard@latest'] }
42
+ ];
43
+ function runCommand(_a) {
44
+ return __awaiter(this, arguments, void 0, function* ({ cmd, args, skipIfExists }) {
45
+ if (skipIfExists) {
46
+ const folderPath = upath_1.default.resolve(skipIfExists);
47
+ if (yield fs_extra_1.default.pathExists(folderPath)) {
48
+ console.log(`\nSkipping: ${cmd} ${args.join(' ')} (folder exists: ${folderPath})`);
49
+ return;
50
+ }
51
+ }
52
+ console.log(`\nRunning: ${cmd} ${args.join(' ')}`);
53
+ yield new Promise((resolve, reject) => {
54
+ const child = (0, cross_spawn_1.default)(cmd, args, { stdio: 'inherit', shell: true });
55
+ child.on('close', (code) => {
56
+ if (code === 0)
57
+ resolve();
58
+ else
59
+ reject(new Error(`${cmd} exited with code ${code}`));
60
+ });
61
+ });
62
+ });
63
+ }
64
+ function main() {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ try {
67
+ for (const command of commands) {
68
+ yield runCommand(command);
69
+ }
70
+ console.log('\nAll commands executed successfully!');
71
+ }
72
+ catch (err) {
73
+ console.error('\nError executing commands:', err);
74
+ process.exit(1);
75
+ }
76
+ });
77
+ }
78
+ main();