From 7c0e9050400d1354bb1a748bf0b877f8131abf37 Mon Sep 17 00:00:00 2001 From: imMxts Date: Mon, 5 Oct 2026 16:17:54 +0200 Subject: [PATCH 1/3] chore: prepare isolated custom proxy worktrees --- README.md | 30 ++++++++++++++++++++++++++++++ scripts/setup.sh | 27 +++++++++++++++++++++++++++ t3.json | 20 ++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100755 scripts/setup.sh create mode 100644 t3.json diff --git a/README.md b/README.md index e2819281d4f..86e932f39f1 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,36 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file ## Local custom build +### Source worktree setup + +On macOS or Linux, install Go 1.26+ and the frontend's pinned Bun 1.3.14. +Then run `bash scripts/setup.sh` from a fresh checkout of this fork's `custom` +branch. It downloads Go modules, verifies their checksums, installs frozen Bun +dependencies, builds and embeds the custom panel, and builds `./cli-proxy-api`. +Generated output is ignored by Git. Repeating setup leaves tracked source files +alone. Setup does not install a service or copy credentials. + +Import the actions from `t3.json` into each T3 project and environment. Setup runs +when T3 creates a worktree and waits before the agent starts. Check runs +`bun run verify` in `web`, `go test -mod=readonly -p 2 ./...`, and a Go build. +A checked-in action still needs importing before it runs automatically. + +Independent tasks use separate branches and worktrees. Each checkout owns its +`web/node_modules`, `web/dist`, embedded panel, and binary. Do not run +`scripts/install-local.sh` as worktree setup; it replaces the Mac's installed +binary and restarts a service. + +For a development proxy, create a private, ignored config from +`config.example.yaml` with `server.host: "127.0.0.1"`, an unused `server.port`, +and a separate `oauth.auth-dir`. +Provider login callbacks also need unused ports; the CLI supports +`--oauth-callback-port`. Use `bun run dev -- --port --strictPort` +in `web` for a separate frontend. Never attach a test worktree to the production +proxy's config, account store, database, or Docker Compose project. Keep the +codingbox service and its existing port 8317 out of development runs. + +### Service installation + `scripts/install-local.sh` builds the bundled `web/` management UI, embeds it into the Go binary, and installs a launchd agent (`dev.local.cliproxyapi`) that runs the local build with `CPA_TRUST_LOCAL_PANEL=1`, which lets the panel served by this binary use the management API without a key from the same loopback origin. It stops the Homebrew `cliproxyapi` service first (the formula is left installed). Update flow: diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 00000000000..6dce4c24f96 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +for tool in go bun; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "Missing $tool. Install Go 1.26+ and Bun 1.3.14 before running setup." >&2 + echo "Go installation: https://go.dev/doc/install" >&2 + echo 'Bun installation: curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"' >&2 + exit 1 + fi +done + +if [[ "$(bun --version)" != "1.3.14" ]]; then + echo "This frontend pins Bun 1.3.14. Select that version before running setup." >&2 + echo 'Install it with: curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"' >&2 + exit 1 +fi + +go mod download +go mod verify +(cd web && bun install --frozen-lockfile && bun run build) +cp web/dist/index.html internal/managementasset/panel/management.html +go build -mod=readonly -p 2 -o cli-proxy-api ./cmd/server + +echo "Built ./cli-proxy-api with the custom management UI. No service was started." diff --git a/t3.json b/t3.json new file mode 100644 index 00000000000..75cffefa626 --- /dev/null +++ b/t3.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://t3.codes/schema/t3.json", + "defaultThreadEnvMode": "worktree", + "scripts": [ + { + "name": "Setup", + "command": "bash scripts/setup.sh", + "icon": "configure", + "runOnWorktreeCreate": true, + "async": false + }, + { + "name": "Check", + "command": "(cd web && bun run verify) && go test -mod=readonly -p 2 ./... && go build -mod=readonly -p 2 -o cli-proxy-api ./cmd/server", + "icon": "test", + "runOnWorktreeCreate": false, + "async": false + } + ] +} From 1660e45ab0efa7088c2d41b9263d6b3b2526f6d9 Mon Sep 17 00:00:00 2001 From: imMxts Date: Mon, 5 Oct 2026 16:24:29 +0200 Subject: [PATCH 2/3] chore: select isolated toolchains and stabilize model option tests --- README.md | 7 ++++++- scripts/check.sh | 8 ++++++++ scripts/setup.sh | 15 +-------------- scripts/toolchain.sh | 24 ++++++++++++++++++++++++ t3.json | 2 +- web/tests/providerModelOptions.test.ts | 23 ++++++++++++++++------- 6 files changed, 56 insertions(+), 23 deletions(-) create mode 100755 scripts/check.sh create mode 100644 scripts/toolchain.sh diff --git a/README.md b/README.md index 86e932f39f1..354b77d1217 100644 --- a/README.md +++ b/README.md @@ -338,8 +338,13 @@ dependencies, builds and embeds the custom panel, and builds `./cli-proxy-api`. Generated output is ignored by Git. Repeating setup leaves tracked source files alone. Setup does not install a service or copy credentials. +The commands use Bun 1.3.14 from PATH, or the machine's dedicated +`~/.local/share/codingbox/toolchains/bun/1.3.14/bin/bun`. Override that selection +with `BUN_BIN=/absolute/path/to/bun`. They leave other projects' Bun versions +alone. Go must be on PATH or installed at `~/.local/bin/go`. + Import the actions from `t3.json` into each T3 project and environment. Setup runs -when T3 creates a worktree and waits before the agent starts. Check runs +when T3 creates a worktree and waits before the agent starts. `bash scripts/check.sh` runs `bun run verify` in `web`, `go test -mod=readonly -p 2 ./...`, and a Go build. A checked-in action still needs importing before it runs automatically. diff --git a/scripts/check.sh b/scripts/check.sh new file mode 100755 index 00000000000..035cfb6b0f4 --- /dev/null +++ b/scripts/check.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." +source scripts/toolchain.sh + +(cd web && bun run verify) +go test -mod=readonly -p 2 ./... +go build -mod=readonly -p 2 -o cli-proxy-api ./cmd/server diff --git a/scripts/setup.sh b/scripts/setup.sh index 6dce4c24f96..2020de44f7f 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -3,20 +3,7 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." -for tool in go bun; do - if ! command -v "$tool" >/dev/null 2>&1; then - echo "Missing $tool. Install Go 1.26+ and Bun 1.3.14 before running setup." >&2 - echo "Go installation: https://go.dev/doc/install" >&2 - echo 'Bun installation: curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"' >&2 - exit 1 - fi -done - -if [[ "$(bun --version)" != "1.3.14" ]]; then - echo "This frontend pins Bun 1.3.14. Select that version before running setup." >&2 - echo 'Install it with: curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"' >&2 - exit 1 -fi +source scripts/toolchain.sh go mod download go mod verify diff --git a/scripts/toolchain.sh b/scripts/toolchain.sh new file mode 100644 index 00000000000..7dc1c18ed2c --- /dev/null +++ b/scripts/toolchain.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Sourced by the worktree setup and check commands. +if [[ -z "${BUN_BIN:-}" ]]; then + BUN_BIN=bun + if ! command -v bun >/dev/null 2>&1 || [[ "$(bun --version)" != "1.3.14" ]]; then + BUN_BIN="$HOME/.local/share/codingbox/toolchains/bun/1.3.14/bin/bun" + fi +fi +if ! command -v "$BUN_BIN" >/dev/null 2>&1 || [[ "$("$BUN_BIN" --version)" != "1.3.14" ]]; then + echo "Select Bun 1.3.14 with BUN_BIN=/path/to/bun." >&2 + echo 'Install it with: curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"' >&2 + exit 1 +fi + +if ! command -v go >/dev/null 2>&1; then + export PATH="$HOME/.local/bin:$PATH" +fi +if ! command -v go >/dev/null 2>&1; then + echo "Install Go 1.26+ first: https://go.dev/doc/install" >&2 + exit 1 +fi + +# Bun package scripts invoke bun again, so use the selected runtime throughout. +export PATH="$(dirname "$(command -v "$BUN_BIN")"):$PATH" diff --git a/t3.json b/t3.json index 75cffefa626..a65346461c8 100644 --- a/t3.json +++ b/t3.json @@ -11,7 +11,7 @@ }, { "name": "Check", - "command": "(cd web && bun run verify) && go test -mod=readonly -p 2 ./... && go build -mod=readonly -p 2 -o cli-proxy-api ./cmd/server", + "command": "bash scripts/check.sh", "icon": "test", "runOnWorktreeCreate": false, "async": false diff --git a/web/tests/providerModelOptions.test.ts b/web/tests/providerModelOptions.test.ts index d609322895d..a7bc96e63bd 100644 --- a/web/tests/providerModelOptions.test.ts +++ b/web/tests/providerModelOptions.test.ts @@ -1,6 +1,8 @@ import { describe, expect, test } from 'bun:test'; import { createElement } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; +import { createInstance } from 'i18next'; +import { I18nextProvider } from 'react-i18next'; import { readModelOptions, buildModelOptions, @@ -10,6 +12,9 @@ import { ModelAdvancedFields } from '@/features/providers/sheets/forms/ModelAdva import type { ModelEntryInput, ProviderBrand } from '@/features/providers/types'; import type { ModelAlias } from '@/types'; +const i18n = createInstance(); +await i18n.init({ lng: 'en', resources: { en: { translation: {} } } }); + const draft = (model: ModelAlias): ModelEntryInput => ({ name: model.name, thinkingJson: model.thinking === undefined ? undefined : JSON.stringify(model.thinking), @@ -174,13 +179,17 @@ describe('provider model options', () => { const render = (brand: ProviderBrand, disabled = false, enabled = true) => renderToStaticMarkup( - createElement(ModelAdvancedFields, { - entry: { name: 'model', thinkingEnabled: enabled }, - providerBrand: brand, - disabled, - supportsThinking: true, - onUpdate: () => {}, - }) + createElement( + I18nextProvider, + { i18n }, + createElement(ModelAdvancedFields, { + entry: { name: 'model', thinkingEnabled: enabled }, + providerBrand: brand, + disabled, + supportsThinking: true, + onUpdate: () => {}, + }) + ) ); test('gates fields by provider capability', () => { From f7f2effaa605422a8645d76f1fdf4de21eeefc33 Mon Sep 17 00:00:00 2001 From: imMxts Date: Mon, 5 Oct 2026 16:29:48 +0200 Subject: [PATCH 3/3] chore: refresh embedded panel during worktree checks --- scripts/check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check.sh b/scripts/check.sh index 035cfb6b0f4..b73cfc7b0de 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -4,5 +4,6 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.." source scripts/toolchain.sh (cd web && bun run verify) +cp web/dist/index.html internal/managementasset/panel/management.html go test -mod=readonly -p 2 ./... go build -mod=readonly -p 2 -o cli-proxy-api ./cmd/server