Skip to content

Development

root edited this page Dec 4, 2026 · 6 revisions

Development Guide

🌐 English · 简体中文

This guide covers Trizano's local toolchain requirements, Makefile targets, test suite, Protobuf contract generation, engineering conventions, and release process for contributors. For the overall system architecture and directory layout, see Architecture.

Toolchain and PATH

Make sure go, pnpm, buf, protoc-gen-go, and protoc-gen-connect-go are installed and available on your PATH. The repository Makefile prepends /usr/local/go/bin, $HOME/go/bin, and /opt/node24/bin to PATH when invoking targets; when running commands directly in your shell, ensure your own installation directories are on PATH.

Tool / Runtime Requirement Source of Truth Purpose
Go 1.27.4 server/go.mod, desktop-go/go.mod Build Hub, Node, and MyGo desktop app
Node.js 24 .github/workflows/desktop*.yml Web build, typecheck, and vitest
pnpm 12.23.0 Root package.json (packageManager) Manage web and packages/* workspace dependencies (pnpm-workspace.yaml)
buf & Go protoc plugins buf v2, protoc-gen-go, protoc-gen-connect-go buf.yaml, buf.gen.yaml Lint and generate Go / TS contract code from proto/ (the TS plugin @bufbuild/protoc-gen-es installs via pnpm install)
JDK & Android SDK (optional) JDK 17, Android compileSdk 36 android/app/build.gradle.kts Build and test the Android client (set ANDROID_HOME or android/local.properties)
Desktop packaging tools (optional) nsis on Linux (Windows installer); hdiutil on macOS (.dmg) .github/workflows/desktop-go.yml, desktop.yml Package local desktop installers

After cloning the repository, install frontend workspace dependencies first:

pnpm install

Makefile Targets

Common build, development, and test workflows are consolidated in the root Makefile. VERSION is derived automatically from git describe --tags --match 'v*' (exact tag → <ver>, commits after tag → <ver>-dev, no tags → 0.0.0-dev) and injected into server/internal/version.Version via -ldflags.

Target Behavior
make gen Runs buf lint and buf generate, regenerating server/gen and packages/proto-ts/src/gen from proto/
make web Runs pnpm --filter @trizano/web build (tsc --noEmit && vite build), writing output to server/hub/webui/dist
make dist Cross-compiles trizano-h3 with CGO_ENABLED=0 for all 6 platforms (linux/darwin/windows × amd64/arm64) into bin/dist/
make build Runs web and dist, then builds bin/trizano-carbon with embedded Web UI (-tags embedweb) and host bin/trizano-h3
make hub-release Runs web and dist, then packages Hub release tarballs (trizano-carbon, trizano-h3, and dist/) for linux/amd64, linux/arm64, darwin/arm64, and darwin/amd64 into bin/release/
make release Runs hub-release and android, collecting all four Hub tarballs, the Release APK, and SHA256SUMS into bin/release/
make test Runs go vet ./..., GOOS=windows go vet ./..., and TRIZANO_TEST_SSHD=1 go test -race ./... in server/, followed by pnpm --filter @trizano/web typecheck
make dev Runs dist, builds host bin/trizano-h3, and starts trizano-carbon on 127.0.0.1:47900 with --origin http://localhost:5733
make dev-web Starts the Vite dev server on 127.0.0.1:5733, proxying /trizano.hub.v1. and /nodes/ to the Hub; pair with make dev in a second terminal
make desktop-go Runs web, then invokes desktop-go/scripts/build.sh to package the MyGo desktop app; pass DESKTOP_PLATFORM=linux/amd64,windows/amd64 to cross-package
make android Runs ./gradlew :app:assembleRelease in android/ to produce an R8-shrunk Release APK
make android-test Runs build, then executes ./gradlew :app:testDebugUnitTest (including HubContractTest driving the real bin/trizano-carbon)
make clean Removes bin, server/hub/webui/dist, desktop-go/build, and desktop-go/resources

A trizano-carbon binary built without -tags embedweb does not serve the Web UI (server/hub/webui/webui.go returns a short development hint). During development, always open http://localhost:5733.

Test Suite

Automated tests never invoke real external agent CLIs. Every end-to-end scenario runs locally against fake binaries, emulators, and ephemeral daemons.

Running Individual Test Suites

make test covers server-side Go vet/race tests and Web TypeScript checks, but does not run Web vitest unit tests or desktop-go tests. Run them directly when editing those modules:

# Server end-to-end test through the Hub
cd server && go test -race -run TestSessionThroughHub ./hub/

# Single driver package test
cd server && go test -run TestName ./node/driver/claude/

# MyGo desktop app (not included in make test)
cd desktop-go && go vet ./... && GOOS=windows go vet ./... && GOOS=darwin go vet ./... && go test -race ./...

# Web unit tests (vitest, not included in make test)
pnpm --filter @trizano/web test
pnpm --filter @trizano/web exec vitest run src/lib/diff.test.ts

# Android unit tests
cd android && ./gradlew :app:testDebugUnitTest --tests '*AgentBrandTest'

Fake CLIs, Ephemeral SSH, and Cross-Platform Testing

  • Fake agent CLIs (server/hub/testdata/): End-to-end tests build fakeclaude, fakecodex, and fakeacp via go build into temporary executables named claude, codex, and opencode inside t.TempDir(), prepending that directory to PATH (see server/hub/e2e_test.go, agents_e2e_test.go, discussion_e2e_test.go).
  • WSL / PowerShell emulators: server/hub/testdata/fakewsl and fakepowershell emulate Windows wsl.exe and PowerShell so server/hub/wsl_e2e_test.go can test WSL Node probing, bootstrapping, and Sessions on Linux.
  • Ephemeral sshd tests: TestSSHNode (server/hub/ssh_e2e_test.go) and TestSSHWSLNode (server/hub/wsl_e2e_test.go) start a temporary sshd on 127.0.0.1 to bootstrap the Node daemon. They run only when TRIZANO_TEST_SSHD=1 is set (enabled by make test).
  • Windows compilation checks and platform-specific tests: make test runs GOOS=windows go vet ./... so Windows cross-compilation stays green. Place Unix-only tests in *_unix_test.go (with //go:build !windows) and Windows-only tests in *_windows_test.go. The CI workflow .github/workflows/windows.yml runs go test -count=1 -run "^TestWindows" ./... on windows-latest and runs TestWindowsSSHNode against native OpenSSH Server with cmd.exe, Windows PowerShell, and PowerShell 7 as the default shell.
  • Claude non-root test convention: TestMain in server/node/driver/claude/main_test.go sets the package variable asRoot to false to cover regular non-root behavior; the root-user restriction branch is tested explicitly by TestRoot in server/node/driver/claude/catalog_test.go.

Contract Changes and Code Generation

Protobuf is the single source of truth shared by the Hub, Nodes, and all three clients. Edit proto/ and run make gen—never edit generated files by hand.

  • Schema directories: proto/trizano/hub/v1/, proto/trizano/node/v1/, and proto/trizano/roster/v1/.
  • Generated outputs: buf.gen.yaml generates two checked-in trees—server/gen/ (protoc-gen-go + protoc-gen-connect-go) and packages/proto-ts/src/gen/ (protoc-gen-es). Android does not commit generated code; Gradle generates it directly from proto/ at build time.
  • Compatibility checks: buf.yaml enables STANDARD lint rules and FILE-level breaking-change detection. Removing fields or breaking wire compatibility fails make gen.
  • Zero-routing-change rule: Because the Hub reverse-proxies /nodes/{node}/<procedure> verbatim to Nodes, adding a new RPC to trizano.node.v1 typically only requires editing proto/, running make gen, and implementing the handler in server/node/—no Hub routing changes needed (see Architecture).

Engineering Conventions

The codebase follows a "no defensive code" and single-responsibility discipline:

  • Validate once at trust boundaries: Validate at network ingress, auth middleware, resource-name parsing, and proto field constraints. Internal code trusts static types and caller contracts—avoid redundant nil checks and "just in case" fallback branches.
  • Propagate typed errors to the UI: Preserve Connect error codes all the way to the client. Do not swallow errors, silently degrade, or paper over missing state with defaults.
  • Single owner per state domain: Every piece of mutable state belongs to one owner (such as a Session actor goroutine, a Node connection supervisor, or the review catalog owner). Other goroutines communicate via messages rather than scattering locks.
  • Keep retries in the connection layer: SSH reconnection, Reverse Node exponential backoff, and event-stream resumption live in the connection layer and expose visible state. Business RPC layers must not hide implicit retries.
  • Sanitize external bytes to valid UTF-8 before protobuf: Clean output from external processes (SSH, agent CLIs, Git, terminal OSC) with strings.ToValidUTF8(s, "\uFFFD") before writing to proto3 string fields, and truncate only on UTF-8 rune boundaries so a single malformed byte never breaks an event stream.
  • Probe capabilities from CLIs; never hardcode: Models, reasoning effort, modes, options, and rate limits are probed live by drivers and cached per CLI version—never hardcoded in servers or clients (see Agent Drivers).
  • Preserve extension boundaries: Keep existing extension interfaces (driver.Driver, nodes.Dialer, etc.) intact when refactoring or trimming features.
  • Languages and commit format: Write code comments and git commit messages in English, strictly using Conventional Commits (feat(approval): ..., fix(sync): ..., docs(wiki): ...). UI strings, user-facing errors, and internal design docs in docs/ are in Chinese; README and the wiki are maintained in both English and Chinese and updated together.

Release Process

Pushing a v* tag triggers .github/workflows/desktop.yml to build and publish all desktop installers, Hub release tarballs, and the Android APK. Update client versions before tagging (trizano-carbon and trizano-h3 versions are injected automatically from the git tag via Makefile's VERSION).

1. Bump Client Versions

Update both files in the release commit:

Client File Field
Desktop (MyGo) desktop-go/mygo.json "version"
Android android/app/build.gradle.kts versionName and incremented versionCode

2. Tagging, CI Jobs, and Artifact Names

After committing the version bump, push a v<version> tag (for example v0.9.1). .github/workflows/desktop.yml runs three jobs in parallel; once all succeed, publish-release creates or updates the matching GitHub Release (gh release upload --clobber):

  • Desktop (MyGo, via .github/workflows/desktop-go.yml):
    • The Ubuntu runner runs three-platform go vet and go test -race ./... in desktop-go/, then cross-builds Linux packages (.deb, .rpm, .tar.gz, install.sh) and the Windows installer (*-setup-*.exe).
    • The macOS runner builds the darwin/arm64 .dmg.
    • Pushes to main touching desktop-go/** or .github/workflows/desktop-go.yml also trigger this workflow automatically (without creating a Release).
  • Hub tarballs (build-hub): Runs make hub-release on ubuntu-latest, producing trizano_<version>_<os>_<arch>.tar.gz for linux/amd64, linux/arm64, darwin/arm64, and darwin/amd64 (each containing trizano-carbon, trizano-h3, and the 6-platform dist/ directory).
  • Android Release APK (build-android): Runs ./gradlew :app:assembleRelease with JDK 17 on ubuntu-latest, outputting trizano_<version>_android.apk.

3. Android Signing Secrets

To support in-place APK upgrades without reinstalling on phones, configure a persistent signing keystore in GitHub repository Secrets:

  • ANDROID_KEYSTORE_BASE64: Base64-encoded keystore file; CI decodes it to a temporary path and exports ANDROID_KEYSTORE_PATH.
  • ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD: Optional; when unset, android/app/build.gradle.kts defaults to "android", "androiddebugkey", and "android" respectively.
  • If ANDROID_KEYSTORE_BASE64 is not set, release builds automatically fall back to signing with the debug keystore.

Clone this wiki locally