Skip to content

Components

The pkg directory contains the reusable library components that power gtb applications. These packages are designed to be modular, testable, and strictly typed.

Core Components

Component Package Description
Props pkg/props The dependency injection container. Holds global state like configuration, logger, and filesystem interfaces.
Config pkg/config Robust configuration management wrapping generic Viper usage with type safety and interface-based testability.
Logger pkg/logger Unified logging abstraction with charmbracelet, slog, and noop backends.
Commands cmd/ Built-in Cobra commands for configuration (init), updates (version, update), interactive browser (docs), and agentic workflows (mcp).
Error Handling pkg/errorhandling Centralized error reporting and formatting, ensuring consistent exit codes and log output.
Output pkg/output Dual-format (text/JSON) structured output for scriptable CLI commands.
Version pkg/version Semantic version parsing, comparison, and development-build detection.

Advanced Features

Component Package Description
Controls pkg/controls Service orchestration and lifecycle management for long-running processes (e.g., servers, watchers).
Setup pkg/setup bootstrapping logic for tool initialization, including GitHub authentication and self-updates.
VCS pkg/vcs/... Git operations, GitHub/GitLab API clients, and backend-agnostic release provider.
Chat pkg/chat Multi-provider AI client (OpenAI, Anthropic, Gemini) for building intelligent features.
Docs pkg/docs Logic for the interactive TUI documentation browser.
Forms pkg/forms Multi-step interactive CLI form helpers with Escape-to-go-back navigation, built on charmbracelet/huh.
Utils pkg/utils General-purpose utility functions for path resolution and system checks.

Web Service

Components for running a CLI as a long-lived service. See also Controls for the lifecycle management they register against.

Component Package Description
gRPC pkg/grpc gRPC server wired to the controller, with health, reflection, interceptors and TLS โ€” plus DialLocal and client credentials for in-process callers.
HTTP pkg/http Hardened HTTP server and client, health endpoints, middleware chains, and per-server config prefixes.
TLS pkg/tls Shared hardened TLS config, the typed Pair, shared/per-transport resolution, and client cert-pool helpers.
Gateway pkg/gateway grpc-gateway as a first-class transport: REST-to-gRPC, mounted or as its own server.
OpenAPI pkg/openapi Serve an OpenAPI spec and an embedded Stoplight Elements docs site.

Testing Support

Component Package Description
Mocks pkg/mocks Auto-generated Mockery definitions for all core interfaces to simplify unit testing.

Internal Development

  • Internal Packages: Documentation for the private internal/ packages that power the CLI generator itself. (Contributors Only)