binary-collections 2.0.13 → 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.
- package/.opencode/plugins/opencode-request-logger/README.md +44 -0
- package/.venv/Lib/site-packages/pyarrow/tests/data/orc/README.md +22 -0
- package/binaries/binary-executor.cjs +307 -238
- package/binaries/clean-nodemodule.cjs +307 -238
- package/binaries/clean-nodemodules.cjs +307 -238
- package/binaries/composer.cjs +323 -0
- package/binaries/composer.cmd +2 -0
- package/binaries/composer.phar +0 -0
- package/binaries/dev.cjs +307 -238
- package/binaries/empty.cjs +307 -238
- package/binaries/git-reduce-size.cjs +307 -238
- package/binaries/javakill.cjs +307 -238
- package/binaries/kill-process.cjs +307 -238
- package/binaries/nodekill.cjs +307 -238
- package/binaries/prod.cjs +307 -238
- package/binaries/py.cjs +307 -238
- package/binaries/rmfind.cjs +307 -238
- package/binaries/rmx.cjs +307 -238
- package/binaries/submodule-token.cjs +307 -238
- package/binaries/test-cjs.cjs +307 -238
- package/binaries/test-esm.cjs +307 -238
- package/binaries/yarn-clean.cjs +307 -238
- package/binaries/yc.cjs +307 -238
- package/binaries/ycw.cjs +307 -238
- package/docs-src/binary-collections.md +1 -1
- package/docs-src/clean-github-actions-caches.md +1 -1
- package/docs-src/copy-move-file.md +1 -4
- package/docs-src/del-ps.md +1 -1
- package/docs-src/find-node-modules.md +1 -1
- package/docs-src/generate-test-ci.md +56 -0
- package/docs-src/get-latest-workflow-status.md +100 -0
- package/docs-src/git-diff.md +1 -1
- package/docs-src/git-fix.md +1 -1
- package/docs-src/git-purge.md +1 -1
- package/docs-src/install-opencode-plugins.md +86 -0
- package/docs-src/kill-night-crows.md +1 -1
- package/docs-src/node-cache-cleaner.md +2 -2
- package/docs-src/node-package-packer.md +1 -1
- package/docs-src/opencode-cli.md +155 -0
- package/docs-src/package-resolutions-updater.md +1 -1
- package/docs-src/rmpath.md +1 -1
- package/docs-src/run-by-checksum.md +1 -1
- package/docs-src/submodule-remove.md +1 -1
- package/docs-src/upload-backend.md +29 -0
- package/docs-src/vscode-cli.md +84 -0
- package/docs-src/workflow-badge.md +120 -0
- package/lib/binary-collections/config-types.cjs +17 -0
- package/lib/binary-collections/config-types.d.ts +12 -0
- package/lib/binary-collections/config-types.js +2 -0
- package/lib/binary-collections/config-types.mjs +7 -0
- package/lib/binary-collections/config.cjs +28 -8
- package/lib/binary-collections/config.d.cts +26 -8
- package/lib/binary-collections/config.mjs +2 -2
- package/lib/binary-collections/findScript.cjs +49 -25
- package/lib/binary-collections/findScript.mjs +2 -2
- package/lib/binary-collections/listScript.cjs +49 -25
- package/lib/binary-collections/listScript.mjs +2 -2
- package/lib/binary-collections.cjs +49 -25
- package/lib/binary-collections.mjs +6 -6
- package/lib/changelog.cjs +142 -4
- package/lib/changelog.mjs +9 -5
- package/lib/chunk-3T6AMFI3.mjs +52 -0
- package/lib/{chunk-2MN4VPV2.mjs → chunk-3ZF2QMDK.mjs} +4 -4
- package/lib/chunk-56BVU63B.mjs +86 -0
- package/lib/chunk-7N52Z4IJ.mjs +39 -0
- package/lib/chunk-B77D3SR4.mjs +28 -0
- package/lib/chunk-BPED62FN.mjs +115 -0
- package/lib/{chunk-RDN6HF5Z.mjs → chunk-DHFRWM2W.mjs} +1 -1
- package/lib/chunk-DPEE3FBB.mjs +146 -0
- package/lib/{chunk-MGPYPKIE.mjs → chunk-H7AE4IO3.mjs} +5 -1
- package/lib/{chunk-H44UWUFY.mjs → chunk-J4M5EL5P.mjs} +3 -0
- package/lib/chunk-KCJYREA2.mjs +67 -0
- package/lib/chunk-LACQTD5V.mjs +225 -0
- package/lib/{chunk-TBWXE7ST.mjs → chunk-NHD4HLSU.mjs} +24 -31
- package/lib/{chunk-RDGDLSPD.mjs → chunk-OWNVMKAA.mjs} +6 -5
- package/lib/chunk-SKVF4TMD.mjs +59 -0
- package/lib/{chunk-BZWVHODJ.mjs → chunk-TDUUOAQD.mjs} +5 -5
- package/lib/chunk-TP3O2JGW.mjs +88 -0
- package/lib/{chunk-FLYSZFLW.mjs → chunk-UAEKSLAX.mjs} +1 -1
- package/lib/chunk-UDZBVKXH.mjs +94 -0
- package/lib/chunk-UEOWRYAN.mjs +32 -0
- package/lib/chunk-V6PTSDW5.mjs +82 -0
- package/lib/{chunk-NQXUYO67.mjs → chunk-WNUEY6VJ.mjs} +49 -25
- package/lib/chunk-X7UVQ6ZC.mjs +183 -0
- package/lib/chunk-XW5NZAKI.mjs +82 -0
- package/lib/{chunk-LVSPEFU2.mjs → chunk-Z53IUBUN.mjs} +6 -5
- package/lib/{chunk-CD3HF3LK.mjs → chunk-Z7RM46Q4.mjs} +5 -11
- package/lib/chunk-ZB4IQ6VJ.mjs +46 -0
- package/lib/del-gradle.cjs +1 -1
- package/lib/del-gradle.mjs +22 -16
- package/lib/del-node-modules.cjs +1 -1
- package/lib/del-node-modules.mjs +148 -142
- package/lib/find-node-modules-cli.cjs +1 -1
- package/lib/find-node-modules-cli.mjs +10 -4
- package/lib/{git-diff-cli.cjs → git/git-diff-cli.cjs} +32 -12
- package/lib/{git-diff-cli.mjs → git/git-diff-cli.mjs} +7 -7
- package/lib/{git-diff.cjs → git/git-diff.cjs} +30 -10
- package/lib/{git-diff.js → git/git-diff.js} +3 -3
- package/lib/{git-diff.mjs → git/git-diff.mjs} +6 -6
- package/lib/{git-fix.cjs → git/git-fix.cjs} +142 -3
- package/lib/{git-fix.mjs → git/git-fix.mjs} +19 -14
- package/lib/{git-purge.cjs → git/git-purge.cjs} +1 -1
- package/lib/{git-purge.mjs → git/git-purge.mjs} +4 -4
- package/lib/git/user-config.cjs +139 -1
- package/lib/git/user-config.mjs +3 -1
- package/lib/{clean-github-actions-caches-cli.cjs → github-workflows/clean-github-actions-caches-cli.cjs} +46 -10
- package/lib/{clean-github-actions-caches-cli.mjs → github-workflows/clean-github-actions-caches-cli.mjs} +7 -6
- package/lib/{clean-github-actions-caches.cjs → github-workflows/clean-github-actions-caches.cjs} +46 -10
- package/lib/{clean-github-actions-caches.mjs → github-workflows/clean-github-actions-caches.mjs} +5 -4
- package/lib/github-workflows/generate-test-ci-step-cli.cjs +240 -0
- package/lib/github-workflows/generate-test-ci-step-cli.d.mts +2 -0
- package/lib/github-workflows/generate-test-ci-step-cli.mjs +132 -0
- package/lib/github-workflows/get-latest-workflow-status-cli.cjs +549 -0
- package/lib/github-workflows/get-latest-workflow-status-cli.d.mts +2 -0
- package/lib/github-workflows/get-latest-workflow-status-cli.mjs +61 -0
- package/lib/github-workflows/get-latest-workflow-status.cjs +56 -0
- package/lib/github-workflows/get-latest-workflow-status.d.mts +1 -0
- package/lib/github-workflows/get-latest-workflow-status.mjs +8 -0
- package/lib/github-workflows/utils.cjs +279 -0
- package/lib/github-workflows/utils.d.cts +76 -0
- package/lib/github-workflows/utils.mjs +8 -0
- package/lib/github-workflows/workflow-badge-cli.cjs +730 -0
- package/lib/github-workflows/workflow-badge-cli.d.mts +2 -0
- package/lib/github-workflows/workflow-badge-cli.mjs +98 -0
- package/lib/github-workflows/workflow-badge-generator.cjs +200 -0
- package/lib/github-workflows/workflow-badge-generator.d.mts +14 -0
- package/lib/github-workflows/workflow-badge-generator.mjs +8 -0
- package/lib/github-workflows/workflow-test-data.cjs +73 -0
- package/lib/github-workflows/workflow-test-data.d.cts +63 -0
- package/lib/github-workflows/workflow-test-data.mjs +6 -0
- package/lib/node-cache-cleaner-cli.mjs +3 -3
- package/lib/opencode/cli/auth-rotate.cjs +458 -0
- package/lib/opencode/cli/auth-rotate.d.ts +3 -0
- package/lib/opencode/cli/auth-rotate.js +65 -0
- package/lib/opencode/cli/auth-rotate.mjs +14 -0
- package/lib/opencode/cli/auth-rotate.runner.cjs +454 -0
- package/lib/opencode/cli/auth-rotate.runner.d.ts +1 -0
- package/lib/opencode/cli/auth-rotate.runner.js +8 -0
- package/lib/opencode/cli/auth-rotate.runner.mjs +21 -0
- package/lib/opencode/cli/list-projects.cjs +184 -0
- package/lib/opencode/cli/list-projects.d.ts +1 -0
- package/lib/opencode/cli/list-projects.js +32 -0
- package/lib/opencode/cli/list-projects.mjs +11 -0
- package/lib/opencode/cli/list-sessions.cjs +215 -0
- package/lib/opencode/cli/list-sessions.d.ts +1 -0
- package/lib/opencode/cli/list-sessions.js +45 -0
- package/lib/opencode/cli/list-sessions.mjs +11 -0
- package/lib/opencode/database.cjs +349 -0
- package/lib/opencode/database.d.ts +91 -0
- package/lib/opencode/database.js +252 -0
- package/lib/opencode/database.mjs +28 -0
- package/lib/opencode/database.runner.cjs +145 -0
- package/lib/opencode/database.runner.d.ts +1 -0
- package/lib/opencode/database.runner.js +56 -0
- package/lib/opencode/database.runner.mjs +37 -0
- package/lib/opencode/install-opencode-plugins-cli.cjs +82 -0
- package/lib/opencode/install-opencode-plugins-cli.d.ts +1 -0
- package/lib/opencode/install-opencode-plugins-cli.js +78 -0
- package/lib/opencode/install-opencode-plugins-cli.mjs +65 -0
- package/lib/opencode/opencode-zen.runner.cjs +48 -0
- package/lib/opencode/opencode-zen.runner.d.mts +1 -0
- package/lib/opencode/opencode-zen.runner.mjs +31 -0
- package/lib/opencode/sqlite.cjs +114 -0
- package/lib/opencode/sqlite.d.ts +18 -0
- package/lib/opencode/sqlite.js +82 -0
- package/lib/opencode/sqlite.mjs +10 -0
- package/lib/opencode/storage.cjs +124 -0
- package/lib/opencode/storage.d.ts +27 -0
- package/lib/opencode/storage.js +101 -0
- package/lib/opencode/storage.mjs +38 -0
- package/lib/opencode/storage.runner.cjs +50 -0
- package/lib/opencode/storage.runner.d.ts +1 -0
- package/lib/opencode/storage.runner.js +13 -0
- package/lib/opencode/storage.runner.mjs +29 -0
- package/lib/opencode/types.cjs +17 -0
- package/lib/opencode/types.d.ts +31 -0
- package/lib/opencode/types.js +2 -0
- package/lib/opencode/types.mjs +7 -0
- package/lib/opencode/utils/check-api.cjs +373 -0
- package/lib/opencode/utils/check-api.d.ts +16 -0
- package/lib/opencode/utils/check-api.js +132 -0
- package/lib/opencode/utils/check-api.mjs +12 -0
- package/lib/opencode/utils/check-api.runner.cjs +0 -0
- package/lib/opencode/utils/check-api.runner.d.ts +0 -0
- package/lib/opencode/utils/check-api.runner.js +1 -0
- package/lib/opencode/utils/check-api.runner.mjs +7 -0
- package/lib/opencode-cli.cjs +796 -0
- package/lib/opencode-cli.d.ts +2 -0
- package/lib/opencode-cli.js +116 -0
- package/lib/opencode-cli.mjs +116 -0
- package/lib/package-resolutions-updater-cli.cjs +189 -154
- package/lib/package-resolutions-updater-cli.mjs +3 -2
- package/lib/package-resolutions-updater.cjs +189 -154
- package/lib/package-resolutions-updater.d.mts +12 -3
- package/lib/package-resolutions-updater.mjs +3 -2
- package/lib/print-directory-tree.cjs +139 -3
- package/lib/print-directory-tree.mjs +6 -3
- package/lib/print-tarball-tree-cli.cjs +305 -0
- package/lib/print-tarball-tree-cli.d.mts +2 -0
- package/lib/print-tarball-tree-cli.mjs +54 -0
- package/lib/print-tarball-tree.cjs +43 -216
- package/lib/print-tarball-tree.d.mts +4 -1
- package/lib/print-tarball-tree.mjs +12 -66
- package/lib/rmpath-cli.cjs +139 -5
- package/lib/rmpath-cli.mjs +3 -1
- package/lib/rmpath.cjs +155 -11
- package/lib/rmpath.mjs +3 -1
- package/lib/run-by-checksum/hash.cjs +50 -56
- package/lib/run-by-checksum/hash.d.cts +24 -0
- package/lib/run-by-checksum/hash.mjs +3 -7
- package/lib/run-by-checksum/run.cjs +95 -42
- package/lib/run-by-checksum/run.js +3 -3
- package/lib/run-by-checksum/run.mjs +2 -2
- package/lib/run-by-checksum-cli.cjs +96 -58
- package/lib/run-by-checksum-cli.mjs +2 -2
- package/lib/submodule-install.cjs +138 -4
- package/lib/submodule-install.mjs +5 -4
- package/lib/submodule-remove-cli.cjs +139 -5
- package/lib/submodule-remove-cli.mjs +3 -1
- package/lib/submodule-remove.cjs +154 -5
- package/lib/submodule-remove.mjs +3 -1
- package/lib/utils/findEnvFiles.cjs +3 -0
- package/lib/utils/findEnvFiles.d.cts +2 -2
- package/lib/utils/findEnvFiles.mjs +1 -1
- package/lib/utils/isDebug.cjs +13 -0
- package/lib/utils/isDebug.d.cts +9 -0
- package/lib/utils/isDebug.mjs +6 -0
- package/lib/vscode/project.cjs +0 -0
- package/lib/vscode/project.d.ts +0 -0
- package/lib/vscode/project.js +1 -0
- package/lib/vscode/project.mjs +7 -0
- package/lib/vscode/storage.cjs +138 -0
- package/lib/vscode/storage.d.ts +51 -0
- package/lib/vscode/storage.js +169 -0
- package/lib/vscode/storage.mjs +42 -0
- package/lib/vscode/storage.runner.cjs +125 -0
- package/lib/vscode/storage.runner.d.ts +1 -0
- package/lib/vscode/storage.runner.js +47 -0
- package/lib/vscode/storage.runner.mjs +60 -0
- package/lib/vscode-cli.cjs +155 -0
- package/lib/vscode-cli.d.ts +2 -0
- package/lib/vscode-cli.js +80 -0
- package/lib/vscode-cli.mjs +71 -0
- package/package.json +50 -26
- package/readme.md +104 -8
- package/releases/readme.md +1 -1
- package/src/github-workflows/generate-test-ci-step-cli.mjs +126 -0
- package/vendor/clue/ndjson-react/README.md +365 -0
- package/vendor/composer/pcre/README.md +189 -0
- package/vendor/composer/semver/README.md +99 -0
- package/vendor/composer/xdebug-handler/README.md +305 -0
- package/vendor/ergebnis/agent-detector/README.md +107 -0
- package/vendor/evenement/evenement/README.md +64 -0
- package/vendor/fidry/cpu-core-counter/README.md +138 -0
- package/vendor/friendsofphp/php-cs-fixer/README.md +97 -0
- package/vendor/psr/container/README.md +13 -0
- package/vendor/psr/event-dispatcher/README.md +6 -0
- package/vendor/psr/log/README.md +58 -0
- package/vendor/react/cache/README.md +367 -0
- package/vendor/react/child-process/README.md +619 -0
- package/vendor/react/dns/README.md +453 -0
- package/vendor/react/event-loop/README.md +930 -0
- package/vendor/react/promise/README.md +722 -0
- package/vendor/react/socket/README.md +1564 -0
- package/vendor/react/stream/README.md +1249 -0
- package/vendor/sebastian/diff/README.md +151 -0
- package/vendor/symfony/console/README.md +30 -0
- package/vendor/symfony/deprecation-contracts/README.md +26 -0
- package/vendor/symfony/event-dispatcher/README.md +25 -0
- package/vendor/symfony/event-dispatcher-contracts/README.md +9 -0
- package/vendor/symfony/filesystem/README.md +23 -0
- package/vendor/symfony/finder/README.md +24 -0
- package/vendor/symfony/options-resolver/README.md +25 -0
- package/vendor/symfony/polyfill-ctype/README.md +12 -0
- package/vendor/symfony/polyfill-intl-grapheme/README.md +32 -0
- package/vendor/symfony/polyfill-intl-normalizer/README.md +14 -0
- package/vendor/symfony/polyfill-mbstring/README.md +13 -0
- package/vendor/symfony/polyfill-php80/README.md +25 -0
- package/vendor/symfony/polyfill-php81/README.md +18 -0
- package/vendor/symfony/polyfill-php84/README.md +23 -0
- package/vendor/symfony/polyfill-php85/README.md +20 -0
- package/vendor/symfony/process/README.md +23 -0
- package/vendor/symfony/service-contracts/README.md +9 -0
- package/vendor/symfony/stopwatch/README.md +52 -0
- package/vendor/symfony/string/README.md +24 -0
- package/lib/chunk-WSHVPGNM.mjs +0 -44
- package/lib/chunk-X2B3X7D4.mjs +0 -35
- package/lib/del-gradle.js +0 -16
- package/lib/del-node-modules.js +0 -211
- package/lib/find-node-modules-cli.js +0 -4
- package/lib/run-by-checksum/hash.d.ts +0 -14
- package/lib/run-by-checksum/hash.js +0 -85
- package/readme.html +0 -784
- /package/lib/{clean-github-actions-caches-cli.d.cts → del-gradle.d.cts} +0 -0
- /package/lib/{del-gradle.d.ts → del-node-modules.d.cts} +0 -0
- /package/lib/{find-node-modules-cli.d.ts → find-node-modules-cli.d.cts} +0 -0
- /package/lib/{git-diff-cli.d.ts → git/git-diff-cli.d.ts} +0 -0
- /package/lib/{git-diff-cli.js → git/git-diff-cli.js} +0 -0
- /package/lib/{git-diff.d.ts → git/git-diff.d.ts} +0 -0
- /package/lib/{git-fix.d.cts → git/git-fix.d.cts} +0 -0
- /package/lib/{git-purge.d.cts → git/git-purge.d.cts} +0 -0
- /package/lib/{del-node-modules.d.ts → github-workflows/clean-github-actions-caches-cli.d.cts} +0 -0
- /package/lib/{clean-github-actions-caches.d.cts → github-workflows/clean-github-actions-caches.d.cts} +0 -0
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
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
|
+
|
|
265
|
+
// src/opencode-cli.ts
|
|
266
|
+
init_cjs_shims();
|
|
267
|
+
var import_minimist = __toESM(require("minimist"), 1);
|
|
268
|
+
|
|
269
|
+
// src/opencode/database.ts
|
|
270
|
+
init_cjs_shims();
|
|
271
|
+
|
|
272
|
+
// src/opencode/storage.ts
|
|
273
|
+
init_cjs_shims();
|
|
274
|
+
var import_upath = __toESM(require("upath"), 1);
|
|
275
|
+
var import_os = __toESM(require("os"), 1);
|
|
276
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
277
|
+
var import_jsonc_parser = require("jsonc-parser");
|
|
278
|
+
var OPCODE_DIR = import_upath.default.join(import_os.default.homedir(), ".local/share/opencode");
|
|
279
|
+
var CONFIG_DIR = import_upath.default.join(import_os.default.homedir(), ".config/opencode");
|
|
280
|
+
var CACHE_DIR = import_upath.default.join(import_os.default.homedir(), ".cache/opencode");
|
|
281
|
+
var LOG_DIR = import_upath.default.join(OPCODE_DIR, "log");
|
|
282
|
+
var AUTH_PATH = import_upath.default.join(OPCODE_DIR, "auth.json");
|
|
283
|
+
var PROJECT_DIR = import_upath.default.join(OPCODE_DIR, "project");
|
|
284
|
+
var STORAGE_PATH = import_upath.default.join(OPCODE_DIR, "storage");
|
|
285
|
+
var SESSION_PATH = import_upath.default.join(STORAGE_PATH, "session");
|
|
286
|
+
var SESSION_DIFF_DIR = import_upath.default.join(STORAGE_PATH, "session_diff");
|
|
287
|
+
var DATABASE_PATH = import_upath.default.join(OPCODE_DIR, "opencode.db");
|
|
288
|
+
async function readJson(filePath) {
|
|
289
|
+
try {
|
|
290
|
+
const content = await import_fs_extra.default.readFile(filePath, "utf-8");
|
|
291
|
+
return (0, import_jsonc_parser.parse)(content);
|
|
292
|
+
} catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function getOpenCodeAuth() {
|
|
297
|
+
const file = import_upath.default.join(OPCODE_DIR, "auth.json");
|
|
298
|
+
if (!import_fs_extra.default.existsSync(file)) return null;
|
|
299
|
+
return readJson(file);
|
|
300
|
+
}
|
|
301
|
+
async function saveOpenCodeAuth(auth) {
|
|
302
|
+
const file = import_upath.default.join(OPCODE_DIR, "auth.json");
|
|
303
|
+
await import_fs_extra.default.ensureFile(file);
|
|
304
|
+
await import_fs_extra.default.writeFile(file, JSON.stringify(auth, null, 2), "utf-8");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/opencode/sqlite.ts
|
|
308
|
+
init_cjs_shims();
|
|
309
|
+
var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
|
|
310
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
311
|
+
var import_upath2 = __toESM(require("upath"), 1);
|
|
312
|
+
var DEFAULT_DB_PATH = import_upath2.default.join(process.cwd(), "data", "database", "db.sqlite");
|
|
313
|
+
var SQLite = class {
|
|
314
|
+
constructor(dbPath = DEFAULT_DB_PATH) {
|
|
315
|
+
const dir = import_upath2.default.dirname(dbPath);
|
|
316
|
+
if (!import_fs_extra2.default.existsSync(dir)) {
|
|
317
|
+
import_fs_extra2.default.mkdirSync(dir, { recursive: true });
|
|
318
|
+
}
|
|
319
|
+
this.db = new import_better_sqlite3.default(dbPath);
|
|
320
|
+
this.db.pragma("journal_mode = WAL");
|
|
321
|
+
this.db.pragma("synchronous = NORMAL");
|
|
322
|
+
this.db.pragma("temp_store = MEMORY");
|
|
323
|
+
this.db.pragma("foreign_keys = ON");
|
|
324
|
+
}
|
|
325
|
+
// -------------------------
|
|
326
|
+
// Migration / schema init
|
|
327
|
+
// -------------------------
|
|
328
|
+
migrate(schemaFilePath) {
|
|
329
|
+
const schema = import_fs_extra2.default.readFileSync(schemaFilePath, "utf-8");
|
|
330
|
+
this.db.exec(schema);
|
|
331
|
+
}
|
|
332
|
+
// -------------------------
|
|
333
|
+
// Core query helpers
|
|
334
|
+
// -------------------------
|
|
335
|
+
prepare(sql) {
|
|
336
|
+
return this.db.prepare(sql);
|
|
337
|
+
}
|
|
338
|
+
get(sql, params = {}) {
|
|
339
|
+
return this.db.prepare(sql).get(params);
|
|
340
|
+
}
|
|
341
|
+
all(sql, params = {}) {
|
|
342
|
+
return this.db.prepare(sql).all(params);
|
|
343
|
+
}
|
|
344
|
+
run(sql, params = {}) {
|
|
345
|
+
return this.db.prepare(sql).run(params);
|
|
346
|
+
}
|
|
347
|
+
// -------------------------
|
|
348
|
+
// Transactions
|
|
349
|
+
// -------------------------
|
|
350
|
+
transaction(fn) {
|
|
351
|
+
const trx = this.db.transaction(fn);
|
|
352
|
+
return trx();
|
|
353
|
+
}
|
|
354
|
+
// -------------------------
|
|
355
|
+
// Upsert helper (very useful for build cache)
|
|
356
|
+
// -------------------------
|
|
357
|
+
upsert(sql, params = {}) {
|
|
358
|
+
return this.db.prepare(sql).run(params);
|
|
359
|
+
}
|
|
360
|
+
// -------------------------
|
|
361
|
+
// Bulk insert helper
|
|
362
|
+
// -------------------------
|
|
363
|
+
insertMany(sql, rows) {
|
|
364
|
+
const stmt = this.db.prepare(sql);
|
|
365
|
+
const trx = this.db.transaction((rows2) => {
|
|
366
|
+
for (const row of rows2) {
|
|
367
|
+
stmt.run(row);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
trx(rows);
|
|
371
|
+
}
|
|
372
|
+
// -------------------------
|
|
373
|
+
// Utility
|
|
374
|
+
// -------------------------
|
|
375
|
+
close() {
|
|
376
|
+
this.db.close();
|
|
377
|
+
}
|
|
378
|
+
// Raw access if needed (escape hatch)
|
|
379
|
+
raw() {
|
|
380
|
+
return this.db;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// src/opencode/database.ts
|
|
385
|
+
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
386
|
+
var import_node_child_process = require("child_process");
|
|
387
|
+
async function checkDatabase() {
|
|
388
|
+
if (!import_fs_extra3.default.existsSync(DATABASE_PATH)) {
|
|
389
|
+
console.error("No OpenCode database found. Run opencode (v1.2.0+) at least once to create the database.");
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const db = new SQLite(DATABASE_PATH);
|
|
394
|
+
try {
|
|
395
|
+
const rows = db.all("SELECT name FROM sqlite_master WHERE type='table' AND name='session'");
|
|
396
|
+
if (rows.length === 0) {
|
|
397
|
+
console.error(
|
|
398
|
+
"OpenCode database exists but is missing expected tables. Try running opencode to complete the migration."
|
|
399
|
+
);
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
return true;
|
|
403
|
+
} finally {
|
|
404
|
+
db.close();
|
|
405
|
+
}
|
|
406
|
+
} catch (error) {
|
|
407
|
+
if (error instanceof Error) {
|
|
408
|
+
console.error(`Could not open OpenCode database: ${error.message}`);
|
|
409
|
+
} else {
|
|
410
|
+
console.error("Could not open OpenCode database.");
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function toProject(row) {
|
|
416
|
+
let sandboxes = [];
|
|
417
|
+
try {
|
|
418
|
+
sandboxes = JSON.parse(row.sandboxes);
|
|
419
|
+
} catch {
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
id: row.id,
|
|
423
|
+
worktree: row.worktree,
|
|
424
|
+
vcs: row.vcs,
|
|
425
|
+
name: row.name,
|
|
426
|
+
sandboxes,
|
|
427
|
+
time: {
|
|
428
|
+
created: row.time_created,
|
|
429
|
+
updated: row.time_updated
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function toSession(row) {
|
|
434
|
+
const session = {
|
|
435
|
+
id: row.id,
|
|
436
|
+
slug: row.slug,
|
|
437
|
+
version: row.version,
|
|
438
|
+
projectID: row.project_id,
|
|
439
|
+
directory: row.directory,
|
|
440
|
+
parentID: row.parent_id ?? void 0,
|
|
441
|
+
title: row.title,
|
|
442
|
+
time: {
|
|
443
|
+
created: row.time_created,
|
|
444
|
+
updated: row.time_updated,
|
|
445
|
+
compacting: row.time_compacting ?? void 0,
|
|
446
|
+
archived: row.time_archived ?? void 0
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
if (row.summary_files != null) {
|
|
450
|
+
session.summary = {
|
|
451
|
+
additions: row.summary_additions ?? 0,
|
|
452
|
+
deletions: row.summary_deletions ?? 0,
|
|
453
|
+
files: row.summary_files
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
if (row.share_url) {
|
|
457
|
+
session.share = { url: row.share_url };
|
|
458
|
+
}
|
|
459
|
+
return session;
|
|
460
|
+
}
|
|
461
|
+
async function loadProjects() {
|
|
462
|
+
const rows = query("SELECT id, worktree, vcs, name, time_created, time_updated, sandboxes FROM project");
|
|
463
|
+
return rows.map(toProject);
|
|
464
|
+
}
|
|
465
|
+
async function loadSessions() {
|
|
466
|
+
const rows = query(
|
|
467
|
+
`SELECT id, project_id, parent_id, slug, directory, title, version,
|
|
468
|
+
share_url, summary_additions, summary_deletions, summary_files,
|
|
469
|
+
time_created, time_updated, time_compacting, time_archived
|
|
470
|
+
FROM session
|
|
471
|
+
WHERE parent_id IS NULL
|
|
472
|
+
ORDER BY time_updated DESC`
|
|
473
|
+
);
|
|
474
|
+
return rows.map(toSession);
|
|
475
|
+
}
|
|
476
|
+
function runSql(query2) {
|
|
477
|
+
const dbPath = DATABASE_PATH;
|
|
478
|
+
(0, import_node_child_process.execSync)(`sqlite3 "${dbPath}"`, {
|
|
479
|
+
input: query2,
|
|
480
|
+
timeout: 1e4
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
async function deleteSessionById(id) {
|
|
484
|
+
const sid = escapeSql(id);
|
|
485
|
+
runSql(
|
|
486
|
+
`WITH RECURSIVE descendants(id) AS (SELECT id FROM session WHERE id = '${sid}' UNION ALL SELECT s.id FROM session s JOIN descendants d ON s.parent_id = d.id) DELETE FROM session WHERE id IN (SELECT id FROM descendants);`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
async function deleteAllSessions() {
|
|
490
|
+
runSql(`DELETE FROM part; DELETE FROM message; DELETE FROM session;`);
|
|
491
|
+
}
|
|
492
|
+
async function deleteAllProjectSessions(projectID) {
|
|
493
|
+
const pid = escapeSql(projectID);
|
|
494
|
+
runSql(`DELETE FROM session WHERE project_id = '${pid}'; DELETE FROM project WHERE id = '${pid}';`);
|
|
495
|
+
}
|
|
496
|
+
function query(sql) {
|
|
497
|
+
const db = new SQLite(DATABASE_PATH);
|
|
498
|
+
try {
|
|
499
|
+
return db.all(sql);
|
|
500
|
+
} finally {
|
|
501
|
+
db.close();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function escapeSql(value) {
|
|
505
|
+
return value.replace(/'/g, "''");
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/opencode/cli/auth-rotate.ts
|
|
509
|
+
init_cjs_shims();
|
|
510
|
+
|
|
511
|
+
// src/opencode/utils/check-api.ts
|
|
512
|
+
init_cjs_shims();
|
|
513
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
514
|
+
var import_sbg_utility = require("sbg-utility");
|
|
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 = "***";
|
|
528
|
+
}
|
|
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
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/opencode/cli/auth-rotate.ts
|
|
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;
|
|
614
|
+
if (!keys || !Array.isArray(keys) || keys.length === 0) {
|
|
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
|
+
);
|
|
618
|
+
process.exit(1);
|
|
619
|
+
}
|
|
620
|
+
const auth = await getOpenCodeAuth();
|
|
621
|
+
if (!auth) {
|
|
622
|
+
console.error("No auth file found. Run configure first.");
|
|
623
|
+
process.exit(1);
|
|
624
|
+
}
|
|
625
|
+
const currentKey = auth.opencode.key;
|
|
626
|
+
const candidates = keys.filter((k) => k.key !== currentKey);
|
|
627
|
+
if (candidates.length === 0) {
|
|
628
|
+
console.error("No other keys available to rotate to");
|
|
629
|
+
process.exit(1);
|
|
630
|
+
}
|
|
631
|
+
for (let i = candidates.length - 1; i > 0; i--) {
|
|
632
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
633
|
+
[candidates[i], candidates[j]] = [candidates[j], candidates[i]];
|
|
634
|
+
}
|
|
635
|
+
let chosen = null;
|
|
636
|
+
for (const candidate of candidates) {
|
|
637
|
+
try {
|
|
638
|
+
const ok = await checkOpenCodeApi("Hello", candidate.key, "deepseek-v4-flash-free", options == null ? void 0 : options.proxy);
|
|
639
|
+
if (ok) {
|
|
640
|
+
chosen = candidate;
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
} catch {
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (!chosen) {
|
|
647
|
+
console.error("No working key found among available keys");
|
|
648
|
+
process.exit(1);
|
|
649
|
+
}
|
|
650
|
+
auth.opencode.key = chosen.key;
|
|
651
|
+
await saveOpenCodeAuth(auth);
|
|
652
|
+
console.log(`Rotated OpenCode API key to: ${chosen.name}`);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// src/opencode/cli/list-projects.ts
|
|
656
|
+
init_cjs_shims();
|
|
657
|
+
async function handleListProjects() {
|
|
658
|
+
const projects = await loadProjects();
|
|
659
|
+
console.log(`Projects (${projects.length}):
|
|
660
|
+
`);
|
|
661
|
+
const rows = projects.map((p) => ({
|
|
662
|
+
id: p.id.slice(0, 8),
|
|
663
|
+
name: p.name || "-",
|
|
664
|
+
worktree: p.worktree
|
|
665
|
+
}));
|
|
666
|
+
const idWidth = Math.max(...rows.map((r) => r.id.length), 2);
|
|
667
|
+
const nameWidth = Math.max(...rows.map((r) => r.name.length), 4);
|
|
668
|
+
const sep = "\u2500".repeat(idWidth + nameWidth + 15);
|
|
669
|
+
console.log(` ${"ID".padEnd(idWidth)} ${"Name".padEnd(nameWidth)} Worktree`);
|
|
670
|
+
console.log(` ${sep}`);
|
|
671
|
+
for (const r of rows) {
|
|
672
|
+
console.log(` ${r.id.padEnd(idWidth)} ${r.name.padEnd(nameWidth)} ${r.worktree}`);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// src/opencode/cli/list-sessions.ts
|
|
677
|
+
init_cjs_shims();
|
|
678
|
+
var import_moment = __toESM(require("moment"), 1);
|
|
679
|
+
async function handleListSessions() {
|
|
680
|
+
const sessions = await loadSessions();
|
|
681
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
682
|
+
for (const s of sessions) {
|
|
683
|
+
const dir = s.directory || "(no directory)";
|
|
684
|
+
if (!grouped.has(dir)) grouped.set(dir, []);
|
|
685
|
+
grouped.get(dir).push(s);
|
|
686
|
+
}
|
|
687
|
+
console.log(`Sessions (${sessions.length} total, ${grouped.size} directories):
|
|
688
|
+
`);
|
|
689
|
+
for (const [dir, dirSessions] of grouped) {
|
|
690
|
+
console.log(` ${dir}`);
|
|
691
|
+
const slugWidth = Math.max(...dirSessions.map((s) => s.slug.length), 4);
|
|
692
|
+
const titleWidth = Math.max(...dirSessions.map((s) => (s.title || "-").length), 5);
|
|
693
|
+
const dateWidth = Math.max(
|
|
694
|
+
...dirSessions.map((s) => (0, import_moment.default)(s.time.created).format("YYYY-MM-DDTHH:mm:ssZ").length),
|
|
695
|
+
25
|
|
696
|
+
);
|
|
697
|
+
const sep = "\u2500".repeat(Math.max(dir.length, slugWidth + titleWidth + dateWidth + 15));
|
|
698
|
+
console.log(` ${sep}`);
|
|
699
|
+
console.log(` ${"Slug".padEnd(slugWidth)} ${"Title".padEnd(titleWidth)} ${"Date".padEnd(dateWidth)} Version`);
|
|
700
|
+
const rowSep = "\u2500".repeat(slugWidth + titleWidth + dateWidth + 17);
|
|
701
|
+
console.log(` ${rowSep}`);
|
|
702
|
+
for (const s of dirSessions) {
|
|
703
|
+
console.log(
|
|
704
|
+
` ${s.slug.padEnd(slugWidth)} ${(s.title || "-").padEnd(titleWidth)} ${(0, import_moment.default)(s.time.created).format("YYYY-MM-DDTHH:mm:ssZ").padEnd(dateWidth)} ${s.version}`
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
console.log();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/opencode-cli.ts
|
|
712
|
+
var argv = (0, import_minimist.default)(process.argv.slice(2), {
|
|
713
|
+
alias: { h: "help", p: "proxy" }
|
|
714
|
+
});
|
|
715
|
+
function printHelp() {
|
|
716
|
+
console.log(`
|
|
717
|
+
Usage: opc <command> [options]
|
|
718
|
+
|
|
719
|
+
Commands:
|
|
720
|
+
list session List all sessions grouped by directory
|
|
721
|
+
list project List all projects
|
|
722
|
+
delete session <id> Delete a single session by ID
|
|
723
|
+
delete sessions Delete all sessions (irreversible)
|
|
724
|
+
delete project <id> Delete a project's sessions from the OpenCode database (not the real project folder)
|
|
725
|
+
auth rotate Rotate OpenCode API key from .opencode.keys.json(c)
|
|
726
|
+
|
|
727
|
+
Options:
|
|
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)
|
|
730
|
+
`);
|
|
731
|
+
}
|
|
732
|
+
async function main() {
|
|
733
|
+
if (argv.help || argv._.length === 0) {
|
|
734
|
+
printHelp();
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const command = argv._[0];
|
|
738
|
+
if (!await checkDatabase()) {
|
|
739
|
+
process.exit(1);
|
|
740
|
+
}
|
|
741
|
+
if (command === "list") {
|
|
742
|
+
const sub = argv._[1];
|
|
743
|
+
if (sub === "session") {
|
|
744
|
+
await handleListSessions();
|
|
745
|
+
} else if (sub === "project") {
|
|
746
|
+
await handleListProjects();
|
|
747
|
+
} else {
|
|
748
|
+
console.error(`Unknown subcommand: list ${sub || ""}`);
|
|
749
|
+
printHelp();
|
|
750
|
+
process.exit(1);
|
|
751
|
+
}
|
|
752
|
+
} else if (command === "delete") {
|
|
753
|
+
const sub = argv._[1];
|
|
754
|
+
if (sub === "session") {
|
|
755
|
+
const sessionId = argv._[2];
|
|
756
|
+
if (!sessionId) {
|
|
757
|
+
console.error("Usage: opc delete session <id>");
|
|
758
|
+
process.exit(1);
|
|
759
|
+
}
|
|
760
|
+
console.log(`Deleting session ${sessionId}...`);
|
|
761
|
+
await deleteSessionById(sessionId);
|
|
762
|
+
console.log("Done.");
|
|
763
|
+
} else if (sub === "sessions") {
|
|
764
|
+
console.log("Deleting all sessions (irreversible)...");
|
|
765
|
+
await deleteAllSessions();
|
|
766
|
+
console.log("Done.");
|
|
767
|
+
} else if (sub === "project") {
|
|
768
|
+
const projectId = argv._[2];
|
|
769
|
+
if (!projectId) {
|
|
770
|
+
console.error("Usage: opc delete project <id>");
|
|
771
|
+
process.exit(1);
|
|
772
|
+
}
|
|
773
|
+
console.log(`Deleting project ${projectId} sessions from the OpenCode database...`);
|
|
774
|
+
await deleteAllProjectSessions(projectId);
|
|
775
|
+
console.log("Done.");
|
|
776
|
+
} else {
|
|
777
|
+
console.error(`Unknown subcommand: delete ${sub || ""}`);
|
|
778
|
+
printHelp();
|
|
779
|
+
process.exit(1);
|
|
780
|
+
}
|
|
781
|
+
} else if (command === "auth") {
|
|
782
|
+
const sub = argv._[1];
|
|
783
|
+
if (sub === "rotate") {
|
|
784
|
+
await handleAuthRotate({ proxy: argv.proxy });
|
|
785
|
+
} else {
|
|
786
|
+
console.error(`Unknown subcommand: auth ${sub || ""}`);
|
|
787
|
+
printHelp();
|
|
788
|
+
process.exit(1);
|
|
789
|
+
}
|
|
790
|
+
} else {
|
|
791
|
+
console.error(`Unknown command: ${command}`);
|
|
792
|
+
printHelp();
|
|
793
|
+
process.exit(1);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
main();
|