This file provides guidance to AI coding agents when working with code in this repository.
This repository contains:
- Protocol Buffer definitions (
proto/) - service and message definitions for Cofide's APIs - Generated code (
gen/) - auto-generated Go and TypeScript stubs from the proto files - Go client library (
pkg/connect/client/) - hand-written wrapper clients for the Cofide Connect API
All APIs are versioned as v1alpha1 (backward compatibility not guaranteed).
Commands use Just as the task runner.
| Command | Purpose |
|---|---|
just fmt |
Format proto files (buf format -w) |
just lint |
Lint proto files and Go source |
just buf-lint |
Lint proto files only |
just go-lint |
Run golangci-lint only |
just proto-gen |
Regenerate Go and TypeScript stubs from proto files |
just proto-docs |
Generate Markdown API docs (to docs/, git-ignored) |
just test |
Run Go tests |
just test-race |
Run Go tests with race detector |
To run a single test package: go run gotest.tools/gotestsum@latest -- ./pkg/connect/client/...
To run with -run: go run gotest.tools/gotestsum@latest -- -run TestName ./...
The project follows a strict layered pattern:
-
proto/- Source of truth. 13 gRPC services defined underproto/connect/, plus domain message types across 20+ packages. All inv1alpha1. -
gen/go/- Auto-generated, do not edit manually. Regenerate withjust proto-gen. Mirrors theproto/directory structure. -
pkg/connect/client/- Hand-written Go clients. Each service gets its own package (e.g.,pkg/connect/client/cluster/v1alpha1/). TheClientSetinterface inclientset.goaggregates all service clients into a single accessor.New(conn grpc.ClientConnInterface)constructs aClientSet.
pkg/connect/client/fake/ contains fake implementations of every service client for use in tests. These implement the same interfaces as the real clients. Test utilities live in pkg/connect/client/test/.
pkg/connect/client/clientset.go-ClientSetinterface +New()constructorpkg/connect/client/config.go-Configstruct (ConnectURL + ConnectTrustDomain)buf.gen.yaml- Code generation config (4 plugins: protoc-gen-go, protoc-gen-connect-go, grpc/go, bufbuild/es)buf.yaml- Buf linting rules (STANDARD minus FIELD_NOT_REQUIRED and PACKAGE_NO_IMPORT_CYCLE)
When adding a new service, the typical flow is:
- Add proto definition under
proto/connect/<service_name>_service/ - Run
just proto-gento generate stubs ingen/ - Create a wrapper client package at
pkg/connect/client/<service_name>/v1alpha1/ - Add fake implementation in
pkg/connect/client/fake/ - Register the new client in
ClientSetinterface andclientSetstruct inclientset.go
Required tools for just proto-gen:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.5go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest- Buf CLI