krz/gitbay

A CLI-first git forge.

clone: git clone https://gitbay.org/krz/gitbay.git

main: internal/protocol/protocol.go · raw

 1// Package protocol defines the wire contract shared by the CLI and server:
 2// exit codes, the JSON response envelope, and (later) the SSH command
 3// tokenizer.
 4package protocol
 5
 6// Version is the control-plane protocol version. It is embedded in every JSON
 7// response envelope; clients check it opportunistically and refuse on major
 8// mismatch. Bump the major on breaking envelope or command changes.
 9const Version = 1
10
11// Exit codes shared by the CLI and by control commands run over bare ssh.
12const (
13	ExitOK        = 0
14	ExitFailure   = 1 // general failure
15	ExitUsage     = 2 // usage error
16	ExitNotFound  = 3
17	ExitDenied    = 4
18	ExitProtocol  = 5 // server/protocol error
19)
20
21// Envelope wraps every JSON response from a control command.
22type Envelope struct {
23	ProtocolVersion int    `json:"protocol_version"`
24	Data            any    `json:"data,omitempty"`
25	Error           string `json:"error,omitempty"`
26}