makecoder 1.0.25
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/LICENSE +21 -0
- package/README.md +281 -0
- package/claude/commands/dev/ultra-think.md +153 -0
- package/claude/commands/docs/generate-api-documentation.md +80 -0
- package/claude/commands/git/commit.md +63 -0
- package/claude/commands/git/status.md +39 -0
- package/claude/commands/setup/migrate-to-typescript.md +76 -0
- package/claude/commands/test/generate-test-cases.md +76 -0
- package/dist/cc.mjs +4654 -0
- package/dist/coder.js +201 -0
- package/dist/codex +0 -0
- package/dist/codex.exe +0 -0
- package/dist/codex.mjs +162 -0
- package/dist/gcli.mjs +3162 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/annotations-23.0.0.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.12-beta-searchableOptions.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/claude-code-jetbrains-plugin-0.1.12-beta.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/config-1.4.3.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/jansi-2.4.1.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlin-logging-jvm-7.0.0.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlin-reflect-2.0.21.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlin-sdk-jvm-0.4.0.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlin-stdlib-2.1.20.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-core-jvm-1.9.0.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-coroutines-slf4j-1.9.0.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-bytestring-jvm-0.5.4.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-io-core-jvm-0.5.4.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-core-jvm-1.8.1.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/kotlinx-serialization-json-jvm-1.8.1.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-client-cio-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-client-core-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-events-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-http-cio-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-http-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-io-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-network-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-network-tls-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-serialization-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-server-cio-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-server-core-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-server-sse-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-server-websockets-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-sse-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-utils-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-websocket-serialization-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/ktor-websockets-jvm-3.0.2.jar +0 -0
- package/dist/vendor/claude-code-jetbrains-plugin/lib/slf4j-api-2.0.16.jar +0 -0
- package/dist/vendor/ripgrep/COPYING +3 -0
- package/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/arm64-darwin/ripgrep.node +0 -0
- package/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/dist/vendor/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/dist/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/dist/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
- package/dist/zod/LICENSE +21 -0
- package/dist/zod/README.md +208 -0
- package/dist/zod/index.cjs +33 -0
- package/dist/zod/index.d.cts +4 -0
- package/dist/zod/index.d.ts +4 -0
- package/dist/zod/index.js +4 -0
- package/dist/zod/package.json +118 -0
- package/dist/zod/src/index.ts +4 -0
- package/dist/zod/src/v3/ZodError.ts +330 -0
- package/dist/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/dist/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/dist/zod/src/v3/benchmarks/index.ts +59 -0
- package/dist/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/dist/zod/src/v3/benchmarks/object.ts +69 -0
- package/dist/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/dist/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/dist/zod/src/v3/benchmarks/string.ts +55 -0
- package/dist/zod/src/v3/benchmarks/union.ts +80 -0
- package/dist/zod/src/v3/errors.ts +13 -0
- package/dist/zod/src/v3/external.ts +6 -0
- package/dist/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/dist/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/dist/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/dist/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/dist/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/dist/zod/src/v3/helpers/util.ts +224 -0
- package/dist/zod/src/v3/index.ts +4 -0
- package/dist/zod/src/v3/locales/en.ts +124 -0
- package/dist/zod/src/v3/standard-schema.ts +113 -0
- package/dist/zod/src/v3/tests/Mocker.ts +54 -0
- package/dist/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/dist/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/dist/zod/src/v3/tests/array.test.ts +71 -0
- package/dist/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/dist/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/dist/zod/src/v3/tests/base.test.ts +29 -0
- package/dist/zod/src/v3/tests/bigint.test.ts +55 -0
- package/dist/zod/src/v3/tests/branded.test.ts +53 -0
- package/dist/zod/src/v3/tests/catch.test.ts +220 -0
- package/dist/zod/src/v3/tests/coerce.test.ts +133 -0
- package/dist/zod/src/v3/tests/complex.test.ts +56 -0
- package/dist/zod/src/v3/tests/custom.test.ts +31 -0
- package/dist/zod/src/v3/tests/date.test.ts +32 -0
- package/dist/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/dist/zod/src/v3/tests/default.test.ts +112 -0
- package/dist/zod/src/v3/tests/description.test.ts +33 -0
- package/dist/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/dist/zod/src/v3/tests/enum.test.ts +80 -0
- package/dist/zod/src/v3/tests/error.test.ts +551 -0
- package/dist/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/dist/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/dist/zod/src/v3/tests/function.test.ts +257 -0
- package/dist/zod/src/v3/tests/generics.test.ts +48 -0
- package/dist/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/dist/zod/src/v3/tests/intersection.test.ts +110 -0
- package/dist/zod/src/v3/tests/language-server.source.ts +76 -0
- package/dist/zod/src/v3/tests/language-server.test.ts +207 -0
- package/dist/zod/src/v3/tests/literal.test.ts +36 -0
- package/dist/zod/src/v3/tests/map.test.ts +110 -0
- package/dist/zod/src/v3/tests/masking.test.ts +4 -0
- package/dist/zod/src/v3/tests/mocker.test.ts +19 -0
- package/dist/zod/src/v3/tests/nan.test.ts +21 -0
- package/dist/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/dist/zod/src/v3/tests/nullable.test.ts +42 -0
- package/dist/zod/src/v3/tests/number.test.ts +176 -0
- package/dist/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/dist/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/dist/zod/src/v3/tests/object.test.ts +434 -0
- package/dist/zod/src/v3/tests/optional.test.ts +42 -0
- package/dist/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/dist/zod/src/v3/tests/parser.test.ts +41 -0
- package/dist/zod/src/v3/tests/partials.test.ts +243 -0
- package/dist/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/dist/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/dist/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/dist/zod/src/v3/tests/primitive.test.ts +440 -0
- package/dist/zod/src/v3/tests/promise.test.ts +90 -0
- package/dist/zod/src/v3/tests/readonly.test.ts +194 -0
- package/dist/zod/src/v3/tests/record.test.ts +171 -0
- package/dist/zod/src/v3/tests/recursive.test.ts +197 -0
- package/dist/zod/src/v3/tests/refine.test.ts +313 -0
- package/dist/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/dist/zod/src/v3/tests/set.test.ts +142 -0
- package/dist/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/dist/zod/src/v3/tests/string.test.ts +916 -0
- package/dist/zod/src/v3/tests/transformer.test.ts +233 -0
- package/dist/zod/src/v3/tests/tuple.test.ts +90 -0
- package/dist/zod/src/v3/tests/unions.test.ts +57 -0
- package/dist/zod/src/v3/tests/validations.test.ts +133 -0
- package/dist/zod/src/v3/tests/void.test.ts +15 -0
- package/dist/zod/src/v3/types.ts +5136 -0
- package/dist/zod/src/v4/classic/checks.ts +30 -0
- package/dist/zod/src/v4/classic/coerce.ts +27 -0
- package/dist/zod/src/v4/classic/compat.ts +66 -0
- package/dist/zod/src/v4/classic/errors.ts +75 -0
- package/dist/zod/src/v4/classic/external.ts +50 -0
- package/dist/zod/src/v4/classic/index.ts +5 -0
- package/dist/zod/src/v4/classic/iso.ts +90 -0
- package/dist/zod/src/v4/classic/parse.ts +33 -0
- package/dist/zod/src/v4/classic/schemas.ts +2054 -0
- package/dist/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/dist/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/dist/zod/src/v4/classic/tests/assignability.test.ts +210 -0
- package/dist/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/dist/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/dist/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/dist/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/dist/zod/src/v4/classic/tests/brand.test.ts +63 -0
- package/dist/zod/src/v4/classic/tests/catch.test.ts +252 -0
- package/dist/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/dist/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/dist/zod/src/v4/classic/tests/continuability.test.ts +352 -0
- package/dist/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/dist/zod/src/v4/classic/tests/date.test.ts +31 -0
- package/dist/zod/src/v4/classic/tests/datetime.test.ts +296 -0
- package/dist/zod/src/v4/classic/tests/default.test.ts +313 -0
- package/dist/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/dist/zod/src/v4/classic/tests/discriminated-unions.test.ts +619 -0
- package/dist/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/dist/zod/src/v4/classic/tests/error-utils.test.ts +527 -0
- package/dist/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/dist/zod/src/v4/classic/tests/file.test.ts +91 -0
- package/dist/zod/src/v4/classic/tests/firstparty.test.ts +175 -0
- package/dist/zod/src/v4/classic/tests/function.test.ts +268 -0
- package/dist/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/dist/zod/src/v4/classic/tests/index.test.ts +829 -0
- package/dist/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
- package/dist/zod/src/v4/classic/tests/intersection.test.ts +171 -0
- package/dist/zod/src/v4/classic/tests/json.test.ts +108 -0
- package/dist/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/dist/zod/src/v4/classic/tests/literal.test.ts +92 -0
- package/dist/zod/src/v4/classic/tests/map.test.ts +196 -0
- package/dist/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/dist/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/dist/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
- package/dist/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/dist/zod/src/v4/classic/tests/number.test.ts +247 -0
- package/dist/zod/src/v4/classic/tests/object.test.ts +563 -0
- package/dist/zod/src/v4/classic/tests/optional.test.ts +123 -0
- package/dist/zod/src/v4/classic/tests/partial.test.ts +147 -0
- package/dist/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
- package/dist/zod/src/v4/classic/tests/pipe.test.ts +81 -0
- package/dist/zod/src/v4/classic/tests/prefault.test.ts +37 -0
- package/dist/zod/src/v4/classic/tests/preprocess.test.ts +298 -0
- package/dist/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/dist/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/dist/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/dist/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/dist/zod/src/v4/classic/tests/record.test.ts +342 -0
- package/dist/zod/src/v4/classic/tests/recursive-types.test.ts +356 -0
- package/dist/zod/src/v4/classic/tests/refine.test.ts +532 -0
- package/dist/zod/src/v4/classic/tests/registries.test.ts +204 -0
- package/dist/zod/src/v4/classic/tests/set.test.ts +179 -0
- package/dist/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
- package/dist/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
- package/dist/zod/src/v4/classic/tests/string.test.ts +881 -0
- package/dist/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
- package/dist/zod/src/v4/classic/tests/template-literal.test.ts +758 -0
- package/dist/zod/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
- package/dist/zod/src/v4/classic/tests/transform.test.ts +250 -0
- package/dist/zod/src/v4/classic/tests/tuple.test.ts +163 -0
- package/dist/zod/src/v4/classic/tests/union.test.ts +94 -0
- package/dist/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/dist/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/dist/zod/src/v4/core/api.ts +1594 -0
- package/dist/zod/src/v4/core/checks.ts +1283 -0
- package/dist/zod/src/v4/core/config.ts +15 -0
- package/dist/zod/src/v4/core/core.ts +134 -0
- package/dist/zod/src/v4/core/doc.ts +44 -0
- package/dist/zod/src/v4/core/errors.ts +424 -0
- package/dist/zod/src/v4/core/function.ts +176 -0
- package/dist/zod/src/v4/core/index.ts +15 -0
- package/dist/zod/src/v4/core/json-schema.ts +143 -0
- package/dist/zod/src/v4/core/parse.ts +94 -0
- package/dist/zod/src/v4/core/regexes.ts +135 -0
- package/dist/zod/src/v4/core/registries.ts +96 -0
- package/dist/zod/src/v4/core/schemas.ts +3842 -0
- package/dist/zod/src/v4/core/standard-schema.ts +64 -0
- package/dist/zod/src/v4/core/tests/index.test.ts +46 -0
- package/dist/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/dist/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/dist/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/dist/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/dist/zod/src/v4/core/to-json-schema.ts +977 -0
- package/dist/zod/src/v4/core/util.ts +775 -0
- package/dist/zod/src/v4/core/versions.ts +5 -0
- package/dist/zod/src/v4/core/zsf.ts +323 -0
- package/dist/zod/src/v4/index.ts +4 -0
- package/dist/zod/src/v4/locales/ar.ts +125 -0
- package/dist/zod/src/v4/locales/az.ts +121 -0
- package/dist/zod/src/v4/locales/be.ts +184 -0
- package/dist/zod/src/v4/locales/ca.ts +127 -0
- package/dist/zod/src/v4/locales/cs.ts +142 -0
- package/dist/zod/src/v4/locales/de.ts +124 -0
- package/dist/zod/src/v4/locales/en.ts +127 -0
- package/dist/zod/src/v4/locales/eo.ts +125 -0
- package/dist/zod/src/v4/locales/es.ts +125 -0
- package/dist/zod/src/v4/locales/fa.ts +134 -0
- package/dist/zod/src/v4/locales/fi.ts +131 -0
- package/dist/zod/src/v4/locales/fr-CA.ts +126 -0
- package/dist/zod/src/v4/locales/fr.ts +124 -0
- package/dist/zod/src/v4/locales/he.ts +125 -0
- package/dist/zod/src/v4/locales/hu.ts +126 -0
- package/dist/zod/src/v4/locales/id.ts +125 -0
- package/dist/zod/src/v4/locales/index.ts +39 -0
- package/dist/zod/src/v4/locales/it.ts +125 -0
- package/dist/zod/src/v4/locales/ja.ts +122 -0
- package/dist/zod/src/v4/locales/kh.ts +126 -0
- package/dist/zod/src/v4/locales/ko.ts +131 -0
- package/dist/zod/src/v4/locales/mk.ts +127 -0
- package/dist/zod/src/v4/locales/ms.ts +124 -0
- package/dist/zod/src/v4/locales/nl.ts +126 -0
- package/dist/zod/src/v4/locales/no.ts +124 -0
- package/dist/zod/src/v4/locales/ota.ts +125 -0
- package/dist/zod/src/v4/locales/pl.ts +126 -0
- package/dist/zod/src/v4/locales/ps.ts +133 -0
- package/dist/zod/src/v4/locales/pt.ts +123 -0
- package/dist/zod/src/v4/locales/ru.ts +184 -0
- package/dist/zod/src/v4/locales/sl.ts +126 -0
- package/dist/zod/src/v4/locales/sv.ts +127 -0
- package/dist/zod/src/v4/locales/ta.ts +125 -0
- package/dist/zod/src/v4/locales/th.ts +126 -0
- package/dist/zod/src/v4/locales/tr.ts +121 -0
- package/dist/zod/src/v4/locales/ua.ts +126 -0
- package/dist/zod/src/v4/locales/ur.ts +126 -0
- package/dist/zod/src/v4/locales/vi.ts +125 -0
- package/dist/zod/src/v4/locales/zh-CN.ts +123 -0
- package/dist/zod/src/v4/locales/zh-TW.ts +125 -0
- package/dist/zod/src/v4/mini/checks.ts +32 -0
- package/dist/zod/src/v4/mini/coerce.ts +22 -0
- package/dist/zod/src/v4/mini/external.ts +40 -0
- package/dist/zod/src/v4/mini/index.ts +3 -0
- package/dist/zod/src/v4/mini/iso.ts +62 -0
- package/dist/zod/src/v4/mini/parse.ts +1 -0
- package/dist/zod/src/v4/mini/schemas.ts +1579 -0
- package/dist/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/dist/zod/src/v4/mini/tests/brand.test.ts +51 -0
- package/dist/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/dist/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/dist/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/dist/zod/src/v4/mini/tests/functions.test.ts +43 -0
- package/dist/zod/src/v4/mini/tests/index.test.ts +871 -0
- package/dist/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/dist/zod/src/v4/mini/tests/object.test.ts +185 -0
- package/dist/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/dist/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
- package/dist/zod/src/v4/mini/tests/string.test.ts +299 -0
- package/dist/zod/src/v4-mini/index.ts +1 -0
- package/dist/zod/v3/ZodError.cjs +138 -0
- package/dist/zod/v3/ZodError.d.cts +164 -0
- package/dist/zod/v3/ZodError.d.ts +164 -0
- package/dist/zod/v3/ZodError.js +133 -0
- package/dist/zod/v3/errors.cjs +17 -0
- package/dist/zod/v3/errors.d.cts +5 -0
- package/dist/zod/v3/errors.d.ts +5 -0
- package/dist/zod/v3/errors.js +9 -0
- package/dist/zod/v3/external.cjs +22 -0
- package/dist/zod/v3/external.d.cts +6 -0
- package/dist/zod/v3/external.d.ts +6 -0
- package/dist/zod/v3/external.js +6 -0
- package/dist/zod/v3/helpers/enumUtil.cjs +2 -0
- package/dist/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/dist/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/dist/zod/v3/helpers/enumUtil.js +1 -0
- package/dist/zod/v3/helpers/errorUtil.cjs +9 -0
- package/dist/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/dist/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/dist/zod/v3/helpers/errorUtil.js +6 -0
- package/dist/zod/v3/helpers/parseUtil.cjs +124 -0
- package/dist/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/dist/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/dist/zod/v3/helpers/parseUtil.js +109 -0
- package/dist/zod/v3/helpers/partialUtil.cjs +2 -0
- package/dist/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/dist/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/dist/zod/v3/helpers/partialUtil.js +1 -0
- package/dist/zod/v3/helpers/typeAliases.cjs +2 -0
- package/dist/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/dist/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/dist/zod/v3/helpers/typeAliases.js +1 -0
- package/dist/zod/v3/helpers/util.cjs +137 -0
- package/dist/zod/v3/helpers/util.d.cts +85 -0
- package/dist/zod/v3/helpers/util.d.ts +85 -0
- package/dist/zod/v3/helpers/util.js +133 -0
- package/dist/zod/v3/index.cjs +33 -0
- package/dist/zod/v3/index.d.cts +4 -0
- package/dist/zod/v3/index.d.ts +4 -0
- package/dist/zod/v3/index.js +4 -0
- package/dist/zod/v3/locales/en.cjs +111 -0
- package/dist/zod/v3/locales/en.d.cts +3 -0
- package/dist/zod/v3/locales/en.d.ts +3 -0
- package/dist/zod/v3/locales/en.js +109 -0
- package/dist/zod/v3/standard-schema.cjs +2 -0
- package/dist/zod/v3/standard-schema.d.cts +102 -0
- package/dist/zod/v3/standard-schema.d.ts +102 -0
- package/dist/zod/v3/standard-schema.js +1 -0
- package/dist/zod/v3/types.cjs +3775 -0
- package/dist/zod/v3/types.d.cts +1031 -0
- package/dist/zod/v3/types.d.ts +1031 -0
- package/dist/zod/v3/types.js +3693 -0
- package/dist/zod/v4/classic/checks.cjs +32 -0
- package/dist/zod/v4/classic/checks.d.cts +1 -0
- package/dist/zod/v4/classic/checks.d.ts +1 -0
- package/dist/zod/v4/classic/checks.js +1 -0
- package/dist/zod/v4/classic/coerce.cjs +47 -0
- package/dist/zod/v4/classic/coerce.d.cts +17 -0
- package/dist/zod/v4/classic/coerce.d.ts +17 -0
- package/dist/zod/v4/classic/coerce.js +17 -0
- package/dist/zod/v4/classic/compat.cjs +57 -0
- package/dist/zod/v4/classic/compat.d.cts +46 -0
- package/dist/zod/v4/classic/compat.d.ts +46 -0
- package/dist/zod/v4/classic/compat.js +27 -0
- package/dist/zod/v4/classic/errors.cjs +67 -0
- package/dist/zod/v4/classic/errors.d.cts +30 -0
- package/dist/zod/v4/classic/errors.d.ts +30 -0
- package/dist/zod/v4/classic/errors.js +41 -0
- package/dist/zod/v4/classic/external.cjs +70 -0
- package/dist/zod/v4/classic/external.d.cts +13 -0
- package/dist/zod/v4/classic/external.d.ts +13 -0
- package/dist/zod/v4/classic/external.js +18 -0
- package/dist/zod/v4/classic/index.cjs +33 -0
- package/dist/zod/v4/classic/index.d.cts +4 -0
- package/dist/zod/v4/classic/index.d.ts +4 -0
- package/dist/zod/v4/classic/index.js +4 -0
- package/dist/zod/v4/classic/iso.cjs +60 -0
- package/dist/zod/v4/classic/iso.d.cts +22 -0
- package/dist/zod/v4/classic/iso.d.ts +22 -0
- package/dist/zod/v4/classic/iso.js +30 -0
- package/dist/zod/v4/classic/parse.cjs +32 -0
- package/dist/zod/v4/classic/parse.d.cts +23 -0
- package/dist/zod/v4/classic/parse.d.ts +23 -0
- package/dist/zod/v4/classic/parse.js +6 -0
- package/dist/zod/v4/classic/schemas.cjs +1109 -0
- package/dist/zod/v4/classic/schemas.d.cts +630 -0
- package/dist/zod/v4/classic/schemas.d.ts +630 -0
- package/dist/zod/v4/classic/schemas.js +1006 -0
- package/dist/zod/v4/core/api.cjs +1039 -0
- package/dist/zod/v4/core/api.d.cts +284 -0
- package/dist/zod/v4/core/api.d.ts +284 -0
- package/dist/zod/v4/core/api.js +906 -0
- package/dist/zod/v4/core/checks.cjs +591 -0
- package/dist/zod/v4/core/checks.d.cts +278 -0
- package/dist/zod/v4/core/checks.d.ts +278 -0
- package/dist/zod/v4/core/checks.js +565 -0
- package/dist/zod/v4/core/core.cjs +67 -0
- package/dist/zod/v4/core/core.d.cts +49 -0
- package/dist/zod/v4/core/core.d.ts +49 -0
- package/dist/zod/v4/core/core.js +61 -0
- package/dist/zod/v4/core/doc.cjs +39 -0
- package/dist/zod/v4/core/doc.d.cts +14 -0
- package/dist/zod/v4/core/doc.d.ts +14 -0
- package/dist/zod/v4/core/doc.js +35 -0
- package/dist/zod/v4/core/errors.cjs +226 -0
- package/dist/zod/v4/core/errors.d.cts +208 -0
- package/dist/zod/v4/core/errors.d.ts +208 -0
- package/dist/zod/v4/core/errors.js +195 -0
- package/dist/zod/v4/core/function.cjs +102 -0
- package/dist/zod/v4/core/function.d.cts +52 -0
- package/dist/zod/v4/core/function.d.ts +52 -0
- package/dist/zod/v4/core/function.js +75 -0
- package/dist/zod/v4/core/index.cjs +44 -0
- package/dist/zod/v4/core/index.d.cts +15 -0
- package/dist/zod/v4/core/index.d.ts +15 -0
- package/dist/zod/v4/core/index.js +15 -0
- package/dist/zod/v4/core/json-schema.cjs +2 -0
- package/dist/zod/v4/core/json-schema.d.cts +87 -0
- package/dist/zod/v4/core/json-schema.d.ts +87 -0
- package/dist/zod/v4/core/json-schema.js +1 -0
- package/dist/zod/v4/core/parse.cjs +87 -0
- package/dist/zod/v4/core/parse.d.cts +25 -0
- package/dist/zod/v4/core/parse.d.ts +25 -0
- package/dist/zod/v4/core/parse.js +57 -0
- package/dist/zod/v4/core/regexes.cjs +103 -0
- package/dist/zod/v4/core/regexes.d.cts +62 -0
- package/dist/zod/v4/core/regexes.d.ts +62 -0
- package/dist/zod/v4/core/regexes.js +95 -0
- package/dist/zod/v4/core/registries.cjs +56 -0
- package/dist/zod/v4/core/registries.d.cts +35 -0
- package/dist/zod/v4/core/registries.d.ts +35 -0
- package/dist/zod/v4/core/registries.js +51 -0
- package/dist/zod/v4/core/schemas.cjs +1748 -0
- package/dist/zod/v4/core/schemas.d.cts +1041 -0
- package/dist/zod/v4/core/schemas.d.ts +1041 -0
- package/dist/zod/v4/core/schemas.js +1717 -0
- package/dist/zod/v4/core/standard-schema.cjs +2 -0
- package/dist/zod/v4/core/standard-schema.d.cts +55 -0
- package/dist/zod/v4/core/standard-schema.d.ts +55 -0
- package/dist/zod/v4/core/standard-schema.js +1 -0
- package/dist/zod/v4/core/to-json-schema.cjs +854 -0
- package/dist/zod/v4/core/to-json-schema.d.cts +88 -0
- package/dist/zod/v4/core/to-json-schema.d.ts +88 -0
- package/dist/zod/v4/core/to-json-schema.js +849 -0
- package/dist/zod/v4/core/util.cjs +539 -0
- package/dist/zod/v4/core/util.d.cts +183 -0
- package/dist/zod/v4/core/util.d.ts +183 -0
- package/dist/zod/v4/core/util.js +493 -0
- package/dist/zod/v4/core/versions.cjs +8 -0
- package/dist/zod/v4/core/versions.d.cts +5 -0
- package/dist/zod/v4/core/versions.d.ts +5 -0
- package/dist/zod/v4/core/versions.js +5 -0
- package/dist/zod/v4/index.cjs +22 -0
- package/dist/zod/v4/index.d.cts +3 -0
- package/dist/zod/v4/index.d.ts +3 -0
- package/dist/zod/v4/index.js +3 -0
- package/dist/zod/v4/locales/ar.cjs +142 -0
- package/dist/zod/v4/locales/ar.d.cts +4 -0
- package/dist/zod/v4/locales/ar.d.ts +4 -0
- package/dist/zod/v4/locales/ar.js +116 -0
- package/dist/zod/v4/locales/az.cjs +141 -0
- package/dist/zod/v4/locales/az.d.cts +4 -0
- package/dist/zod/v4/locales/az.d.ts +4 -0
- package/dist/zod/v4/locales/az.js +115 -0
- package/dist/zod/v4/locales/be.cjs +190 -0
- package/dist/zod/v4/locales/be.d.cts +4 -0
- package/dist/zod/v4/locales/be.d.ts +4 -0
- package/dist/zod/v4/locales/be.js +164 -0
- package/dist/zod/v4/locales/ca.cjs +144 -0
- package/dist/zod/v4/locales/ca.d.cts +4 -0
- package/dist/zod/v4/locales/ca.d.ts +4 -0
- package/dist/zod/v4/locales/ca.js +118 -0
- package/dist/zod/v4/locales/cs.cjs +161 -0
- package/dist/zod/v4/locales/cs.d.cts +4 -0
- package/dist/zod/v4/locales/cs.d.ts +4 -0
- package/dist/zod/v4/locales/cs.js +135 -0
- package/dist/zod/v4/locales/de.cjs +142 -0
- package/dist/zod/v4/locales/de.d.cts +4 -0
- package/dist/zod/v4/locales/de.d.ts +4 -0
- package/dist/zod/v4/locales/de.js +116 -0
- package/dist/zod/v4/locales/en.cjs +145 -0
- package/dist/zod/v4/locales/en.d.cts +5 -0
- package/dist/zod/v4/locales/en.d.ts +5 -0
- package/dist/zod/v4/locales/en.js +117 -0
- package/dist/zod/v4/locales/eo.cjs +144 -0
- package/dist/zod/v4/locales/eo.d.cts +5 -0
- package/dist/zod/v4/locales/eo.d.ts +5 -0
- package/dist/zod/v4/locales/eo.js +116 -0
- package/dist/zod/v4/locales/es.cjs +143 -0
- package/dist/zod/v4/locales/es.d.cts +4 -0
- package/dist/zod/v4/locales/es.d.ts +4 -0
- package/dist/zod/v4/locales/es.js +117 -0
- package/dist/zod/v4/locales/fa.cjs +148 -0
- package/dist/zod/v4/locales/fa.d.cts +4 -0
- package/dist/zod/v4/locales/fa.d.ts +4 -0
- package/dist/zod/v4/locales/fa.js +122 -0
- package/dist/zod/v4/locales/fi.cjs +148 -0
- package/dist/zod/v4/locales/fi.d.cts +4 -0
- package/dist/zod/v4/locales/fi.d.ts +4 -0
- package/dist/zod/v4/locales/fi.js +122 -0
- package/dist/zod/v4/locales/fr-CA.cjs +143 -0
- package/dist/zod/v4/locales/fr-CA.d.cts +4 -0
- package/dist/zod/v4/locales/fr-CA.d.ts +4 -0
- package/dist/zod/v4/locales/fr-CA.js +117 -0
- package/dist/zod/v4/locales/fr.cjs +142 -0
- package/dist/zod/v4/locales/fr.d.cts +4 -0
- package/dist/zod/v4/locales/fr.d.ts +4 -0
- package/dist/zod/v4/locales/fr.js +116 -0
- package/dist/zod/v4/locales/he.cjs +143 -0
- package/dist/zod/v4/locales/he.d.cts +4 -0
- package/dist/zod/v4/locales/he.d.ts +4 -0
- package/dist/zod/v4/locales/he.js +117 -0
- package/dist/zod/v4/locales/hu.cjs +143 -0
- package/dist/zod/v4/locales/hu.d.cts +4 -0
- package/dist/zod/v4/locales/hu.d.ts +4 -0
- package/dist/zod/v4/locales/hu.js +117 -0
- package/dist/zod/v4/locales/id.cjs +142 -0
- package/dist/zod/v4/locales/id.d.cts +4 -0
- package/dist/zod/v4/locales/id.d.ts +4 -0
- package/dist/zod/v4/locales/id.js +116 -0
- package/dist/zod/v4/locales/index.cjs +84 -0
- package/dist/zod/v4/locales/index.d.cts +39 -0
- package/dist/zod/v4/locales/index.d.ts +39 -0
- package/dist/zod/v4/locales/index.js +39 -0
- package/dist/zod/v4/locales/it.cjs +143 -0
- package/dist/zod/v4/locales/it.d.cts +4 -0
- package/dist/zod/v4/locales/it.d.ts +4 -0
- package/dist/zod/v4/locales/it.js +117 -0
- package/dist/zod/v4/locales/ja.cjs +141 -0
- package/dist/zod/v4/locales/ja.d.cts +4 -0
- package/dist/zod/v4/locales/ja.d.ts +4 -0
- package/dist/zod/v4/locales/ja.js +115 -0
- package/dist/zod/v4/locales/kh.cjs +143 -0
- package/dist/zod/v4/locales/kh.d.cts +4 -0
- package/dist/zod/v4/locales/kh.d.ts +4 -0
- package/dist/zod/v4/locales/kh.js +117 -0
- package/dist/zod/v4/locales/ko.cjs +147 -0
- package/dist/zod/v4/locales/ko.d.cts +4 -0
- package/dist/zod/v4/locales/ko.d.ts +4 -0
- package/dist/zod/v4/locales/ko.js +121 -0
- package/dist/zod/v4/locales/mk.cjs +144 -0
- package/dist/zod/v4/locales/mk.d.cts +4 -0
- package/dist/zod/v4/locales/mk.d.ts +4 -0
- package/dist/zod/v4/locales/mk.js +118 -0
- package/dist/zod/v4/locales/ms.cjs +142 -0
- package/dist/zod/v4/locales/ms.d.cts +4 -0
- package/dist/zod/v4/locales/ms.d.ts +4 -0
- package/dist/zod/v4/locales/ms.js +116 -0
- package/dist/zod/v4/locales/nl.cjs +143 -0
- package/dist/zod/v4/locales/nl.d.cts +4 -0
- package/dist/zod/v4/locales/nl.d.ts +4 -0
- package/dist/zod/v4/locales/nl.js +117 -0
- package/dist/zod/v4/locales/no.cjs +142 -0
- package/dist/zod/v4/locales/no.d.cts +4 -0
- package/dist/zod/v4/locales/no.d.ts +4 -0
- package/dist/zod/v4/locales/no.js +116 -0
- package/dist/zod/v4/locales/ota.cjs +143 -0
- package/dist/zod/v4/locales/ota.d.cts +4 -0
- package/dist/zod/v4/locales/ota.d.ts +4 -0
- package/dist/zod/v4/locales/ota.js +117 -0
- package/dist/zod/v4/locales/pl.cjs +143 -0
- package/dist/zod/v4/locales/pl.d.cts +4 -0
- package/dist/zod/v4/locales/pl.d.ts +4 -0
- package/dist/zod/v4/locales/pl.js +117 -0
- package/dist/zod/v4/locales/ps.cjs +148 -0
- package/dist/zod/v4/locales/ps.d.cts +4 -0
- package/dist/zod/v4/locales/ps.d.ts +4 -0
- package/dist/zod/v4/locales/ps.js +122 -0
- package/dist/zod/v4/locales/pt.cjs +142 -0
- package/dist/zod/v4/locales/pt.d.cts +4 -0
- package/dist/zod/v4/locales/pt.d.ts +4 -0
- package/dist/zod/v4/locales/pt.js +116 -0
- package/dist/zod/v4/locales/ru.cjs +190 -0
- package/dist/zod/v4/locales/ru.d.cts +4 -0
- package/dist/zod/v4/locales/ru.d.ts +4 -0
- package/dist/zod/v4/locales/ru.js +164 -0
- package/dist/zod/v4/locales/sl.cjs +143 -0
- package/dist/zod/v4/locales/sl.d.cts +4 -0
- package/dist/zod/v4/locales/sl.d.ts +4 -0
- package/dist/zod/v4/locales/sl.js +117 -0
- package/dist/zod/v4/locales/sv.cjs +144 -0
- package/dist/zod/v4/locales/sv.d.cts +4 -0
- package/dist/zod/v4/locales/sv.d.ts +4 -0
- package/dist/zod/v4/locales/sv.js +118 -0
- package/dist/zod/v4/locales/ta.cjs +143 -0
- package/dist/zod/v4/locales/ta.d.cts +4 -0
- package/dist/zod/v4/locales/ta.d.ts +4 -0
- package/dist/zod/v4/locales/ta.js +117 -0
- package/dist/zod/v4/locales/th.cjs +143 -0
- package/dist/zod/v4/locales/th.d.cts +4 -0
- package/dist/zod/v4/locales/th.d.ts +4 -0
- package/dist/zod/v4/locales/th.js +117 -0
- package/dist/zod/v4/locales/tr.cjs +143 -0
- package/dist/zod/v4/locales/tr.d.cts +5 -0
- package/dist/zod/v4/locales/tr.d.ts +5 -0
- package/dist/zod/v4/locales/tr.js +115 -0
- package/dist/zod/v4/locales/ua.cjs +143 -0
- package/dist/zod/v4/locales/ua.d.cts +4 -0
- package/dist/zod/v4/locales/ua.d.ts +4 -0
- package/dist/zod/v4/locales/ua.js +117 -0
- package/dist/zod/v4/locales/ur.cjs +143 -0
- package/dist/zod/v4/locales/ur.d.cts +4 -0
- package/dist/zod/v4/locales/ur.d.ts +4 -0
- package/dist/zod/v4/locales/ur.js +117 -0
- package/dist/zod/v4/locales/vi.cjs +142 -0
- package/dist/zod/v4/locales/vi.d.cts +4 -0
- package/dist/zod/v4/locales/vi.d.ts +4 -0
- package/dist/zod/v4/locales/vi.js +116 -0
- package/dist/zod/v4/locales/zh-CN.cjs +142 -0
- package/dist/zod/v4/locales/zh-CN.d.cts +4 -0
- package/dist/zod/v4/locales/zh-CN.d.ts +4 -0
- package/dist/zod/v4/locales/zh-CN.js +116 -0
- package/dist/zod/v4/locales/zh-TW.cjs +143 -0
- package/dist/zod/v4/locales/zh-TW.d.cts +4 -0
- package/dist/zod/v4/locales/zh-TW.d.ts +4 -0
- package/dist/zod/v4/locales/zh-TW.js +117 -0
- package/dist/zod/v4/mini/checks.cjs +34 -0
- package/dist/zod/v4/mini/checks.d.cts +1 -0
- package/dist/zod/v4/mini/checks.d.ts +1 -0
- package/dist/zod/v4/mini/checks.js +1 -0
- package/dist/zod/v4/mini/coerce.cjs +47 -0
- package/dist/zod/v4/mini/coerce.d.cts +7 -0
- package/dist/zod/v4/mini/coerce.d.ts +7 -0
- package/dist/zod/v4/mini/coerce.js +17 -0
- package/dist/zod/v4/mini/external.cjs +62 -0
- package/dist/zod/v4/mini/external.d.cts +11 -0
- package/dist/zod/v4/mini/external.d.ts +11 -0
- package/dist/zod/v4/mini/external.js +13 -0
- package/dist/zod/v4/mini/index.cjs +32 -0
- package/dist/zod/v4/mini/index.d.cts +3 -0
- package/dist/zod/v4/mini/index.d.ts +3 -0
- package/dist/zod/v4/mini/index.js +3 -0
- package/dist/zod/v4/mini/iso.cjs +60 -0
- package/dist/zod/v4/mini/iso.d.cts +22 -0
- package/dist/zod/v4/mini/iso.d.ts +22 -0
- package/dist/zod/v4/mini/iso.js +30 -0
- package/dist/zod/v4/mini/parse.cjs +8 -0
- package/dist/zod/v4/mini/parse.d.cts +1 -0
- package/dist/zod/v4/mini/parse.d.ts +1 -0
- package/dist/zod/v4/mini/parse.js +1 -0
- package/dist/zod/v4/mini/schemas.cjs +839 -0
- package/dist/zod/v4/mini/schemas.d.cts +356 -0
- package/dist/zod/v4/mini/schemas.d.ts +356 -0
- package/dist/zod/v4/mini/schemas.js +732 -0
- package/dist/zod/v4-mini/index.cjs +17 -0
- package/dist/zod/v4-mini/index.d.cts +1 -0
- package/dist/zod/v4-mini/index.d.ts +1 -0
- package/dist/zod/v4-mini/index.js +1 -0
- package/package.json +42 -0
- package/scripts/postinstall.js +75 -0
package/dist/coder.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var Ue=Object.create;var X=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var m=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Re=(l,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ve(e))!Ne.call(l,o)&&o!==s&&X(l,o,{get:()=>e[o],enumerable:!(t=Be(e,o))||t.enumerable});return l};var Le=(l,e,s)=>(s=l!=null?Ue(Ge(l)):{},Re(e||!l||!l.__esModule?X(s,"default",{value:l,enumerable:!0}):s,l));var ee=m((_s,Z)=>{var He=require("http"),A=class{constructor(e={}){this.port=e.port||9380,this.timeout=e.timeout||300*1e3,this.server=null,this.timeoutId=null}validateTokenFormat(e){if(!e||typeof e!="string")return!1;let s=e.split(".");if(s.length!==2)return!1;let[t,o]=s;return t&&t.length>0&&o&&o.length>0}async waitForCallback(e){return new Promise((s,t)=>{let o=!1;this.server=He.createServer((n,i)=>{let a=new URL(n.url,`http://localhost:${this.port}`);if(a.pathname==="/callback"){let r=a.searchParams.get("token"),c=a.searchParams.get("state"),h=a.searchParams.get("error");if(h){i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(`
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<title>\u767B\u5F55\u5931\u8D25 - MakeCoder</title>
|
|
8
|
+
<style>
|
|
9
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f3f4f6; color: #1f2937; }
|
|
10
|
+
.container { text-align: center; background: white; padding: 3rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); max-width: 28rem; width: 90%; }
|
|
11
|
+
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; color: #111827; }
|
|
12
|
+
p { color: #4b5563; line-height: 1.5; margin-bottom: 1rem; }
|
|
13
|
+
.icon { font-size: 4rem; margin-bottom: 1rem; display: inline-block; }
|
|
14
|
+
.error { color: #ef4444; }
|
|
15
|
+
.code { background: #fee2e2; color: #b91c1c; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-family: monospace; font-size: 0.875rem; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div class="container">
|
|
20
|
+
<div class="icon">\u274C</div>
|
|
21
|
+
<h1>\u767B\u5F55\u5931\u8D25</h1>
|
|
22
|
+
<p>\u6388\u6743\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF\uFF0C\u8BF7\u8FD4\u56DE\u7EC8\u7AEF\u91CD\u8BD5\u3002</p>
|
|
23
|
+
<p class="code">\u9519\u8BEF: ${h}</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
27
|
+
`),o||(o=!0,this.cleanup(),t(new Error(`OAuth error: ${h}`)));return}if(c!==e){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(`
|
|
28
|
+
<!DOCTYPE html>
|
|
29
|
+
<html>
|
|
30
|
+
<head>
|
|
31
|
+
<meta charset="utf-8">
|
|
32
|
+
<title>\u5B89\u5168\u9519\u8BEF - MakeCoder</title>
|
|
33
|
+
<style>
|
|
34
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f3f4f6; color: #1f2937; }
|
|
35
|
+
.container { text-align: center; background: white; padding: 3rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); max-width: 28rem; width: 90%; }
|
|
36
|
+
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; color: #111827; }
|
|
37
|
+
p { color: #4b5563; line-height: 1.5; margin-bottom: 1rem; }
|
|
38
|
+
.icon { font-size: 4rem; margin-bottom: 1rem; display: inline-block; }
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<div class="container">
|
|
43
|
+
<div class="icon">\u26A0\uFE0F</div>
|
|
44
|
+
<h1>\u5B89\u5168\u9A8C\u8BC1\u5931\u8D25</h1>
|
|
45
|
+
<p>\u68C0\u6D4B\u5230\u6F5C\u5728\u7684\u5B89\u5168\u98CE\u9669\uFF08CSRF\uFF09\uFF0C\u8BF7\u8FD4\u56DE\u7EC8\u7AEF\u91CD\u65B0\u5C1D\u8BD5\u767B\u5F55\u3002</p>
|
|
46
|
+
</div>
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
49
|
+
`),o||(o=!0,this.cleanup(),t(new Error("Invalid state parameter - possible CSRF attack")));return}if(!r){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(`
|
|
50
|
+
<!DOCTYPE html>
|
|
51
|
+
<html>
|
|
52
|
+
<head>
|
|
53
|
+
<meta charset="utf-8">
|
|
54
|
+
<title>\u6388\u6743\u5931\u8D25 - MakeCoder</title>
|
|
55
|
+
<style>
|
|
56
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f3f4f6; color: #1f2937; }
|
|
57
|
+
.container { text-align: center; background: white; padding: 3rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); max-width: 28rem; width: 90%; }
|
|
58
|
+
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; color: #111827; }
|
|
59
|
+
p { color: #4b5563; line-height: 1.5; margin-bottom: 1rem; }
|
|
60
|
+
.icon { font-size: 4rem; margin-bottom: 1rem; display: inline-block; }
|
|
61
|
+
</style>
|
|
62
|
+
</head>
|
|
63
|
+
<body>
|
|
64
|
+
<div class="container">
|
|
65
|
+
<div class="icon">\u274C</div>
|
|
66
|
+
<h1>\u6388\u6743\u5931\u8D25</h1>
|
|
67
|
+
<p>\u672A\u80FD\u83B7\u53D6\u6388\u6743\u4EE4\u724C\uFF0C\u8BF7\u8FD4\u56DE\u7EC8\u7AEF\u91CD\u8BD5\u3002</p>
|
|
68
|
+
</div>
|
|
69
|
+
</body>
|
|
70
|
+
</html>
|
|
71
|
+
`),o||(o=!0,this.cleanup(),t(new Error("No token received from OAuth callback")));return}if(!this.validateTokenFormat(r)){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(`
|
|
72
|
+
<!DOCTYPE html>
|
|
73
|
+
<html>
|
|
74
|
+
<head>
|
|
75
|
+
<meta charset="utf-8">
|
|
76
|
+
<title>\u4EE4\u724C\u683C\u5F0F\u9519\u8BEF - MakeCoder</title>
|
|
77
|
+
<style>
|
|
78
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f3f4f6; color: #1f2937; }
|
|
79
|
+
.container { text-align: center; background: white; padding: 3rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); max-width: 28rem; width: 90%; }
|
|
80
|
+
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; color: #111827; }
|
|
81
|
+
p { color: #4b5563; line-height: 1.5; margin-bottom: 1rem; }
|
|
82
|
+
.icon { font-size: 4rem; margin-bottom: 1rem; display: inline-block; }
|
|
83
|
+
.code { background: #fee2e2; color: #b91c1c; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-family: monospace; font-size: 0.875rem; }
|
|
84
|
+
</style>
|
|
85
|
+
</head>
|
|
86
|
+
<body>
|
|
87
|
+
<div class="container">
|
|
88
|
+
<div class="icon">\u26A0\uFE0F</div>
|
|
89
|
+
<h1>\u4EE4\u724C\u683C\u5F0F\u9519\u8BEF</h1>
|
|
90
|
+
<p>\u63A5\u6536\u5230\u7684\u4EE4\u724C\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u5E94\u4E3A <span class="code">ak.sk</span> \u683C\u5F0F\u3002</p>
|
|
91
|
+
<p>\u8BF7\u8FD4\u56DE\u7EC8\u7AEF\u91CD\u65B0\u5C1D\u8BD5\u767B\u5F55\u3002</p>
|
|
92
|
+
</div>
|
|
93
|
+
</body>
|
|
94
|
+
</html>
|
|
95
|
+
`),o||(o=!0,this.cleanup(),t(new Error("Invalid token format - expected ak.sk format")));return}let[u,g]=r.split(".");i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(`
|
|
96
|
+
<!DOCTYPE html>
|
|
97
|
+
<html>
|
|
98
|
+
<head>
|
|
99
|
+
<meta charset="utf-8">
|
|
100
|
+
<title>\u767B\u5F55\u6210\u529F - MakeCoder</title>
|
|
101
|
+
<style>
|
|
102
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f3f4f6; color: #1f2937; }
|
|
103
|
+
.container { text-align: center; background: white; padding: 3rem; border-radius: 1rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); max-width: 28rem; width: 90%; }
|
|
104
|
+
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; color: #111827; }
|
|
105
|
+
p { color: #4b5563; line-height: 1.5; margin-bottom: 0; }
|
|
106
|
+
.icon { font-size: 4rem; margin-bottom: 1.5rem; display: inline-block; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
|
|
107
|
+
.sub-text { font-size: 0.875rem; color: #9ca3af; margin-top: 2rem; }
|
|
108
|
+
@keyframes pop {
|
|
109
|
+
0% { transform: scale(0.5); opacity: 0; }
|
|
110
|
+
100% { transform: scale(1); opacity: 1; }
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
113
|
+
</head>
|
|
114
|
+
<body>
|
|
115
|
+
<div class="container">
|
|
116
|
+
<div class="icon">\u{1F389}</div>
|
|
117
|
+
<h1>\u767B\u5F55\u6210\u529F!</h1>
|
|
118
|
+
<p>\u5DF2\u6210\u529F\u83B7\u53D6\u6388\u6743\uFF0C\u6B63\u5728\u914D\u7F6E\u60A8\u7684 API Key...</p>
|
|
119
|
+
<p class="sub-text">\u60A8\u53EF\u4EE5\u5173\u95ED\u6B64\u7A97\u53E3\u5E76\u8FD4\u56DE\u7EC8\u7AEF</p>
|
|
120
|
+
</div>
|
|
121
|
+
<script>
|
|
122
|
+
// Auto-close after 3 seconds
|
|
123
|
+
setTimeout(() => { window.close(); }, 3000);
|
|
124
|
+
</script>
|
|
125
|
+
</body>
|
|
126
|
+
</html>
|
|
127
|
+
`),o||(o=!0,this.cleanup(),s({ak:u,sk:g}))}else i.writeHead(404,{"Content-Type":"text/plain"}),i.end("Not Found")}),this.server.on("error",n=>{if(n.code==="EADDRINUSE"){if(this.port++,this.port>9390){o||(o=!0,t(new Error("Could not find available port for OAuth callback server")));return}this.server.close(),this.server.listen(this.port)}else o||(o=!0,this.cleanup(),t(n))}),this.server.listen(this.port,()=>{process.env.CODEV_DEBUG&&console.log(`OAuth callback server listening on port ${this.port}`)}),this.timeoutId=setTimeout(()=>{o||(o=!0,this.cleanup(),t(new Error("OAuth login timeout - no response received within 5 minutes")))},this.timeout)})}getCallbackUrl(){return`http://localhost:${this.port}/callback`}cleanup(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.server&&(this.server.close(),this.server=null)}};Z.exports=A});var te=m((Ps,se)=>{var Ke=require("crypto"),We=ee(),O=class{constructor(e={}){this.baseUrl=e.baseUrl||"https://makecoder.com",this.callbackServer=null}generateState(){return Ke.randomBytes(16).toString("hex")}buildAuthorizationUrl(e,s){let t=new URLSearchParams({redirect_uri:e,state:s,response_type:"token"});return`${this.baseUrl}/oauth/authorize?${t.toString()}`}async login(){let e=this.generateState();this.callbackServer=new We;try{let s=this.callbackServer.getCallbackUrl(),t=this.buildAuthorizationUrl(s,e);console.log(`
|
|
128
|
+
\u{1F510} \u5F00\u59CB OAuth \u767B\u5F55\u6D41\u7A0B...
|
|
129
|
+
`),console.log(`\u{1F4CB} \u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u767B\u5F55
|
|
130
|
+
`),console.log(`\u{1F310} \u6388\u6743\u5730\u5740: ${t}
|
|
131
|
+
`),console.log(`\u23F3 \u7B49\u5F85\u60A8\u7684\u6388\u6743...(\u8D85\u65F6\u65F6\u95F4: 5\u5206\u949F)
|
|
132
|
+
`);try{let n=(await import("open")).default;await n(t)}catch(n){console.warn("\u26A0\uFE0F \u65E0\u6CD5\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668,\u8BF7\u624B\u52A8\u590D\u5236\u4E0A\u8FF0\u94FE\u63A5\u5230\u6D4F\u89C8\u5668\u6253\u5F00"),process.env.CODEV_DEBUG&&console.error("Browser open error:",n)}let o=await this.callbackServer.waitForCallback(e);return console.log(`\u2705 API Key \u83B7\u53D6\u6210\u529F!
|
|
133
|
+
`),o}catch(s){throw console.error(`
|
|
134
|
+
\u274C OAuth \u767B\u5F55\u5931\u8D25: ${s.message}
|
|
135
|
+
`),s}finally{this.callbackServer&&this.callbackServer.cleanup()}}cleanup(){this.callbackServer&&this.callbackServer.cleanup()}};se.exports=O});var re=m((ks,ne)=>{var w=require("fs"),oe=require("path"),je=require("os"),ze=require("readline"),Qe=te(),F=class{constructor(){this.configPath=oe.join(je.homedir(),".coder","config.json"),this.defaultConfig={agent:"claude",auth:{ak:null,sk:null}}}async promptForAKSK(){let e=ze.createInterface({input:process.stdin,output:process.stdout});return new Promise((s,t)=>{console.log(`
|
|
136
|
+
\u{1F510} \u8BF7\u8F93\u5165\u60A8\u7684 API Key\uFF1A`),e.question("\u8BF7\u8F93\u5165 API Key: ",o=>{let n=o.indexOf(".");if(n===-1||n===0||n===o.length-1){e.close(),t(new Error("\u683C\u5F0F\u9519\u8BEF"));return}let i=o.substring(0,n),a=o.substring(n+1);if(!i.trim()||!a.trim()){e.close(),t(new Error("\u683C\u5F0F\u9519\u8BEF"));return}e.close(),s({ak:i.trim(),sk:a.trim()})})})}ensureConfig(){let e=oe.dirname(this.configPath);try{w.existsSync(e)||w.mkdirSync(e,{recursive:!0}),w.existsSync(this.configPath)||w.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2))}catch(s){return console.warn(`Warning: Could not create config file: ${s.message}`),this.defaultConfig}}loadConfig(){this.ensureConfig();try{let e=w.readFileSync(this.configPath,"utf8");return JSON.parse(e)}catch(e){return console.warn(`Warning: Could not load config, using defaults: ${e.message}`),this.defaultConfig}}async parse(e=process.argv.slice(2)){let s=this.loadConfig(),t={agent:s.agent||"claude",remainingArgs:[]},o=0,n=!1;for(e.length>0&&["claude","gemini","codex"].includes(e[0])?(t.agent=e[0],n=!0,o=1):e.length>0&&e[0]==="pub"&&(t.command="pub",o=1);o<e.length;){let r=e[o];if(r==="--agent"){if(n)throw new Error(`Cannot use both subcommand '${t.agent}' and --agent flag. Please use only one method to specify the agent.`);if(o+1>=e.length)throw new Error("--agent requires a value (claude, gemini, or codex)");let c=e[o+1];if(!["claude","gemini","codex"].includes(c))throw new Error(`Invalid agent: ${c}. Must be 'claude', 'gemini', or 'codex'`);t.agent=c,o+=2}else if(r==="--apikey"||r==="--aksk")if(o+1>=e.length||e[o+1].startsWith("--"))t.needAKSKPrompt=!0,o+=1;else{let c=e[o+1],h=c.indexOf(".");if(h===-1)throw new Error("API Key Format error");t.auth_ak=c.substring(0,h),t.auth_sk=c.substring(h+1),o+=2}else if(r==="--save-auth")t.saveAuth=!0,o+=1;else if(r==="--name")o+1>=e.length||e[o+1].startsWith("--")?o+=1:(t.pubName=e[o+1],o+=2);else if(r==="--clear-auth")t.clearAuth=!0,o+=1;else if(r==="--allow-clone")t.allowClone=!0,o+=1;else{t.remainingArgs=e.slice(o);break}}if(t.needAKSKPrompt)try{let{ak:r,sk:c}=await this.promptForAKSK();t.auth_ak=r,t.auth_sk=c,delete t.needAKSKPrompt}catch(r){console.error(`\u274C ${r.message}`),process.exit(1)}if(!t.auth_ak&&s.auth&&s.auth.ak&&(t.auth_ak=s.auth.ak),!t.auth_sk&&s.auth&&s.auth.sk&&(t.auth_sk=s.auth.sk),!t.auth_ak&&process.env.CODEV_AUTH_AK&&(t.auth_ak=process.env.CODEV_AUTH_AK),!t.auth_sk&&process.env.CODEV_AUTH_SK&&(t.auth_sk=process.env.CODEV_AUTH_SK),t.saveAuth&&t.auth_ak&&t.auth_sk){let r=this.saveAuthToConfig(t.auth_ak,t.auth_sk);console.log(r?"\u2705 API Key \u5DF2\u4FDD\u5B58\u5230\u914D\u7F6E\u6587\u4EF6":"\u274C \u4FDD\u5B58 API Key \u5931\u8D25"),process.exit(0)}if(t.clearAuth){let r=this.clearAuthFromConfig();console.log(r?"\u2705 API Key \u5DF2\u4ECE\u914D\u7F6E\u6587\u4EF6\u6E05\u9664":"\u274C \u6E05\u9664 API Key \u5931\u8D25"),process.exit(0)}let i=t.remainingArgs.includes("--version")||t.remainingArgs.includes("-v"),a=t.remainingArgs.includes("--help")||t.remainingArgs.includes("-h");if(!i&&!a&&(!t.auth_ak||!t.auth_sk))try{console.log(`\u274C \u7F3A\u5C11\u5FC5\u8981\u7684 API Key
|
|
137
|
+
`),console.log(`\u{1F510} \u6B63\u5728\u542F\u52A8\u767B\u5F55\u6D41\u7A0B...
|
|
138
|
+
`);let c=await new Qe({baseUrl:"https://makecoder.com",apiBaseUrl:t.codevServer||"https://makecoder.com/bigapis/codev/v1"}).login();t.auth_ak=c.ak,t.auth_sk=c.sk;let h=this.saveAuthToConfig(c.ak,c.sk);console.log(h?`\u2705 API Key \u5DF2\u81EA\u52A8\u4FDD\u5B58\u5230\u914D\u7F6E\u6587\u4EF6
|
|
139
|
+
`:`\u26A0\uFE0F API Key \u83B7\u53D6\u6210\u529F\u4F46\u672A\u80FD\u4FDD\u5B58\u5230\u914D\u7F6E\u6587\u4EF6,\u4E0B\u6B21\u4F7F\u7528\u9700\u8981\u91CD\u65B0\u767B\u5F55
|
|
140
|
+
`)}catch(r){console.error(`
|
|
141
|
+
\u274C \u767B\u5F55\u5931\u8D25: ${r.message}
|
|
142
|
+
`),console.error(`\u{1F4CB} \u60A8\u4E5F\u53EF\u4EE5\u624B\u52A8\u83B7\u53D6 API Key\uFF1A
|
|
143
|
+
\u8BF7\u8BBF\u95EE\uFF1Ahttps://makecoder.com/my/apikeys
|
|
144
|
+
|
|
145
|
+
\u{1F680} \u624B\u52A8\u4F7F\u7528\u65B9\u5F0F\uFF1A
|
|
146
|
+
coder --apikey <\u4F60\u7684API Key>
|
|
147
|
+
\u6216\u8005\uFF1Acoder --apikey \uFF08\u7136\u540E\u5B89\u5168\u8F93\u5165\uFF09
|
|
148
|
+
`),process.exit(1)}return process.env.CODEV_SERVER?t.codevServer=process.env.CODEV_SERVER:s.codevServer?t.codevServer=s.codevServer:t.codevServer="https://makecoder.com/bigapis/codev/v1",t}saveAuthToConfig(e,s){let t=this.loadConfig();t.auth||(t.auth={}),t.auth.ak=e,t.auth.sk=s;try{return w.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch(o){return console.warn(`Warning: Could not save auth to config: ${o.message}`),!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth&&(e.auth.ak=null,e.auth.sk=null);try{return w.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch(s){return console.warn(`Warning: Could not clear auth from config: ${s.message}`),!1}}showHelp(){console.log(`
|
|
149
|
+
Coder AI Agent
|
|
150
|
+
|
|
151
|
+
USAGE:
|
|
152
|
+
coder [--agent <agent>] [agent-args...]
|
|
153
|
+
coder <agent> [agent-args...]
|
|
154
|
+
coder pub [--name <name>]
|
|
155
|
+
|
|
156
|
+
AGENTS:
|
|
157
|
+
claude Use Claude Code (default)
|
|
158
|
+
gemini Use Gemini CLI
|
|
159
|
+
codex Use OpenAI Codex CLI
|
|
160
|
+
|
|
161
|
+
COMMANDS:
|
|
162
|
+
pub Publish current directory to hosting server
|
|
163
|
+
|
|
164
|
+
EXAMPLES:
|
|
165
|
+
coder claude # Launch Claude agent
|
|
166
|
+
coder gemini # Launch Gemini agent
|
|
167
|
+
coder codex --help # Launch Codex agent
|
|
168
|
+
coder --agent claude # Alternative syntax
|
|
169
|
+
coder pub --name myproject # Publish current directory as 'myproject'
|
|
170
|
+
coder pub # Publish (will prompt for name)
|
|
171
|
+
|
|
172
|
+
OPTIONS:
|
|
173
|
+
--agent <agent> Specify which agent to use (claude|gemini|codex)
|
|
174
|
+
--version Show version
|
|
175
|
+
--help Show this help message
|
|
176
|
+
--apikey [API Key] \u63D0\u4F9B API Key \u6216\u4F7F\u7528 --apikey \u4EA4\u4E92\u5F0F\u5B89\u5168\u8F93\u5165
|
|
177
|
+
(\u83B7\u53D6\u5730\u5740: https://makecoder.com/my/apikeys)
|
|
178
|
+
--save-auth Save provided API Key to config file ~/.coder/config.json
|
|
179
|
+
--clear-auth Clear saved API Key from config file
|
|
180
|
+
--name <name> (pub command) Project name for publishing
|
|
181
|
+
--allow-clone (pub command) Include Claude Code generation history for cloning
|
|
182
|
+
|
|
183
|
+
CONFIG:
|
|
184
|
+
Default configuration is stored in ~/.coder/config.json
|
|
185
|
+
Command line --agent overrides the default but doesn't modify the file.
|
|
186
|
+
Auth credentials can be stored in config file under "auth" section.
|
|
187
|
+
`)}};ne.exports=F});var T=m((Ts,ae)=>{var{spawn:Je}=require("child_process"),D=require("path"),C=require("fs"),ie=require("os"),M=class{constructor(e){this.config=e}resloveSettingFilePath(e){return D.join(e,this.config.configDir,"settings.json")}readModelFromSettingsFile(e){try{let s=this.resloveSettingFilePath(e);if(C.existsSync(s)){let t=C.readFileSync(s,"utf8"),o=JSON.parse(t);if(o&&o.model)return o.model}}catch(s){console.warn(e,s.message)}return null}getCurrentModel(e){let s=e.findIndex(o=>o==="--model");if(s!==-1&&s+1<e.length)return e[s+1];let t=this.readModelFromSettingsFile(process.cwd());return t||(t=this.readModelFromSettingsFile(ie.homedir()),t)?t:this.config.defaultModel}async ensureConfig(e=0){let s=D.join(ie.homedir(),this.config.configDir,this.config.configFile),t=D.dirname(s);if(!C.existsSync(s)){let o=this.config.defaultConfig||{};try{C.existsSync(t)||C.mkdirSync(t,{recursive:!0}),C.writeFileSync(s,JSON.stringify(o,null,2)),e>0&&await new Promise(n=>setTimeout(n,e))}catch(n){console.warn(`Failed to create ${this.config.configFile}: ${n.message}`)}}}findExecutablePath(){let e=D.dirname(require.main.filename);for(let s of this.config.executablePaths){let t=D.resolve(e,s);if(C.existsSync(t))return t}throw new Error(`Could not find executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}handleChildMessages(e){process.env.CODEV_DEBUG&&console.log("Child process message handler initialized"),e.connected&&(e.on("message",s=>{this.onChildMessage(s)}),e.on("exit",async(s,t)=>{try{await this.handleChildProcessExit(s,t)}catch(o){console.error("Error in handleChildProcessExit:",o.message)}}),e.on("error",s=>{this.handleChildProcessError(s)}))}onChildMessage(e){process.env.CODEV_DEBUG&&console.log("Received IPC message from child:",e)}handleChildProcessExit(e,s){}handleChildProcessError(e){}async launch(e={}){let{remainingArgs:s=[],codevServer:t,auth_ak:o=null,auth_sk:n=null}=e;try{let i=this.getCurrentModel(s);console.log(`model:\x1B[90m\x1B[3m ${i} (use /model to switch models) \x1B[0m`),await this.ensureConfig(1e3);let a=this.findExecutablePath();return process.env.CODEV_DEBUG&&console.log(`executablePath: ${a}`),new Promise((r,c)=>{let h={...process.env,...this.config.environmentVariables(t)};o&&(h.CODEV_AUTH_AK=o),n&&(h.CODEV_AUTH_SK=n);let u=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&u.push("--inspect-brk"),u.push(a,...s);let g=Je("node",u,{env:h,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(g),g.on("error",S=>{console.error(`Failed to start: ${S.message}`),c(S)}),g.on("exit",async(S,Y)=>{console.log(Y?`terminated by signal: ${Y}`:"Goodbye for now! Keep building great things!")}),process.on("SIGINT",async()=>{console.log(`
|
|
188
|
+
Terminating ...`),g.kill("SIGTERM"),setTimeout(()=>{g.killed||g.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
|
|
189
|
+
Terminating ...`),g.kill("SIGTERM"),setTimeout(()=>{g.killed||g.kill("SIGKILL")},8e3)})})}catch(i){throw i}}};ae.exports=M});var le=m(($s,ce)=>{var d=process.env.CODEV_DEBUG==="True",q=class{constructor(e={}){this.queue=[],this.processing=!1,this.shuttingDown=!1,this.shutdownTimeout=e.shutdownTimeout||5e3,this.maxRetries=e.maxRetries||3,this.retryDelay=e.retryDelay||1e3,this.onProcessMessage=e.onProcessMessage||null,this.shutdownPromise=null,this.currentlyProcessing=null}enqueue(e){if(this.shuttingDown)return d&&console.log("Queue is shutting down, skipping new messages"),null;let s={id:Date.now()+Math.random(),data:e,timestamp:Date.now(),retryCount:0,processing:!1};return this.queue.push(s),d&&console.log(`Message enqueued, queue length: ${this.queue.length}`),this.processQueue(),s.id}dequeue(){let e=this.queue.shift();return d&&e&&console.log(`Message dequeued, remaining queue length: ${this.queue.length}`),e}removeById(e){let s=this.queue.findIndex(t=>t.id===e);return s>-1?(this.queue.splice(s,1),d&&console.log(`Message ${e} removed from queue`),!0):!1}async processQueue(){if(!(this.processing||this.queue.length===0)){this.processing=!0;try{for(;this.queue.length>0&&!this.shuttingDown;){let e=this.queue[0];e.processing=!0;try{this.onProcessMessage&&await this.onProcessMessage(e),this.dequeue()}catch(s){if(d&&console.error(`Failed to process message: ${s.message}`),e.retryCount++,d&&console.log("Start Retry:",e.retryCount,"times..."),e.retryCount>=this.maxRetries)d&&console.error("Message exceeded max retries, removing from queue"),this.dequeue();else{e.processing=!1;let t=this.shuttingDown?100:this.retryDelay*e.retryCount;await new Promise(o=>setTimeout(o,t))}}}}finally{this.processing=!1}}}getQueueSize(){return this.queue.length}clear(){this.queue=[],d&&console.log("Message queue cleared")}setMessageProcessor(e){this.onProcessMessage=e}async waitForProcessingMessages(e=5e3){let s=this.queue.filter(o=>o.processing);if(s.length===0)return;d&&console.log(`Waiting for ${s.length} processing messages to complete (timeout: ${e}ms)`);let t=Date.now();for(;Date.now()-t<e;){if(this.queue.filter(n=>n.processing).length===0){d&&console.log(`All processing messages completed in ${Date.now()-t}ms`);return}await new Promise(n=>setTimeout(n,50))}if(d){let o=this.queue.filter(n=>n.processing);console.log(`Timeout waiting for processing messages. ${o.length} messages still processing`)}}async gracefulShutdown(e={}){if(this.shutdownPromise)return this.shutdownPromise;let{timeoutMs:s=this.shutdownTimeout,batchSize:t=10,fastMode:o=!1}=e;return this.shutdownPromise=new Promise(async n=>{this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(s*.3,3e3));let i=this.queue.filter(S=>!S.processing),a=i.length;d&&(console.log(`Starting graceful shutdown with ${a} pending messages (${this.queue.length-a} already processing)`),console.log(`Mode: ${o?"fast (parallel)":"sequential"}, timeout: ${s}ms`));let r=Date.now(),c=0,h=0;try{if(o){let S=await this.processAllParallel(s-(Date.now()-r),i);c=S.processed,h=S.failed}else{let S=await this.processInBatches(t,s-(Date.now()-r),i);c=S.processed,h=S.failed}}catch(S){d&&console.error("Error during shutdown processing:",S.message)}let u=Date.now()-r,g=this.queue.length;d&&(console.log(`Shutdown completed in ${u}ms:`),console.log(` - Total: ${a} messages`),console.log(` - Processed: ${c}`),console.log(` - Failed: ${h}`),console.log(` - Remaining: ${g}`)),n({totalMessages:a,processedMessages:c,failedMessages:h,remainingMessages:g,duration:u,allMessagesSent:g===0&&h===0})}),this.shutdownPromise}async processAllParallel(e){if(this.queue.length===0)return{processed:0,failed:0};d&&console.log(`Processing ${this.queue.length} messages in parallel...`);let s=[...this.queue];this.queue=[];let t=s.map(async r=>{try{return this.onProcessMessage&&await this.onProcessMessage(r),{success:!0,messageId:r.id}}catch(c){return d&&console.warn(`Message ${r.id} processing failed: ${c.message}`),{success:!1,messageId:r.id,error:c}}}),o=new Promise(r=>{setTimeout(()=>r({timedOut:!0}),e)}),n=await Promise.race([Promise.allSettled(t).then(r=>({results:r})),o]);if(n.timedOut)return d&&console.log(`Parallel processing timed out after ${e}ms`),{processed:0,failed:s.length};let i=n.results.filter(r=>r.status==="fulfilled"&&r.value?.success).length,a=s.length-i;return{processed:i,failed:a}}async processInBatches(e,s){if(this.queue.length===0)return{processed:0,failed:0};d&&console.log(`Processing ${this.queue.length} messages in batches of ${e}...`);let t=Date.now(),o=0,n=0;for(;this.queue.length>0&&Date.now()-t<s;){let i=this.queue.splice(0,e),a=i.map(async u=>{try{return this.onProcessMessage&&await this.onProcessMessage(u),{success:!0}}catch(g){return d&&console.warn(`Batch message processing failed: ${g.message}`),{success:!1,error:g}}}),c=(await Promise.allSettled(a)).filter(u=>u.status==="fulfilled"&&u.value?.success).length,h=i.length-c;o+=c,n+=h,d&&i.length>0&&console.log(`Batch completed: ${c}/${i.length} successful`),this.queue.length>0&&await new Promise(u=>setTimeout(u,10))}return this.queue.length>0&&(n+=this.queue.length,d&&console.log(`${this.queue.length} messages not processed due to timeout`),this.queue=[]),{processed:o,failed:n}}async forceFlushAndShutdown(e=2e3){this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(e*.4,1e3));let s=this.queue.filter(r=>!r.processing);d&&console.log(`Force flush: attempting to send ${s.length} pending messages within ${e}ms (${this.queue.length-s.length} already processing)`);let t=Date.now(),o=s.map(async r=>{try{return this.onProcessMessage&&Date.now()-t<e?(await this.onProcessMessage(r),{success:!0,messageId:r.id}):{success:!1,messageId:r.id,reason:"timeout"}}catch(c){return{success:!1,messageId:r.id,error:c.message}}}),n=e-(Date.now()-t),i=new Promise(r=>{setTimeout(()=>r({timedOut:!0}),Math.max(100,n))}),a=await Promise.race([Promise.allSettled(o).then(r=>({results:r})),i]);if(s.forEach(r=>{let c=this.queue.findIndex(h=>h.id===r.id);c>-1&&this.queue.splice(c,1)}),this.processing=!1,a.timedOut)return d&&console.log(`Force flush timed out after ${e}ms`),{success:!1,reason:"timeout",attemptedCount:s.length};{let r=a.results.filter(c=>c.status==="fulfilled"&&c.value.success).length;return d&&console.log(`Force flush completed: ${r}/${s.length} messages sent`),{success:r===s.length,successCount:r,totalCount:s.length,results:a.results}}}forceShutdown(){this.shuttingDown=!0,this.queue=[],this.processing=!1,d&&console.log("Force shutdown: Queue cleared")}};ce.exports=q});var U=m((As,Ye)=>{Ye.exports={name:"makecoder",version:"1.0.25",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","agent"],author:"makecoder",license:"MIT",dependencies:{zod:"^3.25.76",open:"^10.1.0","node-fetch":"^3.3.2"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","claude","scripts/postinstall.js"]}});var ge=m((Os,de)=>{var Xe=require("http"),Ze=require("https"),{URL:he}=require("url"),{version:es}=U(),ue=process.env.CODEV_DEBUG==="True",B=class{constructor(e={}){this.baseUrl=e.baseUrl||"",this.timeout=e.timeout||3e4,this.defaultHeaders={"Content-Type":"application/json","User-Agent":`codev-cli/${es}`,...e.headers}}setBaseUrl(e){this.baseUrl=e}setDefaultHeaders(e){this.defaultHeaders={...this.defaultHeaders,...e}}async post(e,s,t={}){let o=this.resolveUrl(e),n={...this.defaultHeaders,...t.headers};return new Promise((i,a)=>{this.validateRequest(o,s,a);let r=this.serializeData(s,a);if(!r)return;n["Content-Length"]=Buffer.byteLength(r);let c=this.buildRequestOptions(o,"POST",n),h=this.getHttpModule(o);ue&&console.debug(`HTTP POST to ${o} with data length: ${r.length}`);let u=h.request(c,g=>{this.handleResponse(g,i,a)});this.attachErrorHandlers(u,o,a),u.setTimeout(this.timeout),u.write(r),u.end()})}resolveUrl(e){return e.startsWith("http")?e:`${this.baseUrl}${e.startsWith("/")?"":"/"}${e}`}validateRequest(e,s,t){return!e||typeof e!="string"?(t(new Error(`Invalid URL: ${e}`)),!1):s?!0:(t(new Error("No data provided for HTTP POST")),!1)}serializeData(e,s){try{return typeof e=="string"?e:JSON.stringify(e)}catch(t){return s(new Error(`Failed to serialize data: ${t.message}`)),null}}buildRequestOptions(e,s,t){let o=new he(e),n=o.protocol==="https:";return{hostname:o.hostname,port:o.port||(n?443:80),path:o.pathname+o.search,method:s,headers:t}}getHttpModule(e){return new he(e).protocol==="https:"?Ze:Xe}handleResponse(e,s,t){ue&&console.debug(`HTTP response status: ${e.statusCode}`);let o="";e.on("data",n=>{o+=n}),e.on("end",()=>{e.statusCode>=200&&e.statusCode<300?s({statusCode:e.statusCode,data:o,headers:e.headers}):t(new Error(`HTTP request returned status ${e.statusCode}: ${o}`))})}attachErrorHandlers(e,s,t){e.on("error",o=>{t(new Error(`HTTP POST request failed: ${o.message}`))}),e.on("timeout",()=>{t(new Error(`HTTP POST request timed out for URL: ${s}`)),e.destroy()})}};de.exports=B});var me=m((Fs,fe)=>{var ss=require("crypto"),{URL:ts}=require("url"),V=class{static generateSignature(e,s,t,o){try{let n=new ts(e),i=Buffer.from(n.pathname),a=Buffer.from(i),r=s?typeof s=="string"?Buffer.from(s):Buffer.from(JSON.stringify(s)):Buffer.alloc(0),c=Buffer.concat([a,r,Buffer.from(o)]),h=ss.createHmac("sha256",t);return h.update(c),h.digest("hex")}catch(n){throw new Error(`Failed to generate signature: ${n.message}`)}}static validateSignature(e,s,t,o,n){return this.generateSignature(e,s,t,o)===n}static generateTimestamp(){return Date.now().toString()}};fe.exports=V});var Se=m((Ms,pe)=>{var os=me(),G=class{constructor(e={}){this.accessKey=null,this.secretKey=null,this.validateCredentials=e.validateCredentials!==!1}setCredentials(e,s){if(this.validateCredentials&&(!e||!s))throw new Error("Both access key and secret key are required");this.accessKey=e,this.secretKey=s}hasCredentials(){return!!(this.accessKey&&this.secretKey)}generateAuthHeaders(e,s=null){if(!this.hasCredentials())return{};try{return{AUTHORIZATION:`Bearer ${this.accessKey}.${this.secretKey}`}}catch(t){throw new Error(`Failed to generate auth headers: ${t.message}`)}}validateAuthHeaders(e,s,t,o){if(!this.hasCredentials())throw new Error("No credentials available for validation");return os.validateSignature(e,s,this.secretKey,t,o)}clearCredentials(){this.accessKey=null,this.secretKey=null}getCredentials(){return{accessKey:this.accessKey,hasCredentials:this.hasCredentials()}}};pe.exports=G});var we=m((qs,ye)=>{var _=process.env.CODEV_DEBUG==="True",N=class{constructor(e={}){this.currentSessionId=null,this.previousSessionId=null,this.onSessionSwitch=e.onSessionSwitch||null,this.terminateSignal=e.terminateSignal||"CODEV_TERMINATE_SIGNAL"}handleSessionSwitch(e){if(!e)return _&&console.warn("Received empty session ID"),!1;let s=this.previousSessionId!==null&&this.previousSessionId!==e;return s&&(_&&console.log(`Session switch detected: ${this.previousSessionId} -> ${e}`),this.onSessionSwitch&&this.onSessionSwitch({type:this.terminateSignal,reason:"User switch session",agent:"claude",previousSessionId:this.previousSessionId,newSessionId:e})),this.previousSessionId=this.currentSessionId,this.currentSessionId=e,s}getCurrentSessionId(){return this.currentSessionId}getPreviousSessionId(){return this.previousSessionId}hasActiveSession(){return!!this.currentSessionId}terminateCurrentSession(e="Session terminated",s=null,t=null){if(!this.hasActiveSession())return _&&console.log("No active session to terminate"),null;let o={type:this.terminateSignal,reason:t?`terminated by signal: ${t}`:e,code:s,signal:t,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId};return _&&console.log("Terminating session:",o),this.previousSessionId=null,this.currentSessionId=null,o}createErrorTermination(e){return this.hasActiveSession()?{type:this.terminateSignal,error:e.message,stack:e.stack,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId}:null}reset(){_&&console.log("Resetting session manager"),this.currentSessionId=null,this.previousSessionId=null}setSessionSwitchCallback(e){this.onSessionSwitch=e}getSessionInfo(){return{currentSessionId:this.currentSessionId,previousSessionId:this.previousSessionId,hasActiveSession:this.hasActiveSession()}}};ye.exports=N});var ve=m((Us,Ce)=>{var v=require("fs"),E=require("path"),ns=require("events"),rs=require("crypto"),p=process.env.CODEV_DEBUG==="True",R=class extends ns{constructor(e={}){super(),this.watchPaths=e.watchPaths||[],this.excludePatterns=e.excludePatterns||[/node_modules/,/\.git/,/\.DS_Store/,/\.tmp/,/\.log$/,/\.swp$/,/codev\.log/],this.includePatterns=e.includePatterns||[/\.(js|jsx|ts|tsx|py|java|c|cpp|h|hpp|go|rs|rb|php|html|css|scss|sass|less|json|xml|yaml|yml|md|txt)$/],this.watchers=new Map,this.isWatching=!1,this.debounceTimeout=e.debounceTimeout||300,this.pendingChanges=new Map,this.fileContentHashes=new Map,this.enableContentComparison=e.enableContentComparison!==!1,this.onFileChange=e.onFileChange||null}calculateFileHash(e){try{let s=v.readFileSync(e,"utf8");return rs.createHash("sha256").update(s).digest("hex")}catch{return null}}hasContentChanged(e){if(!this.enableContentComparison)return!0;let s=this.calculateFileHash(e),t=this.fileContentHashes.get(e);return s===null?t!==void 0?(this.fileContentHashes.delete(e),!0):!1:t===void 0||s!==t?(this.fileContentHashes.set(e,s),!0):!1}preloadFileHashes(e){if(!(!this.enableContentComparison||!v.existsSync(e)))try{let s=v.readdirSync(e,{withFileTypes:!0});for(let t of s){let o=E.join(e,t.name);t.isFile()&&this.shouldWatchFile(o)?(this.calculateFileHash(o),this.fileContentHashes.set(o,this.calculateFileHash(o))):t.isDirectory()&&!this.shouldExcludeDirectory(o)&&this.preloadFileHashes(o)}}catch(s){p&&console.warn(`Failed to preload hashes for ${e}:`,s.message)}}shouldExcludeDirectory(e){let s=e.replace(/\\/g,"/");for(let t of this.excludePatterns)if(t.test(s)||t.test(E.basename(e)))return!0;return!1}startWatching(e=null){if(this.isWatching){p&&console.log("FileWatchService is already watching");return}let s=e||this.watchPaths;if(s.length===0){p&&console.log("No watch paths specified");return}this.isWatching=!0;for(let t of s)this.enableContentComparison&&this.preloadFileHashes(t),this.watchDirectory(t);p&&(console.log(`FileWatchService started watching ${s.length} paths`),this.enableContentComparison&&console.log(`Preloaded hashes for ${this.fileContentHashes.size} files`))}stopWatching(){if(this.isWatching){this.isWatching=!1;for(let[e,s]of this.watchers)try{s.close(),p&&console.log(`Stopped watching: ${e}`)}catch(t){p&&console.error(`Error stopping watcher for ${e}:`,t.message)}this.watchers.clear(),this.pendingChanges.clear(),this.fileContentHashes.clear(),p&&console.log("FileWatchService stopped watching all paths")}}watchDirectory(e){if(!v.existsSync(e)){p&&console.warn(`Watch path does not exist: ${e}`);return}if(!v.statSync(e).isDirectory()){p&&console.warn(`Watch path is not a directory: ${e}`);return}try{let t=v.watch(e,{recursive:!0,persistent:!1},(o,n)=>{if(!n)return;let i=E.join(e,n);this.handleFileChange(o,i,e)});this.watchers.set(e,t),p&&console.log(`Started watching directory: ${e}`),t.on("error",o=>{p&&console.error(`Watcher error for ${e}:`,o.message),this.watchers.delete(e)})}catch(t){p&&console.error(`Failed to start watching ${e}:`,t.message)}}handleFileChange(e,s,t){if(!this.shouldWatchFile(s))return;let o=`${e}:${s}`;this.pendingChanges.has(o)&&clearTimeout(this.pendingChanges.get(o)),this.pendingChanges.set(o,setTimeout(()=>{this.pendingChanges.delete(o),this.processFileChange(e,s,t)},this.debounceTimeout))}processFileChange(e,s,t){if(!this.isWatching)return;let o="modified",n=!1;try{v.statSync(s),n=!0,e==="rename"?o="created":e==="change"&&(o="modified")}catch{e==="rename"&&(o="deleted")}if(n&&(o==="modified"||o==="created")&&!this.hasContentChanged(s)){p&&console.log(`Ignoring false change for: ${E.relative(t,s)}`);return}!n&&o==="deleted"&&this.fileContentHashes.delete(s);let i={type:"CODEV_FILE_CHANGE_DETECTTED",data:{eventType:e,changeType:o,filePath:s,relativePath:E.relative(t,s),watchPath:t,fileExists:n,timestamp:Date.now(),sessionId:process.env.SESSION_ID||"default"}};if(p&&console.log(`File ${o}: ${i.data.relativePath}`),this.emit("fileChange",i),this.onFileChange&&typeof this.onFileChange=="function")try{this.onFileChange(i)}catch(a){p&&console.error("Error in file change callback:",a.message)}}shouldWatchFile(e){let s=E.basename(e),t=e.replace(/\\/g,"/");for(let o of this.excludePatterns)if(o.test(t)||o.test(s))return!1;if(this.includePatterns.length===0)return!0;for(let o of this.includePatterns)if(o.test(t)||o.test(s))return!0;return!1}addWatchPath(e){this.watchPaths.includes(e)||(this.watchPaths.push(e),this.isWatching&&this.watchDirectory(e))}removeWatchPath(e){let s=this.watchPaths.indexOf(e);if(s>-1&&(this.watchPaths.splice(s,1),this.watchers.has(e)))try{this.watchers.get(e).close(),this.watchers.delete(e),p&&console.log(`Removed watch path: ${e}`)}catch(t){p&&console.error(`Error removing watch path ${e}:`,t.message)}}getStatus(){return{isWatching:this.isWatching,watchPaths:[...this.watchPaths],activeWatchers:this.watchers.size,pendingChanges:this.pendingChanges.size}}setFileChangeCallback(e){this.onFileChange=e}};Ce.exports=R});var xe=m((Bs,Ee)=>{var is=T(),L=require("path"),x=require("fs"),as=require("os"),cs=le(),ls=ge(),hs=Se(),us=we(),ds=ve(),f=process.env.CODEV_DEBUG==="True",H=class extends is{constructor(){super({configDir:".",configFile:".claude.json",defaultModel:"Claude Sonnet 4.5",executablePaths:["cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"codev",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:e}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}}),this.fileWatchService=null,this.shutdownInProgress=!1,this.initializeServices()}initializeServices(){this.httpClient=new ls({timeout:1e4}),this.authService=new hs({validateCredentials:!1}),this.sessionManager=new us({onSessionSwitch:e=>{this.sendTerminationMessage(e)}}),this.messageQueue=new cs({maxRetries:2,retryDelay:500,shutdownTimeout:3e3,onProcessMessage:e=>this.processMessage(e)}),this.initializeFileWatchService()}resloveSettingFilePath(e){return L.join(e,this.config.configDir,".claude","settings.json")}initializeFileWatchService(){if(!process.env.SESSION_ID){f&&console.log("FileWatchService disabled: SESSION_ID environment variable not found");return}try{this.fileWatchService=new ds({watchPaths:this.getFileWatchPaths(),onFileChange:e=>this.handleFileChange(e),debounceTimeout:300}),f&&console.log("FileWatchService initialized with SESSION_ID:",process.env.SESSION_ID)}catch(e){f&&console.error("Failed to initialize FileWatchService:",e.message)}}getFileWatchPaths(){let e=[],s=process.cwd();e.push(s);let t=process.env.CODEV_WATCH_PATHS;if(t){let o=t.split(",").map(n=>n.trim());e.push(...o)}return e}handleFileChange(e){if(f&&console.log("File change detected:",e.data.relativePath),this.shutdownInProgress)return;let s={message:e,sessionId:e.data.sessionId||process.env.SESSION_ID};this.messageQueue.enqueue(s)}startFileWatching(){this.fileWatchService&&!this.fileWatchService.isWatching&&(this.fileWatchService.startWatching(),f&&console.log("File watching started"))}stopFileWatching(){this.fileWatchService&&this.fileWatchService.isWatching&&(this.fileWatchService.stopWatching(),f&&console.log("File watching stopped"))}onChildMessage(e){e&&e.type==="claude:send-msg"&&this.handleClaudeSendMessage(e.data),super.onChildMessage(e)}handleClaudeSendMessage(e){if(f&&console.log("Handling claude:send-msg message:",e),!e||typeof e!="object"){console.error(`handleClaudeSendMessage: Invalid message data. Expected object, got: ${typeof e}`);return}if(this.shutdownInProgress){f&&console.log("Shutdown in progress, ignoring new message");return}let s=e.sessionId||process.env.SESSION_ID;this.sessionManager.handleSessionSwitch(s),this.messageQueue.enqueue(e)}async processMessage(e){let s=e.data.message,t=e.data.sessionId||process.env.SESSION_ID;if(!t)throw new Error("No session ID available");let o;try{o=typeof s=="string"?JSON.parse(s):s}catch(a){throw new Error(`Failed to parse message data: ${a.message}`)}let n=`/conversations/${t}/@append?task_type=codev`,i=this.authService.hasCredentials()?this.authService.generateAuthHeaders(`${this.httpClient.baseUrl}${n}`,o):{};f&&(console.debug("Sending message to:",n),console.debug("Send Message: ",JSON.stringify(o))),e.type!=="CODEV_TERMINATE_SIGNAL"&&(this.sessionManager.currentSessionId=t)}sendTerminationMessage(e){let s={message:e,sessionId:e.sessionId||this.sessionManager.getCurrentSessionId()};this.messageQueue.enqueue(s)}async handleChildProcessExit(e,s){f&&console.log(`Child process exited with code: ${e}, signal: ${s}`),this.stopFileWatching();let t=this.messageQueue.getQueueSize(),o=this.sessionManager.terminateCurrentSession("process exited normally",e,s);if(o&&this.sendTerminationMessage(o),t>0||o){f&&console.log("Starting graceful shutdown of message queue...");try{let n=!s||s==="SIGTERM",i=this.messageQueue.getQueueSize(),a={timeoutMs:n?8e3:3e3,batchSize:Math.min(i,15),fastMode:!n||i>30};f&&console.log("Shutdown options:",a);let r=await this.messageQueue.gracefulShutdown(a);f&&console.log("Message queue shutdown completed:",r),r.failedMessages>0&&f&&console.warn(`Shutdown summary: ${r.processedMessages} sent, ${r.failedMessages} failed, ${r.remainingMessages} remaining`)}catch(n){f&&console.error("Error during message queue shutdown:",n.message)}}}handleChildProcessError(e){f&&console.error(`Child process error: ${e.message}`);let s=this.sessionManager.createErrorTermination(e);s&&this.sendTerminationMessage(s)}async forceFlushMessages(e=3e3){if(this.messageQueue.getQueueSize()===0)return{success:!0,message:"No messages to flush"};f&&console.log(`Force flushing ${this.messageQueue.getQueueSize()} messages...`);try{return await this.messageQueue.forceFlushAndShutdown(e)}catch(s){return f&&console.error("Force flush failed:",s.message),{success:!1,error:s.message}}}async linkClaudeMarkdown(){let e="/var/app/data/codev/CLAUDE.md",s=as.homedir(),t=L.join(s,".claude"),o=L.join(t,"CLAUDE.md");try{if(!x.existsSync(e))return;x.existsSync(t)||x.mkdirSync(t,{recursive:!0}),x.existsSync(o)&&x.unlinkSync(o),x.symlinkSync(e,o),f&&console.log(`Successfully linked ${e} to ${o}`)}catch(n){f&&console.error(`Failed to link CLAUDE.md file: ${n.message}`)}}async launch(e={}){let{codevServer:s,auth_ak:t=null,auth_sk:o=null}=e;return this.httpClient.setBaseUrl(s),t&&o&&this.authService.setCredentials(t,o),await this.linkClaudeMarkdown(),this.startFileWatching(),super.launch(e)}};Ee.exports=H});var Ie=m((Gs,be)=>{var gs=T(),Vs=require("path"),K=class extends gs{constructor(){super({configDir:".gemini",configFile:"settings.json",defaultModel:"gemini-2.5-pro",executablePaths:["gcli.mjs","../libs/codev-gemini-cli/bundle/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{TelemetrySettings:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}};be.exports=K});var _e=m((Ns,De)=>{var fs=T(),P=require("path"),b=require("fs"),ms=require("os"),{spawn:ps}=require("child_process"),W=process.env.CODEV_DEBUG==="True",j=class extends fs{constructor(){super({configDir:".codex",configFile:"config.toml",defaultModel:"o4-mini",executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:e=>({OPENAI_BASE_URL:`${e}/codex`,OPENAI_API_KEY:"codev-proxy-key",DEBUG:W?"true":"false",CODEX_QUIET_MODE:"0",OPENAI_DISABLE_TELEMETRY:"true",CODEX_DISABLE_PROJECT_DOC:"0",CODEV_SERVER:e}),defaultConfig:{model:"gpt-5-codex",approvalMode:"suggest",fullAutoErrorMode:"ask-user",notify:[],history:{maxSize:1e3,saveHistory:!0,sensitivePatterns:[],persistence:"save-all"}}})}checkCodexAvailability(){try{let e=this.findExecutablePath();return b.existsSync(e)}catch{return!1}}resloveSettingFilePath(e){return P.join(e,this.config.configDir,"config.toml")}async ensureConfig(e=0){let s=P.join(ms.homedir(),this.config.configDir,this.config.configFile),t=P.dirname(s);if(!b.existsSync(s)){let o=this.config.defaultConfig||{};try{b.existsSync(t)||b.mkdirSync(t,{recursive:!0});let n=this.generateTOMLConfig(o);b.writeFileSync(s,n),W&&console.log(`Created Codex config file: ${s}`),e>0&&await new Promise(i=>setTimeout(i,e))}catch(n){console.warn(`Failed to create ${this.config.configFile}: ${n.message}`)}}}generateTOMLConfig(e){return`model = "${e.model||"gpt-5-codex"}"`}findExecutablePath(){let e=P.dirname(require.main.filename);for(let s of this.config.executablePaths){let t=P.resolve(e,s);if(b.existsSync(t))return t}throw new Error(`Could not find Codex executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}async launch(e={}){let{remainingArgs:s=[],codevServer:t,auth_ak:o=null,auth_sk:n=null}=e;try{if(!this.checkCodexAvailability())throw new Error("Codex executable not found. Please ensure the Codex CLI is available in libs/codex/codex-cli/bin/");await this.ensureConfig(1e3);let i=this.findExecutablePath();return W&&console.log(`executablePath: ${i}`),new Promise((a,r)=>{let c={...process.env,...this.config.environmentVariables(t)};o&&(c.CODEV_AUTH_AK=o),n&&(c.CODEV_AUTH_SK=n);let h=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&h.push("--inspect-brk"),h.push(i,...s);let u=ps("node",h,{env:c,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(u),u.on("error",g=>{console.error(`Failed to start Codex: ${g.message}`),r(g)}),u.on("exit",async(g,S)=>{console.log(S?`terminated by signal: ${S}`:"Goodbye for now! Keep building great things!")}),process.on("SIGINT",async()=>{console.log(`
|
|
190
|
+
Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
|
|
191
|
+
Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)})})}catch(i){throw i}}};De.exports=j});var $e=m((Rs,Te)=>{var k=require("fs"),Pe=require("path"),{spawn:ke}=require("child_process"),z=class{constructor(){this.extensionId="codev.codev-background";let e=require.main?Pe.dirname(require.main.filename):__dirname;this.extensionPath=Pe.resolve(e,"vendor/claude-code.vsix"),this._codeCommand=null}async resolveCodeCommand(){if(this._codeCommand)return this._codeCommand;if(process.env.IS_AISTUDIO==="True"){let e="/usr/lib/aistudio/lib/vscode/bin/remote-cli/aistudio";if(k.existsSync(e))try{return k.accessSync(e,k.constants.F_OK|k.constants.X_OK),this._codeCommand=e,process.env.CODEV_DEBUG&&console.log(`Using AI Studio VSCode path: ${e}`),this._codeCommand}catch(s){process.env.CODEV_DEBUG&&console.log(`AI Studio path exists but not executable: ${s.message}`)}else process.env.CODEV_DEBUG&&console.log(`AI Studio path not found: ${e}`)}try{let{spawn:e}=require("child_process");return new Promise(s=>{let t=e("which",["code"],{stdio:"pipe"}),o="";t.stdout.on("data",n=>{o+=n.toString().trim()}),t.on("close",n=>{n===0&&o?(this._codeCommand=o,process.env.CODEV_DEBUG&&console.log(`Resolved code command path: ${o}`),s(this._codeCommand)):(this._codeCommand="code",s(this._codeCommand))}),t.on("error",()=>{this._codeCommand="code",s(this._codeCommand)}),setTimeout(()=>{t.kill(),this._codeCommand="code",s(this._codeCommand)},3e3)})}catch{return this._codeCommand="code",this._codeCommand}}async shouldInstallExtension(){try{return process.env.IS_AISTUDIO!=="True"?(process.env.CODEV_DEBUG&&console.log("Not in AI Studio environment (IS_AISTUDIO!=True), skipping extension installation"),!1):await this.isVSCodeAvailable()?await this.isExtensionInstalled()?(process.env.CODEV_DEBUG&&console.log(`Extension ${this.extensionId} already installed`),!1):k.existsSync(this.extensionPath)?!0:(console.warn(`VSCode extension file not found: ${this.extensionPath}`),!1):(process.env.CODEV_DEBUG&&console.log("VSCode not available, skipping extension installation"),!1)}catch(e){return process.env.CODEV_DEBUG&&console.error(`Error checking extension installation status: ${e.message}`),!1}}async installExtension(){try{return console.log("Installing Codev VSCode extension..."),await this.executeVSCodeCommand(["--install-extension",this.extensionPath])?(console.log("\u2705 Codev VSCode extension installed successfully"),!0):(console.warn("\u274C Failed to install Codev VSCode extension"),!1)}catch(e){return console.warn(`Error installing VSCode extension: ${e.message}`),!1}}async isVSCodeAvailable(){try{let e=process.env.IS_AISTUDIO==="True"?["--help"]:["--version"],s=await this.executeVSCodeCommand(e,{timeout:1e4});if(process.env.CODEV_DEBUG&&(console.log(`VSCode availability check (${e.join(" ")}): ${s?"available":"unavailable"}`),process.env.IS_AISTUDIO==="True")){let{spawn:t}=require("child_process");try{t("which",["code"],{stdio:"pipe"}).stdout.on("data",n=>{console.log("which code:",n.toString().trim())})}catch(o){console.log("which command failed:",o.message)}}return s}catch(e){return process.env.CODEV_DEBUG&&console.error("VSCode availability check error:",e.message),!1}}async isExtensionInstalled(){let e=await this.resolveCodeCommand();try{return new Promise(s=>{try{let t={stdio:["ignore","pipe","ignore"],shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${e} --list-extensions`);let o=ke(e,["--list-extensions"],t),n="";o.stdout.on("data",i=>{n+=i.toString()}),o.on("close",i=>{if(i===0){let a=n.split(`
|
|
192
|
+
`).map(r=>r.trim());s(a.includes(this.extensionId))}else s(!1)}),o.on("error",i=>{process.env.CODEV_DEBUG&&(console.error("VSCode list extensions error:",i.message),console.error("Error code:",i.code),console.error("Error errno:",i.errno),console.error("Error syscall:",i.syscall)),s(!1)}),setTimeout(()=>{try{o.kill()}catch{}s(!1)},1e4)}catch(t){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode list extensions:",t.message),s(!1)}})}catch{return!1}}async executeVSCodeCommand(e,s={}){let t=await this.resolveCodeCommand();return new Promise(o=>{try{let n={stdio:"ignore",shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${t} ${e.join(" ")}`);let i=ke(t,e,n);i.on("close",r=>{o(r===0)}),i.on("error",r=>{process.env.CODEV_DEBUG&&(console.error("VSCode command error:",r.message),console.error("Error code:",r.code),console.error("Error errno:",r.errno),console.error("Error syscall:",r.syscall)),o(!1)});let a=s.timeout||3e4;setTimeout(()=>{try{i.kill()}catch{}o(!1)},a)}catch(n){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode command:",n.message),o(!1)}})}async ensureExtensionInstalled(){try{process.env.CODEV_DEBUG&&console.log("VSCode Extension Service: Checking extension status..."),await this.shouldInstallExtension()&&await this.installExtension()}catch(e){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",e)}}};Te.exports=z});var Fe=m((Ls,Oe)=>{var y=require("fs"),I=require("path"),Ss=require("readline"),{execSync:$}=require("child_process"),Ae=require("os"),Q=class{constructor(){this.serverUrl="https://makecoder.com/bigapis/codev/v1/coderpub"}getClaudeJsonlPath(e){let s=e.replace(/\//g,"-"),t=I.join(Ae.homedir(),".claude","projects",s);if(!y.existsSync(t))return null;try{let o=y.readdirSync(t).filter(n=>n.endsWith(".jsonl")).map(n=>({name:n,path:I.join(t,n),mtime:y.statSync(I.join(t,n)).mtime})).sort((n,i)=>i.mtime-n.mtime);return o.length>0?o[0].path:null}catch{return null}}async promptForName(){let e=Ss.createInterface({input:process.stdin,output:process.stdout});return new Promise((s,t)=>{e.question("\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0 (name): ",o=>{e.close();let n=o.trim();if(!n){t(new Error("\u9879\u76EE\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A"));return}if(!/^[a-zA-Z0-9_-]+$/.test(n)){t(new Error("\u9879\u76EE\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26"));return}s(n)})})}async createZip(e,s={}){let{allowClone:t=!1}=s,o=Ae.tmpdir(),n=`coder-pub-${Date.now()}.zip`,i=I.join(o,n);try{let a=!1;if(y.existsSync(I.join(e,".git")))try{$(`git archive -o "${i}" HEAD`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u4F7F\u7528 git archive \u521B\u5EFA\u538B\u7F29\u5305\uFF08\u5DF2\u6392\u9664 .gitignore \u4E2D\u7684\u6587\u4EF6\uFF09"),a=!0}catch{console.log("\u26A0\uFE0F git archive \u5931\u8D25\uFF0C\u4F7F\u7528\u666E\u901A zip \u547D\u4EE4")}if(!a){let c=[".git/*","node_modules/*",".env",".env.*","*.log",".DS_Store"].map(h=>`-x "${h}"`).join(" ");$(`zip -r "${i}" . ${c}`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u5DF2\u521B\u5EFA\u538B\u7F29\u5305")}if(t){let r=this.getClaudeJsonlPath(e);if(r){let c=I.join(o,"coder.pub.jsonl");y.copyFileSync(r,c),$(`zip -j "${i}" "${c}"`,{stdio:"pipe"}),y.unlinkSync(c),console.log("\u{1F4CB} \u5DF2\u6DFB\u52A0 AI \u751F\u6210\u8BB0\u5F55 (coder.pub.jsonl)")}else console.log("\u26A0\uFE0F \u672A\u627E\u5230 Claude Code \u751F\u6210\u8BB0\u5F55")}return i}catch(a){throw new Error(`\u521B\u5EFA\u538B\u7F29\u5305\u5931\u8D25: ${a.message}`)}}async upload(e,s,t,o,n){let i=n?`${n}/coderpub`:this.serverUrl,a=`${t}.${o}`;console.log("\u{1F4E4} \u6B63\u5728\u4E0A\u4F20\u5230\u670D\u52A1\u5668...");try{let r=`curl -s -X POST "${i}" -H "Authorization: Bearer ${a}" -F "name=${s}" -F "zip_file=@${e}"`,c=$(r,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]});return JSON.parse(c)}catch(r){if(r.stdout)try{return JSON.parse(r.stdout)}catch{throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${r.message}`)}throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${r.message}`)}}cleanup(e){try{y.existsSync(e)&&y.unlinkSync(e)}catch{}}async publish(e){let{ak:s,sk:t,serverBaseUrl:o,allowClone:n}=e,{name:i}=e,a=null;try{i||(i=await this.promptForName()),console.log(`
|
|
193
|
+
\u{1F680} \u6B63\u5728\u53D1\u5E03\u9879\u76EE: ${i}`),console.log(`\u{1F4C1} \u76EE\u5F55: ${process.cwd()}
|
|
194
|
+
`),a=await this.createZip(process.cwd(),{allowClone:n});let c=(y.statSync(a).size/(1024*1024)).toFixed(2);console.log(`\u{1F4CA} \u538B\u7F29\u5305\u5927\u5C0F: ${c} MB`);let h=await this.upload(a,i,s,t,o);return h.code===0?(console.log(`
|
|
195
|
+
\u2705 \u53D1\u5E03\u6210\u529F!`),console.log(`\u{1F4CC} \u7248\u672C: ${h.data.version}`),console.log(`\u{1F310} \u8BBF\u95EE\u5730\u5740: https://${i}.coder.pub/`),0):(console.error(`
|
|
196
|
+
\u274C \u53D1\u5E03\u5931\u8D25: ${h.message||h.reason}`),1)}catch(r){return console.error(`
|
|
197
|
+
\u274C ${r.message}`),1}finally{a&&this.cleanup(a)}}};Oe.exports=Q});var qe=m((Hs,Me)=>{var ys=re(),ws=xe(),Cs=Ie(),vs=_e(),Es=$e(),xs=Fe(),J=class{constructor(){this.argParser=new ys,this.claudeLauncher=new ws,this.geminiLauncher=new Cs,this.codexLauncher=new vs,this.vscodeExtensionService=new Es,this.publishService=new xs}async run(e=process.argv.slice(2)){try{try{await this.vscodeExtensionService.ensureExtensionInstalled()}catch(t){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",t)}if(!e.includes("--agent")&&!e.includes("-a")){let t=e.length>0&&["claude","gemini","codex"].includes(e[0]);if(!t&&(e.includes("--help")||e.includes("-h")))return this.argParser.showHelp(),0;if(!t&&(e.includes("--version")||e.includes("-v")))return this.showVersion(),0}let s=await this.argParser.parse(e);return s.command==="pub"?await this.publishService.publish({name:s.pubName,ak:s.auth_ak,sk:s.auth_sk,serverBaseUrl:s.codevServer,allowClone:s.allowClone}):await this.launchAgent(s)}catch(s){return console.error(`Error: ${s.message}`),process.env.CODEV_DEBUG&&console.error("Stack trace:",s.stack),1}}async launchAgent(e){let{agent:s}=e;return console.log(`cwd:\x1B[90m\x1B[3m ${process.cwd()} \x1B[0m`),s==="claude"?await this.claudeLauncher.launch(e):s==="gemini"?await this.geminiLauncher.launch(e):s==="codex"?await this.codexLauncher.launch(e):1}showVersion(){let e=U();console.log(`coder version: ${e.version}`)}async shutdown(){console.log(`
|
|
198
|
+
Shutting down...`),process.exit(0)}};Me.exports=J});var bs=qe();process.on("unhandledRejection",(l,e)=>{console.error("Unhandled Promise Rejection:",l),process.exit(1)});process.on("uncaughtException",l=>{console.error("Uncaught Exception:",l.message),process.env.CODEV_DEBUG&&console.error(l.stack),process.exit(1)});async function Is(){console.log(`Welcome to Coder!
|
|
199
|
+
`);let l=new bs;process.on("SIGINT",async()=>{console.log(`
|
|
200
|
+
Received SIGINT, shutting down gracefully...`),await l.shutdown()}),process.on("SIGTERM",async()=>{console.log(`
|
|
201
|
+
Received SIGTERM, shutting down gracefully...`),await l.shutdown()});try{let e=await l.run();process.exit(e)}catch(e){console.error(`Fatal error: ${e.message}`),process.env.CODEV_DEBUG&&console.error(e.stack),process.exit(1)}}Is().catch(l=>{console.error(`Startup error: ${l.message}`),process.exit(1)});
|
package/dist/codex
ADDED
|
Binary file
|
package/dist/codex.exe
ADDED
|
Binary file
|
package/dist/codex.mjs
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the Codex CLI.
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
// __dirname equivalent in ESM
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const { platform, arch } = process;
|
|
12
|
+
|
|
13
|
+
let targetTriple = null;
|
|
14
|
+
switch (platform) {
|
|
15
|
+
case "linux":
|
|
16
|
+
case "android":
|
|
17
|
+
switch (arch) {
|
|
18
|
+
case "x64":
|
|
19
|
+
targetTriple = "x86_64-unknown-linux-musl";
|
|
20
|
+
break;
|
|
21
|
+
case "arm64":
|
|
22
|
+
targetTriple = "aarch64-unknown-linux-musl";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "darwin":
|
|
29
|
+
switch (arch) {
|
|
30
|
+
case "x64":
|
|
31
|
+
targetTriple = "x86_64-apple-darwin";
|
|
32
|
+
break;
|
|
33
|
+
case "arm64":
|
|
34
|
+
//targetTriple = "aarch64-apple-darwin";
|
|
35
|
+
targetTriple = "codex"
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "win32":
|
|
42
|
+
switch (arch) {
|
|
43
|
+
case "x64":
|
|
44
|
+
targetTriple = "codex.exe";
|
|
45
|
+
break;
|
|
46
|
+
case "arm64":
|
|
47
|
+
targetTriple = "aarch64-pc-windows-msvc.exe";
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!targetTriple) {
|
|
58
|
+
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const binaryPath = path.join(__dirname, targetTriple);
|
|
62
|
+
|
|
63
|
+
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
64
|
+
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
65
|
+
// executing. This allows us to forward those signals to the child process
|
|
66
|
+
// and guarantees that when either the child terminates or the parent
|
|
67
|
+
// receives a fatal signal, both processes exit in a predictable manner.
|
|
68
|
+
const { spawn } = await import("child_process");
|
|
69
|
+
|
|
70
|
+
async function tryImport(moduleName) {
|
|
71
|
+
try {
|
|
72
|
+
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
73
|
+
return await import(moduleName);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function resolveRgDir() {
|
|
80
|
+
const ripgrep = await tryImport("@vscode/ripgrep");
|
|
81
|
+
if (!ripgrep?.rgPath) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return path.dirname(ripgrep.rgPath);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getUpdatedPath(newDirs) {
|
|
88
|
+
const pathSep = process.platform === "win32" ? ";" : ":";
|
|
89
|
+
const existingPath = process.env.PATH || "";
|
|
90
|
+
const updatedPath = [
|
|
91
|
+
...newDirs,
|
|
92
|
+
...existingPath.split(pathSep).filter(Boolean),
|
|
93
|
+
].join(pathSep);
|
|
94
|
+
return updatedPath;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const additionalDirs = [];
|
|
98
|
+
const rgDir = await resolveRgDir();
|
|
99
|
+
if (rgDir) {
|
|
100
|
+
additionalDirs.push(rgDir);
|
|
101
|
+
}
|
|
102
|
+
const updatedPath = getUpdatedPath(additionalDirs);
|
|
103
|
+
|
|
104
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
105
|
+
stdio: "inherit",
|
|
106
|
+
env: { ...process.env, PATH: updatedPath, CODEX_MANAGED_BY_NPM: "1" },
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
child.on("error", (err) => {
|
|
110
|
+
// Typically triggered when the binary is missing or not executable.
|
|
111
|
+
// Re-throwing here will terminate the parent with a non-zero exit code
|
|
112
|
+
// while still printing a helpful stack trace.
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.error(err);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Forward common termination signals to the child so that it shuts down
|
|
119
|
+
// gracefully. In the handler we temporarily disable the default behavior of
|
|
120
|
+
// exiting immediately; once the child has been signaled we simply wait for
|
|
121
|
+
// its exit event which will in turn terminate the parent (see below).
|
|
122
|
+
const forwardSignal = (signal) => {
|
|
123
|
+
if (child.killed) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
child.kill(signal);
|
|
128
|
+
} catch {
|
|
129
|
+
/* ignore */
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
134
|
+
process.on(sig, () => forwardSignal(sig));
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// When the child exits, mirror its termination reason in the parent so that
|
|
138
|
+
// shell scripts and other tooling observe the correct exit status.
|
|
139
|
+
// Wrap the lifetime of the child process in a Promise so that we can await
|
|
140
|
+
// its termination in a structured way. The Promise resolves with an object
|
|
141
|
+
// describing how the child exited: either via exit code or due to a signal.
|
|
142
|
+
const childResult = await new Promise((resolve) => {
|
|
143
|
+
child.on("exit", (code, signal) => {
|
|
144
|
+
if (signal) {
|
|
145
|
+
// eslint-disable-next-line no-console
|
|
146
|
+
console.error(`Child process exited with signal: ${signal}`);
|
|
147
|
+
resolve({ type: "signal", signal });
|
|
148
|
+
} else {
|
|
149
|
+
// eslint-disable-next-line no-console
|
|
150
|
+
console.error(`Child process exited with code: ${code ?? 1}`);
|
|
151
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (childResult.type === "signal") {
|
|
157
|
+
// Re-emit the same signal so that the parent terminates with the expected
|
|
158
|
+
// semantics (this also sets the correct exit code of 128 + n).
|
|
159
|
+
process.kill(process.pid, childResult.signal);
|
|
160
|
+
} else {
|
|
161
|
+
process.exit(childResult.exitCode);
|
|
162
|
+
}
|